double distance_dim2(x1, x2)
double x1[2];
double x2[2];
{
  double seperation;
  int i;
  for (i = 0, seperation = 0.0; i < 2; i++) {
    seperation += (x1[i] - x2[i]) * (x1[i] - x2[i]);
  }
  return (seperation);
}


x86 assembly (clang, -O0):
<distance_dim2>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    1179 <distance_dim2+0x79>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    111b <distance_dim2+0x1b>
movsd  -0x18(%rbp),%xmm0
pop    %rbp
ret

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

LLVM IR (-O0):
define double @distance_dim2(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca double
%6 = alloca i32
store double* %0, double** %3
store double* %1, double** %4
store i32 0, i32* %6
store double 0.000000e+00, double* %5
br label %7
7: ; preds = %35, %2
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %38
10: ; preds = %7
%11 = load double*, double** %3
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds double, double* %11, i64 %13
%15 = load double, double* %14
%16 = load double*, double** %4
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %16, i64 %18
%20 = load double, double* %19
%21 = fsub double %15, %20
%22 = load double*, double** %3
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = load double, double* %25
%27 = load double*, double** %4
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %27, i64 %29
%31 = load double, double* %30
%32 = fsub double %26, %31
%33 = load double, double* %5
%34 = call double @llvm.fmuladd.f64(double %21, double %32, double %33)
store double %34, double* %5
br label %35
35: ; preds = %10
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %7
38: ; preds = %7
%39 = load double, double* %5
ret double %39
}

LLVM IR (-O2):
define double @distance_dim2(double* nocapture %0, double* nocapture %1) {
%3 = load double, double* %0
%4 = load double, double* %1
%5 = fsub double %3, %4
%6 = tail call double @llvm.fmuladd.f64(double %5, double %5, double 0.000000e+00)
%7 = getelementptr inbounds double, double* %0, i64 1
%8 = load double, double* %7
%9 = getelementptr inbounds double, double* %1, i64 1
%10 = load double, double* %9
%11 = fsub double %8, %10
%12 = tail call double @llvm.fmuladd.f64(double %11, double %11, double %6)
ret double %12
}