// File: /workspace/github_c_makefile_star2_O0/canboat[P]canboat/analyzer/print.c
// Function: printString
static bool printString(const char *fieldName, const uint8_t *data, size_t len)
{
  const uint8_t *p;

  if (len > 0)
  {
    // find the first zero byte (Raymarine does this, followed by junk)
    for (p = data; p < data + len - 1; p++)
    {
      if (*p == '\0')
      {
        logDebug("printString: shorten len from %zu to %zu (C string seen)\n", len, p - data);
        len = p - data;
        p--;
        break;
        // still do the next part, maybe they have @ or spaces at the end still?
      }
    }
    // rtrim funny stuff from end, we see all sorts. 0xff is believed to be the correct
    // content according to NMEA 2000. '@' originates from badly converted NMEA AIS data.
    // Space is just to avoid funny strings, 0 looks like incorrect C data.
    while (len > 0 && (*p == 0xff || isspace((unsigned char) *p) || *p == 0 || *p == '@'))
    {
      len--;
      p--;
    }
  }

  if (len == 0)
  {
    printEmpty(fieldName, DATAFIELD_UNKNOWN);
    return true;
  }

  if (showJson)
  {
    mprintf("\"");
    print_ascii_json_escaped(data, len);
    mprintf("\"");
  }
  else
  {
    print_ascii_json_escaped(data, len);
  }

  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jbe 0x1d639
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
addq -0x20(%rbp), %rcx
addq $-0x1, %rcx
cmpq %rcx, %rax
jae 0x1d5a2
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x1d592
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x18(%rbp), %rax
subq %rax, %rdx
leaq 0x13c91(%rip), %rdi     # 0x311ff
movb $0x0, %al
callq 0x1f670
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x1d5a2
jmp 0x1d594
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x1d537
jmp 0x1d5a4
xorl %eax, %eax
cmpq $0x0, -0x20(%rbp)
movb %al, -0x29(%rbp)
jbe 0x1d611
movq -0x28(%rbp), %rax
movzbl (%rax), %ecx
movb $0x1, %al
cmpl $0xff, %ecx
movb %al, -0x2a(%rbp)
je 0x1d60b
callq 0xd350
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movzbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %ecx
andl $0x2000, %ecx           # imm = 0x2000
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x2a(%rbp)
jne 0x1d60b
movq -0x28(%rbp), %rax
movzbl (%rax), %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x2a(%rbp)
je 0x1d60b
movq -0x28(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x40, %eax
sete %al
movb %al, -0x2a(%rbp)
movb -0x2a(%rbp), %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
testb $0x1, %al
jne 0x1d61a
jmp 0x1d637
movq -0x20(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x1d5a4
jmp 0x1d639
cmpq $0x0, -0x20(%rbp)
jne 0x1d653
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1b5f0
movb $0x1, -0x1(%rbp)
jmp 0x1d69f
leaq 0x74018(%rip), %rax     # 0x91672
testb $0x1, (%rax)
je 0x1d68c
leaq 0x13be3(%rip), %rdi     # 0x31249
movb $0x0, %al
callq 0x1ade0
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %esi
callq 0x1db50
leaq 0x13bc6(%rip), %rdi     # 0x31249
movb $0x0, %al
callq 0x1ade0
jmp 0x1d69b
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %esi
callq 0x1db50
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)