// File: /workspace/github_c_makefile_star2_O2/alexgirao[P]aimant/bsd-getopt_long.c
// Function: pure_getopt_internal
static int pure_getopt_internal(int nargc, char * const *nargv,
                                const char *options,
                                const struct pure_option *long_options,
                                int *idx, int flags)
{
    char *oli;                /* option letter list index */
    int optchar, short_too;
    static int posixly_correct = -1;
    
    if (options == NULL)
        return -1;
    
    /*
     * XXX Some GNU programs (like cvs) set pure_optind to 0 instead of
     * XXX using pure_optreset.  Work around this braindamage.
     */
    if (pure_optind == 0)
        pure_optind = pure_optreset = 1;    
    
    /*
     * Disable GNU extensions if POSIXLY_CORRECT is set or options
     * string begins with a '+'.
     */
    if (posixly_correct == -1 || pure_optreset)
        posixly_correct = (getenv("POSIXLY_CORRECT") != NULL);
    if (*options == '-')
        flags |= FLAG_ALLARGS;    
    else if (posixly_correct || *options == '+')
        flags &= ~FLAG_PERMUTE;
    if (*options == '+' || *options == '-')
        options++;
        
    pure_optarg = NULL;
    if (pure_optreset)
        nonopt_start = nonopt_end = -1;
    start:
    if (pure_optreset || !*pure_place) {        /* update scanning pointer */
        pure_optreset = 0;
        if (pure_optind >= nargc) {          /* end of argument vector */
            pure_place = EMSG;
            if (nonopt_end != -1) {
                /* do permutation, if we have to */
                pure_permute_args(nonopt_start, nonopt_end,
                                  pure_optind, nargv);
                pure_optind -= nonopt_end - nonopt_start;
            }
            else if (nonopt_start != -1) {
                /*
                 * If we skipped non-options, set pure_optind
                 * to the first of them.
                 */
                pure_optind = nonopt_start;
            }
            nonopt_start = nonopt_end = -1;
            return -1;
        }
        if (*(pure_place = nargv[pure_optind]) != '-' ||
            (pure_place[1] == '\0' && strchr(options, '-') == NULL)) {
            pure_place = EMSG;        /* found non-option */
            if (flags & FLAG_ALLARGS) {
                /*
                 * GNU extension:
                 * return non-option as argument to option 1
                 */
                pure_optarg = nargv[pure_optind++];
                return INORDER;
            }
            if (!(flags & FLAG_PERMUTE)) {
                /*
                 * If no permutation wanted, stop parsing
                 * at first non-option.
                 */
                return -1;
            }
            /* do permutation */
            if (nonopt_start == -1)
                nonopt_start = pure_optind;
            else if (nonopt_end != -1) {
                pure_permute_args(nonopt_start, nonopt_end,
                                  pure_optind, nargv);
                nonopt_start = pure_optind -
                    (nonopt_end - nonopt_start);
                nonopt_end = -1;
            }
            pure_optind++;
            /* process next argument */
            goto start;
        }
        if (nonopt_start != -1 && nonopt_end == -1)
            nonopt_end = pure_optind;

        /*
         * Check for "--" or "--foo" with no long options
         * but if pure_place is simply "-" leave it unmolested.
         */

        if (pure_place[1] != '\0' && *++pure_place == '-' &&
            (pure_place[1] == '\0' || long_options == NULL)) {
            pure_optind++;
            pure_place = EMSG;
            /*
             * We found an option (--), so if we skipped
             * non-options, we have to permute.
             */
            if (nonopt_end != -1) {
                pure_permute_args(nonopt_start, nonopt_end,
                                  pure_optind, nargv);
                pure_optind -= nonopt_end - nonopt_start;
            }
            nonopt_start = nonopt_end = -1;
            return -1;
        }
    }
    
    /*
     * Check long options if:
     *  1) we were passed some
     *  2) the arg is not just "-"
     *  3) either the arg starts with -- we are pure_getopt_long_only()
     */
    if (long_options != NULL && pure_place != nargv[pure_optind] &&
        (*pure_place == '-' || (flags & FLAG_LONGONLY))) {
        short_too = 0;
        if (*pure_place == '-')
            pure_place++;        /* --foo long option */
        else if (*pure_place != ':' && strchr(options, *pure_place) != NULL)
            short_too = 1;        /* could be short option too */
        
        optchar = pure_parse_long_options(nargv, options, long_options,
                                          idx, short_too);
        if (optchar != -1) {
            pure_place = EMSG;
            return optchar;
        }
    }
    
    if ((optchar = (int) *pure_place++) == ':' ||
        (optchar == '-' && *pure_place) != '\0' ||
        (oli = strchr(options, optchar)) == NULL) { 
         /*
          * If the user didn't specify '-' as an option,
          * assume it means -1 as POSIX specifies.
          */
        if (optchar == '-')
            return -1;
        /* option letter unknown or ':' */
        if (!*pure_place)
            ++pure_optind;
        if (PRINT_ERROR)
            fprintf(stderr, illoptchar, optchar);
        pure_optopt = optchar;
        return BADCH;
    }
    if (long_options != NULL && optchar == 'W' && oli[1] == ';') {
        /* -W long-option */
        if (*pure_place)            /* no space */
            /* NOTHING */;
        else if (++pure_optind >= nargc) {    /* no arg */
            pure_place = EMSG;
            if (PRINT_ERROR)
                fprintf(stderr, recargchar, optchar);
            pure_optopt = optchar;
            return BADARG;
        } else                /* white space */
            pure_place = nargv[pure_optind];
        optchar = pure_parse_long_options(nargv, options, long_options,
                                          idx, 0);
        pure_place = EMSG;
        return optchar;
    }
    if (*++oli != ':') {            /* doesn't take argument */
        if (!*pure_place) {
            ++pure_optind;
        }
    } else {                /* takes (optional) argument */
        pure_optarg = NULL;
        if (*pure_place) {            /* no white space */
            pure_optarg = pure_place;
        } else if (oli[1] != ':') {    /* arg not optional */
            if (++pure_optind >= nargc) {    /* no arg */
                pure_place = EMSG;
                if (PRINT_ERROR)
                    fprintf(stderr, recargchar, optchar);
                pure_optopt = optchar;
                return BADARG;
            } else {
                pure_optarg = nargv[pure_optind];
            }
        }
        pure_place = EMSG;
        ++pure_optind;
    }
    /* dump back option letter */
    return optchar;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edi, -0x2c(%rbp)
testq %rdx, %rdx
je 0x395d
movq %rcx, %r12
movq %rdx, %r15
movq %rsi, %r10
movq %r8, -0x58(%rbp)
movl 0x501e(%rip), %ebx      # 0x86d4
testl %ebx, %ebx
je 0x36c3
movl 0x503f(%rip), %r14d     # 0x8700
jmp 0x36d5
pushq $0x1
popq %rbx
movl %ebx, 0x5034(%rip)      # 0x8700
movl %ebx, 0x5002(%rip)      # 0x86d4
movl %ebx, %r14d
movl 0x5001(%rip), %ecx      # 0x86dc
cmpl $-0x1, %ecx
sete %al
testl %r14d, %r14d
setne %dl
orb %al, %dl
cmpb $0x1, %dl
movq %r10, -0x38(%rbp)
jne 0x3716
leaq 0x282f(%rip), %rdi      # 0x5f28
movl %r9d, %r13d
callq 0x1030
movl %r13d, %r9d
movq -0x38(%rbp), %r10
xorl %ecx, %ecx
testq %rax, %rax
setne %cl
movl %ecx, 0x4fc6(%rip)      # 0x86dc
movb (%r15), %dl
cmpb $0x2d, %dl
jne 0x3727
orl $0x2, %r9d
movl %r9d, %eax
jmp 0x373c
movl %r9d, %eax
andl $-0x2, %eax
testl %ecx, %ecx
cmovnel %eax, %r9d
cmpb $0x2b, %dl
cmovel %eax, %r9d
jne 0x3742
incq %r15
movl %eax, %r9d
movq %r12, -0x40(%rbp)
andq $0x0, 0x4fba(%rip)      # 0x8708
testl %r14d, %r14d
je 0x3769
orl $-0x1, 0x4f86(%rip)     # 0x86e0
orl $-0x1, 0x4f83(%rip)     # 0x86e4
pushq $-0x1
popq %rdx
movl %edx, %r12d
jmp 0x3776
movl 0x4f74(%rip), %r12d     # 0x86e4
movl 0x4f6a(%rip), %edx      # 0x86e0
movq %r15, -0x48(%rbp)
movq 0x4f67(%rip), %r15      # 0x86e8
leaq 0x1de9(%rip), %r13      # 0x5571
movl %r9d, -0x4c(%rbp)
movslq %ebx, %rsi
testl %r14d, %r14d
jne 0x379e
cmpb $0x0, (%r15)
jne 0x39a0
andl $0x0, 0x4f5b(%rip)      # 0x8700
cmpl -0x2c(%rbp), %ebx
jge 0x388d
movq (%r10,%rsi,8), %r15
movq %r15, 0x4f2f(%rip)      # 0x86e8
cmpb $0x2d, (%r15)
jne 0x3808
movb 0x1(%r15), %r14b
testb %r14b, %r14b
jne 0x38c8
movq -0x48(%rbp), %rdi
movl %ebx, -0x5c(%rbp)
movl %r12d, %r13d
movl %edx, %r12d
movq %rsi, %rbx
pushq $0x2d
popq %rsi
callq 0x1100
movq %rbx, %rsi
movl %r12d, %edx
movl %r13d, %r12d
leaq 0x1d7d(%rip), %r13      # 0x5571
movl -0x5c(%rbp), %ebx
movl -0x4c(%rbp), %r9d
movq -0x38(%rbp), %r10
testq %rax, %rax
jne 0x38c8
movq %r13, 0x4ed9(%rip)      # 0x86e8
testb $0x2, %r9b
jne 0x3964
testb $0x1, %r9b
je 0x395d
cmpl $-0x1, %r12d
je 0x3871
xorl %r14d, %r14d
cmpl $-0x1, %edx
je 0x386c
movl %r12d, %edi
movl %edx, %r14d
movl %edx, %esi
movl %ebx, %edx
movq %r10, %rcx
callq 0x3cb9
movl -0x4c(%rbp), %r9d
movq -0x38(%rbp), %r10
movl 0x4e83(%rip), %ebx      # 0x86d4
subl %r14d, %r12d
orl $-0x1, 0x4e85(%rip)     # 0x86e0
addl %ebx, %r12d
movl %r12d, 0x4e7f(%rip)     # 0x86e4
movl 0x4e94(%rip), %r14d     # 0x8700
pushq $-0x1
popq %rdx
jmp 0x387d
movl %ebx, 0x4e6d(%rip)      # 0x86e4
xorl %r14d, %r14d
movl %ebx, %r12d
incl %ebx
movl %ebx, 0x4e4f(%rip)      # 0x86d4
movq %r13, %r15
jmp 0x378c
leaq 0x1cdd(%rip), %rax      # 0x5571
movq %rax, 0x4e4d(%rip)      # 0x86e8
cmpl $-0x1, %edx
je 0x397a
movl %r12d, %edi
movl %edx, %r14d
movl %edx, %esi
movl %ebx, %edx
movq %r10, %rcx
callq 0x3cb9
subl %r14d, %r12d
addl 0x4e14(%rip), %r12d     # 0x86d4
pushq $-0x1
popq %rax
jmp 0x3983
cmpl $-0x1, %r12d
setne %al
cmpl $-0x1, %edx
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x38e4
movl %ebx, 0x4dfe(%rip)      # 0x86e0
movl %ebx, %edx
testb %r14b, %r14b
je 0x39a0
leaq 0x1(%r15), %rax
movq %rax, 0x4df0(%rip)      # 0x86e8
cmpb $0x2d, %r14b
jne 0x399d
cmpq $0x0, -0x40(%rbp)
movq -0x48(%rbp), %r13
je 0x3918
cmpb $0x0, 0x2(%r15)
jne 0x39b4
incl %ebx
movl %ebx, 0x4db4(%rip)      # 0x86d4
leaq 0x1c4a(%rip), %rax      # 0x5571
movq %rax, 0x4dba(%rip)      # 0x86e8
cmpl $-0x1, %edx
je 0x394f
movl %r12d, %edi
movl %edx, %r14d
movl %edx, %esi
movl %ebx, %edx
movq %r10, %rcx
callq 0x3cb9
subl %r14d, %r12d
addl %r12d, 0x4d85(%rip)     # 0x86d4
orl $-0x1, 0x4d8a(%rip)     # 0x86e0
orl $-0x1, 0x4d87(%rip)     # 0x86e4
pushq $-0x1
jmp 0x3ade
incl %ebx
movl %ebx, 0x4d68(%rip)      # 0x86d4
movq %r15, 0x4d95(%rip)      # 0x8708
pushq $0x1
jmp 0x3ade
cmpl $-0x1, %r12d
pushq $-0x1
popq %rax
je 0x398a
movl %r12d, 0x4d4a(%rip)     # 0x86d4
orl $-0x1, 0x4d4f(%rip)     # 0x86e0
orl $-0x1, 0x4d4c(%rip)     # 0x86e4
jmp 0x3adf
movq %rax, %r15
cmpq $0x0, -0x40(%rbp)
je 0x39c9
cmpq (%r10,%rsi,8), %r15
je 0x39fd
movq %r15, %rax
movq -0x48(%rbp), %r13
movb (%rax), %cl
movb $0x1, %r14b
testb $0x4, %r9b
jne 0x39ce
cmpb $0x2d, %cl
je 0x39ce
movq %rax, %r15
jmp 0x3a04
xorl %r14d, %r14d
jmp 0x3a00
xorl %r8d, %r8d
cmpb $0x3a, %cl
je 0x3b1c
movzbl %cl, %edx
cmpl $0x2d, %edx
movq -0x58(%rbp), %rbx
movq -0x40(%rbp), %r15
jne 0x3b26
incq %rax
movq %rax, 0x4cf0(%rip)      # 0x86e8
jmp 0x3b3f
movb $0x1, %r14b
movq -0x48(%rbp), %r13
leaq 0x1(%r15), %r12
movq %r12, 0x4cd9(%rip)      # 0x86e8
movzbl (%r15), %r15d
movsbl %r15b, %ebx
cmpl $0x3a, %r15d
pushq $-0x1
popq %rax
je 0x3ab5
cmpl $0x2d, %r15d
jne 0x3a35
cmpb $0x0, (%r12)
jne 0x3adf
movq %r13, %rdi
movl %ebx, %esi
callq 0x1100
testq %rax, %rax
je 0x3aac
cmpb $0x57, %r15b
setne %dl
xorb $0x1, %r14b
movb 0x1(%rax), %cl
orb %dl, %r14b
jne 0x3aee
cmpb $0x3b, %cl
jne 0x3aee
cmpb $0x0, (%r12)
movq -0x38(%rbp), %rdi
movq -0x58(%rbp), %rcx
movq -0x40(%rbp), %rdx
jne 0x3a9c
movslq 0x4c56(%rip), %rax      # 0x86d4
leal 0x1(%rax), %esi
movl %esi, 0x4c4d(%rip)      # 0x86d4
cmpl -0x2c(%rbp), %esi
jge 0x3b9a
movq 0x8(%rdi,%rax,8), %rax
movq %rax, 0x4c4c(%rip)      # 0x86e8
movq %r13, %rsi
xorl %r8d, %r8d
callq 0x3d59
jmp 0x3b55
cmpb $0x2d, %r15b
pushq $-0x1
popq %rax
je 0x3adf
cmpb $0x0, (%r12)
jne 0x3ac2
incl 0x4c12(%rip)            # 0x86d4
cmpl $0x0, 0x4c07(%rip)      # 0x86d0
je 0x3ad6
cmpb $0x3a, (%r13)
jne 0x3bdb
movl %ebx, 0x4bfc(%rip)      # 0x86d8
pushq $0x3f
popq %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x3a, %cl
movq -0x38(%rbp), %rdx
jne 0x3b74
andq $0x0, 0x4c09(%rip)      # 0x8708
cmpb $0x0, (%r12)
je 0x3b8a
movq %r12, 0x4bf7(%rip)      # 0x8708
movl 0x4bbd(%rip), %eax      # 0x86d4
jmp 0x3c17
movq -0x58(%rbp), %rbx
movq -0x40(%rbp), %r15
jmp 0x3b3f
movsbl %cl, %esi
movq %r13, %rdi
callq 0x1100
movq -0x38(%rbp), %r10
xorl %r8d, %r8d
testq %rax, %rax
setne %r8b
movq %r10, %rdi
movq %r13, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x3d59
cmpl $-0x1, %eax
je 0x3b68
leaq 0x1a15(%rip), %rcx      # 0x5571
movq %rcx, 0x4b85(%rip)      # 0x86e8
jmp 0x3adf
movq 0x4b79(%rip), %r15      # 0x86e8
jmp 0x3a04
cmpb $0x0, (%r12)
jne 0x3c2d
incl 0x4b4f(%rip)            # 0x86d4
jmp 0x3c2d
cmpb $0x3a, 0x2(%rax)
movl 0x4b40(%rip), %ecx      # 0x86d4
jne 0x3bfa
movl %ecx, %eax
jmp 0x3c17
leaq 0x19d0(%rip), %rax      # 0x5571
movq %rax, 0x4b40(%rip)      # 0x86e8
cmpl $0x0, 0x4b21(%rip)      # 0x86d0
je 0x3bbc
cmpb $0x3a, (%r13)
jne 0x3c5d
movl $0x57, 0x4b12(%rip)     # 0x86d8
xorl %eax, %eax
cmpb $0x3a, (%r13)
setne %al
leal (%rax,%rax,4), %eax
addl $0x3a, %eax
jmp 0x3adf
movq 0x4416(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq 0x23c8(%rip), %rsi      # 0x5fb4
movl %ebx, %edx
xorl %eax, %eax
callq 0x11b0
jmp 0x3ad6
leal 0x1(%rcx), %eax
movl %eax, 0x4ad1(%rip)      # 0x86d4
cmpl -0x2c(%rbp), %eax
jge 0x3c34
movslq %ecx, %rcx
movq 0x8(%rdx,%rcx,8), %rcx
movq %rcx, 0x4af1(%rip)      # 0x8708
leaq 0x1953(%rip), %rcx      # 0x5571
movq %rcx, 0x4ac3(%rip)      # 0x86e8
incl %eax
movl %eax, 0x4aa7(%rip)      # 0x86d4
movl %ebx, %eax
jmp 0x3adf
leaq 0x1936(%rip), %rax      # 0x5571
movq %rax, 0x4aa6(%rip)      # 0x86e8
cmpl $0x0, 0x4a87(%rip)      # 0x86d0
je 0x3c52
cmpb $0x3a, (%r13)
jne 0x3c7d
movl %ebx, 0x4a80(%rip)      # 0x86d8
jmp 0x3bc6
movq 0x4394(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq 0x235c(%rip), %rsi      # 0x5fca
pushq $0x57
popq %rdx
xorl %eax, %eax
callq 0x11b0
jmp 0x3bbc
movq 0x4374(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq 0x233c(%rip), %rsi      # 0x5fca
movl %ebx, %edx
xorl %eax, %eax
callq 0x11b0
jmp 0x3c52