// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/rbf.c
// Function: train_rbfnetwork_reg
Rbfnetworkptr train_rbfnetwork_reg(Instanceptr traindata, Instanceptr cvdata, Rbf_parameterptr params)
{
	/*!Last Changed 19.08.2007*/
	int i, j, *array, datasize = data_size(traindata);
	double *p, *y, squaredError, minSquaredError;
	Instanceptr inst;
	Rbfnetworkptr bestnetwork, network;
 Rbfweights prevweights, delta;
	network = allocate_rbfnetwork(params);
	initialize_rbfnetwork(network, traindata, params);
	p = safemalloc((network->hidden + 1) * sizeof(double), "train_rbfnetwork_reg", 7);
	y = safemalloc(sizeof(double), "train_rbfnetwork_reg", 8);
	params->eta = params->initialeta;
 allocate_rbfweights(&prevweights, params);
 for (i = 0; i < params->epochs; i++)
	 {
		 array = random_array(datasize);
			for (j = 0; j < datasize; j++)
			 {
				 inst = data_x(traindata, array[j]);
				 rbf_forward_propagation(network, inst, p, y);
					delta = rbf_backward_propagation(network, inst, p, y, params);
     update_rbfweights(network, delta, prevweights, params);
     copy_rbfweights(&prevweights, delta);
     free_rbfweights(delta);
			 }
			safe_free(array);
			squaredError = test_rbfnetwork_reg(network, cvdata);
		 if (i > 0)
			 {
			  if (squaredError < minSquaredError)
					 {
				   params->bestepoch = i;
				   minSquaredError = squaredError;
				   free_rbfnetwork(bestnetwork);
							bestnetwork = copy_of_rbfnetwork(network, params);
					 }
			 }
		 else
			 {
			  params->bestepoch = i;
			  minSquaredError = squaredError;
					bestnetwork = copy_of_rbfnetwork(network, params);
			 }
		 params->eta *= params->etadecrease;
	 }
	safe_free(p);
	safe_free(y);
 free_rbfweights(prevweights);
	return bestnetwork;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0x449f0
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rdi
callq 0x9d1f0
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
movq -0x8(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x9d260
movq -0x68(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
leaq 0x4dcda(%rip), %rsi     # 0xebe82
movl $0x7, %edx
callq 0x52d70
movq %rax, -0x38(%rbp)
movl $0x8, %edi
leaq 0x4dcc0(%rip), %rsi     # 0xebe82
movl $0x8, %edx
callq 0x52d70
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movsd 0x18(%rax), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, 0x28(%rax)
movq -0x18(%rbp), %rsi
leaq -0x98(%rbp), %rdi
callq 0x9d120
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x9e3eb
movl -0x2c(%rbp), %edi
callq 0x54600
movq %rax, -0x28(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x9e340
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %esi
callq 0x46c40
movq %rax, -0x58(%rbp)
movq -0x68(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0x9d4f0
movq -0x68(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %r8
movq -0x18(%rbp), %r9
leaq -0xf8(%rbp), %rdi
callq 0x9d700
leaq -0xc8(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
movl $0x30, %edx
callq 0x42b0
movq -0x68(%rbp), %rdi
movq -0x18(%rbp), %rsi
movups -0x98(%rbp), %xmm0
movups -0x88(%rbp), %xmm1
movups -0x78(%rbp), %xmm2
movq %rsp, %rax
movups %xmm2, 0x50(%rax)
movups %xmm1, 0x40(%rax)
movups %xmm0, 0x30(%rax)
movups -0xc8(%rbp), %xmm0
movups -0xb8(%rbp), %xmm1
movups -0xa8(%rbp), %xmm2
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x9da50
movups -0xc8(%rbp), %xmm0
movups -0xb8(%rbp), %xmm1
movups -0xa8(%rbp), %xmm2
movq %rsp, %rax
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0x98(%rbp), %rdi
callq 0x9d390
movups -0xc8(%rbp), %xmm0
movups -0xb8(%rbp), %xmm1
movups -0xa8(%rbp), %xmm2
movq %rsp, %rax
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x9d080
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x9e21c
movq -0x28(%rbp), %rdi
callq 0x52e80
movq -0x68(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x9e040
movsd %xmm0, -0x48(%rbp)
cmpl $0x0, -0x1c(%rbp)
jle 0x9e3a1
movsd -0x48(%rbp), %xmm1
movsd -0x50(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x9e39f
movl -0x1c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x10(%rax)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x60(%rbp), %rdi
callq 0x9d0d0
movq -0x68(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x9d3f0
movq %rax, -0x60(%rbp)
jmp 0x9e3c6
movl -0x1c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x10(%rax)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x68(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x9d3f0
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movsd 0x30(%rax), %xmm0
movq -0x18(%rbp), %rax
mulsd 0x28(%rax), %xmm0
movsd %xmm0, 0x28(%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x9e1f9
movq -0x38(%rbp), %rdi
callq 0x52e80
movq -0x40(%rbp), %rdi
callq 0x52e80
movups -0x98(%rbp), %xmm0
movups -0x88(%rbp), %xmm1
movups -0x78(%rbp), %xmm2
movq %rsp, %rax
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x9d080
movq -0x60(%rbp), %rax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nop