// File: /workspace/github_c_makefile_star2_O1/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 0x10(%rsp), %rsi
movq %rsi, (%rsp)
leaq 0x8(%rsp), %r9
movq %rdx, %rsi
movq %rcx, %rdx
movq %rax, %rcx
callq 0x22937
testb %al, %al
je 0x23a51
movq 0x8(%rsp), %rdx
testq %rdx, %rdx
je 0x23a20
movq (%rbx), %rsi
leaq 0x172cf(%rip), %rdi     # 0x3abe1
xorl %eax, %eax
callq 0x254dd
leaq 0x77dd4(%rip), %rcx     # 0x9b6f4
leaq 0x77dcb(%rip), %rax     # 0x9b6f2
movb (%rax), %al
orb (%rcx), %al
leaq 0x172a4(%rip), %rcx     # 0x3abd6
leaq 0x7a65(%rip), %rbp      # 0x2b39e
testb $0x1, %al
cmovneq %rcx, %rbp
cmpq $0x0, (%rbx)
je 0x23a05
movl $0x1, %r15d
xorl %r13d, %r13d
movq 0x8(%rsp), %r12
xorl %ecx, %ecx
testq %r15, %r12
setne %cl
leaq 0x1729d(%rip), %rdi     # 0x3ac03
movq %r13, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x254dd
testq %r15, %r12
je 0x239f6
movq %r13, %rdi
callq *0x70(%r14)
leaq 0x77d6e(%rip), %rcx     # 0x9b6f4
movb (%rcx), %cl
testq %rax, %rax
je 0x239aa
testb %cl, %cl
je 0x239b7
leaq 0x17297(%rip), %rdi     # 0x3ac2f
movq %rbp, %rsi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x226ec
jmp 0x239ef
testb %cl, %cl
je 0x239cc
leaq 0x172a2(%rip), %rdi     # 0x3ac57
jmp 0x239d3
leaq 0x77d34(%rip), %rcx     # 0x9b6f2
cmpb $0x1, (%rcx)
jne 0x239db
leaq 0x17281(%rip), %rdi     # 0x3ac4b
jmp 0x239e2
leaq 0x172a0(%rip), %rdi     # 0x3ac73
movq %rbp, %rsi
movq %r15, %rdx
jmp 0x239e8
leaq 0x17270(%rip), %rdi     # 0x3ac52
movq %rbp, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x226ec
leaq 0x1c537(%rip), %rbp     # 0x3ff2d
addq %r15, %r15
incq %r13
cmpq (%rbx), %r13
jb 0x23952
leaq 0x77ce6(%rip), %rax     # 0x9b6f2
cmpb $0x1, (%rax)
jne 0x23a51
cmpb $0x5b, (%rbp)
jne 0x23a43
leaq 0x1725b(%rip), %rdi     # 0x3ac79
jmp 0x23a4a
leaq 0x77ccb(%rip), %rax     # 0x9b6f2
cmpb $0x1, (%rax)
jne 0x23a3a
xorl %esi, %esi
subq 0x10(%rsp), %rsi
callq 0x22ba4
jmp 0x23a51
leaq 0x13b8f(%rip), %rdi     # 0x375d0
jmp 0x23a4a
leaq 0x17230(%rip), %rdi     # 0x3ac7a
xorl %eax, %eax
callq 0x226ec
movb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq