// File: /workspace/github_cpp_makefile_star2_O1/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 0xe2e1
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
leaq 0x198(%rdi), %r14
xorl %r15d, %r15d
cmpl $0x0, 0x24(%rbx)
leaq (%r15,%r15,2), %r13
jle 0xdffa
movq 0x40(%rbx), %rax
leaq (,%r13,8), %rcx
addq (%rbx), %rcx
xorl %edx, %edx
cmpl $0x0, (%rax,%r15,4)
jle 0xdfee
movq (%rcx), %rdi
leaq (%rdx,%rdx,2), %rsi
movq (%rdi,%rsi,8), %rdi
movq 0x90(%rbx), %r8
movq 0xa8(%rbx), %r9
addq $-0x18, %r9
movq 0xc0(%rbx), %r10
addq $-0x18, %r10
xorl %r11d, %r11d
movslq (%rdi,%r11,4), %r12
testq %r12, %r12
je 0xdfe2
movslq (%r8,%r15,4), %rbp
leaq (%rbp,%rbp,2), %rbp
movq (%r9,%rbp,8), %rbp
movq (%rbp,%rsi,8), %rbp
decl -0x4(%rbp,%r12,4)
movslq (%r8,%r15,4), %r12
leaq (%r12,%r12,2), %r12
movq (%r10,%r12,8), %r12
decl (%r12,%rdx,4)
incq %r11
movslq (%rax,%r15,4), %r12
cmpq %r12, %r11
jl 0xdfb2
incq %rdx
movslq 0x24(%rbx), %rsi
cmpq %rsi, %rdx
jl 0xdf80
movsd 0x78(%rbx), %xmm0
ucomisd 0x290a1(%rip), %xmm0    # 0x370a8
jne 0xe14a
jp 0xe14a
movslq 0x1c(%rbx), %r12
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
callq 0x3290
xorpd 0x29014(%rip), %xmm0    # 0x37040
movlpd %xmm0, 0x30(%rsp)
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
leaq 0x30(%rsp), %rdx
leaq 0xf(%rsp), %rcx
callq 0x5bba
movq 0x170(%rbx), %rdi
movaps 0x10(%rsp), %xmm0
movq 0x20(%rsp), %rax
movq %rdi, 0x10(%rsp)
movups 0x178(%rbx), %xmm1
movups %xmm0, 0x170(%rbx)
movq %rax, 0x180(%rbx)
movups %xmm1, 0x18(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
testq %rdi, %rdi
je 0xe094
callq 0x3310
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xe0a3
callq 0x3310
movslq 0x1c(%rbx), %rsi
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
movsd 0x291aa(%rip), %xmm1    # 0x37260
divsd %xmm0, %xmm1
movsd %xmm1, 0x30(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
leaq 0xf(%rsp), %rcx
callq 0x5bba
movq 0x198(%rbx), %rdi
movapd 0x10(%rsp), %xmm0
movq 0x20(%rsp), %rax
movq %rdi, 0x10(%rsp)
movupd 0x1a0(%rbx), %xmm1
movupd %xmm0, 0x198(%rbx)
movq %rax, 0x1a8(%rbx)
movupd %xmm1, 0x18(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
testq %rdi, %rdi
je 0xe125
callq 0x3310
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xe134
callq 0x3310
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x1b0(%rbx)
jmp 0xe223
cmpl $0x0, 0x1c(%rbx)
jle 0xe16a
xorl %r12d, %r12d
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0xeb32
incl %r12d
cmpl 0x1c(%rbx), %r12d
jl 0xe153
movq 0x170(%rbx), %rdx
movq 0x178(%rbx), %rax
cmpq %rax, %rdx
sete %sil
movq %rdx, %rcx
addq $0x8, %rcx
cmpq %rax, %rcx
sete %dil
orb %sil, %dil
je 0xe197
movq %rdx, %rsi
jmp 0xe1b3
movsd (%rcx), %xmm0
ucomisd (%rdx), %xmm0
movq %rcx, %rsi
ja 0xe1a7
movq %rdx, %rsi
addq $0x8, %rcx
movq %rsi, %rdx
cmpq %rax, %rcx
jne 0xe197
movsd (%rsi), %xmm0
movsd %xmm0, 0x190(%rbx)
movq $0x0, 0x1b0(%rbx)
cmpl $0x0, 0x1c(%rbx)
jle 0xe223
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 0xe1d3
movsd 0x1b0(%rbx), %xmm0
movq %r14, %rdi
callq 0x1d629
movq 0x90(%rbx), %rcx
movl %eax, (%rcx,%r15,4)
cmpl $0x0, 0x24(%rbx)
jle 0xe2c3
movq 0x40(%rbx), %rax
shlq $0x3, %r13
addq (%rbx), %r13
xorl %edx, %edx
cmpl $0x0, (%rax,%r15,4)
jle 0xe2b7
movq (%r13), %rdi
leaq (%rdx,%rdx,2), %rsi
movq (%rdi,%rsi,8), %rdi
movq 0xa8(%rbx), %r8
movq 0xc0(%rbx), %r9
addq $-0x18, %r8
addq $-0x18, %r9
xorl %r10d, %r10d
movslq (%rdi,%r10,4), %r11
testq %r11, %r11
je 0xe2ab
movslq (%rcx,%r15,4), %r12
leaq (%r12,%r12,2), %r12
movq (%r8,%r12,8), %r12
movq (%r12,%rsi,8), %r12
incl -0x4(%r12,%r11,4)
movslq (%rcx,%r15,4), %r11
leaq (%r11,%r11,2), %r11
movq (%r9,%r11,8), %r11
incl (%r11,%rdx,4)
incq %r10
movslq (%rax,%r15,4), %r11
cmpq %r11, %r10
jl 0xe27d
incq %rdx
movslq 0x24(%rbx), %rsi
cmpq %rsi, %rdx
jl 0xe251
incq %r15
movslq 0x20(%rbx), %rax
cmpq %rax, %r15
jl 0xdf61
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq