// File: /workspace/github_cpp_makefile_star2_O2/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 0x18eed1(%rip), %rax    # 0x2050dc
movl %edi, (%rax)
andl $0x0, 0x2e5c10(%rip)    # 0x35be24
leaq 0x280db5(%rip), %rax    # 0x2f6fd0
movsd (%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
leaq 0x280dad(%rip), %rax    # 0x2f6fd8
movsd (%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
leaq 0x280da5(%rip), %rbx    # 0x2f6fe0
movsd (%rbx), %xmm0
movsd %xmm0, -0x60(%rbp)
leaq 0x2812bd(%rip), %rax    # 0x2f7508
movl (%rax), %eax
movl %eax, -0x48(%rbp)
leaq 0x2812ad(%rip), %rax    # 0x2f7504
movl (%rax), %eax
movl %eax, -0x44(%rbp)
leaq 0x28129d(%rip), %rax    # 0x2f7500
movl (%rax), %eax
movl %eax, -0x40(%rbp)
leaq 0x2812a5(%rip), %rcx    # 0x2f7514
leaq 0x2812a2(%rip), %rax    # 0x2f7518
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
leaq 0x28125a(%rip), %rax    # 0x2f74e0
movsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
leaq 0x18ee4a(%rip), %rax    # 0x2050e0
cmpl $0x0, (%rax)
movl (%rcx), %eax
movl %eax, -0x3c(%rbp)
leaq 0x28126b(%rip), %rax    # 0x2f7510
movl (%rax), %eax
movl %eax, -0x38(%rbp)
leaq 0x28125b(%rip), %rax    # 0x2f750c
movl (%rax), %eax
movl %eax, -0x34(%rbp)
leaq 0x281213(%rip), %rax    # 0x2f74d0
movl (%rax), %eax
movl %eax, -0x30(%rbp)
leaq 0x281203(%rip), %rax    # 0x2f74cc
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
leaq 0x2811f3(%rip), %rax    # 0x2f74c8
movl (%rax), %r12d
leaq 0x2811fd(%rip), %rax    # 0x2f74dc
movl (%rax), %r15d
leaq 0x2811ef(%rip), %rax    # 0x2f74d8
movl (%rax), %r13d
leaq 0x2811e1(%rip), %rax    # 0x2f74d4
movl (%rax), %r14d
jne 0x76314
leaq 0x18edd9(%rip), %rax    # 0x2050d8
cmpl $0x0, (%rax)
jne 0x76314
leaq 0x18edc9(%rip), %rax    # 0x2050d4
cmpl $0x0, (%rax)
je 0x76500
callq 0x75767
callq 0x75d56
callq 0x75dd8
callq 0x75767
testl %eax, %eax
je 0x76420
leaq 0x2af709(%rip), %rbx    # 0x325a40
movq %rbx, %rdi
callq 0x9120
xorl %edx, %edx
xorl %ecx, %ecx
movl %edx, %edx
cmpq %rdx, %rax
jbe 0x7635a
xorl %esi, %esi
cmpb $0x4e, (%rbx,%rdx)
setne %sil
addl %esi, %ecx
incl %edx
jmp 0x76343
testl %ecx, %ecx
leaq 0x280c7d(%rip), %rbx    # 0x2f6fe0
je 0x76420
callq 0x75767
testl %eax, %eax
je 0x76394
leaq 0x2af6c7(%rip), %rdi    # 0x325a40
callq 0x95e0
leaq 0x1b2b87(%rip), %rcx    # 0x228f0c
movl %eax, (%rcx)
leaq 0x280f8a(%rip), %rax    # 0x2f7318
movl $0x2, (%rax)
callq 0x75767
callq 0x75767
testl %eax, %eax
je 0x763b6
leaq 0x2af697(%rip), %rdi    # 0x325a40
callq 0x95e0
cvtsi2sd %eax, %xmm0
movsd %xmm0, (%rbx)
callq 0x75767
callq 0x75767
callq 0x75767
callq 0x75767
leaq 0x1b2b3b(%rip), %rax    # 0x228f0c
movl (%rax), %edi
callq 0x56d93
callq 0x760b7
leaq 0x18ecfc(%rip), %rax    # 0x2050e0
cmpl $0x0, (%rax)
jne 0x764f1
leaq 0x18ece4(%rip), %rax    # 0x2050d8
cmpl $0x0, (%rax)
jne 0x764f1
leaq 0x18ecd0(%rip), %rax    # 0x2050d4
cmpl $0x0, (%rax)
jne 0x764f1
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7650a
leaq 0x2810e1(%rip), %rax    # 0x2f7508
movl -0x48(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x2810d1(%rip), %rax    # 0x2f7504
movl -0x44(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x2810c1(%rip), %rax    # 0x2f7500
movl -0x40(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x2810c9(%rip), %rax    # 0x2f7514
movl -0x3c(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x2810b9(%rip), %rax    # 0x2f7510
movl -0x38(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x2810a9(%rip), %rax    # 0x2f750c
movl -0x34(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x281061(%rip), %rax    # 0x2f74d0
movl -0x30(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x281051(%rip), %rax    # 0x2f74cc
movl -0x2c(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x281041(%rip), %rax    # 0x2f74c8
movl %r12d, (%rax)
leaq 0x28104b(%rip), %rax    # 0x2f74dc
movl %r15d, (%rax)
leaq 0x28103d(%rip), %rax    # 0x2f74d8
movl %r13d, (%rax)
leaq 0x28102f(%rip), %rax    # 0x2f74d4
movl %r14d, (%rax)
leaq 0x280b21(%rip), %rax    # 0x2f6fd0
movsd -0x70(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq 0x280b19(%rip), %rax    # 0x2f6fd8
movsd -0x68(%rbp), %xmm0
movsd %xmm0, (%rax)
movsd -0x60(%rbp), %xmm0
movsd %xmm0, (%rbx)
leaq 0x281040(%rip), %rax    # 0x2f7518
movsd -0x58(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq 0x280ff8(%rip), %rax    # 0x2f74e0
movsd -0x50(%rbp), %xmm0
movsd %xmm0, (%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x75eb3
jmp 0x76319