// File: /workspace/github_cpp_makefile_star2_O1/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 0x92980(%rip), %rdi     # 0x124211
callq 0x58e77
leaq 0x18975b(%rip), %r15    # 0x21aff8
movl (%r15), %eax
testl %eax, %eax
je 0x91a6f
decl %eax
movl %eax, (%r15)
leaq 0x189734(%rip), %rax    # 0x21afe8
cmpl $0x4f, (%rax)
jne 0x91b1c
leaq 0x2a9f6c(%rip), %rdi    # 0x33b830
leaq 0x92956(%rip), %rsi     # 0x124221
callq 0x9090
movl $0xfffffc19, %r15d      # imm = 0xFFFFFC19
movl $0xfffffc19, %ebx       # imm = 0xFFFFFC19
testq %rax, %rax
je 0x918fe
movq %rax, %r14
addq $0x3, %r14
movq %r14, %rdi
movl $0x2, %esi
callq 0x8fd78
movq %r14, %rdi
callq 0x95e0
movl %eax, %ebx
leaq 0x2a9f2b(%rip), %rdi    # 0x33b830
leaq 0x92919(%rip), %rsi     # 0x124225
callq 0x9090
testq %rax, %rax
je 0x91935
movq %rax, %r14
addq $0x5, %r14
movq %r14, %rdi
movl $0x3, %esi
callq 0x8fd78
movq %r14, %rdi
callq 0x95e0
movl %eax, %r15d
movq %r15, -0x40(%rbp)
leaq 0x2a9ef0(%rip), %rdi    # 0x33b830
leaq 0x928e4(%rip), %rsi     # 0x12422b
callq 0x9090
movl $0xfffffc19, %r13d      # imm = 0xFFFFFC19
movl $0xfffffc19, %r12d      # imm = 0xFFFFFC19
testq %rax, %rax
je 0x9197c
movq %rax, %r14
addq $0x5, %r14
movq %r14, %rdi
movl $0x2, %esi
callq 0x8fd78
movq %r14, %rdi
callq 0x95e0
movl %eax, %r12d
leaq 0x2a9ead(%rip), %rdi    # 0x33b830
leaq 0x928a7(%rip), %rsi     # 0x124231
callq 0x9090
testq %rax, %rax
je 0x919ba
movq %rax, %r14
addq $0x5, %r14
movq %r14, %rdi
movl $0x1, %esi
callq 0x8fd78
movq %r14, %rdi
callq 0x95e0
xorl %r13d, %r13d
cmpl $0x2, %eax
adcl $0x1, %r13d
leaq 0x2a9e6f(%rip), %rdi    # 0x33b830
leaq 0x9286f(%rip), %rsi     # 0x124237
callq 0x9090
movq %rax, %r15
movl $0xfffffc19, %eax       # imm = 0xFFFFFC19
movq %rax, -0x30(%rbp)
movl $0xfffffc19, %r14d      # imm = 0xFFFFFC19
testq %r15, %r15
je 0x91a00
addq $0x4, %r15
movq %r15, %rdi
movl $0x6, %esi
callq 0x8fd78
movq %r15, %rdi
callq 0x95e0
movl %eax, %r14d
leal -0x1(%rbx), %eax
cmpl $0x3e6, %eax            # imm = 0x3E6
ja 0x91be9
movl %ebx, %eax
imulq $0x348, %rax, %rcx      # imm = 0x348
leaq 0x1ad592(%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 0x1895b4(%rip), %r15    # 0x21aff8
jne 0x91bf8
addq %rcx, %rax
movl $0x88, 0x1c(%rax)
movl %ebx, 0x218(%rax)
movl %ebx, %edi
callq 0xdbb74
leaq 0x27b8e4(%rip), %rcx    # 0x30d34c
orl %eax, (%rcx)
jmp 0x91bf8
callq 0x811da
testl %eax, %eax
je 0x91d14
leaq 0x189579(%rip), %rbx    # 0x21affc
movl $0xcd, (%rbx)
leaq 0x2a9fb0(%rip), %rdi    # 0x33ba40
callq 0x95e0
movl %eax, (%r15)
leaq 0x1ac8f1(%rip), %rcx    # 0x23e390
movq (%rcx), %rdi
testq %rdi, %rdi
je 0x91abc
leaq 0x927cf(%rip), %rsi     # 0x12427d
movl $0xcd, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0x9560
leaq 0x189525(%rip), %rax    # 0x21afe8
movl (%rax), %eax
cmpl $0x4f, %eax
jne 0x91ad1
movl $0xc, (%r15)
movl $0x21c, %ecx            # imm = 0x21C
xorl %edx, %edx
leaq 0x1ad4d1(%rip), %rsi    # 0x23efb0
movl %edx, (%rsi,%rcx)
movl %edx, -0x200(%rsi,%rcx)
cmpl $0x4f, %eax
jne 0x91af6
movl $0x0, -0x4(%rsi,%rcx)
addq $0x348, %rcx            # imm = 0x348
cmpq $0xcd35c, %rcx          # imm = 0xCD35C
jne 0x91adf
cmpl $0x0, (%r15)
jne 0x91d14
xorl %eax, %eax
movl %eax, (%r15)
movl %eax, (%rbx)
jmp 0x91d14
callq 0x811da
callq 0x811da
movl $0xfffffc19, %r12d      # imm = 0xFFFFFC19
movl $0xfffffc19, %ebx       # imm = 0xFFFFFC19
testl %eax, %eax
je 0x91b43
leaq 0x2a9f04(%rip), %rdi    # 0x33ba40
callq 0x95e0
movl %eax, %ebx
callq 0x811da
testl %eax, %eax
je 0x91b5b
leaq 0x2a9eed(%rip), %rdi    # 0x33ba40
callq 0x95e0
movl %eax, %r12d
callq 0x811da
movl $0xfffffc19, %ecx       # imm = 0xFFFFFC19
movq %rcx, -0x30(%rbp)
movl $0xfffffc19, %r14d      # imm = 0xFFFFFC19
testl %eax, %eax
je 0x91b82
leaq 0x2a9ec6(%rip), %rdi    # 0x33ba40
callq 0x95e0
movl %eax, %r14d
callq 0x811da
testl %eax, %eax
je 0x91b9b
leaq 0x2a9eae(%rip), %rdi    # 0x33ba40
callq 0x95e0
movq %rax, -0x30(%rbp)
movq %r14, -0x40(%rbp)
callq 0x811da
movl $0xfffffc19, %r14d      # imm = 0xFFFFFC19
testl %eax, %eax
je 0x91bf2
leaq 0x2a9e8b(%rip), %r15    # 0x33ba40
movq %r15, %rdi
callq 0x95e0
movl %eax, %r13d
movq %r15, %rdi
movl $0x3b, %esi
callq 0x9100
testq %rax, %rax
je 0x91be9
xorl %eax, %eax
leaq 0x18941d(%rip), %r15    # 0x21aff8
movl %eax, (%r15)
leaq 0x189417(%rip), %rcx    # 0x21affc
movl %eax, (%rcx)
jmp 0x91bf8
leaq 0x189408(%rip), %r15    # 0x21aff8
jmp 0x91bf8
movl $0xfffffc19, %r13d      # imm = 0xFFFFFC19
leal -0x1(%rbx), %eax
cmpl $0x3e6, %eax            # imm = 0x3E6
ja 0x91d14
movl %r14d, -0x34(%rbp)
leaq 0x1ac77f(%rip), %rax    # 0x23e390
movq (%rax), %rdi
testq %rdi, %rdi
movl %r12d, %r14d
movq -0x40(%rbp), %r12
je 0x91c4f
leaq 0x1893d5(%rip), %rax    # 0x21affc
movl (%rax), %edx
movl (%r15), %ecx
subq $0x8, %rsp
leaq 0x92605(%rip), %rsi     # 0x12423c
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 0x5ad98
movq %rbx, %r14
movl %ebx, %eax
imulq $0x348, %rax, %rax      # imm = 0x348
leaq 0x1ad33a(%rip), %rcx    # 0x23efb0
leaq (%rcx,%rax), %r15
movb %r13b, (%rcx,%rax)
leaq 0x189363(%rip), %r13    # 0x21afe8
cmpl $0x4f, (%r13)
movl -0x34(%rbp), %ebx
jne 0x91cb5
cmpl $0xfffffc19, %ebx       # imm = 0xFFFFFC19
je 0x91cb5
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
movsd %xmm0, 0x30(%r15)
movl %r14d, %edi
callq 0xdbb74
leaq 0x27b68d(%rip), %rcx    # 0x30d340
orl %eax, (%rcx)
leaq 0x27b5d8(%rip), %rax    # 0x30d294
movl $0x2, (%rax)
movl $0x1, 0x21c(%r15)
cmpl $0x4f, (%r13)
je 0x91d03
xorps %xmm0, %xmm0
cvtsi2ssl -0x30(%rbp), %xmm0
movss %xmm0, 0x20(%r15)
movl $0x34, 0x1c(%r15)
movl %r14d, %edi
callq 0xdbb74
leaq 0x27b653(%rip), %rcx    # 0x30d34c
orl %eax, (%rcx)
movl %r14d, %edi
callq 0x5ced3
leaq 0x8c266(%rip), %rax     # 0x11df70
leaq 0x1ad1e7(%rip), %rcx    # 0x23eef8
movq %rax, (%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq