#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(int /*<<< orphan*/);
double cos(double);
double deg2rad(double);
double sin(double);
int /*<<< orphan*/ sqrt(double);
double distanceEarth(double lat1d, double lon1d, double lat2d, double lon2d) {
  double lat1r, lon1r, lat2r, lon2r, u, v;
  lat1r = deg2rad(lat1d);
  lon1r = deg2rad(lon1d);
  lat2r = deg2rad(lat2d);
  lon2r = deg2rad(lon2d);
  u = sin((lat2r - lat1r) / 2);
  v = sin((lon2r - lon1r) / 2);
  return 2.0 * 6371.0 * asin(sqrt(u * u + cos(lat1r) * cos(lat2r) * v * v));
}


x86 assembly (clang, -O0):
<distanceEarth>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <deg2rad@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <deg2rad@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <deg2rad@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <deg2rad@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  0xe4e(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  0xe2e(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1060 <cos@plt>
movsd  -0x68(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  -0x50(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
mov    %eax,%edi
call   1050 <asin@plt>
movaps %xmm0,%xmm1
movsd  0xdac(%rip),%xmm0
mulsd  %xmm1,%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<distanceEarth>:
sub    $0x28,%rsp
movsd  %xmm3,0x18(%rsp)
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,(%rsp)
call   1030 <deg2rad@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1030 <deg2rad@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <deg2rad@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <deg2rad@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
mulsd  0xe4b(%rip),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x20(%rsp),%xmm0
subsd  (%rsp),%xmm0
mulsd  0xe2d(%rip),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  (%rsp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
mov    %eax,%edi
call   1050 <asin@plt>
mulsd  0xdda(%rip),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @distanceEarth(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
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%15 = load double, double* %5
%16 = call double @deg2rad(double %15)
store double %16, double* %9
%17 = load double, double* %6
%18 = call double @deg2rad(double %17)
store double %18, double* %10
%19 = load double, double* %7
%20 = call double @deg2rad(double %19)
store double %20, double* %11
%21 = load double, double* %8
%22 = call double @deg2rad(double %21)
store double %22, double* %12
%23 = load double, double* %11
%24 = load double, double* %9
%25 = fsub double %23, %24
%26 = fdiv double %25, 2.000000e+00
%27 = call double @sin(double %26)
store double %27, double* %13
%28 = load double, double* %12
%29 = load double, double* %10
%30 = fsub double %28, %29
%31 = fdiv double %30, 2.000000e+00
%32 = call double @sin(double %31)
store double %32, double* %14
%33 = load double, double* %13
%34 = load double, double* %13
%35 = load double, double* %9
%36 = call double @cos(double %35)
%37 = load double, double* %11
%38 = call double @cos(double %37)
%39 = fmul double %36, %38
%40 = load double, double* %14
%41 = fmul double %39, %40
%42 = load double, double* %14
%43 = fmul double %41, %42
%44 = call double @llvm.fmuladd.f64(double %33, double %34, double %43)
%45 = call i32 @sqrt(double %44)
%46 = call double @asin(i32 %45)
%47 = fmul double 1.274200e+04, %46
ret double %47
}

LLVM IR (-O2):
define double @distanceEarth(double %0, double %1, double %2, double %3) {
%5 = tail call double @deg2rad(double %0)
%6 = tail call double @deg2rad(double %1)
%7 = tail call double @deg2rad(double %2)
%8 = tail call double @deg2rad(double %3)
%9 = fsub double %7, %5
%10 = fmul double %9, 5.000000e-01
%11 = tail call double @sin(double %10)
%12 = fsub double %8, %6
%13 = fmul double %12, 5.000000e-01
%14 = tail call double @sin(double %13)
%15 = tail call double @cos(double %5)
%16 = tail call double @cos(double %7)
%17 = fmul double %15, %16
%18 = fmul double %14, %17
%19 = fmul double %14, %18
%20 = tail call double @llvm.fmuladd.f64(double %11, double %11, double %19)
%21 = tail call i32 @sqrt(double %20)
%22 = tail call double @asin(i32 %21)
%23 = fmul double %22, 1.274200e+04
ret double %23
}