// File: philipperemy[P]digital-setting-circles/Calc.cpp
// Function: Calc::AzElToEq(double, double, double, double*, double*)
void Calc::AzElToEq(double az, double el, double time, double *raptr, double *decptr)
{
  int I, J;

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

  F *= radPerDeg;
  H *= radPerDeg;

  AzEltoYY0();
  XX[1][1]=YY[1][0]; XX[2][1]=YY[2][0]; XX[3][1]=YY[3][0];
  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] += (QQ[I][J]*XX[J][1]);
    }
  }
  YY1toFH(false);

  F *= degPerRad;
  H *= degPerRad;

  F += degreesPerMinute*time;

  F=F-MathLib::floor(F/360)*360;
  //F = fmod(F, 360.0);

  if (raptr)
    *raptr = F;

  if (decptr)
    *decptr = H;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movsd %xmm1, -0x18(%rbp)
movsd %xmm2, -0x20(%rbp)
movq %rsi, -0x28(%rbp)
movq %rdx, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x40(%rbp)
movsd 0x32765(%rip), %xmm0    # 0x38068
subsd -0x10(%rbp), %xmm0
movsd %xmm0, 0x280(%rdi)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, 0x288(%rdi)
movsd 0x32733(%rip), %xmm0    # 0x38058
mulsd 0x280(%rdi), %xmm0
movsd %xmm0, 0x280(%rdi)
movsd 0x3271b(%rip), %xmm0    # 0x38058
mulsd 0x288(%rdi), %xmm0
movsd %xmm0, 0x288(%rdi)
callq 0x3d90
movq -0x40(%rbp), %rax
movsd 0x220(%rax), %xmm0
movsd %xmm0, 0x1a8(%rax)
movsd 0x240(%rax), %xmm0
movsd %xmm0, 0x1c8(%rax)
movsd 0x260(%rax), %xmm0
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, -0x34(%rbp)
cmpl $0x3, -0x34(%rbp)
jg 0x5a38
movl $0x1, -0x38(%rbp)
cmpl $0x3, -0x38(%rbp)
jg 0x5a28
movq -0x40(%rbp), %rax
movslq -0x34(%rbp), %rdx
shlq $0x5, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movslq -0x38(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq %rax, %rcx
addq $0x180, %rcx            # imm = 0x180
movslq -0x38(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
movsd 0x8(%rcx), %xmm2
addq $0x200, %rax            # imm = 0x200
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rax)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x59bf
jmp 0x5a2a
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x59ae
movq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0x3bc0
movq -0x40(%rbp), %rax
movsd 0x32601(%rip), %xmm0    # 0x38050
mulsd 0x280(%rax), %xmm0
movsd %xmm0, 0x280(%rax)
movsd 0x325e9(%rip), %xmm0    # 0x38050
mulsd 0x288(%rax), %xmm0
movsd %xmm0, 0x288(%rax)
movsd -0x20(%rbp), %xmm0
movsd 0x280(%rax), %xmm1
movsd 0x325e4(%rip), %xmm2    # 0x38070
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x280(%rax)
movsd 0x280(%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd 0x280(%rax), %xmm0
movsd 0x325af(%rip), %xmm1    # 0x38068
divsd %xmm1, %xmm0
callq 0x7960
movsd -0x48(%rbp), %xmm1
movq -0x40(%rbp), %rax
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
movsd 0x3257e(%rip), %xmm2    # 0x38068
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x280(%rax)
cmpq $0x0, -0x28(%rbp)
je 0x5b15
movq -0x40(%rbp), %rax
movsd 0x280(%rax), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, (%rax)
cmpq $0x0, -0x30(%rbp)
je 0x5b30
movq -0x40(%rbp), %rax
movsd 0x288(%rax), %xmm0
movq -0x30(%rbp), %rax
movsd %xmm0, (%rax)
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)