// File: /workspace/github_c_makefile_star2_O3/cktan[P]tomlc99/toml.c
// Function: parse_keyval
static int parse_keyval(context_t *ctx, toml_table_t *tab) {
  if (tab->readonly) {
    return e_forbid(ctx, ctx->tok.lineno,
                    "cannot insert new entry into existing table");
  }

  token_t key = ctx->tok;
  if (eat_token(ctx, STRING, 1, FLINE))
    return -1;

  if (ctx->tok.tok == DOT) {
    /* handle inline dotted key.
       e.g.
       physical.color = "orange"
       physical.shape = "round"
    */
    toml_table_t *subtab = 0;
    {
      char *subtabstr = normalize_key(ctx, key);
      if (!subtabstr)
        return -1;

      subtab = toml_table_in(tab, subtabstr);
      xfree(subtabstr);
    }
    if (!subtab) {
      subtab = create_keytable_in_table(ctx, tab, key);
      if (!subtab)
        return -1;
    }
    if (next_token(ctx, 1))
      return -1;
    if (parse_keyval(ctx, subtab))
      return -1;
    return 0;
  }

  if (ctx->tok.tok != EQUAL) {
    return e_syntax(ctx, ctx->tok.lineno, "missing =");
  }

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

  switch (ctx->tok.tok) {
  case STRING: { /* key = "value" */
    toml_keyval_t *keyval = create_keyval_in_table(ctx, tab, key);
    if (!keyval)
      return -1;
    token_t val = ctx->tok;

    assert(keyval->val == 0);
    if (!(keyval->val = STRNDUP(val.ptr, val.len)))
      return e_outofmemory(ctx, FLINE);

    if (next_token(ctx, 1))
      return -1;

    return 0;
  }

  case LBRACKET: { /* key = [ array ] */
    toml_array_t *arr = create_keyarray_in_table(ctx, tab, key, 0);
    if (!arr)
      return -1;
    if (parse_array(ctx, arr))
      return -1;
    return 0;
  }

  case LBRACE: { /* key = { table } */
    toml_table_t *nxttab = create_keytable_in_table(ctx, tab, key);
    if (!nxttab)
      return -1;
    if (parse_inline_table(ctx, nxttab))
      return -1;
    return 0;
  }

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %r14
cmpb $0x1, 0x9(%rsi)
jne 0x301d
movl 0x24(%r14), %ecx
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x3282(%rip), %rdx      # 0x628c
leaq 0x31e7(%rip), %r8       # 0x61f8
xorl %eax, %eax
callq 0x10e0
jmp 0x3119
movq 0x30(%r14), %rax
movq %rax, 0x30(%rsp)
movups 0x20(%r14), %xmm0
movaps %xmm0, 0x20(%rsp)
cmpl $0x9, 0x20(%r14)
jne 0x30fc
movq %rsi, %r15
movq %r14, %rdi
movl $0x1, %esi
callq 0x2988
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x311e
leaq 0x20(%r14), %r12
movl (%r12), %eax
cmpl $0x3, %eax
je 0x312f
cmpl $0x1, %eax
jne 0x31e0
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
callq 0x487c
testq %rax, %rax
je 0x311e
movq %rax, %r13
movq %r15, %rdi
movq %rax, %rsi
callq 0x376f
movq %rax, %r12
movq %r13, %rdi
callq *0x6068(%rip)           # 0x9118
testq %r12, %r12
jne 0x30db
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x4a57
testq %rax, %rax
je 0x311e
movq %rax, %r12
movq %r14, %rdi
movl $0x1, %esi
callq 0x2988
testl %eax, %eax
jne 0x311e
movq %r14, %rdi
movq %r12, %rsi
callq 0x2fe0
jmp 0x3279
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x32c7(%rip), %rdx      # 0x63d2
leaq 0x3112(%rip), %rcx      # 0x6224
xorl %eax, %eax
callq 0x10e0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
xorl %esi, %esi
callq 0x2988
testl %eax, %eax
jne 0x311e
movl (%r12), %eax
cmpl $0x4, %eax
je 0x3247
cmpl $0x7, %eax
je 0x3206
cmpl $0x9, %eax
jne 0x3284
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x4bf7
testq %rax, %rax
je 0x311e
movq %rax, %r15
cmpq $0x0, 0x8(%rax)
jne 0x32cd
movslq 0x30(%r14), %rsi
movq 0x28(%r14), %r12
movq %r12, %rdi
callq 0x1110
movq %rax, %r13
leaq 0x1(%rax), %rdi
callq *0x5f66(%rip)           # 0x9110
testq %rax, %rax
je 0x32a3
movq %rax, %rbp
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1180
movb $0x0, (%rbp,%r13)
movq %rbp, 0x8(%r15)
movq %r14, %rdi
movl $0x1, %esi
callq 0x2988
jmp 0x3279
movl 0x24(%r14), %ecx
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x3099(%rip), %rdx      # 0x628c
leaq 0x3036(%rip), %r8       # 0x6230
xorl %eax, %eax
callq 0x10e0
jmp 0x311e
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
xorl %ebp, %ebp
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x4d57
testq %rax, %rax
je 0x311e
movq %r14, %rdi
movq %rax, %rsi
callq 0x4ec9
negl %eax
sbbl %ebp, %ebp
movl %ebp, %ebx
jmp 0x311e
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x4a57
testq %rax, %rax
je 0x311e
movq %r14, %rdi
movq %rax, %rsi
callq 0x52ed
xorl %ebx, %ebx
negl %eax
sbbl %ebx, %ebx
jmp 0x311e
movl 0x24(%r14), %ecx
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x2ff5(%rip), %rdx      # 0x628c
leaq 0x2f0e(%rip), %r8       # 0x61ac
jmp 0x31fa
movq $0x0, 0x8(%r15)
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x2f24(%rip), %rdx      # 0x61de
leaq 0x2fbf(%rip), %rcx      # 0x6280
xorl %eax, %eax
callq 0x10e0
jmp 0x311e
leaq 0x2f66(%rip), %rdi      # 0x623a
leaq 0x2f70(%rip), %rsi      # 0x624b
leaq 0x2f70(%rip), %rcx      # 0x6252
movl $0x485, %edx            # imm = 0x485
callq 0x10f0