// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathmsc.cpp
// Function: fetch_mtie_info(int, ADEV_INFO*)
int fetch_mtie_info(int id, struct ADEV_INFO *bins)
{
int i;
int count;
double val;
double period;
double max_val, min_val;

   // copy MTIE info into an ADEV_INFO type array for display

   max_val = (-(BIG_NUM));
   min_val = (BIG_NUM);

   bins->adev_type = PPS_ADEV;
   for(i=0; i<32; i++) {
      bins->adev_taus[i] = (float) 0;
      bins->adev_on[i] = (long) 0;
      bins->adev_bins[i] = (float) 0;
      bins->bin_count = 0;
      bins->adev_min = (float) min_val;
      bins->adev_max = (float) max_val;
   }

   if(id < 0) return 0;
   if(id > MAX_MTIE_CHANS) return 0;

   period = 1.0;
   if(id == CHA_MTIE) {
      bins->adev_type = A_MTIE;   //PPS_ADEV;
      period = pps_adev_period;
   }
   else if(id == CHB_MTIE) {
      bins->adev_type = B_MTIE;   //OSC_ADEV;
      period = osc_adev_period;
   }
   else if(id == CHC_MTIE) {
      bins->adev_type = C_MTIE;   //CHC_ADEV;
      period = chc_adev_period;
   }
   else if(id == CHD_MTIE) {
      bins->adev_type = D_MTIE;   //CHD_ADEV;
      period = chd_adev_period;
   }
   else return 0;

   count = 0;
   for(i=0; i<32; i++) {
      if(mtie[id][i] == (-BIG_NUM)) break;
      val = (float) (mtie[id][i] / 1.0E9);
if((i == 0) && (mtie[id][0] > mtie[id][1])) val = (float) (mtie[id][1] / 1.0E9); 

      ++count;
      bins->bin_count = count;
      bins->adev_taus[i] = ((float) pow2[i]) * (float) period;
      bins->adev_on[i] = mtie_intervals[id][i];
if(bins->adev_on[i] == 0) bins->adev_on[i] = 1;
      bins->adev_bins[i] = (float) val;
      if(val > max_val) max_val = val;
      if(val < min_val) min_val = val;
   }
   bins->adev_min = (float) min_val;
   bins->adev_max = (float) max_val;

   return count;
}

// Assembly:
movb $0x5, (%rsi)
andl $0x0, 0x648(%rsi)
movabsq $0x65, %rax
movabsq $-0x105e70f7905e70f8, %rcx # imm = 0xEFA18F086FA18F08
cmpq $0x85, %rax
je 0xe870c
andl $0x0, -0x190(%rsi,%rax,4)
andq $0x0, (%rsi,%rax,8)
andl $0x0, (%rsi,%rax,4)
movq %rcx, 0x64c(%rsi)
incq %rax
jmp 0xe86e7
xorl %eax, %eax
cmpl $0x3, %edi
ja 0xe8851
pushq %rbp
movq %rsp, %rbp
leal (,%rdi,8), %ecx
movl $0x130e0409, %eax       # imm = 0x130E0409
shrl %cl, %eax
movl %edi, %edx
leaq 0x51506(%rip), %rcx     # 0x139c38
movq (%rcx,%rdx,8), %rcx
movb %al, (%rsi)
imulq $0x328, %rdx, %rax      # imm = 0x328
cvtsd2ss (%rcx), %xmm0
leaq 0x355906(%rip), %rcx    # 0x43e050
addq %rax, %rcx
imulq $0x194, %rdx, %rax      # imm = 0x194
leaq 0x3565c5(%rip), %rdx    # 0x43ed20
addq %rax, %rdx
movsd 0xd14a(%rip), %xmm1     # 0xf58b0
movsd 0x2df22(%rip), %xmm2    # 0x116690
movabsq $-0x20, %rdi
leaq 0x355731(%rip), %r8     # 0x43deb0
movl $0x20, %eax
movsd 0xa89c(%rip), %xmm4     # 0xf3028
movapd %xmm2, %xmm3
testq %rdi, %rdi
je 0xe8838
movsd 0x100(%rcx,%rdi,8), %xmm5
ucomisd %xmm2, %xmm5
jne 0xe87ae
jnp 0xe8833
cmpq $-0x20, %rdi
jne 0xe87c7
movsd (%rcx), %xmm7
movsd 0x8(%rcx), %xmm6
ucomisd %xmm6, %xmm7
jbe 0xe87c7
movapd %xmm6, %xmm5
divsd %xmm4, %xmm5
cvtsd2ss %xmm5, %xmm5
cvtss2sd %xmm5, %xmm6
leal 0x21(%rdi), %r9d
movl %r9d, 0x648(%rsi)
cvtsi2ssl (%r8), %xmm7
mulss %xmm0, %xmm7
movss %xmm7, 0x84(%rsi,%rdi,4)
movl 0x80(%rdx,%rdi,4), %r9d
cmpl $0x1, %r9d
adcl $0x0, %r9d
movslq %r9d, %r9
movq %r9, 0x428(%rsi,%rdi,8)
movss %xmm5, 0x214(%rsi,%rdi,4)
movaps %xmm6, %xmm5
maxsd %xmm3, %xmm5
minsd %xmm1, %xmm6
incq %rdi
addq $0x4, %r8
movapd %xmm5, %xmm3
movapd %xmm6, %xmm1
jmp 0xe8790
addl $0x20, %edi
movl %edi, %eax
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x64c(%rsi)
cvtsd2ss %xmm3, %xmm0
movss %xmm0, 0x650(%rsi)
popq %rbp
retq