// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathmsc.cpp
// Function: draw_azel_sats(int, int, int)
void draw_azel_sats(int grid_x,int grid_y, int grid_r)
{
float az,el;
int x, y;
int marker_size;
int row;
int i, j;
int color;
u08 m;

   // Draw the sats on the sat position map.  Sats that are being used are
   // drawn colored in.  Sats that are not being used are drawn as hollow
   // circles.

   m = 0;
   j = 0;
   row = 0;

   map_x = grid_x;
   map_y = grid_y;
   map_r = grid_r;

   if(AZEL_Y >= PLOT_ROW) shared_item = SHARE_MAP;
   if(map_and_watch && (shared_item == SHARE_MAP)) {
      if(0 && plot_lla && lla_showing) ;
      else shared_item = (SHARE_MAP | SHARE_WATCH);
   }

   log_sun_posn();
   if(1 || (shared_plot == 0) || (aclock_y < (SCREEN_HEIGHT/3)) || (zoom_screen == 'M') || (zoom_screen == 'X') || (zoom_screen == 'Y')) {
      #ifdef TRUE_MOON
         calc_moon_posn(0);
      #endif
      if((lat != 0.0) || (lon != 0.0)) {
         draw_moon(jd_utc, grid_x,grid_y, grid_r, 0);
      }
   }
   
   drawn_sats = 0;
   for(i=1; i<=SUN_MOON_PRN; i++) { // !!!!! mooooo  now draw the sat vectors
      if(sat[i].level_msg == 0x00) continue;
      if((i == SUN_PRN) && (no_sun_moon & 0x01)) continue;
      if((i == MOON_PRN) && (no_sun_moon & 0x02)) continue;

if(tracked_only & (sat[i].tracking <= 0) && (i != SUN_PRN) && (i != MOON_PRN)) continue;
      if(i == SUN_PRN) ;
      else if(i == MOON_PRN);
      else if(sat[i].sig_level <= 0.0) continue;  // zzzzzzzzzzzzzzz

      if((i == SUN_PRN) && (sun_el == 0.0F) && (sun_az == 0.0F)) continue;
      if((i == MOON_PRN) && (moon_el == 0.0F) && (moon_az == 0.0F)) continue;

      // filter out potentially bogus data
      el = sat[i].elevation;
      az = sat[i].azimuth;

      if((az == 0.0F) && (el == 0.0F)) continue;
      if((az < 0.0F) || (az >= 360.0F)) continue;
      if((el < -90.0F) || (el > 90.0F)) continue;

      if((i == SUN_PRN) || (i == MOON_PRN)) {
         if(el < 0.0F) el = 0.0F - el;
      }
      if((el < 0.0F) || (el > 90.0F)) continue;

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

      x = grid_x + (int) (el * cos360(az) * grid_r);
      y = grid_y + (int) (el * sin360(az) * grid_r);
      if(x < 0) continue;
      if(y < 0) continue;
      if(x >= SCREEN_WIDTH) continue;
      if(y >= SCREEN_HEIGHT) continue;

      // the size of the sat marker is based upon the signal strength
      marker_size = set_marker_size(i);
  
      
      color = j;
      if(i == SUN_PRN) {
         color = YELLOW_SAT_COLOR;  // !!!! kludge: force YELLOW for the sun
      }
      else if(i == MOON_PRN) {
         if(moon_el < 0) color = GREY_SAT_COLOR;
         else            color = YELLOW_SAT_COLOR;  // !!!! kludge: force YELLOW for the moon
      }


      #ifdef SAT_TRAILS
         // we draw the line first,  then the time marker dots
         // since the dots can be hollow and erase part of the line
         plot_sat_trail(grid_x,grid_y, grid_r,  i, az,el, sat_colors[color], 0);   // plot the satellite's path line 
         if(dot_trails) {
            plot_sat_trail(grid_x,grid_y, grid_r,  i, az,el, sat_colors[color], 1);   // dot the satellite's path with time markers
         }
      #endif

      if(i == MOON_PRN) ;  // we draw the moon separately
      else if((i == SUN_PRN) && (fancy_sats >= RECT_SATS)) {
         if(sat[i].tracking > 0) {  //  mark sats that are actively tracked with a filled box
            draw_circle(x,y, marker_size, sat_colors[color], 1);     
         }
         else {
            draw_circle(x,y, marker_size, sat_colors[color], 0);     
         }
         sat[i].plot_x = x;
         sat[i].plot_y = y;
         sat[i].plot_r = marker_size;
         sat[i].plot_color = sat_colors[color];
      }
      else if(sat[i].tracking > 0) {  //  mark sats that are actively tracked with a filled box
         draw_sat(i, x,y, marker_size, sat_colors[color], 1);     
         ++drawn_sats;
         sat[i].plot_x = x;
         sat[i].plot_y = y;
         sat[i].plot_r = marker_size;
         sat[i].plot_color = sat_colors[color];

         if((fancy_sats <= RECT_SATS) && (map_and_sigs || (zoom_screen == 'X') || (zoom_screen == 'Y'))) {  // outline the sats in black
            draw_sat(i, x,y, marker_size+1, BLACK, 0);
            draw_sat(i, x,y, marker_size+2, BLACK, 0);
         }
      }
      else {  // mark inactive sats with a hollow box
         draw_sat(i, x,y, marker_size, sat_colors[color], 0);          
         ++drawn_sats;
         sat[i].plot_x = x;
         sat[i].plot_y = y;
         sat[i].plot_r = marker_size;
         sat[i].plot_color = sat_colors[color];

         if((fancy_sats <= RECT_SATS) && (map_and_sigs || (zoom_screen == 'X') || (zoom_screen == 'Y'))) {  // outline the sats in black
            draw_sat(i, x,y, marker_size+1, BLACK, 0);
            draw_sat(i, x,y, marker_size+2, BLACK, 0);
         }
         if((fancy_sats <= RECT_SATS) && (marker_size > 1+1)) {
            draw_sat(i, x,y, marker_size-1-1, BLACK, 1);
         }
      }

      if(i == SUN_PRN) {
         draw_sun_rays(x,y, marker_size, 0);
      }
      else if(i == MOON_PRN) {
      }

      ++j;
      if(j > MAX_SAT_COLOR) j = 0;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %edx, %ebx
movl %esi, %r14d
movl %edi, %r15d
leaq 0x245045(%rip), %rax    # 0x3253ac
movl %edi, (%rax)
leaq 0x245040(%rip), %rax    # 0x3253b0
movl %esi, (%rax)
leaq 0x24503b(%rip), %rax    # 0x3253b4
movl %edx, (%rax)
leaq 0x245022(%rip), %rax    # 0x3253a4
movl (%rax), %eax
leaq 0x1224f1(%rip), %rcx    # 0x20287c
cmpl (%rcx), %eax
jge 0xe039e
leaq 0x245056(%rip), %rax    # 0x3253ec
cmpl $0x2, (%rax)
sete %al
jmp 0xe03ad
leaq 0x245047(%rip), %rax    # 0x3253ec
movl $0x2, (%rax)
movb $0x1, %al
leaq 0x12505c(%rip), %rcx    # 0x205410
cmpb $0x0, (%rcx)
je 0xe03ca
testb %al, %al
je 0xe03ca
leaq 0x245028(%rip), %rax    # 0x3253ec
movl $0x3, (%rax)
callq 0xdfb15
xorl %edi, %edi
callq 0xdc612
leaq 0x216bf3(%rip), %rax    # 0x2f6fd0
movsd (%rax), %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0xe0400
jp 0xe0400
leaq 0x216be4(%rip), %rax    # 0x2f6fd8
movsd (%rax), %xmm1
ucomisd %xmm0, %xmm1
jne 0xe0400
jnp 0xe041a
leaq 0x217129(%rip), %rax    # 0x2f7530
movsd (%rax), %xmm0
movl %r15d, %edi
movl %r14d, %esi
movl %ebx, %edx
xorl %ecx, %ecx
callq 0xddb21
movl %r15d, -0x54(%rbp)
movl %r14d, -0x50(%rbp)
leaq 0x148adf(%rip), %rax    # 0x228f08
andl $0x0, (%rax)
movl $0x57c, %r12d           # imm = 0x57C
addq 0x59b0f(%rip), %r12     # 0x139f48
movl %ebx, -0x58(%rbp)
cvtsi2ss %ebx, %xmm3
leaq 0x7a821(%rip), %r10     # 0x15ac68
leaq 0x148ac6(%rip), %rsi    # 0x228f14
leaq 0x217363(%rip), %rdi    # 0x2f77b8
leaq 0x217374(%rip), %r8     # 0x2f77d0
xorpd %xmm4, %xmm4
leaq 0x217389(%rip), %r9     # 0x2f77f0
leaq 0x21737a(%rip), %r14    # 0x2f77e8
xorps %xmm5, %xmm5
movaps 0x36408(%rip), %xmm6    # 0x116880
movss 0x28524(%rip), %xmm7    # 0x1089a4
movss 0x16c7b(%rip), %xmm8    # 0xf7104
movss 0x2850e(%rip), %xmm9    # 0x1089a0
movss 0x36269(%rip), %xmm10   # 0x116704
movsd 0x27d0d(%rip), %xmm1    # 0x1081b0
xorl %ebx, %ebx
xorl %r11d, %r11d
cmpq $0x3e9, %rbx            # imm = 0x3E9
je 0xe0b14
movq %rbx, %r13
incq %rbx
cmpl $0x0, -0x218(%r12)
je 0xe058e
cmpq $0x3e7, %r13            # imm = 0x3E7
jne 0xe04de
testb $0x1, (%r10)
je 0xe04f5
jmp 0xe058e
cmpq $0x3e8, %r13            # imm = 0x3E8
jne 0xe04f5
movb $0x1, %r15b
testb $0x2, (%r10)
je 0xe04f8
jmp 0xe058e
xorl %r15d, %r15d
cmpq $0x3e7, %rbx            # imm = 0x3E7
ja 0xe0510
cmpl $0x0, -0x1c(%r12)
jg 0xe0510
movl (%rsi), %eax
andl $0x1, %eax
jne 0xe058e
movl %ebx, %eax
andl $0x3fe, %eax            # imm = 0x3FE
cmpl $0x3e8, %eax            # imm = 0x3E8
je 0xe0529
ucomiss -0x214(%r12), %xmm5
jae 0xe058e
cmpq $0x3e7, %r13            # imm = 0x3E7
jne 0xe054b
movsd (%rdi), %xmm0
ucomisd %xmm4, %xmm0
jne 0xe054b
jp 0xe054b
movsd (%r8), %xmm0
ucomisd %xmm4, %xmm0
jne 0xe054b
jnp 0xe058e
movsd (%r9), %xmm0
ucomisd %xmm4, %xmm0
setnp %cl
sete %dl
andb %cl, %dl
andb %r15b, %dl
cmpb $0x1, %dl
jne 0xe0571
movsd (%r14), %xmm0
ucomisd %xmm4, %xmm0
jne 0xe0571
jnp 0xe058e
movss -0x2c(%r12), %xmm0
movss -0x28(%r12), %xmm12
ucomiss %xmm5, %xmm0
jne 0xe059a
jp 0xe059a
ucomiss %xmm5, %xmm12
jne 0xe059a
jp 0xe059a
addq $0x348, %r12            # imm = 0x348
jmp 0xe04a8
ucomiss %xmm0, %xmm5
ja 0xe058e
ucomiss %xmm7, %xmm0
jae 0xe058e
movaps %xmm12, %xmm2
andps %xmm6, %xmm2
ucomiss %xmm8, %xmm2
ja 0xe058e
cmpl $0x3e8, %eax            # imm = 0x3E8
jne 0xe05da
xorps %xmm11, %xmm11
subss %xmm12, %xmm11
movaps %xmm12, %xmm2
cmpltss %xmm5, %xmm2
andps %xmm2, %xmm11
andnps %xmm12, %xmm2
orps %xmm11, %xmm2
movaps %xmm2, %xmm12
ucomiss %xmm12, %xmm5
ja 0xe058e
ucomiss %xmm8, %xmm12
ja 0xe058e
movq %r11, -0x40(%rbp)
addss %xmm9, %xmm12
divss %xmm8, %xmm12
movaps %xmm12, -0x70(%rbp)
addss %xmm8, %xmm0
movaps %xmm0, %xmm4
addss %xmm7, %xmm4
movaps %xmm0, %xmm2
cmpltss %xmm5, %xmm2
andps %xmm2, %xmm4
andnps %xmm0, %xmm2
orps %xmm4, %xmm2
cmpnless %xmm2, %xmm7
movaps %xmm7, %xmm0
andps %xmm2, %xmm0
addss %xmm10, %xmm2
andnps %xmm2, %xmm7
orps %xmm0, %xmm7
movaps %xmm7, -0x80(%rbp)
cvtss2sd %xmm7, %xmm0
movsd %xmm0, -0x48(%rbp)
movss %xmm3, -0x4c(%rbp)
callq 0x94d0
divsd 0x12b15(%rip), %xmm0    # 0xf3160
callq 0x9710
cvtsd2ss %xmm0, %xmm0
mulss -0x70(%rbp), %xmm0
mulss -0x4c(%rbp), %xmm0
cvttss2si %xmm0, %r14d
movsd -0x48(%rbp), %xmm0
movsd 0x27b40(%rip), %xmm1    # 0x1081b0
callq 0x94d0
divsd 0x12ae3(%rip), %xmm0    # 0xf3160
callq 0x9080
addl -0x54(%rbp), %r14d
movl %r14d, -0x48(%rbp)
js 0xe0997
cvtsd2ss %xmm0, %xmm0
movaps -0x70(%rbp), %xmm2
mulss %xmm2, %xmm0
movss -0x4c(%rbp), %xmm3
mulss %xmm3, %xmm0
cvttss2si %xmm0, %eax
addl -0x50(%rbp), %eax
movl %eax, -0x2c(%rbp)
leaq 0x14885e(%rip), %rsi    # 0x228f14
leaq 0x2170fb(%rip), %rdi    # 0x2f77b8
leaq 0x21710c(%rip), %r8     # 0x2f77d0
xorps %xmm4, %xmm4
leaq 0x217122(%rip), %r9     # 0x2f77f0
leaq 0x217113(%rip), %r14    # 0x2f77e8
xorps %xmm5, %xmm5
movaps 0x361a1(%rip), %xmm6    # 0x116880
movss 0x282bd(%rip), %xmm7    # 0x1089a4
movss 0x16a14(%rip), %xmm8    # 0xf7104
movss 0x282a7(%rip), %xmm9    # 0x1089a0
movss 0x36002(%rip), %xmm10   # 0x116704
movsd 0x27aa6(%rip), %xmm1    # 0x1081b0
leaq 0x1220ef(%rip), %rax    # 0x202800
leaq 0x1220ec(%rip), %rcx    # 0x202804
js 0xe09f7
movl -0x48(%rbp), %r10d
cmpl (%rax), %r10d
jge 0xe09f7
movl -0x2c(%rbp), %eax
cmpl (%rcx), %eax
jge 0xe09f7
movl %ebx, %edi
movq %r9, %r14
callq 0xde14c
movq %rax, -0x38(%rbp)
cmpq $0x3e7, %r13            # imm = 0x3E7
movq -0x40(%rbp), %rax
pushq $0xe
popq %rcx
cmovel %ecx, %eax
xorl %ecx, %ecx
xorps %xmm0, %xmm0
ucomisd (%r14), %xmm0
setbe %cl
leal (%rcx,%rcx,2), %ecx
addl $0xb, %ecx
testb %r15b, %r15b
cmovel %eax, %ecx
movslq %ecx, %r14
leaq 0x73f08(%rip), %rax     # 0x154680
movl (%rax,%r14,4), %r8d
movl -0x54(%rbp), %edi
movl -0x50(%rbp), %esi
movl -0x58(%rbp), %edx
movl %ebx, %ecx
movaps -0x80(%rbp), %xmm0
movaps -0x70(%rbp), %xmm1
xorl %r9d, %r9d
callq 0xdf786
leaq 0x124c7c(%rip), %rax    # 0x20541a
cmpb $0x0, (%rax)
je 0xe07ca
leaq 0x73ed6(%rip), %rax     # 0x154680
movl (%rax,%r14,4), %r8d
movl -0x54(%rbp), %edi
movl -0x50(%rbp), %esi
movl -0x58(%rbp), %edx
movl %ebx, %ecx
movaps -0x80(%rbp), %xmm0
movaps -0x70(%rbp), %xmm1
pushq $0x1
popq %r9
callq 0xdf786
testb %r15b, %r15b
movl $0x0, %esi
leaq 0x73ea7(%rip), %rax     # 0x154680
leaq 0x124c4c(%rip), %rdx    # 0x20542c
movq -0x40(%rbp), %rdi
je 0xe07f4
cmpq $0x3e7, %r13            # imm = 0x3E7
je 0xe0860
jmp 0xe0877
movl -0x1c(%r12), %ecx
movl (%rax,%r14,4), %eax
cmpq $0x3e7, %r13            # imm = 0x3E7
jne 0xe08e8
cmpl $0x0, (%rdx)
jle 0xe08e8
movq %r14, %rsi
xorl %r8d, %r8d
testl %ecx, %ecx
setg %r8b
movl -0x48(%rbp), %r15d
movl %r15d, %edi
movq -0x38(%rbp), %r13
movl -0x2c(%rbp), %r14d
movq %rsi, -0x70(%rbp)
movl %r14d, %esi
movl %r13d, %edx
movl %eax, %ecx
callq 0xec2f
movl %r15d, -0xc(%r12)
movl %r14d, -0x8(%r12)
movl %r13d, -0x4(%r12)
leaq 0x73e2b(%rip), %rax     # 0x154680
movq -0x70(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, (%r12)
movl -0x48(%rbp), %edi
movl -0x2c(%rbp), %esi
movq -0x38(%rbp), %rdx
xorl %ecx, %ecx
callq 0xdde34
movq -0x40(%rbp), %rdi
xorl %esi, %esi
cmpl $0xe, %edi
leal 0x1(%rdi), %eax
cmovgel %esi, %eax
movl %eax, %r11d
movss -0x4c(%rbp), %xmm3
leaq 0x148685(%rip), %rsi    # 0x228f14
leaq 0x216f22(%rip), %rdi    # 0x2f77b8
leaq 0x216f33(%rip), %r8     # 0x2f77d0
xorps %xmm4, %xmm4
leaq 0x216f49(%rip), %r9     # 0x2f77f0
leaq 0x216f3a(%rip), %r14    # 0x2f77e8
xorps %xmm5, %xmm5
movaps 0x35fc8(%rip), %xmm6    # 0x116880
movss 0x280e4(%rip), %xmm7    # 0x1089a4
movss 0x1683b(%rip), %xmm8    # 0xf7104
movss 0x280ce(%rip), %xmm9    # 0x1089a0
movss 0x35e29(%rip), %xmm10   # 0x116704
movsd 0x278cd(%rip), %xmm1    # 0x1081b0
jmp 0xe09fb
movl %ebx, %edi
testl %ecx, %ecx
jle 0xe0a07
movl -0x48(%rbp), %r15d
movl %r15d, %esi
movl -0x2c(%rbp), %edx
movq -0x38(%rbp), %rcx
movl %eax, %r8d
pushq $0x1
popq %r9
callq 0xdfcbf
leaq 0x1485f5(%rip), %rax    # 0x228f08
incl (%rax)
movl %r15d, -0xc(%r12)
movl -0x2c(%rbp), %eax
movl %eax, -0x8(%r12)
movq -0x38(%rbp), %rax
movl %eax, -0x4(%r12)
leaq 0x73d4e(%rip), %rax     # 0x154680
movl (%rax,%r14,4), %eax
movl %eax, (%r12)
leaq 0x124aeb(%rip), %rax    # 0x20542c
cmpl $0x1, (%rax)
movl $0x0, %esi
leaq 0x124ac1(%rip), %rax    # 0x205411
leaq 0x215e51(%rip), %rcx    # 0x2f67a8
movq -0x40(%rbp), %rdi
jg 0xe07e6
cmpb $0x0, (%rax)
jne 0xe0972
movb (%rcx), %al
andb $-0x2, %al
cmpb $0x58, %al
jne 0xe07e6
movq -0x38(%rbp), %rax
leal 0x1(%rax), %ecx
xorl %r14d, %r14d
movl %ebx, %edi
movl -0x48(%rbp), %esi
movl -0x2c(%rbp), %edx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xdfcbf
pushq $0x2
popq %rdx
jmp 0xe0aee
movss -0x4c(%rbp), %xmm3
leaq 0x148571(%rip), %rsi    # 0x228f14
leaq 0x216e0e(%rip), %rdi    # 0x2f77b8
leaq 0x216e1f(%rip), %r8     # 0x2f77d0
xorps %xmm4, %xmm4
leaq 0x216e35(%rip), %r9     # 0x2f77f0
leaq 0x216e26(%rip), %r14    # 0x2f77e8
xorps %xmm5, %xmm5
movaps 0x35eb4(%rip), %xmm6    # 0x116880
movss 0x27fd0(%rip), %xmm7    # 0x1089a4
movss 0x16727(%rip), %xmm8    # 0xf7104
movss 0x27fba(%rip), %xmm9    # 0x1089a0
movss 0x35d15(%rip), %xmm10   # 0x116704
movsd 0x277b9(%rip), %xmm1    # 0x1081b0
movq -0x40(%rbp), %r11
leaq 0x7a266(%rip), %r10     # 0x15ac68
jmp 0xe058e
movl -0x48(%rbp), %r15d
movl %r15d, %esi
movl -0x2c(%rbp), %edx
movq -0x38(%rbp), %rcx
movl %eax, %r8d
xorl %r9d, %r9d
callq 0xdfcbf
leaq 0x1484e1(%rip), %rax    # 0x228f08
incl (%rax)
movl %r15d, -0xc(%r12)
movl -0x2c(%rbp), %eax
movl %eax, -0x8(%r12)
movq -0x38(%rbp), %rax
movl %eax, -0x4(%r12)
leaq 0x73c3a(%rip), %rax     # 0x154680
movl (%rax,%r14,4), %eax
movl %eax, (%r12)
leaq 0x1249d7(%rip), %rax    # 0x20542c
cmpl $0x1, (%rax)
movl $0x0, %esi
leaq 0x1249ad(%rip), %rax    # 0x205411
leaq 0x215d3d(%rip), %rcx    # 0x2f67a8
movq -0x40(%rbp), %rdi
jg 0xe07e6
cmpb $0x0, (%rax)
jne 0xe0a86
movb (%rcx), %cl
andb $-0x2, %cl
movb $0x1, %al
cmpb $0x58, %cl
jne 0xe0ad5
movq -0x38(%rbp), %rax
leal 0x1(%rax), %ecx
movl %ebx, %edi
movl -0x48(%rbp), %r15d
movl %r15d, %esi
movl -0x2c(%rbp), %r14d
movl %r14d, %edx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xdfcbf
movq -0x38(%rbp), %rax
leal 0x2(%rax), %ecx
movl %ebx, %edi
movl %r15d, %esi
movl %r14d, %edx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xdfcbf
movq -0x40(%rbp), %rdi
leaq 0x12495f(%rip), %rax    # 0x20542c
xorl %esi, %esi
cmpl $0x2, (%rax)
setl %al
cmpl $0x3, -0x38(%rbp)
jl 0xe07e6
pushq $-0x2
popq %rdx
pushq $0x1
popq %r14
testb %al, %al
je 0xe07e6
movq -0x38(%rbp), %rax
movl %eax, %ecx
addl %edx, %ecx
movl %ebx, %edi
movl -0x48(%rbp), %esi
movl -0x2c(%rbp), %edx
xorl %r8d, %r8d
movl %r14d, %r9d
callq 0xdfcbf
movq -0x40(%rbp), %rdi
xorl %esi, %esi
jmp 0xe07e6
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq