// File: /workspace/github_c_makefile_star2_O2/canboat[P]canboat/analyzer/print.c
// Function: fieldPrintBitLookup
extern bool fieldPrintBitLookup(const Field   *field,
                                const char    *fieldName,
                                const uint8_t *data,
                                size_t         dataLen,
                                size_t         startBit,
                                size_t        *bits)
{
  int64_t value;
  int64_t maxValue;
  int64_t bitValue;
  size_t  bit;
  char   *sep;

  if (!extractNumber(field, data, dataLen, startBit, *bits, &value, &maxValue))
  {
    return true;
  }
  if (value == 0)
  {
    if (showJson)
    {
      printEmpty(fieldName, value - maxValue);
    }
    else
    {
      mprintf("None");
    }
    return true;
  }

  logDebug("RES_BITFIELD length %u value %" PRIx64 "\n", *bits, value);

  if (showJsonValue)
  {
    sep = "[";
  }
  else if (showJson)
  {
    sep = "[";
  }
  else
  {
    sep = "";
  }

  for (bitValue = 1, bit = 0; bit < *bits; (bitValue <<= 1), bit++)
  {
    bool isSet = (value & bitValue) != 0;
    logDebug("RES_BITFIELD is bit %u value %" PRIx64 " set? = %d\n", bit, bitValue, isSet);
    if (isSet)
    {
      const char *s = (*field->lookup.function.pair)(bit);

      if (s != NULL)
      {
        if (showJsonValue)
        {
          mprintf("%s{\"value\":%" PRId64 ",\"name\":\"%s\"}", sep, bitValue, s);
        }
        else if (showJson)
        {
          mprintf("%s\"%s\"", sep, s);
        }
        else
        {
          mprintf("%s%s", sep, s);
        }
      }
      else
      {
        if (showJsonValue)
        {
          mprintf("%s{\"value\":%" PRIu64 ",\"name\":null}", sep, bitValue);
        }
        else
        {
          mprintf("%s%" PRIu64, sep, bitValue);
        }
      }
      sep = ",";
    }
  }
  if (showJson)
  {
    if (*sep != '[')
    {
      mprintf("]");
    }
    else
    {
      mprintf("[]");
    }
  }
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %rbx
movq %r8, %rax
movq %rdi, %r14
movq (%r9), %r8
leaq 0x8(%rsp), %rsi
movq %rsi, (%rsp)
leaq 0x10(%rsp), %r9
movq %rdx, %rsi
movq %rcx, %rdx
movq %rax, %rcx
callq 0x193d9
testb %al, %al
je 0x1a455
movq 0x10(%rsp), %r15
testq %r15, %r15
je 0x1a424
movq (%rbx), %rsi
leaq 0x12632(%rip), %rdi     # 0x2c951
movq %r15, %rdx
xorl %eax, %eax
callq 0x1bd48
leaq 0x753c4(%rip), %rcx     # 0x8f6f4
leaq 0x753bb(%rip), %rax     # 0x8f6f2
movb (%rax), %al
orb (%rcx), %al
leaq 0x12604(%rip), %rcx     # 0x2c946
leaq 0x8055(%rip), %r13      # 0x2239e
testb $0x1, %al
cmovneq %rcx, %r13
pushq $0x1
popq %r12
xorl %ebp, %ebp
cmpq (%rbx), %rbp
jae 0x1a408
xorl %ecx, %ecx
testq %r12, %r15
setne %cl
leaq 0x12606(%rip), %rdi     # 0x2c973
movq %rbp, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x1bd48
testq %r12, %r15
je 0x1a3fd
movq %rbp, %rdi
callq *0x70(%r14)
leaq 0x75367(%rip), %rcx     # 0x8f6f4
movb (%rcx), %cl
testq %rax, %rax
je 0x1a3b1
testb %cl, %cl
je 0x1a3be
leaq 0x12600(%rip), %rdi     # 0x2c99f
movq %r13, %rsi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x19194
jmp 0x1a3f6
testb %cl, %cl
je 0x1a3d3
leaq 0x1260b(%rip), %rdi     # 0x2c9c7
jmp 0x1a3da
leaq 0x7532d(%rip), %rcx     # 0x8f6f2
cmpb $0x1, (%rcx)
jne 0x1a3e2
leaq 0x125ea(%rip), %rdi     # 0x2c9bb
jmp 0x1a3e9
leaq 0x12609(%rip), %rdi     # 0x2c9e3
movq %r13, %rsi
movq %r12, %rdx
jmp 0x1a3ef
leaq 0x125d9(%rip), %rdi     # 0x2c9c2
movq %r13, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x19194
leaq 0x178cd(%rip), %r13     # 0x31cca
addq %r12, %r12
incq %rbp
jmp 0x1a355
leaq 0x752e3(%rip), %rax     # 0x8f6f2
cmpb $0x1, (%rax)
jne 0x1a455
cmpb $0x5b, (%r13)
jne 0x1a447
leaq 0x125c7(%rip), %rdi     # 0x2c9e9
jmp 0x1a44e
leaq 0x752c7(%rip), %rax     # 0x8f6f2
cmpb $0x1, (%rax)
jne 0x1a43e
xorl %esi, %esi
subq 0x8(%rsp), %rsi
callq 0x19614
jmp 0x1a455
leaq 0xeeff(%rip), %rdi      # 0x29344
jmp 0x1a44e
leaq 0x1259c(%rip), %rdi     # 0x2c9ea
xorl %eax, %eax
callq 0x19194
movb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq