// File: philipperemy[P]digital-setting-circles/Calc.cpp
// Function: Calc::EqToAzEl(double, double, double, bool, double*, double*)
void Calc::EqToAzEl(double ra, double dec, double time, bool flipped, double *azptr, double *elptr)
{
  int I, J;

  double RA = ra;
  double DEC = dec;

  DEC=DEC/degPerRad;
  RA=(RA-degreesPerMinute*time)/degPerRad;
  XX[1][1]=MathLib::cos(DEC)*MathLib::cos(RA);
  XX[2][1]=MathLib::cos(DEC)*MathLib::sin(RA);
  XX[3][1]=MathLib::sin(DEC);

  YY[1][1]=0; YY[2][1]=0; YY[3][1]=0;
  for (I=1; I<=3; I++) {
    for (J=1; J<=3; J++) {
      YY[I][1] += (RR[I][J]*XX[J][1]);
    }
  }

  YY1toFH(flipped);

  TrueToApparentAzEl(flipped);

  F *= degPerRad;
  H *= degPerRad;

  // This code measures azimuth backwards!
  F = 360.0-F;

  if (azptr)
    *azptr = F;

  if (elptr)
    *elptr = H;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movsd %xmm1, -0x18(%rbp)
movsd %xmm2, -0x20(%rbp)
andb $0x1, %al
movb %al, -0x21(%rbp)
movq %rdx, -0x30(%rbp)
movq %rcx, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm0
movsd 0x3299c(%rip), %xmm1    # 0x38050
divsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x48(%rbp), %xmm1
movsd -0x20(%rbp), %xmm0
movsd 0x32991(%rip), %xmm2    # 0x38060
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x32971(%rip), %xmm1    # 0x38050
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x50(%rbp), %xmm0
callq 0x75e0
movsd %xmm0, -0x68(%rbp)
movsd -0x48(%rbp), %xmm0
callq 0x75e0
movq -0x58(%rbp), %rax
movaps %xmm0, %xmm1
movsd -0x68(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x1a8(%rax)
movsd -0x50(%rbp), %xmm0
callq 0x75e0
movsd %xmm0, -0x60(%rbp)
movsd -0x48(%rbp), %xmm0
callq 0x7600
movq -0x58(%rbp), %rax
movaps %xmm0, %xmm1
movsd -0x60(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x1c8(%rax)
movsd -0x50(%rbp), %xmm0
callq 0x7600
movq -0x58(%rbp), %rax
movsd %xmm0, 0x1e8(%rax)
xorps %xmm0, %xmm0
movsd %xmm0, 0x228(%rax)
xorps %xmm0, %xmm0
movsd %xmm0, 0x248(%rax)
xorps %xmm0, %xmm0
movsd %xmm0, 0x268(%rax)
movl $0x1, -0x3c(%rbp)
cmpl $0x3, -0x3c(%rbp)
jg 0x5819
movl $0x1, -0x40(%rbp)
cmpl $0x3, -0x40(%rbp)
jg 0x5809
movq -0x58(%rbp), %rax
movq %rax, %rcx
addq $0x100, %rcx            # imm = 0x100
movslq -0x3c(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movslq -0x40(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq %rax, %rcx
addq $0x180, %rcx            # imm = 0x180
movslq -0x40(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movsd 0x8(%rcx), %xmm2
addq $0x200, %rax            # imm = 0x200
movslq -0x3c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rax)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x5799
jmp 0x580b
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x5788
movq -0x58(%rbp), %rdi
movb -0x21(%rbp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0x3bc0
movq -0x58(%rbp), %rdi
movb -0x21(%rbp), %al
andb $0x1, %al
movzbl %al, %esi
callq 0x4130
movq -0x58(%rbp), %rax
movsd 0x32809(%rip), %xmm0    # 0x38050
mulsd 0x280(%rax), %xmm0
movsd %xmm0, 0x280(%rax)
movsd 0x327f1(%rip), %xmm0    # 0x38050
mulsd 0x288(%rax), %xmm0
movsd %xmm0, 0x288(%rax)
movsd 0x327f1(%rip), %xmm0    # 0x38068
subsd 0x280(%rax), %xmm0
movsd %xmm0, 0x280(%rax)
cmpq $0x0, -0x30(%rbp)
je 0x58a2
movq -0x58(%rbp), %rax
movsd 0x280(%rax), %xmm0
movq -0x30(%rbp), %rax
movsd %xmm0, (%rax)
cmpq $0x0, -0x38(%rbp)
je 0x58bd
movq -0x58(%rbp), %rax
movsd 0x288(%rax), %xmm0
movq -0x38(%rbp), %rax
movsd %xmm0, (%rax)
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)