// File: vsklad[P]cgen/commands.cpp
// Function: variables_store_computed(bal::Formula const&, bal::VariablesArray const&, 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>>>&)
void variables_store_computed(const bal::Formula& formula,
                              const bal::VariablesArray& variables,
                              CGenVariablesMap& variables_map) {
    assert(formula.variables_size() == variables.size());
    for (auto it = variables_map.begin(); it != variables_map.end(); it++ ) {
        if (it->second.mode == vmCompute) {
            const bal::VariablesArray template_ = variable_get_template(formula, it->first.c_str());
            it->second.data.assign_from_template(variables, template_,
                                                 it->second.compute_mode == vcmComplete ? bal::VariablesArray::aftmComplete :
                                                 it->second.compute_mode == vcmConstant ? bal::VariablesArray::aftmConstant :
                                                 bal::VariablesArray::aftmDifference);
            
            std::cout << it->first << " = " << it->second.data << std::endl;
            it->second.mode = vmValue; // the value has now been computed
        };
    };
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq (%rdi), %rax
callq *0x58(%rax)
movl %eax, -0x64(%rbp)
movq -0x10(%rbp), %rdi
callq 0x102f0
movl %eax, %ecx
movl -0x64(%rbp), %eax
cmpl %ecx, %eax
jne 0x2c2b8
jmp 0x2c2d7
leaq 0x364b4(%rip), %rdi     # 0x62773
leaq 0x361cb(%rip), %rsi     # 0x62491
movl $0x192, %edx            # imm = 0x192
leaq 0x365af(%rip), %rcx     # 0x62881
callq 0xd1c0
movq -0x18(%rbp), %rdi
callq 0x2e0b0
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2e110
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x2e0e0
testb $0x1, %al
jne 0x2c307
jmp 0x2c473
leaq -0x20(%rbp), %rdi
callq 0x26cf0
cmpl $0x2, 0x20(%rax)
jne 0x2c45d
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x26cf0
movq %rax, %rdi
callq 0xd120
movq -0x80(%rbp), %rsi
movq %rax, %rdx
leaq -0x48(%rbp), %rdi
callq 0x2a470
leaq -0x20(%rbp), %rdi
callq 0x26cf0
addq $0x20, %rax
addq $0x18, %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x26cf0
cmpl $0x0, 0x24(%rax)
jne 0x2c379
xorl %eax, %eax
movl %eax, -0x84(%rbp)
jmp 0x2c39b
leaq -0x20(%rbp), %rdi
callq 0x26cf0
movl 0x24(%rax), %edx
movl $0x2, %eax
movl $0x1, %ecx
cmpl $0x2, %edx
cmovel %ecx, %eax
movl %eax, -0x84(%rbp)
movq -0x70(%rbp), %rsi
movq -0x78(%rbp), %rdi
movl -0x84(%rbp), %ecx
leaq -0x48(%rbp), %rdx
callq 0x2e400
jmp 0x2c3b4
leaq -0x20(%rbp), %rdi
callq 0x26cf0
movq %rax, %rsi
movq 0x56bd9(%rip), %rdi     # 0x82fa0
callq 0xd290
movq %rax, -0x90(%rbp)
jmp 0x2c3d5
movq -0x90(%rbp), %rdi
leaq 0x2f9b3(%rip), %rsi     # 0x5bd96
callq 0xd320
movq %rax, -0x98(%rbp)
jmp 0x2c3f1
leaq -0x20(%rbp), %rdi
callq 0x26cf0
movq -0x98(%rbp), %rdi
movq %rax, %rsi
addq $0x38, %rsi
callq 0x58fd0
movq %rax, -0xa0(%rbp)
jmp 0x2c416
movq -0xa0(%rbp), %rdi
movq 0x56b5c(%rip), %rsi     # 0x82f80
callq 0xd360
jmp 0x2c42b
leaq -0x20(%rbp), %rdi
callq 0x26cf0
movl $0x0, 0x20(%rax)
leaq -0x48(%rbp), %rdi
callq 0x10850
jmp 0x2c45d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x10850
jmp 0x2c47c
jmp 0x2c45f
leaq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x2e140
movq %rax, -0x60(%rbp)
jmp 0x2c2e4
addq $0xa0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0xd5a0
nopw %cs:(%rax,%rax)