#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 GCDistance(double, double, double, double);
double sqrt(double);
double Dist2D_LocSum(double x1, double x2, double y1, double y2, int latlon) {
  if (latlon) {
    return (GCDistance(y1, x1, y2, x2));
  } else {
    double dx, dy;
    dx = x1 - x2;
    dy = y1 - y2;
    return (sqrt(dx * dx + dy * dy));
  }
}


x86 assembly (clang, -O0):
<Dist2D_LocSum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
mov    %edi,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     116c <Dist2D_LocSum+0x4c>
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
call   1030 <GCDistance@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    11b0 <Dist2D_LocSum+0x90>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Dist2D_LocSum>:
movapd %xmm1,%xmm4
movapd %xmm0,%xmm1
test   %edi,%edi
je     113b <Dist2D_LocSum+0x1b>
movaps %xmm2,%xmm0
movaps %xmm3,%xmm2
movapd %xmm4,%xmm3
jmp    1030 <GCDistance@plt>
subsd  %xmm4,%xmm1
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm2
mulsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     1161 <Dist2D_LocSum+0x41>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
ret
movapd %xmm1,%xmm0
jmp    1040 <sqrt@plt>

LLVM IR (-O0):
define double @Dist2D_LocSum(double %0, double %1, double %2, double %3, i32 %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca double
%13 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store i32 %4, i32* %11
%14 = load i32, i32* %11
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %5
%17 = load double, double* %9
%18 = load double, double* %7
%19 = load double, double* %10
%20 = load double, double* %8
%21 = call double @GCDistance(double %17, double %18, double %19, double %20)
store double %21, double* %6
br label %36
22: ; preds = %5
%23 = load double, double* %7
%24 = load double, double* %8
%25 = fsub double %23, %24
store double %25, double* %12
%26 = load double, double* %9
%27 = load double, double* %10
%28 = fsub double %26, %27
store double %28, double* %13
%29 = load double, double* %12
%30 = load double, double* %12
%31 = load double, double* %13
%32 = load double, double* %13
%33 = fmul double %31, %32
%34 = call double @llvm.fmuladd.f64(double %29, double %30, double %33)
%35 = call double @sqrt(double %34)
store double %35, double* %6
br label %36
36: ; preds = %22, %16
%37 = load double, double* %6
ret double %37
}

LLVM IR (-O2):
define double @Dist2D_LocSum(double %0, double %1, double %2, double %3, i32 %4) {
%6 = icmp eq i32 %4, 0
br i1 %6, label %9, label %7
7: ; preds = %5
%8 = tail call double @GCDistance(double %2, double %0, double %3, double %1)
br label %15
9: ; preds = %5
%10 = fsub double %0, %1
%11 = fsub double %2, %3
%12 = fmul double %11, %11
%13 = tail call double @llvm.fmuladd.f64(double %10, double %10, double %12)
%14 = tail call double @sqrt(double %13)
br label %15
15: ; preds = %9, %7
%16 = phi double [ %8, %7 ], [ %14, %9 ]
ret double %16
}