// File: /workspace/github_cpp_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movsd %xmm0, 0x8(%rsp)
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
cmpb $0x1, 0xf9(%rsi)
jne 0x9b56
movsd (%r15), %xmm0
ucomisd 0xf069(%rip), %xmm0     # 0x18b70
jne 0x9b0b
jnp 0x9b56
movq 0x110(%r14), %rax
testq %rax, %rax
je 0x9c05
movq 0x20(%rax), %rcx
testq %rcx, %rcx
je 0x9c24
xorpd %xmm0, %xmm0
addsd 0x70(%rcx), %xmm0
movsd %xmm0, (%r15)
movq %rax, (%rbx)
movq 0x118(%r14), %rax
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x9bf3
lock
incl 0x8(%rax)
jmp 0x9bf3
movq 0x18(%r14), %rax
movq (%rax), %r12
xorpd %xmm0, %xmm0
movupd %xmm0, (%rbx)
cmpl $0x0, 0x20(%r14)
je 0x9c43
xorpd %xmm0, %xmm0
movl $0x1, %r13d
xorl %ebp, %ebp
movsd %xmm0, 0x10(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x107c0
movq (%rbx), %rax
testq %rax, %rax
je 0x9c05
cmpb $0x0, 0x10(%rax)
movsd 0x10(%rsp), %xmm1
jne 0x9bd2
movsd 0x28(%rax), %xmm0
addsd %xmm1, %xmm0
ucomisd 0x8(%rsp), %xmm0
jbe 0x9bd6
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x9c24
movsd 0x8(%rsp), %xmm0
subsd %xmm1, %xmm0
addsd 0x70(%rax), %xmm0
movsd %xmm0, (%r15)
movb $0x1, %bpl
movapd %xmm1, %xmm0
testb $0x1, %bpl
jne 0x9bed
addq $0x10, %r12
leal 0x1(%r13), %eax
cmpl 0x20(%r14), %r13d
movl %eax, %r13d
jb 0x9b7c
testb $0x1, %bpl
je 0x9c43
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xeeec(%rip), %rdi      # 0x18af8
leaq 0xf7f3(%rip), %rsi      # 0x19406
leaq 0xf818(%rip), %rcx      # 0x19432
movl $0x2d8, %edx            # imm = 0x2D8
callq 0x3170
leaq 0xeecd(%rip), %rdi      # 0x18af8
leaq 0xeece(%rip), %rsi      # 0x18b00
leaq 0xf862(%rip), %rcx      # 0x1949b
movl $0xc7, %edx
callq 0x3170
movl $0x8, %edi
callq 0x3100
leaq 0xef94(%rip), %rcx      # 0x18be8
movq %rcx, (%rax)
movq 0x16352(%rip), %rsi     # 0x1ffb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x33d0
movq %rax, %r14
addq $0x8, %rbx
movq %rbx, %rdi
callq 0x10dec
movq %r14, %rdi
callq 0x33f0
nop