// File: /workspace/github_c_makefile_star2_O0/ikbenlike[P]nngutils/src/tee.c
// Function: main
int main(int argc, char **argv){
    struct tee_args *args = calloc(1, sizeof(struct tee_args));
    args = parse_arg(args, argc, argv);
    int *fds = calloc(1, sizeof(int) * args->fcount);
    for(int i = 0; i < args->fcount; i++){
        if(!strcmp(args->files[i], "-")){
            fds[i] = STDIN_FILENO;
            continue;
        }
        fds[i] = open(args->files[i], O_WRONLY);
        if(fds[i] == -1){
            fprintf(stderr, "%s: %s\n", argv[0], strerror(errno));
            return 1;
        }
    }
    char *buf = calloc(1, 4096 * sizeof(char));
    if(buf == NULL){
        fprintf(stderr, "%s: %s\n", argv[0], strerror(errno));
        return 1;
    }
    int buf_len = read(STDIN_FILENO, buf, 4096);
    while(buf_len != 0){
        for(int i = 0; i < args->fcount; i++){
            write(fds[i], buf, buf_len);
        }
        write(STDOUT_FILENO, buf, buf_len);
        buf_len = read(STDIN_FILENO, buf, 4096);
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x1, %edi
movl $0x18, %esi
callq 0x1060
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x11c0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movslq 0x10(%rax), %rsi
shlq $0x2, %rsi
movl $0x1, %edi
callq 0x1060
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x1454
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xc83(%rip), %rsi       # 0x2028
callq 0x1070
cmpl $0x0, %eax
jne 0x13c3
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
jmp 0x1446
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movl $0x1, %esi
movb $0x0, %al
callq 0x1090
movl %eax, %edx
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
cmpl $-0x1, (%rax,%rcx,4)
jne 0x1444
movq 0x2bf7(%rip), %rax      # 0x3ff8
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
callq 0x1030
movl (%rax), %edi
callq 0x10b0
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rdx
movq %rax, %rcx
leaq 0xbf9(%rip), %rsi       # 0x202a
movb $0x0, %al
callq 0x1080
movl $0x1, -0x4(%rbp)
jmp 0x1532
jmp 0x1446
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x137e
movl $0x1, %edi
movl $0x1000, %esi           # imm = 0x1000
callq 0x1060
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x14b5
movq 0x2b83(%rip), %rax      # 0x3ff8
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
callq 0x1030
movl (%rax), %edi
callq 0x10b0
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rdx
movq %rax, %rcx
leaq 0xb85(%rip), %rsi       # 0x202a
movb $0x0, %al
callq 0x1080
movl $0x1, -0x4(%rbp)
jmp 0x1532
movq -0x30(%rbp), %rsi
xorl %edi, %edi
movl $0x1000, %edx           # imm = 0x1000
callq 0x1050
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x152b
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x1504
movq -0x20(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %edi
movq -0x30(%rbp), %rsi
movslq -0x34(%rbp), %rdx
callq 0x1040
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x14d5
movq -0x30(%rbp), %rsi
movslq -0x34(%rbp), %rdx
movl $0x1, %edi
callq 0x1040
movq -0x30(%rbp), %rsi
xorl %edi, %edi
movl $0x1000, %edx           # imm = 0x1000
callq 0x1050
movl %eax, -0x34(%rbp)
jmp 0x14c8
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq