void cal_inv(double **cov, double **inv, const int L) {
  int i, j, k;
  double **S, **S_inv;
  S = (double **)malloc(sizeof(double *) * L);
  S_inv = (double **)malloc(sizeof(double *) * L);
  for (i = 0; i < L; i++) {
    S[i] = dgetmem(L);
    S_inv[i] = dgetmem(L);
  }
  for (i = 0; i < L; i++) {
    for (j = 0; j < L; j++) {
      S[i][j] = 0.0;
      S_inv[i][j] = 0.0;
      inv[i][j] = 0.0;
    }
  }
  if (choleski(cov, S, L) == 0)
    return;
  cal_tri_inv(S, S_inv, L);
  for (i = 0; i < L; i++)
    for (j = 0; j < L; j++) {
      if (i > j)
        for (k = i; k < L; k++)
          inv[i][j] = inv[i][j] + S_inv[k][i] * S_inv[k][j];
      else
        for (k = j; k < L; k++)
          inv[i][j] = inv[i][j] + S_inv[k][i] * S_inv[k][j];
    }
  for (i = 0; i < L; i++) {
    free(S[i]);
    free(S_inv[i]);
  }
  free(S);
  free(S_inv);
}


x86 assembly (clang, -O0):
<cal_inv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movslq -0x14(%rbp),%rdi
shl    $0x3,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
movslq -0x14(%rbp),%rdi
shl    $0x3,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d8 <cal_inv+0x88>
mov    -0x14(%rbp),%edi
mov    $0x0,%al
call   1070 <dgetmem@plt>
movslq %eax,%rdx
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%edi
mov    $0x0,%al
call   1070 <dgetmem@plt>
movslq %eax,%rdx
mov    -0x30(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118c <cal_inv+0x3c>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1267 <cal_inv+0x117>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1254 <cal_inv+0x104>
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f2 <cal_inv+0xa2>
jmp    1259 <cal_inv+0x109>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11df <cal_inv+0x8f>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    $0x0,%al
call   1040 <choleski@plt>
cmp    $0x0,%eax
jne    1287 <cal_inv+0x137>
jmp    1448 <cal_inv+0x2f8>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    $0x0,%al
call   1060 <cal_tri_inv@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    13f3 <cal_inv+0x2a3>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    13e0 <cal_inv+0x290>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    134c <cal_inv+0x1fc>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1347 <cal_inv+0x1f7>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x30(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12d1 <cal_inv+0x181>
jmp    13cd <cal_inv+0x27d>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    13c8 <cal_inv+0x278>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x30(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1352 <cal_inv+0x202>
jmp    13cd <cal_inv+0x27d>
jmp    13d2 <cal_inv+0x282>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12b3 <cal_inv+0x163>
jmp    13e5 <cal_inv+0x295>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12a0 <cal_inv+0x150>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1436 <cal_inv+0x2e6>
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    13fa <cal_inv+0x2aa>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cal_inv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %edx,%r12d
mov    %rsi,0x10(%rsp)
mov    %rdi,0x18(%rsp)
movslq %edx,%rbp
lea    0x0(,%rbp,8),%rbx
mov    %rbx,%rdi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1050 <malloc@plt>
mov    %rax,%r13
mov    %r12d,%r15d
test   %ebp,%ebp
jle    1413 <cal_inv+0x2c3>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r12d,%edi
xor    %eax,%eax
call   1070 <dgetmem@plt>
cltq
mov    %rax,(%r14,%rbx,8)
mov    %r12d,%edi
xor    %eax,%eax
call   1070 <dgetmem@plt>
cltq
mov    %rax,0x0(%r13,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11a0 <cal_inv+0x50>
test   %r12d,%r12d
mov    0x10(%rsp),%rdi
jle    1413 <cal_inv+0x2c3>
mov    %r15d,%eax
and    $0xfffffffc,%eax
add    $0xfffffffffffffffc,%rax
mov    %rax,0x38(%rsp)
mov    %rax,%rcx
shr    $0x2,%rcx
add    $0x1,%rcx
mov    %r15d,%eax
and    $0xfffffffc,%eax
mov    %rax,0x28(%rsp)
mov    %rcx,%rax
mov    %rcx,0x30(%rsp)
and    $0xfffffffffffffffe,%rcx
mov    %rcx,0x20(%rsp)
mov    %r15,%rax
neg    %rax
mov    %rax,0x40(%rsp)
xor    %esi,%esi
xorpd  %xmm0,%xmm0
mov    %r12d,0xc(%rsp)
jmp    123d <cal_inv+0xed>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rsi
cmp    %r15,%rsi
je     1413 <cal_inv+0x2c3>
mov    (%r14,%rsi,8),%rax
mov    0x0(%r13,%rsi,8),%rcx
mov    (%rdi,%rsi,8),%rdx
cmp    $0x4,%r12d
jae    1260 <cal_inv+0x110>
xor    %r11d,%r11d
jmp    1380 <cal_inv+0x230>
nopl   0x0(%rax,%rax,1)
mov    %r13,%r12
mov    %r14,%r13
lea    (%rax,%r15,8),%rbp
lea    (%rcx,%r15,8),%rdi
lea    (%rdx,%r15,8),%rbx
cmp    %rdi,%rax
setb   %r10b
cmp    %rbp,%rcx
setb   %r14b
cmp    %rbx,%rax
setb   %r8b
cmp    %rbp,%rdx
setb   %r11b
cmp    %rbx,%rcx
setb   %bpl
cmp    %rdi,%rdx
setb   %r9b
test   %r14b,%r10b
jne    136a <cal_inv+0x21a>
and    %r11b,%r8b
jne    136a <cal_inv+0x21a>
mov    $0x0,%r11d
and    %r9b,%bpl
mov    %r13,%r14
mov    %r12,%r13
mov    0xc(%rsp),%r12d
mov    0x10(%rsp),%rdi
jne    1380 <cal_inv+0x230>
cmpq   $0x0,0x38(%rsp)
je     1401 <cal_inv+0x2b1>
mov    0x20(%rsp),%rbp
xor    %ebx,%ebx
movupd %xmm0,(%rax,%rbx,8)
movupd %xmm0,0x10(%rax,%rbx,8)
movupd %xmm0,(%rcx,%rbx,8)
movupd %xmm0,0x10(%rcx,%rbx,8)
movupd %xmm0,(%rdx,%rbx,8)
movupd %xmm0,0x10(%rdx,%rbx,8)
movupd %xmm0,0x20(%rax,%rbx,8)
movupd %xmm0,0x30(%rax,%rbx,8)
movupd %xmm0,0x20(%rcx,%rbx,8)
movupd %xmm0,0x30(%rcx,%rbx,8)
movupd %xmm0,0x20(%rdx,%rbx,8)
movupd %xmm0,0x30(%rdx,%rbx,8)
add    $0x8,%rbx
add    $0xfffffffffffffffe,%rbp
jne    12e0 <cal_inv+0x190>
testb  $0x1,0x30(%rsp)
je     1357 <cal_inv+0x207>
movupd %xmm0,(%rax,%rbx,8)
movupd %xmm0,0x10(%rax,%rbx,8)
movupd %xmm0,(%rcx,%rbx,8)
movupd %xmm0,0x10(%rcx,%rbx,8)
movupd %xmm0,(%rdx,%rbx,8)
movupd %xmm0,0x10(%rdx,%rbx,8)
mov    0x28(%rsp),%rbp
mov    %rbp,%r11
cmp    %r15,%rbp
je     1230 <cal_inv+0xe0>
jmp    1380 <cal_inv+0x230>
xor    %r11d,%r11d
mov    %r13,%r14
mov    %r12,%r13
mov    0xc(%rsp),%r12d
mov    0x10(%rsp),%rdi
nopl   (%rax)
mov    %r11,%rbx
test   $0x1,%r15b
je     13a8 <cal_inv+0x258>
movq   $0x0,(%rax,%r11,8)
movq   $0x0,(%rcx,%r11,8)
movq   $0x0,(%rdx,%r11,8)
mov    %r11,%rbx
or     $0x1,%rbx
not    %r11
cmp    0x40(%rsp),%r11
je     1230 <cal_inv+0xe0>
cs nopw 0x0(%rax,%rax,1)
movq   $0x0,(%rax,%rbx,8)
movq   $0x0,(%rcx,%rbx,8)
movq   $0x0,(%rdx,%rbx,8)
movq   $0x0,0x8(%rax,%rbx,8)
movq   $0x0,0x8(%rcx,%rbx,8)
movq   $0x0,0x8(%rdx,%rbx,8)
add    $0x2,%rbx
cmp    %rbx,%r15
jne    13c0 <cal_inv+0x270>
jmp    1230 <cal_inv+0xe0>
xor    %ebx,%ebx
testb  $0x1,0x30(%rsp)
jne    1336 <cal_inv+0x1e6>
jmp    1357 <cal_inv+0x207>
mov    0x18(%rsp),%rdi
mov    %r14,%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1040 <choleski@plt>
test   %eax,%eax
je     1503 <cal_inv+0x3b3>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1060 <cal_tri_inv@plt>
test   %r12d,%r12d
jle    153c <cal_inv+0x3ec>
xor    %eax,%eax
mov    %r15,%r8
mov    %r13,%r9
mov    0x10(%rsp),%r10
jmp    1475 <cal_inv+0x325>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rax
add    $0x8,%r9
add    $0xffffffffffffffff,%r8
cmp    %r15,%rax
je     1512 <cal_inv+0x3c2>
mov    (%r10,%rax,8),%rsi
mov    %r15,%rdi
mov    %r13,%rbp
xor    %ebx,%ebx
jmp    14a1 <cal_inv+0x351>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
add    $0x8,%rbp
add    $0xffffffffffffffff,%rdi
cmp    %r15,%rbx
je     1460 <cal_inv+0x310>
movsd  (%rsi,%rbx,8),%xmm0
xor    %ecx,%ecx
cmp    %rbx,%rax
jbe    14e0 <cal_inv+0x390>
nopl   (%rax)
mov    (%r9,%rcx,8),%rdx
movsd  (%rdx,%rax,8),%xmm1
mulsd  (%rdx,%rbx,8),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsi,%rbx,8)
add    $0x1,%rcx
cmp    %rcx,%r8
jne    14b0 <cal_inv+0x360>
jmp    1490 <cal_inv+0x340>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x0(%rbp,%rcx,8),%rdx
movsd  (%rdx,%rax,8),%xmm1
mulsd  (%rdx,%rbx,8),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsi,%rbx,8)
add    $0x1,%rcx
cmp    %rcx,%rdi
jne    14e0 <cal_inv+0x390>
jmp    1490 <cal_inv+0x340>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
test   %r12d,%r12d
jle    153c <cal_inv+0x3ec>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r14,%rbx,8),%rdi
call   1030 <free@plt>
mov    0x0(%r13,%rbx,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1520 <cal_inv+0x3d0>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

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

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