// File: /workspace/github_c_makefile_star2_O2/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 $0x128, %rsp            # imm = 0x128
movq (%rdi), %rax
movslq 0xc(%rdi), %r13
movq (%rax,%r13,8), %r12
pushq $-0x1
popq %rbp
testq %r12, %r12
je 0x273a
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq %r12, %rdi
callq 0x2629
testl %eax, %eax
je 0x274e
incl %r13d
movl %r13d, 0xc(%rbx)
movl %ebp, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rdi
callq 0x2640
testl %eax, %eax
je 0x27f1
movq %rsp, %rax
xorl %ecx, %ecx
movq %rcx, %rdx
shlq $0x4, %rdx
cmpq $0x0, (%r15,%rdx)
movl 0x8(%r15,%rdx), %esi
je 0x277c
testl %esi, %esi
jne 0x2780
jmp 0x279d
testl %esi, %esi
je 0x27a2
addq %r15, %rdx
movb %sil, (%rax)
xorl %esi, %esi
cmpl 0xc(%rdx), %esi
jge 0x2797
movb $0x3a, 0x1(%rax,%rsi)
incq %rsi
jmp 0x2788
addq %rsi, %rax
incq %rax
incq %rcx
jmp 0x2763
movb $0x0, (%rax)
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x249b
movl %eax, %ebp
testq %r14, %r14
je 0x273a
orl $-0x1, (%r14)
cmpl $-0x1, %ebp
je 0x273a
addq $0x8, %r15
xorl %eax, %eax
cmpq $0x0, -0x8(%r15)
je 0x27d6
movl (%r15), %ecx
jmp 0x27e1
movl (%r15), %ecx
testl %ecx, %ecx
je 0x273a
cmpl 0x10(%rbx), %ecx
jne 0x27e9
movl %eax, (%r14)
incl %eax
addq $0x10, %r15
jmp 0x27ca
cmpb $0x2d, (%r12)
jne 0x2876
cmpb $0x2d, 0x1(%r12)
jne 0x2876
cmpb $0x0, 0x2(%r12)
je 0x2876
movb $0x0, 0x20(%rbx)
andl $0x0, 0x10(%rbx)
andq $0x0, 0x18(%rbx)
leaq 0x2(%r12), %rax
incl %r13d
movl %r13d, 0xc(%rbx)
xorl %esi, %esi
movq %rsi, %rdx
shlq $0x4, %rdx
leaq (%r15,%rdx), %rcx
movq (%r15,%rdx), %rdx
testq %rdx, %rdx
je 0x285b
xorl %edi, %edi
movb (%rax,%rdi), %r9b
movb (%rdx,%rdi), %r8b
testb %r9b, %r9b
je 0x286c
cmpb $0x3d, %r9b
je 0x2866
testb %r8b, %r8b
je 0x2866
cmpb %r8b, %r9b
jne 0x2871
incq %rdi
jmp 0x2839
cmpl $0x0, 0x8(%rcx)
jne 0x2871
jmp 0x28e7
cmpb $0x3d, %r9b
jne 0x2871
testb %r8b, %r8b
je 0x28aa
incq %rsi
jmp 0x2823
cmpl $0x0, 0x8(%rbx)
je 0x273a
leal 0x1(%r13), %eax
movl %eax, 0xc(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x26fa
movl %eax, %ebp
movq %rbx, %rdi
movl %r13d, %esi
callq 0x2657
decl 0xc(%rbx)
jmp 0x273a
testq %r14, %r14
je 0x28b2
movl %esi, (%r14)
movl 0x8(%rcx), %ebp
movl %ebp, 0x10(%rbx)
addq $0x3, %r12
movzbl -0x1(%r12), %eax
testl %eax, %eax
je 0x28d0
cmpl $0x3d, %eax
je 0x28d0
incq %r12
jmp 0x28bc
movl 0xc(%rcx), %ecx
cmpb $0x3d, %al
jne 0x2901
testl %ecx, %ecx
jne 0x2901
leaq 0x4842(%rip), %rsi      # 0x7124
movq %rbx, %rdi
jmp 0x28f4
leaq 0x480b(%rip), %rsi      # 0x70f9
movq %rbx, %rdi
movq %rax, %rdx
callq 0x2685
pushq $0x3f
popq %rbp
jmp 0x273a
cmpb $0x3d, %al
jne 0x290e
movq %r12, 0x18(%rbx)
jmp 0x273a
cmpl $0x1, %ecx
jne 0x273a
movq (%rbx), %rax
movslq 0xc(%rbx), %rcx
leal 0x1(%rcx), %esi
movl %esi, 0xc(%rbx)
movq (%rax,%rcx,8), %rax
movq %rax, 0x18(%rbx)
testq %rax, %rax
jne 0x273a
leaq 0x47cc(%rip), %rsi      # 0x7108
jmp 0x28e2