#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 */
long double cquat_norm2_l(double const *);
void cquat_inverse_l(double *qdest, const double *qorg) {
  long double norm2_l = cquat_norm2_l(qorg);
  qdest[0] = -qorg[0] / norm2_l;
  qdest[1] = -qorg[1] / norm2_l;
  qdest[2] = -qorg[2] / norm2_l;
  qdest[3] = qorg[3] / norm2_l;
}


x86 assembly (clang, -O0):
<cquat_inverse_l>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <cquat_norm2_l@plt>
fstpt  -0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movapd 0xec4(%rip),%xmm1
pxor   %xmm1,%xmm0
movlpd %xmm0,-0x28(%rbp)
fldl   -0x28(%rbp)
fldt   -0x20(%rbp)
fdivrp %st,%st(1)
mov    -0x8(%rbp),%rax
fstpl  (%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
pxor   %xmm1,%xmm0
movlpd %xmm0,-0x30(%rbp)
fldl   -0x30(%rbp)
fldt   -0x20(%rbp)
fdivrp %st,%st(1)
mov    -0x8(%rbp),%rax
fstpl  0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
pxor   %xmm1,%xmm0
movlpd %xmm0,-0x38(%rbp)
fldl   -0x38(%rbp)
fldt   -0x20(%rbp)
fdivrp %st,%st(1)
mov    -0x8(%rbp),%rax
fstpl  0x10(%rax)
mov    -0x10(%rbp),%rax
fldl   0x18(%rax)
fldt   -0x20(%rbp)
fdivrp %st,%st(1)
fstpl  -0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x18(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cquat_inverse_l>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <cquat_norm2_l@plt>
movsd  (%rbx),%xmm0
movaps 0xed0(%rip),%xmm1
xorps  %xmm1,%xmm0
movlps %xmm0,0x10(%rsp)
fld    %st(0)
fdivrl 0x10(%rsp)
fstpl  (%r14)
movsd  0x8(%rbx),%xmm0
xorps  %xmm1,%xmm0
movlps %xmm0,0x8(%rsp)
fld    %st(0)
fdivrl 0x8(%rsp)
fstpl  0x8(%r14)
movsd  0x10(%rbx),%xmm0
xorps  %xmm1,%xmm0
movlps %xmm0,(%rsp)
fld    %st(0)
fdivrl (%rsp)
fstpl  0x10(%r14)
fdivrl 0x18(%rbx)
fstpl  0x18(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @cquat_inverse_l(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca x86_fp80
store double* %0, double** %3
store double* %1, double** %4
%6 = load double*, double** %4
%7 = call x86_fp80 @cquat_norm2_l(double* %6)
store x86_fp80 %7, x86_fp80* %5
%8 = load double*, double** %4
%9 = getelementptr inbounds double, double* %8, i64 0
%10 = load double, double* %9
%11 = fneg double %10
%12 = fpext double %11 to x86_fp80
%13 = load x86_fp80, x86_fp80* %5
%14 = fdiv x86_fp80 %12, %13
%15 = fptrunc x86_fp80 %14 to double
%16 = load double*, double** %3
%17 = getelementptr inbounds double, double* %16, i64 0
store double %15, double* %17
%18 = load double*, double** %4
%19 = getelementptr inbounds double, double* %18, i64 1
%20 = load double, double* %19
%21 = fneg double %20
%22 = fpext double %21 to x86_fp80
%23 = load x86_fp80, x86_fp80* %5
%24 = fdiv x86_fp80 %22, %23
%25 = fptrunc x86_fp80 %24 to double
%26 = load double*, double** %3
%27 = getelementptr inbounds double, double* %26, i64 1
store double %25, double* %27
%28 = load double*, double** %4
%29 = getelementptr inbounds double, double* %28, i64 2
%30 = load double, double* %29
%31 = fneg double %30
%32 = fpext double %31 to x86_fp80
%33 = load x86_fp80, x86_fp80* %5
%34 = fdiv x86_fp80 %32, %33
%35 = fptrunc x86_fp80 %34 to double
%36 = load double*, double** %3
%37 = getelementptr inbounds double, double* %36, i64 2
store double %35, double* %37
%38 = load double*, double** %4
%39 = getelementptr inbounds double, double* %38, i64 3
%40 = load double, double* %39
%41 = fpext double %40 to x86_fp80
%42 = load x86_fp80, x86_fp80* %5
%43 = fdiv x86_fp80 %41, %42
%44 = fptrunc x86_fp80 %43 to double
%45 = load double*, double** %3
%46 = getelementptr inbounds double, double* %45, i64 3
store double %44, double* %46
ret void
}

LLVM IR (-O2):
define void @cquat_inverse_l(double* nocapture writeonly %0, double* %1) {
%3 = tail call x86_fp80 @cquat_norm2_l(double* %1)
%4 = load double, double* %1
%5 = fneg double %4
%6 = fpext double %5 to x86_fp80
%7 = fdiv x86_fp80 %6, %3
%8 = fptrunc x86_fp80 %7 to double
store double %8, double* %0
%9 = getelementptr inbounds double, double* %1, i64 1
%10 = load double, double* %9
%11 = fneg double %10
%12 = fpext double %11 to x86_fp80
%13 = fdiv x86_fp80 %12, %3
%14 = fptrunc x86_fp80 %13 to double
%15 = getelementptr inbounds double, double* %0, i64 1
store double %14, double* %15
%16 = getelementptr inbounds double, double* %1, i64 2
%17 = load double, double* %16
%18 = fneg double %17
%19 = fpext double %18 to x86_fp80
%20 = fdiv x86_fp80 %19, %3
%21 = fptrunc x86_fp80 %20 to double
%22 = getelementptr inbounds double, double* %0, i64 2
store double %21, double* %22
%23 = getelementptr inbounds double, double* %1, i64 3
%24 = load double, double* %23
%25 = fpext double %24 to x86_fp80
%26 = fdiv x86_fp80 %25, %3
%27 = fptrunc x86_fp80 %26 to double
%28 = getelementptr inbounds double, double* %0, i64 3
store double %27, double* %28
ret void
}