#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 */
float Magnitude(float *);
void NormalizeVector(float *arVec) {
  float fMagnitude = Magnitude(arVec);
  if (fMagnitude != 0.0f) {
    arVec[0] = arVec[0] / fMagnitude;
    arVec[1] = arVec[1] / fMagnitude;
    arVec[2] = arVec[2] / fMagnitude;
  }
}


x86 assembly (clang, -O0):
<NormalizeVector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <Magnitude@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1146 <NormalizeVector+0x36>
jp     1146 <NormalizeVector+0x36>
jmp    1189 <NormalizeVector+0x79>
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
divss  -0xc(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
divss  -0xc(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
divss  -0xc(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NormalizeVector>:
push   %rbx
mov    %rdi,%rbx
call   1030 <Magnitude@plt>
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1123 <NormalizeVector+0x13>
jnp    114b <NormalizeVector+0x3b>
movss  (%rbx),%xmm1
movss  0x4(%rbx),%xmm2
divss  %xmm0,%xmm1
movss  %xmm1,(%rbx)
divss  %xmm0,%xmm2
movss  %xmm2,0x4(%rbx)
movss  0x8(%rbx),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0x8(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @NormalizeVector(float* %0) {
%2 = alloca float*
%3 = alloca float
store float* %0, float** %2
%4 = load float*, float** %2
%5 = call float @Magnitude(float* %4)
store float %5, float* %3
%6 = load float, float* %3
%7 = fcmp une float %6, 0.000000e+00
br i1 %7, label %8, label %30
8: ; preds = %1
%9 = load float*, float** %2
%10 = getelementptr inbounds float, float* %9, i64 0
%11 = load float, float* %10
%12 = load float, float* %3
%13 = fdiv float %11, %12
%14 = load float*, float** %2
%15 = getelementptr inbounds float, float* %14, i64 0
store float %13, float* %15
%16 = load float*, float** %2
%17 = getelementptr inbounds float, float* %16, i64 1
%18 = load float, float* %17
%19 = load float, float* %3
%20 = fdiv float %18, %19
%21 = load float*, float** %2
%22 = getelementptr inbounds float, float* %21, i64 1
store float %20, float* %22
%23 = load float*, float** %2
%24 = getelementptr inbounds float, float* %23, i64 2
%25 = load float, float* %24
%26 = load float, float* %3
%27 = fdiv float %25, %26
%28 = load float*, float** %2
%29 = getelementptr inbounds float, float* %28, i64 2
store float %27, float* %29
br label %30
30: ; preds = %8, %1
ret void
}

LLVM IR (-O2):
define void @NormalizeVector(float* %0) {
%2 = tail call float @Magnitude(float* %0)
%3 = fcmp une float %2, 0.000000e+00
br i1 %3, label %4, label %13
4: ; preds = %1
%5 = load float, float* %0
%6 = fdiv float %5, %2
store float %6, float* %0
%7 = getelementptr inbounds float, float* %0, i64 1
%8 = load float, float* %7
%9 = fdiv float %8, %2
store float %9, float* %7
%10 = getelementptr inbounds float, float* %0, i64 2
%11 = load float, float* %10
%12 = fdiv float %11, %2
store float %12, float* %10
br label %13
13: ; preds = %4, %1
ret void
}