// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathgps.cpp
// Function: get_sat_solutions()
void get_sat_solutions()
{   //not available on ThunderBolt-E
u08 format;
u32 time_of_week;
float clock_bias;
float clock_bias_rate;
float sat_bias;
int prn;
int i;

   log_packet_id("Packet 0x8F.A7 (Satellite solutions)");

   if(tsip_type == STARLOC_TYPE) {  // !!!! who knows what garbage this device craps out?
      // some of these are 9 bytes long, some are 13... we just ignore this message
      return;
   }

   format = tsip_byte();
   time_of_week = tsip_dword();

   if(format == 0) {     // floating point
      clock_bias = tsip_single();
      clock_bias_rate = tsip_single();
   }
   else if(format == 1) {   // integer values
      clock_bias = (float) (int) tsip_word();
      clock_bias *= 100.0e-12F;
      clock_bias_rate = (float) (int) tsip_word();
      clock_bias_rate *= 1.0e-12F;
   }
   else {  // invalid format
      check_tsip_end(1);
      if(tsip_error) return;
      return;
   }

   for(i=1; i<=MAX_PRN; i++) {  // reset current bias flags
      sat[i].last_bias_msg = 0;
   }

   for(i=0; i<8; i++) {  // get bias info from all satellites
      prn = tsip_byte();
      if(prn > MAX_PRN) prn = 0;  // put any bogus data in unused entry in array
      if(format == 0) {
         sat_bias = tsip_single();
      }
      else {
         sat_bias = (float) (int) tsip_word();
         sat_bias *= 100.0e-12F;
      }

      sat[prn].time_of_fix = (float) time_of_week;
      sat[prn].sat_bias = sat_bias;
      sat[prn].last_bias_msg = 1;

      if(have_bias == 0) need_redraw = 2006;
      have_bias = 1;
   }
   check_tsip_end(1);
   if(tsip_error) return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0xacaf3(%rip), %rdi     # 0x1220a1
callq 0x58dc2
leaq 0x1a5a1a(%rip), %rax    # 0x21afd4
cmpl $0x53, (%rax)
jne 0x755ce
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x587be
movl %eax, %ebx
cmpl $0x100, %eax            # imm = 0x100
jb 0x755e6
leaq 0x1c998d(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
callq 0x58964
movl %eax, %r14d
testb %bl, %bl
je 0x75607
cmpb $0x1, %bl
jne 0x756da
callq 0x588d2
callq 0x588d2
jmp 0x75611
callq 0x58a30
callq 0x58a30
movl $0x588, %eax            # imm = 0x588
leaq 0x1c9993(%rip), %r15    # 0x23efb0
movb $0x0, (%r15,%rax)
addq $0x348, %rax            # imm = 0x348
cmpq $0xcd380, %rax          # imm = 0xCD380
jne 0x7561d
movl %r14d, %eax
xorps %xmm0, %xmm0
cvtsi2ss %rax, %xmm0
movss %xmm0, -0x2c(%rbp)
movl $0x8, %r12d
leaq 0x297d6f(%rip), %r13    # 0x30d3bc
callq 0x587be
movl %eax, %r14d
cmpl $0x100, %eax            # imm = 0x100
jb 0x75666
leaq 0x1c990d(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
testb %bl, %bl
je 0x75683
callq 0x588d2
movzwl %ax, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
mulss 0xa93d3(%rip), %xmm0    # 0x11ea54
jmp 0x75688
callq 0x58a30
movzbl %r14b, %eax
imulq $0x348, %rax, %rax      # imm = 0x348
movss -0x2c(%rbp), %xmm1
movss %xmm1, 0x23c(%r15,%rax)
movss %xmm0, 0x238(%r15,%rax)
movb $0x1, 0x240(%r15,%rax)
cmpl $0x0, (%r13)
jne 0x756c9
leaq 0x1a3181(%rip), %rax    # 0x218844
movl $0x7d6, (%rax)          # imm = 0x7D6
movl $0x1, (%r13)
decl %r12d
jne 0x7564d
xorl %edi, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x58e9b