#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 palPa(double ha, double dec, double phi) {
  double cp, sqsz, cqsz;
  cp = cos(phi);
  sqsz = cp * sin(ha);
  cqsz = sin(phi) * cos(dec) - cp * sin(dec) * cos(ha);
  if (sqsz == 0.0 && cqsz == 0.0)
    cqsz = 1.0;
  return atan2(sqsz, cqsz);
}


x86 assembly (clang, -O0):
<palPa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <cos@plt>
movsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    123f <palPa+0x10f>
jp     123f <palPa+0x10f>
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    123f <palPa+0x10f>
jp     123f <palPa+0x10f>
movsd  0xdc6(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
call   1030 <atan2@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<palPa>:
sub    $0x48,%rsp
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x20(%rsp)
movaps %xmm2,%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x20(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x28(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,0x30(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
call   1050 <cos@plt>
movsd  0x8(%rsp),%xmm1
mulsd  0x18(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd 0x30(%rsp),%xmm3
mulsd  0x10(%rsp),%xmm3
subsd  %xmm1,%xmm3
xorpd  %xmm1,%xmm1
movapd %xmm3,%xmm0
cmpeqsd %xmm1,%xmm0
movsd  0xe23(%rip),%xmm2
andpd  %xmm0,%xmm2
andnpd %xmm3,%xmm0
orpd   %xmm0,%xmm2
movsd  0x28(%rsp),%xmm0
cmpeqsd %xmm0,%xmm1
andpd  %xmm1,%xmm2
andnpd %xmm3,%xmm1
orpd   %xmm2,%xmm1
add    $0x48,%rsp
jmp    1030 <atan2@plt>

LLVM IR (-O0):
define double @palPa(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%10 = load double, double* %6
%11 = call double @cos(double %10)
store double %11, double* %7
%12 = load double, double* %7
%13 = load double, double* %4
%14 = call double @sin(double %13)
%15 = fmul double %12, %14
store double %15, double* %8
%16 = load double, double* %6
%17 = call double @sin(double %16)
%18 = load double, double* %5
%19 = call double @cos(double %18)
%20 = load double, double* %7
%21 = load double, double* %5
%22 = call double @sin(double %21)
%23 = fmul double %20, %22
%24 = load double, double* %4
%25 = call double @cos(double %24)
%26 = fmul double %23, %25
%27 = fneg double %26
%28 = call double @llvm.fmuladd.f64(double %17, double %19, double %27)
store double %28, double* %9
%29 = load double, double* %8
%30 = fcmp oeq double %29, 0.000000e+00
br i1 %30, label %31, label %35
31: ; preds = %3
%32 = load double, double* %9
%33 = fcmp oeq double %32, 0.000000e+00
br i1 %33, label %34, label %35
34: ; preds = %31
store double 1.000000e+00, double* %9
br label %35
35: ; preds = %34, %31, %3
%36 = load double, double* %8
%37 = load double, double* %9
%38 = call double @atan2(double %36, double %37)
ret double %38
}

LLVM IR (-O2):
define double @palPa(double %0, double %1, double %2) {
%4 = tail call double @cos(double %2)
%5 = tail call double @sin(double %0)
%6 = fmul double %4, %5
%7 = tail call double @sin(double %2)
%8 = tail call double @cos(double %1)
%9 = tail call double @sin(double %1)
%10 = tail call double @cos(double %0)
%11 = fneg double %4
%12 = fmul double %9, %11
%13 = fmul double %12, %10
%14 = tail call double @llvm.fmuladd.f64(double %7, double %8, double %13)
%15 = fcmp oeq double %6, 0.000000e+00
%16 = fcmp oeq double %14, 0.000000e+00
%17 = select i1 %15, i1 %16, i1 false
%18 = select i1 %17, double 1.000000e+00, double %14
%19 = tail call double @atan2(double %6, double %18)
ret double %19
}