// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heathmsc.cpp
// Function: plot_sat_trail(int, int, int, int, float, float, int, int)
void plot_sat_trail(int grid_x,int grid_y, int grid_r,  int prn, float az,float el,  int color, int dots)
{
int x1,y1;
int x2,y2;
int i;
int row;
u08 m;

   // Draw the trail of previous sat positions.  The trail is marked with colored
   // on the hour and black dots otherwise  as time markers.  

   if(map_trails == 0) return;  // trails disabled
   if((prn == SUN_PRN) && (no_sun_moon & 0x01)) return;
   if((prn == MOON_PRN) && (no_sun_moon & 0x02)) return;

   m = 0;
   row = 0;

   // the current location of the sat
   if(az < 0.0F) az += 360.0F;
   if(az >= 360.0F) az -= 360.0F;
   x1 = grid_x + (int) ((el * cos360(az) * grid_r)+0.50);
   y1 = grid_y + (int) ((el * sin360(az) * grid_r)+0.50);
   if(x1 < 0) return;
   if(y1 < 0) return;
   if(x1 >= SCREEN_WIDTH) return;
   if(y1 >= SCREEN_WIDTH) return;

   for(i=0; i<trail_count; i++) { // check the old locations of the sat
      el = (float) sat_trail[prn].el[i];
      az = (float) sat_trail[prn].az[i];
      if((az == 0.0F) && (el == 0.0F)) break;  // end of valid locations
      if((prn == MOON_PRN) || (prn == SUN_PRN)) {  // moon color depends upon elevation
         if(el < 0.0F) color = GREY;  // !!!! this does not work since saved el is always positive
         else color = MOON_COLOR;
//sprintf(debug_text2, "moon: el:%f  moon_el:%f  color:%d", el, moon_el, color);
      }
      if(el < 0.0F) el = 0.0F - el;

      el = (el - 90.0F) / 90.0F;
      az += 90.0F;
      if(az < 0.0F) az += 360.0F;
      if(az >= 360.0F) az -= 360.0F;

      x2 = grid_x + (int) ((el * cos360(az) * grid_r)+0.50);
      y2 = grid_y + (int) ((el * sin360(az) * grid_r)+0.50);
      if(x2 < 0) continue;
      if(y2 < 0) continue;
      if(x2 >= SCREEN_WIDTH) continue;
      if(y2 >= SCREEN_WIDTH) continue;

      if(dots) {  // mark the trail with time markers
         if((sat_trail[prn].mins[i] % TRAIL_MARKER) == 0) {    // it's time to mark the trail
            if(sat_trail[prn].mins[i] != 0) {  // it's not the hour... dot the dot
               draw_circle(x2,y2, 2, color, 0);  // hollow circle
            }
            else {
               draw_circle(x2,y2, 2, color, 1);  // filled circle
            }
         }
      }
      else {   // draw the trail line
         line(x1,y1, x2,y2, color); 
      }

      x1 = x2;
      y1 = y2;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r9d, -0x44(%rbp)
movl %esi, -0x3c(%rbp)
movl %edi, -0x40(%rbp)
leaq 0x126df8(%rip), %rax    # 0x21b419
cmpb $0x0, (%rax)
je 0xf499c
movl %r8d, %r12d
movl %ecx, %r14d
movl %edx, %ebx
cmpl $0x3e9, %ecx            # imm = 0x3E9
je 0xf465c
cmpl $0x3e8, %r14d           # imm = 0x3E8
jne 0xf466c
leaq 0x7c61e(%rip), %rax     # 0x170c68
testb $0x1, (%rax)
jne 0xf499c
cmpl $0x3e9, %r14d           # imm = 0x3E9
jne 0xf466c
leaq 0x7c605(%rip), %rax     # 0x170c68
testb $0x2, (%rax)
jne 0xf499c
movss 0x2a308(%rip), %xmm4    # 0x11e97c
movaps %xmm0, %xmm5
addss %xmm4, %xmm5
xorps %xmm2, %xmm2
movss %xmm1, -0x2c(%rbp)
movaps %xmm0, %xmm3
cmpltss %xmm2, %xmm3
andps %xmm3, %xmm5
andnps %xmm0, %xmm3
orps %xmm5, %xmm3
movaps %xmm4, %xmm0
cmpnless %xmm3, %xmm0
movaps %xmm3, %xmm1
addss 0x38055(%rip), %xmm1    # 0x12c6fc
movaps %xmm0, %xmm2
andps %xmm3, %xmm2
andnps %xmm1, %xmm0
orps %xmm2, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd 0x299cc(%rip), %xmm1    # 0x11e090
callq 0x94d0
divsd 0x14a87(%rip), %xmm0    # 0x109158
callq 0x9710
cvtsd2ss %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtsi2ss %ebx, %xmm1
movss %xmm1, -0x30(%rbp)
mulss -0x2c(%rbp), %xmm0
mulss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
addsd 0x1496d(%rip), %xmm0    # 0x109068
cvttsd2si %xmm0, %r13d
movsd -0x38(%rbp), %xmm0
movsd 0x29983(%rip), %xmm1    # 0x11e090
callq 0x94d0
divsd 0x14a3e(%rip), %xmm0    # 0x109158
callq 0x9080
movss -0x2c(%rbp), %xmm3
movsd 0x1493c(%rip), %xmm2    # 0x109068
movss -0x30(%rbp), %xmm1
addl -0x40(%rbp), %r13d
js 0xf499c
cvtsd2ss %xmm0, %xmm0
mulss %xmm3, %xmm0
mulss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
addsd %xmm2, %xmm0
cvttsd2si %xmm0, %r15d
addl -0x3c(%rbp), %r15d
js 0xf499c
leaq 0x12409b(%rip), %rax    # 0x218800
movl (%rax), %eax
cmpl %eax, %r13d
jge 0xf499c
cmpl %eax, %r15d
jge 0xf499c
cmpl $0x0, 0x2871c0(%rip)    # 0x37b940
jle 0xf499c
movslq %r14d, %rax
imulq $0x36c, %rax, %rax      # imm = 0x36C
leaq 0x2871b9(%rip), %rcx    # 0x37b950
addq %rax, %rcx
movq %rcx, -0x50(%rbp)
andl $-0x2, %r14d
movl %r14d, -0x48(%rbp)
xorl %r14d, %r14d
xorps %xmm4, %xmm4
movq -0x50(%rbp), %rax
movss (%rax,%r14,4), %xmm0
movss 0x124(%rax,%r14,4), %xmm2
ucomiss %xmm4, %xmm0
jne 0xf47d2
jp 0xf47d2
ucomiss %xmm4, %xmm2
jne 0xf47d2
jnp 0xf499c
ucomiss %xmm2, %xmm4
movl $0xe, %eax
movl $0x8, %ecx
cmoval %ecx, %eax
jbe 0xf47ee
xorps %xmm1, %xmm1
subss %xmm2, %xmm1
movaps %xmm1, %xmm2
cmpl $0x3e8, -0x48(%rbp)     # imm = 0x3E8
cmovel %eax, %r12d
movl %r12d, -0x38(%rbp)
addss 0x2a173(%rip), %xmm2    # 0x11e978
movss 0x187e3(%rip), %xmm1    # 0x10cff0
divss %xmm1, %xmm2
movss %xmm2, -0x2c(%rbp)
addss %xmm1, %xmm0
movaps %xmm0, %xmm1
movss 0x2a157(%rip), %xmm3    # 0x11e97c
addss %xmm3, %xmm1
movaps %xmm0, %xmm2
cmpltss %xmm4, %xmm2
andps %xmm2, %xmm1
andnps %xmm0, %xmm2
orps %xmm1, %xmm2
movaps %xmm3, %xmm0
cmpnless %xmm2, %xmm0
movaps %xmm0, %xmm1
andps %xmm2, %xmm1
addss 0x37eac(%rip), %xmm2    # 0x12c6fc
andnps %xmm2, %xmm0
orps %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
movsd 0x29829(%rip), %xmm1    # 0x11e090
callq 0x94d0
movsd 0x148e4(%rip), %xmm1    # 0x109158
divsd %xmm1, %xmm0
callq 0x9710
cvtsd2ss %xmm0, %xmm0
mulss -0x2c(%rbp), %xmm0
mulss -0x30(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x147d1(%rip), %xmm1    # 0x109068
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %ebx
movsd -0x58(%rbp), %xmm0
movsd 0x297e4(%rip), %xmm1    # 0x11e090
callq 0x94d0
divsd 0x1489f(%rip), %xmm0    # 0x109158
callq 0x9080
addl -0x40(%rbp), %ebx
js 0xf494f
cvtsd2ss %xmm0, %xmm0
movss -0x2c(%rbp), %xmm1
mulss %xmm0, %xmm1
movss -0x30(%rbp), %xmm2
mulss %xmm2, %xmm1
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
addsd 0x1477c(%rip), %xmm0    # 0x109068
cvttsd2si %xmm0, %r12d
addl -0x3c(%rbp), %r12d
xorps %xmm4, %xmm4
js 0xf4947
leaq 0x123eff(%rip), %rax    # 0x218800
movl (%rax), %eax
cmpl %eax, %ebx
jge 0xf4947
cmpl %eax, %r12d
jge 0xf4947
cmpl $0x0, -0x44(%rbp)
je 0xf4957
movq -0x50(%rbp), %rax
movl 0x248(%rax,%r14,4), %eax
imull $0xeeeeeeef, %eax, %ecx # imm = 0xEEEEEEEF
movl $0x8888888, %edx        # imm = 0x8888888
addl %edx, %ecx
rorl %ecx
cmpl %edx, %ecx
ja 0xf497f
movl %ebx, %edi
movl %r12d, %esi
movl $0x2, %edx
testl %eax, %eax
je 0xf496e
movl -0x38(%rbp), %ecx
xorl %r8d, %r8d
jmp 0xf4977
movl %r15d, %r12d
movl %r13d, %ebx
jmp 0xf497f
movl %r15d, %r12d
movl %r13d, %ebx
jmp 0xf497c
movzbl -0x38(%rbp), %r8d
movl %r13d, %edi
movl %r15d, %esi
movl %ebx, %edx
movl %r12d, %ecx
callq 0xe3c3
jmp 0xf497c
movl -0x38(%rbp), %ecx
movl $0x1, %r8d
callq 0xf1f0
xorps %xmm4, %xmm4
incq %r14
movslq 0x286fb7(%rip), %rax    # 0x37b940
movl %ebx, %r13d
movl %r12d, %r15d
cmpq %rax, %r14
movl -0x38(%rbp), %r12d
jl 0xf47ac
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq