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


x86 assembly (clang, -O0):
<cquat_inverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <cquat_norm2@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x18(%rbp),%xmm0
mov    -0x8(%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  -0x18(%rbp),%xmm0
mov    -0x8(%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  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm0
divsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x18(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cquat_inverse>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <cquat_norm2@plt>
movsd  (%rbx),%xmm1
movapd 0xed2(%rip),%xmm2
xorpd  %xmm2,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
movsd  0x8(%rbx),%xmm1
xorpd  %xmm2,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%r14)
movsd  0x10(%rbx),%xmm1
xorpd  %xmm2,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%r14)
movsd  0x18(%rbx),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @cquat_inverse(double* nocapture writeonly %0, double* %1) {
%3 = tail call double @cquat_norm2(double* %1)
%4 = load double, double* %1
%5 = fneg double %4
%6 = fdiv double %5, %3
store double %6, double* %0
%7 = getelementptr inbounds double, double* %1, i64 1
%8 = load double, double* %7
%9 = fneg double %8
%10 = fdiv double %9, %3
%11 = getelementptr inbounds double, double* %0, i64 1
store double %10, double* %11
%12 = getelementptr inbounds double, double* %1, i64 2
%13 = load double, double* %12
%14 = fneg double %13
%15 = fdiv double %14, %3
%16 = getelementptr inbounds double, double* %0, i64 2
store double %15, double* %16
%17 = getelementptr inbounds double, double* %1, i64 3
%18 = load double, double* %17
%19 = fdiv double %18, %3
%20 = getelementptr inbounds double, double* %0, i64 3
store double %19, double* %20
ret void
}