// File: /workspace/github_cpp_makefile_star2_O1/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 $0x58, %rsp
movl %ecx, %ebx
movq %rdx, 0x50(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdi, %r13
leaq 0x88(%rdi), %rbp
movq 0x88(%rdi), %rax
movsbq 0x8b8(%rax), %r14
movsbl 0x8b9(%rax), %r15d
movzbl %r15b, %eax
movq %rax, 0x20(%rsp)
movl $0x8, %esi
movq %r14, %rdi
callq 0x4130
movq %rax, 0x18(%rsp)
movq %r14, 0x8(%rsp)
movl %r14d, %edi
movl %r15d, %esi
callq 0xbb5c
movq %rax, %r12
movq %r13, 0x10(%rsp)
movq 0x88(%r13), %rax
movq 0x878(%rax), %rcx
movslq %ebx, %rsi
movslq (%rcx,%rsi,4), %rcx
movq %rcx, 0x30(%rsp)
cmpb $0x0, 0x918(%rax)
je 0x330a2
movq 0x888(%rax), %rcx
movq 0x898(%rax), %rdx
movslq (%rdx,%rsi,4), %rdx
leaq (%rcx,%rdx,4), %r13
movl (%r13), %ecx
movl %ecx, 0x2c(%rsp)
movq 0x890(%rax), %rax
movl (%rax,%rsi,4), %ebx
movq %rbp, 0x48(%rsp)
cmpl $0x1, %ebx
movq 0x20(%rsp), %r11
jne 0x32eea
cmpb $0x0, 0x8(%rsp)
jle 0x3300f
movq 0x38(%rsp), %rax
movq 0x30(%rsp), %rcx
movq (%rax,%rcx,8), %rcx
movslq (%r13), %rax
movq (%rcx,%rax,8), %rcx
movq 0x10(%rsp), %rdx
movq 0x48(%rdx), %rdx
movslq 0x8(%rsp), %rsi
xorl %edi, %edi
movsd (%rcx,%rdi,8), %xmm0
movq 0x18(%rsp), %r8
movsd %xmm0, (%r8,%rdi,8)
testb %r11b, %r11b
jle 0x32edd
movq (%rdx,%rax,8), %r8
movq (%r8,%rdi,8), %r8
movq (%r12,%rdi,8), %r9
xorl %r10d, %r10d
movsd (%r8,%r10,8), %xmm0
movsd %xmm0, (%r9,%r10,8)
incq %r10
cmpq %r10, %r11
jne 0x32ec9
incq %rdi
cmpq %rsi, %rdi
jne 0x32ea5
jmp 0x3300f
cmpb $0x0, 0x8(%rsp)
jle 0x3300f
movslq %ebx, %rax
movq %rax, 0x40(%rsp)
xorl %ebp, %ebp
movl $0x8, %esi
movq 0x40(%rsp), %rdi
callq 0x4130
movq %rax, %r15
testl %ebx, %ebx
jle 0x32f46
movq 0x38(%rsp), %rax
movq 0x30(%rsp), %rcx
movq (%rax,%rcx,8), %rax
xorl %ecx, %ecx
movsbq %cl, %rcx
movslq (%r13,%rcx,4), %rdx
movq (%rax,%rdx,8), %rdx
movsd (%rdx,%rbp,8), %xmm0
movsd %xmm0, (%r15,%rcx,8)
incb %cl
movsbl %cl, %edx
cmpl %edx, %ebx
jg 0x32f25
movq 0x10(%rsp), %rax
movq 0x98(%rax), %rdi
movq (%rdi), %rax
movq %r15, %rsi
movl %ebx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq *0x8(%rax)
movq 0x18(%rsp), %rax
movsd %xmm0, (%rax,%rbp,8)
movq %r15, %rdi
callq 0x42a0
cmpb $0x0, 0x20(%rsp)
jle 0x33001
xorl %r14d, %r14d
movl $0x8, %esi
movq 0x40(%rsp), %rdi
callq 0x4130
movq %rax, %r15
testl %ebx, %ebx
jle 0x32fc9
movq 0x10(%rsp), %rax
movq 0x48(%rax), %rax
xorl %ecx, %ecx
movsbq %cl, %rcx
movslq (%r13,%rcx,4), %rdx
movq (%rax,%rdx,8), %rdx
movq (%rdx,%rbp,8), %rdx
movsd (%rdx,%r14,8), %xmm0
movsd %xmm0, (%r15,%rcx,8)
incb %cl
movsbl %cl, %edx
cmpl %edx, %ebx
jg 0x32fa3
movq %r15, %rdi
callq 0x42a0
movq 0x10(%rsp), %rax
movq 0x98(%rax), %rdi
movq (%rdi), %rax
movq %r15, %rsi
movl %ebx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq *0x8(%rax)
movq (%r12,%rbp,8), %rax
movsd %xmm0, (%rax,%r14,8)
incq %r14
cmpq 0x20(%rsp), %r14
jne 0x32f82
incq %rbp
cmpq 0x8(%rsp), %rbp
jne 0x32eff
movq 0x48(%rsp), %rax
movq (%rax), %r14
movsbq 0x8b9(%r14), %rbx
testq %rbx, %rbx
movq 0x50(%rsp), %r15
jle 0x3303b
leaq (,%rbx,8), %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x4120
testb %bl, %bl
movq 0x18(%rsp), %rdi
jle 0x33082
movzbl 0x8b8(%r14), %eax
xorl %ecx, %ecx
testb %al, %al
jle 0x3307a
movsd (%r15,%rcx,8), %xmm0
xorl %edx, %edx
movsd (%rdi,%rdx,8), %xmm1
movq (%r12,%rdx,8), %rsi
mulsd (%rsi,%rcx,8), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, (%r15,%rcx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x3305a
incq %rcx
cmpq %rbx, %rcx
jne 0x3304e
callq 0x42a0
movq %r12, %rdi
movq 0x8(%rsp), %rsi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa5e0
leaq 0x2c(%rsp), %r13
movq %rbp, %rdi
movq %r13, %rdx
callq 0x56a3
movl $0x1, %ebx
jmp 0x32e65