// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/hmm.c
// Function: complexity_of_hmm
int complexity_of_hmm(Hmmptr hmm)
{
 /*!Last Changed 02.04.2007*/
 int complexity = 0, statecomplexity, numrealfeatures, componentcount, i;
 complexity += hmm->statecount; /*pi*/
 switch (hmm->hmmtype) /*a_dot_j and a_i_dot*/
  {
   case    FULL_MODEL:complexity += hmm->statecount * hmm->statecount;
                      break;
   case      LR_MODEL:complexity += 2 * hmm->statecount - 1;
                      break;
   case LR_LOOP_MODEL:complexity += 2 * hmm->statecount;
                      break;
  }
 numrealfeatures = current_dataset->multifeaturecount - 1;
 switch (hmm->statetype)
  {
   case          STATE_DISCRETE:statecomplexity = 0;
                                for (i = 0; i < current_dataset->featurecount; i++) /*prob*/
                                  if (current_dataset->features[i].type == STRING)
                                    statecomplexity += current_dataset->features[i].valuecount;
                                complexity += statecomplexity * hmm->statecount;
                                break;
   case          STATE_GAUSSIAN:complexity += (numrealfeatures + numrealfeatures * numrealfeatures) * hmm->statecount; /*mean and covariance*/
                                break;
   case  STATE_GAUSSIAN_MIXTURE:for (i = 0; i < hmm->statecount; i++)
                                 {
                                  componentcount = ((Gaussianmixtureptr) hmm->states[i].b)->componentcount;
                                  complexity += componentcount * (numrealfeatures + numrealfeatures * numrealfeatures); /*mean and covariance*/
                                 }
                                break;
   case         STATE_DIRICHLET:complexity += numrealfeatures * hmm->statecount; /*alpha*/
                                break;
   case STATE_DIRICHLET_MIXTURE:for (i = 0; i < hmm->statecount; i++)
                                 {
                                  componentcount = ((Dirichletmixtureptr) hmm->states[i].b)->componentcount;
                                  complexity += componentcount * numrealfeatures; /*alpha*/
                                 }
                                break;
  }
 return complexity;
}

// Assembly:
movl 0x8(%rdi), %ecx
movl 0x10(%rdi), %edx
cmpl $0x2, %edx
je 0x244dd
cmpl $0x1, %edx
je 0x244d6
movl %ecx, %eax
testl %edx, %edx
jne 0x244e0
leal 0x1(%rcx), %eax
imull %ecx, %eax
jmp 0x244e0
leal (%rcx,%rcx,2), %eax
decl %eax
jmp 0x244e0
leal (%rcx,%rcx,2), %eax
movl 0xc(%rdi), %r9d
cmpq $0x4, %r9
ja 0x245b3
leaq 0xa937b(%rip), %rdx     # 0xcd870
movq (%rdx), %rsi
movl 0x1c0(%rsi), %r8d
leal -0x1(%r8), %edx
leaq 0x73cba(%rip), %r10     # 0x981c4
movslq (%r10,%r9,4), %r9
addq %r10, %r9
jmpq *%r9
movl 0x1bc(%rsi), %edi
xorl %edx, %edx
testl %edi, %edi
cmovlel %edx, %edi
imulq $0x340, %rdi, %r8       # imm = 0x340
xorl %edi, %edi
cmpq %rdx, %r8
je 0x245ae
cmpl $0x1, 0x30f08(%rsi,%rdx)
jne 0x24540
addl 0x30f20(%rsi,%rdx), %edi
addq $0x340, %rdx            # imm = 0x340
jmp 0x2452a
xorl %esi, %esi
testl %ecx, %ecx
cmovlel %esi, %ecx
shlq $0x5, %rcx
cmpq %rsi, %rcx
je 0x245b3
movq (%rdi), %r8
movq 0x18(%r8,%rsi), %r8
movl 0x8(%r8), %r8d
imull %edx, %r8d
addl %r8d, %eax
addq $0x20, %rsi
jmp 0x24554
imull %r8d, %edx
xorl %esi, %esi
testl %ecx, %ecx
cmovlel %esi, %ecx
shlq $0x5, %rcx
cmpq %rsi, %rcx
je 0x245b3
movq (%rdi), %r8
movq 0x18(%r8,%rsi), %r8
movl 0x8(%r8), %r8d
imull %edx, %r8d
addl %r8d, %eax
addq $0x20, %rsi
jmp 0x24581
imull %ecx, %edx
jmp 0x245ab
imull %ecx, %edx
imull %r8d, %edx
addl %edx, %eax
retq
imull %ecx, %edi
addl %edi, %eax
retq