#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 atan2(double, double);
double cos(double);
double sin(double);
double sqrt(double);
void palDh2e(double az, double el, double phi, double *ha, double *dec) {
  double sa;
  double ca;
  double se;
  double ce;
  double sp;
  double cp;
  double x;
  double y;
  double z;
  double r;
  sa = sin(az);
  ca = cos(az);
  se = sin(el);
  ce = cos(el);
  sp = sin(phi);
  cp = cos(phi);
  x = -ca * ce * sp + se * cp;
  y = -sa * ce;
  z = ca * ce * cp + se * sp;
  r = sqrt(x * x + y * y);
  if (r == 0.) {
    *ha = 0.;
  } else {
    *ha = atan2(y, x);
  }
  *dec = atan2(z, r);
  return;
}


x86 assembly (clang, -O0):
<palDh2e>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm1
mulsd  -0x68(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1293 <palDh2e+0x153>
jp     1293 <palDh2e+0x153>
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    12aa <palDh2e+0x16a>
movsd  -0x68(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
call   1030 <atan2@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x70(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm1
call   1030 <atan2@plt>
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<palDh2e>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm2,(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
call   1040 <sin@plt>
movaps %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1050 <cos@plt>
movapd %xmm0,%xmm2
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm4
mulsd  %xmm4,%xmm0
movsd  0x30(%rsp),%xmm1
mulsd  %xmm2,%xmm1
movsd  %xmm0,0x10(%rsp)
mulsd  0x8(%rsp),%xmm0
movapd 0x20(%rsp),%xmm3
xorpd  0xe13(%rip),%xmm3
subsd  %xmm0,%xmm1
mulsd  %xmm4,%xmm3
movapd %xmm3,0x20(%rsp)
mulsd  %xmm3,%xmm3
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm3,%xmm0
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm0
jb     121e <palDh2e+0xde>
xorps  %xmm3,%xmm3
sqrtsd %xmm0,%xmm3
jmp    1241 <palDh2e+0x101>
movsd  %xmm2,(%rsp)
movsd  %xmm1,0x18(%rsp)
call   1060 <sqrt@plt>
xorpd  %xmm4,%xmm4
movsd  0x18(%rsp),%xmm1
movsd  (%rsp),%xmm2
movapd %xmm0,%xmm3
ucomisd %xmm4,%xmm3
jne    1249 <palDh2e+0x109>
jnp    126e <palDh2e+0x12e>
movapd 0x20(%rsp),%xmm0
movsd  %xmm2,(%rsp)
movsd  %xmm3,0x20(%rsp)
call   1030 <atan2@plt>
movsd  0x20(%rsp),%xmm3
movsd  (%rsp),%xmm2
movapd %xmm0,%xmm4
movsd  %xmm4,(%rbx)
movsd  0x30(%rsp),%xmm1
mulsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movapd %xmm3,%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,(%r14)
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @palDh2e(double %0, double %1, double %2, double* nocapture writeonly %3, double* nocapture writeonly %4) {
%6 = tail call double @sin(double %0)
%7 = tail call double @cos(double %0)
%8 = tail call double @sin(double %1)
%9 = tail call double @cos(double %1)
%10 = tail call double @sin(double %2)
%11 = tail call double @cos(double %2)
%12 = fneg double %7
%13 = fmul double %9, %12
%14 = fmul double %8, %11
%15 = tail call double @llvm.fmuladd.f64(double %13, double %10, double %14)
%16 = fneg double %6
%17 = fmul double %9, %16
%18 = fmul double %17, %17
%19 = tail call double @llvm.fmuladd.f64(double %15, double %15, double %18)
%20 = tail call double @sqrt(double %19)
%21 = fcmp oeq double %20, 0.000000e+00
br i1 %21, label %24, label %22
22: ; preds = %5
%23 = tail call double @atan2(double %17, double %15)
br label %24
24: ; preds = %5, %22
%25 = phi double [ %23, %22 ], [ 0.000000e+00, %5 ]
store double %25, double* %3
%26 = fmul double %7, %9
%27 = fmul double %8, %10
%28 = tail call double @llvm.fmuladd.f64(double %26, double %11, double %27)
%29 = tail call double @atan2(double %28, double %20)
store double %29, double* %4
ret void
}