// File: Merulo[P]CompilerJFTT/src/Register/RegisterBlock.cpp
// Function: RegisterBlock::saveVariableToMemory(Block&, Register&, Register&)
void RegisterBlock::saveVariableToMemory(Block& b, Register& r, Register& freeRegister)
 {
    unsigned long long memoryCell = _symbolTable->getMemoryCell(r.variableName);
    
    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({"STORE", r.name});
    b.insert(lines);
 }

// Assembly:
subq $0x278, %rsp            # imm = 0x278
movq %rdi, 0x270(%rsp)
movq %rsi, 0x268(%rsp)
movq %rdx, 0x260(%rsp)
movq %rcx, 0x258(%rsp)
movq 0x270(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0xdde0
movq %rax, 0x38(%rsp)
movq 0x260(%rsp), %rsi
addq $0x30, %rsi
leaq 0x230(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x4180
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x20200
movq %rax, 0x48(%rsp)
jmp 0x95b2
leaq 0x230(%rsp), %rdi
callq 0x46e8
movq 0x48(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x250(%rsp)
cmpl $0x0, 0x10(%rax)
jne 0x9817
movq 0x268(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x20(%rsp)
leaq 0x197(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x4600
movq 0x28(%rsp), %rdx
leaq 0x47ac4(%rip), %rsi     # 0x510ce
leaq 0x198(%rsp), %rdi
callq 0x4f10
jmp 0x9619
leaq 0x16f(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x4600
movq 0x18(%rsp), %rdx
leaq 0x47a95(%rip), %rsi     # 0x510cc
leaq 0x170(%rsp), %rdi
callq 0x4f10
jmp 0x9646
leaq 0x147(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x4600
movq 0x10(%rsp), %rdx
leaq 0x47a68(%rip), %rsi     # 0x510cc
leaq 0x148(%rsp), %rdi
callq 0x4f10
jmp 0x9673
leaq 0x1b8(%rsp), %rdi
leaq 0x198(%rsp), %rsi
leaq 0x170(%rsp), %rdx
leaq 0x148(%rsp), %rcx
callq 0xd3b0
jmp 0x969a
movq 0x20(%rsp), %rdi
leaq 0x1b8(%rsp), %rsi
callq 0xd380
jmp 0x96ae
leaq 0x1b8(%rsp), %rdi
callq 0xd490
leaq 0x148(%rsp), %rdi
callq 0x46e8
leaq 0x147(%rsp), %rdi
callq 0x43b0
leaq 0x170(%rsp), %rdi
callq 0x46e8
leaq 0x16f(%rsp), %rdi
callq 0x43b0
leaq 0x198(%rsp), %rdi
callq 0x46e8
leaq 0x197(%rsp), %rdi
callq 0x43b0
movq 0x30(%rsp), %rax
movl $0x2, 0x10(%rax)
movq $0x0, 0x18(%rax)
jmp 0x9817
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x228(%rsp)
movl %eax, 0x224(%rsp)
leaq 0x230(%rsp), %rdi
callq 0x46e8
jmp 0x9a2a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x228(%rsp)
movl %eax, 0x224(%rsp)
jmp 0x9805
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x228(%rsp)
movl %eax, 0x224(%rsp)
jmp 0x97eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x228(%rsp)
movl %eax, 0x224(%rsp)
jmp 0x97d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x228(%rsp)
movl %eax, 0x224(%rsp)
jmp 0x97c4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x228(%rsp)
movl %eax, 0x224(%rsp)
leaq 0x1b8(%rsp), %rdi
callq 0xd490
leaq 0x148(%rsp), %rdi
callq 0x46e8
leaq 0x147(%rsp), %rdi
callq 0x43b0
leaq 0x170(%rsp), %rdi
callq 0x46e8
leaq 0x16f(%rsp), %rdi
callq 0x43b0
leaq 0x198(%rsp), %rdi
callq 0x46e8
leaq 0x197(%rsp), %rdi
callq 0x43b0
jmp 0x9a2a
movq 0x30(%rsp), %rsi
movq %rsi, %rdx
addq $0x18, %rdx
movq 0x250(%rsp), %rcx
movq 0x258(%rsp), %r8
leaq 0x128(%rsp), %rdi
callq 0x6770
leaq 0x9f(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x4600
movq 0x8(%rsp), %rdx
leaq 0x47894(%rip), %rsi     # 0x510f2
leaq 0xa0(%rsp), %rdi
callq 0x4f10
jmp 0x986d
movq 0x260(%rsp), %rsi
addq $0x10, %rsi
leaq 0x78(%rsp), %rdi
callq 0x4180
jmp 0x9885
leaq 0x57(%rsp), %rdi
movq %rdi, (%rsp)
callq 0x4600
movq (%rsp), %rdx
leaq 0x4787d(%rip), %rsi     # 0x5111b
leaq 0x58(%rsp), %rdi
callq 0x4f10
jmp 0x98aa
leaq 0xc0(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x78(%rsp), %rdx
leaq 0x58(%rsp), %rcx
callq 0xd3b0
jmp 0x98cb
leaq 0x128(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0xd380
jmp 0x98e2
leaq 0xc0(%rsp), %rdi
callq 0xd490
leaq 0x58(%rsp), %rdi
callq 0x46e8
leaq 0x57(%rsp), %rdi
callq 0x43b0
leaq 0x78(%rsp), %rdi
callq 0x46e8
leaq 0xa0(%rsp), %rdi
callq 0x46e8
leaq 0x9f(%rsp), %rdi
callq 0x43b0
movq 0x268(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0xd4d0
jmp 0x993e
leaq 0x128(%rsp), %rdi
callq 0xd550
addq $0x278, %rsp            # imm = 0x278
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x228(%rsp)
movl %eax, 0x224(%rsp)
jmp 0x99fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x228(%rsp)
movl %eax, 0x224(%rsp)
jmp 0x99ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x228(%rsp)
movl %eax, 0x224(%rsp)
jmp 0x99d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x228(%rsp)
movl %eax, 0x224(%rsp)
jmp 0x99cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x228(%rsp)
movl %eax, 0x224(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0xd490
leaq 0x58(%rsp), %rdi
callq 0x46e8
leaq 0x57(%rsp), %rdi
callq 0x43b0
leaq 0x78(%rsp), %rdi
callq 0x46e8
leaq 0xa0(%rsp), %rdi
callq 0x46e8
leaq 0x9f(%rsp), %rdi
callq 0x43b0
jmp 0x9a1d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x228(%rsp)
movl %eax, 0x224(%rsp)
leaq 0x128(%rsp), %rdi
callq 0xd550
movq 0x228(%rsp), %rdi
callq 0x45f0
nopw (%rax,%rax)