// File: /workspace/github_cpp_makefile_star2_O3/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
movl 0x20(%rdi), %ecx
testl %ecx, %ecx
jle 0xa4f9
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movl 0x24(%rdi), %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq $0x0, 0x8(%rsp)
movsd 0x2bf57(%rip), %xmm4    # 0x36260
testl %edx, %edx
jle 0xa4d2
movq 0x40(%rbx), %rsi
movq 0x8(%rsp), %rcx
leaq (,%rcx,8), %rcx
leaq (%rcx,%rcx,2), %rcx
movq %rcx, 0x18(%rsp)
xorl %r12d, %r12d
movq 0x8(%rsp), %rcx
cmpl $0x0, (%rsi,%rcx,4)
jle 0xa4c0
movl 0x1c(%rbx), %edx
leaq (%r12,%r12,2), %r13
xorl %edi, %edi
incl %eax
movl %eax, 0x108(%rbx)
movq $0x0, 0x278(%rbx)
testl %edx, %edx
jle 0xa4a8
movq %rsi, 0x20(%rsp)
movq (%rbx), %rcx
movq 0x28(%rbx), %rsi
movq 0x18(%rsp), %r11
movq (%rcx,%r11), %rcx
movq (%rcx,%r13,8), %rcx
movq %rdi, 0x10(%rsp)
movslq (%rcx,%rdi,4), %rdi
movq 0x110(%rbx), %r8
movq 0x128(%rbx), %r9
movq 0x260(%rbx), %r10
movq 0x188(%rbx), %rcx
movq (%rcx,%r11), %r11
movl %edx, %r14d
xorl %r15d, %r15d
xorl %ecx, %ecx
movapd %xmm4, %xmm0
testl %edi, %edi
je 0xa3f1
movq (%r8,%r15,2), %rbp
movq (%rbp,%r13,8), %rbp
xorps %xmm0, %xmm0
cvtsi2sdl -0x4(%rbp,%rdi,4), %xmm0
movsd 0x78(%rbx), %xmm1
movq (%r9,%r15,2), %rbp
xorps %xmm2, %xmm2
cvtsi2sdl (%rbp,%r12,4), %xmm2
xorps %xmm3, %xmm3
cvtsi2sdl (%rsi,%r12,4), %xmm3
addsd %xmm1, %xmm0
mulsd %xmm1, %xmm3
addsd %xmm2, %xmm3
divsd %xmm3, %xmm0
movsd %xmm0, (%r10,%rcx,8)
xorps %xmm1, %xmm1
cvtsi2sdl (%r11,%rcx,4), %xmm1
addsd 0x88(%rbx), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%r10,%rcx,8)
addsd 0x278(%rbx), %xmm1
movsd %xmm1, 0x278(%rbx)
incq %rcx
addq $0xc, %r15
cmpq %rcx, %r14
jne 0xa3ab
testl %edx, %edx
movq 0x20(%rsp), %rsi
jle 0xa4a3
xorl %r14d, %r14d
movq 0x260(%rbx), %rcx
movq 0x2b0(%rbx), %rdx
movsd (%rcx,%r14,8), %xmm0
divsd 0x278(%rbx), %xmm0
cltq
leaq (%rax,%rax,2), %rax
movq (%rdx,%rax,8), %rax
movsd %xmm0, (%rax,%r14,8)
callq 0x3290
movslq 0x108(%rbx), %rax
movq 0x298(%rbx), %rcx
leaq (%rax,%rax,2), %rdx
movq (%rcx,%rdx,8), %rcx
movsd %xmm0, (%rcx,%r14,8)
incq %r14
movslq 0x1c(%rbx), %rdx
cmpq %rdx, %r14
jl 0xa43e
movq 0x40(%rbx), %rsi
movsd 0x2bdbd(%rip), %xmm4    # 0x36260
movq 0x10(%rsp), %rdi
incq %rdi
movq 0x8(%rsp), %rcx
movslq (%rsi,%rcx,4), %rcx
cmpq %rcx, %rdi
jl 0xa346
movl 0x24(%rbx), %edx
incq %r12
movslq %edx, %rcx
cmpq %rcx, %r12
jl 0xa32e
movl 0x20(%rbx), %ecx
movq 0x8(%rsp), %r8
incq %r8
movslq %ecx, %rsi
movq %r8, 0x8(%rsp)
cmpq %rsi, %r8
jl 0xa309
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq