// File: /workspace/github_cpp_makefile_star2_O2/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 0x26b24d(%rip), %rax    # 0x2f71d8
movl (%rax), %edx
movl %edx, %ecx
andl $-0x7, %ecx
leaq 0x7d8af(%rip), %r8      # 0x109848
movslq (%r8,%rsi,4), %rsi
addq %r8, %rsi
jmpq *%rsi
orl $0x4, %ecx
jmp 0x8bfb1
orl $0x2, %ecx
jmp 0x8bfb1
orl $0x6, %edx
movl %edx, %ecx
leaq 0x26b274(%rip), %rdx    # 0x2f722c
movl $0x1, %esi
movl %esi, (%rdx)
movl %edi, %edx
andl $0x8, %edx
andl $0xfffff7d7, %ecx       # imm = 0xFFFFF7D7
orl %edx, %ecx
leaq 0x26b4c9(%rip), %r8     # 0x2f749c
movl %edx, (%r8)
leaq 0x26b2d3(%rip), %rdx    # 0x2f72b0
movl %esi, (%rdx)
leaq 0x26b2aa(%rip), %rdx    # 0x2f7290
movl %esi, (%rdx)
movl %edi, %edx
andl $0x10, %edx
movl %edi, %r8d
shll $0x4, %r8d
andl $0x800, %r8d            # imm = 0x800
leal (%r8,%rdx,2), %edx
orl %ecx, %edx
movl %edx, (%rax)
leaq 0x26b29a(%rip), %rax    # 0x2f72a4
movl %esi, (%rax)
shrl $0xd, %edi
andl $0x7, %edi
cmpl $0x3, %edi
sete %al
shlb $0x2, %al
leaq 0x26b475(%rip), %rcx    # 0x2f7497
movb %al, (%rcx)
leal -0x4(%rdi), %ecx
cmpl $0x4, %ecx
jae 0x8c038
shll $0x3, %ecx
movl $0x4030807, %eax        # imm = 0x4030807
shrl %cl, %eax
jmp 0x8c04f
movb $0x9, %al
cmpl $0x3, %edi
je 0x8c04f
cmpl $0x2, %edi
movl $0xa, %ecx
movl $0x63, %eax
cmovel %ecx, %eax
leaq 0x26b07a(%rip), %rcx    # 0x2f70d0
movb %al, (%rcx)
leaq 0x26b3ae(%rip), %rax    # 0x2f740d
movb $0x5, (%rax)
popq %rbp
retq