// File: /workspace/github_cpp_makefile_star2_O3/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 0x7cf52(%rip), %rdi     # 0x12604b
callq 0x58dc2
callq 0x58b08
divsd 0x5ff2d(%rip), %xmm0    # 0x109038
movsd %xmm0, -0x30(%rbp)
callq 0x588d2
leaq 0x26460c(%rip), %rcx    # 0x30d728
cvtsi2sdl (%rcx), %xmm2
addsd -0x30(%rbp), %xmm2
leaq 0x17222c(%rip), %rcx    # 0x21b358
movsd (%rcx), %xmm0
movapd %xmm2, %xmm1
mulsd %xmm0, %xmm1
addsd 0x5ffc0(%rip), %xmm1    # 0x109100
cvttsd2si %xmm1, %edx
movl %eax, %ecx
leaq 0x17222b(%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 0xa9397
movzwl %cx, %edi
movsd %xmm2, -0x38(%rbp)
callq 0xa8c7b
leaq 0x2643fb(%rip), %rcx    # 0x30d578
movsd -0x38(%rbp), %xmm0
movsd %xmm0, (%rcx)
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
mulsd 0x62773(%rip), %xmm1    # 0x10b908
addsd 0x626fb(%rip), %xmm1    # 0x10b898
movsd %xmm1, -0x30(%rbp)
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0xd492e
addsd -0x30(%rbp), %xmm0
leaq 0x2643b7(%rip), %rax    # 0x30d570
movsd %xmm0, (%rax)
callq 0x58b08
callq 0x58b08
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0xa91dd
leaq 0x195d96(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
leaq 0x28f070(%rip), %rax    # 0x338254
movzwl (%rax), %eax
leaq 0x28f064(%rip), %rcx    # 0x338252
cmpw (%rcx), %ax
jae 0xa9397
leaq 0x195db2(%rip), %r12    # 0x23efb0
leaq 0x195d6b(%rip), %r13    # 0x23ef70
callq 0x587be
movl %eax, %ebx
cmpl $0x100, %eax            # imm = 0x100
jb 0xa9218
orb $0x8, (%r13)
callq 0x587be
movl %eax, %r14d
cmpl $0x100, %eax            # imm = 0x100
jb 0xa922c
orb $0x8, (%r13)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0xa923d
orb $0x8, (%r13)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0xa924e
orb $0x8, (%r13)
callq 0x58b08
movsd %xmm0, -0x38(%rbp)
callq 0x58b08
movsd %xmm0, -0x30(%rbp)
callq 0x58b08
movsd %xmm0, -0x40(%rbp)
callq 0x587be
movl %eax, %r15d
cmpl $0x100, %eax            # imm = 0x100
jb 0xa9280
orb $0x8, (%r13)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0xa9291
orb $0x8, (%r13)
movzbl %r14b, %r14d
cmpb $0x2, %bl
je 0xa92aa
movzbl %bl, %eax
cmpl $0x1, %eax
jne 0xa937d
addl $0x40, %r14d
movsd -0x30(%rbp), %xmm0
divsd 0x5fd81(%rip), %xmm0    # 0x109038
mulsd 0x625b1(%rip), %xmm0    # 0x10b870
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 0x5fdf4(%rip), %xmm1    # 0x109118
jne 0xa9328
jnp 0xa9339
movl %r14d, %edi
callq 0xdc1dd
leaq 0x264009(%rip), %rcx    # 0x30d340
orl %eax, (%rcx)
movsd -0x38(%rbp), %xmm0
ucomisd 0x5fdd2(%rip), %xmm0    # 0x109118
jne 0xa934a
jnp 0xa935b
movl %r14d, %edi
callq 0xdc1dd
leaq 0x263feb(%rip), %rcx    # 0x30d344
orl %eax, (%rcx)
movsd -0x30(%rbp), %xmm0
ucomisd 0x5fdb0(%rip), %xmm0    # 0x109118
jne 0xa936c
jnp 0xa937d
movl %r14d, %edi
callq 0xdc1dd
leaq 0x263fcd(%rip), %rcx    # 0x30d348
orl %eax, (%rcx)
leaq 0x28eed0(%rip), %rax    # 0x338254
movzwl (%rax), %eax
leaq 0x28eec4(%rip), %rcx    # 0x338252
cmpw (%rcx), %ax
jb 0xa9205
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq