// File: jkingan[P]ladyheather/heathgps.cpp
// Function: parse_ubx_utc()
void parse_ubx_utc()
{
u32 gps_msec;
double accu;

   // get utc time
   log_packet_id("UBX_UTC");

   gps_msec = tsip_dword();
   pri_tow = tow = this_tow = (gps_msec / 1000);
   if(have_tow == 0) need_redraw = 2014;
   have_tow = 2;
   survey_tow = this_tow;
   accu = (double) tsip_dword();  // time error estimate in nanoseconds

   pri_frac = (double) (int) tsip_dword();  // !!!!!! can be negative
   pri_frac /= 1.0E9;
   raw_frac = pri_frac;

   pri_year = year = tsip_word();
   pri_month = month = tsip_byte();
   pri_day = day = tsip_byte();
   pri_hours = hours = tsip_byte();
   pri_minutes = minutes = tsip_byte();
   pri_seconds = seconds = tsip_byte();
   tsip_byte();  // validity flags

//if(log_file) fprintf(log_file, "  %02d:%02d:%02d.%f  %04d/%02d/%02d  tow:%d\n", 
//pri_hours,pri_minutes,pri_seconds, pri_frac, pri_year,pri_month,pri_day, tow); // zorky

   if(accu == (double) (u32) 0xFFFFFFFF) accu = 0.0;  // filter bogus power-up value
   pps_offset = (accu);
   have_pps_offset = 3;
   have_rcvr_pps = 3;
//adadad   if(jitter_adev == 0) do_pps_adev(pps_offset);

   osc_offset = pri_frac*1.0E9;
   have_osc_offset = 3;
   have_rcvr_osc = 3;
//adadad   if(jitter_adev == 0) do_osc_adev(osc_offset);

   time_flags |= TFLAGS_UTC;  // UTC based time
   have_timing_mode = 1;
   have_rcvr_tmode = 1;

   if(timing_mode == TMODE_GPS) {     // convert utc time to gps time
      utc_to_gps();
   }
   else {
      adjust_rcvr_time(0.0);  // incorporarte possibly negative fractional second into time variables
   }

   update_gps_screen(1000);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
leaq 0xbde63(%rip), %rdi     # 0x187982
callq 0x7add0
callq 0x7a680
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %edx, %edx
divl %ecx
movl %eax, %ecx
leaq 0x2a2ddf(%rip), %rax    # 0x36c920
movl %ecx, (%rax)
leaq 0x2a2dd2(%rip), %rax    # 0x36c91c
movl %ecx, (%rax)
leaq 0x2a2dd1(%rip), %rax    # 0x36c924
movl %ecx, (%rax)
leaq 0x2a29ac(%rip), %rax    # 0x36c508
cmpl $0x0, (%rax)
jne 0xc9b6e
leaq 0x1adebc(%rip), %rax    # 0x277a24
movl $0x7de, (%rax)          # imm = 0x7DE
leaq 0x2a2993(%rip), %rax    # 0x36c508
movl $0x2, (%rax)
leaq 0x2a2d9e(%rip), %rax    # 0x36c920
movl (%rax), %eax
movl %eax, %ecx
leaq 0x2a2da3(%rip), %rax    # 0x36c930
movq %rcx, (%rax)
callq 0x7a680
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x10(%rbp)
callq 0x7a680
cvtsi2sd %eax, %xmm0
leaq 0x2a2b47(%rip), %rax    # 0x36c6f8
movsd %xmm0, (%rax)
leaq 0x2a2b3c(%rip), %rax    # 0x36c6f8
movsd (%rax), %xmm0
movsd 0xa5460(%rip), %xmm1    # 0x16f028
divsd %xmm1, %xmm0
leaq 0x2a2b25(%rip), %rax    # 0x36c6f8
movsd %xmm0, (%rax)
leaq 0x2a2b1a(%rip), %rax    # 0x36c6f8
movsd (%rax), %xmm0
leaq 0x2a2ad7(%rip), %rax    # 0x36c6c0
movsd %xmm0, (%rax)
callq 0x7a560
movzwl %ax, %ecx
leaq 0x2a2ac0(%rip), %rax    # 0x36c6bc
movl %ecx, (%rax)
leaq 0x2a2aef(%rip), %rax    # 0x36c6f4
movl %ecx, (%rax)
callq 0x7a510
movzbl %al, %ecx
leaq 0x2a2aa2(%rip), %rax    # 0x36c6b8
movl %ecx, (%rax)
leaq 0x2a2ad1(%rip), %rax    # 0x36c6f0
movl %ecx, (%rax)
callq 0x7a510
movzbl %al, %ecx
leaq 0x2a2a84(%rip), %rax    # 0x36c6b4
movl %ecx, (%rax)
leaq 0x2a2ab3(%rip), %rax    # 0x36c6ec
movl %ecx, (%rax)
callq 0x7a510
movzbl %al, %ecx
leaq 0x2a2a66(%rip), %rax    # 0x36c6b0
movl %ecx, (%rax)
leaq 0x2a2a95(%rip), %rax    # 0x36c6e8
movl %ecx, (%rax)
callq 0x7a510
movzbl %al, %ecx
leaq 0x2a2a48(%rip), %rax    # 0x36c6ac
movl %ecx, (%rax)
leaq 0x2a2a77(%rip), %rax    # 0x36c6e4
movl %ecx, (%rax)
callq 0x7a510
movzbl %al, %ecx
leaq 0x2a2a2a(%rip), %rax    # 0x36c6a8
movl %ecx, (%rax)
leaq 0x2a2a59(%rip), %rax    # 0x36c6e0
movl %ecx, (%rax)
callq 0x7a510
movsd -0x10(%rbp), %xmm0
movsd 0xb93b5(%rip), %xmm1    # 0x183050
ucomisd %xmm1, %xmm0
jne 0xc9cab
jp 0xc9cab
xorps %xmm0, %xmm0
movsd %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
leaq 0x2a1ce1(%rip), %rax    # 0x36b998
movsd %xmm0, (%rax)
leaq 0x2a2756(%rip), %rax    # 0x36c418
movl $0x3, (%rax)
leaq 0x2a2755(%rip), %rax    # 0x36c424
movl $0x3, (%rax)
movsd 0xa534b(%rip), %xmm0    # 0x16f028
leaq 0x2a2a14(%rip), %rax    # 0x36c6f8
mulsd (%rax), %xmm0
leaq 0x2a1cb1(%rip), %rax    # 0x36b9a0
movsd %xmm0, (%rax)
leaq 0x2a271a(%rip), %rax    # 0x36c414
movl $0x3, (%rax)
leaq 0x2a2721(%rip), %rax    # 0x36c428
movl $0x3, (%rax)
leaq 0x2a2970(%rip), %rax    # 0x36c684
movl (%rax), %ecx
orl $0x1, %ecx
leaq 0x2a2964(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
leaq 0x2a2883(%rip), %rax    # 0x36c5ac
movl $0x1, (%rax)
leaq 0x2a287a(%rip), %rax    # 0x36c5b0
movl $0x1, (%rax)
leaq 0x2a295a(%rip), %rax    # 0x36c69d
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0xc9d52
callq 0x7fc70
jmp 0xc9d5a
xorps %xmm0, %xmm0
callq 0x7fbf0
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x9d790
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)