// File: /workspace/github_c_makefile_star2_O1/canboat[P]canboat/analyzer/analyzer.c
// Function: printPgn
bool printPgn(const RawMessage *msg, const uint8_t *data, int length, bool showData, bool showJson)
{
  const Pgn *pgn;

  size_t i;
  bool   r;
  size_t variableFields = 0; // How many variable fields remain (product of repetition count * # of fields)

  if (msg == NULL)
  {
    return false;
  }
  pgn = getMatchingPgn(msg->pgn, data, length);
  if (!pgn)
  {
    logAbort("No PGN definition found for PGN %u\n", msg->pgn);
  }

  if (showData)
  {
    FILE *f = stdout;

    if (showJson)
    {
      f = stderr;
    }

    fprintf(f, "%s %u %3u %3u %6u %s: ", msg->timestamp, msg->prio, msg->src, msg->dst, msg->pgn, pgn->description);
    for (i = 0; i < length; i++)
    {
      fprintf(f, " %2.02X", data[i]);
    }
    putc('\n', f);

    fprintf(f, "%s %u %3u %3u %6u %s: ", msg->timestamp, msg->prio, msg->src, msg->dst, msg->pgn, pgn->description);
    for (i = 0; i < length; i++)
    {
      fprintf(f, "  %c", isalnum(data[i]) ? data[i] : '.');
    }
    putc('\n', f);
  }
  if (showJson)
  {
    if (pgn->camelDescription)
    {
      mprintf("{\"%s\":", pgn->camelDescription);
    }
    mprintf("{\"timestamp\":\"%s\",\"prio\":%u,\"src\":%u,\"dst\":%u,\"pgn\":%u,\"description\":\"%s\"",
            msg->timestamp,
            msg->prio,
            msg->src,
            msg->dst,
            msg->pgn,
            pgn->description);
    if (showAllBytes)
    {
      mprintf(",\"data\":\"");
      for (i = 0; i < length; i++)
      {
        mprintf("%2.02X", data[i]);
      }
      mprintf("\"");
    }
    if (pgn->camelDescription)
    {
      strcpy(closingBraces, "}}");
    }
    else
    {
      strcpy(closingBraces, "}");
    }
    sep = ",\"fields\":{";
  }
  else
  {
    mprintf("%s %u %3u %3u %6u %s:", msg->timestamp, msg->prio, msg->src, msg->dst, msg->pgn, pgn->description);
    sep = " ";
  }
  r = printFields(pgn, data, length, showData, showJson, &variableFields);

  if (showJson)
  {
    for (i = strlen(closingBraces); i;)
    {
      mprintf("%c", closingBraces[--i]);
    }
  }
  mprintf("\n");

  if (r)
  {
    mwrite(stdout);
    if (variableFields > 0 && g_variableFieldRepeat[0] < UINT8_MAX)
    {
      logError("PGN %u has %zu missing fields in repeating set\n", msg->pgn, variableFields);
    }
  }
  else
  {
    if (!showJson)
    {
      mwrite(stdout);
    }
    mreset();
    logError("PGN %u analysis error\n", msg->pgn);
  }

  if (msg->pgn == 126992 && currentDate < UINT16_MAX && currentTime < UINT32_MAX && clockSrc == msg->src)
  {
    setSystemClock();
  }
  return r;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq $0x0, 0x18(%rsp)
testq %rdi, %rdi
je 0xed18
movl %r8d, %ebx
movl %ecx, %r13d
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbp
movl 0x40(%rdi), %edi
callq 0xd5f2
movq %rax, %r12
testq %rax, %rax
jne 0xed02
movl 0x40(%rbp), %esi
leaq 0x10a6e(%rip), %rdi     # 0x1f769
xorl %eax, %eax
callq 0x19bbb
testb %r13b, %r13b
je 0xee3f
testb %bl, %bl
je 0xed20
movq 0x272da(%rip), %rax     # 0x35ff0
jmp 0xed27
xorl %r14d, %r14d
jmp 0xf028
movq 0x27299(%rip), %rax     # 0x35fc0
movl %ebx, 0x8(%rsp)
movq (%rax), %r13
movzbl 0x3c(%rbp), %ecx
movzbl 0x45(%rbp), %r8d
movzbl 0x44(%rbp), %r9d
movl 0x40(%rbp), %r10d
leaq 0x10a46(%rip), %rsi     # 0x1f78d
movq %r13, %rdi
movq %rbp, %rdx
xorl %eax, %eax
movq %r12, 0x10(%rsp)
pushq (%r12)
pushq %r10
callq 0xd1e0
addq $0x10, %rsp
movslq %r14d, %r12
movl %r14d, 0xc(%rsp)
testl %r14d, %r14d
je 0xed93
leaq 0x10a2d(%rip), %r14     # 0x1f7a4
xorl %ebx, %ebx
movzbl (%r15,%rbx), %edx
movq %r13, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0xd1e0
incq %rbx
cmpq %rbx, %r12
jne 0xed79
movl $0xa, %edi
movq %r13, %rsi
callq 0xd1b0
movzbl 0x3c(%rbp), %ecx
movzbl 0x45(%rbp), %r8d
movzbl 0x44(%rbp), %r9d
movl 0x40(%rbp), %r10d
leaq 0x109d4(%rip), %rsi     # 0x1f78d
movq %r13, %rdi
movq %rbp, 0x20(%rsp)
movq %rbp, %rdx
xorl %eax, %eax
movq 0x10(%rsp), %r11
pushq (%r11)
pushq %r10
callq 0xd1e0
addq $0x10, %rsp
cmpl $0x0, 0xc(%rsp)
je 0xee1f
callq 0xd390
movq %rax, %rbp
leaq 0x109bd(%rip), %r14     # 0x1f7ac
xorl %ebx, %ebx
movq (%rbp), %rcx
movzbl (%r15,%rbx), %eax
movzwl (%rcx,%rax,2), %ecx
movl $0x2e, %edx
testb $0x8, %cl
je 0xee0a
movl %eax, %edx
movq %r13, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0xd1e0
incq %rbx
cmpq %rbx, %r12
jne 0xedf1
movl $0xa, %edi
movq %r13, %rsi
callq 0xd1b0
movq 0x20(%rsp), %rbp
movl 0x8(%rsp), %ebx
movl 0xc(%rsp), %r14d
movq 0x10(%rsp), %r12
testb %bl, %bl
je 0xef13
movq 0x15c8(%r12), %rsi
testq %rsi, %rsi
je 0xee62
leaq 0x10956(%rip), %rdi     # 0x1f7b1
xorl %eax, %eax
callq 0x16cd0
movzbl 0x3c(%rbp), %edx
movzbl 0x45(%rbp), %ecx
movzbl 0x44(%rbp), %r8d
movl 0x40(%rbp), %r9d
subq $0x8, %rsp
leaq 0x1093a(%rip), %rdi     # 0x1f7b8
movq %rbp, %rsi
xorl %eax, %eax
pushq (%r12)
callq 0x16cd0
addq $0x10, %rsp
cmpb $0x1, 0x7a430(%rip)     # 0x892c7
jne 0xeef6
movq %r12, 0x10(%rsp)
movl %ebx, 0x8(%rsp)
leaq 0x10959(%rip), %rdi     # 0x1f802
xorl %eax, %eax
callq 0x16cd0
movl %r14d, %r13d
testl %r14d, %r14d
je 0xeedc
movslq %r13d, %rbx
leaq 0x108e3(%rip), %r14     # 0x1f7a5
xorl %r12d, %r12d
movzbl (%r15,%r12), %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x16cd0
incq %r12
cmpq %r12, %rbx
jne 0xeec5
leaq 0x11262(%rip), %rdi     # 0x20145
xorl %eax, %eax
callq 0x16cd0
movl 0x8(%rsp), %ebx
movl %r13d, %r14d
movq 0x10(%rsp), %r12
cmpq $0x0, 0x15c8(%r12)
je 0xef4a
movb $0x0, 0x7a3da(%rip)     # 0x892e2
movw $0x7d7d, 0x7a3cf(%rip)  # imm = 0x7D7D
jmp 0xef53
movzbl 0x3c(%rbp), %edx
movzbl 0x45(%rbp), %ecx
movzbl 0x44(%rbp), %r8d
movl 0x40(%rbp), %r9d
subq $0x8, %rsp
leaq 0x108ec(%rip), %rdi     # 0x1f81b
movq %rbp, %rsi
xorl %eax, %eax
pushq (%r12)
callq 0x16cd0
addq $0x10, %rsp
leaq 0x10b83(%rip), %rax     # 0x1facb
jmp 0xef5a
movw $0x7d, 0x7a38d(%rip)    # 0x892e0
leaq 0x108b5(%rip), %rax     # 0x1f80f
movq %rax, 0x7425f(%rip)     # 0x831c0
movzbl %bl, %r8d
leaq 0x18(%rsp), %r9
movq %r12, %rdi
movq %r15, %rsi
movl %r14d, %edx
xorl %ecx, %ecx
callq 0xf03a
movl %eax, %r14d
testb %bl, %bl
je 0xefb4
leaq 0x7a358(%rip), %r15     # 0x892e0
movq %r15, %rdi
callq 0xd0f0
testq %rax, %rax
je 0xefb4
movq %rax, %r12
leaq 0x1080f(%rip), %r13     # 0x1f7ae
movsbl -0x1(%r12,%r15), %esi
movq %r13, %rdi
xorl %eax, %eax
callq 0x16cd0
decq %r12
jne 0xef9f
leaq 0x106ad(%rip), %rdi     # 0x1f668
xorl %eax, %eax
callq 0x16cd0
testb %r14b, %r14b
je 0xefff
movq 0x26ff2(%rip), %rax     # 0x35fc0
movq (%rax), %rdi
callq 0x16e1e
movq 0x18(%rsp), %rdx
testq %rdx, %rdx
je 0xf028
cmpl $0xfe, 0x7a306(%rip)    # 0x892f0
jg 0xf028
movl 0x40(%rbp), %esi
leaq 0x1083b(%rip), %rdi     # 0x1f831
xorl %eax, %eax
callq 0x19b28
jmp 0xf028
testb %bl, %bl
jne 0xf012
movq 0x26fb6(%rip), %rax     # 0x35fc0
movq (%rax), %rdi
callq 0x16e1e
callq 0x16d85
movl 0x40(%rbp), %esi
leaq 0x10840(%rip), %rdi     # 0x1f861
xorl %eax, %eax
callq 0x19b28
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq