#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 cart_2d(double *x1, double *x2) {
  double out;
  double a;
  a = *(x2++) - *(x1++);
  out = a * a;
  a = *(x2++) - *(x1++);
  return sqrt(out + a * a);
}


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

x86 assembly (clang, -O2):
<cart_2d>:
movsd  (%rsi),%xmm1
movsd  0x8(%rsi),%xmm0
subsd  (%rdi),%xmm1
mulsd  %xmm1,%xmm1
subsd  0x8(%rdi),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     113d <cart_2d+0x2d>
sqrtsd %xmm0,%xmm0
ret
jmp    1030 <sqrt@plt>

LLVM IR (-O0):
define double @cart_2d(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca double
%6 = alloca double
store double* %0, double** %3
store double* %1, double** %4
%7 = load double*, double** %4
%8 = getelementptr inbounds double, double* %7, i32 1
store double* %8, double** %4
%9 = load double, double* %7
%10 = load double*, double** %3
%11 = getelementptr inbounds double, double* %10, i32 1
store double* %11, double** %3
%12 = load double, double* %10
%13 = fsub double %9, %12
store double %13, double* %6
%14 = load double, double* %6
%15 = load double, double* %6
%16 = fmul double %14, %15
store double %16, double* %5
%17 = load double*, double** %4
%18 = getelementptr inbounds double, double* %17, i32 1
store double* %18, double** %4
%19 = load double, double* %17
%20 = load double*, double** %3
%21 = getelementptr inbounds double, double* %20, i32 1
store double* %21, double** %3
%22 = load double, double* %20
%23 = fsub double %19, %22
store double %23, double* %6
%24 = load double, double* %5
%25 = load double, double* %6
%26 = load double, double* %6
%27 = call double @llvm.fmuladd.f64(double %25, double %26, double %24)
%28 = call double @sqrt(double %27)
ret double %28
}

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