#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 asin(double);
double atan2(double, double);
int dot(double *, double *, int);
int /*<<< orphan*/ ecef2enu(double const *, double const *, double *);
extern double satazel(const double *pos, const double *e, double *azel) {
  double az = 0.0, el = 3.1415926535897932 / 2.0, enu[3];
  if (pos[2] > -6378137.0) {
    ecef2enu(pos, e, enu);
    az = dot(enu, enu, 2) < 1E-12 ? 0.0 : atan2(enu[0], enu[1]);
    if (az < 0.0)
      az += 2 * 3.1415926535897932;
    el = asin(enu[2]);
  }
  if (azel) {
    azel[0] = az;
    azel[1] = el;
  }
  return el;
}


x86 assembly (clang, -O0):
<satazel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xea4(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  0xe86(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1217 <satazel+0xd7>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1060 <ecef2enu@plt>
lea    -0x40(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x2,%edx
call   1030 <dot@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe5d(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11ca <satazel+0x8a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    11de <satazel+0x9e>
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
call   1040 <atan2@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1208 <satazel+0xc8>
movsd  0xe1a(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1050 <asin@plt>
movsd  %xmm0,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     123d <satazel+0xfd>
movsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x28(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<satazel>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%rbx
movsd  0x10(%rdi),%xmm0
ucomisd 0xeb1(%rip),%xmm0
jbe    11d2 <satazel+0x92>
mov    %rsp,%r14
mov    %r14,%rdx
call   1060 <ecef2enu@plt>
mov    %r14,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1030 <dot@plt>
xorpd  %xmm2,%xmm2
xorpd  %xmm0,%xmm0
test   %eax,%eax
jle    1194 <satazel+0x54>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1040 <atan2@plt>
xorpd  %xmm2,%xmm2
movsd  0xe74(%rip),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm0,%xmm3
cmpltsd %xmm2,%xmm3
andpd  %xmm3,%xmm1
andnpd %xmm0,%xmm3
orpd   %xmm1,%xmm3
movapd %xmm3,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <asin@plt>
movaps 0x20(%rsp),%xmm1
test   %rbx,%rbx
jne    11e2 <satazel+0xa2>
jmp    11eb <satazel+0xab>
movsd  0xe26(%rip),%xmm0
xorps  %xmm1,%xmm1
test   %rbx,%rbx
je     11eb <satazel+0xab>
movsd  %xmm1,(%rbx)
movsd  %xmm0,0x8(%rbx)
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @satazel(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca double
%9 = alloca [3 x double]
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
store double 0.000000e+00, double* %7
store double 0x3FF921FB54442D18, double* %8
%10 = load double*, double** %4
%11 = getelementptr inbounds double, double* %10, i64 2
%12 = load double, double* %11
%13 = fcmp ogt double %12, 0xC15854A640000000
br i1 %13, label %14, label %42
14: ; preds = %3
%15 = load double*, double** %4
%16 = load double*, double** %5
%17 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%18 = call i32 @ecef2enu(double* %15, double* %16, double* %17)
%19 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%20 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%21 = call i32 @dot(double* %19, double* %20, i32 2)
%22 = sitofp i32 %21 to double
%23 = fcmp olt double %22, 0x3D719799812DEA11
br i1 %23, label %24, label %25
24: ; preds = %14
br label %31
25: ; preds = %14
%26 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%27 = load double, double* %26
%28 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 1
%29 = load double, double* %28
%30 = call double @atan2(double %27, double %29)
br label %31
31: ; preds = %25, %24
%32 = phi double [ 0.000000e+00, %24 ], [ %30, %25 ]
store double %32, double* %7
%33 = load double, double* %7
%34 = fcmp olt double %33, 0.000000e+00
br i1 %34, label %35, label %38
35: ; preds = %31
%36 = load double, double* %7
%37 = fadd double %36, 0x401921FB54442D18
store double %37, double* %7
br label %38
38: ; preds = %35, %31
%39 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 2
%40 = load double, double* %39
%41 = call double @asin(double %40)
store double %41, double* %8
br label %42
42: ; preds = %38, %3
%43 = load double*, double** %6
%44 = icmp ne double* %43, null
br i1 %44, label %45, label %52
45: ; preds = %42
%46 = load double, double* %7
%47 = load double*, double** %6
%48 = getelementptr inbounds double, double* %47, i64 0
store double %46, double* %48
%49 = load double, double* %8
%50 = load double*, double** %6
%51 = getelementptr inbounds double, double* %50, i64 1
store double %49, double* %51
br label %52
52: ; preds = %45, %42
%53 = load double, double* %8
ret double %53
}

LLVM IR (-O2):
define double @satazel(double* %0, double* %1, double* writeonly %2) {
%4 = alloca [3 x double]
%5 = bitcast [3 x double]* %4 to i8*
%6 = getelementptr inbounds double, double* %0, i64 2
%7 = load double, double* %6
%8 = fcmp ogt double %7, 0xC15854A640000000
br i1 %8, label %9, label %27
9: ; preds = %3
%10 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%11 = call i32 @ecef2enu(double* %0, double* %1, double* %10)
%12 = call i32 @dot(double* %10, double* %10, i32 2)
%13 = icmp slt i32 %12, 1
br i1 %13, label %19, label %14
14: ; preds = %9
%15 = load double, double* %10
%16 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 1
%17 = load double, double* %16
%18 = call double @atan2(double %15, double %17)
br label %19
19: ; preds = %9, %14
%20 = phi double [ %18, %14 ], [ 0.000000e+00, %9 ]
%21 = fcmp olt double %20, 0.000000e+00
%22 = fadd double %20, 0x401921FB54442D18
%23 = select i1 %21, double %22, double %20
%24 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
%25 = load double, double* %24
%26 = call double @asin(double %25)
br label %27
27: ; preds = %19, %3
%28 = phi double [ %23, %19 ], [ 0.000000e+00, %3 ]
%29 = phi double [ %26, %19 ], [ 0x3FF921FB54442D18, %3 ]
%30 = icmp eq double* %2, null
br i1 %30, label %33, label %31
31: ; preds = %27
store double %28, double* %2
%32 = getelementptr inbounds double, double* %2, i64 1
store double %29, double* %32
br label %33
33: ; preds = %31, %27
ret double %29
}