// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/classification.c
// Function: train_hmm
void* train_hmm(Instanceptr* trdata, Instanceptr *cvdata, void* parameters)
{
 /*!Last Changed 16.08.2007*/
 /*!Last Changed 02.04.2007*/
 Hmm_parameterptr p;
 Hmmptr* model;
 Instanceptr *trclasses, *cvclasses = NULL;
 int i;
 p = (Hmm_parameterptr) parameters;
 trclasses = divide_instancelist_into_classes(trdata);
 if (p->learningtype == LEARNING_SEPARATE)
   cvclasses = divide_instancelist_into_classes(cvdata);
 model = safemalloc(current_dataset->classno * sizeof(Hmmptr), "train_hmm", 9);
 switch (p->learningtype)
  {
   case LEARNING_SEPARATE:for (i = 0; i < current_dataset->classno; i++)
                           {
                            switch (p->statetype)
                             {
                              case          STATE_DISCRETE:
                              case          STATE_GAUSSIAN:
                              case         STATE_DIRICHLET:model[i] = best_hmm_for_single(trclasses[i], cvclasses[i], p);
                                                           break;
                              case  STATE_GAUSSIAN_MIXTURE:
                              case STATE_DIRICHLET_MIXTURE:model[i] = best_hmm_for_mixture(trclasses[i], cvclasses[i], p);
                                                           break;
                             }
                            printf("Class %d is finished\n", i + 1);
                           }
                          break;
   case LEARNING_TOGETHER:best_hmm_for_together(model, trclasses, *cvdata, p);
                          break;
   case    LEARNING_FIXED:for (i = 0; i < current_dataset->classno; i++)
                           {
                            model[i] = random_hmm(p->statecounts[i], p->statetype, p->componentcounts[i], p->hmmtype, trclasses[i]);
                            baumwelch(model[i], trclasses[i], p->iteration);
                           }
                          break;
  }
 merge_instancelist_groups(trdata, trclasses, current_dataset->classno);
 safe_free(trclasses);
 if (p->learningtype == LEARNING_SEPARATE)
  {
   merge_instancelist_groups(cvdata, cvclasses, current_dataset->classno);
   safe_free(cvclasses);
  }
 return model;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
callq 0x45e20
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0xbc48
movq -0x10(%rbp), %rdi
callq 0x45e20
movq %rax, -0x38(%rbp)
leaq 0xf9bf1(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
leaq 0xd6e93(%rip), %rsi     # 0xe2af4
movl $0x9, %edx
callq 0x52d70
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x40(%rbp)
testl %eax, %eax
je 0xbc9e
jmp 0xbc7f
movl -0x40(%rbp), %eax
subl $0x1, %eax
je 0xbd73
jmp 0xbc8d
movl -0x40(%rbp), %eax
subl $0x2, %eax
je 0xbd90
jmp 0xbe28
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
leaq 0xf9b91(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x10(%rcx), %eax
jge 0xbd6e
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x44(%rbp)
subl $0x2, %eax
jb 0xbcea
jmp 0xbccc
movl -0x44(%rbp), %eax
subl $0x2, %eax
je 0xbd1c
jmp 0xbcd6
movl -0x44(%rbp), %eax
subl $0x3, %eax
je 0xbcea
jmp 0xbce0
movl -0x44(%rbp), %eax
subl $0x4, %eax
je 0xbd1c
jmp 0xbd4c
movq -0x30(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x38(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x20(%rbp), %rdx
callq 0x3e710
movq %rax, %rdx
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0xbd4c
movq -0x30(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x38(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x20(%rbp), %rdx
callq 0x3ea20
movq %rax, %rdx
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x3c(%rbp), %esi
addl $0x1, %esi
leaq 0xd6da5(%rip), %rdi     # 0xe2afe
movb $0x0, %al
callq 0x4030
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xbca5
jmp 0xbe28
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
movq -0x20(%rbp), %rcx
callq 0x3eba0
jmp 0xbe28
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
leaq 0xf9a9f(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x10(%rcx), %eax
jge 0xbe26
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %edi
movq -0x20(%rbp), %rax
movl 0x4(%rax), %esi
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movq -0x30(%rbp), %rax
movslq -0x3c(%rbp), %r8
movq (%rax,%r8,8), %r8
callq 0x38060
movq %rax, %rdx
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x30(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %edx
callq 0x3dbd0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xbd97
jmp 0xbe28
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
leaq 0xf9a09(%rip), %rax     # 0x105840
movq (%rax), %rax
movl 0x10(%rax), %edx
callq 0x44fa0
movq -0x30(%rbp), %rdi
callq 0x52e80
movq -0x20(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0xbe78
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq 0xf99dc(%rip), %rax     # 0x105840
movq (%rax), %rax
movl 0x10(%rax), %edx
callq 0x44fa0
movq -0x38(%rbp), %rdi
callq 0x52e80
movq -0x28(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)