// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
cmpl $0x0, 0x107c2(%rip)     # 0x21430
je 0x10c9e
movq 0x106c1(%rip), %rdi     # 0x21338
movq 0x106ca(%rip), %rsi     # 0x21348
movq 0x107a3(%rip), %rdx     # 0x21428
callq 0x5750
movl $0x1, %edi
callq 0xe6b0
movl $0x0, 0x10792(%rip)     # 0x21430
movl 0x107d4(%rip), %eax     # 0x21478
andl $0x40, %eax
cmpl $0x0, %eax
je 0x10cb1
jmp 0x10e25
cmpq $0x0, 0x106cf(%rip)     # 0x21388
je 0x10ce1
movq 0x106c6(%rip), %rdi     # 0x21388
movq -0x10(%rbp), %rsi
leaq -0x60(%rbp), %rdx
movl $0x40, %ecx
leaq -0x18(%rbp), %r8
leaq -0x74(%rbp), %r9
callq 0x5760
movl %eax, -0x6c(%rbp)
jmp 0x10cff
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl $0x40, %edx
leaq -0x18(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r8d
callq 0x5150
movl %eax, -0x6c(%rbp)
leaq 0x856a(%rip), %rax      # 0x19270
movq %rax, -0x80(%rbp)
leaq 0x855f(%rip), %rax      # 0x19270
addq $0x240, %rax            # imm = 0x240
cmpq %rax, -0x80(%rbp)
jae 0x10d69
movq -0x18(%rbp), %rax
movq -0x80(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x10d59
movq -0x80(%rbp), %rax
movl (%rax), %edi
movq -0x10(%rbp), %rax
movl 0x50(%rax), %esi
callq 0x11870
cmpl $0x0, %eax
je 0x10d59
movq -0x80(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x80(%rbp), %rdi
addq $0x18, %rdi
callq *%rax
jmp 0x10e25
jmp 0x10d5b
movq -0x80(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x80(%rbp)
jmp 0x10d0a
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x50(%rax), %esi
callq 0x118b0
movq %rax, -0x68(%rbp)
cmpq $0x0, %rax
je 0x10dad
movq -0x68(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x68(%rbp), %rdi
callq 0x5370
movq -0x88(%rbp), %rdi
movq %rax, %rsi
movl $0x1, %edx
callq 0x7180
jmp 0x10e25
cmpl $0x0, -0x6c(%rbp)
jne 0x10db5
jmp 0x10e25
cmpl $0x1, -0x6c(%rbp)
jne 0x10e13
movq -0x10(%rbp), %rax
movl 0x50(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x10e13
movl 0x106a8(%rip), %eax     # 0x21478
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x10e00
movsbl -0x60(%rbp), %eax
cmpl $0x7f, %eax
jge 0x10dfe
movsbl -0x60(%rbp), %eax
orl $0x80, %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %edi
leaq -0x60(%rbp), %rsi
callq 0x5c30
movl %eax, -0x6c(%rbp)
jmp 0x10e11
movb -0x60(%rbp), %al
movb %al, -0x5f(%rbp)
movb $0x1b, -0x60(%rbp)
movl $0x2, -0x6c(%rbp)
jmp 0x10e13
leaq -0x60(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
movl $0x1, %edx
callq 0x7180
addq $0x90, %rsp
popq %rbp
retq
nop