// File: /workspace/github_c_makefile_star2_O3/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 0x4eb1
cmpq $0x1f, %rsi
jg 0x4ec0
movq $0x0, 0x8(%rbx)
testb $0x1, 0x4(%rdi)
jne 0x4edb
movq %rsi, %rcx
shlq $0x4, %rcx
movl 0xa4(%rdi,%rcx), %eax
cmpl $-0x1, %eax
je 0x4edb
addq %rdi, %rcx
addq $0xa0, %rcx
movl %eax, 0x8(%rbx)
movl 0xc(%rcx), %ecx
movl %ecx, 0x10(%rbx)
testl %eax, %eax
je 0x4edb
movl $0x2, (%rbx)
jmp 0x4eff
movl $0x2, (%rbx)
movl $0x5, 0x8(%rbx)
jmp 0x4ef8
cmpq $0x7f, %rsi
jne 0x4f17
testb $0x1, 0x4(%rdi)
jne 0x4f19
movl $0x2, (%rbx)
movl $0x6, 0x8(%rbx)
jmp 0x4f4a
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)
movq %rbx, %rsi
callq 0x3270
cmpl $0x0, (%rbx)
je 0x4f0e
popq %rbx
retq
movq %rbx, %rdi
popq %rbx
jmp 0x3b05
ja 0x4f26
xorl %eax, %eax
movl %eax, (%rbx)
movq %rsi, 0x8(%rbx)
movl %eax, 0x10(%rbx)
jmp 0x4eff
movl $0x0, (%rbx)
cmpq $0x9f, %rsi
ja 0x4f46
addq $-0x40, %rsi
movq %rsi, 0x8(%rbx)
movl $0x6, 0x10(%rbx)
jmp 0x4eff
movq %rsi, 0x8(%rbx)
movl $0x0, 0x10(%rbx)
jmp 0x4eff