// File: ridiculousfish[P]docopt_fish/docopt_matching.cpp
// Function: docopt_fish::match(docopt_fish::expression_list_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_list_t &node, match_state_t state, const match_context_t &ctx,
                  match_state_list_t *resulting_states) {
    size_t count = node.expressions.size();
    if (count == 0) {
        // Empty expression list, append the state
        resulting_states->push_back(state.move());
    } else if (count == 1) {
        // Common case of just one expression, trivial
        match(node.expressions.at(0), state.move(), ctx, resulting_states);
    } else {
        // First expression
        match_state_list_t intermed_state_list;
        match(node.expressions.at(0), state.move(), ctx, &intermed_state_list);
        // Middle expressions
        for (size_t i = 1; i + 1 < count; i++) {
            match_state_list_t new_states;
            match_list(node.expressions.at(i), std::move(intermed_state_list), ctx, &new_states);
            intermed_state_list = std::move(new_states);
        }
        // Last expression
        match_list(node.expressions.at(count - 1), std::move(intermed_state_list), ctx, resulting_states);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rsi, -0x138(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rdi
callq 0x29fd0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x303b1
movq -0x138(%rbp), %rdi
movq -0x20(%rbp), %rax
movq %rax, -0x140(%rbp)
callq 0x32ae0
movq -0x140(%rbp), %rdi
movq %rax, %rsi
callq 0x32d70
jmp 0x3060c
cmpq $0x1, -0x28(%rbp)
jne 0x30443
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x32da0
movq -0x138(%rbp), %rdi
movq %rax, -0x150(%rbp)
callq 0x32ae0
movq %rax, %rsi
leaq -0x88(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x32af0
movq -0x150(%rbp), %rdi
movq -0x148(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x30630
jmp 0x3040f
leaq -0x88(%rbp), %rdi
callq 0x321f0
jmp 0x3060a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x321f0
jmp 0x30615
leaq -0xb0(%rbp), %rdi
callq 0x32070
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x32da0
movq %rax, -0x158(%rbp)
jmp 0x30465
movq -0x138(%rbp), %rdi
callq 0x32ae0
movq %rax, -0x160(%rbp)
jmp 0x3047a
movq -0x160(%rbp), %rsi
leaq -0x110(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x32af0
movq -0x158(%rbp), %rdi
movq -0x168(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0xb0(%rbp), %rcx
callq 0x30630
jmp 0x304b4
leaq -0x110(%rbp), %rdi
callq 0x321f0
movq $0x1, -0x118(%rbp)
movq -0x118(%rbp), %rax
addq $0x1, %rax
cmpq -0x28(%rbp), %rax
jae 0x305b5
leaq -0x130(%rbp), %rdi
callq 0x32070
movq -0x8(%rbp), %rdi
movq -0x118(%rbp), %rsi
callq 0x32da0
movq %rax, -0x170(%rbp)
jmp 0x30505
movq -0x170(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq -0xb0(%rbp), %rsi
leaq -0x130(%rbp), %rcx
xorl %r8d, %r8d
callq 0x30b30
jmp 0x30528
leaq -0xb0(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x32de0
leaq -0x130(%rbp), %rdi
callq 0x32990
movq -0x118(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x118(%rbp)
jmp 0x304cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x305fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x321f0
jmp 0x305fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x32990
jmp 0x305fc
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
decq %rsi
callq 0x32da0
movq %rax, -0x178(%rbp)
jmp 0x305ce
movq -0x178(%rbp), %rdi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq -0xb0(%rbp), %rsi
xorl %r8d, %r8d
callq 0x30b30
jmp 0x305ee
leaq -0xb0(%rbp), %rdi
callq 0x32990
jmp 0x3060a
leaq -0xb0(%rbp), %rdi
callq 0x32990
jmp 0x30615
jmp 0x3060c
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
movq -0x90(%rbp), %rdi
callq 0x85d0
nopw %cs:(%rax,%rax)