// File: /workspace/github_cpp_makefile_star2_O2/myudelson[P]hmm-scalable/HMMProblemComp.cpp
// Function: HMMProblemComp::producePCorrect(double***, double*, int)
void HMMProblemComp::producePCorrect(NUMBER*** group_skill_map, NUMBER* local_pred, NDAT t) {
	NPAR m, i, l;
	NCAT k, g, nS = this->p->nS, nO = this->p->nO;
	NUMBER *a_L = init1D<NUMBER>((NDAT)nS);
	NUMBER **a_B = init2D<NUMBER>((NDAT)nS, (NDAT)nO);
	
	g = this->p->dat_group[t];
	NCAT *ks;
	int nks;
	if(this->p->multiskill==0) {
		fprintf(stderr,"WARNING! Multi-skill flag should have been set!");
		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];
	}
	
	if(nks==1) {
		for(i=0; i<nS; i++) {
			a_L[i] = group_skill_map[g][ ks[0] ][i];
			for(m=0; m<nO; m++)
				a_B[i][m] = this->B[ ks[0] ][i][m];
		}
	} else {
		NUMBER *q = NULL;
		for(i=0; i<nS; i++) {
			q = Calloc(NUMBER, (size_t)nks);
			for(l=0;l<nks;l++) q[l] = group_skill_map[g][ ks[l] ][i];
			a_L[i] = this->pu->unite(q, nks, NULL, 0); //a_L[i] = squishing(q, nks);
			free(q);

			for(m=0; m<nO; m++) {
				q = Calloc(NUMBER, (size_t)nks);
				for(l=0;l<nks;l++) q[l] = this->B[ ks[l] ][i][m];
				free(q);
				a_B[i][m] = this->pu->unite(q, nks, NULL, 0); //a_B[i][m] = squishing(q, nks);
			}
		}
	}

	for(m=0; m<this->p->nO; m++) local_pred[m] = 0.0;
	for(m=0; m<this->p->nO; m++)
		for(i=0; i<this->p->nS; i++)
			local_pred[m] += a_L[i] * a_B[i][m];
	
	free(a_L);
	free2D<NUMBER>(a_B, nS);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, %ebx
movq %rdx, %r13
movq %rsi, 0x28(%rsp)
movq %rdi, %r15
movq 0x88(%rdi), %rax
movsbl 0x8b8(%rax), %r14d
movb 0x8b9(%rax), %al
movb %al, 0x10(%rsp)
movsbl %al, %ebp
movl %r14d, %edi
callq 0x7dde
movq %rax, 0x18(%rsp)
movl %r14d, %edi
movl %ebp, %esi
callq 0x9328
movq %rax, %r12
movq %r15, 0x8(%rsp)
movq 0x88(%r15), %rax
movq 0x878(%rax), %rcx
movslq %ebx, %rbx
movslq (%rcx,%rbx,4), %rcx
movq %rcx, 0x30(%rsp)
cmpb $0x0, 0x918(%rax)
je 0x2bcdc
movq 0x898(%rax), %rcx
movslq (%rcx,%rbx,4), %rcx
movq 0x888(%rax), %rdx
movq 0x890(%rax), %rsi
leaq (%rdx,%rcx,4), %r15
movslq (%rsi,%rbx,4), %rbx
movl (%r15), %ecx
movl %ecx, 0x24(%rsp)
cmpq $0x1, %rbx
jne 0x2bb01
movb 0x10(%rsp), %dl
movzbl %dl, %esi
xorl %ecx, %ecx
testb %dl, %dl
cmovlel %ecx, %esi
testb %r14b, %r14b
movl $0x0, %edx
cmovgl %r14d, %edx
movslq %edx, %rdx
movzbl %sil, %esi
movq 0x18(%rsp), %rdi
cmpq %rdx, %rcx
je 0x2bc52
movq 0x28(%rsp), %r8
movq 0x30(%rsp), %r9
movq (%r8,%r9,8), %r8
movslq (%r15), %r11
movq (%r8,%r11,8), %r8
movsd (%r8,%rcx,8), %xmm0
movsd %xmm0, (%rdi,%rcx,8)
movq 0x8(%rsp), %r8
movq 0x48(%r8), %r8
xorl %r9d, %r9d
cmpq %r9, %rsi
je 0x2bafc
movq (%r8,%r11,8), %r10
movq (%r10,%rcx,8), %r10
movsd (%r10,%r9,8), %xmm0
movq (%r12,%rcx,8), %r10
movsd %xmm0, (%r10,%r9,8)
incq %r9
jmp 0x2bada
incq %rcx
jmp 0x2baa5
movq %r13, 0x38(%rsp)
movb 0x10(%rsp), %cl
movzbl %cl, %eax
xorl %r13d, %r13d
testb %cl, %cl
cmovlel %r13d, %eax
testb %r14b, %r14b
movl $0x0, %ecx
movl %r14d, 0x20(%rsp)
cmovgl %r14d, %ecx
movslq %ecx, %rcx
movq %rcx, 0x40(%rsp)
movzbl %al, %eax
movq %rax, 0x10(%rsp)
cmpq 0x40(%rsp), %r13
movq 0x30(%rsp), %r14
je 0x2bc37
movq %rbx, %rdi
pushq $0x8
popq %rsi
callq 0x4120
movq %rax, %rbp
xorl %eax, %eax
movq 0x28(%rsp), %rdi
movsbl %al, %ecx
cmpl %ecx, %ebx
jle 0x2bb83
movq (%rdi,%r14,8), %rcx
movsbq %al, %rdx
movslq (%r15,%rdx,4), %rsi
movq (%rcx,%rsi,8), %rcx
movsd (%rcx,%r13,8), %xmm0
movsd %xmm0, (%rbp,%rdx,8)
incb %al
jmp 0x2bb5c
movq 0x8(%rsp), %rax
movq 0x98(%rax), %rdi
movq (%rdi), %rax
movq %rbp, %rsi
movl %ebx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq *0x8(%rax)
movq 0x18(%rsp), %rax
movsd %xmm0, (%rax,%r13,8)
movq %rbp, %rdi
callq 0x4290
xorl %r14d, %r14d
cmpq 0x10(%rsp), %r14
je 0x2bc2f
movq %rbx, %rdi
pushq $0x8
popq %rsi
callq 0x4120
movq %rax, %rbp
movq 0x8(%rsp), %rax
movq 0x48(%rax), %rax
xorl %ecx, %ecx
movsbl %cl, %edx
cmpl %edx, %ebx
jle 0x2bbfc
movsbq %cl, %rdx
movslq (%r15,%rdx,4), %rsi
movq (%rax,%rsi,8), %rsi
movq (%rsi,%r13,8), %rsi
movsd (%rsi,%r14,8), %xmm0
movsd %xmm0, (%rbp,%rdx,8)
incb %cl
jmp 0x2bbd5
movq %rbp, %rdi
callq 0x4290
movq 0x8(%rsp), %rax
movq 0x98(%rax), %rdi
movq (%rdi), %rax
movq %rbp, %rsi
movl %ebx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq *0x8(%rax)
movq (%r12,%r13,8), %rax
movsd %xmm0, (%rax,%r14,8)
incq %r14
jmp 0x2bbb5
incq %r13
jmp 0x2bb37
movq 0x8(%rsp), %rax
movq 0x88(%rax), %rax
movl 0x20(%rsp), %r14d
movq 0x38(%rsp), %r13
movq 0x18(%rsp), %rdi
movzbl 0x8b9(%rax), %ecx
xorl %edx, %edx
testb %cl, %cl
cmovlel %edx, %ecx
movzbl %cl, %ecx
cmpq %rdx, %rcx
je 0x2bc73
andq $0x0, (%r13,%rdx,8)
incq %rdx
jmp 0x2bc63
xorl %edx, %edx
xorl %esi, %esi
cmpq %rcx, %rsi
je 0x2bcbe
movl 0x8b8(%rax), %r8d
testb %r8b, %r8b
cmovlel %edx, %r8d
movzbl %r8b, %r10d
xorl %r8d, %r8d
cmpq %r8, %r10
je 0x2bcb9
movsd (%rdi,%r8,8), %xmm0
movq (%r12,%r8,8), %r9
mulsd (%r9,%rsi,8), %xmm0
addsd (%r13,%rsi,8), %xmm0
movsd %xmm0, (%r13,%rsi,8)
incq %r8
jmp 0x2bc91
incq %rsi
jmp 0x2bc77
callq 0x4290
movq %r12, %rdi
movl %r14d, %esi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7f2c
movq 0xd2f5(%rip), %rax      # 0x38fd8
movq (%rax), %rcx
leaq 0x2018(%rip), %rdi      # 0x2dd05
pushq $0x2f
popq %rsi
pushq $0x1
popq %rdx
callq 0x44b0
movq 0x8(%rsp), %rax
movq 0x88(%rax), %rax
movq 0x880(%rax), %rcx
movl (%rcx,%rbx,4), %ecx
leaq 0x24(%rsp), %r15
movl %ecx, (%r15)
jmp 0x2ba7f