// File: /workspace/github_c_makefile_star2_O3/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2000, %rsp           # imm = 0x2000
movq %rsi, %r15
movq 0x2d8a(%rip), %rax      # 0x3fd0
movq (%rax), %rbx
cmpl $0x2, %edi
jl 0x1340
leal -0x1(%rdi), %eax
movl $0x1, %ecx
xorl %r14d, %r14d
movb $0x1, %sil
movslq %ecx, %r8
movq (%r15,%r8,8), %rdx
cmpb $0x2d, (%rdx)
jne 0x145a
cmpb $0x61, 0x1(%rdx)
jne 0x127c
cmpb $0x0, 0x2(%rdx)
je 0x12e9
cmpb $0x41, 0x1(%rdx)
jne 0x1288
cmpb $0x0, 0x2(%rdx)
je 0x12f2
cmpb $0x55, 0x1(%rdx)
jne 0x1294
cmpb $0x0, 0x2(%rdx)
je 0x1302
cmpb $0x72, 0x1(%rdx)
jne 0x12a0
cmpb $0x0, 0x2(%rdx)
je 0x1312
cmpb $0x7a, 0x1(%rdx)
jne 0x12ac
cmpb $0x0, 0x2(%rdx)
je 0x131b
cmpb $0x62, 0x1(%rdx)
jne 0x12b8
cmpb $0x0, 0x2(%rdx)
je 0x1324
cmpb $0x75, 0x1(%rdx)
jne 0x12c4
cmpb $0x0, 0x2(%rdx)
je 0x132d
cmpb $0x6f, 0x1(%rdx)
jne 0x1444
cmpb $0x0, 0x2(%rdx)
jne 0x1444
cmpl %eax, %ecx
jge 0x1479
incl %ecx
movq 0x8(%r15,%r8,8), %r14
jmp 0x1334
movb $0x1, 0x2dc0(%rip)      # 0x40b0
jmp 0x1334
movb $0x1, 0x2db8(%rip)      # 0x40b1
movb $0x0, 0x2db2(%rip)      # 0x40b2
jmp 0x1334
movb %sil, 0x2da8(%rip)      # 0x40b1
movb %sil, 0x2da2(%rip)      # 0x40b2
jmp 0x1334
movb $0x1, 0x2d9a(%rip)      # 0x40b3
jmp 0x1334
movb $0x0, 0x2d8e(%rip)      # 0x40b0
jmp 0x1334
movb $0x1, 0x2d89(%rip)      # 0x40b4
jmp 0x1334
movb $0x0, 0x2d80(%rip)      # 0x40b4
incl %ecx
cmpl %edi, %ecx
jl 0x1260
jmp 0x1343
xorl %r14d, %r14d
cmpb $0x1, 0x2d66(%rip)      # 0x40b0
jne 0x1364
cmpb $0x1, 0x2d60(%rip)      # 0x40b3
jne 0x1364
movq (%r15), %rdi
leaq 0xce9(%rip), %rsi       # 0x2048
callq 0x1488
testq %r14, %r14
je 0x1392
leaq 0xcfb(%rip), %rsi       # 0x206b
movq %r14, %rdi
callq 0x10e0
movq %rax, %rbx
testq %rax, %rax
jne 0x1392
movq %r14, %rdi
callq 0x10f0
movl $0x1, %edi
callq 0x1110
cmpb $0x0, 0x2d1b(%rip)      # 0x40b4
jne 0x13a5
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1050
movq %rbx, %rdi
movl $0x1, %esi
callq 0x151d
movl $0xa, %edi
movq %rbx, %rsi
callq 0x10b0
movq 0x2c12(%rip), %r13      # 0x3fd8
movq (%r13), %rdx
movq %rsp, %rdi
movl $0x2000, %esi           # imm = 0x2000
callq 0x10a0
testq %rax, %rax
je 0x1416
leaq 0xc8a(%rip), %r15       # 0x206d
movq %rsp, %r12
movq %rbx, %rdi
xorl %esi, %esi
callq 0x151d
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x10c0
movq (%r13), %rdx
movq %r12, %rdi
movl $0x2000, %esi           # imm = 0x2000
callq 0x10a0
testq %rax, %rax
jne 0x13e6
movq %rbx, %rdi
movl $0x1, %esi
callq 0x151d
movl $0xa, %edi
movq %rbx, %rsi
callq 0x10b0
testq %r14, %r14
je 0x143d
movq %rbx, %rdi
callq 0x1040
xorl %edi, %edi
callq 0x1110
cmpb $0x68, 0x1(%rdx)
jne 0x145a
cmpb $0x0, 0x2(%rdx)
jne 0x145a
movq (%r15), %rdi
xorl %esi, %esi
callq 0x1488
leaq 0xbcb(%rip), %rsi       # 0x202c
movq %rsp, %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1100
movq (%r15), %rdi
movq %rbx, %rsi
callq 0x1488
movq (%r15), %rdi
leaq 0xb81(%rip), %rsi       # 0x2004
callq 0x1488