// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heather.cpp
// Function: add_stat_point(PLOT_Q*)
void add_stat_point(struct PLOT_Q *q)
{
int k;
DATA_SIZE val;
DATA_SIZE x;

   // calculate statistics of the points in the plot window
   if(queue_interval <= 0) return;

   x = (stat_count * view_interval * queue_interval);
   for(k=0; k<NUM_PLOTS+DERIVED_PLOTS; k++) {
      if(k >= NUM_PLOTS) {   // derived data DERIVED_PLOTS !!!!
         if(luxor && (k == BATTW)) {        // battery watts
            val = q->data[BATTI]*q->data[BATTV] / (DATA_SIZE) queue_interval;
         }
         else if(luxor && (k == LEDW)) {   // LED watts
            val = q->data[LEDI]*q->data[LEDV] / (DATA_SIZE) queue_interval;
         }
         else if(luxor && (k == EFF)) { // driver efficency
            val = q->data[BATTI]*q->data[BATTV];
            if(val) val = q->data[LEDI]*q->data[LEDV] / val;
            val *= (DATA_SIZE) 100.0;
         }
         else if(luxor && (k == CCT)) { // color temo  // !!!!!!! wrong! need raw data here
            val = (DATA_SIZE) calc_cct(cct_type, 1, (double)q->data[REDHZ]/(double)queue_interval, (double)q->data[GREENHZ]/(double)queue_interval, (double)q->data[BLUEHZ]/(double)queue_interval);
         }
         else {
//          val = (DATA_SIZE) 0.0;
            val = q->data[k] / queue_interval;
            plot[k].sum_change += (val - (last_q.data[k]/queue_interval));
         }
         // !!!!! sum_change
      }
      else {
         val = q->data[k] / queue_interval;
         plot[k].sum_change += (val - (last_q.data[k]/queue_interval));
      }

      plot[k].sum_y  += val;
      plot[k].sum_yy += (val * val);
      plot[k].sum_xy += (x * val);
      plot[k].sum_xx += (x * x);
      plot[k].sum_x  += x;
      plot[k].stat_count += 1.0F;
   }

   ++stat_count;
}

// Assembly:
movq 0x202677(%rip), %rax    # 0x21b398
testq %rax, %rax
jle 0x18f41
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
cvtsi2sdq 0x20265b(%rip), %xmm0 # 0x21b3a0
mulsd 0x2f4243(%rip), %xmm0   # 0x30cf90
cvtsi2sd %rax, %xmm3
mulsd %xmm0, %xmm3
leaq 0x14507b(%rip), %r14    # 0x15ddd8
xorl %r15d, %r15d
xorpd %xmm4, %xmm4
movsd 0xf02f4(%rip), %xmm5    # 0x109060
leaq 0x3277f5(%rip), %r12    # 0x340568
movapd %xmm3, %xmm6
mulsd %xmm3, %xmm6
movsd 0xf02ed(%rip), %xmm7    # 0x109070
movsd %xmm3, -0x30(%rbp)
movsd %xmm6, -0x28(%rbp)
cmpq $0x10, %r15
jb 0x18e71
movb 0x2261a1(%rip), %al     # 0x23ef3e
testb %al, %al
sete %cl
cmpq $0x10, %r15
setne %dl
orb %cl, %dl
jne 0x18dcc
movsd 0x40(%rbx), %xmm0
mulsd 0x38(%rbx), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdq 0x2025d5(%rip), %xmm1 # 0x21b398
divsd %xmm1, %xmm0
jmp 0x18ea5
testb %al, %al
sete %cl
cmpq $0x11, %r15
setne %dl
orb %cl, %dl
jne 0x18e09
movsd 0x18(%rbx), %xmm0
mulsd 0x20(%rbx), %xmm0
ucomisd %xmm4, %xmm0
jne 0x18dee
jnp 0x18e00
movsd 0x40(%rbx), %xmm1
mulsd 0x38(%rbx), %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
mulsd %xmm5, %xmm0
jmp 0x18ea5
testb %al, %al
sete %al
cmpq $0x12, %r15
setne %cl
orb %al, %cl
jne 0x18e71
movzbl 0x2f4148(%rip), %edi    # 0x30cf68
movsd 0x68(%rbx), %xmm0
xorps %xmm3, %xmm3
cvtsi2sdq 0x202567(%rip), %xmm3 # 0x21b398
divsd %xmm3, %xmm0
movsd 0x58(%rbx), %xmm2
movsd 0x60(%rbx), %xmm1
divsd %xmm3, %xmm1
divsd %xmm3, %xmm2
movl $0x1, %esi
callq 0x7aa82
movsd 0xf0217(%rip), %xmm7    # 0x109070
movsd -0x28(%rbp), %xmm6
movsd 0xf01fa(%rip), %xmm5    # 0x109060
xorpd %xmm4, %xmm4
movsd -0x30(%rbp), %xmm3
jmp 0x18ea5
movsd 0x10(%rbx,%r15,8), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdq 0x202514(%rip), %xmm1 # 0x21b398
divsd %xmm1, %xmm0
movsd 0x10(%r12,%r15,8), %xmm2
divsd %xmm1, %xmm2
movapd %xmm0, %xmm1
subsd %xmm2, %xmm1
addsd (%r14), %xmm1
movsd %xmm1, (%r14)
movsd -0x40(%r14), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0x40(%r14)
movapd %xmm3, %xmm1
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm0
addsd -0x30(%r14), %xmm0
movsd %xmm0, -0x30(%r14)
addsd -0x28(%r14), %xmm1
movsd %xmm1, -0x28(%r14)
movsd -0x38(%r14), %xmm0
addsd %xmm6, %xmm0
movsd %xmm0, -0x38(%r14)
movsd -0x48(%r14), %xmm0
addsd %xmm3, %xmm0
movsd %xmm0, -0x48(%r14)
movsd -0x20(%r14), %xmm0
addsd %xmm7, %xmm0
movsd %xmm0, -0x20(%r14)
incq %r15
addq $0xe8, %r14
cmpq $0x14, %r15
jne 0x18d8d
movsd 0x2f406b(%rip), %xmm0   # 0x30cf90
addsd 0xf0143(%rip), %xmm0    # 0x109070
movsd %xmm0, 0x2f405b(%rip)   # 0x30cf90
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq