// File: /workspace/github_cpp_makefile_star2_O3/gchen98[P]macs/datastructures.cpp
// Function: GraphBuilder::printHaplotypes()
void GraphBuilder::printHaplotypes(){
    unsigned int iTotalSites = pMutationPtrVector->size();
    bool bZeroCellCount=false;
    if (pConfig->bDebug) cerr<<"Total sites: "<<iTotalSites<<endl;
    if (iTotalSites){
        int iReducedSites=iTotalSites;
        if (pConfig->bSNPAscertainment){
            // first see if any expected count exceed actual counts
            bool bSufficientObs=false;
            do{
                bSufficientObs=true;
                AlleleFreqBinPtrSet::iterator it=pConfig->pAlleleFreqBinPtrSet->begin();
                while(bSufficientObs && !bZeroCellCount && it!=pConfig->pAlleleFreqBinPtrSet->end()){
                    AlleleFreqBinPtr bin = *it;
                    int iExpectedCount = static_cast<int>(bin->dFreq * iReducedSites);
                    if (!iExpectedCount && bin->dFreq>0.){
                        bZeroCellCount = true;
                        if (pConfig->bDebug){
                            cerr<<"Setting zero cell count true because expecting a proportion of "<<
                            bin->dFreq<<" but found "<<iExpectedCount<<endl;
                        }
                    }
                    else if (bin->iObservedCounts<iExpectedCount){
                        bSufficientObs = false;
                        --iReducedSites;
                    }else{
                        ++it;
                    }
                }
            }while(!bSufficientObs && !bZeroCellCount);
            if (bZeroCellCount){
                cerr<<"Warning: Some observed SNP counts were zero when they should have been positive.\n"<<
                "No ascertainment correction was applied.\n"<<
                "Try expanding frequency bin sizes and/or increasing mutation rate.\n";
                iReducedSites = 0;
            }else{
                int tally=0;
                for (AlleleFreqBinPtrSet::iterator it=pConfig->pAlleleFreqBinPtrSet->begin();
                it!=pConfig->pAlleleFreqBinPtrSet->end();++it){
                    AlleleFreqBinPtr bin = *it;
                    double dStart = bin->dStart;
                    double dEnd = bin->dEnd;
                    int iExpectedCount = static_cast<int>(bin->dFreq * iReducedSites);

                    tally+=iExpectedCount;
                    if (pConfig->bDebug) {
                        cerr<<"Looking for SNPs in range "<<dStart<<" to "<<dEnd<<endl;
                        cerr<<"iObserved count: "<<bin->iObservedCounts<<endl;
                        cerr<<"Expecting "<<iExpectedCount<<" SNPS."<<endl;
                    }
                    #ifdef DIAG
                    if (bin->iObservedCounts<iExpectedCount){
                        throw "Too many expected counts";
                    }
                    #endif
                    while(iExpectedCount>0){
                        int iRandIndex = static_cast<int>(pRandNumGenerator->unifRV()*iTotalSites);
                        MutationPtr mutation = pMutationPtrVector->at(iRandIndex);
                        if (!mutation->bPrintOutput && mutation->dFreq>=dStart && mutation->dFreq<=dEnd){
                            mutation->bPrintOutput = true;
                            --iExpectedCount;
                        }
                    }
                }
                iReducedSites = tally;
                cerr<<"Total sites reduced from "<<iTotalSites<<" to "<<iReducedSites<<endl;
            }
        }
        if (iReducedSites){
            MutationPtrVector::iterator it;
            // copy to a temporary vector if ascertained
            cout<<TOTALSAMPLES<<FIELD_DELIMITER<<pConfig->iSampleSize<<endl;
            cout<<TOTALSITES<<FIELD_DELIMITER<<iReducedSites<<endl;
            cout<<SNPBEGIN<<endl;
            if (pConfig->bSNPAscertainment && !bZeroCellCount){
                int origIndex=0;
                bool indexPrinted=false;
                for (it = pMutationPtrVector->begin();
                it!=pMutationPtrVector->end();++it){
                    MutationPtr mutation = *it;
                    if (mutation->bPrintOutput){
                        if (indexPrinted) cout<<FIELD_DELIMITER;
                        cout<<origIndex;
                        indexPrinted=true;
                    }
                    ++origIndex;
                }
            }else{
                for(int i=0;i<iReducedSites;++i){
                  if (i) cout<<FIELD_DELIMITER;
                  cout<<i;
                }
            }
            cout<<endl<<SNPEND<<endl;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq 0xa8(%rdi), %rax
movq 0x8(%rax), %r14
subq (%rax), %r14
movq 0x8(%rdi), %rax
shrq $0x3, %r14
cmpb $0x1, 0x48(%rax)
jne 0x142df
movq 0xbd5a(%rip), %r15      # 0x1fff0
leaq 0x54a4(%rip), %rsi      # 0x19741
movl $0xd, %edx
movq %r15, %rdi
callq 0x32a0
movl %r14d, %esi
movq %r15, %rdi
callq 0x31a0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
testl %r14d, %r14d
je 0x14882
movq 0x8(%rbx), %rax
cmpb $0x1, 0x49(%rax)
jne 0x14706
xorl %r13d, %r13d
movq 0xbcf0(%rip), %r15      # 0x1fff0
movq %r14, 0x8(%rsp)
movl %r14d, (%rsp)
testb $0x1, %r13b
jne 0x14414
xorps %xmm0, %xmm0
cvtsi2sdl (%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x8(%rbx), %rax
movq 0x90(%rax), %rax
movq 0x18(%rax), %rbp
movq 0x8(%rbx), %rax
movq 0x90(%rax), %rcx
addq $0x8, %rcx
cmpq %rcx, %rbp
je 0x14465
movq 0x20(%rbp), %r14
movsd 0x10(%r14), %xmm0
ucomisd 0x2cb6(%rip), %xmm0     # 0x17010
mulsd 0x10(%rsp), %xmm0
cvttsd2si %xmm0, %ecx
jbe 0x143ea
testl %ecx, %ecx
jne 0x143ea
movb $0x1, %r13b
cmpb $0x1, 0x48(%rax)
jne 0x143fb
movl $0x3f, %edx
movq %r15, %rdi
leaq 0x53c5(%rip), %rsi      # 0x1974f
callq 0x32a0
movsd 0x10(%r14), %xmm0
movq %r15, %rdi
callq 0x3360
movq %rax, %r12
movl $0xb, %edx
movq %rax, %rdi
leaq 0x53e0(%rip), %rsi      # 0x1978f
callq 0x32a0
movq %r12, %rdi
xorl %esi, %esi
callq 0x33e0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
jmp 0x143fb
cmpl %ecx, 0x18(%r14)
jl 0x14407
movq %rbp, %rdi
callq 0x32b0
movq %rax, %rbp
testb $0x1, %r13b
je 0x14330
jmp 0x14414
decl (%rsp)
testb $0x1, %r13b
je 0x14309
movq 0xbbd5(%rip), %rbx      # 0x1fff0
leaq 0x5379(%rip), %rsi      # 0x1979b
movl $0x51, %edx
movq %rbx, %rdi
callq 0x32a0
leaq 0x53b7(%rip), %rsi      # 0x197ed
movl $0x29, %edx
movq %rbx, %rdi
callq 0x32a0
leaq 0x53cd(%rip), %rsi      # 0x19817
movl $0x43, %edx
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x32a0
movq 0x8(%rbx), %rax
movq 0x90(%rax), %rcx
movq 0x18(%rcx), %r15
addq $0x8, %rcx
cmpq %rcx, %r15
je 0x14687
movl 0x8(%rsp), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
movsd %xmm0, (%rsp)
xorl %ebp, %ebp
movq 0x20(%r15), %r14
movsd (%r14), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x8(%r14), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x10(%r14), %xmm0
mulsd 0x10(%rsp), %xmm0
cvttsd2si %xmm0, %r13d
cmpb $0x1, 0x48(%rax)
jne 0x145f4
movl $0x1a, %edx
movq 0xbb1a(%rip), %r12      # 0x1fff0
movq %r12, %rdi
leaq 0x537b(%rip), %rsi      # 0x1985b
callq 0x32a0
movq %r12, %rdi
movsd 0x20(%rsp), %xmm0
callq 0x3360
movq %rax, %r12
movl $0x4, %edx
movq %rax, %rdi
leaq 0x3b8b(%rip), %rsi      # 0x18090
callq 0x32a0
movq %r12, %rdi
movsd 0x18(%rsp), %xmm0
callq 0x3360
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
movl $0x11, %edx
movq 0xbaa2(%rip), %r12      # 0x1fff0
movq %r12, %rdi
leaq 0x531e(%rip), %rsi      # 0x19876
callq 0x32a0
movl 0x18(%r14), %esi
movq %r12, %rdi
movq %r12, %r14
callq 0x33e0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
movl $0xa, %edx
movq %r14, %rdi
leaq 0x52e3(%rip), %rsi      # 0x19888
callq 0x32a0
movq %r14, %rdi
movl %r13d, %esi
callq 0x33e0
movq %rax, %r12
movl $0x6, %edx
movq %rax, %rdi
leaq 0x52cc(%rip), %rsi      # 0x19893
callq 0x32a0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
testl %r13d, %r13d
jle 0x1465f
movl %r13d, %r14d
movq (%rbx), %rax
movq (%rax), %rdi
callq 0x10d90
mulsd (%rsp), %xmm0
cvttsd2si %xmm0, %eax
movq 0xa8(%rbx), %rcx
movslq %eax, %rsi
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rsi, %rdx
jbe 0x1493f
movq (%rax,%rsi,8), %rax
cmpb $0x0, 0x10(%rax)
jne 0x1465a
movsd (%rax), %xmm0
ucomisd 0x20(%rsp), %xmm0
jb 0x1465a
movsd 0x18(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x1465a
movb $0x1, 0x10(%rax)
decl %r14d
testl %r14d, %r14d
jg 0x145fc
addl %r13d, %ebp
movq %r15, %rdi
callq 0x32b0
movq %rax, %r15
movq 0x8(%rbx), %rax
movq 0x90(%rax), %rcx
addq $0x8, %rcx
cmpq %rcx, %r15
jne 0x14494
jmp 0x14689
xorl %ebp, %ebp
movq 0xb960(%rip), %r15      # 0x1fff0
leaq 0x5203(%rip), %rsi      # 0x1989a
movl $0x19, %edx
movq %r15, %rdi
callq 0x32a0
movl 0x8(%rsp), %esi
movq %r15, %rdi
callq 0x31a0
movq %rax, %r14
leaq 0x39d6(%rip), %rsi      # 0x18090
movl $0x4, %edx
movq %rax, %rdi
callq 0x32a0
movq %r14, %rdi
movl %ebp, %esi
callq 0x33e0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
movl %ebp, %r14d
testl %ebp, %ebp
je 0x14882
movq 0xbef3(%rip), %rsi      # 0x20600
movq 0xbef4(%rip), %rdx      # 0x20608
movq 0xb8b5(%rip), %r15      # 0x1ffd0
movq %r15, %rdi
callq 0x32a0
movq 0xbf16(%rip), %rsi      # 0x20640
movq 0xbf17(%rip), %rdx      # 0x20648
movq %rax, %rdi
callq 0x32a0
movq 0x8(%rbx), %rcx
movl 0x30(%rcx), %esi
movq %rax, %rdi
callq 0x31a0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
movq 0xbea7(%rip), %rsi      # 0x20620
movq 0xbea8(%rip), %rdx      # 0x20628
movq %r15, %rdi
callq 0x32a0
movq 0xbeb1(%rip), %rsi      # 0x20640
movq 0xbeb2(%rip), %rdx      # 0x20648
movq %rax, %rdi
callq 0x32a0
movq %rax, %rdi
movl %r14d, %esi
callq 0x33e0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
movq 0xbde6(%rip), %rsi      # 0x205c0
movq 0xbde7(%rip), %rdx      # 0x205c8
movq %r15, %rdi
callq 0x32a0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r12, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
movq 0x8(%rbx), %rax
cmpb $0x0, 0x49(%rax)
je 0x14891
movq 0xa8(%rbx), %rax
movq (%rax), %r12
cmpq 0x8(%rax), %r12
je 0x148ca
xorl %ecx, %ecx
movq 0xb796(%rip), %r14      # 0x1ffd0
xorl %ebp, %ebp
movq (%r12), %rdx
cmpb $0x1, 0x10(%rdx)
jne 0x14874
testb $0x1, %cl
je 0x14861
movq 0xbdee(%rip), %rsi      # 0x20640
movq 0xbdef(%rip), %rdx      # 0x20648
movq %r14, %rdi
callq 0x32a0
movq %r14, %rdi
movl %ebp, %esi
callq 0x33e0
movq 0xa8(%rbx), %rax
movb $0x1, %cl
incl %ebp
addq $0x8, %r12
cmpq 0x8(%rax), %r12
jne 0x1483c
jmp 0x148ca
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %r14d, %r14d
jle 0x148ca
xorl %ebx, %ebx
movq 0xb731(%rip), %r12      # 0x1ffd0
testl %ebx, %ebx
je 0x148b9
movq 0xbd96(%rip), %rsi      # 0x20640
movq 0xbd97(%rip), %rdx      # 0x20648
movq %r12, %rdi
callq 0x32a0
movq %r12, %rdi
movl %ebx, %esi
callq 0x33e0
incl %ebx
cmpl %ebx, %r14d
jne 0x1489f
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r15, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
movq 0xbce8(%rip), %rsi      # 0x205e0
movq 0xbce9(%rip), %rdx      # 0x205e8
movq %rax, %rdi
callq 0x32a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x31b0
leaq 0x4bf2(%rip), %rdi      # 0x19538
xorl %eax, %eax
callq 0x3320
nop