#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 int /*<<< orphan*/ y;
typedef int /*<<< orphan*/ u;
typedef int /*<<< orphan*/ p;

/* Variables and functions */
void *alloca(unsigned int);
int /*<<< orphan*/ frlufact(float *, unsigned int *, float const *,
                            unsigned int);
int /*<<< orphan*/ frlusolve(float *, float *, float *, unsigned int *,
                             unsigned int);
int /*<<< orphan*/ frtranspose(float *, float *, unsigned int, unsigned int);
int /*<<< orphan*/ memset(float *, int /*<<< orphan*/, unsigned int);
void frinv(float *ainv, const float *a, unsigned d) {
  float *u, *y;
  unsigned int *p;
  unsigned int k;
  u = alloca(d * d * sizeof(u[0]));
  p = alloca((d - 1) * sizeof(p[0]));
  frlufact(u, p, a, d);
  for (k = 0; k < d; k++) {
    y = &ainv[k * d];
    memset(y, 0, d * sizeof(y[0]));
    y[k] = 1;
    frlusolve(y, y, u, p, d);
  }
  frtranspose(ainv, ainv, d, d);
}


x86 assembly (clang, -O0):
<frinv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <alloca@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,%eax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <alloca@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
call   1040 <frlufact@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1220 <frinv+0xd0>
mov    -0x8(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x14(%rbp),%ecx
mov    %ecx,%ecx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%eax
shl    $0x2,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x28(%rbp),%rax
mov    -0x34(%rbp),%ecx
movss  0xe0c(%rip),%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x28(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x14(%rbp),%r8d
call   1060 <frlusolve@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11ad <frinv+0x5d>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1070 <frtranspose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<frinv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,0x10(%rsp)
lea    0x0(,%rbp,4),%edi
mov    %edi,0x1c(%rsp)
imul   %edx,%edi
call   1050 <alloca@plt>
mov    %rax,%rbx
lea    -0x4(,%rbp,4),%edi
call   1050 <alloca@plt>
mov    %rax,%r13
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %r14,%rdx
mov    %ebp,%ecx
call   1040 <frlufact@plt>
mov    %rbp,0x8(%rsp)
test   %ebp,%ebp
je     1210 <frinv+0xc0>
mov    0x8(%rsp),%r15d
xor    %r14d,%r14d
mov    0x10(%rsp),%r12
mov    %rbx,0x20(%rsp)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rbx
mov    %r14d,%r13d
mov    0x10(%rsp),%rax
lea    (%rax,%r13,4),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    0x1c(%rsp),%edx
call   1030 <memset@plt>
movl   $0x3f800000,(%r12,%r13,4)
3f
mov    %rbx,%r13
mov    0x20(%rsp),%rdx
mov    %rbp,%rdi
mov    %rbp,%rsi
mov    %rbx,%rcx
mov    0x8(%rsp),%rbp
mov    %ebp,%r8d
call   1060 <frlusolve@plt>
add    $0x4,%r12
add    %ebp,%r14d
add    $0xffffffffffffffff,%r15
jne    11c0 <frinv+0x70>
mov    0x10(%rsp),%rdi
mov    %rdi,%rsi
mov    0x8(%rsp),%rcx
mov    %ecx,%edx
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <frtranspose@plt>

LLVM IR (-O0):
define void @frinv(float* %0, float* %1, i32 %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca i32
%7 = alloca float*
%8 = alloca float*
%9 = alloca i32*
%10 = alloca i32
store float* %0, float** %4
store float* %1, float** %5
store i32 %2, i32* %6
%11 = load i32, i32* %6
%12 = load i32, i32* %6
%13 = mul i32 %11, %12
%14 = zext i32 %13 to i64
%15 = mul i64 %14, 4
%16 = trunc i64 %15 to i32
%17 = call i8* @alloca(i32 %16)
%18 = bitcast i8* %17 to float*
store float* %18, float** %7
%19 = load i32, i32* %6
%20 = sub i32 %19, 1
%21 = zext i32 %20 to i64
%22 = mul i64 %21, 4
%23 = trunc i64 %22 to i32
%24 = call i8* @alloca(i32 %23)
%25 = bitcast i8* %24 to i32*
store i32* %25, i32** %9
%26 = load float*, float** %7
%27 = load i32*, i32** %9
%28 = load float*, float** %5
%29 = load i32, i32* %6
%30 = call i32 @frlufact(float* %26, i32* %27, float* %28, i32 %29)
store i32 0, i32* %10
br label %31
31: ; preds = %58, %3
%32 = load i32, i32* %10
%33 = load i32, i32* %6
%34 = icmp ult i32 %32, %33
br i1 %34, label %35, label %61
35: ; preds = %31
%36 = load float*, float** %4
%37 = load i32, i32* %10
%38 = load i32, i32* %6
%39 = mul i32 %37, %38
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds float, float* %36, i64 %40
store float* %41, float** %8
%42 = load float*, float** %8
%43 = load i32, i32* %6
%44 = zext i32 %43 to i64
%45 = mul i64 %44, 4
%46 = trunc i64 %45 to i32
%47 = call i32 @memset(float* %42, i32 0, i32 %46)
%48 = load float*, float** %8
%49 = load i32, i32* %10
%50 = zext i32 %49 to i64
%51 = getelementptr inbounds float, float* %48, i64 %50
store float 1.000000e+00, float* %51
%52 = load float*, float** %8
%53 = load float*, float** %8
%54 = load float*, float** %7
%55 = load i32*, i32** %9
%56 = load i32, i32* %6
%57 = call i32 @frlusolve(float* %52, float* %53, float* %54, i32* %55, i32 %56)
br label %58
58: ; preds = %35
%59 = load i32, i32* %10
%60 = add i32 %59, 1
store i32 %60, i32* %10
br label %31
61: ; preds = %31
%62 = load float*, float** %4
%63 = load float*, float** %4
%64 = load i32, i32* %6
%65 = load i32, i32* %6
%66 = call i32 @frtranspose(float* %62, float* %63, i32 %64, i32 %65)
ret void
}

LLVM IR (-O2):
define void @frinv(float* %0, float* %1, i32 %2) {
%4 = shl i32 %2, 2
%5 = mul i32 %4, %2
%6 = tail call i8* @alloca(i32 %5)
%7 = bitcast i8* %6 to float*
%8 = add i32 %4, -4
%9 = tail call i8* @alloca(i32 %8)
%10 = bitcast i8* %9 to i32*
%11 = tail call i32 @frlufact(float* %7, i32* %10, float* %1, i32 %2)
%12 = icmp eq i32 %2, 0
br i1 %12, label %26, label %13
13: ; preds = %3
%14 = zext i32 %2 to i64
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ 0, %13 ], [ %24, %15 ]
%17 = trunc i64 %16 to i32
%18 = mul i32 %17, %2
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds float, float* %0, i64 %19
%21 = tail call i32 @memset(float* %20, i32 0, i32 %4)
%22 = getelementptr inbounds float, float* %20, i64 %16
store float 1.000000e+00, float* %22
%23 = tail call i32 @frlusolve(float* %20, float* %20, float* %7, i32* %10, i32 %2)
%24 = add nuw nsw i64 %16, 1
%25 = icmp eq i64 %24, %14
br i1 %25, label %26, label %15
26: ; preds = %15, %3
%27 = tail call i32 @frtranspose(float* %0, float* %0, i32 %2, i32 %2)
ret void
}