// File: /workspace/github_cpp_makefile_star2_O2/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 0x6533(%rip), %rax      # 0x9260
leaq 0x60(%rsp), %rcx
movq %rax, -0x8(%rcx)
andq $0x0, 0x18(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rcx)
leaq 0x40(%rsp), %rax
movq %rax, 0x20(%rax)
leaq 0x20(%rsp), %r13
andq $0x0, 0x10(%r13)
movq %rsp, %rbp
andq $0x0, 0x10(%rbp)
movaps %xmm0, (%r13)
movaps %xmm0, (%rbp)
leaq 0x35cc(%rip), %r14      # 0x6339
leaq 0x80(%rsp), %r15
movq %r14, %rsi
callq 0x22d0
testq %rax, %rax
je 0x2dc3
movq %rax, %r12
movq %rax, %rdi
callq 0x20b0
movzbl -0x1(%r12,%rax), %ecx
cmpl $0x5c, %ecx
je 0x2da0
movq %r13, %rbx
cmpl $0x2f, %ecx
jne 0x2da9
movb $0x0, -0x1(%r12,%rax)
movq %rbp, %rbx
movq %r15, %rdi
movq %r12, %rsi
callq 0x3fea
movq %rbx, %rdi
movq %r15, %rsi
callq 0x45c2
xorl %edi, %edi
jmp 0x2d75
movb $0x66, 0x649e(%rip)     # 0x9268
movq 0x649f(%rip), %rax      # 0x9270
cmpq %rax, 0x64a0(%rip)      # 0x9278
je 0x2de1
movq %rax, 0x6497(%rip)      # 0x9278
orl $-0x1, 0x64a0(%rip)     # 0x9288
leaq 0x40(%rsp), %r14
leaq 0x80(%rsp), %r12
leaq 0x35cd(%rip), %r13      # 0x63c9
movq %r14, %rdi
callq 0x4082
testq %rax, %rax
je 0x2ee4
movq 0x70(%rsp), %rax
movq (%rax), %rbp
movq 0x20(%rsp), %rbx
movq 0x28(%rsp), %r15
cmpq %r15, %rbx
je 0x2e3b
movq %rbx, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x40a6
addq $0x20, %rbx
testb %al, %al
jne 0x2e1f
jmp 0x2dfc
movq (%rsp), %rbp
movq 0x8(%rsp), %r15
cmpq %rbp, %r15
je 0x2e6d
movq 0x68(%rsp), %rax
movq (%rax), %rbx
cmpq %r15, %rbp
je 0x2e6d
movq %rbp, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x40a6
addq $0x20, %rbp
testb %al, %al
jne 0x2e51
jmp 0x2dfc
leaq 0x63fc(%rip), %rdi      # 0x9270
leaq 0x60(%rsp), %rsi
callq 0x410c
movq 0x63f3(%rip), %rbp      # 0x9278
subq 0x63e4(%rip), %rbp      # 0x9270
shrq $0x5, %rbp
movq 0x70(%rsp), %rax
movq (%rax), %rbx
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %rcx
movq (%rax), %rsi
movq (%rcx), %rdx
movq %r12, %rdi
xorl %ecx, %ecx
callq 0x2b69
movq %r13, %rdi
movl %ebp, %esi
movq %rbx, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x2030
movq 0x63cd(%rip), %rax      # 0x9298
movl 0x4(%rax), %esi
cmpl %ebp, %esi
jg 0x2dfc
leaq 0x34f7(%rip), %rdi      # 0x63d4
xorl %eax, %eax
callq 0x2030
movq %rsp, %rdi
callq 0x458e
leaq 0x20(%rsp), %rdi
callq 0x458e
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2f10
jmp 0x2f10
jmp 0x2f10
jmp 0x2f10
movq %rax, %rbx
movq %rsp, %rdi
callq 0x458e
leaq 0x20(%rsp), %rdi
callq 0x458e
movq %rbx, %rdi
callq 0x2310