// File: /workspace/github_cpp_makefile_star2_O2/gchen98[P]macs/algorithm.cpp
// Function: GraphBuilder::pruneARG(int)
void GraphBuilder::pruneARG(int iHistoryMax){
    bool found = false;
    EdgePtrList candidateEdges;
    EdgePtrList::iterator it = pEdgeListInARG->begin();
    // look for old edges that have an expired graph iteration value
    while (it!=pEdgeListInARG->end()){
        EdgePtr curEdge = *it;
        if (curEdge->iGraphIteration<=iHistoryMax)
            candidateEdges.push_back(curEdge);
        ++it;
    }
    candidateEdges.sort(byBottomNode());
    do{
        EdgePtr oldEdge;
        found = false;
        // sort the edges from top to bottom as the pruning order
        EdgePtrList::iterator it2 = candidateEdges.begin();
        while(!found && it2!=candidateEdges.end()){
            EdgePtr curEdge = *it2;
            if (!curEdge->bDeleted &&curEdge->getBottomNodeRef()->
            getType()==Node::XOVER){
                oldEdge = curEdge;
                found = true;
            }else{
                ++it2;
            }
        }
        if (found){
            NodePtr & xoverNode = oldEdge->getBottomNodeRef();
            EdgePtr edge0 = xoverNode->getTopEdgeByIndex(0);
            EdgePtr edge1 = xoverNode->getTopEdgeByIndex(1);
            EdgePtr edgeToPrune = edge0->iGraphIteration<
            edge1->iGraphIteration?edge0:edge1;

            pruneEdgesAbove(edgeToPrune);

            edge0 = xoverNode->getTopEdgeByIndex(0);
            edge1 = xoverNode->getTopEdgeByIndex(1);

            EdgePtr otherTopEdge = edge0->iGraphIteration>
            edge1->iGraphIteration?edge0:edge1;

            EdgePtr bottomEdge = xoverNode->getBottomEdgeByIndex(0);

            if (grandMRCA->getHeight()>xoverNode->getHeight()){
                mergeEdges(otherTopEdge,bottomEdge);
                xoverNode->removeEvent();
            }else{
                // we just removed a loop above the grandMRCA which
                // includes the edges around the xover point.
            }
        }
    }while(found);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x70(%rsp), %r14
movq %r14, 0x8(%r14)
movq %r14, (%r14)
andq $0x0, 0x10(%r14)
movq 0x10(%rdi), %rax
movq (%rax), %r13
leaq 0x8(%rsp), %r15
movq %rsp, %r12
cmpq %rax, %r13
je 0xc9a9
movq 0x10(%r13), %rax
movq %rax, (%rsp)
movq 0x18(%r13), %rax
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0xc97f
lock
incl 0x8(%rax)
movq %r12, %rdi
callq 0xda24
cmpl %ebp, 0x14(%rax)
jg 0xc997
movq %r14, %rdi
movq %r12, %rsi
callq 0xde3c
movq (%r13), %r13
movq %r15, %rdi
callq 0xdff8
movq 0x10(%rbx), %rax
jmp 0xc960
leaq 0x70(%rsp), %rbp
movq %rbp, %rdi
callq 0xde48
leaq 0x38(%rsp), %r13
leaq 0x38(%rbx), %rax
movq %rax, 0x50(%rsp)
xorpd %xmm0, %xmm0
leaq 0x30(%rsp), %r12
movapd %xmm0, (%rsp)
movq 0x70(%rsp), %r14
xorl %r15d, %r15d
testb $0x1, %r15b
jne 0xca49
cmpq %rbp, %r14
je 0xcc19
movq 0x10(%r14), %rax
movq %rax, 0x30(%rsp)
movq 0x18(%r14), %rax
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0xca04
lock
incl 0x8(%rax)
movq %r12, %rdi
callq 0xda24
cmpb $0x0, 0x10(%rax)
jne 0xca39
movq %r12, %rdi
callq 0xda24
leaq 0x20(%rax), %rdi
callq 0xda4e
cmpl $0x1, 0x64(%rax)
jne 0xca39
movq %rsp, %rdi
movq %r12, %rsi
callq 0xda78
movb $0x1, %r15b
jmp 0xca3f
movq (%r14), %r14
xorl %r15d, %r15d
movq %r13, %rdi
callq 0xdff8
jmp 0xc9da
movq %rsp, %rdi
callq 0xda24
movq %rax, %r14
addq $0x20, %r14
movq %r14, %rdi
callq 0xda4e
leaq 0x20(%rax), %rsi
movq %r12, %rdi
callq 0xe1ca
movq %r14, %rdi
callq 0xda4e
leaq 0x30(%rax), %rsi
leaq 0x10(%rsp), %rdi
callq 0xe1ca
movq %r12, %rdi
callq 0xda24
movl 0x14(%rax), %r15d
leaq 0x10(%rsp), %rdi
callq 0xda24
cmpl 0x14(%rax), %r15d
leaq 0x10(%rsp), %rax
cmovlq %r12, %rax
movq (%rax), %rax
leaq 0x18(%rsp), %rcx
cmovlq %r13, %rcx
movq %rax, 0x40(%rsp)
movq (%rcx), %rax
movq %rax, 0x48(%rsp)
testq %rax, %rax
je 0xcac7
lock
incl 0x8(%rax)
movq %rbx, %rdi
leaq 0x40(%rsp), %rsi
callq 0x8fe6
movq %r14, %rdi
callq 0xda4e
leaq 0x20(%rax), %rsi
leaq 0x20(%rsp), %r15
movq %r15, %rdi
callq 0xe1ca
movq %r12, %rdi
movq %r15, %rsi
callq 0xdbce
leaq 0x28(%rsp), %rdi
callq 0xdff8
movq %r14, %rdi
callq 0xda4e
leaq 0x30(%rax), %rsi
movq %r15, %rdi
callq 0xe1ca
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0xdbce
leaq 0x28(%rsp), %rdi
callq 0xdff8
movq %r12, %rdi
callq 0xda24
movl 0x14(%rax), %r15d
leaq 0x10(%rsp), %rdi
callq 0xda24
cmpl 0x14(%rax), %r15d
leaq 0x10(%rsp), %rax
cmovgq %r12, %rax
movq (%rax), %rax
leaq 0x18(%rsp), %rcx
cmovgq %r13, %rcx
movq %rax, 0x20(%rsp)
movq (%rcx), %rax
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0xcb72
lock
incl 0x8(%rax)
movq %r14, %rdi
callq 0xda4e
leaq 0x40(%rax), %rsi
leaq 0x60(%rsp), %rdi
callq 0xe1ca
movq 0x50(%rsp), %rdi
callq 0xda4e
movsd 0x70(%rax), %xmm0
movsd %xmm0, 0x58(%rsp)
movq %r14, %rdi
callq 0xda4e
movsd 0x58(%rsp), %xmm0
ucomisd 0x70(%rax), %xmm0
jbe 0xcbd4
movq %rbx, %rdi
leaq 0x20(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x10ec6
movq %r14, %rdi
callq 0xda4e
movq %rax, %rdi
callq 0xdb54
leaq 0x68(%rsp), %rdi
callq 0xdff8
leaq 0x28(%rsp), %rdi
callq 0xdff8
leaq 0x48(%rsp), %rdi
callq 0xdff8
leaq 0x18(%rsp), %rdi
callq 0xdff8
leaq 0x38(%rsp), %rdi
callq 0xdff8
leaq 0x8(%rsp), %rdi
callq 0xdff8
xorpd %xmm0, %xmm0
jmp 0xc9cd
leaq 0x8(%rsp), %rdi
callq 0xdff8
leaq 0x70(%rsp), %rdi
callq 0xe2ec
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0xdff8
leaq 0x28(%rsp), %rdi
callq 0xdff8
jmp 0xcc60
movq %rax, %rbx
jmp 0xcc90
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0xdff8
leaq 0x18(%rsp), %rdi
callq 0xdff8
leaq 0x38(%rsp), %rdi
callq 0xdff8
leaq 0x8(%rsp), %rdi
jmp 0xcc8b
movq %rax, %rbx
movq %r15, %rdi
callq 0xdff8
leaq 0x70(%rsp), %rdi
callq 0xe2ec
movq %rbx, %rdi
callq 0x3400