// File: /workspace/github_c_makefile_star2_O2/neovim[P]libvterm/src/keyboard.c
// Function: vterm_keyboard_unichar
void vterm_keyboard_unichar(VTerm *vt, uint32_t c, VTermModifier mod)
{
  /* The shift modifier is never important for Unicode characters
   * apart from Space
   */
  if(c != ' ')
    mod &= ~VTERM_MOD_SHIFT;

  if(mod == 0) {
    // Normal text - ignore just shift
    char str[6];
    int seqlen = fill_utf8(c, str);
    vterm_push_output_bytes(vt, str, seqlen);
    return;
  }

  int needs_CSIu;
  switch(c) {
    /* Special Ctrl- letters that can't be represented elsewise */
    case 'i': case 'j': case 'm': case '[':
      needs_CSIu = 1;
      break;
    /* Ctrl-\ ] ^ _ don't need CSUu */
    case '\\': case ']': case '^': case '_':
      needs_CSIu = 0;
      break;
    /* Shift-space needs CSIu */
    case ' ':
      needs_CSIu = !!(mod & VTERM_MOD_SHIFT);
      break;
    /* All other characters needs CSIu except for letters a-z */
    default:
      needs_CSIu = (c < 'a' || c > 'z');
  }

  /* ALT we can just prefix with ESC; anything else requires CSI u */
  if(needs_CSIu && (mod & ~VTERM_MOD_ALT)) {
    vterm_push_output_sprintf_ctrl(vt, C1_CSI, "%d;%du", c, mod+1);
    return;
  }

  if(mod & VTERM_MOD_CTRL)
    c &= 0x1f;

  vterm_push_output_sprintf(vt, "%s%c", mod & VTERM_MOD_ALT ? ESC_S : "", c);
}

// Assembly:
movl %esi, %eax
movl %edx, %r8d
andl $-0x2, %r8d
cmpl $0x20, %esi
cmovel %edx, %r8d
testl %r8d, %r8d
je 0x2640
leal -0x5b(%rax), %ecx
cmpl $0x12, %ecx
ja 0x26b2
pushq $0x1e
popq %rsi
btl %ecx, %esi
jb 0x2650
movl $0x4c001, %esi          # imm = 0x4C001
btl %ecx, %esi
jae 0x26b2
pushq $0x1
popq %rdx
jmp 0x2652
movl %eax, %ecx
cmpl $0x80, %eax
jae 0x26a7
pushq $0x1
jmp 0x26e0
xorl %edx, %edx
testl $0xfffffffd, %r8d       # imm = 0xFFFFFFFD
je 0x2677
testl %edx, %edx
je 0x2677
incl %r8d
leaq 0x7c2f(%rip), %rdx      # 0xa298
movl $0x9b, %esi
movl %eax, %ecx
xorl %eax, %eax
jmp 0x9800
movl %eax, %ecx
andl $0x1f, %ecx
testb $0x4, %r8b
cmovel %eax, %ecx
testb $0x2, %r8b
leaq 0x7c20(%rip), %rax      # 0xa2ae
leaq 0x7c0f(%rip), %rdx      # 0xa2a4
cmoveq %rax, %rdx
leaq 0x7bff(%rip), %rsi      # 0xa29f
xorl %eax, %eax
jmp 0x977c
cmpl $0x800, %eax            # imm = 0x800
jae 0x26bc
pushq $0x2
jmp 0x26e0
cmpl $0x20, %eax
jne 0x26c7
andl $0x1, %edx
jmp 0x2652
cmpl $0x10000, %eax          # imm = 0x10000
jae 0x26d7
pushq $0x3
jmp 0x26e0
leal -0x7b(%rax), %ecx
xorl %edx, %edx
cmpl $-0x1a, %ecx
setb %dl
jmp 0x2652
cmpl $0x200000, %eax         # imm = 0x200000
jae 0x2751
pushq $0x4
popq %rax
pushq %rax
movl %eax, %edx
movq %rdx, %rax
cmpq $0x2, %rax
jl 0x2705
movl %ecx, %esi
andb $0x3f, %sil
orb $-0x80, %sil
movb %sil, 0x1(%rsp,%rax)
decq %rax
shrq $0x6, %rcx
jmp 0x26e7
leal -0x1(%rdx), %eax
leaq 0x7911(%rip), %rsi      # 0xa020
movslq (%rsi,%rax,4), %rax
addq %rsi, %rax
jmpq *%rax
andb $0x7f, %cl
jmp 0x2743
andb $0x3, %cl
orb $-0x8, %cl
jmp 0x2743
andb $0xf, %cl
orb $-0x20, %cl
jmp 0x2743
andb $0x7, %cl
orb $-0x10, %cl
jmp 0x2743
andb $0x1f, %cl
orb $-0x40, %cl
jmp 0x2743
andb $0x1, %cl
orb $-0x4, %cl
leaq 0x2(%rsp), %rsi
movb %cl, (%rsi)
callq 0x96ec
popq %rax
retq
cmpl $0x4000000, %eax        # imm = 0x4000000
pushq $0x6
popq %rax
sbbl $0x0, %eax
jmp 0x26e1