// File: /workspace/github_cpp_makefile_star2_O3/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, 0x40(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdi, %r15
movq 0x88(%rdi), %rax
movsbq 0x8b8(%rax), %r14
movsbl 0x8b9(%rax), %ebp
movzbl %bpl, %eax
movq %rax, 0x18(%rsp)
movl $0x8, %esi
movq %r14, %rdi
callq 0x4130
movq %rax, 0x10(%rsp)
movl %r14d, %edi
movl %ebp, %esi
callq 0xbb36
movq %rax, %r12
movq %r15, 0x8(%rsp)
movq 0x88(%r15), %r13
movq 0x878(%r13), %rax
movslq %ebx, %rbx
movslq (%rax,%rbx,4), %rax
movq %rax, 0x28(%rsp)
cmpb $0x0, 0x918(%r13)
movq %r14, 0x38(%rsp)
je 0x32b82
movq 0x898(%r13), %rax
movslq (%rax,%rbx,4), %rax
movq 0x888(%r13), %rcx
movq 0x890(%r13), %rdx
leaq (%rcx,%rax,4), %r15
movslq (%rdx,%rbx,4), %rbp
movl (%r15), %eax
movl %eax, 0x24(%rsp)
cmpq $0x1, %rbp
jne 0x329d4
testb %r14b, %r14b
movq 0x10(%rsp), %r11
jle 0x32af5
movq 0x30(%rsp), %rax
movq 0x28(%rsp), %rcx
movq (%rax,%rcx,8), %rcx
movslq (%r15), %rax
movq (%rcx,%rax,8), %rcx
movq 0x8(%rsp), %rdx
movq 0x48(%rdx), %rdx
movslq %r14d, %rsi
xorl %edi, %edi
movq 0x18(%rsp), %rbx
movsd (%rcx,%rdi,8), %xmm0
movsd %xmm0, (%r11,%rdi,8)
testb %bl, %bl
jle 0x329c7
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, %rbx
jne 0x329b3
incq %rdi
cmpq %rsi, %rdi
jne 0x32995
jmp 0x32af5
testb %r14b, %r14b
jle 0x32af5
xorl %r13d, %r13d
movl $0x8, %esi
movq %rbp, %rdi
callq 0x4130
movq %rax, %rbx
testl %ebp, %ebp
movq 0x18(%rsp), %r14
jle 0x32a29
movq 0x30(%rsp), %rax
movq 0x28(%rsp), %rcx
movq (%rax,%rcx,8), %rax
xorl %ecx, %ecx
movsbq %cl, %rcx
movslq (%r15,%rcx,4), %rdx
movq (%rax,%rdx,8), %rdx
movsd (%rdx,%r13,8), %xmm0
movsd %xmm0, (%rbx,%rcx,8)
incb %cl
movsbl %cl, %edx
cmpl %edx, %ebp
jg 0x32a09
movq 0x8(%rsp), %rax
movq 0x98(%rax), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movl %ebp, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq *0x8(%rax)
movq 0x10(%rsp), %rax
movsd %xmm0, (%rax,%r13,8)
movq %rbx, %rdi
callq 0x42a0
testb %r14b, %r14b
jle 0x32adb
xorl %r14d, %r14d
movl $0x8, %esi
movq %rbp, %rdi
callq 0x4130
movq %rax, %rbx
testl %ebp, %ebp
jle 0x32aa3
movq 0x8(%rsp), %rax
movq 0x48(%rax), %rax
xorl %ecx, %ecx
movsbq %cl, %rcx
movslq (%r15,%rcx,4), %rdx
movq (%rax,%rdx,8), %rdx
movq (%rdx,%r13,8), %rdx
movsd (%rdx,%r14,8), %xmm0
movsd %xmm0, (%rbx,%rcx,8)
incb %cl
movsbl %cl, %edx
cmpl %edx, %ebp
jg 0x32a7f
movq %rbx, %rdi
callq 0x42a0
movq 0x8(%rsp), %rax
movq 0x98(%rax), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movl %ebp, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq *0x8(%rax)
movq (%r12,%r13,8), %rax
movsd %xmm0, (%rax,%r14,8)
incq %r14
cmpq 0x18(%rsp), %r14
jne 0x32a60
incq %r13
cmpq 0x38(%rsp), %r13
jne 0x329e0
movq 0x8(%rsp), %rax
movq 0x88(%rax), %r13
movsbq 0x8b9(%r13), %rbx
testq %rbx, %rbx
movq 0x40(%rsp), %r15
movq 0x10(%rsp), %rbp
jle 0x32b5f
leaq (,%rbx,8), %rdx
xorl %r14d, %r14d
movq %r15, %rdi
xorl %esi, %esi
callq 0x4120
movzbl 0x8b8(%r13), %eax
testb %al, %al
jle 0x32b57
movsd (%r15,%r14,8), %xmm0
xorl %ecx, %ecx
movsd (%rbp,%rcx,8), %xmm1
movq (%r12,%rcx,8), %rdx
mulsd (%rdx,%r14,8), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, (%r15,%r14,8)
incq %rcx
cmpq %rcx, %rax
jne 0x32b35
incq %r14
cmpq %rbx, %r14
jne 0x32b29
movq %rbp, %rdi
callq 0x42a0
movq %r12, %rdi
movq 0x38(%rsp), %rsi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xa5dd
movq 0xc44f(%rip), %rax      # 0x3efd8
movq (%rax), %rcx
leaq 0x21b2(%rip), %rdi      # 0x34d45
movl $0x2f, %esi
movl $0x1, %edx
callq 0x4480
movq 0x8(%rsp), %rax
movq 0x88(%rax), %r13
movq 0x880(%r13), %rax
movl (%rax,%rbx,4), %eax
leaq 0x24(%rsp), %r15
movl %eax, (%r15)
jmp 0x3295f