// File: /workspace/github_cpp_makefile_star2_O1/skyshore2001[P]symfind/symfind.cpp
// Function: QueryFile(char*)
void QueryFile(char *arg)
{
	SfFileIter it(g_repos);
	SfPatterns pats, pats_dir;

	char *p;
	while (p = strtok(arg, " ")) {
		arg = NULL; // make strtok contine
		char *p1 = strchr(p, 0)-1;
		SfPatterns *ppats = &pats;
		if (*p1 == '/' || *p1 == '\\') {
			*p1 -- = 0;
			ppats = &pats_dir;
		}
		ppats->push_back(SfPattern(p));
	}

	g_result.Init('f');
	while (it.Next()) {
		const SfContext &ctx = it.GetContext();
		char *name = ctx.file->name;
		bool ok = true;
		for (SfPattern &pat: pats) {
			if (! pat.Match(name)) {
				ok = false;
				break;
			}
		}
		if (ok && pats_dir.size() > 0) {
			name = ctx.folder->name;
			for (SfPattern &pat: pats_dir) {
				if (! pat.Match(name)) {
					ok = false;
					break;
				}
			}
		}
		if (ok) {
			auto &items = g_result.items;
			items.push_back(ctx);
			int cnt = items.size();
			char buf[1024];
			printf("%d:\t%s\t%s\n", cnt, ctx.file->name, GetFullName(buf, ctx.repo->root, ctx.folder->name));
			if (cnt >= MAX_FOUND) {
				printf("... (max %d)\n", MAX_FOUND);
				break;
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x488, %rsp            # imm = 0x488
movq 0x6423(%rip), %rax      # 0x9250
leaq 0x40(%rsp), %rcx
movq %rax, 0x18(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rcx)
movups %xmm0, 0x30(%rcx)
movq %rcx, 0x20(%rcx)
xorl %eax, %eax
movq %rax, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movq %rax, 0x10(%rsp)
movaps %xmm0, (%rsp)
leaq 0x34d8(%rip), %rsi      # 0x6339
callq 0x22a0
testq %rax, %rax
je 0x2f03
movq %rax, %r15
leaq 0x20(%rsp), %r13
movq %rsp, %rbp
leaq 0x80(%rsp), %rbx
leaq 0x34b0(%rip), %r14      # 0x6339
movq %r15, %rdi
callq 0x20b0
movzbl -0x1(%r15,%rax), %ecx
cmpl $0x5c, %ecx
je 0x2ea4
movq %r13, %r12
cmpl $0x2f, %ecx
jne 0x2ead
movb $0x0, -0x1(%r15,%rax)
movq %rbp, %r12
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4590
movq 0x8(%r12), %rsi
cmpq 0x10(%r12), %rsi
je 0x2ee6
movups 0x80(%rsp), %xmm0
movups 0x90(%rsp), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
addq $0x20, %rsi
movq %rsi, 0x8(%r12)
jmp 0x2ef1
movq %r12, %rdi
movq %rbx, %rdx
callq 0x4a9c
xorl %edi, %edi
movq %r14, %rsi
callq 0x22a0
movq %rax, %r15
testq %rax, %rax
jne 0x2e89
movb $0x66, 0x634e(%rip)     # 0x9258
movq 0x634f(%rip), %rax      # 0x9260
cmpq %rax, 0x6350(%rip)      # 0x9268
je 0x2f21
movq %rax, 0x6347(%rip)      # 0x9268
movl $0xffffffff, 0x634d(%rip) # imm = 0xFFFFFFFF
leaq 0x40(%rsp), %r14
xorl %r13d, %r13d
movq %r14, %rdi
callq 0x4654
testq %rax, %rax
je 0x30b3
movq 0x20(%rsp), %rbx
movq 0x28(%rsp), %r12
cmpq %r12, %rbx
je 0x2f92
movq 0x70(%rsp), %rax
movq (%rax), %r15
movb $0x1, %bpl
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rdi
addq %rbx, %rdi
testb $0x1, %al
je 0x2f75
movq (%rdi), %rcx
movq -0x1(%rcx,%rax), %rax
movq %r15, %rsi
callq *%rax
movzbl %bpl, %ebp
cmpb %al, 0xa(%rbx)
cmovel %r13d, %ebp
je 0x2f95
addq $0x20, %rbx
cmpq %r12, %rbx
jne 0x2f5e
jmp 0x2f95
movb $0x1, %bpl
testb $0x1, %bpl
je 0x2fe3
movq (%rsp), %rbx
movq 0x8(%rsp), %r12
cmpq %rbx, %r12
je 0x2fe3
movq 0x68(%rsp), %rax
movq (%rax), %r15
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rdi
addq %rbx, %rdi
testb $0x1, %al
je 0x2fc8
movq (%rdi), %rcx
movq -0x1(%rcx,%rax), %rax
movq %r15, %rsi
callq *%rax
movzbl %bpl, %ebp
cmpb %al, 0xa(%rbx)
cmovel %r13d, %ebp
je 0x2fe3
addq $0x20, %rbx
cmpq %r12, %rbx
jne 0x2fb1
testb $0x1, %bpl
je 0x30a9
movq 0x6274(%rip), %rsi      # 0x9268
cmpq 0x6275(%rip), %rsi      # 0x9270
je 0x301a
leaq 0x60(%rsp), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
addq $0x20, 0x6250(%rip)     # 0x9268
jmp 0x302b
leaq 0x623f(%rip), %rdi      # 0x9260
leaq 0x60(%rsp), %rdx
callq 0x4bfa
movq 0x6236(%rip), %r15      # 0x9268
subq 0x6227(%rip), %r15      # 0x9260
shrq $0x5, %r15
movq 0x70(%rsp), %rax
movq (%rax), %rbp
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %rcx
movq (%rax), %rsi
movq (%rcx), %rdx
xorl %ebx, %ebx
leaq 0x80(%rsp), %r12
movq %r12, %rdi
xorl %ecx, %ecx
callq 0x2c60
leaq 0x3359(%rip), %rdi      # 0x63c9
movl %r15d, %esi
movq %rbp, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x2030
movq 0x6201(%rip), %rax      # 0x9288
movl 0x4(%rax), %ebp
cmpl %r15d, %ebp
jg 0x30a4
leaq 0x333e(%rip), %rdi      # 0x63d4
movl %ebp, %esi
xorl %eax, %eax
callq 0x2030
movl $0x5, %ebx
cmpl %r15d, %ebp
jle 0x30ab
xorl %ebx, %ebx
testl %ebx, %ebx
je 0x2f33
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x30c9
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x21a0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x30e0
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x21a0
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x30fa
jmp 0x30fa
jmp 0x30fa
jmp 0x30fa
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x3113
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x21a0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x312a
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x21a0
movq %rbx, %rdi
callq 0x22e0