// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r13
cmpl $0xa, %edi
jg 0xff19c
cmpl $0x1, %edi
je 0xff1ba
cmpl $0x6, %edi
jne 0xff391
leaq 0x13d9ad(%rip), %rax    # 0x23cb40
leaq 0x13d99e(%rip), %rcx    # 0x23cb38
jmp 0xff1d8
cmpl $0xb, %edi
je 0xff1ca
cmpl $0x10, %edi
jne 0xff391
leaq 0x13da7f(%rip), %rax    # 0x23cc30
leaq 0x13da70(%rip), %rcx    # 0x23cc28
jmp 0xff1d8
leaq 0x13d9cf(%rip), %rax    # 0x23cb90
leaq 0x13d9c0(%rip), %rcx    # 0x23cb88
jmp 0xff1d8
leaq 0x13da0f(%rip), %rax    # 0x23cbe0
leaq 0x13da00(%rip), %rcx    # 0x23cbd8
leaq 0x13dae1(%rip), %rdx    # 0x23ccc0
cmpl $0x0, (%rdx)
jle 0xff37a
movsd (%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
movq (%rcx), %rdx
xorl %r8d, %r8d
movzbl %dil, %r14d
xorpd %xmm3, %xmm3
movl $0x0, -0x2c(%rbp)
movq %rdx, -0x40(%rbp)
movq %r13, -0x50(%rbp)
imulq $0x38, %r8, %r15
movl 0x4(%r13,%r15), %eax
testl %eax, %eax
js 0xff381
addq %r13, %r15
movslq (%r15), %rbx
leaq (%rbx,%rbx,2), %r12
addl %r12d, %eax
cltq
cmpq %rax, %rdx
jle 0xff381
movl 0x4(%r15), %eax
leal (%rax,%r12), %ecx
movslq %ecx, %rsi
cmpq %rsi, %rdx
jle 0xff2f9
movq %r8, -0x58(%rbp)
leaq (%rbx,%rbx), %r13
movl %r14d, %edi
callq 0x100a1e
movsd %xmm0, -0x38(%rbp)
movslq 0x4(%r15), %rsi
addq %r13, %rsi
movl %r14d, %edi
callq 0x100a1e
movsd 0xc791(%rip), %xmm1     # 0x10ba08
mulsd %xmm1, %xmm0
movsd -0x38(%rbp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, -0x38(%rbp)
movslq 0x4(%r15), %rsi
addq %rbx, %rsi
movl %r14d, %edi
callq 0x100a1e
mulsd 0xc768(%rip), %xmm0     # 0x10ba08
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movslq 0x4(%r15), %rsi
movl %r14d, %edi
callq 0x100a1e
movsd -0x38(%rbp), %xmm1
subsd %xmm0, %xmm1
mulsd %xmm1, %xmm1
addsd 0x8(%r15), %xmm1
movsd %xmm1, 0x8(%r15)
incl 0x4(%r15)
callq 0xfeec0
movq -0x40(%rbp), %rdx
movslq 0x4(%r15), %rax
leaq (%rax,%r12), %rsi
cmpq %rsi, %rdx
jg 0xff253
movq -0x50(%rbp), %r13
movq -0x58(%rbp), %r8
xorpd %xmm3, %xmm3
testl %eax, %eax
je 0xff362
leaq 0x13d9b8(%rip), %rcx    # 0x23ccbc
cmpl (%rcx), %eax
jl 0xff362
movsd 0x18(%r15), %xmm0
ucomisd %xmm3, %xmm0
jne 0xff316
jnp 0xff362
movsd 0x8(%r15), %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
addsd -0x48(%rbp), %xmm1
mulsd 0x1f3c0(%rip), %xmm1    # 0x11e6f0
divsd %xmm1, %xmm0
ucomisd %xmm3, %xmm0
jb 0xff340
sqrtsd %xmm0, %xmm0
jmp 0xff353
movq %r8, %rbx
callq 0x9270
xorpd %xmm3, %xmm3
movq %rbx, %r8
movq -0x40(%rbp), %rdx
divsd 0x18(%r15), %xmm0
movsd %xmm0, 0x10(%r15)
incl -0x2c(%rbp)
incq %r8
leaq 0x13d954(%rip), %rax    # 0x23ccc0
movslq (%rax), %rax
cmpq %rax, %r8
jl 0xff20e
jmp 0xff381
movl $0x0, -0x2c(%rbp)
leaq 0x125bf8(%rip), %rax    # 0x224f80
movl -0x2c(%rbp), %ecx
cmpl (%rax), %ecx
jle 0xff391
movl %ecx, (%rax)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq