// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/kplib.c
// Function: kzfindfile
int kzfindfile (char *filnam)
{
	int i;

	filnam[0] = 0;
	if (srchstat == -3)
	{
		if (!wildst[0]) { srchstat = -1; return(0); }
		do
		{
			srchstat = -2;

				//Extract directory from wildcard string for pre-pending
			wildstpathleng = 0;
			for(i=0;wildst[i];i++)
				if ((wildst[i] == '/') || (wildst[i] == '\\'))
					wildstpathleng = i+1;

			memcpy(filnam,wildst,wildstpathleng);

#if defined(__DOS__)
			if (_dos_findfirst(wildst,_A_SUBDIR,&findata))
				{ if (!kzhashbuf) return(0); srchstat = kzlastfnam; continue; }
			i = wildstpathleng;
			if (findata.attrib&16)
				if ((findata.name[0] == '.') && (!findata.name[1])) continue;
			strcpy(&filnam[i],findata.name);
			if (findata.attrib&16) strcat(&filnam[i],"\\");
#elif defined(_WIN32)
			hfind = FindFirstFile(wildst,&findata);
			if (hfind == INVALID_HANDLE_VALUE)
				{ if (!kzhashbuf) return(0); srchstat = kzlastfnam; continue; }
			if (findata.dwFileAttributes&FILE_ATTRIBUTE_HIDDEN) continue;
			i = wildstpathleng;
			if (findata.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
				if ((findata.cFileName[0] == '.') && (!findata.cFileName[1])) continue;
			strcpy(&filnam[i],findata.cFileName);
			if (findata.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) strcat(&filnam[i],"\\");
#else
			if (!hfind)
			{
				char *s = ".";
				if (wildstpathleng > 0) {
					filnam[wildstpathleng] = 0;
					s = filnam;
				}
				hfind = opendir(s);
				if (!hfind) { if (!kzhashbuf) return 0; srchstat = kzlastfnam; continue; }
			}
			break;   // process srchstat == -2
#endif
			return(1);
		} while (0);
	}
	if (srchstat == -2)
		while (1)
		{
			memcpy(filnam,wildst,wildstpathleng);
#if defined(__DOS__)
			if (_dos_findnext(&findata))
				{ if (!kzhashbuf) return(0); srchstat = kzlastfnam; break; }
			i = wildstpathleng;
			if (findata.attrib&16)
				if ((findata.name[0] == '.') && (!findata.name[1])) continue;
			strcpy(&filnam[i],findata.name);
			if (findata.attrib&16) strcat(&filnam[i],"\\");
#elif defined(_WIN32)
			if (!FindNextFile(hfind,&findata))
				{ FindClose(hfind); hfind = INVALID_HANDLE_VALUE; if (!kzhashbuf) return(0); srchstat = kzlastfnam; break; }
			if (findata.dwFileAttributes&FILE_ATTRIBUTE_HIDDEN) continue;
			i = wildstpathleng;
			if (findata.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
				if ((findata.cFileName[0] == '.') && (!findata.cFileName[1])) continue;
			strcpy(&filnam[i],findata.cFileName);
			if (findata.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) strcat(&filnam[i],"\\");
#else
			struct stat st;
			if ((findata = readdir(hfind)) == NULL)
				{ closedir(hfind); hfind = NULL; if (!kzhashbuf) return 0; srchstat = kzlastfnam; break; }
			i = wildstpathleng;
			if (fstatat(dirfd(hfind), findata->d_name, &st, 0)) continue;
			if (st.st_mode & S_IFDIR)
				{ if (findata->d_name[0] == '.' && !findata->d_name[1]) continue; } //skip .
			else if ((st.st_mode & S_IFREG) || (st.st_mode & S_IFLNK))
				{ if (findata->d_name[0] == '.') continue; } //skip hidden (dot) files
			else continue; //skip devices and fifos and such
			if (!wildmatch(findata->d_name,&wildst[wildstpathleng])) continue;
			strcpy(&filnam[i],findata->d_name);
			if (st.st_mode & S_IFDIR) strcat(&filnam[i],"/");
#endif
			return(1);
		}
	while (srchstat >= 0)
	{
		if (wildmatch(&kzhashbuf[srchstat+16],wildst))
		{
			//strcpy(filnam,&kzhashbuf[srchstat+16]);
			filnam[0] = '|'; strcpy(&filnam[1],&kzhashbuf[srchstat+16]);
			srchstat = *(int *)&kzhashbuf[srchstat+4];
			return(1);
		}
		srchstat = *(int *)&kzhashbuf[srchstat+4];
	}
	return(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movb $0x0, (%rax)
cmpl $-0x3, 0x78943(%rip)    # 0xe1220
jne 0x68a01
cmpb $0x0, 0x5406e6(%rip)    # 0x5a8fd0
jne 0x68902
movl $0xffffffff, 0x7892a(%rip) # imm = 0xFFFFFFFF
movl $0x0, -0x4(%rbp)
jmp 0x68c50
jmp 0x68904
movl $0xfffffffe, 0x78912(%rip) # imm = 0xFFFFFFFE
movl $0x0, 0x5407bc(%rip)    # 0x5a90d4
movl $0x0, -0x14(%rbp)
movslq -0x14(%rbp), %rcx
leaq 0x5406a6(%rip), %rax    # 0x5a8fd0
cmpb $0x0, (%rax,%rcx)
je 0x68971
movslq -0x14(%rbp), %rcx
leaq 0x540695(%rip), %rax    # 0x5a8fd0
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
je 0x68958
movslq -0x14(%rbp), %rcx
leaq 0x540681(%rip), %rax    # 0x5a8fd0
movsbl (%rax,%rcx), %eax
cmpl $0x5c, %eax
jne 0x68964
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, 0x540770(%rip)    # 0x5a90d4
jmp 0x68966
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x6891f
movq -0x10(%rbp), %rdi
movslq 0x540758(%rip), %rdx    # 0x5a90d4
leaq 0x54064d(%rip), %rsi    # 0x5a8fd0
callq 0x60c0
cmpq $0x0, 0x540630(%rip)    # 0x5a8fc0
jne 0x689fd
leaq 0x46926(%rip), %rax     # 0xaf2bf
movq %rax, -0x20(%rbp)
cmpl $0x0, 0x540730(%rip)    # 0x5a90d4
jle 0x689bd
movq -0x10(%rbp), %rax
movslq 0x540723(%rip), %rcx    # 0x5a90d4
movb $0x0, (%rax,%rcx)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x65b0
movq %rax, 0x5405f3(%rip)    # 0x5a8fc0
cmpq $0x0, 0x5405eb(%rip)    # 0x5a8fc0
jne 0x689fb
cmpq $0x0, 0x540189(%rip)    # 0x5a8b68
jne 0x689ed
movl $0x0, -0x4(%rbp)
jmp 0x68c50
movl 0x54058d(%rip), %eax    # 0x5a8f80
movl %eax, 0x78827(%rip)     # 0xe1220
jmp 0x689ff
jmp 0x689fd
jmp 0x689ff
jmp 0x68a01
cmpl $-0x2, 0x78818(%rip)    # 0xe1220
jne 0x68ba5
jmp 0x68a10
movq -0x10(%rbp), %rdi
movslq 0x5406b9(%rip), %rdx    # 0x5a90d4
leaq 0x5405ae(%rip), %rsi    # 0x5a8fd0
callq 0x60c0
movq 0x540592(%rip), %rdi    # 0x5a8fc0
callq 0x6760
movq %rax, 0x54069e(%rip)    # 0x5a90d8
cmpq $0x0, %rax
jne 0x68a7e
movq 0x540579(%rip), %rdi    # 0x5a8fc0
callq 0x6580
movq $0x0, 0x540569(%rip) # 0x5a8fc0
cmpq $0x0, 0x540109(%rip)    # 0x5a8b68
jne 0x68a6d
movl $0x0, -0x4(%rbp)
jmp 0x68c50
movl 0x54050d(%rip), %eax    # 0x5a8f80
movl %eax, 0x787a7(%rip)     # 0xe1220
jmp 0x68ba3
movl 0x540650(%rip), %eax    # 0x5a90d4
movl %eax, -0x14(%rbp)
movq 0x540532(%rip), %rdi    # 0x5a8fc0
callq 0x69b0
movl %eax, %edi
movq 0x54063c(%rip), %rsi    # 0x5a90d8
addq $0x13, %rsi
leaq -0xb0(%rbp), %rdx
xorl %ecx, %ecx
callq 0x63c0
cmpl $0x0, %eax
je 0x68ab8
jmp 0x68a10
movl -0x98(%rbp), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0x68aec
movq 0x540609(%rip), %rax    # 0x5a90d8
movsbl 0x13(%rax), %eax
cmpl $0x2e, %eax
jne 0x68aea
movq 0x5405f9(%rip), %rax    # 0x5a90d8
cmpb $0x0, 0x14(%rax)
jne 0x68aea
jmp 0x68a10
jmp 0x68b2a
movl -0x98(%rbp), %eax
andl $0x8000, %eax           # imm = 0x8000
cmpl $0x0, %eax
jne 0x68b0c
movl -0x98(%rbp), %eax
andl $0xa000, %eax           # imm = 0xA000
cmpl $0x0, %eax
je 0x68b23
movq 0x5405c5(%rip), %rax    # 0x5a90d8
movsbl 0x13(%rax), %eax
cmpl $0x2e, %eax
jne 0x68b21
jmp 0x68a10
jmp 0x68b28
jmp 0x68a10
jmp 0x68b2a
movq 0x5405a7(%rip), %rdi    # 0x5a90d8
addq $0x13, %rdi
movslq 0x540598(%rip), %rax    # 0x5a90d4
leaq 0x54048d(%rip), %rsi    # 0x5a8fd0
addq %rax, %rsi
callq 0x68c60
cmpl $0x0, %eax
jne 0x68b55
jmp 0x68a10
movq -0x10(%rbp), %rdi
movslq -0x14(%rbp), %rax
addq %rax, %rdi
movq 0x540571(%rip), %rsi    # 0x5a90d8
addq $0x13, %rsi
callq 0x63e0
movl -0x98(%rbp), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0x68b97
movq -0x10(%rbp), %rdi
movslq -0x14(%rbp), %rax
addq %rax, %rdi
leaq 0x49459(%rip), %rsi     # 0xb1feb
callq 0x6690
movl $0x1, -0x4(%rbp)
jmp 0x68c50
jmp 0x68ba5
jmp 0x68ba7
cmpl $0x0, 0x78672(%rip)     # 0xe1220
jl 0x68c49
movq 0x53ffad(%rip), %rdi    # 0x5a8b68
movl 0x7865f(%rip), %eax     # 0xe1220
addl $0x10, %eax
cltq
addq %rax, %rdi
leaq 0x540400(%rip), %rsi    # 0x5a8fd0
callq 0x68c60
cmpl $0x0, %eax
je 0x68c28
movq -0x10(%rbp), %rax
movb $0x7c, (%rax)
movq -0x10(%rbp), %rdi
addq $0x1, %rdi
movq 0x53ff78(%rip), %rsi    # 0x5a8b68
movl 0x7862a(%rip), %eax     # 0xe1220
addl $0x10, %eax
cltq
addq %rax, %rsi
callq 0x63e0
movq 0x53ff5e(%rip), %rax    # 0x5a8b68
movl 0x78610(%rip), %ecx     # 0xe1220
addl $0x4, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx), %eax
movl %eax, 0x78601(%rip)     # 0xe1220
movl $0x1, -0x4(%rbp)
jmp 0x68c50
movq 0x53ff39(%rip), %rax    # 0x5a8b68
movl 0x785eb(%rip), %ecx     # 0xe1220
addl $0x4, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx), %eax
movl %eax, 0x785dc(%rip)     # 0xe1220
jmp 0x68ba7
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax)