#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 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 *= 0.01745329252;
  lon1 *= 0.01745329252;
  lat2 *= 0.01745329252;
  lon2 *= 0.01745329252;
  d = sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon1 - lon2);
  return (6371.0 * 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    1265 <GCDistance+0x135>
movsd  0xe7b(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe69(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe57(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe45(%rip),%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  0xda4(%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
movsd  0xeab(%rip),%xmm0
mulsd  %xmm0,%xmm4
movsd  %xmm4,0x8(%rsp)
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm2
movsd  %xmm2,(%rsp)
mulsd  %xmm0,%xmm3
subsd  %xmm3,%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  0xe1c(%rip),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
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 %46
19: ; preds = %14, %4
%20 = load double, double* %6
%21 = fmul double %20, 0x3F91DF46A252DD11
store double %21, double* %6
%22 = load double, double* %7
%23 = fmul double %22, 0x3F91DF46A252DD11
store double %23, double* %7
%24 = load double, double* %8
%25 = fmul double %24, 0x3F91DF46A252DD11
store double %25, double* %8
%26 = load double, double* %9
%27 = fmul double %26, 0x3F91DF46A252DD11
store double %27, double* %9
%28 = load double, double* %6
%29 = call double @sin(double %28)
%30 = load double, double* %8
%31 = call double @sin(double %30)
%32 = load double, double* %6
%33 = call double @cos(double %32)
%34 = load double, double* %8
%35 = call double @cos(double %34)
%36 = fmul double %33, %35
%37 = load double, double* %7
%38 = load double, double* %9
%39 = fsub double %37, %38
%40 = call double @cos(double %39)
%41 = fmul double %36, %40
%42 = call double @llvm.fmuladd.f64(double %29, double %31, double %41)
store double %42, double* %10
%43 = load double, double* %10
%44 = call double @acos(double %43)
%45 = fmul double 6.371000e+03, %44
store double %45, double* %5
br label %46
46: ; preds = %19, %18
%47 = load double, double* %5
ret double %47
}

LLVM IR (-O2):
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 %24, label %8
8: ; preds = %4
%9 = fmul double %0, 0x3F91DF46A252DD11
%10 = fmul double %1, 0x3F91DF46A252DD11
%11 = fmul double %2, 0x3F91DF46A252DD11
%12 = fmul double %3, 0x3F91DF46A252DD11
%13 = tail call double @sin(double %9)
%14 = tail call double @sin(double %11)
%15 = tail call double @cos(double %9)
%16 = tail call double @cos(double %11)
%17 = fmul double %15, %16
%18 = fsub double %10, %12
%19 = tail call double @cos(double %18)
%20 = fmul double %17, %19
%21 = tail call double @llvm.fmuladd.f64(double %13, double %14, double %20)
%22 = tail call double @acos(double %21)
%23 = fmul double %22, 6.371000e+03
br label %24
24: ; preds = %4, %8
%25 = phi double [ %23, %8 ], [ 0.000000e+00, %4 ]
ret double %25
}