// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0xc0, %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), %rax
movq 0x18(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movsd 0x30(%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x60(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1b95a
jp 0x1b95a
movsd 0x8a43(%rip), %xmm0     # 0x24398
movsd %xmm0, -0x60(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
movq -0x38(%rbp), %rax
movq (%rax), %r9
leaq -0x40(%rbp), %r10
leaq -0x48(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x1b770
testb $0x1, %al
jne 0x1b998
movb $0x1, -0x1(%rbp)
jmp 0x1bbfc
movq -0x18(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x88(%rbp)
movsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0x10(%rbp), %rax
movsd 0x40(%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x1b9ed
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xa0(%rbp)
jmp 0x1b9fd
leaq 0x11e0d(%rip), %rax     # 0x2d801
movq %rax, -0xa0(%rbp)
jmp 0x1b9fd
movsd -0x78(%rbp), %xmm1
movsd -0x80(%rbp), %xmm0
movq -0x88(%rbp), %rcx
movq -0x90(%rbp), %rdx
movq -0x98(%rbp), %rsi
movq -0xa0(%rbp), %r8
leaq 0x151fa(%rip), %rdi     # 0x30c24
movb $0x2, %al
callq 0x1f670
movsd -0x60(%rbp), %xmm0
movsd 0x895a(%rip), %xmm1     # 0x24398
ucomisd %xmm1, %xmm0
jne 0x1baac
jp 0x1baac
movq -0x10(%rbp), %rax
movsd 0x40(%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1baac
jp 0x1baac
movq -0x18(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq 0x15206(%rip), %rdi     # 0x30c6f
movb $0x0, %al
callq 0x1f670
movq -0x40(%rbp), %rsi
leaq 0x1519e(%rip), %rdi     # 0x30c19
movb $0x0, %al
callq 0x1ade0
leaq 0x75be9(%rip), %rax     # 0x91672
testb $0x1, (%rax)
jne 0x1baa7
cmpq $0x0, -0x58(%rbp)
je 0x1baa7
movq -0x58(%rbp), %rsi
leaq 0x1a56b(%rip), %rdi     # 0x3600b
movb $0x0, %al
callq 0x1ade0
jmp 0x1bbf8
cvtsi2sdq -0x40(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd 0x30(%rax), %xmm2
movq -0x10(%rbp), %rax
movsd 0x40(%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x10(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, -0x64(%rbp)
cmpl $0x0, -0x64(%rbp)
jne 0x1bb46
movq -0x10(%rbp), %rax
movsd 0x30(%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x70(%rbp), %xmm0
xorl %eax, %eax
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movb %al, -0xa1(%rbp)
jbe 0x1bb1b
movsd 0x888b(%rip), %xmm0     # 0x24398
ucomisd -0x70(%rbp), %xmm0
seta %al
movb %al, -0xa1(%rbp)
movb -0xa1(%rbp), %al
testb $0x1, %al
jne 0x1bb27
jmp 0x1bb44
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
movsd 0x14fd8(%rip), %xmm0    # 0x30b10
mulsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
jmp 0x1baef
jmp 0x1bb46
leaq 0x75b25(%rip), %rax     # 0x91672
testb $0x1, (%rax)
je 0x1bb6d
movl -0x64(%rbp), %esi
movsd -0x50(%rbp), %xmm0
leaq 0x1513a(%rip), %rdi     # 0x30c9b
movb $0x1, %al
callq 0x1ade0
jmp 0x1bbf6
cmpq $0x0, -0x58(%rbp)
je 0x1bbc3
movq -0x58(%rbp), %rdi
leaq 0x16a9f(%rip), %rsi     # 0x3261e
callq 0xd190
cmpl $0x0, %eax
jne 0x1bbc3
movsd -0x50(%rbp), %xmm0
movsd 0x14f72(%rip), %xmm1    # 0x30b08
ucomisd %xmm1, %xmm0
jb 0x1bbc3
movl -0x64(%rbp), %esi
addl $0x3, %esi
movsd -0x50(%rbp), %xmm0
movsd 0x14f59(%rip), %xmm1    # 0x30b08
divsd %xmm1, %xmm0
leaq 0x150e6(%rip), %rdi     # 0x30ca0
movb $0x1, %al
callq 0x1ade0
jmp 0x1bbf4
movl -0x64(%rbp), %esi
movsd -0x50(%rbp), %xmm0
leaq 0x150c9(%rip), %rdi     # 0x30c9b
movb $0x1, %al
callq 0x1ade0
cmpq $0x0, -0x58(%rbp)
je 0x1bbf2
movq -0x58(%rbp), %rsi
leaq 0x1a420(%rip), %rdi     # 0x3600b
movb $0x0, %al
callq 0x1ade0
jmp 0x1bbf4
jmp 0x1bbf6
jmp 0x1bbf8
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xc0, %rsp
popq %rbp
retq
nopw (%rax,%rax)