// File: /workspace/github_cpp_makefile_star2_O1/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 0x600d
cmpl $0x3, %eax
je 0x605b
cmpl $0x1, %eax
jne 0x617d
cmpq $0x0, 0x38(%rbx)
je 0x6052
leaq 0x30(%rbx), %rdi
leaq 0x32087(%rip), %rsi     # 0x380a6
callq 0x40d0
testl %eax, %eax
je 0x617d
cmpb $0x1, 0x50(%rbx)
jne 0x617d
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 0x9ad2
cmpl $0x3, %eax
jne 0x617d
leaq 0x30(%rbx), %r13
leaq 0x33557(%rip), %rsi     # 0x395bd
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 0xc228
testb %al, %al
je 0x60fa
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 0x618c
movl (%r12), %ecx
testl %ecx, %ecx
je 0x6149
cmpl $0x22, %ecx
jne 0x6151
leaq 0x3202d(%rip), %rdi     # 0x38122
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 0xca12
leaq 0x30(%rsp), %r8
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r12, %rcx
callq 0xa504
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x6162
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x6162
movl 0xc(%rsp), %ecx
movl %ecx, (%r12)
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %rax, %r8
callq 0x9f64
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x617d
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 0x31f8f(%rip), %rdi     # 0x38122
callq 0x41a0
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r13, %rdi
je 0x61cb
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x61cb
movq %rax, %rbx
cmpl $0x0, (%r12)
jne 0x61cb
movl 0xc(%rsp), %eax
movl %eax, (%r12)
jmp 0x61cb
movq %rax, %rbx
leaq 0x20(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x61e6
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x44c0