// File: /workspace/github_cpp_makefile_star2_O1/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 $0x38, %rsp
movq %rdi, %rbx
movq 0xa8(%rdi), %rax
movq 0x8(%rax), %r13
subq (%rax), %r13
movq 0x8(%rdi), %rax
shrq $0x3, %r13
cmpb $0x1, 0x48(%rax)
jne 0x1438d
movq 0xbcac(%rip), %r15      # 0x1fff0
leaq 0x5396(%rip), %rsi      # 0x196e1
movl $0xd, %edx
movq %r15, %rdi
callq 0x32a0
movl %r13d, %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 %r13d, %r13d
je 0x14947
movq 0x8(%rbx), %rax
cmpb $0x1, 0x49(%rax)
jne 0x1452b
xorl %r12d, %r12d
xorpd %xmm2, %xmm2
movq %r13, 0x10(%rsp)
movb $0x1, %r15b
testb $0x1, %r12b
jne 0x144ca
movq 0x8(%rbx), %rax
movq 0x90(%rax), %rax
movq 0x18(%rax), %rbp
movb $0x1, %r15b
movq 0x8(%rbx), %rax
movq 0x90(%rax), %rcx
addq $0x8, %rcx
cmpq %rcx, %rbp
je 0x144ca
movq 0x20(%rbp), %r14
movsd 0x10(%r14), %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %r13d, %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %ecx
ucomisd %xmm2, %xmm0
jbe 0x1449d
testl %ecx, %ecx
jne 0x1449d
movb $0x1, %r12b
cmpb $0x1, 0x48(%rax)
jne 0x144ba
movl $0x3f, %edx
movq 0xbbc4(%rip), %r12      # 0x1fff0
movq %r12, %rdi
leaq 0x52b9(%rip), %rsi      # 0x196ef
callq 0x32a0
movsd 0x10(%r14), %xmm0
movq %r12, %rdi
movb $0x1, %r12b
callq 0x3360
movq %rax, %r14
movl $0xb, %edx
movq %rax, %rdi
leaq 0x52d1(%rip), %rsi      # 0x1972f
callq 0x32a0
movq %r14, %rdi
xorl %esi, %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
xorpd %xmm2, %xmm2
jmp 0x144ba
cmpl %ecx, 0x18(%r14)
jge 0x144ab
decl %r13d
xorl %r15d, %r15d
jmp 0x144ba
movq %rbp, %rdi
callq 0x32b0
xorpd %xmm2, %xmm2
movq %rax, %rbp
testb $0x1, %r15b
je 0x144ca
testb $0x1, %r12b
je 0x143cf
testb $0x1, %r15b
jne 0x144da
testb $0x1, %r12b
je 0x143b0
testb $0x1, %r12b
je 0x14533
movq 0xbb09(%rip), %r14      # 0x1fff0
leaq 0x524d(%rip), %rsi      # 0x1973b
movl $0x51, %edx
movq %r14, %rdi
callq 0x32a0
leaq 0x528b(%rip), %rsi      # 0x1978d
movl $0x29, %edx
movq %r14, %rdi
callq 0x32a0
leaq 0x52a1(%rip), %rsi      # 0x197b7
movl $0x43, %edx
movq %r14, %rdi
callq 0x32a0
xorl %r13d, %r13d
jmp 0x147e2
xorl %r12d, %r12d
jmp 0x147e2
movq 0x8(%rbx), %rax
movq 0x90(%rax), %rcx
movq 0x18(%rcx), %r15
addq $0x8, %rcx
cmpq %rcx, %r15
je 0x1476b
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
movsd %xmm0, 0x28(%rsp)
movl 0x10(%rsp), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
movsd %xmm0, 0x30(%rsp)
xorl %ebp, %ebp
movl %ebp, 0xc(%rsp)
movq 0x20(%r15), %r13
movsd (%r13), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x8(%r13), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x10(%r13), %xmm0
mulsd 0x28(%rsp), %xmm0
cvttsd2si %xmm0, %ebp
cmpb $0x1, 0x48(%rax)
jne 0x146d3
movl $0x1a, %edx
movq 0xba39(%rip), %r14      # 0x1fff0
movq %r14, %rdi
leaq 0x523a(%rip), %rsi      # 0x197fb
callq 0x32a0
movq %r14, %rdi
movsd 0x20(%rsp), %xmm0
callq 0x3360
movq %rax, %r14
movl $0x4, %edx
movq %rax, %rdi
leaq 0x3aaa(%rip), %rsi      # 0x18090
callq 0x32a0
movq %r14, %rdi
movsd 0x18(%rsp), %xmm0
callq 0x3360
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 $0x11, %edx
movq 0xb9c1(%rip), %r14      # 0x1fff0
movq %r14, %rdi
leaq 0x51dd(%rip), %rsi      # 0x19816
callq 0x32a0
movl 0x18(%r13), %esi
movq %r14, %rdi
movq %r14, %r13
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 $0xa, %edx
movq %r13, %rdi
leaq 0x51a2(%rip), %rsi      # 0x19828
callq 0x32a0
movq %r13, %rdi
movl %ebp, %esi
callq 0x33e0
movq %rax, %r14
movl $0x6, %edx
movq %rax, %rdi
leaq 0x518c(%rip), %rsi      # 0x19833
callq 0x32a0
movq (%r14), %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
testl %ebp, %ebp
jle 0x1473e
movl %ebp, %r14d
movq (%rbx), %rax
movq (%rax), %rdi
callq 0x10e1e
mulsd 0x30(%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 0x14a29
movq (%rax,%rsi,8), %rax
cmpb $0x0, 0x10(%rax)
jne 0x14739
movsd (%rax), %xmm0
ucomisd 0x20(%rsp), %xmm0
jb 0x14739
movsd 0x18(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x14739
movb $0x1, 0x10(%rax)
decl %r14d
testl %r14d, %r14d
jg 0x146da
movl 0xc(%rsp), %eax
addl %ebp, %eax
movl %eax, %ebp
movq %r15, %rdi
callq 0x32b0
movq %rax, %r15
movq 0x8(%rbx), %rax
movq 0x90(%rax), %rcx
addq $0x8, %rcx
cmpq %rcx, %r15
jne 0x14571
jmp 0x1476d
xorl %ebp, %ebp
movq 0xb87c(%rip), %r14      # 0x1fff0
leaq 0x50bf(%rip), %rsi      # 0x1983a
movl $0x19, %edx
movq %r14, %rdi
callq 0x32a0
movl 0x10(%rsp), %esi
movq %r14, %rdi
callq 0x31a0
movq %rax, %r14
leaq 0x38f2(%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, %r13d
testl %r13d, %r13d
je 0x14947
movq 0xbe0e(%rip), %rsi      # 0x20600
movq 0xbe0f(%rip), %rdx      # 0x20608
movq 0xb7d0(%rip), %r15      # 0x1ffd0
movq %r15, %rdi
callq 0x32a0
movq 0xbe31(%rip), %rsi      # 0x20640
movq 0xbe32(%rip), %rdx      # 0x20648
movq %rax, %rdi
callq 0x32a0
movq 0x8(%rbx), %rcx
movl 0x30(%rcx), %esi
movq %rax, %rdi
callq 0x31a0
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
movq 0xbdc2(%rip), %rsi      # 0x20620
movq 0xbdc3(%rip), %rdx      # 0x20628
movq %r15, %rdi
callq 0x32a0
movq 0xbdcc(%rip), %rsi      # 0x20640
movq 0xbdcd(%rip), %rdx      # 0x20648
movq %rax, %rdi
callq 0x32a0
movq %rax, %rdi
movl %r13d, %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
movq 0xbd01(%rip), %rsi      # 0x205c0
movq 0xbd02(%rip), %rdx      # 0x205c8
movq %r15, %rdi
callq 0x32a0
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
movq 0x8(%rbx), %rax
movb 0x49(%rax), %al
notb %al
orb %r12b, %al
testb $0x1, %al
je 0x14956
testl %r13d, %r13d
jle 0x149b4
xorl %ebx, %ebx
movq 0xb6b6(%rip), %r12      # 0x1ffd0
testl %ebx, %ebx
je 0x14934
movq 0xbd1b(%rip), %rsi      # 0x20640
movq 0xbd1c(%rip), %rdx      # 0x20648
movq %r12, %rdi
callq 0x32a0
movq %r12, %rdi
movl %ebx, %esi
callq 0x33e0
incl %ebx
cmpl %ebx, %r13d
jne 0x1491a
jmp 0x149b4
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xa8(%rbx), %rax
movq (%rax), %r12
cmpq 0x8(%rax), %r12
je 0x149b4
xorl %eax, %eax
movq 0xb661(%rip), %r14      # 0x1ffd0
xorl %ebp, %ebp
movq (%r12), %rcx
cmpb $0x1, 0x10(%rcx)
jne 0x149a1
testb $0x1, %al
je 0x14995
movq 0xbcba(%rip), %rsi      # 0x20640
movq 0xbcbb(%rip), %rdx      # 0x20648
movq %r14, %rdi
callq 0x32a0
movq %r14, %rdi
movl %ebp, %esi
callq 0x33e0
movb $0x1, %al
incl %ebp
addq $0x8, %r12
movq 0xa8(%rbx), %rcx
cmpq 0x8(%rcx), %r12
jne 0x14971
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 0xbbfe(%rip), %rsi      # 0x205e0
movq 0xbbff(%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 $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x31b0
leaq 0x4aa8(%rip), %rdi      # 0x194d8
xorl %eax, %eax
callq 0x3320
nop