// File: /workspace/github_c_makefile_star2_O3/canboat[P]canboat/analyzer/analyzer.c
// Function: showBytesOrBits
static void showBytesOrBits(const uint8_t *data, size_t startBit, size_t bits)
{
  int64_t     value;
  int64_t     maxValue;
  size_t      i;
  size_t      remaining_bits;
  const char *s;
  uint8_t     byte;

  logDebug("showBytesOrBits(%p, %zu, %zu)\n", data, startBit, bits);

  if (showJson)
  {
    size_t location = mlocation();

    if (location == 0 || mchr(location - 1) != '{')
    {
      mprintf(",");
    }
    mprintf("\"bytes\":\"");
  }
  else
  {
    mprintf(" (bytes = \"");
  }
  remaining_bits = bits;
  s              = "";
  for (i = 0; i < (bits + 7) >> 3; i++)
  {
    uint8_t byte = data[i];

    if (i == 0 && startBit != 0)
    {
      byte = byte >> startBit; // Shift off older bits
      if (remaining_bits + startBit < 8)
      {
        byte = byte & ((1 << remaining_bits) - 1);
      }
      byte = byte << startBit; // Shift zeros back in
      remaining_bits -= (8 - startBit);
    }
    else
    {
      if (remaining_bits < 8)
      {
        // only the lower remaining_bits should be used
        byte = byte & ((1 << remaining_bits) - 1);
      }
      remaining_bits -= 8;
    }
    mprintf("%s%2.02X", s, byte);
    s = " ";
  }
  mprintf("\"");

  if (startBit != 0 || ((bits & 7) != 0))
  {
    extractNumber(NULL, data, (bits + 7) >> 3, startBit, bits, &value, &maxValue);
    if (showJson)
    {
      mprintf(",\"bits\":\"");
    }
    else
    {
      mprintf(", bits = \"");
    }

    for (i = bits; i > 0;)
    {
      i--;
      byte = (value >> (i >> 3)) & 0xff;
      mprintf("%c", (byte & (1 << (i & 7))) ? '1' : '0');
    }
    mprintf("\"");
  }

  if (!showJson)
  {
    mprintf(")");
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0xf851(%rip), %rdi      # 0x1f112
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1990d
cmpb $0x1, 0x789f0(%rip)     # 0x882c8
jne 0xf90a
callq 0x16da9
testq %rax, %rax
je 0xf8f3
decq %rax
movq %rax, %rdi
callq 0x16cf2
cmpb $0x7b, %al
je 0xf901
leaq 0x1ef58(%rip), %rdi     # 0x2e852
xorl %eax, %eax
callq 0x16c1c
leaq 0xf829(%rip), %rdi      # 0x1f131
jmp 0xf911
leaq 0xf82a(%rip), %rdi      # 0x1f13b
xorl %eax, %eax
callq 0x16c1c
leaq 0x7(%rbx), %rax
movq %rax, %r12
shrq $0x3, %r12
cmpq $0x8, %rax
jb 0xf9c8
leaq -0x8(%r14), %rax
movq %rax, 0x10(%rsp)
leaq 0xed2c(%rip), %rsi      # 0x1e669
xorl %r13d, %r13d
movq %rbx, %rbp
testq %r14, %r14
sete %cl
movzbl (%r15,%r13), %eax
testq %r13, %r13
setne %dl
orb %cl, %dl
jne 0xf986
movl %r14d, %ecx
shrl %cl, %eax
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %ebp, %ecx
shll %cl, %edx
leaq (%r14,%rbp), %rcx
cmpq $0x8, %rcx
notl %edx
movl $0xff, %ecx
cmovael %ecx, %edx
andl %eax, %edx
movl %r14d, %ecx
shll %cl, %edx
addq 0x10(%rsp), %rbp
jmp 0xf9a4
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %ebp, %ecx
shll %cl, %edx
subq $0x8, %rbp
notb %dl
movzbl %dl, %ecx
movl $0xff, %edx
cmovael %edx, %ecx
andl %ecx, %eax
movl %eax, %edx
movzbl %dl, %edx
leaq 0xf799(%rip), %rdi      # 0x1f147
xorl %eax, %eax
callq 0x16c1c
incq %r13
leaq 0xf10c(%rip), %rsi      # 0x1eacb
cmpq %r13, %r12
jne 0xf943
leaq 0xf776(%rip), %rdi      # 0x1f145
xorl %eax, %eax
callq 0x16c1c
movl %ebx, %eax
andl $0x7, %eax
orq %r14, %rax
je 0xfa6e
leaq 0x20(%rsp), %rax
movq %rax, (%rsp)
leaq 0x18(%rsp), %r9
xorl %edi, %edi
movq %r15, %rsi
movq %r12, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x16e67
leaq 0xf744(%rip), %rax      # 0x1f150
leaq 0xf747(%rip), %rdi      # 0x1f15a
cmpb $0x0, 0x788ae(%rip)     # 0x882c8
cmovneq %rax, %rdi
xorl %eax, %eax
callq 0x16c1c
testq %rbx, %rbx
je 0xfa60
leaq 0xed7d(%rip), %r14      # 0x1e7ae
decq %rbx
movq 0x18(%rsp), %rax
movl %ebx, %ecx
shrl $0x3, %ecx
sarq %cl, %rax
movl %ebx, %ecx
andl $0x7, %ecx
btl %ecx, %eax
movl $0x0, %esi
adcl $0x30, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x16c1c
testq %rbx, %rbx
jne 0xfa31
leaq 0xf6de(%rip), %rdi      # 0x1f145
xorl %eax, %eax
callq 0x16c1c
cmpb $0x0, 0x78853(%rip)     # 0x882c8
jne 0xfa85
leaq 0x1c2ee(%rip), %rdi     # 0x2bd6c
xorl %eax, %eax
callq 0x16c1c
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq