.section .text .L28: .string "Total distance: %zu\n" .L24: .string "%d\n" .L23: .string "%d " .L7: .string "r" .L6: .string "./input" .global isdigit isdigit: push rbp mov rbp, rsp sub rsp, 16 mov byte ptr [rbp - 1], dil mov r14b, byte ptr [rbp - 1] mov r13b, 48 cmp r14b, r13b setge r15b cmp r15b, 0 je .L0 mov r14b, byte ptr [rbp - 1] mov r13b, 57 cmp r14b, r13b setle r15b cmp r15b, 0 je .L0 mov r15b, 1 jmp .L1 .L0: mov r15b, 0 .L1: cmp r15b, 0 je .L3 mov r15b, 1 movzx rax, r15b jmp isdigit_ret jmp .L2 .L3: mov r15b, 0 movzx rax, r15b jmp isdigit_ret .L2: isdigit_ret: leave ret .global compare compare: push rbp mov rbp, rsp sub rsp, 32 mov qword ptr [rbp - 8], rdi mov qword ptr [rbp - 16], rsi mov r14, qword ptr [rbp - 16] mov r15d, dword ptr [r14] mov eax, r15d cdqe mov r15, rax mov qword ptr [rbp - 24], r15 mov r14, qword ptr [rbp - 8] mov r15d, dword ptr [r14] mov eax, r15d cdqe mov r15, rax mov qword ptr [rbp - 32], r15 mov r15, qword ptr [rbp - 32] mov r14, qword ptr [rbp - 24] sub r14, r15 mov r15, r14 mov eax, r15d cdqe mov rax, rax jmp compare_ret compare_ret: leave ret .global find_non_digit find_non_digit: push rbp mov rbp, rsp sub rsp, 16 mov qword ptr [rbp - 8], rdi .L4: mov r13, qword ptr [rbp - 8] movzx r14, byte ptr [r13] mov rdi, r14 call OFFSET isdigit mov r15b, al cmp r15b, 0 je .L5 mov r14, qword ptr [rbp - 8] mov rax, 1 mov r12, 1 imul r12 mov r12, rax add r14, r12 mov qword ptr [rbp - 8], r14 jmp .L4 .L5: mov r15, qword ptr [rbp - 8] mov rax, r15 jmp find_non_digit_ret find_non_digit_ret: leave ret .global main main: push rbp mov rbp, rsp sub rsp, 160 mov byte ptr [rbp - 1], 10 mov r15, OFFSET .L6 mov rdi, r15 mov r15, OFFSET .L7 mov rsi, r15 call OFFSET fopen mov qword ptr [rbp - 9], rax mov r15, qword ptr [rbp - 9] mov rdi, r15 mov r15, 0 mov rsi, r15 mov r15, 2 mov rdx, r15 call OFFSET fseek mov r15, qword ptr [rbp - 9] mov rdi, r15 call OFFSET ftell mov qword ptr [rbp - 17], rax mov r15, qword ptr [rbp - 9] mov rdi, r15 call OFFSET rewind mov r15, qword ptr [rbp - 17] mov rdi, r15 call OFFSET malloc mov qword ptr [rbp - 25], rax mov r15, qword ptr [rbp - 25] mov rdi, r15 mov r15, 1 mov rsi, r15 mov r15, qword ptr [rbp - 17] mov rdx, r15 mov r15, qword ptr [rbp - 9] mov rcx, r15 call OFFSET fread mov qword ptr [rbp - 33], 0 mov qword ptr [rbp - 41], 0 .L8: mov r14, qword ptr [rbp - 41] mov r13, qword ptr [rbp - 17] cmp r14, r13 setl r15b cmp r15b, 0 je .L9 mov r14, qword ptr [rbp - 41] mov r13, qword ptr [rbp - 25] mov rax, 1 mov r12, r14 imul r12 mov r12, rax add r13, r12 mov r14, r13 mov qword ptr [rbp - 49], r14 mov r11, qword ptr [rbp - 49] mov r13b, byte ptr [r11] mov r12b, byte ptr [rbp - 1] cmp r13b, r12b sete r14b cmp r14b, 0 je .L12 mov r14, qword ptr [rbp - 33] add r14, 1 mov qword ptr [rbp - 33], r14 .L12: .L10: mov r14, qword ptr [rbp - 41] add r14, 1 mov qword ptr [rbp - 41], r14 jmp .L8 .L9: mov r15, qword ptr [rbp - 33] mov rax, r15 mov r15, 4 imul r15 mov r15, rax mov rdi, r15 call OFFSET malloc mov qword ptr [rbp - 57], rax mov r15, qword ptr [rbp - 33] mov rax, r15 mov r15, 4 imul r15 mov r15, rax mov rdi, r15 call OFFSET malloc mov qword ptr [rbp - 65], rax mov byte ptr [rbp - 66], 0 mov qword ptr [rbp - 74], 0 mov qword ptr [rbp - 82], 0 .L13: mov r14, qword ptr [rbp - 82] mov r13, qword ptr [rbp - 17] cmp r14, r13 setl r15b cmp r15b, 0 je .L14 mov r14, qword ptr [rbp - 82] mov r13, qword ptr [rbp - 25] mov rax, 1 mov r12, r14 imul r12 mov r12, rax add r13, r12 mov r14, r13 lea r13, [r14] mov r12b, byte ptr [r13] mov byte ptr [rbp - 83], r12b movzx r13, byte ptr [rbp - 83] mov rdi, r13 call OFFSET isdigit mov r14b, al cmp r14b, 0 je .L17 mov r13, qword ptr [rbp - 82] mov r12, qword ptr [rbp - 25] mov rax, 1 mov r11, r13 imul r11 mov r11, rax add r12, r11 mov r13, r12 mov rdi, r13 call OFFSET find_non_digit mov r14, rax mov byte ptr [r14], 0 mov r14, qword ptr [rbp - 82] mov r13, qword ptr [rbp - 25] mov rax, 1 mov r12, r14 imul r12 mov r12, rax add r13, r12 mov r14, r13 mov rdi, r14 call OFFSET atoi mov dword ptr [rbp - 87], eax mov r13b, byte ptr [rbp - 66] mov r12b, 0 cmp r13b, r12b sete r14b cmp r14b, 0 je .L19 mov r14, qword ptr [rbp - 74] mov r13, qword ptr [rbp - 57] mov rax, 4 mov r12, r14 imul r12 mov r12, rax add r13, r12 mov r14, r13 mov qword ptr [rbp - 95], r14 mov r14, qword ptr [rbp - 95] lea r13, [rbp - 87] mov r12d, dword ptr [r13] mov dword ptr [r14], r12d mov byte ptr [rbp - 66], 1 jmp .L18 .L19: mov r14, qword ptr [rbp - 74] mov r13, qword ptr [rbp - 65] mov rax, 4 mov r12, r14 imul r12 mov r12, rax add r13, r12 mov r14, r13 mov qword ptr [rbp - 103], r14 mov r14, qword ptr [rbp - 103] lea r13, [rbp - 87] mov r12d, dword ptr [r13] mov dword ptr [r14], r12d mov r14, qword ptr [rbp - 74] add r14, 1 mov qword ptr [rbp - 74], r14 mov byte ptr [rbp - 66], 0 .L18: mov r14, qword ptr [rbp - 82] mov r13, qword ptr [rbp - 25] mov rax, 1 mov r12, r14 imul r12 mov r12, rax add r13, r12 mov r14, r13 mov rdi, r14 call OFFSET strlen mov qword ptr [rbp - 111], rax mov r14, qword ptr [rbp - 111] mov r13, qword ptr [rbp - 82] add r13, r14 mov r14, r13 mov qword ptr [rbp - 82], r14 .L17: .L15: mov r14, qword ptr [rbp - 82] add r14, 1 mov qword ptr [rbp - 82], r14 jmp .L13 .L14: mov qword ptr [rbp - 119], 0 .L20: mov r14, qword ptr [rbp - 119] mov r13, qword ptr [rbp - 33] cmp r14, r13 setl r15b cmp r15b, 0 je .L21 mov r14, qword ptr [rbp - 119] mov r13, qword ptr [rbp - 57] mov rax, 4 mov r12, r14 imul r12 mov r12, rax add r13, r12 mov r14, r13 lea r13, [r14] mov r12d, dword ptr [r13] mov dword ptr [rbp - 123], r12d mov r14, qword ptr [rbp - 119] mov r13, qword ptr [rbp - 65] mov rax, 4 mov r12, r14 imul r12 mov r12, rax add r13, r12 mov r14, r13 lea r13, [r14] mov r12d, dword ptr [r13] mov dword ptr [rbp - 127], r12d mov r14, OFFSET .L23 mov rdi, r14 mov r14d, dword ptr [rbp - 123] mov eax, r14d mov r14, rax mov rsi, r14 call OFFSET printf mov r14, OFFSET .L24 mov rdi, r14 mov r14d, dword ptr [rbp - 127] mov eax, r14d mov r14, rax mov rsi, r14 call OFFSET printf .L22: mov r14, qword ptr [rbp - 119] add r14, 1 mov qword ptr [rbp - 119], r14 jmp .L20 .L21: mov r15, qword ptr [rbp - 25] mov rdi, r15 call OFFSET free mov r15, qword ptr [rbp - 57] mov rdi, r15 mov r15, qword ptr [rbp - 33] mov rsi, r15 mov r15, 4 mov rdx, r15 mov r15, OFFSET compare mov rcx, r15 call OFFSET qsort mov r15, qword ptr [rbp - 65] mov rdi, r15 mov r15, qword ptr [rbp - 33] mov rsi, r15 mov r15, 3 mov rdx, r15 mov r15, OFFSET compare mov rcx, r15 call OFFSET qsort mov qword ptr [rbp - 135], 0 mov qword ptr [rbp - 143], 0 .L25: mov r14, qword ptr [rbp - 143] mov r13, qword ptr [rbp - 33] cmp r14, r13 setl r15b cmp r15b, 0 je .L26 mov r14, qword ptr [rbp - 143] mov r13, qword ptr [rbp - 57] mov rax, 4 mov r12, r14 imul r12 mov r12, rax add r13, r12 mov r14, r13 lea r13, [r14] mov r12d, dword ptr [r13] mov dword ptr [rbp - 147], r12d mov r14, qword ptr [rbp - 143] mov r13, qword ptr [rbp - 65] mov rax, 4 mov r12, r14 imul r12 mov r12, rax add r13, r12 mov r14, r13 lea r13, [r14] mov r12d, dword ptr [r13] mov dword ptr [rbp - 151], r12d mov r14d, dword ptr [rbp - 151] mov r13d, dword ptr [rbp - 147] sub r13d, r14d mov r14d, r13d mov dword ptr [rbp - 155], r14d mov eax, dword ptr [rbp - 155] mov r14, rax mov rdi, r14 call OFFSET abs mov dword ptr [rbp - 159], eax mov r14d, dword ptr [rbp - 159] mov eax, r14d cdqe mov r14, rax mov r13, qword ptr [rbp - 135] add r13, r14 mov r14, r13 mov qword ptr [rbp - 135], r14 .L27: mov r14, qword ptr [rbp - 143] add r14, 1 mov qword ptr [rbp - 143], r14 jmp .L25 .L26: mov r15, qword ptr [rbp - 57] mov rdi, r15 call OFFSET free mov r15, qword ptr [rbp - 65] mov rdi, r15 call OFFSET free mov r15, OFFSET .L28 mov rdi, r15 mov r15, qword ptr [rbp - 135] mov rsi, r15 call OFFSET printf mov r15b, 0 movzx rax, r15b jmp main_ret main_ret: leave ret