// File: 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
subq $0x2b0, %rsp            # imm = 0x2B0
movq %rdi, -0x230(%rbp)
movq %rdi, %rax
movq %rax, -0x228(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x220(%rbp)
movb $0x0, -0x1d(%rbp)
callq 0xd450
movq -0x220(%rbp), %rdi
movl $0x7fffffff, -0x24(%rbp) # imm = 0x7FFFFFFF
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
movl $0x1, %esi
callq 0x25bb0
movb %al, -0x212(%rbp)
jmp 0x22009
movb -0x212(%rbp), %al
testb $0x1, %al
jne 0x22018
jmp 0x2209b
movq -0x220(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
movl $0x1, %esi
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
callq 0x25c30
movl %eax, -0x234(%rbp)
jmp 0x22040
movl -0x234(%rbp), %edi
callq 0x25c00
movl %eax, -0x238(%rbp)
jmp 0x22053
movl -0x238(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %esi
incl %esi
leaq -0x58(%rbp), %rdi
callq 0x260b0
jmp 0x2206c
movq -0x230(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0xd3d0
leaq -0x58(%rbp), %rdi
callq 0xd1b0
jmp 0x221b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x2277e
movq -0x220(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
movl $0x5, %esi
callq 0x25bb0
movb %al, -0x239(%rbp)
jmp 0x220be
movb -0x239(%rbp), %al
testb $0x1, %al
jne 0x220ca
jmp 0x22104
movq -0x220(%rbp), %rsi
movq (%rsi), %rax
movq -0x18(%rax), %rax
addq %rax, %rsi
leaq -0x78(%rbp), %rdi
callq 0x26190
jmp 0x220e6
movq -0x230(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0xd3d0
leaq -0x78(%rbp), %rdi
callq 0xd1b0
jmp 0x221b1
movq -0x220(%rbp), %rax
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x250(%rbp)
leaq -0x99(%rbp), %rdi
movq %rdi, -0x248(%rbp)
callq 0xd5b0
movq -0x248(%rbp), %rdx
leaq 0x3f3bd(%rip), %rsi     # 0x614fa
leaq -0x98(%rbp), %rdi
callq 0xd440
jmp 0x2214b
movq -0x250(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x262a0
jmp 0x22160
leaq -0x98(%rbp), %rdi
callq 0xd1b0
leaq -0x99(%rbp), %rdi
callq 0xd370
jmp 0x221b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x221a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x98(%rbp), %rdi
callq 0xd1b0
leaq -0x99(%rbp), %rdi
callq 0xd370
jmp 0x2277e
jmp 0x221b3
movq -0x220(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
movl $0x3d, %esi
callq 0x263d0
movb %al, -0x251(%rbp)
jmp 0x221d6
movb -0x251(%rbp), %al
testb $0x1, %al
jne 0x221e2
jmp 0x22204
movq -0x220(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
movl $0x3d, %esi
callq 0x26430
jmp 0x221ff
jmp 0x222fa
movq -0x220(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x26670
movb %al, -0x252(%rbp)
jmp 0x22222
movb -0x252(%rbp), %al
testb $0x1, %al
jne 0x2222e
jmp 0x2224b
movq -0x220(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x26710
jmp 0x22246
jmp 0x222f8
movq -0x220(%rbp), %rax
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x268(%rbp)
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x260(%rbp)
callq 0xd5b0
movq -0x260(%rbp), %rdx
leaq 0x3f28c(%rip), %rsi     # 0x61510
leaq -0xc0(%rbp), %rdi
callq 0xd440
jmp 0x22292
movq -0x268(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x262a0
jmp 0x222a7
leaq -0xc0(%rbp), %rdi
callq 0xd1b0
leaq -0xc1(%rbp), %rdi
callq 0xd370
jmp 0x222f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x222e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0xd1b0
leaq -0xc1(%rbp), %rdi
callq 0xd370
jmp 0x2277e
jmp 0x222fa
leaq -0x108(%rbp), %rdi
callq 0x267c0
jmp 0x22308
movq -0x220(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
leaq 0x3f20a(%rip), %rsi     # 0x6152a
callq 0x26810
movb %al, -0x269(%rbp)
jmp 0x2232d
movb -0x269(%rbp), %al
testb $0x1, %al
jne 0x22339
jmp 0x22371
movq -0x220(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x26900
jmp 0x22351
movl $0x1, -0x108(%rbp)
jmp 0x225e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x22754
movq -0x220(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
leaq 0x3f1a8(%rip), %rsi     # 0x61531
callq 0x26810
movb %al, -0x26a(%rbp)
jmp 0x22396
movb -0x26a(%rbp), %al
testb $0x1, %al
jne 0x223a2
jmp 0x223c9
movq -0x220(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x26900
jmp 0x223ba
movl $0x2, -0x108(%rbp)
jmp 0x225e0
cmpl $0x7fffffff, -0x24(%rbp) # imm = 0x7FFFFFFF
jne 0x224b3
movq -0x220(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
leaq 0x3f14b(%rip), %rsi     # 0x61539
callq 0x26810
movb %al, -0x26b(%rbp)
jmp 0x223fb
movb -0x26b(%rbp), %al
testb $0x1, %al
jne 0x2240a
jmp 0x224b3
movq -0x220(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x26900
jmp 0x22422
movq -0x220(%rbp), %rdi
movl $0x0, -0x108(%rbp)
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
movl $0x3a, %esi
callq 0x26430
jmp 0x22449
movq -0x220(%rbp), %rsi
movq (%rsi), %rax
movq -0x18(%rax), %rax
addq %rax, %rsi
leaq -0x128(%rbp), %rdi
callq 0x26930
jmp 0x22468
leaq -0x128(%rbp), %rdi
callq 0xd120
movq %rax, %rsi
leaq -0xf0(%rbp), %rdi
callq 0x269f0
jmp 0x22485
leaq -0x128(%rbp), %rdi
callq 0xd1b0
jmp 0x225de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x128(%rbp), %rdi
callq 0xd1b0
jmp 0x22754
movq -0x220(%rbp), %rsi
movl $0x0, -0x108(%rbp)
movq (%rsi), %rax
movq -0x28(%rax), %rax
addq %rax, %rsi
leaq -0x148(%rbp), %rdi
callq 0x597d0
jmp 0x224dc
leaq -0x108(%rbp), %rdi
addq $0x18, %rdi
leaq -0x148(%rbp), %rsi
callq 0x26b30
leaq -0x148(%rbp), %rdi
callq 0x10850
cmpl $0x7fffffff, -0x24(%rbp) # imm = 0x7FFFFFFF
je 0x225dc
leaq -0xf0(%rbp), %rdi
callq 0x102f0
movl %eax, -0x270(%rbp)
jmp 0x22520
movl -0x270(%rbp), %eax
cmpl $0x1, %eax
je 0x225dc
movq -0x220(%rbp), %rax
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x280(%rbp)
leaq -0x169(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0xd5b0
movq -0x278(%rbp), %rdx
leaq 0x3efd8(%rip), %rsi     # 0x61540
leaq -0x168(%rbp), %rdi
callq 0xd440
jmp 0x22576
movq -0x280(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x262a0
jmp 0x2258b
leaq -0x168(%rbp), %rdi
callq 0xd1b0
leaq -0x169(%rbp), %rdi
callq 0xd370
jmp 0x225dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x225cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x168(%rbp), %rdi
callq 0xd1b0
leaq -0x169(%rbp), %rdi
callq 0xd370
jmp 0x22754
jmp 0x225de
jmp 0x225e0
jmp 0x225e2
movq -0x230(%rbp), %rsi
movq -0x18(%rbp), %rax
movq %rax, -0x288(%rbp)
leaq -0x1e0(%rbp), %rdi
leaq -0x108(%rbp), %rdx
callq 0x26bb0
jmp 0x22609
movq -0x288(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x26b70
movb %dl, -0x291(%rbp)
movq %rax, -0x290(%rbp)
jmp 0x2262b
movb -0x291(%rbp), %al
movq -0x290(%rbp), %rcx
movq %rcx, -0x1f0(%rbp)
movb %al, -0x1e8(%rbp)
movq -0x1f0(%rbp), %rax
movq %rax, -0x180(%rbp)
movb -0x1e8(%rbp), %al
movb %al, -0x178(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x26c10
testb $0x1, -0x178(%rbp)
jne 0x2273c
movq -0x220(%rbp), %rax
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x2a8(%rbp)
leaq -0x211(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0xd5b0
movq -0x2a0(%rbp), %rdx
leaq 0x3eebe(%rip), %rsi     # 0x6156f
leaq -0x210(%rbp), %rdi
callq 0xd440
jmp 0x226bf
movq -0x2a8(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x262a0
jmp 0x226d4
leaq -0x210(%rbp), %rdi
callq 0xd1b0
leaq -0x211(%rbp), %rdi
callq 0xd370
jmp 0x2273c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x26c10
jmp 0x22754
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x2272e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x210(%rbp), %rdi
callq 0xd1b0
leaq -0x211(%rbp), %rdi
callq 0xd370
jmp 0x22754
movb $0x1, -0x1d(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x26c40
testb $0x1, -0x1d(%rbp)
jne 0x2276e
jmp 0x22762
leaq -0x108(%rbp), %rdi
callq 0x26c40
jmp 0x2277e
movq -0x230(%rbp), %rdi
callq 0xd1b0
movq -0x228(%rbp), %rax
addq $0x2b0, %rsp            # imm = 0x2B0
popq %rbp
retq
movq -0x230(%rbp), %rdi
callq 0xd1b0
movq -0x30(%rbp), %rdi
callq 0xd5a0
nopw %cs:(%rax,%rax)