// File: /workspace/github_c_makefile_star2_O0/cktan[P]tomlc99/toml.c
// Function: walk_tabpath
static int walk_tabpath(context_t *ctx) {
  /* start from root */
  toml_table_t *curtab = ctx->root;

  for (int i = 0; i < ctx->tpath.top; i++) {
    const char *key = ctx->tpath.key[i];

    toml_keyval_t *nextval = 0;
    toml_array_t *nextarr = 0;
    toml_table_t *nexttab = 0;
    switch (check_key(curtab, key, &nextval, &nextarr, &nexttab)) {
    case 't':
      /* found a table. nexttab is where we will go next. */
      break;

    case 'a':
      /* found an array. nexttab is the last table in the array. */
      if (nextarr->kind != 't')
        return e_internal(ctx, FLINE);

      if (nextarr->nitem == 0)
        return e_internal(ctx, FLINE);

      nexttab = nextarr->item[nextarr->nitem - 1].tab;
      break;

    case 'v':
      return e_keyexists(ctx, ctx->tpath.tok[i].lineno);

    default: { /* Not found. Let's create an implicit table. */
      int n = curtab->ntab;
      toml_table_t **base =
          (toml_table_t **)expand_ptrarr((void **)curtab->tab, n);
      if (0 == base)
        return e_outofmemory(ctx, FLINE);

      curtab->tab = base;

      if (0 == (base[n] = (toml_table_t *)CALLOC(1, sizeof(*base[n]))))
        return e_outofmemory(ctx, FLINE);

      if (0 == (base[n]->key = STRDUP(key)))
        return e_outofmemory(ctx, FLINE);

      nexttab = curtab->tab[curtab->ntab++];

      /* tabs created by walk_tabpath are considered implicit */
      nexttab->implicit = true;
    } break;
    }

    /* switch to next tab */
    curtab = nexttab;
  }

  /* save it */
  ctx->curtab = curtab;

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x48(%rcx), %eax
jge 0x713f
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq 0x50(%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
leaq -0x30(%rbp), %rdx
leaq -0x38(%rbp), %rcx
leaq -0x40(%rbp), %r8
callq 0x6620
movl %eax, %ecx
movl %ecx, -0x54(%rbp)
subl $0x61, %eax
je 0x6fa9
jmp 0x6f8d
movl -0x54(%rbp), %eax
subl $0x74, %eax
je 0x6fa4
jmp 0x6f97
movl -0x54(%rbp), %eax
subl $0x76, %eax
je 0x7016
jmp 0x7041
jmp 0x7129
movq -0x38(%rbp), %rax
cmpl $0x74, 0x8(%rax)
je 0x6fcb
movq -0x10(%rbp), %rdi
leaq 0x1640(%rip), %rsi      # 0x85fe
callq 0x6cd0
movl %eax, -0x4(%rbp)
jmp 0x7152
movq -0x38(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x6fed
movq -0x10(%rbp), %rdi
leaq 0x162a(%rip), %rsi      # 0x860a
callq 0x6cd0
movl %eax, -0x4(%rbp)
jmp 0x7152
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x38(%rbp), %rcx
movl 0x10(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x7129
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
addq $0x48, %rax
addq $0x58, %rax
movslq -0x1c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %esi
callq 0x67d0
movl %eax, -0x4(%rbp)
jmp 0x7152
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rdi
movl -0x44(%rbp), %esi
callq 0x6810
movq %rax, -0x50(%rbp)
xorl %eax, %eax
cmpq -0x50(%rbp), %rax
jne 0x707f
movq -0x10(%rbp), %rdi
leaq 0x15a4(%rip), %rsi      # 0x8616
callq 0x2910
movl %eax, -0x4(%rbp)
jmp 0x7152
movq -0x50(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x30(%rax)
movl $0x1, %edi
movl $0x38, %esi
callq 0x28b0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rdx
movq %rcx, (%rax,%rdx,8)
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x70c8
movq -0x10(%rbp), %rdi
leaq 0x1567(%rip), %rsi      # 0x8622
callq 0x2910
movl %eax, -0x4(%rbp)
jmp 0x7152
movq -0x28(%rbp), %rdi
callq 0x7160
movq %rax, %rcx
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, (%rax)
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x70ff
movq -0x10(%rbp), %rdi
leaq 0x1539(%rip), %rsi      # 0x862e
callq 0x2910
movl %eax, -0x4(%rbp)
jmp 0x7152
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x18(%rbp), %rdx
movl 0x28(%rdx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x28(%rdx)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movb $0x1, 0x8(%rax)
movq -0x40(%rbp), %rax
movq %rax, -0x18(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x6f2f
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)