#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(int);
void llh2xyz(double llh[], double xyz[]) {
  double a, f, a_WGS84, f_WGS84;
  double e2, N, temp;
  double lat, lon, h;
  double ellip[2] = {0, 0};
  a_WGS84 = 6378137;
  f_WGS84 = 1 / 298.257223563;
  a = a_WGS84 - ellip[0];
  f = f_WGS84 - ellip[1] * 1e-4;
  e2 = f * (2 - f);
  lat = 3.1415926535898 * llh[0] / 180;
  lon = 3.1415926535898 * llh[1] / 180;
  h = llh[2];
  N = a / sqrt(1 - e2 * sin(lat) * sin(lat));
  temp = (N + h) * cos(lat);
  xyz[0] = temp * cos(lon);
  xyz[1] = temp * sin(lon);
  xyz[2] = (N * (1 - e2) + h) * sin(lat);
}


x86 assembly (clang, -O0):
<llh2xyz>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
movsd  0xec5(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xeb0(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe6b(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe49(%rip),%xmm1
subsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  0xe27(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  0xe13(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rax
movsd  0xe06(%rip),%xmm0
mulsd  0x8(%rax),%xmm0
movsd  0xdf1(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0xa8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd5f(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x40(%rbp),%xmm0
movsd  0xcaa(%rip),%xmm2
subsd  -0x38(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<llh2xyz>:
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%rbx
movsd  0xec0(%rip),%xmm2
movsd  (%rdi),%xmm0
mulsd  %xmm2,%xmm0
movsd  0xeb8(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x18(%rsp)
mulsd  0x8(%rdi),%xmm2
divsd  %xmm1,%xmm2
movsd  %xmm2,0x20(%rsp)
movsd  0x10(%rdi),%xmm1
movsd  %xmm1,0x28(%rsp)
call   1030 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x8(%rsp),%xmm1
mulsd  0xe78(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xe74(%rip),%xmm1
cvttsd2si %xmm1,%edi
call   1050 <sqrt@plt>
movsd  0xe6b(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x20(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x20(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rbx)
movsd  0x8(%rsp),%xmm0
mulsd  0xe09(%rip),%xmm0
addsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rbx)
add    $0x30,%rsp
pop    %rbx
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 [2 x double]
store double* %0, double** %3
store double* %1, double** %4
%16 = bitcast [2 x double]* %15 to i8*
store double 0x415854A640000000, double* %7
store double 0x3F6B775A84F3E128, double* %8
%17 = load double, double* %7
%18 = getelementptr inbounds [2 x double], [2 x double]* %15, i64 0, i64 0
%19 = load double, double* %18
%20 = fsub double %17, %19
store double %20, double* %5
%21 = load double, double* %8
%22 = getelementptr inbounds [2 x double], [2 x double]* %15, i64 0, i64 1
%23 = load double, double* %22
%24 = fneg double %23
%25 = call double @llvm.fmuladd.f64(double %24, double 1.000000e-04, double %21)
store double %25, double* %6
%26 = load double, double* %6
%27 = load double, double* %6
%28 = fsub double 2.000000e+00, %27
%29 = fmul double %26, %28
store double %29, double* %9
%30 = load double*, double** %3
%31 = getelementptr inbounds double, double* %30, i64 0
%32 = load double, double* %31
%33 = fmul double 0x400921FB54442D28, %32
%34 = fdiv double %33, 1.800000e+02
store double %34, double* %12
%35 = load double*, double** %3
%36 = getelementptr inbounds double, double* %35, i64 1
%37 = load double, double* %36
%38 = fmul double 0x400921FB54442D28, %37
%39 = fdiv double %38, 1.800000e+02
store double %39, double* %13
%40 = load double*, double** %3
%41 = getelementptr inbounds double, double* %40, i64 2
%42 = load double, double* %41
store double %42, double* %14
%43 = load double, double* %5
%44 = load double, double* %9
%45 = load double, double* %12
%46 = call double @sin(double %45)
%47 = fmul double %44, %46
%48 = load double, double* %12
%49 = call double @sin(double %48)
%50 = fneg double %47
%51 = call double @llvm.fmuladd.f64(double %50, double %49, double 1.000000e+00)
%52 = fptosi double %51 to i32
%53 = call double @sqrt(i32 %52)
%54 = fdiv double %43, %53
store double %54, double* %10
%55 = load double, double* %10
%56 = load double, double* %14
%57 = fadd double %55, %56
%58 = load double, double* %12
%59 = call double @cos(double %58)
%60 = fmul double %57, %59
store double %60, double* %11
%61 = load double, double* %11
%62 = load double, double* %13
%63 = call double @cos(double %62)
%64 = fmul double %61, %63
%65 = load double*, double** %4
%66 = getelementptr inbounds double, double* %65, i64 0
store double %64, double* %66
%67 = load double, double* %11
%68 = load double, double* %13
%69 = call double @sin(double %68)
%70 = fmul double %67, %69
%71 = load double*, double** %4
%72 = getelementptr inbounds double, double* %71, i64 1
store double %70, double* %72
%73 = load double, double* %10
%74 = load double, double* %9
%75 = fsub double 1.000000e+00, %74
%76 = load double, double* %14
%77 = call double @llvm.fmuladd.f64(double %73, double %75, double %76)
%78 = load double, double* %12
%79 = call double @sin(double %78)
%80 = fmul double %77, %79
%81 = load double*, double** %4
%82 = getelementptr inbounds double, double* %81, i64 2
store double %80, double* %82
ret void
}

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