#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 asin(int /*<<< orphan*/);
double cos(double);
double degreesToRadians(double);
double sin(double);
int /*<<< orphan*/ sqrt(double);
void getDistanceEx(double lat1, double lng1, double lat2, double lng2,
                   double *retValue) {
  double dLat, dLon;
  double earth_radius = 6373;
  double a, c, d;
  dLat = degreesToRadians(lat2 - lat1);
  dLon = degreesToRadians(lng2 - lng1);
  a = sin(dLat / 2) * sin(dLat / 2) + cos(degreesToRadians(lat1)) *
                                          cos(degreesToRadians(lat2)) *
                                          sin(dLon / 2) * sin(dLon / 2);
  c = 2 * asin(sqrt(a));
  *retValue = earth_radius * c;
  *retValue *= 1000.0;
}


x86 assembly (clang, -O0):
<getDistanceEx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
movsd  0xe95(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
call   1050 <degreesToRadians@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1050 <degreesToRadians@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe53(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe38(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <degreesToRadians@plt>
call   1060 <cos@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <degreesToRadians@plt>
call   1060 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xde9(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xdc2(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sin@plt>
movsd  -0x70(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1070 <sqrt@plt>
mov    %eax,%edi
call   1040 <asin@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  0xd53(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getDistanceEx>:
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
movsd  %xmm3,0x18(%rsp)
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x28(%rsp)
movapd %xmm0,%xmm1
movsd  %xmm0,0x20(%rsp)
movapd %xmm2,%xmm0
subsd  %xmm1,%xmm0
call   1050 <degreesToRadians@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
subsd  0x28(%rsp),%xmm0
call   1050 <degreesToRadians@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0xe54(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1030 <sin@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x20(%rsp),%xmm0
call   1050 <degreesToRadians@plt>
call   1060 <cos@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <degreesToRadians@plt>
call   1060 <cos@plt>
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0xdf2(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  0x28(%rsp),%xmm1
addsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
mov    %eax,%edi
call   1040 <asin@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xda5(%rip),%xmm0
mulsd  0xda5(%rip),%xmm0
movsd  %xmm0,(%rbx)
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @getDistanceEx(double %0, double %1, double %2, double %3, double* %4) {
%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
%16 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store double* %4, double** %10
store double 6.373000e+03, double* %13
%17 = load double, double* %8
%18 = load double, double* %6
%19 = fsub double %17, %18
%20 = call double @degreesToRadians(double %19)
store double %20, double* %11
%21 = load double, double* %9
%22 = load double, double* %7
%23 = fsub double %21, %22
%24 = call double @degreesToRadians(double %23)
store double %24, double* %12
%25 = load double, double* %11
%26 = fdiv double %25, 2.000000e+00
%27 = call double @sin(double %26)
%28 = load double, double* %11
%29 = fdiv double %28, 2.000000e+00
%30 = call double @sin(double %29)
%31 = load double, double* %6
%32 = call double @degreesToRadians(double %31)
%33 = call double @cos(double %32)
%34 = load double, double* %8
%35 = call double @degreesToRadians(double %34)
%36 = call double @cos(double %35)
%37 = fmul double %33, %36
%38 = load double, double* %12
%39 = fdiv double %38, 2.000000e+00
%40 = call double @sin(double %39)
%41 = fmul double %37, %40
%42 = load double, double* %12
%43 = fdiv double %42, 2.000000e+00
%44 = call double @sin(double %43)
%45 = fmul double %41, %44
%46 = call double @llvm.fmuladd.f64(double %27, double %30, double %45)
store double %46, double* %14
%47 = load double, double* %14
%48 = call i32 @sqrt(double %47)
%49 = call i32 @asin(i32 %48)
%50 = mul nsw i32 2, %49
%51 = sitofp i32 %50 to double
store double %51, double* %15
%52 = load double, double* %13
%53 = load double, double* %15
%54 = fmul double %52, %53
%55 = load double*, double** %10
store double %54, double* %55
%56 = load double*, double** %10
%57 = load double, double* %56
%58 = fmul double %57, 1.000000e+03
store double %58, double* %56
ret void
}

LLVM IR (-O2):
define void @getDistanceEx(double %0, double %1, double %2, double %3, double* nocapture writeonly %4) {
%6 = fsub double %2, %0
%7 = tail call double @degreesToRadians(double %6)
%8 = fsub double %3, %1
%9 = tail call double @degreesToRadians(double %8)
%10 = fmul double %7, 5.000000e-01
%11 = tail call double @sin(double %10)
%12 = tail call double @sin(double %10)
%13 = tail call double @degreesToRadians(double %0)
%14 = tail call double @cos(double %13)
%15 = tail call double @degreesToRadians(double %2)
%16 = tail call double @cos(double %15)
%17 = fmul double %14, %16
%18 = fmul double %9, 5.000000e-01
%19 = tail call double @sin(double %18)
%20 = fmul double %17, %19
%21 = tail call double @sin(double %18)
%22 = fmul double %20, %21
%23 = tail call double @llvm.fmuladd.f64(double %11, double %12, double %22)
%24 = tail call i32 @sqrt(double %23)
%25 = tail call i32 @asin(i32 %24)
%26 = shl nsw i32 %25, 1
%27 = sitofp i32 %26 to double
%28 = fmul double %27, 6.373000e+03
%29 = fmul double %28, 1.000000e+03
store double %29, double* %4
ret void
}