decompiled_code:
__int64 gh_5()
{
__int64 v0; // rax
__int64 v1; // r12
__int64 v2; // rax
__int64 v3; // rbx
char *v4; // rbp
__int64 result; // rax
char *s2; // [rsp+0h] [rbp-48h] BYREF
__int64 v7; // [rsp+8h] [rbp-40h] BYREF
char v8[14]; // [rsp+16h] [rbp-32h] BYREF
__int16 v9[3]; // [rsp+24h] [rbp-24h] BYREF
char v10[30]; // [rsp+2Ah] [rbp-1Eh] BYREF

v0 = sp_env();
if ( !v0 )
{
printf("fail (%s:%d) %s\n", "issues.c", 19LL, "env != NULL");
fflush(0LL);
abort();
}
v1 = v0;
if ( (unsigned int)sp_ctl(v0, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "issues.c", 20LL, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0");
fflush(0LL);
abort();
}
v2 = sp_open(v1);
v3 = v2;
if ( !v2 )
{
printf("fail (%s:%d) %s\n", "issues.c", 22LL, "db != NULL");
fflush(0LL);
abort();
}
strcpy(v10, "key-1");
strcpy((char *)v9, "val-1");
if ( (unsigned int)sp_set(v2, v10, 6LL, v9, 6LL) )
{
printf("fail (%s:%d) %s\n", "issues.c", 26LL, "sp_set(db, k1, sizeof(k1), v1, sizeof(v1)) == 0");
fflush(0LL);
abort();
}
strcpy(&v8[7], "key-10");
strcpy(v8, "val-10");
if ( (unsigned int)sp_set(v3, &v8[7], 7LL, v8, 7LL) )
{
printf("fail (%s:%d) %s\n", "issues.c", 30LL, "sp_set(db, k2, sizeof(k2), v2, sizeof(v2)) == 0");
fflush(0LL);
abort();
}
v7 = 0LL;
s2 = 0LL;
if ( (unsigned int)sp_get(v3, v10, 6LL, &s2, &v7) != 1 )
{
printf("fail (%s:%d) %s\n", "issues.c", 34LL, "sp_get(db, k1, sizeof(k1), &res, &ressize) == 1");
fflush(0LL);
abort();
}
if ( v7 != 6 )
{
printf("fail (%s:%d) %s\n", "issues.c", 36LL, "ressize == sizeof(v1)");
fflush(0LL);
abort();
}
v4 = s2;
if ( strcmp((const char *)v9, s2) )
{
printf("fail (%s:%d) %s\n", "issues.c", 37LL, "strcmp(v1, res) == 0");
fflush(0LL);
abort();
}
free(v4);
if ( (unsigned int)sp_destroy(v3) )
{
printf("fail (%s:%d) %s\n", "issues.c", 41LL, "sp_destroy(db) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v1) )
{
printf("fail (%s:%d) %s\n", "issues.c", 42LL, "sp_destroy(env) == 0");
fflush(0LL);
abort();
}
result = rmrf("./rep");
if ( (_DWORD)result )
{
printf("fail (%s:%d) %s\n", "issues.c", 43LL, "rmrf(dbrep) == 0");
fflush(0LL);
abort();
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rax
__int64 v1; // r12
__int64 v2; // rax
__int64 v3; // rbx
char *v4; // rbp
__int64 result; // rax
char *s2; // [rsp+0h] [rbp-48h] BYREF
__int64 v7; // [rsp+8h] [rbp-40h] BYREF
char v8[14]; // [rsp+16h] [rbp-32h] BYREF
__int16 v9[3]; // [rsp+24h] [rbp-24h] BYREF
char v10[30]; // [rsp+2Ah] [rbp-1Eh] BYREF

v0 = sp_env();
if ( !v0 )
{
printf("fail (%s:%d) %s\n", "issues.c", 19LL, "env != NULL");
fflush(0LL);
abort();
}
v1 = v0;
if ( (unsigned int)sp_ctl(v0, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "issues.c", 20LL, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0");
fflush(0LL);
abort();
}
v2 = sp_open(v1);
v3 = v2;
if ( !v2 )
{
printf("fail (%s:%d) %s\n", "issues.c", 22LL, "db != NULL");
fflush(0LL);
abort();
}
strcpy(v10, "key-1");
strcpy((char *)v9, "val-1");
if ( (unsigned int)sp_set(v2, v10, 6LL, v9, 6LL) )
{
printf("fail (%s:%d) %s\n", "issues.c", 26LL, "sp_set(db, k1, sizeof(k1), v1, sizeof(v1)) == 0");
fflush(0LL);
abort();
}
strcpy(&v8[7], "key-10");
strcpy(v8, "val-10");
if ( (unsigned int)sp_set(v3, &v8[7], 7LL, v8, 7LL) )
{
printf("fail (%s:%d) %s\n", "issues.c", 30LL, "sp_set(db, k2, sizeof(k2), v2, sizeof(v2)) == 0");
fflush(0LL);
abort();
}
v7 = 0LL;
s2 = 0LL;
if ( (unsigned int)sp_get(v3, v10, 6LL, &s2, &v7) != 1 )
{
printf("fail (%s:%d) %s\n", "issues.c", 34LL, "sp_get(db, k1, sizeof(k1), &res, &ressize) == 1");
fflush(0LL);
abort();
}
if ( v7 != 6 )
{
printf("fail (%s:%d) %s\n", "issues.c", 36LL, "ressize == sizeof(v1)");
fflush(0LL);
abort();
}
v4 = s2;
if ( strcmp((const char *)v9, s2) )
{
printf("fail (%s:%d) %s\n", "issues.c", 37LL, "strcmp(v1, res) == 0");
fflush(0LL);
abort();
}
free(v4);
if ( (unsigned int)sp_destroy(v3) )
{
printf("fail (%s:%d) %s\n", "issues.c", 41LL, "sp_destroy(db) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v1) )
{
printf("fail (%s:%d) %s\n", "issues.c", 42LL, "sp_destroy(env) == 0");
fflush(0LL);
abort();
}
result = func0("./rep");
if ( (_DWORD)result )
{
printf("fail (%s:%d) %s\n", "issues.c", 43LL, "rmrf(dbrep) == 0");
fflush(0LL);
abort();
}
return result;
}

original_code:
static void
gh_5(void) {
 void *env = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "issues.c", 19, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 20, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0"); fflush(((void *)0)); abort(); } });
 void *db = sp_open(env);
 ({ if (! (db != ((void *)0))) { printf("fail (%s:%d) %s\n", "issues.c", 22, "db != NULL"); fflush(((void *)0)); abort(); } });
 char k1[] = "key-1";
 char v1[] = "val-1";
 ({ if (! (sp_set(db, k1, sizeof(k1), v1, sizeof(v1)) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 26, "sp_set(db, k1, sizeof(k1), v1, sizeof(v1)) == 0"); fflush(((void *)0)); abort(); } });
 char k2[] = "key-10";
 char v2[] = "val-10";
 ({ if (! (sp_set(db, k2, sizeof(k2), v2, sizeof(v2)) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 30, "sp_set(db, k2, sizeof(k2), v2, sizeof(v2)) == 0"); fflush(((void *)0)); abort(); } });
 size_t ressize = 0;
 void *res = ((void *)0);
 ({ if (! (sp_get(db, k1, sizeof(k1), &res, &ressize) == 1)) { printf("fail (%s:%d) %s\n", "issues.c", 34, "sp_get(db, k1, sizeof(k1), &res, &ressize) == 1"); fflush(((void *)0)); abort(); } });
 ({ if (! (ressize == sizeof(v1))) { printf("fail (%s:%d) %s\n", "issues.c", 36, "ressize == sizeof(v1)"); fflush(((void *)0)); abort(); } });
 ({ if (! (strcmp(v1, res) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 37, "strcmp(v1, res) == 0"); fflush(((void *)0)); abort(); } });
 free(res);
 ({ if (! (sp_destroy(db) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 41, "sp_destroy(db) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 42, "sp_destroy(env) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (rmrf(dbrep) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 43, "rmrf(dbrep) == 0"); fflush(((void *)0)); abort(); } });
}

canonical_original_code:
static void gh_5() {
 void *env = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "issues.c", 19, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 20, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0"); fflush(((void *)0)); abort(); } });
 void *db = sp_open(env);
 ({ if (! (db != ((void *)0))) { printf("fail (%s:%d) %s\n", "issues.c", 22, "db != NULL"); fflush(((void *)0)); abort(); } });
 char k1[] = "key-1";
 char v1[] = "val-1";
 ({ if (! (sp_set(db, k1, sizeof(k1), v1, sizeof(v1)) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 26, "sp_set(db, k1, sizeof(k1), v1, sizeof(v1)) == 0"); fflush(((void *)0)); abort(); } });
 char k2[] = "key-10";
 char v2[] = "val-10";
 ({ if (! (sp_set(db, k2, sizeof(k2), v2, sizeof(v2)) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 30, "sp_set(db, k2, sizeof(k2), v2, sizeof(v2)) == 0"); fflush(((void *)0)); abort(); } });
 unsigned long ressize = 0;
 void *res = ((void *)0);
 ({ if (! (sp_get(db, k1, sizeof(k1), &res, &ressize) == 1)) { printf("fail (%s:%d) %s\n", "issues.c", 34, "sp_get(db, k1, sizeof(k1), &res, &ressize) == 1"); fflush(((void *)0)); abort(); } });
 ({ if (! (ressize == sizeof(v1))) { printf("fail (%s:%d) %s\n", "issues.c", 36, "ressize == sizeof(v1)"); fflush(((void *)0)); abort(); } });
 ({ if (! (strcmp(v1, res) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 37, "strcmp(v1, res) == 0"); fflush(((void *)0)); abort(); } });
 free(res);
 ({ if (! (sp_destroy(db) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 41, "sp_destroy(db) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 42, "sp_destroy(env) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (rmrf(dbrep) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 43, "rmrf(dbrep) == 0"); fflush(((void *)0)); abort(); } });
}

variable_types:
ressize
unsigned long

variable_types:
res
void *


repo: Peaker/bindings-sophia

decompiled_code:
__int64 gh_29()
{
__int64 v0; // rax
__int64 v1; // r12
__int64 v2; // rbp
unsigned int i; // ebx
int v4; // eax
unsigned int j; // er13
int v6; // eax
size_t v7; // rbx
void *v8; // r14
__int64 result; // rax
char s1[4]; // [rsp+Ch] [rbp-3Ch] BYREF
__int64 v11; // [rsp+10h] [rbp-38h] BYREF
char s[8]; // [rsp+18h] [rbp-30h] BYREF

v0 = sp_env();
if ( !v0 )
{
printf("fail (%s:%d) %s\n", "issues.c", 49LL, "env != NULL");
fflush(0LL);
abort();
}
v1 = v0;
if ( (unsigned int)sp_ctl(v0, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "issues.c", 50LL, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0");
fflush(0LL);
abort();
}
v2 = sp_open(v1);
if ( !v2 )
{
printf("fail (%s:%d) %s\n", "issues.c", 52LL, "db != NULL");
fflush(0LL);
abort();
}
for ( i = 1; i != 11; ++i )
{
v4 = snprintf(s, 4uLL, "%d", i);
if ( (unsigned int)sp_set(v2, s, v4, s, v4) )
{
printf("fail (%s:%d) %s\n", "issues.c", 57LL, "sp_set(db, key, len, key, len) == 0");
fflush(0LL);
abort();
}
}
for ( j = 1; j != 11; ++j )
{
v6 = snprintf(s1, 4uLL, "%d", j);
v11 = 0LL;
*(_QWORD *)s = 0LL;
v7 = v6;
if ( (unsigned int)sp_get(v2, s1, v6, s, &v11) != 1 )
{
printf("fail (%s:%d) %s\n", "issues.c", 64LL, "sp_get(db, key, len, &vp, &vsize) == 1");
fflush(0LL);
abort();
}
if ( v7 != v11 )
{
printf("fail (%s:%d) %s\n", "issues.c", 65LL, "vsize == len");
fflush(0LL);
abort();
}
v8 = *(void **)s;
if ( memcmp(s1, *(const void **)s, v7) )
{
printf("fail (%s:%d) %s\n", "issues.c", 66LL, "memcmp(key, vp, len) == 0");
fflush(0LL);
abort();
}
free(v8);
}
if ( (unsigned int)sp_destroy(v2) )
{
printf("fail (%s:%d) %s\n", "issues.c", 69LL, "sp_destroy(db) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v1) )
{
printf("fail (%s:%d) %s\n", "issues.c", 70LL, "sp_destroy(env) == 0");
fflush(0LL);
abort();
}
result = rmrf("./rep");
if ( (_DWORD)result )
{
printf("fail (%s:%d) %s\n", "issues.c", 71LL, "rmrf(dbrep) == 0");
fflush(0LL);
abort();
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // rax
__int64 v1; // r12
__int64 v2; // rbp
unsigned int i; // ebx
int v4; // eax
unsigned int j; // er13
int v6; // eax
size_t v7; // rbx
void *v8; // r14
__int64 result; // rax
char s1[4]; // [rsp+Ch] [rbp-3Ch] BYREF
__int64 v11; // [rsp+10h] [rbp-38h] BYREF
char s[8]; // [rsp+18h] [rbp-30h] BYREF

v0 = sp_env();
if ( !v0 )
{
printf("fail (%s:%d) %s\n", "issues.c", 49LL, "env != NULL");
fflush(0LL);
abort();
}
v1 = v0;
if ( (unsigned int)sp_ctl(v0, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "issues.c", 50LL, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0");
fflush(0LL);
abort();
}
v2 = sp_open(v1);
if ( !v2 )
{
printf("fail (%s:%d) %s\n", "issues.c", 52LL, "db != NULL");
fflush(0LL);
abort();
}
for ( i = 1; i != 11; ++i )
{
v4 = snprintf(s, 4uLL, "%d", i);
if ( (unsigned int)sp_set(v2, s, v4, s, v4) )
{
printf("fail (%s:%d) %s\n", "issues.c", 57LL, "sp_set(db, key, len, key, len) == 0");
fflush(0LL);
abort();
}
}
for ( j = 1; j != 11; ++j )
{
v6 = snprintf(s1, 4uLL, "%d", j);
v11 = 0LL;
*(_QWORD *)s = 0LL;
v7 = v6;
if ( (unsigned int)sp_get(v2, s1, v6, s, &v11) != 1 )
{
printf("fail (%s:%d) %s\n", "issues.c", 64LL, "sp_get(db, key, len, &vp, &vsize) == 1");
fflush(0LL);
abort();
}
if ( v7 != v11 )
{
printf("fail (%s:%d) %s\n", "issues.c", 65LL, "vsize == len");
fflush(0LL);
abort();
}
v8 = *(void **)s;
if ( memcmp(s1, *(const void **)s, v7) )
{
printf("fail (%s:%d) %s\n", "issues.c", 66LL, "memcmp(key, vp, len) == 0");
fflush(0LL);
abort();
}
free(v8);
}
if ( (unsigned int)sp_destroy(v2) )
{
printf("fail (%s:%d) %s\n", "issues.c", 69LL, "sp_destroy(db) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v1) )
{
printf("fail (%s:%d) %s\n", "issues.c", 70LL, "sp_destroy(env) == 0");
fflush(0LL);
abort();
}
result = func0("./rep");
if ( (_DWORD)result )
{
printf("fail (%s:%d) %s\n", "issues.c", 71LL, "rmrf(dbrep) == 0");
fflush(0LL);
abort();
}
return result;
}

original_code:
static void
gh_29(void) {
 void *env = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "issues.c", 49, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 50, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0"); fflush(((void *)0)); abort(); } });
 void *db = sp_open(env);
 ({ if (! (db != ((void *)0))) { printf("fail (%s:%d) %s\n", "issues.c", 52, "db != NULL"); fflush(((void *)0)); abort(); } });
 int i;
 for (i = 1; i <= 10; i++) {
  char key[4];
  int len = snprintf(key, sizeof(key), "%d", i);
  ({ if (! (sp_set(db, key, len, key, len) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 57, "sp_set(db, key, len, key, len) == 0"); fflush(((void *)0)); abort(); } });
 }
 for (i = 1; i <= 10; i++) {
  char key[4];
  int len = snprintf(key, sizeof(key), "%d", i);
  size_t vsize = 0;
  void *vp = ((void *)0);
  ({ if (! (sp_get(db, key, len, &vp, &vsize) == 1)) { printf("fail (%s:%d) %s\n", "issues.c", 64, "sp_get(db, key, len, &vp, &vsize) == 1"); fflush(((void *)0)); abort(); } });
  ({ if (! (vsize == len)) { printf("fail (%s:%d) %s\n", "issues.c", 65, "vsize == len"); fflush(((void *)0)); abort(); } });
  ({ if (! (memcmp(key, vp, len) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 66, "memcmp(key, vp, len) == 0"); fflush(((void *)0)); abort(); } });
  free(vp);
 }
 ({ if (! (sp_destroy(db) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 69, "sp_destroy(db) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 70, "sp_destroy(env) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (rmrf(dbrep) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 71, "rmrf(dbrep) == 0"); fflush(((void *)0)); abort(); } });
}

canonical_original_code:
static void gh_29() {
 void *env = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "issues.c", 49, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 50, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0"); fflush(((void *)0)); abort(); } });
 void *db = sp_open(env);
 ({ if (! (db != ((void *)0))) { printf("fail (%s:%d) %s\n", "issues.c", 52, "db != NULL"); fflush(((void *)0)); abort(); } });
 int i;
 for (i = 1; i <= 10; i++) {
  char key[4];
  int len = snprintf(key, sizeof(key), "%d", i);
  ({ if (! (sp_set(db, key, len, key, len) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 57, "sp_set(db, key, len, key, len) == 0"); fflush(((void *)0)); abort(); } });
 }
 for (i = 1; i <= 10; i++) {
  char key[4];
  int len = snprintf(key, sizeof(key), "%d", i);
  unsigned long vsize = 0;
  void *vp = ((void *)0);
  ({ if (! (sp_get(db, key, len, &vp, &vsize) == 1)) { printf("fail (%s:%d) %s\n", "issues.c", 64, "sp_get(db, key, len, &vp, &vsize) == 1"); fflush(((void *)0)); abort(); } });
  ({ if (! (vsize == len)) { printf("fail (%s:%d) %s\n", "issues.c", 65, "vsize == len"); fflush(((void *)0)); abort(); } });
  ({ if (! (memcmp(key, vp, len) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 66, "memcmp(key, vp, len) == 0"); fflush(((void *)0)); abort(); } });
  free(vp);
 }
 ({ if (! (sp_destroy(db) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 69, "sp_destroy(db) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 70, "sp_destroy(env) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (rmrf(dbrep) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 71, "rmrf(dbrep) == 0"); fflush(((void *)0)); abort(); } });
}

variable_types:
env
void *

variable_types:
db
void *

variable_types: i int

variable_types:
key
char [4]

variable_types: len int

variable_types:
vsize
unsigned long

variable_types:
vp
void *

return_type: void


decompiled_code:
__int64 gh_37()
{
__int64 v0; // r13
__int64 v1; // rcx
__int64 v2; // rcx
int v3; // ebx
__int64 v4; // rbx
int v5; // eax
__int64 v6; // rdx
__int64 result; // rax
__int64 v8; // [rsp+0h] [rbp-420h] BYREF
char v9[983]; // [rsp+8h] [rbp-418h] BYREF
__int64 v10; // [rsp+3DFh] [rbp-41h] BYREF
int v11[9]; // [rsp+3FCh] [rbp-24h] BYREF

v8 = 0LL;
v10 = 0LL;
memset(v9, 0, 0x3D8uLL);
v0 = sp_env((char *)&v10 + 1);
if ( (unsigned int)sp_ctl(v0, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "issues.c", 86LL, "rc == 0");
fflush(0LL);
abort();
}
v3 = sp_ctl(v0, 8LL, 3996LL, v1);
if ( v3 == -1 )
{
printf("fail (%s:%d) %s\n", "issues.c", 94LL, "rc == 0");
fflush(0LL);
abort();
}
sp_ctl(v0, 3LL, 1022LL, v2);
if ( v3 )
{
printf("fail (%s:%d) %s\n", "issues.c", 97LL, "rc == 0");
fflush(0LL);
abort();
}
v4 = sp_open(v0);
if ( !v4 )
{
printf("fail (%s:%d) %s\n", "issues.c", 100LL, "db != NULL");
fflush(0LL);
abort();
}
v11[0] = 0;
do
{
if ( (unsigned int)sp_set(v4, v11, 4LL, &v8, 999LL) )
{
printf("fail (%s:%d) %s\n", "issues.c", 106LL, "rc == 0");
fflush(0LL);
abort();
}
v5 = v11[0] + 1;
v11[0] = v5;
}
while ( v5 <= 99999 );
v6 = (unsigned int)(3996 * (v5 / 3996));
if ( v5 == (_DWORD)v6 && (unsigned int)sp_ctl(v4, 9LL, v6, (unsigned int)(v5 >> 31)) )
{
printf("fail (%s:%d) %s\n", "issues.c", 112LL, "rc == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v4) )
{
printf("fail (%s:%d) %s\n", "issues.c", 115LL, "sp_destroy(db) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v0) )
{
printf("fail (%s:%d) %s\n", "issues.c", 116LL, "sp_destroy(env) == 0");
fflush(0LL);
abort();
}
result = rmrf("./rep");
if ( (_DWORD)result )
{
printf("fail (%s:%d) %s\n", "issues.c", 117LL, "rmrf(dbrep) == 0");
fflush(0LL);
abort();
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // r13
__int64 v1; // rcx
__int64 v2; // rcx
int v3; // ebx
__int64 v4; // rbx
int v5; // eax
__int64 v6; // rdx
__int64 result; // rax
__int64 v8; // [rsp+0h] [rbp-420h] BYREF
char v9[983]; // [rsp+8h] [rbp-418h] BYREF
__int64 v10; // [rsp+3DFh] [rbp-41h] BYREF
int v11[9]; // [rsp+3FCh] [rbp-24h] BYREF

v8 = 0LL;
v10 = 0LL;
memset(v9, 0, 0x3D8uLL);
v0 = sp_env((char *)&v10 + 1);
if ( (unsigned int)sp_ctl(v0, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "issues.c", 86LL, "rc == 0");
fflush(0LL);
abort();
}
v3 = sp_ctl(v0, 8LL, 3996LL, v1);
if ( v3 == -1 )
{
printf("fail (%s:%d) %s\n", "issues.c", 94LL, "rc == 0");
fflush(0LL);
abort();
}
sp_ctl(v0, 3LL, 1022LL, v2);
if ( v3 )
{
printf("fail (%s:%d) %s\n", "issues.c", 97LL, "rc == 0");
fflush(0LL);
abort();
}
v4 = sp_open(v0);
if ( !v4 )
{
printf("fail (%s:%d) %s\n", "issues.c", 100LL, "db != NULL");
fflush(0LL);
abort();
}
v11[0] = 0;
do
{
if ( (unsigned int)sp_set(v4, v11, 4LL, &v8, 999LL) )
{
printf("fail (%s:%d) %s\n", "issues.c", 106LL, "rc == 0");
fflush(0LL);
abort();
}
v5 = v11[0] + 1;
v11[0] = v5;
}
while ( v5 <= 99999 );
v6 = (unsigned int)(3996 * (v5 / 3996));
if ( v5 == (_DWORD)v6 && (unsigned int)sp_ctl(v4, 9LL, v6, (unsigned int)(v5 >> 31)) )
{
printf("fail (%s:%d) %s\n", "issues.c", 112LL, "rc == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v4) )
{
printf("fail (%s:%d) %s\n", "issues.c", 115LL, "sp_destroy(db) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v0) )
{
printf("fail (%s:%d) %s\n", "issues.c", 116LL, "sp_destroy(env) == 0");
fflush(0LL);
abort();
}
result = func0("./rep");
if ( (_DWORD)result )
{
printf("fail (%s:%d) %s\n", "issues.c", 117LL, "rmrf(dbrep) == 0");
fflush(0LL);
abort();
}
return result;
}

original_code:
static void
gh_37(void)
{
 const int size = 999;
 const int watermark = 3996;
 const int pagesize = 1022;
 char data[size];
 memset(data, 0, sizeof(data));
 void *env = sp_env();
 int rc = sp_ctl(env, SPDIR, SPO_CREAT | SPO_RDWR, dbrep);
 ({ if (! (rc == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 86, "rc == 0"); fflush(((void *)0)); abort(); } });
 if (rc == -1)
 rc = sp_ctl(env, SPMERGE, 0);
 ({ if (! (rc == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 90, "rc == 0"); fflush(((void *)0)); abort(); } });
 rc = sp_ctl(env, SPMERGEWM, watermark);
 if (rc == -1)
 ({ if (! (rc == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 94, "rc == 0"); fflush(((void *)0)); abort(); } });
 sp_ctl(env, SPPAGE, pagesize);
 ({ if (! (rc == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 97, "rc == 0"); fflush(((void *)0)); abort(); } });
 void *db = sp_open(env);
 ({ if (! (db != ((void *)0))) { printf("fail (%s:%d) %s\n", "issues.c", 100, "db != NULL"); fflush(((void *)0)); abort(); } });
 int byteCount = 0;
 int i;
 for (i = 0; i < 100000; ++i) {
  rc = sp_set(db, &i, sizeof(int), data, size);
  ({ if (! (rc == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 106, "rc == 0"); fflush(((void *)0)); abort(); } });
 }
 byteCount += size;
 if (i != 0 && i % watermark == 0) {
  rc = sp_ctl(db, SPMERGEFORCE);
  ({ if (! (rc == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 112, "rc == 0"); fflush(((void *)0)); abort(); } });
 }
 ({ if (! (sp_destroy(db) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 115, "sp_destroy(db) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 116, "sp_destroy(env) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (rmrf(dbrep) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 117, "rmrf(dbrep) == 0"); fflush(((void *)0)); abort(); } });
}

canonical_original_code:
static void gh_37()
{
 int size = 999;
 int watermark = 3996;
 int pagesize = 1022;
 char data[-1];
 memset(data, 0, sizeof(data));
 void *env = sp_env();
 int rc = sp_ctl(env, SPDIR, SPO_CREAT | SPO_RDWR, dbrep);
 ({ if (! (rc == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 86, "rc == 0"); fflush(((void *)0)); abort(); } });
 if (rc == -1)
 rc = sp_ctl(env, SPMERGE, 0);
 ({ if (! (rc == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 90, "rc == 0"); fflush(((void *)0)); abort(); } });
 rc = sp_ctl(env, SPMERGEWM, watermark);
 if (rc == -1)
 ({ if (! (rc == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 94, "rc == 0"); fflush(((void *)0)); abort(); } });
 sp_ctl(env, SPPAGE, pagesize);
 ({ if (! (rc == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 97, "rc == 0"); fflush(((void *)0)); abort(); } });
 void *db = sp_open(env);
 ({ if (! (db != ((void *)0))) { printf("fail (%s:%d) %s\n", "issues.c", 100, "db != NULL"); fflush(((void *)0)); abort(); } });
 int byteCount = 0;
 int i;
 for (i = 0; i < 100000; ++i) {
  rc = sp_set(db, &i, sizeof(int), data, size);
  ({ if (! (rc == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 106, "rc == 0"); fflush(((void *)0)); abort(); } });
 }
 byteCount += size;
 if (i != 0 && i % watermark == 0) {
  rc = sp_ctl(db, SPMERGEFORCE);
  ({ if (! (rc == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 112, "rc == 0"); fflush(((void *)0)); abort(); } });
 }
 ({ if (! (sp_destroy(db) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 115, "sp_destroy(db) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 116, "sp_destroy(env) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (rmrf(dbrep) == 0)) { printf("fail (%s:%d) %s\n", "issues.c", 117, "rmrf(dbrep) == 0"); fflush(((void *)0)); abort(); } });
}

variable_types: size int

variable_types: watermark int

variable_types: pagesize int

variable_types:
data
char [-1]

variable_types: rc int

variable_types: byteCount int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
rmrf("./rep");
printf("%s: ", "gh_5");
fflush(0LL);
gh_5();
puts("ok");
fflush(0LL);
printf("%s: ", "gh_29");
fflush(0LL);
gh_29();
puts("ok");
fflush(0LL);
printf("%s: ", "gh_37");
fflush(0LL);
gh_37();
puts("ok");
fflush(0LL);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func0("./rep");
printf("%s: ", "gh_5");
fflush(0LL);
func1();
puts("ok");
fflush(0LL);
printf("%s: ", "gh_29");
fflush(0LL);
func2();
puts("ok");
fflush(0LL);
printf("%s: ", "gh_37");
fflush(0LL);
func3();
puts("ok");
fflush(0LL);
return 0;
}

original_code:
int
main(int argc, char *argv[])
{
 rmrf(dbrep);
 ({ printf("%s: ", "gh_5"); fflush(((void *)0)); gh_5(); printf("ok\n"); fflush(((void *)0)); });
 ({ printf("%s: ", "gh_29"); fflush(((void *)0)); gh_29(); printf("ok\n"); fflush(((void *)0)); });
 ({ printf("%s: ", "gh_37"); fflush(((void *)0)); gh_37(); printf("ok\n"); fflush(((void *)0)); });
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

return_type: int


original_code:
static inline sppage*
sp_catsearch(spcat *c, sppage *v, uint32_t *index) {
 int min = 0;
 int max = c->count - 1;
 while (max >= min) {
  int mid = min + ((max - min) >> 1);
  switch (cmppage(c, c->i[mid], v)) {
  case -1: min = mid + 1;
   continue;
  case 1: max = mid - 1;
   continue;
  default:
   *index = mid;
   return c->i[mid];
  }
 }
 *index = min;
 return ((void *)0);
}

canonical_original_code:
static inline struct sppage *sp_catsearch(struct spcat *c, struct sppage *v, unsigned int *index) {
 int min = 0;
 int max = c->count - 1;
 while (max >= min) {
  int mid = min + ((max - min) >> 1);
  switch (cmppage(c, c->i[mid], v)) {
  case -1: min = mid + 1;
   continue;
  case 1: max = mid - 1;
   continue;
  default:
   *index = mid;
   return c->i[mid];
  }
 }
 *index = min;
 return ((void *)0);
}

variable_types: struct spcat { struct spa { void *(*alloc)(void *ptr, unsigned long size, void *arg); void *arg; } *a; struct sppage **i; unsigned int count; unsigned int top; int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg); void *cmparg; } *

variable_types:
v
struct sppage *

variable_types:
index
unsigned int *

variable_types: min int

variable_types: max int

variable_types: mid int

return_type: struct sppage { unsigned long id; unsigned long offset; void *epoch; unsigned int size; struct spv { unsigned int epoch; unsigned int crc; unsigned short size; unsigned char flags; char key[]; } *min; struct spv *max; struct splist { struct splist *next; } link; } *

user_defined_types: struct spcat { struct spa *a; struct sppage **i; unsigned int count; unsigned int top; int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg); void *cmparg; }

user_defined_types: struct sppage { unsigned long id; unsigned long offset; void *epoch; unsigned int size; struct spv *min; struct spv *max; struct splist link; }


cmpkey

original_code:
static inline int
cmpkey(spcat *c, sppage *p, void *rkey, int size)
{
 register int l =
  c->cmp(p->min->key, p->min->size, rkey, size, c->cmparg);
 register int r =
  c->cmp(p->max->key, p->max->size, rkey, size, c->cmparg);
 if (l <= 0 && r >= 0)
  return 0;
 if (l == -1)
  return -1;
 ((void) (0));
 return 1;
}

canonical_original_code:
static inline int cmpkey(struct spcat *c, struct sppage *p, void *rkey, int size)
{
 register int l = c->cmp(p->min->key, p->min->size, rkey, size, c->cmparg);
 register int r = c->cmp(p->max->key, p->max->size, rkey, size, c->cmparg);
 if (l <= 0 && r >= 0)
  return 0;
 if (l == -1)
  return -1;
 ((void) (0));
 return 1;
}

variable_types: struct spcat { struct spa { void *(*alloc)(void *ptr, unsigned long size, void *arg); void *arg; } *a; struct sppage { unsigned long id; unsigned long offset; void *epoch; unsigned int size; struct spv { unsigned int epoch; unsigned int crc; unsigned short size; unsigned char flags; char key[]; } *min; struct spv *max; struct splist { struct splist *next; } link; } **i; unsigned int count; unsigned int top; int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg); void *cmparg; } *

variable_types:
p
struct sppage *

variable_types:
rkey
void *

variable_types: l int

variable_types: r int


decompiled_code:
__int64 __fastcall sp_catensure(__int64 a1)
{
unsigned int v1; // esi
unsigned int v3; // esi
void *v4; // rax

v1 = *(_DWORD *)(a1 + 20);
if ( *(_DWORD *)(a1 + 16) + 1 < v1 )
return 0LL;
v3 = 2 * v1;
*(_DWORD *)(a1 + 20) = v3;
v4 = realloc(*(void **)(a1 + 8), 8LL * v3);
*(_QWORD *)(a1 + 8) = v4;
return (unsigned int)-(v4 == 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
unsigned int v1; // esi
unsigned int v3; // esi
void *v4; // rax

v1 = *(_DWORD *)(a1 + 20);
if ( *(_DWORD *)(a1 + 16) + 1 < v1 )
return 0LL;
v3 = 2 * v1;
*(_DWORD *)(a1 + 20) = v3;
v4 = realloc(*(void **)(a1 + 8), 8LL * v3);
*(_QWORD *)(a1 + 8) = v4;
return (unsigned int)-(v4 == 0LL);
}

original_code:
static inline int sp_catensure(spcat *c) {
 if ((c->count + 1) < c->top)
  return 0;
 c->top *= 2;
 c->i = realloc(c->i, c->top * sizeof(sppage*));
 if (c->i == ((void *)0))
  return -1;
 return 0;
}

canonical_original_code:
static inline int sp_catensure(struct spcat *c) {
 if ((c->count + 1) < c->top)
  return 0;
 c->top *= 2;
 c->i = realloc(c->i, c->top * sizeof(struct sppage *));
 if (c->i == ((void *)0))
  return -1;
 return 0;
}

user_defined_types: struct spa { void *(*alloc)(void *ptr, unsigned long size, void *arg); void *arg; }

user_defined_types: struct spv { unsigned int epoch; unsigned int crc; unsigned short size; unsigned char flags; char key[]; }


original_code:
int sp_catinit(spcat *c, spa *a, int top, spcmpf cmp, void *cmparg) {
 c->a = a;
 c->cmp = cmp;
 c->cmparg = cmparg;
 c->count = 0;
 c->top = top;
 c->i = sp_malloc(a, sizeof(sppage*) * top);
 if (__builtin_expect(!! (c->i == ((void *)0)), 0))
  return -1;
 return 0;
}

canonical_original_code:
int sp_catinit(struct spcat *c, struct spa *a, int top, int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg), void *cmparg) {
 c->a = a;
 c->cmp = cmp;
 c->cmparg = cmparg;
 c->count = 0;
 c->top = top;
 c->i = sp_malloc(a, sizeof(struct sppage *) * top);
 if (__builtin_expect(!! (c->i == ((void *)0)), 0))
  return -1;
 return 0;
}

variable_types:
a
struct spa *

variable_types: top int

variable_types: int (*)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg)

variable_types:
cmparg
void *


original_code:
void sp_catfree(spcat *c) {
 uint32_t p = 0;
 while (p < c->count) {
  sp_free(c->a, c->i[p]->min);
  sp_free(c->a, c->i[p]->max);
  sp_free(c->a, c->i[p]);
  p++;
 }
 sp_free(c->a, c->i);
}

canonical_original_code:
void sp_catfree(struct spcat *c) {
 unsigned int p = 0;
 while (p < c->count) {
  sp_free(c->a, c->i[p]->min);
  sp_free(c->a, c->i[p]->max);
  sp_free(c->a, c->i[p]);
  p++;
 }
 sp_free(c->a, c->i);
}

variable_types:
p
unsigned int


original_code:
int sp_catset(spcat *c, sppage *n, sppage **o)
{
 uint32_t i;
 sppage *p = sp_catsearch(c, n, &i);
 if (p) {
  *o = c->i[i];
  c->i[i] = p;
  return 0;
 }
 int rc = sp_catensure(c);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 memmove(&c->i[i + 1], &c->i[i], sizeof(sppage*) * (c->count - i));
 c->i[i] = n;
 c->count++;
 *o = ((void *)0);
 return 0;
}

canonical_original_code:
int sp_catset(struct spcat *c, struct sppage *n, struct sppage **o)
{
 unsigned int i;
 struct sppage *p = sp_catsearch(c, n, &i);
 if (p) {
  *o = c->i[i];
  c->i[i] = p;
  return 0;
 }
 int rc = sp_catensure(c);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 memmove(&c->i[i + 1], &c->i[i], sizeof(struct sppage *) * (c->count - i));
 c->i[i] = n;
 c->count++;
 *o = ((void *)0);
 return 0;
}

variable_types:
n
struct sppage *

variable_types:
o
struct sppage **

variable_types:
i
unsigned int

variable_types: struct sppage { unsigned long id; unsigned long offset; void *epoch; unsigned int size; struct spv { unsigned int epoch; unsigned int crc; unsigned short size; unsigned char flags; char key[]; } *min; struct spv *max; struct splist { struct splist *next; } link; } *

variable_types: rc int


original_code:
int sp_catdel(spcat *c, uint32_t idx)
{
 ((void) (0));
 if (__builtin_expect(!! (idx != (uint32_t)(c->count-1)), 1))
  memmove(&c->i[idx], &c->i[idx + 1],
          sizeof(sppage*) * (c->count - idx - 1));
 c->count--;
 return 0;
}

canonical_original_code:
int sp_catdel(struct spcat *c, unsigned int idx)
{
 ((void) (0));
 if (__builtin_expect(!! (idx != (unsigned int)(c->count-1)), 1))
  memmove(&c->i[idx], &c->i[idx + 1],
          sizeof(struct sppage *) * (c->count - idx - 1));
 c->count--;
 return 0;
}

variable_types:
idx
unsigned int


original_code:
sppage*
sp_catfind(spcat *c, char *rkey, int size, uint32_t *index)
{
 register int min = 0;
 register int max = c->count - 1;
 while (max >= min) {
  register int mid = min + ((max - min) >> 1);
  switch (cmpkey(c, c->i[mid], rkey, size)) {
  case -1: min = mid + 1;
   continue;
  case 1: max = mid - 1;
   continue;
  default: *index = mid;
   return c->i[mid];
  }
 }
 *index = min;
 return ((void *)0);
}

canonical_original_code:
struct sppage *sp_catfind(struct spcat *c, char *rkey, int size, unsigned int *index)
{
 register int min = 0;
 register int max = c->count - 1;
 while (max >= min) {
  register int mid = min + ((max - min) >> 1);
  switch (cmpkey(c, c->i[mid], rkey, size)) {
  case -1: min = mid + 1;
   continue;
  case 1: max = mid - 1;
   continue;
  default: *index = mid;
   return c->i[mid];
  }
 }
 *index = min;
 return ((void *)0);
}

variable_types: struct spcat { struct spa { void *(*alloc)(void *ptr, unsigned long size, void *arg); void *arg; } *a; struct sppage **i; unsigned int count; unsigned int top; int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg); void *cmparg; } *

variable_types:
rkey
char *

variable_types: size int

variable_types:
index
unsigned int *

variable_types: min int

variable_types: max int

variable_types: mid int


original_code:
sppage *sp_catroute(spcat *c, char *rkey, int size, uint32_t *idx)
{
 if (__builtin_expect(!! (c->count == 1), 0))
  return c->i[0];
 uint32_t i;
 sppage *p = sp_catfind(c, rkey, size, &i);
 if (__builtin_expect(!! (p), 1)) {
  *idx = i;
  return p;
 }
 if (__builtin_expect(!! (i >= c->count), 0))
  i = c->count - 1;
 if (i > 0 && c->cmp(c->i[i]->min->key, c->i[i]->min->size,
                     rkey,
                     size, c->cmparg) == 1) {
  i = i - 1;
 }
 if (idx)
  *idx = i;
 return c->i[i];
}

canonical_original_code:
struct sppage *sp_catroute(struct spcat *c, char *rkey, int size, unsigned int *idx)
{
 if (__builtin_expect(!! (c->count == 1), 0))
  return c->i[0];
 unsigned int i;
 struct sppage *p = sp_catfind(c, rkey, size, &i);
 if (__builtin_expect(!! (p), 1)) {
  *idx = i;
  return p;
 }
 if (__builtin_expect(!! (i >= c->count), 0))
  i = c->count - 1;
 if (i > 0 && c->cmp(c->i[i]->min->key, c->i[i]->min->size,
                     rkey,
                     size, c->cmparg) == 1) {
  i = i - 1;
 }
 if (idx)
  *idx = i;
 return c->i[i];
}

variable_types:
idx
unsigned int *


decompiled_code:
__int64 __fastcall sp_catown(__int64 a1, unsigned int a2, __int64 a3)
{
__int64 v4; // r13
__int64 result; // rax
__int64 v6; // rdx

v4 = a3 + 11;
result = cmpkey(a1, *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * a2), a3 + 11, *(unsigned __int16 *)(a3 + 8));
if ( !(_DWORD)result )
return 1LL;
if ( (_DWORD)result == 1 )
{
if ( !a2 )
return result;
LABEL_4:
v6 = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * (a2 + 1)) + 28LL);
return (*(unsigned int (__fastcall **)(__int64, _QWORD, __int64, _QWORD, _QWORD))(a1 + 24))(
v4,
*(unsigned __int16 *)(a3 + 8),
v6 + 11,
*(unsigned __int16 *)(v6 + 8),
*(_QWORD *)(a1 + 32)) == -1;
}
if ( (_DWORD)result != -1 )
goto LABEL_4;
result = 1LL;
if ( *(_DWORD *)(a1 + 16) - 1 != a2 )
goto LABEL_4;
return result;
}

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

v4 = a3 + 11;
result = func4(a1, *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * a2), a3 + 11, *(unsigned __int16 *)(a3 + 8));
if ( !(_DWORD)result )
return 1LL;
if ( (_DWORD)result == 1 )
{
if ( !a2 )
return result;
LABEL_4:
v6 = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * (a2 + 1)) + 28LL);
return (*(unsigned int (__fastcall **)(__int64, _QWORD, __int64, _QWORD, _QWORD))(a1 + 24))(
v4,
*(unsigned __int16 *)(a3 + 8),
v6 + 11,
*(unsigned __int16 *)(v6 + 8),
*(_QWORD *)(a1 + 32)) == -1;
}
if ( (_DWORD)result != -1 )
goto LABEL_4;
result = 1LL;
if ( *(_DWORD *)(a1 + 16) - 1 != a2 )
goto LABEL_4;
return result;
}

original_code:
int sp_catown(spcat *c, uint32_t idx, spv *v)
{
 register sppage *p = c->i[idx];
 switch (cmpkey(c, p, v->key, v->size)) {
 case 0:
  return 1;
 case -1:
  if (idx == c->count-1)
   return 1;
  break;
 case 1:
  if (idx == 0)
   return 1;
  break;
 }
 if (c->cmp(v->key, v->size,
            c->i[idx + 1]->min->key,
            c->i[idx + 1]->min->size, c->cmparg) == -1)
  return 1;
 return 0;
}

canonical_original_code:
int sp_catown(struct spcat *c, unsigned int idx, struct spv *v)
{
 register struct sppage *p = c->i[idx];
 switch (cmpkey(c, p, v->key, v->size)) {
 case 0:
  return 1;
 case -1:
  if (idx == c->count-1)
   return 1;
  break;
 case 1:
  if (idx == 0)
   return 1;
  break;
 }
 if (c->cmp(v->key, v->size,
            c->i[idx + 1]->min->key,
            c->i[idx + 1]->min->size, c->cmparg) == -1)
  return 1;
 return 0;
}

variable_types: struct spcat { struct spa { void *(*alloc)(void *ptr, unsigned long size, void *arg); void *arg; } *a; struct sppage { unsigned long id; unsigned long offset; void *epoch; unsigned int size; struct spv { unsigned int epoch; unsigned int crc; unsigned short size; unsigned char flags; char key[]; } *min; struct spv *max; struct splist { struct splist *next; } link; } **i; unsigned int count; unsigned int top; int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg); void *cmparg; } *

variable_types:
v
struct spv *


decompiled_code:
__int64 __fastcall sp_listappend(__int64 a1, _QWORD *a2)
{
_QWORD *v2; // rax
__int64 result; // rax

*a2 = a1;
v2 = *(_QWORD **)(a1 + 8);
a2[1] = v2;
*v2 = a2;
result = *a2;
*(_QWORD *)(*a2 + 8LL) = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, _QWORD *a2)
{
_QWORD *v2; // rax
__int64 result; // rax

*a2 = a1;
v2 = *(_QWORD **)(a1 + 8);
a2[1] = v2;
*v2 = a2;
result = *a2;
*(_QWORD *)(*a2 + 8LL) = a2;
return result;
}

original_code:
static inline void
sp_listappend(splist *h, splist *n) {
 n->next = h;
 n->prev = h->prev;
 n->prev->next = n;
 n->next->prev = n;
}

canonical_original_code:
static inline void sp_listappend(struct splist *h, struct splist *n) {
 n->next = h;
 n->prev = h->prev;
 n->prev->next = n;
 n->next->prev = n;
}

variable_types: struct splist { struct splist *next; } *

variable_types:
n
struct splist *


decompiled_code:
__int64 __fastcall sp_repcmp(const void *a1, const void *a2)
{
return **(_DWORD **)a2 < **(_DWORD **)a1 ? 1 : -1;
}

canonical_decompiled_code:
__int64 __fastcall func7(const void *a1, const void *a2)
{
return **(_DWORD **)a2 < **(_DWORD **)a1 ? 1 : -1;
}

original_code:
static inline int sp_repcmp(const void *p1, const void *p2) {
 register const spepoch *a = *(spepoch**)p1;
 register const spepoch *b = *(spepoch**)p2;
 ((void) (0));
 return (a->epoch > b->epoch)? 1: -1;
}

canonical_original_code:
static inline int sp_repcmp(void *p1, void *p2) {
 register struct spepoch *a = *(spepoch**)p1;
 register struct spepoch *b = *(spepoch**)p2;
 ((void) (0));
 return (a->epoch > b->epoch)? 1: -1;
}

variable_types: struct spepoch { unsigned int epoch; unsigned int n; unsigned int ngc; unsigned int nupdate; enum spepochtype { SPUNDEF=0, SPLIVE=1, SPXFER=2, SPDB=3 } type; unsigned int recover; struct spfile { struct spa { void *(*alloc)(void *ptr, unsigned long size, void *arg); void *arg; } *a; int creat; unsigned long used; unsigned long size; unsigned long svp; char *file; int fd; char *map; } log; unsigned char lock; struct splist { struct splist *next; } pages; struct splist link; } *

user_defined_types: struct spepoch { unsigned int epoch; unsigned int n; unsigned int ngc; unsigned int nupdate; enum spepochtype type; unsigned int recover; struct spfile log; unsigned char lock; struct splist pages; struct splist link; }

user_defined_types: struct spfile { struct spa *a; int creat; unsigned long used; unsigned long size; unsigned long svp; char *file; int fd; char *map; }


original_code:
void sp_repinit(sprep *r, spa *a) {
 sp_listinit(&r->l);
 r->a = a;
 r->n = 0;
 r->ndb = 0;
 r->nxfer = 0;
 r->epoch = 0;
}

canonical_original_code:
void sp_repinit(struct sprep *r, struct spa *a) {
 sp_listinit(&r->l);
 r->a = a;
 r->n = 0;
 r->ndb = 0;
 r->nxfer = 0;
 r->epoch = 0;
}

variable_types: struct sprep { struct spa { void *(*alloc)(void *ptr, unsigned long size, void *arg); void *arg; } *a; unsigned int epoch; struct splist { struct splist *next; } l; int n; int ndb; int nxfer; } *

variable_types:
a
struct spa *

user_defined_types: struct sprep { struct spa *a; unsigned int epoch; struct splist l; int n; int ndb; int nxfer; }


original_code:
int sp_repprepare(sprep *r) {
 spepoch **a = sp_malloc(r->a, sizeof(spepoch*) * r->n);
 if (__builtin_expect(!! (a == ((void *)0)), 0))
  return -1;
 uint32_t epoch = 0;
 int j = 0;
 splist *i;
 for (i = (&r->l)->next; i != &r->l; i = (i)->next) {
  a[j] = ((spepoch*)((char*)(i) - __builtin_offsetof(spepoch, link)));
  if (a[j]->epoch > epoch)
   epoch = a[j]->epoch;
  j++;
 }
 qsort(a, r->n, sizeof(spepoch*), sp_repcmp);
 sp_listinit(&r->l);
 j = 0;
 while (j < r->n) {
  sp_listinit(&a[j]->link);
  sp_listappend(&r->l, &a[j]->link);
  j++;
 }
 sp_free(r->a, a);
 r->epoch = epoch;
 return 0;
}

canonical_original_code:
int sp_repprepare(struct sprep *r) {
 struct spepoch **a = sp_malloc(r->a, sizeof(spepoch*) * r->n);
 if (__builtin_expect(!! (a == ((void *)0)), 0))
  return -1;
 unsigned int epoch = 0;
 int j = 0;
 struct splist *i;
 for (i = (&r->l)->next; i != &r->l; i = (i)->next) {
  a[j] = ((struct spepoch *)((char *)(i) - __builtin_offsetof(spepoch, link)));
  if (a[j]->epoch > epoch)
   epoch = a[j]->epoch;
  j++;
 }
 qsort(a, r->n, sizeof(struct spepoch *), sp_repcmp);
 sp_listinit(&r->l);
 j = 0;
 while (j < r->n) {
  sp_listinit(&a[j]->link);
  sp_listappend(&r->l, &a[j]->link);
  j++;
 }
 sp_free(r->a, a);
 r->epoch = epoch;
 return 0;
}

variable_types: struct spepoch { unsigned int epoch; unsigned int n; unsigned int ngc; unsigned int nupdate; enum spepochtype { SPUNDEF=0, SPLIVE=1, SPXFER=2, SPDB=3 } type; unsigned int recover; struct spfile { struct spa { void *(*alloc)(void *ptr, unsigned long size, void *arg); void *arg; } *a; int creat; unsigned long used; unsigned long size; unsigned long svp; char *file; int fd; char *map; } log; unsigned char lock; struct splist { struct splist *next; } pages; struct splist link; } **

variable_types:
epoch
unsigned int

variable_types: j int


decompiled_code:
__int64 __fastcall sp_repattach(__int64 a1, __int64 a2)
{
__int64 result; // rax

result = sp_listappend(a1 + 16, (_QWORD *)(a2 + 176));
++*(_DWORD *)(a1 + 32);
return result;
}

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

result = func3(a1 + 16, (_QWORD *)(a2 + 176));
++*(_DWORD *)(a1 + 32);
return result;
}

original_code:
void sp_repattach(sprep *r, spepoch *e) {
 sp_listappend(&r->l, &e->link);
 r->n++;
}

canonical_original_code:
void sp_repattach(struct sprep *r, struct spepoch *e) {
 sp_listappend(&r->l, &e->link);
 r->n++;
}

variable_types: struct spepoch { unsigned int epoch; unsigned int n; unsigned int ngc; unsigned int nupdate; enum spepochtype { SPUNDEF=0, SPLIVE=1, SPXFER=2, SPDB=3 } type; unsigned int recover; struct spfile { struct spa *a; int creat; unsigned long used; unsigned long size; unsigned long svp; char *file; int fd; char *map; } log; unsigned char lock; struct splist pages; struct splist link; } *


original_code:
void sp_repset(sprep *r, spepoch *e, spepochtype t) {
 switch (t) {
 case SPUNDEF:
  if (e->type == SPXFER)
   r->nxfer--;
  else
  if (e->type == SPDB)
   r->ndb--;
  break;
 case SPLIVE:
  ((void) (0));
  break;
 case SPXFER:
  ((void) (0));
  r->nxfer++;
  break;
 case SPDB:
  ((void) (0));
  if (e->type == SPXFER)
   r->nxfer--;
  r->ndb++;
  break;
 }
 e->type = t;
}

canonical_original_code:
void sp_repset(struct sprep *r, struct spepoch *e, enum spepochtype t) {
 switch (t) {
 case SPUNDEF:
  if (e->type == SPXFER)
   r->nxfer--;
  else
  if (e->type == SPDB)
   r->ndb--;
  break;
 case SPLIVE:
  ((void) (0));
  break;
 case SPXFER:
  ((void) (0));
  r->nxfer++;
  break;
 case SPDB:
  ((void) (0));
  if (e->type == SPXFER)
   r->nxfer--;
  r->ndb++;
  break;
 }
 e->type = t;
}

variable_types: enum spepochtype { SPUNDEF=0, SPLIVE=1, SPXFER=2, SPDB=3 }


decompiled_code:
void __fastcall sp_repdetach(__int64 a1, __int64 a2)
{
sp_listunlink((__int64 *)(a2 + 176));
--*(_DWORD *)(a1 + 32);
sp_repset(a1, a2, 0);
}

original_code:
void sp_repdetach(sprep *r, spepoch *e) {
 sp_listunlink(&e->link);
 r->n--;
 sp_repset(r, e, SPUNDEF);
}

canonical_original_code:
void sp_repdetach(struct sprep *r, struct spepoch *e) {
 sp_listunlink(&e->link);
 r->n--;
 sp_repset(r, e, SPUNDEF);
}

user_defined_types: enum spepochtype { SPUNDEF=0, SPLIVE=1, SPXFER=2, SPDB=3 }


canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, _QWORD *a2)
{
_QWORD *v2; // rax
__int64 result; // rax

*a2 = a1;
v2 = *(_QWORD **)(a1 + 8);
a2[1] = v2;
*v2 = a2;
result = *a2;
*(_QWORD *)(*a2 + 8LL) = a2;
return result;
}


decompiled_code:
char __fastcall sp_lock(char *a1)
{
char result; // al
int v2; // ebx

result = *a1;
*a1 = 1;
if ( result )
{
v2 = 0;
while ( 1 )
{
_mm_pause();
if ( !*a1 )
{
result = *a1;
*a1 = 1;
if ( !result )
break;
}
if ( (unsigned int)++v2 > 0x64 )
usleep(0);
}
}
return result;
}

canonical_decompiled_code:
char __fastcall func5(char *a1)
{
char result; // al
int v2; // ebx

result = *a1;
*a1 = 1;
if ( result )
{
v2 = 0;
while ( 1 )
{
_mm_pause();
if ( !*a1 )
{
result = *a1;
*a1 = 1;
if ( !result )
break;
}
if ( (unsigned int)++v2 > 0x64 )
usleep(0);
}
}
return result;
}

original_code:
static inline void
sp_lock(volatile spspinlock *l) {
 if (__sync_lock_test_and_set(l, 1) != 0) {
  unsigned int spin_count = 0U;
  for (;;) {
   __asm__ ("pause");
   if (*l == 0U && __sync_lock_test_and_set(l, 1) == 0)
    break;
   if (++spin_count > 100U)
    usleep(0);
  }
 }
}

canonical_original_code:
static inline void sp_lock(unsigned char *l) {
 if (__sync_lock_test_and_set(l, 1) != 0) {
  unsigned int spin_count = 0U;
  for (;;) {
   __asm__ ("pause");
   if (*l == 0U && __sync_lock_test_and_set(l, 1) == 0)
    break;
   if (++spin_count > 100U)
    usleep(0);
  }
 }
}

variable_types:
l
unsigned char *


original_code:
int sp_gc(sp *s, spepoch *x)
{
 for (;;)
 {
  sp_lock(&s->lockr);
  spepoch *g = sp_repgc(&s->rep, s->env->gcfactor);
  sp_unlock(&s->lockr);
  if (g == ((void *)0))
   break;
  int rc;
  splist *i, *n;
  for (i = (&g->pages)->next; i != &g->pages && (n = i->next); i = n) {
   sppage *p = ((sppage*)((char*)(i) - __builtin_offsetof(sppage, link)));
   sppageh *h = (sppageh*)(g->db.map + p->offset);
   sp_lock(&x->lock);
   rc = sp_mapensure(&x->db, sizeof(sppageh) + h->size, s->env->dbgrow);
   if (__builtin_expect(!! (rc == -1), 0)) {
    sp_unlock(&x->lock);
    return sp_em(s, 8|16, x->epoch, "failed to remap db file");
   }
   sp_unlock(&x->lock);
   memcpy(x->db.map + x->db.used, h, sizeof(sppageh) + h->size);
   sp_lock(&s->locks);
   sp_listunlink(&p->link);
   sp_listappend(&x->pages, &p->link);
   p->epoch = x;
   p->offset = x->db.used;
   sp_unlock(&s->locks);
   sp_mapuse(&x->db, sizeof(sppageh) + h->size);
  }
  rc = sp_mapunlink(&g->db);
  if (__builtin_expect(!! (rc == -1), 0))
   return sp_em(s, 8|16, g->epoch, "failed to unlink db file");
  rc = sp_mapclose(&g->db);
  if (__builtin_expect(!! (rc == -1), 0))
   return sp_em(s, 8|16, g->epoch, "failed to close db file");
  sp_lock(&s->lockr);
  sp_repdetach(&s->rep, g);
  sp_free(&s->a, g);
  sp_unlock(&s->lockr);
 }
 return 0;
}

canonical_original_code:
int sp_gc(struct sp *s, struct spepoch *x)
{
 for (;;)
 {
  sp_lock(&s->lockr);
  struct spepoch *g = sp_repgc(&s->rep, s->env->gcfactor);
  sp_unlock(&s->lockr);
  if (g == ((void *)0))
   break;
  int rc;
  struct splist *i; struct splist *n;
  for (i = (&g->pages)->next; i != &g->pages && (n = i->next); i = n) {
   struct sppage *p = ((sppage*)((char*)(i) - __builtin_offsetof(sppage, link)));
   struct sppageh *h = (sppageh*)(g->db.map + p->offset);
   sp_lock(&x->lock);
   rc = sp_mapensure(&x->db, sizeof(sppageh) + h->size, s->env->dbgrow);
   if (__builtin_expect(!! (rc == -1), 0)) {
    sp_unlock(&x->lock);
    return sp_em(s, 8|16, x->epoch, "failed to remap db file");
   }
   sp_unlock(&x->lock);
   memcpy(x->db.map + x->db.used, h, sizeof(sppageh) + h->size);
   sp_lock(&s->locks);
   sp_listunlink(&p->link);
   sp_listappend(&x->pages, &p->link);
   p->epoch = x;
   p->offset = x->db.used;
   sp_unlock(&s->locks);
   sp_mapuse(&x->db, sizeof(sppageh) + h->size);
  }
  rc = sp_mapunlink(&g->db);
  if (__builtin_expect(!! (rc == -1), 0))
   return sp_em(s, 8|16, g->epoch, "failed to unlink db file");
  rc = sp_mapclose(&g->db);
  if (__builtin_expect(!! (rc == -1), 0))
   return sp_em(s, 8|16, g->epoch, "failed to close db file");
  sp_lock(&s->lockr);
  sp_repdetach(&s->rep, g);
  sp_free(&s->a, g);
  sp_unlock(&s->lockr);
 }
 return 0;
}

variable_types: struct sp { enum spmagic { SPMCUR=357046582, SPMENV=102058036, SPMDB=16695550, SPMNONE=0 } m; struct spenv { enum spmagic { SPMCUR=357046582, SPMENV=102058036, SPMDB=16695550, SPMNONE=0 } m; struct spe { unsigned char lock; int type; int errno_; char e[256]; } e; int inuse; void *(*alloc)(void *ptr, unsigned long size, void *arg); void *allocarg; int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg); void *cmparg; unsigned int flags; char *dir; int merge; unsigned int mergewm; unsigned int page; unsigned int dbnewsize; float dbgrow; int gc; float gcfactor; } *env; struct spa { void *(*alloc)(void *ptr, unsigned long size, void *arg); void *arg; } a; struct sprep { struct spa *a; unsigned int epoch; struct splist { struct splist *next; } l; int n; int ndb; int nxfer; } rep; enum sptxn { SPTSS=0, SPTMS=1 } txn; struct spi { struct spa *a; int pagesize; struct spipage { unsigned short count; struct spv { unsigned int epoch; unsigned int crc; unsigned short size; unsigned char flags; char key[]; } *i[]; } **i; unsigned int itop; unsigned int icount; unsigned int count; int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg); void *cmparg; } *i; struct spi itxn; int iskip; unsigned long psn; struct spcat { struct spa *a; struct sppage { unsigned long id; unsigned long offset; void *epoch; unsigned int size; struct spv *min; struct spv *max; struct splist link; } **i; unsigned int count; unsigned int top; int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg); void *cmparg; } s; struct spbatch { struct iovec { void *iov_base; unsigned long iov_len; } iov[1024]; int iovc; } lb; int stop; struct sptask { int run; void *arg; unsigned long id; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } l; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } c; } merger; struct sprefset { struct spref { unsigned char type; union { struct spvh { unsigned int crc; unsigned int size; unsigned int voffset; unsigned int vsize; unsigned char flags; char key[]; } *vh; struct spv *v; } v; } *r; int used; int max; } refs; struct spfile { struct spa *a; int creat; unsigned long used; unsigned long size; unsigned long svp; char *file; int fd; char *map; } lockdb; int lockc; unsigned char lockr; unsigned char locks; unsigned char locki; struct spe e; } *

variable_types: struct spepoch { unsigned int epoch; unsigned int n; unsigned int ngc; unsigned int nupdate; enum spepochtype { SPUNDEF=0, SPLIVE=1, SPXFER=2, SPDB=3 } type; unsigned int recover; struct spfile log; unsigned char lock; struct splist pages; struct splist link; } *

variable_types: rc int

variable_types: struct sppage { unsigned long id; unsigned long offset; void *epoch; unsigned int size; struct spv { unsigned int epoch; unsigned int crc; unsigned short size; unsigned char flags; char key[]; } *min; struct spv *max; struct splist { struct splist *next; } link; } *

variable_types: struct sppageh { unsigned int crc; unsigned long id; unsigned short count; unsigned int size; unsigned int bsize; } *

user_defined_types: struct sp { enum spmagic m; struct spenv *env; struct spa a; struct sprep rep; enum sptxn txn; struct spi *i; struct spi itxn; int iskip; unsigned long psn; struct spcat s; struct spbatch lb; int stop; struct sptask merger; struct sprefset refs; struct spfile lockdb; int lockc; unsigned char lockr; unsigned char locks; unsigned char locki; struct spe e; }

user_defined_types: struct spbatch { struct iovec iov[1024]; int iovc; }

user_defined_types: struct sptask { int run; void *arg; unsigned long id; union pthread_mutex_t l; union pthread_cond_t c; }

user_defined_types: struct sprefset { struct spref *r; int used; int max; }

user_defined_types: struct spenv { enum spmagic m; struct spe e; int inuse; void *(*alloc)(void *ptr, unsigned long size, void *arg); void *allocarg; int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg); void *cmparg; unsigned int flags; char *dir; int merge; unsigned int mergewm; unsigned int page; unsigned int dbnewsize; float dbgrow; int gc; float gcfactor; }

user_defined_types: struct spi { struct spa *a; int pagesize; struct spipage **i; unsigned int itop; unsigned int icount; unsigned int count; int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg); void *cmparg; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: union pthread_cond_t { struct __pthread_cond_s __data; char __size[48]; long long __align; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }

user_defined_types: struct spref { unsigned char type; union { struct spvh *vh; struct spv *v; } v; }

user_defined_types: struct spipage { unsigned short count; struct spv *i[]; }


cmp

decompiled_code:
__int64 __fastcall cmp(_DWORD *a1, __int64 a2, _DWORD *a3)
{
__int64 result; // rax

result = 0LL;
if ( *a1 != *a3 )
result = *a3 < *a1 ? 1 : -1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_DWORD *a1, __int64 a2, _DWORD *a3)
{
__int64 result; // rax

result = 0LL;
if ( *a1 != *a3 )
result = *a3 < *a1 ? 1 : -1;
return result;
}

original_code:
static inline int
cmp(char *a, size_t asz, char *b, size_t bsz, void *arg) {
 register uint32_t av = *(uint32_t*)a;
 register uint32_t bv = *(uint32_t*)b;
 if (av == bv)
  return 0;
 return (av > bv) ? 1 : -1;
}

canonical_original_code:
static inline int cmp(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg) {
 register unsigned int av = *(uint32_t*)a;
 register unsigned int bv = *(uint32_t*)b;
 if (av == bv)
  return 0;
 return (av > bv) ? 1 : -1;
}

variable_types:
a
char *

variable_types:
asz
unsigned long

variable_types:
b
char *

variable_types:
bsz
unsigned long

variable_types:
arg
void *

variable_types:
av
unsigned int

variable_types:
bv
unsigned int


decompiled_code:
__int64 limit_key()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 v2; // rax
__int64 v3; // rbp
char v5[25]; // [rsp+Fh] [rbp-19h] BYREF

v0 = sp_env();
if ( !v0 )
{
printf("fail (%s:%d) %s\n", "limit.c", 27LL, "env != NULL");
fflush(0LL);
abort();
}
v1 = v0;
if ( (unsigned int)sp_ctl(v0, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "limit.c", 28LL, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_ctl(v1, 2LL, cmp, 0LL) )
{
printf("fail (%s:%d) %s\n", "limit.c", 29LL, "sp_ctl(env, SPCMP, cmp, NULL) == 0");
fflush(0LL);
abort();
}
v2 = sp_open(v1);
v3 = v2;
if ( !v2 )
{
printf("fail (%s:%d) %s\n", "limit.c", 31LL, "db != NULL");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_set(v2, v5, 0x10000LL, v5, 1LL) != -1 )
{
printf("fail (%s:%d) %s\n", "limit.c", 33LL, "sp_set(db, buf, UINT16_MAX + 1, buf, sizeof(buf)) == -1");
fflush(0LL);
abort();
}
if ( !sp_error(v3) )
{
printf("fail (%s:%d) %s\n", "limit.c", 34LL, "sp_error(db) != NULL");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v3) )
{
printf("fail (%s:%d) %s\n", "limit.c", 35LL, "sp_destroy(db) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v1) )
{
printf("fail (%s:%d) %s\n", "limit.c", 36LL, "sp_destroy(env) == 0");
fflush(0LL);
abort();
}
return rmrf("./rep");
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 v2; // rax
__int64 v3; // rbp
char v5[25]; // [rsp+Fh] [rbp-19h] BYREF

v0 = sp_env();
if ( !v0 )
{
printf("fail (%s:%d) %s\n", "limit.c", 27LL, "env != NULL");
fflush(0LL);
abort();
}
v1 = v0;
if ( (unsigned int)sp_ctl(v0, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "limit.c", 28LL, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_ctl(v1, 2LL, cmp, 0LL) )
{
printf("fail (%s:%d) %s\n", "limit.c", 29LL, "sp_ctl(env, SPCMP, cmp, NULL) == 0");
fflush(0LL);
abort();
}
v2 = sp_open(v1);
v3 = v2;
if ( !v2 )
{
printf("fail (%s:%d) %s\n", "limit.c", 31LL, "db != NULL");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_set(v2, v5, 0x10000LL, v5, 1LL) != -1 )
{
printf("fail (%s:%d) %s\n", "limit.c", 33LL, "sp_set(db, buf, UINT16_MAX + 1, buf, sizeof(buf)) == -1");
fflush(0LL);
abort();
}
if ( !sp_error(v3) )
{
printf("fail (%s:%d) %s\n", "limit.c", 34LL, "sp_error(db) != NULL");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v3) )
{
printf("fail (%s:%d) %s\n", "limit.c", 35LL, "sp_destroy(db) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v1) )
{
printf("fail (%s:%d) %s\n", "limit.c", 36LL, "sp_destroy(env) == 0");
fflush(0LL);
abort();
}
return func1("./rep");
}

original_code:
static void
limit_key(void) {
 void *env = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "limit.c", 27, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 28, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPCMP, cmp, ((void *)0)) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 29, "sp_ctl(env, SPCMP, cmp, NULL) == 0"); fflush(((void *)0)); abort(); } });
 void *db = sp_open(env);
 ({ if (! (db != ((void *)0))) { printf("fail (%s:%d) %s\n", "limit.c", 31, "db != NULL"); fflush(((void *)0)); abort(); } });
 char buf[1];
 ({ if (! (sp_set(db, buf, (65535) + 1, buf, sizeof(buf)) == -1)) { printf("fail (%s:%d) %s\n", "limit.c", 33, "sp_set(db, buf, UINT16_MAX + 1, buf, sizeof(buf)) == -1"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_error(db) != ((void *)0))) { printf("fail (%s:%d) %s\n", "limit.c", 34, "sp_error(db) != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(db) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 35, "sp_destroy(db) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 36, "sp_destroy(env) == 0"); fflush(((void *)0)); abort(); } });
 rmrf(dbrep);
}

canonical_original_code:
static void limit_key() {
 void *env = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "limit.c", 27, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 28, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPCMP, cmp, ((void *)0)) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 29, "sp_ctl(env, SPCMP, cmp, NULL) == 0"); fflush(((void *)0)); abort(); } });
 void *db = sp_open(env);
 ({ if (! (db != ((void *)0))) { printf("fail (%s:%d) %s\n", "limit.c", 31, "db != NULL"); fflush(((void *)0)); abort(); } });
 char buf[1];
 ({ if (! (sp_set(db, buf, (65535) + 1, buf, sizeof(buf)) == -1)) { printf("fail (%s:%d) %s\n", "limit.c", 33, "sp_set(db, buf, UINT16_MAX + 1, buf, sizeof(buf)) == -1"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_error(db) != ((void *)0))) { printf("fail (%s:%d) %s\n", "limit.c", 34, "sp_error(db) != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(db) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 35, "sp_destroy(db) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 36, "sp_destroy(env) == 0"); fflush(((void *)0)); abort(); } });
 rmrf(dbrep);
}

variable_types:
env
void *

variable_types:
db
void *

variable_types:
buf
char [1]


decompiled_code:
__int64 limit_value()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 v2; // rax
__int64 v3; // rbp
char v5[25]; // [rsp+Fh] [rbp-19h] BYREF

v0 = sp_env();
if ( !v0 )
{
printf("fail (%s:%d) %s\n", "limit.c", 43LL, "env != NULL");
fflush(0LL);
abort();
}
v1 = v0;
if ( (unsigned int)sp_ctl(v0, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "limit.c", 44LL, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_ctl(v1, 2LL, cmp, 0LL) )
{
printf("fail (%s:%d) %s\n", "limit.c", 45LL, "sp_ctl(env, SPCMP, cmp, NULL) == 0");
fflush(0LL);
abort();
}
v2 = sp_open(v1);
v3 = v2;
if ( !v2 )
{
printf("fail (%s:%d) %s\n", "limit.c", 47LL, "db != NULL");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_set(v2, v5, 1LL, v5, 0x100000000LL) != -1 )
{
printf("fail (%s:%d) %s\n", "limit.c", 49LL, "sp_set(db, buf, sizeof(buf), buf, UINT32_MAX + 1ULL) == -1");
fflush(0LL);
abort();
}
if ( !sp_error(v3) )
{
printf("fail (%s:%d) %s\n", "limit.c", 50LL, "sp_error(db) != NULL");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v3) )
{
printf("fail (%s:%d) %s\n", "limit.c", 51LL, "sp_destroy(db) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v1) )
{
printf("fail (%s:%d) %s\n", "limit.c", 52LL, "sp_destroy(env) == 0");
fflush(0LL);
abort();
}
return rmrf("./rep");
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 v2; // rax
__int64 v3; // rbp
char v5[25]; // [rsp+Fh] [rbp-19h] BYREF

v0 = sp_env();
if ( !v0 )
{
printf("fail (%s:%d) %s\n", "limit.c", 43LL, "env != NULL");
fflush(0LL);
abort();
}
v1 = v0;
if ( (unsigned int)sp_ctl(v0, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "limit.c", 44LL, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_ctl(v1, 2LL, cmp, 0LL) )
{
printf("fail (%s:%d) %s\n", "limit.c", 45LL, "sp_ctl(env, SPCMP, cmp, NULL) == 0");
fflush(0LL);
abort();
}
v2 = sp_open(v1);
v3 = v2;
if ( !v2 )
{
printf("fail (%s:%d) %s\n", "limit.c", 47LL, "db != NULL");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_set(v2, v5, 1LL, v5, 0x100000000LL) != -1 )
{
printf("fail (%s:%d) %s\n", "limit.c", 49LL, "sp_set(db, buf, sizeof(buf), buf, UINT32_MAX + 1ULL) == -1");
fflush(0LL);
abort();
}
if ( !sp_error(v3) )
{
printf("fail (%s:%d) %s\n", "limit.c", 50LL, "sp_error(db) != NULL");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v3) )
{
printf("fail (%s:%d) %s\n", "limit.c", 51LL, "sp_destroy(db) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v1) )
{
printf("fail (%s:%d) %s\n", "limit.c", 52LL, "sp_destroy(env) == 0");
fflush(0LL);
abort();
}
return func1("./rep");
}

original_code:
static void
limit_value(void) {
 void *env = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "limit.c", 43, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 44, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPCMP, cmp, ((void *)0)) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 45, "sp_ctl(env, SPCMP, cmp, NULL) == 0"); fflush(((void *)0)); abort(); } });
 void *db = sp_open(env);
 ({ if (! (db != ((void *)0))) { printf("fail (%s:%d) %s\n", "limit.c", 47, "db != NULL"); fflush(((void *)0)); abort(); } });
 char buf[1];
 ({ if (! (sp_set(db, buf, sizeof(buf), buf, (4294967295U) + 1ULL) == -1)) { printf("fail (%s:%d) %s\n", "limit.c", 49, "sp_set(db, buf, sizeof(buf), buf, UINT32_MAX + 1ULL) == -1"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_error(db) != ((void *)0))) { printf("fail (%s:%d) %s\n", "limit.c", 50, "sp_error(db) != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(db) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 51, "sp_destroy(db) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 52, "sp_destroy(env) == 0"); fflush(((void *)0)); abort(); } });
 rmrf(dbrep);
}

canonical_original_code:
static void limit_value() {
 void *env = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "limit.c", 43, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 44, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPCMP, cmp, ((void *)0)) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 45, "sp_ctl(env, SPCMP, cmp, NULL) == 0"); fflush(((void *)0)); abort(); } });
 void *db = sp_open(env);
 ({ if (! (db != ((void *)0))) { printf("fail (%s:%d) %s\n", "limit.c", 47, "db != NULL"); fflush(((void *)0)); abort(); } });
 char buf[1];
 ({ if (! (sp_set(db, buf, sizeof(buf), buf, (4294967295U) + 1ULL) == -1)) { printf("fail (%s:%d) %s\n", "limit.c", 49, "sp_set(db, buf, sizeof(buf), buf, UINT32_MAX + 1ULL) == -1"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_error(db) != ((void *)0))) { printf("fail (%s:%d) %s\n", "limit.c", 50, "sp_error(db) != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(db) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 51, "sp_destroy(db) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 52, "sp_destroy(env) == 0"); fflush(((void *)0)); abort(); } });
 rmrf(dbrep);
}


decompiled_code:
__int64 error_nonfatal()
{
__int64 v0; // rax
__int64 v1; // rbp
__int64 v2; // rax
__int64 v3; // rbx
__int64 result; // rax
int v5; // [rsp+8h] [rbp-20h] BYREF
int v6[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v0 = sp_env();
if ( !v0 )
{
printf("fail (%s:%d) %s\n", "limit.c", 59LL, "env != NULL");
fflush(0LL);
abort();
}
v1 = v0;
if ( (unsigned int)sp_ctl(v0, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "limit.c", 60LL, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_ctl(v1, 2LL, cmp, 0LL) )
{
printf("fail (%s:%d) %s\n", "limit.c", 61LL, "sp_ctl(env, SPCMP, cmp, NULL) == 0");
fflush(0LL);
abort();
}
v2 = sp_open(v1);
v3 = v2;
if ( !v2 )
{
printf("fail (%s:%d) %s\n", "limit.c", 63LL, "db != NULL");
fflush(0LL);
abort();
}
v6[0] = 1;
v5 = 1;
if ( (unsigned int)sp_set(v2, v6, 4LL, &v5, 4LL) )
{
printf("fail (%s:%d) %s\n", "limit.c", 65LL, "sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_set(v3, v6, 0x10000LL, &v5, 4LL) != -1 )
{
printf("fail (%s:%d) %s\n", "limit.c", 66LL, "sp_set(db, &k, UINT16_MAX + 1 , &v, sizeof(v)) == -1");
fflush(0LL);
abort();
}
if ( !sp_error(v3) )
{
printf("fail (%s:%d) %s\n", "limit.c", 67LL, "sp_error(db) != NULL");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_set(v3, v6, 4LL, &v5, 4LL) )
{
printf("fail (%s:%d) %s\n", "limit.c", 68LL, "sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0");
fflush(0LL);
abort();
}
if ( sp_error(v3) )
{
printf("fail (%s:%d) %s\n", "limit.c", 69LL, "sp_error(db) == NULL");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v3) )
{
printf("fail (%s:%d) %s\n", "limit.c", 70LL, "sp_destroy(db) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v1) )
{
printf("fail (%s:%d) %s\n", "limit.c", 71LL, "sp_destroy(env) == 0");
fflush(0LL);
abort();
}
result = rmrf("./rep");
if ( (_DWORD)result )
{
printf("fail (%s:%d) %s\n", "limit.c", 72LL, "rmrf(dbrep) == 0");
fflush(0LL);
abort();
}
return result;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 v0; // rax
__int64 v1; // rbp
__int64 v2; // rax
__int64 v3; // rbx
__int64 result; // rax
int v5; // [rsp+8h] [rbp-20h] BYREF
int v6[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v0 = sp_env();
if ( !v0 )
{
printf("fail (%s:%d) %s\n", "limit.c", 59LL, "env != NULL");
fflush(0LL);
abort();
}
v1 = v0;
if ( (unsigned int)sp_ctl(v0, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "limit.c", 60LL, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_ctl(v1, 2LL, cmp, 0LL) )
{
printf("fail (%s:%d) %s\n", "limit.c", 61LL, "sp_ctl(env, SPCMP, cmp, NULL) == 0");
fflush(0LL);
abort();
}
v2 = sp_open(v1);
v3 = v2;
if ( !v2 )
{
printf("fail (%s:%d) %s\n", "limit.c", 63LL, "db != NULL");
fflush(0LL);
abort();
}
v6[0] = 1;
v5 = 1;
if ( (unsigned int)sp_set(v2, v6, 4LL, &v5, 4LL) )
{
printf("fail (%s:%d) %s\n", "limit.c", 65LL, "sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_set(v3, v6, 0x10000LL, &v5, 4LL) != -1 )
{
printf("fail (%s:%d) %s\n", "limit.c", 66LL, "sp_set(db, &k, UINT16_MAX + 1 , &v, sizeof(v)) == -1");
fflush(0LL);
abort();
}
if ( !sp_error(v3) )
{
printf("fail (%s:%d) %s\n", "limit.c", 67LL, "sp_error(db) != NULL");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_set(v3, v6, 4LL, &v5, 4LL) )
{
printf("fail (%s:%d) %s\n", "limit.c", 68LL, "sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0");
fflush(0LL);
abort();
}
if ( sp_error(v3) )
{
printf("fail (%s:%d) %s\n", "limit.c", 69LL, "sp_error(db) == NULL");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v3) )
{
printf("fail (%s:%d) %s\n", "limit.c", 70LL, "sp_destroy(db) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v1) )
{
printf("fail (%s:%d) %s\n", "limit.c", 71LL, "sp_destroy(env) == 0");
fflush(0LL);
abort();
}
result = func1("./rep");
if ( (_DWORD)result )
{
printf("fail (%s:%d) %s\n", "limit.c", 72LL, "rmrf(dbrep) == 0");
fflush(0LL);
abort();
}
return result;
}

original_code:
static void
error_nonfatal(void) {
 void *env = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "limit.c", 59, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 60, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPCMP, cmp, ((void *)0)) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 61, "sp_ctl(env, SPCMP, cmp, NULL) == 0"); fflush(((void *)0)); abort(); } });
 void *db = sp_open(env);
 ({ if (! (db != ((void *)0))) { printf("fail (%s:%d) %s\n", "limit.c", 63, "db != NULL"); fflush(((void *)0)); abort(); } });
 uint32_t k = 1, v = 1;
 ({ if (! (sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 65, "sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_set(db, &k, (65535) + 1 , &v, sizeof(v)) == -1)) { printf("fail (%s:%d) %s\n", "limit.c", 66, "sp_set(db, &k, UINT16_MAX + 1 , &v, sizeof(v)) == -1"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_error(db) != ((void *)0))) { printf("fail (%s:%d) %s\n", "limit.c", 67, "sp_error(db) != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 68, "sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_error(db) == ((void *)0))) { printf("fail (%s:%d) %s\n", "limit.c", 69, "sp_error(db) == NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(db) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 70, "sp_destroy(db) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 71, "sp_destroy(env) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (rmrf(dbrep) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 72, "rmrf(dbrep) == 0"); fflush(((void *)0)); abort(); } });
}

canonical_original_code:
static void error_nonfatal() {
 void *env = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "limit.c", 59, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 60, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPCMP, cmp, ((void *)0)) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 61, "sp_ctl(env, SPCMP, cmp, NULL) == 0"); fflush(((void *)0)); abort(); } });
 void *db = sp_open(env);
 ({ if (! (db != ((void *)0))) { printf("fail (%s:%d) %s\n", "limit.c", 63, "db != NULL"); fflush(((void *)0)); abort(); } });
 unsigned int k = 1; unsigned int v = 1;
 ({ if (! (sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 65, "sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_set(db, &k, (65535) + 1 , &v, sizeof(v)) == -1)) { printf("fail (%s:%d) %s\n", "limit.c", 66, "sp_set(db, &k, UINT16_MAX + 1 , &v, sizeof(v)) == -1"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_error(db) != ((void *)0))) { printf("fail (%s:%d) %s\n", "limit.c", 67, "sp_error(db) != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 68, "sp_set(db, &k, sizeof(k), &v, sizeof(v)) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_error(db) == ((void *)0))) { printf("fail (%s:%d) %s\n", "limit.c", 69, "sp_error(db) == NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(db) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 70, "sp_destroy(db) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 71, "sp_destroy(env) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (rmrf(dbrep) == 0)) { printf("fail (%s:%d) %s\n", "limit.c", 72, "rmrf(dbrep) == 0"); fflush(((void *)0)); abort(); } });
}

variable_types:
k
unsigned int

variable_types:
v
unsigned int


decompiled_code:
__int64 __fastcall sp_crc32c(unsigned int a1, _DWORD *a2, int a3)
{
int v5; // er9
__int64 v6; // rdx
int v7; // eax
int v8; // eax
_DWORD *v9; // r15
unsigned int v10; // ecx
unsigned int v11; // edx
_DWORD *v12; // rdx
int v14; // [rsp+0h] [rbp-34h]

v5 = -(int)a2 & 3;
if ( v5 > a3 )
v5 = a3;
if ( v5 > 0 )
{
v6 = 0LL;
do
a1 = crc_tableil8_o32[(unsigned __int8)(*((_BYTE *)a2 + v6++) ^ a1)] ^ (a1 >> 8);
while ( v5 > (int)v6 );
a2 = (_DWORD *)((char *)a2 + (unsigned int)v5);
}
v7 = a3 - v5;
v14 = v7 & 7;
v8 = v7 >> 3;
if ( v8 > 0 )
{
v9 = &a2[2 * v8];
do
{
v10 = *a2 ^ a1;
v11 = a2[1];
a1 = crc_tableil8_o72[BYTE2(v10)] ^ crc_tableil8_o80[BYTE1(v10)] ^ crc_tableil8_o40[BYTE2(v11)] ^ crc_tableil8_o48[BYTE1(v11)] ^ crc_tableil8_o64[HIBYTE(v10)] ^ crc_tableil8_o88[(unsigned __int8)v10] ^ crc_tableil8_o32[HIBYTE(v11)] ^ crc_tableil8_o56[(unsigned __int8)v11];
a2 += 2;
}
while ( v9 != a2 );
}
if ( v14 > 0 )
{
v12 = (_DWORD *)((char *)a2 + (unsigned int)v14);
do
{
a2 = (_DWORD *)((char *)a2 + 1);
a1 = crc_tableil8_o32[(unsigned __int8)(*((_BYTE *)a2 - 1) ^ a1)] ^ (a1 >> 8);
}
while ( a2 != v12 );
}
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, _DWORD *a2, int a3)
{
int v5; // er9
__int64 v6; // rdx
int v7; // eax
int v8; // eax
_DWORD *v9; // r15
unsigned int v10; // ecx
unsigned int v11; // edx
_DWORD *v12; // rdx
int v14; // [rsp+0h] [rbp-34h]

v5 = -(int)a2 & 3;
if ( v5 > a3 )
v5 = a3;
if ( v5 > 0 )
{
v6 = 0LL;
do
a1 = crc_tableil8_o32[(unsigned __int8)(*((_BYTE *)a2 + v6++) ^ a1)] ^ (a1 >> 8);
while ( v5 > (int)v6 );
a2 = (_DWORD *)((char *)a2 + (unsigned int)v5);
}
v7 = a3 - v5;
v14 = v7 & 7;
v8 = v7 >> 3;
if ( v8 > 0 )
{
v9 = &a2[2 * v8];
do
{
v10 = *a2 ^ a1;
v11 = a2[1];
a1 = crc_tableil8_o72[BYTE2(v10)] ^ crc_tableil8_o80[BYTE1(v10)] ^ crc_tableil8_o40[BYTE2(v11)] ^ crc_tableil8_o48[BYTE1(v11)] ^ crc_tableil8_o64[HIBYTE(v10)] ^ crc_tableil8_o88[(unsigned __int8)v10] ^ crc_tableil8_o32[HIBYTE(v11)] ^ crc_tableil8_o56[(unsigned __int8)v11];
a2 += 2;
}
while ( v9 != a2 );
}
if ( v14 > 0 )
{
v12 = (_DWORD *)((char *)a2 + (unsigned int)v14);
do
{
a2 = (_DWORD *)((char *)a2 + 1);
a1 = crc_tableil8_o32[(unsigned __int8)(*((_BYTE *)a2 - 1) ^ a1)] ^ (a1 >> 8);
}
while ( a2 != v12 );
}
return a1;
}

original_code:
uint32_t sp_crc32c(uint32_t crc, const void *buf, int len)
{
 const char *p_buf = (const char*)buf;
 int initial_bytes = (sizeof(int32_t) - (intptr_t)p_buf) & (sizeof(int32_t) - 1);
 if (len < initial_bytes)
  initial_bytes = len;
 int li;
 for (li = 0; li < initial_bytes; li++)
  crc = crc_tableil8_o32[(crc ^ *p_buf++) & 0x000000FF] ^ (crc >> 8);
 len -= initial_bytes;
 int running_len = len & ~(sizeof(uint64_t) - 1);
 int end_bytes = len - running_len;
 for (li = 0; li < running_len / 8; li++) {
  crc ^= *(uint32_t*)p_buf;
  p_buf += 4;
  uint32_t term1 = crc_tableil8_o88[(crc) & 0x000000FF] ^
                   crc_tableil8_o80[(crc >> 8) & 0x000000FF];
  uint32_t term2 = crc >> 16;
  crc = term1 ^
        crc_tableil8_o72[term2 & 0x000000FF] ^
        crc_tableil8_o64[(term2 >> 8) & 0x000000FF];
  term1 = crc_tableil8_o56[(*(uint32_t*)p_buf) & 0x000000FF] ^
          crc_tableil8_o48[((*(uint32_t*)p_buf) >> 8) & 0x000000FF];
  term2 = (*(uint32_t*)p_buf) >> 16;
  crc = crc ^ term1 ^
        crc_tableil8_o40[term2 & 0x000000FF] ^
        crc_tableil8_o32[(term2 >> 8) & 0x000000FF];
  p_buf += 4;
 }
    for (li = 0; li < end_bytes; li++)
        crc = crc_tableil8_o32[(crc ^ *p_buf++) & 0x000000FF] ^ (crc >> 8);
    return crc;
}

canonical_original_code:
unsigned int sp_crc32c(unsigned int crc, void *buf, int len)
{
 char *p_buf = (const char*)buf;
 int initial_bytes = (sizeof(int32_t) - (intptr_t)p_buf) & (sizeof(int32_t) - 1);
 if (len < initial_bytes)
  initial_bytes = len;
 int li;
 for (li = 0; li < initial_bytes; li++)
  crc = crc_tableil8_o32[(crc ^ *p_buf++) & 0x000000FF] ^ (crc >> 8);
 len -= initial_bytes;
 int running_len = len & ~(sizeof(uint64_t) - 1);
 int end_bytes = len - running_len;
 for (li = 0; li < running_len / 8; li++) {
  crc ^= *(unsigned int *)p_buf;
  p_buf += 4;
  unsigned int term1 = crc_tableil8_o88[(crc) & 0x000000FF] ^
                   crc_tableil8_o80[(crc >> 8) & 0x000000FF];
  unsigned int term2 = crc >> 16;
  crc = term1 ^
        crc_tableil8_o72[term2 & 0x000000FF] ^
        crc_tableil8_o64[(term2 >> 8) & 0x000000FF];
  term1 = crc_tableil8_o56[(*(unsigned int *)p_buf) & 0x000000FF] ^
          crc_tableil8_o48[((*(unsigned int *)p_buf) >> 8) & 0x000000FF];
  term2 = (*(unsigned int *)p_buf) >> 16;
  crc = crc ^ term1 ^
        crc_tableil8_o40[term2 & 0x000000FF] ^
        crc_tableil8_o32[(term2 >> 8) & 0x000000FF];
  p_buf += 4;
 }
    for (li = 0; li < end_bytes; li++)
        crc = crc_tableil8_o32[(crc ^ *p_buf++) & 0x000000FF] ^ (crc >> 8);
    return crc;
}

variable_types:
crc
unsigned int

variable_types:
buf
void *

variable_types: len int

variable_types: li int

return_type: unsigned int


canonical_decompiled_code:
char __fastcall func0(char *a1)
{
char result; // al
int v2; // ebx

result = *a1;
*a1 = 1;
if ( result )
{
v2 = 0;
while ( 1 )
{
_mm_pause();
if ( !*a1 )
{
result = *a1;
*a1 = 1;
if ( !result )
break;
}
if ( (unsigned int)++v2 > 0x64 )
usleep(0);
}
}
return result;
}

variable_types:
l
unsigned char *


destroy

decompiled_code:
void destroy()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code: static void destroy(void *arg, small_hash__node *node) {}

canonical_original_code: static void destroy(void *arg, struct small_hash__node *node) {}

variable_types: struct small_hash__node { struct small_hash__node *prev; } *


usage

decompiled_code:
int __fastcall usage(const char *a1)
{
return fprintf(stderr, "Usage: %s <count>\n", a1);
}

canonical_decompiled_code:
int __fastcall func3(const char *a1)
{
return fprintf(stderr, "Usage: %s <count>\n", a1);
}

original_code: static void usage(char *progname) { fprintf(stderr, "Usage: %s <count>\n", progname); }

variable_types:
progname
char *


decompiled_code:
__suseconds_t get_time_micros()
{
struct timeval v1; // [rsp+0h] [rbp-18h] BYREF

if ( gettimeofday(&v1, 0LL) )
{
perror("gettimeofday");
abort();
}
return v1.tv_usec + 1000000 * v1.tv_sec;
}

canonical_decompiled_code:
__suseconds_t func4()
{
struct timeval v1; // [rsp+0h] [rbp-18h] BYREF

if ( gettimeofday(&v1, 0LL) )
{
perror("gettimeofday");
abort();
}
return v1.tv_usec + 1000000 * v1.tv_sec;
}

original_code:
static inline uint64_t get_time_micros() {
    struct timeval tv;
    int rc = gettimeofday(&tv, ((void *)0));
    if(0 != rc) {
        perror("gettimeofday");
        abort();
    }
    return tv.tv_sec * 1000000 + tv.tv_usec;
}

canonical_original_code:
static inline unsigned long get_time_micros() {
    struct timeval tv;
    int rc = gettimeofday(&tv, ((void *)0));
    if(0 != rc) {
        perror("gettimeofday");
        abort();
    }
    return tv.tv_sec * 1000000 + tv.tv_usec;
}

variable_types: struct timeval { long tv_sec; long tv_usec; }

variable_types: rc int

return_type: unsigned long


decompiled_code:
__int64 __fastcall by_name__hash_name(char *a1)
{
char v1; // al
unsigned int v2; // edx

v1 = *a1;
if ( !*a1 )
return 74565;
v2 = 74565;
do
{
v2 = v1 + 33 * v2;
v1 = *++a1;
}
while ( *a1 );
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1)
{
char v1; // al
unsigned int v2; // edx

v1 = *a1;
if ( !*a1 )
return 74565;
v2 = 74565;
do
{
v2 = v1 + 33 * v2;
v1 = *++a1;
}
while ( *a1 );
return v2;
}

original_code:
static small_hash__hash by_name__hash_name(const char *name)
{
    small_hash__hash result = 0x12345;
    const char *p;
    for(p = name; *p; p++) {
        result *= 33;
        result += *p;
    }
    return result;
}

canonical_original_code:
static unsigned int by_name__hash_name(char *name)
{
    unsigned int result = 0x12345;
    char *p;
    for(p = name; *p; p++) {
        result *= 33;
        result += *p;
    }
    return result;
}

variable_types:
name
char *

variable_types:
result
unsigned int

variable_types:
p
char *


decompiled_code:
__int64 __fastcall by_age__hash_age(unsigned int a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1)
{
return a1;
}

original_code:
static small_hash__hash by_age__hash_age(unsigned age)
{
    return age;
}

canonical_original_code:
static unsigned int by_age__hash_age(unsigned int age)
{
    return age;
}

variable_types:
age
unsigned int


decompiled_code:
__int64 __fastcall users__init(__int64 a1)
{
small_hash__table__init_dynamic(a1, &by_name_funcs, 0LL, 2LL);
return small_hash__table__init_dynamic(a1 + 64, &by_age_funcs, 0LL, 2LL);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
small_hash__table__init_dynamic(a1, &by_name_funcs, 0LL, 2LL);
return small_hash__table__init_dynamic(a1 + 64, &by_age_funcs, 0LL, 2LL);
}

original_code:
static void users__init(struct users *users)
{
    small_hash__table__init_dynamic(
        &users->by_name_table,
        &by_name_funcs, ((void *)0), 2);
    small_hash__table__init_dynamic(
        &users->by_age_table,
        &by_age_funcs, ((void *)0), 2);
}

variable_types: struct users { struct small_hash__table { struct small_hash__funcs { _Bool (*match_key)(void *user_arg, void *key, struct small_hash__node { struct small_hash__node *prev; } *); unsigned int (*get_hash)(void *user_arg, struct small_hash__node *); } *user_funcs; void *user_arg; unsigned int count; _Bool is_dynamic; unsigned int min_anchors_count; unsigned int low_watermark; unsigned int high_watermark; unsigned int expensive_lookup_count; unsigned int lookup_count; unsigned int anchors_count; struct small_hash__anchor { struct small_hash__node *first; } *anchors; unsigned int prevent_resizes_count; } by_name_table; struct small_hash__table by_age_table; } *

user_defined_types: struct users { struct small_hash__table by_name_table; struct small_hash__table by_age_table; }

user_defined_types: struct small_hash__table { struct small_hash__funcs *user_funcs; void *user_arg; unsigned int count; _Bool is_dynamic; unsigned int min_anchors_count; unsigned int low_watermark; unsigned int high_watermark; unsigned int expensive_lookup_count; unsigned int lookup_count; unsigned int anchors_count; struct small_hash__anchor *anchors; unsigned int prevent_resizes_count; }

user_defined_types: struct small_hash__funcs { _Bool (*match_key)(void *user_arg, void *key, struct small_hash__node *); unsigned int (*get_hash)(void *user_arg, struct small_hash__node *); }


decompiled_code:
__int64 __fastcall users__add(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
unsigned int v3; // eax

v2 = by_name__hash_name(*(char **)a2);
small_hash__table__add(a1, v2, a2 + 16);
v3 = by_age__hash_age(*(_DWORD *)(a2 + 8));
return small_hash__table__add(a1 + 64, v3, a2 + 32);
}

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

v2 = func0(*(char **)a2);
small_hash__table__add(a1, v2, a2 + 16);
v3 = func3(*(_DWORD *)(a2 + 8));
return small_hash__table__add(a1 + 64, v3, a2 + 32);
}

original_code:
static void users__add(struct users *users, struct user *u)
{
    small_hash__table__add(&users->by_name_table, by_name__hash_name(u->name), &u->by_name_node);
    small_hash__table__add(&users->by_age_table, by_age__hash_age(u->age), &u->by_age_node);
}

variable_types: struct user { char *name; unsigned int age; struct small_hash__node by_name_node; struct small_hash__node by_age_node; } *

user_defined_types: struct small_hash__anchor { struct small_hash__node *first; }

user_defined_types: struct small_hash__node { struct small_hash__node *prev; }


decompiled_code:
__int64 __fastcall users__del(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
unsigned int v3; // eax

v2 = by_name__hash_name(*(char **)a2);
small_hash__table__del(a1, v2, a2 + 16);
v3 = by_age__hash_age(*(_DWORD *)(a2 + 8));
return small_hash__table__del(a1 + 64, v3, a2 + 32);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
unsigned int v3; // eax

v2 = func0(*(char **)a2);
small_hash__table__del(a1, v2, a2 + 16);
v3 = func3(*(_DWORD *)(a2 + 8));
return small_hash__table__del(a1 + 64, v3, a2 + 32);
}

original_code:
static void users__del(struct users *users, struct user *u)
{
    small_hash__table__del(&users->by_name_table, by_name__hash_name(u->name), &u->by_name_node);
    small_hash__table__del(&users->by_age_table, by_age__hash_age(u->age), &u->by_age_node);
}

user_defined_types: struct user { char *name; unsigned int age; struct small_hash__node by_name_node; struct small_hash__node by_age_node; }


decompiled_code:
__int64 __fastcall users__fini(__int64 a1)
{
((void (*)(void))small_hash__table__fini)();
return small_hash__table__fini(a1 + 64);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
((void (*)(void))small_hash__table__fini)();
return small_hash__table__fini(a1 + 64);
}

original_code:
static void users__fini(struct users *users)
{
    small_hash__table__fini(&users->by_name_table);
    small_hash__table__fini(&users->by_age_table);
}


original_code:
static void init_internal(
    small_hash__table *table,
    struct small_hash__funcs *user_funcs, void *user_arg,
    unsigned anchors_count,
    small_hash__anchor anchors[],
    _Bool is_dynamic)
{
    table->user_funcs = user_funcs;
    table->user_arg = user_arg;
    table->is_dynamic = is_dynamic;
    table->anchors_count = anchors_count;
    table->anchors = anchors;
    table->count = 0;
    table->expensive_lookup_count = 0;
    table->lookup_count = 0;
    table->prevent_resizes_count = 0;
}

canonical_original_code:
static void init_internal(struct small_hash__table *table, struct small_hash__funcs *user_funcs, void *user_arg, unsigned int anchors_count, struct small_hash__anchor anchors[], _Bool is_dynamic)
{
    table->user_funcs = user_funcs;
    table->user_arg = user_arg;
    table->is_dynamic = is_dynamic;
    table->anchors_count = anchors_count;
    table->anchors = anchors;
    table->count = 0;
    table->expensive_lookup_count = 0;
    table->lookup_count = 0;
    table->prevent_resizes_count = 0;
}

variable_types: struct small_hash__table { struct small_hash__funcs { _Bool (*match_key)(void *user_arg, void *key, struct small_hash__node { struct small_hash__node *prev; } *); unsigned int (*get_hash)(void *user_arg, struct small_hash__node *); } *user_funcs; void *user_arg; unsigned int count; _Bool is_dynamic; unsigned int min_anchors_count; unsigned int low_watermark; unsigned int high_watermark; unsigned int expensive_lookup_count; unsigned int lookup_count; unsigned int anchors_count; struct small_hash__anchor { struct small_hash__node *first; } *anchors; unsigned int prevent_resizes_count; } *

variable_types:
anchors
struct small_hash__anchor []


find

decompiled_code:
__int64 __fastcall find(__int64 a1, unsigned int a2, __int64 a3)
{
__int64 i; // rbx

for ( i = *(_QWORD *)anchor_of_hash(a1, a2); i; i = *(_QWORD *)(i + 8) )
{
if ( (**(unsigned __int8 (__fastcall ***)(_QWORD, __int64, __int64))a1)(*(_QWORD *)(a1 + 8), a3, i) )
break;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned int a2, __int64 a3)
{
__int64 i; // rbx

for ( i = *(_QWORD *)func2(a1, a2); i; i = *(_QWORD *)(i + 8) )
{
if ( (**(unsigned __int8 (__fastcall ***)(_QWORD, __int64, __int64))a1)(*(_QWORD *)(a1 + 8), a3, i) )
break;
}
return i;
}

original_code:
static inline small_hash__node *find(
    small_hash__table *table, small_hash__hash hash, const void *key)
{
    small_hash__anchor *anchor = anchor_of_hash(table, hash);
    small_hash__node *node;
    for(node = anchor->first; node; node = node->next) {
        if(table->user_funcs->match_key(table->user_arg, key, node)) {
            return node;
        }
    }
    return ((void *)0);
}

canonical_original_code:
static inline struct small_hash__node *find(struct small_hash__table *table, unsigned int hash, void *key)
{
    struct small_hash__anchor *anchor = anchor_of_hash(table, hash);
    struct small_hash__node *node;
    for(node = anchor->first; node; node = node->next) {
        if(table->user_funcs->match_key(table->user_arg, key, node)) {
            return node;
        }
    }
    return ((void *)0);
}

variable_types: struct small_hash__table { struct small_hash__funcs { _Bool (*match_key)(void *user_arg, void *key, struct small_hash__node *); unsigned int (*get_hash)(void *user_arg, struct small_hash__node *); } *user_funcs; void *user_arg; unsigned int count; _Bool is_dynamic; unsigned int min_anchors_count; unsigned int low_watermark; unsigned int high_watermark; unsigned int expensive_lookup_count; unsigned int lookup_count; unsigned int anchors_count; struct small_hash__anchor { struct small_hash__node *first; } *anchors; unsigned int prevent_resizes_count; } *

variable_types:
hash
unsigned int

variable_types:
key
void *

variable_types: struct small_hash__anchor { struct small_hash__node { struct small_hash__node *prev; } *first; } *


decompiled_code:
void *__fastcall alloc_anchors(unsigned int a1)
{
void *v1; // rax

v1 = malloc(8LL * a1);
return memset(v1, 0, 8LL * a1);
}

canonical_decompiled_code:
void *__fastcall func4(unsigned int a1)
{
void *v1; // rax

v1 = malloc(8LL * a1);
return memset(v1, 0, 8LL * a1);
}

original_code:
static small_hash__anchor *alloc_anchors(unsigned count)
{
    small_hash__anchor *anchors = malloc(count * sizeof *anchors);
    memset(anchors, 0, count * sizeof *anchors);
    return anchors;
}

canonical_original_code:
static struct small_hash__anchor *alloc_anchors(unsigned int count)
{
    struct small_hash__anchor *anchors = malloc(count * sizeof *anchors);
    memset(anchors, 0, count * sizeof *anchors);
    return anchors;
}

variable_types:
count
unsigned int

return_type: struct small_hash__anchor { struct small_hash__node { struct small_hash__node *prev; } *first; } *


decompiled_code:
void __fastcall report_lookup(__int64 a1, unsigned int a2)
{
unsigned int v2; // eax
unsigned int v3; // edx

if ( *(_BYTE *)(a1 + 20) )
{
if ( !*(_DWORD *)(a1 + 56) )
{
v2 = *(_DWORD *)(a1 + 16);
if ( v2 > *(_DWORD *)(a1 + 32) && a2 > 6 )
{
v3 = *(_DWORD *)(a1 + 36) + 1;
*(_DWORD *)(a1 + 36) = v3;
if ( v3 > 1 )
{
if ( *(_DWORD *)(a1 + 24) >= v2 / 5 )
_assert_fail("new_anchors_count > table->min_anchors_count", "small_hash.c", 0xC5u, "report_lookup");
rehash((_DWORD *)a1, v2 / 5);
}
}
}
}
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1, unsigned int a2)
{
unsigned int v2; // eax
unsigned int v3; // edx

if ( *(_BYTE *)(a1 + 20) )
{
if ( !*(_DWORD *)(a1 + 56) )
{
v2 = *(_DWORD *)(a1 + 16);
if ( v2 > *(_DWORD *)(a1 + 32) && a2 > 6 )
{
v3 = *(_DWORD *)(a1 + 36) + 1;
*(_DWORD *)(a1 + 36) = v3;
if ( v3 > 1 )
{
if ( *(_DWORD *)(a1 + 24) >= v2 / 5 )
_assert_fail("new_anchors_count > table->min_anchors_count", "small_hash.c", 0xC5u, "report_lookup");
func5((_DWORD *)a1, v2 / 5);
}
}
}
}
}

original_code:
static inline void report_lookup(small_hash__table *table, unsigned lookup_cost)
{
    if(!table->is_dynamic || 0 != table->prevent_resizes_count) return;
    if(table->count <= table->high_watermark) return;
    if(lookup_cost < 7) return;
    table->expensive_lookup_count++;
    if(table->expensive_lookup_count < 2) return;
    unsigned new_anchors_count = table->count / 5;
    ((void) sizeof ((new_anchors_count > table->min_anchors_count) ? 1 : 0), __extension__ ({ if (new_anchors_count > table->min_anchors_count) ; else __assert_fail ("new_anchors_count > table->min_anchors_count", "small_hash.c", 197, __extension__ __PRETTY_FUNCTION__); }));
    rehash(table, new_anchors_count);
}

canonical_original_code:
static inline void report_lookup(struct small_hash__table *table, unsigned int lookup_cost)
{
    if(!table->is_dynamic || 0 != table->prevent_resizes_count) return;
    if(table->count <= table->high_watermark) return;
    if(lookup_cost < 7) return;
    table->expensive_lookup_count++;
    if(table->expensive_lookup_count < 2) return;
    unsigned int new_anchors_count = table->count / 5;
    ((void) sizeof ((new_anchors_count > table->min_anchors_count) ? 1 : 0), __extension__ ({ if (new_anchors_count > table->min_anchors_count) ; else __assert_fail ("new_anchors_count > table->min_anchors_count", "small_hash.c", 197, __extension__ __PRETTY_FUNCTION__); }));
    rehash(table, new_anchors_count);
}


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

v4 = *(_QWORD *)anchor_of_hash(a1, a2);
if ( v4 )
{
v5 = 0;
do
{
++v5;
if ( (**(unsigned __int8 (__fastcall ***)(_QWORD, __int64, __int64))a1)(*(_QWORD *)(a1 + 8), a3, v4) )
break;
v4 = *(_QWORD *)(v4 + 8);
}
while ( v4 );
}
else
{
v5 = 0;
}
report_lookup(a1, v5);
return v4;
}

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

v4 = *(_QWORD *)func2(a1, a2);
if ( v4 )
{
v5 = 0;
do
{
++v5;
if ( (**(unsigned __int8 (__fastcall ***)(_QWORD, __int64, __int64))a1)(*(_QWORD *)(a1 + 8), a3, v4) )
break;
v4 = *(_QWORD *)(v4 + 8);
}
while ( v4 );
}
else
{
v5 = 0;
}
func7(a1, v5);
return v4;
}

original_code:
static inline small_hash__node *find_and_report(
    small_hash__table *table,
    small_hash__hash hash, const void *key)
{
    small_hash__anchor *anchor = anchor_of_hash(table, hash);
    small_hash__node *node;
    unsigned lookup_cost = 0;
    for(node = anchor->first; node; node = node->next) {
        lookup_cost++;
        if(table->user_funcs->match_key(table->user_arg, key, node)) {
            break;
        }
    }
    report_lookup(table, lookup_cost);
    return node;
}

canonical_original_code:
static inline struct small_hash__node *find_and_report(struct small_hash__table *table, unsigned int hash, void *key)
{
    struct small_hash__anchor *anchor = anchor_of_hash(table, hash);
    struct small_hash__node *node;
    unsigned int lookup_cost = 0;
    for(node = anchor->first; node; node = node->next) {
        lookup_cost++;
        if(table->user_funcs->match_key(table->user_arg, key, node)) {
            break;
        }
    }
    report_lookup(table, lookup_cost);
    return node;
}

variable_types: struct small_hash__node { struct small_hash__node *prev; } *


decompiled_code:
void __fastcall small_hash__table__fini(__int64 a1)
{
if ( *(_DWORD *)(a1 + 56) )
_assert_fail("0 == table->prevent_resizes_count", "small_hash.c", 0x52u, "small_hash__table__fini");
if ( *(_BYTE *)(a1 + 20) )
{
free(*(void **)(a1 + 48));
*(_QWORD *)(a1 + 48) = 0LL;
}
}

canonical_decompiled_code:
void __fastcall func11(__int64 a1)
{
if ( *(_DWORD *)(a1 + 56) )
_assert_fail("0 == table->prevent_resizes_count", "small_hash.c", 0x52u, "small_hash__table__fini");
if ( *(_BYTE *)(a1 + 20) )
{
free(*(void **)(a1 + 48));
*(_QWORD *)(a1 + 48) = 0LL;
}
}

original_code:
void small_hash__table__fini(small_hash__table *table)
{
    ((void) sizeof ((0 == table->prevent_resizes_count) ? 1 : 0), __extension__ ({ if (0 == table->prevent_resizes_count) ; else __assert_fail ("0 == table->prevent_resizes_count", "small_hash.c", 82, __extension__ __PRETTY_FUNCTION__); }));
    if(table->is_dynamic) {
        free(table->anchors);
        table->anchors = ((void *)0);
    }
}

canonical_original_code:
void small_hash__table__fini(struct small_hash__table *table)
{
    ((void) sizeof ((0 == table->prevent_resizes_count) ? 1 : 0), __extension__ ({ if (0 == table->prevent_resizes_count) ; else __assert_fail ("0 == table->prevent_resizes_count", "small_hash.c", 82, __extension__ __PRETTY_FUNCTION__); }));
    if(table->is_dynamic) {
        free(table->anchors);
        table->anchors = ((void *)0);
    }
}