// File: /workspace/github_cpp_makefile_star2_O2/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 0x1ed14c(%rip), %rax    # 0x205398
testq %rax, %rax
jle 0x1846e
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
cvtsi2sdq 0x1ed12e(%rip), %xmm0 # 0x2053a0
mulsd 0x2ded16(%rip), %xmm0   # 0x2f6f90
cvtsi2sd %rax, %xmm3
mulsd %xmm0, %xmm3
leaq 0x12fb4e(%rip), %r15    # 0x147dd8
xorl %r12d, %r12d
xorpd %xmm4, %xmm4
movsd 0xdadc7(%rip), %xmm5    # 0xf3060
pushq $0x1
popq %r14
leaq 0x3122c4(%rip), %r13    # 0x32a568
movapd %xmm3, %xmm6
mulsd %xmm3, %xmm6
movsd 0xdadbc(%rip), %xmm7    # 0xf3070
movsd %xmm3, -0x38(%rbp)
movsd %xmm6, -0x30(%rbp)
cmpq $0x14, %r12
je 0x18448
cmpq $0x10, %r12
jb 0x183a4
movb 0x210c66(%rip), %al     # 0x228f3e
testb %al, %al
sete %cl
cmpq $0x10, %r12
setne %dl
orb %cl, %dl
jne 0x18304
movsd 0x40(%rbx), %xmm0
mulsd 0x38(%rbx), %xmm0
cvtsi2sdq 0x1ed09d(%rip), %xmm1 # 0x205398
divsd %xmm1, %xmm0
jmp 0x183d5
testb %al, %al
sete %cl
cmpq $0x11, %r12
setne %dl
orb %cl, %dl
jne 0x18341
movsd 0x18(%rbx), %xmm0
mulsd 0x20(%rbx), %xmm0
ucomisd %xmm4, %xmm0
jne 0x18326
jnp 0x18338
movsd 0x40(%rbx), %xmm1
mulsd 0x38(%rbx), %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
mulsd %xmm5, %xmm0
jmp 0x183d5
testb %al, %al
sete %al
cmpq $0x12, %r12
setne %cl
orb %al, %cl
jne 0x183a4
movzbl 0x2dec10(%rip), %edi    # 0x2f6f68
movsd 0x68(%rbx), %xmm0
cvtsi2sdq 0x1ed032(%rip), %xmm3 # 0x205398
divsd %xmm3, %xmm0
movsd 0x58(%rbx), %xmm2
movsd 0x60(%rbx), %xmm1
divsd %xmm3, %xmm1
divsd %xmm3, %xmm2
movl %r14d, %esi
callq 0x702c1
movsd 0xdace4(%rip), %xmm7    # 0xf3070
movsd -0x30(%rbp), %xmm6
movsd 0xdacc7(%rip), %xmm5    # 0xf3060
xorpd %xmm4, %xmm4
movsd -0x38(%rbp), %xmm3
jmp 0x183d5
movsd 0x10(%rbx,%r12,8), %xmm0
cvtsi2sdq 0x1ecfe4(%rip), %xmm1 # 0x205398
divsd %xmm1, %xmm0
movsd 0x10(%r13,%r12,8), %xmm2
divsd %xmm1, %xmm2
movapd %xmm0, %xmm1
subsd %xmm2, %xmm1
addsd (%r15), %xmm1
movsd %xmm1, (%r15)
movsd -0x40(%r15), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0x40(%r15)
movapd %xmm3, %xmm1
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm0
addsd -0x30(%r15), %xmm0
movsd %xmm0, -0x30(%r15)
addsd -0x28(%r15), %xmm1
movsd %xmm1, -0x28(%r15)
movsd -0x38(%r15), %xmm0
addsd %xmm6, %xmm0
movsd %xmm0, -0x38(%r15)
movsd -0x48(%r15), %xmm0
addsd %xmm3, %xmm0
movsd %xmm0, -0x48(%r15)
movsd -0x20(%r15), %xmm0
addsd %xmm7, %xmm0
movsd %xmm0, -0x20(%r15)
incq %r12
addq $0xe8, %r15
jmp 0x182be
movsd 0x2deb40(%rip), %xmm0   # 0x2f6f90
addsd 0xdac18(%rip), %xmm0    # 0xf3070
movsd %xmm0, 0x2deb30(%rip)   # 0x2f6f90
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq