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


x86 assembly (clang, -O0):
<cquat_normalize_l>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <cquat_norm_l@plt>
fstpt  -0x20(%rbp)
mov    -0x10(%rbp),%rax
fldl   (%rax)
fldt   -0x20(%rbp)
fdivrp %st,%st(1)
mov    -0x8(%rbp),%rax
fstpl  (%rax)
mov    -0x10(%rbp),%rax
fldl   0x8(%rax)
fldt   -0x20(%rbp)
fdivrp %st,%st(1)
mov    -0x8(%rbp),%rax
fstpl  0x8(%rax)
mov    -0x10(%rbp),%rax
fldl   0x10(%rax)
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  -0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x18(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cquat_normalize_l>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <cquat_norm_l@plt>
fld    %st(0)
fdivrl (%rbx)
fstpl  (%r14)
fld    %st(0)
fdivrl 0x8(%rbx)
fstpl  0x8(%r14)
fld    %st(0)
fdivrl 0x10(%rbx)
fstpl  0x10(%r14)
fdivrl 0x18(%rbx)
fstpl  0x18(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @cquat_normalize_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_norm_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 = fpext double %10 to x86_fp80
%12 = load x86_fp80, x86_fp80* %5
%13 = fdiv x86_fp80 %11, %12
%14 = fptrunc x86_fp80 %13 to double
%15 = load double*, double** %3
%16 = getelementptr inbounds double, double* %15, i64 0
store double %14, double* %16
%17 = load double*, double** %4
%18 = getelementptr inbounds double, double* %17, i64 1
%19 = load double, double* %18
%20 = fpext double %19 to x86_fp80
%21 = load x86_fp80, x86_fp80* %5
%22 = fdiv x86_fp80 %20, %21
%23 = fptrunc x86_fp80 %22 to double
%24 = load double*, double** %3
%25 = getelementptr inbounds double, double* %24, i64 1
store double %23, double* %25
%26 = load double*, double** %4
%27 = getelementptr inbounds double, double* %26, i64 2
%28 = load double, double* %27
%29 = fpext double %28 to x86_fp80
%30 = load x86_fp80, x86_fp80* %5
%31 = fdiv x86_fp80 %29, %30
%32 = fptrunc x86_fp80 %31 to double
%33 = load double*, double** %3
%34 = getelementptr inbounds double, double* %33, i64 2
store double %32, double* %34
%35 = load double*, double** %4
%36 = getelementptr inbounds double, double* %35, i64 3
%37 = load double, double* %36
%38 = fpext double %37 to x86_fp80
%39 = load x86_fp80, x86_fp80* %5
%40 = fdiv x86_fp80 %38, %39
%41 = fptrunc x86_fp80 %40 to double
%42 = load double*, double** %3
%43 = getelementptr inbounds double, double* %42, i64 3
store double %41, double* %43
ret void
}

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