// File: ridiculousfish[P]docopt_fish/docopt_matching.cpp
// Function: void docopt_fish::match_list<docopt_fish::expression_t>(docopt_fish::expression_t const&, std::vector<docopt_fish::match_state_t, std::allocator<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>>*, bool)
static void match_list(const T &node, match_state_list_t &&incoming_state_list, const match_context_t &ctx,
                       match_state_list_t *resulting_states, bool require_progress = false) {
    for (match_state_t &state : incoming_state_list) {
        // If we require that this makes progress, then get the current progress so
        // we can compare
        size_t init_progress = npos;
        size_t init_size = -1;
        if (require_progress) {
            init_progress = state.progress();
            init_size = resulting_states->size();
        }

        match(node, state.move(), ctx, resulting_states);

        if (require_progress) {
            // Keep only those results that have increased in progress. States after
            // init_size are new.
            size_t idx = resulting_states->size();
            assert(idx >= init_size);
            while (idx-- > init_size) {  // last processed idx will be init_size
                size_t new_progress = resulting_states->at(idx).progress();
                assert(new_progress >= init_progress);  // should never go backwards
                if (new_progress == init_progress) {
                    // No progress was made, toss this state
                    resulting_states->erase(resulting_states->begin() + idx);
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movb %r8b, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
andb $0x1, %al
movb %al, -0x21(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x32320
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0x32350
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x32380
testb $0x1, %al
jne 0x30b8b
jmp 0x30d7a
leaq -0x38(%rbp), %rdi
callq 0x323c0
movq %rax, -0x48(%rbp)
movq $-0x1, -0x50(%rbp)
movq $-0x1, -0x58(%rbp)
testb $0x1, -0x21(%rbp)
je 0x30bc8
movq -0x48(%rbp), %rdi
callq 0x353e0
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rdi
callq 0x33300
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x48(%rbp), %rdi
callq 0x32ae0
movq %rax, %rsi
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x32af0
movq -0x108(%rbp), %rdi
movq -0x100(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x30630
jmp 0x30c0f
leaq -0xb8(%rbp), %rdi
callq 0x321f0
testb $0x1, -0x21(%rbp)
je 0x30d6a
movq -0x20(%rbp), %rdi
callq 0x33300
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
cmpq -0x58(%rbp), %rax
jb 0x30c44
jmp 0x30c86
leaq 0x1b9b5(%rip), %rdi     # 0x4c600
leaq 0x1b5e1(%rip), %rsi     # 0x4c233
movl $0x145, %edx            # imm = 0x145
leaq 0x1bc1a(%rip), %rcx     # 0x4c878
callq 0x81e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x321f0
jmp 0x30d83
jmp 0x30c88
movq -0xd0(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0xd0(%rbp)
cmpq -0x58(%rbp), %rax
jbe 0x30d68
movq -0x20(%rbp), %rdi
movq -0xd0(%rbp), %rsi
callq 0x352f0
movq %rax, %rdi
callq 0x353e0
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rax
cmpq -0x50(%rbp), %rax
jb 0x30cd5
jmp 0x30cf4
leaq 0x1b9cc(%rip), %rdi     # 0x4c6a8
leaq 0x1b550(%rip), %rsi     # 0x4c233
movl $0x148, %edx            # imm = 0x148
leaq 0x1bb89(%rip), %rcx     # 0x4c878
callq 0x81e0
movq -0xd8(%rbp), %rax
cmpq -0x50(%rbp), %rax
jne 0x30d63
movq -0x20(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x20(%rbp), %rdi
callq 0x32320
movq %rax, -0xf0(%rbp)
movq -0xd0(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x35500
movq %rax, -0xe8(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x35540
movq -0x110(%rbp), %rdi
movq -0xe0(%rbp), %rsi
callq 0x35490
movq %rax, -0xf8(%rbp)
jmp 0x30c88
jmp 0x30d6a
jmp 0x30d6c
leaq -0x38(%rbp), %rdi
callq 0x32970
jmp 0x30b75
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0xc0(%rbp), %rdi
callq 0x85d0
nop