// File: /workspace/github_c_makefile_star2_O2/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 0x2b18
movl 0x24(%r14), %ecx
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x2793(%rip), %rdx      # 0x5298
leaq 0x26f8(%rip), %r8       # 0x5204
xorl %eax, %eax
callq 0x10e0
pushq $-0x1
popq %rbx
jmp 0x2b4a
movq %rsi, %r15
movq 0x30(%r14), %rax
movq %rax, 0x30(%rsp)
movups 0x20(%r14), %xmm0
movaps %xmm0, 0x20(%rsp)
leaq 0x26fb(%rip), %rcx      # 0x5230
pushq $0x9
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x2e1f
pushq $-0x1
popq %rbx
testl %eax, %eax
je 0x2b5b
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x20(%r14), %r12
movl (%r12), %eax
cmpl $0x3, %eax
je 0x2c01
cmpl $0x1, %eax
jne 0x2c84
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
callq 0x41f4
testq %rax, %rax
je 0x2b4a
movq %rax, %r13
movq %r15, %rdi
movq %rax, %rsi
callq 0x324b
movq %rax, %r12
movq %r13, %rdi
callq *0x5569(%rip)           # 0x8118
testq %r12, %r12
jne 0x2bde
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x4327
testq %rax, %rax
je 0x2b4a
movq %rax, %r12
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x2583
testl %eax, %eax
jne 0x2b4a
movq %r14, %rdi
movq %r12, %rsi
callq 0x2adb
jmp 0x2d0f
movq %r14, %rdi
xorl %esi, %esi
callq 0x2583
testl %eax, %eax
jne 0x2b4a
movl (%r12), %eax
cmpl $0x4, %eax
je 0x2cdd
cmpl $0x7, %eax
je 0x2c9c
cmpl $0x9, %eax
jne 0x2d1a
movl 0x24(%rsp), %ebp
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
callq 0x41f4
testq %rax, %rax
je 0x2b4a
movq %rax, %r12
movq %r15, %rdi
movq %rax, %rsi
callq 0x4aef
testl %eax, %eax
je 0x2d2a
movq %r12, %rdi
callq *0x54a3(%rip)           # 0x8118
movq %r14, %rdi
movl %ebp, %esi
callq 0x4a85
jmp 0x2b4a
movl 0x24(%r14), %esi
leaq 0x25ad(%rip), %rdx      # 0x523c
movq %r14, %rdi
callq 0x2e01
jmp 0x2b4a
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 0x4495
testq %rax, %rax
je 0x2b4a
movq %r14, %rdi
movq %rax, %rsi
callq 0x4597
negl %eax
sbbl %ebp, %ebp
movl %ebp, %ebx
jmp 0x2b4a
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x4327
testq %rax, %rax
je 0x2b4a
movq %r14, %rdi
movq %rax, %rsi
callq 0x4882
xorl %ebx, %ebx
negl %eax
sbbl %ebx, %ebx
jmp 0x2b4a
movl 0x24(%r14), %esi
leaq 0x2493(%rip), %rdx      # 0x51b8
jmp 0x2c8f
movl 0xc(%r15), %ebp
movq 0x10(%r15), %rdi
movl %ebp, %esi
callq 0x4aa0
testq %rax, %rax
je 0x2da4
movq %rax, %r13
movslq %ebp, %rbp
movq %rax, 0x10(%r15)
pushq $0x10
popq %rdi
callq *0x53bf(%rip)           # 0x8110
testq %rax, %rax
je 0x2db6
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %rax, (%r13,%rbp,8)
movq 0x10(%r15), %rax
movslq 0xc(%r15), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0xc(%r15)
movq (%rax,%rcx,8), %r15
movq %r12, (%r15)
cmpq $0x0, 0x8(%r15)
jne 0x2de2
movslq 0x30(%r14), %rsi
movq 0x28(%r14), %rdi
callq 0x4457
movq %rax, 0x8(%r15)
testq %rax, %rax
je 0x2dce
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x2583
jmp 0x2d0f
movq %r12, %rdi
callq *0x536b(%rip)           # 0x8118
leaq 0x2541(%rip), %rsi      # 0x52f5
jmp 0x2dd5
andq $0x0, (%r13,%rbp,8)
movq %r12, %rdi
callq *0x5353(%rip)           # 0x8118
leaq 0x2534(%rip), %rsi      # 0x5300
jmp 0x2dd5
leaq 0x24b7(%rip), %rsi      # 0x528c
movq %r14, %rdi
callq 0x2567
jmp 0x2b4a
leaq 0x245d(%rip), %rdi      # 0x5246
leaq 0x2467(%rip), %rsi      # 0x5257
leaq 0x2467(%rip), %rcx      # 0x525e
movl $0x485, %edx            # imm = 0x485
callq 0x10f0