// File: /workspace/github_cpp_makefile_star2_O3/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 0x13a6e
movq %rcx, %rbx
movq %rdx, %r12
movq %rdi, %r15
movb 0x58(%rdi), %bpl
leaq 0xdba3(%rip), %rcx      # 0x210f0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb %bpl, 0x8(%rsp)
movq (%r15), %r13
testq %r13, %r13
je 0x13a8d
movq 0x8(%rbx), %rbp
subq (%rbx), %rbp
leaq 0x158(%rsp), %r14
movq %r14, %rdi
callq 0x14c48
movq %r13, %rdi
movq %r14, %rsi
movq %r12, 0x30(%rsp)
movq %r12, %rdx
movq %rbx, %rcx
callq 0x13c25
leaq 0x180(%rsp), %r12
movq %r12, %rdi
callq 0xb254
movq -0x10(%r12), %rdi
testq %rdi, %rdi
je 0x135b3
callq 0x1563c
movq 0x160(%rsp), %rdi
testq %rdi, %rdi
je 0x135c5
callq 0x1563c
cmpb $0x0, 0x8(%rsp)
je 0x13a0d
sarq $0x5, %rbp
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
movq 0x8(%rbx), %rsi
subq (%rbx), %rsi
imulq %rax, %rbp
sarq $0x5, %rsi
imulq %rax, %rsi
cmpq %rbp, %rsi
jb 0x13b09
jbe 0x13a0d
movq (%r15), %rax
movq %rax, 0x28(%rsp)
leaq 0x10(%rsp), %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
subq %rbp, %rsi
movq %r14, %rdi
callq 0x15434
movq (%rbx), %rsi
movq 0x8(%rbx), %r15
subq %rsi, %r15
sarq $0x5, %r15
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %r15
cmpq %r15, %rbp
leaq 0x38(%rsp), %r14
jae 0x136c2
movq %rbp, %rax
shlq $0x5, %rax
leaq (%rax,%rax,2), %r12
addq %r12, %rsi
movq %r14, %rdi
callq 0x15a4c
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x14d20
leaq 0x60(%rsp), %rdi
callq 0xb254
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x1368b
callq 0x1563c
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x1369a
callq 0x1563c
incq %rbp
movq (%rbx), %rsi
movq 0x8(%rbx), %r15
subq %rsi, %r15
sarq $0x5, %r15
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %r15
addq $0x60, %r12
cmpq %r15, %rbp
jb 0x1365a
movq 0x10(%rsp), %rbp
movq 0x18(%rsp), %rax
movq %rax, (%rsp)
cmpq %rax, %rbp
je 0x137de
movq %rbp, %rdi
callq 0x154e4
movq %rax, %r13
movq 0x8(%rbx), %r12
subq (%rbx), %r12
movq %r14, %rdi
movq %rbp, %rsi
callq 0x14c48
movq 0x28(%rsp), %rdi
movq %r14, %rsi
movq 0x30(%rsp), %rdx
movq %rbx, %rcx
callq 0x13c25
leaq 0x60(%rsp), %rdi
callq 0xb254
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x13724
callq 0x1563c
movq %rbp, 0x8(%rsp)
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x13738
callq 0x1563c
sarq $0x5, %r12
movq 0x8(%rbx), %rsi
subq (%rbx), %rsi
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %r12
sarq $0x5, %rsi
imulq %rax, %rsi
cmpq %r12, %rsi
jb 0x13a4f
jbe 0x137c6
leaq (%rsi,%rsi,2), %r14
shlq $0x5, %r14
addq $-0x60, %r14
leaq -0x1(%rsi), %rbp
movq (%rbx), %rdi
movq 0x8(%rbx), %rdx
subq %rdi, %rdx
sarq $0x5, %rdx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rdx
cmpq %rbp, %rdx
jbe 0x13a3e
addq %r14, %rdi
callq 0x154e4
cmpq %r13, %rax
jb 0x13a1f
jne 0x137ba
movq (%rbx), %rsi
addq %r14, %rsi
movq %rbx, %rdi
callq 0x15556
addq $-0x60, %r14
movq %rbp, %rsi
cmpq %r12, %rbp
ja 0x13770
movq 0x8(%rsp), %rbp
addq $0x60, %rbp
cmpq (%rsp), %rbp
leaq 0x38(%rsp), %r14
jne 0x136d9
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x14c18
movq 0x8(%rbx), %rsi
subq (%rbx), %rsi
sarq $0x5, %rsi
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rsi
movq %r15, %rbp
cmpq %rsi, %r15
jb 0x1360d
jmp 0x13a0d
cmpq $0x0, 0x20(%r15)
je 0x13aac
leaq 0x38(%rsp), %r13
movq %r13, %rdi
movq %rsi, (%rsp)
callq 0x15a4c
movq %rbx, %rdi
movq %r13, %rsi
callq 0x14d20
leaq 0x60(%rsp), %r13
movq %r13, %rdi
callq 0xb254
movq -0x10(%r13), %rdi
testq %rdi, %rdi
je 0x13857
callq 0x1563c
movb %bpl, 0x8(%rsp)
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x1386b
callq 0x1563c
movq 0x8(%rbx), %r14
subq (%rbx), %r14
movq 0x20(%r15), %r13
leaq 0x98(%rsp), %rbp
movq %rbp, %rdi
movq (%rsp), %rsi
callq 0x14c48
movq %r13, %rdi
movq %rbp, %rsi
movq %r12, %r13
movq %r12, %rdx
movq %rbx, %rcx
callq 0x13091
leaq 0xc0(%rsp), %r12
movq %r12, %rdi
callq 0xb254
movq -0x10(%r12), %rdi
testq %rdi, %rdi
movb 0x8(%rsp), %bpl
je 0x138c2
callq 0x1563c
movq 0xa0(%rsp), %rdi
jmp 0x139dd
movq %rsi, (%rsp)
cmpb $0x0, 0x60(%r15)
je 0x13acb
movq 0x8(%r12), %rax
movq (%rax), %rdi
movq 0x8(%rax), %rsi
movq (%rsp), %rdx
movq %r12, %rcx
callq 0x142bc
testb %al, %al
jne 0x13957
testb $0x1, 0x2(%r12)
je 0x13957
movq 0x8(%r12), %rax
movq (%rax), %r15
movq 0x8(%rax), %r13
cmpq %r13, %r15
je 0x13957
movq (%rsp), %rax
leaq 0x28(%rax), %r14
leaq 0x48(%r15), %rbp
movl $0x80, %r12d
xorl %eax, %eax
leaq -0x18(%rax), %rsi
cmpq $-0x60, %rsi
je 0x13941
cmpq $0x0, 0x38(%r15,%rax)
movq %rsi, %rax
je 0x13927
addq %rbp, %rsi
jmp 0x13944
movq %r15, %rsi
movq %r14, %rdi
callq 0xcc78
addq %r12, %r15
addq %r12, %rbp
cmpq %r13, %r15
jne 0x13925
movq %rbx, %rdi
movq (%rsp), %rsi
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x14d20
movb %bpl, 0x8(%rsp)
movq 0x20(%r15), %r13
testq %r13, %r13
je 0x13aea
movq 0x8(%rbx), %r14
subq (%rbx), %r14
leaq 0xf8(%rsp), %rbp
movq %rbp, %rdi
callq 0x14c48
movq %r13, %rdi
movq %rbp, %rsi
movq %r12, %r13
movq %r12, %rdx
movq %rbx, %rcx
callq 0x13091
leaq 0x120(%rsp), %r12
movq %r12, %rdi
callq 0xb254
movq -0x10(%r12), %rdi
testq %rdi, %rdi
movb 0x8(%rsp), %bpl
je 0x139d5
callq 0x1563c
movq 0x100(%rsp), %rdi
testq %rdi, %rdi
je 0x139e7
callq 0x1563c
testb %bpl, %bpl
je 0x13a0d
sarq $0x5, %r14
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
imulq %r14, %rsi
movq 0x20(%r15), %rdi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x13fc9
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xdb8e(%rip), %rdi      # 0x215b4
leaq 0xd712(%rip), %rsi      # 0x2113f
leaq 0xdae9(%rip), %rcx      # 0x2151d
movl $0x148, %edx            # imm = 0x148
callq 0x6120
decq %rsi
leaq 0xd386(%rip), %rdi      # 0x20dce
xorl %eax, %eax
callq 0x6300
leaq 0xdab6(%rip), %rdi      # 0x2150c
leaq 0xd6e2(%rip), %rsi      # 0x2113f
leaq 0xdab9(%rip), %rcx      # 0x2151d
movl $0x145, %edx            # imm = 0x145
callq 0x6120
leaq 0xd8b1(%rip), %rdi      # 0x21326
leaq 0xd6c3(%rip), %rsi      # 0x2113f
leaq 0xd7f2(%rip), %rcx      # 0x21275
movl $0x1fb, %edx            # imm = 0x1FB
callq 0x6120
leaq 0xd7bd(%rip), %rdi      # 0x21251
leaq 0xd6a4(%rip), %rsi      # 0x2113f
leaq 0xd7d3(%rip), %rcx      # 0x21275
movl $0x1c6, %edx            # imm = 0x1C6
callq 0x6120
leaq 0xd82e(%rip), %rdi      # 0x212e1
leaq 0xd685(%rip), %rsi      # 0x2113f
leaq 0xd7b4(%rip), %rcx      # 0x21275
movl $0x1e1, %edx            # imm = 0x1E1
callq 0x6120
leaq 0xd836(%rip), %rdi      # 0x21308
leaq 0xd666(%rip), %rsi      # 0x2113f
leaq 0xd795(%rip), %rcx      # 0x21275
movl $0x1ed, %edx            # imm = 0x1ED
callq 0x6120
leaq 0xd7f0(%rip), %rdi      # 0x212e1
leaq 0xd647(%rip), %rsi      # 0x2113f
leaq 0xd776(%rip), %rcx      # 0x21275
movl $0x1d5, %edx            # imm = 0x1D5
callq 0x6120
leaq 0xd93c(%rip), %rdi      # 0x2144c
leaq 0xd628(%rip), %rsi      # 0x2113f
leaq 0xd961(%rip), %rcx      # 0x2147f
movl $0x1a7, %edx            # imm = 0x1A7
callq 0x6120
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
jmp 0x13b57
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
jmp 0x13b57
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
jmp 0x13b57
movq %rax, %rbx
leaq 0x158(%rsp), %rdi
callq 0x1475a
jmp 0x13b84
jmp 0x13b77
jmp 0x13b66
jmp 0x13b77
jmp 0x13b77
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x1475a
jmp 0x13b7a
jmp 0x13b77
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x14c18
movq %rbx, %rdi
callq 0x6360