int main (void) { return 1; } Ubuntu Jaunty. gcc --save-temps -fno-stack-protector -fomit-frame-pointer -Os ./cpuid.c generates thgis: -------------- main: leal 4(%esp), %ecx andl $-16, %esp pushl -4(%ecx) movl $1, %eax pushl %ecx popl %ecx leal -4(%ecx), %esp ret -------------------------- why i get this: pushl %ecx popl %ecx and other non-needed instructions (for another example) pushl %ebp andl $1, %eax movl %esp, %ebp pushl %ecx popl %ecx popl %ebp These instructions are not optimized not in -O3, nor in -Os
gcc322 generates this: (gcc -Os -fomit-frame-pointer qwe.c --save-temps) main: movl $1, %eax ret WTF?
It aligns the incoming stack. Fixed in 4.4/4.5.