// File: /workspace/github_cpp_makefile_star2_O2/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)
pushq $0x1
popq %rdi
movsd %xmm0, -0x28(%rbp)
callq 0xbfac2
movapd -0x20(%rbp), %xmm1
cvttpd2dq %xmm1, %xmm0
cvtdq2pd %xmm0, %xmm0
subsd %xmm0, %xmm1
leaq 0x22bf65(%rip), %rbx    # 0x2f76b8
movsd (%rbx), %xmm0
movapd %xmm0, %xmm3
subsd %xmm1, %xmm3
andpd 0x27a29(%rip), %xmm3    # 0xf3190
ucomisd 0x299279(%rip), %xmm3   # 0x3649e8
jbe 0xcb787
movsd 0x278ef(%rip), %xmm2    # 0xf3068
ucomisd %xmm3, %xmm2
jbe 0xcb787
movsd %xmm3, 0x299261(%rip)   # 0x3649e8
movsd 0x278e1(%rip), %xmm4    # 0xf3070
subsd %xmm3, %xmm4
movsd 0x49fad(%rip), %xmm2    # 0x115748
cmpltsd %xmm3, %xmm2
andpd %xmm2, %xmm4
andnpd %xmm3, %xmm2
orpd %xmm4, %xmm2
leaq 0x137111(%rip), %r14    # 0x2028c4
cmpb $0x0, (%r14)
movapd %xmm1, -0x20(%rbp)
movapd %xmm2, -0x40(%rbp)
je 0xcb7e2
leaq 0x25d5c6(%rip), %rdi    # 0x328d90
leaq 0x51ce6(%rip), %rsi     # 0x11d4b7
movb $0x3, %al
callq 0x9060
movapd -0x40(%rbp), %xmm2
movapd -0x20(%rbp), %xmm1
movsd 0x49ed6(%rip), %xmm0    # 0x1156c0
ucomisd %xmm2, %xmm0
jbe 0xcb841
ucomisd %xmm1, %xmm0
movsd (%rbx), %xmm3
jbe 0xcb80e
ucomisd 0x49f46(%rip), %xmm3    # 0x115748
jbe 0xcb80e
movsd 0x49f44(%rip), %xmm0    # 0x115750
jmp 0xcb826
ucomisd %xmm3, %xmm0
jbe 0xcb83d
ucomisd 0x49f2c(%rip), %xmm1    # 0x115748
jbe 0xcb83d
movsd 0x49f32(%rip), %xmm0    # 0x115758
addsd -0x28(%rbp), %xmm0
pushq $0x1
popq %rdi
callq 0xbfac2
movapd -0x20(%rbp), %xmm1
movapd -0x40(%rbp), %xmm2
movsd %xmm1, (%rbx)
cmpb $0x0, (%r14)
je 0xcb870
movsd (%rbx), %xmm0
movsd 0x299195(%rip), %xmm3   # 0x3649e8
leaq 0x25d3e6(%rip), %rdi    # 0x328c40
leaq 0x51c7b(%rip), %rsi     # 0x11d4dc
movb $0x4, %al
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x9060
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
retq