// File: /workspace/github_cpp_makefile_star2_O1/attractivechaos[P]udb2/stb/./stb.h
// Function: stb_dirtree2_from_files_relative
stb_dirtree2 *stb_dirtree2_from_files_relative(char *src, char **filelist, int count)
{
   char buffer1[1024];
   int i;
   int dlen = strlen(src), elen;
   stb_dirtree2 *d;
   char ** descendents = NULL;
   char ** files = NULL;
   char *s;
   if (!count) return NULL;
   // first find all the ones that belong here... note this is will take O(NM) with N files and M subdirs
   for (i=0; i < count; ++i) {
      if (stb_dir_is_prefix(src, dlen, filelist[i])) {
         stb_arr_push(descendents, filelist[i]);
      }
   }
   if (descendents == NULL)
      return NULL;
   elen = dlen;
   // skip a leading slash
   if (elen == 0 && (descendents[0][0] == '/' || descendents[0][0] == '\\'))
      ++elen;
   else if (elen)
      ++elen;
   // now extract all the ones that have their root here
   for (i=0; i < stb_arr_len(descendents);) {
      if (!stb_strchr2(descendents[i]+elen, '/', '\\')) {
         stb_arr_push(files, descendents[i]);
         descendents[i] = descendents[stb_arr_len(descendents)-1];
         stb_arr_pop(descendents);
      } else
         ++i;
   }
   // now create a record
   d = (stb_dirtree2 *) malloc(sizeof(*d));
   d->files = files;
   d->subdirs = NULL;
   d->fullpath = strdup(src);
   s = stb_strrchr2(d->fullpath, '/', '\\');
   if (s)
      ++s;
   else
      s = d->fullpath;
   d->relpath = s;
   // now create the children
   qsort(descendents, stb_arr_len(descendents), sizeof(char *), stb_qsort_stricmp(0));
   buffer1[0] = 0;
   for (i=0; i < stb_arr_len(descendents); ++i) {
      char buffer2[1024];
      char *s = descendents[i] + elen, *t;
      t = stb_strchr2(s, '/', '\\');
      assert(t);
      stb_strncpy(buffer2, descendents[i], t-descendents[i]+1);
      if (stb_stricmp(buffer1, buffer2)) {
         stb_dirtree2 *t = stb_dirtree2_from_files_relative(buffer2, descendents, stb_arr_len(descendents));
         assert(t != NULL);
         strcpy(buffer1, buffer2);
         stb_arr_push(d->subdirs, t);
      }
   }
   d->num_subdir = stb_arr_len(d->subdirs);
   d->weight = 0;
   return d;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x828, %rsp            # imm = 0x828
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r12
callq 0x2100
xorl %r15d, %r15d
movq %r15, 0x10(%rsp)
movq %r15, 0x8(%rsp)
testl %ebp, %ebp
je 0xa22a
movq %rax, %rbx
jle 0x9f75
movl %ebp, %ebp
xorl %r15d, %r15d
movq (%r14,%r15,8), %r13
movq %r12, %rdi
movl %ebx, %esi
movq %r13, %rdx
callq 0x9e83
testl %eax, %eax
je 0x9f6d
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x9f28
movl -0x10(%rax), %ecx
incl %ecx
jmp 0x9f2d
movl $0x1, %ecx
testq %rax, %rax
je 0x9f37
movl -0xc(%rax), %edx
jmp 0x9f39
xorl %edx, %edx
cmpl %edx, %ecx
jle 0x9f53
leaq 0x10(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x57e0
jmp 0x9f56
incl -0x10(%rax)
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x9f66
movslq -0x10(%rax), %rcx
jmp 0x9f68
xorl %ecx, %ecx
movq %r13, -0x8(%rax,%rcx,8)
incq %r15
cmpq %r15, %rbp
jne 0x9f02
movq 0x10(%rsp), %r14
testq %r14, %r14
je 0x9f9a
movabsq $0x100000000, %rax      # imm = 0x100000000
testl %ebx, %ebx
je 0x9fa2
shlq $0x20, %rbx
addq %rax, %rbx
sarq $0x20, %rbx
jmp 0x9fb6
xorl %r15d, %r15d
jmp 0xa22a
movq (%r14), %rax
movb (%rax), %al
cmpb $0x2f, %al
sete %cl
cmpb $0x5c, %al
sete %al
orb %cl, %al
movzbl %al, %ebx
cmpl $0x0, -0x10(%r14)
jle 0xa084
leaq 0x1(%rbx), %rsi
xorl %ebp, %ebp
movq %r14, 0x18(%rsp)
movslq %ebp, %r15
movq (%r14,%r15,8), %r13
movb (%r13,%rbx), %cl
testb %cl, %cl
je 0x9ff6
leaq (%rsi,%r13), %rax
cmpb $0x2f, %cl
je 0xa007
movzbl %cl, %ecx
cmpl $0x5c, %ecx
je 0xa007
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x9fe0
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0xa00b
movl -0x10(%rax), %ecx
incl %ecx
jmp 0xa010
incl %ebp
jmp 0xa07a
movl $0x1, %ecx
testq %rax, %rax
je 0xa01a
movl -0xc(%rax), %edx
jmp 0xa01c
xorl %edx, %edx
cmpl %edx, %ecx
jle 0xa04d
leaq 0x8(%rsp), %rdi
movq %rbx, %r14
movq %r12, %rbx
movq %rsi, %r12
movl $0x8, %esi
movl $0x1, %edx
callq 0x57e0
movq %r12, %rsi
movq %rbx, %r12
movq %r14, %rbx
movq 0x18(%rsp), %r14
jmp 0xa050
incl -0x10(%rax)
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0xa060
movslq -0x10(%rax), %rcx
jmp 0xa062
xorl %ecx, %ecx
movq %r13, -0x8(%rax,%rcx,8)
movslq -0x10(%r14), %rax
movq -0x8(%r14,%rax,8), %rcx
movq %rcx, (%r14,%r15,8)
decl %eax
movl %eax, -0x10(%r14)
cmpl -0x10(%r14), %ebp
jl 0x9fcc
movl $0x28, %edi
callq 0x2250
movq %rax, %r15
movq 0x8(%rsp), %rax
movq %rax, 0x20(%r15)
movq $0x0, (%r15)
movq %r12, %rdi
callq 0x2390
movq %rax, 0x10(%r15)
movb (%rax), %dl
xorl %ecx, %ecx
testb %dl, %dl
je 0xa0d0
movq %rax, %rsi
cmpb $0x5c, %dl
cmoveq %rsi, %rcx
cmpb $0x2f, %dl
cmoveq %rsi, %rcx
movb 0x1(%rsi), %dl
incq %rsi
testb %dl, %dl
jne 0xa0b8
leaq 0x1(%rcx), %rdx
testq %rcx, %rcx
cmoveq %rax, %rdx
movq %rdx, 0x18(%r15)
movslq -0x10(%r14), %rsi
movl $0x0, 0x13a2f(%rip)     # 0x1db1c
leaq -0x6544(%rip), %rcx     # 0x3bb0
movl $0x8, %edx
movq %r14, %rdi
callq 0x20a0
movb $0x0, 0x20(%rsp)
cmpl $0x0, -0x10(%r14)
jle 0xa20f
xorl %r13d, %r13d
leaq 0x420(%rsp), %r12
movq (%r14,%r13,8), %rsi
movb (%rsi,%rbx), %al
testb %al, %al
je 0xa141
leaq (%rsi,%rbx), %rbp
cmpb $0x2f, %al
je 0xa143
movzbl %al, %eax
cmpl $0x5c, %eax
je 0xa143
movb 0x1(%rbp), %al
incq %rbp
testb %al, %al
jne 0xa12b
xorl %ebp, %ebp
testq %rbp, %rbp
je 0xa23f
subl %esi, %ebp
shlq $0x20, %rbp
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %rbp
sarq $0x20, %rbp
movq %r12, %rdi
movq %rbp, %rdx
callq 0x2060
movb $0x0, 0x41f(%rsp,%rbp)
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x2040
testl %eax, %eax
je 0xa1ff
movl -0x10(%r14), %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0x9ec5
testq %rax, %rax
je 0xa25e
movq %rax, %rbp
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x2080
movq (%r15), %rax
testq %rax, %rax
je 0xa1be
movl -0x10(%rax), %ecx
incl %ecx
jmp 0xa1c3
movl $0x1, %ecx
testq %rax, %rax
je 0xa1cd
movl -0xc(%rax), %edx
jmp 0xa1cf
xorl %edx, %edx
cmpl %edx, %ecx
jle 0xa1e7
movq %r15, %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x57e0
jmp 0xa1ea
incl -0x10(%rax)
movq (%r15), %rax
testq %rax, %rax
je 0xa1f8
movslq -0x10(%rax), %rcx
jmp 0xa1fa
xorl %ecx, %ecx
movq %rbp, -0x8(%rax,%rcx,8)
incq %r13
movslq -0x10(%r14), %rax
cmpq %rax, %r13
jl 0xa11c
movq (%r15), %rax
testq %rax, %rax
je 0xa21c
movl -0x10(%rax), %eax
jmp 0xa21e
xorl %eax, %eax
movl %eax, 0x8(%r15)
movl $0x0, 0xc(%r15)
movq %r15, %rax
addq $0x828, %rsp            # imm = 0x828
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8949(%rip), %rdi      # 0x12b8f
leaq 0x82b4(%rip), %rsi      # 0x12501
leaq 0x8684(%rip), %rcx      # 0x128d8
movl $0x1824, %edx           # imm = 0x1824
callq 0x2140
leaq 0x86b8(%rip), %rdi      # 0x1291d
leaq 0x8295(%rip), %rsi      # 0x12501
leaq 0x8665(%rip), %rcx      # 0x128d8
movl $0x1828, %edx           # imm = 0x1828
callq 0x2140