// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x5e70
movq -0x18(%rbp), %rax
movl $0x2, (%rax)
movq -0x18(%rbp), %rax
movl $0x5, 0x8(%rax)
movq -0x18(%rbp), %rax
movl $0x4, 0x10(%rax)
jmp 0x603e
cmpq $0x20, -0x10(%rbp)
jge 0x5f6b
movq -0x18(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x5efd
movq -0x8(%rbp), %rax
addq $0xa0, %rax
movq -0x10(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
cmpl $-0x1, 0x4(%rax)
je 0x5efd
movq -0x8(%rbp), %rax
addq $0xa0, %rax
movq -0x10(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x8(%rbp), %rax
addq $0xa0, %rax
movq -0x10(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
movq -0x18(%rbp), %rax
orl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x5f5c
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
addq $0x40, %rax
cmpq $0x41, %rax
jl 0x5f3f
movq -0x10(%rbp), %rax
addq $0x40, %rax
cmpq $0x5a, %rax
jg 0x5f3f
movq -0x10(%rbp), %rcx
addq $0x60, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x5f4f
movq -0x10(%rbp), %rcx
addq $0x40, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movl $0x4, 0x10(%rax)
jmp 0x5f66
movq -0x18(%rbp), %rax
movl $0x2, (%rax)
jmp 0x603c
cmpq $0x7f, -0x10(%rbp)
jne 0x5fa6
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x5fa6
movq -0x18(%rbp), %rax
movl $0x2, (%rax)
movq -0x18(%rbp), %rax
movl $0x6, 0x8(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x10(%rax)
jmp 0x603a
cmpq $0x20, -0x10(%rbp)
jl 0x5fda
cmpq $0x80, -0x10(%rbp)
jge 0x5fda
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x10(%rax)
jmp 0x6038
cmpq $0x80, -0x10(%rbp)
jl 0x6015
cmpq $0xa0, -0x10(%rbp)
jge 0x6015
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rcx
subq $0x40, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movl $0x6, 0x10(%rax)
jmp 0x6036
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x10(%rax)
jmp 0x6038
jmp 0x603a
jmp 0x603c
jmp 0x603e
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x32a0
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x605d
movq -0x18(%rbp), %rdi
callq 0x4090
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)