Skip to content

Instantly share code, notes, and snippets.

@jotaki
Created October 3, 2013 06:54
Show Gist options
  • Save jotaki/6806079 to your computer and use it in GitHub Desktop.
Save jotaki/6806079 to your computer and use it in GitHub Desktop.
.file "mynewx.c"
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "numbers.txt"
.LC1:
.string "%u\n"
.LC2:
.string "%d in %ld ms\n"
.section .text.startup,"ax",@progbits
.p2align 4,,15
.globl main
.type main, @function
main:
.LFB76:
.cfi_startproc
pushq %r15
.cfi_def_cfa_offset 16
.cfi_offset 15, -16
movl $.LC0, %esi
movl %edi, %r15d
movl $1, %edi
pushq %r14
.cfi_def_cfa_offset 24
.cfi_offset 14, -24
pushq %r13
.cfi_def_cfa_offset 32
.cfi_offset 13, -32
pushq %r12
.cfi_def_cfa_offset 40
.cfi_offset 12, -40
pushq %rbp
.cfi_def_cfa_offset 48
.cfi_offset 6, -48
pushq %rbx
.cfi_def_cfa_offset 56
.cfi_offset 3, -56
subq $152, %rsp
.cfi_def_cfa_offset 208
movq %rsp, %rdx
call __xstat
movq 48(%rsp), %rbp
leaq 1(%rbp), %rdi
call malloc
movq %rax, %r13
call clock
xorl %esi, %esi
movq %rax, %r14
movl $.LC0, %edi
xorl %eax, %eax
movq %r13, %rbx
call open
cmpl $-1, %eax
movl %eax, %r12d
jne .L3
jmp .L2
.p2align 4,,10
.p2align 3
.L4:
addq %rax, %rbx
.L3:
movl $4096, %edx
movq %rbx, %rsi
movl %r12d, %edi
call read
testq %rax, %rax
jne .L4
cmpl $1, %r15d
movb $10, (%rbx)
je .L19
addq %r13, %rbp
xorl %r15d, %r15d
cmpq %rbp, %r13
jae .L7
.p2align 4,,10
.p2align 3
.L17:
addq $1, %r13
cmpb $10, 0(%r13)
jne .L17
addl $1, %r15d
cmpq %r13, %rbp
ja .L17
.L7:
movl %r12d, %edi
call close
call clock
movq %rax, %rsi
movabsq $2361183241434822607, %rcx
movl $1, %edi
subq %r14, %rsi
movq %rsi, %rax
sarq $63, %rsi
imulq %rcx
xorl %eax, %eax
movq %rdx, %rcx
movl %r15d, %edx
sarq $7, %rcx
subq %rsi, %rcx
movl $.LC2, %esi
call __printf_chk
.L2:
addq $152, %rsp
.cfi_remember_state
.cfi_def_cfa_offset 56
xorl %eax, %eax
popq %rbx
.cfi_def_cfa_offset 48
popq %rbp
.cfi_def_cfa_offset 40
popq %r12
.cfi_def_cfa_offset 32
popq %r13
.cfi_def_cfa_offset 24
popq %r14
.cfi_def_cfa_offset 16
popq %r15
.cfi_def_cfa_offset 8
ret
.L19:
.cfi_restore_state
movq %r13, %rax
addq 48(%rsp), %rax
xorb %r15b, %r15b
cmpq %rax, %r13
jae .L7
movq %r13, %rbp
xorl %r15d, %r15d
.p2align 4,,10
.p2align 3
.L6:
movsbl 0(%rbp), %eax
movl $52543, %edx
.p2align 4,,10
.p2align 3
.L10:
addq $1, %rbp
movl %eax, %esi
movzbl 0(%rbp), %ecx
movl %esi, %edi
andl $240, %edi
movsbl %cl, %eax
movl %ecx, %ebx
addl %eax, %edi
sarb $4, %bl
leal (%rdi,%rdi,4), %r8d
leal (%rdi,%r8,2), %edi
leal (%rdi,%rdx,2), %edx
movl %ebx, %edi
xorl %esi, %edi
imull %eax, %esi
andl $15, %edi
addl %edi, %edx
sall $19, %esi
xorl %esi, %edx
cmpb $10, %cl
jne .L10
xorl %eax, %eax
movl $.LC1, %esi
movl $1, %edi
call __printf_chk
movq %r13, %rax
addq 48(%rsp), %rax
addl $1, %r15d
cmpq %rax, %rbp
jb .L6
jmp .L7
.cfi_endproc
.LFE76:
.size main, .-main
.ident "GCC: (Gentoo 4.6.3 p1.13, pie-0.5.2) 4.6.3"
.section .note.GNU-stack,"",@progbits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment