#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 FLT_MIN;
double M_PI;
double acos(double);
double atan2(double, double);
double cos(double);
double fabs(double);
scalar_t__ isnan(double);
double sin(double);
double GCAzimuth(double lat1, double lon1, double lat2, double lon2) {
  double lonA = lon1 * (M_PI / 180.0);
  double latA = lat1 * (M_PI / 180.0);
  double lonB = lon2 * (M_PI / 180.0);
  double latB = lat2 * (M_PI / 180.0);
  double dist =
      acos(sin(latA) * sin(latB) + cos(latA) * cos(latB) * cos((lonB - lonA)));
  if (dist < FLT_MIN) {
    return (0.0);
  }
  double cosAzimuth =
      (cos(latA) * sin(latB) - sin(latA) * cos(latB) * cos((lonB - lonA))) /
      sin(dist);
  double sinAzimuth = cos(latB) * sin((lonB - lonA)) / sin(dist);
  double az = atan2(sinAzimuth, cosAzimuth) / (M_PI / 180.0);
  if (isnan(az) && fabs(lon2 - lon1) < 0.000001) {
    if (lat1 > lat2) {
      az = 180.0;
    } else {
      az = 0.0;
    }
  }
  if (az < 0.0) {
    az += 360.0;
  }
  return (az);
}


x86 assembly (clang, -O0):
<GCAzimuth>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    0x2e6d(%rip),%rax
movsd  (%rax),%xmm1
movsd  0xe79(%rip),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    0x2e48(%rip),%rax
movsd  (%rax),%xmm1
movsd  0xe54(%rip),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    0x2e23(%rip),%rax
movsd  (%rax),%xmm1
movsd  0xe2f(%rip),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    0x2dfe(%rip),%rax
movsd  (%rax),%xmm1
movsd  0xe0a(%rip),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
call   1070 <cos@plt>
movsd  -0x80(%rbp),%xmm1
movsd  -0x78(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <acos@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm1
mov    0x2d4c(%rip),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    12af <GCAzimuth+0x15f>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1492 <GCAzimuth+0x342>
movsd  -0x38(%rbp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0xc0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
call   1070 <cos@plt>
movsd  -0xb8(%rbp),%xmm1
ff
movsd  -0xb0(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0xa8(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
call   1030 <atan2@plt>
mov    0x2c03(%rip),%rax
movsd  (%rax),%xmm1
movsd  0xc0f(%rip),%xmm2
divsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
call   1060 <isnan@plt>
cmp    $0x0,%rax
je     1468 <GCAzimuth+0x318>
movsd  -0x28(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
movaps 0xbfd(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xbd9(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1468 <GCAzimuth+0x318>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    145b <GCAzimuth+0x30b>
movsd  0xbaf(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    1463 <GCAzimuth+0x313>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    1468 <GCAzimuth+0x318>
xorps  %xmm0,%xmm0
ucomisd -0x68(%rbp),%xmm0
jbe    1488 <GCAzimuth+0x338>
movsd  0xb92(%rip),%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GCAzimuth>:
push   %rbx
sub    $0x80,%rsp
mov    0x2e89(%rip),%rbx
movsd  (%rbx),%xmm5
divsd  0xe95(%rip),%xmm5
movapd %xmm5,%xmm4
movsd  %xmm1,0x58(%rsp)
mulsd  %xmm1,%xmm4
movapd %xmm5,%xmm1
movsd  %xmm0,0x50(%rsp)
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x30(%rsp)
movapd %xmm5,%xmm0
movapd %xmm3,0x70(%rsp)
mulsd  %xmm3,%xmm0
subsd  %xmm4,%xmm0
movsd  %xmm0,0x40(%rsp)
movapd %xmm2,0x60(%rsp)
mulsd  %xmm2,%xmm5
movsd  %xmm5,0x10(%rsp)
movapd %xmm1,%xmm0
call   1050 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,0x38(%rsp)
movsd  0x30(%rsp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x10(%rsp),%xmm0
call   1070 <cos@plt>
mulsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x28(%rsp)
movsd  0x40(%rsp),%xmm0
call   1070 <cos@plt>
mulsd  0x28(%rsp),%xmm0
movsd  0x38(%rsp),%xmm1
mulsd  0x8(%rsp),%xmm1
addsd  %xmm1,%xmm0
call   1040 <acos@plt>
movapd %xmm0,%xmm2
mov    0x2db2(%rip),%rax
movsd  (%rax),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm1
ja     13b0 <GCAzimuth+0x260>
movsd  0x30(%rsp),%xmm0
movsd  %xmm2,0x38(%rsp)
call   1070 <cos@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x30(%rsp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x10(%rsp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,0x48(%rsp)
movsd  0x40(%rsp),%xmm0
call   1070 <cos@plt>
movsd  0x48(%rsp),%xmm1
mulsd  0x30(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  0x28(%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x38(%rsp),%xmm0
call   1050 <sin@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x40(%rsp),%xmm0
call   1050 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x38(%rsp),%xmm0
call   1050 <sin@plt>
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
call   1030 <atan2@plt>
movsd  (%rbx),%xmm1
divsd  0xcd2(%rip),%xmm1
divsd  %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
call   1060 <isnan@plt>
test   %rax,%rax
je     1385 <GCAzimuth+0x235>
movapd 0x70(%rsp),%xmm1
subsd  0x58(%rsp),%xmm1
andpd  0xcca(%rip),%xmm1
movsd  0xcaa(%rip),%xmm0
ucomisd %xmm1,%xmm0
movapd 0x10(%rsp),%xmm3
jbe    138b <GCAzimuth+0x23b>
movapd 0x60(%rsp),%xmm0
cmpltsd 0x50(%rsp),%xmm0
movsd  0xc81(%rip),%xmm3
andpd  %xmm0,%xmm3
jmp    138b <GCAzimuth+0x23b>
movapd 0x10(%rsp),%xmm3
movsd  0xc7d(%rip),%xmm1
addsd  %xmm3,%xmm1
xorpd  %xmm2,%xmm2
movapd %xmm3,%xmm0
cmpltsd %xmm2,%xmm0
andpd  %xmm0,%xmm1
andnpd %xmm3,%xmm0
orpd   %xmm1,%xmm0
add    $0x80,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
@FLT_MIN = global double 0.000000e+00
define double @GCAzimuth(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 @sin(double %8)
%12 = tail call double @sin(double %10)
%13 = tail call double @cos(double %8)
%14 = tail call double @cos(double %10)
%15 = fmul double %13, %14
%16 = fsub double %9, %7
%17 = tail call double @cos(double %16)
%18 = fmul double %15, %17
%19 = tail call double @llvm.fmuladd.f64(double %11, double %12, double %18)
%20 = tail call double @acos(double %19)
%21 = load double, double* @FLT_MIN
%22 = fcmp olt double %20, %21
br i1 %22, label %58, label %23
23: ; preds = %4
%24 = tail call double @cos(double %8)
%25 = tail call double @sin(double %10)
%26 = tail call double @sin(double %8)
%27 = tail call double @cos(double %10)
%28 = tail call double @cos(double %16)
%29 = fneg double %26
%30 = fmul double %27, %29
%31 = fmul double %30, %28
%32 = tail call double @llvm.fmuladd.f64(double %24, double %25, double %31)
%33 = tail call double @sin(double %20)
%34 = fdiv double %32, %33
%35 = tail call double @cos(double %10)
%36 = tail call double @sin(double %16)
%37 = fmul double %35, %36
%38 = tail call double @sin(double %20)
%39 = fdiv double %37, %38
%40 = tail call double @atan2(double %39, double %34)
%41 = load double, double* @M_PI
%42 = fdiv double %41, 1.800000e+02
%43 = fdiv double %40, %42
%44 = tail call i64 @isnan(double %43)
%45 = icmp eq i64 %44, 0
br i1 %45, label %53, label %46
46: ; preds = %23
%47 = fsub double %3, %1
%48 = tail call double @llvm.fabs.f64(double %47)
%49 = fcmp olt double %48, 0x3EB0C6F7A0B5ED8D
br i1 %49, label %50, label %53
50: ; preds = %46
%51 = fcmp ogt double %0, %2
%52 = select i1 %51, double 1.800000e+02, double 0.000000e+00
br label %53
53: ; preds = %50, %46, %23
%54 = phi double [ %43, %46 ], [ %43, %23 ], [ %52, %50 ]
%55 = fcmp olt double %54, 0.000000e+00
%56 = fadd double %54, 3.600000e+02
%57 = select i1 %55, double %56, double %54
br label %58
58: ; preds = %4, %53
%59 = phi double [ %57, %53 ], [ 0.000000e+00, %4 ]
ret double %59
}