float course_to(float lat1, float long1, float lat2, float long2) {
  float dlon = ((long2 - long1) * 0.017453292519943295769236907684886);
  lat1 = ((lat1)*0.017453292519943295769236907684886);
  lat2 = ((lat2)*0.017453292519943295769236907684886);
  float a1 = sin(dlon) * cos(lat2);
  float a2 = sin(lat1) * cos(lat2) * cos(dlon);
  a2 = cos(lat1) * sin(lat2) - a2;
  a2 = atan2(a1, a2);
  if (a2 < 0.0) {
    a2 += 6.283185307179586476925286766559;
  }
  return ((a2)*57.295779513082320876798154814105);
}


x86 assembly (clang, -O0):
<course_to>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe9e(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe80(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe62(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x40(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x28(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
call   1030 <atan2@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    12e4 <course_to+0x1b4>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd31(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd1b(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<course_to>:
sub    $0x28,%rsp
subss  %xmm1,%xmm3
xorps  %xmm1,%xmm1
cvtss2sd %xmm3,%xmm1
movsd  0xeb9(%rip),%xmm3
mulsd  %xmm3,%xmm1
cvtsd2ss %xmm1,%xmm1
cvtss2sd %xmm0,%xmm0
mulsd  %xmm3,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
mulsd  %xmm3,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movsd  %xmm0,0x18(%rsp)
call   1040 <sin@plt>
movsd  %xmm0,0x20(%rsp)
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
call   1050 <cos@plt>
mulsd  0x20(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x20(%rsp)
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,(%rsp)
call   1040 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
call   1050 <cos@plt>
mulsd  0x10(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
movss  0x18(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm1
movss  0x20(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
call   1030 <atan2@plt>
cvtsd2ss %xmm0,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
addsd  0xdb1(%rip),%xmm1
cvtsd2ss %xmm1,%xmm1
xorps  %xmm2,%xmm2
movaps %xmm0,%xmm3
cmpltss %xmm2,%xmm3
movaps %xmm3,%xmm2
andnps %xmm0,%xmm2
andps  %xmm1,%xmm3
orps   %xmm2,%xmm3
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
mulsd  0xd8f(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define float @course_to(float %0, float %1, float %2, float %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
store float %0, float* %5
store float %1, float* %6
store float %2, float* %7
store float %3, float* %8
%12 = load float, float* %8
%13 = load float, float* %6
%14 = fsub float %12, %13
%15 = fpext float %14 to double
%16 = fmul double %15, 0x3F91DF46A2529D39
%17 = fptrunc double %16 to float
store float %17, float* %9
%18 = load float, float* %5
%19 = fpext float %18 to double
%20 = fmul double %19, 0x3F91DF46A2529D39
%21 = fptrunc double %20 to float
store float %21, float* %5
%22 = load float, float* %7
%23 = fpext float %22 to double
%24 = fmul double %23, 0x3F91DF46A2529D39
%25 = fptrunc double %24 to float
store float %25, float* %7
%26 = load float, float* %9
%27 = fpext float %26 to double
%28 = call double @sin(double %27)
%29 = load float, float* %7
%30 = fpext float %29 to double
%31 = call double @cos(double %30)
%32 = fmul double %28, %31
%33 = fptrunc double %32 to float
store float %33, float* %10
%34 = load float, float* %5
%35 = fpext float %34 to double
%36 = call double @sin(double %35)
%37 = load float, float* %7
%38 = fpext float %37 to double
%39 = call double @cos(double %38)
%40 = fmul double %36, %39
%41 = load float, float* %9
%42 = fpext float %41 to double
%43 = call double @cos(double %42)
%44 = fmul double %40, %43
%45 = fptrunc double %44 to float
store float %45, float* %11
%46 = load float, float* %5
%47 = fpext float %46 to double
%48 = call double @cos(double %47)
%49 = load float, float* %7
%50 = fpext float %49 to double
%51 = call double @sin(double %50)
%52 = load float, float* %11
%53 = fpext float %52 to double
%54 = fneg double %53
%55 = call double @llvm.fmuladd.f64(double %48, double %51, double %54)
%56 = fptrunc double %55 to float
store float %56, float* %11
%57 = load float, float* %10
%58 = fpext float %57 to double
%59 = load float, float* %11
%60 = fpext float %59 to double
%61 = call double @atan2(double %58, double %60)
%62 = fptrunc double %61 to float
store float %62, float* %11
%63 = load float, float* %11
%64 = fpext float %63 to double
%65 = fcmp olt double %64, 0.000000e+00
br i1 %65, label %66, label %71
66: ; preds = %4
%67 = load float, float* %11
%68 = fpext float %67 to double
%69 = fadd double %68, 0x401921FB54442D18
%70 = fptrunc double %69 to float
store float %70, float* %11
br label %71
71: ; preds = %66, %4
%72 = load float, float* %11
%73 = fpext float %72 to double
%74 = fmul double %73, 0x404CA5DC1A63C1F8
%75 = fptrunc double %74 to float
ret float %75
}

LLVM IR (-O2):
define float @course_to(float %0, float %1, float %2, float %3) {
%5 = fsub float %3, %1
%6 = fpext float %5 to double
%7 = fmul double %6, 0x3F91DF46A2529D39
%8 = fptrunc double %7 to float
%9 = fpext float %0 to double
%10 = fmul double %9, 0x3F91DF46A2529D39
%11 = fptrunc double %10 to float
%12 = fpext float %2 to double
%13 = fmul double %12, 0x3F91DF46A2529D39
%14 = fptrunc double %13 to float
%15 = fpext float %8 to double
%16 = tail call double @sin(double %15)
%17 = fpext float %14 to double
%18 = tail call double @cos(double %17)
%19 = fmul double %16, %18
%20 = fptrunc double %19 to float
%21 = fpext float %11 to double
%22 = tail call double @sin(double %21)
%23 = tail call double @cos(double %17)
%24 = fmul double %22, %23
%25 = tail call double @cos(double %15)
%26 = fmul double %24, %25
%27 = fptrunc double %26 to float
%28 = tail call double @cos(double %21)
%29 = tail call double @sin(double %17)
%30 = fpext float %27 to double
%31 = fneg double %30
%32 = tail call double @llvm.fmuladd.f64(double %28, double %29, double %31)
%33 = fptrunc double %32 to float
%34 = fpext float %20 to double
%35 = fpext float %33 to double
%36 = tail call double @atan2(double %34, double %35)
%37 = fptrunc double %36 to float
%38 = fcmp olt float %37, 0.000000e+00
%39 = fpext float %37 to double
%40 = fadd double %39, 0x401921FB54442D18
%41 = fptrunc double %40 to float
%42 = select i1 %38, float %41, float %37
%43 = fpext float %42 to double
%44 = fmul double %43, 0x404CA5DC1A63C1F8
%45 = fptrunc double %44 to float
ret float %45
}