#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 **allocateDoubleMatrix(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
double *gaussianElimination(int, double **, double *);
int /*<<< orphan*/ printVector(double *, int);
int /*<<< orphan*/ stdout;
void testGaussianElimination() {
  double **A;
  int n;
  double *x;
  n = 3;
  double b[n];
  A = allocateDoubleMatrix(3, 3);
  A[0][0] = 1.0;
  A[0][1] = 1.0;
  A[0][2] = -1.0;
  A[1][0] = 1.0;
  A[1][1] = 2.0;
  A[1][2] = 1.0;
  A[2][0] = 2.0;
  A[2][1] = -1.0;
  A[2][2] = 1.0;
  b[0] = 2.0;
  b[1] = 6.0;
  b[2] = 1.0;
  x = gaussianElimination(n, A, b);
  fprintf(stdout, "Gaussian Elimination\n");
  printVector(x, n);
}


x86 assembly (clang, -O0):
<testGaussianElimination>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x3,-0xc(%rbp)
mov    -0xc(%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    $0x3,%esi
mov    %esi,%edi
call   1030 <allocateDoubleMatrix@plt>
mov    -0x30(%rbp),%rdx
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsd  0xe67(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsd  0xe54(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsd  0xe58(%rip),%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movsd  0xe2b(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movsd  0xe27(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movsd  0xe02(%rip),%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
movsd  0xdfd(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
movsd  0xdf1(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
movsd  0xdc4(%rip),%xmm0
movsd  %xmm0,0x10(%rax)
movsd  0xdc7(%rip),%xmm0
movsd  %xmm0,(%rdx)
movsd  0xdb3(%rip),%xmm0
movsd  %xmm0,0x8(%rdx)
movsd  0xd9e(%rip),%xmm0
movsd  %xmm0,0x10(%rdx)
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1060 <gaussianElimination@plt>
mov    %rax,-0x18(%rbp)
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
lea    0xd99(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <printVector@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testGaussianElimination>:
push   %rbx
sub    $0x20,%rsp
mov    $0x3,%edi
mov    $0x3,%esi
call   1030 <allocateDoubleMatrix@plt>
mov    (%rax),%rcx
movaps 0xea2(%rip),%xmm0
movups %xmm0,(%rcx)
movabs $0xbff0000000000000,%rdx
mov    %rdx,0x10(%rcx)
mov    0x8(%rax),%rcx
movaps 0xe96(%rip),%xmm0
movups %xmm0,(%rcx)
movabs $0x3ff0000000000000,%rdx
mov    %rdx,0x10(%rcx)
mov    0x10(%rax),%rcx
movaps 0xe8a(%rip),%xmm0
movups %xmm0,(%rcx)
mov    %rdx,0x10(%rcx)
movaps 0xe8c(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rdx,0x10(%rsp)
mov    %rsp,%rdx
mov    $0x3,%edi
mov    %rax,%rsi
call   1060 <gaussianElimination@plt>
mov    %rax,%rbx
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%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 = [22 x i8] c"Gaussian Elimination\0A\00"
define void @testGaussianElimination() {
%1 = alloca double**
%2 = alloca i32
%3 = alloca double*
%4 = alloca i8*
%5 = alloca i64
store i32 3, i32* %2
%6 = load i32, i32* %2
%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 = call double** @allocateDoubleMatrix(i32 3, i32 3)
store double** %10, double*** %1
%11 = load double**, double*** %1
%12 = getelementptr inbounds double*, double** %11, i64 0
%13 = load double*, double** %12
%14 = getelementptr inbounds double, double* %13, i64 0
store double 1.000000e+00, double* %14
%15 = load double**, double*** %1
%16 = getelementptr inbounds double*, double** %15, i64 0
%17 = load double*, double** %16
%18 = getelementptr inbounds double, double* %17, i64 1
store double 1.000000e+00, double* %18
%19 = load double**, double*** %1
%20 = getelementptr inbounds double*, double** %19, i64 0
%21 = load double*, double** %20
%22 = getelementptr inbounds double, double* %21, i64 2
store double -1.000000e+00, double* %22
%23 = load double**, double*** %1
%24 = getelementptr inbounds double*, double** %23, i64 1
%25 = load double*, double** %24
%26 = getelementptr inbounds double, double* %25, i64 0
store double 1.000000e+00, double* %26
%27 = load double**, double*** %1
%28 = getelementptr inbounds double*, double** %27, i64 1
%29 = load double*, double** %28
%30 = getelementptr inbounds double, double* %29, i64 1
store double 2.000000e+00, double* %30
%31 = load double**, double*** %1
%32 = getelementptr inbounds double*, double** %31, i64 1
%33 = load double*, double** %32
%34 = getelementptr inbounds double, double* %33, i64 2
store double 1.000000e+00, double* %34
%35 = load double**, double*** %1
%36 = getelementptr inbounds double*, double** %35, i64 2
%37 = load double*, double** %36
%38 = getelementptr inbounds double, double* %37, i64 0
store double 2.000000e+00, double* %38
%39 = load double**, double*** %1
%40 = getelementptr inbounds double*, double** %39, i64 2
%41 = load double*, double** %40
%42 = getelementptr inbounds double, double* %41, i64 1
store double -1.000000e+00, double* %42
%43 = load double**, double*** %1
%44 = getelementptr inbounds double*, double** %43, i64 2
%45 = load double*, double** %44
%46 = getelementptr inbounds double, double* %45, i64 2
store double 1.000000e+00, double* %46
%47 = getelementptr inbounds double, double* %9, i64 0
store double 2.000000e+00, double* %47
%48 = getelementptr inbounds double, double* %9, i64 1
store double 6.000000e+00, double* %48
%49 = getelementptr inbounds double, double* %9, i64 2
store double 1.000000e+00, double* %49
%50 = load i32, i32* %2
%51 = load double**, double*** %1
%52 = call double* @gaussianElimination(i32 %50, double** %51, double* %9)
store double* %52, double** %3
%53 = load i32, i32* @stdout
%54 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%55 = load double*, double** %3
%56 = load i32, i32* %2
%57 = call i32 @printVector(double* %55, i32 %56)
%58 = load i8*, i8** %4
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [22 x i8] c"Gaussian Elimination\0A\00"
define void @testGaussianElimination() {
%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 1.000000e+00, double 1.000000e+00>, <2 x double>* %5
%6 = getelementptr inbounds double, double* %4, i64 2
store double -1.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 1.000000e+00, double 2.000000e+00>, <2 x double>* %9
%10 = getelementptr inbounds double, double* %8, i64 2
store double 1.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 2.000000e+00, double -1.000000e+00>, <2 x double>* %13
%14 = getelementptr inbounds double, double* %12, i64 2
store double 1.000000e+00, double* %14
%15 = bitcast [3 x double]* %1 to <2 x double>*
store <2 x double> <double 2.000000e+00, double 6.000000e+00>, <2 x double>* %15
%16 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 2
store double 1.000000e+00, double* %16
%17 = call double* @gaussianElimination(i32 3, double** %3, double* %2)
%18 = load i32, i32* @stdout
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @printVector(double* %17, i32 3)
ret void
}