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

    std::string argument = l.two;
    if (l.one == l.two)
    {
        argument = "";
    }

    Register& registerC = rb.getRegistersForOperation(argument, b, {registerB});
    registerC.state = RegisterState::UNKNOWN;
    registerC.variableName = "";

    if (l.one == l.two)
    {
        b.lines.push_back({"COPY", registerC.name, registerB.name});
    }

    Register& registerD = rb.getRegistersForOperation("TEMPORARY_2", b, {registerB, registerC});
    registerD.state = RegisterState::UNKNOWN;
    registerD.variableName = "";

    auto lines = MathOperations::generateMultiplication(registerB.name, registerC.name, registerD.name, l);
    b.lines.insert(b.lines.end(), lines.begin(), lines.end());

    registerD.variableName = l.one;
    updateRegisterState(b, rb, registerD, l.one);
    registerD.needToSafe = true;

    registerB.state = RegisterState::UNKNOWN;
    registerB.variableName = "";
    registerB.needToSafe = false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2b8, %rsp            # imm = 0x2B8
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %rbp
movq %rcx, 0x8(%rsp)
leaq 0x20(%rcx), %r15
leaq 0x230(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4390
xorps %xmm0, %xmm0
leaq 0x70(%rsp), %rcx
movaps %xmm0, (%rcx)
andq $0x0, 0x10(%rcx)
pushq $0x1
popq %r8
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movl %r8d, %r9d
callq 0x5ec6
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x9106
leaq 0x230(%rsp), %rdi
callq 0x4548
leaq 0x30(%rbx), %rdi
movq %rdi, 0x10(%rsp)
movq %r15, %rsi
callq 0x4180
leaq 0x210(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x4390
movq %rbp, 0x18(%rsp)
movq %rbp, %rdi
movq %rbx, %rcx
movq %r12, %r8
callq 0x192a6
leaq 0x210(%rsp), %rdi
callq 0x4548
movb $0x1, 0x50(%rbx)
movq 0x8(%rsp), %rax
leaq 0x40(%rax), %rbp
leaq 0x50(%rsp), %rdi
movq %rbp, %rsi
callq 0x4390
movq %r15, %rdi
movq %rbp, %rsi
callq 0x8141
testb %al, %al
je 0x181bb
leaq 0xaf32(%rip), %rsi      # 0x230e3
leaq 0x50(%rsp), %rdi
callq 0x44e0
leaq 0x188(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x4390
leaq 0x1a8(%rsp), %rsi
movq %rbx, (%rsi)
leaq 0x38(%rsp), %rdi
pushq $0x1
popq %rdx
leaq 0x6(%rsp), %rcx
callq 0x8492
leaq 0x188(%rsp), %rsi
leaq 0x38(%rsp), %rcx
movq %r14, %rdi
movq %r13, %rdx
callq 0x5958
movq %rax, %r12
leaq 0x38(%rsp), %rdi
callq 0x9106
leaq 0x188(%rsp), %rdi
callq 0x4548
andl $0x0, (%r12)
leaq 0x30(%r12), %rdi
leaq 0xaeb6(%rip), %rsi      # 0x230e3
callq 0x44e0
movq %r15, %rdi
movq %rbp, %rsi
callq 0x8141
testb %al, %al
je 0x182eb
leaq 0xae79(%rip), %rsi      # 0x230c5
leaq 0x168(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x4a54
leaq 0x10(%r12), %rsi
leaq 0x148(%rsp), %rdi
callq 0x4390
leaq 0x10(%rbx), %rsi
leaq 0x128(%rsp), %rdi
callq 0x4390
leaq 0x1a8(%rsp), %rdi
leaq 0x168(%rsp), %rsi
leaq 0x148(%rsp), %rdx
leaq 0x128(%rsp), %rcx
callq 0x816a
leaq 0x20(%r13), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x8f90
leaq 0x1a8(%rsp), %rdi
callq 0x81fe
leaq 0x128(%rsp), %rdi
callq 0x4548
leaq 0x148(%rsp), %rdi
callq 0x4548
leaq 0x168(%rsp), %rdi
callq 0x4548
leaq 0xb245(%rip), %rsi      # 0x23537
leaq 0x108(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x4a54
leaq 0x1a8(%rsp), %rsi
movq %rbx, (%rsi)
movq %r12, 0x8(%rsi)
leaq 0x20(%rsp), %rdi
pushq $0x2
popq %rdx
leaq 0x7(%rsp), %rcx
callq 0x8492
leaq 0x108(%rsp), %rsi
leaq 0x20(%rsp), %rcx
movq %r14, %rdi
movq %r13, %rdx
callq 0x5958
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x9106
leaq 0x108(%rsp), %rdi
callq 0x4548
andl $0x0, (%r14)
leaq 0x30(%r14), %rbp
leaq 0xad7d(%rip), %rsi      # 0x230e3
movq %rbp, %rdi
callq 0x44e0
movq %rbx, %rsi
addq $0x10, %rsi
leaq 0xe8(%rsp), %rdi
callq 0x4390
addq $0x10, %r12
leaq 0xc8(%rsp), %rdi
movq %r12, %rsi
callq 0x4390
movq %r14, %rsi
addq $0x10, %rsi
leaq 0xa8(%rsp), %rdi
callq 0x4390
leaq 0x250(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x8a26
leaq 0x1a8(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
leaq 0xc8(%rsp), %rdx
leaq 0xa8(%rsp), %rcx
leaq 0x250(%rsp), %r8
callq 0x94d2
leaq 0x250(%rsp), %rdi
callq 0x81fe
leaq 0xa8(%rsp), %rdi
callq 0x4548
leaq 0xc8(%rsp), %rdi
callq 0x4548
leaq 0xe8(%rsp), %rdi
callq 0x4548
movq 0x28(%r13), %rsi
addq $0x20, %r13
movq 0x1a8(%rsp), %rdx
movq 0x1b0(%rsp), %rcx
movq %r13, %rdi
callq 0x85b6
movq %rbp, %rdi
movq %r15, %rsi
callq 0x4180
movq 0x18(%rsp), %r12
leaq 0x88(%rsp), %rdi
movq %r15, %rsi
callq 0x4390
leaq 0x88(%rsp), %r8
movq %r12, %rdi
movq %r14, %rcx
callq 0x192a6
leaq 0x88(%rsp), %rdi
callq 0x4548
movb $0x1, 0x50(%r14)
andl $0x0, (%rbx)
leaq 0xac57(%rip), %rsi      # 0x230e3
movq 0x10(%rsp), %rdi
callq 0x44e0
movb $0x0, 0x50(%rbx)
leaq 0x1a8(%rsp), %rdi
callq 0x8236
leaq 0x50(%rsp), %rdi
callq 0x4548
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x1a8(%rsp), %rdi
callq 0x81fe
jmp 0x184d8
movq %rax, %rbx
leaq 0x128(%rsp), %rdi
callq 0x4548
jmp 0x184ea
movq %rax, %rbx
leaq 0x148(%rsp), %rdi
callq 0x4548
jmp 0x184fc
movq %rax, %rbx
leaq 0x168(%rsp), %rdi
jmp 0x185ac
jmp 0x185d7
jmp 0x185d7
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x4548
jmp 0x185df
jmp 0x185dc
movq %rax, %rbx
leaq 0x250(%rsp), %rdi
callq 0x81fe
jmp 0x18542
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x4548
jmp 0x18554
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x4548
jmp 0x18566
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
jmp 0x185ac
jmp 0x185d7
jmp 0x185d7
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x9106
jmp 0x18586
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
jmp 0x185ac
jmp 0x185d7
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x9106
jmp 0x185a4
movq %rax, %rbx
leaq 0x188(%rsp), %rdi
callq 0x4548
jmp 0x185ec
movq %rax, %rbx
leaq 0x210(%rsp), %rdi
jmp 0x185f1
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x9106
leaq 0x230(%rsp), %rdi
jmp 0x185f1
movq %rax, %rbx
jmp 0x185ec
movq %rax, %rbx
leaq 0x1a8(%rsp), %rdi
callq 0x8236
leaq 0x50(%rsp), %rdi
callq 0x4548
movq %rbx, %rdi
callq 0x4490