// File: /workspace/github_cpp_makefile_star2_O3/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 $0x10, %rsp
movsd %xmm0, (%rsp)
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
cmpb $0x1, 0xf9(%rsi)
jne 0x9b2b
movsd (%r14), %xmm0
ucomisd 0xf094(%rip), %xmm0     # 0x18b70
jne 0x9ae0
jnp 0x9b2b
movq 0x110(%r15), %rax
testq %rax, %rax
je 0x9be9
movq 0x20(%rax), %rcx
testq %rcx, %rcx
je 0x9c08
xorpd %xmm0, %xmm0
addsd 0x70(%rcx), %xmm0
movsd %xmm0, (%r14)
movq %rax, (%rbx)
movq 0x118(%r15), %rax
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x9bd9
lock
incl 0x8(%rax)
jmp 0x9bd9
movq 0x18(%r15), %rax
movq (%rax), %r12
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
cmpl $0x0, 0x20(%r15)
je 0x9b98
xorl %ebp, %ebp
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x10736
movq (%rbx), %rax
testq %rax, %rax
je 0x9be9
cmpb $0x0, 0x10(%rax)
movsd 0x8(%rsp), %xmm1
je 0x9b76
movapd %xmm1, %xmm0
jmp 0x9b86
movsd 0x28(%rax), %xmm0
addsd %xmm1, %xmm0
ucomisd (%rsp), %xmm0
ja 0x9bbd
incl %ebp
addq $0x10, %r12
movsd %xmm0, 0x8(%rsp)
cmpl 0x20(%r15), %ebp
jb 0x9b4d
movl $0x8, %edi
callq 0x3100
leaq 0xf09f(%rip), %rcx      # 0x18c48
movq %rcx, (%rax)
movq 0x163fd(%rip), %rsi     # 0x1ffb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x33d0
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x9c08
movsd (%rsp), %xmm0
subsd %xmm1, %xmm0
addsd 0x70(%rax), %xmm0
movsd %xmm0, (%r14)
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0xef08(%rip), %rdi      # 0x18af8
leaq 0xf86f(%rip), %rsi      # 0x19466
leaq 0xf894(%rip), %rcx      # 0x19492
movl $0x2d8, %edx            # imm = 0x2D8
callq 0x3170
leaq 0xeee9(%rip), %rdi      # 0x18af8
leaq 0xeeea(%rip), %rsi      # 0x18b00
leaq 0xf8de(%rip), %rcx      # 0x194fb
movl $0xc7, %edx
callq 0x3170
movq %rax, %r14
addq $0x8, %rbx
movq %rbx, %rdi
callq 0x10d5e
movq %r14, %rdi
callq 0x33f0