// File: 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:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x40(%rsp)
movl $0xffffffff, 0x108(%rax) # imm = 0xFFFFFFFF
movl $0x0, 0x5c(%rsp)
movq 0x40(%rsp), %rcx
movl 0x5c(%rsp), %eax
cmpl 0x20(%rcx), %eax
jge 0x14d0c
movl $0x0, 0x58(%rsp)
movq 0x40(%rsp), %rcx
movl 0x58(%rsp), %eax
cmpl 0x24(%rcx), %eax
jge 0x14cfa
movl $0x0, 0x54(%rsp)
movq 0x40(%rsp), %rdi
movl 0x54(%rsp), %eax
movl %eax, 0x3c(%rsp)
addq $0x40, %rdi
movslq 0x5c(%rsp), %rsi
callq 0x8ba0
movq %rax, %rcx
movl 0x3c(%rsp), %eax
cmpl (%rcx), %eax
jge 0x14ce8
movq 0x40(%rsp), %rax
movl 0x108(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x108(%rax)
xorps %xmm0, %xmm0
movsd %xmm0, 0x278(%rax)
movl $0x0, 0x50(%rsp)
movq 0x40(%rsp), %rcx
movl 0x50(%rsp), %eax
cmpl 0x1c(%rcx), %eax
jge 0x14be5
movq 0x40(%rsp), %rdi
movslq 0x5c(%rsp), %rsi
callq 0x8c40
movq %rax, %rdi
movslq 0x58(%rsp), %rsi
callq 0x8c60
movq %rax, %rdi
movslq 0x54(%rsp), %rsi
callq 0x8ba0
cmpl $0x0, (%rax)
jne 0x14a51
movq 0x40(%rsp), %rdi
addq $0x260, %rdi            # imm = 0x260
movslq 0x50(%rsp), %rsi
callq 0x8c20
movsd 0x477b8(%rip), %xmm0    # 0x5c200
movsd %xmm0, (%rax)
jmp 0x14b4a
movq 0x40(%rsp), %rdi
addq $0x110, %rdi            # imm = 0x110
movslq 0x50(%rsp), %rsi
callq 0x8c40
movq %rax, %rdi
movslq 0x58(%rsp), %rsi
callq 0x8c60
movq 0x40(%rsp), %rdi
movq %rax, 0x18(%rsp)
movslq 0x5c(%rsp), %rsi
callq 0x8c40
movq %rax, %rdi
movslq 0x58(%rsp), %rsi
callq 0x8c60
movq %rax, %rdi
movslq 0x54(%rsp), %rsi
callq 0x8ba0
movq 0x18(%rsp), %rdi
movl (%rax), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x8ba0
movq 0x40(%rsp), %rdi
cvtsi2sdl (%rax), %xmm0
addsd 0x78(%rdi), %xmm0
movsd %xmm0, 0x28(%rsp)
addq $0x128, %rdi            # imm = 0x128
movslq 0x50(%rsp), %rsi
callq 0x8c60
movq %rax, %rdi
movslq 0x58(%rsp), %rsi
callq 0x8ba0
movq 0x40(%rsp), %rdi
cvtsi2sdl (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
addq $0x28, %rdi
movslq 0x58(%rsp), %rsi
callq 0x8ba0
movsd 0x20(%rsp), %xmm2
movsd 0x28(%rsp), %xmm0
movq 0x40(%rsp), %rdi
cvtsi2sdl (%rax), %xmm1
movsd 0x78(%rdi), %xmm3
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
addq $0x260, %rdi            # imm = 0x260
movslq 0x50(%rsp), %rsi
callq 0x8c20
movsd 0x30(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x40(%rsp), %rdi
addq $0x188, %rdi            # imm = 0x188
movslq 0x5c(%rsp), %rsi
callq 0x8c60
movq %rax, %rdi
movslq 0x50(%rsp), %rsi
callq 0x8ba0
movq 0x40(%rsp), %rdi
cvtsi2sdl (%rax), %xmm0
addsd 0x88(%rdi), %xmm0
movsd %xmm0, 0x10(%rsp)
addq $0x260, %rdi            # imm = 0x260
movslq 0x50(%rsp), %rsi
callq 0x8c20
movsd 0x10(%rsp), %xmm0
movq 0x40(%rsp), %rdi
mulsd (%rax), %xmm0
movsd %xmm0, (%rax)
addq $0x260, %rdi            # imm = 0x260
movslq 0x50(%rsp), %rsi
callq 0x8c20
movq %rax, %rcx
movq 0x40(%rsp), %rax
movsd (%rcx), %xmm0
addsd 0x278(%rax), %xmm0
movsd %xmm0, 0x278(%rax)
movl 0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50(%rsp)
jmp 0x149ea
movl $0x0, 0x4c(%rsp)
movq 0x40(%rsp), %rcx
movl 0x4c(%rsp), %eax
cmpl 0x1c(%rcx), %eax
jge 0x14cd6
movq 0x40(%rsp), %rdi
addq $0x260, %rdi            # imm = 0x260
movslq 0x4c(%rsp), %rsi
callq 0x8c20
movq %rax, %rcx
movq 0x40(%rsp), %rax
movsd (%rcx), %xmm0
divsd 0x278(%rax), %xmm0
movsd %xmm0, (%rsp)
movq %rax, %rdi
addq $0x2b0, %rdi            # imm = 0x2B0
movslq 0x108(%rax), %rsi
callq 0x8bc0
movq %rax, %rdi
movslq 0x4c(%rsp), %rsi
callq 0x8c20
movsd (%rsp), %xmm0
movq %rax, %rcx
movq 0x40(%rsp), %rax
movsd %xmm0, (%rcx)
movq %rax, %rdi
addq $0x2b0, %rdi            # imm = 0x2B0
movslq 0x108(%rax), %rsi
callq 0x8bc0
movq %rax, %rdi
movslq 0x4c(%rsp), %rsi
callq 0x8c20
movsd (%rax), %xmm0
callq 0x4390
movq 0x40(%rsp), %rax
movsd %xmm0, 0x8(%rsp)
movq %rax, %rdi
addq $0x298, %rdi            # imm = 0x298
movslq 0x108(%rax), %rsi
callq 0x8bc0
movq %rax, %rdi
movslq 0x4c(%rsp), %rsi
callq 0x8c20
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x14bed
jmp 0x14cd8
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x14999
jmp 0x14cea
movl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x58(%rsp)
jmp 0x1497f
jmp 0x14cfc
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x14965
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)