// File: myudelson[P]hmm-scalable/HMMProblem.cpp
// Function: HMMProblem::producePCorrect(double***, double*, int)
void HMMProblem::producePCorrect(NUMBER*** group_skill_map, NUMBER* local_pred, NDAT t) {
    NPAR m, i;
    NCAT k;
    NUMBER *local_pred_inner = init1D<NUMBER>(this->p->nO);
    char f_multiskill = this->p->multiskill;
    
    struct data* dt = new struct data;
    NCAT *ks;
    int nks;
    if(f_multiskill==0) {
        k = this->p->dat_skill[t];
        ks = &k;
        nks = 1;
    } else {
        NDAT rix = this->p->dat_skill_rix[t];
        k = this->p->dat_skill_stacked[ rix ];
        ks = &this->p->dat_skill_stacked[ rix ];
        nks = this->p->dat_skill_rcount[t];
    }
    
    dt->g = this->p->dat_group[t];
    dt->t = t; // statefulness
    for(m=0; m<this->p->nO; m++) local_pred[m] = 0.0;
    for(int l=0; l<nks; l++) {
        for(m=0; m<this->p->nO; m++) local_pred_inner[m] = 0.0;
        k = ks[l];
        dt->k = k;
        for(m=0; m<this->p->nO; m++)
            for(i=0; i<this->p->nS; i++)
                local_pred_inner[m] += group_skill_map[dt->g][k][i] * getB(dt,i,m);
        for(m=0; m<this->p->nO; m++)
            local_pred[m] += local_pred_inner[m];
    }
    if(nks>1) {
        for(m=0; m<this->p->nO; m++)
            local_pred[m] /= nks;
    }
    
    delete(dt);
//    NUMBER sum=0;
//    for(m=0; m<this->p->nO; m++)
//        sum+=local_pred[m];
//    if( fabs(sum-1)>SAFETY ) {
//        int a = 0;
//    }
    
    free(local_pred_inner);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq 0x88(%rax), %rax
movsbl 0x8b9(%rax), %edi
callq 0xc410
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq %rcx, -0x30(%rbp)
movq 0x88(%rax), %rax
movb 0x918(%rax), %al
movb %al, -0x31(%rbp)
movl $0x60, %edi
callq 0x52d0
movq %rax, -0x40(%rbp)
movsbl -0x31(%rbp), %eax
cmpl $0x0, %eax
jne 0x1d0c1
movq -0x60(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x880(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x24(%rbp)
leaq -0x24(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x1, -0x4c(%rbp)
jmp 0x1d12a
movq -0x60(%rbp), %rax
movq 0x88(%rax), %rcx
movq 0x898(%rcx), %rcx
movslq -0x1c(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x50(%rbp)
movq 0x88(%rax), %rcx
movq 0x888(%rcx), %rcx
movslq -0x50(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x24(%rbp)
movq 0x88(%rax), %rcx
movq 0x888(%rcx), %rcx
movslq -0x50(%rbp), %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
movq %rcx, -0x48(%rbp)
movq 0x88(%rax), %rax
movq 0x890(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x4c(%rbp)
movq -0x60(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x878(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x5c(%rax)
movl -0x1c(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movb $0x0, -0x1d(%rbp)
movq -0x60(%rbp), %rcx
movsbl -0x1d(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
cmpl %ecx, %eax
jge 0x1d18d
movq -0x18(%rbp), %rax
movsbq -0x1d(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movb -0x1d(%rbp), %al
addb $0x1, %al
movb %al, -0x1d(%rbp)
jmp 0x1d158
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x1d30a
movb $0x0, -0x1d(%rbp)
movq -0x60(%rbp), %rcx
movsbl -0x1d(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
cmpl %ecx, %eax
jge 0x1d1d9
movq -0x30(%rbp), %rax
movsbq -0x1d(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movb -0x1d(%rbp), %al
addb $0x1, %al
movb %al, -0x1d(%rbp)
jmp 0x1d1a4
movq -0x48(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x58(%rax)
movb $0x0, -0x1d(%rbp)
movq -0x60(%rbp), %rcx
movsbl -0x1d(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
cmpl %ecx, %eax
jge 0x1d2b1
movb $0x0, -0x1e(%rbp)
movq -0x60(%rbp), %rcx
movsbl -0x1e(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x1d2a2
movq -0x60(%rbp), %rdi
movq -0x10(%rbp), %rax
movq -0x40(%rbp), %rcx
movslq 0x5c(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x1e(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0x40(%rbp), %rsi
movb -0x1e(%rbp), %dl
movb -0x1d(%rbp), %cl
movq (%rdi), %rax
movsbl %dl, %edx
movsbl %cl, %ecx
callq *0x20(%rax)
movaps %xmm0, %xmm2
movsd -0x68(%rbp), %xmm0
movq -0x30(%rbp), %rax
movsbq -0x1d(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movb -0x1e(%rbp), %al
addb $0x1, %al
movb %al, -0x1e(%rbp)
jmp 0x1d217
jmp 0x1d2a4
movb -0x1d(%rbp), %al
addb $0x1, %al
movb %al, -0x1d(%rbp)
jmp 0x1d1f5
movb $0x0, -0x1d(%rbp)
movq -0x60(%rbp), %rcx
movsbl -0x1d(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
cmpl %ecx, %eax
jge 0x1d2fa
movq -0x30(%rbp), %rax
movsbq -0x1d(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x18(%rbp), %rax
movsbq -0x1d(%rbp), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movb -0x1d(%rbp), %al
addb $0x1, %al
movb %al, -0x1d(%rbp)
jmp 0x1d2b5
jmp 0x1d2fc
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x1d194
cmpl $0x1, -0x4c(%rbp)
jle 0x1d356
movb $0x0, -0x1d(%rbp)
movq -0x60(%rbp), %rcx
movsbl -0x1d(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
cmpl %ecx, %eax
jge 0x1d354
cvtsi2sdl -0x4c(%rbp), %xmm1
movq -0x18(%rbp), %rax
movsbq -0x1d(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movb -0x1d(%rbp), %al
addb $0x1, %al
movb %al, -0x1d(%rbp)
jmp 0x1d314
jmp 0x1d356
movq -0x40(%rbp), %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, %rax
je 0x1d372
movq -0x70(%rbp), %rdi
movl $0x60, %esi
callq 0x52e0
movq -0x30(%rbp), %rdi
callq 0x5380
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)