// File: /workspace/github_c_makefile_star2_O3/skeeto[P]enchive/src/optparse.h
// Function: optparse
OPTPARSE_API
int
optparse(struct optparse *options, const char *optstring)
{
    int type;
    char *next;
    char *option = options->argv[options->optind];
    options->errmsg[0] = '\0';
    options->optopt = 0;
    options->optarg = 0;
    if (option == 0) {
        return -1;
    } else if (optparse_is_dashdash(option)) {
        options->optind++; /* consume "--" */
        return -1;
    } else if (!optparse_is_shortopt(option)) {
        if (options->permute) {
            int index = options->optind++;
            int r = optparse(options, optstring);
            optparse_permute(options, index);
            options->optind--;
            return r;
        } else {
            return -1;
        }
    }
    option += options->subopt + 1;
    options->optopt = option[0];
    type = optparse_argtype(optstring, option[0]);
    next = options->argv[options->optind + 1];
    switch (type) {
    case -1: {
        char str[2] = {0, 0};
        str[0] = option[0];
        options->optind++;
        return optparse_error(options, OPTPARSE_MSG_INVALID, str);
    }
    case OPTPARSE_NONE:
        if (option[1]) {
            options->subopt++;
        } else {
            options->subopt = 0;
            options->optind++;
        }
        return option[0];
    case OPTPARSE_REQUIRED:
        options->subopt = 0;
        options->optind++;
        if (option[1]) {
            options->optarg = option + 1;
        } else if (next != 0) {
            options->optarg = next;
            options->optind++;
        } else {
            char str[2] = {0, 0};
            str[0] = option[0];
            options->optarg = 0;
            return optparse_error(options, OPTPARSE_MSG_MISSING, str);
        }
        return option[0];
    case OPTPARSE_OPTIONAL:
        options->subopt = 0;
        options->optind++;
        if (option[1])
            options->optarg = option + 1;
        else
            options->optarg = 0;
        return option[0];
    }
    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq (%rdi), %rdx
movslq 0xc(%rdi), %r14
movq (%rdx,%r14,8), %rcx
movb $0x0, 0x20(%rdi)
movl $0x0, 0x10(%rdi)
movq $0x0, 0x18(%rdi)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rcx, %rcx
je 0x26f6
movq %rdi, %rbx
cmpb $0x2d, (%rcx)
jne 0x26ac
movzbl 0x1(%rcx), %edi
testl %edi, %edi
je 0x26ac
cmpl $0x2d, %edi
jne 0x26fe
cmpb $0x0, 0x2(%rcx)
je 0x2787
cmpl $0x0, 0x8(%rbx)
je 0x26f6
leal 0x1(%r14), %eax
movl %eax, 0xc(%rbx)
movq %rbx, %rdi
callq 0x2661
movq (%rbx), %rdi
movq (%rdi,%r14,8), %rcx
movslq 0xc(%rbx), %rdx
leal -0x1(%rdx), %esi
cmpl %r14d, %esi
jle 0x26ee
incq %r14
movq (%rbx), %rdi
movq (%rdi,%r14,8), %r8
movq %r8, -0x8(%rdi,%r14,8)
incq %r14
cmpq %r14, %rdx
jne 0x26d7
movq (%rbx), %rdi
movq %rcx, -0x8(%rdi,%rdx,8)
movl %esi, 0xc(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movslq 0x60(%rbx), %rax
movsbl 0x1(%rcx,%rax), %edi
movl %edi, 0x10(%rbx)
movb 0x1(%rcx,%rax), %dil
cmpb $0x3a, %dil
je 0x275a
addq %rax, %rcx
movb (%rsi), %r8b
incq %rsi
testb %r8b, %r8b
je 0x2728
cmpb %dil, %r8b
jne 0x2718
testb %r8b, %r8b
je 0x275a
cmpb $0x3a, (%rsi)
jne 0x2793
cmpb $0x3a, 0x1(%rsi)
jne 0x279d
movl $0x0, 0x60(%rbx)
incl %r14d
movl %r14d, 0xc(%rbx)
leaq 0x2(%rcx), %rax
xorl %edx, %edx
cmpb $0x0, 0x2(%rcx)
cmovneq %rax, %rdx
movq %rdx, 0x18(%rbx)
jmp 0x27cc
leaq 0x6(%rsp), %rdx
movw $0x0, (%rdx)
movb %dil, (%rdx)
incl %r14d
movl %r14d, 0xc(%rbx)
leaq 0x598b(%rip), %rsi      # 0x8100
movq %rbx, %rdi
callq 0x280b
movl $0x3f, %eax
jmp 0x26f6
incl %r14d
movl %r14d, 0xc(%rbx)
jmp 0x26f6
cmpb $0x0, 0x2(%rcx)
je 0x27c0
incl %eax
jmp 0x27c9
movq 0x8(%rdx,%r14,8), %rax
movl $0x0, 0x60(%rbx)
leal 0x1(%r14), %edx
movl %edx, 0xc(%rbx)
cmpb $0x0, 0x2(%rcx)
je 0x27d5
leaq 0x2(%rcx), %rax
movq %rax, 0x18(%rbx)
jmp 0x27cc
incl %r14d
movl %r14d, 0xc(%rbx)
xorl %eax, %eax
movl %eax, 0x60(%rbx)
movsbl 0x1(%rcx), %eax
jmp 0x26f6
testq %rax, %rax
je 0x27e8
movq %rax, 0x18(%rbx)
addl $0x2, %r14d
movl %r14d, 0xc(%rbx)
jmp 0x27cc
leaq 0x4(%rsp), %rdx
movw $0x0, (%rdx)
movb 0x1(%rcx), %al
movb %al, (%rdx)
movq $0x0, 0x18(%rbx)
leaq 0x5909(%rip), %rsi      # 0x810f
jmp 0x2775