#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 GeogLonR(double const, double);
double asin(double);
double atan2(double, double);
int cos(double const);
double sin(double const);
void GeogStep(const double o1, const double a1, const double d, const double s,
              double *o2, double *a2) {
  double sin_s, sin_d, cos_d, dlon, a, x, y;
  sin_s = sin(s);
  sin_d = sin(d);
  cos_d = cos(d);
  a = 0.5 * (sin(a1 + s) * (1.0 + cos_d) + sin(a1 - s) * (1.0 - cos_d));
  *a2 = (a > 1.0)    ? 1.570796326794896619231
        : (a < -1.0) ? -1.570796326794896619231
                     : asin(a);
  y = sin_s * sin_d;
  x = 0.5 * (cos(a1 + s) * (1 + cos_d) + cos(a1 - s) * (1 - cos_d));
  dlon = atan2(y, x);
  *o2 = GeogLonR(o1 + dlon, 0.0);
}


x86 assembly (clang, -O0):
<GeogStep>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%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  -0x20(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1060 <cos@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  0xe3c(%rip),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1040 <sin@plt>
movsd  -0x78(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm2
movsd  0xe11(%rip),%xmm3
subsd  -0x48(%rbp),%xmm3
mulsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe00(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  0xde2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    123a <GeogStep+0xea>
movsd  0xdf0(%rip),%xmm0
movsd  %xmm0,-0x80(%rbp)
jmp    1281 <GeogStep+0x131>
movsd  0xdce(%rip),%xmm0
ucomisd -0x58(%rbp),%xmm0
jbe    1262 <GeogStep+0x112>
movsd  0xdc3(%rip),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
jmp    1274 <GeogStep+0x124>
movsd  -0x58(%rbp),%xmm0
call   1050 <asin@plt>
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0x80(%rbp)
movsd  -0x80(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
call   1060 <cos@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  0xd40(%rip),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1060 <cos@plt>
movsd  -0x98(%rbp),%xmm1
ff
movsd  -0x90(%rbp),%xmm2
ff
cvtsi2sd %eax,%xmm0
movsd  0xd08(%rip),%xmm3
subsd  -0x48(%rbp),%xmm3
mulsd  %xmm3,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xcf7(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
call   1070 <GeogLonR@plt>
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GeogStep>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
movsd  %xmm3,0x10(%rsp)
movsd  %xmm2,(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x40(%rsp)
movaps %xmm3,%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x20(%rsp)
movsd  (%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x38(%rsp)
movsd  (%rsp),%xmm0
call   1060 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x30(%rsp)
call   1040 <sin@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x8(%rsp),%xmm1
addsd  0xe2c(%rip),%xmm1
movsd  %xmm1,(%rsp)
movsd  0x18(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
call   1040 <sin@plt>
movsd  0xe08(%rip),%xmm2
movapd %xmm2,%xmm1
subsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
mulsd  %xmm1,%xmm0
movsd  0x28(%rsp),%xmm1
mulsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
mulsd  0xde5(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    1233 <GeogStep+0xe3>
movsd  0xddf(%rip),%xmm0
jmp    1254 <GeogStep+0x104>
movsd  0xde5(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    124b <GeogStep+0xfb>
movsd  0xdcf(%rip),%xmm0
jmp    1254 <GeogStep+0x104>
movapd %xmm1,%xmm0
call   1050 <asin@plt>
movsd  %xmm0,(%rbx)
movsd  0x20(%rsp),%xmm0
mulsd  0x38(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x30(%rsp),%xmm0
call   1060 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1060 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  (%rsp),%xmm0
addsd  %xmm1,%xmm0
mulsd  0xd53(%rip),%xmm0
movapd %xmm0,%xmm1
movsd  0x20(%rsp),%xmm0
call   1030 <atan2@plt>
addsd  0x40(%rsp),%xmm0
xorpd  %xmm1,%xmm1
call   1070 <GeogLonR@plt>
movsd  %xmm0,(%r14)
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @GeogStep(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
%17 = alloca double
%18 = alloca double
%19 = 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
%20 = load double, double* %10
%21 = call double @sin(double %20)
store double %21, double* %13
%22 = load double, double* %9
%23 = call double @sin(double %22)
store double %23, double* %14
%24 = load double, double* %9
%25 = call i32 @cos(double %24)
%26 = sitofp i32 %25 to double
store double %26, double* %15
%27 = load double, double* %8
%28 = load double, double* %10
%29 = fadd double %27, %28
%30 = call double @sin(double %29)
%31 = load double, double* %15
%32 = fadd double 1.000000e+00, %31
%33 = load double, double* %8
%34 = load double, double* %10
%35 = fsub double %33, %34
%36 = call double @sin(double %35)
%37 = load double, double* %15
%38 = fsub double 1.000000e+00, %37
%39 = fmul double %36, %38
%40 = call double @llvm.fmuladd.f64(double %30, double %32, double %39)
%41 = fmul double 5.000000e-01, %40
store double %41, double* %17
%42 = load double, double* %17
%43 = fcmp ogt double %42, 1.000000e+00
br i1 %43, label %44, label %45
44: ; preds = %6
br label %54
45: ; preds = %6
%46 = load double, double* %17
%47 = fcmp olt double %46, -1.000000e+00
br i1 %47, label %48, label %49
48: ; preds = %45
br label %52
49: ; preds = %45
%50 = load double, double* %17
%51 = call double @asin(double %50)
br label %52
52: ; preds = %49, %48
%53 = phi double [ 0xBFF921FB54442D18, %48 ], [ %51, %49 ]
br label %54
54: ; preds = %52, %44
%55 = phi double [ 0x3FF921FB54442D18, %44 ], [ %53, %52 ]
%56 = load double*, double** %12
store double %55, double* %56
%57 = load double, double* %13
%58 = load double, double* %14
%59 = fmul double %57, %58
store double %59, double* %19
%60 = load double, double* %8
%61 = load double, double* %10
%62 = fadd double %60, %61
%63 = call i32 @cos(double %62)
%64 = sitofp i32 %63 to double
%65 = load double, double* %15
%66 = fadd double 1.000000e+00, %65
%67 = load double, double* %8
%68 = load double, double* %10
%69 = fsub double %67, %68
%70 = call i32 @cos(double %69)
%71 = sitofp i32 %70 to double
%72 = load double, double* %15
%73 = fsub double 1.000000e+00, %72
%74 = fmul double %71, %73
%75 = call double @llvm.fmuladd.f64(double %64, double %66, double %74)
%76 = fmul double 5.000000e-01, %75
store double %76, double* %18
%77 = load double, double* %19
%78 = load double, double* %18
%79 = call double @atan2(double %77, double %78)
store double %79, double* %16
%80 = load double, double* %7
%81 = load double, double* %16
%82 = fadd double %80, %81
%83 = call double @GeogLonR(double %82, double 0.000000e+00)
%84 = load double*, double** %11
store double %83, double* %84
ret void
}

LLVM IR (-O2):
define void @GeogStep(double %0, double %1, double %2, double %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = tail call double @sin(double %3)
%8 = tail call double @sin(double %2)
%9 = tail call i32 @cos(double %2)
%10 = sitofp i32 %9 to double
%11 = fadd double %1, %3
%12 = tail call double @sin(double %11)
%13 = fadd double %10, 1.000000e+00
%14 = fsub double %1, %3
%15 = tail call double @sin(double %14)
%16 = fsub double 1.000000e+00, %10
%17 = fmul double %15, %16
%18 = tail call double @llvm.fmuladd.f64(double %12, double %13, double %17)
%19 = fmul double %18, 5.000000e-01
%20 = fcmp ogt double %19, 1.000000e+00
br i1 %20, label %25, label %21
21: ; preds = %6
%22 = fcmp olt double %19, -1.000000e+00
br i1 %22, label %25, label %23
23: ; preds = %21
%24 = tail call double @asin(double %19)
br label %25
25: ; preds = %23, %21, %6
%26 = phi double [ 0x3FF921FB54442D18, %6 ], [ %24, %23 ], [ 0xBFF921FB54442D18, %21 ]
store double %26, double* %5
%27 = fmul double %7, %8
%28 = tail call i32 @cos(double %11)
%29 = sitofp i32 %28 to double
%30 = tail call i32 @cos(double %14)
%31 = sitofp i32 %30 to double
%32 = fmul double %16, %31
%33 = tail call double @llvm.fmuladd.f64(double %29, double %13, double %32)
%34 = fmul double %33, 5.000000e-01
%35 = tail call double @atan2(double %27, double %34)
%36 = fadd double %35, %0
%37 = tail call double @GeogLonR(double %36, double 0.000000e+00)
store double %37, double* %4
ret void
}