// File: /workspace/github_c_makefile_star2_O1/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, (%rsp)
leaq 0x1(%rdi), %rbp
movq %rsi, %rdi
callq 0x20b0
movq %rax, %r13
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x2280
testq %rax, %rax
je 0x3037
cmpb $0x22, -0x1(%rax)
jne 0x302f
cmpb $0x22, (%rax,%r13)
jne 0x302f
leaq (%rax,%r13), %r14
cmpb $0x3a, 0x1(%r14)
je 0x305f
addq %r13, %rax
movq %rax, %rdi
jmp 0x300a
leaq 0x143f(%rip), %rdi      # 0x447d
xorl %ebp, %ebp
movq (%rsp), %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x28a5
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x2, %r14
callq 0x2290
movq (%rax), %rcx
movzbl (%r14), %r13d
incq %r14
testb $0x20, 0x1(%rcx,%r13,2)
jne 0x306b
cmpb $0x7b, %r13b
jne 0x30a0
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 0x3203
movq %rax, 0x10(%rsp)
leaq -0x1(%r14), %rbp
leaq 0x13fc(%rip), %rsi      # 0x44ac
movl $0x4, %edx
movq %rbp, %rdi
callq 0x2070
testl %eax, %eax
je 0x318c
cmpb $0x22, %r13b
movq 0x10(%rsp), %rdi
jne 0x3198
cmpq $0x2, %r12
jb 0x317f
leaq 0x1327(%rip), %r13      # 0x440c
leaq 0xc(%rsp), %rbp
movzbl (%r14), %eax
cmpl $0x5c, %eax
je 0x3104
cmpl $0x22, %eax
je 0x317f
incq %r14
movb %al, (%r15)
jmp 0x316f
movb 0x1(%r14), %al
movzbl %al, %ecx
leal -0x6e(%rcx), %edx
cmpl $0x7, %edx
ja 0x3123
movslq (%r13,%rdx,4), %rcx
addq %r13, %rcx
jmpq *%rcx
movb $0xa, (%r15)
jmp 0x316b
cmpl $0x66, %ecx
je 0x3167
cmpl $0x62, %ecx
jne 0x3133
movb $0x8, (%r15)
jmp 0x316b
addq $0x2, %r14
jmp 0x3156
leaq 0x1(%r14), %rdi
leaq 0x13c5(%rip), %rsi      # 0x4509
movq %rbp, %rdx
xorl %eax, %eax
callq 0x21b0
addq $0x5, %r14
movb 0xc(%rsp), %al
movb %al, (%r15)
jmp 0x316f
movb $0xd, (%r15)
jmp 0x316b
movb $0x9, (%r15)
jmp 0x316b
movb $0xc, (%r15)
addq $0x2, %r14
incq %r15
decq %r12
cmpq $0x1, %r12
ja 0x30ea
movb $0x0, (%r15)
leaq 0x1383(%rip), %rdi      # 0x450d
jmp 0x31ed
leaq 0x131e(%rip), %rdi      # 0x44b1
jmp 0x303e
movabsq $0x100000001000003, %rax # imm = 0x100000001000003
movq (%rdi), %rsi
movb (%rbp), %cl
movzbl %cl, %edx
movzwl (%rsi,%rdx,2), %esi
btl $0xb, %esi
jb 0x31c3
addl $-0x2d, %edx
cmpl $0x38, %edx
ja 0x31d7
btq %rdx, %rax
jae 0x31d7
cmpq $0x2, %r12
jb 0x31e2
incq %rbp
movb %cl, (%r15)
incq %r15
decq %r12
jmp 0x31a2
cmpb $0x2b, %cl
jne 0x31e2
cmpq $0x1, %r12
ja 0x31c9
movb $0x0, (%r15)
leaq 0x12ef(%rip), %rdi      # 0x44dc
movq (%rsp), %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x28a5
movb $0x1, %bpl
jmp 0x304e