#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double sqrt(double);
double distance(double *A, double *B) {
  double x, y, z;
  x = A[0] - B[0];
  y = A[1] - B[1];
  z = A[2] - B[2];
  return sqrt(x * x + y * y + z * z);
}


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

x86 assembly (clang, -O2):
<distance>:
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
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     114f <distance+0x3f>
sqrtsd %xmm0,%xmm0
ret
jmp    1030 <sqrt@plt>

LLVM IR (-O0):
define double @distance(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double* %0, double** %3
store double* %1, double** %4
%8 = load double*, double** %3
%9 = getelementptr inbounds double, double* %8, i64 0
%10 = load double, double* %9
%11 = load double*, double** %4
%12 = getelementptr inbounds double, double* %11, i64 0
%13 = load double, double* %12
%14 = fsub double %10, %13
store double %14, double* %5
%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
store double %21, double* %6
%22 = load double*, double** %3
%23 = getelementptr inbounds double, double* %22, i64 2
%24 = load double, double* %23
%25 = load double*, double** %4
%26 = getelementptr inbounds double, double* %25, i64 2
%27 = load double, double* %26
%28 = fsub double %24, %27
store double %28, double* %7
%29 = load double, double* %5
%30 = load double, double* %5
%31 = load double, double* %6
%32 = load double, double* %6
%33 = fmul double %31, %32
%34 = call double @llvm.fmuladd.f64(double %29, double %30, double %33)
%35 = load double, double* %7
%36 = load double, double* %7
%37 = call double @llvm.fmuladd.f64(double %35, double %36, double %34)
%38 = call double @sqrt(double %37)
ret double %38
}

LLVM IR (-O2):
define double @distance(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)
%19 = tail call double @sqrt(double %18)
ret double %19
}