// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: parse_ubx_svn()
void parse_ubx_svn()
{
int chans;
int prn;
int flag;
int qual;
int sig;
int az;
int el;

   // get satellite position and signal info
   log_packet_id("UBX_SVIN");

   tsip_dword();  // tow
   chans = tsip_byte();
if(debug_file) fprintf(debug_file, "UBX_SVN chans:%d\n", chans);
   have_count = 50;
   tsip_byte();
   tsip_word();

   reset_sat_tracking();

   sat_count = 0;
   while(chans--) {
      tsip_byte();       // channel number
      prn = tsip_byte();
      flag = tsip_byte();
      qual = tsip_byte();
      sig = tsip_byte();
//sig += (sig/2);   // Ublox reports dBc levels that are around 50% less than most receivers
      el = tsip_byte();
      az = tsip_word();
      tsip_dword();      // pseudo range
if(0 && debug_file) fprintf(debug_file, "UBX_SVN %3d:: az:%-3d  el:%-3d  sig:%-3d  flag:%02X\n", prn, az,el, sig, flag);

//    if((az == 0) || (el == 0)) continue;

      if((prn >= 1) && (prn <= MAX_PRN)) {  
         set_sat_azel(prn, (float) az, (float) el);
         sat[prn].sig_level = (float) sig;
         sat[prn].level_msg = 3;
         sat[prn].sv_accuracy = 0.0F;
         sat[prn].state = qual;
         if(flag & 0x10) sat[prn].health_flag = 1;
         else            sat[prn].health_flag = 0;
         if(have_state == 0) need_redraw = 2033;
         have_state = UBX_STATE;
         have_snr |= rinex_gnss(prn);
         have_sat_azel = 3;

if(debug_file) fprintf(debug_file, "UBX_SVN %3d:  az:%-3d  el:%-2d  sig:%-2d  flag:%02X\n", prn, az,el, sig, flag);
         if(flag & 0x01) sat[prn].tracking = 1;
         else            sat[prn].tracking = (-1);

         record_sig_levels(prn);
         ++sat_count;
         have_count = 20;
      }
   }

   level_type = "dBc";
   config_sat_count(sat_count); 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0x87a82(%rip), %rdi     # 0x10e5fb
callq 0x520bf
callq 0x51cf3
callq 0x51c47
movzbl %al, %r15d
leaq 0x1a17fd(%rip), %rax    # 0x228390
movq (%rax), %rdi
testq %rdi, %rdi
je 0x86bac
leaq 0x87a62(%rip), %rsi     # 0x10e604
movl %r15d, %edx
xorl %eax, %eax
callq 0x9560
leaq 0x270765(%rip), %rax    # 0x2f7318
movl $0x32, (%rax)
callq 0x51c47
callq 0x51c63
callq 0x56b1c
leaq 0x1a233d(%rip), %rax    # 0x228f0c
andl $0x0, (%rax)
subl $0x1, %r15d
jb 0x86d3d
callq 0x51c47
callq 0x51c47
movl %eax, %r14d
callq 0x51c47
movb %al, -0x29(%rbp)
callq 0x51c47
movb %al, -0x30(%rbp)
callq 0x51c47
movl %eax, %r12d
callq 0x51c47
movl %eax, %r13d
callq 0x51c63
movl %eax, %ebx
callq 0x51cf3
testb %r14b, %r14b
je 0x86bd2
movl %r15d, -0x34(%rbp)
movzbl %r14b, %r15d
movzbl %r12b, %eax
movzbl %r13b, %ecx
movl %eax, %r13d
movzwl %bx, %r14d
cvtsi2ss %r14d, %xmm0
movzbl -0x30(%rbp), %r12d
movl %ecx, -0x30(%rbp)
cvtsi2ss %ecx, %xmm1
movl %r15d, %edi
callq 0x53b74
cvtsi2ss %r13d, %xmm0
movl %r15d, %eax
imulq $0x348, %rax, %rbx      # imm = 0x348
leaq 0x1a2350(%rip), %rcx    # 0x228fb0
movss %xmm0, 0x20(%rcx,%rbx)
movl $0x3, 0x1c(%rcx,%rbx)
andl $0x0, 0x1fc(%rcx,%rbx)
movl %r12d, 0x18(%rcx,%rbx)
movb -0x29(%rbp), %dl
movl %edx, %eax
shrb $0x4, %al
andb $0x1, %al
movb %al, (%rcx,%rbx)
leaq 0x2706ad(%rip), %rax    # 0x2f733c
cmpl $0x0, (%rax)
jne 0x86ca1
leaq 0x17bba9(%rip), %rcx    # 0x202844
movl $0x7f1, (%rcx)          # imm = 0x7F1
movzbl %dl, %r12d
movl $0x5, (%rax)
movl %r15d, %edi
callq 0xca4da
leaq 0x270692(%rip), %rcx    # 0x2f734c
orl %eax, (%rcx)
leaq 0x2705d1(%rip), %rax    # 0x2f7294
movl $0x3, (%rax)
leaq 0x1a16c0(%rip), %rax    # 0x228390
movq (%rax), %rdi
testq %rdi, %rdi
je 0x86cf7
movl %r12d, (%rsp)
leaq 0x87933(%rip), %rsi     # 0x10e616
movl %r15d, %edx
movl %r14d, %ecx
movl -0x30(%rbp), %r8d
movl %r13d, %r9d
xorl %eax, %eax
callq 0x9560
addq 0xb324a(%rip), %rbx     # 0x139f48
andl $0x1, %r12d
cmpl $0x1, %r12d
movl $0x0, %eax
sbbl %eax, %eax
orl $0x1, %eax
movl %eax, 0x218(%rbx)
movl %r15d, %edi
callq 0x559ba
leaq 0x1a21e7(%rip), %rax    # 0x228f0c
incl (%rax)
leaq 0x2705ea(%rip), %rax    # 0x2f7318
movl $0x14, (%rax)
movl -0x34(%rbp), %r15d
jmp 0x86bd2
leaq 0x84ede(%rip), %rax     # 0x10bc22
leaq 0x1a21ad(%rip), %rcx    # 0x228ef8
movq %rax, (%rcx)
leaq 0x1a21b7(%rip), %rax    # 0x228f0c
movl (%rax), %edi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x56d93