double **invert_matrix(double **mat, unsigned int size) {
  int i, j, k;
  double **hmat, **imat, *vec;
  extern void solvele(double **, double *, unsigned int);
  check_alloc(hmat = (double **)malloc(sizeof(double *) * size));
  for (i = 0; i < size; i++) {
    check_alloc(hmat[i] = (double *)malloc(sizeof(double) * size));
  }
  check_alloc(imat = (double **)malloc(sizeof(double *) * size));
  for (i = 0; i < size; i++) {
    check_alloc(imat[i] = (double *)malloc(sizeof(double) * size));
  }
  check_alloc(vec = (double *)malloc(sizeof(double) * size));
  for (i = 0; i < size; i++) {
    for (j = 0; j < size; j++) {
      vec[j] = (i == j) ? 1.0 : 0.0;
      for (k = 0; k < size; k++)
        hmat[j][k] = mat[j][k];
    }
    solvele(hmat, vec, size);
    for (j = 0; j < size; j++)
      imat[j][i] = vec[j];
  }
  free(vec);
  for (i = 0; i < size; i++)
    free(hmat[i]);
  free(hmat);
  return imat;
}


x86 assembly (clang, -O0):
<invert_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%edi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,%rdi
mov    %rdi,-0x20(%rbp)
mov    $0x0,%al
call   1060 <check_alloc@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11b0 <invert_matrix+0x70>
mov    -0xc(%rbp),%eax
mov    %eax,%edi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,%rdi
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %rdi,(%rax,%rcx,8)
mov    $0x0,%al
call   1060 <check_alloc@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1172 <invert_matrix+0x32>
mov    -0xc(%rbp),%eax
mov    %eax,%edi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,%rdi
mov    %rdi,-0x28(%rbp)
mov    $0x0,%al
call   1060 <check_alloc@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1211 <invert_matrix+0xd1>
mov    -0xc(%rbp),%eax
mov    %eax,%edi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,%rdi
mov    -0x28(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %rdi,(%rax,%rcx,8)
mov    $0x0,%al
call   1060 <check_alloc@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11d3 <invert_matrix+0x93>
mov    -0xc(%rbp),%eax
mov    %eax,%edi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,%rdi
mov    %rdi,-0x30(%rbp)
mov    $0x0,%al
call   1060 <check_alloc@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1356 <invert_matrix+0x216>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    12f0 <invert_matrix+0x1b0>
mov    -0x10(%rbp),%eax
mov    -0x14(%rbp),%ecx
movsd  0xd9f(%rip),%xmm0
xorps  %xmm1,%xmm1
movsd  %xmm1,-0x40(%rbp)
cmp    %ecx,%eax
movsd  %xmm0,-0x38(%rbp)
je     1280 <invert_matrix+0x140>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    12dd <invert_matrix+0x19d>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1299 <invert_matrix+0x159>
jmp    12e2 <invert_matrix+0x1a2>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1247 <invert_matrix+0x107>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1050 <solvele@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1343 <invert_matrix+0x203>
mov    -0x30(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1307 <invert_matrix+0x1c7>
jmp    1348 <invert_matrix+0x208>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1234 <invert_matrix+0xf4>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1391 <invert_matrix+0x251>
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1366 <invert_matrix+0x226>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<invert_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %esi,%ebp
mov    %rdi,0x28(%rsp)
mov    %esi,%r12d
lea    0x0(,%r12,8),%r14
mov    %r14,%rdi
call   1040 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
xor    %eax,%eax
call   1060 <check_alloc@plt>
mov    %ebp,0xc(%rsp)
test   %ebp,%ebp
je     119f <invert_matrix+0x5f>
xor    %ebp,%ebp
nop
mov    %r14,%rdi
call   1040 <malloc@plt>
mov    %rax,(%r15,%rbp,8)
mov    %rax,%rdi
xor    %eax,%eax
call   1060 <check_alloc@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1180 <invert_matrix+0x40>
mov    %r15,0x18(%rsp)
mov    %r14,%rdi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %eax,%eax
call   1060 <check_alloc@plt>
cmpl   $0x0,0xc(%rsp)
je     11ef <invert_matrix+0xaf>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <malloc@plt>
mov    %rax,(%rbx,%rbp,8)
mov    %rax,%rdi
xor    %eax,%eax
call   1060 <check_alloc@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    11d0 <invert_matrix+0x90>
mov    %r14,%rdi
call   1040 <malloc@plt>
mov    %rax,%r13
mov    %rax,%rdi
xor    %eax,%eax
call   1060 <check_alloc@plt>
mov    0xc(%rsp),%edx
test   %edx,%edx
je     1544 <invert_matrix+0x404>
mov    %rbx,0x10(%rsp)
mov    %r12d,%r10d
and    $0xfffffffc,%r10d
lea    -0x4(%r10),%r11
mov    %r11,%rax
shr    $0x2,%rax
add    $0x1,%rax
lea    -0x1(%r12),%rcx
mov    %rcx,0x30(%rsp)
mov    %eax,%r15d
and    $0x3,%r15d
and    $0xfffffffffffffffc,%rax
mov    %rax,0x38(%rsp)
mov    %r12d,%ebp
and    $0x3,%ebp
mov    %r15,0x40(%rsp)
shl    $0x5,%r15
xor    %r14d,%r14d
movsd  0xda1(%rip),%xmm2
mov    0x18(%rsp),%r8
mov    0x28(%rsp),%r9
mov    %rbp,0x20(%rsp)
jmp    127d <invert_matrix+0x13d>
add    $0x1,%r14
cmp    %r12,%r14
je     150d <invert_matrix+0x3cd>
xor    %eax,%eax
jmp    129d <invert_matrix+0x15d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rax
cmp    %r12,%rax
je     1420 <invert_matrix+0x2e0>
movaps %xmm2,%xmm0
cmp    %rax,%r14
je     12a8 <invert_matrix+0x168>
xorps  %xmm0,%xmm0
movsd  %xmm0,0x0(%r13,%rax,8)
mov    (%r9,%rax,8),%rcx
mov    (%r8,%rax,8),%rbx
cmp    $0x4,%edx
jb     12ce <invert_matrix+0x18e>
lea    (%rcx,%r12,8),%rsi
cmp    %rsi,%rbx
jae    1340 <invert_matrix+0x200>
lea    (%rbx,%r12,8),%rsi
cmp    %rsi,%rcx
jae    1340 <invert_matrix+0x200>
xor    %esi,%esi
mov    0x30(%rsp),%rdi
sub    %rsi,%rdi
test   %rbp,%rbp
je     12f4 <invert_matrix+0x1b4>
nopl   (%rax)
movsd  (%rcx,%rsi,8),%xmm0
movsd  %xmm0,(%rbx,%rsi,8)
add    $0x1,%rsi
add    $0xffffffffffffffff,%rbp
jne    12e0 <invert_matrix+0x1a0>
cmp    $0x3,%rdi
mov    0x20(%rsp),%rbp
jb     1290 <invert_matrix+0x150>
nop
movsd  (%rcx,%rsi,8),%xmm0
movsd  %xmm0,(%rbx,%rsi,8)
movsd  0x8(%rcx,%rsi,8),%xmm0
movsd  %xmm0,0x8(%rbx,%rsi,8)
movsd  0x10(%rcx,%rsi,8),%xmm0
movsd  %xmm0,0x10(%rbx,%rsi,8)
movsd  0x18(%rcx,%rsi,8),%xmm0
movsd  %xmm0,0x18(%rbx,%rsi,8)
add    $0x4,%rsi
cmp    %rsi,%r12
jne    1300 <invert_matrix+0x1c0>
jmp    1290 <invert_matrix+0x150>
nopl   0x0(%rax)
cmp    $0xc,%r11
jae    134a <invert_matrix+0x20a>
xor    %esi,%esi
jmp    13b8 <invert_matrix+0x278>
mov    0x38(%rsp),%rdi
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movups (%rcx,%rsi,8),%xmm0
movups 0x10(%rcx,%rsi,8),%xmm1
movups %xmm0,(%rbx,%rsi,8)
movups %xmm1,0x10(%rbx,%rsi,8)
movups 0x20(%rcx,%rsi,8),%xmm0
movups 0x30(%rcx,%rsi,8),%xmm1
movups %xmm0,0x20(%rbx,%rsi,8)
movups %xmm1,0x30(%rbx,%rsi,8)
movups 0x40(%rcx,%rsi,8),%xmm0
movups 0x50(%rcx,%rsi,8),%xmm1
movups %xmm0,0x40(%rbx,%rsi,8)
movups %xmm1,0x50(%rbx,%rsi,8)
movups 0x60(%rcx,%rsi,8),%xmm0
movups 0x70(%rcx,%rsi,8),%xmm1
movups %xmm0,0x60(%rbx,%rsi,8)
movups %xmm1,0x70(%rbx,%rsi,8)
add    $0x10,%rsi
add    $0xfffffffffffffffc,%rdi
jne    1360 <invert_matrix+0x220>
cmpq   $0x0,0x40(%rsp)
je     13fb <invert_matrix+0x2bb>
lea    (%rbx,%rsi,8),%rdi
add    $0x10,%rdi
lea    (%rcx,%rsi,8),%rsi
add    $0x10,%rsi
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movups -0x10(%rsi,%rbp,1),%xmm0
movups (%rsi,%rbp,1),%xmm1
movups %xmm0,-0x10(%rdi,%rbp,1)
movups %xmm1,(%rdi,%rbp,1)
add    $0x20,%rbp
cmp    %rbp,%r15
jne    13e0 <invert_matrix+0x2a0>
mov    %r10,%rsi
cmp    %r12,%r10
mov    0x20(%rsp),%rbp
je     1290 <invert_matrix+0x150>
jmp    12d0 <invert_matrix+0x190>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r11,%rbp
mov    %r10,%rbx
mov    %r8,%rdi
mov    %r13,%rsi
call   1050 <solvele@plt>
cmpq   $0x3,0x30(%rsp)
jae    1450 <invert_matrix+0x310>
xor    %eax,%eax
mov    0x10(%rsp),%rsi
mov    %rbx,%r10
jmp    14b0 <invert_matrix+0x370>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
mov    0x10(%rsp),%rsi
mov    %rbx,%r10
nopw   0x0(%rax,%rax,1)
movsd  0x0(%r13,%rax,8),%xmm0
mov    (%rsi,%rax,8),%rcx
movsd  %xmm0,(%rcx,%r14,8)
movsd  0x8(%r13,%rax,8),%xmm0
mov    0x8(%rsi,%rax,8),%rcx
movsd  %xmm0,(%rcx,%r14,8)
movsd  0x10(%r13,%rax,8),%xmm0
mov    0x10(%rsi,%rax,8),%rcx
movsd  %xmm0,(%rcx,%r14,8)
movsd  0x18(%r13,%rax,8),%xmm0
mov    0x18(%rsi,%rax,8),%rcx
movsd  %xmm0,(%rcx,%r14,8)
add    $0x4,%rax
cmp    %rax,%r10
jne    1460 <invert_matrix+0x320>
test   $0x3,%r12b
mov    0x18(%rsp),%r8
mov    0xc(%rsp),%edx
mov    0x28(%rsp),%r9
mov    %rbp,%r11
mov    0x20(%rsp),%rbp
movsd  0xb2e(%rip),%xmm2
je     1270 <invert_matrix+0x130>
lea    (%rsi,%rax,8),%rcx
lea    0x0(,%rax,8),%rax
add    %r13,%rax
xor    %edi,%edi
nopl   0x0(%rax)
movsd  (%rax,%rdi,8),%xmm0
mov    (%rcx,%rdi,8),%rsi
movsd  %xmm0,(%rsi,%r14,8)
add    $0x1,%rdi
cmp    %rdi,%rbp
jne    14f0 <invert_matrix+0x3b0>
jmp    1270 <invert_matrix+0x130>
mov    %r13,%rdi
mov    %r8,%r14
mov    %edx,%ebx
call   1030 <free@plt>
test   %ebx,%ebx
mov    0x10(%rsp),%rbx
je     1551 <invert_matrix+0x411>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r14,%rbp,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1530 <invert_matrix+0x3f0>
jmp    1551 <invert_matrix+0x411>
mov    %r13,%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%r14
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define double** @invert_matrix(double** nocapture %0, i32 %1) {
%3 = zext i32 %1 to i64
%4 = shl nuw nsw i64 %3, 3
%5 = tail call i8* @malloc(i64 %4)
%6 = bitcast i8* %5 to double**
%7 = tail call i32 (double**, ...) bitcast (i32 (...)* @check_alloc to i32 (double**, ...)*)(double** %6)
%8 = icmp eq i32 %1, 0
br i1 %8, label %18, label %9
9: ; preds = %2, %9
%10 = phi i64 [ %16, %9 ], [ 0, %2 ]
%11 = tail call i8* @malloc(i64 %4)
%12 = bitcast i8* %11 to double*
%13 = getelementptr inbounds double*, double** %6, i64 %10
%14 = bitcast double** %13 to i8**
store i8* %11, i8** %14
%15 = tail call i32 (double*, ...) bitcast (i32 (...)* @check_alloc to i32 (double*, ...)*)(double* %12)
%16 = add nuw nsw i64 %10, 1
%17 = icmp eq i64 %16, %3
br i1 %17, label %18, label %9
18: ; preds = %9, %2
%19 = tail call i8* @malloc(i64 %4)
%20 = bitcast i8* %19 to double**
%21 = tail call i32 (double**, ...) bitcast (i32 (...)* @check_alloc to i32 (double**, ...)*)(double** %20)
br i1 %8, label %31, label %22
22: ; preds = %18, %22
%23 = phi i64 [ %29, %22 ], [ 0, %18 ]
%24 = tail call i8* @malloc(i64 %4)
%25 = bitcast i8* %24 to double*
%26 = getelementptr inbounds double*, double** %20, i64 %23
%27 = bitcast double** %26 to i8**
store i8* %24, i8** %27
%28 = tail call i32 (double*, ...) bitcast (i32 (...)* @check_alloc to i32 (double*, ...)*)(double* %25)
%29 = add nuw nsw i64 %23, 1
%30 = icmp eq i64 %29, %3
br i1 %30, label %31, label %22
31: ; preds = %22, %18
%32 = tail call i8* @malloc(i64 %4)
%33 = bitcast i8* %32 to double*
%34 = tail call i32 (double*, ...) bitcast (i32 (...)* @check_alloc to i32 (double*, ...)*)(double* %33)
br i1 %8, label %54, label %35
35: ; preds = %31
%36 = and i64 %3, 4294967292
%37 = add nsw i64 %36, -4
%38 = lshr exact i64 %37, 2
%39 = add nuw nsw i64 %38, 1
%40 = add nsw i64 %3, -1
%41 = icmp ult i32 %1, 4
%42 = and i64 %3, 4294967292
%43 = and i64 %39, 3
%44 = icmp ult i64 %37, 12
%45 = and i64 %39, 9223372036854775804
%46 = icmp eq i64 %43, 0
%47 = icmp eq i64 %42, %3
%48 = and i64 %3, 3
%49 = icmp eq i64 %48, 0
%50 = and i64 %3, 3
%51 = icmp ult i64 %40, 3
%52 = and i64 %3, 4294967292
%53 = icmp eq i64 %50, 0
br label %55
54: ; preds = %31
tail call void @free(i8* %32)
br label %232
55: ; preds = %35, %221
%56 = phi i64 [ %222, %221 ], [ 0, %35 ]
br label %57
57: ; preds = %55, %175
%58 = phi i64 [ 0, %55 ], [ %176, %175 ]
%59 = icmp eq i64 %56, %58
%60 = select i1 %59, double 1.000000e+00, double 0.000000e+00
%61 = getelementptr inbounds double, double* %33, i64 %58
store double %60, double* %61
%62 = getelementptr inbounds double*, double** %0, i64 %58
%63 = load double*, double** %62
%64 = getelementptr inbounds double*, double** %6, i64 %58
%65 = load double*, double** %64
br i1 %41, label %141, label %66
66: ; preds = %57
%67 = getelementptr double, double* %65, i64 %3
%68 = getelementptr double, double* %63, i64 %3
%69 = icmp ult double* %65, %68
%70 = icmp ult double* %63, %67
%71 = and i1 %69, %70
br i1 %71, label %141, label %72
72: ; preds = %66
br i1 %44, label %122, label %73
73: ; preds = %72, %73
%74 = phi i64 [ %119, %73 ], [ 0, %72 ]
%75 = phi i64 [ %120, %73 ], [ 0, %72 ]
%76 = getelementptr inbounds double, double* %63, i64 %74
%77 = bitcast double* %76 to <2 x double>*
%78 = load <2 x double>, <2 x double>* %77
%79 = getelementptr inbounds double, double* %76, i64 2
%80 = bitcast double* %79 to <2 x double>*
%81 = load <2 x double>, <2 x double>* %80
%82 = getelementptr inbounds double, double* %65, i64 %74
%83 = bitcast double* %82 to <2 x double>*
store <2 x double> %78, <2 x double>* %83
%84 = getelementptr inbounds double, double* %82, i64 2
%85 = bitcast double* %84 to <2 x double>*
store <2 x double> %81, <2 x double>* %85
%86 = or i64 %74, 4
%87 = getelementptr inbounds double, double* %63, i64 %86
%88 = bitcast double* %87 to <2 x double>*
%89 = load <2 x double>, <2 x double>* %88
%90 = getelementptr inbounds double, double* %87, i64 2
%91 = bitcast double* %90 to <2 x double>*
%92 = load <2 x double>, <2 x double>* %91
%93 = getelementptr inbounds double, double* %65, i64 %86
%94 = bitcast double* %93 to <2 x double>*
store <2 x double> %89, <2 x double>* %94
%95 = getelementptr inbounds double, double* %93, i64 2
%96 = bitcast double* %95 to <2 x double>*
store <2 x double> %92, <2 x double>* %96
%97 = or i64 %74, 8
%98 = getelementptr inbounds double, double* %63, i64 %97
%99 = bitcast double* %98 to <2 x double>*
%100 = load <2 x double>, <2 x double>* %99
%101 = getelementptr inbounds double, double* %98, i64 2
%102 = bitcast double* %101 to <2 x double>*
%103 = load <2 x double>, <2 x double>* %102
%104 = getelementptr inbounds double, double* %65, i64 %97
%105 = bitcast double* %104 to <2 x double>*
store <2 x double> %100, <2 x double>* %105
%106 = getelementptr inbounds double, double* %104, i64 2
%107 = bitcast double* %106 to <2 x double>*
store <2 x double> %103, <2 x double>* %107
%108 = or i64 %74, 12
%109 = getelementptr inbounds double, double* %63, i64 %108
%110 = bitcast double* %109 to <2 x double>*
%111 = load <2 x double>, <2 x double>* %110
%112 = getelementptr inbounds double, double* %109, i64 2
%113 = bitcast double* %112 to <2 x double>*
%114 = load <2 x double>, <2 x double>* %113
%115 = getelementptr inbounds double, double* %65, i64 %108
%116 = bitcast double* %115 to <2 x double>*
store <2 x double> %111, <2 x double>* %116
%117 = getelementptr inbounds double, double* %115, i64 2
%118 = bitcast double* %117 to <2 x double>*
store <2 x double> %114, <2 x double>* %118
%119 = add nuw i64 %74, 16
%120 = add nuw i64 %75, 4
%121 = icmp eq i64 %120, %45
br i1 %121, label %122, label %73
122: ; preds = %73, %72
%123 = phi i64 [ 0, %72 ], [ %119, %73 ]
br i1 %46, label %140, label %124
124: ; preds = %122, %124
%125 = phi i64 [ %137, %124 ], [ %123, %122 ]
%126 = phi i64 [ %138, %124 ], [ 0, %122 ]
%127 = getelementptr inbounds double, double* %63, i64 %125
%128 = bitcast double* %127 to <2 x double>*
%129 = load <2 x double>, <2 x double>* %128
%130 = getelementptr inbounds double, double* %127, i64 2
%131 = bitcast double* %130 to <2 x double>*
%132 = load <2 x double>, <2 x double>* %131
%133 = getelementptr inbounds double, double* %65, i64 %125
%134 = bitcast double* %133 to <2 x double>*
store <2 x double> %129, <2 x double>* %134
%135 = getelementptr inbounds double, double* %133, i64 2
%136 = bitcast double* %135 to <2 x double>*
store <2 x double> %132, <2 x double>* %136
%137 = add nuw i64 %125, 4
%138 = add i64 %126, 1
%139 = icmp eq i64 %138, %43
br i1 %139, label %140, label %124
140: ; preds = %124, %122
br i1 %47, label %175, label %141
141: ; preds = %66, %57, %140
%142 = phi i64 [ 0, %66 ], [ 0, %57 ], [ %42, %140 ]
%143 = sub nsw i64 %40, %142
br i1 %49, label %153, label %144
144: ; preds = %141, %144
%145 = phi i64 [ %150, %144 ], [ %142, %141 ]
%146 = phi i64 [ %151, %144 ], [ 0, %141 ]
%147 = getelementptr inbounds double, double* %63, i64 %145
%148 = load double, double* %147
%149 = getelementptr inbounds double, double* %65, i64 %145
store double %148, double* %149
%150 = add nuw nsw i64 %145, 1
%151 = add i64 %146, 1
%152 = icmp eq i64 %151, %48
br i1 %152, label %153, label %144
153: ; preds = %144, %141
%154 = phi i64 [ %142, %141 ], [ %150, %144 ]
%155 = icmp ult i64 %143, 3
br i1 %155, label %175, label %156
156: ; preds = %153, %156
%157 = phi i64 [ %173, %156 ], [ %154, %153 ]
%158 = getelementptr inbounds double, double* %63, i64 %157
%159 = load double, double* %158
%160 = getelementptr inbounds double, double* %65, i64 %157
store double %159, double* %160
%161 = add nuw nsw i64 %157, 1
%162 = getelementptr inbounds double, double* %63, i64 %161
%163 = load double, double* %162
%164 = getelementptr inbounds double, double* %65, i64 %161
store double %163, double* %164
%165 = add nuw nsw i64 %157, 2
%166 = getelementptr inbounds double, double* %63, i64 %165
%167 = load double, double* %166
%168 = getelementptr inbounds double, double* %65, i64 %165
store double %167, double* %168
%169 = add nuw nsw i64 %157, 3
%170 = getelementptr inbounds double, double* %63, i64 %169
%171 = load double, double* %170
%172 = getelementptr inbounds double, double* %65, i64 %169
store double %171, double* %172
%173 = add nuw nsw i64 %157, 4
%174 = icmp eq i64 %173, %3
br i1 %174, label %175, label %156
175: ; preds = %153, %156, %140
%176 = add nuw nsw i64 %58, 1
%177 = icmp eq i64 %176, %3
br i1 %177, label %178, label %57
178: ; preds = %175
tail call void @solvele(double** %6, double* %33, i32 %1)
br i1 %51, label %208, label %179
179: ; preds = %178, %179
%180 = phi i64 [ %205, %179 ], [ 0, %178 ]
%181 = phi i64 [ %206, %179 ], [ 0, %178 ]
%182 = getelementptr inbounds double, double* %33, i64 %180
%183 = load double, double* %182
%184 = getelementptr inbounds double*, double** %20, i64 %180
%185 = load double*, double** %184
%186 = getelementptr inbounds double, double* %185, i64 %56
store double %183, double* %186
%187 = or i64 %180, 1
%188 = getelementptr inbounds double, double* %33, i64 %187
%189 = load double, double* %188
%190 = getelementptr inbounds double*, double** %20, i64 %187
%191 = load double*, double** %190
%192 = getelementptr inbounds double, double* %191, i64 %56
store double %189, double* %192
%193 = or i64 %180, 2
%194 = getelementptr inbounds double, double* %33, i64 %193
%195 = load double, double* %194
%196 = getelementptr inbounds double*, double** %20, i64 %193
%197 = load double*, double** %196
%198 = getelementptr inbounds double, double* %197, i64 %56
store double %195, double* %198
%199 = or i64 %180, 3
%200 = getelementptr inbounds double, double* %33, i64 %199
%201 = load double, double* %200
%202 = getelementptr inbounds double*, double** %20, i64 %199
%203 = load double*, double** %202
%204 = getelementptr inbounds double, double* %203, i64 %56
store double %201, double* %204
%205 = add nuw nsw i64 %180, 4
%206 = add i64 %181, 4
%207 = icmp eq i64 %206, %52
br i1 %207, label %208, label %179
208: ; preds = %179, %178
%209 = phi i64 [ 0, %178 ], [ %205, %179 ]
br i1 %53, label %221, label %210
210: ; preds = %208, %210
%211 = phi i64 [ %218, %210 ], [ %209, %208 ]
%212 = phi i64 [ %219, %210 ], [ 0, %208 ]
%213 = getelementptr inbounds double, double* %33, i64 %211
%214 = load double, double* %213
%215 = getelementptr inbounds double*, double** %20, i64 %211
%216 = load double*, double** %215
%217 = getelementptr inbounds double, double* %216, i64 %56
store double %214, double* %217
%218 = add nuw nsw i64 %211, 1
%219 = add i64 %212, 1
%220 = icmp eq i64 %219, %50
br i1 %220, label %221, label %210
221: ; preds = %210, %208
%222 = add nuw nsw i64 %56, 1
%223 = icmp eq i64 %222, %3
br i1 %223, label %224, label %55
224: ; preds = %221
tail call void @free(i8* %32)
br i1 %8, label %232, label %225
225: ; preds = %224, %225
%226 = phi i64 [ %230, %225 ], [ 0, %224 ]
%227 = getelementptr inbounds double*, double** %6, i64 %226
%228 = bitcast double** %227 to i8**
%229 = load i8*, i8** %228
tail call void @free(i8* %229)
%230 = add nuw nsw i64 %226, 1
%231 = icmp eq i64 %230, %3
br i1 %231, label %232, label %225
232: ; preds = %225, %54, %224
tail call void @free(i8* %5)
ret double** %20
}