// File: /workspace/github_c_makefile_star2_O3/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 0x1a2c7
testb %al, %al
je 0x1b3b7
movq 0x10(%rsp), %r15
testq %r15, %r15
je 0x1b386
movq (%rbx), %rsi
leaq 0x126db(%rip), %rdi     # 0x2d951
movq %r15, %rdx
xorl %eax, %eax
callq 0x1cd55
leaq 0x7346d(%rip), %rcx     # 0x8e6f4
leaq 0x73464(%rip), %rax     # 0x8e6f2
movb (%rax), %al
movb (%rcx), %cl
orb %al, %cl
leaq 0x126ab(%rip), %rdx     # 0x2d946
leaq 0x80fc(%rip), %rbp      # 0x2339e
testb $0x1, %cl
cmovneq %rdx, %rbp
cmpq $0x0, (%rbx)
je 0x1b373
movl $0x1, %r12d
xorl %r13d, %r13d
xorl %ecx, %ecx
testq %r12, %r15
setne %cl
leaq 0x126a8(%rip), %rdi     # 0x2d973
movq %r13, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x1cd55
testq %r12, %r15
je 0x1b35b
movq %r13, %rdi
callq *0x70(%r14)
leaq 0x73409(%rip), %rcx     # 0x8e6f4
movb (%rcx), %cl
testq %rax, %rax
je 0x1b30f
testb %cl, %cl
je 0x1b31c
leaq 0x126a2(%rip), %rdi     # 0x2d99f
movq %rbp, %rsi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1a07c
jmp 0x1b354
testb %cl, %cl
je 0x1b331
leaq 0x126ad(%rip), %rdi     # 0x2d9c7
jmp 0x1b338
leaq 0x733cf(%rip), %rcx     # 0x8e6f2
cmpb $0x1, (%rcx)
jne 0x1b340
leaq 0x1268c(%rip), %rdi     # 0x2d9bb
jmp 0x1b347
leaq 0x126ab(%rip), %rdi     # 0x2d9e3
movq %rbp, %rsi
movq %r12, %rdx
jmp 0x1b34d
leaq 0x1267b(%rip), %rdi     # 0x2d9c2
movq %rbp, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1a07c
leaq 0x1796f(%rip), %rbp     # 0x32cca
addq %r12, %r12
incq %r13
cmpq (%rbx), %r13
jb 0x1b2bc
leaq 0x73381(%rip), %rax     # 0x8e6f2
movb (%rax), %al
testb $0x1, %al
je 0x1b3b7
cmpb $0x5b, (%rbp)
jne 0x1b3a9
leaq 0x12665(%rip), %rdi     # 0x2d9e9
jmp 0x1b3b0
leaq 0x73365(%rip), %rax     # 0x8e6f2
cmpb $0x1, (%rax)
jne 0x1b3a0
xorl %esi, %esi
subq 0x8(%rsp), %rsi
callq 0x1a52f
jmp 0x1b3b7
leaq 0xef9d(%rip), %rdi      # 0x2a344
jmp 0x1b3b0
leaq 0x1263a(%rip), %rdi     # 0x2d9ea
xorl %eax, %eax
callq 0x1a07c
movb $0x1, %al
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq