// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathmsc.cpp
// Function: incr_hdev(unsigned char, BIN*)
void incr_hdev(u08 id, struct BIN *bins)
{
S32 b;
S32 t1,t2,t3;
struct BIN *B;
double v;
int vis_bins;
long adev_q_count;
double adev_q_overflow;

   if     (id == PPS_HDEV) { adev_q_count = pps_adev_q_count; adev_q_overflow = pps_adev_q_overflow; }
   else if(id == OSC_HDEV) { adev_q_count = osc_adev_q_count; adev_q_overflow = osc_adev_q_overflow; }
   else if(id == CHC_HDEV) { adev_q_count = chc_adev_q_count; adev_q_overflow = chc_adev_q_overflow; }
   else if(id == CHD_HDEV) { adev_q_count = chd_adev_q_count; adev_q_overflow = chd_adev_q_overflow; }
   else return;

   vis_bins = 0;

   for(b=0; b<n_bins; b++) {
      B = &bins[b];
      if(B->n < 0) break;

      t1 = B->m;
      t2 = t1 + t1;
      t3 = t1 + t1 + t1;

      if((B->n+t3) >= adev_q_count) break;

      while((B->n+t3) < adev_q_count) {
         v =  get_adev_point(id, B->n+t3);
         v -= get_adev_point(id, B->n+t2) * 3.0;
         v += get_adev_point(id, B->n+t1) * 3.0;
         v -= get_adev_point(id, B->n);

         B->sum += (v * v);
         B->n++;
         adev_mouse();
      }

      if(B->n >= min_points_per_bin) {
         if(B->n && B->tau) {
            B->value = sqrt(B->sum / (6.0 * ((double) B->n + adev_q_overflow))) / B->tau;
            ++vis_bins;
         }
      }
   }

   if(vis_bins > max_adev_rows) max_adev_rows = vis_bins;
}

// Assembly:
movq %rsi, %r8
cmpl $0xa, %edi
jg 0xff84b
cmpl $0x1, %edi
je 0xff869
cmpl $0x6, %edi
jne 0xffa50
leaq 0x13d2fe(%rip), %rax    # 0x23cb40
leaq 0x13d2ef(%rip), %rcx    # 0x23cb38
jmp 0xff887
cmpl $0xb, %edi
je 0xff879
cmpl $0x10, %edi
jne 0xffa50
leaq 0x13d3d0(%rip), %rax    # 0x23cc30
leaq 0x13d3c1(%rip), %rcx    # 0x23cc28
jmp 0xff887
leaq 0x13d320(%rip), %rax    # 0x23cb90
leaq 0x13d311(%rip), %rcx    # 0x23cb88
jmp 0xff887
leaq 0x13d360(%rip), %rax    # 0x23cbe0
leaq 0x13d351(%rip), %rcx    # 0x23cbd8
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
leaq 0x13d421(%rip), %rdx    # 0x23ccc0
cmpl $0x0, (%rdx)
jle 0xffa2a
movsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movq (%rcx), %rcx
xorl %edx, %edx
movzbl %dil, %r14d
movl $0x0, -0x2c(%rbp)
movq %r8, -0x48(%rbp)
imulq $0x38, %rdx, %r15
movl 0x4(%r8,%r15), %eax
testl %eax, %eax
js 0xffa31
addq %r8, %r15
movslq (%r15), %rbx
leaq (%rbx,%rbx,2), %r12
addl %r12d, %eax
movslq %eax, %rsi
cmpq %rsi, %rcx
jle 0xffa31
movq %rdx, -0x38(%rbp)
leaq (%rbx,%rbx), %rax
movq %rax, -0x58(%rbp)
movl %r14d, %edi
movq %rcx, %r13
callq 0x10109e
movsd %xmm0, -0x40(%rbp)
movslq 0x4(%r15), %rsi
addq -0x58(%rbp), %rsi
movl %r14d, %edi
callq 0x10109e
movsd 0xc0e5(%rip), %xmm1     # 0x10ba08
mulsd %xmm1, %xmm0
movsd -0x40(%rbp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, -0x40(%rbp)
movslq 0x4(%r15), %rsi
addq %rbx, %rsi
movl %r14d, %edi
callq 0x10109e
mulsd 0xc0bc(%rip), %xmm0     # 0x10ba08
addsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movslq 0x4(%r15), %rsi
movl %r14d, %edi
callq 0x10109e
movsd -0x40(%rbp), %xmm1
subsd %xmm0, %xmm1
mulsd %xmm1, %xmm1
addsd 0x8(%r15), %xmm1
movsd %xmm1, 0x8(%r15)
incl 0x4(%r15)
callq 0xff598
movq %r13, %rcx
movslq 0x4(%r15), %rax
leaq (%rax,%r12), %rsi
cmpq %rsi, %r13
jg 0xff8fb
testl %eax, %eax
je 0xff9e7
leaq 0x13d319(%rip), %rdx    # 0x23ccbc
cmpl (%rdx), %eax
movq -0x48(%rbp), %r8
xorpd %xmm2, %xmm2
jl 0xff9eb
movsd 0x18(%r15), %xmm0
ucomisd %xmm2, %xmm0
jne 0xff9bd
jnp 0xff9eb
movsd 0x8(%r15), %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
addsd -0x50(%rbp), %xmm1
mulsd 0x1edc9(%rip), %xmm1    # 0x11e7a0
divsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jb 0xff9f1
sqrtsd %xmm0, %xmm0
jmp 0xff9ff
movq -0x48(%rbp), %r8
movq -0x38(%rbp), %rdx
jmp 0xffa12
movq %r8, %rbx
callq 0x9270
movq %rbx, %r8
movq %r13, %rcx
movq -0x38(%rbp), %rdx
divsd 0x18(%r15), %xmm0
movsd %xmm0, 0x10(%r15)
incl -0x2c(%rbp)
incq %rdx
leaq 0x13d2a4(%rip), %rax    # 0x23ccc0
movslq (%rax), %rax
cmpq %rax, %rdx
jl 0xff8c5
jmp 0xffa31
movl $0x0, -0x2c(%rbp)
leaq 0x125548(%rip), %rax    # 0x224f80
movl -0x2c(%rbp), %ecx
cmpl (%rax), %ecx
leaq 0x38(%rsp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jle 0xffa50
movl %ecx, (%rax)
retq