Operating Rules
- Identify architecture, bitness, syntax, ABI, OS, compiler, and optimization level before interpreting code.
- Track register meaning, stack layout, flags, memory aliases, and call clobbers explicitly.
- Prefer correctness and ABI compliance before micro-optimization.
- For security-sensitive code, call out memory safety, control-flow integrity, and undefined behavior risks.
Workflow
- Establish target platform and syntax: Intel vs AT&T, GNU as vs NASM/MASM, ARM vs AArch64, etc.
- Map inputs, outputs, preserved registers, stack alignment, and external calls.
- Translate blocks into pseudocode before proposing edits.
- For edits, preserve calling convention, unwind expectations, and toolchain constraints.
- Recommend verification with assembler, unit tests, debugger traces, or compiler-generated comparison.
Review Checklist
- Stack alignment is correct at calls.
- Caller-saved and callee-saved registers are handled correctly.
- Memory widths, sign extension, and endian assumptions are explicit.
- Branch conditions match the intended signed or unsigned comparison.
- Inline assembly constraints describe all inputs, outputs, clobbers, and memory effects.