// File: /workspace/github_cpp_makefile_star2_O3/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
movl $0x1, %edi
callq 0x7f2b8
leaq 0x2973c6(%rip), %rbx    # 0x33b830
movb $0x0, (%rbx)
xorl %r14d, %r14d
leaq 0x293ddb(%rip), %r15    # 0x338252
leaq 0x19aaf2(%rip), %r12    # 0x23ef70
movzwl (%r15), %eax
cmpq %rax, %r14
jae 0xa44ae
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0xa4498
orb $0x8, (%r12)
movb %al, (%r14,%rbx)
movb $0x0, 0x1(%r14,%rbx)
incq %r14
cmpq $0x1f6, %r14            # imm = 0x1F6
jne 0xa447e
leaq 0x29737b(%rip), %rdi    # 0x33b830
callq 0x9899
leaq 0x199ecf(%rip), %r12    # 0x23e390
movq (%r12), %rdi
testq %rdi, %rdi
je 0xa44df
leaq 0x7bcda(%rip), %rsi     # 0x1201ab
leaq 0x297358(%rip), %rdx    # 0x33b830
xorl %eax, %eax
callq 0x9560
leaq 0x29775e(%rip), %rax    # 0x33bc44
movl $0x0, (%rax)
callq 0x810b1
testl %eax, %eax
je 0xa4687
leaq 0x297540(%rip), %rdi    # 0x33ba40
callq 0x95e0
movl %eax, %ebx
callq 0x810b1
testl %eax, %eax
je 0xa4687
leaq 0x297525(%rip), %rdi    # 0x33ba40
callq 0x95e0
movl %eax, %r14d
callq 0x810b1
testl %eax, %eax
je 0xa4687
leaq 0x297509(%rip), %rdi    # 0x33ba40
callq 0x95e0
movl %eax, %r15d
callq 0x810b1
testl %eax, %eax
je 0xa4687
leaq 0x268f51(%rip), %rax    # 0x30d4a4
andb $-0x5, (%rax)
leaq 0x268f3a(%rip), %rax    # 0x30d497
movb $0x0, (%rax)
leaq 0x2974d9(%rip), %r13    # 0x33ba40
movq %r13, %rdi
callq 0x95e0
movq (%r12), %rdi
testq %rdi, %rdi
movl %r15d, %r12d
movl %eax, %r15d
je 0xa459b
movq %r13, (%rsp)
leaq 0x81537(%rip), %rsi     # 0x125ac0
movl %ebx, %edx
movl %r14d, %ecx
movl %r12d, %r8d
movl %r15d, %r9d
xorl %eax, %eax
callq 0x9560
leaq 0x29749e(%rip), %rdi    # 0x33ba40
movl $0x58, %esi
callq 0x9100
testq %rax, %rax
je 0xa45bd
leaq 0x268eec(%rip), %rax    # 0x30d4a4
orb $0x4, (%rax)
jmp 0xa45dd
leaq 0x29747c(%rip), %rdi    # 0x33ba40
movl $0x46, %esi
callq 0x9100
testq %rax, %rax
je 0xa45dd
leaq 0x268ebd(%rip), %rax    # 0x30d497
movb $0x2, (%rax)
callq 0xa477
leaq 0x2690df(%rip), %rax    # 0x30d6c8
movl (%rax), %edi
movl $0x1, %esi
movl $0x1, %edx
callq 0xd485e
cvtsi2sd %ebx, %xmm1
addsd %xmm1, %xmm0
addsd 0x64aee(%rip), %xmm0    # 0x1090f8
movsd %xmm0, -0x30(%rbp)
xorpd %xmm0, %xmm0
movl %r14d, %edi
movl %r12d, %esi
movl %r15d, %edx
callq 0xd492e
addsd -0x30(%rbp), %xmm0
callq 0x5c71d
leaq 0x268e8b(%rip), %rax    # 0x30d4bd
cmpb $0x0, (%rax)
je 0xa4642
xorpd %xmm0, %xmm0
callq 0x5c7ed
jmp 0xa466c
leaq 0x2690df(%rip), %rax    # 0x30d728
xorps %xmm0, %xmm0
cvtsi2sdl (%rax), %xmm0
callq 0x5c7ed
leaq 0x268e48(%rip), %rax    # 0x30d4a4
andb $-0x2, (%rax)
leaq 0x268d66(%rip), %rax    # 0x30d3cc
movl $0x1, (%rax)
cmpl $0x3e7, %r15d           # imm = 0x3E7
je 0xa467a
callq 0x730e8
leaq 0x19a91f(%rip), %rax    # 0x23efa0
movl $0x1, (%rax)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq