#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 M_PI;
double acos(double);
double cos(double);
double sin(double);
double GCDistance(double lat1, double lon1, double lat2, double lon2) {
  double d;
  if (lat1 == lat2 && lon1 == lon2)
    return (0.0);
  lat1 *= (M_PI / 180.0);
  lon1 *= (M_PI / 180.0);
  lat2 *= (M_PI / 180.0);
  lon2 *= (M_PI / 180.0);
  d = sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon1 - lon2);
  return (6371.0087714 * acos(d));
}


x86 assembly (clang, -O0):
<GCDistance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jne    1185 <GCDistance+0x55>
jp     1185 <GCDistance+0x55>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jne    1185 <GCDistance+0x55>
jp     1185 <GCDistance+0x55>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a1 <GCDistance+0x171>
mov    0x2e5c(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe70(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    0x2e3b(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe4f(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    0x2e1a(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe2e(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    0x2df9(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe0d(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
call   1050 <cos@plt>
movsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1030 <acos@plt>
movaps %xmm0,%xmm1
movsd  0xd68(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GCDistance>:
movapd %xmm0,%xmm4
ucomisd %xmm2,%xmm0
jne    1149 <GCDistance+0x19>
jp     1149 <GCDistance+0x19>
xorpd  %xmm0,%xmm0
ucomisd %xmm3,%xmm1
jne    1149 <GCDistance+0x19>
jp     1149 <GCDistance+0x19>
ret
sub    $0x28,%rsp
mov    0x2e94(%rip),%rax
movsd  (%rax),%xmm0
divsd  0xea0(%rip),%xmm0
mulsd  %xmm0,%xmm4
movsd  %xmm4,0x8(%rsp)
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm2
movsd  %xmm2,(%rsp)
mulsd  %xmm3,%xmm0
subsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movapd %xmm4,%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x20(%rsp)
movsd  (%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1050 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x18(%rsp),%xmm0
call   1050 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm1
addsd  %xmm1,%xmm0
call   1030 <acos@plt>
mulsd  0xe11(%rip),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double @GCDistance(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
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
%11 = load double, double* %6
%12 = load double, double* %8
%13 = fcmp oeq double %11, %12
br i1 %13, label %14, label %19
14: ; preds = %4
%15 = load double, double* %7
%16 = load double, double* %9
%17 = fcmp oeq double %15, %16
br i1 %17, label %18, label %19
18: ; preds = %14
store double 0.000000e+00, double* %5
br label %54
19: ; preds = %14, %4
%20 = load double, double* @M_PI
%21 = fdiv double %20, 1.800000e+02
%22 = load double, double* %6
%23 = fmul double %22, %21
store double %23, double* %6
%24 = load double, double* @M_PI
%25 = fdiv double %24, 1.800000e+02
%26 = load double, double* %7
%27 = fmul double %26, %25
store double %27, double* %7
%28 = load double, double* @M_PI
%29 = fdiv double %28, 1.800000e+02
%30 = load double, double* %8
%31 = fmul double %30, %29
store double %31, double* %8
%32 = load double, double* @M_PI
%33 = fdiv double %32, 1.800000e+02
%34 = load double, double* %9
%35 = fmul double %34, %33
store double %35, double* %9
%36 = load double, double* %6
%37 = call double @sin(double %36)
%38 = load double, double* %8
%39 = call double @sin(double %38)
%40 = load double, double* %6
%41 = call double @cos(double %40)
%42 = load double, double* %8
%43 = call double @cos(double %42)
%44 = fmul double %41, %43
%45 = load double, double* %7
%46 = load double, double* %9
%47 = fsub double %45, %46
%48 = call double @cos(double %47)
%49 = fmul double %44, %48
%50 = call double @llvm.fmuladd.f64(double %37, double %39, double %49)
store double %50, double* %10
%51 = load double, double* %10
%52 = call double @acos(double %51)
%53 = fmul double 0x40B8E3023ED7AC24, %52
store double %53, double* %5
br label %54
54: ; preds = %19, %18
%55 = load double, double* %5
ret double %55
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @GCDistance(double %0, double %1, double %2, double %3) {
%5 = fcmp oeq double %0, %2
%6 = fcmp oeq double %1, %3
%7 = and i1 %5, %6
br i1 %7, label %26, label %8
8: ; preds = %4
%9 = load double, double* @M_PI
%10 = fdiv double %9, 1.800000e+02
%11 = fmul double %10, %0
%12 = fmul double %10, %1
%13 = fmul double %10, %2
%14 = fmul double %10, %3
%15 = tail call double @sin(double %11)
%16 = tail call double @sin(double %13)
%17 = tail call double @cos(double %11)
%18 = tail call double @cos(double %13)
%19 = fmul double %17, %18
%20 = fsub double %12, %14
%21 = tail call double @cos(double %20)
%22 = fmul double %19, %21
%23 = tail call double @llvm.fmuladd.f64(double %15, double %16, double %22)
%24 = tail call double @acos(double %23)
%25 = fmul double %24, 0x40B8E3023ED7AC24
br label %26
26: ; preds = %4, %8
%27 = phi double [ %25, %8 ], [ 0.000000e+00, %4 ]
ret double %27
}