// File: /workspace/github_cpp_makefile_star2_O2/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 0x196023(%rip), %rax    # 0x228390
movq (%rax), %rdi
testq %rdi, %rdi
je 0x92390
movl 0x2c7c75(%rip), %edx    # 0x359ff0
leaq 0x7d316(%rip), %rsi     # 0x10f698
leaq 0x2c47b7(%rip), %rcx    # 0x356b40
xorl %eax, %eax
callq 0x9560
movl $0x4479c000, -0xc(%rbp) # imm = 0x4479C000
movl 0x2c7c53(%rip), %eax    # 0x359ff0
cmpl $0x1, %eax
je 0x92478
cmpl $0x2, %eax
jne 0x924a9
leaq 0x2c478a(%rip), %rdi    # 0x356b40
leaq 0x7d2f8(%rip), %rsi     # 0x10f6b5
callq 0x9090
testq %rax, %rax
je 0x9241a
movq %rax, %rbx
addq $0x7, %rbx
leaq 0x7d2e8(%rip), %rsi     # 0x10f6bd
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
jne 0x9241a
movq %rbx, %rdi
callq 0x9470
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
mulsd 0x60c2e(%rip), %xmm0    # 0xf3028
leaq 0x2643bf(%rip), %rax    # 0x2f67c0
movsd %xmm0, (%rax)
leaq 0x264e28(%rip), %rax    # 0x2f7234
pushq $0xa
popq %rcx
movl %ecx, (%rax)
leaq 0x264e30(%rip), %rax    # 0x2f7248
movl %ecx, (%rax)
leaq 0x2c471f(%rip), %rdi    # 0x356b40
leaq 0x7d2a1(%rip), %rsi     # 0x10f6c9
callq 0x9090
testq %rax, %rax
je 0x92578
movq %rax, %rbx
addq $0x6, %rbx
leaq 0x7d279(%rip), %rsi     # 0x10f6bd
movq %rbx, %rdi
callq 0x9090
testq %rax, %rax
jne 0x92578
movq %rbx, %rdi
callq 0x9470
cvtsd2ss %xmm0, %xmm0
leaq 0x172bac(%rip), %rax    # 0x205014
movss %xmm0, (%rax)
leaq 0x172b9d(%rip), %rax    # 0x205010
jmp 0x92572
leaq 0x2c46c1(%rip), %rdi    # 0x356b40
pushq $0x3d
popq %rsi
callq 0x9100
testq %rax, %rax
je 0x92532
incq %rax
movq %rax, %rdi
callq 0x9470
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0xc(%rbp)
jmp 0x92532
subq $0x8, %rsp
leaq -0x14(%rbp), %r10
leaq -0xc(%rbp), %r11
leaq -0x18(%rbp), %rbx
leaq 0x2c4680(%rip), %rdi    # 0x356b40
leaq 0x7d209(%rip), %rsi     # 0x10f6d0
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 0x9350
addq $0x20, %rsp
leaq 0x172b2a(%rip), %rax    # 0x205018
cmpl $0x0, (%rax)
setne %dl
leaq 0x264f9c(%rip), %rax    # 0x2f7497
movb (%rax), %cl
cmpb $0xa, %cl
sete %sil
testb %sil, %dl
jne 0x92532
movss -0x10(%rbp), %xmm0
testb %cl, %cl
jne 0x92521
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x9251c
jnp 0x92521
movb $0x3, (%rax)
jmp 0x92532
testb %cl, %cl
je 0x92532
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x92532
jp 0x92532
movb $0x0, (%rax)
cvtss2sd -0xc(%rbp), %xmm0
movaps 0x60c52(%rip), %xmm1    # 0xf3190
andps %xmm0, %xmm1
ucomisd 0x75d8f(%rip), %xmm1    # 0x1082d8
ja 0x92578
mulsd 0x60ad5(%rip), %xmm0    # 0xf3028
leaq 0x264266(%rip), %rax    # 0x2f67c0
movsd %xmm0, (%rax)
leaq 0x264ccf(%rip), %rax    # 0x2f7234
movl $0xa, (%rax)
leaq 0x264cd6(%rip), %rax    # 0x2f7248
movl $0xa, (%rax)
addq $0x28, %rsp
popq %rbx
popq %rbp
retq