// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
orl $-0x1, 0x108(%rdi)
pushq $-0x1
popq %rax
xorl %edx, %edx
movsd 0x1e649(%rip), %xmm4    # 0x27210
movslq 0x20(%rbx), %rcx
cmpq %rcx, %rdx
jge 0x8d89
imulq $0x18, %rdx, %rcx
movq %rcx, 0x10(%rsp)
xorl %r12d, %r12d
movq %rdx, 0x18(%rsp)
movslq 0x24(%rbx), %rcx
cmpq %rcx, %r12
jge 0x8d81
xorl %esi, %esi
movq 0x40(%rbx), %rcx
movslq (%rcx,%rdx,4), %rcx
cmpq %rcx, %rsi
jge 0x8d79
movq %rsi, 0x8(%rsp)
incl %eax
movl %eax, 0x108(%rbx)
andq $0x0, 0x278(%rbx)
movl 0x1c(%rbx), %ecx
movq (%rbx), %rdx
movq 0x10(%rsp), %rsi
addq %rsi, %rdx
movq 0x110(%rbx), %rdi
movq %rdi, 0x20(%rsp)
movq 0x128(%rbx), %rdi
movq 0x28(%rbx), %r8
movq 0x260(%rbx), %r9
movq 0x188(%rbx), %r10
addq %rsi, %r10
testl %ecx, %ecx
movl $0x0, %r11d
cmovgl %ecx, %r11d
xorl %ebp, %ebp
xorl %r14d, %r14d
cmpq %r14, %r11
je 0x8cff
movq (%rdx), %r13
imulq $0x18, %r12, %r15
movq (%r13,%r15), %r13
movq 0x8(%rsp), %rsi
movslq (%r13,%rsi,4), %r13
movapd %xmm4, %xmm0
testq %r13, %r13
je 0x8cc2
movq 0x20(%rsp), %rsi
movq (%rsi,%rbp), %rsi
movq (%rsi,%r15), %rsi
cvtsi2sdl -0x4(%rsi,%r13,4), %xmm0
movsd 0x78(%rbx), %xmm1
movq (%rdi,%rbp), %rsi
cvtsi2sdl (%rsi,%r12,4), %xmm2
cvtsi2sdl (%r8,%r12,4), %xmm3
addsd %xmm1, %xmm0
mulsd %xmm1, %xmm3
addsd %xmm2, %xmm3
divsd %xmm3, %xmm0
movsd %xmm0, (%r9,%r14,8)
movq (%r10), %rsi
cvtsi2sdl (%rsi,%r14,4), %xmm1
addsd 0x88(%rbx), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%r9,%r14,8)
addsd 0x278(%rbx), %xmm1
movsd %xmm1, 0x278(%rbx)
incq %r14
addq $0x18, %rbp
jmp 0x8c61
xorl %r14d, %r14d
movslq %ecx, %rcx
cmpq %rcx, %r14
jge 0x8d5f
movq 0x260(%rbx), %rcx
movq 0x2b0(%rbx), %rdx
movsd (%rcx,%r14,8), %xmm0
divsd 0x278(%rbx), %xmm0
cltq
imulq $0x18, %rax, %rax
movq (%rdx,%rax), %rax
movsd %xmm0, (%rax,%r14,8)
callq 0x32d0
movslq 0x108(%rbx), %rax
movq 0x298(%rbx), %rcx
imulq $0x18, %rax, %rdx
movq (%rcx,%rdx), %rcx
movsd %xmm0, (%rcx,%r14,8)
incq %r14
movl 0x1c(%rbx), %ecx
jmp 0x8d02
movq 0x8(%rsp), %rsi
incq %rsi
movq 0x18(%rsp), %rdx
movsd 0x1e49c(%rip), %xmm4    # 0x27210
jmp 0x8bf4
incq %r12
jmp 0x8be5
incq %rdx
jmp 0x8bc7
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq