// File: attractivechaos[P]udb2/stb/./stb.h
// Function: stb__splitpath_raw
static char *stb__splitpath_raw(char *buffer, char *path, int flag)
{
   int len=0,x,y, n = (int) strlen(path), f1,f2;
   char *s = stb_strrchr2(path, '/', '\\');
   char *t = strrchr(path, '.');
   if (s && t && t < s) t = NULL;
   if (s) ++s;

   if (flag == STB_EXT_NO_PERIOD)
      flag |= STB_EXT;

   if (!(flag & (STB_PATH | STB_FILE | STB_EXT))) return NULL;

   f1 = s == NULL ? 0 : s-path; // start of filename
   f2 = t == NULL ? n : t-path; // just past end of filename

   if (flag & STB_PATH) {
      x = 0; if (f1 == 0 && flag == STB_PATH) len=2;
   } else if (flag & STB_FILE) {
      x = f1;
   } else {
      x = f2;
      if (flag & STB_EXT_NO_PERIOD)
         if (buffer[x] == '.')
            ++x;
   }

   if (flag & STB_EXT)
      y = n;
   else if (flag & STB_FILE)
      y = f2;
   else
      y = f1;

   if (buffer == NULL) {
      buffer = (char *) malloc(y-x + len + 1);
      if (!buffer) return NULL;
   }

   if (len) { strcpy(buffer, "./"); return buffer; }
   strncpy(buffer, path+x, y-x);
   buffer[y-x] = 0;
   return buffer;
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movl %edx, 0x3c(%rsp)
movl $0x0, 0x38(%rsp)
movq 0x40(%rsp), %rdi
callq 0x2100
movl %eax, 0x2c(%rsp)
movq 0x40(%rsp), %rdi
movl $0x2f, %esi
movl $0x5c, %edx
callq 0x5490
movq %rax, 0x18(%rsp)
movq 0x40(%rsp), %rdi
movl $0x2e, %esi
callq 0x2130
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x18(%rsp)
je 0x6ada
cmpq $0x0, 0x10(%rsp)
je 0x6ada
movq 0x10(%rsp), %rax
cmpq 0x18(%rsp), %rax
jae 0x6ada
movq $0x0, 0x10(%rsp)
cmpq $0x0, 0x18(%rsp)
je 0x6af0
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
cmpl $0x8, 0x3c(%rsp)
jne 0x6b02
movl 0x3c(%rsp), %eax
orl $0x4, %eax
movl %eax, 0x3c(%rsp)
movl 0x3c(%rsp), %eax
andl $0x7, %eax
cmpl $0x0, %eax
jne 0x6b1c
movq $0x0, 0x50(%rsp)
jmp 0x6cc1
cmpq $0x0, 0x18(%rsp)
jne 0x6b2d
xorl %eax, %eax
movq %rax, 0x8(%rsp)
jmp 0x6b3f
movq 0x18(%rsp), %rax
movq 0x40(%rsp), %rcx
subq %rcx, %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
movl %eax, 0x28(%rsp)
cmpq $0x0, 0x10(%rsp)
jne 0x6b5b
movslq 0x2c(%rsp), %rax
movq %rax, (%rsp)
jmp 0x6b6c
movq 0x10(%rsp), %rax
movq 0x40(%rsp), %rcx
subq %rcx, %rax
movq %rax, (%rsp)
movq (%rsp), %rax
movl %eax, 0x24(%rsp)
movl 0x3c(%rsp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x6ba0
movl $0x0, 0x34(%rsp)
cmpl $0x0, 0x28(%rsp)
jne 0x6b9e
cmpl $0x1, 0x3c(%rsp)
jne 0x6b9e
movl $0x2, 0x38(%rsp)
jmp 0x6bee
movl 0x3c(%rsp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x6bb6
movl 0x28(%rsp), %eax
movl %eax, 0x34(%rsp)
jmp 0x6bec
movl 0x24(%rsp), %eax
movl %eax, 0x34(%rsp)
movl 0x3c(%rsp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x6bea
movq 0x48(%rsp), %rax
movslq 0x34(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2e, %eax
jne 0x6be8
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x6bea
jmp 0x6bec
jmp 0x6bee
movl 0x3c(%rsp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x6c04
movl 0x2c(%rsp), %eax
movl %eax, 0x30(%rsp)
jmp 0x6c24
movl 0x3c(%rsp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x6c1a
movl 0x24(%rsp), %eax
movl %eax, 0x30(%rsp)
jmp 0x6c22
movl 0x28(%rsp), %eax
movl %eax, 0x30(%rsp)
jmp 0x6c24
cmpq $0x0, 0x48(%rsp)
jne 0x6c5d
movl 0x30(%rsp), %eax
subl 0x34(%rsp), %eax
addl 0x38(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rdi
callq 0x2260
movq %rax, 0x48(%rsp)
cmpq $0x0, 0x48(%rsp)
jne 0x6c5b
movq $0x0, 0x50(%rsp)
jmp 0x6cc1
jmp 0x6c5d
cmpl $0x0, 0x38(%rsp)
je 0x6c81
movq 0x48(%rsp), %rdi
leaq 0x19222(%rip), %rsi     # 0x1fe92
callq 0x2070
movq 0x48(%rsp), %rax
movq %rax, 0x50(%rsp)
jmp 0x6cc1
movq 0x48(%rsp), %rdi
movq 0x40(%rsp), %rsi
movslq 0x34(%rsp), %rax
addq %rax, %rsi
movl 0x30(%rsp), %eax
subl 0x34(%rsp), %eax
movslq %eax, %rdx
callq 0x2050
movq 0x48(%rsp), %rax
movl 0x30(%rsp), %ecx
subl 0x34(%rsp), %ecx
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
movq 0x48(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
addq $0x58, %rsp
retq
nopl (%rax,%rax)