// File: /workspace/github_c_makefile_star2_O1/skeeto[P]enchive/src/optparse.h
// Function: optparse_long
OPTPARSE_API
int
optparse_long(struct optparse *options,
              const struct optparse_long *longopts,
              int *longindex)
{
    int i;
    char *option = options->argv[options->optind];
    if (option == 0) {
        return -1;
    } else if (optparse_is_dashdash(option)) {
        options->optind++; /* consume "--" */
        return -1;
    } else if (optparse_is_shortopt(option)) {
        return optparse_long_fallback(options, longopts, longindex);
    } else if (!optparse_is_longopt(option)) {
        if (options->permute) {
            int index = options->optind++;
            int r = optparse_long(options, longopts, longindex);
            optparse_permute(options, index);
            options->optind--;
            return r;
        } else {
            return -1;
        }
    }

    /* Parse as long option. */
    options->errmsg[0] = '\0';
    options->optopt = 0;
    options->optarg = 0;
    option += 2; /* skip "--" */
    options->optind++;
    for (i = 0; !optparse_longopts_end(longopts, i); i++) {
        const char *name = longopts[i].longname;
        if (optparse_longopts_match(name, option)) {
            char *arg;
            if (longindex)
                *longindex = i;
            options->optopt = longopts[i].shortname;
            arg = optparse_longopts_arg(option);
            if (longopts[i].argtype == OPTPARSE_NONE && arg != 0) {
                return optparse_error(options, OPTPARSE_MSG_TOOMANY, name);
            } if (arg != 0) {
                options->optarg = arg;
            } else if (longopts[i].argtype == OPTPARSE_REQUIRED) {
                options->optarg = options->argv[options->optind++];
                if (options->optarg == 0)
                    return optparse_error(options, OPTPARSE_MSG_MISSING, name);
            }
            return options->optopt;
        }
    }
    return optparse_error(options, OPTPARSE_MSG_INVALID, option);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq (%rdi), %rax
movslq 0xc(%rdi), %r13
movq (%rax,%r13,8), %rbp
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rbp, %rbp
je 0x2ae0
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movb (%rbp), %cl
cmpb $0x2d, %cl
jne 0x2ab3
cmpb $0x2d, 0x1(%rbp)
jne 0x290b
cmpb $0x0, 0x2(%rbp)
je 0x2af2
cmpb $0x2d, %cl
jne 0x2ab3
movzbl 0x1(%rbp), %edx
testl %edx, %edx
je 0x2925
cmpl $0x2d, %edx
jne 0x2afb
cmpb $0x2d, %cl
jne 0x2ab3
cmpb $0x2d, 0x1(%rbp)
jne 0x2ab3
cmpb $0x0, 0x2(%rbp)
je 0x2ab3
movb $0x0, 0x20(%rbx)
movl $0x0, 0x10(%rbx)
movq $0x0, 0x18(%rbx)
leaq 0x2(%rbp), %rax
movq %rax, 0x8(%rsp)
incl %r13d
movl %r13d, 0xc(%rbx)
addq $0x3, %rbp
xorl %r13d, %r13d
movq %r13, %rdx
shlq $0x4, %rdx
leaq (%r15,%rdx), %rcx
cmpq $0x0, (%r15,%rdx)
jne 0x2988
cmpl $0x0, 0x8(%rcx)
je 0x2b92
movq (%r15,%rdx), %rdx
movb $0x1, %r12b
testq %rdx, %rdx
je 0x2a19
movq 0x8(%rsp), %rsi
movb (%rsi), %dil
testb %dil, %dil
sete %sil
je 0x29e9
cmpb $0x3d, %dil
je 0x29f0
movb (%rdx), %r10b
testb %r10b, %r10b
je 0x29f0
leaq 0x1(%rdx), %r11
movq %rbp, %r9
cmpb %r10b, %dil
jne 0x2a19
movq %r11, %r8
movb (%r9), %dil
testb %dil, %dil
sete %sil
je 0x29f3
cmpb $0x3d, %dil
je 0x29f3
movb (%r8), %r10b
incq %r9
leaq 0x1(%r8), %r11
testb %r10b, %r10b
jne 0x29be
jmp 0x29f3
xorl %edi, %edi
movq %rdx, %r8
jmp 0x29fb
movq %rdx, %r8
cmpb $0x3d, %dil
sete %dil
xorl %r9d, %r9d
cmpb $0x0, (%r8)
sete %r9b
movzbl %dil, %r12d
cmovnel %r9d, %r12d
testb %sil, %sil
cmovnel %r9d, %r12d
xorb $0x1, %r12b
testb %r12b, %r12b
jne 0x2a99
testq %r14, %r14
je 0x2a26
movl %r13d, (%r14)
movl 0x8(%rcx), %eax
movl %eax, 0x10(%rbx)
movq %rbp, %rsi
movzbl -0x1(%rsi), %edi
testl %edi, %edi
je 0x2a41
cmpl $0x3d, %edi
je 0x2a41
incq %rsi
jmp 0x2a2f
movl 0xc(%rcx), %ecx
cmpb $0x3d, %dil
movl $0x0, %r8d
cmovneq %r8, %rsi
jne 0x2a6e
testl %ecx, %ecx
jne 0x2a6e
movq %rbx, %rdi
leaq 0x56b2(%rip), %rsi      # 0x8114
callq 0x2821
movl $0x3f, %eax
jmp 0x2a99
cmpb $0x3d, %dil
jne 0x2a7a
movq %rsi, 0x18(%rbx)
jmp 0x2a99
cmpl $0x1, %ecx
jne 0x2a99
movq (%rbx), %rcx
movslq 0xc(%rbx), %rsi
leal 0x1(%rsi), %edi
movl %edi, 0xc(%rbx)
movq (%rcx,%rsi,8), %rcx
movq %rcx, 0x18(%rbx)
testq %rcx, %rcx
je 0x2aa7
incq %r13
testb %r12b, %r12b
jne 0x296c
jmp 0x2ae0
movq %rbx, %rdi
leaq 0x5647(%rip), %rsi      # 0x80f8
jmp 0x2a62
cmpl $0x0, 0x8(%rbx)
je 0x2ae0
leal 0x1(%r13), %eax
movl %eax, 0xc(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x28bc
movl %eax, %ebp
movq %rbx, %rdi
movl %r13d, %esi
callq 0x27ec
decl 0xc(%rbx)
movl %ebp, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
incl %r13d
movl %r13d, 0xc(%rbx)
jmp 0x2ae0
leaq 0x10(%rsp), %rax
xorl %ecx, %ecx
movq %rcx, %rsi
shlq $0x4, %rsi
leaq (%r15,%rsi), %rdx
cmpq $0x0, (%r15,%rsi)
jne 0x2b1a
cmpl $0x0, 0x8(%rdx)
je 0x2b43
movl 0x8(%rdx), %esi
testl %esi, %esi
je 0x2b3e
movb %sil, (%rax)
incq %rax
cmpl $0x0, 0xc(%rdx)
jle 0x2b3e
xorl %esi, %esi
movb $0x3a, (%rax,%rsi)
incq %rsi
cmpl 0xc(%rdx), %esi
jl 0x2b2f
addq %rsi, %rax
incq %rcx
jmp 0x2b02
movb $0x0, (%rax)
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x2631
testq %r14, %r14
je 0x2ae0
movl $0xffffffff, (%r14)     # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x2ae0
addq $0x8, %r15
xorl %ecx, %ecx
cmpq $0x0, -0x8(%r15)
jne 0x2b7f
cmpl $0x0, (%r15)
je 0x2ae0
movl (%r15), %edx
cmpl 0x10(%rbx), %edx
jne 0x2b8a
movl %ecx, (%r14)
incl %ecx
addq $0x10, %r15
jmp 0x2b6e
leaq 0x5550(%rip), %rsi      # 0x80e9
movq %rbx, %rdi
movq 0x8(%rsp), %rdx
callq 0x2821
movl $0x3f, %eax
jmp 0x2ae0