void MakeNormal(float *outX, float *outY, float *outZ, float inX, float inY,
                float inZ, float refX, float refY, float refZ) {
  float vvX, vvY, vvZ;
  float mod;
  mod = (float)sqrt((inX) * (inX) + (inY) * (inY) + (inZ) * (inZ));
  UnitVectorVV(&vvX, &vvY, &vvZ, refX, refY, refZ, inX, inY, inZ);
  UnitVectorVV(outX, outY, outZ, vvX, vvY, vvZ, refX, refY, refZ);
  *outX = (*outX) * mod;
  *outY = (*outY) * mod;
  *outZ = (*outZ) * mod;
}


x86 assembly (clang, -O0):
<MakeNormal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movss  %xmm0,-0x1c(%rbp)
movss  %xmm1,-0x20(%rbp)
movss  %xmm2,-0x24(%rbp)
movss  %xmm3,-0x28(%rbp)
movss  %xmm4,-0x2c(%rbp)
movss  %xmm5,-0x30(%rbp)
movss  -0x1c(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm2
movss  -0x20(%rbp),%xmm0
mulss  -0x20(%rbp),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x24(%rbp),%xmm0
movss  -0x24(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
call   1040 <sqrt@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x40(%rbp)
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x2c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x30(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
movss  -0x1c(%rbp),%xmm3
cvtss2sd %xmm3,%xmm3
movss  -0x20(%rbp),%xmm4
cvtss2sd %xmm4,%xmm4
movss  -0x24(%rbp),%xmm5
cvtss2sd %xmm5,%xmm5
lea    -0x34(%rbp),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
mov    $0x6,%al
call   1030 <UnitVectorVV@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
movss  -0x34(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x38(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x3c(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
movss  -0x28(%rbp),%xmm3
cvtss2sd %xmm3,%xmm3
movss  -0x2c(%rbp),%xmm4
cvtss2sd %xmm4,%xmm4
movss  -0x30(%rbp),%xmm5
cvtss2sd %xmm5,%xmm5
mov    $0x6,%al
call   1030 <UnitVectorVV@plt>
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mulss  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
mulss  -0x40(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
mulss  -0x40(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MakeNormal>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
movaps %xmm0,%xmm8
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movaps %xmm1,%xmm0
mulss  %xmm1,%xmm0
movaps %xmm8,%xmm6
mulss  %xmm8,%xmm6
addss  %xmm0,%xmm6
movaps %xmm2,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm6,%xmm0
xorps  %xmm6,%xmm6
ucomiss %xmm6,%xmm0
jb     1163 <MakeNormal+0x43>
sqrtss %xmm0,%xmm0
jmp    11b2 <MakeNormal+0x92>
movss  %xmm2,0x20(%rsp)
movss  %xmm5,0x18(%rsp)
movss  %xmm1,0x10(%rsp)
movss  %xmm4,0x30(%rsp)
movss  %xmm8,0x2c(%rsp)
movss  %xmm3,0x28(%rsp)
call   1040 <sqrtf@plt>
movss  0x28(%rsp),%xmm3
movss  0x2c(%rsp),%xmm8
movss  0x30(%rsp),%xmm4
movss  0x10(%rsp),%xmm1
movss  0x18(%rsp),%xmm5
movss  0x20(%rsp),%xmm2
movss  %xmm0,0xc(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
movsd  %xmm0,0x20(%rsp)
xorps  %xmm6,%xmm6
cvtss2sd %xmm4,%xmm6
movsd  %xmm6,0x18(%rsp)
cvtss2sd %xmm5,%xmm7
movsd  %xmm7,0x10(%rsp)
xorps  %xmm3,%xmm3
cvtss2sd %xmm8,%xmm3
xorps  %xmm4,%xmm4
cvtss2sd %xmm1,%xmm4
xorps  %xmm5,%xmm5
cvtss2sd %xmm2,%xmm5
lea    0x3c(%rsp),%rdi
lea    0x38(%rsp),%rsi
lea    0x34(%rsp),%rdx
movaps %xmm6,%xmm1
movaps %xmm7,%xmm2
mov    $0x6,%al
call   1030 <UnitVectorVV@plt>
movss  0x3c(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x38(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  0x34(%rsp),%xmm2
cvtss2sd %xmm2,%xmm2
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
movsd  0x20(%rsp),%xmm3
movsd  0x18(%rsp),%xmm4
movsd  0x10(%rsp),%xmm5
mov    $0x6,%al
call   1030 <UnitVectorVV@plt>
movss  (%rbx),%xmm0
movss  0xc(%rsp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,(%rbx)
movss  (%r15),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,(%r15)
mulss  (%r14),%xmm1
movss  %xmm1,(%r14)
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @MakeNormal(float* %0, float* %1, float* %2, float %3, float %4, float %5, float %6, float %7, float %8) {
%10 = alloca float*
%11 = alloca float*
%12 = alloca float*
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca float
%21 = alloca float
%22 = alloca float
store float* %0, float** %10
store float* %1, float** %11
store float* %2, float** %12
store float %3, float* %13
store float %4, float* %14
store float %5, float* %15
store float %6, float* %16
store float %7, float* %17
store float %8, float* %18
%23 = load float, float* %13
%24 = load float, float* %13
%25 = load float, float* %14
%26 = load float, float* %14
%27 = fmul float %25, %26
%28 = call float @llvm.fmuladd.f32(float %23, float %24, float %27)
%29 = load float, float* %15
%30 = load float, float* %15
%31 = call float @llvm.fmuladd.f32(float %29, float %30, float %28)
%32 = fpext float %31 to double
%33 = call double @sqrt(double %32)
%34 = fptrunc double %33 to float
store float %34, float* %22
%35 = load float, float* %16
%36 = fpext float %35 to double
%37 = load float, float* %17
%38 = fpext float %37 to double
%39 = load float, float* %18
%40 = fpext float %39 to double
%41 = load float, float* %13
%42 = fpext float %41 to double
%43 = load float, float* %14
%44 = fpext float %43 to double
%45 = load float, float* %15
%46 = fpext float %45 to double
%47 = call i32 (float*, float*, float*, double, double, double, double, double, double, ...) bitcast (i32 (...)* @UnitVectorVV to i32 (float*, float*, float*, double, double, double, double, double, double, ...)*)(float* %19, float* %20, float* %21, double %36, double %38, double %40, double %42, double %44, double %46)
%48 = load float*, float** %10
%49 = load float*, float** %11
%50 = load float*, float** %12
%51 = load float, float* %19
%52 = fpext float %51 to double
%53 = load float, float* %20
%54 = fpext float %53 to double
%55 = load float, float* %21
%56 = fpext float %55 to double
%57 = load float, float* %16
%58 = fpext float %57 to double
%59 = load float, float* %17
%60 = fpext float %59 to double
%61 = load float, float* %18
%62 = fpext float %61 to double
%63 = call i32 (float*, float*, float*, double, double, double, double, double, double, ...) bitcast (i32 (...)* @UnitVectorVV to i32 (float*, float*, float*, double, double, double, double, double, double, ...)*)(float* %48, float* %49, float* %50, double %52, double %54, double %56, double %58, double %60, double %62)
%64 = load float*, float** %10
%65 = load float, float* %64
%66 = load float, float* %22
%67 = fmul float %65, %66
%68 = load float*, float** %10
store float %67, float* %68
%69 = load float*, float** %11
%70 = load float, float* %69
%71 = load float, float* %22
%72 = fmul float %70, %71
%73 = load float*, float** %11
store float %72, float* %73
%74 = load float*, float** %12
%75 = load float, float* %74
%76 = load float, float* %22
%77 = fmul float %75, %76
%78 = load float*, float** %12
store float %77, float* %78
ret void
}

LLVM IR (-O2):
define void @MakeNormal(float* %0, float* %1, float* %2, float %3, float %4, float %5, float %6, float %7, float %8) {
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = bitcast float* %10 to i8*
%14 = bitcast float* %11 to i8*
%15 = bitcast float* %12 to i8*
%16 = fmul float %4, %4
%17 = tail call float @llvm.fmuladd.f32(float %3, float %3, float %16)
%18 = tail call float @llvm.fmuladd.f32(float %5, float %5, float %17)
%19 = tail call float @sqrtf(float %18)
%20 = fpext float %6 to double
%21 = fpext float %7 to double
%22 = fpext float %8 to double
%23 = fpext float %3 to double
%24 = fpext float %4 to double
%25 = fpext float %5 to double
%26 = call i32 (float*, float*, float*, double, double, double, double, double, double, ...) bitcast (i32 (...)* @UnitVectorVV to i32 (float*, float*, float*, double, double, double, double, double, double, ...)*)(float* %10, float* %11, float* %12, double %20, double %21, double %22, double %23, double %24, double %25)
%27 = load float, float* %10
%28 = fpext float %27 to double
%29 = load float, float* %11
%30 = fpext float %29 to double
%31 = load float, float* %12
%32 = fpext float %31 to double
%33 = call i32 (float*, float*, float*, double, double, double, double, double, double, ...) bitcast (i32 (...)* @UnitVectorVV to i32 (float*, float*, float*, double, double, double, double, double, double, ...)*)(float* %0, float* %1, float* %2, double %28, double %30, double %32, double %20, double %21, double %22)
%34 = load float, float* %0
%35 = fmul float %19, %34
store float %35, float* %0
%36 = load float, float* %1
%37 = fmul float %19, %36
store float %37, float* %1
%38 = load float, float* %2
%39 = fmul float %19, %38
store float %39, float* %2
ret void
}