#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);
double sin(double);
void palDs2tp(double ra, double dec, double raz, double decz, double *xi,
              double *eta, int *j) {
  const double TINY = 1.0e-6;
  double cdec;
  double sdec;
  double radif;
  double cdecz;
  double denom;
  double sdecz;
  double cradif;
  double sradif;
  sdecz = sin(decz);
  sdec = sin(dec);
  cdecz = cos(decz);
  cdec = cos(dec);
  radif = ra - raz;
  sradif = sin(radif);
  cradif = cos(radif);
  denom = sdec * sdecz + cdec * cdecz * cradif;
  if (denom > TINY) {
    *j = 0;
  } else if (denom >= 0.) {
    *j = 1;
    denom = TINY;
  } else if (denom > -TINY) {
    *j = 2;
    denom = -TINY;
  } else {
    *j = 3;
  }
  *xi = cdec * sradif / denom;
  *eta = (sdec * cdecz - cdec * sdecz * cradif) / denom;
  return;
}


x86 assembly (clang, -O0):
<palDs2tp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
movsd  0xead(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm1
mulsd  -0x60(%rbp),%xmm1
mulsd  -0x78(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  0xe0c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    120d <palDs2tp+0xed>
mov    -0x38(%rbp),%rax
movl   $0x0,(%rax)
jmp    1282 <palDs2tp+0x162>
movsd  -0x68(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     123b <palDs2tp+0x11b>
mov    -0x38(%rbp),%rax
movl   $0x1,(%rax)
movsd  0xdcf(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    127d <palDs2tp+0x15d>
movsd  -0x68(%rbp),%xmm0
movsd  0xdc0(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    126e <palDs2tp+0x14e>
mov    -0x38(%rbp),%rax
movl   $0x2,(%rax)
movsd  0xda4(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    1278 <palDs2tp+0x158>
mov    -0x38(%rbp),%rax
movl   $0x3,(%rax)
jmp    127d <palDs2tp+0x15d>
jmp    1282 <palDs2tp+0x162>
movsd  -0x48(%rbp),%xmm0
mulsd  -0x80(%rbp),%xmm0
divsd  -0x68(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm1
mulsd  -0x70(%rbp),%xmm1
mulsd  -0x78(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x68(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<palDs2tp>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
movsd  %xmm3,0x10(%rsp)
movsd  %xmm2,0x30(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x18(%rsp)
movaps %xmm3,%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x38(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
subsd  0x30(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
call   1030 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1040 <cos@plt>
movsd  0x20(%rsp),%xmm6
movsd  0x10(%rsp),%xmm5
movsd  0x28(%rsp),%xmm4
movsd  0x38(%rsp),%xmm3
movapd %xmm5,%xmm2
mulsd  %xmm6,%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm4,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
xor    %eax,%eax
ucomisd 0xe13(%rip),%xmm1
ja     1224 <palDs2tp+0x104>
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
jae    1217 <palDs2tp+0xf7>
movsd  0xe07(%rip),%xmm2
xor    %eax,%eax
ucomisd %xmm2,%xmm1
seta   %al
xor    $0x3,%eax
minsd  %xmm1,%xmm2
movapd %xmm2,%xmm1
jmp    1224 <palDs2tp+0x104>
movsd  0xde1(%rip),%xmm1
mov    $0x1,%eax
mov    %eax,(%rbx)
movsd  0x8(%rsp),%xmm2
mulsd  %xmm6,%xmm2
divsd  %xmm1,%xmm2
movsd  %xmm2,(%r15)
mulsd  %xmm6,%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm5,%xmm4
subsd  %xmm3,%xmm4
divsd  %xmm1,%xmm4
movsd  %xmm4,(%r14)
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @palDs2tp(double %0, double %1, double %2, double %3, double* %4, double* %5, i32* %6) {
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double*
%13 = alloca double*
%14 = alloca i32*
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
store double %0, double* %8
store double %1, double* %9
store double %2, double* %10
store double %3, double* %11
store double* %4, double** %12
store double* %5, double** %13
store i32* %6, i32** %14
store double 0x3EB0C6F7A0B5ED8D, double* %15
%24 = load double, double* %11
%25 = call double @sin(double %24)
store double %25, double* %21
%26 = load double, double* %9
%27 = call double @sin(double %26)
store double %27, double* %17
%28 = load double, double* %11
%29 = call double @cos(double %28)
store double %29, double* %19
%30 = load double, double* %9
%31 = call double @cos(double %30)
store double %31, double* %16
%32 = load double, double* %8
%33 = load double, double* %10
%34 = fsub double %32, %33
store double %34, double* %18
%35 = load double, double* %18
%36 = call double @sin(double %35)
store double %36, double* %23
%37 = load double, double* %18
%38 = call double @cos(double %37)
store double %38, double* %22
%39 = load double, double* %17
%40 = load double, double* %21
%41 = load double, double* %16
%42 = load double, double* %19
%43 = fmul double %41, %42
%44 = load double, double* %22
%45 = fmul double %43, %44
%46 = call double @llvm.fmuladd.f64(double %39, double %40, double %45)
store double %46, double* %20
%47 = load double, double* %20
%48 = fcmp ogt double %47, 0x3EB0C6F7A0B5ED8D
br i1 %48, label %49, label %51
49: ; preds = %7
%50 = load i32*, i32** %14
store i32 0, i32* %50
br label %65
51: ; preds = %7
%52 = load double, double* %20
%53 = fcmp oge double %52, 0.000000e+00
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = load i32*, i32** %14
store i32 1, i32* %55
store double 0x3EB0C6F7A0B5ED8D, double* %20
br label %64
56: ; preds = %51
%57 = load double, double* %20
%58 = fcmp ogt double %57, 0xBEB0C6F7A0B5ED8D
br i1 %58, label %59, label %61
59: ; preds = %56
%60 = load i32*, i32** %14
store i32 2, i32* %60
store double 0xBEB0C6F7A0B5ED8D, double* %20
br label %63
61: ; preds = %56
%62 = load i32*, i32** %14
store i32 3, i32* %62
br label %63
63: ; preds = %61, %59
br label %64
64: ; preds = %63, %54
br label %65
65: ; preds = %64, %49
%66 = load double, double* %16
%67 = load double, double* %23
%68 = fmul double %66, %67
%69 = load double, double* %20
%70 = fdiv double %68, %69
%71 = load double*, double** %12
store double %70, double* %71
%72 = load double, double* %17
%73 = load double, double* %19
%74 = load double, double* %16
%75 = load double, double* %21
%76 = fmul double %74, %75
%77 = load double, double* %22
%78 = fmul double %76, %77
%79 = fneg double %78
%80 = call double @llvm.fmuladd.f64(double %72, double %73, double %79)
%81 = load double, double* %20
%82 = fdiv double %80, %81
%83 = load double*, double** %13
store double %82, double* %83
ret void
}

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