int func1(int a, int b) { int x, y, r; x = a + b; y = 2*x - b; return x*y; } ----------------------------------------------------- .file "func1.c" .version "01.01" gcc2_compiled.: .text .align 4 .globl func1 .type func1,@function func1: pushl %ebp // Setup Stack movl %esp,%ebp movl 12(%ebp),%ecx // Get b movl %ecx,%edx addl 8(%ebp),%edx // %edx = a + b = x leal (%edx,%edx),%eax // %eax = 2*x subl %ecx,%eax // %eax = 2*x - b = y imull %eax,%edx // %edx = x*y movl %edx,%eax // move result into %eax movl %ebp,%esp // Stack stuff popl %ebp ret .Lfe1: .size func1,.Lfe1-func1 .ident "GCC: (GNU) 2.95.3 20010315 (release)" ----------------------------------------------------- int func2(int a, int b) { if ( (a - b) > 0 ) return a; else return b; } ----------------------------------------------------- .file "func2.c" .version "01.01" gcc2_compiled.: .text .align 4 .globl func2 .type func2,@function func2:s pushl %ebp //Setup Stack movl %esp,%ebp movl 8(%ebp),%ecx // Get a movl 12(%ebp),%edx // Get b movl %ecx,%eax // %eax = a subl %edx,%eax // %eax = a-b testl %eax,%eax // test %eax jg .L3 // if test > 0 jump to .L3 movl %edx,%eax // result = a jmp .L5 .p2align 4,,7 .L3: movl %ecx,%eax // result = b .L5: movl %ebp,%esp // Stack stuff popl %ebp ret .Lfe1: .size func2,.Lfe1-func2 .ident "GCC: (GNU) 2.95.3 20010315 (release)" ----------------------------------------------------- #define foo1 "I am a string" int func3(int a, int b) { int r; char s[100]; switch(a) { case 0: r = a; break; case 1: r = b; break; case 2: r = a+b; break; case 3: r = a-b; break; case 4: r = a*b; break; default: scanf("%s",s); strcat(s,foo1); r = 0; break; } return r; } ----------------------------------------------------- .file "func3.c" .version "01.01" gcc2_compiled.: .section .rodata // Read only section for strings .LC0: .string "%s" .LC1: .string "I am a string" .text .align 4 .globl func3 .type func3,@function func3: pushl %ebp // Stack Stuff movl %esp,%ebp subl $112,%esp pushl %esi // Saving registers for local use pushl %ebx movl 8(%ebp),%eax // get a movl 12(%ebp),%edx // get b cmpl $4,%eax // test value of a - 4 ja .L9 // if (a > 4), default case jmp *.L10(,%eax,4) // jump to (.L10 + 4a) .p2align 4,,7 .section .rodata // Read-Only section for jump table .align 4 .align 4 .L10: // the jump table .long .L3 // case 0 .long .L5 // case 1 .long .L6 // case 2 .long .L7 // case 3 .long .L8 // case 4 .text .p2align 4,,7 .L5: movl %edx,%eax jmp .L3 .p2align 4,,7 .L6: addl %edx,%eax jmp .L3 .p2align 4,,7 .L7: subl %edx,%eax jmp .L3 .p2align 4,,7 .L8: imull %edx,%eax jmp .L3 .p2align 4,,7 .L9: addl $-8,%esp leal -100(%ebp),%ebx pushl %ebx pushl $.LC0 call scanf addl $-8,%esp pushl $.LC1 // referring to string in .rodata pushl %ebx call strcat xorl %eax,%eax // result = 0 .L3: movl -120(%ebp),%ebx movl %ebp,%esp popl %ebp ret .Lfe1: .size func3,.Lfe1-func3 .ident "GCC: (GNU) 2.95.3 20010315 (release)" -----------------------------------------------------