// File: /workspace/github_cpp_makefile_star2_O3/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 %r12
pushq %rbx
subq $0x30, %rsp
leaq 0x13a456(%rip), %rax    # 0x23e360
cmpq $0x0, (%rax)
je 0x10436d
leaq 0x13a4f9(%rip), %rax    # 0x23e414
cmpb $0x0, (%rax)
je 0x10436d
movq %rdi, %rbx
movb (%rdi), %al
leal -0xf(%rax), %ecx
cmpb $0x5, %cl
jae 0x103f3d
leaq 0x19338(%rip), %r14     # 0x11d270
jmp 0x103fd4
leal -0xa(%rax), %ecx
cmpb $0x5, %cl
jae 0x103f51
leaq 0xcd6a(%rip), %r14      # 0x110cb6
jmp 0x103fd2
addb $-0x5, %al
leaq 0x138d6a(%rip), %rcx    # 0x23ccc4
movl (%rcx), %ecx
cmpb $0x4, %al
ja 0x103f6d
testl %ecx, %ecx
je 0x103f7a
leaq 0x31c3d(%rip), %r14     # 0x135ba8
jmp 0x103fd2
testl %ecx, %ecx
je 0x103fa3
leaq 0x31b5d(%rip), %r14     # 0x135ad5
jmp 0x103fd2
leaq 0x11494f(%rip), %rax    # 0x2188d0
leaq 0x19f31(%rip), %r14     # 0x11deb9
cmpq $0x10000, (%rax)        # imm = 0x10000
je 0x103fd2
callq 0x702e7
testl %eax, %eax
jne 0x103fd2
leaq 0x59d8f(%rip), %rax     # 0x15dd30
jmp 0x103fcf
leaq 0x114926(%rip), %rax    # 0x2188d0
leaq 0x19f0e(%rip), %r14     # 0x11debf
cmpq $0x10000, (%rax)        # imm = 0x10000
je 0x103fd2
callq 0x702e7
testl %eax, %eax
jne 0x103fd2
movl $0xe8, %eax
addq 0x4bf41(%rip), %rax     # 0x14ff10
movq (%rax), %r14
movb (%rbx), %al
cmpb $0x13, %al
ja 0x104180
movzbl %al, %eax
leaq 0x27522(%rip), %rcx     # 0x12b508
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x138b92(%rip), %rax    # 0x23cb88
leaq 0x138b93(%rip), %rcx    # 0x23cb90
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x138cfc(%rip), %rax    # 0x23cd08
jmp 0x10423f
leaq 0x138c10(%rip), %rax    # 0x23cc28
leaq 0x138c11(%rip), %rcx    # 0x23cc30
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x138cea(%rip), %rax    # 0x23cd18
jmp 0x1041f7
movslq 0x35100e(%rip), %r15    # 0x455048
leaq 0x138ccf(%rip), %rax    # 0x23cd10
jmp 0x10427c
leaq 0x138b8b(%rip), %rax    # 0x23cbd8
leaq 0x138b8c(%rip), %rcx    # 0x23cbe0
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x138cad(%rip), %rax    # 0x23cd10
jmp 0x1041f7
movslq 0x350e45(%rip), %r15    # 0x454eb4
leaq 0x138c92(%rip), %rax    # 0x23cd08
jmp 0x10427c
leaq 0x138b56(%rip), %rax    # 0x23cbd8
leaq 0x138b57(%rip), %rcx    # 0x23cbe0
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x138c78(%rip), %rax    # 0x23cd10
jmp 0x104174
movslq 0x350c7c(%rip), %r15    # 0x454d20
leaq 0x138c55(%rip), %rax    # 0x23cd00
jmp 0x10427c
leaq 0x138ad1(%rip), %rax    # 0x23cb88
leaq 0x138ad2(%rip), %rcx    # 0x23cb90
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x138c3b(%rip), %rax    # 0x23cd08
jmp 0x104174
leaq 0x138b4f(%rip), %rax    # 0x23cc28
leaq 0x138b50(%rip), %rcx    # 0x23cc30
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x138c29(%rip), %rax    # 0x23cd18
jmp 0x10423f
leaq 0x138a8d(%rip), %rax    # 0x23cb88
leaq 0x138a8e(%rip), %rcx    # 0x23cb90
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x138bf7(%rip), %rax    # 0x23cd08
jmp 0x104265
leaq 0x138a1b(%rip), %rax    # 0x23cb38
leaq 0x138a1c(%rip), %rcx    # 0x23cb40
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x138bcd(%rip), %rax    # 0x23cd00
jmp 0x104174
leaq 0x138a4c(%rip), %rax    # 0x23cb88
leaq 0x138a4d(%rip), %rcx    # 0x23cb90
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x138bb6(%rip), %rax    # 0x23cd08
jmp 0x1041f7
leaq 0x138aca(%rip), %rax    # 0x23cc28
leaq 0x138acb(%rip), %rcx    # 0x23cc30
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x138ba4(%rip), %rax    # 0x23cd18
leaq 0x31948(%rip), %rcx     # 0x135ac3
jmp 0x104283
leaq 0x138b71(%rip), %rax    # 0x23ccf8
leaq 0x319ba(%rip), %rcx     # 0x135b48
xorl %r15d, %r15d
jmp 0x104283
leaq 0x13899b(%rip), %rax    # 0x23cb38
leaq 0x13899c(%rip), %rcx    # 0x23cb40
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x138b4d(%rip), %rax    # 0x23cd00
jmp 0x10423f
leaq 0x138a19(%rip), %rax    # 0x23cbd8
leaq 0x138a1a(%rip), %rcx    # 0x23cbe0
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x138b3b(%rip), %rax    # 0x23cd10
jmp 0x104265
leaq 0x138957(%rip), %rax    # 0x23cb38
leaq 0x138958(%rip), %rcx    # 0x23cb40
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x138b09(%rip), %rax    # 0x23cd00
leaq 0x318c0(%rip), %rcx     # 0x135abe
jmp 0x104283
leaq 0x138a1e(%rip), %rax    # 0x23cc28
leaq 0x138a1f(%rip), %rcx    # 0x23cc30
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x138af8(%rip), %rax    # 0x23cd18
jmp 0x104265
leaq 0x1389af(%rip), %rax    # 0x23cbd8
leaq 0x1389b0(%rip), %rcx    # 0x23cbe0
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x138ad1(%rip), %rax    # 0x23cd10
leaq 0x31873(%rip), %rcx     # 0x135ab9
jmp 0x104283
leaq 0x1388e9(%rip), %rax    # 0x23cb38
leaq 0x1388ea(%rip), %rcx    # 0x23cb40
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x138a9b(%rip), %rax    # 0x23cd00
leaq 0x19cb0(%rip), %rcx     # 0x11df1c
jmp 0x104283
movslq 0x350f67(%rip), %r15    # 0x4551dc
leaq 0x138a9c(%rip), %rax    # 0x23cd18
leaq 0x31845(%rip), %rcx     # 0x135ac8
movsd (%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
movb 0x4(%rcx), %al
movb %al, -0x4c(%rbp)
movl (%rcx), %eax
movl %eax, -0x50(%rbp)
leaq 0x114632(%rip), %rax    # 0x2188d0
cmpq $0x10000, (%rax)        # imm = 0x10000
je 0x1042b0
callq 0x702e7
testl %eax, %eax
je 0x1042bc
leaq 0x114651(%rip), %rax    # 0x218908
cmpl $0x4c, (%rax)
jne 0x1042c5
leaq -0x50(%rbp), %rdi
callq 0x986c
leaq 0x139694(%rip), %r12    # 0x23d960
movw $0x23, (%r12)
movl $0x1, %edi
callq 0xc36e2
movl 0x648(%rbx), %r9d
leaq 0x318c5(%rip), %rsi     # 0x135bb0
leaq -0x50(%rbp), %rcx
movq %r12, %rdi
movq %r14, %rdx
movq %r15, %r8
movsd -0x28(%rbp), %xmm0
movb $0x1, %al
callq 0x9060
movl $0x1, %edi
callq 0xc36e2
cmpl $0x0, 0x648(%rbx)
jle 0x10436d
xorl %r12d, %r12d
leaq 0x13963f(%rip), %r14    # 0x23d960
leaq 0x318ca(%rip), %r15     # 0x135bf2
xorps %xmm0, %xmm0
cvtss2sd 0x4(%rbx,%r12,4), %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x194(%rbx,%r12,4), %xmm1
movq 0x328(%rbx,%r12,8), %rdx
movq %r14, %rdi
movq %r15, %rsi
movb $0x2, %al
callq 0x9060
movl $0x1, %edi
callq 0xc36e2
incq %r12
movslq 0x648(%rbx), %rax
cmpq %rax, %r12
jl 0x104328
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq