#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 QuaternionNorm(float *);
float *QuaternionNormalize(float quat[4]) {
  float temp = 1.0 / QuaternionNorm(quat);
  quat[0] *= temp;
  quat[1] *= temp;
  quat[2] *= temp;
  quat[3] *= temp;
  return quat;
}


x86 assembly (clang, -O0):
<QuaternionNormalize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <QuaternionNorm@plt>
movaps %xmm0,%xmm1
movsd  0xed0(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mulss  (%rax),%xmm0
movss  %xmm0,(%rax)
movss  -0xc(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mulss  0x4(%rax),%xmm0
movss  %xmm0,0x4(%rax)
movss  -0xc(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mulss  0x8(%rax),%xmm0
movss  %xmm0,0x8(%rax)
movss  -0xc(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mulss  0xc(%rax),%xmm0
movss  %xmm0,0xc(%rax)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<QuaternionNormalize>:
push   %rbx
mov    %rdi,%rbx
call   1030 <QuaternionNorm@plt>
movsd  0xedf(%rip),%xmm1
divsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movups (%rbx),%xmm1
shufps $0x0,%xmm0,%xmm0
mulps  %xmm1,%xmm0
movups %xmm0,(%rbx)
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define float* @QuaternionNormalize(float* %0) {
%2 = alloca float*
%3 = alloca float
store float* %0, float** %2
%4 = load float*, float** %2
%5 = call double @QuaternionNorm(float* %4)
%6 = fdiv double 1.000000e+00, %5
%7 = fptrunc double %6 to float
store float %7, float* %3
%8 = load float, float* %3
%9 = load float*, float** %2
%10 = getelementptr inbounds float, float* %9, i64 0
%11 = load float, float* %10
%12 = fmul float %11, %8
store float %12, float* %10
%13 = load float, float* %3
%14 = load float*, float** %2
%15 = getelementptr inbounds float, float* %14, i64 1
%16 = load float, float* %15
%17 = fmul float %16, %13
store float %17, float* %15
%18 = load float, float* %3
%19 = load float*, float** %2
%20 = getelementptr inbounds float, float* %19, i64 2
%21 = load float, float* %20
%22 = fmul float %21, %18
store float %22, float* %20
%23 = load float, float* %3
%24 = load float*, float** %2
%25 = getelementptr inbounds float, float* %24, i64 3
%26 = load float, float* %25
%27 = fmul float %26, %23
store float %27, float* %25
%28 = load float*, float** %2
ret float* %28
}

LLVM IR (-O2):
define float* @QuaternionNormalize(float* returned %0) {
%2 = tail call double @QuaternionNorm(float* %0)
%3 = fdiv double 1.000000e+00, %2
%4 = fptrunc double %3 to float
%5 = bitcast float* %0 to <4 x float>*
%6 = load <4 x float>, <4 x float>* %5
%7 = insertelement <4 x float> poison, float %4, i64 0
%8 = shufflevector <4 x float> %7, <4 x float> poison, <4 x i32> zeroinitializer
%9 = fmul <4 x float> %6, %8
%10 = bitcast float* %0 to <4 x float>*
store <4 x float> %9, <4 x float>* %10
ret float* %0
}