// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/mlp.c
// Function: testMlpnInput_cls
double testMlpnInput_cls(double *Test, matrix* testY, Mlpnetwork N, int* correctlyclassified, double* prob)
{
	/*!Last Changed 09.02.2004 Oya*/
	double sqrderror;
	matrix output_error;
	matrixptr testH;
	int li, output, classno;		
	output_error = matrix_alloc(1, N.P.classnum);
	*testY = matrix_alloc(1, N.P.classnum);
	testH = allocate_hiddens(N.P);
	/*calculate hidden layers*/
	for (li=0; li<N.P.layernum; li++)
	 {
 		if (li == 0)
  			calculate_hidden_values(Test, N.weights[0], &testH[0]);
	 	else
	  		calculate_hidden_values(testH[li-1].values[0], N.weights[li], &testH[li]);
	 }
	/*calculate outputs*/
	if (N.P.layernum == 0)
  	calculate_output_values_cls(Test, N.weights[N.P.layernum], testY);
	else
		 calculate_output_values_cls(testH[N.P.layernum-1].values[0], N.weights[N.P.layernum], testY);
	/*calculate error*/
	sqrderror = calculate_error_values_cls(Test[N.P.dimnum], *testY, &output_error);
	output = findMaxOutput(testY->values[0], N.P.classnum);
	classno = (int)Test[N.P.dimnum];
	*prob = testY->values[0][classno];
	matrix_free(output_error);
	free_hiddens(testH, N.P.layernum);	
	if (classno == output)
		 *correctlyclassified = 1;
	else
		 *correctlyclassified = 0;
	return sqrderror;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rcx, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
movq %rsi, %rbx
movq %rdi, %r12
leaq 0x110(%rsp), %rbp
leaq 0x118(%rsp), %r14
movl (%r14), %r15d
movl $0x1, %edi
movl %r15d, %esi
callq 0x3c6e5
movq %rax, 0x18(%rsp)
movq %rax, 0x38(%rsp)
movq %rdx, 0x10(%rsp)
movq %rdx, 0x40(%rsp)
movl $0x1, %edi
movl %r15d, 0x4(%rsp)
movl %r15d, %esi
callq 0x3c6e5
movq %rax, (%rbx)
movq %rbx, 0x20(%rsp)
movq %rdx, 0x8(%rbx)
leaq 0x48(%rsp), %r13
movl $0x90, %edx
movq %r13, %rdi
movq %r14, %rsi
callq 0x4310
movslq 0x54(%r13), %rbx
testq %rbx, %rbx
jle 0x450e3
movq %rbx, %rdi
shlq $0x4, %rdi
leaq 0x6225c(%rip), %rsi     # 0xa7305
movl $0x4, %edx
callq 0x390f5
movq %rax, %r14
shlq $0x2, %rbx
xorl %r15d, %r15d
movl 0x90(%rsp,%r15), %esi
movl $0x1, %edi
callq 0x3c6e5
movq %rax, (%r14,%r15,4)
movq %rdx, 0x8(%r14,%r15,4)
addq $0x4, %r15
cmpq %r15, %rbx
jne 0x450bd
jmp 0x450e6
xorl %r14d, %r14d
movslq 0x5c(%rbp), %rbx
testq %rbx, %rbx
jle 0x4513d
leaq 0x110(%rsp), %rax
movq (%rax), %rbp
movq %rbx, %r13
shlq $0x4, %r13
xorl %r15d, %r15d
testq %r15, %r15
je 0x45121
leaq (%r14,%r15), %rcx
movq -0x8(%r14,%r15), %rax
movq (%rax), %rdi
movq (%rbp,%r15), %rsi
movq 0x8(%rbp,%r15), %rdx
jmp 0x4512f
movq (%rbp), %rsi
movq 0x8(%rbp), %rdx
movq %r12, %rdi
movq %r14, %rcx
callq 0x43994
addq $0x10, %r15
cmpq %r15, %r13
jne 0x45104
testl %ebx, %ebx
je 0x4515b
shlq $0x4, %rbx
movq -0x8(%r14,%rbx), %rax
movq (%rax), %rdi
leaq 0x110(%rsp), %r13
addq (%r13), %rbx
jmp 0x4516a
leaq 0x110(%rsp), %r13
movq (%r13), %rbx
movq %r12, %rdi
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x20(%rsp), %rbp
movq %rbp, %rcx
callq 0x43e8f
movslq 0xc(%r13), %r15
movsd (%r12,%r15,8), %xmm0
movq (%rbp), %rdi
movq 0x8(%rbp), %rsi
leaq 0x38(%rsp), %rdx
callq 0x44342
movsd %xmm0, 0x8(%rsp)
movq 0x8(%rbp), %rax
movq (%rax), %rdi
movl 0x4(%rsp), %esi
callq 0x37852
movl %eax, %ebx
cvttsd2si (%r12,%r15,8), %eax
movq 0x8(%rbp), %rcx
movq (%rcx), %rcx
movslq %eax, %r15
movsd (%rcx,%r15,8), %xmm0
movq 0x28(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x3dbad
movl 0x5c(%r13), %esi
movq %r14, %rdi
callq 0x44307
xorl %eax, %eax
cmpl %r15d, %ebx
sete %al
movq 0x30(%rsp), %rcx
movl %eax, (%rcx)
movsd 0x8(%rsp), %xmm0
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq