// File: /workspace/github_c_makefile_star2_O1/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, 0x8(%rsp)
movl %edx, 0xc(%rsp)
movq %rsi, %r14
movq %rdi, %r12
movq $0x0, (%rsp)
callq 0x3200
movq %rax, %rbx
movq %r12, %rdi
callq 0x31d0
testq %rax, %rax
je 0x11546
movq %rax, %r15
movslq %ebx, %r13
leaq 0xb0(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x34a0
movb $0x2f, 0xb0(%rsp,%r13)
movq %r15, %rdi
callq 0x35e0
testq %rax, %rax
je 0x11527
movq %rax, %r12
shlq $0x20, %rbx
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rbx, %rax
sarq $0x20, %rax
addq %rsp, %rax
addq $0xb0, %rax
movq %rax, 0x18(%rsp)
leaq 0x8599(%rip), %rbx      # 0x199bc
leaq 0x9c39(%rip), %r13      # 0x1b063
movq %r14, 0x10(%rsp)
addq $0x13, %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3440
testl %eax, %eax
je 0x11513
movq %r12, %rdi
movq %r13, %rsi
callq 0x3440
testl %eax, %eax
je 0x11513
testq %r14, %r14
je 0x11471
movq %r14, %rdi
movq %r12, %rsi
callq 0x12f9d
testl %eax, %eax
je 0x11513
movq %rbx, %r14
movq %r13, %rbx
movq 0x18(%rsp), %rdi
movq %r12, %rsi
callq 0x30e0
leaq 0xb0(%rsp), %rbp
movq %rbp, %rdi
leaq 0x20(%rsp), %rsi
callq 0x3250
xorl %r13d, %r13d
testl %eax, %eax
jns 0x114ca
cmpl $0x0, 0x8(%rsp)
je 0x114b1
callq 0x30c0
movl (%rax), %r13d
jmp 0x114c2
xorl %r13d, %r13d
leaq 0x9967(%rip), %rdi      # 0x1ae22
xorl %eax, %eax
callq 0xb8d7
leaq 0xb0(%rsp), %rbp
movl 0x38(%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 %rbp, %r12
movq 0x50(%rsp), %rsi
movq 0x68(%rsp), %r8
movq %r12, %rdi
movl %r13d, %ecx
callq 0x112c7
movq (%rsp), %rcx
movq %rcx, (%rax)
movq %rax, (%rsp)
movq %rbx, %r13
movq %r14, %rbx
movq 0x10(%rsp), %r14
movq %r15, %rdi
callq 0x35e0
movq %rax, %r12
testq %rax, %rax
jne 0x1142f
movq %r15, %rdi
callq 0x3380
leaq -0x215(%rip), %rsi      # 0x11321
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x678c
movq (%rbx), %rax
jmp 0x11548
xorl %eax, %eax
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq