// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathmsc.cpp
// Function: plot_lla_point(int, int)
void plot_lla_point(int draw, int color)
{
double x,y;
double xi, yi;
double half_span;
double old_lat, old_lon, old_alt;
double old_ref_lat, old_ref_lon, old_ref_alt;
double old_span, old_scale, old_cos;
double span;

   // add a point to the lat/lon scattergram plot

   if(draw) {
      if(text_mode || (first_key && (SCREEN_HEIGHT < SHORT_SCREEN))) return;
      if(zoom_screen && (zoom_screen != 'L')) return; 
      if(0 && all_adevs && (WIDE_SCREEN == 0)) return;
      if((SCREEN_HEIGHT < SHORT_SCREEN) && (shared_plot == 0)) return;
   }

   old_lat = lat;
   old_lon = lon;
   old_alt = alt;
   old_ref_lat = ref_lat;
   old_ref_lon = ref_lon;
   old_ref_alt = ref_alt;
   old_span = LLA_SPAN;
   old_scale = ANGLE_SCALE;
   old_cos = cos_factor;

   if((rcvr_type == TIDE_RCVR) || show_tides) { // ckckck adjust scale factors for showing lat/lon earth tides
      LLA_SPAN = TIDE_LLA_SPAN;    // !!!!! 10? 15?
      ANGLE_SCALE = 1.0;
      cos_factor = 1.0;
      lat = 0.0 - (lat_tide / RAD_TO_DEG);
      lon = 0.0 - (lon_tide / RAD_TO_DEG);
      alt = alt_tide;
      ref_lat = 0.0;
      ref_lon = 0.0;
      tide_scatter = 1;
   }
   else if(1 && ((lat == 0.0) || (lon == 0.0))) {  // ignore likely invald location
      goto no_lla;
   }
   else {
      if(1 && autoscale_lla && have_valid_lla) {
         span = calc_lla_span(0);
         if(((lla_points < 2) && (span != last_lla_span)) || (span > last_lla_span)) {  // the plot scale has changed
//          autoscale_lla = 0;  // toggle autoscale off
//          change_lla_scale();

            autoscale_lla = 1;        // toggle autoscale back on
            change_lla_scale();

            if(in_rebuild_lla) ;      //llascale - prevent recursion with rebuild_lla_plot()
            else rebuild_lla_plot(0);
            need_redraw = 4321;

            old_ref_lat = ref_lat;
            old_ref_lon = ref_lon;
            old_ref_alt = alt;
            old_cos = cos_factor;
            old_span = LLA_SPAN;
            user_set_ref_lla = 3;
         }
      }
      tide_scatter = 0;
   }


   y = (ref_lat - lat) * RAD_TO_DEG / ANGLE_SCALE;   // x,y = meters (or feet) from center
   x = ((lon - ref_lon) * RAD_TO_DEG / ANGLE_SCALE) * cos_factor;

   half_span = (LLA_SPAN*(double)LLA_DIVISIONS/2.0); // meters each side of center
   if(half_span == 0.0) return;

   if(x > half_span) x = half_span;
   if(x < (-half_span)) x = (-half_span);

   if(y > half_span) y = half_span;
   if(y < (-half_span)) y = (-half_span);

   yi = (y * ((double)lla_width / 2.0)) / half_span;
   xi = (x * ((double)lla_width / 2.0)) / half_span;
   lla_xi = LLA_X + (int) xi;
   lla_yi = LLA_Y + (int) yi;
   if(draw) dot(lla_xi, lla_yi, color);

#ifdef BUFFER_LLA
   // save lla point in the buffer so we can redraw the screen later
   ++lla_points;
   color = (lla_points / (60*60));
   color = (color % 12) + 3;

   xi += ((double) lla_width/2.0);
   yi += ((double) lla_width/2.0);

   xi = ((double) xi * (double) MAX_LLA_SIZE / (double) lla_width);
   yi = ((double) yi * (double) MAX_LLA_SIZE / (double) lla_width);
   if((xi >= 0.0) && (xi < (double) MAX_LLA_SIZE) && (yi >= 0.0) && (yi < (double) MAX_LLA_SIZE)) {
      lla_data[(int)xi][(int)yi] = (u08) color;
   }
#endif

   no_lla:
   lat = old_lat;
   lon = old_lon;
   alt = old_alt;
   ref_lat = old_ref_lat;
   ref_lon = old_ref_lon;
   ref_alt = old_ref_alt;
   LLA_SPAN = old_span;
   ANGLE_SCALE = old_scale;
   cos_factor = old_cos;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %esi, %ebx
movl %edi, %r14d
testl %edi, %edi
je 0xdb6f8
leaq 0x13d13d(%rip), %rax    # 0x2187d8
cmpl $0x0, (%rax)
jne 0xdbbd1
leaq 0x1638ad(%rip), %rax    # 0x23ef58
cmpl $0x0, (%rax)
setne %cl
leaq 0x13d14c(%rip), %rax    # 0x218804
movl (%rax), %eax
cmpl $0x258, %eax            # imm = 0x258
setl %dl
testb %dl, %cl
jne 0xdbbd1
leaq 0x2310d7(%rip), %rcx    # 0x30c7a8
movzbl (%rcx), %ecx
cmpl $0x4c, %ecx
je 0xdb6e1
testl %ecx, %ecx
jne 0xdbbd1
cmpl $0x257, %eax            # imm = 0x257
jg 0xdb6f8
leaq 0x25fcf9(%rip), %rax    # 0x33b3e8
cmpb $0x0, (%rax)
je 0xdbbd1
leaq 0x2318d1(%rip), %r8     # 0x30cfd0
movsd (%r8), %xmm5
leaq 0x2318cd(%rip), %r9     # 0x30cfd8
movsd (%r9), %xmm6
leaq 0x2318c9(%rip), %r10    # 0x30cfe0
movsd (%r10), %xmm7
leaq 0x25fbed(%rip), %r15    # 0x33b310
movsd (%r15), %xmm9
leaq 0x25fbe9(%rip), %r12    # 0x33b318
movsd (%r12), %xmm10
leaq 0x25fbe4(%rip), %r11    # 0x33b320
movsd (%r11), %xmm11
leaq 0x25fb48(%rip), %rsi    # 0x33b290
movsd (%rsi), %xmm13
leaq 0x231864(%rip), %rdi    # 0x30cfb8
movsd (%rdi), %xmm8
leaq 0x231868(%rip), %r13    # 0x30cfc8
movsd (%r13), %xmm12
leaq 0x13d163(%rip), %rax    # 0x2188d0
cmpq $0x800000, (%rax)       # imm = 0x800000
je 0xdb8a9
leaq 0x2318ff(%rip), %rax    # 0x30d080
cmpl $0x0, (%rax)
jne 0xdb8a9
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm5
jne 0xdb79a
jnp 0xdbba2
ucomisd %xmm0, %xmm6
jne 0xdb7a6
jnp 0xdbba2
leaq 0x25fb07(%rip), %r13    # 0x33b2b4
xorl %eax, %eax
cmpl $0x0, (%r13)
je 0xdbbe0
leaq 0x231b03(%rip), %rcx    # 0x30d2c4
cmpl $0x0, (%rcx)
je 0xdbbe0
movsd %xmm13, -0x50(%rbp)
movsd %xmm12, -0x58(%rbp)
movsd %xmm11, -0x60(%rbp)
movsd %xmm10, -0x68(%rbp)
movsd %xmm9, -0x70(%rbp)
movsd %xmm8, -0x30(%rbp)
movsd %xmm7, -0x38(%rbp)
movsd %xmm6, -0x40(%rbp)
movsd %xmm5, -0x48(%rbp)
xorl %edi, %edi
callq 0xfc0e0
leaq 0x25fadd(%rip), %rax    # 0x33b2e8
cmpl $0x2, (%rax)
setb %al
leaq 0x25faa0(%rip), %rcx    # 0x33b2b8
movsd (%rcx), %xmm1
ucomisd %xmm1, %xmm0
setp %cl
setne %dl
orb %cl, %dl
testb %dl, %al
jne 0xdbbf1
ucomisd %xmm1, %xmm0
ja 0xdbbf1
leaq 0x25fa4f(%rip), %rax    # 0x33b290
movsd (%rax), %xmm0
xorl %eax, %eax
leaq 0x231782(%rip), %r8     # 0x30cfd0
movsd -0x48(%rbp), %xmm5
leaq 0x23177e(%rip), %r9     # 0x30cfd8
movsd -0x40(%rbp), %xmm6
leaq 0x23177a(%rip), %r10    # 0x30cfe0
movsd -0x38(%rbp), %xmm7
leaq 0x25faae(%rip), %r11    # 0x33b320
leaq 0x23173f(%rip), %rdi    # 0x30cfb8
movsd -0x30(%rbp), %xmm8
leaq 0x231742(%rip), %r13    # 0x30cfc8
movsd -0x70(%rbp), %xmm9
movsd -0x68(%rbp), %xmm10
movsd -0x60(%rbp), %xmm11
movsd -0x58(%rbp), %xmm12
movsd -0x50(%rbp), %xmm13
jmp 0xdb92d
movabsq $0x402e000000000000, %rax # imm = 0x402E000000000000
movq %rax, (%rsi)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, (%rdi)
movq %rax, (%r13)
leaq 0x23177a(%rip), %rax    # 0x30d048
movsd (%rax), %xmm0
movsd 0x2d886(%rip), %xmm1    # 0x109160
divsd %xmm1, %xmm0
xorpd %xmm2, %xmm2
xorpd %xmm3, %xmm3
subsd %xmm0, %xmm3
movsd %xmm3, (%r8)
leaq 0x23175a(%rip), %rax    # 0x30d050
movsd (%rax), %xmm0
divsd %xmm1, %xmm0
subsd %xmm0, %xmm2
movsd %xmm2, (%r9)
leaq 0x23174a(%rip), %rax    # 0x30d058
movsd (%rax), %xmm0
movsd %xmm0, (%r10)
xorl %eax, %eax
movq %rax, (%r15)
movq %rax, (%r12)
movl $0x1, %eax
movsd 0x42c0b(%rip), %xmm0    # 0x11e538
leaq 0x231750(%rip), %rcx    # 0x30d084
mulsd 0x2d76c(%rip), %xmm0    # 0x1090a8
mulsd 0x2d724(%rip), %xmm0    # 0x109068
movl %eax, (%rcx)
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xdb956
jnp 0xdbbd1
movsd (%r15), %xmm1
subsd (%r8), %xmm1
movsd 0x2d7f8(%rip), %xmm2    # 0x109160
mulsd %xmm2, %xmm1
movsd (%rdi), %xmm3
divsd %xmm3, %xmm1
movsd (%r9), %xmm4
subsd (%r12), %xmm4
mulsd %xmm2, %xmm4
divsd %xmm3, %xmm4
mulsd (%r13), %xmm4
movapd %xmm0, %xmm2
minsd %xmm4, %xmm2
movapd 0x2d813(%rip), %xmm4    # 0x1091b0
xorpd %xmm0, %xmm4
movapd %xmm4, %xmm14
maxsd %xmm2, %xmm14
movapd %xmm0, %xmm2
minsd %xmm1, %xmm2
maxsd %xmm2, %xmm4
leaq 0x25f8e6(%rip), %rax    # 0x33b2a4
xorps %xmm1, %xmm1
cvtsi2sdl (%rax), %xmm1
movsd 0x2d69b(%rip), %xmm2    # 0x109068
mulsd %xmm1, %xmm2
mulsd %xmm2, %xmm4
divsd %xmm0, %xmm4
mulsd %xmm2, %xmm14
divsd %xmm0, %xmm14
leaq 0x25f8c2(%rip), %rax    # 0x33b2ac
leaq 0x25f8a7(%rip), %rcx    # 0x33b298
movl (%rcx), %ecx
movl %ecx, %esi
shrl $0x1f, %esi
addl %ecx, %esi
sarl %esi
cvttsd2si %xmm14, %ecx
decl %esi
movl (%rax), %edi
addl %esi, %edi
addl %ecx, %edi
leaq 0x25f898(%rip), %rax    # 0x33b2a8
cvttsd2si %xmm4, %ecx
addl (%rax), %esi
addl %ecx, %esi
movl %edi, 0x29e35a(%rip)    # 0x379d78
movl %esi, 0x29e358(%rip)    # 0x379d7c
testl %r14d, %r14d
je 0xdbafa
movzbl %bl, %edx
movq %r8, %rbx
movsd %xmm5, -0x48(%rbp)
movq %r9, %r14
movsd %xmm6, -0x40(%rbp)
movq %r10, %r15
movsd %xmm7, -0x38(%rbp)
movq %r13, %r12
movq %r11, %r13
movsd %xmm8, -0x30(%rbp)
movsd %xmm9, -0x70(%rbp)
movsd %xmm10, -0x68(%rbp)
movsd %xmm11, -0x60(%rbp)
movsd %xmm12, -0x58(%rbp)
movsd %xmm13, -0x50(%rbp)
movapd %xmm4, -0x90(%rbp)
movapd %xmm14, -0x80(%rbp)
callq 0xe657
movapd -0x80(%rbp), %xmm14
movapd -0x90(%rbp), %xmm4
movsd -0x50(%rbp), %xmm13
movsd -0x58(%rbp), %xmm12
movsd -0x60(%rbp), %xmm11
movsd -0x68(%rbp), %xmm10
movsd -0x70(%rbp), %xmm9
movsd -0x30(%rbp), %xmm8
movq %r13, %r11
movq %r12, %r13
movsd -0x38(%rbp), %xmm7
movq %r15, %r10
leaq 0x25f844(%rip), %r15    # 0x33b310
leaq 0x25f845(%rip), %r12    # 0x33b318
movsd -0x40(%rbp), %xmm6
movq %r14, %r9
movsd -0x48(%rbp), %xmm5
movq %rbx, %r8
leaq 0x25f7ba(%rip), %rax    # 0x33b2a4
cvtsi2sdl (%rax), %xmm1
movsd 0x2d572(%rip), %xmm2    # 0x109068
mulsd %xmm1, %xmm2
leaq 0x25f7e7(%rip), %rcx    # 0x33b2e8
movl (%rcx), %eax
incl %eax
movl %eax, (%rcx)
addsd %xmm2, %xmm14
movsd 0x4fcec(%rip), %xmm0    # 0x12b800
mulsd %xmm0, %xmm14
divsd %xmm1, %xmm14
xorpd %xmm3, %xmm3
ucomisd %xmm3, %xmm14
leaq 0x25f762(%rip), %rsi    # 0x33b290
jb 0xdbc97
ucomisd %xmm14, %xmm0
leaq 0x231478(%rip), %rdi    # 0x30cfb8
jbe 0xdbba2
addsd %xmm2, %xmm4
mulsd %xmm0, %xmm4
divsd %xmm1, %xmm4
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm4
jb 0xdbba2
ucomisd %xmm4, %xmm0
jbe 0xdbba2
movl %eax, %eax
movl $0x91a2b3c5, %ecx       # imm = 0x91A2B3C5
imulq %rax, %rcx
shrq $0x2b, %rcx
imulq $0x15555556, %rcx, %rax # imm = 0x15555556
shrq $0x20, %rax
shll $0x2, %eax
leal (%rax,%rax,2), %eax
subl %eax, %ecx
addb $0x3, %cl
cvttsd2si %xmm14, %eax
cltq
cvttsd2si %xmm4, %edx
movslq %edx, %rdx
imulq $0x281, %rax, %rax      # imm = 0x281
addq 0x743e1(%rip), %rax     # 0x14ff80
movb %cl, (%rdx,%rax)
movsd %xmm5, (%r8)
movsd %xmm6, (%r9)
movsd %xmm7, (%r10)
movsd %xmm9, (%r15)
movsd %xmm10, (%r12)
movsd %xmm11, (%r11)
movsd %xmm13, (%rsi)
movsd %xmm8, (%rdi)
movsd %xmm12, (%r13)
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movapd %xmm13, %xmm0
leaq 0x2313dc(%rip), %r13    # 0x30cfc8
jmp 0xdb92d
movl $0x1, (%r13)
callq 0xfc28e
leaq 0x25f6c7(%rip), %rax    # 0x33b2cc
cmpl $0x0, (%rax)
jne 0xdbc11
xorl %edi, %edi
callq 0xfc4c8
leaq 0x13cc2c(%rip), %rax    # 0x218844
movl $0x10e1, (%rax)         # imm = 0x10E1
movsd (%r15), %xmm9
movsd (%r12), %xmm10
leaq 0x2313b0(%rip), %r10    # 0x30cfe0
movsd (%r10), %xmm11
leaq 0x23138c(%rip), %r13    # 0x30cfc8
movsd (%r13), %xmm12
leaq 0x25f647(%rip), %rax    # 0x33b290
movsd (%rax), %xmm0
leaq 0x25f6ec(%rip), %rax    # 0x33b340
movl $0x3, (%rax)
xorl %eax, %eax
movapd %xmm0, %xmm13
leaq 0x231368(%rip), %r8     # 0x30cfd0
movsd -0x48(%rbp), %xmm5
leaq 0x231364(%rip), %r9     # 0x30cfd8
movsd -0x40(%rbp), %xmm6
movsd -0x38(%rbp), %xmm7
leaq 0x25f69b(%rip), %r11    # 0x33b320
leaq 0x23132c(%rip), %rdi    # 0x30cfb8
movsd -0x30(%rbp), %xmm8
jmp 0xdb92d
leaq 0x23131a(%rip), %rdi    # 0x30cfb8
jmp 0xdbba2