// File: /workspace/github_cpp_makefile_star2_O3/Merulo[P]CompilerJFTT/src/IRs/FourthIR.cpp
// Function: FourthIR::recursiveUsageTest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, Block&)
bool FourthIR::recursiveUsageTest(std::string name, Block& b)
{
    if (b.visited)
    {
        return true;
    }
    b.visited = true;

    for(auto& l : b.lines)
    {
        if(l.two == name)
        {
            return false;
        }
        if (l.two.find("(" + name + ")") != std::string::npos)
        {
            return false;
        }
        if (l.one.find("(" + name + ")") != std::string::npos)
        {
            return false;
        }  
        if (l.one == name)
        {
            if (l.operation == "COPY")
            {
                return true;
            }
            if (l.operation == "CONST")
            {
                return true;
            }
            if (l.operation == "READ")
            {
                return true;
            }
            return false;
        }
    }
    if (!b.blockJump.empty())
    {
        Block& nextBlock = getPairByName(b.blockJump).block;
        return recursiveUsageTest(name, nextBlock);
    }
    else if (!b.blockIfFalse.empty())
    {
        Block& blockTrue = getPairByName(b.blockIfTrue).block;
        bool r1 = recursiveUsageTest(name, blockTrue);  
        Block& blockFalse = getPairByName(b.blockIfFalse).block;
        bool r2 = recursiveUsageTest(name, blockFalse);  
        return r1 && r2;
    }
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movb $0x1, %bpl
cmpb $0x0, 0x98(%rdx)
jne 0x292dc
movq %rsi, %r14
movq %rdi, 0x40(%rsp)
movb $0x1, 0x98(%rdx)
movq 0x20(%rdx), %r12
movq %rdx, 0x48(%rsp)
movq 0x28(%rdx), %rax
movq %rax, 0x50(%rsp)
cmpq %rax, %r12
je 0x29086
leaq 0x10(%rsp), %r15
movq 0x8(%r14), %rbp
addq $0x40, %r12
leaq 0x20(%rsp), %rbx
cmpq %rbp, 0x8(%r12)
jne 0x28eda
testq %rbp, %rbp
je 0x29146
movq (%r14), %rsi
movq (%r12), %rdi
movq %rbp, %rdx
callq 0x42b0
testl %eax, %eax
je 0x29146
movq %rbx, %rdi
leaq 0xf6d9(%rip), %rbp      # 0x385bd
movq %rbp, %rsi
movq %r14, %rdx
callq 0x5344
movq %rbx, %rdi
leaq 0xe60b(%rip), %rsi      # 0x37504
callq 0x4510
movq %r15, (%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x28f1f
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x28f26
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq (%rsp), %rsi
movq 0x8(%rsp), %rcx
movq %r12, %rdi
xorl %edx, %edx
callq 0x44a0
movq %rax, %r13
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x28f6a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x28f86
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42a0
cmpq $-0x1, %r13
jne 0x29146
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x5344
movq %rbx, %rdi
leaq 0xe55c(%rip), %rsi      # 0x37504
callq 0x4510
movq %r15, (%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x28fce
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x28fd5
movups (%rcx), %xmm0
movups %xmm0, (%r15)
leaq -0x20(%r12), %r13
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq (%rsp), %rsi
movq 0x8(%rsp), %rcx
movq %r13, %rdi
xorl %edx, %edx
callq 0x44a0
movq %rax, %rbp
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x2901e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x2903a
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42a0
cmpq $-0x1, %rbp
jne 0x29146
movq -0x18(%r12), %rdx
movq 0x8(%r14), %rbp
cmpq %rbp, %rdx
jne 0x2906f
testq %rdx, %rdx
je 0x2929a
movq (%r14), %rsi
movq (%r13), %rdi
callq 0x42b0
testl %eax, %eax
je 0x2929a
leaq 0x68(%r12), %rax
addq $0x28, %r12
cmpq 0x50(%rsp), %r12
movq %rax, %r12
jne 0x28eb3
movq 0x48(%rsp), %rax
movq 0x80(%rax), %rdx
testq %rdx, %rdx
je 0x2914d
leaq 0x108(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x78(%rax), %rsi
addq %rsi, %rdx
leaq 0xf8(%rsp), %r15
movq %r15, %rdi
callq 0xc7aa
movq 0x40(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x29e92
movq %rax, %rbx
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x290ea
movq 0x108(%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), %r14
movq %r14, %rdi
callq 0xc7aa
movq %r13, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x28e56
movl %eax, %ebp
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0x292dc
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x292dc
xorl %ebp, %ebp
jmp 0x292dc
cmpq $0x0, 0x60(%rax)
movq 0x40(%rsp), %r13
movb $0x1, %bpl
je 0x292dc
leaq 0xe8(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x38(%rax), %rsi
movq 0x40(%rax), %rdx
addq %rsi, %rdx
leaq 0xd8(%rsp), %r12
movq %r12, %rdi
callq 0xc7aa
movq %r13, %rdi
movq %r12, %rsi
callq 0x29e92
movq %rax, %rbx
movq (%r12), %rdi
cmpq %r15, %rdi
je 0x291ae
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x88(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %r12
movq %r12, %rdi
callq 0xc7aa
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x28e56
movl %eax, %ebp
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x291fb
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0xc8(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x48(%rsp), %rax
movq 0x58(%rax), %rsi
movq 0x60(%rax), %rdx
addq %rsi, %rdx
leaq 0xb8(%rsp), %r15
movq %r15, %rdi
callq 0xc7aa
movq %r13, %rdi
movq %r15, %rsi
callq 0x29e92
movq %rax, %rbx
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x2924e
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x68(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %r14
movq %r14, %rdi
callq 0xc7aa
movq %r13, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x28e56
movl %eax, %ebx
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x29295
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42a0
andb %bl, %bpl
jmp 0x292dc
addq $-0x40, %r12
leaq 0xde20(%rip), %rsi      # 0x370c5
movq %r12, %rdi
callq 0x40d0
testl %eax, %eax
movb $0x1, %bpl
je 0x292dc
leaq 0xe266(%rip), %rsi      # 0x37521
movq %r12, %rdi
callq 0x40d0
testl %eax, %eax
je 0x292dc
leaq 0xe238(%rip), %rsi      # 0x37506
movq %r12, %rdi
callq 0x40d0
testl %eax, %eax
sete %bpl
movl %ebp, %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 %r15, %rdi
je 0x29356
movq 0x68(%rsp), %rsi
jmp 0x2934e
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x29356
movq 0x88(%rsp), %rsi
jmp 0x2934e
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0x29356
movq 0xa8(%rsp), %rsi
jmp 0x2934e
jmp 0x29337
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x29356
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x44c0