// File: myudelson[P]hmm-scalable/HMMProblemComp.cpp
// Function: HMMProblemComp::getA(data*, signed char, signed char)
NUMBER HMMProblemComp::getA(struct data* dt, NPAR i, NPAR j) {
	NUMBER r = 0;
	// dt->cnt==0 means, get dt->k'th skill only
	// if param->tag1==1, try and see whether there are other "neighbours"
	// dt->t should be set to the global index of the row in question
	if( this->p->tag1==0 || this->is_multi[dt->k] == 0) { // we ask for single skill specifically or this skill is never multiskill
		r = this->A[dt->k][i][j];
	} else {
		NCAT n_skills = this->p->dat_skill_rcount[ dt->t ];
		if( n_skills==1 ) { // this skill is alone on row dt->t
			r = this->A[dt->k][i][j];
		} else { // collect multiple \pi[i]
			NUMBER* q = Calloc(NUMBER, (size_t)n_skills );
			NCAT k=0;
			for(NCAT l=0; l<n_skills; l++) {
				k = this->p->dat_skill_stacked[ this->p->dat_skill_rix[ dt->t ]+l ];
				q[l] = this->A[k][i][j];
			}
			r = this->pu->unite(q, n_skills, NULL, 0); //r = squishing(q, n_skills);
			free(q);
		} // definitely multiskill
	} // end sometimes multiskill
	return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %cl, %al
movb %dl, %cl
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb %cl, -0x11(%rbp)
movb %al, -0x12(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x20(%rbp)
movq 0x88(%rax), %rax
cmpl $0x0, 0x9a0(%rax)
je 0x4c336
movq -0x40(%rbp), %rax
movq 0x90(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x58(%rcx), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x4c367
movq -0x40(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x58(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x4c481
movq -0x40(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x890(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x8(%rcx), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x24(%rbp)
cmpl $0x1, -0x24(%rbp)
jne 0x4c3be
movq -0x40(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x58(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x4c47f
movslq -0x24(%rbp), %rdi
movl $0x8, %esi
callq 0x5180
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x4c454
movq -0x40(%rbp), %rax
movq 0x88(%rax), %rcx
movq 0x888(%rcx), %rcx
movq 0x88(%rax), %rdx
movq 0x898(%rdx), %rdx
movq -0x10(%rbp), %rsi
movslq 0x8(%rsi), %rsi
movl (%rdx,%rsi,4), %edx
addl -0x38(%rbp), %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x34(%rbp)
movq 0x40(%rax), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x11(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbq -0x12(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x4c3de
movq -0x40(%rbp), %rax
movq 0x98(%rax), %rdi
movq -0x30(%rbp), %rsi
movl -0x24(%rbp), %edx
movq (%rdi), %rax
xorl %ecx, %ecx
xorl %r8d, %r8d
callq *0x8(%rax)
movsd %xmm0, -0x20(%rbp)
movq -0x30(%rbp), %rdi
callq 0x5380
jmp 0x4c481
movsd -0x20(%rbp), %xmm0
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)