// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq (%rdi), %r13
movslq 0xc(%rdi), %r14
movq (%r13,%r14,8), %r15
movb $0x0, 0x20(%rdi)
andl $0x0, 0x10(%rdi)
andq $0x0, 0x18(%rdi)
pushq $-0x1
popq %rbp
testq %r15, %r15
je 0x25e5
movq %rdi, %rbx
movq %rsi, %r12
movq %r15, %rdi
callq 0x2629
testl %eax, %eax
je 0x24e9
incl %r14d
movl %r14d, 0xc(%rbx)
jmp 0x25e5
movq %r15, %rdi
callq 0x2640
testl %eax, %eax
je 0x257e
movslq 0x60(%rbx), %rax
movsbl 0x1(%r15,%rax), %ecx
movl %ecx, 0x10(%rbx)
movb 0x1(%r15,%rax), %cl
cmpb $0x3a, %cl
je 0x2558
addq %rax, %r15
movb (%r12), %dl
incq %r12
testb %dl, %dl
je 0x2522
cmpb %cl, %dl
jne 0x2513
testb %dl, %dl
je 0x2558
cmpb $0x3a, (%r12)
jne 0x25a8
cmpb $0x3a, 0x1(%r12)
jne 0x25b3
andl $0x0, 0x60(%rbx)
incl %r14d
movl %r14d, 0xc(%rbx)
leaq 0x2(%r15), %rax
xorl %ecx, %ecx
cmpb $0x0, 0x2(%r15)
cmovneq %rax, %rcx
movq %rcx, 0x18(%rbx)
jmp 0x25e0
leaq 0x6(%rsp), %rdx
andw $0x0, (%rdx)
movb %cl, (%rdx)
incl %r14d
movl %r14d, 0xc(%rbx)
leaq 0x4b88(%rip), %rsi      # 0x70f9
movq %rbx, %rdi
callq 0x2685
pushq $0x3f
popq %rbp
jmp 0x25e5
cmpl $0x0, 0x8(%rbx)
je 0x25e5
leal 0x1(%r14), %eax
movl %eax, 0xc(%rbx)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x249b
movl %eax, %ebp
movq %rbx, %rdi
movl %r14d, %esi
callq 0x2657
decl 0xc(%rbx)
jmp 0x25e5
cmpb $0x0, 0x2(%r15)
je 0x25d4
incl %eax
jmp 0x25dd
movq 0x8(%r13,%r14,8), %rax
andl $0x0, 0x60(%rbx)
leal 0x1(%r14), %ecx
movl %ecx, 0xc(%rbx)
cmpb $0x0, 0x2(%r15)
je 0x25f6
leaq 0x2(%r15), %rax
movq %rax, 0x18(%rbx)
jmp 0x25e0
incl %r14d
movl %r14d, 0xc(%rbx)
xorl %eax, %eax
movl %eax, 0x60(%rbx)
movsbl 0x1(%r15), %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rax, %rax
je 0x2609
movq %rax, 0x18(%rbx)
addl $0x2, %r14d
movl %r14d, 0xc(%rbx)
jmp 0x25e0
leaq 0x4(%rsp), %rdx
andw $0x0, (%rdx)
movb 0x1(%r15), %al
movb %al, (%rdx)
andq $0x0, 0x18(%rbx)
leaq 0x4ae4(%rip), %rsi      # 0x7108
jmp 0x2571