#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 */
scalar_t__ malloc(int);
float *matrix_inverse(const float *matr) {
  int i = 0;
  float *result = (float *)malloc(16 * sizeof(float));
  for (i = 0; i < 16; i++) {
    result[i] = matr[(i % 4) * 4 + i / 4];
  }
  return result;
}


x86 assembly (clang, -O0):
<matrix_inverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x40,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jge    1190 <matrix_inverse+0x80>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
shl    $0x2,%ecx
mov    -0xc(%rbp),%eax
mov    $0x4,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x20(%rbp),%rax
add    %edx,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1138 <matrix_inverse+0x28>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrix_inverse>:
push   %rbx
mov    %rdi,%rbx
mov    $0x40,%edi
call   1030 <malloc@plt>
movss  (%rbx),%xmm0
movss  %xmm0,(%rax)
movss  0x10(%rbx),%xmm0
movss  %xmm0,0x4(%rax)
movss  0x20(%rbx),%xmm0
movss  %xmm0,0x8(%rax)
movss  0x30(%rbx),%xmm0
movss  %xmm0,0xc(%rax)
movss  0x4(%rbx),%xmm0
movss  %xmm0,0x10(%rax)
movss  0x14(%rbx),%xmm0
movss  %xmm0,0x14(%rax)
movss  0x24(%rbx),%xmm0
movss  %xmm0,0x18(%rax)
movss  0x34(%rbx),%xmm0
movss  %xmm0,0x1c(%rax)
movss  0x8(%rbx),%xmm0
movss  %xmm0,0x20(%rax)
movss  0x18(%rbx),%xmm0
movss  %xmm0,0x24(%rax)
movss  0x28(%rbx),%xmm0
movss  %xmm0,0x28(%rax)
movss  0x38(%rbx),%xmm0
movss  %xmm0,0x2c(%rax)
movss  0xc(%rbx),%xmm0
movss  %xmm0,0x30(%rax)
movss  0x1c(%rbx),%xmm0
movss  %xmm0,0x34(%rax)
movss  0x2c(%rbx),%xmm0
movss  %xmm0,0x38(%rax)
movss  0x3c(%rbx),%xmm0
movss  %xmm0,0x3c(%rax)
pop    %rbx
ret

LLVM IR (-O0):
define float* @matrix_inverse(float* %0) {
%2 = alloca float*
%3 = alloca i32
%4 = alloca float*
store float* %0, float** %2
store i32 0, i32* %3
%5 = call i64 @malloc(i32 64)
%6 = inttoptr i64 %5 to float*
store float* %6, float** %4
store i32 0, i32* %3
br label %7
7: ; preds = %25, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 16
br i1 %9, label %10, label %28
10: ; preds = %7
%11 = load float*, float** %2
%12 = load i32, i32* %3
%13 = srem i32 %12, 4
%14 = mul nsw i32 %13, 4
%15 = load i32, i32* %3
%16 = sdiv i32 %15, 4
%17 = add nsw i32 %14, %16
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds float, float* %11, i64 %18
%20 = load float, float* %19
%21 = load float*, float** %4
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds float, float* %21, i64 %23
store float %20, float* %24
br label %25
25: ; preds = %10
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %7
28: ; preds = %7
%29 = load float*, float** %4
ret float* %29
}

LLVM IR (-O2):
define float* @matrix_inverse(float* nocapture %0) {
%2 = tail call i64 @malloc(i32 64)
%3 = inttoptr i64 %2 to float*
%4 = load float, float* %0
store float %4, float* %3
%5 = getelementptr inbounds float, float* %0, i64 4
%6 = load float, float* %5
%7 = getelementptr inbounds float, float* %3, i64 1
store float %6, float* %7
%8 = getelementptr inbounds float, float* %0, i64 8
%9 = load float, float* %8
%10 = getelementptr inbounds float, float* %3, i64 2
store float %9, float* %10
%11 = getelementptr inbounds float, float* %0, i64 12
%12 = load float, float* %11
%13 = getelementptr inbounds float, float* %3, i64 3
store float %12, float* %13
%14 = getelementptr inbounds float, float* %0, i64 1
%15 = load float, float* %14
%16 = getelementptr inbounds float, float* %3, i64 4
store float %15, float* %16
%17 = getelementptr inbounds float, float* %0, i64 5
%18 = load float, float* %17
%19 = getelementptr inbounds float, float* %3, i64 5
store float %18, float* %19
%20 = getelementptr inbounds float, float* %0, i64 9
%21 = load float, float* %20
%22 = getelementptr inbounds float, float* %3, i64 6
store float %21, float* %22
%23 = getelementptr inbounds float, float* %0, i64 13
%24 = load float, float* %23
%25 = getelementptr inbounds float, float* %3, i64 7
store float %24, float* %25
%26 = getelementptr inbounds float, float* %0, i64 2
%27 = load float, float* %26
%28 = getelementptr inbounds float, float* %3, i64 8
store float %27, float* %28
%29 = getelementptr inbounds float, float* %0, i64 6
%30 = load float, float* %29
%31 = getelementptr inbounds float, float* %3, i64 9
store float %30, float* %31
%32 = getelementptr inbounds float, float* %0, i64 10
%33 = load float, float* %32
%34 = getelementptr inbounds float, float* %3, i64 10
store float %33, float* %34
%35 = getelementptr inbounds float, float* %0, i64 14
%36 = load float, float* %35
%37 = getelementptr inbounds float, float* %3, i64 11
store float %36, float* %37
%38 = getelementptr inbounds float, float* %0, i64 3
%39 = load float, float* %38
%40 = getelementptr inbounds float, float* %3, i64 12
store float %39, float* %40
%41 = getelementptr inbounds float, float* %0, i64 7
%42 = load float, float* %41
%43 = getelementptr inbounds float, float* %3, i64 13
store float %42, float* %43
%44 = getelementptr inbounds float, float* %0, i64 11
%45 = load float, float* %44
%46 = getelementptr inbounds float, float* %3, i64 14
store float %45, float* %46
%47 = getelementptr inbounds float, float* %0, i64 15
%48 = load float, float* %47
%49 = getelementptr inbounds float, float* %3, i64 15
store float %48, float* %49
ret float* %3
}