// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathmsc.cpp
// Function: rebuild_lla_plot(int)
void rebuild_lla_plot(int draw)
{
struct PLOT_Q q;
double old_lat, old_lon, old_alt;
double old_lat_tide, old_lon_tide, old_alt_tide;
long i;
long count;
int color;

   // rebuild the LLA scattergram image from the plot queue data

   old_lat = lat;
   old_lon = lon;
   old_alt = alt;
   old_lat_tide = lat_tide;
   old_lon_tide = lon_tide;
   old_alt_tide = alt_tide;

   plot_lla_axes(10);    // erase the old scattergram
   #ifdef BUFFER_LLA
      clear_lla_points(1);
   #endif
   count = 0;

   i = plot_q_out;   // dumping the full queue
   while(i != plot_q_in) {  // rebuilt the scattergram from plot queue lat/lon data
      q = get_plot_q(i);

      lat = (double) q.data[ONE] * DEG_TO_RAD;
      lon = (double) q.data[TWO] * DEG_TO_RAD;
      alt = (double) q.data[THREE];

      lat_tide = (double) q.data[ELEVEN];
      lon_tide = (double) q.data[TWELVE];
      alt_tide = (double) q.data[THIRTEEN];
 
      color = lla_points / (60L*60L);
      color %= 12;
      in_rebuild_lla = 1;   // prevent recursion with plot_lla_point()
      plot_lla_point(draw, color+3); 
      in_rebuild_lla = 0;

      if(0 && (count == 0)) {  // !!!! this does not work = draw X at start of scattergram data
         dot(lla_xi+1,lla_yi+1, color+3);
         dot(lla_xi+2,lla_yi+2, color+3);
         dot(lla_xi+1,lla_yi-1, color+3);
         dot(lla_xi+2,lla_yi-2, color+3);
         dot(lla_xi-1,lla_yi+1, color+3);
         dot(lla_xi-2,lla_yi+2, color+3);
         dot(lla_xi-1,lla_yi-1, color+3);
         dot(lla_xi-2,lla_yi-2, color+3);
      }

      if(++i >= plot_q_size) i = 0;
      if(++count >= plot_q_size) break;
   }

   lat = old_lat;
   lon = old_lon;
   alt = old_alt;
   lat_tide = old_lat_tide;
   lon_tide = old_lon_tide;
   alt_tide = old_alt_tide;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movl %edi, %ebx
leaq 0x210aeb(%rip), %rax    # 0x30cfd0
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
leaq 0x210ae3(%rip), %rax    # 0x30cfd8
movsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
leaq 0x210adb(%rip), %rax    # 0x30cfe0
movsd (%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
leaq 0x210b33(%rip), %rax    # 0x30d048
movsd (%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
leaq 0x210b2b(%rip), %rax    # 0x30d050
movsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
leaq 0x210b23(%rip), %rax    # 0x30d058
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
callq 0xdb2e0
movl $0x1, %edi
callq 0xfae0d
leaq 0x11eddc(%rip), %rax    # 0x21b330
movq (%rax), %r14
leaq 0x23ed6e(%rip), %r13    # 0x33b2cc
leaq 0x11edbb(%rip), %r12    # 0x21b320
xorl %r15d, %r15d
leaq 0x11edb9(%rip), %rax    # 0x21b328
cmpq (%rax), %r14
je 0xfc662
leaq -0x108(%rbp), %rdi
movq %r14, %rsi
callq 0x100be
movsd -0xc8(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
movsd -0x78(%rbp), %xmm2
movsd -0x70(%rbp), %xmm3
movsd -0xd8(%rbp), %xmm4
movsd 0xf362(%rip), %xmm6     # 0x10b910
mulsd %xmm6, %xmm4
movsd -0xd0(%rbp), %xmm5
mulsd %xmm6, %xmm5
leaq 0x210a0b(%rip), %rax    # 0x30cfd0
movsd %xmm4, (%rax)
leaq 0x210a08(%rip), %rax    # 0x30cfd8
movsd %xmm5, (%rax)
leaq 0x210a05(%rip), %rax    # 0x30cfe0
movsd %xmm0, (%rax)
leaq 0x210a62(%rip), %rax    # 0x30d048
movsd %xmm1, (%rax)
leaq 0x210a5f(%rip), %rax    # 0x30d050
movsd %xmm2, (%rax)
leaq 0x210a5c(%rip), %rax    # 0x30d058
movsd %xmm3, (%rax)
leaq 0x23ece1(%rip), %rax    # 0x33b2e8
movl (%rax), %esi
movl $0x91a2b3c5, %eax       # imm = 0x91A2B3C5
imulq %rax, %rsi
shrq $0x2b, %rsi
imulq $0x15555556, %rsi, %rax # imm = 0x15555556
shrq $0x20, %rax
shll $0x2, %eax
leal (%rax,%rax,2), %eax
subl %eax, %esi
movl $0x1, (%r13)
addl $0x3, %esi
movl %ebx, %edi
callq 0xdb67a
movl $0x0, (%r13)
incq %r14
movq (%r12), %rax
cmpq %rax, %r14
movl $0x0, %ecx
cmovgeq %rcx, %r14
incq %r15
cmpq %rax, %r15
jl 0xfc568
leaq 0x210967(%rip), %rax    # 0x30cfd0
movsd -0x58(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq 0x21095f(%rip), %rax    # 0x30cfd8
movsd -0x50(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq 0x210957(%rip), %rax    # 0x30cfe0
movsd -0x48(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq 0x2109af(%rip), %rax    # 0x30d048
movsd -0x40(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq 0x2109a7(%rip), %rax    # 0x30d050
movsd -0x38(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq 0x21099f(%rip), %rax    # 0x30d058
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rax)
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq