#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 const);
double sin(double const);
double sqrt(double);
extern void pos2ecef(const double *pos, double *r) {
  double sinp = sin(pos[0]), cosp = cos(pos[0]), sinl = sin(pos[1]),
         cosl = cos(pos[1]);
  double e2 = (1.0 / 298.257223563) * (2.0 - (1.0 / 298.257223563)),
         v = 6378137.0 / sqrt(1.0 - e2 * sinp * sinp);
  r[0] = (v + pos[2]) * cosp * cosl;
  r[1] = (v + pos[2]) * cosp * sinl;
  r[2] = (v * (1.0 - e2) + pos[2]) * sinp;
}


x86 assembly (clang, -O0):
<pos2ecef>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  0xe7e(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe37(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe2b(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x10(%rax),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x10(%rax),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x40(%rbp),%xmm0
movsd  0xdcc(%rip),%xmm2
subsd  -0x38(%rbp),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pos2ecef>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rbx),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rbx),%xmm0
call   1040 <cos@plt>
movsd  0xe83(%rip),%xmm1
movsd  0x8(%rsp),%xmm2
mulsd  %xmm2,%xmm1
mulsd  %xmm2,%xmm1
addsd  0xe75(%rip),%xmm1
movapd %xmm0,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     11aa <pos2ecef+0x7a>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    11bf <pos2ecef+0x8f>
movapd %xmm1,%xmm0
movsd  %xmm3,0x10(%rsp)
call   1050 <sqrt@plt>
movsd  0x10(%rsp),%xmm3
movsd  0xe49(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0x10(%rbx),%xmm0
addsd  %xmm1,%xmm0
movsd  0x20(%rsp),%xmm2
mulsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm3
movsd  %xmm3,(%r14)
movsd  0x10(%rbx),%xmm0
addsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
movsd  0x18(%rsp),%xmm2
mulsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%r14)
mulsd  0xe0c(%rip),%xmm1
addsd  0x10(%rbx),%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @pos2ecef(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double* %0, double** %3
store double* %1, double** %4
%11 = load double*, double** %3
%12 = getelementptr inbounds double, double* %11, i64 0
%13 = load double, double* %12
%14 = call double @sin(double %13)
store double %14, double* %5
%15 = load double*, double** %3
%16 = getelementptr inbounds double, double* %15, i64 0
%17 = load double, double* %16
%18 = call double @cos(double %17)
store double %18, double* %6
%19 = load double*, double** %3
%20 = getelementptr inbounds double, double* %19, i64 1
%21 = load double, double* %20
%22 = call double @sin(double %21)
store double %22, double* %7
%23 = load double*, double** %3
%24 = getelementptr inbounds double, double* %23, i64 1
%25 = load double, double* %24
%26 = call double @cos(double %25)
store double %26, double* %8
store double 0x3F7B6B90F1FE94F0, double* %9
%27 = load double, double* %9
%28 = load double, double* %5
%29 = fmul double %27, %28
%30 = load double, double* %5
%31 = fneg double %29
%32 = call double @llvm.fmuladd.f64(double %31, double %30, double 1.000000e+00)
%33 = call double @sqrt(double %32)
%34 = fdiv double 0x415854A640000000, %33
store double %34, double* %10
%35 = load double, double* %10
%36 = load double*, double** %3
%37 = getelementptr inbounds double, double* %36, i64 2
%38 = load double, double* %37
%39 = fadd double %35, %38
%40 = load double, double* %6
%41 = fmul double %39, %40
%42 = load double, double* %8
%43 = fmul double %41, %42
%44 = load double*, double** %4
%45 = getelementptr inbounds double, double* %44, i64 0
store double %43, double* %45
%46 = load double, double* %10
%47 = load double*, double** %3
%48 = getelementptr inbounds double, double* %47, i64 2
%49 = load double, double* %48
%50 = fadd double %46, %49
%51 = load double, double* %6
%52 = fmul double %50, %51
%53 = load double, double* %7
%54 = fmul double %52, %53
%55 = load double*, double** %4
%56 = getelementptr inbounds double, double* %55, i64 1
store double %54, double* %56
%57 = load double, double* %10
%58 = load double, double* %9
%59 = fsub double 1.000000e+00, %58
%60 = load double*, double** %3
%61 = getelementptr inbounds double, double* %60, i64 2
%62 = load double, double* %61
%63 = call double @llvm.fmuladd.f64(double %57, double %59, double %62)
%64 = load double, double* %5
%65 = fmul double %63, %64
%66 = load double*, double** %4
%67 = getelementptr inbounds double, double* %66, i64 2
store double %65, double* %67
ret void
}

LLVM IR (-O2):
define void @pos2ecef(double* nocapture %0, double* nocapture writeonly %1) {
%3 = load double, double* %0
%4 = tail call double @sin(double %3)
%5 = load double, double* %0
%6 = tail call double @cos(double %5)
%7 = getelementptr inbounds double, double* %0, i64 1
%8 = load double, double* %7
%9 = tail call double @sin(double %8)
%10 = load double, double* %7
%11 = tail call double @cos(double %10)
%12 = fmul double %4, 0xBF7B6B90F1FE94F0
%13 = tail call double @llvm.fmuladd.f64(double %12, double %4, double 1.000000e+00)
%14 = tail call double @sqrt(double %13)
%15 = fdiv double 0x415854A640000000, %14
%16 = getelementptr inbounds double, double* %0, i64 2
%17 = load double, double* %16
%18 = fadd double %15, %17
%19 = fmul double %6, %18
%20 = fmul double %11, %19
store double %20, double* %1
%21 = load double, double* %16
%22 = fadd double %15, %21
%23 = fmul double %6, %22
%24 = fmul double %9, %23
%25 = getelementptr inbounds double, double* %1, i64 1
store double %24, double* %25
%26 = load double, double* %16
%27 = tail call double @llvm.fmuladd.f64(double %15, double 0x3FEFC928DE1C02D6, double %26)
%28 = fmul double %4, %27
%29 = getelementptr inbounds double, double* %1, i64 2
store double %28, double* %29
ret void
}