// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/model.c
// Function: mlp_model_simulation_multitest
int mlp_model_simulation_multitest(Datasetptr d, char* simulationdirectory, int maxhidden, int starthidden, int* tries)
{
 /*!Last Changed 26.05.2006 added starthidden*/
	/*!Last Changed 29.10.2005*/
	/*!Last Changed 02.06.2004*/
	char **filenames, filename[500], directory[500], tmpst[500];
	int numberofclasses, bestmodel, filecount, models[MAX_MODEL_SEARCH], i, j, tmp, m, c, *model, *modelselected, *modelstried;
 if (starthidden < 0 || starthidden > maxhidden)
   bestmodel = 0;
 else
   bestmodel = starthidden;
	filenames = (char **) safemalloc_2d(sizeof(char *), sizeof(char), MAX_MODEL_SEARCH, 500, "mlp_model_simulation", 3);
	modelselected = (int *) safecalloc(maxhidden + 1, sizeof(int), "mlp_model_simulation", 4);
	modelstried = (int *) safecalloc(maxhidden + 1, sizeof(int), "mlp_model_simulation", 5);
	modelselected[bestmodel] = 1;
	modelstried[bestmodel] = 1;
	sprintf(directory,"%s/%s", simulationdirectory, d->name);
	if (d->classno == 0)
		 numberofclasses = 1;
	else
		 numberofclasses = d->classno;
	while (1)
	 {
		 filecount = 0;
		 search_and_add_candidate_model(filenames, directory, bestmodel, models, &filecount);
		 if (bestmodel == 0)
			 {
				 if (numberofclasses <= maxhidden)
					 {
						 search_and_add_candidate_model(filenames, directory, numberofclasses, models, &filecount);
							if (2 * numberofclasses <= maxhidden)
								 search_and_add_candidate_model(filenames, directory, 2 * numberofclasses, models, &filecount);
							else
						   search_and_add_candidate_model(filenames, directory, maxhidden, models, &filecount);
					 }
					else
						 search_and_add_candidate_model(filenames, directory, maxhidden, models, &filecount);
					if ((numberofclasses + d->multifeaturecount) / 4 <= maxhidden)
					 {
						 search_and_add_candidate_model(filenames, directory, (numberofclasses + d->multifeaturecount) / 4, models, &filecount);
							if ((numberofclasses + d->multifeaturecount) / 2 <= maxhidden)
								 search_and_add_candidate_model(filenames, directory, (numberofclasses + d->multifeaturecount) / 2, models, &filecount);
							else
						   search_and_add_candidate_model(filenames, directory, maxhidden, models, &filecount);
					 }
					else
						 search_and_add_candidate_model(filenames, directory, maxhidden, models, &filecount);
			 }
			else
			 {
				 if (bestmodel + 1 <= maxhidden)
					 {
  				 search_and_add_candidate_model(filenames, directory, bestmodel + 1, models, &filecount);
							if (1.5 * bestmodel <= maxhidden)
								 search_and_add_candidate_model(filenames, directory, (int) (1.5 * bestmodel), models, &filecount);
							else
         search_and_add_candidate_model(filenames, directory, maxhidden, models, &filecount);
					 }
					else
						 search_and_add_candidate_model(filenames, directory, maxhidden, models, &filecount);
					search_and_add_candidate_model(filenames, directory, bestmodel - 1, models, &filecount);
     search_and_add_candidate_model(filenames, directory, (int) (0.5 * bestmodel), models, &filecount);
			 }
			if (filecount == 1)
				 break;
			for (i = 0; i < filecount; i++)
				 for (j = i + 1; j < filecount; j++)
						 if (models[i] > models[j])
							 {
								 tmp = models[i];
									models[i] = models[j];
									models[j] = tmp;
									strcpy(filename, filenames[i]);
									strcpy(filenames[i], filenames[j]);
									strcpy(filenames[j], filename);
							 }
			sprintf(tmpst,"-");
			for (i = 0; i < filecount; i++)
				 modelstried[models[i]] = 1;
			model = multiple_comparison(filenames, filecount, get_parameter_l("testtype"), tmpst, &m, &c, get_parameter_l("correctiontype"));
			if (models[model[0] - 1] == bestmodel)
			 {
				 safe_free(model);
				 break;
			 }
			else
			 {
				 if (modelselected[models[model[0] - 1]])
						 break;
				 bestmodel = models[model[0] - 1];
					modelselected[bestmodel] = 1;
			 }
			safe_free(model);
	 }
	*tries = 0;
	for (i = 0; i <= maxhidden; i++)
		 if (modelstried[i])
				 (*tries)++;
	free_2d((void**)filenames, MAX_MODEL_SEARCH);
	safe_free(modelselected);
	safe_free(modelstried);
 return bestmodel;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x6a0, %rsp            # imm = 0x6A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
cmpl $0x0, -0x18(%rbp)
jl 0x6825b
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jle 0x68267
movl $0x0, -0x628(%rbp)
jmp 0x68270
movl -0x18(%rbp), %eax
movl %eax, -0x628(%rbp)
movl $0x8, %edi
movl $0x1, %esi
movl $0x7, %edx
movl $0x1f4, %ecx            # imm = 0x1F4
leaq 0x7ed3f(%rip), %r8      # 0xe6fca
movl $0x3, %r9d
callq 0x53120
movq %rax, -0x28(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
movl $0x4, %esi
leaq 0x7ed1b(%rip), %rdx     # 0xe6fca
movl $0x4, %ecx
callq 0x52f40
movq %rax, -0x678(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
movl $0x4, %esi
leaq 0x7ecf5(%rip), %rdx     # 0xe6fca
movl $0x5, %ecx
callq 0x52f40
movq %rax, -0x680(%rbp)
movq -0x678(%rbp), %rax
movslq -0x628(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movq -0x680(%rbp), %rax
movslq -0x628(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
leaq -0x420(%rbp), %rdi
movq -0x10(%rbp), %rdx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
leaq 0x7bd0c(%rip), %rsi     # 0xe4036
movb $0x0, %al
callq 0x4170
movq -0x8(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x68347
movl $0x1, -0x624(%rbp)
jmp 0x68354
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x624(%rbp)
jmp 0x68356
movl $0x0, -0x62c(%rbp)
movq -0x28(%rbp), %rdi
leaq -0x420(%rbp), %rsi
movl -0x628(%rbp), %edx
leaq -0x650(%rbp), %rcx
leaq -0x62c(%rbp), %r8
callq 0x67bc0
cmpl $0x0, -0x628(%rbp)
jne 0x68532
movl -0x624(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0x68418
movq -0x28(%rbp), %rdi
leaq -0x420(%rbp), %rsi
movl -0x624(%rbp), %edx
leaq -0x650(%rbp), %rcx
leaq -0x62c(%rbp), %r8
callq 0x67bc0
movl -0x624(%rbp), %eax
shll %eax
cmpl -0x14(%rbp), %eax
jg 0x683f5
movq -0x28(%rbp), %rdi
leaq -0x420(%rbp), %rsi
movl -0x624(%rbp), %edx
shll %edx
leaq -0x650(%rbp), %rcx
leaq -0x62c(%rbp), %r8
callq 0x67bc0
jmp 0x68416
movq -0x28(%rbp), %rdi
leaq -0x420(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x650(%rbp), %rcx
leaq -0x62c(%rbp), %r8
callq 0x67bc0
jmp 0x68439
movq -0x28(%rbp), %rdi
leaq -0x420(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x650(%rbp), %rcx
leaq -0x62c(%rbp), %r8
callq 0x67bc0
movl -0x624(%rbp), %eax
movq -0x8(%rbp), %rcx
addl 0x1c0(%rcx), %eax
movl $0x4, %ecx
cltd
idivl %ecx
cmpl -0x14(%rbp), %eax
jg 0x6850c
movq -0x28(%rbp), %rdi
leaq -0x420(%rbp), %rsi
movl -0x624(%rbp), %eax
movq -0x8(%rbp), %rcx
addl 0x1c0(%rcx), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, %edx
leaq -0x650(%rbp), %rcx
leaq -0x62c(%rbp), %r8
callq 0x67bc0
movl -0x624(%rbp), %eax
movq -0x8(%rbp), %rcx
addl 0x1c0(%rcx), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl -0x14(%rbp), %eax
jg 0x684e9
movq -0x28(%rbp), %rdi
leaq -0x420(%rbp), %rsi
movl -0x624(%rbp), %eax
movq -0x8(%rbp), %rcx
addl 0x1c0(%rcx), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %edx
leaq -0x650(%rbp), %rcx
leaq -0x62c(%rbp), %r8
callq 0x67bc0
jmp 0x6850a
movq -0x28(%rbp), %rdi
leaq -0x420(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x650(%rbp), %rcx
leaq -0x62c(%rbp), %r8
callq 0x67bc0
jmp 0x6852d
movq -0x28(%rbp), %rdi
leaq -0x420(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x650(%rbp), %rcx
leaq -0x62c(%rbp), %r8
callq 0x67bc0
jmp 0x68663
movl -0x628(%rbp), %eax
addl $0x1, %eax
cmpl -0x14(%rbp), %eax
jg 0x685e5
movq -0x28(%rbp), %rdi
leaq -0x420(%rbp), %rsi
movl -0x628(%rbp), %edx
addl $0x1, %edx
leaq -0x650(%rbp), %rcx
leaq -0x62c(%rbp), %r8
callq 0x67bc0
cvtsi2sdl -0x628(%rbp), %xmm0
movsd 0x7a4fd(%rip), %xmm1    # 0xe2a78
mulsd %xmm0, %xmm1
cvtsi2sdl -0x14(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x685c2
movq -0x28(%rbp), %rdi
leaq -0x420(%rbp), %rsi
cvtsi2sdl -0x628(%rbp), %xmm1
movsd 0x7a4d3(%rip), %xmm0    # 0xe2a78
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %edx
leaq -0x650(%rbp), %rcx
leaq -0x62c(%rbp), %r8
callq 0x67bc0
jmp 0x685e3
movq -0x28(%rbp), %rdi
leaq -0x420(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x650(%rbp), %rcx
leaq -0x62c(%rbp), %r8
callq 0x67bc0
jmp 0x68606
movq -0x28(%rbp), %rdi
leaq -0x420(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x650(%rbp), %rcx
leaq -0x62c(%rbp), %r8
callq 0x67bc0
movq -0x28(%rbp), %rdi
leaq -0x420(%rbp), %rsi
movl -0x628(%rbp), %edx
subl $0x1, %edx
leaq -0x650(%rbp), %rcx
leaq -0x62c(%rbp), %r8
callq 0x67bc0
movq -0x28(%rbp), %rdi
leaq -0x420(%rbp), %rsi
cvtsi2sdl -0x628(%rbp), %xmm1
movsd 0x7a370(%rip), %xmm0    # 0xe29b8
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %edx
leaq -0x650(%rbp), %rcx
leaq -0x62c(%rbp), %r8
callq 0x67bc0
cmpl $0x1, -0x62c(%rbp)
jne 0x68671
jmp 0x68900
movl $0x0, -0x654(%rbp)
movl -0x654(%rbp), %eax
cmpl -0x62c(%rbp), %eax
jge 0x68799
movl -0x654(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x658(%rbp)
movl -0x658(%rbp), %eax
cmpl -0x62c(%rbp), %eax
jge 0x68783
movslq -0x654(%rbp), %rax
movl -0x650(%rbp,%rax,4), %eax
movslq -0x658(%rbp), %rcx
cmpl -0x650(%rbp,%rcx,4), %eax
jle 0x6876d
movslq -0x654(%rbp), %rax
movl -0x650(%rbp,%rax,4), %eax
movl %eax, -0x65c(%rbp)
movslq -0x658(%rbp), %rax
movl -0x650(%rbp,%rax,4), %ecx
movslq -0x654(%rbp), %rax
movl %ecx, -0x650(%rbp,%rax,4)
movl -0x65c(%rbp), %ecx
movslq -0x658(%rbp), %rax
movl %ecx, -0x650(%rbp,%rax,4)
leaq -0x220(%rbp), %rdi
movq -0x28(%rbp), %rax
movslq -0x654(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x4220
movq -0x28(%rbp), %rax
movslq -0x654(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x28(%rbp), %rax
movslq -0x658(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x4220
movq -0x28(%rbp), %rax
movslq -0x658(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq -0x220(%rbp), %rsi
callq 0x4220
jmp 0x6876f
movl -0x658(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x658(%rbp)
jmp 0x6869c
jmp 0x68785
movl -0x654(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x654(%rbp)
jmp 0x6867b
leaq -0x620(%rbp), %rdi
leaq 0x7d3db(%rip), %rsi     # 0xe5b82
movb $0x0, %al
callq 0x4170
movl $0x0, -0x654(%rbp)
movl -0x654(%rbp), %eax
cmpl -0x62c(%rbp), %eax
jge 0x687f4
movq -0x680(%rbp), %rax
movslq -0x654(%rbp), %rcx
movslq -0x650(%rbp,%rcx,4), %rcx
movl $0x1, (%rax,%rcx,4)
movl -0x654(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x654(%rbp)
jmp 0x687b8
movq -0x28(%rbp), %rax
movq %rax, -0x698(%rbp)
movl -0x62c(%rbp), %eax
movl %eax, -0x690(%rbp)
leaq 0x7e7af(%rip), %rdi     # 0xe6fc1
callq 0x792b0
movl %eax, -0x68c(%rbp)
leaq -0x620(%rbp), %rax
movq %rax, -0x688(%rbp)
leaq 0x79e7b(%rip), %rdi     # 0xe26ad
callq 0x792b0
movq -0x698(%rbp), %rdi
movl -0x690(%rbp), %esi
movl -0x68c(%rbp), %edx
movq -0x688(%rbp), %rcx
leaq -0x660(%rbp), %r8
leaq -0x664(%rbp), %r9
movl %eax, (%rsp)
callq 0xc3c40
movq %rax, -0x670(%rbp)
movq -0x670(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
cltq
movl -0x650(%rbp,%rax,4), %eax
cmpl -0x628(%rbp), %eax
jne 0x68899
movq -0x670(%rbp), %rdi
callq 0x52e80
jmp 0x68900
movq -0x678(%rbp), %rax
movq -0x670(%rbp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movslq -0x650(%rbp,%rcx,4), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x688bf
jmp 0x68900
movq -0x670(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
cltq
movl -0x650(%rbp,%rax,4), %eax
movl %eax, -0x628(%rbp)
movq -0x678(%rbp), %rax
movslq -0x628(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movq -0x670(%rbp), %rdi
callq 0x52e80
jmp 0x68356
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x654(%rbp)
movl -0x654(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0x68951
movq -0x680(%rbp), %rax
movslq -0x654(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x6893e
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x68940
movl -0x654(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x654(%rbp)
jmp 0x68914
movq -0x28(%rbp), %rdi
movl $0x7, %esi
callq 0x52e20
movq -0x678(%rbp), %rdi
callq 0x52e80
movq -0x680(%rbp), %rdi
callq 0x52e80
movl -0x628(%rbp), %eax
addq $0x6a0, %rsp            # imm = 0x6A0
popq %rbp
retq
nopw %cs:(%rax,%rax)