// File: /workspace/github_cpp_makefile_star2_O3/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 0x2f95e0(%rip), %xmm1   # 0x30cf90
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x139bd
jp 0x139bd
retq
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x18, %rsp
movslq %edi, %rax
imulq $0xe8, %rax, %rax
leaq 0x14a359(%rip), %rcx    # 0x15dd30
leaq (%rcx,%rax), %rbx
movl 0xd4(%rax,%rcx), %eax
cmpl $0xf, %eax
jg 0x13a1e
decl %eax
cmpl $0x7, %eax
ja 0x13b1a
leaq 0xf5a2b(%rip), %rcx     # 0x109424
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x736d72, 0x32bd34(%rip) # imm = 0x736D72
movsd 0x78(%rbx), %xmm0
divsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
jmp 0x13aa4
cmpl $0x10, %eax
je 0x13af2
cmpl $0x20, %eax
je 0x13b06
cmpl $0x40, %eax
jne 0x13b1a
movb $0x0, 0x32bd04(%rip)    # 0x33f744
movl $0x6e617073, 0x32bcf6(%rip) # imm = 0x6E617073
movsd 0xb8(%rbx), %xmm0
subsd 0xb0(%rbx), %xmm0
jmp 0x13b28
movl $0x766473, 0x32bcd7(%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 0x13ab0
sqrtsd %xmm0, %xmm0
jmp 0x13b28
callq 0x9270
jmp 0x13b28
movl $0x726176, 0x32bc7f(%rip) # imm = 0x726176
movsd 0x68(%rbx), %xmm2
movsd 0x78(%rbx), %xmm0
divsd %xmm1, %xmm0
divsd %xmm1, %xmm2
mulsd %xmm2, %xmm2
subsd %xmm2, %xmm0
jmp 0x13b28
movl $0x677661, 0x32bc59(%rip) # imm = 0x677661
movsd 0x68(%rbx), %xmm0
divsd %xmm1, %xmm0
jmp 0x13b28
movl $0x6e696d, 0x32bc44(%rip) # imm = 0x6E696D
movsd 0xb0(%rbx), %xmm0
jmp 0x13b28
movl $0x78616d, 0x32bc30(%rip) # imm = 0x78616D
movsd 0xb8(%rbx), %xmm0
jmp 0x13b28
movl $0x3f3f3f, 0x32bc1c(%rip) # imm = 0x3F3F3F
xorpd %xmm0, %xmm0
movsd %xmm0, -0x10(%rbp)
cmpl $0x0, 0xcc(%rbx)
je 0x13b4d
leaq 0x32bc03(%rip), %rbx    # 0x33f740
movq %rbx, %rdi
callq 0x9120
movw $0x2a, (%rax,%rbx)
jmp 0x13ba8
cmpl $0x0, 0xd0(%rbx)
je 0x13b6d
leaq 0x32bbe3(%rip), %rbx    # 0x33f740
movq %rbx, %rdi
callq 0x9120
movw $0x23, (%rax,%rbx)
jmp 0x13ba8
movsd 0xa0(%rbx), %xmm0
movsd %xmm0, -0x18(%rbp)
leaq 0x32bbbf(%rip), %rbx    # 0x33f740
movq %rbx, %rdi
callq 0x9120
xorpd %xmm0, %xmm0
movsd -0x18(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jne 0x13b9a
jnp 0x13ba2
movw $0x3d, (%rax,%rbx)
jmp 0x13ba8
movw $0x3a, (%rax,%rbx)
movsd -0x10(%rbp), %xmm0
addq $0x18, %rsp
popq %rbx
popq %rbp
retq