// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movl 0x101df(%rip), %eax     # 0x226d4
andl $0x40, %eax
cmpl $0x0, %eax
je 0x12502
jmp 0x12681
cmpq $0x0, 0x100de(%rip)     # 0x225e8
je 0x1253d
movq 0x100d5(%rip), %rdi     # 0x225e8
movq -0x10(%rbp), %rsi
leaq -0x60(%rbp), %rdx
movl $0x40, %ecx
leaq -0x18(%rbp), %r8
leaq -0x74(%rbp), %r9
callq 0x6840
movl %eax, -0x6c(%rbp)
cmpl $-0x1, -0x74(%rbp)
jne 0x1253b
jmp 0x12681
jmp 0x1255b
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl $0x40, %edx
leaq -0x18(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r8d
callq 0x6170
movl %eax, -0x6c(%rbp)
leaq 0x7f4e(%rip), %rax      # 0x1a4b0
movq %rax, -0x80(%rbp)
leaq 0x7f43(%rip), %rax      # 0x1a4b0
addq $0x200, %rax            # imm = 0x200
cmpq %rax, -0x80(%rbp)
jae 0x125c5
movq -0x18(%rbp), %rax
movq -0x80(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x125b5
movq -0x80(%rbp), %rax
movl (%rax), %edi
movq -0x10(%rbp), %rax
movl 0x50(%rax), %esi
callq 0x13100
cmpl $0x0, %eax
je 0x125b5
movq -0x80(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x80(%rbp), %rdi
addq $0x18, %rdi
callq *%rax
jmp 0x12681
jmp 0x125b7
movq -0x80(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x80(%rbp)
jmp 0x12566
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x50(%rax), %esi
callq 0x13140
movq %rax, -0x68(%rbp)
cmpq $0x0, %rax
je 0x12609
movq -0x68(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x68(%rbp), %rdi
callq 0x6410
movq -0x88(%rbp), %rdi
movq %rax, %rsi
movl $0x1, %edx
callq 0x8350
jmp 0x12681
cmpl $0x0, -0x6c(%rbp)
jne 0x12611
jmp 0x12681
cmpl $0x1, -0x6c(%rbp)
jne 0x1266f
movq -0x10(%rbp), %rax
movl 0x50(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x1266f
movl 0x100a8(%rip), %eax     # 0x226d4
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x1265c
movsbl -0x60(%rbp), %eax
cmpl $0x7f, %eax
jge 0x1265a
movsbl -0x60(%rbp), %eax
orl $0x80, %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %edi
leaq -0x60(%rbp), %rsi
callq 0x6d70
movl %eax, -0x6c(%rbp)
jmp 0x1266d
movb -0x60(%rbp), %al
movb %al, -0x5f(%rbp)
movb $0x1b, -0x60(%rbp)
movl $0x2, -0x6c(%rbp)
jmp 0x1266f
leaq -0x60(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
movl $0x1, %edx
callq 0x8350
addq $0x90, %rsp
popq %rbp
retq
nopw (%rax,%rax)