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

   if     (id == PPS_TDEV) { adev_q_count = pps_adev_q_count; adev_q_overflow = pps_adev_q_overflow; }
   else if(id == OSC_TDEV) { adev_q_count = osc_adev_q_count; adev_q_overflow = osc_adev_q_overflow; }
   else if(id == CHC_TDEV) { adev_q_count = chc_adev_q_count; adev_q_overflow = chc_adev_q_overflow; }
   else if(id == CHD_TDEV) { 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;
      if(B->j < 0) break;
      if(B->i < 0) break;

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

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

      while(((B->i+t2) < adev_q_count) && (B->i < t1)) {
         B->accum += get_adev_point(id, B->i+t2);
         B->accum -= get_adev_point(id, B->i+t1) * 2.0;
         B->accum += get_adev_point(id, B->i);
         B->i++;
         adev_mouse();
      }

      if(B->init == 0) {
         B->sum += (B->accum * B->accum);
         B->n++;
         B->init = 1;
      }

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

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

      if(B->n >= min_points_per_bin) {
         divisor = (double) B->m * B->tau;
         if(divisor != 0.0) {
            B->value = sqrt(B->sum / (2.0 * ((double) B->n + adev_q_overflow))) / divisor;
            B->value = B->value * B->tau / SQRT3;
         }
         ++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, %r15
cmpl $0x12, %edi
je 0xe9cf0
cmpl $0x8, %edi
je 0xe9cd0
cmpl $0xd, %edi
je 0xe9ce0
cmpl $0x3, %edi
jne 0xe9f69
leaq 0x13cec9(%rip), %rax    # 0x226b90
leaq 0x13ceba(%rip), %rcx    # 0x226b88
jmp 0xe9cfe
leaq 0x13ce69(%rip), %rax    # 0x226b40
leaq 0x13ce5a(%rip), %rcx    # 0x226b38
jmp 0xe9cfe
leaq 0x13cef9(%rip), %rax    # 0x226be0
leaq 0x13ceea(%rip), %rcx    # 0x226bd8
jmp 0xe9cfe
leaq 0x13cf39(%rip), %rax    # 0x226c30
leaq 0x13cf2a(%rip), %rcx    # 0x226c28
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movq (%rcx), %rax
movq %rax, -0x48(%rbp)
xorl %edx, %edx
movzbl %dil, %r14d
movl $0x0, -0x2c(%rbp)
movq %r15, -0x40(%rbp)
leaq 0x13cf9a(%rip), %rax    # 0x226cc0
movslq (%rax), %rax
cmpq %rax, %rdx
jge 0xe9f59
imulq $0x38, %rdx, %r13
cmpl $0x0, 0x4(%r15,%r13)
js 0xe9f59
addq %r15, %r13
movl 0x2c(%r13), %ecx
testl %ecx, %ecx
js 0xe9f59
movl 0x28(%r13), %eax
testl %eax, %eax
js 0xe9f59
movslq (%r13), %rbx
leaq (%rbx,%rbx,2), %r12
addl %r12d, %ecx
movslq %ecx, %rcx
cmpq %rcx, -0x48(%rbp)
jl 0xe9f59
movq %rdx, -0x38(%rbp)
leaq (%rbx,%rbx), %r15
cmpl %ebx, %eax
jge 0xe9de5
addl %r15d, %eax
movslq %eax, %rsi
movl %r14d, %edi
callq 0xead56
addsd 0x20(%r13), %xmm0
movsd %xmm0, 0x20(%r13)
movslq 0x28(%r13), %rsi
addq %rbx, %rsi
movl %r14d, %edi
callq 0xead56
movsd 0x20(%r13), %xmm1
addsd %xmm0, %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, 0x20(%r13)
movslq 0x28(%r13), %rsi
movl %r14d, %edi
callq 0xead56
addsd 0x20(%r13), %xmm0
movsd %xmm0, 0x20(%r13)
incl 0x28(%r13)
callq 0xe9548
movl 0x28(%r13), %eax
jmp 0xe9d7d
cmpl $0x0, 0x30(%r13)
jne 0xe9eb2
movsd 0x20(%r13), %xmm0
mulsd %xmm0, %xmm0
addsd 0x8(%r13), %xmm0
movsd %xmm0, 0x8(%r13)
incl 0x4(%r13)
movl $0x1, 0x30(%r13)
jmp 0xe9eb2
movl %r14d, %edi
callq 0xead56
addsd 0x20(%r13), %xmm0
movsd %xmm0, 0x20(%r13)
movslq 0x2c(%r13), %rsi
addq %r15, %rsi
movl %r14d, %edi
callq 0xead56
movsd 0x20(%r13), %xmm1
movsd 0xbc38(%rip), %xmm2     # 0xf5a80
mulsd %xmm2, %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, 0x20(%r13)
movslq 0x2c(%r13), %rsi
addq %rbx, %rsi
movl %r14d, %edi
callq 0xead56
mulsd 0xbc13(%rip), %xmm0     # 0xf5a80
addsd 0x20(%r13), %xmm0
movsd %xmm0, 0x20(%r13)
movslq 0x2c(%r13), %rsi
movl %r14d, %edi
callq 0xead56
movsd 0x20(%r13), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x20(%r13)
mulsd %xmm1, %xmm1
addsd 0x8(%r13), %xmm1
movsd %xmm1, 0x8(%r13)
incl 0x2c(%r13)
incl 0x4(%r13)
callq 0xe9548
movslq 0x2c(%r13), %rsi
addq %r12, %rsi
cmpq %rsi, -0x48(%rbp)
jg 0xe9e17
movl 0x4(%r13), %eax
leaq 0x13cdee(%rip), %rcx    # 0x226cbc
cmpl (%rcx), %eax
jge 0xe9edc
movq -0x40(%rbp), %r15
movq -0x38(%rbp), %rdx
jmp 0xe9f51
cvtsi2sdl (%r13), %xmm2
mulsd 0x18(%r13), %xmm2
ucomisd 0x9228(%rip), %xmm2     # 0xf3118
movq -0x40(%rbp), %r15
movq -0x38(%rbp), %rdx
jne 0xe9efc
jnp 0xe9f4e
movsd 0x8(%r13), %xmm0
cvtsi2sd %eax, %xmm1
addsd -0x58(%rbp), %xmm1
addsd %xmm1, %xmm1
divsd %xmm1, %xmm0
ucomisd 0x91fd(%rip), %xmm0     # 0xf3118
jb 0xe9f23
sqrtsd %xmm0, %xmm0
jmp 0xe9f36
movsd %xmm2, -0x50(%rbp)
callq 0x9260
movsd -0x50(%rbp), %xmm2
movq -0x38(%rbp), %rdx
divsd %xmm2, %xmm0
mulsd 0x18(%r13), %xmm0
divsd 0x2c760(%rip), %xmm0    # 0x1166a8
movsd %xmm0, 0x10(%r13)
incl -0x2c(%rbp)
incq %rdx
jmp 0xe9d1f
leaq 0x125020(%rip), %rax    # 0x20ef80
movl -0x2c(%rbp), %ecx
cmpl (%rax), %ecx
jle 0xe9f69
movl %ecx, (%rax)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq