// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/model.c
// Function: hmm_model_simulation_multitest
Hmm_model hmm_model_simulation_multitest(char* simulationdirectory, int maxstates, int maxmixture, int* tries)
{
 /*!Last Changed 10.01.2009*/
 char **filenames, directory[500], tmpst[500];
 int filecount, i, j, k, m, c, *model, *models_searched, current_best_index;
 Hmm_modelptr bestmodel;
 Hmm_modelptr models;
 Hmm_model result;
 models = safemalloc(sizeof(Hmm_model) * maxstates * maxmixture, "hmm_model_simulation_multitest", 4);
 models_searched = safemalloc(sizeof(int) * MAX_MODEL_SEARCH, "hmm_model_simulation_multitest", 4);
 k = 0;
 for (i = 1; i <= maxstates; i++)
   for (j = 1; j <= maxmixture; j++)
    {
     models[k].states = i;
     models[k].mixture = j;
     models[k].index = k;
     models[k].selected = BOOLEAN_FALSE;
     models[k].tried = BOOLEAN_FALSE;
     k++;
    }
 bestmodel = &(models[0]);
 bestmodel->selected = BOOLEAN_TRUE;
 filenames = (char **) safemalloc_2d(sizeof(char *), sizeof(char), MAX_MODEL_SEARCH, 500, "hmm_model_simulation_multitest", 3);
 sprintf(directory,"%s", simulationdirectory);
 while (BOOLEAN_TRUE)
  {
   filecount = 0;
   /*Remove one state*/
   if (bestmodel->states > 1)
     hmm_add_candidate_model(filenames, directory, bestmodel->index - maxmixture, models, models_searched, &filecount);
   /*Remove one mixture*/
   if (bestmodel->mixture > 1)
     hmm_add_candidate_model(filenames, directory, bestmodel->index - 1, models, models_searched, &filecount);
   /*Add best model to comparison*/
   hmm_add_candidate_model(filenames, directory, bestmodel->index, models, models_searched, &filecount);
   /*Add one mixture*/
   if (bestmodel->mixture < maxmixture)
     hmm_add_candidate_model(filenames, directory, bestmodel->index + 1, models, models_searched, &filecount);
   /*Add one state*/
   if (bestmodel->states < maxstates)
     hmm_add_candidate_model(filenames, directory, bestmodel->index + maxmixture, models, models_searched, &filecount);
   sprintf(tmpst,"-");
   model = multiple_comparison(filenames, filecount, get_parameter_l("testtype"), tmpst, &m, &c, get_parameter_l("correctiontype"));
   current_best_index = models_searched[model[0] - 1]; 
   if (current_best_index == bestmodel->index)
    {
     safe_free(model);
     break;
    }
   else
    {
     if (models[current_best_index].selected)
       break;
     bestmodel = &(models[current_best_index]);
     bestmodel->selected = BOOLEAN_TRUE;
    }
   safe_free(model);
  }
 *tries = 0;
 for (i = 0; i < maxstates * maxmixture; i++)
   if (models[i].tried)
     (*tries)++;
 result = *bestmodel;
 free_2d((void**)filenames, MAX_MODEL_SEARCH);
 safe_free(models);
 safe_free(models_searched);
 return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x490, %rsp            # imm = 0x490
movq %rdi, -0x470(%rbp)
movq %rdi, -0x468(%rbp)
movq %rsi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl %ecx, -0x10(%rbp)
movq %r8, -0x18(%rbp)
movslq -0xc(%rbp), %rax
imulq $0x14, %rax, %rdi
movslq -0x10(%rbp), %rax
imulq %rax, %rdi
leaq 0x7f224(%rip), %rsi     # 0xe6fa2
movl $0x4, %edx
callq 0x52d70
movq %rax, -0x460(%rbp)
movl $0x1c, %edi
leaq 0x7f207(%rip), %rsi     # 0xe6fa2
movl $0x4, %edx
callq 0x52d70
movq %rax, -0x448(%rbp)
movl $0x0, -0x430(%rbp)
movl $0x1, -0x428(%rbp)
movl -0x428(%rbp), %eax
cmpl -0xc(%rbp), %eax
jg 0x67eb2
movl $0x1, -0x42c(%rbp)
movl -0x42c(%rbp), %eax
cmpl -0x10(%rbp), %eax
jg 0x67e9c
movl -0x428(%rbp), %ecx
movq -0x460(%rbp), %rax
movslq -0x430(%rbp), %rdx
imulq $0x14, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x42c(%rbp), %ecx
movq -0x460(%rbp), %rax
movslq -0x430(%rbp), %rdx
imulq $0x14, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movl -0x430(%rbp), %ecx
movq -0x460(%rbp), %rax
movslq -0x430(%rbp), %rdx
imulq $0x14, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq -0x460(%rbp), %rax
movslq -0x430(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0xc(%rax)
movq -0x460(%rbp), %rax
movslq -0x430(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x10(%rax)
movl -0x430(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x430(%rbp)
movl -0x42c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x42c(%rbp)
jmp 0x67dd9
jmp 0x67e9e
movl -0x428(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x428(%rbp)
jmp 0x67dc0
movq -0x460(%rbp), %rax
movq %rax, -0x458(%rbp)
movq -0x458(%rbp), %rax
movl $0x1, 0xc(%rax)
movl $0x8, %edi
movl $0x1, %esi
movl $0x7, %edx
movl $0x1f4, %ecx            # imm = 0x1F4
leaq 0x7f0b9(%rip), %r8      # 0xe6fa2
movl $0x3, %r9d
callq 0x53120
movq %rax, -0x20(%rbp)
leaq -0x220(%rbp), %rdi
movq -0x8(%rbp), %rdx
leaq 0x7cb8e(%rip), %rsi     # 0xe4a98
movb $0x0, %al
callq 0x4170
movl $0x0, -0x424(%rbp)
movq -0x458(%rbp), %rax
cmpl $0x1, (%rax)
jle 0x67f59
movq -0x20(%rbp), %rdi
leaq -0x220(%rbp), %rsi
movq -0x458(%rbp), %rax
movl 0x8(%rax), %edx
subl -0x10(%rbp), %edx
movq -0x460(%rbp), %rcx
movq -0x448(%rbp), %r8
leaq -0x424(%rbp), %r9
callq 0x67c80
movq -0x458(%rbp), %rax
cmpl $0x1, 0x4(%rax)
jle 0x67f98
movq -0x20(%rbp), %rdi
leaq -0x220(%rbp), %rsi
movq -0x458(%rbp), %rax
movl 0x8(%rax), %edx
subl $0x1, %edx
movq -0x460(%rbp), %rcx
movq -0x448(%rbp), %r8
leaq -0x424(%rbp), %r9
callq 0x67c80
movq -0x20(%rbp), %rdi
leaq -0x220(%rbp), %rsi
movq -0x458(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x460(%rbp), %rcx
movq -0x448(%rbp), %r8
leaq -0x424(%rbp), %r9
callq 0x67c80
movq -0x458(%rbp), %rax
movl 0x4(%rax), %eax
cmpl -0x10(%rbp), %eax
jge 0x68008
movq -0x20(%rbp), %rdi
leaq -0x220(%rbp), %rsi
movq -0x458(%rbp), %rax
movl 0x8(%rax), %edx
addl $0x1, %edx
movq -0x460(%rbp), %rcx
movq -0x448(%rbp), %r8
leaq -0x424(%rbp), %r9
callq 0x67c80
movq -0x458(%rbp), %rax
movl (%rax), %eax
cmpl -0xc(%rbp), %eax
jge 0x68048
movq -0x20(%rbp), %rdi
leaq -0x220(%rbp), %rsi
movq -0x458(%rbp), %rax
movl 0x8(%rax), %edx
addl -0x10(%rbp), %edx
movq -0x460(%rbp), %rcx
movq -0x448(%rbp), %r8
leaq -0x424(%rbp), %r9
callq 0x67c80
leaq -0x420(%rbp), %rdi
leaq 0x7db2c(%rip), %rsi     # 0xe5b82
movb $0x0, %al
callq 0x4170
movq -0x20(%rbp), %rax
movq %rax, -0x488(%rbp)
movl -0x424(%rbp), %eax
movl %eax, -0x480(%rbp)
leaq 0x7ef46(%rip), %rdi     # 0xe6fc1
callq 0x792b0
movl %eax, -0x47c(%rbp)
leaq -0x420(%rbp), %rax
movq %rax, -0x478(%rbp)
leaq 0x7a612(%rip), %rdi     # 0xe26ad
callq 0x792b0
movq -0x488(%rbp), %rdi
movl -0x480(%rbp), %esi
movl -0x47c(%rbp), %edx
movq -0x478(%rbp), %rcx
leaq -0x434(%rbp), %r8
leaq -0x438(%rbp), %r9
movl %eax, (%rsp)
callq 0xc3c40
movq %rax, -0x440(%rbp)
movq -0x448(%rbp), %rax
movq -0x440(%rbp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x44c(%rbp)
movl -0x44c(%rbp), %eax
movq -0x458(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jne 0x68116
movq -0x440(%rbp), %rdi
callq 0x52e80
jmp 0x6816e
movq -0x460(%rbp), %rax
movslq -0x44c(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0xc(%rax)
je 0x68133
jmp 0x6816e
movq -0x460(%rbp), %rax
movslq -0x44c(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x458(%rbp)
movq -0x458(%rbp), %rax
movl $0x1, 0xc(%rax)
movq -0x440(%rbp), %rdi
callq 0x52e80
jmp 0x67f11
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x428(%rbp)
movl -0x428(%rbp), %eax
movl -0xc(%rbp), %ecx
imull -0x10(%rbp), %ecx
cmpl %ecx, %eax
jge 0x681cc
movq -0x460(%rbp), %rax
movslq -0x428(%rbp), %rcx
imulq $0x14, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x10(%rax)
je 0x681b9
movq -0x18(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x681bb
movl -0x428(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x428(%rbp)
jmp 0x68182
movq -0x470(%rbp), %rax
movq -0x458(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movl 0x10(%rcx), %ecx
movl %ecx, 0x10(%rax)
movq -0x20(%rbp), %rdi
movl $0x7, %esi
callq 0x52e20
movq -0x460(%rbp), %rdi
callq 0x52e80
movq -0x448(%rbp), %rdi
callq 0x52e80
movq -0x468(%rbp), %rax
addq $0x490, %rsp            # imm = 0x490
popq %rbp
retq
nopw %cs:(%rax,%rax)