#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 sqrtf(float);
void Normalize(float v[3]) {
  float len;
  len = v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
  if (len != 0.0) {
    len = sqrtf(len);
    v[0] /= len;
    v[1] /= len;
    v[2] /= len;
  }
}


x86 assembly (clang, -O0):
<Normalize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x8(%rbp),%rax
mulss  0x4(%rax),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1186 <Normalize+0x76>
jp     1186 <Normalize+0x76>
jmp    11d8 <Normalize+0xc8>
movss  -0xc(%rbp),%xmm0
call   1030 <sqrtf@plt>
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)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Normalize>:
push   %rbx
movss  (%rdi),%xmm1
movss  0x4(%rdi),%xmm0
mulss  %xmm0,%xmm0
mulss  %xmm1,%xmm1
addss  %xmm0,%xmm1
movss  0x8(%rdi),%xmm0
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    113d <Normalize+0x2d>
jnp    1175 <Normalize+0x65>
mov    %rdi,%rbx
jb     1148 <Normalize+0x38>
sqrtss %xmm0,%xmm0
jmp    114d <Normalize+0x3d>
call   1030 <sqrtf@plt>
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 @Normalize(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)
store float %24, float* %3
%25 = load float, float* %3
%26 = fpext float %25 to double
%27 = fcmp une double %26, 0.000000e+00
br i1 %27, label %28, label %46
28: ; preds = %1
%29 = load float, float* %3
%30 = call float @sqrtf(float %29)
store float %30, float* %3
%31 = load float, float* %3
%32 = load float*, float** %2
%33 = getelementptr inbounds float, float* %32, i64 0
%34 = load float, float* %33
%35 = fdiv float %34, %31
store float %35, float* %33
%36 = load float, float* %3
%37 = load float*, float** %2
%38 = getelementptr inbounds float, float* %37, i64 1
%39 = load float, float* %38
%40 = fdiv float %39, %36
store float %40, float* %38
%41 = load float, float* %3
%42 = load float*, float** %2
%43 = getelementptr inbounds float, float* %42, i64 2
%44 = load float, float* %43
%45 = fdiv float %44, %41
store float %45, float* %43
br label %46
46: ; preds = %28, %1
ret void
}

LLVM IR (-O2):
define void @Normalize(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 = fcmp une float %9, 0.000000e+00
br i1 %10, label %11, label %19
11: ; preds = %1
%12 = tail call float @sqrtf(float %9)
%13 = load float, float* %0
%14 = fdiv float %13, %12
store float %14, float* %0
%15 = load float, float* %3
%16 = fdiv float %15, %12
store float %16, float* %3
%17 = load float, float* %7
%18 = fdiv float %17, %12
store float %18, float* %7
br label %19
19: ; preds = %11, %1
ret void
}