// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/data.c
// Function: covariance_2d
matrix covariance_2d(Instanceptr myptr, matrix currentmean)
{
 /*!Last Changed 30.01.2005*/
 matrix result;
 Instanceptr tmp;
 int dim, matrixdim, i, j, k, m, size = 0, x, y;
 double fx, fy, meanx, meany;
 dim  = current_dataset->multifeaturecount - 1;
 matrixdim = multifeaturecount_2d(current_dataset);
 result = matrix_alloc(matrixdim, matrixdim);
 tmp = myptr;
 while (tmp)
  {
   x = 0;
   /*For dimensions x_ix_j*/
   for (i = 0; i < dim; i++)
     for (j = i; j < dim; j++)
      {
       y = 0;
       fx = real_feature(tmp, i) * real_feature(tmp, j);
       meanx = currentmean.values[0][x];
       /*with dimensions x_kx_m*/
       for (k = 0; k < dim; k++)
         for (m = k; m < dim; m++)
          {           
           fy = real_feature(tmp, k) * real_feature(tmp, m);
           meany = currentmean.values[0][y];
           result.values[x][y] += (fx - meanx) * (fy - meany);
           y++;
          }
       /*with dimensions x_k*/
       for (k = 0; k < dim; k++)
        {
         fy = real_feature(tmp, k);
         meany = currentmean.values[0][y];
         result.values[x][y] += (fx - meanx) * (fy - meany);
         y++;
        }
       x++;
      }
   /*For dimensions x_i*/
   for (i = 0; i < dim; i++)
    {
     y = 0;
     fx = real_feature(tmp, i);
     meanx = currentmean.values[0][x];
     /*with dimensions x_kx_m*/
     for (k = 0; k < dim; k++)
       for (m = k; m < dim; m++)
        {           
         fy = real_feature(tmp, k) * real_feature(tmp, m);
         meany = currentmean.values[0][y];
         result.values[x][y] += (fx - meanx) * (fy - meany);
         y++;
        }
     /*with dimensions x_k*/
     for (k = 0; k < dim; k++)
      {
       fy = real_feature(tmp, k);
       meany = currentmean.values[0][y];
       result.values[x][y] += (fx - meanx) * (fy - meany);
       y++;
      }
     x++;
    }
   tmp = tmp->next;
   size++;
  }
 for (i = 0; i < matrixdim; i++)
   for (j = 0; j < matrixdim; j++)
     result.values[i][j] /= (size - 1);
 return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, 0x28(%rsp)
movq %rdi, %r12
leaq 0xbd4f7(%rip), %rax     # 0xcd870
movq (%rax), %rdi
movl 0x1c0(%rdi), %ebx
leal -0x1(%rbx), %r15d
callq 0x126ea
movl %eax, %edi
movl %eax, 0x50(%rsp)
movl %eax, %esi
callq 0x380d3
movq %rax, 0x68(%rsp)
movq %rdx, 0x20(%rsp)
xorl %eax, %eax
testl %r15d, %r15d
movl $0x0, %ecx
cmovgl %r15d, %ecx
movl %ecx, 0x48(%rsp)
addl $-0x2, %ebx
movq %rbx, 0x60(%rsp)
movl %r15d, 0x4c(%rsp)
testq %r12, %r12
je 0x1067b
movl %eax, 0x54(%rsp)
xorl %eax, %eax
movl %r15d, 0x44(%rsp)
xorl %esi, %esi
movslq %eax, %r13
cmpl 0x48(%rsp), %esi
je 0x10545
addl 0x44(%rsp), %eax
movl %eax, 0x58(%rsp)
cltq
movq %rax, 0x70(%rsp)
movl %esi, %ebx
movl %esi, 0x5c(%rsp)
cmpq 0x70(%rsp), %r13
je 0x10536
movq %r12, %rdi
callq 0x2aea2
movsd %xmm0, 0x38(%rsp)
movq %r12, %rdi
movl %ebx, 0xc(%rsp)
movl %ebx, %esi
callq 0x2aea2
mulsd 0x38(%rsp), %xmm0
movq 0x28(%rsp), %rax
movq (%rax), %rax
subsd (%rax,%r13,8), %xmm0
movsd %xmm0, 0x30(%rsp)
xorl %ebx, %ebx
movl %r15d, %ecx
movq 0x60(%rsp), %rax
movl %r15d, %edx
xorl %esi, %esi
movslq %esi, %r14
cmpl %r15d, %ebx
je 0x104e3
movl %eax, 0x18(%rsp)
movl %ecx, 0x1c(%rsp)
movslq %ecx, %r15
movl %edx, 0x14(%rsp)
addl %edx, %esi
movl %esi, 0x10(%rsp)
movl %ebx, %ebp
cmpq %r14, %r15
je 0x104c1
movq %r12, %rdi
movl %ebx, %esi
callq 0x2aea2
movsd %xmm0, 0x38(%rsp)
movq %r12, %rdi
movl %ebp, %esi
callq 0x2aea2
mulsd 0x38(%rsp), %xmm0
movq 0x28(%rsp), %rax
movq (%rax), %rax
subsd (%rax,%r14,8), %xmm0
movq 0x20(%rsp), %rax
movq (%rax,%r13,8), %rax
mulsd 0x30(%rsp), %xmm0
addsd (%rax,%r14,8), %xmm0
movsd %xmm0, (%rax,%r14,8)
incq %r14
incl %ebp
jmp 0x1046c
incl %ebx
movl 0x14(%rsp), %edx
decl %edx
movl 0x1c(%rsp), %ecx
movl 0x18(%rsp), %eax
addl %eax, %ecx
decl %eax
movl 0x4c(%rsp), %r15d
movl 0x10(%rsp), %esi
jmp 0x10449
xorl %ebx, %ebx
cmpl %ebx, %r15d
je 0x10524
movq %r12, %rdi
movl %ebx, %esi
callq 0x2aea2
movq 0x28(%rsp), %rax
movq (%rax), %rax
subsd (%rax,%r14,8), %xmm0
movq 0x20(%rsp), %rax
movq (%rax,%r13,8), %rax
mulsd 0x30(%rsp), %xmm0
addsd (%rax,%r14,8), %xmm0
movsd %xmm0, (%rax,%r14,8)
incq %r14
incl %ebx
jmp 0x104e5
incq %r13
movl 0xc(%rsp), %ebx
incl %ebx
movl 0x5c(%rsp), %esi
jmp 0x103f9
incl %esi
decl 0x44(%rsp)
movl 0x58(%rsp), %eax
jmp 0x103d7
xorl %ebx, %ebx
cmpl 0x48(%rsp), %ebx
je 0x1066b
movq %r12, %rdi
movl %ebx, 0xc(%rsp)
movl %ebx, %esi
callq 0x2aea2
movq 0x28(%rsp), %rax
movq (%rax), %rax
subsd (%rax,%r13,8), %xmm0
movsd %xmm0, 0x30(%rsp)
xorl %ebx, %ebx
movl %r15d, %ecx
movq 0x60(%rsp), %rax
movl %r15d, %edx
xorl %esi, %esi
movslq %esi, %r14
cmpl %r15d, %ebx
je 0x1061c
movl %eax, 0x18(%rsp)
movl %ecx, 0x1c(%rsp)
movslq %ecx, %r15
movl %edx, 0x14(%rsp)
addl %edx, %esi
movl %esi, 0x10(%rsp)
movl %ebx, %ebp
cmpq %r14, %r15
je 0x105fa
movq %r12, %rdi
movl %ebx, %esi
callq 0x2aea2
movsd %xmm0, 0x38(%rsp)
movq %r12, %rdi
movl %ebp, %esi
callq 0x2aea2
mulsd 0x38(%rsp), %xmm0
movq 0x28(%rsp), %rax
movq (%rax), %rax
subsd (%rax,%r14,8), %xmm0
movq 0x20(%rsp), %rax
movq (%rax,%r13,8), %rax
mulsd 0x30(%rsp), %xmm0
addsd (%rax,%r14,8), %xmm0
movsd %xmm0, (%rax,%r14,8)
incq %r14
incl %ebp
jmp 0x105a5
incl %ebx
movl 0x14(%rsp), %edx
decl %edx
movl 0x1c(%rsp), %ecx
movl 0x18(%rsp), %eax
addl %eax, %ecx
decl %eax
movl 0x4c(%rsp), %r15d
movl 0x10(%rsp), %esi
jmp 0x10582
xorl %ebp, %ebp
movl 0xc(%rsp), %ebx
cmpl %ebp, %r15d
je 0x10661
movq %r12, %rdi
movl %ebp, %esi
callq 0x2aea2
movq 0x28(%rsp), %rax
movq (%rax), %rax
subsd (%rax,%r14,8), %xmm0
movq 0x20(%rsp), %rax
movq (%rax,%r13,8), %rax
mulsd 0x30(%rsp), %xmm0
addsd (%rax,%r14,8), %xmm0
movsd %xmm0, (%rax,%r14,8)
incq %r14
incl %ebp
jmp 0x10622
incq %r13
incl %ebx
jmp 0x10547
movq 0x10(%r12), %r12
movl 0x54(%rsp), %eax
incl %eax
jmp 0x103c1
decl %eax
cvtsi2sd %eax, %xmm0
xorl %eax, %eax
movl 0x50(%rsp), %edx
testl %edx, %edx
movl $0x0, %ecx
cmovgl %edx, %ecx
movl %edx, %edx
cmpq %rcx, %rax
je 0x106c0
xorl %esi, %esi
cmpq %rsi, %rdx
je 0x106bb
movq 0x20(%rsp), %rdi
movq (%rdi,%rax,8), %rdi
movsd (%rdi,%rsi,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rdi,%rsi,8)
incq %rsi
jmp 0x1069a
incq %rax
jmp 0x10693
movq 0x68(%rsp), %rax
movq 0x20(%rsp), %rdx
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq