#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 M_PI;
double cos(double);
double sin(double);
void raw_move_loxo(double latitude, double longitude, double distance,
                   double heading, double *new_latitude,
                   double *new_longitude) {
  double d, new_lat, t_lat, new_lon;
  d = (((distance / 60.0) / 180.0) * M_PI);
  new_lat = latitude + d * cos(heading);
  t_lat = (latitude + new_lat) / 2.0;
  new_lon = longitude + (d * sin(heading)) / cos(t_lat);
  if (new_lon > M_PI) {
    new_lon -= M_PI * 2;
  } else if (new_lon < -M_PI) {
    new_lon += M_PI * 2;
  }
  *new_latitude = new_lat;
  *new_longitude = new_lon;
}


x86 assembly (clang, -O0):
<raw_move_loxo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xebc(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xea8(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    0x2e7d(%rip),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movsd  -0x78(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  0xe42(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1040 <cos@plt>
movsd  -0x60(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x58(%rbp),%xmm0
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
mov    0x2dc2(%rip),%rax
ucomisd (%rax),%xmm0
jbe    1269 <raw_move_loxo+0x149>
mov    0x2db1(%rip),%rax
movsd  (%rax),%xmm0
movsd  -0x50(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    12bc <raw_move_loxo+0x19c>
movsd  -0x50(%rbp),%xmm1
mov    0x2d73(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
ucomisd %xmm1,%xmm0
jbe    12b7 <raw_move_loxo+0x197>
mov    0x2d47(%rip),%rax
movsd  (%rax),%xmm0
movsd  -0x50(%rbp),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    12bc <raw_move_loxo+0x19c>
movsd  -0x40(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<raw_move_loxo>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
divsd  0xecf(%rip),%xmm2
divsd  0xecf(%rip),%xmm2
mov    %rsi,%r14
mov    %rdi,%r15
movsd  %xmm3,0x28(%rsp)
movsd  %xmm1,0x30(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    0x2e90(%rip),%rbx
mulsd  (%rbx),%xmm2
movsd  %xmm2,0x10(%rsp)
movapd %xmm3,%xmm0
call   1040 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,0x38(%rsp)
addsd  %xmm0,%xmm1
mulsd  0xe83(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movapd %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movapd 0x10(%rsp),%xmm2
divsd  %xmm0,%xmm2
addsd  0x30(%rsp),%xmm2
movsd  (%rbx),%xmm0
ucomisd %xmm0,%xmm2
movapd 0xe4b(%rip),%xmm1
xorpd  %xmm0,%xmm1
jbe    11e5 <raw_move_loxo+0xc5>
addsd  %xmm1,%xmm1
addsd  %xmm1,%xmm2
jmp    11f3 <raw_move_loxo+0xd3>
ucomisd %xmm2,%xmm1
jbe    11f3 <raw_move_loxo+0xd3>
addsd  %xmm0,%xmm0
addsd  %xmm0,%xmm2
movsd  0x38(%rsp),%xmm0
movsd  %xmm0,(%r15)
movsd  %xmm2,(%r14)
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define void @raw_move_loxo(double %0, double %1, double %2, double %3, double* %4, double* %5) {
%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
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store double* %4, double** %11
store double* %5, double** %12
%17 = load double, double* %9
%18 = fdiv double %17, 6.000000e+01
%19 = fdiv double %18, 1.800000e+02
%20 = load double, double* @M_PI
%21 = fmul double %19, %20
store double %21, double* %13
%22 = load double, double* %7
%23 = load double, double* %13
%24 = load double, double* %10
%25 = call double @cos(double %24)
%26 = call double @llvm.fmuladd.f64(double %23, double %25, double %22)
store double %26, double* %14
%27 = load double, double* %7
%28 = load double, double* %14
%29 = fadd double %27, %28
%30 = fdiv double %29, 2.000000e+00
store double %30, double* %15
%31 = load double, double* %8
%32 = load double, double* %13
%33 = load double, double* %10
%34 = call double @sin(double %33)
%35 = fmul double %32, %34
%36 = load double, double* %15
%37 = call double @cos(double %36)
%38 = fdiv double %35, %37
%39 = fadd double %31, %38
store double %39, double* %16
%40 = load double, double* %16
%41 = load double, double* @M_PI
%42 = fcmp ogt double %40, %41
br i1 %42, label %43, label %48
43: ; preds = %6
%44 = load double, double* @M_PI
%45 = load double, double* %16
%46 = fneg double %44
%47 = call double @llvm.fmuladd.f64(double %46, double 2.000000e+00, double %45)
store double %47, double* %16
br label %58
48: ; preds = %6
%49 = load double, double* %16
%50 = load double, double* @M_PI
%51 = fneg double %50
%52 = fcmp olt double %49, %51
br i1 %52, label %53, label %57
53: ; preds = %48
%54 = load double, double* @M_PI
%55 = load double, double* %16
%56 = call double @llvm.fmuladd.f64(double %54, double 2.000000e+00, double %55)
store double %56, double* %16
br label %57
57: ; preds = %53, %48
br label %58
58: ; preds = %57, %43
%59 = load double, double* %14
%60 = load double*, double** %11
store double %59, double* %60
%61 = load double, double* %16
%62 = load double*, double** %12
store double %61, double* %62
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define void @raw_move_loxo(double %0, double %1, double %2, double %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = fdiv double %2, 6.000000e+01
%8 = fdiv double %7, 1.800000e+02
%9 = load double, double* @M_PI
%10 = fmul double %8, %9
%11 = tail call double @cos(double %3)
%12 = tail call double @llvm.fmuladd.f64(double %10, double %11, double %0)
%13 = fadd double %12, %0
%14 = fmul double %13, 5.000000e-01
%15 = tail call double @sin(double %3)
%16 = fmul double %10, %15
%17 = tail call double @cos(double %14)
%18 = fdiv double %16, %17
%19 = fadd double %18, %1
%20 = load double, double* @M_PI
%21 = fcmp ogt double %19, %20
%22 = fneg double %20
br i1 %21, label %23, label %25
23: ; preds = %6
%24 = tail call double @llvm.fmuladd.f64(double %22, double 2.000000e+00, double %19)
br label %29
25: ; preds = %6
%26 = fcmp olt double %19, %22
br i1 %26, label %27, label %29
27: ; preds = %25
%28 = tail call double @llvm.fmuladd.f64(double %20, double 2.000000e+00, double %19)
br label %29
29: ; preds = %25, %27, %23
%30 = phi double [ %24, %23 ], [ %28, %27 ], [ %19, %25 ]
store double %12, double* %4
store double %30, double* %5
ret void
}