#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 atan2(double, double);
double cos(double);
double fabs(double);
double sin(double);
double sqrt(double);
void GreatCircle(double PointA_Latitude, double PointA_Longitude,
                 double PointB_Latitude, double PointB_Longitude,
                 double *GreatCircleDistance, double *GreatCircleBearing) {
  double Cos_PointA_Latitude;
  double Cos_PointB_Latitude;
  double Sin_PointA_Latitude;
  double Sin_PointB_Latitude;
  double Delta_Longitude;
  double Cos_Delta_Longitude;
  double Sin_Delta_Longitude;
  double Sin_Distance;
  double Cos_Distance;
  double Sin_Bearing;
  double Cos_Bearing;
  double intermeadiate;
  Cos_PointA_Latitude = cos(PointA_Latitude);
  Cos_PointB_Latitude = cos(PointB_Latitude);
  Sin_PointA_Latitude = sin(PointA_Latitude);
  Sin_PointB_Latitude = sin(PointB_Latitude);
  Delta_Longitude = PointB_Longitude - PointA_Longitude;
  Cos_Delta_Longitude = cos(Delta_Longitude);
  Sin_Delta_Longitude = sin(Delta_Longitude);
  Cos_Distance =
      Sin_PointA_Latitude * Sin_PointB_Latitude +
      Cos_PointA_Latitude * Cos_PointB_Latitude * Cos_Delta_Longitude;
  intermeadiate =
      ((Cos_PointB_Latitude * Sin_Delta_Longitude) *
       (Cos_PointB_Latitude * Sin_Delta_Longitude)) +
      ((Cos_PointA_Latitude * Sin_PointB_Latitude -
        Sin_PointA_Latitude * Cos_PointB_Latitude * Cos_Delta_Longitude) *
       (Cos_PointA_Latitude * Sin_PointB_Latitude -
        Sin_PointA_Latitude * Cos_PointB_Latitude * Cos_Delta_Longitude));
  Sin_Distance = sqrt(fabs(intermeadiate));
  if (fabs(Sin_Distance) > .0000001 || fabs(Cos_Distance) > .0000001)
    *GreatCircleDistance = atan2(Sin_Distance, Cos_Distance);
  else
    *GreatCircleDistance = 0.0;
  Sin_Bearing = Sin_Delta_Longitude * Cos_PointB_Latitude;
  Cos_Bearing = Cos_PointA_Latitude * Sin_PointB_Latitude -
                Sin_PointA_Latitude * Cos_PointB_Latitude * Cos_Delta_Longitude;
  intermeadiate = atan2(Sin_Bearing, Cos_Bearing);
  while (intermeadiate < 0.0)
    intermeadiate += 2.0 * 3.14159265358979323846;
  *GreatCircleBearing = intermeadiate;
}


x86 assembly (clang, -O0):
<GreatCircle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  -0x60(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
mulsd  -0x68(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm4
movsd  -0x48(%rbp),%xmm3
mulsd  -0x40(%rbp),%xmm3
mulsd  -0x60(%rbp),%xmm3
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm1
addsd  %xmm3,%xmm1
movsd  -0x38(%rbp),%xmm3
movsd  -0x50(%rbp),%xmm5
movsd  -0x48(%rbp),%xmm4
mulsd  -0x40(%rbp),%xmm4
mulsd  -0x60(%rbp),%xmm4
movq   %xmm4,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm4
mulsd  %xmm5,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
movaps 0xd73(%rip),%xmm1
pand   %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
movaps 0xd59(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xd3d(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     12ef <GreatCircle+0x1af>
movsd  -0x78(%rbp),%xmm0
movaps 0xd37(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xd1b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    130b <GreatCircle+0x1cb>
movsd  -0x70(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm1
call   1030 <atan2@plt>
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1316 <GreatCircle+0x1d6>
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
movsd  -0x68(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  -0x60(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
movsd  -0x88(%rbp),%xmm1
ff
call   1030 <atan2@plt>
movsd  %xmm0,-0x90(%rbp)
ff
xorps  %xmm0,%xmm0
ucomisd -0x90(%rbp),%xmm0
ff
jbe    13ad <GreatCircle+0x26d>
movsd  0xc70(%rip),%xmm0
addsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x90(%rbp)
ff
jmp    137f <GreatCircle+0x23f>
movsd  -0x90(%rbp),%xmm0
ff
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GreatCircle>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm3,0x8(%rsp)
movsd  %xmm2,(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x20(%rsp)
call   1050 <cos@plt>
movsd  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x20(%rsp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,0x20(%rsp)
movsd  (%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1050 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
movapd 0x20(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movapd %xmm2,%xmm3
movsd  0x30(%rsp),%xmm4
mulsd  %xmm4,%xmm3
movsd  0x10(%rsp),%xmm5
mulsd  %xmm5,%xmm3
mulsd  %xmm4,%xmm0
mulsd  %xmm1,%xmm4
mulsd  %xmm5,%xmm4
movsd  (%rsp),%xmm5
mulsd  %xmm5,%xmm2
subsd  %xmm4,%xmm2
movsd  %xmm2,0x18(%rsp)
mulsd  %xmm2,%xmm2
movsd  %xmm0,0x8(%rsp)
mulsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
andpd  0xddd(%rip),%xmm0
mulsd  %xmm5,%xmm1
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm0
jb     1237 <GreatCircle+0xf7>
sqrtsd %xmm0,%xmm0
jmp    1256 <GreatCircle+0x116>
movapd %xmm1,0x20(%rsp)
movsd  %xmm3,(%rsp)
call   1060 <sqrt@plt>
xorpd  %xmm4,%xmm4
movsd  (%rsp),%xmm3
movapd 0x20(%rsp),%xmm1
addsd  %xmm3,%xmm1
movapd 0xd9e(%rip),%xmm3
movapd %xmm0,%xmm2
andpd  %xmm3,%xmm2
ucomisd 0xd9e(%rip),%xmm2
ja     1282 <GreatCircle+0x142>
andpd  %xmm1,%xmm3
ucomisd 0xd90(%rip),%xmm3
jbe    128b <GreatCircle+0x14b>
call   1030 <atan2@plt>
movapd %xmm0,%xmm4
movsd  %xmm4,(%rbx)
movsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
call   1030 <atan2@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    12ca <GreatCircle+0x18a>
movsd  0xd66(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
addsd  %xmm2,%xmm0
ucomisd %xmm0,%xmm1
ja     12c0 <GreatCircle+0x180>
movsd  %xmm0,(%r14)
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @GreatCircle(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
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = 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
%25 = load double, double* %7
%26 = call double @cos(double %25)
store double %26, double* %13
%27 = load double, double* %9
%28 = call double @cos(double %27)
store double %28, double* %14
%29 = load double, double* %7
%30 = call double @sin(double %29)
store double %30, double* %15
%31 = load double, double* %9
%32 = call double @sin(double %31)
store double %32, double* %16
%33 = load double, double* %10
%34 = load double, double* %8
%35 = fsub double %33, %34
store double %35, double* %17
%36 = load double, double* %17
%37 = call double @cos(double %36)
store double %37, double* %18
%38 = load double, double* %17
%39 = call double @sin(double %38)
store double %39, double* %19
%40 = load double, double* %15
%41 = load double, double* %16
%42 = load double, double* %13
%43 = load double, double* %14
%44 = fmul double %42, %43
%45 = load double, double* %18
%46 = fmul double %44, %45
%47 = call double @llvm.fmuladd.f64(double %40, double %41, double %46)
store double %47, double* %21
%48 = load double, double* %14
%49 = load double, double* %19
%50 = fmul double %48, %49
%51 = load double, double* %14
%52 = load double, double* %19
%53 = fmul double %51, %52
%54 = load double, double* %13
%55 = load double, double* %16
%56 = load double, double* %15
%57 = load double, double* %14
%58 = fmul double %56, %57
%59 = load double, double* %18
%60 = fmul double %58, %59
%61 = fneg double %60
%62 = call double @llvm.fmuladd.f64(double %54, double %55, double %61)
%63 = load double, double* %13
%64 = load double, double* %16
%65 = load double, double* %15
%66 = load double, double* %14
%67 = fmul double %65, %66
%68 = load double, double* %18
%69 = fmul double %67, %68
%70 = fneg double %69
%71 = call double @llvm.fmuladd.f64(double %63, double %64, double %70)
%72 = fmul double %62, %71
%73 = call double @llvm.fmuladd.f64(double %50, double %53, double %72)
store double %73, double* %24
%74 = load double, double* %24
%75 = call double @llvm.fabs.f64(double %74)
%76 = call double @sqrt(double %75)
store double %76, double* %20
%77 = load double, double* %20
%78 = call double @llvm.fabs.f64(double %77)
%79 = fcmp ogt double %78, 0x3E7AD7F29ABCAF48
br i1 %79, label %84, label %80
80: ; preds = %6
%81 = load double, double* %21
%82 = call double @llvm.fabs.f64(double %81)
%83 = fcmp ogt double %82, 0x3E7AD7F29ABCAF48
br i1 %83, label %84, label %89
84: ; preds = %80, %6
%85 = load double, double* %20
%86 = load double, double* %21
%87 = call double @atan2(double %85, double %86)
%88 = load double*, double** %11
store double %87, double* %88
br label %91
89: ; preds = %80
%90 = load double*, double** %11
store double 0.000000e+00, double* %90
br label %91
91: ; preds = %89, %84
%92 = load double, double* %19
%93 = load double, double* %14
%94 = fmul double %92, %93
store double %94, double* %22
%95 = load double, double* %13
%96 = load double, double* %16
%97 = load double, double* %15
%98 = load double, double* %14
%99 = fmul double %97, %98
%100 = load double, double* %18
%101 = fmul double %99, %100
%102 = fneg double %101
%103 = call double @llvm.fmuladd.f64(double %95, double %96, double %102)
store double %103, double* %23
%104 = load double, double* %22
%105 = load double, double* %23
%106 = call double @atan2(double %104, double %105)
store double %106, double* %24
br label %107
107: ; preds = %110, %91
%108 = load double, double* %24
%109 = fcmp olt double %108, 0.000000e+00
br i1 %109, label %110, label %113
110: ; preds = %107
%111 = load double, double* %24
%112 = fadd double %111, 0x401921FB54442D18
store double %112, double* %24
br label %107
113: ; preds = %107
%114 = load double, double* %24
%115 = load double*, double** %12
store double %114, double* %115
ret void
}

LLVM IR (-O2):
define void @GreatCircle(double %0, double %1, double %2, double %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = tail call double @cos(double %0)
%8 = tail call double @cos(double %2)
%9 = tail call double @sin(double %0)
%10 = tail call double @sin(double %2)
%11 = fsub double %3, %1
%12 = tail call double @cos(double %11)
%13 = tail call double @sin(double %11)
%14 = fmul double %7, %8
%15 = fmul double %14, %12
%16 = tail call double @llvm.fmuladd.f64(double %9, double %10, double %15)
%17 = fmul double %8, %13
%18 = fneg double %9
%19 = fmul double %8, %18
%20 = fmul double %19, %12
%21 = tail call double @llvm.fmuladd.f64(double %7, double %10, double %20)
%22 = fmul double %21, %21
%23 = tail call double @llvm.fmuladd.f64(double %17, double %17, double %22)
%24 = tail call double @llvm.fabs.f64(double %23)
%25 = tail call double @sqrt(double %24)
%26 = tail call double @llvm.fabs.f64(double %25)
%27 = fcmp ogt double %26, 0x3E7AD7F29ABCAF48
%28 = tail call double @llvm.fabs.f64(double %16)
%29 = fcmp ogt double %28, 0x3E7AD7F29ABCAF48
%30 = select i1 %27, i1 true, i1 %29
br i1 %30, label %31, label %33
31: ; preds = %6
%32 = tail call double @atan2(double %25, double %16)
br label %33
33: ; preds = %6, %31
%34 = phi double [ %32, %31 ], [ 0.000000e+00, %6 ]
store double %34, double* %4
%35 = tail call double @atan2(double %17, double %21)
%36 = fcmp olt double %35, 0.000000e+00
br i1 %36, label %37, label %41
37: ; preds = %33, %37
%38 = phi double [ %39, %37 ], [ %35, %33 ]
%39 = fadd double %38, 0x401921FB54442D18
%40 = fcmp olt double %39, 0.000000e+00
br i1 %40, label %37, label %41
41: ; preds = %37, %33
%42 = phi double [ %35, %33 ], [ %39, %37 ]
store double %42, double* %5
ret void
}