// File: /workspace/github_c_makefile_star2_O0/canboat[P]canboat/nmea0183/../common/common.c
// Function: getJSONValue
bool getJSONValue(const char *message, const char *fieldName, char *value, size_t len)
{
  const char *loc      = message + 1;
  size_t      fieldLen = strlen(fieldName);

  for (;;)
  {
    loc = strstr(loc, fieldName);
    if (!loc)
    {
      logDebug("getJSONValue('%s','%s',...) => name not found\n", message, fieldName);
      return false;
    }
    if (loc[-1] == '"' && loc[fieldLen] == '"' && loc[fieldLen + 1] == ':')
    {
      break;
    }
    loc += fieldLen;
  }

  /* field has been found */
  loc += fieldLen + 2;

  while (isspace((unsigned char) *loc))
  {
    loc++;
  }

  if (*loc == '{')
  {
    /* It is a nested value like "field" : {"value":0,"name":"Under way using engine"} */
    return getJSONLookupValue(message, fieldName, value, len);
  }

  if (strncmp(loc, "null", 4) == 0)
  {
    logDebug("getJSONValue('%s','%s',...) => value null\n", message, fieldName);
    return false;
  }

  if (*loc != '"')
  {
    while ((isdigit((unsigned char) *loc) || *loc == '.' || *loc == '-' || *loc == 'E' || *loc == 'e' || *loc == '+') && len > 1)
    {
      *value++ = *loc++;
      len--;
    }
    *value = 0;
    logDebug("getJSONValue('%s','%s',...) => valid number\n", message, fieldName);
    return true;
  }

  /* field is string */

  loc++;

  while (len > 1)
  {
    if (*loc == '\\')
    {
      loc++;
      switch (*loc)
      {
        case 'b':
          *value++ = '\b';
          loc++;
          break;
        case 'f':
          *value++ = '\f';
          loc++;
          break;
        case 'n':
          *value++ = '\n';
          loc++;
          break;
        case 'r':
          *value++ = '\r';
          loc++;
          break;
        case 't':
          *value++ = '\t';
          loc++;
          break;
        case 'u': {
          unsigned int n;
          sscanf(loc, "%4x", &n);
          loc += 4;
          *value++ = n & 255; // We're single byte, forget about the high byte...
        }
        break;

        default:
          *value++ = *loc++;
      }
    }
    else if (*loc == '"')
    {
      break;
    }
    else
    {
      *value++ = *loc++;
    }
    len--;
  }
  *value = 0;
  logDebug("getJSONValue('%s','%s',...) => valid string\n", message, fieldName);
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20a0
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2280
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x35f8
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq 0x1eb5(%rip), %rdi      # 0x549d
movb $0x0, %al
callq 0x2a10
movb $0x0, -0x1(%rbp)
jmp 0x398c
movq -0x30(%rbp), %rax
movsbl -0x1(%rax), %eax
cmpl $0x22, %eax
jne 0x362a
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x22, %eax
jne 0x362a
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl 0x1(%rax,%rcx), %eax
cmpl $0x3a, %eax
jne 0x362a
jmp 0x3638
movq -0x38(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x35c1
movq -0x38(%rbp), %rax
addq $0x2, %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
callq 0x2290
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movzbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x3676
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x3648
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x7b, %eax
jne 0x36a1
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x39a0
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x398c
movq -0x30(%rbp), %rdi
leaq 0x1e20(%rip), %rsi      # 0x54cc
movl $0x4, %edx
callq 0x2070
cmpl $0x0, %eax
jne 0x36da
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq 0x1e07(%rip), %rdi      # 0x54d1
movb $0x0, %al
callq 0x2a10
movb $0x0, -0x1(%rbp)
jmp 0x398c
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x22, %eax
je 0x37ba
jmp 0x36ec
callq 0x2290
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movzbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
jne 0x374d
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
je 0x374d
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x374d
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x45, %eax
je 0x374d
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x65, %eax
je 0x374d
movq -0x30(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x2b, %ecx
movb %al, -0x3d(%rbp)
jne 0x3758
cmpq $0x1, -0x28(%rbp)
seta %al
movb %al, -0x3d(%rbp)
movb -0x3d(%rbp), %al
testb $0x1, %al
jne 0x3761
jmp 0x3794
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movb (%rax), %cl
movq -0x20(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x20(%rbp)
movb %cl, (%rax)
movq -0x28(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x36ec
movq -0x20(%rbp), %rax
movb $0x0, (%rax)
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq 0x1d52(%rip), %rdi      # 0x54fc
movb $0x0, %al
callq 0x2a10
movb $0x1, -0x1(%rbp)
jmp 0x398c
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
cmpq $0x1, -0x28(%rbp)
jbe 0x396b
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5c, %eax
jne 0x3928
movq -0x30(%rbp), %rax
incq %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
addl $-0x62, %eax
movl %eax, %ecx
movq %rcx, -0x48(%rbp)
subl $0x13, %eax
ja 0x3904
movq -0x48(%rbp), %rax
leaq 0x1bfc(%rip), %rcx      # 0x540c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movb $0x8, (%rax)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x3926
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movb $0xc, (%rax)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x3926
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movb $0xa, (%rax)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x3926
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movb $0xd, (%rax)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x3926
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movb $0x9, (%rax)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x3926
movq -0x30(%rbp), %rdi
leaq 0x1c59(%rip), %rsi      # 0x5529
leaq -0x3c(%rbp), %rdx
movb $0x0, %al
callq 0x21c0
movq -0x30(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x30(%rbp)
movl -0x3c(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x20(%rbp)
movb %cl, (%rax)
jmp 0x3926
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movb (%rax), %cl
movq -0x20(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x20(%rbp)
movb %cl, (%rax)
jmp 0x395a
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x22, %eax
jne 0x3936
jmp 0x396b
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movb (%rax), %cl
movq -0x20(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x20(%rbp)
movb %cl, (%rax)
jmp 0x395a
movq -0x28(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x37c6
movq -0x20(%rbp), %rax
movb $0x0, (%rax)
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq 0x1bac(%rip), %rdi      # 0x552d
movb $0x0, %al
callq 0x2a10
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)