// File: /workspace/github_cpp_makefile_star2_O2/bobverity[P]MavericK/MCMCobject_admixture.cpp
// Function: MCMCobject_admixture::reset(bool)
void MCMCobject_admixture::reset(bool reset_Qmatrix_running) {
    
    // reset likelihoods
    logLikeGroup = 0;
    logLikeGroup_sum = 0;
    logLikeGroup_store = vector<double>(samples);
    logLikeGroup_sumSquared = 0;
    logLikeJoint = 0;
    logLikeJoint_sum = 0;
    logLikeJoint_sumSquared = 0;
    harmonic = log(double(0));
    
    // reset Qmatrices
    logQmatrix_gene_old = vector< vector<double> >(geneCopies, vector<double>(K));
    logQmatrix_gene_new = vector< vector<double> >(geneCopies, vector<double>(K));
    Qmatrix_gene_new = vector< vector<double> >(geneCopies, vector<double>(K));
    if (reset_Qmatrix_running) {
        logQmatrix_gene_running = vector< vector<double> >(geneCopies, vector<double>(K,-log(double(K))));
    }
    
    logQmatrix_gene = vector< vector<double> >(geneCopies, vector<double>(K, log(double(0))));
    Qmatrix_gene = vector< vector<double> >(geneCopies, vector<double>(K));
    Qmatrix_ind = vector< vector<double> >(n, vector<double>(K));
    Qmatrix_pop = vector< vector<double> >(uniquePops.size(), vector<double>(K));
    
    // initialise group with random allocation
    vector<double> equalK(K,1/double(K));
    groupIndex=-1;
    for (int i=0; i<n; i++) {
        for (int l=0; l<loci; l++) {
            for (int p=0; p<ploidy_vec[i]; p++) {
                groupIndex++;
                linearGroup[groupIndex] = sample1(equalK,1.0);
                group[i][l][p] = linearGroup[groupIndex];
            }
        }
    }
    
    // zero allele counts and admix counts
    for (int k=0; k<K; k++) {
        alleleCountsTotals[k] = vector<int>(loci);
        for (int l=0; l<loci; l++) {
            alleleCounts[k][l] = vector<int>(J[l]);
        }
    }
    admixCounts = vector< vector<int> > (n,vector<int>(K));
    admixCountsTotals = vector<int> (n);
    
    // populate allele counts and admix counts
    groupIndex=-1;
    for (int ind=0; ind<n; ind++) {
        for (int l=0; l<loci; l++) {
            for (int p=0; p<ploidy_vec[ind]; p++) {
                groupIndex++;
                if (data[ind][l][p]!=0) {
                    alleleCounts[linearGroup[groupIndex]-1][l][data[ind][l][p]-1]++;
                    alleleCountsTotals[linearGroup[groupIndex]-1][l]++;
                    
                    admixCounts[ind][linearGroup[groupIndex]-1]++;
                    admixCountsTotals[ind]++;
                }
            }
        }
    }
    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %esi, %ebp
movq %rdi, %rbx
xorpd %xmm0, %xmm0
movupd %xmm0, 0x1e8(%rdi)
movslq 0xa8(%rdi), %rsi
leaq 0x20(%rsp), %r14
leaq 0x8(%rsp), %rdx
movq %r14, %rdi
callq 0x4f6c
leaq 0x1f8(%rbx), %rdi
movq %r14, %rsi
callq 0x55b8
movq %r14, %rdi
callq 0x51a2
xorpd %xmm0, %xmm0
movupd %xmm0, 0x220(%rbx)
movupd %xmm0, 0x210(%rbx)
xorpd %xmm0, %xmm0
callq 0x32d0
movsd %xmm0, 0x230(%rbx)
movslq 0x70(%rbx), %r14
movslq 0x1c(%rbx), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x4f6c
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rdx
leaq 0x6(%rsp), %rcx
movq %r14, %rsi
callq 0x4fbe
leaq 0x280(%rbx), %rdi
leaq 0x20(%rsp), %r14
movq %r14, %rsi
callq 0x5566
movq %r14, %rdi
callq 0x50da
leaq 0x8(%rsp), %rdi
callq 0x51a2
movslq 0x70(%rbx), %r14
movslq 0x1c(%rbx), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x4f6c
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rdx
leaq 0x6(%rsp), %rcx
movq %r14, %rsi
callq 0x4fbe
leaq 0x298(%rbx), %rdi
leaq 0x20(%rsp), %r14
movq %r14, %rsi
callq 0x5566
movq %r14, %rdi
callq 0x50da
leaq 0x8(%rsp), %rdi
callq 0x51a2
movslq 0x70(%rbx), %r14
movslq 0x1c(%rbx), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x4f6c
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rdx
leaq 0x6(%rsp), %rcx
movq %r14, %rsi
callq 0x4fbe
leaq 0x2b0(%rbx), %rdi
leaq 0x20(%rsp), %r14
movq %r14, %rsi
callq 0x5566
movq %r14, %rdi
callq 0x50da
leaq 0x8(%rsp), %rdi
callq 0x51a2
testb %bpl, %bpl
je 0x73e5
movslq 0x70(%rbx), %r14
movslq 0x1c(%rbx), %r15
cvtsi2sd %r15d, %xmm0
callq 0x32d0
xorpd 0x1fca3(%rip), %xmm0    # 0x27030
leaq 0x38(%rsp), %rdx
movlpd %xmm0, (%rdx)
leaq 0x8(%rsp), %rdi
leaq 0x6(%rsp), %rcx
movq %r15, %rsi
callq 0x5120
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rdx
leaq 0x7(%rsp), %rcx
movq %r14, %rsi
callq 0x4fbe
leaq 0x2c8(%rbx), %rdi
leaq 0x20(%rsp), %r14
movq %r14, %rsi
callq 0x5566
movq %r14, %rdi
callq 0x50da
leaq 0x8(%rsp), %rdi
callq 0x51a2
movslq 0x70(%rbx), %r14
movslq 0x1c(%rbx), %r15
xorpd %xmm0, %xmm0
callq 0x32d0
leaq 0x38(%rsp), %rdx
movsd %xmm0, (%rdx)
leaq 0x8(%rsp), %rdi
leaq 0x6(%rsp), %rcx
movq %r15, %rsi
callq 0x5120
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rdx
leaq 0x7(%rsp), %rcx
movq %r14, %rsi
callq 0x4fbe
leaq 0x2e0(%rbx), %rdi
leaq 0x20(%rsp), %r14
movq %r14, %rsi
callq 0x5566
movq %r14, %rdi
callq 0x50da
leaq 0x8(%rsp), %rdi
callq 0x51a2
movslq 0x70(%rbx), %r14
movslq 0x1c(%rbx), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x4f6c
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rdx
leaq 0x6(%rsp), %rcx
movq %r14, %rsi
callq 0x4fbe
leaq 0x2f8(%rbx), %rdi
leaq 0x20(%rsp), %r14
movq %r14, %rsi
callq 0x5566
movq %r14, %rdi
callq 0x50da
leaq 0x8(%rsp), %rdi
callq 0x51a2
movslq 0x20(%rbx), %r14
movslq 0x1c(%rbx), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x4f6c
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rdx
leaq 0x6(%rsp), %rcx
movq %r14, %rsi
callq 0x4fbe
leaq 0x310(%rbx), %rdi
leaq 0x20(%rsp), %r14
movq %r14, %rsi
callq 0x5566
movq %r14, %rdi
callq 0x50da
leaq 0x8(%rsp), %rdi
callq 0x51a2
movq 0x58(%rbx), %r15
movq 0x60(%rbx), %r14
movslq 0x1c(%rbx), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x4f6c
subq %r15, %r14
sarq $0x5, %r14
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rdx
leaq 0x6(%rsp), %rcx
movq %r14, %rsi
callq 0x4fbe
leaq 0x328(%rbx), %rdi
leaq 0x20(%rsp), %r14
movq %r14, %rsi
callq 0x5566
movq %r14, %rdi
callq 0x50da
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x51a2
movslq 0x1c(%rbx), %rsi
cvtsi2sd %esi, %xmm0
movsd 0x1fca8(%rip), %xmm1    # 0x27210
divsd %xmm0, %xmm1
movsd %xmm1, (%r14)
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rdx
leaq 0x38(%rsp), %rcx
callq 0x5120
orl $-0x1, 0x108(%rbx)
xorl %r15d, %r15d
leaq 0x20(%rsp), %r14
movslq 0x20(%rbx), %rax
cmpq %rax, %r15
jge 0x7624
imulq $0x18, %r15, %r12
xorl %ecx, %ecx
movslq 0x24(%rbx), %rax
cmpq %rax, %rcx
jge 0x761c
movq %rcx, 0x50(%rsp)
imulq $0x18, %rcx, %rbp
xorl %r13d, %r13d
movq 0x40(%rbx), %rax
movslq (%rax,%r15,4), %rax
cmpq %rax, %r13
jge 0x7612
incl 0x108(%rbx)
movq %r14, %rdi
movsd 0x1fc36(%rip), %xmm0    # 0x27210
callq 0x17127
movslq 0x108(%rbx), %rcx
movq 0xc0(%rbx), %rdx
movl %eax, (%rdx,%rcx,4)
movslq 0x108(%rbx), %rax
movl (%rdx,%rax,4), %eax
movq 0xd8(%rbx), %rcx
movq (%rcx,%r12), %rcx
movq (%rcx,%rbp), %rcx
movl %eax, (%rcx,%r13,4)
incq %r13
jmp 0x75bc
movq 0x50(%rsp), %rcx
incq %rcx
jmp 0x75a7
incq %r15
jmp 0x7594
xorl %r12d, %r12d
leaq 0x8(%rsp), %r14
leaq 0x38(%rsp), %r15
movslq 0x1c(%rbx), %rsi
cmpq %rsi, %r12
jge 0x76c5
movslq 0x24(%rbx), %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x5f7c
movq %r12, 0x50(%rsp)
imulq $0x18, %r12, %r13
movq 0x128(%rbx), %rdi
addq %r13, %rdi
movq %r14, %rsi
callq 0x6266
movq %r14, %rdi
callq 0x61d0
xorl %ebp, %ebp
xorl %r12d, %r12d
movslq 0x24(%rbx), %rax
cmpq %rax, %r12
jge 0x76b8
movq 0x28(%rbx), %rax
movslq (%rax,%r12,4), %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x5f7c
movq 0x110(%rbx), %rax
movq (%rax,%r13), %rdi
addq %rbp, %rdi
movq %r14, %rsi
callq 0x6266
movq %r14, %rdi
callq 0x61d0
incq %r12
addq $0x18, %rbp
jmp 0x7675
movq 0x50(%rsp), %r12
incq %r12
jmp 0x7631
movslq 0x20(%rbx), %r14
leaq 0x38(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x5f7c
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
leaq 0x7(%rsp), %rcx
movq %r14, %rsi
callq 0x9908
leaq 0x188(%rbx), %rdi
leaq 0x8(%rsp), %r14
movq %r14, %rsi
callq 0xa27c
movq %r14, %rdi
callq 0x98e6
leaq 0x38(%rsp), %rdi
callq 0x61d0
movslq 0x20(%rbx), %rsi
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x5f7c
leaq 0x1a0(%rbx), %rdi
leaq 0x8(%rsp), %r14
movq %r14, %rsi
callq 0x6266
movq %r14, %rdi
callq 0x61d0
orl $-0x1, 0x108(%rbx)
xorl %eax, %eax
movslq 0x20(%rbx), %rcx
cmpq %rcx, %rax
jge 0x7833
movq 0x40(%rbx), %rcx
imulq $0x18, %rax, %rdx
xorl %esi, %esi
movslq 0x24(%rbx), %rdi
cmpq %rdi, %rsi
jge 0x782b
movq (%rbx), %rdi
addq %rdx, %rdi
movq 0xc0(%rbx), %r8
movq 0x110(%rbx), %r9
addq $-0x18, %r9
movq 0x128(%rbx), %r10
addq $-0x18, %r10
movq 0x188(%rbx), %r11
addq %rdx, %r11
movq 0x1a0(%rbx), %r14
imulq $0x18, %rsi, %r15
xorl %r12d, %r12d
movslq (%rcx,%rax,4), %r13
cmpq %r13, %r12
jge 0x7823
movslq 0x108(%rbx), %r13
leal 0x1(%r13), %ebp
movl %ebp, 0x108(%rbx)
movq (%rdi), %rbp
movq (%rbp,%r15), %rbp
movslq (%rbp,%r12,4), %rbp
testq %rbp, %rbp
je 0x781e
movslq 0x4(%r8,%r13,4), %r13
imulq $0x18, %r13, %r13
movq (%r9,%r13), %r13
movq (%r13,%r15), %r13
incl -0x4(%r13,%rbp,4)
movslq 0x108(%rbx), %r13
movslq (%r8,%r13,4), %r13
imulq $0x18, %r13, %r13
movq (%r10,%r13), %r13
incl (%r13,%rsi,4)
movslq 0x108(%rbx), %r13
movslq (%r8,%r13,4), %r13
movq (%r11), %rbp
incl -0x4(%rbp,%r13,4)
incl (%r14,%rax,4)
incq %r12
jmp 0x77ac
incq %rsi
jmp 0x7764
incq %rax
jmp 0x774d
leaq 0x20(%rsp), %rdi
callq 0x51a2
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x787d
jmp 0x7887
jmp 0x7890
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x61d0
jmp 0x7893
jmp 0x7890
jmp 0x7887
jmp 0x787d
jmp 0x7887
jmp 0x787d
jmp 0x7887
jmp 0x787d
jmp 0x7887
jmp 0x787d
jmp 0x7887
jmp 0x787d
jmp 0x7887
jmp 0x787d
jmp 0x7887
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
jmp 0x7898
movq %rax, %rbx
jmp 0x789d
jmp 0x7890
jmp 0x7890
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x51a2
movq %rbx, %rdi
callq 0x35a0
nop