// File: /workspace/github_cpp_makefile_star2_O3/pgrouchy[P]NoiseWorld/mathNet.cpp
// Function: Genome::numRefsToTree(int)
int Genome::numRefsToTree(int treeNum) {
    list<Tree*>::iterator curTree;
    list<TreeID*>::iterator curTreeID;
    TreeID *treeNumID;
    list<int> treeList;
    int i, currentTreeNum;
    bool isChecked[this->num_trees];
    int counter = 0;
    curTreeID = this->tree_id_lookup.begin();
    for (i = 0; i < this->num_trees; i++) {
        isChecked[i] = false;
        if (i == treeNum) {
            treeNumID = (*curTreeID);
        }
        ++curTreeID;
    }
    // Only check trees that are directly or indirectly referenced by the output equations
    for (i = 0; i < NUM_OUTPUTS; i++) {
        treeList.push_back(i);
    }
    while (!treeList.empty()) {
        currentTreeNum = treeList.front();
        if (!isChecked[currentTreeNum]) {
            curTree = this->trees.begin();
            for (i = 0; i < currentTreeNum; i++) { // get the pointer to the currentTreeNum tree
                ++curTree;
            }
            (*curTree)->refCheck(treeList, treeNum, treeNumID, counter, isChecked);
            isChecked[currentTreeNum] = true;
        }
        treeList.pop_front();
    }
    return counter;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsp, -0x50(%rbp)
leaq -0x48(%rbp), %rax
movq %rax, 0x8(%rax)
movq %rax, (%rax)
movq $0x0, 0x10(%rax)
movl 0x34(%rdi), %eax
movq %rsp, %r12
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %r12
movq %r12, %rsp
movl $0x0, -0x2c(%rbp)
movslq 0x34(%rdi), %rax
testq %rax, %rax
movq %rdi, -0x58(%rbp)
jle 0x7ead
leaq 0x18(%rdi), %rcx
movl %esi, %edx
xorl %edi, %edi
movq (%rcx), %rcx
movb $0x0, (%r12,%rdi)
cmpq %rdi, %rdx
jne 0x7ea3
movq 0x10(%rcx), %r8
movq %r8, -0x60(%rbp)
incq %rdi
cmpq %rdi, %rax
jne 0x7e8e
jmp 0x7ead
movl %esi, -0x30(%rbp)
xorl %r13d, %r13d
movb $0x1, %r14b
leaq -0x48(%rbp), %r15
xorl %ebx, %ebx
movl $0x18, %edi
callq 0x21e0
movl %r13d, 0x10(%rax)
movq %rax, %rdi
movq %r15, %rsi
callq 0x2060
incq -0x38(%rbp)
movl $0x1, %r13d
testb $0x1, %r14b
movl $0x0, %r14d
jne 0x7ebc
movq -0x48(%rbp), %r14
cmpq %r15, %r14
je 0x7f62
movl -0x30(%rbp), %r13d
movslq 0x10(%r14), %rbx
cmpb $0x0, (%r12,%rbx)
jne 0x7f3d
testl %ebx, %ebx
movl $0x0, %eax
cmovgl %ebx, %eax
incl %eax
movq -0x58(%rbp), %rcx
movq (%rcx), %rcx
decl %eax
jne 0x7f13
movq 0x10(%rcx), %rdi
movq %r15, %rsi
movl %r13d, %edx
movq -0x60(%rbp), %rcx
leaq -0x2c(%rbp), %r8
movq %r12, %r9
callq 0x7fc0
movb $0x1, (%r12,%rbx)
movq -0x48(%rbp), %r14
decq -0x38(%rbp)
movq %r14, %rdi
callq 0x22d0
movl $0x18, %esi
movq %r14, %rdi
callq 0x21f0
movq -0x48(%rbp), %r14
cmpq %r15, %r14
jne 0x7ef8
movl -0x2c(%rbp), %ebx
movq -0x50(%rbp), %rsp
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x7f84
movq (%rdi), %r14
movl $0x18, %esi
callq 0x21f0
movq %r14, %rdi
cmpq %r15, %r14
jne 0x7f6f
movl %ebx, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7f97
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x7fb8
movq (%rdi), %r14
movl $0x18, %esi
callq 0x21f0
movq %r14, %rdi
cmpq %r15, %r14
jne 0x7fa3
movq %rbx, %rdi
callq 0x2300