// File: /workspace/github_c_makefile_star2_O2/chbarts[P]aa-tree/sort.c
// Function: main
int main(int argc, char *argv[])
{
    aa *tree;
    char *pnam;
    FILE *fin;
    int i, lind, c;
    bool uniq = false, rev = false, numer = false;
    extern int optind;
    struct option longopts[] = {
        {"uniqify", 0, 0, 0},
        {"reverse", 0, 0, 0},
        {"numer", 0, 0, 0},
        {"help", 0, 0, 0},
        {"version", 0, 0, 0},
        {0, 0, 0, 0}
    };

    if (argc == 1) {
        if ((tree = aa_new(comparator)) == NULL) {
            fprintf(stderr, "aa_new() error\n");
            exit(EXIT_FAILURE);
        }

        dofile("stdin", stdin, tree, false, false);
        aa_traverse(tree, printall, TRAV_IN);
        cleanup(tree, numer);
        return 0;
    }

    pnam = argv[0];

    while ((c = getopt_long(argc, argv, "urnhv", longopts, &lind)) != -1) {
        switch (c) {
        case 0:
            switch (lind) {
            case 0:
                uniq = true;
                break;
            case 1:
                rev = true;
                break;
            case 2:
                numer = true;
                break;
            case 3:
                usage(pnam);
                return 0;
                break;
            case 4:
                version();
                return 0;
                break;
            default:
                usage(pnam);
                exit(EXIT_FAILURE);
                break;
            }

            break;
        case 'u':
            uniq = true;
            break;
        case 'r':
            rev = true;
            break;
        case 'n':
            numer = true;
            break;
        case 'h':
            usage(pnam);
            return 0;
            break;
        case 'v':
            version();
            return 0;
            break;
        default:
            usage(pnam);
            exit(EXIT_FAILURE);
            break;
        }
    }

    if (rev && numer) {
        if ((tree = aa_new(rncomparator)) == NULL) {
            fprintf(stderr, "aa_new error\n");
            exit(EXIT_FAILURE);
        }
    } else if (numer) {
        if ((tree = aa_new(ncomparator)) == NULL) {
            fprintf(stderr, "aa_new error\n");
            exit(EXIT_FAILURE);
        }
    } else if (rev) {
        if ((tree = aa_new(rcomparator)) == NULL) {
            fprintf(stderr, "aa_new error\n");
            exit(EXIT_FAILURE);
        }
    } else {
        if ((tree = aa_new(comparator)) == NULL) {
            fprintf(stderr, "aa_new error\n");
            exit(EXIT_FAILURE);
        }
    }

    if (optind >= argc) {
        dofile("stdin", stdin, tree, numer, rev);
    } else {
        for (i = optind; i < argc; i++) {
            if ((fin = fopen(argv[i], "rb")) == NULL) {
                handle_ferr(argv[i], "sort");
                continue;
            }

            dofile(argv[i], fin, tree, numer, rev);

            if (fclose(fin) == EOF) {
                handle_ferr(argv[i], "sort");
            }
        }
    }

    if (uniq && numer) {
        aa_traverse(tree, printn, TRAV_IN);
    } else if (uniq) {
        aa_traverse(tree, print, TRAV_IN);
    } else if (numer) {
        aa_traverse(tree, printalln, TRAV_IN);
    } else {
        aa_traverse(tree, printall, TRAV_IN);
    }

    cleanup(tree, numer);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x4003(%rip), %rsi      # 0x5d20
leaq 0x20(%rsp), %rdi
movl $0xc0, %edx
callq 0x10f0
cmpl $0x1, %ebp
jne 0x1d87
leaq 0x2a2(%rip), %rdi       # 0x1fda
callq 0x1394
testq %rax, %rax
je 0x1fa7
movq %rax, %rbx
movq 0x4280(%rip), %rax      # 0x5fd0
movq (%rax), %rsi
leaq 0x13bc(%rip), %rdi      # 0x3116
movq %rbx, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2011
leaq 0x4b9(%rip), %rsi       # 0x2227
movq %rbx, %rdi
xorl %edx, %edx
callq 0x1760
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2258
jmp 0x1e3e
movq (%rbx), %rax
movq %rax, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
leaq 0x137e(%rip), %r15      # 0x311c
leaq 0x20(%rsp), %r12
leaq 0x1c(%rsp), %r13
leaq 0x1301(%rip), %r14      # 0x30b0
movl $0x0, 0x14(%rsp)
xorl %eax, %eax
movl %eax, 0x4(%rsp)
movl %ebp, %edi
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
movq %r13, %r8
callq 0x1080
leal -0x6e(%rax), %ecx
cmpl $0x8, %ecx
ja 0x1de3
movb $0x1, %al
movslq (%r14,%rcx,4), %rcx
addq %r14, %rcx
jmpq *%rcx
testl %eax, %eax
jne 0x1e1f
movl 0x1c(%rsp), %ecx
cmpq $0x4, %rcx
ja 0x1f95
movb $0x1, %al
leaq 0x12d6(%rip), %rdx      # 0x30d4
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movb $0x1, %al
movl %eax, 0x10(%rsp)
movl 0x4(%rsp), %eax
jmp 0x1db9
movb $0x1, %al
movl %eax, 0x14(%rsp)
movl 0x4(%rsp), %eax
jmp 0x1db9
cmpl $-0x1, %eax
je 0x1e52
cmpl $0x68, %eax
jne 0x1f95
movq 0x8(%rsp), %rdi
callq 0x2283
jmp 0x1e3e
callq 0x2307
xorl %eax, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x14(%rsp), %r15d
testb $0x1, %r15b
je 0x1e6d
testb $0x1, 0x4(%rsp)
je 0x1e7d
leaq 0x4f2(%rip), %rdi       # 0x235d
jmp 0x1e8d
testb $0x1, 0x4(%rsp)
je 0x1e86
leaq 0x4fc(%rip), %rdi       # 0x2377
jmp 0x1e8d
leaq 0x505(%rip), %rdi       # 0x2389
jmp 0x1e8d
leaq 0x14d(%rip), %rdi       # 0x1fda
callq 0x1394
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x1fc5
movl 0x4(%rsp), %ecx
movq 0x412d(%rip), %rax      # 0x5fd8
movslq (%rax), %r14
movzbl %cl, %ecx
cmpl %ebp, %r14d
movl %ecx, 0x18(%rsp)
jge 0x1f1f
movslq %ebp, %r12
movl %ecx, %ebp
andl $0x1, %ebp
movzbl %r15b, %r15d
andl $0x1, %r15d
cmpq %r12, %r14
jge 0x1f45
movq (%rbx,%r14,8), %rdi
leaq 0x1256(%rip), %rsi      # 0x3130
callq 0x1130
movq (%rbx,%r14,8), %rdi
testq %rax, %rax
je 0x1f0e
movq %rax, %r13
movq %rax, %rsi
movq 0x8(%rsp), %rdx
movl %ebp, %ecx
movl %r15d, %r8d
callq 0x2011
movq %r13, %rdi
callq 0x1070
cmpl $-0x1, %eax
jne 0x1f1a
movq (%rbx,%r14,8), %rdi
leaq 0x121e(%rip), %rsi      # 0x3133
callq 0x135c
incq %r14
jmp 0x1eca
movq 0x40aa(%rip), %rax      # 0x5fd0
movq (%rax), %rsi
andl $0x1, %ecx
movzbl %r15b, %r8d
andl $0x1, %r8d
leaq 0x11db(%rip), %rdi      # 0x3116
movq 0x8(%rsp), %rdx
callq 0x2011
leaq 0x478(%rip), %rax       # 0x23c4
leaq 0x48c(%rip), %rcx       # 0x23df
testb $0x1, 0x4(%rsp)
cmovneq %rax, %rcx
leaq 0x492(%rip), %rax       # 0x23f5
leaq 0x2bd(%rip), %rsi       # 0x2227
cmovneq %rax, %rsi
testb $0x1, 0x10(%rsp)
cmovneq %rcx, %rsi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x1760
movl 0x18(%rsp), %esi
andl $0x1, %esi
movq %rbx, %rdi
jmp 0x1d7d
movq 0x8(%rsp), %rdi
callq 0x2283
pushq $0x1
popq %rdi
callq 0x1150
movq 0x404a(%rip), %rax      # 0x5ff8
movq (%rax), %rcx
leaq 0x114e(%rip), %rdi      # 0x3106
pushq $0xf
popq %rsi
pushq $0x1
popq %rdx
callq 0x1160
jmp 0x1f9f
movq 0x402c(%rip), %rax      # 0x5ff8
movq (%rax), %rcx
leaq 0x114c(%rip), %rdi      # 0x3122
pushq $0xd
jmp 0x1fba