Skip to content

Instantly share code, notes, and snippets.

Created June 27, 2017 19:36
Show Gist options
  • Save anonymous/c4708600946f04b87c8b9586b15e3017 to your computer and use it in GitHub Desktop.
Save anonymous/c4708600946f04b87c8b9586b15e3017 to your computer and use it in GitHub Desktop.
The old asm:
_ZN5test44main17hde37e0367608b3d5E:
pushq %r15
pushq %r14
pushq %rsi
pushq %rdi
pushq %rbx
subq $144, %rsp
movl $20000000, %ecx
movl $1, %edx
callq __rust_allocate
movq %rax, %r15
testq %r15, %r15
je .LBB1_15
movl $2, %edx
movl $20000000, %r8d
movq %r15, %rcx
callq memset
xorl %r14d, %r14d
movl $1, %eax
jmp .LBB1_2
.p2align 4, 0x90
.LBB1_8:
movb (%r15,%rdx), %r9b
movl %r9d, %edx
addb $-25, %dl
cmpb %bl, %dl
movl $0, %edx
cmoveq %rcx, %rdx
addq %rdx, %r14
cmpq $39999999, %rcx
ja .LBB1_2
leaq -1(%r8,%r8), %r8
negb %bl
.p2align 4, 0x90
.LBB1_10:
movq %rcx, %rdi
shrq %rdi
.p2align 4, 0x90
.LBB1_11:
movq %rdi, %rdx
addq %rcx, %rdx
movl $20000000, %esi
cmovaeq %rdx, %rsi
movzbl (%r15,%rdi), %edx
addb %r9b, %dl
addb %bl, %dl
addb $-2, %dl
movb %dl, (%r15,%rdi)
movq %rsi, %rdi
cmpq $20000000, %rsi
jb .LBB1_11
movq %r8, %rdx
imulq %rcx, %rdx
imulq %r10, %rcx
leaq (%rdx,%rcx,2), %rcx
cmpq $40000000, %rcx
jb .LBB1_10
.p2align 4, 0x90
.LBB1_2:
movq %rax, %r8
leaq -1(%r8,%r8), %rcx
xorl %r10d, %r10d
.p2align 4, 0x90
.LBB1_3:
cmpq $19999999, %rax
ja .LBB1_13
addq $1, %r10
addq $2, %rcx
cmpb $2, (%r15,%rax)
leaq 1(%rax), %rax
ja .LBB1_3
leaq -1(%rax), %rdx
xorl %ebx, %ebx
.p2align 4, 0x90
.LBB1_6:
movq %rdx, %rsi
shrq %rdx
addb $-1, %bl
testb $1, %sil
je .LBB1_6
cmpq $40000000, %rsi
jb .LBB1_8
leaq panic_bounds_check_loc.2(%rip), %rcx
movl $20000000, %r8d
callq _ZN4core9panicking18panic_bounds_check17hc1b5ea060cf92e68E
ud2
.LBB1_13:
movl $20000000, %edx
movl $1, %r8d
movq %r15, %rcx
callq __rust_deallocate
movq %r14, 40(%rsp)
leaq 40(%rsp), %rax
movq %rax, 48(%rsp)
leaq ref.4(%rip), %rax
movq %rax, 56(%rsp)
movabsq $1677366278943, %rax
cmpq %rax, %r14
jne .LBB1_17
addq $144, %rsp
popq %rbx
popq %rdi
popq %rsi
popq %r14
popq %r15
retq
.LBB1_15:
callq _ZN5alloc3oom3oom17h3058f2f8bf84e7b0E
ud2
.LBB1_17:
leaq 48(%rsp), %rax
movq %rax, 64(%rsp)
leaq _ZN53_$LT$$RF$$u27$a$u20$T$u20$as$u20$core..fmt..Debug$GT$3fmt17h5359b8d7ffbfc5a0E(%rip), %rax
movq %rax, 72(%rsp)
leaq 56(%rsp), %rcx
movq %rcx, 80(%rsp)
movq %rax, 88(%rsp)
leaq ref.9(%rip), %rax
movq %rax, 96(%rsp)
movq $3, 104(%rsp)
movq $0, 112(%rsp)
leaq 64(%rsp), %rax
movq %rax, 128(%rsp)
movq $2, 136(%rsp)
leaq _ZN5test44main10_FILE_LINE17ha4ac6e59b8b9993dE(%rip), %rdx
leaq 96(%rsp), %rcx
callq _ZN3std9panicking15begin_panic_fmt17h86c214ca1e42d813E
ud2
The new asm:
_ZN5test44main17hde37e0367608b3d5E:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rsi
pushq %rdi
pushq %rbp
pushq %rbx
subq $152, %rsp
leaq 64(%rsp), %rcx
movl $20000000, %edx
movl $1, %r8d
callq _ZN5alloc9allocator6Layout15from_size_align17he4ea7424a3dbcbdcE
cmpq $0, 64(%rsp)
je .LBB1_2
vmovups 72(%rsp), %xmm0
vmovaps %xmm0, 32(%rsp)
leaq 64(%rsp), %rcx
leaq 112(%rsp), %r15
leaq 32(%rsp), %r14
movq %r15, %rdx
movq %r14, %r8
callq _ZN66_$LT$alloc..heap..HeapAlloc$u20$as$u20$alloc..allocator..Alloc$GT$5alloc17h177ce93396a87701E
cmpq $0, 64(%rsp)
jne .LBB1_8
movq 72(%rsp), %rbp
movl $20000000, %r13d
movl $2, %edx
movl $20000000, %r8d
movq %rbp, %rcx
callq memset
movq %rbp, 32(%rsp)
vmovaps .LCPI1_0(%rip), %xmm0
vmovups %xmm0, 40(%rsp)
xorl %r12d, %r12d
movl $1, %r11d
movl $20000000, %r8d
jmp .LBB1_15
.LBB1_14:
movq 32(%rsp), %rbp
movq 48(%rsp), %r8
.p2align 4, 0x90
.LBB1_15:
movq %r11, %r9
leaq -1(%r9,%r9), %rcx
xorl %edi, %edi
movq %r9, %rdx
.p2align 4, 0x90
.LBB1_16:
cmpq $20000000, %rdx
jae .LBB1_17
cmpq %rdx, %r8
jbe .LBB1_40
leaq 1(%rdx), %r11
addq $1, %rdi
addq $2, %rcx
cmpb $2, (%rbp,%rdx)
movq %r11, %rdx
ja .LBB1_16
leaq -1(%r11), %rdx
xorl %esi, %esi
.p2align 4, 0x90
.LBB1_29:
movl %edx, %ebx
shrq %rdx
addb $-1, %sil
testb $1, %bl
je .LBB1_29
cmpq %rdx, %r8
jbe .LBB1_40
movb (%rbp,%rdx), %r10b
movl %r10d, %edx
addb $-25, %dl
cmpb %sil, %dl
movl $0, %edx
cmoveq %rcx, %rdx
addq %rdx, %r12
cmpq $39999999, %rcx
ja .LBB1_15
leaq -1(%r9,%r9), %r9
negb %sil
.p2align 4, 0x90
.LBB1_33:
movq %rcx, %rdx
shrq %rdx
.p2align 4, 0x90
.LBB1_34:
movq %rdx, %rbp
addq %rcx, %rbp
setb %bl
movq 48(%rsp), %r8
cmpq %rdx, %r8
jbe .LBB1_41
movq 32(%rsp), %rax
testb %bl, %bl
cmovneq %r13, %rbp
movzbl (%rax,%rdx), %ebx
addb %r10b, %bl
addb %sil, %bl
addb $-2, %bl
movb %bl, (%rax,%rdx)
movq %rbp, %rdx
cmpq $20000000, %rbp
jb .LBB1_34
movq %r9, %rdx
imulq %rcx, %rdx
imulq %rdi, %rcx
leaq (%rdx,%rcx,2), %rcx
cmpq $40000000, %rcx
jb .LBB1_33
jmp .LBB1_14
.LBB1_17:
movq 40(%rsp), %rsi
testq %rsi, %rsi
je .LBB1_38
leaq 64(%rsp), %rcx
movl $1, %edx
movl $1, %r8d
callq _ZN5alloc9allocator6Layout15from_size_align17he4ea7424a3dbcbdcE
cmpq $0, 64(%rsp)
je .LBB1_19
vmovups 72(%rsp), %xmm0
vmovaps %xmm0, 112(%rsp)
leaq 64(%rsp), %rcx
leaq 112(%rsp), %rdx
movq %rsi, %r8
callq _ZN5alloc9allocator6Layout6repeat17h9ab668c62bc63d7eE
cmpq $0, 64(%rsp)
je .LBB1_23
vmovups 72(%rsp), %xmm0
leaq 48(%rsp), %rcx
vmovaps %xmm0, 64(%rsp)
leaq 64(%rsp), %r8
movq %rbp, %rdx
callq _ZN66_$LT$alloc..heap..HeapAlloc$u20$as$u20$alloc..allocator..Alloc$GT$7dealloc17h25a3b92034540e3dE
.LBB1_38:
movq %r12, 136(%rsp)
leaq 136(%rsp), %rax
movq %rax, 144(%rsp)
leaq ref.4(%rip), %rax
movq %rax, 112(%rsp)
movabsq $1677366278943, %rax
cmpq %rax, %r12
jne .LBB1_42
addq $152, %rsp
popq %rbx
popq %rbp
popq %rdi
popq %rsi
popq %r12
popq %r13
popq %r14
popq %r15
retq
.LBB1_40:
leaq panic_bounds_check_loc.2(%rip), %rcx
callq _ZN4core9panicking18panic_bounds_check17hc94bb2d7d20ff74cE
ud2
.LBB1_41:
leaq panic_bounds_check_loc.3(%rip), %rcx
callq _ZN4core9panicking18panic_bounds_check17hc94bb2d7d20ff74cE
ud2
.LBB1_2:
.Ltmp12:
leaq _ZN38_$LT$core..option..Option$LT$T$GT$$GT$6unwrap14_MSG_FILE_LINE17hc13aed2dd4121e3bE(%rip), %rcx
callq _ZN4core9panicking5panic17hc4bc423e36a079b2E
.Ltmp13:
ud2
.LBB1_8:
ud2
ud2
.LBB1_42:
leaq 144(%rsp), %rax
movq %rax, 32(%rsp)
leaq _ZN53_$LT$$RF$$u27$a$u20$T$u20$as$u20$core..fmt..Debug$GT$3fmt17ha6ed145788af8ef5E(%rip), %rax
movq %rax, 40(%rsp)
movq %r15, 48(%rsp)
movq %rax, 56(%rsp)
leaq ref.9(%rip), %rax
movq %rax, 64(%rsp)
movq $3, 72(%rsp)
movq $0, 80(%rsp)
movq %r14, 96(%rsp)
movq $2, 104(%rsp)
leaq _ZN5test44main10_FILE_LINE17ha4ac6e59b8b9993dE(%rip), %rdx
leaq 64(%rsp), %rcx
callq _ZN3std9panicking15begin_panic_fmt17hb8cee25661fb7188E
ud2
.LBB1_19:
leaq _ZN38_$LT$core..option..Option$LT$T$GT$$GT$6unwrap14_MSG_FILE_LINE17hc13aed2dd4121e3bE(%rip), %rcx
callq _ZN4core9panicking5panic17hc4bc423e36a079b2E
ud2
.LBB1_23:
leaq _ZN38_$LT$core..option..Option$LT$T$GT$$GT$6unwrap14_MSG_FILE_LINE17hc13aed2dd4121e3bE(%rip), %rcx
callq _ZN4core9panicking5panic17hc4bc423e36a079b2E
ud2
.LBB1_25:
jmp .LBB1_10
.LBB1_21:
jmp .LBB1_10
.LBB1_4:
movq %rax, %rcx
callq rust_eh_unwind_resume
ud2
.LBB1_11:
jmp .LBB1_10
.LBB1_12:
jmp .LBB1_10
.LBB1_9:
.LBB1_10:
movq %rax, %rcx
callq rust_eh_unwind_resume
ud2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment