// File: /workspace/github_cpp_makefile_star2_O3/Merulo[P]CompilerJFTT/src/IRs/ThirdIR.cpp
// Function: ThirdIR::legalizeJumpWithEqualZero(Block&)
void ThirdIR::legalizeJumpWithEqualZero(Block& b)
{
    Line lastLine = b.lines.back();
    b.lines.clear();

    std::swap(b.blockIfFalse, b.blockIfTrue);
    std::string argument = lastLine.one;
    if (!_symbolTable->isConst(argument))
    {
        Line l;
        l.operation = "JUMP";
        l.two = "#" + b.blockIfFalse;
        b.lines.push_back(l);
        return;
    }
    argument = lastLine.two;
    
    Line l;
    l.operation = "JZERO";
    l.one = argument;
    l.two = "#" + b.blockIfFalse;
    b.lines.push_back(l);

    Line l2;
    l2.operation = "JUMP";
    l2.two = "#" + b.blockIfTrue;
    b.lines.push_back(l2);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movq %rsi, %r14
movq %rdi, %r13
movq 0x28(%rsi), %r15
leaq 0x98(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq -0x68(%r15), %rsi
movq -0x60(%r15), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %rdi
callq 0xc7aa
leaq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %r12
movq %r12, -0x10(%r12)
movq -0x48(%r15), %rsi
movq -0x40(%r15), %rdx
addq %rsi, %rdx
callq 0xc7aa
leaq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
movq %rax, -0x10(%rax)
movq -0x28(%r15), %rsi
movq -0x20(%r15), %rdx
addq %rsi, %rdx
callq 0xc7aa
leaq 0x20(%r14), %rbx
movl -0x8(%r15), %eax
movl %eax, 0xe8(%rsp)
movq 0x20(%r14), %rsi
movq %rbx, %rdi
callq 0x19de2
leaq 0x58(%r14), %r15
addq $0x38, %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x41f0
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
addq %rsi, %rdx
movq %rsp, %rdi
callq 0xc7aa
movq (%r13), %r13
leaq 0x100(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
addq %rsi, %rdx
leaq 0xf0(%rsp), %rdi
callq 0xc7aa
leaq 0xf0(%rsp), %rsi
movq %r13, %rdi
callq 0x1a6f8
movl %eax, %ebp
movq 0xf0(%rsp), %rdi
cmpq %r12, %rdi
je 0x2f99d
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x42a0
testb %bpl, %bpl
je 0x2fbeb
movq %rsp, %rdi
leaq 0xc8(%rsp), %rsi
callq 0x4170
leaq 0x30(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x50(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x70(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq %rax, -0x8(%rbp)
movb %al, (%rbp)
leaq 0x778f(%rip), %rcx      # 0x3717c
leaq 0x20(%rsp), %rdi
movl $0x5, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x4440
leaq 0x40(%rsp), %rdi
movq %rsp, %rsi
callq 0x4170
leaq 0x7b46(%rip), %rsi      # 0x3755b
leaq 0x110(%rsp), %rdi
movq %r15, %rdx
callq 0x5344
leaq 0x60(%rsp), %rdi
leaq 0x110(%rsp), %r15
movq %r15, %rsi
callq 0x4380
movq (%r15), %rdi
leaq 0x120(%rsp), %r15
cmpq %r15, %rdi
je 0x2fa5a
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x1f6f6
leaq 0x140(%rsp), %r12
movq %r15, -0x30(%r12)
xorl %eax, %eax
movq %rax, -0x28(%r12)
movb %al, -0x20(%r12)
movq %r12, -0x10(%r12)
movq %rax, -0x8(%r12)
movb %al, (%r12)
leaq 0x160(%rsp), %r13
movq %r13, -0x10(%r13)
movq %rax, -0x8(%r13)
movb %al, (%r13)
leaq 0x76e3(%rip), %rcx      # 0x3718c
leaq 0x110(%rsp), %rdi
movl $0x4, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x4440
leaq 0x7a94(%rip), %rsi      # 0x3755b
leaq 0x178(%rsp), %rdi
movq %r14, %rdx
callq 0x5344
leaq 0x150(%rsp), %rdi
leaq 0x178(%rsp), %r14
movq %r14, %rsi
callq 0x4380
movq (%r14), %rdi
leaq 0x188(%rsp), %rax
cmpq %rax, %rdi
je 0x2fb0f
movq 0x188(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x110(%rsp), %rsi
movq %rbx, %rdi
callq 0x1f6f6
movq 0x150(%rsp), %rdi
cmpq %r13, %rdi
je 0x2fb3c
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x130(%rsp), %rdi
cmpq %r12, %rdi
je 0x2fb59
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x110(%rsp), %rdi
cmpq %r15, %rdi
leaq 0x98(%rsp), %rbx
leaq 0x10(%rsp), %r14
leaq 0xb8(%rsp), %r15
leaq 0xd8(%rsp), %r12
je 0x2fb93
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x60(%rsp), %rdi
cmpq %rbp, %rdi
je 0x2fbaa
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x2fbc6
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x2fcf7
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x2fcf7
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
xorl %eax, %eax
movq %rax, -0x8(%r12)
movb %al, (%r12)
leaq 0x50(%rsp), %r13
movq %r13, -0x10(%r13)
movq %rax, -0x8(%r13)
movb %al, (%r13)
leaq 0x70(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq %rax, -0x8(%rbp)
movb %al, (%rbp)
leaq 0x7564(%rip), %rcx      # 0x3718c
leaq 0x20(%rsp), %rdi
movl $0x4, %r8d
xorl %esi, %esi
xorl %edx, %edx
callq 0x4440
leaq 0x7918(%rip), %rsi      # 0x3755b
leaq 0x110(%rsp), %rdi
movq %r15, %rdx
callq 0x5344
leaq 0x60(%rsp), %rdi
leaq 0x110(%rsp), %r14
movq %r14, %rsi
callq 0x4380
movq (%r14), %rdi
leaq 0x120(%rsp), %rax
cmpq %rax, %rdi
je 0x2fc88
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x1f6f6
movq 0x60(%rsp), %rdi
cmpq %rbp, %rdi
je 0x2fcac
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x40(%rsp), %rdi
cmpq %r13, %rdi
je 0x2fcc3
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x2fcda
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x98(%rsp), %rbx
leaq 0x10(%rsp), %r14
leaq 0xb8(%rsp), %r15
leaq 0xd8(%rsp), %r12
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x2fd0d
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0xc8(%rsp), %rdi
cmpq %r12, %rdi
je 0x2fd2a
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2fd47
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x88(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2fd64
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x42a0
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2fd82
jmp 0x2fe07
jmp 0x2fe07
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
callq 0xbca2
jmp 0x2fe0a
jmp 0x2fe07
movq %rax, %rbx
movq 0xf0(%rsp), %rdi
cmpq %r12, %rdi
je 0x2fe19
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x2fe19
movq %rax, %rbx
jmp 0x2fe34
movq %rbx, %r14
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r12, %rdi
je 0x2fde8
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x2fde8
movq %rbx, %r14
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r14, %rdi
je 0x2fe41
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x2fe41
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xbca2
jmp 0x2fe19
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x2fe34
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x88(%rsp), %rdi
callq 0xbca2
movq %rbx, %rdi
callq 0x44c0
nop