// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0x929e1(%rip), %rdi     # 0x1242f1
callq 0x58dc2
leaq 0x1896dc(%rip), %r15    # 0x21aff8
movl (%r15), %eax
testl %eax, %eax
je 0x91aee
decl %eax
movl %eax, (%r15)
leaq 0x1896b5(%rip), %rax    # 0x21afe8
cmpl $0x4f, (%rax)
jne 0x91b9a
leaq 0x2a9eed(%rip), %rdi    # 0x33b830
leaq 0x929b7(%rip), %rsi     # 0x124301
callq 0x9090
movl $0xfffffc19, %r15d      # imm = 0xFFFFFC19
movl $0xfffffc19, %ebx       # imm = 0xFFFFFC19
testq %rax, %rax
je 0x9197d
movq %rax, %r14
addq $0x3, %r14
movq %r14, %rdi
movl $0x2, %esi
callq 0x8fdd2
movq %r14, %rdi
callq 0x95e0
movl %eax, %ebx
leaq 0x2a9eac(%rip), %rdi    # 0x33b830
leaq 0x9297a(%rip), %rsi     # 0x124305
callq 0x9090
testq %rax, %rax
je 0x919b4
movq %rax, %r14
addq $0x5, %r14
movq %r14, %rdi
movl $0x3, %esi
callq 0x8fdd2
movq %r14, %rdi
callq 0x95e0
movl %eax, %r15d
movq %r15, -0x40(%rbp)
leaq 0x2a9e71(%rip), %rdi    # 0x33b830
leaq 0x92945(%rip), %rsi     # 0x12430b
callq 0x9090
movl $0xfffffc19, %r13d      # imm = 0xFFFFFC19
movl $0xfffffc19, %r12d      # imm = 0xFFFFFC19
testq %rax, %rax
je 0x919fb
movq %rax, %r14
addq $0x5, %r14
movq %r14, %rdi
movl $0x2, %esi
callq 0x8fdd2
movq %r14, %rdi
callq 0x95e0
movl %eax, %r12d
leaq 0x2a9e2e(%rip), %rdi    # 0x33b830
leaq 0x92908(%rip), %rsi     # 0x124311
callq 0x9090
testq %rax, %rax
je 0x91a39
movq %rax, %r14
addq $0x5, %r14
movq %r14, %rdi
movl $0x1, %esi
callq 0x8fdd2
movq %r14, %rdi
callq 0x95e0
xorl %r13d, %r13d
cmpl $0x2, %eax
adcl $0x1, %r13d
leaq 0x2a9df0(%rip), %rdi    # 0x33b830
leaq 0x928d0(%rip), %rsi     # 0x124317
callq 0x9090
movq %rax, %r15
movl $0xfffffc19, %eax       # imm = 0xFFFFFC19
movq %rax, -0x30(%rbp)
movl $0xfffffc19, %r14d      # imm = 0xFFFFFC19
testq %r15, %r15
je 0x91a7f
addq $0x4, %r15
movq %r15, %rdi
movl $0x6, %esi
callq 0x8fdd2
movq %r15, %rdi
callq 0x95e0
movl %eax, %r14d
leal -0x1(%rbx), %eax
cmpl $0x3e6, %eax            # imm = 0x3E6
ja 0x91c67
movl %ebx, %eax
imulq $0x348, %rax, %rcx      # imm = 0x348
leaq 0x1ad513(%rip), %rax    # 0x23efb0
movl 0x220(%rax,%rcx), %edx
movq %rdx, -0x30(%rbp)
cvtsi2ss %edx, %xmm0
movl 0x224(%rax,%rcx), %edx
movss %xmm0, 0x20(%rax,%rcx)
cmpl $0x8, %edx
leaq 0x189535(%rip), %r15    # 0x21aff8
jne 0x91c76
addq %rcx, %rax
movl $0x88, 0x1c(%rax)
movl %ebx, 0x218(%rax)
movl %ebx, %edi
callq 0xdc1dd
leaq 0x27b865(%rip), %rcx    # 0x30d34c
orl %eax, (%rcx)
jmp 0x91c76
callq 0x810b1
testl %eax, %eax
je 0x91d90
leaq 0x1894fa(%rip), %rbx    # 0x21affc
movl $0xcd, (%rbx)
leaq 0x2a9f31(%rip), %rdi    # 0x33ba40
callq 0x95e0
movl %eax, (%r15)
leaq 0x1ac872(%rip), %rcx    # 0x23e390
movq (%rcx), %rdi
testq %rdi, %rdi
je 0x91b3b
leaq 0x92830(%rip), %rsi     # 0x12435d
movl $0xcd, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0x9560
leaq 0x1894a6(%rip), %rax    # 0x21afe8
movl (%rax), %eax
cmpl $0x4f, %eax
jne 0x91b50
movl $0xc, (%r15)
movl $0x21c, %ecx            # imm = 0x21C
xorl %edx, %edx
leaq 0x1ad452(%rip), %rsi    # 0x23efb0
movl %edx, (%rsi,%rcx)
movl %edx, -0x200(%rsi,%rcx)
cmpl $0x4f, %eax
jne 0x91b75
movl $0x0, -0x4(%rsi,%rcx)
addq $0x348, %rcx            # imm = 0x348
cmpq $0xcd35c, %rcx          # imm = 0xCD35C
jne 0x91b5e
cmpl $0x0, (%r15)
jne 0x91d90
movl $0x0, (%rbx)
jmp 0x91d90
callq 0x810b1
callq 0x810b1
movl $0xfffffc19, %r12d      # imm = 0xFFFFFC19
movl $0xfffffc19, %ebx       # imm = 0xFFFFFC19
testl %eax, %eax
je 0x91bc1
leaq 0x2a9e86(%rip), %rdi    # 0x33ba40
callq 0x95e0
movl %eax, %ebx
callq 0x810b1
testl %eax, %eax
je 0x91bd9
leaq 0x2a9e6f(%rip), %rdi    # 0x33ba40
callq 0x95e0
movl %eax, %r12d
callq 0x810b1
movl $0xfffffc19, %ecx       # imm = 0xFFFFFC19
movq %rcx, -0x30(%rbp)
movl $0xfffffc19, %r14d      # imm = 0xFFFFFC19
testl %eax, %eax
je 0x91c00
leaq 0x2a9e48(%rip), %rdi    # 0x33ba40
callq 0x95e0
movl %eax, %r14d
callq 0x810b1
testl %eax, %eax
je 0x91c19
leaq 0x2a9e30(%rip), %rdi    # 0x33ba40
callq 0x95e0
movq %rax, -0x30(%rbp)
movq %r14, -0x40(%rbp)
callq 0x810b1
movl $0xfffffc19, %r14d      # imm = 0xFFFFFC19
testl %eax, %eax
je 0x91c70
leaq 0x2a9e0d(%rip), %r15    # 0x33ba40
movq %r15, %rdi
callq 0x95e0
movl %eax, %r13d
movq %r15, %rdi
movl $0x3b, %esi
callq 0x9100
testq %rax, %rax
je 0x91c67
xorl %eax, %eax
leaq 0x18939f(%rip), %r15    # 0x21aff8
movl %eax, (%r15)
leaq 0x189399(%rip), %rcx    # 0x21affc
movl %eax, (%rcx)
jmp 0x91c76
leaq 0x18938a(%rip), %r15    # 0x21aff8
jmp 0x91c76
movl $0xfffffc19, %r13d      # imm = 0xFFFFFC19
leal -0x1(%rbx), %eax
cmpl $0x3e6, %eax            # imm = 0x3E6
ja 0x91d90
movl %r14d, -0x34(%rbp)
leaq 0x1ac701(%rip), %rax    # 0x23e390
movq (%rax), %rdi
testq %rdi, %rdi
movl %r12d, %r14d
movq -0x40(%rbp), %r12
je 0x91ccd
leaq 0x189357(%rip), %rax    # 0x21affc
movl (%rax), %edx
movl (%r15), %ecx
subq $0x8, %rsp
leaq 0x92667(%rip), %rsi     # 0x12431c
movl %ebx, %r8d
movl %r14d, %r9d
xorl %eax, %eax
pushq %r13
pushq -0x30(%rbp)
pushq %r12
callq 0x9560
addq $0x20, %rsp
xorps %xmm0, %xmm0
cvtsi2ss %r12d, %xmm0
cvtsi2ss %r14d, %xmm1
movl %ebx, %edi
callq 0x5ace1
movl %ebx, %eax
imulq $0x348, %rax, %rax      # imm = 0x348
leaq 0x1ad2bf(%rip), %rcx    # 0x23efb0
leaq (%rcx,%rax), %r15
movb %r13b, (%rcx,%rax)
leaq 0x1892e8(%rip), %r13    # 0x21afe8
movl (%r13), %eax
cmpl $0x4f, %eax
jne 0x91d35
movl -0x34(%rbp), %ecx
cmpl $0xfffffc19, %ecx       # imm = 0xFFFFFC19
je 0x91d35
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movsd %xmm0, 0x30(%r15)
movl %ebx, %edi
callq 0xdc1dd
leaq 0x27b611(%rip), %rcx    # 0x30d340
orl %eax, (%rcx)
movl (%r13), %eax
leaq 0x27b558(%rip), %rcx    # 0x30d294
movl $0x2, (%rcx)
movl $0x1, 0x21c(%r15)
cmpl $0x4f, %eax
je 0x91d7f
xorps %xmm0, %xmm0
cvtsi2ssl -0x30(%rbp), %xmm0
movss %xmm0, 0x20(%r15)
movl $0x34, 0x1c(%r15)
movl %ebx, %edi
callq 0xdc1dd
leaq 0x27b5d6(%rip), %rcx    # 0x30d34c
orl %eax, (%rcx)
movl %ebx, %edi
callq 0x5cdab
leaq 0x8c275(%rip), %rax     # 0x11dffb
leaq 0x1ad16b(%rip), %rcx    # 0x23eef8
movq %rax, (%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq