// File: /workspace/github_cpp_makefile_star2_O2/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 $0x3028, %rsp           # imm = 0x3028
movq %rdx, 0x10(%rsp)
movl %esi, %ebp
movq %rdi, %rbx
andq $0x0, 0x8(%rsp)
leaq 0x20(%rsp), %rdi
movl $0x1000, %edx           # imm = 0x1000
movq %rbx, %rsi
callq 0x3a4a
movq %rax, %r13
addq $-0x1000, %rax          # imm = 0xF000
cmpq $-0xfff, %rax           # imm = 0xF001
jb 0x8c73
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x45de
movq %r13, %rax
decq %rax
je 0x8aed
cmpb $0x2f, -0x2(%r13,%r14)
jne 0x8af2
movq %rax, %r13
jmp 0x8af7
xorl %r13d, %r13d
jmp 0x8af7
movb $0x2f, 0x20(%rsp,%rax)
movb $0x0, 0x20(%rsp,%r13)
leaq 0x2020(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl $0x1000, %edx           # imm = 0x1000
callq 0x3a4a
testq %rax, %rax
je 0x8c73
movq %rbx, %rdi
callq 0x20e0
testq %rax, %rax
je 0x8c73
movq %rax, %r14
movq %rax, %rdi
callq 0x2240
testq %rax, %rax
je 0x8c8b
movq %rax, %rbx
leaq (%rsp,%r13), %rax
addq $0x20, %rax
movq %rax, 0x18(%rsp)
movl $0x1000, %r12d          # imm = 0x1000
subq %r13, %r12
xorl %r13d, %r13d
leaq 0x13(%rbx), %r15
movq 0x18(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x3a4a
testq %rax, %rax
je 0x8c8e
movzbl 0x12(%rbx), %eax
andl $0x4, %eax
movl %eax, %ecx
shrl $0x2, %ecx
cmpl %ebp, %ecx
jne 0x8c5d
testb %al, %al
je 0x8bab
cmpb $0x2e, (%r15)
jne 0x8bab
movb 0x14(%rbx), %al
cmpb $0x2e, %al
jne 0x8ba3
movb 0x15(%rbx), %al
testb %al, %al
je 0x8c5d
cmpq $0x0, 0x10(%rsp)
je 0x8bc8
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0xbfda
testl %eax, %eax
je 0x8c5d
movl $0x1000, %esi           # imm = 0x1000
leaq 0x1020(%rsp), %rdi
leaq 0x841d(%rip), %rdx      # 0x10ff9
leaq 0x2020(%rsp), %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x2871
testl %eax, %eax
js 0x8c98
movb 0x1020(%rsp), %al
movb 0x1021(%rsp), %cl
xorb $0x2e, %al
xorb $0x2f, %cl
xorl %edx, %edx
orb %al, %cl
sete %dl
leaq (%rsp,%rdx,2), %rdi
addq $0x1020, %rdi           # imm = 0x1020
callq 0x2380
movq %rax, %rbx
movq 0x8(%rsp), %r13
testq %r13, %r13
je 0x8c3f
movl -0x10(%r13), %eax
cmpl -0xc(%r13), %eax
jge 0x8c3f
incl %eax
movl %eax, -0x10(%r13)
jmp 0x8c54
leaq 0x8(%rsp), %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
callq 0x521e
movq 0x8(%rsp), %r13
movslq -0x10(%r13), %rax
movq %rbx, -0x8(%r13,%rax,8)
movq %r14, %rdi
callq 0x2240
movq %rax, %rbx
testq %rax, %rax
jne 0x8b5e
jmp 0x8c8e
xorl %r13d, %r13d
movq %r13, %rax
addq $0x3028, %rsp           # imm = 0x3028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r13d, %r13d
movq %r14, %rdi
callq 0x21a0
jmp 0x8c76
movq 0x8(%rsp), %r13
jmp 0x8c8e