// File: /workspace/github_c_makefile_star2_O3/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, 0x103b8(%rip)    # 0x1f934
jne 0xf726
movq %rdi, %rbx
movq 0x102bc(%rip), %rdi     # 0x1f848
testq %rdi, %rdi
je 0xf5b9
leaq 0x10(%rsp), %rdx
movq %rsp, %r8
leaq 0xc(%rsp), %r14
movq %rbx, %rsi
movl $0x40, %ecx
movq %r14, %r9
callq 0x6830
cmpl $-0x1, (%r14)
jne 0xf5d1
jmp 0xf726
leaq 0x10(%rsp), %rsi
movq %rsp, %rcx
movq %rbx, %rdi
movl $0x40, %edx
xorl %r8d, %r8d
callq 0x6170
movl $0x18, %edx
movq (%rsp), %rcx
leaq 0x9b7f(%rip), %rsi      # 0x19160
movl $0xffff9fef, %edi       # imm = 0xFFFF9FEF
cmpq -0x10(%rdx,%rsi), %rcx
jne 0xf60c
movl -0x18(%rdx,%rsi), %r8d
cmpl $-0x1, %r8d
je 0xf6f2
movl 0x50(%rbx), %r9d
andl %edi, %r9d
cmpl %r8d, %r9d
je 0xf6f2
leaq 0x20(%rdx), %r8
addq $-0x18, %rdx
cmpq $0x1e0, %rdx            # imm = 0x1E0
movq %r8, %rdx
jb 0xf5e6
movl 0x50(%rbx), %edx
movl %ecx, %esi
andl $0xff00, %esi           # imm = 0xFF00
cmpl $0xfd00, %esi           # imm = 0xFD00
jb 0xf6c2
movl %edx, %esi
andl $0xffff9fef, %esi       # imm = 0xFFFF9FEF
movq $-0x20, %rdi
movl 0x102e7(%rip), %r9d     # 0x1f934
leaq 0x6d2c(%rip), %r8       # 0x16380
movl %r9d, %r10d
shrl $0x11, %r10d
cmpq %rcx, 0x20(%rdi,%r8)
jne 0xf6b5
movl 0x28(%rdi,%r8), %r11d
cmpl $-0x1, %r11d
setne %bl
cmpl %r11d, %esi
setne %r11b
testb %r11b, %bl
jne 0xf6b5
movb 0x38(%rdi,%r8), %r11b
testb $0x4, %r9b
jne 0xf68c
testb %r11b, %r11b
jg 0xf6b5
jmp 0xf69d
cmpb $0x2, %r11b
sete %bl
testb %r11b, %r11b
js 0xf6b5
andb %r10b, %bl
jne 0xf6b5
btl $0x8, %r9d
movb 0x39(%rdi,%r8), %r11b
jb 0xf6b0
testb %r11b, %r11b
jg 0xf6b5
jmp 0xf72e
testb %r11b, %r11b
jns 0xf72e
addq $0x20, %rdi
cmpq $0x1a00, %rdi           # imm = 0x1A00
jb 0xf65b
testl %eax, %eax
je 0xf726
cmpl $0x1, %eax
jne 0xf714
movl $0x1, %eax
testb $0x8, %dl
je 0xf714
testb $0x4, 0x10259(%rip)     # 0x1f935
movb 0x10(%rsp), %cl
jne 0xf6fc
movb %cl, 0x11(%rsp)
movb $0x1b, 0x10(%rsp)
movl $0x2, %eax
jmp 0xf714
leaq (%rsi,%rdx), %rdi
callq *-0x8(%rdx,%rsi)
jmp 0xf726
cmpb $0x7f, %cl
je 0xf714
movsbl %cl, %edi
orl $0x80, %edi
leaq 0x10(%rsp), %rsi
callq 0x7194
movslq %eax, %rsi
leaq 0x10(%rsp), %rdi
movl $0x1, %edx
callq 0x8127
addq $0x58, %rsp
popq %rbx
popq %r14
retq
movq 0x30(%rdi,%r8), %rbx
testq %rbx, %rbx
je 0xf6c2
movq %rbx, %rdi
callq 0x6410
movq %rbx, %rdi
movq %rax, %rsi
jmp 0xf71c