#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 doubles_magnitude(double const *, int);
void doubles_quat_inverse(const double q[4], double r[4]) {
  double mag = doubles_magnitude(q, 4);
  r[0] = q[0] / mag;
  r[1] = -q[1] / mag;
  r[2] = -q[2] / mag;
  r[3] = -q[3] / mag;
}


x86 assembly (clang, -O0):
<doubles_quat_inverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x4,%esi
call   1030 <doubles_magnitude@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
divsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
divsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x18(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doubles_quat_inverse>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x4,%esi
call   1030 <doubles_magnitude@plt>
movsd  (%rbx),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
movsd  0x8(%rbx),%xmm1
movapd 0xec2(%rip),%xmm2
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
xorpd  %xmm2,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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