// File: /workspace/github_cpp_makefile_star2_O2/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 0x89811(%rip), %rdi     # 0x10e239
callq 0x520bf
leaq 0x1805c4(%rip), %r15    # 0x204ff8
movl (%r15), %eax
testl %eax, %eax
je 0x84bfc
decl %eax
movl %eax, (%r15)
leaq 0x18059d(%rip), %rax    # 0x204fe8
cmpl $0x4f, (%rax)
jne 0x84c96
leaq 0x2a0dd5(%rip), %rdi    # 0x325830
leaq 0x897e7(%rip), %rsi     # 0x10e249
callq 0x9090
movl $0xfffffc19, %r15d      # imm = 0xFFFFFC19
movl $0xfffffc19, %ebx       # imm = 0xFFFFFC19
testq %rax, %rax
je 0x84a93
movq %rax, %r14
addq $0x3, %r14
pushq $0x2
popq %rsi
movq %r14, %rdi
callq 0x830bb
movq %r14, %rdi
callq 0x95e0
movl %eax, %ebx
leaq 0x2a0d96(%rip), %rdi    # 0x325830
leaq 0x897ac(%rip), %rsi     # 0x10e24d
callq 0x9090
testq %rax, %rax
je 0x84ac8
movq %rax, %r14
addq $0x5, %r14
pushq $0x3
popq %rsi
movq %r14, %rdi
callq 0x830bb
movq %r14, %rdi
callq 0x95e0
movl %eax, %r15d
movq %r15, -0x40(%rbp)
leaq 0x2a0d5d(%rip), %rdi    # 0x325830
leaq 0x89779(%rip), %rsi     # 0x10e253
callq 0x9090
movl $0xfffffc19, %r13d      # imm = 0xFFFFFC19
movl $0xfffffc19, %r12d      # imm = 0xFFFFFC19
testq %rax, %rax
je 0x84b0d
movq %rax, %r14
addq $0x5, %r14
pushq $0x2
popq %rsi
movq %r14, %rdi
callq 0x830bb
movq %r14, %rdi
callq 0x95e0
movl %eax, %r12d
leaq 0x2a0d1c(%rip), %rdi    # 0x325830
leaq 0x8973e(%rip), %rsi     # 0x10e259
callq 0x9090
testq %rax, %rax
je 0x84b49
movq %rax, %r14
addq $0x5, %r14
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x830bb
movq %r14, %rdi
callq 0x95e0
xorl %r13d, %r13d
cmpl $0x2, %eax
adcl $0x1, %r13d
leaq 0x2a0ce0(%rip), %rdi    # 0x325830
leaq 0x89708(%rip), %rsi     # 0x10e25f
callq 0x9090
movq %rax, %r15
movl $0xfffffc19, %eax       # imm = 0xFFFFFC19
movq %rax, -0x30(%rbp)
movl $0xfffffc19, %r14d      # imm = 0xFFFFFC19
testq %r15, %r15
je 0x84b8d
addq $0x4, %r15
pushq $0x6
popq %rsi
movq %r15, %rdi
callq 0x830bb
movq %r15, %rdi
callq 0x95e0
movl %eax, %r14d
leal -0x1(%rbx), %eax
cmpl $0x3e6, %eax            # imm = 0x3E6
ja 0x84d73
movl %ebx, %eax
imulq $0x348, %rax, %rcx      # imm = 0x348
leaq 0x1a4405(%rip), %rax    # 0x228fb0
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 0x180427(%rip), %r15    # 0x204ff8
jne 0x84d82
addq %rcx, %rax
movl $0x88, 0x1c(%rax)
movl %ebx, 0x218(%rax)
movl %ebx, %edi
callq 0xca4da
leaq 0x272757(%rip), %rcx    # 0x2f734c
orl %eax, (%rcx)
jmp 0x84d82
callq 0x75767
testl %eax, %eax
je 0x84e93
leaq 0x1803ec(%rip), %rbx    # 0x204ffc
movl $0xcd, (%rbx)
leaq 0x2a0e23(%rip), %rdi    # 0x325a40
callq 0x95e0
movl %eax, (%r15)
leaq 0x1a3764(%rip), %rcx    # 0x228390
movq (%rcx), %rdi
testq %rdi, %rdi
je 0x84c49
leaq 0x8966a(%rip), %rsi     # 0x10e2a5
movl $0xcd, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0x9560
leaq 0x180398(%rip), %rax    # 0x204fe8
movl (%rax), %eax
cmpl $0x4f, %eax
jne 0x84c5e
movl $0xc, (%r15)
movl $0x21c, %ecx            # imm = 0x21C
leaq 0x1a4346(%rip), %rdx    # 0x228fb0
cmpq $0xcd35c, %rcx          # imm = 0xCD35C
je 0x84d61
andl $0x0, (%rdx,%rcx)
andl $0x0, -0x200(%rdx,%rcx)
cmpl $0x4f, %eax
jne 0x84c8d
andl $0x0, -0x4(%rdx,%rcx)
addq $0x348, %rcx            # imm = 0x348
jmp 0x84c6a
callq 0x75767
callq 0x75767
movl $0xfffffc19, %r12d      # imm = 0xFFFFFC19
movl $0xfffffc19, %ebx       # imm = 0xFFFFFC19
testl %eax, %eax
je 0x84cbd
leaq 0x2a0d8a(%rip), %rdi    # 0x325a40
callq 0x95e0
movl %eax, %ebx
callq 0x75767
testl %eax, %eax
je 0x84cd5
leaq 0x2a0d73(%rip), %rdi    # 0x325a40
callq 0x95e0
movl %eax, %r12d
callq 0x75767
movl $0xfffffc19, %ecx       # imm = 0xFFFFFC19
movq %rcx, -0x30(%rbp)
movl $0xfffffc19, %r14d      # imm = 0xFFFFFC19
testl %eax, %eax
je 0x84cfc
leaq 0x2a0d4c(%rip), %rdi    # 0x325a40
callq 0x95e0
movl %eax, %r14d
callq 0x75767
testl %eax, %eax
je 0x84d15
leaq 0x2a0d34(%rip), %rdi    # 0x325a40
callq 0x95e0
movq %rax, -0x30(%rbp)
movq %r14, -0x40(%rbp)
callq 0x75767
movl $0xfffffc19, %r14d      # imm = 0xFFFFFC19
testl %eax, %eax
je 0x84d7c
leaq 0x2a0d11(%rip), %r15    # 0x325a40
movq %r15, %rdi
callq 0x95e0
movl %eax, %r13d
pushq $0x3b
popq %rsi
movq %r15, %rdi
callq 0x9100
testq %rax, %rax
je 0x84d73
leaq 0x1802a7(%rip), %r15    # 0x204ff8
andl $0x0, (%r15)
leaq 0x1802a0(%rip), %rax    # 0x204ffc
andl $0x0, (%rax)
jmp 0x84d82
cmpl $0x0, (%r15)
jne 0x84e93
andl $0x0, (%rbx)
jmp 0x84e93
leaq 0x18027e(%rip), %r15    # 0x204ff8
jmp 0x84d82
movl $0xfffffc19, %r13d      # imm = 0xFFFFFC19
leal -0x1(%rbx), %eax
cmpl $0x3e6, %eax            # imm = 0x3E6
ja 0x84e93
movl %r14d, -0x34(%rbp)
leaq 0x1a35f5(%rip), %rax    # 0x228390
movq (%rax), %rdi
testq %rdi, %rdi
movl %r12d, %r14d
movq -0x40(%rbp), %r12
je 0x84dd9
leaq 0x18024b(%rip), %rax    # 0x204ffc
movl (%rax), %edx
movl (%r15), %ecx
subq $0x8, %rsp
leaq 0x894a3(%rip), %rsi     # 0x10e264
movl %ebx, %r8d
movl %r14d, %r9d
xorl %eax, %eax
pushq %r13
pushq -0x30(%rbp)
pushq %r12
callq 0x9560
addq $0x20, %rsp
cvtsi2ss %r12d, %xmm0
cvtsi2ss %r14d, %xmm1
movl %ebx, %edi
callq 0x53b74
movl %ebx, %eax
imulq $0x348, %rax, %rax      # imm = 0x348
leaq 0x1a41b6(%rip), %rcx    # 0x228fb0
leaq (%rcx,%rax), %r15
movb %r13b, (%rcx,%rax)
leaq 0x1801df(%rip), %r13    # 0x204fe8
movl (%r13), %eax
cmpl $0x4f, %eax
jne 0x84e3b
movl -0x34(%rbp), %ecx
cmpl $0xfffffc19, %ecx       # imm = 0xFFFFFC19
je 0x84e3b
cvtsi2sd %ecx, %xmm0
movsd %xmm0, 0x30(%r15)
movl %ebx, %edi
callq 0xca4da
leaq 0x27250b(%rip), %rcx    # 0x2f7340
orl %eax, (%rcx)
movl (%r13), %eax
leaq 0x272452(%rip), %rcx    # 0x2f7294
movl $0x2, (%rcx)
movl $0x1, 0x21c(%r15)
cmpl $0x4f, %eax
je 0x84e82
cvtsi2ssl -0x30(%rbp), %xmm0
movss %xmm0, 0x20(%r15)
movl $0x34, 0x1c(%r15)
movl %ebx, %edi
callq 0xca4da
leaq 0x2724d3(%rip), %rcx    # 0x2f734c
orl %eax, (%rcx)
movl %ebx, %edi
callq 0x559ba
leaq 0x831ed(%rip), %rax     # 0x108076
leaq 0x1a4068(%rip), %rcx    # 0x228ef8
movq %rax, (%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq