// File: /workspace/github_cpp_makefile_star2_O3/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 0x2973b7(%rip), %rax    # 0x30d514
movl (%rax), %edi
leaq 0x2973aa(%rip), %rax    # 0x30d510
movl (%rax), %esi
leaq 0x29739d(%rip), %r13    # 0x30d50c
movl (%r13), %edx
callq 0xd485e
movsd %xmm0, -0x30(%rbp)
leaq 0x297384(%rip), %rbx    # 0x30d508
movl (%rbx), %edi
leaq 0x297377(%rip), %r14    # 0x30d504
movl (%r14), %esi
leaq 0x297369(%rip), %r15    # 0x30d500
movl (%r15), %edx
xorpd %xmm0, %xmm0
callq 0xd492e
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0x2fab4b(%rip), %xmm0   # 0x370d00
movsd %xmm0, -0x40(%rbp)
xorpd %xmm0, %xmm0
xorl %edi, %edi
xorl %esi, %esi
movl $0x2, %edx
callq 0xd492e
movsd -0x30(%rbp), %xmm4
addsd -0x40(%rbp), %xmm0
movapd %xmm4, %xmm2
leaq 0x1a26e3(%rip), %rax    # 0x2188c4
cmpb $0x0, (%rax)
subsd %xmm0, %xmm2
setne %al
leaq 0x1c819e(%rip), %r12    # 0x23e390
movq (%r12), %rdi
testq %rdi, %rdi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x76248
movsd 0x2faaf5(%rip), %xmm1   # 0x370d00
movsd 0x92df5(%rip), %xmm0    # 0x109008
movapd %xmm2, %xmm3
mulsd %xmm0, %xmm3
mulsd %xmm0, %xmm3
mulsd 0x92e19(%rip), %xmm3    # 0x109040
leaq 0xabf80(%rip), %rsi     # 0x1221ae
movapd %xmm4, %xmm0
movb $0x4, %al
movapd %xmm2, -0x40(%rbp)
callq 0x9560
movapd -0x40(%rbp), %xmm2
movsd -0x30(%rbp), %xmm4
movsd 0x2faab0(%rip), %xmm0   # 0x370d00
ucomisd %xmm4, %xmm0
ja 0x76391
andpd 0x92f2e(%rip), %xmm2    # 0x109190
movsd 0xa7fee(%rip), %xmm0    # 0x11e258
ucomisd %xmm2, %xmm0
jb 0x76391
xorpd %xmm0, %xmm0
xorl %edi, %edi
xorl %esi, %esi
movl $0x1, %edx
callq 0xd492e
movsd -0x30(%rbp), %xmm1
subsd %xmm0, %xmm1
xorl %edi, %edi
movapd %xmm1, %xmm0
callq 0xd12da
leaq 0x297403(%rip), %rax    # 0x30d6a4
movl (%rax), %edi
leaq 0x29726a(%rip), %rax    # 0x30d514
movl %edi, (%rax)
leaq 0x2973e9(%rip), %rax    # 0x30d69c
movl (%rax), %esi
leaq 0x297254(%rip), %rax    # 0x30d510
movl %esi, (%rax)
leaq 0x2973db(%rip), %rax    # 0x30d6a0
movl (%rax), %edx
movl %edx, (%r13)
leaq 0x297246(%rip), %rax    # 0x30d518
movq $0x0, (%rax)
leaq 0x2973c8(%rip), %rax    # 0x30d6a8
movl (%rax), %eax
movl %eax, 0x2f5af8(%rip)    # 0x36bde0
movl %eax, (%rbx)
leaq 0x2973bb(%rip), %rax    # 0x30d6ac
movl (%rax), %eax
movl %eax, 0x2f5aeb(%rip)    # 0x36bde4
movl %eax, (%r14)
leaq 0x2973ad(%rip), %r13    # 0x30d6b0
movl (%r13), %eax
movl %eax, 0x2f5adb(%rip)    # 0x36bde8
movl %eax, (%r15)
callq 0xd485e
movsd %xmm0, -0x30(%rbp)
movl (%rbx), %edi
movl (%r14), %esi
movl (%r15), %edx
xorpd %xmm0, %xmm0
callq 0xd492e
movapd %xmm0, %xmm4
addsd -0x30(%rbp), %xmm4
leaq 0x1a2589(%rip), %rax    # 0x2188c4
cmpb $0x0, (%rax)
setne %al
movq (%r12), %rdi
testq %rdi, %rdi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x76384
leaq 0x29734f(%rip), %rax    # 0x30d6a8
movl (%rax), %edx
leaq 0x29734a(%rip), %rax    # 0x30d6ac
movl (%rax), %ecx
movl (%r13), %r8d
leaq 0xabe67(%rip), %rsi     # 0x1221d6
movapd %xmm4, %xmm0
movb $0x1, %al
movsd %xmm4, -0x30(%rbp)
callq 0x9560
movsd -0x30(%rbp), %xmm4
leaq 0x1ad261(%rip), %rax    # 0x2235ec
movl $0x3, (%rax)
movsd %xmm4, 0x2fa967(%rip)   # 0x370d00
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq