// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
leaq 0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl (%rax), %esi
movl $0x1, %edi
callq 0x57fc0
movq %rax, %rcx
movq -0x80(%rbp), %rax
movq %rcx, -0x68(%rbp)
movq %rdx, -0x60(%rbp)
movq -0x68(%rbp), %rcx
movq %rcx, -0x30(%rbp)
movq -0x60(%rbp), %rcx
movq %rcx, -0x28(%rbp)
movl (%rax), %esi
movl $0x1, %edi
callq 0x57fc0
movq -0x80(%rbp), %rsi
movq %rax, -0x78(%rbp)
movq %rdx, -0x70(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x38(%rbp)
xorl %eax, %eax
movq %rsp, %rdi
movl $0x12, %ecx
rep  movsq (%rsi), %es:(%rdi)
movl $0x2, %edi
xorl %esi, %esi
callq 0x634e0
movq %rax, -0x48(%rbp)
movl $0x0, -0x54(%rbp)
movq -0x80(%rbp), %rcx
movl -0x54(%rbp), %eax
cmpl 0x54(%rcx), %eax
jge 0x64a98
cmpl $0x0, -0x54(%rbp)
jne 0x64a46
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movq (%rax), %rsi
movq 0x8(%rax), %rdx
callq 0x62ac0
jmp 0x64a8b
movq -0x18(%rbp), %rax
movl -0x54(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movslq -0x54(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq -0x18(%rbp), %rcx
movslq -0x54(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rax), %rsi
movq 0x8(%rax), %rdx
callq 0x62ac0
jmp 0x64a8d
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x64a1a
movq -0x80(%rbp), %rcx
movq -0x18(%rbp), %rax
movl 0x54(%rcx), %edx
subl $0x1, %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq 0x8(%rax), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movslq 0x54(%rcx), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
leaq -0x40(%rbp), %rcx
callq 0x632a0
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq -0x30(%rbp), %rcx
callq 0x63d50
movq -0x80(%rbp), %rsi
movsd %xmm0, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x18(%rbp), %rdx
movq -0x48(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x30(%rbp), %r8
movq -0x28(%rbp), %r9
movq %rsp, %rdi
movl $0x12, %ecx
rep  movsq (%rsi), %es:(%rdi)
movq -0xa8(%rbp), %rsi
movq -0xa0(%rbp), %rdi
movq -0x98(%rbp), %rcx
callq 0x63e10
movq -0x80(%rbp), %rsi
movq -0x10(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x20(%rbp), %rdx
movq %rsp, %rdi
movl $0x12, %ecx
rep  movsq (%rsi), %es:(%rdi)
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdi
callq 0x64250
movl $0x0, -0x54(%rbp)
movq -0x80(%rbp), %rcx
movl -0x54(%rbp), %eax
movl 0x54(%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x64bcf
movq -0x20(%rbp), %rdi
movslq -0x54(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
movq -0x48(%rbp), %rax
movslq -0x54(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
callq 0x5c040
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x64b89
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x59ea0
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x59ea0
movq -0x80(%rbp), %rax
movq -0x48(%rbp), %rdi
movl 0x54(%rax), %esi
callq 0x63ae0
movsd -0x50(%rbp), %xmm0
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
nopw (%rax,%rax)