Skip to content

Instantly share code, notes, and snippets.

@valexey
Created September 10, 2016 01:40
Show Gist options
  • Save valexey/76b7dd5d91cb7b04ce72bf4e81deb411 to your computer and use it in GitHub Desktop.
Save valexey/76b7dd5d91cb7b04ce72bf4e81deb411 to your computer and use it in GitHub Desktop.
$ cat bubble.s
.text
.file "bubble.cpp"
.globl _Z9print_allRKSt6vectorIiSaIiEE
.align 16, 0x90
.type _Z9print_allRKSt6vectorIiSaIiEE,@function
_Z9print_allRKSt6vectorIiSaIiEE: # @_Z9print_allRKSt6vectorIiSaIiEE
.cfi_startproc
# BB#0:
pushq %r15
.Ltmp0:
.cfi_def_cfa_offset 16
pushq %r14
.Ltmp1:
.cfi_def_cfa_offset 24
pushq %r12
.Ltmp2:
.cfi_def_cfa_offset 32
pushq %rbx
.Ltmp3:
.cfi_def_cfa_offset 40
pushq %rax
.Ltmp4:
.cfi_def_cfa_offset 48
.Ltmp5:
.cfi_offset %rbx, -40
.Ltmp6:
.cfi_offset %r12, -32
.Ltmp7:
.cfi_offset %r14, -24
.Ltmp8:
.cfi_offset %r15, -16
movq %rdi, %r14
movq (%r14), %rax
xorl %r12d, %r12d
cmpq %rax, 8(%r14)
je .LBB0_6
.align 16, 0x90
.LBB0_1: # %.lr.ph
# =>This Inner Loop Header: Depth=1
movl (%rax,%r12,4), %esi
movl $_ZSt4cout, %edi
callq _ZNSolsEi
movq %rax, %r15
movq (%r15), %rax
movq -24(%rax), %rax
movq 240(%r15,%rax), %rbx
testq %rbx, %rbx
je .LBB0_7
# BB#2: # %_ZSt13__check_facetISt5ctypeIcEERKT_PS3_.exit
# in Loop: Header=BB0_1 Depth=1
cmpb $0, 56(%rbx)
je .LBB0_4
# BB#3: # in Loop: Header=BB0_1 Depth=1
movb 67(%rbx), %al
jmp .LBB0_5
.align 16, 0x90
.LBB0_4: # in Loop: Header=BB0_1 Depth=1
movq %rbx, %rdi
callq _ZNKSt5ctypeIcE13_M_widen_initEv
movq (%rbx), %rax
movl $10, %esi
movq %rbx, %rdi
callq *48(%rax)
.LBB0_5: # %_ZNKSt5ctypeIcE5widenEc.exit
# in Loop: Header=BB0_1 Depth=1
movsbl %al, %esi
movq %r15, %rdi
callq _ZNSo3putEc
movq %rax, %rdi
callq _ZNSo5flushEv
incq %r12
movq (%r14), %rax
movq 8(%r14), %rcx
subq %rax, %rcx
sarq $2, %rcx
cmpq %rcx, %r12
jb .LBB0_1
.LBB0_6: # %._crit_edge
addq $8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
.LBB0_7:
callq _ZSt16__throw_bad_castv
.Lfunc_end0:
.size _Z9print_allRKSt6vectorIiSaIiEE, .Lfunc_end0-_Z9print_allRKSt6vectorIiSaIiEE
.cfi_endproc
.section .rodata.cst16,"aM",@progbits,16
.align 16
.LCPI1_0:
.quad 40000 # 0x9c40
.quad 39999 # 0x9c3f
.LCPI1_1:
.quad 39998 # 0x9c3e
.quad 39997 # 0x9c3d
.text
.globl main
.align 16, 0x90
.type main,@function
main: # @main
.Lfunc_begin0:
.cfi_startproc
.cfi_personality 3, __gxx_personality_v0
.cfi_lsda 3, .Lexception0
# BB#0:
pushq %r15
.Ltmp17:
.cfi_def_cfa_offset 16
pushq %r14
.Ltmp18:
.cfi_def_cfa_offset 24
pushq %rbx
.Ltmp19:
.cfi_def_cfa_offset 32
subq $32, %rsp
.Ltmp20:
.cfi_def_cfa_offset 64
.Ltmp21:
.cfi_offset %rbx, -32
.Ltmp22:
.cfi_offset %r14, -24
.Ltmp23:
.cfi_offset %r15, -16
pxor %xmm0, %xmm0
movdqa %xmm0, (%rsp)
movq $0, 16(%rsp)
.Ltmp9:
movl $160000, %edi # imm = 0x27100
callq _Znwm
movq %rax, %r14
.Ltmp10:
# BB#1: # %.lr.ph10
movq %r14, (%rsp)
leaq 160000(%r14), %r15
movq %r15, 16(%rsp)
xorl %ebx, %ebx
xorl %esi, %esi
movl $160000, %edx # imm = 0x27100
movq %r14, %rdi
callq memset
movq %r15, 8(%rsp)
movdqa .LCPI1_0(%rip), %xmm0 # xmm0 = [40000,39999]
movdqa .LCPI1_1(%rip), %xmm1 # xmm1 = [39998,39997]
.align 16, 0x90
.LBB1_2: # %vector.body
# =>This Inner Loop Header: Depth=1
movd %rbx, %xmm2
pshufd $68, %xmm2, %xmm2 # xmm2 = xmm2[0,1,0,1]
movdqa %xmm0, %xmm3
psubd %xmm2, %xmm3
pshufd $232, %xmm3, %xmm3 # xmm3 = xmm3[0,2,2,3]
movq %xmm3, (%r14,%rbx,4)
movdqa %xmm1, %xmm3
psubd %xmm2, %xmm3
pshufd $232, %xmm3, %xmm2 # xmm2 = xmm3[0,2,2,3]
movq %xmm2, 8(%r14,%rbx,4)
leaq 4(%rbx), %rax
movd %rax, %xmm2
pshufd $68, %xmm2, %xmm2 # xmm2 = xmm2[0,1,0,1]
movdqa %xmm0, %xmm3
psubd %xmm2, %xmm3
pshufd $232, %xmm3, %xmm3 # xmm3 = xmm3[0,2,2,3]
movq %xmm3, 16(%r14,%rbx,4)
movdqa %xmm1, %xmm3
psubd %xmm2, %xmm3
pshufd $232, %xmm3, %xmm2 # xmm2 = xmm3[0,2,2,3]
movq %xmm2, 24(%r14,%rbx,4)
addq $8, %rbx
cmpq $40000, %rbx # imm = 0x9C40
jne .LBB1_2
# BB#3: # %._crit_edge11
.Ltmp12:
leaq (%rsp), %rdi
callq _Z9print_allRKSt6vectorIiSaIiEE
.Ltmp13:
# BB#4:
movl $.Lstr, %edi
callq puts
movq 8(%rsp), %r8
cmpq %r14, %r8
je .LBB1_13
# BB#5: # %.preheader.lr.ph
movq (%rsp), %rcx
subq %rcx, %r8
sarq $2, %r8
xorl %edi, %edi
.align 16, 0x90
.LBB1_6: # %.preheader
# =>This Loop Header: Depth=1
# Child Loop BB1_8 Depth 2
leaq 1(%rdi), %r9
cmpq %r9, %r8
je .LBB1_12
# BB#7: # %.lr.ph
# in Loop: Header=BB1_6 Depth=1
notq %rdi
movq 8(%rsp), %rsi
subq (%rsp), %rsi
sarq $2, %rsi
addq %rdi, %rsi
movl (%rcx), %edx
xorl %ebx, %ebx
.align 16, 0x90
.LBB1_8: # Parent Loop BB1_6 Depth=1
# => This Inner Loop Header: Depth=2
leaq 1(%rbx), %rax
movl 4(%rcx,%rbx,4), %edi
cmpl %edi, %edx
jle .LBB1_9
# BB#17: # in Loop: Header=BB1_8 Depth=2
movl %edi, (%rcx,%rbx,4)
movl %edx, 4(%rcx,%rbx,4)
jmp .LBB1_18
.align 16, 0x90
.LBB1_9: # in Loop: Header=BB1_8 Depth=2
movl %edi, %edx
.LBB1_18: # %.backedge
# in Loop: Header=BB1_8 Depth=2
cmpq %rsi, %rax
movq %rax, %rbx
jb .LBB1_8
.LBB1_12: # %._crit_edge
# in Loop: Header=BB1_6 Depth=1
cmpq %r8, %r9
movq %r9, %rdi
jb .LBB1_6
.LBB1_13: # %._crit_edge7
.Ltmp14:
leaq (%rsp), %rdi
callq _Z9print_allRKSt6vectorIiSaIiEE
.Ltmp15:
# BB#14:
movq (%rsp), %rdi
testq %rdi, %rdi
je .LBB1_16
# BB#15:
callq _ZdlPv
.LBB1_16: # %_ZNSt6vectorIiSaIiEED2Ev.exit
xorl %eax, %eax
addq $32, %rsp
popq %rbx
popq %r14
popq %r15
retq
.LBB1_10:
.Ltmp16:
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je .LBB1_20
# BB#11:
callq _ZdlPv
movq %rbx, %rdi
callq _Unwind_Resume
.LBB1_19:
.Ltmp11:
movq %rax, %rbx
.LBB1_20: # %_ZNSt6vectorIiSaIiEED2Ev.exit3
movq %rbx, %rdi
callq _Unwind_Resume
.Lfunc_end1:
.size main, .Lfunc_end1-main
.cfi_endproc
.section .gcc_except_table,"a",@progbits
.align 4
GCC_except_table1:
.Lexception0:
.byte 255 # @LPStart Encoding = omit
.byte 3 # @TType Encoding = udata4
.asciz "\266\200\200" # @TType base offset
.byte 3 # Call site Encoding = udata4
.byte 52 # Call site table length
.long .Ltmp9-.Lfunc_begin0 # >> Call Site 1 <<
.long .Ltmp10-.Ltmp9 # Call between .Ltmp9 and .Ltmp10
.long .Ltmp11-.Lfunc_begin0 # jumps to .Ltmp11
.byte 0 # On action: cleanup
.long .Ltmp10-.Lfunc_begin0 # >> Call Site 2 <<
.long .Ltmp12-.Ltmp10 # Call between .Ltmp10 and .Ltmp12
.long 0 # has no landing pad
.byte 0 # On action: cleanup
.long .Ltmp12-.Lfunc_begin0 # >> Call Site 3 <<
.long .Ltmp15-.Ltmp12 # Call between .Ltmp12 and .Ltmp15
.long .Ltmp16-.Lfunc_begin0 # jumps to .Ltmp16
.byte 0 # On action: cleanup
.long .Ltmp15-.Lfunc_begin0 # >> Call Site 4 <<
.long .Lfunc_end1-.Ltmp15 # Call between .Ltmp15 and .Lfunc_end1
.long 0 # has no landing pad
.byte 0 # On action: cleanup
.align 4
.section .text.startup,"ax",@progbits
.align 16, 0x90
.type _GLOBAL__sub_I_bubble.cpp,@function
_GLOBAL__sub_I_bubble.cpp: # @_GLOBAL__sub_I_bubble.cpp
.cfi_startproc
# BB#0:
pushq %rax
.Ltmp24:
.cfi_def_cfa_offset 16
movl $_ZStL8__ioinit, %edi
callq _ZNSt8ios_base4InitC1Ev
movl $_ZNSt8ios_base4InitD1Ev, %edi
movl $_ZStL8__ioinit, %esi
movl $__dso_handle, %edx
popq %rax
jmp __cxa_atexit # TAILCALL
.Lfunc_end2:
.size _GLOBAL__sub_I_bubble.cpp, .Lfunc_end2-_GLOBAL__sub_I_bubble.cpp
.cfi_endproc
.type _ZStL8__ioinit,@object # @_ZStL8__ioinit
.local _ZStL8__ioinit
.comm _ZStL8__ioinit,1,1
.section .init_array,"aw",@init_array
.align 8
.quad _GLOBAL__sub_I_bubble.cpp
.type .Lstr,@object # @str
.section .rodata.str1.1,"aMS",@progbits,1
.Lstr:
.asciz "---"
.size .Lstr, 4
.ident "clang version 3.8.1 (tags/RELEASE_381/final)"
.section ".note.GNU-stack","",@progbits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment