// File: /workspace/github_cpp_makefile_star2_O2/gchen98[P]macs/algorithm.cpp
// Function: GraphBuilder::checkPendingGeneConversions(double&)
bool GraphBuilder::checkPendingGeneConversions(double & curPos){
    bool found = false;
    GeneConversionPtrSet::iterator it = pGeneConversionPtrSet->begin();
    while(!found){
        if (it!=pGeneConversionPtrSet->end()){
            GeneConversionPtr gc= *it;
            if (gc->dEndPos<curPos){
                EdgePtr edge0 = gc->xOverNode->getTopEdgeByIndex(0);
                EdgePtr edge1 = gc->xOverNode->getTopEdgeByIndex(1);
                if (gc->xOverNode->bDeleted ||
                edge1->iGraphIteration!=iGraphIteration){
                    if (pConfig->bDebug){
                        cerr<<"Deleting gene conversion because:"<<endl;
                        if (gc->xOverNode->bDeleted)
                          cerr<<"xover node was deleted\n";
                        else if (edge1->iGraphIteration!=iGraphIteration)
                          cerr<<"new edge "<<edge1->getBottomNodeRef()->getHeight()<<" to "<<
                          edge1->getTopNodeRef()->getHeight()<<" was not ancestral\n";
                    }
                    delete(*it);
                    pGeneConversionPtrSet->erase(it++);
                }else{
                    if (pConfig->bDebug){
                        cerr<<"Closing a gene conversion: "<<
                        "Backtracking position from "<<curPos<<" to "<<
                        gc->dEndPos<<endl;
                    }
                    curPos = gc->dEndPos;
                    this->gcOldEdge = edge0;
                    this->gcNewEdge = edge1;
                    delete(*it);
                    pGeneConversionPtrSet->erase(it++);
                    return true;
                }
            }else{
                found = true;
            }
        }else found = true;
    }
    return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r13
movq %rdi, %r15
movq 0xf0(%rdi), %rax
movq 0x18(%rax), %r12
leaq 0x8(%rsp), %rbx
movq 0xf0(%r15), %rax
addq $0x8, %rax
cmpq %rax, %r12
je 0xd2f2
movq 0x20(%r12), %r14
movsd (%r13), %xmm0
ucomisd 0x18(%r14), %xmm0
jbe 0xd2f2
leaq 0x10(%r14), %rbp
movq %rbp, %rdi
callq 0xda4e
leaq 0x20(%rax), %rsi
leaq 0x18(%rsp), %rdi
callq 0xe1ca
movq %rbp, %rdi
callq 0xda4e
leaq 0x30(%rax), %rsi
movq %rbx, %rdi
callq 0xe1ca
movq %rbp, %rdi
callq 0xda4e
cmpb $0x0, 0x10(%rax)
jne 0xd1d9
movq %rbx, %rdi
callq 0xda24
movl 0x14(%rax), %eax
cmpl 0xd0(%r15), %eax
je 0xd303
movq 0x8(%r15), %rax
cmpb $0x1, 0x48(%rax)
jne 0xd2a9
movq 0x11e02(%rip), %rdi     # 0x1eff0
leaq 0x90bd(%rip), %rsi      # 0x162b2
callq 0x3250
movq %rax, %rdi
callq 0x3100
movq %rbp, %rdi
callq 0xda4e
cmpb $0x1, 0x10(%rax)
movq 0x11ddb(%rip), %rdi     # 0x1eff0
leaq 0x90b8(%rip), %rsi      # 0x162d4
je 0xd2a4
movq %rbx, %rdi
callq 0xda24
movl 0x14(%rax), %eax
cmpl 0xd0(%r15), %eax
je 0xd2a9
movq 0x11db3(%rip), %rdi     # 0x1eff0
leaq 0x90a8(%rip), %rsi      # 0x162ec
callq 0x3250
movq %rax, %rbp
movq %rbx, %rdi
callq 0xda24
leaq 0x20(%rax), %rdi
callq 0xda4e
movsd 0x70(%rax), %xmm0
movq %rbp, %rdi
callq 0x3370
movq %rax, %rdi
leaq 0x7e25(%rip), %rsi      # 0x15099
callq 0x3250
movq %rax, %rbp
movq %rbx, %rdi
callq 0xda24
leaq 0x18(%rax), %rdi
callq 0xda4e
movsd 0x70(%rax), %xmm0
movq %rbp, %rdi
callq 0x3370
movq %rax, %rdi
leaq 0x9052(%rip), %rsi      # 0x162f6
callq 0x3250
movq 0x20(%r12), %rdi
testq %rdi, %rdi
je 0xd2b9
movq (%rdi), %rax
callq *0x8(%rax)
movq 0xf0(%r15), %r14
movq %r12, %rdi
callq 0x32a0
movq %rax, %rbp
movq %r14, %rdi
movq %r12, %rsi
callq 0xf494
leaq 0x10(%rsp), %rdi
callq 0xdff8
leaq 0x20(%rsp), %rdi
callq 0xdff8
movq %rbp, %r12
jmp 0xd15a
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%r15), %rax
cmpb $0x1, 0x48(%rax)
jne 0xd362
movq 0x11cdc(%rip), %rdi     # 0x1eff0
leaq 0x8fef(%rip), %rsi      # 0x1630a
callq 0x3250
leaq 0x8fff(%rip), %rsi      # 0x16326
movq %rax, %rdi
callq 0x3250
movsd (%r13), %xmm0
movq %rax, %rdi
callq 0x3370
leaq 0x7d55(%rip), %rsi      # 0x15099
movq %rax, %rdi
callq 0x3250
movsd 0x18(%r14), %xmm0
movq %rax, %rdi
callq 0x3370
movq %rax, %rdi
callq 0x3100
movsd 0x18(%r14), %xmm0
movsd %xmm0, (%r13)
leaq 0x100(%r15), %rdi
leaq 0x18(%rsp), %rsi
callq 0xda78
leaq 0x110(%r15), %rdi
leaq 0x8(%rsp), %rsi
callq 0xda78
movq 0x20(%r12), %rdi
testq %rdi, %rdi
je 0xd3a0
movq (%rdi), %rax
callq *0x8(%rax)
movq 0xf0(%r15), %rdi
movq %r12, %rsi
callq 0xf494
leaq 0x10(%rsp), %rdi
callq 0xdff8
leaq 0x20(%rsp), %rdi
callq 0xdff8
movb $0x1, %al
jmp 0xd2f4
jmp 0xd3cc
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xdff8
leaq 0x20(%rsp), %rdi
callq 0xdff8
movq %rbx, %rdi
callq 0x3400
nop