// File: gchen98[P]macs/algorithm.cpp
// Function: GraphBuilder::getNextPos(double&, std::_List_iterator<HotSpotBin*>&)
bool GraphBuilder::getNextPos(double & curPos,HotSpotBinPtrList::iterator & hotSpotIt){
    bool bBinCrossed = false;
    if (hotSpotIt==pConfig->pHotSpotBinPtrList->end()){
        curPos+=pRandNumGenerator->expRV(getRate());
    }else{
        HotSpotBinPtr hotspot = *hotSpotIt;
        double startPos = hotspot->dStart;
        double endPos = hotspot->dEnd;
        if (curPos>=startPos&&curPos<endPos){
            curPos+=pRandNumGenerator->expRV(getRate()*hotspot->dRate);
            if (curPos>endPos){
                bBinCrossed = true;
                curPos = endPos;
                ++hotSpotIt;
            }
        }else if (curPos<startPos){
            curPos+=pRandNumGenerator->expRV(getRate());
            if (curPos>startPos){
                bBinCrossed = true;
                curPos = startPos;
            }
        }else{
            cerr<<"startPos is "<<startPos<<" endPos is "
            <<endPos<<" and curPos is "<<curPos<<endl;
            throw "Shouldn't be here for variable recomb";
        }
    }
    return bBinCrossed;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movb $0x0, -0x19(%rbp)
movq -0x18(%rbp), %rcx
movq %rcx, -0x48(%rbp)
movq 0x8(%rax), %rax
movq 0x88(%rax), %rdi
callq 0xb9f0
movq -0x48(%rbp), %rdi
movq %rax, -0x28(%rbp)
leaq -0x28(%rbp), %rsi
callq 0x1f810
testb $0x1, %al
jne 0x1ce7f
jmp 0x1cea9
movq -0x50(%rbp), %rdi
movq (%rdi), %rax
movq %rax, -0x58(%rbp)
callq 0x1f840
movq -0x58(%rbp), %rdi
callq 0x1ec00
movq -0x10(%rbp), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
jmp 0x1d044
movq -0x18(%rbp), %rdi
callq 0xba20
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x30(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
ucomisd -0x38(%rbp), %xmm0
jb 0x1cf52
movq -0x10(%rbp), %rax
movsd (%rax), %xmm1
movsd -0x40(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1cf52
movq -0x50(%rbp), %rdi
movq (%rdi), %rax
movq %rax, -0x60(%rbp)
callq 0x1f840
movq -0x60(%rbp), %rdi
movq -0x30(%rbp), %rax
mulsd 0x10(%rax), %xmm0
callq 0x1ec00
movq -0x10(%rbp), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
ucomisd -0x40(%rbp), %xmm0
jbe 0x1cf4d
movb $0x1, -0x19(%rbp)
movsd -0x40(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x18(%rbp), %rdi
callq 0xba40
jmp 0x1d042
movq -0x10(%rbp), %rax
movsd (%rax), %xmm1
movsd -0x38(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1cfaf
movq -0x50(%rbp), %rdi
movq (%rdi), %rax
movq %rax, -0x68(%rbp)
callq 0x1f840
movq -0x68(%rbp), %rdi
callq 0x1ec00
movq -0x10(%rbp), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
ucomisd -0x38(%rbp), %xmm0
jbe 0x1cfaa
movb $0x1, -0x19(%rbp)
movsd -0x38(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x1d040
movq 0x2c03a(%rip), %rdi     # 0x48ff0
leaq 0x17354(%rip), %rsi     # 0x34311
callq 0x42b0
movq %rax, %rdi
movsd -0x38(%rbp), %xmm0
callq 0x4550
movq %rax, %rdi
leaq 0x17345(%rip), %rsi     # 0x3431e
callq 0x42b0
movq %rax, %rdi
movsd -0x40(%rbp), %xmm0
callq 0x4550
movq %rax, %rdi
leaq 0x17335(%rip), %rsi     # 0x3432a
callq 0x42b0
movq %rax, %rdi
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
callq 0x4550
movq %rax, %rdi
movq 0x2bf9c(%rip), %rsi     # 0x48fb0
callq 0x4300
movl $0x8, %edi
callq 0x4130
movq %rax, %rdi
leaq 0x1730d(%rip), %rax     # 0x3433a
movq %rax, (%rdi)
movq 0x2bf81(%rip), %rsi     # 0x48fb8
xorl %eax, %eax
movl %eax, %edx
callq 0x44c0
jmp 0x1d042
jmp 0x1d044
movb -0x19(%rbp), %al
andb $0x1, %al
addq $0x70, %rsp
popq %rbp
retq
nop