// File: onai[P]npio/./npio.h
// Function: npio_ph_parse_shape_(npio_Array*, char const*, char const*, char const**)
static inline int npio_ph_parse_shape_(npio_Array* array, const char *start
  , const char *end, const char **where)
{
  const char *p = start, *nbeg, *nend;
  size_t val;
  int err;

  if (p == end)
    return EINVAL;

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

  array->_shape_capacity = 8;
  array->shape = (size_t*) malloc(sizeof(size_t) * array->_shape_capacity);
  if (array->shape == 0)
    return ENOMEM;

  while (1)
  {
    p = npio_ph_skip_spaces_(p, end);

    nbeg = p;
    while (p < end && *p >= '0' && *p <= '9')
      ++p;
    nend = p;

    if (p == end)
      return EINVAL;

    if (nbeg < nend)  /* trailing comma is allowed in python, so must check */
    {
      val = 0;
      while (nbeg < nend)
        val = (*nbeg++ - '0') + val * 10;
      if ((err = npio_ph_shape_append_(array, val)))
        return err;
    }

    p = npio_ph_skip_spaces_(p, end);
    if (p == end)
      return EINVAL;
    if (*p == ',')
      ++p;
    else if (*p == ')')
    {
      ++p;
      break;
    }
    else
      return EINVAL;
  }

  *where = p;
  array->size = npio_array_size(array);
  return 0;
}

// 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 -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x20(%rbp), %rax
jne 0x1ea6
movl $0x16, -0x4(%rbp)
jmp 0x2077
movq -0x30(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x30(%rbp)
movsbl (%rax), %eax
cmpl $0x28, %eax
je 0x1ec9
movl $0x16, -0x4(%rbp)
jmp 0x2077
movq -0x10(%rbp), %rax
movq $0x8, 0x70(%rax)
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rdi
shlq $0x3, %rdi
callq 0x10e0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x1f08
movl $0xc, -0x4(%rbp)
jmp 0x2077
jmp 0x1f0a
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x1de0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rcx
xorl %eax, %eax
cmpq -0x20(%rbp), %rcx
movb %al, -0x4d(%rbp)
jae 0x1f53
movq -0x30(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x30, %ecx
movb %al, -0x4d(%rbp)
jl 0x1f53
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x39, %eax
setle %al
movb %al, -0x4d(%rbp)
movb -0x4d(%rbp), %al
testb $0x1, %al
jne 0x1f5c
jmp 0x1f6a
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x1f23
movq -0x30(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x20(%rbp), %rax
jne 0x1f88
movl $0x16, -0x4(%rbp)
jmp 0x2077
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0x1feb
movq $0x0, -0x48(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0x1fc9
movq -0x38(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x38(%rbp)
movsbl (%rax), %eax
subl $0x30, %eax
cltq
imulq $0xa, -0x48(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
jmp 0x1f9a
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x21f0
movl %eax, -0x4c(%rbp)
cmpl $0x0, %eax
je 0x1fe9
movl -0x4c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x2077
jmp 0x1feb
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x1de0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x20(%rbp), %rax
jne 0x200f
movl $0x16, -0x4(%rbp)
jmp 0x2077
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2c, %eax
jne 0x2029
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x204c
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x29, %eax
jne 0x2043
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x2051
movl $0x16, -0x4(%rbp)
jmp 0x2077
jmp 0x1f0a
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rdi
callq 0x2290
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq