// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/mlp.c
// Function: mlpn_general
Mlpnetwork mlpn_general(matrix Train, matrix Validation, Mlpparametersptr P, SUPERVISED_ALGORITHM_TYPE algorithm_type)
{
	int iindex, tr, k;
	double sqrdError = 0, minError, cvError, loglikelihood;
	int *I;
	Mlpnetwork nN, minN;
	matrixptr prevWeights;
	matrixptr H;
	nN = allocate_mlpnnetwork(*P);
	prevWeights = allocate_weights(*P, INITIAL_VALUE, 0);
	H = allocate_hiddens(*P);
	P->eta = P->initialeta;
	for (tr = 0; tr < P->epochs; tr++)
  {
   sqrdError = 0;
   I = random_array(P->inputnum);
   for (k = 0; k < P->inputnum; k++)
    {
     iindex = I[k];
     switch (algorithm_type)
      {
       case CLASSIFICATION:
       default            :sqrdError = sqrdError + backPropMlpn_cls(Train.values[iindex], nN.weights, H, prevWeights, *P);
                           break;
       case REGRESSION    :sqrdError = sqrdError + backPropMlpn_reg(Train.values[iindex], nN.weights, H, prevWeights, *P);
                           break;
       case AUTOENCODER   :sqrdError = sqrdError + backPropMlpn_autoencoder(Train.values[iindex], nN.weights, H, prevWeights, *P);
                           break;
      }
    }
   safe_free(I);
   sqrdError = sqrdError / P->inputnum;
   P->sqrderror = sqrdError;
   P->eta = P->eta * P->etadecrease;
   /*check validation data and update the best network if necessary*/
   nN.P = *P;
   switch (algorithm_type)
    {
     case CLASSIFICATION:
     default            :cvError = Validation.row - testMlpnNetwork_cls(Validation, nN, &loglikelihood);
                         break;
     case REGRESSION    :cvError = testMlpnNetwork_reg(Validation, nN);
                         break;
     case AUTOENCODER   :cvError = testMlpnNetwork_autoencoder(Validation, nN);
                         break;
    }
   if (tr > 0)
    {
     if (cvError < minError)
      {
       P->bestepoch = tr;
       minError = cvError;
       free_mlpnnetwork(&minN);
       minN = copy_of_Mlpnetwork(nN);
      }
    }
   else
    {
     P->bestepoch = tr;
     minError = cvError;
     minN = copy_of_Mlpnetwork(nN);
    }
  }
	free_weights(prevWeights, P->layernum);
	free_hiddens(H, P->layernum);
	free_mlpnnetwork(&nN);
 return minN;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x420, %rsp            # imm = 0x420
movq %rdi, -0x2e0(%rbp)
movq %rdi, -0x2d8(%rbp)
movl 0x10(%rbp), %eax
movq %rsi, -0x10(%rbp)
movq %rdx, -0x8(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x18(%rbp)
movq %r9, -0x28(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x28(%rbp), %rsi
movq %rsp, %rdi
movl $0x12, %ecx
rep  movsq (%rsi), %es:(%rdi)
leaq -0x1a0(%rbp), %rdi
callq 0x61600
leaq -0xf8(%rbp), %rdi
leaq -0x1a0(%rbp), %rsi
movl $0x98, %edx
callq 0x42b0
movq -0x28(%rbp), %rsi
xorl %eax, %eax
movq %rsp, %rdi
movl $0x12, %ecx
rep  movsq (%rsi), %es:(%rdi)
movl $0x1, %edi
xorl %esi, %esi
callq 0x634e0
movq %rax, -0x100(%rbp)
movq -0x28(%rbp), %rsi
movq %rsp, %rdi
movl $0x12, %ecx
rep  movsq (%rsi), %es:(%rdi)
callq 0x63970
movq %rax, -0x108(%rbp)
movq -0x28(%rbp), %rax
movsd 0x20(%rax), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x38(%rax)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jge 0x61c23
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x28(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x54600
movq %rax, -0x60(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x619ed
movq -0x60(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
movl 0x10(%rbp), %eax
movl %eax, -0x2e4(%rbp)
testl %eax, %eax
je 0x61851
jmp 0x6182f
movl -0x2e4(%rbp), %eax
subl $0x1, %eax
je 0x618d8
jmp 0x61840
movl -0x2e4(%rbp), %eax
subl $0x2, %eax
je 0x6195d
jmp 0x61853
jmp 0x61853
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x2f0(%rbp)
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x300(%rbp)
movq -0xf8(%rbp), %rax
movq %rax, -0x308(%rbp)
movq -0x108(%rbp), %rdx
movq -0x100(%rbp), %rax
movq %rax, -0x2f8(%rbp)
movq -0x28(%rbp), %rsi
movq %rsp, %rdi
movl $0x12, %ecx
rep  movsq (%rsi), %es:(%rdi)
movq -0x308(%rbp), %rsi
movq -0x300(%rbp), %rdi
movq -0x2f8(%rbp), %rcx
callq 0x643e0
movaps %xmm0, %xmm1
movsd -0x2f0(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
jmp 0x619dd
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x310(%rbp)
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x320(%rbp)
movq -0xf8(%rbp), %rax
movq %rax, -0x328(%rbp)
movq -0x108(%rbp), %rdx
movq -0x100(%rbp), %rax
movq %rax, -0x318(%rbp)
movq -0x28(%rbp), %rsi
movq %rsp, %rdi
movl $0x12, %ecx
rep  movsq (%rsi), %es:(%rdi)
movq -0x328(%rbp), %rsi
movq -0x320(%rbp), %rdi
movq -0x318(%rbp), %rcx
callq 0x646b0
movaps %xmm0, %xmm1
movsd -0x310(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
jmp 0x619dd
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x330(%rbp)
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x340(%rbp)
movq -0xf8(%rbp), %rax
movq %rax, -0x348(%rbp)
movq -0x108(%rbp), %rdx
movq -0x100(%rbp), %rax
movq %rax, -0x338(%rbp)
movq -0x28(%rbp), %rsi
movq %rsp, %rdi
movl $0x12, %ecx
rep  movsq (%rsi), %es:(%rdi)
movq -0x348(%rbp), %rsi
movq -0x340(%rbp), %rdi
movq -0x338(%rbp), %rcx
callq 0x64980
movaps %xmm0, %xmm1
movsd -0x330(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
jmp 0x619df
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x61802
movq -0x60(%rbp), %rdi
callq 0x52e80
movsd -0x40(%rbp), %xmm0
movq -0x28(%rbp), %rax
cvtsi2sdl 0x8(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x88(%rax)
movq -0x28(%rbp), %rax
movsd 0x38(%rax), %xmm0
movsd 0x40(%rax), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rax)
leaq -0xf0(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl $0x90, %edx
callq 0x42b0
movl 0x10(%rbp), %eax
movl %eax, -0x34c(%rbp)
testl %eax, %eax
je 0x61a77
jmp 0x61a59
movl -0x34c(%rbp), %eax
subl $0x1, %eax
je 0x61ad9
jmp 0x61a66
movl -0x34c(%rbp), %eax
subl $0x2, %eax
je 0x61b1b
jmp 0x61a79
jmp 0x61a79
movl -0x20(%rbp), %eax
movl %eax, -0x350(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x358(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x360(%rbp)
movq %rsp, %rdi
movl $0x13, %ecx
leaq -0xf8(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq -0x360(%rbp), %rsi
movq -0x358(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x61cd0
movl %eax, %ecx
movl -0x350(%rbp), %eax
subl %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x50(%rbp)
jmp 0x61b5b
movq -0x20(%rbp), %rax
movq %rax, -0x368(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x370(%rbp)
movq %rsp, %rdi
movl $0x13, %ecx
leaq -0xf8(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq -0x370(%rbp), %rsi
movq -0x368(%rbp), %rdi
callq 0x61e80
movsd %xmm0, -0x50(%rbp)
jmp 0x61b5b
movq -0x20(%rbp), %rax
movq %rax, -0x378(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x380(%rbp)
movq %rsp, %rdi
movl $0x13, %ecx
leaq -0xf8(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq -0x380(%rbp), %rsi
movq -0x378(%rbp), %rdi
callq 0x652c0
movsd %xmm0, -0x50(%rbp)
cmpl $0x0, -0x30(%rbp)
jle 0x61bc9
movsd -0x50(%rbp), %xmm1
movsd -0x48(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x61bc7
movq -0x2e0(%rbp), %rdi
movl -0x30(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x18(%rax)
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
callq 0x63ab0
movq %rsp, %rdi
movl $0x13, %ecx
leaq -0xf8(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq -0x238(%rbp), %rdi
callq 0x61510
movq -0x2e0(%rbp), %rdi
leaq -0x238(%rbp), %rsi
movl $0x98, %edx
callq 0x42b0
jmp 0x61c13
movl -0x30(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x18(%rax)
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movq %rsp, %rdi
movl $0x13, %ecx
leaq -0xf8(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq -0x2d0(%rbp), %rdi
callq 0x61510
movq -0x2e0(%rbp), %rdi
leaq -0x2d0(%rbp), %rsi
movl $0x98, %edx
callq 0x42b0
jmp 0x61c15
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x617d3
movq -0x100(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x54(%rax), %esi
callq 0x63ae0
movq -0x108(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x54(%rax), %esi
callq 0x63b40
leaq -0xf8(%rbp), %rdi
callq 0x63ab0
movq -0x2d8(%rbp), %rax
addq $0x420, %rsp            # imm = 0x420
popq %rbp
retq
nopw %cs:(%rax,%rax)