// File: /workspace/github_c_makefile_star2_O0/neovim[P]libtermkey/driver-ti.c
// Function: peekkey
static TermKeyResult peekkey(TermKey *tk, void *info, TermKeyKey *key, int force, size_t *nbytep)
{
  TermKeyTI *ti = info;

  if(tk->buffcount == 0)
    return tk->is_closed ? TERMKEY_RES_EOF : TERMKEY_RES_NONE;

  struct trie_node *p = ti->root;

  unsigned int pos = 0;
  while(pos < tk->buffcount) {
    p = lookup_next(p, CHARAT(pos));
    if(!p)
      break;

    pos++;

    if(p->type != TYPE_KEY)
      continue;

    struct trie_node_key *nk = (struct trie_node_key*)p;
    if(nk->key.type == TERMKEY_TYPE_MOUSE) {
      tk->buffstart += pos;
      tk->buffcount -= pos;

      TermKeyResult mouse_result = (*tk->method.peekkey_mouse)(tk, key, nbytep);

      tk->buffstart -= pos;
      tk->buffcount += pos;

      if(mouse_result == TERMKEY_RES_KEY)
        *nbytep += pos;

      return mouse_result;
    }

    key->type      = nk->key.type;
    key->code.sym  = nk->key.sym;
    key->modifiers = nk->key.modifier_set;
    *nbytep = pos;
    return TERMKEY_RES_KEY;
  }

  // If p is not NULL then we hadn't walked off the end yet, so we have a
  // partial match
  if(p && !force)
    return TERMKEY_RES_AGAIN;

  return TERMKEY_RES_NONE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x886e
movq -0x10(%rbp), %rax
movsbl 0x8c(%rax), %edx
xorl %eax, %eax
movl $0x2, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0x89cd
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jae 0x89b0
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl -0x44(%rbp), %edx
addq %rdx, %rcx
movzbl (%rax,%rcx), %esi
callq 0x9350
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x88c5
jmp 0x89b0
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movq -0x40(%rbp), %rax
cmpl $0x0, (%rax)
je 0x88d9
jmp 0x8881
movq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
cmpl $0x3, 0x4(%rax)
jne 0x8972
movl -0x44(%rbp), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
addq 0x18(%rax), %rcx
movq %rcx, 0x18(%rax)
movl -0x44(%rbp), %eax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq 0x2b8(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq *%rax
movl %eax, -0x54(%rbp)
movl -0x44(%rbp), %eax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x18(%rax)
movl -0x44(%rbp), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
addq 0x20(%rax), %rcx
movq %rcx, 0x20(%rax)
cmpl $0x1, -0x54(%rbp)
jne 0x896a
movl -0x44(%rbp), %eax
movl %eax, %ecx
movq -0x30(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movl -0x54(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x89cd
movq -0x50(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x50(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x50(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x10(%rax)
movl -0x44(%rbp), %eax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x89cd
cmpq $0x0, -0x40(%rbp)
je 0x89c6
cmpl $0x0, -0x24(%rbp)
jne 0x89c6
movl $0x3, -0x4(%rbp)
jmp 0x89cd
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)