// File: 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:
subq $0x938, %rsp            # imm = 0x938
movq %rdi, 0x928(%rsp)
movq %rsi, 0x920(%rsp)
movl %edx, 0x91c(%rsp)
movq 0x928(%rsp), %rdi
callq 0x2100
movl %eax, 0x508(%rsp)
movq $0x0, 0x4f0(%rsp)
movq $0x0, 0x4e8(%rsp)
cmpl $0x0, 0x91c(%rsp)
jne 0x10055
movq $0x0, 0x930(%rsp)
jmp 0x108b2
movl $0x0, 0x50c(%rsp)
movl 0x50c(%rsp), %eax
cmpl 0x91c(%rsp), %eax
jge 0x101d3
movq 0x928(%rsp), %rdi
movl 0x508(%rsp), %esi
movq 0x920(%rsp), %rax
movslq 0x50c(%rsp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0xff60
cmpl $0x0, %eax
je 0x101bb
movq 0x920(%rsp), %rax
movslq 0x50c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0xc0(%rsp)
cmpq $0x0, 0x4f0(%rsp)
je 0x100e0
movq 0x4f0(%rsp), %rax
movl -0x10(%rax), %eax
movl %eax, 0xbc(%rsp)
jmp 0x100eb
xorl %eax, %eax
movl %eax, 0xbc(%rsp)
jmp 0x100eb
movl 0xbc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xb8(%rsp)
cmpq $0x0, 0x4f0(%rsp)
je 0x1011b
movq 0x4f0(%rsp), %rax
movl -0xc(%rax), %eax
movl %eax, 0xb4(%rsp)
jmp 0x10126
xorl %eax, %eax
movl %eax, 0xb4(%rsp)
jmp 0x10126
movl 0xb8(%rsp), %eax
movl 0xb4(%rsp), %ecx
cmpl %ecx, %eax
jle 0x10151
leaq 0x4f0(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x8030
jmp 0x10162
movq 0x4f0(%rsp), %rax
movl -0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, -0x10(%rax)
movq 0x4f0(%rsp), %rax
movq %rax, 0xa8(%rsp)
cmpq $0x0, 0x4f0(%rsp)
je 0x10191
movq 0x4f0(%rsp), %rax
movl -0x10(%rax), %eax
movl %eax, 0xa4(%rsp)
jmp 0x1019c
xorl %eax, %eax
movl %eax, 0xa4(%rsp)
jmp 0x1019c
movq 0xa8(%rsp), %rax
movq 0xc0(%rsp), %rdx
movl 0xa4(%rsp), %ecx
movslq %ecx, %rcx
movq %rdx, -0x8(%rax,%rcx,8)
jmp 0x101bd
movl 0x50c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50c(%rsp)
jmp 0x10060
cmpq $0x0, 0x4f0(%rsp)
jne 0x101ef
movq $0x0, 0x930(%rsp)
jmp 0x108b2
movl 0x508(%rsp), %eax
movl %eax, 0x504(%rsp)
cmpl $0x0, 0x504(%rsp)
jne 0x10240
movq 0x4f0(%rsp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
je 0x1022d
movq 0x4f0(%rsp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x5c, %eax
jne 0x10240
movl 0x504(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x504(%rsp)
jmp 0x1025d
cmpl $0x0, 0x504(%rsp)
je 0x1025b
movl 0x504(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x504(%rsp)
jmp 0x1025d
movl $0x0, 0x50c(%rsp)
movl 0x50c(%rsp), %eax
movl %eax, 0xa0(%rsp)
cmpq $0x0, 0x4f0(%rsp)
je 0x10295
movq 0x4f0(%rsp), %rax
movl -0x10(%rax), %eax
movl %eax, 0x9c(%rsp)
jmp 0x102a0
xorl %eax, %eax
movl %eax, 0x9c(%rsp)
jmp 0x102a0
movl 0xa0(%rsp), %eax
movl 0x9c(%rsp), %ecx
cmpl %ecx, %eax
jge 0x10476
movq 0x4f0(%rsp), %rax
movslq 0x50c(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movslq 0x504(%rsp), %rax
addq %rax, %rdi
movl $0x2f, %esi
movl $0x5c, %edx
callq 0x5420
cmpq $0x0, %rax
jne 0x10460
movq 0x4f0(%rsp), %rax
movslq 0x50c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x90(%rsp)
cmpq $0x0, 0x4e8(%rsp)
je 0x10329
movq 0x4e8(%rsp), %rax
movl -0x10(%rax), %eax
movl %eax, 0x8c(%rsp)
jmp 0x10334
xorl %eax, %eax
movl %eax, 0x8c(%rsp)
jmp 0x10334
movl 0x8c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x88(%rsp)
cmpq $0x0, 0x4e8(%rsp)
je 0x10364
movq 0x4e8(%rsp), %rax
movl -0xc(%rax), %eax
movl %eax, 0x84(%rsp)
jmp 0x1036f
xorl %eax, %eax
movl %eax, 0x84(%rsp)
jmp 0x1036f
movl 0x88(%rsp), %eax
movl 0x84(%rsp), %ecx
cmpl %ecx, %eax
jle 0x1039a
leaq 0x4e8(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x8030
jmp 0x103ab
movq 0x4e8(%rsp), %rax
movl -0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, -0x10(%rax)
movq 0x4e8(%rsp), %rax
movq %rax, 0x78(%rsp)
cmpq $0x0, 0x4e8(%rsp)
je 0x103d4
movq 0x4e8(%rsp), %rax
movl -0x10(%rax), %eax
movl %eax, 0x74(%rsp)
jmp 0x103dc
xorl %eax, %eax
movl %eax, 0x74(%rsp)
jmp 0x103dc
movq 0x78(%rsp), %rax
movq 0x90(%rsp), %rdx
movl 0x74(%rsp), %ecx
movslq %ecx, %rcx
movq %rdx, -0x8(%rax,%rcx,8)
movq 0x4f0(%rsp), %rax
movq %rax, 0x68(%rsp)
cmpq $0x0, 0x4f0(%rsp)
je 0x1041e
movq 0x4f0(%rsp), %rax
movl -0x10(%rax), %eax
movl %eax, 0x64(%rsp)
jmp 0x10426
xorl %eax, %eax
movl %eax, 0x64(%rsp)
jmp 0x10426
movq 0x68(%rsp), %rax
movl 0x64(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
movq 0x4f0(%rsp), %rax
movslq 0x50c(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x4f0(%rsp), %rax
movl -0x10(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, -0x10(%rax)
jmp 0x10471
movl 0x50c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50c(%rsp)
jmp 0x10268
movl $0x28, %edi
callq 0x2260
movq %rax, 0x4f8(%rsp)
movq 0x4e8(%rsp), %rcx
movq 0x4f8(%rsp), %rax
movq %rcx, 0x20(%rax)
movq 0x4f8(%rsp), %rax
movq $0x0, (%rax)
movq 0x928(%rsp), %rdi
callq 0x2390
movq %rax, %rcx
movq 0x4f8(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x4f8(%rsp), %rax
movq 0x10(%rax), %rdi
movl $0x2f, %esi
movl $0x5c, %edx
callq 0x5490
movq %rax, 0x4e0(%rsp)
cmpq $0x0, 0x4e0(%rsp)
je 0x1050b
movq 0x4e0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x4e0(%rsp)
jmp 0x1051f
movq 0x4f8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x4e0(%rsp)
movq 0x4e0(%rsp), %rcx
movq 0x4f8(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x4f0(%rsp), %rax
movq %rax, 0x58(%rsp)
cmpq $0x0, 0x4f0(%rsp)
je 0x1055c
movq 0x4f0(%rsp), %rax
movl -0x10(%rax), %eax
movl %eax, 0x54(%rsp)
jmp 0x10564
xorl %eax, %eax
movl %eax, 0x54(%rsp)
jmp 0x10564
movl 0x54(%rsp), %eax
cltq
movq %rax, 0x48(%rsp)
xorl %edi, %edi
callq 0x4b40
movq 0x58(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq %rax, %rcx
movl $0x8, %edx
callq 0x20a0
movb $0x0, 0x510(%rsp)
movl $0x0, 0x50c(%rsp)
movl 0x50c(%rsp), %eax
movl %eax, 0x44(%rsp)
cmpq $0x0, 0x4f0(%rsp)
je 0x105c7
movq 0x4f0(%rsp), %rax
movl -0x10(%rax), %eax
movl %eax, 0x40(%rsp)
jmp 0x105cf
xorl %eax, %eax
movl %eax, 0x40(%rsp)
jmp 0x105cf
movl 0x44(%rsp), %eax
movl 0x40(%rsp), %ecx
cmpl %ecx, %eax
jge 0x1085c
movq 0x4f0(%rsp), %rax
movslq 0x50c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x504(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0xd8(%rsp)
movq 0xd8(%rsp), %rdi
movl $0x2f, %esi
movl $0x5c, %edx
callq 0x5420
movq %rax, 0xd0(%rsp)
cmpq $0x0, 0xd0(%rsp)
je 0x10632
jmp 0x10651
leaq 0xf3fc(%rip), %rdi      # 0x1fa35
leaq 0xed49(%rip), %rsi      # 0x1f389
movl $0x1824, %edx           # imm = 0x1824
leaq 0xf114(%rip), %rcx      # 0x1f760
callq 0x2140
leaq 0xe0(%rsp), %rdi
movq 0x4f0(%rsp), %rax
movslq 0x50c(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
movq 0xd0(%rsp), %rax
movq 0x4f0(%rsp), %rcx
movslq 0x50c(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
subq %rcx, %rax
addq $0x1, %rax
movl %eax, %edx
callq 0x52c0
leaq 0x510(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x2030
cmpl $0x0, %eax
je 0x10844
leaq 0xe0(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x4f0(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x4f0(%rsp)
je 0x106eb
movq 0x4f0(%rsp), %rax
movl -0x10(%rax), %eax
movl %eax, 0x2c(%rsp)
jmp 0x106f3
xorl %eax, %eax
movl %eax, 0x2c(%rsp)
jmp 0x106f3
movq 0x38(%rsp), %rsi
movq 0x30(%rsp), %rdi
movl 0x2c(%rsp), %edx
callq 0xfff0
movq %rax, 0xc8(%rsp)
cmpq $0x0, 0xc8(%rsp)
je 0x1071b
jmp 0x1073a
leaq 0xf083(%rip), %rdi      # 0x1f7a5
leaq 0xec60(%rip), %rsi      # 0x1f389
movl $0x1828, %edx           # imm = 0x1828
leaq 0xf02b(%rip), %rcx      # 0x1f760
callq 0x2140
leaq 0x510(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x2070
movq 0xc8(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x4f8(%rsp), %rax
cmpq $0x0, (%rax)
je 0x1077e
movq 0x4f8(%rsp), %rax
movq (%rax), %rax
movl -0x10(%rax), %eax
movl %eax, 0x1c(%rsp)
jmp 0x10786
xorl %eax, %eax
movl %eax, 0x1c(%rsp)
jmp 0x10786
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
movq 0x4f8(%rsp), %rax
cmpq $0x0, (%rax)
je 0x107b3
movq 0x4f8(%rsp), %rax
movq (%rax), %rax
movl -0xc(%rax), %eax
movl %eax, 0x14(%rsp)
jmp 0x107bb
xorl %eax, %eax
movl %eax, 0x14(%rsp)
jmp 0x107bb
movl 0x18(%rsp), %eax
movl 0x14(%rsp), %ecx
cmpl %ecx, %eax
jle 0x107e0
movq 0x4f8(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x8030
jmp 0x107f4
movq 0x4f8(%rsp), %rax
movq (%rax), %rax
movl -0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, -0x10(%rax)
movq 0x4f8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x4f8(%rsp), %rax
cmpq $0x0, (%rax)
je 0x10826
movq 0x4f8(%rsp), %rax
movq (%rax), %rax
movl -0x10(%rax), %eax
movl %eax, 0x4(%rsp)
jmp 0x1082e
xorl %eax, %eax
movl %eax, 0x4(%rsp)
jmp 0x1082e
movq 0x8(%rsp), %rax
movq 0x20(%rsp), %rdx
movl 0x4(%rsp), %ecx
movslq %ecx, %rcx
movq %rdx, -0x8(%rax,%rcx,8)
jmp 0x10846
movl 0x50c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50c(%rsp)
jmp 0x105a0
movq 0x4f8(%rsp), %rax
cmpq $0x0, (%rax)
je 0x1087d
movq 0x4f8(%rsp), %rax
movq (%rax), %rax
movl -0x10(%rax), %eax
movl %eax, (%rsp)
jmp 0x10884
xorl %eax, %eax
movl %eax, (%rsp)
jmp 0x10884
movl (%rsp), %ecx
movq 0x4f8(%rsp), %rax
movl %ecx, 0x8(%rax)
movq 0x4f8(%rsp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0xc(%rax)
movq 0x4f8(%rsp), %rax
movq %rax, 0x930(%rsp)
movq 0x930(%rsp), %rax
addq $0x938, %rsp            # imm = 0x938
retq
nopw %cs:(%rax,%rax)