// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdx, %rbx
movq %rsi, 0xc8(%rsp)
movq %rdi, %r14
callq 0x2fa14
movl %eax, %ebp
movq %rbx, %rdi
callq 0x6e4d7
movq %rax, %r12
movq %rax, %rdi
movq %r14, 0xf0(%rsp)
movq %r14, %rsi
movq %rbx, %rdx
callq 0x6e521
movslq (%r12), %rax
leaq 0x8(,%rax,8), %rdi
leaq 0x3d52b(%rip), %r14     # 0xac69a
movq %r14, %rsi
movl $0x7, %edx
callq 0x390f5
movq %rax, 0x80(%rsp)
movl $0x8, %edi
movq %r14, %rsi
movl $0x8, %edx
callq 0x390f5
movq %rax, %r13
movsd 0x18(%rbx), %xmm0
movsd %xmm0, 0x28(%rbx)
leaq 0x98(%rsp), %rdi
movq %rbx, %rsi
callq 0x6e487
movq %rbx, 0x68(%rsp)
cmpl $0x0, 0xc(%rbx)
jle 0x6f448
movl %ebp, %eax
movq %rax, 0xe0(%rsp)
xorl %ecx, %ecx
movq 0x80(%rsp), %r14
movl %ebp, 0x74(%rsp)
movq %r12, 0xe8(%rsp)
movq %r13, 0xd8(%rsp)
movq %rcx, 0x90(%rsp)
movl %ebp, %edi
callq 0x39fdc
movq %rax, %rdx
testl %ebp, %ebp
movq %r13, %rbp
jle 0x6f389
xorl %r13d, %r13d
movq %rdx, 0xf8(%rsp)
movq 0x68(%rsp), %rbx
movl (%rdx,%r13,4), %esi
movq 0xf0(%rsp), %rdi
callq 0x30fe5
movq %rax, %r15
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x6e714
leaq 0x108(%rsp), %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
movq %rbp, %r8
movq %rbx, %r9
callq 0x6e83e
movups 0x98(%rsp), %xmm0
movups 0xa8(%rsp), %xmm1
movups 0xb8(%rsp), %xmm2
movups %xmm2, 0x50(%rsp)
movups %xmm1, 0x40(%rsp)
movups %xmm0, 0x30(%rsp)
movupd 0x108(%rsp), %xmm0
movupd 0x118(%rsp), %xmm1
movups 0x128(%rsp), %xmm2
movups %xmm2, 0x20(%rsp)
movupd %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x6eadc
movq 0x108(%rsp), %rbp
movq 0x110(%rsp), %r14
movq 0x118(%rsp), %r12
movq %r12, 0x78(%rsp)
movq 0x120(%rsp), %rax
movq %rax, 0x100(%rsp)
movq 0x128(%rsp), %rbx
movq 0x130(%rsp), %r15
leaq 0x98(%rsp), %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x3f37d
leaq 0xa8(%rsp), %rdi
movq %r12, %rsi
movq 0x100(%rsp), %r12
movq %r12, %rdx
callq 0x3f37d
leaq 0xb8(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x3f37d
movq %rbp, %rdi
movq 0xd8(%rsp), %rbp
movq %r14, %rsi
movq 0x80(%rsp), %r14
callq 0x3dbad
movq 0x78(%rsp), %rdi
movq %r12, %rsi
movq 0xe8(%rsp), %r12
callq 0x3dbad
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3dbad
movq 0xe0(%rsp), %rcx
movq 0xf8(%rsp), %rdx
incq %r13
cmpq %r13, %rcx
jne 0x6f212
movq %rdx, %rdi
callq 0x39194
movq %r12, %rdi
movq 0xc8(%rsp), %rsi
callq 0x6f027
movapd %xmm0, %xmm1
movq 0x90(%rsp), %rcx
testl %ecx, %ecx
je 0x6f3e0
movsd 0xd0(%rsp), %xmm0
ucomisd %xmm1, %xmm0
movq %rbp, %r13
jbe 0x6f423
movsd %xmm1, 0x78(%rsp)
movq 0x68(%rsp), %rax
movl %ecx, 0x10(%rax)
movq 0x88(%rsp), %rdi
callq 0x6e437
jmp 0x6f3f1
movsd %xmm1, 0x78(%rsp)
movq 0x68(%rsp), %rax
movl %ecx, 0x10(%rax)
movq %rbp, %r13
movq %r12, %rdi
movq 0x68(%rsp), %rsi
callq 0x6e630
movq %rax, 0x88(%rsp)
movsd 0x78(%rsp), %xmm0
movsd %xmm0, 0xd0(%rsp)
movl 0x74(%rsp), %ebp
movq 0x90(%rsp), %rcx
jmp 0x6f427
movl 0x74(%rsp), %ebp
movq 0x68(%rsp), %rax
movsd 0x30(%rax), %xmm0
mulsd 0x28(%rax), %xmm0
movsd %xmm0, 0x28(%rax)
incl %ecx
cmpl 0xc(%rax), %ecx
jl 0x6f1ea
jmp 0x6f450
movq 0x80(%rsp), %r14
movq %r14, %rdi
callq 0x39194
movq %r13, %rdi
callq 0x39194
movq 0x98(%rsp), %rdi
movq 0xa0(%rsp), %rsi
movq 0xa8(%rsp), %rbx
movq 0xb0(%rsp), %r14
movq 0xb8(%rsp), %r15
movq 0xc0(%rsp), %r12
callq 0x3dbad
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3dbad
movq %r15, %rdi
movq %r12, %rsi
callq 0x3dbad
movq 0x88(%rsp), %rax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)