// File: /workspace/github_cpp_makefile_star2_O3/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, %rbx
cmpl $0x9, %edi
jg 0xff67d
testl %edi, %edi
je 0xff69b
cmpl $0x5, %edi
jne 0xff816
leaq 0x13d4cc(%rip), %rax    # 0x23cb40
leaq 0x13d4bd(%rip), %rcx    # 0x23cb38
jmp 0xff6b9
cmpl $0xa, %edi
je 0xff6ab
cmpl $0xf, %edi
jne 0xff816
leaq 0x13d59e(%rip), %rax    # 0x23cc30
leaq 0x13d58f(%rip), %rcx    # 0x23cc28
jmp 0xff6b9
leaq 0x13d4ee(%rip), %rax    # 0x23cb90
leaq 0x13d4df(%rip), %rcx    # 0x23cb88
jmp 0xff6b9
leaq 0x13d52e(%rip), %rax    # 0x23cbe0
leaq 0x13d51f(%rip), %rcx    # 0x23cbd8
leaq 0x13d600(%rip), %rdx    # 0x23ccc0
cmpl $0x0, (%rdx)
jle 0xff7ff
movsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movq (%rcx), %r13
xorl %r12d, %r12d
movzbl %dil, %r14d
movl $0x0, -0x2c(%rbp)
movq %rbx, -0x40(%rbp)
imulq $0x38, %r12, %r15
movl 0x4(%rbx,%r15), %eax
testl %eax, %eax
js 0xff806
movq %r12, -0x48(%rbp)
addq %rbx, %r15
movslq (%r15), %rbx
leaq (%rbx,%rbx), %r12
addl %r12d, %eax
movslq %eax, %rsi
cmpq %rsi, %r13
jle 0xff806
movl %r14d, %edi
callq 0x10109e
movsd %xmm0, -0x38(%rbp)
movslq 0x4(%r15), %rsi
addq %rbx, %rsi
movl %r14d, %edi
callq 0x10109e
addsd %xmm0, %xmm0
movsd -0x38(%rbp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, -0x38(%rbp)
movslq 0x4(%r15), %rsi
movl %r14d, %edi
callq 0x10109e
addsd -0x38(%rbp), %xmm0
mulsd %xmm0, %xmm0
addsd 0x8(%r15), %xmm0
movsd %xmm0, 0x8(%r15)
incl 0x4(%r15)
callq 0xff598
movslq 0x4(%r15), %rax
leaq (%rax,%r12), %rsi
cmpq %rsi, %r13
jg 0xff715
testl %eax, %eax
je 0xff7c9
leaq 0x13d537(%rip), %rcx    # 0x23ccbc
cmpl (%rcx), %eax
movq -0x40(%rbp), %rbx
movq -0x48(%rbp), %r12
xorpd %xmm2, %xmm2
jl 0xff7e7
movsd 0x18(%r15), %xmm0
ucomisd %xmm2, %xmm0
jne 0xff7a3
jnp 0xff7e7
movsd 0x8(%r15), %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
addsd -0x50(%rbp), %xmm1
addsd %xmm1, %xmm1
divsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jb 0xff7d3
sqrtsd %xmm0, %xmm0
jmp 0xff7d8
movq -0x40(%rbp), %rbx
movq -0x48(%rbp), %r12
jmp 0xff7e7
callq 0x9270
divsd 0x18(%r15), %xmm0
movsd %xmm0, 0x10(%r15)
incl -0x2c(%rbp)
incq %r12
leaq 0x13d4cf(%rip), %rax    # 0x23ccc0
movslq (%rax), %rax
cmpq %rax, %r12
jl 0xff6e7
jmp 0xff806
movl $0x0, -0x2c(%rbp)
leaq 0x125773(%rip), %rax    # 0x224f80
movl -0x2c(%rbp), %ecx
cmpl (%rax), %ecx
jle 0xff816
movl %ecx, (%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq