You could look up your CPU manual, or you could just ask the compiler
gcc -c foo.c
objdump -d foo.o
Where foo.c is just your function in a simple method. The output is
00000000 <_foo>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 ec 10 sub $0x10,%esp
6: c7 45 fc 02 00 00 00 movl $0x2,-0x4(%ebp)
d: c7 45 f8 03 00 00 00 movl $0x3,-0x8(%ebp)
14: 8b 45 fc mov -0x4(%ebp),%eax
17: 3b 45 f8 cmp -0x8(%ebp),%eax
1a: 7e 09 jle 25 <_foo+0x25>
1c: c7 45 fc 01 00 00 00 movl $0x1,-0x4(%ebp)
23: eb 07 jmp 2c <_foo+0x2c>
25: c7 45 fc 04 00 00 00 movl $0x4,-0x4(%ebp)
2c: c9 leave
2d: c3 ret
2e: 90 nop
2f: 90 nop
The stuff at the start is setting up the stack / dealing with the calling convention, the important bit is this
17: 3b 45 f8 cmp -0x8(%ebp),%eax
1a: 7e 09 jle 25 <_foo+0x25>
1c: c7 45 fc 01 00 00 00 movl $0x1,-0x4(%ebp) // i = 1;
23: eb 07 jmp 2c <_foo+0x2c>
25: c7 45 fc 04 00 00 00 movl $0x4,-0x4(%ebp) // i = 4;
In this case its just a cmp
, followed by a jle
- the "if" part of the statement ends with a jmp
to skip over the else part of the statement.