// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rax
movq (%rax), %r8
leaq -0x40(%rbp), %r9
leaq -0x48(%rbp), %rax
movq %rax, (%rsp)
callq 0x1b150
testb $0x1, %al
jne 0x1c928
movb $0x1, -0x1(%rbp)
jmp 0x1cb3a
cmpq $0x0, -0x40(%rbp)
jne 0x1c965
leaq 0x74d3c(%rip), %rax     # 0x91672
testb $0x1, (%rax)
je 0x1c94e
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rsi
subq -0x48(%rbp), %rsi
callq 0x1b5f0
jmp 0x1c95c
leaq 0x10eac(%rip), %rdi     # 0x2d801
movb $0x0, %al
callq 0x1ade0
movb $0x1, -0x1(%rbp)
jmp 0x1cb3a
movq -0x38(%rbp), %rax
movq (%rax), %rsi
movq -0x40(%rbp), %rdx
leaq 0x14432(%rip), %rdi     # 0x30da9
movb $0x0, %al
callq 0x1f670
leaq 0x74cef(%rip), %rax     # 0x91674
testb $0x1, (%rax)
je 0x1c997
leaq 0x1440d(%rip), %rax     # 0x30d9e
movq %rax, -0x60(%rbp)
jmp 0x1c9bd
leaq 0x74cd4(%rip), %rax     # 0x91672
testb $0x1, (%rax)
je 0x1c9b0
leaq 0x143f4(%rip), %rax     # 0x30d9e
movq %rax, -0x60(%rbp)
jmp 0x1c9bb
leaq 0xaf9e(%rip), %rax      # 0x27955
movq %rax, -0x60(%rbp)
jmp 0x1c9bd
movq $0x1, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq -0x38(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x1cafe
movq -0x40(%rbp), %rax
andq -0x50(%rbp), %rax
cmpq $0x0, %rax
setne %al
andb $0x1, %al
movb %al, -0x61(%rbp)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movb -0x61(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
leaq 0x143c2(%rip), %rdi     # 0x30dcb
movb $0x0, %al
callq 0x1f670
testb $0x1, -0x61(%rbp)
je 0x1cae0
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x58(%rbp), %rdi
callq *%rax
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0x1ca99
leaq 0x74c3a(%rip), %rax     # 0x91674
testb $0x1, (%rax)
je 0x1ca5b
movq -0x60(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x70(%rbp), %rcx
leaq 0x143a5(%rip), %rdi     # 0x30df7
movb $0x0, %al
callq 0x1ade0
jmp 0x1ca97
leaq 0x74c10(%rip), %rax     # 0x91672
testb $0x1, (%rax)
je 0x1ca7f
movq -0x60(%rbp), %rsi
movq -0x70(%rbp), %rdx
leaq 0x1439d(%rip), %rdi     # 0x30e13
movb $0x0, %al
callq 0x1ade0
jmp 0x1ca95
movq -0x60(%rbp), %rsi
movq -0x70(%rbp), %rdx
leaq 0x1438c(%rip), %rdi     # 0x30e1a
movb $0x0, %al
callq 0x1ade0
jmp 0x1ca97
jmp 0x1cad5
leaq 0x74bd4(%rip), %rax     # 0x91674
testb $0x1, (%rax)
je 0x1cabd
movq -0x60(%rbp), %rsi
movq -0x50(%rbp), %rdx
leaq 0x1436b(%rip), %rdi     # 0x30e1f
movb $0x0, %al
callq 0x1ade0
jmp 0x1cad3
movq -0x60(%rbp), %rsi
movq -0x50(%rbp), %rdx
leaq 0x1436f(%rip), %rdi     # 0x30e3b
movb $0x0, %al
callq 0x1ade0
jmp 0x1cad5
leaq 0x1963c(%rip), %rax     # 0x36118
movq %rax, -0x60(%rbp)
jmp 0x1cae2
movq -0x50(%rbp), %rax
shlq %rax
movq %rax, -0x50(%rbp)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x1c9cd
leaq 0x74b6d(%rip), %rax     # 0x91672
testb $0x1, (%rax)
je 0x1cb36
movq -0x60(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5b, %eax
je 0x1cb26
leaq 0x14325(%rip), %rdi     # 0x30e42
movb $0x0, %al
callq 0x1ade0
jmp 0x1cb34
leaq 0x14314(%rip), %rdi     # 0x30e41
movb $0x0, %al
callq 0x1ade0
jmp 0x1cb36
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)