// File: /workspace/github_cpp_makefile_star2_O2/Merulo[P]CompilerJFTT/src/IRs/FourthIR.cpp
// Function: FourthIR::handleDirectTranslation(RegisterBlock&, Block&, Line&)
void FourthIR::handleDirectTranslation(RegisterBlock& rb, Block& b, Line& l)
{   
    Register& regOne = rb.getRegister(l.one, b, {}, true, true);
    updateRegisterState(b, rb, regOne, l.one);
    regOne.variableName = l.one;
    regOne.needToSafe = true;

    if (l.one == l.two && l.operation == "ADD")
    {
        b.lines.push_back({l.operation, regOne.name, regOne.name});
        return;
    }

    Register& regTwo = rb.getRegister(l.two, b, {regOne}, false, true);
    updateRegisterState(b, rb, regTwo, l.two);
    regTwo.variableName = l.two;

    b.lines.push_back({l.operation, regOne.name, regTwo.name});  

    if (_symbolTable->isConst(l.two) && _removeConsts)
    {
        regTwo.variableName = "";
        regTwo.state = RegisterState::UNKNOWN;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rcx, %r13
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %rbp
leaq 0x20(%rcx), %r14
leaq 0x190(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x4390
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rcx
movaps %xmm0, (%rcx)
andq $0x0, 0x10(%rcx)
pushq $0x1
popq %r8
movq %r12, 0x8(%rsp)
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movl %r8d, %r9d
callq 0x5ec6
movq %rax, %r12
leaq 0x30(%rsp), %rdi
callq 0x9106
leaq 0x190(%rsp), %rdi
callq 0x4548
leaq 0x170(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x4390
movq %rbp, 0x10(%rsp)
movq %rbp, %rdi
movq %r12, %rcx
movq %r15, %r8
callq 0x192a6
leaq 0x170(%rsp), %rdi
callq 0x4548
leaq 0x30(%r12), %rdi
movq %r14, %rsi
callq 0x4180
movb $0x1, 0x50(%r12)
leaq 0x40(%r13), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x8141
testb %al, %al
je 0x17c3b
leaq 0xb518(%rip), %rsi      # 0x230a2
movq %r13, %rdi
callq 0x8453
testb %al, %al
je 0x17c3b
leaq 0x130(%rsp), %rdi
movq %r13, %rsi
callq 0x4390
addq $0x10, %r12
leaq 0x110(%rsp), %rdi
movq %r12, %rsi
callq 0x4390
leaq 0xf0(%rsp), %rdi
movq %r12, %rsi
callq 0x4390
leaq 0x1b0(%rsp), %rdi
leaq 0x130(%rsp), %rsi
leaq 0x110(%rsp), %rdx
leaq 0xf0(%rsp), %rcx
callq 0x816a
addq $0x20, %rbx
leaq 0x1b0(%rsp), %rsi
movq %rbx, %rdi
callq 0x8f90
leaq 0x1b0(%rsp), %rdi
callq 0x81fe
leaq 0xf0(%rsp), %rdi
callq 0x4548
leaq 0x110(%rsp), %rdi
callq 0x4548
leaq 0x130(%rsp), %rdi
jmp 0x17ddb
leaq 0xd0(%rsp), %rdi
movq %r15, %rsi
callq 0x4390
leaq 0x1b0(%rsp), %rsi
movq %r12, (%rsi)
leaq 0x18(%rsp), %rdi
pushq $0x1
popq %rdx
leaq 0x7(%rsp), %rcx
callq 0x8492
leaq 0xd0(%rsp), %rsi
leaq 0x18(%rsp), %rcx
pushq $0x1
popq %r9
movq 0x8(%rsp), %rdi
movq %rbx, %rdx
xorl %r8d, %r8d
callq 0x5ec6
movq %rax, %rbp
leaq 0x18(%rsp), %rdi
callq 0x9106
leaq 0xd0(%rsp), %rdi
callq 0x4548
leaq 0x150(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x4390
movq 0x10(%rsp), %rdi
movq %rbp, %rcx
movq %r14, %r8
callq 0x192a6
leaq 0x150(%rsp), %rdi
callq 0x4548
leaq 0x30(%rbp), %rdi
movq %rdi, 0x8(%rsp)
movq %r15, %rsi
callq 0x4180
leaq 0xb0(%rsp), %rdi
movq %r13, %rsi
callq 0x4390
addq $0x10, %r12
leaq 0x90(%rsp), %rdi
movq %r12, %rsi
callq 0x4390
movq %rbp, %rsi
addq $0x10, %rsi
leaq 0x70(%rsp), %rdi
callq 0x4390
movq 0x10(%rsp), %r12
leaq 0x1b0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
leaq 0x90(%rsp), %rdx
leaq 0x70(%rsp), %rcx
callq 0x816a
addq $0x20, %rbx
leaq 0x1b0(%rsp), %rsi
movq %rbx, %rdi
callq 0x8f90
leaq 0x1b0(%rsp), %rdi
callq 0x81fe
leaq 0x70(%rsp), %rdi
callq 0x4548
leaq 0x90(%rsp), %rdi
callq 0x4548
leaq 0xb0(%rsp), %rdi
callq 0x4548
movq (%r12), %rbx
leaq 0x50(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x4390
movq %rbx, %rdi
movq %r14, %rsi
callq 0x10282
testb %al, %al
je 0x17dd6
movb 0xd0(%r12), %bl
leaq 0x50(%rsp), %rdi
callq 0x4548
cmpb $0x1, %bl
jne 0x17de0
leaq 0xb31d(%rip), %rsi      # 0x230e3
movq 0x8(%rsp), %rdi
callq 0x44e0
andl $0x0, (%rbp)
jmp 0x17de0
leaq 0x50(%rsp), %rdi
callq 0x4548
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x1b0(%rsp), %rdi
callq 0x81fe
jmp 0x17e07
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x4548
jmp 0x17e19
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0x4548
jmp 0x17e2b
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
jmp 0x17ed0
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
jmp 0x17ed0
movq %rax, %rbx
leaq 0x1b0(%rsp), %rdi
callq 0x81fe
jmp 0x17e5a
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x4548
jmp 0x17e69
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x4548
jmp 0x17e7b
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
jmp 0x17ed0
movq %rax, %rbx
leaq 0x150(%rsp), %rdi
jmp 0x17ed0
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x9106
jmp 0x17ea4
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
jmp 0x17ed0
movq %rax, %rbx
leaq 0x170(%rsp), %rdi
jmp 0x17ed0
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x9106
leaq 0x190(%rsp), %rdi
callq 0x4548
movq %rbx, %rdi
callq 0x4490
nop