// File: 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
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
movb $0x0, -0x19(%rbp)
movq 0xf0(%rax), %rdi
callq 0x1f860
movq %rax, -0x28(%rbp)
movb -0x19(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x1d090
jmp 0x1d543
movq -0x98(%rbp), %rax
movq 0xf0(%rax), %rdi
callq 0x1f8c0
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x1f890
testb $0x1, %al
jne 0x1d0bd
jmp 0x1d53a
leaq -0x28(%rbp), %rdi
callq 0x1f8f0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movsd 0x18(%rax), %xmm1
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1d534
movq -0x38(%rbp), %rdi
addq $0x10, %rdi
callq 0x1ded0
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
xorl %edx, %edx
callq 0x1e390
movq -0x38(%rbp), %rdi
addq $0x10, %rdi
callq 0x1ded0
movq %rax, %rsi
leaq -0x58(%rbp), %rdi
movl $0x1, %edx
callq 0x1e390
jmp 0x1d123
movq -0x38(%rbp), %rdi
addq $0x10, %rdi
callq 0x1ded0
testb $0x1, 0x10(%rax)
jne 0x1d155
leaq -0x58(%rbp), %rdi
callq 0x1de60
movq -0x98(%rbp), %rcx
movl 0x14(%rax), %eax
cmpl 0xd0(%rcx), %eax
je 0x1d382
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rax
testb $0x1, 0x48(%rax)
je 0x1d30f
movq 0x2be7f(%rip), %rdi     # 0x48ff0
leaq 0x171e8(%rip), %rsi     # 0x34360
callq 0x42b0
movq %rax, -0xa0(%rbp)
jmp 0x1d186
movq -0xa0(%rbp), %rdi
movq 0x2be1c(%rip), %rsi     # 0x48fb0
callq 0x4300
jmp 0x1d19b
movq -0x38(%rbp), %rdi
addq $0x10, %rdi
callq 0x1ded0
testb $0x1, 0x10(%rax)
je 0x1d1f3
movq 0x2be3b(%rip), %rdi     # 0x48ff0
leaq 0x171c6(%rip), %rsi     # 0x34382
callq 0x42b0
jmp 0x1d1c3
jmp 0x1d30d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1d529
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x1e090
jmp 0x1d529
leaq -0x58(%rbp), %rdi
callq 0x1de60
movq -0x98(%rbp), %rcx
movl 0x14(%rax), %eax
cmpl 0xd0(%rcx), %eax
je 0x1d30b
movq 0x2bdd7(%rip), %rdi     # 0x48ff0
leaq 0x1717a(%rip), %rsi     # 0x3439a
callq 0x42b0
movq %rax, -0xa8(%rbp)
jmp 0x1d22e
leaq -0x58(%rbp), %rdi
callq 0x1de60
movq %rax, %rdi
callq 0x1deb0
movq %rax, -0xb0(%rbp)
jmp 0x1d248
movq -0xb0(%rbp), %rdi
callq 0x1ded0
movq %rax, %rdi
callq 0x1df20
movsd %xmm0, -0xb8(%rbp)
jmp 0x1d266
movsd -0xb8(%rbp), %xmm0
movq -0xa8(%rbp), %rdi
callq 0x4550
movq %rax, -0xc0(%rbp)
jmp 0x1d283
movq -0xc0(%rbp), %rdi
leaq 0x15ed8(%rip), %rsi     # 0x33169
callq 0x42b0
movq %rax, -0xc8(%rbp)
jmp 0x1d29f
leaq -0x58(%rbp), %rdi
callq 0x1de60
movq %rax, %rdi
callq 0x1e1e0
movq %rax, -0xd0(%rbp)
jmp 0x1d2b9
movq -0xd0(%rbp), %rdi
callq 0x1ded0
movq %rax, %rdi
callq 0x1df20
movsd %xmm0, -0xd8(%rbp)
jmp 0x1d2d7
movsd -0xd8(%rbp), %xmm0
movq -0xc8(%rbp), %rdi
callq 0x4550
movq %rax, -0xe0(%rbp)
jmp 0x1d2f4
movq -0xe0(%rbp), %rdi
leaq 0x170a2(%rip), %rsi     # 0x343a4
callq 0x42b0
jmp 0x1d309
jmp 0x1d30b
jmp 0x1d30d
jmp 0x1d30f
leaq -0x28(%rbp), %rdi
callq 0x1f8f0
movq (%rax), %rax
movq %rax, -0xe8(%rbp)
cmpq $0x0, %rax
je 0x1d335
movq -0xe8(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0x98(%rbp), %rax
movq 0xf0(%rax), %rax
movq %rax, -0xf8(%rbp)
leaq -0x28(%rbp), %rdi
xorl %esi, %esi
callq 0x1f960
movq -0xf8(%rbp), %rdi
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rsi
callq 0x1f920
movq %rax, -0xf0(%rbp)
jmp 0x1d372
movq -0xf0(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x1d4fd
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rax
testb $0x1, 0x48(%rax)
je 0x1d43d
movq 0x2bc52(%rip), %rdi     # 0x48ff0
leaq 0x17013(%rip), %rsi     # 0x343b8
callq 0x42b0
movq %rax, -0x100(%rbp)
jmp 0x1d3b3
movq -0x100(%rbp), %rdi
leaq 0x17013(%rip), %rsi     # 0x343d4
callq 0x42b0
movq %rax, -0x108(%rbp)
jmp 0x1d3cf
movq -0x108(%rbp), %rdi
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
callq 0x4550
movq %rax, -0x110(%rbp)
jmp 0x1d3ec
movq -0x110(%rbp), %rdi
leaq 0x15d6f(%rip), %rsi     # 0x33169
callq 0x42b0
movq %rax, -0x118(%rbp)
jmp 0x1d408
movq -0x118(%rbp), %rdi
movq -0x38(%rbp), %rax
movsd 0x18(%rax), %xmm0
callq 0x4550
movq %rax, -0x120(%rbp)
jmp 0x1d426
movq -0x120(%rbp), %rdi
movq 0x2bb7c(%rip), %rsi     # 0x48fb0
callq 0x4300
jmp 0x1d43b
jmp 0x1d43d
movq -0x98(%rbp), %rdi
movq -0x38(%rbp), %rax
movsd 0x18(%rax), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
addq $0x100, %rdi            # imm = 0x100
leaq -0x48(%rbp), %rsi
callq 0x1e000
movq -0x98(%rbp), %rdi
addq $0x110, %rdi            # imm = 0x110
leaq -0x58(%rbp), %rsi
callq 0x1e000
leaq -0x28(%rbp), %rdi
callq 0x1f8f0
movq (%rax), %rax
movq %rax, -0x128(%rbp)
cmpq $0x0, %rax
je 0x1d4a2
movq -0x128(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0x98(%rbp), %rax
movq 0xf0(%rax), %rax
movq %rax, -0x138(%rbp)
leaq -0x28(%rbp), %rdi
xorl %esi, %esi
callq 0x1f960
movq -0x138(%rbp), %rdi
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rsi
callq 0x1f920
movq %rax, -0x130(%rbp)
jmp 0x1d4df
movq -0x130(%rbp), %rax
movq %rax, -0x88(%rbp)
movb $0x1, -0x1(%rbp)
movl $0x1, -0x8c(%rbp)
jmp 0x1d507
movl $0x0, -0x8c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x1e090
leaq -0x48(%rbp), %rdi
callq 0x1e090
movl -0x8c(%rbp), %eax
testl %eax, %eax
je 0x1d527
jmp 0x1d525
jmp 0x1d547
jmp 0x1d538
leaq -0x48(%rbp), %rdi
callq 0x1e090
jmp 0x1d555
movb $0x1, -0x19(%rbp)
jmp 0x1d53e
movb $0x1, -0x19(%rbp)
jmp 0x1d082
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x44e0
nop