// File: /workspace/github_c_makefile_star2_O3/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 $0x2a8, %rsp            # imm = 0x2A8
movl %ecx, 0x8(%rsp)
movl %edx, 0xc(%rsp)
movq %rsi, %r14
movq %rdi, %rbx
movq $0x0, (%rsp)
callq 0x3200
movq %rax, %r13
movq %rbx, %rdi
callq 0x31d0
testq %rax, %rax
je 0x112a8
movq %rax, %r15
movslq %r13d, %rbp
leaq 0xa0(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x34a0
movb $0x2f, 0xa0(%rsp,%rbp)
movq %r15, %rdi
callq 0x35e0
testq %rax, %rax
je 0x11289
movq %rax, %rbx
shlq $0x20, %r13
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %r13, %rax
sarq $0x20, %rax
leaq (%rsp,%rax), %r13
addq $0xa0, %r13
cmpb $0x2e, 0x13(%rbx)
jne 0x111e2
cmpb $0x0, 0x14(%rbx)
je 0x11275
cmpb $0x2e, 0x14(%rbx)
jne 0x111e2
cmpb $0x0, 0x15(%rbx)
je 0x11275
addq $0x13, %rbx
testq %r14, %r14
je 0x111fa
movq %r14, %rdi
movq %rbx, %rsi
callq 0x12d41
testl %eax, %eax
je 0x11275
movq %r13, %rdi
movq %rbx, %rsi
callq 0x30e0
movq %r12, %rdi
leaq 0x10(%rsp), %rsi
callq 0x3250
xorl %ebp, %ebp
testl %eax, %eax
jns 0x11238
cmpl $0x0, 0x8(%rsp)
je 0x11228
callq 0x30c0
movl (%rax), %ebp
jmp 0x11238
xorl %ebp, %ebp
leaq 0x9bfe(%rip), %rdi      # 0x1ae2f
xorl %eax, %eax
callq 0xb6c8
movl 0x28(%rsp), %eax
movl $0xf000, %ecx           # imm = 0xF000
andl %ecx, %eax
xorl %edx, %edx
cmpl $0x4000, %eax           # imm = 0x4000
sete %dl
cmpl $0x0, 0xc(%rsp)
cmovneq %r12, %rbx
movq 0x40(%rsp), %rsi
movq 0x58(%rsp), %r8
movq %rbx, %rdi
movl %ebp, %ecx
callq 0x1106e
movq (%rsp), %rcx
movq %rcx, (%rax)
movq %rax, (%rsp)
movq %r15, %rdi
callq 0x35e0
movq %rax, %rbx
testq %rax, %rax
jne 0x111c2
movq %r15, %rdi
callq 0x3380
leaq -0x1d0(%rip), %rsi      # 0x110c8
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x670c
movq (%rbx), %rax
jmp 0x112aa
xorl %eax, %eax
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq