// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movl $0x7, %esi
xorl %edx, %edx
leaq 0x2297(%rip), %rcx      # 0x83f9
callq 0x3060
cmpl $0x0, %eax
je 0x6178
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6475
jmp 0x617a
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x68d0
cmpl $0x0, %eax
je 0x6196
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6475
movq -0x10(%rbp), %rax
cmpl $0x8, 0x20(%rax)
jne 0x61a5
jmp 0x6446
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x44(%rbp)
subl $0x4, %eax
je 0x6369
jmp 0x61ba
movl -0x44(%rbp), %eax
subl $0x7, %eax
je 0x62f4
jmp 0x61c8
movl -0x44(%rbp), %eax
subl $0x9, %eax
jne 0x63db
jmp 0x61d6
movq -0x18(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x61ed
movq -0x18(%rbp), %rax
movl $0x76, 0x8(%rax)
jmp 0x6204
movq -0x18(%rbp), %rax
cmpl $0x76, 0x8(%rax)
je 0x6202
movq -0x18(%rbp), %rax
movl $0x6d, 0x8(%rax)
jmp 0x6204
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x6930
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x624a
movq -0x10(%rbp), %rdi
leaq 0x21c8(%rip), %rsi      # 0x8405
callq 0x2910
movl %eax, -0x4(%rbp)
jmp 0x6475
movq -0x20(%rbp), %rdi
movslq -0x24(%rbp), %rsi
callq 0x5f50
movq -0x30(%rbp), %rcx
movq %rax, 0x8(%rcx)
cmpq $0x0, %rax
jne 0x627d
movq -0x10(%rbp), %rdi
leaq 0x21a1(%rip), %rsi      # 0x8411
callq 0x2910
movl %eax, -0x4(%rbp)
jmp 0x6475
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x69c0
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
cmpl $0x1, 0x10(%rax)
jne 0x62ab
movq -0x30(%rbp), %rax
movl (%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xc(%rax)
jmp 0x62c7
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x30(%rbp), %rcx
cmpl (%rcx), %eax
je 0x62c5
movq -0x18(%rbp), %rax
movl $0x6d, 0xc(%rax)
jmp 0x62c7
movq -0x10(%rbp), %rdi
movl $0x9, %esi
xorl %edx, %edx
leaq 0x2144(%rip), %rcx      # 0x841d
callq 0x3060
cmpl $0x0, %eax
je 0x62ef
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6475
jmp 0x63f7
movq -0x18(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x630b
movq -0x18(%rbp), %rax
movl $0x61, 0x8(%rax)
jmp 0x6322
movq -0x18(%rbp), %rax
cmpl $0x61, 0x8(%rax)
je 0x6320
movq -0x18(%rbp), %rax
movl $0x6d, 0x8(%rax)
jmp 0x6322
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x6ab0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x6346
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6475
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x6140
cmpl $0x0, %eax
je 0x6364
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6475
jmp 0x63f7
movq -0x18(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x6380
movq -0x18(%rbp), %rax
movl $0x74, 0x8(%rax)
jmp 0x6397
movq -0x18(%rbp), %rax
cmpl $0x74, 0x8(%rax)
je 0x6395
movq -0x18(%rbp), %rax
movl $0x6d, 0x8(%rax)
jmp 0x6397
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x6b80
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x63bb
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6475
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x6480
cmpl $0x0, %eax
je 0x63d9
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6475
jmp 0x63f7
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x24(%rax), %esi
leaq 0x1ea3(%rip), %rdx      # 0x8290
callq 0x3010
movl %eax, -0x4(%rbp)
jmp 0x6475
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x68d0
cmpl $0x0, %eax
je 0x6410
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6475
movq -0x10(%rbp), %rax
cmpl $0x2, 0x20(%rax)
jne 0x6444
movq -0x10(%rbp), %rdi
movl $0x2, %esi
xorl %edx, %edx
leaq 0x1ffd(%rip), %rcx      # 0x8429
callq 0x3060
cmpl $0x0, %eax
je 0x643f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6475
jmp 0x617a
jmp 0x6446
movq -0x10(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
leaq 0x1fda(%rip), %rcx      # 0x8435
callq 0x3060
cmpl $0x0, %eax
je 0x646e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6475
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop