// File: jkingan[P]ladyheather/heathgps.cpp
// Function: fix_starloc_time()
void fix_starloc_time()
{
double this_jd;
double delta_jd;
static double last_jd = 0.0;

   // attempt to fix skipped time stamps from the STARLOC receivers by backing
   // them up one second.  This works more times than it doesn't...

   this_jd = jdate(pri_year,pri_month,pri_day) + jtime(pri_hours,pri_minutes,pri_seconds, 0.0);
   delta_jd = this_jd - (last_jd + jtime(0,0,2, 0.0));
   if(show_debug_info && debug_file) fprintf(debug_file, "thisjd:%f  lastjd:%f  delta:%.12f (%f)\n", this_jd,last_jd, delta_jd, delta_jd*60.0*60.0*24.0);
   if(this_jd < last_jd) ; 
   else if((fabs(delta_jd) <= 0.0000001)) {  // time stamp skip detected
      this_jd -= jtime(0,0,1, 0.0); // ... back this time up a second

      gregorian(0, this_jd);
      pri_year = g_year;
      pri_month = g_month;
      pri_day = g_day;
      pri_frac = 0.0;
      pri_hours = pt_hh = g_hours;
      pri_minutes = pt_min = g_minutes;
      pri_seconds = pt_sec = g_seconds;
      this_jd = jdate(pri_year,pri_month,pri_day) + jtime(pri_hours,pri_minutes,pri_seconds, 0.0);
      if(show_debug_info && debug_file) fprintf(debug_file, "!! time stamp skip fixed! %02d:%02d:%02d -> %.6f\n", g_hours,g_minutes,g_seconds, this_jd);
      starloc_skip_delay = 3; // inhibit next 3 time stamp skip checks
   }

   last_jd = this_jd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
leaq 0x2ca455(%rip), %rax    # 0x36c6f4
movl (%rax), %edi
leaq 0x2ca448(%rip), %rax    # 0x36c6f0
movl (%rax), %esi
leaq 0x2ca43b(%rip), %rax    # 0x36c6ec
movl (%rax), %edx
callq 0x122140
movsd %xmm0, -0x28(%rbp)
leaq 0x2ca424(%rip), %rax    # 0x36c6e8
movl (%rax), %edi
leaq 0x2ca417(%rip), %rax    # 0x36c6e4
movl (%rax), %esi
leaq 0x2ca40a(%rip), %rax    # 0x36c6e0
movl (%rax), %edx
xorps %xmm0, %xmm0
callq 0x122210
movaps %xmm0, %xmm1
movsd -0x28(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
movsd %xmm0, -0x18(%rbp)
movsd 0x32dbd5(%rip), %xmm0   # 0x3cfed8
movsd %xmm0, -0x20(%rbp)
xorl %esi, %esi
movl $0x2, %edx
xorps %xmm0, %xmm0
movl %esi, %edi
callq 0x122210
movsd -0x20(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0x18(%rbp), %xmm0
addsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x10(%rbp)
leaq 0x1d576a(%rip), %rax    # 0x277aa4
cmpb $0x0, (%rax)
je 0xa239b
leaq 0x1fb22a(%rip), %rax    # 0x29d570
cmpq $0x0, (%rax)
je 0xa239b
leaq 0x1fb21d(%rip), %rax    # 0x29d570
movq (%rax), %rdi
movsd -0x8(%rbp), %xmm0
movsd 0x32db75(%rip), %xmm1   # 0x3cfed8
movsd -0x10(%rbp), %xmm2
movsd 0xccca8(%rip), %xmm3    # 0x16f018
mulsd -0x10(%rbp), %xmm3
movsd 0xccc9b(%rip), %xmm4    # 0x16f018
mulsd %xmm4, %xmm3
movsd 0xcccaf(%rip), %xmm4    # 0x16f038
mulsd %xmm4, %xmm3
leaq 0xe30aa(%rip), %rsi     # 0x18543e
movb $0x4, %al
callq 0x9550
movsd -0x8(%rbp), %xmm1
movsd 0x32db30(%rip), %xmm0   # 0x3cfed8
ucomisd %xmm1, %xmm0
jbe 0xa23b3
jmp 0xa2549
movsd -0x10(%rbp), %xmm1
movaps 0xcced1(%rip), %xmm0    # 0x16f290
pand %xmm0, %xmm1
movsd 0xccddd(%rip), %xmm0    # 0x16f1a8
ucomisd %xmm1, %xmm0
jb 0xa2547
xorl %esi, %esi
movl $0x1, %edx
xorps %xmm0, %xmm0
movl %esi, %edi
callq 0x122210
movaps %xmm0, %xmm1
movsd -0x8(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
xorl %edi, %edi
callq 0x11dd00
leaq 0x2ca47a(%rip), %rax    # 0x36c884
movl (%rax), %ecx
leaq 0x2ca2e1(%rip), %rax    # 0x36c6f4
movl %ecx, (%rax)
leaq 0x2ca460(%rip), %rax    # 0x36c87c
movl (%rax), %ecx
leaq 0x2ca2cb(%rip), %rax    # 0x36c6f0
movl %ecx, (%rax)
leaq 0x2ca452(%rip), %rax    # 0x36c880
movl (%rax), %ecx
leaq 0x2ca2b5(%rip), %rax    # 0x36c6ec
movl %ecx, (%rax)
leaq 0x2ca2b8(%rip), %rax    # 0x36c6f8
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
leaq 0x2ca43a(%rip), %rax    # 0x36c888
movl (%rax), %ecx
movl %ecx, 0x328b6a(%rip)    # 0x3cafc0
leaq 0x2ca28b(%rip), %rax    # 0x36c6e8
movl %ecx, (%rax)
leaq 0x2ca426(%rip), %rax    # 0x36c88c
movl (%rax), %ecx
movl %ecx, 0x328b56(%rip)    # 0x3cafc4
leaq 0x2ca26f(%rip), %rax    # 0x36c6e4
movl %ecx, (%rax)
leaq 0x2ca412(%rip), %rax    # 0x36c890
movl (%rax), %ecx
movl %ecx, 0x328b42(%rip)    # 0x3cafc8
leaq 0x2ca253(%rip), %rax    # 0x36c6e0
movl %ecx, (%rax)
leaq 0x2ca25e(%rip), %rax    # 0x36c6f4
movl (%rax), %edi
leaq 0x2ca251(%rip), %rax    # 0x36c6f0
movl (%rax), %esi
leaq 0x2ca244(%rip), %rax    # 0x36c6ec
movl (%rax), %edx
callq 0x122140
movsd %xmm0, -0x30(%rbp)
leaq 0x2ca22d(%rip), %rax    # 0x36c6e8
movl (%rax), %edi
leaq 0x2ca220(%rip), %rax    # 0x36c6e4
movl (%rax), %esi
leaq 0x2ca213(%rip), %rax    # 0x36c6e0
movl (%rax), %edx
xorps %xmm0, %xmm0
callq 0x122210
movaps %xmm0, %xmm1
movsd -0x30(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
leaq 0x1d55b5(%rip), %rax    # 0x277aa4
cmpb $0x0, (%rax)
je 0xa253a
leaq 0x1fb075(%rip), %rax    # 0x29d570
cmpq $0x0, (%rax)
je 0xa253a
leaq 0x1fb068(%rip), %rax    # 0x29d570
movq (%rax), %rdi
leaq 0x2ca376(%rip), %rax    # 0x36c888
movl (%rax), %edx
leaq 0x2ca371(%rip), %rax    # 0x36c88c
movl (%rax), %ecx
leaq 0x2ca36c(%rip), %rax    # 0x36c890
movl (%rax), %r8d
movsd -0x8(%rbp), %xmm0
leaq 0xe2f33(%rip), %rsi     # 0x185466
movb $0x1, %al
callq 0x9550
leaq 0x1e028b(%rip), %rax    # 0x2827cc
movl $0x3, (%rax)
jmp 0xa2549
movsd -0x8(%rbp), %xmm0
movsd %xmm0, 0x32d982(%rip)   # 0x3cfed8
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)