// File: jkingan[P]ladyheather/heathgps.cpp
// Function: parse_gptps()
void parse_gptps()
{
int yy,mm,dd;
int hrs,mins,secs;
int pend, leap_flag;
int i, val;

   get_msg_field();  // 2: eat the date/time

   if(get_msg_field()) {  // 3: time standard
      val = atoi(msg_field);
      if(val == 1) { // RTC time
      }
      else if(val == 2) {  // GPS time
         time_flags &= (~TFLAGS_UTC);
         have_timing_mode = 1;
         have_rcvr_tmode = 1;
      }
      else if(val == 3) {  // UTC time
         time_flags |= TFLAGS_UTC;
         have_timing_mode = 1;
         have_rcvr_tmode = 1;
      }
   }

   get_msg_field();  // 4: eat PPS status
   get_msg_field();  // 5: eat the fix mode

   leap_flag = 0;
   yy = mm = dd = 0;
   hrs = mins = secs = 0;
   if(get_msg_field()) {  // 6: pending leapsecond date/time
      if(atoi(msg_field)) {
         sscanf(msg_field, "%2d%2d%2d%2d%2d%2d", &yy,&mm,&dd, &hrs,&mins,&secs);
         yy += 2000;
         leap_flag = 1;
      }
   }

   minor_alarms &= (~MINOR_LEAP_PEND);
   if(get_msg_field()) {  // 7: leapsecond adjustment (-1, 00, +1)
      pend = atoi(msg_field);  // leap second +/- 1
//sprintf(debug_text, "leap dir:%s  pend:%d", msg_field, pend);
      if(pend && leap_flag) {
         minor_alarms |= MINOR_LEAP_PEND;
         jd_leap = jdate(yy,mm, dd) + jtime(hrs,mins,secs,-1.0);  // -1 since says 2017/1/1
         have_jd_leap = 88;
         calc_jd_leap(88);
      }
      have_leap_info = 54;
   }

   if(get_msg_field()) {  // 8: leap second count
      i = atoi(msg_field);
      time_flags |= TFLAGS_NO_UTC_OFS;
      if(i) {
         time_flags &= (~TFLAGS_NO_UTC_OFS);
         if(!user_set_utc_ofs) utc_offset = i;
         check_utc_ofs(334);
      }
   }

   if(get_msg_field()) {  // 9: UTC parameter date/time
   }

   if(get_msg_field()) {  // 10: gps week
      gps_week = atoi(msg_field);
      faked_tow = 0;
      have_week = 1;
   }

   if(get_msg_field()) {  // 11: GPS TOW
      pri_tow = atoi(msg_field);
      tow = pri_tow;  
      this_tow = tow;
      survey_tow = tow;

      if(have_tow == 0) need_redraw = 3029;
      have_tow = 55;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
callq 0xb0bd0
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb4074
leaq 0x2e6c2e(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x28(%rbp)
cmpl $0x1, -0x28(%rbp)
jne 0xb4002
jmp 0xb4072
cmpl $0x2, -0x28(%rbp)
jne 0xb4039
leaq 0x2b8675(%rip), %rax    # 0x36c684
movl (%rax), %ecx
andl $-0x2, %ecx
leaq 0x2b8669(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
leaq 0x2b8588(%rip), %rax    # 0x36c5ac
movl $0x1, (%rax)
leaq 0x2b857f(%rip), %rax    # 0x36c5b0
movl $0x1, (%rax)
jmp 0xb4070
cmpl $0x3, -0x28(%rbp)
jne 0xb406e
leaq 0x2b863e(%rip), %rax    # 0x36c684
movl (%rax), %ecx
orl $0x1, %ecx
leaq 0x2b8632(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
leaq 0x2b8551(%rip), %rax    # 0x36c5ac
movl $0x1, (%rax)
leaq 0x2b8548(%rip), %rax    # 0x36c5b0
movl $0x1, (%rax)
jmp 0xb4070
jmp 0xb4072
jmp 0xb4074
callq 0xb0bd0
callq 0xb0bd0
movl $0x0, -0x20(%rbp)
movl $0x0, -0xc(%rbp)
movl $0x0, -0x8(%rbp)
movl $0x0, -0x4(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x14(%rbp)
movl $0x0, -0x10(%rbp)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb4114
leaq 0x2e6b60(%rip), %rdi    # 0x39ac20
callq 0x95c0
cmpl $0x0, %eax
je 0xb4112
leaq 0x2e6b4f(%rip), %rdi    # 0x39ac20
leaq 0xd2028(%rip), %rsi     # 0x186100
leaq -0x4(%rbp), %rdx
leaq -0x8(%rbp), %rcx
leaq -0xc(%rbp), %r8
leaq -0x10(%rbp), %r9
leaq -0x14(%rbp), %r10
leaq -0x18(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x9370
movl -0x4(%rbp), %eax
addl $0x7d0, %eax            # imm = 0x7D0
movl %eax, -0x4(%rbp)
movl $0x1, -0x20(%rbp)
jmp 0xb4114
leaq 0x2b829d(%rip), %rax    # 0x36c3b8
movl (%rax), %ecx
andl $0xffffff7f, %ecx       # imm = 0xFFFFFF7F
leaq 0x2b828e(%rip), %rax    # 0x36c3b8
movl %ecx, (%rax)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb41d1
leaq 0x2e6adf(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0xb41c4
cmpl $0x0, -0x20(%rbp)
je 0xb41c4
leaq 0x2b825c(%rip), %rax    # 0x36c3b8
movl (%rax), %ecx
orl $0x80, %ecx
leaq 0x2b824d(%rip), %rax    # 0x36c3b8
movl %ecx, (%rax)
movl -0x4(%rbp), %edi
movl -0x8(%rbp), %esi
movl -0xc(%rbp), %edx
callq 0x122140
movsd %xmm0, -0x30(%rbp)
movl -0x10(%rbp), %edi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
movsd 0xbaf87(%rip), %xmm0    # 0x16f118
callq 0x122210
movaps %xmm0, %xmm1
movsd -0x30(%rbp), %xmm0
addsd %xmm1, %xmm0
leaq 0x2b8597(%rip), %rax    # 0x36c740
movsd %xmm0, (%rax)
leaq 0x2b8594(%rip), %rax    # 0x36c748
movl $0x58, (%rax)
movl $0x58, %edi
callq 0x80070
leaq 0x2b82ad(%rip), %rax    # 0x36c478
movl $0x36, (%rax)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb423e
leaq 0x2e6a3e(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x24(%rbp)
leaq 0x2b8493(%rip), %rax    # 0x36c684
movl (%rax), %ecx
orl $0x8, %ecx
leaq 0x2b8487(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
cmpl $0x0, -0x24(%rbp)
je 0xb423c
leaq 0x2b8478(%rip), %rax    # 0x36c684
movl (%rax), %ecx
andl $-0x9, %ecx
leaq 0x2b846c(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
leaq 0x2b86f3(%rip), %rax    # 0x36c914
cmpl $0x0, (%rax)
jne 0xb4232
movl -0x24(%rbp), %ecx
leaq 0x2b86d8(%rip), %rax    # 0x36c908
movl %ecx, (%rax)
movl $0x14e, %edi            # imm = 0x14E
callq 0x7a270
jmp 0xb423e
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb424a
jmp 0xb424a
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb4287
leaq 0x2e69c5(%rip), %rdi    # 0x39ac20
callq 0x95c0
movw %ax, %cx
leaq 0x2b86ae(%rip), %rax    # 0x36c918
movw %cx, (%rax)
leaq 0x2b86b4(%rip), %rax    # 0x36c928
movl $0x0, (%rax)
leaq 0x2b828b(%rip), %rax    # 0x36c50c
movl $0x1, (%rax)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb4307
leaq 0x2e6988(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, %ecx
leaq 0x2b867e(%rip), %rax    # 0x36c924
movl %ecx, (%rax)
leaq 0x2b8675(%rip), %rax    # 0x36c924
movl (%rax), %ecx
leaq 0x2b8664(%rip), %rax    # 0x36c91c
movl %ecx, (%rax)
leaq 0x2b865b(%rip), %rax    # 0x36c91c
movl (%rax), %ecx
leaq 0x2b8656(%rip), %rax    # 0x36c920
movl %ecx, (%rax)
leaq 0x2b8649(%rip), %rax    # 0x36c91c
movl (%rax), %eax
movl %eax, %ecx
leaq 0x2b8652(%rip), %rax    # 0x36c930
movq %rcx, (%rax)
leaq 0x2b8220(%rip), %rax    # 0x36c508
cmpl $0x0, (%rax)
jne 0xb42fa
leaq 0x1c3730(%rip), %rax    # 0x277a24
movl $0xbd5, (%rax)          # imm = 0xBD5
leaq 0x2b8207(%rip), %rax    # 0x36c508
movl $0x37, (%rax)
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)