// File: /workspace/github_cpp_makefile_star2_O1/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
cmpl $0x0, 0x1c(%rdi)
jle 0xafb0
movq $0x0, 0x8(%rsp)
cmpl $0x0, 0x24(%rbx)
jle 0xaf96
movq 0x8(%rsp), %rcx
leaq (,%rcx,8), %rax
leaq (%rax,%rax,2), %r15
leaq (%rcx,%rcx,2), %r12
xorl %r13d, %r13d
movq 0x28(%rbx), %rax
movl (%rax,%r13,4), %eax
xorpd %xmm1, %xmm1
testl %eax, %eax
jle 0xaf4e
leaq (,%r13,8), %rax
leaq (%rax,%rax,2), %rbp
xorl %r14d, %r14d
movsd %xmm1, 0x10(%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 0x2c346(%rip), %xmm1    # 0x37260
callq 0x1d505
movsd 0x10(%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), %rax
cmpq %rax, %r14
jl 0xaeef
testl %eax, %eax
jle 0xaf86
movq 0x140(%rbx), %rcx
movq (%rcx,%r12,8), %rcx
leaq (,%r13,2), %rdx
addq %r13, %rdx
movq (%rcx,%rdx,8), %rcx
movl %eax, %eax
xorl %edx, %edx
movsd (%rcx,%rdx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0xaf70
incq %r13
movslq 0x24(%rbx), %rax
cmpq %rax, %r13
jl 0xaed0
movq 0x8(%rsp), %rdx
incq %rdx
movslq 0x1c(%rbx), %rax
movq %rdx, 0x8(%rsp)
cmpq %rax, %rdx
jl 0xaeae
cmpl $0x0, 0x20(%rbx)
jle 0xb06a
xorl %r14d, %r14d
movl 0x1c(%rbx), %eax
xorpd %xmm1, %xmm1
testl %eax, %eax
jle 0xb02d
leaq (,%r14,8), %rax
leaq (%rax,%rax,2), %r15
xorl %r12d, %r12d
movsd %xmm1, 0x10(%rsp)
movq 0x188(%rbx), %rax
movq (%rax,%r15), %rax
xorps %xmm0, %xmm0
cvtsi2sdl (%rax,%r12,4), %xmm0
addsd 0x88(%rbx), %xmm0
movsd 0x2c25f(%rip), %xmm1    # 0x37260
callq 0x1d505
movsd 0x10(%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 0xafd7
testl %eax, %eax
jle 0xb05a
movq 0x1b8(%rbx), %rcx
leaq (%r14,%r14,2), %rdx
movq (%rcx,%rdx,8), %rcx
movl %eax, %eax
xorl %edx, %edx
movsd (%rcx,%rdx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0xb044
incq %r14
movslq 0x20(%rbx), %rax
cmpq %rax, %r14
jl 0xafbd
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop