When is "greater than" really "greater than" cis-lclient02:~/2012/quiz23>more maingt.c #include int gt1(int a, int b); int gt2(int a, int b); main () { int twob = 2000000000; printf("%d\n", gt1(twob, -twob)); printf("%d\n", gt2(twob, -twob)); } int gt1(int a, int b) { if (a >= b) return 1; else return 0; } int gt2(int a, int b) { if (a - b >= 0) return 1; else return 0; } cis-lclient02:~/2012/quiz23>gcc maingt.c cis-lclient02:~/2012/quiz23>./a.out 1 0 cis-lclient02:~/2012/quiz23>gcc -S maingt.c cis-lclient02:~/2012/quiz23>more maingt.s .file "maingt.c" .section .rodata .LC0: .string "%d\n" .text .globl main .type main, @function main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $32, %esp movl $2000000000, 28(%esp) movl 28(%esp), %eax negl %eax movl %eax, 4(%esp) movl 28(%esp), %eax movl %eax, (%esp) call gt1 movl $.LC0, %edx movl %eax, 4(%esp) movl %edx, (%esp) call printf movl 28(%esp), %eax negl %eax movl %eax, 4(%esp) movl 28(%esp), %eax movl %eax, (%esp) call gt2 movl $.LC0, %edx movl %eax, 4(%esp) movl %edx, (%esp) call printf leave ret .size main, .-main .globl gt1 .type gt1, @function gt1: pushl %ebp movl %esp, %ebp movl 8(%ebp), %eax cmpl 12(%ebp), %eax jl .L4 movl $1, %eax jmp .L5 .L4: movl $0, %eax .L5: popl %ebp ret .size gt1, .-gt1 .globl gt2 .type gt2, @function gt2: pushl %ebp movl %esp, %ebp movl 12(%ebp), %eax movl 8(%ebp), %edx movl %edx, %ecx subl %eax, %ecx movl %ecx, %eax testl %eax, %eax js .L8 movl $1, %eax jmp .L9 .L8: movl $0, %eax .L9: popl %ebp ret .size gt2, .-gt2 .ident "GCC: (GNU) 4.4.4 20100630 (Red Hat 4.4.4-10)" .section .note.GNU-stack,"",@progbits cis-lclient02:~/2012/quiz23>