// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x1
popq %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x10b0
testq %rax, %rax
je 0x16d0
movq %rax, %r15
movl $0x1000, %edx           # imm = 0x1000
movl %r12d, %edi
movq %rax, %rsi
callq 0x10a0
movq %rax, %r14
cmpb $0x1, 0x3(%rbx)
jne 0x1551
movq 0x2be7(%rip), %rsi      # 0x40a0
cmpq $0x8, %rsi
ja 0x14d2
incq %rsi
movq %rsi, 0x2bd7(%rip)      # 0x40a0
leaq 0xbb8(%rip), %rdi       # 0x2088
jmp 0x154a
cmpq $0x62, %rsi
ja 0x14eb
incq %rsi
movq %rsi, 0x2bbe(%rip)      # 0x40a0
leaq 0xba0(%rip), %rdi       # 0x2089
jmp 0x154a
cmpq $0x3e6, %rsi            # imm = 0x3E6
ja 0x1507
incq %rsi
movq %rsi, 0x2ba2(%rip)      # 0x40a0
leaq 0xb85(%rip), %rdi       # 0x208a
jmp 0x154a
cmpq $0x270e, %rsi           # imm = 0x270E
ja 0x1523
incq %rsi
movq %rsi, 0x2b86(%rip)      # 0x40a0
leaq 0xb6a(%rip), %rdi       # 0x208b
jmp 0x154a
leaq 0x1(%rsi), %rax
movq %rax, 0x2b72(%rip)      # 0x40a0
cmpq $0x1869e, %rsi          # imm = 0x1869E
ja 0x1540
leaq 0xb4e(%rip), %rdi       # 0x208c
jmp 0x1547
leaq 0xb46(%rip), %rdi       # 0x208d
movq %rax, %rsi
xorl %eax, %eax
callq 0x1060
movq 0x2a80(%rip), %r13      # 0x3fd8
movl %r12d, -0x2c(%rbp)
testl %r14d, %r14d
je 0x16b7
movq %r14, %rax
movl $0x0, %r14d
movq %rax, -0x38(%rbp)
cmovgl %eax, %r14d
xorl %r12d, %r12d
cmpq %r12, %r14
je 0x169f
cmpb $0x1, 0x2(%rbx)
jne 0x159b
cmpb $0xa, (%r15,%r12)
jne 0x159b
movq (%r13), %rsi
pushq $0x24
popq %rdi
callq 0x1090
cmpb $0x1, 0x5(%rbx)
jne 0x15bd
cmpb $0x9, (%r15,%r12)
jne 0x15bd
movq (%r13), %rsi
leaq 0xae0(%rip), %rdi       # 0x2093
callq 0x1070
jmp 0x1697
movsbl (%r15,%r12), %edi
cmpb $0x1, 0x3(%rbx)
jne 0x160d
cmpb $0xa, %dil
setne %al
leal 0x1(%r12), %ecx
cmpl -0x38(%rbp), %ecx
setge %cl
orb %al, %cl
jne 0x160d
movq (%r13), %rsi
pushq $0xa
popq %rdi
callq 0x1090
movq 0x2aaf(%rip), %rsi      # 0x40a0
cmpq $0x8, %rsi
ja 0x1618
incq %rsi
movq %rsi, 0x2a9f(%rip)      # 0x40a0
leaq 0xa80(%rip), %rdi       # 0x2088
jmp 0x1690
movq (%r13), %rsi
callq 0x1090
jmp 0x1697
cmpq $0x62, %rsi
ja 0x1631
incq %rsi
movq %rsi, 0x2a78(%rip)      # 0x40a0
leaq 0xa5a(%rip), %rdi       # 0x2089
jmp 0x1690
cmpq $0x3e6, %rsi            # imm = 0x3E6
ja 0x164d
incq %rsi
movq %rsi, 0x2a5c(%rip)      # 0x40a0
leaq 0xa3f(%rip), %rdi       # 0x208a
jmp 0x1690
cmpq $0x270e, %rsi           # imm = 0x270E
ja 0x1669
incq %rsi
movq %rsi, 0x2a40(%rip)      # 0x40a0
leaq 0xa24(%rip), %rdi       # 0x208b
jmp 0x1690
leaq 0x1(%rsi), %rax
movq %rax, 0x2a2c(%rip)      # 0x40a0
cmpq $0x1869e, %rsi          # imm = 0x1869E
ja 0x1686
leaq 0xa08(%rip), %rdi       # 0x208c
jmp 0x168d
leaq 0xa00(%rip), %rdi       # 0x208d
movq %rax, %rsi
xorl %eax, %eax
callq 0x1060
incq %r12
jmp 0x1579
movl $0x1000, %edx           # imm = 0x1000
movl -0x2c(%rbp), %edi
movq %r15, %rsi
callq 0x10a0
movq %rax, %r14
jmp 0x155c
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 0x2921(%rip), %rax      # 0x3ff8
movq (%rax), %rbx
callq 0x1040
movl (%rax), %edi
callq 0x1100
leaq 0x993(%rip), %rsi       # 0x2080
movq %rbx, %rdi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x10d0
pushq $0x1
popq %rdi
callq 0x10f0