// File: /workspace/github_c_makefile_star2_O1/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, %ebx
movq %rsi, %r12
movq %rdi, %rsi
leaq 0x89ae0(%rip), %rax     # 0xd2878
movq (%rax), %rdi
callq 0x14f16
testq %rax, %rax
je 0x49194
leal 0x1(%rbx), %r13d
movq %rbx, 0x18(%rsp)
movslq %ebx, %r15
leaq 0x8(,%r15,8), %rdi
leaq 0x5e796(%rip), %rsi     # 0xa755a
movl $0x7, %edx
movq %rax, %r14
callq 0x390f5
movq %rax, %rbx
testl %r15d, %r15d
js 0x48e16
leaq 0xa0(%rsp), %r15
xorl %ebp, %ebp
movq 0x8(%r14), %rcx
movq %r15, %rdi
leaq 0x5e69b(%rip), %rsi     # 0xa748c
movq %r12, %rdx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x41b0
movq (%rbx,%rbp,8), %rdi
movq %r15, %rsi
callq 0x3a404
movq %rax, (%rbx,%rbp,8)
incq %rbp
cmpq %rbp, %r13
jne 0x48de3
movq %r14, 0x30(%rsp)
leaq 0xf44e0(%rsp), %r14
movw $0x2d, (%r14)
leaq 0x5e5d1(%rip), %rdi     # 0xa7401
callq 0x535f7
movl %eax, %ebp
leaq 0x59afa(%rip), %rdi     # 0xa2938
callq 0x535f7
movl %eax, (%rsp)
leaq 0x7c(%rsp), %r8
leaq 0x78(%rsp), %r9
movq %rbx, %rdi
movl %r13d, %esi
movl %ebp, %edx
movq %r14, %rcx
callq 0x8c4bc
movq %rax, 0x38(%rsp)
movq %rbx, %rdi
movl %r13d, %esi
callq 0x3915f
leaq 0x40(%rsp), %rbx
xorl %ebp, %ebp
movq %rax, 0x10(%rsp)
movq %r12, 0x28(%rsp)
cmpl $0x4, %ebp
ja 0x48f2a
movl %ebp, %eax
leaq 0x5e4c5(%rip), %rcx     # 0xa7358
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x30(%rsp), %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
movl 0x20(%rsp), %ecx
movq %rbx, %r8
callq 0x47b05
jmp 0x48f25
movq 0x30(%rsp), %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
movl 0x20(%rsp), %ecx
movq %rbx, %r8
movl $0x1, %r9d
jmp 0x48f05
movq 0x30(%rsp), %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
movl 0x20(%rsp), %ecx
movq %rbx, %r8
callq 0x48b48
jmp 0x48f25
movq 0x30(%rsp), %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
movl 0x20(%rsp), %ecx
movq %rbx, %r8
xorl %r9d, %r9d
callq 0x48516
jmp 0x48f25
movq 0x30(%rsp), %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
movl 0x20(%rsp), %ecx
movq %rbx, %r8
callq 0x48937
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
leal 0x1(%rax), %edx
movq 0x38(%rsp), %rdi
movl %r13d, %esi
callq 0x379c4
movl %eax, 0x60(%rsp,%rbp,4)
leaq 0x1(%rbp), %r12
movq %r13, %r15
leaq 0x7a3c0(%rsp), %r13
movq %r13, %rdi
leaq 0x5e46e(%rip), %rsi     # 0xa73ca
movl %r12d, %edx
xorl %eax, %eax
callq 0x41b0
movl 0x60(%rsp,%rbp,4), %edx
leaq 0x2a0(%rsp), %r14
movq %r14, %rdi
leaq 0x64be1(%rip), %rsi     # 0xadb5d
xorl %eax, %eax
callq 0x41b0
movq %r13, %rdi
movq %r15, %r13
movq %r14, %rsi
callq 0x32e47
leal -0x1(%r12), %eax
movl %eax, 0x80(%rsp,%rbp,4)
addq $0x4, %rbx
movq %r12, %rbp
cmpq $0x5, %r12
movq 0x28(%rsp), %r12
jne 0x48e81
leaq 0x84(%rsp), %r12
movl $0x4, %eax
movq %rax, 0x20(%rsp)
movq $0x0, 0x18(%rsp)
xorl %eax, %eax
movq %rax, 0x28(%rsp)
cmpq $0x3, %rax
ja 0x49082
movq 0x28(%rsp), %rax
leaq (%rsp,%rax,4), %rbx
addq $0x60, %rbx
leaq (%rsp,%rax,4), %r14
addq $0x40, %r14
leaq (%rsp,%rax,4), %r15
addq $0x80, %r15
movq 0x20(%rsp), %rbp
movq 0x18(%rsp), %r13
leaq 0x64(%rsp), %rax
leaq (%rax,%r13), %rsi
movl 0x64(%rsp,%r13), %eax
cmpl %eax, (%rbx)
jle 0x49042
movq %rbx, %rdi
callq 0x395a3
leaq (%r12,%r13), %rsi
movq %r15, %rdi
callq 0x395a3
leaq 0x44(%rsp), %rax
leaq (%rax,%r13), %rsi
movq %r14, %rdi
callq 0x395a3
jmp 0x49079
jne 0x49079
movl (%r14), %eax
cmpl 0x44(%rsp,%r13), %eax
jle 0x49079
leaq 0x44(%rsp), %rax
addq %r13, %rax
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
callq 0x395a3
leaq (%r12,%r13), %rsi
movq %r15, %rdi
callq 0x395a3
movq %r14, %rdi
movq 0x10(%rsp), %rsi
jmp 0x4903b
addq $0x4, %r13
decq %rbp
jne 0x49009
movq 0x28(%rsp), %rax
incq %rax
addq $0x4, 0x18(%rsp)
decq 0x20(%rsp)
cmpq $0x5, %rax
jne 0x48fd0
leaq 0x5d4fd(%rip), %r14     # 0xa65a3
xorl %eax, %eax
leal 0x1(%rax), %edx
movslq %eax, %rcx
cmpl $0x3, %eax
jg 0x490eb
movq %rcx, %r13
movl 0x60(%rsp,%r13,4), %edi
cmpl 0x64(%rsp,%r13,4), %edi
jne 0x490ee
movl 0x40(%rsp,%r13,4), %edi
cmpl 0x44(%rsp,%r13,4), %edi
jne 0x490ee
addl %r13d, %edx
addl $0x2, %edx
movq %r13, %rdi
incq %rdi
movq %rdi, %r13
cmpq $0x4, %rdi
jne 0x490b6
movl $0x4, %r13d
jmp 0x490ee
movl %eax, %r13d
movl %r13d, %ebp
subl %eax, %ebp
leaq 0x7a3c0(%rsp), %r12
jl 0x4917b
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
addsd 0x5940d(%rip), %xmm0    # 0xa2520
divsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
leaq (%rsp,%rcx,4), %rax
addq $0x80, %rax
movq %rax, 0x28(%rsp)
incl %ebp
xorl %r15d, %r15d
movq 0x28(%rsp), %rax
movl (%rax,%r15,4), %edx
incl %edx
movq %r12, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x41b0
leaq 0x2a0(%rsp), %rbx
movq %rbx, %rdi
leaq 0x5bd24(%rip), %rsi     # 0xa4e7f
movsd 0x10(%rsp), %xmm0
movb $0x1, %al
callq 0x41b0
movq %r12, %rdi
movq %rbx, %rsi
callq 0x32e47
incq %r15
cmpl %r15d, %ebp
jne 0x49131
leal 0x1(%r13), %eax
cmpl $0x4, %r13d
jl 0x490a8
movq 0x38(%rsp), %rax
movl (%rax), %eax
decl %eax
jmp 0x49199
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x16e608, %rsp         # imm = 0x16E608
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq