// File: /workspace/github_cpp_makefile_star2_O1/bobverity[P]MavericK/MCMCobject_admixture.cpp
// Function: MCMCobject_admixture::produceQmatrix()
void MCMCobject_admixture::produceQmatrix() {
    
    // populate Qmatrix_gene_new
    groupIndex=-1;
    for (int ind=0; ind<n; ind++) {
        for (int l=0; l<loci; l++) {
            for (int p=0; p<ploidy_vec[ind]; p++) {
                groupIndex++;
                
                probVecSum = 0;
                for (int k=0; k<K; k++) {
                    if (data[ind][l][p]==0) {
                        probVec[k] = 1.0;
                    } else {
                        probVec[k] = double(alleleCounts[k][l][data[ind][l][p]-1]+lambda)/double(alleleCountsTotals[k][l]+J[l]*lambda);
                    }
                    probVec[k] *= double(admixCounts[ind][k]+alpha); // (denominator of this expression is the same for all k, so is omitted)
                    probVecSum += probVec[k];
                }
                for (int k=0; k<K; k++) {
                    Qmatrix_gene_new[groupIndex][k] = probVec[k]/probVecSum;
                    logQmatrix_gene_new[groupIndex][k] = log(Qmatrix_gene_new[groupIndex][k]);
                }
                
            } // p
        } // l
    } // ind
    
}

// Assembly:
movl $0xffffffff, 0x108(%rdi) # imm = 0xFFFFFFFF
cmpl $0x0, 0x20(%rdi)
jle 0xa82b
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq $0x0, (%rsp)
movsd 0x2cc04(%rip), %xmm4    # 0x37260
cmpl $0x0, 0x24(%rbx)
jle 0xa805
movq (%rsp), %rax
leaq (,%rax,8), %rax
leaq (%rax,%rax,2), %r15
xorl %r12d, %r12d
movq 0x40(%rbx), %rax
movq (%rsp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jle 0xa7f5
leaq (%r12,%r12,2), %r13
xorl %ebp, %ebp
incl 0x108(%rbx)
movq $0x0, 0x278(%rbx)
movslq 0x1c(%rbx), %rax
testq %rax, %rax
jle 0xa76e
movq (%rbx), %rdx
movq 0x28(%rbx), %rcx
movq (%rdx,%r15), %rdx
movq (%rdx,%r13,8), %rdx
movslq (%rdx,%rbp,4), %rdx
movq 0x110(%rbx), %rsi
movq 0x128(%rbx), %rdi
movq 0x260(%rbx), %r8
movq 0x188(%rbx), %r9
movq (%r9,%r15), %r9
xorl %r10d, %r10d
xorl %r11d, %r11d
movapd %xmm4, %xmm0
testl %edx, %edx
je 0xa72d
movq (%rsi,%r10,2), %r14
movq (%r14,%r13,8), %r14
xorps %xmm0, %xmm0
cvtsi2sdl -0x4(%r14,%rdx,4), %xmm0
movsd 0x78(%rbx), %xmm1
movq (%rdi,%r10,2), %r14
xorps %xmm2, %xmm2
cvtsi2sdl (%r14,%r12,4), %xmm2
xorps %xmm3, %xmm3
cvtsi2sdl (%rcx,%r12,4), %xmm3
addsd %xmm1, %xmm0
mulsd %xmm1, %xmm3
addsd %xmm2, %xmm3
divsd %xmm3, %xmm0
movsd %xmm0, (%r8,%r11,8)
xorps %xmm1, %xmm1
cvtsi2sdl (%r9,%r11,4), %xmm1
addsd 0x88(%rbx), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%r8,%r11,8)
addsd 0x278(%rbx), %xmm1
movsd %xmm1, 0x278(%rbx)
incq %r11
addq $0xc, %r10
cmpq %r11, %rax
jne 0xa6e8
cmpl $0x0, 0x1c(%rbx)
jle 0xa7d5
xorl %r14d, %r14d
movq 0x260(%rbx), %rax
movq 0x2b0(%rbx), %rcx
movsd (%rax,%r14,8), %xmm0
divsd 0x278(%rbx), %xmm0
movslq 0x108(%rbx), %rax
leaq (%rax,%rax,2), %rax
movq (%rcx,%rax,8), %rax
movsd %xmm0, (%rax,%r14,8)
callq 0x3290
movslq 0x108(%rbx), %rax
movq 0x298(%rbx), %rcx
leaq (%rax,%rax,2), %rax
movq (%rcx,%rax,8), %rax
movsd %xmm0, (%rax,%r14,8)
incq %r14
movslq 0x1c(%rbx), %rax
cmpq %rax, %r14
jl 0xa777
incq %rbp
movq 0x40(%rbx), %rax
movq (%rsp), %rcx
movslq (%rax,%rcx,4), %rax
cmpq %rax, %rbp
movsd 0x2ca71(%rip), %xmm4    # 0x37260
jl 0xa691
incq %r12
movslq 0x24(%rbx), %rax
cmpq %rax, %r12
jl 0xa679
movq (%rsp), %rdx
incq %rdx
movslq 0x20(%rbx), %rax
movq %rdx, (%rsp)
cmpq %rax, %rdx
jl 0xa65c
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq