#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 */
double *LUSolver(double **, double *, int);
double **allocateDoubleMatrix(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printVector(double *, int);
int /*<<< orphan*/ stdout;
void testLUSolver() {
  double **A, *x;
  int n;
  n = 3;
  double b[n];
  A = 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;
  b[0] = 4.0;
  b[1] = 19.0;
  b[2] = -6.0;
  x = LUSolver(A, b, n);
  fprintf(stdout, "LU solver U:\n");
  printVector(x, n);
}


x86 assembly (clang, -O0):
<testLUSolver>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x3,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1030 <allocateDoubleMatrix@plt>
mov    -0x30(%rbp),%rsi
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsd  0xeb0(%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  0xe86(%rip),%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movsd  0xe69(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movsd  0xe3d(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movsd  0xe38(%rip),%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
movsd  0xe1b(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
movsd  0xdff(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
movsd  0xde2(%rip),%xmm0
movsd  %xmm0,0x10(%rax)
movsd  0xdcd(%rip),%xmm0
movsd  %xmm0,(%rsi)
movsd  0xdb9(%rip),%xmm0
movsd  %xmm0,0x8(%rsi)
movsd  0xda4(%rip),%xmm0
movsd  %xmm0,0x10(%rsi)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
call   1060 <LUSolver@plt>
mov    %rax,-0x10(%rbp)
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
lea    0xdcf(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <printVector@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testLUSolver>:
push   %rbx
sub    $0x20,%rsp
mov    $0x3,%edi
mov    $0x3,%esi
call   1030 <allocateDoubleMatrix@plt>
mov    (%rax),%rcx
movsd  0xea1(%rip),%xmm0
movups %xmm0,(%rcx)
movabs $0x4000000000000000,%rdx
mov    %rdx,0x10(%rcx)
mov    0x8(%rax),%rcx
movaps 0xe95(%rip),%xmm0
movups %xmm0,(%rcx)
movabs $0x4020000000000000,%rdx
mov    %rdx,0x10(%rcx)
mov    0x10(%rax),%rcx
movaps 0xe89(%rip),%xmm0
movups %xmm0,(%rcx)
movabs $0xc008000000000000,%rdx
mov    %rdx,0x10(%rcx)
movaps 0xe81(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0xc018000000000000,%rcx
mov    %rcx,0x10(%rsp)
mov    %rsp,%rsi
mov    %rax,%rdi
mov    $0x3,%edx
call   1060 <LUSolver@plt>
mov    %rax,%rbx
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
lea    0xe5b(%rip),%rsi
call   1050 <fprintf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <printVector@plt>
add    $0x20,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@stdout = global i32 0
@.str = [14 x i8] c"LU solver U:\0A\00"
define void @testLUSolver() {
%1 = alloca [3 x double]
%2 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
%3 = tail call double** @allocateDoubleMatrix(i32 3, i32 3)
%4 = load double*, double** %3
%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** %3, 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** %3, 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 = bitcast [3 x double]* %1 to <2 x double>*
store <2 x double> <double 4.000000e+00, double 1.900000e+01>, <2 x double>* %15
%16 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 2
store double -6.000000e+00, double* %16
%17 = call double* @LUSolver(double** %3, double* %2, i32 3)
%18 = load i32, i32* @stdout
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @printVector(double* %17, i32 3)
ret void
}