// File: /workspace/github_cpp_makefile_star2_O3/Merulo[P]CompilerJFTT/src/Register/RegisterBlock.cpp
// Function: RegisterBlock::loadVarTableFromMemory(Block&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, Register&, Register&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void RegisterBlock::loadVarTableFromMemory(Block& b, std::string name, Register& r, Register& freeRegister, std::string addresVariableName)
{
    std::string array = name.substr(0, name.find("("));
    unsigned long memoryCell = _symbolTable->getMemoryCell(array);
    unsigned long long shift = _symbolTable->getTableShift(array);

    Register& regToSub = getRegister("", b, {r, freeRegister}, false, true);
    loadVariableFromMemory(b, addresVariableName, freeRegister, r);

    auto linesToAdd = generateNumber(shift, memoryCell, regToSub);
    regToSub.variableName = "";
    regToSub.state = RegisterState::UNKNOWN;

    _addressRegister.state = RegisterState::UNKNOWN;    
    b.insert(linesToAdd);

    b.lines.push_back({"LOAD", r.name});    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movq %r9, 0x8(%rsp)
movq %r8, 0x10(%rsp)
movq %rcx, %r13
movq %rdx, %rbp
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x2d0ed(%rip), %rsi     # 0x385bd
movl $0x1, %ecx
movq %rdx, %rdi
xorl %edx, %edx
callq 0x44a0
leaq 0x130(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x42c0
movq (%r15), %rbp
leaq 0x120(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x110(%rsp), %rdi
callq 0xc7aa
leaq 0x110(%rsp), %rsi
movq %rbp, %rdi
callq 0x1a522
movq %rax, (%rsp)
movq 0x110(%rsp), %rdi
cmpq %r12, %rdi
je 0xb54f
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x42a0
movq (%r15), %rbp
leaq 0x100(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x130(%rsp), %rsi
movq 0x138(%rsp), %rdx
addq %rsi, %rdx
leaq 0xf0(%rsp), %rdi
callq 0xc7aa
movq 0x10(%rsp), %r12
leaq 0xf0(%rsp), %rsi
movq %rbp, %rdi
callq 0x1b1fa
movq %rax, %rbp
movq 0xf0(%rsp), %rdi
cmpq %r14, %rdi
je 0xb5b3
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbp, 0x48(%rsp)
leaq 0xe0(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x2bb18(%rip), %rdx     # 0x370e3
leaq 0xd0(%rsp), %rdi
movq %rdx, %rsi
callq 0x53cc
leaq 0x150(%rsp), %rsi
movq %r13, (%rsi)
movq %r12, 0x8(%rsi)
leaq 0x30(%rsp), %rdi
leaq 0x18(%rsp), %rcx
movl $0x2, %edx
callq 0xc082
leaq 0xd0(%rsp), %rsi
leaq 0x30(%rsp), %rcx
movq %r15, %rdi
movq %rbx, %rdx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x7b6c
movq %rax, %rbp
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xb639
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x42a0
movq 0xd0(%rsp), %rdi
cmpq %r14, %rdi
je 0xb656
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0xc0(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0xb0(%rsp), %rdi
callq 0xc7aa
leaq 0xb0(%rsp), %rdx
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rcx
callq 0xa7ce
movq 0xb0(%rsp), %rdi
cmpq %r14, %rdi
je 0xb6b1
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x18(%rsp), %rdi
leaq 0x48(%rsp), %rdx
movq %r15, %rsi
movq (%rsp), %rcx
movq %rbp, %r8
callq 0x8f6a
movq %rbp, %rdi
addq $0x30, %rdi
movq 0x38(%rbp), %rdx
leaq 0x2ba07(%rip), %rcx     # 0x370e3
xorl %r14d, %r14d
xorl %esi, %esi
xorl %r8d, %r8d
callq 0x4440
movl %r14d, (%rbp)
movl %r14d, 0x10(%r15)
movq 0x28(%rbx), %rsi
addq $0x20, %rbx
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rcx
movq %rbx, %rdi
callq 0xc18c
leaq 0xa0(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x2b9a2(%rip), %rsi     # 0x370c0
leaq 0x2b99f(%rip), %rdx     # 0x370c4
leaq 0x90(%rsp), %rdi
callq 0x53cc
leaq 0x80(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x10(%r13), %rsi
movq 0x18(%r13), %rdx
addq %rsi, %rdx
leaq 0x70(%rsp), %rdi
callq 0xc7aa
leaq 0x60(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2b97f(%rip), %rdx     # 0x370e3
leaq 0x50(%rsp), %rdi
movq %rdx, %rsi
callq 0x53cc
leaq 0x150(%rsp), %rdi
leaq 0x90(%rsp), %rsi
leaq 0x70(%rsp), %rdx
leaq 0x50(%rsp), %rcx
callq 0xbbea
leaq 0x150(%rsp), %rsi
movq %rbx, %rdi
callq 0xccac
leaq 0x1a0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb7c1
movq 0x1a0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x180(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb7e2
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x160(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb803
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0xb81a
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x70(%rsp), %rdi
cmpq %r15, %rdi
je 0xb834
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x90(%rsp), %rdi
cmpq %r14, %rdi
je 0xb851
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x18(%rsp), %rdi
callq 0xbcf0
leaq 0x140(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb87c
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x42a0
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x150(%rsp), %rdi
callq 0xbca2
jmp 0xb8a3
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0xb8bf
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0xb8bf
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %r15, %rdi
je 0xb8de
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0xb8de
movq %rax, %rbx
movq 0x90(%rsp), %rdi
cmpq %r14, %rdi
je 0xb9ac
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0xb9ac
jmp 0xb9a9
jmp 0xb9a4
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
cmpq %r14, %rdi
je 0xb9b6
movq 0xc0(%rsp), %rsi
jmp 0xb99a
jmp 0xb9a4
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xb94d
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x42a0
jmp 0xb94d
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
cmpq %r14, %rdi
je 0xb9b6
movq 0xe0(%rsp), %rsi
jmp 0xb99a
jmp 0xb9a4
movq %rax, %rbx
movq 0xf0(%rsp), %rdi
cmpq %r14, %rdi
je 0xb9b6
movq 0x100(%rsp), %rsi
jmp 0xb99a
jmp 0xb9a4
movq %rax, %rbx
movq 0x110(%rsp), %rdi
cmpq %r12, %rdi
je 0xb9b6
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0xb9b6
movq %rax, %rbx
jmp 0xb9b6
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0xbcf0
leaq 0x140(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb9d7
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x44c0
nop