// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathgps.cpp
// Function: get_gpsd_message()
void get_gpsd_message()
{
u08 c;
static int paren_level = 0;

   // This routine buffers up an incoming GPSD JSON message.  When the end of the
   // message is seen, the message is parsed and decoded with decode_gpsd_msg()

   if(SERIAL_DATA_AVAILABLE(RCVR_PORT) == 0) {
      check_com_timer(RCVR_PORT);
      return;
   }
   else {
      reset_com_timer(RCVR_PORT);
   }

   c = get_com_char();
   if(com[RCVR_PORT].rcv_error) {      // parity/framing/overrun errors
      com[RCVR_PORT].rcv_error = 0;
//!!!!!qqqq    goto rst_msg;
   }

   if(tsip_sync == 0) {    // syncing to start of message, search for a '{'
      tsip_rptr = 0;
      tsip_wptr = 0;
      tsip_buf[tsip_wptr] = 0;
      if(c == '{') {
         get_sync_time();
         ++tsip_sync;
         tsip_buf[tsip_wptr++] = (u08) c;
         tsip_buf[tsip_wptr] = 0;
         paren_level = 1;
      }
      return;
   }
   else if(tsip_sync == 1) { // '"' has been seen
      if(c == '"') ++tsip_sync; 
      else goto rst_msg;
      tsip_buf[tsip_wptr++] = (u08) c;
      tsip_buf[tsip_wptr] = 0;
   }
   else if(tsip_sync == 2) { // 'c' has been seen
      if(c == 'c') ++tsip_sync; 
      else goto rst_msg;
      tsip_buf[tsip_wptr++] = (u08) c;
      tsip_buf[tsip_wptr] = 0;
   }
   else if(tsip_sync == 3) { // 'l' has been seen
      if(c == 'l') ++tsip_sync; 
      else goto rst_msg;
      tsip_buf[tsip_wptr++] = (u08) c;
      tsip_buf[tsip_wptr] = 0;
   }
   else if(tsip_sync == 4) { // 'a' has been seen
      if(c == 'a') ++tsip_sync; 
      else goto rst_msg;
      tsip_buf[tsip_wptr++] = (u08) c;
      tsip_buf[tsip_wptr] = 0;
   }
   else if(tsip_sync == 5) { // 's' has been seen
      if(c == 's') ++tsip_sync; 
      else goto rst_msg;
      tsip_buf[tsip_wptr++] = (u08) c;
      tsip_buf[tsip_wptr] = 0;
   }
   else if(tsip_sync == 6) { // 's' has been seen - time to start building the full message
      if(c == 's') ++tsip_sync; 
      else goto rst_msg;
      tsip_buf[tsip_wptr++] = (u08) c;
      tsip_buf[tsip_wptr] = 0;
   }
   else if(tsip_sync == 7) {  // adding chars to the message
      if(tsip_wptr > MAX_GPSD_LEN) goto rst_msg; // message too long (max JSON is 1536 chars)
      if((c == 0x0D) || (c == 0x0A)) {
         decode_gpsd_msg();
         packet_end = 1;
         tsip_wptr = 0;     // prepare for next message
         tsip_sync = 0;
      }
      else {
         tsip_buf[tsip_wptr++] = (u08) c;
         tsip_buf[tsip_wptr] = 0;
      }
   }
   else {     // should never happen, prepare for next message
      rst_msg:
      tsip_wptr = 0;
      tsip_sync = 0;
      paren_level = 0;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq $0xa
popq %rdi
callq 0xb771
pushq $0xa
popq %rdi
testl %eax, %eax
je 0x98707
callq 0x1d93f
callq 0x51891
movl %eax, %ebx
leaq 0x25fc61(%rip), %rax    # 0x2f82e0
cmpb $0x0, 0x17a12(%rax)
je 0x9868f
movb $0x0, 0x17a12(%rax)
leaq 0x289bc0(%rip), %r14    # 0x322256
movzwl (%r14), %eax
cmpq $0x6, %rax
ja 0x9874a
leaq 0x713bd(%rip), %rcx     # 0x109a68
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x289b99(%rip), %rax    # 0x322254
andw $0x0, (%rax)
leaq 0x289b8c(%rip), %r12    # 0x322252
andw $0x0, (%r12)
leaq 0x288b7d(%rip), %r15    # 0x321250
movb $0x0, (%r15)
cmpl $0x7b, %ebx
jne 0x987e2
callq 0x51a2f
incw (%r14)
movzwl (%r12), %eax
leal 0x1(%rax), %ecx
movw %cx, (%r12)
movb %bl, (%r15,%rax)
movzwl %cx, %eax
movb $0x0, (%r15,%rax)
jmp 0x987e2
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x1d61b
cmpl $0x61, %ebx
jne 0x987d2
movw $0x5, (%r14)
jmp 0x987af
cmpl $0x63, %ebx
jne 0x987d2
movw $0x3, (%r14)
jmp 0x987af
cmpl $0x6c, %ebx
jne 0x987d2
movw $0x4, (%r14)
jmp 0x987af
cmpw $0x7, %ax
setne %cl
leaq 0x289afa(%rip), %r15    # 0x322252
movzwl (%r15), %eax
cmpw $0x601, %ax             # imm = 0x601
setae %dl
orb %cl, %dl
jne 0x987d2
cmpb $0xd, %bl
je 0x98774
movzbl %bl, %ecx
cmpl $0xa, %ecx
jne 0x987eb
callq 0x983fc
andw $0x0, (%r15)
movl $0x1, 0x2bd50c(%rip)    # 0x355c94
jmp 0x987dd
cmpl $0x22, %ebx
jne 0x987d2
movw $0x2, (%r14)
jmp 0x987af
cmpl $0x73, %ebx
jne 0x987d2
movw $0x6, (%r14)
jmp 0x987af
cmpl $0x73, %ebx
jne 0x987d2
movw $0x7, (%r14)
leaq 0x289a9c(%rip), %rax    # 0x322252
movzwl (%rax), %ecx
leal 0x1(%rcx), %edx
movw %dx, (%rax)
leaq 0x288a8a(%rip), %rax    # 0x321250
movb %bl, (%rax,%rcx)
movzwl %dx, %ecx
movb $0x0, (%rax,%rcx)
jmp 0x987e2
leaq 0x289a79(%rip), %rax    # 0x322252
andw $0x0, (%rax)
andw $0x0, (%r14)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movzwl %ax, %eax
leaq 0x1(%rax), %rcx
movw %cx, (%r15)
leaq 0x288a53(%rip), %rcx    # 0x321250
movb %bl, (%rcx,%rax)
movb $0x0, 0x1(%rcx,%rax)
jmp 0x987e2