// File: /workspace/github_c_makefile_star2_O1/odknt[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);
	}
	/* 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
movq $0x0, (%rsp)
testb $0x40, 0xfa2f(%rip)     # 0x1e944
jne 0xf0f6
movq %rdi, %rbx
movq 0xf933(%rip), %rdi      # 0x1e858
testq %rdi, %rdi
je 0xef52
leaq 0x10(%rsp), %rdx
movq %rsp, %r8
leaq 0xc(%rsp), %r14
movq %rbx, %rsi
movl $0x40, %ecx
movq %r14, %r9
callq 0x6840
cmpl $-0x1, (%r14)
jne 0xef6a
jmp 0xf0f6
leaq 0x10(%rsp), %rsi
movq %rsp, %rcx
movq %rbx, %rdi
movl $0x40, %edx
xorl %r8d, %r8d
callq 0x6170
movl $0x18, %ecx
movq (%rsp), %rsi
leaq 0x91f6(%rip), %rdx      # 0x18170
movl $0xffff9fef, %edi       # imm = 0xFFFF9FEF
cmpq -0x10(%rcx,%rdx), %rsi
jne 0xef9d
movl -0x18(%rcx,%rdx), %r8d
cmpl $-0x1, %r8d
je 0xefe9
movl 0x50(%rbx), %r9d
andl %edi, %r9d
cmpl %r8d, %r9d
je 0xefe9
leaq 0x20(%rcx), %r8
addq $-0x18, %rcx
cmpq $0x1e0, %rcx            # imm = 0x1E0
movq %r8, %rcx
jb 0xef7f
movq (%rsp), %rdx
movl 0x50(%rbx), %ecx
xorl %edi, %edi
movl %edi, %esi
cmpq $-0x1, %rdx
je 0xefcb
movb $0x1, %dil
testb $0x1, %sil
je 0xefba
movl %edx, %edi
andl $0xff00, %edi           # imm = 0xFF00
cmpl $0xfd00, %edi           # imm = 0xFD00
setb %dil
testb %sil, %dil
je 0xeff6
xorl %ebx, %ebx
jmp 0xf080
leaq (%rdx,%rcx), %rdi
callq *-0x8(%rcx,%rdx)
jmp 0xf0f6
movl %ecx, %esi
andl $0xffff9fef, %esi       # imm = 0xFFFF9FEF
movq $-0x20, %rdi
movl 0xf938(%rip), %r9d      # 0x1e944
leaq 0x636d(%rip), %r8       # 0x15380
xorl %ebx, %ebx
cmpq %rdx, 0x20(%rdi,%r8)
jne 0xf073
movl 0x28(%rdi,%r8), %r10d
cmpl $-0x1, %r10d
setne %r11b
cmpl %r10d, %esi
setne %r10b
testb %r10b, %r11b
jne 0xf073
movb 0x38(%rdi,%r8), %r10b
testb $0x4, %r9b
jne 0xf047
testb %r10b, %r10b
jg 0xf073
jmp 0xf04c
testb %r10b, %r10b
js 0xf073
btl $0x11, %r9d
jae 0xf05b
cmpb $0x2, 0x38(%rdi,%r8)
je 0xf073
btl $0x8, %r9d
movb 0x39(%rdi,%r8), %r10b
jb 0xf06e
testb %r10b, %r10b
jg 0xf073
jmp 0xf0c5
testb %r10b, %r10b
jns 0xf0c5
addq $0x20, %rdi
cmpq $0x1a00, %rdi           # imm = 0x1A00
jb 0xf015
testq %rbx, %rbx
je 0xf095
movq %rbx, %rdi
callq 0x6410
movq %rbx, %rdi
movq %rax, %rsi
jmp 0xf0ec
testl %eax, %eax
je 0xf0f6
cmpl $0x1, %eax
jne 0xf0e4
movl $0x1, %eax
testb $0x8, %cl
je 0xf0e4
testb $0x4, 0xf896(%rip)      # 0x1e945
movb 0x10(%rsp), %cl
jne 0xf0cc
movb %cl, 0x11(%rsp)
movb $0x1b, 0x10(%rsp)
movl $0x2, %eax
jmp 0xf0e4
movq 0x30(%rdi,%r8), %rbx
jmp 0xf080
cmpb $0x7f, %cl
je 0xf0e4
movsbl %cl, %edi
orl $0x80, %edi
leaq 0x10(%rsp), %rsi
callq 0x71b4
movslq %eax, %rsi
leaq 0x10(%rsp), %rdi
movl $0x1, %edx
callq 0x8045
addq $0x58, %rsp
popq %rbx
popq %r14
retq