// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: parse_nvs_raw()
void parse_nvs_raw()
{
double tow;
int week;
double gps_shift;
double glonass_shift;
int corr;
u08 type;
int prn;
u08 glonass_carrier;
u08 snr;
double phase;
double range;
double doppler;
u08 flags;
u08 rsvd;
int lli;
int xtow;
double meas_tow;

   // 0xF5 packet
   log_packet_id("nvs_raw");

   tow = tsip_double() / 1000.0;   // in seconds
   week = tsip_word();
   week = fix_nvs_week(week); 

   meas_tow = ((double) tow);         // this is in UTC... bastards!!!
   meas_tow += (double) utc_offset;   // convert to GPS time
   xtow = (int) (meas_tow*nav_rate+0.01);  // raw Hz //rtk3   raw Hz

   if(1) {  // this might cause time stamp faults in CSRS-PPP  rnx3
      if(xtow % (int) ((double)raw_msg_rate*nav_rate)) return;

      obs_tow = meas_tow;
      jd_obs = GPS_EPOCH + ((double) week * 7.0) + jtime(0,0,0,meas_tow);
   }
   else {
      obs_tow = meas_tow;
      jd_obs = GPS_EPOCH + ((double) week * 7.0) + jtime(0,0,0,meas_tow);
   }

   gps_shift = tsip_double();
   glonass_shift = tsip_double();
   corr = (int) (s08) tsip_byte();

   while(tsip_rptr < tsip_wptr) {
      type = tsip_byte();
      prn = tsip_byte();
      glonass_carrier = tsip_byte();
      snr = tsip_byte();
      phase = tsip_double();
      range = tsip_double();    // msecs
      doppler = tsip_double();
      flags = tsip_byte();
      rsvd = tsip_byte();

      if(type == 0x01) prn += NVS_GLONASS_PRN;
      else if(type == 0x02) prn += 0;
      else {
         continue;
      }
      if(prn < 0) continue;
      if(prn > MAX_PRN) continue;

      range /= 1000.0;  // pseudorange now in seconds
      range *= (LIGHTSPEED*1000.0);  // now in meters

      sat[prn].code_phase = phase;
      sat[prn].doppler = doppler;
      sat[prn].range = range;

      lli = 0x00;
      if((flags & 0x01) == 0) lli |= 0x80;  // no gignal
      if((flags & 0x02) == 0) lli |= 0x80;  // no doppler/pseudorange
      if((flags & 0x08) == 0) lli |= 0x80;  // no carrier phase

      sat[prn].ca_lli = lli;
      sat[prn].l1_lli = 0;
      sat[prn].l2_lli = 0;

      if(doppler) {
         have_doppler |= rinex_gnss(prn);
      }
      if(phase) {
         have_phase |= rinex_gnss(prn); 
      }
      if(range) {
         have_range |= rinex_gnss(prn); 
      }
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0x76a2e(%rip), %rdi     # 0x10ff90
callq 0x520bf
callq 0x51e6f
divsd 0x59ac4(%rip), %xmm0    # 0xf3038
movsd %xmm0, -0x30(%rbp)
callq 0x51c63
leaq 0x25e1a3(%rip), %rcx    # 0x2f7728
cvtsi2sdl (%rcx), %xmm2
addsd -0x30(%rbp), %xmm2
leaq 0x16bdc3(%rip), %rcx    # 0x205358
movsd (%rcx), %xmm0
movapd %xmm2, %xmm1
mulsd %xmm0, %xmm1
addsd 0x59b57(%rip), %xmm1    # 0xf3100
cvttsd2si %xmm1, %edx
movl %eax, %ecx
leaq 0x16bdc2(%rip), %rax    # 0x205378
cvtsi2sdl (%rax), %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %esi
movl %edx, %eax
cltd
idivl %esi
testl %edx, %edx
je 0x995da
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movzwl %cx, %edi
movsd %xmm2, -0x38(%rbp)
callq 0x99169
leaq 0x25df8a(%rip), %rcx    # 0x2f7578
movsd -0x38(%rbp), %xmm0
movsd %xmm0, (%rcx)
cvtsi2sd %eax, %xmm1
mulsd 0x5c37d(%rip), %xmm1    # 0xf5980
addsd 0x5c305(%rip), %xmm1    # 0xf5910
movsd %xmm1, -0x30(%rbp)
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc2faf
addsd -0x30(%rbp), %xmm0
leaq 0x25df49(%rip), %rax    # 0x2f7570
movsd %xmm0, (%rax)
callq 0x51e6f
callq 0x51e6f
callq 0x51c47
leaq 0x288c11(%rip), %r13    # 0x322252
leaq 0x18f968(%rip), %r12    # 0x228fb0
leaq 0x288c05(%rip), %rax    # 0x322254
movzwl (%rax), %eax
cmpw (%r13), %ax
jae 0x995cb
callq 0x51c47
movl %eax, %r14d
callq 0x51c47
movzbl %al, %ebx
callq 0x51c47
callq 0x51c47
callq 0x51e6f
movsd %xmm0, -0x38(%rbp)
callq 0x51e6f
movsd %xmm0, -0x30(%rbp)
callq 0x51e6f
movsd %xmm0, -0x40(%rbp)
callq 0x51c47
movl %eax, %r15d
callq 0x51c47
cmpb $0x2, %r14b
je 0x996b4
movzbl %r14b, %eax
cmpl $0x1, %eax
jne 0x99648
addl $0x40, %ebx
movsd -0x30(%rbp), %xmm0
divsd 0x59977(%rip), %xmm0    # 0xf3038
mulsd 0x5c21f(%rip), %xmm0    # 0xf58e8
movl %ebx, %eax
imulq $0x348, %rax, %rax      # imm = 0x348
movsd -0x38(%rbp), %xmm1
movsd %xmm1, 0x28(%r12,%rax)
movsd -0x40(%rbp), %xmm1
movsd %xmm1, 0x30(%r12,%rax)
movsd %xmm0, -0x30(%rbp)
movsd %xmm0, 0x38(%r12,%rax)
movzbl %r15b, %ecx
notl %ecx
movl %ecx, %edx
shll $0x7, %edx
movzbl %dl, %edx
testb $0xa, %cl
movl $0x80, %ecx
cmovnel %ecx, %edx
movl %edx, 0x68(%r12,%rax)
andl $0x0, 0xa8(%r12,%rax)
andl $0x0, 0xe8(%r12,%rax)
ucomisd 0x599ea(%rip), %xmm1    # 0xf3118
jne 0x99732
jnp 0x99742
movl %ebx, %edi
callq 0xca4da
leaq 0x25dc00(%rip), %rcx    # 0x2f7340
orl %eax, (%rcx)
movsd -0x38(%rbp), %xmm0
ucomisd 0x599c9(%rip), %xmm0    # 0xf3118
jne 0x99753
jnp 0x99763
movl %ebx, %edi
callq 0xca4da
leaq 0x25dbe3(%rip), %rcx    # 0x2f7344
orl %eax, (%rcx)
movsd -0x30(%rbp), %xmm0
ucomisd 0x599a8(%rip), %xmm0    # 0xf3118
jne 0x99778
jnp 0x99648
movl %ebx, %edi
callq 0xca4da
leaq 0x25dbc2(%rip), %rcx    # 0x2f7348
orl %eax, (%rcx)
jmp 0x99648