// File: /workspace/github_c_makefile_star2_O1/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 %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
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 0x26b3
movq %rdi, %rbx
movb (%rcx), %dil
cmpb $0x2d, %dil
jne 0x268c
cmpb $0x2d, 0x1(%rcx)
jne 0x2679
cmpb $0x0, 0x2(%rcx)
je 0x26bc
cmpb $0x2d, %dil
jne 0x268c
movzbl 0x1(%rcx), %edi
cmpl $0x2d, %edi
je 0x268c
testl %edi, %edi
jne 0x26c5
cmpl $0x0, 0x8(%rbx)
je 0x26b3
leal 0x1(%r14), %eax
movl %eax, 0xc(%rbx)
movq %rbx, %rdi
callq 0x2631
movl %eax, %ebp
movq %rbx, %rdi
movl %r14d, %esi
callq 0x27ec
decl 0xc(%rbx)
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
incl %r14d
movl %r14d, 0xc(%rbx)
jmp 0x26b3
movslq 0x60(%rbx), %rax
movsbl 0x1(%rcx,%rax), %edi
movl %edi, 0x10(%rbx)
movb 0x1(%rcx,%rax), %dil
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
cmpb $0x3a, %dil
je 0x270d
movb (%rsi), %r9b
incq %rsi
testb %r9b, %r9b
je 0x26f2
cmpb %dil, %r9b
jne 0x26e2
testb %r9b, %r9b
je 0x270d
xorl %r8d, %r8d
cmpb $0x3a, (%rsi)
jne 0x270d
xorl %r8d, %r8d
cmpb $0x3a, 0x1(%rsi)
sete %r8b
incl %r8d
addq %rax, %rcx
incl %r8d
leaq 0x58f6(%rip), %rsi      # 0x8010
movslq (%rsi,%r8,4), %r8
addq %rsi, %r8
jmpq *%r8
leaq 0xe(%rsp), %rdx
movw $0x0, (%rdx)
movb %dil, (%rdx)
incl %r14d
movl %r14d, 0xc(%rbx)
leaq 0x59aa(%rip), %rsi      # 0x80e9
movq %rbx, %rdi
callq 0x2821
movl $0x3f, %eax
jmp 0x26b3
movq 0x8(%rdx,%r14,8), %rax
movl $0x0, 0x60(%rbx)
leal 0x1(%r14), %edx
movl %edx, 0xc(%rbx)
cmpb $0x0, 0x2(%rcx)
je 0x27a3
leaq 0x2(%rcx), %rax
movq %rax, 0x18(%rbx)
jmp 0x27c0
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 0x27c0
cmpb $0x0, 0x2(%rcx)
je 0x27b2
incl %eax
movl %eax, 0x60(%rbx)
jmp 0x27c0
testq %rax, %rax
je 0x27c9
movq %rax, 0x18(%rbx)
addl $0x2, %r14d
jmp 0x27bc
movl $0x0, 0x60(%rbx)
incl %r14d
movl %r14d, 0xc(%rbx)
movsbl 0x1(%rcx), %eax
jmp 0x26b3
leaq 0xc(%rsp), %rdx
movw $0x0, (%rdx)
movb 0x1(%rcx), %al
movb %al, (%rdx)
movq $0x0, 0x18(%rbx)
leaq 0x5911(%rip), %rsi      # 0x80f8
jmp 0x273f