#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 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 = 0.01745329252 * lat1;
  lon1 = -0.01745329252 * lon1;
  lat2 = 0.01745329252 * lat2;
  lon2 = -0.01745329252 * 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)
movsd  0xed1(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  0xeb7(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xead(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe93(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  0xe5f(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  0xe44(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  0xe29(%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  0xd07(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd03(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xce7(%rip),%xmm1
mulsd  -0x78(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
movsd  0xcce(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xcaa(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xcae(%rip),%xmm1
mulsd  -0x70(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  0xc95(%rip),%xmm0
mulsd  -0x80(%rbp),%xmm0
movsd  0xc80(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0xa0(%rbp),%xmm0
ff
movsd  0xc54(%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  0xc34(%rip),%xmm1
addsd  %xmm1,%xmm2
movsd  0xc20(%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
movsd  0xeb4(%rip),%xmm4
mulsd  %xmm4,%xmm0
mulsd  0xeb0(%rip),%xmm1
mulsd  %xmm4,%xmm2
mulsd  %xmm3,%xmm4
addsd  %xmm1,%xmm4
movapd %xmm0,%xmm3
addsd  %xmm2,%xmm3
movsd  0xe9c(%rip),%xmm1
mulsd  %xmm1,%xmm3
movsd  %xmm3,(%rsp)
subsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x40(%rsp)
mulsd  %xmm1,%xmm4
movsd  %xmm4,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     1252 <ApproxDistance+0x112>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    1269 <ApproxDistance+0x129>
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     1281 <ApproxDistance+0x141>
xorps  %xmm1,%xmm1
sqrtsd %xmm2,%xmm1
jmp    129a <ApproxDistance+0x15a>
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     12c6 <ApproxDistance+0x186>
sqrtsd %xmm0,%xmm0
jmp    12e2 <ApproxDistance+0x1a2>
movsd  %xmm4,0x10(%rsp)
call   1060 <sqrt@plt>
movsd  0x10(%rsp),%xmm4
movsd  0x30(%rsp),%xmm3
movapd (%rsp),%xmm2
divsd  %xmm4,%xmm0
mulsd  0xd2a(%rip),%xmm0
movsd  0xd2a(%rip),%xmm1
addsd  %xmm0,%xmm1
addsd  %xmm2,%xmm2
divsd  %xmm2,%xmm1
movsd  0xd1e(%rip),%xmm2
addsd  %xmm2,%xmm0
addsd  %xmm3,%xmm3
addsd  %xmm4,%xmm4
mulsd  0xd12(%rip),%xmm4
divsd  %xmm3,%xmm0
mulsd  0xd0e(%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  0xcee(%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):
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* %5
%26 = fmul double 0x3F91DF46A252DD11, %25
store double %26, double* %5
%27 = load double, double* %6
%28 = fmul double 0xBF91DF46A252DD11, %27
store double %28, double* %6
%29 = load double, double* %7
%30 = fmul double 0x3F91DF46A252DD11, %29
store double %30, double* %7
%31 = load double, double* %8
%32 = fmul double 0xBF91DF46A252DD11, %31
store double %32, double* %8
%33 = load double, double* %5
%34 = load double, double* %7
%35 = fadd double %33, %34
%36 = fdiv double %35, 2.000000e+00
store double %36, double* %9
%37 = load double, double* %5
%38 = load double, double* %7
%39 = fsub double %37, %38
%40 = fdiv double %39, 2.000000e+00
store double %40, double* %10
%41 = load double, double* %6
%42 = load double, double* %8
%43 = fsub double %41, %42
%44 = fdiv double %43, 2.000000e+00
store double %44, double* %11
%45 = load double, double* %10
%46 = call double @sin(double %45)
store double %46, double* %12
%47 = load double, double* %11
%48 = call double @cos(double %47)
store double %48, double* %13
%49 = load double, double* %9
%50 = call double @cos(double %49)
store double %50, double* %14
%51 = load double, double* %11
%52 = call double @sin(double %51)
store double %52, double* %15
%53 = load double, double* %9
%54 = call double @sin(double %53)
store double %54, double* %16
%55 = load double, double* %10
%56 = call double @cos(double %55)
store double %56, double* %17
%57 = load double, double* %12
%58 = load double, double* %12
%59 = fmul double %57, %58
%60 = load double, double* %13
%61 = fmul double %59, %60
%62 = load double, double* %13
%63 = load double, double* %14
%64 = load double, double* %14
%65 = fmul double %63, %64
%66 = load double, double* %15
%67 = fmul double %65, %66
%68 = load double, double* %15
%69 = fmul double %67, %68
%70 = call double @llvm.fmuladd.f64(double %61, double %62, double %69)
store double %70, double* %18
%71 = load double, double* %17
%72 = load double, double* %17
%73 = fmul double %71, %72
%74 = load double, double* %13
%75 = fmul double %73, %74
%76 = load double, double* %13
%77 = load double, double* %16
%78 = load double, double* %16
%79 = fmul double %77, %78
%80 = load double, double* %15
%81 = fmul double %79, %80
%82 = load double, double* %15
%83 = fmul double %81, %82
%84 = call double @llvm.fmuladd.f64(double %75, double %76, double %83)
store double %84, double* %19
%85 = load double, double* %18
%86 = call double @sqrt(double %85)
%87 = load double, double* %19
%88 = call double @sqrt(double %87)
%89 = call double @atan2(double %86, double %88)
store double %89, double* %20
%90 = load double, double* %18
%91 = load double, double* %19
%92 = fmul double %90, %91
%93 = call double @sqrt(double %92)
%94 = load double, double* %20
%95 = fdiv double %93, %94
store double %95, double* %21
%96 = load double, double* %21
%97 = call double @llvm.fmuladd.f64(double 3.000000e+00, double %96, double -1.000000e+00)
%98 = load double, double* %19
%99 = fmul double 2.000000e+00, %98
%100 = fdiv double %97, %99
store double %100, double* %22
%101 = load double, double* %21
%102 = call double @llvm.fmuladd.f64(double 3.000000e+00, double %101, double 1.000000e+00)
%103 = load double, double* %18
%104 = fmul double 2.000000e+00, %103
%105 = fdiv double %102, %104
store double %105, double* %23
%106 = load double, double* %20
%107 = fmul double 2.000000e+00, %106
%108 = fmul double %107, 0x40B8EA228F5C28F6
store double %108, double* %24
%109 = load double, double* %24
%110 = load double, double* %22
%111 = fmul double 0x3F6B7749C3673876, %110
%112 = load double, double* %16
%113 = fmul double %111, %112
%114 = load double, double* %16
%115 = fmul double %113, %114
%116 = load double, double* %17
%117 = fmul double %115, %116
%118 = load double, double* %17
%119 = call double @llvm.fmuladd.f64(double %117, double %118, double 1.000000e+00)
%120 = load double, double* %23
%121 = fmul double 0x3F6B7749C3673876, %120
%122 = load double, double* %14
%123 = fmul double %121, %122
%124 = load double, double* %14
%125 = fmul double %123, %124
%126 = load double, double* %12
%127 = fmul double %125, %126
%128 = load double, double* %12
%129 = fneg double %127
%130 = call double @llvm.fmuladd.f64(double %129, double %128, double %119)
%131 = fmul double %109, %130
ret double %131
}

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