#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 */
int /*<<< orphan*/ TM_Forword(double, double, double *, double *);
double sqrt(double);
double GetDistance(double dLat1, double dLon1, double dLat2, double dLon2) {
  double dX1, dY1;
  TM_Forword(dLon1, dLat1, &dX1, &dY1);
  double dX2, dY2;
  TM_Forword(dLon2, dLat2, &dX2, &dY2);
  double deltaX = (dX1 - dX2);
  double deltaY = (dY1 - dY2);
  double dist = sqrt((deltaX * deltaX) + (deltaY * deltaY));
  return dist;
}


x86 assembly (clang, -O0):
<GetDistance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <TM_Forword@plt>
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    -0x38(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <TM_Forword@plt>
movsd  -0x28(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetDistance>:
sub    $0x38,%rsp
movsd  %xmm3,0x8(%rsp)
movsd  %xmm2,0x10(%rsp)
movaps %xmm0,%xmm2
lea    0x30(%rsp),%rdi
lea    0x28(%rsp),%rsi
movaps %xmm1,%xmm0
movaps %xmm2,%xmm1
call   1030 <TM_Forword@plt>
lea    0x20(%rsp),%rdi
lea    0x18(%rsp),%rsi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1030 <TM_Forword@plt>
movsd  0x30(%rsp),%xmm0
subsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
subsd  0x18(%rsp),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     119a <GetDistance+0x7a>
sqrtsd %xmm0,%xmm0
add    $0x38,%rsp
ret
call   1040 <sqrt@plt>
add    $0x38,%rsp
ret

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

LLVM IR (-O2):
define double @GetDistance(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = bitcast double* %5 to i8*
%10 = bitcast double* %6 to i8*
%11 = call i32 @TM_Forword(double %1, double %0, double* %5, double* %6)
%12 = bitcast double* %7 to i8*
%13 = bitcast double* %8 to i8*
%14 = call i32 @TM_Forword(double %3, double %2, double* %7, double* %8)
%15 = load double, double* %5
%16 = load double, double* %7
%17 = fsub double %15, %16
%18 = load double, double* %6
%19 = load double, double* %8
%20 = fsub double %18, %19
%21 = fmul double %20, %20
%22 = call double @llvm.fmuladd.f64(double %17, double %17, double %21)
%23 = call double @sqrt(double %22)
ret double %23
}