// File: /workspace/github_c_makefile_star2_O1/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 0x95a6a
movq %rax, %r14
movq %rdx, %r12
movq %rax, %r15
cmpl $0x1, %r14d
jne 0x9782b
movq %r15, %rdi
movq %r12, %rsi
callq 0x3dbad
jmp 0x97883
movl %r14d, %ebp
leaq 0x18(%rsp), %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x3f03e
movq %rax, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movq %rax, %rdi
movq %rdx, %rsi
callq 0x3f436
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x97897
jp 0x97897
movq %r15, %rdi
movq %r12, %rsi
callq 0x3dbad
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x3dbad
movq 0x18(%rsp), %rdi
callq 0x39194
movl $0x1, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, 0x28(%rsp)
shrq $0x20, %r14
leaq 0x8(%rsp), %rdi
callq 0x3f648
movl %ebp, 0x24(%rsp)
testl %ebp, %ebp
jle 0x978ec
movq 0x18(%rsp), %rax
movl %r15d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
xorl %edx, %edx
testl %r14d, %r14d
jle 0x978e4
movq (%r12,%rdx,8), %rsi
xorl %edi, %edi
movsd (%rsi,%rdi,8), %xmm0
subsd (%rax,%rdi,8), %xmm0
movsd %xmm0, (%rsi,%rdi,8)
incq %rdi
cmpq %rdi, %r14
jne 0x978cd
incq %rdx
cmpq %rcx, %rdx
jne 0x978c2
movq %r15, %rdi
movq %r12, %rsi
callq 0x3dbba
movq %rax, %rbp
movq %rax, 0x30(%rsp)
movq %rdx, (%rsp)
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rcx
movq %r15, %rdi
movq %r12, %rsi
callq 0x3dc8b
movq %rax, %rbx
movq %rdx, %r13
movq %rax, %rdi
movq %rdx, %rsi
movq %rbp, %rdx
movq (%rsp), %rcx
callq 0x3dc8b
movq %rax, 0x38(%rsp)
movq %rdx, %rbp
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3dbad
movq 0x30(%rsp), %rdi
movq (%rsp), %rsi
callq 0x3dbad
movq %r15, %rdi
movq %r12, %rsi
callq 0x3dbad
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x3dbad
movq 0x18(%rsp), %rdi
callq 0x39194
movl 0x24(%rsp), %r12d
testl %r12d, %r12d
jle 0x979bf
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
xorpd %xmm2, %xmm2
xorl %eax, %eax
movq 0x28(%rsp), %rbx
movq (%rbp,%rax,8), %rcx
xorl %edx, %edx
movsd (%rcx,%rdx,8), %xmm0
movapd %xmm0, %xmm1
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
addsd %xmm1, %xmm2
incq %rdx
cmpq %rdx, %r15
jne 0x97998
incq %rax
cmpq %r15, %rax
jne 0x97991
jmp 0x979c8
xorpd %xmm2, %xmm2
movq 0x28(%rsp), %rbx
movsd %xmm2, (%rsp)
movq 0x38(%rsp), %rdi
movq %rbp, %rsi
callq 0x3dbad
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
imull %r12d, %r12d
xorps %xmm1, %xmm1
cvtsi2sd %r12d, %xmm1
movsd (%rsp), %xmm2
divsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
divsd 0xd26d(%rip), %xmm2     # 0xa4c70
movsd %xmm2, (%rbx)
movapd %xmm2, %xmm0
leal 0x1(%r14), %eax
imull %r14d, %eax
leal 0x2(%r14), %ecx
imull %eax, %ecx
movslq %ecx, %rax
imulq $0x2aaaaaab, %rax, %rdi # imm = 0x2AAAAAAB
movq %rdi, %rax
shrq $0x3f, %rax
shrq $0x20, %rdi
addl %eax, %edi
callq 0x1f4cd
movsd 0xaae2(%rip), %xmm1     # 0xa2520
subsd %xmm0, %xmm1
xorl %eax, %eax
ucomisd 0x40(%rsp), %xmm1
seta %al
jmp 0x97888