#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 const cos(double);
double const sin(double);
double const sqrt(int);
void turtle_ecef_from_geodetic(double latitude, double longitude,
                               double elevation, double ecef[3]) {
  const double a = 6378137, e = 0.081819190842622;
  const double s = sin(latitude * 3.14159265358979323846 / 180.);
  const double c = cos(latitude * 3.14159265358979323846 / 180.);
  const double R = a / sqrt(1. - e * e * s * s);
  ecef[0] =
      (R + elevation) * c * cos(longitude * 3.14159265358979323846 / 180.);
  ecef[1] =
      (R + elevation) * c * sin(longitude * 3.14159265358979323846 / 180.);
  ecef[2] = (R * (1. - e * e) + elevation) * s;
}


x86 assembly (clang, -O0):
<turtle_ecef_from_geodetic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
movsd  0xec5(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xed0(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xea3(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  0xe8e(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xe80(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  0xe6b(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  0xe75(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe40(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe20(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xdf3(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xdde(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xdad(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xd98(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x48(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xd60(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<turtle_ecef_from_geodetic>:
push   %rbx
sub    $0x50,%rsp
mov    %rdi,%rbx
movsd  %xmm2,0x28(%rsp)
movsd  %xmm1,0x8(%rsp)
mulsd  0xeb4(%rip),%xmm0
divsd  0xeb4(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1030 <sin@plt>
movapd %xmm0,0x30(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0xe92(%rip),%xmm0
movapd 0x30(%rsp),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
addsd  0xe84(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
movsd  0xe7b(%rip),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,0x40(%rsp)
movapd %xmm1,%xmm0
addsd  0x28(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
movapd %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xe2d(%rip),%xmm0
divsd  0xe2d(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movapd 0x40(%rsp),%xmm1
mulsd  0xe1f(%rip),%xmm1
addsd  0x28(%rsp),%xmm1
movapd 0x10(%rsp),%xmm2
unpcklpd 0x30(%rsp),%xmm2
unpcklpd %xmm1,%xmm0
mulpd  %xmm2,%xmm0
movupd %xmm0,0x8(%rbx)
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @turtle_ecef_from_geodetic(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
%12 = alloca double
%13 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double* %3, double** %8
store double 0x415854A640000000, double* %9
store double 0x3FB4F21A3CDAAFBF, double* %10
%14 = load double, double* %5
%15 = fmul double %14, 0x400921FB54442D18
%16 = fdiv double %15, 1.800000e+02
%17 = call double @sin(double %16)
store double %17, double* %11
%18 = load double, double* %5
%19 = fmul double %18, 0x400921FB54442D18
%20 = fdiv double %19, 1.800000e+02
%21 = call double @cos(double %20)
store double %21, double* %12
%22 = load double, double* %11
%23 = fmul double 0x3F7B6B90F1FE9550, %22
%24 = load double, double* %11
%25 = fneg double %23
%26 = call double @llvm.fmuladd.f64(double %25, double %24, double 1.000000e+00)
%27 = fptosi double %26 to i32
%28 = call double @sqrt(i32 %27)
%29 = fdiv double 0x415854A640000000, %28
store double %29, double* %13
%30 = load double, double* %13
%31 = load double, double* %7
%32 = fadd double %30, %31
%33 = load double, double* %12
%34 = fmul double %32, %33
%35 = load double, double* %6
%36 = fmul double %35, 0x400921FB54442D18
%37 = fdiv double %36, 1.800000e+02
%38 = call double @cos(double %37)
%39 = fmul double %34, %38
%40 = load double*, double** %8
%41 = getelementptr inbounds double, double* %40, i64 0
store double %39, double* %41
%42 = load double, double* %13
%43 = load double, double* %7
%44 = fadd double %42, %43
%45 = load double, double* %12
%46 = fmul double %44, %45
%47 = load double, double* %6
%48 = fmul double %47, 0x400921FB54442D18
%49 = fdiv double %48, 1.800000e+02
%50 = call double @sin(double %49)
%51 = fmul double %46, %50
%52 = load double*, double** %8
%53 = getelementptr inbounds double, double* %52, i64 1
store double %51, double* %53
%54 = load double, double* %13
%55 = load double, double* %7
%56 = call double @llvm.fmuladd.f64(double %54, double 0x3FEFC928DE1C02D5, double %55)
%57 = load double, double* %11
%58 = fmul double %56, %57
%59 = load double*, double** %8
%60 = getelementptr inbounds double, double* %59, i64 2
store double %58, double* %60
ret void
}

LLVM IR (-O2):
define void @turtle_ecef_from_geodetic(double %0, double %1, double %2, double* nocapture writeonly %3) {
%5 = fmul double %0, 0x400921FB54442D18
%6 = fdiv double %5, 1.800000e+02
%7 = tail call double @sin(double %6)
%8 = tail call double @cos(double %6)
%9 = fmul double %7, 0xBF7B6B90F1FE9550
%10 = tail call double @llvm.fmuladd.f64(double %9, double %7, double 1.000000e+00)
%11 = fptosi double %10 to i32
%12 = tail call double @sqrt(i32 %11)
%13 = fdiv double 0x415854A640000000, %12
%14 = fadd double %13, %2
%15 = fmul double %8, %14
%16 = fmul double %1, 0x400921FB54442D18
%17 = fdiv double %16, 1.800000e+02
%18 = tail call double @cos(double %17)
%19 = fmul double %18, %15
store double %19, double* %3
%20 = tail call double @sin(double %17)
%21 = getelementptr inbounds double, double* %3, i64 1
%22 = tail call double @llvm.fmuladd.f64(double %13, double 0x3FEFC928DE1C02D5, double %2)
%23 = insertelement <2 x double> poison, double %15, i64 0
%24 = insertelement <2 x double> %23, double %7, i64 1
%25 = insertelement <2 x double> poison, double %20, i64 0
%26 = insertelement <2 x double> %25, double %22, i64 1
%27 = fmul <2 x double> %24, %26
%28 = bitcast double* %21 to <2 x double>*
store <2 x double> %27, <2 x double>* %28
ret void
}