// File: gchen98[P]macs/datastructures.cpp
// Function: GraphBuilder::GraphBuilder(Configuration*, RandNumGenerator*)
GraphBuilder::GraphBuilder(Configuration *pConfig,RandNumGenerator * pRG){
    this->iGraphIteration = 0;
    this->bIncrementHistory = false;
    this->iTotalTreeEdges = 0;
    this->dArgLength = 0.;
    this->pConfig = pConfig;
    this->pChrPositionQueue = new ChrPositionQueue;
    this->dTrailingGap = pConfig->dBasesToTrack/pConfig->dSeqLength;
    this->bEndGeneConversion = false;
    this->bBeginGeneConversion = false;
    this->dScaledRecombRate = pConfig->dRecombRateRAcrossSites*
    (pConfig->dGeneConvRatio+1.);
    this->dMigrationMatrix = pConfig->dMigrationMatrix;
    this->pRandNumGenerator = pRG;
    this->pEdgeVectorByPop = new EdgePtrVectorByPop;
    this->pVectorIndicesToRecycle = new EdgeIndexQueueByPop;
    this->pEdgeListInARG = new EdgePtrList;
    this->pTreeEdgesToCoalesceArray = new EdgePtr[pConfig->iSampleSize];
    for (int i=0;i<pConfig->iTotalPops;++i){
        this->pEdgeVectorByPop->push_back(EdgePtrVector());
        cerr<<"DEBUG: Size at "<<i<<" is "<<this->pEdgeVectorByPop->at(i).size()<<endl;
        this->pVectorIndicesToRecycle->push_back(EdgeIndexQueue());
    }
    this->pSampleNodeArray = new NodePtr[pConfig->iSampleSize];
    sites = new bool[pConfig->iSampleSize];
    this->pEdgeVectorInTree = new EdgePtrVector;
    this->pMutationPtrVector = new MutationPtrVector;
    this->pEventList = new EventPtrList;
    EventPtrList::iterator it = pConfig->pEventList->begin();
    for (it=pConfig->pEventList->begin();it!=pConfig->pEventList->end();++it){
        this->pEventList->push_back(*it);
    }
    this->pGeneConversionPtrSet = new GeneConversionPtrSet;
    if (pConfig->pAlleleFreqBinPtrSet!=NULL){
      AlleleFreqBinPtrSet::iterator it2;
      for (it2=pConfig->pAlleleFreqBinPtrSet->begin();it2!=pConfig->pAlleleFreqBinPtrSet->end();++it2){
        AlleleFreqBinPtr ptr = *it2;
        ptr->iObservedCounts = 0;
      }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
addq $0x38, %rdi
movq %rdi, -0x118(%rbp)
callq 0x1e680
movq -0xd8(%rbp), %rdi
addq $0x40, %rdi
movq %rdi, -0x110(%rbp)
callq 0x1e680
movq -0xd8(%rbp), %rdi
addq $0x48, %rdi
movq %rdi, -0x108(%rbp)
callq 0x1e680
movq -0xd8(%rbp), %rdi
movabsq $0x3eb0c6f7a0b5ed8d, %rax # imm = 0x3EB0C6F7A0B5ED8D
movq %rax, 0x50(%rdi)
addq $0x60, %rdi
movq %rdi, -0x100(%rbp)
callq 0xb7e0
movq -0xd8(%rbp), %rdi
addq $0x78, %rdi
movq %rdi, -0xf8(%rbp)
callq 0x1dfb0
movq -0xd8(%rbp), %rdi
addq $0x88, %rdi
movq %rdi, -0xf0(%rbp)
callq 0x1dfb0
movq -0xd8(%rbp), %rdi
addq $0x100, %rdi            # imm = 0x100
movq %rdi, -0xe8(%rbp)
callq 0x1dfb0
movq -0xd8(%rbp), %rdi
addq $0x110, %rdi            # imm = 0x110
movq %rdi, -0xe0(%rbp)
callq 0x1dfb0
movq -0xd8(%rbp), %rax
movl $0x0, 0xd0(%rax)
movb $0x0, 0xe8(%rax)
movl $0x0, 0x20(%rax)
movq $0x0, 0x28(%rax)
movq -0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x50, %edi
callq 0x42c0
movq %rax, -0xd0(%rbp)
jmp 0x285fc
movq -0xd0(%rbp), %rdi
callq 0x2bb30
jmp 0x2860a
movq -0xd8(%rbp), %rdi
movq -0xd0(%rbp), %rax
movq %rax, 0xd8(%rdi)
movq -0x10(%rbp), %rax
movsd 0x20(%rax), %xmm1
movsd 0x28(%rax), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0xe0(%rdi)
movb $0x0, 0xf9(%rdi)
movb $0x0, 0xf8(%rdi)
movq -0x10(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd 0x18(%rax), %xmm1
movsd 0x99ab(%rip), %xmm2     # 0x32008
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0xc8(%rdi)
movq -0x10(%rbp), %rsi
addq $0x50, %rsi
addq $0x60, %rdi
callq 0x1e7c0
jmp 0x28680
movq -0xd8(%rbp), %rax
movq -0x18(%rbp), %rcx
movq %rcx, (%rax)
movl $0x18, %edi
callq 0x42c0
movq %rax, -0x120(%rbp)
jmp 0x286a1
movq -0x120(%rbp), %rdi
callq 0x2bb60
movq -0x120(%rbp), %rcx
movq -0xd8(%rbp), %rax
movq %rcx, 0x98(%rax)
movl $0x18, %edi
callq 0x42c0
movq %rax, -0x128(%rbp)
jmp 0x286d5
movq -0x128(%rbp), %rdi
callq 0x2bb80
movq -0x128(%rbp), %rcx
movq -0xd8(%rbp), %rax
movq %rcx, 0xa0(%rax)
movl $0x18, %edi
callq 0x42c0
movq %rax, -0x130(%rbp)
jmp 0x28709
movq -0x130(%rbp), %rdi
callq 0x1f1d0
movq -0x130(%rbp), %rcx
movq -0xd8(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
movl %eax, %edi
movq %rdi, -0x140(%rbp)
shlq $0x4, %rdi
orq $0x8, %rdi
callq 0x4030
movq %rax, -0x138(%rbp)
jmp 0x2874d
movq -0x140(%rbp), %rax
movq -0x138(%rbp), %rcx
movq %rax, (%rcx)
addq $0x8, %rcx
movq %rcx, -0x148(%rbp)
cmpq $0x0, %rax
je 0x287c6
movq -0x148(%rbp), %rax
movq -0x140(%rbp), %rdx
shlq $0x4, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, -0x158(%rbp)
movq %rax, -0x150(%rbp)
movq -0x150(%rbp), %rdi
movq %rdi, -0x160(%rbp)
callq 0x1dfb0
movq -0x160(%rbp), %rax
movq -0x158(%rbp), %rcx
addq $0x10, %rax
cmpq %rcx, %rax
movq %rax, -0x150(%rbp)
jne 0x28795
movq -0xd8(%rbp), %rax
movq -0x148(%rbp), %rcx
movq %rcx, 0xb8(%rax)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x10(%rbp), %rcx
movzwl 0x3c(%rcx), %ecx
cmpl %ecx, %eax
jge 0x289ac
movq -0xd8(%rbp), %rax
movq 0x98(%rax), %rax
movq %rax, -0x170(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movq $0x0, -0x30(%rbp)
leaq -0x40(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x2bbd0
movq -0x170(%rbp), %rdi
movq -0x168(%rbp), %rsi
callq 0x2bba0
jmp 0x2883e
leaq -0x40(%rbp), %rdi
callq 0x2b9b0
movq 0x207a2(%rip), %rdi     # 0x48ff0
leaq 0xbee8(%rip), %rsi      # 0x3473d
callq 0x42b0
movq %rax, -0x178(%rbp)
jmp 0x28863
movq -0x178(%rbp), %rdi
movl -0x28(%rbp), %esi
callq 0x44d0
movq %rax, -0x180(%rbp)
jmp 0x2887b
movq -0x180(%rbp), %rdi
leaq 0xa481(%rip), %rsi      # 0x32d0a
callq 0x42b0
movq %rax, -0x188(%rbp)
jmp 0x28897
movq -0xd8(%rbp), %rax
movq 0x98(%rax), %rdi
movslq -0x28(%rbp), %rsi
callq 0x1e0d0
movq %rax, -0x190(%rbp)
jmp 0x288b7
movq -0x190(%rbp), %rdi
callq 0x1e150
movq -0x188(%rbp), %rdi
movq %rax, %rsi
callq 0x4090
movq %rax, -0x198(%rbp)
jmp 0x288db
movq -0x198(%rbp), %rdi
movq 0x206c7(%rip), %rsi     # 0x48fb0
callq 0x4300
jmp 0x288f0
movq -0xd8(%rbp), %rax
movq 0xa0(%rax), %rax
movq %rax, -0x1a0(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x2bc20
jmp 0x28913
movq -0x1a0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x2bbf0
jmp 0x28928
leaq -0x90(%rbp), %rdi
callq 0x2bc50
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x287e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x28caf
movq -0xd0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x50, %esi
callq 0x42d0
jmp 0x28caf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x2b9b0
jmp 0x28caf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x2bc50
jmp 0x28caf
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
movq %rax, -0x1b0(%rbp)
leaq 0x8(,%rax,8), %rdi
callq 0x4030
movq %rax, -0x1a8(%rbp)
jmp 0x289d0
movq -0x1b0(%rbp), %rax
movq -0x1a8(%rbp), %rcx
movq %rax, (%rcx)
addq $0x8, %rcx
movq %rcx, -0x1b8(%rbp)
cmpq $0x0, %rax
je 0x28a49
movq -0x1b8(%rbp), %rax
movq -0x1b0(%rbp), %rdx
shlq $0x3, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, -0x1c8(%rbp)
movq %rax, -0x1c0(%rbp)
movq -0x1c0(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x1e680
movq -0x1d0(%rbp), %rax
movq -0x1c8(%rbp), %rcx
addq $0x8, %rax
cmpq %rcx, %rax
movq %rax, -0x1c0(%rbp)
jne 0x28a18
movq -0xd8(%rbp), %rax
movq -0x1b8(%rbp), %rcx
movq %rcx, 0xc0(%rax)
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
movl %eax, %edi
callq 0x4030
movq %rax, -0x1d8(%rbp)
jmp 0x28a75
movq -0xd8(%rbp), %rax
movq -0x1d8(%rbp), %rcx
movq %rcx, 0xb0(%rax)
movl $0x18, %edi
callq 0x42c0
movq %rax, -0x1e0(%rbp)
jmp 0x28a9d
movq -0x1e0(%rbp), %rdi
callq 0x2bbd0
movq -0x1e0(%rbp), %rcx
movq -0xd8(%rbp), %rax
movq %rcx, 0x18(%rax)
movl $0x18, %edi
callq 0x42c0
movq %rax, -0x1e8(%rbp)
jmp 0x28ace
movq -0x1e8(%rbp), %rdi
callq 0x2bc70
movq -0x1e8(%rbp), %rcx
movq -0xd8(%rbp), %rax
movq %rcx, 0xa8(%rax)
movl $0x18, %edi
callq 0x42c0
movq %rax, -0x1f0(%rbp)
jmp 0x28b02
movq -0x1f0(%rbp), %rdi
callq 0xbb70
movq -0x1f0(%rbp), %rcx
movq -0xd8(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rdi
callq 0x124b0
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rdi
callq 0x124b0
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rdi
callq 0x12130
movq %rax, -0xa8(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x12ac0
testb $0x1, %al
jne 0x28b8c
jmp 0x28bcb
movq -0xd8(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x1f8(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x12b40
movq -0x1f8(%rbp), %rdi
movq %rax, %rsi
callq 0xc280
jmp 0x28bbb
jmp 0x28bbd
leaq -0x98(%rbp), %rdi
callq 0x12750
jmp 0x28b5c
movl $0x30, %edi
callq 0x42c0
movq %rax, -0x200(%rbp)
jmp 0x28bde
movq -0x200(%rbp), %rdi
callq 0x2bc90
movq -0x200(%rbp), %rcx
movq -0xd8(%rbp), %rax
movq %rcx, 0xf0(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0x28ca6
leaq -0xb0(%rbp), %rdi
callq 0xb840
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rdi
callq 0xb860
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rdi
callq 0xb8c0
movq %rax, -0xc0(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0xb890
testb $0x1, %al
jne 0x28c72
jmp 0x28ca4
leaq -0xb0(%rbp), %rdi
callq 0xb8f0
movq (%rax), %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movl $0x0, 0x18(%rax)
leaq -0xb0(%rbp), %rdi
callq 0xb920
jmp 0x28c42
jmp 0x28ca6
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
movq -0xe0(%rbp), %rdi
callq 0x1e090
movq -0xe8(%rbp), %rdi
callq 0x1e090
movq -0xf0(%rbp), %rdi
callq 0x1e090
movq -0xf8(%rbp), %rdi
callq 0x1e090
movq -0x100(%rbp), %rdi
callq 0xbae0
movq -0x108(%rbp), %rdi
callq 0x1e420
movq -0x110(%rbp), %rdi
callq 0x1e420
movq -0x118(%rbp), %rdi
callq 0x1e420
movq -0x20(%rbp), %rdi
callq 0x44e0
nopl (%rax,%rax)