// File: 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:
pushq %rbp
movq %rsp, %rbp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movsd 0x10c9d(%rip), %xmm0    # 0x16f060
movsd %xmm0, -0x30(%rbp)
movsd 0x10c88(%rip), %xmm0    # 0x16f058
movsd %xmm0, -0x38(%rbp)
movq -0x10(%rbp), %rax
movb $0x5, (%rax)
movl $0x0, -0x14(%rbp)
cmpl $0x20, -0x14(%rbp)
jge 0x15e468
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
xorps %xmm0, %xmm0
movss %xmm0, 0x4(%rax,%rcx,4)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq $0x0, 0x328(%rax,%rcx,8)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
xorps %xmm0, %xmm0
movss %xmm0, 0x194(%rax,%rcx,4)
movq -0x10(%rbp), %rax
movl $0x0, 0x648(%rax)
movsd -0x38(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x64c(%rax)
movsd -0x30(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x650(%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x15e3e3
cmpl $0x0, -0x8(%rbp)
jge 0x15e47a
movl $0x0, -0x4(%rbp)
jmp 0x15e736
cmpl $0x4, -0x8(%rbp)
jle 0x15e48c
movl $0x0, -0x4(%rbp)
jmp 0x15e736
movsd 0x10bd4(%rip), %xmm0    # 0x16f068
movsd %xmm0, -0x28(%rbp)
cmpl $0x0, -0x8(%rbp)
jne 0x15e4b8
movq -0x10(%rbp), %rax
movb $0x9, (%rax)
leaq 0x13da33(%rip), %rax    # 0x29bee0
movsd (%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0x15e527
cmpl $0x1, -0x8(%rbp)
jne 0x15e4d7
movq -0x10(%rbp), %rax
movb $0x4, (%rax)
leaq 0x13da1c(%rip), %rax    # 0x29bee8
movsd (%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0x15e525
cmpl $0x2, -0x8(%rbp)
jne 0x15e4f6
movq -0x10(%rbp), %rax
movb $0xe, (%rax)
leaq 0x13da05(%rip), %rax    # 0x29bef0
movsd (%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0x15e523
cmpl $0x3, -0x8(%rbp)
jne 0x15e515
movq -0x10(%rbp), %rax
movb $0x13, (%rax)
leaq 0x13d9ee(%rip), %rax    # 0x29bef8
movsd (%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0x15e521
movl $0x0, -0x4(%rbp)
jmp 0x15e736
jmp 0x15e523
jmp 0x15e525
jmp 0x15e527
movl $0x0, -0x18(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x20, -0x14(%rbp)
jge 0x15e706
movslq -0x8(%rbp), %rcx
leaq 0x3550f6(%rip), %rax    # 0x4b3640
imulq $0x328, %rcx, %rcx      # imm = 0x328
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x10afb(%rip), %xmm1    # 0x16f060
ucomisd %xmm1, %xmm0
jne 0x15e572
jp 0x15e572
jmp 0x15e706
movslq -0x8(%rbp), %rcx
leaq 0x3550c3(%rip), %rax    # 0x4b3640
imulq $0x328, %rcx, %rcx      # imm = 0x328
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x10a90(%rip), %xmm1    # 0x16f028
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x20(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x15e617
movslq -0x8(%rbp), %rcx
leaq 0x355086(%rip), %rax    # 0x4b3640
imulq $0x328, %rcx, %rcx      # imm = 0x328
addq %rcx, %rax
movsd (%rax), %xmm0
movslq -0x8(%rbp), %rcx
leaq 0x35506d(%rip), %rax    # 0x4b3640
imulq $0x328, %rcx, %rcx      # imm = 0x328
addq %rcx, %rax
ucomisd 0x8(%rax), %xmm0
jbe 0x15e617
movslq -0x8(%rbp), %rcx
leaq 0x355051(%rip), %rax    # 0x4b3640
imulq $0x328, %rcx, %rcx      # imm = 0x328
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd 0x10a22(%rip), %xmm1    # 0x16f028
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x20(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x648(%rax)
movslq -0x14(%rbp), %rcx
leaq 0x354e68(%rip), %rax    # 0x4b34a0
cvtsi2ssl (%rax,%rcx,4), %xmm0
movsd -0x28(%rbp), %xmm1
cvtsd2ss %xmm1, %xmm1
mulss %xmm1, %xmm0
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movss %xmm0, 0x4(%rax,%rcx,4)
movslq -0x8(%rbp), %rcx
leaq 0x355cad(%rip), %rax    # 0x4b4310
imulq $0x194, %rcx, %rcx      # imm = 0x194
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
movslq (%rax,%rcx,4), %rdx
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq %rdx, 0x328(%rax,%rcx,8)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
cmpq $0x0, 0x328(%rax,%rcx,8)
jne 0x15e6ac
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq $0x1, 0x328(%rax,%rcx,8)
movsd -0x20(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movss %xmm0, 0x194(%rax,%rcx,4)
movsd -0x20(%rbp), %xmm0
ucomisd -0x30(%rbp), %xmm0
jbe 0x15e6dc
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x20(%rbp), %xmm1
movsd -0x38(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x15e6f6
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
jmp 0x15e6f8
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x15e535
movsd -0x38(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x64c(%rax)
movsd -0x30(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x10(%rbp), %rax
movss %xmm0, 0x650(%rax)
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax,%rax)