// File: /workspace/github_cpp_makefile_star2_O1/ridiculousfish[P]docopt_fish/docopt_matching.cpp
// Function: docopt_fish::match_options(std::vector<docopt_fish::option_t, std::allocator<docopt_fish::option_t>> const&, docopt_fish::match_state_t*, docopt_fish::match_context_t const&)
static bool match_options(const option_list_t &options_in_doc, match_state_t *state,
                          const match_context_t &ctx) {
    bool successful_match = false;
    bool made_suggestion = false;

    // Collect potential suggestions in here. We squelch them if we find that a
    // later matched option
    // has the same corresponding long name; we need to remove those from the
    // suggestions
    option_list_t potential_suggestions;

    for (const option_t &opt_in_doc : options_in_doc) {
        // Find the matching option from the resolved option list (i.e. argv)
        size_t resolved_opt_idx = npos;
        for (size_t i = 0; i < ctx.aclass.resolved_options.size(); i++) {
            // Skip ones that have already been consumed
            if (! state->consumed_options->at(i)) {
                // See if the option from argv has the same key range as the option in
                // the document
                if (ctx.aclass.resolved_options.at(i).option.has_same_name(opt_in_doc)) {
                    resolved_opt_idx = i;
                    break;
                }
            }
        }

        if (resolved_opt_idx != npos) {
            // We found a matching option in argv. Set it in the argument_values for
            // this state and mark its index as used
            // We have two things to set:
            //  - The option name, like -foo
            //  - The option's argument value (if any)
            const resolved_option_t &resolved_opt = ctx.aclass.resolved_options.at(resolved_opt_idx);
            const rstring_t &name = opt_in_doc.best_name();

            // Update the option value, creating it if necessary
            state->argument_values.mut()[name].count += 1;

            // Update the option argument vlaue
            if (opt_in_doc.has_value() && resolved_opt.value_idx_in_argv != npos) {
                const rstring_t &variable_name = opt_in_doc.value;

                const rstring_t &value = resolved_opt.value_in_arg;
                state->argument_values.mut()[variable_name].values.push_back(value.std_string());
            }

            successful_match = true;
            state->consumed_options.mut()[resolved_opt_idx] = true;
        } else {
            // This was an option that was not specified in argv
            // It can be a suggestion
            if (ctx.flags & flag_generate_suggestions) {
                potential_suggestions.push_back(opt_in_doc);
            }
        }
    }

    // Now go through and handle potential suggestions
    if (ctx.flags & flag_generate_suggestions) {
        for (const option_t &suggestion : potential_suggestions) {
            size_t type_idx = option_t::NAME_TYPE_COUNT;
            while (type_idx--) {
                option_t::name_type_t type = static_cast<option_t::name_type_t>(type_idx);
                if (suggestion.has_type(type)) {
                    state->suggested_next_arguments.insert(suggestion.names[type]);
                }
            }
            made_suggestion = true;
        }
    }

    bool matched_something = successful_match || made_suggestion;
    if (matched_something) {
        ctx.try_mark_fully_consumed(state);
    }
    return matched_something;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %r14
movq %rsi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq (%rdi), %r12
movq 0x8(%rdi), %rax
movq %rax, 0x28(%rsp)
cmpq %rax, %r12
je 0x1563d
leaq 0x10(%rbx), %rax
movq %rax, 0x30(%rsp)
leaq 0x30(%r12), %r13
movq $0x0, 0x8(%rsp)
movq 0x10(%r14), %rax
movq 0x20(%rax), %rcx
cmpq 0x18(%rax), %rcx
je 0x15490
xorl %r15d, %r15d
xorl %ebp, %ebp
movq 0x10(%rbx), %rdi
movq %rbp, %rsi
callq 0x16812
testb %al, %al
jne 0x15463
movq 0x10(%r14), %rax
movq 0x18(%rax), %rdi
movq 0x20(%rax), %rdx
subq %rdi, %rdx
sarq $0x3, %rdx
movabsq $-0x30c30c30c30c30c3, %rax # imm = 0xCF3CF3CF3CF3CF3D
imulq %rax, %rdx
cmpq %rbp, %rdx
jbe 0x156f8
addq %r15, %rdi
movq %r12, %rsi
callq 0xf5a2
testb %al, %al
jne 0x15497
incq %rbp
movq 0x10(%r14), %rax
movq 0x20(%rax), %rcx
subq 0x18(%rax), %rcx
sarq $0x3, %rcx
movabsq $-0x30c30c30c30c30c3, %rax # imm = 0xCF3CF3CF3CF3CF3D
imulq %rax, %rcx
addq $0xa8, %r15
cmpq %rcx, %rbp
jb 0x1541a
movq $-0x1, %rbp
cmpq $-0x1, %rbp
je 0x154fd
movq %rbp, 0x8(%rsp)
movq 0x10(%r14), %rax
movq 0x18(%rax), %rbp
movq 0x20(%rax), %rdx
subq %rbp, %rdx
sarq $0x3, %rdx
movabsq $-0x30c30c30c30c30c3, %rax # imm = 0xCF3CF3CF3CF3CF3D
imulq %rax, %rdx
movq 0x8(%rsp), %rsi
cmpq %rsi, %rdx
jbe 0x15709
imulq $0xa8, %rsi, %rax
addq %rax, %rbp
xorl %eax, %eax
leaq -0x18(%rax), %rcx
cmpq $-0x60, %rcx
je 0x15534
cmpq $0x0, 0x38(%r12,%rax)
leaq (%r13,%rax), %rax
cmovneq %rax, %r15
movq %rcx, %rax
je 0x154dd
jmp 0x15537
testb $0x1, 0x2(%r14)
je 0x1560c
movq 0x18(%rsp), %rax
cmpq 0x20(%rsp), %rax
je 0x15624
movl $0x10, %ecx
movq %rax, %rdi
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
subq $-0x80, %rax
movq %rax, 0x18(%rsp)
jmp 0x1560c
movq %r12, %r15
movq %rbx, %rdi
callq 0x15c6e
movq %rax, %rdi
movq %r15, %rsi
callq 0x160d0
incl 0x18(%rax)
cmpq $0x0, 0x50(%r12)
je 0x155b9
cmpq $-0x1, 0x88(%rbp)
je 0x155b9
movq %rbx, %rdi
callq 0x15c6e
leaq 0x48(%r12), %rsi
movq %rax, %rdi
callq 0x160d0
movq %rax, %r15
addq $0x90, %rbp
leaq 0x38(%rsp), %rdi
movq %rbp, %rsi
callq 0xbec4
movq %r15, %rdi
leaq 0x38(%rsp), %rsi
callq 0xde04
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x155b9
movq 0x48(%rsp), %rax
leaq 0x4(,%rax,4), %rsi
callq 0x7200
movq 0x30(%rsp), %rdi
callq 0x16872
movq 0x8(%rsp), %rcx
leaq 0x3f(%rcx), %rdx
testq %rcx, %rcx
cmovnsq %rcx, %rdx
sarq $0x6, %rdx
shlq $0x3, %rdx
addq (%rax), %rdx
movabsq $-0x8000000000000000, %rdi # imm = 0x8000000000000000
leaq 0x3f(%rdi), %rax
andq %rcx, %rax
xorl %esi, %esi
cmpq %rdi, %rax
setbe %sil
movl $0x1, %eax
shlq %cl, %rax
orq %rax, -0x8(%rdx,%rsi,8)
movb $0x1, %al
movq %rax, 0x8(%rsp)
movl $0x80, %eax
addq %rax, %r12
addq %rax, %r13
cmpq 0x28(%rsp), %r12
jne 0x15407
jmp 0x15636
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0x1043e
jmp 0x1560c
movq 0x8(%rsp), %rax
jmp 0x1563f
xorl %eax, %eax
testb $0x1, 0x2(%r14)
je 0x156a7
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %rcx
movq %rcx, 0x28(%rsp)
cmpq %rcx, %r12
je 0x156a7
movq %rax, 0x8(%rsp)
leaq 0x28(%rbx), %r15
leaq 0x30(%r12), %rbp
xorl %r13d, %r13d
cmpq $0x0, 0x38(%r12,%r13)
je 0x15681
movq %rbp, %rsi
addq %r13, %rsi
movq %r15, %rdi
callq 0xdcc4
addq $-0x18, %r13
cmpq $-0x48, %r13
jne 0x1566b
movl $0x80, %eax
addq %rax, %r12
addq %rax, %rbp
cmpq 0x28(%rsp), %r12
jne 0x15668
movb $0x1, %bpl
movq 0x8(%rsp), %rax
jmp 0x156a9
xorl %ebp, %ebp
orb %al, %bpl
testb $0x1, %bpl
je 0x156cc
testb $0x2, 0x2(%r14)
je 0x156cc
movq %r14, %rdi
movq %rbx, %rsi
callq 0x16406
testb %al, %al
je 0x156cc
movb $0x1, 0x58(%rbx)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x156e3
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x7200
andb $0x1, %bpl
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd720(%rip), %rdi      # 0x22e1f
movq %rbp, %rsi
xorl %eax, %eax
callq 0x7300
leaq 0xd70f(%rip), %rdi      # 0x22e1f
xorl %eax, %eax
callq 0x7300
jmp 0x1574f
jmp 0x1574f
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x15752
movq 0x48(%rsp), %rax
leaq 0x4(,%rax,4), %rsi
callq 0x7200
jmp 0x15752
jmp 0x1574f
jmp 0x1574f
jmp 0x1574f
jmp 0x1574f
jmp 0x1574f
jmp 0x1574f
jmp 0x1574f
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x15769
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x7200
movq %rbx, %rdi
callq 0x7360
nop