// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0x29722a(%rip), %rax    # 0x30d514
movl (%rax), %edi
leaq 0x29721d(%rip), %rax    # 0x30d510
movl (%rax), %esi
leaq 0x297210(%rip), %r13    # 0x30d50c
movl (%r13), %edx
callq 0xd4110
movsd %xmm0, -0x30(%rbp)
leaq 0x2971f7(%rip), %rbx    # 0x30d508
movl (%rbx), %edi
leaq 0x2971ea(%rip), %r14    # 0x30d504
movl (%r14), %esi
leaq 0x2971dc(%rip), %r15    # 0x30d500
movl (%r15), %edx
xorpd %xmm0, %xmm0
callq 0xd41e0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0x2fa9be(%rip), %xmm0   # 0x370d00
movsd %xmm0, -0x40(%rbp)
xorpd %xmm0, %xmm0
xorl %edi, %edi
xorl %esi, %esi
movl $0x2, %edx
callq 0xd41e0
movsd -0x30(%rbp), %xmm4
addsd -0x40(%rbp), %xmm0
movapd %xmm4, %xmm2
leaq 0x1a2556(%rip), %rax    # 0x2188c4
cmpb $0x0, (%rax)
subsd %xmm0, %xmm2
setne %al
leaq 0x1c8011(%rip), %r12    # 0x23e390
movq (%r12), %rdi
testq %rdi, %rdi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x763d5
movsd 0x2fa968(%rip), %xmm1   # 0x370d00
movsd 0x92c68(%rip), %xmm0    # 0x109008
movapd %xmm2, %xmm3
mulsd %xmm0, %xmm3
mulsd %xmm0, %xmm3
mulsd 0x92c8c(%rip), %xmm3    # 0x109040
leaq 0xabd13(%rip), %rsi     # 0x1220ce
movapd %xmm4, %xmm0
movb $0x4, %al
movapd %xmm2, -0x40(%rbp)
callq 0x9560
movapd -0x40(%rbp), %xmm2
movsd -0x30(%rbp), %xmm4
movsd 0x2fa923(%rip), %xmm0   # 0x370d00
ucomisd %xmm4, %xmm0
ja 0x7651e
andpd 0x92d91(%rip), %xmm2    # 0x109180
movsd 0xa7db9(%rip), %xmm0    # 0x11e1b0
ucomisd %xmm2, %xmm0
jb 0x7651e
xorpd %xmm0, %xmm0
xorl %edi, %edi
xorl %esi, %esi
movl $0x1, %edx
callq 0xd41e0
movsd -0x30(%rbp), %xmm1
subsd %xmm0, %xmm1
xorl %edi, %edi
movapd %xmm1, %xmm0
callq 0xd0c46
leaq 0x297276(%rip), %rax    # 0x30d6a4
movl (%rax), %edi
leaq 0x2970dd(%rip), %rax    # 0x30d514
movl %edi, (%rax)
leaq 0x29725c(%rip), %rax    # 0x30d69c
movl (%rax), %esi
leaq 0x2970c7(%rip), %rax    # 0x30d510
movl %esi, (%rax)
leaq 0x29724e(%rip), %rax    # 0x30d6a0
movl (%rax), %edx
movl %edx, (%r13)
leaq 0x2970b9(%rip), %rax    # 0x30d518
movq $0x0, (%rax)
leaq 0x29723b(%rip), %rax    # 0x30d6a8
movl (%rax), %eax
movl %eax, 0x2f596b(%rip)    # 0x36bde0
movl %eax, (%rbx)
leaq 0x29722e(%rip), %rax    # 0x30d6ac
movl (%rax), %eax
movl %eax, 0x2f595e(%rip)    # 0x36bde4
movl %eax, (%r14)
leaq 0x297220(%rip), %r13    # 0x30d6b0
movl (%r13), %eax
movl %eax, 0x2f594e(%rip)    # 0x36bde8
movl %eax, (%r15)
callq 0xd4110
movsd %xmm0, -0x30(%rbp)
movl (%rbx), %edi
movl (%r14), %esi
movl (%r15), %edx
xorpd %xmm0, %xmm0
callq 0xd41e0
movapd %xmm0, %xmm4
addsd -0x30(%rbp), %xmm4
leaq 0x1a23fc(%rip), %rax    # 0x2188c4
cmpb $0x0, (%rax)
setne %al
movq (%r12), %rdi
testq %rdi, %rdi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x76511
leaq 0x2971c2(%rip), %rax    # 0x30d6a8
movl (%rax), %edx
leaq 0x2971bd(%rip), %rax    # 0x30d6ac
movl (%rax), %ecx
movl (%r13), %r8d
leaq 0xabbfa(%rip), %rsi     # 0x1220f6
movapd %xmm4, %xmm0
movb $0x1, %al
movsd %xmm4, -0x30(%rbp)
callq 0x9560
movsd -0x30(%rbp), %xmm4
leaq 0x1ad0d4(%rip), %rax    # 0x2235ec
movl $0x3, (%rax)
movsd %xmm4, 0x2fa7da(%rip)   # 0x370d00
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq