#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 find_closest_point_on_ellipse(double const, double const, int,
                                     double const, double *);
double planet_axis_ratio(int const);
double planet_radius_in_meters(int const);
double parallax_to_lat_alt(const double rho_cos_phi, const double rho_sin_phi,
                           double *lat_out, const int planet_idx) {
  const double axis_ratio = planet_axis_ratio(planet_idx);
  const double major_axis_in_meters = planet_radius_in_meters(planet_idx);
  const double rval = find_closest_point_on_ellipse(rho_cos_phi, rho_sin_phi,
                                                    1., axis_ratio, lat_out);
  return (rval * major_axis_in_meters);
}


x86 assembly (clang, -O0):
<parallax_to_lat_alt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <planet_axis_ratio@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <planet_radius_in_meters@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
mov    -0x18(%rbp),%rsi
mov    $0x1,%edi
call   1040 <find_closest_point_on_ellipse@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parallax_to_lat_alt>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,0x18(%rsp)
mov    %esi,%edi
call   1050 <planet_axis_ratio@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1030 <planet_radius_in_meters@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
mov    $0x1,%edi
movsd  0x8(%rsp),%xmm2
mov    %r14,%rsi
call   1040 <find_closest_point_on_ellipse@plt>
mulsd  0x10(%rsp),%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @parallax_to_lat_alt(double %0, double %1, double* %2, i32 %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double*
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double %0, double* %5
store double %1, double* %6
store double* %2, double** %7
store i32 %3, i32* %8
%12 = load i32, i32* %8
%13 = call double @planet_axis_ratio(i32 %12)
store double %13, double* %9
%14 = load i32, i32* %8
%15 = call double @planet_radius_in_meters(i32 %14)
store double %15, double* %10
%16 = load double, double* %5
%17 = load double, double* %6
%18 = load double, double* %9
%19 = load double*, double** %7
%20 = call double @find_closest_point_on_ellipse(double %16, double %17, i32 1, double %18, double* %19)
store double %20, double* %11
%21 = load double, double* %11
%22 = load double, double* %10
%23 = fmul double %21, %22
ret double %23
}

LLVM IR (-O2):
define double @parallax_to_lat_alt(double %0, double %1, double* %2, i32 %3) {
%5 = tail call double @planet_axis_ratio(i32 %3)
%6 = tail call double @planet_radius_in_meters(i32 %3)
%7 = tail call double @find_closest_point_on_ellipse(double %0, double %1, i32 1, double %5, double* %2)
%8 = fmul double %6, %7
ret double %8
}