// File: /workspace/github_cpp_makefile_star2_O2/onai[P]npio/./npio.h
// Function: npio_ph_parse_dict_(npio_Array*, char const*, char const*)
static inline int npio_ph_parse_dict_(npio_Array* array, const char* start, const char* end)
{
  int err;
  char open_quote;
  const char *p = start;
  const char *dtbeg, *dtend;
  size_t dtsz;
  enum {k_descr, k_shape, k_fortran_order} key;

  if (p >= end)
    return EINVAL;

  if (*p++ != '{')
    return EINVAL;

  /* Go through all key-value pairs. */
  while (1)
  {
    p = npio_ph_skip_spaces_(p, end);
    if (p >= end)
      return EINVAL;

    /* are we done? */
    if (*p == '}')
    {
      ++p;
      break;
    }

    /* Expect the open quote of a key */
    if (!npio_ph_is_quote_(open_quote = *p++))
      return EINVAL;

    /* Check for one of the three possible keys */
    if (p + 5 < end && memcmp(p, "descr", 5) == 0)
    {
      key = k_descr;
      p += 5;
    }
    else if (p + 5 < end && memcmp(p, "shape", 5) == 0)
    {
      key = k_shape;
      p += 5;
    }
    else if (p + 13 < end && memcmp(p, "fortran_order", 13) == 0)
    {
      key = k_fortran_order;
      p += 13;
    }
    else
      return EINVAL;

    /* Expect the close quote of the key */
    if (p >= end || *p++ != open_quote)
      return EINVAL;

    /* Get to the colon */
    p = npio_ph_skip_spaces_(p, end);
    if (p >= end || *p++ != ':')
      return EINVAL;

    /* skip any more spaces */
    p = npio_ph_skip_spaces_(p, end);
    if (p == end)
      return EINVAL;

    switch (key)
    {
      case k_descr:
        if (!npio_ph_is_quote_(open_quote = *p++))
          return EINVAL;
        dtbeg = p;
        while (p < end && *p != open_quote)
          ++p;
        dtend = p;
        if (p == end)
          return EINVAL;
        ++p;
        dtsz = dtend - dtbeg;
        array->dtype = (char*) malloc(dtsz + 1);
        memcpy(array->dtype, dtbeg, dtsz);
        array->dtype[dtsz] = 0;
        break;

      case k_fortran_order:
        if (p + 4 < end && memcmp(p, "True", 4) == 0)
        {
          array->fortran_order = 1;
          p += 4;
        }
        else if (p + 5 < end && memcmp(p, "False", 5) == 0)
        {
          array->fortran_order = 0;
          p += 5;
        }
        else
          return EINVAL;
        break;

      case k_shape:
        if ((err = npio_ph_parse_shape_(array, p, end, &p)))
          return err;
        break;
    }

    /* skip any spaces after end of key : value */
    p = npio_ph_skip_spaces_(p, end);

    if (p == end)
      return EINVAL;

    /* grab that separating comma */
    if (*p == ',')
      ++p;

    /* next iteration takes care of any nonsense that might happen here! */
  }

  /* Parse the (very restricted) numpy dtype and return */
  return npio_ph_parse_dtype_(array);
}

// Assembly:
pushq $0x16
popq %rcx
cmpq %rdx, %rsi
jae 0x1754
cmpb $0x7b, (%rsi)
jne 0x1754
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rdi, %r14
incq %rsi
movq %rdi, (%rsp)
movq %rsi, %rdi
movq %r15, %rsi
callq 0x17ec
cmpq %r15, %rax
jae 0x1743
movq %rax, %r12
movzbl (%rax), %ebx
cmpl $0x7d, %ebx
je 0x1757
cmpl $0x27, %ebx
je 0x1490
cmpl $0x22, %ebx
jne 0x1743
leaq 0x1(%r12), %rbp
leaq 0x6(%r12), %r13
cmpq %r15, %r13
jae 0x14d3
movq %rbp, %rdi
leaq 0xbf3(%rip), %rsi       # 0x209c
pushq $0x5
popq %r14
movq %r14, %rdx
callq 0x10c0
testl %eax, %eax
je 0x1502
movq %rbp, %rdi
leaq 0xbdf(%rip), %rsi       # 0x20a2
movq %r14, %rdx
callq 0x10c0
pushq $0x1
popq %r14
testl %eax, %eax
je 0x1505
addq $0xe, %r12
cmpq %r15, %r12
jae 0x1743
movq %rbp, %rdi
leaq 0xbbe(%rip), %rsi       # 0x20a8
pushq $0xd
popq %rdx
callq 0x10c0
movq %r12, %r13
pushq $0x2
popq %r14
testl %eax, %eax
je 0x1505
jmp 0x1743
xorl %r14d, %r14d
cmpq %r15, %r13
jae 0x1743
cmpb %bl, (%r13)
jne 0x1743
incq %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x17ec
cmpq %r15, %rax
jae 0x1743
cmpb $0x3a, (%rax)
jne 0x1743
incq %rax
movq %rax, %rdi
movq %r15, %rsi
callq 0x17ec
cmpq %r15, %rax
je 0x1743
movq %rax, %r13
movq %rax, %r12
cmpl $0x2, %r14d
je 0x166b
cmpl $0x1, %r14d
jne 0x16b7
cmpb $0x28, (%r12)
movq (%rsp), %r14
jne 0x1743
movq $0x8, 0x70(%r14)
pushq $0x40
popq %rdi
callq 0x10e0
movq %rax, 0x20(%r14)
testq %rax, %rax
je 0x177e
movq %rax, %rbp
incq %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x17ec
movq %rax, %r12
cmpq %r15, %r12
jae 0x15bf
movb (%r12), %cl
addb $-0x30, %cl
cmpb $0x9, %cl
ja 0x15bf
incq %r12
jmp 0x15a9
cmpq %r15, %r12
je 0x1743
cmpq %r12, %rax
jae 0x1628
xorl %ebx, %ebx
cmpq %r12, %rax
jae 0x15e9
movsbq (%rax), %rcx
incq %rax
imulq $0xa, %rbx, %rdx
leaq (%rdx,%rcx), %rbx
addq $-0x30, %rbx
jmp 0x15cf
movq 0x18(%r14), %rsi
cmpq 0x70(%r14), %rsi
jne 0x161b
leaq (%rsi,%rsi), %rax
movq %rax, 0x70(%r14)
shlq $0x4, %rsi
movq %rbp, %rdi
callq 0x1100
testq %rax, %rax
je 0x177e
movq %rax, %rbp
movq %rax, 0x20(%r14)
movq 0x18(%r14), %rsi
leaq 0x1(%rsi), %rax
movq %rax, 0x18(%r14)
movq %rbx, (%rbp,%rsi,8)
movq %r12, %rdi
movq %r15, %rsi
callq 0x17ec
cmpq %r15, %rax
je 0x1743
movq %rax, %r12
movzbl (%rax), %eax
cmpl $0x2c, %eax
je 0x1598
cmpl $0x29, %eax
jne 0x1743
incq %r12
movq %r14, %rdi
callq 0x1817
movq %rax, 0x28(%r14)
movq %r12, %rbp
jmp 0x1714
leaq 0x4(%r13), %rbp
cmpq %r15, %rbp
jae 0x1682
cmpl $0x65757254, (%r12)     # imm = 0x65757254
je 0x1735
addq $0x5, %r13
cmpq %r15, %r13
movq (%rsp), %r14
jae 0x1743
movq %r12, %rdi
leaq 0xa1e(%rip), %rsi       # 0x20bb
pushq $0x5
popq %rdx
callq 0x10c0
testl %eax, %eax
jne 0x1743
andl $0x0, 0x30(%r14)
movq %r13, %rbp
jmp 0x1714
movq (%rsp), %r14
movzbl (%r12), %eax
cmpl $0x27, %eax
pushq $0x16
popq %rcx
je 0x16cd
cmpl $0x22, %eax
jne 0x1746
incq %r13
xorl %r12d, %r12d
movq %r13, %rbp
cmpq %r15, %rbp
jae 0x16e8
cmpb %al, (%rbp)
je 0x16e8
incq %rbp
incq %r12
jmp 0x16d6
cmpq %r15, %rbp
je 0x1746
incq %rbp
leaq 0x1(%r12), %rdi
callq 0x10e0
movq %rax, %rbx
movq %rax, 0x10(%r14)
movq %rax, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x10b0
movb $0x0, (%rbx,%r12)
movq %rbp, %rdi
movq %r15, %rsi
callq 0x17ec
cmpq %r15, %rax
je 0x1743
xorl %esi, %esi
cmpb $0x2c, (%rax)
sete %sil
addq %rax, %rsi
jmp 0x145f
movq (%rsp), %r14
movl $0x1, 0x30(%r14)
jmp 0x1714
pushq $0x16
popq %rcx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
movl %ecx, %eax
retq
movq 0x10(%r14), %r15
movq %r15, %rdi
callq 0x1070
pushq $0x5f
popq %rcx
cmpq $0x3, %rax
jne 0x1746
movzbl (%r15), %eax
cmpl $0x3c, %eax
je 0x1782
cmpl $0x3e, %eax
jne 0x1746
xorl %eax, %eax
jmp 0x1785
pushq $0xc
jmp 0x1745
pushq $0x1
popq %rax
movl %eax, 0x34(%r14)
movzbl 0x1(%r15), %eax
cmpl $0x66, %eax
je 0x17ac
cmpl $0x69, %eax
je 0x17a2
cmpl $0x75, %eax
jne 0x1746
xorps %xmm0, %xmm0
jmp 0x17b3
movsd 0x876(%rip), %xmm0      # 0x2020
jmp 0x17b3
movaps 0x87d(%rip), %xmm0      # 0x2030
movlps %xmm0, 0x38(%r14)
movb 0x2(%r15), %al
addb $-0x31, %al
cmpb $0x7, %al
ja 0x1746
movzbl %al, %eax
movl %ecx, %edx
movl $0x8b, %ecx
btl %eax, %ecx
movl %edx, %ecx
jae 0x1746
leaq 0x8e6(%rip), %rcx       # 0x20c4
movl (%rcx,%rax,4), %eax
movl %eax, 0x40(%r14)
xorl %ecx, %ecx
jmp 0x1746