#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 dist2(double, double, double, double);
double dist2i(double *vertex, int v1, int v2) {
  return dist2(vertex[2 * v1 + 0], vertex[2 * v1 + 1], vertex[2 * v2 + 0],
               vertex[2 * v2 + 1]);
}


x86 assembly (clang, -O0):
<dist2i>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x1,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm3
call   1030 <dist2@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dist2i>:
lea    (%rsi,%rsi,1),%eax
cltq
movsd  (%rdi,%rax,8),%xmm0
lea    0x1(%rsi,%rsi,1),%eax
cltq
movsd  (%rdi,%rax,8),%xmm1
lea    (%rdx,%rdx,1),%eax
cltq
movsd  (%rdi,%rax,8),%xmm2
lea    (%rdx,%rdx,1),%eax
add    $0x1,%eax
cltq
movsd  (%rdi,%rax,8),%xmm3
jmp    1030 <dist2@plt>

LLVM IR (-O0):
define double @dist2i(double* %0, i32 %1, i32 %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
store double* %0, double** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load double*, double** %4
%8 = load i32, i32* %5
%9 = mul nsw i32 2, %8
%10 = add nsw i32 %9, 0
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds double, double* %7, i64 %11
%13 = load double, double* %12
%14 = load double*, double** %4
%15 = load i32, i32* %5
%16 = mul nsw i32 2, %15
%17 = add nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %14, i64 %18
%20 = load double, double* %19
%21 = load double*, double** %4
%22 = load i32, i32* %6
%23 = mul nsw i32 2, %22
%24 = add nsw i32 %23, 0
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %21, i64 %25
%27 = load double, double* %26
%28 = load double*, double** %4
%29 = load i32, i32* %6
%30 = mul nsw i32 2, %29
%31 = add nsw i32 %30, 1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %28, i64 %32
%34 = load double, double* %33
%35 = call double @dist2(double %13, double %20, double %27, double %34)
ret double %35
}

LLVM IR (-O2):
define double @dist2i(double* nocapture %0, i32 %1, i32 %2) {
%4 = shl nsw i32 %1, 1
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds double, double* %0, i64 %5
%7 = load double, double* %6
%8 = or i32 %4, 1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds double, double* %0, i64 %9
%11 = load double, double* %10
%12 = shl nsw i32 %2, 1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds double, double* %0, i64 %13
%15 = load double, double* %14
%16 = or i32 %12, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds double, double* %0, i64 %17
%19 = load double, double* %18
%20 = tail call double @dist2(double %7, double %11, double %15, double %19)
ret double %20
}