#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 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 * 0.01745329252;
  double latA = lat1 * 0.01745329252;
  double lonB = lon2 * 0.01745329252;
  double latB = lat2 * 0.01745329252;
  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) / 0.01745329252;
  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  0xe89(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe77(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe65(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe53(%rip),%xmm0
mulsd  -0x20(%rbp),%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    0x2da0(%rip),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    1263 <GCAzimuth+0x113>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1437 <GCAzimuth+0x2e7>
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>
movsd  0xc66(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
call   1060 <isnan@plt>
cmp    $0x0,%rax
je     140d <GCAzimuth+0x2bd>
movsd  -0x28(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
movaps 0xc58(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xc34(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    140d <GCAzimuth+0x2bd>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1400 <GCAzimuth+0x2b0>
movsd  0xc1a(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    1408 <GCAzimuth+0x2b8>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    140d <GCAzimuth+0x2bd>
xorps  %xmm0,%xmm0
ucomisd -0x68(%rbp),%xmm0
jbe    142d <GCAzimuth+0x2dd>
movsd  0xbf5(%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>:
sub    $0x88,%rsp
movsd  0xea1(%rip),%xmm4
movsd  %xmm1,0x58(%rsp)
mulsd  %xmm4,%xmm1
movsd  %xmm0,0x50(%rsp)
mulsd  %xmm4,%xmm0
movsd  %xmm0,0x30(%rsp)
movapd %xmm3,0x70(%rsp)
mulsd  %xmm4,%xmm3
subsd  %xmm1,%xmm3
movsd  %xmm3,0x40(%rsp)
movapd %xmm2,0x60(%rsp)
mulsd  %xmm2,%xmm4
movsd  %xmm4,0x10(%rsp)
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    0x2dd6(%rip),%rax
movsd  (%rax),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm1
ja     138c <GCAzimuth+0x23c>
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>
divsd  0xcf2(%rip),%xmm0
movapd %xmm0,0x10(%rsp)
call   1060 <isnan@plt>
test   %rax,%rax
je     1361 <GCAzimuth+0x211>
movapd 0x70(%rsp),%xmm1
subsd  0x58(%rsp),%xmm1
andpd  0xcee(%rip),%xmm1
movsd  0xcce(%rip),%xmm0
ucomisd %xmm1,%xmm0
movapd 0x10(%rsp),%xmm3
jbe    1367 <GCAzimuth+0x217>
movapd 0x60(%rsp),%xmm0
cmpltsd 0x50(%rsp),%xmm0
movsd  0xcb5(%rip),%xmm3
andpd  %xmm0,%xmm3
jmp    1367 <GCAzimuth+0x217>
movapd 0x10(%rsp),%xmm3
movsd  0xca9(%rip),%xmm1
addsd  %xmm3,%xmm1
xorpd  %xmm2,%xmm2
movapd %xmm3,%xmm0
cmpltsd %xmm2,%xmm0
andpd  %xmm0,%xmm1
andnpd %xmm3,%xmm0
orpd   %xmm1,%xmm0
add    $0x88,%rsp
ret

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

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