#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 **paw_alloc_2d_array(int, int);
int /*<<< orphan*/ paw_get_inverse(double **, int);
int /*<<< orphan*/ printf(char *, double, double);
void paw_test_matrix_inverse() {
  int i, j, k;
  int n;
  double **a;
  double **b;
  double **c;
  n = 2;
  a = paw_alloc_2d_array(n, n);
  b = paw_alloc_2d_array(n, n);
  c = paw_alloc_2d_array(n, n);
  a[0][0] = 1.0;
  a[0][1] = 2.0;
  a[1][0] = 2.0;
  a[1][1] = 3.0;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) {
      b[i][j] = a[i][j];
      c[i][j] = 0.0;
    }
  paw_get_inverse(b, 2);
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      for (k = 0; k < n; k++) {
        c[i][j] = c[i][j] + a[i][k] * b[k][j];
      }
  for (j = 0; j < n; j++)
    printf("%f\t%f\n", c[0][j], c[1][j]);
}


x86 assembly (clang, -O0):
<paw_test_matrix_inverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <paw_alloc_2d_array@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <paw_alloc_2d_array@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <paw_alloc_2d_array@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsd  0xe95(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsd  0xe7a(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
movsd  0xe65(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
movsd  0xe49(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1245 <paw_test_matrix_inverse+0x115>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1232 <paw_test_matrix_inverse+0x102>
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x8(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x8(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d6 <paw_test_matrix_inverse+0xa6>
jmp    1237 <paw_test_matrix_inverse+0x107>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11c3 <paw_test_matrix_inverse+0x93>
mov    -0x20(%rbp),%rdi
mov    $0x2,%esi
call   1050 <paw_get_inverse@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    131c <paw_test_matrix_inverse+0x1ec>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1309 <paw_test_matrix_inverse+0x1d9>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    12f6 <paw_test_matrix_inverse+0x1c6>
mov    -0x28(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x8(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1280 <paw_test_matrix_inverse+0x150>
jmp    12fb <paw_test_matrix_inverse+0x1cb>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    126d <paw_test_matrix_inverse+0x13d>
jmp    130e <paw_test_matrix_inverse+0x1de>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    125a <paw_test_matrix_inverse+0x12a>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    136a <paw_test_matrix_inverse+0x23a>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
movslq -0x8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
lea    0xcc1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1323 <paw_test_matrix_inverse+0x1f3>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<paw_test_matrix_inverse>:
push   %r15
push   %r14
push   %rbx
mov    $0x2,%edi
mov    $0x2,%esi
call   1040 <paw_alloc_2d_array@plt>
mov    %rax,%r14
mov    $0x2,%edi
mov    $0x2,%esi
call   1040 <paw_alloc_2d_array@plt>
mov    %rax,%rbx
mov    $0x2,%edi
mov    $0x2,%esi
call   1040 <paw_alloc_2d_array@plt>
mov    %rax,%r15
mov    (%r14),%rax
movaps 0xe8b(%rip),%xmm0
movups %xmm0,(%rax)
mov    0x8(%r14),%rcx
movaps 0xe8d(%rip),%xmm0
movups %xmm0,(%rcx)
mov    (%rbx),%rdx
mov    (%r15),%rsi
movsd  (%rax),%xmm0
movsd  %xmm0,(%rdx)
movq   $0x0,(%rsi)
movsd  0x8(%rax),%xmm0
movsd  %xmm0,0x8(%rdx)
movq   $0x0,0x8(%rsi)
mov    0x8(%rbx),%rax
mov    0x8(%r15),%rdx
movsd  (%rcx),%xmm0
movsd  %xmm0,(%rax)
movq   $0x0,(%rdx)
movsd  0x8(%rcx),%xmm0
movsd  %xmm0,0x8(%rax)
movq   $0x0,0x8(%rdx)
mov    %rbx,%rdi
mov    $0x2,%esi
call   1050 <paw_get_inverse@plt>
mov    (%r15),%rax
mov    (%r14),%rsi
movsd  (%rsi),%xmm0
mov    (%rbx),%rcx
mulsd  (%rcx),%xmm0
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
movsd  0x8(%rsi),%xmm1
mov    0x8(%rbx),%rdx
mulsd  (%rdx),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rax)
movsd  (%rsi),%xmm0
mulsd  0x8(%rcx),%xmm0
addsd  0x8(%rax),%xmm0
movsd  %xmm0,0x8(%rax)
movsd  0x8(%rsi),%xmm1
mulsd  0x8(%rdx),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rax)
mov    0x8(%r15),%rsi
mov    0x8(%r14),%rdi
movsd  (%rdi),%xmm0
mulsd  (%rcx),%xmm0
addsd  (%rsi),%xmm0
movsd  %xmm0,(%rsi)
movsd  0x8(%rdi),%xmm1
mulsd  (%rdx),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsi)
movsd  (%rdi),%xmm0
mulsd  0x8(%rcx),%xmm0
addsd  0x8(%rsi),%xmm0
movsd  %xmm0,0x8(%rsi)
movsd  0x8(%rdi),%xmm2
mulsd  0x8(%rdx),%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsi)
movsd  (%rax),%xmm0
lea    0xd8f(%rip),%rbx
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    (%r15),%rax
mov    0x8(%r15),%rcx
movsd  0x8(%rax),%xmm0
movsd  0x8(%rcx),%xmm1
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%f\09%f\0A\00"
define void @paw_test_matrix_inverse() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double**
%6 = alloca double**
%7 = alloca double**
store i32 2, i32* %4
%8 = load i32, i32* %4
%9 = load i32, i32* %4
%10 = call double** @paw_alloc_2d_array(i32 %8, i32 %9)
store double** %10, double*** %5
%11 = load i32, i32* %4
%12 = load i32, i32* %4
%13 = call double** @paw_alloc_2d_array(i32 %11, i32 %12)
store double** %13, double*** %6
%14 = load i32, i32* %4
%15 = load i32, i32* %4
%16 = call double** @paw_alloc_2d_array(i32 %14, i32 %15)
store double** %16, double*** %7
%17 = load double**, double*** %5
%18 = getelementptr inbounds double*, double** %17, i64 0
%19 = load double*, double** %18
%20 = getelementptr inbounds double, double* %19, i64 0
store double 1.000000e+00, double* %20
%21 = load double**, double*** %5
%22 = getelementptr inbounds double*, double** %21, i64 0
%23 = load double*, double** %22
%24 = getelementptr inbounds double, double* %23, i64 1
store double 2.000000e+00, double* %24
%25 = load double**, double*** %5
%26 = getelementptr inbounds double*, double** %25, i64 1
%27 = load double*, double** %26
%28 = getelementptr inbounds double, double* %27, i64 0
store double 2.000000e+00, double* %28
%29 = load double**, double*** %5
%30 = getelementptr inbounds double*, double** %29, i64 1
%31 = load double*, double** %30
%32 = getelementptr inbounds double, double* %31, i64 1
store double 3.000000e+00, double* %32
store i32 0, i32* %1
br label %33
33: ; preds = %72, %0
%34 = load i32, i32* %1
%35 = load i32, i32* %4
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %75
37: ; preds = %33
store i32 0, i32* %2
br label %38
38: ; preds = %68, %37
%39 = load i32, i32* %2
%40 = load i32, i32* %4
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %71
42: ; preds = %38
%43 = load double**, double*** %5
%44 = load i32, i32* %1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double*, double** %43, i64 %45
%47 = load double*, double** %46
%48 = load i32, i32* %2
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
%51 = load double, double* %50
%52 = load double**, double*** %6
%53 = load i32, i32* %1
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double*, double** %52, i64 %54
%56 = load double*, double** %55
%57 = load i32, i32* %2
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %56, i64 %58
store double %51, double* %59
%60 = load double**, double*** %7
%61 = load i32, i32* %1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double*, double** %60, i64 %62
%64 = load double*, double** %63
%65 = load i32, i32* %2
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %64, i64 %66
store double 0.000000e+00, double* %67
br label %68
68: ; preds = %42
%69 = load i32, i32* %2
%70 = add nsw i32 %69, 1
store i32 %70, i32* %2
br label %38
71: ; preds = %38
br label %72
72: ; preds = %71
%73 = load i32, i32* %1
%74 = add nsw i32 %73, 1
store i32 %74, i32* %1
br label %33
75: ; preds = %33
%76 = load double**, double*** %6
%77 = call i32 @paw_get_inverse(double** %76, i32 2)
store i32 0, i32* %1
br label %78
78: ; preds = %137, %75
%79 = load i32, i32* %1
%80 = load i32, i32* %4
%81 = icmp slt i32 %79, %80
br i1 %81, label %82, label %140
82: ; preds = %78
store i32 0, i32* %2
br label %83
83: ; preds = %133, %82
%84 = load i32, i32* %2
%85 = load i32, i32* %4
%86 = icmp slt i32 %84, %85
br i1 %86, label %87, label %136
87: ; preds = %83
store i32 0, i32* %3
br label %88
88: ; preds = %129, %87
%89 = load i32, i32* %3
%90 = load i32, i32* %4
%91 = icmp slt i32 %89, %90
br i1 %91, label %92, label %132
92: ; preds = %88
%93 = load double**, double*** %7
%94 = load i32, i32* %1
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds double*, double** %93, i64 %95
%97 = load double*, double** %96
%98 = load i32, i32* %2
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds double, double* %97, i64 %99
%101 = load double, double* %100
%102 = load double**, double*** %5
%103 = load i32, i32* %1
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds double*, double** %102, i64 %104
%106 = load double*, double** %105
%107 = load i32, i32* %3
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds double, double* %106, i64 %108
%110 = load double, double* %109
%111 = load double**, double*** %6
%112 = load i32, i32* %3
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds double*, double** %111, i64 %113
%115 = load double*, double** %114
%116 = load i32, i32* %2
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds double, double* %115, i64 %117
%119 = load double, double* %118
%120 = call double @llvm.fmuladd.f64(double %110, double %119, double %101)
%121 = load double**, double*** %7
%122 = load i32, i32* %1
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds double*, double** %121, i64 %123
%125 = load double*, double** %124
%126 = load i32, i32* %2
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds double, double* %125, i64 %127
store double %120, double* %128
br label %129
129: ; preds = %92
%130 = load i32, i32* %3
%131 = add nsw i32 %130, 1
store i32 %131, i32* %3
br label %88
132: ; preds = %88
br label %133
133: ; preds = %132
%134 = load i32, i32* %2
%135 = add nsw i32 %134, 1
store i32 %135, i32* %2
br label %83
136: ; preds = %83
br label %137
137: ; preds = %136
%138 = load i32, i32* %1
%139 = add nsw i32 %138, 1
store i32 %139, i32* %1
br label %78
140: ; preds = %78
store i32 0, i32* %2
br label %141
141: ; preds = %161, %140
%142 = load i32, i32* %2
%143 = load i32, i32* %4
%144 = icmp slt i32 %142, %143
br i1 %144, label %145, label %164
145: ; preds = %141
%146 = load double**, double*** %7
%147 = getelementptr inbounds double*, double** %146, i64 0
%148 = load double*, double** %147
%149 = load i32, i32* %2
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds double, double* %148, i64 %150
%152 = load double, double* %151
%153 = load double**, double*** %7
%154 = getelementptr inbounds double*, double** %153, i64 1
%155 = load double*, double** %154
%156 = load i32, i32* %2
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds double, double* %155, i64 %157
%159 = load double, double* %158
%160 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %152, double %159)
br label %161
161: ; preds = %145
%162 = load i32, i32* %2
%163 = add nsw i32 %162, 1
store i32 %163, i32* %2
br label %141
164: ; preds = %141
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%f\09%f\0A\00"
define void @paw_test_matrix_inverse() {
%1 = tail call double** @paw_alloc_2d_array(i32 2, i32 2)
%2 = tail call double** @paw_alloc_2d_array(i32 2, i32 2)
%3 = tail call double** @paw_alloc_2d_array(i32 2, i32 2)
%4 = load double*, double** %1
%5 = getelementptr inbounds double, double* %4, i64 1
%6 = bitcast double* %4 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 2.000000e+00>, <2 x double>* %6
%7 = getelementptr inbounds double*, double** %1, i64 1
%8 = load double*, double** %7
%9 = getelementptr inbounds double, double* %8, i64 1
%10 = bitcast double* %8 to <2 x double>*
store <2 x double> <double 2.000000e+00, double 3.000000e+00>, <2 x double>* %10
%11 = load double*, double** %2
%12 = load double*, double** %3
%13 = load double, double* %4
store double %13, double* %11
store double 0.000000e+00, double* %12
%14 = load double, double* %5
%15 = getelementptr inbounds double, double* %11, i64 1
store double %14, double* %15
%16 = getelementptr inbounds double, double* %12, i64 1
store double 0.000000e+00, double* %16
%17 = getelementptr inbounds double*, double** %2, i64 1
%18 = load double*, double** %17
%19 = getelementptr inbounds double*, double** %3, i64 1
%20 = load double*, double** %19
%21 = load double, double* %8
store double %21, double* %18
store double 0.000000e+00, double* %20
%22 = load double, double* %9
%23 = getelementptr inbounds double, double* %18, i64 1
store double %22, double* %23
%24 = getelementptr inbounds double, double* %20, i64 1
store double 0.000000e+00, double* %24
%25 = tail call i32 @paw_get_inverse(double** %2, i32 2)
%26 = load double*, double** %3
%27 = load double*, double** %1
%28 = load double, double* %26
%29 = load double, double* %27
%30 = load double*, double** %2
%31 = load double, double* %30
%32 = tail call double @llvm.fmuladd.f64(double %29, double %31, double %28)
store double %32, double* %26
%33 = getelementptr inbounds double, double* %27, i64 1
%34 = load double, double* %33
%35 = load double*, double** %17
%36 = load double, double* %35
%37 = tail call double @llvm.fmuladd.f64(double %34, double %36, double %32)
store double %37, double* %26
%38 = getelementptr inbounds double, double* %26, i64 1
%39 = load double, double* %38
%40 = load double, double* %27
%41 = getelementptr inbounds double, double* %30, i64 1
%42 = load double, double* %41
%43 = tail call double @llvm.fmuladd.f64(double %40, double %42, double %39)
store double %43, double* %38
%44 = load double, double* %33
%45 = getelementptr inbounds double, double* %35, i64 1
%46 = load double, double* %45
%47 = tail call double @llvm.fmuladd.f64(double %44, double %46, double %43)
store double %47, double* %38
%48 = load double*, double** %19
%49 = load double*, double** %7
%50 = load double, double* %48
%51 = load double, double* %49
%52 = load double, double* %30
%53 = tail call double @llvm.fmuladd.f64(double %51, double %52, double %50)
store double %53, double* %48
%54 = getelementptr inbounds double, double* %49, i64 1
%55 = load double, double* %54
%56 = load double, double* %35
%57 = tail call double @llvm.fmuladd.f64(double %55, double %56, double %53)
store double %57, double* %48
%58 = getelementptr inbounds double, double* %48, i64 1
%59 = load double, double* %58
%60 = load double, double* %49
%61 = load double, double* %41
%62 = tail call double @llvm.fmuladd.f64(double %60, double %61, double %59)
store double %62, double* %58
%63 = load double, double* %54
%64 = load double, double* %45
%65 = tail call double @llvm.fmuladd.f64(double %63, double %64, double %62)
store double %65, double* %58
%66 = load double, double* %26
%67 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %66, double %57)
%68 = load double*, double** %3
%69 = getelementptr inbounds double, double* %68, i64 1
%70 = load double, double* %69
%71 = load double*, double** %19
%72 = getelementptr inbounds double, double* %71, i64 1
%73 = load double, double* %72
%74 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %70, double %73)
ret void
}