// File: /workspace/github_c_makefile_star2_O3/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, 0x20(%rsp)
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %rsi
leaq 0x8b703(%rip), %rax     # 0xd5878
movq (%rax), %rdi
callq 0x14fb7
testq %rax, %rax
je 0x4a59f
movq %rax, %r12
leal 0x1(%r15), %eax
movl %eax, 0x28(%rsp)
movslq %eax, %rdi
shlq $0x3, %rdi
leaq 0x6045b(%rip), %rsi     # 0xaa5fa
movl $0x7, %edx
callq 0x3a0e1
movq %rax, %rbx
movq %r15, 0x18(%rsp)
testl %r15d, %r15d
js 0x4a1fa
movl 0x28(%rsp), %r15d
leaq 0xa0(%rsp), %rbp
xorl %r13d, %r13d
movq 0x8(%r12), %rcx
movq %rbp, %rdi
leaq 0x60357(%rip), %rsi     # 0xaa52c
movq %r14, %rdx
movl %r13d, %r8d
xorl %eax, %eax
callq 0x41b0
movq (%rbx,%r13,8), %rdi
movq %rbp, %rsi
callq 0x3b494
movq %rax, (%rbx,%r13,8)
incq %r13
cmpq %r13, %r15
jne 0x4a1c6
movq %r14, 0x10(%rsp)
leaq 0xf44e0(%rsp), %r14
movw $0x2d, (%r14)
leaq 0x6028d(%rip), %rdi     # 0xaa4a1
callq 0x54afc
movl %eax, %ebp
leaq 0x5b716(%rip), %rdi     # 0xa5938
callq 0x54afc
movl %eax, (%rsp)
leaq 0x9c(%rsp), %r8
leaq 0x98(%rsp), %r9
movq %rbx, %rdi
movl 0x28(%rsp), %r15d
movl %r15d, %esi
movl %ebp, %edx
movq %r14, %rcx
callq 0x8ec4a
movq %rax, 0x38(%rsp)
movq %rbx, %rdi
movl %r15d, %esi
callq 0x3a14b
leaq 0x40(%rsp), %rbx
xorl %ebp, %ebp
movq %r12, 0x30(%rsp)
movl %ebp, %eax
leaq 0x60184(%rip), %rcx     # 0xaa3f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r12, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl 0x20(%rsp), %ecx
movq %rbx, %r8
callq 0x48eb1
jmp 0x4a306
movq %r12, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl 0x20(%rsp), %ecx
movq %rbx, %r8
movl $0x1, %r9d
jmp 0x4a2e6
movq %r12, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl 0x20(%rsp), %ecx
movq %rbx, %r8
callq 0x49f24
jmp 0x4a306
movq %r12, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl 0x20(%rsp), %ecx
movq %rbx, %r8
xorl %r9d, %r9d
callq 0x498e2
jmp 0x4a306
movq %r12, %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl 0x20(%rsp), %ecx
movq %rbx, %r8
callq 0x49d11
incl %eax
movq 0x38(%rsp), %rdi
movl 0x28(%rsp), %esi
movl %eax, %edx
callq 0x384d0
movl %eax, %r13d
movl %eax, 0x60(%rsp,%rbp,4)
leaq 0x1(%rbp), %r15
leaq 0x7a3c0(%rsp), %r14
movq %r14, %rdi
leaq 0x60135(%rip), %rsi     # 0xaa46a
movl %r15d, %edx
xorl %eax, %eax
callq 0x41b0
leaq 0x2a0(%rsp), %r12
movq %r12, %rdi
leaq 0x668a4(%rip), %rsi     # 0xb0bf5
movl %r13d, %edx
xorl %eax, %eax
callq 0x41b0
movq %r14, %rdi
movq %r12, %rsi
callq 0x33827
leal -0x1(%r15), %eax
movl %eax, 0x80(%rsp,%rbp,4)
addq $0x4, %rbx
movq %r15, %rbp
cmpq $0x5, %r15
movq 0x30(%rsp), %r12
jne 0x4a26b
movl $0x1, %eax
movq %rax, 0x18(%rsp)
movl $0x4, %eax
movq %rax, 0x10(%rsp)
movq $0x0, 0x30(%rsp)
xorl %eax, %eax
movq %rax, 0x20(%rsp)
cmpq $0x3, %rax
ja 0x4a46d
movq 0x20(%rsp), %rax
leaq (%rsp,%rax,4), %rbx
addq $0x60, %rbx
leaq 0x40(%rsp,%rax,4), %r14
leaq 0x80(%rsp,%rax,4), %rax
movq %rax, 0x28(%rsp)
movq 0x10(%rsp), %rbp
movq 0x30(%rsp), %r13
movq 0x18(%rsp), %r15
leaq 0x64(%rsp), %rax
leaq (%rax,%r13), %rsi
movl 0x64(%rsp,%r13), %eax
cmpl %eax, (%rbx)
jle 0x4a428
movq %rbx, %rdi
callq 0x3a5af
leaq 0x84(%rsp), %rax
leaq (%rax,%r13), %rsi
movq 0x28(%rsp), %rdi
callq 0x3a5af
leaq (%rsp,%r15,4), %r12
addq $0x40, %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x3a5af
jmp 0x4a45d
jne 0x4a45d
movl (%r14), %eax
cmpl 0x44(%rsp,%r13), %eax
jle 0x4a45d
leaq 0x44(%rsp), %rax
leaq (%rax,%r13), %r12
movq %rbx, %rdi
callq 0x3a5af
leaq 0x84(%rsp), %rax
leaq (%rax,%r13), %rsi
movq 0x28(%rsp), %rdi
callq 0x3a5af
jmp 0x4a41b
incq %r15
addq $0x4, %r13
decq %rbp
jne 0x4a3e3
movq 0x20(%rsp), %rax
incq %rax
incq 0x18(%rsp)
addq $0x4, 0x30(%rsp)
decq 0x10(%rsp)
cmpq $0x5, %rax
jne 0x4a3a6
leaq 0x5f13b(%rip), %r14     # 0xa95d1
leaq 0x7a3c0(%rsp), %r12
leaq 0x5da32(%rip), %rbp     # 0xa7ed7
leaq 0x2a0(%rsp), %rbx
xorl %eax, %eax
leal 0x1(%rax), %edx
movslq %eax, %rcx
cmpl $0x3, %eax
jg 0x4a4f2
movl 0x60(%rsp,%rcx,4), %r8d
movq %rcx, %r13
cmpl 0x64(%rsp,%r13,4), %r8d
jne 0x4a4f5
movl 0x40(%rsp,%r13,4), %edi
cmpl 0x44(%rsp,%r13,4), %edi
jne 0x4a4f5
addl %r13d, %edx
addl $0x2, %edx
movq %r13, %rdi
incq %rdi
movq %rdi, %r13
cmpq $0x4, %rdi
jne 0x4a4c2
movl $0x4, %r13d
jmp 0x4a4f5
movl %eax, %r13d
movl %r13d, %edi
subl %eax, %edi
jge 0x4a505
leal 0x1(%r13), %eax
jmp 0x4a58a
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %edi, %xmm0
addsd 0x5b005(%rip), %xmm0    # 0xa5520
divsd %xmm0, %xmm1
movsd %xmm1, 0x28(%rsp)
leal 0x1(%r13), %edx
leaq 0x80(%rsp,%rcx,4), %rcx
movq %rcx, 0x20(%rsp)
movl %edx, 0x10(%rsp)
movl %edx, %ecx
subl %eax, %ecx
movq %rcx, 0x18(%rsp)
xorl %r15d, %r15d
movq 0x20(%rsp), %rax
movl (%rax,%r15,4), %edx
incl %edx
movq %r12, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x41b0
movq %rbx, %rdi
movq %rbp, %rsi
movsd 0x28(%rsp), %xmm0
movb $0x1, %al
callq 0x41b0
movq %r12, %rdi
movq %rbx, %rsi
callq 0x33827
incq %r15
cmpl %r15d, 0x18(%rsp)
jne 0x4a546
movl 0x10(%rsp), %eax
cmpl $0x4, %r13d
jl 0x4a4af
movq 0x38(%rsp), %rax
movl (%rax), %eax
decl %eax
jmp 0x4a5a4
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x16e608, %rsp         # imm = 0x16E608
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq