// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r12
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x1(%rdi), %rbp
movq %rsi, %rdi
callq 0x20b0
movq %rax, %r13
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x2280
testq %rax, %rax
je 0x3002
cmpb $0x22, -0x1(%rax)
jne 0x2ffa
cmpb $0x22, (%rax,%r13)
jne 0x2ffa
leaq (%rax,%r13), %rbp
cmpb $0x3a, 0x1(%rbp)
je 0x3029
addq %r13, %rax
movq %rax, %rdi
jmp 0x2fd6
leaq 0x1490(%rip), %rdi      # 0x4499
xorl %ebp, %ebp
movq %r14, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2891
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, (%rsp)
addq $0x2, %rbp
callq 0x2290
movq (%rax), %rcx
movzbl (%rbp), %r13d
movzwl (%rcx,%r13,2), %r14d
incq %rbp
btl $0xd, %r14d
jb 0x3039
cmpb $0x7b, %r13b
jne 0x3073
movq (%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r12, %rcx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x31ea
movq %rax, 0x10(%rsp)
leaq -0x1(%rbp), %rdi
leaq 0x1445(%rip), %rsi      # 0x44c8
movl $0x4, %edx
callq 0x2070
testl %eax, %eax
je 0x3151
cmpb $0x22, %r13b
movq 0x10(%rsp), %rsi
jne 0x3163
cmpq $0x2, %r12
jb 0x31c6
leaq 0x1373(%rip), %r13      # 0x4428
movq (%rsp), %r14
movzbl (%rbp), %eax
cmpl $0x5c, %eax
je 0x30d3
cmpl $0x22, %eax
je 0x31ca
incq %rbp
movb %al, (%r15)
jmp 0x313f
movb 0x1(%rbp), %al
movzbl %al, %ecx
leal -0x6e(%rcx), %edx
cmpl $0x7, %edx
ja 0x30f1
movslq (%r13,%rdx,4), %rcx
addq %r13, %rcx
jmpq *%rcx
movb $0xa, (%r15)
jmp 0x313b
cmpl $0x66, %ecx
je 0x3137
cmpl $0x62, %ecx
jne 0x3101
movb $0x8, (%r15)
jmp 0x313b
addq $0x2, %rbp
jmp 0x3126
leaq 0x1(%rbp), %rdi
leaq 0x1413(%rip), %rsi      # 0x4525
leaq 0xc(%rsp), %rdx
xorl %eax, %eax
callq 0x21b0
addq $0x5, %rbp
movb 0xc(%rsp), %al
movb %al, (%r15)
jmp 0x313f
movb $0xd, (%r15)
jmp 0x313b
movb $0x9, (%r15)
jmp 0x313b
movb $0xc, (%r15)
addq $0x2, %rbp
incq %r15
decq %r12
cmpq $0x1, %r12
ja 0x30b9
jmp 0x31ca
leaq 0x1375(%rip), %rdi      # 0x44cd
xorl %ebp, %ebp
movq (%rsp), %rsi
jmp 0x300e
xorl %eax, %eax
movabsq $0x100000001000003, %rcx # imm = 0x100000001000003
btl $0xb, %r14d
jb 0x3188
movzbl %r13b, %edx
addl $-0x2d, %edx
cmpl $0x38, %edx
ja 0x31a8
btq %rdx, %rcx
jae 0x31a8
cmpq $0x2, %r12
jb 0x31b4
movb %r13b, (%r15,%rax)
decq %r12
movq (%rsi), %rdx
movzbl (%rbp,%rax), %r13d
movzwl (%rdx,%r13,2), %r14d
incq %rax
jmp 0x316f
cmpb $0x2b, %r13b
jne 0x31b4
cmpq $0x1, %r12
ja 0x318e
movb $0x0, (%r15,%rax)
leaq 0x1338(%rip), %rdi      # 0x44f8
movq (%rsp), %rsi
jmp 0x31d8
movq (%rsp), %r14
movb $0x0, (%r15)
leaq 0x1354(%rip), %rdi      # 0x4529
movq %r14, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2891
movb $0x1, %bpl
jmp 0x3018