// File: /workspace/github_cpp_makefile_star2_O3/Merulo[P]CompilerJFTT/src/IRs/ThirdIR.cpp
// Function: ThirdIR::legalizeJMR(Block&, bool)
void ThirdIR::legalizeJMR(Block& b, bool inc)
{
    if (checkZeroJump(b) && !inc)
    {
        legalizeJumpWithZero(b);
        return;
    }
    if (checkZeroJump(b) && inc)
    {
        legalizeJumpWithEqualZero(b);
        return;
    }

    Line lastLine = b.lines.back();
    b.lines.pop_back();

    std::string var = calculateDiff(b, lastLine.one, lastLine.two, inc);
    insertJumps(b, var);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
callq 0x2edc6
xorb $0x1, %al
orb %bpl, %al
je 0x2e265
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2edc6
andb %bpl, %al
cmpb $0x1, %al
jne 0x2e281
movq %r14, %rdi
movq %rbx, %rsi
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2f86a
movq %r14, %rdi
movq %rbx, %rsi
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2f2c0
movq 0x28(%rbx), %r15
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
movq -0x68(%r15), %rsi
movq -0x60(%r15), %rdx
addq %rsi, %rdx
movq %rsp, %rdi
callq 0xc7aa
leaq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %r13
movq %r13, -0x10(%r13)
movq -0x48(%r15), %rsi
movq -0x40(%r15), %rdx
addq %rsi, %rdx
callq 0xc7aa
leaq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
movq -0x28(%r15), %rsi
movq -0x20(%r15), %rdx
addq %rsi, %rdx
callq 0xc7aa
leaq 0x20(%rbx), %rdi
movl -0x8(%r15), %eax
movl %eax, 0x60(%rsp)
movq 0x28(%rbx), %rsi
addq $-0x68, %rsi
movq %rsi, 0x28(%rbx)
callq 0xced4
leaq 0xb8(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
leaq 0xa8(%rsp), %rdi
callq 0xc7aa
leaq 0x98(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %rdi
callq 0xc7aa
movzbl %bpl, %r9d
leaq 0xc8(%rsp), %rdi
leaq 0xa8(%rsp), %rcx
leaq 0x88(%rsp), %r8
movq %r14, %rsi
movq %rbx, %rdx
callq 0x2e892
movq 0x88(%rsp), %rdi
cmpq %r12, %rdi
je 0x2e38b
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2e3a8
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x78(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %rdi
callq 0xc7aa
leaq 0x68(%rsp), %rdx
movq %rbx, %rsi
callq 0x2eb68
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x2e3f2
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0xd8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2e413
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x2e42f
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0x2e446
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42a0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x2e461
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42a0
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x2e492
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x2e492
movq %rax, %rbx
leaq 0xd8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2e4f4
movq 0xd8(%rsp), %rsi
jmp 0x2e4e7
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r12, %rdi
je 0x2e4d2
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x2e4d2
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2e4f4
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x2e4f4
movq %rax, %rbx
movq %rsp, %rdi
callq 0xbca2
movq %rbx, %rdi
callq 0x44c0
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0x2e523
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x2e523
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x2e4fc
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x2e4fc