// File: /workspace/github_c_makefile_star2_O2/aimerneige[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;

	if (xw.pointerisvisible) {
		XDefineCursor(xw.dpy, xw.win, xw.bpointer);
		xsetpointermotion(1);
		xw.pointerisvisible = 0;
	}

	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);
	/* 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 %rbp
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
cmpl $0x0, 0xf27a(%rip)      # 0x1be00
je 0xcbb1
movq 0xf179(%rip), %rdi      # 0x1bd08
movq 0xf182(%rip), %rsi      # 0x1bd18
movq 0xf25b(%rip), %rdx      # 0x1bdf8
callq 0x5740
pushq $0x1
popq %rdi
callq 0xb3fe
andl $0x0, 0xf24f(%rip)      # 0x1be00
testb $0x40, 0xf290(%rip)     # 0x1be48
jne 0xcd4c
movq 0xf193(%rip), %rdi      # 0x1bd58
testq %rdi, %rdi
je 0xcbe4
leaq 0x10(%rsp), %rdx
pushq $0x40
popq %rcx
movq %rsp, %r8
leaq 0xc(%rsp), %r9
movq %rbx, %rsi
callq 0x5750
jmp 0xcbfa
leaq 0x10(%rsp), %rsi
pushq $0x40
popq %rdx
movq %rsp, %rcx
movq %rbx, %rdi
xorl %r8d, %r8d
callq 0x5150
pushq $0x1
popq %rcx
movq (%rsp), %rdx
xorl %esi, %esi
leaq 0x8a76(%rip), %rdi      # 0x15680
movl $0xffffdfef, %r8d       # imm = 0xFFFFDFEF
cmpq $0x23f, %rsi            # imm = 0x23F
ja 0xcc44
cmpq 0x8(%rsi,%rdi), %rdx
jne 0xcc3e
movl (%rsi,%rdi), %r9d
cmpl $-0x1, %r9d
je 0xccfb
movl 0x50(%rbx), %r10d
andl %r8d, %r10d
cmpl %r9d, %r10d
je 0xccfb
addq $0x20, %rsi
jmp 0xcc10
movl 0x50(%rbx), %esi
movl %edx, %edi
andl $0xff00, %edi           # imm = 0xFF00
cmpl $0xfd00, %edi           # imm = 0xFD00
jae 0xcc79
testl %eax, %eax
je 0xcd4c
cmpl $0x1, %eax
jne 0xcd3c
testb $0x8, %sil
jne 0xcd07
movl %ecx, %eax
jmp 0xcd3c
movl %esi, %edi
andl $0xffffdfef, %edi       # imm = 0xFFFFDFEF
movl 0xf1c0(%rip), %r9d      # 0x1be48
xorl %r8d, %r8d
leaq 0x66de(%rip), %r10      # 0x13370
movl %r9d, %r11d
shrl $0x11, %r11d
cmpq $0x1a1f, %r8            # imm = 0x1A1F
ja 0xcc57
cmpq %rdx, (%r8,%r10)
jne 0xccf5
movl 0x8(%r8,%r10), %ebx
cmpl $-0x1, %ebx
setne %bpl
cmpl %ebx, %edi
setne %bl
testb %bl, %bpl
jne 0xccf5
movb 0x18(%r8,%r10), %bl
testb $0x4, %r9b
jne 0xcccf
testb %bl, %bl
jg 0xccf5
jmp 0xccdf
cmpb $0x2, %bl
sete %bpl
testb %bl, %bl
js 0xccf5
andb %r11b, %bpl
jne 0xccf5
btl $0x8, %r9d
movb 0x19(%r8,%r10), %bl
jb 0xccf1
testb %bl, %bl
jg 0xccf5
jmp 0xcd53
testb %bl, %bl
jns 0xcd53
addq $0x20, %r8
jmp 0xcc99
addq %rsi, %rdi
addq $0x18, %rdi
callq *-0x8(%rdi)
jmp 0xcd4c
testb $0x4, 0xf13b(%rip)      # 0x1be49
movb 0x10(%rsp), %dl
jne 0xcd22
movb %dl, 0x11(%rsp)
movb $0x1b, 0x10(%rsp)
pushq $0x2
popq %rax
jmp 0xcd3c
movl %ecx, %eax
cmpb $0x7f, %dl
je 0xcd3c
movsbl %dl, %edi
orl $0x80, %edi
leaq 0x10(%rsp), %rsi
callq 0x5b82
movslq %eax, %rsi
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rdx
callq 0x68b0
addq $0x58, %rsp
popq %rbx
popq %rbp
retq
movq 0x10(%r8,%r10), %rbx
testq %rbx, %rbx
je 0xcc57
movq %rbx, %rdi
callq 0x5370
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %rax, %rsi
jmp 0xcd47