#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 sin(double);
double sqrt(double);
void llh2xyz(double *llh, double *xyz) {
  double n;
  double a;
  double e;
  double e2;
  double clat;
  double slat;
  double clon;
  double slon;
  double d, nph;
  double tmp;
  a = 6378137.0;
  e = 0.0818191908426;
  e2 = e * e;
  clat = cos(llh[0]);
  slat = sin(llh[0]);
  clon = cos(llh[1]);
  slon = sin(llh[1]);
  d = e * slat;
  n = a / sqrt(1.0 - d * d);
  nph = n + llh[2];
  tmp = nph * clat;
  xyz[0] = tmp * clon;
  xyz[1] = tmp * slon;
  xyz[2] = ((1.0 - e2) * n + llh[2]) * slat;
  return;
}


x86 assembly (clang, -O0):
<llh2xyz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  0xec8(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xeb3(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe07(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x68(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  0xd9e(%rip),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0x40(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<llh2xyz>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
call   1040 <cos@plt>
movaps %xmm0,0x30(%rsp)
movsd  (%rbx),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rbx),%xmm0
call   1040 <cos@plt>
movaps %xmm0,0x20(%rsp)
movsd  0x8(%rbx),%xmm0
call   1030 <sin@plt>
movapd %xmm0,%xmm3
movsd  0xe81(%rip),%xmm1
mulsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm1
movsd  0xe77(%rip),%xmm0
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11a5 <llh2xyz+0x75>
sqrtsd %xmm0,%xmm0
jmp    11b6 <llh2xyz+0x86>
movapd %xmm3,0x10(%rsp)
call   1050 <sqrt@plt>
movapd 0x10(%rsp),%xmm3
movsd  0xe52(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  0x10(%rbx),%xmm0
addsd  %xmm1,%xmm0
movapd 0x30(%rsp),%xmm2
mulsd  %xmm0,%xmm2
movapd 0x20(%rsp),%xmm0
unpcklpd %xmm3,%xmm0
unpcklpd %xmm2,%xmm2
mulpd  %xmm0,%xmm2
movupd %xmm2,(%r14)
mulsd  0xe24(%rip),%xmm1
addsd  0x10(%rbx),%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%r14)
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

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

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