// File: /workspace/github_c_makefile_star2_O0/canboat[P]canboat/analyzer/../common/parse.c
// Function: parseRawFormatChetco
int parseRawFormatChetco(char *msg, RawMessage *m, bool showJson)
{
  unsigned int pgn, src, i;
  unsigned int tstamp;
  time_t       t;
  struct tm    tm;
  char        *p;

  if (*msg == 0 || *msg == '\n')
  {
    return 1;
  }

  if (sscanf(msg, "$PCDIN,%x,%x,%x,", &pgn, &tstamp, &src) < 3)
  {
    logError("Error reading Chetco message: %s", msg);
    if (!showJson)
      fprintf(stdout, "%s", msg);
    return 2;
  }

  t = (time_t) tstamp / 1000;
  localtime_r(&t, &tm);
  strftime(m->timestamp, sizeof(m->timestamp), "%Y-%m-%dT%H:%M:%S", &tm);
  sprintf(m->timestamp + strlen(m->timestamp), ",%3.3u", tstamp % 1000);

  p = msg + STRSIZE("$PCDIN,01FD07,089C77D!,03,"); // Fixed length where data bytes start;

  for (i = 0; *p != '*'; i++)
  {
    if (scanHex(&p, &m->data[i]))
    {
      logError("Error reading message, scanned %zu bytes from %s/%s, index %u", p - msg, msg, p, i);
      if (!showJson)
        fprintf(stdout, "%s", msg);
      return 2;
    }
  }

  return setParsedValues(m, 0, pgn, 255, src, i + 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movb %dl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x21d32
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
jne 0x21d3e
movl $0x1, -0x4(%rbp)
jmp 0x21ec7
movq -0x10(%rbp), %rdi
leaq 0x1424c(%rip), %rsi     # 0x35f95
leaq -0x20(%rbp), %rdx
leaq -0x2c(%rbp), %rcx
leaq -0x24(%rbp), %r8
movb $0x0, %al
callq 0xd220
cmpl $0x3, %eax
jge 0x21da1
movq -0x10(%rbp), %rsi
leaq 0x1423a(%rip), %rdi     # 0x35fa6
movb $0x0, %al
callq 0x1f720
testb $0x1, -0x19(%rbp)
jne 0x21d95
movq 0x1a258(%rip), %rax     # 0x3bfd8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x1427e(%rip), %rsi     # 0x3600c
movb $0x0, %al
callq 0xd1b0
movl $0x2, -0x4(%rbp)
jmp 0x21ec7
movl -0x2c(%rbp), %eax
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
movq %rax, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0xd090
movq -0x18(%rbp), %rdi
movl $0x3c, %esi
leaq 0x13e69(%rip), %rdx     # 0x35c38
leaq -0x70(%rbp), %rcx
callq 0xd260
movq -0x18(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x18(%rbp), %rdi
callq 0xd0d0
movq -0x80(%rbp), %rdi
addq %rax, %rdi
movl -0x2c(%rbp), %eax
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %edx, %edx
divl %ecx
leaq 0x141c4(%rip), %rsi     # 0x35fc7
movb $0x0, %al
callq 0xd2d0
movq -0x10(%rbp), %rax
addq $0x1a, %rax
movq %rax, -0x78(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x78(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2a, %eax
je 0x21ea5
movq -0x18(%rbp), %rsi
addq $0x47, %rsi
movl -0x28(%rbp), %eax
addq %rax, %rsi
leaq -0x78(%rbp), %rdi
callq 0x20e30
cmpl $0x0, %eax
je 0x21e95
movq -0x78(%rbp), %rsi
movq -0x10(%rbp), %rax
subq %rax, %rsi
movq -0x10(%rbp), %rdx
movq -0x78(%rbp), %rcx
movl -0x28(%rbp), %r8d
leaq 0x140c3(%rip), %rdi     # 0x35f26
movb $0x0, %al
callq 0x1f720
testb $0x1, -0x19(%rbp)
jne 0x21e8c
movq 0x1a161(%rip), %rax     # 0x3bfd8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x14187(%rip), %rsi     # 0x3600c
movb $0x0, %al
callq 0xd1b0
movl $0x2, -0x4(%rbp)
jmp 0x21ec7
jmp 0x21e97
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x21e1d
movq -0x18(%rbp), %rdi
movl -0x20(%rbp), %edx
movl -0x24(%rbp), %r8d
movl -0x28(%rbp), %r9d
addl $0x1, %r9d
xorl %esi, %esi
movl $0xff, %ecx
callq 0x21780
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)