// File: /workspace/github_c_makefile_star2_O1/canboat[P]canboat/analyzer/../common/parse.c
// Function: parseRawFormatGarminCSV
int parseRawFormatGarminCSV(char *msg, RawMessage *m, bool showJson, bool absolute)
{
  unsigned int seq, tstamp, pgn, src, dst, prio, single, count;
  time_t       t;
  struct tm    tm;
  char        *p;
  int          consumed;
  unsigned int i;

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

  if (absolute)
  {
    unsigned int month, day, year, hours, minutes, seconds, ms;

    if (sscanf(msg, "%u,%u_%u_%u_%u_%u_%u_%u,%u,", &seq, &month, &day, &year, &hours, &minutes, &seconds, &ms, &pgn) < 9)
    {
      logError("Error reading Garmin CSV message: %s", msg);
      if (!showJson)
        fprintf(stdout, "%s", msg);
      return 2;
    }
    snprintf(m->timestamp,
             sizeof(m->timestamp),
             "%04u-%02u-%02uT%02u:%02u:%02u,%03u",
             year,
             month,
             day,
             hours,
             minutes,
             seconds,
             ms % 1000);

    p = findOccurrence(msg, ',', 6);
  }
  else
  {
    if (sscanf(msg, "%u,%u,%u,", &seq, &tstamp, &pgn) < 3)
    {
      logError("Error reading Garmin CSV 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 = findOccurrence(msg, ',', 5);
  }

  if (!p || sscanf(p, "%u,%u,%u,%u,%u,0x%n", &src, &dst, &prio, &single, &count, &consumed) < 5)
  {
    logError("Error reading Garmin CSV message: %s", msg);
    if (!showJson)
      fprintf(stdout, "%s", msg);
    return 3;
  }
  p += consumed;

  for (i = 0; *p && i < count; 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, prio, pgn, dst, src, i + 1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movzbl (%rdi), %eax
movl $0x1, %r12d
testl %eax, %eax
je 0x27066
cmpl $0xa, %eax
je 0x27066
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
testb %cl, %cl
je 0x26e6a
subq $0x8, %rsp
leaq 0x34(%rsp), %r10
leaq 0x30(%rsp), %r11
leaq 0x14(%rsp), %r15
leaq 0x18(%rsp), %r12
leaq 0x1c(%rsp), %r13
leaq 0x19025(%rip), %rsi     # 0x3fde3
leaq 0x3c(%rsp), %rdx
leaq 0x48(%rsp), %rcx
leaq 0x40(%rsp), %r8
leaq 0x10(%rsp), %r9
movq %rbx, %rdi
movl $0x0, %eax
pushq %r10
pushq %r11
pushq %r15
pushq %r12
pushq %r13
callq 0xd220
addq $0x30, %rsp
movl %eax, %r15d
cmpl $0x8, %eax
jle 0x26eab
movl 0x8(%rsp), %ecx
movl 0x40(%rsp), %r8d
movl 0x38(%rsp), %r9d
movl 0x14(%rsp), %r10d
movl 0x10(%rsp), %r11d
movl 0xc(%rsp), %r12d
movl 0x28(%rsp), %r13d
imulq $0x10624dd3, %r13, %rax # imm = 0x10624DD3
shrq $0x26, %rax
imull $0x3e8, %eax, %eax      # imm = 0x3E8
subl %eax, %r13d
leaq 0x18fee(%rip), %rdx     # 0x3fe24
movl $0x3c, %esi
movq %r14, %rdi
xorl %eax, %eax
pushq %r13
pushq %r12
pushq %r11
pushq %r10
callq 0xd120
addq $0x20, %rsp
movq %rbx, %rdi
movl $0x2c, %esi
movl $0x6, %edx
callq 0x267af
movq %rax, 0x18(%rsp)
jmp 0x26ed3
leaq 0x18fd6(%rip), %rsi     # 0x3fe47
leaq 0x34(%rsp), %rdx
leaq 0x8(%rsp), %rcx
leaq 0x2c(%rsp), %r8
movq %rbx, %rdi
xorl %eax, %eax
callq 0xd220
cmpl $0x2, %eax
jg 0x26ee8
leaq 0x18f69(%rip), %rdi     # 0x3fdff
movq %rbx, %rsi
xorl %eax, %eax
callq 0x25570
movl $0x2, %r12d
jmp 0x26fc5
leaq 0x18f4d(%rip), %rdi     # 0x3fdff
movq %rbx, %rsi
xorl %eax, %eax
callq 0x25570
testb %bpl, %bpl
jne 0x26ed3
movq 0x1f100(%rip), %rax     # 0x45fc8
movq (%rax), %rsi
movq %rbx, %rdi
callq 0xd170
movl $0x2, %r12d
cmpl $0x8, %r15d
jg 0x26f6b
jmp 0x27066
movl 0x8(%rsp), %eax
imulq $0x10624dd3, %rax, %rax # imm = 0x10624DD3
shrq $0x26, %rax
leaq 0x38(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x40(%rsp), %r15
movq %r15, %rsi
callq 0xd0a0
leaq 0x18b45(%rip), %rdx     # 0x3fa58
movl $0x3c, %esi
movq %r14, %rdi
movq %r15, %rcx
callq 0xd260
movq %r14, %rdi
callq 0xd0f0
leaq (%rax,%r14), %rdi
movl 0x8(%rsp), %edx
imulq $0x10624dd3, %rdx, %rax # imm = 0x10624DD3
shrq $0x26, %rax
imull $0x3e8, %eax, %eax      # imm = 0x3E8
subl %eax, %edx
leaq 0x18e8f(%rip), %rsi     # 0x3fddc
xorl %eax, %eax
callq 0xd2c0
movq %rbx, %rdi
movl $0x2c, %esi
movl $0x5, %edx
callq 0x267af
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x26fae
leaq 0x30(%rsp), %r10
leaq 0x24(%rsp), %r11
leaq 0x18ecb(%rip), %rsi     # 0x3fe51
leaq 0x14(%rsp), %rdx
leaq 0x10(%rsp), %rcx
leaq 0xc(%rsp), %r8
leaq 0x28(%rsp), %r9
xorl %eax, %eax
pushq %r10
pushq %r11
callq 0xd220
addq $0x10, %rsp
cmpl $0x4, %eax
jg 0x26fe5
leaq 0x18e4a(%rip), %rdi     # 0x3fdff
movq %rbx, %rsi
xorl %eax, %eax
callq 0x25570
movl $0x3, %r12d
testb %bpl, %bpl
jne 0x27066
movq 0x1eff3(%rip), %rax     # 0x45fc8
movq (%rax), %rsi
movq %rbx, %rdi
callq 0xd170
jmp 0x27066
movslq 0x30(%rsp), %rax
movq 0x18(%rsp), %rcx
leaq (%rcx,%rax), %rdx
movq %rdx, 0x18(%rsp)
cmpb $0x0, (%rcx,%rax)
movb $0x1, %al
je 0x2703d
cmpl $0x0, 0x24(%rsp)
je 0x2703d
leaq 0x47(%r14), %r13
xorl %r15d, %r15d
leaq 0x18(%rsp), %r12
leaq (%r15,%r13), %rsi
movq %r12, %rdi
callq 0x262e5
movq 0x18(%rsp), %rcx
testl %eax, %eax
jne 0x27078
incq %r15
cmpb $0x0, (%rcx)
je 0x27039
movl 0x24(%rsp), %eax
cmpq %rax, %r15
jb 0x27013
leal 0x1(%r15), %eax
movb 0xc(%rsp), %cl
movl 0x2c(%rsp), %edx
movb 0x10(%rsp), %sil
movb 0x14(%rsp), %dil
movb %cl, 0x3c(%r14)
movl %edx, 0x40(%r14)
movb %sil, 0x44(%r14)
movb %dil, 0x45(%r14)
movb %al, 0x46(%r14)
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, %rsi
subq %rbx, %rsi
leaq 0x18cb6(%rip), %rdi     # 0x3fd3b
movq %rbx, %rdx
movl %r15d, %r8d
xorl %eax, %eax
callq 0x25570
jmp 0x26ea0