// File: /workspace/github_cpp_makefile_star2_O1/Merulo[P]CompilerJFTT/src/IRs/SecondIR.cpp
// Function: SecondIR::isUsedInEndingBlock(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, Block&, Block&)
bool SecondIR::isUsedInEndingBlock(std::string variable, Block& startingBlock, Block& endingBlock)
{
    if (startingBlock.visited)
    {
        return true;
    }
    if (startingBlock == endingBlock)
    {
        return true;
    }

    startingBlock.visited = true;

    for(auto& l : startingBlock.lines)
    {
        if (l.one == variable || l.two == variable)
        {
            return false;
        }
        std::string index = "(" + variable + ")";
        if (l.one.find(index) != std::string::npos || l.two.find(index) != std::string::npos)
        {
            return false;
        }
    }

    if (!startingBlock.blockJump.empty())
    {
        Block& next = getBlockByName(startingBlock.blockJump, _blocks);
        return isUsedInEndingBlock(variable, next, endingBlock);
    }

    Block& nextTrue = getBlockByName(startingBlock.blockIfTrue, _blocks);
    Block& nextFalse = getBlockByName(startingBlock.blockIfFalse, _blocks);

    return isUsedInEndingBlock(variable, nextTrue, endingBlock) 
        && isUsedInEndingBlock(variable, nextFalse, endingBlock);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movb $0x1, %bl
cmpb $0x0, 0x98(%rdx)
jne 0x21bea
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r13
movq 0x8(%rdx), %rdx
cmpq 0x8(%rcx), %rdx
jne 0x2183b
testq %rdx, %rdx
je 0x21bea
movq (%r14), %rsi
movq (%r12), %rdi
callq 0x42b0
testl %eax, %eax
je 0x21bea
movq %r13, 0x8(%rsp)
movq %r14, (%rsp)
movb $0x1, 0x98(%r12)
movq 0x20(%r12), %r13
movq 0x28(%r12), %rax
movq %rax, 0x30(%rsp)
cmpq %rax, %r13
sete %r14b
je 0x219d5
addq $0x40, %r13
leaq -0x20(%r13), %rbx
movq -0x18(%r13), %rdx
movq 0x8(%r15), %rbp
cmpq %rbp, %rdx
jne 0x2189a
testq %rdx, %rdx
je 0x219cb
movq (%r15), %rsi
movq (%rbx), %rdi
callq 0x42b0
testl %eax, %eax
je 0x219cb
movq 0x8(%r13), %rdx
cmpq %rbp, %rdx
jne 0x218c0
testq %rdx, %rdx
je 0x219cb
movq (%r15), %rsi
movq (%r13), %rdi
callq 0x42b0
testl %eax, %eax
je 0x219cb
leaq 0x58(%rsp), %rbp
movq %rbp, %rdi
leaq 0x17cee(%rip), %rsi     # 0x395bd
movq %r15, %rdx
callq 0x5474
movq %rbp, %rdi
leaq 0x16c23(%rip), %rsi     # 0x38504
callq 0x4510
leaq 0x20(%rsp), %rbp
movq %rbp, 0x10(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2190e
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x21915
movups (%rcx), %xmm0
movups %xmm0, (%rbp)
movq 0x8(%rax), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x21949
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rcx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x44a0
movq 0x10(%rsp), %rsi
cmpq $-0x1, %rax
jne 0x219b3
movq 0x18(%rsp), %rcx
movq %r13, %rdi
xorl %edx, %edx
callq 0x44a0
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x21991
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42a0
cmpq $-0x1, %rbx
jne 0x219cb
leaq 0x68(%r13), %rax
addq $0x28, %r13
cmpq 0x30(%rsp), %r13
sete %r14b
movq %rax, %r13
jne 0x2186d
jmp 0x219d5
cmpq %rbp, %rsi
je 0x219cb
movq 0x20(%rsp), %rax
incq %rax
movq %rsi, %rdi
movq %rax, %rsi
callq 0x42a0
testb $0x1, %r14b
je 0x21bac
movq 0x80(%r12), %rdx
testq %rdx, %rdx
je 0x21a86
leaq 0xc8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x78(%r12), %rsi
addq %rsi, %rdx
leaq 0xb8(%rsp), %rbx
movq %rbx, %rdi
callq 0xca12
movq 0x8(%rsp), %r12
leaq 0x10(%r12), %rdx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2be3a
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x21a3f
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x108(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0xf8(%rsp), %r15
movq %r15, %rdi
callq 0xca12
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq (%rsp), %rcx
callq 0x217e8
movl %eax, %ebx
movq 0xf8(%rsp), %rdi
jmp 0x21bda
leaq 0xa8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x38(%r12), %rsi
movq 0x40(%r12), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rbx
movq %rbx, %rdi
callq 0xca12
movq 0x8(%rsp), %rbp
leaq 0x10(%rbp), %r13
movq %rbp, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x2be3a
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x21ae6
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x88(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x58(%r12), %rsi
movq 0x60(%r12), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %r12
movq %r12, %rdi
callq 0xca12
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x2be3a
movq %rax, %r12
movq 0x78(%rsp), %rdi
cmpq %r14, %rdi
je 0x21b37
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0xe8(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0xd8(%rsp), %r13
movq %r13, %rdi
callq 0xca12
movq %rbp, %rdi
movq %r13, %rsi
movq %rbx, %rdx
movq (%rsp), %rcx
callq 0x217e8
movl %eax, %ebp
testb %al, %al
je 0x21bb0
leaq 0x48(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x38(%rsp), %rdi
callq 0xca12
leaq 0x38(%rsp), %rsi
movq 0x8(%rsp), %rdi
movq %r12, %rdx
movq (%rsp), %rcx
callq 0x217e8
movl %eax, %ebx
jmp 0x21bb2
xorl %ebx, %ebx
jmp 0x21bea
xorl %ebx, %ebx
testb %bpl, %bpl
je 0x21bd2
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x21bd2
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x42a0
movq 0xd8(%rsp), %rdi
cmpq %r14, %rdi
je 0x21bea
movq (%r14), %rsi
incq %rsi
callq 0x42a0
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 0x38(%rsp), %rdi
cmpq %r13, %rdi
je 0x21c52
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x21c52
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r14, %rdi
je 0x21cbc
movq 0x88(%rsp), %rsi
jmp 0x21cb4
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x21cbc
movq 0xa8(%rsp), %rsi
jmp 0x21cb4
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
cmpq %r14, %rdi
je 0x21cbc
movq 0xe8(%rsp), %rsi
jmp 0x21cb4
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
cmpq %r14, %rdi
je 0x21cbc
movq 0x108(%rsp), %rsi
jmp 0x21cb4
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r14, %rdi
je 0x21cbc
movq 0xc8(%rsp), %rsi
jmp 0x21cb4
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x21cbc
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x44c0