// File: /workspace/github_cpp_makefile_star2_O2/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 0x1e057(%rip), %rsi     # 0x245bd
movq %r14, %rdi
xorl %edx, %edx
callq 0x4520
leaq 0x18(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x42a0
movq 0x68(%rbx), %rbp
movq 0x70(%rbx), %r12
movq %rbx, (%rsp)
leaq 0x10(%rbx), %rax
movq %rax, 0x8(%rsp)
leaq 0x38(%rsp), %r15
leaq 0x58(%rsp), %rcx
cmpq %r12, %rbp
je 0x66b5
cmpl $0x3, (%rbp)
jne 0x66ac
leaq 0x30(%rbp), %r13
movq %rcx, %rbx
movq %r14, %rdi
movq %r13, %rsi
callq 0x8141
movq %rbx, %rcx
testb %al, %al
jne 0x66ac
movq %r13, %rdi
leaq 0x1dfe2(%rip), %rsi     # 0x245bd
xorl %edx, %edx
callq 0x4520
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x42a0
movq %r15, %rdi
leaq 0x18(%rsp), %rsi
callq 0x8141
testb %al, %al
je 0x662e
movq (%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %rbp, %rdx
movq 0x8(%rsp), %rcx
callq 0x51c8
andl $0x0, (%rbp)
movq %r13, %rdi
leaq 0x1cabc(%rip), %rsi     # 0x230e3
callq 0x44e0
jmp 0x66a1
movq %r13, %rdi
leaq 0x1df85(%rip), %rsi     # 0x245bd
xorl %edx, %edx
callq 0x4520
leaq 0x1(%rax), %rdx
movq %rbx, %r15
movq %rbx, %rdi
movq %r13, %rsi
pushq $-0x1
popq %rcx
callq 0x42a0
movq %r15, %rdi
callq 0x4330
movq %r14, %rdi
movq %r15, %rsi
callq 0x8141
testb %al, %al
je 0x6694
movq (%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %rbp, %rdx
movq 0x8(%rsp), %rcx
callq 0x51c8
andl $0x0, (%rbp)
movq %r13, %rdi
leaq 0x1ca54(%rip), %rsi     # 0x230e3
callq 0x44e0
movq %rbx, %rdi
callq 0x4548
leaq 0x38(%rsp), %r15
movq %r15, %rdi
callq 0x4548
movq %rbx, %rcx
addq $0x58, %rbp
jmp 0x65a1
leaq 0x18(%rsp), %rdi
callq 0x4548
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x4548
jmp 0x66e2
jmp 0x66df
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x4548
jmp 0x66f1
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x4548
movq %rbx, %rdi
callq 0x4490
nop