// File: /workspace/github_cpp_makefile_star2_O1/Merulo[P]CompilerJFTT/src/IRs/FourthIR.cpp
// Function: FourthIR::handleMod(RegisterBlock&, Block&, Line&)
void FourthIR::handleMod(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;

    if (_symbolTable->isConst(l.two) && _symbolTable->getConstValue(l.two) == "2")
    {
        auto lines = MathOperations::generateModuloTwo(registerB.name, l);
        b.insert(lines);
        return;
    }

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

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

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

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

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x328, %rsp            # imm = 0x328
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %rbp
movq %rdi, %r13
leaq 0x228(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x20(%rcx), %rsi
movq 0x28(%rcx), %rdx
addq %rsi, %rdx
leaq 0x218(%rsp), %r15
movq %r15, %rdi
callq 0xca12
xorps %xmm0, %xmm0
leaq 0x1a0(%rsp), %rcx
movaps %xmm0, (%rcx)
movq $0x0, 0x10(%rcx)
movq %rbp, 0x30(%rsp)
movq %rbp, %rdi
movq %r15, %rsi
movq %r12, 0x10(%rsp)
movq %r12, %rdx
movl $0x1, %r8d
movl $0x1, %r9d
callq 0x7d06
movq %rax, %r15
movq 0x1a0(%rsp), %rdi
testq %rdi, %rdi
je 0x282e2
movq 0x1b0(%rsp), %rsi
subq %rdi, %rsi
callq 0x42a0
movq 0x218(%rsp), %rdi
cmpq %rbx, %rdi
je 0x282ff
movq 0x228(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x208(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
addq %rsi, %rdx
leaq 0x1f8(%rsp), %r12
movq %r12, %rdi
callq 0xca12
movq %r13, %rdi
movq %r15, %rcx
movq %r12, %r8
callq 0x28ed2
leaq 0x20(%r14), %r12
movq 0x1f8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x28355
movq 0x208(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %r15, %rdi
addq $0x30, %rdi
movq %r12, %rsi
callq 0x4170
movb $0x1, 0x50(%r15)
movq (%r13), %r12
leaq 0x1e8(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x40(%r14), %rsi
movq 0x48(%r14), %rdx
addq %rsi, %rdx
leaq 0x1d8(%rsp), %rbp
movq %rbp, %rdi
callq 0xca12
movq %r12, %rdi
movq %rbp, %rsi
callq 0x1a9b6
movl %eax, %ebp
testb %al, %al
je 0x28401
movq (%r13), %r12
leaq 0xd0(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x40(%r14), %rsi
movq 0x48(%r14), %rdx
addq %rsi, %rdx
leaq 0xc0(%rsp), %rdi
callq 0xca12
leaq 0x308(%rsp), %rdi
leaq 0xc0(%rsp), %rdx
movq %r12, %rsi
callq 0x1b276
leaq 0x11355(%rip), %rsi     # 0x39741
leaq 0x308(%rsp), %rdi
callq 0x40d0
testl %eax, %eax
sete %r12b
jmp 0x28404
xorl %r12d, %r12d
testb %bpl, %bpl
je 0x2844b
leaq 0x318(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2842a
movq 0x318(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0xd0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2844b
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x1d8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x28468
movq 0x1e8(%rsp), %rsi
incq %rsi
callq 0x42a0
testb %r12b, %r12b
je 0x285b7
leaq 0x190(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x10(%r15), %rsi
movq 0x18(%r15), %rdx
addq %rsi, %rdx
leaq 0x180(%rsp), %rdi
callq 0xca12
leaq 0x2b0(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x2a0(%rsp), %rdi
callq 0xca12
leaq 0x2c0(%rsp), %rdi
leaq 0x2d0(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
addq %rsi, %rdx
callq 0xca12
leaq 0x2e0(%rsp), %rdi
leaq 0x2f0(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x40(%r14), %rsi
movq 0x48(%r14), %rdx
addq %rsi, %rdx
callq 0xca12
movl 0x60(%r14), %eax
leaq 0x2a0(%rsp), %rdx
movl %eax, 0x60(%rdx)
leaq 0x18(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0x17aaa
movq 0x2e0(%rsp), %rdi
cmpq %r13, %rdi
je 0x2853f
movq 0x2f0(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x2c0(%rsp), %rdi
cmpq %r15, %rdi
je 0x2855c
movq 0x2d0(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x2a0(%rsp), %rdi
cmpq %rbx, %rdi
je 0x28579
movq 0x2b0(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x180(%rsp), %rdi
cmpq %r12, %rdi
je 0x28596
movq 0x190(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x10(%rsp), %rdi
movq 0x28(%rdi), %rsi
addq $0x20, %rdi
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rcx
callq 0xc3f4
jmp 0x28a65
leaq 0x170(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x40(%r14), %rsi
movq 0x48(%r14), %rdx
addq %rsi, %rdx
leaq 0x160(%rsp), %rdi
callq 0xca12
leaq 0x18(%rsp), %rsi
movq %r15, (%rsi)
leaq 0xa8(%rsp), %rdi
leaq 0xf(%rsp), %rcx
movl $0x1, %edx
callq 0xc2ee
leaq 0x160(%rsp), %rsi
leaq 0xa8(%rsp), %rcx
movq 0x30(%rsp), %rdi
movq 0x10(%rsp), %rdx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0x7d06
movq %rax, %rbp
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x28642
movq 0xb8(%rsp), %rsi
subq %rdi, %rsi
callq 0x42a0
movq 0x160(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2865f
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x1c8(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x40(%r14), %rsi
movq 0x48(%r14), %rdx
addq %rsi, %rdx
leaq 0x1b8(%rsp), %r12
movq %r12, %rdi
callq 0xca12
movq %r13, %rdi
movq %rbp, %rcx
movq %r12, %r8
callq 0x28ed2
leaq 0x40(%r14), %r12
movq 0x1b8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x286b5
movq 0x1c8(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbp, %rdi
addq $0x30, %rdi
movq %r12, %rsi
callq 0x4170
leaq 0x150(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0xfe60(%rip), %rsi      # 0x38537
leaq 0xfe64(%rip), %rdx      # 0x38542
leaq 0x140(%rsp), %rdi
callq 0x54fc
leaq 0x18(%rsp), %rsi
movq %r15, (%rsi)
movq %rbp, 0x8(%rsi)
leaq 0x90(%rsp), %rdi
leaq 0xf(%rsp), %rcx
movl $0x2, %edx
callq 0xc2ee
leaq 0x140(%rsp), %rsi
leaq 0x90(%rsp), %rcx
movq 0x30(%rsp), %rdi
movq 0x10(%rsp), %rdx
callq 0x6d22
movq %rax, %r13
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x2874d
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x42a0
movq 0x140(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2876a
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x42a0
movl $0x0, (%r13)
movq %r13, %rdi
addq $0x30, %rdi
movq 0x38(%r13), %rdx
leaq 0xf95f(%rip), %rcx      # 0x380e3
xorl %esi, %esi
xorl %r8d, %r8d
callq 0x4440
leaq 0x130(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0xfdae(%rip), %rsi      # 0x3854f
leaq 0xfdb2(%rip), %rdx      # 0x3855a
leaq 0x120(%rsp), %rdi
callq 0x54fc
leaq 0x18(%rsp), %rsi
movq %r15, (%rsi)
movq %rbp, 0x8(%rsi)
movq %r13, 0x10(%rsi)
leaq 0x78(%rsp), %rdi
leaq 0xf(%rsp), %rcx
movl $0x3, %edx
callq 0xc2ee
leaq 0x120(%rsp), %rsi
leaq 0x78(%rsp), %rcx
movq 0x30(%rsp), %rdi
movq 0x10(%rsp), %rdx
callq 0x6d22
movq %rax, %r12
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x28812
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x42a0
movq 0x120(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2882f
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x42a0
movl $0x0, (%r12)
movq %r12, %rdi
addq $0x30, %rdi
movq 0x38(%r12), %rdx
leaq 0xf899(%rip), %rcx      # 0x380e3
xorl %esi, %esi
xorl %r8d, %r8d
callq 0x4440
leaq 0x110(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x10(%r15), %rsi
movq 0x18(%r15), %rdx
addq %rsi, %rdx
leaq 0x100(%rsp), %rdi
callq 0xca12
leaq 0xf0(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x10(%rbp), %rsi
movq 0x18(%rbp), %rdx
addq %rsi, %rdx
leaq 0xe0(%rsp), %rdi
callq 0xca12
leaq 0x68(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x10(%r13), %rsi
movq 0x18(%r13), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %rdi
callq 0xca12
movq %rbx, %rbp
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x10(%r12), %rsi
movq 0x18(%r12), %rdx
addq %rsi, %rdx
leaq 0x38(%rsp), %rdi
callq 0xca12
leaq 0x248(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x238(%rsp), %rdi
callq 0xca12
movq %r15, %r13
leaq 0x258(%rsp), %rdi
leaq 0x268(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
addq %rsi, %rdx
callq 0xca12
leaq 0x278(%rsp), %rdi
leaq 0x288(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x40(%r14), %rsi
movq 0x48(%r14), %rdx
addq %rsi, %rdx
callq 0xca12
movl 0x60(%r14), %eax
leaq 0x238(%rsp), %r9
movl %eax, 0x60(%r9)
leaq 0x18(%rsp), %rdi
leaq 0x100(%rsp), %rsi
leaq 0xe0(%rsp), %rdx
leaq 0x58(%rsp), %rcx
leaq 0x38(%rsp), %r8
callq 0x142a6
movq 0x278(%rsp), %rdi
cmpq %r15, %rdi
je 0x2899d
movq 0x288(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x258(%rsp), %rdi
cmpq %r12, %rdi
je 0x289ba
movq 0x268(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x238(%rsp), %rdi
cmpq %rbx, %rdi
je 0x289d7
movq 0x248(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x289f3
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x28a0f
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0xe0(%rsp), %rdi
cmpq %r13, %rdi
je 0x28a2c
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x100(%rsp), %rdi
cmpq %rbp, %rdi
je 0x28a49
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x10(%rsp), %rdi
movq 0x28(%rdi), %rsi
addq $0x20, %rdi
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rcx
callq 0xc3f4
leaq 0x18(%rsp), %rdi
callq 0xbf5e
addq $0x328, %rsp            # imm = 0x328
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x28bd2
movq %rax, %r14
leaq 0x238(%rsp), %rdi
callq 0xbf10
jmp 0x28ae2
movq %rax, %r14
movq 0x258(%rsp), %rdi
cmpq %r12, %rdi
je 0x28abd
movq 0x268(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x28abd
movq %rax, %r14
movq 0x238(%rsp), %rdi
cmpq %rbx, %rdi
je 0x28ae2
movq 0x248(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x28ae2
movq %r15, %r13
movq %rax, %r14
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x28b06
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x28b06
movq %r15, %r13
movq %rax, %r14
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x28b2d
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x28b2d
movq %r15, %r13
movq %rbx, %rbp
movq %rax, %r14
movq 0xe0(%rsp), %rdi
cmpq %r13, %rdi
je 0x28b52
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x28b52
movq %rbx, %rbp
movq %rax, %r14
movq 0x100(%rsp), %rdi
cmpq %rbp, %rdi
je 0x28d80
movq 0x110(%rsp), %rsi
jmp 0x28d78
movq %rax, %r14
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x28b92
movq 0x88(%rsp), %rsi
subq %rdi, %rsi
callq 0x42a0
jmp 0x28b92
movq %rax, %r14
movq 0x120(%rsp), %rdi
cmpq %rbx, %rdi
je 0x28d80
movq 0x130(%rsp), %rsi
jmp 0x28d78
movq %rax, %r14
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x28be7
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x42a0
jmp 0x28be7
movq %rax, %r14
leaq 0x18(%rsp), %rdi
callq 0xbf5e
jmp 0x28d80
movq %rax, %r14
movq 0x140(%rsp), %rdi
cmpq %rbx, %rdi
je 0x28d80
movq 0x150(%rsp), %rsi
jmp 0x28d78
movq %rax, %r14
leaq 0x2a0(%rsp), %rdi
callq 0xbf10
jmp 0x28cc5
movq %rax, %r14
movq 0x1b8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x28d80
movq 0x1c8(%rsp), %rsi
jmp 0x28d78
movq %rax, %r14
movq 0x2c0(%rsp), %rdi
cmpq %r15, %rdi
je 0x28c82
movq 0x2d0(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x28c82
movq %rax, %r14
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x28ca4
movq 0xb8(%rsp), %rsi
subq %rdi, %rsi
callq 0x42a0
jmp 0x28ca4
movq %rax, %r14
movq 0x2a0(%rsp), %rdi
cmpq %rbx, %rdi
je 0x28cc5
movq 0x2b0(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x28cc5
movq %rax, %r14
movq 0x160(%rsp), %rdi
cmpq %rbx, %rdi
je 0x28d80
movq 0x170(%rsp), %rsi
jmp 0x28d78
movq %rax, %r14
movq 0x180(%rsp), %rdi
cmpq %r12, %rdi
je 0x28d80
movq 0x190(%rsp), %rsi
jmp 0x28d78
movq %rax, %r14
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x28d12
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x28d12
jmp 0x28d0f
movq %rax, %r14
movq 0x1d8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x28d80
movq 0x1e8(%rsp), %rsi
jmp 0x28d78
movq %rax, %r14
movq 0x1f8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x28d80
movq 0x208(%rsp), %rsi
jmp 0x28d78
movq %rax, %r14
movq 0x1a0(%rsp), %rdi
testq %rdi, %rdi
je 0x28d63
movq 0x1b0(%rsp), %rsi
subq %rdi, %rsi
callq 0x42a0
movq 0x218(%rsp), %rdi
cmpq %rbx, %rdi
je 0x28d80
movq 0x228(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %r14, %rdi
callq 0x44c0