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

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

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

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

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

    auto lines = MathOperations::generateDivision(
        registerB.name, registerC.name, 
        registerD.name, registerE.name,
        registerF.name, l);

    b.lines.insert(b.lines.end(), lines.begin(), lines.end());

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

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

// Assembly:
subq $0x548, %rsp            # imm = 0x548
movq %rdi, 0x540(%rsp)
movq %rsi, 0x538(%rsp)
movq %rdx, 0x530(%rsp)
movq %rcx, 0x528(%rsp)
movq 0x540(%rsp), %rax
movq %rax, 0x130(%rsp)
movq 0x538(%rsp), %rax
movq %rax, 0x138(%rsp)
movq 0x528(%rsp), %rsi
addq $0x20, %rsi
leaq 0x500(%rsp), %rdi
movq %rdi, 0x140(%rsp)
callq 0x4180
movq 0x530(%rsp), %rax
movq %rax, 0x148(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x4e0(%rsp)
movq $0x0, 0x4f0(%rsp)
leaq 0x4e0(%rsp), %rdi
movq %rdi, 0x150(%rsp)
callq 0x391c0
movq 0x138(%rsp), %rdi
movq 0x140(%rsp), %rsi
movq 0x148(%rsp), %rdx
movq 0x150(%rsp), %rcx
movl $0x1, %r9d
movl %r9d, %r8d
callq 0x7ac0
movq %rax, 0x158(%rsp)
jmp 0x35bdc
leaq 0x4e0(%rsp), %rdi
callq 0xd9c0
leaq 0x500(%rsp), %rdi
callq 0x46e8
movq 0x158(%rsp), %rax
movq %rax, 0x520(%rsp)
movq 0x530(%rsp), %rax
movq %rax, 0x110(%rsp)
movq 0x538(%rsp), %rax
movq %rax, 0x118(%rsp)
movq 0x520(%rsp), %rax
movq %rax, 0x120(%rsp)
movq 0x528(%rsp), %rsi
addq $0x20, %rsi
leaq 0x4b0(%rsp), %rdi
movq %rdi, 0x128(%rsp)
callq 0x4180
movq 0x130(%rsp), %rdi
movq 0x110(%rsp), %rsi
movq 0x118(%rsp), %rdx
movq 0x120(%rsp), %rcx
movq 0x128(%rsp), %r8
callq 0x37870
jmp 0x35c86
leaq 0x4b0(%rsp), %rdi
callq 0x46e8
movq 0x528(%rsp), %rsi
addq $0x20, %rsi
movq 0x520(%rsp), %rdi
addq $0x30, %rdi
callq 0x4050
movq 0x520(%rsp), %rax
movb $0x1, 0x50(%rax)
movq 0x538(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq 0x528(%rsp), %rsi
addq $0x40, %rsi
leaq 0x488(%rsp), %rdi
callq 0x4180
movq 0x530(%rsp), %rax
movq %rax, 0xf8(%rsp)
movq 0x520(%rsp), %rsi
leaq 0x458(%rsp), %rdi
movq %rdi, 0x100(%rsp)
callq 0xddf0
movq 0x100(%rsp), %rax
movq %rax, 0x460(%rsp)
movq $0x1, 0x468(%rsp)
leaq 0x457(%rsp), %rdi
movq %rdi, 0x108(%rsp)
callq 0xde20
movq 0x108(%rsp), %rcx
movq 0x460(%rsp), %rsi
movq 0x468(%rsp), %rdx
leaq 0x470(%rsp), %rdi
callq 0xde30
jmp 0x35d6a
movq 0xf8(%rsp), %rdx
movq 0xf0(%rsp), %rdi
leaq 0x488(%rsp), %rsi
leaq 0x470(%rsp), %rcx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x7ac0
movq %rax, 0xe8(%rsp)
jmp 0x35da2
leaq 0x470(%rsp), %rdi
callq 0xd9c0
leaq 0x457(%rsp), %rdi
callq 0xdec0
leaq 0x488(%rsp), %rdi
callq 0x46e8
movq 0xe8(%rsp), %rax
movq %rax, 0x4a8(%rsp)
movq 0x530(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq 0x538(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq 0x4a8(%rsp), %rax
movq %rax, 0xd8(%rsp)
movq 0x528(%rsp), %rsi
addq $0x40, %rsi
leaq 0x430(%rsp), %rdi
movq %rdi, 0xe0(%rsp)
callq 0x4180
movq 0x130(%rsp), %rdi
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
movq 0xd8(%rsp), %rcx
movq 0xe0(%rsp), %r8
callq 0x37870
jmp 0x35e59
leaq 0x430(%rsp), %rdi
callq 0x46e8
movq 0x528(%rsp), %rsi
addq $0x40, %rsi
movq 0x4a8(%rsp), %rdi
addq $0x30, %rdi
callq 0x4050
movq 0x538(%rsp), %rax
movq %rax, 0xb8(%rsp)
leaq 0x407(%rsp), %rdi
movq %rdi, 0xc0(%rsp)
callq 0x4600
movq 0xc0(%rsp), %rdx
leaq 0x1b6cd(%rip), %rsi     # 0x51584
leaq 0x408(%rsp), %rdi
callq 0x4f10
jmp 0x35ec6
movq 0x530(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0x520(%rsp), %rsi
leaq 0x3c8(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0xddf0
leaq 0x3d0(%rsp), %rdi
movq 0x4a8(%rsp), %rsi
callq 0xddf0
movq 0xa8(%rsp), %rax
movq %rax, 0x3d8(%rsp)
movq $0x2, 0x3e0(%rsp)
leaq 0x3c7(%rsp), %rdi
movq %rdi, 0xb0(%rsp)
callq 0xde20
movq 0xb0(%rsp), %rcx
movq 0x3d8(%rsp), %rsi
movq 0x3e0(%rsp), %rdx
leaq 0x3e8(%rsp), %rdi
callq 0xde30
jmp 0x35f60
movq 0xa0(%rsp), %rdx
movq 0xb8(%rsp), %rdi
leaq 0x408(%rsp), %rsi
leaq 0x3e8(%rsp), %rcx
callq 0x73c0
movq %rax, 0x98(%rsp)
jmp 0x35f8f
leaq 0x3e8(%rsp), %rdi
callq 0xd9c0
leaq 0x3c7(%rsp), %rdi
callq 0xdec0
leaq 0x408(%rsp), %rdi
callq 0x46e8
leaq 0x407(%rsp), %rdi
callq 0x43b0
movq 0x98(%rsp), %rax
movq %rax, 0x428(%rsp)
movq 0x428(%rsp), %rax
movl $0x0, (%rax)
movq 0x428(%rsp), %rdi
addq $0x30, %rdi
leaq 0x1b127(%rip), %rsi     # 0x5111b
callq 0x44a0
movq 0x538(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x397(%rsp), %rdi
movq %rdi, 0x90(%rsp)
callq 0x4600
movq 0x90(%rsp), %rdx
leaq 0x1b54b(%rip), %rsi     # 0x51578
leaq 0x398(%rsp), %rdi
callq 0x4f10
jmp 0x3603c
movq 0x530(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x520(%rsp), %rsi
leaq 0x350(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0xddf0
leaq 0x358(%rsp), %rdi
movq 0x4a8(%rsp), %rsi
callq 0xddf0
leaq 0x360(%rsp), %rdi
movq 0x428(%rsp), %rsi
callq 0xddf0
movq 0x78(%rsp), %rax
movq %rax, 0x368(%rsp)
movq $0x3, 0x370(%rsp)
leaq 0x34f(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0xde20
movq 0x80(%rsp), %rcx
movq 0x368(%rsp), %rsi
movq 0x370(%rsp), %rdx
leaq 0x378(%rsp), %rdi
callq 0xde30
jmp 0x360e2
movq 0x70(%rsp), %rdx
movq 0x88(%rsp), %rdi
leaq 0x398(%rsp), %rsi
leaq 0x378(%rsp), %rcx
callq 0x73c0
movq %rax, 0x68(%rsp)
jmp 0x3610b
leaq 0x378(%rsp), %rdi
callq 0xd9c0
leaq 0x34f(%rsp), %rdi
callq 0xdec0
leaq 0x398(%rsp), %rdi
callq 0x46e8
leaq 0x397(%rsp), %rdi
callq 0x43b0
movq 0x68(%rsp), %rax
movq %rax, 0x3b8(%rsp)
movq 0x3b8(%rsp), %rax
movl $0x0, (%rax)
movq 0x3b8(%rsp), %rdi
addq $0x30, %rdi
leaq 0x1afae(%rip), %rsi     # 0x5111b
callq 0x44a0
movq 0x538(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0x31f(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x4600
movq 0x60(%rsp), %rdx
leaq 0x1b3f3(%rip), %rsi     # 0x51590
leaq 0x320(%rsp), %rdi
callq 0x4f10
jmp 0x361ac
movq 0x530(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x520(%rsp), %rsi
leaq 0x2d0(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0xddf0
leaq 0x2d8(%rsp), %rdi
movq 0x4a8(%rsp), %rsi
callq 0xddf0
leaq 0x2e0(%rsp), %rdi
movq 0x428(%rsp), %rsi
callq 0xddf0
leaq 0x2e8(%rsp), %rdi
movq 0x3b8(%rsp), %rsi
callq 0xddf0
movq 0x48(%rsp), %rax
movq %rax, 0x2f0(%rsp)
movq $0x4, 0x2f8(%rsp)
leaq 0x2cf(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0xde20
movq 0x50(%rsp), %rcx
movq 0x2f0(%rsp), %rsi
movq 0x2f8(%rsp), %rdx
leaq 0x300(%rsp), %rdi
callq 0xde30
jmp 0x36261
movq 0x40(%rsp), %rdx
movq 0x58(%rsp), %rdi
leaq 0x320(%rsp), %rsi
leaq 0x300(%rsp), %rcx
callq 0x73c0
movq %rax, 0x38(%rsp)
jmp 0x36287
leaq 0x300(%rsp), %rdi
callq 0xd9c0
leaq 0x2cf(%rsp), %rdi
callq 0xdec0
leaq 0x320(%rsp), %rdi
callq 0x46e8
leaq 0x31f(%rsp), %rdi
callq 0x43b0
movq 0x38(%rsp), %rax
movq %rax, 0x340(%rsp)
movq 0x340(%rsp), %rax
movl $0x0, (%rax)
movq 0x340(%rsp), %rdi
addq $0x30, %rdi
leaq 0x1ae32(%rip), %rsi     # 0x5111b
callq 0x44a0
movq 0x520(%rsp), %rsi
addq $0x10, %rsi
leaq 0x290(%rsp), %rdi
callq 0x4180
movq 0x4a8(%rsp), %rsi
addq $0x10, %rsi
leaq 0x270(%rsp), %rdi
callq 0x4180
jmp 0x36322
movq 0x428(%rsp), %rsi
addq $0x10, %rsi
leaq 0x250(%rsp), %rdi
callq 0x4180
jmp 0x3633d
movq 0x3b8(%rsp), %rsi
addq $0x10, %rsi
leaq 0x230(%rsp), %rdi
callq 0x4180
jmp 0x36358
movq 0x340(%rsp), %rsi
addq $0x10, %rsi
leaq 0x210(%rsp), %rdi
callq 0x4180
jmp 0x36373
movq 0x528(%rsp), %rsi
leaq 0x1a8(%rsp), %rdi
callq 0xfb20
jmp 0x3638a
movq %rsp, %rax
leaq 0x1a8(%rsp), %rcx
movq %rcx, (%rax)
leaq 0x2b0(%rsp), %rdi
leaq 0x290(%rsp), %rsi
leaq 0x270(%rsp), %rdx
leaq 0x250(%rsp), %rcx
leaq 0x230(%rsp), %r8
leaq 0x210(%rsp), %r9
callq 0x159c0
jmp 0x363cf
leaq 0x1a8(%rsp), %rdi
callq 0xd490
leaq 0x210(%rsp), %rdi
callq 0x46e8
leaq 0x230(%rsp), %rdi
callq 0x46e8
leaq 0x250(%rsp), %rdi
callq 0x46e8
leaq 0x270(%rsp), %rdi
callq 0x46e8
leaq 0x290(%rsp), %rdi
callq 0x46e8
movq 0x530(%rsp), %rdi
addq $0x20, %rdi
movq %rdi, 0x28(%rsp)
callq 0xe380
movq %rax, 0x198(%rsp)
leaq 0x1a0(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0xe3b0
leaq 0x2b0(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0xe3f0
movq 0x20(%rsp), %rdi
movq %rax, 0x190(%rsp)
callq 0xe380
movq 0x28(%rsp), %rdi
movq %rax, 0x188(%rsp)
movq 0x1a0(%rsp), %rsi
movq 0x190(%rsp), %rdx
movq 0x188(%rsp), %rcx
callq 0xe2c0
movq %rax, 0x30(%rsp)
jmp 0x364a5
movq 0x30(%rsp), %rax
movq %rax, 0x180(%rsp)
movq 0x530(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x538(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x428(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x528(%rsp), %rsi
addq $0x20, %rsi
leaq 0x160(%rsp), %rdi
callq 0x4180
jmp 0x364f4
movq 0x18(%rsp), %rcx
movq 0x10(%rsp), %rdx
movq 0x8(%rsp), %rsi
movq 0x130(%rsp), %rdi
leaq 0x160(%rsp), %r8
callq 0x37870
jmp 0x3651a
leaq 0x160(%rsp), %rdi
callq 0x46e8
movq 0x528(%rsp), %rsi
addq $0x20, %rsi
movq 0x428(%rsp), %rdi
addq $0x30, %rdi
callq 0x4050
jmp 0x36546
movq 0x428(%rsp), %rax
movb $0x1, 0x50(%rax)
movq 0x520(%rsp), %rax
movl $0x0, (%rax)
movq 0x520(%rsp), %rdi
addq $0x30, %rdi
leaq 0x1aba8(%rip), %rsi     # 0x5111b
callq 0x44a0
jmp 0x3657a
movq 0x520(%rsp), %rax
movb $0x0, 0x50(%rax)
leaq 0x2b0(%rsp), %rdi
callq 0xd550
addq $0x548, %rsp            # imm = 0x548
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
leaq 0x4e0(%rsp), %rdi
callq 0xd9c0
leaq 0x500(%rsp), %rdi
callq 0x46e8
jmp 0x368f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
leaq 0x4b0(%rsp), %rdi
callq 0x46e8
jmp 0x368f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x3662b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
leaq 0x470(%rsp), %rdi
callq 0xd9c0
leaq 0x457(%rsp), %rdi
callq 0xdec0
leaq 0x488(%rsp), %rdi
callq 0x46e8
jmp 0x368f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
leaq 0x430(%rsp), %rdi
callq 0x46e8
jmp 0x368f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x366d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x366bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
leaq 0x3e8(%rsp), %rdi
callq 0xd9c0
leaq 0x3c7(%rsp), %rdi
callq 0xdec0
leaq 0x408(%rsp), %rdi
callq 0x46e8
leaq 0x407(%rsp), %rdi
callq 0x43b0
jmp 0x368f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x36750
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x36736
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
leaq 0x378(%rsp), %rdi
callq 0xd9c0
leaq 0x34f(%rsp), %rdi
callq 0xdec0
leaq 0x398(%rsp), %rdi
callq 0x46e8
leaq 0x397(%rsp), %rdi
callq 0x43b0
jmp 0x368f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x367c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x367af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
leaq 0x300(%rsp), %rdi
callq 0xd9c0
leaq 0x2cf(%rsp), %rdi
callq 0xdec0
leaq 0x320(%rsp), %rdi
callq 0x46e8
leaq 0x31f(%rsp), %rdi
callq 0x43b0
jmp 0x368f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x368a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x36897
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x3688a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x3687d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x36870
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
leaq 0x1a8(%rsp), %rdi
callq 0xd490
leaq 0x210(%rsp), %rdi
callq 0x46e8
leaq 0x230(%rsp), %rdi
callq 0x46e8
leaq 0x250(%rsp), %rdi
callq 0x46e8
leaq 0x270(%rsp), %rdi
callq 0x46e8
leaq 0x290(%rsp), %rdi
callq 0x46e8
jmp 0x368f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x368ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
leaq 0x160(%rsp), %rdi
callq 0x46e8
leaq 0x2b0(%rsp), %rdi
callq 0xd550
movq 0x4d8(%rsp), %rdi
callq 0x45f0
nopw %cs:(%rax,%rax)