// File: /workspace/github_cpp_makefile_star2_O2/myudelson[P]hmm-scalable/HMMProblemSlicedAB.cpp
// Function: HMMProblemSlicedAB::checkPIABConstraints(double*, double***, double***)
bool HMMProblemSlicedAB::checkPIABConstraints(NUMBER* a_PI, NUMBER*** a_A, NUMBER*** a_B) {
	NPAR i, j, z;
    NPAR nS = this->p->nS, nO = this->p->nO, nZ = this->p->nZ;
	// check values
	NUMBER sum_pi = 0.0;
	NUMBER sum_a_row[nZ][nS];
	NUMBER sum_b_row[nZ][nS];
    for(z=0; z<nZ; z++) {
        for(i=0; i<nS; i++) {
            sum_a_row[z][i] = 0.0;
            sum_b_row[z][i] = 0.0;
        }
    }
	for(i=0; i<nS; i++) {
		if( a_PI[i]>1.0 || a_PI[i]<0.0)
			return false;
		sum_pi += a_PI[i];
    }
    
    for(z=0; z<nZ; z++) {
        for(i=0; i<nS; i++) {
            for(j=0; j<nS; j++) {
                if( a_A[z][i][j]>1.0 || a_A[z][i][j]<0.0)
                    return false;
                sum_a_row[z][i] += a_A[z][i][j];
            }// all states 2
            for(int m=0; m<nO; m++) {
                if( a_B[z][i][m]>1.0 || a_B[z][i][m]<0.0)
                    return false;
                sum_b_row[z][i] += a_B[z][i][m];
            }// all observations
        }// all states
    } // all slices
	if(sum_pi!=1.0)
		return false;
    for(z=0; z<nZ; z++) {
        for(i=0; i<nS; i++) {
            if( sum_a_row[z][i]!=1.0 || sum_b_row[z][i]!=1.0) {
                return false;
            }
        }
    }
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x88(%rdi), %rax
movzbl 0x8b8(%rax), %r11d
movb 0x8b9(%rax), %bl
movzbl 0x8c8(%rax), %edi
movl %edi, %eax
imull %r11d, %eax
leal 0xf(,%rax,8), %eax
andl $-0x10, %eax
movq %rsp, %r8
subq %rax, %r8
movq %r8, %rsp
movq %rsp, %r9
subq %rax, %r9
movq %r9, %rsp
xorl %eax, %eax
testb %r11b, %r11b
movl $0x0, %r10d
cmovgl %r11d, %r10d
testb %dil, %dil
cmovlel %eax, %edi
movl %r11d, %r14d
shll $0x3, %r14d
movq %r8, %r15
movq %r9, %r12
cmpq %rdi, %rax
je 0x1fc53
xorl %r13d, %r13d
cmpq %r13, %r10
je 0x1fc48
andq $0x0, (%r15,%r13,8)
andq $0x0, (%r12,%r13,8)
incq %r13
jmp 0x1fc34
incq %rax
addq %r14, %r12
addq %r14, %r15
jmp 0x1fc2c
xorpd %xmm2, %xmm2
xorl %r14d, %r14d
movsd 0xcc8e(%rip), %xmm0     # 0x2c8f0
xorpd %xmm1, %xmm1
xorl %eax, %eax
cmpq %r14, %r10
je 0x1fc90
movsd (%rsi,%r14,8), %xmm3
ucomisd %xmm0, %xmm3
ja 0x1fd46
ucomisd %xmm3, %xmm2
ja 0x1fd46
addsd %xmm3, %xmm1
incq %r14
jmp 0x1fc68
movzbl %bl, %eax
xorl %esi, %esi
testb %al, %al
cmovlel %esi, %eax
movzbl %al, %ebx
xorpd %xmm2, %xmm2
cmpq %rdi, %rsi
je 0x1fd38
movq %rsi, %rax
imulq %r11, %rax
leaq (%r8,%rax,8), %r14
leaq (%r9,%rax,8), %r15
xorl %r12d, %r12d
cmpq %r10, %r12
je 0x1fd30
xorl %r13d, %r13d
cmpq %r13, %r11
je 0x1fcf6
movq (%rdx,%rsi,8), %rax
movq (%rax,%r12,8), %rax
movsd (%rax,%r13,8), %xmm3
xorl %eax, %eax
ucomisd %xmm0, %xmm3
ja 0x1fd46
ucomisd %xmm3, %xmm2
ja 0x1fd46
addsd (%r14,%r12,8), %xmm3
movsd %xmm3, (%r14,%r12,8)
incq %r13
jmp 0x1fcc4
xorl %r13d, %r13d
cmpq %r13, %rbx
je 0x1fd2b
movq (%rcx,%rsi,8), %rax
movq (%rax,%r12,8), %rax
movsd (%rax,%r13,8), %xmm3
xorl %eax, %eax
ucomisd %xmm0, %xmm3
ja 0x1fd46
ucomisd %xmm3, %xmm2
ja 0x1fd46
addsd (%r15,%r12,8), %xmm3
movsd %xmm3, (%r15,%r12,8)
incq %r13
jmp 0x1fcf9
incq %r12
jmp 0x1fcbc
incq %rsi
jmp 0x1fca1
ucomisd 0xcbb0(%rip), %xmm1     # 0x2c8f0
jne 0x1fd44
jnp 0x1fd55
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leal (,%r11,8), %ecx
xorl %edx, %edx
xorl %eax, %eax
cmpq %rdi, %rdx
je 0x1fd99
xorl %esi, %esi
cmpq %rsi, %r10
je 0x1fd8e
movsd (%r8,%rsi,8), %xmm1
ucomisd %xmm0, %xmm1
jne 0x1fd44
jp 0x1fd44
movsd (%r9,%rsi,8), %xmm1
incq %rsi
ucomisd %xmm0, %xmm1
jne 0x1fd46
jnp 0x1fd68
jmp 0x1fd46
incq %rdx
addq %rcx, %r9
addq %rcx, %r8
jmp 0x1fd61
movb $0x1, %al
jmp 0x1fd46
nop