// File: /workspace/github_c_makefile_star2_O2/cktan[P]tomlc99/toml.c
// Function: parse_array
static int parse_array(context_t *ctx, toml_array_t *arr) {
  if (eat_token(ctx, LBRACKET, 0, FLINE))
    return -1;

  for (;;) {
    if (skip_newlines(ctx, 0))
      return -1;

    /* until ] */
    if (ctx->tok.tok == RBRACKET)
      break;

    switch (ctx->tok.tok) {
    case STRING: {
      /* set array kind if this will be the first entry */
      if (arr->kind == 0)
        arr->kind = 'v';
      else if (arr->kind != 'v')
        arr->kind = 'm';

      char *val = ctx->tok.ptr;
      int vlen = ctx->tok.len;

      /* make a new value in array */
      toml_arritem_t *newval = create_value_in_array(ctx, arr);
      if (!newval)
        return e_outofmemory(ctx, FLINE);

      if (!(newval->val = STRNDUP(val, vlen)))
        return e_outofmemory(ctx, FLINE);

      newval->valtype = valtype(newval->val);

      /* set array type if this is the first entry */
      if (arr->nitem == 1)
        arr->type = newval->valtype;
      else if (arr->type != newval->valtype)
        arr->type = 'm'; /* mixed */

      if (eat_token(ctx, STRING, 0, FLINE))
        return -1;
      break;
    }

    case LBRACKET: { /* [ [array], [array] ... ] */
      /* set the array kind if this will be the first entry */
      if (arr->kind == 0)
        arr->kind = 'a';
      else if (arr->kind != 'a')
        arr->kind = 'm';

      toml_array_t *subarr = create_array_in_array(ctx, arr);
      if (!subarr)
        return -1;
      if (parse_array(ctx, subarr))
        return -1;
      break;
    }

    case LBRACE: { /* [ {table}, {table} ... ] */
      /* set the array kind if this will be the first entry */
      if (arr->kind == 0)
        arr->kind = 't';
      else if (arr->kind != 't')
        arr->kind = 'm';

      toml_table_t *subtab = create_table_in_array(ctx, arr);
      if (!subtab)
        return -1;
      if (parse_inline_table(ctx, subtab))
        return -1;
      break;
    }

    default:
      return e_syntax(ctx, ctx->tok.lineno, "syntax error");
    }

    if (skip_newlines(ctx, 0))
      return -1;

    /* on comma, continue to scan for next element */
    if (ctx->tok.tok == COMMA) {
      if (eat_token(ctx, COMMA, 0, FLINE))
        return -1;
      continue;
    }
    break;
  }

  if (eat_token(ctx, RBRACKET, 1, FLINE))
    return -1;
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r15
movq %rdi, %r14
leaq 0xd6f(%rip), %rcx       # 0x5321
pushq $0x7
popq %rsi
xorl %edx, %edx
callq 0x2e1f
pushq $-0x1
popq %rcx
testl %eax, %eax
jne 0x4871
leaq 0xba2(%rip), %rbx       # 0x5170
pushq $0x6d
popq %r13
movq %r14, %rdi
callq 0x4afb
testl %eax, %eax
jne 0x486e
movl 0x20(%r14), %eax
addl $-0x4, %eax
cmpl $0x5, %eax
ja 0x4820
movslq (%rbx,%rax,4), %rax
addq %rbx, %rax
jmpq *%rax
movl 0x8(%r15), %eax
pushq $0x74
popq %rcx
testl %eax, %eax
je 0x460e
cmpl $0x74, %eax
je 0x4612
movl %r13d, %ecx
movl %ecx, 0x8(%r15)
movq %r14, %rdi
movq %r15, %rsi
callq 0x4b2e
testq %rax, %rax
je 0x486e
movq %r14, %rdi
movq %rax, %rsi
callq 0x4882
jmp 0x47c6
movl 0x8(%r15), %eax
pushq $0x61
popq %rcx
testl %eax, %eax
je 0x4649
cmpl $0x61, %eax
je 0x464d
movl %r13d, %ecx
movl %ecx, 0x8(%r15)
movl 0x10(%r15), %ebp
movq 0x18(%r15), %rdi
movl %ebp, %esi
callq 0x4bac
testq %rax, %rax
je 0x4835
movq %rax, %r12
pushq $0x20
popq %rdi
callq *0x3a9f(%rip)           # 0x8110
testq %rax, %rax
je 0x4856
movslq %ebp, %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
shlq $0x5, %rcx
movq %rax, 0x10(%r12,%rcx)
movq %r12, 0x18(%r15)
incl 0x10(%r15)
movq %r14, %rdi
movq %rax, %rsi
callq 0x4597
jmp 0x47c6
movl 0x8(%r15), %eax
pushq $0x76
popq %rcx
testl %eax, %eax
je 0x46bb
cmpl $0x76, %eax
je 0x46bf
movl %r13d, %ecx
movl %ecx, 0x8(%r15)
movq 0x28(%r14), %r12
movslq 0x30(%r14), %rbp
movl 0x10(%r15), %ebx
movq 0x18(%r15), %rdi
movl %ebx, %esi
callq 0x4bac
testq %rax, %rax
je 0x483e
movq %rax, %r13
movslq %ebx, %rbx
movq %rax, 0x18(%r15)
incl 0x10(%r15)
shlq $0x5, %rbx
movq %r12, %rdi
movq %rbp, %rsi
callq 0x4457
movq %rax, 0x8(%r13,%rbx)
testq %rax, %rax
je 0x485f
movq %rax, %r12
movzbl (%rax), %eax
pushq $0x73
popq %rcx
cmpl $0x22, %eax
je 0x477f
cmpl $0x27, %eax
je 0x477f
movq %r12, %rdi
xorl %esi, %esi
callq 0x3651
pushq $0x62
popq %rcx
testl %eax, %eax
je 0x477f
movq %r12, %rdi
xorl %esi, %esi
callq 0x36b1
pushq $0x69
popq %rcx
testl %eax, %eax
je 0x477f
movq %r12, %rdi
xorl %esi, %esi
callq 0x391b
pushq $0x64
popq %rcx
testl %eax, %eax
je 0x477f
movq %r12, %rdi
movq %rsp, %rsi
callq 0x332c
pushq $0x75
popq %rcx
testl %eax, %eax
jne 0x477f
xorl %ecx, %ecx
cmpq $0x0, 0x40(%rsp)
setne %cl
shll $0x4, %ecx
orl $0x44, %ecx
cmpq $0x0, 0x28(%rsp)
pushq $0x74
popq %rax
cmovel %eax, %ecx
addq %rbx, %r13
movl %ecx, (%r13)
cmpl $0x1, 0x10(%r15)
jne 0x479a
leaq 0x9dc(%rip), %rbx       # 0x5170
pushq $0x6d
popq %r13
jmp 0x47ae
cmpl %ecx, 0xc(%r15)
pushq $0x6d
popq %r13
movl %r13d, %ecx
leaq 0x9c4(%rip), %rbx       # 0x5170
je 0x47b2
movl %ecx, 0xc(%r15)
movq %r14, %rdi
pushq $0x9
popq %rsi
xorl %edx, %edx
leaq 0xb84(%rip), %rcx       # 0x5345
callq 0x2e1f
testl %eax, %eax
jne 0x486e
movq %r14, %rdi
callq 0x4afb
testl %eax, %eax
jne 0x486e
cmpl $0x2, 0x20(%r14)
jne 0x4803
movq %r14, %rdi
pushq $0x2
popq %rsi
xorl %edx, %edx
leaq 0xb5d(%rip), %rcx       # 0x5351
callq 0x2e1f
testl %eax, %eax
je 0x45d2
jmp 0x486e
leaq 0xb53(%rip), %rcx       # 0x535d
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x2e1f
xorl %ecx, %ecx
negl %eax
sbbl %ecx, %ecx
jmp 0x4871
movl 0x24(%r14), %esi
leaq 0x98d(%rip), %rdx       # 0x51b8
movq %r14, %rdi
callq 0x2e01
jmp 0x486e
leaq 0xb38(%rip), %rsi       # 0x5374
jmp 0x4866
leaq 0xb24(%rip), %rsi       # 0x5369
movq %r14, %rdi
callq 0x2567
leaq 0xad9(%rip), %rsi       # 0x532d
jmp 0x4866
leaq 0xb22(%rip), %rsi       # 0x537f
jmp 0x4866
leaq 0xad3(%rip), %rsi       # 0x5339
movq %r14, %rdi
callq 0x2567
pushq $-0x1
popq %rcx
movl %ecx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq