// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/plot.c
// Function: plot_covariance
void plot_covariance(matrix avg, matrix covariance, int contour, int color, double maxdist)
{
 int i, j, oldbin, newbin;
 double avgdist, predicted, predictedx, predictedy;
 Point p, dummyp;
 char st[2];
 matrix x;
 st[0] = '.';
 st[1] = '\0';
 dummyp.x = color;
 if (maxdist == 0.0)
   maxdist = 0.5 * pow(matrix_determinant(covariance), 0.25);
 else
   maxdist /= 2.0;
 avgdist = maxdist / contour;
 x = matrix_alloc(1, 2);
 for (i = 1; i < MESHDEPTH * PARTITIONS; i++)
  {
   p.x = img.xaxis.lim.min + i * ((img.xaxis.lim.max - img.xaxis.lim.min) / (MESHDEPTH * PARTITIONS));
   x.values[0][0] = p.x;
   for (j = 1; j < MESHDEPTH * PARTITIONS; j++)
    {
     p.y = img.yaxis.lim.min + j * ((img.yaxis.lim.max - img.yaxis.lim.min) / (MESHDEPTH * PARTITIONS));
     x.values[0][1] = p.y;
     predicted = sqrt(mahalanobis_distance(x, avg, covariance));
     oldbin = ((int)(predictedy / avgdist));
     newbin = ((int)(predicted / avgdist));
     if ((oldbin != newbin) && (newbin < contour) && (j != 1))
       add_object(OBJECT_POINT, p, dummyp, dummyp, st);
     predictedy = predicted;
    }
  }
 for (i = 1; i < MESHDEPTH * PARTITIONS; i++)
  {
   p.x = img.xaxis.lim.max - i * ((img.xaxis.lim.max - img.xaxis.lim.min) / (MESHDEPTH * PARTITIONS));
   x.values[0][0] = p.x;
   for (j = 1; j < MESHDEPTH * PARTITIONS; j++)
    {
     p.y = img.yaxis.lim.max - j * ((img.yaxis.lim.max - img.yaxis.lim.min) / (MESHDEPTH * PARTITIONS));
     x.values[0][1] = p.y;
     predicted = sqrt(mahalanobis_distance(x, avg, covariance));
     oldbin = ((int)(predictedy / avgdist));
     newbin = ((int)(predicted / avgdist));
     if ((oldbin != newbin) && (newbin < contour) && (j != 1))
       add_object(OBJECT_POINT, p, dummyp, dummyp, st);
     predictedy = predicted;
    }
  }
 for (i = 1; i < MESHDEPTH * PARTITIONS; i++)
  {
   p.y = img.yaxis.lim.min + i * ((img.yaxis.lim.max - img.yaxis.lim.min) / (MESHDEPTH * PARTITIONS));
   x.values[0][1] = p.y;
   for (j = 1; j < MESHDEPTH * PARTITIONS; j++)
    {
     p.x = img.xaxis.lim.min + j * ((img.xaxis.lim.max - img.xaxis.lim.min) / (MESHDEPTH * PARTITIONS));
     x.values[0][0] = p.x;
     predicted = sqrt(mahalanobis_distance(x, avg, covariance));
     oldbin = ((int)(predictedx / avgdist));
     newbin = ((int)(predicted / avgdist));
     if ((oldbin != newbin) && (newbin < contour) && (j != 1))
       add_object(OBJECT_POINT, p, dummyp, dummyp, st);
     predictedx = predicted;
    }
  }
 for (i = 1; i < MESHDEPTH * PARTITIONS; i++)
  {
   p.y = img.yaxis.lim.max - i * ((img.yaxis.lim.max - img.yaxis.lim.min) / (MESHDEPTH * PARTITIONS));
   x.values[0][1] = p.y;
   for (j = 1; j < MESHDEPTH * PARTITIONS; j++)
    {
     p.x = img.xaxis.lim.max - j * ((img.xaxis.lim.max - img.xaxis.lim.min) / (MESHDEPTH * PARTITIONS));
     x.values[0][0] = p.x;
     predicted = sqrt(mahalanobis_distance(x, avg, covariance));
     oldbin = ((int)(predictedx / avgdist));
     newbin = ((int)(predicted / avgdist));
     if ((oldbin != newbin) && (newbin < contour) && (j != 1))
       add_object(OBJECT_POINT, p, dummyp, dummyp, st);
     predictedx = predicted;
    }
  }
 matrix_free(x);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %r9d, %ebx
movl %r8d, 0x1c(%rsp)
movq %rcx, %r12
movq %rdx, %r13
movq %rsi, 0x58(%rsp)
movq %rdi, 0x50(%rsp)
movw $0x2e, 0xa(%rsp)
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x576ef
jp 0x576ef
movq %r13, %rdi
movq %r12, %rsi
callq 0x4078e
movsd 0x4e60e(%rip), %xmm1    # 0xa5cf8
callq 0x42f0
xorps %xmm1, %xmm1
cvtsi2sd %ebx, %xmm1
movsd %xmm1, 0x48(%rsp)
mulsd 0x4e614(%rip), %xmm0    # 0xa5d18
movapd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsi2sdl 0x1c(%rsp), %xmm0
divsd %xmm0, %xmm1
movapd %xmm1, 0x60(%rsp)
movl $0x1, %r15d
movl $0x1, %edi
movl $0x2, %esi
callq 0x3d79d
movq %rax, %rbp
movq %rdx, %rbx
movaps 0x60(%rsp), %xmm0
movlhps %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movaps %xmm0, 0x60(%rsp)
movsd 0x4ddd5(%rip), %xmm0    # 0xa5520
leaq 0x35a966(%rip), %r14    # 0x3b20b8
movl %r15d, 0xc(%rsp)
movapd %xmm0, %xmm2
movsd 0x10(%r14), %xmm0
movsd 0x18(%r14), %xmm3
subsd %xmm0, %xmm3
divsd 0x506a5(%rip), %xmm3    # 0xa7e18
movsd %xmm2, 0x30(%rsp)
mulsd %xmm2, %xmm3
addsd %xmm0, %xmm3
movq (%rbx), %rax
movsd %xmm3, 0x38(%rsp)
movsd %xmm3, (%rax)
movl $0x1f3, %r15d           # imm = 0x1F3
movsd 0x4dd84(%rip), %xmm2    # 0xa5520
movaps %xmm1, 0x20(%rsp)
movsd 0x80(%r14), %xmm0
movsd 0x88(%r14), %xmm1
subsd %xmm0, %xmm1
divsd 0x50659(%rip), %xmm1    # 0xa7e18
movsd %xmm2, 0x10(%rsp)
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movq (%rbx), %rax
movsd %xmm1, 0x40(%rsp)
movsd %xmm1, 0x8(%rax)
movq %rbp, %rdi
movq %rbx, %rsi
movq 0x50(%rsp), %rdx
movq 0x58(%rsp), %rcx
movq %r13, %r8
movq %r12, %r9
callq 0x4088c
ucomisd 0x4e50a(%rip), %xmm0    # 0xa5d08
jb 0x57809
xorps %xmm1, %xmm1
sqrtsd %xmm0, %xmm1
jmp 0x57812
callq 0x4300
movapd %xmm0, %xmm1
movapd 0x20(%rsp), %xmm0
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
divpd 0x60(%rsp), %xmm0
cvttpd2dq %xmm0, %xmm0
movd %xmm0, %ecx
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %eax
cmpl %eax, %ecx
movsd 0x10(%rsp), %xmm2
je 0x57882
cmpl $0x1f3, %r15d           # imm = 0x1F3
je 0x57882
cmpl 0x1c(%rsp), %eax
jge 0x57882
movl $0x8, %edi
movq 0x38(%rsp), %xmm0
movapd %xmm1, 0x20(%rsp)
movsd 0x40(%rsp), %xmm1
movsd 0x48(%rsp), %xmm2
movaps %xmm2, %xmm4
leaq 0xa(%rsp), %rsi
callq 0x2cc6c
movsd 0x10(%rsp), %xmm2
movapd 0x20(%rsp), %xmm1
movsd 0x4dc96(%rip), %xmm0    # 0xa5520
addsd %xmm0, %xmm2
decl %r15d
jne 0x5779c
movsd 0x30(%rsp), %xmm2
addsd %xmm0, %xmm2
movapd %xmm2, %xmm0
movl 0xc(%rsp), %r15d
incl %r15d
cmpl $0x1f4, %r15d           # imm = 0x1F4
jne 0x57752
movl $0x1, %eax
movsd 0x4dc59(%rip), %xmm0    # 0xa5520
movl %eax, 0xc(%rsp)
movapd %xmm0, %xmm2
movsd 0x18(%r14), %xmm0
movapd %xmm0, %xmm3
subsd 0x10(%r14), %xmm3
divsd 0x50519(%rip), %xmm3    # 0xa7e00
movsd %xmm2, 0x30(%rsp)
mulsd %xmm2, %xmm3
addsd %xmm0, %xmm3
movq (%rbx), %rax
movsd %xmm3, 0x38(%rsp)
movsd %xmm3, (%rax)
movl $0x1f3, %r15d           # imm = 0x1F3
movsd 0x4dc10(%rip), %xmm2    # 0xa5520
movapd %xmm1, 0x20(%rsp)
movsd 0x88(%r14), %xmm0
movapd %xmm0, %xmm1
subsd 0x80(%r14), %xmm1
divsd 0x504cc(%rip), %xmm1    # 0xa7e00
movsd %xmm2, 0x10(%rsp)
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movq (%rbx), %rax
movsd %xmm1, 0x40(%rsp)
movsd %xmm1, 0x8(%rax)
movq %rbp, %rdi
movq %rbx, %rsi
movq 0x50(%rsp), %rdx
movq 0x58(%rsp), %rcx
movq %r13, %r8
movq %r12, %r9
callq 0x4088c
ucomisd 0x4e395(%rip), %xmm0    # 0xa5d08
jb 0x5797e
xorps %xmm1, %xmm1
sqrtsd %xmm0, %xmm1
jmp 0x57987
callq 0x4300
movapd %xmm0, %xmm1
movapd 0x20(%rsp), %xmm0
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
divpd 0x60(%rsp), %xmm0
cvttpd2dq %xmm0, %xmm0
movd %xmm0, %ecx
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %eax
cmpl %eax, %ecx
movsd 0x10(%rsp), %xmm2
je 0x579f7
cmpl $0x1f3, %r15d           # imm = 0x1F3
je 0x579f7
cmpl 0x1c(%rsp), %eax
jge 0x579f7
movl $0x8, %edi
movq 0x38(%rsp), %xmm0
movapd %xmm1, 0x20(%rsp)
movsd 0x40(%rsp), %xmm1
movsd 0x48(%rsp), %xmm2
movaps %xmm2, %xmm4
leaq 0xa(%rsp), %rsi
callq 0x2cc6c
movsd 0x10(%rsp), %xmm2
movapd 0x20(%rsp), %xmm1
movsd 0x4db21(%rip), %xmm0    # 0xa5520
addsd %xmm0, %xmm2
decl %r15d
jne 0x57910
movsd 0x30(%rsp), %xmm2
addsd %xmm0, %xmm2
movapd %xmm2, %xmm0
movl 0xc(%rsp), %eax
incl %eax
cmpl $0x1f4, %eax            # imm = 0x1F4
jne 0x578c7
movl $0x1, %eax
movsd 0x4dae8(%rip), %xmm0    # 0xa5520
movl %eax, 0xc(%rsp)
movapd %xmm0, %xmm2
movsd 0x80(%r14), %xmm0
movsd 0x88(%r14), %xmm3
subsd %xmm0, %xmm3
divsd 0x503ba(%rip), %xmm3    # 0xa7e18
movsd %xmm2, 0x30(%rsp)
mulsd %xmm2, %xmm3
addsd %xmm0, %xmm3
movq (%rbx), %rax
movsd %xmm3, 0x38(%rsp)
movsd %xmm3, 0x8(%rax)
movl $0x1f3, %r15d           # imm = 0x1F3
movsd 0x4da98(%rip), %xmm2    # 0xa5520
movaps %xmm1, 0x20(%rsp)
movsd 0x10(%r14), %xmm0
movsd 0x18(%r14), %xmm1
subsd %xmm0, %xmm1
divsd 0x50373(%rip), %xmm1    # 0xa7e18
movsd %xmm2, 0x10(%rsp)
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movq (%rbx), %rax
movsd %xmm1, 0x40(%rsp)
movsd %xmm1, (%rax)
movq %rbp, %rdi
movq %rbx, %rsi
movq 0x50(%rsp), %rdx
movq 0x58(%rsp), %rcx
movq %r13, %r8
movq %r12, %r9
callq 0x4088c
ucomisd 0x4e225(%rip), %xmm0    # 0xa5d08
jb 0x57aee
xorps %xmm1, %xmm1
sqrtsd %xmm0, %xmm1
jmp 0x57af7
callq 0x4300
movapd %xmm0, %xmm1
movapd 0x20(%rsp), %xmm0
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
divpd 0x60(%rsp), %xmm0
cvttpd2dq %xmm0, %xmm0
movd %xmm0, %ecx
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %eax
cmpl %eax, %ecx
movsd 0x10(%rsp), %xmm2
je 0x57b67
cmpl $0x1f3, %r15d           # imm = 0x1F3
je 0x57b67
cmpl 0x1c(%rsp), %eax
jge 0x57b67
movl $0x8, %edi
movq 0x40(%rsp), %xmm0
movapd %xmm1, 0x20(%rsp)
movsd 0x38(%rsp), %xmm1
movsd 0x48(%rsp), %xmm2
movaps %xmm2, %xmm4
leaq 0xa(%rsp), %rsi
callq 0x2cc6c
movsd 0x10(%rsp), %xmm2
movapd 0x20(%rsp), %xmm1
movsd 0x4d9b1(%rip), %xmm0    # 0xa5520
addsd %xmm0, %xmm2
decl %r15d
jne 0x57a88
movsd 0x30(%rsp), %xmm2
addsd %xmm0, %xmm2
movapd %xmm2, %xmm0
movl 0xc(%rsp), %eax
incl %eax
cmpl $0x1f4, %eax            # imm = 0x1F4
jne 0x57a38
movl $0x1, %eax
movsd 0x4d978(%rip), %xmm0    # 0xa5520
movl %eax, 0xc(%rsp)
movapd %xmm0, %xmm2
movsd 0x88(%r14), %xmm0
movapd %xmm0, %xmm3
subsd 0x80(%r14), %xmm3
divsd 0x50232(%rip), %xmm3    # 0xa7e00
movsd %xmm2, 0x30(%rsp)
mulsd %xmm2, %xmm3
addsd %xmm0, %xmm3
movq (%rbx), %rax
movsd %xmm3, 0x38(%rsp)
movsd %xmm3, 0x8(%rax)
movl $0x1f3, %r15d           # imm = 0x1F3
movsd 0x4d928(%rip), %xmm2    # 0xa5520
movapd %xmm1, 0x20(%rsp)
movsd 0x18(%r14), %xmm0
movapd %xmm0, %xmm1
subsd 0x10(%r14), %xmm1
divsd 0x501ea(%rip), %xmm1    # 0xa7e00
movsd %xmm2, 0x10(%rsp)
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movq (%rbx), %rax
movsd %xmm1, 0x40(%rsp)
movsd %xmm1, (%rax)
movq %rbp, %rdi
movq %rbx, %rsi
movq 0x50(%rsp), %rdx
movq 0x58(%rsp), %rcx
movq %r13, %r8
movq %r12, %r9
callq 0x4088c
ucomisd 0x4e0b4(%rip), %xmm0    # 0xa5d08
jb 0x57c5f
xorps %xmm1, %xmm1
sqrtsd %xmm0, %xmm1
jmp 0x57c68
callq 0x4300
movapd %xmm0, %xmm1
movapd 0x20(%rsp), %xmm0
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
divpd 0x60(%rsp), %xmm0
cvttpd2dq %xmm0, %xmm0
movd %xmm0, %ecx
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %eax
cmpl %eax, %ecx
movsd 0x10(%rsp), %xmm2
je 0x57cd8
cmpl $0x1f3, %r15d           # imm = 0x1F3
je 0x57cd8
cmpl 0x1c(%rsp), %eax
jge 0x57cd8
movl $0x8, %edi
movq 0x40(%rsp), %xmm0
movapd %xmm1, 0x20(%rsp)
movsd 0x38(%rsp), %xmm1
movsd 0x48(%rsp), %xmm2
movaps %xmm2, %xmm4
leaq 0xa(%rsp), %rsi
callq 0x2cc6c
movsd 0x10(%rsp), %xmm2
movapd 0x20(%rsp), %xmm1
movsd 0x4d840(%rip), %xmm0    # 0xa5520
addsd %xmm0, %xmm2
decl %r15d
jne 0x57bf8
movsd 0x30(%rsp), %xmm2
addsd %xmm0, %xmm2
movapd %xmm2, %xmm0
movl 0xc(%rsp), %eax
incl %eax
cmpl $0x1f4, %eax            # imm = 0x1F4
jne 0x57ba8
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x3ed51
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq