// File: /workspace/github_cpp_makefile_star2_O2/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 0x28b64e(%rip), %rax    # 0x2f7514
movl (%rax), %edi
leaq 0x28b641(%rip), %rax    # 0x2f7510
movl (%rax), %esi
leaq 0x28b634(%rip), %r13    # 0x2f750c
movl (%r13), %edx
callq 0xc2f07
movsd %xmm0, -0x30(%rbp)
leaq 0x28b61b(%rip), %rbx    # 0x2f7508
movl (%rbx), %edi
leaq 0x28b60e(%rip), %r14    # 0x2f7504
movl (%r14), %esi
leaq 0x28b600(%rip), %r15    # 0x2f7500
movl (%r15), %edx
xorpd %xmm0, %xmm0
callq 0xc2faf
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0x2eede2(%rip), %xmm0   # 0x35ad00
movsd %xmm0, -0x40(%rbp)
pushq $0x2
popq %rdx
xorpd %xmm0, %xmm0
xorl %edi, %edi
xorl %esi, %esi
callq 0xc2faf
movsd -0x30(%rbp), %xmm4
addsd -0x40(%rbp), %xmm0
movapd %xmm4, %xmm2
leaq 0x19697c(%rip), %rax    # 0x2028c4
cmpb $0x0, (%rax)
subsd %xmm0, %xmm2
setne %al
leaq 0x1bc437(%rip), %r12    # 0x228390
movq (%r12), %rdi
testq %rdi, %rdi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x6bfaf
movsd 0x2eed8e(%rip), %xmm1   # 0x35ad00
movsd 0x8708e(%rip), %xmm0    # 0xf3008
movapd %xmm2, %xmm3
mulsd %xmm0, %xmm3
mulsd %xmm0, %xmm3
mulsd 0x870b2(%rip), %xmm3    # 0xf3040
leaq 0xa0161(%rip), %rsi     # 0x10c0f6
movapd %xmm4, %xmm0
movb $0x4, %al
movapd %xmm2, -0x40(%rbp)
callq 0x9560
movapd -0x40(%rbp), %xmm2
movsd -0x30(%rbp), %xmm4
movsd 0x2eed49(%rip), %xmm0   # 0x35ad00
ucomisd %xmm4, %xmm0
ja 0x6c0f3
andpd 0x871c7(%rip), %xmm2    # 0xf3190
movsd 0x9c2ff(%rip), %xmm0    # 0x1082d0
ucomisd %xmm2, %xmm0
jb 0x6c0f3
pushq $0x1
popq %rdx
xorpd %xmm0, %xmm0
xorl %edi, %edi
xorl %esi, %esi
callq 0xc2faf
movsd -0x30(%rbp), %xmm1
subsd %xmm0, %xmm1
xorl %edi, %edi
movapd %xmm1, %xmm0
callq 0xbfac2
leaq 0x28b69e(%rip), %rax    # 0x2f76a4
movl (%rax), %edi
leaq 0x28b505(%rip), %rax    # 0x2f7514
movl %edi, (%rax)
leaq 0x28b684(%rip), %rax    # 0x2f769c
movl (%rax), %esi
leaq 0x28b4ef(%rip), %rax    # 0x2f7510
movl %esi, (%rax)
leaq 0x28b676(%rip), %rax    # 0x2f76a0
movl (%rax), %edx
movl %edx, (%r13)
leaq 0x28b4e1(%rip), %rax    # 0x2f7518
andq $0x0, (%rax)
leaq 0x28b666(%rip), %rax    # 0x2f76a8
movl (%rax), %eax
movl %eax, 0x2e9d96(%rip)    # 0x355de0
movl %eax, (%rbx)
leaq 0x28b659(%rip), %rax    # 0x2f76ac
movl (%rax), %eax
movl %eax, 0x2e9d89(%rip)    # 0x355de4
movl %eax, (%r14)
leaq 0x28b64b(%rip), %r13    # 0x2f76b0
movl (%r13), %eax
movl %eax, 0x2e9d79(%rip)    # 0x355de8
movl %eax, (%r15)
callq 0xc2f07
movsd %xmm0, -0x30(%rbp)
movl (%rbx), %edi
movl (%r14), %esi
movl (%r15), %edx
xorpd %xmm0, %xmm0
callq 0xc2faf
movapd %xmm0, %xmm4
addsd -0x30(%rbp), %xmm4
leaq 0x196827(%rip), %rax    # 0x2028c4
cmpb $0x0, (%rax)
setne %al
movq (%r12), %rdi
testq %rdi, %rdi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x6c0e6
leaq 0x28b5ed(%rip), %rax    # 0x2f76a8
movl (%rax), %edx
leaq 0x28b5e8(%rip), %rax    # 0x2f76ac
movl (%rax), %ecx
movl (%r13), %r8d
leaq 0xa004d(%rip), %rsi     # 0x10c11e
movapd %xmm4, %xmm0
movb $0x1, %al
movsd %xmm4, -0x30(%rbp)
callq 0x9560
movsd -0x30(%rbp), %xmm4
leaq 0x1a14ff(%rip), %rax    # 0x20d5ec
movl $0x3, (%rax)
movsd %xmm4, 0x2eec05(%rip)   # 0x35ad00
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq