// File: /workspace/github_cpp_makefile_star2_O3/Merulo[P]CompilerJFTT/src/IRs/SecondIR.cpp
// Function: SecondIR::canRemove(__gnu_cxx::__normal_iterator<Line*, std::vector<Line, std::allocator<Line>>>, Block&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool SecondIR::canRemove(std::vector<Line>::iterator line, Block& b, std::string name)
{
    line++;
    for (; line != b.lines.end(); line++)
    {
        if(line->two == name)
        {
            return false;
        }
        if (line->two.find("(" + name + ")") != std::string::npos)
        {
            return false;
        }
        if (line->one.find("(" + name + ")") != std::string::npos)
        {
            return false;
        }  
        if (line->one == name)
        {
            if (_banned.find(line->operation) != _banned.end())
            {
                return false;
            } 
            return true;
        }       
    }
    if (!b.blockJump.empty())
    {
        Block& nextBlock = getBlockByName(b.blockJump, _blocks);
        return canRemoveRecursive(nextBlock, name);
    }
    else if (!b.blockIfFalse.empty())
    {
        Block& blockTrue = getBlockByName(b.blockIfFalse, _blocks);
        bool r1 = canRemoveRecursive(blockTrue, name);  
        Block& blockFalse = getBlockByName(b.blockIfTrue, _blocks);
        bool r2 = canRemoveRecursive(blockFalse, name);  
        return r1 && r2;
    }
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rcx, %r14
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, 0x28(%rsp)
addq $0x68, %r12
cmpq 0x28(%rdx), %r12
je 0x2340b
leaq 0x18(%rsp), %r15
movq 0x8(%r14), %rbx
leaq 0x38(%rsp), %rbp
movq %r13, 0x30(%rsp)
leaq 0x40(%r12), %r13
cmpq %rbx, 0x48(%r12)
jne 0x2325a
testq %rbx, %rbx
je 0x234cf
movq (%r14), %rsi
movq (%r13), %rdi
movq %rbx, %rdx
callq 0x42b0
testl %eax, %eax
je 0x234cf
movq %rbp, %rdi
leaq 0x15359(%rip), %rsi     # 0x385bd
movq %r14, %rdx
callq 0x5344
movq %rbp, %rdi
leaq 0x1428e(%rip), %rsi     # 0x37504
callq 0x4510
movq %r15, 0x8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2329e
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x232a5
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rcx
movq %r13, %rdi
xorl %edx, %edx
callq 0x44a0
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x232eb
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x23307
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x42a0
cmpq $-0x1, %rbx
jne 0x234cf
movq %rbp, %rdi
leaq 0x152a2(%rip), %rsi     # 0x385bd
movq %r14, %rdx
callq 0x5344
movq %rbp, %rdi
leaq 0x141d7(%rip), %rsi     # 0x37504
callq 0x4510
movq %r15, 0x8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x23355
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x2335c
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x20(%r12), %r13
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rcx
movq %r13, %rdi
xorl %edx, %edx
callq 0x44a0
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x233a7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x233c3
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x42a0
cmpq $-0x1, %rbx
jne 0x234cf
movq 0x28(%r12), %rdx
movq 0x8(%r14), %rbx
cmpq %rbx, %rdx
jne 0x233f8
testq %rdx, %rdx
je 0x23636
movq (%r14), %rsi
movq (%r13), %rdi
callq 0x42b0
testl %eax, %eax
je 0x23636
addq $0x68, %r12
movq 0x30(%rsp), %r13
cmpq 0x28(%r13), %r12
jne 0x2322e
movq 0x80(%r13), %rdx
testq %rdx, %rdx
je 0x234d6
leaq 0x108(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x78(%r13), %rsi
addq %rsi, %rdx
leaq 0xf8(%rsp), %rbx
movq %rbx, %rdi
callq 0xc7aa
movq 0x28(%rsp), %r12
leaq 0x10(%r12), %rdx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2bb9e
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
cmpq %r15, %rdi
je 0x23473
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0xe8(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0xd8(%rsp), %r14
movq %r14, %rdi
callq 0xc7aa
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2373a
movl %eax, %ebx
movq 0xd8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2365b
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x2365b
xorl %ebx, %ebx
jmp 0x2365b
movq 0x60(%r13), %rdx
testq %rdx, %rdx
movq 0x28(%rsp), %rbp
je 0x23659
leaq 0xc8(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x58(%r13), %rsi
addq %rsi, %rdx
leaq 0xb8(%rsp), %rbx
movq %rbx, %rdi
callq 0xc7aa
leaq 0x10(%rbp), %r12
movq %rbp, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x2bb9e
movq %rax, %rbx
movq %r13, 0x30(%rsp)
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x23542
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0xa8(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %r13
movq %r13, %rdi
callq 0xc7aa
movq %rbp, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x2373a
movl %eax, %ebx
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0x23595
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x88(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x30(%rsp), %rax
movq 0x38(%rax), %rsi
movq 0x40(%rax), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %r15
movq %r15, %rdi
callq 0xc7aa
movq %rbp, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2bb9e
movq %rax, %r15
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0x235e9
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x68(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %r14
movq %r14, %rdi
callq 0xc7aa
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2373a
movl %eax, %ebp
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x23631
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42a0
andb %bpl, %bl
jmp 0x2365b
movq 0x28(%rsp), %rbx
leaq 0xb8(%rbx), %rdi
movq %r12, %rsi
callq 0x24168
addq $0xc0, %rbx
cmpq %rbx, %rax
sete %bl
jmp 0x2365b
movb $0x1, %bl
movl %ebx, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x23731
movq 0x68(%rsp), %rsi
jmp 0x23729
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0x23731
movq 0x88(%rsp), %rsi
jmp 0x23729
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0x23731
movq 0xa8(%rsp), %rsi
jmp 0x23729
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x23731
movq 0xc8(%rsp), %rsi
jmp 0x23729
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r15, %rdi
je 0x23731
movq 0xe8(%rsp), %rsi
jmp 0x23729
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
cmpq %r15, %rdi
je 0x23731
movq 0x108(%rsp), %rsi
jmp 0x23729
jmp 0x23712
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x23731
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x44c0
nop