#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 M_PI_4;
double cos(double);
double fabs(double);
double log(double);
double sin(double);
double tan(double);
void get_loxo_coord_from_dist_angle(double latitude, double longitude,
                                    double distance, double angle,
                                    double *target_lat, double *target_long) {
  double ld, la;
  *target_lat = latitude + ((((cos(angle) * distance) / 60.0) / 180.0) * M_PI);
  if (fabs(*target_lat - latitude) > (((0.001) / 180.0) * M_PI)) {
    ld = log(tan(M_PI_4 + (latitude / 2.0)));
    la = log(tan(M_PI_4 + (*target_lat / 2.0)));
    *target_long = longitude + (la - ld) * tan(angle);
  } else {
    *target_long =
        longitude +
        sin(angle) * (((distance / (60.0 * cos(latitude))) / 180.0) * M_PI);
  }
}


x86 assembly (clang, -O0):
<get_loxo_coord_from_dist_angle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%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  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1050 <cos@plt>
movsd  -0x48(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm0
movsd  0xe86(%rip),%xmm2
divsd  %xmm2,%xmm0
movsd  0xe72(%rip),%xmm2
divsd  %xmm2,%xmm0
mov    0x2e47(%rip),%rax
movsd  (%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
subsd  -0x8(%rbp),%xmm0
movaps 0xe57(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe2b(%rip),%xmm1
mov    0x2e0c(%rip),%rax
mulsd  (%rax),%xmm1
ucomisd %xmm1,%xmm0
jbe    1290 <get_loxo_coord_from_dist_angle+0x150>
mov    0x2def(%rip),%rax
movsd  (%rax),%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  0xe16(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
call   1040 <tan@plt>
call   1060 <log@plt>
movsd  %xmm0,-0x38(%rbp)
mov    0x2dc0(%rip),%rax
movsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm1
movsd  0xde4(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
call   1040 <tan@plt>
call   1060 <log@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <tan@plt>
movsd  -0x58(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1306 <get_loxo_coord_from_dist_angle+0x1c6>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <cos@plt>
movsd  -0x70(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm1
movaps %xmm0,%xmm4
movsd  -0x60(%rbp),%xmm0
movsd  0xd39(%rip),%xmm3
mulsd  %xmm4,%xmm3
divsd  %xmm3,%xmm2
movsd  0xd21(%rip),%xmm3
divsd  %xmm3,%xmm2
mov    0x2cf6(%rip),%rax
mulsd  (%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_loxo_coord_from_dist_angle>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,(%rsp)
movsd  %xmm3,0x8(%rsp)
movapd %xmm3,%xmm0
call   1050 <cos@plt>
mulsd  0x18(%rsp),%xmm0
divsd  0xe83(%rip),%xmm0
divsd  0xe83(%rip),%xmm0
mov    0x2e5c(%rip),%r15
mulsd  (%r15),%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rbx)
subsd  %xmm1,%xmm0
andpd  0xe76(%rip),%xmm0
movsd  (%r15),%xmm1
mulsd  0xe59(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    121c <get_loxo_coord_from_dist_angle+0xdc>
mov    0x2e1c(%rip),%r15
movsd  (%rsp),%xmm0
mulsd  0xe47(%rip),%xmm0
addsd  (%r15),%xmm0
call   1040 <tan@plt>
call   1060 <log@plt>
movsd  %xmm0,(%rsp)
movsd  0xe2b(%rip),%xmm0
mulsd  (%rbx),%xmm0
addsd  (%r15),%xmm0
call   1040 <tan@plt>
call   1060 <log@plt>
subsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <tan@plt>
mulsd  (%rsp),%xmm0
jmp    1260 <get_loxo_coord_from_dist_angle+0x120>
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1050 <cos@plt>
mulsd  0xdc1(%rip),%xmm0
movsd  0x18(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
divsd  0xdb3(%rip),%xmm0
mulsd  (%r15),%xmm0
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
@M_PI_4 = global double 0.000000e+00
define void @get_loxo_coord_from_dist_angle(double %0, double %1, double %2, double %3, double* nocapture %4, double* nocapture writeonly %5) {
%7 = tail call double @cos(double %3)
%8 = fmul double %7, %2
%9 = fdiv double %8, 6.000000e+01
%10 = fdiv double %9, 1.800000e+02
%11 = load double, double* @M_PI
%12 = tail call double @llvm.fmuladd.f64(double %10, double %11, double %0)
store double %12, double* %4
%13 = fsub double %12, %0
%14 = tail call double @llvm.fabs.f64(double %13)
%15 = load double, double* @M_PI
%16 = fmul double %15, 0x3ED74D3B7BA75828
%17 = fcmp ogt double %14, %16
br i1 %17, label %18, label %33
18: ; preds = %6
%19 = load double, double* @M_PI_4
%20 = fmul double %0, 5.000000e-01
%21 = fadd double %20, %19
%22 = tail call double @tan(double %21)
%23 = tail call double @log(double %22)
%24 = load double, double* @M_PI_4
%25 = load double, double* %4
%26 = fmul double %25, 5.000000e-01
%27 = fadd double %24, %26
%28 = tail call double @tan(double %27)
%29 = tail call double @log(double %28)
%30 = fsub double %29, %23
%31 = tail call double @tan(double %3)
%32 = tail call double @llvm.fmuladd.f64(double %30, double %31, double %1)
br label %42
33: ; preds = %6
%34 = tail call double @sin(double %3)
%35 = tail call double @cos(double %0)
%36 = fmul double %35, 6.000000e+01
%37 = fdiv double %2, %36
%38 = fdiv double %37, 1.800000e+02
%39 = load double, double* @M_PI
%40 = fmul double %39, %38
%41 = tail call double @llvm.fmuladd.f64(double %34, double %40, double %1)
br label %42
42: ; preds = %33, %18
%43 = phi double [ %41, %33 ], [ %32, %18 ]
store double %43, double* %5
ret void
}