// File: /workspace/github_cpp_makefile_star2_O1/myudelson[P]hmm-scalable/HMMProblemSlicedA.cpp
// Function: HMMProblemSlicedA::checkPIABConstraints(double*, double***, double**)
bool HMMProblemSlicedA::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[nS];
    for(i=0; i<nS; i++) {
        for(z=0; z<nZ; z++) {
            sum_a_row[z][i] = 0.0;
        }
        sum_b_row[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
        }// all states
    } // all slices

    for(i=0; i<nS; i++) {
        for(int m=0; m<nO; m++) {
            if( a_B[i][m]>1.0 || a_B[i][m]<0.0)
                return false;
            sum_b_row[i] += a_B[i][m];
        }// all observations
    }// all states
    
    if(sum_pi!=1.0)
		return false;
    for(i=0; i<nS; i++) {
        if( sum_b_row[i]!=1.0) return false;
        for(z=0; z<nZ; z++)
            if( sum_a_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 %rcx, -0x30(%rbp)
movq 0x88(%rdi), %rax
movzbl 0x8b8(%rax), %edi
movzbl 0x8c8(%rax), %r8d
movl %r8d, %ecx
imull %edi, %ecx
leal 0xf(,%rcx,8), %ecx
andl $-0x10, %ecx
movq %rsp, %r9
subq %rcx, %r9
movq %r9, %rsp
leal 0xf(,%rdi,8), %ecx
andl $-0x10, %ecx
movq %rsp, %r10
subq %rcx, %r10
movq %r10, %rsp
testb %dil, %dil
jle 0x2bb5e
leal (,%rdi,8), %r11d
xorl %ebx, %ebx
movq %r9, %r14
movq %r8, %rcx
movq %r14, %r15
testb %r8b, %r8b
jle 0x2bb4a
movq $0x0, (%r15)
addq %r11, %r15
decq %rcx
jne 0x2bb3b
movq $0x0, (%r10,%rbx,8)
incq %rbx
addq $0x8, %r14
cmpq %rdi, %rbx
jne 0x2bb30
movsbq 0x8b9(%rax), %r11
testb %dil, %dil
jle 0x2bbb7
xorpd %xmm0, %xmm0
xorl %ebx, %ebx
movsd 0x8d77(%rip), %xmm2     # 0x348f0
xorpd %xmm1, %xmm1
movsd (%rsi,%rbx,8), %xmm3
xorl %eax, %eax
ucomisd %xmm2, %xmm3
ja 0x2bc7d
ucomisd %xmm3, %xmm0
ja 0x2bc7d
addsd %xmm3, %xmm1
incq %rbx
cmpq %rbx, %rdi
jne 0x2bb7d
cmpneqsd 0x8d43(%rip), %xmm1     # 0x348f0
movq %xmm1, %rcx
andl $0x1, %ecx
jmp 0x2bbb9
movb $0x1, %cl
testb %r8b, %r8b
jle 0x2bc26
xorl %ebx, %ebx
movsd 0x8d28(%rip), %xmm0     # 0x348f0
xorpd %xmm1, %xmm1
testb %dil, %dil
jle 0x2bc1e
movq %rbx, %rax
imulq %rdi, %rax
leaq (%r9,%rax,8), %r14
movq (%rdx,%rbx,8), %r15
xorl %r12d, %r12d
movq (%r15,%r12,8), %r13
xorl %esi, %esi
movsd (%r13,%rsi,8), %xmm2
xorl %eax, %eax
ucomisd %xmm0, %xmm2
ja 0x2bc7d
ucomisd %xmm2, %xmm1
ja 0x2bc7d
addsd (%r14,%r12,8), %xmm2
movsd %xmm2, (%r14,%r12,8)
incq %rsi
cmpq %rsi, %rdi
jne 0x2bbe9
incq %r12
cmpq %rdi, %r12
jne 0x2bbe3
incq %rbx
cmpq %r8, %rbx
jne 0x2bbcc
testb %dil, %dil
jle 0x2bc77
xorl %edx, %edx
movsd 0x8cbb(%rip), %xmm0     # 0x348f0
xorpd %xmm1, %xmm1
testb %r11b, %r11b
jle 0x2bc6f
movq -0x30(%rbp), %rax
movq (%rax,%rdx,8), %rbx
xorl %esi, %esi
movsd (%rbx,%rsi,8), %xmm2
xorl %eax, %eax
ucomisd %xmm0, %xmm2
ja 0x2bc7d
ucomisd %xmm2, %xmm1
ja 0x2bc7d
addsd (%r10,%rdx,8), %xmm2
movsd %xmm2, (%r10,%rdx,8)
incq %rsi
cmpq %rsi, %r11
jne 0x2bc48
incq %rdx
cmpq %rdi, %rdx
jne 0x2bc39
testb %cl, %cl
je 0x2bc8c
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testb %dil, %dil
jle 0x2bcef
leal (,%rdi,8), %ecx
xorl %edx, %edx
movsd 0x8c4e(%rip), %xmm0     # 0x348f0
movsd (%r10,%rdx,8), %xmm1
movapd %xmm1, %xmm2
cmpeqsd %xmm0, %xmm2
movq %xmm2, %rax
andl $0x1, %eax
ucomisd %xmm0, %xmm1
jne 0x2bc7d
jp 0x2bc7d
movq %r8, %rsi
movq %r9, %r11
testb %r8b, %r8b
jle 0x2bce1
movsd (%r11), %xmm1
ucomisd %xmm0, %xmm1
jne 0x2bc7b
jp 0x2bc7b
addq %rcx, %r11
decq %rsi
jne 0x2bccc
incq %rdx
addq $0x8, %r9
cmpq %rdi, %rdx
jne 0x2bca2
jmp 0x2bc7d
movb $0x1, %al
jmp 0x2bc7d
nop