// File: ridiculousfish[P]docopt_fish/docopt_fish.cpp
// Function: docopt_fish::parse_variable_name(docopt_fish::rstring_t*, std::vector<docopt_fish::error_t, std::allocator<docopt_fish::error_t>>*)
static rstring_t parse_variable_name(rstring_t *inout_spec, error_list_t *out_errors) {
    assert(! inout_spec->empty());
    assert(inout_spec->front() == '<');
    rstring_t result;
    rstring_t remaining = *inout_spec;
    
    rstring_t open_bracket, name, close_bracket;
    std::tie(open_bracket, name, close_bracket) =
        remaining.scan_multiple<it_equals<'<'>, char_is_valid_in_variable_name, it_equals<'>'>>();
    assert(! open_bracket.empty());
    
    if (close_bracket.empty()) {
        // Invalid variable name, or missing > outright
        if (remaining.empty()) {
            // like '<foo'
            append_token_error(out_errors, open_bracket, error_missing_close_variable,
                               "No > to balance this <");
        } else {
            // like '<foo<'
            append_token_error(out_errors, remaining, error_invalid_variable_name,
                               "Character not allowed in variable name");
        }
    } else if (name.empty()) {
        append_token_error(out_errors, close_bracket, error_invalid_variable_name,
                           "Missing variable name");
    } else if (! remaining.empty() && char_is_valid_in_option_name(remaining.front())) {
        // Some extra stuff after the closing >
        append_token_error(out_errors, remaining, error_invalid_variable_name,
                           "Extra stuff after closing '>'");
    } else {
        result = open_bracket.merge(name).merge(close_bracket);
        *inout_spec = remaining;
    }
    return result;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x110(%rbp)
movq %rdi, -0x108(%rbp)
movq %rsi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0xbe30
xorb $-0x1, %al
testb $0x1, %al
jne 0x8f02
jmp 0x8f04
jmp 0x8f23
leaq 0x425e2(%rip), %rdi     # 0x4b4ed
leaq 0x42176(%rip), %rsi     # 0x4b088
movl $0x54, %edx
leaq 0x425e5(%rip), %rcx     # 0x4b503
callq 0x81e0
movq -0x8(%rbp), %rdi
callq 0xfa90
cmpl $0x3c, %eax
jne 0x8f33
jmp 0x8f52
leaq 0x42611(%rip), %rdi     # 0x4b54b
leaq 0x42147(%rip), %rsi     # 0x4b088
movl $0x55, %edx
leaq 0x425b6(%rip), %rcx     # 0x4b503
callq 0x81e0
movq -0x110(%rbp), %rdi
callq 0xbe70
movq -0x8(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x28(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x20(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xbe70
leaq -0x58(%rbp), %rdi
callq 0xbe70
leaq -0x70(%rbp), %rdi
callq 0xbe70
leaq -0xb8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0xac60
leaq -0xd0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x58(%rbp), %rdx
leaq -0x70(%rbp), %rcx
callq 0xfaf0
leaq -0xd0(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0xfb30
leaq -0x40(%rbp), %rdi
callq 0xbe30
xorb $-0x1, %al
testb $0x1, %al
jne 0x8fe0
jmp 0x8fe2
jmp 0x9001
leaq 0x4257d(%rip), %rdi     # 0x4b566
leaq 0x42098(%rip), %rsi     # 0x4b088
movl $0x5c, %edx
leaq 0x42507(%rip), %rcx     # 0x4b503
callq 0x81e0
leaq -0x70(%rbp), %rdi
callq 0xbe30
testb $0x1, %al
jne 0x9010
jmp 0x9058
leaq -0x28(%rbp), %rdi
callq 0xbe30
testb $0x1, %al
jne 0x901f
jmp 0x903a
movq -0x10(%rbp), %rdi
leaq -0x40(%rbp), %rsi
movl $0xb, %edx
leaq 0x4254a(%rip), %rcx     # 0x4b57d
callq 0x8e80
jmp 0x9053
movq -0x10(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0x6, %edx
leaq 0x42546(%rip), %rcx     # 0x4b594
callq 0x8e80
jmp 0x9134
leaq -0x58(%rbp), %rdi
callq 0xbe30
testb $0x1, %al
jne 0x9067
jmp 0x9085
movq -0x10(%rbp), %rdi
leaq -0x70(%rbp), %rsi
movl $0x6, %edx
leaq 0x42540(%rip), %rcx     # 0x4b5bb
callq 0x8e80
jmp 0x9132
leaq -0x28(%rbp), %rdi
callq 0xbe30
testb $0x1, %al
jne 0x90c3
leaq -0x28(%rbp), %rdi
callq 0xfa90
movl %eax, %edi
callq 0xac90
testb $0x1, %al
jne 0x90a8
jmp 0x90c3
movq -0x10(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movl $0x6, %edx
leaq 0x42515(%rip), %rcx     # 0x4b5d1
callq 0x8e80
jmp 0x9130
leaq -0x100(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0xc010
leaq -0xe8(%rbp), %rdi
leaq -0x100(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0xc010
movq -0x110(%rbp), %rax
movq -0xe8(%rbp), %rcx
movq %rcx, (%rax)
movq -0xe0(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0xd8(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rcx
movq %rcx, 0x10(%rax)
jmp 0x9132
jmp 0x9134
movq -0x108(%rbp), %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopw %cs:(%rax,%rax)