#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 */
long double cos(long double);
long double sin(long double);
long double sqrt(int);
void lla2ecef(double lat, double lng, double alt, double *ecef_x,
              double *ecef_y, double *ecef_z) {
  long double n;
  long double a = 6378137.0;
  long double esqr = 6.69437999014e-3;
  long double s;
  long double llat, llng, lalt;
  llat = lat * 3.14159265358979323846 / 180;
  llng = lng * 3.14159265358979323846 / 180;
  lalt = alt;
  s = sin(llat);
  n = a / sqrt(1 - esqr * s * s);
  *ecef_x = (double)((n + lalt) * cos(llat) * cos(llng));
  *ecef_y = (double)((n + lalt) * cos(llat) * sin(llng));
  *ecef_z = (double)((n * (1 - esqr) + lalt) * sin(llat));
}


x86 assembly (clang, -O0):
<lla2ecef>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
flds   0xea4(%rip)
fstpt  -0x50(%rbp)
fldl   0xea3(%rip)
fstpt  -0x60(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe9b(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  0xe97(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
fldl   -0xb0(%rbp)
fstpt  -0x80(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  %xmm2,%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
fldl   -0xb8(%rbp)
fstpt  -0x90(%rbp)
fldl   -0x18(%rbp)
fstpt  -0xa0(%rbp)
fldt   -0x80(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <sin@plt>
fstpt  -0x70(%rbp)
fldt   -0x50(%rbp)
fstpt  -0x118(%rbp)
fldt   -0x60(%rbp)
fldt   -0x70(%rbp)
fmul   %st,%st(1)
fmulp  %st,%st(1)
fld1
fld    %st(0)
fstpt  -0xe8(%rbp)
fsubp  %st,%st(1)
fnstcw -0xc2(%rbp)
movzwl -0xc2(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0xc4(%rbp)
fldcw  -0xc4(%rbp)
fistpl -0xa4(%rbp)
fldcw  -0xc2(%rbp)
mov    -0xa4(%rbp),%edi
call   1050 <sqrt@plt>
fldt   -0x118(%rbp)
fdivp  %st,%st(1)
fstpt  -0x40(%rbp)
fldt   -0x40(%rbp)
fldt   -0xa0(%rbp)
faddp  %st,%st(1)
fstpt  -0x10c(%rbp)
fldt   -0x80(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <cos@plt>
fldt   -0x10c(%rbp)
fmulp  %st,%st(1)
fstpt  -0x100(%rbp)
fldt   -0x90(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <cos@plt>
fldt   -0x100(%rbp)
fmulp  %st,%st(1)
mov    -0x20(%rbp),%rax
fstpl  (%rax)
fldt   -0x40(%rbp)
fldt   -0xa0(%rbp)
faddp  %st,%st(1)
fstpt  -0xf4(%rbp)
fldt   -0x80(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <cos@plt>
fldt   -0xf4(%rbp)
fmulp  %st,%st(1)
fstpt  -0xdc(%rbp)
fldt   -0x90(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <sin@plt>
fldt   -0xe8(%rbp)
fldt   -0xdc(%rbp)
fmulp  %st,%st(2)
mov    -0x28(%rbp),%rax
fxch   %st(1)
fstpl  (%rax)
fldt   -0x40(%rbp)
fldt   -0x60(%rbp)
fsubrp %st,%st(2)
fldt   -0xa0(%rbp)
fxch   %st(1)
fmulp  %st,%st(2)
faddp  %st,%st(1)
fstpt  -0xd0(%rbp)
fldt   -0x80(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <sin@plt>
fldt   -0xd0(%rbp)
fmulp  %st,%st(1)
fstpl  -0xc0(%rbp)
movsd  -0xc0(%rbp),%xmm0
ff
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lla2ecef>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movsd  0xeb3(%rip),%xmm3
mulsd  %xmm3,%xmm0
movsd  0xeaf(%rip),%xmm4
divsd  %xmm4,%xmm0
movsd  %xmm0,0x58(%rsp)
fldl   0x58(%rsp)
fld    %st(0)
fstpt  0x38(%rsp)
mulsd  %xmm3,%xmm1
divsd  %xmm4,%xmm1
movsd  %xmm1,0x50(%rsp)
fldl   0x50(%rsp)
fstpt  0x44(%rsp)
movsd  %xmm2,0x60(%rsp)
fldl   0x60(%rsp)
fstpt  0x28(%rsp)
fstpt  (%rsp)
call   1030 <sin@plt>
fld    %st(0)
fmull  0xe6f(%rip)
fmulp  %st,%st(1)
fld1
faddp  %st,%st(1)
fnstcw 0x18(%rsp)
movzwl 0x18(%rsp),%eax
or     $0xc00,%eax
mov    %ax,0x1a(%rsp)
fldcw  0x1a(%rsp)
fistpl 0x34(%rsp)
fldcw  0x18(%rsp)
mov    0x34(%rsp),%edi
call   1050 <sqrt@plt>
fdivrs 0xe43(%rip)
fld    %st(0)
fstpt  0x74(%rsp)
fldt   0x28(%rsp)
faddp  %st,%st(1)
fstpt  0x1c(%rsp)
fldt   0x38(%rsp)
fstpt  (%rsp)
call   1040 <cos@plt>
fldt   0x1c(%rsp)
fmulp  %st,%st(1)
fstpt  0x68(%rsp)
fldt   0x44(%rsp)
fstpt  (%rsp)
call   1040 <cos@plt>
fldt   0x68(%rsp)
fmulp  %st,%st(1)
fstpl  (%rbx)
fldt   0x38(%rsp)
fstpt  (%rsp)
call   1040 <cos@plt>
fldt   0x1c(%rsp)
fmulp  %st,%st(1)
fstpt  0x1c(%rsp)
fldt   0x44(%rsp)
fstpt  (%rsp)
call   1030 <sin@plt>
fldt   0x1c(%rsp)
fmulp  %st,%st(1)
fstpl  (%r15)
fldt   0xde0(%rip)
fldt   0x74(%rsp)
fmulp  %st,%st(1)
fldt   0x28(%rsp)
faddp  %st,%st(1)
fstpt  0x28(%rsp)
fldt   0x38(%rsp)
fstpt  (%rsp)
call   1030 <sin@plt>
fldt   0x28(%rsp)
fmulp  %st,%st(1)
fstpl  (%r14)
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @lla2ecef(double %0, double %1, double %2, double* %3, double* %4, double* %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca x86_fp80
%14 = alloca x86_fp80
%15 = alloca x86_fp80
%16 = alloca x86_fp80
%17 = alloca x86_fp80
%18 = alloca x86_fp80
%19 = alloca x86_fp80
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double* %3, double** %10
store double* %4, double** %11
store double* %5, double** %12
store x86_fp80 0xK4015C2A5320000000000, x86_fp80* %14
store x86_fp80 0xK3FF7DB5C878FF4781000, x86_fp80* %15
%20 = load double, double* %7
%21 = fmul double %20, 0x400921FB54442D18
%22 = fdiv double %21, 1.800000e+02
%23 = fpext double %22 to x86_fp80
store x86_fp80 %23, x86_fp80* %17
%24 = load double, double* %8
%25 = fmul double %24, 0x400921FB54442D18
%26 = fdiv double %25, 1.800000e+02
%27 = fpext double %26 to x86_fp80
store x86_fp80 %27, x86_fp80* %18
%28 = load double, double* %9
%29 = fpext double %28 to x86_fp80
store x86_fp80 %29, x86_fp80* %19
%30 = load x86_fp80, x86_fp80* %17
%31 = call x86_fp80 @sin(x86_fp80 %30)
store x86_fp80 %31, x86_fp80* %16
%32 = load x86_fp80, x86_fp80* %14
%33 = load x86_fp80, x86_fp80* %15
%34 = load x86_fp80, x86_fp80* %16
%35 = fmul x86_fp80 %33, %34
%36 = load x86_fp80, x86_fp80* %16
%37 = fneg x86_fp80 %35
%38 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %37, x86_fp80 %36, x86_fp80 0xK3FFF8000000000000000)
%39 = fptosi x86_fp80 %38 to i32
%40 = call x86_fp80 @sqrt(i32 %39)
%41 = fdiv x86_fp80 %32, %40
store x86_fp80 %41, x86_fp80* %13
%42 = load x86_fp80, x86_fp80* %13
%43 = load x86_fp80, x86_fp80* %19
%44 = fadd x86_fp80 %42, %43
%45 = load x86_fp80, x86_fp80* %17
%46 = call x86_fp80 @cos(x86_fp80 %45)
%47 = fmul x86_fp80 %44, %46
%48 = load x86_fp80, x86_fp80* %18
%49 = call x86_fp80 @cos(x86_fp80 %48)
%50 = fmul x86_fp80 %47, %49
%51 = fptrunc x86_fp80 %50 to double
%52 = load double*, double** %10
store double %51, double* %52
%53 = load x86_fp80, x86_fp80* %13
%54 = load x86_fp80, x86_fp80* %19
%55 = fadd x86_fp80 %53, %54
%56 = load x86_fp80, x86_fp80* %17
%57 = call x86_fp80 @cos(x86_fp80 %56)
%58 = fmul x86_fp80 %55, %57
%59 = load x86_fp80, x86_fp80* %18
%60 = call x86_fp80 @sin(x86_fp80 %59)
%61 = fmul x86_fp80 %58, %60
%62 = fptrunc x86_fp80 %61 to double
%63 = load double*, double** %11
store double %62, double* %63
%64 = load x86_fp80, x86_fp80* %13
%65 = load x86_fp80, x86_fp80* %15
%66 = fsub x86_fp80 0xK3FFF8000000000000000, %65
%67 = load x86_fp80, x86_fp80* %19
%68 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %64, x86_fp80 %66, x86_fp80 %67)
%69 = load x86_fp80, x86_fp80* %17
%70 = call x86_fp80 @sin(x86_fp80 %69)
%71 = fmul x86_fp80 %68, %70
%72 = fptrunc x86_fp80 %71 to double
%73 = load double*, double** %12
store double %72, double* %73
ret void
}

LLVM IR (-O2):
define void @lla2ecef(double %0, double %1, double %2, double* nocapture writeonly %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = fmul double %0, 0x400921FB54442D18
%8 = fdiv double %7, 1.800000e+02
%9 = fpext double %8 to x86_fp80
%10 = fmul double %1, 0x400921FB54442D18
%11 = fdiv double %10, 1.800000e+02
%12 = fpext double %11 to x86_fp80
%13 = fpext double %2 to x86_fp80
%14 = tail call x86_fp80 @sin(x86_fp80 %9)
%15 = fmul x86_fp80 %14, 0xKBFF7DB5C878FF4781000
%16 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %15, x86_fp80 %14, x86_fp80 0xK3FFF8000000000000000)
%17 = fptosi x86_fp80 %16 to i32
%18 = tail call x86_fp80 @sqrt(i32 %17)
%19 = fdiv x86_fp80 0xK4015C2A5320000000000, %18
%20 = fadd x86_fp80 %19, %13
%21 = tail call x86_fp80 @cos(x86_fp80 %9)
%22 = fmul x86_fp80 %21, %20
%23 = tail call x86_fp80 @cos(x86_fp80 %12)
%24 = fmul x86_fp80 %23, %22
%25 = fptrunc x86_fp80 %24 to double
store double %25, double* %3
%26 = tail call x86_fp80 @cos(x86_fp80 %9)
%27 = fmul x86_fp80 %20, %26
%28 = tail call x86_fp80 @sin(x86_fp80 %12)
%29 = fmul x86_fp80 %27, %28
%30 = fptrunc x86_fp80 %29 to double
store double %30, double* %4
%31 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %19, x86_fp80 0xK3FFEFE4946F0E0170FE0, x86_fp80 %13)
%32 = tail call x86_fp80 @sin(x86_fp80 %9)
%33 = fmul x86_fp80 %31, %32
%34 = fptrunc x86_fp80 %33 to double
store double %34, double* %5
ret void
}