// File: jkingan[P]ladyheather/heathgps.cpp
// Function: parse_star_gps_time()
void parse_star_gps_time()   
{
int ls;
int dd,mm,yy;
int hrs,mins,secs;
char c[2];

   // gps time / leapsecond info
   log_packet_id("Star gps time");

   if(get_msg_field()) {  // GPS week
      gps_week = atoi(msg_field);
      faked_tow = 0;
      if(gps_week == 0) return;   // bogus 0 values will be in the message
      if(have_week == 0) need_redraw = 4354;
      have_week = 299;
   }

   if(get_msg_field()) {  // GPS TOW
      if(0) {   // !!!! we fake the GPS week and tow since this message only comes in every 10+ seconds
         pri_tow = atoi(msg_field);
         tow = pri_tow; 
         this_tow = tow;
         survey_tow = tow;

         if(have_tow == 0) need_redraw = 4029;
         have_tow = 59;
      }
   }

   dd = mm = yy = 0;
   hrs = mins = secs = 0;
   if(get_msg_field()) { // leap dd/mm/yy
      sscanf(msg_field, "%d%c%d%c%d", &dd,&c[0],&mm,&c[0],&yy);
   }
   if(get_msg_field()) { // leap hh/mm/ss
      sscanf(msg_field, "%d%c%d%c%d", &hrs,&c[0],&mins,&c[0],&secs);
   }

   if(get_msg_field()) { // leap pending
      if(gps_week) {  // if week is 0, the message was invalid
         ls = atoi(msg_field);
         if(ls) {
            minor_alarms |= MINOR_LEAP_PEND;

            if(time_flags & TFLAGS_NO_UTC_OFS) {
               jd_leap = 0.0;
               have_jd_leap = 0;
               have_leap_days = 0;
            }
            else if(have_time && (yy || dd || mm || hrs || mins || secs)) {
               if(yy && (yy < 100)) yy += 2000;
               jd_leap = jdate(yy,mm,dd) + jtime(hrs,mins,secs,0.0) - jtime(0,0,1,0.0);
               calc_jd_leap(5);
            }
         }
         else {
            minor_alarms &= (~MINOR_LEAP_PEND);
            jd_leap = 0.0;
            have_jd_leap = 0;
            have_leap_days = 0;
         }
         have_leap_info = 32;
      }
   }

   if(get_msg_field()) {  // leap second count
      ls = atoi(msg_field);
      if(!user_set_utc_ofs) utc_offset = ls;
      check_utc_ofs(39);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
leaq 0xc189d(%rip), %rdi     # 0x18746c
callq 0x7add0
callq 0xb0bd0
cmpl $0x0, %eax
je 0xc5c3e
leaq 0x2d503b(%rip), %rdi    # 0x39ac20
callq 0x95c0
movw %ax, %cx
leaq 0x2a6d24(%rip), %rax    # 0x36c918
movw %cx, (%rax)
leaq 0x2a6d2a(%rip), %rax    # 0x36c928
movl $0x0, (%rax)
leaq 0x2a6d0d(%rip), %rax    # 0x36c918
movzwl (%rax), %eax
cmpl $0x0, %eax
jne 0xc5c18
jmp 0xc5eb0
leaq 0x2a68ed(%rip), %rax    # 0x36c50c
cmpl $0x0, (%rax)
jne 0xc5c31
leaq 0x1b1df9(%rip), %rax    # 0x277a24
movl $0x1102, (%rax)         # imm = 0x1102
leaq 0x2a68d4(%rip), %rax    # 0x36c50c
movl $0x12b, (%rax)          # imm = 0x12B
callq 0xb0bd0
cmpl $0x0, %eax
je 0xc5c4a
jmp 0xc5c4a
movl $0x0, -0x10(%rbp)
movl $0x0, -0xc(%rbp)
movl $0x0, -0x8(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x14(%rbp)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xc5cab
leaq -0x1e(%rbp), %rcx
leaq -0x1e(%rbp), %r9
leaq 0x2d4f93(%rip), %rdi    # 0x39ac20
leaq 0xbce53(%rip), %rsi     # 0x182ae7
leaq -0x8(%rbp), %rdx
leaq -0xc(%rbp), %r8
leaq -0x10(%rbp), %rax
movq %rax, (%rsp)
movb $0x0, %al
callq 0x9370
callq 0xb0bd0
cmpl $0x0, %eax
je 0xc5ce2
leaq -0x1e(%rbp), %rcx
leaq -0x1e(%rbp), %r9
leaq 0x2d4f5c(%rip), %rdi    # 0x39ac20
leaq 0xbce1c(%rip), %rsi     # 0x182ae7
leaq -0x14(%rbp), %rdx
leaq -0x18(%rbp), %r8
leaq -0x1c(%rbp), %rax
movq %rax, (%rsp)
movb $0x0, %al
callq 0x9370
callq 0xb0bd0
cmpl $0x0, %eax
je 0xc5e75
leaq 0x2a6c21(%rip), %rax    # 0x36c918
cmpw $0x0, (%rax)
je 0xc5e73
leaq 0x2d4f18(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x4(%rbp)
cmpl $0x0, -0x4(%rbp)
je 0xc5e26
leaq 0x2a6697(%rip), %rax    # 0x36c3b8
movl (%rax), %ecx
orl $0x80, %ecx
leaq 0x2a6688(%rip), %rax    # 0x36c3b8
movl %ecx, (%rax)
leaq 0x2a694b(%rip), %rax    # 0x36c684
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0xc5d70
leaq 0x2a69f6(%rip), %rax    # 0x36c740
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
leaq 0x2a69f0(%rip), %rax    # 0x36c748
movl $0x0, (%rax)
leaq 0x2a666b(%rip), %rax    # 0x36c3d0
movl $0x0, (%rax)
jmp 0xc5e24
leaq 0x1d8345(%rip), %rax    # 0x29e0bc
cmpb $0x0, (%rax)
je 0xc5e22
cmpl $0x0, -0x10(%rbp)
jne 0xc5da4
cmpl $0x0, -0x8(%rbp)
jne 0xc5da4
cmpl $0x0, -0xc(%rbp)
jne 0xc5da4
cmpl $0x0, -0x14(%rbp)
jne 0xc5da4
cmpl $0x0, -0x18(%rbp)
jne 0xc5da4
cmpl $0x0, -0x1c(%rbp)
je 0xc5e22
cmpl $0x0, -0x10(%rbp)
je 0xc5dbb
cmpl $0x64, -0x10(%rbp)
jge 0xc5dbb
movl -0x10(%rbp), %eax
addl $0x7d0, %eax            # imm = 0x7D0
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %edi
movl -0xc(%rbp), %esi
movl -0x8(%rbp), %edx
callq 0x122140
movsd %xmm0, -0x30(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
movl -0x1c(%rbp), %edx
xorps %xmm0, %xmm0
callq 0x122210
movaps %xmm0, %xmm1
movsd -0x30(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
xorl %esi, %esi
movl $0x1, %edx
xorps %xmm0, %xmm0
movl %esi, %edi
callq 0x122210
movaps %xmm0, %xmm1
movsd -0x28(%rbp), %xmm0
subsd %xmm1, %xmm0
leaq 0x2a692c(%rip), %rax    # 0x36c740
movsd %xmm0, (%rax)
movl $0x5, %edi
callq 0x80070
jmp 0xc5e24
jmp 0xc5e66
leaq 0x2a658b(%rip), %rax    # 0x36c3b8
movl (%rax), %ecx
andl $0xffffff7f, %ecx       # imm = 0xFFFFFF7F
leaq 0x2a657c(%rip), %rax    # 0x36c3b8
movl %ecx, (%rax)
leaq 0x2a68fb(%rip), %rax    # 0x36c740
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
leaq 0x2a68f5(%rip), %rax    # 0x36c748
movl $0x0, (%rax)
leaq 0x2a6570(%rip), %rax    # 0x36c3d0
movl $0x0, (%rax)
leaq 0x2a660b(%rip), %rax    # 0x36c478
movl $0x20, (%rax)
jmp 0xc5e75
callq 0xb0bd0
cmpl $0x0, %eax
je 0xc5eb0
leaq 0x2d4d9a(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x4(%rbp)
leaq 0x2a6a7f(%rip), %rax    # 0x36c914
cmpl $0x0, (%rax)
jne 0xc5ea6
movl -0x4(%rbp), %ecx
leaq 0x2a6a64(%rip), %rax    # 0x36c908
movl %ecx, (%rax)
movl $0x27, %edi
callq 0x7a270
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)