// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathmsc.cpp
// Function: draw_azel_grid(int, int, int, int)
void draw_azel_grid(int signals, int grid_x,int grid_y, int grid_r)
{
int az, el;
int x0, y0;
float x1, y1;
float x2, y2;
float elx;
float len;
float r;
int max_el, el_grid;

   x0 = grid_x;
   y0 = grid_y;
   len = (float) grid_r;
   if(signals && (plot_signals == 3)) {
      x0 -= grid_r;
      y0 += grid_r;
      len *= 2.0F;
   }

   x1 = cos360(0) * len;
   y1 = sin360(0) * len;

   for(az=AZ_INCR; az<=360; az+=AZ_INCR) {
      x2 = cos360(az) * len;
      y2 = sin360(az) * len;

      if(signals && (plot_signals == 3) && ((az-AZ_INCR) > 90) && ((az-AZ_INCR) < 360)) {
         goto skip_it;
      }

      if(1 || (plot_signals == 0) || (signals && ((plot_signals >= 4)))) {
         r = 1.03F;  // extend radials out a smidge
         max_el = 90;
         el_grid = 30;
      }
      else {
         r = 1.0F;
         max_el = 100;
         el_grid = 25;
      }

      if(((az-AZ_INCR)%AZ_GRID) == 0) {  // draw azimuth vectors
         line(x0+0,y0-0, 
              x0+(int)(x1*r),y0-(int)(y1*r), azel_grid_color);
         if(signals && plot_signals) {
            if(plot_signals >= 4) tick_radial(grid_x,grid_y,grid_r, 90, (az-AZ_INCR)+270);
            else                  tick_radial(grid_x,grid_y,grid_r,100, (az-AZ_INCR)+270);
         }
      }

      // tick mark the 0 degree elevation circle
      line(x0+(int)(x1*0.99F),y0-(int)(y1*0.99F),  
           x0+(int)(x1*1.03F),y0-(int)(y1*1.03F), azel_grid_color); 

      // dot the satelite elevation mask angle circle
      if(plot_el_mask == 0) ;
      else if((signals == 0) && (map_and_watch || (map_and_sigs == 0) || (zoom_screen == 'B'))) { 
         elx = ((90.0F-el_mask) / 90.0F);
         dot(x0+(int)(x1*elx),y0-(int)(y1*elx), azel_grid_color); 
      }
      else if((plot_signals == 0) || (signals && ((plot_signals > 3)))) { 
         elx = ((90.0F-el_mask) / 90.0F);
         dot(x0+(int)(x1*elx),y0-(int)(y1*elx), azel_grid_color); 
      }

      // draw the elevation circles
//      for(el=0; el<max_el; el+=el_grid) {  
      for(el=0; el<=max_el; el+=el_grid) {  
         if(max_el == 0) break;
         elx = r = ((((float) max_el) - (float) el) / (float) max_el);

         if(plot_el_mask && (el == (int) el_mask) && (el_mask != 0.0F)) {
            continue;  
         }
         if((zoom_screen == 'B') && (el == 0)) continue;
         if(zoom_screen == 'M') ;
         else if(zoom_screen == 'S') ;
         else if(zoom_screen == 'Y') ;
         else if(zoom_screen == 'U') ;
         else if(zoom_screen == 'V') ;
         else if(zoom_screen == 'I') ;
         else if(map_and_watch && (el == 0)) continue;
         if(signals && (plot_signals == 3) && ((az-AZ_INCR) == 90)) continue;

         line(x0+(int)(x1*elx),y0-(int)(y1*elx), 
              x0+(int)(x2*elx),y0-(int)(y2*elx), azel_grid_color);
      }

      skip_it:
      x1 = x2;  y1 = y2;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, -0x40(%rbp)
cvtsi2ss %ecx, %xmm1
movl %esi, -0x3c(%rbp)
movl %edi, %r13d
testl %edi, %edi
setne %al
leaq 0x12626b(%rip), %rdx    # 0x205415
cmpb $0x3, (%rdx)
sete %dl
xorl %esi, %esi
testb %dl, %al
movl %ecx, -0x64(%rbp)
cmovnel %ecx, %esi
je 0xdf1c0
addss %xmm1, %xmm1
movl -0x3c(%rbp), %r15d
subl %esi, %r15d
addl -0x40(%rbp), %esi
movl %esi, -0x38(%rbp)
xorps %xmm0, %xmm0
movaps %xmm1, %xmm2
mulss %xmm0, %xmm2
movss %xmm2, -0x34(%rbp)
pushq $0x5
popq %rbx
movsd 0x13f59(%rip), %xmm0    # 0xf3140
leaq 0x126228(%rip), %r12    # 0x205416
movss %xmm1, -0x30(%rbp)
movss %xmm1, -0x4c(%rbp)
movl %r13d, -0x48(%rbp)
movl %r15d, -0x44(%rbp)
cmpl $0x168, %ebx            # imm = 0x168
ja 0xdf55c
movsd %xmm0, -0x70(%rbp)
movsd 0x28f97(%rip), %xmm1    # 0x1081b0
callq 0x94d0
movsd 0x13f3a(%rip), %xmm1    # 0xf3160
divsd %xmm1, %xmm0
callq 0x9710
cvtsd2ss %xmm0, %xmm0
mulss -0x4c(%rbp), %xmm0
movss %xmm0, -0x54(%rbp)
movsd -0x70(%rbp), %xmm0
movsd 0x28f66(%rip), %xmm1    # 0x1081b0
callq 0x94d0
divsd 0x13f09(%rip), %xmm0    # 0xf3160
callq 0x9080
movss -0x4c(%rbp), %xmm1
cvtsd2ss %xmm0, %xmm0
mulss %xmm1, %xmm0
movss %xmm0, -0x50(%rbp)
movq %rbx, -0x60(%rbp)
cmpl $0x60, %ebx
jb 0xdf2b5
testl %r13d, %r13d
je 0xdf2b5
leaq 0x126192(%rip), %rax    # 0x205415
cmpb $0x3, (%rax)
jne 0xdf2b5
movsd -0x70(%rbp), %xmm0
addsd 0x13eab(%rip), %xmm0    # 0xf3140
movq -0x60(%rbp), %rbx
addl $0x5, %ebx
movss -0x54(%rbp), %xmm2
movss %xmm2, -0x30(%rbp)
movss -0x50(%rbp), %xmm2
movss %xmm2, -0x34(%rbp)
jmp 0xdf200
movq -0x60(%rbp), %rax
leal -0x5(%rax), %r14d
movl %r14d, %eax
xorl %edx, %edx
movw $0x1e, %cx
divw %cx
movss -0x30(%rbp), %xmm0
movss 0x37426(%rip), %xmm1    # 0x1166fc
mulss %xmm1, %xmm0
cvttss2si %xmm0, %ebx
addl %r15d, %ebx
movss -0x34(%rbp), %xmm0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %r15d, %ecx
movl -0x38(%rbp), %r15d
movl %r15d, %r13d
subl %eax, %r13d
testw %dx, %dx
jne 0xdf362
cmpl $0x0, -0x48(%rbp)
setne -0x29(%rbp)
leaq 0x246099(%rip), %rax    # 0x3253a8
movzbl (%rax), %r8d
movl %ecx, %edi
movl %r15d, %esi
movl %ebx, %edx
movl %r13d, %ecx
callq 0xdedf
leaq 0x1260ec(%rip), %rax    # 0x205415
movb (%rax), %al
testb %al, %al
setne %cl
andb -0x29(%rbp), %cl
cmpb $0x1, %cl
movl -0x44(%rbp), %ecx
jne 0xdf362
movq -0x60(%rbp), %rcx
leal 0x109(%rcx), %r8d
cmpb $0x4, %al
pushq $0x64
popq %rcx
pushq $0x5a
popq %rax
cmovael %eax, %ecx
movl -0x3c(%rbp), %edi
movl -0x40(%rbp), %esi
movl -0x64(%rbp), %edx
callq 0xdefeb
movl -0x44(%rbp), %ecx
movss -0x30(%rbp), %xmm0
movss 0x37391(%rip), %xmm1    # 0x116700
mulss %xmm1, %xmm0
cvttss2si %xmm0, %edi
movss -0x34(%rbp), %xmm0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
addl %ecx, %edi
subl %eax, %r15d
leaq 0x246018(%rip), %rax    # 0x3253a8
movzbl (%rax), %r8d
movl %r15d, %esi
movl %ebx, %edx
movl %ecx, %r15d
movl %r13d, %ecx
callq 0xdedf
cmpb $0x0, (%r12)
movl -0x48(%rbp), %r13d
je 0xdf440
testl %r13d, %r13d
jne 0xdf3dc
leaq 0x126051(%rip), %rax    # 0x205410
cmpb $0x0, (%rax)
jne 0xdf3f9
leaq 0x126046(%rip), %rax    # 0x205411
cmpb $0x0, (%rax)
je 0xdf3f9
leaq 0x2173d1(%rip), %rax    # 0x2f67a8
cmpb $0x42, (%rax)
je 0xdf3f9
testl %r13d, %r13d
setne %al
leaq 0x12602c(%rip), %rcx    # 0x205415
movb (%rcx), %dl
cmpb $0x4, %dl
setae %cl
testb %dl, %dl
je 0xdf3f9
andb %cl, %al
je 0xdf440
movss 0x17d03(%rip), %xmm1    # 0xf7104
movaps %xmm1, %xmm0
leaq 0x217ca9(%rip), %rax    # 0x2f70b4
subss (%rax), %xmm0
divss %xmm1, %xmm0
movss -0x30(%rbp), %xmm1
mulss %xmm0, %xmm1
cvttss2si %xmm1, %edi
mulss -0x34(%rbp), %xmm0
cvttss2si %xmm0, %eax
addl %r15d, %edi
movl -0x38(%rbp), %esi
subl %eax, %esi
leaq 0x245f70(%rip), %rax    # 0x3253a8
movzbl (%rax), %edx
callq 0xe1a7
xorl %ebx, %ebx
xorps %xmm2, %xmm2
leaq 0x21735c(%rip), %rsi    # 0x2f67a8
leaq 0x217c61(%rip), %rdi    # 0x2f70b4
cmpl $0x5a, %ebx
ja 0xdf288
cmpb $0x0, (%r12)
je 0xdf483
movss (%rdi), %xmm0
cvttss2si %xmm0, %eax
cmpl %eax, %ebx
sete %al
ucomiss %xmm0, %xmm2
setp %cl
setne %dl
orb %cl, %dl
testb %al, %dl
jne 0xdf53b
movzbl (%rsi), %eax
movl %eax, %ecx
xorl $0x42, %ecx
orl %ebx, %ecx
je 0xdf53b
addl $-0x49, %eax
cmpl $0x10, %eax
ja 0xdf543
movl $0x13411, %ecx          # imm = 0x13411
btl %eax, %ecx
jae 0xdf543
cmpl $0x5a, %r14d
jne 0xdf4c4
testl %r13d, %r13d
je 0xdf4c4
leaq 0x125f56(%rip), %rax    # 0x205415
cmpb $0x3, (%rax)
je 0xdf53b
cvtsi2ss %ebx, %xmm0
movss 0x17c34(%rip), %xmm2    # 0xf7104
movaps %xmm2, %xmm1
subss %xmm0, %xmm1
divss %xmm2, %xmm1
movss -0x30(%rbp), %xmm0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %edi
addl %r15d, %edi
movss -0x34(%rbp), %xmm0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl -0x38(%rbp), %ecx
movl %ecx, %esi
movss -0x54(%rbp), %xmm0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %edx
subl %eax, %esi
mulss -0x50(%rbp), %xmm1
cvttss2si %xmm1, %eax
addl %r15d, %edx
subl %eax, %ecx
leaq 0x245e87(%rip), %rax    # 0x3253a8
movzbl (%rax), %r8d
callq 0xdedf
leaq 0x217b83(%rip), %rdi    # 0x2f70b4
leaq 0x217270(%rip), %rsi    # 0x2f67a8
xorps %xmm2, %xmm2
addl $0x1e, %ebx
jmp 0xdf453
testl %ebx, %ebx
jne 0xdf4ad
leaq 0x125ebe(%rip), %rax    # 0x205410
cmpb $0x0, (%rax)
jne 0xdf53b
jmp 0xdf4ad
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq