// File: /workspace/github_c_makefile_star2_O0/zenlinux[P]cwm/search.c
// Function: search_match_client
void
search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search)
{
	struct winname	*wn;
	struct menu	*mi, *tierp[4], *before = NULL;

	TAILQ_INIT(resultq);

	(void)memset(tierp, 0, sizeof(tierp));

	/*
	 * In order of rank:
	 *
	 *   1. Look through labels.
	 *   2. Look at title history, from present to past.
	 *   3. Look at window class name.
	 */

	TAILQ_FOREACH(mi, menuq, entry) {
		int tier = -1, t;
		struct client_ctx *cc = mi->ctx;

		/* First, try to match on labels. */
		if (cc->label != NULL && strsubmatch(search, cc->label, 0)) {
			cc->matchname = cc->label;
			tier = 0;
		}

		/* Then, on window names. */
		if (tier < 0) {
			TAILQ_FOREACH_REVERSE(wn, &cc->nameq, winname_q, entry)
				if (strsubmatch(search, wn->name, 0)) {
					cc->matchname = wn->name;
					tier = 2;
					break;
				}
		}

		/* Then if there is a match on the window class name. */
		if (tier < 0 && strsubmatch(search, cc->app_class, 0)) {
			cc->matchname = cc->app_class;
			tier = 3;
		}

		if (tier < 0)
			continue;

		/*
		 * De-rank a client one tier if it's the current
		 * window.  Furthermore, this is denoted by a "!" when
		 * printing the window name in the search menu.
		 */
		if (cc == client_current() && tier < nitems(tierp) - 1)
			tier++;

		/* Clients that are hidden get ranked one up. */
		if (cc->flags & CLIENT_HIDDEN && tier > 0)
			tier--;

		assert(tier < nitems(tierp));

		/*
		 * If you have a tierp, insert after it, and make it
		 * the new tierp.  If you don't have a tierp, find the
		 * first nonzero tierp above you, insert after it.
		 * Always make your current tierp the newly inserted
		 * entry.
		 */
		for (t = tier; t >= 0 && ((before = tierp[t]) == NULL); t--)
			;

		if (before == NULL)
			TAILQ_INSERT_HEAD(resultq, mi, resultentry);
		else
			TAILQ_INSERT_AFTER(resultq, before, mi, resultentry);

		tierp[tier] = mi;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x5090
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xa3ac
movl $0xffffffff, -0x5c(%rbp) # imm = 0xFFFFFFFF
movq -0x28(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpq $0x0, 0xe0(%rax)
je 0xa168
movq -0x18(%rbp), %rdi
movq -0x68(%rbp), %rax
movq 0xe0(%rax), %rsi
xorl %edx, %edx
callq 0xa3c0
cmpl $0x0, %eax
je 0xa168
movq -0x68(%rbp), %rax
movq 0xe0(%rax), %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0xe8(%rax)
movl $0x0, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
jge 0xa1d8
movq -0x68(%rbp), %rax
movq 0xc8(%rax), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xa1d6
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
xorl %edx, %edx
callq 0xa3c0
cmpl $0x0, %eax
je 0xa1bf
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0xe8(%rax)
movl $0x2, -0x5c(%rbp)
jmp 0xa1d6
jmp 0xa1c1
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0xa184
jmp 0xa1d8
cmpl $0x0, -0x5c(%rbp)
jge 0xa216
movq -0x18(%rbp), %rdi
movq -0x68(%rbp), %rax
movq 0xf8(%rax), %rsi
xorl %edx, %edx
callq 0xa3c0
cmpl $0x0, %eax
je 0xa216
movq -0x68(%rbp), %rax
movq 0xf8(%rax), %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0xe8(%rax)
movl $0x3, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
jge 0xa221
jmp 0xa39c
movq -0x68(%rbp), %rax
movq %rax, -0x70(%rbp)
callq 0x7aa0
movq %rax, %rcx
movq -0x70(%rbp), %rax
cmpq %rcx, %rax
jne 0xa24d
movslq -0x5c(%rbp), %rax
cmpq $0x3, %rax
jae 0xa24d
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x68(%rbp), %rax
movl 0xa8(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xa26e
cmpl $0x0, -0x5c(%rbp)
jle 0xa26e
movl -0x5c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x5c(%rbp)
movslq -0x5c(%rbp), %rax
cmpq $0x4, %rax
jae 0xa27a
jmp 0xa299
leaq 0xa01c(%rip), %rdi      # 0x1429d
leaq 0xa02a(%rip), %rsi      # 0x142b2
movl $0x63, %edx
leaq 0xa027(%rip), %rcx      # 0x142bb
callq 0x5190
movl -0x5c(%rbp), %eax
movl %eax, -0x60(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x60(%rbp)
movb %al, -0x71(%rbp)
jl 0xa2c1
movslq -0x60(%rbp), %rax
movq -0x50(%rbp,%rax,8), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
sete %al
movb %al, -0x71(%rbp)
movb -0x71(%rbp), %al
testb $0x1, %al
jne 0xa2ca
jmp 0xa2d7
jmp 0xa2cc
movl -0x60(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0xa29f
cmpq $0x0, -0x58(%rbp)
jne 0xa333
jmp 0xa2e0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movq %rax, 0x10(%rcx)
cmpq $0x0, %rax
je 0xa30a
movq -0x28(%rbp), %rcx
addq $0x10, %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x18(%rax)
jmp 0xa31a
movq -0x28(%rbp), %rcx
addq $0x10, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0xa38f
jmp 0xa335
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rcx
movq %rax, 0x10(%rcx)
cmpq $0x0, %rax
je 0xa361
movq -0x28(%rbp), %rcx
addq $0x10, %rcx
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rcx, 0x18(%rax)
jmp 0xa371
movq -0x28(%rbp), %rcx
addq $0x10, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x58(%rbp), %rcx
addq $0x10, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0xa38f
movq -0x28(%rbp), %rcx
movslq -0x5c(%rbp), %rax
movq %rcx, -0x50(%rbp,%rax,8)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0xa101
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)