// File: /workspace/github_cpp_makefile_star2_O1/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 0x7d0bf(%rip), %rdi     # 0x125f6b
callq 0x58e77
callq 0x58b86
divsd 0x6017a(%rip), %xmm0    # 0x109038
movsd %xmm0, -0x30(%rbp)
callq 0x588f0
leaq 0x264859(%rip), %rcx    # 0x30d728
cvtsi2sdl (%rcx), %xmm2
addsd -0x30(%rbp), %xmm2
leaq 0x172479(%rip), %rcx    # 0x21b358
movsd (%rcx), %xmm0
movapd %xmm2, %xmm1
mulsd %xmm0, %xmm1
addsd 0x6020d(%rip), %xmm1    # 0x109100
cvttsd2si %xmm1, %edx
movl %eax, %ecx
leaq 0x172478(%rip), %rax    # 0x21b378
xorps %xmm1, %xmm1
cvtsi2sdl (%rax), %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %esi
movl %edx, %eax
cltd
idivl %esi
testl %edx, %edx
jne 0xa914a
movzwl %cx, %edi
movsd %xmm2, -0x38(%rbp)
callq 0xa8a2e
leaq 0x264648(%rip), %rcx    # 0x30d578
movsd -0x38(%rbp), %xmm0
movsd %xmm0, (%rcx)
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
mulsd 0x629b8(%rip), %xmm1    # 0x10b900
addsd 0x62938(%rip), %xmm1    # 0x10b888
movsd %xmm1, -0x30(%rbp)
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0xd41e0
addsd -0x30(%rbp), %xmm0
leaq 0x264604(%rip), %rax    # 0x30d570
movsd %xmm0, (%rax)
callq 0x58b86
callq 0x58b86
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0xa8f90
leaq 0x195fe3(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
leaq 0x28f2bd(%rip), %rax    # 0x338254
movzwl (%rax), %eax
leaq 0x28f2b1(%rip), %rcx    # 0x338252
cmpw (%rcx), %ax
jae 0xa914a
leaq 0x195fff(%rip), %r12    # 0x23efb0
leaq 0x195fb8(%rip), %r13    # 0x23ef70
callq 0x587d1
movl %eax, %ebx
cmpl $0x100, %eax            # imm = 0x100
jb 0xa8fcb
orb $0x8, (%r13)
callq 0x587d1
movl %eax, %r14d
cmpl $0x100, %eax            # imm = 0x100
jb 0xa8fdf
orb $0x8, (%r13)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0xa8ff0
orb $0x8, (%r13)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0xa9001
orb $0x8, (%r13)
callq 0x58b86
movsd %xmm0, -0x38(%rbp)
callq 0x58b86
movsd %xmm0, -0x30(%rbp)
callq 0x58b86
movsd %xmm0, -0x40(%rbp)
callq 0x587d1
movl %eax, %r15d
cmpl $0x100, %eax            # imm = 0x100
jb 0xa9033
orb $0x8, (%r13)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0xa9044
orb $0x8, (%r13)
movzbl %r14b, %r14d
cmpb $0x2, %bl
je 0xa905d
movzbl %bl, %eax
cmpl $0x1, %eax
jne 0xa9130
addl $0x40, %r14d
movsd -0x30(%rbp), %xmm0
divsd 0x5ffce(%rip), %xmm0    # 0x109038
mulsd 0x627ee(%rip), %xmm0    # 0x10b860
movl %r14d, %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)
notl %r15d
movl %r15d, %ecx
shll $0x7, %ecx
movzbl %cl, %ecx
testb $0xa, %r15b
movl $0x80, %edx
cmovnel %edx, %ecx
movl %ecx, 0x68(%r12,%rax)
xorl %ecx, %ecx
movl %ecx, 0xa8(%r12,%rax)
movl %ecx, 0xe8(%r12,%rax)
ucomisd 0x60041(%rip), %xmm1    # 0x109118
jne 0xa90db
jnp 0xa90ec
movl %r14d, %edi
callq 0xdbb74
leaq 0x264256(%rip), %rcx    # 0x30d340
orl %eax, (%rcx)
movsd -0x38(%rbp), %xmm0
ucomisd 0x6001f(%rip), %xmm0    # 0x109118
jne 0xa90fd
jnp 0xa910e
movl %r14d, %edi
callq 0xdbb74
leaq 0x264238(%rip), %rcx    # 0x30d344
orl %eax, (%rcx)
movsd -0x30(%rbp), %xmm0
ucomisd 0x5fffd(%rip), %xmm0    # 0x109118
jne 0xa911f
jnp 0xa9130
movl %r14d, %edi
callq 0xdbb74
leaq 0x26421a(%rip), %rcx    # 0x30d348
orl %eax, (%rcx)
leaq 0x28f11d(%rip), %rax    # 0x338254
movzwl (%rax), %eax
leaq 0x28f111(%rip), %rcx    # 0x338252
cmpw (%rcx), %ax
jb 0xa8fb8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq