// File: /workspace/github_cpp_makefile_star2_O2/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, %r13d
movq %rsi, 0x18(%rsp)
movq %rdi, 0x8(%rsp)
callq 0x2100
andq $0x0, 0x10(%rsp)
andq $0x0, (%rsp)
xorl %r14d, %r14d
testl %r13d, %r13d
je 0x9159
movq %rax, %r12
cmovlel %r14d, %r13d
xorl %ebx, %ebx
xorl %ebp, %ebp
cmpq %rbp, %r13
je 0x8f77
movq 0x18(%rsp), %rax
movq (%rax,%rbp,8), %r15
movq 0x8(%rsp), %rdi
movl %r12d, %esi
movq %r15, %rdx
callq 0x8e8d
testl %eax, %eax
je 0x8f72
testq %rbx, %rbx
je 0x8f48
movl -0x10(%rbx), %eax
cmpl -0xc(%rbx), %eax
jge 0x8f48
incl %eax
movl %eax, -0x10(%rbx)
jmp 0x8f5d
leaq 0x10(%rsp), %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
callq 0x521e
movq 0x10(%rsp), %r14
testq %r14, %r14
je 0x8f68
movslq -0x10(%r14), %rax
jmp 0x8f6a
xorl %eax, %eax
movq %r15, -0x8(%r14,%rax,8)
movq %r14, %rbx
incq %rbp
jmp 0x8f12
testq %rbx, %rbx
je 0x8f8b
testl %r12d, %r12d
je 0x8f93
leal 0x1(%r12), %eax
movslq %eax, %r15
jmp 0x8fa8
xorl %r14d, %r14d
jmp 0x9159
movq (%rbx), %rax
movb (%rax), %al
cmpb $0x2f, %al
sete %cl
cmpb $0x5c, %al
sete %al
orb %cl, %al
movzbl %al, %r15d
movl -0x10(%rbx), %r12d
xorl %r13d, %r13d
pushq $0x5c
popq %r14
movslq %r13d, %r13
cmpl %r12d, %r13d
jge 0x9022
movq (%rbx,%r13,8), %rbp
leaq (%r15,%rbp), %rdi
pushq $0x2f
popq %rsi
movl %r14d, %edx
callq 0x3cd9
testq %rax, %rax
je 0x8fd8
incq %r13
jmp 0x8fb6
movq (%rsp), %rax
testq %rax, %rax
je 0x8ff0
movl -0x10(%rax), %ecx
cmpl -0xc(%rax), %ecx
jge 0x8ff0
incl %ecx
movl %ecx, -0x10(%rax)
jmp 0x9002
movq %rsp, %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
callq 0x521e
movq (%rsp), %rax
movslq -0x10(%rax), %rcx
movq %rbp, -0x8(%rax,%rcx,8)
movslq -0x10(%rbx), %rax
movq -0x8(%rbx,%rax,8), %rcx
movq %rcx, (%rbx,%r13,8)
leal -0x1(%rax), %r12d
movl %r12d, -0x10(%rbx)
jmp 0x8fb3
pushq $0x28
popq %rdi
callq 0x2250
movq %rax, %r14
movq (%rsp), %rax
movq %rax, 0x20(%r14)
andq $0x0, (%r14)
movq 0x8(%rsp), %rdi
callq 0x2380
movq %rax, %r13
movq %rax, 0x10(%r14)
pushq $0x2f
popq %rsi
pushq $0x5c
popq %rdx
movq %rax, %rdi
callq 0x3cf3
leaq 0x1(%rax), %rcx
testq %rax, %rax
cmoveq %r13, %rcx
movq %rcx, 0x18(%r14)
movslq %r12d, %rsi
andl $0x0, 0x12a9b(%rip)     # 0x1bb0c
leaq -0x57ea(%rip), %rcx     # 0x388e
pushq $0x8
popq %rdx
movq %rbx, %rdi
callq 0x20a0
leaq 0x20(%rsp), %rax
movb $0x0, (%rax)
xorl %r12d, %r12d
leaq 0x420(%rsp), %r13
movslq -0x10(%rbx), %rax
cmpq %rax, %r12
jge 0x9141
movq (%rbx,%r12,8), %rbp
leaq (%r15,%rbp), %rdi
pushq $0x2f
popq %rsi
pushq $0x5c
popq %rdx
callq 0x3cd9
testq %rax, %rax
je 0x916e
subl %ebp, %eax
incl %eax
movq %r13, %rdi
movq %rbp, %rsi
movl %eax, %edx
callq 0x3c14
leaq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0x2040
testl %eax, %eax
je 0x9139
movl -0x10(%rbx), %edx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x8ecd
testq %rax, %rax
je 0x918d
movq %rax, %rbp
leaq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0x2080
movq (%r14), %rax
testq %rax, %rax
je 0x911f
movl -0x10(%rax), %ecx
cmpl -0xc(%rax), %ecx
jge 0x911f
incl %ecx
movl %ecx, -0x10(%rax)
jmp 0x9130
movq %r14, %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
callq 0x521e
movq (%r14), %rax
movslq -0x10(%rax), %rcx
movq %rbp, -0x8(%rax,%rcx,8)
incq %r12
jmp 0x9096
movq (%r14), %rax
testq %rax, %rax
je 0x914e
movl -0x10(%rax), %eax
jmp 0x9150
xorl %eax, %eax
movl %eax, 0x8(%r14)
andl $0x0, 0xc(%r14)
movq %r14, %rax
addq $0x828, %rsp            # imm = 0x828
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x793a(%rip), %rdi      # 0x10aaf
leaq 0x72a5(%rip), %rsi      # 0x10421
leaq 0x7675(%rip), %rcx      # 0x107f8
movl $0x1824, %edx           # imm = 0x1824
callq 0x2140
leaq 0x76a9(%rip), %rdi      # 0x1083d
leaq 0x7286(%rip), %rsi      # 0x10421
leaq 0x7656(%rip), %rcx      # 0x107f8
movl $0x1828, %edx           # imm = 0x1828
callq 0x2140