// File: 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:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x30(%rsp)
movl $0x0, 0x54(%rsp)
movq 0x30(%rsp), %rcx
movl 0x54(%rsp), %eax
cmpl 0x1c(%rcx), %eax
jge 0x15c90
movl $0x0, 0x50(%rsp)
movq 0x30(%rsp), %rcx
movl 0x50(%rsp), %eax
cmpl 0x24(%rcx), %eax
jge 0x15c7e
xorps %xmm0, %xmm0
movsd %xmm0, 0x58(%rsp)
movl $0x0, 0x4c(%rsp)
movq 0x30(%rsp), %rdi
movl 0x4c(%rsp), %eax
movl %eax, 0x2c(%rsp)
addq $0x28, %rdi
movslq 0x50(%rsp), %rsi
callq 0x8ba0
movq %rax, %rcx
movl 0x2c(%rsp), %eax
cmpl (%rcx), %eax
jge 0x15be0
movq 0x30(%rsp), %rdi
addq $0x110, %rdi            # imm = 0x110
movslq 0x54(%rsp), %rsi
callq 0x8c40
movq %rax, %rdi
movslq 0x50(%rsp), %rsi
callq 0x8c60
movq %rax, %rdi
movslq 0x4c(%rsp), %rsi
callq 0x8ba0
movq %rax, %rcx
movq 0x30(%rsp), %rax
cvtsi2sdl (%rcx), %xmm0
addsd 0x78(%rax), %xmm0
movsd 0x466b5(%rip), %xmm1    # 0x5c200
callq 0x39190
movq 0x30(%rsp), %rdi
movsd %xmm0, 0x20(%rsp)
addq $0x140, %rdi            # imm = 0x140
movslq 0x54(%rsp), %rsi
callq 0x8ae0
movq %rax, %rdi
movslq 0x50(%rsp), %rsi
callq 0x8bc0
movq %rax, %rdi
movslq 0x4c(%rsp), %rsi
callq 0x8c20
movsd 0x20(%rsp), %xmm0
movq 0x30(%rsp), %rdi
movsd %xmm0, (%rax)
addq $0x140, %rdi            # imm = 0x140
movslq 0x54(%rsp), %rsi
callq 0x8ae0
movq %rax, %rdi
movslq 0x50(%rsp), %rsi
callq 0x8bc0
movq %rax, %rdi
movslq 0x4c(%rsp), %rsi
callq 0x8c20
movsd (%rax), %xmm0
addsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x15ad8
movl $0x0, 0x48(%rsp)
movq 0x30(%rsp), %rdi
movl 0x48(%rsp), %eax
movl %eax, 0x1c(%rsp)
addq $0x28, %rdi
movslq 0x50(%rsp), %rsi
callq 0x8ba0
movq %rax, %rcx
movl 0x1c(%rsp), %eax
cmpl (%rcx), %eax
jge 0x15c6c
movq 0x30(%rsp), %rdi
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
addq $0x140, %rdi            # imm = 0x140
movslq 0x54(%rsp), %rsi
callq 0x8ae0
movq %rax, %rdi
movslq 0x50(%rsp), %rsi
callq 0x8bc0
movq %rax, %rdi
movslq 0x48(%rsp), %rsi
callq 0x8c20
movsd 0x10(%rsp), %xmm1
movsd (%rax), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0x15be8
jmp 0x15c6e
movl 0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50(%rsp)
jmp 0x15ab5
jmp 0x15c80
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x15a9b
movl $0x0, 0x44(%rsp)
movq 0x30(%rsp), %rcx
movl 0x44(%rsp), %eax
cmpl 0x20(%rcx), %eax
jge 0x15dfb
xorps %xmm0, %xmm0
movsd %xmm0, 0x58(%rsp)
movl $0x0, 0x40(%rsp)
movq 0x30(%rsp), %rcx
movl 0x40(%rsp), %eax
cmpl 0x1c(%rcx), %eax
jge 0x15d87
movq 0x30(%rsp), %rdi
addq $0x188, %rdi            # imm = 0x188
movslq 0x44(%rsp), %rsi
callq 0x8c60
movq %rax, %rdi
movslq 0x40(%rsp), %rsi
callq 0x8ba0
movq %rax, %rcx
movq 0x30(%rsp), %rax
cvtsi2sdl (%rcx), %xmm0
addsd 0x88(%rax), %xmm0
movsd 0x464f4(%rip), %xmm1    # 0x5c200
callq 0x39190
movq 0x30(%rsp), %rdi
movsd %xmm0, 0x8(%rsp)
addq $0x1b8, %rdi            # imm = 0x1B8
movslq 0x44(%rsp), %rsi
callq 0x8bc0
movq %rax, %rdi
movslq 0x40(%rsp), %rsi
callq 0x8c20
movsd 0x8(%rsp), %xmm0
movq 0x30(%rsp), %rdi
movsd %xmm0, (%rax)
addq $0x1b8, %rdi            # imm = 0x1B8
movslq 0x44(%rsp), %rsi
callq 0x8bc0
movq %rax, %rdi
movslq 0x40(%rsp), %rsi
callq 0x8c20
movsd (%rax), %xmm0
addsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movl 0x40(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x40(%rsp)
jmp 0x15cbb
movl $0x0, 0x3c(%rsp)
movq 0x30(%rsp), %rcx
movl 0x3c(%rsp), %eax
cmpl 0x1c(%rcx), %eax
jge 0x15de9
movq 0x30(%rsp), %rdi
movsd 0x58(%rsp), %xmm0
movsd %xmm0, (%rsp)
addq $0x1b8, %rdi            # imm = 0x1B8
movslq 0x44(%rsp), %rsi
callq 0x8bc0
movq %rax, %rdi
movslq 0x3c(%rsp), %rsi
callq 0x8c20
movsd (%rsp), %xmm1
movsd (%rax), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x15d8f
jmp 0x15deb
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0x15c98
addq $0x68, %rsp
retq