#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 atan(double const);
double planet_axis_ratio(int);
double const planet_radius_in_meters(int);
double const sqrt(double const);
double approx_parallax_to_lat_alt(const double x, const double y, double *lat) {
  const double flat = planet_axis_ratio(3);
  const double f = 1. - flat, k = f * (2. - f);
  const double tan_u = y * (flat + k / sqrt(x * x + y * y)) / x;
  const double sec_u = sqrt(1. + tan_u * tan_u);
  const double sin_u = tan_u / sec_u, cos_u = 1. / sec_u;
  const double tan_phi = (y * flat + k * sin_u * sin_u * sin_u) /
                         (flat * (x - k * cos_u * cos_u * cos_u));
  const double sec_phi = sqrt(1. + tan_phi * tan_phi);
  const double sin_phi = tan_phi / sec_phi, cos_phi = 1. / sec_phi;
  const double alt =
      x * cos_phi + y * sin_phi - sqrt(1. - k * sin_phi * sin_phi);
  *lat = atan(tan_phi);
  return (alt * planet_radius_in_meters(3));
}


x86 assembly (clang, -O0):
<approx_parallax_to_lat_alt>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    $0x3,%edi
call   1050 <planet_axis_ratio@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xe90(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe81(%rip),%xmm1
subsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  -0xa0(%rbp),%xmm2
ff
movsd  -0x98(%rbp),%xmm1
ff
movaps %xmm0,%xmm3
movsd  -0x90(%rbp),%xmm0
ff
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xddc(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xdb7(%rip),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm2
mulsd  -0x50(%rbp),%xmm2
mulsd  -0x50(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm4
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd27(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
divsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xd02(%rip),%xmm0
divsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  -0x68(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xca2(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1040 <atan@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    $0x3,%edi
call   1030 <planet_radius_in_meters@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm1,%xmm0
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<approx_parallax_to_lat_alt>:
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%rbx
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    $0x3,%edi
call   1050 <planet_axis_ratio@plt>
movapd %xmm0,%xmm4
movsd  0xe96(%rip),%xmm0
subsd  %xmm4,%xmm0
movsd  0xe92(%rip),%xmm3
subsd  %xmm0,%xmm3
mulsd  %xmm0,%xmm3
movsd  0x18(%rsp),%xmm1
mulsd  %xmm1,%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
movapd %xmm3,0x20(%rsp)
movsd  %xmm4,0x10(%rsp)
jb     11b2 <approx_parallax_to_lat_alt+0x72>
sqrtsd %xmm0,%xmm0
jmp    11c7 <approx_parallax_to_lat_alt+0x87>
call   1060 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  0x10(%rsp),%xmm4
movapd 0x20(%rsp),%xmm3
movapd %xmm3,%xmm5
divsd  %xmm0,%xmm5
addsd  %xmm4,%xmm5
mulsd  0x18(%rsp),%xmm5
divsd  0x8(%rsp),%xmm5
movapd %xmm5,%xmm0
mulsd  %xmm5,%xmm0
addsd  0xe11(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     11fb <approx_parallax_to_lat_alt+0xbb>
sqrtsd %xmm0,%xmm0
jmp    1218 <approx_parallax_to_lat_alt+0xd8>
movapd %xmm5,0x30(%rsp)
call   1060 <sqrt@plt>
movapd 0x30(%rsp),%xmm5
movsd  0x10(%rsp),%xmm4
movapd 0x20(%rsp),%xmm3
divsd  %xmm0,%xmm5
movsd  0xddc(%rip),%xmm2
movapd %xmm2,%xmm1
divsd  %xmm0,%xmm1
movapd %xmm3,%xmm0
mulsd  %xmm5,%xmm0
mulsd  %xmm5,%xmm0
mulsd  %xmm5,%xmm0
movsd  0x18(%rsp),%xmm6
mulsd  %xmm4,%xmm6
addsd  %xmm0,%xmm6
movapd %xmm1,%xmm0
mulsd  %xmm3,%xmm0
xorpd  0xdb6(%rip),%xmm3
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  %xmm4,%xmm1
divsd  %xmm1,%xmm6
movapd %xmm6,%xmm0
mulsd  %xmm6,%xmm0
addsd  %xmm2,%xmm0
xorpd  %xmm7,%xmm7
ucomisd %xmm7,%xmm0
movsd  %xmm6,0x10(%rsp)
jb     1296 <approx_parallax_to_lat_alt+0x156>
sqrtsd %xmm0,%xmm0
jmp    12b1 <approx_parallax_to_lat_alt+0x171>
movapd %xmm3,0x20(%rsp)
call   1060 <sqrt@plt>
xorpd  %xmm7,%xmm7
movsd  0x10(%rsp),%xmm6
movapd 0x20(%rsp),%xmm3
movapd %xmm6,%xmm1
divsd  %xmm0,%xmm1
movsd  0xd3f(%rip),%xmm5
movapd %xmm5,%xmm2
divsd  %xmm0,%xmm2
movsd  0x18(%rsp),%xmm4
mulsd  %xmm1,%xmm4
movsd  0x8(%rsp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm4,%xmm0
movsd  %xmm0,0x8(%rsp)
mulsd  %xmm1,%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm5,%xmm3
ucomisd %xmm7,%xmm3
jb     1302 <approx_parallax_to_lat_alt+0x1c2>
xorps  %xmm0,%xmm0
sqrtsd %xmm3,%xmm0
jmp    1311 <approx_parallax_to_lat_alt+0x1d1>
movapd %xmm3,%xmm0
call   1060 <sqrt@plt>
movsd  0x10(%rsp),%xmm6
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm6,%xmm0
call   1040 <atan@plt>
movsd  %xmm0,(%rbx)
mov    $0x3,%edi
call   1030 <planet_radius_in_meters@plt>
mulsd  0x8(%rsp),%xmm0
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @approx_parallax_to_lat_alt(double %0, double %1, double* %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double*
%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
store double %0, double* %4
store double %1, double* %5
store double* %2, double** %6
%19 = call double @planet_axis_ratio(i32 3)
store double %19, double* %7
%20 = load double, double* %7
%21 = fsub double 1.000000e+00, %20
store double %21, double* %8
%22 = load double, double* %8
%23 = load double, double* %8
%24 = fsub double 2.000000e+00, %23
%25 = fmul double %22, %24
store double %25, double* %9
%26 = load double, double* %5
%27 = load double, double* %7
%28 = load double, double* %9
%29 = load double, double* %4
%30 = load double, double* %4
%31 = load double, double* %5
%32 = load double, double* %5
%33 = fmul double %31, %32
%34 = call double @llvm.fmuladd.f64(double %29, double %30, double %33)
%35 = call double @sqrt(double %34)
%36 = fdiv double %28, %35
%37 = fadd double %27, %36
%38 = fmul double %26, %37
%39 = load double, double* %4
%40 = fdiv double %38, %39
store double %40, double* %10
%41 = load double, double* %10
%42 = load double, double* %10
%43 = call double @llvm.fmuladd.f64(double %41, double %42, double 1.000000e+00)
%44 = call double @sqrt(double %43)
store double %44, double* %11
%45 = load double, double* %10
%46 = load double, double* %11
%47 = fdiv double %45, %46
store double %47, double* %12
%48 = load double, double* %11
%49 = fdiv double 1.000000e+00, %48
store double %49, double* %13
%50 = load double, double* %5
%51 = load double, double* %7
%52 = load double, double* %9
%53 = load double, double* %12
%54 = fmul double %52, %53
%55 = load double, double* %12
%56 = fmul double %54, %55
%57 = load double, double* %12
%58 = fmul double %56, %57
%59 = call double @llvm.fmuladd.f64(double %50, double %51, double %58)
%60 = load double, double* %7
%61 = load double, double* %4
%62 = load double, double* %9
%63 = load double, double* %13
%64 = fmul double %62, %63
%65 = load double, double* %13
%66 = fmul double %64, %65
%67 = load double, double* %13
%68 = fneg double %66
%69 = call double @llvm.fmuladd.f64(double %68, double %67, double %61)
%70 = fmul double %60, %69
%71 = fdiv double %59, %70
store double %71, double* %14
%72 = load double, double* %14
%73 = load double, double* %14
%74 = call double @llvm.fmuladd.f64(double %72, double %73, double 1.000000e+00)
%75 = call double @sqrt(double %74)
store double %75, double* %15
%76 = load double, double* %14
%77 = load double, double* %15
%78 = fdiv double %76, %77
store double %78, double* %16
%79 = load double, double* %15
%80 = fdiv double 1.000000e+00, %79
store double %80, double* %17
%81 = load double, double* %4
%82 = load double, double* %17
%83 = load double, double* %5
%84 = load double, double* %16
%85 = fmul double %83, %84
%86 = call double @llvm.fmuladd.f64(double %81, double %82, double %85)
%87 = load double, double* %9
%88 = load double, double* %16
%89 = fmul double %87, %88
%90 = load double, double* %16
%91 = fneg double %89
%92 = call double @llvm.fmuladd.f64(double %91, double %90, double 1.000000e+00)
%93 = call double @sqrt(double %92)
%94 = fsub double %86, %93
store double %94, double* %18
%95 = load double, double* %14
%96 = call double @atan(double %95)
%97 = load double*, double** %6
store double %96, double* %97
%98 = load double, double* %18
%99 = call double @planet_radius_in_meters(i32 3)
%100 = fmul double %98, %99
ret double %100
}

LLVM IR (-O2):
define double @approx_parallax_to_lat_alt(double %0, double %1, double* nocapture writeonly %2) {
%4 = tail call double @planet_axis_ratio(i32 3)
%5 = fsub double 1.000000e+00, %4
%6 = fsub double 2.000000e+00, %5
%7 = fmul double %5, %6
%8 = fmul double %1, %1
%9 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %8)
%10 = tail call double @sqrt(double %9)
%11 = fdiv double %7, %10
%12 = fadd double %4, %11
%13 = fmul double %12, %1
%14 = fdiv double %13, %0
%15 = tail call double @llvm.fmuladd.f64(double %14, double %14, double 1.000000e+00)
%16 = tail call double @sqrt(double %15)
%17 = fdiv double %14, %16
%18 = fdiv double 1.000000e+00, %16
%19 = fmul double %7, %17
%20 = fmul double %17, %19
%21 = fmul double %17, %20
%22 = tail call double @llvm.fmuladd.f64(double %1, double %4, double %21)
%23 = fneg double %7
%24 = fmul double %18, %23
%25 = fmul double %18, %24
%26 = tail call double @llvm.fmuladd.f64(double %25, double %18, double %0)
%27 = fmul double %4, %26
%28 = fdiv double %22, %27
%29 = tail call double @llvm.fmuladd.f64(double %28, double %28, double 1.000000e+00)
%30 = tail call double @sqrt(double %29)
%31 = fdiv double %28, %30
%32 = fdiv double 1.000000e+00, %30
%33 = fmul double %31, %1
%34 = tail call double @llvm.fmuladd.f64(double %0, double %32, double %33)
%35 = fmul double %31, %23
%36 = tail call double @llvm.fmuladd.f64(double %35, double %31, double 1.000000e+00)
%37 = tail call double @sqrt(double %36)
%38 = fsub double %34, %37
%39 = tail call double @atan(double %28)
store double %39, double* %2
%40 = tail call double @planet_radius_in_meters(i32 3)
%41 = fmul double %40, %38
ret double %41
}