// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/mlp.c
// Function: hessian_matrix_cls
matrix hessian_matrix_cls(Mlpnetwork N, Instanceptr train)
{
	/*!Last Changed 18.06.2005*/
	int weightcount, firstlayer, k, h, hprime, i, iprime, index1, index2, classno;
	double mul, yk, zh, sum1, sum2, zhprime, xi, xiprime, vkh, vkhprime;
	Instanceptr tmp;
	matrix result, testY, testH, inst;
	weightcount = number_of_weights_in_mlp_network(N);
	result = matrix_alloc(weightcount, weightcount);
	testY = matrix_alloc(1, N.P.classnum);
	testH = matrix_alloc(1, N.P.hidden[0]);
	firstlayer = N.weights[0].row * N.weights[0].col;
	tmp = train;
	while (tmp)
	 {
		 classno = give_classno(tmp);
		 inst = instance_to_matrix(tmp);
  	calculate_hidden_values(inst.values[0], N.weights[0], &testH);
		 calculate_output_values_cls(testH.values[0], N.weights[1], &testY);
			/*Both in the second layer*/
   for (k = 0; k < N.weights[1].row; k++)
			 {
					yk = testY.values[0][k];
				 for (h = 0; h < N.weights[1].col; h++)
					 {
						 zh = testH.values[0][h];
  					for (hprime = 0; hprime < N.weights[1].col; hprime++)
							 {
									zhprime = testH.values[0][hprime];
									index1 = firstlayer + k * N.weights[1].col + h;
									index2 = firstlayer + k * N.weights[1].col + hprime;
									result.values[index1][index2] += zh * zhprime * yk * (1 - yk);
							 }
					 }
			 }
   /*Both in the first 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++)
					 {
						 xi = inst.values[0][i];
						 index2 = 0;
						 for (hprime = 0; hprime < N.weights[0].row; hprime++)
							 {
								 zhprime = testH.values[0][hprime];
								 if (h == hprime)
									 {
           sum1 = 0;
											for (k = 0; k < N.weights[1].row; k++)
											 {
												 vkhprime = N.weights[1].values[k][hprime + 1];
													yk = testY.values[0][k];
												 if (k == classno)
														 sum1 += vkhprime * (yk - 1);
													else
														 sum1 += vkhprime * yk;
											 }
											sum1 = sum1 * (1 - 2 * zhprime);
									 }
									else
										 sum1 = 0;
									sum2 = 0;
         for (k = 0; k < N.weights[1].row; k++)
									 {
										 vkh = N.weights[1].values[k][h + 1];
											vkhprime = N.weights[1].values[k][hprime + 1];
											yk = testY.values[0][k];
											sum2 += vkh * vkhprime * yk * (1 - yk);
									 }
         sum2 = zh * (1 - zh) * sum2;
								 for (iprime = 0; iprime < N.weights[0].col; iprime++)
									 { 
										 xiprime = inst.values[0][iprime];
    							mul = xi * xiprime * zhprime * (1 - zhprime);
           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 (k = 0; k < N.weights[1].row; k++)
							 {
								 yk = testY.values[0][k];
								 for (hprime = 0; hprime < N.weights[1].col; hprime++)
									 {
										 if (h == hprime - 1)
												 if (k == classno)
  												 sum1 = yk - 1;
													else
														 sum1 = yk;
											else
											  sum1 = 0;
											zhprime = testH.values[0][hprime];
											vkh = N.weights[1].values[k][h + 1];
											sum2 = zhprime * vkh * yk * (1 - yk);
           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 0x8(%rax), %esi
movl $0x1, %edi
callq 0x57fc0
movq %rax, %rcx
movq -0x110(%rbp), %rax
movq %rcx, -0xe8(%rbp)
movq %rdx, -0xe0(%rbp)
movq -0xe8(%rbp), %rcx
movq %rcx, -0xa8(%rbp)
movq -0xe0(%rbp), %rcx
movq %rcx, -0xa0(%rbp)
movl 0x50(%rax), %esi
movl $0x1, %edi
callq 0x57fc0
movq -0x110(%rbp), %rcx
movq %rax, -0xf8(%rbp)
movq %rdx, -0xf0(%rbp)
movq -0xf8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xf0(%rbp), %rax
movq %rax, -0xb0(%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 0x62a89
movq -0x98(%rbp), %rdi
callq 0x43530
movl %eax, -0x40(%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 0x62b90
movl $0x0, -0x24(%rbp)
movq -0x110(%rbp), %rcx
movl -0x24(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x10(%rcx), %eax
jge 0x624a0
movq -0xa0(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x50(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x110(%rbp), %rcx
movl -0x28(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x14(%rcx), %eax
jge 0x62490
movq -0xb0(%rbp), %rax
movq (%rax), %rax
movslq -0x28(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x58(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x110(%rbp), %rcx
movl -0x2c(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x14(%rcx), %eax
jge 0x62480
movq -0x110(%rbp), %rdx
movq -0xb0(%rbp), %rax
movq (%rax), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x70(%rbp)
movl -0x20(%rbp), %eax
movl -0x24(%rbp), %ecx
movq (%rdx), %rsi
imull 0x14(%rsi), %ecx
addl %ecx, %eax
addl -0x28(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x20(%rbp), %eax
movl -0x24(%rbp), %ecx
movq (%rdx), %rdx
imull 0x14(%rdx), %ecx
addl %ecx, %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movsd -0x58(%rbp), %xmm0
mulsd -0x70(%rbp), %xmm0
mulsd -0x50(%rbp), %xmm0
movsd 0x7fbcd(%rip), %xmm2    # 0xe2018
subsd -0x50(%rbp), %xmm2
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x623d5
jmp 0x62482
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x623a0
jmp 0x62492
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x6236b
movl $0x0, -0x38(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x110(%rbp), %rcx
movl -0x28(%rbp), %eax
movq (%rcx), %rcx
cmpl (%rcx), %eax
jge 0x6281a
movq -0xb0(%rbp), %rax
movq (%rax), %rax
movslq -0x28(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x58(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x110(%rbp), %rcx
movl -0x30(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x4(%rcx), %eax
jge 0x6280a
movq -0xc0(%rbp), %rax
movq (%rax), %rax
movslq -0x30(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x78(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x110(%rbp), %rcx
movl -0x2c(%rbp), %eax
movq (%rcx), %rcx
cmpl (%rcx), %eax
jge 0x627f3
movq -0xb0(%rbp), %rax
movq (%rax), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x70(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jne 0x62649
xorps %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x110(%rbp), %rcx
movl -0x24(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x10(%rcx), %eax
jge 0x62624
movq -0x110(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x90(%rbp)
movq -0xa0(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x50(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x40(%rbp), %eax
jne 0x625f5
movsd -0x90(%rbp), %xmm0
movsd -0x50(%rbp), %xmm2
movsd 0x7fa3b(%rip), %xmm1    # 0xe2018
subsd %xmm1, %xmm2
movsd -0x60(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
jmp 0x62614
movsd -0x90(%rbp), %xmm0
movsd -0x50(%rbp), %xmm2
movsd -0x60(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
jmp 0x62616
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x62566
movsd -0x60(%rbp), %xmm0
movsd -0x70(%rbp), %xmm2
addsd %xmm2, %xmm2
movsd 0x7f9de(%rip), %xmm1    # 0xe2018
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
jmp 0x62651
xorps %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x110(%rbp), %rcx
movl -0x24(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x10(%rcx), %eax
jge 0x62721
movq -0x110(%rbp), %rax
movq (%rax), %rcx
movq 0x18(%rcx), %rcx
movslq -0x24(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
movl -0x28(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movsd (%rcx,%rdx,8), %xmm0
movsd %xmm0, -0x88(%rbp)
movq (%rax), %rax
movq 0x18(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x90(%rbp)
movq -0xa0(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x88(%rbp), %xmm0
mulsd -0x90(%rbp), %xmm0
mulsd -0x50(%rbp), %xmm0
movsd 0x7f91c(%rip), %xmm2    # 0xe2018
subsd -0x50(%rbp), %xmm2
movsd -0x68(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x62660
movsd -0x58(%rbp), %xmm0
movsd 0x7f8ea(%rip), %xmm1    # 0xe2018
subsd -0x58(%rbp), %xmm1
mulsd %xmm1, %xmm0
mulsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x110(%rbp), %rcx
movl -0x34(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x4(%rcx), %eax
jge 0x627e3
movq -0xc0(%rbp), %rax
movq (%rax), %rax
movslq -0x34(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x78(%rbp), %xmm0
mulsd -0x80(%rbp), %xmm0
mulsd -0x70(%rbp), %xmm0
movsd 0x7f88b(%rip), %xmm1    # 0xe2018
subsd -0x70(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
movsd -0x60(%rbp), %xmm2
addsd -0x68(%rbp), %xmm2
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x62748
jmp 0x627e5
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x6251e
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x624e2
jmp 0x6280c
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x624ae
movl $0x0, -0x38(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x110(%rbp), %rcx
movl -0x28(%rbp), %eax
movq (%rcx), %rcx
cmpl (%rcx), %eax
jge 0x62a5f
movq -0xb0(%rbp), %rax
movq (%rax), %rax
movslq -0x28(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x58(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x110(%rbp), %rcx
movl -0x30(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x4(%rcx), %eax
jge 0x62a4f
movl -0x20(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0xc0(%rbp), %rax
movq (%rax), %rax
movslq -0x30(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x78(%rbp), %xmm0
mulsd -0x58(%rbp), %xmm0
movsd 0x7f776(%rip), %xmm1    # 0xe2018
subsd -0x58(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x110(%rbp), %rcx
movl -0x24(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x10(%rcx), %eax
jge 0x62a38
movq -0xa0(%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 0x14(%rcx), %eax
jge 0x62a28
movl -0x28(%rbp), %eax
movl -0x2c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x6293b
movl -0x24(%rbp), %eax
cmpl -0x40(%rbp), %eax
jne 0x6292f
movsd -0x50(%rbp), %xmm0
movsd 0x7f6f4(%rip), %xmm1    # 0xe2018
subsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
jmp 0x62939
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
jmp 0x62943
xorps %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
movq -0x110(%rbp), %rax
movq -0xb0(%rbp), %rcx
movq (%rcx), %rcx
movslq -0x2c(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movsd %xmm0, -0x70(%rbp)
movq (%rax), %rax
movq 0x18(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x28(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x70(%rbp), %xmm0
mulsd -0x88(%rbp), %xmm0
mulsd -0x50(%rbp), %xmm0
movsd 0x7f677(%rip), %xmm1    # 0xe2018
subsd -0x50(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x48(%rbp), %xmm0
movsd -0x60(%rbp), %xmm2
addsd -0x68(%rbp), %xmm2
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movsd -0x48(%rbp), %xmm0
movsd -0x60(%rbp), %xmm2
addsd -0x68(%rbp), %xmm2
movq -0x8(%rbp), %rax
movslq -0x3c(%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 -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x628ec
jmp 0x62a2a
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x628b7
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x6285c
jmp 0x62a51
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x62828
movq -0xc8(%rbp), %rdi
movq -0xc0(%rbp), %rsi
callq 0x59ea0
movq -0x98(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x98(%rbp)
jmp 0x622bf
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