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

    if (_addressRegister.state == RegisterState::UNKNOWN)
    {
        b.lines.push_back({"SUB", "A", "A"});
        _addressRegister.state = RegisterState::CONST;
        _addressRegister.constValue = 0;
    }
    auto lines = generateNumberFrom(_addressRegister.constValue, memoryCell, freeRegister);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %r9, 0x40(%rsp)
movq %rcx, %r14
movq %rdx, %r13
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x2e422(%rip), %rsi     # 0x395bd
movl $0x1, %ecx
movq %rdx, %rdi
xorl %edx, %edx
callq 0x44a0
leaq 0x120(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x42c0
movq (%r15), %r13
leaq 0x110(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rbp), %rsi
movq 0x8(%rbp), %rdx
addq %rsi, %rdx
leaq 0x100(%rsp), %rdi
callq 0xca12
leaq 0x100(%rsp), %rsi
movq %r13, %rdi
callq 0x1a7e6
movq %rax, %r13
movq 0x100(%rsp), %rdi
cmpq %r12, %rdi
je 0xb21a
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x42a0
movq (%r15), %rbp
leaq 0xf0(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x120(%rsp), %rsi
movq 0x128(%rsp), %rdx
addq %rsi, %rdx
leaq 0xe0(%rsp), %rdi
callq 0xca12
leaq 0xe0(%rsp), %rsi
movq %rbp, %rdi
callq 0x1b4b8
movq %rax, %rbp
movq 0xe0(%rsp), %rdi
cmpq %r12, %rdi
je 0xb27a
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x42a0
cmpl $0x0, 0x10(%r15)
jne 0xb3e4
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x2ce01(%rip), %rsi     # 0x38096
leaq 0x2cdfd(%rip), %rdx     # 0x38099
leaq 0x20(%rsp), %rdi
callq 0x54fc
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x2cdde(%rip), %rsi     # 0x38094
leaq 0x2cdd8(%rip), %rdx     # 0x38095
movq %rsp, %rdi
callq 0x54fc
leaq 0xd0(%rsp), %rax
movq %rax, %r12
movq %rax, -0x10(%rax)
leaq 0x2cdb9(%rip), %rsi     # 0x38094
leaq 0x2cdb3(%rip), %rdx     # 0x38095
leaq 0xc0(%rsp), %rdi
callq 0x54fc
leaq 0x140(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movq %rsp, %rdx
leaq 0xc0(%rsp), %rcx
callq 0xbe58
leaq 0x20(%rbx), %rdi
leaq 0x140(%rsp), %rsi
callq 0xcf0e
leaq 0x190(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb33e
movq 0x190(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x170(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb35f
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x150(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb380
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0xc0(%rsp), %rdi
cmpq %r12, %rdi
je 0xb39d
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x42a0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
leaq 0x30(%rsp), %r12
je 0xb3bd
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0xb3d4
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42a0
movl $0x2, 0x10(%r15)
movq $0x0, 0x18(%r15)
addq 0x40(%rsp), %r13
subq %rbp, %r13
addq $0x18, %r15
leaq 0x48(%rsp), %rdi
movq %r15, %rdx
movq %r13, %rcx
callq 0x65be
leaq 0xb0(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2ccad(%rip), %rsi     # 0x380c0
leaq 0x2ccaa(%rip), %rdx     # 0x380c4
leaq 0xa0(%rsp), %rdi
callq 0x54fc
leaq 0x90(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
addq %rsi, %rdx
leaq 0x80(%rsp), %rdi
callq 0xca12
leaq 0x70(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x2cc87(%rip), %rdx     # 0x380e3
leaq 0x60(%rsp), %rdi
movq %rdx, %rsi
callq 0x54fc
leaq 0x140(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x80(%rsp), %rdx
leaq 0x60(%rsp), %rcx
callq 0xbe58
leaq 0x48(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0xcf0e
leaq 0x190(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb4be
movq 0x190(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x170(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb4df
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x150(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb500
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x60(%rsp), %rdi
cmpq %r14, %rdi
je 0xb517
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x80(%rsp), %rdi
cmpq %r12, %rdi
je 0xb534
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0xa0(%rsp), %rdi
cmpq %r15, %rdi
je 0xb551
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x28(%rbx), %rsi
addq $0x20, %rbx
movq 0x48(%rsp), %rdx
movq 0x50(%rsp), %rcx
movq %rbx, %rdi
callq 0xc3f4
leaq 0x48(%rsp), %rdi
callq 0xbf5e
leaq 0x130(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb596
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x42a0
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0xbf10
jmp 0xb5bd
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
cmpq %r12, %rdi
je 0xb5df
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0xb5df
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xb5ff
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0xb5ff
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0xb6e7
movq 0x30(%rsp), %rsi
jmp 0xb6da
jmp 0xb6e4
jmp 0xb695
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0xbf10
jmp 0xb638
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r14, %rdi
je 0xb654
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0xb654
movq %rax, %rbx
movq 0x80(%rsp), %rdi
cmpq %r12, %rdi
je 0xb676
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0xb676
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
cmpq %r15, %rdi
je 0xb698
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0xb698
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0xbf5e
jmp 0xb6e7
jmp 0xb6e4
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
cmpq %r12, %rdi
je 0xb6e7
movq 0xf0(%rsp), %rsi
jmp 0xb6da
jmp 0xb6e4
movq %rax, %rbx
movq 0x100(%rsp), %rdi
cmpq %r12, %rdi
je 0xb6e7
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0xb6e7
movq %rax, %rbx
leaq 0x130(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb708
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x44c0