// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
testb $0x1, 0x9(%rax)
je 0x2c6c
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x24(%rax), %esi
leaq 0x567d(%rip), %rdx      # 0x82dc
callq 0x5970
movl %eax, -0x4(%rbp)
jmp 0x2ff6
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
movq %rcx, -0x30(%rbp)
movq 0x28(%rax), %rcx
movq %rcx, -0x28(%rbp)
movq 0x30(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movl $0x9, %esi
movl $0x1, %edx
leaq 0x566b(%rip), %rcx      # 0x8308
callq 0x3060
cmpl $0x0, %eax
je 0x2cb3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2ff6
movq -0x10(%rbp), %rax
cmpl $0x1, 0x20(%rax)
jne 0x2db3
movq $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x30(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x59c0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x2d06
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2ff6
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x3b80
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rdi
callq 0x3500
cmpq $0x0, -0x38(%rbp)
jne 0x2d6a
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x30(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x5c20
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x2d68
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2ff6
jmp 0x2d6a
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x2950
cmpl $0x0, %eax
je 0x2d89
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2ff6
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x2c30
cmpl $0x0, %eax
je 0x2da7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2ff6
movl $0x0, -0x4(%rbp)
jmp 0x2ff6
movq -0x10(%rbp), %rax
cmpl $0x3, 0x20(%rax)
je 0x2ddc
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x24(%rax), %esi
leaq 0x5545(%rip), %rdx      # 0x8314
callq 0x3010
movl %eax, -0x4(%rbp)
jmp 0x2ff6
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x2950
cmpl $0x0, %eax
je 0x2df8
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2ff6
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x74(%rbp)
subl $0x4, %eax
je 0x2f7a
jmp 0x2e0d
movl -0x74(%rbp), %eax
subl $0x7, %eax
je 0x2f10
jmp 0x2e1b
movl -0x74(%rbp), %eax
subl $0x9, %eax
jne 0x2fdc
jmp 0x2e29
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x30(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x5dd0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x2e6a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2ff6
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
movq %rcx, -0x60(%rbp)
movq 0x28(%rax), %rcx
movq %rcx, -0x58(%rbp)
movq 0x30(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x2e93
jmp 0x2eb2
leaq 0x5484(%rip), %rdi      # 0x831e
leaq 0x548e(%rip), %rsi      # 0x832f
movl $0x485, %edx            # imm = 0x485
leaq 0x5489(%rip), %rcx      # 0x8336
callq 0x10f0
movq -0x58(%rbp), %rdi
movslq -0x50(%rbp), %rsi
callq 0x5f50
movq -0x48(%rbp), %rcx
movq %rax, 0x8(%rcx)
cmpq $0x0, %rax
jne 0x2ee5
movq -0x10(%rbp), %rdi
leaq 0x548c(%rip), %rsi      # 0x8364
callq 0x2910
movl %eax, -0x4(%rbp)
jmp 0x2ff6
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x2950
cmpl $0x0, %eax
je 0x2f04
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2ff6
movl $0x0, -0x4(%rbp)
jmp 0x2ff6
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x30(%rbp), %rax
xorl %edx, %edx
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x5fc0
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0x2f53
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2ff6
movq -0x10(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x6140
cmpl $0x0, %eax
je 0x2f71
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2ff6
movl $0x0, -0x4(%rbp)
jmp 0x2ff6
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x30(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x5c20
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x2fb8
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2ff6
movq -0x10(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x6480
cmpl $0x0, %eax
je 0x2fd3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2ff6
movl $0x0, -0x4(%rbp)
jmp 0x2ff6
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x24(%rax), %esi
leaq 0x52a2(%rip), %rdx      # 0x8290
callq 0x3010
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)