// File: /workspace/github_cpp_makefile_star2_O2/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 0xc9b13
leaq 0x138d22(%rip), %rax    # 0x2027d8
cmpl $0x0, (%rax)
jne 0xc9fd4
leaq 0x15f492(%rip), %rax    # 0x228f58
cmpl $0x0, (%rax)
setne %cl
leaq 0x138d31(%rip), %rax    # 0x202804
movl (%rax), %eax
cmpl $0x258, %eax            # imm = 0x258
setl %dl
testb %dl, %cl
jne 0xc9fd4
leaq 0x22ccbc(%rip), %rcx    # 0x2f67a8
movzbl (%rcx), %ecx
cmpl $0x4c, %ecx
je 0xc9afc
testl %ecx, %ecx
jne 0xc9fd4
cmpl $0x257, %eax            # imm = 0x257
jg 0xc9b13
leaq 0x25b8de(%rip), %rax    # 0x3253e8
cmpb $0x0, (%rax)
je 0xc9fd4
leaq 0x22d4b6(%rip), %r8     # 0x2f6fd0
movsd (%r8), %xmm5
leaq 0x22d4b2(%rip), %r9     # 0x2f6fd8
movsd (%r9), %xmm6
leaq 0x22d4ae(%rip), %r10    # 0x2f6fe0
movsd (%r10), %xmm7
leaq 0x25b7d2(%rip), %r15    # 0x325310
movsd (%r15), %xmm9
leaq 0x25b7ce(%rip), %r12    # 0x325318
movsd (%r12), %xmm10
leaq 0x25b7c9(%rip), %r11    # 0x325320
movsd (%r11), %xmm11
leaq 0x25b72d(%rip), %rsi    # 0x325290
movsd (%rsi), %xmm13
leaq 0x22d449(%rip), %rdi    # 0x2f6fb8
movsd (%rdi), %xmm8
leaq 0x22d44d(%rip), %r13    # 0x2f6fc8
movsd (%r13), %xmm12
leaq 0x138d48(%rip), %rax    # 0x2028d0
cmpq $0x800000, (%rax)       # imm = 0x800000
je 0xc9cc4
leaq 0x22d4e4(%rip), %rax    # 0x2f7080
cmpl $0x0, (%rax)
jne 0xc9cc4
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm5
jne 0xc9bb5
jnp 0xc9fa5
ucomisd %xmm0, %xmm6
jne 0xc9bc1
jnp 0xc9fa5
leaq 0x25b6ec(%rip), %r13    # 0x3252b4
xorl %eax, %eax
cmpl $0x0, (%r13)
je 0xc9fe3
leaq 0x22d6e8(%rip), %rcx    # 0x2f72c4
cmpl $0x0, (%rcx)
je 0xc9fe3
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 0xe6593
leaq 0x25b6c2(%rip), %rax    # 0x3252e8
cmpl $0x2, (%rax)
setb %al
leaq 0x25b685(%rip), %rcx    # 0x3252b8
movsd (%rcx), %xmm1
ucomisd %xmm1, %xmm0
setp %cl
setne %dl
orb %cl, %dl
testb %dl, %al
jne 0xc9ff4
ucomisd %xmm1, %xmm0
ja 0xc9ff4
leaq 0x25b634(%rip), %rax    # 0x325290
movsd (%rax), %xmm0
xorl %eax, %eax
leaq 0x22d367(%rip), %r8     # 0x2f6fd0
movsd -0x48(%rbp), %xmm5
leaq 0x22d363(%rip), %r9     # 0x2f6fd8
movsd -0x40(%rbp), %xmm6
leaq 0x22d35f(%rip), %r10    # 0x2f6fe0
movsd -0x38(%rbp), %xmm7
leaq 0x25b693(%rip), %r11    # 0x325320
leaq 0x22d324(%rip), %rdi    # 0x2f6fb8
movsd -0x30(%rbp), %xmm8
leaq 0x22d327(%rip), %r13    # 0x2f6fc8
movsd -0x70(%rbp), %xmm9
movsd -0x68(%rbp), %xmm10
movsd -0x60(%rbp), %xmm11
movsd -0x58(%rbp), %xmm12
movsd -0x50(%rbp), %xmm13
jmp 0xc9d46
movabsq $0x402e000000000000, %rax # imm = 0x402E000000000000
movq %rax, (%rsi)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, (%rdi)
movq %rax, (%r13)
leaq 0x22d35f(%rip), %rax    # 0x2f7048
movsd (%rax), %xmm0
movsd 0x2946b(%rip), %xmm1    # 0xf3160
divsd %xmm1, %xmm0
xorpd %xmm2, %xmm2
xorpd %xmm3, %xmm3
subsd %xmm0, %xmm3
movsd %xmm3, (%r8)
leaq 0x22d33f(%rip), %rax    # 0x2f7050
movsd (%rax), %xmm0
divsd %xmm1, %xmm0
subsd %xmm0, %xmm2
movsd %xmm2, (%r9)
andq $0x0, (%r15)
leaq 0x22d32b(%rip), %rax    # 0x2f7058
andq $0x0, (%r12)
movsd (%rax), %xmm0
movsd %xmm0, (%r10)
pushq $0x1
popq %rax
movsd 0x3e7e2(%rip), %xmm0    # 0x108528
leaq 0x22d337(%rip), %rcx    # 0x2f7084
mulsd 0x29353(%rip), %xmm0    # 0xf30a8
mulsd 0x2930b(%rip), %xmm0    # 0xf3068
movl %eax, (%rcx)
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xc9d6f
jnp 0xc9fd4
movsd (%r15), %xmm1
subsd (%r8), %xmm1
movsd 0x293df(%rip), %xmm2    # 0xf3160
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 0x293fa(%rip), %xmm4    # 0xf31b0
xorpd %xmm0, %xmm4
movapd %xmm4, %xmm14
maxsd %xmm2, %xmm14
movapd %xmm0, %xmm2
minsd %xmm1, %xmm2
maxsd %xmm2, %xmm4
leaq 0x25b4cd(%rip), %rax    # 0x3252a4
cvtsi2sdl (%rax), %xmm1
movsd 0x29285(%rip), %xmm2    # 0xf3068
mulsd %xmm1, %xmm2
mulsd %xmm2, %xmm4
divsd %xmm0, %xmm4
mulsd %xmm2, %xmm14
divsd %xmm0, %xmm14
leaq 0x25b4ac(%rip), %rcx    # 0x3252ac
leaq 0x25b491(%rip), %rax    # 0x325298
movl (%rax), %eax
pushq $0x2
popq %rsi
cltd
idivl %esi
cvttsd2si %xmm14, %edx
decl %eax
movl (%rcx), %edi
addl %eax, %edi
addl %edx, %edi
leaq 0x25b485(%rip), %rcx    # 0x3252a8
cvttsd2si %xmm4, %edx
addl (%rcx), %eax
addl %edx, %eax
movl %edi, 0x299f47(%rip)    # 0x363d78
movl %eax, 0x299f45(%rip)    # 0x363d7c
testl %r14d, %r14d
je 0xc9f0f
movzbl %bl, %edx
movl %eax, %esi
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 0xe1a7
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 0x25b42f(%rip), %r15    # 0x325310
leaq 0x25b430(%rip), %r12    # 0x325318
movsd -0x40(%rbp), %xmm6
movq %r14, %r9
movsd -0x48(%rbp), %xmm5
movq %rbx, %r8
leaq 0x25b3a5(%rip), %rax    # 0x3252a4
cvtsi2sdl (%rax), %xmm1
movsd 0x2915d(%rip), %xmm2    # 0xf3068
mulsd %xmm1, %xmm2
leaq 0x25b3d2(%rip), %rcx    # 0x3252e8
movl (%rcx), %eax
incl %eax
movl %eax, (%rcx)
addsd %xmm2, %xmm14
movsd 0x3e6bf(%rip), %xmm0    # 0x1085e8
mulsd %xmm0, %xmm14
divsd %xmm1, %xmm14
xorpd %xmm3, %xmm3
ucomisd %xmm3, %xmm14
leaq 0x25b34d(%rip), %rsi    # 0x325290
jb 0xca09a
ucomisd %xmm14, %xmm0
leaq 0x22d063(%rip), %rdi    # 0x2f6fb8
jbe 0xc9fa5
addsd %xmm2, %xmm4
mulsd %xmm0, %xmm4
divsd %xmm1, %xmm4
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm4
jb 0xc9fa5
ucomisd %xmm4, %xmm0
jbe 0xc9fa5
movl $0xe10, %ecx            # imm = 0xE10
xorl %edx, %edx
divl %ecx
pushq $0xc
popq %rcx
xorl %edx, %edx
divl %ecx
addb $0x3, %dl
cvttsd2si %xmm14, %eax
cltq
cvttsd2si %xmm4, %ecx
movslq %ecx, %rcx
imulq $0x281, %rax, %rax      # imm = 0x281
addq 0x6ffde(%rip), %rax     # 0x139f80
movb %dl, (%rcx,%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 0x22cfd9(%rip), %r13    # 0x2f6fc8
jmp 0xc9d46
movl $0x1, (%r13)
callq 0xe6741
leaq 0x25b2c4(%rip), %rax    # 0x3252cc
cmpl $0x0, (%rax)
jne 0xca014
xorl %edi, %edi
callq 0xe6975
leaq 0x138829(%rip), %rax    # 0x202844
movl $0x10e1, (%rax)         # imm = 0x10E1
movsd (%r15), %xmm9
movsd (%r12), %xmm10
leaq 0x22cfad(%rip), %r10    # 0x2f6fe0
movsd (%r10), %xmm11
leaq 0x22cf89(%rip), %r13    # 0x2f6fc8
movsd (%r13), %xmm12
leaq 0x25b244(%rip), %rax    # 0x325290
movsd (%rax), %xmm0
leaq 0x25b2e9(%rip), %rax    # 0x325340
movl $0x3, (%rax)
xorl %eax, %eax
movapd %xmm0, %xmm13
leaq 0x22cf65(%rip), %r8     # 0x2f6fd0
movsd -0x48(%rbp), %xmm5
leaq 0x22cf61(%rip), %r9     # 0x2f6fd8
movsd -0x40(%rbp), %xmm6
movsd -0x38(%rbp), %xmm7
leaq 0x25b298(%rip), %r11    # 0x325320
leaq 0x22cf29(%rip), %rdi    # 0x2f6fb8
movsd -0x30(%rbp), %xmm8
jmp 0xc9d46
leaq 0x22cf17(%rip), %rdi    # 0x2f6fb8
jmp 0xc9fa5