下と同じソース。callは無くなったけど、_sumまではジャンプして、結局スタックを積んでるような。
「-O3」にしたら最適化された。
.file "foo.c" .text .p2align 4,,15 .def _sum; .scl 3; .type 32; .endef _sum: pushl %ebp movl %eax, %ecx movl %esp, %ebp movl %edx, %eax jmp L3 .p2align 4,,7 L6: addl %ecx, %eax decl %ecx L3: cmpl $1, %ecx jne L6 popl %ebp ret .def ___main; .scl 2; .type 32; .endef .section .rdata,"dr" LC0: .ascii "%d\12\0" .text .p2align 4,,15 .globl _main .def _main; .scl 2; .type 32; .endef _main: pushl %ebp movl $16, %eax movl %esp, %ebp subl $8, %esp andl $-16, %esp call __alloca call ___main movl $5, %edx movl $4, %eax call _sum movl %eax, 4(%esp) movl $LC0, (%esp) call _printf leave xorl %eax, %eax ret .def _printf; .scl 3; .type 32; .endef