// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0xc(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movb $0x0, 0x20(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x18(%rax)
cmpq $0x0, -0x30(%rbp)
jne 0x2529
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x27a7
movq -0x30(%rbp), %rdi
callq 0x27b0
cmpl $0x0, %eax
je 0x2550
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x27a7
movq -0x30(%rbp), %rdi
callq 0x2810
cmpl $0x0, %eax
jne 0x25ba
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
je 0x25ae
movq -0x10(%rbp), %rcx
movl 0xc(%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0xc(%rcx)
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x24d0
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x2870
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0xc(%rax)
movl -0x38(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x27a7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x27a7
jmp 0x25bc
jmp 0x25be
movq -0x10(%rbp), %rax
movslq 0x60(%rax), %rax
movq -0x30(%rbp), %rcx
leaq 0x1(%rax,%rcx), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rax
movsbl (%rax), %esi
callq 0x2900
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rcx
movq (%rcx), %rax
movslq 0xc(%rcx), %rcx
movq 0x8(%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movl -0x1c(%rbp), %eax
incl %eax
movl %eax, %ecx
movq %rcx, -0x48(%rbp)
subl $0x3, %eax
ja 0x27a0
movq -0x48(%rbp), %rax
leaq 0x89e9(%rip), %rcx      # 0xb010
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x3a(%rbp), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2160
movq -0x30(%rbp), %rax
movb (%rax), %al
movb %al, -0x3a(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
movq -0x10(%rbp), %rdi
leaq -0x3a(%rbp), %rdx
leaq 0x8b74(%rip), %rsi      # 0xb1d9
callq 0x29c0
movl %eax, -0x4(%rbp)
jmp 0x27a7
movq -0x30(%rbp), %rax
cmpb $0x0, 0x1(%rax)
je 0x268b
movq -0x10(%rbp), %rax
movl 0x60(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x60(%rax)
jmp 0x26a3
movq -0x10(%rbp), %rax
movl $0x0, 0x60(%rax)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x27a7
movq -0x10(%rbp), %rax
movl $0x0, 0x60(%rax)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
movq -0x30(%rbp), %rax
cmpb $0x0, 0x1(%rax)
je 0x26e6
movq -0x30(%rbp), %rcx
addq $0x1, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x2748
cmpq $0x0, -0x28(%rbp)
je 0x2708
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x2746
leaq -0x3c(%rbp), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2160
movq -0x30(%rbp), %rax
movb (%rax), %al
movb %al, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x10(%rbp), %rdi
leaq -0x3c(%rbp), %rdx
leaq 0x8aac(%rip), %rsi      # 0xb1e8
callq 0x29c0
movl %eax, -0x4(%rbp)
jmp 0x27a7
jmp 0x2748
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x27a7
movq -0x10(%rbp), %rax
movl $0x0, 0x60(%rax)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
movq -0x30(%rbp), %rax
cmpb $0x0, 0x1(%rax)
je 0x2788
movq -0x30(%rbp), %rcx
addq $0x1, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x2794
movq -0x10(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x27a7
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq