#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 */
scalar_t__ sqrt(double);
int get_euclidean_distance(double *x_coordinates, double *y_coordinates,
                           int p1_index, int p2_index) {
  double t1 = x_coordinates[p1_index] - x_coordinates[p2_index];
  double t2 = y_coordinates[p1_index] - y_coordinates[p2_index];
  return (int)(sqrt(t1 * t1 + t2 * t2) + 0.5);
}


x86 assembly (clang, -O0):
<get_euclidean_distance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%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>
cvtsi2sd %rax,%xmm0
movsd  0xe6e(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_euclidean_distance>:
push   %rax
movslq %edx,%rax
movsd  (%rdi,%rax,8),%xmm0
movslq %ecx,%rcx
subsd  (%rdi,%rcx,8),%xmm0
movsd  (%rsi,%rax,8),%xmm1
subsd  (%rsi,%rcx,8),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xeb4(%rip),%xmm0
cvttsd2si %xmm0,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @get_euclidean_distance(double* %0, double* %1, i32 %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load double*, double** %5
%12 = load i32, i32* %7
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds double, double* %11, i64 %13
%15 = load double, double* %14
%16 = load double*, double** %5
%17 = load i32, i32* %8
%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** %6
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = load double, double* %25
%27 = load double*, double** %6
%28 = load i32, i32* %8
%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 i64 @sqrt(double %38)
%40 = sitofp i64 %39 to double
%41 = fadd double %40, 5.000000e-01
%42 = fptosi double %41 to i32
ret i32 %42
}

LLVM IR (-O2):
define i32 @get_euclidean_distance(double* nocapture %0, double* nocapture %1, i32 %2, i32 %3) {
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds double, double* %0, i64 %5
%7 = load double, double* %6
%8 = sext i32 %3 to i64
%9 = getelementptr inbounds double, double* %0, i64 %8
%10 = load double, double* %9
%11 = fsub double %7, %10
%12 = getelementptr inbounds double, double* %1, i64 %5
%13 = load double, double* %12
%14 = getelementptr inbounds double, double* %1, 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 i64 @sqrt(double %18)
%20 = sitofp i64 %19 to double
%21 = fadd double %20, 5.000000e-01
%22 = fptosi double %21 to i32
ret i32 %22
}