// File: /workspace/github_cpp_makefile_star2_O3/gchen98[P]macs/algorithm.cpp
// Function: GraphBuilder::addMutations(double, double)
void GraphBuilder::addMutations(double startPos,double endPos){
    bool bEndMutate = false;
    while(!bEndMutate){
        // find the next point on this interval
        startPos+=pRandNumGenerator->expRV(dLastTreeLength*
        pConfig->dTheta);
        if (startPos>=endPos){
            bEndMutate = true;
        }else{
            //if (pMutationPtrVector->size()==0){
            //   cout<<HAPLOBEGIN<<endl;
            //}
            double dRandomSpot = pRandNumGenerator->unifRV() * dLastTreeLength;
            double dMutationTime=-1.;
            EdgePtr selectedEdge = getRandomEdgeOnTree(dMutationTime,dRandomSpot);
            //cerr<<"Mutation time is "<<dMutationTime<<endl;
            mutateBelowEdge(selectedEdge);
            NodePtrVector::iterator it;

            cout<<MUTATIONSITE<<FIELD_DELIMITER<<pMutationPtrVector->size()<<
            FIELD_DELIMITER<< setw(15) << setprecision(9)<<startPos<<
            FIELD_DELIMITER<< setw(15) << setprecision(9)<<dMutationTime<<
            FIELD_DELIMITER;
            unsigned int iSampleSize = pConfig->iSampleSize;
            for (unsigned int iSampleIndex=0;iSampleIndex<iSampleSize;++iSampleIndex){
                SampleNode * sample = static_cast<SampleNode*>(pSampleNodeArray[iSampleIndex].get());
                sites[iSampleIndex]=sample->bAffected;
                cout<<sample->bAffected;
                sample->bAffected=false;
            }
            cout<<endl;
            double dFreq=0.;
            if (pConfig->bSNPAscertainment){
                // first compute the MAF
                int counts=0;
                for (unsigned int i=0;i<iSampleSize;++i){
                    counts=counts+sites[i];
                }
                dFreq = 1.*counts/iSampleSize;
                if (pConfig->bFlipAlleles && dFreq>.5){
                    for (unsigned int i=0;i<iSampleSize;++i){
                        sites[i]=!sites[i];
                    }
                    dFreq = 1.-dFreq;
                }
                AlleleFreqBinPtr query(new AlleleFreqBin(dFreq,dFreq,0.));
                AlleleFreqBinPtrSet::iterator it = pConfig->pAlleleFreqBinPtrSet->find(query);
                if (it!=pConfig->pAlleleFreqBinPtrSet->end()){
                    AlleleFreqBinPtr bin = *it;
                    ++bin->iObservedCounts;
                }else throw "Did not find a frequency range for freq";
            }
            pMutationPtrVector->push_back(MutationPtr(new Mutation(startPos,dFreq)));

        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %r14
leaq 0x28(%rsp), %r15
movq 0x10b11(%rip), %r13     # 0x1ffd0
movsd %xmm1, 0x18(%rsp)
movsd %xmm0, 0x8(%rsp)
movsd 0x30(%r14), %xmm0
movq (%r14), %rax
movq 0x8(%r14), %rcx
mulsd (%rcx), %xmm0
movsd %xmm0, (%rsp)
movq (%rax), %rdi
callq 0x10d90
movsd 0x7b17(%rip), %xmm1     # 0x17008
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
callq 0x31e0
divsd (%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x8(%rsp), %xmm0
ucomisd 0x18(%rsp), %xmm0
jae 0xf7fe
movq (%r14), %rax
movq (%rax), %rdi
callq 0x10d90
mulsd 0x30(%r14), %xmm0
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
movq %rax, 0x20(%rsp)
movq %r15, %rdi
movq %r14, %rsi
leaq 0x20(%rsp), %rdx
callq 0x9aac
movq %r14, %rdi
movq %r15, %rsi
callq 0xa044
movq 0x10ed1(%rip), %rsi     # 0x20438
movq 0x10ed2(%rip), %rdx     # 0x20440
movq %r13, %rdi
callq 0x32a0
movq 0x10f5b(%rip), %rsi     # 0x204d8
movq 0x10f5c(%rip), %rdx     # 0x204e0
movq %rax, %rdi
callq 0x32a0
movq 0xa8(%r14), %rcx
movq 0x8(%rcx), %rsi
subq (%rcx), %rsi
sarq $0x3, %rsi
movq %rax, %rdi
callq 0x31a0
movq 0x10f2b(%rip), %rsi     # 0x204d8
movq 0x10f2c(%rip), %rdx     # 0x204e0
movq %rax, %rdi
callq 0x32a0
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
movq $0xf, 0x10(%rax,%rdx)
movq -0x18(%rcx), %rcx
movq $0x9, 0x8(%rax,%rcx)
movq %rax, %rdi
movsd 0x8(%rsp), %xmm0
callq 0x3360
movq 0x10eea(%rip), %rsi     # 0x204d8
movq 0x10eeb(%rip), %rdx     # 0x204e0
movq %rax, %rdi
callq 0x32a0
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
movq $0xf, 0x10(%rax,%rdx)
movq -0x18(%rcx), %rcx
movq $0x9, 0x8(%rax,%rcx)
movsd 0x20(%rsp), %xmm0
movq %rax, %rdi
callq 0x3360
movq 0x10ea9(%rip), %rsi     # 0x204d8
movq 0x10eaa(%rip), %rdx     # 0x204e0
movq %rax, %rdi
callq 0x32a0
movq 0x8(%r14), %rax
movl 0x30(%rax), %ebx
testq %rbx, %rbx
je 0xf67b
xorl %r12d, %r12d
movq 0xb0(%r14), %rax
movq 0xc0(%r14), %rcx
movq (%rcx,%r12,8), %rbp
movzbl 0x7c(%rbp), %esi
movb %sil, (%rax,%r12)
movq %r13, %rdi
callq 0x33a0
movb $0x0, 0x7c(%rbp)
incq %r12
cmpq %r12, %rbx
jne 0xf64d
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r13, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
movq 0x8(%r14), %rax
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
cmpb $0x1, 0x49(%rax)
jne 0xf7a5
testq %rbx, %rbx
je 0xf719
movq 0xb0(%r14), %rcx
xorl %edx, %edx
xorl %esi, %esi
movzbl (%rcx,%rdx), %edi
addl %edi, %esi
incq %rdx
cmpq %rdx, %rbx
jne 0xf6ca
cvtsi2sd %esi, %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %rbx, %xmm0
divsd %xmm0, %xmm1
cmpb $0x1, 0x4a(%rax)
movsd %xmm1, (%rsp)
jne 0xf74f
ucomisd 0x947d(%rip), %xmm1     # 0x18b78
jbe 0xf74f
testq %rbx, %rbx
je 0xf73d
movq 0xb0(%r14), %rax
xorl %ecx, %ecx
xorb $0x1, (%rax,%rcx)
incq %rcx
cmpq %rcx, %rbx
jne 0xf70b
jmp 0xf73d
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
xorpd %xmm1, %xmm1
divsd %xmm0, %xmm1
cmpb $0x1, 0x4a(%rax)
movsd %xmm1, (%rsp)
jne 0xf74f
ucomisd 0x943d(%rip), %xmm1     # 0x18b78
jbe 0xf74f
movsd 0x78c3(%rip), %xmm0     # 0x17008
subsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movl $0x20, %edi
callq 0x3260
movq %rax, %rbx
xorps %xmm2, %xmm2
movq %rax, %rdi
movsd (%rsp), %xmm0
movapd %xmm0, %xmm1
callq 0x11e5e
movq %rbx, 0x10(%rsp)
movq 0x8(%r14), %rax
movq 0x90(%rax), %rdi
leaq 0x10(%rsp), %rsi
callq 0x11a5a
movq 0x8(%r14), %rcx
movq 0x90(%rcx), %rcx
addq $0x8, %rcx
cmpq %rcx, %rax
je 0xf80d
movq 0x20(%rax), %rax
incl 0x18(%rax)
movq 0xa8(%r14), %rbx
movl $0x18, %edi
callq 0x3260
movq %rax, %r12
movq %rax, %rdi
movsd 0x8(%rsp), %xmm0
movsd (%rsp), %xmm1
callq 0x11dd4
movq %r12, 0x10(%rsp)
movq %rbx, %rdi
leaq 0x10(%rsp), %rsi
callq 0x11ace
leaq 0x30(%rsp), %rdi
callq 0x10d5e
movsd 0x18(%rsp), %xmm1
movsd 0x8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jb 0xf4c5
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x3100
leaq 0x9a6d(%rip), %rcx      # 0x1928b
movq %rcx, (%rax)
movq 0x10788(%rip), %rsi     # 0x1ffb0
movq %rax, %rdi
xorl %edx, %edx
callq 0x33d0
jmp 0xf85f
jmp 0xf85f
movq %rax, %r14
movl $0x20, %esi
movq %rbx, %rdi
jmp 0xf850
jmp 0xf85f
movq %rax, %r14
movl $0x18, %esi
movq %r12, %rdi
callq 0x3270
jmp 0xf862
jmp 0xf85f
jmp 0xf85f
jmp 0xf85f
jmp 0xf85f
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x10d5e
movq %r14, %rdi
callq 0x33f0