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


x86 assembly (clang, -O0):
<cquat_normalize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <cquat_norm@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
divsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
divsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%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_normalize>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <cquat_norm@plt>
movsd  (%rbx),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
movsd  0x8(%rbx),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%r14)
movsd  0x10(%rbx),%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_normalize(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_norm(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 = load double, double* %5
%12 = fdiv double %10, %11
%13 = load double*, double** %3
%14 = getelementptr inbounds double, double* %13, i64 0
store double %12, double* %14
%15 = load double*, double** %4
%16 = getelementptr inbounds double, double* %15, i64 1
%17 = load double, double* %16
%18 = load double, double* %5
%19 = fdiv double %17, %18
%20 = load double*, double** %3
%21 = getelementptr inbounds double, double* %20, i64 1
store double %19, double* %21
%22 = load double*, double** %4
%23 = getelementptr inbounds double, double* %22, i64 2
%24 = load double, double* %23
%25 = load double, double* %5
%26 = fdiv double %24, %25
%27 = load double*, double** %3
%28 = getelementptr inbounds double, double* %27, i64 2
store double %26, double* %28
%29 = load double*, double** %4
%30 = getelementptr inbounds double, double* %29, i64 3
%31 = load double, double* %30
%32 = load double, double* %5
%33 = fdiv double %31, %32
%34 = load double*, double** %3
%35 = getelementptr inbounds double, double* %34, i64 3
store double %33, double* %35
ret void
}

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