// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x35(%rbp)
movb $0x0, -0x36(%rbp)
movb $0x0, -0x37(%rbp)
leaq -0x120(%rbp), %rdi
leaq 0x420d(%rip), %rsi      # 0x6d00
movl $0xe0, %edx
callq 0x1110
movl $0x1, 0x45d5(%rip)      # 0x70dc
cmpl $0x1, -0x8(%rbp)
jne 0x2b88
leaq 0x43c(%rip), %rdi       # 0x2f50
callq 0x1460
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x2b45
movq 0x44ce(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x15b8(%rip), %rsi      # 0x40ec
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1170
movq 0x4484(%rip), %rax      # 0x6fd0
movq (%rax), %rsi
movq -0x18(%rbp), %rdx
leaq 0x15a2(%rip), %rdi      # 0x40fc
xorl %ecx, %ecx
callq 0x2fc0
movq -0x18(%rbp), %rdi
leaq 0x5b4(%rip), %rsi       # 0x3120
xorl %edx, %edx
callq 0x1b20
movq -0x18(%rbp), %rdi
callq 0x3180
movl $0x0, -0x4(%rbp)
jmp 0x2f38
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq -0x120(%rbp), %rcx
leaq 0x155a(%rip), %rdx      # 0x4102
leaq -0x30(%rbp), %r8
callq 0x1090
movl %eax, -0x34(%rbp)
cmpl $-0x1, %eax
je 0x2d11
movl -0x34(%rbp), %eax
movl %eax, -0x124(%rbp)
testl %eax, %eax
je 0x2c35
jmp 0x2bcc
movl -0x124(%rbp), %eax
subl $0x62, %eax
je 0x2ccd
jmp 0x2bdd
movl -0x124(%rbp), %eax
subl $0x68, %eax
je 0x2cd3
jmp 0x2bee
movl -0x124(%rbp), %eax
subl $0x6e, %eax
je 0x2cc7
jmp 0x2bff
movl -0x124(%rbp), %eax
subl $0x72, %eax
je 0x2cbb
jmp 0x2c10
movl -0x124(%rbp), %eax
subl $0x75, %eax
je 0x2cb5
jmp 0x2c21
movl -0x124(%rbp), %eax
subl $0x76, %eax
je 0x2ce8
jmp 0x2cf9
movl -0x30(%rbp), %eax
movq %rax, -0x130(%rbp)
subq $0x5, %rax
ja 0x2ca0
movq -0x130(%rbp), %rax
leaq 0x145d(%rip), %rcx      # 0x40b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb $0x1, -0x35(%rbp)
jmp 0x2cb3
movl $0xffffffff, 0x4470(%rip) # imm = 0xFFFFFFFF
jmp 0x2cb3
movb $0x1, -0x36(%rbp)
jmp 0x2cb3
movb $0x1, -0x37(%rbp)
jmp 0x2cb3
movq -0x20(%rbp), %rdi
callq 0x31b0
movl $0x0, -0x4(%rbp)
jmp 0x2f38
callq 0x3270
movl $0x0, -0x4(%rbp)
jmp 0x2f38
movq -0x20(%rbp), %rdi
callq 0x31b0
movl $0x1, %edi
callq 0x1170
jmp 0x2d0c
movb $0x1, -0x35(%rbp)
jmp 0x2d0c
movl $0xffffffff, 0x4417(%rip) # imm = 0xFFFFFFFF
jmp 0x2d0c
movb $0x1, -0x36(%rbp)
jmp 0x2d0c
movb $0x1, -0x37(%rbp)
jmp 0x2d0c
movq -0x20(%rbp), %rdi
callq 0x31b0
movl $0x0, -0x4(%rbp)
jmp 0x2f38
callq 0x3270
movl $0x0, -0x4(%rbp)
jmp 0x2f38
movq -0x20(%rbp), %rdi
callq 0x31b0
movl $0x1, %edi
callq 0x1170
jmp 0x2b93
testb $0x1, -0x36(%rbp)
je 0x2d5a
testb $0x1, -0x37(%rbp)
je 0x2d5a
leaq 0x5ac(%rip), %rdi       # 0x32d0
callq 0x1460
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x2d55
movq 0x42be(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x13c5(%rip), %rsi      # 0x4109
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1170
jmp 0x2ddc
testb $0x1, -0x36(%rbp)
jne 0x2d66
testb $0x1, -0x37(%rbp)
je 0x2da0
leaq 0x633(%rip), %rdi       # 0x33a0
callq 0x1460
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x2d9e
movq 0x4275(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x137c(%rip), %rsi      # 0x4109
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1170
jmp 0x2dda
leaq 0x1a9(%rip), %rdi       # 0x2f50
callq 0x1460
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x2dd8
movq 0x423b(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0x1342(%rip), %rsi      # 0x4109
movb $0x0, %al
callq 0x1100
movl $0x1, %edi
callq 0x1170
jmp 0x2dda
jmp 0x2ddc
movq 0x41f5(%rip), %rax      # 0x6fd8
movl (%rax), %eax
cmpl -0x8(%rbp), %eax
jl 0x2e11
movq 0x41df(%rip), %rax      # 0x6fd0
movq (%rax), %rsi
movq -0x18(%rbp), %rdx
movb -0x37(%rbp), %al
leaq 0x12fa(%rip), %rdi      # 0x40fc
andb $0x1, %al
movzbl %al, %ecx
callq 0x2fc0
jmp 0x2ebe
movq 0x41c0(%rip), %rax      # 0x6fd8
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x2ebc
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x12db(%rip), %rsi      # 0x4117
callq 0x1150
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x2e65
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x12bc(%rip), %rsi      # 0x411a
callq 0x1410
jmp 0x2eae
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x28(%rbp), %rsi
movq -0x18(%rbp), %rdx
movb -0x37(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0x2fc0
movq -0x28(%rbp), %rdi
callq 0x1070
cmpl $-0x1, %eax
jne 0x2eac
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1273(%rip), %rsi      # 0x411a
callq 0x1410
jmp 0x2eae
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2e1d
jmp 0x2ebe
testb $0x1, -0x37(%rbp)
je 0x2ede
testb $0x1, -0x35(%rbp)
je 0x2ede
movq -0x18(%rbp), %rdi
leaq 0x51b(%rip), %rsi       # 0x33f0
xorl %edx, %edx
callq 0x1b20
jmp 0x2f28
testb $0x1, -0x37(%rbp)
je 0x2ef8
movq -0x18(%rbp), %rdi
leaq 0x551(%rip), %rsi       # 0x3440
xorl %edx, %edx
callq 0x1b20
jmp 0x2f26
testb $0x1, -0x35(%rbp)
je 0x2f12
movq -0x18(%rbp), %rdi
leaq 0x5a7(%rip), %rsi       # 0x34b0
xorl %edx, %edx
callq 0x1b20
jmp 0x2f24
movq -0x18(%rbp), %rdi
leaq 0x203(%rip), %rsi       # 0x3120
xorl %edx, %edx
callq 0x1b20
jmp 0x2f26
jmp 0x2f28
movq -0x18(%rbp), %rdi
callq 0x3180
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nopw %cs:(%rax,%rax)