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

   if     (id == PPS_ADEV) { adev_q_count = pps_adev_q_count; adev_q_overflow = pps_adev_q_overflow; }
   else if(id == OSC_ADEV) { adev_q_count = osc_adev_q_count; adev_q_overflow = osc_adev_q_overflow; } 
   else if(id == CHC_ADEV) { adev_q_count = chc_adev_q_count; adev_q_overflow = chc_adev_q_overflow; } 
   else if(id == CHD_ADEV) { 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;

      if((B->n+t2) >= adev_q_count) break;
//tvb if((B->n+t2) > adev_q_count) break;

      while((B->n+t2) < adev_q_count) {
         v =  get_adev_point(id, B->n+t2);
         v -= get_adev_point(id, B->n+t1) * 2.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 / (2.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 $0x28, %rsp
movq %rsi, %r12
cmpl $0xf, %edi
je 0xe964a
cmpl $0x5, %edi
je 0xe962a
cmpl $0xa, %edi
je 0xe963a
testl %edi, %edi
jne 0xe97a6
leaq 0x13d56f(%rip), %rax    # 0x226b90
leaq 0x13d560(%rip), %rcx    # 0x226b88
jmp 0xe9658
leaq 0x13d50f(%rip), %rax    # 0x226b40
leaq 0x13d500(%rip), %rcx    # 0x226b38
jmp 0xe9658
leaq 0x13d59f(%rip), %rax    # 0x226be0
leaq 0x13d590(%rip), %rcx    # 0x226bd8
jmp 0xe9658
leaq 0x13d5df(%rip), %rax    # 0x226c30
leaq 0x13d5d0(%rip), %rcx    # 0x226c28
movsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movq (%rcx), %r15
xorl %edx, %edx
movzbl %dil, %r14d
movl $0x0, -0x2c(%rbp)
movq %r12, -0x40(%rbp)
leaq 0x13d644(%rip), %rax    # 0x226cc0
movslq (%rax), %rax
cmpq %rax, %rdx
jge 0xe9796
imulq $0x38, %rdx, %r13
movslq 0x4(%r12,%r13), %rax
testq %rax, %rax
js 0xe9796
addq %r12, %r13
movslq (%r13), %rbx
leaq (%rax,%rbx,2), %rcx
cmpq %rcx, %r15
jle 0xe9796
movq %rdx, -0x48(%rbp)
leaq (%rbx,%rbx), %r12
leal (%rax,%r12), %ecx
movslq %ecx, %rsi
cmpq %rsi, %r15
jle 0xe9720
movl %r14d, %edi
callq 0xead56
movsd %xmm0, -0x38(%rbp)
movslq 0x4(%r13), %rsi
addq %rbx, %rsi
movl %r14d, %edi
callq 0xead56
addsd %xmm0, %xmm0
movsd -0x38(%rbp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, -0x38(%rbp)
movslq 0x4(%r13), %rsi
movl %r14d, %edi
callq 0xead56
addsd -0x38(%rbp), %xmm0
mulsd %xmm0, %xmm0
addsd 0x8(%r13), %xmm0
movsd %xmm0, 0x8(%r13)
incl 0x4(%r13)
callq 0xe9548
movl 0x4(%r13), %eax
jmp 0xe96b6
testl %eax, %eax
movq -0x48(%rbp), %rdx
je 0xe9770
leaq 0x13d58d(%rip), %rcx    # 0x226cbc
cmpl (%rcx), %eax
movq -0x40(%rbp), %r12
jl 0xe978e
xorpd %xmm1, %xmm1
movsd 0x18(%r13), %xmm0
ucomisd %xmm1, %xmm0
jne 0xe9749
jnp 0xe978e
xorpd %xmm2, %xmm2
movsd 0x8(%r13), %xmm0
cvtsi2sd %eax, %xmm1
addsd -0x50(%rbp), %xmm1
addsd %xmm1, %xmm1
divsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jb 0xe9776
sqrtsd %xmm0, %xmm0
jmp 0xe977f
movq -0x40(%rbp), %r12
jmp 0xe978e
callq 0x9260
movq -0x48(%rbp), %rdx
divsd 0x18(%r13), %xmm0
movsd %xmm0, 0x10(%r13)
incl -0x2c(%rbp)
incq %rdx
jmp 0xe9675
leaq 0x1257e3(%rip), %rax    # 0x20ef80
movl -0x2c(%rbp), %ecx
cmpl (%rax), %ecx
jle 0xe97a6
movl %ecx, (%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq