// File: /workspace/github_c_makefile_star2_O2/jaimecgomezz[P]st/x.c
// Function: kpress
void kpress(XEvent *ev) {
  XKeyEvent *e = &ev->xkey;
  KeySym ksym;
  char buf[64], *customkey;
  int len;
  Rune c;
  Status status;
  Shortcut *bp;

  // >>>>>>>>>>>>>>>>>>>> hide-cursor
  // ==================== hide-cursor
  // ==================== hide-cursor
  // <<<<<<<<<<<<<<<<<<<< hide-cursor

  if (IS_SET(MODE_KBDLOCK))
    return;

  if (xw.ime.xic)
    len = XmbLookupString(xw.ime.xic, e, buf, sizeof buf, &ksym, &status);
  else
    len = XLookupString(e, buf, sizeof buf, &ksym, NULL);
  // >>>>>>>>>>>>>>>>>>>> vim-browse
  // ==================== vim-browse
  // ==================== vim-browse
  // <<<<<<<<<<<<<<<<<<<< vim-browse
  // >>>>>>>>>>>>>>>>>>>> keyboard-select
  // ==================== keyboard-select
  // ==================== keyboard-select
  // <<<<<<<<<<<<<<<<<<<< keyboard-select
  /* 1. shortcuts */
  for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) {
    if (ksym == bp->keysym && match(bp->mod, e->state)) {
      bp->func(&(bp->arg));
      return;
    }
  }

  /* 2. custom keys from config.h */
  if ((customkey = kmap(ksym, e->state))) {
    ttywrite(customkey, strlen(customkey), 1);
    return;
  }

  /* 3. composed string from input method */
  if (len == 0)
    return;
  if (len == 1 && e->state & Mod1Mask) {
    if (IS_SET(MODE_8BIT)) {
      if (*buf < 0177) {
        c = *buf | 0x80;
        len = utf8encode(c, buf);
      }
    } else {
      buf[1] = buf[0];
      buf[0] = '\033';
      len = 2;
    }
  }
  ttywrite(buf, len, 1);
}

// Assembly:
testb $0x40, 0xaf0e(%rip)     # 0x16da8
jne 0xc03d
pushq %rbx
subq $0x50, %rsp
movq %rdi, %rbx
movq 0xae31(%rip), %rdi      # 0x16ce0
testq %rdi, %rdi
je 0xbece
leaq 0x10(%rsp), %rdx
pushq $0x40
popq %rcx
movq %rsp, %r8
leaq 0xc(%rsp), %r9
movq %rbx, %rsi
callq 0x5700
jmp 0xbee4
leaq 0x10(%rsp), %rsi
pushq $0x40
popq %rdx
movq %rsp, %rcx
movq %rbx, %rdi
xorl %r8d, %r8d
callq 0x5150
movq (%rsp), %rcx
xorl %edx, %edx
leaq 0x864f(%rip), %rsi      # 0x14540
movl $0xffffdfef, %edi       # imm = 0xFFFFDFEF
cmpq $0x17f, %rdx            # imm = 0x17F
ja 0xbf2a
cmpq 0x8(%rdx,%rsi), %rcx
jne 0xbf24
movl (%rdx,%rsi), %r8d
cmpl $-0x1, %r8d
je 0xc003
movl 0x50(%rbx), %r9d
andl %edi, %r9d
cmpl %r8d, %r9d
je 0xc003
addq $0x20, %rdx
jmp 0xbef6
movl 0x50(%rbx), %edx
movl %ecx, %esi
andl $0xff00, %esi           # imm = 0xFF00
cmpl $0xfd00, %esi           # imm = 0xFD00
jae 0xbf7c
testl %eax, %eax
je 0xc038
cmpl $0x1, %eax
jne 0xc028
pushq $0x1
popq %rax
testb $0x8, %dl
je 0xc028
testb $0x4, 0xae48(%rip)      # 0x16da9
movb 0x10(%rsp), %cl
jne 0xc010
movb %cl, 0x11(%rsp)
movb $0x1b, 0x10(%rsp)
pushq $0x2
popq %rax
jmp 0xc028
movl %edx, %esi
andl $0xffffdfef, %esi       # imm = 0xFFFFDFEF
movl 0xae1d(%rip), %r8d      # 0x16da8
xorl %edi, %edi
leaq 0x63ec(%rip), %r9       # 0x12380
movl %r8d, %r10d
shrl $0x11, %r10d
cmpq $0x1a1f, %rdi           # imm = 0x1A1F
ja 0xbf3d
cmpq %rcx, (%rdi,%r9)
jne 0xbffd
movl 0x8(%rdi,%r9), %r11d
cmpl $-0x1, %r11d
setne %bl
cmpl %r11d, %esi
setne %r11b
testb %r11b, %bl
jne 0xbffd
movb 0x18(%rdi,%r9), %r11b
testb $0x4, %r8b
jne 0xbfd4
testb %r11b, %r11b
jg 0xbffd
jmp 0xbfe5
cmpb $0x2, %r11b
sete %bl
testb %r11b, %r11b
js 0xbffd
andb %r10b, %bl
jne 0xbffd
btl $0x8, %r8d
movb 0x19(%rdi,%r9), %r11b
jb 0xbff8
testb %r11b, %r11b
jg 0xbffd
jmp 0xc03e
testb %r11b, %r11b
jns 0xc03e
addq $0x20, %rdi
jmp 0xbf9b
leaq (%rdx,%rsi), %rdi
addq $0x18, %rdi
callq *-0x8(%rdi)
jmp 0xc038
cmpb $0x7f, %cl
je 0xc028
movsbl %cl, %edi
orl $0x80, %edi
leaq 0x10(%rsp), %rsi
callq 0x5b12
movslq %eax, %rsi
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rdx
callq 0x671c
addq $0x50, %rsp
popq %rbx
retq
movq 0x10(%rdi,%r9), %rbx
testq %rbx, %rbx
je 0xbf3d
movq %rbx, %rdi
callq 0x5350
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %rax, %rsi
jmp 0xc033