// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/rbf.c
// Function: train_rbfnetwork_cls
Rbfnetworkptr train_rbfnetwork_cls(Instanceptr traindata, Instanceptr cvdata, Rbf_parameterptr params)
{
	/*!Last Changed 19.08.2007*/
	int i, j, *array, performance, bestperformance, datasize = data_size(traindata);
	double *p, *y;
	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_cls", 7);
	y = safemalloc(network->output * sizeof(double), "train_rbfnetwork_cls", 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);
			performance = test_rbfnetwork_cls(network, cvdata);
		 if (i > 0)
			 {
			  if (performance > bestperformance)
					 {
				   params->bestepoch = i;
				   bestperformance = performance;
				   free_rbfnetwork(bestnetwork);
							bestnetwork = copy_of_rbfnetwork(network, params);
					 }
			 }
		 else
			 {
			  params->bestepoch = i;
			  bestperformance = performance;
					bestnetwork = copy_of_rbfnetwork(network, params);
			 }
		 params->eta *= params->etadecrease;
	 }
	safe_free(p);
	safe_free(y);
 free_rbfweights(prevweights);
 free_rbfnetwork(network);
	return bestnetwork;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rdx, %rbx
movq %rsi, 0xb8(%rsp)
movq %rdi, %r15
callq 0x2fa14
movl %eax, %ebp
movq %rbx, %rdi
callq 0x6e4d7
movq %rax, %r14
movq %rax, %rdi
movq %r15, 0xd8(%rsp)
movq %r15, %rsi
movq %rbx, %rdx
callq 0x6e521
movslq (%r14), %rax
leaq 0x8(,%rax,8), %rdi
leaq 0x3d96c(%rip), %r15     # 0xac671
movq %r15, %rsi
movl $0x7, %edx
callq 0x390f5
movq %rax, 0x68(%rsp)
movslq 0x4(%r14), %rdi
shlq $0x3, %rdi
movq %r15, %rsi
movl $0x8, %edx
callq 0x390f5
movq %rax, %r13
movsd 0x18(%rbx), %xmm0
movsd %xmm0, 0x28(%rbx)
leaq 0x88(%rsp), %rdi
movq %rbx, %rsi
callq 0x6e487
movq %rbx, 0x60(%rsp)
cmpl $0x0, 0xc(%rbx)
jle 0x6efa5
movl %ebp, %eax
movq %rax, 0xc8(%rsp)
xorl %ecx, %ecx
movq 0x68(%rsp), %r15
movq %r14, 0xd0(%rsp)
movl %ebp, 0x70(%rsp)
movq %r13, 0xc0(%rsp)
movq %rcx, 0x80(%rsp)
movl %ebp, %edi
callq 0x39fdc
movq %rax, %rdx
testl %ebp, %ebp
movq %r13, %rbp
jle 0x6ef17
xorl %r13d, %r13d
movq %rdx, 0xe0(%rsp)
movq 0x60(%rsp), %rbx
movl (%rdx,%r13,4), %esi
movq 0xd8(%rsp), %rdi
callq 0x30fe5
movq %rax, %r12
movq %r14, %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %rbp, %rcx
callq 0x6e714
leaq 0xf8(%rsp), %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %rcx
movq %rbp, %r8
movq %rbx, %r9
callq 0x6e83e
movups 0x88(%rsp), %xmm0
movups 0x98(%rsp), %xmm1
movups 0xa8(%rsp), %xmm2
movups %xmm2, 0x50(%rsp)
movups %xmm1, 0x40(%rsp)
movups %xmm0, 0x30(%rsp)
movupd 0xf8(%rsp), %xmm0
movups 0x108(%rsp), %xmm1
movups 0x118(%rsp), %xmm2
movups %xmm2, 0x20(%rsp)
movups %xmm1, 0x10(%rsp)
movupd %xmm0, (%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x6eadc
movq 0xf8(%rsp), %rbp
movq 0x100(%rsp), %rdx
movq %rdx, 0xf0(%rsp)
movq 0x108(%rsp), %r15
movq %r15, 0xe8(%rsp)
movq 0x110(%rsp), %r14
movq 0x118(%rsp), %rbx
movq 0x120(%rsp), %r12
leaq 0x88(%rsp), %rdi
movq %rbp, %rsi
callq 0x3f37d
leaq 0x98(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x3f37d
leaq 0xa8(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x3f37d
movq %rbp, %rdi
movq 0xc0(%rsp), %rbp
movq 0xf0(%rsp), %rsi
movq 0x68(%rsp), %r15
callq 0x3dbad
movq 0xe8(%rsp), %rdi
movq %r14, %rsi
movq 0xd0(%rsp), %r14
callq 0x3dbad
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3dbad
movq 0xc8(%rsp), %rcx
movq 0xe0(%rsp), %rdx
incq %r13
cmpq %r13, %rcx
jne 0x6eda5
movq %rbp, %r13
movq %rdx, %rdi
callq 0x39194
movq %r14, %rdi
movq 0xb8(%rsp), %rsi
callq 0x6ec01
movl %eax, %ebp
movq 0x80(%rsp), %rcx
testl %ecx, %ecx
je 0x6ef5a
cmpl 0x74(%rsp), %ebp
jle 0x6ef80
movq 0x60(%rsp), %rax
movl %ecx, 0x10(%rax)
movq 0x78(%rsp), %rdi
callq 0x6e437
jmp 0x6ef62
movq 0x60(%rsp), %rax
movl %ecx, 0x10(%rax)
movq %r14, %rdi
movq 0x60(%rsp), %rsi
callq 0x6e630
movq %rax, 0x78(%rsp)
movl %ebp, 0x74(%rsp)
movq 0x80(%rsp), %rcx
movq 0x60(%rsp), %rax
movsd 0x30(%rax), %xmm0
mulsd 0x28(%rax), %xmm0
movsd %xmm0, 0x28(%rax)
incl %ecx
cmpl 0xc(%rax), %ecx
movl 0x70(%rsp), %ebp
jl 0x6ed7d
jmp 0x6efaa
movq 0x68(%rsp), %r15
movq %r15, %rdi
callq 0x39194
movq %r13, %rdi
callq 0x39194
movq 0x88(%rsp), %rdi
movq 0x90(%rsp), %rsi
movq %r14, %r13
movq 0x98(%rsp), %rbx
movq 0xa0(%rsp), %r14
movq 0xa8(%rsp), %r15
movq 0xb0(%rsp), %r12
callq 0x3dbad
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3dbad
movq %r15, %rdi
movq %r12, %rsi
callq 0x3dbad
movq %r13, %rdi
callq 0x6e437
movq 0x78(%rsp), %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq