// File: /workspace/github_c_makefile_star2_O2/sheneman[P]clearcut/getopt_long.c
// Function: getopt_long
int
getopt_long(int argc, char **argv,
            const char *shortopts,
            struct option *longopts,
            int *indexptr)
{
    char *opt;
    int i;
    static int shortoptind;
    static int no_optind = 0;
    
    if (optind == 0) {            /* skip first argument (command name) */
        optind++;
        no_optind = 0;
        shortoptind = 0;
    }

    optarg = 0;

    if (no_optind && !shortoptind) {
        while (!is_option(argv[no_optind]))
            insert_argv(argv, no_optind, optind-1);

        if (has_argument(argv[no_optind], shortopts, longopts) == 2)
            no_optind += 2;
        else
            no_optind++;

        if (argv[optind] && strcmp(argv[optind], "--") == 0) {
            while (!is_option(argv[no_optind]))
                insert_argv(argv, no_optind, optind);
            optind = no_optind;
            no_optind = 0;
        }
    }

    if (optind >= argc)
        goto end_of_option;

 retry:
    /*
    puts_argv(&argv[optind]);
    */
    opt = argv[optind];

    if (shortoptind == 0 && is_option(opt) == 1) {
        shortoptind++;
    }

    if (shortoptind) {
        /* short option */
        char *p = &opt[shortoptind];

        if (*p == '\0')
            assert(0);

        switch (has_argument_short(p, shortopts)) {
        case 0:
            /* no argument */
            optarg = 0;

            shortoptind++;
            if (opt[shortoptind] == '\0')
                optind++, shortoptind = 0;
            return *p;
        case 1:
            /* following character is argument */
            optind++, shortoptind = 0;
            optarg = &p[1];
            return *p;
        case 2:
            /* next argv is argument */
            optind++, shortoptind = 0;
            optarg = argv[optind++];
            return *p;
        case 3:
            /* has 1 byte argument */
            optarg = &p[1];
            if (p[2] == 0)
                optind++, shortoptind = 0;
            else
                shortoptind += 2;
            return *p;
        default:
            /* Invalid option */
            if (opterr)
                fprintf(stderr,
                        "%s: invalid option -- %c\n",
                        argv[0],
                        *p);

            optind++, shortoptind = 0;
            optopt = *p;
            return '?';
        }
    }
    else if (opt[0] == '-' && opt[1] == '-') {
        /* long option */

        if (opt[2] == '\0') {
            /* end of command line switch */
            optind++;
            return -1;
        }

        opt += 2;

        i = search_longopt(opt, longopts);
        if (i == -1) {
            optind++;
            optopt = 0;
            return '?';
        }
        else {
            int len = strlen(opt);
            char *p = strchr(opt, '=');
            if (p) {
                len = p - opt;
            }

            switch (longopts[i].has_arg) {
            case no_argument:
                break;
            case required_argument:
                if (opt[len] == '=')
                    optarg = opt + len + 1;
                else {
                    optind++;
                    optarg = argv[optind];
                    if (optarg == 0) {
                        if (opterr)
                            fprintf(stderr,
                                    "%s: option `--%s' requires an argument\n",
                                    argv[0],
                                    opt);

                        optopt = 0;
                        return '?'; /* no argument */
                    }
                }
                break;
            case optional_argument:
                if (opt[len] == '=')
                    optarg = opt + len + 1;
                else {
                    optarg = 0;
                }
                break;
            default:
                break;
            }

            *indexptr = i;
            optind++;
            if (longopts[i].flag) {
                *longopts[i].flag = longopts[i].val;
                return 0;
            }
            else {
                return longopts[i].val;
            }
        }

        optind++;
        optopt = 0;
        return '?';
    }

    /* not option */
    if (no_optind == 0)
        no_optind = optind;

    for (i = optind; argv[i]; i++) {
        if (is_option(argv[i])) {
            optind = i;
            goto retry;
        }
    }

 end_of_option:
    if (no_optind) {
        optind = no_optind;
        no_optind = 0;
    }

    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, 0x20(%rsp)
movq %rcx, %r12
movq %rdx, 0x10(%rsp)
movq %rsi, %rbx
movl 0x7127(%rip), %r15d     # 0xd808
testl %r15d, %r15d
je 0x6738
movslq 0x7117(%rip), %r13      # 0xd804
andq $0x0, 0x711b(%rip)      # 0xd810
testq %r13, %r13
je 0x6889
cmpl $0x0, 0x70fb(%rip)      # 0xd800
jne 0x6889
movl %edi, 0x8(%rsp)
pushq $-0x1
popq %r14
movq (%rbx,%r13,8), %r15
movq %r15, %rdi
callq 0x6c22
testl %eax, %eax
jne 0x6764
movl 0x70df(%rip), %edx      # 0xd808
decl %edx
movq %rbx, %rdi
movl %r13d, %esi
callq 0x6c3e
jmp 0x6713
andl $0x0, 0x70c5(%rip)      # 0xd804
andl $0x0, 0x70ba(%rip)      # 0xd800
andq $0x0, 0x70c2(%rip)      # 0xd810
movl $0x1, 0x70b0(%rip)      # 0xd808
pushq $0x1
popq %r15
xorl %r13d, %r13d
jmp 0x6889
movl %eax, %ebp
cmpl $0x2, %eax
jne 0x67e1
addq $0x2, %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x6d5a
cmpl $-0x1, %eax
je 0x681e
movl %eax, %ebp
movq %r15, %rdi
callq 0x20e0
movq %rax, %r14
pushq $0x3d
popq %rsi
movq %r15, %rdi
callq 0x20f0
movq %rax, %rcx
subq %r15, %rcx
testq %rax, %rax
cmoveq %r14, %rcx
movslq %ebp, %rax
shlq $0x5, %rax
movl 0x8(%r12,%rax), %r14d
testl %r14d, %r14d
je 0x6845
cmpl $0x2, %r14d
je 0x6824
cmpl $0x1, %r14d
jne 0x6c03
movslq %ecx, %rax
xorl %r14d, %r14d
cmpb $0x3d, (%r15,%rax)
setne %r14b
incl %r14d
jmp 0x6845
movslq %ebp, %r13
cmpb $0x0, (%r15,%r13)
je 0x683e
addq %r15, %r13
movq %r13, %rdi
movq 0x10(%rsp), %rsi
callq 0x6c7e
movl %eax, %r14d
cmpl $0x3, %eax
je 0x6811
testl %r14d, %r14d
jne 0x683e
cmpb $0x0, 0x1(%r13)
jne 0x681a
jmp 0x683b
cmpb $0x0, 0x2(%r13)
je 0x6835
incl %ebp
incl %ebp
jmp 0x67e1
pushq $-0x1
popq %r14
jmp 0x6845
movslq %ecx, %rax
xorl %r14d, %r14d
cmpb $0x3d, (%r15,%rax)
sete %r14b
jmp 0x6845
pushq $0x3
popq %r14
jmp 0x683e
xorl %r14d, %r14d
movl 0x6fbf(%rip), %r13d     # 0xd804
xorl %eax, %eax
cmpl $0x2, %r14d
sete %al
leal 0x1(%rax,%r13), %r15d
movl %r15d, 0x6faa(%rip)     # 0xd804
movslq 0x6fa7(%rip), %rax      # 0xd808
movq (%rbx,%rax,8), %rcx
testq %rcx, %rcx
je 0x687f
cmpb $0x2d, (%rcx)
jne 0x687f
cmpb $0x2d, 0x1(%rcx)
jne 0x687f
cmpb $0x0, 0x2(%rcx)
je 0x69b6
movl %r15d, %r13d
movl %eax, %r15d
movl 0x8(%rsp), %edi
cmpl %edi, %r15d
jge 0x6918
movq %r12, 0x18(%rsp)
movslq 0x6f62(%rip), %rdi      # 0xd800
leaq 0x8(%rbx), %rax
movq %rax, 0x8(%rsp)
movslq %r15d, %r12
movq (%rbx,%r12,8), %rbp
testl %edi, %edi
jne 0x694a
movq %rdi, %r14
movq %rbp, %rdi
callq 0x6c22
cmpl $0x1, %eax
je 0x693d
cmpb $0x2d, (%rbp)
jne 0x68d6
cmpb $0x2d, 0x1(%rbp)
je 0x69ef
testl %r13d, %r13d
jne 0x68e5
movl %r15d, 0x6f22(%rip)     # 0xd804
movl %r15d, %r13d
movq 0x8(%rsp), %rax
leaq (%rax,%r12,8), %r12
testq %rbp, %rbp
je 0x6918
movq %rbp, %rdi
callq 0x6c22
testl %eax, %eax
jne 0x690c
movq (%r12), %rbp
incl %r15d
addq $0x8, %r12
jmp 0x68ee
movl %r15d, 0x6ef5(%rip)     # 0xd808
movq %r14, %rdi
jmp 0x68a7
pushq $-0x1
popq %rax
testl %r13d, %r13d
je 0x692e
movl %r13d, 0x6ee1(%rip)     # 0xd808
andl $0x0, 0x6ed6(%rip)      # 0xd804
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, 0x6eb9(%rip)      # 0xd800
pushq $0x1
popq %rdi
cmpb $0x0, (%rbp,%rdi)
je 0x6be4
addq %rbp, %rdi
movq %rdi, %r14
movq 0x10(%rsp), %rsi
callq 0x6c7e
cmpl $0x3, %eax
ja 0x6acc
movl %eax, %eax
leaq 0x1f51(%rip), %rcx      # 0x88c8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
andq $0x0, 0x6e88(%rip)      # 0xd810
movslq 0x6e71(%rip), %rax      # 0xd800
leaq 0x1(%rax), %rcx
movl %ecx, 0x6e67(%rip)      # 0xd800
cmpb $0x0, 0x1(%rbp,%rax)
jne 0x6b0e
incl 0x6e5e(%rip)            # 0xd808
andl $0x0, 0x6e4f(%rip)      # 0xd800
jmp 0x6b0e
movslq %r15d, %r14
movq (%rbx,%r14,8), %rdi
callq 0x6c22
testl %eax, %eax
jne 0x69d9
movl 0x6e3c(%rip), %edx      # 0xd808
movq %rbx, %rdi
movl %r15d, %esi
callq 0x6c3e
jmp 0x69b9
movl %r15d, 0x6e28(%rip)     # 0xd808
andl $0x0, 0x6e1d(%rip)      # 0xd804
xorl %r13d, %r13d
jmp 0x6885
cmpb $0x0, 0x2(%rbp)
je 0x6af2
addq $0x2, %rbp
movq %rbp, %rdi
movq 0x18(%rsp), %r14
movq %r14, %rsi
callq 0x6d5a
cmpl $-0x1, %eax
je 0x6b17
movq %rbp, %rdi
movl %eax, %r13d
callq 0x20e0
movq %rax, 0x10(%rsp)
pushq $0x3d
popq %rsi
movq %rbp, %rdi
callq 0x20f0
movq %rax, %rcx
subq %rbp, %rcx
testq %rax, %rax
cmoveq 0x10(%rsp), %rcx
movslq %r13d, %rax
shlq $0x5, %rax
movl 0x8(%r14,%rax), %edx
cmpl $0x2, %edx
je 0x6b30
cmpl $0x1, %edx
jne 0x6b4a
movslq %ecx, %rcx
cmpb $0x3d, (%rbp,%rcx)
jne 0x6b79
addq %rcx, %rbp
incq %rbp
jmp 0x6b43
movslq 0x6d8a(%rip), %rax      # 0xd808
andl $0x0, 0x6d7b(%rip)      # 0xd800
leal 0x2(%rax), %ecx
movl %ecx, 0x6d7a(%rip)      # 0xd808
movq 0x8(%rbx,%rax,8), %rax
jmp 0x6ac3
leaq 0x1(%r14), %rax
movq %rax, 0x6d70(%rip)      # 0xd810
cmpb $0x0, 0x2(%r14)
je 0x6b00
movl 0x6d53(%rip), %eax      # 0xd800
addl $0x2, %eax
jmp 0x6b08
incl 0x6d50(%rip)            # 0xd808
andl $0x0, 0x6d41(%rip)      # 0xd800
leaq 0x1(%r14), %rax
movq %rax, 0x6d46(%rip)      # 0xd810
jmp 0x6b0e
cmpl $0x0, 0x6d45(%rip)      # 0xd818
jne 0x6bc0
incl 0x6d29(%rip)            # 0xd808
andl $0x0, 0x6d1a(%rip)      # 0xd800
movsbl (%r14), %eax
movl %eax, 0x6d2c(%rip)      # 0xd81c
jmp 0x6b28
incl %r15d
movl %r15d, 0x6d0c(%rip)     # 0xd808
pushq $-0x1
jmp 0x6b2a
incl 0x6d02(%rip)            # 0xd808
xorl %eax, %eax
movl %eax, 0x6cf2(%rip)      # 0xd800
movsbl (%r14), %eax
jmp 0x692e
incl %r15d
movl %r15d, 0x6ce7(%rip)     # 0xd808
andl $0x0, 0x6cf4(%rip)      # 0xd81c
pushq $0x3f
popq %rax
jmp 0x692e
movslq %ecx, %rcx
addq %rbp, %rcx
incq %rcx
xorl %ebp, %ebp
cmpb $0x3d, -0x1(%rcx)
cmoveq %rcx, %rbp
movq %rbp, 0x6cc6(%rip)      # 0xd810
movq 0x20(%rsp), %rcx
movl %r13d, (%rcx)
incl 0x6cb0(%rip)            # 0xd808
movq 0x18(%rsp), %rdx
addq %rax, %rdx
movq 0x10(%rdx), %rcx
movl 0x18(%rdx), %eax
testq %rcx, %rcx
je 0x692e
movl %eax, (%rcx)
xorl %eax, %eax
jmp 0x692e
incl %r15d
movl %r15d, 0x6c85(%rip)     # 0xd808
movq 0x8(%rbx,%r12,8), %rcx
movq %rcx, 0x6c81(%rip)      # 0xd810
testq %rcx, %rcx
jne 0x6b4a
cmpl $0x0, 0x6c7d(%rip)      # 0xd818
je 0x6b21
movq 0x5454(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movq (%rbx), %rdx
leaq 0x1d95(%rip), %rsi      # 0x8946
movq %rbp, %rcx
xorl %eax, %eax
callq 0x2180
jmp 0x6b21
movq 0x5431(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movq (%rbx), %rdx
movsbl (%r14), %ecx
leaq 0x1d54(%rip), %rsi      # 0x892c
xorl %eax, %eax
callq 0x2180
jmp 0x6ad9
leaq 0x1ced(%rip), %rdi      # 0x88d8
leaq 0x1ce8(%rip), %rsi      # 0x88da
leaq 0x1cef(%rip), %rcx      # 0x88e8
movl $0x143, %edx            # imm = 0x143
callq 0x2120
leaq 0x1cce(%rip), %rdi      # 0x88d8
leaq 0x1cc9(%rip), %rsi      # 0x88da
leaq 0x1d56(%rip), %rcx      # 0x896e
movl $0xe4, %edx
callq 0x2120