#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 */
int fabs(double);
int inv2(const double *a, double *b) {
  double det = a[0] * a[3] - a[1] * a[2];
  if (fabs(det) < (1e-60))
    return -1;
  b[0] = a[3] / det;
  b[1] = -a[1] / det;
  b[2] = -a[2] / det;
  b[3] = a[0] / det;
  return 0;
}


x86 assembly (clang, -O0):
<inv2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%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,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe83(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1193 <inv2+0x83>
movl   $0xffffffff,-0x4(%rbp)
jmp    1222 <inv2+0x112>
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x18(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inv2>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  0x10(%rdi),%xmm1
mulsd  0x8(%rdi),%xmm1
movsd  (%rdi),%xmm0
mulsd  0x18(%rdi),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
call   1030 <fabs@plt>
test   %eax,%eax
jle    1192 <inv2+0x82>
movsd  0x18(%rbx),%xmm0
movsd  (%rsp),%xmm2
divsd  %xmm2,%xmm0
movsd  %xmm0,(%r14)
movsd  0x8(%rbx),%xmm0
movapd 0xea1(%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
jmp    1197 <inv2+0x87>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @inv2(double* %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca double*
%6 = alloca double
store double* %0, double** %4
store double* %1, double** %5
%7 = load double*, double** %4
%8 = getelementptr inbounds double, double* %7, i64 0
%9 = load double, double* %8
%10 = load double*, double** %4
%11 = getelementptr inbounds double, double* %10, i64 3
%12 = load double, double* %11
%13 = load double*, double** %4
%14 = getelementptr inbounds double, double* %13, i64 1
%15 = load double, double* %14
%16 = load double*, double** %4
%17 = getelementptr inbounds double, double* %16, i64 2
%18 = load double, double* %17
%19 = fmul double %15, %18
%20 = fneg double %19
%21 = call double @llvm.fmuladd.f64(double %9, double %12, double %20)
store double %21, double* %6
%22 = load double, double* %6
%23 = call i32 @fabs(double %22)
%24 = sitofp i32 %23 to double
%25 = fcmp olt double %24, 0x3379B604AAACA626
br i1 %25, label %26, label %27
26: ; preds = %2
store i32 -1, i32* %3
br label %58
27: ; preds = %2
%28 = load double*, double** %4
%29 = getelementptr inbounds double, double* %28, i64 3
%30 = load double, double* %29
%31 = load double, double* %6
%32 = fdiv double %30, %31
%33 = load double*, double** %5
%34 = getelementptr inbounds double, double* %33, i64 0
store double %32, double* %34
%35 = load double*, double** %4
%36 = getelementptr inbounds double, double* %35, i64 1
%37 = load double, double* %36
%38 = fneg double %37
%39 = load double, double* %6
%40 = fdiv double %38, %39
%41 = load double*, double** %5
%42 = getelementptr inbounds double, double* %41, i64 1
store double %40, double* %42
%43 = load double*, double** %4
%44 = getelementptr inbounds double, double* %43, i64 2
%45 = load double, double* %44
%46 = fneg double %45
%47 = load double, double* %6
%48 = fdiv double %46, %47
%49 = load double*, double** %5
%50 = getelementptr inbounds double, double* %49, i64 2
store double %48, double* %50
%51 = load double*, double** %4
%52 = getelementptr inbounds double, double* %51, i64 0
%53 = load double, double* %52
%54 = load double, double* %6
%55 = fdiv double %53, %54
%56 = load double*, double** %5
%57 = getelementptr inbounds double, double* %56, i64 3
store double %55, double* %57
store i32 0, i32* %3
br label %58
58: ; preds = %27, %26
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
define i32 @inv2(double* nocapture %0, double* nocapture writeonly %1) {
%3 = load double, double* %0
%4 = getelementptr inbounds double, double* %0, i64 3
%5 = load double, double* %4
%6 = getelementptr inbounds double, double* %0, i64 1
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %0, i64 2
%9 = load double, double* %8
%10 = fneg double %7
%11 = fmul double %9, %10
%12 = tail call double @llvm.fmuladd.f64(double %3, double %5, double %11)
%13 = tail call i32 @fabs(double %12)
%14 = icmp slt i32 %13, 1
br i1 %14, label %29, label %15
15: ; preds = %2
%16 = load double, double* %4
%17 = fdiv double %16, %12
store double %17, double* %1
%18 = load double, double* %6
%19 = fneg double %18
%20 = fdiv double %19, %12
%21 = getelementptr inbounds double, double* %1, i64 1
store double %20, double* %21
%22 = load double, double* %8
%23 = fneg double %22
%24 = fdiv double %23, %12
%25 = getelementptr inbounds double, double* %1, i64 2
store double %24, double* %25
%26 = load double, double* %0
%27 = fdiv double %26, %12
%28 = getelementptr inbounds double, double* %1, i64 3
store double %27, double* %28
br label %29
29: ; preds = %2, %15
%30 = phi i32 [ 0, %15 ], [ -1, %2 ]
ret i32 %30
}