#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, double);
double cos(double);
double pow(double, int);
double sin(double);
double sqrt(int);
void ECEF_to_LLA(double x, double y, long z, double *lat, double *lon,
                 double *alt) {
  *lat =
      atan2(z + (6378137.0 * 6378137.0 - 6356752.31424518 * 6356752.31424518) /
                    (6356752.31424518 * 6356752.31424518) * 6356752.31424518 *
                    pow(sin(atan2(z * 6378137.0,
                                  sqrt(x * x + y * y) * 6356752.31424518)),
                        3),
            sqrt(x * x + y * y) -
                (6378137.0 * 6378137.0 - 6356752.31424518 * 6356752.31424518) /
                    (6378137.0 * 6378137.0) * 6378137.0 *
                    pow(cos(atan2(z * 6378137.0,
                                  sqrt(x * x + y * y) * 6356752.31424518)),
                        3));
  *lon = atan2(y, x);
  *alt = sqrt(x * x + y * y) / cos(*lat) -
         6378137.0 / sqrt(1 - (6378137.0 * 6378137.0 -
                               6356752.31424518 * 6356752.31424518) /
                                  (6378137.0 * 6378137.0) * pow(sin(*lat), 2));
  *lat = *lat / 3.14159265358979323846 * 180;
  *lon = *lon / 3.14159265358979323846 * 180;
}


x86 assembly (clang, -O0):
<ECEF_to_LLA>:
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    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
cvtsi2sdq -0x18(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
cvtsi2sdq -0x18(%rbp),%xmm0
movsd  0xe85(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1070 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
movsd  0xe67(%rip),%xmm2
mulsd  %xmm2,%xmm1
call   1030 <atan2@plt>
call   1040 <sin@plt>
mov    $0x3,%edi
call   1060 <pow@plt>
movsd  -0x60(%rbp),%xmm1
movsd  0xe4a(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1070 <sqrt@plt>
movsd  %xmm0,-0x50(%rbp)
cvtsi2sdq -0x18(%rbp),%xmm0
movsd  0xddd(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1070 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  0xdbf(%rip),%xmm2
mulsd  %xmm2,%xmm1
call   1030 <atan2@plt>
call   1050 <cos@plt>
mov    $0x3,%edi
call   1060 <pow@plt>
movsd  -0x50(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  0xd8a(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
call   1030 <atan2@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
call   1030 <atan2@plt>
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1070 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <sin@plt>
mov    $0x2,%edi
call   1060 <pow@plt>
movsd  0xce7(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xce3(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1070 <sqrt@plt>
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
movsd  0xcb6(%rip),%xmm1
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xc8e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xc7a(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xc66(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xc52(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ECEF_to_LLA>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
cvtsi2sd %rdi,%xmm2
movsd  %xmm2,0x8(%rsp)
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%rbx
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,0x18(%rsp)
mulsd  0xe7e(%rip),%xmm2
movsd  %xmm2,(%rsp)
movapd %xmm1,%xmm2
mulsd  %xmm1,%xmm2
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
cvttsd2si %xmm1,%ebp
mov    %ebp,%edi
call   1070 <sqrt@plt>
movapd %xmm0,%xmm1
mulsd  0xe56(%rip),%xmm1
movsd  (%rsp),%xmm0
call   1030 <atan2@plt>
call   1040 <sin@plt>
mov    $0x3,%edi
call   1060 <pow@plt>
mulsd  0xe3d(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
call   1070 <sqrt@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebp,%edi
call   1070 <sqrt@plt>
movsd  0xe0d(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
call   1030 <atan2@plt>
call   1050 <cos@plt>
mov    $0x3,%edi
call   1060 <pow@plt>
mulsd  0xdf8(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
call   1030 <atan2@plt>
movsd  %xmm0,(%rbx)
movsd  0x20(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,(%r14)
mov    %ebp,%edi
call   1070 <sqrt@plt>
movsd  %xmm0,(%rsp)
movsd  (%rbx),%xmm0
call   1050 <cos@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rbx),%xmm0
call   1040 <sin@plt>
mov    $0x2,%edi
call   1060 <pow@plt>
mulsd  0xd93(%rip),%xmm0
addsd  0xd93(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1070 <sqrt@plt>
movsd  0xd5a(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%r15)
movsd  (%rbx),%xmm0
movsd  0xd6c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd68(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,(%rbx)
movsd  (%r14),%xmm0
divsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ECEF_to_LLA(double %0, double %1, i64 %2, double* %3, double* %4, double* %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca i64
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
store double %0, double* %7
store double %1, double* %8
store i64 %2, i64* %9
store double* %3, double** %10
store double* %4, double** %11
store double* %5, double** %12
%13 = load i64, i64* %9
%14 = sitofp i64 %13 to double
%15 = load i64, i64* %9
%16 = sitofp i64 %15 to double
%17 = fmul double %16, 0x415854A640000000
%18 = load double, double* %7
%19 = load double, double* %7
%20 = load double, double* %8
%21 = load double, double* %8
%22 = fmul double %20, %21
%23 = call double @llvm.fmuladd.f64(double %18, double %19, double %22)
%24 = fptosi double %23 to i32
%25 = call double @sqrt(i32 %24)
%26 = fmul double %25, 0x41583FC4141C97D1
%27 = call double @atan2(double %17, double %26)
%28 = call double @sin(double %27)
%29 = call double @pow(double %28, i32 3)
%30 = call double @llvm.fmuladd.f64(double 0x40E4EB29F7EAC418, double %29, double %14)
%31 = load double, double* %7
%32 = load double, double* %7
%33 = load double, double* %8
%34 = load double, double* %8
%35 = fmul double %33, %34
%36 = call double @llvm.fmuladd.f64(double %31, double %32, double %35)
%37 = fptosi double %36 to i32
%38 = call double @sqrt(i32 %37)
%39 = load i64, i64* %9
%40 = sitofp i64 %39 to double
%41 = fmul double %40, 0x415854A640000000
%42 = load double, double* %7
%43 = load double, double* %7
%44 = load double, double* %8
%45 = load double, double* %8
%46 = fmul double %44, %45
%47 = call double @llvm.fmuladd.f64(double %42, double %43, double %46)
%48 = fptosi double %47 to i32
%49 = call double @sqrt(i32 %48)
%50 = fmul double %49, 0x41583FC4141C97D1
%51 = call double @atan2(double %41, double %50)
%52 = call double @cos(double %51)
%53 = call double @pow(double %52, i32 3)
%54 = call double @llvm.fmuladd.f64(double 0xC0E4D93586D1348F, double %53, double %38)
%55 = call double @atan2(double %30, double %54)
%56 = load double*, double** %10
store double %55, double* %56
%57 = load double, double* %8
%58 = load double, double* %7
%59 = call double @atan2(double %57, double %58)
%60 = load double*, double** %11
store double %59, double* %60
%61 = load double, double* %7
%62 = load double, double* %7
%63 = load double, double* %8
%64 = load double, double* %8
%65 = fmul double %63, %64
%66 = call double @llvm.fmuladd.f64(double %61, double %62, double %65)
%67 = fptosi double %66 to i32
%68 = call double @sqrt(i32 %67)
%69 = load double*, double** %10
%70 = load double, double* %69
%71 = call double @cos(double %70)
%72 = fdiv double %68, %71
%73 = load double*, double** %10
%74 = load double, double* %73
%75 = call double @sin(double %74)
%76 = call double @pow(double %75, i32 2)
%77 = call double @llvm.fmuladd.f64(double 0xBF7B6B90F1FE9412, double %76, double 1.000000e+00)
%78 = fptosi double %77 to i32
%79 = call double @sqrt(i32 %78)
%80 = fdiv double 0x415854A640000000, %79
%81 = fsub double %72, %80
%82 = load double*, double** %12
store double %81, double* %82
%83 = load double*, double** %10
%84 = load double, double* %83
%85 = fdiv double %84, 0x400921FB54442D18
%86 = fmul double %85, 1.800000e+02
%87 = load double*, double** %10
store double %86, double* %87
%88 = load double*, double** %11
%89 = load double, double* %88
%90 = fdiv double %89, 0x400921FB54442D18
%91 = fmul double %90, 1.800000e+02
%92 = load double*, double** %11
store double %91, double* %92
ret void
}

LLVM IR (-O2):
define void @ECEF_to_LLA(double %0, double %1, i64 %2, double* nocapture %3, double* nocapture %4, double* nocapture writeonly %5) {
%7 = sitofp i64 %2 to double
%8 = fmul double %7, 0x415854A640000000
%9 = fmul double %1, %1
%10 = tail call double @llvm.fmuladd.f64(double %0, double %0, double %9)
%11 = fptosi double %10 to i32
%12 = tail call double @sqrt(i32 %11)
%13 = fmul double %12, 0x41583FC4141C97D1
%14 = tail call double @atan2(double %8, double %13)
%15 = tail call double @sin(double %14)
%16 = tail call double @pow(double %15, i32 3)
%17 = tail call double @llvm.fmuladd.f64(double %16, double 0x40E4EB29F7EAC418, double %7)
%18 = tail call double @sqrt(i32 %11)
%19 = tail call double @sqrt(i32 %11)
%20 = fmul double %19, 0x41583FC4141C97D1
%21 = tail call double @atan2(double %8, double %20)
%22 = tail call double @cos(double %21)
%23 = tail call double @pow(double %22, i32 3)
%24 = tail call double @llvm.fmuladd.f64(double %23, double 0xC0E4D93586D1348F, double %18)
%25 = tail call double @atan2(double %17, double %24)
store double %25, double* %3
%26 = tail call double @atan2(double %1, double %0)
store double %26, double* %4
%27 = tail call double @sqrt(i32 %11)
%28 = load double, double* %3
%29 = tail call double @cos(double %28)
%30 = fdiv double %27, %29
%31 = load double, double* %3
%32 = tail call double @sin(double %31)
%33 = tail call double @pow(double %32, i32 2)
%34 = tail call double @llvm.fmuladd.f64(double %33, double 0xBF7B6B90F1FE9412, double 1.000000e+00)
%35 = fptosi double %34 to i32
%36 = tail call double @sqrt(i32 %35)
%37 = fdiv double 0x415854A640000000, %36
%38 = fsub double %30, %37
store double %38, double* %5
%39 = load double, double* %3
%40 = fdiv double %39, 0x400921FB54442D18
%41 = fmul double %40, 1.800000e+02
store double %41, double* %3
%42 = load double, double* %4
%43 = fdiv double %42, 0x400921FB54442D18
%44 = fmul double %43, 1.800000e+02
store double %44, double* %4
ret void
}