// File: /workspace/github_cpp_makefile_star2_O1/Merulo[P]CompilerJFTT/src/IRs/FifthIR.cpp
// Function: FifthIR::removeJumps()
void FifthIR::removeJumps()
{
    for(auto b = _blocks.begin(); b != _blocks.end(); b++)
    {
        if (onlyComments(*b))
        {
            if ((*b).lines.back().operation == "JUMP")
            {
                std::string arg = (*b).lines.back().two;
                arg.erase(0, 1);
                Block& current = getBlockByName(arg, _blocks);
                replaceJump((*b), current);  
                b = _blocks.erase(b);
                b--;
            }
        }
    }
    for(auto it = _blocks.begin() + 1; it != _blocks.end(); it++)
    {
        Block& previous = *(it-1);
        Block& current = *it;
        if(previous.lines.back().two == "#" + current.blockName)
        {
            previous.lines.erase(previous.lines.end() - 1);
            if (onlyComments(previous))
            {
                replaceJump(previous, current);
            }
        }
    }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movq 0x10(%rdi), %r14
cmpq 0x18(%rdi), %r14
je 0x2caba
leaq 0x10(%rbx), %r15
leaq 0xb7d0(%rip), %r12      # 0x3818c
leaq 0x28(%rsp), %rbp
movq %r14, %rsi
callq 0x2d47e
testb %al, %al
je 0x2caa9
movq 0x28(%r14), %rdi
addq $-0x68, %rdi
movq %r12, %rsi
callq 0x40d0
testl %eax, %eax
jne 0x2caa9
movq 0x28(%r14), %rax
leaq 0x18(%rsp), %rcx
movq %rcx, 0x8(%rsp)
movq -0x28(%rax), %rsi
movq -0x20(%rax), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0xca12
movl $0x1, %edx
movq %r13, %rdi
xorl %esi, %esi
callq 0x4090
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0xca12
movq %rbx, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x2be3a
movq %rax, %r13
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2ca6a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x2d4e8
movq %r15, %rdi
movq %r14, %rsi
callq 0x241c0
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2caa2
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42a0
addq $-0xa0, %r14
addq $0xa0, %r14
cmpq 0x18(%rbx), %r14
jne 0x2c9c1
movq 0x10(%rbx), %r14
leaq 0xa0(%r14), %rax
cmpq 0x18(%rbx), %rax
je 0x2cb81
leaq 0xba85(%rip), %r15      # 0x3855b
leaq 0x8(%rsp), %r12
movq %r14, %r13
addq $0xa0, %r14
movq 0x28(%r13), %rbp
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x5474
movq -0x20(%rbp), %rdx
cmpq 0x10(%rsp), %rdx
jne 0x2cb1d
testq %rdx, %rdx
je 0x2cb21
movq 0x8(%rsp), %rsi
movq -0x28(%rbp), %rdi
callq 0x42b0
testl %eax, %eax
sete %bpl
jmp 0x2cb24
xorl %ebp, %ebp
jmp 0x2cb24
movb $0x1, %bpl
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2cb40
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42a0
testb %bpl, %bpl
je 0x2cb70
leaq 0x20(%r13), %rdi
movq 0x28(%r13), %rsi
addq $-0x68, %rsi
callq 0x242a4
movq %r13, %rsi
callq 0x2d47e
testb %al, %al
je 0x2cb70
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x2d4e8
addq $0x140, %r13            # imm = 0x140
cmpq 0x18(%rbx), %r13
jne 0x2cadb
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2cbb5
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2cbb8
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x2cbb8
jmp 0x2cbb5
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2cbd4
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x44c0