// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/model.c
// Function: mlp_model_selection_aic
Mlpnetwork mlp_model_selection_aic(Instanceptr data, Instanceptr validation, double alpha, int maxhidden, int problemtype)
{
	/*!Last Changed 25.06.2005*/
 int i, hiddennodes[1] = {1};
	Mlpparameters mlpparams;
	matrix train, cv, hessian, eigenvectors;
	Mlpnetwork neuralnetwork, best;
	double* eigenvalues, d, aicerror, loglikelihood, trainerror, besterror = +INT_MAX;
	train = instancelist_to_matrix(data, problemtype, -1, MULTIVARIATE_LINEAR);
	cv = instancelist_to_matrix(validation, problemtype, -1, MULTIVARIATE_LINEAR);
 if (current_dataset->classno == 0)
	  mlpparams = prepare_Mlpparameters(data, validation, 1, alpha, 1, hiddennodes, 0, 0.0, 0.0, 0, REGRESSION);
 else
   mlpparams = prepare_Mlpparameters(data, validation, 1, alpha, 1, hiddennodes, 0, 0.0, 0.0, 0, CLASSIFICATION);
	for (i = 1; i <= maxhidden; i++)
	 {
			mlpparams.hidden[0] = i;
			neuralnetwork = mlp_network_train_general(train, cv, &mlpparams);
			if (current_dataset->classno == 0)
			 {
     hessian = hessian_matrix_reg(neuralnetwork, data);
					trainerror = test_mlp_network(neuralnetwork, train);
			 }
			else
			 {
     hessian = hessian_matrix_cls(neuralnetwork, data);
			  loglikelihood = log_likelihood_of_mlp_network(neuralnetwork, train);
			 }
   eigenvalues = find_eigenvalues_eigenvectors_symmetric(&eigenvectors, hessian);
			matrix_free(eigenvectors);
			d = number_of_free_parameters_of_hessian(eigenvalues, hessian.row, alpha);
			if (current_dataset->classno == 0)
				 aicerror = aic_squared_error(trainerror, d, train.row);
			else
  			aicerror = aic_loglikelihood(loglikelihood, d);
			if (i != 1 && aicerror < besterror)
				 free_mlpnnetwork(&best);
			if (i == 1 || aicerror < besterror)
			 {
					best = copy_of_Mlpnetwork(neuralnetwork);
					besterror = aicerror;
			 }
			free_mlpnnetwork(&neuralnetwork);
			matrix_free(hessian);
	 }
	matrix_free(train);
	matrix_free(cv);
	return best;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x530, %rsp            # imm = 0x530
movq %rdi, -0x460(%rbp)
movq %rdi, -0x458(%rbp)
movq %rsi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl 0x81235(%rip), %eax     # 0xe7168
movl %eax, -0x28(%rbp)
movsd 0x7c0d2(%rip), %xmm0    # 0xe2010
movsd %xmm0, -0x1c0(%rbp)
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
callq 0x44720
movq %rax, -0x1d0(%rbp)
movq %rdx, -0x1c8(%rbp)
movq -0x1d0(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x1c8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x10(%rbp), %rdi
movl -0x20(%rbp), %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0xfffffffe, %ecx       # imm = 0xFFFFFFFE
callq 0x44720
movq %rax, -0x1e0(%rbp)
movq %rdx, -0x1d8(%rbp)
movq -0x1e0(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x1d8(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq 0x9f873(%rip), %rax     # 0x105840
movq (%rax), %rax
cmpl $0x0, 0x10(%rax)
jne 0x66035
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
movsd -0x18(%rbp), %xmm0
leaq -0x28(%rbp), %r9
leaq -0x270(%rbp), %rdi
movl $0x1, %r8d
xorl %eax, %eax
xorps %xmm2, %xmm2
movl %r8d, %ecx
movl $0x0, (%rsp)
movaps %xmm2, %xmm1
movl $0x0, 0x8(%rsp)
movl $0x1, 0x10(%rsp)
callq 0x61f60
leaq -0xb8(%rbp), %rdi
leaq -0x270(%rbp), %rsi
movl $0x90, %edx
callq 0x42b0
jmp 0x66092
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
movsd -0x18(%rbp), %xmm0
leaq -0x28(%rbp), %r9
leaq -0x300(%rbp), %rdi
movl $0x1, %r8d
xorl %eax, %eax
xorps %xmm2, %xmm2
movl %r8d, %ecx
movl $0x0, (%rsp)
movaps %xmm2, %xmm1
movl $0x0, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x61f60
leaq -0xb8(%rbp), %rdi
leaq -0x300(%rbp), %rsi
movl $0x90, %edx
callq 0x42b0
movl $0x1, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x6639f
movl -0x24(%rbp), %eax
movl %eax, -0x70(%rbp)
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
movq -0xd8(%rbp), %rcx
movq -0xd0(%rbp), %r8
leaq -0x398(%rbp), %rdi
leaq -0xb8(%rbp), %r9
callq 0x61660
leaq -0x190(%rbp), %rdi
leaq -0x398(%rbp), %rsi
movl $0x98, %edx
callq 0x42b0
leaq 0x9f747(%rip), %rax     # 0x105840
movq (%rax), %rax
cmpl $0x0, 0x10(%rax)
jne 0x661a7
movq -0x8(%rbp), %rax
movq %rax, -0x478(%rbp)
movq %rsp, %rdi
movl $0x13, %ecx
leaq -0x190(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq -0x478(%rbp), %rdi
callq 0x62bd0
movq %rax, -0x3a8(%rbp)
movq %rdx, -0x3a0(%rbp)
movq -0x3a8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x3a0(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0x468(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x470(%rbp)
movq %rsp, %rdi
movl $0x13, %ecx
leaq -0x190(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq -0x470(%rbp), %rsi
movq -0x468(%rbp), %rdi
callq 0x61da0
movsd %xmm0, -0x1b8(%rbp)
jmp 0x66243
movq -0x8(%rbp), %rax
movq %rax, -0x490(%rbp)
movq %rsp, %rdi
movl $0x13, %ecx
leaq -0x190(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq -0x490(%rbp), %rdi
callq 0x621c0
movq %rax, -0x3b8(%rbp)
movq %rdx, -0x3b0(%rbp)
movq -0x3b8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x3b0(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0x480(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x488(%rbp)
movq %rsp, %rdi
movl $0x13, %ecx
leaq -0x190(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq -0x488(%rbp), %rsi
movq -0x480(%rbp), %rdi
callq 0x61c70
movsd %xmm0, -0x1b0(%rbp)
movq -0xe8(%rbp), %rsi
movq -0xe0(%rbp), %rdx
leaq -0xf8(%rbp), %rdi
callq 0x5fb50
movq %rax, -0x198(%rbp)
movq -0xf8(%rbp), %rdi
movq -0xf0(%rbp), %rsi
callq 0x59ea0
movq -0x198(%rbp), %rdi
movl -0xe8(%rbp), %esi
movsd -0x18(%rbp), %xmm0
callq 0x65c40
movsd %xmm0, -0x1a0(%rbp)
leaq 0x9f5a3(%rip), %rax     # 0x105840
movq (%rax), %rax
cmpl $0x0, 0x10(%rax)
jne 0x662cb
movsd -0x1b8(%rbp), %xmm0
movsd -0x1a0(%rbp), %xmm1
movl -0xc8(%rbp), %edi
callq 0x663e0
movsd %xmm0, -0x1a8(%rbp)
jmp 0x662e8
movsd -0x1b0(%rbp), %xmm0
movsd -0x1a0(%rbp), %xmm1
callq 0x66430
movsd %xmm0, -0x1a8(%rbp)
cmpl $0x1, -0x24(%rbp)
je 0x66310
movsd -0x1a8(%rbp), %xmm1
movsd -0x1c0(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x66310
movq -0x460(%rbp), %rdi
callq 0x63ab0
cmpl $0x1, -0x24(%rbp)
je 0x6632c
movsd -0x1a8(%rbp), %xmm1
movsd -0x1c0(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x66372
movq %rsp, %rdi
movl $0x13, %ecx
leaq -0x190(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq -0x450(%rbp), %rdi
callq 0x61510
movq -0x460(%rbp), %rdi
leaq -0x450(%rbp), %rsi
movl $0x98, %edx
callq 0x42b0
movsd -0x1a8(%rbp), %xmm0
movsd %xmm0, -0x1c0(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x63ab0
movq -0xe8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
callq 0x59ea0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x66099
movq -0xc8(%rbp), %rdi
movq -0xc0(%rbp), %rsi
callq 0x59ea0
movq -0xd8(%rbp), %rdi
movq -0xd0(%rbp), %rsi
callq 0x59ea0
movq -0x458(%rbp), %rax
addq $0x530, %rsp            # imm = 0x530
popq %rbp
retq
nopw %cs:(%rax,%rax)