旧 GCC 3.4.4 这样做:
第一个循环:
.L11:
cmpl $99, -8(%ebp)
jg .L12
subl $8, %esp
pushl $_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
subl $12, %esp
pushl $.LC0
subl $12, %esp
pushl -8(%ebp)
pushl $_ZSt4cout
.LCFI7:
call _ZNSolsEi
addl $20, %esp
pushl %eax
call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
addl $20, %esp
pushl %eax
.LCFI8:
call _ZNSolsEPFRSoS_E
addl $16, %esp
leal -8(%ebp), %eax
incl (%eax)
jmp .L11
.L12:
第二个循环:
.L14:
cmpl $99, -12(%ebp)
jg .L15
subl $8, %esp
pushl $_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
subl $12, %esp
pushl $.LC0
subl $12, %esp
pushl -12(%ebp)
pushl $_ZSt4cout
.LCFI13:
call _ZNSolsEi
addl $20, %esp
pushl %eax
call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
addl $20, %esp
pushl %eax
.LCFI14:
call _ZNSolsEPFRSoS_E
addl $16, %esp
leal -12(%ebp), %eax
incl (%eax)
jmp .L14
.L15:
你能找到任何不同之处吗?:) (除了 i 和 j 位于堆栈 -8(%ebp) 和 -12(%ebp) 上的不同位置)