// File: jkingan[P]ladyheather/heathgps.cpp
// Function: sv6_time_code(float)
void sv6_time_code(float time_of_fix)
{
double jd;

   if(time_of_fix < 0.0F) {
      time_flags |= TFLAGS_INVALID;
   }
   else if(ACU_GG || ACU_360 || ACUTIME) {
      time_flags &= (~TFLAGS_INVALID);
      if(ACU_GG) return;
      if(ACU_360) return;
      if(ACUTIME) return;
      request_gps_time();
      request_osc_offset();
   }
   else {
      time_flags &= (~TFLAGS_INVALID);

      jd = GPS_EPOCH + ((double) sv6_week * 7.0) + jtime(0,0,0,(double)time_of_fix);
//    jd = GPS_EPOCH + ((double) sv6_week * 7.0) + jtime(0,0,1,(double)sv6_tow);
      
      set_gregorian_time(jd);

if(0 && log_file) {
   fprintf(log_file, "!@ tof:%f  %02d:%02d:%02d %f  ", time_of_fix, g_hours,g_minutes,g_seconds, g_frac);
   if(log_flush_mode) fflush(log_file);
}

      if(timing_mode == TMODE_GPS) {    // convert utc time to gps time
//mmmmm         utc_to_gps();
      }
      else {
//mmmmm         adjust_rcvr_time(0.0);  // incorporarte possibly negative fractional second into time variables
      }

      update_gps_screen(666);

      request_gps_time();
      request_osc_offset();
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movss %xmm0, -0x4(%rbp)
xorps %xmm0, %xmm0
ucomiss -0x4(%rbp), %xmm0
jbe 0x9d5e0
leaq 0x2cf0b7(%rip), %rax    # 0x36c684
movl (%rax), %ecx
orl $0x4, %ecx
leaq 0x2cf0ab(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
jmp 0x9d787
leaq 0x1da4c9(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x9d605
leaq 0x1dcbc0(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x9d605
leaq 0x1da4d8(%rip), %rax    # 0x277ad8
cmpl $0x47, (%rax)
je 0x9d657
leaq 0x1da4a4(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x9d636
leaq 0x1dcb9b(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x9d636
leaq 0x1da4b3(%rip), %rax    # 0x277ad8
cmpl $0x33, (%rax)
je 0x9d657
leaq 0x1da4a7(%rip), %rax    # 0x277ad8
cmpl $0x47, (%rax)
je 0x9d657
leaq 0x1da473(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x9d6f9
leaq 0x1dcb66(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x9d6f9
leaq 0x2cf026(%rip), %rax    # 0x36c684
movl (%rax), %ecx
andl $-0x5, %ecx
leaq 0x2cf01a(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
leaq 0x1da43d(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x9d696
leaq 0x1dcb34(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x9d696
leaq 0x1da44c(%rip), %rax    # 0x277ad8
cmpl $0x47, (%rax)
jne 0x9d696
jmp 0x9d787
leaq 0x1da413(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x9d6cc
leaq 0x1dcb0a(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x9d6cc
leaq 0x1da422(%rip), %rax    # 0x277ad8
cmpl $0x33, (%rax)
je 0x9d6c7
leaq 0x1da416(%rip), %rax    # 0x277ad8
cmpl $0x47, (%rax)
jne 0x9d6cc
jmp 0x9d787
leaq 0x1da3dd(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x9d6ea
leaq 0x1dcad4(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x9d6ea
jmp 0x9d787
callq 0x8bf60
callq 0x85eb0
jmp 0x9d785
leaq 0x2cef84(%rip), %rax    # 0x36c684
movb (%rax), %cl
andb $-0x5, %cl
movb %cl, (%rax)
movzwl 0x32d8da(%rip), %eax    # 0x3cafe8
cvtsi2sd %eax, %xmm0
movsd 0xd3f6e(%rip), %xmm1    # 0x171688
mulsd %xmm1, %xmm0
movsd 0xd3ef2(%rip), %xmm1    # 0x171618
addsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
movss -0x4(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
xorl %edx, %edx
movl %edx, %edi
movl %edx, %esi
callq 0x122210
movaps %xmm0, %xmm1
movsd -0x18(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0x7fb00
leaq 0x2cef38(%rip), %rax    # 0x36c69d
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x9d76f
jmp 0x9d771
jmp 0x9d771
movl $0x29a, %edi            # imm = 0x29A
callq 0x9d790
callq 0x8bf60
callq 0x85eb0
jmp 0x9d787
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)