#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(int);
void blhToxyz(const double *blh, double *xyz) {
  double N = 0;
  N = 6.3781370e6 / sqrt(1 - 0.00669437999013 * sin(blh[0]) * sin(blh[0]));
  xyz[0] = (N + blh[2]) * cos(blh[0]) * cos(blh[1]);
  xyz[1] = (N + blh[2]) * cos(blh[0]) * sin(blh[1]);
  xyz[2] = (N * (1 - 0.00669437999013) + blh[2]) * sin(blh[0]);
}


x86 assembly (clang, -O0):
<blhToxyz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  0xeb8(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe6f(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe4f(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
movsd  0xd81(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blhToxyz>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rbx),%xmm0
call   1030 <sin@plt>
movsd  0x10(%rsp),%xmm1
mulsd  0xe9d(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xe99(%rip),%xmm1
cvttsd2si %xmm1,%edi
call   1050 <sqrt@plt>
movsd  0xe90(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x10(%rbx),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx),%xmm0
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rbx),%xmm0
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14)
movsd  0x10(%rbx),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx),%xmm0
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rbx),%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  0xe11(%rip),%xmm1
movsd  %xmm0,0x8(%r14)
addsd  0x10(%rbx),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  (%rbx),%xmm0
call   1030 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @blhToxyz(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 @sin(double %5)
%7 = fmul double %4, 0xBF7B6B90F1FE61F9
%8 = tail call double @llvm.fmuladd.f64(double %7, double %6, double 1.000000e+00)
%9 = fptosi double %8 to i32
%10 = tail call double @sqrt(i32 %9)
%11 = fdiv double 0x415854A640000000, %10
%12 = getelementptr inbounds double, double* %0, i64 2
%13 = load double, double* %12
%14 = fadd double %11, %13
%15 = load double, double* %0
%16 = tail call double @cos(double %15)
%17 = fmul double %14, %16
%18 = getelementptr inbounds double, double* %0, i64 1
%19 = load double, double* %18
%20 = tail call double @cos(double %19)
%21 = fmul double %17, %20
store double %21, double* %1
%22 = load double, double* %12
%23 = fadd double %11, %22
%24 = load double, double* %0
%25 = tail call double @cos(double %24)
%26 = fmul double %23, %25
%27 = load double, double* %18
%28 = tail call double @sin(double %27)
%29 = fmul double %26, %28
%30 = getelementptr inbounds double, double* %1, i64 1
store double %29, double* %30
%31 = load double, double* %12
%32 = tail call double @llvm.fmuladd.f64(double %11, double 0x3FEFC928DE1C033C, double %31)
%33 = load double, double* %0
%34 = tail call double @sin(double %33)
%35 = fmul double %32, %34
%36 = getelementptr inbounds double, double* %1, i64 2
store double %35, double* %36
ret void
}