// File: /workspace/github_cpp_makefile_star2_O3/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 0x1994b3(%rip), %rax    # 0x21b0dc
movl %edi, (%rax)
movl $0x0, 0x2f01ef(%rip)    # 0x371e24
leaq 0x28b394(%rip), %rax    # 0x30cfd0
movsd (%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
leaq 0x28b38c(%rip), %rax    # 0x30cfd8
movsd (%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
leaq 0x28b384(%rip), %rax    # 0x30cfe0
movsd (%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
leaq 0x28b89c(%rip), %rax    # 0x30d508
movl (%rax), %eax
movl %eax, -0x48(%rbp)
leaq 0x28b88c(%rip), %rax    # 0x30d504
movl (%rax), %eax
movl %eax, -0x44(%rbp)
leaq 0x28b87c(%rip), %rax    # 0x30d500
movl (%rax), %eax
movl %eax, -0x40(%rbp)
leaq 0x28b884(%rip), %rcx    # 0x30d514
leaq 0x28b881(%rip), %rax    # 0x30d518
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
leaq 0x28b839(%rip), %rax    # 0x30d4e0
movsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
leaq 0x199429(%rip), %rax    # 0x21b0e0
cmpl $0x0, (%rax)
movl (%rcx), %eax
movl %eax, -0x3c(%rbp)
leaq 0x28b84a(%rip), %rax    # 0x30d510
movl (%rax), %eax
movl %eax, -0x38(%rbp)
leaq 0x28b83a(%rip), %rax    # 0x30d50c
movl (%rax), %eax
movl %eax, -0x34(%rbp)
leaq 0x28b7f2(%rip), %rax    # 0x30d4d0
movl (%rax), %eax
movl %eax, -0x30(%rbp)
leaq 0x28b7e2(%rip), %rax    # 0x30d4cc
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
leaq 0x28b7d2(%rip), %rax    # 0x30d4c8
movl (%rax), %r12d
leaq 0x28b7dc(%rip), %rax    # 0x30d4dc
movl (%rax), %r15d
leaq 0x28b7ce(%rip), %rax    # 0x30d4d8
movl (%rax), %r13d
leaq 0x28b7c0(%rip), %rax    # 0x30d4d4
movl (%rax), %r14d
jne 0x81d35
leaq 0x1993b8(%rip), %rax    # 0x21b0d8
cmpl $0x0, (%rax)
jne 0x81d35
leaq 0x1993a8(%rip), %rax    # 0x21b0d4
cmpl $0x0, (%rax)
je 0x81f33
callq 0x810b1
callq 0x816d8
callq 0x8175a
callq 0x810b1
testl %eax, %eax
je 0x81e4c
leaq 0x2b9ce8(%rip), %rbx    # 0x33ba40
movq %rbx, %rdi
callq 0x9120
testq %rax, %rax
je 0x81e4c
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 0x81d6d
testl %edx, %edx
je 0x81e4c
callq 0x810b1
testl %eax, %eax
je 0x81db6
leaq 0x2b9ca5(%rip), %rdi    # 0x33ba40
callq 0x95e0
leaq 0x1bd165(%rip), %rcx    # 0x23ef0c
movl %eax, (%rcx)
leaq 0x28b568(%rip), %rax    # 0x30d318
movl $0x2, (%rax)
callq 0x810b1
callq 0x810b1
testl %eax, %eax
je 0x81de2
leaq 0x2b9c75(%rip), %rdi    # 0x33ba40
callq 0x95e0
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
leaq 0x28b202(%rip), %rax    # 0x30cfe0
movsd %xmm0, (%rax)
callq 0x810b1
callq 0x810b1
callq 0x810b1
callq 0x810b1
leaq 0x1bd10f(%rip), %rax    # 0x23ef0c
movl (%rax), %edi
callq 0x5e390
callq 0x81ad5
leaq 0x1992d0(%rip), %rax    # 0x21b0e0
cmpl $0x0, (%rax)
jne 0x81f24
leaq 0x1992b8(%rip), %rax    # 0x21b0d8
cmpl $0x0, (%rax)
jne 0x81f24
leaq 0x1992a4(%rip), %rax    # 0x21b0d4
cmpl $0x0, (%rax)
jne 0x81f24
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x81f3d
leaq 0x28b6b5(%rip), %rax    # 0x30d508
movl -0x48(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x28b6a5(%rip), %rax    # 0x30d504
movl -0x44(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x28b695(%rip), %rax    # 0x30d500
movl -0x40(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x28b69d(%rip), %rax    # 0x30d514
movl -0x3c(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x28b68d(%rip), %rax    # 0x30d510
movl -0x38(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x28b67d(%rip), %rax    # 0x30d50c
movl -0x34(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x28b635(%rip), %rax    # 0x30d4d0
movl -0x30(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x28b625(%rip), %rax    # 0x30d4cc
movl -0x2c(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x28b615(%rip), %rax    # 0x30d4c8
movl %r12d, (%rax)
leaq 0x28b61f(%rip), %rax    # 0x30d4dc
movl %r15d, (%rax)
leaq 0x28b611(%rip), %rax    # 0x30d4d8
movl %r13d, (%rax)
leaq 0x28b603(%rip), %rax    # 0x30d4d4
movl %r14d, (%rax)
leaq 0x28b0f5(%rip), %rax    # 0x30cfd0
movsd -0x70(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq 0x28b0ed(%rip), %rax    # 0x30cfd8
movsd -0x68(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq 0x28b0e5(%rip), %rax    # 0x30cfe0
movsd -0x60(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq 0x28b60d(%rip), %rax    # 0x30d518
movsd -0x58(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq 0x28b5c5(%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 0x81835
jmp 0x81d3a