#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ mtx_deriv_mean(double *, double *, double *, int, int);
int /*<<< orphan*/ mtx_mult(double *, double *, double *, int, int, int);
int /*<<< orphan*/ mtx_transpose(double *, double *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ show_matrix(double *, int, int);
int /*<<< orphan*/ stat_mean(double *, double *, int, int);
void test_pca(void) {
  int DIM_I = 6;
  int DIM_J = 6;
  int i;
  double a[36] = {3.5712,  1.4007,  2.5214,  35.7680, 12.5698, 34.5678,
                  1.4007,  84.9129, 2.7030,  64.5638, 4.5645,  56.4523,
                  2.5214,  2.7030,  93.3993, 32.4563, 56.4322, 24.4678,
                  35.7680, 64.5638, 32.4563, 43.2345, 21.3456, 32.5476,
                  12.5698, 4.5645,  56.4322, 21.3456, 78.4356, 65.4356,
                  34.5678, 56.4523, 24.4678, 32.5476, 65.4356, 21.4567};
  double lancz_trans_mtx[36];
  double *mean = (double *)calloc(sizeof(double), DIM_J);
  double *b = (double *)calloc(sizeof(double), (DIM_J * DIM_I));
  double *b_prime = (double *)calloc(sizeof(double), (DIM_J * DIM_I));
  double *cov = (double *)calloc(sizeof(double), (DIM_J * DIM_I));
  double *eigenvalues = (double *)calloc(sizeof(double), (DIM_J));
  double *Identity = (double *)calloc(sizeof(double), (DIM_J * DIM_I));
  double *mtx_diag = (double *)calloc(sizeof(double), (DIM_J * DIM_I));
  double *mtx_off_diag = (double *)calloc(sizeof(double), (DIM_J * DIM_I));
  double *ident_eigen = (double *)calloc(sizeof(double), (DIM_J * DIM_I));
  show_matrix(a, DIM_I, DIM_J);
  stat_mean(a, mean, DIM_I, DIM_J);
  printf("\nexpected mean matrix \n"
         "15.06650 35.76620 35.33000 38.31930 39.79720 39.15460");
  printf("\n\nMean matrix \n");
  show_matrix(mean, 1, DIM_J);
  printf("\nexpected derivation from the mean matrix\n"
         "-11.49528 -34.36550 -32.80860 -2.55130 -27.22742 -4.58683\n"
         "-13.66578 49.14670 -32.62700 26.24450 -35.23272 17.29767\n"
         "-12.54508 -33.06320 58.06930 -5.86300 16.63498 -14.68683\n"
         "20.70152 28.79760 -2.87370 4.91520 -18.45162 -6.60703\n"
         "-2.49668 -31.20170 21.10220 -16.97370 38.63838 26.28097\n"
         "19.50132 20.68610 -10.86220 -5.77170 25.63838 -17.69793\n");
  printf("\n Derivation from the mean matrix \n");
  mtx_deriv_mean(b, a, mean, DIM_I, DIM_J);
  show_matrix(b, DIM_I, DIM_J);
  printf("\n");
  printf("Expected transpose matrix \n"
         "-11.49528 -13.66578 -12.54508 20.70152 -2.49668 19.50132\n"
         "-34.36550 49.14670 -33.06320 28.79760 -31.20170 20.68610\n"
         "-32.80860 -32.62700 58.06930 -2.87370 21.10220 -10.86220\n"
         "-2.55130 26.24450 -5.86300 4.91520 -16.97370 -5.77170\n"
         "-27.22742 -35.23272 16.63498 -18.45162 38.63838 25.63838\n"
         "-4.58683 17.29767 -14.68683 -6.60703 26.28097 -17.69793\n");
  printf("\n\n Transpose matrix \n");
  mtx_transpose(b, b_prime, DIM_I, DIM_J);
  show_matrix(b_prime, DIM_J, DIM_I);
  printf("\nExpected multiplication prior to covariance matrix (b*b')\n"
         "3158.41375 351.58407 -995.33304 -613.17658 -720.63631 -1180.85189\n"
         "351.58407 5896.00026 -4342.15094 1890.97606 -3540.04502 -256.36445\n"
         "-995.33304 -4342.15094 5149.39843 -1617.44056 2644.62062 -839.09450\n"
         "-613.17658 1890.97606 -1617.44056 1674.38695 -1980.86959 646.12372\n"
         "-720.63631 -3540.04502 2644.62062 -1980.86959 3896.80272 -299.87242\n"
         "-1180.85189 -256.36445 -839.09450 646.12372 -299.87242 1930.05954\n");
  printf("\n\n Multiplication prior to covariance matrix (b*b')\n");
  mtx_mult(b, b_prime, cov, DIM_I, DIM_J, DIM_I);
  show_matrix(cov, DIM_I, DIM_I);
  for (i = 0; i < DIM_I * DIM_I; i++)
    cov[i] /= DIM_I;
  printf("\nExpected covarianc matrix\n"
         "526.40229 58.59735 -165.88884 -102.19610 -120.10605 -196.80865\n"
         "58.59735 982.66671 -723.69182 315.16268 -590.00750 -42.72741\n"
         "-165.88884 -723.69182 858.23307 -269.57343 440.77010 -139.84908\n"
         "-102.19610 315.16268 -269.57343 279.06449 -330.14493 107.68729\n"
         "-120.10605 -590.00750 440.77010 -330.14493 649.46712 -49.97874\n"
         "-196.80865 -42.72741 -139.84908 107.68729 -49.97874 321.67659\n");
  printf("\nCovariance matrix\n");
  show_matrix(cov, DIM_I, DIM_I);
}


x86 assembly (clang, -O0):
<test_pca>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2a0,%rsp
movl   $0x6,-0x4(%rbp)
movl   $0x6,-0x8(%rbp)
lea    -0x130(%rbp),%rdi
lea    0xe59(%rip),%rsi
mov    $0x120,%edx
call   1090 <memcpy@plt>
mov    -0x8(%rbp),%esi
mov    $0x8,%edi
call   1080 <calloc@plt>
mov    %rax,-0x258(%rbp)
mov    -0x8(%rbp),%esi
imul   -0x4(%rbp),%esi
mov    $0x8,%edi
call   1080 <calloc@plt>
mov    %rax,-0x260(%rbp)
mov    -0x8(%rbp),%esi
imul   -0x4(%rbp),%esi
mov    $0x8,%edi
call   1080 <calloc@plt>
mov    %rax,-0x268(%rbp)
mov    -0x8(%rbp),%esi
imul   -0x4(%rbp),%esi
mov    $0x8,%edi
call   1080 <calloc@plt>
mov    %rax,-0x270(%rbp)
mov    -0x8(%rbp),%esi
mov    $0x8,%edi
call   1080 <calloc@plt>
mov    %rax,-0x278(%rbp)
mov    -0x8(%rbp),%esi
imul   -0x4(%rbp),%esi
mov    $0x8,%edi
call   1080 <calloc@plt>
mov    %rax,-0x280(%rbp)
mov    -0x8(%rbp),%esi
imul   -0x4(%rbp),%esi
mov    $0x8,%edi
call   1080 <calloc@plt>
mov    %rax,-0x288(%rbp)
mov    -0x8(%rbp),%esi
imul   -0x4(%rbp),%esi
mov    $0x8,%edi
call   1080 <calloc@plt>
mov    %rax,-0x290(%rbp)
mov    -0x8(%rbp),%esi
imul   -0x4(%rbp),%esi
mov    $0x8,%edi
call   1080 <calloc@plt>
mov    %rax,-0x298(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1050 <show_matrix@plt>
lea    -0x130(%rbp),%rdi
mov    -0x258(%rbp),%rsi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
call   10a0 <stat_mean@plt>
lea    0xe6d(%rip),%rdi
call   1070 <printf@plt>
lea    0xeae(%rip),%rdi
call   1070 <printf@plt>
mov    -0x258(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    $0x1,%esi
call   1050 <show_matrix@plt>
lea    0xe9e(%rip),%rdi
call   1070 <printf@plt>
lea    0x100f(%rip),%rdi
call   1070 <printf@plt>
mov    -0x260(%rbp),%rdi
lea    -0x130(%rbp),%rsi
mov    -0x258(%rbp),%rdx
mov    -0x4(%rbp),%ecx
mov    -0x8(%rbp),%r8d
call   1060 <mtx_deriv_mean@plt>
mov    -0x260(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1050 <show_matrix@plt>
lea    0x1176(%rip),%rdi
call   1070 <printf@plt>
lea    0xfe8(%rip),%rdi
call   1070 <printf@plt>
lea    0x114a(%rip),%rdi
call   1070 <printf@plt>
mov    -0x260(%rbp),%rdi
mov    -0x268(%rbp),%rsi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
call   1040 <mtx_transpose@plt>
mov    -0x268(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
call   1050 <show_matrix@plt>
lea    0x1129(%rip),%rdi
call   1070 <printf@plt>
lea    0x12eb(%rip),%rdi
call   1070 <printf@plt>
mov    -0x260(%rbp),%rdi
mov    -0x268(%rbp),%rsi
mov    -0x270(%rbp),%rdx
mov    -0x4(%rbp),%ecx
mov    -0x8(%rbp),%r8d
mov    -0x4(%rbp),%r9d
call   1030 <mtx_mult@plt>
mov    -0x270(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%edx
call   1050 <show_matrix@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x4(%rbp),%ecx
imul   -0x4(%rbp),%ecx
cmp    %ecx,%eax
jge    1406 <test_pca+0x286>
cvtsi2sdl -0x4(%rbp),%xmm1
mov    -0x270(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    13c8 <test_pca+0x248>
lea    0x1298(%rip),%rdi
call   1070 <printf@plt>
lea    0x1420(%rip),%rdi
call   1070 <printf@plt>
mov    -0x270(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%edx
call   1050 <show_matrix@plt>
add    $0x2a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_pca>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x120,%rsp
lea    0xe59(%rip),%rsi
mov    %rsp,%r12
mov    $0x120,%edx
mov    %r12,%rdi
call   10b0 <memcpy@plt>
mov    $0x8,%edi
mov    $0x6,%esi
call   10a0 <calloc@plt>
mov    %rax,%r13
mov    $0x8,%edi
mov    $0x24,%esi
call   10a0 <calloc@plt>
mov    %rax,%r14
mov    $0x8,%edi
mov    $0x24,%esi
call   10a0 <calloc@plt>
mov    %rax,%r15
mov    $0x8,%edi
mov    $0x24,%esi
call   10a0 <calloc@plt>
mov    %rax,%rbx
mov    $0x8,%edi
mov    $0x6,%esi
call   10a0 <calloc@plt>
mov    $0x8,%edi
mov    $0x24,%esi
call   10a0 <calloc@plt>
mov    $0x8,%edi
mov    $0x24,%esi
call   10a0 <calloc@plt>
mov    $0x8,%edi
mov    $0x24,%esi
call   10a0 <calloc@plt>
mov    $0x8,%edi
mov    $0x24,%esi
call   10a0 <calloc@plt>
mov    %r12,%rdi
mov    $0x6,%esi
mov    $0x6,%edx
call   1070 <show_matrix@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    $0x6,%edx
mov    $0x6,%ecx
call   10c0 <stat_mean@plt>
lea    0xea8(%rip),%rdi
call   1090 <printf@plt>
lea    0xee9(%rip),%rdi
call   1060 <puts@plt>
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x6,%edx
call   1070 <show_matrix@plt>
lea    0xeda(%rip),%rdi
call   1060 <puts@plt>
lea    0x104a(%rip),%rdi
call   1060 <puts@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    $0x6,%ecx
mov    $0x6,%r8d
call   1080 <mtx_deriv_mean@plt>
mov    %r14,%rdi
mov    $0x6,%esi
mov    $0x6,%edx
call   1070 <show_matrix@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x102c(%rip),%rdi
call   1060 <puts@plt>
lea    0x118d(%rip),%rdi
call   1060 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x6,%edx
mov    $0x6,%ecx
call   1050 <mtx_transpose@plt>
mov    %r15,%rdi
mov    $0x6,%esi
mov    $0x6,%edx
call   1070 <show_matrix@plt>
lea    0x116f(%rip),%rdi
call   1060 <puts@plt>
lea    0x1330(%rip),%rdi
call   1060 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    $0x6,%ecx
mov    $0x6,%r8d
mov    $0x6,%r9d
call   1040 <mtx_mult@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x6,%edx
call   1070 <show_matrix@plt>
movapd 0xc78(%rip),%xmm0
movupd (%rbx),%xmm1
movupd 0x10(%rbx),%xmm2
movupd 0x20(%rbx),%xmm3
movupd 0x30(%rbx),%xmm4
divpd  %xmm0,%xmm1
movupd %xmm1,(%rbx)
divpd  %xmm0,%xmm2
movupd %xmm2,0x10(%rbx)
divpd  %xmm0,%xmm3
movupd %xmm3,0x20(%rbx)
divpd  %xmm0,%xmm4
movupd %xmm4,0x30(%rbx)
movupd 0x40(%rbx),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0x40(%rbx)
movupd 0x50(%rbx),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0x50(%rbx)
movupd 0x60(%rbx),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0x60(%rbx)
movupd 0x70(%rbx),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0x70(%rbx)
movupd 0x80(%rbx),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0x80(%rbx)
movupd 0x90(%rbx),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0x90(%rbx)
movupd 0xa0(%rbx),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0xa0(%rbx)
movupd 0xb0(%rbx),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0xb0(%rbx)
movupd 0xc0(%rbx),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0xc0(%rbx)
movupd 0xd0(%rbx),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0xd0(%rbx)
movupd 0xe0(%rbx),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0xe0(%rbx)
movupd 0xf0(%rbx),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0xf0(%rbx)
movupd 0x100(%rbx),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0x100(%rbx)
movupd 0x110(%rbx),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,0x110(%rbx)
lea    0x11e9(%rip),%rdi
call   1060 <puts@plt>
lea    0x1370(%rip),%rdi
call   1060 <puts@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x6,%edx
call   1070 <show_matrix@plt>
add    $0x120,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.test_pca.a = [36 x double] [double 3.571200e+00, double 1.400700e+00, double 2.521400e+00, double 3.576800e+01, double 1.256980e+01, double 3.456780e+01, double 1.400700e+00, double 0x40553A6CF41F212D, double 2.703000e+00, double 6.456380e+01, double 4.564500e+00, double 5.645230e+01, double 2.521400e+00, double 2.703000e+00, double 0x4057598E219652BD, double 3.245630e+01, double 5.643220e+01, double 2.446780e+01, double 3.576800e+01, double 6.456380e+01, double 3.245630e+01, double 4.323450e+01, double 2.134560e+01, double 3.254760e+01, double 1.256980e+01, double 4.564500e+00, double 5.643220e+01, double 2.134560e+01, double 7.843560e+01, double 6.543560e+01, double 3.456780e+01, double 5.645230e+01, double 2.446780e+01, double 3.254760e+01, double 6.543560e+01, double 2.145670e+01]
@.str = [77 x i8] c"\0Aexpected mean matrix \0A15.06650 35.76620 35.33000 38.31930 39.79720 39.15460\00"
@.str.1 = [16 x i8] c"\0A\0AMean matrix \0A\00"
@.str.2 = [381 x i8] c"\0Aexpected derivation from the mean matrix\0A-11.49528 -34.36550 -32.80860 -2.55130 -27.22742 -4.58683\0A-13.66578 49.14670 -32.62700 26.24450 -35.23272 17.29767\0A-12.54508 -33.06320 58.06930 -5.86300 16.63498 -14.68683\0A20.70152 28.79760 -2.87370 4.91520 -18.45162 -6.60703\0A-2.49668 -31.20170 21.10220 -16.97370 38.63838 26.28097\0A19.50132 20.68610 -10.86220 -5.77170 25.63838 -17.69793\0A\00"
@.str.3 = [36 x i8] c"\0A Derivation from the mean matrix \0A\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [366 x i8] c"Expected transpose matrix \0A-11.49528 -13.66578 -12.54508 20.70152 -2.49668 19.50132\0A-34.36550 49.14670 -33.06320 28.79760 -31.20170 20.68610\0A-32.80860 -32.62700 58.06930 -2.87370 21.10220 -10.86220\0A-2.55130 26.24450 -5.86300 4.91520 -16.97370 -5.77170\0A-27.22742 -35.23272 16.63498 -18.45162 38.63838 25.63838\0A-4.58683 17.29767 -14.68683 -6.60703 26.28097 -17.69793\0A\00"
@.str.6 = [22 x i8] c"\0A\0A Transpose matrix \0A\00"
@.str.7 = [462 x i8] c"\0AExpected multiplication prior to covariance matrix (b*b')\0A3158.41375 351.58407 -995.33304 -613.17658 -720.63631 -1180.85189\0A351.58407 5896.00026 -4342.15094 1890.97606 -3540.04502 -256.36445\0A-995.33304 -4342.15094 5149.39843 -1617.44056 2644.62062 -839.09450\0A-613.17658 1890.97606 -1617.44056 1674.38695 -1980.86959 646.12372\0A-720.63631 -3540.04502 2644.62062 -1980.86959 3896.80272 -299.87242\0A-1180.85189 -256.36445 -839.09450 646.12372 -299.87242 1930.05954\0A\00"
@.str.8 = [53 x i8] c"\0A\0A Multiplication prior to covariance matrix (b*b')\0A\00"
@.str.9 = [404 x i8] c"\0AExpected covarianc matrix\0A526.40229 58.59735 -165.88884 -102.19610 -120.10605 -196.80865\0A58.59735 982.66671 -723.69182 315.16268 -590.00750 -42.72741\0A-165.88884 -723.69182 858.23307 -269.57343 440.77010 -139.84908\0A-102.19610 315.16268 -269.57343 279.06449 -330.14493 107.68729\0A-120.10605 -590.00750 440.77010 -330.14493 649.46712 -49.97874\0A-196.80865 -42.72741 -139.84908 107.68729 -49.97874 321.67659\0A\00"
@.str.10 = [20 x i8] c"\0ACovariance matrix\0A\00"
define void @test_pca() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [36 x double]
%5 = alloca [36 x double]
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
store i32 6, i32* %1
store i32 6, i32* %2
%15 = bitcast [36 x double]* %4 to i8*
%16 = load i32, i32* %2
%17 = call i64 @calloc(i32 8, i32 %16)
%18 = inttoptr i64 %17 to double*
store double* %18, double** %6
%19 = load i32, i32* %2
%20 = load i32, i32* %1
%21 = mul nsw i32 %19, %20
%22 = call i64 @calloc(i32 8, i32 %21)
%23 = inttoptr i64 %22 to double*
store double* %23, double** %7
%24 = load i32, i32* %2
%25 = load i32, i32* %1
%26 = mul nsw i32 %24, %25
%27 = call i64 @calloc(i32 8, i32 %26)
%28 = inttoptr i64 %27 to double*
store double* %28, double** %8
%29 = load i32, i32* %2
%30 = load i32, i32* %1
%31 = mul nsw i32 %29, %30
%32 = call i64 @calloc(i32 8, i32 %31)
%33 = inttoptr i64 %32 to double*
store double* %33, double** %9
%34 = load i32, i32* %2
%35 = call i64 @calloc(i32 8, i32 %34)
%36 = inttoptr i64 %35 to double*
store double* %36, double** %10
%37 = load i32, i32* %2
%38 = load i32, i32* %1
%39 = mul nsw i32 %37, %38
%40 = call i64 @calloc(i32 8, i32 %39)
%41 = inttoptr i64 %40 to double*
store double* %41, double** %11
%42 = load i32, i32* %2
%43 = load i32, i32* %1
%44 = mul nsw i32 %42, %43
%45 = call i64 @calloc(i32 8, i32 %44)
%46 = inttoptr i64 %45 to double*
store double* %46, double** %12
%47 = load i32, i32* %2
%48 = load i32, i32* %1
%49 = mul nsw i32 %47, %48
%50 = call i64 @calloc(i32 8, i32 %49)
%51 = inttoptr i64 %50 to double*
store double* %51, double** %13
%52 = load i32, i32* %2
%53 = load i32, i32* %1
%54 = mul nsw i32 %52, %53
%55 = call i64 @calloc(i32 8, i32 %54)
%56 = inttoptr i64 %55 to double*
store double* %56, double** %14
%57 = getelementptr inbounds [36 x double], [36 x double]* %4, i64 0, i64 0
%58 = load i32, i32* %1
%59 = load i32, i32* %2
%60 = call i32 @show_matrix(double* %57, i32 %58, i32 %59)
%61 = getelementptr inbounds [36 x double], [36 x double]* %4, i64 0, i64 0
%62 = load double*, double** %6
%63 = load i32, i32* %1
%64 = load i32, i32* %2
%65 = call i32 @stat_mean(double* %61, double* %62, i32 %63, i32 %64)
%66 = call i32 @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0))
%67 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%68 = load double*, double** %6
%69 = load i32, i32* %2
%70 = call i32 @show_matrix(double* %68, i32 1, i32 %69)
%71 = call i32 @printf(i8* getelementptr inbounds ([381 x i8], [381 x i8]* @.str.2, i64 0, i64 0))
%72 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%73 = load double*, double** %7
%74 = getelementptr inbounds [36 x double], [36 x double]* %4, i64 0, i64 0
%75 = load double*, double** %6
%76 = load i32, i32* %1
%77 = load i32, i32* %2
%78 = call i32 @mtx_deriv_mean(double* %73, double* %74, double* %75, i32 %76, i32 %77)
%79 = load double*, double** %7
%80 = load i32, i32* %1
%81 = load i32, i32* %2
%82 = call i32 @show_matrix(double* %79, i32 %80, i32 %81)
%83 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%84 = call i32 @printf(i8* getelementptr inbounds ([366 x i8], [366 x i8]* @.str.5, i64 0, i64 0))
%85 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%86 = load double*, double** %7
%87 = load double*, double** %8
%88 = load i32, i32* %1
%89 = load i32, i32* %2
%90 = call i32 @mtx_transpose(double* %86, double* %87, i32 %88, i32 %89)
%91 = load double*, double** %8
%92 = load i32, i32* %2
%93 = load i32, i32* %1
%94 = call i32 @show_matrix(double* %91, i32 %92, i32 %93)
%95 = call i32 @printf(i8* getelementptr inbounds ([462 x i8], [462 x i8]* @.str.7, i64 0, i64 0))
%96 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.8, i64 0, i64 0))
%97 = load double*, double** %7
%98 = load double*, double** %8
%99 = load double*, double** %9
%100 = load i32, i32* %1
%101 = load i32, i32* %2
%102 = load i32, i32* %1
%103 = call i32 @mtx_mult(double* %97, double* %98, double* %99, i32 %100, i32 %101, i32 %102)
%104 = load double*, double** %9
%105 = load i32, i32* %1
%106 = load i32, i32* %1
%107 = call i32 @show_matrix(double* %104, i32 %105, i32 %106)
store i32 0, i32* %3
br label %108
108: ; preds = %123, %0
%109 = load i32, i32* %3
%110 = load i32, i32* %1
%111 = load i32, i32* %1
%112 = mul nsw i32 %110, %111
%113 = icmp slt i32 %109, %112
br i1 %113, label %114, label %126
114: ; preds = %108
%115 = load i32, i32* %1
%116 = sitofp i32 %115 to double
%117 = load double*, double** %9
%118 = load i32, i32* %3
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds double, double* %117, i64 %119
%121 = load double, double* %120
%122 = fdiv double %121, %116
store double %122, double* %120
br label %123
123: ; preds = %114
%124 = load i32, i32* %3
%125 = add nsw i32 %124, 1
store i32 %125, i32* %3
br label %108
126: ; preds = %108
%127 = call i32 @printf(i8* getelementptr inbounds ([404 x i8], [404 x i8]* @.str.9, i64 0, i64 0))
%128 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0))
%129 = load double*, double** %9
%130 = load i32, i32* %1
%131 = load i32, i32* %1
%132 = call i32 @show_matrix(double* %129, i32 %130, i32 %131)
ret void
}

LLVM IR (-O2):
@__const.test_pca.a = [36 x double] [double 3.571200e+00, double 1.400700e+00, double 2.521400e+00, double 3.576800e+01, double 1.256980e+01, double 3.456780e+01, double 1.400700e+00, double 0x40553A6CF41F212D, double 2.703000e+00, double 6.456380e+01, double 4.564500e+00, double 5.645230e+01, double 2.521400e+00, double 2.703000e+00, double 0x4057598E219652BD, double 3.245630e+01, double 5.643220e+01, double 2.446780e+01, double 3.576800e+01, double 6.456380e+01, double 3.245630e+01, double 4.323450e+01, double 2.134560e+01, double 3.254760e+01, double 1.256980e+01, double 4.564500e+00, double 5.643220e+01, double 2.134560e+01, double 7.843560e+01, double 6.543560e+01, double 3.456780e+01, double 5.645230e+01, double 2.446780e+01, double 3.254760e+01, double 6.543560e+01, double 2.145670e+01]
@.str = [77 x i8] c"\0Aexpected mean matrix \0A15.06650 35.76620 35.33000 38.31930 39.79720 39.15460\00"
@str = [15 x i8] c"\0A\0AMean matrix \00"
@str.11 = [380 x i8] c"\0Aexpected derivation from the mean matrix\0A-11.49528 -34.36550 -32.80860 -2.55130 -27.22742 -4.58683\0A-13.66578 49.14670 -32.62700 26.24450 -35.23272 17.29767\0A-12.54508 -33.06320 58.06930 -5.86300 16.63498 -14.68683\0A20.70152 28.79760 -2.87370 4.91520 -18.45162 -6.60703\0A-2.49668 -31.20170 21.10220 -16.97370 38.63838 26.28097\0A19.50132 20.68610 -10.86220 -5.77170 25.63838 -17.69793\00"
@str.12 = [35 x i8] c"\0A Derivation from the mean matrix \00"
@str.13 = [365 x i8] c"Expected transpose matrix \0A-11.49528 -13.66578 -12.54508 20.70152 -2.49668 19.50132\0A-34.36550 49.14670 -33.06320 28.79760 -31.20170 20.68610\0A-32.80860 -32.62700 58.06930 -2.87370 21.10220 -10.86220\0A-2.55130 26.24450 -5.86300 4.91520 -16.97370 -5.77170\0A-27.22742 -35.23272 16.63498 -18.45162 38.63838 25.63838\0A-4.58683 17.29767 -14.68683 -6.60703 26.28097 -17.69793\00"
@str.14 = [21 x i8] c"\0A\0A Transpose matrix \00"
@str.15 = [461 x i8] c"\0AExpected multiplication prior to covariance matrix (b*b')\0A3158.41375 351.58407 -995.33304 -613.17658 -720.63631 -1180.85189\0A351.58407 5896.00026 -4342.15094 1890.97606 -3540.04502 -256.36445\0A-995.33304 -4342.15094 5149.39843 -1617.44056 2644.62062 -839.09450\0A-613.17658 1890.97606 -1617.44056 1674.38695 -1980.86959 646.12372\0A-720.63631 -3540.04502 2644.62062 -1980.86959 3896.80272 -299.87242\0A-1180.85189 -256.36445 -839.09450 646.12372 -299.87242 1930.05954\00"
@str.16 = [52 x i8] c"\0A\0A Multiplication prior to covariance matrix (b*b')\00"
@str.17 = [403 x i8] c"\0AExpected covarianc matrix\0A526.40229 58.59735 -165.88884 -102.19610 -120.10605 -196.80865\0A58.59735 982.66671 -723.69182 315.16268 -590.00750 -42.72741\0A-165.88884 -723.69182 858.23307 -269.57343 440.77010 -139.84908\0A-102.19610 315.16268 -269.57343 279.06449 -330.14493 107.68729\0A-120.10605 -590.00750 440.77010 -330.14493 649.46712 -49.97874\0A-196.80865 -42.72741 -139.84908 107.68729 -49.97874 321.67659\00"
@str.18 = [19 x i8] c"\0ACovariance matrix\00"
define void @test_pca() {
%1 = alloca [36 x double]
%2 = bitcast [36 x double]* %1 to i8*
%3 = tail call i64 @calloc(i32 8, i32 6)
%4 = inttoptr i64 %3 to double*
%5 = tail call i64 @calloc(i32 8, i32 36)
%6 = inttoptr i64 %5 to double*
%7 = tail call i64 @calloc(i32 8, i32 36)
%8 = inttoptr i64 %7 to double*
%9 = tail call i64 @calloc(i32 8, i32 36)
%10 = inttoptr i64 %9 to double*
%11 = tail call i64 @calloc(i32 8, i32 6)
%12 = tail call i64 @calloc(i32 8, i32 36)
%13 = tail call i64 @calloc(i32 8, i32 36)
%14 = tail call i64 @calloc(i32 8, i32 36)
%15 = tail call i64 @calloc(i32 8, i32 36)
%16 = getelementptr inbounds [36 x double], [36 x double]* %1, i64 0, i64 0
%17 = call i32 @show_matrix(double* %16, i32 6, i32 6)
%18 = call i32 @stat_mean(double* %16, double* %4, i32 6, i32 6)
%19 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%21 = call i32 @show_matrix(double* %4, i32 1, i32 6)
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([380 x i8], [380 x i8]* @str.11, i64 0, i64 0))
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.12, i64 0, i64 0))
%24 = call i32 @mtx_deriv_mean(double* %6, double* %16, double* %4, i32 6, i32 6)
%25 = call i32 @show_matrix(double* %6, i32 6, i32 6)
%26 = call i32 @putchar(i32 10)
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([365 x i8], [365 x i8]* @str.13, i64 0, i64 0))
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.14, i64 0, i64 0))
%29 = call i32 @mtx_transpose(double* %6, double* %8, i32 6, i32 6)
%30 = call i32 @show_matrix(double* %8, i32 6, i32 6)
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([461 x i8], [461 x i8]* @str.15, i64 0, i64 0))
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.16, i64 0, i64 0))
%33 = call i32 @mtx_mult(double* %6, double* %8, double* %10, i32 6, i32 6, i32 6)
%34 = call i32 @show_matrix(double* %10, i32 6, i32 6)
%35 = inttoptr i64 %9 to <2 x double>*
%36 = load <2 x double>, <2 x double>* %35
%37 = fdiv <2 x double> %36, <double 6.000000e+00, double 6.000000e+00>
%38 = inttoptr i64 %9 to <2 x double>*
store <2 x double> %37, <2 x double>* %38
%39 = getelementptr inbounds double, double* %10, i64 2
%40 = bitcast double* %39 to <2 x double>*
%41 = load <2 x double>, <2 x double>* %40
%42 = fdiv <2 x double> %41, <double 6.000000e+00, double 6.000000e+00>
%43 = bitcast double* %39 to <2 x double>*
store <2 x double> %42, <2 x double>* %43
%44 = getelementptr inbounds double, double* %10, i64 4
%45 = bitcast double* %44 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = fdiv <2 x double> %46, <double 6.000000e+00, double 6.000000e+00>
%48 = bitcast double* %44 to <2 x double>*
store <2 x double> %47, <2 x double>* %48
%49 = getelementptr inbounds double, double* %10, i64 6
%50 = bitcast double* %49 to <2 x double>*
%51 = load <2 x double>, <2 x double>* %50
%52 = fdiv <2 x double> %51, <double 6.000000e+00, double 6.000000e+00>
%53 = bitcast double* %49 to <2 x double>*
store <2 x double> %52, <2 x double>* %53
%54 = getelementptr inbounds double, double* %10, i64 8
%55 = bitcast double* %54 to <2 x double>*
%56 = load <2 x double>, <2 x double>* %55
%57 = fdiv <2 x double> %56, <double 6.000000e+00, double 6.000000e+00>
%58 = bitcast double* %54 to <2 x double>*
store <2 x double> %57, <2 x double>* %58
%59 = getelementptr inbounds double, double* %10, i64 10
%60 = bitcast double* %59 to <2 x double>*
%61 = load <2 x double>, <2 x double>* %60
%62 = fdiv <2 x double> %61, <double 6.000000e+00, double 6.000000e+00>
%63 = bitcast double* %59 to <2 x double>*
store <2 x double> %62, <2 x double>* %63
%64 = getelementptr inbounds double, double* %10, i64 12
%65 = bitcast double* %64 to <2 x double>*
%66 = load <2 x double>, <2 x double>* %65
%67 = fdiv <2 x double> %66, <double 6.000000e+00, double 6.000000e+00>
%68 = bitcast double* %64 to <2 x double>*
store <2 x double> %67, <2 x double>* %68
%69 = getelementptr inbounds double, double* %10, i64 14
%70 = bitcast double* %69 to <2 x double>*
%71 = load <2 x double>, <2 x double>* %70
%72 = fdiv <2 x double> %71, <double 6.000000e+00, double 6.000000e+00>
%73 = bitcast double* %69 to <2 x double>*
store <2 x double> %72, <2 x double>* %73
%74 = getelementptr inbounds double, double* %10, i64 16
%75 = bitcast double* %74 to <2 x double>*
%76 = load <2 x double>, <2 x double>* %75
%77 = fdiv <2 x double> %76, <double 6.000000e+00, double 6.000000e+00>
%78 = bitcast double* %74 to <2 x double>*
store <2 x double> %77, <2 x double>* %78
%79 = getelementptr inbounds double, double* %10, i64 18
%80 = bitcast double* %79 to <2 x double>*
%81 = load <2 x double>, <2 x double>* %80
%82 = fdiv <2 x double> %81, <double 6.000000e+00, double 6.000000e+00>
%83 = bitcast double* %79 to <2 x double>*
store <2 x double> %82, <2 x double>* %83
%84 = getelementptr inbounds double, double* %10, i64 20
%85 = bitcast double* %84 to <2 x double>*
%86 = load <2 x double>, <2 x double>* %85
%87 = fdiv <2 x double> %86, <double 6.000000e+00, double 6.000000e+00>
%88 = bitcast double* %84 to <2 x double>*
store <2 x double> %87, <2 x double>* %88
%89 = getelementptr inbounds double, double* %10, i64 22
%90 = bitcast double* %89 to <2 x double>*
%91 = load <2 x double>, <2 x double>* %90
%92 = fdiv <2 x double> %91, <double 6.000000e+00, double 6.000000e+00>
%93 = bitcast double* %89 to <2 x double>*
store <2 x double> %92, <2 x double>* %93
%94 = getelementptr inbounds double, double* %10, i64 24
%95 = bitcast double* %94 to <2 x double>*
%96 = load <2 x double>, <2 x double>* %95
%97 = fdiv <2 x double> %96, <double 6.000000e+00, double 6.000000e+00>
%98 = bitcast double* %94 to <2 x double>*
store <2 x double> %97, <2 x double>* %98
%99 = getelementptr inbounds double, double* %10, i64 26
%100 = bitcast double* %99 to <2 x double>*
%101 = load <2 x double>, <2 x double>* %100
%102 = fdiv <2 x double> %101, <double 6.000000e+00, double 6.000000e+00>
%103 = bitcast double* %99 to <2 x double>*
store <2 x double> %102, <2 x double>* %103
%104 = getelementptr inbounds double, double* %10, i64 28
%105 = bitcast double* %104 to <2 x double>*
%106 = load <2 x double>, <2 x double>* %105
%107 = fdiv <2 x double> %106, <double 6.000000e+00, double 6.000000e+00>
%108 = bitcast double* %104 to <2 x double>*
store <2 x double> %107, <2 x double>* %108
%109 = getelementptr inbounds double, double* %10, i64 30
%110 = bitcast double* %109 to <2 x double>*
%111 = load <2 x double>, <2 x double>* %110
%112 = fdiv <2 x double> %111, <double 6.000000e+00, double 6.000000e+00>
%113 = bitcast double* %109 to <2 x double>*
store <2 x double> %112, <2 x double>* %113
%114 = getelementptr inbounds double, double* %10, i64 32
%115 = bitcast double* %114 to <2 x double>*
%116 = load <2 x double>, <2 x double>* %115
%117 = fdiv <2 x double> %116, <double 6.000000e+00, double 6.000000e+00>
%118 = bitcast double* %114 to <2 x double>*
store <2 x double> %117, <2 x double>* %118
%119 = getelementptr inbounds double, double* %10, i64 34
%120 = bitcast double* %119 to <2 x double>*
%121 = load <2 x double>, <2 x double>* %120
%122 = fdiv <2 x double> %121, <double 6.000000e+00, double 6.000000e+00>
%123 = bitcast double* %119 to <2 x double>*
store <2 x double> %122, <2 x double>* %123
%124 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([403 x i8], [403 x i8]* @str.17, i64 0, i64 0))
%125 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.18, i64 0, i64 0))
%126 = call i32 @show_matrix(double* %10, i32 6, i32 6)
ret void
}