// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/tests.c
// Function: multivariate_normality_test
int multivariate_normality_test(char* filename, double confidence, double* test_statistic)
{
 double* averages;
 matrix observations, S, g, observations_transpose, tmp;
 int i, j, p, n, freedom;
 double sum, res;
 observations = read_multivariate_observations_for_file(filename);
 p = observations.col;
 n = observations.row;
 if (n == 1)
  {
   matrix_free(observations);
   return 1;
  }
 S = matrix_covariance(observations, &averages);
 if (matrix_determinant(S) == 0)
  {
   matrix_free(observations);
   matrix_free(S);
   safe_free(averages);
   return 1;
  }
 matrix_inverse(&S);
 for (i = 0; i < n; i++)
   for (j = 0; j < p; j++)
     observations.values[i][j] -= averages[j];
 observations_transpose = matrix_transpose(observations);
 tmp = matrix_multiply(observations, S);
 g = matrix_multiply(tmp, observations_transpose);
 matrix_free(tmp);
 matrix_free(observations_transpose);
 matrix_free(observations);
 matrix_free(S);
 safe_free(averages);
 sum = 0.0;
 for (i = 0; i < n; i++)
   for (j = 0; j < n; j++)
     sum += g.values[i][j] * g.values[i][j] * g.values[i][j];
 matrix_free(g);
 sum /= (n * n);
 *test_statistic = (sum * n) / 6.0;
 freedom = (p * (p + 1) * (p + 2)) / 6;
 res = 1 - chi_square(freedom, *test_statistic);
 if (res > confidence)
   return 1;
 else
   return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movsd %xmm0, 0x40(%rsp)
callq 0x89cd3
movq %rax, %r14
movq %rdx, %r12
cmpl $0x1, %r14d
jne 0x8b8f6
movq %r14, %rdi
movq %r12, %rsi
callq 0x3929f
jmp 0x8b94b
leaq 0x18(%rsp), %rdx
movq %r14, %rdi
movq %r12, %rsi
callq 0x3a4c9
movq %rax, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movq %rax, %rdi
movq %rdx, %rsi
callq 0x3a822
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x8b95d
jp 0x8b95d
movq %r14, %rdi
movq %r12, %rsi
callq 0x3929f
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x3929f
movq 0x18(%rsp), %rdi
callq 0x34ff7
pushq $0x1
popq %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %r15
shrq $0x20, %r15
leaq 0x8(%rsp), %rdi
callq 0x3a9f7
xorl %eax, %eax
testl %r15d, %r15d
movl $0x0, %ecx
movq %r15, 0x30(%rsp)
cmovgl %r15d, %ecx
testl %r14d, %r14d
movl $0x0, %r15d
cmovgl %r14d, %r15d
cmpq %r15, %rax
je 0x8b9bc
movq 0x18(%rsp), %rdx
xorl %esi, %esi
cmpq %rsi, %rcx
je 0x8b9b7
movq (%r12,%rax,8), %rdi
movsd (%rdi,%rsi,8), %xmm0
subsd (%rdx,%rsi,8), %xmm0
movsd %xmm0, (%rdi,%rsi,8)
incq %rsi
jmp 0x8b99a
incq %rax
jmp 0x8b98e
movq %r14, %rdi
movq %r12, %rsi
callq 0x392ac
movq %rax, %rbp
movq %rax, 0x20(%rsp)
movq %rdx, (%rsp)
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rcx
movq %r14, %rdi
movq %r12, %rsi
callq 0x3933d
movq %rbx, 0x38(%rsp)
movq %rax, %rbx
movq %rdx, %r13
movq %rax, %rdi
movq %rdx, %rsi
movq %rbp, %rdx
movq (%rsp), %rcx
callq 0x3933d
movq %rax, 0x28(%rsp)
movq %rdx, %rbp
movq %rbx, %rdi
movq 0x38(%rsp), %rbx
movq %r13, %rsi
callq 0x3929f
movq 0x20(%rsp), %rdi
movq (%rsp), %rsi
callq 0x3929f
movq %r14, %rdi
movq %r12, %rsi
callq 0x3929f
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x3929f
movq 0x18(%rsp), %rdi
callq 0x34ff7
movl %r14d, %eax
xorpd %xmm2, %xmm2
xorl %ecx, %ecx
cmpq %r15, %rcx
je 0x8ba88
xorl %edx, %edx
cmpq %rdx, %rax
je 0x8ba83
movq (%rbp,%rcx,8), %rsi
movsd (%rsi,%rdx,8), %xmm0
movapd %xmm0, %xmm1
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
addsd %xmm1, %xmm2
incq %rdx
jmp 0x8ba5f
incq %rcx
jmp 0x8ba58
movq 0x28(%rsp), %rdi
movq %rbp, %rsi
movsd %xmm2, (%rsp)
callq 0x3929f
cvtsi2sd %r14d, %xmm0
imull %r14d, %r14d
cvtsi2sd %r14d, %xmm1
movsd (%rsp), %xmm2
divsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
divsd 0xc1db(%rip), %xmm2     # 0x97c98
movsd %xmm2, (%rbx)
movapd %xmm2, %xmm0
movq 0x30(%rsp), %rax
leal 0x1(%rax), %ecx
imull %eax, %ecx
addl $0x2, %eax
imull %ecx, %eax
pushq $0x6
popq %rcx
cltd
idivl %ecx
movl %eax, %edi
callq 0x1d59f
movsd 0x9a35(%rip), %xmm1     # 0x95520
subsd %xmm0, %xmm1
xorl %eax, %eax
ucomisd 0x40(%rsp), %xmm1
seta %al
jmp 0x8b94e