Skip to content

Instantly share code, notes, and snippets.

@klogk
Last active August 29, 2015 13:58
Show Gist options
  • Save klogk/9994674 to your computer and use it in GitHub Desktop.
Save klogk/9994674 to your computer and use it in GitHub Desktop.
关于GCC 4.8 O2选项一个BUG的讨论-汇编码1
main:
.LFB1016:
subq $24, %rsp
.LCFI0:
xorl %eax, %eax
movl $.LC0, %edi
leaq 12(%rsp), %rsi
call scanf
movl 12(%rsp), %eax # n[%eax] <- scanf
testl %eax, %eax # (n&n) - 0 ?
js .L2 # if negative, goto .L2
cmpl $3, %eax # $3 - n ?
je .L5 # if equal, goto .L5
.L2:
movl $.LC2, %edi
call puts # printf("-1\n")
xorl %eax, %eax
addq $24, %rsp
.LCFI1:
ret # return 0
.L5:
.LCFI2:
movl $.LC1, %edi
xorl %ecx, %ecx
movl $1, %edx
movl $2, %esi
xorl %eax, %eax
call printf # printf("2 1 0\n")
xorl %edi, %edi
call exit # exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment