void normalize(double a[3]) {
  double t;
  t = ((a[0]) * (a[0])) + ((a[1]) * (a[1])) + ((a[2]) * (a[2]));
  t = sqrt(t);
  a[0] = a[0] / t;
  a[2] = a[2] / t;
  a[1] = a[1] / t;
}


x86 assembly (clang, -O0):
<normalize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
divsd  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
divsd  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
divsd  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalize>:
push   %rbx
mov    %rdi,%rbx
movsd  (%rdi),%xmm1
movsd  0x8(%rdi),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x10(%rdi),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1146 <normalize+0x36>
sqrtsd %xmm0,%xmm0
jmp    114b <normalize+0x3b>
call   1030 <sqrt@plt>
movsd  0x10(%rbx),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rbx)
movupd (%rbx),%xmm1
unpcklpd %xmm0,%xmm0
divpd  %xmm0,%xmm1
movupd %xmm1,(%rbx)
pop    %rbx
ret

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

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