// File: jkingan[P]ladyheather/heathmsc.cpp
// Function: write_log_adevs(ADEV_INFO*)
void write_log_adevs(struct ADEV_INFO *bins)
{
int i;
char *d;
char *t;
long adev_q_count;
char adev_id[32];
double period;

   // write an adev table to the log file
   if(log_file == 0) return;
   if(log_comments == 0) return;

   i = bins->adev_type / NUM_ADEV_TYPES;

   if(i == CHD_ID) {
      d = "chD";
   }
   else if(i == CHC_ID) { 
      d = "chC";
   }
   else if(i == PPS_ID) { 
      if(jitter_adev)    d = "Mag jit"; //"PPS";
      else if(TICC_USED) d = "chA";
      else               d = plot[PPS].plot_id; //"PPS";
   }
   else {
      if(jitter_adev)    d = "Msg ofs"; //"OSC";
      else if(TICC_USED) d = "chB";
      else               d = plot[OSC].plot_id; //"OSC";
   }

   period = adev_period;
   if     (bins->adev_type == PPS_ADEV) { t = "ADEV"; adev_q_count = pps_adev_q_count+(long) pps_adev_q_overflow; period = pps_adev_period; } 
   else if(bins->adev_type == OSC_ADEV) { t = "ADEV"; adev_q_count = osc_adev_q_count+(long) osc_adev_q_overflow; period = osc_adev_period; } 
   else if(bins->adev_type == CHC_ADEV) { t = "ADEV"; adev_q_count = chc_adev_q_count+(long) chc_adev_q_overflow; period = chc_adev_period; } 
   else if(bins->adev_type == CHD_ADEV) { t = "ADEV"; adev_q_count = chd_adev_q_count+(long) chd_adev_q_overflow; period = chd_adev_period; } 

   else if(bins->adev_type == PPS_MDEV) { t = "MDEV"; adev_q_count = pps_adev_q_count+(long) pps_adev_q_overflow; period = pps_adev_period; } 
   else if(bins->adev_type == OSC_MDEV) { t = "MDEV"; adev_q_count = osc_adev_q_count+(long) osc_adev_q_overflow; period = osc_adev_period; } 
   else if(bins->adev_type == CHC_MDEV) { t = "MDEV"; adev_q_count = chc_adev_q_count+(long) chc_adev_q_overflow; period = chc_adev_period; } 
   else if(bins->adev_type == CHD_MDEV) { t = "MDEV"; adev_q_count = chd_adev_q_count+(long) chd_adev_q_overflow; period = chd_adev_period; } 

   else if(bins->adev_type == PPS_HDEV) { t = "HDEV"; adev_q_count = pps_adev_q_count+(long) pps_adev_q_overflow; period = pps_adev_period; } 
   else if(bins->adev_type == OSC_HDEV) { t = "HDEV"; adev_q_count = osc_adev_q_count+(long) osc_adev_q_overflow; period = osc_adev_period; } 
   else if(bins->adev_type == CHC_HDEV) { t = "HDEV"; adev_q_count = chc_adev_q_count+(long) chc_adev_q_overflow; period = chc_adev_period; } 
   else if(bins->adev_type == CHD_HDEV) { t = "HDEV"; adev_q_count = chd_adev_q_count+(long) chd_adev_q_overflow; period = chd_adev_period; } 

   else if(bins->adev_type == PPS_TDEV) { t = "TDEV"; adev_q_count = pps_adev_q_count+(long) pps_adev_q_overflow; period = pps_adev_period; } 
   else if(bins->adev_type == OSC_TDEV) { t = "TDEV"; adev_q_count = osc_adev_q_count+(long) osc_adev_q_overflow; period = osc_adev_period; } 
   else if(bins->adev_type == CHC_TDEV) { t = "TDEV"; adev_q_count = chc_adev_q_count+(long) chc_adev_q_overflow; period = chc_adev_period; } 
   else if(bins->adev_type == CHD_TDEV) { t = "TDEV"; adev_q_count = chd_adev_q_count+(long) chd_adev_q_overflow; period = chd_adev_period; } 

   else if(bins->adev_type == A_MTIE)   { t = "MTIE"; adev_q_count = mtie_intervals[CHA_MTIE][0]; period = pps_adev_period; } 
   else if(bins->adev_type == B_MTIE)   { t = "MTIE"; adev_q_count = mtie_intervals[CHB_MTIE][0]; period = osc_adev_period; } 
   else if(bins->adev_type == C_MTIE)   { t = "MTIE"; adev_q_count = mtie_intervals[CHC_MTIE][0]; period = chc_adev_period; } 
   else if(bins->adev_type == D_MTIE)   { t = "MTIE"; adev_q_count = mtie_intervals[CHD_MTIE][0]; period = chd_adev_period; } 
   else { t="????"; adev_q_count = 0; }

   strcpy(adev_id, t);
   if(TICC_USED == 0) strlwr(adev_id);  // show bogo-adevs in lower case
   else if(ticc_type == LARS_TICC) strlwr(adev_id);

   sprintf(log_text, "#");
   write_log_comment(1);

   sprintf(log_text, "#  %s %s for %lu points - sample period=%.3f secs  - bin count:%d", 
      d, adev_id, adev_q_count, period, bins->bin_count);   // aaaapppp other periods 
   write_log_comment(1);

   for(i=0; i<bins->bin_count; i++) {
      sprintf(log_text, "# %10.3f tau  %.4le (n=%ld)", 
      bins->adev_taus[i], bins->adev_bins[i], bins->adev_on[i]);
      write_log_comment(1);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
leaq 0x13670d(%rip), %rax    # 0x29d540
cmpq $0x0, (%rax)
jne 0x166e3e
jmp 0x16761e
leaq 0x1367af(%rip), %rax    # 0x29d5f4
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x166e52
jmp 0x16761e
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
movl $0x5, %ecx
cltd
idivl %ecx
movl %eax, -0xc(%rbp)
cmpl $0x3, -0xc(%rbp)
jne 0x166e7a
leaq 0x1ae02(%rip), %rax     # 0x181c73
movq %rax, -0x18(%rbp)
jmp 0x166f42
cmpl $0x2, -0xc(%rbp)
jne 0x166e90
leaq 0xe78c(%rip), %rax      # 0x175613
movq %rax, -0x18(%rbp)
jmp 0x166f40
cmpl $0x1, -0xc(%rbp)
jne 0x166ee8
leaq 0x135007(%rip), %rax    # 0x29bea4
cmpl $0x0, (%rax)
je 0x166eaf
leaq 0x31874(%rip), %rax     # 0x19871d
movq %rax, -0x18(%rbp)
jmp 0x166ee6
leaq 0x110bfa(%rip), %rax    # 0x277ab0
cmpq $0x10000, (%rax)        # imm = 0x10000
je 0x166ec9
callq 0x992e0
cmpl $0x0, %eax
je 0x166ed6
leaq 0x1ba00(%rip), %rax     # 0x1828d0
movq %rax, -0x18(%rbp)
jmp 0x166ee4
leaq 0x55e43(%rip), %rax     # 0x1bcd20
movq (%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x166ee6
jmp 0x166f3e
leaq 0x134fb5(%rip), %rax    # 0x29bea4
cmpl $0x0, (%rax)
je 0x166f01
leaq 0x31758(%rip), %rax     # 0x198653
movq %rax, -0x18(%rbp)
jmp 0x166f3c
leaq 0x110ba8(%rip), %rax    # 0x277ab0
cmpq $0x10000, (%rax)        # imm = 0x10000
je 0x166f1b
callq 0x992e0
cmpl $0x0, %eax
je 0x166f28
leaq 0x1b9b4(%rip), %rax     # 0x1828d6
movq %rax, -0x18(%rbp)
jmp 0x166f3a
leaq 0x55df1(%rip), %rax     # 0x1bcd20
movq 0xe8(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x166f3c
jmp 0x166f3e
jmp 0x166f40
jmp 0x166f42
leaq 0x134f8f(%rip), %rax    # 0x29bed8
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x5, %eax
jne 0x166f9b
leaq 0x99a5(%rip), %rax      # 0x17090a
movq %rax, -0x20(%rbp)
leaq 0x134da8(%rip), %rax    # 0x29bd18
movq (%rax), %rax
leaq 0x134da6(%rip), %rcx    # 0x29bd20
cvttsd2si (%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq 0x134f53(%rip), %rax    # 0x29bee0
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1674ee
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x166fe4
leaq 0x995c(%rip), %rax      # 0x17090a
movq %rax, -0x20(%rbp)
leaq 0x134daf(%rip), %rax    # 0x29bd68
movq (%rax), %rax
leaq 0x134dad(%rip), %rcx    # 0x29bd70
cvttsd2si (%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq 0x134f12(%rip), %rax    # 0x29bee8
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1674ec
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xa, %eax
jne 0x16702d
leaq 0x9913(%rip), %rax      # 0x17090a
movq %rax, -0x20(%rbp)
leaq 0x134db6(%rip), %rax    # 0x29bdb8
movq (%rax), %rax
leaq 0x134db4(%rip), %rcx    # 0x29bdc0
cvttsd2si (%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq 0x134ed1(%rip), %rax    # 0x29bef0
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1674ea
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xf, %eax
jne 0x167076
leaq 0x98ca(%rip), %rax      # 0x17090a
movq %rax, -0x20(%rbp)
leaq 0x134dbd(%rip), %rax    # 0x29be08
movq (%rax), %rax
leaq 0x134dbb(%rip), %rcx    # 0x29be10
cvttsd2si (%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq 0x134e90(%rip), %rax    # 0x29bef8
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1674e8
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x7, %eax
jne 0x1670bf
leaq 0x988b(%rip), %rax      # 0x170914
movq %rax, -0x20(%rbp)
leaq 0x134c84(%rip), %rax    # 0x29bd18
movq (%rax), %rax
leaq 0x134c82(%rip), %rcx    # 0x29bd20
cvttsd2si (%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq 0x134e2f(%rip), %rax    # 0x29bee0
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1674e6
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x2, %eax
jne 0x167108
leaq 0x9842(%rip), %rax      # 0x170914
movq %rax, -0x20(%rbp)
leaq 0x134c8b(%rip), %rax    # 0x29bd68
movq (%rax), %rax
leaq 0x134c89(%rip), %rcx    # 0x29bd70
cvttsd2si (%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq 0x134dee(%rip), %rax    # 0x29bee8
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1674e4
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xc, %eax
jne 0x167151
leaq 0x97f9(%rip), %rax      # 0x170914
movq %rax, -0x20(%rbp)
leaq 0x134c92(%rip), %rax    # 0x29bdb8
movq (%rax), %rax
leaq 0x134c90(%rip), %rcx    # 0x29bdc0
cvttsd2si (%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq 0x134dad(%rip), %rax    # 0x29bef0
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1674e2
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x11, %eax
jne 0x16719a
leaq 0x97b0(%rip), %rax      # 0x170914
movq %rax, -0x20(%rbp)
leaq 0x134c99(%rip), %rax    # 0x29be08
movq (%rax), %rax
leaq 0x134c97(%rip), %rcx    # 0x29be10
cvttsd2si (%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq 0x134d6c(%rip), %rax    # 0x29bef8
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1674e0
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x6, %eax
jne 0x1671e3
leaq 0x9762(%rip), %rax      # 0x17090f
movq %rax, -0x20(%rbp)
leaq 0x134b60(%rip), %rax    # 0x29bd18
movq (%rax), %rax
leaq 0x134b5e(%rip), %rcx    # 0x29bd20
cvttsd2si (%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq 0x134d0b(%rip), %rax    # 0x29bee0
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1674de
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x1, %eax
jne 0x16722c
leaq 0x9719(%rip), %rax      # 0x17090f
movq %rax, -0x20(%rbp)
leaq 0x134b67(%rip), %rax    # 0x29bd68
movq (%rax), %rax
leaq 0x134b65(%rip), %rcx    # 0x29bd70
cvttsd2si (%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq 0x134cca(%rip), %rax    # 0x29bee8
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1674dc
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xb, %eax
jne 0x167275
leaq 0x96d0(%rip), %rax      # 0x17090f
movq %rax, -0x20(%rbp)
leaq 0x134b6e(%rip), %rax    # 0x29bdb8
movq (%rax), %rax
leaq 0x134b6c(%rip), %rcx    # 0x29bdc0
cvttsd2si (%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq 0x134c89(%rip), %rax    # 0x29bef0
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1674da
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x10, %eax
jne 0x1672be
leaq 0x9687(%rip), %rax      # 0x17090f
movq %rax, -0x20(%rbp)
leaq 0x134b75(%rip), %rax    # 0x29be08
movq (%rax), %rax
leaq 0x134b73(%rip), %rcx    # 0x29be10
cvttsd2si (%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq 0x134c48(%rip), %rax    # 0x29bef8
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1674d8
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x8, %eax
jne 0x167307
leaq 0x9648(%rip), %rax      # 0x170919
movq %rax, -0x20(%rbp)
leaq 0x134a3c(%rip), %rax    # 0x29bd18
movq (%rax), %rax
leaq 0x134a3a(%rip), %rcx    # 0x29bd20
cvttsd2si (%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq 0x134be7(%rip), %rax    # 0x29bee0
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1674d6
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x3, %eax
jne 0x167350
leaq 0x95ff(%rip), %rax      # 0x170919
movq %rax, -0x20(%rbp)
leaq 0x134a43(%rip), %rax    # 0x29bd68
movq (%rax), %rax
leaq 0x134a41(%rip), %rcx    # 0x29bd70
cvttsd2si (%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq 0x134ba6(%rip), %rax    # 0x29bee8
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1674d4
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xd, %eax
jne 0x167399
leaq 0x95b6(%rip), %rax      # 0x170919
movq %rax, -0x20(%rbp)
leaq 0x134a4a(%rip), %rax    # 0x29bdb8
movq (%rax), %rax
leaq 0x134a48(%rip), %rcx    # 0x29bdc0
cvttsd2si (%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq 0x134b65(%rip), %rax    # 0x29bef0
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1674d2
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x12, %eax
jne 0x1673e2
leaq 0x956d(%rip), %rax      # 0x170919
movq %rax, -0x20(%rbp)
leaq 0x134a51(%rip), %rax    # 0x29be08
movq (%rax), %rax
leaq 0x134a4f(%rip), %rcx    # 0x29be10
cvttsd2si (%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
leaq 0x134b24(%rip), %rax    # 0x29bef8
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1674d0
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x9, %eax
jne 0x167419
leaq 0x9529(%rip), %rax      # 0x17091e
movq %rax, -0x20(%rbp)
movslq 0x34cf10(%rip), %rax    # 0x4b4310
movq %rax, -0x28(%rbp)
leaq 0x134ad5(%rip), %rax    # 0x29bee0
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1674ce
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x4, %eax
jne 0x16744d
leaq 0x94f2(%rip), %rax      # 0x17091e
movq %rax, -0x20(%rbp)
movslq 0x34d06d(%rip), %rax    # 0x4b44a4
movq %rax, -0x28(%rbp)
leaq 0x134aa6(%rip), %rax    # 0x29bee8
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1674cc
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xe, %eax
jne 0x167481
leaq 0x94be(%rip), %rax      # 0x17091e
movq %rax, -0x20(%rbp)
movslq 0x34d1cd(%rip), %rax    # 0x4b4638
movq %rax, -0x28(%rbp)
leaq 0x134a7a(%rip), %rax    # 0x29bef0
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1674ca
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x13, %eax
jne 0x1674b5
leaq 0x948a(%rip), %rax      # 0x17091e
movq %rax, -0x20(%rbp)
movslq 0x34d32d(%rip), %rax    # 0x4b47cc
movq %rax, -0x28(%rbp)
leaq 0x134a4e(%rip), %rax    # 0x29bef8
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1674c8
leaq 0x231b1(%rip), %rax     # 0x18a66d
movq %rax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
jmp 0x1674ca
jmp 0x1674cc
jmp 0x1674ce
jmp 0x1674d0
jmp 0x1674d2
jmp 0x1674d4
jmp 0x1674d6
jmp 0x1674d8
jmp 0x1674da
jmp 0x1674dc
jmp 0x1674de
jmp 0x1674e0
jmp 0x1674e2
jmp 0x1674e4
jmp 0x1674e6
jmp 0x1674e8
jmp 0x1674ea
jmp 0x1674ec
jmp 0x1674ee
leaq -0x50(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x9350
movb $0x1, %al
leaq 0x1105ac(%rip), %rcx    # 0x277ab0
cmpq $0x10000, (%rcx)        # imm = 0x10000
movb %al, -0x59(%rbp)
je 0x16751e
callq 0x992e0
cmpl $0x0, %eax
setne %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x167536
leaq -0x50(%rbp), %rdi
callq 0x9850
jmp 0x16754d
leaq 0x1105ab(%rip), %rax    # 0x277ae8
cmpl $0x4c, (%rax)
jne 0x16754b
leaq -0x50(%rbp), %rdi
callq 0x9850
jmp 0x16754d
leaq 0x1355ec(%rip), %rdi    # 0x29cb40
leaq 0xa841(%rip), %rsi      # 0x171d9c
movb $0x0, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
movq -0x18(%rbp), %rdx
leaq -0x50(%rbp), %rcx
movq -0x28(%rbp), %r8
movsd -0x58(%rbp), %xmm0
movq -0x8(%rbp), %rax
movl 0x648(%rax), %r9d
leaq 0x1355b1(%rip), %rdi    # 0x29cb40
leaq 0x3118f(%rip), %rsi     # 0x198725
movb $0x1, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x648(%rcx), %eax
jge 0x16761e
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movss 0x4(%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movss 0x194(%rax,%rcx,4), %xmm1
cvtss2sd %xmm1, %xmm1
movq -0x8(%rbp), %rax
movslq -0xc(%rbp), %rcx
movq 0x328(%rax,%rcx,8), %rdx
leaq 0x135545(%rip), %rdi    # 0x29cb40
leaq 0x31165(%rip), %rsi     # 0x198767
movb $0x2, %al
callq 0x9060
movl $0x1, %edi
callq 0x10cbe0
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x1675ae
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)