// File: /workspace/github_cpp_makefile_star2_O2/ridiculousfish[P]docopt_fish/docopt_matching.cpp
// Function: docopt_fish::match(docopt_fish::expression_t const&, docopt_fish::match_state_t, docopt_fish::match_context_t const&, std::vector<docopt_fish::match_state_t, std::allocator<docopt_fish::match_state_t>>*)
static void match(const expression_t &node, match_state_t state, const match_context_t &ctx,
                  match_state_list_t *resulting_states) {
    // Check to see if we have ellipsis. If so, we keep going as long as we can.
    bool has_ellipsis = node.opt_ellipsis.present;

    switch (node.production) {
        case 0: {
            // This is a simple clause which may have ellipsis, like foo...
            // If we have ellipsis, we match one time, and then construct a sequence of
            // 'intermediate state lists'.
            //  An intermediate state represents the result of matching N times. Each time
            //  we construct a new intermediate state, we append (copy) all of its states into the
            //  result; thus we may match one time, two times, three times...
            //  We stop when we get no more matches, which usually happens when we run out
            //  of positionals.
            assert(node.simple_clause.get() != nullptr);
            size_t prior_state_count = resulting_states->size();
            match(*node.simple_clause, state.move(), ctx, resulting_states);
            // Now we know that all states starting at state_count_before are newly added.
            // If we have ellipsis, go until we stop getting new states.
            if (has_ellipsis) {
                repeat_matching(*node.simple_clause, prior_state_count, ctx, resulting_states);
            }
            break;
        }

        case 1: {
            // This is a parenthesized clause which may have ellipsis, like (foo)...
            // Same algorithm as the simple clause above.
            size_t prior_state_count = resulting_states->size();
            assert(node.alternation_list.get() != nullptr);
            match(*node.alternation_list, state.move(), ctx, resulting_states);
            if (has_ellipsis) {
                repeat_matching(*node.alternation_list, prior_state_count, ctx, resulting_states);
            }
            break;
        }

        case 2: {
            // This is a square-bracketed clause which may have ellipsis, like [foo]...
            // Same algorithm as the simple clause above, except that we also append the
            // initial state as a not-taken branch.
            assert(node.alternation_list.get() != nullptr);
            resulting_states->push_back(state.copy());  // append the not-taken-branch
            size_t prior_state_count = resulting_states->size();
            match(*node.alternation_list, std::move(state), ctx, resulting_states);
            if (has_ellipsis) {
                repeat_matching(*node.alternation_list, prior_state_count, ctx, resulting_states);
            }
            break;
        }

        case 3: {
            // This is the [options] clause. It does not have ellipsis.
            assert(node.options_shortcut.present);
            if (!match_options(ctx.shortcut_options, &state, ctx)) {
                // No match, but matches are not required
                if (ctx.flags & flag_generate_suggestions) {
                    for (const option_t &opt : ctx.shortcut_options) {
                        state.suggested_next_arguments.insert(opt.best_name());
                    }
                }
            }
            resulting_states->push_back(state.move());
            break;
        }

        default:
            assert(0 && "unknown production");
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movzbl 0x61(%rdi), %eax
cmpq $0x3, %rax
ja 0x12761
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
movb 0x58(%rdi), %dl
leaq 0xadc0(%rip), %rcx      # 0x1d16c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
pushq $0x60
popq %rbp
jmpq *%rax
movb %dl, 0x8(%rsp)
movq %r14, (%rsp)
movq (%r15), %r13
testq %r13, %r13
je 0x12780
movq 0x8(%rbx), %r14
subq (%rbx), %r14
movq %r14, %rax
cqto
idivq %rbp
movq %rax, %rbp
leaq 0x98(%rsp), %rdi
movq %r12, %rsi
callq 0x1341a
movq %r13, %rdi
leaq 0x98(%rsp), %rsi
movq (%rsp), %rdx
movq %rbx, %rcx
callq 0x128f3
leaq 0x98(%rsp), %rdi
callq 0x130ce
cmpb $0x0, 0x8(%rsp)
je 0x126df
movq (%rbx), %rcx
movq 0x8(%rbx), %rax
movq %rax, %rdx
subq %rcx, %rdx
cmpq %r14, %rdx
jb 0x127fc
movq (%r15), %rdx
movq %rdx, 0x30(%rsp)
subq %rcx, %rax
cqto
pushq $0x60
popq %rcx
idivq %rcx
subq %rbp, %rax
jbe 0x126df
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x13dac
movq 0x8(%rbx), %rax
subq (%rbx), %rax
cqto
pushq $0x60
popq %rcx
idivq %rcx
cmpq %rax, %rbp
jae 0x124b3
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x13e4e
leaq 0x38(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x14754
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x13574
movq %r14, %rdi
callq 0x130ce
incq %rbp
jmp 0x1246a
movq %rax, 0x28(%rsp)
movq 0x10(%rsp), %rbp
movq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq 0x8(%rsp), %rbp
je 0x1257b
movq %rbp, %rdi
callq 0x13e94
movq %rax, %r14
movq 0x8(%rbx), %rax
subq (%rbx), %rax
cqto
pushq $0x60
popq %r12
idivq %r12
movq %rax, %r15
leaq 0x38(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0x1341a
movq 0x30(%rsp), %rdi
movq %r13, %rsi
movq (%rsp), %rdx
movq %rbx, %rcx
callq 0x128f3
movq %r13, %rdi
callq 0x130ce
movq 0x8(%rbx), %rax
subq (%rbx), %rax
cqto
idivq %r12
cmpq %r15, %rax
jb 0x12742
movq %rax, %r13
imulq $0x60, %rax, %r12
addq $-0x60, %r12
cmpq %r15, %r13
jbe 0x12572
decq %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x13e4e
movq %rax, %rdi
callq 0x13e94
cmpq %r14, %rax
jb 0x12723
jne 0x12538
movq (%rbx), %rsi
addq %r12, %rsi
movq %rbx, %rdi
callq 0x13ec8
jmp 0x12538
addq $0x60, %rbp
jmp 0x124c7
leaq 0x10(%rsp), %rdi
callq 0x133da
movq (%rbx), %rcx
movq 0x8(%rbx), %rax
movq 0x28(%rsp), %rbp
jmp 0x1243b
cmpq $0x0, 0x20(%r15)
je 0x1279f
movb %dl, 0x8(%rsp)
movq %r14, (%rsp)
leaq 0x38(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x14754
movq %rbx, %rdi
movq %r14, %rsi
callq 0x13574
leaq 0x38(%rsp), %rdi
callq 0x130ce
movq 0x8(%rbx), %rax
subq (%rbx), %rax
cqto
idivq %rbp
movq %rax, %r14
movq 0x20(%r15), %r13
leaq 0xf8(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x1341a
movq %r13, %rdi
movq %rbp, %rsi
movq (%rsp), %rdx
movq %rbx, %rcx
callq 0x120d2
leaq 0xf8(%rsp), %rdi
callq 0x130ce
cmpb $0x0, 0x8(%rsp)
je 0x126df
movq 0x20(%r15), %rdi
movq %r14, %rsi
movq (%rsp), %rdx
jmp 0x126d7
cmpb $0x0, 0x60(%r15)
je 0x127be
movq 0x8(%r14), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x12dc7
testb %al, %al
jne 0x12657
testb $0x1, 0x2(%r14)
jne 0x126f1
movq %rbx, %rdi
movq %r12, %rsi
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x13574
movb %dl, 0x8(%rsp)
movq 0x8(%rbx), %rax
subq (%rbx), %rax
cqto
idivq %rbp
movq %rax, (%rsp)
movq 0x20(%r15), %r13
testq %r13, %r13
je 0x127dd
leaq 0x158(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
callq 0x1341a
movq %r13, %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x120d2
leaq 0x158(%rsp), %rdi
callq 0x130ce
cmpb $0x0, 0x8(%rsp)
je 0x126df
movq 0x20(%r15), %rdi
movq (%rsp), %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x12b9c
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%r14), %rax
movq (%rax), %r14
movq 0x8(%rax), %r13
leaq 0x28(%r12), %r15
cmpq %r13, %r14
je 0x12657
movq %r14, %rdi
callq 0xdffe
movq %r15, %rdi
movq %rax, %rsi
callq 0xc73c
subq $-0x80, %r14
jmp 0x12701
leaq 0xaf06(%rip), %rdi      # 0x1d630
leaq 0xaa8a(%rip), %rsi      # 0x1d1bb
leaq 0xae61(%rip), %rcx      # 0x1d599
movl $0x148, %edx            # imm = 0x148
callq 0x7150
leaq 0xae3f(%rip), %rdi      # 0x1d588
leaq 0xaa6b(%rip), %rsi      # 0x1d1bb
leaq 0xae42(%rip), %rcx      # 0x1d599
movl $0x145, %edx            # imm = 0x145
callq 0x7150
leaq 0xac3a(%rip), %rdi      # 0x1d3a2
leaq 0xaa4c(%rip), %rsi      # 0x1d1bb
leaq 0xab7b(%rip), %rcx      # 0x1d2f1
movl $0x1fb, %edx            # imm = 0x1FB
callq 0x7150
leaq 0xab46(%rip), %rdi      # 0x1d2cd
leaq 0xaa2d(%rip), %rsi      # 0x1d1bb
leaq 0xab5c(%rip), %rcx      # 0x1d2f1
movl $0x1c6, %edx            # imm = 0x1C6
callq 0x7150
leaq 0xabb7(%rip), %rdi      # 0x1d35d
leaq 0xaa0e(%rip), %rsi      # 0x1d1bb
leaq 0xab3d(%rip), %rcx      # 0x1d2f1
movl $0x1e1, %edx            # imm = 0x1E1
callq 0x7150
leaq 0xabbf(%rip), %rdi      # 0x1d384
leaq 0xa9ef(%rip), %rsi      # 0x1d1bb
leaq 0xab1e(%rip), %rcx      # 0x1d2f1
movl $0x1ed, %edx            # imm = 0x1ED
callq 0x7150
leaq 0xab79(%rip), %rdi      # 0x1d35d
leaq 0xa9d0(%rip), %rsi      # 0x1d1bb
leaq 0xaaff(%rip), %rcx      # 0x1d2f1
movl $0x1d5, %edx            # imm = 0x1D5
callq 0x7150
leaq 0xacc5(%rip), %rdi      # 0x1d4c8
leaq 0xa9b1(%rip), %rsi      # 0x1d1bb
leaq 0xacea(%rip), %rcx      # 0x1d4fb
movl $0x1a7, %edx            # imm = 0x1A7
callq 0x7150
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
jmp 0x1284a
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
jmp 0x1284a
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
jmp 0x1284a
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x130ce
jmp 0x12875
jmp 0x12868
jmp 0x12868
jmp 0x12857
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x130ce
jmp 0x1286b
jmp 0x12868
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x133da
movq %rbx, %rdi
callq 0x7390