// File: /workspace/github_c_makefile_star2_O1/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 0x31dc
movl 0x24(%r14), %ecx
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x309f(%rip), %rdx      # 0x6268
leaq 0x3004(%rip), %r8       # 0x61d4
xorl %eax, %eax
callq 0x10f0
jmp 0x3285
movq 0x30(%r14), %rax
movq %rax, 0x30(%rsp)
movups 0x20(%r14), %xmm0
movaps %xmm0, 0x20(%rsp)
cmpl $0x9, 0x20(%r14)
jne 0x3268
movq %rsi, %r15
movq %r14, %rdi
movl $0x1, %esi
callq 0x2b77
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x328a
leaq 0x20(%r14), %r12
movl (%r12), %eax
cmpl $0x3, %eax
je 0x329b
cmpl $0x1, %eax
jne 0x334c
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
callq 0x4b42
movq %rax, %r13
testq %rax, %rax
je 0x3372
movq %r15, %rdi
movq %r13, %rsi
callq 0x3955
movq %rax, %r12
movq %r13, %rdi
callq *0x5ebd(%rip)           # 0x9120
jmp 0x3375
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x3137(%rip), %rdx      # 0x63ae
leaq 0x2f82(%rip), %rcx      # 0x6200
xorl %eax, %eax
callq 0x10f0
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 0x2b77
testl %eax, %eax
jne 0x328a
movl (%r12), %eax
cmpl $0x4, %eax
je 0x3410
cmpl $0x7, %eax
je 0x33cf
cmpl $0x9, %eax
jne 0x344d
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x4ec3
testq %rax, %rax
je 0x328a
movq %rax, %r15
cmpq $0x0, 0x8(%rax)
jne 0x3492
movslq 0x30(%r14), %rsi
movq 0x28(%r14), %r12
movq %r12, %rdi
callq 0x1120
movq %rax, %r13
leaq 0x1(%rax), %rdi
callq *0x5e02(%rip)           # 0x9118
movq %rax, %rbp
testq %rax, %rax
je 0x346c
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1190
movb $0x0, (%rbp,%r13)
movq %rbp, 0x8(%r15)
movq %r14, %rdi
movl $0x1, %esi
callq 0x2b77
jmp 0x3442
movl 0x24(%r14), %ecx
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x2f09(%rip), %rdx      # 0x6268
leaq 0x2ea6(%rip), %r8       # 0x620c
xorl %eax, %eax
callq 0x10f0
jmp 0x328a
xorl %r12d, %r12d
testq %r13, %r13
je 0x328a
testq %r12, %r12
jne 0x33ad
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x4d1d
movq %rax, %r12
testq %rax, %rax
je 0x328a
movq %r14, %rdi
movl $0x1, %esi
callq 0x2b77
testl %eax, %eax
jne 0x328a
movq %r14, %rdi
movq %r12, %rsi
callq 0x319f
jmp 0x3442
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 0x5029
testq %rax, %rax
je 0x328a
movq %r14, %rdi
movq %rax, %rsi
callq 0x51a1
negl %eax
sbbl %ebp, %ebp
movl %ebp, %ebx
jmp 0x328a
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x4d1d
testq %rax, %rax
je 0x328a
movq %r14, %rdi
movq %rax, %rsi
callq 0x55e4
xorl %ebx, %ebx
negl %eax
sbbl %ebx, %ebx
jmp 0x328a
movl 0x24(%r14), %ecx
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x2e08(%rip), %rdx      # 0x6268
leaq 0x2d21(%rip), %r8       # 0x6188
jmp 0x3366
movq %rbp, 0x8(%r15)
movq 0x10(%r14), %rdi
movslq 0x18(%r14), %rsi
leaq 0x2d3b(%rip), %rdx      # 0x61ba
leaq 0x2dd6(%rip), %rcx      # 0x625c
xorl %eax, %eax
callq 0x10f0
jmp 0x328a
leaq 0x2d7d(%rip), %rdi      # 0x6216
leaq 0x2d87(%rip), %rsi      # 0x6227
leaq 0x2d87(%rip), %rcx      # 0x622e
movl $0x485, %edx            # imm = 0x485
callq 0x1100