// File: /workspace/github_cpp_makefile_star2_O3/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 0x63f1(%rip), %rax      # 0x9250
leaq 0x40(%rsp), %rcx
movq %rax, 0x18(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rcx)
xorl %eax, %eax
movq %rax, 0x38(%rcx)
movq %rcx, 0x20(%rcx)
movq %rax, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movq %rax, 0x10(%rsp)
movaps %xmm0, (%rsp)
leaq 0x34a6(%rip), %rsi      # 0x6339
callq 0x22a0
testq %rax, %rax
je 0x2f35
movq %rax, %r15
leaq 0x20(%rsp), %r13
movq %rsp, %rbp
leaq 0x80(%rsp), %rbx
leaq 0x347e(%rip), %r14      # 0x6339
movq %r15, %rdi
callq 0x20b0
movzbl -0x1(%r15,%rax), %ecx
cmpl $0x5c, %ecx
je 0x2ed6
movq %r13, %r12
cmpl $0x2f, %ecx
jne 0x2edf
movb $0x0, -0x1(%r15,%rax)
movq %rbp, %r12
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4478
movq 0x8(%r12), %rsi
cmpq 0x10(%r12), %rsi
je 0x2f18
movups 0x80(%rsp), %xmm0
movups 0x90(%rsp), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
addq $0x20, %rsi
movq %rsi, 0x8(%r12)
jmp 0x2f23
movq %r12, %rdi
movq %rbx, %rdx
callq 0x4970
xorl %edi, %edi
movq %r14, %rsi
callq 0x22a0
movq %rax, %r15
testq %rax, %rax
jne 0x2ebb
movb $0x66, 0x631c(%rip)     # 0x9258
movq 0x631d(%rip), %rax      # 0x9260
cmpq %rax, 0x631e(%rip)      # 0x9268
je 0x2f53
movq %rax, 0x6315(%rip)      # 0x9268
leaq 0x60(%rsp), %rbx
movl $0xffffffff, 0x6316(%rip) # imm = 0xFFFFFFFF
leaq 0x40(%rsp), %r14
leaq 0x80(%rsp), %r12
movq %r14, %rdi
callq 0x4536
testq %rax, %rax
je 0x30b2
movq 0x20(%rsp), %r15
movq 0x28(%rsp), %r13
cmpq %r13, %r15
je 0x2fc2
movq 0x70(%rsp), %rax
movq (%rax), %rbp
movq 0x10(%r15), %rax
movq 0x18(%r15), %rdi
addq %r15, %rdi
testb $0x1, %al
je 0x2fae
movq (%rdi), %rcx
movq -0x1(%rcx,%rax), %rax
movq %rbp, %rsi
callq *%rax
cmpb %al, 0xa(%r15)
je 0x2f6f
addq $0x20, %r15
cmpq %r13, %r15
jne 0x2f97
movq (%rsp), %r15
movq 0x8(%rsp), %r13
cmpq %r15, %r13
je 0x3007
movq 0x68(%rsp), %rax
movq (%rax), %rbp
movq 0x10(%r15), %rax
movq 0x18(%r15), %rdi
addq %r15, %rdi
testb $0x1, %al
je 0x2fef
movq (%rdi), %rcx
movq -0x1(%rcx,%rax), %rax
movq %rbp, %rsi
callq *%rax
cmpb %al, 0xa(%r15)
je 0x2f6f
addq $0x20, %r15
cmpq %r13, %r15
jne 0x2fd8
movq 0x625a(%rip), %rsi      # 0x9268
cmpq 0x625b(%rip), %rsi      # 0x9270
je 0x3039
movups (%rbx), %xmm0
movups 0x10(%rbx), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
movq 0x623c(%rip), %rbp      # 0x9268
addq $0x20, %rbp
movq %rbp, 0x6231(%rip)      # 0x9268
jmp 0x304f
leaq 0x6220(%rip), %rdi      # 0x9260
movq %rbx, %rdx
callq 0x4ace
movq 0x6219(%rip), %rbp      # 0x9268
subq 0x620a(%rip), %rbp      # 0x9260
shrq $0x5, %rbp
movq 0x70(%rsp), %rax
movq (%rax), %r15
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %rcx
movq (%rax), %rsi
movq (%rcx), %rdx
movq %r12, %rdi
xorl %ecx, %ecx
callq 0x2c94
leaq 0x3346(%rip), %rdi      # 0x63c9
movl %ebp, %esi
movq %r15, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x2030
movq 0x61ef(%rip), %rax      # 0x9288
movl 0x4(%rax), %esi
cmpl %ebp, %esi
jg 0x2f6f
leaq 0x3329(%rip), %rdi      # 0x63d4
xorl %eax, %eax
callq 0x2030
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x30c8
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x21a0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x30df
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 0x30f9
jmp 0x30f9
jmp 0x30f9
jmp 0x30f9
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x3112
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x21a0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x3129
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x21a0
movq %rbx, %rdi
callq 0x22e0