#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 */
scalar_t__ sqrt(float);
void mvVecNormalize4(float *v) {
  float length = (float)sqrt((v[0] * v[0]) + (v[1] * v[1]) + (v[2] * v[2]) +
                             (v[3] * v[3]));
  v[0] /= length;
  v[1] /= length;
  v[2] /= length;
  v[3] /= length;
}


x86 assembly (clang, -O0):
<mvVecNormalize4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulss  0x4(%rax),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <sqrt@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,(%rax)
movss  -0xc(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,0x4(%rax)
movss  -0xc(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,0x8(%rax)
movss  -0xc(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,0xc(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mvVecNormalize4>:
push   %rbx
mov    %rdi,%rbx
movss  (%rdi),%xmm0
movss  0x4(%rdi),%xmm1
mulss  %xmm1,%xmm1
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
movss  0x8(%rdi),%xmm1
mulss  %xmm1,%xmm1
addss  %xmm0,%xmm1
movss  0xc(%rdi),%xmm0
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
call   1030 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movups (%rbx),%xmm1
shufps $0x0,%xmm0,%xmm0
divps  %xmm0,%xmm1
movups %xmm1,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @mvVecNormalize4(float* %0) {
%2 = alloca float*
%3 = alloca float
store float* %0, float** %2
%4 = load float*, float** %2
%5 = getelementptr inbounds float, float* %4, i64 0
%6 = load float, float* %5
%7 = load float*, float** %2
%8 = getelementptr inbounds float, float* %7, i64 0
%9 = load float, float* %8
%10 = load float*, float** %2
%11 = getelementptr inbounds float, float* %10, i64 1
%12 = load float, float* %11
%13 = load float*, float** %2
%14 = getelementptr inbounds float, float* %13, i64 1
%15 = load float, float* %14
%16 = fmul float %12, %15
%17 = call float @llvm.fmuladd.f32(float %6, float %9, float %16)
%18 = load float*, float** %2
%19 = getelementptr inbounds float, float* %18, i64 2
%20 = load float, float* %19
%21 = load float*, float** %2
%22 = getelementptr inbounds float, float* %21, i64 2
%23 = load float, float* %22
%24 = call float @llvm.fmuladd.f32(float %20, float %23, float %17)
%25 = load float*, float** %2
%26 = getelementptr inbounds float, float* %25, i64 3
%27 = load float, float* %26
%28 = load float*, float** %2
%29 = getelementptr inbounds float, float* %28, i64 3
%30 = load float, float* %29
%31 = call float @llvm.fmuladd.f32(float %27, float %30, float %24)
%32 = call i64 @sqrt(float %31)
%33 = sitofp i64 %32 to float
store float %33, float* %3
%34 = load float, float* %3
%35 = load float*, float** %2
%36 = getelementptr inbounds float, float* %35, i64 0
%37 = load float, float* %36
%38 = fdiv float %37, %34
store float %38, float* %36
%39 = load float, float* %3
%40 = load float*, float** %2
%41 = getelementptr inbounds float, float* %40, i64 1
%42 = load float, float* %41
%43 = fdiv float %42, %39
store float %43, float* %41
%44 = load float, float* %3
%45 = load float*, float** %2
%46 = getelementptr inbounds float, float* %45, i64 2
%47 = load float, float* %46
%48 = fdiv float %47, %44
store float %48, float* %46
%49 = load float, float* %3
%50 = load float*, float** %2
%51 = getelementptr inbounds float, float* %50, i64 3
%52 = load float, float* %51
%53 = fdiv float %52, %49
store float %53, float* %51
ret void
}

LLVM IR (-O2):
define void @mvVecNormalize4(float* nocapture %0) {
%2 = load float, float* %0
%3 = getelementptr inbounds float, float* %0, i64 1
%4 = load float, float* %3
%5 = fmul float %4, %4
%6 = tail call float @llvm.fmuladd.f32(float %2, float %2, float %5)
%7 = getelementptr inbounds float, float* %0, i64 2
%8 = load float, float* %7
%9 = tail call float @llvm.fmuladd.f32(float %8, float %8, float %6)
%10 = getelementptr inbounds float, float* %0, i64 3
%11 = load float, float* %10
%12 = tail call float @llvm.fmuladd.f32(float %11, float %11, float %9)
%13 = tail call i64 @sqrt(float %12)
%14 = sitofp i64 %13 to float
%15 = bitcast float* %0 to <4 x float>*
%16 = load <4 x float>, <4 x float>* %15
%17 = insertelement <4 x float> poison, float %14, i64 0
%18 = shufflevector <4 x float> %17, <4 x float> poison, <4 x i32> zeroinitializer
%19 = fdiv <4 x float> %16, %18
%20 = bitcast float* %0 to <4 x float>*
store <4 x float> %19, <4 x float>* %20
ret void
}