// File: /workspace/github_cpp_makefile_star2_O1/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 0xb9c3
movl $0xa, %edi
testl %eax, %eax
je 0xa7d55
callq 0x1ea2c
callq 0x584d5
movl %eax, %ebx
leaq 0x266613(%rip), %rax    # 0x30e2e0
cmpb $0x0, 0x17a12(%rax)
je 0xa7cdd
movb $0x0, 0x17a12(%rax)
leaq 0x290572(%rip), %r14    # 0x338256
movzwl (%r14), %eax
cmpq $0x6, %rax
ja 0xa7d8e
leaq 0x77d53(%rip), %rcx     # 0x11fa4c
movslq (%rcx,%rax,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
leaq 0x29054b(%rip), %rax    # 0x338254
xorl %ecx, %ecx
movw %cx, (%rax)
leaq 0x29053d(%rip), %r12    # 0x338252
movw %cx, (%r12)
leaq 0x28f52f(%rip), %r15    # 0x337250
movb $0x0, (%r15)
cmpl $0x7b, %ebx
jne 0xa7e23
callq 0x58682
incw (%r14)
movzwl (%r12), %eax
leal 0x1(%rax), %ecx
movw %cx, (%r12)
movb %bl, (%r15,%rax)
movzwl %cx, %eax
movb $0x0, (%r15,%rax)
jmp 0xa7e23
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x1e6a0
cmpl $0x61, %ebx
jne 0xa7e13
movw $0x5, (%r14)
jmp 0xa7df0
cmpl $0x63, %ebx
jne 0xa7e13
movw $0x3, (%r14)
jmp 0xa7df0
cmpl $0x6c, %ebx
je 0xa7ddd
jmp 0xa7e13
cmpw $0x7, %ax
setne %cl
leaq 0x2904b6(%rip), %r15    # 0x338252
movzwl (%r15), %eax
cmpl $0x601, %eax            # imm = 0x601
setae %dl
orb %cl, %dl
jne 0xa7e13
cmpl $0xd, %ebx
je 0xa7db6
cmpl $0xa, %ebx
jne 0xa7e2c
callq 0xa7a60
movl $0x1, 0x2c3ecf(%rip)    # 0x36bc94
xorl %eax, %eax
movw %ax, (%r15)
movw %ax, (%r14)
jmp 0xa7e23
cmpl $0x22, %ebx
je 0xa7ddd
jmp 0xa7e13
cmpl $0x73, %ebx
jne 0xa7e13
incl %eax
movw %ax, (%r14)
jmp 0xa7df0
cmpl $0x73, %ebx
jne 0xa7e13
movw $0x7, (%r14)
leaq 0x29045b(%rip), %rax    # 0x338252
movzwl (%rax), %ecx
leal 0x1(%rcx), %edx
movw %dx, (%rax)
leaq 0x28f449(%rip), %rax    # 0x337250
movb %bl, (%rax,%rcx)
movzwl %dx, %ecx
movb $0x0, (%rax,%rcx)
jmp 0xa7e23
leaq 0x290438(%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 0x28f415(%rip), %rcx    # 0x337250
movb %bl, (%rcx,%rax)
movb $0x0, 0x1(%rcx,%rax)
jmp 0xa7e23