// File: 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:
subq $0x128, %rsp            # imm = 0x128
movq %rdi, 0x120(%rsp)
movq 0x120(%rsp), %rax
movq %rax, 0x80(%rsp)
movl $0x0, 0x11c(%rsp)
movq 0x80(%rsp), %rcx
movl 0x11c(%rsp), %eax
cmpl 0x20(%rcx), %eax
jge 0x1fd16
movl $0x0, 0x118(%rsp)
movq 0x80(%rsp), %rcx
movl 0x118(%rsp), %eax
cmpl 0x24(%rcx), %eax
jge 0x1f763
movl $0x0, 0x114(%rsp)
movq 0x80(%rsp), %rdi
movl 0x114(%rsp), %eax
movl %eax, 0x7c(%rsp)
addq $0x40, %rdi
movslq 0x11c(%rsp), %rsi
callq 0x8ba0
movq %rax, %rcx
movl 0x7c(%rsp), %eax
cmpl (%rcx), %eax
jge 0x1f74b
movq 0x80(%rsp), %rdi
movslq 0x11c(%rsp), %rsi
callq 0x8c40
movq %rax, %rdi
movslq 0x118(%rsp), %rsi
callq 0x8c60
movq %rax, %rdi
movslq 0x114(%rsp), %rsi
callq 0x8ba0
cmpl $0x0, (%rax)
je 0x1f733
movq 0x80(%rsp), %rdi
movq %rdi, %rax
addq $0xa8, %rax
movq %rax, 0x60(%rsp)
addq $0x90, %rdi
movslq 0x11c(%rsp), %rsi
callq 0x8ba0
movq 0x60(%rsp), %rdi
movl (%rax), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x8c40
movq %rax, %rdi
movslq 0x118(%rsp), %rsi
callq 0x8c60
movq 0x80(%rsp), %rdi
movq %rax, 0x68(%rsp)
movslq 0x11c(%rsp), %rsi
callq 0x8c40
movq %rax, %rdi
movslq 0x118(%rsp), %rsi
callq 0x8c60
movq %rax, %rdi
movslq 0x114(%rsp), %rsi
callq 0x8ba0
movq 0x68(%rsp), %rdi
movl (%rax), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x8ba0
movq 0x80(%rsp), %rdi
movl (%rax), %ecx
addl $-0x1, %ecx
movl %ecx, (%rax)
movq %rdi, %rax
addq $0xc0, %rax
movq %rax, 0x70(%rsp)
addq $0x90, %rdi
movslq 0x11c(%rsp), %rsi
callq 0x8ba0
movq 0x70(%rsp), %rdi
movl (%rax), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x8c60
movq %rax, %rdi
movslq 0x118(%rsp), %rsi
callq 0x8ba0
movl (%rax), %ecx
addl $-0x1, %ecx
movl %ecx, (%rax)
jmp 0x1f735
movl 0x114(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x114(%rsp)
jmp 0x1f5d0
jmp 0x1f74d
movl 0x118(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x118(%rsp)
jmp 0x1f5ad
movq 0x80(%rsp), %rax
movsd 0x78(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1f918
jp 0x1f918
movq 0x80(%rsp), %rax
movslq 0x1c(%rax), %rax
movq %rax, 0x50(%rsp)
cvtsi2sd %eax, %xmm0
callq 0x4390
movaps 0x3c88c(%rip), %xmm1    # 0x5c030
pxor %xmm1, %xmm0
movlpd %xmm0, 0xf0(%rsp)
leaq 0xef(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x8780
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rcx
leaq 0xf8(%rsp), %rdi
leaq 0xf0(%rsp), %rdx
callq 0x8cf0
jmp 0x1f7e4
movq 0x80(%rsp), %rdi
addq $0x170, %rdi            # imm = 0x170
leaq 0xf8(%rsp), %rsi
movq %rsi, 0x38(%rsp)
callq 0x8be0
movq 0x38(%rsp), %rdi
callq 0x88b0
leaq 0xef(%rsp), %rdi
callq 0x8910
movq 0x80(%rsp), %rax
movslq 0x1c(%rax), %rax
movq %rax, 0x40(%rsp)
cvtsi2sd %eax, %xmm1
movsd 0x3c9c7(%rip), %xmm0    # 0x5c200
divsd %xmm1, %xmm0
movsd %xmm0, 0xb8(%rsp)
leaq 0xb7(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x8780
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rcx
leaq 0xc0(%rsp), %rdi
leaq 0xb8(%rsp), %rdx
callq 0x8cf0
jmp 0x1f879
movq 0x80(%rsp), %rdi
addq $0x198, %rdi            # imm = 0x198
leaq 0xc0(%rsp), %rsi
callq 0x8be0
leaq 0xc0(%rsp), %rdi
callq 0x88b0
leaq 0xb7(%rsp), %rdi
callq 0x8910
movq 0x80(%rsp), %rax
movsd 0x3c941(%rip), %xmm0    # 0x5c200
movsd %xmm0, 0x1b0(%rax)
jmp 0x1faf8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0xef(%rsp), %rdi
callq 0x8910
jmp 0x1fd1e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe0(%rsp)
movl %eax, 0xdc(%rsp)
leaq 0xb7(%rsp), %rdi
callq 0x8910
jmp 0x1fd1e
movl $0x0, 0xb0(%rsp)
movq 0x80(%rsp), %rcx
movl 0xb0(%rsp), %eax
cmpl 0x1c(%rcx), %eax
jge 0x1f965
movq 0x80(%rsp), %rdi
movl 0x11c(%rsp), %esi
movl 0xb0(%rsp), %edx
callq 0x20d00
movl 0xb0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xb0(%rsp)
jmp 0x1f923
movq 0x80(%rsp), %rdi
addq $0x170, %rdi            # imm = 0x170
callq 0xc880
movq 0x80(%rsp), %rdi
movq %rax, 0xa0(%rsp)
addq $0x170, %rdi            # imm = 0x170
callq 0xc8b0
movq %rax, 0x98(%rsp)
movq 0xa0(%rsp), %rdi
movq 0x98(%rsp), %rsi
callq 0x21080
movq %rax, 0xa8(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0xc8e0
movq %rax, %rcx
movq 0x80(%rsp), %rax
movsd (%rcx), %xmm0
movsd %xmm0, 0x190(%rax)
xorps %xmm0, %xmm0
movsd %xmm0, 0x1b0(%rax)
movl $0x0, 0x94(%rsp)
movq 0x80(%rsp), %rcx
movl 0x94(%rsp), %eax
cmpl 0x1c(%rcx), %eax
jge 0x1faf6
movq 0x80(%rsp), %rdi
movsd 0x78(%rdi), %xmm0
movsd %xmm0, 0x28(%rsp)
addq $0x170, %rdi            # imm = 0x170
movslq 0x94(%rsp), %rsi
callq 0x8c20
movsd 0x28(%rsp), %xmm0
movq %rax, %rcx
movq 0x80(%rsp), %rax
movsd (%rcx), %xmm2
movsd 0x78(%rax), %xmm1
mulsd 0x190(%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x4760
movq 0x80(%rsp), %rdi
movsd %xmm0, 0x30(%rsp)
addq $0x198, %rdi            # imm = 0x198
movslq 0x94(%rsp), %rsi
callq 0x8c20
movsd 0x30(%rsp), %xmm0
movq 0x80(%rsp), %rdi
movsd %xmm0, (%rax)
addq $0x198, %rdi            # imm = 0x198
movslq 0x94(%rsp), %rsi
callq 0x8c20
movq %rax, %rcx
movq 0x80(%rsp), %rax
movsd (%rcx), %xmm0
addsd 0x1b0(%rax), %xmm0
movsd %xmm0, 0x1b0(%rax)
movl 0x94(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x94(%rsp)
jmp 0x1f9f4
jmp 0x1faf8
movq 0x80(%rsp), %rax
movq %rax, %rdi
addq $0x198, %rdi            # imm = 0x198
movsd 0x1b0(%rax), %xmm0
callq 0x39240
movq 0x80(%rsp), %rdi
movl %eax, 0x24(%rsp)
addq $0x90, %rdi
movslq 0x11c(%rsp), %rsi
callq 0x8ba0
movl 0x24(%rsp), %ecx
movl %ecx, (%rax)
movl $0x0, 0x90(%rsp)
movq 0x80(%rsp), %rcx
movl 0x90(%rsp), %eax
cmpl 0x24(%rcx), %eax
jge 0x1fcfe
movl $0x0, 0x8c(%rsp)
movq 0x80(%rsp), %rdi
movl 0x8c(%rsp), %eax
movl %eax, 0x20(%rsp)
addq $0x40, %rdi
movslq 0x11c(%rsp), %rsi
callq 0x8ba0
movq %rax, %rcx
movl 0x20(%rsp), %eax
cmpl (%rcx), %eax
jge 0x1fce6
movq 0x80(%rsp), %rdi
movslq 0x11c(%rsp), %rsi
callq 0x8c40
movq %rax, %rdi
movslq 0x90(%rsp), %rsi
callq 0x8c60
movq %rax, %rdi
movslq 0x8c(%rsp), %rsi
callq 0x8ba0
cmpl $0x0, (%rax)
je 0x1fcce
movq 0x80(%rsp), %rdi
movq %rdi, %rax
addq $0xa8, %rax
movq %rax, 0x8(%rsp)
addq $0x90, %rdi
movslq 0x11c(%rsp), %rsi
callq 0x8ba0
movq 0x8(%rsp), %rdi
movl (%rax), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x8c40
movq %rax, %rdi
movslq 0x90(%rsp), %rsi
callq 0x8c60
movq 0x80(%rsp), %rdi
movq %rax, 0x10(%rsp)
movslq 0x11c(%rsp), %rsi
callq 0x8c40
movq %rax, %rdi
movslq 0x90(%rsp), %rsi
callq 0x8c60
movq %rax, %rdi
movslq 0x8c(%rsp), %rsi
callq 0x8ba0
movq 0x10(%rsp), %rdi
movl (%rax), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x8ba0
movq 0x80(%rsp), %rdi
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq %rdi, %rax
addq $0xc0, %rax
movq %rax, 0x18(%rsp)
addq $0x90, %rdi
movslq 0x11c(%rsp), %rsi
callq 0x8ba0
movq 0x18(%rsp), %rdi
movl (%rax), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x8c60
movq %rax, %rdi
movslq 0x90(%rsp), %rsi
callq 0x8ba0
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x1fcd0
movl 0x8c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8c(%rsp)
jmp 0x1fb6b
jmp 0x1fce8
movl 0x90(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x90(%rsp)
jmp 0x1fb48
jmp 0x1fd00
movl 0x11c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x11c(%rsp)
jmp 0x1f58a
addq $0x128, %rsp            # imm = 0x128
retq
movq 0xe0(%rsp), %rdi
callq 0x4730
nopl (%rax,%rax)