// File: jkingan[P]ladyheather/heathmsc.cpp
// Function: log_stats()
void log_stats()
{
int old_stat;
DATA_SIZE val;
int id;
char units[SLEN+1];
char *s;
int old_interval;
int old_col0;
int old_last_col;

   // write plot queue statistics (of the plot window when the log file was
   // closed) when the log file is closed

   if(log_file == 0) return;
   if(log_comments == 0) return;

if(1) {
   old_interval = view_interval;   // don't downsample the queue data
   old_col0 = plot_q_col0;
   old_last_col = plot_q_last_col;

   view_interval = 1;
   plot_q_col0 = plot_q_out;
   calc_queue_stats(STOP_AT_Q_END);

   view_interval = old_interval;
   plot_q_col0 = old_col0;
   plot_q_last_col = old_last_col;
}

   sprintf(log_text, "#");
   write_log_comment(1);
   write_log_comment(1);
   write_log_comment(1);
   sprintf(log_text,    "#  Plot statistics:");
   write_log_comment(1);

   for(id=0; id<=FIFTEEN; id++) {
      plot[id].show_stat = SHOW_SPAN;
      val = (DATA_SIZE) fabs(get_stat_val(id));
      plot[id].show_stat = SDEV;
      val += (DATA_SIZE) fabs(get_stat_val(id));
      plot[id].show_stat = RMS;
      val += (DATA_SIZE) fabs(get_stat_val(id));
      if(val == 0.0) continue;    // plot has no data

      sprintf(log_text, "#");
      write_log_comment(1);
      sprintf(log_text, "#     %s:", plot[id].plot_id);
      write_log_comment(1);
      strcpy(units, plot[id].plot_id);
      strupr(units);
      if((plot_loc == 0) && (!strcmp(units, "LAT") || !strcmp(units, "LON"))) {
         sprintf(log_text, "#       (private)");
         write_log_comment(1);
         continue;
      }
      
      old_stat = plot[id].show_stat;
      strcpy(units, plot[id].units);
      s = strchr(units, DEGREES);
      if(s) *s = ' ';

      plot[id].show_stat = RMS;
      val = get_stat_val(id);
      sprintf(log_text, "#       %s %.9f %s", stat_id, val, units);
      write_log_comment(1);

      plot[id].show_stat = AVG;
      val = get_stat_val(id);
      sprintf(log_text, "#       %s %.9f %s", stat_id, val, units);
      write_log_comment(1);

      plot[id].show_stat = SDEV;
      val = get_stat_val(id);
      sprintf(log_text, "#       %s %.9f %s", stat_id, val, units);
      write_log_comment(1);

      plot[id].show_stat = VAR;
      val = get_stat_val(id);
      sprintf(log_text, "#       %s %.9f %s", stat_id, val, units);
      write_log_comment(1);

      plot[id].show_stat = SHOW_MIN;
      val = get_stat_val(id);
      sprintf(log_text, "#       %s %.9f %s", stat_id, val, units);
      write_log_comment(1);

      plot[id].show_stat = SHOW_MAX;
      val = get_stat_val(id);
      sprintf(log_text, "#       %s %.9f %s", stat_id, val, units);
      write_log_comment(1);

      plot[id].show_stat = SHOW_SPAN;
      val = get_stat_val(id);
      sprintf(log_text, "#       %s %.9f %s", stat_id, val, units);
      write_log_comment(1);

      plot[id].show_stat = old_stat;
   }

   sprintf(log_text, "#");
   write_log_comment(1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
leaq 0x17f47e(%rip), %rax    # 0x29d540
cmpq $0x0, (%rax)
jne 0x11e0cd
jmp 0x11e6c9
leaq 0x17f520(%rip), %rax    # 0x29d5f4
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x11e0e1
jmp 0x11e6c9
leaq 0x15c498(%rip), %rax    # 0x27a580
movq (%rax), %rax
movl %eax, -0x11c(%rbp)
leaq 0x15c350(%rip), %rax    # 0x27a448
movq (%rax), %rax
movl %eax, -0x120(%rbp)
leaq 0x15c348(%rip), %rax    # 0x27a450
movq (%rax), %rax
movl %eax, -0x124(%rbp)
leaq 0x15c468(%rip), %rax    # 0x27a580
movq $0x1, (%rax)
leaq 0x15c3ea(%rip), %rax    # 0x27a510
movq (%rax), %rcx
leaq 0x15c318(%rip), %rax    # 0x27a448
movq %rcx, (%rax)
xorl %edi, %edi
callq 0x23e80
movslq -0x11c(%rbp), %rcx
leaq 0x15c438(%rip), %rax    # 0x27a580
movq %rcx, (%rax)
movslq -0x120(%rbp), %rcx
leaq 0x15c2ef(%rip), %rax    # 0x27a448
movq %rcx, (%rax)
movslq -0x124(%rbp), %rcx
leaq 0x15c2e6(%rip), %rax    # 0x27a450
movq %rcx, (%rax)
leaq 0x17e9cc(%rip), %rdi    # 0x29cb40
leaq 0x53c21(%rip), %rsi     # 0x171d9c
movb $0x0, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
movl $0x1, %edi
callq 0x10cbe0
movl $0x1, %edi
callq 0x10cbe0
leaq 0x17e999(%rip), %rdi    # 0x29cb40
leaq 0x768ac(%rip), %rsi     # 0x194a5a
movb $0x0, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
movl $0x0, -0x14(%rbp)
cmpl $0x13, -0x14(%rbp)
jg 0x11e6aa
movslq -0x14(%rbp), %rcx
leaq 0x9eb45(%rip), %rax     # 0x1bcd20
imulq $0xe8, %rcx, %rcx
addq %rcx, %rax
movl $0x40, 0xd4(%rax)
movl -0x14(%rbp), %edi
callq 0x19040
movaps 0x51092(%rip), %xmm1    # 0x16f290
pand %xmm1, %xmm0
movsd %xmm0, -0x10(%rbp)
movslq -0x14(%rbp), %rcx
leaq 0x9eb0e(%rip), %rax     # 0x1bcd20
imulq $0xe8, %rcx, %rcx
addq %rcx, %rax
movl $0x4, 0xd4(%rax)
movl -0x14(%rbp), %edi
callq 0x19040
movaps 0x5105b(%rip), %xmm1    # 0x16f290
pand %xmm1, %xmm0
addsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x10(%rbp)
movslq -0x14(%rbp), %rcx
leaq 0x9ead2(%rip), %rax     # 0x1bcd20
imulq $0xe8, %rcx, %rcx
addq %rcx, %rax
movl $0x1, 0xd4(%rax)
movl -0x14(%rbp), %edi
callq 0x19040
movaps 0x5101f(%rip), %xmm1    # 0x16f290
pand %xmm1, %xmm0
addsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x11e294
jp 0x11e294
jmp 0x11e69c
leaq 0x17e8a5(%rip), %rdi    # 0x29cb40
leaq 0x53afa(%rip), %rsi     # 0x171d9c
movb $0x0, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
movslq -0x14(%rbp), %rcx
leaq 0x9ea62(%rip), %rax     # 0x1bcd20
imulq $0xe8, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdx
leaq 0x17e86e(%rip), %rdi    # 0x29cb40
leaq 0x76795(%rip), %rsi     # 0x194a6e
movb $0x0, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
leaq -0x110(%rbp), %rdi
movslq -0x14(%rbp), %rcx
leaq 0x9ea24(%rip), %rax     # 0x1bcd20
imulq $0xe8, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x9350
leaq -0x110(%rbp), %rdi
callq 0x9890
leaq 0x15c2a1(%rip), %rax    # 0x27a5c2
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x11e37d
leaq -0x110(%rbp), %rdi
leaq 0x76741(%rip), %rsi     # 0x194a78
callq 0x9510
cmpl $0x0, %eax
je 0x11e359
leaq -0x110(%rbp), %rdi
leaq 0x7672d(%rip), %rsi     # 0x194a7c
callq 0x9510
cmpl $0x0, %eax
jne 0x11e37d
leaq 0x17e7e0(%rip), %rdi    # 0x29cb40
leaq 0x76719(%rip), %rsi     # 0x194a80
movb $0x0, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
jmp 0x11e69c
movslq -0x14(%rbp), %rcx
leaq 0x9e998(%rip), %rax     # 0x1bcd20
imulq $0xe8, %rcx, %rcx
addq %rcx, %rax
movl 0xd4(%rax), %eax
movl %eax, -0x4(%rbp)
leaq -0x110(%rbp), %rdi
movslq -0x14(%rbp), %rcx
leaq 0x9e973(%rip), %rax     # 0x1bcd20
imulq $0xe8, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x9350
leaq -0x110(%rbp), %rdi
movl $0x1, %esi
callq 0x9100
movq %rax, -0x118(%rbp)
cmpq $0x0, -0x118(%rbp)
je 0x11e3ec
movq -0x118(%rbp), %rax
movb $0x20, (%rax)
movslq -0x14(%rbp), %rcx
leaq 0x9e929(%rip), %rax     # 0x1bcd20
imulq $0xe8, %rcx, %rcx
addq %rcx, %rax
movl $0x1, 0xd4(%rax)
movl -0x14(%rbp), %edi
callq 0x19040
movsd %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
leaq -0x110(%rbp), %rcx
leaq 0x17e715(%rip), %rdi    # 0x29cb40
leaq 0x76660(%rip), %rsi     # 0x194a92
leaq 0x2804e7(%rip), %rdx    # 0x39e920
movb $0x1, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
movslq -0x14(%rbp), %rcx
leaq 0x9e8cb(%rip), %rax     # 0x1bcd20
imulq $0xe8, %rcx, %rcx
addq %rcx, %rax
movl $0x2, 0xd4(%rax)
movl -0x14(%rbp), %edi
callq 0x19040
movsd %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
leaq -0x110(%rbp), %rcx
leaq 0x17e6b7(%rip), %rdi    # 0x29cb40
leaq 0x76602(%rip), %rsi     # 0x194a92
leaq 0x280489(%rip), %rdx    # 0x39e920
movb $0x1, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
movslq -0x14(%rbp), %rcx
leaq 0x9e86d(%rip), %rax     # 0x1bcd20
imulq $0xe8, %rcx, %rcx
addq %rcx, %rax
movl $0x4, 0xd4(%rax)
movl -0x14(%rbp), %edi
callq 0x19040
movsd %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
leaq -0x110(%rbp), %rcx
leaq 0x17e659(%rip), %rdi    # 0x29cb40
leaq 0x765a4(%rip), %rsi     # 0x194a92
leaq 0x28042b(%rip), %rdx    # 0x39e920
movb $0x1, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
movslq -0x14(%rbp), %rcx
leaq 0x9e80f(%rip), %rax     # 0x1bcd20
imulq $0xe8, %rcx, %rcx
addq %rcx, %rax
movl $0x8, 0xd4(%rax)
movl -0x14(%rbp), %edi
callq 0x19040
movsd %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
leaq -0x110(%rbp), %rcx
leaq 0x17e5fb(%rip), %rdi    # 0x29cb40
leaq 0x76546(%rip), %rsi     # 0x194a92
leaq 0x2803cd(%rip), %rdx    # 0x39e920
movb $0x1, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
movslq -0x14(%rbp), %rcx
leaq 0x9e7b1(%rip), %rax     # 0x1bcd20
imulq $0xe8, %rcx, %rcx
addq %rcx, %rax
movl $0x10, 0xd4(%rax)
movl -0x14(%rbp), %edi
callq 0x19040
movsd %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
leaq -0x110(%rbp), %rcx
leaq 0x17e59d(%rip), %rdi    # 0x29cb40
leaq 0x764e8(%rip), %rsi     # 0x194a92
leaq 0x28036f(%rip), %rdx    # 0x39e920
movb $0x1, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
movslq -0x14(%rbp), %rcx
leaq 0x9e753(%rip), %rax     # 0x1bcd20
imulq $0xe8, %rcx, %rcx
addq %rcx, %rax
movl $0x20, 0xd4(%rax)
movl -0x14(%rbp), %edi
callq 0x19040
movsd %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
leaq -0x110(%rbp), %rcx
leaq 0x17e53f(%rip), %rdi    # 0x29cb40
leaq 0x7648a(%rip), %rsi     # 0x194a92
leaq 0x280311(%rip), %rdx    # 0x39e920
movb $0x1, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
movslq -0x14(%rbp), %rcx
leaq 0x9e6f5(%rip), %rax     # 0x1bcd20
imulq $0xe8, %rcx, %rcx
addq %rcx, %rax
movl $0x40, 0xd4(%rax)
movl -0x14(%rbp), %edi
callq 0x19040
movsd %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
leaq -0x110(%rbp), %rcx
leaq 0x17e4e1(%rip), %rdi    # 0x29cb40
leaq 0x7642c(%rip), %rsi     # 0x194a92
leaq 0x2802b3(%rip), %rdx    # 0x39e920
movb $0x1, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
movl -0x4(%rbp), %ecx
movslq -0x14(%rbp), %rdx
leaq 0x9e694(%rip), %rax     # 0x1bcd20
imulq $0xe8, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0xd4(%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x11e1c6
leaq 0x17e48f(%rip), %rdi    # 0x29cb40
leaq 0x536e4(%rip), %rsi     # 0x171d9c
movb $0x0, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nopw %cs:(%rax,%rax)