#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(int, int);
int cos(double);
int sin(double);
double get_direction(double fLng, double fLat, double tLng, double tLat) {
  double rads;
  double result;
  fLng = (fLng * (3.14159265 / 180));
  fLat = (fLat * (3.14159265 / 180));
  tLng = (tLng * (3.14159265 / 180));
  tLat = (tLat * (3.14159265 / 180));
  rads =
      atan2(sin(tLng - fLng) * cos(tLat),
            cos(fLat) * sin(tLat) - sin(fLat) * cos(tLat) * cos(tLng - fLng));
  result = (rads / (3.14159265 / 180));
  if (result < 0)
    return result + 360;
  else
    return result;
}


x86 assembly (clang, -O0):
<get_direction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  0xeac(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe9a(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe88(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe76(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
mov    %eax,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <cos@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
mov    %eax,-0x4c(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <sin@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x44(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
mov    %eax,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <cos@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x3c(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1050 <cos@plt>
mov    -0x44(%rbp),%esi
mov    -0x40(%rbp),%edi
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
imul   %ecx,%eax
sub    %eax,%esi
call   1030 <atan2@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xdcb(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    1263 <get_direction+0x133>
movsd  0xdb4(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    126d <get_direction+0x13d>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_direction>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movsd  0xebe(%rip),%xmm4
mulsd  %xmm4,%xmm0
mulsd  %xmm4,%xmm1
movsd  %xmm1,0x8(%rsp)
mulsd  %xmm4,%xmm2
subsd  %xmm0,%xmm2
movsd  %xmm2,0x10(%rsp)
mulsd  %xmm4,%xmm3
movsd  %xmm3,(%rsp)
movapd %xmm2,%xmm0
call   1040 <sin@plt>
mov    %eax,%r14d
movsd  (%rsp),%xmm0
call   1050 <cos@plt>
imul   %eax,%r14d
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
mov    %eax,%ebp
movsd  (%rsp),%xmm0
call   1040 <sin@plt>
imul   %eax,%ebp
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
mov    %eax,%r15d
movsd  (%rsp),%xmm0
call   1050 <cos@plt>
mov    %eax,%ebx
imul   %r15d,%ebx
movsd  0x10(%rsp),%xmm0
call   1050 <cos@plt>
imul   %ebx,%eax
sub    %eax,%ebp
mov    %r14d,%edi
mov    %ebp,%esi
call   1030 <atan2@plt>
divsd  0xe25(%rip),%xmm0
movsd  0xe25(%rip),%xmm2
addsd  %xmm0,%xmm2
xorpd  %xmm3,%xmm3
movapd %xmm0,%xmm1
cmpltsd %xmm3,%xmm1
andpd  %xmm1,%xmm2
andnpd %xmm0,%xmm1
orpd   %xmm2,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @get_direction(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
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
%12 = load double, double* %6
%13 = fmul double %12, 0x3F91DF46A1FAE712
store double %13, double* %6
%14 = load double, double* %7
%15 = fmul double %14, 0x3F91DF46A1FAE712
store double %15, double* %7
%16 = load double, double* %8
%17 = fmul double %16, 0x3F91DF46A1FAE712
store double %17, double* %8
%18 = load double, double* %9
%19 = fmul double %18, 0x3F91DF46A1FAE712
store double %19, double* %9
%20 = load double, double* %8
%21 = load double, double* %6
%22 = fsub double %20, %21
%23 = call i32 @sin(double %22)
%24 = load double, double* %9
%25 = call i32 @cos(double %24)
%26 = mul nsw i32 %23, %25
%27 = load double, double* %7
%28 = call i32 @cos(double %27)
%29 = load double, double* %9
%30 = call i32 @sin(double %29)
%31 = mul nsw i32 %28, %30
%32 = load double, double* %7
%33 = call i32 @sin(double %32)
%34 = load double, double* %9
%35 = call i32 @cos(double %34)
%36 = mul nsw i32 %33, %35
%37 = load double, double* %8
%38 = load double, double* %6
%39 = fsub double %37, %38
%40 = call i32 @cos(double %39)
%41 = mul nsw i32 %36, %40
%42 = sub nsw i32 %31, %41
%43 = call double @atan2(i32 %26, i32 %42)
store double %43, double* %10
%44 = load double, double* %10
%45 = fdiv double %44, 0x3F91DF46A1FAE712
store double %45, double* %11
%46 = load double, double* %11
%47 = fcmp olt double %46, 0.000000e+00
br i1 %47, label %48, label %51
48: ; preds = %4
%49 = load double, double* %11
%50 = fadd double %49, 3.600000e+02
store double %50, double* %5
br label %53
51: ; preds = %4
%52 = load double, double* %11
store double %52, double* %5
br label %53
53: ; preds = %51, %48
%54 = load double, double* %5
ret double %54
}

LLVM IR (-O2):
define double @get_direction(double %0, double %1, double %2, double %3) {
%5 = fmul double %0, 0x3F91DF46A1FAE712
%6 = fmul double %1, 0x3F91DF46A1FAE712
%7 = fmul double %2, 0x3F91DF46A1FAE712
%8 = fmul double %3, 0x3F91DF46A1FAE712
%9 = fsub double %7, %5
%10 = tail call i32 @sin(double %9)
%11 = tail call i32 @cos(double %8)
%12 = mul nsw i32 %11, %10
%13 = tail call i32 @cos(double %6)
%14 = tail call i32 @sin(double %8)
%15 = mul nsw i32 %14, %13
%16 = tail call i32 @sin(double %6)
%17 = tail call i32 @cos(double %8)
%18 = mul nsw i32 %17, %16
%19 = tail call i32 @cos(double %9)
%20 = mul nsw i32 %18, %19
%21 = sub nsw i32 %15, %20
%22 = tail call double @atan2(i32 %12, i32 %21)
%23 = fdiv double %22, 0x3F91DF46A1FAE712
%24 = fcmp olt double %23, 0.000000e+00
%25 = fadd double %23, 3.600000e+02
%26 = select i1 %24, double %25, double %23
ret double %26
}