// File: /workspace/github_c_makefile_star2_O0/zenlinux[P]cwm/menu.c
// Function: menu_handle_key
static struct menu *
menu_handle_key(XEvent *e, struct menu_ctx *mc, struct menu_q *menuq,
    struct menu_q *resultq)
{
	struct menu	*mi;
	enum ctltype	 ctl;
	char		 chr[32];
	size_t		 len;
	int 		 clen, i;
	wchar_t 	 wc;

	if (menu_keycode(&e->xkey, &ctl, chr) < 0)
		return (NULL);

	switch (ctl) {
	case CTL_ERASEONE:
		if ((len = strlen(mc->searchstr)) > 0) {
			clen = 1;
			while (mbtowc(&wc, &mc->searchstr[len-clen], MB_CUR_MAX) == -1)
				clen++;
			for (i = 1; i <= clen; i++)
				mc->searchstr[len - i] = '\0';
			mc->changed = 1;
		}
		break;
	case CTL_UP:
		mi = TAILQ_LAST(resultq, menu_q);
		if (mi == NULL)
			break;

		TAILQ_REMOVE(resultq, mi, resultentry);
		TAILQ_INSERT_HEAD(resultq, mi, resultentry);
		break;
	case CTL_DOWN:
		mi = TAILQ_FIRST(resultq);
		if (mi == NULL)
			break;

		TAILQ_REMOVE(resultq, mi, resultentry);
		TAILQ_INSERT_TAIL(resultq, mi, resultentry);
		break;
	case CTL_RETURN:
		/*
		 * Return whatever the cursor is currently on. Else
		 * even if dummy is zero, we need to return something.
		 */
		if ((mi = TAILQ_FIRST(resultq)) == NULL) {
			mi = xmalloc(sizeof *mi);
			(void)strlcpy(mi->text,
			    mc->searchstr, sizeof(mi->text));
			mi->dummy = 1;
		}
		mi->abort = 0;
		return (mi);
	case CTL_WIPE:
		mc->searchstr[0] = '\0';
		mc->changed = 1;
		break;
	case CTL_ALL:
		mc->list = !mc->list;
		break;
	case CTL_ABORT:
		mi = xmalloc(sizeof *mi);
		mi->text[0] = '\0';
		mi->dummy = 1;
		mi->abort = 1;
		return (mi);
	default:
		break;
	}

	if (chr[0] != '\0') {
		mc->changed = 1;
		(void)strlcat(mc->searchstr, chr, sizeof(mc->searchstr));
	}

	mc->noresult = 0;
	if (mc->changed && mc->searchstr[0] != '\0') {
		(*mc->match)(menuq, resultq, mc->searchstr);
		/* If menuq is empty, never show we've failed */
		mc->noresult = TAILQ_EMPTY(resultq) && !TAILQ_EMPTY(menuq);
	} else if (mc->changed)
		TAILQ_INIT(resultq);

	if (!mc->list && mc->listing && !mc->changed) {
		TAILQ_INIT(resultq);
		mc->listing = 0;
	}

	return (NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rdx
leaq -0x34(%rbp), %rsi
callq 0x9e10
cmpl $0x0, %eax
jge 0x8f5e
movq $0x0, -0x8(%rbp)
jmp 0x9376
movl -0x34(%rbp), %eax
movq %rax, -0x80(%rbp)
subq $0x6, %rax
ja 0x924f
movq -0x80(%rbp), %rax
leaq 0xb19e(%rip), %rcx      # 0x14118
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rdi
callq 0x5320
movq %rax, -0x68(%rbp)
cmpq $0x0, %rax
jbe 0x901d
movl $0x1, -0x6c(%rbp)
movq -0x18(%rbp), %rax
movq -0x68(%rbp), %rcx
movslq -0x6c(%rbp), %rdx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
callq 0x5370
movq -0x88(%rbp), %rsi
movq %rax, %rdx
leaq -0x74(%rbp), %rdi
callq 0x5080
cmpl $-0x1, %eax
jne 0x8fe2
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x8fa1
movl $0x1, -0x70(%rbp)
movl -0x70(%rbp), %eax
cmpl -0x6c(%rbp), %eax
jg 0x900f
movq -0x18(%rbp), %rax
movq -0x68(%rbp), %rcx
movslq -0x70(%rbp), %rdx
subq %rdx, %rcx
movb $0x0, (%rax,%rcx)
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x8fe9
movq -0x18(%rbp), %rax
movl $0x1, 0xd8(%rax)
jmp 0x9251
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x9041
jmp 0x9251
jmp 0x9043
movq -0x30(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x9064
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rcx, 0x18(%rax)
jmp 0x9074
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq %rcx, (%rax)
jmp 0x9089
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movq %rax, 0x10(%rcx)
cmpq $0x0, %rax
je 0x90b3
movq -0x30(%rbp), %rcx
addq $0x10, %rcx
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x18(%rax)
jmp 0x90c3
movq -0x30(%rbp), %rcx
addq $0x10, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x9251
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x90f6
jmp 0x9251
jmp 0x90f8
movq -0x30(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x9119
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rcx, 0x18(%rax)
jmp 0x9129
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq %rcx, (%rax)
jmp 0x913e
movq -0x30(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rcx
addq $0x10, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x9251
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x91c0
movl $0x98, %edi
callq 0x6420
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
addq $0x20, %rdi
movq -0x18(%rbp), %rsi
movl $0x33, %edx
callq 0x12ce0
movq -0x30(%rbp), %rax
movw $0x1, 0x90(%rax)
movq -0x30(%rbp), %rax
movw $0x0, 0x92(%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9376
movq -0x18(%rbp), %rax
movb $0x0, (%rax)
movq -0x18(%rbp), %rax
movl $0x1, 0xd8(%rax)
jmp 0x9251
movq -0x18(%rbp), %rax
cmpl $0x0, 0xd0(%rax)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xd0(%rax)
jmp 0x9251
movl $0x98, %edi
callq 0x6420
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movb $0x0, 0x20(%rax)
movq -0x30(%rbp), %rax
movw $0x1, 0x90(%rax)
movq -0x30(%rbp), %rax
movw $0x1, 0x92(%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x9376
jmp 0x9251
movsbl -0x60(%rbp), %eax
cmpl $0x0, %eax
je 0x927a
movq -0x18(%rbp), %rax
movl $0x1, 0xd8(%rax)
movq -0x18(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl $0x33, %edx
callq 0x12db0
movq -0x18(%rbp), %rax
movl $0x0, 0xdc(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0xd8(%rax)
je 0x92f6
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x92f6
movq -0x18(%rbp), %rax
movq 0x100(%rax), %rax
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq *%rax
movq -0x28(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, (%rcx)
movb %al, -0x89(%rbp)
jne 0x92df
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
sete %al
xorb $-0x1, %al
movb %al, -0x89(%rbp)
movb -0x89(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xdc(%rax)
jmp 0x9320
movq -0x18(%rbp), %rax
cmpl $0x0, 0xd8(%rax)
je 0x931e
jmp 0x9305
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movq -0x28(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x931e
jmp 0x9320
movq -0x18(%rbp), %rax
cmpl $0x0, 0xd0(%rax)
jne 0x936e
movq -0x18(%rbp), %rax
cmpl $0x0, 0xd4(%rax)
je 0x936e
movq -0x18(%rbp), %rax
cmpl $0x0, 0xd8(%rax)
jne 0x936e
jmp 0x9349
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movq -0x28(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0xd4(%rax)
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)