#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 /*<<< orphan*/);
double cos(double);
double sin(double);
int /*<<< orphan*/ sqrt(double);
double DistanceAngle(double LatA, double LongA, double LatB, double LongB) {
  double dlon = LongB - LongA;
  double dlat = LatB - LatA;
  double sindlat2 = sin(dlat / 2);
  double sindlon2 = sin(dlon / 2);
  double corde =
      sindlat2 * sindlat2 + cos(LatA) * cos(LatB) * sindlon2 * sindlon2;
  if (corde > 1)
    corde = 1;
  return 2 * asin(sqrt(corde));
}


x86 assembly (clang, -O0):
<DistanceAngle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe81(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe66(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
movsd  -0x60(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  0xde9(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    122e <DistanceAngle+0xee>
movsd  0xdd7(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1060 <sqrt@plt>
mov    %eax,%edi
call   1040 <asin@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DistanceAngle>:
sub    $0x28,%rsp
movsd  %xmm2,0x18(%rsp)
movapd %xmm0,%xmm4
movsd  %xmm0,0x10(%rsp)
subsd  %xmm1,%xmm3
movsd  %xmm3,0x8(%rsp)
movapd %xmm2,%xmm0
subsd  %xmm4,%xmm0
mulsd  0xe92(%rip),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xe79(%rip),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
call   1050 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movsd  0x20(%rsp),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe30(%rip),%xmm0
minsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
mov    %eax,%edi
call   1040 <asin@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add    $0x28,%rsp
ret

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

LLVM IR (-O2):
define double @DistanceAngle(double %0, double %1, double %2, double %3) {
%5 = fsub double %3, %1
%6 = fsub double %2, %0
%7 = fmul double %6, 5.000000e-01
%8 = tail call double @sin(double %7)
%9 = fmul double %5, 5.000000e-01
%10 = tail call double @sin(double %9)
%11 = tail call double @cos(double %0)
%12 = tail call double @cos(double %2)
%13 = fmul double %11, %12
%14 = fmul double %10, %13
%15 = fmul double %10, %14
%16 = tail call double @llvm.fmuladd.f64(double %8, double %8, double %15)
%17 = fcmp ogt double %16, 1.000000e+00
%18 = select i1 %17, double 1.000000e+00, double %16
%19 = tail call i32 @sqrt(double %18)
%20 = tail call i32 @asin(i32 %19)
%21 = shl nsw i32 %20, 1
%22 = sitofp i32 %21 to double
ret double %22
}