// File: /workspace/github_cpp_makefile_star2_O1/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 0x7f47d
leaq 0x2975d9(%rip), %rbx    # 0x33b830
movb $0x0, (%rbx)
xorl %r14d, %r14d
leaq 0x293fee(%rip), %r15    # 0x338252
leaq 0x19ad05(%rip), %r12    # 0x23ef70
movzwl (%r15), %eax
cmpq %rax, %r14
jae 0xa429b
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0xa4285
orb $0x8, (%r12)
movb %al, (%r14,%rbx)
movb $0x0, 0x1(%r14,%rbx)
incq %r14
cmpq $0x1f6, %r14            # imm = 0x1F6
jne 0xa426b
leaq 0x29758e(%rip), %rdi    # 0x33b830
callq 0x9899
leaq 0x19a0e2(%rip), %r12    # 0x23e390
movq (%r12), %rdi
testq %rdi, %rdi
je 0xa42cc
leaq 0x7be0d(%rip), %rsi     # 0x1200cb
leaq 0x29756b(%rip), %rdx    # 0x33b830
xorl %eax, %eax
callq 0x9560
leaq 0x297971(%rip), %rax    # 0x33bc44
movl $0x0, (%rax)
callq 0x811da
testl %eax, %eax
je 0xa4474
leaq 0x297753(%rip), %rdi    # 0x33ba40
callq 0x95e0
movl %eax, %ebx
callq 0x811da
testl %eax, %eax
je 0xa4474
leaq 0x297738(%rip), %rdi    # 0x33ba40
callq 0x95e0
movl %eax, %r14d
callq 0x811da
testl %eax, %eax
je 0xa4474
leaq 0x29771c(%rip), %rdi    # 0x33ba40
callq 0x95e0
movl %eax, %r15d
callq 0x811da
testl %eax, %eax
je 0xa4474
leaq 0x269164(%rip), %rax    # 0x30d4a4
andb $-0x5, (%rax)
leaq 0x26914d(%rip), %rax    # 0x30d497
movb $0x0, (%rax)
leaq 0x2976ec(%rip), %r13    # 0x33ba40
movq %r13, %rdi
callq 0x95e0
movq (%r12), %rdi
testq %rdi, %rdi
movl %r15d, %r12d
movl %eax, %r15d
je 0xa4388
movq %r13, (%rsp)
leaq 0x8166a(%rip), %rsi     # 0x1259e0
movl %ebx, %edx
movl %r14d, %ecx
movl %r12d, %r8d
movl %r15d, %r9d
xorl %eax, %eax
callq 0x9560
leaq 0x2976b1(%rip), %rdi    # 0x33ba40
movl $0x58, %esi
callq 0x9100
testq %rax, %rax
je 0xa43aa
leaq 0x2690ff(%rip), %rax    # 0x30d4a4
orb $0x4, (%rax)
jmp 0xa43ca
leaq 0x29768f(%rip), %rdi    # 0x33ba40
movl $0x46, %esi
callq 0x9100
testq %rax, %rax
je 0xa43ca
leaq 0x2690d0(%rip), %rax    # 0x30d497
movb $0x2, (%rax)
callq 0xa495
leaq 0x2692f2(%rip), %rax    # 0x30d6c8
movl (%rax), %edi
movl $0x1, %esi
movl $0x1, %edx
callq 0xd4110
cvtsi2sd %ebx, %xmm1
addsd %xmm1, %xmm0
addsd 0x64d01(%rip), %xmm0    # 0x1090f8
movsd %xmm0, -0x30(%rbp)
xorpd %xmm0, %xmm0
movl %r14d, %edi
movl %r12d, %esi
movl %r15d, %edx
callq 0xd41e0
addsd -0x30(%rbp), %xmm0
callq 0x5c837
leaq 0x26909e(%rip), %rax    # 0x30d4bd
cmpb $0x0, (%rax)
je 0xa442f
xorpd %xmm0, %xmm0
callq 0x5c907
jmp 0xa4459
leaq 0x2692f2(%rip), %rax    # 0x30d728
xorps %xmm0, %xmm0
cvtsi2sdl (%rax), %xmm0
callq 0x5c907
leaq 0x26905b(%rip), %rax    # 0x30d4a4
andb $-0x2, (%rax)
leaq 0x268f79(%rip), %rax    # 0x30d3cc
movl $0x1, (%rax)
cmpl $0x3e7, %r15d           # imm = 0x3E7
je 0xa4467
callq 0x7327e
leaq 0x19ab32(%rip), %rax    # 0x23efa0
movl $0x1, (%rax)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq