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

	if (IS_SET(MODE_KBDLOCK))
		return;

	if (xw.ime.xic) {
		len = XmbLookupString(xw.ime.xic, e, buf, sizeof buf, &ksym, &status);
		if (status == XBufferOverflow)
			return;
	} else {
		len = XLookupString(e, buf, sizeof buf, &ksym, NULL);
	}
	if ( IS_SET(MODE_KBDSELECT) ) {
		if ( match(XK_NO_MOD, e->state) ||
		     (XK_Shift_L | XK_Shift_R) & e->state )
			win.mode ^= trt_kbdselect(ksym, buf, len);
		return;
	}
	/* 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:
pushq %r14
pushq %rbx
subq $0x58, %rsp
andq $0x0, (%rsp)
testb $0x40, 0xde2b(%rip)     # 0x1cc18
jne 0xefcb
movq %rdi, %rbx
movq 0xdd4b(%rip), %rdi      # 0x1cb48
testq %rdi, %rdi
je 0xee28
leaq 0x10(%rsp), %rdx
pushq $0x40
popq %rcx
movq %rsp, %r8
leaq 0xc(%rsp), %r14
movq %rbx, %rsi
movq %r14, %r9
callq 0x6760
cmpl $-0x1, (%r14)
jne 0xee3e
jmp 0xefcb
leaq 0x10(%rsp), %rsi
pushq $0x40
popq %rdx
movq %rsp, %rcx
movq %rbx, %rdi
xorl %r8d, %r8d
callq 0x6150
movl 0xddd4(%rip), %ecx      # 0x1cc18
btl $0x12, %ecx
jb 0xee91
movq (%rsp), %rdx
xorl %esi, %esi
leaq 0xa359(%rip), %rdi      # 0x191b0
movl $0xffff9fef, %r8d       # imm = 0xFFFF9FEF
cmpq $0x21f, %rsi            # imm = 0x21F
ja 0xeec8
cmpq 0x8(%rsi,%rdi), %rdx
jne 0xee8b
movl (%rsi,%rdi), %r9d
cmpl $-0x1, %r9d
je 0xef97
movl 0x50(%rbx), %r10d
andl %r8d, %r10d
cmpl %r9d, %r10d
je 0xef97
addq $0x20, %rsi
jmp 0xee5d
movl 0x50(%rbx), %ecx
testl $0xffff9fef, %ecx       # imm = 0xFFFF9FEF
setne %dl
testw $0xffe3, %cx            # imm = 0xFFE3
sete %cl
testb %cl, %dl
jne 0xefcb
movq (%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl %eax, %edx
callq 0x85b6
xorl %eax, 0xdd55(%rip)      # 0x1cc18
jmp 0xefcb
movl 0x50(%rbx), %esi
movl %edx, %edi
andl $0xff00, %edi           # imm = 0xFF00
cmpl $0xfd00, %edi           # imm = 0xFD00
jae 0xef18
testl %eax, %eax
je 0xefcb
cmpl $0x1, %eax
jne 0xefbb
pushq $0x1
popq %rax
testb $0x8, %sil
je 0xefbb
btl $0xa, %ecx
movb 0x10(%rsp), %cl
jb 0xefa3
movb %cl, 0x11(%rsp)
movb $0x1b, 0x10(%rsp)
pushq $0x2
popq %rax
jmp 0xefbb
movl %esi, %edi
andl $0xffff9fef, %edi       # imm = 0xFFFF9FEF
xorl %r8d, %r8d
leaq 0x7446(%rip), %r9       # 0x16370
movl %ecx, %r10d
shrl $0x11, %r10d
cmpq $0x1a1f, %r8            # imm = 0x1A1F
ja 0xeedb
cmpq %rdx, (%r8,%r9)
jne 0xef91
movl 0x8(%r8,%r9), %r11d
cmpl $-0x1, %r11d
setne %bl
cmpl %r11d, %edi
setne %r11b
testb %r11b, %bl
jne 0xef91
movb 0x18(%r8,%r9), %r11b
testb $0x4, %cl
jne 0xef69
testb %r11b, %r11b
jg 0xef91
jmp 0xef7a
cmpb $0x2, %r11b
sete %bl
testb %r11b, %r11b
js 0xef91
andb %r10b, %bl
jne 0xef91
btl $0x8, %ecx
movb 0x19(%r8,%r9), %r11b
jb 0xef8c
testb %r11b, %r11b
jg 0xef91
jmp 0xefd3
testb %r11b, %r11b
jns 0xefd3
addq $0x20, %r8
jmp 0xef31
addq %rsi, %rdi
addq $0x18, %rdi
callq *-0x8(%rdi)
jmp 0xefcb
cmpb $0x7f, %cl
je 0xefbb
movsbl %cl, %edi
orl $0x80, %edi
leaq 0x10(%rsp), %rsi
callq 0x6c46
movslq %eax, %rsi
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rdx
callq 0x79bf
addq $0x58, %rsp
popq %rbx
popq %r14
retq
movq 0x10(%r8,%r9), %rbx
testq %rbx, %rbx
je 0xeedb
movq %rbx, %rdi
callq 0x6390
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %rax, %rsi
jmp 0xefc6