#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 */
double const fabs(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ isnan(double);
int /*<<< orphan*/ stderr;
int inverse(double *x, double *y, const double eps) {
  double det;
  det = y[0] * y[3] - y[1] * y[2];
  if ((fabs(det) < eps) || isnan(det)) {
    fprintf(stderr,
            "theq() : determinant of the normal matrix is too small!\n");
    return (-1);
  }
  x[0] = y[3] / det;
  x[1] = -y[1] / det;
  x[2] = -y[2] / det;
  x[3] = y[0] / det;
  return (0);
}


x86 assembly (clang, -O0):
<inverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x18(%rax),%xmm2
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x18(%rbp),%rax
mulsd  0x10(%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <fabs@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
ja     11bc <inverse+0x8c>
movsd  -0x28(%rbp),%xmm0
call   1050 <isnan@plt>
cmp    $0x0,%rax
je     11dd <inverse+0xad>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0xe34(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    126c <inverse+0x13c>
mov    -0x18(%rbp),%rax
movsd  0x18(%rax),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x18(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inverse>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movsd  0x10(%rsi),%xmm1
mulsd  0x8(%rsi),%xmm1
movsd  (%rsi),%xmm2
mulsd  0x18(%rsi),%xmm2
subsd  %xmm1,%xmm2
movapd 0xeba(%rip),%xmm1
andpd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
ja     116e <inverse+0x4e>
mov    %rsi,%rbx
mov    %rdi,%r14
movapd %xmm2,%xmm0
movapd %xmm2,(%rsp)
call   1040 <isnan@plt>
movapd (%rsp),%xmm2
test   %rax,%rax
je     118a <inverse+0x6a>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
lea    0xea2(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    11d6 <inverse+0xb6>
movsd  0x18(%rbx),%xmm0
divsd  %xmm2,%xmm0
movsd  %xmm0,(%r14)
movsd  0x8(%rbx),%xmm0
movapd 0xe6b(%rip),%xmm1
xorpd  %xmm1,%xmm0
divsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%r14)
movsd  0x10(%rbx),%xmm0
xorpd  %xmm1,%xmm0
divsd  %xmm2,%xmm0
movsd  %xmm0,0x10(%r14)
movsd  (%rbx),%xmm0
divsd  %xmm2,%xmm0
movsd  %xmm0,0x18(%r14)
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [57 x i8] c"theq() : determinant of the normal matrix is too small!\0A\00"
define i32 @inverse(double* %0, double* %1, double %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store double %2, double* %7
%9 = load double*, double** %6
%10 = getelementptr inbounds double, double* %9, i64 0
%11 = load double, double* %10
%12 = load double*, double** %6
%13 = getelementptr inbounds double, double* %12, i64 3
%14 = load double, double* %13
%15 = load double*, double** %6
%16 = getelementptr inbounds double, double* %15, i64 1
%17 = load double, double* %16
%18 = load double*, double** %6
%19 = getelementptr inbounds double, double* %18, i64 2
%20 = load double, double* %19
%21 = fmul double %17, %20
%22 = fneg double %21
%23 = call double @llvm.fmuladd.f64(double %11, double %14, double %22)
store double %23, double* %8
%24 = load double, double* %8
%25 = call double @fabs(double %24)
%26 = load double, double* %7
%27 = fcmp olt double %25, %26
br i1 %27, label %32, label %28
28: ; preds = %3
%29 = load double, double* %8
%30 = call i64 @isnan(double %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %28, %3
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %66
35: ; preds = %28
%36 = load double*, double** %6
%37 = getelementptr inbounds double, double* %36, i64 3
%38 = load double, double* %37
%39 = load double, double* %8
%40 = fdiv double %38, %39
%41 = load double*, double** %5
%42 = getelementptr inbounds double, double* %41, i64 0
store double %40, double* %42
%43 = load double*, double** %6
%44 = getelementptr inbounds double, double* %43, i64 1
%45 = load double, double* %44
%46 = fneg double %45
%47 = load double, double* %8
%48 = fdiv double %46, %47
%49 = load double*, double** %5
%50 = getelementptr inbounds double, double* %49, i64 1
store double %48, double* %50
%51 = load double*, double** %6
%52 = getelementptr inbounds double, double* %51, i64 2
%53 = load double, double* %52
%54 = fneg double %53
%55 = load double, double* %8
%56 = fdiv double %54, %55
%57 = load double*, double** %5
%58 = getelementptr inbounds double, double* %57, i64 2
store double %56, double* %58
%59 = load double*, double** %6
%60 = getelementptr inbounds double, double* %59, i64 0
%61 = load double, double* %60
%62 = load double, double* %8
%63 = fdiv double %61, %62
%64 = load double*, double** %5
%65 = getelementptr inbounds double, double* %64, i64 3
store double %63, double* %65
store i32 0, i32* %4
br label %66
66: ; preds = %35, %32
%67 = load i32, i32* %4
ret i32 %67
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [57 x i8] c"theq() : determinant of the normal matrix is too small!\0A\00"
define i32 @inverse(double* nocapture writeonly %0, double* nocapture %1, double %2) {
%4 = load double, double* %1
%5 = getelementptr inbounds double, double* %1, i64 3
%6 = load double, double* %5
%7 = getelementptr inbounds double, double* %1, i64 1
%8 = load double, double* %7
%9 = getelementptr inbounds double, double* %1, i64 2
%10 = load double, double* %9
%11 = fneg double %8
%12 = fmul double %10, %11
%13 = tail call double @llvm.fmuladd.f64(double %4, double %6, double %12)
%14 = tail call double @llvm.fabs.f64(double %13)
%15 = fcmp olt double %14, %2
br i1 %15, label %19, label %16
16: ; preds = %3
%17 = tail call i64 @isnan(double %13)
%18 = icmp eq i64 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16, %3
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
br label %36
22: ; preds = %16
%23 = load double, double* %5
%24 = fdiv double %23, %13
store double %24, double* %0
%25 = load double, double* %7
%26 = fneg double %25
%27 = fdiv double %26, %13
%28 = getelementptr inbounds double, double* %0, i64 1
store double %27, double* %28
%29 = load double, double* %9
%30 = fneg double %29
%31 = fdiv double %30, %13
%32 = getelementptr inbounds double, double* %0, i64 2
store double %31, double* %32
%33 = load double, double* %1
%34 = fdiv double %33, %13
%35 = getelementptr inbounds double, double* %0, i64 3
store double %34, double* %35
br label %36
36: ; preds = %22, %19
%37 = phi i32 [ -1, %19 ], [ 0, %22 ]
ret i32 %37
}