decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
FILE *v4; // rdi
__int64 v5; // rbp
const char *v6; // rdi
FILE *v7; // r12
__int64 v8; // rbx
__int64 v9; // rax

if ( argc <= 1 )
{
printf("%s", USAGE);
}
else
{
v4 = fopen(argv[1], "r");
if ( v4 )
{
v5 = vm_machine_ascii(v4);
vm_machine_print(v5);
if ( argc == 2 )
v6 = "a.vmc";
else
v6 = (const char *)(argv + 2);
v7 = fopen(v6, "w");
fwrite(&VMMajorVersion, 1uLL, 4uLL, v7);
fwrite(&VMMinorVersion, 1uLL, 4uLL, v7);
if ( *(int *)(v5 + 16) >= 0 )
{
v8 = 0LL;
do
{
v9 = *(_QWORD *)(v5 + 8) + 16 * v8++;
fwrite(*(const void **)(v9 + 8), 1uLL, 0x1CuLL, v7);
}
while ( *(_DWORD *)(v5 + 16) >= (int)v8 );
}
fflush(v7);
fclose(v7);
vm_machine_delete(v5);
}
else
{
printf("ERROR - BAD FILE : %s\n", *argv);
}
}
return 0;
}

original_code:
int main(int argc, char **argv) {
    VMachine* turing;
    if((argc >= 2) && (strcmp("-?", argv[1]) == 0)) {
        printf("%s\n", USAGE);
    }
    else if ((argc >= 3) && (strcmp("--ascii", argv[1]) == 0)) {
        turing = vm_machine_ascii(fopen(argv[2], "r"));
    }
    else if (argc > 1) {
        printf(".VMC MODE....\n");
        turing = vm_machine_binary(fopen(argv[1], "r"));
    }
    else {
        printf("INTERACTIVE MODE....\n");
        turing = vm_machine_ascii(stdin);
        printf("TRYING TO PRINT MACHINE...\n");
        vm_machine_print(turing);
        printf("EVALUATING.....\n");
    }
    vm_machine_run(turing);
    return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
    struct VMachine *turing;
    if((argc >= 2) && (strcmp("-?", argv[1]) == 0)) {
        printf("%s\n", USAGE);
    }
    else if ((argc >= 3) && (strcmp("--ascii", argv[1]) == 0)) {
        turing = vm_machine_ascii(fopen(argv[2], "r"));
    }
    else if (argc > 1) {
        printf(".VMC MODE....\n");
        turing = vm_machine_binary(fopen(argv[1], "r"));
    }
    else {
        printf("INTERACTIVE MODE....\n");
        turing = vm_machine_ascii(stdin);
        printf("TRYING TO PRINT MACHINE...\n");
        vm_machine_print(turing);
        printf("EVALUATING.....\n");
    }
    vm_machine_run(turing);
    return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct VMachine { struct VMRam { struct VMBlock { int ptr; int type; int used; } *regs; int size; int used; } *memory; struct VMLine { char *text; int *code; } *code; int lines; struct ll { void *next; void *data; } *threads; int threadcount; char *errmsg; int errcode; } *

user_defined_types: struct VMachine { struct VMRam *memory; struct VMLine *code; int lines; struct ll *threads; int threadcount; char *errmsg; int errcode; }


repo: arrdem/SimpleVM

decompiled_code:
__int64 __fastcall ll_search(__int64 a1, __int64 a2)
{
return (unsigned int)-(*(_QWORD *)(a1 + 8) != a2);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
return (unsigned int)-(*(_QWORD *)(a1 + 8) != a2);
}

original_code:
int ll_search(ll* o, void* d) {
    int i = 0;
    ll* c;
    c = o;
    while((c != o) && (c->data != d) && (c->next)) {
        c = c->next;
        i++;
    }
    if(c->data == d) return i;
    else return -1;
}

canonical_original_code:
int ll_search(struct ll *o, void *d) {
    int i = 0;
    struct ll *c;
    c = o;
    while((c != o) && (c->data != d) && (c->next)) {
        c = c->next;
        i++;
    }
    if(c->data == d) return i;
    else return -1;
}

variable_types:
o
struct ll { void *next; void *data; } *

variable_types:
d
void *

variable_types: i int

variable_types:
c
struct ll { void *next; void *data; } *

return_type: int


decompiled_code:
__int64 __fastcall ll_c_delete_node(_QWORD **a1, __int64 a2)
{
_QWORD *v3; // rdi
_QWORD *v4; // r8
__int64 v5; // rax
__int64 v6; // rdx

v3 = *a1;
v4 = a1;
while ( 1 )
{
v6 = v3[1];
if ( v3 == a1 )
break;
v5 = *v3;
if ( !*v3 )
break;
if ( a2 == v6 )
goto LABEL_9;
v4 = v3;
v3 = (_QWORD *)*v3;
}
if ( a2 != v6 )
return 0xFFFFFFFFLL;
v5 = *v3;
LABEL_9:
*v4 = v5;
free(v3);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD **a1, __int64 a2)
{
_QWORD *v3; // rdi
_QWORD *v4; // r8
__int64 v5; // rax
__int64 v6; // rdx

v3 = *a1;
v4 = a1;
while ( 1 )
{
v6 = v3[1];
if ( v3 == a1 )
break;
v5 = *v3;
if ( !*v3 )
break;
if ( a2 == v6 )
goto LABEL_9;
v4 = v3;
v3 = (_QWORD *)*v3;
}
if ( a2 != v6 )
return 0xFFFFFFFFLL;
v5 = *v3;
LABEL_9:
*v4 = v5;
free(v3);
return 1LL;
}

original_code:
int ll_c_delete_node(ll* o, void* d) {
    ll *c, *t;
    t = o;
    c = t->next;
    while((c != o) && (c->next) && (c->data != d)) {
        t = c;
        c = c->next;
    }
    if(c->data == d) {
        t->next = c->next;
        free(c);
        return 1;
    }
    return -1;
}

canonical_original_code:
int ll_c_delete_node(struct ll *o, void *d) {
    struct ll *c; struct ll *t;
    t = o;
    c = t->next;
    while((c != o) && (c->next) && (c->data != d)) {
        t = c;
        c = c->next;
    }
    if(c->data == d) {
        t->next = c->next;
        free(c);
        return 1;
    }
    return -1;
}

variable_types:
t
struct ll { void *next; void *data; } *


decompiled_code:
void __fastcall ll_c_delete(void **a1, void *a2)
{
void *v3; // rdi

free(a1[1]);
v3 = *a1;
if ( v3 && v3 != a2 )
{
ll_c_delete(v3, a2);
v3 = *a1;
}
free(v3);
}

canonical_decompiled_code:
void __fastcall func2(void **a1, void *a2)
{
void *v3; // rdi

free(a1[1]);
v3 = *a1;
if ( v3 && v3 != a2 )
{
func2(v3, a2);
v3 = *a1;
}
free(v3);
}

original_code:
void ll_c_delete(ll* n, ll* s) {
    free(n->data);
    if((n->next) && (n->next != s)) ll_c_delete(n->next, s);
    free(n->next);
}

canonical_original_code:
void ll_c_delete(struct ll *n, struct ll *s) {
    free(n->data);
    if((n->next) && (n->next != s)) ll_c_delete(n->next, s);
    free(n->next);
}

variable_types:
n
struct ll { void *next; void *data; } *

variable_types:
s
struct ll *

return_type: void


repo: arrrbiter/flowftpd

decompiled_code:
__int64 __fastcall str_getcwd(__int64 a1)
{
__int64 result; // rax

if ( !p_getcwd_buf_1 )
vsf_secbuf_alloc(&p_getcwd_buf_1, 4096LL);
str_empty(a1);
result = vsf_sysutil_getcwd(p_getcwd_buf_1, 4096LL);
if ( result )
result = str_alloc_text(a1, p_getcwd_buf_1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 result; // rax

if ( !p_getcwd_buf_1 )
vsf_secbuf_alloc(&p_getcwd_buf_1, 4096LL);
str_empty(a1);
result = vsf_sysutil_getcwd(p_getcwd_buf_1, 4096LL);
if ( result )
result = str_alloc_text(a1, p_getcwd_buf_1);
return result;
}

original_code:
void
str_getcwd(struct mystr* p_str)
{
  static char* p_getcwd_buf;
  char* p_ret;
  if (p_getcwd_buf == 0)
  {
    vsf_secbuf_alloc(&p_getcwd_buf, 4096);
  }
  str_empty(p_str);
  p_ret = vsf_sysutil_getcwd(p_getcwd_buf, 4096);
  if (p_ret != 0)
  {
    str_alloc_text(p_str, p_getcwd_buf);
  }
}

canonical_original_code:
void str_getcwd(struct mystr *p_str)
{
  static char *p_getcwd_buf;
  char *p_ret;
  if (p_getcwd_buf == 0)
  {
    vsf_secbuf_alloc(&p_getcwd_buf, 4096);
  }
  str_empty(p_str);
  p_ret = vsf_sysutil_getcwd(p_getcwd_buf, 4096);
  if (p_ret != 0)
  {
    str_alloc_text(p_str, p_getcwd_buf);
  }
}

variable_types: struct mystr { char *PRIVATE_HANDS_OFF_p_buf; unsigned int PRIVATE_HANDS_OFF_len; unsigned int PRIVATE_HANDS_OFF_alloc_bytes; } *


decompiled_code:
__int64 __fastcall str_write_loop(__int64 a1, unsigned int a2)
{
unsigned int v2; // er13
__int64 v3; // rax

v2 = str_getlen();
v3 = str_getbuf(a1);
return vsf_sysutil_write_loop(a2, v3, v2);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned int a2)
{
unsigned int v2; // er13
__int64 v3; // rax

v2 = str_getlen();
v3 = str_getbuf(a1);
return vsf_sysutil_write_loop(a2, v3, v2);
}

original_code:
int
str_write_loop(const struct mystr* p_str, const int fd)
{
  return vsf_sysutil_write_loop(fd, str_getbuf(p_str), str_getlen(p_str));
}

canonical_original_code:
int str_write_loop(struct mystr *p_str, int fd)
{
  return vsf_sysutil_write_loop(fd, str_getbuf(p_str), str_getlen(p_str));
}

variable_types: fd int

user_defined_types: struct mystr { char *PRIVATE_HANDS_OFF_p_buf; unsigned int PRIVATE_HANDS_OFF_len; unsigned int PRIVATE_HANDS_OFF_alloc_bytes; }


decompiled_code:
__int64 __fastcall str_read_loop(__int64 a1, unsigned int a2)
{
unsigned int v2; // er13
__int64 v3; // rax

v2 = str_getlen();
v3 = str_getbuf(a1);
return vsf_sysutil_read_loop(a2, v3, v2);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned int a2)
{
unsigned int v2; // er13
__int64 v3; // rax

v2 = str_getlen();
v3 = str_getbuf(a1);
return vsf_sysutil_read_loop(a2, v3, v2);
}

original_code:
int
str_read_loop(struct mystr* p_str, const int fd)
{
  return vsf_sysutil_read_loop(
    fd, (char*) str_getbuf(p_str), str_getlen(p_str));
}

canonical_original_code:
int str_read_loop(struct mystr *p_str, int fd)
{
  return vsf_sysutil_read_loop(
    fd, (char *) str_getbuf(p_str), str_getlen(p_str));
}


decompiled_code:
__int64 __fastcall str_mkdir(__int64 a1, unsigned int a2)
{
__int64 v2; // rax

v2 = str_getbuf(a1);
return vsf_sysutil_mkdir(v2, a2);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned int a2)
{
__int64 v2; // rax

v2 = str_getbuf(a1);
return vsf_sysutil_mkdir(v2, a2);
}

original_code:
int
str_mkdir(const struct mystr* p_str, const unsigned int mode)
{
  return vsf_sysutil_mkdir(str_getbuf(p_str), mode);
}

canonical_original_code:
int str_mkdir(struct mystr *p_str, unsigned int mode)
{
  return vsf_sysutil_mkdir(str_getbuf(p_str), mode);
}

variable_types:
mode
unsigned int


decompiled_code:
__int64 __fastcall str_rmdir(__int64 a1)
{
__int64 v1; // rax

v1 = str_getbuf(a1);
return vsf_sysutil_rmdir(v1);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
__int64 v1; // rax

v1 = str_getbuf(a1);
return vsf_sysutil_rmdir(v1);
}

original_code:
int
str_rmdir(const struct mystr* p_str)
{
  return vsf_sysutil_rmdir(str_getbuf(p_str));
}

canonical_original_code:
int str_rmdir(struct mystr *p_str)
{
  return vsf_sysutil_rmdir(str_getbuf(p_str));
}


decompiled_code:
__int64 __fastcall str_unlink(__int64 a1)
{
__int64 v1; // rax

v1 = str_getbuf(a1);
return vsf_sysutil_unlink(v1);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 v1; // rax

v1 = str_getbuf(a1);
return vsf_sysutil_unlink(v1);
}

original_code:
int
str_unlink(const struct mystr* p_str)
{
  return vsf_sysutil_unlink(str_getbuf(p_str));
}

canonical_original_code:
int str_unlink(struct mystr *p_str)
{
  return vsf_sysutil_unlink(str_getbuf(p_str));
}


decompiled_code:
__int64 __fastcall str_chdir(__int64 a1)
{
__int64 v1; // rax

v1 = str_getbuf(a1);
return vsf_sysutil_chdir(v1);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
__int64 v1; // rax

v1 = str_getbuf(a1);
return vsf_sysutil_chdir(v1);
}

original_code:
int
str_chdir(const struct mystr* p_str)
{
  return vsf_sysutil_chdir(str_getbuf(p_str));
}

canonical_original_code:
int str_chdir(struct mystr *p_str)
{
  return vsf_sysutil_chdir(str_getbuf(p_str));
}


decompiled_code:
__int64 __fastcall str_open(__int64 a1, unsigned int a2)
{
unsigned int v2; // ebp
__int64 v3; // rax

v2 = a2;
if ( a2 != 1 )
{
v2 = 0;
bug("unknown mode value in str_open");
}
v3 = str_getbuf(a1);
return vsf_sysutil_open_file(v3, v2);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, unsigned int a2)
{
unsigned int v2; // ebp
__int64 v3; // rax

v2 = a2;
if ( a2 != 1 )
{
v2 = 0;
bug("unknown mode value in str_open");
}
v3 = str_getbuf(a1);
return vsf_sysutil_open_file(v3, v2);
}

original_code:
int
str_open(const struct mystr* p_str, const enum EVSFSysStrOpenMode mode)
{
  enum EVSFSysUtilOpenMode open_mode = kVSFSysStrOpenUnknown;
  switch (mode)
  {
    case kVSFSysStrOpenReadOnly:
      open_mode = kVSFSysUtilOpenReadOnly;
      break;
    default:
      bug("unknown mode value in str_open");
      break;
  }
  return vsf_sysutil_open_file(str_getbuf(p_str), open_mode);
}

canonical_original_code:
int str_open(struct mystr *p_str, enum EVSFSysStrOpenMode mode)
{
  enum EVSFSysUtilOpenMode open_mode = kVSFSysStrOpenUnknown;
  switch (mode)
  {
    case kVSFSysStrOpenReadOnly:
      open_mode = kVSFSysUtilOpenReadOnly;
      break;
    default:
      bug("unknown mode value in str_open");
      break;
  }
  return vsf_sysutil_open_file(str_getbuf(p_str), open_mode);
}

variable_types: enum EVSFSysStrOpenMode { kVSFSysStrOpenUnknown=0, kVSFSysStrOpenReadOnly=1 }

variable_types: enum EVSFSysUtilOpenMode { kVSFSysUtilOpenReadOnly=1, kVSFSysUtilOpenWriteOnly=2, kVSFSysUtilOpenReadWrite=3 }


decompiled_code:
__int64 __fastcall str_create_exclusive(__int64 a1)
{
__int64 v1; // rax

v1 = str_getbuf(a1);
return vsf_sysutil_create_file_exclusive(v1);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
__int64 v1; // rax

v1 = str_getbuf(a1);
return vsf_sysutil_create_file_exclusive(v1);
}

original_code:
int
str_create_exclusive(const struct mystr* p_str)
{
  return vsf_sysutil_create_file_exclusive(str_getbuf(p_str));
}

canonical_original_code:
int str_create_exclusive(struct mystr *p_str)
{
  return vsf_sysutil_create_file_exclusive(str_getbuf(p_str));
}


decompiled_code:
__int64 __fastcall str_create(__int64 a1)
{
unsigned int v1; // ebp
__int64 v2; // rax

v1 = tunable_file_open_mode;
v2 = str_getbuf(a1);
return vsf_sysutil_create_or_open_file(v2, v1);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
unsigned int v1; // ebp
__int64 v2; // rax

v1 = tunable_file_open_mode;
v2 = str_getbuf(a1);
return vsf_sysutil_create_or_open_file(v2, v1);
}

original_code:
int
str_create(const struct mystr* p_str)
{
  return vsf_sysutil_create_or_open_file(
      str_getbuf(p_str), tunable_file_open_mode);
}

canonical_original_code:
int str_create(struct mystr *p_str)
{
  return vsf_sysutil_create_or_open_file(
      str_getbuf(p_str), tunable_file_open_mode);
}


decompiled_code:
__int64 __fastcall str_chmod(__int64 a1, unsigned int a2)
{
__int64 v2; // rax

v2 = str_getbuf(a1);
return vsf_sysutil_chmod(v2, a2);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, unsigned int a2)
{
__int64 v2; // rax

v2 = str_getbuf(a1);
return vsf_sysutil_chmod(v2, a2);
}

original_code:
int
str_chmod(const struct mystr* p_str, unsigned int mode)
{
  return vsf_sysutil_chmod(str_getbuf(p_str), mode);
}

canonical_original_code:
int str_chmod(struct mystr *p_str, unsigned int mode)
{
  return vsf_sysutil_chmod(str_getbuf(p_str), mode);
}


decompiled_code:
__int64 __fastcall str_rename(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // rax

v2 = str_getbuf(a2);
v3 = str_getbuf(a1);
return vsf_sysutil_rename(v3, v2);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // rax

v2 = str_getbuf(a2);
v3 = str_getbuf(a1);
return vsf_sysutil_rename(v3, v2);
}

original_code:
int
str_rename(const struct mystr* p_from_str, const struct mystr* p_to_str)
{
  return vsf_sysutil_rename(str_getbuf(p_from_str), str_getbuf(p_to_str));
}

canonical_original_code:
int str_rename(struct mystr *p_from_str, struct mystr *p_to_str)
{
  return vsf_sysutil_rename(str_getbuf(p_from_str), str_getbuf(p_to_str));
}


decompiled_code:
__int64 __fastcall str_readlink(__int64 a1, __int64 a2)
{
__int64 v2; // r13
__int64 v3; // rax
__int64 v4; // r12

if ( !p_readlink_buf_0 )
vsf_secbuf_alloc(&p_readlink_buf_0, 4096LL);
str_empty(a1);
v2 = p_readlink_buf_0;
v3 = str_getbuf(a2);
v4 = (unsigned int)vsf_sysutil_readlink(v3, v2, 4096LL);
if ( !(unsigned int)vsf_sysutil_retval_is_error(v4) )
{
LODWORD(v4) = 0;
str_alloc_text(a1, p_readlink_buf_0);
}
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, __int64 a2)
{
__int64 v2; // r13
__int64 v3; // rax
__int64 v4; // r12

if ( !p_readlink_buf_0 )
vsf_secbuf_alloc(&p_readlink_buf_0, 4096LL);
str_empty(a1);
v2 = p_readlink_buf_0;
v3 = str_getbuf(a2);
v4 = (unsigned int)vsf_sysutil_readlink(v3, v2, 4096LL);
if ( !(unsigned int)vsf_sysutil_retval_is_error(v4) )
{
LODWORD(v4) = 0;
str_alloc_text(a1, p_readlink_buf_0);
}
return (unsigned int)v4;
}

original_code:
int
str_readlink(struct mystr* p_str, const struct mystr* p_filename_str)
{
  static char* p_readlink_buf;
  int retval;
  if (p_readlink_buf == 0)
  {
    vsf_secbuf_alloc(&p_readlink_buf, 4096);
  }
  str_empty(p_str);
  retval = vsf_sysutil_readlink(str_getbuf(p_filename_str), p_readlink_buf,
                                4096);
  if (vsf_sysutil_retval_is_error(retval))
  {
    return retval;
  }
  str_alloc_text(p_str, p_readlink_buf);
  return 0;
}

canonical_original_code:
int str_readlink(struct mystr *p_str, struct mystr *p_filename_str)
{
  static char *p_readlink_buf;
  int retval;
  if (p_readlink_buf == 0)
  {
    vsf_secbuf_alloc(&p_readlink_buf, 4096);
  }
  str_empty(p_str);
  retval = vsf_sysutil_readlink(str_getbuf(p_filename_str), p_readlink_buf,
                                4096);
  if (vsf_sysutil_retval_is_error(retval))
  {
    return retval;
  }
  str_alloc_text(p_str, p_readlink_buf);
  return 0;
}

variable_types: retval int


decompiled_code:
__int64 __fastcall str_syslog(__int64 a1, unsigned int a2)
{
__int64 v2; // rax

v2 = str_getbuf(a1);
return vsf_sysutil_syslog(v2, a2);
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1, unsigned int a2)
{
__int64 v2; // rax

v2 = str_getbuf(a1);
return vsf_sysutil_syslog(v2, a2);
}

original_code:
void
str_syslog(const struct mystr* p_str, int severe)
{
  vsf_sysutil_syslog(str_getbuf(p_str), severe);
}

canonical_original_code:
void str_syslog(struct mystr *p_str, int severe)
{
  vsf_sysutil_syslog(str_getbuf(p_str), severe);
}

variable_types: severe int


decompiled_code:
__int64 __fastcall sort_compare_common(__int64 a1, __int64 a2, int a3)
{
__int64 v4; // rbp
__int64 v5; // r12
__int64 result; // rax

v4 = a1 + 16;
if ( (unsigned int)str_isempty(a1 + 16) )
v4 = a1;
v5 = a2 + 16;
if ( (unsigned int)str_isempty(a2 + 16) )
v5 = a2;
if ( a3 )
result = str_strcmp(v5, v4);
else
result = str_strcmp(v4, v5);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, int a3)
{
__int64 v4; // rbp
__int64 v5; // r12
__int64 result; // rax

v4 = a1 + 16;
if ( (unsigned int)str_isempty(a1 + 16) )
v4 = a1;
v5 = a2 + 16;
if ( (unsigned int)str_isempty(a2 + 16) )
v5 = a2;
if ( a3 )
result = str_strcmp(v5, v4);
else
result = str_strcmp(v4, v5);
return result;
}

original_code:
static int
sort_compare_common(const void* p1, const void* p2, int reverse)
{
  const struct mystr* p_cmp1;
  const struct mystr* p_cmp2;
  const struct mystr_list_node* p_node1 = (const struct mystr_list_node*) p1;
  const struct mystr_list_node* p_node2 = (const struct mystr_list_node*) p2;
  if (!str_isempty(&p_node1->sort_key_str))
  {
    p_cmp1 = &p_node1->sort_key_str;
  }
  else
  {
    p_cmp1 = &p_node1->str;
  }
  if (!str_isempty(&p_node2->sort_key_str))
  {
    p_cmp2 = &p_node2->sort_key_str;
  }
  else
  {
    p_cmp2 = &p_node2->str;
  }
  if (reverse)
  {
    return str_strcmp(p_cmp2, p_cmp1);
  }
  else
  {
    return str_strcmp(p_cmp1, p_cmp2);
  }
}

canonical_original_code:
static int sort_compare_common(void *p1, void *p2, int reverse)
{
  struct mystr *p_cmp1;
  struct mystr *p_cmp2;
  struct mystr_list_node *p_node1 = (const struct mystr_list_node*) p1;
  struct mystr_list_node *p_node2 = (const struct mystr_list_node*) p2;
  if (!str_isempty(&p_node1->sort_key_str))
  {
    p_cmp1 = &p_node1->sort_key_str;
  }
  else
  {
    p_cmp1 = &p_node1->str;
  }
  if (!str_isempty(&p_node2->sort_key_str))
  {
    p_cmp2 = &p_node2->sort_key_str;
  }
  else
  {
    p_cmp2 = &p_node2->str;
  }
  if (reverse)
  {
    return str_strcmp(p_cmp2, p_cmp1);
  }
  else
  {
    return str_strcmp(p_cmp1, p_cmp2);
  }
}

variable_types: reverse int

variable_types: struct mystr_list_node { struct mystr { char *PRIVATE_HANDS_OFF_p_buf; unsigned int PRIVATE_HANDS_OFF_len; unsigned int PRIVATE_HANDS_OFF_alloc_bytes; } str; struct mystr sort_key_str; } *

user_defined_types: struct mystr_list_node { struct mystr str; struct mystr sort_key_str; }


decompiled_code:
__int64 __fastcall sort_compare_func_reverse(__int64 a1, __int64 a2)
{
return sort_compare_common(a1, a2, 1);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
return func0(a1, a2, 1);
}

original_code:
static int
sort_compare_func_reverse(const void* p1, const void* p2)
{
  return sort_compare_common(p1, p2, 1);
}

canonical_original_code:
static int sort_compare_func_reverse(void *p1, void *p2)
{
  return sort_compare_common(p1, p2, 1);
}


decompiled_code:
__int64 __fastcall sort_compare_func(__int64 a1, __int64 a2)
{
return sort_compare_common(a1, a2, 0);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
return func0(a1, a2, 0);
}

original_code:
static int
sort_compare_func(const void* p1, const void* p2)
{
  return sort_compare_common(p1, p2, 0);
}

canonical_original_code:
static int sort_compare_func(void *p1, void *p2)
{
  return sort_compare_common(p1, p2, 0);
}


decompiled_code:
__int64 __fastcall str_list_free(__int64 a1)
{
__int64 result; // rax
unsigned int v3; // ebp
__int64 v4; // rbx
__int64 v5; // rdi

result = *(unsigned int *)(a1 + 4);
if ( (_DWORD)result )
{
v3 = 0;
do
{
v4 = v3++;
v4 *= 32LL;
str_free(v4 + *(_QWORD *)(a1 + 8));
result = str_free(*(_QWORD *)(a1 + 8) + v4 + 16);
}
while ( *(_DWORD *)(a1 + 4) > v3 );
}
v5 = *(_QWORD *)(a1 + 8);
*(_QWORD *)a1 = 0LL;
if ( v5 )
{
result = vsf_sysutil_free();
*(_QWORD *)(a1 + 8) = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 result; // rax
unsigned int v3; // ebp
__int64 v4; // rbx
__int64 v5; // rdi

result = *(unsigned int *)(a1 + 4);
if ( (_DWORD)result )
{
v3 = 0;
do
{
v4 = v3++;
v4 *= 32LL;
str_free(v4 + *(_QWORD *)(a1 + 8));
result = str_free(*(_QWORD *)(a1 + 8) + v4 + 16);
}
while ( *(_DWORD *)(a1 + 4) > v3 );
}
v5 = *(_QWORD *)(a1 + 8);
*(_QWORD *)a1 = 0LL;
if ( v5 )
{
result = vsf_sysutil_free();
*(_QWORD *)(a1 + 8) = 0LL;
}
return result;
}

original_code:
void
str_list_free(struct mystr_list* p_list)
{
  unsigned int i;
  for (i=0; i < p_list->list_len; ++i)
  {
    str_free(&p_list->p_nodes[i].str);
    str_free(&p_list->p_nodes[i].sort_key_str);
  }
  p_list->list_len = 0;
  p_list->alloc_len = 0;
  if (p_list->p_nodes)
  {
    vsf_sysutil_free(p_list->p_nodes);
    p_list->p_nodes = 0;
  }
}

canonical_original_code:
void str_list_free(struct mystr_list *p_list)
{
  unsigned int i;
  for (i=0; i < p_list->list_len; ++i)
  {
    str_free(&p_list->p_nodes[i].str);
    str_free(&p_list->p_nodes[i].sort_key_str);
  }
  p_list->list_len = 0;
  p_list->alloc_len = 0;
  if (p_list->p_nodes)
  {
    vsf_sysutil_free(p_list->p_nodes);
    p_list->p_nodes = 0;
  }
}

variable_types: struct mystr_list { unsigned int alloc_len; unsigned int list_len; struct mystr_list_node { struct mystr { char *PRIVATE_HANDS_OFF_p_buf; unsigned int PRIVATE_HANDS_OFF_len; unsigned int PRIVATE_HANDS_OFF_alloc_bytes; } str; struct mystr sort_key_str; } *p_nodes; } *

variable_types:
i
unsigned int

user_defined_types: struct mystr_list { unsigned int alloc_len; unsigned int list_len; struct mystr_list_node *p_nodes; }


decompiled_code:
__int64 __fastcall str_list_get_length(__int64 a1)
{
return *(unsigned int *)(a1 + 4);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
return *(unsigned int *)(a1 + 4);
}

original_code:
int
str_list_get_length(const struct mystr_list* p_list)
{
  return p_list->list_len;
}

canonical_original_code:
int str_list_get_length(struct mystr_list *p_list)
{
  return p_list->list_len;
}


decompiled_code:
__int64 __fastcall str_list_contains_str(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx

if ( !*(_DWORD *)(a1 + 4) )
return 0LL;
v2 = 0;
do
{
if ( (unsigned int)str_equal(a2, *(_QWORD *)(a1 + 8) + 32LL * v2) )
return 1LL;
++v2;
}
while ( *(_DWORD *)(a1 + 4) > v2 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx

if ( !*(_DWORD *)(a1 + 4) )
return 0LL;
v2 = 0;
do
{
if ( (unsigned int)str_equal(a2, *(_QWORD *)(a1 + 8) + 32LL * v2) )
return 1LL;
++v2;
}
while ( *(_DWORD *)(a1 + 4) > v2 );
return 0LL;
}

original_code:
int
str_list_contains_str(const struct mystr_list* p_list,
                      const struct mystr* p_str)
{
  unsigned int i;
  for (i=0; i < p_list->list_len; ++i)
  {
    if (str_equal(p_str, &p_list->p_nodes[i].str))
    {
      return 1;
    }
  }
  return 0;
}

canonical_original_code:
int str_list_contains_str(struct mystr_list *p_list, struct mystr *p_str)
{
  unsigned int i;
  for (i=0; i < p_list->list_len; ++i)
  {
    if (str_equal(p_str, &p_list->p_nodes[i].str))
    {
      return 1;
    }
  }
  return 0;
}


original_code:
void
str_list_add(struct mystr_list* p_list, const struct mystr* p_str,
             const struct mystr* p_sort_key_str)
{
  struct mystr_list_node* p_node;
  if (p_list->list_len == p_list->alloc_len)
  {
    if (p_list->alloc_len == 0)
    {
      p_list->alloc_len = 32;
      p_list->p_nodes = vsf_sysutil_malloc(p_list->alloc_len *
                                           sizeof(struct mystr_list_node));
    }
    else
    {
      p_list->alloc_len *= 2;
      p_list->p_nodes = vsf_sysutil_realloc(p_list->p_nodes,
                                            p_list->alloc_len *
                                            sizeof(struct mystr_list_node));
    }
  }
  p_node = &p_list->p_nodes[p_list->list_len];
  p_node->str = s_null_str;
  p_node->sort_key_str = s_null_str;
  str_copy(&p_node->str, p_str);
  if (p_sort_key_str)
  {
    str_copy(&p_node->sort_key_str, p_sort_key_str);
  }
  p_list->list_len++;
}

canonical_original_code:
void str_list_add(struct mystr_list *p_list, struct mystr *p_str, struct mystr *p_sort_key_str)
{
  struct mystr_list_node *p_node;
  if (p_list->list_len == p_list->alloc_len)
  {
    if (p_list->alloc_len == 0)
    {
      p_list->alloc_len = 32;
      p_list->p_nodes = vsf_sysutil_malloc(p_list->alloc_len *
                                           sizeof(struct mystr_list_node));
    }
    else
    {
      p_list->alloc_len *= 2;
      p_list->p_nodes = vsf_sysutil_realloc(p_list->p_nodes,
                                            p_list->alloc_len *
                                            sizeof(struct mystr_list_node));
    }
  }
  p_node = &p_list->p_nodes[p_list->list_len];
  p_node->str = s_null_str;
  p_node->sort_key_str = s_null_str;
  str_copy(&p_node->str, p_str);
  if (p_sort_key_str)
  {
    str_copy(&p_node->sort_key_str, p_sort_key_str);
  }
  p_list->list_len++;
}


decompiled_code:
__int64 __fastcall str_list_sort(__int64 a1, int a2)
{
__int64 v3; // rsi
__int64 v4; // rdi
__int64 result; // rax

v3 = *(unsigned int *)(a1 + 4);
v4 = *(_QWORD *)(a1 + 8);
if ( a2 )
result = vsf_sysutil_qsort(v4, v3, 32LL, sort_compare_func_reverse);
else
result = vsf_sysutil_qsort(v4, v3, 32LL, sort_compare_func);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, int a2)
{
__int64 v3; // rsi
__int64 v4; // rdi
__int64 result; // rax

v3 = *(unsigned int *)(a1 + 4);
v4 = *(_QWORD *)(a1 + 8);
if ( a2 )
result = vsf_sysutil_qsort(v4, v3, 32LL, sort_compare_func_reverse);
else
result = vsf_sysutil_qsort(v4, v3, 32LL, sort_compare_func);
return result;
}

original_code:
void
str_list_sort(struct mystr_list* p_list, int reverse)
{
  if (!reverse)
  {
    vsf_sysutil_qsort(p_list->p_nodes, p_list->list_len,
                      sizeof(struct mystr_list_node), sort_compare_func);
  }
  else
  {
    vsf_sysutil_qsort(p_list->p_nodes, p_list->list_len,
                      sizeof(struct mystr_list_node),
                      sort_compare_func_reverse);
  }
}

canonical_original_code:
void str_list_sort(struct mystr_list *p_list, int reverse)
{
  if (!reverse)
  {
    vsf_sysutil_qsort(p_list->p_nodes, p_list->list_len,
                      sizeof(struct mystr_list_node), sort_compare_func);
  }
  else
  {
    vsf_sysutil_qsort(p_list->p_nodes, p_list->list_len,
                      sizeof(struct mystr_list_node),
                      sort_compare_func_reverse);
  }
}


decompiled_code:
__int64 __fastcall str_list_get_pstr(__int64 a1, unsigned int a2)
{
if ( *(_DWORD *)(a1 + 4) <= a2 )
bug("indexx out of range in str_list_get_str");
return *(_QWORD *)(a1 + 8) + 32LL * a2;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, unsigned int a2)
{
if ( *(_DWORD *)(a1 + 4) <= a2 )
bug("indexx out of range in str_list_get_str");
return *(_QWORD *)(a1 + 8) + 32LL * a2;
}

original_code:
const struct mystr*
str_list_get_pstr(const struct mystr_list* p_list, unsigned int indexx)
{
  if (indexx >= p_list->list_len)
  {
    bug("indexx out of range in str_list_get_str");
  }
  return &p_list->p_nodes[indexx].str;
}

canonical_original_code:
struct mystr *str_list_get_pstr(struct mystr_list *p_list, unsigned int indexx)
{
  if (indexx >= p_list->list_len)
  {
    bug("indexx out of range in str_list_get_str");
  }
  return &p_list->p_nodes[indexx].str;
}

variable_types: struct mystr_list { unsigned int alloc_len; unsigned int list_len; struct mystr_list_node { struct mystr str; struct mystr sort_key_str; } *p_nodes; } *

variable_types:
indexx
unsigned int

return_type: struct mystr { char *PRIVATE_HANDS_OFF_p_buf; unsigned int PRIVATE_HANDS_OFF_len; unsigned int PRIVATE_HANDS_OFF_alloc_bytes; } *


decompiled_code:
__int64 __fastcall priv_sock_send_cmd(__int64 a1, char a2)
{
__int64 result; // rax
char v3[12]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = a2;
result = vsf_sysutil_write_loop(a1, v3, 1LL);
if ( (_DWORD)result != 1 )
result = die("priv_sock_send_cmd");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, char a2)
{
__int64 result; // rax
char v3[12]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = a2;
result = vsf_sysutil_write_loop(a1, v3, 1LL);
if ( (_DWORD)result != 1 )
result = die("priv_sock_send_cmd");
return result;
}

original_code:
void
priv_sock_send_cmd(int fd, char cmd)
{
  int retval = vsf_sysutil_write_loop(fd, &cmd, sizeof(cmd));
  if (retval != sizeof(cmd))
  {
    die("priv_sock_send_cmd");
  }
}

variable_types: cmd char


decompiled_code:
__int64 __fastcall priv_sock_get_result(__int64 a1)
{
char v2[9]; // [rsp+Fh] [rbp-9h] BYREF

if ( (unsigned int)vsf_sysutil_read_loop(a1, v2, 1LL) != 1 )
die("priv_sock_get_result");
return (unsigned __int8)v2[0];
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
char v2[9]; // [rsp+Fh] [rbp-9h] BYREF

if ( (unsigned int)vsf_sysutil_read_loop(a1, v2, 1LL) != 1 )
die("priv_sock_get_result");
return (unsigned __int8)v2[0];
}

original_code:
char
priv_sock_get_result(int fd)
{
  char res;
  int retval = vsf_sysutil_read_loop(fd, &res, sizeof(res));
  if (retval != sizeof(res))
  {
    die("priv_sock_get_result");
  }
  return res;
}

variable_types: res char

return_type: char


decompiled_code:
__int64 __fastcall priv_sock_get_cmd(__int64 a1)
{
char v2[9]; // [rsp+Fh] [rbp-9h] BYREF

if ( (unsigned int)vsf_sysutil_read_loop(a1, v2, 1LL) != 1 )
die("priv_sock_get_cmd");
return (unsigned __int8)v2[0];
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
char v2[9]; // [rsp+Fh] [rbp-9h] BYREF

if ( (unsigned int)vsf_sysutil_read_loop(a1, v2, 1LL) != 1 )
die("priv_sock_get_cmd");
return (unsigned __int8)v2[0];
}

original_code:
char
priv_sock_get_cmd(int fd)
{
  char res;
  int retval = vsf_sysutil_read_loop(fd, &res, sizeof(res));
  if (retval != sizeof(res))
  {
    die("priv_sock_get_cmd");
  }
  return res;
}


decompiled_code:
__int64 __fastcall priv_sock_send_result(__int64 a1, char a2)
{
__int64 result; // rax
char v3[12]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = a2;
result = vsf_sysutil_write_loop(a1, v3, 1LL);
if ( (_DWORD)result != 1 )
result = die("priv_sock_send_result");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, char a2)
{
__int64 result; // rax
char v3[12]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = a2;
result = vsf_sysutil_write_loop(a1, v3, 1LL);
if ( (_DWORD)result != 1 )
result = die("priv_sock_send_result");
return result;
}

original_code:
void
priv_sock_send_result(int fd, char res)
{
  int retval = vsf_sysutil_write_loop(fd, &res, sizeof(res));
  if (retval != sizeof(res))
  {
    die("priv_sock_send_result");
  }
}


decompiled_code:
// attributes: thunk
__int64 priv_sock_send_fd()
{
return vsf_sysutil_send_fd();
}

canonical_decompiled_code:
__int64 func8()
{
return vsf_sysutil_send_fd();
}

original_code:
void
priv_sock_send_fd(int fd, int send_fd)
{
  vsf_sysutil_send_fd(fd, send_fd);
}


decompiled_code:
// attributes: thunk
__int64 priv_sock_recv_fd()
{
return vsf_sysutil_recv_fd();
}

canonical_decompiled_code:
__int64 func9()
{
return vsf_sysutil_recv_fd();
}

original_code:
int
priv_sock_recv_fd(int fd)
{
  return vsf_sysutil_recv_fd(fd);
}


decompiled_code:
__int64 __fastcall priv_sock_send_int(__int64 a1, int a2)
{
__int64 result; // rax
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = a2;
result = vsf_sysutil_write_loop(a1, v3, 4LL);
if ( (_DWORD)result != 4 )
result = die("priv_sock_send_int");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, int a2)
{
__int64 result; // rax
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = a2;
result = vsf_sysutil_write_loop(a1, v3, 4LL);
if ( (_DWORD)result != 4 )
result = die("priv_sock_send_int");
return result;
}

original_code:
void
priv_sock_send_int(int fd, int the_int)
{
  int retval = vsf_sysutil_write_loop(fd, &the_int, sizeof(the_int));
  if (retval != sizeof(the_int))
  {
    die("priv_sock_send_int");
  }
}


decompiled_code:
__int64 __fastcall priv_sock_send_str(unsigned int a1, __int64 a2)
{
int v2; // ebx
__int64 result; // rax

v2 = str_getlen(a2);
result = priv_sock_send_int(a1, v2);
if ( v2 )
result = str_netfd_write(a2, a1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(unsigned int a1, __int64 a2)
{
int v2; // ebx
__int64 result; // rax

v2 = str_getlen(a2);
result = func10(a1, v2);
if ( v2 )
result = str_netfd_write(a2, a1);
return result;
}

original_code:
void
priv_sock_send_str(int fd, const struct mystr* p_str)
{
  unsigned int len = str_getlen(p_str);
  priv_sock_send_int(fd, (int) len);
  if (len > 0)
  {
    str_netfd_write(p_str, fd);
  }
}

canonical_original_code:
void priv_sock_send_str(int fd, struct mystr *p_str)
{
  unsigned int len = str_getlen(p_str);
  priv_sock_send_int(fd, (int) len);
  if (len > 0)
  {
    str_netfd_write(p_str, fd);
  }
}

variable_types:
len
unsigned int


decompiled_code:
__int64 __fastcall priv_sock_send_buf(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 result; // rax

result = priv_sock_send_int(a1, a3);
if ( a3 )
{
result = vsf_sysutil_write_loop((unsigned int)a1, a2, a3);
if ( a3 != (_DWORD)result )
result = die("priv_sock_send_buf");
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 result; // rax

result = func10(a1, a3);
if ( a3 )
{
result = vsf_sysutil_write_loop((unsigned int)a1, a2, a3);
if ( a3 != (_DWORD)result )
result = die("priv_sock_send_buf");
}
return result;
}

original_code:
void
priv_sock_send_buf(int fd, const char* p_buf, unsigned int len)
{
  priv_sock_send_int(fd, (int) len);
  if (len > 0)
  {
    if (vsf_sysutil_write_loop(fd, p_buf, len) != (int) len)
    {
      die("priv_sock_send_buf");
    }
  }
}

canonical_original_code:
void priv_sock_send_buf(int fd, char *p_buf, unsigned int len)
{
  priv_sock_send_int(fd, (int) len);
  if (len > 0)
  {
    if (vsf_sysutil_write_loop(fd, p_buf, len) != (int) len)
    {
      die("priv_sock_send_buf");
    }
  }
}


decompiled_code:
__int64 __fastcall priv_sock_get_int(__int64 a1)
{
unsigned int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( (unsigned int)vsf_sysutil_read_loop(a1, v2, 4LL) != 4 )
die("priv_sock_get_int");
return v2[0];
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1)
{
unsigned int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( (unsigned int)vsf_sysutil_read_loop(a1, v2, 4LL) != 4 )
die("priv_sock_get_int");
return v2[0];
}

original_code:
int
priv_sock_get_int(int fd)
{
  int the_int;
  int retval = vsf_sysutil_read_loop(fd, &the_int, sizeof(the_int));
  if (retval != sizeof(the_int))
  {
    die("priv_sock_get_int");
  }
  return the_int;
}


decompiled_code:
__int64 __fastcall priv_sock_recv_buf(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 result; // rax
unsigned int v5; // ebx

result = priv_sock_get_int(a1);
v5 = result;
if ( (unsigned int)result > a3 )
{
result = bug("recv_len bigger than buffer");
if ( !v5 )
return result;
}
else if ( !(_DWORD)result )
{
return result;
}
result = vsf_sysutil_read_loop((unsigned int)a1, a2, v5);
if ( v5 != (_DWORD)result )
result = die("priv_sock_recv_buf");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, __int64 a2, unsigned int a3)
{
__int64 result; // rax
unsigned int v5; // ebx

result = func13(a1);
v5 = result;
if ( (unsigned int)result > a3 )
{
result = bug("recv_len bigger than buffer");
if ( !v5 )
return result;
}
else if ( !(_DWORD)result )
{
return result;
}
result = vsf_sysutil_read_loop((unsigned int)a1, a2, v5);
if ( v5 != (_DWORD)result )
result = die("priv_sock_recv_buf");
return result;
}

original_code:
void
priv_sock_recv_buf(int fd, char* p_buf, unsigned int len)
{
  unsigned int recv_len = (unsigned int) priv_sock_get_int(fd);
  if (recv_len > len)
  {
    bug("recv_len bigger than buffer");
  }
  if (recv_len > 0)
  {
    if (vsf_sysutil_read_loop(fd, p_buf, recv_len) != (int) recv_len)
    {
      die("priv_sock_recv_buf");
    }
  }
}

canonical_original_code:
void priv_sock_recv_buf(int fd, char *p_buf, unsigned int len)
{
  unsigned int recv_len = (unsigned int) priv_sock_get_int(fd);
  if (recv_len > len)
  {
    bug("recv_len bigger than buffer");
  }
  if (recv_len > 0)
  {
    if (vsf_sysutil_read_loop(fd, p_buf, recv_len) != (int) recv_len)
    {
      die("priv_sock_recv_buf");
    }
  }
}


decompiled_code:
__int64 __fastcall priv_sock_get_str(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx
__int64 result; // rax

v2 = priv_sock_get_int(a1);
if ( v2 > 0x20000 )
{
die("priv_sock_get_str: too big");
str_empty(a2);
}
else
{
result = str_empty(a2);
if ( !v2 )
return result;
}
result = str_netfd_read(a2, (unsigned int)a1, v2);
if ( v2 != (_DWORD)result )
result = die("priv_sock_get_str: read error");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx
__int64 result; // rax

v2 = func13(a1);
if ( v2 > 0x20000 )
{
die("priv_sock_get_str: too big");
str_empty(a2);
}
else
{
result = str_empty(a2);
if ( !v2 )
return result;
}
result = str_netfd_read(a2, (unsigned int)a1, v2);
if ( v2 != (_DWORD)result )
result = die("priv_sock_get_str: read error");
return result;
}

original_code:
void
priv_sock_get_str(int fd, struct mystr* p_dest)
{
  unsigned int len = (unsigned int) priv_sock_get_int(fd);
  if (len > 65536 * 2)
  {
    die("priv_sock_get_str: too big");
  }
  str_empty(p_dest);
  if (len > 0)
  {
    int retval = str_netfd_read(p_dest, fd, len);
    if ((unsigned int) retval != len)
    {
      die("priv_sock_get_str: read error");
    }
  }
}

canonical_original_code:
void priv_sock_get_str(int fd, struct mystr *p_dest)
{
  unsigned int len = (unsigned int) priv_sock_get_int(fd);
  if (len > 65536 * 2)
  {
    die("priv_sock_get_str: too big");
  }
  str_empty(p_dest);
  if (len > 0)
  {
    int retval = str_netfd_read(p_dest, fd, len);
    if ((unsigned int) retval != len)
    {
      die("priv_sock_get_str: read error");
    }
  }
}


decompiled_code:
__int64 __fastcall hash_ip(unsigned int a1, unsigned __int8 *a2)
{
unsigned int v2; // er8
int v4; // ecx
unsigned int v5; // eax
unsigned __int8 *v6; // rdi

v2 = s_ipaddr_size;
if ( s_ipaddr_size )
{
v4 = 24;
v5 = 0;
v6 = &a2[s_ipaddr_size];
do
{
v5 ^= *a2 << v4;
v4 -= 8;
if ( v4 < 0 )
v4 = 24;
++a2;
}
while ( v6 != a2 );
v2 = v5 % a1;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, unsigned __int8 *a2)
{
unsigned int v2; // er8
int v4; // ecx
unsigned int v5; // eax
unsigned __int8 *v6; // rdi

v2 = s_ipaddr_size;
if ( s_ipaddr_size )
{
v4 = 24;
v5 = 0;
v6 = &a2[s_ipaddr_size];
do
{
v5 ^= *a2 << v4;
v4 -= 8;
if ( v4 < 0 )
v4 = 24;
++a2;
}
while ( v6 != a2 );
v2 = v5 % a1;
}
return v2;
}

original_code:
static unsigned int
hash_ip(unsigned int buckets, void* p_key)
{
  const unsigned char* p_raw_ip = (const unsigned char*)p_key;
  unsigned int val = 0;
  int shift = 24;
  unsigned int i;
  for (i = 0; i < s_ipaddr_size; ++i)
  {
    val ^= p_raw_ip[i] << shift;
    shift -= 8;
    if (shift < 0)
    {
      shift = 24;
    }
  }
  return val % buckets;
}

canonical_original_code:
static unsigned int hash_ip(unsigned int buckets, void *p_key)
{
  unsigned char *p_raw_ip = (const unsigned char*)p_key;
  unsigned int val = 0;
  int shift = 24;
  unsigned int i;
  for (i = 0; i < s_ipaddr_size; ++i)
  {
    val ^= p_raw_ip[i] << shift;
    shift -= 8;
    if (shift < 0)
    {
      shift = 24;
    }
  }
  return val % buckets;
}

variable_types:
buckets
unsigned int

variable_types:
val
unsigned int

variable_types: shift int

return_type: unsigned int


decompiled_code:
__int64 __fastcall hash_pid(unsigned int a1, _DWORD *a2)
{
return *a2 % a1;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1, _DWORD *a2)
{
return *a2 % a1;
}

original_code:
static unsigned int
hash_pid(unsigned int buckets, void* p_key)
{
  unsigned int* p_pid = (unsigned int*)p_key;
  return (*p_pid) % buckets;
}

canonical_original_code:
static unsigned int hash_pid(unsigned int buckets, void *p_key)
{
  unsigned int *p_pid = (unsigned int*)p_key;
  return (*p_pid) % buckets;
}


decompiled_code:
__int64 handle_sighup()
{
tunables_load_defaults();
return vsf_parseconf_load_file(0LL, 0LL);
}

canonical_decompiled_code:
__int64 func2()
{
tunables_load_defaults();
return vsf_parseconf_load_file(0LL, 0LL);
}

original_code:
static void
handle_sighup(void* duff)
{
  (void) duff;
  tunables_load_defaults();
  vsf_parseconf_load_file(0, 0);
}

canonical_original_code:
static void handle_sighup(void *duff)
{
  (void) duff;
  tunables_load_defaults();
  vsf_parseconf_load_file(0, 0);
}

variable_types:
duff
void *


decompiled_code:
__int64 __fastcall handle_ip_count(__int64 a1)
{
unsigned int *v1; // rax
unsigned int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v1 = (unsigned int *)hash_lookup_entry(s_p_ip_count_hash, a1);
if ( v1 )
{
v3[0] = *v1 + 1;
*v1 = v3[0];
}
else
{
v3[0] = 1;
hash_add_entry(s_p_ip_count_hash, a1, v3);
}
return v3[0];
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
unsigned int *v1; // rax
unsigned int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v1 = (unsigned int *)hash_lookup_entry(s_p_ip_count_hash, a1);
if ( v1 )
{
v3[0] = *v1 + 1;
*v1 = v3[0];
}
else
{
v3[0] = 1;
hash_add_entry(s_p_ip_count_hash, a1, v3);
}
return v3[0];
}

original_code:
static unsigned int
handle_ip_count(void* p_ipaddr)
{
  unsigned int* p_count =
    (unsigned int*)hash_lookup_entry(s_p_ip_count_hash, p_ipaddr);
  unsigned int count;
  if (!p_count)
  {
    count = 1;
    hash_add_entry(s_p_ip_count_hash, p_ipaddr, (void*)&count);
  }
  else
  {
    count = *p_count;
    count++;
    *p_count = count;
  }
  return count;
}

canonical_original_code:
static unsigned int handle_ip_count(void *p_ipaddr)
{
  unsigned int *p_count = (unsigned int*)hash_lookup_entry(s_p_ip_count_hash, p_ipaddr);
  unsigned int count;
  if (!p_count)
  {
    count = 1;
    hash_add_entry(s_p_ip_count_hash, p_ipaddr, (void *)&count);
  }
  else
  {
    count = *p_count;
    count++;
    *p_count = count;
  }
  return count;
}

variable_types:
count
unsigned int


decompiled_code:
__int64 __fastcall drop_ip_count(__int64 a1)
{
_DWORD *v1; // rbx
__int64 result; // rax

v1 = (_DWORD *)hash_lookup_entry(s_p_ip_count_hash, a1);
if ( !v1 )
bug("IP address missing from hash");
result = (unsigned int)*v1;
if ( (_DWORD)result )
{
*v1 = result - 1;
if ( (_DWORD)result == 1 )
result = hash_free_entry(s_p_ip_count_hash, a1);
}
else
{
result = bug("zero count for IP address");
*v1 = -1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
_DWORD *v1; // rbx
__int64 result; // rax

v1 = (_DWORD *)hash_lookup_entry(s_p_ip_count_hash, a1);
if ( !v1 )
bug("IP address missing from hash");
result = (unsigned int)*v1;
if ( (_DWORD)result )
{
*v1 = result - 1;
if ( (_DWORD)result == 1 )
result = hash_free_entry(s_p_ip_count_hash, a1);
}
else
{
result = bug("zero count for IP address");
*v1 = -1;
}
return result;
}

original_code:
static void
drop_ip_count(void* p_raw_addr)
{
  unsigned int count;
  unsigned int* p_count =
    (unsigned int*)hash_lookup_entry(s_p_ip_count_hash, p_raw_addr);
  if (!p_count)
  {
    bug("IP address missing from hash");
  }
  count = *p_count;
  if (!count)
  {
    bug("zero count for IP address");
  }
  count--;
  *p_count = count;
  if (!count)
  {
    hash_free_entry(s_p_ip_count_hash, p_raw_addr);
  }
}

canonical_original_code:
static void drop_ip_count(void *p_raw_addr)
{
  unsigned int count;
  unsigned int *p_count = (unsigned int*)hash_lookup_entry(s_p_ip_count_hash, p_raw_addr);
  if (!p_count)
  {
    bug("IP address missing from hash");
  }
  count = *p_count;
  if (!count)
  {
    bug("zero count for IP address");
  }
  count--;
  *p_count = count;
  if (!count)
  {
    hash_free_entry(s_p_ip_count_hash, p_raw_addr);
  }
}


decompiled_code:
__int64 handle_sigchld()
{
__int64 result; // rax
__int64 v1; // rax
int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

v2[0] = 1;
do
{
result = vsf_sysutil_wait_reap_one();
v2[0] = result;
if ( !(_DWORD)result )
break;
--s_children;
v1 = hash_lookup_entry(s_p_pid_ip_hash, v2);
drop_ip_count(v1);
hash_free_entry(s_p_pid_ip_hash, v2);
result = (unsigned int)v2[0];
}
while ( v2[0] );
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 result; // rax
__int64 v1; // rax
int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

v2[0] = 1;
do
{
result = vsf_sysutil_wait_reap_one();
v2[0] = result;
if ( !(_DWORD)result )
break;
--s_children;
v1 = hash_lookup_entry(s_p_pid_ip_hash, v2);
func4(v1);
hash_free_entry(s_p_pid_ip_hash, v2);
result = (unsigned int)v2[0];
}
while ( v2[0] );
return result;
}

original_code:
static void
handle_sigchld(void* duff)
{
  struct vsf_sysutil_wait_retval wait_retval = vsf_sysutil_wait();
  (void) duff;
  if (vsf_sysutil_retval_is_error(vsf_sysutil_wait_get_retval(&wait_retval)) ||
      !vsf_sysutil_wait_exited_normally(&wait_retval) ||
      vsf_sysutil_wait_get_exitcode(&wait_retval) != 0)
  {
    die("child died");
  }
  else
  {
    vsf_sysutil_exit(0);
  }
}

canonical_original_code:
static void handle_sigchld(void *duff)
{
  struct vsf_sysutil_wait_retval wait_retval = vsf_sysutil_wait();
  (void) duff;
  if (vsf_sysutil_retval_is_error(vsf_sysutil_wait_get_retval(&wait_retval)) ||
      !vsf_sysutil_wait_exited_normally(&wait_retval) ||
      vsf_sysutil_wait_get_exitcode(&wait_retval) != 0)
  {
    die("child died");
  }
  else
  {
    vsf_sysutil_exit(0);
  }
}

variable_types: struct vsf_sysutil_wait_retval { int PRIVATE_HANDS_OFF_syscall_retval; int PRIVATE_HANDS_OFF_exit_status; }


decompiled_code:
__int64 __fastcall prepare_child(__int64 a1)
{
__int64 result; // rax

vsf_sysutil_dupfd2(a1, 0LL);
vsf_sysutil_dupfd2((unsigned int)a1, 1LL);
result = vsf_sysutil_dupfd2((unsigned int)a1, 2LL);
if ( (int)a1 > 2 )
result = vsf_sysutil_close((unsigned int)a1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
__int64 result; // rax

vsf_sysutil_dupfd2(a1, 0LL);
vsf_sysutil_dupfd2((unsigned int)a1, 1LL);
result = vsf_sysutil_dupfd2((unsigned int)a1, 2LL);
if ( (int)a1 > 2 )
result = vsf_sysutil_close((unsigned int)a1);
return result;
}

original_code:
static void
prepare_child(int new_client_sock)
{
  vsf_sysutil_dupfd2(new_client_sock, 0);
  vsf_sysutil_dupfd2(new_client_sock, 1);
  vsf_sysutil_dupfd2(new_client_sock, 2);
  if (new_client_sock > 2)
  {
    vsf_sysutil_close(new_client_sock);
  }
}


decompiled_code:
__int64 __fastcall vsf_secbuf_free(unsigned __int64 *a1)
{
unsigned __int64 v1; // rbp
__int64 result; // rax
unsigned __int64 v3; // rdx
unsigned int *v4; // rbp

v1 = *a1;
result = vsf_sysutil_getpagesize();
if ( v1 )
{
v3 = v1 % (unsigned int)result;
if ( v3 )
v1 -= v3;
v4 = (unsigned int *)(v1 - (unsigned int)result);
vsf_sysutil_memprotect(v4, (unsigned int)result, 1LL);
result = vsf_sysutil_memunmap(v4, *v4);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int64 *a1)
{
unsigned __int64 v1; // rbp
__int64 result; // rax
unsigned __int64 v3; // rdx
unsigned int *v4; // rbp

v1 = *a1;
result = vsf_sysutil_getpagesize();
if ( v1 )
{
v3 = v1 % (unsigned int)result;
if ( v3 )
v1 -= v3;
v4 = (unsigned int *)(v1 - (unsigned int)result);
vsf_sysutil_memprotect(v4, (unsigned int)result, 1LL);
result = vsf_sysutil_memunmap(v4, *v4);
}
return result;
}

original_code:
void
vsf_secbuf_free(char** p_ptr)
{
  unsigned int map_size;
  unsigned long page_offset;
  char* p_mmap = *p_ptr;
  unsigned int page_size = vsf_sysutil_getpagesize();
  if (p_mmap == 0)
  {
    return;
  }
  page_offset = (unsigned long) p_mmap % page_size;
  if (page_offset)
  {
    p_mmap -= page_offset;
  }
  p_mmap -= page_size;
  vsf_sysutil_memprotect(p_mmap, page_size, kVSFSysUtilMapProtReadOnly);
  map_size = *((unsigned int*)p_mmap);
  vsf_sysutil_memunmap(p_mmap, map_size);
}

canonical_original_code:
void vsf_secbuf_free(char **p_ptr)
{
  unsigned int map_size;
  unsigned long page_offset;
  char *p_mmap = *p_ptr;
  unsigned int page_size = vsf_sysutil_getpagesize();
  if (p_mmap == 0)
  {
    return;
  }
  page_offset = (unsigned long) p_mmap % page_size;
  if (page_offset)
  {
    p_mmap -= page_offset;
  }
  p_mmap -= page_size;
  vsf_sysutil_memprotect(p_mmap, page_size, kVSFSysUtilMapProtReadOnly);
  map_size = *((unsigned int *)p_mmap);
  vsf_sysutil_memunmap(p_mmap, map_size);
}


original_code:
struct ascii_to_bin_ret
vsf_ascii_ascii_to_bin(char* p_buf, unsigned int in_len, int prev_cr)
{
  struct ascii_to_bin_ret ret;
  unsigned int indexx = 0;
  unsigned int written = 0;
  char* p_out = p_buf + 1;
  ret.last_was_cr = 0;
  if (prev_cr && (!in_len || p_out[0] != '\n'))
  {
    p_buf[0] = '\r';
    ret.p_buf = p_buf;
    written++;
  }
  else
  {
    ret.p_buf = p_out;
  }
  while (indexx < in_len)
  {
    char the_char = p_buf[indexx + 1];
    if (the_char != '\r')
    {
      *p_out++ = the_char;
      written++;
    }
    else if (indexx == in_len - 1)
    {
      ret.last_was_cr = 1;
    }
    else if (p_buf[indexx + 2] != '\n')
    {
      *p_out++ = the_char;
      written++;
    }
    indexx++;
  }
  ret.stored = written;
  return ret;
}

canonical_original_code:
struct ascii_to_bin_ret vsf_ascii_ascii_to_bin(char *p_buf, unsigned int in_len, int prev_cr)
{
  struct ascii_to_bin_ret ret;
  unsigned int indexx = 0;
  unsigned int written = 0;
  char *p_out = p_buf + 1;
  ret.last_was_cr = 0;
  if (prev_cr && (!in_len || p_out[0] != '\n'))
  {
    p_buf[0] = '\r';
    ret.p_buf = p_buf;
    written++;
  }
  else
  {
    ret.p_buf = p_out;
  }
  while (indexx < in_len)
  {
    char the_char = p_buf[indexx + 1];
    if (the_char != '\r')
    {
      *p_out++ = the_char;
      written++;
    }
    else if (indexx == in_len - 1)
    {
      ret.last_was_cr = 1;
    }
    else if (p_buf[indexx + 2] != '\n')
    {
      *p_out++ = the_char;
      written++;
    }
    indexx++;
  }
  ret.stored = written;
  return ret;
}

variable_types: struct ascii_to_bin_ret { unsigned int stored; int last_was_cr; char *p_buf; }

variable_types:
written
unsigned int


original_code:
struct bin_to_ascii_ret
vsf_ascii_bin_to_ascii(const char* p_in,
                       char* p_out,
                       unsigned int in_len,
                       int prev_cr)
{
  struct bin_to_ascii_ret ret = { 0, 0 };
  unsigned int indexx = 0;
  unsigned int written = 0;
  char last_char = 0;
  if (prev_cr)
  {
    last_char = '\r';
    ret.last_was_cr = 1;
  }
  while (indexx < in_len)
  {
    char the_char = p_in[indexx];
    if (the_char == '\n' && last_char != '\r')
    {
      *p_out++ = '\r';
      written++;
    }
    *p_out++ = the_char;
    written++;
    indexx++;
    last_char = the_char;
    if (the_char == '\r')
    {
      ret.last_was_cr = 1;
    }
    else
    {
      ret.last_was_cr = 0;
    }
  }
  ret.stored = written;
  return ret;
}

canonical_original_code:
struct bin_to_ascii_ret vsf_ascii_bin_to_ascii(char *p_in, char *p_out, unsigned int in_len, int prev_cr)
{
  struct bin_to_ascii_ret ret = { 0, 0 };
  unsigned int indexx = 0;
  unsigned int written = 0;
  char last_char = 0;
  if (prev_cr)
  {
    last_char = '\r';
    ret.last_was_cr = 1;
  }
  while (indexx < in_len)
  {
    char the_char = p_in[indexx];
    if (the_char == '\n' && last_char != '\r')
    {
      *p_out++ = '\r';
      written++;
    }
    *p_out++ = the_char;
    written++;
    indexx++;
    last_char = the_char;
    if (the_char == '\r')
    {
      ret.last_was_cr = 1;
    }
    else
    {
      ret.last_was_cr = 0;
    }
  }
  ret.stored = written;
  return ret;
}

variable_types: struct bin_to_ascii_ret { unsigned int stored; int last_was_cr; }


decompiled_code:
_BOOL8 __fastcall vsf_access_check_file(__int64 a1)
{
_BOOL8 result; // rax
int v2; // er8
int v3[6]; // [rsp+0h] [rbp-18h] BYREF

result = 1LL;
v3[0] = 0;
if ( tunable_deny_file )
{
if ( (unsigned int)str_isempty(&s_access_str_1) )
str_alloc_text(&s_access_str_1, tunable_deny_file);
v2 = vsf_filename_passes_filter(a1, &s_access_str_1, v3);
result = 0LL;
if ( !v2 )
result = (unsigned int)str_locate_str(a1, &s_access_str_1) == 0;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(__int64 a1)
{
_BOOL8 result; // rax
int v2; // er8
int v3[6]; // [rsp+0h] [rbp-18h] BYREF

result = 1LL;
v3[0] = 0;
if ( tunable_deny_file )
{
if ( (unsigned int)str_isempty(&s_access_str_1) )
str_alloc_text(&s_access_str_1, tunable_deny_file);
v2 = vsf_filename_passes_filter(a1, &s_access_str_1, v3);
result = 0LL;
if ( !v2 )
result = (unsigned int)str_locate_str(a1, &s_access_str_1) == 0;
}
return result;
}

original_code:
int
vsf_access_check_file(const struct mystr* p_filename_str)
{
  static struct mystr s_access_str;
  unsigned int iters = 0;
  if (!tunable_deny_file)
  {
    return 1;
  }
  if (str_isempty(&s_access_str))
  {
    str_alloc_text(&s_access_str, tunable_deny_file);
  }
  if (vsf_filename_passes_filter(p_filename_str, &s_access_str, &iters))
  {
    return 0;
  }
  else
  {
    struct str_locate_result loc_res =
      str_locate_str(p_filename_str, &s_access_str);
    if (loc_res.found)
    {
      return 0;
    }
  }
  return 1;
}

canonical_original_code:
int vsf_access_check_file(struct mystr *p_filename_str)
{
  static struct mystr s_access_str;
  unsigned int iters = 0;
  if (!tunable_deny_file)
  {
    return 1;
  }
  if (str_isempty(&s_access_str))
  {
    str_alloc_text(&s_access_str, tunable_deny_file);
  }
  if (vsf_filename_passes_filter(p_filename_str, &s_access_str, &iters))
  {
    return 0;
  }
  else
  {
    struct str_locate_result loc_res = str_locate_str(p_filename_str, &s_access_str);
    if (loc_res.found)
    {
      return 0;
    }
  }
  return 1;
}

variable_types: struct mystr { char *PRIVATE_HANDS_OFF_p_buf; unsigned int PRIVATE_HANDS_OFF_len; unsigned int PRIVATE_HANDS_OFF_alloc_bytes; } *

variable_types:
iters
unsigned int

variable_types: struct str_locate_result { int found; unsigned int index; char char_found; }


decompiled_code:
_BOOL8 __fastcall vsf_access_check_file_visible(__int64 a1)
{
_BOOL8 result; // rax
int v2; // er8
int v3[6]; // [rsp+0h] [rbp-18h] BYREF

result = 1LL;
v3[0] = 0;
if ( tunable_hide_file )
{
if ( (unsigned int)str_isempty(&s_access_str_0) )
str_alloc_text(&s_access_str_0, tunable_hide_file);
v2 = vsf_filename_passes_filter(a1, &s_access_str_0, v3);
result = 0LL;
if ( !v2 )
result = (unsigned int)str_locate_str(a1, &s_access_str_0) == 0;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(__int64 a1)
{
_BOOL8 result; // rax
int v2; // er8
int v3[6]; // [rsp+0h] [rbp-18h] BYREF

result = 1LL;
v3[0] = 0;
if ( tunable_hide_file )
{
if ( (unsigned int)str_isempty(&s_access_str_0) )
str_alloc_text(&s_access_str_0, tunable_hide_file);
v2 = vsf_filename_passes_filter(a1, &s_access_str_0, v3);
result = 0LL;
if ( !v2 )
result = (unsigned int)str_locate_str(a1, &s_access_str_0) == 0;
}
return result;
}

original_code:
int
vsf_access_check_file_visible(const struct mystr* p_filename_str)
{
  static struct mystr s_access_str;
  unsigned int iters = 0;
  if (!tunable_hide_file)
  {
    return 1;
  }
  if (str_isempty(&s_access_str))
  {
    str_alloc_text(&s_access_str, tunable_hide_file);
  }
  if (vsf_filename_passes_filter(p_filename_str, &s_access_str, &iters))
  {
    return 0;
  }
  else
  {
    struct str_locate_result loc_res =
      str_locate_str(p_filename_str, &s_access_str);
    if (loc_res.found)
    {
      return 0;
    }
  }
  return 1;
}

canonical_original_code:
int vsf_access_check_file_visible(struct mystr *p_filename_str)
{
  static struct mystr s_access_str;
  unsigned int iters = 0;
  if (!tunable_hide_file)
  {
    return 1;
  }
  if (str_isempty(&s_access_str))
  {
    str_alloc_text(&s_access_str, tunable_hide_file);
  }
  if (vsf_filename_passes_filter(p_filename_str, &s_access_str, &iters))
  {
    return 0;
  }
  else
  {
    struct str_locate_result loc_res = str_locate_str(p_filename_str, &s_access_str);
    if (loc_res.found)
    {
      return 0;
    }
  }
  return 1;
}

variable_types: struct mystr { char *PRIVATE_HANDS_OFF_p_buf; unsigned int PRIVATE_HANDS_OFF_len; unsigned int PRIVATE_HANDS_OFF_alloc_bytes; }

user_defined_types: struct str_locate_result { int found; unsigned int index; char char_found; }


decompiled_code:
__int64 vsf_tcp_wrapper_ok()
{
die("tcp_wrappers is set to YES but no tcp wrapper support compiled in");
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
die("tcp_wrappers is set to YES but no tcp wrapper support compiled in");
return 0LL;
}

original_code:
int
vsf_tcp_wrapper_ok(int remote_fd)
{
  (void) remote_fd;
  die("tcp_wrappers is set to YES but no tcp wrapper support compiled in");
  return 0;
}


decompiled_code:
__int64 __fastcall str_netfd_write(__int64 a1, unsigned int a2)
{
int v2; // ebx
unsigned int v3; // ebp
__int64 result; // rax

v2 = str_getlen();
if ( !v2 )
bug("zero str_len in str_netfd_write");
v3 = str_write_loop(a1, a2);
if ( (unsigned int)vsf_sysutil_retval_is_error(v3) )
result = 0xFFFFFFFFLL;
else
result = (unsigned int)-(v3 != v2);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned int a2)
{
int v2; // ebx
unsigned int v3; // ebp
__int64 result; // rax

v2 = str_getlen();
if ( !v2 )
bug("zero str_len in str_netfd_write");
v3 = str_write_loop(a1, a2);
if ( (unsigned int)vsf_sysutil_retval_is_error(v3) )
result = 0xFFFFFFFFLL;
else
result = (unsigned int)-(v3 != v2);
return result;
}

original_code:
int
str_netfd_write(const struct mystr* p_str, int fd)
{
  int ret = 0;
  int retval;
  unsigned int str_len = str_getlen(p_str);
  if (str_len == 0)
  {
    bug("zero str_len in str_netfd_write");
  }
  retval = str_write_loop(p_str, fd);
  if (vsf_sysutil_retval_is_error(retval) || (unsigned int) retval != str_len)
  {
    ret = -1;
  }
  return ret;
}

canonical_original_code:
int str_netfd_write(struct mystr *p_str, int fd)
{
  int ret = 0;
  int retval;
  unsigned int str_len = str_getlen(p_str);
  if (str_len == 0)
  {
    bug("zero str_len in str_netfd_write");
  }
  retval = str_write_loop(p_str, fd);
  if (vsf_sysutil_retval_is_error(retval) || (unsigned int) retval != str_len)
  {
    ret = -1;
  }
  return ret;
}

variable_types: fd int

variable_types: ret int

variable_types: retval int


decompiled_code:
__int64 __fastcall str_netfd_read(__int64 a1, unsigned int a2, unsigned int a3)
{
unsigned int v4; // er12

str_reserve(a1, a3);
str_trunc(a1, a3);
v4 = str_read_loop(a1, a2);
if ( (unsigned int)vsf_sysutil_retval_is_error(v4) || v4 != a3 )
v4 = -1;
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned int a2, unsigned int a3)
{
unsigned int v4; // er12

str_reserve(a1, a3);
str_trunc(a1, a3);
v4 = str_read_loop(a1, a2);
if ( (unsigned int)vsf_sysutil_retval_is_error(v4) || v4 != a3 )
v4 = -1;
return v4;
}

original_code:
int
str_netfd_read(struct mystr* p_str, int fd, unsigned int len)
{
  int retval;
  str_reserve(p_str, len);
  str_trunc(p_str, len);
  retval = str_read_loop(p_str, fd);
  if (vsf_sysutil_retval_is_error(retval) || (unsigned int) retval != len)
  {
    return -1;
  }
  return retval;
}

canonical_original_code:
int str_netfd_read(struct mystr *p_str, int fd, unsigned int len)
{
  int retval;
  str_reserve(p_str, len);
  str_trunc(p_str, len);
  retval = str_read_loop(p_str, fd);
  if (vsf_sysutil_retval_is_error(retval) || (unsigned int) retval != len)
  {
    return -1;
  }
  return retval;
}

variable_types:
len
unsigned int


decompiled_code:
__int64 __fastcall hash_alloc(int a1, int a2, int a3, __int64 a4)
{
__int64 v6; // rax
__int64 v7; // r12
__int64 v8; // rbp
__int64 v9; // rax

v6 = vsf_sysutil_malloc(32LL);
*(_DWORD *)v6 = a1;
v7 = v6;
*(_DWORD *)(v6 + 4) = a2;
*(_DWORD *)(v6 + 8) = a3;
*(_QWORD *)(v6 + 16) = a4;
v8 = (unsigned int)(8 * a1);
v9 = vsf_sysutil_malloc(v8);
*(_QWORD *)(v7 + 24) = v9;
vsf_sysutil_memclr(v9, (unsigned int)v8);
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, int a2, int a3, __int64 a4)
{
__int64 v6; // rax
__int64 v7; // r12
__int64 v8; // rbp
__int64 v9; // rax

v6 = vsf_sysutil_malloc(32LL);
*(_DWORD *)v6 = a1;
v7 = v6;
*(_DWORD *)(v6 + 4) = a2;
*(_DWORD *)(v6 + 8) = a3;
*(_QWORD *)(v6 + 16) = a4;
v8 = (unsigned int)(8 * a1);
v9 = vsf_sysutil_malloc(v8);
*(_QWORD *)(v7 + 24) = v9;
vsf_sysutil_memclr(v9, (unsigned int)v8);
return v7;
}

original_code:
struct hash*
hash_alloc(unsigned int buckets, unsigned int key_size,
           unsigned int value_size, hashfunc_t hash_func)
{
  unsigned int size;
  struct hash* p_hash = vsf_sysutil_malloc(sizeof(*p_hash));
  p_hash->buckets = buckets;
  p_hash->key_size = key_size;
  p_hash->value_size = value_size;
  p_hash->hash_func = hash_func;
  size = sizeof(struct hash_node*) * buckets;
  p_hash->p_nodes = vsf_sysutil_malloc(size);
  vsf_sysutil_memclr(p_hash->p_nodes, size);
  return p_hash;
}

canonical_original_code:
struct hash *hash_alloc(unsigned int buckets, unsigned int key_size, unsigned int value_size, unsigned int (*hash_func)(unsigned int, void *))
{
  unsigned int size;
  struct hash *p_hash = vsf_sysutil_malloc(sizeof(*p_hash));
  p_hash->buckets = buckets;
  p_hash->key_size = key_size;
  p_hash->value_size = value_size;
  p_hash->hash_func = hash_func;
  size = sizeof(struct hash_node *) * buckets;
  p_hash->p_nodes = vsf_sysutil_malloc(size);
  vsf_sysutil_memclr(p_hash->p_nodes, size);
  return p_hash;
}

variable_types:
buckets
unsigned int

variable_types:
size
unsigned int

variable_types: struct hash { unsigned int buckets; unsigned int key_size; unsigned int value_size; unsigned int (*hash_func)(unsigned int, void *); struct hash_node { void *p_key; void *p_value; struct hash_node *p_prev; struct hash_node *p_next; } **p_nodes; } *

user_defined_types: struct hash { unsigned int buckets; unsigned int key_size; unsigned int value_size; unsigned int (*hash_func)(unsigned int, void *); struct hash_node **p_nodes; }


decompiled_code:
__int64 __fastcall hash_get_bucket(unsigned int *a1)
{
unsigned int v1; // eax
__int64 v2; // rbx

v1 = (*((__int64 (__fastcall **)(_QWORD))a1 + 2))(*a1);
v2 = v1;
if ( *a1 > v1 )
return *((_QWORD *)a1 + 3) + 8LL * v1;
bug("bad bucket lookup");
return *((_QWORD *)a1 + 3) + 8 * v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int *a1)
{
unsigned int v1; // eax
__int64 v2; // rbx

v1 = (*((__int64 (__fastcall **)(_QWORD))a1 + 2))(*a1);
v2 = v1;
if ( *a1 > v1 )
return *((_QWORD *)a1 + 3) + 8LL * v1;
bug("bad bucket lookup");
return *((_QWORD *)a1 + 3) + 8 * v2;
}

original_code:
struct hash_node**
hash_get_bucket(struct hash* p_hash, void* p_key)
{
  unsigned int bucket = (*p_hash->hash_func)(p_hash->buckets, p_key);
  if (bucket >= p_hash->buckets)
  {
    bug("bad bucket lookup");
  }
  return &(p_hash->p_nodes[bucket]);
}

canonical_original_code:
struct hash_node **hash_get_bucket(struct hash *p_hash, void *p_key)
{
  unsigned int bucket = (*p_hash->hash_func)(p_hash->buckets, p_key);
  if (bucket >= p_hash->buckets)
  {
    bug("bad bucket lookup");
  }
  return &(p_hash->p_nodes[bucket]);
}

variable_types: struct hash { unsigned int buckets; unsigned int key_size; unsigned int value_size; unsigned int (*hash_func)(unsigned int, void *); struct hash_node **p_nodes; } *

variable_types:
bucket
unsigned int

return_type: struct hash_node { void *p_key; void *p_value; struct hash_node *p_prev; struct hash_node *p_next; } **


decompiled_code:
__int64 __fastcall hash_add_entry(unsigned int *a1, __int64 a2, __int64 a3)
{
__int64 *v5; // r13
__int64 v6; // rax
__int64 v7; // rdi
_QWORD *v8; // rbx
__int64 v9; // rax
__int64 v10; // rdx
__int64 v11; // rax
__int64 v12; // rdx
__int64 result; // rax

if ( hash_lookup_entry(a1, a2) )
bug("duplicate hash key");
v5 = (__int64 *)hash_get_bucket(a1);
v6 = vsf_sysutil_malloc(32LL);
v7 = a1[1];
*(_QWORD *)(v6 + 16) = 0LL;
v8 = (_QWORD *)v6;
*(_QWORD *)(v6 + 24) = 0LL;
v9 = vsf_sysutil_malloc(v7);
v10 = a1[1];
*v8 = v9;
vsf_sysutil_memcpy(v9, a2, v10);
v11 = vsf_sysutil_malloc(a1[2]);
v12 = a1[2];
v8[1] = v11;
vsf_sysutil_memcpy(v11, a3, v12);
result = *v5;
if ( *v5 )
{
v8[3] = result;
*(_QWORD *)(result + 16) = v8;
}
*v5 = (__int64)v8;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int *a1, __int64 a2, __int64 a3)
{
__int64 *v5; // r13
__int64 v6; // rax
__int64 v7; // rdi
_QWORD *v8; // rbx
__int64 v9; // rax
__int64 v10; // rdx
__int64 v11; // rax
__int64 v12; // rdx
__int64 result; // rax

if ( hash_lookup_entry(a1, a2) )
bug("duplicate hash key");
v5 = (__int64 *)func1(a1);
v6 = vsf_sysutil_malloc(32LL);
v7 = a1[1];
*(_QWORD *)(v6 + 16) = 0LL;
v8 = (_QWORD *)v6;
*(_QWORD *)(v6 + 24) = 0LL;
v9 = vsf_sysutil_malloc(v7);
v10 = a1[1];
*v8 = v9;
vsf_sysutil_memcpy(v9, a2, v10);
v11 = vsf_sysutil_malloc(a1[2]);
v12 = a1[2];
v8[1] = v11;
vsf_sysutil_memcpy(v11, a3, v12);
result = *v5;
if ( *v5 )
{
v8[3] = result;
*(_QWORD *)(result + 16) = v8;
}
*v5 = (__int64)v8;
return result;
}

original_code:
void
hash_add_entry(struct hash* p_hash, void* p_key, void* p_value)
{
  struct hash_node** p_bucket;
  struct hash_node* p_new_node;
  if (hash_lookup_entry(p_hash, p_key))
  {
    bug("duplicate hash key");
  }
  p_bucket = hash_get_bucket(p_hash, p_key);
  p_new_node = vsf_sysutil_malloc(sizeof(*p_new_node));
  p_new_node->p_prev = 0;
  p_new_node->p_next = 0;
  p_new_node->p_key = vsf_sysutil_malloc(p_hash->key_size);
  vsf_sysutil_memcpy(p_new_node->p_key, p_key, p_hash->key_size);
  p_new_node->p_value = vsf_sysutil_malloc(p_hash->value_size);
  vsf_sysutil_memcpy(p_new_node->p_value, p_value, p_hash->value_size);
  if (!*p_bucket)
  {
    *p_bucket = p_new_node;
  }
  else
  {
    p_new_node->p_next = *p_bucket;
    (*p_bucket)->p_prev = p_new_node;
    *p_bucket = p_new_node;
  }
}

canonical_original_code:
void hash_add_entry(struct hash *p_hash, void *p_key, void *p_value)
{
  struct hash_node **p_bucket;
  struct hash_node *p_new_node;
  if (hash_lookup_entry(p_hash, p_key))
  {
    bug("duplicate hash key");
  }
  p_bucket = hash_get_bucket(p_hash, p_key);
  p_new_node = vsf_sysutil_malloc(sizeof(*p_new_node));
  p_new_node->p_prev = 0;
  p_new_node->p_next = 0;
  p_new_node->p_key = vsf_sysutil_malloc(p_hash->key_size);
  vsf_sysutil_memcpy(p_new_node->p_key, p_key, p_hash->key_size);
  p_new_node->p_value = vsf_sysutil_malloc(p_hash->value_size);
  vsf_sysutil_memcpy(p_new_node->p_value, p_value, p_hash->value_size);
  if (!*p_bucket)
  {
    *p_bucket = p_new_node;
  }
  else
  {
    p_new_node->p_next = *p_bucket;
    (*p_bucket)->p_prev = p_new_node;
    *p_bucket = p_new_node;
  }
}

variable_types: struct hash_node { void *p_key; void *p_value; struct hash_node *p_prev; struct hash_node *p_next; } **


decompiled_code:
__int64 __fastcall hash_free_entry(unsigned int *a1, __int64 a2)
{
_QWORD *v2; // rbp
__int64 v3; // rax
__int64 v4; // rax

v2 = hash_get_node_by_key(a1, a2);
if ( !v2 )
bug("hash node not found");
vsf_sysutil_free(*v2);
vsf_sysutil_free(v2[1]);
v3 = v2[2];
if ( v3 )
*(_QWORD *)(v3 + 24) = v2[3];
else
*(_QWORD *)hash_get_bucket(a1) = v2[3];
v4 = v2[3];
if ( v4 )
*(_QWORD *)(v4 + 16) = v2[2];
return vsf_sysutil_free(v2);
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int *a1, __int64 a2)
{
_QWORD *v2; // rbp
__int64 v3; // rax
__int64 v4; // rax

v2 = hash_get_node_by_key(a1, a2);
if ( !v2 )
bug("hash node not found");
vsf_sysutil_free(*v2);
vsf_sysutil_free(v2[1]);
v3 = v2[2];
if ( v3 )
*(_QWORD *)(v3 + 24) = v2[3];
else
*(_QWORD *)func1(a1) = v2[3];
v4 = v2[3];
if ( v4 )
*(_QWORD *)(v4 + 16) = v2[2];
return vsf_sysutil_free(v2);
}

original_code:
void
hash_free_entry(struct hash* p_hash, void* p_key)
{
  struct hash_node* p_node = hash_get_node_by_key(p_hash, p_key);
  if (!p_node)
  {
    bug("hash node not found");
  }
  vsf_sysutil_free(p_node->p_key);
  vsf_sysutil_free(p_node->p_value);
  if (p_node->p_prev)
  {
    p_node->p_prev->p_next = p_node->p_next;
  }
  else
  {
    struct hash_node** p_bucket = hash_get_bucket(p_hash, p_key);
    *p_bucket = p_node->p_next;
  }
  if (p_node->p_next)
  {
    p_node->p_next->p_prev = p_node->p_prev;
  }
  vsf_sysutil_free(p_node);
}

canonical_original_code:
void hash_free_entry(struct hash *p_hash, void *p_key)
{
  struct hash_node *p_node = hash_get_node_by_key(p_hash, p_key);
  if (!p_node)
  {
    bug("hash node not found");
  }
  vsf_sysutil_free(p_node->p_key);
  vsf_sysutil_free(p_node->p_value);
  if (p_node->p_prev)
  {
    p_node->p_prev->p_next = p_node->p_next;
  }
  else
  {
    struct hash_node **p_bucket = hash_get_bucket(p_hash, p_key);
    *p_bucket = p_node->p_next;
  }
  if (p_node->p_next)
  {
    p_node->p_next->p_prev = p_node->p_prev;
  }
  vsf_sysutil_free(p_node);
}

variable_types: struct hash_node { void *p_key; void *p_value; struct hash_node *p_prev; struct hash_node *p_next; } *


decompiled_code:
__int64 __fastcall vsf_pid_write_pid_file(int a1)
{
__int64 v1; // rbp
unsigned int v2; // er12
__int64 v3; // rax
__int64 v5[5]; // [rsp+0h] [rbp-28h] BYREF

v5[0] = 0LL;
v5[1] = 0LL;
v1 = (unsigned int)vsf_sysutil_create_or_open_file(tunable_pid_file, 384LL);
if ( (unsigned int)vsf_sysutil_retval_is_error(v1) )
die2("cannot open pidfile:", tunable_pid_file);
str_alloc_ulong(v5, a1);
str_append_text(v5, "\n");
v2 = str_getlen(v5);
v3 = str_getbuf(v5);
vsf_sysutil_write((unsigned int)v1, v3, v2);
if ( (unsigned int)vsf_sysutil_retval_is_error((unsigned int)v1) )
die2("failed write to pidfile:", tunable_pid_file);
return vsf_sysutil_close((unsigned int)v1);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
__int64 v1; // rbp
unsigned int v2; // er12
__int64 v3; // rax
__int64 v5[5]; // [rsp+0h] [rbp-28h] BYREF

v5[0] = 0LL;
v5[1] = 0LL;
v1 = (unsigned int)vsf_sysutil_create_or_open_file(tunable_pid_file, 384LL);
if ( (unsigned int)vsf_sysutil_retval_is_error(v1) )
die2("cannot open pidfile:", tunable_pid_file);
str_alloc_ulong(v5, a1);
str_append_text(v5, "\n");
v2 = str_getlen(v5);
v3 = str_getbuf(v5);
vsf_sysutil_write((unsigned int)v1, v3, v2);
if ( (unsigned int)vsf_sysutil_retval_is_error((unsigned int)v1) )
die2("failed write to pidfile:", tunable_pid_file);
return vsf_sysutil_close((unsigned int)v1);
}

original_code:
void
vsf_pid_write_pid_file(int pid)
{
  int pidfile;
  int retval;
  struct mystr pid_str = { (void*)0, 0, 0 };
  pidfile = vsf_sysutil_create_or_open_file(tunable_pid_file, 0600);
  if (vsf_sysutil_retval_is_error(pidfile))
  {
    die2("cannot open pidfile:", tunable_pid_file);
  }
  str_alloc_ulong(&pid_str, (unsigned long)pid);
  str_append_text(&pid_str, "\n");
  retval = vsf_sysutil_write(pidfile, str_getbuf(&pid_str), str_getlen(&pid_str));
  if (vsf_sysutil_retval_is_error(pidfile))
  {
    die2("failed write to pidfile:", tunable_pid_file);
  }
  vsf_sysutil_close(pidfile);
}

variable_types: pid int

variable_types: pidfile int


decompiled_code:
__int64 __fastcall ipv6_parse_main(__int64 a1)
{
unsigned int v1; // er12

while ( 1 )
{
str_copy(&s_lhs_str_4);
v1 = str_isempty(&s_lhs_str_4);
if ( v1 )
break;
str_split_char(&s_lhs_str_4, &s_rhs_str_3, 58LL);
if ( (unsigned int)str_isempty(&s_lhs_str_4) )
return v1;
if ( (unsigned int)str_locate_char(&s_lhs_str_4, 46LL) )
{
if ( !(unsigned int)ipv4_parse_dotquad_constprop_0(a1) )
return v1;
}
else if ( !(unsigned int)ipv6_parse_hex_constprop_0(a1) )
{
return v1;
}
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
unsigned int v1; // er12

while ( 1 )
{
str_copy(&s_lhs_str_4);
v1 = str_isempty(&s_lhs_str_4);
if ( v1 )
break;
str_split_char(&s_lhs_str_4, &s_rhs_str_3, 58LL);
if ( (unsigned int)str_isempty(&s_lhs_str_4) )
return v1;
if ( (unsigned int)str_locate_char(&s_lhs_str_4, 46LL) )
{
if ( !(unsigned int)func0(a1) )
return v1;
}
else if ( !(unsigned int)func1(a1) )
{
return v1;
}
}
return 1LL;
}

original_code:
static int
ipv6_parse_main(struct mystr* p_out_str, const struct mystr* p_in_str)
{
  static struct mystr s_lhs_str;
  static struct mystr s_rhs_str;
  struct str_locate_result loc_ret;
  str_copy(&s_lhs_str, p_in_str);
  while (!str_isempty(&s_lhs_str))
  {
    str_split_char(&s_lhs_str, &s_rhs_str, ':');
    if (str_isempty(&s_lhs_str))
    {
      return 0;
    }
    loc_ret = str_locate_char(&s_lhs_str, '.');
    if (loc_ret.found)
    {
      if (!ipv4_parse_dotquad(p_out_str, &s_lhs_str))
      {
        return 0;
      }
    }
    else if (!ipv6_parse_hex(p_out_str, &s_lhs_str))
    {
      return 0;
    }
    str_copy(&s_lhs_str, &s_rhs_str);
  }
  return 1;
}

canonical_original_code:
static int ipv6_parse_main(struct mystr *p_out_str, struct mystr *p_in_str)
{
  static struct mystr s_lhs_str;
  static struct mystr s_rhs_str;
  struct str_locate_result loc_ret;
  str_copy(&s_lhs_str, p_in_str);
  while (!str_isempty(&s_lhs_str))
  {
    str_split_char(&s_lhs_str, &s_rhs_str, ':');
    if (str_isempty(&s_lhs_str))
    {
      return 0;
    }
    loc_ret = str_locate_char(&s_lhs_str, '.');
    if (loc_ret.found)
    {
      if (!ipv4_parse_dotquad(p_out_str, &s_lhs_str))
      {
        return 0;
      }
    }
    else if (!ipv6_parse_hex(p_out_str, &s_lhs_str))
    {
      return 0;
    }
    str_copy(&s_lhs_str, &s_rhs_str);
  }
  return 1;
}

variable_types: struct mystr { char *PRIVATE_HANDS_OFF_p_buf; unsigned int PRIVATE_HANDS_OFF_len; unsigned int PRIVATE_HANDS_OFF_alloc_bytes; } *


decompiled_code:
__int64 vsf_sysutil_parse_ipv6()
{
void *v0; // rsi
int v1; // ebx
int v2; // edx
int v3; // eax
__int64 v4; // rbp
__int64 v5; // rbx
__int64 v6; // rax

str_empty(&s_ret_8);
str_empty(&s_rhs_ret_7);
str_copy(&s_lhs_str_6);
str_split_text(&s_lhs_str_6, &s_rhs_str_5, &unk_4F0);
if ( !(unsigned int)ipv6_parse_main((__int64)&s_ret_8) )
return 0LL;
v0 = &s_rhs_str_5;
if ( !(unsigned int)ipv6_parse_main((__int64)&s_rhs_ret_7) )
return 0LL;
v1 = str_getlen(&s_ret_8);
v2 = str_getlen(&s_rhs_ret_7);
v3 = v1 + v2;
if ( (unsigned int)(v1 + v2) > 0x10 )
return 0LL;
if ( v2 )
{
v4 = (unsigned int)(15 - v3);
if ( v3 != 16 )
{
v5 = 0LL;
do
{
str_append_char(&s_ret_8, 0LL);
v6 = v5++;
}
while ( v4 != v6 );
}
v0 = &s_rhs_ret_7;
str_append_str(&s_ret_8, &s_rhs_ret_7);
}
return str_getbuf(&s_ret_8, v0);
}

canonical_decompiled_code:
__int64 func3()
{
void *v0; // rsi
int v1; // ebx
int v2; // edx
int v3; // eax
__int64 v4; // rbp
__int64 v5; // rbx
__int64 v6; // rax

str_empty(&s_ret_8);
str_empty(&s_rhs_ret_7);
str_copy(&s_lhs_str_6);
str_split_text(&s_lhs_str_6, &s_rhs_str_5, &unk_4F0);
if ( !(unsigned int)func2((__int64)&s_ret_8) )
return 0LL;
v0 = &s_rhs_str_5;
if ( !(unsigned int)func2((__int64)&s_rhs_ret_7) )
return 0LL;
v1 = str_getlen(&s_ret_8);
v2 = str_getlen(&s_rhs_ret_7);
v3 = v1 + v2;
if ( (unsigned int)(v1 + v2) > 0x10 )
return 0LL;
if ( v2 )
{
v4 = (unsigned int)(15 - v3);
if ( v3 != 16 )
{
v5 = 0LL;
do
{
str_append_char(&s_ret_8, 0LL);
v6 = v5++;
}
while ( v4 != v6 );
}
v0 = &s_rhs_ret_7;
str_append_str(&s_ret_8, &s_rhs_ret_7);
}
return str_getbuf(&s_ret_8, v0);
}

original_code:
const unsigned char*
vsf_sysutil_parse_ipv6(const struct mystr* p_str)
{
  static struct mystr s_ret;
  static struct mystr s_rhs_ret;
  static struct mystr s_lhs_str;
  static struct mystr s_rhs_str;
  unsigned int lhs_len;
  unsigned int rhs_len;
  str_empty(&s_ret);
  str_empty(&s_rhs_ret);
  str_copy(&s_lhs_str, p_str);
  str_split_text(&s_lhs_str, &s_rhs_str, "::");
  if (!ipv6_parse_main(&s_ret, &s_lhs_str))
  {
    return 0;
  }
  if (!ipv6_parse_main(&s_rhs_ret, &s_rhs_str))
  {
    return 0;
  }
  lhs_len = str_getlen(&s_ret);
  rhs_len = str_getlen(&s_rhs_ret);
  if (lhs_len + rhs_len > 16)
  {
    return 0;
  }
  if (rhs_len > 0)
  {
    unsigned int add_nulls = 16 - (lhs_len + rhs_len);
    while (add_nulls--)
    {
      str_append_char(&s_ret, '\0');
    }
    str_append_str(&s_ret, &s_rhs_ret);
  }
  return (const unsigned char*) str_getbuf(&s_ret);
}

canonical_original_code:
unsigned char *vsf_sysutil_parse_ipv6(struct mystr *p_str)
{
  static struct mystr s_ret;
  static struct mystr s_rhs_ret;
  static struct mystr s_lhs_str;
  static struct mystr s_rhs_str;
  unsigned int lhs_len;
  unsigned int rhs_len;
  str_empty(&s_ret);
  str_empty(&s_rhs_ret);
  str_copy(&s_lhs_str, p_str);
  str_split_text(&s_lhs_str, &s_rhs_str, "::");
  if (!ipv6_parse_main(&s_ret, &s_lhs_str))
  {
    return 0;
  }
  if (!ipv6_parse_main(&s_rhs_ret, &s_rhs_str))
  {
    return 0;
  }
  lhs_len = str_getlen(&s_ret);
  rhs_len = str_getlen(&s_rhs_ret);
  if (lhs_len + rhs_len > 16)
  {
    return 0;
  }
  if (rhs_len > 0)
  {
    unsigned int add_nulls = 16 - (lhs_len + rhs_len);
    while (add_nulls--)
    {
      str_append_char(&s_ret, '\0');
    }
    str_append_str(&s_ret, &s_rhs_ret);
  }
  return (unsigned char *) str_getbuf(&s_ret);
}

return_type: unsigned char *


decompiled_code:
__int64 __fastcall vsf_sysutil_parse_uchar_string_sep(__int64 a1, char a2, __int64 a3, unsigned int a4)
{
__int64 v4; // r14
unsigned int v5; // er13
__int64 v7; // rbx
unsigned int v8; // eax

v4 = a4;
v5 = a4 - 1;
v7 = 0LL;
str_copy(&s_tmp_str_1);
if ( (_DWORD)v4 )
{
do
{
str_split_char(&s_tmp_str_1, &s_rhs_sep_str_0, (unsigned int)a2);
if ( (unsigned int)v7 >= v5 )
{
if ( (_DWORD)v7 == v5 && !(unsigned int)str_isempty(&s_rhs_sep_str_0) )
return 0LL;
}
else if ( (unsigned int)str_isempty(&s_rhs_sep_str_0) )
{
return 0LL;
}
v8 = str_atoi(&s_tmp_str_1);
if ( v8 > 0xFF )
return 0LL;
*(_BYTE *)(a3 + v7++) = v8;
str_copy(&s_tmp_str_1);
}
while ( v7 != v4 );
}
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, char a2, __int64 a3, unsigned int a4)
{
__int64 v4; // r14
unsigned int v5; // er13
__int64 v7; // rbx
unsigned int v8; // eax

v4 = a4;
v5 = a4 - 1;
v7 = 0LL;
str_copy(&s_tmp_str_1);
if ( (_DWORD)v4 )
{
do
{
str_split_char(&s_tmp_str_1, &s_rhs_sep_str_0, (unsigned int)a2);
if ( (unsigned int)v7 >= v5 )
{
if ( (_DWORD)v7 == v5 && !(unsigned int)str_isempty(&s_rhs_sep_str_0) )
return 0LL;
}
else if ( (unsigned int)str_isempty(&s_rhs_sep_str_0) )
{
return 0LL;
}
v8 = str_atoi(&s_tmp_str_1);
if ( v8 > 0xFF )
return 0LL;
*(_BYTE *)(a3 + v7++) = v8;
str_copy(&s_tmp_str_1);
}
while ( v7 != v4 );
}
return a3;
}

original_code:
const unsigned char*
vsf_sysutil_parse_uchar_string_sep(
  const struct mystr* p_str, char sep, unsigned char* p_items,
  unsigned int items)
{
  static struct mystr s_tmp_str;
  unsigned int i;
  str_copy(&s_tmp_str, p_str);
  for (i=0; i<items; i++)
  {
    static struct mystr s_rhs_sep_str;
    int this_number;
    str_split_char(&s_tmp_str, &s_rhs_sep_str, sep);
    if ( (i < (items-1) && str_isempty(&s_rhs_sep_str)) ||
         (i == (items-1) && !str_isempty(&s_rhs_sep_str)))
    {
      return 0;
    }
    this_number = str_atoi(&s_tmp_str);
    if (this_number < 0 || this_number > 255)
    {
      return 0;
    }
    p_items[i] = (unsigned char) this_number;
    str_copy(&s_tmp_str, &s_rhs_sep_str);
  }
  return p_items;
}

canonical_original_code:
unsigned char *vsf_sysutil_parse_uchar_string_sep(struct mystr *p_str, char sep, unsigned char *p_items, unsigned int items)
{
  static struct mystr s_tmp_str;
  unsigned int i;
  str_copy(&s_tmp_str, p_str);
  for (i=0; i<items; i++)
  {
    static struct mystr s_rhs_sep_str;
    int this_number;
    str_split_char(&s_tmp_str, &s_rhs_sep_str, sep);
    if ( (i < (items-1) && str_isempty(&s_rhs_sep_str)) ||
         (i == (items-1) && !str_isempty(&s_rhs_sep_str)))
    {
      return 0;
    }
    this_number = str_atoi(&s_tmp_str);
    if (this_number < 0 || this_number > 255)
    {
      return 0;
    }
    p_items[i] = (unsigned char) this_number;
    str_copy(&s_tmp_str, &s_rhs_sep_str);
  }
  return p_items;
}

variable_types: sep char

variable_types:
items
unsigned int

variable_types:
i
unsigned int


decompiled_code:
__int64 __fastcall vsf_sysutil_parse_ipv4(__int64 a1)
{
return vsf_sysutil_parse_uchar_string_sep(a1, 46, (__int64)&items_2, 4u);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return func4(a1, 46, (__int64)&items_2, 4u);
}

original_code:
const unsigned char*
vsf_sysutil_parse_ipv4(const struct mystr* p_str)
{
  static unsigned char items[4];
  return vsf_sysutil_parse_uchar_string_sep(p_str, '.', items, sizeof(items));
}

canonical_original_code:
unsigned char *vsf_sysutil_parse_ipv4(struct mystr *p_str)
{
  static unsigned char items[4];
  return vsf_sysutil_parse_uchar_string_sep(p_str, '.', items, sizeof(items));
}

variable_types:
items
unsigned char [4]


decompiled_code:
__int64 __fastcall vsf_filename_passes_filter(__int64 *a1, __int64 a2, _DWORD *a3)
{
int v3; // er13
char v6; // bp
unsigned int v7; // er12
unsigned __int64 v8; // rax
char v9; // dl
unsigned __int64 v10; // rbp
int v11; // eax
unsigned __int64 v12; // rax
unsigned __int64 v13; // r14
int v14; // eax
int v15; // eax
char v17; // [rsp+10h] [rbp-88h]
__int64 v18[2]; // [rsp+20h] [rbp-78h] BYREF
__int64 v19[2]; // [rsp+30h] [rbp-68h] BYREF
__int64 v20[2]; // [rsp+40h] [rbp-58h] BYREF
__int64 v21[2]; // [rsp+50h] [rbp-48h] BYREF
__int64 v22[7]; // [rsp+60h] [rbp-38h] BYREF

v3 = 1;
v18[0] = 0LL;
v18[1] = 0LL;
v19[0] = 0LL;
v19[1] = 0LL;
v20[0] = 0LL;
v20[1] = 0LL;
v21[0] = 0LL;
v21[1] = 0LL;
v22[0] = 0LL;
v22[1] = 0LL;
str_copy(v18);
v6 = 0;
str_copy(v19);
while ( 1 )
{
while ( 1 )
{
while ( 1 )
{
v7 = str_isempty(v18, a1);
if ( v7 || *a3 > 0x3E7u )
{
v15 = str_getlen(v19);
if ( v6 != 42 && v15 )
v7 = 0;
else
v7 = *a3 != 1000;
goto LABEL_25;
}
v8 = str_locate_chars(v18, &unk_BB7);
++*a3;
v17 = v9;
v10 = HIDWORD(v8);
if ( (_DWORD)v8 )
break;
a1 = v18;
str_copy(&s_match_needed_str_0);
str_empty(v18, v18);
if ( !(unsigned int)str_isempty(&s_match_needed_str_0, v18) )
{
v6 = 0;
goto LABEL_15;
}
v3 = 0;
v6 = 0;
}
str_left(v18, &s_match_needed_str_0, HIDWORD(v8));
str_mid_to_end(v18, v20, (unsigned int)(v10 + 1));
a1 = v20;
str_copy(v18);
v6 = v17;
if ( (unsigned int)str_isempty(&s_match_needed_str_0, v20) )
{
if ( v17 == 63 )
goto LABEL_19;
goto LABEL_7;
}
LABEL_15:
v12 = str_locate_str(v19, &s_match_needed_str_0);
v13 = HIDWORD(v12);
if ( !(_DWORD)v12 || HIDWORD(v12) && v3 )
goto LABEL_25;
v14 = str_getlen(&s_match_needed_str_0);
str_mid_to_end(v19, v20, (unsigned int)(v14 + v13));
a1 = v20;
str_copy(v19);
if ( v6 == 63 )
{
LABEL_19:
if ( (unsigned int)str_isempty(v19, v20) )
goto LABEL_25;
goto LABEL_11;
}
LABEL_7:
if ( v6 == 123 )
break;
v3 = 0;
}
if ( (unsigned int)str_locate_char(v18, 125LL) )
break;
if ( (unsigned int)str_isempty(v19, 125LL) )
goto LABEL_25;
v6 = str_get_char_at(v19, 0LL);
if ( v6 != 123 )
goto LABEL_25;
LABEL_11:
v3 = 1;
v11 = str_getlen(v19);
str_right(v19, v20, (unsigned int)(v11 - 1));
a1 = v20;
str_copy(v19);
}
str_split_char(v18, v20, 125LL);
str_copy(v21);
str_copy(v18);
str_split_char(v21, v20, 44LL);
if ( !(unsigned int)str_isempty(v21, v20) )
{
while ( 1 )
{
str_copy(v22);
str_append_str(v22, v18);
if ( (unsigned int)vsf_filename_passes_filter(v19, v22, a3) )
break;
str_copy(v21);
str_split_char(v21, v20, 44LL);
if ( (unsigned int)str_isempty(v21, v20) )
goto LABEL_25;
}
v7 = 1;
}
LABEL_25:
str_free(v18);
str_free(v19);
str_free(v20);
str_free(v21);
str_free(v22);
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 *a1, __int64 a2, _DWORD *a3)
{
int v3; // er13
char v6; // bp
unsigned int v7; // er12
unsigned __int64 v8; // rax
char v9; // dl
unsigned __int64 v10; // rbp
int v11; // eax
unsigned __int64 v12; // rax
unsigned __int64 v13; // r14
int v14; // eax
int v15; // eax
char v17; // [rsp+10h] [rbp-88h]
__int64 v18[2]; // [rsp+20h] [rbp-78h] BYREF
__int64 v19[2]; // [rsp+30h] [rbp-68h] BYREF
__int64 v20[2]; // [rsp+40h] [rbp-58h] BYREF
__int64 v21[2]; // [rsp+50h] [rbp-48h] BYREF
__int64 v22[7]; // [rsp+60h] [rbp-38h] BYREF

v3 = 1;
v18[0] = 0LL;
v18[1] = 0LL;
v19[0] = 0LL;
v19[1] = 0LL;
v20[0] = 0LL;
v20[1] = 0LL;
v21[0] = 0LL;
v21[1] = 0LL;
v22[0] = 0LL;
v22[1] = 0LL;
str_copy(v18);
v6 = 0;
str_copy(v19);
while ( 1 )
{
while ( 1 )
{
while ( 1 )
{
v7 = str_isempty(v18, a1);
if ( v7 || *a3 > 0x3E7u )
{
v15 = str_getlen(v19);
if ( v6 != 42 && v15 )
v7 = 0;
else
v7 = *a3 != 1000;
goto LABEL_25;
}
v8 = str_locate_chars(v18, &unk_BB7);
++*a3;
v17 = v9;
v10 = HIDWORD(v8);
if ( (_DWORD)v8 )
break;
a1 = v18;
str_copy(&s_match_needed_str_0);
str_empty(v18, v18);
if ( !(unsigned int)str_isempty(&s_match_needed_str_0, v18) )
{
v6 = 0;
goto LABEL_15;
}
v3 = 0;
v6 = 0;
}
str_left(v18, &s_match_needed_str_0, HIDWORD(v8));
str_mid_to_end(v18, v20, (unsigned int)(v10 + 1));
a1 = v20;
str_copy(v18);
v6 = v17;
if ( (unsigned int)str_isempty(&s_match_needed_str_0, v20) )
{
if ( v17 == 63 )
goto LABEL_19;
goto LABEL_7;
}
LABEL_15:
v12 = str_locate_str(v19, &s_match_needed_str_0);
v13 = HIDWORD(v12);
if ( !(_DWORD)v12 || HIDWORD(v12) && v3 )
goto LABEL_25;
v14 = str_getlen(&s_match_needed_str_0);
str_mid_to_end(v19, v20, (unsigned int)(v14 + v13));
a1 = v20;
str_copy(v19);
if ( v6 == 63 )
{
LABEL_19:
if ( (unsigned int)str_isempty(v19, v20) )
goto LABEL_25;
goto LABEL_11;
}
LABEL_7:
if ( v6 == 123 )
break;
v3 = 0;
}
if ( (unsigned int)str_locate_char(v18, 125LL) )
break;
if ( (unsigned int)str_isempty(v19, 125LL) )
goto LABEL_25;
v6 = str_get_char_at(v19, 0LL);
if ( v6 != 123 )
goto LABEL_25;
LABEL_11:
v3 = 1;
v11 = str_getlen(v19);
str_right(v19, v20, (unsigned int)(v11 - 1));
a1 = v20;
str_copy(v19);
}
str_split_char(v18, v20, 125LL);
str_copy(v21);
str_copy(v18);
str_split_char(v21, v20, 44LL);
if ( !(unsigned int)str_isempty(v21, v20) )
{
while ( 1 )
{
str_copy(v22);
str_append_str(v22, v18);
if ( (unsigned int)func1(v19, v22, a3) )
break;
str_copy(v21);
str_split_char(v21, v20, 44LL);
if ( (unsigned int)str_isempty(v21, v20) )
goto LABEL_25;
}
v7 = 1;
}
LABEL_25:
str_free(v18);
str_free(v19);
str_free(v20);
str_free(v21);
str_free(v22);
return v7;
}

original_code:
int
vsf_filename_passes_filter(const struct mystr* p_filename_str,
                           const struct mystr* p_filter_str,
                           unsigned int* iters)
{
  struct mystr filter_remain_str = { (void*)0, 0, 0 };
  struct mystr name_remain_str = { (void*)0, 0, 0 };
  struct mystr temp_str = { (void*)0, 0, 0 };
  struct mystr brace_list_str = { (void*)0, 0, 0 };
  struct mystr new_filter_str = { (void*)0, 0, 0 };
  int ret = 0;
  char last_token = 0;
  int must_match_at_current_pos = 1;
  str_copy(&filter_remain_str, p_filter_str);
  str_copy(&name_remain_str, p_filename_str);
  while (!str_isempty(&filter_remain_str) && *iters < 1000)
  {
    static struct mystr s_match_needed_str;
    struct str_locate_result locate_result =
      str_locate_chars(&filter_remain_str, "*?{");
    (*iters)++;
    if (locate_result.found)
    {
      unsigned int indexx = locate_result.index;
      str_left(&filter_remain_str, &s_match_needed_str, indexx);
      str_mid_to_end(&filter_remain_str, &temp_str, indexx + 1);
      str_copy(&filter_remain_str, &temp_str);
      last_token = locate_result.char_found;
    }
    else
    {
      str_copy(&s_match_needed_str, &filter_remain_str);
      str_empty(&filter_remain_str);
      last_token = 0;
    }
    if (!str_isempty(&s_match_needed_str))
    {
      unsigned int indexx;
      locate_result = str_locate_str(&name_remain_str, &s_match_needed_str);
      if (!locate_result.found)
      {
        goto out;
      }
      indexx = locate_result.index;
      if (must_match_at_current_pos && indexx > 0)
      {
        goto out;
      }
      str_mid_to_end(&name_remain_str, &temp_str,
                     indexx + str_getlen(&s_match_needed_str));
      str_copy(&name_remain_str, &temp_str);
    }
    if (last_token == '?')
    {
      if (str_isempty(&name_remain_str))
      {
        goto out;
      }
      str_right(&name_remain_str, &temp_str, str_getlen(&name_remain_str) - 1);
      str_copy(&name_remain_str, &temp_str);
      must_match_at_current_pos = 1;
    }
    else if (last_token == '{')
    {
      struct str_locate_result end_brace =
        str_locate_char(&filter_remain_str, '}');
      must_match_at_current_pos = 1;
      if (end_brace.found)
      {
        str_split_char(&filter_remain_str, &temp_str, '}');
        str_copy(&brace_list_str, &filter_remain_str);
        str_copy(&filter_remain_str, &temp_str);
        str_split_char(&brace_list_str, &temp_str, ',');
        while (!str_isempty(&brace_list_str))
        {
          str_copy(&new_filter_str, &brace_list_str);
          str_append_str(&new_filter_str, &filter_remain_str);
          if (vsf_filename_passes_filter(&name_remain_str, &new_filter_str,
                                         iters))
          {
            ret = 1;
            goto out;
          }
          str_copy(&brace_list_str, &temp_str);
          str_split_char(&brace_list_str, &temp_str, ',');
        }
        goto out;
      }
      else if (str_isempty(&name_remain_str) ||
               str_get_char_at(&name_remain_str, 0) != '{')
      {
        goto out;
      }
      else
      {
        str_right(&name_remain_str, &temp_str,
                  str_getlen(&name_remain_str) - 1);
        str_copy(&name_remain_str, &temp_str);
      }
    }
    else
    {
      must_match_at_current_pos = 0;
    }
  }
  if (str_getlen(&name_remain_str) > 0 && last_token != '*')
  {
    goto out;
  }
  ret = 1;
  if (*iters == 1000) {
    ret = 0;
  }
out:
  str_free(&filter_remain_str);
  str_free(&name_remain_str);
  str_free(&temp_str);
  str_free(&brace_list_str);
  str_free(&new_filter_str);
  return ret;
}

canonical_original_code:
int vsf_filename_passes_filter(struct mystr *p_filename_str, struct mystr *p_filter_str, unsigned int *iters)
{
  struct mystr filter_remain_str = { (void*)0, 0, 0 };
  struct mystr name_remain_str = { (void*)0, 0, 0 };
  struct mystr temp_str = { (void*)0, 0, 0 };
  struct mystr brace_list_str = { (void*)0, 0, 0 };
  struct mystr new_filter_str = { (void*)0, 0, 0 };
  int ret = 0;
  char last_token = 0;
  int must_match_at_current_pos = 1;
  str_copy(&filter_remain_str, p_filter_str);
  str_copy(&name_remain_str, p_filename_str);
  while (!str_isempty(&filter_remain_str) && *iters < 1000)
  {
    static struct mystr s_match_needed_str;
    struct str_locate_result locate_result = str_locate_chars(&filter_remain_str, "*?{");
    (*iters)++;
    if (locate_result.found)
    {
      unsigned int indexx = locate_result.index;
      str_left(&filter_remain_str, &s_match_needed_str, indexx);
      str_mid_to_end(&filter_remain_str, &temp_str, indexx + 1);
      str_copy(&filter_remain_str, &temp_str);
      last_token = locate_result.char_found;
    }
    else
    {
      str_copy(&s_match_needed_str, &filter_remain_str);
      str_empty(&filter_remain_str);
      last_token = 0;
    }
    if (!str_isempty(&s_match_needed_str))
    {
      unsigned int indexx;
      locate_result = str_locate_str(&name_remain_str, &s_match_needed_str);
      if (!locate_result.found)
      {
        goto out;
      }
      indexx = locate_result.index;
      if (must_match_at_current_pos && indexx > 0)
      {
        goto out;
      }
      str_mid_to_end(&name_remain_str, &temp_str,
                     indexx + str_getlen(&s_match_needed_str));
      str_copy(&name_remain_str, &temp_str);
    }
    if (last_token == '?')
    {
      if (str_isempty(&name_remain_str))
      {
        goto out;
      }
      str_right(&name_remain_str, &temp_str, str_getlen(&name_remain_str) - 1);
      str_copy(&name_remain_str, &temp_str);
      must_match_at_current_pos = 1;
    }
    else if (last_token == '{')
    {
      struct str_locate_result end_brace = str_locate_char(&filter_remain_str, '}');
      must_match_at_current_pos = 1;
      if (end_brace.found)
      {
        str_split_char(&filter_remain_str, &temp_str, '}');
        str_copy(&brace_list_str, &filter_remain_str);
        str_copy(&filter_remain_str, &temp_str);
        str_split_char(&brace_list_str, &temp_str, ',');
        while (!str_isempty(&brace_list_str))
        {
          str_copy(&new_filter_str, &brace_list_str);
          str_append_str(&new_filter_str, &filter_remain_str);
          if (vsf_filename_passes_filter(&name_remain_str, &new_filter_str,
                                         iters))
          {
            ret = 1;
            goto out;
          }
          str_copy(&brace_list_str, &temp_str);
          str_split_char(&brace_list_str, &temp_str, ',');
        }
        goto out;
      }
      else if (str_isempty(&name_remain_str) ||
               str_get_char_at(&name_remain_str, 0) != '{')
      {
        goto out;
      }
      else
      {
        str_right(&name_remain_str, &temp_str,
                  str_getlen(&name_remain_str) - 1);
        str_copy(&name_remain_str, &temp_str);
      }
    }
    else
    {
      must_match_at_current_pos = 0;
    }
  }
  if (str_getlen(&name_remain_str) > 0 && last_token != '*')
  {
    goto out;
  }
  ret = 1;
  if (*iters == 1000) {
    ret = 0;
  }
out:
  str_free(&filter_remain_str);
  str_free(&name_remain_str);
  str_free(&temp_str);
  str_free(&brace_list_str);
  str_free(&new_filter_str);
  return ret;
}

variable_types:
iters
unsigned int *

variable_types: struct mystr { char *PRIVATE_HANDS_OFF_p_buf; unsigned int PRIVATE_HANDS_OFF_len; unsigned int PRIVATE_HANDS_OFF_alloc_bytes; }

variable_types: ret int

variable_types: struct str_locate_result { int found; unsigned int index; char char_found; }

variable_types:
indexx
unsigned int