// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heathgps.cpp
// Function: decode_moto_status(int)
void decode_moto_status(int r_status)
{
int ant;
int mode;

   // convert status word into tbolt equivalents

   // Bit fields:
   //    0x0006 = antenna status
   //    0x0008 = no sats
   //    0x0010 = survey mode
   //    0x0020 = posn lock
   //    0x0040 = differential mode
   //    0x0080 = cold start
   //    0x0100 - unfiltered GPS
   //    0x0200 - fast acquisition mode
   //    0x0400 - narrow band filter
   //    0xE000 = rcvr mode
   //             7=3d  6=2d  5=propogeate 4=posn hold  3=acquiring 2=bad geom

   ant = (r_status >> 1) & 0x03;

   minor_alarms &= (~MINOR_ANT_NO_PWR);  // antenna state
   if     (ant == 3) minor_alarms |= MINOR_ANT_NO_PWR;  // unbiased
   else if(ant == 2) minor_alarms |= MINOR_ANT_OPEN;    // open
   else if(ant == 1) minor_alarms |= MINOR_ANT_SHORT;   // short
   have_antenna = 1;

   if(r_status & 0x0008) {
      minor_alarms |= MINOR_NO_TRACK;    // no sats
      gps_status = GPS_NO_SATS;
   }
   else { 
      minor_alarms &= (~MINOR_NO_TRACK);
      gps_status = GPS_FIXES;
   }
   have_gps_status = 1;
   have_tracking = 1;

   set_survey_status(r_status & 0x0010);

   if(r_status & 0x0080) minor_alarms |= MINOR_ALMANAC;   // cold start/no almanac
   else                  minor_alarms &= (~MINOR_ALMANAC);
   have_almanac = 1;

   //  mode: 7=3d  6=2d  5=propogate 4=posn hold  3=acquiring 2=bad geom
   mode = (r_status >> 13) & 0x07;  

   if(mode == 3) discipline_mode = DIS_MODE_RECOVERY;
   else          discipline_mode = DIS_MODE_NORMAL;

   if     (mode == 7) rcvr_mode = RCVR_MODE_3D;
   else if(mode == 6) rcvr_mode = RCVR_MODE_2D;
   else if(mode == 5) rcvr_mode = RCVR_MODE_PROP;
   else if(mode == 4) rcvr_mode = RCVR_MODE_HOLD;
   else if(mode == 3) rcvr_mode = RCVR_MODE_ACQUIRE;
   else if(mode == 2) rcvr_mode = RCVR_MODE_BAD_GEOM;
   else               rcvr_mode = RCVR_MODE_UNKNOWN;
   have_rcvr_mode = 5;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, %esi
shrl %esi
andl $0x3, %esi
leaq 0x272ed4(%rip), %rax    # 0x30d1d8
movl (%rax), %ecx
movl %ecx, %edx
andl $-0x7, %edx
movl %edx, (%rax)
leaq 0x85518(%rip), %r8      # 0x11f82c
movslq (%r8,%rsi,4), %rsi
addq %r8, %rsi
jmpq *%rsi
orl $0x4, %edx
jmp 0x9a325
orl $0x2, %edx
movl %edx, %ecx
jmp 0x9a32c
orl $0x6, %ecx
movl %ecx, (%rax)
leaq 0x272ef7(%rip), %rcx    # 0x30d22c
movl $0x1, %edx
movl %edx, (%rcx)
movl %edi, %ecx
andl $0x8, %ecx
movl $0xfffff7d7, %esi       # imm = 0xFFFFF7D7
andl (%rax), %esi
orl %ecx, %esi
leaq 0x27314b(%rip), %r8     # 0x30d49c
movl %ecx, (%r8)
leaq 0x272f55(%rip), %rcx    # 0x30d2b0
movl %edx, (%rcx)
leaq 0x272f2c(%rip), %rcx    # 0x30d290
movl %edx, (%rcx)
movl %edi, %ecx
andl $0x10, %ecx
movl %edi, %r8d
shll $0x4, %r8d
andl $0x800, %r8d            # imm = 0x800
leal (%r8,%rcx,2), %ecx
orl %esi, %ecx
movl %ecx, (%rax)
leaq 0x272f1c(%rip), %rax    # 0x30d2a4
movl %edx, (%rax)
shrl $0xd, %edi
andl $0x7, %edi
cmpl $0x3, %edi
sete %al
shlb $0x2, %al
leaq 0x2730f7(%rip), %rcx    # 0x30d497
movb %al, (%rcx)
leal -0x4(%rdi), %ecx
cmpl $0x4, %ecx
jae 0x9a3b6
shll $0x3, %ecx
movl $0x4030807, %eax        # imm = 0x4030807
shrl %cl, %eax
jmp 0x9a3cd
movb $0x9, %al
cmpl $0x3, %edi
je 0x9a3cd
cmpl $0x2, %edi
movl $0xa, %ecx
movl $0x63, %eax
cmovel %ecx, %eax
leaq 0x272cfc(%rip), %rcx    # 0x30d0d0
movb %al, (%rcx)
leaq 0x273030(%rip), %rax    # 0x30d40d
movb $0x5, (%rax)
popq %rbp
retq