// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/mlp.c
// Function: hessian_matrix_reg
matrix hessian_matrix_reg(Mlpnetwork N, Instanceptr train)
{
	/*!Last Changed 18.06.2005*/
	int weightcount, firstlayer, h, hprime, i, iprime, index1, index2;
	double mul, yk, zh, sum1, sum2, zhprime, xi, xiprime, vkh, vkhprime, regvalue;
	Instanceptr tmp;
	matrix result, testY, testH, inst;
	weightcount = number_of_weights_in_mlp_network(N);
	result = matrix_alloc(weightcount, weightcount);
	testH = matrix_alloc(1, N.P.hidden[0]);
	testY = matrix_alloc(1, 1);
	firstlayer = N.weights[0].row * N.weights[0].col;
	tmp = train;
	while (tmp)
	 {
		 regvalue = give_regressionvalue(tmp);
   yk = testY.values[0][0];
		 inst = instance_to_matrix(tmp);
  	calculate_hidden_values(inst.values[0], N.weights[0], &testH);
		 calculate_output_values_reg(testH.values[0], N.weights[1], &testY);
			/*Both in the second layer*/
   for (h = 0; h < N.weights[1].col; h++)
				 for (hprime = 0; hprime < N.weights[1].col; hprime++)
					 {
							zh = testH.values[0][h];
							zhprime = testH.values[0][hprime];
							index1 = firstlayer + h;
							index2 = firstlayer + hprime;
							result.values[index1][index2] += zh * zhprime;
					 }
   /*Both in the first layer*/
			index1 = 0;
			for (h = 0; h < N.weights[0].row; h++)
			 {
					zh = testH.values[0][h];
     vkh = N.weights[1].values[0][h + 1];
				 for (i = 0; i < N.weights[0].col; i++)
					 {
						 xi = inst.values[0][i];
						 index2 = 0;
						 for (hprime = 0; hprime < N.weights[0].row; hprime++)
							 {
         vkhprime = N.weights[1].values[0][hprime + 1];
								 zhprime = testH.values[0][hprime];
								 if (h == hprime)
           sum1 = (yk - regvalue) * (1 - 2 * zhprime);
									else
										 sum1 = 0;
									sum2 = zh * (1 - zh) * vkh;
								 for (iprime = 0; iprime < N.weights[0].col; iprime++)
									 { 
										 xiprime = inst.values[0][iprime];
    							mul = xi * xiprime * zhprime * (1 - zhprime) * vkhprime;
           result.values[index1][index2] += mul * (sum1 + sum2);
										 index2++;
									 }
							 }
						 index1++;
					 }
			 }
   /*One weight in each layer*/
			index1 = 0;
			for (h = 0; h < N.weights[0].row; h++)
			 {
				 zh = testH.values[0][h];
				 for (i = 0; i < N.weights[0].col; i++)
					 {
						 index2 = firstlayer;
							xi = inst.values[0][i];
							mul = xi * zh * (1 - zh);
							for (hprime = 0; hprime < N.weights[1].col; hprime++)
								{
									if (h == hprime - 1)
  									sum1 = yk - regvalue;
									else
											sum1 = 0;
									zhprime = testH.values[0][hprime];
									vkh = N.weights[1].values[0][h + 1];
									sum2 = zhprime * vkh;
         result.values[index1][index2] += mul * (sum1 + sum2);
									result.values[index2][index1] += mul * (sum1 + sum2);
									index2++;
							 }
							index1++;
					 }
			 }
   matrix_free(inst);
		 tmp = tmp->next;
	 }
	matrix_free(testY);
	matrix_free(testH);
	return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
leaq 0x10(%rbp), %rsi
movq %rsi, -0x110(%rbp)
movq %rdi, -0x18(%rbp)
movq %rsp, %rdi
movl $0x13, %ecx
rep  movsq (%rsi), %es:(%rdi)
callq 0x62150
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %edi
movl -0x1c(%rbp), %esi
callq 0x57fc0
movq %rax, %rcx
movq -0x110(%rbp), %rax
movq %rcx, -0xd8(%rbp)
movq %rdx, -0xd0(%rbp)
movq -0xd8(%rbp), %rcx
movq %rcx, -0x10(%rbp)
movq -0xd0(%rbp), %rcx
movq %rcx, -0x8(%rbp)
movl 0x50(%rax), %esi
movl $0x1, %edi
callq 0x57fc0
movq %rax, -0xe8(%rbp)
movq %rdx, -0xe0(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xe0(%rbp), %rax
movq %rax, -0xb0(%rbp)
movl $0x1, %esi
movl %esi, %edi
callq 0x57fc0
movq -0x110(%rbp), %rcx
movq %rax, -0xf8(%rbp)
movq %rdx, -0xf0(%rbp)
movq -0xf8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xf0(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq (%rcx), %rax
movl (%rax), %eax
movq (%rcx), %rcx
imull 0x4(%rcx), %eax
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x98(%rbp)
je 0x63268
movq -0x98(%rbp), %rdi
callq 0x43580
movsd %xmm0, -0x90(%rbp)
movq -0xa0(%rbp), %rax
movq (%rax), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x98(%rbp), %rdi
callq 0x43160
movq %rax, %rcx
movq -0x110(%rbp), %rax
movq %rcx, -0x108(%rbp)
movq %rdx, -0x100(%rbp)
movq -0x108(%rbp), %rcx
movq %rcx, -0xc8(%rbp)
movq -0x100(%rbp), %rcx
movq %rcx, -0xc0(%rbp)
movq -0xc0(%rbp), %rcx
movq (%rcx), %rdi
movq (%rax), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
leaq -0xb8(%rbp), %rcx
callq 0x62ac0
movq -0x110(%rbp), %rax
movq -0xb0(%rbp), %rcx
movq (%rcx), %rdi
movq (%rax), %rax
movq 0x10(%rax), %rsi
movq 0x18(%rax), %rdx
leaq -0xa8(%rbp), %rcx
callq 0x632a0
movl $0x0, -0x24(%rbp)
movq -0x110(%rbp), %rcx
movl -0x24(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x14(%rcx), %eax
jge 0x62e43
movl $0x0, -0x28(%rbp)
movq -0x110(%rbp), %rcx
movl -0x28(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x14(%rcx), %eax
jge 0x62e33
movq -0xb0(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0xb0(%rbp), %rax
movq (%rax), %rax
movslq -0x28(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x68(%rbp)
movl -0x20(%rbp), %eax
addl -0x24(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x20(%rbp), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x38(%rbp)
movsd -0x50(%rbp), %xmm0
movsd -0x68(%rbp), %xmm2
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x62da5
jmp 0x62e35
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x62d88
movl $0x0, -0x34(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x110(%rbp), %rcx
movl -0x24(%rbp), %eax
movq (%rcx), %rcx
cmpl (%rcx), %eax
jge 0x63077
movq -0x110(%rbp), %rax
movq -0xb0(%rbp), %rcx
movq (%rcx), %rcx
movslq -0x24(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movsd %xmm0, -0x50(%rbp)
movq (%rax), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x80(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x110(%rbp), %rcx
movl -0x2c(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x4(%rcx), %eax
jge 0x63067
movq -0xc0(%rbp), %rax
movq (%rax), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x70(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x110(%rbp), %rcx
movl -0x28(%rbp), %eax
movq (%rcx), %rcx
cmpl (%rcx), %eax
jge 0x63050
movq -0x110(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
movl -0x28(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x88(%rbp)
movq -0xb0(%rbp), %rax
movq (%rax), %rax
movslq -0x28(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x68(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jne 0x62f6e
movsd -0x48(%rbp), %xmm0
subsd -0x90(%rbp), %xmm0
movsd -0x68(%rbp), %xmm2
addsd %xmm2, %xmm2
movsd 0x7f0b9(%rip), %xmm1    # 0xe2018
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x62f76
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x50(%rbp), %xmm0
movsd 0x7f095(%rip), %xmm1    # 0xe2018
subsd -0x50(%rbp), %xmm1
mulsd %xmm1, %xmm0
mulsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x110(%rbp), %rcx
movl -0x30(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x4(%rcx), %eax
jge 0x63040
movq -0xc0(%rbp), %rax
movq (%rax), %rax
movslq -0x30(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x70(%rbp), %xmm0
mulsd -0x78(%rbp), %xmm0
mulsd -0x68(%rbp), %xmm0
movsd 0x7f036(%rip), %xmm1    # 0xe2018
subsd -0x68(%rbp), %xmm1
mulsd %xmm1, %xmm0
mulsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
movsd -0x58(%rbp), %xmm2
addsd -0x60(%rbp), %xmm2
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x62f9d
jmp 0x63042
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x62ee5
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x62ea9
jmp 0x63069
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x62e51
movl $0x0, -0x34(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x110(%rbp), %rcx
movl -0x24(%rbp), %eax
movq (%rcx), %rcx
cmpl (%rcx), %eax
jge 0x6323e
movq -0xb0(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x50(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x110(%rbp), %rcx
movl -0x2c(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x4(%rcx), %eax
jge 0x6322e
movl -0x20(%rbp), %eax
movl %eax, -0x38(%rbp)
movq -0xc0(%rbp), %rax
movq (%rax), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x70(%rbp), %xmm0
mulsd -0x50(%rbp), %xmm0
movsd 0x7ef19(%rip), %xmm1    # 0xe2018
subsd -0x50(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x110(%rbp), %rcx
movl -0x28(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x14(%rcx), %eax
jge 0x63217
movl -0x24(%rbp), %eax
movl -0x28(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x6314b
movsd -0x48(%rbp), %xmm0
subsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x63153
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x110(%rbp), %rax
movq -0xb0(%rbp), %rcx
movq (%rcx), %rcx
movslq -0x28(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movsd %xmm0, -0x68(%rbp)
movq (%rax), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x68(%rbp), %xmm0
mulsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x40(%rbp), %xmm0
movsd -0x58(%rbp), %xmm2
addsd -0x60(%rbp), %xmm2
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movsd -0x40(%rbp), %xmm0
movsd -0x58(%rbp), %xmm2
addsd -0x60(%rbp), %xmm2
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x34(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x63114
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x630b9
jmp 0x63230
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x63085
movq -0xc8(%rbp), %rdi
movq -0xc0(%rbp), %rsi
callq 0x59ea0
movq -0x98(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x98(%rbp)
jmp 0x62cc4
movq -0xa8(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0x59ea0
movq -0xb8(%rbp), %rdi
movq -0xb0(%rbp), %rsi
callq 0x59ea0
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rdx
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
nop