// File: /workspace/github_cpp_makefile_star2_O1/Merulo[P]CompilerJFTT/src/Register/RegisterBlock.cpp
// Function: RegisterBlock::storeSameTable(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, Block&)
void RegisterBlock::storeSameTable(std::string name, Block& b)
{
    std::string currentTable = name.substr(0, name.find("("));
    for(auto& reg : _registers)
    {
        if (reg.state != RegisterState::TABLE)
        {
            continue;
        }
        if (name == reg.variableName)
        {
            continue;
        }
        std::string registerTable = reg.variableName.substr(0, reg.variableName.find("("));
        if (registerTable == currentTable)
        {
            saveToMemory(b, reg, _addressRegister);
            reg.state = RegisterState::UNKNOWN;
            reg.variableName = "";
            continue;
        }
        std::string rest = reg.variableName.substr(reg.variableName.find("(") + 1, std::string::npos);
        rest.pop_back();
        if (name == rest)
        {
            saveToMemory(b, reg, _addressRegister);
            reg.state = RegisterState::UNKNOWN;
            reg.variableName = "";
            continue;            
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, 0x10(%rsp)
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x306e9(%rip), %rsi     # 0x395bd
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x44a0
leaq 0x58(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x42c0
movq 0x68(%rbx), %r12
movq %rbx, (%rsp)
movq 0x70(%rbx), %rbx
cmpq %rbx, %r12
je 0x90b7
movq (%rsp), %rax
addq $0x10, %rax
movq %rax, 0x8(%rsp)
leaq 0x3069f(%rip), %rbp     # 0x395bd
cmpl $0x3, (%r12)
jne 0x90aa
leaq 0x30(%r12), %r13
movq 0x8(%r14), %rdx
cmpq 0x38(%r12), %rdx
jne 0x8f56
testq %rdx, %rdx
je 0x90aa
movq (%r13), %rsi
movq (%r14), %rdi
callq 0x42b0
testl %eax, %eax
je 0x90aa
movl $0x1, %ecx
movq %r13, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x44a0
leaq 0x38(%rsp), %rdi
movq %r13, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x42c0
movq 0x40(%rsp), %rdx
cmpq 0x60(%rsp), %rdx
jne 0x8fa6
testq %rdx, %rdx
je 0x9057
movq 0x58(%rsp), %rsi
movq 0x38(%rsp), %rdi
callq 0x42b0
testl %eax, %eax
je 0x9057
movl $0x1, %ecx
movq %r13, %rdi
movq %rbp, %r15
movq %rbp, %rsi
xorl %edx, %edx
callq 0x44a0
leaq 0x1(%rax), %rdx
leaq 0x18(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
movq $-0x1, %rcx
callq 0x42c0
movq %rbp, %rdi
callq 0x4370
movq 0x8(%r14), %rdx
cmpq 0x20(%rsp), %rdx
jne 0x9036
testq %rdx, %rdx
je 0x8fff
movq 0x18(%rsp), %rsi
movq (%r14), %rdi
callq 0x42b0
testl %eax, %eax
jne 0x9036
movq (%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r12, %rdx
movq 0x8(%rsp), %rcx
callq 0x5fde
movl $0x0, (%r12)
movq 0x38(%r12), %rdx
movq %r13, %rdi
xorl %esi, %esi
leaq 0x2f0b5(%rip), %rcx     # 0x380e3
xorl %r8d, %r8d
callq 0x4440
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
movq %r15, %rbp
je 0x908e
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x908e
movq (%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r12, %rdx
movq 0x8(%rsp), %rcx
callq 0x5fde
movl $0x0, (%r12)
movq 0x38(%r12), %rdx
movq %r13, %rdi
xorl %esi, %esi
leaq 0x2f05d(%rip), %rcx     # 0x380e3
xorl %r8d, %r8d
callq 0x4440
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x90aa
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x42a0
addq $0x58, %r12
cmpq %rbx, %r12
jne 0x8f1e
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x90d2
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42a0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x9107
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x9107
jmp 0x9104
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x9128
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x9128
movq %rax, %rbx
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x9143
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x44c0
nop