// File: /workspace/github_cpp_makefile_star2_O3/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 %rcx, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq %rsi, 0x30(%rsp)
cmpq %rsi, %rdi
movq %rdx, (%rsp)
je 0x1451a
movq %rdi, %r15
leaq 0x10(%rdx), %r13
leaq 0x48(%rdi), %rax
movq %rax, 0x8(%rsp)
xorl %r12d, %r12d
movq 0x10(%r14), %rax
movq 0x20(%rax), %rcx
cmpq 0x18(%rax), %rcx
je 0x1439a
movl $0x90, %ebx
xorl %ebp, %ebp
movq (%r13), %rdi
movq %rbp, %rsi
callq 0x156ac
testb %al, %al
jne 0x1436d
movq 0x10(%r14), %rcx
movq 0x18(%rcx), %rax
movq 0x20(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x30c30c30c30c30c3, %rcx # imm = 0xCF3CF3CF3CF3CF3D
imulq %rcx, %rdx
cmpq %rbp, %rdx
jbe 0x145cc
leaq (%rax,%rbx), %rdi
addq $-0x90, %rdi
movq %r15, %rsi
callq 0xe544
testb %al, %al
jne 0x143cd
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, %rbx
cmpq %rcx, %rbp
jb 0x1431c
testb $0x1, 0x2(%r14)
je 0x14500
movq 0x18(%rsp), %rax
cmpq 0x20(%rsp), %rax
je 0x1441a
movl $0x10, %ecx
movq %rax, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
subq $-0x80, %rax
movq %rax, 0x18(%rsp)
jmp 0x14500
movq 0x10(%r14), %rax
movq 0x18(%rax), %rcx
movq 0x20(%rax), %rdx
movq %rcx, 0x28(%rsp)
subq %rcx, %rdx
sarq $0x3, %rdx
movabsq $-0x30c30c30c30c30c3, %rax # imm = 0xCF3CF3CF3CF3CF3D
imulq %rax, %rdx
cmpq %rbp, %rdx
jbe 0x145dd
xorl %eax, %eax
leaq -0x18(%rax), %r12
cmpq $-0x60, %r12
je 0x1442f
cmpq $0x0, 0x38(%r15,%rax)
movq %r12, %rax
je 0x143fe
addq 0x8(%rsp), %r12
jmp 0x14432
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0xf41e
jmp 0x14500
movq %r15, %r12
movq (%rsp), %rdi
callq 0x14ae8
movq %rax, %rdi
movq %r12, %rsi
callq 0x14f34
incl 0x18(%rax)
cmpq $0x0, 0x50(%r15)
je 0x144b6
movq 0x28(%rsp), %rax
cmpq $-0x1, -0x8(%rax,%rbx)
je 0x144b6
movq (%rsp), %rdi
callq 0x14ae8
leaq 0x48(%r15), %rsi
movq %rax, %rdi
callq 0x14f34
movq %rax, %r12
movq 0x28(%rsp), %rsi
addq %rbx, %rsi
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0xaf0c
movq %r12, %rdi
movq %rbx, %rsi
callq 0xcdb8
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x144b6
movq 0x48(%rsp), %rax
leaq 0x4(,%rax,4), %rsi
callq 0x6200
movq %r13, %rdi
callq 0x1570c
leaq 0x3f(%rbp), %rdx
testq %rbp, %rbp
cmovnsq %rbp, %rdx
sarq $0x6, %rdx
shlq $0x3, %rdx
addq (%rax), %rdx
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
leaq 0x3f(%rcx), %rax
andq %rbp, %rax
xorl %esi, %esi
cmpq %rcx, %rax
setbe %sil
movl $0x1, %eax
movl %ebp, %ecx
shlq %cl, %rax
orq %rax, -0x8(%rdx,%rsi,8)
movb $0x1, %r12b
movl $0x80, %eax
addq %rax, %r15
addq %rax, 0x8(%rsp)
cmpq 0x30(%rsp), %r15
jne 0x14303
jmp 0x1451d
xorl %r12d, %r12d
testb $0x1, 0x2(%r14)
je 0x14579
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq %rax, %r15
je 0x14579
movq (%rsp), %rax
leaq 0x28(%rax), %rbx
leaq 0x30(%r15), %r12
movl $0x80, %ebp
xorl %r13d, %r13d
cmpq $0x0, 0x38(%r15,%r13)
je 0x14560
leaq (%r12,%r13), %rsi
movq %rbx, %rdi
callq 0xcc78
addq $-0x18, %r13
cmpq $-0x48, %r13
jne 0x1454c
addq %rbp, %r15
addq %rbp, %r12
cmpq 0x8(%rsp), %r15
jne 0x14549
jmp 0x1457f
testb $0x1, %r12b
je 0x145a2
movb $0x1, %bl
testb $0x2, 0x2(%r14)
je 0x145a4
movq %r14, %rdi
movq (%rsp), %r14
movq %r14, %rsi
callq 0x1526c
testb %al, %al
je 0x145a4
movb $0x1, 0x58(%r14)
jmp 0x145a4
xorl %ebx, %ebx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x145bb
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6200
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc7fb(%rip), %rdi      # 0x20dce
movq %rbp, %rsi
xorl %eax, %eax
callq 0x6300
leaq 0xc7ea(%rip), %rdi      # 0x20dce
movq %rbp, %rsi
xorl %eax, %eax
callq 0x6300
jmp 0x14626
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x14629
movq 0x48(%rsp), %rax
leaq 0x4(,%rax,4), %rsi
callq 0x6200
jmp 0x14629
jmp 0x14626
jmp 0x14626
jmp 0x14626
jmp 0x14626
jmp 0x14626
jmp 0x14626
jmp 0x14626
jmp 0x14626
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x14640
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6200
movq %rbx, %rdi
callq 0x6360