// File: myudelson[P]hmm-scalable/HMMProblemSt.cpp
// Function: HMMProblemSt::producePCorrect(double***, int*, signed char, double*, context*)
void HMMProblemSt::producePCorrect(NUMBER*** group_skill_map, NCAT* skills, NPAR n_skills, NUMBER* local_pred, struct context *ctx) {
    NPAR m, i, nO = this->task->nO, nS = this->task->nS;
    NCAT k;
    NUMBER *local_pred_inner = init1D<NUMBER>(nO);
    for(m=0; m<nO; m++) local_pred[m] = 0.0;
    
    for(int l=0; l<n_skills; l++) {
        for(m=0; m<nO; m++) local_pred_inner[m] = 0.0;
        k = skills[l];
        ctx->k=k;
        NUMBER* group_skill_map_gk = group_skill_map[ctx->g][k];
        for(i=0; i<nS; i++) {
            if(/*group_skill_map[ctx->g][k]*/group_skill_map_gk[i]==-1) {
                /*group_skill_map[ctx->g][k]*/group_skill_map_gk[i] = getPI(ctx,i);
            }
            for(m=0; m<nO; m++)
                local_pred_inner[m] += /*group_skill_map[ctx->g][k]*/group_skill_map_gk[i] * getB(ctx,i,m);
        }
        for(m=0; m<nO; m++)
            local_pred[m] += local_pred_inner[m];
    }
    if(n_skills>1) {
        for(m=0; m<nO; m++)
            local_pred[m] /= n_skills;
    }
    projectsimplex(local_pred, nO);
    free(local_pred_inner);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movb %cl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb %al, -0x19(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq 0x68(%rax), %rcx
movb 0x901(%rcx), %cl
movb %cl, -0x33(%rbp)
movq 0x68(%rax), %rax
movb 0x900(%rax), %al
movb %al, -0x34(%rbp)
movsbl -0x33(%rbp), %edi
callq 0x9da0
movq %rax, -0x40(%rbp)
movb $0x0, -0x31(%rbp)
movsbl -0x31(%rbp), %eax
movsbl -0x33(%rbp), %ecx
cmpl %ecx, %eax
jge 0x14e8b
movq -0x28(%rbp), %rax
movsbq -0x31(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movb -0x31(%rbp), %al
addb $0x1, %al
movb %al, -0x31(%rbp)
jmp 0x14e64
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movsbl -0x19(%rbp), %ecx
cmpl %ecx, %eax
jge 0x15017
movb $0x0, -0x31(%rbp)
movsbl -0x31(%rbp), %eax
movsbl -0x33(%rbp), %ecx
cmpl %ecx, %eax
jge 0x14ecc
movq -0x40(%rbp), %rax
movsbq -0x31(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movb -0x31(%rbp), %al
addb $0x1, %al
movb %al, -0x31(%rbp)
jmp 0x14ea5
movq -0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq -0x30(%rbp), %rcx
movslq 0x4(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
movb $0x0, -0x32(%rbp)
movsbl -0x32(%rbp), %eax
movsbl -0x34(%rbp), %ecx
cmpl %ecx, %eax
jge 0x14fcc
movq -0x50(%rbp), %rax
movsbq -0x32(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x6b27(%rip), %xmm1     # 0x1ba50
ucomisd %xmm1, %xmm0
jne 0x14f53
jp 0x14f53
movq -0x58(%rbp), %rdi
movq -0x30(%rbp), %rsi
movb -0x32(%rbp), %cl
movq (%rdi), %rax
movsbl %cl, %edx
callq *0x28(%rax)
movq -0x50(%rbp), %rax
movsbq -0x32(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movb $0x0, -0x31(%rbp)
movsbl -0x31(%rbp), %eax
movsbl -0x33(%rbp), %ecx
cmpl %ecx, %eax
jge 0x14fbd
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rax
movsbq -0x32(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x60(%rbp)
movq -0x30(%rbp), %rsi
movb -0x32(%rbp), %dl
movb -0x31(%rbp), %cl
movq (%rdi), %rax
movsbl %dl, %edx
movsbl %cl, %ecx
callq *0x38(%rax)
movaps %xmm0, %xmm2
movsd -0x60(%rbp), %xmm0
movq -0x40(%rbp), %rax
movsbq -0x31(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movb -0x31(%rbp), %al
addb $0x1, %al
movb %al, -0x31(%rbp)
jmp 0x14f57
jmp 0x14fbf
movb -0x32(%rbp), %al
addb $0x1, %al
movb %al, -0x32(%rbp)
jmp 0x14f03
movb $0x0, -0x31(%rbp)
movsbl -0x31(%rbp), %eax
movsbl -0x33(%rbp), %ecx
cmpl %ecx, %eax
jge 0x15007
movq -0x40(%rbp), %rax
movsbq -0x31(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movsbq -0x31(%rbp), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movb -0x31(%rbp), %al
addb $0x1, %al
movb %al, -0x31(%rbp)
jmp 0x14fd0
jmp 0x15009
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x14e92
movsbl -0x19(%rbp), %eax
cmpl $0x1, %eax
jle 0x1505b
movb $0x0, -0x31(%rbp)
movsbl -0x31(%rbp), %eax
movsbl -0x33(%rbp), %ecx
cmpl %ecx, %eax
jge 0x15059
movsbl -0x19(%rbp), %eax
cvtsi2sd %eax, %xmm1
movq -0x28(%rbp), %rax
movsbq -0x31(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movb -0x31(%rbp), %al
addb $0x1, %al
movb %al, -0x31(%rbp)
jmp 0x15024
jmp 0x1505b
movq -0x28(%rbp), %rdi
movsbl -0x33(%rbp), %esi
callq 0x5560
movq -0x40(%rbp), %rdi
callq 0x3320
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)