#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 */
typedef size_t j;
typedef scalar_t__ *N;
typedef int /*<<< orphan*/ A;

/* Variables and functions */
int /*<<< orphan*/ lubacksub(float *, float *, float *, float *, float *,
                             float *, int);
int ludecomp(float *, float *, float *, int);
int /*<<< orphan*/ memcpy(float *, float *, int);
int luinv(float A0[], float Ainv[], int N) {
  int s;
  int i, j;
  int sz = N * sizeof(float);
  float A[N * sz], P[sz], x[sz], y[sz], b[sz], b0[sz];
  memcpy(A, A0, sizeof(A));
  s = ludecomp(A, A, P, N);
  if (!s) {
    return 0;
  }
  for (j = 0; j < N; j++) {
    for (i = 0; i < N; i++) {
      b0[i] = 0;
    }
    b0[j] = 1;
    lubacksub(A, x, y, b0, b, P, N);
    for (i = 0; i < N; i++) {
      Ainv[(j) * (N) + (i)] = x[i];
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<luinv>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x2,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x2c(%rbp),%ecx
imul   %ecx,%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x80(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x2c(%rbp),%ecx
lea    0xf(,%rcx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x78(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x48(%rbp)
mov    -0x2c(%rbp),%ecx
lea    0xf(,%rcx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0xa0(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x50(%rbp)
mov    -0x2c(%rbp),%ecx
lea    0xf(,%rcx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x98(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x58(%rbp)
mov    -0x2c(%rbp),%ecx
lea    0xf(,%rcx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x90(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x60(%rbp)
mov    -0x2c(%rbp),%ecx
lea    0xf(,%rcx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x88(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x68(%rbp)
mov    -0x10(%rbp),%rsi
shl    $0x2,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x80(%rbp),%rsi
mov    -0x78(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    %rsi,%rdi
call   1050 <ludecomp@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    126a <luinv+0x13a>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x6c(%rbp)
jmp    1361 <luinv+0x231>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1353 <luinv+0x223>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12b1 <luinv+0x181>
mov    -0x88(%rbp),%rax
movslq -0x24(%rbp),%rcx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1284 <luinv+0x154>
mov    -0x78(%rbp),%r9
mov    -0x90(%rbp),%r8
mov    -0x88(%rbp),%rcx
mov    -0x98(%rbp),%rdx
mov    -0xa0(%rbp),%rsi
mov    -0x80(%rbp),%rdi
movslq -0x28(%rbp),%rax
movss  0xd1f(%rip),%xmm0
movss  %xmm0,(%rcx,%rax,4)
mov    -0x1c(%rbp),%eax
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   1030 <lubacksub@plt>
add    $0x10,%rsp
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1340 <luinv+0x210>
mov    -0xa0(%rbp),%rax
movslq -0x24(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
add    -0x24(%rbp),%ecx
movslq %ecx,%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1300 <luinv+0x1d0>
jmp    1345 <luinv+0x215>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1271 <luinv+0x141>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x6c(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<luinv>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %edx,%ebx
mov    %rsi,-0x60(%rbp)
mov    %rdi,%rsi
lea    0x0(,%rbx,4),%eax
mov    %eax,%edx
imul   %ebx,%edx
lea    0x0(,%rdx,4),%rcx
mov    %rsp,%r15
sub    %rcx,%r15
mov    %r15,%rsp
mov    %rsp,%r13
shl    $0x2,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x78(%rbp)
mov    %rcx,%rsp
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rcx,%rsp
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rsp,%r12
sub    %rax,%r12
mov    %r12,%rsp
shl    $0x2,%edx
mov    %r15,%rdi
call   1050 <memcpy@plt>
mov    %r15,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
mov    %rbx,-0x30(%rbp)
mov    %ebx,%ecx
call   1060 <ludecomp@plt>
test   %eax,%eax
je     1293 <luinv+0x153>
mov    $0x1,%eax
cmpl   $0x0,-0x30(%rbp)
jle    1295 <luinv+0x155>
mov    -0x30(%rbp),%eax
mov    %rax,-0x58(%rbp)
lea    0x0(,%rax,4),%rax
mov    %rax,-0x48(%rbp)
xor    %ebx,%ebx
mov    %r15,-0x40(%rbp)
xor    %r15d,%r15d
mov    %r13,-0x38(%rbp)
mov    %r12,-0x50(%rbp)
mov    -0x48(%rbp),%r14
mov    -0x78(%rbp),%r13
cs nopw 0x0(%rax,%rax,1)
movslq %ebx,%rbx
mov    -0x60(%rbp),%rax
lea    (%rax,%rbx,4),%rax
mov    %rax,-0x80(%rbp)
mov    %r12,%rdi
xor    %esi,%esi
mov    %r14,%rdx
call   1030 <memset@plt>
movl   $0x3f800000,(%r12,%r15,4)
3f
sub    $0x8,%rsp
mov    -0x40(%rbp),%rdi
mov    %r13,%rsi
mov    -0x70(%rbp),%rdx
mov    %r12,%rcx
mov    -0x68(%rbp),%r8
mov    -0x38(%rbp),%r9
mov    -0x58(%rbp),%r12
push   %r12
call   1040 <lubacksub@plt>
add    $0x10,%rsp
mov    -0x80(%rbp),%rdi
mov    %r13,%rsi
mov    %r14,%rdx
call   1050 <memcpy@plt>
add    $0x1,%r15
add    -0x30(%rbp),%ebx
cmp    %r15,%r12
mov    -0x50(%rbp),%r12
jne    1220 <luinv+0xe0>
mov    $0x1,%eax
jmp    1295 <luinv+0x155>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @luinv(float* %0, float* %1, i32 %2) {
%4 = alloca i32
%5 = alloca float*
%6 = alloca float*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64
%18 = alloca i64
%19 = alloca i32
store float* %0, float** %5
store float* %1, float** %6
store i32 %2, i32* %7
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = mul i64 %21, 4
%23 = trunc i64 %22 to i32
store i32 %23, i32* %11
%24 = load i32, i32* %7
%25 = load i32, i32* %11
%26 = mul nsw i32 %24, %25
%27 = zext i32 %26 to i64
%28 = call i8* @llvm.stacksave()
store i8* %28, i8** %12
%29 = alloca float, i64 %27
store i64 %27, i64* %13
%30 = load i32, i32* %11
%31 = zext i32 %30 to i64
%32 = alloca float, i64 %31
store i64 %31, i64* %14
%33 = load i32, i32* %11
%34 = zext i32 %33 to i64
%35 = alloca float, i64 %34
store i64 %34, i64* %15
%36 = load i32, i32* %11
%37 = zext i32 %36 to i64
%38 = alloca float, i64 %37
store i64 %37, i64* %16
%39 = load i32, i32* %11
%40 = zext i32 %39 to i64
%41 = alloca float, i64 %40
store i64 %40, i64* %17
%42 = load i32, i32* %11
%43 = zext i32 %42 to i64
%44 = alloca float, i64 %43
store i64 %43, i64* %18
%45 = load float*, float** %5
%46 = mul nuw i64 4, %27
%47 = trunc i64 %46 to i32
%48 = call i32 @memcpy(float* %29, float* %45, i32 %47)
%49 = load i32, i32* %7
%50 = call i32 @ludecomp(float* %29, float* %29, float* %32, i32 %49)
store i32 %50, i32* %8
%51 = load i32, i32* %8
%52 = icmp ne i32 %51, 0
br i1 %52, label %54, label %53
53: ; preds = %3
store i32 0, i32* %4
store i32 1, i32* %19
br label %102
54: ; preds = %3
store i32 0, i32* %10
br label %55
55: ; preds = %98, %54
%56 = load i32, i32* %10
%57 = load i32, i32* %7
%58 = icmp slt i32 %56, %57
br i1 %58, label %59, label %101
59: ; preds = %55
store i32 0, i32* %9
br label %60
60: ; preds = %68, %59
%61 = load i32, i32* %9
%62 = load i32, i32* %7
%63 = icmp slt i32 %61, %62
br i1 %63, label %64, label %71
64: ; preds = %60
%65 = load i32, i32* %9
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds float, float* %44, i64 %66
store float 0.000000e+00, float* %67
br label %68
68: ; preds = %64
%69 = load i32, i32* %9
%70 = add nsw i32 %69, 1
store i32 %70, i32* %9
br label %60
71: ; preds = %60
%72 = load i32, i32* %10
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds float, float* %44, i64 %73
store float 1.000000e+00, float* %74
%75 = load i32, i32* %7
%76 = call i32 @lubacksub(float* %29, float* %35, float* %38, float* %44, float* %41, float* %32, i32 %75)
store i32 0, i32* %9
br label %77
77: ; preds = %94, %71
%78 = load i32, i32* %9
%79 = load i32, i32* %7
%80 = icmp slt i32 %78, %79
br i1 %80, label %81, label %97
81: ; preds = %77
%82 = load i32, i32* %9
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds float, float* %35, i64 %83
%85 = load float, float* %84
%86 = load float*, float** %6
%87 = load i32, i32* %10
%88 = load i32, i32* %7
%89 = mul nsw i32 %87, %88
%90 = load i32, i32* %9
%91 = add nsw i32 %89, %90
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds float, float* %86, i64 %92
store float %85, float* %93
br label %94
94: ; preds = %81
%95 = load i32, i32* %9
%96 = add nsw i32 %95, 1
store i32 %96, i32* %9
br label %77
97: ; preds = %77
br label %98
98: ; preds = %97
%99 = load i32, i32* %10
%100 = add nsw i32 %99, 1
store i32 %100, i32* %10
br label %55
101: ; preds = %55
store i32 1, i32* %4
store i32 1, i32* %19
br label %102
102: ; preds = %101, %53
%103 = load i8*, i8** %12
%104 = load i32, i32* %4
ret i32 %104
}

LLVM IR (-O2):
define i32 @luinv(float* %0, float* nocapture writeonly %1, i32 %2) {
%4 = shl i32 %2, 2
%5 = mul nsw i32 %4, %2
%6 = zext i32 %5 to i64
%7 = alloca float, i64 %6
%8 = zext i32 %4 to i64
%9 = alloca float, i64 %8
%10 = alloca float, i64 %8
%11 = bitcast float* %10 to i8*
%12 = alloca float, i64 %8
%13 = alloca float, i64 %8
%14 = alloca float, i64 %8
%15 = bitcast float* %14 to i8*
%16 = shl i32 %5, 2
%17 = call i32 @memcpy(float* %7, float* %0, i32 %16)
%18 = call i32 @ludecomp(float* %7, float* %7, float* %9, i32 %2)
%19 = icmp eq i32 %18, 0
br i1 %19, label %36, label %20
20: ; preds = %3
%21 = icmp sgt i32 %2, 0
br i1 %21, label %22, label %36
22: ; preds = %20
%23 = zext i32 %2 to i64
%24 = shl nuw nsw i64 %23, 2
br label %25
25: ; preds = %22, %25
%26 = phi i64 [ 0, %22 ], [ %34, %25 ]
%27 = trunc i64 %26 to i32
%28 = mul i32 %27, %2
%29 = sext i32 %28 to i64
%30 = getelementptr float, float* %1, i64 %29
%31 = bitcast float* %30 to i8*
%32 = getelementptr inbounds float, float* %14, i64 %26
store float 1.000000e+00, float* %32
%33 = call i32 @lubacksub(float* %7, float* %10, float* %12, float* %14, float* %13, float* %9, i32 %2)
%34 = add nuw nsw i64 %26, 1
%35 = icmp eq i64 %34, %23
br i1 %35, label %36, label %25
36: ; preds = %25, %20, %3
%37 = phi i32 [ 0, %3 ], [ 1, %20 ], [ 1, %25 ]
ret i32 %37
}