decompiled_code:
__int64 __fastcall sp_vnew(__int64 a1, const void *a2, unsigned __int16 a3)
{
return sp_vnewof(a1, a2, a3, 0);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, const void *a2, unsigned __int16 a3)
{
return func5(a1, a2, a3, 0);
}

original_code:
spv *sp_vnew(sp *s, void *k, uint16_t size) {
 return sp_vnewof(s, k, size, 0);
}

canonical_original_code:
struct spv *sp_vnew(struct sp *s, void *k, unsigned short size) {
 return sp_vnewof(s, k, size, 0);
}

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

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 spref { unsigned char type; union { struct spvh *vh; struct spv *v; } v; }


repo: Peaker/bindings-sophia

decompiled_code:
__int64 __fastcall sp_vnewv(__int64 a1, const void *a2, unsigned __int16 a3, const void *a4, unsigned int a5)
{
__int64 v7; // rax
__int64 v8; // rbx

v7 = sp_vnewof(a1, a2, a3, a5 + 4);
v8 = v7;
if ( v7 )
{
*(_DWORD *)(v7 + *(unsigned __int16 *)(v7 + 8) + 11) = a5;
memcpy((void *)(v7 + *(unsigned __int16 *)(v7 + 8) + 15), a4, a5);
}
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, const void *a2, unsigned __int16 a3, const void *a4, unsigned int a5)
{
__int64 v7; // rax
__int64 v8; // rbx

v7 = func5(a1, a2, a3, a5 + 4);
v8 = v7;
if ( v7 )
{
*(_DWORD *)(v7 + *(unsigned __int16 *)(v7 + 8) + 11) = a5;
memcpy((void *)(v7 + *(unsigned __int16 *)(v7 + 8) + 15), a4, a5);
}
return v8;
}

original_code:
spv *sp_vnewv(sp *s, void *k, uint16_t size, void *v, uint32_t vsize)
{
 spv *vn = sp_vnewof(s, k, size, sizeof(uint32_t) + vsize);
 if (__builtin_expect(!! (vn == ((void *)0)), 0))
  return ((void *)0);
 memcpy(vn->key + vn->size, &vsize, sizeof(uint32_t));
 memcpy(vn->key + vn->size + sizeof(uint32_t), v, vsize);
 return vn;
}

canonical_original_code:
struct spv *sp_vnewv(struct sp *s, void *k, unsigned short size, void *v, unsigned int vsize)
{
 struct spv *vn = sp_vnewof(s, k, size, sizeof(uint32_t) + vsize);
 if (__builtin_expect(!! (vn == ((void *)0)), 0))
  return ((void *)0);
 memcpy(vn->key + vn->size, &vsize, sizeof(unsigned int));
 memcpy(vn->key + vn->size + sizeof(unsigned int), v, vsize);
 return vn;
}

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 *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:
k
void *

variable_types:
size
unsigned short

variable_types:
v
void *

variable_types:
vsize
unsigned int

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

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 sprep { struct spa *a; unsigned int epoch; struct splist l; int n; int ndb; int nxfer; }

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 __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }


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

result = sp_vnewof(a1, (const void *)(a2 + 17), *(_WORD *)(a2 + 4), 0);
if ( result )
*(_BYTE *)(result + 10) = *(_BYTE *)(a2 + 16);
return result;
}

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

result = func5(a1, (const void *)(a2 + 17), *(_WORD *)(a2 + 4), 0);
if ( result )
*(_BYTE *)(result + 10) = *(_BYTE *)(a2 + 16);
return result;
}

original_code:
spv *sp_vnewh(sp *s, spvh *v) {
 spv *vn = sp_vnewof(s, v->key, v->size, 0);
 if (__builtin_expect(!! (vn == ((void *)0)), 0))
  return ((void *)0);
 vn->flags = v->flags;
 return vn;
}

canonical_original_code:
struct spv *sp_vnewh(struct sp *s, struct spvh *v) {
 struct spv *vn = sp_vnewof(s, v->key, v->size, 0);
 if (__builtin_expect(!! (vn == ((void *)0)), 0))
  return ((void *)0);
 vn->flags = v->flags;
 return vn;
}

variable_types:
v
struct spvh *

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

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

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; }

user_defined_types: struct spe { unsigned char lock; int type; int errno_; char e[256]; }

user_defined_types: struct iovec { void *iov_base; unsigned long iov_len; }

user_defined_types: 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]; }

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; }

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }

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

user_defined_types: struct spvh { unsigned int crc; unsigned int size; unsigned int voffset; unsigned int vsize; unsigned char flags; char key[]; }


decompiled_code:
void *__fastcall sp_vdup(__int64 a1, unsigned __int16 *a2)
{
void *v2; // rax
void *v3; // rbx

v2 = (void *)sp_malloc(a1 + 16, a2[4] + 11LL);
v3 = v2;
if ( v2 )
memcpy(v2, a2, a2[4] + 11LL);
return v3;
}

canonical_decompiled_code:
void *__fastcall func14(__int64 a1, unsigned __int16 *a2)
{
void *v2; // rax
void *v3; // rbx

v2 = (void *)func3(a1 + 16, a2[4] + 11LL);
v3 = v2;
if ( v2 )
memcpy(v2, a2, a2[4] + 11LL);
return v3;
}

original_code:
spv *sp_vdup(sp *s, spv *v)
{
 spv *vn = sp_malloc(&s->a, sizeof(spv) + v->size);
 if (__builtin_expect(!! (vn == ((void *)0)), 0))
  return ((void *)0);
 memcpy(vn, v, sizeof(spv) + v->size);
 return vn;
}

canonical_original_code:
struct spv *sp_vdup(struct sp *s, struct spv *v)
{
 struct spv *vn = sp_malloc(&s->a, sizeof(spv) + v->size);
 if (__builtin_expect(!! (vn == ((void *)0)), 0))
  return ((void *)0);
 memcpy(vn, v, sizeof(spv) + v->size);
 return vn;
}

variable_types:
v
struct spv *

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; }


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

if ( *(_BYTE *)a2 == 1 )
{
result = sp_vnewh(a1, *(_QWORD *)(a2 + 1));
}
else
{
result = 0LL;
if ( *(_BYTE *)a2 != 2 )
return result;
result = (__int64)sp_vdup(a1, *(unsigned __int16 **)(a2 + 1));
}
if ( result )
{
*(_DWORD *)result = a3;
*(_BYTE *)(result + 10) = 0;
}
return result;
}

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

if ( *(_BYTE *)a2 == 1 )
{
result = func13(a1, *(_QWORD *)(a2 + 1));
}
else
{
result = 0LL;
if ( *(_BYTE *)a2 != 2 )
return result;
result = (__int64)func14(a1, *(unsigned __int16 **)(a2 + 1));
}
if ( result )
{
*(_DWORD *)result = a3;
*(_BYTE *)(result + 10) = 0;
}
return result;
}

original_code:
spv *sp_vdupref(sp *s, spref *r, uint32_t epoch)
{
 spv *vn = ((void *)0);
 switch (r->type) {
 case 2: vn = sp_vdup(s, r->v.v);
  break;
 case 1: vn = sp_vnewh(s, r->v.vh);
  break;
 }
 if (__builtin_expect(!! (vn == ((void *)0)), 0))
  return ((void *)0);
 vn->epoch = epoch;
 vn->flags = 0;
 return vn;
}

canonical_original_code:
struct spv *sp_vdupref(struct sp *s, struct spref *r, unsigned int epoch)
{
 struct spv *vn = ((void *)0);
 switch (r->type) {
 case 2: vn = sp_vdup(s, r->v.v);
  break;
 case 1: vn = sp_vnewh(s, r->v.vh);
  break;
 }
 if (__builtin_expect(!! (vn == ((void *)0)), 0))
  return ((void *)0);
 vn->epoch = epoch;
 vn->flags = 0;
 return vn;
}

variable_types:
r
struct spref *

variable_types:
epoch
unsigned int

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 sprep { struct spa *a; unsigned int epoch; struct splist l; int n; int ndb; int nxfer; }

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: 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; }


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

result = *(_QWORD *)(a1 + 16);
*(_QWORD *)(a1 + 32) = result;
return result;
}

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

result = *(_QWORD *)(a1 + 16);
*(_QWORD *)(a1 + 32) = result;
return result;
}

original_code:
static inline void
sp_filesvp(spfile *f) {
 f->svp = f->used;
}

canonical_original_code:
static inline void sp_filesvp(struct spfile *f) {
 f->svp = f->used;
}

variable_types: 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; } *

return_type: void

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; }


decompiled_code:
__off_t __fastcall sp_mapsizeof(const char *a1)
{
bool v1; // zf
__off_t result; // rax
struct stat v3; // [rsp+0h] [rbp-98h] BYREF

v1 = lstat(a1, &v3) == -1;
result = -1LL;
if ( !v1 )
result = v3.st_size;
return result;
}

canonical_decompiled_code:
__off_t __fastcall func2(const char *a1)
{
bool v1; // zf
__off_t result; // rax
struct stat v3; // [rsp+0h] [rbp-98h] BYREF

v1 = lstat(a1, &v3) == -1;
result = -1LL;
if ( !v1 )
result = v3.st_size;
return result;
}

original_code:
static inline ssize_t
sp_mapsizeof(char *path) {
 struct stat st;
 int rc = lstat(path, &st);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 return st.st_size;
}

canonical_original_code:
static inline long sp_mapsizeof(char *path) {
 struct stat st;
 int rc = lstat(path, &st);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 return st.st_size;
}

variable_types:
path
char *

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

variable_types: rc int

return_type: long

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }


decompiled_code:
int __fastcall sp_fileclose(__int64 a1)
{
__int64 v2; // rsi
int v3; // edi
int result; // eax

v2 = *(_QWORD *)(a1 + 40);
if ( v2 )
{
sp_free(*(_QWORD *)a1, v2);
*(_QWORD *)(a1 + 40) = 0LL;
}
v3 = *(_DWORD *)(a1 + 48);
result = 0;
if ( v3 != -1 )
{
result = close(v3);
if ( result != -1 )
{
*(_DWORD *)(a1 + 48) = -1;
result = 0;
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1)
{
__int64 v2; // rsi
int v3; // edi
int result; // eax

v2 = *(_QWORD *)(a1 + 40);
if ( v2 )
{
func0(*(_QWORD *)a1, v2);
*(_QWORD *)(a1 + 40) = 0LL;
}
v3 = *(_DWORD *)(a1 + 48);
result = 0;
if ( v3 != -1 )
{
result = close(v3);
if ( result != -1 )
{
*(_DWORD *)(a1 + 48) = -1;
result = 0;
}
}
return result;
}

original_code:
static inline int
sp_fileclose(spfile *f)
{
 if (__builtin_expect(!! (f->file), 1)) {
  sp_free(f->a, f->file);
  f->file = ((void *)0);
 }
 int rc;
 if (__builtin_expect(!! (f->fd != -1), 0)) {
  rc = close(f->fd);
  if (__builtin_expect(!! (rc == -1), 0))
   return -1;
  f->fd = -1;
 }
 return 0;
}

canonical_original_code:
static inline int sp_fileclose(struct spfile *f)
{
 if (__builtin_expect(!! (f->file), 1)) {
  sp_free(f->a, f->file);
  f->file = ((void *)0);
 }
 int rc;
 if (__builtin_expect(!! (f->fd != -1), 0)) {
  rc = close(f->fd);
  if (__builtin_expect(!! (rc == -1), 0))
   return -1;
  f->fd = -1;
 }
 return 0;
}

return_type: int

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


decompiled_code:
int __fastcall sp_logopenof(__int64 a1, const char *a2, int a3)
{
int result; // eax
void *v4; // rax

*(_DWORD *)(a1 + 8) = 1;
result = open(a2, a3, 384LL);
*(_DWORD *)(a1 + 48) = result;
if ( result != -1 )
{
v4 = sp_strdup(*(_QWORD *)a1, a2);
*(_QWORD *)(a1 + 40) = v4;
if ( v4 )
{
*(_QWORD *)(a1 + 24) = 0LL;
*(_QWORD *)(a1 + 16) = 0LL;
result = 0;
}
else
{
close(*(_DWORD *)(a1 + 48));
*(_DWORD *)(a1 + 48) = -1;
result = -1;
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func5(__int64 a1, const char *a2, int a3)
{
int result; // eax
void *v4; // rax

*(_DWORD *)(a1 + 8) = 1;
result = open(a2, a3, 384LL);
*(_DWORD *)(a1 + 48) = result;
if ( result != -1 )
{
v4 = func4(*(_QWORD *)a1, a2);
*(_QWORD *)(a1 + 40) = v4;
if ( v4 )
{
*(_QWORD *)(a1 + 24) = 0LL;
*(_QWORD *)(a1 + 16) = 0LL;
result = 0;
}
else
{
close(*(_DWORD *)(a1 + 48));
*(_DWORD *)(a1 + 48) = -1;
result = -1;
}
}
return result;
}

original_code:
static inline int
sp_logopenof(spfile *f, char *path, int flags)
{
 f->creat = 1;
 f->fd = open(path, flags, 0600);
 if (__builtin_expect(!! (f->fd == -1), 0))
  return -1;
 f->file = sp_strdup(f->a, path);
 if (__builtin_expect(!! (f->file == ((void *)0)), 0)) {
  close(f->fd);
  f->fd = -1;
  return -1;
 }
 f->size = 0;
 f->used = 0;
 return 0;
}

canonical_original_code:
static inline int sp_logopenof(struct spfile *f, char *path, int flags)
{
 f->creat = 1;
 f->fd = open(path, flags, 0600);
 if (__builtin_expect(!! (f->fd == -1), 0))
  return -1;
 f->file = sp_strdup(f->a, path);
 if (__builtin_expect(!! (f->file == ((void *)0)), 0)) {
  close(f->fd);
  f->fd = -1;
  return -1;
 }
 f->size = 0;
 f->used = 0;
 return 0;
}

variable_types: flags int


decompiled_code:
int __fastcall sp_mapresize(__int64 a1, __off_t a2)
{
int result; // eax

result = ftruncate(*(_DWORD *)(a1 + 48), a2);
if ( result != -1 )
{
*(_QWORD *)(a1 + 24) = a2;
result = 0;
}
return result;
}

canonical_decompiled_code:
int __fastcall func6(__int64 a1, __off_t a2)
{
int result; // eax

result = ftruncate(*(_DWORD *)(a1 + 48), a2);
if ( result != -1 )
{
*(_QWORD *)(a1 + 24) = a2;
result = 0;
}
return result;
}

original_code:
static inline int
sp_mapresize(spfile *f, size_t size) {
 int rc = ftruncate(f->fd, size);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 f->size = size;
 return 0;
}

canonical_original_code:
static inline int sp_mapresize(struct spfile *f, unsigned long size) {
 int rc = ftruncate(f->fd, size);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 f->size = size;
 return 0;
}

variable_types:
size
unsigned long


decompiled_code:
__int64 __fastcall sp_map(__int64 a1, int a2)
{
void *v2; // rax

v2 = mmap(0LL, *(_QWORD *)(a1 + 24), a2, 1, *(_DWORD *)(a1 + 48), 0LL);
if ( v2 == (void *)-1LL )
return 0xFFFFFFFFLL;
*(_QWORD *)(a1 + 56) = v2;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, int a2)
{
void *v2; // rax

v2 = mmap(0LL, *(_QWORD *)(a1 + 24), a2, 1, *(_DWORD *)(a1 + 48), 0LL);
if ( v2 == (void *)-1LL )
return 0xFFFFFFFFLL;
*(_QWORD *)(a1 + 56) = v2;
return 0LL;
}

original_code:
static inline int
sp_map(spfile *f, int flags) {
 void *p = mmap(((void *)0), f->size, flags, 0x01, f->fd, 0);
 if (p == ((void *) -1))
  return -1;
 f->map = p;
 return 0;
}

canonical_original_code:
static inline int sp_map(struct spfile *f, int flags) {
 void *p = mmap(((void *)0), f->size, flags, 0x01, f->fd, 0);
 if (p == ((void *) -1))
  return -1;
 f->map = p;
 return 0;
}

variable_types:
p
void *


original_code:
static inline int
sp_mapopenof(spfile *f, char *path, int flags, uint64_t size)
{
 f->fd = open(path, flags, 0600);
 if (__builtin_expect(!! (f->fd == -1), 0))
  return -1;
 f->file = sp_strdup(f->a, path);
 if (__builtin_expect(!! (f->file == ((void *)0)), 0)) {
  close(f->fd);
  f->fd = -1;
  return -1;
 }
 f->used = 0;
 f->creat = (flags & 0100 ? 1 : 0);
 int rc;
 if (! f->creat) {
  ssize_t sz = sp_mapsizeof(path);
  if (__builtin_expect(!! (sz == -1), 0))
   goto err;
  f->size = sz;
  rc = sp_map(f, 0x1);
  if (__builtin_expect(!! (rc == -1), 0))
   goto err;
  return 0;
 }
 f->size = 0;
 rc = sp_mapresize(f, size);
 if (__builtin_expect(!! (rc == -1), 0))
  goto err;
 rc = sp_map(f, 0x1|0x2);
 if (__builtin_expect(!! (rc == -1), 0))
  goto err;
 return 0;
err:
 close(f->fd);
 f->fd = -1;
 sp_free(f->a, f->file);
 f->file = ((void *)0);
 return -1;
}

canonical_original_code:
static inline int sp_mapopenof(struct spfile *f, char *path, int flags, unsigned long size)
{
 f->fd = open(path, flags, 0600);
 if (__builtin_expect(!! (f->fd == -1), 0))
  return -1;
 f->file = sp_strdup(f->a, path);
 if (__builtin_expect(!! (f->file == ((void *)0)), 0)) {
  close(f->fd);
  f->fd = -1;
  return -1;
 }
 f->used = 0;
 f->creat = (flags & 0100 ? 1 : 0);
 int rc;
 if (! f->creat) {
  long sz = sp_mapsizeof(path);
  if (__builtin_expect(!! (sz == -1), 0))
   goto err;
  f->size = sz;
  rc = sp_map(f, 0x1);
  if (__builtin_expect(!! (rc == -1), 0))
   goto err;
  return 0;
 }
 f->size = 0;
 rc = sp_mapresize(f, size);
 if (__builtin_expect(!! (rc == -1), 0))
  goto err;
 rc = sp_map(f, 0x1|0x2);
 if (__builtin_expect(!! (rc == -1), 0))
  goto err;
 return 0;
err:
 close(f->fd);
 f->fd = -1;
 sp_free(f->a, f->file);
 f->file = ((void *)0);
 return -1;
}

variable_types: sz long


decompiled_code:
int __fastcall sp_unmap(__int64 a1)
{
void *v2; // rdi
int result; // eax

v2 = *(void **)(a1 + 56);
result = 0;
if ( v2 )
{
result = munmap(v2, *(_QWORD *)(a1 + 24));
*(_QWORD *)(a1 + 56) = 0LL;
}
return result;
}

canonical_decompiled_code:
int __fastcall func9(__int64 a1)
{
void *v2; // rdi
int result; // eax

v2 = *(void **)(a1 + 56);
result = 0;
if ( v2 )
{
result = munmap(v2, *(_QWORD *)(a1 + 24));
*(_QWORD *)(a1 + 56) = 0LL;
}
return result;
}

original_code:
static inline int
sp_unmap(spfile *f) {
 int rc;
 if (f->map) {
  rc = munmap(f->map, f->size);
  f->map = ((void *)0);
  return rc;
 }
 return 0;
}

canonical_original_code:
static inline int sp_unmap(struct spfile *f) {
 int rc;
 if (f->map) {
  rc = munmap(f->map, f->size);
  f->map = ((void *)0);
  return rc;
 }
 return 0;
}


decompiled_code:
int __fastcall sp_mapcut(__int64 a1)
{
int result; // eax

result = *(_DWORD *)(a1 + 8);
if ( result )
{
result = sp_mapsync(a1);
if ( result != -1 )
{
result = sp_unmap(a1);
if ( result != -1 )
result = -(sp_mapresize(a1, *(_QWORD *)(a1 + 16)) == -1);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func11(__int64 a1)
{
int result; // eax

result = *(_DWORD *)(a1 + 8);
if ( result )
{
result = func10(a1);
if ( result != -1 )
{
result = func9(a1);
if ( result != -1 )
result = -(func6(a1, *(_QWORD *)(a1 + 16)) == -1);
}
}
return result;
}

original_code:
static inline int
sp_mapcut(spfile *f)
{
 if (f->creat == 0)
  return 0;
 int rc = sp_mapsync(f);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 rc = sp_unmap(f);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 rc = sp_mapresize(f, f->used);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 return 0;
}

canonical_original_code:
static inline int sp_mapcut(struct spfile *f)
{
 if (f->creat == 0)
  return 0;
 int rc = sp_mapsync(f);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 rc = sp_unmap(f);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 rc = sp_mapresize(f, f->used);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 return 0;
}


decompiled_code:
int __fastcall sp_filecomplete(__int64 a1)
{
char *v1; // rax
int result; // eax
_BYTE savedregs[1048]; // [rsp+0h] [rbp+0h] BYREF

*(_DWORD *)(a1 + 8) = 0;
snprintf(savedregs, 0x400uLL, "%s", *(const char **)(a1 + 40));
v1 = strstr(savedregs, ".incomplete");
if ( !v1 )
return 0;
*v1 = 0;
result = rename(*(const char **)(a1 + 40), savedregs);
if ( result != -1 )
{
if ( sp_strdup(*(_QWORD *)a1, savedregs) )
{
sp_free(*(_QWORD *)a1, *(_QWORD *)(a1 + 40));
*(_QWORD *)(a1 + 40) = savedregs;
result = 0;
}
else
{
result = -1;
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func12(__int64 a1)
{
char *v1; // rax
int result; // eax
_BYTE savedregs[1048]; // [rsp+0h] [rbp+0h] BYREF

*(_DWORD *)(a1 + 8) = 0;
snprintf(savedregs, 0x400uLL, "%s", *(const char **)(a1 + 40));
v1 = strstr(savedregs, ".incomplete");
if ( !v1 )
return 0;
*v1 = 0;
result = rename(*(const char **)(a1 + 40), savedregs);
if ( result != -1 )
{
if ( func4(*(_QWORD *)a1, savedregs) )
{
func0(*(_QWORD *)a1, *(_QWORD *)(a1 + 40));
*(_QWORD *)(a1 + 40) = savedregs;
result = 0;
}
else
{
result = -1;
}
}
return result;
}

original_code:
static inline int
sp_filecomplete(spfile *f)
{
 f->creat = 0;
 char path[1024];
 snprintf(path, sizeof(path), "%s", f->file);
 char *ext = strstr(path, ".incomplete");
 if (__builtin_expect(!! (ext == ((void *)0)), 0))
  return 0;
 *ext = 0;
 int rc = rename(f->file, path);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 char *p = sp_strdup(f->a, path);
 if (__builtin_expect(!! (p == ((void *)0)), 0))
  return -1;
 sp_free(f->a, f->file);
 f->file = p;
 return 0;
}

canonical_original_code:
static inline int sp_filecomplete(struct spfile *f)
{
 f->creat = 0;
 char path[1024];
 snprintf(path, sizeof(path), "%s", f->file);
 char *ext = strstr(path, ".incomplete");
 if (__builtin_expect(!! (ext == ((void *)0)), 0))
  return 0;
 *ext = 0;
 int rc = rename(f->file, path);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 char *p = sp_strdup(f->a, path);
 if (__builtin_expect(!! (p == ((void *)0)), 0))
  return -1;
 sp_free(f->a, f->file);
 f->file = p;
 return 0;
}

variable_types:
path
char [1024]

variable_types:
ext
char *

variable_types:
p
char *


decompiled_code:
int __fastcall sp_logsync(__int64 a1)
{
int result; // eax

result = *(_DWORD *)(a1 + 8);
if ( result )
result = fsync(*(_DWORD *)(a1 + 48));
return result;
}

canonical_decompiled_code:
int __fastcall func13(__int64 a1)
{
int result; // eax

result = *(_DWORD *)(a1 + 8);
if ( result )
result = fsync(*(_DWORD *)(a1 + 48));
return result;
}

original_code:
static inline int
sp_logsync(spfile *f) {
 return (f->creat ? fsync(f->fd) : 0);
}

canonical_original_code:
static inline int sp_logsync(struct spfile *f) {
 return (f->creat ? fsync(f->fd) : 0);
}


decompiled_code:
_BOOL8 __fastcall sp_fileexists(const char *a1)
{
struct stat v2; // [rsp+0h] [rbp-98h] BYREF

return lstat(a1, &v2) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func14(const char *a1)
{
struct stat v2; // [rsp+0h] [rbp-98h] BYREF

return lstat(a1, &v2) == 0;
}

original_code:
int sp_fileexists(char *path) {
 struct stat st;
 int rc = lstat(path, &st);
 return rc == 0;
}

user_defined_types: struct timespec { long tv_sec; long tv_nsec; }


decompiled_code:
int __fastcall sp_filerm(const char *a1)
{
return unlink(a1);
}

canonical_decompiled_code:
int __fastcall func15(const char *a1)
{
return unlink(a1);
}

original_code:
int sp_filerm(char *path) {
 return unlink(path);
}


decompiled_code:
__int64 __fastcall sp_mapopen(__int64 a1, const char *a2)
{
return sp_mapopenof(a1, a2, 0, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, const char *a2)
{
return func8(a1, a2, 0, 0LL);
}

original_code:
int sp_mapopen(spfile *f, char *path) {
 return sp_mapopenof(f, path, 00, 0);
}

canonical_original_code:
int sp_mapopen(struct spfile *f, char *path) {
 return sp_mapopenof(f, path, 00, 0);
}


decompiled_code:
__int64 __fastcall sp_mapnew(__int64 a1, const char *a2, __off_t a3)
{
return sp_mapopenof(a1, a2, 66, a3);
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, const char *a2, __off_t a3)
{
return func8(a1, a2, 66, a3);
}

original_code:
int sp_mapnew(spfile *f, char *path, uint64_t size) {
 return sp_mapopenof(f, path, 02|0100, size);
}

canonical_original_code:
int sp_mapnew(struct spfile *f, char *path, unsigned long size) {
 return sp_mapopenof(f, path, 02|0100, size);
}


decompiled_code:
int __fastcall sp_mapunlink(__int64 a1)
{
return sp_filerm(*(const char **)(a1 + 40));
}

canonical_decompiled_code:
int __fastcall func18(__int64 a1)
{
return func15(*(const char **)(a1 + 40));
}

original_code:
int sp_mapunlink(spfile *f) {
 return sp_filerm(f->file);
}

canonical_original_code:
int sp_mapunlink(struct spfile *f) {
 return sp_filerm(f->file);
}


decompiled_code:
int __fastcall sp_mapunmap(__int64 a1)
{
return sp_unmap(a1);
}

canonical_decompiled_code:
int __fastcall func19(__int64 a1)
{
return func9(a1);
}

original_code:
int sp_mapunmap(spfile *f) {
 return sp_unmap(f);
}

canonical_original_code:
int sp_mapunmap(struct spfile *f) {
 return sp_unmap(f);
}


decompiled_code:
int __fastcall sp_mapclose(__int64 a1)
{
int result; // eax

result = sp_mapcut(a1);
if ( result != -1 )
{
if ( !*(_QWORD *)(a1 + 56) || (result = sp_unmap(a1), result != -1) )
result = sp_fileclose(a1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func20(__int64 a1)
{
int result; // eax

result = func11(a1);
if ( result != -1 )
{
if ( !*(_QWORD *)(a1 + 56) || (result = func9(a1), result != -1) )
result = func3(a1);
}
return result;
}

original_code:
int sp_mapclose(spfile *f)
{
 int rc = sp_mapcut(f);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 if (f->map) {
  rc = sp_unmap(f);
  if (__builtin_expect(!! (rc == -1), 0))
   return -1;
 }
 return sp_fileclose(f);
}

canonical_original_code:
int sp_mapclose(struct spfile *f)
{
 int rc = sp_mapcut(f);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 if (f->map) {
  rc = sp_unmap(f);
  if (__builtin_expect(!! (rc == -1), 0))
   return -1;
 }
 return sp_fileclose(f);
}


decompiled_code:
int __fastcall sp_mapcomplete(__int64 a1)
{
int result; // eax

result = *(_DWORD *)(a1 + 8);
if ( result )
{
result = sp_mapcut(a1);
if ( result != -1 )
{
result = sp_filecomplete(a1);
if ( result != -1 )
result = sp_map(a1, 1);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func21(__int64 a1)
{
int result; // eax

result = *(_DWORD *)(a1 + 8);
if ( result )
{
result = func11(a1);
if ( result != -1 )
{
result = func12(a1);
if ( result != -1 )
result = func7(a1, 1);
}
}
return result;
}

original_code:
int sp_mapcomplete(spfile *f)
{
 if (f->creat == 0)
  return 0;
 int rc = sp_mapcut(f);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 rc = sp_filecomplete(f);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 return sp_map(f, 0x1);
}

canonical_original_code:
int sp_mapcomplete(struct spfile *f)
{
 if (f->creat == 0)
  return 0;
 int rc = sp_mapcut(f);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 rc = sp_filecomplete(f);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 return sp_map(f, 0x1);
}


decompiled_code:
int __fastcall sp_mapensure(__int64 a1, unsigned __int64 a2, float a3)
{
int result; // eax
__int64 v5; // rax
__int64 v6; // rdx
float v7; // xmm0_4
float v8; // xmm0_4
float v9; // xmm1_4
float v10; // xmm0_4
unsigned __int64 v11; // rsi
unsigned __int64 v12; // rax
__int64 v13; // rcx
__int64 v14; // rdx

result = 0;
if ( *(_QWORD *)(a1 + 16) + a2 > *(_QWORD *)(a1 + 24) )
{
result = sp_unmap(a1);
if ( result != -1 )
{
v5 = *(_QWORD *)(a1 + 16);
v6 = *(_QWORD *)(a1 + 24);
if ( v6 < 0 )
{
v13 = *(_QWORD *)(a1 + 24) & 1LL | ((unsigned __int64)v6 >> 1);
v7 = (float)(int)v13 + (float)(int)v13;
}
else
{
v7 = (float)(int)v6;
}
v8 = v7 * a3;
if ( v5 < 0 )
{
v14 = *(_QWORD *)(a1 + 16) & 1LL | ((unsigned __int64)v5 >> 1);
v9 = (float)(int)v14 + (float)(int)v14;
}
else
{
v9 = (float)(int)v5;
}
v10 = v8 + v9;
if ( v10 >= 9.223372e18 )
v11 = (unsigned int)(int)(float)(v10 - 9.223372e18) ^ 0x8000000000000000LL;
else
v11 = (unsigned int)(int)v10;
v12 = a2 + v5;
if ( a2 > v11 )
v11 = v12;
result = sp_mapresize(a1, v11);
if ( result != -1 )
result = sp_map(a1, 3);
}
}
return result;
}

original_code:
int sp_mapensure(spfile *f, uint64_t size, float grow)
{
 if (__builtin_expect(!! ((f->used + size) <= f->size), 1))
  return 0;
 int rc = sp_unmap(f);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 uint64_t nsz = f->used + f->size * grow;
 if (__builtin_expect(!! (nsz < size), 0))
  nsz = f->used + size;
 ((void) (0));
 rc = sp_mapresize(f, nsz);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 return sp_map(f, 0x1|0x2);
}

canonical_original_code:
int sp_mapensure(struct spfile *f, unsigned long size, float grow)
{
 if (__builtin_expect(!! ((f->used + size) <= f->size), 1))
  return 0;
 int rc = sp_unmap(f);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 unsigned long nsz = f->used + f->size * grow;
 if (__builtin_expect(!! (nsz < size), 0))
  nsz = f->used + size;
 ((void) (0));
 rc = sp_mapresize(f, nsz);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 return sp_map(f, 0x1|0x2);
}

variable_types: grow float

variable_types:
nsz
unsigned long


decompiled_code:
__int64 __fastcall sp_lognew(__int64 a1, const char *a2, unsigned int a3)
{
_BYTE savedregs[1048]; // [rsp+0h] [rbp+0h] BYREF

snprintf(savedregs, 0x400uLL, "%s/%u.log.incomplete", a2, a3);
return (unsigned int)-(sp_logopenof(a1, savedregs, 1089) == -1);
}

canonical_decompiled_code:
__int64 __fastcall func23(__int64 a1, const char *a2, unsigned int a3)
{
_BYTE savedregs[1048]; // [rsp+0h] [rbp+0h] BYREF

snprintf(savedregs, 0x400uLL, "%s/%u.log.incomplete", a2, a3);
return (unsigned int)-(func5(a1, savedregs, 1089) == -1);
}

original_code:
int sp_lognew(spfile *f, char *dir, uint32_t epoch)
{
 char path[1024];
 snprintf(path, sizeof(path), "%s/%""u"".log.incomplete",
          dir, epoch);
 int rc = sp_logopenof(f, path, 01|02000|0100);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 return 0;
}

canonical_original_code:
int sp_lognew(struct spfile *f, char *dir, unsigned int epoch)
{
 char path[1024];
 snprintf(path, sizeof(path), "%s/%""u"".log.incomplete",
          dir, epoch);
 int rc = sp_logopenof(f, path, 01|02000|0100);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 return 0;
}

variable_types:
dir
char *


decompiled_code:
__int64 __fastcall sp_logcontinue(__int64 a1, const char *a2, unsigned int a3)
{
_BYTE savedregs[1048]; // [rsp+0h] [rbp+0h] BYREF

snprintf(savedregs, 0x400uLL, "%s/%u.log.incomplete", a2, a3);
return (unsigned int)-(sp_logopenof(a1, savedregs, 1025) == -1);
}

canonical_decompiled_code:
__int64 __fastcall func24(__int64 a1, const char *a2, unsigned int a3)
{
_BYTE savedregs[1048]; // [rsp+0h] [rbp+0h] BYREF

snprintf(savedregs, 0x400uLL, "%s/%u.log.incomplete", a2, a3);
return (unsigned int)-(func5(a1, savedregs, 1025) == -1);
}

original_code:
int sp_logcontinue(spfile *f, char *dir, uint32_t epoch) {
 char path[1024];
 snprintf(path, sizeof(path), "%s/%""u"".log.incomplete",
          dir, epoch);
 int rc = sp_logopenof(f, path, 01|02000);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 return 0;
}

canonical_original_code:
int sp_logcontinue(struct spfile *f, char *dir, unsigned int epoch) {
 char path[1024];
 snprintf(path, sizeof(path), "%s/%""u"".log.incomplete",
          dir, epoch);
 int rc = sp_logopenof(f, path, 01|02000);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 return 0;
}


decompiled_code:
int __fastcall sp_logclose(__int64 a1)
{
return sp_fileclose(a1);
}

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

original_code:
int sp_logclose(spfile *f) {
 return sp_fileclose(f);
}

canonical_original_code:
int sp_logclose(struct spfile *f) {
 return sp_fileclose(f);
}


decompiled_code:
int __fastcall sp_logcomplete(__int64 a1)
{
int result; // eax

result = sp_logsync(a1);
if ( result != -1 )
result = sp_filecomplete(a1);
return result;
}

canonical_decompiled_code:
int __fastcall func26(__int64 a1)
{
int result; // eax

result = func13(a1);
if ( result != -1 )
result = func12(a1);
return result;
}

original_code:
int sp_logcomplete(spfile *f)
{
 int rc = sp_logsync(f);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 return sp_filecomplete(f);
}

canonical_original_code:
int sp_logcomplete(struct spfile *f)
{
 int rc = sp_logsync(f);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 return sp_filecomplete(f);
}


decompiled_code:
int __fastcall sp_logcompleteforce(__int64 a1)
{
int result; // eax
int v2; // ebp

result = sp_logsync(a1);
if ( result != -1 )
{
v2 = *(_DWORD *)(a1 + 8);
*(_DWORD *)(a1 + 8) = 1;
result = sp_filecomplete(a1);
*(_DWORD *)(a1 + 8) = v2;
}
return result;
}

canonical_decompiled_code:
int __fastcall func27(__int64 a1)
{
int result; // eax
int v2; // ebp

result = func13(a1);
if ( result != -1 )
{
v2 = *(_DWORD *)(a1 + 8);
*(_DWORD *)(a1 + 8) = 1;
result = func12(a1);
*(_DWORD *)(a1 + 8) = v2;
}
return result;
}

original_code:
int sp_logcompleteforce(spfile *f) {
 int rc = sp_logsync(f);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 int oldcreat = f->creat;
 f->creat = 1;
 rc = sp_filecomplete(f);
 f->creat = oldcreat;
 return rc;
}

canonical_original_code:
int sp_logcompleteforce(struct spfile *f) {
 int rc = sp_logsync(f);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 int oldcreat = f->creat;
 f->creat = 1;
 rc = sp_filecomplete(f);
 f->creat = oldcreat;
 return rc;
}

variable_types: oldcreat int


decompiled_code:
int __fastcall sp_logunlink(__int64 a1)
{
return sp_filerm(*(const char **)(a1 + 40));
}

canonical_decompiled_code:
int __fastcall func28(__int64 a1)
{
return func15(*(const char **)(a1 + 40));
}

original_code:
int sp_logunlink(spfile *f) {
 return sp_filerm(f->file);
}

canonical_original_code:
int sp_logunlink(struct spfile *f) {
 return sp_filerm(f->file);
}


decompiled_code:
__int64 __fastcall sp_logwrite(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbx
ssize_t v5; // rax

v4 = 0LL;
while ( 1 )
{
while ( 1 )
{
v5 = write(*(_DWORD *)(a1 + 48), (const void *)(a2 + v4), a3 - v4);
if ( v5 != -1 )
break;
if ( *_errno_location() != 4 )
return 0xFFFFFFFFLL;
}
if ( v5 <= 0 )
break;
v4 += v5;
if ( a3 == v4 )
{
*(_QWORD *)(a1 + 16) += v4;
return 0LL;
}
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func29(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbx
ssize_t v5; // rax

v4 = 0LL;
while ( 1 )
{
while ( 1 )
{
v5 = write(*(_DWORD *)(a1 + 48), (const void *)(a2 + v4), a3 - v4);
if ( v5 != -1 )
break;
if ( *_errno_location() != 4 )
return 0xFFFFFFFFLL;
}
if ( v5 <= 0 )
break;
v4 += v5;
if ( a3 == v4 )
{
*(_QWORD *)(a1 + 16) += v4;
return 0LL;
}
}
return 0xFFFFFFFFLL;
}

original_code:
int sp_logwrite(spfile *f, void *buf, size_t size)
{
 size_t n = 0;
 do {
  ssize_t r;
  do {
   r = write(f->fd, (char*)buf + n, size - n);
  } while (r == -1 && (*__errno_location ()) == 4);
  if (r <= 0)
   return -1;
  n += r;
 } while (n != size);
 f->used += size;
 return 0;
}

canonical_original_code:
int sp_logwrite(struct spfile *f, void *buf, unsigned long size)
{
 unsigned long n = 0;
 do {
  long r;
  do {
   r = write(f->fd, (char *)buf + n, size - n);
  } while (r == -1 && (*__errno_location ()) == 4);
  if (r <= 0)
   return -1;
  n += r;
 } while (n != size);
 f->used += size;
 return 0;
}

variable_types:
buf
void *

variable_types:
n
unsigned long

variable_types: r long


decompiled_code:
__int64 __fastcall sp_logput(__int64 a1, __int64 a2)
{
const struct iovec *v2; // rbx
int v3; // ebp
__int64 v4; // r12
int v6; // eax
int v7; // edx
unsigned __int64 v8; // rax

v2 = (const struct iovec *)a2;
v3 = *(_DWORD *)(a2 + 0x4000);
v4 = 0LL;
do
{
while ( 1 )
{
v6 = writev(*(_DWORD *)(a1 + 48), v2, v3);
v7 = v6;
if ( v6 != -1 )
break;
if ( *_errno_location() != 4 )
goto LABEL_3;
}
if ( v6 < 0 )
{
LABEL_3:
*(_DWORD *)(a2 + 0x4000) = 0;
return 0xFFFFFFFFLL;
}
v4 += v6;
if ( v3 <= 0 )
break;
while ( 1 )
{
v8 = v2->iov_len;
if ( v8 > v7 )
break;
v7 -= v8;
++v2;
if ( !--v3 )
goto LABEL_10;
}
v2->iov_base = (char *)v2->iov_base + v7;
v2->iov_len = v8 - v7;
}
while ( v3 > 0 );
LABEL_10:
*(_QWORD *)(a1 + 16) += v4;
*(_DWORD *)(a2 + 0x4000) = 0;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func30(__int64 a1, __int64 a2)
{
const struct iovec *v2; // rbx
int v3; // ebp
__int64 v4; // r12
int v6; // eax
int v7; // edx
unsigned __int64 v8; // rax

v2 = (const struct iovec *)a2;
v3 = *(_DWORD *)(a2 + 0x4000);
v4 = 0LL;
do
{
while ( 1 )
{
v6 = writev(*(_DWORD *)(a1 + 48), v2, v3);
v7 = v6;
if ( v6 != -1 )
break;
if ( *_errno_location() != 4 )
goto LABEL_3;
}
if ( v6 < 0 )
{
LABEL_3:
*(_DWORD *)(a2 + 0x4000) = 0;
return 0xFFFFFFFFLL;
}
v4 += v6;
if ( v3 <= 0 )
break;
while ( 1 )
{
v8 = v2->iov_len;
if ( v8 > v7 )
break;
v7 -= v8;
++v2;
if ( !--v3 )
goto LABEL_10;
}
v2->iov_base = (char *)v2->iov_base + v7;
v2->iov_len = v8 - v7;
}
while ( v3 > 0 );
LABEL_10:
*(_QWORD *)(a1 + 16) += v4;
*(_DWORD *)(a2 + 0x4000) = 0;
return 0LL;
}

original_code:
int sp_logput(spfile *f, spbatch *b)
{
 register struct iovec *v = b->iov;
 register uint64_t size = 0;
 register int n = b->iovc;
 do {
  int r;
  do {
   r = writev(f->fd, v, n);
  } while (r == -1 && (*__errno_location ()) == 4);
  if (r < 0) {
   b->iovc = 0;
   return -1;
  }
  size += r;
  while (n > 0) {
   if (v->iov_len > (size_t)r) {
    v->iov_base = (char*)v->iov_base + r;
    v->iov_len -= r;
    break;
   } else {
    r -= v->iov_len;
    v++;
    n--;
   }
  }
 } while (n > 0);
 f->used += size;
 b->iovc = 0;
 return 0;
}

canonical_original_code:
int sp_logput(struct spfile *f, struct spbatch *b)
{
 register struct iovec *v = b->iov;
 register unsigned long size = 0;
 register int n = b->iovc;
 do {
  int r;
  do {
   r = writev(f->fd, v, n);
  } while (r == -1 && (*__errno_location ()) == 4);
  if (r < 0) {
   b->iovc = 0;
   return -1;
  }
  size += r;
  while (n > 0) {
   if (v->iov_len > (unsigned long)r) {
    v->iov_base = (char *)v->iov_base + r;
    v->iov_len -= r;
    break;
   } else {
    r -= v->iov_len;
    v++;
    n--;
   }
  }
 } while (n > 0);
 f->used += size;
 b->iovc = 0;
 return 0;
}

variable_types: 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; } *

variable_types: struct spbatch { struct iovec { void *iov_base; unsigned long iov_len; } iov[1024]; int iovc; } *

variable_types: struct iovec { void *iov_base; unsigned long iov_len; } *

variable_types: n int

variable_types: r int


decompiled_code:
int __fastcall sp_logrlb(__int64 a1)
{
int result; // eax
__off_t v2; // rsi

result = ftruncate(*(_DWORD *)(a1 + 48), *(_QWORD *)(a1 + 32));
if ( result != -1 )
{
v2 = *(_QWORD *)(a1 + 32);
*(_QWORD *)(a1 + 16) = v2;
*(_QWORD *)(a1 + 32) = 0LL;
result = lseek(*(_DWORD *)(a1 + 48), v2, 0);
}
return result;
}

canonical_decompiled_code:
int __fastcall func31(__int64 a1)
{
int result; // eax
__off_t v2; // rsi

result = ftruncate(*(_DWORD *)(a1 + 48), *(_QWORD *)(a1 + 32));
if ( result != -1 )
{
v2 = *(_QWORD *)(a1 + 32);
*(_QWORD *)(a1 + 16) = v2;
*(_QWORD *)(a1 + 32) = 0LL;
result = lseek(*(_DWORD *)(a1 + 48), v2, 0);
}
return result;
}

original_code:
int sp_logrlb(spfile *f)
{
 int rc = ftruncate(f->fd, f->svp);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 f->used = f->svp;
 f->svp = 0;
 return lseek(f->fd, f->used, 0);
}

canonical_original_code:
int sp_logrlb(struct spfile *f)
{
 int rc = ftruncate(f->fd, f->svp);
 if (__builtin_expect(!! (rc == -1), 0))
  return -1;
 f->used = f->svp;
 f->svp = 0;
 return lseek(f->fd, f->used, 0);
}

variable_types: rc int


decompiled_code:
__int64 __fastcall sp_logeof(__int64 a1)
{
unsigned int v1; // ebx
int v3[7]; // [rsp+Ch] [rbp-1Ch] BYREF

sp_filesvp(a1);
v3[0] = 11202301;
v1 = 0;
if ( (unsigned int)sp_logwrite(a1, (__int64)v3, 4LL) == -1 )
{
v1 = -1;
sp_logrlb(a1);
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func32(__int64 a1)
{
unsigned int v1; // ebx
int v3[7]; // [rsp+Ch] [rbp-1Ch] BYREF

func1(a1);
v3[0] = 11202301;
v1 = 0;
if ( (unsigned int)func29(a1, (__int64)v3, 4LL) == -1 )
{
v1 = -1;
func31(a1);
}
return v1;
}

original_code:
int sp_logeof(spfile *f)
{
 sp_filesvp(f);
 speofh eof = { 0x00aaeefdL };
 int rc = sp_logwrite(f, &eof, sizeof(eof));
 if (__builtin_expect(!! (rc == -1), 0)) {
  sp_logrlb(f);
  return -1;
 }
 return 0;
}

canonical_original_code:
int sp_logeof(struct spfile *f)
{
 sp_filesvp(f);
 struct speofh eof = { 0x00aaeefdL };
 int rc = sp_logwrite(f, &eof, sizeof(eof));
 if (__builtin_expect(!! (rc == -1), 0)) {
  sp_logrlb(f);
  return -1;
 }
 return 0;
}

variable_types:
eof
struct speofh { unsigned int magic; }


decompiled_code:
int __fastcall sp_lockfile(__int64 a1, const char *a2)
{
int result; // eax
void *v3; // rax
int v4; // edx
__int64 v5[7]; // [rsp+0h] [rbp-38h] BYREF

*(_DWORD *)(a1 + 8) = 0;
result = open(a2, 65, 384LL);
*(_DWORD *)(a1 + 48) = result;
if ( result != -1 )
{
v3 = sp_strdup(*(_QWORD *)a1, a2);
*(_QWORD *)(a1 + 40) = v3;
if ( v3 )
{
v5[0] = 1LL;
v5[1] = 0LL;
v5[2] = 0LL;
v5[3] = 0LL;
v4 = fcntl(*(_DWORD *)(a1 + 48), 6, v5);
result = 0;
if ( v4 == -1 )
{
sp_fileclose(a1);
result = 1;
}
}
else
{
close(*(_DWORD *)(a1 + 48));
*(_DWORD *)(a1 + 48) = -1;
result = -1;
}
}
return result;
}

original_code:
int sp_lockfile(spfile *f, char *path)
{
 f->creat = 0;
 f->fd = open(path, 0100|01, 0600);
 if (__builtin_expect(!! (f->fd == -1), 0))
  return -1;
 f->file = sp_strdup(f->a, path);
 if (__builtin_expect(!! (f->file == ((void *)0)), 0)) {
  close(f->fd);
  f->fd = -1;
  return -1;
 }
 struct flock l;
 memset(&l, 0, sizeof(l));
 l.l_whence = 0;
 l.l_start = 0;
 l.l_len = 0;
 l.l_type = 1;
 int rc = fcntl(f->fd, 6, &l);
 if (__builtin_expect(!! (rc == -1), 0)) {
  sp_fileclose(f);
  return 1;
 }
 return 0;
}

canonical_original_code:
int sp_lockfile(struct spfile *f, char *path)
{
 f->creat = 0;
 f->fd = open(path, 0100|01, 0600);
 if (__builtin_expect(!! (f->fd == -1), 0))
  return -1;
 f->file = sp_strdup(f->a, path);
 if (__builtin_expect(!! (f->file == ((void *)0)), 0)) {
  close(f->fd);
  f->fd = -1;
  return -1;
 }
 struct flock l;
 memset(&l, 0, sizeof(l));
 l.l_whence = 0;
 l.l_start = 0;
 l.l_len = 0;
 l.l_type = 1;
 int rc = fcntl(f->fd, 6, &l);
 if (__builtin_expect(!! (rc == -1), 0)) {
  sp_fileclose(f);
  return 1;
 }
 return 0;
}

variable_types:
path
char *

variable_types: struct flock { short l_type; short l_whence; long l_start; long l_len; int l_pid; }


decompiled_code:
int __fastcall sp_unlockfile(__int64 a1)
{
int v2; // edi
__int64 v4[5]; // [rsp+0h] [rbp-28h] BYREF

v2 = *(_DWORD *)(a1 + 48);
if ( v2 == -1 )
return 0;
v4[0] = 2LL;
v4[1] = 0LL;
v4[2] = 0LL;
v4[3] = 0LL;
fcntl(v2, 6, v4);
unlink(*(const char **)(a1 + 40));
return sp_fileclose(a1);
}

original_code:
int sp_unlockfile(spfile *f)
{
 if (__builtin_expect(!! (f->fd == -1), 0))
  return 0;
 struct flock l;
 memset(&l, 0, sizeof(l));
 l.l_whence = 0;
 l.l_start = 0;
 l.l_len = 0;
 l.l_type = 2;
 fcntl(f->fd, 6, &l);
 unlink(f->file);
 return sp_fileclose(f);
}

canonical_original_code:
int sp_unlockfile(struct spfile *f)
{
 if (__builtin_expect(!! (f->fd == -1), 0))
  return 0;
 struct flock l;
 memset(&l, 0, sizeof(l));
 l.l_whence = 0;
 l.l_start = 0;
 l.l_len = 0;
 l.l_type = 2;
 fcntl(f->fd, 6, &l);
 unlink(f->file);
 return sp_fileclose(f);
}

user_defined_types: struct flock { short l_type; short l_whence; long l_start; long l_len; int l_pid; }


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 single_process()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 v2; // r12
__int64 v3; // rax
__int64 v4; // rbp

v0 = sp_env();
if ( !v0 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 31LL, "env != NULL");
fflush(0LL);
abort();
}
v1 = v0;
if ( (unsigned int)sp_ctl(v0, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 32LL, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0");
fflush(0LL);
abort();
}
v2 = sp_open(v1);
if ( !v2 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 34LL, "db != NULL");
fflush(0LL);
abort();
}
v3 = sp_env();
v4 = v3;
if ( !v3 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 36LL, "env2 != NULL");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_ctl(v3, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 37LL, "sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0");
fflush(0LL);
abort();
}
if ( sp_open(v4) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 39LL, "db2 == NULL");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v4) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 40LL, "sp_destroy(env2) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v2) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 41LL, "sp_destroy(db) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v1) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 42LL, "sp_destroy(env) == 0");
fflush(0LL);
abort();
}
return rmrf("./rep");
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 v2; // r12
__int64 v3; // rax
__int64 v4; // rbp

v0 = sp_env();
if ( !v0 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 31LL, "env != NULL");
fflush(0LL);
abort();
}
v1 = v0;
if ( (unsigned int)sp_ctl(v0, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 32LL, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0");
fflush(0LL);
abort();
}
v2 = sp_open(v1);
if ( !v2 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 34LL, "db != NULL");
fflush(0LL);
abort();
}
v3 = sp_env();
v4 = v3;
if ( !v3 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 36LL, "env2 != NULL");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_ctl(v3, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 37LL, "sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0");
fflush(0LL);
abort();
}
if ( sp_open(v4) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 39LL, "db2 == NULL");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v4) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 40LL, "sp_destroy(env2) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v2) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 41LL, "sp_destroy(db) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v1) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 42LL, "sp_destroy(env) == 0");
fflush(0LL);
abort();
}
return func1("./rep");
}

original_code:
static void
single_process(void) {
 void *env = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 31, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 32, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0"); fflush(((void *)0)); abort(); } });
 void *db = sp_open(env);
 ({ if (! (db != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 34, "db != NULL"); fflush(((void *)0)); abort(); } });
 void *env2 = sp_env();
 ({ if (! (env2 != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 36, "env2 != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 37, "sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0"); fflush(((void *)0)); abort(); } });
 void *db2 = sp_open(env2);
 ({ if (! (db2 == ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 39, "db2 == NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env2) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 40, "sp_destroy(env2) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(db) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 41, "sp_destroy(db) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 42, "sp_destroy(env) == 0"); fflush(((void *)0)); abort(); } });
 rmrf(dbrep1);
}

canonical_original_code:
static void single_process() {
 void *env = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 31, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 32, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0"); fflush(((void *)0)); abort(); } });
 void *db = sp_open(env);
 ({ if (! (db != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 34, "db != NULL"); fflush(((void *)0)); abort(); } });
 void *env2 = sp_env();
 ({ if (! (env2 != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 36, "env2 != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 37, "sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0"); fflush(((void *)0)); abort(); } });
 void *db2 = sp_open(env2);
 ({ if (! (db2 == ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 39, "db2 == NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env2) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 40, "sp_destroy(env2) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(db) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 41, "sp_destroy(db) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 42, "sp_destroy(env) == 0"); fflush(((void *)0)); abort(); } });
 rmrf(dbrep1);
}

variable_types:
env
void *

variable_types:
db
void *


decompiled_code:
__int64 single_process_2()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 v2; // r12
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // r13
__int64 result; // rax
void *ptr; // [rsp+8h] [rbp-40h] BYREF
__int64 v8; // [rsp+10h] [rbp-38h] BYREF
int v9[11]; // [rsp+1Ch] [rbp-2Ch] BYREF

v0 = sp_env();
if ( !v0 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 49LL, "env != NULL");
fflush(0LL);
abort();
}
v1 = v0;
if ( (unsigned int)sp_ctl(v0, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 50LL, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_ctl(v1, 2LL, cmp, 0LL) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 51LL, "sp_ctl(env, SPCMP, cmp, NULL) == 0");
fflush(0LL);
abort();
}
v2 = sp_open(v1);
if ( !v2 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 53LL, "db != NULL");
fflush(0LL);
abort();
}
v3 = sp_env();
if ( (unsigned int)sp_ctl(v3, 0LL, 6LL, "./rep2") )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 56LL, "sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep2) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_ctl(v3, 2LL, cmp, 0LL) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 57LL, "sp_ctl(env2, SPCMP, cmp, NULL) == 0");
fflush(0LL);
abort();
}
v4 = sp_open(v3);
v5 = v4;
if ( !v4 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 59LL, "db2 != NULL");
fflush(0LL);
abort();
}
v9[0] = 1;
if ( (unsigned int)sp_set(v4, v9, 4LL, v9, 4LL) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 61LL, "sp_set(db2, &k, sizeof(k), &k, sizeof(k)) == 0");
fflush(0LL);
abort();
}
v8 = 0LL;
ptr = 0LL;
if ( (unsigned int)sp_get(v5, v9, 4LL, &ptr, &v8) != 1 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 64LL, "sp_get(db2, &k, sizeof(k), &vp, &vsize) == 1");
fflush(0LL);
abort();
}
if ( v8 != 4 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 65LL, "vsize == sizeof(k)");
fflush(0LL);
abort();
}
if ( *(_DWORD *)ptr != v9[0] )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 66LL, "*(uint32_t*)vp == k");
fflush(0LL);
abort();
}
free(ptr);
v9[0] = 3;
if ( (unsigned int)sp_set(v2, v9, 4LL, v9, 4LL) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 69LL, "sp_set(db, &k, sizeof(k), &k, sizeof(k)) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_get(v2, v9, 4LL, &ptr, &v8) != 1 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 70LL, "sp_get(db, &k, sizeof(k), &vp, &vsize) == 1");
fflush(0LL);
abort();
}
if ( v8 != 4 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 71LL, "vsize == sizeof(k)");
fflush(0LL);
abort();
}
if ( *(_DWORD *)ptr != v9[0] )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 72LL, "*(uint32_t*)vp == k");
fflush(0LL);
abort();
}
free(ptr);
if ( (unsigned int)sp_destroy(v2) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 74LL, "sp_destroy(db) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v1) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 75LL, "sp_destroy(env) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v5) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 76LL, "sp_destroy(db2) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v3) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 77LL, "sp_destroy(env2) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)rmrf("./rep") )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 78LL, "rmrf(dbrep1) == 0");
fflush(0LL);
abort();
}
result = rmrf("./rep2");
if ( (_DWORD)result )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 79LL, "rmrf(dbrep2) == 0");
fflush(0LL);
abort();
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 v2; // r12
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // r13
__int64 result; // rax
void *ptr; // [rsp+8h] [rbp-40h] BYREF
__int64 v8; // [rsp+10h] [rbp-38h] BYREF
int v9[11]; // [rsp+1Ch] [rbp-2Ch] BYREF

v0 = sp_env();
if ( !v0 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 49LL, "env != NULL");
fflush(0LL);
abort();
}
v1 = v0;
if ( (unsigned int)sp_ctl(v0, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 50LL, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_ctl(v1, 2LL, cmp, 0LL) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 51LL, "sp_ctl(env, SPCMP, cmp, NULL) == 0");
fflush(0LL);
abort();
}
v2 = sp_open(v1);
if ( !v2 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 53LL, "db != NULL");
fflush(0LL);
abort();
}
v3 = sp_env();
if ( (unsigned int)sp_ctl(v3, 0LL, 6LL, "./rep2") )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 56LL, "sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep2) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_ctl(v3, 2LL, cmp, 0LL) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 57LL, "sp_ctl(env2, SPCMP, cmp, NULL) == 0");
fflush(0LL);
abort();
}
v4 = sp_open(v3);
v5 = v4;
if ( !v4 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 59LL, "db2 != NULL");
fflush(0LL);
abort();
}
v9[0] = 1;
if ( (unsigned int)sp_set(v4, v9, 4LL, v9, 4LL) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 61LL, "sp_set(db2, &k, sizeof(k), &k, sizeof(k)) == 0");
fflush(0LL);
abort();
}
v8 = 0LL;
ptr = 0LL;
if ( (unsigned int)sp_get(v5, v9, 4LL, &ptr, &v8) != 1 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 64LL, "sp_get(db2, &k, sizeof(k), &vp, &vsize) == 1");
fflush(0LL);
abort();
}
if ( v8 != 4 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 65LL, "vsize == sizeof(k)");
fflush(0LL);
abort();
}
if ( *(_DWORD *)ptr != v9[0] )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 66LL, "*(uint32_t*)vp == k");
fflush(0LL);
abort();
}
free(ptr);
v9[0] = 3;
if ( (unsigned int)sp_set(v2, v9, 4LL, v9, 4LL) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 69LL, "sp_set(db, &k, sizeof(k), &k, sizeof(k)) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_get(v2, v9, 4LL, &ptr, &v8) != 1 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 70LL, "sp_get(db, &k, sizeof(k), &vp, &vsize) == 1");
fflush(0LL);
abort();
}
if ( v8 != 4 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 71LL, "vsize == sizeof(k)");
fflush(0LL);
abort();
}
if ( *(_DWORD *)ptr != v9[0] )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 72LL, "*(uint32_t*)vp == k");
fflush(0LL);
abort();
}
free(ptr);
if ( (unsigned int)sp_destroy(v2) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 74LL, "sp_destroy(db) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v1) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 75LL, "sp_destroy(env) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v5) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 76LL, "sp_destroy(db2) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v3) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 77LL, "sp_destroy(env2) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)func1("./rep") )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 78LL, "rmrf(dbrep1) == 0");
fflush(0LL);
abort();
}
result = func1("./rep2");
if ( (_DWORD)result )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 79LL, "rmrf(dbrep2) == 0");
fflush(0LL);
abort();
}
return result;
}

original_code:
static void
single_process_2(void) {
 void *env = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 49, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 50, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPCMP, cmp, ((void *)0)) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 51, "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", "concurrent.c", 53, "db != NULL"); fflush(((void *)0)); abort(); } });
 void *env2 = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 55, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep2) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 56, "sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep2) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env2, SPCMP, cmp, ((void *)0)) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 57, "sp_ctl(env2, SPCMP, cmp, NULL) == 0"); fflush(((void *)0)); abort(); } });
 void *db2 = sp_open(env2);
 ({ if (! (db2 != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 59, "db2 != NULL"); fflush(((void *)0)); abort(); } });
 uint32_t k = 1;
 ({ if (! (sp_set(db2, &k, sizeof(k), &k, sizeof(k)) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 61, "sp_set(db2, &k, sizeof(k), &k, sizeof(k)) == 0"); fflush(((void *)0)); abort(); } });
 size_t vsize = 0;
 void *vp = ((void *)0);
 ({ if (! (sp_get(db2, &k, sizeof(k), &vp, &vsize) == 1)) { printf("fail (%s:%d) %s\n", "concurrent.c", 64, "sp_get(db2, &k, sizeof(k), &vp, &vsize) == 1"); fflush(((void *)0)); abort(); } });
 ({ if (! (vsize == sizeof(k))) { printf("fail (%s:%d) %s\n", "concurrent.c", 65, "vsize == sizeof(k)"); fflush(((void *)0)); abort(); } });
 ({ if (! (*(uint32_t*)vp == k)) { printf("fail (%s:%d) %s\n", "concurrent.c", 66, "*(uint32_t*)vp == k"); fflush(((void *)0)); abort(); } });
 free(vp);
 k = 3;
 ({ if (! (sp_set(db, &k, sizeof(k), &k, sizeof(k)) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 69, "sp_set(db, &k, sizeof(k), &k, sizeof(k)) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_get(db, &k, sizeof(k), &vp, &vsize) == 1)) { printf("fail (%s:%d) %s\n", "concurrent.c", 70, "sp_get(db, &k, sizeof(k), &vp, &vsize) == 1"); fflush(((void *)0)); abort(); } });
 ({ if (! (vsize == sizeof(k))) { printf("fail (%s:%d) %s\n", "concurrent.c", 71, "vsize == sizeof(k)"); fflush(((void *)0)); abort(); } });
 ({ if (! (*(uint32_t*)vp == k)) { printf("fail (%s:%d) %s\n", "concurrent.c", 72, "*(uint32_t*)vp == k"); fflush(((void *)0)); abort(); } });
 free(vp);
 ({ if (! (sp_destroy(db) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 74, "sp_destroy(db) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 75, "sp_destroy(env) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(db2) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 76, "sp_destroy(db2) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env2) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 77, "sp_destroy(env2) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (rmrf(dbrep1) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 78, "rmrf(dbrep1) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (rmrf(dbrep2) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 79, "rmrf(dbrep2) == 0"); fflush(((void *)0)); abort(); } });
}

canonical_original_code:
static void single_process_2() {
 void *env = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 49, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 50, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPCMP, cmp, ((void *)0)) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 51, "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", "concurrent.c", 53, "db != NULL"); fflush(((void *)0)); abort(); } });
 void *env2 = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 55, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep2) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 56, "sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep2) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env2, SPCMP, cmp, ((void *)0)) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 57, "sp_ctl(env2, SPCMP, cmp, NULL) == 0"); fflush(((void *)0)); abort(); } });
 void *db2 = sp_open(env2);
 ({ if (! (db2 != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 59, "db2 != NULL"); fflush(((void *)0)); abort(); } });
 unsigned int k = 1;
 ({ if (! (sp_set(db2, &k, sizeof(k), &k, sizeof(k)) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 61, "sp_set(db2, &k, sizeof(k), &k, sizeof(k)) == 0"); fflush(((void *)0)); abort(); } });
 unsigned long vsize = 0;
 void *vp = ((void *)0);
 ({ if (! (sp_get(db2, &k, sizeof(k), &vp, &vsize) == 1)) { printf("fail (%s:%d) %s\n", "concurrent.c", 64, "sp_get(db2, &k, sizeof(k), &vp, &vsize) == 1"); fflush(((void *)0)); abort(); } });
 ({ if (! (vsize == sizeof(k))) { printf("fail (%s:%d) %s\n", "concurrent.c", 65, "vsize == sizeof(k)"); fflush(((void *)0)); abort(); } });
 ({ if (! (*(unsigned int *)vp == k)) { printf("fail (%s:%d) %s\n", "concurrent.c", 66, "*(uint32_t*)vp == k"); fflush(((void *)0)); abort(); } });
 free(vp);
 k = 3;
 ({ if (! (sp_set(db, &k, sizeof(k), &k, sizeof(k)) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 69, "sp_set(db, &k, sizeof(k), &k, sizeof(k)) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_get(db, &k, sizeof(k), &vp, &vsize) == 1)) { printf("fail (%s:%d) %s\n", "concurrent.c", 70, "sp_get(db, &k, sizeof(k), &vp, &vsize) == 1"); fflush(((void *)0)); abort(); } });
 ({ if (! (vsize == sizeof(k))) { printf("fail (%s:%d) %s\n", "concurrent.c", 71, "vsize == sizeof(k)"); fflush(((void *)0)); abort(); } });
 ({ if (! (*(unsigned int *)vp == k)) { printf("fail (%s:%d) %s\n", "concurrent.c", 72, "*(uint32_t*)vp == k"); fflush(((void *)0)); abort(); } });
 free(vp);
 ({ if (! (sp_destroy(db) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 74, "sp_destroy(db) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 75, "sp_destroy(env) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(db2) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 76, "sp_destroy(db2) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env2) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 77, "sp_destroy(env2) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (rmrf(dbrep1) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 78, "rmrf(dbrep1) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (rmrf(dbrep2) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 79, "rmrf(dbrep2) == 0"); fflush(((void *)0)); abort(); } });
}

variable_types:
k
unsigned int

variable_types:
vsize
unsigned long

variable_types:
vp
void *


decompiled_code:
__int64 multi_process()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 v2; // r12
__pid_t v3; // eax
__int64 v4; // rax
__int64 v5; // rbx
int stat_loc[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v0 = sp_env();
if ( !v0 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 85LL, "env != NULL");
fflush(0LL);
abort();
}
v1 = v0;
if ( (unsigned int)sp_ctl(v0, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 86LL, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0");
fflush(0LL);
abort();
}
v2 = sp_open(v1);
if ( !v2 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 88LL, "db != NULL");
fflush(0LL);
abort();
}
v3 = fork();
if ( v3 == -1 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 90LL, "pid != -1");
fflush(0LL);
abort();
}
if ( !v3 )
{
v4 = sp_env();
v5 = v4;
if ( v4 )
{
if ( !(unsigned int)sp_ctl(v4, 0LL, 6LL, "./rep") )
{
if ( !sp_open(v5) )
{
if ( !(unsigned int)sp_destroy(v5) )
exit(0);
printf("fail (%s:%d) %s\n", "concurrent.c", 98LL, "sp_destroy(env2) == 0");
fflush(0LL);
abort();
}
printf("fail (%s:%d) %s\n", "concurrent.c", 97LL, "db2 == NULL");
fflush(0LL);
abort();
}
printf("fail (%s:%d) %s\n", "concurrent.c", 95LL, "sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0");
fflush(0LL);
abort();
}
printf("fail (%s:%d) %s\n", "concurrent.c", 94LL, "env2 != NULL");
fflush(0LL);
abort();
}
stat_loc[0] = 0;
if ( waitpid(v3, stat_loc, 0) != v3 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 106LL, "waitpid(pid, &status, 0) == pid");
fflush(0LL);
abort();
}
if ( stat_loc[0] )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 107LL, "status == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v2) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 109LL, "sp_destroy(db) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v1) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 110LL, "sp_destroy(env) == 0");
fflush(0LL);
abort();
}
return rmrf("./rep");
}

canonical_decompiled_code:
__int64 func4()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 v2; // r12
__pid_t v3; // eax
__int64 v4; // rax
__int64 v5; // rbx
int stat_loc[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v0 = sp_env();
if ( !v0 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 85LL, "env != NULL");
fflush(0LL);
abort();
}
v1 = v0;
if ( (unsigned int)sp_ctl(v0, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 86LL, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0");
fflush(0LL);
abort();
}
v2 = sp_open(v1);
if ( !v2 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 88LL, "db != NULL");
fflush(0LL);
abort();
}
v3 = fork();
if ( v3 == -1 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 90LL, "pid != -1");
fflush(0LL);
abort();
}
if ( !v3 )
{
v4 = sp_env();
v5 = v4;
if ( v4 )
{
if ( !(unsigned int)sp_ctl(v4, 0LL, 6LL, "./rep") )
{
if ( !sp_open(v5) )
{
if ( !(unsigned int)sp_destroy(v5) )
exit(0);
printf("fail (%s:%d) %s\n", "concurrent.c", 98LL, "sp_destroy(env2) == 0");
fflush(0LL);
abort();
}
printf("fail (%s:%d) %s\n", "concurrent.c", 97LL, "db2 == NULL");
fflush(0LL);
abort();
}
printf("fail (%s:%d) %s\n", "concurrent.c", 95LL, "sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0");
fflush(0LL);
abort();
}
printf("fail (%s:%d) %s\n", "concurrent.c", 94LL, "env2 != NULL");
fflush(0LL);
abort();
}
stat_loc[0] = 0;
if ( waitpid(v3, stat_loc, 0) != v3 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 106LL, "waitpid(pid, &status, 0) == pid");
fflush(0LL);
abort();
}
if ( stat_loc[0] )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 107LL, "status == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v2) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 109LL, "sp_destroy(db) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v1) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 110LL, "sp_destroy(env) == 0");
fflush(0LL);
abort();
}
return func1("./rep");
}

original_code:
static void
multi_process(void) {
 void *env = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 85, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 86, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0"); fflush(((void *)0)); abort(); } });
 void *db = sp_open(env);
 ({ if (! (db != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 88, "db != NULL"); fflush(((void *)0)); abort(); } });
 int pid = fork();
 ({ if (! (pid != -1)) { printf("fail (%s:%d) %s\n", "concurrent.c", 90, "pid != -1"); fflush(((void *)0)); abort(); } });
 if (pid == 0) {
  void *env2 = sp_env();
  ({ if (! (env2 != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 94, "env2 != NULL"); fflush(((void *)0)); abort(); } });
  ({ if (! (sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 95, "sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0"); fflush(((void *)0)); abort(); } });
  void *db2 = sp_open(env2);
  ({ if (! (db2 == ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 97, "db2 == NULL"); fflush(((void *)0)); abort(); } });
  ({ if (! (sp_destroy(env2) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 98, "sp_destroy(env2) == 0"); fflush(((void *)0)); abort(); } });
  exit(0);
 } else {
  int status = 0;
  ({ if (! (waitpid(pid, &status, 0) == pid)) { printf("fail (%s:%d) %s\n", "concurrent.c", 106, "waitpid(pid, &status, 0) == pid"); fflush(((void *)0)); abort(); } });
  ({ if (! (status == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 107, "status == 0"); fflush(((void *)0)); abort(); } });
 }
 ({ if (! (sp_destroy(db) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 109, "sp_destroy(db) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 110, "sp_destroy(env) == 0"); fflush(((void *)0)); abort(); } });
 rmrf(dbrep1);
}

canonical_original_code:
static void multi_process() {
 void *env = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 85, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 86, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0"); fflush(((void *)0)); abort(); } });
 void *db = sp_open(env);
 ({ if (! (db != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 88, "db != NULL"); fflush(((void *)0)); abort(); } });
 int pid = fork();
 ({ if (! (pid != -1)) { printf("fail (%s:%d) %s\n", "concurrent.c", 90, "pid != -1"); fflush(((void *)0)); abort(); } });
 if (pid == 0) {
  void *env2 = sp_env();
  ({ if (! (env2 != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 94, "env2 != NULL"); fflush(((void *)0)); abort(); } });
  ({ if (! (sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 95, "sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0"); fflush(((void *)0)); abort(); } });
  void *db2 = sp_open(env2);
  ({ if (! (db2 == ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 97, "db2 == NULL"); fflush(((void *)0)); abort(); } });
  ({ if (! (sp_destroy(env2) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 98, "sp_destroy(env2) == 0"); fflush(((void *)0)); abort(); } });
  exit(0);
 } else {
  int status = 0;
  ({ if (! (waitpid(pid, &status, 0) == pid)) { printf("fail (%s:%d) %s\n", "concurrent.c", 106, "waitpid(pid, &status, 0) == pid"); fflush(((void *)0)); abort(); } });
  ({ if (! (status == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 107, "status == 0"); fflush(((void *)0)); abort(); } });
 }
 ({ if (! (sp_destroy(db) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 109, "sp_destroy(db) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 110, "sp_destroy(env) == 0"); fflush(((void *)0)); abort(); } });
 rmrf(dbrep1);
}

variable_types: pid int

variable_types: status int


decompiled_code:
__pid_t multi_process_2()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 v2; // r12
__int64 v3; // r13
__pid_t v4; // eax
__pid_t v5; // ebp
__int64 v6; // rax
__int64 v7; // rbx
__pid_t result; // eax
int stat_loc; // [rsp+4h] [rbp-44h] BYREF
void *ptr; // [rsp+8h] [rbp-40h] BYREF
__int64 v11; // [rsp+10h] [rbp-38h] BYREF
int v12[11]; // [rsp+1Ch] [rbp-2Ch] BYREF

v0 = sp_env();
if ( !v0 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 117LL, "env != NULL");
fflush(0LL);
abort();
}
v1 = v0;
if ( (unsigned int)sp_ctl(v0, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 118LL, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_ctl(v1, 2LL, cmp, 0LL) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 119LL, "sp_ctl(env, SPCMP, cmp, NULL) == 0");
fflush(0LL);
abort();
}
v2 = sp_open(v1);
if ( !v2 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 121LL, "db != NULL");
fflush(0LL);
abort();
}
v3 = sp_env();
if ( (unsigned int)sp_ctl(v3, 0LL, 6LL, "./rep2") )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 124LL, "sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep2) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_ctl(v3, 2LL, cmp, 0LL) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 125LL, "sp_ctl(env2, SPCMP, cmp, NULL) == 0");
fflush(0LL);
abort();
}
v12[0] = 1;
v11 = 0LL;
ptr = 0LL;
v4 = fork();
v5 = v4;
if ( v4 == -1 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 130LL, "pid != -1");
fflush(0LL);
abort();
}
if ( !v4 )
{
v6 = sp_open(v3);
v7 = v6;
if ( v6 )
{
if ( !(unsigned int)sp_set(v6, v12, 4LL, v12, 4LL) )
{
if ( (unsigned int)sp_get(v7, v12, 4LL, &ptr, &v11) == 1 )
{
if ( v11 == 4 )
{
if ( *(_DWORD *)ptr == v12[0] )
{
free(ptr);
if ( !(unsigned int)sp_destroy(v7) )
{
if ( !(unsigned int)sp_destroy(v3) )
{
if ( !(unsigned int)rmrf("./rep2") )
exit(0);
printf("fail (%s:%d) %s\n", "concurrent.c", 141LL, "rmrf(dbrep2) == 0");
fflush(0LL);
abort();
}
printf("fail (%s:%d) %s\n", "concurrent.c", 140LL, "sp_destroy(env2) == 0");
fflush(0LL);
abort();
}
printf("fail (%s:%d) %s\n", "concurrent.c", 139LL, "sp_destroy(db2) == 0");
fflush(0LL);
abort();
}
printf("fail (%s:%d) %s\n", "concurrent.c", 137LL, "*(uint32_t*)vp == k");
fflush(0LL);
abort();
}
printf("fail (%s:%d) %s\n", "concurrent.c", 136LL, "vsize == sizeof(k)");
fflush(0LL);
abort();
}
printf("fail (%s:%d) %s\n", "concurrent.c", 135LL, "sp_get(db2, &k, sizeof(k), &vp, &vsize) == 1");
fflush(0LL);
abort();
}
printf("fail (%s:%d) %s\n", "concurrent.c", 134LL, "sp_set(db2, &k, sizeof(k), &k, sizeof(k)) == 0");
fflush(0LL);
abort();
}
printf("fail (%s:%d) %s\n", "concurrent.c", 133LL, "db2 != NULL");
fflush(0LL);
abort();
}
v12[0] = 3;
if ( (unsigned int)sp_set(v2, v12, 4LL, v12, 4LL) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 149LL, "sp_set(db, &k, sizeof(k), &k, sizeof(k)) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_get(v2, v12, 4LL, &ptr, &v11) != 1 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 150LL, "sp_get(db, &k, sizeof(k), &vp, &vsize) == 1");
fflush(0LL);
abort();
}
if ( v11 != 4 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 151LL, "vsize == sizeof(k)");
fflush(0LL);
abort();
}
if ( *(_DWORD *)ptr != v12[0] )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 152LL, "*(uint32_t*)vp == k");
fflush(0LL);
abort();
}
free(ptr);
if ( (unsigned int)sp_destroy(v2) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 154LL, "sp_destroy(db) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v1) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 155LL, "sp_destroy(env) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)rmrf("./rep") )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 156LL, "rmrf(dbrep1) == 0");
fflush(0LL);
abort();
}
stat_loc = 0;
result = waitpid(v5, &stat_loc, 0);
if ( result != v5 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 158LL, "waitpid(pid, &status, 0) == pid");
fflush(0LL);
abort();
}
if ( stat_loc )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 159LL, "status == 0");
fflush(0LL);
abort();
}
return result;
}

canonical_decompiled_code:
__pid_t func5()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 v2; // r12
__int64 v3; // r13
__pid_t v4; // eax
__pid_t v5; // ebp
__int64 v6; // rax
__int64 v7; // rbx
__pid_t result; // eax
int stat_loc; // [rsp+4h] [rbp-44h] BYREF
void *ptr; // [rsp+8h] [rbp-40h] BYREF
__int64 v11; // [rsp+10h] [rbp-38h] BYREF
int v12[11]; // [rsp+1Ch] [rbp-2Ch] BYREF

v0 = sp_env();
if ( !v0 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 117LL, "env != NULL");
fflush(0LL);
abort();
}
v1 = v0;
if ( (unsigned int)sp_ctl(v0, 0LL, 6LL, "./rep") )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 118LL, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_ctl(v1, 2LL, cmp, 0LL) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 119LL, "sp_ctl(env, SPCMP, cmp, NULL) == 0");
fflush(0LL);
abort();
}
v2 = sp_open(v1);
if ( !v2 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 121LL, "db != NULL");
fflush(0LL);
abort();
}
v3 = sp_env();
if ( (unsigned int)sp_ctl(v3, 0LL, 6LL, "./rep2") )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 124LL, "sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep2) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_ctl(v3, 2LL, cmp, 0LL) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 125LL, "sp_ctl(env2, SPCMP, cmp, NULL) == 0");
fflush(0LL);
abort();
}
v12[0] = 1;
v11 = 0LL;
ptr = 0LL;
v4 = fork();
v5 = v4;
if ( v4 == -1 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 130LL, "pid != -1");
fflush(0LL);
abort();
}
if ( !v4 )
{
v6 = sp_open(v3);
v7 = v6;
if ( v6 )
{
if ( !(unsigned int)sp_set(v6, v12, 4LL, v12, 4LL) )
{
if ( (unsigned int)sp_get(v7, v12, 4LL, &ptr, &v11) == 1 )
{
if ( v11 == 4 )
{
if ( *(_DWORD *)ptr == v12[0] )
{
free(ptr);
if ( !(unsigned int)sp_destroy(v7) )
{
if ( !(unsigned int)sp_destroy(v3) )
{
if ( !(unsigned int)func1("./rep2") )
exit(0);
printf("fail (%s:%d) %s\n", "concurrent.c", 141LL, "rmrf(dbrep2) == 0");
fflush(0LL);
abort();
}
printf("fail (%s:%d) %s\n", "concurrent.c", 140LL, "sp_destroy(env2) == 0");
fflush(0LL);
abort();
}
printf("fail (%s:%d) %s\n", "concurrent.c", 139LL, "sp_destroy(db2) == 0");
fflush(0LL);
abort();
}
printf("fail (%s:%d) %s\n", "concurrent.c", 137LL, "*(uint32_t*)vp == k");
fflush(0LL);
abort();
}
printf("fail (%s:%d) %s\n", "concurrent.c", 136LL, "vsize == sizeof(k)");
fflush(0LL);
abort();
}
printf("fail (%s:%d) %s\n", "concurrent.c", 135LL, "sp_get(db2, &k, sizeof(k), &vp, &vsize) == 1");
fflush(0LL);
abort();
}
printf("fail (%s:%d) %s\n", "concurrent.c", 134LL, "sp_set(db2, &k, sizeof(k), &k, sizeof(k)) == 0");
fflush(0LL);
abort();
}
printf("fail (%s:%d) %s\n", "concurrent.c", 133LL, "db2 != NULL");
fflush(0LL);
abort();
}
v12[0] = 3;
if ( (unsigned int)sp_set(v2, v12, 4LL, v12, 4LL) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 149LL, "sp_set(db, &k, sizeof(k), &k, sizeof(k)) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_get(v2, v12, 4LL, &ptr, &v11) != 1 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 150LL, "sp_get(db, &k, sizeof(k), &vp, &vsize) == 1");
fflush(0LL);
abort();
}
if ( v11 != 4 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 151LL, "vsize == sizeof(k)");
fflush(0LL);
abort();
}
if ( *(_DWORD *)ptr != v12[0] )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 152LL, "*(uint32_t*)vp == k");
fflush(0LL);
abort();
}
free(ptr);
if ( (unsigned int)sp_destroy(v2) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 154LL, "sp_destroy(db) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)sp_destroy(v1) )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 155LL, "sp_destroy(env) == 0");
fflush(0LL);
abort();
}
if ( (unsigned int)func1("./rep") )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 156LL, "rmrf(dbrep1) == 0");
fflush(0LL);
abort();
}
stat_loc = 0;
result = waitpid(v5, &stat_loc, 0);
if ( result != v5 )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 158LL, "waitpid(pid, &status, 0) == pid");
fflush(0LL);
abort();
}
if ( stat_loc )
{
printf("fail (%s:%d) %s\n", "concurrent.c", 159LL, "status == 0");
fflush(0LL);
abort();
}
return result;
}

original_code:
static void
multi_process_2(void) {
 void *env = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 117, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 118, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPCMP, cmp, ((void *)0)) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 119, "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", "concurrent.c", 121, "db != NULL"); fflush(((void *)0)); abort(); } });
 void *env2 = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 123, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep2) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 124, "sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep2) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env2, SPCMP, cmp, ((void *)0)) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 125, "sp_ctl(env2, SPCMP, cmp, NULL) == 0"); fflush(((void *)0)); abort(); } });
 uint32_t k = 1;
 size_t vsize = 0;
 void *vp = ((void *)0);
 int pid = fork();
 ({ if (! (pid != -1)) { printf("fail (%s:%d) %s\n", "concurrent.c", 130, "pid != -1"); fflush(((void *)0)); abort(); } });
 if (pid == 0) {
  void *db2 = sp_open(env2);
  ({ if (! (db2 != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 133, "db2 != NULL"); fflush(((void *)0)); abort(); } });
  ({ if (! (sp_set(db2, &k, sizeof(k), &k, sizeof(k)) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 134, "sp_set(db2, &k, sizeof(k), &k, sizeof(k)) == 0"); fflush(((void *)0)); abort(); } });
  ({ if (! (sp_get(db2, &k, sizeof(k), &vp, &vsize) == 1)) { printf("fail (%s:%d) %s\n", "concurrent.c", 135, "sp_get(db2, &k, sizeof(k), &vp, &vsize) == 1"); fflush(((void *)0)); abort(); } });
  ({ if (! (vsize == sizeof(k))) { printf("fail (%s:%d) %s\n", "concurrent.c", 136, "vsize == sizeof(k)"); fflush(((void *)0)); abort(); } });
  ({ if (! (*(uint32_t*)vp == k)) { printf("fail (%s:%d) %s\n", "concurrent.c", 137, "*(uint32_t*)vp == k"); fflush(((void *)0)); abort(); } });
  free(vp);
  ({ if (! (sp_destroy(db2) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 139, "sp_destroy(db2) == 0"); fflush(((void *)0)); abort(); } });
  ({ if (! (sp_destroy(env2) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 140, "sp_destroy(env2) == 0"); fflush(((void *)0)); abort(); } });
  ({ if (! (rmrf(dbrep2) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 141, "rmrf(dbrep2) == 0"); fflush(((void *)0)); abort(); } });
  exit(0);
 }
 k = 3;
 ({ if (! (sp_set(db, &k, sizeof(k), &k, sizeof(k)) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 149, "sp_set(db, &k, sizeof(k), &k, sizeof(k)) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_get(db, &k, sizeof(k), &vp, &vsize) == 1)) { printf("fail (%s:%d) %s\n", "concurrent.c", 150, "sp_get(db, &k, sizeof(k), &vp, &vsize) == 1"); fflush(((void *)0)); abort(); } });
 ({ if (! (vsize == sizeof(k))) { printf("fail (%s:%d) %s\n", "concurrent.c", 151, "vsize == sizeof(k)"); fflush(((void *)0)); abort(); } });
 ({ if (! (*(uint32_t*)vp == k)) { printf("fail (%s:%d) %s\n", "concurrent.c", 152, "*(uint32_t*)vp == k"); fflush(((void *)0)); abort(); } });
 free(vp);
 ({ if (! (sp_destroy(db) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 154, "sp_destroy(db) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 155, "sp_destroy(env) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (rmrf(dbrep1) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 156, "rmrf(dbrep1) == 0"); fflush(((void *)0)); abort(); } });
 int status = 0;
 ({ if (! (waitpid(pid, &status, 0) == pid)) { printf("fail (%s:%d) %s\n", "concurrent.c", 158, "waitpid(pid, &status, 0) == pid"); fflush(((void *)0)); abort(); } });
 ({ if (! (status == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 159, "status == 0"); fflush(((void *)0)); abort(); } });
}

canonical_original_code:
static void multi_process_2() {
 void *env = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 117, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 118, "sp_ctl(env, SPDIR, SPO_CREAT|SPO_RDWR, dbrep1) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env, SPCMP, cmp, ((void *)0)) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 119, "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", "concurrent.c", 121, "db != NULL"); fflush(((void *)0)); abort(); } });
 void *env2 = sp_env();
 ({ if (! (env != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 123, "env != NULL"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep2) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 124, "sp_ctl(env2, SPDIR, SPO_CREAT|SPO_RDWR, dbrep2) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_ctl(env2, SPCMP, cmp, ((void *)0)) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 125, "sp_ctl(env2, SPCMP, cmp, NULL) == 0"); fflush(((void *)0)); abort(); } });
 unsigned int k = 1;
 unsigned long vsize = 0;
 void *vp = ((void *)0);
 int pid = fork();
 ({ if (! (pid != -1)) { printf("fail (%s:%d) %s\n", "concurrent.c", 130, "pid != -1"); fflush(((void *)0)); abort(); } });
 if (pid == 0) {
  void *db2 = sp_open(env2);
  ({ if (! (db2 != ((void *)0))) { printf("fail (%s:%d) %s\n", "concurrent.c", 133, "db2 != NULL"); fflush(((void *)0)); abort(); } });
  ({ if (! (sp_set(db2, &k, sizeof(k), &k, sizeof(k)) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 134, "sp_set(db2, &k, sizeof(k), &k, sizeof(k)) == 0"); fflush(((void *)0)); abort(); } });
  ({ if (! (sp_get(db2, &k, sizeof(k), &vp, &vsize) == 1)) { printf("fail (%s:%d) %s\n", "concurrent.c", 135, "sp_get(db2, &k, sizeof(k), &vp, &vsize) == 1"); fflush(((void *)0)); abort(); } });
  ({ if (! (vsize == sizeof(k))) { printf("fail (%s:%d) %s\n", "concurrent.c", 136, "vsize == sizeof(k)"); fflush(((void *)0)); abort(); } });
  ({ if (! (*(unsigned int *)vp == k)) { printf("fail (%s:%d) %s\n", "concurrent.c", 137, "*(uint32_t*)vp == k"); fflush(((void *)0)); abort(); } });
  free(vp);
  ({ if (! (sp_destroy(db2) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 139, "sp_destroy(db2) == 0"); fflush(((void *)0)); abort(); } });
  ({ if (! (sp_destroy(env2) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 140, "sp_destroy(env2) == 0"); fflush(((void *)0)); abort(); } });
  ({ if (! (rmrf(dbrep2) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 141, "rmrf(dbrep2) == 0"); fflush(((void *)0)); abort(); } });
  exit(0);
 }
 k = 3;
 ({ if (! (sp_set(db, &k, sizeof(k), &k, sizeof(k)) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 149, "sp_set(db, &k, sizeof(k), &k, sizeof(k)) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_get(db, &k, sizeof(k), &vp, &vsize) == 1)) { printf("fail (%s:%d) %s\n", "concurrent.c", 150, "sp_get(db, &k, sizeof(k), &vp, &vsize) == 1"); fflush(((void *)0)); abort(); } });
 ({ if (! (vsize == sizeof(k))) { printf("fail (%s:%d) %s\n", "concurrent.c", 151, "vsize == sizeof(k)"); fflush(((void *)0)); abort(); } });
 ({ if (! (*(unsigned int *)vp == k)) { printf("fail (%s:%d) %s\n", "concurrent.c", 152, "*(uint32_t*)vp == k"); fflush(((void *)0)); abort(); } });
 free(vp);
 ({ if (! (sp_destroy(db) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 154, "sp_destroy(db) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (sp_destroy(env) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 155, "sp_destroy(env) == 0"); fflush(((void *)0)); abort(); } });
 ({ if (! (rmrf(dbrep1) == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 156, "rmrf(dbrep1) == 0"); fflush(((void *)0)); abort(); } });
 int status = 0;
 ({ if (! (waitpid(pid, &status, 0) == pid)) { printf("fail (%s:%d) %s\n", "concurrent.c", 158, "waitpid(pid, &status, 0) == pid"); fflush(((void *)0)); abort(); } });
 ({ if (! (status == 0)) { printf("fail (%s:%d) %s\n", "concurrent.c", 159, "status == 0"); fflush(((void *)0)); abort(); } });
}