// File: /workspace/github_cpp_makefile_star2_O2/vsklad[P]cgen/commandline.cpp
// Function: CGenCommandLineReader::parse_variable(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, CGenVariableInfo, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, CGenVariableInfo>>>&, CGenCommand)
std::string CGenCommandLineReader::parse_variable(CGenVariablesMap& variables_map, const CGenCommand command) {
    std::string variable_name;
    bal::variableid_t variable_id = bal::VARIABLEID_UNASSIGNED;
    
    if (is_token(TextReader::ttDec)) {
        // binary variable
        variable_id = bal::variable_t__from_uint(read_uint32(bal::VARIABLEID_MIN + 1, bal::VARIABLEID_MAX + 1));
        variable_name = std::to_string(variable_id + 1);
    } else if (is_token(TextReader::ttLiteral)) {
        // named variable
        variable_name = read_literal();
    } else {
        parse_error(ERROR_INVALID_VARIABLE_NAME);
    };
    
    if (is_symbol('=')) { // value immediately after =
        read_symbol('=');
    } else if (is_eol()) { // value as a next argument
        read_eol();
    } else {
        parse_error(ERROR_MISSING_VARIABLE_VALUE);
    };
    
    CGenVariableInfo variable_value;
    
    if (is_token("random")) {
        skip_token();
        variable_value.mode = vmRandom;
    } else if (is_token("compute")) {
        skip_token();
        variable_value.mode = vmCompute;
    } else if (variable_id == bal::VARIABLEID_UNASSIGNED && is_token("string")) {
        skip_token();
        variable_value.mode = vmValue;
        read_symbol(':');
        // take the rest of the argument as a value
        // needed because the shell removes quotes from arguments
        variable_value.data = read_until_eol().c_str();
    } else {
        variable_value.mode = vmValue;
        variable_value.data = read_variable_value();
        
        if (variable_id != bal::VARIABLEID_UNASSIGNED && variable_value.data.size() != 1) {
            // binary variable requires binary value
            parse_error(ERROR_INVALID_BINARY_VALUE);
        };
    };
    
    auto r = variables_map.insert({variable_name, variable_value});
    if (!r.second) {
        parse_error(ERROR_DUPLICATED_VARIABLE_NAME);
    };
    
    return variable_name;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, (%rdi)
andq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
movq (%rsi), %rax
movq -0x18(%rax), %rdi
addq %rsi, %rdi
pushq $0x1
popq %rsi
callq 0x18644
movq (%r14), %rcx
movq -0x18(%rcx), %rdi
addq %r14, %rdi
testb %al, %al
je 0x166e2
pushq $0x1
popq %rsi
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
callq 0x1866c
testl %eax, %eax
setle %r15b
movl $0x80000000, %esi       # imm = 0x80000000
cmovgl %eax, %esi
leaq -0x90(%rbp), %rdi
callq 0x188f9
leaq -0x90(%rbp), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0xc320
movq %r12, %rdi
callq 0xc110
jmp 0x1675d
pushq $0x5
popq %rsi
callq 0x18644
testb %al, %al
je 0x1671b
movq (%r14), %rax
movq -0x18(%rax), %rsi
addq %r14, %rsi
leaq -0x90(%rbp), %rdi
callq 0x18938
leaq -0x90(%rbp), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0xc320
movq %r12, %rdi
jmp 0x16755
movq (%r14), %rax
movq -0x18(%rax), %r12
leaq 0x20d19(%rip), %rsi     # 0x37442
leaq -0x150(%rbp), %rdi
leaq -0x90(%rbp), %rdx
callq 0xc0e0
addq %r14, %r12
leaq -0x150(%rbp), %rsi
movq %r12, %rdi
callq 0x189ce
leaq -0x150(%rbp), %rdi
callq 0xc110
movb $0x1, %r15b
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
pushq $0x3d
popq %rsi
callq 0x18a92
movq (%r14), %rcx
movq -0x18(%rcx), %rdi
addq %r14, %rdi
testb %al, %al
je 0x16787
pushq $0x3d
popq %rsi
callq 0x18ac2
jmp 0x167dc
callq 0x18bfe
movq (%r14), %rcx
movq -0x18(%rcx), %r12
testb %al, %al
je 0x167a4
addq %r14, %r12
movq %r12, %rdi
callq 0x18c3c
jmp 0x167dc
leaq 0x20cad(%rip), %rsi     # 0x37458
leaq -0x130(%rbp), %rdi
leaq -0x90(%rbp), %rdx
callq 0xc0e0
addq %r14, %r12
leaq -0x130(%rbp), %rsi
movq %r12, %rdi
callq 0x189ce
leaq -0x130(%rbp), %rdi
callq 0xc110
leaq -0xd0(%rbp), %rdi
callq 0x18cac
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
leaq 0x20c79(%rip), %rsi     # 0x37472
callq 0x18cd6
movq (%r14), %rcx
movq -0x18(%rcx), %rdi
addq %r14, %rdi
testb %al, %al
je 0x1682c
movq 0x10(%rdi), %rax
addq %rax, 0x8(%rdi)
andq $0x0, 0x10(%rdi)
andl $0x0, 0x40(%rdi)
movl $0x1, -0xd0(%rbp)
jmp 0x16986
leaq 0x20c46(%rip), %rsi     # 0x37479
callq 0x18cd6
testb %al, %al
je 0x16868
movq (%r14), %rax
movq -0x18(%rax), %rax
movq 0x10(%r14,%rax), %rcx
addq %rcx, 0x8(%r14,%rax)
andq $0x0, 0x10(%r14,%rax)
andl $0x0, 0x40(%r14,%rax)
movl $0x2, -0xd0(%rbp)
jmp 0x16986
testb %r15b, %r15b
je 0x168f3
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
leaq 0x20bff(%rip), %rsi     # 0x37481
callq 0x18cd6
testb %al, %al
je 0x168f3
movq (%r14), %rax
movq -0x18(%rax), %rcx
movq 0x10(%r14,%rcx), %rdx
addq %rdx, 0x8(%r14,%rcx)
andq $0x0, 0x10(%r14,%rcx)
andl $0x0, 0x40(%r14,%rcx)
andl $0x0, -0xd0(%rbp)
movq -0x18(%rax), %rdi
addq %r14, %rdi
pushq $0x3a
popq %rsi
callq 0x18ac2
movq (%r14), %rax
movq -0x18(%rax), %rsi
addq %r14, %rsi
leaq -0x90(%rbp), %rdi
callq 0x18d34
movq -0x90(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x18d74
leaq -0x90(%rbp), %rdi
jmp 0x16981
movq %r13, -0x30(%rbp)
andl $0x0, -0xd0(%rbp)
movq (%r14), %rax
movq -0x28(%rax), %rsi
addq %r14, %rsi
leaq -0x90(%rbp), %rdi
callq 0x302e4
leaq -0xb8(%rbp), %r12
leaq -0x90(%rbp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x18e2a
movq %r13, %rdi
callq 0xde58
cmpl $0x1, 0x8(%r12)
sete %al
orb %al, %r15b
movq -0x30(%rbp), %r13
jne 0x16986
movq (%r14), %rax
movq -0x18(%rax), %r12
leaq 0x20b33(%rip), %rsi     # 0x37488
leaq -0x110(%rbp), %rdi
leaq -0x90(%rbp), %rdx
callq 0xc0e0
addq %r14, %r12
leaq -0x110(%rbp), %rsi
movq %r12, %rdi
callq 0x189ce
leaq -0x110(%rbp), %rdi
callq 0xc110
leaq -0x90(%rbp), %rdi
leaq -0xd0(%rbp), %rdx
movq %rbx, %rsi
callq 0x18e4c
leaq -0x90(%rbp), %rsi
movq %r13, %rdi
callq 0x19938
movl %edx, %r15d
leaq -0x90(%rbp), %rdi
callq 0x18e82
testb $0x1, %r15b
jne 0x169ff
movq (%r14), %rax
movq -0x18(%rax), %r15
leaq 0x20ae9(%rip), %rsi     # 0x374b7
leaq -0xf0(%rbp), %rdi
leaq -0x90(%rbp), %rdx
callq 0xc0e0
addq %r15, %r14
leaq -0xf0(%rbp), %rsi
movq %r14, %rdi
callq 0x189ce
leaq -0xf0(%rbp), %rdi
callq 0xc110
leaq -0xb8(%rbp), %rdi
callq 0xde58
movq %rbx, %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq -0x90(%rbp), %rdi
jmp 0x16a6b
jmp 0x16a8b
movq %rax, %r14
leaq -0x110(%rbp), %rdi
jmp 0x16a6b
jmp 0x16a8b
jmp 0x16a8b
movq %rax, %r14
leaq -0x130(%rbp), %rdi
jmp 0x16a56
jmp 0x16a9c
movq %rax, %r14
leaq -0x150(%rbp), %rdi
callq 0xc110
jmp 0x16a9f
jmp 0x16a9c
jmp 0x16a9c
movq %rax, %r14
leaq -0xf0(%rbp), %rdi
callq 0xc110
jmp 0x16a8e
jmp 0x16a8b
jmp 0x16a9c
movq %rax, %r14
leaq -0x90(%rbp), %rdi
callq 0x18e82
jmp 0x16a8e
jmp 0x16a8b
jmp 0x16a9c
movq %rax, %r14
leaq -0xb8(%rbp), %rdi
callq 0xde58
jmp 0x16a9f
movq %rax, %r14
movq %rbx, %rdi
callq 0xc110
movq %r14, %rdi
callq 0xc4c0
nop