double distanceSquared(double a[3], double b[3]) {
  double dis_components[3] = {0.0, 0.0, 0.0};
  dis_components[0] = (a[0] - b[0]);
  dis_components[1] = (a[1] - b[1]);
  dis_components[2] = (a[2] - b[2]);
  return ((dis_components[0]) * (dis_components[0]) +
          (dis_components[1]) * (dis_components[1]) +
          (dis_components[2]) * (dis_components[2]));
}


x86 assembly (clang, -O0):
<distanceSquared>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<distanceSquared>:
movsd  (%rdi),%xmm1
movsd  0x8(%rdi),%xmm2
subsd  (%rsi),%xmm1
subsd  0x8(%rsi),%xmm2
movsd  0x10(%rdi),%xmm0
subsd  0x10(%rsi),%xmm0
mulsd  %xmm2,%xmm2
mulsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
ret

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

LLVM IR (-O2):
define double @distanceSquared(double* nocapture %0, double* nocapture %1) {
%3 = load double, double* %0
%4 = load double, double* %1
%5 = fsub double %3, %4
%6 = getelementptr inbounds double, double* %0, i64 1
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %1, i64 1
%9 = load double, double* %8
%10 = fsub double %7, %9
%11 = getelementptr inbounds double, double* %0, i64 2
%12 = load double, double* %11
%13 = getelementptr inbounds double, double* %1, i64 2
%14 = load double, double* %13
%15 = fsub double %12, %14
%16 = fmul double %10, %10
%17 = tail call double @llvm.fmuladd.f64(double %5, double %5, double %16)
%18 = tail call double @llvm.fmuladd.f64(double %15, double %15, double %17)
ret double %18
}