#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 asin(int);
double cos(double);
double sin(double);
int sqrt(double);
void DistCompute(double R, double lat1, double lon1, double lat2, double lon2,
                 double *dist) {
  double dLat;
  double dLon;
  double a;
  double c;
  dLon = (lon2 - lon1) * 0.0087266462599716478846;
  dLat = (lat2 - lat1) * 0.0087266462599716478846;
  a = sin(dLat) * sin(dLat) + cos(lat1 * 0.017453292519943295769) *
                                  cos(lat2 * 0.017453292519943295769) *
                                  sin(dLon) * sin(dLon);
  c = (sqrt(a) < 1) ? 2 * asin(sqrt(a)) : 180;
  *dist = R * c;
}


x86 assembly (clang, -O0):
<DistCompute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
mov    %rdi,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  0xe8e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xe73(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  0xe3c(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  0xe25(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <sin@plt>
movsd  -0x68(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1060 <sqrt@plt>
cmp    $0x1,%eax
jge    126d <DistCompute+0x12d>
movsd  -0x48(%rbp),%xmm0
call   1060 <sqrt@plt>
mov    %eax,%edi
call   1040 <asin@plt>
shl    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    127a <DistCompute+0x13a>
mov    $0xb4,%eax
mov    %eax,-0x7c(%rbp)
jmp    127a <DistCompute+0x13a>
mov    -0x7c(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DistCompute>:
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
movsd  %xmm3,(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x28(%rsp)
subsd  %xmm2,%xmm4
movsd  0xe9b(%rip),%xmm0
mulsd  %xmm0,%xmm4
movsd  %xmm4,0x18(%rsp)
subsd  %xmm1,%xmm3
mulsd  %xmm0,%xmm3
movsd  %xmm3,0x8(%rsp)
movapd %xmm3,%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0xe5d(%rip),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
mulsd  0xe45(%rip),%xmm0
call   1050 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
call   1060 <sqrt@plt>
test   %eax,%eax
jle    1225 <DistCompute+0xe5>
movsd  0xded(%rip),%xmm0
jmp    1240 <DistCompute+0x100>
movsd  0x8(%rsp),%xmm0
call   1060 <sqrt@plt>
mov    %eax,%edi
call   1040 <asin@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x28(%rsp),%xmm0
movsd  %xmm0,(%rbx)
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @DistCompute(double %0, double %1, double %2, double %3, double %4, double* %5) {
%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
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store double %4, double* %11
store double* %5, double** %12
%17 = load double, double* %11
%18 = load double, double* %9
%19 = fsub double %17, %18
%20 = fmul double %19, 0x3F81DF46A2529D39
store double %20, double* %14
%21 = load double, double* %10
%22 = load double, double* %8
%23 = fsub double %21, %22
%24 = fmul double %23, 0x3F81DF46A2529D39
store double %24, double* %13
%25 = load double, double* %13
%26 = call double @sin(double %25)
%27 = load double, double* %13
%28 = call double @sin(double %27)
%29 = load double, double* %8
%30 = fmul double %29, 0x3F91DF46A2529D39
%31 = call double @cos(double %30)
%32 = load double, double* %10
%33 = fmul double %32, 0x3F91DF46A2529D39
%34 = call double @cos(double %33)
%35 = fmul double %31, %34
%36 = load double, double* %14
%37 = call double @sin(double %36)
%38 = fmul double %35, %37
%39 = load double, double* %14
%40 = call double @sin(double %39)
%41 = fmul double %38, %40
%42 = call double @llvm.fmuladd.f64(double %26, double %28, double %41)
store double %42, double* %15
%43 = load double, double* %15
%44 = call i32 @sqrt(double %43)
%45 = icmp slt i32 %44, 1
br i1 %45, label %46, label %51
46: ; preds = %6
%47 = load double, double* %15
%48 = call i32 @sqrt(double %47)
%49 = call i32 @asin(i32 %48)
%50 = mul nsw i32 2, %49
br label %52
51: ; preds = %6
br label %52
52: ; preds = %51, %46
%53 = phi i32 [ %50, %46 ], [ 180, %51 ]
%54 = sitofp i32 %53 to double
store double %54, double* %16
%55 = load double, double* %7
%56 = load double, double* %16
%57 = fmul double %55, %56
%58 = load double*, double** %12
store double %57, double* %58
ret void
}

LLVM IR (-O2):
define void @DistCompute(double %0, double %1, double %2, double %3, double %4, double* nocapture writeonly %5) {
%7 = fsub double %4, %2
%8 = fmul double %7, 0x3F81DF46A2529D39
%9 = fsub double %3, %1
%10 = fmul double %9, 0x3F81DF46A2529D39
%11 = tail call double @sin(double %10)
%12 = tail call double @sin(double %10)
%13 = fmul double %1, 0x3F91DF46A2529D39
%14 = tail call double @cos(double %13)
%15 = fmul double %3, 0x3F91DF46A2529D39
%16 = tail call double @cos(double %15)
%17 = fmul double %14, %16
%18 = tail call double @sin(double %8)
%19 = fmul double %17, %18
%20 = tail call double @sin(double %8)
%21 = fmul double %19, %20
%22 = tail call double @llvm.fmuladd.f64(double %11, double %12, double %21)
%23 = tail call i32 @sqrt(double %22)
%24 = icmp slt i32 %23, 1
br i1 %24, label %25, label %30
25: ; preds = %6
%26 = tail call i32 @sqrt(double %22)
%27 = tail call i32 @asin(i32 %26)
%28 = shl nsw i32 %27, 1
%29 = sitofp i32 %28 to double
br label %30
30: ; preds = %6, %25
%31 = phi double [ %29, %25 ], [ 1.800000e+02, %6 ]
%32 = fmul double %31, %0
store double %32, double* %5
ret void
}