#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 */
int /*<<< orphan*/ dlubksb(double **, long, long *, double *);
int /*<<< orphan*/ dludcmp(double **, long, long *, double *);
double *dvector(int, long);
int /*<<< orphan*/ free_dvector(double *, int, long);
int /*<<< orphan*/ free_lvector(long *, int, long);
long *lvector(int, long);
void dinverse(double **a, long n, double **y) {
  double d, *col;
  long i, j, *indx;
  col = dvector(1, n);
  indx = lvector(1, n);
  dludcmp(a, n, indx, &d);
  for (j = 1; j <= n; j++) {
    for (i = 1; i <= n; i++)
      col[i] = 0.0;
    col[j] = 1.0;
    dlubksb(a, n, indx, col);
    for (i = 1; i <= n; i++)
      y[i][j] = col[i];
  }
  free_lvector(indx, 1, n);
  free_dvector(col, 1, n);
}


x86 assembly (clang, -O0):
<dinverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
mov    $0x1,%edi
call   1050 <dvector@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rsi
mov    $0x1,%edi
call   1080 <lvector@plt>
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x40(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1040 <dludcmp@plt>
movq   $0x1,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x10(%rbp),%rax
jg     1283 <dinverse+0x123>
movq   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x10(%rbp),%rax
jg     11fa <dinverse+0x9a>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11cb <dinverse+0x6b>
mov    -0x28(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsd  0xdf6(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1060 <dlubksb@plt>
movq   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x10(%rbp),%rax
jg     126d <dinverse+0x10d>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    122c <dinverse+0xcc>
jmp    1272 <dinverse+0x112>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11b5 <dinverse+0x55>
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1,%esi
call   1030 <free_lvector@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1,%esi
call   1070 <free_dvector@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dinverse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%rbp
mov    $0x1,%edi
call   1060 <dvector@plt>
mov    %rax,%rbx
mov    $0x1,%edi
mov    %r13,%rsi
call   1090 <lvector@plt>
lea    0x30(%rsp),%rcx
mov    %rbp,0x28(%rsp)
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %rax,0x8(%rsp)
mov    %rax,%rdx
call   1050 <dludcmp@plt>
test   %r13,%r13
jle    12ed <dinverse+0x17d>
lea    0x8(%rbx),%rax
mov    %rax,0x20(%rsp)
lea    0x0(,%r13,8),%rax
mov    %rax,0x18(%rsp)
lea    -0x1(%r13),%rax
mov    %rax,0x10(%rsp)
mov    %r13d,%r14d
and    $0x3,%r14d
mov    %r13,%rbp
and    $0xfffffffffffffffc,%rbp
mov    $0x1,%r12d
jmp    1211 <dinverse+0xa1>
nopl   0x0(%rax)
lea    0x1(%r12),%rax
cmp    %r13,%r12
mov    %rax,%r12
je     12ed <dinverse+0x17d>
mov    0x20(%rsp),%rdi
xor    %esi,%esi
mov    0x18(%rsp),%rdx
call   1040 <memset@plt>
movabs $0x3ff0000000000000,%rax
mov    %rax,(%rbx,%r12,8)
mov    0x28(%rsp),%rdi
mov    %r13,%rsi
mov    0x8(%rsp),%rdx
mov    %rbx,%rcx
call   1070 <dlubksb@plt>
mov    $0x1,%eax
cmpq   $0x3,0x10(%rsp)
jb     12b1 <dinverse+0x141>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  0x8(%rbx,%rax,8),%xmm0
mov    0x8(%r15,%rax,8),%rcx
movsd  %xmm0,(%rcx,%r12,8)
movsd  0x10(%rbx,%rax,8),%xmm0
mov    0x10(%r15,%rax,8),%rcx
movsd  %xmm0,(%rcx,%r12,8)
movsd  0x18(%rbx,%rax,8),%xmm0
mov    0x18(%r15,%rax,8),%rcx
movsd  %xmm0,(%rcx,%r12,8)
movsd  0x20(%rbx,%rax,8),%xmm0
mov    0x20(%r15,%rax,8),%rcx
movsd  %xmm0,(%rcx,%r12,8)
add    $0x4,%rax
cmp    %rax,%rbp
jne    1260 <dinverse+0xf0>
add    $0x1,%rax
test   %r14,%r14
je     1200 <dinverse+0x90>
lea    (%r15,%rax,8),%rcx
lea    (%rbx,%rax,8),%rax
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%rax,%rdx,8),%xmm0
mov    (%rcx,%rdx,8),%rsi
movsd  %xmm0,(%rsi,%r12,8)
add    $0x1,%rdx
cmp    %rdx,%r14
jne    12d0 <dinverse+0x160>
jmp    1200 <dinverse+0x90>
mov    0x8(%rsp),%rdi
mov    $0x1,%esi
mov    %r13,%rdx
call   1030 <free_lvector@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r13,%rdx
call   1080 <free_dvector@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @dinverse(double** %0, i64 %1, double** %2) {
%4 = alloca double**
%5 = alloca i64
%6 = alloca double**
%7 = alloca double
%8 = alloca double*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64*
store double** %0, double*** %4
store i64 %1, i64* %5
store double** %2, double*** %6
%12 = load i64, i64* %5
%13 = call double* @dvector(i32 1, i64 %12)
store double* %13, double** %8
%14 = load i64, i64* %5
%15 = call i64* @lvector(i32 1, i64 %14)
store i64* %15, i64** %11
%16 = load double**, double*** %4
%17 = load i64, i64* %5
%18 = load i64*, i64** %11
%19 = call i32 @dludcmp(double** %16, i64 %17, i64* %18, double* %7)
store i64 1, i64* %10
br label %20
20: ; preds = %64, %3
%21 = load i64, i64* %10
%22 = load i64, i64* %5
%23 = icmp sle i64 %21, %22
br i1 %23, label %24, label %67
24: ; preds = %20
store i64 1, i64* %9
br label %25
25: ; preds = %33, %24
%26 = load i64, i64* %9
%27 = load i64, i64* %5
%28 = icmp sle i64 %26, %27
br i1 %28, label %29, label %36
29: ; preds = %25
%30 = load double*, double** %8
%31 = load i64, i64* %9
%32 = getelementptr inbounds double, double* %30, i64 %31
store double 0.000000e+00, double* %32
br label %33
33: ; preds = %29
%34 = load i64, i64* %9
%35 = add nsw i64 %34, 1
store i64 %35, i64* %9
br label %25
36: ; preds = %25
%37 = load double*, double** %8
%38 = load i64, i64* %10
%39 = getelementptr inbounds double, double* %37, i64 %38
store double 1.000000e+00, double* %39
%40 = load double**, double*** %4
%41 = load i64, i64* %5
%42 = load i64*, i64** %11
%43 = load double*, double** %8
%44 = call i32 @dlubksb(double** %40, i64 %41, i64* %42, double* %43)
store i64 1, i64* %9
br label %45
45: ; preds = %60, %36
%46 = load i64, i64* %9
%47 = load i64, i64* %5
%48 = icmp sle i64 %46, %47
br i1 %48, label %49, label %63
49: ; preds = %45
%50 = load double*, double** %8
%51 = load i64, i64* %9
%52 = getelementptr inbounds double, double* %50, i64 %51
%53 = load double, double* %52
%54 = load double**, double*** %6
%55 = load i64, i64* %9
%56 = getelementptr inbounds double*, double** %54, i64 %55
%57 = load double*, double** %56
%58 = load i64, i64* %10
%59 = getelementptr inbounds double, double* %57, i64 %58
store double %53, double* %59
br label %60
60: ; preds = %49
%61 = load i64, i64* %9
%62 = add nsw i64 %61, 1
store i64 %62, i64* %9
br label %45
63: ; preds = %45
br label %64
64: ; preds = %63
%65 = load i64, i64* %10
%66 = add nsw i64 %65, 1
store i64 %66, i64* %10
br label %20
67: ; preds = %20
%68 = load i64*, i64** %11
%69 = load i64, i64* %5
%70 = call i32 @free_lvector(i64* %68, i32 1, i64 %69)
%71 = load double*, double** %8
%72 = load i64, i64* %5
%73 = call i32 @free_dvector(double* %71, i32 1, i64 %72)
ret void
}

LLVM IR (-O2):
define void @dinverse(double** %0, i64 %1, double** nocapture %2) {
%4 = alloca double
%5 = bitcast double* %4 to i8*
%6 = tail call double* @dvector(i32 1, i64 %1)
%7 = tail call i64* @lvector(i32 1, i64 %1)
%8 = call i32 @dludcmp(double** %0, i64 %1, i64* %7, double* %4)
%9 = icmp slt i64 %1, 1
br i1 %9, label %68, label %10
10: ; preds = %3
%11 = getelementptr double, double* %6, i64 1
%12 = bitcast double* %11 to i8*
%13 = shl nuw i64 %1, 3
%14 = add i64 %1, -1
%15 = and i64 %1, 3
%16 = icmp ult i64 %14, 3
%17 = and i64 %1, -4
%18 = icmp eq i64 %15, 0
br label %19
19: ; preds = %65, %10
%20 = phi i64 [ 1, %10 ], [ %66, %65 ]
%21 = getelementptr inbounds double, double* %6, i64 %20
store double 1.000000e+00, double* %21
%22 = call i32 @dlubksb(double** %0, i64 %1, i64* %7, double* %6)
br i1 %16, label %52, label %23
23: ; preds = %19, %23
%24 = phi i64 [ %49, %23 ], [ 1, %19 ]
%25 = phi i64 [ %50, %23 ], [ 0, %19 ]
%26 = getelementptr inbounds double, double* %6, i64 %24
%27 = load double, double* %26
%28 = getelementptr inbounds double*, double** %2, i64 %24
%29 = load double*, double** %28
%30 = getelementptr inbounds double, double* %29, i64 %20
store double %27, double* %30
%31 = add nuw nsw i64 %24, 1
%32 = getelementptr inbounds double, double* %6, i64 %31
%33 = load double, double* %32
%34 = getelementptr inbounds double*, double** %2, i64 %31
%35 = load double*, double** %34
%36 = getelementptr inbounds double, double* %35, i64 %20
store double %33, double* %36
%37 = add nuw nsw i64 %24, 2
%38 = getelementptr inbounds double, double* %6, i64 %37
%39 = load double, double* %38
%40 = getelementptr inbounds double*, double** %2, i64 %37
%41 = load double*, double** %40
%42 = getelementptr inbounds double, double* %41, i64 %20
store double %39, double* %42
%43 = add nuw i64 %24, 3
%44 = getelementptr inbounds double, double* %6, i64 %43
%45 = load double, double* %44
%46 = getelementptr inbounds double*, double** %2, i64 %43
%47 = load double*, double** %46
%48 = getelementptr inbounds double, double* %47, i64 %20
store double %45, double* %48
%49 = add nuw i64 %24, 4
%50 = add i64 %25, 4
%51 = icmp eq i64 %50, %17
br i1 %51, label %52, label %23
52: ; preds = %23, %19
%53 = phi i64 [ 1, %19 ], [ %49, %23 ]
br i1 %18, label %65, label %54
54: ; preds = %52, %54
%55 = phi i64 [ %62, %54 ], [ %53, %52 ]
%56 = phi i64 [ %63, %54 ], [ 0, %52 ]
%57 = getelementptr inbounds double, double* %6, i64 %55
%58 = load double, double* %57
%59 = getelementptr inbounds double*, double** %2, i64 %55
%60 = load double*, double** %59
%61 = getelementptr inbounds double, double* %60, i64 %20
store double %58, double* %61
%62 = add nuw i64 %55, 1
%63 = add i64 %56, 1
%64 = icmp eq i64 %63, %15
br i1 %64, label %65, label %54
65: ; preds = %54, %52
%66 = add nuw i64 %20, 1
%67 = icmp eq i64 %20, %1
br i1 %67, label %68, label %19
68: ; preds = %65, %3
%69 = call i32 @free_lvector(i64* %7, i32 1, i64 %1)
%70 = call i32 @free_dvector(double* %6, i32 1, i64 %1)
ret void
}