// File: /workspace/github_cpp_makefile_star2_O1/myudelson[P]hmm-scalable/HMMProblemSt.cpp
// Function: HMMProblemSt::updateValuesLocal(double***, int*, signed char, double*, context*)
void HMMProblemSt::updateValuesLocal(NUMBER*** group_skill_map, NCAT* skills, NPAR n_skills, NUMBER* local_pred, struct context *ctx) {
    NPAR i, j, nS = this->task->nS;//, o = this->task->dat_obs[ctx->t];
    NCAT k, g = ctx->g;
    NUMBER pLe_denom = 0.0;
    NUMBER *pLe = init1D<NUMBER>(nS);
    NUMBER* group_skill_map_gk; // TODO, try to see time change
    
    // update pL
    for(NPAR l=0; l<n_skills; l++) {
        k = skills[l];
        ctx->k = k;
        group_skill_map_gk = group_skill_map[g][k]; // TODO, try to see time change
//        NUMBER* pLbit = gsm(g,k); //BOOST
        
        if(ctx->o>-1) { // known observations //
            // update p(L)
            pLe_denom = 0.0;
            // 1. pLe =  (L .* B(:,o)) ./ ( L'*B(:,o)+1e-8 );
            for(i=0; i<nS; i++)
                pLe_denom += /*group_skill_map[g][k]*/group_skill_map_gk[i] * getB(ctx,i,ctx->o);  // TODO: this is local_pred[o]!!!//UNBOOST
//                  pLe_denom += pLbit[i] * getB(ctx,i,o); //BOOST
            for(i=0; i<nS; i++)
                pLe[i] = /*group_skill_map[g][k]*/group_skill_map_gk[i] * getB(ctx,i,ctx->o) / safe0num(pLe_denom); //UNBOOST
//                  pLe[i] = pLbit[i] * getB(ctx,i,o) / safe0num(pLe_denom); //BOOST
            // 2. L = (pLe'*A)';
            for(i=0; i<nS; i++)
            /*group_skill_map[g][k]*/group_skill_map_gk[i]= 0.0; //UNBOOST
//                  pLbit[i]= 0.0; //BOOST
            for(j=0; j<nS; j++)
                for(i=0; i<nS; i++)
            /*group_skill_map[g][k]*/group_skill_map_gk[j] += pLe[i] * getA(ctx,i,j);//A[i][j]; //UNBOOST
//                    pLbit[j] += pLe[i] * getA(ctx,i,j);//A[i][j]; //BOOST
        } else { // unknown observation
            // 2. L = (pL'*A)';
            for(i=0; i<nS; i++)
                pLe[i] = /*group_skill_map[g][k]*/group_skill_map_gk[i]; // copy first; //UNBOOST
//                  pLe[i] = pLbit[i]; // copy first; //BOOST
            for(i=0; i<nS; i++)
            /*group_skill_map[g][k]*/group_skill_map_gk[i] = 0.0; // erase old value //UNBOOST
//                  pLbit[i] = 0.0; // erase old value //BOOST
            for(j=0; j<nS; j++)
                for(i=0; i<nS; i++)
                    /*group_skill_map[g][k]*/group_skill_map_gk[j] += pLe[i] * getA(ctx,i,j);//UNBOOST
//               pLbit[j] += pLe[i] * getA(ctx,i,j);//BOOST
        }// observations
        projectsimplex(/*group_skill_map[g][k]*/group_skill_map_gk, nS); // addition to make sure there's no side effects //UNBOOST
//            projectsimplex(pLbit, nS); // addition to make sure there's no side effects //BOOST
    }
    free(pLe);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, %rbx
movl %ecx, %ebp
movq %rdx, 0x68(%rsp)
movq %rsi, 0x60(%rsp)
movq %rdi, %r12
movq 0x68(%rdi), %rax
movsbq 0x900(%rax), %r14
movslq 0x4(%r9), %rax
movq %rax, 0x58(%rsp)
movl $0x8, %esi
movq %r14, %rdi
callq 0x2110
movq %rax, %r15
testb %bpl, %bpl
jle 0xdc6a
movzbl %r14b, %eax
leal (,%rax,8), %ecx
movq %rcx, 0x40(%rsp)
leal (,%rax,8), %ecx
movq %rcx, 0x38(%rsp)
leal (,%rax,8), %ecx
movq %rcx, 0x48(%rsp)
movzbl %bpl, %ecx
movq %rcx, 0x50(%rsp)
movq %rax, %rbp
xorl %ecx, %ecx
movq %rbx, 0x28(%rsp)
movq %r15, 0x20(%rsp)
movq %r12, 0x18(%rsp)
movq %rax, 0x10(%rsp)
movq 0x68(%rsp), %rax
movq %rcx, 0x70(%rsp)
movslq (%rax,%rcx,4), %rax
movl %eax, (%rbx)
movq 0x60(%rsp), %rcx
movq 0x58(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movq (%rcx,%rax,8), %r13
cmpb $0x0, 0x10(%rbx)
movq %r13, 0x30(%rsp)
js 0xdabb
xorpd %xmm0, %xmm0
testb %bpl, %bpl
jle 0xdb59
movsd %xmm0, (%rsp)
xorl %r14d, %r14d
movsd (%r13,%r14,8), %xmm0
movsd %xmm0, 0x8(%rsp)
movsbl 0x10(%rbx), %ecx
movq (%r12), %rax
movsbl %r14b, %edx
movq %r12, %rdi
movq %rbx, %rsi
callq *0x38(%rax)
mulsd 0x8(%rsp), %xmm0
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
incq %r14
cmpq %r14, %rbp
jne 0xda78
jmp 0xdb5e
testb %bpl, %bpl
jle 0xdad0
movq %r15, %rdi
movq %r13, %rsi
movq 0x40(%rsp), %rdx
callq 0x2180
testb %bpl, %bpl
jle 0xdae4
movq %r13, %rdi
xorl %esi, %esi
movq 0x38(%rsp), %rdx
callq 0x2100
testb %bpl, %bpl
jle 0xdc3a
xorl %r14d, %r14d
xorl %r13d, %r13d
movq 0x28(%rsp), %rbx
movq 0x20(%rsp), %r15
movq 0x18(%rsp), %r12
movq 0x30(%rsp), %rbp
movsd (%r15,%r13,8), %xmm0
movsd %xmm0, (%rsp)
movq (%r12), %rax
movsbl %r14b, %ecx
movsbl %r13b, %edx
movq %r12, %rdi
movq %rbx, %rsi
callq *0x30(%rax)
mulsd (%rsp), %xmm0
addsd (%rbp,%r14,8), %xmm0
movsd %xmm0, (%rbp,%r14,8)
incq %r13
cmpq %r13, 0x10(%rsp)
jne 0xdb07
incq %r14
movq 0x10(%rsp), %rax
cmpq %rax, %r14
movq %rax, %rbp
jne 0xdaf0
jmp 0xdc3a
movsd %xmm0, (%rsp)
testb %bpl, %bpl
jle 0xdbb6
xorl %r14d, %r14d
movsd (%r13,%r14,8), %xmm0
movsd %xmm0, 0x8(%rsp)
movsbl 0x10(%rbx), %ecx
movq (%r12), %rax
movsbl %r14b, %edx
movq %r12, %rdi
movq %rbx, %rsi
callq *0x38(%rax)
mulsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd (%rsp), %xmm0
callq 0x6046
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%r15,%r14,8)
incq %r14
cmpq %r14, %rbp
jne 0xdb66
testb %bpl, %bpl
jle 0xdbca
movq %r13, %rdi
xorl %esi, %esi
movq 0x48(%rsp), %rdx
callq 0x2100
testb %bpl, %bpl
jle 0xdc3a
xorl %r13d, %r13d
movsbl %r13b, %eax
movl %eax, 0x8(%rsp)
xorl %ebx, %ebx
movq 0x28(%rsp), %r15
movq 0x20(%rsp), %r12
movq 0x18(%rsp), %rbp
movq 0x30(%rsp), %r14
movsd (%r12,%rbx,8), %xmm0
movsd %xmm0, (%rsp)
movq (%rbp), %rax
movsbl %bl, %edx
movq %rbp, %rdi
movq %r15, %rsi
movl 0x8(%rsp), %ecx
callq *0x30(%rax)
mulsd (%rsp), %xmm0
addsd (%r14,%r13,8), %xmm0
movsd %xmm0, (%r14,%r13,8)
incq %rbx
cmpq %rbx, 0x10(%rsp)
jne 0xdbf0
incq %r13
movq 0x10(%rsp), %rax
cmpq %rax, %r13
movq %rax, %rbp
jne 0xdbd2
movsbl %bpl, %esi
movq 0x30(%rsp), %rdi
callq 0x3d55
movq 0x70(%rsp), %rcx
incq %rcx
cmpq 0x50(%rsp), %rcx
movq 0x28(%rsp), %rbx
movq 0x20(%rsp), %r15
movq 0x18(%rsp), %r12
jne 0xda36
movq %r15, %rdi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2240