// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: decode_tserve_msg()
void decode_tserve_msg()
{
int i;
char c;
int doy;
int hh,mm,ss;
int q;
double jd;
int last_tick = 999;

   start_msg_decode(1);

   nmea_msg[0] = 0;
   for(i=0; i<tsip_wptr; i++) {  // copy message from tsip buffer to nmea buffer
      c = tsip_byte();
      nmea_msg[i] = c;
      nmea_msg[i+1] = 0;
      if(i >= ((int)sizeof(nmea_msg)-12)) break;
   }
   strupr(nmea_msg);
if(debug_file) fprintf(debug_file, "{%s}\n", nmea_msg);

   doy = 0;
   hh = mm = ss = 0;
   q = 0;

   msg_col = 0;
   if(get_msg_field()) {
      doy = atoi(msg_field);
   }
   else return;

   if(get_msg_field()) {
      hh = atoi(msg_field);
   }
   else return;

   if(get_msg_field()) {
      mm = atoi(msg_field);
   }
   else return;

   if(get_msg_field()) {
      time_flags &= (~TFLAGS_INVALID);
      discipline_mode = DIS_MODE_NORMAL;

      ss = atoi(msg_field);
if(debug_file) fprintf(debug_file, "  %03d:%02d:%02d:%02d  %s\n", doy,hh,mm,ss, msg_field);

      if(strchr(msg_field, 'X')) {  // no time avail
         time_flags |= TFLAGS_INVALID;
      }
      else if(strchr(msg_field, 'F')) {  // flywheeling
         discipline_mode = DIS_MODE_AUTO_HOLD;
      }
      else {
      }
   }
   else return;

   get_clock_time();   // in UTC
   jd = jdate(clk_year, 1, 1) + (double) (doy) - 1.0;
   jd += jtime(hh,mm,ss, 0.0);

   set_gregorian_time(jd);  // convert julian date to gregorian

   if(timing_mode == TMODE_GPS) {     // convert utc time to gps time
      utc_to_gps();
   }
   else {
      adjust_rcvr_time(0.0);  // incorporarte possibly negative fractional second into time variables
   }
   
   if(last_tick != ss) {
      last_tick = ss;
      update_gps_screen(1555);
   }
   saw_rcvr_msg = 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
pushq $0x1
popq %rdi
callq 0x73dcb
leaq 0x290813(%rip), %rbx    # 0x325830
movb $0x0, (%rbx)
xorl %r14d, %r14d
leaq 0x28d228(%rip), %r15    # 0x322252
movzwl (%r15), %eax
cmpq %rax, %r14
jae 0x9504e
callq 0x51c47
movb %al, (%r14,%rbx)
movb $0x0, 0x1(%r14,%rbx)
incq %r14
cmpq $0x1f6, %r14            # imm = 0x1F6
jne 0x9502a
leaq 0x2907db(%rip), %rdi    # 0x325830
callq 0x988f
leaq 0x19332f(%rip), %r12    # 0x228390
movq (%r12), %rdi
testq %rdi, %rdi
je 0x9507f
leaq 0x75082(%rip), %rsi     # 0x10a0f3
leaq 0x2907b8(%rip), %rdx    # 0x325830
xorl %eax, %eax
callq 0x9560
leaq 0x290bbe(%rip), %rax    # 0x325c44
andl $0x0, (%rax)
callq 0x75767
testl %eax, %eax
je 0x951f6
leaq 0x2909a3(%rip), %rdi    # 0x325a40
callq 0x95e0
movl %eax, %ebx
callq 0x75767
testl %eax, %eax
je 0x951f6
leaq 0x290988(%rip), %rdi    # 0x325a40
callq 0x95e0
movl %eax, %r14d
callq 0x75767
testl %eax, %eax
je 0x951f6
leaq 0x29096c(%rip), %rdi    # 0x325a40
callq 0x95e0
movl %eax, %r15d
callq 0x75767
testl %eax, %eax
je 0x951f6
leaq 0x2623b4(%rip), %rax    # 0x2f74a4
andb $-0x5, (%rax)
leaq 0x26239d(%rip), %rax    # 0x2f7497
movb $0x0, (%rax)
leaq 0x29093c(%rip), %r13    # 0x325a40
movq %r13, %rdi
callq 0x95e0
movq (%r12), %rdi
testq %rdi, %rdi
movl %r15d, %r12d
movl %eax, %r15d
je 0x95138
movq %r13, (%rsp)
leaq 0x7a8e2(%rip), %rsi     # 0x10fa08
movl %ebx, %edx
movl %r14d, %ecx
movl %r12d, %r8d
movl %r15d, %r9d
xorl %eax, %eax
callq 0x9560
leaq 0x290901(%rip), %rdi    # 0x325a40
pushq $0x58
popq %rsi
callq 0x9100
testq %rax, %rax
je 0x95158
leaq 0x262351(%rip), %rax    # 0x2f74a4
orb $0x4, (%rax)
jmp 0x95176
leaq 0x2908e1(%rip), %rdi    # 0x325a40
pushq $0x46
popq %rsi
callq 0x9100
testq %rax, %rax
je 0x95176
leaq 0x262324(%rip), %rax    # 0x2f7497
movb $0x2, (%rax)
callq 0xa386
leaq 0x262546(%rip), %rax    # 0x2f76c8
movl (%rax), %edi
pushq $0x1
popq %rdx
movl %edx, %esi
callq 0xc2f07
cvtsi2sd %ebx, %xmm1
addsd %xmm1, %xmm0
addsd 0x5df5a(%rip), %xmm0    # 0xf30f8
movsd %xmm0, -0x30(%rbp)
xorpd %xmm0, %xmm0
movl %r14d, %edi
movl %r12d, %esi
movl %r15d, %edx
callq 0xc2faf
addsd -0x30(%rbp), %xmm0
callq 0x55392
leaq 0x2622f7(%rip), %rax    # 0x2f74bd
cmpb $0x0, (%rax)
je 0x951d6
xorpd %xmm0, %xmm0
callq 0x55462
jmp 0x951db
callq 0x554d3
cmpl $0x3e7, %r15d           # imm = 0x3E7
je 0x951e9
callq 0x694f6
leaq 0x193db0(%rip), %rax    # 0x228fa0
movl $0x1, (%rax)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq