// File: jkingan[P]ladyheather/heathgps.cpp
// Function: parse_gpgns(int)
void parse_gpgns(int system)
{
double old_lat, old_lon, old_alt;
int old_hours;
int old_minutes;
int old_seconds;
int old_year;
int old_month;
int old_day;
double old_frac;

int old_pri_hours;
int old_pri_minutes;
int old_pri_seconds;
int old_pri_year;
int old_pri_month;
int old_pri_day;
double old_pri_frac;
unsigned i, aok;

   have_gpgns = system;
   last_was_gsv = 0;

   old_lat = lat;
   old_lon = lon;
   old_alt = alt;

   old_pri_hours = pri_hours;
   old_pri_minutes = pri_minutes;
   old_pri_seconds = pri_seconds;
   old_pri_year = pri_year;
   old_pri_month = pri_month;
   old_pri_day = pri_day;
   old_pri_frac = pri_frac;

   old_hours = hours;
   old_minutes = minutes;
   old_seconds = seconds;
   old_year = year;
   old_month = month;
   old_day = day;
   old_frac = raw_frac;

   if     (TIME_FILTER && have_gpzda) get_msg_field();
   else if(TIME_FILTER && have_gprmc) get_msg_field(); 
   else if(TIME_FILTER && have_gpgga) get_msg_field(); 
   else                               get_nmea_time();

   get_nmea_lat();
   get_nmea_lon();

   if(get_msg_field()) {  // mode
      aok = 0;
      for(i=0; i<strlen(msg_field); i++) {
         if(msg_field[i] != 'N') ++aok;
      }

      if(aok == 0) {  // invalid fix for all systems
         reject:
         lat = old_lat;
         lon = old_lon;
         alt = old_alt;

         pri_hours = old_pri_hours;   
         pri_minutes = old_pri_minutes; 
         pri_seconds = old_pri_seconds; 
         pri_year = old_pri_year;    
         pri_month = old_pri_month;   
         pri_day = old_pri_day;     
         pri_frac = old_pri_frac;    

         hours = old_hours;   
         minutes = old_minutes; 
         seconds = old_seconds; 
         year = old_year;    
         month = old_month;   
         day = old_day;     
         raw_frac = old_frac;
         return;
      }
   }
   else goto reject;

   if(get_msg_field()) {  // sat count
      sat_count = atoi(msg_field);
      have_count = 2;
   }

   get_msg_field();  // HDOP

   if(get_msg_field()) {
      alt = atoi(msg_field);
   }

   if(get_msg_field()) {  // geoid height separation in meters
   }
   if(get_msg_field()) {  // DGPS age
   }
   if(get_msg_field()) {  // DGPS ref station id
   }

   if(get_msg_field()) {  // nav status - non-standard, Furuno sends this
      // S=safe
      // C=caution
      // U=unsafe
      // V=valid
   }

   config_sat_count(sat_count);

   check_nmea_date();

   // priority of date/time is ZDA, RMC, GGA, GNS
   if     (TIME_FILTER && have_gpzda) ;
   else if(TIME_FILTER && have_gprmc) ;
   else if(TIME_FILTER && have_gpgga) ;
   else drive_nmea_screen(system, NMEA_GNS);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movl %edi, -0x4(%rbp)
movl -0x4(%rbp), %ecx
leaq 0x1c8747(%rip), %rax    # 0x27a2bc
movl %ecx, (%rax)
movl $0x0, 0x31f473(%rip)    # 0x3d0ff4
leaq 0x2ba628(%rip), %rax    # 0x36c1b0
movsd (%rax), %xmm0
movsd %xmm0, -0x10(%rbp)
leaq 0x2ba620(%rip), %rax    # 0x36c1b8
movsd (%rax), %xmm0
movsd %xmm0, -0x18(%rbp)
leaq 0x2ba618(%rip), %rax    # 0x36c1c0
movsd (%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
leaq 0x2bab30(%rip), %rax    # 0x36c6e8
movl (%rax), %eax
movl %eax, -0x44(%rbp)
leaq 0x2bab20(%rip), %rax    # 0x36c6e4
movl (%rax), %eax
movl %eax, -0x48(%rbp)
leaq 0x2bab10(%rip), %rax    # 0x36c6e0
movl (%rax), %eax
movl %eax, -0x4c(%rbp)
leaq 0x2bab18(%rip), %rax    # 0x36c6f4
movl (%rax), %eax
movl %eax, -0x50(%rbp)
leaq 0x2bab08(%rip), %rax    # 0x36c6f0
movl (%rax), %eax
movl %eax, -0x54(%rbp)
leaq 0x2baaf8(%rip), %rax    # 0x36c6ec
movl (%rax), %eax
movl %eax, -0x58(%rbp)
leaq 0x2baaf8(%rip), %rax    # 0x36c6f8
movsd (%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
leaq 0x2baaa0(%rip), %rax    # 0x36c6b0
movl (%rax), %eax
movl %eax, -0x24(%rbp)
leaq 0x2baa90(%rip), %rax    # 0x36c6ac
movl (%rax), %eax
movl %eax, -0x28(%rbp)
leaq 0x2baa80(%rip), %rax    # 0x36c6a8
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
leaq 0x2baa88(%rip), %rax    # 0x36c6bc
movl (%rax), %eax
movl %eax, -0x30(%rbp)
leaq 0x2baa78(%rip), %rax    # 0x36c6b8
movl (%rax), %eax
movl %eax, -0x34(%rbp)
leaq 0x2baa68(%rip), %rax    # 0x36c6b4
movl (%rax), %eax
movl %eax, -0x38(%rbp)
leaq 0x2baa68(%rip), %rax    # 0x36c6c0
movsd (%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
leaq 0x1c8658(%rip), %rax    # 0x27a2c0
cmpl $0x0, (%rax)
je 0xb1c74
callq 0xb0bd0
jmp 0xb1ca3
leaq 0x1c863d(%rip), %rax    # 0x27a2b8
cmpl $0x0, (%rax)
je 0xb1c87
callq 0xb0bd0
jmp 0xb1ca1
leaq 0x1c8626(%rip), %rax    # 0x27a2b4
cmpl $0x0, (%rax)
je 0xb1c9a
callq 0xb0bd0
jmp 0xb1c9f
callq 0xb1730
jmp 0xb1ca1
jmp 0xb1ca3
callq 0xb14a0
callq 0xb15b0
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb1e06
movl $0x0, -0x68(%rbp)
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
movq %rax, -0x70(%rbp)
leaq 0x2e8f49(%rip), %rdi    # 0x39ac20
callq 0x9120
movq %rax, %rcx
movq -0x70(%rbp), %rax
cmpq %rcx, %rax
jae 0xb1d13
movl -0x64(%rbp), %eax
movl %eax, %ecx
leaq 0x2e8f2c(%rip), %rax    # 0x39ac20
movsbl (%rax,%rcx), %eax
cmpl $0x4e, %eax
je 0xb1d06
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0xb1d08
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0xb1cc9
cmpl $0x0, -0x68(%rbp)
jne 0xb1e04
jmp 0xb1d1f
movsd -0x10(%rbp), %xmm0
leaq 0x2ba485(%rip), %rax    # 0x36c1b0
movsd %xmm0, (%rax)
movsd -0x18(%rbp), %xmm0
leaq 0x2ba47d(%rip), %rax    # 0x36c1b8
movsd %xmm0, (%rax)
movsd -0x20(%rbp), %xmm0
leaq 0x2ba475(%rip), %rax    # 0x36c1c0
movsd %xmm0, (%rax)
movl -0x44(%rbp), %ecx
leaq 0x2ba98f(%rip), %rax    # 0x36c6e8
movl %ecx, (%rax)
movl -0x48(%rbp), %ecx
leaq 0x2ba97f(%rip), %rax    # 0x36c6e4
movl %ecx, (%rax)
movl -0x4c(%rbp), %ecx
leaq 0x2ba96f(%rip), %rax    # 0x36c6e0
movl %ecx, (%rax)
movl -0x50(%rbp), %ecx
leaq 0x2ba977(%rip), %rax    # 0x36c6f4
movl %ecx, (%rax)
movl -0x54(%rbp), %ecx
leaq 0x2ba967(%rip), %rax    # 0x36c6f0
movl %ecx, (%rax)
movl -0x58(%rbp), %ecx
leaq 0x2ba957(%rip), %rax    # 0x36c6ec
movl %ecx, (%rax)
movsd -0x60(%rbp), %xmm0
leaq 0x2ba955(%rip), %rax    # 0x36c6f8
movsd %xmm0, (%rax)
movl -0x24(%rbp), %ecx
leaq 0x2ba8ff(%rip), %rax    # 0x36c6b0
movl %ecx, (%rax)
movl -0x28(%rbp), %ecx
leaq 0x2ba8ef(%rip), %rax    # 0x36c6ac
movl %ecx, (%rax)
movl -0x2c(%rbp), %ecx
leaq 0x2ba8df(%rip), %rax    # 0x36c6a8
movl %ecx, (%rax)
movl -0x30(%rbp), %ecx
leaq 0x2ba8e7(%rip), %rax    # 0x36c6bc
movl %ecx, (%rax)
movl -0x34(%rbp), %ecx
leaq 0x2ba8d7(%rip), %rax    # 0x36c6b8
movl %ecx, (%rax)
movl -0x38(%rbp), %ecx
leaq 0x2ba8c7(%rip), %rax    # 0x36c6b4
movl %ecx, (%rax)
movsd -0x40(%rbp), %xmm0
leaq 0x2ba8c5(%rip), %rax    # 0x36c6c0
movsd %xmm0, (%rax)
jmp 0xb1ee1
jmp 0xb1e0b
jmp 0xb1d1f
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb1e39
leaq 0x2e8e04(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, %ecx
leaq 0x1ec2c2(%rip), %rax    # 0x29e0ec
movl %ecx, (%rax)
leaq 0x2ba6c5(%rip), %rax    # 0x36c4f8
movl $0x2, (%rax)
callq 0xb0bd0
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb1e63
leaq 0x2e8dd1(%rip), %rdi    # 0x39ac20
callq 0x95c0
cvtsi2sd %eax, %xmm0
leaq 0x2ba361(%rip), %rax    # 0x36c1c0
movsd %xmm0, (%rax)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb1e6f
jmp 0xb1e6f
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb1e7b
jmp 0xb1e7b
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb1e87
jmp 0xb1e87
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb1e93
jmp 0xb1e93
leaq 0x1ec252(%rip), %rax    # 0x29e0ec
movl (%rax), %edi
callq 0x82080
callq 0xb19e0
leaq 0x1c8413(%rip), %rax    # 0x27a2c0
cmpl $0x0, (%rax)
je 0xb1eb4
jmp 0xb1ee1
leaq 0x1c83fd(%rip), %rax    # 0x27a2b8
cmpl $0x0, (%rax)
je 0xb1ec2
jmp 0xb1edf
leaq 0x1c83eb(%rip), %rax    # 0x27a2b4
cmpl $0x0, (%rax)
je 0xb1ed0
jmp 0xb1edd
movl -0x4(%rbp), %edi
movl $0x4, %esi
callq 0xb1ef0
jmp 0xb1edf
jmp 0xb1ee1
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)