// File: /workspace/github_c_makefile_star2_O2/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 0x196cf
popq %rcx
popq %rdx
testb %al, %al
je 0x19968
xorpd %xmm0, %xmm0
movapd (%rsp), %xmm2
movapd %xmm2, %xmm1
cmpeqsd %xmm0, %xmm1
movsd 0x5b8b(%rip), %xmm3     # 0x1f398
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 0xfb00(%rip), %r8       # 0x29344
cmovneq %rax, %r8
leaq 0x12f7d(%rip), %rdi     # 0x2c7cc
movq %r14, %rsi
movq %r12, %rdx
movb $0x2, %al
callq 0x1bd48
movsd 0x5b34(%rip), %xmm5     # 0x1f398
movapd (%rsp), %xmm0
ucomisd %xmm5, %xmm0
movsd 0x40(%r15), %xmm1
jne 0x198c2
jp 0x198c2
ucomisd 0x5b21(%rip), %xmm1     # 0x1f3a0
jne 0x198c2
jp 0x198c2
leaq 0x12f8d(%rip), %rdi     # 0x2c817
movq %r14, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x1bd48
leaq 0x12f23(%rip), %rdi     # 0x2c7c1
movq %r12, %rsi
xorl %eax, %eax
callq 0x19194
leaq 0x75e43(%rip), %rax     # 0x8f6f2
testq %rbx, %rbx
sete %cl
orb (%rax), %cl
je 0x19957
jmp 0x19968
cvtsi2sd %r12, %xmm0
movsd 0x30(%r15), %xmm2
mulsd %xmm2, %xmm0
movl 0x38(%r15), %esi
testl %esi, %esi
je 0x19927
addsd %xmm1, %xmm0
leaq 0x75e0e(%rip), %rax     # 0x8f6f2
cmpb $0x1, (%rax)
je 0x19917
testq %rbx, %rbx
je 0x19917
cmpb $0x6d, (%rbx)
jne 0x19949
cmpb $0x0, 0x1(%rbx)
jne 0x19949
ucomisd 0x12d87(%rip), %xmm0    # 0x2c688
jb 0x19949
addl $0x3, %esi
divsd 0x12d7a(%rip), %xmm0    # 0x2c688
leaq 0x12f33(%rip), %rdi     # 0x2c848
jmp 0x1991e
leaq 0x12f25(%rip), %rdi     # 0x2c843
movb $0x1, %al
callq 0x19194
jmp 0x19968
xorl %esi, %esi
xorpd %xmm3, %xmm3
movsd 0x12d5b(%rip), %xmm4    # 0x2c690
ucomisd %xmm3, %xmm2
jbe 0x198d9
ucomisd %xmm2, %xmm5
jbe 0x198d9
incl %esi
mulsd %xmm4, %xmm2
jmp 0x19935
leaq 0x12ef3(%rip), %rdi     # 0x2c843
movb $0x1, %al
callq 0x19194
leaq 0x1825f(%rip), %rdi     # 0x31bbd
movq %rbx, %rsi
xorl %eax, %eax
callq 0x19194
movb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq