Skip to content

Instantly share code, notes, and snippets.

@lexfrei
Last active March 3, 2018 11:18
Show Gist options
  • Select an option

  • Save lexfrei/b2dca77b678d1889907ad6a8af2a7303 to your computer and use it in GitHub Desktop.

Select an option

Save lexfrei/b2dca77b678d1889907ad6a8af2a7303 to your computer and use it in GitHub Desktop.
--- ./prepatch.s 2018-03-03 14:14:58.000000000 +0300
+++ ./hello.s 2018-03-03 14:15:02.000000000 +0300
@@ -13,36 +13,10 @@
movq %rsp, %rbp
Lcfi2:
.cfi_def_cfa_register %rbp
- subq $48, %rsp
- movl $0, -20(%rbp)
- movl $0, -24(%rbp)
-LBB0_1: ## =>This Loop Header: Depth=1
- ## Child Loop BB0_3 Depth 2
- cmpl $2147483647, -24(%rbp) ## imm = 0x7FFFFFFF
- jge LBB0_8
-## BB#2: ## in Loop: Header=BB0_1 Depth=1
- movl $0, -28(%rbp)
-LBB0_3: ## Parent Loop BB0_1 Depth=1
- ## => This Inner Loop Header: Depth=2
- cmpl $2147483647, -28(%rbp) ## imm = 0x7FFFFFFF
- jge LBB0_6
-## BB#4: ## in Loop: Header=BB0_3 Depth=2
- jmp LBB0_5
-LBB0_5: ## in Loop: Header=BB0_3 Depth=2
- movl -28(%rbp), %eax
- addl $1, %eax
- movl %eax, -28(%rbp)
- jmp LBB0_3
-LBB0_6: ## in Loop: Header=BB0_1 Depth=1
- jmp LBB0_7
-LBB0_7: ## in Loop: Header=BB0_1 Depth=1
- movl -24(%rbp), %eax
- addl $1, %eax
- movl %eax, -24(%rbp)
- jmp LBB0_1
-LBB0_8:
+ subq $32, %rsp
movq __ZNSt3__14coutE@GOTPCREL(%rip), %rdi
leaq L_.str(%rip), %rsi
+ movl $0, -20(%rbp)
callq __ZNSt3__1lsINS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc
leaq __ZNSt3__14endlIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_(%rip), %rsi
movq %rax, -8(%rbp)
@@ -50,9 +24,9 @@
movq -8(%rbp), %rdi
callq *-16(%rbp)
xorl %ecx, %ecx
- movq %rax, -40(%rbp) ## 8-byte Spill
+ movq %rax, -32(%rbp) ## 8-byte Spill
movl %ecx, %eax
- addq $48, %rsp
+ addq $32, %rsp
popq %rbp
retq
.cfi_endproc
sviridkin@mbp:~$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
sviridkin@mbp:/tmp$ g++ -O3 madhello.cpp -o mad
sviridkin@mbp:/tmp$ g++ -O3 hello.cpp -o norm
sviridkin@mbp:/tmp$ time ./norm
Hello World!
real 0m0.014s
user 0m0.006s
sys 0m0.008s
sviridkin@mbp:/tmp$ time ./mad
Hello World!
real 0m0.014s
user 0m0.006s
sys 0m0.008s
sviridkin@mbp:/tmp$ diff hello.s madhello.s
<nothing>
#include <iostream>
int main()
{
std::cout << "Hello World!" << std::endl;
return 0;
}
# g++ -S -O3 hello.cpp
.section __TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 13
.globl _main
.p2align 4, 0x90
_main: ## @main
Lfunc_begin0:
.cfi_startproc
.cfi_personality 155, ___gxx_personality_v0
.cfi_lsda 16, Lexception0
## BB#0:
pushq %rbp
Lcfi0:
.cfi_def_cfa_offset 16
Lcfi1:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Lcfi2:
.cfi_def_cfa_register %rbp
pushq %r14
pushq %rbx
subq $16, %rsp
Lcfi3:
.cfi_offset %rbx, -32
Lcfi4:
.cfi_offset %r14, -24
movq __ZNSt3__14coutE@GOTPCREL(%rip), %rdi
leaq L_.str(%rip), %rsi
movl $12, %edx
callq __ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m
movq %rax, %rbx
movq (%rbx), %rax
movq -24(%rax), %rsi
addq %rbx, %rsi
leaq -24(%rbp), %r14
movq %r14, %rdi
callq __ZNKSt3__18ios_base6getlocEv
Ltmp0:
movq __ZNSt3__15ctypeIcE2idE@GOTPCREL(%rip), %rsi
movq %r14, %rdi
callq __ZNKSt3__16locale9use_facetERNS0_2idE
Ltmp1:
## BB#1:
movq (%rax), %rcx
Ltmp2:
movl $10, %esi
movq %rax, %rdi
callq *56(%rcx)
movl %eax, %r14d
Ltmp3:
## BB#2:
leaq -24(%rbp), %rdi
callq __ZNSt3__16localeD1Ev
movsbl %r14b, %esi
movq %rbx, %rdi
callq __ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE3putEc
movq %rbx, %rdi
callq __ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5flushEv
xorl %eax, %eax
addq $16, %rsp
popq %rbx
popq %r14
popq %rbp
retq
LBB0_3:
Ltmp4:
movq %rax, %rbx
Ltmp5:
leaq -24(%rbp), %rdi
callq __ZNSt3__16localeD1Ev
Ltmp6:
## BB#4:
movq %rbx, %rdi
callq __Unwind_Resume
LBB0_5:
Ltmp7:
movq %rax, %rdi
callq ___clang_call_terminate
Lfunc_end0:
.cfi_endproc
.section __TEXT,__gcc_except_tab
.p2align 2
GCC_except_table0:
Lexception0:
.byte 255 ## @LPStart Encoding = omit
.byte 155 ## @TType Encoding = indirect pcrel sdata4
.byte 73 ## @TType base offset
.byte 3 ## Call site Encoding = udata4
.byte 65 ## Call site table length
Lset0 = Lfunc_begin0-Lfunc_begin0 ## >> Call Site 1 <<
.long Lset0
Lset1 = Ltmp0-Lfunc_begin0 ## Call between Lfunc_begin0 and Ltmp0
.long Lset1
.long 0 ## has no landing pad
.byte 0 ## On action: cleanup
Lset2 = Ltmp0-Lfunc_begin0 ## >> Call Site 2 <<
.long Lset2
Lset3 = Ltmp3-Ltmp0 ## Call between Ltmp0 and Ltmp3
.long Lset3
Lset4 = Ltmp4-Lfunc_begin0 ## jumps to Ltmp4
.long Lset4
.byte 0 ## On action: cleanup
Lset5 = Ltmp3-Lfunc_begin0 ## >> Call Site 3 <<
.long Lset5
Lset6 = Ltmp5-Ltmp3 ## Call between Ltmp3 and Ltmp5
.long Lset6
.long 0 ## has no landing pad
.byte 0 ## On action: cleanup
Lset7 = Ltmp5-Lfunc_begin0 ## >> Call Site 4 <<
.long Lset7
Lset8 = Ltmp6-Ltmp5 ## Call between Ltmp5 and Ltmp6
.long Lset8
Lset9 = Ltmp7-Lfunc_begin0 ## jumps to Ltmp7
.long Lset9
.byte 1 ## On action: 1
Lset10 = Ltmp6-Lfunc_begin0 ## >> Call Site 5 <<
.long Lset10
Lset11 = Lfunc_end0-Ltmp6 ## Call between Ltmp6 and Lfunc_end0
.long Lset11
.long 0 ## has no landing pad
.byte 0 ## On action: cleanup
.byte 1 ## >> Action Record 1 <<
## Catch TypeInfo 1
.byte 0 ## No further actions
## >> Catch TypeInfos <<
.long 0 ## TypeInfo 1
.p2align 2
.section __TEXT,__text,regular,pure_instructions
.globl __ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m
.weak_def_can_be_hidden __ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m
.p2align 4, 0x90
__ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m: ## @_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m
Lfunc_begin1:
.cfi_startproc
.cfi_personality 155, ___gxx_personality_v0
.cfi_lsda 16, Lexception1
## BB#0:
pushq %rbp
Lcfi5:
.cfi_def_cfa_offset 16
Lcfi6:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Lcfi7:
.cfi_def_cfa_register %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $40, %rsp
Lcfi8:
.cfi_offset %rbx, -56
Lcfi9:
.cfi_offset %r12, -48
Lcfi10:
.cfi_offset %r13, -40
Lcfi11:
.cfi_offset %r14, -32
Lcfi12:
.cfi_offset %r15, -24
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
Ltmp8:
leaq -80(%rbp), %rdi
movq %rbx, %rsi
callq __ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryC1ERS3_
Ltmp9:
## BB#1:
cmpb $0, -80(%rbp)
je LBB1_11
## BB#2:
movq (%rbx), %rax
movq -24(%rax), %rax
leaq (%rbx,%rax), %r12
movq 40(%rbx,%rax), %rdi
movl 8(%rbx,%rax), %r13d
movl 144(%rbx,%rax), %eax
cmpl $-1, %eax
jne LBB1_8
## BB#3:
Ltmp10:
movq %rdi, -64(%rbp) ## 8-byte Spill
leaq -56(%rbp), %rdi
movq %r12, %rsi
callq __ZNKSt3__18ios_base6getlocEv
Ltmp11:
## BB#4:
Ltmp12:
movq __ZNSt3__15ctypeIcE2idE@GOTPCREL(%rip), %rsi
leaq -56(%rbp), %rdi
callq __ZNKSt3__16locale9use_facetERNS0_2idE
Ltmp13:
## BB#5:
movq (%rax), %rcx
Ltmp14:
movl $32, %esi
movq %rax, %rdi
callq *56(%rcx)
movb %al, -41(%rbp) ## 1-byte Spill
Ltmp15:
## BB#6:
Ltmp20:
leaq -56(%rbp), %rdi
callq __ZNSt3__16localeD1Ev
Ltmp21:
## BB#7:
movsbl -41(%rbp), %eax ## 1-byte Folded Reload
movl %eax, 144(%r12)
movq -64(%rbp), %rdi ## 8-byte Reload
LBB1_8:
addq %r15, %r14
andl $176, %r13d
cmpl $32, %r13d
movq %r15, %rdx
cmoveq %r14, %rdx
Ltmp22:
movsbl %al, %r9d
movq %r15, %rsi
movq %r14, %rcx
movq %r12, %r8
callq __ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_
Ltmp23:
## BB#9:
testq %rax, %rax
jne LBB1_11
## BB#10:
movq (%rbx), %rax
movq -24(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 32(%rbx,%rax), %esi
orl $5, %esi
Ltmp24:
callq __ZNSt3__18ios_base5clearEj
Ltmp25:
LBB1_11:
Ltmp29:
leaq -80(%rbp), %rdi
callq __ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryD1Ev
Ltmp30:
LBB1_19:
movq %rbx, %rax
addq $40, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
LBB1_12:
Ltmp16:
movq %rax, %r14
Ltmp17:
leaq -56(%rbp), %rdi
callq __ZNSt3__16localeD1Ev
Ltmp18:
jmp LBB1_15
LBB1_13:
Ltmp19:
movq %rax, %rdi
callq ___clang_call_terminate
LBB1_14:
Ltmp26:
movq %rax, %r14
LBB1_15:
Ltmp27:
leaq -80(%rbp), %rdi
callq __ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryD1Ev
Ltmp28:
jmp LBB1_17
LBB1_16:
Ltmp31:
movq %rax, %r14
LBB1_17:
movq %r14, %rdi
callq ___cxa_begin_catch
movq (%rbx), %rax
movq %rbx, %rdi
addq -24(%rax), %rdi
Ltmp32:
callq __ZNSt3__18ios_base33__set_badbit_and_consider_rethrowEv
Ltmp33:
## BB#18:
callq ___cxa_end_catch
jmp LBB1_19
LBB1_20:
Ltmp34:
movq %rax, %rbx
Ltmp35:
callq ___cxa_end_catch
Ltmp36:
## BB#21:
movq %rbx, %rdi
callq __Unwind_Resume
LBB1_22:
Ltmp37:
movq %rax, %rdi
callq ___clang_call_terminate
Lfunc_end1:
.cfi_endproc
.section __TEXT,__gcc_except_tab
.p2align 2
GCC_except_table1:
Lexception1:
.byte 255 ## @LPStart Encoding = omit
.byte 155 ## @TType Encoding = indirect pcrel sdata4
.asciz "\245\201\200\200" ## @TType base offset
.byte 3 ## Call site Encoding = udata4
.ascii "\234\001" ## Call site table length
Lset12 = Ltmp8-Lfunc_begin1 ## >> Call Site 1 <<
.long Lset12
Lset13 = Ltmp9-Ltmp8 ## Call between Ltmp8 and Ltmp9
.long Lset13
Lset14 = Ltmp31-Lfunc_begin1 ## jumps to Ltmp31
.long Lset14
.byte 1 ## On action: 1
Lset15 = Ltmp10-Lfunc_begin1 ## >> Call Site 2 <<
.long Lset15
Lset16 = Ltmp11-Ltmp10 ## Call between Ltmp10 and Ltmp11
.long Lset16
Lset17 = Ltmp26-Lfunc_begin1 ## jumps to Ltmp26
.long Lset17
.byte 1 ## On action: 1
Lset18 = Ltmp12-Lfunc_begin1 ## >> Call Site 3 <<
.long Lset18
Lset19 = Ltmp15-Ltmp12 ## Call between Ltmp12 and Ltmp15
.long Lset19
Lset20 = Ltmp16-Lfunc_begin1 ## jumps to Ltmp16
.long Lset20
.byte 1 ## On action: 1
Lset21 = Ltmp20-Lfunc_begin1 ## >> Call Site 4 <<
.long Lset21
Lset22 = Ltmp25-Ltmp20 ## Call between Ltmp20 and Ltmp25
.long Lset22
Lset23 = Ltmp26-Lfunc_begin1 ## jumps to Ltmp26
.long Lset23
.byte 1 ## On action: 1
Lset24 = Ltmp29-Lfunc_begin1 ## >> Call Site 5 <<
.long Lset24
Lset25 = Ltmp30-Ltmp29 ## Call between Ltmp29 and Ltmp30
.long Lset25
Lset26 = Ltmp31-Lfunc_begin1 ## jumps to Ltmp31
.long Lset26
.byte 1 ## On action: 1
Lset27 = Ltmp17-Lfunc_begin1 ## >> Call Site 6 <<
.long Lset27
Lset28 = Ltmp18-Ltmp17 ## Call between Ltmp17 and Ltmp18
.long Lset28
Lset29 = Ltmp19-Lfunc_begin1 ## jumps to Ltmp19
.long Lset29
.byte 1 ## On action: 1
Lset30 = Ltmp27-Lfunc_begin1 ## >> Call Site 7 <<
.long Lset30
Lset31 = Ltmp28-Ltmp27 ## Call between Ltmp27 and Ltmp28
.long Lset31
Lset32 = Ltmp37-Lfunc_begin1 ## jumps to Ltmp37
.long Lset32
.byte 1 ## On action: 1
Lset33 = Ltmp28-Lfunc_begin1 ## >> Call Site 8 <<
.long Lset33
Lset34 = Ltmp32-Ltmp28 ## Call between Ltmp28 and Ltmp32
.long Lset34
.long 0 ## has no landing pad
.byte 0 ## On action: cleanup
Lset35 = Ltmp32-Lfunc_begin1 ## >> Call Site 9 <<
.long Lset35
Lset36 = Ltmp33-Ltmp32 ## Call between Ltmp32 and Ltmp33
.long Lset36
Lset37 = Ltmp34-Lfunc_begin1 ## jumps to Ltmp34
.long Lset37
.byte 0 ## On action: cleanup
Lset38 = Ltmp33-Lfunc_begin1 ## >> Call Site 10 <<
.long Lset38
Lset39 = Ltmp35-Ltmp33 ## Call between Ltmp33 and Ltmp35
.long Lset39
.long 0 ## has no landing pad
.byte 0 ## On action: cleanup
Lset40 = Ltmp35-Lfunc_begin1 ## >> Call Site 11 <<
.long Lset40
Lset41 = Ltmp36-Ltmp35 ## Call between Ltmp35 and Ltmp36
.long Lset41
Lset42 = Ltmp37-Lfunc_begin1 ## jumps to Ltmp37
.long Lset42
.byte 1 ## On action: 1
Lset43 = Ltmp36-Lfunc_begin1 ## >> Call Site 12 <<
.long Lset43
Lset44 = Lfunc_end1-Ltmp36 ## Call between Ltmp36 and Lfunc_end1
.long Lset44
.long 0 ## has no landing pad
.byte 0 ## On action: cleanup
.byte 1 ## >> Action Record 1 <<
## Catch TypeInfo 1
.byte 0 ## No further actions
## >> Catch TypeInfos <<
.long 0 ## TypeInfo 1
.p2align 2
.section __TEXT,__text,regular,pure_instructions
.private_extern __ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_
.globl __ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_
.weak_def_can_be_hidden __ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_
.p2align 4, 0x90
__ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_: ## @_ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_
Lfunc_begin2:
.cfi_startproc
.cfi_personality 155, ___gxx_personality_v0
.cfi_lsda 16, Lexception2
## BB#0:
pushq %rbp
Lcfi13:
.cfi_def_cfa_offset 16
Lcfi14:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Lcfi15:
.cfi_def_cfa_register %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $72, %rsp
Lcfi16:
.cfi_offset %rbx, -56
Lcfi17:
.cfi_offset %r12, -48
Lcfi18:
.cfi_offset %r13, -40
Lcfi19:
.cfi_offset %r14, -32
Lcfi20:
.cfi_offset %r15, -24
movq %r8, %r14
movq %rcx, %r12
movq %rdi, %r13
testq %r13, %r13
je LBB2_17
## BB#1:
movl %r9d, -44(%rbp) ## 4-byte Spill
movq %r12, %rax
subq %rsi, %rax
movq 24(%r14), %rcx
xorl %r15d, %r15d
subq %rax, %rcx
cmovgq %rcx, %r15
movq %rdx, -104(%rbp) ## 8-byte Spill
movq %rdx, %rbx
subq %rsi, %rbx
testq %rbx, %rbx
jle LBB2_3
## BB#2:
movq (%r13), %rax
movq %r13, %rdi
movq %rbx, %rdx
callq *96(%rax)
cmpq %rbx, %rax
jne LBB2_17
LBB2_3:
testq %r15, %r15
jle LBB2_13
## BB#4:
movq %r12, -88(%rbp) ## 8-byte Spill
movq %r14, -96(%rbp) ## 8-byte Spill
xorps %xmm0, %xmm0
movaps %xmm0, -80(%rbp)
movq $0, -64(%rbp)
cmpq $23, %r15
jae LBB2_8
## BB#5:
movl %r15d, %eax
addb %al, %al
movb %al, -80(%rbp)
leaq -79(%rbp), %r14
movq %r14, %r12
jmp LBB2_9
LBB2_8:
leaq 16(%r15), %rbx
andq $-16, %rbx
movq %rbx, %rdi
callq __Znwm
movq %rax, %r12
movq %r12, -64(%rbp)
orq $1, %rbx
movq %rbx, -80(%rbp)
movq %r15, -72(%rbp)
leaq -79(%rbp), %r14
LBB2_9:
movl -44(%rbp), %eax ## 4-byte Reload
movzbl %al, %esi
movq %r12, %rdi
movq %r15, %rdx
callq _memset
movb $0, (%r12,%r15)
testb $1, -80(%rbp)
cmovneq -64(%rbp), %r14
movq (%r13), %rax
Ltmp38:
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq *96(%rax)
movq %rax, %rbx
Ltmp39:
## BB#10:
testb $1, -80(%rbp)
movq -96(%rbp), %r14 ## 8-byte Reload
movq -88(%rbp), %r12 ## 8-byte Reload
je LBB2_12
## BB#11:
movq -64(%rbp), %rdi
callq __ZdlPv
LBB2_12:
cmpq %r15, %rbx
jne LBB2_17
LBB2_13:
movq -104(%rbp), %rsi ## 8-byte Reload
subq %rsi, %r12
testq %r12, %r12
jle LBB2_15
## BB#14:
movq (%r13), %rax
movq %r13, %rdi
movq %r12, %rdx
callq *96(%rax)
cmpq %r12, %rax
jne LBB2_17
LBB2_15:
movq $0, 24(%r14)
jmp LBB2_18
LBB2_17:
xorl %r13d, %r13d
LBB2_18:
movq %r13, %rax
addq $72, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
LBB2_19:
Ltmp40:
movq %rax, %rbx
testb $1, -80(%rbp)
je LBB2_21
## BB#20:
movq -64(%rbp), %rdi
callq __ZdlPv
LBB2_21:
movq %rbx, %rdi
callq __Unwind_Resume
Lfunc_end2:
.cfi_endproc
.section __TEXT,__gcc_except_tab
.p2align 2
GCC_except_table2:
Lexception2:
.byte 255 ## @LPStart Encoding = omit
.byte 155 ## @TType Encoding = indirect pcrel sdata4
.byte 41 ## @TType base offset
.byte 3 ## Call site Encoding = udata4
.byte 39 ## Call site table length
Lset45 = Lfunc_begin2-Lfunc_begin2 ## >> Call Site 1 <<
.long Lset45
Lset46 = Ltmp38-Lfunc_begin2 ## Call between Lfunc_begin2 and Ltmp38
.long Lset46
.long 0 ## has no landing pad
.byte 0 ## On action: cleanup
Lset47 = Ltmp38-Lfunc_begin2 ## >> Call Site 2 <<
.long Lset47
Lset48 = Ltmp39-Ltmp38 ## Call between Ltmp38 and Ltmp39
.long Lset48
Lset49 = Ltmp40-Lfunc_begin2 ## jumps to Ltmp40
.long Lset49
.byte 0 ## On action: cleanup
Lset50 = Ltmp39-Lfunc_begin2 ## >> Call Site 3 <<
.long Lset50
Lset51 = Lfunc_end2-Ltmp39 ## Call between Ltmp39 and Lfunc_end2
.long Lset51
.long 0 ## has no landing pad
.byte 0 ## On action: cleanup
.p2align 2
.section __TEXT,__text,regular,pure_instructions
.private_extern ___clang_call_terminate
.globl ___clang_call_terminate
.weak_def_can_be_hidden ___clang_call_terminate
.p2align 4, 0x90
___clang_call_terminate: ## @__clang_call_terminate
## BB#0:
pushq %rax
callq ___cxa_begin_catch
callq __ZSt9terminatev
.section __TEXT,__cstring,cstring_literals
L_.str: ## @.str
.asciz "Hello World!"
.subsections_via_symbols
#include <iostream>
int main()
{
for (int i =0; i < 2147483647; i++) {
for (int j = 0;j < 2147483647; j++) {
}
}
std::cout << "Hello World!" << std::endl;
return 0;
}
# g++ -S -O3 madhello.cpp
.section __TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 13
.globl _main
.p2align 4, 0x90
_main: ## @main
Lfunc_begin0:
.cfi_startproc
.cfi_personality 155, ___gxx_personality_v0
.cfi_lsda 16, Lexception0
## BB#0:
pushq %rbp
Lcfi0:
.cfi_def_cfa_offset 16
Lcfi1:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Lcfi2:
.cfi_def_cfa_register %rbp
pushq %r14
pushq %rbx
subq $16, %rsp
Lcfi3:
.cfi_offset %rbx, -32
Lcfi4:
.cfi_offset %r14, -24
movq __ZNSt3__14coutE@GOTPCREL(%rip), %rdi
leaq L_.str(%rip), %rsi
movl $12, %edx
callq __ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m
movq %rax, %rbx
movq (%rbx), %rax
movq -24(%rax), %rsi
addq %rbx, %rsi
leaq -24(%rbp), %r14
movq %r14, %rdi
callq __ZNKSt3__18ios_base6getlocEv
Ltmp0:
movq __ZNSt3__15ctypeIcE2idE@GOTPCREL(%rip), %rsi
movq %r14, %rdi
callq __ZNKSt3__16locale9use_facetERNS0_2idE
Ltmp1:
## BB#1:
movq (%rax), %rcx
Ltmp2:
movl $10, %esi
movq %rax, %rdi
callq *56(%rcx)
movl %eax, %r14d
Ltmp3:
## BB#2:
leaq -24(%rbp), %rdi
callq __ZNSt3__16localeD1Ev
movsbl %r14b, %esi
movq %rbx, %rdi
callq __ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE3putEc
movq %rbx, %rdi
callq __ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5flushEv
xorl %eax, %eax
addq $16, %rsp
popq %rbx
popq %r14
popq %rbp
retq
LBB0_3:
Ltmp4:
movq %rax, %rbx
Ltmp5:
leaq -24(%rbp), %rdi
callq __ZNSt3__16localeD1Ev
Ltmp6:
## BB#4:
movq %rbx, %rdi
callq __Unwind_Resume
LBB0_5:
Ltmp7:
movq %rax, %rdi
callq ___clang_call_terminate
Lfunc_end0:
.cfi_endproc
.section __TEXT,__gcc_except_tab
.p2align 2
GCC_except_table0:
Lexception0:
.byte 255 ## @LPStart Encoding = omit
.byte 155 ## @TType Encoding = indirect pcrel sdata4
.byte 73 ## @TType base offset
.byte 3 ## Call site Encoding = udata4
.byte 65 ## Call site table length
Lset0 = Lfunc_begin0-Lfunc_begin0 ## >> Call Site 1 <<
.long Lset0
Lset1 = Ltmp0-Lfunc_begin0 ## Call between Lfunc_begin0 and Ltmp0
.long Lset1
.long 0 ## has no landing pad
.byte 0 ## On action: cleanup
Lset2 = Ltmp0-Lfunc_begin0 ## >> Call Site 2 <<
.long Lset2
Lset3 = Ltmp3-Ltmp0 ## Call between Ltmp0 and Ltmp3
.long Lset3
Lset4 = Ltmp4-Lfunc_begin0 ## jumps to Ltmp4
.long Lset4
.byte 0 ## On action: cleanup
Lset5 = Ltmp3-Lfunc_begin0 ## >> Call Site 3 <<
.long Lset5
Lset6 = Ltmp5-Ltmp3 ## Call between Ltmp3 and Ltmp5
.long Lset6
.long 0 ## has no landing pad
.byte 0 ## On action: cleanup
Lset7 = Ltmp5-Lfunc_begin0 ## >> Call Site 4 <<
.long Lset7
Lset8 = Ltmp6-Ltmp5 ## Call between Ltmp5 and Ltmp6
.long Lset8
Lset9 = Ltmp7-Lfunc_begin0 ## jumps to Ltmp7
.long Lset9
.byte 1 ## On action: 1
Lset10 = Ltmp6-Lfunc_begin0 ## >> Call Site 5 <<
.long Lset10
Lset11 = Lfunc_end0-Ltmp6 ## Call between Ltmp6 and Lfunc_end0
.long Lset11
.long 0 ## has no landing pad
.byte 0 ## On action: cleanup
.byte 1 ## >> Action Record 1 <<
## Catch TypeInfo 1
.byte 0 ## No further actions
## >> Catch TypeInfos <<
.long 0 ## TypeInfo 1
.p2align 2
.section __TEXT,__text,regular,pure_instructions
.globl __ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m
.weak_def_can_be_hidden __ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m
.p2align 4, 0x90
__ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m: ## @_ZNSt3__124__put_character_sequenceIcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m
Lfunc_begin1:
.cfi_startproc
.cfi_personality 155, ___gxx_personality_v0
.cfi_lsda 16, Lexception1
## BB#0:
pushq %rbp
Lcfi5:
.cfi_def_cfa_offset 16
Lcfi6:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Lcfi7:
.cfi_def_cfa_register %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $40, %rsp
Lcfi8:
.cfi_offset %rbx, -56
Lcfi9:
.cfi_offset %r12, -48
Lcfi10:
.cfi_offset %r13, -40
Lcfi11:
.cfi_offset %r14, -32
Lcfi12:
.cfi_offset %r15, -24
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
Ltmp8:
leaq -80(%rbp), %rdi
movq %rbx, %rsi
callq __ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryC1ERS3_
Ltmp9:
## BB#1:
cmpb $0, -80(%rbp)
je LBB1_11
## BB#2:
movq (%rbx), %rax
movq -24(%rax), %rax
leaq (%rbx,%rax), %r12
movq 40(%rbx,%rax), %rdi
movl 8(%rbx,%rax), %r13d
movl 144(%rbx,%rax), %eax
cmpl $-1, %eax
jne LBB1_8
## BB#3:
Ltmp10:
movq %rdi, -64(%rbp) ## 8-byte Spill
leaq -56(%rbp), %rdi
movq %r12, %rsi
callq __ZNKSt3__18ios_base6getlocEv
Ltmp11:
## BB#4:
Ltmp12:
movq __ZNSt3__15ctypeIcE2idE@GOTPCREL(%rip), %rsi
leaq -56(%rbp), %rdi
callq __ZNKSt3__16locale9use_facetERNS0_2idE
Ltmp13:
## BB#5:
movq (%rax), %rcx
Ltmp14:
movl $32, %esi
movq %rax, %rdi
callq *56(%rcx)
movb %al, -41(%rbp) ## 1-byte Spill
Ltmp15:
## BB#6:
Ltmp20:
leaq -56(%rbp), %rdi
callq __ZNSt3__16localeD1Ev
Ltmp21:
## BB#7:
movsbl -41(%rbp), %eax ## 1-byte Folded Reload
movl %eax, 144(%r12)
movq -64(%rbp), %rdi ## 8-byte Reload
LBB1_8:
addq %r15, %r14
andl $176, %r13d
cmpl $32, %r13d
movq %r15, %rdx
cmoveq %r14, %rdx
Ltmp22:
movsbl %al, %r9d
movq %r15, %rsi
movq %r14, %rcx
movq %r12, %r8
callq __ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_
Ltmp23:
## BB#9:
testq %rax, %rax
jne LBB1_11
## BB#10:
movq (%rbx), %rax
movq -24(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 32(%rbx,%rax), %esi
orl $5, %esi
Ltmp24:
callq __ZNSt3__18ios_base5clearEj
Ltmp25:
LBB1_11:
Ltmp29:
leaq -80(%rbp), %rdi
callq __ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryD1Ev
Ltmp30:
LBB1_19:
movq %rbx, %rax
addq $40, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
LBB1_12:
Ltmp16:
movq %rax, %r14
Ltmp17:
leaq -56(%rbp), %rdi
callq __ZNSt3__16localeD1Ev
Ltmp18:
jmp LBB1_15
LBB1_13:
Ltmp19:
movq %rax, %rdi
callq ___clang_call_terminate
LBB1_14:
Ltmp26:
movq %rax, %r14
LBB1_15:
Ltmp27:
leaq -80(%rbp), %rdi
callq __ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryD1Ev
Ltmp28:
jmp LBB1_17
LBB1_16:
Ltmp31:
movq %rax, %r14
LBB1_17:
movq %r14, %rdi
callq ___cxa_begin_catch
movq (%rbx), %rax
movq %rbx, %rdi
addq -24(%rax), %rdi
Ltmp32:
callq __ZNSt3__18ios_base33__set_badbit_and_consider_rethrowEv
Ltmp33:
## BB#18:
callq ___cxa_end_catch
jmp LBB1_19
LBB1_20:
Ltmp34:
movq %rax, %rbx
Ltmp35:
callq ___cxa_end_catch
Ltmp36:
## BB#21:
movq %rbx, %rdi
callq __Unwind_Resume
LBB1_22:
Ltmp37:
movq %rax, %rdi
callq ___clang_call_terminate
Lfunc_end1:
.cfi_endproc
.section __TEXT,__gcc_except_tab
.p2align 2
GCC_except_table1:
Lexception1:
.byte 255 ## @LPStart Encoding = omit
.byte 155 ## @TType Encoding = indirect pcrel sdata4
.asciz "\245\201\200\200" ## @TType base offset
.byte 3 ## Call site Encoding = udata4
.ascii "\234\001" ## Call site table length
Lset12 = Ltmp8-Lfunc_begin1 ## >> Call Site 1 <<
.long Lset12
Lset13 = Ltmp9-Ltmp8 ## Call between Ltmp8 and Ltmp9
.long Lset13
Lset14 = Ltmp31-Lfunc_begin1 ## jumps to Ltmp31
.long Lset14
.byte 1 ## On action: 1
Lset15 = Ltmp10-Lfunc_begin1 ## >> Call Site 2 <<
.long Lset15
Lset16 = Ltmp11-Ltmp10 ## Call between Ltmp10 and Ltmp11
.long Lset16
Lset17 = Ltmp26-Lfunc_begin1 ## jumps to Ltmp26
.long Lset17
.byte 1 ## On action: 1
Lset18 = Ltmp12-Lfunc_begin1 ## >> Call Site 3 <<
.long Lset18
Lset19 = Ltmp15-Ltmp12 ## Call between Ltmp12 and Ltmp15
.long Lset19
Lset20 = Ltmp16-Lfunc_begin1 ## jumps to Ltmp16
.long Lset20
.byte 1 ## On action: 1
Lset21 = Ltmp20-Lfunc_begin1 ## >> Call Site 4 <<
.long Lset21
Lset22 = Ltmp25-Ltmp20 ## Call between Ltmp20 and Ltmp25
.long Lset22
Lset23 = Ltmp26-Lfunc_begin1 ## jumps to Ltmp26
.long Lset23
.byte 1 ## On action: 1
Lset24 = Ltmp29-Lfunc_begin1 ## >> Call Site 5 <<
.long Lset24
Lset25 = Ltmp30-Ltmp29 ## Call between Ltmp29 and Ltmp30
.long Lset25
Lset26 = Ltmp31-Lfunc_begin1 ## jumps to Ltmp31
.long Lset26
.byte 1 ## On action: 1
Lset27 = Ltmp17-Lfunc_begin1 ## >> Call Site 6 <<
.long Lset27
Lset28 = Ltmp18-Ltmp17 ## Call between Ltmp17 and Ltmp18
.long Lset28
Lset29 = Ltmp19-Lfunc_begin1 ## jumps to Ltmp19
.long Lset29
.byte 1 ## On action: 1
Lset30 = Ltmp27-Lfunc_begin1 ## >> Call Site 7 <<
.long Lset30
Lset31 = Ltmp28-Ltmp27 ## Call between Ltmp27 and Ltmp28
.long Lset31
Lset32 = Ltmp37-Lfunc_begin1 ## jumps to Ltmp37
.long Lset32
.byte 1 ## On action: 1
Lset33 = Ltmp28-Lfunc_begin1 ## >> Call Site 8 <<
.long Lset33
Lset34 = Ltmp32-Ltmp28 ## Call between Ltmp28 and Ltmp32
.long Lset34
.long 0 ## has no landing pad
.byte 0 ## On action: cleanup
Lset35 = Ltmp32-Lfunc_begin1 ## >> Call Site 9 <<
.long Lset35
Lset36 = Ltmp33-Ltmp32 ## Call between Ltmp32 and Ltmp33
.long Lset36
Lset37 = Ltmp34-Lfunc_begin1 ## jumps to Ltmp34
.long Lset37
.byte 0 ## On action: cleanup
Lset38 = Ltmp33-Lfunc_begin1 ## >> Call Site 10 <<
.long Lset38
Lset39 = Ltmp35-Ltmp33 ## Call between Ltmp33 and Ltmp35
.long Lset39
.long 0 ## has no landing pad
.byte 0 ## On action: cleanup
Lset40 = Ltmp35-Lfunc_begin1 ## >> Call Site 11 <<
.long Lset40
Lset41 = Ltmp36-Ltmp35 ## Call between Ltmp35 and Ltmp36
.long Lset41
Lset42 = Ltmp37-Lfunc_begin1 ## jumps to Ltmp37
.long Lset42
.byte 1 ## On action: 1
Lset43 = Ltmp36-Lfunc_begin1 ## >> Call Site 12 <<
.long Lset43
Lset44 = Lfunc_end1-Ltmp36 ## Call between Ltmp36 and Lfunc_end1
.long Lset44
.long 0 ## has no landing pad
.byte 0 ## On action: cleanup
.byte 1 ## >> Action Record 1 <<
## Catch TypeInfo 1
.byte 0 ## No further actions
## >> Catch TypeInfos <<
.long 0 ## TypeInfo 1
.p2align 2
.section __TEXT,__text,regular,pure_instructions
.private_extern __ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_
.globl __ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_
.weak_def_can_be_hidden __ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_
.p2align 4, 0x90
__ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_: ## @_ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_
Lfunc_begin2:
.cfi_startproc
.cfi_personality 155, ___gxx_personality_v0
.cfi_lsda 16, Lexception2
## BB#0:
pushq %rbp
Lcfi13:
.cfi_def_cfa_offset 16
Lcfi14:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Lcfi15:
.cfi_def_cfa_register %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $72, %rsp
Lcfi16:
.cfi_offset %rbx, -56
Lcfi17:
.cfi_offset %r12, -48
Lcfi18:
.cfi_offset %r13, -40
Lcfi19:
.cfi_offset %r14, -32
Lcfi20:
.cfi_offset %r15, -24
movq %r8, %r14
movq %rcx, %r12
movq %rdi, %r13
testq %r13, %r13
je LBB2_17
## BB#1:
movl %r9d, -44(%rbp) ## 4-byte Spill
movq %r12, %rax
subq %rsi, %rax
movq 24(%r14), %rcx
xorl %r15d, %r15d
subq %rax, %rcx
cmovgq %rcx, %r15
movq %rdx, -104(%rbp) ## 8-byte Spill
movq %rdx, %rbx
subq %rsi, %rbx
testq %rbx, %rbx
jle LBB2_3
## BB#2:
movq (%r13), %rax
movq %r13, %rdi
movq %rbx, %rdx
callq *96(%rax)
cmpq %rbx, %rax
jne LBB2_17
LBB2_3:
testq %r15, %r15
jle LBB2_13
## BB#4:
movq %r12, -88(%rbp) ## 8-byte Spill
movq %r14, -96(%rbp) ## 8-byte Spill
xorps %xmm0, %xmm0
movaps %xmm0, -80(%rbp)
movq $0, -64(%rbp)
cmpq $23, %r15
jae LBB2_8
## BB#5:
movl %r15d, %eax
addb %al, %al
movb %al, -80(%rbp)
leaq -79(%rbp), %r14
movq %r14, %r12
jmp LBB2_9
LBB2_8:
leaq 16(%r15), %rbx
andq $-16, %rbx
movq %rbx, %rdi
callq __Znwm
movq %rax, %r12
movq %r12, -64(%rbp)
orq $1, %rbx
movq %rbx, -80(%rbp)
movq %r15, -72(%rbp)
leaq -79(%rbp), %r14
LBB2_9:
movl -44(%rbp), %eax ## 4-byte Reload
movzbl %al, %esi
movq %r12, %rdi
movq %r15, %rdx
callq _memset
movb $0, (%r12,%r15)
testb $1, -80(%rbp)
cmovneq -64(%rbp), %r14
movq (%r13), %rax
Ltmp38:
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq *96(%rax)
movq %rax, %rbx
Ltmp39:
## BB#10:
testb $1, -80(%rbp)
movq -96(%rbp), %r14 ## 8-byte Reload
movq -88(%rbp), %r12 ## 8-byte Reload
je LBB2_12
## BB#11:
movq -64(%rbp), %rdi
callq __ZdlPv
LBB2_12:
cmpq %r15, %rbx
jne LBB2_17
LBB2_13:
movq -104(%rbp), %rsi ## 8-byte Reload
subq %rsi, %r12
testq %r12, %r12
jle LBB2_15
## BB#14:
movq (%r13), %rax
movq %r13, %rdi
movq %r12, %rdx
callq *96(%rax)
cmpq %r12, %rax
jne LBB2_17
LBB2_15:
movq $0, 24(%r14)
jmp LBB2_18
LBB2_17:
xorl %r13d, %r13d
LBB2_18:
movq %r13, %rax
addq $72, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
LBB2_19:
Ltmp40:
movq %rax, %rbx
testb $1, -80(%rbp)
je LBB2_21
## BB#20:
movq -64(%rbp), %rdi
callq __ZdlPv
LBB2_21:
movq %rbx, %rdi
callq __Unwind_Resume
Lfunc_end2:
.cfi_endproc
.section __TEXT,__gcc_except_tab
.p2align 2
GCC_except_table2:
Lexception2:
.byte 255 ## @LPStart Encoding = omit
.byte 155 ## @TType Encoding = indirect pcrel sdata4
.byte 41 ## @TType base offset
.byte 3 ## Call site Encoding = udata4
.byte 39 ## Call site table length
Lset45 = Lfunc_begin2-Lfunc_begin2 ## >> Call Site 1 <<
.long Lset45
Lset46 = Ltmp38-Lfunc_begin2 ## Call between Lfunc_begin2 and Ltmp38
.long Lset46
.long 0 ## has no landing pad
.byte 0 ## On action: cleanup
Lset47 = Ltmp38-Lfunc_begin2 ## >> Call Site 2 <<
.long Lset47
Lset48 = Ltmp39-Ltmp38 ## Call between Ltmp38 and Ltmp39
.long Lset48
Lset49 = Ltmp40-Lfunc_begin2 ## jumps to Ltmp40
.long Lset49
.byte 0 ## On action: cleanup
Lset50 = Ltmp39-Lfunc_begin2 ## >> Call Site 3 <<
.long Lset50
Lset51 = Lfunc_end2-Ltmp39 ## Call between Ltmp39 and Lfunc_end2
.long Lset51
.long 0 ## has no landing pad
.byte 0 ## On action: cleanup
.p2align 2
.section __TEXT,__text,regular,pure_instructions
.private_extern ___clang_call_terminate
.globl ___clang_call_terminate
.weak_def_can_be_hidden ___clang_call_terminate
.p2align 4, 0x90
___clang_call_terminate: ## @__clang_call_terminate
## BB#0:
pushq %rax
callq ___cxa_begin_catch
callq __ZSt9terminatev
.section __TEXT,__cstring,cstring_literals
L_.str: ## @.str
.asciz "Hello World!"
.subsections_via_symbols
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment