// File: /workspace/github_c_makefile_star2_O1/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 0x272ed
cmpl $0x1, %edx
je 0x272e6
movl %ecx, %eax
testl %edx, %edx
jne 0x272f0
leal 0x1(%rcx), %eax
imull %ecx, %eax
jmp 0x272f0
leal (%rcx,%rcx,2), %eax
decl %eax
jmp 0x272f0
leal (%rcx,%rcx,2), %eax
movl 0xc(%rdi), %r9d
cmpq $0x4, %r9
ja 0x27387
leaq 0xab56b(%rip), %rdx     # 0xd2870
movq (%rdx), %rsi
movl 0x1c0(%rsi), %r8d
leal -0x1(%r8), %edx
leaq 0x7ded2(%rip), %r10     # 0xa51ec
movslq (%r10,%r9,4), %r9
addq %r10, %r9
jmpq *%r9
movslq 0x1bc(%rsi), %rdx
testq %rdx, %rdx
jle 0x273bd
imulq $0x340, %rdx, %rdi      # imm = 0x340
xorl %r8d, %r8d
xorl %edx, %edx
cmpl $0x1, 0x30f08(%rsi,%r8)
jne 0x27353
addl 0x30f20(%rsi,%r8), %edx
addq $0x340, %r8             # imm = 0x340
cmpq %r8, %rdi
jne 0x27340
jmp 0x273bf
testl %ecx, %ecx
jle 0x27387
movq (%rdi), %rsi
shlq $0x5, %rcx
xorl %edi, %edi
movq 0x18(%rsi,%rdi), %r8
movl 0x8(%r8), %r8d
imull %edx, %r8d
addl %r8d, %eax
addq $0x20, %rdi
cmpq %rdi, %rcx
jne 0x2736e
retq
imull %ecx, %edx
imull %r8d, %edx
jmp 0x273c2
testl %ecx, %ecx
jle 0x27387
movq (%rdi), %rsi
imull %r8d, %edx
shlq $0x5, %rcx
xorl %edi, %edi
movq 0x18(%rsi,%rdi), %r8
movl 0x8(%r8), %r8d
imull %edx, %r8d
addl %r8d, %eax
addq $0x20, %rdi
cmpq %rdi, %rcx
jne 0x273a2
jmp 0x27387
xorl %edx, %edx
imull %ecx, %edx
addl %edx, %eax
retq