// File: 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
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x108(%rbp)
movb $0x0, -0xd(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x1f1d0
movq -0x108(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x1f1f0
movq %rax, -0x30(%rbp)
movq -0x108(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x1f250
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x1f220
testb $0x1, %al
jne 0x1c2d5
jmp 0x1c33d
leaq -0x30(%rbp), %rdi
callq 0x1f280
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x1df40
leaq -0x48(%rbp), %rdi
callq 0x1de60
movl 0x14(%rax), %eax
cmpl -0xc(%rbp), %eax
jg 0x1c326
leaq -0x28(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x1f2a0
jmp 0x1c30a
jmp 0x1c326
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x1e090
jmp 0x1c7ef
leaq -0x30(%rbp), %rdi
callq 0x1f2e0
leaq -0x48(%rbp), %rdi
callq 0x1e090
jmp 0x1c2ae
leaq -0x28(%rbp), %rdi
callq 0x1f300
jmp 0x1c348
jmp 0x1c34a
leaq -0x68(%rbp), %rdi
callq 0x1dfb0
movb $0x0, -0xd(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x1f1f0
movq %rax, -0x70(%rbp)
xorl %eax, %eax
testb $0x1, -0xd(%rbp)
movb %al, -0x109(%rbp)
jne 0x1c392
leaq -0x28(%rbp), %rdi
callq 0x1f250
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x1f220
movb %al, -0x109(%rbp)
movb -0x109(%rbp), %al
testb $0x1, %al
jne 0x1c3a1
jmp 0x1c471
leaq -0x70(%rbp), %rdi
callq 0x1f280
movq %rax, %rsi
leaq -0x88(%rbp), %rdi
callq 0x1df40
leaq -0x88(%rbp), %rdi
callq 0x1de60
testb $0x1, 0x10(%rax)
jne 0x1c457
leaq -0x88(%rbp), %rdi
callq 0x1de60
movq %rax, %rdi
callq 0x1deb0
movq %rax, -0x118(%rbp)
jmp 0x1c3ec
movq -0x118(%rbp), %rdi
callq 0x1ded0
movq %rax, %rdi
callq 0x1e200
movl %eax, -0x11c(%rbp)
jmp 0x1c408
movl -0x11c(%rbp), %eax
cmpl $0x1, %eax
jne 0x1c457
leaq -0x68(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x1e000
movb $0x1, -0xd(%rbp)
jmp 0x1c460
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1c7ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x1e090
jmp 0x1c7e6
leaq -0x70(%rbp), %rdi
callq 0x1f2e0
leaq -0x88(%rbp), %rdi
callq 0x1e090
jmp 0x1c364
testb $0x1, -0xd(%rbp)
je 0x1c7c1
leaq -0x68(%rbp), %rdi
callq 0x1de60
movq %rax, %rdi
callq 0x1deb0
movq %rax, -0x128(%rbp)
jmp 0x1c495
movq -0x128(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
callq 0x1ded0
movq %rax, %rsi
leaq -0xa0(%rbp), %rdi
xorl %edx, %edx
callq 0x1e390
jmp 0x1c4c2
movq -0x90(%rbp), %rdi
callq 0x1ded0
movq %rax, %rsi
leaq -0xb0(%rbp), %rdi
movl $0x1, %edx
callq 0x1e390
jmp 0x1c4e4
leaq -0xa0(%rbp), %rdi
callq 0x1de60
movl 0x14(%rax), %eax
movl %eax, -0x12c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x1de60
movq %rax, %rcx
movl -0x12c(%rbp), %eax
cmpl 0x14(%rcx), %eax
jge 0x1c523
leaq -0xa0(%rbp), %rax
movq %rax, -0x138(%rbp)
jmp 0x1c533
leaq -0xb0(%rbp), %rax
movq %rax, -0x138(%rbp)
jmp 0x1c533
movq -0x138(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x1df40
movq -0x108(%rbp), %rdi
movq -0x140(%rbp), %rsi
callq 0x15bf0
jmp 0x1c562
movq -0x90(%rbp), %rdi
callq 0x1ded0
movq %rax, %rsi
leaq -0xd0(%rbp), %rdi
xorl %edx, %edx
callq 0x1e390
jmp 0x1c581
leaq -0xa0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movq %rsi, -0x148(%rbp)
callq 0x1e630
movq -0x148(%rbp), %rdi
callq 0x1e090
movq -0x90(%rbp), %rdi
callq 0x1ded0
movq %rax, %rsi
leaq -0xe0(%rbp), %rdi
movl $0x1, %edx
callq 0x1e390
jmp 0x1c5c9
leaq -0xb0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x1e630
leaq -0xe0(%rbp), %rdi
callq 0x1e090
leaq -0xa0(%rbp), %rdi
callq 0x1de60
movl 0x14(%rax), %eax
movl %eax, -0x14c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x1de60
movq %rax, %rcx
movl -0x14c(%rbp), %eax
cmpl 0x14(%rcx), %eax
jle 0x1c627
leaq -0xa0(%rbp), %rax
movq %rax, -0x158(%rbp)
jmp 0x1c637
leaq -0xb0(%rbp), %rax
movq %rax, -0x158(%rbp)
jmp 0x1c637
movq -0x158(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x1df40
movq -0x90(%rbp), %rdi
callq 0x1ded0
movq %rax, %rsi
leaq -0x100(%rbp), %rdi
xorl %edx, %edx
callq 0x1e260
jmp 0x1c669
movq -0x108(%rbp), %rdi
addq $0x38, %rdi
callq 0x1ded0
movq %rax, %rdi
callq 0x1df20
movsd %xmm0, -0x160(%rbp)
jmp 0x1c68b
movq -0x90(%rbp), %rdi
callq 0x1ded0
movq %rax, %rdi
callq 0x1df20
movsd %xmm0, -0x168(%rbp)
jmp 0x1c6a9
movsd -0x160(%rbp), %xmm0
movsd -0x168(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1c74f
movq -0x108(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
leaq -0x100(%rbp), %rdx
callq 0x2a2d0
jmp 0x1c6df
movq -0x90(%rbp), %rdi
callq 0x1ded0
movq %rax, %rdi
callq 0x1e480
jmp 0x1c6f5
jmp 0x1c751
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1c7e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1c7b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1c79b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1c78f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x1e090
jmp 0x1c78f
jmp 0x1c751
leaq -0x100(%rbp), %rdi
callq 0x1e090
leaq -0xf0(%rbp), %rdi
callq 0x1e090
leaq -0xc0(%rbp), %rdi
callq 0x1e090
leaq -0xb0(%rbp), %rdi
callq 0x1e090
leaq -0xa0(%rbp), %rdi
callq 0x1e090
jmp 0x1c7c1
leaq -0xf0(%rbp), %rdi
callq 0x1e090
leaq -0xc0(%rbp), %rdi
callq 0x1e090
leaq -0xb0(%rbp), %rdi
callq 0x1e090
leaq -0xa0(%rbp), %rdi
callq 0x1e090
jmp 0x1c7e6
leaq -0x68(%rbp), %rdi
callq 0x1e090
testb $0x1, -0xd(%rbp)
jne 0x1c34a
leaq -0x28(%rbp), %rdi
callq 0x1f700
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
leaq -0x68(%rbp), %rdi
callq 0x1e090
leaq -0x28(%rbp), %rdi
callq 0x1f700
movq -0x50(%rbp), %rdi
callq 0x44e0
nopw %cs:(%rax,%rax)