// File: /workspace/github_c_makefile_star2_O0/zenlinux[P]cwm/menu.c
// Function: menu_filter
struct menu *
menu_filter(struct screen_ctx *sc, struct menu_q *menuq, char *prompt,
    char *initial, int dummy,
    void (*match)(struct menu_q *, struct menu_q *, char *),
    void (*print)(struct menu *, int))
{
	struct menu_ctx		 mc;
	struct menu_q		 resultq;
	struct menu		*mi = NULL;
	XEvent			 e;
	Window			 focuswin;
	int			 evmask, focusrevert;
	int			 xsave, ysave, xcur, ycur;

	TAILQ_INIT(&resultq);

	bzero(&mc, sizeof(mc));

	xu_ptr_getpos(sc->rootwin, &mc.x, &mc.y);

	xsave = mc.x;
	ysave = mc.y;

	if (prompt == NULL) {
		evmask = MENUMASK;
		mc.promptstr[0] = '\0';
		mc.list = 1;
	} else {
		evmask = MENUMASK | KEYMASK; /* only accept keys if prompt */
		(void)snprintf(mc.promptstr, sizeof(mc.promptstr), "%s%s",
		    prompt, PROMPT_SCHAR);
		(void)snprintf(mc.dispstr, sizeof(mc.dispstr), "%s%s%s",
		    mc.promptstr, mc.searchstr, PROMPT_ECHAR);
		mc.width = font_width(sc, mc.dispstr, strlen(mc.dispstr));
		mc.hasprompt = 1;
	}

	if (initial != NULL)
		(void)strlcpy(mc.searchstr, initial, sizeof(mc.searchstr));
	else
		mc.searchstr[0] = '\0';

	mc.match = match;
	mc.print = print;
	mc.entry = mc.prev = -1;

	XMoveResizeWindow(X_Dpy, sc->menuwin, mc.x, mc.y, mc.width,
	    font_height(sc));
	XSelectInput(X_Dpy, sc->menuwin, evmask);
	XMapRaised(X_Dpy, sc->menuwin);

	if (xu_ptr_grab(sc->menuwin, MENUGRABMASK, Cursor_question) < 0) {
		XUnmapWindow(X_Dpy, sc->menuwin);
		return (NULL);
	}

	XGetInputFocus(X_Dpy, &focuswin, &focusrevert);
	XSetInputFocus(X_Dpy, sc->menuwin, RevertToPointerRoot, CurrentTime);

	/* make sure keybindings don't remove keys from the menu stream */
	XGrabKeyboard(X_Dpy, sc->menuwin, True,
	    GrabModeAsync, GrabModeAsync, CurrentTime);

	for (;;) {
		mc.changed = 0;

		XWindowEvent(X_Dpy, sc->menuwin, evmask, &e);

		switch (e.type) {
		case KeyPress:
			if ((mi = menu_handle_key(&e, &mc, menuq, &resultq))
			    != NULL)
				goto out;
			/* FALLTHROUGH */
		case Expose:
			menu_draw(sc, &mc, menuq, &resultq);
			break;
		case MotionNotify:
			menu_handle_move(&e, &mc, sc);
			break;
		case ButtonRelease:
			if ((mi = menu_handle_release(&e, &mc, sc, &resultq))
			    != NULL)
				goto out;
			break;
		default:
			break;
		}
	}
out:
	if (dummy == 0 && mi->dummy) { /* no mouse based match */
		xfree(mi);
		mi = NULL;
	}

	XSetInputFocus(X_Dpy, focuswin, focusrevert, CurrentTime);
	/* restore if user didn't move */
	xu_ptr_getpos(sc->rootwin, &xcur, &ycur);
	if (xcur == mc.x && ycur == mc.y)
		xu_ptr_setpos(sc->rootwin, xsave, ysave);
	xu_ptr_ungrab();

	XUnmapWindow(X_Dpy, sc->menuwin);
	XUngrabKeyboard(X_Dpy, CurrentTime);

	return (mi);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x280, %rsp            # imm = 0x280
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq %r9, -0x38(%rbp)
movq $0x0, -0x160(%rbp)
movq $0x0, -0x158(%rbp)
leaq -0x158(%rbp), %rax
movq %rax, -0x150(%rbp)
leaq -0x148(%rbp), %rdi
xorl %esi, %esi
movl $0x110, %edx            # imm = 0x110
callq 0x5090
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x148(%rbp), %rsi
addq $0xf4, %rsi
leaq -0x148(%rbp), %rdx
addq $0xf8, %rdx
callq 0xabf0
movl -0x54(%rbp), %eax
movl %eax, -0x234(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0x238(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x8aed
movl $0xa04c, -0x22c(%rbp)   # imm = 0xA04C
movb $0x0, -0xb0(%rbp)
movl $0x1, -0x78(%rbp)
jmp 0x8ba9
movl $0xa04d, -0x22c(%rbp)   # imm = 0xA04D
leaq -0x148(%rbp), %rdi
addq $0x98, %rdi
movq -0x20(%rbp), %rcx
movl $0x33, %esi
leaq 0xb780(%rip), %rdx      # 0x14295
leaq 0xb774(%rip), %r8       # 0x14290
movb $0x0, %al
callq 0x50b0
leaq -0x148(%rbp), %rdi
addq $0x33, %rdi
leaq -0x148(%rbp), %rcx
addq $0x98, %rcx
leaq -0x148(%rbp), %r8
movl $0x65, %esi
leaq 0xb744(%rip), %rdx      # 0x14293
leaq 0xb744(%rip), %r9       # 0x1429a
movb $0x0, %al
callq 0x50b0
movq -0x10(%rbp), %rax
movq %rax, -0x250(%rbp)
leaq -0x148(%rbp), %rax
addq $0x33, %rax
movq %rax, -0x248(%rbp)
leaq -0x148(%rbp), %rdi
addq $0x33, %rdi
callq 0x5320
movq -0x250(%rbp), %rdi
movq -0x248(%rbp), %rsi
movl %eax, %edx
callq 0x10af0
movl %eax, -0x5c(%rbp)
movl $0x1, -0x7c(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x8bc7
leaq -0x148(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl $0x33, %edx
callq 0x12ce0
jmp 0x8bce
movb $0x0, -0x148(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq 0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0xffffffff, -0x68(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x64(%rbp) # imm = 0xFFFFFFFF
leaq 0x13bb5(%rip), %rax     # 0x1c7a8
movq (%rax), %rax
movq %rax, -0x270(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x268(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x25c(%rbp)
movl -0x50(%rbp), %eax
movl %eax, -0x258(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x254(%rbp)
movq -0x10(%rbp), %rdi
callq 0x109b0
movq -0x270(%rbp), %rdi
movq -0x268(%rbp), %rsi
movl -0x25c(%rbp), %edx
movl -0x258(%rbp), %ecx
movl -0x254(%rbp), %r8d
movl %eax, %r9d
callq 0x5440
leaq 0x13b48(%rip), %rax     # 0x1c7a8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
movslq -0x22c(%rbp), %rdx
callq 0x5560
leaq 0x13b2a(%rip), %rax     # 0x1c7a8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x5800
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
leaq 0x13b2b(%rip), %rax     # 0x1c7c8
movq (%rax), %rdx
movl $0x2204c, %esi          # imm = 0x2204C
callq 0xaa30
cmpl $0x0, %eax
jge 0x8cd3
leaq 0x13af2(%rip), %rax     # 0x1c7a8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x53c0
movq $0x0, -0x8(%rbp)
jmp 0x8f05
leaq 0x13ace(%rip), %rax     # 0x1c7a8
movq (%rax), %rdi
leaq -0x228(%rbp), %rsi
leaq -0x230(%rbp), %rdx
callq 0x54e0
leaq 0x13ab1(%rip), %rax     # 0x1c7a8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x1, %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x5570
leaq 0x13a91(%rip), %rax     # 0x1c7a8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
movl $0x1, %r8d
xorl %eax, %eax
movl %eax, %r9d
movl %r8d, %edx
movl %r8d, %ecx
callq 0x56a0
movl $0x0, -0x70(%rbp)
leaq 0x13a62(%rip), %rax     # 0x1c7a8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
movslq -0x22c(%rbp), %rdx
leaq -0x220(%rbp), %rcx
callq 0x5470
movl -0x220(%rbp), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0x278(%rbp)
subl $0xa, %eax
ja 0x8e2a
movq -0x278(%rbp), %rax
leaq 0xb35f(%rip), %rcx      # 0x140ec
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rdx
leaq -0x220(%rbp), %rdi
leaq -0x148(%rbp), %rsi
leaq -0x158(%rbp), %rcx
callq 0x8f20
movq %rax, -0x160(%rbp)
cmpq $0x0, %rax
je 0x8dc3
jmp 0x8e31
jmp 0x8dc5
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq -0x148(%rbp), %rsi
leaq -0x158(%rbp), %rcx
callq 0x9390
jmp 0x8e2c
movq -0x10(%rbp), %rdx
leaq -0x220(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x9bc0
jmp 0x8e2c
movq -0x10(%rbp), %rdx
leaq -0x220(%rbp), %rdi
leaq -0x148(%rbp), %rsi
leaq -0x158(%rbp), %rcx
callq 0x9d50
movq %rax, -0x160(%rbp)
cmpq $0x0, %rax
je 0x8e28
jmp 0x8e31
jmp 0x8e2c
jmp 0x8e2c
jmp 0x8d38
cmpl $0x0, -0x2c(%rbp)
jne 0x8e61
movq -0x160(%rbp), %rax
movswl 0x90(%rax), %eax
cmpl $0x0, %eax
je 0x8e61
movq -0x160(%rbp), %rdi
callq 0x64b0
movq $0x0, -0x160(%rbp)
leaq 0x13940(%rip), %rax     # 0x1c7a8
movq (%rax), %rdi
movq -0x228(%rbp), %rsi
movl -0x230(%rbp), %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x5570
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x23c(%rbp), %rsi
leaq -0x240(%rbp), %rdx
callq 0xabf0
movl -0x23c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jne 0x8ecb
movl -0x240(%rbp), %eax
cmpl -0x50(%rbp), %eax
jne 0x8ecb
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x234(%rbp), %esi
movl -0x238(%rbp), %edx
callq 0xac50
callq 0xaae0
leaq 0x138d1(%rip), %rax     # 0x1c7a8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x53c0
leaq 0x138ba(%rip), %rax     # 0x1c7a8
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x54d0
movq -0x160(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x280, %rsp            # imm = 0x280
popq %rbp
retq
nopw %cs:(%rax,%rax)