// File: /workspace/github_c_makefile_star2_O2/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
leal -0x1(%rdi), %eax
pushq $0x1
popq %rcx
xorl %r14d, %r14d
movb $0x1, %sil
cmpl %edi, %ecx
jge 0x1338
movslq %ecx, %r8
movq (%r15,%r8,8), %rdx
cmpb $0x2d, (%rdx)
jne 0x1431
cmpb $0x61, 0x1(%rdx)
jne 0x1279
cmpb $0x0, 0x2(%rdx)
je 0x12e6
cmpb $0x41, 0x1(%rdx)
jne 0x1285
cmpb $0x0, 0x2(%rdx)
je 0x12ef
cmpb $0x55, 0x1(%rdx)
jne 0x1291
cmpb $0x0, 0x2(%rdx)
je 0x12ff
cmpb $0x72, 0x1(%rdx)
jne 0x129d
cmpb $0x0, 0x2(%rdx)
je 0x130f
cmpb $0x7a, 0x1(%rdx)
jne 0x12a9
cmpb $0x0, 0x2(%rdx)
je 0x1318
cmpb $0x62, 0x1(%rdx)
jne 0x12b5
cmpb $0x0, 0x2(%rdx)
je 0x1321
cmpb $0x75, 0x1(%rdx)
jne 0x12c1
cmpb $0x0, 0x2(%rdx)
je 0x132a
cmpb $0x6f, 0x1(%rdx)
jne 0x141b
cmpb $0x0, 0x2(%rdx)
jne 0x141b
cmpl %eax, %ecx
jge 0x1450
incl %ecx
movq 0x8(%r15,%r8,8), %r14
jmp 0x1331
movb $0x1, 0x2dc3(%rip)      # 0x40b0
jmp 0x1331
movb $0x1, 0x2dbb(%rip)      # 0x40b1
movb $0x0, 0x2db5(%rip)      # 0x40b2
jmp 0x1331
movb %sil, 0x2dab(%rip)      # 0x40b1
movb %sil, 0x2da5(%rip)      # 0x40b2
jmp 0x1331
movb $0x1, 0x2d9d(%rip)      # 0x40b3
jmp 0x1331
movb $0x0, 0x2d91(%rip)      # 0x40b0
jmp 0x1331
movb $0x1, 0x2d8c(%rip)      # 0x40b4
jmp 0x1331
movb $0x0, 0x2d83(%rip)      # 0x40b4
incl %ecx
jmp 0x1255
cmpb $0x1, 0x2d71(%rip)      # 0x40b0
jne 0x1359
cmpb $0x1, 0x2d6b(%rip)      # 0x40b3
jne 0x1359
movq (%r15), %rdi
leaq 0xcf4(%rip), %rsi       # 0x2048
callq 0x145f
testq %r14, %r14
je 0x1385
leaq 0xd06(%rip), %rsi       # 0x206b
movq %r14, %rdi
callq 0x10e0
movq %rax, %rbx
testq %rax, %rax
jne 0x1385
movq %r14, %rdi
callq 0x10f0
pushq $0x1
popq %rdi
callq 0x1110
cmpb $0x0, 0x2d28(%rip)      # 0x40b4
jne 0x1398
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1050
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x14f4
pushq $0xa
popq %rdi
movq %rbx, %rsi
callq 0x10b0
movq 0x2c23(%rip), %r13      # 0x3fd8
movq %rsp, %r15
leaq 0xcae(%rip), %r12       # 0x206d
movq (%r13), %rdx
movq %r15, %rdi
movl $0x2000, %esi           # imm = 0x2000
callq 0x10a0
testq %rax, %rax
je 0x13f1
movq %rbx, %rdi
xorl %esi, %esi
callq 0x14f4
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x10c0
jmp 0x13bf
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x14f4
pushq $0xa
popq %rdi
movq %rbx, %rsi
callq 0x10b0
testq %r14, %r14
je 0x1414
movq %rbx, %rdi
callq 0x1040
xorl %edi, %edi
callq 0x1110
cmpb $0x68, 0x1(%rdx)
jne 0x1431
cmpb $0x0, 0x2(%rdx)
jne 0x1431
movq (%r15), %rdi
xorl %esi, %esi
callq 0x145f
leaq 0xbf4(%rip), %rsi       # 0x202c
movq %rsp, %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1100
movq (%r15), %rdi
movq %rbx, %rsi
callq 0x145f
movq (%r15), %rdi
leaq 0xbaa(%rip), %rsi       # 0x2004
callq 0x145f