// File: /workspace/github_cpp_makefile_star2_O3/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 $0x28, %rsp
movq %rsi, %r12
cmpl $0xc, %edi
jg 0xffd8a
cmpl $0x3, %edi
je 0xffda8
cmpl $0x8, %edi
jne 0x100054
leaq 0x13cdbf(%rip), %rax    # 0x23cb40
leaq 0x13cdb0(%rip), %rcx    # 0x23cb38
jmp 0xffdc6
cmpl $0xd, %edi
je 0xffdb8
cmpl $0x12, %edi
jne 0x100054
leaq 0x13ce91(%rip), %rax    # 0x23cc30
leaq 0x13ce82(%rip), %rcx    # 0x23cc28
jmp 0xffdc6
leaq 0x13cde1(%rip), %rax    # 0x23cb90
leaq 0x13cdd2(%rip), %rcx    # 0x23cb88
jmp 0xffdc6
leaq 0x13ce21(%rip), %rax    # 0x23cbe0
leaq 0x13ce12(%rip), %rcx    # 0x23cbd8
leaq 0x13cef3(%rip), %rdx    # 0x23ccc0
cmpl $0x0, (%rdx)
jle 0x10003d
movsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movq (%rcx), %r13
xorl %ebx, %ebx
movzbl %dil, %r14d
movl $0x0, -0x2c(%rbp)
movq %r12, -0x40(%rbp)
imulq $0x38, %rbx, %r15
cmpl $0x0, 0x4(%r12,%r15)
js 0x100044
addq %r12, %r15
movl 0x2c(%r15), %ecx
testl %ecx, %ecx
js 0x100044
movl 0x28(%r15), %eax
testl %eax, %eax
js 0x100044
movq %rbx, -0x48(%rbp)
movslq (%r15), %rbx
leaq (%rbx,%rbx,2), %rdx
addl %edx, %ecx
movslq %ecx, %rcx
cmpq %rcx, %r13
jl 0x100044
movq %rdx, -0x38(%rbp)
leaq (%rbx,%rbx), %r12
cmpl %ebx, %eax
jge 0xffea7
addl %r12d, %eax
movslq %eax, %rsi
movl %r14d, %edi
callq 0x10109e
addsd 0x20(%r15), %xmm0
movsd %xmm0, 0x20(%r15)
movslq 0x28(%r15), %rsi
addq %rbx, %rsi
movl %r14d, %edi
callq 0x10109e
movsd 0x20(%r15), %xmm1
addsd %xmm0, %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, 0x20(%r15)
movslq 0x28(%r15), %rsi
movl %r14d, %edi
callq 0x10109e
addsd 0x20(%r15), %xmm0
movsd %xmm0, 0x20(%r15)
incl 0x28(%r15)
callq 0xff598
movl 0x28(%r15), %eax
jmp 0xffe3f
cmpl $0x0, 0x30(%r15)
jne 0xffed0
movsd 0x20(%r15), %xmm0
mulsd %xmm0, %xmm0
addsd 0x8(%r15), %xmm0
movsd %xmm0, 0x8(%r15)
incl 0x4(%r15)
movl $0x1, 0x30(%r15)
movslq 0x2c(%r15), %rsi
movq -0x38(%rbp), %rax
addq %rax, %rsi
cmpq %rsi, %r13
jle 0xfff96
cltq
movq %rax, -0x38(%rbp)
movl %r14d, %edi
callq 0x10109e
addsd 0x20(%r15), %xmm0
movsd %xmm0, 0x20(%r15)
movslq 0x2c(%r15), %rsi
addq %r12, %rsi
movl %r14d, %edi
callq 0x10109e
movsd 0x20(%r15), %xmm1
movsd 0xbaed(%rip), %xmm2     # 0x10ba08
mulsd %xmm2, %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, 0x20(%r15)
movslq 0x2c(%r15), %rsi
addq %rbx, %rsi
movl %r14d, %edi
callq 0x10109e
mulsd 0xbac8(%rip), %xmm0     # 0x10ba08
addsd 0x20(%r15), %xmm0
movsd %xmm0, 0x20(%r15)
movslq 0x2c(%r15), %rsi
movl %r14d, %edi
callq 0x10109e
movsd 0x20(%r15), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x20(%r15)
mulsd %xmm1, %xmm1
addsd 0x8(%r15), %xmm1
movsd %xmm1, 0x8(%r15)
incl 0x2c(%r15)
incl 0x4(%r15)
callq 0xff598
movslq 0x2c(%r15), %rsi
addq -0x38(%rbp), %rsi
cmpq %rsi, %r13
jg 0xffeea
movl 0x4(%r15), %eax
leaq 0x13cd1b(%rip), %rcx    # 0x23ccbc
cmpl (%rcx), %eax
jge 0xfffaf
movq -0x40(%rbp), %r12
movq -0x48(%rbp), %rbx
jmp 0x100025
xorps %xmm2, %xmm2
cvtsi2sdl (%r15), %xmm2
mulsd 0x18(%r15), %xmm2
ucomisd 0x9153(%rip), %xmm2     # 0x109118
movq -0x40(%rbp), %r12
movq -0x48(%rbp), %rbx
jne 0xfffd1
jnp 0x100022
movsd 0x8(%r15), %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
addsd -0x50(%rbp), %xmm1
addsd %xmm1, %xmm1
divsd %xmm1, %xmm0
ucomisd 0x9125(%rip), %xmm0     # 0x109118
jb 0xffffb
sqrtsd %xmm0, %xmm0
jmp 0x10000a
movsd %xmm2, -0x38(%rbp)
callq 0x9270
movsd -0x38(%rbp), %xmm2
divsd %xmm2, %xmm0
mulsd 0x18(%r15), %xmm0
divsd 0x2c76c(%rip), %xmm0    # 0x12c788
movsd %xmm0, 0x10(%r15)
incl -0x2c(%rbp)
incq %rbx
leaq 0x13cc91(%rip), %rax    # 0x23ccc0
movslq (%rax), %rax
cmpq %rax, %rbx
jl 0xffdf3
jmp 0x100044
movl $0x0, -0x2c(%rbp)
leaq 0x124f35(%rip), %rax    # 0x224f80
movl -0x2c(%rbp), %ecx
cmpl (%rax), %ecx
jle 0x100054
movl %ecx, (%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq