// File: attractivechaos[P]udb2/stb/./stb.h
// Function: stb_cfg_open
STB_EXTERN stb_cfg * stb_cfg_open(char *config, char *mode)
{
   size_t len;
   stb_cfg *z;
   char file[512];
   if (mode[0] != 'r' && mode[0] != 'w') return NULL;

   if (!stb__cfg_dir[0]) {
      #ifdef _WIN32
      strcpy(stb__cfg_dir, "c:/stb");
      #else
      strcpy(stb__cfg_dir, "~/.stbconfig");
      #endif

      #ifdef STB_HAS_REGISTRY
      {
         void *reg = stb_reg_open("rHKLM", "Software\\SilverSpaceship\\stb");
         if (reg) {
            stb_reg_read_string(reg, "config_dir", stb__cfg_dir, sizeof(stb__cfg_dir));
            stb_reg_close(reg);
         }
      }
      #endif
   }

   sprintf(file, "%s/%s.cfg", stb__cfg_dir, config);

   z = (stb_cfg *) stb_malloc(0, sizeof(*z));
   z->data = NULL;

   z->loaded_file = stb_filec(file, &len);
   if (z->loaded_file) {
      char *s = z->loaded_file;
      if (!memcmp(s, stb__cfg_sig, 12)) {
         char *s = z->loaded_file + 12;
         while (s < z->loaded_file + len) {
            stb__cfg_item a;
            int n = *(stb_int16 *) s;
            a.key = s+2;
            s = s+2 + n;
            a.value_len = *(int *) s;
            s += 4;
            a.value = s;
            s += a.value_len;
            stb_arr_push(z->data, a);
         }
         assert(s == z->loaded_file + len);
      }
   }

   if (mode[0] == 'w')
      z->f = fopen(file, "wb");
   else
      z->f = NULL;

   return z;
}

// Assembly:
subq $0x278, %rsp            # imm = 0x278
movq %rdi, 0x268(%rsp)
movq %rsi, 0x260(%rsp)
movq 0x260(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x72, %eax
je 0x116f8
movq 0x260(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x77, %eax
je 0x116f8
movq $0x0, 0x270(%rsp)
jmp 0x119f7
cmpb $0x0, 0x18df1(%rip)     # 0x2a4f0
jne 0x11714
leaq 0x18de8(%rip), %rdi     # 0x2a4f0
leaq 0xe180(%rip), %rsi      # 0x1f88f
callq 0x2070
leaq 0x50(%rsp), %rdi
movq 0x268(%rsp), %rcx
leaq 0xe174(%rip), %rsi      # 0x1f89c
leaq 0x18dc1(%rip), %rdx     # 0x2a4f0
movb $0x0, %al
callq 0x2350
xorl %eax, %eax
movl %eax, %edi
movl $0x18, %esi
callq 0x75b0
movq %rax, 0x250(%rsp)
movq 0x250(%rsp), %rax
movq $0x0, (%rax)
leaq 0x50(%rsp), %rdi
leaq 0x258(%rsp), %rsi
callq 0xd160
movq %rax, %rcx
movq 0x250(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0x250(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x119a5
movq 0x250(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rdi
movq 0x14bcc(%rip), %rsi     # 0x26378
movl $0xc, %edx
callq 0x21c0
cmpl $0x0, %eax
jne 0x119a3
movq 0x250(%rsp), %rax
movq 0x8(%rax), %rax
addq $0xc, %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq 0x250(%rsp), %rcx
movq 0x8(%rcx), %rcx
addq 0x258(%rsp), %rcx
cmpq %rcx, %rax
jae 0x11962
movq 0x40(%rsp), %rax
movswl (%rax), %eax
movl %eax, 0x24(%rsp)
movq 0x40(%rsp), %rax
addq $0x2, %rax
movq %rax, 0x28(%rsp)
movq 0x40(%rsp), %rax
addq $0x2, %rax
movslq 0x24(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x38(%rsp)
movq 0x40(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movl 0x38(%rsp), %ecx
movq 0x40(%rsp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x40(%rsp)
movq 0x250(%rsp), %rax
cmpq $0x0, (%rax)
je 0x1187f
movq 0x250(%rsp), %rax
movq (%rax), %rax
movl -0x10(%rax), %eax
movl %eax, 0x20(%rsp)
jmp 0x11887
xorl %eax, %eax
movl %eax, 0x20(%rsp)
jmp 0x11887
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
movq 0x250(%rsp), %rax
cmpq $0x0, (%rax)
je 0x118b4
movq 0x250(%rsp), %rax
movq (%rax), %rax
movl -0xc(%rax), %eax
movl %eax, 0x18(%rsp)
jmp 0x118bc
xorl %eax, %eax
movl %eax, 0x18(%rsp)
jmp 0x118bc
movl 0x1c(%rsp), %eax
movl 0x18(%rsp), %ecx
cmpl %ecx, %eax
jle 0x118e1
movq 0x250(%rsp), %rdi
movl $0x18, %esi
movl $0x1, %edx
callq 0x8030
jmp 0x118f5
movq 0x250(%rsp), %rax
movq (%rax), %rax
movl -0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, -0x10(%rax)
movq 0x250(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x250(%rsp), %rax
cmpq $0x0, (%rax)
je 0x11927
movq 0x250(%rsp), %rax
movq (%rax), %rax
movl -0x10(%rax), %eax
movl %eax, 0xc(%rsp)
jmp 0x1192f
xorl %eax, %eax
movl %eax, 0xc(%rsp)
jmp 0x1192f
movq 0x10(%rsp), %rax
movl 0xc(%rsp), %ecx
movslq %ecx, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x28(%rsp), %rcx
movq %rcx, -0x18(%rax)
movq 0x30(%rsp), %rcx
movq %rcx, -0x10(%rax)
movq 0x38(%rsp), %rcx
movq %rcx, -0x8(%rax)
jmp 0x117d4
movq 0x40(%rsp), %rax
movq 0x250(%rsp), %rcx
movq 0x8(%rcx), %rcx
addq 0x258(%rsp), %rcx
cmpq %rcx, %rax
jne 0x11982
jmp 0x119a1
leaq 0xdf1d(%rip), %rdi      # 0x1f8a6
leaq 0xd9f9(%rip), %rsi      # 0x1f389
movl $0x1a14, %edx           # imm = 0x1A14
leaq 0xdf24(%rip), %rcx      # 0x1f8c0
callq 0x2140
jmp 0x119a3
jmp 0x119a5
movq 0x260(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x77, %eax
jne 0x119d7
leaq 0x50(%rsp), %rdi
leaq 0xdd16(%rip), %rsi      # 0x1f6d7
callq 0x22f0
movq %rax, %rcx
movq 0x250(%rsp), %rax
movq %rcx, 0x10(%rax)
jmp 0x119e7
movq 0x250(%rsp), %rax
movq $0x0, 0x10(%rax)
movq 0x250(%rsp), %rax
movq %rax, 0x270(%rsp)
movq 0x270(%rsp), %rax
addq $0x278, %rsp            # imm = 0x278
retq
nopw (%rax,%rax)