// File: jkingan[P]ladyheather/heathgps.cpp
// Function: parse_crw()
void parse_crw()
{
int i;
int tls, fls;
int pps;
int yy;
int mm;
int dd;

   // leapsecond info

   if(get_msg_field()) {  // eat the TPS1
   }

   i = 0;
   fls = tls = 0;

   get_fixed_field(4);
   yy = atoi(msg_field);
   get_fixed_field(2);
   mm = atoi(msg_field);
   get_fixed_field(2);
   dd = atoi(msg_field);
   if(get_msg_field()) {  // hour/min/sec
   }

   if(get_msg_field()) {  // time validity
      i = atoi(msg_field);
      time_flags &= (~(TFLAGS_USER_TIME | TFLAGS_GNSS_MASK | TFLAGS_UTC | TFLAGS_INVALID | TFLAGS_RTC));
      if     (i == 0) time_flags |= TFLAGS_RTC;  // time from rtc chip
      else if(i == 1) ;  // GPS time
      else if(i == 2) time_flags |= TFLAGS_UTC;
//    else if(i == 3) time_flags |= TFLAGS_GLONASS;
      else            time_flags |= TFLAGS_INVALID;
   }

   get_fixed_field(4);
   yy = atoi(msg_field);
   get_fixed_field(2);
   mm = atoi(msg_field);
   get_fixed_field(2);
   dd = atoi(msg_field);
   if(get_msg_field()) {  // hour/min/sec - should be 000000
   }

   if(get_msg_field()) {  // utc offset
      tls = atoi(msg_field);
      if(tls) {
         if(!user_set_utc_ofs) utc_offset = tls;
         check_utc_ofs(33);
      }
   }

   if(get_msg_field()) {  // future utc offset
      fls = atoi(msg_field);
   }

   minor_alarms &= (~MINOR_LEAP_PEND);
   if(yy && mm && dd && fls && tls && (fls != tls)) {
      minor_alarms |= MINOR_LEAP_PEND;
      jd_leap = jdate(yy,mm,dd) + jtime(0,0,0,-1.0);  // -1 since says 2017/1/1
      have_jd_leap = 87;
      calc_jd_leap(87);
   }
   have_leap_info = 87;

   if(get_msg_field()) {  // pps source
      pps = atoi(msg_field);
      esip_time_source = pps;
      if(0) {
         time_flags &= (~(TFLAGS_USER_TIME | TFLAGS_GNSS_MASK | TFLAGS_UTC | TFLAGS_INVALID | TFLAGS_RTC));
         if     (pps == 0) time_flags |= TFLAGS_USER_TIME;  // time from rtc chip
         else if(pps == 1) ;  // GPS time
         else if(pps == 2) time_flags |= TFLAGS_UTC;
         else if(pps == 3) time_flags |= TFLAGS_GLONASS;
         else              time_flags |= TFLAGS_INVALID;
      }
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb4ab4
jmp 0xb4ab4
movl $0x0, -0x4(%rbp)
movl $0x0, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movl $0x4, %edi
callq 0xb4d60
leaq 0x2e6146(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x14(%rbp)
movl $0x2, %edi
callq 0xb4d60
leaq 0x2e612d(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x18(%rbp)
movl $0x2, %edi
callq 0xb4d60
leaq 0x2e6114(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x1c(%rbp)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb4b20
jmp 0xb4b20
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb4bb5
leaq 0x2e60eb(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x4(%rbp)
leaq 0x2b7b40(%rip), %rax    # 0x36c684
movl (%rax), %ecx
andl $0xfffffeca, %ecx       # imm = 0xFFFFFECA
leaq 0x2b7b31(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
cmpl $0x0, -0x4(%rbp)
jne 0xb4b75
leaq 0x2b7b22(%rip), %rax    # 0x36c684
movl (%rax), %ecx
orl $0x100, %ecx            # imm = 0x100
leaq 0x2b7b13(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
jmp 0xb4bb3
cmpl $0x1, -0x4(%rbp)
jne 0xb4b7d
jmp 0xb4bb1
cmpl $0x2, -0x4(%rbp)
jne 0xb4b9a
leaq 0x2b7afa(%rip), %rax    # 0x36c684
movl (%rax), %ecx
orl $0x1, %ecx
leaq 0x2b7aee(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
jmp 0xb4baf
leaq 0x2b7ae3(%rip), %rax    # 0x36c684
movl (%rax), %ecx
orl $0x4, %ecx
leaq 0x2b7ad7(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
jmp 0xb4bb1
jmp 0xb4bb3
jmp 0xb4bb5
movl $0x4, %edi
callq 0xb4d60
leaq 0x2e605a(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x14(%rbp)
movl $0x2, %edi
callq 0xb4d60
leaq 0x2e6041(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x18(%rbp)
movl $0x2, %edi
callq 0xb4d60
leaq 0x2e6028(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x1c(%rbp)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb4c0c
jmp 0xb4c0c
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb4c4f
leaq 0x2e6003(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x8(%rbp)
cmpl $0x0, -0x8(%rbp)
je 0xb4c4d
leaq 0x2b7ce2(%rip), %rax    # 0x36c914
cmpl $0x0, (%rax)
jne 0xb4c43
movl -0x8(%rbp), %ecx
leaq 0x2b7cc7(%rip), %rax    # 0x36c908
movl %ecx, (%rax)
movl $0x21, %edi
callq 0x7a270
jmp 0xb4c4f
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb4c68
leaq 0x2e5fc0(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0xc(%rbp)
leaq 0x2b7749(%rip), %rax    # 0x36c3b8
movl (%rax), %ecx
andl $0xffffff7f, %ecx       # imm = 0xFFFFFF7F
leaq 0x2b773a(%rip), %rax    # 0x36c3b8
movl %ecx, (%rax)
cmpl $0x0, -0x14(%rbp)
je 0xb4d1e
cmpl $0x0, -0x18(%rbp)
je 0xb4d1e
cmpl $0x0, -0x1c(%rbp)
je 0xb4d1e
cmpl $0x0, -0xc(%rbp)
je 0xb4d1e
cmpl $0x0, -0x8(%rbp)
je 0xb4d1e
movl -0xc(%rbp), %eax
cmpl -0x8(%rbp), %eax
je 0xb4d1e
leaq 0x2b76ff(%rip), %rax    # 0x36c3b8
movl (%rax), %ecx
orl $0x80, %ecx
leaq 0x2b76f0(%rip), %rax    # 0x36c3b8
movl %ecx, (%rax)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
movl -0x1c(%rbp), %edx
callq 0x122140
movsd %xmm0, -0x28(%rbp)
xorl %edx, %edx
movsd 0xba431(%rip), %xmm0    # 0x16f118
movl %edx, %edi
movl %edx, %esi
callq 0x122210
movaps %xmm0, %xmm1
movsd -0x28(%rbp), %xmm0
addsd %xmm1, %xmm0
leaq 0x2b7a3d(%rip), %rax    # 0x36c740
movsd %xmm0, (%rax)
leaq 0x2b7a3a(%rip), %rax    # 0x36c748
movl $0x57, (%rax)
movl $0x57, %edi
callq 0x80070
leaq 0x2b7753(%rip), %rax    # 0x36c478
movl $0x57, (%rax)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xb4d50
leaq 0x2e5ee4(%rip), %rdi    # 0x39ac20
callq 0x95c0
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %ecx
leaq 0x2b8216(%rip), %rax    # 0x36cf64
movl %ecx, (%rax)
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)