I'm wondering if the problem is the wrong target architecture. Notice the line at the top of the assembly - "Machine type IA32." I'm compiling on a Pentium 4. The compiler was downloaded/installed by Gentoo's portage system (and I do have -march=pentium4 in my system's default CCFLAGS).
Just out of curiousity, I compiled with -O2 -march=pentium4 and the program worked. With -O2 -march=i686 and -O2 -march=i386 it was busted.
--
James
Code: Select all
# -- Machine type IA32
# mark_description "Intel(R) C++ Compiler for applications running on IA-32, Version 10.0 Build 20070809 %s";
# mark_description "-O2 -S -c";
.file "main.c"
.text
<snip>
..B3.3: # Preds ..B3.21
xorl %edx, %edx #34.7
xorl %eax, %eax #34.7
# LOE eax edx
..B3.4: # Preds ..B3.8 ..B3.3
movl %eax, 4(%esp) #36.8
movl %eax, (%esp) #36.8
movl %edx, 16(%esp) #36.8
xorl %esi, %esi #35.3
xorl %ebp, %ebp #35.3
xorl %ebx, %ebx #35.3
xorl %ecx, %ecx #35.3
movl $8, %edi #36.8
movl %edi, 8(%esp) #36.8
movl %edi, %edx #36.8
lea -448(%eax), %edi #36.8
movl 4(%esp), %eax #36.8
movl %edi, 12(%esp) #36.8
# LOE eax edx ecx ebx ebp esi
..B3.5: # Preds ..B3.6 ..B3.4
movl 16(%esp), %edi #38.13
subl %edx, %edi #38.13
js ..B3.18 # Prob 1% #38.16
# LOE eax edx ecx ebx ebp esi
..B3.6: # Preds ..B3.5
orl -64+bm_mask(%eax), %esi #39.4
movl %esi, %ebx #39.4
movl 12(%esp), %edi #36.14
addl $8, %edx #36.16
orl -60+bm_mask(%eax), %ebp #39.4
movl %ebp, %ecx #39.4
addl $-64, %eax #36.16
cmpl %eax, %edi #36.14
jb ..B3.5 # Prob 85% #36.14
# LOE eax edx ecx ebx ebp esi
..B3.7: # Preds ..B3.6
movl (%esp), %eax #
movl 16(%esp), %edx #
movl %esi, to_boundary(%eax) #39.4
movl %ebp, 4+to_boundary(%eax) #39.4
# LOE eax edx al dl ah dh
..B3.8: # Preds ..B3.7 ..B3.18
addl $8, %eax #34.16
addl $1, %edx #34.16
cmpl $64, %edx #34.13
jl ..B3.4 # Prob 98% #34.13
# LOE eax edx
..B3.9: # Preds ..B3.8
movl 288+to_boundary, %ecx #44.13
movl 292+to_boundary, %edx #44.13
xorl %eax, %eax #44.2
movl %eax, %ebp #44.2
movl %edx, %esi #44.2
movl %ecx, %edi #44.2
# LOE ebx ebp esi edi
..B3.10: # Preds ..B3.14 ..B3.9
movl bm_mask(,%ebp,8), %edx #44.2
movl 4+bm_mask(,%ebp,8), %eax #44.2
andl %edi, %edx #44.2
andl %esi, %eax #44.2
orl %eax, %edx #44.2
je ..B3.12 # Prob 50% #44.2
# LOE ebx ebp esi edi
..B3.11: # Preds ..B3.10
pushl $_2__STRING.0.0 #44.2
call printf #44.2
jmp ..B3.27 # Prob 100% #44.2
# LOE ebx ebp esi edi
..B3.12: # Preds ..B3.10
pushl $_2__STRING.1.0 #44.2
call printf #44.2
# LOE ebx ebp esi edi
..B3.27: # Preds ..B3.11 ..B3.12
popl %ecx #44.2
# LOE ebx ebp esi edi
..B3.13: # Preds ..B3.27
movl %ebp, %eax #44.2
andl $-2147483641, %eax #44.2
jge ..B3.24 # Prob 50% #44.2
# LOE eax ebx ebp esi edi
..B3.25: # Preds ..B3.13
decl %eax #44.2
orl $-8, %eax #44.2
incl %eax #44.2
# LOE eax ebx ebp esi edi
..B3.24: # Preds ..B3.13 ..B3.25
cmpl $7, %eax #44.2
je ..B3.17 # Prob 5% #44.2
# LOE ebx ebp esi edi
..B3.14: # Preds ..B3.29 ..B3.24
addl $1, %ebp #44.2
cmpl $64, %ebp #44.2
jl ..B3.10 # Prob 98% #44.2
# LOE ebx ebp esi edi
..B3.15: # Preds ..B3.14
pushl $_2__STRING.2.0 #44.2
call printf #44.2
# LOE ebx ebp esi edi
..B3.16: # Preds ..B3.15
addl $24, %esp #46.1
popl %ebx #46.1
popl %ebp #46.1
popl %esi #46.1
popl %edi #46.1
ret #46.1
# LOE
..B3.17: # Preds ..B3.24 # Infreq
pushl $_2__STRING.2.0 #44.2
call printf #44.2
# LOE ebx ebp esi edi
..B3.29: # Preds ..B3.17 # Infreq
popl %ecx #44.2
jmp ..B3.14 # Prob 100% #44.2
# LOE ebx ebp esi edi
..B3.18: # Preds ..B3.5 # Infreq
movl (%esp), %eax #
movl 16(%esp), %edx #
movl %ebx, to_boundary(%eax) #39.4
movl %ecx, 4+to_boundary(%eax) #39.4
jmp ..B3.8 # Prob 100% #39.4
.align 2,0x90
# LOE eax edx al dl ah dh
# mark_end;
.type Initialize,@function
.size Initialize,.-Initialize
.data
# -- End Initialize
.section .rodata.str1.4, "aMS",@progbits,1
.align 4
.align 4
_2__STRING.1.0:
.byte 48
.byte 0
.type _2__STRING.1.0,@object
.size _2__STRING.1.0,2
.space 2 # pad
_2__STRING.0.0:
.byte 49
.byte 0
.type _2__STRING.0.0,@object
.size _2__STRING.0.0,2
.space 2 # pad
_2__STRING.2.0:
.byte 10
.byte 0
.type _2__STRING.2.0,@object
.size _2__STRING.2.0,2
.data
.comm bm_mask,512,32
.comm to_boundary,512,32
.section .note.GNU-stack, ""
# End