// File: /workspace/github_cpp_makefile_star2_O2/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 0x1953b
movq %rsi, %r15
movq %rdi, (%rsp)
movb $0x1, 0x98(%rdx)
movq 0x20(%rdx), %r13
movq %rdx, 0x10(%rsp)
movq 0x28(%rdx), %rax
movq %rax, 0x18(%rsp)
leaq 0xb195(%rip), %rbx      # 0x245bd
leaq 0x88(%rsp), %r14
leaq 0x108(%rsp), %r12
movq %rsi, 0x8(%rsp)
cmpq 0x18(%rsp), %r13
je 0x1954f
leaq 0x40(%r13), %rbp
movq %rbp, %rdi
movq %r15, %rsi
callq 0x8141
testb %al, %al
jne 0x19539
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x4acd
movq %r12, %rdi
movq %r14, %rsi
leaq 0xa08a(%rip), %rdx      # 0x23504
callq 0x4a8f
movq %rbp, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x4530
movq %rax, %rbp
movq %r12, %rdi
callq 0x4548
movq %r14, %rdi
callq 0x4548
cmpq $-0x1, %rbp
jne 0x19539
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x4acd
movq %r12, %rdi
movq %r14, %rsi
leaq 0xa040(%rip), %rdx      # 0x23504
callq 0x4a8f
movq %r13, %rbx
leaq 0x20(%r13), %rbp
movq %rbp, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x4530
movq %rax, 0x20(%rsp)
movq %r12, %r15
movq %r12, %rdi
callq 0x4548
movq %r14, %r13
movq %r14, %rdi
callq 0x4548
cmpq $-0x1, 0x20(%rsp)
jne 0x19539
movq %rbp, %rdi
movq 0x8(%rsp), %rsi
callq 0x8141
testb %al, %al
jne 0x195c2
movq %rbx, %rax
addq $0x68, %rax
leaq 0xb09a(%rip), %rbx      # 0x245bd
movq 0x8(%rsp), %rcx
movq %r13, %r14
movq %rax, %r13
movq %r15, %r12
movq %rcx, %r15
jmp 0x1943d
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %r13
cmpq $0x0, 0x80(%r13)
je 0x1960d
addq $0x78, %r13
leaq 0xe8(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4390
movq (%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x19ec2
movq %rax, %r14
movq %rbx, %rdi
callq 0x4548
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4390
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x193e0
movl %eax, %ebp
leaq 0x68(%rsp), %rdi
callq 0x4548
jmp 0x1953b
leaq 0x9afc(%rip), %rsi      # 0x230c5
movq %rbx, %rdi
callq 0x8453
testb %al, %al
je 0x195dd
movb $0x1, %bpl
jmp 0x1953b
leaq 0x9f3d(%rip), %rsi      # 0x23521
movq %rbx, %rdi
callq 0x8453
testb %al, %al
movb $0x1, %bpl
jne 0x1953b
leaq 0x9f08(%rip), %rsi      # 0x23506
movq %rbx, %rdi
callq 0x8453
movl %eax, %ebp
jmp 0x1953b
cmpq $0x0, 0x60(%r13)
movb $0x1, %bpl
movq (%rsp), %r12
je 0x1953b
leaq 0x38(%r13), %rsi
leaq 0xc8(%rsp), %rbx
movq %rbx, %rdi
callq 0x4390
movq %r12, %rdi
movq %rbx, %rsi
callq 0x19ec2
movq %rax, %r14
movq %rbx, %rdi
callq 0x4548
leaq 0x48(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4390
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x193e0
movl %eax, %ebp
addq $0x58, %r13
leaq 0x48(%rsp), %rdi
callq 0x4548
leaq 0xa8(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4390
movq %r12, %rdi
movq %rbx, %rsi
callq 0x19ec2
movq %rax, %r14
movq %rbx, %rdi
callq 0x4548
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4390
movq %r12, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x193e0
movl %eax, %ebx
leaq 0x28(%rsp), %rdi
callq 0x4548
andb %bl, %bpl
jmp 0x1953b
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
jmp 0x196fd
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
jmp 0x196fd
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
jmp 0x196fd
jmp 0x196f2
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x4548
movq %rbx, %rdi
callq 0x4490