// File: /workspace/github_cpp_makefile_star2_O3/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
movl $0xa, %edi
callq 0xb9ad
movl $0xa, %edi
testl %eax, %eax
je 0xa7f83
callq 0x1ea0b
callq 0x584bd
movl %eax, %ebx
leaq 0x2663e5(%rip), %rax    # 0x30e2e0
cmpb $0x0, 0x17a12(%rax)
je 0xa7f0b
movb $0x0, 0x17a12(%rax)
leaq 0x290344(%rip), %r14    # 0x338256
movzwl (%r14), %eax
cmpq $0x6, %rax
ja 0xa7fc6
leaq 0x77bfd(%rip), %rcx     # 0x11fb24
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x29031d(%rip), %rax    # 0x338254
xorl %ecx, %ecx
movw %cx, (%rax)
leaq 0x29030f(%rip), %r12    # 0x338252
movw %cx, (%r12)
leaq 0x28f301(%rip), %r15    # 0x337250
movb $0x0, (%r15)
cmpl $0x7b, %ebx
jne 0xa8064
callq 0x58672
incw (%r14)
movzwl (%r12), %eax
leal 0x1(%rax), %ecx
movw %cx, (%r12)
movb %bl, (%r15,%rax)
movzwl %cx, %eax
movb $0x0, (%r15,%rax)
jmp 0xa8064
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x1e66a
cmpl $0x61, %ebx
jne 0xa8054
movw $0x5, (%r14)
jmp 0xa8031
cmpl $0x63, %ebx
jne 0xa8054
movw $0x3, (%r14)
jmp 0xa8031
cmpl $0x6c, %ebx
jne 0xa8054
movw $0x4, (%r14)
jmp 0xa8031
cmpw $0x7, %ax
setne %cl
leaq 0x29027e(%rip), %r15    # 0x338252
movzwl (%r15), %eax
cmpl $0x601, %eax            # imm = 0x601
setae %dl
orb %cl, %dl
jne 0xa8054
cmpb $0xd, %bl
je 0xa7ff1
movzbl %bl, %ecx
cmpl $0xa, %ecx
jne 0xa806d
callq 0xa7c8e
movl $0x1, 0x2c3c94(%rip)    # 0x36bc94
xorl %eax, %eax
movw %ax, (%r15)
movw %ax, (%r14)
jmp 0xa8064
cmpl $0x22, %ebx
jne 0xa8054
movw $0x2, (%r14)
jmp 0xa8031
cmpl $0x73, %ebx
jne 0xa8054
movw $0x6, (%r14)
jmp 0xa8031
cmpl $0x73, %ebx
jne 0xa8054
movw $0x7, (%r14)
leaq 0x29021a(%rip), %rax    # 0x338252
movzwl (%rax), %ecx
leal 0x1(%rcx), %edx
movw %dx, (%rax)
leaq 0x28f208(%rip), %rax    # 0x337250
movb %bl, (%rax,%rcx)
movzwl %dx, %ecx
movb $0x0, (%rax,%rcx)
jmp 0xa8064
leaq 0x2901f7(%rip), %rax    # 0x338252
xorl %ecx, %ecx
movw %cx, (%rax)
movw %cx, (%r14)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1(%rax), %rcx
movw %cx, (%r15)
leaq 0x28f1d4(%rip), %rcx    # 0x337250
movb %bl, (%rcx,%rax)
movb $0x0, 0x1(%rcx,%rax)
jmp 0xa8064