// File: /workspace/github_c_makefile_star2_O0/canboat[P]canboat/analyzer/print.c
// Function: fieldPrintLookup
extern bool fieldPrintLookup(const Field   *field,
                             const char    *fieldName,
                             const uint8_t *data,
                             size_t         dataLen,
                             size_t         startBit,
                             size_t        *bits)
{
  char        lookfor[20];
  const char *s = NULL;

  int64_t value;
  int64_t maxValue;

  // Can't use extractNumberNotEmpty when the lookup key might use the 'error/unknown' values.
  if (!extractNumber(field, data, dataLen, startBit, *bits, &value, &maxValue))
  {
    return true;
  }

  if (field->unit && field->unit[0] == '=' && isdigit((unsigned char) field->unit[1]))
  {
    sprintf(lookfor, "=%" PRId64, value);
    if (strcmp(lookfor, field->unit) != 0)
    {
      logDebug("Field %s value %" PRId64 " does not match %s\n", fieldName, value, field->unit + 1);
      g_skip = true;
      return false;
    }
    s = field->description;
    if (s == NULL && field->lookup.type == LOOKUP_TYPE_NONE)
    {
      s = lookfor + 1;
    }
  }

  if (s == NULL && field->lookup.type != LOOKUP_TYPE_NONE && value >= 0)
  {
    if (field->lookup.type == LOOKUP_TYPE_PAIR || field->lookup.type == LOOKUP_TYPE_FIELDTYPE)
    {
      s = (*field->lookup.function.pair)((size_t) value);
    }
    else if (field->lookup.type == LOOKUP_TYPE_TRIPLET)
    {
      int64_t val1;

      logDebug("Triplet extraction for field '%s'\n", field->name);

      if (field->pgn != NULL && extractNumberByOrder(field->pgn, field->lookup.val1Order, data, dataLen, &val1))
      {
        s = (*field->lookup.function.triplet)((size_t) val1, (size_t) value);
      }
    }
    // BIT is handled in fieldPrintBitLookup
  }

  if (s != NULL)
  {
    if (showJsonValue)
    {
      mprintf("%" PRId64 ",\"name\":\"%s\"}", value, s);
    }
    else if (showJson)
    {
      mprintf("\"%s\"", s);
    }
    else
    {
      mprintf("%s", s);
    }
  }
  else
  {
    if (*bits > 1 && (value >= maxValue - (*bits > 2 ? 2 : 1)))
    {
      printEmpty(fieldName, value - maxValue);
    }
    else if (showJsonValue)
    {
      mprintf("%" PRId64, value);
      if (showJsonEmpty)
      {
        mprintf(",\"name\":null");
      }
      mprintf("}");
    }
    else if (showJson)
    {
      mprintf("%" PRId64, value);
    }
    else
    {
      mprintf("%" PRId64, value);
    }
  }

  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 $0x0, -0x58(%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 -0x60(%rbp), %r9
leaq -0x68(%rbp), %rax
movq %rax, (%rsp)
callq 0x1b150
testb $0x1, %al
jne 0x1bee0
movb $0x1, -0x1(%rbp)
jmp 0x1c1a6
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x1bfb5
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movsbl (%rax), %eax
cmpl $0x3d, %eax
jne 0x1bfb5
callq 0xd350
movq (%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movzbl 0x1(%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x1bfb5
leaq -0x50(%rbp), %rdi
movq -0x60(%rbp), %rdx
leaq 0x14da8(%rip), %rsi     # 0x30ce3
movb $0x0, %al
callq 0xd2d0
leaq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0xd190
cmpl $0x0, %eax
je 0x1bf8a
movq -0x18(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
addq $0x1, %rcx
leaq 0x14d75(%rip), %rdi     # 0x30ce8
movb $0x0, %al
callq 0x1f670
movb $0x1, 0x7783f(%rip)     # 0x937c0
movb $0x0, -0x1(%rbp)
jmp 0x1c1a6
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x1bfb3
movq -0x10(%rbp), %rax
cmpl $0x0, 0x68(%rax)
jne 0x1bfb3
leaq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x1bfb5
cmpq $0x0, -0x58(%rbp)
jne 0x1c076
movq -0x10(%rbp), %rax
cmpl $0x0, 0x68(%rax)
je 0x1c076
cmpq $0x0, -0x60(%rbp)
jl 0x1c076
movq -0x10(%rbp), %rax
cmpl $0x1, 0x68(%rax)
je 0x1bfed
movq -0x10(%rbp), %rax
cmpl $0x4, 0x68(%rax)
jne 0x1c001
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x60(%rbp), %rdi
callq *%rax
movq %rax, -0x58(%rbp)
jmp 0x1c074
movq -0x10(%rbp), %rax
cmpl $0x2, 0x68(%rax)
jne 0x1c072
movq -0x10(%rbp), %rax
movq (%rax), %rsi
leaq 0x14cf5(%rip), %rdi     # 0x30d0e
movb $0x0, %al
callq 0x1f670
movq -0x10(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0x1c070
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rdi
movq -0x10(%rbp), %rax
movzbl 0x78(%rax), %eax
movl %eax, %esi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
leaq -0x70(%rbp), %r8
callq 0x1b4c0
testb $0x1, %al
jne 0x1c05a
jmp 0x1c070
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x70(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq *%rax
movq %rax, -0x58(%rbp)
jmp 0x1c072
jmp 0x1c074
jmp 0x1c076
cmpq $0x0, -0x58(%rbp)
je 0x1c0da
leaq 0x755f0(%rip), %rax     # 0x91674
testb $0x1, (%rax)
je 0x1c0a1
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
leaq 0x14d6a(%rip), %rdi     # 0x30e02
movb $0x0, %al
callq 0x1ade0
jmp 0x1c0d5
leaq 0x755ca(%rip), %rax     # 0x91672
testb $0x1, (%rax)
je 0x1c0c1
movq -0x58(%rbp), %rsi
leaq 0x14d5d(%rip), %rdi     # 0x30e15
movb $0x0, %al
callq 0x1ade0
jmp 0x1c0d3
movq -0x58(%rbp), %rsi
leaq 0x19f40(%rip), %rdi     # 0x3600c
movb $0x0, %al
callq 0x1ade0
jmp 0x1c0d5
jmp 0x1c1a2
movq -0x38(%rbp), %rax
cmpq $0x1, (%rax)
jbe 0x1c122
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rcx
movq -0x38(%rbp), %rdx
movq (%rdx), %rdi
movl $0x1, %edx
movl $0x2, %esi
cmpq $0x2, %rdi
cmoval %esi, %edx
movslq %edx, %rdx
subq %rdx, %rcx
cmpq %rcx, %rax
jl 0x1c122
movq -0x18(%rbp), %rdi
movq -0x60(%rbp), %rsi
subq -0x68(%rbp), %rsi
callq 0x1b5f0
jmp 0x1c1a0
leaq 0x7554b(%rip), %rax     # 0x91674
testb $0x1, (%rax)
je 0x1c16a
movq -0x60(%rbp), %rsi
leaq 0x14ae0(%rip), %rdi     # 0x30c19
movb $0x0, %al
callq 0x1ade0
leaq 0x7552c(%rip), %rax     # 0x91673
testb $0x1, (%rax)
je 0x1c15a
leaq 0x14bde(%rip), %rdi     # 0x30d31
movb $0x0, %al
callq 0x1ade0
leaq 0x14cb0(%rip), %rdi     # 0x30e11
movb $0x0, %al
callq 0x1ade0
jmp 0x1c19e
leaq 0x75501(%rip), %rax     # 0x91672
testb $0x1, (%rax)
je 0x1c18a
movq -0x60(%rbp), %rsi
leaq 0x14a98(%rip), %rdi     # 0x30c19
movb $0x0, %al
callq 0x1ade0
jmp 0x1c19c
movq -0x60(%rbp), %rsi
leaq 0x14a84(%rip), %rdi     # 0x30c19
movb $0x0, %al
callq 0x1ade0
jmp 0x1c19e
jmp 0x1c1a0
jmp 0x1c1a2
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)