// File: /workspace/github_c_makefile_star2_O2/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 $0x48, %rsp
movq %rdx, %rbx
movq %rdi, %r15
andq $0x0, (%rsi)
leaq 0x8(%rsi), %rax
movq %rax, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
movq %rsi, 0x8(%rsi)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
xorl %r14d, %r14d
movq (%r15), %r15
testq %r15, %r15
je 0x80b6
movq 0x88(%r15), %rbp
movq 0xe0(%rbp), %r12
testq %r12, %r12
je 0x7fb5
xorl %r13d, %r13d
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x80e2
testl %eax, %eax
jne 0x80ab
leaq 0xc8(%rbp), %r13
movq (%r13), %rax
movq 0x8(%rax), %rax
movq (%rax), %r13
testq %r13, %r13
je 0x803f
movq 0x10(%r13), %r12
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x80e2
addq $0x8, %r13
testl %eax, %eax
je 0x7fbc
movb $0x1, %al
movl %eax, 0xc(%rsp)
pushq $0x2
popq %r13
movq %r12, 0xe8(%rbp)
callq 0x6b6a
cmpq %rax, %rbp
sete %al
andb 0xc(%rsp), %al
movzbl %al, %ecx
addl %r13d, %ecx
setne %al
andb 0xa8(%rbp), %al
movzbl %al, %eax
subl %eax, %ecx
cmpl $0x3, %ecx
ja 0x80c5
movslq %ecx, %rax
testl %ecx, %ecx
js 0x8067
movl %ecx, %edx
movq 0x20(%rsp,%rdx,8), %rdx
decl %ecx
movl $0x0, %r14d
testq %rdx, %rdx
je 0x8025
jmp 0x806f
movq 0xf8(%rbp), %r12
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x80e2
testl %eax, %eax
je 0x7f7e
movl $0x0, 0xc(%rsp)
pushq $0x3
jmp 0x7fed
movq %r14, %rdx
testq %r14, %r14
je 0x80a2
leaq 0x10(%rdx), %rcx
movq (%rcx), %rsi
leaq 0x10(%r15), %rdi
movq %rsi, 0x10(%r15)
leaq 0x18(%rsi), %r8
testq %rsi, %rsi
cmoveq 0x18(%rsp), %r8
movq %rdi, (%r8)
movq %r15, (%rcx)
movq %rcx, 0x18(%r15)
movq %r15, 0x20(%rsp,%rax,8)
movq %rdx, %r14
jmp 0x7f7e
movq 0x10(%rsp), %rcx
xorl %edx, %edx
jmp 0x8073
movb $0x1, %al
movl %eax, 0xc(%rsp)
jmp 0x7fef
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x602c(%rip), %rdi      # 0xe0f8
leaq 0x603a(%rip), %rsi      # 0xe10d
leaq 0x603c(%rip), %rcx      # 0xe116
pushq $0x63
popq %rdx
callq 0x5190