#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 sin(double);
int /*<<< orphan*/ sqrt(int);
double great_circle_distance(double *p1, double *p2) {
  double dist, beta;
  beta =
      2. *
      asin(sqrt(sin((p1[1] - p2[1]) / 2.) * sin((p1[1] - p2[1]) / 2.) +
                cos(p1[1]) * cos(p2[1]) *
                    (sin((p1[0] - p2[0]) / 2.) * sin((p1[0] - p2[0]) / 2.))));
  dist = (6371000.) * beta;
  return dist;
}


x86 assembly (clang, -O0):
<great_circle_distance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  0xe9e(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sin@plt>
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  0xe78(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sin@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1050 <cos@plt>
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1050 <cos@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movsd  0xe22(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sin@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movsd  0xdfe(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sin@plt>
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%edi
mov    %eax,%edx
mov    -0x24(%rbp),%eax
imul   %edx,%ecx
imul   %ecx,%eax
add    %eax,%edi
call   1060 <sqrt@plt>
mov    %eax,%edi
call   1040 <asin@plt>
cvtsi2sd %eax,%xmm1
movsd  0xdca(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xdb1(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<great_circle_distance>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%rbp
movsd  0x8(%rdi),%xmm0
subsd  0x8(%rsi),%xmm0
mulsd  0xe9d(%rip),%xmm0
call   1030 <sin@plt>
mov    %eax,%r14d
movsd  0x8(%rbp),%xmm0
subsd  0x8(%r12),%xmm0
mulsd  0xe81(%rip),%xmm0
call   1030 <sin@plt>
imul   %eax,%r14d
movsd  0x8(%rbp),%xmm0
call   1050 <cos@plt>
mov    %eax,%r15d
movsd  0x8(%r12),%xmm0
call   1050 <cos@plt>
mov    %eax,%ebx
movsd  0x0(%rbp),%xmm0
subsd  (%r12),%xmm0
mulsd  0xe4a(%rip),%xmm0
call   1030 <sin@plt>
mov    %eax,%r13d
movsd  0x0(%rbp),%xmm0
subsd  (%r12),%xmm0
mulsd  0xe2f(%rip),%xmm0
call   1030 <sin@plt>
imul   %r15d,%ebx
imul   %r13d,%ebx
imul   %eax,%ebx
add    %r14d,%ebx
mov    %ebx,%edi
call   1060 <sqrt@plt>
mov    %eax,%edi
call   1040 <asin@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  %xmm0,%xmm0
mulsd  0xe03(%rip),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @great_circle_distance(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca double
%6 = alloca double
store double* %0, double** %3
store double* %1, double** %4
%7 = load double*, double** %3
%8 = getelementptr inbounds double, double* %7, i64 1
%9 = load double, double* %8
%10 = load double*, double** %4
%11 = getelementptr inbounds double, double* %10, i64 1
%12 = load double, double* %11
%13 = fsub double %9, %12
%14 = fdiv double %13, 2.000000e+00
%15 = call i32 @sin(double %14)
%16 = load double*, double** %3
%17 = getelementptr inbounds double, double* %16, i64 1
%18 = load double, double* %17
%19 = load double*, double** %4
%20 = getelementptr inbounds double, double* %19, i64 1
%21 = load double, double* %20
%22 = fsub double %18, %21
%23 = fdiv double %22, 2.000000e+00
%24 = call i32 @sin(double %23)
%25 = mul nsw i32 %15, %24
%26 = load double*, double** %3
%27 = getelementptr inbounds double, double* %26, i64 1
%28 = load double, double* %27
%29 = call i32 @cos(double %28)
%30 = load double*, double** %4
%31 = getelementptr inbounds double, double* %30, i64 1
%32 = load double, double* %31
%33 = call i32 @cos(double %32)
%34 = mul nsw i32 %29, %33
%35 = load double*, double** %3
%36 = getelementptr inbounds double, double* %35, i64 0
%37 = load double, double* %36
%38 = load double*, double** %4
%39 = getelementptr inbounds double, double* %38, i64 0
%40 = load double, double* %39
%41 = fsub double %37, %40
%42 = fdiv double %41, 2.000000e+00
%43 = call i32 @sin(double %42)
%44 = load double*, double** %3
%45 = getelementptr inbounds double, double* %44, i64 0
%46 = load double, double* %45
%47 = load double*, double** %4
%48 = getelementptr inbounds double, double* %47, i64 0
%49 = load double, double* %48
%50 = fsub double %46, %49
%51 = fdiv double %50, 2.000000e+00
%52 = call i32 @sin(double %51)
%53 = mul nsw i32 %43, %52
%54 = mul nsw i32 %34, %53
%55 = add nsw i32 %25, %54
%56 = call i32 @sqrt(i32 %55)
%57 = call i32 @asin(i32 %56)
%58 = sitofp i32 %57 to double
%59 = fmul double 2.000000e+00, %58
store double %59, double* %6
%60 = load double, double* %6
%61 = fmul double 6.371000e+06, %60
store double %61, double* %5
%62 = load double, double* %5
ret double %62
}

LLVM IR (-O2):
define double @great_circle_distance(double* nocapture %0, double* nocapture %1) {
%3 = getelementptr inbounds double, double* %0, i64 1
%4 = load double, double* %3
%5 = getelementptr inbounds double, double* %1, i64 1
%6 = load double, double* %5
%7 = fsub double %4, %6
%8 = fmul double %7, 5.000000e-01
%9 = tail call i32 @sin(double %8)
%10 = load double, double* %3
%11 = load double, double* %5
%12 = fsub double %10, %11
%13 = fmul double %12, 5.000000e-01
%14 = tail call i32 @sin(double %13)
%15 = mul nsw i32 %14, %9
%16 = load double, double* %3
%17 = tail call i32 @cos(double %16)
%18 = load double, double* %5
%19 = tail call i32 @cos(double %18)
%20 = load double, double* %0
%21 = load double, double* %1
%22 = fsub double %20, %21
%23 = fmul double %22, 5.000000e-01
%24 = tail call i32 @sin(double %23)
%25 = load double, double* %0
%26 = load double, double* %1
%27 = fsub double %25, %26
%28 = fmul double %27, 5.000000e-01
%29 = tail call i32 @sin(double %28)
%30 = mul i32 %19, %17
%31 = mul i32 %30, %24
%32 = mul i32 %31, %29
%33 = add nsw i32 %32, %15
%34 = tail call i32 @sqrt(i32 %33)
%35 = tail call i32 @asin(i32 %34)
%36 = sitofp i32 %35 to double
%37 = fmul double %36, 2.000000e+00
%38 = fmul double %37, 6.371000e+06
ret double %38
}