// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/poly.c
// Function: polyfitcls
Polynomptr polyfitcls(double** data, int datasize, int degree)
{
	/*!Last Changed 26.01.2005*/
	int i, j, *array;
	double random_value, o, y, eta, *deltaw, update;
	Polynomptr p = create_polynom();
	Polynodeptr node;
 for (i = 0; i <= degree; i++)
	 {
		 random_value = produce_random_value(-0.01, 0.01);
		 add_polynode_to_polynom(p, i, random_value);
	 }
	eta = get_parameter_f("learning_rate");
	deltaw = safecalloc((degree + 1), sizeof(double), "polyfitcls", 11);
	for (j = 0; j < get_parameter_i("perceptronrun"); j++)
	 {
			array = random_array(datasize);
			for (i = 0; i < datasize; i++)
			 {
				 o = polynom_value(p, data[array[i]][0]);
					y = sigmoid(o);
     node = p->start;
					while (node)
					 {
						 update = (eta * (data[array[i]][1] - y) * fpow(data[array[i]][0], node->power) + get_parameter_f("alpha") * deltaw[node->power]);
						 node->coefficient += update;
							deltaw[node->power] = update;
						 node = node->next;
					 }
			 }
			safe_free(array);
			eta *= get_parameter_f("etadecrease");
	 }
	safe_free(deltaw);
 return p;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, %r12d
movl %esi, 0x1c(%rsp)
movq %rdi, %r14
leaq 0x4f258(%rip), %rsi     # 0xaadf2
movl $0x10, %edi
movl $0x1, %edx
callq 0x3a0e1
movq %rax, %r15
xorpd %xmm0, %xmm0
movupd %xmm0, (%rax)
testl %r12d, %r12d
js 0x5bbe5
leal 0x1(%r12), %ebx
xorl %ebp, %ebp
movsd 0x4a1f0(%rip), %xmm0    # 0xa5db8
movsd 0x4a1f0(%rip), %xmm1    # 0xa5dc0
callq 0x3af6a
movq %r15, %rdi
movl %ebp, %esi
callq 0x5a606
incl %ebp
cmpl %ebp, %ebx
jne 0x5bbc0
incl %r12d
leaq 0x49ce9(%rip), %rdi     # 0xa58d8
callq 0x549ba
movsd %xmm0, 0x8(%rsp)
movslq %r12d, %rdi
leaq 0x4f22c(%rip), %rdx     # 0xaae30
movl $0x8, %esi
movl $0xb, %ecx
callq 0x3a1fc
movq %rax, %r12
leaq 0x49cc9(%rip), %rdi     # 0xa58e6
callq 0x54920
testl %eax, %eax
jle 0x5bdbf
movl 0x1c(%rsp), %eax
movq %rax, 0x40(%rsp)
xorl %ebx, %ebx
leaq 0x49d94(%rip), %r13     # 0xa59d0
movq %r15, 0x30(%rsp)
movq %rbx, 0x38(%rsp)
movl 0x1c(%rsp), %ebx
movl %ebx, %edi
callq 0x3afe4
movq %rax, %rbp
testl %ebx, %ebx
jle 0x5bd80
xorl %ebx, %ebx
movq (%r15), %r15
testq %r15, %r15
je 0x5bcc3
movslq (%rbp,%rbx,4), %rax
movq (%r14,%rax,8), %rax
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd (%r15), %xmm0
movsd %xmm0, 0x28(%rsp)
movl 0x8(%r15), %edi
movsd 0x20(%rsp), %xmm0
callq 0x39b12
mulsd 0x28(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x10(%rsp), %xmm0
movq 0x10(%r15), %r15
testq %r15, %r15
jne 0x5bc7c
jmp 0x5bcc7
xorpd %xmm0, %xmm0
callq 0x55a80
movq 0x30(%rsp), %rax
movq (%rax), %r15
testq %r15, %r15
movsd 0x8(%rsp), %xmm2
je 0x5bd6d
movapd %xmm0, %xmm1
movsd %xmm0, 0x20(%rsp)
movsd %xmm2, 0x8(%rsp)
movslq (%rbp,%rbx,4), %rax
movq (%r14,%rax,8), %rax
movsd (%rax), %xmm0
movsd 0x8(%rax), %xmm3
subsd %xmm1, %xmm3
mulsd %xmm2, %xmm3
movsd %xmm3, 0x10(%rsp)
movl 0x8(%r15), %edi
callq 0x39b12
movsd %xmm0, 0x28(%rsp)
movq %r13, %rdi
callq 0x549ba
movsd 0x8(%rsp), %xmm2
movsd 0x20(%rsp), %xmm1
movslq 0x8(%r15), %rax
mulsd (%r12,%rax,8), %xmm0
movsd 0x28(%rsp), %xmm3
mulsd 0x10(%rsp), %xmm3
addsd %xmm0, %xmm3
movsd (%r15), %xmm0
addsd %xmm3, %xmm0
movsd %xmm0, (%r15)
movsd %xmm3, (%r12,%rax,8)
movq 0x10(%r15), %r15
testq %r15, %r15
jne 0x5bcf3
incq %rbx
cmpq 0x40(%rsp), %rbx
movq 0x30(%rsp), %r15
jne 0x5bc5e
movq %rbp, %rdi
callq 0x3a180
leaq 0x49b3d(%rip), %rdi     # 0xa58cc
callq 0x549ba
movsd 0x8(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movq 0x38(%rsp), %rbx
incl %ebx
leaq 0x49b34(%rip), %rdi     # 0xa58e6
callq 0x54920
cmpl %eax, %ebx
jl 0x5bc41
movq %r12, %rdi
callq 0x3a180
movq %r15, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq