#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 calc_distance(int a[2], int b[2]) {
  double d = 0;
  d = ((double)b[0] - (double)a[0]) * ((double)b[0] - (double)a[0]) +
      ((double)b[1] - (double)a[1]) * ((double)b[1] - (double)a[1]);
  return sqrt(d);
}


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

x86 assembly (clang, -O2):
<calc_distance>:
cvtsi2sdl (%rsi),%xmm0
cvtsi2sdl (%rdi),%xmm1
cvtsi2sdl 0x4(%rsi),%xmm2
cvtsi2sdl 0x4(%rdi),%xmm3
subsd  %xmm1,%xmm0
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm2
mulsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1145 <calc_distance+0x35>
sqrtsd %xmm0,%xmm0
ret
jmp    1030 <sqrt@plt>

LLVM IR (-O0):
define double @calc_distance(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca double
store i32* %0, i32** %3
store i32* %1, i32** %4
store double 0.000000e+00, double* %5
%6 = load i32*, i32** %4
%7 = getelementptr inbounds i32, i32* %6, i64 0
%8 = load i32, i32* %7
%9 = sitofp i32 %8 to double
%10 = load i32*, i32** %3
%11 = getelementptr inbounds i32, i32* %10, i64 0
%12 = load i32, i32* %11
%13 = sitofp i32 %12 to double
%14 = fsub double %9, %13
%15 = load i32*, i32** %4
%16 = getelementptr inbounds i32, i32* %15, i64 0
%17 = load i32, i32* %16
%18 = sitofp i32 %17 to double
%19 = load i32*, i32** %3
%20 = getelementptr inbounds i32, i32* %19, i64 0
%21 = load i32, i32* %20
%22 = sitofp i32 %21 to double
%23 = fsub double %18, %22
%24 = load i32*, i32** %4
%25 = getelementptr inbounds i32, i32* %24, i64 1
%26 = load i32, i32* %25
%27 = sitofp i32 %26 to double
%28 = load i32*, i32** %3
%29 = getelementptr inbounds i32, i32* %28, i64 1
%30 = load i32, i32* %29
%31 = sitofp i32 %30 to double
%32 = fsub double %27, %31
%33 = load i32*, i32** %4
%34 = getelementptr inbounds i32, i32* %33, i64 1
%35 = load i32, i32* %34
%36 = sitofp i32 %35 to double
%37 = load i32*, i32** %3
%38 = getelementptr inbounds i32, i32* %37, i64 1
%39 = load i32, i32* %38
%40 = sitofp i32 %39 to double
%41 = fsub double %36, %40
%42 = fmul double %32, %41
%43 = call double @llvm.fmuladd.f64(double %14, double %23, double %42)
store double %43, double* %5
%44 = load double, double* %5
%45 = call double @sqrt(double %44)
ret double %45
}

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