#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 float *matB;
typedef float *matA;

/* Variables and functions */
double MatDet2by2(float *);
void MatInv2by2(const float *matA, float *matB) {
  float det_inv = 1.0 / MatDet2by2((float *)matA);
  (*((matB) + 1)) = -(*((matA) + 1)) * det_inv;
  (*((matB))) = (*((matA + 2) + 1)) * det_inv;
  (*((matB + 2))) = -(*((matA + 2))) * det_inv;
  (*((matB + 2) + 1)) = (*((matA))) * det_inv;
}


x86 assembly (clang, -O0):
<MatInv2by2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <MatDet2by2@plt>
movaps %xmm0,%xmm1
movsd  0xecc(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm0
mulss  -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mulss  -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0xc(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MatInv2by2>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <MatDet2by2@plt>
movsd  0xed9(%rip),%xmm1
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  0x4(%rbx),%xmm1
movaps 0xed2(%rip),%xmm2
xorps  %xmm2,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x4(%r14)
movss  0xc(%rbx),%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,(%r14)
movss  0x8(%rbx),%xmm1
xorps  %xmm2,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,0x8(%r14)
mulss  (%rbx),%xmm0
movss  %xmm0,0xc(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @MatInv2by2(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca float
store float* %0, float** %3
store float* %1, float** %4
%6 = load float*, float** %3
%7 = call double @MatDet2by2(float* %6)
%8 = fdiv double 1.000000e+00, %7
%9 = fptrunc double %8 to float
store float %9, float* %5
%10 = load float*, float** %3
%11 = getelementptr inbounds float, float* %10, i64 1
%12 = load float, float* %11
%13 = fneg float %12
%14 = load float, float* %5
%15 = fmul float %13, %14
%16 = load float*, float** %4
%17 = getelementptr inbounds float, float* %16, i64 1
store float %15, float* %17
%18 = load float*, float** %3
%19 = getelementptr inbounds float, float* %18, i64 2
%20 = getelementptr inbounds float, float* %19, i64 1
%21 = load float, float* %20
%22 = load float, float* %5
%23 = fmul float %21, %22
%24 = load float*, float** %4
store float %23, float* %24
%25 = load float*, float** %3
%26 = getelementptr inbounds float, float* %25, i64 2
%27 = load float, float* %26
%28 = fneg float %27
%29 = load float, float* %5
%30 = fmul float %28, %29
%31 = load float*, float** %4
%32 = getelementptr inbounds float, float* %31, i64 2
store float %30, float* %32
%33 = load float*, float** %3
%34 = load float, float* %33
%35 = load float, float* %5
%36 = fmul float %34, %35
%37 = load float*, float** %4
%38 = getelementptr inbounds float, float* %37, i64 2
%39 = getelementptr inbounds float, float* %38, i64 1
store float %36, float* %39
ret void
}

LLVM IR (-O2):
define void @MatInv2by2(float* %0, float* nocapture writeonly %1) {
%3 = tail call double @MatDet2by2(float* %0)
%4 = fdiv double 1.000000e+00, %3
%5 = fptrunc double %4 to float
%6 = getelementptr inbounds float, float* %0, i64 1
%7 = load float, float* %6
%8 = fneg float %7
%9 = fmul float %8, %5
%10 = getelementptr inbounds float, float* %1, i64 1
store float %9, float* %10
%11 = getelementptr inbounds float, float* %0, i64 2
%12 = getelementptr inbounds float, float* %0, i64 3
%13 = load float, float* %12
%14 = fmul float %13, %5
store float %14, float* %1
%15 = load float, float* %11
%16 = fneg float %15
%17 = fmul float %5, %16
%18 = getelementptr inbounds float, float* %1, i64 2
store float %17, float* %18
%19 = load float, float* %0
%20 = fmul float %19, %5
%21 = getelementptr inbounds float, float* %1, i64 3
store float %20, float* %21
ret void
}