// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heathgps.cpp
// Function: parse_gpsd_pps(char*, int)
void parse_gpsd_pps(char *s, int type)
{
double clock_sec, clock_nsec;
double real_sec, real_nsec;
double precision;

   // decode the PPS message - used to get info for the PPS plot

   saw_gpsd_pps |= type;
   if((saw_gpsd_pps & 0x01) && (type & 0x02)) { // pps takes priority over toff
      return;
   }
   pps_enabled = 1;
   have_pps_enable = 11;

   precision = 0;  // NTP precision
   clock_sec = real_sec = 0.0;
   clock_nsec = real_nsec = 0.0;

   while(s) {
      s = get_json_field(s);
      strcpy(gpsd_cmd, msg_field);
      if(gpsd_cmd[0] == 0) continue; 

      s = get_json_field(s);
log_gpsd_cmd();

      if(!strcmp(gpsd_cmd, "\"CLOCK_SEC\"")) {
         clock_sec = atof(msg_field);
      }
      else if(!strcmp(gpsd_cmd, "\"CLOCK_NSEC\"")) { 
         clock_nsec = atof(msg_field)*1.0E-9;
      }
      else if(!strcmp(gpsd_cmd, "\"REAL_SEC\"")) { 
         real_sec = atof(msg_field);
      }
      else if(!strcmp(gpsd_cmd, "\"REAL_NSEC\"")) { 
         real_nsec = atof(msg_field)*1.0E-9;
      }
      else if(!strcmp(gpsd_cmd, "\"PRECISION\"")) { // ntp style power of two seconds
         saw_gpsd_pre = 1;
         precision = atof(msg_field);
         precision = pow(2.0, precision);
      }
   }

   pps_offset = (clock_sec - real_sec);
   have_pps_offset = 8;
   have_rcvr_pps = 8;
   pps_offset += (clock_nsec - real_nsec);
   pps_offset *= 1.0E9;
//adadad   if(jitter_adev == 0) do_pps_adev(pps_offset);
if(debug_file) fprintf(debug_file, "pps offset:%.10f", pps_offset);

}

// Assembly:
leaq 0x174032(%rip), %rax    # 0x21b0ac
movl (%rax), %ecx
orl %esi, %ecx
movl %ecx, (%rax)
andl $0x2, %esi
shrl %esi
testl %ecx, %esi
jne 0xa72d7
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x266c78(%rip), %rax    # 0x30dd20
movb $0x1, (%rax)
leaq 0x26622a(%rip), %rax    # 0x30d2dc
movl $0xb, (%rax)
xorpd %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
leaq 0x2caf48(%rip), %r14    # 0x372010
leaq 0x294971(%rip), %r15    # 0x33ba40
movabsq $0x224345534e5f4b, %r13 # imm = 0x224345534E5F4B
leaq 0x10ecf6(%r13), %r12
xorps %xmm1, %xmm1
movsd %xmm1, -0x40(%rbp)
movsd %xmm1, -0x38(%rbp)
movsd %xmm0, -0x30(%rbp)
testq %rbx, %rbx
je 0xa7265
movq %rbx, %rdi
callq 0xa637e
movq %rax, %rbx
movq %r14, %rdi
movq %r15, %rsi
callq 0x9340
cmpb $0x0, 0x2caef8(%rip)    # 0x372010
je 0xa70f2
movq %rbx, %rdi
callq 0xa637e
movq %rax, %rbx
callq 0xa646a
movq 0x2caedf(%rip), %rax    # 0x372010
movabsq $0x535f4b434f4c4322, %rcx # imm = 0x535F4B434F4C4322
xorq %rcx, %rax
movl 0x2caed4(%rip), %ecx    # 0x372018
xorq $0x224345, %rcx         # imm = 0x224345
orq %rax, %rcx
je 0xa7239
movq 0x2caeb5(%rip), %rax    # 0x372010
movabsq $0x4e5f4b434f4c4322, %rcx # imm = 0x4E5F4B434F4C4322
xorq %rcx, %rax
movq 0x2caea6(%rip), %rcx    # 0x372015
xorq %r13, %rcx
orq %rax, %rcx
je 0xa7250
movq 0x2cae8e(%rip), %rax    # 0x372010
movabsq $0x45535f4c41455222, %rcx # imm = 0x45535F4C41455222
xorq %rcx, %rax
movq 0x2cae7d(%rip), %rcx    # 0x372013
xorq %r12, %rcx
orq %rax, %rcx
je 0xa720d
movq 0x2cae6b(%rip), %rax    # 0x372010
movabsq $0x534e5f4c41455222, %rcx # imm = 0x534E5F4C41455222
xorq %rcx, %rax
movl 0x2cae60(%rip), %ecx    # 0x372018
xorq $0x224345, %rcx         # imm = 0x224345
orq %rax, %rcx
je 0xa721f
movq 0x2cae45(%rip), %rax    # 0x372010
movabsq $0x4953494345525022, %rcx # imm = 0x4953494345525022
xorq %rcx, %rax
movl 0x2cae3a(%rip), %ecx    # 0x372018
xorq $0x224e4f, %rcx         # imm = 0x224E4F
orq %rax, %rcx
jne 0xa70f2
leaq 0x173ebb(%rip), %rax    # 0x21b0b0
movl $0x1, (%rax)
movq %r15, %rdi
callq 0x9470
callq 0x9320
jmp 0xa70f2
movq %r15, %rdi
callq 0x9470
movsd %xmm0, -0x40(%rbp)
jmp 0xa70f2
movq %r15, %rdi
callq 0x9470
mulsd 0x76fc1(%rip), %xmm0    # 0x11e1f0
movsd %xmm0, -0x38(%rbp)
jmp 0xa70f2
movq %r15, %rdi
callq 0x9470
movsd %xmm0, -0x48(%rbp)
movsd -0x30(%rbp), %xmm0
jmp 0xa70ed
movq %r15, %rdi
callq 0x9470
mulsd 0x76f90(%rip), %xmm0    # 0x11e1f0
jmp 0xa70ed
movsd -0x48(%rbp), %xmm0
subsd -0x40(%rbp), %xmm0
leaq 0x265542(%rip), %rax    # 0x30c7b8
leaq 0x265fbb(%rip), %rcx    # 0x30d238
movl $0x8, %edx
movl %edx, (%rcx)
leaq 0x265fb9(%rip), %rcx    # 0x30d244
movl %edx, (%rcx)
movsd -0x30(%rbp), %xmm1
subsd -0x38(%rbp), %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, %xmm0
mulsd 0x61d81(%rip), %xmm0    # 0x109028
movsd %xmm0, (%rax)
leaq 0x1970de(%rip), %rax    # 0x23e390
movq (%rax), %rdi
testq %rdi, %rdi
leaq 0x28(%rsp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
je 0xa72d7
leaq 0x7eabb(%rip), %rsi     # 0x125d8b
movb $0x1, %al
jmp 0x9560
retq