// File: /workspace/github_cpp_makefile_star2_O3/bobverity[P]MavericK/MCMCobject_admixture.cpp
// Function: MCMCobject_admixture::drawFreqs()
void MCMCobject_admixture::drawFreqs() {
    
    // draw allele frequencies
    double randSum;
    for (int k=0; k<K; k++) {
        for (int l=0; l<loci; l++) {
            randSum = 0;
            for (int j=0; j<J[l]; j++) {
                alleleFreqs[k][l][j] = rgamma1(alleleCounts[k][l][j]+lambda, 1.0);
                randSum += alleleFreqs[k][l][j];
            }
            for (int j=0; j<J[l]; j++) {
                alleleFreqs[k][l][j] /= randSum;
            }
            
        }
    }
    
    // draw admixture proportions
    for (int i=0; i<n; i++) {
        randSum = 0;
        for (int k=0; k<K; k++) {
            admixFreqs[i][k] = rgamma1(admixCounts[i][k]+alpha, 1.0);
            randSum += admixFreqs[i][k];
        }
        for (int k=0; k<K; k++) {
            admixFreqs[i][k] /= randSum;
        }
    }
    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl 0x1c(%rdi), %eax
testl %eax, %eax
jle 0xac90
movl 0x24(%rbx), %ecx
xorl %esi, %esi
testl %ecx, %ecx
jle 0xac81
movq 0x28(%rbx), %rax
leaq (,%rsi,8), %rcx
leaq (%rcx,%rcx,2), %r15
movq %rsi, 0x10(%rsp)
leaq (%rsi,%rsi,2), %r12
xorl %r13d, %r13d
cmpl $0x0, (%rax,%r13,4)
jle 0xac69
xorps %xmm1, %xmm1
leaq (,%r13,8), %rax
leaq (%rax,%rax,2), %rbp
xorl %r14d, %r14d
movsd %xmm1, 0x8(%rsp)
movq 0x110(%rbx), %rax
movq (%rax,%r15), %rax
movq (%rax,%rbp), %rax
xorps %xmm0, %xmm0
cvtsi2sdl (%rax,%r14,4), %xmm0
addsd 0x78(%rbx), %xmm0
movsd 0x2b661(%rip), %xmm1    # 0x36260
callq 0x1d1b1
movsd 0x8(%rsp), %xmm1
movq 0x140(%rbx), %rax
movq (%rax,%r15), %rax
movq (%rax,%rbp), %rax
movsd %xmm0, (%rax,%r14,8)
addsd %xmm0, %xmm1
incq %r14
movq 0x28(%rbx), %rax
movslq (%rax,%r13,4), %rcx
cmpq %rcx, %r14
jl 0xabd4
testl %ecx, %ecx
jle 0xac69
movq 0x140(%rbx), %rdx
movq (%rdx,%r12,8), %rdx
leaq (,%r13,2), %rsi
addq %r13, %rsi
movq (%rdx,%rsi,8), %rdx
xorl %esi, %esi
movsd (%rdx,%rsi,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rdx,%rsi,8)
incq %rsi
cmpq %rsi, %rcx
jne 0xac53
incq %r13
movslq 0x24(%rbx), %rcx
cmpq %rcx, %r13
jl 0xabb7
movl 0x1c(%rbx), %eax
movq 0x10(%rsp), %rsi
incq %rsi
movslq %eax, %rdx
cmpq %rdx, %rsi
jl 0xab93
cmpl $0x0, 0x20(%rbx)
jle 0xad49
xorl %r14d, %r14d
testl %eax, %eax
jle 0xad39
xorpd %xmm1, %xmm1
leaq (,%r14,8), %rax
leaq (%rax,%rax,2), %r15
xorl %r12d, %r12d
movsd %xmm1, 0x8(%rsp)
movq 0x188(%rbx), %rax
movq (%rax,%r15), %rax
xorps %xmm0, %xmm0
cvtsi2sdl (%rax,%r12,4), %xmm0
addsd 0x88(%rbx), %xmm0
movsd 0x2b57e(%rip), %xmm1    # 0x36260
callq 0x1d1b1
movsd 0x8(%rsp), %xmm1
movq 0x1b8(%rbx), %rax
movq (%rax,%r15), %rax
movsd %xmm0, (%rax,%r12,8)
addsd %xmm0, %xmm1
incq %r12
movslq 0x1c(%rbx), %rax
cmpq %rax, %r12
jl 0xacb8
testl %eax, %eax
jle 0xad39
movq 0x1b8(%rbx), %rcx
leaq (%r14,%r14,2), %rdx
movq (%rcx,%rdx,8), %rcx
xorl %edx, %edx
movsd (%rcx,%rdx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0xad23
incq %r14
movslq 0x20(%rbx), %rcx
cmpq %rcx, %r14
jl 0xac9d
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq