#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 llh_rad_to_metres(double, double, double, double);
double accurate_distance(double lng1, double lat1, double lng2, double lat2) {
  double lat_1 = (M_PI / 180.0) * lat1;
  double lon_1 = (M_PI / 180.0) * lng1;
  double lat_2 = (M_PI / 180.0) * lat2;
  double lon_2 = (M_PI / 180.0) * lng2;
  return llh_rad_to_metres(lon_1, lat_1, lon_2, lat_2);
}


x86 assembly (clang, -O0):
<accurate_distance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    0x2eb5(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xec1(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    0x2e94(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xea0(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    0x2e73(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe7f(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    0x2e52(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe5e(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
call   1030 <llh_rad_to_metres@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<accurate_distance>:
mov    0x2ed1(%rip),%rax
movsd  (%rax),%xmm4
divsd  0xedd(%rip),%xmm4
mulsd  %xmm4,%xmm1
mulsd  %xmm4,%xmm0
mulsd  %xmm4,%xmm3
mulsd  %xmm4,%xmm2
jmp    1030 <llh_rad_to_metres@plt>

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double @accurate_distance(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
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%13 = load double, double* @M_PI
%14 = fdiv double %13, 1.800000e+02
%15 = load double, double* %6
%16 = fmul double %14, %15
store double %16, double* %9
%17 = load double, double* @M_PI
%18 = fdiv double %17, 1.800000e+02
%19 = load double, double* %5
%20 = fmul double %18, %19
store double %20, double* %10
%21 = load double, double* @M_PI
%22 = fdiv double %21, 1.800000e+02
%23 = load double, double* %8
%24 = fmul double %22, %23
store double %24, double* %11
%25 = load double, double* @M_PI
%26 = fdiv double %25, 1.800000e+02
%27 = load double, double* %7
%28 = fmul double %26, %27
store double %28, double* %12
%29 = load double, double* %10
%30 = load double, double* %9
%31 = load double, double* %12
%32 = load double, double* %11
%33 = call double @llh_rad_to_metres(double %29, double %30, double %31, double %32)
ret double %33
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @accurate_distance(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, %1
%8 = fmul double %6, %0
%9 = fmul double %6, %3
%10 = fmul double %6, %2
%11 = tail call double @llh_rad_to_metres(double %8, double %7, double %10, double %9)
ret double %11
}