// File: /workspace/github_cpp_makefile_star2_O3/Merulo[P]CompilerJFTT/src/Register/RegisterBlock.cpp
// Function: RegisterBlock::saveToMemory(Block&, Register&, Register&)
void RegisterBlock::saveToMemory(Block& b, Register& r, Register& freeRegister)
{
    if ((r.state == RegisterState::VARIABLE || r.state == RegisterState::CONSTVARIABLE) && !r.variableName.empty())
    {
        if (r.variableName == "IF_CONTROL_VARIABLE")
        {
            return;
        }
        if (r.needToSafe)
        {
            saveVariableToMemory(b, r, freeRegister);
        }
    }
    else if (r.state == RegisterState::TABLE)
    {
        std::string rest = r.variableName.substr(r.variableName.find("(") + 1, std::string::npos);
        rest.pop_back();
        if (isDigits(rest))
        {
            saveConstTableToMemory(b, r, freeRegister, std::stoull(rest));
        }
        else 
        {
            saveVarTableToMemory(b, r, freeRegister, rest);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, %r12
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movl (%rdx), %eax
cmpl $0x4, %eax
je 0x5f0d
cmpl $0x3, %eax
je 0x5f5b
cmpl $0x1, %eax
jne 0x607d
cmpq $0x0, 0x38(%rbx)
je 0x5f52
leaq 0x30(%rbx), %rdi
leaq 0x31187(%rip), %rsi     # 0x370a6
callq 0x40d0
testl %eax, %eax
je 0x607d
cmpb $0x1, 0x50(%rbx)
jne 0x607d
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9858
cmpl $0x3, %eax
jne 0x607d
leaq 0x30(%rbx), %r13
leaq 0x32657(%rip), %rsi     # 0x385bd
movl $0x1, %ecx
movq %r13, %rdi
xorl %edx, %edx
callq 0x44a0
leaq 0x1(%rax), %rdx
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
movq $-0x1, %rcx
callq 0x42c0
movq %rbp, %rdi
callq 0x4370
movq %r15, %rdi
movq %rbp, %rsi
callq 0xbfbc
testb %al, %al
je 0x5ffa
movq 0x10(%rsp), %r13
callq 0x4050
movq %rax, %r12
movl (%rax), %eax
movl %eax, 0xc(%rsp)
movl $0x0, (%r12)
leaq 0x50(%rsp), %rbp
movq %r13, %rdi
movq %rbp, %rsi
movl $0xa, %edx
callq 0x43c0
cmpq %r13, (%rbp)
je 0x608c
movl (%r12), %ecx
testl %ecx, %ecx
je 0x6049
cmpl $0x22, %ecx
jne 0x6051
leaq 0x3112d(%rip), %rdi     # 0x37122
callq 0x43f0
leaq 0x40(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
leaq 0x30(%rsp), %rdi
callq 0xc7aa
leaq 0x30(%rsp), %r8
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq 0xa28a
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x6062
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x6062
movl 0xc(%rsp), %ecx
movl %ecx, (%r12)
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %rax, %r8
callq 0x9cea
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x607d
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42a0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3108f(%rip), %rdi     # 0x37122
callq 0x41a0
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x60cb
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x60cb
movq %rax, %rbx
cmpl $0x0, (%r12)
jne 0x60cb
movl 0xc(%rsp), %eax
movl %eax, (%r12)
jmp 0x60cb
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x60e6
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x44c0