#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 atan2(double const, double const);
double const cos(double const);
double planet_axis_ratio(int const);
double planet_radius_in_meters(int const);
double const sin(double const);
int lat_alt_to_parallax(const double lat, const double ht_in_meters,
                        double *rho_cos_phi, double *rho_sin_phi,
                        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 u = atan2(sin(lat) * axis_ratio, cos(lat));
  *rho_sin_phi =
      axis_ratio * sin(u) + (ht_in_meters / major_axis_in_meters) * sin(lat);
  *rho_cos_phi = cos(u) + (ht_in_meters / major_axis_in_meters) * cos(lat);
  return (0);
}


x86 assembly (clang, -O0):
<lat_alt_to_parallax>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1060 <planet_axis_ratio@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x24(%rbp),%edi
call   1040 <planet_radius_in_meters@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <sin@plt>
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
call   1030 <atan2@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <sin@plt>
movsd  -0x68(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1070 <cos@plt>
movsd  -0x50(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lat_alt_to_parallax>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %edx,%edi
call   1060 <planet_axis_ratio@plt>
movsd  %xmm0,(%rsp)
mov    %ebp,%edi
call   1040 <planet_radius_in_meters@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movsd  0x18(%rsp),%xmm0
call   1030 <atan2@plt>
movsd  %xmm0,0x18(%rsp)
call   1050 <sin@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
divsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
mulsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx)
movsd  0x18(%rsp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1070 <cos@plt>
mulsd  0x10(%rsp),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%r14)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @lat_alt_to_parallax(double %0, double %1, double* %2, double* %3, i32 %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca double
store double %0, double* %6
store double %1, double* %7
store double* %2, double** %8
store double* %3, double** %9
store i32 %4, i32* %10
%14 = load i32, i32* %10
%15 = call double @planet_axis_ratio(i32 %14)
store double %15, double* %11
%16 = load i32, i32* %10
%17 = call double @planet_radius_in_meters(i32 %16)
store double %17, double* %12
%18 = load double, double* %6
%19 = call double @sin(double %18)
%20 = load double, double* %11
%21 = fmul double %19, %20
%22 = load double, double* %6
%23 = call double @cos(double %22)
%24 = call double @atan2(double %21, double %23)
store double %24, double* %13
%25 = load double, double* %11
%26 = load double, double* %13
%27 = call double @sin(double %26)
%28 = load double, double* %7
%29 = load double, double* %12
%30 = fdiv double %28, %29
%31 = load double, double* %6
%32 = call double @sin(double %31)
%33 = fmul double %30, %32
%34 = call double @llvm.fmuladd.f64(double %25, double %27, double %33)
%35 = load double*, double** %9
store double %34, double* %35
%36 = load double, double* %13
%37 = call double @cos(double %36)
%38 = load double, double* %7
%39 = load double, double* %12
%40 = fdiv double %38, %39
%41 = load double, double* %6
%42 = call double @cos(double %41)
%43 = call double @llvm.fmuladd.f64(double %40, double %42, double %37)
%44 = load double*, double** %8
store double %43, double* %44
ret i32 0
}

LLVM IR (-O2):
define i32 @lat_alt_to_parallax(double %0, double %1, double* nocapture writeonly %2, double* nocapture writeonly %3, i32 %4) {
%6 = tail call double @planet_axis_ratio(i32 %4)
%7 = tail call double @planet_radius_in_meters(i32 %4)
%8 = tail call double @sin(double %0)
%9 = fmul double %6, %8
%10 = tail call double @cos(double %0)
%11 = tail call double @atan2(double %9, double %10)
%12 = tail call double @sin(double %11)
%13 = fdiv double %1, %7
%14 = tail call double @sin(double %0)
%15 = fmul double %13, %14
%16 = tail call double @llvm.fmuladd.f64(double %6, double %12, double %15)
store double %16, double* %3
%17 = tail call double @cos(double %11)
%18 = tail call double @cos(double %0)
%19 = tail call double @llvm.fmuladd.f64(double %13, double %18, double %17)
store double %19, double* %2
ret i32 0
}