// File: /workspace/github_c_makefile_star2_O1/neovim[P]libtermkey/termkey.c
// Function: emit_codepoint
static void emit_codepoint(TermKey *tk, long codepoint, TermKeyKey *key)
{
  if(codepoint == 0) {
    // ASCII NUL = Ctrl-Space
    key->type = TERMKEY_TYPE_KEYSYM;
    key->code.sym = TERMKEY_SYM_SPACE;
    key->modifiers = TERMKEY_KEYMOD_CTRL;
  }
  else if(codepoint < 0x20) {
    // C0 range
    key->code.codepoint = 0;
    key->modifiers = 0;

    if(!(tk->flags & TERMKEY_FLAG_NOINTERPRET) && tk->c0[codepoint].sym != TERMKEY_SYM_UNKNOWN) {
      key->code.sym = tk->c0[codepoint].sym;
      key->modifiers |= tk->c0[codepoint].modifier_set;
    }

    if(!key->code.sym) {
      key->type = TERMKEY_TYPE_UNICODE;
      /* Generically modified Unicode ought not report the SHIFT state, or else
       * we get into complications trying to report Shift-; vs : and so on...
       * In order to be able to represent Ctrl-Shift-A as CTRL modified
       * unicode A, we need to call Ctrl-A simply 'a', lowercase
       */
      if(codepoint+0x40 >= 'A' && codepoint+0x40 <= 'Z')
        // it's a letter - use lowercase instead
        key->code.codepoint = codepoint + 0x60;
      else
        key->code.codepoint = codepoint + 0x40;
      key->modifiers = TERMKEY_KEYMOD_CTRL;
    }
    else {
      key->type = TERMKEY_TYPE_KEYSYM;
    }
  }
  else if(codepoint == 0x7f && !(tk->flags & TERMKEY_FLAG_NOINTERPRET)) {
    // ASCII DEL
    key->type = TERMKEY_TYPE_KEYSYM;
    key->code.sym = TERMKEY_SYM_DEL;
    key->modifiers = 0;
  }
  else if(codepoint >= 0x20 && codepoint < 0x80) {
    // ASCII lowbyte range
    key->type = TERMKEY_TYPE_UNICODE;
    key->code.codepoint = codepoint;
    key->modifiers = 0;
  }
  else if(codepoint >= 0x80 && codepoint < 0xa0) {
    // UTF-8 never starts with a C1 byte. So we can be sure of these
    key->type = TERMKEY_TYPE_UNICODE;
    key->code.codepoint = codepoint - 0x40;
    key->modifiers = TERMKEY_KEYMOD_CTRL|TERMKEY_KEYMOD_ALT;
  }
  else {
    // UTF-8 codepoint
    key->type = TERMKEY_TYPE_UNICODE;
    key->code.codepoint = codepoint;
    key->modifiers = 0;
  }

  termkey_canonicalise(tk, key);

  if(key->type == TERMKEY_TYPE_UNICODE)
    fill_utf8(key);
}

// Assembly:
pushq %rbx
movq %rdx, %rbx
testq %rsi, %rsi
je 0x4f39
cmpq $0x1f, %rsi
jg 0x4f48
movq $0x0, 0x8(%rbx)
movl $0x0, 0x10(%rbx)
testb $0x1, 0x4(%rdi)
jne 0x4f28
movq %rsi, %rax
shlq $0x4, %rax
movl 0xa4(%rdi,%rax), %ecx
cmpl $-0x1, %ecx
je 0x4f28
addq %rdi, %rax
addq $0xa0, %rax
movl %ecx, 0x8(%rbx)
movl 0xc(%rax), %eax
movl %eax, 0x10(%rbx)
cmpl $0x0, 0x8(%rbx)
je 0x4f76
movl $0x2, (%rbx)
jmp 0x4fc7
movl $0x2, (%rbx)
movl $0x5, 0x8(%rbx)
jmp 0x4f93
cmpq $0x7f, %rsi
jne 0x4f63
testb $0x1, 0x4(%rdi)
jne 0x4f63
movl $0x2, (%rbx)
movl $0x6, 0x8(%rbx)
jmp 0x4fc0
cmpq $0x7f, %rsi
jg 0x4f9c
xorl %eax, %eax
movl %eax, (%rbx)
movq %rsi, 0x8(%rbx)
movl %eax, 0x10(%rbx)
jmp 0x4fc7
movl $0x0, (%rbx)
xorl %eax, %eax
cmpq $0x1b, %rsi
setb %al
shll $0x5, %eax
addq %rsi, %rax
addq $0x40, %rax
movq %rax, 0x8(%rbx)
movl $0x4, 0x10(%rbx)
jmp 0x4fc7
movl $0x0, (%rbx)
cmpq $0x9f, %rsi
jg 0x4fbc
addq $-0x40, %rsi
movq %rsi, 0x8(%rbx)
movl $0x6, 0x10(%rbx)
jmp 0x4fc7
movq %rsi, 0x8(%rbx)
movl $0x0, 0x10(%rbx)
movq %rbx, %rsi
callq 0x3270
cmpl $0x0, (%rbx)
je 0x4fd6
popq %rbx
retq
movq %rbx, %rdi
popq %rbx
jmp 0x3b1e