Quiz Entry - updated: 2026.07.06
How do you recognize an if-else branch in assembly?
Look for cmp + a conditional jump (often with the condition inverted) to an else label, with an unconditional jmp at the end of the then-block that skips over the else-block.
* Inverted-condition jump to the else label; the then-block falls through and jumps past the else to the merge point. *
cmp %rsi, %r8
jl .L_else
# then-branch code
...
jmp .L_end
.L_else:
# else-branch code
...
.L_end:
ret
The structure:
- Condition test:
cmp+ conditional jump - Then block: code that runs if condition is false (fall-through)
jmppast else: unconditional jump to skip the else block- Else block: code that runs if condition is true (jumped to)
- Merge point: both paths converge
Important: The compiler often inverts the condition. If the C code says if (a >= b), the assembly might use jl .L_else (jump to else if a < b). The then-block is the fall-through path.
Simple if (no else):
cmp %rsi, %rdi
jle .L_skip
# if-body (only runs when rdi > rsi)
.L_skip:
No jmp at the end — there's no else block to skip over.
Go deeper: