// File: /workspace/github_cpp_makefile_star2_O3/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 $0x38, %rsp
movl %edx, -0x40(%rbp)
cvtsi2ss %ecx, %xmm1
movl %esi, -0x3c(%rbp)
movl %edi, -0x38(%rbp)
testl %edi, %edi
setne %al
leaq 0x126d4f(%rip), %rdx    # 0x21b415
cmpb $0x3, (%rdx)
sete %dl
xorl %ebx, %ebx
testb %dl, %al
movl %ecx, -0x50(%rbp)
cmovnel %ecx, %ebx
je 0xf46dc
addss %xmm1, %xmm1
movl -0x3c(%rbp), %r15d
subl %ebx, %r15d
addl -0x40(%rbp), %ebx
xorps %xmm0, %xmm0
movaps %xmm1, %xmm2
mulss %xmm0, %xmm2
movss %xmm2, -0x34(%rbp)
movl $0x5, %r12d
movsd 0x14a35(%rip), %xmm0    # 0x109138
movss %xmm1, -0x30(%rbp)
movss %xmm1, -0x44(%rbp)
movsd %xmm0, -0x58(%rbp)
movsd 0x29a1e(%rip), %xmm1    # 0x11e138
callq 0x94d0
movsd 0x14a39(%rip), %xmm1    # 0x109160
divsd %xmm1, %xmm0
callq 0x9710
cvtsd2ss %xmm0, %xmm0
mulss -0x44(%rbp), %xmm0
movss %xmm0, -0x4c(%rbp)
movsd -0x58(%rbp), %xmm0
movsd 0x299ed(%rip), %xmm1    # 0x11e138
callq 0x94d0
divsd 0x14a08(%rip), %xmm0    # 0x109160
callq 0x9080
movss -0x44(%rbp), %xmm1
cvtsd2ss %xmm0, %xmm0
mulss %xmm1, %xmm0
movss %xmm0, -0x48(%rbp)
cmpl $0x60, %r12d
jb 0xf47c2
cmpl $0x0, -0x38(%rbp)
je 0xf47c2
leaq 0x126c93(%rip), %rax    # 0x21b415
cmpb $0x3, (%rax)
jne 0xf47c2
movsd -0x58(%rbp), %xmm0
addsd 0x149a4(%rip), %xmm0    # 0x109138
leal 0x5(%r12), %eax
movss -0x48(%rbp), %xmm2
movss %xmm2, -0x34(%rbp)
movss -0x4c(%rbp), %xmm2
movss %xmm2, -0x30(%rbp)
cmpl $0x164, %r12d           # imm = 0x164
movl %eax, %r12d
jb 0xf470d
jmp 0xf4a87
imull $0xffffeeef, %r12d, %eax # imm = 0xFFFFEEEF
addl $0x5ddd, %eax           # imm = 0x5DDD
rorw %ax
movzwl %ax, %eax
movss -0x30(%rbp), %xmm0
movss 0x37ffb(%rip), %xmm1    # 0x12c7dc
mulss %xmm1, %xmm0
cvttss2si %xmm0, %r14d
movss -0x34(%rbp), %xmm0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %ecx
addl %r15d, %r14d
movl %ebx, %r13d
subl %ecx, %r13d
cmpl $0x888, %eax            # imm = 0x888
ja 0xf4865
cmpl $0x0, -0x38(%rbp)
setne -0x29(%rbp)
leaq 0x246b92(%rip), %rax    # 0x33b3a8
movzbl (%rax), %r8d
movl %r15d, %edi
movl %ebx, %esi
movl %r14d, %edx
movl %r13d, %ecx
callq 0xe38a
leaq 0x126be4(%rip), %rax    # 0x21b415
movb (%rax), %al
testb %al, %al
setne %cl
andb -0x29(%rbp), %cl
cmpb $0x1, %cl
jne 0xf4865
leal 0x109(%r12), %r8d
cmpb $0x4, %al
movl $0x64, %ecx
movl $0x5a, %eax
cmovael %eax, %ecx
movl -0x3c(%rbp), %edi
movl -0x40(%rbp), %esi
movl -0x50(%rbp), %edx
callq 0xf44f9
movss -0x30(%rbp), %xmm0
movss 0x37f6e(%rip), %xmm1    # 0x12c7e0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %edi
movss -0x34(%rbp), %xmm0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
addl %r15d, %edi
movl %ebx, %esi
subl %eax, %esi
leaq 0x246b13(%rip), %rax    # 0x33b3a8
movzbl (%rax), %r8d
movl %r14d, %edx
movl %r13d, %ecx
callq 0xe38a
leaq 0x126b6b(%rip), %rax    # 0x21b416
cmpb $0x0, (%rax)
je 0xf4942
cmpl $0x0, -0x38(%rbp)
jne 0xf48de
leaq 0x126b4f(%rip), %rax    # 0x21b410
cmpb $0x0, (%rax)
jne 0xf48fc
leaq 0x126b44(%rip), %rax    # 0x21b411
cmpb $0x0, (%rax)
je 0xf48fc
leaq 0x217ecf(%rip), %rax    # 0x30c7a8
cmpb $0x42, (%rax)
je 0xf48fc
cmpl $0x0, -0x38(%rbp)
setne %al
leaq 0x126b29(%rip), %rcx    # 0x21b415
movb (%rcx), %dl
cmpb $0x4, %dl
setae %cl
testb %dl, %dl
je 0xf48fc
andb %cl, %al
je 0xf4942
movss 0x18780(%rip), %xmm1    # 0x10d084
movaps %xmm1, %xmm0
leaq 0x2187a6(%rip), %rax    # 0x30d0b4
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 %ebx, %esi
subl %eax, %esi
leaq 0x246a6e(%rip), %rax    # 0x33b3a8
movzbl (%rax), %edx
callq 0xe657
leal -0x5(%r12), %r14d
leaq 0x126ac8(%rip), %rax    # 0x21b416
movb (%rax), %al
xorl %r13d, %r13d
xorps %xmm2, %xmm2
leaq 0x217e4b(%rip), %rdi    # 0x30c7a8
leaq 0x218750(%rip), %r8     # 0x30d0b4
testb %al, %al
je 0xf498d
movss (%r8), %xmm0
cvttss2si %xmm0, %ecx
cmpl %ecx, %r13d
sete %cl
ucomiss %xmm0, %xmm2
setp %dl
setne %sil
orb %dl, %sil
testb %cl, %sil
jne 0xf4a57
movzbl (%rdi), %ecx
movl %ecx, %edx
xorl $0x42, %edx
orl %r13d, %edx
je 0xf4a57
addl $-0x49, %ecx
cmpl $0x10, %ecx
ja 0xf4a6d
movl $0x13411, %edx          # imm = 0x13411
btl %ecx, %edx
jae 0xf4a6d
cmpl $0x5a, %r14d
jne 0xf49d4
cmpl $0x0, -0x38(%rbp)
je 0xf49d4
leaq 0x126a4a(%rip), %rcx    # 0x21b415
cmpb $0x3, (%rcx)
je 0xf4a57
xorps %xmm0, %xmm0
cvtsi2ss %r13d, %xmm0
movss 0x186a0(%rip), %xmm2    # 0x10d084
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 %ebx, %esi
movss -0x4c(%rbp), %xmm0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %edx
subl %eax, %esi
mulss -0x48(%rbp), %xmm1
cvttss2si %xmm1, %eax
addl %r15d, %edx
movl %ebx, %ecx
subl %eax, %ecx
leaq 0x246974(%rip), %rax    # 0x33b3a8
movzbl (%rax), %r8d
callq 0xe38a
leaq 0x218670(%rip), %r8     # 0x30d0b4
leaq 0x217d5d(%rip), %rdi    # 0x30c7a8
xorps %xmm2, %xmm2
leaq 0x1269c1(%rip), %rax    # 0x21b416
movb (%rax), %al
leal 0x1e(%r13), %ecx
cmpl $0x3d, %r13d
movl %ecx, %r13d
jb 0xf4964
jmp 0xf4787
testl %r13d, %r13d
jne 0xf49b8
leaq 0x126993(%rip), %rcx    # 0x21b410
cmpb $0x0, (%rcx)
jne 0xf4a57
jmp 0xf49b8
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq