#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 const);
int pow(int /*<<< orphan*/, int);
int /*<<< orphan*/ sin(double const);
int /*<<< orphan*/ sqrt(int);
double calcSmallAngularDist(const double lat1, const double lon1,
                            const double lat2, const double lon2) {
  return 2 * asin(sqrt(pow(sin((lat1 - lat2) / 2), 2) +
                       cos(lat1) * cos(lat2) * pow(sin((lon1 - lon2) / 2), 2)));
}


x86 assembly (clang, -O0):
<calcSmallAngularDist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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  0xe82(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sin@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1060 <pow@plt>
mov    %eax,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <cos@plt>
mov    %eax,-0x2c(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x24(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  0xe36(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sin@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1060 <pow@plt>
mov    -0x28(%rbp),%edi
mov    %eax,%ecx
mov    -0x24(%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
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcSmallAngularDist>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x8(%rsp)
subsd  %xmm2,%xmm0
mulsd  0xe86(%rip),%xmm0
call   1030 <sin@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1060 <pow@plt>
mov    %eax,%ebx
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
mov    %eax,%ebp
movsd  0x10(%rsp),%xmm0
call   1050 <cos@plt>
imul   %eax,%ebp
movsd  0x18(%rsp),%xmm0
subsd  0x20(%rsp),%xmm0
mulsd  0xe44(%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
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @calcSmallAngularDist(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%9 = load double, double* %5
%10 = load double, double* %7
%11 = fsub double %9, %10
%12 = fdiv double %11, 2.000000e+00
%13 = call i32 @sin(double %12)
%14 = call i32 @pow(i32 %13, i32 2)
%15 = load double, double* %5
%16 = call i32 @cos(double %15)
%17 = load double, double* %7
%18 = call i32 @cos(double %17)
%19 = mul nsw i32 %16, %18
%20 = load double, double* %6
%21 = load double, double* %8
%22 = fsub double %20, %21
%23 = fdiv double %22, 2.000000e+00
%24 = call i32 @sin(double %23)
%25 = call i32 @pow(i32 %24, i32 2)
%26 = mul nsw i32 %19, %25
%27 = add nsw i32 %14, %26
%28 = call i32 @sqrt(i32 %27)
%29 = call i32 @asin(i32 %28)
%30 = mul nsw i32 2, %29
%31 = sitofp i32 %30 to double
ret double %31
}

LLVM IR (-O2):
define double @calcSmallAngularDist(double %0, double %1, double %2, double %3) {
%5 = fsub double %0, %2
%6 = fmul double %5, 5.000000e-01
%7 = tail call i32 @sin(double %6)
%8 = tail call i32 @pow(i32 %7, i32 2)
%9 = tail call i32 @cos(double %0)
%10 = tail call i32 @cos(double %2)
%11 = mul nsw i32 %10, %9
%12 = fsub double %1, %3
%13 = fmul double %12, 5.000000e-01
%14 = tail call i32 @sin(double %13)
%15 = tail call i32 @pow(i32 %14, i32 2)
%16 = mul nsw i32 %11, %15
%17 = add nsw i32 %16, %8
%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
ret double %21
}