// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/hmm.c
// Function: check_hmm
int check_hmm(char* name, Hmmptr hmm)
{
 /*!Last Changed 11.04.2007*/
 int i, j;
 double sum;
 Gaussianptr g;
 Gaussianmixtureptr gm;
 int numrealfeatures = current_dataset->multifeaturecount - 1;
 printf("Checking %s. ", name);
 if (!between(hmm->hmmtype, 0, 2))
  {
   printf("Hmm type %d wrong\n", hmm->hmmtype);
   return 0;
  }
 if (!between(hmm->statetype, 0, 4))
  {
   printf("Hmm state type %d wrong\n", hmm->statetype);
   return 0;
  }
 if (hmm->statecount <= 1)
  {
   printf("Hmm state count %d must be larger than 1\n", hmm->statecount);
   return 0;
  }
 if (!(hmm->states))
  {
   printf("Hmm states not allocated\n");
   return 0;
  }
 sum = 0.0;
 for (i = 0; i < hmm->statecount; i++)
   sum += hmm->states[i].pi;
 if (!dequal(sum - 1, 0))
  {
   printf("Sum of pi %.6f is not equal to 1\n", sum);
   return 0;
  }
 for (i = 0; i < hmm->statecount; i++)
  {
   for (j = 0; j < hmm->statecount; j++)
     if (hmm->states[i].a_i_dot[j] != hmm->states[j].a_dot_j[i])
      {
       printf("Outgoing probability %.6f and incoming probability %.6f from state %d to state %d do not match\n", hmm->states[i].a_i_dot[j], hmm->states[j].a_dot_j[i], i, j);
       return 0;
      }
   sum = sum_of_list_double(hmm->states[i].a_i_dot, hmm->statecount);
   if (!dequal(sum - 1, 0))
    {
     printf("Sum of a_i_dot %.6f of state %d is not equal to 1\n", sum, i);
     return 0;
    }
   switch (hmm->statetype)
    {
     case         STATE_GAUSSIAN:g = (Gaussianptr) hmm->states[i].b;
                                 if (!(g->mean))
                                  {
                                   printf("Gaussian mean of state %d not allocated\n", i);
                                   return 0;
                                  }
                                 if (g->covariance.row != numrealfeatures || g->covariance.col != numrealfeatures)
                                  {
                                   printf("Covariance matrix dimensions %d %d of state %d is not true\n", g->covariance.row, g->covariance.col, i);
                                   return 0;
                                  }
                                 break;
     case STATE_GAUSSIAN_MIXTURE:gm = (Gaussianmixtureptr) hmm->states[i].b;
                                 if (gm->componentcount <= 0)
                                  {
                                   printf("Number of components %d must be larger than 0\n", gm->componentcount);
                                   return 0;
                                  }
                                 sum = sum_of_list_double(gm->weights, gm->componentcount);
                                 if (!dequal(sum - 1, 0))
                                  {
                                   printf("Sum of component weights %.6f must be equal to 1.0", sum);
                                   return 0;
                                  }
                                 if (!(gm->components))
                                  {
                                   printf("Gaussian components not allocated\n");
                                   return 0;
                                  }
                                 for (j = 0; i < gm->componentcount; i++)
                                  {
                                   if (!(gm->components[i].mean))
                                    {
                                     printf("Gaussian mean of mixture component %d of state %d not allocated\n", j, i);
                                     return 0;
                                    }
                                   if (gm->components[i].covariance.row != numrealfeatures || gm->components[i].covariance.col != numrealfeatures)
                                    {
                                     printf("Covariance matrix dimensions %d %d of mixture component %d of state %d is not true\n", g->covariance.row, g->covariance.col, j, i);
                                     return 0;
                                    }
                                  }
                                 break;
     default                    :break;
    }
  }
 printf("Ok...\n");
 return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq 0xcb679(%rip), %rax     # 0x105840
movq (%rax), %rax
movl 0x1c0(%rax), %eax
subl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rsi
leaq 0xaaccd(%rip), %rdi     # 0xe4eae
movb $0x0, %al
callq 0x4030
movq -0x18(%rbp), %rax
movl 0x10(%rax), %edi
xorl %esi, %esi
movl $0x2, %edx
callq 0x52600
cmpl $0x0, %eax
jne 0x3a221
movq -0x18(%rbp), %rax
movl 0x10(%rax), %esi
leaq 0xaacae(%rip), %rdi     # 0xe4ebc
movb $0x0, %al
callq 0x4030
movl $0x0, -0x4(%rbp)
jmp 0x3a6c4
movq -0x18(%rbp), %rax
movl 0xc(%rax), %edi
xorl %esi, %esi
movl $0x4, %edx
callq 0x52600
cmpl $0x0, %eax
jne 0x3a25a
movq -0x18(%rbp), %rax
movl 0xc(%rax), %esi
leaq 0xaac88(%rip), %rdi     # 0xe4ecf
movb $0x0, %al
callq 0x4030
movl $0x0, -0x4(%rbp)
jmp 0x3a6c4
movq -0x18(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jg 0x3a285
movq -0x18(%rbp), %rax
movl 0x8(%rax), %esi
leaq 0xaac76(%rip), %rdi     # 0xe4ee8
movb $0x0, %al
callq 0x4030
movl $0x0, -0x4(%rbp)
jmp 0x3a6c4
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x3a2a9
leaq 0xaac7c(%rip), %rdi     # 0xe4f12
movb $0x0, %al
callq 0x4030
movl $0x0, -0x4(%rbp)
jmp 0x3a6c4
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x3a2f0
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsd 0x10(%rax), %xmm0
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x3a2b8
movsd -0x28(%rbp), %xmm0
movsd 0xa7d1b(%rip), %xmm1    # 0xe2018
subsd %xmm1, %xmm0
xorps %xmm1, %xmm1
callq 0x526b0
cmpl $0x0, %eax
jne 0x3a32d
movsd -0x28(%rbp), %xmm0
leaq 0xaac12(%rip), %rdi     # 0xe4f2c
movb $0x1, %al
callq 0x4030
movl $0x0, -0x4(%rbp)
jmp 0x3a6c4
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x3a6af
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x3a40b
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movslq -0x20(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
ucomisd (%rax,%rcx,8), %xmm0
jne 0x3a39e
jp 0x3a39e
jmp 0x3a3fb
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movslq -0x20(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movl -0x1c(%rbp), %esi
movl -0x20(%rbp), %edx
leaq 0xaab66(%rip), %rdi     # 0xe4f4e
movb $0x2, %al
callq 0x4030
movl $0x0, -0x4(%rbp)
jmp 0x3a6c4
jmp 0x3a3fd
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x3a34b
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x50b50
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
movsd 0xa7bd9(%rip), %xmm1    # 0xe2018
subsd %xmm1, %xmm0
xorps %xmm1, %xmm1
callq 0x526b0
cmpl $0x0, %eax
jne 0x3a472
movsd -0x28(%rbp), %xmm0
movl -0x1c(%rbp), %esi
leaq 0xaab4f(%rip), %rdi     # 0xe4fae
movb $0x1, %al
callq 0x4030
movl $0x0, -0x4(%rbp)
jmp 0x3a6c4
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x40(%rbp)
subl $0x1, %eax
je 0x3a494
jmp 0x3a483
movl -0x40(%rbp), %eax
subl $0x2, %eax
je 0x3a51d
jmp 0x3a69d
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x3a4d5
movl -0x1c(%rbp), %esi
leaq 0xaab1f(%rip), %rdi     # 0xe4fe1
movb $0x0, %al
callq 0x4030
movl $0x0, -0x4(%rbp)
jmp 0x3a6c4
movq -0x30(%rbp), %rax
movl 0x8(%rax), %eax
cmpl -0x3c(%rbp), %eax
jne 0x3a4ed
movq -0x30(%rbp), %rax
movl 0xc(%rax), %eax
cmpl -0x3c(%rbp), %eax
je 0x3a518
movq -0x30(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x30(%rbp), %rax
movl 0xc(%rax), %edx
movl -0x1c(%rbp), %ecx
leaq 0xaab05(%rip), %rdi     # 0xe500a
movb $0x0, %al
callq 0x4030
movl $0x0, -0x4(%rbp)
jmp 0x3a6c4
jmp 0x3a69f
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jg 0x3a562
movq -0x38(%rbp), %rax
movl 0x8(%rax), %esi
leaq 0xaaaf7(%rip), %rdi     # 0xe5046
movb $0x0, %al
callq 0x4030
movl $0x0, -0x4(%rbp)
jmp 0x3a6c4
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x38(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x50b50
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
movsd 0xa7a90(%rip), %xmm1    # 0xe2018
subsd %xmm1, %xmm0
xorps %xmm1, %xmm1
callq 0x526b0
cmpl $0x0, %eax
jne 0x3a5b8
movsd -0x28(%rbp), %xmm0
leaq 0xaaad0(%rip), %rdi     # 0xe5075
movb $0x1, %al
callq 0x4030
movl $0x0, -0x4(%rbp)
jmp 0x3a6c4
movq -0x38(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x3a5dc
leaq 0xaaadf(%rip), %rdi     # 0xe50a8
movb $0x0, %al
callq 0x4030
movl $0x0, -0x4(%rbp)
jmp 0x3a6c4
movl $0x0, -0x20(%rbp)
movl -0x1c(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x3a69b
movq -0x38(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, (%rax)
jne 0x3a62b
movl -0x20(%rbp), %esi
movl -0x1c(%rbp), %edx
leaq 0xaaab3(%rip), %rdi     # 0xe50cb
movb $0x0, %al
callq 0x4030
movl $0x0, -0x4(%rbp)
jmp 0x3a6c4
movq -0x38(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
cmpl -0x3c(%rbp), %eax
jne 0x3a65f
movq -0x38(%rbp), %rax
movq (%rax), %rax
movslq -0x1c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
cmpl -0x3c(%rbp), %eax
je 0x3a68b
movq -0x30(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x30(%rbp), %rax
movl 0xc(%rax), %edx
movl -0x20(%rbp), %ecx
movl -0x1c(%rbp), %r8d
leaq 0xaaa91(%rip), %rdi     # 0xe510c
movb $0x0, %al
callq 0x4030
movl $0x0, -0x4(%rbp)
jmp 0x3a6c4
jmp 0x3a68d
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x3a5e3
jmp 0x3a69f
jmp 0x3a69f
jmp 0x3a6a1
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x3a334
leaq 0xaaaaa(%rip), %rdi     # 0xe5160
movb $0x0, %al
callq 0x4030
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)