// File: /workspace/github_cpp_makefile_star2_O1/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 0x2f9551(%rip), %xmm1   # 0x30cf90
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x13a4c
jp 0x13a4c
retq
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x18, %rsp
movslq %edi, %rax
imulq $0xe8, %rax, %rax
leaq 0x14a2ca(%rip), %rcx    # 0x15dd30
leaq (%rcx,%rax), %rbx
movl 0xd4(%rax,%rcx), %eax
cmpl $0xf, %eax
jg 0x13aad
decl %eax
cmpl $0x7, %eax
ja 0x13ba9
leaq 0xf598c(%rip), %rcx     # 0x109414
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x736d72, 0x32bca5(%rip) # imm = 0x736D72
movsd 0x78(%rbx), %xmm0
divsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
jmp 0x13b33
cmpl $0x10, %eax
je 0x13b81
cmpl $0x20, %eax
je 0x13b95
cmpl $0x40, %eax
jne 0x13ba9
movb $0x0, 0x32bc75(%rip)    # 0x33f744
movl $0x6e617073, 0x32bc67(%rip) # imm = 0x6E617073
movsd 0xb8(%rbx), %xmm0
subsd 0xb0(%rbx), %xmm0
jmp 0x13bb7
movl $0x766473, 0x32bc48(%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 0x13b3f
sqrtsd %xmm0, %xmm0
jmp 0x13bb7
callq 0x9270
jmp 0x13bb7
movl $0x726176, 0x32bbf0(%rip) # imm = 0x726176
movsd 0x68(%rbx), %xmm2
movsd 0x78(%rbx), %xmm0
divsd %xmm1, %xmm0
divsd %xmm1, %xmm2
mulsd %xmm2, %xmm2
subsd %xmm2, %xmm0
jmp 0x13bb7
movl $0x677661, 0x32bbca(%rip) # imm = 0x677661
movsd 0x68(%rbx), %xmm0
divsd %xmm1, %xmm0
jmp 0x13bb7
movl $0x6e696d, 0x32bbb5(%rip) # imm = 0x6E696D
movsd 0xb0(%rbx), %xmm0
jmp 0x13bb7
movl $0x78616d, 0x32bba1(%rip) # imm = 0x78616D
movsd 0xb8(%rbx), %xmm0
jmp 0x13bb7
movl $0x3f3f3f, 0x32bb8d(%rip) # imm = 0x3F3F3F
xorpd %xmm0, %xmm0
movsd %xmm0, -0x10(%rbp)
cmpl $0x0, 0xcc(%rbx)
je 0x13bdc
leaq 0x32bb74(%rip), %rbx    # 0x33f740
movq %rbx, %rdi
callq 0x9120
movw $0x2a, (%rax,%rbx)
jmp 0x13c37
cmpl $0x0, 0xd0(%rbx)
je 0x13bfc
leaq 0x32bb54(%rip), %rbx    # 0x33f740
movq %rbx, %rdi
callq 0x9120
movw $0x23, (%rax,%rbx)
jmp 0x13c37
movsd 0xa0(%rbx), %xmm0
movsd %xmm0, -0x18(%rbp)
leaq 0x32bb30(%rip), %rbx    # 0x33f740
movq %rbx, %rdi
callq 0x9120
xorpd %xmm0, %xmm0
movsd -0x18(%rbp), %xmm1
ucomisd %xmm0, %xmm1
jne 0x13c29
jnp 0x13c31
movw $0x3d, (%rax,%rbx)
jmp 0x13c37
movw $0x3a, (%rax,%rbx)
movsd -0x10(%rbp), %xmm0
addq $0x18, %rsp
popq %rbx
popq %rbp
retq