// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
leaq 0x1993d2(%rip), %rax    # 0x21b0dc
movl %edi, (%rax)
movl $0x0, 0x2f010e(%rip)    # 0x371e24
leaq 0x28b2b3(%rip), %rax    # 0x30cfd0
movsd (%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
leaq 0x28b2ab(%rip), %rax    # 0x30cfd8
movsd (%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
leaq 0x28b2a3(%rip), %rax    # 0x30cfe0
movsd (%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
leaq 0x28b7bb(%rip), %rax    # 0x30d508
movl (%rax), %eax
movl %eax, -0x48(%rbp)
leaq 0x28b7ab(%rip), %rax    # 0x30d504
movl (%rax), %eax
movl %eax, -0x44(%rbp)
leaq 0x28b79b(%rip), %rax    # 0x30d500
movl (%rax), %eax
movl %eax, -0x40(%rbp)
leaq 0x28b7a3(%rip), %rcx    # 0x30d514
leaq 0x28b7a0(%rip), %rax    # 0x30d518
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
leaq 0x28b758(%rip), %rax    # 0x30d4e0
movsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
leaq 0x199348(%rip), %rax    # 0x21b0e0
cmpl $0x0, (%rax)
movl (%rcx), %eax
movl %eax, -0x3c(%rbp)
leaq 0x28b769(%rip), %rax    # 0x30d510
movl (%rax), %eax
movl %eax, -0x38(%rbp)
leaq 0x28b759(%rip), %rax    # 0x30d50c
movl (%rax), %eax
movl %eax, -0x34(%rbp)
leaq 0x28b711(%rip), %rax    # 0x30d4d0
movl (%rax), %eax
movl %eax, -0x30(%rbp)
leaq 0x28b701(%rip), %rax    # 0x30d4cc
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
leaq 0x28b6f1(%rip), %rax    # 0x30d4c8
movl (%rax), %r12d
leaq 0x28b6fb(%rip), %rax    # 0x30d4dc
movl (%rax), %r15d
leaq 0x28b6ed(%rip), %rax    # 0x30d4d8
movl (%rax), %r13d
leaq 0x28b6df(%rip), %rax    # 0x30d4d4
movl (%rax), %r14d
jne 0x81e16
leaq 0x1992d7(%rip), %rax    # 0x21b0d8
cmpl $0x0, (%rax)
jne 0x81e16
leaq 0x1992c7(%rip), %rax    # 0x21b0d4
cmpl $0x0, (%rax)
je 0x82014
callq 0x811da
callq 0x817c1
callq 0x81843
callq 0x811da
testl %eax, %eax
je 0x81f2d
leaq 0x2b9c07(%rip), %rbx    # 0x33ba40
movq %rbx, %rdi
callq 0x9120
testq %rax, %rax
je 0x81f2d
xorl %ecx, %ecx
xorl %edx, %edx
xorl %esi, %esi
cmpb $0x4e, (%rbx,%rcx)
setne %sil
addl %esi, %edx
incq %rcx
movl %ecx, %esi
cmpq %rsi, %rax
ja 0x81e4e
testl %edx, %edx
je 0x81f2d
callq 0x811da
testl %eax, %eax
je 0x81e97
leaq 0x2b9bc4(%rip), %rdi    # 0x33ba40
callq 0x95e0
leaq 0x1bd084(%rip), %rcx    # 0x23ef0c
movl %eax, (%rcx)
leaq 0x28b487(%rip), %rax    # 0x30d318
movl $0x2, (%rax)
callq 0x811da
callq 0x811da
testl %eax, %eax
je 0x81ec3
leaq 0x2b9b94(%rip), %rdi    # 0x33ba40
callq 0x95e0
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
leaq 0x28b121(%rip), %rax    # 0x30cfe0
movsd %xmm0, (%rax)
callq 0x811da
callq 0x811da
callq 0x811da
callq 0x811da
leaq 0x1bd02e(%rip), %rax    # 0x23ef0c
movl (%rax), %edi
callq 0x5e411
callq 0x81bb6
leaq 0x1991ef(%rip), %rax    # 0x21b0e0
cmpl $0x0, (%rax)
jne 0x82005
leaq 0x1991d7(%rip), %rax    # 0x21b0d8
cmpl $0x0, (%rax)
jne 0x82005
leaq 0x1991c3(%rip), %rax    # 0x21b0d4
cmpl $0x0, (%rax)
jne 0x82005
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8201e
leaq 0x28b5d4(%rip), %rax    # 0x30d508
movl -0x48(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x28b5c4(%rip), %rax    # 0x30d504
movl -0x44(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x28b5b4(%rip), %rax    # 0x30d500
movl -0x40(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x28b5bc(%rip), %rax    # 0x30d514
movl -0x3c(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x28b5ac(%rip), %rax    # 0x30d510
movl -0x38(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x28b59c(%rip), %rax    # 0x30d50c
movl -0x34(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x28b554(%rip), %rax    # 0x30d4d0
movl -0x30(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x28b544(%rip), %rax    # 0x30d4cc
movl -0x2c(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x28b534(%rip), %rax    # 0x30d4c8
movl %r12d, (%rax)
leaq 0x28b53e(%rip), %rax    # 0x30d4dc
movl %r15d, (%rax)
leaq 0x28b530(%rip), %rax    # 0x30d4d8
movl %r13d, (%rax)
leaq 0x28b522(%rip), %rax    # 0x30d4d4
movl %r14d, (%rax)
leaq 0x28b014(%rip), %rax    # 0x30cfd0
movsd -0x70(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq 0x28b00c(%rip), %rax    # 0x30cfd8
movsd -0x68(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq 0x28b004(%rip), %rax    # 0x30cfe0
movsd -0x60(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq 0x28b52c(%rip), %rax    # 0x30d518
movsd -0x58(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq 0x28b4e4(%rip), %rax    # 0x30d4e0
movsd -0x50(%rbp), %xmm0
movsd %xmm0, (%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x8191e
jmp 0x81e1b