#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 acos(int);
int cos(int /*<<< orphan*/);
int /*<<< orphan*/ radians(double const);
int sin(int /*<<< orphan*/);
double great_circle_distance(const double lat1, const double lon1,
                             const double lat2, const double lon2) {
  return 6378137 * acos((sin(radians(lat1)) * sin(radians(lat2)) +
                         cos(radians(lat1)) * cos(radians(lat2)) *
                             cos(radians(lon2 - lon1))));
}


x86 assembly (clang, -O0):
<great_circle_distance>:
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
call   1050 <radians@plt>
mov    %eax,%edi
call   1040 <sin@plt>
mov    %eax,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <radians@plt>
mov    %eax,%edi
call   1040 <sin@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <radians@plt>
mov    %eax,%edi
call   1060 <cos@plt>
mov    %eax,-0x2c(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <radians@plt>
mov    %eax,%edi
call   1060 <cos@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x24(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1050 <radians@plt>
mov    %eax,%edi
call   1060 <cos@plt>
mov    -0x28(%rbp),%edi
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
imul   %ecx,%eax
add    %eax,%edi
call   1030 <acos@plt>
imul   $0x615299,%eax,%eax
cvtsi2sd %eax,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<great_circle_distance>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x10(%rsp)
call   1050 <radians@plt>
mov    %eax,%edi
call   1040 <sin@plt>
mov    %eax,%ebx
movsd  0x8(%rsp),%xmm0
call   1050 <radians@plt>
mov    %eax,%edi
call   1040 <sin@plt>
imul   %eax,%ebx
movsd  0x10(%rsp),%xmm0
call   1050 <radians@plt>
mov    %eax,%edi
call   1060 <cos@plt>
mov    %eax,%ebp
movsd  0x8(%rsp),%xmm0
call   1050 <radians@plt>
mov    %eax,%edi
call   1060 <cos@plt>
imul   %eax,%ebp
movsd  0x20(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
call   1050 <radians@plt>
mov    %eax,%edi
call   1060 <cos@plt>
imul   %eax,%ebp
add    %ebx,%ebp
mov    %ebp,%edi
call   1030 <acos@plt>
imul   $0x615299,%eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @great_circle_distance(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 = call i32 @radians(double %9)
%11 = call i32 @sin(i32 %10)
%12 = load double, double* %7
%13 = call i32 @radians(double %12)
%14 = call i32 @sin(i32 %13)
%15 = mul nsw i32 %11, %14
%16 = load double, double* %5
%17 = call i32 @radians(double %16)
%18 = call i32 @cos(i32 %17)
%19 = load double, double* %7
%20 = call i32 @radians(double %19)
%21 = call i32 @cos(i32 %20)
%22 = mul nsw i32 %18, %21
%23 = load double, double* %8
%24 = load double, double* %6
%25 = fsub double %23, %24
%26 = call i32 @radians(double %25)
%27 = call i32 @cos(i32 %26)
%28 = mul nsw i32 %22, %27
%29 = add nsw i32 %15, %28
%30 = call i32 @acos(i32 %29)
%31 = mul nsw i32 6378137, %30
%32 = sitofp i32 %31 to double
ret double %32
}

LLVM IR (-O2):
define double @great_circle_distance(double %0, double %1, double %2, double %3) {
%5 = tail call i32 @radians(double %0)
%6 = tail call i32 @sin(i32 %5)
%7 = tail call i32 @radians(double %2)
%8 = tail call i32 @sin(i32 %7)
%9 = mul nsw i32 %8, %6
%10 = tail call i32 @radians(double %0)
%11 = tail call i32 @cos(i32 %10)
%12 = tail call i32 @radians(double %2)
%13 = tail call i32 @cos(i32 %12)
%14 = mul nsw i32 %13, %11
%15 = fsub double %3, %1
%16 = tail call i32 @radians(double %15)
%17 = tail call i32 @cos(i32 %16)
%18 = mul nsw i32 %14, %17
%19 = add nsw i32 %18, %9
%20 = tail call i32 @acos(i32 %19)
%21 = mul nsw i32 %20, 6378137
%22 = sitofp i32 %21 to double
ret double %22
}