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

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

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

    b.lines.push_back({"COPY", regOne.name, regTwo.name});  

    regOne.constValue = regTwo.constValue;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rcx, %rbp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
leaq 0x40(%rcx), %r13
leaq 0x130(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4390
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rcx
movaps %xmm0, (%rcx)
andq $0x0, 0x10(%rcx)
pushq $0x1
popq %r8
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, 0x8(%rsp)
movq %r14, %rdx
movl %r8d, %r9d
callq 0x5ec6
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x9106
leaq 0x130(%rsp), %rdi
callq 0x4548
leaq 0x110(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x4390
movq %r12, %rdi
movq %rbx, %rcx
movq %r14, %r8
callq 0x192a6
leaq 0x110(%rsp), %rdi
callq 0x4548
leaq 0x30(%rbx), %rdi
movq %rdi, 0x10(%rsp)
movq %r13, %rsi
callq 0x4180
addq $0x20, %rbp
leaq 0xd0(%rsp), %rdi
movq %rbp, %rsi
callq 0x4390
leaq 0x150(%rsp), %rsi
movq %rbx, (%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 %r8
movq %r15, %rdi
movq 0x8(%rsp), %rdx
xorl %r9d, %r9d
callq 0x5ec6
movq %rax, %r15
leaq 0x18(%rsp), %rdi
callq 0x9106
leaq 0xd0(%rsp), %rdi
callq 0x4548
leaq 0xf0(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0x4390
movq %r12, %rdi
movq %r15, %rcx
movq %r14, %r8
callq 0x192a6
leaq 0xf0(%rsp), %rdi
callq 0x4548
leaq 0x30(%r15), %rdi
movq %rbp, %rsi
callq 0x4180
movb $0x1, 0x50(%r15)
movq (%r12), %r14
leaq 0xb0(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0x4390
movq %r14, %rdi
movq %rbp, %rsi
callq 0x10282
testb %al, %al
je 0x17941
movb 0xd0(%r12), %bpl
leaq 0xb0(%rsp), %rdi
callq 0x4548
cmpb $0x1, %bpl
jne 0x1794e
leaq 0xb7b1(%rip), %rsi      # 0x230e3
movq 0x10(%rsp), %rdi
callq 0x44e0
andl $0x0, (%rbx)
jmp 0x1794e
leaq 0xb0(%rsp), %rdi
callq 0x4548
leaq 0xb770(%rip), %rsi      # 0x230c5
leaq 0x90(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x4a54
movq %r15, %rsi
addq $0x10, %rsi
leaq 0x70(%rsp), %rdi
callq 0x4390
movq %rbx, %rsi
addq $0x10, %rsi
leaq 0x50(%rsp), %rdi
callq 0x4390
leaq 0x150(%rsp), %rdi
leaq 0x90(%rsp), %rsi
leaq 0x70(%rsp), %rdx
leaq 0x50(%rsp), %rcx
callq 0x816a
movq 0x8(%rsp), %rdi
addq $0x20, %rdi
leaq 0x150(%rsp), %rsi
callq 0x8f90
leaq 0x150(%rsp), %rdi
callq 0x81fe
leaq 0x50(%rsp), %rdi
callq 0x4548
leaq 0x70(%rsp), %rdi
callq 0x4548
leaq 0x90(%rsp), %rdi
callq 0x4548
movq 0x8(%rbx), %rax
movq %rax, 0x8(%r15)
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 0x81fe
jmp 0x17a1b
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x4548
jmp 0x17a2a
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x4548
jmp 0x17a39
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
jmp 0x17aa0
movq %rax, %rbx
jmp 0x17aa5
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
jmp 0x17aa0
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
jmp 0x17aa0
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x9106
jmp 0x17a74
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
jmp 0x17aa0
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
jmp 0x17aa0
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x9106
leaq 0x130(%rsp), %rdi
callq 0x4548
movq %rbx, %rdi
callq 0x4490
nop