float *normalize(float *v) {
  static float vv[3];
  float len;
  len = v[0] * v[0] + v[1] * v[1] + v[2] * v[2];
  vv[0] = v[0] / len;
  vv[1] = v[1] / len;
  vv[2] = v[2] / len;
  return vv;
}


x86 assembly (clang, -O0):
<normalize>:
push   %rbp
mov    %rsp,%rbp
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)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
divss  -0xc(%rbp),%xmm0
movss  %xmm0,0x2ebe(%rip)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
divss  -0xc(%rbp),%xmm0
movss  %xmm0,0x2eac(%rip)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
divss  -0xc(%rbp),%xmm0
movss  %xmm0,0x2e9a(%rip)
lea    0x2e8b(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalize>:
movss  (%rdi),%xmm0
movss  0x4(%rdi),%xmm1
movaps %xmm1,%xmm2
mulss  %xmm1,%xmm2
movaps %xmm0,%xmm3
mulss  %xmm0,%xmm3
addss  %xmm2,%xmm3
movss  0x8(%rdi),%xmm2
movaps %xmm2,%xmm4
mulss  %xmm2,%xmm4
addss  %xmm3,%xmm4
divss  %xmm4,%xmm0
movss  %xmm0,0x2eed(%rip)
lea    0x2ee6(%rip),%rax
divss  %xmm4,%xmm1
movss  %xmm1,0x2ede(%rip)
divss  %xmm4,%xmm2
movss  %xmm2,0x2ed6(%rip)
ret

LLVM IR (-O0):
@normalize.vv = internal global [3 x float] zeroinitializer
define float* @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** %2
%26 = getelementptr inbounds float, float* %25, i64 0
%27 = load float, float* %26
%28 = load float, float* %3
%29 = fdiv float %27, %28
store float %29, float* getelementptr inbounds ([3 x float], [3 x float]* @normalize.vv, i64 0, i64 0)
%30 = load float*, float** %2
%31 = getelementptr inbounds float, float* %30, i64 1
%32 = load float, float* %31
%33 = load float, float* %3
%34 = fdiv float %32, %33
store float %34, float* getelementptr inbounds ([3 x float], [3 x float]* @normalize.vv, i64 0, i64 1)
%35 = load float*, float** %2
%36 = getelementptr inbounds float, float* %35, i64 2
%37 = load float, float* %36
%38 = load float, float* %3
%39 = fdiv float %37, %38
store float %39, float* getelementptr inbounds ([3 x float], [3 x float]* @normalize.vv, i64 0, i64 2)
ret float* getelementptr inbounds ([3 x float], [3 x float]* @normalize.vv, i64 0, i64 0)
}

LLVM IR (-O2):
@normalize.vv = internal global [3 x float] zeroinitializer
define float* @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 = fdiv float %2, %9
store float %10, float* getelementptr inbounds ([3 x float], [3 x float]* @normalize.vv, i64 0, i64 0)
%11 = fdiv float %4, %9
store float %11, float* getelementptr inbounds ([3 x float], [3 x float]* @normalize.vv, i64 0, i64 1)
%12 = fdiv float %8, %9
store float %12, float* getelementptr inbounds ([3 x float], [3 x float]* @normalize.vv, i64 0, i64 2)
ret float* getelementptr inbounds ([3 x float], [3 x float]* @normalize.vv, i64 0, i64 0)
}