// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/mlp.c
// Function: backPropMlpn_autoencoder
double backPropMlpn_autoencoder(double *Train, matrixptr weights, matrixptr hidden, matrixptr prevWeights, Mlpparameters P)
{
	matrix output_error, Y;
	matrixptr dweights;
	double sqrderror;
 int li;
	output_error = matrix_alloc(1, P.classnum);
	Y = matrix_alloc(1, P.classnum);
	dweights = allocate_weights(P, NO_INITIALIZATION, 0);/*dweights has the same dimensions as weights*/
	/*calculate hidden layers*/
	for (li = 0; li < P.layernum; li++)
  {
   if (li == 0)
     calculate_hidden_values(Train, weights[0], &hidden[0]);
   else
     calculate_hidden_values(hidden[li-1].values[0], weights[li], &hidden[li]);
  }
 calculate_output_values_reg(hidden[P.layernum-1].values[0], weights[P.layernum], &Y);
	sqrderror = calculate_error_values_autoencoder(Train, Y, &output_error); 	/*calculate error*/
	calculate_change_in_weights(Train, weights, hidden, dweights, output_error, P); 	/*calculate the change in weights*/
	update_weights(weights, dweights, prevWeights, P); 	/*add the change and momentum value to weights*/
	/*update prevWeights*/
	for (li = 0; li < (P.layernum + 1); li++)
   matrix_identical(&(prevWeights[li]), dweights[li]);
	matrix_free(output_error);
	matrix_free(Y);
	free_weights(dweights, P.layernum);
	return sqrderror;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rcx, 0xc0(%rsp)
movq %rdx, %rbp
movq %rsi, %r13
movq %rdi, %rbx
leaq 0x100(%rsp), %r14
movl (%r14), %r15d
movl $0x1, %edi
movl %r15d, %esi
callq 0x3c6e5
movq %rax, 0xb8(%rsp)
movq %rdx, 0xa8(%rsp)
movl $0x1, %edi
movl %r15d, %esi
callq 0x3c6e5
movq %rax, 0xb0(%rsp)
movq %rdx, 0x90(%rsp)
movl $0x12, %ecx
movq %rsp, %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
movl $0x2, %edi
xorl %esi, %esi
callq 0x43f69
movq %rax, %r15
movslq 0x54(%r14), %rax
movq %rax, 0x98(%rsp)
testq %rax, %rax
jle 0x44e3a
movq 0x98(%rsp), %r12
shlq $0x4, %r12
xorl %r14d, %r14d
testq %r14, %r14
je 0x44e1e
leaq (%r14,%rbp), %rcx
movq -0x8(%rbp,%r14), %rax
movq (%rax), %rdi
movq (%r13,%r14), %rsi
movq 0x8(%r13,%r14), %rdx
jmp 0x44e2c
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %rbx, %rdi
movq %rbp, %rcx
callq 0x43994
addq $0x10, %r14
cmpq %r14, %r12
jne 0x44e01
movq 0x98(%rsp), %rsi
shlq $0x4, %rsi
movq (%r13,%rsi), %rax
testl %eax, %eax
jle 0x44eb4
movq 0x8(%r13,%rsi), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
movq -0x8(%rbp,%rsi), %rsi
movq (%rsi), %rsi
movq 0x90(%rsp), %rdi
movq (%rdi), %rdi
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rdx, %r8
decq %r8
xorl %r9d, %r9d
movq (%rcx,%r9,8), %r10
movsd (%r10), %xmm0
cmpl $0x2, %edx
jl 0x44ea6
xorl %r11d, %r11d
movsd 0x8(%r10,%r11,8), %xmm1
mulsd (%rsi,%r11,8), %xmm1
addsd %xmm1, %xmm0
incq %r11
cmpq %r11, %r8
jne 0x44e8d
movsd %xmm0, (%rdi,%r9,8)
incq %r9
cmpq %rax, %r9
jne 0x44e7c
movq 0xb0(%rsp), %r12
shrq $0x20, %r12
testl %r12d, %r12d
jle 0x44f02
movq 0x90(%rsp), %rax
movq (%rax), %rax
movq 0xa8(%rsp), %rcx
movq (%rcx), %rcx
xorpd %xmm1, %xmm1
xorl %edx, %edx
movsd (%rbx,%rdx,8), %xmm0
subsd (%rax,%rdx,8), %xmm0
movsd %xmm0, (%rcx,%rdx,8)
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm1
incq %rdx
cmpq %rdx, %r12
jne 0x44ee1
jmp 0x44f06
xorpd %xmm1, %xmm1
movsd %xmm1, 0xa0(%rsp)
movl $0x12, %ecx
movq %rsp, %rdi
leaq 0x100(%rsp), %r14
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %r15, %rcx
movq 0xa8(%rsp), %rbp
movq %rbp, %r9
callq 0x4448b
movl $0x12, %ecx
movq %rsp, %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r13, %rdi
movq %r15, %rsi
movq 0xc0(%rsp), %r13
movq %r13, %rdx
callq 0x44713
movq 0x98(%rsp), %rax
testl %eax, %eax
js 0x44f99
movl %eax, %ebx
shlq $0x4, %rbx
addq $0x10, %rbx
xorl %r14d, %r14d
leaq (%r14,%r13), %rdi
movq (%r15,%r14), %rsi
movq 0x8(%r15,%r14), %rdx
callq 0x3f37d
addq $0x10, %r14
cmpq %r14, %rbx
jne 0x44f7e
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
movsd 0xa0(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0xa0(%rsp)
movq 0xb8(%rsp), %rdi
movq %rbp, %rsi
callq 0x3dbad
movq 0xb0(%rsp), %rdi
movq 0x90(%rsp), %rsi
callq 0x3dbad
leaq 0x100(%rsp), %rax
movl 0x54(%rax), %esi
movq %r15, %rdi
callq 0x442c9
movsd 0xa0(%rsp), %xmm0
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq