// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq $0x0, (%rsi)
movq %rsi, (%rsp)
movq %rsi, 0x8(%rsi)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
movq (%rdi), %r12
testq %r12, %r12
je 0x8306
movq %rdx, %rbx
movq (%rsp), %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
movq 0x88(%r12), %rbp
movq 0xe0(%rbp), %r15
testq %r15, %r15
je 0x8221
xorl %r14d, %r14d
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x8334
movb $0x1, %r13b
testl %eax, %eax
jne 0x827f
movq 0xc8(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %r14
testq %r14, %r14
je 0x824f
movq 0x10(%r14), %r15
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x8334
testl %eax, %eax
jne 0x8276
movq 0x8(%r14), %rax
jmp 0x8228
movq 0xf8(%rbp), %r15
xorl %r13d, %r13d
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x8334
testl %eax, %eax
je 0x82f9
movl $0x3, %r14d
jmp 0x827f
movl $0x2, %r14d
movb $0x1, %r13b
movq %r15, 0xe8(%rbp)
callq 0x6d39
cmpq %rax, %rbp
sete %al
andb %r13b, %al
movzbl %al, %ecx
addl %r14d, %ecx
setne %al
andb 0xa8(%rbp), %al
movzbl %al, %eax
subl %eax, %ecx
cmpl $0x3, %ecx
ja 0x8315
movslq %ecx, %rax
movl %ecx, %edx
movq 0x10(%rsp,%rdx,8), %rdx
testq %rdx, %rdx
jne 0x82cb
leal -0x1(%rcx), %edx
testl %ecx, %ecx
movl %edx, %ecx
jg 0x82b0
movq (%rsp), %rdx
jmp 0x82cf
addq $0x10, %rdx
movq (%rdx), %rcx
leaq 0x10(%r12), %rsi
movq %rcx, 0x10(%r12)
leaq 0x18(%rcx), %rdi
testq %rcx, %rcx
cmoveq 0x8(%rsp), %rdi
movq %rsi, (%rdi)
movq %r12, (%rdx)
movq %rdx, 0x18(%r12)
movq %r12, 0x10(%rsp,%rax,8)
movq (%r12), %r12
testq %r12, %r12
jne 0x81f6
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5ddc(%rip), %rdi      # 0xe0f8
leaq 0x5dea(%rip), %rsi      # 0xe10d
leaq 0x5dec(%rip), %rcx      # 0xe116
movl $0x63, %edx
callq 0x5190