// File: /workspace/github_cpp_makefile_star2_O1/attractivechaos[P]udb2/stb/./stb.h
// Function: readdir_raw
static char **readdir_raw(char *dir, int return_subdirs, char *mask)
{
   char **results = NULL;
   char buffer[4096], with_slash[4096];
   size_t n;

   #ifdef _MSC_VER
      stb__wchar *ws;
      struct _wfinddata_t data;
   #ifdef _WIN64
      const intptr_t none = -1;
      intptr_t z;
   #else
      const long none = -1;
      long z;
   #endif
   #else // !_MSC_VER
      const DIR *none = NULL;
      DIR *z;
   #endif

   n = stb_strscpy(buffer,dir,sizeof(buffer));
   if (!n || n >= sizeof(buffer))
      return NULL;
   stb_fixpath(buffer);
   n--;

   if (n > 0 && (buffer[n-1] != '/')) {
      buffer[n++] = '/';
   }
   buffer[n] = 0;
   if (!stb_strscpy(with_slash,buffer,sizeof(with_slash)))
      return NULL;

   #ifdef _MSC_VER
      if (!stb_strscpy(buffer+n,"*.*",sizeof(buffer)-n))
         return NULL;
      ws = stb__from_utf8(buffer);
      z = _wfindfirst((const wchar_t *)ws, &data);
   #else
      z = opendir(dir);
   #endif

   if (z != none) {
      int nonempty = STB_TRUE;
      #ifndef _MSC_VER
      struct dirent *data = readdir(z);
      nonempty = (data != NULL);
      #endif

      if (nonempty) {

         do {
            int is_subdir;
            #ifdef _MSC_VER
            char *name = stb__to_utf8((stb__wchar *)data.name);
            if (name == NULL) {
               fprintf(stderr, "%s to convert '%S' to %s!\n", "Unable", data.name, "utf8");
               continue;
            }
            is_subdir = !!(data.attrib & _A_SUBDIR);
            #else
            char *name = data->d_name;
            if (!stb_strscpy(buffer+n,name,sizeof(buffer)-n))
               break;
            // Could follow DT_LNK, but would need to check for recursive links.
            is_subdir = !!(data->d_type & DT_DIR);
            #endif

            if (is_subdir == return_subdirs) {
               if (!is_subdir || !isdotdirname(name)) {
                  if (!mask || stb_wildmatchi(mask, name)) {
                     char buffer[4096],*p=buffer;
                     if ( stb_snprintf(buffer, sizeof(buffer), "%s%s", with_slash, name) < 0 )
                        break;
                     if (buffer[0] == '.' && buffer[1] == '/')
                        p = buffer+2;
                     stb_arr_push(results, strdup(p));
                  }
               }
            }
         }
         #ifdef _MSC_VER
         while (0 == _wfindnext(z, &data));
         #else
         while ((data = readdir(z)) != NULL);
         #endif
      }
      #ifdef _MSC_VER
         _findclose(z);
      #else
         closedir(z);
      #endif
   }
   return results;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3018, %rsp           # imm = 0x3018
movq %rdx, 0x8(%rsp)
movl %esi, %ebp
movq %rdi, %r14
movq $0x0, (%rsp)
leaq 0x10(%rsp), %rbx
movl $0x1000, %edx           # imm = 0x1000
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3d6f
leaq -0x1000(%rax), %rcx
cmpq $-0xfff, %rcx           # imm = 0xF001
jb 0x9c5a
movq %rax, %r13
movzbl (%rbx), %ecx
cmpl $0x5c, %ecx
je 0x9a79
testl %ecx, %ecx
jne 0x9a7c
jmp 0x9a81
movb $0x2f, (%rbx)
incq %rbx
jmp 0x9a6b
decq %rax
je 0x9a98
leaq 0x10(%rsp), %rcx
cmpb $0x2f, -0x2(%r13,%rcx)
jne 0x9a9d
movq %rax, %r13
jmp 0x9aa2
xorl %r13d, %r13d
jmp 0x9aa2
movb $0x2f, 0x10(%rsp,%rax)
movb $0x0, 0x10(%rsp,%r13)
leaq 0x2010(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl $0x1000, %edx           # imm = 0x1000
callq 0x3d6f
testq %rax, %rax
je 0x9c5a
movq %r14, %rdi
callq 0x20e0
testq %rax, %rax
je 0x9c54
movq %rax, %r14
movq %rax, %rdi
callq 0x2240
testq %rax, %rax
je 0x9c4c
movq %rax, %rbx
leaq (%rsp,%r13), %r15
addq $0x10, %r15
movl $0x1000, %r12d          # imm = 0x1000
subq %r13, %r12
leaq 0x13(%rbx), %r13
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x3d6f
testq %rax, %rax
je 0x9bdb
movzbl 0x12(%rbx), %eax
andl $0x4, %eax
movl %eax, %ecx
shrl $0x2, %ecx
cmpl %ebp, %ecx
jne 0x9c32
testb %al, %al
je 0x9b4d
cmpb $0x2e, (%r13)
jne 0x9b4d
movb 0x14(%rbx), %al
cmpb $0x2e, %al
jne 0x9b45
movb 0x15(%rbx), %al
testb %al, %al
je 0x9c32
cmpq $0x0, 0x8(%rsp)
je 0x9b71
movq 0x8(%rsp), %rdi
movq %r13, %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0xd75e
testl %eax, %eax
js 0x9c32
movl $0x1000, %esi           # imm = 0x1000
leaq 0x1010(%rsp), %rdi
leaq 0x955e(%rip), %rdx      # 0x130e3
leaq 0x2010(%rsp), %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x29a8
movl %eax, %r13d
testl %eax, %eax
js 0x9be2
movb 0x1010(%rsp), %al
movb 0x1011(%rsp), %cl
xorb $0x2e, %al
xorb $0x2f, %cl
xorl %edx, %edx
orb %al, %cl
sete %dl
leaq (%rsp,%rdx,2), %rdi
addq $0x1010, %rdi           # imm = 0x1010
callq 0x2390
movq %rax, %rbx
movq (%rsp), %rax
testq %rax, %rax
je 0x9be9
movl -0x10(%rax), %ecx
incl %ecx
jmp 0x9bee
movl $0x2, %eax
jmp 0x9c34
movl $0x2, %eax
jmp 0x9c2d
movl $0x1, %ecx
testq %rax, %rax
je 0x9bf8
movl -0xc(%rax), %edx
jmp 0x9bfa
xorl %edx, %edx
cmpl %edx, %ecx
jle 0x9c12
movq %rsp, %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x57e0
jmp 0x9c15
incl -0x10(%rax)
movq (%rsp), %rax
testq %rax, %rax
je 0x9c24
movslq -0x10(%rax), %rcx
jmp 0x9c26
xorl %ecx, %ecx
movq %rbx, -0x8(%rax,%rcx,8)
xorl %eax, %eax
testl %r13d, %r13d
js 0x9c34
xorl %eax, %eax
testl %eax, %eax
jne 0x9c4c
movq %r14, %rdi
callq 0x2240
movq %rax, %rbx
testq %rax, %rax
jne 0x9b01
movq %r14, %rdi
callq 0x21a0
movq (%rsp), %rax
jmp 0x9c5c
xorl %eax, %eax
addq $0x3018, %rsp           # imm = 0x3018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq