// File: /workspace/github_cpp_makefile_star2_O3/vsklad[P]cgen/commands.cpp
// Function: variables_merge(bal::VariablesArray&, bal::Formula&, 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>>> const&, bool, bool)
bal::variables_size_t variables_merge(bal::VariablesArray& variables,
                                      bal::Formula& formula,
                                      const CGenVariablesMap& variables_map,
                                      const bool apply_except,
                                      const bool reassign_in_formula) {
    assert(formula.variables_size() == variables.size());
    bal::variables_size_t changes_count = 0;
    for (auto it = variables_map.begin(); it != variables_map.end(); it++ ) {
        // other types must have been resolved into values at this point
        _assert_level_1(it->second.mode == vmValue || it->second.mode == vmCompute);
        if (it->second.mode == vmValue) {
            const bal::VariablesArray variable_template = variable_get_template(formula, it->first.c_str());
            bal::VariablesArray variable_value = variable_generate_value(formula, it->first, it->second,
                                                                         variable_template, apply_except,
                                                                         reassign_in_formula);
            bal::variables_size_t assignment_result = variables.assign_template_from(variable_template, variable_value);
            if (assignment_result != bal::VARIABLEID_ERROR) {
                changes_count += assignment_result;
            } else {
                throw std::invalid_argument("Conflicting binary variable assignment");
            };
            
            if (apply_except && !is_binary_variable_name(it->first)) {
                // update any unassigned variables within template
                // with values that has been specified or generated
                formula.named_variable_update_unassigned(it->first, variable_value);
            };
        };
    };
    return changes_count;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %r8d, %r14d
movl %ecx, -0x30(%rbp)
movq %rdx, %r13
movq %rdi, %rbx
movq (%rsi), %rax
movq %rsi, %r15
movq %rsi, %rdi
callq *0x58(%rax)
movq %rbx, -0x80(%rbp)
cmpl 0x8(%rbx), %eax
jne 0x1fbdc
movq 0x18(%r13), %rax
addq $0x8, %r13
xorl %r12d, %r12d
cmpq %r13, %rax
je 0x1fb38
movl %r14d, %ecx
leaq -0x68(%rbp), %r14
leaq -0xc0(%rbp), %rbx
movzbl %cl, %ecx
movl %ecx, -0x38(%rbp)
movzbl -0x30(%rbp), %ecx
movl %ecx, -0x34(%rbp)
movq %r13, -0x70(%rbp)
movq %r15, -0x78(%rbp)
movl 0x40(%rax), %ecx
testl %ecx, %ecx
je 0x1f919
cmpl $0x2, %ecx
je 0x1fb23
jmp 0x1fbbd
movl %r12d, -0x3c(%rbp)
movq 0x20(%rax), %rdx
movq %r14, %rdi
movq %rax, %r13
movq %r15, %rsi
callq 0x1eaef
leaq -0xb0(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq 0x20(%r13), %rsi
movq 0x28(%r13), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x1da14
movq %r13, -0x48(%rbp)
leaq 0x40(%r13), %rcx
movl -0x38(%rbp), %eax
movl %eax, (%rsp)
leaq -0xa0(%rbp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r14, %r8
movl -0x34(%rbp), %r9d
callq 0x1f10c
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
je 0x1f98f
callq 0xb280
movl -0x60(%rbp), %esi
cmpl -0x98(%rbp), %esi
jne 0x1fb9e
testl %esi, %esi
je 0x1faa8
movq -0x68(%rbp), %rax
xorl %ecx, %ecx
movq -0xa0(%rbp), %rdx
movl $0x0, -0x2c(%rbp)
movl (%rdx,%rcx,4), %edi
cmpl $-0x1, %edi
je 0x1fa8c
movl (%rax,%rcx,4), %r11d
cmpl $-0x1, %r11d
je 0x1fa8c
cmpl %edi, %r11d
je 0x1fa8c
movq -0x80(%rbp), %r8
movl 0x8(%r8), %r9d
movq (%r8), %r8
cmpl $0x2, %r11d
jb 0x1fa45
movl %r11d, %r14d
shrl %r14d
decl %r14d
cmpl %r9d, %r14d
jae 0x1fb7f
movl %r11d, %r10d
andl $0x1, %r10d
xorl %edi, %r10d
movl %r10d, %edi
xorl $0x1, %edi
movl %r14d, %r15d
movl (%r8,%r15,4), %r14d
cmpl %edi, %r14d
je 0x1fa8c
movq %rbx, %r12
orl $0x1, %r11d
leal -0x2(%rdi), %r13d
cmpl $-0x3, %r13d
setb %r13b
cmpl %r11d, %edi
seta %bl
testb %r13b, %bl
je 0x1fa55
movl %edi, %r14d
movl %r11d, %edi
movq %r12, %rbx
jmp 0x1fa6c
movl %edi, %r14d
cmpl $0x1, %edi
movl %r11d, %edi
ja 0x1fa6c
jmp 0x1fb4d
cmpl %r11d, %r14d
movq %r12, %rbx
je 0x1fa7f
cmpl $-0x1, %r14d
je 0x1fa7f
xorl %r14d, %r11d
cmpl $0x1, %r11d
je 0x1fa82
cmpl $-0x1, %edi
je 0x1fa8c
movl %r14d, %r11d
cmpl %edi, %r14d
jne 0x1f9e8
jmp 0x1fa8c
movl %edi, %r10d
movl %r10d, (%r8,%r15,4)
incl -0x2c(%rbp)
movl -0x60(%rbp), %esi
incq %rcx
movl %esi, %edi
cmpq %rdi, %rcx
jb 0x1f9ba
cmpl $0x7fffffff, -0x2c(%rbp) # imm = 0x7FFFFFFF
jne 0x1faaf
jmp 0x1fb4d
movl $0x0, -0x2c(%rbp)
cmpb $0x0, -0x30(%rbp)
movq -0x78(%rbp), %r15
je 0x1fae5
movq -0x48(%rbp), %rax
leaq 0x20(%rax), %rsi
cmpq $0x0, 0x28(%rax)
je 0x1fad6
movq (%rsi), %rax
movsbl (%rax), %eax
addl $-0x30, %eax
cmpl $0xa, %eax
jb 0x1fae5
movq %r15, %rdi
leaq -0xa0(%rbp), %rdx
callq 0x3b3c0
cmpl $0x0, -0x88(%rbp)
movq -0x70(%rbp), %r13
movl -0x3c(%rbp), %r12d
je 0x1fb07
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x1fb07
callq 0xb350
cmpl $0x0, -0x50(%rbp)
je 0x1fb1b
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x1fb1b
callq 0xb350
addl -0x2c(%rbp), %r12d
movq -0x48(%rbp), %rax
movq %rax, %rdi
callq 0xb330
cmpq %r13, %rax
leaq -0x68(%rbp), %r14
jne 0x1f904
movl %r12d, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0xb130
movq %rax, %r14
leaq 0x26d0d(%rip), %rsi     # 0x4686e
movq %rax, %rdi
callq 0xb520
movq 0x3c468(%rip), %rsi     # 0x5bfd8
movq 0x3c449(%rip), %rdx     # 0x5bfc0
movq %r14, %rdi
callq 0xb4b0
leaq 0x1fd26(%rip), %rdi     # 0x3f8ac
leaq 0x1fb9f(%rip), %rsi     # 0x3f72c
leaq 0x1fcad(%rip), %rcx     # 0x3f841
movl $0x9d, %edx
callq 0xb180
leaq 0x1fc7d(%rip), %rdi     # 0x3f822
leaq 0x1fb80(%rip), %rsi     # 0x3f72c
leaq 0x1fc8e(%rip), %rcx     # 0x3f841
movl $0x8d, %edx
callq 0xb180
leaq 0x26c6f(%rip), %rdi     # 0x46833
leaq 0x268da(%rip), %rsi     # 0x464a5
leaq 0x26be2(%rip), %rcx     # 0x467b4
movl $0x175, %edx            # imm = 0x175
callq 0xb180
leaq 0x26ba4(%rip), %rdi     # 0x46787
leaq 0x268bb(%rip), %rsi     # 0x464a5
leaq 0x26bc3(%rip), %rcx     # 0x467b4
movl $0x171, %edx            # imm = 0x171
callq 0xb180
jmp 0x1fc1f
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
je 0x1fc49
callq 0xb280
jmp 0x1fc49
movq %rax, %rbx
jmp 0x1fc49
movq %rax, %rbx
jmp 0x1fc2f
movq %rax, %rbx
movq %r14, %rdi
callq 0xb1e0
cmpl $0x0, -0x88(%rbp)
je 0x1fc49
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x1fc49
callq 0xb350
cmpl $0x0, -0x50(%rbp)
je 0x1fc5d
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x1fc5d
callq 0xb350
movq %rbx, %rdi
callq 0xb4e0