#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 cos(double);
double pow(double, int);
double sin(double);
double sqrt(double);
double rdir(double a, double e2, double hdg, double lat) {
  double re, rn, tmp;
  re = a / sqrt(1.0 - e2 * pow(sin(lat), 2));
  rn = (a * (1.0 - e2)) / pow((1.0 - e2 * pow(sin(lat), 2)), 1.5);
  tmp = (re * rn) / (re * pow(cos(hdg), 2) + rn * pow(sin(hdg), 2));
  return (tmp);
}


x86 assembly (clang, -O0):
<rdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
mov    $0x2,%edi
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe4e(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe27(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
mov    $0x2,%edi
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xdd0(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    $0x1,%edi
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <cos@plt>
mov    $0x2,%edi
call   1050 <pow@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
mov    $0x2,%edi
call   1050 <pow@plt>
movsd  -0x58(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm3
movaps %xmm0,%xmm4
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm4,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rdir>:
sub    $0x68,%rsp
movsd  %xmm2,0x18(%rsp)
movaps %xmm1,(%rsp)
movaps %xmm0,0x20(%rsp)
movsd  %xmm3,0x40(%rsp)
movapd %xmm3,%xmm0
call   1030 <sin@plt>
mov    $0x2,%edi
call   1050 <pow@plt>
movapd %xmm0,%xmm1
movapd 0xe88(%rip),%xmm0
movapd (%rsp),%xmm2
xorpd  %xmm2,%xmm0
movapd %xmm0,0x30(%rsp)
mulsd  %xmm2,%xmm1
movsd  0xe7d(%rip),%xmm0
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11a7 <rdir+0x67>
sqrtsd %xmm0,%xmm0
jmp    11ac <rdir+0x6c>
call   1060 <sqrt@plt>
movapd %xmm0,0x50(%rsp)
movsd  0xe56(%rip),%xmm0
subsd  (%rsp),%xmm0
mulsd  0x20(%rsp),%xmm0
movapd %xmm0,(%rsp)
movsd  0x40(%rsp),%xmm0
call   1030 <sin@plt>
mov    $0x2,%edi
call   1050 <pow@plt>
mulsd  0x30(%rsp),%xmm0
addsd  0xe23(%rip),%xmm0
mov    $0x1,%edi
call   1050 <pow@plt>
movapd 0x20(%rsp),%xmm1
unpcklpd (%rsp),%xmm1
movapd 0x50(%rsp),%xmm2
unpcklpd %xmm0,%xmm2
divpd  %xmm2,%xmm1
movapd %xmm1,0x20(%rsp)
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
movapd %xmm2,0x40(%rsp)
movapd %xmm1,%xmm0
mulsd  %xmm2,%xmm0
movapd %xmm0,(%rsp)
movsd  0x18(%rsp),%xmm0
call   1040 <cos@plt>
mov    $0x2,%edi
call   1050 <pow@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
mov    $0x2,%edi
call   1050 <pow@plt>
mulsd  0x40(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm1
addsd  %xmm0,%xmm1
movapd (%rsp),%xmm0
divsd  %xmm1,%xmm0
add    $0x68,%rsp
ret

LLVM IR (-O0):
define double @rdir(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%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 double %3, double* %8
%12 = load double, double* %5
%13 = load double, double* %6
%14 = load double, double* %8
%15 = call double @sin(double %14)
%16 = call double @pow(double %15, i32 2)
%17 = fneg double %13
%18 = call double @llvm.fmuladd.f64(double %17, double %16, double 1.000000e+00)
%19 = call double @sqrt(double %18)
%20 = fdiv double %12, %19
store double %20, double* %9
%21 = load double, double* %5
%22 = load double, double* %6
%23 = fsub double 1.000000e+00, %22
%24 = fmul double %21, %23
%25 = load double, double* %6
%26 = load double, double* %8
%27 = call double @sin(double %26)
%28 = call double @pow(double %27, i32 2)
%29 = fneg double %25
%30 = call double @llvm.fmuladd.f64(double %29, double %28, double 1.000000e+00)
%31 = call double @pow(double %30, i32 1)
%32 = fdiv double %24, %31
store double %32, double* %10
%33 = load double, double* %9
%34 = load double, double* %10
%35 = fmul double %33, %34
%36 = load double, double* %9
%37 = load double, double* %7
%38 = call double @cos(double %37)
%39 = call double @pow(double %38, i32 2)
%40 = load double, double* %10
%41 = load double, double* %7
%42 = call double @sin(double %41)
%43 = call double @pow(double %42, i32 2)
%44 = fmul double %40, %43
%45 = call double @llvm.fmuladd.f64(double %36, double %39, double %44)
%46 = fdiv double %35, %45
store double %46, double* %11
%47 = load double, double* %11
ret double %47
}

LLVM IR (-O2):
define double @rdir(double %0, double %1, double %2, double %3) {
%5 = tail call double @sin(double %3)
%6 = tail call double @pow(double %5, i32 2)
%7 = fneg double %1
%8 = tail call double @llvm.fmuladd.f64(double %7, double %6, double 1.000000e+00)
%9 = tail call double @sqrt(double %8)
%10 = fsub double 1.000000e+00, %1
%11 = fmul double %10, %0
%12 = tail call double @sin(double %3)
%13 = tail call double @pow(double %12, i32 2)
%14 = tail call double @llvm.fmuladd.f64(double %7, double %13, double 1.000000e+00)
%15 = tail call double @pow(double %14, i32 1)
%16 = insertelement <2 x double> poison, double %0, i64 0
%17 = insertelement <2 x double> %16, double %11, i64 1
%18 = insertelement <2 x double> poison, double %9, i64 0
%19 = insertelement <2 x double> %18, double %15, i64 1
%20 = fdiv <2 x double> %17, %19
%21 = extractelement <2 x double> %20, i64 0
%22 = extractelement <2 x double> %20, i64 1
%23 = fmul double %21, %22
%24 = tail call double @cos(double %2)
%25 = tail call double @pow(double %24, i32 2)
%26 = tail call double @sin(double %2)
%27 = tail call double @pow(double %26, i32 2)
%28 = fmul double %22, %27
%29 = tail call double @llvm.fmuladd.f64(double %21, double %25, double %28)
%30 = fdiv double %23, %29
ret double %30
}