// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heather.cpp
// Function: get_stat_val(int)
DATA_SIZE get_stat_val(int id)
{
DATA_SIZE val;

   // get the plot statistic value to show for the plot

   if(stat_count == (DATA_SIZE) 0.0) return (DATA_SIZE) 0.0;

   if(plot[id].show_stat == RMS) {
      strcpy(stat_id, "rms");
      val = sqrt(plot[id].sum_yy/stat_count);
   }
   else if(plot[id].show_stat == AVG) {
      strcpy(stat_id, "avg");
      val = plot[id].sum_y/stat_count;
   }
   else if(plot[id].show_stat == SDEV) {
      strcpy(stat_id, "sdv");
      val = ((plot[id].sum_yy/stat_count) - ((plot[id].sum_y/stat_count)*(plot[id].sum_y/stat_count)) );
//    val = ( plot[id].sum_yy - ((plot[id].sum_y*plot[id].sum_y)/stat_count) ) / stat_count;
      if(val < (DATA_SIZE) 0.0) val = (DATA_SIZE) 0.0 - val;
      val = sqrt(val);
   }
   else if(plot[id].show_stat == VAR) {
      strcpy(stat_id, "var");
      val = ( (plot[id].sum_yy/stat_count) - ((plot[id].sum_y/stat_count)*(plot[id].sum_y/stat_count)) );
//    val = ( plot[id].sum_yy - ((plot[id].sum_y*plot[id].sum_y)/stat_count) ) / stat_count;
   }
   else if(plot[id].show_stat == SHOW_MIN) {
      strcpy(stat_id, "min");
      val = plot[id].min_disp_val;
   }
   else if(plot[id].show_stat == SHOW_MAX) {
      strcpy(stat_id, "max");
      val = plot[id].max_disp_val;
   }
   else if(plot[id].show_stat == SHOW_SPAN) {
      strcpy(stat_id, "span");
      val = plot[id].max_disp_val - plot[id].min_disp_val;
   }
   else {
      strcpy(stat_id, "???");
      val = (DATA_SIZE) 0.0;
   }

   if(plot[id].show_deriv) strcat(stat_id, "*");
   else if(plot[id].show_freq) strcat(stat_id, "#");
   else if(plot[id].drift_rate) strcat(stat_id, "=");
   else strcat(stat_id, ":");

   return val;
}

// Assembly:
movsd 0x2e3ea2(%rip), %xmm1   # 0x2f6f90
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x130fb
jp 0x130fb
retq
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x18, %rsp
movslq %edi, %rax
imulq $0xe8, %rax, %rax
leaq 0x134c1b(%rip), %rcx    # 0x147d30
leaq (%rcx,%rax), %rbx
movl 0xd4(%rax,%rcx), %eax
leal -0x1(%rax), %ecx
cmpl $0x7, %ecx
ja 0x13154
leaq 0xe02f5(%rip), %rax     # 0xf3424
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl $0x736d72, 0x3165fe(%rip) # imm = 0x736D72
movsd 0x78(%rbx), %xmm0
divsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
jmp 0x13227
cmpl $0x10, %eax
je 0x1324e
cmpl $0x20, %eax
je 0x1323a
cmpl $0x40, %eax
jne 0x13191
movb $0x0, 0x3165d2(%rip)    # 0x329744
movl $0x6e617073, 0x3165c4(%rip) # imm = 0x6E617073
movsd 0xb8(%rbx), %xmm0
subsd 0xb0(%rbx), %xmm0
jmp 0x13260
movl $0x3f3f3f, 0x3165a5(%rip) # imm = 0x3F3F3F
xorpd %xmm0, %xmm0
jmp 0x13260
movl $0x677661, 0x316592(%rip) # imm = 0x677661
movsd 0x68(%rbx), %xmm0
divsd %xmm1, %xmm0
jmp 0x13260
movl $0x726176, 0x31657a(%rip) # imm = 0x726176
movsd 0x68(%rbx), %xmm2
movsd 0x78(%rbx), %xmm0
divsd %xmm1, %xmm0
divsd %xmm1, %xmm2
mulsd %xmm2, %xmm2
subsd %xmm2, %xmm0
jmp 0x13260
movl $0x766473, 0x316554(%rip) # imm = 0x766473
movsd 0x68(%rbx), %xmm0
movsd 0x78(%rbx), %xmm2
divsd %xmm1, %xmm2
divsd %xmm1, %xmm0
mulsd %xmm0, %xmm0
subsd %xmm0, %xmm2
xorpd %xmm1, %xmm1
xorpd %xmm3, %xmm3
subsd %xmm2, %xmm3
movapd %xmm2, %xmm0
cmpltsd %xmm1, %xmm0
andpd %xmm0, %xmm3
andnpd %xmm2, %xmm0
orpd %xmm3, %xmm0
ucomisd %xmm1, %xmm0
jb 0x13233
sqrtsd %xmm0, %xmm0
jmp 0x13260
callq 0x9260
jmp 0x13260
movl $0x78616d, 0x3164fc(%rip) # imm = 0x78616D
movsd 0xb8(%rbx), %xmm0
jmp 0x13260
movl $0x6e696d, 0x3164e8(%rip) # imm = 0x6E696D
movsd 0xb0(%rbx), %xmm0
movsd %xmm0, -0x10(%rbp)
cmpl $0x0, 0xcc(%rbx)
je 0x13285
leaq 0x3164cb(%rip), %rbx    # 0x329740
movq %rbx, %rdi
callq 0x9120
movw $0x2a, (%rax,%rbx)
jmp 0x132e0
cmpl $0x0, 0xd0(%rbx)
je 0x132a5
leaq 0x3164ab(%rip), %rbx    # 0x329740
movq %rbx, %rdi
callq 0x9120
movw $0x23, (%rax,%rbx)
jmp 0x132e0
movsd 0xa0(%rbx), %xmm0
movsd %xmm0, -0x18(%rbp)
leaq 0x316487(%rip), %rbx    # 0x329740
movq %rbx, %rdi
callq 0x9120
xorpd %xmm0, %xmm0
movsd -0x18(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jne 0x132d2
jnp 0x132da
movw $0x3d, (%rax,%rbx)
jmp 0x132e0
movw $0x3a, (%rax,%rbx)
movsd -0x10(%rbp), %xmm0
addq $0x18, %rsp
popq %rbx
popq %rbp
retq