// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/model.c
// Function: compare_mlp_model_selection_techniques
int compare_mlp_model_selection_techniques(char *datasetname, char* simulationdirectory, int maxhidden, int starthidden)
{
	/*!Last Changed 18.07.2005*/
	char** filenames, filename[500], tmpst[READLINELENGTH], varname[MAXLENGTH], varvalue[MAXLENGTH];
	int* model, dummy, dummy2, i, j, k, selectedmodels[MAX_MLP_SIMULATION_ALGORITHMS], tries[MAX_MLP_SIMULATION_ALGORITHMS], bestmodel, indexes[MAX_MLP_SIMULATION_ALGORITHMS], sum;
	Datasetptr d;
 d = search_dataset(Datasets, datasetname);
	if (d == NULL)
		 return -1;
	filenames = safemalloc((maxhidden + 1) * sizeof(char *), "compare_mlp_model_selection_techniques", 7);
 for (i = 0; i <= maxhidden; i++)
	 {
		 sprintf(filename, "%s/%s-%d.txt", simulationdirectory, d->name, i);
			filenames[i] = strcopy(filenames[i], filename);
	 }
	strcpy(tmpst, "-");
 model = multiple_comparison(filenames, maxhidden + 1, get_parameter_l("testtype"), tmpst, &dummy, &dummy2, get_parameter_l("correctiontype"));
	free_2d((void**)filenames, maxhidden + 1);
	for (i = 0; i < MAX_MLP_SIMULATION_ALGORITHMS; i++)
	 {
		 switch (i)
	   {
		   case MULTIMOST    :bestmodel = mlp_model_simulation_multitest(d, simulationdirectory, maxhidden, starthidden, &(tries[i]));
						                  break;
					case ONE_FORWARD  :bestmodel = mlp_model_simulation_one_forward(d, simulationdirectory, maxhidden, starthidden, &(tries[i]));
						                  break;
					case ONE_BACKWARD :bestmodel = mlp_model_simulation_one_backward(d, simulationdirectory, maxhidden, starthidden, &(tries[i]));
						                  break;
					case FORWARD_MOST :bestmodel = mlp_model_simulation_most(d, simulationdirectory, maxhidden, starthidden, &(tries[i]), FORWARD);
						                  break;
					case BACKWARD_MOST:bestmodel = mlp_model_simulation_most(d, simulationdirectory, maxhidden, starthidden, &(tries[i]), BACKWARD);
						                  break;
    }
			selectedmodels[i] = search_list(model, maxhidden + 1, bestmodel + 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;
	 }
	return model[0] - 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x16e608, %rsp         # imm = 0x16E608
movl %ecx, 0x28(%rsp)
movl %edx, %ebx
movq %rsi, 0x10(%rsp)
movq %rdi, %rsi
leaq 0x8a5a8(%rip), %rax     # 0xcd878
movq (%rax), %rdi
callq 0x13da6
testq %rax, %rax
je 0x4369d
movq %rax, %r12
leal 0x1(%rbx), %eax
movl %eax, 0x30(%rsp)
movq %rbx, 0x20(%rsp)
movslq %ebx, %r15
leaq 0x8(,%r15,8), %rdi
leaq 0x57228(%rip), %rsi     # 0x9a52a
pushq $0x7
popq %rdx
callq 0x34f59
movq %rax, %rbx
leaq 0x57148(%rip), %rbp     # 0x9a45c
leaq 0xa0(%rsp), %r14
xorl %r13d, %r13d
cmpq %r15, %r13
jg 0x43353
movq 0x8(%r12), %rcx
movq %r14, %rdi
movq %rbp, %rsi
movq 0x10(%rsp), %rdx
movl %r13d, %r8d
xorl %eax, %eax
callq 0x41b0
movq (%rbx,%r13,8), %rdi
movq %r14, %rsi
callq 0x3604c
movq %rax, (%rbx,%r13,8)
incq %r13
jmp 0x4331f
movq %r12, 0x18(%rsp)
leaq 0xf44e0(%rsp), %r14
movw $0x2d, (%r14)
leaq 0x57064(%rip), %rdi     # 0x9a3d1
callq 0x4cf11
movl %eax, %ebp
leaq 0x525bd(%rip), %rdi     # 0x95938
callq 0x4cf11
movl %eax, (%rsp)
leaq 0x9c(%rsp), %r8
leaq 0x98(%rsp), %r9
movq %rbx, %rdi
movl 0x30(%rsp), %r13d
movl %r13d, %esi
movl %ebp, %edx
movq %r14, %rcx
callq 0x81133
movq %rax, 0x38(%rsp)
movq %rbx, %rdi
movl %r13d, %esi
callq 0x34fc3
xorl %ebx, %ebx
xorl %ebp, %ebp
cmpq $0x14, %rbx
je 0x434d7
leaq (%rsp,%rbx), %r8
addq $0x40, %r8
movl %ebp, %eax
leaq 0x56f51(%rip), %rcx     # 0x9a328
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x20(%rsp), %rdx
movl 0x28(%rsp), %ecx
callq 0x420f3
jmp 0x43462
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x20(%rsp), %rdx
movl 0x28(%rsp), %ecx
pushq $0x1
popq %r9
jmp 0x43443
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x20(%rsp), %rdx
movl 0x28(%rsp), %ecx
callq 0x4308c
jmp 0x43462
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x20(%rsp), %rdx
movl 0x28(%rsp), %ecx
xorl %r9d, %r9d
callq 0x42aae
jmp 0x43462
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x20(%rsp), %rdx
movl 0x28(%rsp), %ecx
callq 0x42eaf
incl %eax
movq 0x38(%rsp), %rdi
movl 0x30(%rsp), %esi
movl %eax, %edx
callq 0x33b22
movl %eax, %r14d
movl %eax, 0x60(%rsp,%rbx)
movq %rbp, %r13
incq %r13
leaq 0x7a3c0(%rsp), %r15
movq %r15, %rdi
leaq 0x56f07(%rip), %rsi     # 0x9a39a
movl %r13d, %edx
xorl %eax, %eax
callq 0x41b0
leaq 0x2a0(%rsp), %r12
movq %r12, %rdi
leaq 0x5d6aa(%rip), %rsi     # 0xa0b59
movl %r14d, %edx
xorl %eax, %eax
callq 0x41b0
movq %r15, %rdi
movq %r12, %rsi
callq 0x2f4fc
movl %ebp, 0x80(%rsp,%rbx)
addq $0x4, %rbx
movq %r13, %rbp
jmp 0x433bc
pushq $0x1
popq %r15
pushq $0x4
popq %rbp
xorl %r13d, %r13d
xorl %eax, %eax
cmpq $0x5, %rax
je 0x435d1
leaq (%rsp,%rax,4), %rbx
addq $0x60, %rbx
leaq 0x40(%rsp,%rax,4), %r14
movq %rax, 0x18(%rsp)
leaq 0x80(%rsp,%rax,4), %rax
movq %rax, 0x10(%rsp)
movq %r13, 0x20(%rsp)
movq %rbp, 0x28(%rsp)
movq %r15, 0x30(%rsp)
subq $0x1, %rbp
jb 0x435ab
leaq 0x64(%rsp), %rax
leaq (%rax,%r13), %rsi
movl 0x64(%rsp,%r13), %eax
cmpl %eax, (%rbx)
jle 0x4356a
movq %rbx, %rdi
callq 0x3537f
leaq 0x84(%rsp), %rax
leaq (%rax,%r13), %rsi
movq 0x10(%rsp), %rdi
callq 0x3537f
leaq (%rsp,%r15,4), %r12
addq $0x40, %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x3537f
jmp 0x4359f
jne 0x4359f
movl (%r14), %eax
cmpl 0x44(%rsp,%r13), %eax
jle 0x4359f
leaq 0x44(%rsp), %rax
leaq (%rax,%r13), %r12
movq %rbx, %rdi
callq 0x3537f
leaq 0x84(%rsp), %rax
leaq (%rax,%r13), %rsi
movq 0x10(%rsp), %rdi
callq 0x3537f
jmp 0x4355d
incq %r15
addq $0x4, %r13
jmp 0x4351b
movq 0x18(%rsp), %rax
incq %rax
movq 0x30(%rsp), %r15
incq %r15
movq 0x28(%rsp), %rbp
decq %rbp
movq 0x20(%rsp), %r13
addq $0x4, %r13
jmp 0x434e3
leaq 0x7a3c0(%rsp), %r14
leaq 0x54877(%rip), %r15     # 0x97e57
leaq 0x2a0(%rsp), %r12
xorl %eax, %eax
cmpl $0x4, %eax
jg 0x43692
movslq %eax, %r13
movq %r13, %rbp
movl %eax, %ecx
incl %ecx
cmpq $0x4, %rbp
je 0x43620
movl 0x60(%rsp,%rbp,4), %edx
cmpl 0x64(%rsp,%rbp,4), %edx
jne 0x43625
movl 0x40(%rsp,%rbp,4), %edx
cmpl 0x44(%rsp,%rbp,4), %edx
jne 0x43625
addl %ebp, %ecx
incl %ecx
incq %rbp
jmp 0x435fb
pushq $0x4
popq %rdx
movl %edx, %ebp
cvtsi2sd %ecx, %xmm1
movl %ebp, %ecx
subl %eax, %ecx
cvtsi2sd %ecx, %xmm0
addsd 0x51ee7(%rip), %xmm0    # 0x95520
divsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movslq %ebp, %rbx
cmpq %rbx, %r13
jg 0x43689
movl 0x80(%rsp,%r13,4), %edx
incl %edx
movq %r14, %rdi
leaq 0x55ee2(%rip), %rsi     # 0x99541
xorl %eax, %eax
callq 0x41b0
movq %r12, %rdi
movq %r15, %rsi
movsd 0x10(%rsp), %xmm0
movb $0x1, %al
callq 0x41b0
movq %r14, %rdi
movq %r12, %rsi
callq 0x2f4fc
incq %r13
jmp 0x43646
incl %ebp
movl %ebp, %eax
jmp 0x435ea
movq 0x38(%rsp), %rax
movl (%rax), %eax
decl %eax
jmp 0x436a0
pushq $-0x1
popq %rax
addq $0x16e608, %rsp         # imm = 0x16E608
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq