// File: /workspace/github_cpp_makefile_star2_O3/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 0x2f93b(%rip), %rsi     # 0x385bd
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 0x8e65
movq (%rsp), %rax
addq $0x10, %rax
movq %rax, 0x8(%rsp)
leaq 0x2f8f1(%rip), %rbp     # 0x385bd
cmpl $0x3, (%r12)
jne 0x8e58
leaq 0x30(%r12), %r13
movq 0x8(%r14), %rdx
cmpq 0x38(%r12), %rdx
jne 0x8d04
testq %rdx, %rdx
je 0x8e58
movq (%r13), %rsi
movq (%r14), %rdi
callq 0x42b0
testl %eax, %eax
je 0x8e58
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 0x8d54
testq %rdx, %rdx
je 0x8e05
movq 0x58(%rsp), %rsi
movq 0x38(%rsp), %rdi
callq 0x42b0
testl %eax, %eax
je 0x8e05
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 0x8de4
testq %rdx, %rdx
je 0x8dad
movq 0x18(%rsp), %rsi
movq (%r14), %rdi
callq 0x42b0
testl %eax, %eax
jne 0x8de4
movq (%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r12, %rdx
movq 0x8(%rsp), %rcx
callq 0x5ede
movl $0x0, (%r12)
movq 0x38(%r12), %rdx
movq %r13, %rdi
xorl %esi, %esi
leaq 0x2e307(%rip), %rcx     # 0x370e3
xorl %r8d, %r8d
callq 0x4440
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
movq %r15, %rbp
je 0x8e3c
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x8e3c
movq (%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r12, %rdx
movq 0x8(%rsp), %rcx
callq 0x5ede
movl $0x0, (%r12)
movq 0x38(%r12), %rdx
movq %r13, %rdi
xorl %esi, %esi
leaq 0x2e2af(%rip), %rcx     # 0x370e3
xorl %r8d, %r8d
callq 0x4440
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x8e58
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x42a0
addq $0x58, %r12
cmpq %rbx, %r12
jne 0x8ccc
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8e80
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 0x8eb5
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x8eb5
jmp 0x8eb2
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x8ed6
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x8ed6
movq %rax, %rbx
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8ef1
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x44c0
nop