#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*/ LUFactotisation(int, double **, double **, double **);
double **allocateDoubleMatrix(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printMatrix(double **, int, int);
int /*<<< orphan*/ stdout;
void testLUFactorisation() {
  double **A, **L, **U;
  int n;
  n = 3;
  A = allocateDoubleMatrix(n, n);
  L = allocateDoubleMatrix(n, n);
  U = allocateDoubleMatrix(n, n);
  A[0][0] = 6.0;
  A[0][1] = 0.0;
  A[0][2] = 2.0;
  A[1][0] = 24.0;
  A[1][1] = 1.0;
  A[1][2] = 8.0;
  A[2][0] = -12.0;
  A[2][1] = 1.0;
  A[2][2] = -3.0;
  LUFactotisation(n, A, U, L);
  fprintf(stdout, "Matrix Factorisation U:\n");
  printMatrix(U, n, n);
  fprintf(stdout, "Matrix Factorisation L:\n");
  printMatrix(L, n, n);
}


x86 assembly (clang, -O0):
<testLUFactorisation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x3,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1030 <allocateDoubleMatrix@plt>
mov    %rax,-0x8(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1030 <allocateDoubleMatrix@plt>
mov    %rax,-0x10(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1030 <allocateDoubleMatrix@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsd  0xea5(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsd  0xe7b(%rip),%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movsd  0xe5e(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movsd  0xe32(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movsd  0xe2d(%rip),%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
movsd  0xe10(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
movsd  0xdf4(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
movsd  0xdd7(%rip),%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x1c(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
call   1040 <LUFactotisation@plt>
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
lea    0xde6(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1060 <printMatrix@plt>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
lea    0xddb(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1060 <printMatrix@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testLUFactorisation>:
push   %r15
push   %r14
push   %rbx
mov    $0x3,%edi
mov    $0x3,%esi
call   1030 <allocateDoubleMatrix@plt>
mov    %rax,%rbx
mov    $0x3,%edi
mov    $0x3,%esi
call   1030 <allocateDoubleMatrix@plt>
mov    %rax,%r14
mov    $0x3,%edi
mov    $0x3,%esi
call   1030 <allocateDoubleMatrix@plt>
mov    %rax,%r15
mov    (%rbx),%rax
movsd  0xe7a(%rip),%xmm0
movups %xmm0,(%rax)
movabs $0x4000000000000000,%rcx
mov    %rcx,0x10(%rax)
mov    0x8(%rbx),%rax
movaps 0xe6e(%rip),%xmm0
movups %xmm0,(%rax)
movabs $0x4020000000000000,%rcx
mov    %rcx,0x10(%rax)
mov    0x10(%rbx),%rax
movaps 0xe62(%rip),%xmm0
movups %xmm0,(%rax)
movabs $0xc008000000000000,%rcx
mov    %rcx,0x10(%rax)
mov    $0x3,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <LUFactotisation@plt>
mov    0x2df7(%rip),%rbx
mov    (%rbx),%edi
lea    0xe3e(%rip),%rsi
call   1050 <fprintf@plt>
mov    %r15,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
call   1060 <printMatrix@plt>
mov    (%rbx),%edi
lea    0xe37(%rip),%rsi
call   1050 <fprintf@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <printMatrix@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [25 x i8] c"Matrix Factorisation U:\0A\00"
@.str.1 = [25 x i8] c"Matrix Factorisation L:\0A\00"
define void @testLUFactorisation() {
%1 = alloca double**
%2 = alloca double**
%3 = alloca double**
%4 = alloca i32
store i32 3, i32* %4
%5 = load i32, i32* %4
%6 = load i32, i32* %4
%7 = call double** @allocateDoubleMatrix(i32 %5, i32 %6)
store double** %7, double*** %1
%8 = load i32, i32* %4
%9 = load i32, i32* %4
%10 = call double** @allocateDoubleMatrix(i32 %8, i32 %9)
store double** %10, double*** %2
%11 = load i32, i32* %4
%12 = load i32, i32* %4
%13 = call double** @allocateDoubleMatrix(i32 %11, i32 %12)
store double** %13, double*** %3
%14 = load double**, double*** %1
%15 = getelementptr inbounds double*, double** %14, i64 0
%16 = load double*, double** %15
%17 = getelementptr inbounds double, double* %16, i64 0
store double 6.000000e+00, double* %17
%18 = load double**, double*** %1
%19 = getelementptr inbounds double*, double** %18, i64 0
%20 = load double*, double** %19
%21 = getelementptr inbounds double, double* %20, i64 1
store double 0.000000e+00, double* %21
%22 = load double**, double*** %1
%23 = getelementptr inbounds double*, double** %22, i64 0
%24 = load double*, double** %23
%25 = getelementptr inbounds double, double* %24, i64 2
store double 2.000000e+00, double* %25
%26 = load double**, double*** %1
%27 = getelementptr inbounds double*, double** %26, i64 1
%28 = load double*, double** %27
%29 = getelementptr inbounds double, double* %28, i64 0
store double 2.400000e+01, double* %29
%30 = load double**, double*** %1
%31 = getelementptr inbounds double*, double** %30, i64 1
%32 = load double*, double** %31
%33 = getelementptr inbounds double, double* %32, i64 1
store double 1.000000e+00, double* %33
%34 = load double**, double*** %1
%35 = getelementptr inbounds double*, double** %34, i64 1
%36 = load double*, double** %35
%37 = getelementptr inbounds double, double* %36, i64 2
store double 8.000000e+00, double* %37
%38 = load double**, double*** %1
%39 = getelementptr inbounds double*, double** %38, i64 2
%40 = load double*, double** %39
%41 = getelementptr inbounds double, double* %40, i64 0
store double -1.200000e+01, double* %41
%42 = load double**, double*** %1
%43 = getelementptr inbounds double*, double** %42, i64 2
%44 = load double*, double** %43
%45 = getelementptr inbounds double, double* %44, i64 1
store double 1.000000e+00, double* %45
%46 = load double**, double*** %1
%47 = getelementptr inbounds double*, double** %46, i64 2
%48 = load double*, double** %47
%49 = getelementptr inbounds double, double* %48, i64 2
store double -3.000000e+00, double* %49
%50 = load i32, i32* %4
%51 = load double**, double*** %1
%52 = load double**, double*** %3
%53 = load double**, double*** %2
%54 = call i32 @LUFactotisation(i32 %50, double** %51, double** %52, double** %53)
%55 = load i32, i32* @stdout
%56 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%57 = load double**, double*** %3
%58 = load i32, i32* %4
%59 = load i32, i32* %4
%60 = call i32 @printMatrix(double** %57, i32 %58, i32 %59)
%61 = load i32, i32* @stdout
%62 = call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%63 = load double**, double*** %2
%64 = load i32, i32* %4
%65 = load i32, i32* %4
%66 = call i32 @printMatrix(double** %63, i32 %64, i32 %65)
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [25 x i8] c"Matrix Factorisation U:\0A\00"
@.str.1 = [25 x i8] c"Matrix Factorisation L:\0A\00"
define void @testLUFactorisation() {
%1 = tail call double** @allocateDoubleMatrix(i32 3, i32 3)
%2 = tail call double** @allocateDoubleMatrix(i32 3, i32 3)
%3 = tail call double** @allocateDoubleMatrix(i32 3, i32 3)
%4 = load double*, double** %1
%5 = bitcast double* %4 to <2 x double>*
store <2 x double> <double 6.000000e+00, double 0.000000e+00>, <2 x double>* %5
%6 = getelementptr inbounds double, double* %4, i64 2
store double 2.000000e+00, double* %6
%7 = getelementptr inbounds double*, double** %1, i64 1
%8 = load double*, double** %7
%9 = bitcast double* %8 to <2 x double>*
store <2 x double> <double 2.400000e+01, double 1.000000e+00>, <2 x double>* %9
%10 = getelementptr inbounds double, double* %8, i64 2
store double 8.000000e+00, double* %10
%11 = getelementptr inbounds double*, double** %1, i64 2
%12 = load double*, double** %11
%13 = bitcast double* %12 to <2 x double>*
store <2 x double> <double -1.200000e+01, double 1.000000e+00>, <2 x double>* %13
%14 = getelementptr inbounds double, double* %12, i64 2
store double -3.000000e+00, double* %14
%15 = tail call i32 @LUFactotisation(i32 3, double** %1, double** %3, double** %2)
%16 = load i32, i32* @stdout
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%18 = tail call i32 @printMatrix(double** %3, i32 3, i32 3)
%19 = load i32, i32* @stdout
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%21 = tail call i32 @printMatrix(double** %2, i32 3, i32 3)
ret void
}