// File: /workspace/github_cpp_makefile_star2_O3/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 $0x848, %rsp            # imm = 0x848
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, 0x8(%rsp)
callq 0x2100
movq %rax, %r12
xorl %eax, %eax
movq %rax, 0x30(%rsp)
movq %rax, 0x20(%rsp)
testl %ebp, %ebp
jle 0xa0d5
movl %ebp, %ebx
xorl %ebp, %ebp
xorl %r15d, %r15d
movq (%r14,%r15,8), %r13
movq 0x8(%rsp), %rdi
movl %r12d, %esi
movq %r13, %rdx
callq 0x9d14
testl %eax, %eax
je 0x9deb
testq %rbp, %rbp
je 0x9dc0
movl -0x10(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x9dc0
incl %eax
movl %eax, -0x10(%rbp)
jmp 0x9dd9
leaq 0x30(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x56ce
movq 0x30(%rsp), %rbp
testq %rbp, %rbp
je 0x9de4
movslq -0x10(%rbp), %rax
jmp 0x9de6
xorl %eax, %eax
movq %r13, -0x8(%rbp,%rax,8)
incq %r15
cmpq %r15, %rbx
jne 0x9d94
movq 0x30(%rsp), %r14
testq %r14, %r14
je 0x9e19
movabsq $0x100000000, %r15      # imm = 0x100000000
testl %r12d, %r12d
je 0x9e20
shlq $0x20, %r12
addq %r15, %r12
sarq $0x20, %r12
jmp 0x9e35
xorl %eax, %eax
jmp 0xa0d5
movq (%r14), %rax
movb (%rax), %al
cmpb $0x2f, %al
sete %cl
cmpb $0x5c, %al
sete %al
orb %cl, %al
movzbl %al, %r12d
movl -0x10(%r14), %ebx
testl %ebx, %ebx
movq %r12, 0x18(%rsp)
jle 0x9ee2
leaq 0x1(%r12), %rax
movq %rax, 0x28(%rsp)
xorl %r13d, %r13d
movslq %r13d, %rbp
movq (%r14,%rbp,8), %r12
movq 0x18(%rsp), %rax
movb (%r12,%rax), %cl
testb %cl, %cl
je 0x9e85
movq 0x28(%rsp), %rax
addq %r12, %rax
cmpb $0x2f, %cl
je 0x9e9e
movzbl %cl, %ecx
cmpl $0x5c, %ecx
je 0x9e9e
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x9e6f
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x9ea3
movl -0x10(%rax), %ecx
cmpl -0xc(%rax), %ecx
jge 0x9ea3
incl %ecx
movl %ecx, -0x10(%rax)
jmp 0x9ebc
incl %r13d
jmp 0x9ed9
leaq 0x20(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x56ce
movq 0x20(%rsp), %rax
movslq -0x10(%rax), %rcx
movq %r12, -0x8(%rax,%rcx,8)
movslq -0x10(%r14), %rax
movq -0x8(%r14,%rax,8), %rcx
movq %rcx, (%r14,%rbp,8)
leal -0x1(%rax), %ebx
movl %ebx, -0x10(%r14)
cmpl %ebx, %r13d
jl 0x9e53
movl $0x28, %edi
callq 0x2250
movq %rax, %r12
movq 0x20(%rsp), %rax
movq %rax, 0x20(%r12)
movq $0x0, (%r12)
movq 0x8(%rsp), %rdi
callq 0x2380
movq %r12, 0x10(%rsp)
movq %rax, 0x10(%r12)
movb (%rax), %dl
testb %dl, %dl
je 0x9f4a
xorl %ecx, %ecx
movq %rax, %rsi
movq 0x18(%rsp), %r12
cmpb $0x5c, %dl
cmoveq %rsi, %rcx
cmpb $0x2f, %dl
cmoveq %rsi, %rcx
movb 0x1(%rsi), %dl
incq %rsi
testb %dl, %dl
jne 0x9f25
leaq 0x1(%rcx), %rdx
testq %rcx, %rcx
cmovneq %rdx, %rax
jmp 0x9f4f
movq 0x18(%rsp), %r12
movq 0x10(%rsp), %rcx
movq %rax, 0x18(%rcx)
movslq %ebx, %rsi
movl $0x0, 0x13ba7(%rip)     # 0x1db0c
leaq -0x64f4(%rip), %rcx     # 0x3a78
movl $0x8, %edx
movq %r14, %rdi
callq 0x20a0
movb $0x0, 0x40(%rsp)
movl -0x10(%r14), %ebp
testl %ebp, %ebp
jle 0xa0c0
movq %r14, 0x8(%rsp)
movq %r12, %rax
shlq $0x20, %rax
addq %r15, %rax
movq %rax, 0x28(%rsp)
leaq 0x1(%r12), %rax
movq %rax, 0x38(%rsp)
xorl %r12d, %r12d
leaq 0x440(%rsp), %r13
xorl %ebx, %ebx
movq 0x8(%rsp), %rax
movq (%rax,%rbx,8), %rsi
movq 0x18(%rsp), %rax
movb (%rsi,%rax), %cl
testb %cl, %cl
je 0xa0e7
movq %r13, %r14
movq 0x38(%rsp), %rax
addq %rsi, %rax
movq 0x28(%rsp), %r13
cmpb $0x2f, %cl
je 0x9ffc
movzbl %cl, %ecx
cmpl $0x5c, %ecx
je 0x9ffc
movb (%rax), %cl
addq %r15, %r13
incq %rax
testb %cl, %cl
jne 0x9fde
jmp 0xa0e7
sarq $0x20, %r13
movq %r14, %rdi
movq %r13, %rdx
callq 0x2060
movb $0x0, 0x43f(%rsp,%r13)
movq %r14, %r13
leaq 0x40(%rsp), %rdi
movq %r14, %rsi
callq 0x2040
testl %eax, %eax
je 0xa09f
movq %r13, %rdi
movq 0x8(%rsp), %r14
movq %r14, %rsi
movl %ebp, %edx
callq 0x9d56
testq %rax, %rax
je 0xa106
movq %rax, %rbp
leaq 0x40(%rsp), %rdi
movq %r13, %rsi
callq 0x2080
testq %r12, %r12
je 0xa06d
movl -0x10(%r12), %eax
cmpl -0xc(%r12), %eax
jge 0xa06d
incl %eax
movl %eax, -0x10(%r12)
jmp 0xa088
movq 0x10(%rsp), %r12
movq %r12, %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x56ce
movq (%r12), %r12
testq %r12, %r12
je 0xa094
movslq -0x10(%r12), %rax
jmp 0xa096
xorl %eax, %eax
movq %rbp, -0x8(%r12,%rax,8)
movl -0x10(%r14), %ebp
incq %rbx
movslq %ebp, %rax
cmpq %rax, %rbx
jl 0x9fb5
movq 0x10(%rsp), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0xa0c9
movl -0x10(%rcx), %ecx
jmp 0xa0cb
xorl %ecx, %ecx
movq 0x10(%rsp), %rax
jmp 0xa0cb
xorl %ecx, %ecx
movl %ecx, 0x8(%rax)
movl $0x0, 0xc(%rax)
addq $0x848, %rsp            # imm = 0x848
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8a51(%rip), %rdi      # 0x12b3f
leaq 0x83bc(%rip), %rsi      # 0x124b1
leaq 0x878c(%rip), %rcx      # 0x12888
movl $0x1824, %edx           # imm = 0x1824
callq 0x2140
leaq 0x87c0(%rip), %rdi      # 0x128cd
leaq 0x839d(%rip), %rsi      # 0x124b1
leaq 0x876d(%rip), %rcx      # 0x12888
movl $0x1828, %edx           # imm = 0x1828
callq 0x2140