LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/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 %rbx
cmpl $-0x1, (%rdi)
je 0x3f12
movq %rdi, %rbx
movq 0x18(%rdi), %rsi
testq %rsi, %rsi
je 0x3ed0
movq 0x10(%rbx), %rdi
movq 0x20(%rbx), %rdx
addq %rdi, %rsi
callq 0x3230
movq $0x0, 0x18(%rbx)
movq 0x20(%rbx), %rax
cmpq 0x28(%rbx), %rax
jae 0x3f1f
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 0x3f38
callq 0x3090
movl (%rax), %ecx
movl $0x4, %eax
cmpl $0x4, %ecx
jne 0x3f31
testb $-0x80, 0x4(%rbx)
je 0x3eda
jmp 0x3f2f
callq 0x3090
movl $0x9, (%rax)
jmp 0x3f2a
callq 0x3090
movl $0xc, (%rax)
movl $0x4, %eax
popq %rbx
retq
cmpl $0xb, %ecx
je 0x3f4f
jmp 0x3f2f
testq %rax, %rax
jle 0x3f48
addq %rax, 0x20(%rbx)
movl $0x3, %eax
jmp 0x3f2f
movb $0x1, 0x8c(%rbx)
xorl %eax, %eax
jmp 0x3f2f
// File: /workspace/github_c_makefile_star2_O1/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 0x3f82
movq 0x10(%r14), %rdi
movq 0x20(%r14), %rdx
addq %rdi, %rsi
callq 0x3230
movq $0x0, 0x18(%r14)
movq 0x20(%r14), %rdi
movq 0x28(%r14), %rax
subq %rdi, %rax
jbe 0x3fab
cmpq %rbx, %rax
cmovbq %rax, %rbx
addq 0x10(%r14), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x31a0
addq %rbx, 0x20(%r14)
jmp 0x3fbd
callq 0x3090
movl $0xc, (%rax)
movq $-0x1, %rbx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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, %rbx
movl %esi, %r14d
movq %rdi, %r15
testl %esi, %esi
jne 0x3fe2
movl 0x90(%r15), %r14d
movslq %r14d, %r12
cmpl 0x90(%r15), %r14d
jl 0x4049
movq 0x98(%r15), %rdi
leaq 0x8(,%r12,8), %rsi
callq 0x31f0
movq %rax, %rcx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %rcx, %rcx
je 0x4057
leal 0x1(%r14), %edx
movq %rcx, 0x98(%r15)
movslq 0x90(%r15), %rsi
cmpl %r14d, %esi
jge 0x403d
movq 0x98(%r15), %rdi
movq $0x0, (%rdi,%rsi,8)
incq %rsi
cmpq %rsi, %r12
jne 0x4026
movl %edx, 0x90(%r15)
testq %rcx, %rcx
je 0x4057
movq 0x98(%r15), %rax
movq %rbx, (%rax,%r12,8)
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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
movq %rsi, 0x28(%rsp)
movq %rdx, 0x40(%rsp)
movl $0x0, (%rdx)
cmpl $0x0, 0x90(%rdi)
jle 0x41ff
movl %ecx, %r14d
movq 0x98(%rdi), %rax
movq %rax, 0x38(%rsp)
xorl %ecx, %ecx
movl %r14d, 0x1c(%rsp)
movq %rdi, 0x20(%rsp)
movq 0x38(%rsp), %rax
movq (%rax,%rcx,8), %rbp
testq %rbp, %rbp
je 0x4122
movq %rcx, 0x30(%rsp)
movq %rbp, %rdi
callq 0x30f0
movq %rax, %rbx
testb $0x40, %r14b
jne 0x4129
movq 0x28(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x30c0
addq %r15, %rbx
testl %eax, %eax
sete %al
movq 0x10(%rsp), %rcx
cmoveq %rbx, %rcx
movq %rcx, 0x10(%rsp)
jmp 0x41d7
xorl %eax, %eax
jmp 0x41e1
movl $0x0, 0xc(%rsp)
movq 0x28(%rsp), %r14
movsbl (%r14), %r12d
testl %r12d, %r12d
jne 0x4145
cmpb $0x0, (%rbp)
je 0x41bb
testq %rbx, %rbx
je 0x41bb
callq 0x32e0
movq (%rax), %rax
movsbq (%rbp), %r13
movl (%rax,%r13,4), %r15d
callq 0x32f0
movq (%rax), %rax
movzwl (%rax,%r13,2), %eax
movl %eax, %ecx
shrl $0x8, %ecx
cmpl $0x0, 0xc(%rsp)
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x4196
cmpb $0x20, %r12b
jne 0x4192
movsbl 0x1(%r14), %ecx
incq %r14
movsbl %r15b, %edx
cmpl %ecx, %edx
je 0x419f
xorl %ecx, %ecx
jmp 0x41b0
movsbl %r15b, %ecx
cmpl %r12d, %ecx
jne 0x4192
andl $0x200, %eax            # imm = 0x200
incq %r14
incq %rbp
movb $0x1, %cl
movl %eax, 0xc(%rsp)
decq %rbx
testb %cl, %cl
jne 0x4136
movb (%r14), %al
cmpb (%rbp), %al
sete %al
movq 0x10(%rsp), %rcx
cmoveq %r14, %rcx
movq %rcx, 0x10(%rsp)
movl 0x1c(%rsp), %r14d
movq 0x20(%rsp), %rdi
movq 0x30(%rsp), %rcx
testb %al, %al
jne 0x4203
incq %rcx
movq 0x40(%rsp), %rax
movl %ecx, (%rax)
movslq 0x90(%rdi), %rax
cmpq %rax, %rcx
jl 0x40d0
xorl %eax, %eax
jmp 0x4208
movq 0x10(%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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:
movl $0x3, %eax
cmpq $0x3, 0x20(%rdi)
jb 0x5173
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)
movl $0x1, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x5230
testq %rcx, %rcx
je 0x518a
movl $0x0, (%rcx)
testq %r9, %r9
je 0x51a2
movzbl 0x9(%rsi), %eax
movzbl 0xb(%rsi), %edi
andl $0xf, %edi
shll $0x8, %edi
orl %eax, %edi
movl %edi, (%r9)
testq %r8, %r8
je 0x51ba
movzbl 0xa(%rsi), %eax
movzbl 0xb(%rsi), %edi
andl $0x70, %edi
shll $0x4, %edi
orl %eax, %edi
movl %edi, (%r8)
movl $0x1, %eax
testq %rdx, %rdx
je 0x5230
movsbl 0x8(%rsi), %r8d
movl %r8d, %edi
andl $-0x3d, %edi
leal -0x40(%rdi), %r9d
cmpl $0x4, %r9d
jb 0x51f7
cmpl $0x3, %edi
jae 0x5211
andl $0x20, %r8d
cmpl $0x1, %r8d
movl $0x2, %r8d
sbbl $0x0, %r8d
movl %r8d, (%rdx)
incl %edi
jmp 0x5223
andl $0x20, %r8d
cmpl $0x1, %r8d
movl $0x2, %r8d
sbbl $0x0, %r8d
movl %r8d, (%rdx)
addl $-0x3c, %edi
jmp 0x5223
jne 0x521b
movl $0x3, (%rdx)
jmp 0x5221
movl $0x0, (%rdx)
xorl %edi, %edi
testq %rcx, %rcx
je 0x522a
movl %edi, (%rcx)
cmpb $0x0, 0xb(%rsi)
js 0x5231
retq
movl $0x3, (%rdx)
retq
// File: /workspace/github_c_makefile_star2_O1/neovim[P]libtermkey/driver-csi.c
// Function: termkey_interpret_position
TermKeyResult termkey_interpret_position(TermKey *tk, const TermKeyKey *key, int *line, int *col)
{
  if(key->type != TERMKEY_TYPE_POSITION)
    return TERMKEY_RES_NONE;

  termkey_key_get_linecol(key, line, col);

  return TERMKEY_RES_KEY;
}

// Assembly:
xorl %eax, %eax
cmpl $0x4, (%rsi)
jne 0x5272
testq %rcx, %rcx
je 0x5256
movzbl 0x9(%rsi), %eax
movzbl 0xb(%rsi), %edi
andl $0xf, %edi
shll $0x8, %edi
orl %eax, %edi
movl %edi, (%rcx)
movl $0x1, %eax
testq %rdx, %rdx
je 0x5272
movzbl 0xa(%rsi), %ecx
movzbl 0xb(%rsi), %esi
andl $0x70, %esi
shll $0x4, %esi
orl %ecx, %esi
movl %esi, (%rdx)
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x52a8
testq %rdx, %rdx
je 0x5285
movsbl 0x8(%rsi), %eax
movl %eax, (%rdx)
testq %rcx, %rcx
je 0x5297
movzwl 0x9(%rsi), %eax
rolw $0x8, %ax
movzwl %ax, %eax
movl %eax, (%rcx)
movl $0x1, %eax
testq %r8, %r8
je 0x52a8
movsbl 0xb(%rsi), %ecx
movl %ecx, (%r8)
retq
// File: /workspace/github_c_makefile_star2_O1/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), %r11
movl $0x3, %eax
cmpq %rsi, %r11
seta %bl
jbe 0x5421
movq 0x10(%rdi), %r14
movq 0x18(%rdi), %r15
leaq (%r14,%r15), %r10
cmpb $0x3f, (%rsi,%r10)
movq %rsi, %r10
jg 0x532d
leaq (%r15,%r14), %rbx
incq %rbx
leaq -0x1(%r11), %r14
movq %rsi, %r15
cmpq %r15, %r14
je 0x5421
leaq 0x1(%r15), %r10
cmpb $0x3f, (%rbx,%r15)
movq %r10, %r15
jle 0x5310
cmpq %r11, %r10
setb %bl
testb %bl, %bl
je 0x5421
movq 0x10(%rdi), %rax
movq 0x18(%rdi), %r11
addq %rax, %r11
movzbl (%r10,%r11), %r11d
movq %r11, (%r9)
movq 0x18(%rdi), %rbx
addq %rax, %rbx
movzbl (%rsi,%rbx), %ebx
movl %ebx, %ebp
andb $-0x4, %bpl
cmpb $0x3c, %bpl
jne 0x536b
shll $0x8, %ebx
orq %r11, %rbx
movq %rbx, (%r9)
incq %rsi
xorl %ebx, %ebx
xorl %r11d, %r11d
cmpq %r10, %rsi
jae 0x5409
movq 0x18(%rdi), %r14
addq %rax, %r14
movzbl (%rsi,%r14), %r14d
leal -0x30(%r14), %ebp
cmpb $0x9, %bpl
ja 0x53a8
testb %bl, %bl
je 0x53e7
movslq %r11d, %rbx
movq (%rcx,%rbx,8), %r15
leaq (%r15,%r15,4), %r15
leaq (%r14,%r15,2), %r14
addq $-0x30, %r14
jmp 0x53ee
cmpl $0x3b, %r14d
jne 0x53ce
testb %bl, %bl
jne 0x53bd
movslq %r11d, %rbx
movq $-0x1, (%rcx,%rbx,8)
leal 0x1(%r11), %ebp
xorl %ebx, %ebx
cmpl $0xf, %r11d
jle 0x53f7
xorl %r14d, %r14d
jmp 0x53fd
movl %r14d, %ebp
andb $-0x10, %bpl
cmpb $0x20, %bpl
jne 0x53f4
shll $0x10, %r14d
orq %r14, (%r9)
xorl %r14d, %r14d
jmp 0x5400
addl $-0x30, %r14d
movslq %r11d, %rbx
movq %r14, (%rcx,%rbx,8)
movb $0x1, %bl
movl %r11d, %ebp
incq %rsi
movb $0x1, %r14b
movl %ebp, %r11d
testb %r14b, %r14b
jne 0x5370
cmpb $0x1, %bl
sbbl $-0x1, %r11d
movslq %r11d, %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_O1/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 0x20(%rdi), %r10
testq %r10, %r10
je 0x5c21
movq %rdx, %r9
movq 0x10(%rdi), %r11
movq 0x18(%rdi), %rbx
movzbl (%r11,%rbx), %edx
xorl %eax, %eax
cmpl $0x8f, %edx
jle 0x5c31
cmpl $0x90, %edx
je 0x5c13
cmpl $0x9b, %edx
je 0x5c4c
cmpl $0x9d, %edx
jne 0x5c2f
movl $0x1, %edx
movq %r9, %rcx
popq %rbx
jmp 0x607f
xorl %eax, %eax
cmpb $0x0, 0x8c(%rdi)
setne %al
addl %eax, %eax
popq %rbx
retq
cmpl $0x1b, %edx
je 0x5c5a
cmpl $0x8f, %edx
jne 0x5c2f
movl $0x1, %esi
movq %r9, %rdx
popq %rbx
jmp 0x5f97
movl $0x1, %esi
movq %r9, %rdx
popq %rbx
jmp 0x61c1
cmpq $0x1, %r10
je 0x5c2f
movzbl 0x1(%r11,%rbx), %edx
cmpl $0x5a, %edx
jg 0x5c77
cmpl $0x4f, %edx
je 0x5c88
cmpl $0x50, %edx
je 0x5c81
jmp 0x5c2f
cmpl $0x5b, %edx
je 0x5c8f
cmpl $0x5d, %edx
jne 0x5c2f
movl $0x2, %edx
jmp 0x5c18
movl $0x2, %esi
jmp 0x5c43
movl $0x2, %esi
jmp 0x5c51
// File: /workspace/github_c_makefile_star2_O1/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:
movq 0x2a0(%rdi), %rcx
xorl %eax, %eax
testq %rcx, %rcx
je 0x5cb9
movq 0x433d(%rip), %rdi      # 0x9fe8
cmpq %rdi, (%rcx)
je 0x5cba
movq 0x10(%rcx), %rcx
testq %rcx, %rcx
jne 0x5cab
retq
movl (%rsi), %edi
andl $-0x2, %edi
cmpl $0x6, %edi
jne 0x5cb9
movq 0x8(%rcx), %rcx
movl 0x8(%rcx), %edi
cmpl 0x8(%rsi), %edi
jne 0x5cb9
movq 0x10(%rcx), %rax
movq %rax, (%rdx)
movl $0x1, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x5d23
pushq %rbp
pushq %rbx
pushq %rax
movq %rsi, %rbx
xorl %ebp, %ebp
cmpl $0x2, %r8d
jl 0x5d00
movq 0x8(%rcx), %rax
cmpq $-0x1, %rax
je 0x5d00
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)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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:
movzbl %dl, %edi
xorl %eax, %eax
movl %edi, %r9d
orl $0x20, %r9d
cmpl $0x6d, %r9d
jne 0x5e1e
cmpl $0x100, %edx            # imm = 0x100
setae %r9b
cmpl $0x3, %r8d
setl %r10b
orb %r9b, %r10b
jne 0x5da1
movl $0x3, (%rsi)
movq (%rcx), %rax
movl %eax, %edx
shrl $0x2, %edx
andl $0x7, %edx
movl %edx, 0x10(%rsi)
andb $-0x1d, %al
movb %al, 0x8(%rsi)
movl 0x8(%rcx), %eax
movl 0x10(%rcx), %ecx
movl $0xfff, %edx            # imm = 0xFFF
cmpl %edx, %eax
cmovll %eax, %edx
movl $0x7ff, %eax            # imm = 0x7FF
cmpl %eax, %ecx
cmovll %ecx, %eax
movb %dl, 0x9(%rsi)
movb %al, 0xa(%rsi)
shrl $0x8, %edx
andl $0xf, %edx
shrl $0x4, %eax
andl $0x30, %eax
orl %edx, %eax
movb %al, 0xb(%rsi)
movl $0x1, %eax
retq
cmpl $0x3, %r8d
setl %r8b
andl $0xffffff00, %edx       # imm = 0xFFFFFF00
cmpl $0x3c00, %edx           # imm = 0x3C00
setne %dl
orb %r8b, %dl
jne 0x5e1e
movl $0x3, (%rsi)
movq (%rcx), %rax
movl %eax, %edx
shrl $0x2, %edx
andl $0x7, %edx
movl %edx, 0x10(%rsi)
andb $-0x1d, %al
movb %al, 0x8(%rsi)
movl 0x8(%rcx), %eax
movl 0x10(%rcx), %edx
movl $0xfff, %r8d            # imm = 0xFFF
cmpl %r8d, %eax
cmovll %eax, %r8d
movl $0x7ff, %ecx            # imm = 0x7FF
cmpl %ecx, %edx
cmovll %edx, %ecx
movb %r8b, 0x9(%rsi)
movb %cl, 0xa(%rsi)
shrl $0x8, %r8d
andl $0xf, %r8d
shrl $0x4, %ecx
andl $0x30, %ecx
orl %r8d, %ecx
movb %cl, 0xb(%rsi)
movl $0x1, %eax
cmpl $0x6d, %edi
jne 0x5e1e
orb $-0x80, %cl
movb %cl, 0xb(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x5ea3
xorl %eax, %eax
cmpl $0x2, %r8d
jl 0x5e6a
movl $0x4, (%rsi)
movl (%rcx), %eax
movl 0x8(%rcx), %ecx
movl $0xfff, %edx            # imm = 0xFFF
cmpl %edx, %ecx
cmovll %ecx, %edx
movl $0x7ff, %ecx            # imm = 0x7FF
cmpl %ecx, %eax
cmovll %eax, %ecx
movb %dl, 0x9(%rsi)
movb %cl, 0xa(%rsi)
shrl $0x8, %edx
andl $0xf, %edx
shrl $0x4, %ecx
andl $0x30, %ecx
orl %edx, %ecx
movb %cl, 0xb(%rsi)
movl $0x1, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x5eb9
movq 0x8(%rcx), %rcx
cmpq $-0x1, %rcx
je 0x5eb9
decl %ecx
movl %ecx, %eax
movl %eax, 0x10(%rsi)
movslq %edx, %rcx
shlq $0x4, %rcx
leaq 0x4346(%rip), %rdx      # 0xa210
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
movl %r8d, 0x10(%rsi)
orl -0x3f4(%rcx,%rdx), %r8d
movl %r8d, 0x10(%rsi)
xorl %eax, %eax
cmpl $-0x1, %edi
setne %al
retq
// File: /workspace/github_c_makefile_star2_O1/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 %eax, %eax
cmpl $0x2, %r8d
jl 0x5f20
movq 0x8(%rcx), %rdx
cmpq $-0x1, %rdx
je 0x5f20
decl %edx
movl %edx, %eax
movl %eax, 0x10(%rbx)
movl $0x2, (%rbx)
movq (%rcx), %rax
cmpq $0x1b, %rax
jne 0x5f47
movl 0x10(%rbx), %ebp
movq 0x10(%rcx), %rsi
movq %rbx, %rdx
callq *0x2a8(%rdi)
orl %ebp, 0x10(%rbx)
jmp 0x5f87
cmpq $0x22, %rax
ja 0x5f80
shlq $0x4, %rax
leaq 0x4af8(%rip), %rdx      # 0xaa50
movl (%rax,%rdx), %esi
movl %esi, (%rbx)
movl 0x4(%rax,%rdx), %eax
movl %eax, 0x8(%rbx)
movq (%rcx), %rax
shlq $0x4, %rax
movl 0x8(%rax,%rdx), %ecx
notl %ecx
andl 0x10(%rbx), %ecx
movl %ecx, 0x10(%rbx)
orl 0xc(%rax,%rdx), %ecx
movl %ecx, 0x10(%rbx)
jmp 0x5f87
movl $0xffffffff, 0x8(%rbx)  # imm = 0xFFFFFFFF
xorl %eax, %eax
cmpl $-0x1, 0x8(%rbx)
setne %al
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x601f
movq 0x10(%r15), %rax
addq 0x18(%r15), %rax
movzbl (%rsi,%rax), %ecx
xorl %eax, %eax
cmpb $0x40, %cl
jl 0x6079
andl $0x3f, %ecx
movl %ecx, %edx
shll $0x4, %edx
leaq 0x423f(%rip), %rdi      # 0xa210
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 0x6067
testb $0x2, 0x4(%r15)
je 0x6047
leaq 0x4a13(%rip), %rdx      # 0xaa10
movsbq (%rcx,%rdx), %rdx
testq %rdx, %rdx
je 0x6047
xorl %ecx, %ecx
movl %ecx, (%r14)
movq %rdx, 0x8(%r14)
movl %ecx, 0x10(%r14)
movb %dl, 0x14(%r14)
movb $0x0, 0x15(%r14)
jmp 0x6067
testl %ecx, %ecx
je 0x6040
movl $0x4f, %esi
movq %r15, %rdi
movq %r14, %rdx
callq *0x2a8(%r15)
orb $0x2, 0x10(%r14)
movq 0x20(%r15), %rsi
jmp 0x6071
movl $0x3, %eax
jmp 0x6079
shll $0x4, %ecx
leaq 0x45bf(%rip), %rdx      # 0xa610
movl (%rcx,%rdx), %edi
movl %edi, (%r14)
movl 0x4(%rcx,%rdx), %edi
movl %edi, 0x8(%r14)
movl 0xc(%rcx,%rdx), %ecx
movl %ecx, 0x10(%r14)
cmpl $-0x1, 0x8(%r14)
je 0x6079
incq %rsi
movq %rsi, (%rbx)
movl $0x1, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x20(%rdi), %r10
movl $0x3, %eax
cmpq %rdx, %r10
seta %dl
jbe 0x61b2
movq %rsi, %r12
movq %rdi, %r15
movq 0x10(%rdi), %rdi
movq %r14, %rsi
subq %r10, %rsi
movq 0x18(%r15), %r9
addq %r14, %r9
addq %r9, %rdi
incq %rdi
xorl %r13d, %r13d
movzbl -0x1(%rdi,%r13), %r9d
cmpl $0x1b, %r9d
je 0x60df
cmpl $0x7, %r9d
je 0x610f
cmpl $0x9c, %r9d
jne 0x60f2
jmp 0x610f
leaq (%r14,%r13), %r9
incq %r9
cmpq %r10, %r9
jae 0x60f2
cmpb $0x5c, (%rdi,%r13)
je 0x610f
leaq (%r14,%r13), %rdx
incq %rdx
cmpq %r10, %rdx
setb %dl
incq %r13
movq %rsi, %r9
addq %r13, %r9
jne 0x60c2
jmp 0x61b2
testb $0x1, %dl
je 0x61b2
leaq (%r14,%r13), %rax
leaq (%r14,%r13), %rdx
incq %rdx
movq %rdx, (%r8)
movq 0x10(%r15), %rdx
addq 0x18(%r15), %rdx
cmpb $0x1b, (%rax,%rdx)
jne 0x613f
leaq (%r14,%r13), %rax
addq $0x2, %rax
movq %rax, (%r8)
movq %rcx, (%rsp)
movq 0x10(%r12), %rdi
testq %rdi, %rdi
je 0x6152
callq 0x3050
movl 0x8(%r12), %ebx
incl %ebx
movl %ebx, 0x8(%r12)
leaq 0x1(%r13), %rdi
callq 0x31c0
movq %rax, %rbp
movq %rax, 0x10(%r12)
movq 0x10(%r15), %r12
addq 0x18(%r15), %r12
leaq (%r12,%r14), %rsi
movq %rax, %rdi
movq %r13, %rdx
callq 0x30b0
movb $0x0, (%rbp,%r13)
movb -0x1(%r14,%r12), %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)
movl $0x0, 0x10(%rax)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 %rbx
subq $0x90, %rsp
movq %rdi, %rbx
movq 0x20(%rsi), %r14
movl (%rdi), %edi
cmpl $-0x1, %edi
setne %al
testq %r14, %r14
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x6714
movq %rsp, %rsi
callq 0x32d0
cmpl $-0x1, %eax
je 0x671b
movl $0xf000, %eax           # imm = 0xF000
andl 0x18(%rsp), %eax
cmpl $0x1000, %eax           # imm = 0x1000
jne 0x671f
movl $0x1, %eax
jmp 0x675a
xorl %eax, %eax
jmp 0x675a
movq %r14, %rdi
callq 0x30f0
movq %rax, %r15
testq %r15, %r15
je 0x6714
movl (%rbx), %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x30e0
movq %rax, %rcx
xorl %eax, %eax
cmpq $-0x1, %rcx
movl $0x0, %edx
cmovneq %rcx, %rdx
addq %rdx, %r14
subq %rdx, %r15
cmpq $-0x1, %rcx
jne 0x672a
addq $0x90, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x67e8
movq %r8, %rbx
movl %ecx, %ebp
movq %rdx, %r15
movq 0x10(%rsi), %rax
xorl %r12d, %r12d
movl %r12d, %r12d
cmpq %r12, 0x20(%r14)
jbe 0x67fb
movq 0x10(%r14), %rcx
addq 0x18(%r14), %rcx
movzbl (%r12,%rcx), %esi
movq %rax, %rdi
callq 0x6b7a
testq %rax, %rax
je 0x67f9
incl %r12d
cmpl $0x0, (%rax)
jne 0x6788
movl 0x4(%rax), %ecx
cmpl $0x3, %ecx
jne 0x6816
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 0x680d
addq %r12, (%rbx)
jmp 0x680d
xorl %eax, %eax
cmpb $0x0, 0x8c(%r14)
setne %al
addl %eax, %eax
jmp 0x680d
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
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
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)
movl $0x1, %eax
jmp 0x680d
// File: /workspace/github_c_makefile_star2_O1/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 %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpl $0x1, (%rdi)
jne 0x687e
movzbl 0x4(%rbx), %ebp
cmpb 0x5(%rbx), %bpl
ja 0x687e
movl %ebp, %eax
decl %ebp
leaq (%rbx,%rax,8), %r14
addq $0x8, %r14
movzbl 0x4(%rbx), %eax
shll $0x3, %eax
movq %r14, %rcx
subq %rax, %rcx
movq (%rcx), %rdi
testq %rdi, %rdi
je 0x6870
callq 0x6834
movzbl 0x5(%rbx), %eax
incl %ebp
addq $0x8, %r14
cmpl %eax, %ebp
jb 0x6856
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x3050
// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebp
movl %edi, %r14d
movl %esi, %r15d
subl %edi, %r15d
movslq %r15d, %rax
leaq 0x10(,%rax,8), %rdi
callq 0x31c0
testq %rax, %rax
je 0x68df
movq %rax, %rbx
movl $0x1, (%rax)
movb %r14b, 0x4(%rax)
movb %bpl, 0x5(%rax)
cmpb %bpl, %r14b
ja 0x68e1
movq %rbx, %rdi
addq $0x8, %rdi
leaq 0x8(,%r15,8), %rdx
xorl %esi, %esi
callq 0x3130
jmp 0x68e1
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
cmpq $0x0, 0x8(%rdi)
je 0x6917
movq %r12, %rdi
callq 0x3260
movq %rax, %r14
jmp 0x691a
xorl %r14d, %r14d
movq (%rbx), %rcx
movq 0x78(%rcx), %rax
testq %rax, %rax
je 0x6938
movq 0x80(%rcx), %rdx
movq %r12, %rdi
movq %r14, %rsi
callq *%rax
movq %rax, %r14
leaq 0x1(%r14), %rax
cmpq $0x2, %rax
jae 0x6946
xorl %eax, %eax
jmp 0x6993
cmpb $0x0, (%r14)
je 0x6942
movl (%r15), %ebp
movl 0x4(%r15), %r12d
movl 0x8(%r15), %r13d
movl 0xc(%r15), %r15d
movl $0x14, %edi
callq 0x31c0
testq %rax, %rax
je 0x6981
movl $0x0, (%rax)
movl %ebp, 0x4(%rax)
movl %r12d, 0x8(%rax)
movl %r13d, 0xc(%rax)
movl %r15d, 0x10(%rax)
jmp 0x6983
xorl %eax, %eax
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x69a2
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, (%rsp)
movq %rsi, %r15
movq 0x10(%rdi), %r14
xorl %ebx, %ebx
movb (%r15,%rbx), %al
testb %al, %al
je 0x69e2
movzbl %al, %esi
movq %r14, %rdi
callq 0x6b7a
incq %rbx
testq %rax, %rax
cmovneq %rax, %r14
jne 0x69ba
cmpq $0x1, %rax
sbbl $-0x1, %ebx
decl %ebx
movslq %ebx, %r13
movzbl (%r15,%r13), %ebp
testl %ebp, %ebp
je 0x6a73
cmpb $0x0, 0x1(%r15,%r13)
movq (%rsp), %r12
je 0x6a34
movl $0x808, %edi            # imm = 0x808
callq 0x31c0
testq %rax, %rax
je 0x6a31
movq %rax, %r12
movl $0x1, (%rax)
movw $0xff00, 0x4(%rax)      # imm = 0xFF00
movq %rax, %rdi
addq $0x8, %rdi
movl $0x800, %edx            # imm = 0x800
xorl %esi, %esi
callq 0x3130
jmp 0x6a34
xorl %r12d, %r12d
testq %r12, %r12
je 0x6a6a
incq %r13
movl %r13d, %ebx
movl (%r14), %eax
cmpl $0x1, %eax
je 0x6a4d
testl %eax, %eax
jne 0x6a6a
jmp 0x6aa6
movzbl 0x4(%r14), %ecx
cmpb %cl, %bpl
jb 0x6a82
cmpb 0x5(%r14), %bpl
ja 0x6a82
subl %ecx, %ebp
movslq %ebp, %rax
movq %r12, 0x8(%r14,%rax,8)
movq %r12, %r14
testq %r12, %r12
jne 0x69e2
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3567(%rip), %rax      # 0x9ff0
movq (%rax), %rdi
movzbl 0x5(%r14), %r8d
leaq 0xa48(%rip), %rsi       # 0x74e0
movl %ebp, %edx
xorl %eax, %eax
callq 0x3190
callq 0x3080
callq 0x335b
// File: /workspace/github_c_makefile_star2_O1/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 0x6b6b
movq %rdi, %rbx
cmpl $0x1, (%rdi)
jne 0x6b6d
cmpq $0x0, 0x8(%rbx)
je 0x6ad4
xorl %eax, %eax
jmp 0x6aee
xorl %ecx, %ecx
cmpq $0xff, %rcx
je 0x6b43
leaq 0x1(%rcx), %rax
cmpq $0x0, 0x10(%rbx,%rcx,8)
movq %rax, %rcx
je 0x6ad6
xorl %ecx, %ecx
decb %cl
movzbl %cl, %r14d
cmpq $0x0, 0x8(%rbx,%r14,8)
je 0x6af0
movzbl %al, %r12d
movl %r12d, %edi
movl %r14d, %esi
callq 0x688a
movq %rax, %r15
cmpb %r14b, %r12b
ja 0x6b36
leaq 0x8(%r15), %r13
decq %r12
movq 0x10(%rbx,%r12,8), %rdi
callq 0x6aab
movq %rax, (%r13)
incq %r12
addq $0x8, %r13
cmpq %r14, %r12
jb 0x6b1c
movq %rbx, %rdi
callq 0x3050
movq %r15, %rbx
jmp 0x6b6d
movq %rbx, %rdi
callq 0x3050
movl $0x8, %edi
callq 0x31c0
testq %rax, %rax
je 0x6b6b
movq %rax, %rbx
movl $0x1, (%rax)
movw $0x1, 0x4(%rax)
jmp 0x6b6d
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x6b8b
testl %eax, %eax
jne 0x6b9a
pushq %rax
callq 0x337d
movzbl 0x4(%rdi), %eax
cmpb %sil, %al
ja 0x6b9a
cmpb %sil, 0x5(%rdi)
jae 0x6b9d
xorl %eax, %eax
retq
movzbl %sil, %ecx
subq %rax, %rcx
movq 0x8(%rdi,%rcx,8), %rax
retq
// File: /workspace/github_c_makefile_star2_O1/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, %ebp
callq 0x12d5
testl %eax, %eax
jne 0x120f
movl $0x1, %edi
callq 0x10a0
movslq 0x2e5a(%rip), %rax      # 0x4070
movl %ebp, %ecx
subl %eax, %ecx
cmpl $0x2, %ecx
jl 0x1293
leaq 0x1(%rax), %r12
cmpl %ebp, %r12d
jge 0x12a6
decl %ebp
movslq %ebp, %r13
movl %r13d, %ebp
subl %eax, %ebp
leaq 0xdcb(%rip), %r14       # 0x2004
movq (%rbx,%r12,8), %rdi
movq %r14, %rsi
callq 0x1090
testq %rax, %rax
je 0x12ad
movq %rax, %r15
movq (%rbx,%r12,8), %rdi
callq 0x1030
movslq 0x2e13(%rip), %rax      # 0x4070
movq (%rbx,%rax,8), %rdi
movq %r15, %rsi
callq 0x13a0
movq %r15, %rdi
callq 0x1040
cmpq %r13, %r12
jge 0x128a
movq 0x2d53(%rip), %rax      # 0x3fd0
movq (%rax), %rsi
movl $0xa, %edi
callq 0x1070
incq %r12
decl %ebp
jne 0x1239
jmp 0x12a6
movq (%rbx,%rax,8), %rdi
movq 0x2d3a(%rip), %rax      # 0x3fd8
movq (%rax), %rsi
callq 0x13a0
xorl %edi, %edi
callq 0x10a0
movq 0x2d44(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
movq 0x2dca(%rip), %rdx      # 0x4088
movq (%rbx,%r12,8), %rcx
leaq 0xd3d(%rip), %rsi       # 0x2006
xorl %eax, %eax
callq 0x1080
jmp 0x1205
// File: /workspace/github_c_makefile_star2_O1/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_7/exercise_7_07/find.c
// Function: parse_arg_list
boolean parse_arg_list(int argc, char *argv[])
{
  program_name = argv[0];

  if (argc < 3)
  {
    fprintf(stderr, "Usage: %s [-xn]... PATTERN [FILE]...\n", program_name);
    return false;
  }

  while (--argc > 0 && (*++argv)[0] == '-')
  {
    int c;
    while ((c = *++argv[0]))
    {
      switch (c)
      {
      case 'x':
        except = true;
        break;

      case 'n':
        number = true;
        break;

      default:
        fprintf(stderr, "%s: illegal option %c.\n", program_name, c);
        return false;
        break;
      }
    }

    ++pattern_arg_pos;
  }

  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq (%rsi), %rdx
movq %rdx, 0x2da1(%rip)      # 0x4088
cmpl $0x3, %edi
jl 0x1383
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x2d84(%rip), %r15      # 0x4080
leaq 0x2d81(%rip), %r12      # 0x4084
movl $0x1, %r14d
cmpl $0x2, %ebp
jl 0x1377
movq 0x8(%rbx), %rax
cmpb $0x2d, (%rax)
jne 0x1377
addq $0x8, %rbx
movq (%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rbx)
movb 0x1(%rax), %cl
testb %cl, %cl
sete %r14b
je 0x135d
addq $0x2, %rax
movq %r15, %rdx
cmpb $0x78, %cl
je 0x1347
movzbl %cl, %edi
cmpl $0x6e, %edi
jne 0x136d
movq %r12, %rdx
movl $0x1, (%rdx)
movq %rax, (%rbx)
movb (%rax), %cl
incq %rax
testb %cl, %cl
sete %r14b
jne 0x1334
incl 0x2d0d(%rip)            # 0x4070
decl %ebp
testb $0x1, %r14b
jne 0x1303
jmp 0x1374
callq 0x10d0
jmp 0x1363
xorl %r14d, %r14d
movl %r14d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x2c6e(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0xc86(%rip), %rsi       # 0x201a
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x1080
jmp 0x1377
// File: /workspace/github_c_makefile_star2_O1/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_7/exercise_7_07/find.c
// Function: find_pattern
void find_pattern(char *pattern, FILE *file_p)
{
  size_t line_number = 1;
  char line[MAX_LINE_LEN];
  while (fgets(line, MAX_LINE_LEN, file_p) != NULL)
  {
    if ((strstr(line, pattern) != NULL) != except)
    {
      if (number)
      {
        printf("%ld: ", line_number);
      }
      printf("%s", line);
    }
    ++line_number;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3e8, %rsp            # imm = 0x3E8
movq %rsi, %rbx
movq %rdi, %r14
movq %rsp, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
movq %rbx, %rdx
callq 0x1060
testq %rax, %rax
je 0x1439
movl $0x1, %r15d
movq %rsp, %r12
leaq 0xc82(%rip), %r13       # 0x205e
leaq 0xc75(%rip), %rbp       # 0x2058
movq %r12, %rdi
movq %r14, %rsi
callq 0x10b0
xorl %ecx, %ecx
testq %rax, %rax
setne %cl
cmpl %ecx, 0x2c84(%rip)      # 0x4080
je 0x1421
cmpl $0x0, 0x2c7f(%rip)      # 0x4084
je 0x1414
movq %rbp, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1050
movq %r13, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x1050
incq %r15
movq %r12, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
movq %rbx, %rdx
callq 0x1060
testq %rax, %rax
jne 0x13e3
addq $0x3e8, %rsp            # imm = 0x3E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq