// File: jkingan[P]ladyheather/heathgps.cpp
// Function: parse_ubx_raw()
void parse_ubx_raw()
{
int sats;
double carrier;
double range;
float doppler;
int prn;
int snr;
int lol;
int tow;
int week;
double meas_tow;
int xtow;

   // get doppler and code phase data (only on special receivers)
   log_packet_id("UBX_RAW");
   if(have_ubx_rawx) return;

   tow = tsip_dword();  // tow
   week = tsip_word();  // week
   sats = tsip_byte();

   meas_tow = ((double) tow) / 1000.0;
   if(1 || (nav_rate > 1.0)) {
      xtow = (int) (meas_tow*(double) nav_rate);  // raw Hz 
//sprintf(debug_text, "meas_tow:%.7ff  xtow=%d  ", meas_tow, xtow);  //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);
   if(first_obs == 1) return;

   while(sats--) {
      tsip_byte();
      carrier = tsip_double();
      range = tsip_double();
      doppler = tsip_single();
      prn = tsip_byte();  // !!!! SVN?
      snr = tsip_byte();
      lol = tsip_byte();  // lock quality

      if((prn >= 1) && (prn <= MAX_PRN)) { 
         sat[prn].doppler = doppler;
         sat[prn].code_phase = carrier;
         sat[prn].range = range;


         sat[prn].ca_lli = 0;
         sat[prn].l1_lli = 0;
         sat[prn].l2_lli = 0;
         if(lol < 6) sat[prn].ca_lli |= LOCK_LOST;
//       sat[prn].sig_level = (float) snr;
//       sat[prn].level_msg = 4;
//       record_sig_levels(prn);

         have_snr |= rinex_gnss(prn);
         if(doppler != 0.0F) {
            if(have_doppler == 0) need_redraw = 2018;
            have_doppler |= rinex_gnss(prn);
         }
         if(range != 0.0F) {
            have_range |= rinex_gnss(prn);
         }
         if(carrier != 0.0F) {
            have_phase |= rinex_gnss(prn);
         }
      }
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
leaq 0xbd800(%rip), %rdi     # 0x1879ef
callq 0x7add0
leaq 0x2a2395(%rip), %rax    # 0x36c590
cmpl $0x0, (%rax)
je 0xca205
jmp 0xca4fc
callq 0x7a680
movl %eax, -0x2c(%rbp)
callq 0x7a560
movzwl %ax, %eax
movl %eax, -0x30(%rbp)
callq 0x7a510
movzbl %al, %eax
movl %eax, -0x4(%rbp)
cvtsi2sdl -0x2c(%rbp), %xmm0
movsd 0xa4e00(%rip), %xmm1    # 0x16f030
divsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm0
leaq 0x1b02f3(%rip), %rax    # 0x27a538
mulsd (%rax), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
leaq 0x1b02fe(%rip), %rcx    # 0x27a558
cvtsi2sdl (%rcx), %xmm0
leaq 0x1b02d3(%rip), %rcx    # 0x27a538
mulsd (%rcx), %xmm0
cvttsd2si %xmm0, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0xca27a
jmp 0xca4fc
movsd -0x38(%rbp), %xmm0
leaq 0x2a24d2(%rip), %rax    # 0x36c758
movsd %xmm0, (%rax)
cvtsi2sdl -0x30(%rbp), %xmm0
movsd 0xa73f1(%rip), %xmm1    # 0x171688
mulsd %xmm1, %xmm0
movsd 0xa7375(%rip), %xmm1    # 0x171618
addsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x38(%rbp), %xmm0
xorl %edx, %edx
movl %edx, %edi
movl %edx, %esi
callq 0x122210
movaps %xmm0, %xmm1
movsd -0x48(%rbp), %xmm0
addsd %xmm1, %xmm0
leaq 0x2a2481(%rip), %rax    # 0x36c750
movsd %xmm0, (%rax)
leaq 0x2a2486(%rip), %rax    # 0x36c760
cmpl $0x1, (%rax)
jne 0xca2e4
jmp 0xca4fc
jmp 0xca2e6
movl -0x4(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x4(%rbp)
cmpl $0x0, %eax
je 0xca4fc
callq 0x7a510
callq 0x7a9d0
movsd %xmm0, -0x10(%rbp)
callq 0x7a9d0
movsd %xmm0, -0x18(%rbp)
callq 0x7a860
movss %xmm0, -0x1c(%rbp)
callq 0x7a510
movzbl %al, %eax
movl %eax, -0x20(%rbp)
callq 0x7a510
movzbl %al, %eax
movl %eax, -0x24(%rbp)
callq 0x7a510
movzbl %al, %eax
movl %eax, -0x28(%rbp)
cmpl $0x1, -0x20(%rbp)
jl 0xca4f7
cmpl $0x3e7, -0x20(%rbp)     # imm = 0x3E7
jg 0xca4f7
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movslq -0x20(%rbp), %rcx
leaq 0x1d3e27(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x30(%rax)
movsd -0x10(%rbp), %xmm0
movslq -0x20(%rbp), %rcx
leaq 0x1d3e08(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x28(%rax)
movsd -0x18(%rbp), %xmm0
movslq -0x20(%rbp), %rcx
leaq 0x1d3de9(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x38(%rax)
movslq -0x20(%rbp), %rcx
leaq 0x1d3dcf(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl $0x0, 0x68(%rax)
movslq -0x20(%rbp), %rcx
leaq 0x1d3db3(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl $0x0, 0xa8(%rax)
movslq -0x20(%rbp), %rcx
leaq 0x1d3d94(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl $0x0, 0xe8(%rax)
cmpl $0x6, -0x28(%rbp)
jge 0xca437
movslq -0x20(%rbp), %rcx
leaq 0x1d3d6f(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl 0x68(%rax), %ecx
orl $0x80, %ecx
movl %ecx, 0x68(%rax)
movl -0x20(%rbp), %edi
callq 0x12d280
movl %eax, %ecx
leaq 0x2a20e4(%rip), %rax    # 0x36c52c
orl (%rax), %ecx
leaq 0x2a20db(%rip), %rax    # 0x36c52c
movl %ecx, (%rax)
movss -0x1c(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0xca464
jp 0xca464
jmp 0xca499
leaq 0x2a20b5(%rip), %rax    # 0x36c520
cmpl $0x0, (%rax)
jne 0xca47d
leaq 0x1ad5ad(%rip), %rax    # 0x277a24
movl $0x7e2, (%rax)          # imm = 0x7E2
movl -0x20(%rbp), %edi
callq 0x12d280
movl %eax, %ecx
leaq 0x2a2092(%rip), %rax    # 0x36c520
orl (%rax), %ecx
leaq 0x2a2089(%rip), %rax    # 0x36c520
movl %ecx, (%rax)
movsd -0x18(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xca4ab
jp 0xca4ab
jmp 0xca4c7
movl -0x20(%rbp), %edi
callq 0x12d280
movl %eax, %ecx
leaq 0x2a206c(%rip), %rax    # 0x36c528
orl (%rax), %ecx
leaq 0x2a2063(%rip), %rax    # 0x36c528
movl %ecx, (%rax)
movsd -0x10(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xca4d9
jp 0xca4d9
jmp 0xca4f5
movl -0x20(%rbp), %edi
callq 0x12d280
movl %eax, %ecx
leaq 0x2a203a(%rip), %rax    # 0x36c524
orl (%rax), %ecx
leaq 0x2a2031(%rip), %rax    # 0x36c524
movl %ecx, (%rax)
jmp 0xca4f7
jmp 0xca2e6
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)