// File: /workspace/github_c_makefile_star2_O1/Keith-S-Thompson[P]kst-time-utils/timer.c
// Function: main
int main(int argc, char **argv) {
#define LEN 8192

    char line[LEN];
    int i;
    char *output_file_name = NULL;
    FILE *output_file = stdout;

    for (i = 1; i < argc; i ++) {
        if (strcmp(argv[i], "-a") == 0) {
            absolute = true;
        }
        else if (strcmp(argv[i], "-A") == 0) {
            absolute_readable = true;
            utc = false;
        }
        else if (strcmp(argv[i], "-U") == 0) {
            absolute_readable = true;
            utc = true;
        }
        else if (strcmp(argv[i], "-r") == 0) {
            relative = true;
        }
        else if (strcmp(argv[i], "-z") == 0) {
            absolute = false;
        }
        else if (strcmp(argv[i], "-b") == 0) {
            buffered = true;
        }
        else if (strcmp(argv[i], "-u") == 0) {
            buffered = false;
        }
        else if (strcmp(argv[i], "-o") == 0) {
            if (i < argc-1) {
                output_file_name = argv[i+1];
                i ++;
            }
            else {
                usage(argv[0], "Option -o requires a file name argument");
            }
        }
        else if (strcmp(argv[i], "-h") == 0) {
            usage(argv[0], NULL);
        }
        else {
            char message[100];
            sprintf(message, "Unrecognized argument: \"%s\"", argv[i]);
            usage(argv[0], message);
        }
    }

    if (absolute && relative) {
        usage(argv[0], "Options -a and -r are incompatible");
    }

    if (output_file_name != NULL) {
        output_file = fopen(output_file_name, "w");
        if (output_file == NULL) {
            perror(output_file_name);
            exit(EXIT_FAILURE);
        }
    }


    if (! buffered) {
        setbuf(output_file, NULL);
    }

    show_time(output_file, true);
    putc('\n', output_file);

    while (fgets(line, LEN, stdin)) {
        show_time(output_file, false);
        fprintf(output_file, " %s", line);
    }

    show_time(output_file, true);
    putc('\n', output_file);
    
    if (output_file_name != NULL) {
        fclose(output_file);
    }

    exit(EXIT_SUCCESS);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2018, %rsp           # imm = 0x2018
movq %rsi, %r15
movq 0x2d79(%rip), %rax      # 0x3fd0
movq (%rax), %rbx
cmpl $0x2, %edi
jl 0x13a2
movl %edi, %r12d
leal -0x1(%r12), %eax
movl %eax, 0xc(%rsp)
movl $0x1, %ebp
movq $0x0, (%rsp)
movslq %ebp, %r13
movq (%r15,%r13,8), %r14
movq %r14, %rdi
leaq 0xd77(%rip), %rsi       # 0x2004
callq 0x10b0
testl %eax, %eax
je 0x134a
movq %r14, %rdi
leaq 0xd63(%rip), %rsi       # 0x2007
callq 0x10b0
testl %eax, %eax
je 0x1353
movq %r14, %rdi
leaq 0xd4f(%rip), %rsi       # 0x200a
callq 0x10b0
testl %eax, %eax
je 0x1363
movq %r14, %rdi
leaq 0xd3b(%rip), %rsi       # 0x200d
callq 0x10b0
testl %eax, %eax
je 0x1373
movq %r14, %rdi
leaq 0xd27(%rip), %rsi       # 0x2010
callq 0x10b0
testl %eax, %eax
je 0x137c
movq %r14, %rdi
leaq 0xd13(%rip), %rsi       # 0x2013
callq 0x10b0
testl %eax, %eax
je 0x1385
movq %r14, %rdi
leaq 0xd03(%rip), %rsi       # 0x2016
callq 0x10b0
testl %eax, %eax
je 0x138e
movq %r14, %rdi
leaq 0xcf3(%rip), %rsi       # 0x2019
callq 0x10b0
testl %eax, %eax
jne 0x14b3
cmpl 0xc(%rsp), %ebp
jge 0x14d0
incl %ebp
movq 0x8(%r15,%r13,8), %rax
movq %rax, (%rsp)
jmp 0x1395
movb $0x1, 0x2d67(%rip)      # 0x40b8
jmp 0x1395
movb $0x1, 0x2d5f(%rip)      # 0x40b9
movb $0x0, 0x2d59(%rip)      # 0x40ba
jmp 0x1395
movb $0x1, %al
movb %al, 0x2d4e(%rip)       # 0x40b9
movb %al, 0x2d49(%rip)       # 0x40ba
jmp 0x1395
movb $0x1, 0x2d41(%rip)      # 0x40bb
jmp 0x1395
movb $0x0, 0x2d35(%rip)      # 0x40b8
jmp 0x1395
movb $0x1, 0x2d30(%rip)      # 0x40bc
jmp 0x1395
movb $0x0, 0x2d27(%rip)      # 0x40bc
incl %ebp
cmpl %r12d, %ebp
jl 0x127c
jmp 0x13aa
movq $0x0, (%rsp)
cmpb $0x1, 0x2d07(%rip)      # 0x40b8
jne 0x13cb
cmpb $0x1, 0x2d01(%rip)      # 0x40bb
jne 0x13cb
movq (%r15), %rdi
leaq 0xc9d(%rip), %rsi       # 0x2063
callq 0x1503
movq (%rsp), %r13
testq %r13, %r13
je 0x13fd
leaq 0xcab(%rip), %rsi       # 0x2086
movq %r13, %rdi
callq 0x10f0
movq %rax, %rbx
testq %rax, %rax
jne 0x13fd
movq %r13, %rdi
callq 0x1100
movl $0x1, %edi
callq 0x1120
cmpb $0x0, 0x2cb8(%rip)      # 0x40bc
jne 0x1410
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1050
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1598
movl $0xa, %edi
movq %rbx, %rsi
callq 0x10c0
movq 0x2ba7(%rip), %r12      # 0x3fd8
movq (%r12), %rdx
leaq 0x10(%rsp), %rdi
movl $0x2000, %esi           # imm = 0x2000
callq 0x10a0
testq %rax, %rax
je 0x1485
leaq 0xc38(%rip), %r14       # 0x2088
leaq 0x10(%rsp), %r15
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1598
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x10d0
movq (%r12), %rdx
movq %r15, %rdi
movl $0x2000, %esi           # imm = 0x2000
callq 0x10a0
testq %rax, %rax
jne 0x1455
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1598
movl $0xa, %edi
movq %rbx, %rsi
callq 0x10c0
testq %r13, %r13
je 0x14ac
movq %rbx, %rdi
callq 0x1040
xorl %edi, %edi
callq 0x1120
leaq 0xb8a(%rip), %rsi       # 0x2044
movq %r14, %rdi
callq 0x10b0
testl %eax, %eax
jne 0x14df
movq (%r15), %rdi
xorl %esi, %esi
callq 0x1503
movq (%r15), %rdi
leaq 0xb42(%rip), %rsi       # 0x201c
callq 0x1503
leaq 0xb61(%rip), %rsi       # 0x2047
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1110
movq (%r15), %rdi
movq %rbx, %rsi
callq 0x1503