// File: /workspace/github_cpp_makefile_star2_O1/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, %r14
movq %rcx, %r12
movl %esi, %ebp
movq %rdi, %rbx
orl %esi, %edx
jne 0xa239
movq (%r12), %rax
testq %rax, %rax
je 0xa4e6
movb $0x1, %r15b
cmpb $0x0, 0x12(%rax)
jne 0xa48d
movq (%r12), %rax
testq %rax, %rax
je 0xa4e6
cmpb $0x0, 0x12(%rax)
jne 0xa257
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1413c
movq (%r12), %rax
testq %rax, %rax
je 0xa4e6
movq 0x18(%rax), %rcx
movq %rcx, 0x10(%rsp)
testq %rcx, %rcx
je 0xa505
incq 0x8(%rcx)
movq 0x40(%rbx), %rax
testq %rax, %rax
je 0xa505
movsd 0x70(%rcx), %xmm0
movsd 0x70(%rax), %xmm1
ucomisd %xmm1, %xmm0
jb 0xa29d
cmpl $0x0, 0x64(%rcx)
je 0xa30b
cmpl $0x1, 0x64(%rcx)
jne 0xa2d7
movq $0x0, (%rsp)
movq 0x28(%rcx), %rdx
movq %rdx, 0x8(%rsp)
testq %rdx, %rdx
je 0xa370
movl 0x8(%rdx), %eax
testl %eax, %eax
je 0xa361
leal 0x1(%rax), %esi
lock
cmpxchgl %esi, 0x8(%rdx)
jne 0xa2c0
jmp 0xa363
movq $0x0, (%rsp)
movq 0x28(%rcx), %rdx
movq %rdx, 0x8(%rsp)
testq %rdx, %rdx
je 0xa3b9
movl 0x8(%rdx), %eax
testl %eax, %eax
je 0xa3aa
leal 0x1(%rax), %esi
lock
cmpxchgl %esi, 0x8(%rdx)
jne 0xa2f4
jmp 0xa3ac
movsd %xmm1, 0x28(%rsp)
movsd %xmm0, 0x30(%rsp)
movl (%r14), %edi
shlq $0x4, %rdi
addq 0xb8(%rbx), %rdi
addq $0x40, %rbx
movq %r12, %rsi
callq 0x107c0
testb %bpl, %bpl
je 0xa49f
movb $0x1, %r15b
movsd 0x30(%rsp), %xmm0
ucomisd 0x28(%rsp), %xmm0
jbe 0xa477
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x1080e
jmp 0xa477
xorl %eax, %eax
testl %eax, %eax
jne 0xa370
movq $0x0, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
je 0xa380
movq 0x20(%rcx), %rax
movq %rax, (%rsp)
movq $0x0, 0x18(%rsp)
movq 0x38(%rcx), %rdx
movq %rdx, 0x20(%rsp)
testq %rdx, %rdx
je 0xa3f9
movl 0x8(%rdx), %eax
testl %eax, %eax
je 0xa3ea
leal 0x1(%rax), %esi
lock
cmpxchgl %esi, 0x8(%rdx)
jne 0xa39a
jmp 0xa3ec
xorl %eax, %eax
testl %eax, %eax
jne 0xa3b9
movq $0x0, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
je 0xa3c9
movq 0x20(%rcx), %rax
movq %rax, (%rsp)
leaq 0x8(%rsp), %r12
movzbl %bpl, %esi
movq %rsp, %rcx
movq %rbx, %rdi
xorl %edx, %edx
movq %r14, %r8
callq 0xa202
movl %eax, %r15d
jmp 0xa46f
xorl %eax, %eax
testl %eax, %eax
jne 0xa3f9
movq $0x0, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
je 0xa40a
movq 0x30(%rcx), %rax
movq %rax, 0x18(%rsp)
movq (%rsp), %rdx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testq %rdx, %rdx
je 0xa420
movl 0x14(%rdx), %ecx
movq 0x18(%rsp), %rdx
testq %rdx, %rdx
je 0xa42d
movl 0x14(%rdx), %eax
leaq 0x8(%rsp), %r12
leaq 0x20(%rsp), %r13
cmpl $-0x1, %ecx
jne 0xa445
cmpl $-0x1, %eax
je 0xa524
cmpl %eax, %ecx
movq %rsp, %rax
leaq 0x18(%rsp), %rcx
cmovgq %rax, %rcx
movzbl %bpl, %esi
movq %rbx, %rdi
xorl %edx, %edx
movq %r14, %r8
callq 0xa202
movl %eax, %r15d
movq %r13, %rdi
callq 0x10dec
movq %r12, %rdi
callq 0x10dec
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xa48d
decq 0x8(%rdi)
jne 0xa48d
movq (%rdi), %rax
callq *0x8(%rax)
movl %r15d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsd 0x30(%rsp), %xmm0
ucomisd 0x28(%rsp), %xmm0
jbe 0xa4bf
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x1080e
xorl %r15d, %r15d
jmp 0xa477
movq (%rbx), %rax
movb $0x1, %r15b
cmpq 0x10(%rsp), %rax
je 0xa477
movq 0x15b1d(%rip), %rdi     # 0x1fff0
leaq 0xe7bd(%rip), %rsi      # 0x18c97
movl $0x1f, %edx
callq 0x32a0
jmp 0xa477
leaq 0xe60b(%rip), %rdi      # 0x18af8
leaq 0xef12(%rip), %rsi      # 0x19406
leaq 0xef37(%rip), %rcx      # 0x19432
movl $0x2d8, %edx            # imm = 0x2D8
callq 0x3170
leaq 0xe5ec(%rip), %rdi      # 0x18af8
leaq 0xe5ed(%rip), %rsi      # 0x18b00
leaq 0xef81(%rip), %rcx      # 0x1949b
movl $0xc7, %edx
callq 0x3170
movl $0x8, %edi
callq 0x3100
leaq 0xe782(%rip), %rcx      # 0x18cb7
movq %rcx, (%rax)
movq 0x15a71(%rip), %rsi     # 0x1ffb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x33d0
movq %rax, %rbx
jmp 0xa568
jmp 0xa555
movq %rax, %rbx
jmp 0xa560
movq %rax, %rbx
movq %r13, %rdi
callq 0x10dec
movq %r12, %rdi
callq 0x10dec
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xa57e
decq 0x8(%rdi)
jne 0xa57e
movq (%rdi), %rax
callq *0x8(%rax)
movq %rbx, %rdi
callq 0x33f0