// File: /workspace/github_c_makefile_star2_O1/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 0x1804
movq %rax, %r15
movl $0x1000, %edx           # imm = 0x1000
movl %r12d, %edi
movq %rax, %rsi
callq 0x10a0
movq %rax, %r14
cmpb $0x1, 0x3(%rbx)
jne 0x1671
movq 0x2ac7(%rip), %rsi      # 0x40a0
cmpq $0x8, %rsi
ja 0x15f2
incq %rsi
movq %rsi, 0x2ab7(%rip)      # 0x40a0
leaq 0xab6(%rip), %rdi       # 0x20a6
jmp 0x166a
cmpq $0x62, %rsi
ja 0x160b
incq %rsi
movq %rsi, 0x2a9e(%rip)      # 0x40a0
leaq 0xa9e(%rip), %rdi       # 0x20a7
jmp 0x166a
cmpq $0x3e6, %rsi            # imm = 0x3E6
ja 0x1627
incq %rsi
movq %rsi, 0x2a82(%rip)      # 0x40a0
leaq 0xa83(%rip), %rdi       # 0x20a8
jmp 0x166a
cmpq $0x270e, %rsi           # imm = 0x270E
ja 0x1643
incq %rsi
movq %rsi, 0x2a66(%rip)      # 0x40a0
leaq 0xa68(%rip), %rdi       # 0x20a9
jmp 0x166a
leaq 0x1(%rsi), %rax
movq %rax, 0x2a52(%rip)      # 0x40a0
cmpq $0x1869e, %rsi          # imm = 0x1869E
ja 0x1660
leaq 0xa4c(%rip), %rdi       # 0x20aa
jmp 0x1667
leaq 0xa44(%rip), %rdi       # 0x20ab
movq %rax, %rsi
xorl %eax, %eax
callq 0x1060
testl %r14d, %r14d
je 0x17eb
movq 0x2957(%rip), %r13      # 0x3fd8
movl %r12d, -0x2c(%rbp)
testl %r14d, %r14d
jle 0x17cf
movl %r14d, %r14d
movq %r14, -0x38(%rbp)
negq %r14
movl $0x1, %r12d
cmpb $0x1, 0x2(%rbx)
jne 0x16ba
cmpb $0xa, -0x1(%r15,%r12)
jne 0x16ba
movq (%r13), %rsi
movl $0x24, %edi
callq 0x1090
cmpb $0x1, 0x5(%rbx)
jne 0x16dd
cmpb $0x9, -0x1(%r15,%r12)
jne 0x16dd
movq (%r13), %rsi
leaq 0x9de(%rip), %rdi       # 0x20b1
callq 0x1070
jmp 0x17bb
cmpb $0x1, 0x3(%rbx)
jne 0x172b
cmpb $0xa, -0x1(%r15,%r12)
sete %al
cmpq -0x38(%rbp), %r12
setb %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x172b
movq (%r13), %rsi
movl $0xa, %edi
callq 0x1090
movq 0x2991(%rip), %rsi      # 0x40a0
cmpq $0x8, %rsi
ja 0x173c
incq %rsi
movq %rsi, 0x2981(%rip)      # 0x40a0
leaq 0x980(%rip), %rdi       # 0x20a6
jmp 0x17b4
movsbl -0x1(%r15,%r12), %edi
movq (%r13), %rsi
callq 0x1090
jmp 0x17bb
cmpq $0x62, %rsi
ja 0x1755
incq %rsi
movq %rsi, 0x2954(%rip)      # 0x40a0
leaq 0x954(%rip), %rdi       # 0x20a7
jmp 0x17b4
cmpq $0x3e6, %rsi            # imm = 0x3E6
ja 0x1771
incq %rsi
movq %rsi, 0x2938(%rip)      # 0x40a0
leaq 0x939(%rip), %rdi       # 0x20a8
jmp 0x17b4
cmpq $0x270e, %rsi           # imm = 0x270E
ja 0x178d
incq %rsi
movq %rsi, 0x291c(%rip)      # 0x40a0
leaq 0x91e(%rip), %rdi       # 0x20a9
jmp 0x17b4
leaq 0x1(%rsi), %rax
movq %rax, 0x2908(%rip)      # 0x40a0
cmpq $0x1869e, %rsi          # imm = 0x1869E
ja 0x17aa
leaq 0x902(%rip), %rdi       # 0x20aa
jmp 0x17b1
leaq 0x8fa(%rip), %rdi       # 0x20ab
movq %rax, %rsi
xorl %eax, %eax
callq 0x1060
leaq (%r14,%r12), %rax
incq %rax
incq %r12
cmpq $0x1, %rax
jne 0x169e
movl $0x1000, %edx           # imm = 0x1000
movl -0x2c(%rbp), %edi
movq %r15, %rsi
callq 0x10a0
movq %rax, %r14
testl %r14d, %r14d
jne 0x1685
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