// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/model.c
// Function: compare_hmm_model_selection_techniques
Hmm_model compare_hmm_model_selection_techniques(char* simulationdirectory, int maxstates, int maxmixture)
{
 /*!Last Changed 12.04.2009*/
 char** filenames, filename[500], tmpst[READLINELENGTH], varname[MAXLENGTH], varvalue[MAXLENGTH];
 int* model, dummy, dummy2, i, j, k, selectedmodels[MAX_MLP_SIMULATION_ALGORITHMS], modelcount, tries[MAX_MLP_SIMULATION_ALGORITHMS], indexes[MAX_MLP_SIMULATION_ALGORITHMS], sum;
 Hmm_model bestmodel, *models;
 modelcount = maxstates * maxmixture;
 filenames = safemalloc(modelcount * sizeof(char *), "compare_hmm_model_selection_techniques", 5);
 models = safemalloc(modelcount * sizeof(Hmm_model), "compare_hmm_model_selection_techniques", 6);
 k = 0;
 for (i = 1; i <= maxstates; i++)
   for (j = 1; j <= maxmixture; j++)
    {
     sprintf(filename, "%s/%dM%dS.txt", simulationdirectory, j, i);
     filenames[k] = strcopy(filenames[k], filename);
     models[k].states = i;
     models[k].mixture = j;
     models[k].index = k;     
     k++;
    }
 strcpy(tmpst, "-");
 model = multiple_comparison(filenames, modelcount, get_parameter_l("testtype"), tmpst, &dummy, &dummy2, get_parameter_l("correctiontype"));
 free_2d((void**)filenames, modelcount);
 for (i = 0; i < MAX_MLP_SIMULATION_ALGORITHMS; i++)
  {
   switch (i)
    {
     case MULTIMOST    :bestmodel = hmm_model_simulation_multitest(simulationdirectory, maxstates, maxmixture, &(tries[i]));
                        break;
     case ONE_FORWARD  :bestmodel = hmm_model_simulation_one_forward(simulationdirectory, maxstates, &(tries[i]));
                        break;
     case ONE_BACKWARD :bestmodel = hmm_model_simulation_one_backward(simulationdirectory, maxstates, &(tries[i]));
                        break;
     case FORWARD_MOST :bestmodel = hmm_model_simulation_most(simulationdirectory, maxstates, maxmixture, &(tries[i]), FORWARD);
                        break;
     case BACKWARD_MOST:bestmodel = hmm_model_simulation_most(simulationdirectory, maxstates, maxmixture, &(tries[i]), BACKWARD);
                        break;
    }
   selectedmodels[i] = search_list(model, modelcount, bestmodel.index + 1);
   sprintf(varname, "aout2[%d]", i + 1);
   sprintf(varvalue, "%d", selectedmodels[i]);
   set_variable(varname, varvalue);
   indexes[i] = i;
  }
 for (i = 0; i < MAX_MLP_SIMULATION_ALGORITHMS; i++)
   for (j = i + 1; j < MAX_MLP_SIMULATION_ALGORITHMS; j++)
     if (selectedmodels[i] > selectedmodels[j])
      {
       swap_int(&(selectedmodels[i]), &(selectedmodels[j]));
       swap_int(&(indexes[i]), &(indexes[j]));
       swap_int(&(tries[i]), &(tries[j]));
      }
     else
       if (selectedmodels[i] == selectedmodels[j] && tries[i] > tries[j])
        {
         swap_int(&(selectedmodels[i]), &(selectedmodels[j]));
         swap_int(&(indexes[i]), &(indexes[j]));
         swap_int(&(tries[i]), &(tries[j]));
        }
 i = 0;
 while (i < MAX_MLP_SIMULATION_ALGORITHMS)
  {
   j = i;
   sum = j + 1;
   while (j < MAX_MLP_SIMULATION_ALGORITHMS - 1 && selectedmodels[j] == selectedmodels[j + 1] && tries[j] == tries[j + 1])
    {
     j++;
     sum = sum + j + 1;
    }
   for (k = i; k <= j; k++)
    {
     sprintf(varname, "aout1[%d]", indexes[k] + 1);
     sprintf(varvalue, "%.1f", sum / (j - i + 1.0));
     set_variable(varname, varvalue);
    }
   i = j + 1;
  }
 bestmodel = models[model[0] - 1];
 safe_free(models);
 return bestmodel;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x16e6a0, %rsp         # imm = 0x16E6A0
movq %rdi, -0x16e668(%rbp)
movq %rdi, -0x16e660(%rbp)
movq %rsi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl %ecx, -0x10(%rbp)
movl -0xc(%rbp), %eax
imull -0x10(%rbp), %eax
movl %eax, -0x16e5a4(%rbp)
movslq -0x16e5a4(%rbp), %rdi
shlq $0x3, %rdi
leaq 0x7ccff(%rip), %rsi     # 0xe7141
movl $0x5, %edx
callq 0x52d70
movq %rax, -0x18(%rbp)
movslq -0x16e5a4(%rbp), %rax
imulq $0x14, %rax, %rdi
leaq 0x7ccdf(%rip), %rsi     # 0xe7141
movl $0x6, %edx
callq 0x52d70
movq %rax, -0x16e5f0(%rbp)
movl $0x0, -0x16e58c(%rbp)
movl $0x1, -0x16e584(%rbp)
movl -0x16e584(%rbp), %eax
cmpl -0xc(%rbp), %eax
jg 0x6a594
movl $0x1, -0x16e588(%rbp)
movl -0x16e588(%rbp), %eax
cmpl -0x10(%rbp), %eax
jg 0x6a57e
leaq -0x210(%rbp), %rdi
movq -0x8(%rbp), %rdx
movl -0x16e588(%rbp), %ecx
movl -0x16e584(%rbp), %r8d
leaq 0x7cac6(%rip), %rsi     # 0xe6f94
movb $0x0, %al
callq 0x4170
movq -0x18(%rbp), %rax
movslq -0x16e58c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq -0x210(%rbp), %rsi
callq 0x54ba0
movq %rax, %rdx
movq -0x18(%rbp), %rax
movslq -0x16e58c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x16e584(%rbp), %ecx
movq -0x16e5f0(%rbp), %rax
movslq -0x16e58c(%rbp), %rdx
imulq $0x14, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x16e588(%rbp), %ecx
movq -0x16e5f0(%rbp), %rax
movslq -0x16e58c(%rbp), %rdx
imulq $0x14, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movl -0x16e58c(%rbp), %ecx
movq -0x16e5f0(%rbp), %rax
movslq -0x16e58c(%rbp), %rdx
imulq $0x14, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movl -0x16e58c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16e58c(%rbp)
movl -0x16e588(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16e588(%rbp)
jmp 0x6a4a0
jmp 0x6a580
movl -0x16e584(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16e584(%rbp)
jmp 0x6a487
leaq -0x7a330(%rbp), %rdi
leaq 0x7b5e0(%rip), %rsi     # 0xe5b82
callq 0x4220
movq -0x18(%rbp), %rax
movq %rax, -0x16e680(%rbp)
movl -0x16e5a4(%rbp), %eax
movl %eax, -0x16e678(%rbp)
leaq 0x7c9fc(%rip), %rdi     # 0xe6fc1
callq 0x792b0
movl %eax, -0x16e674(%rbp)
leaq -0x7a330(%rbp), %rax
movq %rax, -0x16e670(%rbp)
leaq 0x780c8(%rip), %rdi     # 0xe26ad
callq 0x792b0
movq -0x16e680(%rbp), %rdi
movl -0x16e678(%rbp), %esi
movl -0x16e674(%rbp), %edx
movq -0x16e670(%rbp), %rcx
leaq -0x16e57c(%rbp), %r8
leaq -0x16e580(%rbp), %r9
movl %eax, (%rsp)
callq 0xc3c40
movq %rax, -0x16e578(%rbp)
movq -0x18(%rbp), %rdi
movl -0x16e5a4(%rbp), %esi
callq 0x52e20
movl $0x0, -0x16e584(%rbp)
cmpl $0x5, -0x16e584(%rbp)
jge 0x6a8c4
movl -0x16e584(%rbp), %eax
movq %rax, -0x16e688(%rbp)
subq $0x4, %rax
ja 0x6a819
movq -0x16e688(%rbp), %rax
leaq 0x7c8c0(%rip), %rcx     # 0xe6f2c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rsi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
movslq -0x16e584(%rbp), %rax
leaq -0x16e5c0(%rbp), %r8
shlq $0x2, %rax
addq %rax, %r8
leaq -0x16e604(%rbp), %rdi
callq 0x67d40
movq -0x16e668(%rbp), %rax
movq -0x16e604(%rbp), %rcx
movq %rcx, (%rax)
movq -0x16e5fc(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl -0x16e5f4(%rbp), %ecx
movl %ecx, 0x10(%rax)
jmp 0x6a819
movq -0x8(%rbp), %rsi
movl -0xc(%rbp), %edx
movslq -0x16e584(%rbp), %rax
leaq -0x16e5c0(%rbp), %rcx
shlq $0x2, %rax
addq %rax, %rcx
leaq -0x16e618(%rbp), %rdi
callq 0x69540
movq -0x16e668(%rbp), %rax
movq -0x16e618(%rbp), %rcx
movq %rcx, (%rax)
movq -0x16e610(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl -0x16e608(%rbp), %ecx
movl %ecx, 0x10(%rax)
jmp 0x6a819
movq -0x8(%rbp), %rsi
movl -0xc(%rbp), %edx
movslq -0x16e584(%rbp), %rax
leaq -0x16e5c0(%rbp), %rcx
shlq $0x2, %rax
addq %rax, %rcx
leaq -0x16e62c(%rbp), %rdi
callq 0x69800
movq -0x16e668(%rbp), %rax
movq -0x16e62c(%rbp), %rcx
movq %rcx, (%rax)
movq -0x16e624(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl -0x16e61c(%rbp), %ecx
movl %ecx, 0x10(%rax)
jmp 0x6a819
movq -0x8(%rbp), %rsi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
movslq -0x16e584(%rbp), %rax
leaq -0x16e5c0(%rbp), %r8
shlq $0x2, %rax
addq %rax, %r8
leaq -0x16e640(%rbp), %rdi
xorl %r9d, %r9d
callq 0x68bf0
movq -0x16e668(%rbp), %rax
movq -0x16e640(%rbp), %rcx
movq %rcx, (%rax)
movq -0x16e638(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl -0x16e630(%rbp), %ecx
movl %ecx, 0x10(%rax)
jmp 0x6a819
movq -0x8(%rbp), %rsi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
movslq -0x16e584(%rbp), %rax
leaq -0x16e5c0(%rbp), %r8
shlq $0x2, %rax
addq %rax, %r8
leaq -0x16e654(%rbp), %rdi
movl $0x1, %r9d
callq 0x68bf0
movq -0x16e668(%rbp), %rax
movq -0x16e654(%rbp), %rcx
movq %rcx, (%rax)
movq -0x16e64c(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl -0x16e644(%rbp), %ecx
movl %ecx, 0x10(%rax)
movq -0x16e668(%rbp), %rax
movq -0x16e578(%rbp), %rdi
movl -0x16e5a4(%rbp), %esi
movl 0x8(%rax), %edx
addl $0x1, %edx
callq 0x508f0
movl %eax, %ecx
movslq -0x16e584(%rbp), %rax
movl %ecx, -0x16e5a0(%rbp,%rax,4)
leaq -0xf4450(%rbp), %rdi
movl -0x16e584(%rbp), %edx
addl $0x1, %edx
leaq 0x7c72b(%rip), %rsi     # 0xe6f8a
movb $0x0, %al
callq 0x4170
leaq -0x16e570(%rbp), %rdi
movslq -0x16e584(%rbp), %rax
movl -0x16e5a0(%rbp,%rax,4), %edx
leaq 0x829e3(%rip), %rsi     # 0xed265
movb $0x0, %al
callq 0x4170
leaq -0xf4450(%rbp), %rdi
leaq -0x16e570(%rbp), %rsi
callq 0x493b0
movl -0x16e584(%rbp), %ecx
movslq -0x16e584(%rbp), %rax
movl %ecx, -0x16e5e0(%rbp,%rax,4)
movl -0x16e584(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16e584(%rbp)
jmp 0x6a63a
movl $0x0, -0x16e584(%rbp)
cmpl $0x5, -0x16e584(%rbp)
jge 0x6aaaa
movl -0x16e584(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16e588(%rbp)
cmpl $0x5, -0x16e588(%rbp)
jge 0x6aa94
movslq -0x16e584(%rbp), %rax
movl -0x16e5a0(%rbp,%rax,4), %eax
movslq -0x16e588(%rbp), %rcx
cmpl -0x16e5a0(%rbp,%rcx,4), %eax
jle 0x6a9ab
movslq -0x16e584(%rbp), %rax
leaq -0x16e5a0(%rbp), %rdi
shlq $0x2, %rax
addq %rax, %rdi
movslq -0x16e588(%rbp), %rax
leaq -0x16e5a0(%rbp), %rsi
shlq $0x2, %rax
addq %rax, %rsi
callq 0x533d0
movslq -0x16e584(%rbp), %rax
leaq -0x16e5e0(%rbp), %rdi
shlq $0x2, %rax
addq %rax, %rdi
movslq -0x16e588(%rbp), %rax
leaq -0x16e5e0(%rbp), %rsi
shlq $0x2, %rax
addq %rax, %rsi
callq 0x533d0
movslq -0x16e584(%rbp), %rax
leaq -0x16e5c0(%rbp), %rdi
shlq $0x2, %rax
addq %rax, %rdi
movslq -0x16e588(%rbp), %rax
leaq -0x16e5c0(%rbp), %rsi
shlq $0x2, %rax
addq %rax, %rsi
callq 0x533d0
jmp 0x6aa7e
movslq -0x16e584(%rbp), %rax
movl -0x16e5a0(%rbp,%rax,4), %eax
movslq -0x16e588(%rbp), %rcx
cmpl -0x16e5a0(%rbp,%rcx,4), %eax
jne 0x6aa7c
movslq -0x16e584(%rbp), %rax
movl -0x16e5c0(%rbp,%rax,4), %eax
movslq -0x16e588(%rbp), %rcx
cmpl -0x16e5c0(%rbp,%rcx,4), %eax
jle 0x6aa7c
movslq -0x16e584(%rbp), %rax
leaq -0x16e5a0(%rbp), %rdi
shlq $0x2, %rax
addq %rax, %rdi
movslq -0x16e588(%rbp), %rax
leaq -0x16e5a0(%rbp), %rsi
shlq $0x2, %rax
addq %rax, %rsi
callq 0x533d0
movslq -0x16e584(%rbp), %rax
leaq -0x16e5e0(%rbp), %rdi
shlq $0x2, %rax
addq %rax, %rdi
movslq -0x16e588(%rbp), %rax
leaq -0x16e5e0(%rbp), %rsi
shlq $0x2, %rax
addq %rax, %rsi
callq 0x533d0
movslq -0x16e584(%rbp), %rax
leaq -0x16e5c0(%rbp), %rdi
shlq $0x2, %rax
addq %rax, %rdi
movslq -0x16e588(%rbp), %rax
leaq -0x16e5c0(%rbp), %rsi
shlq $0x2, %rax
addq %rax, %rsi
callq 0x533d0
jmp 0x6aa7e
jmp 0x6aa80
movl -0x16e588(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16e588(%rbp)
jmp 0x6a8ea
jmp 0x6aa96
movl -0x16e584(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16e584(%rbp)
jmp 0x6a8ce
movl $0x0, -0x16e584(%rbp)
cmpl $0x5, -0x16e584(%rbp)
jge 0x6ac33
movl -0x16e584(%rbp), %eax
movl %eax, -0x16e588(%rbp)
movl -0x16e588(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16e5e4(%rbp)
xorl %eax, %eax
cmpl $0x4, -0x16e588(%rbp)
movb %al, -0x16e689(%rbp)
jge 0x6ab42
movslq -0x16e588(%rbp), %rax
movl -0x16e5a0(%rbp,%rax,4), %ecx
movl -0x16e588(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdx
xorl %eax, %eax
cmpl -0x16e5a0(%rbp,%rdx,4), %ecx
movb %al, -0x16e689(%rbp)
jne 0x6ab42
movslq -0x16e588(%rbp), %rax
movl -0x16e5c0(%rbp,%rax,4), %eax
movl -0x16e588(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
cmpl -0x16e5c0(%rbp,%rcx,4), %eax
sete %al
movb %al, -0x16e689(%rbp)
movb -0x16e689(%rbp), %al
testb $0x1, %al
jne 0x6ab4e
jmp 0x6ab77
movl -0x16e588(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16e588(%rbp)
movl -0x16e5e4(%rbp), %eax
addl -0x16e588(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16e5e4(%rbp)
jmp 0x6aadc
movl -0x16e584(%rbp), %eax
movl %eax, -0x16e58c(%rbp)
movl -0x16e58c(%rbp), %eax
cmpl -0x16e588(%rbp), %eax
jg 0x6ac1f
leaq -0xf4450(%rbp), %rdi
movslq -0x16e58c(%rbp), %rax
movl -0x16e5e0(%rbp,%rax,4), %edx
addl $0x1, %edx
leaq 0x7b5bf(%rip), %rsi     # 0xe6173
movb $0x0, %al
callq 0x4170
leaq -0x16e570(%rbp), %rdi
cvtsi2sdl -0x16e5e4(%rbp), %xmm0
movl -0x16e588(%rbp), %eax
subl -0x16e584(%rbp), %eax
cvtsi2sd %eax, %xmm1
movsd 0x77436(%rip), %xmm2    # 0xe2018
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
leaq 0x79e2e(%rip), %rsi     # 0xe4a1f
movb $0x1, %al
callq 0x4170
leaq -0xf4450(%rbp), %rdi
leaq -0x16e570(%rbp), %rsi
callq 0x493b0
movl -0x16e58c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16e58c(%rbp)
jmp 0x6ab83
movl -0x16e588(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16e584(%rbp)
jmp 0x6aab4
movq -0x16e668(%rbp), %rax
movq -0x16e5f0(%rbp), %rcx
movq -0x16e578(%rbp), %rdx
movl (%rdx), %edx
subl $0x1, %edx
movslq %edx, %rdx
imulq $0x14, %rdx, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movl 0x10(%rcx), %ecx
movl %ecx, 0x10(%rax)
movq -0x16e5f0(%rbp), %rdi
callq 0x52e80
movq -0x16e660(%rbp), %rax
addq $0x16e6a0, %rsp         # imm = 0x16E6A0
popq %rbp
retq
nopw (%rax,%rax)