// File: /workspace/github_c_makefile_star2_O3/canboat[P]canboat/analyzer/print.c
// Function: fieldPrintNumber
extern bool fieldPrintNumber(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;
  double  a;

  const char *unit       = field->unit;
  double      resolution = field->resolution;

  if (resolution == 0.0)
  {
    resolution = 1.0;
  }

  if (!extractNumberNotEmpty(field, fieldName, data, dataLen, startBit, *bits, &value, &maxValue))
  {
    return true;
  }

  logDebug("fieldPrintNumber <%s> value=%" PRIx64 " max=%" PRIx64 " resolution=%g offset=%g unit='%s'\n",
           fieldName,
           value,
           maxValue,
           resolution,
           field->unitOffset,
           (field->unit ? field->unit : "None"));
  if (resolution == 1.0 && field->unitOffset == 0.0)
  {
    logDebug("fieldPrintNumber <%s> print as integer %" PRId64 "\n", fieldName, value);
    mprintf("%" PRId64, value);
    if (!showJson && unit != NULL)
    {
      mprintf(" %s", unit);
    }
  }
  else
  {
    int    precision;
    double r;

    a = (double) value * field->resolution + field->unitOffset;

    precision = field->precision;
    if (precision == 0)
    {
      for (r = field->resolution; (r > 0.0) && (r < 1.0); r *= 10.0)
      {
        precision++;
      }
    }

    if (showJson)
    {
      mprintf("%.*f", precision, a);
    }
    else if (unit != NULL && strcmp(unit, "m") == 0 && a >= 1000.0)
    {
      mprintf("%.*f km", precision + 3, a / 1000);
    }
    else
    {
      mprintf("%.*f", precision, a);
      if (unit != NULL)
      {
        mprintf(" %s", unit);
      }
    }
  }

  return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %r15
movq 0x18(%rdi), %rbx
movsd 0x30(%rdi), %xmm0
movapd %xmm0, (%rsp)
movq (%r9), %r9
leaq 0x18(%rsp), %rax
leaq 0x20(%rsp), %r10
pushq %rax
pushq %r10
callq 0x1a5ec
addq $0x10, %rsp
testb %al, %al
je 0x1a8a2
xorpd %xmm0, %xmm0
movapd (%rsp), %xmm2
movapd %xmm2, %xmm1
cmpeqsd %xmm0, %xmm1
movsd 0x5c69(%rip), %xmm3     # 0x20398
movapd %xmm1, %xmm0
andpd %xmm3, %xmm0
andnpd %xmm2, %xmm1
orpd %xmm0, %xmm1
movapd %xmm1, %xmm0
movapd %xmm1, (%rsp)
movq 0x20(%rsp), %r12
movq 0x18(%rsp), %rcx
movsd 0x40(%r15), %xmm1
movq 0x18(%r15), %rax
testq %rax, %rax
leaq 0xfbde(%rip), %r8       # 0x2a344
cmovneq %rax, %r8
leaq 0x1305b(%rip), %rdi     # 0x2d7cc
movq %r14, %rsi
movq %r12, %rdx
movb $0x2, %al
callq 0x1cd55
movsd 0x5c12(%rip), %xmm5     # 0x20398
movapd (%rsp), %xmm0
ucomisd %xmm5, %xmm0
movsd 0x40(%r15), %xmm1
jne 0x1a7e4
jp 0x1a7e4
ucomisd 0x5bff(%rip), %xmm1     # 0x203a0
jne 0x1a7e4
jp 0x1a7e4
leaq 0x1306b(%rip), %rdi     # 0x2d817
movq %r14, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x1cd55
leaq 0x13001(%rip), %rdi     # 0x2d7c1
movq %r12, %rsi
xorl %eax, %eax
callq 0x1a07c
leaq 0x73f21(%rip), %rax     # 0x8e6f2
testq %rbx, %rbx
sete %cl
orb (%rax), %cl
je 0x1a891
jmp 0x1a8a2
xorps %xmm0, %xmm0
cvtsi2sd %r12, %xmm0
movsd 0x30(%r15), %xmm2
mulsd %xmm2, %xmm0
movl 0x38(%r15), %esi
testl %esi, %esi
je 0x1a84c
addsd %xmm1, %xmm0
leaq 0x73ee9(%rip), %rax     # 0x8e6f2
cmpb $0x1, (%rax)
je 0x1a83c
testq %rbx, %rbx
je 0x1a83c
cmpb $0x6d, (%rbx)
jne 0x1a883
cmpb $0x0, 0x1(%rbx)
jne 0x1a883
ucomisd 0x12e6a(%rip), %xmm0    # 0x2d690
jb 0x1a883
addl $0x3, %esi
divsd 0x12e5d(%rip), %xmm0    # 0x2d690
leaq 0x1300e(%rip), %rdi     # 0x2d848
jmp 0x1a843
leaq 0x13000(%rip), %rdi     # 0x2d843
movb $0x1, %al
callq 0x1a07c
jmp 0x1a8a2
xorl %esi, %esi
xorpd %xmm3, %xmm3
ucomisd %xmm3, %xmm2
jbe 0x1a7fe
ucomisd %xmm2, %xmm5
jbe 0x1a7fe
xorl %esi, %esi
movsd 0x12e20(%rip), %xmm3    # 0x2d688
xorpd %xmm4, %xmm4
incl %esi
mulsd %xmm3, %xmm2
ucomisd %xmm4, %xmm2
jbe 0x1a7fe
ucomisd %xmm2, %xmm5
ja 0x1a86c
jmp 0x1a7fe
leaq 0x12fb9(%rip), %rdi     # 0x2d843
movb $0x1, %al
callq 0x1a07c
leaq 0x18325(%rip), %rdi     # 0x32bbd
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1a07c
movb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq