// File: /workspace/github_cpp_makefile_star2_O2/gchen98[P]macs/algorithm.cpp
// Function: GraphBuilder::getRandomEdgeOnTree(double&, double)
EdgePtr GraphBuilder::getRandomEdgeOnTree(double & dSplitPoint,
double dRandomSpot){
    if (this->bEndGeneConversion && dSplitPoint!=-1.){
        dSplitPoint = gcNewEdge->getBottomNodeRef()->getHeight()+0.;
        return this->gcNewEdge;
    }
    bool found = false;
    double dRunningLength = 0.0;
    EdgePtrVector::iterator it = pEdgeVectorInTree->begin();
    EdgePtr curEdge;
    // the linked list of tree edges are lined up so that a uniform point
    // on the tree can be selected for where the crossover occurs
    unsigned int counter=0;
    while(!found && counter<iTotalTreeEdges){
        curEdge = *it;
        if (!curEdge->bDeleted){
            if (dRandomSpot<dRunningLength+curEdge->getLength()){
                // the random spot is within the current segment
                // the reference var splitpoint returns the position
                // relative to the bottom of this edge that the xover
                // occurs
                dSplitPoint = curEdge->getBottomNodeRef()->getHeight()+
                (dRandomSpot - dRunningLength);
                found = true;
            }else{
                dRunningLength+=curEdge->getLength();
                //if (pConfig->bDebug){
                  //cerr<<"getRandomEdge: running length: "<<dRunningLength<<", random spot "<<dRandomSpot<<"\n"; 
                //}
            }
        }else{
          //if (pConfig->bDebug){
            //cerr<<"getRandomEdge: Sorry edge was deleted\n"; 
          //}
        }
        ++counter;
        ++it;
    }
    if (!found) throw "RandomSpot was out of range for xover";
    return curEdge;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movsd %xmm0, 0x10(%rsp)
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
cmpb $0x1, 0xf9(%rsi)
jne 0x8773
movsd (%r15), %xmm0
ucomisd 0xd453(%rip), %xmm0     # 0x15b78
jne 0x8729
jnp 0x8773
leaq 0x110(%r14), %rdi
callq 0xda24
leaq 0x20(%rax), %rdi
callq 0xda4e
xorpd %xmm0, %xmm0
addsd 0x70(%rax), %xmm0
movsd %xmm0, (%r15)
movq 0x110(%r14), %rax
movq %rax, (%rbx)
movq 0x118(%r14), %rax
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x8842
lock
incl 0x8(%rax)
jmp 0x8842
movq 0x18(%r14), %rax
movq (%rax), %r12
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
xorpd %xmm0, %xmm0
xorl %ebp, %ebp
xorl %eax, %eax
testb $0x1, %al
jne 0x883e
cmpl 0x20(%r14), %ebp
jae 0x883e
movsd %xmm0, 0x8(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xda78
movq %rbx, %rdi
callq 0xda24
cmpb $0x0, 0x10(%rax)
je 0x87c5
xorl %eax, %eax
movsd 0x8(%rsp), %xmm0
jmp 0x8833
movq %rbx, %rdi
callq 0xda24
movsd 0x28(%rax), %xmm0
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %rbx, %rdi
callq 0xda24
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x8826
addq $0x20, %rax
movq %rax, %rdi
callq 0xda4e
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
subsd %xmm1, %xmm0
addsd 0x70(%rax), %xmm0
movsd %xmm0, (%r15)
movb $0x1, %al
movapd %xmm1, %xmm0
jmp 0x8833
movsd 0x8(%rsp), %xmm0
addsd 0x28(%rax), %xmm0
xorl %eax, %eax
incl %ebp
addq $0x10, %r12
jmp 0x878a
testb $0x1, %al
je 0x8852
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x8
popq %rdi
callq 0x3110
leaq 0xd397(%rip), %rcx      # 0x15bf8
movq %rcx, (%rax)
movq 0x16755(%rip), %rsi     # 0x1efc0
movq %rax, %rdi
xorl %edx, %edx
callq 0x33e0
movq %rax, %r14
addq $0x8, %rbx
movq %rbx, %rdi
callq 0xdff8
movq %r14, %rdi
callq 0x3400