// File: /workspace/github_c_makefile_star2_O3/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 0x2755
leal -0x5b(%rax), %esi
cmpl $0x12, %esi
ja 0x27da
movl $0x1e, %ecx
btl %esi, %ecx
jb 0x2725
movl $0x1, %ecx
movl $0x4c001, %r9d          # imm = 0x4C001
btl %esi, %r9d
jae 0x27da
testl $0xfffffffd, %r8d       # imm = 0xFFFFFFFD
je 0x2725
testl %ecx, %ecx
je 0x2725
incl %r8d
leaq 0x9b81(%rip), %rdx      # 0xc298
movl $0x9b, %esi
movl %eax, %ecx
xorl %eax, %eax
jmp 0xaf11
movl %eax, %ecx
andl $0x1f, %ecx
testb $0x4, %r8b
cmovel %eax, %ecx
testb $0x2, %r8b
leaq 0x9b72(%rip), %rax      # 0xc2ae
leaq 0x9b61(%rip), %rdx      # 0xc2a4
cmoveq %rax, %rdx
leaq 0x9b51(%rip), %rsi      # 0xc29f
xorl %eax, %eax
jmp 0xae8d
pushq %rax
cmpl $0x80, %eax
jae 0x2767
movl $0x1, %edx
jmp 0x282d
movl %eax, %ecx
movl $0x2, %edx
cmpl $0x800, %eax            # imm = 0x800
jb 0x279a
movl $0x3, %edx
cmpl $0x10000, %eax          # imm = 0x10000
jb 0x279a
movl $0x4, %edx
cmpl $0x200000, %eax         # imm = 0x200000
jb 0x279a
cmpl $0x4000000, %eax        # imm = 0x4000000
movl $0x6, %edx
sbbl $0x0, %edx
movl %edx, %eax
incq %rax
movl %ecx, %esi
andb $0x3f, %sil
orb $-0x80, %sil
movb %sil, (%rsp,%rax)
shrq $0x6, %rcx
decq %rax
cmpq $0x2, %rax
ja 0x279f
addl $-0x2, %edx
leaq 0x985c(%rip), %rax      # 0xc020
movslq (%rax,%rdx,4), %rdx
addq %rax, %rdx
jmpq *%rdx
andb $0x1f, %cl
orb $-0x40, %cl
movl $0x2, %edx
jmp 0x282b
cmpl $0x20, %eax
jne 0x27e9
andl $0x1, %edx
movl %edx, %ecx
jmp 0x2700
leal -0x7b(%rax), %edx
xorl %ecx, %ecx
cmpl $-0x1a, %edx
setb %cl
jmp 0x2700
andb $0x1, %cl
orb $-0x4, %cl
movl $0x6, %edx
jmp 0x282b
andb $0x7, %cl
orb $-0x10, %cl
movl $0x4, %edx
jmp 0x282b
andb $0x3, %cl
orb $-0x8, %cl
movl $0x5, %edx
jmp 0x282b
andb $0xf, %cl
orb $-0x20, %cl
movl $0x3, %edx
movl %ecx, %eax
leaq 0x2(%rsp), %rsi
movb %al, (%rsi)
callq 0xadad
popq %rax
retq