#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 */
float MatrixDeterminant(float **);
float RoundTwo(float);
void MatrixInverse(float mat[3][3], float result[3][3]) {
  int i, j;
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      result[i][j] = RoundTwo(
          ((mat[(i + 1) % 3][(j + 1) % 3] * mat[(i + 2) % 3][(j + 2) % 3]) -
           (mat[(i + 1) % 3][(j + 2) % 3] * mat[(i + 2) % 3][(j + 1) % 3])) /
          MatrixDeterminant(mat));
    }
  }
}


x86 assembly (clang, -O0):
<MatrixInverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    12c7 <MatrixInverse+0x1a7>
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    12b4 <MatrixInverse+0x194>
mov    -0x8(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x60(%rbp),%rax
movslq %edx,%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x58(%rbp),%rax
movslq %edx,%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x50(%rbp),%rax
movslq %edx,%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x48(%rbp),%rax
movslq %edx,%rcx
movss  (%rax,%rcx,4),%xmm2
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x40(%rbp),%rax
movslq %edx,%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x38(%rbp),%rax
movslq %edx,%rcx
movss  (%rax,%rcx,4),%xmm1
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x30(%rbp),%rax
movslq %edx,%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x28(%rbp),%rax
movslq %edx,%rcx
mulss  (%rax,%rcx,4),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <MatrixDeterminant@plt>
movaps %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
divss  %xmm1,%xmm0
call   1040 <RoundTwo@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1148 <MatrixInverse+0x28>
jmp    12b9 <MatrixInverse+0x199>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <MatrixInverse+0x17>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MatrixInverse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%r13
lea    0x20(%rdi),%rbp
add    $0x8,%r14
mov    $0x1,%ebx
mov    $0x2,%eax
cs nopw 0x0(%rax,%rax,1)
mov    %rax,0x10(%rsp)
mov    0x10(%rsp),%rax
movabs $0xaaaaaaaaaaaaaaab,%rcx
aa aa aa
mul    %rcx
add    %rdx,%rdx
and    $0xfffffffffffffffc,%rdx
lea    (%rdx,%rdx,8),%rax
mov    %rbp,%r12
sub    %rax,%r12
mov    %rax,%rdx
cmp    $0x3,%rbx
mov    %rbx,%rax
mov    $0x0,%ecx
cmove  %rcx,%rax
lea    (%rax,%rax,2),%r15
movss  0x4(%r13,%r15,4),%xmm1
movss  -0x4(%r12),%xmm0
mulss  0x8(%r13,%r15,4),%xmm0
neg    %rdx
mov    %rdx,0x8(%rsp)
mulss  (%r12),%xmm1
subss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
mov    %r13,%rdi
call   1030 <MatrixDeterminant@plt>
movss  0x4(%rsp),%xmm1
divss  %xmm0,%xmm1
movaps %xmm1,%xmm0
call   1040 <RoundTwo@plt>
movss  %xmm0,-0x8(%r14)
movss  (%r12),%xmm0
mulss  0x0(%r13,%r15,4),%xmm0
movss  0x8(%r13,%r15,4),%xmm1
mulss  -0x8(%r12),%xmm1
subss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
mov    %r13,%rdi
call   1030 <MatrixDeterminant@plt>
movss  0x4(%rsp),%xmm1
divss  %xmm0,%xmm1
movaps %xmm1,%xmm0
call   1040 <RoundTwo@plt>
movss  %xmm0,-0x4(%r14)
movss  -0x8(%r12),%xmm0
mulss  0x4(%r13,%r15,4),%xmm0
movss  0x0(%r13,%r15,4),%xmm1
mov    0x8(%rsp),%rax
mulss  -0x4(%rbp,%rax,1),%xmm1
subss  %xmm0,%xmm1
movss  %xmm1,0x8(%rsp)
mov    %r13,%rdi
call   1030 <MatrixDeterminant@plt>
movss  0x8(%rsp),%xmm1
divss  %xmm0,%xmm1
movaps %xmm1,%xmm0
call   1040 <RoundTwo@plt>
mov    0x10(%rsp),%rax
movss  %xmm0,(%r14)
add    $0x1,%rbx
add    $0xc,%rbp
add    $0x1,%rax
add    $0xc,%r14
cmp    $0x4,%rbx
jne    1150 <MatrixInverse+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @MatrixInverse([3 x float]* %0, [3 x float]* %1) {
%3 = alloca [3 x float]*
%4 = alloca [3 x float]*
%5 = alloca i32
%6 = alloca i32
store [3 x float]* %0, [3 x float]** %3
store [3 x float]* %1, [3 x float]** %4
store i32 0, i32* %5
br label %7
7: ; preds = %82, %2
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %85
10: ; preds = %7
store i32 0, i32* %6
br label %11
11: ; preds = %78, %10
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %81
14: ; preds = %11
%15 = load [3 x float]*, [3 x float]** %3
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
%18 = srem i32 %17, 3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [3 x float], [3 x float]* %15, i64 %19
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
%23 = srem i32 %22, 3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [3 x float], [3 x float]* %20, i64 0, i64 %24
%26 = load float, float* %25
%27 = load [3 x float]*, [3 x float]** %3
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 2
%30 = srem i32 %29, 3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [3 x float], [3 x float]* %27, i64 %31
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 2
%35 = srem i32 %34, 3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [3 x float], [3 x float]* %32, i64 0, i64 %36
%38 = load float, float* %37
%39 = load [3 x float]*, [3 x float]** %3
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
%42 = srem i32 %41, 3
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [3 x float], [3 x float]* %39, i64 %43
%45 = load i32, i32* %6
%46 = add nsw i32 %45, 2
%47 = srem i32 %46, 3
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [3 x float], [3 x float]* %44, i64 0, i64 %48
%50 = load float, float* %49
%51 = load [3 x float]*, [3 x float]** %3
%52 = load i32, i32* %5
%53 = add nsw i32 %52, 2
%54 = srem i32 %53, 3
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [3 x float], [3 x float]* %51, i64 %55
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
%59 = srem i32 %58, 3
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [3 x float], [3 x float]* %56, i64 0, i64 %60
%62 = load float, float* %61
%63 = fmul float %50, %62
%64 = fneg float %63
%65 = call float @llvm.fmuladd.f32(float %26, float %38, float %64)
%66 = load [3 x float]*, [3 x float]** %3
%67 = bitcast [3 x float]* %66 to float**
%68 = call float @MatrixDeterminant(float** %67)
%69 = fdiv float %65, %68
%70 = call float @RoundTwo(float %69)
%71 = load [3 x float]*, [3 x float]** %4
%72 = load i32, i32* %5
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [3 x float], [3 x float]* %71, i64 %73
%75 = load i32, i32* %6
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [3 x float], [3 x float]* %74, i64 0, i64 %76
store float %70, float* %77
br label %78
78: ; preds = %14
%79 = load i32, i32* %6
%80 = add nsw i32 %79, 1
store i32 %80, i32* %6
br label %11
81: ; preds = %11
br label %82
82: ; preds = %81
%83 = load i32, i32* %5
%84 = add nsw i32 %83, 1
store i32 %84, i32* %5
br label %7
85: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @MatrixInverse([3 x float]* %0, [3 x float]* nocapture writeonly %1) {
%3 = bitcast [3 x float]* %0 to float**
br label %4
4: ; preds = %2, %4
%5 = phi i64 [ 0, %2 ], [ %6, %4 ]
%6 = add nuw nsw i64 %5, 1
%7 = icmp eq i64 %6, 3
%8 = and i64 %6, 4294967295
%9 = select i1 %7, i64 0, i64 %8
%10 = trunc i64 %5 to i32
%11 = add i32 %10, 2
%12 = urem i32 %11, 3
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds [3 x float], [3 x float]* %0, i64 %9, i64 1
%15 = load float, float* %14
%16 = getelementptr inbounds [3 x float], [3 x float]* %0, i64 %13, i64 2
%17 = load float, float* %16
%18 = getelementptr inbounds [3 x float], [3 x float]* %0, i64 %9, i64 2
%19 = load float, float* %18
%20 = getelementptr inbounds [3 x float], [3 x float]* %0, i64 %13, i64 1
%21 = load float, float* %20
%22 = fneg float %19
%23 = fmul float %21, %22
%24 = tail call float @llvm.fmuladd.f32(float %15, float %17, float %23)
%25 = tail call float @MatrixDeterminant(float** %3)
%26 = fdiv float %24, %25
%27 = tail call float @RoundTwo(float %26)
%28 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 %5, i64 0
store float %27, float* %28
%29 = load float, float* %18
%30 = getelementptr inbounds [3 x float], [3 x float]* %0, i64 %13, i64 0
%31 = load float, float* %30
%32 = getelementptr inbounds [3 x float], [3 x float]* %0, i64 %9, i64 0
%33 = load float, float* %32
%34 = load float, float* %16
%35 = fneg float %33
%36 = fmul float %34, %35
%37 = tail call float @llvm.fmuladd.f32(float %29, float %31, float %36)
%38 = tail call float @MatrixDeterminant(float** %3)
%39 = fdiv float %37, %38
%40 = tail call float @RoundTwo(float %39)
%41 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 %5, i64 1
store float %40, float* %41
%42 = load float, float* %32
%43 = load float, float* %20
%44 = load float, float* %14
%45 = load float, float* %30
%46 = fneg float %44
%47 = fmul float %45, %46
%48 = tail call float @llvm.fmuladd.f32(float %42, float %43, float %47)
%49 = tail call float @MatrixDeterminant(float** %3)
%50 = fdiv float %48, %49
%51 = tail call float @RoundTwo(float %50)
%52 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 %5, i64 2
store float %51, float* %52
%53 = icmp eq i64 %6, 3
br i1 %53, label %54, label %4
54: ; preds = %4
ret void
}