// File: /workspace/github_cpp_makefile_star2_O3/ridiculousfish[P]docopt_fish/docopt_fish.cpp
// Function: docopt_fish::argv_classifier_t::parse_unseparated_short_options(std::vector<docopt_fish::error_t, std::allocator<docopt_fish::error_t>>*)
bool argv_classifier_t::parse_unseparated_short_options(error_list_t *out_errors) {
    const string_t &arg = this->arg();
    assert(this->arg_has_prefix("-"));
    assert(arg.length() > 1);  // must not be just a single dash
    bool errored = false;
    bool last_option_has_argument = false;

    // Construct the list of options in-order, corresponding to this argument
    std::vector<option_t> options_for_argument;

    // walk over the characters in the argument, skipping the leading dash
    for (size_t idx_in_arg = 1; idx_in_arg < arg.length() && !errored; idx_in_arg++) {
        // Get list of short options matching this resolved option.
        const rstring_t::char_t short_char = arg.at(idx_in_arg);
        const option_list_t matches = this->filter_options([&](const option_t &opt) {
            // This is a short option (-D) so we check the second character (idx 1)
            const rstring_t &name = opt.names[option_t::single_short];
            return name.length() > 1 && name[1] == short_char;
        });
        
        size_t match_count = matches.size();
        // We should catch all duplicates during the preflight phase
        assert(match_count <= 1);
        if (match_count < 1) {
            this->error(out_errors, error_unknown_option, "Unknown short option",
                              idx_in_arg);
            errored = true;
        } else {
            // Just one match, add it to the global array
            options_for_argument.push_back(matches.at(0));
        }
    }

    if (!errored) {
        // Now we have all of the short options that this argument represents. No
        // option is allowed to have a value, except possibly the last one.
        for (size_t i = 0; i < options_for_argument.size(); i++) {
            const option_t &opt = options_for_argument.at(i);
            if (opt.has_value()) {
                if (i + 1 == options_for_argument.size()) {
                    // This is the last option
                    last_option_has_argument = true;
                } else {
                    // This is not the last option
                    // This i+1 is the position in the argument and needs some
                    // explanation. We have a leading dash and then an argument,
                    // which is parsed into short options - one per character, including
                    // the dash. Hence we can map from index-in-option to index-in-argument,
                    // unless there was an unknown option error above. In that case this
                    // will be wrong (but we typically only show the first error anyways)
                    this->error(out_errors, error_option_unexpected_argument,
                                      "Option may not have a value unless it is the last option",
                                      i + 1);
                    errored = true;
                }
            }
        }
    }

    // If we have an argument, determine the index of its name and its value
    rstring_t value_for_last_option;
    const size_t name_idx = this->idx;
    size_t val_idx_for_last_option = npos;
    if (!errored && last_option_has_argument) {
        // We don't support -f=bar style for short options.
        // TODO: support delimiter-free style (gcc -Dmacro=something)
        if (this->idx + 1 < this->argv.size()) {
            val_idx_for_last_option = this->idx + 1;
            value_for_last_option = rstring_t(this->argv.at(this->idx + 1));
        } else {
            // We are at the last argument, and we expect a value. Return the value as
            // a suggestion.
            this->suggest(options_for_argument.back().value);
            this->error(out_errors, error_option_has_missing_argument,
                              "Option expects an argument");
            errored = true;
        }
    }

    if (!errored) {
        // Construct resolved options
        for (size_t i = 0; i < options_for_argument.size(); i++) {
            // Most options have no value.
            size_t val_idx = npos;
            rstring_t value;
            if (i + 1 == options_for_argument.size() && last_option_has_argument) {
                // This is the last option
                value = value_for_last_option;
                val_idx = val_idx_for_last_option;
            }
            const option_t &opt = options_for_argument.at(i);
            this->classification.resolved_options.emplace_back(opt, name_idx, val_idx, value);
        }

        // Update the index
        this->idx += (last_option_has_argument ? 2 : 1);
    }
    return !errored;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, 0x8(%rsp)
movq %rdi, %r12
callq 0x8e7a
movq %rax, %r15
leaq 0x1c105(%rip), %rsi     # 0x23574
movq %r12, %rdi
callq 0x8eac
testb %al, %al
je 0x7867
cmpq $0x1, 0x8(%r15)
jbe 0x7886
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movl $0x1, %r13d
xorl %r14d, %r14d
movq %r12, 0x28(%rsp)
movq (%r15), %rax
movl (%rax,%r13,4), %ebx
movq 0x8(%r12), %rax
movq (%rax), %rbp
movq 0x8(%rax), %r12
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
cmpq %r12, %rbp
je 0x7577
cmpq $0x2, 0x8(%rbp)
jb 0x7522
movq (%rbp), %rax
movq 0x10(%rbp), %rcx
cmpl %ebx, 0x4(%rcx,%rax,4)
jne 0x7522
movq 0x18(%rsp), %rax
cmpq 0x20(%rsp), %rax
je 0x7512
movl $0x10, %ecx
movq %rax, %rdi
movq %rbp, %rsi
rep  movsq (%rsi), %es:(%rdi)
subq $-0x80, %rax
movq %rax, 0x18(%rsp)
jmp 0x7522
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %rbp, %rdx
callq 0xf41e
subq $-0x80, %rbp
cmpq %r12, %rbp
jne 0x74d8
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rax
movq %rax, %rcx
subq %rdx, %rcx
cmpq $0x81, %rcx
jae 0x7848
cmpq %rdx, %rax
je 0x7577
movq 0x38(%rsp), %rax
cmpq 0x40(%rsp), %rax
je 0x75c7
movl $0x10, %ecx
movq %rax, %rdi
movq %rdx, %rsi
rep  movsq (%rsi), %es:(%rdi)
subq $-0x80, %rax
movq %rax, 0x38(%rsp)
movq 0x28(%rsp), %r12
jmp 0x759b
movb $0x1, %r14b
movq 0x28(%rsp), %r12
movq %r12, %rdi
movq 0x8(%rsp), %rsi
movl $0x67, %edx
leaq 0x18e52(%rip), %rcx     # 0x203e5
movq %r13, %r8
callq 0x8f00
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x75b2
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6200
incq %r13
cmpq 0x8(%r15), %r13
jae 0x75db
testb $0x1, %r14b
je 0x74ab
jmp 0x75db
leaq 0x30(%rsp), %rdi
movq %rax, %rsi
callq 0xf41e
movq 0x28(%rsp), %r12
jmp 0x759b
testb $0x1, %r14b
je 0x7604
leaq 0x20(%r12), %r8
movq 0x20(%r12), %rcx
movq %rcx, 0x58(%rsp)
movq $-0x1, %r9
movb $0x1, %bpl
movq 0x30(%rsp), %rsi
jmp 0x76ce
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rax
movq %rax, %rcx
subq %rsi, %rcx
je 0x76b5
sarq $0x7, %rcx
movl $0x50, %ebp
xorl %r13d, %r13d
leaq 0x18dcd(%rip), %r15     # 0x203fa
xorl %r12d, %r12d
movl %r13d, %ebx
incq %r12
cmpq $0x0, (%rsi,%rbp)
je 0x766c
movb $0x1, %r13b
cmpq %rcx, %r12
je 0x766f
movq 0x28(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl $0x65, %edx
movq %r15, %rcx
movq %r12, %r8
callq 0x8f00
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rax
movb $0x1, %r14b
movl %ebx, %r13d
movq %rax, %rcx
subq %rsi, %rcx
sarq $0x7, %rcx
subq $-0x80, %rbp
cmpq %rcx, %r12
jb 0x7630
movq 0x28(%rsp), %r12
leaq 0x20(%r12), %r8
movq 0x20(%r12), %rcx
movq %rcx, 0x58(%rsp)
movl %r13d, %ebp
xorb $0x1, %bpl
movl %r14d, %edx
orb %bpl, %dl
testb $0x1, %dl
je 0x77d7
movq $-0x1, %r9
jmp 0x76d1
leaq 0x20(%r12), %r8
movq 0x20(%r12), %rcx
movq %rcx, 0x58(%rsp)
movq $-0x1, %r9
movb $0x1, %bpl
xorl %r13d, %r13d
movq $0x0, 0x8(%rsp)
movq $0x0, 0x50(%rsp)
testb $0x1, %r14b
je 0x76f0
xorl %ebx, %ebx
jmp 0x77ae
movq 0x38(%rsp), %rax
subq %rsi, %rax
je 0x779c
movq %r9, 0x70(%rsp)
movq %r8, 0x68(%rsp)
sarq $0x7, %rax
addq $0x40, %r12
xorl %r14d, %r14d
leaq 0x10(%rsp), %r15
xorl %ebx, %ebx
movq $-0x1, 0x60(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
incq %rbx
cmpq %rax, %rbx
setne %al
orb %bpl, %al
testb $0x1, %al
jne 0x7762
movq 0x50(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x8(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
addq %r14, %rsi
movq %r12, %rdi
leaq 0x58(%rsp), %rdx
leaq 0x60(%rsp), %rcx
movq %r15, %r8
callq 0x9064
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rax
subq %rsi, %rax
sarq $0x7, %rax
subq $-0x80, %r14
cmpq %rax, %rbx
jb 0x771a
movq 0x68(%rsp), %r8
movq (%r8), %rcx
movzbl %r13b, %eax
andl $0x1, %eax
addq %rcx, %rax
incq %rax
movq %rax, (%r8)
movb $0x1, %bl
testq %rsi, %rsi
je 0x77c6
movq 0x40(%rsp), %rax
subq %rsi, %rax
movq %rsi, %rdi
movq %rax, %rsi
callq 0x6200
movl %ebx, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1(%rcx), %r9
movq (%r12), %rdi
movq (%rdi), %rdx
movq 0x8(%rdi), %rdi
subq %rdx, %rdi
sarq $0x5, %rdi
cmpq %rdi, %r9
jae 0x7813
movq %r9, %rax
shlq $0x5, %rax
movq (%rdx,%rax), %rdi
movq %rdi, 0x8(%rsp)
movq 0x8(%rdx,%rax), %rax
movq %rax, 0x50(%rsp)
xorl %ebp, %ebp
jmp 0x76e3
addq $-0x38, %rax
movq %r12, %rdi
movq %rax, %rsi
callq 0x8f58
leaq 0x18a8f(%rip), %rcx     # 0x202b8
movq %r12, %rdi
movq 0x8(%rsp), %rsi
movl $0x64, %edx
xorl %r8d, %r8d
callq 0x8f00
movq 0x30(%rsp), %rsi
jmp 0x76e9
leaq 0x18b85(%rip), %rdi     # 0x203d4
leaq 0x1880e(%rip), %rsi     # 0x20064
leaq 0x18b11(%rip), %rcx     # 0x2036e
movl $0x26a, %edx            # imm = 0x26A
callq 0x6120
leaq 0x18ae6(%rip), %rdi     # 0x20354
leaq 0x187ef(%rip), %rsi     # 0x20064
leaq 0x18af2(%rip), %rcx     # 0x2036e
movl $0x256, %edx            # imm = 0x256
callq 0x6120
leaq 0x18b36(%rip), %rdi     # 0x203c3
leaq 0x187d0(%rip), %rsi     # 0x20064
leaq 0x18ad3(%rip), %rcx     # 0x2036e
movl $0x257, %edx            # imm = 0x257
callq 0x6120
jmp 0x78a9
jmp 0x78a9
movq %rax, %rbx
jmp 0x78ca
jmp 0x78b0
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x78ca
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6200
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x78e1
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6200
movq %rbx, %rdi
callq 0x6360
nop