// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathmsc.cpp
// Function: get_obs_time(double, double)
void get_obs_time(double jd_obs, double obs_tow)
{
double o_frac;
double delta;
static double max_delta = 0.0;

   // Convert jd_obs to gregorian time values.  Since the gregorian() function
   // can have round-off errors the the range of 0.0001 seconds we do some
   // tom-foolery to attempt to use obs_tow value to get the seconds exactly
   // what the receiver sent (jd_obs is used to get the rest of the date/time)

   gregorian(1, jd_obs);

   o_frac = obs_tow - (double) (int) obs_tow;
   delta = fabs(g_frac - o_frac);
   if((delta > max_delta) && (delta < 0.5)) max_delta = delta;
   if(delta > (1.0-JD_OBS_ROUND)) delta = (1.0-delta);

if(show_debug_info) sprintf(debug_text4, "g_frac:%.7f  o_frac:%.7f  delta:%.7f", g_frac,o_frac, delta);
   if(delta < (JD_OBS_ROUND*1.0)) { // gregorian fraction is close to observation fraction
      // if the two fractions are on each side of the 1 second threshold we
      // cant substute the observation fraction for the gregorian fraction since
      // that could cause the seconds value to be wrong and cause a backwards
      // time step.
      if((o_frac < JD_OBS_ROUND) && (g_frac > (1.0-JD_OBS_ROUND))) {
         //  bump the year/month/day hours/minutes/seconds and use o_frac
         gregorian(1, jd_obs+jtime(0,0,0,0.1));  // bump time past any roundoff error
         g_frac = o_frac;
//if(rinex_file) write_rinex_line(rinex_file, "time bump!", "COMMENT");  //rnx
      }
      else if((g_frac < JD_OBS_ROUND) && (o_frac > (1.0-JD_OBS_ROUND))) {
         gregorian(1, jd_obs-jtime(0,0,0,0.1)); // do a negative time bump
         g_frac = o_frac;
//if(rinex_file) write_rinex_line(rinex_file, "negative time bump!", "COMMENT");  //rnx
      }
      else {  // it's safe to replace gregorian() value with obs_tow value
         g_frac = o_frac; 
      }
   }
if(show_debug_info) sprintf(debug_text3, "g_frac:%.7f  o_frac:%.7f  delta:%.7f  maxd:%.7f", g_frac,o_frac, delta,max_delta);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x30, %rsp
movaps %xmm1, -0x20(%rbp)
movl $0x1, %edi
movsd %xmm0, -0x28(%rbp)
callq 0xd12da
movapd -0x20(%rbp), %xmm1
cvttpd2dq %xmm1, %xmm0
cvtdq2pd %xmm0, %xmm0
subsd %xmm0, %xmm1
leaq 0x22f311(%rip), %rbx    # 0x30d6b8
movsd (%rbx), %xmm0
movapd %xmm0, %xmm3
subsd %xmm1, %xmm3
andpd 0x2add5(%rip), %xmm3    # 0x109190
ucomisd 0x29c625(%rip), %xmm3   # 0x37a9e8
jbe 0xde3db
movsd 0x2ac9b(%rip), %xmm2    # 0x109068
ucomisd %xmm3, %xmm2
jbe 0xde3db
movsd %xmm3, 0x29c60d(%rip)   # 0x37a9e8
movsd 0x2ac8d(%rip), %xmm4    # 0x109070
subsd %xmm3, %xmm4
movsd 0x4d419(%rip), %xmm2    # 0x12b808
cmpltsd %xmm3, %xmm2
andpd %xmm2, %xmm4
andnpd %xmm3, %xmm2
orpd %xmm4, %xmm2
leaq 0x13a4bd(%rip), %r14    # 0x2188c4
cmpb $0x0, (%r14)
movapd %xmm1, -0x20(%rbp)
movapd %xmm2, -0x40(%rbp)
je 0xde436
leaq 0x260972(%rip), %rdi    # 0x33ed90
leaq 0x55172(%rip), %rsi     # 0x133597
movb $0x3, %al
callq 0x9060
movapd -0x40(%rbp), %xmm2
movapd -0x20(%rbp), %xmm1
movsd 0x4d33a(%rip), %xmm0    # 0x12b778
ucomisd %xmm2, %xmm0
jbe 0xde497
ucomisd %xmm1, %xmm0
movsd (%rbx), %xmm3
jbe 0xde462
ucomisd 0x4d3b2(%rip), %xmm3    # 0x12b808
jbe 0xde462
movsd 0x4d3b0(%rip), %xmm0    # 0x12b810
jmp 0xde47a
ucomisd %xmm3, %xmm0
jbe 0xde493
ucomisd 0x4d398(%rip), %xmm1    # 0x12b808
jbe 0xde493
movsd 0x4d39e(%rip), %xmm0    # 0x12b818
addsd -0x28(%rbp), %xmm0
movl $0x1, %edi
callq 0xd12da
movapd -0x20(%rbp), %xmm1
movapd -0x40(%rbp), %xmm2
movsd %xmm1, (%rbx)
cmpb $0x0, (%r14)
je 0xde4c6
movsd (%rbx), %xmm0
movsd 0x29c53f(%rip), %xmm3   # 0x37a9e8
leaq 0x260790(%rip), %rdi    # 0x33ec40
leaq 0x55105(%rip), %rsi     # 0x1335bc
movb $0x4, %al
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x9060
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
retq