// File: /workspace/github_c_makefile_star2_O1/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 0x171f3(%rip), %rsi     # 0x3ac7c
movq %rbx, %rdi
callq 0xd330
movq %rax, 0x8(%rsp)
movq (%r12), %rcx
leaq 0x171e1(%rip), %rdi     # 0x3ac82
movq %rbx, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x254dd
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 0x22c61
addq $0x10, %rsp
testb %al, %al
je 0x23cb3
movq 0x18(%rsp), %r14
movq %r14, %r12
negq %r12
cmovsq %r14, %r12
leaq 0x77c03(%rip), %r13     # 0x9b6f8
cmpl $0x0, (%r13)
je 0x23ba3
leaq 0x77bed(%rip), %rbx     # 0x9b6f4
cmpb $0x1, (%rbx)
jne 0x23b1d
leaq 0x1723e(%rip), %rdi     # 0x3ad51
movq %r14, %rsi
xorl %eax, %eax
callq 0x226ec
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 0x16dd5(%rip), %xmm0    # 0x3a920
mulsd %xmm2, %xmm0
cmpl $0x1, %ebp
jne 0x23bc1
leaq 0x77b97(%rip), %rax     # 0x9b6f2
leaq 0x17158(%rip), %rcx     # 0x3acba
cmpb $0x0, (%rax)
leaq 0x17163(%rip), %rdi     # 0x3accf
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 0x226ec
jmp 0x23ca0
cvtsi2sd %r14, %xmm0
mulsd 0x30(%r15), %xmm0
leaq 0x170fe(%rip), %rdi     # 0x3acb3
movb $0x1, %al
callq 0x226ec
jmp 0x23cb3
movsd %xmm1, 0x10(%rsp)
movsd %xmm2, (%rsp)
callq 0xd2b0
movsd (%rsp), %xmm6
movsd 0x10(%rsp), %xmm5
movsd 0x16d44(%rip), %xmm1    # 0x3a928
mulsd %xmm0, %xmm1
mulsd 0x16d40(%rip), %xmm6    # 0x3a930
addsd %xmm1, %xmm6
movsd 0x479c(%rip), %xmm4     # 0x28398
movsd 0x16d34(%rip), %xmm3    # 0x3a938
movapd %xmm3, %xmm1
cmpnlesd %xmm6, %xmm1
movapd %xmm1, %xmm2
andpd %xmm0, %xmm1
addsd %xmm4, %xmm0
andnpd %xmm0, %xmm2
orpd %xmm2, %xmm1
movsd 0x16cf7(%rip), %xmm2    # 0x3a920
ucomisd %xmm2, %xmm1
jb 0x23c33
addsd %xmm4, %xmm5
movapd %xmm6, %xmm0
jb 0x23c3d
xorpd %xmm0, %xmm0
ucomisd %xmm3, %xmm6
jb 0x23c47
xorpd %xmm0, %xmm0
leaq 0x77aa4(%rip), %rax     # 0x9b6f2
leaq 0x17089(%rip), %rcx     # 0x3acde
cmpb $0x0, (%rax)
leaq 0x170a5(%rip), %rdi     # 0x3ad04
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 0x226ec
cmpb $0x1, (%rbx)
jne 0x23cb3
leaq 0x16f9d(%rip), %rdi     # 0x3ac49
xorl %eax, %eax
callq 0x226ec
movb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq