// File: /workspace/github_cpp_makefile_star2_O1/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 0x13ab0d(%rip), %rax    # 0x23e360
cmpq $0x0, (%rax)
je 0x103cb6
leaq 0x13abb0(%rip), %rax    # 0x23e414
cmpb $0x0, (%rax)
je 0x103cb6
movq %rdi, %rbx
movb (%rdi), %al
leal -0xf(%rax), %ecx
cmpb $0x5, %cl
jae 0x103886
leaq 0x1995b(%rip), %r14     # 0x11d1dc
jmp 0x10391b
leal -0xa(%rax), %ecx
cmpb $0x5, %cl
jae 0x10389a
leaq 0xd38d(%rip), %r14      # 0x110c22
jmp 0x10391b
addb $-0x5, %al
leaq 0x139421(%rip), %rcx    # 0x23ccc4
movl (%rcx), %ecx
cmpb $0x4, %al
ja 0x1038b6
testl %ecx, %ecx
je 0x1038c3
leaq 0x321fb(%rip), %r14     # 0x135aaf
jmp 0x10391b
testl %ecx, %ecx
je 0x1038ec
leaq 0x32124(%rip), %r14     # 0x1359e5
jmp 0x10391b
leaq 0x115006(%rip), %rax    # 0x2188d0
leaq 0x1a554(%rip), %r14     # 0x11de25
cmpq $0x10000, (%rax)        # imm = 0x10000
je 0x10391b
callq 0x701f2
testl %eax, %eax
jne 0x10391b
leaq 0x5a446(%rip), %rax     # 0x15dd30
jmp 0x103918
leaq 0x114fdd(%rip), %rax    # 0x2188d0
leaq 0x1a531(%rip), %r14     # 0x11de2b
cmpq $0x10000, (%rax)        # imm = 0x10000
je 0x10391b
callq 0x701f2
testl %eax, %eax
jne 0x10391b
movl $0xe8, %eax
addq 0x4c5f8(%rip), %rax     # 0x14ff10
movq (%rax), %r14
movzbl (%rbx), %eax
cmpq $0x13, %rax
ja 0x103ac9
leaq 0x27b09(%rip), %rcx     # 0x12b438
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x139249(%rip), %rax    # 0x23cb88
leaq 0x13924a(%rip), %rcx    # 0x23cb90
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x1393b3(%rip), %rax    # 0x23cd08
jmp 0x103b88
leaq 0x1392c7(%rip), %rax    # 0x23cc28
leaq 0x1392c8(%rip), %rcx    # 0x23cc30
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x1393a1(%rip), %rax    # 0x23cd18
jmp 0x103b40
movslq 0x3517a5(%rip), %r15    # 0x455128
leaq 0x139386(%rip), %rax    # 0x23cd10
jmp 0x103bc5
leaq 0x139242(%rip), %rax    # 0x23cbd8
leaq 0x139243(%rip), %rcx    # 0x23cbe0
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x139364(%rip), %rax    # 0x23cd10
jmp 0x103b40
movslq 0x3515dc(%rip), %r15    # 0x454f94
leaq 0x139349(%rip), %rax    # 0x23cd08
jmp 0x103bc5
leaq 0x13920d(%rip), %rax    # 0x23cbd8
leaq 0x13920e(%rip), %rcx    # 0x23cbe0
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x13932f(%rip), %rax    # 0x23cd10
jmp 0x103abd
movslq 0x351413(%rip), %r15    # 0x454e00
leaq 0x13930c(%rip), %rax    # 0x23cd00
jmp 0x103bc5
leaq 0x139188(%rip), %rax    # 0x23cb88
leaq 0x139189(%rip), %rcx    # 0x23cb90
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x1392f2(%rip), %rax    # 0x23cd08
jmp 0x103abd
leaq 0x139206(%rip), %rax    # 0x23cc28
leaq 0x139207(%rip), %rcx    # 0x23cc30
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x1392e0(%rip), %rax    # 0x23cd18
jmp 0x103b88
leaq 0x139144(%rip), %rax    # 0x23cb88
leaq 0x139145(%rip), %rcx    # 0x23cb90
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x1392ae(%rip), %rax    # 0x23cd08
jmp 0x103bae
leaq 0x1390d2(%rip), %rax    # 0x23cb38
leaq 0x1390d3(%rip), %rcx    # 0x23cb40
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x139284(%rip), %rax    # 0x23cd00
jmp 0x103abd
leaq 0x139103(%rip), %rax    # 0x23cb88
leaq 0x139104(%rip), %rcx    # 0x23cb90
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x13926d(%rip), %rax    # 0x23cd08
jmp 0x103b40
leaq 0x139181(%rip), %rax    # 0x23cc28
leaq 0x139182(%rip), %rcx    # 0x23cc30
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x13925b(%rip), %rax    # 0x23cd18
leaq 0x31f0f(%rip), %rcx     # 0x1359d3
jmp 0x103bcc
xorl %r15d, %r15d
leaq 0x139225(%rip), %rax    # 0x23ccf8
leaq 0x2370e(%rip), %rcx     # 0x1271e8
jmp 0x103bcc
leaq 0x139052(%rip), %rax    # 0x23cb38
leaq 0x139053(%rip), %rcx    # 0x23cb40
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x139204(%rip), %rax    # 0x23cd00
jmp 0x103b88
leaq 0x1390d0(%rip), %rax    # 0x23cbd8
leaq 0x1390d1(%rip), %rcx    # 0x23cbe0
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x1391f2(%rip), %rax    # 0x23cd10
jmp 0x103bae
leaq 0x13900e(%rip), %rax    # 0x23cb38
leaq 0x13900f(%rip), %rcx    # 0x23cb40
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x1391c0(%rip), %rax    # 0x23cd00
leaq 0x31e87(%rip), %rcx     # 0x1359ce
jmp 0x103bcc
leaq 0x1390d5(%rip), %rax    # 0x23cc28
leaq 0x1390d6(%rip), %rcx    # 0x23cc30
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x1391af(%rip), %rax    # 0x23cd18
jmp 0x103bae
leaq 0x139066(%rip), %rax    # 0x23cbd8
leaq 0x139067(%rip), %rcx    # 0x23cbe0
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x139188(%rip), %rax    # 0x23cd10
leaq 0x31e3a(%rip), %rcx     # 0x1359c9
jmp 0x103bcc
leaq 0x138fa0(%rip), %rax    # 0x23cb38
leaq 0x138fa1(%rip), %rcx    # 0x23cb40
cvttsd2si (%rcx), %r15
addq (%rax), %r15
leaq 0x139152(%rip), %rax    # 0x23cd00
leaq 0x1a2d3(%rip), %rcx     # 0x11de88
jmp 0x103bcc
movslq 0x3516fe(%rip), %r15    # 0x4552bc
leaq 0x139153(%rip), %rax    # 0x23cd18
leaq 0x31e0c(%rip), %rcx     # 0x1359d8
movsd (%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
movb 0x4(%rcx), %al
movb %al, -0x4c(%rbp)
movl (%rcx), %eax
movl %eax, -0x50(%rbp)
leaq 0x114ce9(%rip), %rax    # 0x2188d0
cmpq $0x10000, (%rax)        # imm = 0x10000
je 0x103bf9
callq 0x701f2
testl %eax, %eax
je 0x103c05
leaq 0x114d08(%rip), %rax    # 0x218908
cmpl $0x4c, (%rax)
jne 0x103c0e
leaq -0x50(%rbp), %rdi
callq 0x986c
leaq 0x139d4b(%rip), %r12    # 0x23d960
movw $0x23, (%r12)
movl $0x1, %edi
callq 0xc3105
movl 0x648(%rbx), %r9d
leaq 0x31e83(%rip), %rsi     # 0x135ab7
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 0xc3105
cmpl $0x0, 0x648(%rbx)
jle 0x103cb6
xorl %r12d, %r12d
leaq 0x139cf6(%rip), %r14    # 0x23d960
leaq 0x31e88(%rip), %r15     # 0x135af9
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 0xc3105
incq %r12
movslq 0x648(%rbx), %rax
cmpq %rax, %r12
jl 0x103c71
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq