// File: /workspace/github_c_makefile_star2_O3/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 0x30309
movl %eax, %ebp
movq %rbx, %rdi
callq 0x6fc47
movq %rax, %r14
movq %rax, %rdi
movq %r15, 0xd8(%rsp)
movq %r15, %rsi
movq %rbx, %rdx
callq 0x6fc92
movslq (%r14), %rax
leaq 0x8(,%rax,8), %rdi
leaq 0x3f2d7(%rip), %r15     # 0xaf749
movq %r15, %rsi
movl $0x7, %edx
callq 0x3a0e1
movq %rax, 0x70(%rsp)
movslq 0x4(%r14), %rdi
shlq $0x3, %rdi
movq %r15, %rsi
movl $0x8, %edx
callq 0x3a0e1
movq %rax, %r13
movsd 0x18(%rbx), %xmm0
movsd %xmm0, 0x28(%rbx)
leaq 0x88(%rsp), %rdi
movq %rbx, %rsi
callq 0x6fbf7
movq %rbx, 0x60(%rsp)
cmpl $0x0, 0xc(%rbx)
jle 0x7071d
movl %ebp, %eax
movq %rax, 0xc8(%rsp)
movq $0x0, 0x68(%rsp)
movq 0x70(%rsp), %r15
movq %r14, 0xd0(%rsp)
movl %ebp, 0x78(%rsp)
movq %r13, 0xc0(%rsp)
movl %ebp, %edi
callq 0x3afe4
movq %rax, %rdx
testl %ebp, %ebp
movq %r13, %rbp
jle 0x70683
xorl %r13d, %r13d
movq %rdx, 0xe0(%rsp)
movq 0x60(%rsp), %rbx
movl (%rdx,%r13,4), %esi
movq 0xd8(%rsp), %rdi
callq 0x31851
movq %rax, %r12
movq %r14, %rdi
movq %rax, %rsi
movq %r15, %rdx
movq %rbp, %rcx
callq 0x6fe88
leaq 0xf8(%rsp), %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %rcx
movq %rbp, %r8
movq %rbx, %r9
callq 0x6ffb1
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 0x7024b
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 0x406d5
leaq 0x98(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x406d5
leaq 0xa8(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x406d5
movq %rbp, %rdi
movq 0xc0(%rsp), %rbp
movq 0xf0(%rsp), %rsi
movq 0x70(%rsp), %r15
callq 0x3ed51
movq 0xe8(%rsp), %rdi
movq %r14, %rsi
movq 0xd0(%rsp), %r14
callq 0x3ed51
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3ed51
movq 0xc8(%rsp), %rcx
movq 0xe0(%rsp), %rdx
incq %r13
cmpq %r13, %rcx
jne 0x70511
movq %rbp, %r13
movq %rdx, %rdi
callq 0x3a180
movq %r14, %rdi
movq 0xb8(%rsp), %rsi
callq 0x7036e
movl %eax, %ebp
cmpl $0x0, 0x68(%rsp)
je 0x706c9
cmpl 0x7c(%rsp), %ebp
jle 0x706ee
movq 0x68(%rsp), %rax
movq 0x60(%rsp), %rcx
movl %eax, 0x10(%rcx)
movq 0x80(%rsp), %rdi
callq 0x6fba7
jmp 0x706d5
movq 0x60(%rsp), %rax
movl $0x0, 0x10(%rax)
movq %r14, %rdi
movq 0x60(%rsp), %rsi
callq 0x6fda4
movq %rax, 0x80(%rsp)
movl %ebp, 0x7c(%rsp)
movq 0x60(%rsp), %rcx
movsd 0x30(%rcx), %xmm0
mulsd 0x28(%rcx), %xmm0
movsd %xmm0, 0x28(%rcx)
movq 0x68(%rsp), %rax
incl %eax
movq %rax, 0x68(%rsp)
cmpl 0xc(%rcx), %eax
movl 0x78(%rsp), %ebp
jl 0x704f1
jmp 0x70722
movq 0x70(%rsp), %r15
movq %r15, %rdi
callq 0x3a180
movq %r13, %rdi
callq 0x3a180
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 0x3ed51
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3ed51
movq %r15, %rdi
movq %r12, %rsi
callq 0x3ed51
movq %r13, %rdi
callq 0x6fba7
movq 0x80(%rsp), %rax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq