// File: /workspace/github_c_makefile_star2_O3/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 %r12
pushq %rbx
subq $0x130, %rsp            # imm = 0x130
movq (%rdi), %rax
movslq 0xc(%rdi), %r12
movq (%rax,%r12,8), %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rcx, %rcx
je 0x2a12
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
cmpb $0x2d, (%rcx)
jne 0x29c1
movzbl 0x1(%rcx), %edx
testl %edx, %edx
je 0x29c1
cmpl $0x2d, %edx
jne 0x2a22
cmpb $0x0, 0x2(%rcx)
je 0x2ab5
cmpb $0x0, 0x2(%rcx)
je 0x29c1
leaq 0x2(%rcx), %rax
movb $0x0, 0x20(%rbx)
movl $0x0, 0x10(%rbx)
movq $0x0, 0x18(%rbx)
incl %r12d
movl %r12d, 0xc(%rbx)
leaq 0x3(%rcx), %r8
xorl %edi, %edi
movq %rdi, %rdx
shlq $0x4, %rdx
leaq (%r15,%rdx), %rsi
movq (%r15,%rdx), %rdx
testq %rdx, %rdx
je 0x297b
movb (%rax), %r10b
movq %rdx, %r9
testb %r10b, %r10b
je 0x2973
movq %r8, %r11
movq %rdx, %r9
movb (%r9), %bpl
cmpb $0x3d, %r10b
je 0x298a
testb %bpl, %bpl
je 0x298a
cmpb %bpl, %r10b
jne 0x2985
incq %r9
movb (%r11), %r10b
incq %r11
testb %r10b, %r10b
jne 0x2952
cmpb $0x0, (%r9)
jne 0x2985
jmp 0x2995
cmpl $0x0, 0x8(%rsi)
je 0x2ada
incq %rdi
jmp 0x292d
cmpb $0x3d, %r10b
jne 0x2985
testb %bpl, %bpl
jne 0x2985
testq %r14, %r14
je 0x299d
movl %edi, (%r14)
movl 0x8(%rsi), %eax
movl %eax, 0x10(%rbx)
addq $0x3, %rcx
movzbl -0x1(%rcx), %edi
testl %edi, %edi
je 0x2ac1
cmpl $0x3d, %edi
je 0x2ac1
incq %rcx
jmp 0x29a7
cmpl $0x0, 0x8(%rbx)
je 0x2a12
leal 0x1(%r12), %eax
movl %eax, 0xc(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x28a6
movq (%rbx), %rdi
movq (%rdi,%r12,8), %rcx
movslq 0xc(%rbx), %rdx
leal -0x1(%rdx), %esi
cmpl %r12d, %esi
jle 0x2a0a
incq %r12
movq (%rbx), %rdi
movq (%rdi,%r12,8), %r8
movq %r8, -0x8(%rdi,%r12,8)
incq %r12
cmpq %r12, %rdx
jne 0x29f3
movq (%rbx), %rdi
movq %rcx, -0x8(%rdi,%rdx,8)
movl %esi, 0xc(%rbx)
addq $0x130, %rsp            # imm = 0x130
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rsp, %rax
xorl %ecx, %ecx
movq %rcx, %rdx
shlq $0x4, %rdx
cmpq $0x0, (%r15,%rdx)
movl 0x8(%r15,%rdx), %esi
je 0x2a40
testl %esi, %esi
jne 0x2a44
jmp 0x2a64
testl %esi, %esi
je 0x2a69
addq %r15, %rdx
movb %sil, (%rax)
incq %rax
cmpl $0x0, 0xc(%rdx)
jle 0x2a64
xorl %esi, %esi
movb $0x3a, (%rax,%rsi)
incq %rsi
cmpl 0xc(%rdx), %esi
jl 0x2a55
addq %rsi, %rax
incq %rcx
jmp 0x2a27
movb $0x0, (%rax)
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x2661
testq %r14, %r14
je 0x2a12
movl $0xffffffff, (%r14)     # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x2a12
addq $0x8, %r15
xorl %ecx, %ecx
cmpq $0x0, -0x8(%r15)
je 0x2a9a
movl (%r15), %edx
jmp 0x2aa5
movl (%r15), %edx
testl %edx, %edx
je 0x2a12
cmpl 0x10(%rbx), %edx
jne 0x2aad
movl %ecx, (%r14)
incl %ecx
addq $0x10, %r15
jmp 0x2a8e
incl %r12d
movl %r12d, 0xc(%rbx)
jmp 0x2a12
movl 0xc(%rsi), %esi
cmpb $0x3d, %dil
jne 0x2af6
testl %esi, %esi
jne 0x2af6
leaq 0x5656(%rip), %rsi      # 0x812b
movq %rbx, %rdi
jmp 0x2ae7
leaq 0x561f(%rip), %rsi      # 0x8100
movq %rbx, %rdi
movq %rax, %rdx
callq 0x280b
movl $0x3f, %eax
jmp 0x2a12
cmpb $0x3d, %dil
jne 0x2b05
movq %rcx, 0x18(%rbx)
jmp 0x2a12
cmpl $0x1, %esi
jne 0x2a12
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
jne 0x2a12
leaq 0x55dc(%rip), %rsi      # 0x810f
jmp 0x2ad5