#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 d(int i, int j, double x[], double y[]) {
  double dx = x[i] - x[j];
  double dy = y[i] - y[j];
  return sqrt(dx * dx + dy * dy);
}


x86 assembly (clang, -O0):
<d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<d>:
movslq %edi,%rax
movsd  (%rdx,%rax,8),%xmm0
movslq %esi,%rsi
subsd  (%rdx,%rsi,8),%xmm0
movsd  (%rcx,%rax,8),%xmm1
subsd  (%rcx,%rsi,8),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1145 <d+0x35>
sqrtsd %xmm0,%xmm0
ret
jmp    1030 <sqrt@plt>

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

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