// File: /workspace/github_cpp_makefile_star2_O1/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)
movl $0x0, 0x648(%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x4(%rsi)
movups %xmm0, 0x14(%rsi)
movups %xmm0, 0x24(%rsi)
movups %xmm0, 0x34(%rsi)
movups %xmm0, 0x44(%rsi)
movups %xmm0, 0x54(%rsi)
movups %xmm0, 0x64(%rsi)
movups %xmm0, 0x74(%rsi)
movups %xmm0, 0x194(%rsi)
movups %xmm0, 0x1a4(%rsi)
movups %xmm0, 0x1b4(%rsi)
movups %xmm0, 0x1c4(%rsi)
movups %xmm0, 0x1d4(%rsi)
movups %xmm0, 0x1e4(%rsi)
movups %xmm0, 0x1f4(%rsi)
movups %xmm0, 0x204(%rsi)
movabsq $-0x105e70f7905e70f8, %rax # imm = 0xEFA18F086FA18F08
movq %rax, 0x64c(%rsi)
movl $0x65, %eax
movq $0x0, (%rsi,%rax,8)
incq %rax
cmpq $0x85, %rax
jne 0xfdf61
xorl %eax, %eax
cmpl $0x3, %edi
ja 0xfe0c1
pushq %rbp
movq %rsp, %rbp
pushq %rbx
leal (,%rdi,8), %ecx
movl $0x130e0409, %eax       # imm = 0x130E0409
shrl %cl, %eax
movl %edi, %r8d
leaq 0x51c94(%rip), %rcx     # 0x14fc30
movq (%rcx,%r8,8), %r9
movb %al, (%rsi)
imulq $0x328, %r8, %rcx       # imm = 0x328
leaq 0x356180(%rip), %rdx    # 0x454130
leaq (%rdx,%rcx), %rdi
xorps %xmm0, %xmm0
cvtsd2ss (%r9), %xmm0
imulq $0x194, %r8, %r8        # imm = 0x194
movsd 0x2e6bd(%rip), %xmm1    # 0x12c688
movsd 0xd855(%rip), %xmm4     # 0x10b828
leaq 0x355fb6(%rip), %r9     # 0x453f90
xorl %eax, %eax
movsd 0xb044(%rip), %xmm2     # 0x109028
leaq 0x356e15(%rip), %r10    # 0x454e00
movapd %xmm1, %xmm6
movapd %xmm6, %xmm5
movapd %xmm4, %xmm3
leaq (%rcx,%rax,8), %r11
movsd (%rdx,%r11), %xmm4
ucomisd %xmm1, %xmm4
jne 0xfe00d
jnp 0xfe099
testq %rax, %rax
jne 0xfe025
movsd (%rdi), %xmm7
movsd 0x8(%rdi), %xmm6
ucomisd %xmm6, %xmm7
jbe 0xfe025
movapd %xmm6, %xmm4
divsd %xmm2, %xmm4
xorps %xmm6, %xmm6
cvtsd2ss %xmm4, %xmm6
xorps %xmm4, %xmm4
cvtss2sd %xmm6, %xmm4
leaq 0x1(%rax), %r11
movl %r11d, 0x648(%rsi)
xorps %xmm7, %xmm7
cvtsi2ssl (%r9), %xmm7
mulss %xmm0, %xmm7
movss %xmm7, 0x4(%rsi,%rax,4)
leaq (%r8,%rax,4), %rbx
movl (%r10,%rbx), %ebx
cmpl $0x1, %ebx
adcl $0x0, %ebx
movslq %ebx, %rbx
movq %rbx, 0x328(%rsi,%rax,8)
movss %xmm6, 0x194(%rsi,%rax,4)
movaps %xmm4, %xmm6
maxsd %xmm5, %xmm6
minsd %xmm3, %xmm4
addq $0x4, %r9
movq %r11, %rax
cmpq $0x20, %r11
jne 0xfdfef
movl $0x20, %eax
jmp 0xfe0a1
movapd %xmm5, %xmm6
movapd %xmm3, %xmm4
xorps %xmm0, %xmm0
cvtsd2ss %xmm4, %xmm0
movss %xmm0, 0x64c(%rsi)
xorps %xmm0, %xmm0
cvtsd2ss %xmm6, %xmm0
movss %xmm0, 0x650(%rsi)
popq %rbx
popq %rbp
retq