#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);
int /*<<< orphan*/ sin(double);
int /*<<< orphan*/ sqrt(int);
double distbtp(double lat1, double lng1, double lat2, double lng2) {
  double a = lat1 - lat2;
  double b = lng1 - lng2;
  double s = 2 * asin(sqrt(pow(sin(a / 2), 2) +
                           cos(lat1) * cos(lat2) * pow(sin(b / 2), 2)));
  s = s * 4000;
  return s;
}


x86 assembly (clang, -O0):
<distbtp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe71(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sin@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1060 <pow@plt>
mov    %eax,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <cos@plt>
mov    %eax,-0x44(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x3c(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe2a(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sin@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1060 <pow@plt>
mov    -0x40(%rbp),%edi
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
imul   %ecx,%eax
add    %eax,%edi
call   1070 <sqrt@plt>
mov    %eax,%edi
call   1040 <asin@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xde0(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<distbtp>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  %xmm0,(%rsp)
subsd  %xmm2,%xmm0
subsd  %xmm3,%xmm1
movsd  %xmm1,0x10(%rsp)
mulsd  0xe89(%rip),%xmm0
call   1030 <sin@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1060 <pow@plt>
mov    %eax,%ebx
movsd  (%rsp),%xmm0
call   1050 <cos@plt>
mov    %eax,%ebp
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
imul   %eax,%ebp
movsd  0x10(%rsp),%xmm0
mulsd  0xe4e(%rip),%xmm0
call   1030 <sin@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1060 <pow@plt>
imul   %eax,%ebp
add    %ebx,%ebp
mov    %ebp,%edi
call   1070 <sqrt@plt>
mov    %eax,%edi
call   1040 <asin@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe21(%rip),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

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

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