Skip to content

Instantly share code, notes, and snippets.

@helloqiu
Created March 10, 2018 04:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save helloqiu/0a3354cff566c240625e840f388ae00a to your computer and use it in GitHub Desktop.
Save helloqiu/0a3354cff566c240625e840f388ae00a to your computer and use it in GitHub Desktop.
Assembly code generated by GCC 7.3.0 on i5-5257U Mac OS
.text
.cstring
lC1:
.ascii "%lf\12\0"
.text
.globl _main
_main:
LFB1:
pushq %rbp
LCFI0:
movq %rsp, %rbp
LCFI1:
subq $48, %rsp
call _clock
movq %rax, -24(%rbp)
movl $1, -4(%rbp)
jmp L2
L7:
movl $1, -8(%rbp)
jmp L3
L6:
movl $1, -12(%rbp)
jmp L4
L5:
movl -8(%rbp), %eax
imull -12(%rbp), %eax
movl %eax, %edx
movl -4(%rbp), %eax
addl %edx, %eax
movl %eax, -44(%rbp)
movl -44(%rbp), %eax
movl %eax, -48(%rbp)
addl $1, -12(%rbp)
L4:
cmpl $999, -12(%rbp)
jle L5
addl $1, -8(%rbp)
L3:
cmpl $999, -8(%rbp)
jle L6
addl $1, -4(%rbp)
L2:
cmpl $999, -4(%rbp)
jle L7
call _clock
movq %rax, -32(%rbp)
movq -32(%rbp), %rax
subq -24(%rbp), %rax
testq %rax, %rax
js L8
cvtsi2sdq %rax, %xmm0
jmp L9
L8:
movq %rax, %rdx
shrq %rdx
andl $1, %eax
orq %rax, %rdx
cvtsi2sdq %rdx, %xmm0
addsd %xmm0, %xmm0
L9:
movsd lC0(%rip), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -40(%rbp)
movq -40(%rbp), %rax
movq %rax, %xmm0
leaq lC1(%rip), %rdi
movl $1, %eax
call _printf
movl $0, %eax
leave
LCFI2:
ret
LFE1:
.literal8
.align 3
lC0:
.long 0
.long 1093567616
.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
EH_frame1:
.set L$set$0,LECIE1-LSCIE1
.long L$set$0
LSCIE1:
.long 0
.byte 0x1
.ascii "zR\0"
.byte 0x1
.byte 0x78
.byte 0x10
.byte 0x1
.byte 0x10
.byte 0xc
.byte 0x7
.byte 0x8
.byte 0x90
.byte 0x1
.align 3
LECIE1:
LSFDE1:
.set L$set$1,LEFDE1-LASFDE1
.long L$set$1
LASFDE1:
.long LASFDE1-EH_frame1
.quad LFB1-.
.set L$set$2,LFE1-LFB1
.quad L$set$2
.byte 0
.byte 0x4
.set L$set$3,LCFI0-LFB1
.long L$set$3
.byte 0xe
.byte 0x10
.byte 0x86
.byte 0x2
.byte 0x4
.set L$set$4,LCFI1-LCFI0
.long L$set$4
.byte 0xd
.byte 0x6
.byte 0x4
.set L$set$5,LCFI2-LCFI1
.long L$set$5
.byte 0xc
.byte 0x7
.byte 0x8
.align 3
LEFDE1:
.subsections_via_symbols
.text
.cstring
lC1:
.ascii "%lf\12\0"
.text
.globl _main
_main:
LFB1:
pushq %rbp
LCFI0:
movq %rsp, %rbp
LCFI1:
subq $48, %rsp
call _clock
movq %rax, -24(%rbp)
movl $1, -4(%rbp)
jmp L2
L7:
movl $1, -8(%rbp)
jmp L3
L6:
movl $1, -12(%rbp)
jmp L4
L5:
movl -8(%rbp), %eax
imull -12(%rbp), %eax
movl %eax, %edx
movl -4(%rbp), %eax
addl %edx, %eax
movl %eax, -44(%rbp)
addl $1, -12(%rbp)
L4:
cmpl $999, -12(%rbp)
jle L5
addl $1, -8(%rbp)
L3:
cmpl $999, -8(%rbp)
jle L6
addl $1, -4(%rbp)
L2:
cmpl $999, -4(%rbp)
jle L7
call _clock
movq %rax, -32(%rbp)
movq -32(%rbp), %rax
subq -24(%rbp), %rax
testq %rax, %rax
js L8
cvtsi2sdq %rax, %xmm0
jmp L9
L8:
movq %rax, %rdx
shrq %rdx
andl $1, %eax
orq %rax, %rdx
cvtsi2sdq %rdx, %xmm0
addsd %xmm0, %xmm0
L9:
movsd lC0(%rip), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -40(%rbp)
movq -40(%rbp), %rax
movq %rax, %xmm0
leaq lC1(%rip), %rdi
movl $1, %eax
call _printf
movl $0, %eax
leave
LCFI2:
ret
LFE1:
.literal8
.align 3
lC0:
.long 0
.long 1093567616
.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
EH_frame1:
.set L$set$0,LECIE1-LSCIE1
.long L$set$0
LSCIE1:
.long 0
.byte 0x1
.ascii "zR\0"
.byte 0x1
.byte 0x78
.byte 0x10
.byte 0x1
.byte 0x10
.byte 0xc
.byte 0x7
.byte 0x8
.byte 0x90
.byte 0x1
.align 3
LECIE1:
LSFDE1:
.set L$set$1,LEFDE1-LASFDE1
.long L$set$1
LASFDE1:
.long LASFDE1-EH_frame1
.quad LFB1-.
.set L$set$2,LFE1-LFB1
.quad L$set$2
.byte 0
.byte 0x4
.set L$set$3,LCFI0-LFB1
.long L$set$3
.byte 0xe
.byte 0x10
.byte 0x86
.byte 0x2
.byte 0x4
.set L$set$4,LCFI1-LCFI0
.long L$set$4
.byte 0xd
.byte 0x6
.byte 0x4
.set L$set$5,LCFI2-LCFI1
.long L$set$5
.byte 0xc
.byte 0x7
.byte 0x8
.align 3
LEFDE1:
.subsections_via_symbols
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment