#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 asin(int /*<<< orphan*/);
int cos(double);
int pow(int /*<<< orphan*/, int);
double radian_1(double);
int /*<<< orphan*/ sin(double);
int /*<<< orphan*/ sqrt(int);
double CalculateLength_Haversine(double lng1, double lat1, double lng2,
                                 double lat2) {
  double radLat1 = radian_1(lat1);
  double radLat2 = radian_1(lat2);
  double a = radLat1 - radLat2;
  double b = radian_1(lng1 - lng2);
  double dst = asin((sqrt(pow(sin(a / 2), 2) +
                          cos(radLat1) * cos(radLat2) * pow(sin(b / 2), 2))));
  dst = dst * 2 * 6378.137 * 1000.0;
  return dst;
}


x86 assembly (clang, -O0):
<CalculateLength_Haversine>:
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
call   1030 <radian_1@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <radian_1@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1030 <radian_1@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xe46(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <sin@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1070 <pow@plt>
mov    %eax,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1060 <cos@plt>
mov    %eax,-0x54(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1060 <cos@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x4c(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xdff(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <sin@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1070 <pow@plt>
mov    -0x50(%rbp),%edi
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
imul   %ecx,%eax
add    %eax,%edi
call   1080 <sqrt@plt>
mov    %eax,%edi
call   1050 <asin@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  0xdc4(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  0xdaf(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd9b(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalculateLength_Haversine>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
movsd  %xmm3,0x8(%rsp)
movsd  %xmm2,(%rsp)
movsd  %xmm0,0x20(%rsp)
movaps %xmm1,%xmm0
call   1030 <radian_1@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <radian_1@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0x20(%rsp),%xmm0
subsd  (%rsp),%xmm0
call   1030 <radian_1@plt>
movsd  %xmm0,(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0xe37(%rip),%xmm0
call   1040 <sin@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1070 <pow@plt>
mov    %eax,%ebx
movsd  0x10(%rsp),%xmm0
call   1060 <cos@plt>
mov    %eax,%ebp
movsd  0x8(%rsp),%xmm0
call   1060 <cos@plt>
imul   %eax,%ebp
movsd  (%rsp),%xmm0
mulsd  0xdfc(%rip),%xmm0
call   1040 <sin@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1070 <pow@plt>
imul   %eax,%ebp
add    %ebx,%ebp
mov    %ebp,%edi
call   1080 <sqrt@plt>
mov    %eax,%edi
call   1050 <asin@plt>
addsd  %xmm0,%xmm0
mulsd  0xdd4(%rip),%xmm0
mulsd  0xdd4(%rip),%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @CalculateLength_Haversine(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
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%14 = load double, double* %6
%15 = call double @radian_1(double %14)
store double %15, double* %9
%16 = load double, double* %8
%17 = call double @radian_1(double %16)
store double %17, double* %10
%18 = load double, double* %9
%19 = load double, double* %10
%20 = fsub double %18, %19
store double %20, double* %11
%21 = load double, double* %5
%22 = load double, double* %7
%23 = fsub double %21, %22
%24 = call double @radian_1(double %23)
store double %24, double* %12
%25 = load double, double* %11
%26 = fdiv double %25, 2.000000e+00
%27 = call i32 @sin(double %26)
%28 = call i32 @pow(i32 %27, i32 2)
%29 = load double, double* %9
%30 = call i32 @cos(double %29)
%31 = load double, double* %10
%32 = call i32 @cos(double %31)
%33 = mul nsw i32 %30, %32
%34 = load double, double* %12
%35 = fdiv double %34, 2.000000e+00
%36 = call i32 @sin(double %35)
%37 = call i32 @pow(i32 %36, i32 2)
%38 = mul nsw i32 %33, %37
%39 = add nsw i32 %28, %38
%40 = call i32 @sqrt(i32 %39)
%41 = call double @asin(i32 %40)
store double %41, double* %13
%42 = load double, double* %13
%43 = fmul double %42, 2.000000e+00
%44 = fmul double %43, 0x40B8EA23126E978D
%45 = fmul double %44, 1.000000e+03
store double %45, double* %13
%46 = load double, double* %13
ret double %46
}

LLVM IR (-O2):
define double @CalculateLength_Haversine(double %0, double %1, double %2, double %3) {
%5 = tail call double @radian_1(double %1)
%6 = tail call double @radian_1(double %3)
%7 = fsub double %5, %6
%8 = fsub double %0, %2
%9 = tail call double @radian_1(double %8)
%10 = fmul double %7, 5.000000e-01
%11 = tail call i32 @sin(double %10)
%12 = tail call i32 @pow(i32 %11, i32 2)
%13 = tail call i32 @cos(double %5)
%14 = tail call i32 @cos(double %6)
%15 = mul nsw i32 %14, %13
%16 = fmul double %9, 5.000000e-01
%17 = tail call i32 @sin(double %16)
%18 = tail call i32 @pow(i32 %17, i32 2)
%19 = mul nsw i32 %15, %18
%20 = add nsw i32 %19, %12
%21 = tail call i32 @sqrt(i32 %20)
%22 = tail call double @asin(i32 %21)
%23 = fmul double %22, 2.000000e+00
%24 = fmul double %23, 0x40B8EA23126E978D
%25 = fmul double %24, 1.000000e+03
ret double %25
}