#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 */
double asin(double);
double cos(double const);
double sin(double);
double sqrt(double);
double GeogDist(const double o1, const double a1, const double o2,
                const double a2) {
  double sin_do_2, sin_da_2, a;
  sin_do_2 = sin(0.5 * (o2 - o1));
  sin_da_2 = sin(0.5 * (a2 - a1));
  a = sqrt(sin_da_2 * sin_da_2 + cos(a1) * cos(a2) * sin_do_2 * sin_do_2);
  return (a > 1.0 ? 3.141592653589793238462 : 2.0 * asin(a));
}


x86 assembly (clang, -O0):
<GeogDist>:
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  -0x18(%rbp),%xmm1
subsd  -0x8(%rbp),%xmm1
movsd  0xe9a(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xe7a(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1050 <cos@plt>
movsd  -0x50(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xdf8(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1224 <GeogDist+0xe4>
movsd  0xdfe(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    1242 <GeogDist+0x102>
movsd  -0x38(%rbp),%xmm0
call   1040 <asin@plt>
movaps %xmm0,%xmm1
movsd  0xdd7(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GeogDist>:
sub    $0x28,%rsp
movsd  %xmm3,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
subsd  %xmm0,%xmm2
mulsd  0xea4(%rip),%xmm2
movapd %xmm2,%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
mulsd  0xe81(%rip),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
movapd %xmm1,%xmm0
jb     11f2 <GeogDist+0xb2>
sqrtsd %xmm0,%xmm0
ucomisd 0xe2e(%rip),%xmm0
ja     1201 <GeogDist+0xc1>
call   1040 <asin@plt>
addsd  %xmm0,%xmm0
add    $0x28,%rsp
ret
call   1060 <sqrt@plt>
ucomisd 0xe11(%rip),%xmm0
jbe    11e4 <GeogDist+0xa4>
movsd  0xdff(%rip),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @GeogDist(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* %7
%13 = load double, double* %5
%14 = fsub double %12, %13
%15 = fmul double 5.000000e-01, %14
%16 = call double @sin(double %15)
store double %16, double* %9
%17 = load double, double* %8
%18 = load double, double* %6
%19 = fsub double %17, %18
%20 = fmul double 5.000000e-01, %19
%21 = call double @sin(double %20)
store double %21, double* %10
%22 = load double, double* %10
%23 = load double, double* %10
%24 = load double, double* %6
%25 = call double @cos(double %24)
%26 = load double, double* %8
%27 = call double @cos(double %26)
%28 = fmul double %25, %27
%29 = load double, double* %9
%30 = fmul double %28, %29
%31 = load double, double* %9
%32 = fmul double %30, %31
%33 = call double @llvm.fmuladd.f64(double %22, double %23, double %32)
%34 = call double @sqrt(double %33)
store double %34, double* %11
%35 = load double, double* %11
%36 = fcmp ogt double %35, 1.000000e+00
br i1 %36, label %37, label %38
37: ; preds = %4
br label %42
38: ; preds = %4
%39 = load double, double* %11
%40 = call double @asin(double %39)
%41 = fmul double 2.000000e+00, %40
br label %42
42: ; preds = %38, %37
%43 = phi double [ 0x400921FB54442D18, %37 ], [ %41, %38 ]
ret double %43
}

LLVM IR (-O2):
define double @GeogDist(double %0, double %1, double %2, double %3) {
%5 = fsub double %2, %0
%6 = fmul double %5, 5.000000e-01
%7 = tail call double @sin(double %6)
%8 = fsub double %3, %1
%9 = fmul double %8, 5.000000e-01
%10 = tail call double @sin(double %9)
%11 = tail call double @cos(double %1)
%12 = tail call double @cos(double %3)
%13 = fmul double %11, %12
%14 = fmul double %7, %13
%15 = fmul double %7, %14
%16 = tail call double @llvm.fmuladd.f64(double %10, double %10, double %15)
%17 = tail call double @sqrt(double %16)
%18 = fcmp ogt double %17, 1.000000e+00
br i1 %18, label %22, label %19
19: ; preds = %4
%20 = tail call double @asin(double %17)
%21 = fmul double %20, 2.000000e+00
br label %22
22: ; preds = %4, %19
%23 = phi double [ %21, %19 ], [ 0x400921FB54442D18, %4 ]
ret double %23
}