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


x86 assembly (clang, -O0):
<get_distance>:
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  -0x8(%rbp),%xmm0
call   1030 <radian@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <radian@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <radian@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <radian@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xe28(%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  0xde1(%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   1090 <sqrt@plt>
mov    %eax,%edi
call   1050 <asin@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xd97(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xd7d(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
call   1080 <round@plt>
mov    $0x2710,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xd52(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_distance>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,(%rsp)
call   1030 <radian@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <radian@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  (%rsp),%xmm0
call   1030 <radian@plt>
movsd  %xmm0,(%rsp)
movsd  0x20(%rsp),%xmm0
call   1030 <radian@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0xe17(%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  0xddc(%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   1090 <sqrt@plt>
mov    %eax,%edi
call   1050 <asin@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xdaf(%rip),%xmm0
mulsd  0xdaf(%rip),%xmm0
call   1080 <round@plt>
cltq
imul   $0x68db8bad,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xd8d(%rip),%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @get_distance(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* %5
%15 = call double @radian(double %14)
store double %15, double* %9
%16 = load double, double* %7
%17 = call double @radian(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* %6
%22 = call double @radian(double %21)
%23 = load double, double* %8
%24 = call double @radian(double %23)
%25 = fsub double %22, %24
store double %25, double* %12
%26 = load double, double* %11
%27 = fdiv double %26, 2.000000e+00
%28 = call i32 @sin(double %27)
%29 = call i32 @pow(i32 %28, i32 2)
%30 = load double, double* %9
%31 = call i32 @cos(double %30)
%32 = load double, double* %10
%33 = call i32 @cos(double %32)
%34 = mul nsw i32 %31, %33
%35 = load double, double* %12
%36 = fdiv double %35, 2.000000e+00
%37 = call i32 @sin(double %36)
%38 = call i32 @pow(i32 %37, i32 2)
%39 = mul nsw i32 %34, %38
%40 = add nsw i32 %29, %39
%41 = call i32 @sqrt(i32 %40)
%42 = call i32 @asin(i32 %41)
%43 = mul nsw i32 2, %42
%44 = sitofp i32 %43 to double
store double %44, double* %13
%45 = load double, double* %13
%46 = fmul double %45, 0x40B8EA23126E978D
store double %46, double* %13
%47 = load double, double* %13
%48 = fmul double %47, 1.000000e+04
%49 = call i32 @round(double %48)
%50 = sdiv i32 %49, 10000
%51 = sitofp i32 %50 to double
store double %51, double* %13
%52 = load double, double* %13
%53 = fmul double %52, 1.000000e+03
ret double %53
}

LLVM IR (-O2):
define double @get_distance(double %0, double %1, double %2, double %3) {
%5 = tail call double @radian(double %0)
%6 = tail call double @radian(double %2)
%7 = fsub double %5, %6
%8 = tail call double @radian(double %1)
%9 = tail call double @radian(double %3)
%10 = fsub double %8, %9
%11 = fmul double %7, 5.000000e-01
%12 = tail call i32 @sin(double %11)
%13 = tail call i32 @pow(i32 %12, i32 2)
%14 = tail call i32 @cos(double %5)
%15 = tail call i32 @cos(double %6)
%16 = mul nsw i32 %15, %14
%17 = fmul double %10, 5.000000e-01
%18 = tail call i32 @sin(double %17)
%19 = tail call i32 @pow(i32 %18, i32 2)
%20 = mul nsw i32 %16, %19
%21 = add nsw i32 %20, %13
%22 = tail call i32 @sqrt(i32 %21)
%23 = tail call i32 @asin(i32 %22)
%24 = shl nsw i32 %23, 1
%25 = sitofp i32 %24 to double
%26 = fmul double %25, 0x40B8EA23126E978D
%27 = fmul double %26, 1.000000e+04
%28 = tail call i32 @round(double %27)
%29 = sdiv i32 %28, 10000
%30 = sitofp i32 %29 to double
%31 = fmul double %30, 1.000000e+03
ret double %31
}