// File: jkingan[P]ladyheather/heathgps.cpp
// Function: parse_star_vis()
void parse_star_vis()  
{
int prn;
int el;
int az;
int snr;
int health;
int dop;
char *s;

   // visible sat info
   log_packet_id("Star visibility");

   if(star_line) {
      --star_line;
      prn = el = az = health = dop = (-999);
      snr = (-999);

      if(star_type == OSA_TYPE) {
         s = strstr(nmea_msg, "ID:");
         if(s) {
            s += 3;
            zpad(s,2);
            prn = atoi(s);
         }

         s = strstr(nmea_msg, "AZIM:");
         if(s) {
            s += 5;
            zpad(s,3);
            az = atoi(s);
         }

         s = strstr(nmea_msg, "ELEV:");
         if(s) {
            s += 5;
            zpad(s,2);
            el = atoi(s);
         }

         s = strstr(nmea_msg, "STAT:");
         if(s) {
            s += 5;
            zpad(s,1);
            health = atoi(s);

            if     (health == 0) health = 2;
            else if(health == 1) health = 2;
            else                 health = 1;
         }

         s = strstr(nmea_msg, "DOP:");
         if(s) {
            s += 4;
            zpad(s,6);
            dop = atoi(s);
         }

         if((prn >= 1) && (prn <= MAX_PRN)) { 
            sat[prn].sig_level = (float) sat[prn].osa_snr;
            snr = sat[prn].osa_snr;
            if(sat[prn].osa_state == 8) {
               sat[prn].level_msg = 0x88;
               sat[prn].tracking = prn;
               have_snr |= rinex_gnss(prn);
            }
         }

      }
      else {
         get_msg_field();      // eat the line number

         if(get_msg_field()) prn = atoi(msg_field);
         if(get_msg_field()) el = atoi(msg_field);
         if(get_msg_field()) az = atoi(msg_field);
         if(get_msg_field()) snr = atoi(msg_field);
         if(get_msg_field()) {
            health = atoi(msg_field);
            if(strchr(msg_field, ';')) {  // end of list
               star_line = 0;
               star_msg = 0;
            }
         }
      }


      if((prn >= 1) && (prn <= MAX_PRN)) {  // save the info for sat prn
if(debug_file) fprintf(debug_file, "  star vis msg:%d  line:%d  prn:%d el:%d az:%d snr:%d health:%d\n", 
star_msg,star_line, prn,el,az,snr,health);
         set_sat_azel(prn, (float) az, (float) el);
         sat[prn].health_flag = health;  // 0=no_alm, 1=unhealthy, 2=healthy
         if((star_type == OSA_TYPE) && (dop != (-999))) {
            sat[prn].doppler = (double) dop;
            have_doppler |= rinex_gnss(prn);
         }
         have_sat_azel = 2;

         sat[prn].visible = 1;
         if(star_type != OSA_TYPE) { 
            sat[prn].sig_level = (float) snr;
            sat[prn].level_msg = 52;
            have_snr |= rinex_gnss(prn);
            record_sig_levels(prn);
         }
         level_type = "SNR";
      }
   }
   else if(get_msg_field()) {  // first line of vis message, setup to get the other lines
      star_msg = STAR_VIS_MSG;
      star_line = atoi(msg_field);
if(debug_file) fprintf(debug_file, "start star vis msg:%d  line:%d\n", star_msg,star_line);
      if(star_type == OSA_TYPE) {
         star_line = 12;
      }

      for(prn=0; prn<=MAX_PRN; prn++) { 
         sat[prn].visible = 0;
         sat[prn].level_msg = 0;
         if(star_type == OSA_TYPE) {
            sat[prn].tracking = 0;
         }
      }

      if(star_line == 0) {
         star_line = 0;
         star_msg = 0;
      }
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
leaq 0xc035f(%rip), %rdi     # 0x1875de
callq 0x7add0
leaq 0x1b2f4d(%rip), %rax    # 0x27a1d8
cmpl $0x0, (%rax)
je 0xc7797
leaq 0x1b2f3d(%rip), %rax    # 0x27a1d8
movl (%rax), %ecx
addl $-0x1, %ecx
leaq 0x1b2f31(%rip), %rax    # 0x27a1d8
movl %ecx, (%rax)
movl $0xfffffc19, -0x18(%rbp) # imm = 0xFFFFFC19
movl $0xfffffc19, -0x14(%rbp) # imm = 0xFFFFFC19
movl $0xfffffc19, -0xc(%rbp) # imm = 0xFFFFFC19
movl $0xfffffc19, -0x8(%rbp) # imm = 0xFFFFFC19
movl $0xfffffc19, -0x4(%rbp) # imm = 0xFFFFFC19
movl $0xfffffc19, -0x10(%rbp) # imm = 0xFFFFFC19
leaq 0x1b2eee(%rip), %rax    # 0x27a1c8
cmpl $0x4f, (%rax)
jne 0xc7547
leaq 0x2d3726(%rip), %rdi    # 0x39aa10
leaq 0xc02fd(%rip), %rsi     # 0x1875ee
callq 0x9090
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xc7327
movq -0x20(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movl $0x2, %esi
callq 0xc4fb0
movq -0x20(%rbp), %rdi
callq 0x95c0
movl %eax, -0x4(%rbp)
leaq 0x2d36e2(%rip), %rdi    # 0x39aa10
leaq 0xc02bd(%rip), %rsi     # 0x1875f2
callq 0x9090
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xc736b
movq -0x20(%rbp), %rax
addq $0x5, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movl $0x3, %esi
callq 0xc4fb0
movq -0x20(%rbp), %rdi
callq 0x95c0
movl %eax, -0xc(%rbp)
leaq 0x2d369e(%rip), %rdi    # 0x39aa10
leaq 0xc027f(%rip), %rsi     # 0x1875f8
callq 0x9090
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xc73af
movq -0x20(%rbp), %rax
addq $0x5, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movl $0x2, %esi
callq 0xc4fb0
movq -0x20(%rbp), %rdi
callq 0x95c0
movl %eax, -0x8(%rbp)
leaq 0x2d365a(%rip), %rdi    # 0x39aa10
leaq 0xc0241(%rip), %rsi     # 0x1875fe
callq 0x9090
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xc741c
movq -0x20(%rbp), %rax
addq $0x5, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movl $0x1, %esi
callq 0xc4fb0
movq -0x20(%rbp), %rdi
callq 0x95c0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0xc7402
movl $0x2, -0x14(%rbp)
jmp 0xc741a
cmpl $0x1, -0x14(%rbp)
jne 0xc7411
movl $0x2, -0x14(%rbp)
jmp 0xc7418
movl $0x1, -0x14(%rbp)
jmp 0xc741a
jmp 0xc741c
leaq 0x2d35ed(%rip), %rdi    # 0x39aa10
leaq 0xc01da(%rip), %rsi     # 0x187604
callq 0x9090
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xc7460
movq -0x20(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movl $0x6, %esi
callq 0xc4fb0
movq -0x20(%rbp), %rdi
callq 0x95c0
movl %eax, -0x18(%rbp)
cmpl $0x1, -0x4(%rbp)
jl 0xc7542
cmpl $0x3e7, -0x4(%rbp)      # imm = 0x3E7
jg 0xc7542
movslq -0x4(%rbp), %rcx
leaq 0x1d6d0e(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
cvtsi2ssl 0x220(%rax), %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1d6cf1(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movss %xmm0, 0x20(%rax)
movslq -0x4(%rbp), %rcx
leaq 0x1d6cd7(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl 0x220(%rax), %eax
movl %eax, -0x10(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x1d6cb9(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
cmpl $0x8, 0x224(%rax)
jne 0xc7540
movslq -0x4(%rbp), %rcx
leaq 0x1d6c9b(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl $0x88, 0x1c(%rax)
movl -0x4(%rbp), %ecx
movslq -0x4(%rbp), %rdx
leaq 0x1d6c7c(%rip), %rax    # 0x29e190
imulq $0x348, %rdx, %rdx      # imm = 0x348
addq %rdx, %rax
movl %ecx, 0x218(%rax)
movl -0x4(%rbp), %edi
callq 0x12d280
movl %eax, %ecx
leaq 0x2a4ff7(%rip), %rax    # 0x36c52c
orl (%rax), %ecx
leaq 0x2a4fee(%rip), %rax    # 0x36c52c
movl %ecx, (%rax)
jmp 0xc7542
jmp 0xc75fe
callq 0xb0bd0
callq 0xb0bd0
cmpl $0x0, %eax
je 0xc7565
leaq 0x2d36c3(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x4(%rbp)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xc757e
leaq 0x2d36aa(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x8(%rbp)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xc7597
leaq 0x2d3691(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0xc(%rbp)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xc75b0
leaq 0x2d3678(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x10(%rbp)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xc75fc
leaq 0x2d365f(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x14(%rbp)
leaq 0x2d3650(%rip), %rdi    # 0x39ac20
movl $0x3b, %esi
callq 0x9100
cmpq $0x0, %rax
je 0xc75fa
leaq 0x1b2bf1(%rip), %rax    # 0x27a1d8
movl $0x0, (%rax)
leaq 0x1b2be8(%rip), %rax    # 0x27a1dc
movl $0x0, (%rax)
jmp 0xc75fc
jmp 0xc75fe
cmpl $0x1, -0x4(%rbp)
jl 0xc7792
cmpl $0x3e7, -0x4(%rbp)      # imm = 0x3E7
jg 0xc7792
leaq 0x1d5f54(%rip), %rax    # 0x29d570
cmpq $0x0, (%rax)
je 0xc766c
leaq 0x1d5f47(%rip), %rax    # 0x29d570
movq (%rax), %rdi
leaq 0x1b2ba9(%rip), %rax    # 0x27a1dc
movl (%rax), %edx
leaq 0x1b2b9c(%rip), %rax    # 0x27a1d8
movl (%rax), %ecx
movl -0x4(%rbp), %r8d
movl -0x8(%rbp), %r9d
movl -0xc(%rbp), %r11d
movl -0x10(%rbp), %r10d
movl -0x14(%rbp), %eax
leaq 0xbffb1(%rip), %rsi     # 0x187609
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movb $0x0, %al
callq 0x9550
movl -0x4(%rbp), %edi
cvtsi2ssl -0xc(%rbp), %xmm0
cvtsi2ssl -0x8(%rbp), %xmm1
callq 0x7d450
movl -0x14(%rbp), %eax
movb %al, %cl
movslq -0x4(%rbp), %rdx
leaq 0x1d6b02(%rip), %rax    # 0x29e190
imulq $0x348, %rdx, %rdx      # imm = 0x348
addq %rdx, %rax
movb %cl, (%rax)
leaq 0x1b2b27(%rip), %rax    # 0x27a1c8
cmpl $0x4f, (%rax)
jne 0xc76ea
cmpl $0xfffffc19, -0x18(%rbp) # imm = 0xFFFFFC19
je 0xc76ea
cvtsi2sdl -0x18(%rbp), %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1d6ad1(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movsd %xmm0, 0x30(%rax)
movl -0x4(%rbp), %edi
callq 0x12d280
movl %eax, %ecx
leaq 0x2a4e41(%rip), %rax    # 0x36c520
orl (%rax), %ecx
leaq 0x2a4e38(%rip), %rax    # 0x36c520
movl %ecx, (%rax)
leaq 0x2a4d83(%rip), %rax    # 0x36c474
movl $0x2, (%rax)
movslq -0x4(%rbp), %rcx
leaq 0x1d6a8e(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl $0x1, 0x21c(%rax)
leaq 0x1b2aab(%rip), %rax    # 0x27a1c8
cmpl $0x4f, (%rax)
je 0xc7781
cvtsi2ssl -0x10(%rbp), %xmm0
movslq -0x4(%rbp), %rcx
leaq 0x1d6a5e(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movss %xmm0, 0x20(%rax)
movslq -0x4(%rbp), %rcx
leaq 0x1d6a44(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl $0x34, 0x1c(%rax)
movl -0x4(%rbp), %edi
callq 0x12d280
movl %eax, %ecx
leaq 0x2a4dbe(%rip), %rax    # 0x36c52c
orl (%rax), %ecx
leaq 0x2a4db5(%rip), %rax    # 0x36c52c
movl %ecx, (%rax)
movl -0x4(%rbp), %edi
callq 0x80340
leaq 0x1d6950(%rip), %rax    # 0x29e0d8
leaq 0xbb287(%rip), %rcx     # 0x182a16
movq %rcx, (%rax)
jmp 0xc78c6
callq 0xb0bd0
cmpl $0x0, %eax
je 0xc78c4
leaq 0x1b2a30(%rip), %rax    # 0x27a1dc
movl $0xcd, (%rax)
leaq 0x2d3467(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, %ecx
leaq 0x1b2a11(%rip), %rax    # 0x27a1d8
movl %ecx, (%rax)
leaq 0x1d5da0(%rip), %rax    # 0x29d570
cmpq $0x0, (%rax)
je 0xc7800
leaq 0x1d5d93(%rip), %rax    # 0x29d570
movq (%rax), %rdi
leaq 0x1b29f5(%rip), %rax    # 0x27a1dc
movl (%rax), %edx
leaq 0x1b29e8(%rip), %rax    # 0x27a1d8
movl (%rax), %ecx
leaq 0xbfe51(%rip), %rsi     # 0x18764a
movb $0x0, %al
callq 0x9550
leaq 0x1b29c1(%rip), %rax    # 0x27a1c8
cmpl $0x4f, (%rax)
jne 0xc7819
leaq 0x1b29c5(%rip), %rax    # 0x27a1d8
movl $0xc, (%rax)
movl $0x0, -0x4(%rbp)
cmpl $0x3e7, -0x4(%rbp)      # imm = 0x3E7
jg 0xc789c
movslq -0x4(%rbp), %rcx
leaq 0x1d695c(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl $0x0, 0x21c(%rax)
movslq -0x4(%rbp), %rcx
leaq 0x1d693d(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl $0x0, 0x1c(%rax)
leaq 0x1b295d(%rip), %rax    # 0x27a1c8
cmpl $0x4f, (%rax)
jne 0xc788f
movslq -0x4(%rbp), %rcx
leaq 0x1d6915(%rip), %rax    # 0x29e190
imulq $0x348, %rcx, %rcx      # imm = 0x348
addq %rcx, %rax
movl $0x0, 0x218(%rax)
jmp 0xc7891
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0xc7820
leaq 0x1b2935(%rip), %rax    # 0x27a1d8
cmpl $0x0, (%rax)
jne 0xc78c2
leaq 0x1b2929(%rip), %rax    # 0x27a1d8
movl $0x0, (%rax)
leaq 0x1b2920(%rip), %rax    # 0x27a1dc
movl $0x0, (%rax)
jmp 0xc78c4
jmp 0xc78c6
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)