#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 */
int /*<<< orphan*/ compute_enu(double, double, double *, double *, double *);
double const cos(double const);
double const sin(double const);
void turtle_ecef_from_horizontal(double latitude, double longitude,
                                 double azimuth, double elevation,
                                 double direction[3]) {
  double e[3], n[3], u[3];
  compute_enu(latitude, longitude, e, n, u);
  const double az = azimuth * 3.14159265358979323846 / 180.;
  const double el = elevation * 3.14159265358979323846 / 180.;
  const double ce = cos(el);
  const double r[3] = {ce * sin(az), ce * cos(az), sin(el)};
  direction[0] = r[0] * e[0] + r[1] * n[0] + r[2] * u[0];
  direction[1] = r[0] * e[1] + r[1] * n[1] + r[2] * u[1];
  direction[2] = r[0] * e[2] + r[1] * n[2] + r[2] * u[2];
}


x86 assembly (clang, -O0):
<turtle_ecef_from_horizontal>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   1050 <compute_enu@plt>
movsd  0xe92(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xe7d(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  0xe71(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xe5c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
call   1040 <cos@plt>
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0xc0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0xb8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
call   1030 <sin@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0xb0(%rbp),%xmm1
ff
movsd  -0x40(%rbp),%xmm2
movsd  -0xa8(%rbp),%xmm0
ff
mulsd  -0x60(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
movsd  -0x80(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0xb0(%rbp),%xmm1
ff
movsd  -0x38(%rbp),%xmm2
movsd  -0xa8(%rbp),%xmm0
ff
mulsd  -0x58(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
movsd  -0x78(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0xb0(%rbp),%xmm1
ff
movsd  -0x30(%rbp),%xmm2
movsd  -0xa8(%rbp),%xmm0
ff
mulsd  -0x50(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
movsd  -0x70(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<turtle_ecef_from_horizontal>:
push   %rbx
sub    $0xa0,%rsp
mov    %rdi,%rbx
movsd  %xmm3,0x8(%rsp)
movsd  %xmm2,0x10(%rsp)
lea    0x80(%rsp),%rdi
lea    0x60(%rsp),%rsi
lea    0x40(%rsp),%rdx
call   1050 <compute_enu@plt>
movsd  0xe9a(%rip),%xmm2
movsd  0x10(%rsp),%xmm0
mulsd  %xmm2,%xmm0
movsd  0xe90(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  %xmm2,%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x28(%rsp),%xmm0
movapd %xmm0,0x30(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x28(%rsp),%xmm0
movapd %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movapd 0x10(%rsp),%xmm4
movapd %xmm4,%xmm1
unpcklpd %xmm4,%xmm1
mulpd  0x60(%rsp),%xmm1
movapd 0x30(%rsp),%xmm3
movapd %xmm3,%xmm2
unpcklpd %xmm3,%xmm2
mulpd  0x80(%rsp),%xmm2
addpd  %xmm1,%xmm2
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
mulpd  0x40(%rsp),%xmm1
addpd  %xmm2,%xmm1
movupd %xmm1,(%rbx)
movapd %xmm4,%xmm2
mulsd  0x70(%rsp),%xmm2
movapd %xmm3,%xmm1
mulsd  0x90(%rsp),%xmm1
addsd  %xmm2,%xmm1
mulsd  0x50(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rbx)
add    $0xa0,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define void @turtle_ecef_from_horizontal(double %0, double %1, double %2, double %3, double* nocapture writeonly %4) {
%6 = alloca [3 x double]
%7 = alloca [3 x double]
%8 = alloca [3 x double]
%9 = bitcast [3 x double]* %6 to i8*
%10 = bitcast [3 x double]* %7 to i8*
%11 = bitcast [3 x double]* %8 to i8*
%12 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%13 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%14 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%15 = call i32 @compute_enu(double %0, double %1, double* %12, double* %13, double* %14)
%16 = fmul double %2, 0x400921FB54442D18
%17 = fdiv double %16, 1.800000e+02
%18 = fmul double %3, 0x400921FB54442D18
%19 = fdiv double %18, 1.800000e+02
%20 = call double @cos(double %19)
%21 = call double @sin(double %17)
%22 = fmul double %20, %21
%23 = call double @cos(double %17)
%24 = fmul double %20, %23
%25 = call double @sin(double %19)
%26 = bitcast [3 x double]* %6 to <2 x double>*
%27 = load <2 x double>, <2 x double>* %26
%28 = bitcast [3 x double]* %7 to <2 x double>*
%29 = load <2 x double>, <2 x double>* %28
%30 = insertelement <2 x double> poison, double %24, i64 0
%31 = shufflevector <2 x double> %30, <2 x double> poison, <2 x i32> zeroinitializer
%32 = fmul <2 x double> %31, %29
%33 = insertelement <2 x double> poison, double %22, i64 0
%34 = shufflevector <2 x double> %33, <2 x double> poison, <2 x i32> zeroinitializer
%35 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %34, <2 x double> %27, <2 x double> %32)
%36 = bitcast [3 x double]* %8 to <2 x double>*
%37 = load <2 x double>, <2 x double>* %36
%38 = insertelement <2 x double> poison, double %25, i64 0
%39 = shufflevector <2 x double> %38, <2 x double> poison, <2 x i32> zeroinitializer
%40 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %39, <2 x double> %37, <2 x double> %35)
%41 = bitcast double* %4 to <2 x double>*
store <2 x double> %40, <2 x double>* %41
%42 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
%43 = load double, double* %42
%44 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 2
%45 = load double, double* %44
%46 = fmul double %24, %45
%47 = call double @llvm.fmuladd.f64(double %22, double %43, double %46)
%48 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 2
%49 = load double, double* %48
%50 = call double @llvm.fmuladd.f64(double %25, double %49, double %47)
%51 = getelementptr inbounds double, double* %4, i64 2
store double %50, double* %51
ret void
}