// File: /workspace/github_cpp_makefile_star2_O1/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, -0x34(%rbp)
testl %edi, %edi
setne %al
leaq 0x12740e(%rip), %rdx    # 0x21b415
cmpb $0x3, (%rdx)
sete %dl
xorl %esi, %esi
testb %dl, %al
movl %ecx, -0x54(%rbp)
cmovnel %ecx, %esi
movl %esi, %eax
je 0xf401f
addss %xmm1, %xmm1
movl -0x3c(%rbp), %r15d
subl %eax, %r15d
addl -0x40(%rbp), %eax
movl %eax, -0x38(%rbp)
xorps %xmm0, %xmm0
movaps %xmm1, %xmm2
mulss %xmm0, %xmm2
movss %xmm2, -0x2c(%rbp)
movl $0x5, %ebx
movsd 0x150f0(%rip), %xmm0    # 0x109138
leaq 0x1273c7(%rip), %r14    # 0x21b416
movss %xmm1, -0x30(%rbp)
movss %xmm1, -0x48(%rbp)
movsd %xmm0, -0x60(%rbp)
movsd 0x2a02a(%rip), %xmm1    # 0x11e090
callq 0x94d0
movsd 0x150e5(%rip), %xmm1    # 0x109158
divsd %xmm1, %xmm0
callq 0x9710
cvtsd2ss %xmm0, %xmm0
mulss -0x48(%rbp), %xmm0
movss %xmm0, -0x50(%rbp)
movsd -0x60(%rbp), %xmm0
movsd 0x29ff9(%rip), %xmm1    # 0x11e090
callq 0x94d0
divsd 0x150b4(%rip), %xmm0    # 0x109158
callq 0x9080
movss -0x48(%rbp), %xmm1
cvtsd2ss %xmm0, %xmm0
mulss %xmm1, %xmm0
movss %xmm0, -0x4c(%rbp)
cmpl $0x60, %ebx
jb 0xf4109
cmpl $0x0, -0x34(%rbp)
je 0xf4109
leaq 0x127348(%rip), %rax    # 0x21b415
cmpb $0x3, (%rax)
jne 0xf4109
movsd -0x60(%rbp), %xmm0
addsd 0x15059(%rip), %xmm0    # 0x109138
leal 0x5(%rbx), %eax
movss -0x4c(%rbp), %xmm2
movss %xmm2, -0x2c(%rbp)
movss -0x50(%rbp), %xmm2
movss %xmm2, -0x30(%rbp)
cmpl $0x164, %ebx            # imm = 0x164
movl %eax, %ebx
jb 0xf4059
jmp 0xf43d6
leal -0x5(%rbx), %r12d
imull $0xeeeeeeef, %r12d, %eax # imm = 0xEEEEEEEF
rorl %eax
movss -0x30(%rbp), %xmm4
movss 0x385d1(%rip), %xmm1    # 0x12c6f4
mulss %xmm1, %xmm4
cmpl $0x8888888, %eax        # imm = 0x8888888
ja 0xf41c1
cmpl $0x0, -0x34(%rbp)
setne %r13b
cvttss2si %xmm4, %edx
movss -0x2c(%rbp), %xmm0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
addl %r15d, %edx
movl -0x38(%rbp), %esi
movl %esi, %ecx
subl %eax, %ecx
leaq 0x24724c(%rip), %rax    # 0x33b3a8
movzbl (%rax), %r8d
movl %r15d, %edi
movss %xmm4, -0x44(%rbp)
callq 0xe3c3
movss -0x44(%rbp), %xmm4
movss 0x3857a(%rip), %xmm1    # 0x12c6f4
leaq 0x127294(%rip), %rax    # 0x21b415
movb (%rax), %al
testb %al, %al
setne %cl
andb %r13b, %cl
cmpb $0x1, %cl
jne 0xf41c1
leal 0x109(%rbx), %r8d
cmpb $0x4, %al
movl $0x64, %ecx
movl $0x5a, %eax
cmovael %eax, %ecx
movl -0x3c(%rbp), %edi
movl -0x40(%rbp), %esi
movl -0x54(%rbp), %edx
callq 0xf3e3a
movss -0x44(%rbp), %xmm4
movss 0x38533(%rip), %xmm1    # 0x12c6f4
movss -0x30(%rbp), %xmm0
movss 0x3852a(%rip), %xmm3    # 0x12c6f8
mulss %xmm3, %xmm0
cvttss2si %xmm0, %edi
addl %r15d, %edi
movss -0x2c(%rbp), %xmm2
movaps %xmm2, %xmm0
mulss %xmm3, %xmm0
cvttss2si %xmm0, %eax
movl -0x38(%rbp), %ecx
movl %ecx, %esi
subl %eax, %esi
cvttss2si %xmm4, %edx
movaps %xmm2, %xmm0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
addl %r15d, %edx
subl %eax, %ecx
leaq 0x24719d(%rip), %rax    # 0x33b3a8
movzbl (%rax), %r8d
callq 0xe3c3
cmpb $0x0, (%r14)
je 0xf42ad
cmpl $0x0, -0x34(%rbp)
jne 0xf4248
leaq 0x1271e5(%rip), %rax    # 0x21b410
cmpb $0x0, (%rax)
jne 0xf4266
leaq 0x1271da(%rip), %rax    # 0x21b411
cmpb $0x0, (%rax)
je 0xf4266
leaq 0x218565(%rip), %rax    # 0x30c7a8
cmpb $0x42, (%rax)
je 0xf4266
cmpl $0x0, -0x34(%rbp)
setne %al
leaq 0x1271bf(%rip), %rcx    # 0x21b415
movb (%rcx), %dl
cmpb $0x4, %dl
setae %cl
testb %dl, %dl
je 0xf4266
andb %cl, %al
je 0xf42ad
movss 0x18d82(%rip), %xmm1    # 0x10cff0
movaps %xmm1, %xmm0
leaq 0x218e3c(%rip), %rax    # 0x30d0b4
subss (%rax), %xmm0
divss %xmm1, %xmm0
movss -0x30(%rbp), %xmm1
mulss %xmm0, %xmm1
cvttss2si %xmm1, %edi
mulss -0x2c(%rbp), %xmm0
cvttss2si %xmm0, %eax
addl %r15d, %edi
movl -0x38(%rbp), %esi
subl %eax, %esi
leaq 0x247103(%rip), %rax    # 0x33b3a8
movzbl (%rax), %edx
callq 0xe6a0
xorl %r13d, %r13d
xorps %xmm2, %xmm2
leaq 0x2184ee(%rip), %rsi    # 0x30c7a8
leaq 0x218df3(%rip), %rdi    # 0x30d0b4
cmpb $0x0, (%r14)
je 0xf42e8
movss (%rdi), %xmm0
cvttss2si %xmm0, %eax
cmpl %eax, %r13d
sete %al
ucomiss %xmm0, %xmm2
setp %cl
setne %dl
orb %cl, %dl
testb %al, %dl
jne 0xf43a6
movzbl (%rsi), %eax
movl %eax, %ecx
xorl $0x42, %ecx
orl %r13d, %ecx
je 0xf43a6
addl $-0x49, %eax
cmpl $0x10, %eax
ja 0xf43bc
movl $0x13411, %ecx          # imm = 0x13411
btl %eax, %ecx
jae 0xf43bc
cmpl $0x5a, %r12d
jne 0xf432b
cmpl $0x0, -0x34(%rbp)
je 0xf432b
leaq 0x1270ef(%rip), %rax    # 0x21b415
cmpb $0x3, (%rax)
je 0xf43a6
xorps %xmm0, %xmm0
cvtsi2ss %r13d, %xmm0
movss 0x18cb5(%rip), %xmm2    # 0x10cff0
movaps %xmm2, %xmm1
subss %xmm0, %xmm1
divss %xmm2, %xmm1
movss -0x30(%rbp), %xmm0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %edi
addl %r15d, %edi
movss -0x2c(%rbp), %xmm0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl -0x38(%rbp), %ecx
movl %ecx, %esi
movss -0x50(%rbp), %xmm0
mulss %xmm1, %xmm0
cvttss2si %xmm0, %edx
subl %eax, %esi
mulss -0x4c(%rbp), %xmm1
cvttss2si %xmm1, %eax
addl %r15d, %edx
subl %eax, %ecx
leaq 0x24701c(%rip), %rax    # 0x33b3a8
movzbl (%rax), %r8d
callq 0xe3c3
leaq 0x218d18(%rip), %rdi    # 0x30d0b4
leaq 0x218405(%rip), %rsi    # 0x30c7a8
xorps %xmm2, %xmm2
leal 0x1e(%r13), %eax
cmpl $0x3d, %r13d
movl %eax, %r13d
jb 0xf42c1
jmp 0xf40d2
testl %r13d, %r13d
jne 0xf4313
leaq 0x127044(%rip), %rax    # 0x21b410
cmpb $0x0, (%rax)
jne 0xf43a6
jmp 0xf4313
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq