// File: /workspace/github_cpp_makefile_star2_O2/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:
leaq 0x168639(%rip), %rax    # 0x228360
cmpq $0x0, (%rax)
je 0xc00df
leaq 0x1686dc(%rip), %rax    # 0x228414
cmpb $0x0, (%rax)
je 0xc00df
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
leaq 0x145644(%rip), %rbx    # 0x2053a0
movslq (%rbx), %r14
leaq 0x145502(%rip), %r15    # 0x205268
movslq (%r15), %r12
leaq 0x145500(%rip), %rax    # 0x205270
movslq (%rax), %r13
movq $0x1, (%rbx)
leaq 0x1455af(%rip), %rax    # 0x205330
movq (%rax), %rax
movq %rax, (%r15)
xorl %edi, %edi
callq 0x1846f
movq %r14, (%rbx)
movq %r12, (%r15)
leaq 0x1454d5(%rip), %rax    # 0x205270
movq %r13, (%rax)
leaq 0x167bbb(%rip), %rbx    # 0x227960
movw $0x23, (%rbx)
pushq $0x1
popq %r14
movl %r14d, %edi
callq 0xb25f5
movl %r14d, %edi
callq 0xb25f5
movl %r14d, %edi
callq 0xb25f5
movupd 0x5c0b0(%rip), %xmm0    # 0x11be7e
movapd %xmm0, (%rbx)
movl $0x3a7363, 0x10(%rbx)   # imm = 0x3A7363
movl %r14d, %edi
callq 0xb25f5
movl $0xd4, %r15d
addq 0x7a12a(%rip), %r15     # 0x139f18
leaq -0x140(%rbp), %r12
xorl %r13d, %r13d
cmpq $0x14, %r13
je 0xc00ba
movl $0x40, (%r15)
movl %r13d, %edi
callq 0x130e6
movapd %xmm0, %xmm1
movapd 0x33373(%rip), %xmm0    # 0xf3190
andpd %xmm0, %xmm1
movapd %xmm1, -0x40(%rbp)
movl $0x4, (%r15)
movl %r13d, %edi
callq 0x130e6
andpd 0x33353(%rip), %xmm0    # 0xf3190
addsd -0x40(%rbp), %xmm0
movapd %xmm0, -0x40(%rbp)
movl $0x1, (%r15)
movl %r13d, %edi
callq 0x130e6
andpd 0x33332(%rip), %xmm0    # 0xf3190
addsd -0x40(%rbp), %xmm0
ucomisd 0x332ad(%rip), %xmm0    # 0xf3118
jne 0xbfe73
jnp 0xc00ab
leaq 0x167ae6(%rip), %rbx    # 0x227960
movw $0x23, (%rbx)
movl %r14d, %edi
callq 0xb25f5
movq -0xd4(%r15), %rdx
movq %rbx, %rdi
leaq 0x5bffa(%rip), %rsi     # 0x11be92
xorl %eax, %eax
callq 0x9060
movl %r14d, %edi
callq 0xb25f5
movq -0xd4(%r15), %rsi
movq %r12, %rdi
callq 0x9330
movq %r12, %rdi
callq 0x988f
leaq 0x14551d(%rip), %rax    # 0x2053e2
cmpb $0x0, (%rax)
je 0xc0072
movl (%r15), %eax
movl %eax, -0x40(%rbp)
movq -0xcc(%r15), %rsi
movq %r12, %rdi
callq 0x9330
movq %r12, %rdi
movl %r14d, %esi
callq 0x9100
testq %rax, %rax
je 0xbfef6
movb $0x20, (%rax)
movl $0x1, (%r15)
movl %r13d, %edi
callq 0x130e6
leaq 0x167a54(%rip), %rdi    # 0x227960
leaq 0x5bf9b(%rip), %rsi     # 0x11beae
leaq 0x269826(%rip), %rdx    # 0x329740
leaq -0x140(%rbp), %r12
movq %r12, %rcx
movb $0x1, %al
callq 0x9060
pushq $0x1
popq %r14
movl %r14d, %edi
callq 0xb25f5
movl $0x2, (%r15)
movl %r13d, %edi
callq 0x130e6
leaq 0x167a13(%rip), %rbx    # 0x227960
movq %rbx, %rdi
leaq 0x5bf57(%rip), %rsi     # 0x11beae
leaq 0x2697e2(%rip), %rdx    # 0x329740
movq %r12, %rcx
movb $0x1, %al
callq 0x9060
movl %r14d, %edi
callq 0xb25f5
movl $0x4, (%r15)
movl %r13d, %edi
callq 0x130e6
movq %rbx, %rdi
leaq 0x5bf25(%rip), %rsi     # 0x11beae
leaq 0x2697b0(%rip), %rdx    # 0x329740
movq %r12, %rcx
movb $0x1, %al
callq 0x9060
movl %r14d, %edi
callq 0xb25f5
movl $0x8, (%r15)
movl %r13d, %edi
callq 0x130e6
movq %rbx, %rdi
leaq 0x5bef3(%rip), %rsi     # 0x11beae
leaq 0x26977e(%rip), %rdx    # 0x329740
movq %r12, %rcx
movb $0x1, %al
callq 0x9060
movl %r14d, %edi
callq 0xb25f5
movl $0x10, (%r15)
movl %r13d, %edi
callq 0x130e6
movq %rbx, %rdi
leaq 0x5bec1(%rip), %rsi     # 0x11beae
leaq 0x26974c(%rip), %rdx    # 0x329740
movq %r12, %rcx
movb $0x1, %al
callq 0x9060
movl %r14d, %edi
callq 0xb25f5
movl $0x20, (%r15)
movl %r13d, %edi
callq 0x130e6
movq %rbx, %rdi
leaq 0x5be8f(%rip), %rsi     # 0x11beae
leaq 0x26971a(%rip), %rdx    # 0x329740
movq %r12, %rcx
movb $0x1, %al
callq 0x9060
movl %r14d, %edi
callq 0xb25f5
movl $0x40, (%r15)
movl %r13d, %edi
callq 0x130e6
movq %rbx, %rdi
leaq 0x5be5d(%rip), %rsi     # 0x11beae
leaq 0x2696e8(%rip), %rdx    # 0x329740
movq %r12, %rcx
movb $0x1, %al
callq 0x9060
movl %r14d, %edi
callq 0xb25f5
movl -0x40(%rbp), %eax
movl %eax, (%r15)
jmp 0xc00ab
movl -0x140(%rbp), %eax
cmpl $0x54414c, %eax         # imm = 0x54414C
je 0xc008a
cmpl $0x4e4f4c, %eax         # imm = 0x4E4F4C
jne 0xbfece
movupd 0x5be0a(%rip), %xmm0    # 0x11be9c
leaq 0x1678c7(%rip), %rax    # 0x227960
movapd %xmm0, (%rax)
movw $0x29, 0x10(%rax)
movl %r14d, %edi
callq 0xb25f5
incq %r13
addq $0xe8, %r15
jmp 0xbfdf8
leaq 0x16789f(%rip), %rax    # 0x227960
movw $0x23, (%rax)
pushq $0x1
popq %rdi
callq 0xb25f5
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq