#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 */
int /*<<< orphan*/ mtx_chol(double *, double *, 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);
void test_basic_mtx_op(void) {
  int dim_i = 3;
  int dim_j = 3;
  int dim_k = 4;
  double matrix_A[9] = {0.9572, 0.1419, 0.7922, 0.4854, 0.4218,
                        0.9595, 0.8003, 0.9157, 0.6557};
  double matrix_B[12] = {0.8147, 0.9134, 0.2785, 0.9649, 0.9058, 0.6324,
                         0.5469, 0.1576, 0.1270, 0.0975, 0.9575, 0.9706};
  double matrix_D[9] = {3.5712, 1.4007, 2.5214, 1.4007, 84.9129,
                        2.7030, 2.5214, 2.7030, 93.3993};
  double matrix_C[12];
  double matrix_B_prime[12];
  double matrix_L[9];
  double matrix_L_prime[9];
  double result = 0.0;
  printf("Show Matrix A\n");
  show_matrix(matrix_A, dim_i, dim_j);
  printf("Show Matrix B\n");
  show_matrix(matrix_B, dim_j, dim_k);
  printf("C = A * B\n");
  mtx_mult(matrix_A, matrix_B, matrix_C, dim_i, dim_j, dim_k);
  show_matrix(matrix_C, dim_i, dim_k);
  printf("B' = B\n");
  mtx_transpose(matrix_B, matrix_B_prime, dim_j, dim_k);
  show_matrix(matrix_B_prime, dim_k, dim_j);
  printf("Show Symmetric Matrix D\n");
  show_matrix(matrix_D, dim_i, dim_j);
  printf("L = chol(D)\n");
  mtx_chol(matrix_D, matrix_L, dim_i);
  show_matrix(matrix_L, dim_i, dim_i);
  printf("D = L*L'\n");
  mtx_transpose(matrix_L, matrix_L_prime, dim_i, dim_i);
  mtx_mult(matrix_L, matrix_L_prime, matrix_D, dim_i, dim_i, dim_i);
  show_matrix(matrix_D, dim_i, dim_i);
  printf("Matrix test results validated using Matlab: \n");
  printf("All good! 05/15, FS\n");
}


x86 assembly (clang, -O0):
<test_basic_mtx_op>:
push   %rbp
mov    %rsp,%rbp
sub    $0x280,%rsp
movl   $0x3,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
movl   $0x4,-0xc(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe75(%rip),%rsi
mov    $0x48,%edx
call   1070 <memcpy@plt>
lea    -0xc0(%rbp),%rdi
lea    0xead(%rip),%rsi
mov    $0x60,%edx
call   1070 <memcpy@plt>
lea    -0x110(%rbp),%rdi
lea    0xef5(%rip),%rsi
mov    $0x48,%edx
call   1070 <memcpy@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x278(%rbp)
ff
lea    0xf21(%rip),%rdi
call   1060 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1050 <show_matrix@plt>
lea    0xf15(%rip),%rdi
call   1060 <printf@plt>
lea    -0xc0(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1050 <show_matrix@plt>
lea    0xf06(%rip),%rdi
call   1060 <printf@plt>
lea    -0x60(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
lea    -0x170(%rbp),%rdx
mov    -0x4(%rbp),%ecx
mov    -0x8(%rbp),%r8d
mov    -0xc(%rbp),%r9d
call   1030 <mtx_mult@plt>
lea    -0x170(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1050 <show_matrix@plt>
lea    0xed1(%rip),%rdi
call   1060 <printf@plt>
lea    -0xc0(%rbp),%rdi
lea    -0x1d0(%rbp),%rsi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   1040 <mtx_transpose@plt>
lea    -0x1d0(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1050 <show_matrix@plt>
lea    0xea2(%rip),%rdi
call   1060 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1050 <show_matrix@plt>
lea    0xe9d(%rip),%rdi
call   1060 <printf@plt>
lea    -0x110(%rbp),%rdi
lea    -0x220(%rbp),%rsi
mov    -0x4(%rbp),%edx
call   1080 <mtx_chol@plt>
lea    -0x220(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%edx
call   1050 <show_matrix@plt>
lea    0xe76(%rip),%rdi
call   1060 <printf@plt>
lea    -0x220(%rbp),%rdi
lea    -0x270(%rbp),%rsi
mov    -0x4(%rbp),%edx
mov    -0x4(%rbp),%ecx
call   1040 <mtx_transpose@plt>
lea    -0x220(%rbp),%rdi
lea    -0x270(%rbp),%rsi
lea    -0x110(%rbp),%rdx
mov    -0x4(%rbp),%ecx
mov    -0x4(%rbp),%r8d
mov    -0x4(%rbp),%r9d
call   1030 <mtx_mult@plt>
lea    -0x110(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%edx
call   1050 <show_matrix@plt>
lea    0xe24(%rip),%rdi
call   1060 <printf@plt>
lea    0xe46(%rip),%rdi
call   1060 <printf@plt>
add    $0x280,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_basic_mtx_op>:
push   %r15
push   %r14
push   %rbx
sub    $0x260,%rsp
mov    0xedd(%rip),%rax
mov    %rax,0x90(%rsp)
movaps 0xebe(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xe9f(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xe83(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe67(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xefb(%rip),%xmm0
movaps %xmm0,0xf0(%rsp)
movaps 0xedc(%rip),%xmm0
movaps %xmm0,0xe0(%rsp)
movaps 0xebd(%rip),%xmm0
movaps %xmm0,0xd0(%rsp)
movaps 0xe9e(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movaps 0xe7f(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xe60(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
mov    0xef1(%rip),%rax
mov    %rax,0x40(%rsp)
movaps 0xed5(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeb9(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe9d(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe81(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xebe(%rip),%rdi
call   1050 <puts@plt>
lea    0x50(%rsp),%r14
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
call   1060 <show_matrix@plt>
lea    0xea9(%rip),%rdi
call   1050 <puts@plt>
lea    0xa0(%rsp),%r15
mov    %r15,%rdi
mov    $0x3,%esi
mov    $0x4,%edx
call   1060 <show_matrix@plt>
lea    0xe91(%rip),%rdi
call   1050 <puts@plt>
lea    0x200(%rsp),%rbx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    $0x3,%ecx
mov    $0x3,%r8d
mov    $0x4,%r9d
call   1030 <mtx_mult@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x4,%edx
call   1060 <show_matrix@plt>
lea    0xe56(%rip),%rdi
call   1050 <puts@plt>
lea    0x1a0(%rsp),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
mov    $0x4,%ecx
call   1040 <mtx_transpose@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x3,%edx
call   1060 <show_matrix@plt>
lea    0xe22(%rip),%rdi
call   1050 <puts@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
call   1060 <show_matrix@plt>
lea    0xe19(%rip),%rdi
call   1050 <puts@plt>
lea    0x150(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1070 <mtx_chol@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
call   1060 <show_matrix@plt>
lea    0xdef(%rip),%rdi
call   1050 <puts@plt>
lea    0x100(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x3,%edx
mov    $0x3,%ecx
call   1040 <mtx_transpose@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    $0x3,%ecx
mov    $0x3,%r8d
mov    $0x3,%r9d
call   1030 <mtx_mult@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
call   1060 <show_matrix@plt>
lea    0xd9e(%rip),%rdi
call   1050 <puts@plt>
lea    0xdbf(%rip),%rdi
call   1050 <puts@plt>
add    $0x260,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.test_basic_mtx_op.matrix_A = [9 x double] [double 9.572000e-01, double 1.419000e-01, double 7.922000e-01, double 4.854000e-01, double 4.218000e-01, double 9.595000e-01, double 8.003000e-01, double 0x3FED4D6A161E4F76, double 6.557000e-01]
@__const.test_basic_mtx_op.matrix_B = [12 x double] [double 0x3FEA1205BC01A36E, double 0x3FED3A92A3055326, double 2.785000e-01, double 0x3FEEE075F6FD21FF, double 9.058000e-01, double 6.324000e-01, double 5.469000e-01, double 1.576000e-01, double 1.270000e-01, double 9.750000e-02, double 9.575000e-01, double 9.706000e-01]
@__const.test_basic_mtx_op.matrix_D = [9 x double] [double 3.571200e+00, double 1.400700e+00, double 2.521400e+00, double 1.400700e+00, double 0x40553A6CF41F212D, double 2.703000e+00, double 2.521400e+00, double 2.703000e+00, double 0x4057598E219652BD]
@.str = [15 x i8] c"Show Matrix A\0A\00"
@.str.1 = [15 x i8] c"Show Matrix B\0A\00"
@.str.2 = [11 x i8] c"C = A * B\0A\00"
@.str.3 = [8 x i8] c"B' = B\0A\00"
@.str.4 = [25 x i8] c"Show Symmetric Matrix D\0A\00"
@.str.5 = [13 x i8] c"L = chol(D)\0A\00"
@.str.6 = [10 x i8] c"D = L*L'\0A\00"
@.str.7 = [46 x i8] c"Matrix test results validated using Matlab: \0A\00"
@.str.8 = [21 x i8] c"All good! 05/15, FS\0A\00"
define void @test_basic_mtx_op() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [9 x double]
%5 = alloca [12 x double]
%6 = alloca [9 x double]
%7 = alloca [12 x double]
%8 = alloca [12 x double]
%9 = alloca [9 x double]
%10 = alloca [9 x double]
%11 = alloca double
store i32 3, i32* %1
store i32 3, i32* %2
store i32 4, i32* %3
%12 = bitcast [9 x double]* %4 to i8*
%13 = bitcast [12 x double]* %5 to i8*
%14 = bitcast [9 x double]* %6 to i8*
store double 0.000000e+00, double* %11
%15 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%16 = getelementptr inbounds [9 x double], [9 x double]* %4, i64 0, i64 0
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = call i32 @show_matrix(double* %16, i32 %17, i32 %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%21 = getelementptr inbounds [12 x double], [12 x double]* %5, i64 0, i64 0
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = call i32 @show_matrix(double* %21, i32 %22, i32 %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%26 = getelementptr inbounds [9 x double], [9 x double]* %4, i64 0, i64 0
%27 = getelementptr inbounds [12 x double], [12 x double]* %5, i64 0, i64 0
%28 = getelementptr inbounds [12 x double], [12 x double]* %7, i64 0, i64 0
%29 = load i32, i32* %1
%30 = load i32, i32* %2
%31 = load i32, i32* %3
%32 = call i32 @mtx_mult(double* %26, double* %27, double* %28, i32 %29, i32 %30, i32 %31)
%33 = getelementptr inbounds [12 x double], [12 x double]* %7, i64 0, i64 0
%34 = load i32, i32* %1
%35 = load i32, i32* %3
%36 = call i32 @show_matrix(double* %33, i32 %34, i32 %35)
%37 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%38 = getelementptr inbounds [12 x double], [12 x double]* %5, i64 0, i64 0
%39 = getelementptr inbounds [12 x double], [12 x double]* %8, i64 0, i64 0
%40 = load i32, i32* %2
%41 = load i32, i32* %3
%42 = call i32 @mtx_transpose(double* %38, double* %39, i32 %40, i32 %41)
%43 = getelementptr inbounds [12 x double], [12 x double]* %8, i64 0, i64 0
%44 = load i32, i32* %3
%45 = load i32, i32* %2
%46 = call i32 @show_matrix(double* %43, i32 %44, i32 %45)
%47 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%48 = getelementptr inbounds [9 x double], [9 x double]* %6, i64 0, i64 0
%49 = load i32, i32* %1
%50 = load i32, i32* %2
%51 = call i32 @show_matrix(double* %48, i32 %49, i32 %50)
%52 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%53 = getelementptr inbounds [9 x double], [9 x double]* %6, i64 0, i64 0
%54 = getelementptr inbounds [9 x double], [9 x double]* %9, i64 0, i64 0
%55 = load i32, i32* %1
%56 = call i32 @mtx_chol(double* %53, double* %54, i32 %55)
%57 = getelementptr inbounds [9 x double], [9 x double]* %9, i64 0, i64 0
%58 = load i32, i32* %1
%59 = load i32, i32* %1
%60 = call i32 @show_matrix(double* %57, i32 %58, i32 %59)
%61 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%62 = getelementptr inbounds [9 x double], [9 x double]* %9, i64 0, i64 0
%63 = getelementptr inbounds [9 x double], [9 x double]* %10, i64 0, i64 0
%64 = load i32, i32* %1
%65 = load i32, i32* %1
%66 = call i32 @mtx_transpose(double* %62, double* %63, i32 %64, i32 %65)
%67 = getelementptr inbounds [9 x double], [9 x double]* %9, i64 0, i64 0
%68 = getelementptr inbounds [9 x double], [9 x double]* %10, i64 0, i64 0
%69 = getelementptr inbounds [9 x double], [9 x double]* %6, i64 0, i64 0
%70 = load i32, i32* %1
%71 = load i32, i32* %1
%72 = load i32, i32* %1
%73 = call i32 @mtx_mult(double* %67, double* %68, double* %69, i32 %70, i32 %71, i32 %72)
%74 = getelementptr inbounds [9 x double], [9 x double]* %6, i64 0, i64 0
%75 = load i32, i32* %1
%76 = load i32, i32* %1
%77 = call i32 @show_matrix(double* %74, i32 %75, i32 %76)
%78 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0))
%79 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__const.test_basic_mtx_op.matrix_A = [9 x double] [double 9.572000e-01, double 1.419000e-01, double 7.922000e-01, double 4.854000e-01, double 4.218000e-01, double 9.595000e-01, double 8.003000e-01, double 0x3FED4D6A161E4F76, double 6.557000e-01]
@__const.test_basic_mtx_op.matrix_B = [12 x double] [double 0x3FEA1205BC01A36E, double 0x3FED3A92A3055326, double 2.785000e-01, double 0x3FEEE075F6FD21FF, double 9.058000e-01, double 6.324000e-01, double 5.469000e-01, double 1.576000e-01, double 1.270000e-01, double 9.750000e-02, double 9.575000e-01, double 9.706000e-01]
@__const.test_basic_mtx_op.matrix_D = [9 x double] [double 3.571200e+00, double 1.400700e+00, double 2.521400e+00, double 1.400700e+00, double 0x40553A6CF41F212D, double 2.703000e+00, double 2.521400e+00, double 2.703000e+00, double 0x4057598E219652BD]
@str = [14 x i8] c"Show Matrix A\00"
@str.9 = [14 x i8] c"Show Matrix B\00"
@str.10 = [10 x i8] c"C = A * B\00"
@str.11 = [7 x i8] c"B' = B\00"
@str.12 = [24 x i8] c"Show Symmetric Matrix D\00"
@str.13 = [12 x i8] c"L = chol(D)\00"
@str.14 = [9 x i8] c"D = L*L'\00"
@str.15 = [45 x i8] c"Matrix test results validated using Matlab: \00"
@str.16 = [20 x i8] c"All good! 05/15, FS\00"
define void @test_basic_mtx_op() {
%1 = alloca [9 x double]
%2 = alloca [12 x double]
%3 = alloca [9 x double]
%4 = alloca [12 x double]
%5 = alloca [12 x double]
%6 = alloca [9 x double]
%7 = alloca [9 x double]
%8 = bitcast [9 x double]* %1 to i8*
%9 = bitcast [12 x double]* %2 to i8*
%10 = bitcast [9 x double]* %3 to i8*
%11 = bitcast [12 x double]* %4 to i8*
%12 = bitcast [12 x double]* %5 to i8*
%13 = bitcast [9 x double]* %6 to i8*
%14 = bitcast [9 x double]* %7 to i8*
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%16 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 0
%17 = call i32 @show_matrix(double* %16, i32 3, i32 3)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.9, i64 0, i64 0))
%19 = getelementptr inbounds [12 x double], [12 x double]* %2, i64 0, i64 0
%20 = call i32 @show_matrix(double* %19, i32 3, i32 4)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.10, i64 0, i64 0))
%22 = getelementptr inbounds [12 x double], [12 x double]* %4, i64 0, i64 0
%23 = call i32 @mtx_mult(double* %16, double* %19, double* %22, i32 3, i32 3, i32 4)
%24 = call i32 @show_matrix(double* %22, i32 3, i32 4)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.11, i64 0, i64 0))
%26 = getelementptr inbounds [12 x double], [12 x double]* %5, i64 0, i64 0
%27 = call i32 @mtx_transpose(double* %19, double* %26, i32 3, i32 4)
%28 = call i32 @show_matrix(double* %26, i32 4, i32 3)
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.12, i64 0, i64 0))
%30 = getelementptr inbounds [9 x double], [9 x double]* %3, i64 0, i64 0
%31 = call i32 @show_matrix(double* %30, i32 3, i32 3)
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.13, i64 0, i64 0))
%33 = getelementptr inbounds [9 x double], [9 x double]* %6, i64 0, i64 0
%34 = call i32 @mtx_chol(double* %30, double* %33, i32 3)
%35 = call i32 @show_matrix(double* %33, i32 3, i32 3)
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.14, i64 0, i64 0))
%37 = getelementptr inbounds [9 x double], [9 x double]* %7, i64 0, i64 0
%38 = call i32 @mtx_transpose(double* %33, double* %37, i32 3, i32 3)
%39 = call i32 @mtx_mult(double* %33, double* %37, double* %30, i32 3, i32 3, i32 3)
%40 = call i32 @show_matrix(double* %30, i32 3, i32 3)
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.15, i64 0, i64 0))
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.16, i64 0, i64 0))
ret void
}