// File: 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
subq $0x1b0, %rsp            # imm = 0x1B0
movl %edi, -0x4(%rbp)
leaq 0x2108ab(%rip), %rax    # 0x36c1b0
movsd (%rax), %xmm0
movsd %xmm0, -0xc0(%rbp)
leaq 0x2108a0(%rip), %rax    # 0x36c1b8
movsd (%rax), %xmm0
movsd %xmm0, -0xc8(%rbp)
leaq 0x210895(%rip), %rax    # 0x36c1c0
movsd (%rax), %xmm0
movsd %xmm0, -0xd0(%rbp)
leaq 0x2108ea(%rip), %rax    # 0x36c228
movsd (%rax), %xmm0
movsd %xmm0, -0xd8(%rbp)
leaq 0x2108df(%rip), %rax    # 0x36c230
movsd (%rax), %xmm0
movsd %xmm0, -0xe0(%rbp)
leaq 0x2108d4(%rip), %rax    # 0x36c238
movsd (%rax), %xmm0
movsd %xmm0, -0xe8(%rbp)
movl $0xa, %edi
callq 0x12bcc0
movl $0x1, %edi
callq 0x159b10
movq $0x0, -0xf8(%rbp)
leaq 0x11eb7a(%rip), %rax    # 0x27a510
movq (%rax), %rax
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rax
leaq 0x11eb5a(%rip), %rcx    # 0x27a508
cmpq (%rcx), %rax
je 0x15bafb
movq -0xf0(%rbp), %rsi
leaq -0x1b0(%rbp), %rdi
callq 0x133f0
leaq -0xb8(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
movl $0xb0, %edx
callq 0x92c0
movsd 0x15ca6(%rip), %xmm0    # 0x171690
mulsd -0x88(%rbp), %xmm0
leaq 0x2107b7(%rip), %rax    # 0x36c1b0
movsd %xmm0, (%rax)
movsd 0x15c8b(%rip), %xmm0    # 0x171690
mulsd -0x80(%rbp), %xmm0
leaq 0x2107a7(%rip), %rax    # 0x36c1b8
movsd %xmm0, (%rax)
movsd -0x78(%rbp), %xmm0
leaq 0x21079f(%rip), %rax    # 0x36c1c0
movsd %xmm0, (%rax)
movsd -0x30(%rbp), %xmm0
leaq 0x2107f7(%rip), %rax    # 0x36c228
movsd %xmm0, (%rax)
movsd -0x28(%rbp), %xmm0
leaq 0x2107ef(%rip), %rax    # 0x36c230
movsd %xmm0, (%rax)
movsd -0x20(%rbp), %xmm0
leaq 0x2107e7(%rip), %rax    # 0x36c238
movsd %xmm0, (%rax)
leaq 0x23ea6c(%rip), %rax    # 0x39a4c8
movl (%rax), %eax
movl $0xe10, %ecx            # imm = 0xE10
cqto
idivq %rcx
movl %eax, -0xfc(%rbp)
movl -0xfc(%rbp), %eax
movl $0xc, %ecx
cltd
idivl %ecx
movl %edx, -0xfc(%rbp)
leaq 0x23ea23(%rip), %rax    # 0x39a4ac
movl $0x1, (%rax)
movl -0x4(%rbp), %edi
movl -0xfc(%rbp), %esi
addl $0x3, %esi
callq 0x12c200
leaq 0x23ea05(%rip), %rax    # 0x39a4ac
movl $0x0, (%rax)
movq -0xf0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xf0(%rbp)
leaq 0x11ea3a(%rip), %rcx    # 0x27a500
cmpq (%rcx), %rax
jl 0x15bad6
movq $0x0, -0xf0(%rbp)
movq -0xf8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xf8(%rbp)
leaq 0x11ea11(%rip), %rcx    # 0x27a500
cmpq (%rcx), %rax
jl 0x15baf6
jmp 0x15bafb
jmp 0x15b9a0
movsd -0xc0(%rbp), %xmm0
leaq 0x2106a6(%rip), %rax    # 0x36c1b0
movsd %xmm0, (%rax)
movsd -0xc8(%rbp), %xmm0
leaq 0x21069b(%rip), %rax    # 0x36c1b8
movsd %xmm0, (%rax)
movsd -0xd0(%rbp), %xmm0
leaq 0x210690(%rip), %rax    # 0x36c1c0
movsd %xmm0, (%rax)
movsd -0xd8(%rbp), %xmm0
leaq 0x2106e5(%rip), %rax    # 0x36c228
movsd %xmm0, (%rax)
movsd -0xe0(%rbp), %xmm0
leaq 0x2106da(%rip), %rax    # 0x36c230
movsd %xmm0, (%rax)
movsd -0xe8(%rbp), %xmm0
leaq 0x2106cf(%rip), %rax    # 0x36c238
movsd %xmm0, (%rax)
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
nopw %cs:(%rax,%rax)