LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/termkey.c
// Function: termkey_advisereadable
TermKeyResult termkey_advisereadable(TermKey *tk)
{
  ssize_t len;

  if(tk->fd == -1) {
    errno = EBADF;
    return TERMKEY_RES_ERROR;
  }

  if(tk->buffstart) {
    memmove(tk->buffer, tk->buffer + tk->buffstart, tk->buffcount);
    tk->buffstart = 0;
  }

  /* Not expecting it ever to be greater but doesn't hurt to handle that */
  if(tk->buffcount >= tk->buffsize) {
    errno = ENOMEM;
    return TERMKEY_RES_ERROR;
  }

retry:
  len = read(tk->fd, tk->buffer + tk->buffcount, tk->buffsize - tk->buffcount);

  if(len == -1) {
    if(errno == EAGAIN)
      return TERMKEY_RES_NONE;
    else if(errno == EINTR && !(tk->flags & TERMKEY_FLAG_EINTR))
      goto retry;
    else
      return TERMKEY_RES_ERROR;
  }
  else if(len < 1) {
    tk->is_closed = 1;
    return TERMKEY_RES_NONE;
  }
  else {
    tk->buffcount += len;
    return TERMKEY_RES_AGAIN;
  }
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
cmpl $-0x1, (%rdi)
je 0x3e04
movq %rdi, %rbx
movq 0x18(%rdi), %rsi
testq %rsi, %rsi
je 0x3dc4
movq 0x10(%rbx), %rdi
movq 0x20(%rbx), %rdx
addq %rdi, %rsi
callq 0x3230
andq $0x0, 0x18(%rbx)
movq 0x20(%rbx), %rax
cmpq 0x28(%rbx), %rax
jae 0x3e11
pushq $0x4
popq %rbp
movl (%rbx), %edi
movq 0x20(%rbx), %rax
movq 0x10(%rbx), %rsi
addq %rax, %rsi
movq 0x28(%rbx), %rdx
subq %rax, %rdx
callq 0x3150
cmpq $-0x1, %rax
jne 0x3e2f
callq 0x30a0
movl (%rax), %eax
cmpl $0x4, %eax
jne 0x3e28
testb $-0x80, 0x4(%rbx)
je 0x3dd1
jmp 0x3e1f
callq 0x30a0
movl $0x9, (%rax)
jmp 0x3e1c
callq 0x30a0
movl $0xc, (%rax)
pushq $0x4
popq %rbp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
cmpl $0xb, %eax
je 0x3e43
jmp 0x3e1f
testq %rax, %rax
jle 0x3e3c
addq %rax, 0x20(%rbx)
pushq $0x3
jmp 0x3e1e
movb $0x1, 0x8c(%rbx)
xorl %ebp, %ebp
jmp 0x3e1f
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/termkey.c
// Function: termkey_push_bytes
size_t termkey_push_bytes(TermKey *tk, const char *bytes, size_t len)
{
  if(tk->buffstart) {
    memmove(tk->buffer, tk->buffer + tk->buffstart, tk->buffcount);
    tk->buffstart = 0;
  }

  /* Not expecting it ever to be greater but doesn't hurt to handle that */
  if(tk->buffcount >= tk->buffsize) {
    errno = ENOMEM;
    return (size_t)-1;
  }

  if(len > tk->buffsize - tk->buffcount)
    len = tk->buffsize - tk->buffcount;

  // memcpy(), not strncpy() in case of null bytes in input
  memcpy(tk->buffer + tk->buffcount, bytes, len);
  tk->buffcount += len;

  return len;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq 0x18(%rdi), %rsi
testq %rsi, %rsi
je 0x3e73
movq 0x10(%r14), %rdi
movq 0x20(%r14), %rdx
addq %rdi, %rsi
callq 0x3230
andq $0x0, 0x18(%r14)
movq 0x20(%r14), %rdi
movq 0x28(%r14), %rax
subq %rdi, %rax
jbe 0x3e9c
cmpq %rbx, %rax
cmovbq %rax, %rbx
addq 0x10(%r14), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x31a0
addq %rbx, 0x20(%r14)
jmp 0x3eaa
callq 0x30a0
movl $0xc, (%rax)
pushq $-0x1
popq %rbx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/termkey.c
// Function: termkey_register_keyname
TermKeySym termkey_register_keyname(TermKey *tk, TermKeySym sym, const char *name)
{
  if(!sym)
    sym = tk->nkeynames;

  if(sym >= tk->nkeynames) {
    const char **new_keynames = realloc(tk->keynames, sizeof(new_keynames[0]) * (sym + 1));
    if(!new_keynames)
      return -1;

    tk->keynames = new_keynames;

    // Fill in the hole
    for(int i = tk->nkeynames; i < sym; i++)
      tk->keynames[i] = NULL;

    tk->nkeynames = sym + 1;
  }

  tk->keynames[sym] = name;

  return sym;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rdi, %r15
movl 0x90(%rdi), %eax
testl %esi, %esi
je 0x3ed6
movl %esi, %ebx
cmpl %esi, %eax
jle 0x3ed8
movslq %ebx, %r12
jmp 0x3f22
movl %eax, %ebx
movq 0x98(%r15), %rdi
movslq %ebx, %r12
leaq 0x8(,%r12,8), %rsi
callq 0x31f0
testq %rax, %rax
je 0x3f2f
leal 0x1(%rbx), %ecx
movq %rax, 0x98(%r15)
movslq 0x90(%r15), %rax
cmpq %r12, %rax
jge 0x3f1b
movq 0x98(%r15), %rdx
andq $0x0, (%rdx,%rax,8)
incq %rax
jmp 0x3f05
movl %ecx, 0x90(%r15)
movq 0x98(%r15), %rax
movq %r14, (%rax,%r12,8)
jmp 0x3f32
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/termkey.c
// Function: termkey_lookup_keyname_format
static const char *termkey_lookup_keyname_format(TermKey *tk, const char *str, TermKeySym *sym, TermKeyFormat format)
{
  /* We store an array, so we can't do better than a linear search. Doesn't
   * matter because user won't be calling this too often */

  for(*sym = 0; *sym < tk->nkeynames; (*sym)++) {
    const char *thiskey = tk->keynames[*sym];
    if(!thiskey)
      continue;
    size_t len = strlen(thiskey);
    if(format & TERMKEY_FORMAT_LOWERSPACE) {
      const char *thisstr = str;
      if(strpncmp_camel(&thisstr, &thiskey, len) == 0)
          return thisstr;
    }
    else {
      if(strncmp(str, thiskey, len) == 0)
        return (char *)str + len;
    }
  }

  return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
xorl %ecx, %ecx
movq %rsi, 0x20(%rsp)
movl %ebp, 0xc(%rsp)
movq %rdx, 0x18(%rsp)
movq %rdi, 0x10(%rsp)
movl %ecx, (%r14)
movslq 0x90(%r15), %rax
cmpq %rax, %rcx
jge 0x40b8
movq 0x98(%r15), %rax
movq %rcx, 0x28(%rsp)
movq (%rax,%rcx,8), %r13
testq %r13, %r13
je 0x40ab
movq %r13, %rdi
callq 0x3100
testb $0x40, %bpl
jne 0x3fed
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
movq %rax, %r12
callq 0x30d0
testl %eax, %eax
jne 0x40ab
jmp 0x40bd
xorl %edx, %edx
xorl %r15d, %r15d
movq %rbx, %r12
movq %r13, 0x38(%rsp)
movq %rax, 0x30(%rsp)
movsbl (%r12), %r14d
testl %r14d, %r14d
je 0x4015
movb (%r13,%rdx), %bl
cmpq %rdx, %rax
jne 0x4023
jmp 0x4093
movb (%r13,%rdx), %bl
testb %bl, %bl
je 0x4090
cmpq %rdx, %rax
je 0x4090
movq %rdx, 0x40(%rsp)
callq 0x32e0
movq (%rax), %rax
movsbq %bl, %rbp
movl (%rax,%rbp,4), %r13d
callq 0x32f0
movq (%rax), %rax
movzwl (%rax,%rbp,2), %eax
movl %eax, %ecx
shrl $0x8, %ecx
testl %r15d, %r15d
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x4065
cmpb $0x20, %r14b
jne 0x4093
movsbl 0x1(%r12), %r14d
incq %r12
movsbl %r13b, %ecx
cmpl %r14d, %ecx
jne 0x4093
andl $0x200, %eax            # imm = 0x200
incq %r12
movq 0x40(%rsp), %rdx
incq %rdx
movl %eax, %r15d
movq 0x38(%rsp), %r13
movq 0x30(%rsp), %rax
jmp 0x3fff
xorl %r14d, %r14d
cmpb %bl, %r14b
movq 0x20(%rsp), %rbx
movl 0xc(%rsp), %ebp
movq 0x18(%rsp), %r14
movq 0x10(%rsp), %r15
je 0x40c3
movq 0x28(%rsp), %rcx
incq %rcx
jmp 0x3f95
xorl %r12d, %r12d
jmp 0x40c3
addq %r12, %rbx
movq %rbx, %r12
movq %r12, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/termkey.c
// Function: parse_utf8
static TermKeyResult parse_utf8(const unsigned char *bytes, size_t len, long *cp, size_t *nbytep)
{
  unsigned int nbytes;

  unsigned char b0 = bytes[0];

  if(b0 < 0x80) {
    // Single byte ASCII
    *cp = b0;
    *nbytep = 1;
    return TERMKEY_RES_KEY;
  }
  else if(b0 < 0xc0) {
    // Starts with a continuation byte - that's not right
    *cp = UTF8_INVALID;
    *nbytep = 1;
    return TERMKEY_RES_KEY;
  }
  else if(b0 < 0xe0) {
    nbytes = 2;
    *cp = b0 & 0x1f;
  }
  else if(b0 < 0xf0) {
    nbytes = 3;
    *cp = b0 & 0x0f;
  }
  else if(b0 < 0xf8) {
    nbytes = 4;
    *cp = b0 & 0x07;
  }
  else if(b0 < 0xfc) {
    nbytes = 5;
    *cp = b0 & 0x03;
  }
  else if(b0 < 0xfe) {
    nbytes = 6;
    *cp = b0 & 0x01;
  }
  else {
    *cp = UTF8_INVALID;
    *nbytep = 1;
    return TERMKEY_RES_KEY;
  }

  for(unsigned int b = 1; b < nbytes; b++) {
    unsigned char cb;

    if(b >= len)
      return TERMKEY_RES_AGAIN;

    cb = bytes[b];
    if(cb < 0x80 || cb >= 0xc0) {
      *cp = UTF8_INVALID;
      *nbytep = b;
      return TERMKEY_RES_KEY;
    }

    *cp <<= 6;
    *cp |= cb & 0x3f;
  }

  // Check for overlong sequences
  if(nbytes > utf8_seqlen(*cp))
    *cp = UTF8_INVALID;

  // Check for UTF-16 surrogates or invalid *cps
  if((*cp >= 0xD800 && *cp <= 0xDFFF) ||
     *cp == 0xFFFE ||
     *cp == 0xFFFF)
    *cp = UTF8_INVALID;

  *nbytep = nbytes;
  return TERMKEY_RES_KEY;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r14
movzbl (%rdi), %ecx
testb %cl, %cl
js 0x49e8
pushq $0x1
popq %r12
jmp 0x4aa9
cmpb $-0x40, %cl
jae 0x49fb
pushq $0x1
popq %r12
movl $0xfffd, %ecx           # imm = 0xFFFD
jmp 0x4aa9
pushq $0x3
popq %rax
cmpb $-0x20, %cl
jae 0x4a0c
pushq $0x2
popq %rdx
pushq $0x1f
popq %r12
jmp 0x4a1b
cmpb $-0x10, %cl
jae 0x4abe
pushq $0xf
popq %r12
movl %eax, %edx
movl %r12d, %r15d
andl %ecx, %r15d
movq %r15, (%r14)
movl %edx, %r12d
pushq $0x1
popq %rdx
cmpq %rdx, %r12
je 0x4a4f
cmpq %rsi, %rdx
jae 0x4ab2
movzbl (%rdi,%rdx), %ecx
cmpb $-0x41, %cl
jg 0x4aa1
shlq $0x6, %r15
andl $0x3f, %ecx
orq %rcx, %r15
movq %r15, (%r14)
incq %rdx
jmp 0x4a2a
movq %r15, %rdi
callq 0x4ef8
cmpl %eax, %r12d
seta %al
movl $0xfffd, %ecx           # imm = 0xFFFD
cmovaq %rcx, %r15
movq %r15, %rdx
andq $-0x800, %rdx           # imm = 0xF800
cmpq $0xd800, %rdx           # imm = 0xD800
sete %dl
movq %r15, %rsi
andq $-0x2, %rsi
cmpq $0xfffe, %rsi           # imm = 0xFFFE
sete %sil
orb %dl, %sil
cmovneq %rcx, %r15
orb %al, %sil
movq %r15, %rcx
cmpb $0x1, %sil
je 0x4aa9
jmp 0x4aac
movl $0xfffd, %ecx           # imm = 0xFFFD
movq %rdx, %r12
movq %rcx, (%r14)
movq %r12, (%rbx)
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
cmpb $-0x8, %cl
jae 0x4acd
pushq $0x4
popq %rdx
pushq $0x7
jmp 0x4a08
cmpb $-0x4, %cl
jae 0x4adc
pushq $0x5
popq %rdx
pushq $0x3
jmp 0x4a08
pushq $0x1
popq %r12
cmpb $-0x3, %cl
ja 0x49f1
pushq $0x6
popq %rdx
jmp 0x4a1b
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/termkey.c
// Function: peekkey_mouse
static TermKeyResult peekkey_mouse(TermKey *tk, TermKeyKey *key, size_t *nbytep)
{
  if(tk->buffcount < 3)
    return TERMKEY_RES_AGAIN;

  key->type = TERMKEY_TYPE_MOUSE;
  key->code.mouse[0] = CHARAT(0) - 0x20;
  key->code.mouse[1] = CHARAT(1) - 0x20;
  key->code.mouse[2] = CHARAT(2) - 0x20;
  key->code.mouse[3] = 0;

  key->modifiers     = (key->code.mouse[0] & 0x1c) >> 2;
  key->code.mouse[0] &= ~0x1c;

  *nbytep = 3;
  return TERMKEY_RES_KEY;
}

// Assembly:
cmpq $0x3, 0x20(%rdi)
jae 0x4e98
pushq $0x3
popq %rax
retq
movl $0x3, (%rsi)
movq 0x10(%rdi), %rax
movq 0x18(%rdi), %rcx
movzbl (%rax,%rcx), %eax
leal -0x20(%rax), %ecx
movb %cl, 0x8(%rsi)
movq 0x10(%rdi), %r8
movq 0x18(%rdi), %r9
movb 0x1(%r8,%r9), %r8b
addb $-0x20, %r8b
movb %r8b, 0x9(%rsi)
movq 0x10(%rdi), %r8
movq 0x18(%rdi), %rdi
movb 0x2(%r8,%rdi), %dil
addb $-0x20, %dil
movb %dil, 0xa(%rsi)
movb $0x0, 0xb(%rsi)
shrl $0x2, %eax
andl $0x7, %eax
movl %eax, 0x10(%rsi)
andb $-0x1d, %cl
movb %cl, 0x8(%rsi)
movq $0x3, (%rdx)
pushq $0x1
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-csi.c
// Function: termkey_interpret_mouse
TermKeyResult termkey_interpret_mouse(TermKey *tk, const TermKeyKey *key, TermKeyMouseEvent *event, int *button, int *line, int *col)
{
  if(key->type != TERMKEY_TYPE_MOUSE)
    return TERMKEY_RES_NONE;

  if(button)
    *button = 0;

  termkey_key_get_linecol(key, line, col);

  if(!event)
    return TERMKEY_RES_KEY;

  int btn = 0;

  int code = key->code.mouse[0];

  int drag = code & 0x20;

  code &= ~0x3c;

  switch(code) {
  case 0:
  case 1:
  case 2:
    *event = drag ? TERMKEY_MOUSE_DRAG : TERMKEY_MOUSE_PRESS;
    btn = code + 1;
    break;

  case 3:
    *event = TERMKEY_MOUSE_RELEASE;
    // no button hint
    break;

  case 64:
  case 65:
  case 66:
  case 67:
    *event = drag ? TERMKEY_MOUSE_DRAG : TERMKEY_MOUSE_PRESS;
    btn = code + 4 - 64;
    break;

  default:
    *event = TERMKEY_MOUSE_UNKNOWN;
  }

  if(button)
    *button = btn;

  if(key->code.mouse[3] & 0x80)
    *event = TERMKEY_MOUSE_RELEASE;

  return TERMKEY_RES_KEY;
}

// Assembly:
xorl %eax, %eax
cmpl $0x3, (%rsi)
jne 0x4fd9
pushq %r15
pushq %r14
pushq %rbx
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, %r14
testq %rcx, %rcx
je 0x4f5e
andl $0x0, (%r15)
movq %r14, %rdi
movq %r8, %rsi
movq %r9, %rdx
callq 0x4fda
pushq $0x1
popq %rax
testq %rbx, %rbx
je 0x4fd4
movsbl 0x8(%r14), %edx
movl %edx, %ecx
andl $-0x3d, %ecx
leal -0x40(%rcx), %esi
cmpl $0x4, %esi
jb 0x4f9d
cmpl $0x3, %ecx
jae 0x4fb0
andl $0x20, %edx
cmpl $0x1, %edx
pushq $0x2
popq %rdx
sbbl $0x0, %edx
movl %edx, (%rbx)
incl %ecx
jmp 0x4fbf
andl $0x20, %edx
cmpl $0x1, %edx
pushq $0x2
popq %rdx
sbbl $0x0, %edx
movl %edx, (%rbx)
addl $-0x3c, %ecx
jmp 0x4fbf
jne 0x4fba
movl $0x3, (%rbx)
jmp 0x4fbd
andl $0x0, (%rbx)
xorl %ecx, %ecx
testq %r15, %r15
je 0x4fc7
movl %ecx, (%r15)
cmpb $0x0, 0xb(%r14)
jns 0x4fd4
movl $0x3, (%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/./termkey-internal.h
// Function: termkey_key_get_linecol
static inline void termkey_key_get_linecol(const TermKeyKey *key, int *line, int *col)
{
  if(col)
    *col  = (unsigned char)key->code.mouse[1] | ((unsigned char)key->code.mouse[3] & 0x0f) << 8;

  if(line)
    *line = (unsigned char)key->code.mouse[2] | ((unsigned char)key->code.mouse[3] & 0x70) << 4;
}

// Assembly:
testq %rdx, %rdx
je 0x4ff1
movzbl 0x9(%rdi), %eax
movzbl 0xb(%rdi), %ecx
andl $0xf, %ecx
shll $0x8, %ecx
orl %eax, %ecx
movl %ecx, (%rdx)
testq %rsi, %rsi
je 0x5008
movzbl 0xa(%rdi), %eax
movzbl 0xb(%rdi), %ecx
andl $0x70, %ecx
shll $0x4, %ecx
orl %eax, %ecx
movl %ecx, (%rsi)
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-csi.c
// Function: termkey_interpret_modereport
TermKeyResult termkey_interpret_modereport(TermKey *tk, const TermKeyKey *key, int *initial, int *mode, int *value)
{
  if(key->type != TERMKEY_TYPE_MODEREPORT)
    return TERMKEY_RES_NONE;

  if(initial)
    *initial = key->code.mouse[0];

  if(mode)
    *mode = ((uint8_t)key->code.mouse[1] << 8) | (uint8_t)key->code.mouse[2];

  if(value)
    *value = key->code.mouse[3];

  return TERMKEY_RES_KEY;
}

// Assembly:
xorl %eax, %eax
cmpl $0x5, (%rsi)
jne 0x505a
testq %rdx, %rdx
je 0x5039
movsbl 0x8(%rsi), %eax
movl %eax, (%rdx)
testq %rcx, %rcx
je 0x504b
movzwl 0x9(%rsi), %eax
rolw $0x8, %ax
movzwl %ax, %eax
movl %eax, (%rcx)
pushq $0x1
popq %rax
testq %r8, %r8
je 0x505a
movsbl 0xb(%rsi), %ecx
movl %ecx, (%r8)
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-csi.c
// Function: parse_csi
static TermKeyResult parse_csi(TermKey *tk, size_t introlen, size_t *csi_len, long args[], size_t *nargs, unsigned long *commandp)
{
  size_t csi_end = introlen;

  while(csi_end < tk->buffcount) {
    if(CHARAT(csi_end) >= 0x40 && CHARAT(csi_end) < 0x80)
      break;
    csi_end++;
  }

  if(csi_end >= tk->buffcount)
    return TERMKEY_RES_AGAIN;

  unsigned char cmd = CHARAT(csi_end);
  *commandp = cmd;

  char present = 0;
  int argi = 0;

  size_t p = introlen;

  // See if there is an initial byte
  if(CHARAT(p) >= '<' && CHARAT(p) <= '?') {
    *commandp |= (CHARAT(p) << 8);
    p++;
  }

  // Now attempt to parse out up number;number;... separated values
  while(p < csi_end) {
    unsigned char c = CHARAT(p);

    if(c >= '0' && c <= '9') {
      if(!present) {
        args[argi] = c - '0';
        present = 1;
      }
      else {
        args[argi] = (args[argi] * 10) + c - '0';
      }
    }
    else if(c == ';') {
      if(!present)
        args[argi] = -1;
      present = 0;
      argi++;

      if(argi > 16)
        break;
    }
    else if(c >= 0x20 && c <= 0x2f) {
      *commandp |= c << 16;
      break;
    }

    p++;
  }

  if(present)
    argi++;

  *nargs = argi;
  *csi_len = csi_end + 1;

  return TERMKEY_RES_KEY;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
movq 0x20(%rdi), %r14
movl $0x3, %eax
movq %rsi, %r10
cmpq %r14, %r10
jae 0x5172
movq 0x10(%rdi), %r11
movq 0x18(%rdi), %rbx
addq %r11, %rbx
movsbq (%r10,%rbx), %rbx
cmpq $0x3f, %rbx
jg 0x50b9
incq %r10
jmp 0x5095
movq %rbx, (%r9)
movq 0x18(%rdi), %rax
addq %r11, %rax
movzbl (%rsi,%rax), %eax
movl %eax, %ebp
andb $-0x4, %bpl
cmpb $0x3c, %bpl
jne 0x50df
shll $0x8, %eax
orq %rbx, %rax
movq %rax, (%r9)
incq %rsi
xorl %ebx, %ebx
xorl %eax, %eax
cmpq %r10, %rsi
jae 0x5159
movq 0x18(%rdi), %r14
addq %r11, %r14
movzbl (%rsi,%r14), %r14d
leal -0x30(%r14), %ebp
movslq %eax, %r15
cmpb $0x9, %bpl
ja 0x5117
testb %bl, %bl
je 0x5143
imulq $0xa, (%rcx,%r15,8), %rbx
addq %r14, %rbx
addq $-0x30, %rbx
movq %rbx, (%rcx,%r15,8)
jmp 0x514b
cmpl $0x3b, %r14d
jne 0x5134
testb %bl, %bl
jne 0x5126
orq $-0x1, (%rcx,%r15,8)
leal 0x1(%rax), %ebp
cmpl $0xf, %eax
jg 0x5161
xorl %ebx, %ebx
movl %ebp, %eax
jmp 0x514d
movl %r14d, %ebp
andb $-0x10, %bpl
cmpb $0x20, %bpl
jne 0x514d
jmp 0x5152
addl $-0x30, %r14d
movq %r14, (%rcx,%r15,8)
movb $0x1, %bl
incq %rsi
jmp 0x50e3
shll $0x10, %r14d
orq %r14, (%r9)
cmpb $0x1, %bl
sbbl $-0x1, %eax
movl %eax, %ebp
movslq %ebp, %rax
movq %rax, (%r8)
incq %r10
movq %r10, (%rdx)
movl $0x1, %eax
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-csi.c
// Function: peekkey
static TermKeyResult peekkey(TermKey *tk, void *info, TermKeyKey *key, int force, size_t *nbytep)
{
  if(tk->buffcount == 0)
    return tk->is_closed ? TERMKEY_RES_EOF : TERMKEY_RES_NONE;

  TermKeyCsi *csi = info;

  switch(CHARAT(0)) {
    case 0x1b:
      if(tk->buffcount < 2)
        return TERMKEY_RES_NONE;

      switch(CHARAT(1)) {
        case 0x4f: // ESC-prefixed SS3
          return peekkey_ss3(tk, csi, 2, key, force, nbytep);

        case 0x50: // ESC-prefixed DCS
        case 0x5d: // ESC-prefixed OSC
          return peekkey_ctrlstring(tk, csi, 2, key, force, nbytep);

        case 0x5b: // ESC-prefixed CSI
          return peekkey_csi(tk, csi, 2, key, force, nbytep);
      }

      return TERMKEY_RES_NONE;

    case 0x8f: // SS3
      return peekkey_ss3(tk, csi, 1, key, force, nbytep);

    case 0x90: // DCS
    case 0x9d: // OSC
      return peekkey_ctrlstring(tk, csi, 1, key, force, nbytep);

    case 0x9b: // CSI
      return peekkey_csi(tk, csi, 1, key, force, nbytep);
  }

  return TERMKEY_RES_NONE;
}

// Assembly:
pushq %rbx
movq %rdx, %r9
movq 0x20(%rdi), %rdx
testq %rdx, %rdx
je 0x567a
movq 0x10(%rdi), %r10
movq 0x18(%rdi), %r11
movzbl (%r10,%r11), %ebx
cmpl $0x9d, %ebx
je 0x568a
cmpl $0x8f, %ebx
je 0x569d
cmpl $0x90, %ebx
je 0x568a
cmpl $0x9b, %ebx
je 0x56b0
xorl %eax, %eax
cmpl $0x1b, %ebx
jne 0x5688
cmpq $0x1, %rdx
je 0x5688
movzbl 0x1(%r10,%r11), %edx
cmpl $0x5d, %edx
je 0x56c3
cmpl $0x50, %edx
je 0x56c3
cmpl $0x5b, %edx
je 0x56cf
cmpl $0x4f, %edx
jne 0x5688
movabsq $0x2, %rsi
jmp 0x56a7
xorl %eax, %eax
cmpb $0x0, 0x8c(%rdi)
setne %al
addl %eax, %eax
popq %rbx
retq
movabsq $0x1, %rdx
movq %r9, %rcx
popq %rbx
jmp 0x5a6d
movabsq $0x1, %rsi
movq %r9, %rdx
popq %rbx
jmp 0x598e
movabsq $0x1, %rsi
movq %r9, %rdx
popq %rbx
jmp 0x5b64
movabsq $0x2, %rdx
jmp 0x5694
movabsq $0x2, %rsi
jmp 0x56ba
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-csi.c
// Function: termkey_interpret_string
TermKeyResult termkey_interpret_string(TermKey *tk, const TermKeyKey *key, const char **strp)
{
  struct TermKeyDriverNode *p;
  for(p = tk->drivers; p; p = p->next)
    if(p->driver == &termkey_driver_csi)
      break;

  if(!p)
    return TERMKEY_RES_NONE;

  if(key->type != TERMKEY_TYPE_DCS &&
     key->type != TERMKEY_TYPE_OSC)
    return TERMKEY_RES_NONE;

  TermKeyCsi *csi = p->info;

  if(csi->saved_string_id != key->code.number)
    return TERMKEY_RES_NONE;

  *strp = csi->saved_string;

  return TERMKEY_RES_KEY;
}

// Assembly:
addq $0x2a0, %rdi            # imm = 0x2A0
movq 0x58ff(%rip), %rcx      # 0xafe8
xorl %eax, %eax
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x571e
cmpq %rcx, (%rdi)
je 0x56fe
addq $0x10, %rdi
jmp 0x56eb
movl (%rsi), %ecx
andl $-0x2, %ecx
cmpl $0x6, %ecx
jne 0x571e
movq 0x8(%rdi), %rcx
movl 0x8(%rcx), %edi
cmpl 0x8(%rsi), %edi
jne 0x571e
movq 0x10(%rcx), %rax
movq %rax, (%rdx)
pushq $0x1
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-csi.c
// Function: handle_csi_u
static TermKeyResult handle_csi_u(TermKey *tk, TermKeyKey *key, int cmd, long *arg, int args)
{
  switch(cmd) {
    case 'u': {
      if(args > 1 && arg[1] != -1)
        key->modifiers = arg[1] - 1;
      else
        key->modifiers = 0;

      int mod = key->modifiers;
      key->type = TERMKEY_TYPE_KEYSYM;
      (*tk->method.emit_codepoint)(tk, arg[0], key);
      key->modifiers |= mod;

      return TERMKEY_RES_KEY;
    }
    default:
      return TERMKEY_RES_NONE;
  }
}

// Assembly:
xorl %eax, %eax
cmpl $0x75, %edx
jne 0x5763
pushq %rbp
pushq %rbx
pushq %rax
movq %rsi, %rbx
xorl %ebp, %ebp
cmpl $0x2, %r8d
jl 0x5742
movq 0x8(%rcx), %rax
cmpq $-0x1, %rax
je 0x5742
decl %eax
movl %eax, %ebp
movl %ebp, 0x10(%rbx)
movl $0x2, (%rbx)
movq (%rcx), %rsi
movq %rbx, %rdx
callq *0x2a8(%rdi)
orl %ebp, 0x10(%rbx)
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-csi.c
// Function: handle_csi_m
static TermKeyResult handle_csi_m(TermKey *tk, TermKeyKey *key, int cmd, long *arg, int args)
{
  int initial = cmd >> 8;
  cmd &= 0xff;

  switch(cmd) {
    case 'M':
    case 'm':
      break;
    default:
      return TERMKEY_RES_NONE;
  }

  if(!initial && args >= 3) { // rxvt protocol
    key->type = TERMKEY_TYPE_MOUSE;
    key->code.mouse[0] = arg[0];

    key->modifiers     = (key->code.mouse[0] & 0x1c) >> 2;
    key->code.mouse[0] &= ~0x1c;

    termkey_key_set_linecol(key, arg[1], arg[2]);

    return TERMKEY_RES_KEY;
  }

  if(initial == '<' && args >= 3) { // SGR protocol
    key->type = TERMKEY_TYPE_MOUSE;
    key->code.mouse[0] = arg[0];

    key->modifiers     = (key->code.mouse[0] & 0x1c) >> 2;
    key->code.mouse[0] &= ~0x1c;

    termkey_key_set_linecol(key, arg[1], arg[2]);

    if(cmd == 'm') // release
      key->code.mouse[3] |= 0x80;

    return TERMKEY_RES_KEY;
  }

  return TERMKEY_RES_NONE;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rsi, %rbx
movzbl %dl, %ebp
xorl %eax, %eax
movl %ebp, %esi
orl $0x20, %esi
cmpl $0x6d, %esi
jne 0x580f
cmpl $0x100, %edx            # imm = 0x100
setae %sil
cmpl $0x3, %r8d
setl %dil
orb %sil, %dil
jne 0x57c0
movl $0x3, (%rbx)
movq (%rcx), %rax
movl %eax, %edx
shrl $0x2, %edx
andl $0x7, %edx
movl %edx, 0x10(%rbx)
andb $-0x1d, %al
movb %al, 0x8(%rbx)
movl 0x8(%rcx), %esi
movl 0x10(%rcx), %edx
movq %rbx, %rdi
callq 0x5962
pushq $0x1
popq %rax
jmp 0x580f
cmpl $0x3, %r8d
setl %sil
andl $0xffffff00, %edx       # imm = 0xFFFFFF00
cmpl $0x3c00, %edx           # imm = 0x3C00
setne %dl
orb %sil, %dl
jne 0x580f
movl $0x3, (%rbx)
movq (%rcx), %rax
movl %eax, %edx
shrl $0x2, %edx
andl $0x7, %edx
movl %edx, 0x10(%rbx)
andb $-0x1d, %al
movb %al, 0x8(%rbx)
movl 0x8(%rcx), %esi
movl 0x10(%rcx), %edx
movq %rbx, %rdi
callq 0x5962
pushq $0x1
popq %rax
cmpl $0x6d, %ebp
jne 0x580f
orb $-0x80, 0xb(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-csi.c
// Function: handle_csi_R
static TermKeyResult handle_csi_R(TermKey *tk, TermKeyKey *key, int cmd, long *arg, int args)
{
  switch(cmd) {
    case 'R'|'?'<<8:
      if(args < 2)
        return TERMKEY_RES_NONE;

      key->type = TERMKEY_TYPE_POSITION;
      termkey_key_set_linecol(key, arg[1], arg[0]);
      return TERMKEY_RES_KEY;

    default:
      return handle_csi_ss3_full(tk, key, cmd, arg, args);
  }
}

// Assembly:
cmpl $0x3f52, %edx           # imm = 0x3F52
jne 0x587a
xorl %eax, %eax
cmpl $0x2, %r8d
jl 0x5843
pushq %rax
movl $0x4, (%rsi)
movl (%rcx), %edx
movl 0x8(%rcx), %eax
movq %rsi, %rdi
movl %eax, %esi
callq 0x5962
pushq $0x1
popq %rax
addq $0x8, %rsp
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-csi.c
// Function: handle_csi_y
static TermKeyResult handle_csi_y(TermKey *tk, TermKeyKey *key, int cmd, long *arg, int args)
{
  switch(cmd) {
    case 'y'|'$'<<16:
    case 'y'|'$'<<16 | '?'<<8:
      if(args < 2)
        return TERMKEY_RES_NONE;

      key->type = TERMKEY_TYPE_MODEREPORT;
      key->code.mouse[0] = (cmd >> 8);
      key->code.mouse[1] = arg[0] >> 8;
      key->code.mouse[2] = arg[0] & 0xff;
      key->code.mouse[3] = arg[1];
      return TERMKEY_RES_KEY;

    default:
      return TERMKEY_RES_NONE;
  }
}

// Assembly:
xorl %eax, %eax
cmpl $0x243f79, %edx         # imm = 0x243F79
je 0x5856
cmpl $0x240079, %edx         # imm = 0x240079
jne 0x5879
cmpl $0x2, %r8d
jl 0x5879
movl $0x5, (%rsi)
movb %dh, 0x8(%rsi)
movb 0x1(%rcx), %al
movb %al, 0x9(%rsi)
movb (%rcx), %al
movb %al, 0xa(%rsi)
movb 0x8(%rcx), %al
movb %al, 0xb(%rsi)
pushq $0x1
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-csi.c
// Function: handle_csi_ss3_full
static TermKeyResult handle_csi_ss3_full(TermKey *tk, TermKeyKey *key, int cmd, long *arg, int args)
{
  if(args > 1 && arg[1] != -1)
    key->modifiers = arg[1] - 1;
  else
    key->modifiers = 0;

  key->type = csi_ss3s[cmd - 0x40].type;
  key->code.sym = csi_ss3s[cmd - 0x40].sym;
  key->modifiers &= ~(csi_ss3s[cmd - 0x40].modifier_mask);
  key->modifiers |= csi_ss3s[cmd - 0x40].modifier_set;

  if(key->code.sym == TERMKEY_SYM_UNKNOWN)
    return TERMKEY_RES_NONE;

  return TERMKEY_RES_KEY;
}

// Assembly:
xorl %eax, %eax
cmpl $0x2, %r8d
jl 0x5890
movq 0x8(%rcx), %rcx
cmpq $-0x1, %rcx
je 0x5890
decl %ecx
movl %ecx, %eax
movslq %edx, %rcx
shlq $0x4, %rcx
leaq 0x5972(%rip), %rdx      # 0xb210
movl -0x400(%rcx,%rdx), %edi
movl %edi, (%rsi)
movl -0x3fc(%rcx,%rdx), %edi
movl %edi, 0x8(%rsi)
movl -0x3f8(%rcx,%rdx), %r8d
notl %r8d
andl %eax, %r8d
orl -0x3f4(%rcx,%rdx), %r8d
movl %r8d, 0x10(%rsi)
xorl %eax, %eax
cmpl $-0x1, %edi
setne %al
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-csi.c
// Function: handle_csifunc
static TermKeyResult handle_csifunc(TermKey *tk, TermKeyKey *key, int cmd, long *arg, int args)
{
  if(args > 1 && arg[1] != -1)
    key->modifiers = arg[1] - 1;
  else
    key->modifiers = 0;

  key->type = TERMKEY_TYPE_KEYSYM;

  if(arg[0] == 27) {
    int mod = key->modifiers;
    (*tk->method.emit_codepoint)(tk, arg[2], key);
    key->modifiers |= mod;
  }
  else if(arg[0] >= 0 && arg[0] < NCSIFUNCS) {
    key->type = csifuncs[arg[0]].type;
    key->code.sym = csifuncs[arg[0]].sym;
    key->modifiers &= ~(csifuncs[arg[0]].modifier_mask);
    key->modifiers |= csifuncs[arg[0]].modifier_set;
  }
  else
    key->code.sym = TERMKEY_SYM_UNKNOWN;

  if(key->code.sym == TERMKEY_SYM_UNKNOWN) {
#ifdef DEBUG
    fprintf(stderr, "CSI: Unknown function key %ld\n", arg[0]);
#endif
    return TERMKEY_RES_NONE;
  }

  return TERMKEY_RES_KEY;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rsi, %rbx
xorl %ebp, %ebp
cmpl $0x2, %r8d
jl 0x58f0
movq 0x8(%rcx), %rax
cmpq $-0x1, %rax
je 0x58f0
decl %eax
movl %eax, %ebp
movl %ebp, 0x10(%rbx)
movl $0x2, (%rbx)
movq (%rcx), %rax
cmpq $0x1b, %rax
jne 0x5917
movq 0x10(%rcx), %rsi
movq %rbx, %rdx
callq *0x2a8(%rdi)
orl %ebp, 0x10(%rbx)
movl 0x8(%rbx), %edx
jmp 0x5953
cmpq $0x22, %rax
ja 0x594c
shlq $0x4, %rax
leaq 0x6128(%rip), %rsi      # 0xba50
movl (%rax,%rsi), %edx
movl %edx, (%rbx)
movl 0x4(%rax,%rsi), %edx
movl %edx, 0x8(%rbx)
movq (%rcx), %rax
shlq $0x4, %rax
movl 0x8(%rax,%rsi), %ecx
notl %ecx
andl %ecx, %ebp
orl 0xc(%rax,%rsi), %ebp
movl %ebp, 0x10(%rbx)
jmp 0x5953
orl $-0x1, 0x8(%rbx)
pushq $-0x1
popq %rdx
xorl %eax, %eax
cmpl $-0x1, %edx
setne %al
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/./termkey-internal.h
// Function: termkey_key_set_linecol
static inline void termkey_key_set_linecol(TermKeyKey *key, int line, int col)
{
  if(line > 0xfff)
    line = 0xfff;

  if(col > 0x7ff)
    col = 0x7ff;

  key->code.mouse[1] = (line & 0x0ff);
  key->code.mouse[2] = (col & 0x0ff);
  key->code.mouse[3] = (line & 0xf00) >> 8 | (col & 0x300) >> 4;
}

// Assembly:
movl $0xfff, %eax            # imm = 0xFFF
cmpl %eax, %esi
cmovll %esi, %eax
movl $0x7ff, %ecx            # imm = 0x7FF
cmpl %ecx, %edx
cmovll %edx, %ecx
movb %al, 0x9(%rdi)
movb %cl, 0xa(%rdi)
shrl $0x8, %eax
andl $0xf, %eax
shrl $0x4, %ecx
andl $0x30, %ecx
orl %eax, %ecx
movb %cl, 0xb(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-csi.c
// Function: peekkey_ss3
static TermKeyResult peekkey_ss3(TermKey *tk, TermKeyCsi *csi, size_t introlen, TermKeyKey *key, int force, size_t *nbytep)
{
  if(tk->buffcount < introlen + 1) {
    if(!force)
      return TERMKEY_RES_AGAIN;

    (*tk->method.emit_codepoint)(tk, 'O', key);
    key->modifiers |= TERMKEY_KEYMOD_ALT;
    *nbytep = tk->buffcount;
    return TERMKEY_RES_KEY;
  }

  unsigned char cmd = CHARAT(introlen);

  if(cmd < 0x40 || cmd >= 0x80)
    return TERMKEY_RES_NONE;

  key->type = csi_ss3s[cmd - 0x40].type;
  key->code.sym = csi_ss3s[cmd - 0x40].sym;
  key->modifiers = csi_ss3s[cmd - 0x40].modifier_set;

  if(key->code.sym == TERMKEY_SYM_UNKNOWN) {
    if(tk->flags & TERMKEY_FLAG_CONVERTKP && ss3_kpalts[cmd - 0x40]) {
      key->type = TERMKEY_TYPE_UNICODE;
      key->code.codepoint = ss3_kpalts[cmd - 0x40];
      key->modifiers = 0;

      key->utf8[0] = key->code.codepoint;
      key->utf8[1] = 0;
    }
    else {
      key->type = ss3s[cmd - 0x40].type;
      key->code.sym = ss3s[cmd - 0x40].sym;
      key->modifiers = ss3s[cmd - 0x40].modifier_set;
    }
  }

  if(key->code.sym == TERMKEY_SYM_UNKNOWN) {
#ifdef DEBUG
    fprintf(stderr, "CSI: Unknown SS3 %c (0x%02x)\n", (char)cmd, cmd);
#endif
    return TERMKEY_RES_NONE;
  }

  *nbytep = introlen + 1;

  return TERMKEY_RES_KEY;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %r8, %rbx
movq %rdx, %r14
movq %rdi, %r15
cmpq %rsi, 0x20(%rdi)
jbe 0x5a19
movq 0x10(%r15), %rax
addq 0x18(%r15), %rax
movzbl (%rsi,%rax), %ecx
xorl %eax, %eax
cmpb $0x40, %cl
jl 0x5a40
incq %rsi
andl $0x3f, %ecx
movl %ecx, %edx
shll $0x4, %edx
leaq 0x5845(%rip), %rdi      # 0xb210
movl (%rdx,%rdi), %r8d
movl %r8d, (%r14)
movl 0x4(%rdx,%rdi), %r8d
movl %r8d, 0x8(%r14)
movl 0xc(%rdx,%rdi), %edx
movl %edx, 0x10(%r14)
cmpl $-0x1, %r8d
jne 0x5a36
testb $0x2, 0x4(%r15)
je 0x5a46
leaq 0x6019(%rip), %rdx      # 0xba10
movsbq (%rcx,%rdx), %rdx
testq %rdx, %rdx
je 0x5a46
andl $0x0, (%r14)
movq %rdx, 0x8(%r14)
andl $0x0, 0x10(%r14)
movb %dl, 0x14(%r14)
movb $0x0, 0x15(%r14)
jmp 0x5a66
testl %ecx, %ecx
je 0x5a3d
pushq $0x4f
popq %rsi
movq %r15, %rdi
movq %r14, %rdx
callq *0x2a8(%r15)
orb $0x2, 0x10(%r14)
movq 0x20(%r15), %rsi
movq %rsi, (%rbx)
pushq $0x1
jmp 0x5a3f
pushq $0x3
popq %rax
popq %rbx
popq %r14
popq %r15
retq
shll $0x4, %ecx
leaq 0x5bc0(%rip), %rdi      # 0xb610
movl (%rcx,%rdi), %edx
movl %edx, (%r14)
movl 0x4(%rcx,%rdi), %edx
movl %edx, 0x8(%r14)
movl 0xc(%rcx,%rdi), %ecx
movl %ecx, 0x10(%r14)
cmpl $-0x1, %edx
jne 0x5a36
jmp 0x5a40
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-csi.c
// Function: peekkey_ctrlstring
static TermKeyResult peekkey_ctrlstring(TermKey *tk, TermKeyCsi *csi, size_t introlen, TermKeyKey *key, int force, size_t *nbytep)
{
  size_t str_end = introlen;

  while(str_end < tk->buffcount) {
    if(CHARAT(str_end) == 0x07) // BEL
      break;
    if(CHARAT(str_end) == 0x9c) // ST
      break;
    if(CHARAT(str_end) == 0x1b &&
       (str_end + 1) < tk->buffcount &&
       CHARAT(str_end+1) == 0x5c) // ESC-prefixed ST
      break;

    str_end++;
  }

  if(str_end >= tk->buffcount)
    return TERMKEY_RES_AGAIN;

#ifdef DEBUG
  fprintf(stderr, "Found a control string: %*s",
      str_end - introlen, tk->buffer + tk->buffstart + introlen);
#endif

  *nbytep = str_end + 1;
  if(CHARAT(str_end) == 0x1b)
    (*nbytep)++;

  if(csi->saved_string)
    free(csi->saved_string);

  size_t len = str_end - introlen;

  csi->saved_string_id++;
  csi->saved_string = malloc(len + 1);

  strncpy(csi->saved_string, (char *)tk->buffer + tk->buffstart + introlen, len);
  csi->saved_string[len] = 0;

  key->type = (CHARAT(introlen-1) & 0x1f) == 0x10 ?
    TERMKEY_TYPE_DCS : TERMKEY_TYPE_OSC;
  key->code.number = csi->saved_string_id;
  key->modifiers = 0;

  return TERMKEY_RES_KEY;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %r12
movq 0x20(%rdi), %r9
pushq $0x3
popq %rax
movq %rdx, %rdi
cmpq %r9, %rdi
jae 0x5b55
movq %rdi, %r15
movq 0x10(%r12), %rdx
movq 0x18(%r12), %rsi
addq %rdx, %rsi
movzbl (%rdi,%rsi), %edi
cmpl $0x1b, %edi
je 0x5ac2
cmpl $0x7, %edi
je 0x5ad1
cmpl $0x9c, %edi
je 0x5ad1
incq %r15
movq %r15, %rdi
jmp 0x5a8b
leaq 0x1(%r15), %rdi
cmpq %r9, %rdi
jae 0x5a8b
cmpb $0x5c, (%rsi,%rdi)
jne 0x5a8b
movq %rcx, (%rsp)
leaq 0x1(%r15), %rax
movq %rax, (%r8)
addq 0x18(%r12), %rdx
cmpb $0x1b, (%r15,%rdx)
jne 0x5aef
leaq 0x2(%r15), %rax
movq %rax, (%r8)
movq 0x10(%r13), %rdi
callq 0x3050
subq %r14, %r15
movl 0x8(%r13), %ebx
incl %ebx
movl %ebx, 0x8(%r13)
leaq 0x1(%r15), %rdi
callq 0x31c0
movq %rax, %rbp
movq %rax, 0x10(%r13)
movq 0x10(%r12), %r13
addq 0x18(%r12), %r13
leaq (%r14,%r13), %rsi
movq %rax, %rdi
movq %r15, %rdx
callq 0x30c0
movb $0x0, (%rbp,%r15)
movb -0x1(%r14,%r13), %al
andb $0x1f, %al
xorl %ecx, %ecx
cmpb $0x10, %al
sete %cl
xorl $0x7, %ecx
movq (%rsp), %rax
movl %ecx, (%rax)
movl %ebx, 0x8(%rax)
andl $0x0, 0x10(%rax)
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-ti.c
// Function: stop_driver
static int stop_driver(TermKey *tk, void *info)
{
  TermKeyTI *ti = info;
  struct stat statbuf;
  char *stop_string = ti->stop_string;
  size_t len;

  if(tk->fd == -1 || !stop_string)
    return 1;

  /* There's no point trying to write() to a pipe */
  if(fstat(tk->fd, &statbuf) == -1)
    return 0;

#ifndef _WIN32
  if(S_ISFIFO(statbuf.st_mode))
    return 1;
#endif

  /* The terminfo database will contain keys in application cursor key mode.
   * We may need to enable that mode
   */

  // Can't call putp or tputs because they suck and don't give us fd control
  len = strlen(stop_string);
  while(len) {
    size_t written = write(tk->fd, stop_string, len);
    if(written == -1)
      return 0;
    stop_string += written;
    len -= written;
  }
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %r14
movq 0x20(%rsi), %r15
movl (%rdi), %edi
cmpl $-0x1, %edi
setne %al
testq %r15, %r15
setne %cl
andb %al, %cl
pushq $0x1
popq %rbx
cmpb $0x1, %cl
jne 0x6053
leaq 0x8(%rsp), %rsi
callq 0x32d0
cmpl $-0x1, %eax
je 0x6051
movl $0xf000, %eax           # imm = 0xF000
andl 0x20(%rsp), %eax
cmpl $0x1000, %eax           # imm = 0x1000
je 0x6053
movq %r15, %rdi
callq 0x3100
movq %rax, %r12
testq %r12, %r12
je 0x6053
movl (%r14), %edi
movq %r15, %rsi
movq %r12, %rdx
callq 0x30f0
addq %rax, %r15
subq %rax, %r12
cmpq $-0x1, %rax
jne 0x6032
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %r14
cmpq $0x0, 0x20(%rdi)
je 0x60e5
movq %r8, %rbx
movl %ecx, %ebp
movq %rdx, %r15
movq 0x10(%rsi), %rax
xorl %r12d, %r12d
movl %r12d, %r12d
cmpq %r12, 0x20(%r14)
jbe 0x60f8
movq 0x10(%r14), %rcx
addq 0x18(%r14), %rcx
movzbl (%r12,%rcx), %esi
movq %rax, %rdi
callq 0x6414
testq %rax, %rax
je 0x60f6
incl %r12d
cmpl $0x0, (%rax)
jne 0x6085
movl 0x4(%rax), %ecx
cmpl $0x3, %ecx
jne 0x610c
movl %r12d, %r12d
addq %r12, 0x18(%r14)
subq %r12, 0x20(%r14)
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq *0x2b8(%r14)
subq %r12, 0x18(%r14)
addq %r12, 0x20(%r14)
cmpl $0x1, %eax
jne 0x6126
addq %r12, (%rbx)
jmp 0x6123
xorl %eax, %eax
cmpb $0x0, 0x8c(%r14)
setne %al
addl %eax, %eax
jmp 0x6126
xorl %eax, %eax
xorl %ecx, %ecx
testq %rax, %rax
setne %cl
xorl %edx, %edx
testl %ebp, %ebp
leal (%rcx,%rcx,2), %eax
cmovnel %edx, %eax
jmp 0x6126
movl %ecx, (%r15)
movl 0x8(%rax), %ecx
movl %ecx, 0x8(%r15)
movl 0x10(%rax), %eax
movl %eax, 0x10(%r15)
movl %r12d, %eax
movq %rax, (%rbx)
pushq $0x1
popq %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-ti.c
// Function: free_trie
static void free_trie(struct trie_node *n)
{
  switch(n->type) {
  case TYPE_KEY:
    break;
  case TYPE_ARR:
    {
      struct trie_node_arr *nar = (struct trie_node_arr*)n;
      int i;
      for(i = nar->min; i <= nar->max; i++)
        if(nar->arr[i - nar->min])
          free_trie(nar->arr[i - nar->min]);
      break;
    }
  }

  free(n);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x1, (%rdi)
jne 0x616a
movzbl 0x4(%rbx), %r14d
movzbl 0x5(%rbx), %eax
cmpl %eax, %r14d
ja 0x616a
movzbl 0x4(%rbx), %eax
shll $0x3, %eax
movq %rbx, %rcx
subq %rax, %rcx
movq 0x8(%rcx,%r14,8), %rdi
testq %rdi, %rdi
je 0x6165
callq 0x612f
incq %r14
jmp 0x6140
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3050
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-ti.c
// Function: new_node_arr
static struct trie_node *new_node_arr(unsigned char min, unsigned char max)
{
  struct trie_node_arr *n = malloc(sizeof(*n) + ((int)max-min+1) * sizeof(n->arr[0]));
  if(!n)
    return NULL;

  n->type = TYPE_ARR;
  n->min = min; n->max = max;

  int i;
  for(i = min; i <= max; i++)
    n->arr[i-min] = NULL;

  return (struct trie_node*)n;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %esi, %ebx
movl %edi, %ebp
movl %esi, %eax
movl %edi, %ecx
subq %rcx, %rax
leaq 0x10(,%rax,8), %rdi
callq 0x31c0
testq %rax, %rax
je 0x61c6
movl $0x1, (%rax)
movb %bpl, 0x4(%rax)
movb %bl, 0x5(%rax)
movq %rax, %rcx
addq $0x8, %rcx
movzbl %bpl, %edx
movzbl %bl, %esi
cmpq %rsi, %rdx
ja 0x61c6
andq $0x0, (%rcx)
incq %rdx
addq $0x8, %rcx
jmp 0x61b4
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-ti.c
// Function: try_load_terminfo_key
static bool try_load_terminfo_key(TermKeyTI *ti, const char *name, struct keyinfo *info)
{
  const char *value = NULL;

#ifdef HAVE_UNIBILIUM
  if(ti->unibi)
    value = unibi_get_str_by_name(ti->unibi, name);
#else
  if(ti->term)
    value = tigetstr(name);
#endif

  if(ti->tk->ti_getstr_hook)
    value = (ti->tk->ti_getstr_hook)(name, value, ti->tk->ti_getstr_hook_data);

  if(!value || value == (char*)-1 || !value[0])
    return false;

  struct trie_node *node = new_node_key(info->type, info->sym, info->modifier_mask, info->modifier_set);
  insert_seq(ti, value, node);

  return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbx
cmpq $0x0, 0x8(%rdi)
je 0x61f2
movq %r12, %rdi
callq 0x3260
movq %rax, %r15
jmp 0x61f5
xorl %r15d, %r15d
movq (%rbx), %rcx
movq 0x78(%rcx), %rax
testq %rax, %rax
je 0x6213
movq 0x80(%rcx), %rdx
movq %r12, %rdi
movq %r15, %rsi
callq *%rax
movq %rax, %r15
leaq 0x1(%r15), %rax
cmpq $0x2, %rax
jae 0x6221
xorl %eax, %eax
jmp 0x624b
cmpb $0x0, (%r15)
je 0x621d
movl (%r14), %edi
movl 0x4(%r14), %esi
movl 0x8(%r14), %edx
movl 0xc(%r14), %ecx
callq 0x6257
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x6291
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-ti.c
// Function: new_node_key
static struct trie_node *new_node_key(TermKeyType type, TermKeySym sym, int modmask, int modset)
{
  struct trie_node_key *n = malloc(sizeof(*n));
  if(!n)
    return NULL;

  n->type = TYPE_KEY;

  n->key.type = type;
  n->key.sym  = sym;
  n->key.modifier_mask = modmask;
  n->key.modifier_set  = modset;

  return (struct trie_node*)n;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %ebx
movl %edx, %ebp
movl %esi, %r14d
movl %edi, %r15d
pushq $0x14
popq %rdi
callq 0x31c0
testq %rax, %rax
je 0x6286
andl $0x0, (%rax)
movl %r15d, 0x4(%rax)
movl %r14d, 0x8(%rax)
movl %ebp, 0xc(%rax)
movl %ebx, 0x10(%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-ti.c
// Function: insert_seq
static int insert_seq(TermKeyTI *ti, const char *seq, struct trie_node *node)
{
  int pos = 0;
  struct trie_node *p = ti->root;

  // Unsigned because we'll be using it as an array subscript
  unsigned char b;

  while((b = seq[pos])) {
    struct trie_node *next = lookup_next(p, b);
    if(!next)
      break;
    p = next;
    pos++;
  }

  while((b = seq[pos])) {
    struct trie_node *next;
    if(seq[pos+1])
      // Intermediate node
      next = new_node_arr(0, 0xff);
    else
      // Final key node
      next = node;

    if(!next)
      return 0;

    switch(p->type) {
    case TYPE_ARR:
      {
        struct trie_node_arr *nar = (struct trie_node_arr*)p;
        if(b < nar->min || b > nar->max) {
          fprintf(stderr, "ASSERT FAIL: Trie insert at 0x%02x is outside of extent bounds (0x%02x..0x%02x)\n",
              b, nar->min, nar->max);
          abort();
        }
        nar->arr[b - nar->min] = next;
        p = next;
        break;
      }
    case TYPE_KEY:
      fprintf(stderr, "ASSERT FAIL: Tried to insert child node in TYPE_KEY\n");
      abort();
    }

    pos++;
  }

  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq 0x10(%rdi), %rax
xorl %ecx, %ecx
movq %rax, %r15
movq %rcx, %r12
movb (%r14,%rcx), %al
testb %al, %al
je 0x6317
movzbl %al, %esi
movq %r15, %rdi
callq 0x6414
leaq 0x1(%r12), %rcx
testq %rax, %rax
jne 0x62a5
jmp 0x6317
cmpb $0x0, 0x1(%r14,%r12)
movq %rbx, %rax
je 0x62e1
xorl %edi, %edi
movl $0xff, %esi
callq 0x6179
testq %rax, %rax
je 0x6320
movl (%r15), %ecx
incq %r12
cmpl $0x1, %ecx
je 0x62f7
testl %ecx, %ecx
jne 0x6317
jmp 0x6329
movzbl 0x4(%r15), %ecx
movb 0x5(%r15), %dl
cmpb %cl, %bpl
jb 0x634a
cmpb %dl, %bpl
ja 0x634a
subl %ecx, %ebp
movslq %ebp, %rcx
movq %rax, 0x8(%r15,%rcx,8)
movq %rax, %r15
movzbl (%r14,%r12), %ebp
testl %ebp, %ebp
jne 0x62ca
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x4cc0(%rip), %rax      # 0xaff0
movq (%rax), %rcx
leaq 0x150b(%rip), %rdi      # 0x7845
pushq $0x34
popq %rsi
pushq $0x1
popq %rdx
callq 0x32a0
callq 0x3080
movzbl %dl, %r8d
movq 0x4c9b(%rip), %rax      # 0xaff0
movq (%rax), %rdi
leaq 0x1495(%rip), %rsi      # 0x77f4
movl %ebp, %edx
xorl %eax, %eax
callq 0x3190
callq 0x3080
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-ti.c
// Function: compress_trie
static struct trie_node *compress_trie(struct trie_node *n)
{
  if(!n)
    return NULL;

  switch(n->type) {
  case TYPE_KEY:
    return n;
  case TYPE_ARR:
    {
      struct trie_node_arr *nar = (struct trie_node_arr*)n;
      unsigned char min, max;
      // Find the real bounds
      for(min = 0; !nar->arr[min]; min++)
        if(min == 255 && !nar->arr[min]) {
          free(nar);
          return new_node_arr(1, 0);
        }

      for(max = 0xff; !nar->arr[max]; max--)
        ;

      struct trie_node_arr *new = (struct trie_node_arr*)new_node_arr(min, max);
      int i;
      for(i = min; i <= max; i++)
        new->arr[i - min] = compress_trie(nar->arr[i]);

      free(nar);
      return (struct trie_node*)new;
    }
  }

  return n;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x639c
movq %rdi, %rbx
cmpl $0x1, (%rdi)
jne 0x63a1
xorl %r12d, %r12d
cmpq $0x0, 0x8(%rbx,%r12,8)
jne 0x63a6
cmpq $0xff, %r12
je 0x63f9
incq %r12
jmp 0x6386
xorl %r15d, %r15d
jmp 0x63ec
movq %rbx, %r15
jmp 0x63ec
xorl %eax, %eax
decb %al
movzbl %al, %r14d
cmpq $0x0, 0x8(%rbx,%r14,8)
je 0x63a8
movzbl %r12b, %edi
movl %r14d, %esi
callq 0x6179
movq %rax, %r15
movq %rax, %r13
addq $0x8, %r13
cmpq %r14, %r12
ja 0x63e4
movq 0x8(%rbx,%r12,8), %rdi
callq 0x636d
movq %rax, (%r13)
incq %r12
jmp 0x63c8
movq %rbx, %rdi
callq 0x3050
movq %r15, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rbx, %rdi
callq 0x3050
pushq $0x1
popq %rdi
xorl %esi, %esi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x6179
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/driver-ti.c
// Function: lookup_next
static struct trie_node *lookup_next(struct trie_node *n, unsigned char b)
{
  switch(n->type) {
  case TYPE_KEY:
    fprintf(stderr, "ABORT: lookup_next within a TYPE_KEY node\n");
    abort();
  case TYPE_ARR:
    {
      struct trie_node_arr *nar = (struct trie_node_arr*)n;
      if(b < nar->min || b > nar->max)
        return NULL;
      return nar->arr[b - nar->min];
    }
  }

  return NULL; // Never reached but keeps compiler happy
}

// Assembly:
movl (%rdi), %eax
cmpl $0x1, %eax
je 0x6441
testl %eax, %eax
jne 0x6450
pushq %rax
movq 0x4bc9(%rip), %rax      # 0xaff0
movq (%rax), %rcx
leaq 0x1449(%rip), %rdi      # 0x787a
pushq $0x2a
popq %rsi
pushq $0x1
popq %rdx
callq 0x32a0
callq 0x3080
movzbl 0x4(%rdi), %eax
cmpb %sil, %al
ja 0x6450
cmpb %sil, 0x5(%rdi)
jae 0x6453
xorl %eax, %eax
retq
movzbl %sil, %ecx
subq %rax, %rcx
movq 0x8(%rdi,%rcx,8), %rax
retq
// File: /workspace/github_c_makefile_star2_O2/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_7/exercise_7_07/find.c
// Function: main
int main(int argc, char *argv[])
{
  if (!parse_arg_list(argc, argv))
  {
    exit(EXIT_FAILURE);
  }

  if (argc - pattern_arg_pos > 1)
  {
    for (int file_arg_pos = pattern_arg_pos + 1; file_arg_pos < argc; file_arg_pos++)
    {
      FILE *file_p;
      if ((file_p = fopen(argv[file_arg_pos], "r")) == NULL)
      {
        fprintf(stderr, "%s: can't open %s.\n", program_name, argv[file_arg_pos]);
        exit(EXIT_FAILURE);
      }
      printf("%s\n", argv[file_arg_pos]);
      find_pattern(argv[pattern_arg_pos], file_p);
      fclose(file_p);

      if (file_arg_pos < argc - 1)
      {
        putc('\n', stdout);
      }
    }
  }
  else
  {
    find_pattern(argv[pattern_arg_pos], stdin);
  }

  exit(EXIT_SUCCESS);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %r14d
callq 0x129f
testl %eax, %eax
jne 0x11de
pushq $0x1
popq %rdi
callq 0x10a0
movslq 0x2e8b(%rip), %r12      # 0x4070
movl %r14d, %eax
subl %r12d, %eax
cmpl $0x2, %eax
jl 0x125d
leal -0x1(%r14), %eax
movslq %eax, %r13
movslq %r14d, %rbp
incq %r12
leaq 0xe00(%rip), %r14       # 0x2004
cmpq %rbp, %r12
jge 0x1270
movq (%rbx,%r12,8), %rdi
movq %r14, %rsi
callq 0x1090
testq %rax, %rax
je 0x1277
movq %rax, %r15
movq (%rbx,%r12,8), %rdi
callq 0x1030
movslq 0x2e43(%rip), %rax      # 0x4070
movq (%rbx,%rax,8), %rdi
movq %r15, %rsi
callq 0x1353
movq %r15, %rdi
callq 0x1040
cmpq %r13, %r12
jge 0x1258
movq 0x2d83(%rip), %rax      # 0x3fd0
movq (%rax), %rsi
pushq $0xa
popq %rdi
callq 0x1070
incq %r12
jmp 0x1204
movq (%rbx,%r12,8), %rdi
movq 0x2d70(%rip), %rax      # 0x3fd8
movq (%rax), %rsi
callq 0x1353
xorl %edi, %edi
callq 0x10a0
movq 0x2d7a(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
movq 0x2e00(%rip), %rdx      # 0x4088
movq (%rbx,%r12,8), %rcx
leaq 0xd73(%rip), %rsi       # 0x2006
xorl %eax, %eax
callq 0x1080
jmp 0x11d6