// File: /workspace/github_cpp_makefile_star2_O2/gchen98[P]macs/datastructures.cpp
// Function: GraphBuilder::addEdge(boost::shared_ptr<Edge>&)
void GraphBuilder::addEdge(EdgePtr & edge){
    unsigned int iPopulation = edge->getBottomNodeRef()->getPopulation();
    //if(pConfig->bDebug) cerr<<"DEBUG addEdge: iPopulation: "<<iPopulation<<" and pEdgeVectorByPop size "<<pEdgeVectorByPop->size()<<endl;
    this->pEdgeListInARG->push_back(edge);
    while (iPopulation>=pEdgeVectorByPop->size()){
        this->pEdgeVectorByPop->push_back(EdgePtrVector());
        this->pVectorIndicesToRecycle->push_back(EdgeIndexQueue());
        if(pConfig->bDebug)cerr<<"DEBUG! addEdge: Adding pop "<<iPopulation<<" has edge vector size: "<<pEdgeVectorByPop->size()<<endl;
//        if(pConfig->bDebug)cerr<<"DEBUG! addEdge: Just added. Pop "<<iPopulation<<" has edge vector size: "<<pEdgeVectorByPop->at(iPopulation).size()<<endl;
        //cerr<<"Attempting to add edge of population "<<iPopulation<<" when the number of available population edge pools is only "<<pEdgeVectorByPop->size()<<". It is recommended that you increase the migration rates and/or number of sampled chromosomes."<<endl;
        //for(uint i=0;i<pEdgeVectorByPop->size();++i){
         //cerr<<"Pop "<<i<<" has edge vector size: "<<pEdgeVectorByPop->at(i).size()<<endl;
        //}
         // throw "Data structure integrity error.";
        //}
      //}
    }
    if (iPopulation>=pEdgeVectorByPop->size()){
      if(pConfig->bDebug) cerr<<"DEBUG! addEdge: Still not added! iPopulation: "<<iPopulation<<" and pEdgeVectorByPop size "<<pEdgeVectorByPop->size()<<endl;
      throw "Something wrong with while loop";
    }
    
    // Insert into the vector allowing for random access
    EdgePtrVector & pEdgeVector = this->pEdgeVectorByPop->
    at(iPopulation);
    EdgeIndexQueue & pVectorIndicesToRecycle = this->pVectorIndicesToRecycle->
    at(iPopulation);
    if (pVectorIndicesToRecycle.empty()){
        pEdgeVector.push_back(edge);
        //if(pConfig->bDebug) cerr<<"DEBUG: pEdgeVector for pop "<<iPopulation<<" is now size: "<<pEdgeVector.size()<<endl;
    }else{
        int iIndex = pVectorIndicesToRecycle.front();
        pVectorIndicesToRecycle.pop();
        pEdgeVector[iIndex] = edge;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r15
movq %rdi, %r14
movq %rsi, %rdi
callq 0xda24
leaq 0x20(%rax), %rdi
callq 0xda4e
movswq 0x62(%rax), %rbx
movq 0x10(%r14), %rdi
movq %r15, 0x8(%rsp)
movq %r15, %rsi
callq 0xde3c
movl %ebx, %r15d
pushq $0x18
popq %rbp
leaq 0x10(%rsp), %r12
leaq 0x5952(%rip), %rbx      # 0x166d9
movq 0x98(%r14), %rdi
movq 0x8(%rdi), %rax
subq (%rdi), %rax
cqto
idivq %rbp
cmpq %r15, %rax
ja 0x10e41
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movq %r12, %rsi
callq 0x122d6
movq %r12, %rdi
callq 0x11ca0
movq 0xa0(%r14), %r13
movq %r12, %rdi
callq 0x11cde
movq %r13, %rdi
movq %r12, %rsi
callq 0x12650
movq %r12, %rdi
callq 0x11f1a
movq 0x8(%r14), %rax
cmpb $0x1, 0x48(%rax)
jne 0x10d87
movq 0xe1fc(%rip), %rdi      # 0x1eff0
leaq 0x58c2(%rip), %rsi      # 0x166bd
callq 0x3250
movq %rax, %rdi
movq %r15, %rsi
callq 0x31a0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x3250
movq %rax, %rdi
movq 0x98(%r14), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
cqto
idivq %rbp
movq %rax, %rsi
callq 0x31a0
movq %rax, %rdi
callq 0x3100
jmp 0x10d87
movq %r15, %rsi
callq 0xdab2
movq %rax, %rbx
movq 0xa0(%r14), %rdi
movq %r15, %rsi
callq 0xdad0
movq 0x10(%rax), %rcx
cmpq %rcx, 0x30(%rax)
je 0x10e86
movslq (%rcx), %r14
movq %rax, %rdi
callq 0x132d4
shlq $0x4, %r14
addq (%rbx), %r14
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0xda78
jmp 0x10e93
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0x11d48
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x11ca0
jmp 0x10ebe
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x11f1a
movq %rbx, %rdi
callq 0x3400