// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
leaq 0x13ab7a(%rip), %rax    # 0x228360
cmpq $0x0, (%rax)
je 0xedc33
leaq 0x13ac1d(%rip), %rax    # 0x228414
cmpb $0x0, (%rax)
je 0xedc33
movq %rdi, %rbx
movb (%rdi), %al
leal -0xf(%rax), %ecx
cmpb $0x5, %cl
jae 0xed819
leaq 0x19adc(%rip), %r14     # 0x1072f0
jmp 0xed8b0
leal -0xa(%rax), %ecx
cmpb $0x5, %cl
jae 0xed82d
leaq 0xd50e(%rip), %r14      # 0xfad36
jmp 0xed8ae
addb $-0x5, %al
leaq 0x13948e(%rip), %rcx    # 0x226cc4
movl (%rcx), %ecx
cmpb $0x4, %al
ja 0xed849
testl %ecx, %ecx
je 0xed856
leaq 0x3226d(%rip), %r14     # 0x11fab4
jmp 0xed8ae
testl %ecx, %ecx
je 0xed87f
leaq 0x3218d(%rip), %r14     # 0x11f9e1
jmp 0xed8ae
leaq 0x115073(%rip), %rax    # 0x2028d0
leaq 0x1a6d5(%rip), %r14     # 0x107f39
cmpq $0x10000, (%rax)        # imm = 0x10000
je 0xed8ae
callq 0x66b41
testl %eax, %eax
jne 0xed8ae
leaq 0x5a4b3(%rip), %rax     # 0x147d30
jmp 0xed8ab
leaq 0x11504a(%rip), %rax    # 0x2028d0
leaq 0x1a6b2(%rip), %r14     # 0x107f3f
cmpq $0x10000, (%rax)        # imm = 0x10000
je 0xed8ae
callq 0x66b41
testl %eax, %eax
jne 0xed8ae
movl $0xe8, %eax
addq 0x4c66d(%rip), %rax     # 0x139f18
movq (%rax), %r14
movb (%rbx), %al
cmpb $0x13, %al
ja 0xeda5c
movzbl %al, %eax
leaq 0x27a96(%rip), %rcx     # 0x115358
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x1392b6(%rip), %rax    # 0x226b88
leaq 0x1392b7(%rip), %rcx    # 0x226b90
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x139420(%rip), %rax    # 0x226d08
jmp 0xedb1b
leaq 0x139334(%rip), %rax    # 0x226c28
leaq 0x139335(%rip), %rcx    # 0x226c30
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x13940e(%rip), %rax    # 0x226d18
jmp 0xedad3
movslq 0x351732(%rip), %r15    # 0x43f048
leaq 0x1393f3(%rip), %rax    # 0x226d10
jmp 0xedb58
leaq 0x1392af(%rip), %rax    # 0x226bd8
leaq 0x1392b0(%rip), %rcx    # 0x226be0
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x1393d1(%rip), %rax    # 0x226d10
jmp 0xedad3
movslq 0x351569(%rip), %r15    # 0x43eeb4
leaq 0x1393b6(%rip), %rax    # 0x226d08
jmp 0xedb58
leaq 0x13927a(%rip), %rax    # 0x226bd8
leaq 0x13927b(%rip), %rcx    # 0x226be0
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x13939c(%rip), %rax    # 0x226d10
jmp 0xeda50
movslq 0x3513a0(%rip), %r15    # 0x43ed20
leaq 0x139379(%rip), %rax    # 0x226d00
jmp 0xedb58
leaq 0x1391f5(%rip), %rax    # 0x226b88
leaq 0x1391f6(%rip), %rcx    # 0x226b90
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x13935f(%rip), %rax    # 0x226d08
jmp 0xeda50
leaq 0x139273(%rip), %rax    # 0x226c28
leaq 0x139274(%rip), %rcx    # 0x226c30
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x13934d(%rip), %rax    # 0x226d18
jmp 0xedb1b
leaq 0x1391b1(%rip), %rax    # 0x226b88
leaq 0x1391b2(%rip), %rcx    # 0x226b90
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x13931b(%rip), %rax    # 0x226d08
jmp 0xedb41
leaq 0x13913f(%rip), %rax    # 0x226b38
leaq 0x139140(%rip), %rcx    # 0x226b40
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x1392f1(%rip), %rax    # 0x226d00
jmp 0xeda50
leaq 0x139170(%rip), %rax    # 0x226b88
leaq 0x139171(%rip), %rcx    # 0x226b90
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x1392da(%rip), %rax    # 0x226d08
jmp 0xedad3
leaq 0x1391ee(%rip), %rax    # 0x226c28
leaq 0x1391ef(%rip), %rcx    # 0x226c30
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x1392c8(%rip), %rax    # 0x226d18
leaq 0x6f4b(%rip), %rcx      # 0xf49a2
jmp 0xedb5f
leaq 0x139295(%rip), %rax    # 0x226cf8
leaq 0x31fea(%rip), %rcx     # 0x11fa54
xorl %r15d, %r15d
jmp 0xedb5f
leaq 0x1390bf(%rip), %rax    # 0x226b38
leaq 0x1390c0(%rip), %rcx    # 0x226b40
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x139271(%rip), %rax    # 0x226d00
jmp 0xedb1b
leaq 0x13913d(%rip), %rax    # 0x226bd8
leaq 0x13913e(%rip), %rcx    # 0x226be0
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x13925f(%rip), %rax    # 0x226d10
jmp 0xedb41
leaq 0x13907b(%rip), %rax    # 0x226b38
leaq 0x13907c(%rip), %rcx    # 0x226b40
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x13922d(%rip), %rax    # 0x226d00
leaq 0x6ec3(%rip), %rcx      # 0xf499d
jmp 0xedb5f
leaq 0x139142(%rip), %rax    # 0x226c28
leaq 0x139143(%rip), %rcx    # 0x226c30
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x13921c(%rip), %rax    # 0x226d18
jmp 0xedb41
leaq 0x1390d3(%rip), %rax    # 0x226bd8
leaq 0x1390d4(%rip), %rcx    # 0x226be0
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x1391f5(%rip), %rax    # 0x226d10
leaq 0x6e76(%rip), %rcx      # 0xf4998
jmp 0xedb5f
leaq 0x13900d(%rip), %rax    # 0x226b38
leaq 0x13900e(%rip), %rcx    # 0x226b40
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x1391bf(%rip), %rax    # 0x226d00
leaq 0x6e5f(%rip), %rcx      # 0xf49a7
jmp 0xedb5f
movslq 0x35168b(%rip), %r15    # 0x43f1dc
leaq 0x1391c0(%rip), %rax    # 0x226d18
leaq 0x6e4d(%rip), %rcx      # 0xf49ac
movsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movb 0x4(%rcx), %al
movb %al, -0x4c(%rbp)
movl (%rcx), %eax
movl %eax, -0x50(%rbp)
leaq 0x114d56(%rip), %rax    # 0x2028d0
cmpq $0x10000, (%rax)        # imm = 0x10000
je 0xedb8c
callq 0x66b41
testl %eax, %eax
je 0xedb98
leaq 0x114d75(%rip), %rax    # 0x202908
cmpl $0x4c, (%rax)
jne 0xedba1
leaq -0x50(%rbp), %rdi
callq 0x986c
leaq 0x139db8(%rip), %r12    # 0x227960
movw $0x23, (%r12)
pushq $0x1
popq %r13
movl %r13d, %edi
callq 0xb25f5
movl 0x648(%rbx), %r9d
leaq 0x31ef3(%rip), %rsi     # 0x11fabc
leaq -0x50(%rbp), %rcx
movq %r12, %rdi
movq %r14, %rdx
movq %r15, %r8
movsd -0x30(%rbp), %xmm0
movb $0x1, %al
callq 0x9060
movl %r13d, %edi
callq 0xb25f5
xorl %r15d, %r15d
leaq 0x31f0a(%rip), %r14     # 0x11fafe
movslq 0x648(%rbx), %rax
cmpq %rax, %r15
jge 0xedc33
cvtss2sd 0x4(%rbx,%r15,4), %xmm0
cvtss2sd 0x194(%rbx,%r15,4), %xmm1
movq 0x328(%rbx,%r15,8), %rdx
movq %r12, %rdi
movq %r14, %rsi
movb $0x2, %al
callq 0x9060
movl %r13d, %edi
callq 0xb25f5
incq %r15
jmp 0xedbf4
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq