// File: 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
movq %rsp, %rbp
subq $0x60, %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), %rcx
movsbl 0x8b8(%rcx), %ecx
movl %ecx, -0x2c(%rbp)
movq 0x88(%rax), %rax
movsbl 0x8b9(%rax), %eax
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %edi
callq 0xc410
movq %rax, -0x38(%rbp)
movl -0x2c(%rbp), %edi
movl -0x30(%rbp), %esi
callq 0xf580
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq %rcx, -0x40(%rbp)
movq 0x88(%rax), %rcx
movq 0x878(%rcx), %rcx
movslq -0x1c(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x28(%rbp)
movq 0x88(%rax), %rax
movsbl 0x918(%rax), %eax
cmpl $0x0, %eax
jne 0x4e4d3
movq 0xcb43(%rip), %rax      # 0x5afd8
movq (%rax), %rdi
leaq 0x289a(%rip), %rsi      # 0x50d39
movb $0x0, %al
callq 0x5440
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 0x4e53c
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)
cmpl $0x1, -0x4c(%rbp)
jne 0x4e5ee
movb $0x0, -0x1e(%rbp)
movsbl -0x1e(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x4e5e9
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x48(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x1e(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x38(%rbp), %rax
movsbq -0x1e(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movb $0x0, -0x1d(%rbp)
movsbl -0x1d(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x4e5da
movq -0x60(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x48(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x1e(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x1d(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x40(%rbp), %rax
movsbq -0x1e(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x1d(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movb -0x1d(%rbp), %al
addb $0x1, %al
movb %al, -0x1d(%rbp)
jmp 0x4e58a
jmp 0x4e5dc
movb -0x1e(%rbp), %al
addb $0x1, %al
movb %al, -0x1e(%rbp)
jmp 0x4e54a
jmp 0x4e768
movq $0x0, -0x58(%rbp)
movb $0x0, -0x1e(%rbp)
movsbl -0x1e(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x4e766
movslq -0x4c(%rbp), %rdi
movl $0x8, %esi
callq 0x5180
movq %rax, -0x58(%rbp)
movb $0x0, -0x1f(%rbp)
movsbl -0x1f(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x4e665
movq -0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x48(%rbp), %rcx
movsbq -0x1f(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x1e(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x58(%rbp), %rax
movsbq -0x1f(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movb -0x1f(%rbp), %al
addb $0x1, %al
movb %al, -0x1f(%rbp)
jmp 0x4e61d
movq -0x60(%rbp), %rax
movq 0x98(%rax), %rdi
movq -0x58(%rbp), %rsi
movl -0x4c(%rbp), %edx
movq (%rdi), %rax
xorl %ecx, %ecx
xorl %r8d, %r8d
callq *0x8(%rax)
movq -0x38(%rbp), %rax
movsbq -0x1e(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x58(%rbp), %rdi
callq 0x5380
movb $0x0, -0x1d(%rbp)
movsbl -0x1d(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x4e757
movslq -0x4c(%rbp), %rdi
movl $0x8, %esi
callq 0x5180
movq %rax, -0x58(%rbp)
movb $0x0, -0x1f(%rbp)
movsbl -0x1f(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x4e70d
movq -0x60(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x48(%rbp), %rcx
movsbq -0x1f(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x1e(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x1d(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x58(%rbp), %rax
movsbq -0x1f(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movb -0x1f(%rbp), %al
addb $0x1, %al
movb %al, -0x1f(%rbp)
jmp 0x4e6c0
movq -0x58(%rbp), %rdi
callq 0x5380
movq -0x60(%rbp), %rax
movq 0x98(%rax), %rdi
movq -0x58(%rbp), %rsi
movl -0x4c(%rbp), %edx
movq (%rdi), %rax
xorl %ecx, %ecx
xorl %r8d, %r8d
callq *0x8(%rax)
movq -0x40(%rbp), %rax
movsbq -0x1e(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x1d(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movb -0x1d(%rbp), %al
addb $0x1, %al
movb %al, -0x1d(%rbp)
jmp 0x4e69d
jmp 0x4e759
movb -0x1e(%rbp), %al
addb $0x1, %al
movb %al, -0x1e(%rbp)
jmp 0x4e5fa
jmp 0x4e768
movb $0x0, -0x1d(%rbp)
movq -0x60(%rbp), %rcx
movsbl -0x1d(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
cmpl %ecx, %eax
jge 0x4e7a1
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 0x4e76c
movb $0x0, -0x1d(%rbp)
movq -0x60(%rbp), %rcx
movsbl -0x1d(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b9(%rcx), %ecx
cmpl %ecx, %eax
jge 0x4e836
movb $0x0, -0x1e(%rbp)
movq -0x60(%rbp), %rcx
movsbl -0x1e(%rbp), %eax
movq 0x88(%rcx), %rcx
movsbl 0x8b8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x4e827
movq -0x38(%rbp), %rax
movsbq -0x1e(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x40(%rbp), %rax
movsbq -0x1e(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x1d(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq -0x18(%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 0x4e7c3
jmp 0x4e829
movb -0x1d(%rbp), %al
addb $0x1, %al
movb %al, -0x1d(%rbp)
jmp 0x4e7a5
movq -0x38(%rbp), %rdi
callq 0x5380
movq -0x40(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0xc7f0
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)