// File: /workspace/github_c_makefile_star2_O3/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, 0x10(%rsp)
testq %rdi, %rdi
je 0xec5c
movl %r8d, %r12d
movl %ecx, %r13d
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movl 0x40(%rdi), %edi
callq 0xd5dc
movq %rax, %r15
testq %rax, %rax
jne 0xec45
movl 0x40(%rbx), %esi
leaq 0xfb2b(%rip), %rdi      # 0x1e769
xorl %eax, %eax
callq 0x19a33
testb %r13b, %r13b
je 0xedc1
testb %r12b, %r12b
je 0xec63
movq 0x26396(%rip), %rax     # 0x34ff0
jmp 0xec6a
xorl %ebp, %ebp
jmp 0xefdc
movq 0x26356(%rip), %rax     # 0x34fc0
movl %r12d, 0x18(%rsp)
movq (%rax), %r13
movzbl 0x3c(%rbx), %ecx
movzbl 0x45(%rbx), %r8d
movzbl 0x44(%rbx), %r9d
movl 0x40(%rbx), %r10d
leaq 0xfb02(%rip), %rsi      # 0x1e78d
movq %r13, %rdi
movq %rbx, %rdx
xorl %eax, %eax
pushq (%r15)
pushq %r10
callq 0xd1e0
addq $0x10, %rsp
testl %ebp, %ebp
movq %rbx, 0x20(%rsp)
movl %ebp, 0x1c(%rsp)
movq %r15, 0x8(%rsp)
je 0xed65
movslq %ebp, %r15
leaq 0xfae3(%rip), %r12      # 0x1e7a4
xorl %ebx, %ebx
movzbl (%r14,%rbx), %edx
movq %r13, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0xd1e0
incq %rbx
cmpq %rbx, %r15
jne 0xecc3
movl $0xa, %edi
movq %r13, %rsi
callq 0xd1b0
movq 0x20(%rsp), %rdx
movzbl 0x3c(%rdx), %ecx
movzbl 0x45(%rdx), %r8d
movzbl 0x44(%rdx), %r9d
movl 0x40(%rdx), %r10d
leaq 0xfa85(%rip), %rsi      # 0x1e78d
movq %r13, %rdi
xorl %eax, %eax
movq 0x8(%rsp), %r11
pushq (%r11)
pushq %r10
callq 0xd1e0
addq $0x10, %rsp
testl %ebp, %ebp
je 0xeda1
callq 0xd390
movq %rax, %r12
leaq 0xfa79(%rip), %rbp      # 0x1e7ac
xorl %ebx, %ebx
movq (%r12), %rcx
movzbl (%r14,%rbx), %eax
movzwl (%rcx,%rax,2), %ecx
movl $0x2e, %edx
testb $0x8, %cl
je 0xed4e
movl %eax, %edx
movq %r13, %rdi
movq %rbp, %rsi
xorl %eax, %eax
callq 0xd1e0
incq %rbx
cmpq %rbx, %r15
jne 0xed35
jmp 0xeda1
movl $0xa, %edi
movq %r13, %rsi
callq 0xd1b0
movzbl 0x3c(%rbx), %ecx
movzbl 0x45(%rbx), %r8d
movzbl 0x44(%rbx), %r9d
movl 0x40(%rbx), %r10d
leaq 0xfa02(%rip), %rsi      # 0x1e78d
movq %r13, %rdi
movq %rbx, %rdx
xorl %eax, %eax
pushq (%r15)
pushq %r10
callq 0xd1e0
addq $0x10, %rsp
movl $0xa, %edi
movq %r13, %rsi
callq 0xd1b0
movq 0x20(%rsp), %rbx
movl 0x1c(%rsp), %ebp
movq 0x8(%rsp), %r15
movl 0x18(%rsp), %r12d
testb %r12b, %r12b
je 0xee91
movq 0x15c8(%r15), %rsi
testq %rsi, %rsi
je 0xede4
leaq 0xf9d4(%rip), %rdi      # 0x1e7b1
xorl %eax, %eax
callq 0x16c1c
movzbl 0x3c(%rbx), %edx
movzbl 0x45(%rbx), %ecx
movzbl 0x44(%rbx), %r8d
movl 0x40(%rbx), %r9d
subq $0x8, %rsp
leaq 0xf9b8(%rip), %rdi      # 0x1e7b8
movq %rbx, %rsi
xorl %eax, %eax
pushq (%r15)
callq 0x16c1c
addq $0x10, %rsp
cmpb $0x1, 0x794af(%rip)     # 0x882c7
jne 0xee6e
movq %r15, 0x8(%rsp)
movq %rbx, %r13
leaq 0xf9d9(%rip), %rdi      # 0x1e802
xorl %eax, %eax
callq 0x16c1c
testl %ebp, %ebp
je 0xee58
movslq %ebp, %rbx
leaq 0xf967(%rip), %r12      # 0x1e7a5
xorl %r15d, %r15d
movzbl (%r14,%r15), %esi
movq %r12, %rdi
xorl %eax, %eax
callq 0x16c1c
incq %r15
cmpq %r15, %rbx
jne 0xee41
leaq 0x102e6(%rip), %rdi     # 0x1f145
xorl %eax, %eax
callq 0x16c1c
movq %r13, %rbx
movq 0x8(%rsp), %r15
cmpq $0x0, 0x15c8(%r15)
je 0xef10
movb $0x0, 0x7945f(%rip)     # 0x882e2
movw $0x7d7d, 0x79454(%rip)  # imm = 0x7D7D
jmp 0xef19
movzbl 0x3c(%rbx), %edx
movzbl 0x45(%rbx), %ecx
movzbl 0x44(%rbx), %r8d
movl 0x40(%rbx), %r9d
subq $0x8, %rsp
leaq 0xf96e(%rip), %rdi      # 0x1e81b
movq %rbx, %rsi
xorl %eax, %eax
pushq (%r15)
callq 0x16c1c
addq $0x10, %rsp
leaq 0xfc06(%rip), %rax      # 0x1eacb
movq %rax, 0x732f4(%rip)     # 0x821c0
leaq 0x10(%rsp), %r9
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xefed
movl %eax, %ebp
leaq 0xf77c(%rip), %rdi      # 0x1e668
xorl %eax, %eax
callq 0x16c1c
testb %bpl, %bpl
jne 0xef89
movq 0x260bd(%rip), %rax     # 0x34fc0
movq (%rax), %rdi
callq 0x16d6a
jmp 0xefc4
movw $0x7d, 0x793c7(%rip)    # 0x882e0
leaq 0xf8ef(%rip), %rax      # 0x1e80f
movq %rax, 0x73299(%rip)     # 0x821c0
leaq 0x10(%rsp), %r9
movq %r15, %rdi
movq %r14, %rsi
movl %ebp, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0xefed
movl %eax, %ebp
leaq 0x79396(%rip), %r14     # 0x882e0
movq %r14, %rdi
callq 0xd0f0
testq %rax, %rax
je 0xef76
movq %rax, %r15
leaq 0xf84d(%rip), %r12      # 0x1e7ae
movsbl -0x1(%r15,%r14), %esi
movq %r12, %rdi
xorl %eax, %eax
callq 0x16c1c
decq %r15
jne 0xef61
leaq 0xf6eb(%rip), %rdi      # 0x1e668
xorl %eax, %eax
callq 0x16c1c
testb %bpl, %bpl
je 0xefc4
movq 0x26030(%rip), %rax     # 0x34fc0
movq (%rax), %rdi
callq 0x16d6a
movq 0x10(%rsp), %rdx
movb $0x1, %bpl
testq %rdx, %rdx
je 0xefdc
cmpl $0xfe, 0x79341(%rip)    # 0x882f0
jg 0xefdc
movl 0x40(%rbx), %esi
leaq 0xf876(%rip), %rdi      # 0x1e831
xorl %eax, %eax
callq 0x199a0
jmp 0xefdc
callq 0x16cd1
movl 0x40(%rbx), %esi
leaq 0xf88e(%rip), %rdi      # 0x1e861
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x199a0
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq