// File: /workspace/github_cpp_makefile_star2_O2/gchen98[P]macs/algorithm.cpp
// Function: GraphBuilder::markEdgesAbove(bool, bool, boost::shared_ptr<Edge>&, unsigned int&)
bool GraphBuilder::markEdgesAbove(bool bFirstSample,bool  bCalledFromParent,
EdgePtr & selectedEdge, unsigned int & iSampleIndex){
    if (bFirstSample || bCalledFromParent || !selectedEdge->bInCurrentTree){
        if (!selectedEdge->bInCurrentTree) addEdgeToCurrentTree(selectedEdge);
        NodePtr topNode = selectedEdge->getTopNodeRef();
        double dTopHeight = topNode->getHeight();
        double dproposedOriginHt = localMRCA->getHeight();
        if (dTopHeight>=dproposedOriginHt &&
        topNode->getType()==Node::COAL){
            // If we reach at least as high as proposed MRCA
            // save this edge as the vector
            // so we don't traverse from the bottom
            pTreeEdgesToCoalesceArray[iSampleIndex]=selectedEdge;
            if (bFirstSample){
                if (dTopHeight>dproposedOriginHt)
                    // establish a new proposed MRCA
                    // for susequent samples to try reaching
                    localMRCA = topNode;
                // proceed to the next sampled node
                return true;
            }else{
                if (dTopHeight>dproposedOriginHt){
                    // if we surpassed a MRCA height previously proposed
                    // upgrade the proposed MRCA height
                    localMRCA = topNode;
                    // start over in the loop to sample 0
                    return false;
                }else{
                    if (localMRCA!=topNode){
                        cerr<<"proposed grandMRCA != top Node\n";
                    }
                    // here the current height is EQUAL to the proposed MRCA,
                    // this is good and we can proceed to the next sampled node
                    return true;
                }
            }
        }
        else{
            // if we come across a crossover, there are two edges above,
            // we choose the one with the more recent (larger) tree label
            if (topNode->getType()==Node::XOVER){
                EdgePtr edge0 =topNode->getTopEdgeByIndex(0);
                EdgePtr edge1 =topNode->getTopEdgeByIndex(1);
                int iter0=-1,iter1=-1;
                if (edge0!=NULL) iter0=edge0->iGraphIteration;
                if (edge1!=NULL) iter1=edge1->iGraphIteration;
                if (iter0==-1 && iter1==-1) throw "In mark edges above, both edges above xover were missing";
                EdgePtr & nextEdge = (iter0>iter1)? edge0:edge1;
                return markEdgesAbove(bFirstSample,false,nextEdge,
                iSampleIndex);
            // for other nodes, just choose the single edge above it
            // recursively call this method again
            }else{
                EdgePtr edge = topNode->getTopEdgeByIndex(0);
                return markEdgesAbove(bFirstSample,false,edge,
                iSampleIndex);
            }
        }
    }else{
        // the selected edge was in the current tree already and this is for
        // a sampled node after the first one and was called by this method.
        // the latter condition implies that we previously explored up this
        // node.  in this case, save time and proceed to the next node
        return true;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, %rbx
movq %rcx, %r15
movl %esi, %ebp
movq %rdi, %r14
orl %esi, %edx
jne 0x8c46
movq %r15, %rdi
callq 0xda24
movb $0x1, %r12b
cmpb $0x0, 0x12(%rax)
jne 0x8db9
movq %r15, %rdi
callq 0xda24
cmpb $0x0, 0x12(%rax)
jne 0x8c5f
movq %r14, %rdi
movq %r15, %rsi
callq 0x11118
movq %r15, %rdi
callq 0xda24
movq 0x18(%rax), %rax
movq %rax, (%rsp)
testq %rax, %rax
je 0x8c78
incq 0x8(%rax)
movq %rsp, %rdi
callq 0xda4e
movsd 0x70(%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x40(%r14), %r13
movq %r13, %rdi
callq 0xda4e
movsd 0x70(%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x8cc0
movq %rsp, %rdi
callq 0xda4e
cmpl $0x0, 0x64(%rax)
je 0x8dcb
movq %rsp, %rdi
callq 0xda4e
cmpl $0x1, 0x64(%rax)
jne 0x8d77
movq %rsp, %r12
movq %r12, %rdi
callq 0xda4e
leaq 0x20(%rax), %rsi
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0xe1ca
movq %r12, %rdi
callq 0xda4e
leaq 0x30(%rax), %rsi
leaq 0x28(%rsp), %r12
movq %r12, %rdi
callq 0xe1ca
pushq $-0x1
popq %r13
cmpq $0x0, (%r15)
movl %r13d, %r15d
je 0x8d22
leaq 0x10(%rsp), %rdi
callq 0xda24
movl 0x14(%rax), %r15d
cmpq $0x0, 0x28(%rsp)
je 0x8d38
leaq 0x28(%rsp), %rdi
callq 0xda24
movl 0x14(%rax), %r13d
cmpl $-0x1, %r15d
jne 0x8d48
cmpl $-0x1, %r13d
je 0x8e46
cmpl %r13d, %r15d
leaq 0x10(%rsp), %rax
cmovgq %rax, %r12
movzbl %bpl, %esi
movq %r14, %rdi
xorl %edx, %edx
movq %r12, %rcx
movq %rbx, %r8
callq 0x8c14
movl %eax, %r12d
leaq 0x30(%rsp), %rdi
callq 0xdff8
jmp 0x8da7
movq %rsp, %rdi
callq 0xda4e
leaq 0x20(%rax), %rsi
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0xe1ca
movzbl %bpl, %esi
movq %r14, %rdi
xorl %edx, %edx
movq %r15, %rcx
movq %rbx, %r8
callq 0x8c14
movl %eax, %r12d
leaq 0x18(%rsp), %rdi
callq 0xdff8
movq %rsp, %rdi
callq 0xdb46
movl %r12d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl (%rbx), %edi
shlq $0x4, %rdi
addq 0xb8(%r14), %rdi
movq %r15, %rsi
callq 0xda78
testb %bpl, %bpl
je 0x8e03
movb $0x1, %r12b
movsd 0x8(%rsp), %xmm0
ucomisd 0x20(%rsp), %xmm0
jbe 0x8db1
movq %rsp, %rsi
movq %r13, %rdi
callq 0xdb16
jmp 0x8db1
movsd 0x8(%rsp), %xmm0
ucomisd 0x20(%rsp), %xmm0
jbe 0x8e21
movq %rsp, %rsi
movq %r13, %rdi
callq 0xdb16
xorl %r12d, %r12d
jmp 0x8db1
movq (%r13), %rax
movb $0x1, %r12b
cmpq (%rsp), %rax
je 0x8db1
movq 0x161bb(%rip), %rdi     # 0x1eff0
leaq 0xce6b(%rip), %rsi      # 0x15ca7
callq 0x3250
jmp 0x8db1
pushq $0x8
popq %rdi
callq 0x3110
leaq 0xce72(%rip), %rcx      # 0x15cc7
movq %rcx, (%rax)
movq 0x16161(%rip), %rsi     # 0x1efc0
movq %rax, %rdi
xorl %edx, %edx
callq 0x33e0
movq %rax, %rbx
jmp 0x8e8c
jmp 0x8e75
movq %rax, %rbx
jmp 0x8e82
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xdff8
leaq 0x18(%rsp), %rdi
callq 0xdff8
movq %rsp, %rdi
callq 0xdb46
movq %rbx, %rdi
callq 0x3400