// File: /workspace/github_cpp_makefile_star2_O1/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, %rax
movq %rsi, %r12
movq %rdi, 0x28(%rsp)
addq $0x68, %r12
cmpq 0x28(%rdx), %r12
movq %rdx, 0x50(%rsp)
je 0x236a3
leaq 0x18(%rsp), %r15
leaq 0x160f9(%rip), %rbx     # 0x395bd
leaq 0x30(%rsp), %rbp
leaq 0x40(%r12), %r13
movq 0x48(%r12), %rdx
cmpq 0x8(%r14), %rdx
jne 0x234f6
testq %rdx, %rdx
je 0x23767
movq (%r14), %rsi
movq (%r13), %rdi
callq 0x42b0
testl %eax, %eax
je 0x23767
movq %rbp, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x5474
movq %rbp, %rdi
leaq 0x14ff6(%rip), %rsi     # 0x38504
callq 0x4510
movq %r15, 0x8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x23536
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x2353d
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, %r13
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x23583
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x2359f
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42a0
cmpq $-0x1, %r13
jne 0x23767
movq %rbp, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x5474
movq %rbp, %rdi
leaq 0x14f43(%rip), %rsi     # 0x38504
callq 0x4510
movq %r15, 0x8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x235e9
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x235f0
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 0x2363b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x23657
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42a0
cmpq $-0x1, %rbx
jne 0x23767
movq 0x28(%r12), %rdx
cmpq 0x8(%r14), %rdx
jne 0x23689
testq %rdx, %rdx
je 0x238c9
movq (%r14), %rsi
movq (%r13), %rdi
callq 0x42b0
testl %eax, %eax
je 0x238c9
addq $0x68, %r12
movq 0x50(%rsp), %rax
cmpq 0x28(%rax), %r12
leaq 0x15f20(%rip), %rbx     # 0x395bd
jne 0x234c9
movq 0x80(%rax), %rdx
testq %rdx, %rdx
je 0x2376e
leaq 0x108(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x78(%rax), %rsi
addq %rsi, %rdx
leaq 0xf8(%rsp), %rbx
movq %rbx, %rdi
callq 0xca12
movq 0x28(%rsp), %r12
leaq 0x10(%r12), %rdx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2be3a
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2370b
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 0xca12
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x239cc
movl %eax, %ebx
movq 0xd8(%rsp), %rdi
cmpq %r15, %rdi
je 0x238ee
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x238ee
xorl %ebx, %ebx
jmp 0x238ee
movq 0x60(%rax), %rdx
testq %rdx, %rdx
movq 0x28(%rsp), %rbp
je 0x238ec
leaq 0xc8(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x58(%rax), %rsi
addq %rsi, %rdx
leaq 0xb8(%rsp), %rbx
movq %rbx, %rdi
callq 0xca12
leaq 0x10(%rbp), %r12
movq %rbp, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x2be3a
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x237d5
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 0xca12
movq %rbp, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x239cc
movl %eax, %ebx
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0x23828
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x88(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x50(%rsp), %rax
movq 0x38(%rax), %rsi
movq 0x40(%rax), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %r15
movq %r15, %rdi
callq 0xca12
movq %rbp, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2be3a
movq %rax, %r15
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0x2387c
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 0xca12
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x239cc
movl %eax, %ebp
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x238c4
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42a0
andb %bpl, %bl
jmp 0x238ee
movq 0x28(%rsp), %rbx
leaq 0xb8(%rbx), %rdi
movq %r12, %rsi
callq 0x243bc
addq $0xc0, %rbx
cmpq %rbx, %rax
sete %bl
jmp 0x238ee
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 0x239c4
movq 0x68(%rsp), %rsi
jmp 0x239bc
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r13, %rdi
je 0x239c4
movq 0x88(%rsp), %rsi
jmp 0x239bc
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0x239c4
movq 0xa8(%rsp), %rsi
jmp 0x239bc
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x239c4
movq 0xc8(%rsp), %rsi
jmp 0x239bc
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r15, %rdi
je 0x239c4
movq 0xe8(%rsp), %rsi
jmp 0x239bc
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
cmpq %r15, %rdi
je 0x239c4
movq 0x108(%rsp), %rsi
jmp 0x239bc
jmp 0x239a5
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x239c4
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x44c0