// File: /workspace/github_c_makefile_star2_O1/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 0x54fe
movq %rsi, %r15
movq %r14, %rdi
xorl %esi, %esi
callq 0x2b77
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x5520
leaq 0xf6f(%rip), %r12       # 0x614c
cmpl $0x6, 0x20(%r14)
jne 0x51fd
movq %r14, %rdi
xorl %esi, %esi
callq 0x2b77
testl %eax, %eax
jne 0x5520
cmpl $0x0, 0x34(%r14)
je 0x51dd
movl 0x20(%r14), %eax
addl $-0x4, %eax
cmpl $0x5, %eax
ja 0x5565
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movl 0x8(%r15), %eax
testl %eax, %eax
je 0x52dd
cmpl $0x74, %eax
je 0x52e6
movl $0x6d, %eax
jmp 0x52e2
movl 0x8(%r15), %eax
testl %eax, %eax
je 0x5268
cmpl $0x61, %eax
je 0x5271
movl $0x6d, %eax
jmp 0x526d
movl 0x8(%r15), %eax
testl %eax, %eax
je 0x530a
cmpl $0x76, %eax
je 0x5313
movl $0x6d, %eax
jmp 0x530f
movl $0x61, %eax
movl %eax, 0x8(%r15)
movl 0x10(%r15), %ebp
movq 0x18(%r15), %rdi
movl %ebp, %esi
callq 0x58b0
testq %rax, %rax
je 0x52c2
movq %rax, %r13
movl $0x20, %edi
callq *0x3e85(%rip)           # 0x9118
testq %rax, %rax
je 0x543f
movq %rax, %rsi
movslq %ebp, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsi)
movups %xmm0, (%rsi)
shlq $0x5, %rax
movq %rsi, 0x10(%r13,%rax)
movq %r13, 0x18(%r15)
incl 0x10(%r15)
jmp 0x545e
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0xee9(%rip), %rdx       # 0x61ba
leaq 0x1060(%rip), %rcx      # 0x6338
jmp 0x5455
movl $0x74, %eax
movl %eax, 0x8(%r15)
movq %r14, %rdi
movq %r15, %rsi
callq 0x580a
testq %rax, %rax
je 0x5520
movq %r14, %rdi
movq %rax, %rsi
callq 0x55e4
jmp 0x54c3
movl $0x76, %eax
movl %eax, 0x8(%r15)
movq 0x28(%r14), %r13
movslq 0x30(%r14), %rbp
movl 0x10(%r15), %r12d
movq 0x18(%r15), %rdi
movl %r12d, %esi
callq 0x58b0
testq %rax, %rax
je 0x5344
movq %rax, 0x18(%r15)
incl 0x10(%r15)
movslq %r12d, %rbx
shlq $0x5, %rbx
addq %rax, %rbx
jmp 0x5363
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0xe67(%rip), %rdx       # 0x61ba
leaq 0xfd3(%rip), %rcx       # 0x632d
xorl %eax, %eax
callq 0x10f0
xorl %ebx, %ebx
testq %rbx, %rbx
je 0x5588
movq %r13, %rdi
movq %rbp, %rsi
callq 0x1120
movq %rax, %r12
leaq 0x1(%rax), %rdi
callq *0x3d94(%rip)           # 0x9118
movq %rax, %rbp
testq %rax, %rax
je 0x55a3
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x1190
movb $0x0, (%rbp,%r12)
movq %rbp, 0x8(%rbx)
movzbl (%rbp), %eax
movl $0x73, %r12d
cmpl $0x22, %eax
je 0x547f
cmpl $0x27, %eax
je 0x547f
movq %rbp, %rdi
xorl %esi, %esi
callq 0x3dbf
testl %eax, %eax
je 0x5471
movq %rbp, %rdi
xorl %esi, %esi
callq 0x3e23
testl %eax, %eax
je 0x5479
movl $0x64, %r12d
movq %rbp, %rdi
xorl %esi, %esi
movq %rsp, %rdx
movl $0x64, %ecx
callq 0x3f92
testl %eax, %eax
je 0x547f
movq %rbp, %rdi
movq %rsp, %rsi
callq 0x3a2f
movl $0x75, %r12d
testl %eax, %eax
jne 0x547f
xorl %r12d, %r12d
cmpq $0x0, 0x40(%rsp)
setne %r12b
shll $0x4, %r12d
orl $0x44, %r12d
cmpq $0x0, 0x28(%rsp)
movl $0x74, %eax
cmovel %eax, %r12d
jmp 0x547f
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0xd6c(%rip), %rdx       # 0x61ba
leaq 0xeee(%rip), %rcx       # 0x6343
xorl %eax, %eax
callq 0x10f0
xorl %esi, %esi
testq %rsi, %rsi
je 0x5520
movq %r14, %rdi
callq 0x51a1
jmp 0x54c3
movl $0x62, %r12d
jmp 0x547f
movl $0x69, %r12d
movl %r12d, (%rbx)
cmpl $0x1, 0x10(%r15)
jne 0x5494
movl %r12d, 0xc(%r15)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x54a7
cmpl %r12d, 0xc(%r15)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
je 0x54a7
movl $0x6d, 0xc(%r15)
cmpl $0x9, 0x20(%r14)
leaq 0xc99(%rip), %r12       # 0x614c
jne 0x55c2
movq %r14, %rdi
xorl %esi, %esi
callq 0x2b77
testl %eax, %eax
jne 0x5520
cmpl $0x6, 0x20(%r14)
jne 0x54e3
movq %r14, %rdi
xorl %esi, %esi
callq 0x2b77
testl %eax, %eax
jne 0x5520
cmpl $0x0, 0x34(%r14)
je 0x54c7
cmpl $0x2, 0x20(%r14)
jne 0x5531
movq %r14, %rdi
xorl %esi, %esi
callq 0x2b77
testl %eax, %eax
je 0x51dd
jmp 0x5520
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0xea1(%rip), %rdx       # 0x63ae
leaq 0xddd(%rip), %rcx       # 0x62f1
xorl %eax, %eax
callq 0x10f0
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, 0x20(%r14)
jne 0x554d
movq %r14, %rdi
movl $0x1, %esi
callq 0x2b77
xorl %ebx, %ebx
negl %eax
sbbl %ebx, %ebx
jmp 0x5520
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0xe52(%rip), %rdx       # 0x63ae
leaq 0xdbe(%rip), %rcx       # 0x6321
jmp 0x55d8
movl 0x24(%r14), %ecx
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0xcf0(%rip), %rdx       # 0x6268
leaq 0xc09(%rip), %r8        # 0x6188
xorl %eax, %eax
callq 0x10f0
jmp 0x5520
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0xc23(%rip), %rdx       # 0x61ba
leaq 0xd5f(%rip), %rcx       # 0x62fd
jmp 0x5514
movq %rbp, 0x8(%rbx)
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0xc04(%rip), %rdx       # 0x61ba
leaq 0xd4c(%rip), %rcx       # 0x6309
jmp 0x5514
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0xddd(%rip), %rdx       # 0x63ae
leaq 0xd3d(%rip), %rcx       # 0x6315
xorl %eax, %eax
callq 0x10f0
jmp 0x5520