// File: /workspace/github_c_makefile_star2_O3/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 %rdi, %r14
cmpl $0x7, 0x20(%rdi)
jne 0x51b6
movq %rsi, %r15
movq %r14, %rdi
xorl %esi, %esi
callq 0x2988
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x51d8
leaq 0x126b(%rip), %r12      # 0x6170
movl 0x20(%r14), %eax
cmpl $0x6, %eax
jne 0x4f2b
movq %r14, %rdi
xorl %esi, %esi
callq 0x2988
testl %eax, %eax
jne 0x51d8
cmpl $0x0, 0x34(%r14)
je 0x4f05
movl 0x20(%r14), %eax
addl $-0x4, %eax
cmpl $0x5, %eax
ja 0x521e
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movl 0x8(%r15), %eax
testl %eax, %eax
je 0x4ff8
cmpl $0x74, %eax
je 0x5001
movl $0x6d, %eax
jmp 0x4ffd
movl 0x8(%r15), %eax
testl %eax, %eax
je 0x4f92
cmpl $0x61, %eax
je 0x4f9b
movl $0x6d, %eax
jmp 0x4f97
movl 0x8(%r15), %eax
testl %eax, %eax
je 0x5025
cmpl $0x76, %eax
je 0x502e
movl $0x6d, %eax
jmp 0x502a
movl $0x61, %eax
movl %eax, 0x8(%r15)
movl 0x10(%r15), %ebp
movq 0x18(%r15), %rdi
movl %ebp, %esi
callq 0x55b7
testq %rax, %rax
je 0x5241
movq %rax, %r13
movl $0x20, %edi
callq *0x414f(%rip)           # 0x9110
testq %rax, %rax
je 0x5290
movslq %ebp, %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
shlq $0x5, %rcx
movq %rax, 0x10(%r13,%rcx)
movq %r13, 0x18(%r15)
incl 0x10(%r15)
movq %r14, %rdi
movq %rax, %rsi
callq 0x4ec9
jmp 0x5177
movl $0x74, %eax
movl %eax, 0x8(%r15)
movq %r14, %rdi
movq %r15, %rsi
callq 0x5511
testq %rax, %rax
je 0x51d8
movq %r14, %rdi
movq %rax, %rsi
callq 0x52ed
jmp 0x5177
movl $0x76, %eax
movl %eax, 0x8(%r15)
movq 0x28(%r14), %rbp
movslq 0x30(%r14), %r13
movl 0x10(%r15), %r12d
movq 0x18(%r15), %rdi
movl %r12d, %esi
callq 0x55b7
testq %rax, %rax
je 0x525c
movq %rax, 0x18(%r15)
incl 0x10(%r15)
movslq %r12d, %rbx
shlq $0x5, %rbx
addq %rax, %rbx
movq %rbp, %rdi
movq %r13, %rsi
callq 0x1110
movq %rax, %r12
leaq 0x1(%rax), %rdi
callq *0x4097(%rip)           # 0x9110
testq %rax, %rax
je 0x52a8
movq %rax, %r13
movq %rax, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x1180
movb $0x0, (%r13,%r12)
movq %r13, 0x8(%rbx)
movzbl (%r13), %eax
movl $0x73, %ebp
cmpl $0x22, %eax
je 0x5129
cmpl $0x27, %eax
leaq 0x10ba(%rip), %r12      # 0x6170
je 0x513e
movq %r13, %rdi
xorl %esi, %esi
callq 0x3bcf
testl %eax, %eax
je 0x5132
movq %r13, %rdi
xorl %esi, %esi
callq 0x3c33
testl %eax, %eax
je 0x5139
movl $0x64, %ebp
movq %r13, %rdi
xorl %esi, %esi
movq %rsp, %rdx
movl $0x64, %ecx
callq 0x3d88
testl %eax, %eax
je 0x513e
movq %r13, %rdi
movq %rsp, %rsi
callq 0x3849
movl $0x75, %ebp
testl %eax, %eax
jne 0x513e
xorl %ebp, %ebp
cmpq $0x0, 0x40(%rsp)
setne %bpl
shll $0x4, %ebp
orl $0x44, %ebp
cmpq $0x0, 0x28(%rsp)
movl $0x74, %eax
cmovel %eax, %ebp
jmp 0x513e
leaq 0x1040(%rip), %r12      # 0x6170
jmp 0x513e
movl $0x62, %ebp
jmp 0x513e
movl $0x69, %ebp
movl %ebp, (%rbx)
cmpl $0x1, 0x10(%r15)
jne 0x514e
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x515e
cmpl %ebp, 0xc(%r15)
movl $0x6d, %ebp
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
je 0x5162
movl %ebp, 0xc(%r15)
cmpl $0x9, 0x20(%r14)
jne 0x52cb
movq %r14, %rdi
xorl %esi, %esi
callq 0x2988
testl %eax, %eax
jne 0x51d8
movl 0x20(%r14), %eax
cmpl $0x6, %eax
jne 0x519d
movq %r14, %rdi
xorl %esi, %esi
callq 0x2988
testl %eax, %eax
jne 0x51d8
cmpl $0x0, 0x34(%r14)
je 0x517b
movl 0x20(%r14), %eax
cmpl $0x2, %eax
jne 0x51e9
movq %r14, %rdi
xorl %esi, %esi
callq 0x2988
testl %eax, %eax
je 0x4f05
jmp 0x51d8
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x120d(%rip), %rdx      # 0x63d2
leaq 0x1149(%rip), %rcx      # 0x6315
xorl %eax, %eax
callq 0x10e0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x8, %eax
jne 0x5203
movq %r14, %rdi
movl $0x1, %esi
callq 0x2988
xorl %ebx, %ebx
negl %eax
sbbl %ebx, %ebx
jmp 0x51d8
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x11c0(%rip), %rdx      # 0x63d2
leaq 0x112c(%rip), %rcx      # 0x6345
jmp 0x52e1
movl 0x24(%r14), %ecx
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x105b(%rip), %rdx      # 0x628c
leaq 0xf74(%rip), %r8        # 0x61ac
xorl %eax, %eax
callq 0x10e0
jmp 0x51d8
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0xf8e(%rip), %rdx       # 0x61de
leaq 0x1105(%rip), %rcx      # 0x635c
jmp 0x52e1
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0xf73(%rip), %r15       # 0x61de
leaq 0x10df(%rip), %rcx      # 0x6351
movq %r15, %rdx
xorl %eax, %eax
callq 0x10e0
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x1096(%rip), %rcx      # 0x6321
movq %r15, %rdx
jmp 0x52e1
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0xf3f(%rip), %rdx       # 0x61de
leaq 0x10c1(%rip), %rcx      # 0x6367
jmp 0x52e1
movq $0x0, 0x8(%rbx)
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0xf1f(%rip), %rdx       # 0x61de
leaq 0x1067(%rip), %rcx      # 0x632d
jmp 0x51cc
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x10f8(%rip), %rdx      # 0x63d2
leaq 0x1058(%rip), %rcx      # 0x6339
xorl %eax, %eax
callq 0x10e0
jmp 0x51d8