// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heathgps.cpp
// Function: parse_venus_sv()
void parse_venus_sv()
{
int count;
int i;
int prn;
int state1;
int ura;
int snr;
int az,el;
int state2;

   // sky view
   log_packet_id("venus_sv");

   saw_venus_raw |= 0x01;
   minor_alarms &= (~MINOR_NO_TRACK);
   tsip_byte();  // iod
   count = tsip_byte();

   reset_sat_tracking();
   for(i=0; i<count; i++) {
      tsip_byte(); // channel
      prn = tsip_byte();
      state1 = tsip_byte();
      ura = tsip_byte();
      snr = tsip_byte();
      el = (int) tsip_word();
      az = (int) tsip_word();
      state2 = tsip_byte();

      if((prn >= 1) && (prn <= MAX_PRN)) {
         sat[prn].sv_accuracy = ura_to_dist(prn, ura); // convert to distance

         have_accu = 1;

         if(state1 & 0x04) {  // healthy
            sat[prn].health_flag = 0;
            sat[prn].tracking = 1;
         }
         else {
            sat[prn].health_flag = 1;  // docs say health flag... usage seems more like tracking flag
            sat[prn].tracking = (-1);
         }
         if((state2 & 0x30) == 0) sat[prn].tracking = (-1);
//if(log_file) fprintf(log_file, "prn:%02d  state1:%02X  state2:%02X\n", prn,state1,state2);  // rnx3

         sat[prn].sig_level = (float) snr;
         set_sat_azel(prn, (float) az, (float) el);
         have_sat_azel = 42;

         sat[prn].level_msg = 1;
         level_type = "SNR";
         record_sig_levels(prn);
      }
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0x8d0d6(%rip), %rdi     # 0x1249c3
callq 0x58e77
leaq 0x2a64fb(%rip), %rax    # 0x33ddf4
orb $0x1, (%rax)
leaq 0x2758d5(%rip), %rax    # 0x30d1d8
andb $-0x9, (%rax)
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x9791c
leaq 0x1a7657(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x587d1
movl %eax, %ebx
cmpl $0x100, %eax            # imm = 0x100
jb 0x97934
leaq 0x1a763f(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
movl $0x218, %eax            # imm = 0x218
leaq 0x1a7670(%rip), %rdx    # 0x23efb0
xorl %ecx, %ecx
movl %ecx, (%rdx,%rax)
movl %ecx, -0x1fc(%rdx,%rax)
addq $0x348, %rax            # imm = 0x348
cmpq $0xcd358, %rax          # imm = 0xCD358
jne 0x97942
andl $0xff, %ebx
je 0x97ad7
leaq 0x1a7603(%rip), %r13    # 0x23ef70
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x9797e
orb $0x8, (%r13)
callq 0x587d1
movl %eax, %r14d
cmpl $0x100, %eax            # imm = 0x100
jb 0x97992
orb $0x8, (%r13)
callq 0x587d1
movl %eax, -0x34(%rbp)
cmpl $0x100, %eax            # imm = 0x100
jb 0x979a6
orb $0x8, (%r13)
callq 0x587d1
movl %eax, %r15d
cmpl $0x100, %eax            # imm = 0x100
jb 0x979ba
orb $0x8, (%r13)
callq 0x587d1
movl %eax, -0x30(%rbp)
cmpl $0x100, %eax            # imm = 0x100
jb 0x979ce
orb $0x8, (%r13)
callq 0x588f0
movw %ax, -0x2c(%rbp)
callq 0x588f0
movw %ax, -0x2a(%rbp)
callq 0x587d1
movl %eax, %r12d
cmpl $0x100, %eax            # imm = 0x100
jb 0x979f4
orb $0x8, (%r13)
testb %r14b, %r14b
je 0x97acf
movzbl %r14b, %r13d
movl $0xff, %eax
andl %eax, %r15d
movl %r13d, %edi
movl %r15d, %esi
callq 0x82d30
movl $0xff, %eax
andl %eax, %r14d
imulq $0x348, %r14, %rax      # imm = 0x348
leaq 0x1a7586(%rip), %rdx    # 0x23efb0
leaq (%rdx,%rax), %r14
movss %xmm0, 0x1fc(%rdx,%rax)
leaq 0x275982(%rip), %rcx    # 0x30d3c0
movl $0x1, (%rcx)
xorl %ecx, %ecx
testb $0x4, -0x34(%rbp)
sete %cl
sete (%rdx,%rax)
negl %ecx
orl $0x1, %ecx
movl %ecx, 0x218(%rdx,%rax)
testb $0x30, %r12b
jne 0x97a6e
movl $0xffffffff, 0x218(%r14) # imm = 0xFFFFFFFF
movzbl -0x30(%rbp), %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x20(%r14)
movzwl -0x2a(%rbp), %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movzwl -0x2c(%rbp), %eax
cvtsi2ss %eax, %xmm1
movl %r13d, %edi
callq 0x5ad98
leaq 0x2757f3(%rip), %rax    # 0x30d294
movl $0x2a, (%rax)
movl $0x1, 0x1c(%r14)
leaq 0x864ba(%rip), %rax     # 0x11df70
leaq 0x1a743b(%rip), %rcx    # 0x23eef8
movq %rax, (%rcx)
movl %r13d, %edi
callq 0x5ced3
leaq 0x1a74a1(%rip), %r13    # 0x23ef70
decl %ebx
jne 0x9796d
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq