#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 atan2(double, double);
double cos(double);
double sin(double);
double sqrt(double);
double ApproxDistance(double lat1, double lon1, double lat2, double lon2) {
  double F, G, L, sing, cosl, cosf, sinl, sinf, cosg, S, C, W, R, H1, H2, D;
  lat1 = (M_PI / 180.0) * lat1;
  lon1 = -(M_PI / 180.0) * lon1;
  lat2 = (M_PI / 180.0) * lat2;
  lon2 = -(M_PI / 180.0) * lon2;
  F = (lat1 + lat2) / 2.0;
  G = (lat1 - lat2) / 2.0;
  L = (lon1 - lon2) / 2.0;
  sing = sin(G);
  cosl = cos(L);
  cosf = cos(F);
  sinl = sin(L);
  sinf = sin(F);
  cosg = cos(G);
  S = sing * sing * cosl * cosl + cosf * cosf * sinl * sinl;
  C = cosg * cosg * cosl * cosl + sinf * sinf * sinl * sinl;
  W = atan2(sqrt(S), sqrt(C));
  R = sqrt((S * C)) / W;
  H1 = (3 * R - 1.0) / (2.0 * C);
  H2 = (3 * R + 1.0) / (2.0 * S);
  D = 2 * W * 6378.135;
  return (D * (1 + (1.0 / 298.26) * H1 * sinf * sinf * cosg * cosg -
               (1.0 / 298.26) * H2 * cosf * cosf * sing * sing));
}


x86 assembly (clang, -O0):
<ApproxDistance>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    0x2e82(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xebe(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    0x2e61(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe9d(%rip),%xmm1
divsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    0x2e29(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe65(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    0x2e08(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe44(%rip),%xmm1
divsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  0xdf5(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  0xdda(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  0xdbf(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x68(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm1
mulsd  -0x60(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x70(%rbp),%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x78(%rbp),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0xa8(%rbp),%xmm0
ff
call   1030 <atan2@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x70(%rbp),%xmm0
mulsd  -0x78(%rbp),%xmm0
call   1060 <sqrt@plt>
divsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
movsd  0xc9d(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xc99(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xc7d(%rip),%xmm1
mulsd  -0x78(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
movsd  0xc64(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xc40(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xc44(%rip),%xmm1
mulsd  -0x70(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  0xc2b(%rip),%xmm0
mulsd  -0x80(%rbp),%xmm0
movsd  0xc16(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0xa0(%rbp),%xmm0
ff
movsd  0xbea(%rip),%xmm2
mulsd  -0x90(%rbp),%xmm2
ff
mulsd  -0x60(%rbp),%xmm2
mulsd  -0x60(%rbp),%xmm2
mulsd  -0x68(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm1
mulsd  %xmm1,%xmm2
movsd  0xbca(%rip),%xmm1
addsd  %xmm1,%xmm2
movsd  0xbb6(%rip),%xmm1
mulsd  -0x98(%rbp),%xmm1
ff
mulsd  -0x50(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm3
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ApproxDistance>:
sub    $0x78,%rsp
mov    0x2e9d(%rip),%rax
movsd  (%rax),%xmm4
divsd  0xea9(%rip),%xmm4
mulsd  %xmm4,%xmm0
mulsd  %xmm4,%xmm2
movapd %xmm0,%xmm5
addsd  %xmm2,%xmm5
movsd  0xe99(%rip),%xmm6
mulsd  %xmm6,%xmm5
movsd  %xmm5,(%rsp)
subsd  %xmm2,%xmm0
mulsd  %xmm6,%xmm0
movsd  %xmm0,0x40(%rsp)
mulsd  %xmm4,%xmm3
mulsd  %xmm1,%xmm4
subsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm6
movsd  %xmm6,0x20(%rsp)
call   1040 <sin@plt>
movapd %xmm0,0x60(%rsp)
movsd  0x20(%rsp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,0x30(%rsp)
movsd  (%rsp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,0x50(%rsp)
movsd  0x20(%rsp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,0x20(%rsp)
movsd  0x40(%rsp),%xmm0
call   1050 <cos@plt>
movapd 0x60(%rsp),%xmm2
movapd %xmm0,0x40(%rsp)
unpcklpd %xmm0,%xmm2
mulpd  %xmm2,%xmm2
movapd 0x30(%rsp),%xmm0
unpcklpd %xmm0,%xmm0
mulpd  %xmm0,%xmm2
movapd %xmm0,%xmm1
movapd 0x50(%rsp),%xmm0
unpcklpd 0x20(%rsp),%xmm0
mulpd  %xmm0,%xmm0
movapd 0x10(%rsp),%xmm3
unpcklpd %xmm3,%xmm3
mulpd  %xmm3,%xmm0
mulpd  %xmm3,%xmm0
mulpd  %xmm1,%xmm2
addpd  %xmm0,%xmm2
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm2
movsd  %xmm2,0x30(%rsp)
jb     1259 <ApproxDistance+0x119>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    1270 <ApproxDistance+0x130>
movapd %xmm2,%xmm0
movapd %xmm2,(%rsp)
call   1060 <sqrt@plt>
xorpd  %xmm1,%xmm1
movapd (%rsp),%xmm2
unpckhpd %xmm2,%xmm2
ucomisd %xmm1,%xmm2
movapd %xmm2,(%rsp)
jb     1288 <ApproxDistance+0x148>
xorps  %xmm1,%xmm1
sqrtsd %xmm2,%xmm1
jmp    12a1 <ApproxDistance+0x161>
movsd  %xmm0,0x10(%rsp)
movapd %xmm2,%xmm0
call   1060 <sqrt@plt>
movapd %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
call   1030 <atan2@plt>
movapd %xmm0,%xmm4
movsd  0x30(%rsp),%xmm3
movapd %xmm3,%xmm0
movapd (%rsp),%xmm2
mulsd  %xmm2,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     12cd <ApproxDistance+0x18d>
sqrtsd %xmm0,%xmm0
jmp    12e9 <ApproxDistance+0x1a9>
movsd  %xmm4,0x10(%rsp)
call   1060 <sqrt@plt>
movsd  0x10(%rsp),%xmm4
movsd  0x30(%rsp),%xmm3
movapd (%rsp),%xmm2
divsd  %xmm4,%xmm0
mulsd  0xd1b(%rip),%xmm0
movsd  0xd1b(%rip),%xmm1
addsd  %xmm0,%xmm1
addsd  %xmm2,%xmm2
divsd  %xmm2,%xmm1
movsd  0xd0f(%rip),%xmm2
addsd  %xmm2,%xmm0
addsd  %xmm3,%xmm3
addsd  %xmm4,%xmm4
mulsd  0xd03(%rip),%xmm4
divsd  %xmm3,%xmm0
mulsd  0xcff(%rip),%xmm1
movapd 0x20(%rsp),%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm3,%xmm1
movapd 0x40(%rsp),%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  0xcdf(%rip),%xmm0
movapd 0x50(%rsp),%xmm2
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
movapd 0x60(%rsp),%xmm2
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  %xmm4,%xmm0
add    $0x78,%rsp
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double @ApproxDistance(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
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%25 = load double, double* @M_PI
%26 = fdiv double %25, 1.800000e+02
%27 = load double, double* %5
%28 = fmul double %26, %27
store double %28, double* %5
%29 = load double, double* @M_PI
%30 = fdiv double %29, 1.800000e+02
%31 = fneg double %30
%32 = load double, double* %6
%33 = fmul double %31, %32
store double %33, double* %6
%34 = load double, double* @M_PI
%35 = fdiv double %34, 1.800000e+02
%36 = load double, double* %7
%37 = fmul double %35, %36
store double %37, double* %7
%38 = load double, double* @M_PI
%39 = fdiv double %38, 1.800000e+02
%40 = fneg double %39
%41 = load double, double* %8
%42 = fmul double %40, %41
store double %42, double* %8
%43 = load double, double* %5
%44 = load double, double* %7
%45 = fadd double %43, %44
%46 = fdiv double %45, 2.000000e+00
store double %46, double* %9
%47 = load double, double* %5
%48 = load double, double* %7
%49 = fsub double %47, %48
%50 = fdiv double %49, 2.000000e+00
store double %50, double* %10
%51 = load double, double* %6
%52 = load double, double* %8
%53 = fsub double %51, %52
%54 = fdiv double %53, 2.000000e+00
store double %54, double* %11
%55 = load double, double* %10
%56 = call double @sin(double %55)
store double %56, double* %12
%57 = load double, double* %11
%58 = call double @cos(double %57)
store double %58, double* %13
%59 = load double, double* %9
%60 = call double @cos(double %59)
store double %60, double* %14
%61 = load double, double* %11
%62 = call double @sin(double %61)
store double %62, double* %15
%63 = load double, double* %9
%64 = call double @sin(double %63)
store double %64, double* %16
%65 = load double, double* %10
%66 = call double @cos(double %65)
store double %66, double* %17
%67 = load double, double* %12
%68 = load double, double* %12
%69 = fmul double %67, %68
%70 = load double, double* %13
%71 = fmul double %69, %70
%72 = load double, double* %13
%73 = load double, double* %14
%74 = load double, double* %14
%75 = fmul double %73, %74
%76 = load double, double* %15
%77 = fmul double %75, %76
%78 = load double, double* %15
%79 = fmul double %77, %78
%80 = call double @llvm.fmuladd.f64(double %71, double %72, double %79)
store double %80, double* %18
%81 = load double, double* %17
%82 = load double, double* %17
%83 = fmul double %81, %82
%84 = load double, double* %13
%85 = fmul double %83, %84
%86 = load double, double* %13
%87 = load double, double* %16
%88 = load double, double* %16
%89 = fmul double %87, %88
%90 = load double, double* %15
%91 = fmul double %89, %90
%92 = load double, double* %15
%93 = fmul double %91, %92
%94 = call double @llvm.fmuladd.f64(double %85, double %86, double %93)
store double %94, double* %19
%95 = load double, double* %18
%96 = call double @sqrt(double %95)
%97 = load double, double* %19
%98 = call double @sqrt(double %97)
%99 = call double @atan2(double %96, double %98)
store double %99, double* %20
%100 = load double, double* %18
%101 = load double, double* %19
%102 = fmul double %100, %101
%103 = call double @sqrt(double %102)
%104 = load double, double* %20
%105 = fdiv double %103, %104
store double %105, double* %21
%106 = load double, double* %21
%107 = call double @llvm.fmuladd.f64(double 3.000000e+00, double %106, double -1.000000e+00)
%108 = load double, double* %19
%109 = fmul double 2.000000e+00, %108
%110 = fdiv double %107, %109
store double %110, double* %22
%111 = load double, double* %21
%112 = call double @llvm.fmuladd.f64(double 3.000000e+00, double %111, double 1.000000e+00)
%113 = load double, double* %18
%114 = fmul double 2.000000e+00, %113
%115 = fdiv double %112, %114
store double %115, double* %23
%116 = load double, double* %20
%117 = fmul double 2.000000e+00, %116
%118 = fmul double %117, 0x40B8EA228F5C28F6
store double %118, double* %24
%119 = load double, double* %24
%120 = load double, double* %22
%121 = fmul double 0x3F6B7749C3673876, %120
%122 = load double, double* %16
%123 = fmul double %121, %122
%124 = load double, double* %16
%125 = fmul double %123, %124
%126 = load double, double* %17
%127 = fmul double %125, %126
%128 = load double, double* %17
%129 = call double @llvm.fmuladd.f64(double %127, double %128, double 1.000000e+00)
%130 = load double, double* %23
%131 = fmul double 0x3F6B7749C3673876, %130
%132 = load double, double* %14
%133 = fmul double %131, %132
%134 = load double, double* %14
%135 = fmul double %133, %134
%136 = load double, double* %12
%137 = fmul double %135, %136
%138 = load double, double* %12
%139 = fneg double %137
%140 = call double @llvm.fmuladd.f64(double %139, double %138, double %129)
%141 = fmul double %119, %140
ret double %141
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @ApproxDistance(double %0, double %1, double %2, double %3) {
%5 = load double, double* @M_PI
%6 = fdiv double %5, 1.800000e+02
%7 = fmul double %6, %0
%8 = fmul double %6, %2
%9 = fadd double %7, %8
%10 = fmul double %9, 5.000000e-01
%11 = fsub double %7, %8
%12 = fmul double %11, 5.000000e-01
%13 = fmul double %6, %3
%14 = fmul double %6, %1
%15 = fsub double %13, %14
%16 = fmul double %15, 5.000000e-01
%17 = tail call double @sin(double %12)
%18 = tail call double @cos(double %16)
%19 = tail call double @cos(double %10)
%20 = tail call double @sin(double %16)
%21 = tail call double @sin(double %10)
%22 = tail call double @cos(double %12)
%23 = insertelement <2 x double> poison, double %17, i64 0
%24 = insertelement <2 x double> %23, double %22, i64 1
%25 = fmul <2 x double> %24, %24
%26 = insertelement <2 x double> poison, double %18, i64 0
%27 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> zeroinitializer
%28 = fmul <2 x double> %25, %27
%29 = insertelement <2 x double> poison, double %19, i64 0
%30 = insertelement <2 x double> %29, double %21, i64 1
%31 = fmul <2 x double> %30, %30
%32 = insertelement <2 x double> poison, double %20, i64 0
%33 = shufflevector <2 x double> %32, <2 x double> poison, <2 x i32> zeroinitializer
%34 = fmul <2 x double> %31, %33
%35 = fmul <2 x double> %33, %34
%36 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %28, <2 x double> %27, <2 x double> %35)
%37 = extractelement <2 x double> %36, i64 0
%38 = tail call double @sqrt(double %37)
%39 = extractelement <2 x double> %36, i64 1
%40 = tail call double @sqrt(double %39)
%41 = tail call double @atan2(double %38, double %40)
%42 = fmul double %37, %39
%43 = tail call double @sqrt(double %42)
%44 = fdiv double %43, %41
%45 = tail call double @llvm.fmuladd.f64(double %44, double 3.000000e+00, double -1.000000e+00)
%46 = fmul double %39, 2.000000e+00
%47 = fdiv double %45, %46
%48 = tail call double @llvm.fmuladd.f64(double %44, double 3.000000e+00, double 1.000000e+00)
%49 = fmul double %37, 2.000000e+00
%50 = fdiv double %48, %49
%51 = fmul double %41, 2.000000e+00
%52 = fmul double %51, 0x40B8EA228F5C28F6
%53 = fmul double %47, 0x3F6B7749C3673876
%54 = fmul double %21, %53
%55 = fmul double %21, %54
%56 = fmul double %22, %55
%57 = tail call double @llvm.fmuladd.f64(double %56, double %22, double 1.000000e+00)
%58 = fmul double %50, 0xBF6B7749C3673876
%59 = fmul double %19, %58
%60 = fmul double %19, %59
%61 = fmul double %17, %60
%62 = tail call double @llvm.fmuladd.f64(double %61, double %17, double %57)
%63 = fmul double %52, %62
ret double %63
}