// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %rbx
subq $0x28, %rsp
leaq 0x19d096(%rip), %rax    # 0x23e390
movq (%rax), %rdi
testq %rdi, %rdi
je 0xa131d
movl 0x2cece8(%rip), %edx    # 0x36fff0
leaq 0x84361(%rip), %rsi     # 0x125670
leaq 0x2cb82a(%rip), %rcx    # 0x36cb40
xorl %eax, %eax
callq 0x9560
movl $0x4479c000, -0xc(%rbp) # imm = 0x4479C000
movl 0x2cecc6(%rip), %eax    # 0x36fff0
cmpl $0x1, %eax
je 0xa140c
cmpl $0x2, %eax
jne 0xa143f
leaq 0x2cb7fd(%rip), %rdi    # 0x36cb40
leaq 0x84343(%rip), %rsi     # 0x12568d
callq 0x9090
testq %rax, %rax
je 0xa13ae
movq %rax, %rbx
addq $0x7, %rbx
leaq 0x84333(%rip), %rsi     # 0x125695
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
jne 0xa13ae
movq %rbx, %rdi
callq 0x9470
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm1
mulsd 0x67ca1(%rip), %xmm1    # 0x109028
movss %xmm0, -0xc(%rbp)
leaq 0x26b42d(%rip), %rax    # 0x30c7c0
movsd %xmm1, (%rax)
leaq 0x26be96(%rip), %rax    # 0x30d234
movl $0xa, %ecx
movl %ecx, (%rax)
leaq 0x26be9c(%rip), %rax    # 0x30d248
movl %ecx, (%rax)
leaq 0x2cb78b(%rip), %rdi    # 0x36cb40
leaq 0x842e5(%rip), %rsi     # 0x1256a1
callq 0x9090
testq %rax, %rax
je 0xa1511
movq %rax, %rbx
addq $0x6, %rbx
leaq 0x842bd(%rip), %rsi     # 0x125695
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
jne 0xa1511
movq %rbx, %rdi
callq 0x9470
cvtsd2ss %xmm0, %xmm0
leaq 0x179c18(%rip), %rax    # 0x21b014
movss %xmm0, (%rax)
leaq 0x179c09(%rip), %rax    # 0x21b010
jmp 0xa150b
leaq 0x2cb72d(%rip), %rdi    # 0x36cb40
movl $0x3d, %esi
callq 0x9100
testq %rax, %rax
je 0xa14c8
incq %rax
movq %rax, %rdi
callq 0x9470
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0xc(%rbp)
jmp 0xa14c8
subq $0x8, %rsp
leaq -0x14(%rbp), %r10
leaq -0xc(%rbp), %r11
leaq -0x18(%rbp), %rbx
leaq 0x2cb6ea(%rip), %rdi    # 0x36cb40
leaq 0x8424b(%rip), %rsi     # 0x1256a8
leaq -0x24(%rbp), %rdx
leaq -0x20(%rbp), %rcx
leaq -0x1c(%rbp), %r8
leaq -0x10(%rbp), %r9
xorl %eax, %eax
pushq %r10
pushq %r11
pushq %rbx
callq 0x9360
addq $0x20, %rsp
leaq 0x179b94(%rip), %rax    # 0x21b018
cmpl $0x0, (%rax)
setne %dl
leaq 0x26c006(%rip), %rax    # 0x30d497
movb (%rax), %cl
cmpb $0xa, %cl
sete %sil
testb %sil, %dl
jne 0xa14c8
movss -0x10(%rbp), %xmm0
testb %cl, %cl
jne 0xa14b7
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0xa14b2
jnp 0xa14b7
movb $0x3, (%rax)
jmp 0xa14c8
testb %cl, %cl
je 0xa14c8
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0xa14c8
jp 0xa14c8
movb $0x0, (%rax)
xorps %xmm0, %xmm0
cvtss2sd -0xc(%rbp), %xmm0
movaps 0x67ca9(%rip), %xmm1    # 0x109180
andps %xmm0, %xmm1
ucomisd 0x7ccd6(%rip), %xmm1    # 0x11e1b8
ja 0xa1511
mulsd 0x67b3c(%rip), %xmm0    # 0x109028
leaq 0x26b2cd(%rip), %rax    # 0x30c7c0
movsd %xmm0, (%rax)
leaq 0x26bd36(%rip), %rax    # 0x30d234
movl $0xa, (%rax)
leaq 0x26bd3d(%rip), %rax    # 0x30d248
movl $0xa, (%rax)
addq $0x28, %rsp
popq %rbx
popq %rbp
retq