// File: /workspace/github_c_makefile_star2_O0/mrdotx[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);
	}
	if ( IS_SET(MODE_KBDSELECT) ) {
		if ( match(XK_NO_MOD, e->state) ||
		     (XK_Shift_L | XK_Shift_R) & e->state )
			win.mode ^= trt_kbdselect(ksym, buf, len);
		return;
	}
	/* 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 0xe353(%rip), %eax      # 0x219d8
andl $0x40, %eax
cmpl $0x0, %eax
je 0x13692
jmp 0x13866
cmpq $0x0, 0xe26e(%rip)      # 0x21908
je 0x136cd
movq 0xe265(%rip), %rdi      # 0x21908
movq -0x10(%rbp), %rsi
leaq -0x60(%rbp), %rdx
movl $0x40, %ecx
leaq -0x18(%rbp), %r8
leaq -0x74(%rbp), %r9
callq 0x6780
movl %eax, -0x6c(%rbp)
cmpl $-0x1, -0x74(%rbp)
jne 0x136cb
jmp 0x13866
jmp 0x136eb
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl $0x40, %edx
leaq -0x18(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r8d
callq 0x6150
movl %eax, -0x6c(%rbp)
movl 0xe2e7(%rip), %eax      # 0x219d8
andl $0x40000, %eax          # imm = 0x40000
cmpl $0x0, %eax
je 0x13740
movq -0x10(%rbp), %rax
movl 0x50(%rax), %esi
xorl %edi, %edi
callq 0x142e0
cmpl $0x0, %eax
jne 0x1371f
movq -0x10(%rbp), %rax
movl 0x50(%rax), %eax
andl $0xffe3, %eax           # imm = 0xFFE3
cmpl $0x0, %eax
je 0x1373b
movq -0x18(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl -0x6c(%rbp), %edx
callq 0x94b0
xorl 0xe2a3(%rip), %eax      # 0x219d8
movl %eax, 0xe29d(%rip)      # 0x219d8
jmp 0x13866
leaq 0x8dd9(%rip), %rax      # 0x1c520
movq %rax, -0x80(%rbp)
leaq 0x8dce(%rip), %rax      # 0x1c520
addq $0x220, %rax            # imm = 0x220
cmpq %rax, -0x80(%rbp)
jae 0x137aa
movq -0x18(%rbp), %rax
movq -0x80(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x1379a
movq -0x80(%rbp), %rax
movl (%rax), %edi
movq -0x10(%rbp), %rax
movl 0x50(%rax), %esi
callq 0x142e0
cmpl $0x0, %eax
je 0x1379a
movq -0x80(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x80(%rbp), %rdi
addq $0x18, %rdi
callq *%rax
jmp 0x13866
jmp 0x1379c
movq -0x80(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x80(%rbp)
jmp 0x1374b
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x50(%rax), %esi
callq 0x14320
movq %rax, -0x68(%rbp)
cmpq $0x0, %rax
je 0x137ee
movq -0x68(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x68(%rbp), %rdi
callq 0x6390
movq -0x88(%rbp), %rdi
movq %rax, %rsi
movl $0x1, %edx
callq 0x82c0
jmp 0x13866
cmpl $0x0, -0x6c(%rbp)
jne 0x137f6
jmp 0x13866
cmpl $0x1, -0x6c(%rbp)
jne 0x13854
movq -0x10(%rbp), %rax
movl 0x50(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x13854
movl 0xe1c7(%rip), %eax      # 0x219d8
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x13841
movsbl -0x60(%rbp), %eax
cmpl $0x7f, %eax
jge 0x1383f
movsbl -0x60(%rbp), %eax
orl $0x80, %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %edi
leaq -0x60(%rbp), %rsi
callq 0x6d00
movl %eax, -0x6c(%rbp)
jmp 0x13852
movb -0x60(%rbp), %al
movb %al, -0x5f(%rbp)
movb $0x1b, -0x60(%rbp)
movl $0x2, -0x6c(%rbp)
jmp 0x13854
leaq -0x60(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
movl $0x1, %edx
callq 0x82c0
addq $0x90, %rsp
popq %rbp
retq
nop