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

    rev = 1;

#ifdef DEBUG
    printf("rev = %d\n", rev);
#endif

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

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

    pnam = argv[0];

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

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

    if (numer && bylen) {
        if ((tree = aa_new(lncomparator)) == NULL) {
            fprintf(stderr, "aa_new error\n");
            exit(EXIT_FAILURE);
        }

    } else if (numer || bylen) {
        if ((tree = aa_new(ncomparator)) == 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, bylen);
    } else {
        for (i = optind; i < argc; i++) {
            if ((fin = fopen(argv[i], "rb")) == NULL) {
                handle_ferr(argv[i], "sort2");
                continue;
            }

            dofile(argv[i], fin, tree, bylen);

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

    if (bylen && uniq) {
        aa_traverse(tree, lprint, TRAV_IN);
    } else if (bylen) {
        aa_traverse(tree, lprintall, TRAV_IN);
    } else if (uniq) {
        aa_traverse(tree, print, TRAV_IN);
    } else {
        aa_traverse(tree, printall, TRAV_IN);
    }

    cleanup(tree);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rsi, %r14
movl %edi, %ebx
leaq 0x3d3b(%rip), %rsi      # 0x5d00
leaq 0x20(%rsp), %rdi
movl $0xe0, %edx
callq 0x1120
movl $0x1, 0x410e(%rip)      # 0x60ec
cmpl $0x1, %ebx
jne 0x2022
leaq 0x29b(%rip), %rdi       # 0x2285
callq 0x14b8
testq %rax, %rax
je 0x227b
movq %rax, %rbx
movq 0x3fce(%rip), %rax      # 0x5fd0
movq (%rax), %rsi
leaq 0x1114(%rip), %rdi      # 0x3120
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x22c9
leaq 0x3b4(%rip), %rsi       # 0x23d1
jmp 0x2230
movq (%r14), %rax
movq %rax, 0x10(%rsp)
xorl %ecx, %ecx
leaq 0x20(%rsp), %r13
leaq 0x1c(%rsp), %rbp
leaq 0x1073(%rip), %r12      # 0x30b0
movl $0x0, 0x8(%rsp)
movl $0x0, 0x4(%rsp)
movl %ecx, %r15d
movl %ebx, %edi
movq %r14, %rsi
leaq 0x10ca(%rip), %rdx      # 0x3126
movq %r13, %rcx
movq %rbp, %r8
callq 0x10a0
movb $0x1, %cl
cmpl $0x67, %eax
jle 0x2083
leal -0x6e(%rax), %edx
cmpl $0x8, %edx
ja 0x2111
movslq (%r12,%rdx,4), %rax
addq %r12, %rax
jmpq *%rax
testl %eax, %eax
je 0x2097
cmpl $0x62, %eax
jne 0x20dc
movb $0x1, %al
movl %eax, 0x4(%rsp)
movl %r15d, %ecx
jmp 0x204d
movl 0x1c(%rsp), %eax
cmpq $0x5, %rax
ja 0x2267
leaq 0x1028(%rip), %rdx      # 0x30d4
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movl $0xffffffff, 0x402d(%rip) # imm = 0xFFFFFFFF
movl %r15d, %ecx
jmp 0x204d
movb $0x1, %al
movl %eax, 0x8(%rsp)
movl %r15d, %ecx
jmp 0x204d
callq 0x24c1
jmp 0x2253
cmpl $-0x1, %eax
jne 0x2267
testb $0x1, 0x8(%rsp)
je 0x2129
movl 0x4(%rsp), %ebp
testb $0x1, %bpl
je 0x2133
leaq 0x41a(%rip), %rdi       # 0x2517
callq 0x14b8
movq %rax, 0x8(%rsp)
testq %rax, %rax
jne 0x2168
callq 0x1242
cmpl $0x68, %eax
jne 0x2267
movq 0x10(%rsp), %rdi
callq 0x2422
jmp 0x2253
movl 0x4(%rsp), %ebp
testb $0x1, %bpl
je 0x214e
leaq 0x460(%rip), %rdi       # 0x259a
callq 0x14b8
movq %rax, 0x8(%rsp)
testq %rax, %rax
jne 0x2168
callq 0x121d
leaq 0x130(%rip), %rdi       # 0x2285
callq 0x14b8
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x2280
movq 0x3e69(%rip), %rax      # 0x5fd8
movslq (%rax), %rax
cmpl %eax, %ebx
jle 0x21ed
leaq (%r14,%rax,8), %r12
subl %eax, %ebx
xorl %r14d, %r14d
movzbl %bpl, %ebp
andl $0x1, %ebp
movq (%r12,%r14,8), %rdi
leaq 0xfaa(%rip), %rsi       # 0x313b
callq 0x1160
movq (%r12,%r14,8), %rdi
testq %rax, %rax
je 0x21c2
movq %rax, %r13
movq %rax, %rsi
movq 0x8(%rsp), %rdx
movl %ebp, %ecx
callq 0x22c9
movq %r13, %rdi
callq 0x1080
cmpl $-0x1, %eax
jne 0x21ce
movq (%r12,%r14,8), %rdi
leaq 0xf75(%rip), %rsi       # 0x313e
callq 0x11c0
incq %r14
cmpl %r14d, %ebx
jne 0x2186
testb $0x1, 0x4(%rsp)
jne 0x2215
leaq 0x449(%rip), %rax       # 0x262d
leaq 0x1e6(%rip), %rsi       # 0x23d1
jmp 0x2223
movq 0x3ddc(%rip), %rax      # 0x5fd0
movq (%rax), %rsi
movzbl %bpl, %ecx
andl $0x1, %ecx
leaq 0xf1b(%rip), %rdi       # 0x3120
movq 0x8(%rsp), %rdx
callq 0x22c9
testb $0x1, %bpl
je 0x21dd
leaq 0x3a7(%rip), %rax       # 0x25c3
leaq 0x3c4(%rip), %rsi       # 0x25e7
testb $0x1, %r15b
cmovneq %rax, %rsi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x190d
leaq 0x474(%rip), %rsi       # 0x26b5
movq %rbx, %rdi
xorl %edx, %edx
callq 0x190d
movq %rbx, %rdi
callq 0x1a23
xorl %eax, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rdi
callq 0x2422
movl $0x1, %edi
callq 0x1180
callq 0x1267
callq 0x11f8