// File: /workspace/github_cpp_makefile_star2_O3/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 0x19ce86(%rip), %rax    # 0x23e390
movq (%rax), %rdi
testq %rdi, %rdi
je 0xa152d
movl 0x2cead8(%rip), %edx    # 0x36fff0
leaq 0x84231(%rip), %rsi     # 0x125750
leaq 0x2cb61a(%rip), %rcx    # 0x36cb40
xorl %eax, %eax
callq 0x9560
movl $0x4479c000, -0xc(%rbp) # imm = 0x4479C000
movl 0x2ceab6(%rip), %eax    # 0x36fff0
cmpl $0x1, %eax
je 0xa1617
cmpl $0x2, %eax
jne 0xa164a
leaq 0x2cb5ed(%rip), %rdi    # 0x36cb40
leaq 0x84213(%rip), %rsi     # 0x12576d
callq 0x9090
testq %rax, %rax
je 0xa15b9
movq %rax, %rbx
addq $0x7, %rbx
leaq 0x84203(%rip), %rsi     # 0x125775
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
jne 0xa15b9
movq %rbx, %rdi
callq 0x9470
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
mulsd 0x67a91(%rip), %xmm0    # 0x109028
leaq 0x26b222(%rip), %rax    # 0x30c7c0
movsd %xmm0, (%rax)
leaq 0x26bc8b(%rip), %rax    # 0x30d234
movl $0xa, %ecx
movl %ecx, (%rax)
leaq 0x26bc91(%rip), %rax    # 0x30d248
movl %ecx, (%rax)
leaq 0x2cb580(%rip), %rdi    # 0x36cb40
leaq 0x841ba(%rip), %rsi     # 0x125781
callq 0x9090
testq %rax, %rax
je 0xa171c
movq %rax, %rbx
addq $0x6, %rbx
leaq 0x84192(%rip), %rsi     # 0x125775
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
jne 0xa171c
movq %rbx, %rdi
callq 0x9470
cvtsd2ss %xmm0, %xmm0
leaq 0x179a0d(%rip), %rax    # 0x21b014
movss %xmm0, (%rax)
leaq 0x1799fe(%rip), %rax    # 0x21b010
jmp 0xa1716
leaq 0x2cb522(%rip), %rdi    # 0x36cb40
movl $0x3d, %esi
callq 0x9100
testq %rax, %rax
je 0xa16d3
incq %rax
movq %rax, %rdi
callq 0x9470
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0xc(%rbp)
jmp 0xa16d3
subq $0x8, %rsp
leaq -0x14(%rbp), %r10
leaq -0xc(%rbp), %r11
leaq -0x18(%rbp), %rbx
leaq 0x2cb4df(%rip), %rdi    # 0x36cb40
leaq 0x84120(%rip), %rsi     # 0x125788
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 0x179989(%rip), %rax    # 0x21b018
cmpl $0x0, (%rax)
setne %dl
leaq 0x26bdfb(%rip), %rax    # 0x30d497
movb (%rax), %cl
cmpb $0xa, %cl
sete %sil
testb %sil, %dl
jne 0xa16d3
movss -0x10(%rbp), %xmm0
testb %cl, %cl
jne 0xa16c2
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0xa16bd
jnp 0xa16c2
movb $0x3, (%rax)
jmp 0xa16d3
testb %cl, %cl
je 0xa16d3
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0xa16d3
jp 0xa16d3
movb $0x0, (%rax)
xorps %xmm0, %xmm0
cvtss2sd -0xc(%rbp), %xmm0
movaps 0x67aae(%rip), %xmm1    # 0x109190
andps %xmm0, %xmm1
ucomisd 0x7cb73(%rip), %xmm1    # 0x11e260
ja 0xa171c
mulsd 0x67931(%rip), %xmm0    # 0x109028
leaq 0x26b0c2(%rip), %rax    # 0x30c7c0
movsd %xmm0, (%rax)
leaq 0x26bb2b(%rip), %rax    # 0x30d234
movl $0xa, (%rax)
leaq 0x26bb32(%rip), %rax    # 0x30d248
movl $0xa, (%rax)
addq $0x28, %rsp
popq %rbx
popq %rbp
retq