// File: /workspace/github_cpp_makefile_star2_O1/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 $0x128, %rsp            # imm = 0x128
movb $0x1, %bpl
cmpb $0x0, 0x98(%rdx)
jne 0x2958c
movq %rsi, %r14
movq %rdi, 0x8(%rsp)
movb $0x1, 0x98(%rdx)
movq 0x20(%rdx), %r12
movq %rdx, 0x38(%rsp)
movq 0x28(%rdx), %rax
movq %rax, 0x60(%rsp)
cmpq %rax, %r12
sete %bl
je 0x2936a
leaq 0x28(%rsp), %r15
addq $0x40, %r12
movq 0x8(%r12), %rdx
cmpq 0x8(%r14), %rdx
jne 0x29143
testq %rdx, %rdx
je 0x292c0
movq (%r14), %rsi
movq (%r12), %rdi
callq 0x42b0
testl %eax, %eax
je 0x292c0
leaq 0x40(%rsp), %r13
movq %r13, %rdi
leaq 0x1046b(%rip), %rsi     # 0x395bd
movq %r14, %rdx
callq 0x5474
movq %r13, %rdi
leaq 0xf3a0(%rip), %rsi      # 0x38504
callq 0x4510
movq %r15, 0x18(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2918c
movq %rdx, 0x18(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x28(%rsp)
jmp 0x29193
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x20(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rcx
movq %r12, %rdi
xorl %edx, %edx
callq 0x44a0
movq %rax, %r13
movq 0x18(%rsp), %rdi
cmpq %r15, %rdi
je 0x291d9
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x291f5
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x42a0
cmpq $-0x1, %r13
jne 0x292c0
leaq 0x40(%rsp), %r13
movq %r13, %rdi
leaq 0x103af(%rip), %rsi     # 0x395bd
movq %r14, %rdx
callq 0x5474
movq %r13, %rdi
leaq 0xf2e4(%rip), %rsi      # 0x38504
callq 0x4510
movq %r15, 0x18(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
movl %ebp, 0x14(%rsp)
je 0x2924c
movq %rdx, 0x18(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x28(%rsp)
jmp 0x29253
movups (%rcx), %xmm0
movups %xmm0, (%r15)
leaq -0x20(%r12), %r13
movq 0x8(%rax), %rdx
movq %rdx, 0x20(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rcx
movq %r13, %rdi
xorl %edx, %edx
callq 0x44a0
movq %rax, %rbp
movq 0x18(%rsp), %rdi
cmpq %r15, %rdi
je 0x2929e
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x292ba
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x42a0
cmpq $-0x1, %rbp
je 0x292ef
xorl %r15d, %r15d
xorl %ebp, %ebp
testb %r15b, %r15b
je 0x2936a
leaq 0x68(%r12), %rax
addq $0x28, %r12
cmpq 0x60(%rsp), %r12
sete %bl
movq %rax, %r12
leaq 0x28(%rsp), %r15
jne 0x2911b
jmp 0x2936a
movq -0x18(%r12), %rdx
movb $0x1, %r15b
cmpq 0x8(%r14), %rdx
jne 0x29361
testq %rdx, %rdx
movl 0x14(%rsp), %ebp
je 0x29316
movq (%r14), %rsi
movq (%r13), %rdi
callq 0x42b0
testl %eax, %eax
jne 0x292c5
leaq -0x40(%r12), %r15
movq %r15, %rdi
leaq 0xeda0(%rip), %rsi      # 0x380c5
callq 0x40d0
movb $0x1, %bpl
testl %eax, %eax
je 0x29359
movq %r15, %rdi
leaq 0xf1e6(%rip), %rsi      # 0x38521
callq 0x40d0
testl %eax, %eax
je 0x29359
movq %r15, %rdi
leaq 0xf1b8(%rip), %rsi      # 0x38506
callq 0x40d0
testl %eax, %eax
sete %bpl
xorl %r15d, %r15d
jmp 0x292c5
movl 0x14(%rsp), %ebp
jmp 0x292c5
testb $0x1, %bl
je 0x2958c
movq 0x38(%rsp), %rax
movq 0x80(%rax), %rdx
testq %rdx, %rdx
je 0x29432
leaq 0x118(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x78(%rax), %rsi
addq %rsi, %rdx
leaq 0x108(%rsp), %r15
movq %r15, %rdi
callq 0xca12
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x2a144
movq %rax, %rbx
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x293d4
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0xb8(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0xa8(%rsp), %r14
movq %r14, %rdi
callq 0xca12
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x290c4
movl %eax, %ebp
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2958c
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x2958c
cmpq $0x0, 0x60(%rax)
movb $0x1, %bpl
je 0x2958c
leaq 0xf8(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x38(%rsp), %rax
movq 0x38(%rax), %rsi
movq 0x40(%rax), %rdx
addq %rsi, %rdx
leaq 0xe8(%rsp), %r15
movq %r15, %rdi
callq 0xca12
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x2a144
movq %rax, %rbx
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x29495
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x98(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %r15
movq %r15, %rdi
callq 0xca12
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x290c4
movl %eax, %ebp
movq 0x88(%rsp), %rdi
cmpq %r12, %rdi
movq 0x38(%rsp), %rbx
je 0x294f0
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0xd8(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x58(%rbx), %rsi
movq 0x60(%rbx), %rdx
addq %rsi, %rdx
leaq 0xc8(%rsp), %r15
movq %r15, %rdi
callq 0xca12
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x2a144
movq %rax, %rbx
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x29540
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x78(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %r14
movq %r14, %rdi
callq 0xca12
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x290c4
movl %eax, %ebx
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0x29589
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x42a0
andb %bl, %bpl
andb $0x1, %bpl
movl %ebp, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0x2960d
movq 0x78(%rsp), %rsi
jmp 0x29605
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r12, %rdi
je 0x2960d
movq 0x98(%rsp), %rsi
jmp 0x29605
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2960d
movq 0xb8(%rsp), %rsi
jmp 0x29605
jmp 0x295ee
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x2960d
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x44c0
nop