// File: /workspace/github_cpp_makefile_star2_O1/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 0xdb03c
leaq 0x13d7f9(%rip), %rax    # 0x2187d8
cmpl $0x0, (%rax)
jne 0xdb512
leaq 0x163f69(%rip), %rax    # 0x23ef58
cmpl $0x0, (%rax)
setne %cl
leaq 0x13d808(%rip), %rax    # 0x218804
movl (%rax), %eax
cmpl $0x258, %eax            # imm = 0x258
setl %dl
testb %dl, %cl
jne 0xdb512
leaq 0x231793(%rip), %rcx    # 0x30c7a8
movzbl (%rcx), %ecx
cmpl $0x4c, %ecx
je 0xdb025
testl %ecx, %ecx
jne 0xdb512
cmpl $0x257, %eax            # imm = 0x257
jg 0xdb03c
leaq 0x2603b5(%rip), %rax    # 0x33b3e8
cmpb $0x0, (%rax)
je 0xdb512
leaq 0x231f8d(%rip), %r13    # 0x30cfd0
movsd (%r13), %xmm5
leaq 0x231f88(%rip), %r8     # 0x30cfd8
movsd (%r8), %xmm6
leaq 0x231f84(%rip), %r9     # 0x30cfe0
movsd (%r9), %xmm7
leaq 0x2602a8(%rip), %r10    # 0x33b310
movsd (%r10), %xmm9
leaq 0x2602a4(%rip), %r12    # 0x33b318
movsd (%r12), %xmm10
leaq 0x26029f(%rip), %r11    # 0x33b320
movsd (%r11), %xmm11
leaq 0x260203(%rip), %rsi    # 0x33b290
movsd (%rsi), %xmm12
leaq 0x231f1f(%rip), %rdi    # 0x30cfb8
movsd (%rdi), %xmm8
leaq 0x231f23(%rip), %rdx    # 0x30cfc8
movsd (%rdx), %xmm13
leaq 0x13d81f(%rip), %rax    # 0x2188d0
cmpq $0x800000, (%rax)       # imm = 0x800000
je 0xdb1ef
leaq 0x231fbb(%rip), %rax    # 0x30d080
cmpl $0x0, (%rax)
jne 0xdb1ef
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm5
jne 0xdb0de
jnp 0xdb4e3
ucomisd %xmm0, %xmm6
jne 0xdb0ea
jnp 0xdb4e3
leaq 0x2601c3(%rip), %r13    # 0x33b2b4
xorl %r15d, %r15d
cmpl $0x0, (%r13)
je 0xdb521
leaq 0x2321be(%rip), %rax    # 0x30d2c4
cmpl $0x0, (%rax)
je 0xdb521
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 %r15d, %r15d
xorl %edi, %edi
callq 0xfb962
leaq 0x260195(%rip), %rax    # 0x33b2e8
cmpl $0x2, (%rax)
setb %al
leaq 0x260158(%rip), %rcx    # 0x33b2b8
movsd (%rcx), %xmm1
ucomisd %xmm1, %xmm0
setp %cl
setne %dl
orb %cl, %dl
testb %dl, %al
jne 0xdb52d
ucomisd %xmm1, %xmm0
ja 0xdb52d
leaq 0x231e47(%rip), %r13    # 0x30cfd0
movsd -0x48(%rbp), %xmm5
leaq 0x231e43(%rip), %r8     # 0x30cfd8
movsd -0x40(%rbp), %xmm6
leaq 0x231e3f(%rip), %r9     # 0x30cfe0
movsd -0x38(%rbp), %xmm7
leaq 0x260163(%rip), %r10    # 0x33b310
leaq 0x26016c(%rip), %r11    # 0x33b320
leaq 0x2600d5(%rip), %rsi    # 0x33b290
leaq 0x231df6(%rip), %rdi    # 0x30cfb8
movsd -0x30(%rbp), %xmm8
leaq 0x231df9(%rip), %rdx    # 0x30cfc8
movsd -0x70(%rbp), %xmm9
movsd -0x68(%rbp), %xmm10
movsd -0x60(%rbp), %xmm11
movsd -0x58(%rbp), %xmm12
movsd -0x50(%rbp), %xmm13
jmp 0xdb26c
movabsq $0x402e000000000000, %rax # imm = 0x402E000000000000
movq %rax, (%rsi)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, (%rdi)
movq %rax, (%rdx)
leaq 0x231e35(%rip), %rax    # 0x30d048
movsd (%rax), %xmm0
movsd 0x2df39(%rip), %xmm1    # 0x109158
divsd %xmm1, %xmm0
xorpd %xmm2, %xmm2
xorpd %xmm3, %xmm3
subsd %xmm0, %xmm3
movsd %xmm3, (%r13)
leaq 0x231e14(%rip), %rax    # 0x30d050
movsd (%rax), %xmm0
divsd %xmm1, %xmm0
subsd %xmm0, %xmm2
movsd %xmm2, (%r8)
leaq 0x231e04(%rip), %rax    # 0x30d058
movsd (%rax), %xmm0
movsd %xmm0, (%r9)
xorl %eax, %eax
movq %rax, (%r10)
movq %rax, (%r12)
movl $0x1, %r15d
leaq 0x231e11(%rip), %rax    # 0x30d084
movsd (%rsi), %xmm0
mulsd 0x2de29(%rip), %xmm0    # 0x1090a8
mulsd 0x2dde1(%rip), %xmm0    # 0x109068
movl %r15d, (%rax)
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xdb29a
jnp 0xdb512
movsd (%r10), %xmm1
subsd (%r13), %xmm1
movsd 0x2deab(%rip), %xmm2    # 0x109158
mulsd %xmm2, %xmm1
movsd (%rdi), %xmm3
divsd %xmm3, %xmm1
movsd (%r8), %xmm4
subsd (%r12), %xmm4
mulsd %xmm2, %xmm4
divsd %xmm3, %xmm4
mulsd (%rdx), %xmm4
movapd %xmm0, %xmm2
minsd %xmm4, %xmm2
movapd 0x2dec0(%rip), %xmm4    # 0x1091a0
xorpd %xmm0, %xmm4
movapd %xmm4, %xmm3
maxsd %xmm2, %xmm3
movapd %xmm0, %xmm2
minsd %xmm1, %xmm2
maxsd %xmm2, %xmm4
leaq 0x25ffa5(%rip), %r15    # 0x33b2a4
cvtsi2sdl (%r15), %xmm14
mulsd 0x2dd5b(%rip), %xmm14   # 0x109068
mulsd %xmm14, %xmm4
divsd %xmm0, %xmm4
mulsd %xmm3, %xmm14
divsd %xmm0, %xmm14
leaq 0x25ff85(%rip), %rax    # 0x33b2ac
leaq 0x25ff6a(%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 0x25ff5b(%rip), %rax    # 0x33b2a8
cvttsd2si %xmm4, %ecx
addl (%rax), %esi
addl %ecx, %esi
movl %edi, 0x29ea1d(%rip)    # 0x379d78
movl %esi, 0x29ea1b(%rip)    # 0x379d7c
testl %r14d, %r14d
je 0xdb421
movzbl %bl, %edx
movsd %xmm5, -0x48(%rbp)
movq %r8, %rbx
movsd %xmm6, -0x40(%rbp)
movq %r9, %r14
movsd %xmm7, -0x38(%rbp)
movq %r10, %r12
movq %r11, %r15
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)
movsd %xmm14, -0x78(%rbp)
callq 0xe6a0
movsd -0x78(%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
leaq 0x231bd6(%rip), %rdx    # 0x30cfc8
movsd -0x30(%rbp), %xmm8
movq %r15, %r11
leaq 0x25fea2(%rip), %r15    # 0x33b2a4
movq %r12, %r10
leaq 0x25ff0c(%rip), %r12    # 0x33b318
movsd -0x38(%rbp), %xmm7
movq %r14, %r9
movsd -0x40(%rbp), %xmm6
movq %rbx, %r8
movsd -0x48(%rbp), %xmm5
leaq 0x25fec0(%rip), %rcx    # 0x33b2e8
movl (%rcx), %eax
incl %eax
movl %eax, (%rcx)
xorps %xmm0, %xmm0
cvtsi2sdl (%r15), %xmm0
movsd 0x2dc2a(%rip), %xmm2    # 0x109068
mulsd %xmm0, %xmm2
addsd %xmm2, %xmm14
movsd 0x502d1(%rip), %xmm1    # 0x12b720
mulsd %xmm1, %xmm14
divsd %xmm0, %xmm14
xorpd %xmm3, %xmm3
ucomisd %xmm3, %xmm14
jb 0xdb5d3
ucomisd %xmm14, %xmm1
leaq 0x25fe1c(%rip), %rsi    # 0x33b290
leaq 0x231b3d(%rip), %rdi    # 0x30cfb8
jbe 0xdb4e3
addsd %xmm2, %xmm4
mulsd %xmm1, %xmm4
divsd %xmm0, %xmm4
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm4
jb 0xdb4e3
ucomisd %xmm4, %xmm1
jbe 0xdb4e3
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
movq %rdx, %rbx
cvttsd2si %xmm4, %edx
movslq %edx, %rdx
imulq $0x281, %rax, %rax      # imm = 0x281
addq 0x74aa3(%rip), %rax     # 0x14ff80
movb %cl, (%rdx,%rax)
movq %rbx, %rdx
movsd %xmm5, (%r13)
movsd %xmm6, (%r8)
movsd %xmm7, (%r9)
movsd %xmm9, (%r10)
movsd %xmm10, (%r12)
movsd %xmm11, (%r11)
movsd %xmm12, (%rsi)
movsd %xmm8, (%rdi)
movsd %xmm13, (%rdx)
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x231aa8(%rip), %r13    # 0x30cfd0
jmp 0xdb26c
movl $0x1, (%r13)
callq 0xfbb19
leaq 0x25fd8b(%rip), %rax    # 0x33b2cc
cmpl $0x0, (%rax)
jne 0xdb54d
xorl %edi, %edi
callq 0xfbd5d
leaq 0x13d2f0(%rip), %rax    # 0x218844
movl $0x10e1, (%rax)         # imm = 0x10E1
leaq 0x25fdaf(%rip), %r10    # 0x33b310
movsd (%r10), %xmm9
movsd (%r12), %xmm10
leaq 0x231a6d(%rip), %r9     # 0x30cfe0
movsd (%r9), %xmm11
leaq 0x231a49(%rip), %rdx    # 0x30cfc8
movsd (%rdx), %xmm13
leaq 0x25fd05(%rip), %rsi    # 0x33b290
movsd (%rsi), %xmm12
leaq 0x25fda9(%rip), %rax    # 0x33b340
movl $0x3, (%rax)
leaq 0x231a2c(%rip), %r13    # 0x30cfd0
movsd -0x48(%rbp), %xmm5
leaq 0x231a28(%rip), %r8     # 0x30cfd8
movsd -0x40(%rbp), %xmm6
movsd -0x38(%rbp), %xmm7
leaq 0x25fd5f(%rip), %r11    # 0x33b320
leaq 0x2319f0(%rip), %rdi    # 0x30cfb8
movsd -0x30(%rbp), %xmm8
jmp 0xdb26c
leaq 0x25fcb6(%rip), %rsi    # 0x33b290
leaq 0x2319d7(%rip), %rdi    # 0x30cfb8
jmp 0xdb4e3