// File: /workspace/github_c_makefile_star2_O0/canboat[P]canboat/analyzer/analyzer.c
// Function: printFields
extern bool printFields(const Pgn *pgn, const uint8_t *data, int length, bool showData, bool showJson, size_t *variableFields)
{
  size_t  i;
  size_t  bits;
  size_t  startBit;
  int     repetition;
  char    fieldName[60];
  uint8_t variableFieldStart;
  uint8_t variableFieldCount;

  bool r = true;

  logDebug("fieldCount=%d repeatingStart1=%" PRIu8 "\n", pgn->fieldCount, pgn->repeatingStart1);

  g_variableFieldRepeat[0] = 255; // Can be overridden by '# of parameters'
  g_variableFieldRepeat[1] = 0;   // Can be overridden by '# of parameters'
  repetition               = 0;
  *variableFields          = 0;

  for (i = 0, startBit = 0; (startBit >> 3) < length; i++)
  {
    const Field *field = &pgn->fieldList[i];

    if (*variableFields == 0)
    {
      repetition = 0;
    }

    if (pgn->repeatingCount1 > 0 && field->order == pgn->repeatingStart1 && repetition == 0)
    {
      if (showJson)
      {
        mprintf("%s\"list\":[{", getSep());
        strcat(closingBraces, "]}");
        sep = "";
      }
      // Only now is g_variableFieldRepeat set
      *variableFields    = pgn->repeatingCount1 * g_variableFieldRepeat[0];
      variableFieldCount = pgn->repeatingCount1;
      variableFieldStart = pgn->repeatingStart1;
      repetition         = 1;
    }
    if (pgn->repeatingCount2 > 0 && field->order == pgn->repeatingStart2 && repetition == 0)
    {
      if (showJson)
      {
        mprintf("}],\"list2\":[{");
        sep = "";
      }
      // Only now is g_variableFieldRepeat set
      *variableFields    = pgn->repeatingCount2 * g_variableFieldRepeat[1];
      variableFieldCount = pgn->repeatingCount2;
      variableFieldStart = pgn->repeatingStart2;
      repetition         = 1;
    }

    if (*variableFields > 0)
    {
      if (i + 1 == variableFieldStart + variableFieldCount)
      {
        i     = variableFieldStart - 1;
        field = &pgn->fieldList[i];
        repetition++;
        if (showJson)
        {
          mprintf("},{");
          sep = "";
        }
      }
      logDebug("variableFields: repetition=%d field=%" PRIu8 " variableFieldStart=%" PRIu8 " variableFieldCount=%" PRIu8
               " remaining=%zu\n",
               repetition,
               i + 1,
               variableFieldStart,
               variableFieldCount,
               *variableFields);
      (*variableFields)--;
    }

    if (!field->camelName && !field->name)
    {
      logDebug("PGN %u has unknown bytes at end: %u\n", pgn->pgn, length - (startBit >> 3));
      break;
    }

    if (showCamel)
    {
      strcpy(fieldName, field->camelName ? field->camelName : field->name);
    }
    else
    {
      strcpy(fieldName, field->name);
    }

    if (repetition >= 1 && !showJson)
    {
      strcat(fieldName, field->camelName ? "_" : " ");
      sprintf(fieldName + strlen(fieldName), "%u", repetition);
    }

    if (!printField(field, fieldName, data, length, startBit, &bits, true))
    {
      r = false;
      break;
    }

    startBit += bits;
  }

  return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movb %r8b, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
andb $0x1, %cl
movb %cl, -0x15(%rbp)
andb $0x1, %al
movb %al, -0x16(%rbp)
movq %r9, -0x20(%rbp)
movb $0x1, -0x83(%rbp)
movq -0x8(%rbp), %rax
movl 0x15c0(%rax), %esi
movq -0x8(%rbp), %rax
movzbl 0x15ed(%rax), %edx
leaq 0x1bac6(%rip), %rdi     # 0x299b1
movb $0x0, %al
callq 0x22570
movl $0xff, 0x86474(%rip)    # 0x94370
movl $0x0, 0x8646e(%rip)     # 0x94374
movl $0x0, -0x3c(%rbp)
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
shrq $0x3, %rax
movslq -0x14(%rbp), %rcx
cmpq %rcx, %rax
jae 0xe2e8
movq -0x8(%rbp), %rax
addq $0x18, %rax
imulq $0xa8, -0x28(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x90(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
jne 0xdf68
movl $0x0, -0x3c(%rbp)
movq -0x8(%rbp), %rax
movzbl 0x15eb(%rax), %eax
cmpl $0x0, %eax
jle 0xe024
movq -0x90(%rbp), %rax
movzbl 0x4b(%rax), %eax
movq -0x8(%rbp), %rcx
movzbl 0x15ed(%rcx), %ecx
cmpl %ecx, %eax
jne 0xe024
cmpl $0x0, -0x3c(%rbp)
jne 0xe024
testb $0x1, -0x16(%rbp)
je 0xdfe1
callq 0x1df30
movq %rax, %rsi
leaq 0x1ba1a(%rip), %rdi     # 0x299d3
movb $0x0, %al
callq 0x1dce0
leaq 0x86399(%rip), %rdi     # 0x94360
leaq 0x1ba11(%rip), %rsi     # 0x299df
callq 0xb300
leaq 0x1b68f(%rip), %rax     # 0x29669
movq %rax, 0x801df(%rip)     # 0x8e1c0
movq -0x8(%rbp), %rax
movzbl 0x15eb(%rax), %eax
imull 0x8637d(%rip), %eax     # 0x94370
movslq %eax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movb 0x15eb(%rax), %al
movb %al, -0x82(%rbp)
movq -0x8(%rbp), %rax
movb 0x15ed(%rax), %al
movb %al, -0x81(%rbp)
movl $0x1, -0x3c(%rbp)
movq -0x8(%rbp), %rax
movzbl 0x15ec(%rax), %eax
cmpl $0x0, %eax
jle 0xe0bd
movq -0x90(%rbp), %rax
movzbl 0x4b(%rax), %eax
movq -0x8(%rbp), %rcx
movzbl 0x15ee(%rcx), %ecx
cmpl %ecx, %eax
jne 0xe0bd
cmpl $0x0, -0x3c(%rbp)
jne 0xe0bd
testb $0x1, -0x16(%rbp)
je 0xe07a
leaq 0x1b97d(%rip), %rdi     # 0x299e2
movb $0x0, %al
callq 0x1dce0
leaq 0x1b5f6(%rip), %rax     # 0x29669
movq %rax, 0x80146(%rip)     # 0x8e1c0
movq -0x8(%rbp), %rax
movzbl 0x15ec(%rax), %eax
imull 0x862e8(%rip), %eax     # 0x94374
movslq %eax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movb 0x15ec(%rax), %al
movb %al, -0x82(%rbp)
movq -0x8(%rbp), %rax
movb 0x15ee(%rax), %al
movb %al, -0x81(%rbp)
movl $0x1, -0x3c(%rbp)
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
jbe 0xe17f
movq -0x28(%rbp), %rax
addq $0x1, %rax
movzbl -0x81(%rbp), %ecx
movzbl -0x82(%rbp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jne 0xe142
movzbl -0x81(%rbp), %eax
subl $0x1, %eax
cltq
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
addq $0x18, %rax
imulq $0xa8, -0x28(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x90(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
testb $0x1, -0x16(%rbp)
je 0xe140
leaq 0x1b8c5(%rip), %rdi     # 0x299f0
movb $0x0, %al
callq 0x1dce0
leaq 0x1b530(%rip), %rax     # 0x29669
movq %rax, 0x80080(%rip)     # 0x8e1c0
jmp 0xe142
movl -0x3c(%rbp), %esi
movq -0x28(%rbp), %rdx
addq $0x1, %rdx
movzbl -0x81(%rbp), %ecx
movzbl -0x82(%rbp), %r8d
movq -0x20(%rbp), %rax
movq (%rax), %r9
leaq 0x1b88a(%rip), %rdi     # 0x299f4
movb $0x0, %al
callq 0x22570
movq -0x20(%rbp), %rax
movq (%rax), %rcx
addq $-0x1, %rcx
movq %rcx, (%rax)
movq -0x90(%rbp), %rax
cmpq $0x0, 0x58(%rax)
jne 0xe1c3
movq -0x90(%rbp), %rax
cmpq $0x0, (%rax)
jne 0xe1c3
movq -0x8(%rbp), %rax
movl 0x8(%rax), %esi
movslq -0x14(%rbp), %rdx
movq -0x38(%rbp), %rax
shrq $0x3, %rax
subq %rax, %rdx
leaq 0x1b89f(%rip), %rdi     # 0x29a56
movb $0x0, %al
callq 0x22570
jmp 0xe2e8
testb $0x1, 0x86182(%rip)     # 0x9434c
je 0xe21f
leaq -0x80(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x90(%rbp), %rax
cmpq $0x0, 0x58(%rax)
je 0xe1f9
movq -0x90(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0xa0(%rbp)
jmp 0xe20a
movq -0x90(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0x98(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0xb090
jmp 0xe232
leaq -0x80(%rbp), %rdi
movq -0x90(%rbp), %rax
movq (%rax), %rsi
callq 0xb090
cmpl $0x1, -0x3c(%rbp)
jl 0xe297
testb $0x1, -0x16(%rbp)
jne 0xe297
leaq -0x80(%rbp), %rdi
movq -0x90(%rbp), %rax
movq 0x58(%rax), %rcx
leaq 0x1bd42(%rip), %rsi     # 0x29f96
leaq 0x1b820(%rip), %rax     # 0x29a7b
cmpq $0x0, %rcx
cmovneq %rax, %rsi
callq 0xb300
leaq -0x80(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0x80(%rbp), %rdi
callq 0xb0d0
movq -0xa8(%rbp), %rdi
addq %rax, %rdi
movl -0x3c(%rbp), %edx
leaq 0x2cf19(%rip), %rsi     # 0x3b1a9
movb $0x0, %al
callq 0xb310
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movq -0x10(%rbp), %rdx
movslq -0x14(%rbp), %rcx
movq -0x38(%rbp), %r8
leaq -0x30(%rbp), %r9
movl $0x1, (%rsp)
callq 0xe300
testb $0x1, %al
jne 0xe2cb
movb $0x0, -0x83(%rbp)
jmp 0xe2e8
movq -0x30(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xdf28
movb -0x83(%rbp), %al
andb $0x1, %al
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax)