// File: /workspace/github_c_makefile_star2_O0/serge-404[P]CPM32/cpm.c
// Function: FindFirstFile
DIR *FindFirstFile(char* lpFileName,	// pointer to name of file to search for  
    WIN32_FIND_DATA *lpFindFileData) 	// pointer to returned information 
{
    DIR *pDir;
    struct dirent *pDirent;
    struct stat statbuf;
	char *cDir, *cName=lpFileName;
	int szDir;
	cDir=strrchr(lpFileName, '|');
	if (cDir==NULL)
		cDir=strrchr(lpFileName, '/');
	if ((cDir)!=NULL) { 
		cName=cDir+1;
		cDir=lpFileName;
		szDir=cName-cDir-1;
		strncpy(ffDir, cDir, szDir);
		ffDir[szDir]=0;
	}
	else {
		strncpy(ffDir, cpm_drive[ cpm_disk_no], sizeof(ffDir));
	}
	strncpy(ffName, cName, sizeof(ffName)-1);
	if (strncmp(ffName,"*.*",4)==0) {
		*ffName='*';
		ffName[1]=0;
	}
	CharUpperX(ffName);
	pDir = opendir(ffDir);
	if (pDir == NULL) 
        return hFindFile=INVALID_HANDLE_VALUE;
    while ((pDirent = readdir(pDir)) != NULL) {
       	strncpy(lpFindFileData->cFileName, pDirent->d_name, _MAX_PATH-1);
		if (fnmatch(ffName, CharUpperX(pDirent->d_name), FNM_CASEFOLD)==0) {
			if (stat(buildname(ffDir,lpFindFileData->cFileName), &statbuf)!=0) { 
				closedir(pDir);
				DEBUGOUT(stderr, "FindFirst ERROR: failed while stat file `%s`\n",lpFindFileData->cFileName);
	 			return hFindFile=INVALID_HANDLE_VALUE;
			}
			if (!(statbuf.st_mode & S_IFDIR)) {
				lpFindFileData->cAlternateFileName[0]=0;
				lpFindFileData->dwFileAttributes=(*(lpFindFileData->cFileName)=='.' ? FILE_ATTRIBUTE_HIDDEN : 0);	
				lpFindFileData->nFileSizeHigh=0;
				lpFindFileData->nFileSizeLow=(DWORD)statbuf.st_size;
				return pDir;
			}
		}
    }
    closedir(pDir);
    return hFindFile=INVALID_HANDLE_VALUE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x10(%rbp), %rdi
movl $0x7c, %esi
callq 0x2120
movq %rax, -0xc0(%rbp)
cmpq $0x0, -0xc0(%rbp)
jne 0xe632
movq -0x10(%rbp), %rdi
movl $0x2f, %esi
callq 0x2120
movq %rax, -0xc0(%rbp)
cmpq $0x0, -0xc0(%rbp)
je 0xe6a2
movq -0xc0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xc8(%rbp), %rax
movq -0xc0(%rbp), %rcx
subq %rcx, %rax
subq $0x1, %rax
movl %eax, -0xcc(%rbp)
movq -0xc0(%rbp), %rsi
movslq -0xcc(%rbp), %rdx
leaq 0x10ea07(%rip), %rdi    # 0x11d090
callq 0x2060
movslq -0xcc(%rbp), %rcx
leaq 0x10e9f4(%rip), %rax    # 0x11d090
movb $0x0, (%rax,%rcx)
jmp 0xe6c7
movzbl 0xcb7f(%rip), %eax      # 0x1b228
movl %eax, %ecx
leaq 0x10cf2e(%rip), %rax    # 0x11b5e0
movq (%rax,%rcx,8), %rsi
leaq 0x10e9d3(%rip), %rdi    # 0x11d090
movl $0x104, %edx            # imm = 0x104
callq 0x2060
movq -0xc8(%rbp), %rsi
leaq 0x10eacb(%rip), %rdi    # 0x11d1a0
movl $0x103, %edx            # imm = 0x103
callq 0x2060
leaq 0x10eaba(%rip), %rdi    # 0x11d1a0
leaq 0x9e4d(%rip), %rsi      # 0x1853a
movl $0x4, %edx
callq 0x2080
cmpl $0x0, %eax
jne 0xe70a
movb $0x2a, 0x10ea9d(%rip)   # 0x11d1a0
movb $0x0, 0x10ea97(%rip)    # 0x11d1a1
leaq 0x10ea8f(%rip), %rdi    # 0x11d1a0
callq 0xd640
leaq 0x10e973(%rip), %rdi    # 0x11d090
callq 0x20e0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xe745
movq $0x0, 0x10e948(%rip) # 0x11d080
movq $0x0, -0x8(%rbp)
jmp 0xe896
jmp 0xe747
movq -0x20(%rbp), %rdi
callq 0x22a0
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0xe87a
movq -0x18(%rbp), %rdi
addq $0x18, %rdi
movq -0x28(%rbp), %rsi
addq $0x13, %rsi
movl $0x103, %edx            # imm = 0x103
callq 0x2060
movq -0x28(%rbp), %rdi
addq $0x13, %rdi
callq 0xd640
movq %rax, %rsi
leaq 0x10ea11(%rip), %rdi    # 0x11d1a0
movl $0x10, %edx
callq 0x2150
cmpl $0x0, %eax
jne 0xe875
movq -0x18(%rbp), %rsi
addq $0x18, %rsi
leaq 0x10e8df(%rip), %rdi    # 0x11d090
callq 0xd820
movq %rax, %rdi
leaq -0xb8(%rbp), %rsi
callq 0x2250
cmpl $0x0, %eax
je 0xe814
movq -0x20(%rbp), %rdi
callq 0x21b0
cmpl $0x0, 0x10ccda(%rip)    # 0x11b4b4
je 0xe7fc
movq 0xc815(%rip), %rax      # 0x1aff8
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
addq $0x18, %rdx
leaq 0x9c64(%rip), %rsi      # 0x18459
movb $0x0, %al
callq 0x2220
movq $0x0, 0x10e879(%rip) # 0x11d080
movq $0x0, -0x8(%rbp)
jmp 0xe896
movl -0xa0(%rbp), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
jne 0xe873
movq -0x18(%rbp), %rax
movb $0x0, 0x11c(%rax)
movq -0x18(%rbp), %rax
movsbl 0x18(%rax), %edx
xorl %eax, %eax
movl $0x2, %ecx
cmpl $0x2e, %edx
cmovel %ecx, %eax
movslq %eax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x88(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xe896
jmp 0xe875
jmp 0xe747
movq -0x20(%rbp), %rdi
callq 0x21b0
movq $0x0, 0x10e7f2(%rip) # 0x11d080
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)