// File: jkingan[P]ladyheather/heathgps.cpp
// Function: decode_uccm_loop()
void decode_uccm_loop()
{
float dac_link;
float dac_avg;
float dac_gps;    // same as dac_link?
float freq_corr;  // always 0.0?
float link_off;   // changes
float freq_diff;  // changes
float freq_frac;  // 0 during recovery
char *s;

if(debug_file) fprintf(debug_file, "decode_uccm_loop fmt:%d: %s\n", loop_fmt, scpi_status_line);

   freq_diff = 999.0;

   if(loop_fmt == SAMSUNG_FMT) {
      s = strstr(scpi_status_line, "OCXO : ");
      if(s) { 
         if(strstr(s+7, "UNAVAILABLE")) ;
         else {
            freq_diff = (float) atof(s+7);
            osc_offset = (double) (freq_diff*1.0E9);
            // adevs of loop value is done in secondary_timing();
            have_osc_offset = 10;
            have_rcvr_osc = 10;
         }
      }

      s = strstr(scpi_status_line, "EXT : ");
      if(s) {   // !!!! do something with this value
         if(strstr(s+6, "UNAVAILABLE")) ;
         else { 
            uccm_ext_val = (float) atof(s+6);
            have_uccm_ext_val = 10;
         }
      }
      return;
   }
   else if(loop_fmt == SYMMETRICOM_FMT) {  // Symmetricom
      s = strstr(scpi_status_line, "=");
      if(s) {
         freq_diff = (float) atof(s+1);
      }
   }
   else {  // Trimble
      sscanf(scpi_status_line, "%g %g %g %g %g %g %g", 
         &dac_link, &dac_avg, &dac_gps, &freq_corr, &link_off, &freq_diff, &freq_frac);

      if(saw_uccm_dmode && (discipline_mode == DIS_MODE_WARMUP)) ;
      else if((discipline_mode == DIS_MODE_NORMAL) && (freq_corr != 0.0F)) {
         discipline_mode = DIS_MODE_MANUAL_HOLD;
      }
      else if(discipline_mode && (freq_corr == 0.0F)) {
         discipline_mode = DIS_MODE_NORMAL;
      }
   }

   if(freq_diff < (-2.00E-7)) ;      // bogus value -2.79E-7 shows up occasionally on Trimble
   else if(freq_diff > (2.00E-7)) ;  // bogus value shows up occasionally on Trimble
   else {
      osc_offset = (double) (freq_diff*1.0E9);
      // adevs of loop value is done in secondary_timing();
      have_osc_offset = 10;
      have_rcvr_osc = 10;
   }

//sprintf(plot_title, "%g %g %g %g %g %g %g", 
//dac_link, dac_avg, dac_gps, freq_corr, link_off, freq_diff, freq_frac);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
leaq 0x1c2621(%rip), %rax    # 0x29d570
cmpq $0x0, (%rax)
je 0xdaf7a
leaq 0x1c2614(%rip), %rax    # 0x29d570
movq (%rax), %rdi
movl 0x2f425b(%rip), %edx    # 0x3cf1c0
leaq 0xadad8(%rip), %rsi     # 0x188a44
leaq 0x2f0d9d(%rip), %rcx    # 0x3cbd10
movb $0x0, %al
callq 0x9550
movss 0x969b2(%rip), %xmm0    # 0x171934
movss %xmm0, -0x18(%rbp)
cmpl $0x2, 0x2f4232(%rip)    # 0x3cf1c0
jne 0xdb08a
leaq 0x2f0d75(%rip), %rdi    # 0x3cbd10
leaq 0xadabf(%rip), %rsi     # 0x188a61
callq 0x9090
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xdb020
movq -0x28(%rbp), %rdi
addq $0x7, %rdi
leaq 0xadaa8(%rip), %rsi     # 0x188a69
callq 0x9090
cmpq $0x0, %rax
je 0xdafce
jmp 0xdb01e
movq -0x28(%rbp), %rdi
addq $0x7, %rdi
callq 0x9480
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x18(%rbp)
movss -0x18(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x94033(%rip), %xmm1    # 0x16f028
mulsd %xmm1, %xmm0
leaq 0x2909a0(%rip), %rax    # 0x36b9a0
movsd %xmm0, (%rax)
leaq 0x291409(%rip), %rax    # 0x36c414
movl $0xa, (%rax)
leaq 0x291410(%rip), %rax    # 0x36c428
movl $0xa, (%rax)
jmp 0xdb020
leaq 0x2f0ce9(%rip), %rdi    # 0x3cbd10
leaq 0xada47(%rip), %rsi     # 0x188a75
callq 0x9090
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xdb085
movq -0x28(%rbp), %rdi
addq $0x6, %rdi
leaq 0xada1c(%rip), %rsi     # 0x188a69
callq 0x9090
cmpq $0x0, %rax
je 0xdb05a
jmp 0xdb083
movq -0x28(%rbp), %rdi
addq $0x6, %rdi
callq 0x9480
cvtsd2ss %xmm0, %xmm0
leaq 0x19f182(%rip), %rax    # 0x27a1f4
movss %xmm0, (%rax)
leaq 0x19f173(%rip), %rax    # 0x27a1f0
movl $0xa, (%rax)
jmp 0xdb085
jmp 0xdb1ef
cmpl $0x1, 0x2f412f(%rip)    # 0x3cf1c0
jne 0xdb0cc
leaq 0x2f0c76(%rip), %rdi    # 0x3cbd10
leaq 0x971aa(%rip), %rsi     # 0x17224b
callq 0x9090
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xdb0c7
movq -0x28(%rbp), %rdi
addq $0x1, %rdi
callq 0x9480
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x18(%rbp)
jmp 0xdb17f
leaq 0x2f0c3d(%rip), %rdi    # 0x3cbd10
leaq 0xad9a2(%rip), %rsi     # 0x188a7c
leaq -0x4(%rbp), %rdx
leaq -0x8(%rbp), %rcx
leaq -0xc(%rbp), %r8
leaq -0x10(%rbp), %r9
leaq -0x14(%rbp), %r11
leaq -0x18(%rbp), %r10
leaq -0x1c(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movb $0x0, %al
callq 0x9370
leaq 0x19f0e6(%rip), %rax    # 0x27a1f8
cmpl $0x0, (%rax)
je 0xdb128
leaq 0x291559(%rip), %rax    # 0x36c677
movzbl (%rax), %eax
cmpl $0xa, %eax
jne 0xdb128
jmp 0xdb17d
leaq 0x291548(%rip), %rax    # 0x36c677
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0xdb154
movss -0x10(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0xdb148
jp 0xdb148
jmp 0xdb154
leaq 0x291528(%rip), %rax    # 0x36c677
movb $0x3, (%rax)
jmp 0xdb17b
leaq 0x29151c(%rip), %rax    # 0x36c677
cmpb $0x0, (%rax)
je 0xdb179
movss -0x10(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0xdb179
jp 0xdb179
leaq 0x291501(%rip), %rax    # 0x36c677
movb $0x0, (%rax)
jmp 0xdb17b
jmp 0xdb17d
jmp 0xdb17f
jmp 0xdb181
movss -0x18(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0xa7efe(%rip), %xmm0    # 0x183090
ucomisd %xmm1, %xmm0
jbe 0xdb19a
jmp 0xdb1ef
movss -0x18(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0xa7a9d(%rip), %xmm1    # 0x182c48
ucomisd %xmm1, %xmm0
jbe 0xdb1b3
jmp 0xdb1ed
movss -0x18(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x93e64(%rip), %xmm1    # 0x16f028
mulsd %xmm1, %xmm0
leaq 0x2907d1(%rip), %rax    # 0x36b9a0
movsd %xmm0, (%rax)
leaq 0x29123a(%rip), %rax    # 0x36c414
movl $0xa, (%rax)
leaq 0x291241(%rip), %rax    # 0x36c428
movl $0xa, (%rax)
jmp 0xdb1ef
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)