#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 */
int acos(double);
double cos(double);
double sin(double);
double get_dist(double lat1, double long1, double lat2, double long2) {
  double theta1;
  double phi1;
  double theta2;
  double phi2;
  double dtor;
  double term1;
  double term2;
  double term3;
  double temp;
  double dist;
  dtor = 2.0 * 3.1415 / 360.0;
  theta1 = dtor * long1;
  phi1 = dtor * lat1;
  theta2 = dtor * long2;
  phi2 = dtor * lat2;
  term1 = cos(phi1) * cos(theta1) * cos(phi2) * cos(theta2);
  term2 = cos(phi1) * sin(theta1) * cos(phi2) * sin(theta2);
  term3 = sin(phi1) * sin(phi2);
  temp = term1 + term2 + term3;
  temp = (double)(1.0 < temp) ? 1.0 : temp;
  dist = 6371228. * acos(temp);
  return dist;
}


x86 assembly (clang, -O0):
<get_dist>:
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  0xeb1(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0xa8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  0xd3f(%rip),%xmm1
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
cvtsi2sd %eax,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12e9 <get_dist+0x1b9>
jp     12e9 <get_dist+0x1b9>
jmp    12fe <get_dist+0x1ce>
movsd  0xd0f(%rip),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
jmp    130b <get_dist+0x1db>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
call   1030 <acos@plt>
cvtsi2sd %eax,%xmm1
movsd  0xce2(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_dist>:
sub    $0x88,%rsp
movsd  0xec1(%rip),%xmm4
mulsd  %xmm4,%xmm1
movsd  %xmm1,0x28(%rsp)
mulsd  %xmm4,%xmm0
movsd  %xmm0,0x38(%rsp)
mulsd  %xmm4,%xmm3
movsd  %xmm3,0x30(%rsp)
mulsd  %xmm2,%xmm4
movsd  %xmm4,0x8(%rsp)
call   1050 <cos@plt>
movapd %xmm0,0x70(%rsp)
movsd  0x28(%rsp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,0x40(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,0x10(%rsp)
movsd  0x30(%rsp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,0x50(%rsp)
movsd  0x38(%rsp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,0x60(%rsp)
movsd  0x28(%rsp),%xmm0
call   1040 <sin@plt>
movapd 0x70(%rsp),%xmm2
unpcklpd 0x60(%rsp),%xmm2
movapd 0x40(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
mulpd  %xmm2,%xmm1
movapd %xmm1,0x40(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
movapd 0x10(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
mulpd  0x40(%rsp),%xmm1
movapd %xmm1,0x10(%rsp)
movsd  0x30(%rsp),%xmm0
call   1040 <sin@plt>
movapd 0x50(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
mulpd  0x10(%rsp),%xmm1
movapd %xmm1,0x50(%rsp)
movsd  0x38(%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movapd 0x50(%rsp),%xmm2
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
addsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xda9(%rip),%xmm0
minsd  %xmm1,%xmm0
call   1030 <acos@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xd99(%rip),%xmm0
add    $0x88,%rsp
ret

LLVM IR (-O0):
define double @get_dist(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
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
store double 0x3F91DF24171EA105, double* %13
%19 = load double, double* %13
%20 = load double, double* %6
%21 = fmul double %19, %20
store double %21, double* %9
%22 = load double, double* %13
%23 = load double, double* %5
%24 = fmul double %22, %23
store double %24, double* %10
%25 = load double, double* %13
%26 = load double, double* %8
%27 = fmul double %25, %26
store double %27, double* %11
%28 = load double, double* %13
%29 = load double, double* %7
%30 = fmul double %28, %29
store double %30, double* %12
%31 = load double, double* %10
%32 = call double @cos(double %31)
%33 = load double, double* %9
%34 = call double @cos(double %33)
%35 = fmul double %32, %34
%36 = load double, double* %12
%37 = call double @cos(double %36)
%38 = fmul double %35, %37
%39 = load double, double* %11
%40 = call double @cos(double %39)
%41 = fmul double %38, %40
store double %41, double* %14
%42 = load double, double* %10
%43 = call double @cos(double %42)
%44 = load double, double* %9
%45 = call double @sin(double %44)
%46 = fmul double %43, %45
%47 = load double, double* %12
%48 = call double @cos(double %47)
%49 = fmul double %46, %48
%50 = load double, double* %11
%51 = call double @sin(double %50)
%52 = fmul double %49, %51
store double %52, double* %15
%53 = load double, double* %10
%54 = call double @sin(double %53)
%55 = load double, double* %12
%56 = call double @sin(double %55)
%57 = fmul double %54, %56
store double %57, double* %16
%58 = load double, double* %14
%59 = load double, double* %15
%60 = fadd double %58, %59
%61 = load double, double* %16
%62 = fadd double %60, %61
store double %62, double* %17
%63 = load double, double* %17
%64 = fcmp olt double 1.000000e+00, %63
%65 = zext i1 %64 to i32
%66 = sitofp i32 %65 to double
%67 = fcmp une double %66, 0.000000e+00
br i1 %67, label %68, label %69
68: ; preds = %4
br label %71
69: ; preds = %4
%70 = load double, double* %17
br label %71
71: ; preds = %69, %68
%72 = phi double [ 1.000000e+00, %68 ], [ %70, %69 ]
store double %72, double* %17
%73 = load double, double* %17
%74 = call i32 @acos(double %73)
%75 = sitofp i32 %74 to double
%76 = fmul double 0x41584DE700000000, %75
store double %76, double* %18
%77 = load double, double* %18
ret double %77
}

LLVM IR (-O2):
define double @get_dist(double %0, double %1, double %2, double %3) {
%5 = fmul double %1, 0x3F91DF24171EA105
%6 = fmul double %0, 0x3F91DF24171EA105
%7 = fmul double %3, 0x3F91DF24171EA105
%8 = fmul double %2, 0x3F91DF24171EA105
%9 = tail call double @cos(double %6)
%10 = tail call double @cos(double %5)
%11 = tail call double @cos(double %8)
%12 = tail call double @cos(double %7)
%13 = tail call double @cos(double %6)
%14 = tail call double @sin(double %5)
%15 = insertelement <2 x double> poison, double %9, i64 0
%16 = insertelement <2 x double> %15, double %13, i64 1
%17 = insertelement <2 x double> poison, double %10, i64 0
%18 = insertelement <2 x double> %17, double %14, i64 1
%19 = fmul <2 x double> %16, %18
%20 = tail call double @cos(double %8)
%21 = insertelement <2 x double> poison, double %11, i64 0
%22 = insertelement <2 x double> %21, double %20, i64 1
%23 = fmul <2 x double> %19, %22
%24 = tail call double @sin(double %7)
%25 = insertelement <2 x double> poison, double %12, i64 0
%26 = insertelement <2 x double> %25, double %24, i64 1
%27 = fmul <2 x double> %23, %26
%28 = tail call double @sin(double %6)
%29 = tail call double @sin(double %8)
%30 = fmul double %28, %29
%31 = shufflevector <2 x double> %27, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%32 = fadd <2 x double> %27, %31
%33 = extractelement <2 x double> %32, i64 0
%34 = fadd double %33, %30
%35 = fcmp ogt double %34, 1.000000e+00
%36 = select i1 %35, double 1.000000e+00, double %34
%37 = tail call i32 @acos(double %36)
%38 = sitofp i32 %37 to double
%39 = fmul double %38, 0x41584DE700000000
ret double %39
}