// File: 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
subq $0x50, %rsp
movb %dil, %al
movb %al, -0x1(%rbp)
movq %rsi, -0x10(%rbp)
movzbl -0x1(%rbp), %eax
cmpl $0x6, %eax
jne 0x16023e
leaq 0x13baf6(%rip), %rax    # 0x29bd18
movq (%rax), %rax
movq %rax, -0x40(%rbp)
leaq 0x13baf0(%rip), %rax    # 0x29bd20
movsd (%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0x1602c4
movzbl -0x1(%rbp), %eax
cmpl $0x1, %eax
jne 0x160267
leaq 0x13bb1a(%rip), %rax    # 0x29bd68
movq (%rax), %rax
movq %rax, -0x40(%rbp)
leaq 0x13bb14(%rip), %rax    # 0x29bd70
movsd (%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0x1602c2
movzbl -0x1(%rbp), %eax
cmpl $0xb, %eax
jne 0x160290
leaq 0x13bb41(%rip), %rax    # 0x29bdb8
movq (%rax), %rax
movq %rax, -0x40(%rbp)
leaq 0x13bb3b(%rip), %rax    # 0x29bdc0
movsd (%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0x1602c0
movzbl -0x1(%rbp), %eax
cmpl $0x10, %eax
jne 0x1602b9
leaq 0x13bb68(%rip), %rax    # 0x29be08
movq (%rax), %rax
movq %rax, -0x40(%rbp)
leaq 0x13bb62(%rip), %rax    # 0x29be10
movsd (%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0x1602be
jmp 0x1604eb
jmp 0x1602c0
jmp 0x1602c2
jmp 0x1602c4
movl $0x0, -0x34(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
leaq 0x13bbc4(%rip), %rcx    # 0x29bea0
cmpl (%rcx), %eax
jge 0x1604d1
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jge 0x160306
jmp 0x1604d1
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %eax
addl -0x18(%rbp), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
addl -0x20(%rbp), %eax
cltq
cmpq -0x40(%rbp), %rax
jl 0x16033b
jmp 0x1604d1
jmp 0x16033d
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
addl -0x20(%rbp), %eax
cltq
cmpq -0x40(%rbp), %rax
jge 0x160446
movb -0x1(%rbp), %al
movq -0x28(%rbp), %rcx
movl 0x4(%rcx), %ecx
addl -0x20(%rbp), %ecx
movslq %ecx, %rsi
movzbl %al, %edi
callq 0x1624e0
movsd %xmm0, -0x30(%rbp)
movb -0x1(%rbp), %al
movq -0x28(%rbp), %rcx
movl 0x4(%rcx), %ecx
addl -0x1c(%rbp), %ecx
movslq %ecx, %rsi
movzbl %al, %edi
callq 0x1624e0
movsd -0x30(%rbp), %xmm1
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd 0xee34(%rip), %xmm2     # 0x16f1e0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movb -0x1(%rbp), %al
movq -0x28(%rbp), %rcx
movl 0x4(%rcx), %ecx
addl -0x18(%rbp), %ecx
movslq %ecx, %rsi
movzbl %al, %edi
callq 0x1624e0
movsd -0x30(%rbp), %xmm1
movsd 0xee02(%rip), %xmm2     # 0x16f1e0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movb -0x1(%rbp), %al
movq -0x28(%rbp), %rcx
movslq 0x4(%rcx), %rsi
movzbl %al, %edi
callq 0x1624e0
movaps %xmm0, %xmm1
movsd -0x30(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
movsd -0x30(%rbp), %xmm2
movq -0x28(%rbp), %rax
movsd 0x8(%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rax)
movq -0x28(%rbp), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
callq 0x15fe50
jmp 0x16033d
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
leaq 0x13ba48(%rip), %rcx    # 0x29be9c
cmpl (%rcx), %eax
jl 0x1604c1
movq -0x28(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0x1604bf
movq -0x28(%rbp), %rax
movsd 0x18(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x160478
jp 0x160478
jmp 0x1604bf
movq -0x28(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0x28(%rbp), %rax
cvtsi2sdl 0x4(%rax), %xmm2
addsd -0x48(%rbp), %xmm2
movsd 0x22bd9(%rip), %xmm1    # 0x183070
mulsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x9280
movq -0x28(%rbp), %rax
divsd 0x18(%rax), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x10(%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1604c1
jmp 0x1604c3
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1602d2
movl -0x34(%rbp), %eax
leaq 0x123c85(%rip), %rcx    # 0x284160
cmpl (%rcx), %eax
jle 0x1604eb
movl -0x34(%rbp), %ecx
leaq 0x123c77(%rip), %rax    # 0x284160
movl %ecx, (%rax)
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)