// File: /workspace/github_c_makefile_star2_O3/canboat[P]canboat/analyzer/print.c
// Function: fieldPrintLatLon
extern bool fieldPrintLatLon(const Field   *field,
                             const char    *fieldName,
                             const uint8_t *data,
                             size_t         dataLen,
                             size_t         startBit,
                             size_t        *bits)
{
  uint64_t absVal;
  int64_t  value;
  int64_t  maxValue;
  bool     isLongitude = (strstr(fieldName, "ongit") != NULL);
  double   dd;
  double   degrees;
  double   remainder;
  double   minutes;
  double   seconds;

  logDebug("fieldPrintLatLon for '%s' startbit=%zu bits=%zu\n", fieldName, startBit, *bits);

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

  absVal = (value < 0) ? -value : value;
  dd     = (double) value * field->resolution;

  if (showGeo == GEO_DD)
  {
    mprintf("%10.7f", dd);
  }
  else
  {
    if (showJsonValue)
    {
      mprintf("%" PRId64 ",\"name\":", value);
    }
    if (showGeo == GEO_DM)
    {
      dd        = (double) absVal * field->resolution;
      degrees   = floor(dd);
      remainder = dd - degrees;
      minutes   = remainder * 60.;

      mprintf((showJson ? "\"%02u&deg; %6.3f %c\"" : "%02ud %6.3f %c"),
              (uint32_t) degrees,
              minutes,
              (isLongitude ? ((value >= 0) ? 'E' : 'W') : ((value >= 0) ? 'N' : 'S')));
    }
    else
    {
      dd        = (double) absVal * field->resolution;
      degrees   = floor(dd);
      remainder = dd - degrees;
      minutes   = floor(remainder * 60.);
      seconds   = (remainder * 3600.) - 60. * minutes;

      if (seconds >= 59.9995)
      {
        minutes += 1.0;
        seconds = 0.0;
      }
      if (minutes >= 60.0)
      {
        degrees += 1.0;
        minutes = 0.0;
        seconds = 0.0;
      }

      mprintf((showJson ? "\"%02u&deg;%02u&rsquo;%06.3f&rdquo;%c\"" : "%02ud %02u' %06.3f\"%c"),
              (int) degrees,
              (int) minutes,
              seconds,
              (isLongitude ? ((value >= 0) ? 'E' : 'W') : ((value >= 0) ? 'N' : 'S')));
    }
    if (showJsonValue)
    {
      mprintf("}");
    }
  }
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r12
movq %r8, %r14
movq %rcx, %r13
movq %rdx, %rbp
movq %rsi, %rbx
movq %rdi, %r15
leaq 0x125fd(%rip), %rsi     # 0x2d9ec
movq %rbx, %rdi
callq 0xd330
movq %rax, 0x8(%rsp)
movq (%r12), %rcx
leaq 0x125eb(%rip), %rdi     # 0x2d9f2
movq %rbx, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1cd55
movq (%r12), %r9
leaq 0x20(%rsp), %rax
leaq 0x18(%rsp), %r10
movq %r15, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq %r13, %rcx
movq %r14, %r8
pushq %rax
pushq %r10
callq 0x1a5ec
addq $0x10, %rsp
testb %al, %al
je 0x1b61a
movq 0x18(%rsp), %r14
movq %r14, %r12
negq %r12
cmovsq %r14, %r12
leaq 0x7329d(%rip), %r13     # 0x8e6f8
movl (%r13), %ebp
testl %ebp, %ebp
je 0x1b50a
leaq 0x73286(%rip), %rbx     # 0x8e6f4
cmpb $0x1, (%rbx)
jne 0x1b488
leaq 0x12647(%rip), %rdi     # 0x2dac1
movq %r14, %rsi
xorl %eax, %eax
callq 0x1a07c
movl (%r13), %ebp
cvtsi2sd %r12, %xmm0
mulsd 0x30(%r15), %xmm0
movsd %xmm0, (%rsp)
callq 0xd2b0
movsd (%rsp), %xmm2
movapd %xmm0, %xmm1
subsd %xmm0, %xmm2
movsd 0x121e6(%rip), %xmm0    # 0x2d698
mulsd %xmm2, %xmm0
cmpl $0x1, %ebp
jne 0x1b528
leaq 0x73230(%rip), %rax     # 0x8e6f2
leaq 0x12561(%rip), %rcx     # 0x2da2a
cmpb $0x0, (%rax)
leaq 0x1256c(%rip), %rdi     # 0x2da3f
cmovneq %rcx, %rdi
testq %r14, %r14
movl $0x45, %eax
movl $0x57, %ecx
cmovnsl %eax, %ecx
shrq $0x3f, %r14
cvttsd2si %xmm1, %rsi
cmpq $0x0, 0x8(%rsp)
leal 0x4e(%r14,%r14,4), %edx
cmovnel %ecx, %edx
movb $0x1, %al
callq 0x1a07c
jmp 0x1b607
cvtsi2sd %r14, %xmm0
mulsd 0x30(%r15), %xmm0
leaq 0x12507(%rip), %rdi     # 0x2da23
movb $0x1, %al
callq 0x1a07c
jmp 0x1b61a
movsd %xmm1, 0x10(%rsp)
movsd %xmm2, (%rsp)
callq 0xd2b0
movsd (%rsp), %xmm6
movsd 0x10(%rsp), %xmm5
movsd 0x12155(%rip), %xmm1    # 0x2d6a0
mulsd %xmm0, %xmm1
mulsd 0x12151(%rip), %xmm6    # 0x2d6a8
addsd %xmm1, %xmm6
movsd 0x4e35(%rip), %xmm4     # 0x20398
movsd 0x12145(%rip), %xmm3    # 0x2d6b0
movapd %xmm3, %xmm1
cmpnlesd %xmm6, %xmm1
movapd %xmm1, %xmm2
andpd %xmm0, %xmm1
addsd %xmm4, %xmm0
andnpd %xmm0, %xmm2
orpd %xmm2, %xmm1
movsd 0x12108(%rip), %xmm2    # 0x2d698
ucomisd %xmm2, %xmm1
jb 0x1b59a
addsd %xmm4, %xmm5
movapd %xmm6, %xmm0
jb 0x1b5a4
xorpd %xmm0, %xmm0
ucomisd %xmm3, %xmm6
jb 0x1b5ae
xorpd %xmm0, %xmm0
leaq 0x7313d(%rip), %rax     # 0x8e6f2
leaq 0x12492(%rip), %rcx     # 0x2da4e
cmpb $0x0, (%rax)
leaq 0x124ae(%rip), %rdi     # 0x2da74
cmovneq %rcx, %rdi
testq %r14, %r14
movl $0x45, %eax
movl $0x57, %r8d
cmovnsl %eax, %r8d
shrq $0x3f, %r14
cmpnlesd %xmm1, %xmm2
andpd %xmm1, %xmm2
cvttsd2si %xmm5, %esi
cvttsd2si %xmm2, %edx
cmpq $0x0, 0x8(%rsp)
leal 0x4e(%r14,%r14,4), %ecx
cmovnel %r8d, %ecx
movb $0x1, %al
callq 0x1a07c
cmpb $0x1, (%rbx)
jne 0x1b61a
leaq 0x123a6(%rip), %rdi     # 0x2d9b9
xorl %eax, %eax
callq 0x1a07c
movb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq