#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 asin(double);
double atan2(double, double);
double cos(double);
double sin(double);
void LatLonCompute(double R, double lat1, double lon1, double dist, double bear,
                   double *lat2, double *lon2) {
  double A, B, C;
  lat1 *= 0.017453292519943295769;
  lon1 *= 0.017453292519943295769;
  dist = dist / R;
  bear = 3.14159265358979323846 - bear * 0.017453292519943295769;
  *lat2 = asin(cos(dist) * sin(lat1) - sin(dist) * cos(bear) * cos(lat1)) *
          57.295779513082320877;
  A = cos(dist) * cos(lat1);
  B = sin(dist) * cos(bear) * sin(lat1);
  C = sin(dist) * sin(bear);
  *lon2 = atan2(A * sin(lon1) + B * sin(lon1) + C * cos(lon1),
                A * cos(lon1) + B * cos(lon1) - C * sin(lon1)) *
          57.295779513082320877;
}


x86 assembly (clang, -O0):
<LatLonCompute>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
mov    %rdi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
movsd  0xe94(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe82(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe45(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe41(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0xd8(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0xe8(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
call   1060 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0xe8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
call   1060 <cos@plt>
movsd  -0xe0(%rbp),%xmm1
ff
movsd  -0xd8(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0xd0(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <asin@plt>
movsd  0xd7c(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
call   1060 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0xc8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
call   1060 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0xc0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0xb8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0xb0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
movsd  -0xa8(%rbp),%xmm1
ff
movsd  -0xa0(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0x98(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
call   1060 <cos@plt>
movsd  -0x90(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x88(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1060 <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
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
movsd  -0x68(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x58(%rbp),%xmm0
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
call   1030 <atan2@plt>
movsd  0xb81(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LatLonCompute>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  0xeab(%rip),%xmm5
mulsd  %xmm5,%xmm1
movsd  %xmm1,0x8(%rsp)
mulsd  %xmm5,%xmm2
movsd  %xmm2,0x28(%rsp)
divsd  %xmm0,%xmm3
movsd  %xmm3,0x18(%rsp)
mulsd  %xmm5,%xmm4
movsd  0xe89(%rip),%xmm0
subsd  %xmm4,%xmm0
movsd  %xmm0,0x30(%rsp)
movapd %xmm3,%xmm0
call   1060 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x40(%rsp)
movsd  0x30(%rsp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,0x38(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <cos@plt>
movsd  0x38(%rsp),%xmm1
mulsd  0x40(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x20(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
subsd  %xmm1,%xmm0
call   1050 <asin@plt>
mulsd  0xe0d(%rip),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x18(%rsp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <cos@plt>
movsd  0x20(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x30(%rsp),%xmm0
call   1060 <cos@plt>
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x30(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x28(%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
call   1060 <cos@plt>
mulsd  0x18(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  0x28(%rsp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
call   1060 <cos@plt>
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  0x20(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  0x30(%rsp),%xmm0
call   1030 <atan2@plt>
mulsd  0xcaf(%rip),%xmm0
movsd  %xmm0,(%r14)
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @LatLonCompute(double %0, double %1, double %2, double %3, double %4, double* %5, double* %6) {
%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* %8
store double %1, double* %9
store double %2, double* %10
store double %3, double* %11
store double %4, double* %12
store double* %5, double** %13
store double* %6, double** %14
%18 = load double, double* %9
%19 = fmul double %18, 0x3F91DF46A2529D39
store double %19, double* %9
%20 = load double, double* %10
%21 = fmul double %20, 0x3F91DF46A2529D39
store double %21, double* %10
%22 = load double, double* %11
%23 = load double, double* %8
%24 = fdiv double %22, %23
store double %24, double* %11
%25 = load double, double* %12
%26 = fneg double %25
%27 = call double @llvm.fmuladd.f64(double %26, double 0x3F91DF46A2529D39, double 0x400921FB54442D18)
store double %27, double* %12
%28 = load double, double* %11
%29 = call double @cos(double %28)
%30 = load double, double* %9
%31 = call double @sin(double %30)
%32 = load double, double* %11
%33 = call double @sin(double %32)
%34 = load double, double* %12
%35 = call double @cos(double %34)
%36 = fmul double %33, %35
%37 = load double, double* %9
%38 = call double @cos(double %37)
%39 = fmul double %36, %38
%40 = fneg double %39
%41 = call double @llvm.fmuladd.f64(double %29, double %31, double %40)
%42 = call double @asin(double %41)
%43 = fmul double %42, 0x404CA5DC1A63C1F8
%44 = load double*, double** %13
store double %43, double* %44
%45 = load double, double* %11
%46 = call double @cos(double %45)
%47 = load double, double* %9
%48 = call double @cos(double %47)
%49 = fmul double %46, %48
store double %49, double* %15
%50 = load double, double* %11
%51 = call double @sin(double %50)
%52 = load double, double* %12
%53 = call double @cos(double %52)
%54 = fmul double %51, %53
%55 = load double, double* %9
%56 = call double @sin(double %55)
%57 = fmul double %54, %56
store double %57, double* %16
%58 = load double, double* %11
%59 = call double @sin(double %58)
%60 = load double, double* %12
%61 = call double @sin(double %60)
%62 = fmul double %59, %61
store double %62, double* %17
%63 = load double, double* %15
%64 = load double, double* %10
%65 = call double @sin(double %64)
%66 = load double, double* %16
%67 = load double, double* %10
%68 = call double @sin(double %67)
%69 = fmul double %66, %68
%70 = call double @llvm.fmuladd.f64(double %63, double %65, double %69)
%71 = load double, double* %17
%72 = load double, double* %10
%73 = call double @cos(double %72)
%74 = call double @llvm.fmuladd.f64(double %71, double %73, double %70)
%75 = load double, double* %15
%76 = load double, double* %10
%77 = call double @cos(double %76)
%78 = load double, double* %16
%79 = load double, double* %10
%80 = call double @cos(double %79)
%81 = fmul double %78, %80
%82 = call double @llvm.fmuladd.f64(double %75, double %77, double %81)
%83 = load double, double* %17
%84 = load double, double* %10
%85 = call double @sin(double %84)
%86 = fneg double %83
%87 = call double @llvm.fmuladd.f64(double %86, double %85, double %82)
%88 = call double @atan2(double %74, double %87)
%89 = fmul double %88, 0x404CA5DC1A63C1F8
%90 = load double*, double** %14
store double %89, double* %90
ret void
}

LLVM IR (-O2):
define void @LatLonCompute(double %0, double %1, double %2, double %3, double %4, double* nocapture writeonly %5, double* nocapture writeonly %6) {
%8 = fmul double %1, 0x3F91DF46A2529D39
%9 = fmul double %2, 0x3F91DF46A2529D39
%10 = fdiv double %3, %0
%11 = fneg double %4
%12 = tail call double @llvm.fmuladd.f64(double %11, double 0x3F91DF46A2529D39, double 0x400921FB54442D18)
%13 = tail call double @cos(double %10)
%14 = tail call double @sin(double %8)
%15 = tail call double @sin(double %10)
%16 = tail call double @cos(double %12)
%17 = tail call double @cos(double %8)
%18 = fneg double %15
%19 = fmul double %16, %18
%20 = fmul double %19, %17
%21 = tail call double @llvm.fmuladd.f64(double %13, double %14, double %20)
%22 = tail call double @asin(double %21)
%23 = fmul double %22, 0x404CA5DC1A63C1F8
store double %23, double* %5
%24 = tail call double @cos(double %10)
%25 = tail call double @cos(double %8)
%26 = fmul double %24, %25
%27 = tail call double @sin(double %10)
%28 = tail call double @cos(double %12)
%29 = fmul double %27, %28
%30 = tail call double @sin(double %8)
%31 = fmul double %29, %30
%32 = tail call double @sin(double %10)
%33 = tail call double @sin(double %12)
%34 = fmul double %32, %33
%35 = tail call double @sin(double %9)
%36 = tail call double @sin(double %9)
%37 = fmul double %31, %36
%38 = tail call double @llvm.fmuladd.f64(double %26, double %35, double %37)
%39 = tail call double @cos(double %9)
%40 = tail call double @llvm.fmuladd.f64(double %34, double %39, double %38)
%41 = tail call double @cos(double %9)
%42 = tail call double @cos(double %9)
%43 = fmul double %31, %42
%44 = tail call double @llvm.fmuladd.f64(double %26, double %41, double %43)
%45 = tail call double @sin(double %9)
%46 = fneg double %34
%47 = tail call double @llvm.fmuladd.f64(double %46, double %45, double %44)
%48 = tail call double @atan2(double %40, double %47)
%49 = fmul double %48, 0x404CA5DC1A63C1F8
store double %49, double* %6
ret void
}