// File: /workspace/github_c_makefile_star2_O3/ikbenlike[P]nngutils/src/cat.c
// Function: print_file
int print_file(int fd, struct cat_args *args, char *name){
    int endchar;
    static unsigned long int nline = 0;
    char *buf = calloc(1, 4096 * sizeof(char));
    if(buf == NULL){
        fprintf(stderr, "%s: %s\n", name, strerror(errno));
        exit(1);
    }
    int buf_len = read(fd, buf, 4096);
    if(args->number){
        if(nline < 9){
            printf("     %lu  ", ++nline);
        }
        else if(nline < 99){
            printf("    %lu  ", ++nline);
        }
        else if(nline < 999){
            printf("   %lu  ", ++nline);
        }
        else if(nline < 9999){
            printf("  %lu  ", ++nline);
        }
        else if(nline < 99999){
            printf(" %lu  ", ++nline);
        }
        else{ 
            printf("%lu  ", ++nline);
        }
    }
    while(buf_len != 0){
        for(int i = 0; i < buf_len; i++){
            if(args->show_ends && buf[i] == '\n'){
                fputc('$', stdout);
            }
            if(args->show_tabs && buf[i] == '\t'){
                fputs("^I", stdout);
                continue;
            }
            if(args->number && buf[i] == '\n' && i + 1 < buf_len){
                fputc(buf[i], stdout);
                if(nline < 9){
                    printf("     %lu  ", ++nline);
                }
                else if(nline < 99){
                    printf("    %lu  ", ++nline);
                }
                else if(nline < 999){
                    printf("   %lu  ", ++nline);
                }
                else if(nline < 9999){
                    printf("  %lu  ", ++nline);
                }
                else if(nline < 99999){
                    printf(" %lu  ", ++nline);
                }
                else{ 
                    printf("%lu  ", ++nline);
                }
                continue;
            }
            fputc(buf[i], stdout);
        }
        buf_len = read(fd, buf, 4096);
    }
    free(buf);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movl %edi, %r12d
movl $0x1, %edi
movl $0x1000, %esi           # imm = 0x1000
callq 0x10b0
testq %rax, %rax
je 0x17cb
movq %rax, %r15
movl $0x1000, %edx           # imm = 0x1000
movl %r12d, %edi
movq %rax, %rsi
callq 0x10a0
movq %rax, %r14
cmpb $0x1, 0x3(%rbx)
jne 0x1643
movq 0x2af5(%rip), %rsi      # 0x40a0
cmpq $0x8, %rsi
ja 0x15c4
incq %rsi
movq %rsi, 0x2ae5(%rip)      # 0x40a0
leaq 0xac6(%rip), %rdi       # 0x2088
jmp 0x163c
cmpq $0x62, %rsi
ja 0x15dd
incq %rsi
movq %rsi, 0x2acc(%rip)      # 0x40a0
leaq 0xaae(%rip), %rdi       # 0x2089
jmp 0x163c
cmpq $0x3e6, %rsi            # imm = 0x3E6
ja 0x15f9
incq %rsi
movq %rsi, 0x2ab0(%rip)      # 0x40a0
leaq 0xa93(%rip), %rdi       # 0x208a
jmp 0x163c
cmpq $0x270e, %rsi           # imm = 0x270E
ja 0x1615
incq %rsi
movq %rsi, 0x2a94(%rip)      # 0x40a0
leaq 0xa78(%rip), %rdi       # 0x208b
jmp 0x163c
leaq 0x1(%rsi), %rax
movq %rax, 0x2a80(%rip)      # 0x40a0
cmpq $0x1869e, %rsi          # imm = 0x1869E
ja 0x1632
leaq 0xa5c(%rip), %rdi       # 0x208c
jmp 0x1639
leaq 0xa54(%rip), %rdi       # 0x208d
movq %rax, %rsi
xorl %eax, %eax
callq 0x1060
testl %r14d, %r14d
je 0x17b2
movq 0x2985(%rip), %r13      # 0x3fd8
movl %r12d, -0x2c(%rbp)
testl %r14d, %r14d
jle 0x1796
movl %r14d, %r14d
movq %r14, -0x38(%rbp)
negq %r14
movl $0x1, %r12d
cmpb $0x1, 0x2(%rbx)
jne 0x168c
cmpb $0xa, -0x1(%r15,%r12)
jne 0x168c
movq (%r13), %rsi
movl $0x24, %edi
callq 0x1090
cmpb $0x1, 0x5(%rbx)
jne 0x16af
cmpb $0x9, -0x1(%r15,%r12)
jne 0x16af
movq (%r13), %rsi
leaq 0x9ee(%rip), %rdi       # 0x2093
callq 0x1070
jmp 0x1782
movsbl -0x1(%r15,%r12), %edi
cmpb $0x1, 0x3(%rbx)
jne 0x16f8
cmpb $0xa, %dil
jne 0x16f8
cmpq -0x38(%rbp), %r12
jae 0x16f8
movq (%r13), %rsi
movl $0xa, %edi
callq 0x1090
movq 0x29c4(%rip), %rsi      # 0x40a0
cmpq $0x8, %rsi
ja 0x1703
incq %rsi
movq %rsi, 0x29b4(%rip)      # 0x40a0
leaq 0x995(%rip), %rdi       # 0x2088
jmp 0x177b
movq (%r13), %rsi
callq 0x1090
jmp 0x1782
cmpq $0x62, %rsi
ja 0x171c
incq %rsi
movq %rsi, 0x298d(%rip)      # 0x40a0
leaq 0x96f(%rip), %rdi       # 0x2089
jmp 0x177b
cmpq $0x3e6, %rsi            # imm = 0x3E6
ja 0x1738
incq %rsi
movq %rsi, 0x2971(%rip)      # 0x40a0
leaq 0x954(%rip), %rdi       # 0x208a
jmp 0x177b
cmpq $0x270e, %rsi           # imm = 0x270E
ja 0x1754
incq %rsi
movq %rsi, 0x2955(%rip)      # 0x40a0
leaq 0x939(%rip), %rdi       # 0x208b
jmp 0x177b
leaq 0x1(%rsi), %rax
movq %rax, 0x2941(%rip)      # 0x40a0
cmpq $0x1869e, %rsi          # imm = 0x1869E
ja 0x1771
leaq 0x91d(%rip), %rdi       # 0x208c
jmp 0x1778
leaq 0x915(%rip), %rdi       # 0x208d
movq %rax, %rsi
xorl %eax, %eax
callq 0x1060
leaq (%r14,%r12), %rax
incq %rax
incq %r12
cmpq $0x1, %rax
jne 0x1670
movl $0x1000, %edx           # imm = 0x1000
movl -0x2c(%rbp), %edi
movq %r15, %rsi
callq 0x10a0
movq %rax, %r14
testl %r14d, %r14d
jne 0x1657
movq %r15, %rdi
callq 0x1030
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0x114d