// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r14
pushq %rbx
leaq 0x90e1e(%rip), %rdi     # 0x124696
callq 0x58dc2
callq 0x58964
movl %eax, %eax
imulq $0x10624dd3, %rax, %rax # imm = 0x10624DD3
shrq $0x26, %rax
leaq 0x279eaa(%rip), %rcx    # 0x30d740
movl %eax, (%rcx)
leaq 0x279e9d(%rip), %rcx    # 0x30d73c
movl %eax, (%rcx)
leaq 0x279e9c(%rip), %rcx    # 0x30d744
movl %eax, (%rcx)
leaq 0x279a77(%rip), %rcx    # 0x30d328
cmpl $0x0, (%rcx)
jne 0x938c3
leaq 0x184f87(%rip), %rdx    # 0x218844
movl $0x7de, (%rdx)          # imm = 0x7DE
movl $0x2, (%rcx)
movl %eax, %eax
leaq 0x279e7e(%rip), %rcx    # 0x30d750
movq %rax, (%rcx)
callq 0x58964
movl %eax, %ebx
callq 0x58964
cvtsi2sd %eax, %xmm0
divsd 0x7573b(%rip), %xmm0    # 0x109028
leaq 0x279c24(%rip), %r14    # 0x30d518
movsd %xmm0, (%r14)
leaq 0x279be0(%rip), %rax    # 0x30d4e0
movsd %xmm0, (%rax)
callq 0x588d2
movzwl %ax, %eax
leaq 0x279bc9(%rip), %rcx    # 0x30d4dc
movl %eax, (%rcx)
leaq 0x279bf8(%rip), %rcx    # 0x30d514
movl %eax, (%rcx)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x93934
leaq 0x1ab63f(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movzbl %al, %eax
leaq 0x279b9a(%rip), %rcx    # 0x30d4d8
movl %eax, (%rcx)
leaq 0x279bc9(%rip), %rcx    # 0x30d510
movl %eax, (%rcx)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9395f
leaq 0x1ab614(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movzbl %al, %eax
leaq 0x279b6b(%rip), %rcx    # 0x30d4d4
movl %eax, (%rcx)
leaq 0x279b9a(%rip), %rcx    # 0x30d50c
movl %eax, (%rcx)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x9398a
leaq 0x1ab5e9(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movzbl %al, %eax
leaq 0x279b3c(%rip), %rcx    # 0x30d4d0
movl %eax, (%rcx)
leaq 0x279b6b(%rip), %rcx    # 0x30d508
movl %eax, (%rcx)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x939b5
leaq 0x1ab5be(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movzbl %al, %eax
leaq 0x279b0d(%rip), %rcx    # 0x30d4cc
movl %eax, (%rcx)
leaq 0x279b3c(%rip), %rcx    # 0x30d504
movl %eax, (%rcx)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x939e0
leaq 0x1ab593(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
movzbl %al, %eax
leaq 0x279ade(%rip), %rcx    # 0x30d4c8
movl %eax, (%rcx)
leaq 0x279b0d(%rip), %rcx    # 0x30d500
movl %eax, (%rcx)
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x93a0b
leaq 0x1ab568(%rip), %rax    # 0x23ef70
orb $0x8, (%rax)
xorpd %xmm0, %xmm0
cmpl $-0x1, %ebx
je 0x93a1e
movl %ebx, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
leaq 0x278d93(%rip), %rax    # 0x30c7b8
movsd %xmm0, (%rax)
leaq 0x279808(%rip), %rax    # 0x30d238
movl $0x3, %ecx
movl %ecx, (%rax)
leaq 0x279806(%rip), %rax    # 0x30d244
movl %ecx, (%rax)
movsd (%r14), %xmm0
mulsd 0x755db(%rip), %xmm0    # 0x109028
leaq 0x278d6c(%rip), %rax    # 0x30c7c0
movsd %xmm0, (%rax)
leaq 0x2797d5(%rip), %rax    # 0x30d234
movl %ecx, (%rax)
leaq 0x2797e0(%rip), %rax    # 0x30d248
movl %ecx, (%rax)
leaq 0x279a33(%rip), %rbx    # 0x30d4a4
orb $0x1, (%rbx)
leaq 0x279951(%rip), %r14    # 0x30d3cc
movl $0x1, %eax
movl %eax, (%r14)
leaq 0x279946(%rip), %rcx    # 0x30d3d0
movl %eax, (%rcx)
leaq 0x279a2a(%rip), %rax    # 0x30d4bd
cmpb $0x0, (%rax)
je 0x93aa3
xorpd %xmm0, %xmm0
callq 0x5c7ed
jmp 0x93ac0
leaq 0x279c7e(%rip), %rax    # 0x30d728
xorps %xmm0, %xmm0
cvtsi2sdl (%rax), %xmm0
callq 0x5c7ed
andb $-0x2, (%rbx)
movl $0x1, (%r14)
popq %rbx
popq %r14
popq %rbp
jmp 0x730e8