// File: 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
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x7ce0
leaq -0x20(%rbp), %rdi
callq 0x89d0
leaq -0x40(%rbp), %rdi
callq 0x12de0
movq -0x90(%rbp), %rdi
movl 0x34(%rdi), %eax
movq %rsp, %rcx
movq %rcx, -0x50(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x88(%rbp)
movq %rcx, %rsp
movq %rax, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
addq $0x18, %rdi
callq 0x8ab0
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x44(%rbp)
movq -0x90(%rbp), %rcx
movl -0x44(%rbp), %eax
cmpl 0x34(%rcx), %eax
jge 0xdb45
movq -0x88(%rbp), %rax
movslq -0x44(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x44(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0xdb31
leaq -0x20(%rbp), %rdi
callq 0x8b30
movq (%rax), %rax
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x8b60
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xdafb
movl $0x0, -0x44(%rbp)
cmpl $0x2, -0x44(%rbp)
jge 0xdb88
leaq -0x40(%rbp), %rdi
leaq -0x44(%rbp), %rsi
callq 0x12df0
jmp 0xdb61
jmp 0xdb63
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xdb4c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x12eb0
jmp 0xdc65
jmp 0xdb8a
leaq -0x40(%rbp), %rdi
callq 0x12e30
xorb $-0x1, %al
testb $0x1, %al
jne 0xdb9e
jmp 0xdc41
leaq -0x40(%rbp), %rdi
callq 0x12e50
movq %rax, %rcx
movq -0x88(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0x48(%rbp)
movslq -0x48(%rbp), %rcx
testb $0x1, (%rax,%rcx)
jne 0xdc33
movq -0x90(%rbp), %rdi
callq 0x8810
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x48(%rbp), %eax
jge 0xdbfb
leaq -0x18(%rbp), %rdi
callq 0x88b0
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xdbdf
leaq -0x18(%rbp), %rdi
callq 0x8890
movq -0x88(%rbp), %r9
movq (%rax), %rdi
movl -0xc(%rbp), %edx
movq -0x28(%rbp), %rcx
leaq -0x40(%rbp), %rsi
leaq -0x5c(%rbp), %r8
callq 0xdc70
jmp 0xdc24
movq -0x88(%rbp), %rax
movslq -0x48(%rbp), %rcx
movb $0x1, (%rax,%rcx)
leaq -0x40(%rbp), %rdi
callq 0x12e80
jmp 0xdb8a
movl -0x5c(%rbp), %eax
movl %eax, -0x94(%rbp)
movq -0x50(%rbp), %rax
movq %rax, %rsp
leaq -0x40(%rbp), %rdi
callq 0x12eb0
movl -0x94(%rbp), %eax
movq %rbp, %rsp
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x3430
nop