// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0xf0, %rsp
movb %cl, %al
movb %dl, %cl
movq %rdi, -0x20(%rbp)
movq %rsi, -0x28(%rbp)
andb $0x1, %cl
movb %cl, -0x29(%rbp)
andb $0x1, %al
movb %al, -0x2a(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x21f1d
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
jne 0x21f29
movl $0x1, -0x14(%rbp)
jmp 0x222e6
testb $0x1, -0x2a(%rbp)
je 0x2205b
movq -0x20(%rbp), %rdi
leaq 0x14090(%rip), %rsi     # 0x35fce
leaq -0x30(%rbp), %rdx
leaq -0xa4(%rbp), %rcx
leaq -0xa8(%rbp), %r8
leaq -0xac(%rbp), %r9
leaq -0xb0(%rbp), %r14
leaq -0xb4(%rbp), %rbx
leaq -0xb8(%rbp), %r11
leaq -0xbc(%rbp), %r10
leaq -0x38(%rbp), %rax
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movb $0x0, %al
callq 0xd220
cmpl $0x9, %eax
jge 0x21fdb
movq -0x20(%rbp), %rsi
leaq 0x14044(%rip), %rdi     # 0x35fea
movb $0x0, %al
callq 0x1f720
testb $0x1, -0x29(%rbp)
jne 0x21fcf
movq 0x1a01e(%rip), %rax     # 0x3bfd8
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0x14044(%rip), %rsi     # 0x3600c
movb $0x0, %al
callq 0xd1b0
movl $0x2, -0x14(%rbp)
jmp 0x222e6
movq -0x28(%rbp), %rdi
movl -0xac(%rbp), %ecx
movl -0xa4(%rbp), %r8d
movl -0xa8(%rbp), %r9d
movl -0xb0(%rbp), %ebx
movl -0xb4(%rbp), %r11d
movl -0xb8(%rbp), %r10d
movl -0xbc(%rbp), %eax
movl $0x3e8, %esi            # imm = 0x3E8
xorl %edx, %edx
divl %esi
movl %edx, %eax
movl $0x3c, %esi
leaq 0x13feb(%rip), %rdx     # 0x3600f
movl %ebx, (%rsp)
movl %r11d, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movb $0x0, %al
callq 0xd100
movq -0x20(%rbp), %rdi
movl $0x2c, %esi
movl $0x6, %edx
callq 0x216c0
movq %rax, -0x98(%rbp)
jmp 0x2214d
movq -0x20(%rbp), %rdi
leaq 0x13fcc(%rip), %rsi     # 0x36032
leaq -0x30(%rbp), %rdx
leaq -0x34(%rbp), %rcx
leaq -0x38(%rbp), %r8
movb $0x0, %al
callq 0xd220
cmpl $0x3, %eax
jge 0x220be
movq -0x20(%rbp), %rsi
leaq 0x13f61(%rip), %rdi     # 0x35fea
movb $0x0, %al
callq 0x1f720
testb $0x1, -0x29(%rbp)
jne 0x220b2
movq 0x19f3b(%rip), %rax     # 0x3bfd8
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0x13f61(%rip), %rsi     # 0x3600c
movb $0x0, %al
callq 0xd1b0
movl $0x2, -0x14(%rbp)
jmp 0x222e6
movl -0x34(%rbp), %eax
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
movq %rax, -0x58(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0xd090
movq -0x28(%rbp), %rdi
movl $0x3c, %esi
leaq 0x13b49(%rip), %rdx     # 0x35c38
leaq -0x90(%rbp), %rcx
callq 0xd260
movq -0x28(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x28(%rbp), %rdi
callq 0xd0d0
movq -0xc8(%rbp), %rdi
addq %rax, %rdi
movl -0x34(%rbp), %eax
movl $0x3e8, %ecx            # imm = 0x3E8
xorl %edx, %edx
divl %ecx
leaq 0x13e9b(%rip), %rsi     # 0x35fc7
movb $0x0, %al
callq 0xd2d0
movq -0x20(%rbp), %rdi
movl $0x2c, %esi
movl $0x5, %edx
callq 0x216c0
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x98(%rbp)
je 0x22195
movq -0x98(%rbp), %rdi
leaq 0x13ed7(%rip), %rsi     # 0x3603c
leaq -0x3c(%rbp), %rdx
leaq -0x40(%rbp), %rcx
leaq -0x44(%rbp), %r8
leaq -0x48(%rbp), %r9
leaq -0x4c(%rbp), %r10
leaq -0x9c(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0xd220
cmpl $0x5, %eax
jge 0x221d5
movq -0x20(%rbp), %rsi
leaq 0x13e4a(%rip), %rdi     # 0x35fea
movb $0x0, %al
callq 0x1f720
testb $0x1, -0x29(%rbp)
jne 0x221c9
movq 0x19e24(%rip), %rax     # 0x3bfd8
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0x13e4a(%rip), %rsi     # 0x3600c
movb $0x0, %al
callq 0xd1b0
movl $0x3, -0x14(%rbp)
jmp 0x222e6
movl -0x9c(%rbp), %ecx
movq -0x98(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x98(%rbp)
movl $0x0, -0xa0(%rbp)
movq -0x98(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0xc9(%rbp)
je 0x22222
movl -0xa0(%rbp), %eax
cmpl -0x4c(%rbp), %eax
setb %al
movb %al, -0xc9(%rbp)
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0x22231
jmp 0x222c2
movq -0x28(%rbp), %rsi
addq $0x47, %rsi
movl -0xa0(%rbp), %eax
addq %rax, %rsi
leaq -0x98(%rbp), %rdi
callq 0x20e30
cmpl $0x0, %eax
je 0x222ac
movq -0x98(%rbp), %rsi
movq -0x20(%rbp), %rax
subq %rax, %rsi
movq -0x20(%rbp), %rdx
movq -0x98(%rbp), %rcx
movl -0xa0(%rbp), %r8d
leaq 0x13cac(%rip), %rdi     # 0x35f26
movb $0x0, %al
callq 0x1f720
testb $0x1, -0x29(%rbp)
jne 0x222a3
movq 0x19d4a(%rip), %rax     # 0x3bfd8
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
leaq 0x13d70(%rip), %rsi     # 0x3600c
movb $0x0, %al
callq 0xd1b0
movl $0x2, -0x14(%rbp)
jmp 0x222e6
jmp 0x222ae
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0x221f9
movq -0x28(%rbp), %rdi
movl -0x44(%rbp), %esi
movl -0x38(%rbp), %edx
movl -0x40(%rbp), %ecx
movl -0x3c(%rbp), %r8d
movl -0xa0(%rbp), %r9d
addl $0x1, %r9d
callq 0x21780
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
addq $0xf0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nopw %cs:(%rax,%rax)