// File: /workspace/github_c_makefile_star2_O2/JimKent[P]linearSat/lib/osunix.c
// Function: listDirXExt
struct fileInfo *listDirXExt(char *dir, char *pattern, boolean fullPath, boolean ignoreStatFailures)
/* Return list of files matching wildcard pattern with
 * extra info. If full path is true then the path will be
 * included in the name of each file. */
{
struct fileInfo *list = NULL, *el;
struct dirent *de;
DIR *d;
int dirNameSize = strlen(dir);
int fileNameOffset = dirNameSize+1;
char pathName[512];

if ((d = opendir(dir)) == NULL)
    return NULL;
memcpy(pathName, dir, dirNameSize);
pathName[dirNameSize] = '/';

while ((de = readdir(d)) != NULL)
    {
    char *fileName = de->d_name;
    if (differentString(fileName, ".") && differentString(fileName, ".."))
	{
	if (pattern == NULL || wildMatch(pattern, fileName))
	    {
	    struct stat st;
	    bool isDir = FALSE;
	    int statErrno = 0;
	    strcpy(pathName+fileNameOffset, fileName);
	    if (stat(pathName, &st) < 0)
		{
		if (ignoreStatFailures)
		    statErrno = errno;
		else
    		    errAbort("stat failed in listDirX");
		}
	    if (S_ISDIR(st.st_mode))
		isDir = TRUE;
	    if (fullPath)
		fileName = pathName;
	    el = newFileInfo(fileName, st.st_size, isDir, statErrno, st.st_atime);
	    slAddHead(&list, el);
	    }
	}
    }
closedir(d);
slSort(&list, cmpFileInfo);
return list;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2b8, %rsp            # imm = 0x2B8
movl %ecx, %r13d
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
andq $0x0, 0x10(%rsp)
callq 0x3200
movq %rax, %r12
movq %rbx, %rdi
callq 0x31d0
testq %rax, %rax
je 0xfa33
movq %rax, %r15
movl %r13d, 0xc(%rsp)
movslq %r12d, %r12
leaq 0xb0(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x34a0
movb $0x2f, 0xb0(%rsp,%r12)
incl %r12d
movslq %r12d, %rax
addq %rsp, %rax
addq $0xb0, %rax
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
leaq 0xb0(%rsp), %r12
movq %r15, %rdi
callq 0x35e0
testq %rax, %rax
je 0xfa12
movq %rax, %rbx
cmpb $0x2e, 0x13(%rax)
jne 0xf96c
cmpb $0x0, 0x14(%rbx)
je 0xf940
cmpb $0x2e, 0x14(%rbx)
jne 0xf96c
cmpb $0x0, 0x15(%rbx)
je 0xf940
addq $0x13, %rbx
testq %r14, %r14
je 0xf984
movq %r14, %rdi
movq %rbx, %rsi
callq 0x113f3
testl %eax, %eax
je 0xf940
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x30e0
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
callq 0x3250
movq %r12, %rcx
xorl %r12d, %r12d
testl %eax, %eax
jns 0xf9d2
cmpl $0x0, 0xc(%rsp)
je 0xf9b9
callq 0x30c0
movl (%rax), %r12d
jmp 0xf9ca
xorl %r12d, %r12d
leaq 0x946c(%rip), %rdi      # 0x18e2f
xorl %eax, %eax
callq 0xa61f
leaq 0xb0(%rsp), %rcx
movl 0x38(%rsp), %eax
movl $0xf000, %edx           # imm = 0xF000
andl %edx, %eax
xorl %edx, %edx
cmpl $0x4000, %eax           # imm = 0x4000
sete %dl
testl %ebp, %ebp
cmovneq %rcx, %rbx
movq 0x50(%rsp), %rsi
movq 0x68(%rsp), %r8
movq %rbx, %rdi
movl %r12d, %ecx
callq 0xf803
movq %r13, (%rax)
movq %rax, 0x10(%rsp)
movq %rax, %r13
jmp 0xf938
movq %r15, %rdi
callq 0x3380
leaq -0x1c4(%rip), %rsi      # 0xf85d
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x6183
movq (%rbx), %rax
jmp 0xfa35
xorl %eax, %eax
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq