// File: /workspace/github_cpp_makefile_star2_O3/bobverity[P]MavericK/MCMCobject_noAdmixture.cpp
// Function: MCMCobject_noAdmixture::group_update()
void MCMCobject_noAdmixture::group_update() {
    
    // update group allocation for all individuals
    for (int ind=0; ind<n; ind++) {
        
        // subtract individual ind from allele counts
        for (int l=0; l<loci; l++) {
            for (int p=0; p<ploidy_vec[ind]; p++) {
                if (data[ind][l][p]!=0) {   // if not missing data
                    alleleCounts[group[ind]-1][l][data[ind][l][p]-1]--;
                    alleleCountsTotals[group[ind]-1][l]--;
                }
            }
        }
        
        // calculate probability of individual ind from all demes
        if (beta==0) {    // special case if beta==0 (draw from prior)
            logProbVec = vector<double>(K,-log(double(K)));
            probVec = vector<double>(K,1/double(K));
            probVecSum = 1.0;
        } else {
            for (int k=0; k<K; k++) {
                d_logLikeConditional(ind, k);   // update logProbVec[k]
            }
            logProbVecMax = *max_element(begin(logProbVec),end(logProbVec));
            probVecSum = 0;
            for (int k=0; k<K; k++) {
                probVec[k] = exp(beta*logProbVec[k]-beta*logProbVecMax);
                probVecSum += probVec[k];
            }
        }
        
        // resample grouping
        group[ind] = sample1(probVec, probVecSum);
        
        // add individual ind to allele counts
        for (int l=0; l<loci; l++) {
            for (int p=0; p<ploidy_vec[ind]; p++) {
                if (data[ind][l][p]!=0) {   // if not missing data
                    alleleCounts[group[ind]-1][l][data[ind][l][p]-1]++;
                    alleleCountsTotals[group[ind]-1][l]++;
                }
            }
        }
        
    }
    
}

// Assembly:
cmpl $0x0, 0x20(%rdi)
jle 0xde8d
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
leaq 0x198(%rdi), %r14
movl 0x24(%rdi), %eax
xorl %r15d, %r15d
leaq (%r15,%r15,2), %r13
testl %eax, %eax
jle 0xdbb9
movq 0x40(%rbx), %rcx
leaq (,%r13,8), %rdx
addq (%rbx), %rdx
movl (%rcx,%r15,4), %edi
xorl %esi, %esi
testl %edi, %edi
jle 0xdbae
movq (%rdx), %r8
leaq (%rsi,%rsi,2), %rax
movq (%r8,%rax,8), %r8
movq 0x90(%rbx), %r9
movq 0xa8(%rbx), %r10
addq $-0x18, %r10
movq 0xc0(%rbx), %r11
addq $-0x18, %r11
xorl %r12d, %r12d
movslq (%r8,%r12,4), %rbp
testq %rbp, %rbp
je 0xdba0
movslq (%r9,%r15,4), %rdi
leaq (%rdi,%rdi,2), %rdi
movq (%r10,%rdi,8), %rdi
movq (%rdi,%rax,8), %rdi
decl -0x4(%rdi,%rbp,4)
movslq (%r9,%r15,4), %rdi
leaq (%rdi,%rdi,2), %rdi
movq (%r11,%rdi,8), %rdi
decl (%rdi,%rsi,4)
movl (%rcx,%r15,4), %edi
incq %r12
movslq %edi, %rbp
cmpq %rbp, %r12
jl 0xdb70
movl 0x24(%rbx), %eax
incq %rsi
movslq %eax, %r8
cmpq %r8, %rsi
jl 0xdb41
movsd 0x78(%rbx), %xmm0
ucomisd 0x284e2(%rip), %xmm0    # 0x360a8
jne 0xdce9
jp 0xdce9
movslq 0x1c(%rbx), %r12
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
callq 0x3290
xorpd 0x28455(%rip), %xmm0    # 0x36040
movlpd %xmm0, 0x30(%rsp)
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
leaq 0x30(%rsp), %rdx
leaq 0xf(%rsp), %rcx
callq 0x5b2e
movq 0x170(%rbx), %rdi
movaps 0x10(%rsp), %xmm0
movups %xmm0, 0x170(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x180(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
testq %rdi, %rdi
je 0xdc51
callq 0x3310
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xdc51
callq 0x3310
movslq 0x1c(%rbx), %rsi
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
movsd 0x285fc(%rip), %xmm1    # 0x36260
divsd %xmm0, %xmm1
movsd %xmm1, 0x30(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
leaq 0xf(%rsp), %rcx
callq 0x5b2e
movq 0x198(%rbx), %rdi
movaps 0x10(%rsp), %xmm0
movups %xmm0, 0x198(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x1a8(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
testq %rdi, %rdi
je 0xdccb
callq 0x3310
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xdccb
callq 0x3310
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x1b0(%rbx)
movsd 0x2857c(%rip), %xmm0    # 0x36260
jmp 0xddcd
xorl %r12d, %r12d
cmpl $0x0, 0x1c(%rbx)
jle 0xdd11
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0xe6da
incl %r12d
movl 0x1c(%rbx), %eax
cmpl %eax, %r12d
jl 0xdcf2
testl %eax, %eax
setg %r12b
movq 0x170(%rbx), %rax
movq 0x178(%rbx), %rcx
cmpq %rcx, %rax
sete %sil
movq %rax, %rdx
addq $0x8, %rdx
cmpq %rcx, %rdx
sete %dil
orb %sil, %dil
jne 0xdd5a
movsd (%rax), %xmm0
movsd (%rdx), %xmm1
ucomisd %xmm0, %xmm1
cmovaq %rdx, %rax
maxsd %xmm0, %xmm1
addq $0x8, %rdx
movapd %xmm1, %xmm0
cmpq %rcx, %rdx
jne 0xdd3d
movsd (%rax), %xmm0
movsd %xmm0, 0x190(%rbx)
movq $0x0, 0x1b0(%rbx)
xorpd %xmm0, %xmm0
testb %r12b, %r12b
je 0xddcd
xorl %r12d, %r12d
movsd 0x78(%rbx), %xmm0
movq 0x170(%rbx), %rax
movsd 0x190(%rbx), %xmm1
mulsd %xmm0, %xmm1
mulsd (%rax,%r12,8), %xmm0
subsd %xmm1, %xmm0
callq 0x35a0
movq 0x198(%rbx), %rax
movsd %xmm0, (%rax,%r12,8)
addsd 0x1b0(%rbx), %xmm0
movsd %xmm0, 0x1b0(%rbx)
incq %r12
movslq 0x1c(%rbx), %rax
cmpq %rax, %r12
jl 0xdd7d
movq %r14, %rdi
callq 0x1d2d5
movq 0x90(%rbx), %rcx
movl %eax, (%rcx,%r15,4)
movl 0x24(%rbx), %eax
testl %eax, %eax
jle 0xde6f
movq 0x40(%rbx), %rdx
shlq $0x3, %r13
addq (%rbx), %r13
movl (%rdx,%r15,4), %edi
xorl %esi, %esi
testl %edi, %edi
jle 0xde64
movq (%r13), %r8
leaq (%rsi,%rsi,2), %rax
movq (%r8,%rax,8), %r8
movq 0xa8(%rbx), %r9
movq 0xc0(%rbx), %r10
addq $-0x18, %r9
addq $-0x18, %r10
xorl %r11d, %r11d
movslq (%r8,%r11,4), %r12
testq %r12, %r12
je 0xde56
movslq (%rcx,%r15,4), %rdi
leaq (%rdi,%rdi,2), %rdi
movq (%r9,%rdi,8), %rdi
movq (%rdi,%rax,8), %rdi
incl -0x4(%rdi,%r12,4)
movslq (%rcx,%r15,4), %rdi
leaq (%rdi,%rdi,2), %rdi
movq (%r10,%rdi,8), %rdi
incl (%rdi,%rsi,4)
movl (%rdx,%r15,4), %edi
incq %r11
movslq %edi, %r12
cmpq %r12, %r11
jl 0xde25
movl 0x24(%rbx), %eax
incq %rsi
movslq %eax, %r8
cmpq %r8, %rsi
jl 0xddfc
incq %r15
movslq 0x20(%rbx), %rcx
cmpq %rcx, %r15
jl 0xdb20
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq