bdifferenceb

decompiled_code:
int *__fastcall bdifferenceb(int *a1, __int64 a2)
{
int v2; // edx
__int64 v3; // rax

v2 = *a1;
if ( a1[1] != *(_DWORD *)(a2 + 4) )
_assert_fail("b1->size == b2->size", "bitset.c", 0x7Fu, "bdifferenceb");
v3 = 1LL;
if ( v2 > 0 )
{
do
{
*(_QWORD *)&a1[2 * v3] &= ~*(_QWORD *)(a2 + 8 * v3);
++v3;
}
while ( v2 + 1 != v3 );
}
return a1;
}

original_code:
bitset bdifferenceb(bitset b1, bitset b2)
{
  int i, bsize = b1->bsize;
  ((void) sizeof ((b1->size == b2->size) ? 1 : 0), __extension__ ({ if (b1->size == b2->size) ; else __assert_fail ("b1->size == b2->size", "bitset.c", 127, __extension__ __PRETTY_FUNCTION__); }));
  for (i = 0; i < bsize; i++) b1->bitset[i] &= ~b2->bitset[i];
  return b1;
}

canonical_original_code:
struct { int bsize; long bitset[]; } *bdifferenceb(struct { int bsize; long bitset[]; } *b1, struct { int bsize; long bitset[]; } *b2)
{
  int i; int bsize = b1->bsize;
  ((void) sizeof ((b1->size == b2->size) ? 1 : 0), __extension__ ({ if (b1->size == b2->size) ; else __assert_fail ("b1->size == b2->size", "bitset.c", 127, __extension__ __PRETTY_FUNCTION__); }));
  for (i = 0; i < bsize; i++) b1->bitset[i] &= ~b2->bitset[i];
  return b1;
}


bassignb

repo: jkodumal/banshee

original_code:
bitset bassignb(bitset b1, bitset b2)
{
  int i, bsize = b1->bsize;
  ((void) sizeof ((b1->size == b2->size) ? 1 : 0), __extension__ ({ if (b1->size == b2->size) ; else __assert_fail ("b1->size == b2->size", "bitset.c", 160, __extension__ __PRETTY_FUNCTION__); }));
  for (i = 0; i < bsize; i++) b1->bitset[i] = b2->bitset[i];
  return b1;
}

canonical_original_code:
struct { int bsize; long bitset[]; } *bassignb(struct { int bsize; long bitset[]; } *b1, struct { int bsize; long bitset[]; } *b2)
{
  int i; int bsize = b1->bsize;
  ((void) sizeof ((b1->size == b2->size) ? 1 : 0), __extension__ ({ if (b1->size == b2->size) ; else __assert_fail ("b1->size == b2->size", "bitset.c", 160, __extension__ __PRETTY_FUNCTION__); }));
  for (i = 0; i < bsize; i++) b1->bitset[i] = b2->bitset[i];
  return b1;
}

variable_types: i int

variable_types: bsize int

return_type: struct { int bsize; long bitset[]; } *


decompiled_code:
__int64 __fastcall bitset_inp(int *a1, __int64 a2)
{
int v2; // eax
__int64 v3; // rdx

v2 = *a1;
if ( a1[1] != *(_DWORD *)(a2 + 4) )
_assert_fail("b1->size == b2->size", "bitset.c", 0xB1u, "bitset_inp");
v3 = 1LL;
if ( v2 <= 0 )
return 1LL;
while ( (*(_QWORD *)&a1[2 * v3] & ~*(_QWORD *)(a2 + 8 * v3)) == 0LL )
{
if ( v2 + 1 == ++v3 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func12(int *a1, __int64 a2)
{
int v2; // eax
__int64 v3; // rdx

v2 = *a1;
if ( a1[1] != *(_DWORD *)(a2 + 4) )
_assert_fail("b1->size == b2->size", "bitset.c", 0xB1u, "bitset_inp");
v3 = 1LL;
if ( v2 <= 0 )
return 1LL;
while ( (*(_QWORD *)&a1[2 * v3] & ~*(_QWORD *)(a2 + 8 * v3)) == 0LL )
{
if ( v2 + 1 == ++v3 )
return 1LL;
}
return 0LL;
}

original_code:
bool bitset_inp(bitset b1, bitset b2)
{
  int i, bsize = b1->bsize;
  ((void) sizeof ((b1->size == b2->size) ? 1 : 0), __extension__ ({ if (b1->size == b2->size) ; else __assert_fail ("b1->size == b2->size", "bitset.c", 177, __extension__ __PRETTY_FUNCTION__); }));
  for (i = 0; i < bsize; i++)
    if (b1->bitset[i] & ~b2->bitset[i]) return 0;
  return 1;
}

canonical_original_code:
unsigned char bitset_inp(struct { int bsize; long bitset[]; } *b1, struct { int bsize; long bitset[]; } *b2)
{
  int i; int bsize = b1->bsize;
  ((void) sizeof ((b1->size == b2->size) ? 1 : 0), __extension__ ({ if (b1->size == b2->size) ; else __assert_fail ("b1->size == b2->size", "bitset.c", 177, __extension__ __PRETTY_FUNCTION__); }));
  for (i = 0; i < bsize; i++)
    if (b1->bitset[i] & ~b2->bitset[i]) return 0;
  return 1;
}

return_type: unsigned char


decompiled_code:
bool __fastcall bitset_eqp(int *a1, __int64 a2)
{
if ( a1[1] != *(_DWORD *)(a2 + 4) )
_assert_fail("b1->size == b2->size", "bitset.c", 0xBAu, "bitset_eqp");
return memcmp(a1 + 2, (const void *)(a2 + 8), 8LL * *a1) == 0;
}

canonical_decompiled_code:
bool __fastcall func13(int *a1, __int64 a2)
{
if ( a1[1] != *(_DWORD *)(a2 + 4) )
_assert_fail("b1->size == b2->size", "bitset.c", 0xBAu, "bitset_eqp");
return memcmp(a1 + 2, (const void *)(a2 + 8), 8LL * *a1) == 0;
}

original_code:
bool bitset_eqp(bitset b1, bitset b2)
{
  ((void) sizeof ((b1->size == b2->size) ? 1 : 0), __extension__ ({ if (b1->size == b2->size) ; else __assert_fail ("b1->size == b2->size", "bitset.c", 186, __extension__ __PRETTY_FUNCTION__); }));
  return memcmp(b1->bitset, b2->bitset, b1->bsize * sizeof(b1->bitset[0])) == 0;
}

canonical_original_code:
unsigned char bitset_eqp(struct { int bsize; long bitset[]; } *b1, struct { int bsize; long bitset[]; } *b2)
{
  ((void) sizeof ((b1->size == b2->size) ? 1 : 0), __extension__ ({ if (b1->size == b2->size) ; else __assert_fail ("b1->size == b2->size", "bitset.c", 186, __extension__ __PRETTY_FUNCTION__); }));
  return memcmp(b1->bitset, b2->bitset, b1->bsize * sizeof(b1->bitset[0])) == 0;
}


bemptyp

decompiled_code:
__int64 __fastcall bemptyp(int *a1)
{
_QWORD *v1; // rax

if ( *a1 <= 0 )
return 1LL;
v1 = a1 + 2;
while ( !*v1 )
{
if ( ++v1 == (_QWORD *)&a1[2 * (*a1 - 1) + 4] )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func14(int *a1)
{
_QWORD *v1; // rax

if ( *a1 <= 0 )
return 1LL;
v1 = a1 + 2;
while ( !*v1 )
{
if ( ++v1 == (_QWORD *)&a1[2 * (*a1 - 1) + 4] )
return 1LL;
}
return 0LL;
}

original_code:
bool bemptyp(bitset b)
{
  int i, bsize = b->bsize;
  for (i = 0; i < bsize; i++) if (b->bitset[i]) return 0;
  return 1;
}

canonical_original_code:
unsigned char bemptyp(struct { int bsize; long bitset[]; } *b)
{
  int i; int bsize = b->bsize;
  for (i = 0; i < bsize; i++) if (b->bitset[i]) return 0;
  return 1;
}

variable_types:
b
struct { int bsize; long bitset[]; } *


vfail

decompiled_code:
void __fastcall __noreturn vfail(char *format, __gnuc_va_list arg)
{
vfprintf(stderr, format, arg);
fflush(stderr);
fflush(stdout);
abort();
}

canonical_decompiled_code:
void __fastcall __noreturn func0(char *format, __gnuc_va_list arg)
{
vfprintf(stderr, format, arg);
fflush(stderr);
fflush(stdout);
abort();
}

original_code:
static void vfail(const char *fmt, va_list args)
{
  vfprintf(stderr, fmt, args);
  fflush(stderr);
  fflush(stdout);
  abort();
  while (1);
}

canonical_original_code:
static void vfail(char *fmt, __builtin_va_list args)
{
  vfprintf(stderr, fmt, args);
  fflush(stderr);
  fflush(stdout);
  abort();
  while (1);
}

variable_types:
fmt
char *

return_type: void


xmalloc

decompiled_code:
void *__fastcall xmalloc(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
xmalloc_cold();
return result;
}

canonical_decompiled_code:
void *__fastcall func1(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
func20();
return result;
}

original_code:
void *xmalloc(size_t size)
{
  void *x = malloc(size);
  if (!x) abort();
  return x;
}

canonical_original_code:
void *xmalloc(unsigned long size)
{
  void *x = malloc(size);
  if (!x) abort();
  return x;
}

variable_types:
size
unsigned long

variable_types:
x
void *

return_type: void *


xrealloc

decompiled_code:
void *__fastcall xrealloc(void *a1, size_t a2)
{
void *result; // rax

result = realloc(a1, a2);
if ( !result )
xrealloc_cold();
return result;
}

canonical_decompiled_code:
void *__fastcall func2(void *a1, size_t a2)
{
void *result; // rax

result = realloc(a1, a2);
if ( !result )
func21();
return result;
}

original_code:
void *xrealloc(void *p, size_t newsize)
{
  void *x = realloc(p, newsize);
  if (!x) abort();
  return x;
}

canonical_original_code:
void *xrealloc(void *p, unsigned long newsize)
{
  void *x = realloc(p, newsize);
  if (!x) abort();
  return x;
}

variable_types:
p
void *

variable_types:
newsize
unsigned long


decompiled_code:
__int64 __fastcall align_to(__int64 a1, unsigned __int64 a2)
{
return a2 * (int)((a2 + a1 - 1) / a2);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned __int64 a2)
{
return a2 * (int)((a2 + a1 - 1) / a2);
}

original_code:
unsigned long align_to(unsigned long n, unsigned long alignment)
{
  int count = (n + alignment - 1) / alignment;
  return count * alignment;
}

variable_types:
n
unsigned long

variable_types:
alignment
unsigned long

variable_types: count int

return_type: unsigned long


gcd

decompiled_code:
unsigned __int64 __fastcall gcd(unsigned __int64 a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rax
unsigned __int64 v3; // rdx
unsigned __int64 i; // r8

v2 = a1;
v3 = a2;
for ( i = a1; v3; v2 = i )
{
i = v3;
v3 = v2 % v3;
}
return i;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func4(unsigned __int64 a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rax
unsigned __int64 v3; // rdx
unsigned __int64 i; // r8

v2 = a1;
v3 = a2;
for ( i = a1; v3; v2 = i )
{
i = v3;
v3 = v2 % v3;
}
return i;
}

original_code:
unsigned long gcd(unsigned long x, unsigned long y)
{
  unsigned long z;
  for (;;)
    {
      if (y == 0)
 return x;
      z = x % y; x = y; y = z;
    }
}

variable_types:
x
unsigned long

variable_types:
y
unsigned long

variable_types:
z
unsigned long


lcm

decompiled_code:
unsigned __int64 __fastcall lcm(unsigned __int64 a1, unsigned __int64 a2)
{
return a2 * a1 / gcd(a1, a2);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func5(unsigned __int64 a1, unsigned __int64 a2)
{
return a2 * a1 / func4(a1, a2);
}

original_code:
unsigned long lcm(unsigned long x, unsigned long y)
{
  return (x * y) / gcd(x, y);
}


decompiled_code:
char *__fastcall ptr_to_ascii(const void *a1)
{
int v1; // eax

v1 = snprintf(addr_1, 0x13uLL, "%p", a1);
if ( v1 == -1 || v1 > 18 )
_fail(
"utils.c",
0xF3u,
(__int64)"ptr_to_ascii",
"Unable to convert ptr to ascii (need %d bytes, have %d)\n",
(unsigned int)v1,
19LL);
return addr_1;
}

canonical_decompiled_code:
char *__fastcall func12(const void *a1)
{
int v1; // eax

v1 = snprintf(addr_1, 0x13uLL, "%p", a1);
if ( v1 == -1 || v1 > 18 )
func6(
"utils.c",
0xF3u,
(__int64)"ptr_to_ascii",
"Unable to convert ptr to ascii (need %d bytes, have %d)\n",
(unsigned int)v1,
19LL);
return addr_1;
}

original_code:
char *ptr_to_ascii(void *ptr) {
  static char addr[((int) (3 + sizeof(void *)*2))];
  int nchars;
  nchars = snprintf(addr, ((int) (3 + sizeof(void *)*2)), "%p", ptr);
  if (nchars == -1 || nchars >= ((int) (3 + sizeof(void *)*2)))
    __fail("utils.c", 243, __FUNCTION__, "Unable to convert ptr to ascii (need %d bytes, have %d)\n", nchars, ((int) (3 + sizeof(void *)*2)));
  return addr;
}

canonical_original_code:
char *ptr_to_ascii(void *ptr) {
  static char addr[-1];
  int nchars;
  nchars = snprintf(addr, ((int) (3 + sizeof(void *)*2)), "%p", ptr);
  if (nchars == -1 || nchars >= ((int) (3 + sizeof(void *)*2)))
    __fail("utils.c", 243, __FUNCTION__, "Unable to convert ptr to ascii (need %d bytes, have %d)\n", nchars, ((int) (3 + sizeof(void *)*2)));
  return addr;
}

variable_types:
ptr
void *

variable_types:
addr
char [-1]

variable_types: nchars int

return_type: char *


decompiled_code:
unsigned __int64 __fastcall ptr_hash(unsigned __int64 a1)
{
return a1 >> 3;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func13(unsigned __int64 a1)
{
return a1 >> 3;
}

original_code:
unsigned long ptr_hash(void *ptr)
{
  return (unsigned long) ptr >> 3;
}


decompiled_code:
bool __fastcall ptr_eq(__int64 a1, __int64 a2)
{
return a2 == a1;
}

canonical_decompiled_code:
bool __fastcall func14(__int64 a1, __int64 a2)
{
return a2 == a1;
}

original_code:
bool ptr_eq(void *ptr1, void *ptr2)
{
  return ptr1 == ptr2;
}

canonical_original_code:
unsigned char ptr_eq(void *ptr1, void *ptr2)
{
  return ptr1 == ptr2;
}


decompiled_code:
__int64 __fastcall string_hash(char *a1)
{
__int64 v1; // rax
__int64 i; // r8

if ( !a1 )
return 0LL;
v1 = *a1;
for ( i = 0LL; (_BYTE)v1; v1 = *a1 )
{
++a1;
i = 33 * i + v1 + 720;
}
return i;
}

original_code:
unsigned long string_hash(const char *str)
{
  const char *c;
  unsigned long h;
  c = str;
  h = 0;
  if (!c)
    return 0;
  while (*c)
    h = 33*h + 720 + *c++;
  return h;
}

canonical_original_code:
unsigned long string_hash(char *str)
{
  char *c;
  unsigned long h;
  c = str;
  h = 0;
  if (!c)
    return 0;
  while (*c)
    h = 33*h + 720 + *c++;
  return h;
}

variable_types:
str
char *

variable_types:
c
char *

variable_types:
h
unsigned long


decompiled_code:
bool __fastcall string_eq(const char *a1, const char *a2)
{
bool result; // al

if ( a1 && a2 )
result = strcmp(a1, a2) == 0;
else
result = 0;
return result;
}

canonical_decompiled_code:
bool __fastcall func16(const char *a1, const char *a2)
{
bool result; // al

if ( a1 && a2 )
result = strcmp(a1, a2) == 0;
else
result = 0;
return result;
}

original_code:
bool string_eq(const char *s1, const char *s2)
{
  if (!s1 || !s2)
    return 0;
  return !strcmp(s1, s2);
}

canonical_original_code:
unsigned char string_eq(char *s1, char *s2)
{
  if (!s1 || !s2)
    return 0;
  return !strcmp(s1, s2);
}


decompiled_code:
__int64 __fastcall ptr_cmp(__int64 a1, __int64 a2)
{
return a1 - a2;
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, __int64 a2)
{
return a1 - a2;
}

original_code:
int ptr_cmp(void *ptr1, void *ptr2)
{
  return (char *) ptr1 - (char *) ptr2;
}

return_type: int


min

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

result = a2;
if ( (int)a1 <= (int)a2 )
result = a1;
return result;
}

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

result = a2;
if ( (int)a1 <= (int)a2 )
result = a1;
return result;
}

original_code: int min(int a, int b) { if (a < b) return a; else return b; }

variable_types: a int

variable_types: b int


max

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

result = a2;
if ( (int)a1 >= (int)a2 )
result = a1;
return result;
}

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

result = a2;
if ( (int)a1 >= (int)a2 )
result = a1;
return result;
}

original_code: int max(int a, int b) { if (a < b) return b; else return a; }


decompiled_code:
// attributes: thunk
__int64 banshee_serialize_end()
{
return serialize_end();
}

canonical_decompiled_code:
__int64 func5()
{
return serialize_end();
}

original_code:
void banshee_serialize_end()
{
  serialize_end();
}


decompiled_code:
// attributes: thunk
__int64 banshee_deserialize_end()
{
return deserialize_end();
}

canonical_decompiled_code:
__int64 func7()
{
return deserialize_end();
}

original_code:
void banshee_deserialize_end(void)
{
  deserialize_end();
}

canonical_original_code:
void banshee_deserialize_end()
{
  deserialize_end();
}


decompiled_code:
__int64 gen_e_set_fields()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func2()
{
return 1LL;
}

original_code:
bool gen_e_set_fields(void *obj)
{
  return 1;
}

canonical_original_code:
unsigned char gen_e_set_fields(void *obj)
{
  return 1;
}

variable_types:
obj
void *


original_code:
static unsigned long state_hash(hash_key key)
{
  unsigned long keyval = (unsigned long)key;
  keyval += (keyval << 12);
  keyval ^= (keyval >> 22);
  keyval += (keyval << 4);
  keyval ^= (keyval >> 9);
  keyval += (keyval << 10);
  keyval ^= (keyval >> 2);
  keyval += (keyval << 7);
  keyval ^= (keyval >> 12);
  return keyval;
}

canonical_original_code:
static unsigned long state_hash(void *key)
{
  unsigned long keyval = (unsigned long)key;
  keyval += (keyval << 12);
  keyval ^= (keyval >> 22);
  keyval += (keyval << 4);
  keyval ^= (keyval >> 9);
  keyval += (keyval << 10);
  keyval ^= (keyval >> 2);
  keyval += (keyval << 7);
  keyval ^= (keyval >> 12);
  return keyval;
}

variable_types:
key
void *

variable_types:
keyval
unsigned long


decompiled_code:
bool __fastcall state_eq(__int64 a1, __int64 a2)
{
return a2 == a1;
}

canonical_decompiled_code:
bool __fastcall func1(__int64 a1, __int64 a2)
{
return a2 == a1;
}

original_code:
static bool state_eq(hash_key state1, hash_key state2)
{
  return state1 == state2;
}

canonical_original_code:
static unsigned char state_eq(void *state1, void *state2)
{
  return state1 == state2;
}


decompiled_code:
void *regexp_calloc()
{
return calloc(1uLL, 0x30uLL);
}

canonical_decompiled_code:
void *func2()
{
return calloc(1uLL, 0x30uLL);
}

original_code:
static regexp regexp_calloc() {
  return (regexp) calloc (1, sizeof(struct regexp_));
}

canonical_original_code:
static struct regexp_ *regexp_calloc() {
  return (struct regexp_ *) calloc (1, sizeof(struct regexp_));
}

return_type: struct regexp_ { unsigned char length; unsigned char *expr; unsigned char necessary[32]; } *


decompiled_code:
void *__fastcall regexp_alloc_str(unsigned __int8 a1)
{
return malloc(a1);
}

canonical_decompiled_code:
void *__fastcall func3(unsigned __int8 a1)
{
return malloc(a1);
}

original_code:
static letter* regexp_alloc_str(unsigned char length) {
  return (unsigned char *) malloc (sizeof(letter) * length);
}

canonical_original_code:
static unsigned char *regexp_alloc_str(unsigned char length) {
  return (unsigned char *) malloc (sizeof(letter) * length);
}

variable_types:
length
unsigned char

return_type: unsigned char *


decompiled_code:
__int64 __fastcall regexp_print_subexpr(__int64 a1, unsigned __int8 a2, unsigned __int8 a3)
{
unsigned __int8 v3; // r13
__int64 v4; // rbp
__int64 v5; // rbx
unsigned __int64 v6; // r12
unsigned __int8 v7; // r15
unsigned __int8 v8; // r14
int v9; // edi
__int64 result; // rax

while ( 1 )
{
v3 = a3;
v4 = a1;
if ( a2 >= a3 )
break;
v5 = a2;
v6 = a2 + (unsigned __int64)(unsigned __int8)(a3 - 1 - a2) + 1;
while ( 1 )
{
v7 = v5;
v8 = v5 + 1;
v9 = *(unsigned __int8 *)(*(_QWORD *)(v4 + 8) + v5);
if ( v9 == 1 )
break;
putchar(v9);
if ( v6 == ++v5 )
goto LABEL_7;
}
LABEL_5:
putchar(40);
regexp_print_subexpr(
v4,
(unsigned __int8)(v7 + 2),
(unsigned __int8)(v7 + *(_BYTE *)(*(_QWORD *)(v4 + 8) + v5 + 1)));
putchar(41);
putchar(42);
a3 = v3;
a1 = v4;
a2 = v7 + *(_BYTE *)(*(_QWORD *)(v4 + 8) + v5 + 1) + 1;
}
v8 = a2;
LABEL_7:
result = *(_QWORD *)(v4 + 8);
v5 = v8;
if ( *(_BYTE *)(result + v8) == 1 )
{
v7 = v8;
goto LABEL_5;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, unsigned __int8 a2, unsigned __int8 a3)
{
unsigned __int8 v3; // r13
__int64 v4; // rbp
__int64 v5; // rbx
unsigned __int64 v6; // r12
unsigned __int8 v7; // r15
unsigned __int8 v8; // r14
int v9; // edi
__int64 result; // rax

while ( 1 )
{
v3 = a3;
v4 = a1;
if ( a2 >= a3 )
break;
v5 = a2;
v6 = a2 + (unsigned __int64)(unsigned __int8)(a3 - 1 - a2) + 1;
while ( 1 )
{
v7 = v5;
v8 = v5 + 1;
v9 = *(unsigned __int8 *)(*(_QWORD *)(v4 + 8) + v5);
if ( v9 == 1 )
break;
putchar(v9);
if ( v6 == ++v5 )
goto LABEL_7;
}
LABEL_5:
putchar(40);
func4(
v4,
(unsigned __int8)(v7 + 2),
(unsigned __int8)(v7 + *(_BYTE *)(*(_QWORD *)(v4 + 8) + v5 + 1)));
putchar(41);
putchar(42);
a3 = v3;
a1 = v4;
a2 = v7 + *(_BYTE *)(*(_QWORD *)(v4 + 8) + v5 + 1) + 1;
}
v8 = a2;
LABEL_7:
result = *(_QWORD *)(v4 + 8);
v5 = v8;
if ( *(_BYTE *)(result + v8) == 1 )
{
v7 = v8;
goto LABEL_5;
}
return result;
}

original_code:
static void regexp_print_subexpr(regexp r, unsigned char start,
     unsigned char end) {
  while (start < end && r->expr[start] != STAR) {
    putchar(r->expr[start]);
    start++;
  }
  if (r->expr[start] == STAR) {
    putchar('(');
    regexp_print_subexpr(r, start + 2, start + r->expr[start + 1]);
    putchar(')');
    putchar('*');
    regexp_print_subexpr(r, start + r->expr[start+1] + 1, end);
  }
}

canonical_original_code:
static void regexp_print_subexpr(struct regexp_ *r, unsigned char start, unsigned char end) {
  while (start < end && r->expr[start] != STAR) {
    putchar(r->expr[start]);
    start++;
  }
  if (r->expr[start] == STAR) {
    putchar('(');
    regexp_print_subexpr(r, start + 2, start + r->expr[start + 1]);
    putchar(')');
    putchar('*');
    regexp_print_subexpr(r, start + r->expr[start+1] + 1, end);
  }
}

variable_types: struct regexp_ { unsigned char length; unsigned char *expr; unsigned char necessary[32]; } *

variable_types:
start
unsigned char

variable_types:
end
unsigned char


decompiled_code:
_BYTE *regexp_empty()
{
_BYTE *v0; // rax
_BYTE *v1; // r12
_BYTE *v2; // rax

v0 = regexp_calloc();
*v0 = 0;
v1 = v0;
v2 = regexp_alloc_str(1u);
*((_QWORD *)v1 + 1) = v2;
*v2 = 0;
return v1;
}

original_code:
regexp regexp_empty() {
  regexp result = regexp_calloc();
  result->length = 0;
  result->expr = regexp_alloc_str(1);
  result->expr[0] = 0;
  return result;
}

canonical_original_code:
struct regexp_ *regexp_empty() {
  struct regexp_ *result = regexp_calloc();
  result->length = 0;
  result->expr = regexp_alloc_str(1);
  result->expr[0] = 0;
  return result;
}

user_defined_types: struct regexp_ { unsigned char length; unsigned char *expr; unsigned char necessary[32]; }


decompiled_code:
__int64 __fastcall regexp_fast_disinclusion(__int64 a1, __int64 a2)
{
return 2 * (unsigned int)(memcmp((const void *)(a1 + 16), (const void *)(a2 + 16), 0x20uLL) > 0) - 1;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
return 2 * (unsigned int)(memcmp((const void *)(a1 + 16), (const void *)(a2 + 16), 0x20uLL) > 0) - 1;
}

original_code:
int regexp_fast_disinclusion(regexp r1, regexp r2) {
  if (memcmp(r1->necessary, r2->necessary, sizeof(unsigned char) * 32) > 0) {
    return 1;
  }
  return -1;
}

canonical_original_code:
int regexp_fast_disinclusion(struct regexp_ *r1, struct regexp_ *r2) {
  if (memcmp(r1->necessary, r2->necessary, sizeof(unsigned char) * 32) > 0) {
    return 1;
  }
  return -1;
}


decompiled_code:
int __fastcall regexp_print_expr(unsigned __int8 *a1)
{
regexp_print_subexpr((__int64)a1, 0, *a1);
return fflush(stdout);
}

canonical_decompiled_code:
int __fastcall func10(unsigned __int8 *a1)
{
func4((__int64)a1, 0, *a1);
return fflush(stdout);
}

original_code:
void regexp_print_expr(regexp r) {
  regexp_print_subexpr(r, 0, r->length);
  fflush(stdout);
}

canonical_original_code:
void regexp_print_expr(struct regexp_ *r) {
  regexp_print_subexpr(r, 0, r->length);
  fflush(stdout);
}


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

v1 = 0LL;
printf("Necessary characters in %s:\n", *(const char **)(a1 + 8));
do
{
while ( 1 )
{
v2 = v1++;
v3 = bfx(a1 + 16, v1, 1LL);
if ( v3 )
break;
if ( v1 == 256 )
return v3;
}
LODWORD(v3) = printf("%c (%d) \n", v2, v2);
}
while ( v1 != 256 );
return v3;
}

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

v1 = 0LL;
printf("Necessary characters in %s:\n", *(const char **)(a1 + 8));
do
{
while ( 1 )
{
v2 = v1++;
v3 = bfx(a1 + 16, v1, 1LL);
if ( v3 )
break;
if ( v1 == 256 )
return v3;
}
LODWORD(v3) = printf("%c (%d) \n", v2, v2);
}
while ( v1 != 256 );
return v3;
}

original_code:
void regexp_print_necessary(regexp r) {
  int i;
  printf("Necessary characters in %s:\n", r->expr);
  for (i = 0; i < 256; i++) {
    if (bfx(r->necessary, i+1, 1)) {
      printf("%c (%d) \n",i, i);
    }
  }
}

canonical_original_code:
void regexp_print_necessary(struct regexp_ *r) {
  int i;
  printf("Necessary characters in %s:\n", r->expr);
  for (i = 0; i < 256; i++) {
    if (bfx(r->necessary, i+1, 1)) {
      printf("%c (%d) \n",i, i);
    }
  }
}

variable_types: i int


member

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

LODWORD(result) = *(_DWORD *)(a1 + 4LL * a3);
if ( !(_DWORD)result )
return 0LL;
while ( a4 != (_DWORD)result )
{
a3 = a2 & (a3 + 5189);
result = *(unsigned int *)(a1 + 4LL * a3);
if ( !(_DWORD)result )
return result;
}
return 1LL;
}

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

LODWORD(result) = *(_DWORD *)(a1 + 4LL * a3);
if ( !(_DWORD)result )
return 0LL;
while ( a4 != (_DWORD)result )
{
a3 = a2 & (a3 + 5189);
result = *(unsigned int *)(a1 + 4LL * a3);
if ( !(_DWORD)result )
return result;
}
return 1LL;
}

original_code:
static bool member(int *table, int ub, int i, int value)
{
  while (table[i] != empty_key)
    {
      if (table[i] == value)
 return 1;
      else
 i = ub & (i + prime_2);
    }
  return 0;
}

canonical_original_code:
static unsigned char member(int *table, int ub, int i, int value)
{
  while (table[i] != empty_key)
    {
      if (table[i] == value)
 return 1;
      else
 i = ub & (i + prime_2);
    }
  return 0;
}

variable_types:
table
int *

variable_types: ub int

variable_types: value int


reinsert

decompiled_code:
__int64 __fastcall reinsert(__int64 a1, int a2, int a3)
{
int i; // eax
__int64 result; // rax
_DWORD *v5; // rcx

for ( i = 83 * a3; ; i = result + 5189 )
{
result = a2 & (unsigned int)i;
v5 = (_DWORD *)(a1 + 4LL * (int)result);
if ( !*v5 )
break;
if ( a3 == *v5 )
return result;
}
*v5 = a3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2, int a3)
{
int i; // eax
__int64 result; // rax
_DWORD *v5; // rcx

for ( i = 83 * a3; ; i = result + 5189 )
{
result = a2 & (unsigned int)i;
v5 = (_DWORD *)(a1 + 4LL * (int)result);
if ( !*v5 )
break;
if ( a3 == *v5 )
return result;
}
*v5 = a3;
return result;
}

original_code:
static inline void reinsert(int *table, int ub, int value)
{
  int i;
  i = ub & (prime_1 * value);
  while (table[i] != empty_key)
    {
      if (table[i] == value)
 return;
      else
 i = ub & (i + prime_2);
    }
  table[i] = value;
}


decompiled_code:
__int64 __fastcall member_or_insert(__int64 a1, int a2, int a3, int a4)
{
_DWORD *v6; // rcx

while ( 1 )
{
v6 = (_DWORD *)(a1 + 4LL * a3);
if ( !*v6 )
{
*v6 = a4;
return 0LL;
}
if ( a4 == *v6 )
break;
a3 = a2 & (a3 + 5189);
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2, int a3, int a4)
{
_DWORD *v6; // rcx

while ( 1 )
{
v6 = (_DWORD *)(a1 + 4LL * a3);
if ( !*v6 )
{
*v6 = a4;
return 0LL;
}
if ( a4 == *v6 )
break;
a3 = a2 & (a3 + 5189);
}
return 1LL;
}

original_code:
static bool member_or_insert(int *table, int ub, int i, int value)
{
  while (table[i] != empty_key)
    {
      if (table[i] == value)
 return 1;
      else
 i = ub & (i + prime_2);
    }
  table[i] = value;
  return 0;
}

canonical_original_code:
static unsigned char member_or_insert(int *table, int ub, int i, int value)
{
  while (table[i] != empty_key)
    {
      if (table[i] == value)
 return 1;
      else
 i = ub & (i + prime_2);
    }
  table[i] = value;
  return 0;
}


rehash

original_code:
static void rehash(hash_set hs)
{
  int *old_table;
  int old_capacity, i;
  old_table = hs->table;
  old_capacity = hs->capacity;
  hs->capacity *= 2;
  hs->ub = ((1<<++hs->size)-1);
  hs->table = (int *)calloc(hs->capacity, sizeof(int));
  ((void) (0));
  for (i = 0; i < old_capacity; i++)
    {
      reinsert(hs->table, hs->ub, old_table[i]);
    }
  free(old_table);
}

canonical_original_code:
static void rehash(struct hash_set *hs)
{
  int *old_table;
  int old_capacity; int i;
  old_table = hs->table;
  old_capacity = hs->capacity;
  hs->capacity *= 2;
  hs->ub = ((1<<++hs->size)-1);
  hs->table = (int *)calloc(hs->capacity, sizeof(int));
  ((void) (0));
  for (i = 0; i < old_capacity; i++)
    {
      reinsert(hs->table, hs->ub, old_table[i]);
    }
  free(old_table);
}

variable_types: struct hash_set { int *table; unsigned int ub; unsigned int capacity; unsigned int inserts; unsigned int size; } *


original_code:
static void post_insert(hash_set hs)
{
  int capacity = hs->capacity;
  int inserts = ++hs->inserts;
  float percent_capacity = capacity * .85;
  if ( (float) inserts >= percent_capacity)
    {
      rehash(hs);
    }
}

canonical_original_code:
static void post_insert(struct hash_set *hs)
{
  int capacity = hs->capacity;
  int inserts = ++hs->inserts;
  float percent_capacity = capacity * .85;
  if ( (float) inserts >= percent_capacity)
    {
      rehash(hs);
    }
}

variable_types: capacity int

variable_types: inserts int

user_defined_types: struct hash_set { int *table; unsigned int ub; unsigned int capacity; unsigned int inserts; unsigned int size; }


decompiled_code:
__int64 __fastcall hs_num_items(__int64 a1)
{
return *(unsigned int *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
return *(unsigned int *)(a1 + 16);
}

original_code:
int hs_num_items(hash_set hs)
{
  return hs->inserts;
}

canonical_original_code:
int hs_num_items(struct hash_set *hs)
{
  return hs->inserts;
}


decompiled_code:
__int64 __fastcall hs_list_items(__int64 a1)
{
return *(_QWORD *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
return *(_QWORD *)a1;
}

original_code:
int *hs_list_items(hash_set hs)
{
  return hs->table;
}

canonical_original_code:
int *hs_list_items(struct hash_set *hs)
{
  return hs->table;
}

return_type: int *


original_code:
bool hs_query(hash_set hs, int entry)
{
  int hash;
  int ub = hs->ub;
  hash = ub & (prime_1 * abs(entry));
  return member(hs->table, ub, hash, entry);
}

canonical_original_code:
unsigned char hs_query(struct hash_set *hs, int entry)
{
  int hash;
  int ub = hs->ub;
  hash = ub & (prime_1 * abs(entry));
  return member(hs->table, ub, hash, entry);
}

variable_types: entry int

variable_types: hash int


decompiled_code:
__int64 __fastcall hs_member(__int64 a1, int a2)
{
__int64 v2; // r9

if ( (unsigned __int8)member_or_insert(*(_QWORD *)a1, *(_DWORD *)(a1 + 8), *(_DWORD *)(a1 + 8) & (83 * abs32(a2)), a2) )
return 1LL;
post_insert(v2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, int a2)
{
__int64 v2; // r9

if ( (unsigned __int8)func2(*(_QWORD *)a1, *(_DWORD *)(a1 + 8), *(_DWORD *)(a1 + 8) & (83 * abs32(a2)), a2) )
return 1LL;
func4(v2);
return 0LL;
}

original_code:
bool hs_member(hash_set hs, int entry)
{
  int hash;
  int ub = hs->ub;
  hash = ub & (prime_1 * abs(entry));
  if (member_or_insert(hs->table, ub, hash, entry))
    return 1;
  else
    {
      post_insert(hs);
      return 0;
    }
}

canonical_original_code:
unsigned char hs_member(struct hash_set *hs, int entry)
{
  int hash;
  int ub = hs->ub;
  hash = ub & (prime_1 * abs(entry));
  if (member_or_insert(hs->table, ub, hash, entry))
    return 1;
  else
    {
      post_insert(hs);
      return 0;
    }
}


decompiled_code:
void __fastcall hs_delete(void **a1)
{
free(*a1);
}

canonical_decompiled_code:
void __fastcall func10(void **a1)
{
free(*a1);
}

original_code:
void hs_delete(hash_set hs)
{
  free(hs->table);
}

canonical_original_code:
void hs_delete(struct hash_set *hs)
{
  free(hs->table);
}


decompiled_code:
__int64 bounds_init()
{
__int64 result; // rax

added_edge_info_region = newregion();
result = newregion();
bounds_region = result;
return result;
}

canonical_decompiled_code:
__int64 func19()
{
__int64 result; // rax

added_edge_info_region = newregion();
result = newregion();
bounds_region = result;
return result;
}

original_code:
void bounds_init()
{
  added_edge_info_region = newregion();
  bounds_region = newregion();
}


decompiled_code:
__int64 bounds_reset()
{
deleteregion(bounds_region);
deleteregion(added_edge_info_region);
return bounds_init();
}

canonical_decompiled_code:
__int64 func20()
{
deleteregion(bounds_region);
deleteregion(added_edge_info_region);
return func19();
}

original_code:
void bounds_reset()
{
  deleteregion(bounds_region);
  deleteregion(added_edge_info_region);
  bounds_init();
}


decompiled_code:
__int64 __fastcall tv_combine(__int64 a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return a1;
}

original_code:
static gen_e tv_combine(const gen_e e1,const gen_e e2)
{
  return e1;
}

canonical_original_code:
static struct gen_e_ *tv_combine(struct gen_e_ *e1, struct gen_e_ *e2)
{
  return e1;
}

return_type: struct gen_e_ { enum sort_kind { flowrow_sort=0, setif_sort=1, setst_sort=2, term_sort=3 } sort; } *


decompiled_code:
__int64 is_empty_annotation()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func1()
{
return 1LL;
}

original_code:
bool is_empty_annotation(annotation a) {
  return 1;
}

canonical_original_code:
unsigned char is_empty_annotation(struct annotation_ *a) {
  return 1;
}

variable_types:
a
struct annotation_ {  } *


decompiled_code:
__int64 get_empty_annotation()
{
return 0LL;
}

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

original_code:
annotation get_empty_annotation(void) {
  return ((void *)0);
}

canonical_original_code:
struct annotation_ *get_empty_annotation() {
  return ((void *)0);
}

return_type: struct annotation_ {  } *


decompiled_code:
__int64 concat_annotation()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func3()
{
return 0LL;
}

original_code:
annotation concat_annotation(annotation a1, annotation a2) {
  return ((void *)0);
}

canonical_original_code:
struct annotation_ *concat_annotation(struct annotation_ *a1, struct annotation_ *a2) {
  return ((void *)0);
}


decompiled_code:
__int64 star_annotation()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func4()
{
return 0LL;
}

original_code:
annotation star_annotation(annotation a) {
  return ((void *)0);
}

canonical_original_code:
struct annotation_ *star_annotation(struct annotation_ *a) {
  return ((void *)0);
}

variable_types:
a
struct annotation_ *


decompiled_code:
__int64 subsumed_by_annotation()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func5()
{
return 1LL;
}

original_code:
bool subsumed_by_annotation(annotation a1, annotation a2) {
  return 1;
}

canonical_original_code:
unsigned char subsumed_by_annotation(struct annotation_ *a1, struct annotation_ *a2) {
  return 1;
}


decompiled_code:
void print_annotation()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code:
void print_annotation(annotation a) {
}

canonical_original_code:
void print_annotation(struct annotation_ *a) {
}


bfi

decompiled_code:
unsigned __int64 __fastcall bfi(__int64 a1, __int64 a2, char a3, __int64 a4)
{
unsigned __int64 v4; // rsi
char v5; // dl
unsigned __int64 result; // rax

v4 = a2 - 1;
v5 = (v4 & 0xF8) - a3 + 32 - v4;
result = (unsigned __int64)(0xFFFFFFFFLL << v5 << ((unsigned __int8)v4 - ((unsigned __int8)v4 & 0xF8u))) >> ((unsigned __int8)v4 - ((unsigned __int8)v4 & 0xF8u));
*(_DWORD *)(a1 + (v4 >> 3)) ^= result & (*(_DWORD *)(a1 + (v4 >> 3)) ^ (a4 << v5));
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(__int64 a1, __int64 a2, char a3, __int64 a4)
{
unsigned __int64 v4; // rsi
char v5; // dl
unsigned __int64 result; // rax

v4 = a2 - 1;
v5 = (v4 & 0xF8) - a3 + 32 - v4;
result = (unsigned __int64)(0xFFFFFFFFLL << v5 << ((unsigned __int8)v4 - ((unsigned __int8)v4 & 0xF8u))) >> ((unsigned __int8)v4 - ((unsigned __int8)v4 & 0xF8u));
*(_DWORD *)(a1 + (v4 >> 3)) ^= result & (*(_DWORD *)(a1 + (v4 >> 3)) ^ (a4 << v5));
return result;
}

original_code:
void
bfi(unsigned char *cptr, unsigned long bit_offset, unsigned long bit_len, long value)
{
   unsigned long l;
   unsigned long mask = 0xffffffff;
   unsigned long byte_offset;
   unsigned long pre_shift;
   unsigned long post_shift;
   byte_offset = (bit_offset-1)/8;
   pre_shift = bit_offset - byte_offset*8 - 1;
   post_shift = 32 - bit_len - pre_shift;
   value <<= post_shift;
   mask <<= post_shift;
   mask <<= pre_shift;
   mask >>= pre_shift;
   value &= mask;
   memmove((unsigned char *)&l, &cptr[byte_offset], 4);
   l = (l & (~mask)) | value;
   memmove(&cptr[byte_offset], (unsigned char *)&l, 4);
}

variable_types:
cptr
unsigned char *

variable_types: value long

variable_types:
l
unsigned long

variable_types:
mask
unsigned long


bfx

original_code:
unsigned long
bfx(const unsigned char *cptr, unsigned long bit_offset, unsigned long bit_len)
{
   unsigned long l;
   unsigned long byte_offset;
   unsigned long left_shift;
   unsigned long right_shift;
   byte_offset = (bit_offset-1)/8;
   left_shift = bit_offset - byte_offset*8 - 1;
   right_shift = 32 - bit_len;
   memmove((unsigned char *)&l, &cptr[byte_offset], 4);
   return ( l << left_shift ) >> right_shift;
}

canonical_original_code:
unsigned long bfx(unsigned char *cptr, unsigned long bit_offset, unsigned long bit_len)
{
   unsigned long l;
   unsigned long byte_offset;
   unsigned long left_shift;
   unsigned long right_shift;
   byte_offset = (bit_offset-1)/8;
   left_shift = bit_offset - byte_offset*8 - 1;
   right_shift = 32 - bit_len;
   memmove((unsigned char *)&l, &cptr[byte_offset], 4);
   return ( l << left_shift ) >> right_shift;
}


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

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

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

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

original_code:
void dd_remove(dd_list_pos what)
{
  what->previous->next = what->next;
  what->next->previous = what->previous;
  what->next = what->previous = ((void *)0);
  what->data = ((void *)0);
}

canonical_original_code:
void dd_remove(struct dd_list_pos *what)
{
  what->previous->next = what->next;
  what->next->previous = what->previous;
  what->next = what->previous = ((void *)0);
  what->data = ((void *)0);
}

variable_types: struct dd_list_pos { struct dd_list_pos *next; struct dd_list_pos *previous; void *data; } *


decompiled_code:
__int64 __fastcall dd_first(__int64 a1)
{
return *(_QWORD *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return *(_QWORD *)a1;
}

original_code:
dd_list_pos dd_first(dd_list l)
{
  return l->first;
}

canonical_original_code:
struct dd_list_pos *dd_first(struct dd_list *l)
{
  return l->first;
}

variable_types: struct dd_list { struct dd_list_pos *first; struct dd_list_pos *null; struct dd_list_pos *last; } *

return_type: struct dd_list_pos { struct dd_list_pos *next; struct dd_list_pos *previous; void *data; } *


decompiled_code:
__int64 __fastcall dd_last(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

original_code:
dd_list_pos dd_last(dd_list l)
{
  return l->last;
}

canonical_original_code:
struct dd_list_pos *dd_last(struct dd_list *l)
{
  return l->last;
}

user_defined_types: struct dd_list { struct dd_list_pos *first; struct dd_list_pos *null; struct dd_list_pos *last; }

user_defined_types: struct dd_list_pos { struct dd_list_pos *next; struct dd_list_pos *previous; void *data; }


decompiled_code:
__int64 __fastcall dd_length(__int64 a1)
{
_QWORD **v1; // rax
__int64 v2; // r8
_QWORD *i; // rax

v1 = (_QWORD **)dd_first(a1);
v2 = 0LL;
for ( i = *v1; i; ++v2 )
i = (_QWORD *)*i;
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
_QWORD **v1; // rax
__int64 v2; // r8
_QWORD *i; // rax

v1 = (_QWORD **)func1(a1);
v2 = 0LL;
for ( i = *v1; i; ++v2 )
i = (_QWORD *)*i;
return v2;
}

original_code:
unsigned long dd_length(dd_list l)
{
  dd_list_pos scan;
  unsigned long len = 0;
  for (scan = dd_first((l)); !(!(scan)->next); scan = ((scan)->next)) len++;
  return len;
}

canonical_original_code:
unsigned long dd_length(struct dd_list *l)
{
  struct dd_list_pos *scan;
  unsigned long len = 0;
  for (scan = dd_first((l)); !(!(scan)->next); scan = ((scan)->next)) len++;
  return len;
}

variable_types: struct dd_list { struct dd_list_pos { struct dd_list_pos *next; struct dd_list_pos *previous; void *data; } *first; struct dd_list_pos *null; struct dd_list_pos *last; } *

variable_types:
len
unsigned long


decompiled_code:
__int64 __fastcall jcoll_accum(__int64 a1)
{
return gen_e_list_cons(a1, jf_accum);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return gen_e_list_cons(a1, jf_accum);
}

original_code:
static void jcoll_accum(void *e) {
 gen_e_list_cons((gen_e) e, jf_accum);
}

canonical_original_code:
static void jcoll_accum(void *e) {
 gen_e_list_cons((struct gen_e_ *) e, jf_accum);
}

variable_types:
e
void *

user_defined_types: enum sort_kind { flowrow_sort=0, setif_sort=1, setst_sort=2, term_sort=3 }


decompiled_code:
__int64 banshee_region_persistence_init()
{
__int64 result; // rax

region_init();
banshee_ptr_region = newregion();
banshee_nonptr_region = newregion();
result = make_hash_table(permanent, 32LL, &ptr_hash, &ptr_eq);
extra_regions = result;
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax

region_init();
banshee_ptr_region = newregion();
banshee_nonptr_region = newregion();
result = make_hash_table(permanent, 32LL, &ptr_hash, &ptr_eq);
extra_regions = result;
return result;
}

original_code:
void banshee_region_persistence_init()
{
  region_init();
  banshee_ptr_region = newregion();
  banshee_nonptr_region = newregion();
  extra_regions = make_hash_table(permanent, 32, ptr_hash, ptr_eq);
}


freeToken

decompiled_code:
void __fastcall freeToken(void **a1)
{
void *v2; // rdi
void **v3; // rbx

v2 = *a1;
if ( v2 )
{
v3 = a1 + 1;
do
{
free(v2);
v2 = *v3++;
}
while ( v2 );
}
}

canonical_decompiled_code:
void __fastcall func0(void **a1)
{
void *v2; // rdi
void **v3; // rbx

v2 = *a1;
if ( v2 )
{
v3 = a1 + 1;
do
{
free(v2);
v2 = *v3++;
}
while ( v2 );
}
}

original_code:
void freeToken(char **arr)
{
 int i = 0;
 while (arr[i] != ((void *)0))
  {
   free(arr[i]);
   i++;
  }
}

variable_types:
arr
char **

variable_types: i int


freeCommands

decompiled_code:
void __fastcall freeCommands(void ***a1)
{
void **v1; // rbx
void **v2; // rdi
void *v3; // rdi

v1 = (void **)a1;
v2 = *a1;
if ( v2 )
{
do
{
freeToken(v2);
v3 = *v1++;
free(v3);
v2 = (void **)*v1;
}
while ( *v1 );
}
}

canonical_decompiled_code:
void __fastcall func1(void ***a1)
{
void **v1; // rbx
void **v2; // rdi
void *v3; // rdi

v1 = (void **)a1;
v2 = *a1;
if ( v2 )
{
do
{
func0(v2);
v3 = *v1++;
free(v3);
v2 = (void **)*v1;
}
while ( *v1 );
}
}

original_code:
void freeCommands(char ***arr)
{
 int i = 0;
 while (arr[i] != ((void *)0))
 {
  freeToken(arr[i]);
  free(arr[i]);
 i++;
 }
}

variable_types:
arr
char ***


runpause

decompiled_code:
int __fastcall runpause(__int64 a1, __int64 a2, int a3)
{
__int64 v3; // rax
const char *v4; // rdi
int result; // eax
unsigned int v6; // ebp
__int64 v7; // rax
__int64 v8; // rbx
int *v9; // rax
char *v10; // rax

v3 = *(_QWORD *)(a1 + 8LL * a3);
v4 = *(const char **)(v3 + 8);
if ( !v4 )
return puts("Error: \"pause\" needs one parameter!");
if ( *(_QWORD *)(v3 + 16) )
return puts("Error: \"pause\" has only one parameter!");
v6 = atol(v4);
v7 = findchild(v6, a2);
v8 = v7;
if ( !v7 )
return puts("Error: In \"pause,\" unable to find process!");
if ( !*(_DWORD *)(v7 + 4) )
return puts("Error: Process already paused!");
result = kill(v6, 19);
if ( result )
{
if ( result < 0 )
{
v9 = _errno_location();
v10 = strerror(*v9);
printf("Pause failed: %s\n", v10);
exit(1);
}
}
else
{
*(_DWORD *)(v8 + 4) = 0;
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, __int64 a2, int a3)
{
__int64 v3; // rax
const char *v4; // rdi
int result; // eax
unsigned int v6; // ebp
__int64 v7; // rax
__int64 v8; // rbx
int *v9; // rax
char *v10; // rax

v3 = *(_QWORD *)(a1 + 8LL * a3);
v4 = *(const char **)(v3 + 8);
if ( !v4 )
return puts("Error: \"pause\" needs one parameter!");
if ( *(_QWORD *)(v3 + 16) )
return puts("Error: \"pause\" has only one parameter!");
v6 = atol(v4);
v7 = findchild(v6, a2);
v8 = v7;
if ( !v7 )
return puts("Error: In \"pause,\" unable to find process!");
if ( !*(_DWORD *)(v7 + 4) )
return puts("Error: Process already paused!");
result = kill(v6, 19);
if ( result )
{
if ( result < 0 )
{
v9 = _errno_location();
v10 = strerror(*v9);
printf("Pause failed: %s\n", v10);
exit(1);
}
}
else
{
*(_DWORD *)(v8 + 4) = 0;
}
return result;
}

original_code:
void runpause(char *** commands, struct jobnode **jobs, int i)
{
 if (commands[i][1] == ((void *)0))
 {
  printf("%s\n", "Error: \"pause\" needs one parameter!");
 }
 else if (commands[i][2] != ((void *)0))
 {
  printf("%s\n", "Error: \"pause\" has only one parameter!");
 }
 else
 {
  int pausetarget = atol(commands[i][1]);
  struct jobnode *paused = findchild(pausetarget, jobs);
  if (paused == ((void *)0))
  {
   printf("%s\n", "Error: In \"pause,\" unable to find process!");
  }
  else
  {
   if (paused->running == 0)
   {
    printf("%s\n", "Error: Process already paused!");
   }
   else
   {
   int killresult = kill(pausetarget, 19);
   if (killresult == 0)
   {
    paused->running = 0;
   }
   else if(killresult < 0)
    {
     printf("Pause failed: %s\n", strerror((*__errno_location ())));
     exit(1);
    }
   }
  }
 }
}

canonical_original_code:
void runpause(char ***commands, struct jobnode **jobs, int i)
{
 if (commands[i][1] == ((void *)0))
 {
  printf("%s\n", "Error: \"pause\" needs one parameter!");
 }
 else if (commands[i][2] != ((void *)0))
 {
  printf("%s\n", "Error: \"pause\" has only one parameter!");
 }
 else
 {
  int pausetarget = atol(commands[i][1]);
  struct jobnode *paused = findchild(pausetarget, jobs);
  if (paused == ((void *)0))
  {
   printf("%s\n", "Error: In \"pause,\" unable to find process!");
  }
  else
  {
   if (paused->running == 0)
   {
    printf("%s\n", "Error: Process already paused!");
   }
   else
   {
   int killresult = kill(pausetarget, 19);
   if (killresult == 0)
   {
    paused->running = 0;
   }
   else if(killresult < 0)
    {
     printf("Pause failed: %s\n", strerror((*__errno_location ())));
     exit(1);
    }
   }
  }
 }
}

variable_types:
commands
char ***

variable_types: struct jobnode { int pid; int running; char **command; struct jobnode *next; } **

variable_types: pausetarget int

variable_types: killresult int


resume

decompiled_code:
int __fastcall resume(__int64 a1, __int64 a2, int a3)
{
__int64 v3; // rax
const char *v4; // rdi
int result; // eax
unsigned int v6; // ebp
__int64 v7; // rax
__int64 v8; // rbx
int *v9; // rax
char *v10; // rax

v3 = *(_QWORD *)(a1 + 8LL * a3);
v4 = *(const char **)(v3 + 8);
if ( !v4 )
return puts("Error: \"resume\" needs one parameter!");
if ( *(_QWORD *)(v3 + 16) )
return puts("Error: \"resume\" has only one parameter!");
v6 = atol(v4);
v7 = findchild(v6, a2);
v8 = v7;
if ( !v7 )
return puts("Error: In \"resume,\" unable to find process!");
if ( *(_DWORD *)(v7 + 4) == 1 )
return puts("Error: Process already running!");
result = kill(v6, 18);
if ( result )
{
if ( result < 0 )
{
v9 = _errno_location();
v10 = strerror(*v9);
printf("Resume failed: %s\n", v10);
exit(1);
}
}
else
{
*(_DWORD *)(v8 + 4) = 1;
}
return result;
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1, __int64 a2, int a3)
{
__int64 v3; // rax
const char *v4; // rdi
int result; // eax
unsigned int v6; // ebp
__int64 v7; // rax
__int64 v8; // rbx
int *v9; // rax
char *v10; // rax

v3 = *(_QWORD *)(a1 + 8LL * a3);
v4 = *(const char **)(v3 + 8);
if ( !v4 )
return puts("Error: \"resume\" needs one parameter!");
if ( *(_QWORD *)(v3 + 16) )
return puts("Error: \"resume\" has only one parameter!");
v6 = atol(v4);
v7 = findchild(v6, a2);
v8 = v7;
if ( !v7 )
return puts("Error: In \"resume,\" unable to find process!");
if ( *(_DWORD *)(v7 + 4) == 1 )
return puts("Error: Process already running!");
result = kill(v6, 18);
if ( result )
{
if ( result < 0 )
{
v9 = _errno_location();
v10 = strerror(*v9);
printf("Resume failed: %s\n", v10);
exit(1);
}
}
else
{
*(_DWORD *)(v8 + 4) = 1;
}
return result;
}

original_code:
void resume(char *** commands, struct jobnode **jobs, int i)
{
 if (commands[i][1] == ((void *)0))
 {
  printf("%s\n", "Error: \"resume\" needs one parameter!");
 }
 else if (commands[i][2] != ((void *)0))
 {
  printf("%s\n", "Error: \"resume\" has only one parameter!");
 }
 else
 {
  int resumetarget = atol(commands[i][1]);
  struct jobnode *resume = findchild(resumetarget, jobs);
  if (resume == ((void *)0))
  {
   printf("%s\n", "Error: In \"resume,\" unable to find process!");
  }
  else
  {
   if (resume->running == 1)
   {
    printf("%s\n", "Error: Process already running!");
   }
   else
   {
    int killresult = kill(resumetarget, 18);
    if (killresult == 0)
    {
     resume->running = 1;
    }
    else if(killresult < 0)
    {
     printf("Resume failed: %s\n", strerror((*__errno_location ())));
     exit(1);
    }
   }
  }
 }
}

canonical_original_code:
void resume(char ***commands, struct jobnode **jobs, int i)
{
 if (commands[i][1] == ((void *)0))
 {
  printf("%s\n", "Error: \"resume\" needs one parameter!");
 }
 else if (commands[i][2] != ((void *)0))
 {
  printf("%s\n", "Error: \"resume\" has only one parameter!");
 }
 else
 {
  int resumetarget = atol(commands[i][1]);
  struct jobnode *resume = findchild(resumetarget, jobs);
  if (resume == ((void *)0))
  {
   printf("%s\n", "Error: In \"resume,\" unable to find process!");
  }
  else
  {
   if (resume->running == 1)
   {
    printf("%s\n", "Error: Process already running!");
   }
   else
   {
    int killresult = kill(resumetarget, 18);
    if (killresult == 0)
    {
     resume->running = 1;
    }
    else if(killresult < 0)
    {
     printf("Resume failed: %s\n", strerror((*__errno_location ())));
     exit(1);
    }
   }
  }
 }
}

variable_types: resumetarget int

variable_types: struct jobnode { int pid; int running; char **command; struct jobnode *next; } *


modefun

decompiled_code:
int __fastcall modefun(__int64 a1, int *a2)
{
int result; // eax
const char *v3; // rbp
const char *v4; // rdx
size_t v5; // r12

result = *a2;
if ( *a2 != 2 )
{
v3 = *(const char **)(a1 + 8);
if ( v3 )
{
v4 = "Too many parameters, mode only allows one.";
if ( *(_QWORD *)(a1 + 16) )
return fprintf(stderr, "%s\n", v4);
v5 = strlen(*(const char **)(a1 + 8));
result = strncasecmp("parallel", v3, v5);
if ( result )
{
result = strncasecmp("sequential", v3, v5);
if ( result )
{
v4 = "Incorrect mode specified, please only use parallel or sequential. Thank you.";
return fprintf(stderr, "%s\n", v4);
}
*a2 = 1;
}
else
{
*a2 = 0;
}
}
else if ( result )
{
result = puts("sequential mode");
}
else
{
result = puts("parallel mode");
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1, int *a2)
{
int result; // eax
const char *v3; // rbp
const char *v4; // rdx
size_t v5; // r12

result = *a2;
if ( *a2 != 2 )
{
v3 = *(const char **)(a1 + 8);
if ( v3 )
{
v4 = "Too many parameters, mode only allows one.";
if ( *(_QWORD *)(a1 + 16) )
return fprintf(stderr, "%s\n", v4);
v5 = strlen(*(const char **)(a1 + 8));
result = strncasecmp("parallel", v3, v5);
if ( result )
{
result = strncasecmp("sequential", v3, v5);
if ( result )
{
v4 = "Incorrect mode specified, please only use parallel or sequential. Thank you.";
return fprintf(stderr, "%s\n", v4);
}
*a2 = 1;
}
else
{
*a2 = 0;
}
}
else if ( result )
{
result = puts("sequential mode");
}
else
{
result = puts("parallel mode");
}
}
return result;
}

original_code:
void modefun(char **commands, int *sequential)
{
 if((*sequential) != 2)
 {
  if(commands[1] == ((void *)0))
  {
   if((*sequential))
   {
    printf("%s\n","sequential mode");
   }
   else
   {
    printf("%s\n", "parallel mode");
   }
  }
  else if(commands[2] == ((void *)0))
  {
   if(strncasecmp("parallel", commands[1], strlen(commands[1])) == 0)
   {
    (*sequential) = 0;
   }
   else if(strncasecmp("sequential",commands[1], strlen(commands[1])) == 0)
   {
    (*sequential) = 1;
   }
   else
   {
    fprintf(stderr, "%s\n", "Incorrect mode specified, please only use parallel or sequential. Thank you.");
   }
  }
  else
  {
   fprintf(stderr, "%s\n", "Too many parameters, mode only allows one.");
  }
 }
}

variable_types:
commands
char **

variable_types:
sequential
int *


runSequential

decompiled_code:
void __fastcall runSequential(const char ***a1, int *a2, _QWORD *a3)
{
const char **v3; // rbp
const char ***v6; // r14
bool v7; // al
bool v8; // cf
bool v9; // zf
const char *v10; // rdi
__int64 v11; // rcx
const char *v12; // rsi
int v13; // eax
int *v14; // rax
char *v15; // rdx
int *v16; // rax
char *v17; // rax
int *v18; // rax
char *v19; // rdx
int stat_loc[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v3 = *a1;
if ( *a1 )
{
v6 = a1 + 1;
while ( 1 )
{
if ( !strcmp(*v3, "exit") )
{
if ( v3[1] )
puts("Error: \"exit\" has no parameters!");
else
*a2 = 2;
goto LABEL_5;
}
v7 = strcmp(*v3, "mode") != 0;
v8 = 0;
v9 = !v7;
if ( !v7 )
break;
v10 = "jobs";
v11 = 5LL;
v12 = *v3;
do
{
if ( !v11 )
break;
v8 = *v12 < (unsigned int)*v10;
v9 = *v12++ == *v10++;
--v11;
}
while ( v9 );
if ( (!v8 && !v9) == v8 )
{
if ( !v3[1] )
{
jobs_print(*a3, v12, *v3, v11);
goto LABEL_5;
}
++v6;
puts("Error: \"jobs\" has no parameters!");
v3 = *(v6 - 1);
if ( !v3 )
return;
}
else
{
v13 = fork();
if ( v13 )
{
if ( v13 <= 0 )
{
v18 = _errno_location();
v19 = strerror(*v18);
fprintf(stderr, "Fork failed: %s\n", v19);
LABEL_25:
exit(1);
}
if ( waitpid(v13, stat_loc, 0) == -1 )
{
v14 = _errno_location();
v15 = strerror(*v14);
fprintf(stderr, "Wait failed: %s\n", v15);
goto LABEL_25;
}
}
else if ( execv(*v3, (char *const *)v3) < 0 )
{
v16 = _errno_location();
v17 = strerror(*v16);
printf("Execv of \"%s\" failed: %s\n", *v3, v17);
exit(1);
}
LABEL_5:
v3 = *v6++;
if ( !v3 )
return;
}
}
modefun((__int64)v3, a2);
goto LABEL_5;
}
}

canonical_decompiled_code:
void __fastcall func3(const char ***a1, int *a2, _QWORD *a3)
{
const char **v3; // rbp
const char ***v6; // r14
bool v7; // al
bool v8; // cf
bool v9; // zf
const char *v10; // rdi
__int64 v11; // rcx
const char *v12; // rsi
int v13; // eax
int *v14; // rax
char *v15; // rdx
int *v16; // rax
char *v17; // rax
int *v18; // rax
char *v19; // rdx
int stat_loc[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v3 = *a1;
if ( *a1 )
{
v6 = a1 + 1;
while ( 1 )
{
if ( !strcmp(*v3, "exit") )
{
if ( v3[1] )
puts("Error: \"exit\" has no parameters!");
else
*a2 = 2;
goto LABEL_5;
}
v7 = strcmp(*v3, "mode") != 0;
v8 = 0;
v9 = !v7;
if ( !v7 )
break;
v10 = "jobs";
v11 = 5LL;
v12 = *v3;
do
{
if ( !v11 )
break;
v8 = *v12 < (unsigned int)*v10;
v9 = *v12++ == *v10++;
--v11;
}
while ( v9 );
if ( (!v8 && !v9) == v8 )
{
if ( !v3[1] )
{
jobs_print(*a3, v12, *v3, v11);
goto LABEL_5;
}
++v6;
puts("Error: \"jobs\" has no parameters!");
v3 = *(v6 - 1);
if ( !v3 )
return;
}
else
{
v13 = fork();
if ( v13 )
{
if ( v13 <= 0 )
{
v18 = _errno_location();
v19 = strerror(*v18);
fprintf(stderr, "Fork failed: %s\n", v19);
LABEL_25:
exit(1);
}
if ( waitpid(v13, stat_loc, 0) == -1 )
{
v14 = _errno_location();
v15 = strerror(*v14);
fprintf(stderr, "Wait failed: %s\n", v15);
goto LABEL_25;
}
}
else if ( execv(*v3, (char *const *)v3) < 0 )
{
v16 = _errno_location();
v17 = strerror(*v16);
printf("Execv of \"%s\" failed: %s\n", *v3, v17);
exit(1);
}
LABEL_5:
v3 = *v6++;
if ( !v3 )
return;
}
}
func2((__int64)v3, a2);
goto LABEL_5;
}
}

original_code:
void runSequential(char *** commands, int *sequential, struct jobnode **jobs)
{
 int i = 0;
 while (commands[i] != ((void *)0))
 {
  char **argj = commands[i];
  if (strcmp(commands[i][0], "exit") == 0)
  {
   if (commands[i][1] == ((void *)0))
   {
    (*sequential) = 2;
   }
   else
   {
    printf("%s\n", "Error: \"exit\" has no parameters!");
   }
  }
  else if (strcmp(commands[i][0], "mode") == 0)
  {
   modefun(commands[i], sequential);
  }
  else if (strcmp(commands[i][0], "jobs") == 0)
  {
   if (commands[i][1] == ((void *)0))
   {
    jobs_print(*jobs);
   }
   else
   {
    printf("%s\n", "Error: \"jobs\" has no parameters!");
   }
  }
  else
  {
   pid_t pid = fork();
   int childreturn;
   if (pid == 0)
   {
    if (execv(argj[0], argj) < 0)
       {
     printf("Execv of \"%s\" failed: %s\n", argj[0], strerror((*__errno_location ())));
     exit(1);
    }
   }
   else if (pid > 0)
   {
         int check;
         check = waitpid(pid, &childreturn, 0);
           if (check == -1)
    {
     fprintf(stderr, "Wait failed: %s\n", strerror((*__errno_location ())));
     exit(1);
    }
       }
   else
   {
    fprintf(stderr, "Fork failed: %s\n", strerror((*__errno_location ())));
    exit(1);
   }
  }
  i++;
 }
}

canonical_original_code:
void runSequential(char ***commands, int *sequential, struct jobnode **jobs)
{
 int i = 0;
 while (commands[i] != ((void *)0))
 {
  char **argj = commands[i];
  if (strcmp(commands[i][0], "exit") == 0)
  {
   if (commands[i][1] == ((void *)0))
   {
    (*sequential) = 2;
   }
   else
   {
    printf("%s\n", "Error: \"exit\" has no parameters!");
   }
  }
  else if (strcmp(commands[i][0], "mode") == 0)
  {
   modefun(commands[i], sequential);
  }
  else if (strcmp(commands[i][0], "jobs") == 0)
  {
   if (commands[i][1] == ((void *)0))
   {
    jobs_print(*jobs);
   }
   else
   {
    printf("%s\n", "Error: \"jobs\" has no parameters!");
   }
  }
  else
  {
   int pid = fork();
   int childreturn;
   if (pid == 0)
   {
    if (execv(argj[0], argj) < 0)
       {
     printf("Execv of \"%s\" failed: %s\n", argj[0], strerror((*__errno_location ())));
     exit(1);
    }
   }
   else if (pid > 0)
   {
         int check;
         check = waitpid(pid, &childreturn, 0);
           if (check == -1)
    {
     fprintf(stderr, "Wait failed: %s\n", strerror((*__errno_location ())));
     exit(1);
    }
       }
   else
   {
    fprintf(stderr, "Fork failed: %s\n", strerror((*__errno_location ())));
    exit(1);
   }
  }
  i++;
 }
}

variable_types:
argj
char **

variable_types: pid int

variable_types: childreturn int

variable_types: check int

user_defined_types: struct jobnode { int pid; int running; char **command; struct jobnode *next; }


runParallel

decompiled_code:
void __fastcall runParallel(const char ***a1, int *a2, _QWORD *a3)
{
const char **v3; // r14
__int64 v7; // r15
const char *v8; // rdx
bool v9; // al
bool v10; // cf
bool v11; // zf
const char *v12; // rdi
__int64 v13; // rcx
const char *v14; // rsi
__pid_t v15; // eax
int *v16; // rax
char *v17; // rax
int *v18; // rax
char *v19; // rax

v3 = *a1;
if ( *a1 )
{
v7 = 0LL;
while ( 1 )
{
v8 = *v3;
if ( !strcmp(*v3, "exit") )
break;
v9 = strcmp(*v3, "mode") != 0;
v10 = 0;
v11 = !v9;
if ( v9 )
{
v12 = "jobs";
v13 = 5LL;
v14 = *v3;
do
{
if ( !v13 )
break;
v10 = *v14 < (unsigned int)*v12;
v11 = *v14++ == *v12++;
--v13;
}
while ( v11 );
if ( (!v10 && !v11) != v10 )
{
if ( !strcmp(*v3, "pause") )
{
runpause((__int64)a1, (__int64)a3, v7);
}
else if ( !strcmp(*v3, "resume") )
{
resume((__int64)a1, (__int64)a3, v7);
}
else
{
v15 = fork();
if ( v15 )
{
if ( v15 <= 0 )
{
v18 = _errno_location();
v19 = strerror(*v18);
fprintf(stderr, "Fork failed: %s\n", v19);
exit(1);
}
jobs_append(a1[v7], (unsigned int)v15, a3);
}
else if ( execv(*v3, (char *const *)v3) < 0 )
{
v16 = _errno_location();
v17 = strerror(*v16);
printf("Execv of \"%s\" failed: %s\n", *v3, v17);
exit(1);
}
}
goto LABEL_5;
}
if ( v3[1] )
puts("Error: \"jobs\" has no parameters!");
++v7;
jobs_print(*a3, v14, v8, v13);
v3 = a1[v7];
if ( !v3 )
return;
}
else
{
modefun((__int64)v3, a2);
LABEL_5:
v3 = a1[++v7];
if ( !v3 )
return;
}
}
if ( v3[1] )
puts("Error: \"exit\" has no parameters!");
else
*a2 = 2;
goto LABEL_5;
}
}

canonical_decompiled_code:
void __fastcall func4(const char ***a1, int *a2, _QWORD *a3)
{
const char **v3; // r14
__int64 v7; // r15
const char *v8; // rdx
bool v9; // al
bool v10; // cf
bool v11; // zf
const char *v12; // rdi
__int64 v13; // rcx
const char *v14; // rsi
__pid_t v15; // eax
int *v16; // rax
char *v17; // rax
int *v18; // rax
char *v19; // rax

v3 = *a1;
if ( *a1 )
{
v7 = 0LL;
while ( 1 )
{
v8 = *v3;
if ( !strcmp(*v3, "exit") )
break;
v9 = strcmp(*v3, "mode") != 0;
v10 = 0;
v11 = !v9;
if ( v9 )
{
v12 = "jobs";
v13 = 5LL;
v14 = *v3;
do
{
if ( !v13 )
break;
v10 = *v14 < (unsigned int)*v12;
v11 = *v14++ == *v12++;
--v13;
}
while ( v11 );
if ( (!v10 && !v11) != v10 )
{
if ( !strcmp(*v3, "pause") )
{
func0((__int64)a1, (__int64)a3, v7);
}
else if ( !strcmp(*v3, "resume") )
{
func1((__int64)a1, (__int64)a3, v7);
}
else
{
v15 = fork();
if ( v15 )
{
if ( v15 <= 0 )
{
v18 = _errno_location();
v19 = strerror(*v18);
fprintf(stderr, "Fork failed: %s\n", v19);
exit(1);
}
jobs_append(a1[v7], (unsigned int)v15, a3);
}
else if ( execv(*v3, (char *const *)v3) < 0 )
{
v16 = _errno_location();
v17 = strerror(*v16);
printf("Execv of \"%s\" failed: %s\n", *v3, v17);
exit(1);
}
}
goto LABEL_5;
}
if ( v3[1] )
puts("Error: \"jobs\" has no parameters!");
++v7;
jobs_print(*a3, v14, v8, v13);
v3 = a1[v7];
if ( !v3 )
return;
}
else
{
func2((__int64)v3, a2);
LABEL_5:
v3 = a1[++v7];
if ( !v3 )
return;
}
}
if ( v3[1] )
puts("Error: \"exit\" has no parameters!");
else
*a2 = 2;
goto LABEL_5;
}
}

original_code:
void runParallel(char ***commands, int *sequential, struct jobnode **jobs)
{
 int i = 0;
 while(commands[i] != ((void *)0))
 {
  char **argj = commands[i];
  if (strcmp(commands[i][0], "exit") == 0)
  {
   if (commands[i][1] == ((void *)0))
   {
    (*sequential) = 2;
   }
   else
   {
    printf("%s\n", "Error: \"exit\" has no parameters!");
   }
  }
  else if (strcmp(commands[i][0], "mode") == 0)
  {
   modefun(commands[i], sequential);
  }
  else if (strcmp(commands[i][0], "jobs") == 0)
  {
   if (commands[i][1] != ((void *)0))
   {
    printf("%s\n", "Error: \"jobs\" has no parameters!");
   }
    jobs_print(*jobs);
  }
  else if (strcmp(commands[i][0], "pause") == 0)
  {
   runpause(commands,jobs, i);
  }
  else if (strcmp(commands[i][0], "resume") == 0)
  {
   resume(commands, jobs, i);
  }
  else
  {
   pid_t pid1 = fork();
   if (pid1 == 0)
   {
    if (execv(argj[0], argj) < 0)
    {
     printf("Execv of \"%s\" failed: %s\n", argj[0], strerror((*__errno_location ())));
     exit(1);
    }
   }
   else if (pid1 > 0)
   {
    jobs_append(commands[i], pid1, jobs);
   }
   else
   {
    fprintf(stderr, "Fork failed: %s\n", strerror((*__errno_location ())));
    exit(1);
   }
  }
 i++;
 }
}

canonical_original_code:
void runParallel(char ***commands, int *sequential, struct jobnode **jobs)
{
 int i = 0;
 while(commands[i] != ((void *)0))
 {
  char **argj = commands[i];
  if (strcmp(commands[i][0], "exit") == 0)
  {
   if (commands[i][1] == ((void *)0))
   {
    (*sequential) = 2;
   }
   else
   {
    printf("%s\n", "Error: \"exit\" has no parameters!");
   }
  }
  else if (strcmp(commands[i][0], "mode") == 0)
  {
   modefun(commands[i], sequential);
  }
  else if (strcmp(commands[i][0], "jobs") == 0)
  {
   if (commands[i][1] != ((void *)0))
   {
    printf("%s\n", "Error: \"jobs\" has no parameters!");
   }
    jobs_print(*jobs);
  }
  else if (strcmp(commands[i][0], "pause") == 0)
  {
   runpause(commands,jobs, i);
  }
  else if (strcmp(commands[i][0], "resume") == 0)
  {
   resume(commands, jobs, i);
  }
  else
  {
   int pid1 = fork();
   if (pid1 == 0)
   {
    if (execv(argj[0], argj) < 0)
    {
     printf("Execv of \"%s\" failed: %s\n", argj[0], strerror((*__errno_location ())));
     exit(1);
    }
   }
   else if (pid1 > 0)
   {
    jobs_append(commands[i], pid1, jobs);
   }
   else
   {
    fprintf(stderr, "Fork failed: %s\n", strerror((*__errno_location ())));
    exit(1);
   }
  }
 i++;
 }
}


runProcesses

decompiled_code:
void __fastcall runProcesses(const char ***a1, int *a2, _QWORD *a3)
{
if ( *a2 )
runSequential(a1, a2, a3);
else
runParallel(a1, a2, a3);
}

canonical_decompiled_code:
void __fastcall func5(const char ***a1, int *a2, _QWORD *a3)
{
if ( *a2 )
func3(a1, a2, a3);
else
func4(a1, a2, a3);
}

original_code:
void runProcesses(char *** commands, int *sequential, struct jobnode **jobs)
{
 if((*sequential))
  {
   runSequential(commands, sequential, jobs);
  }
  else
  {
   runParallel(commands, sequential, jobs);
  }
}

canonical_original_code:
void runProcesses(char ***commands, int *sequential, struct jobnode **jobs)
{
 if((*sequential))
  {
   runSequential(commands, sequential, jobs);
  }
  else
  {
   runParallel(commands, sequential, jobs);
  }
}


commandCount

decompiled_code:
__int64 __fastcall commandCount(_QWORD *a1)
{
__int64 v1; // rax
unsigned int v2; // er8

if ( !*a1 )
return 0LL;
v1 = 1LL;
do
v2 = v1++;
while ( a1[v1 - 1] );
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD *a1)
{
__int64 v1; // rax
unsigned int v2; // er8

if ( !*a1 )
return 0LL;
v1 = 1LL;
do
v2 = v1++;
while ( a1[v1 - 1] );
return v2;
}

original_code:
int commandCount(char ***commands)
{
 int i = 0;
 while (commands[i] != ((void *)0))
 {
  i++;
 }
 return i;
}


preparellel

decompiled_code:
int __fastcall preparellel(__int64 a1)
{
int result; // eax
__pid_t v3; // eax
unsigned int v4; // ebp
int v5; // edi
char *v6; // rax
unsigned int *v7; // rbx
int *v8; // rax
char *v9; // rax
int *v10; // rax
char *v11; // rax
int stat_loc; // [rsp+4h] [rbp-24h] BYREF
struct pollfd fds; // [rsp+8h] [rbp-20h] BYREF

fds = (struct pollfd)0x100000000LL;
while ( 1 )
{
result = poll(&fds, 1uLL, 200);
if ( result )
break;
v3 = waitpid(0, &stat_loc, 1);
v4 = v3;
if ( v3 > 0 )
{
v7 = (unsigned int *)findchild((unsigned int)v3, a1);
if ( !v7 )
goto LABEL_11;
printf("%s", "Process ");
printf("%d", *v7);
printf("%s", " (");
jobs_commandprint(*((_QWORD *)v7 + 1), 0LL);
printf("%s", ") ");
puts("completed");
printf("%s", "Shell shell shell:");
if ( fflush(stdout) )
{
v8 = _errno_location();
v9 = strerror(*v8);
fprintf(stderr, "Flush failed: %s\n", v9);
}
if ( !(unsigned int)jobs_delete(v4, a1) )
LABEL_11:
puts("Something went terribly, terribly wrong");
}
else if ( v3 == -1 )
{
v5 = *_errno_location();
if ( v5 != 10 )
{
v6 = strerror(v5);
fprintf(stderr, "Wait failed: %s\n", v6);
}
}
}
if ( result <= 0 )
{
v10 = _errno_location();
v11 = strerror(*v10);
fprintf(stderr, "Poll Failed: %s\n", v11);
exit(1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1)
{
int result; // eax
__pid_t v3; // eax
unsigned int v4; // ebp
int v5; // edi
char *v6; // rax
unsigned int *v7; // rbx
int *v8; // rax
char *v9; // rax
int *v10; // rax
char *v11; // rax
int stat_loc; // [rsp+4h] [rbp-24h] BYREF
struct pollfd fds; // [rsp+8h] [rbp-20h] BYREF

fds = (struct pollfd)0x100000000LL;
while ( 1 )
{
result = poll(&fds, 1uLL, 200);
if ( result )
break;
v3 = waitpid(0, &stat_loc, 1);
v4 = v3;
if ( v3 > 0 )
{
v7 = (unsigned int *)findchild((unsigned int)v3, a1);
if ( !v7 )
goto LABEL_11;
printf("%s", "Process ");
printf("%d", *v7);
printf("%s", " (");
jobs_commandprint(*((_QWORD *)v7 + 1), 0LL);
printf("%s", ") ");
puts("completed");
printf("%s", "Shell shell shell:");
if ( fflush(stdout) )
{
v8 = _errno_location();
v9 = strerror(*v8);
fprintf(stderr, "Flush failed: %s\n", v9);
}
if ( !(unsigned int)jobs_delete(v4, a1) )
LABEL_11:
puts("Something went terribly, terribly wrong");
}
else if ( v3 == -1 )
{
v5 = *_errno_location();
if ( v5 != 10 )
{
v6 = strerror(v5);
fprintf(stderr, "Wait failed: %s\n", v6);
}
}
}
if ( result <= 0 )
{
v10 = _errno_location();
v11 = strerror(*v10);
fprintf(stderr, "Poll Failed: %s\n", v11);
exit(1);
}
return result;
}

original_code:
void preparellel(struct jobnode **jobs)
{
 int check = 0;
 int rv = 0;
 int childreturn;
 struct pollfd pfd;
 pfd.fd = 0;
 pfd.events = 0x001;
 pfd.revents = 0;
 while (1)
 {
  rv = poll(&pfd, 1, 200);
  if (rv == 0)
  {
   check = waitpid(0, &childreturn, 1);
   if (check > 0)
    {
     struct jobnode* child = findchild(check, jobs);
     if (child != ((void *)0))
     {
      printf("%s", "Process ");
      printf("%d", child->pid);
      printf("%s", " (");
      jobs_commandprint(child->command, 0);
      printf("%s", ") ");
      printf("%s\n", "completed");
      printf("%s", "Shell shell shell:");
      int flush = fflush(stdout);
      if (flush)
      {
       fprintf(stderr, "Flush failed: %s\n", strerror((*__errno_location ())));
      }
      int delete = jobs_delete(check, jobs);
      if(!delete)
      {
       printf("%s\n", "Something went terribly, terribly wrong");
      }
     }
     else
     {
      printf("%s\n", "Something went terribly, terribly wrong");
     }
    }
   else if (check == -1)
   {
    if ((*__errno_location ()) != 10)
    {
     fprintf(stderr, "Wait failed: %s\n", strerror((*__errno_location ())));
    }
   }
  }
  else if (rv > 0)
  {
   break;
  }
  else
  {
   fprintf(stderr, "Poll Failed: %s\n", strerror((*__errno_location ())));
   exit(1);
  }
 }
}

canonical_original_code:
void preparellel(struct jobnode **jobs)
{
 int check = 0;
 int rv = 0;
 int childreturn;
 struct pollfd pfd;
 pfd.fd = 0;
 pfd.events = 0x001;
 pfd.revents = 0;
 while (1)
 {
  rv = poll(&pfd, 1, 200);
  if (rv == 0)
  {
   check = waitpid(0, &childreturn, 1);
   if (check > 0)
    {
     struct jobnode *child = findchild(check, jobs);
     if (child != ((void *)0))
     {
      printf("%s", "Process ");
      printf("%d", child->pid);
      printf("%s", " (");
      jobs_commandprint(child->command, 0);
      printf("%s", ") ");
      printf("%s\n", "completed");
      printf("%s", "Shell shell shell:");
      int flush = fflush(stdout);
      if (flush)
      {
       fprintf(stderr, "Flush failed: %s\n", strerror((*__errno_location ())));
      }
      int delete = jobs_delete(check, jobs);
      if(!delete)
      {
       printf("%s\n", "Something went terribly, terribly wrong");
      }
     }
     else
     {
      printf("%s\n", "Something went terribly, terribly wrong");
     }
    }
   else if (check == -1)
   {
    if ((*__errno_location ()) != 10)
    {
     fprintf(stderr, "Wait failed: %s\n", strerror((*__errno_location ())));
    }
   }
  }
  else if (rv > 0)
  {
   break;
  }
  else
  {
   fprintf(stderr, "Poll Failed: %s\n", strerror((*__errno_location ())));
   exit(1);
  }
 }
}

variable_types: rv int

variable_types: struct pollfd { int fd; short events; short revents; }

variable_types: flush int

variable_types: delete int


original_code:
void jobs_append(char **newcommand, pid_t newpid, struct jobnode **head) {
 if (newcommand == ((void *)0))
 {
  return;
 }
 struct jobnode *newnode = (struct jobnode*) malloc(sizeof(struct jobnode));
 if(newnode==((void *)0))
 {
  printf("%s\n", "Malloc Fails: Exiting Now!");
  exit(1);
 }
 int count =0;
 while(newcommand[count]!= ((void *)0))
 {
  count++;
 }
 (newnode->command) = (char **) malloc(sizeof(char**)*(count+1));
 char **temp = newnode->command;
 int x = 0;
 while(newcommand[x] != ((void *)0))
 {
  temp[x] = strdup(newcommand[x]);
  if (temp[x] == ((void *)0))
  {
   printf("Strdup Fails: %s\n", strerror((*__errno_location ())));
   exit(1);
  }
  x++;
 }
 temp[x] = ((void *)0);
 newnode->pid = newpid;
 newnode->running = 1;
 newnode->next = ((void *)0);
  while((*head) != ((void *)0))
        {
  head = &((*head)->next);
 }
 (*head)=newnode;
}

canonical_original_code:
void jobs_append(char **newcommand, int newpid, struct jobnode **head) {
 if (newcommand == ((void *)0))
 {
  return;
 }
 struct jobnode *newnode = (struct jobnode*) malloc(sizeof(struct jobnode));
 if(newnode==((void *)0))
 {
  printf("%s\n", "Malloc Fails: Exiting Now!");
  exit(1);
 }
 int count = 0;
 while(newcommand[count]!= ((void *)0))
 {
  count++;
 }
 (newnode->command) = (char **) malloc(sizeof(char **)*(count+1));
 char **temp = newnode->command;
 int x = 0;
 while(newcommand[x] != ((void *)0))
 {
  temp[x] = strdup(newcommand[x]);
  if (temp[x] == ((void *)0))
  {
   printf("Strdup Fails: %s\n", strerror((*__errno_location ())));
   exit(1);
  }
  x++;
 }
 temp[x] = ((void *)0);
 newnode->pid = newpid;
 newnode->running = 1;
 newnode->next = ((void *)0);
  while((*head) != ((void *)0))
        {
  head = &((*head)->next);
 }
 (*head)=newnode;
}

variable_types:
newcommand
char **

variable_types: newpid int

variable_types: count int

variable_types:
temp
char **

variable_types: x int


decompiled_code:
__int64 __fastcall jobs_delete(int a1, __int64 *a2)
{
__int64 result; // rax
int v3; // edx
__int64 *v4; // rbp

result = *a2;
if ( !*a2 )
return 0LL;
while ( 1 )
{
v3 = *(_DWORD *)result;
v4 = (__int64 *)result;
result = *(_QWORD *)(result + 16);
if ( v3 == a1 )
break;
a2 = v4 + 2;
if ( !result )
return result;
}
*a2 = result;
freeToken(v4[1]);
free(v4);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, __int64 *a2)
{
__int64 result; // rax
int v3; // edx
__int64 *v4; // rbp

result = *a2;
if ( !*a2 )
return 0LL;
while ( 1 )
{
v3 = *(_DWORD *)result;
v4 = (__int64 *)result;
result = *(_QWORD *)(result + 16);
if ( v3 == a1 )
break;
a2 = v4 + 2;
if ( !result )
return result;
}
*a2 = result;
freeToken(v4[1]);
free(v4);
return 1LL;
}

original_code:
int jobs_delete(pid_t target, struct jobnode **head) {
 while((*head) != ((void *)0))
        {
  if((*head)->pid== target)
         {
   struct jobnode *temp = (*head);
   (*head) = (*head)->next;
   freeToken(temp->command);
   free(temp);
   return 1;
                }
  head = &((*head)->next);
        }
 return 0;
}

canonical_original_code:
int jobs_delete(int target, struct jobnode **head) {
 while((*head) != ((void *)0))
        {
  if((*head)->pid== target)
         {
   struct jobnode *temp = (*head);
   (*head) = (*head)->next;
   freeToken(temp->command);
   free(temp);
   return 1;
                }
  head = &((*head)->next);
        }
 return 0;
}

variable_types: target int

variable_types: struct jobnode { int pid; int running; char **command; struct jobnode *next; } **


findchild

decompiled_code:
__int64 __fastcall findchild(int a1, __int64 *a2)
{
__int64 result; // rax

for ( result = *a2; result; result = *(_QWORD *)(result + 16) )
{
if ( *(_DWORD *)result == a1 )
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, __int64 *a2)
{
__int64 result; // rax

for ( result = *a2; result; result = *(_QWORD *)(result + 16) )
{
if ( *(_DWORD *)result == a1 )
break;
}
return result;
}

original_code:
struct jobnode *findchild(pid_t target, struct jobnode **head)
{
 struct jobnode *temp = *head;
 while (temp != ((void *)0))
 {
  if (temp->pid == target)
  {
   return temp;
  }
  temp = temp->next;
 }
 return ((void *)0);
}

canonical_original_code:
struct jobnode *findchild(int target, struct jobnode **head)
{
 struct jobnode *temp = *head;
 while (temp != ((void *)0))
 {
  if (temp->pid == target)
  {
   return temp;
  }
  temp = temp->next;
 }
 return ((void *)0);
}

variable_types:
head
struct jobnode **

variable_types: struct jobnode { int pid; int running; char **command; struct jobnode *next; } *


decompiled_code:
void __fastcall jobs_clear(void *ptr)
{
_QWORD *v1; // rbx
_QWORD *v2; // rbp

if ( ptr )
{
v1 = ptr;
do
{
v2 = v1;
v1 = (_QWORD *)v1[2];
freeToken(v2[1]);
free(v2);
}
while ( v1 );
}
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
_QWORD *v1; // rbx
_QWORD *v2; // rbp

if ( ptr )
{
v1 = ptr;
do
{
v2 = v1;
v1 = (_QWORD *)v1[2];
freeToken(v2[1]);
free(v2);
}
while ( v1 );
}
}

original_code:
void jobs_clear(struct jobnode *list)
{
 while(list != ((void *)0))
  {
   struct jobnode *temp = list;
   list = list->next;
   freeToken(temp->command);
   free(temp);
  }
}


decompiled_code:
int __fastcall jobs_commandprint(const char **a1, int a2)
{
int result; // eax
const char *v4; // rsi
const char **v5; // rbx

if ( !a1 )
return puts("Something went terribly, terribly wrong");
if ( *a1 )
{
result = printf("%s", *a1);
v4 = a1[1];
if ( v4 )
{
v5 = a1 + 2;
do
{
++v5;
result = printf(" %s", v4);
v4 = *(v5 - 1);
}
while ( v4 );
}
}
if ( a2 )
result = puts(&byte_3A0);
return result;
}

canonical_decompiled_code:
int __fastcall func4(const char **a1, int a2)
{
int result; // eax
const char *v4; // rsi
const char **v5; // rbx

if ( !a1 )
return puts("Something went terribly, terribly wrong");
if ( *a1 )
{
result = printf("%s", *a1);
v4 = a1[1];
if ( v4 )
{
v5 = a1 + 2;
do
{
++v5;
result = printf(" %s", v4);
v4 = *(v5 - 1);
}
while ( v4 );
}
}
if ( a2 )
result = puts(&byte_3A0);
return result;
}

original_code:
void jobs_commandprint(char **commands, int newline)
{
 int x =0;
 if(commands==((void *)0))
 {
  printf("%s\n", "Something went terribly, terribly wrong");
  return;
 }
 if(commands[x]!=((void *)0))
 {
  printf("%s",commands[x]);
  x++;
 }
 while (commands[x]!=((void *)0))
 {
  printf(" %s", commands[x]);
  x++;
 }
 if (newline)
 {
  printf("%s\n", "");
 }
}

canonical_original_code:
void jobs_commandprint(char **commands, int newline)
{
 int x = 0;
 if(commands==((void *)0))
 {
  printf("%s\n", "Something went terribly, terribly wrong");
  return;
 }
 if(commands[x]!=((void *)0))
 {
  printf("%s",commands[x]);
  x++;
 }
 while (commands[x]!=((void *)0))
 {
  printf(" %s", commands[x]);
  x++;
 }
 if (newline)
 {
  printf("%s\n", "");
 }
}

variable_types:
commands
char **

variable_types: newline int


decompiled_code:
int __fastcall jobs_print(const char ***a1)
{
const char ***v1; // rbx
int result; // eax
int *v3; // rax
char *v4; // rax

if ( !a1 )
return puts("\nNo processes currently running");
v1 = a1;
puts(&byte_3A0);
puts("\tProcess Id\tState\t\tCommand");
do
{
while ( 1 )
{
printf("%s\t", &byte_3A0);
printf("%d", *(unsigned int *)v1);
printf("%s\t\t", &byte_3A0);
if ( *((_DWORD *)v1 + 1) )
printf("%s", "Running\t\t");
else
printf("%s", "Paused\t\t");
jobs_commandprint(v1[1], 1);
result = fflush(stdout);
if ( result )
break;
v1 = (const char ***)v1[2];
if ( !v1 )
return result;
}
v3 = _errno_location();
v4 = strerror(*v3);
result = fprintf(stderr, "Flush failed: %s\n", v4);
v1 = (const char ***)v1[2];
}
while ( v1 );
return result;
}

canonical_decompiled_code:
int __fastcall func5(const char ***a1)
{
const char ***v1; // rbx
int result; // eax
int *v3; // rax
char *v4; // rax

if ( !a1 )
return puts("\nNo processes currently running");
v1 = a1;
puts(&byte_3A0);
puts("\tProcess Id\tState\t\tCommand");
do
{
while ( 1 )
{
printf("%s\t", &byte_3A0);
printf("%d", *(unsigned int *)v1);
printf("%s\t\t", &byte_3A0);
if ( *((_DWORD *)v1 + 1) )
printf("%s", "Running\t\t");
else
printf("%s", "Paused\t\t");
func4(v1[1], 1);
result = fflush(stdout);
if ( result )
break;
v1 = (const char ***)v1[2];
if ( !v1 )
return result;
}
v3 = _errno_location();
v4 = strerror(*v3);
result = fprintf(stderr, "Flush failed: %s\n", v4);
v1 = (const char ***)v1[2];
}
while ( v1 );
return result;
}

original_code:
void jobs_print(const struct jobnode *head) {
 if (head == ((void *)0))
 {
  printf("%s\n", "\nNo processes currently running");
  return;
 }
 printf("%s\n","");
 printf("%s\n", "\tProcess Id\tState\t\tCommand");
 while(head != ((void *)0))
        {
  printf("%s\t", "");
                printf("%d", head->pid);
  printf("%s\t\t", "");
  if (head->running)
  {
   printf("%s", "Running\t\t");
  }
  else
  {
   printf("%s", "Paused\t\t");
  }
               jobs_commandprint(head->command, 1);
  int flush = fflush(stdout);
  if (flush)
  {
   fprintf(stderr, "Flush failed: %s\n", strerror((*__errno_location ())));
  }
                head = head->next;
        }
}

canonical_original_code:
void jobs_print(struct jobnode *head) {
 if (head == ((void *)0))
 {
  printf("%s\n", "\nNo processes currently running");
  return;
 }
 printf("%s\n","");
 printf("%s\n", "\tProcess Id\tState\t\tCommand");
 while(head != ((void *)0))
        {
  printf("%s\t", "");
                printf("%d", head->pid);
  printf("%s\t\t", "");
  if (head->running)
  {
   printf("%s", "Running\t\t");
  }
  else
  {
   printf("%s", "Paused\t\t");
  }
               jobs_commandprint(head->command, 1);
  int flush = fflush(stdout);
  if (flush)
  {
   fprintf(stderr, "Flush failed: %s\n", strerror((*__errno_location ())));
  }
                head = head->next;
        }
}


decompiled_code:
void __fastcall paths_append(char *src, char **a2)
{
char **v2; // rbx
char *v3; // rax
char *v4; // rax
char *v5; // rcx
char *v6; // rax
char *v7; // rsi

if ( src )
{
v2 = a2;
v3 = (char *)malloc(0x88uLL);
if ( !v3 )
{
puts("Malloc Fails: Exiting Now!");
exit(1);
}
v4 = strncpy(v3, src, 0x7FuLL);
*((_QWORD *)v4 + 16) = 0LL;
v5 = v4;
v6 = *a2;
if ( *a2 )
{
do
{
v7 = v6;
v6 = (char *)*((_QWORD *)v6 + 16);
}
while ( v6 );
v2 = (char **)(v7 + 128);
}
*v2 = v5;
}
}

canonical_decompiled_code:
void __fastcall func0(char *src, char **a2)
{
char **v2; // rbx
char *v3; // rax
char *v4; // rax
char *v5; // rcx
char *v6; // rax
char *v7; // rsi

if ( src )
{
v2 = a2;
v3 = (char *)malloc(0x88uLL);
if ( !v3 )
{
puts("Malloc Fails: Exiting Now!");
exit(1);
}
v4 = strncpy(v3, src, 0x7FuLL);
*((_QWORD *)v4 + 16) = 0LL;
v5 = v4;
v6 = *a2;
if ( *a2 )
{
do
{
v7 = v6;
v6 = (char *)*((_QWORD *)v6 + 16);
}
while ( v6 );
v2 = (char **)(v7 + 128);
}
*v2 = v5;
}
}

original_code:
void paths_append(const char *name, struct node **head) {
 if (name == ((void *)0))
 {
  return;
 }
 struct node *newnode = (struct node*) malloc(sizeof(struct node));
 if(newnode==((void *)0))
 {
  printf("%s\n", "Malloc Fails: Exiting Now!");
  exit(1);
 }
 strncpy((newnode->name), name, 127);
 newnode->next = ((void *)0);
  while((*head) != ((void *)0))
        {
         head = &((*head)->next);
 }
 (*head)=newnode;
}

canonical_original_code:
void paths_append(char *name, struct node **head) {
 if (name == ((void *)0))
 {
  return;
 }
 struct node *newnode = (struct node*) malloc(sizeof(struct node));
 if(newnode==((void *)0))
 {
  printf("%s\n", "Malloc Fails: Exiting Now!");
  exit(1);
 }
 strncpy((newnode->name), name, 127);
 newnode->next = ((void *)0);
  while((*head) != ((void *)0))
        {
         head = &((*head)->next);
 }
 (*head)=newnode;
}

variable_types:
name
char *

variable_types: struct node { char name[128]; struct node *next; } **


decompiled_code:
int __fastcall paths_print(const char *a1)
{
const char *v1; // rbx
int result; // eax

if ( a1 )
{
v1 = a1;
do
{
result = printf("Node at address %p has value %s\n", v1, v1);
v1 = (const char *)*((_QWORD *)v1 + 16);
}
while ( v1 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(const char *a1)
{
const char *v1; // rbx
int result; // eax

if ( a1 )
{
v1 = a1;
do
{
result = printf("Node at address %p has value %s\n", v1, v1);
v1 = (const char *)*((_QWORD *)v1 + 16);
}
while ( v1 );
}
return result;
}

original_code:
void paths_print(const struct node *head) {
        while(head != ((void *)0))
        {
                printf("Node at address %p has value %s\n", head, head->name);
                head = head->next;
        }
}

canonical_original_code:
void paths_print(struct node *head) {
        while(head != ((void *)0))
        {
                printf("Node at address %p has value %s\n", head, head->name);
                head = head->next;
        }
}

variable_types: struct node { char name[128]; struct node *next; } *


decompiled_code:
void __fastcall paths_clear(void *ptr)
{
void *v1; // rbx
void *v2; // rdi

if ( ptr )
{
v1 = ptr;
do
{
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 16);
free(v2);
}
while ( v1 );
}
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
void *v1; // rbx
void *v2; // rdi

if ( ptr )
{
v1 = ptr;
do
{
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 16);
free(v2);
}
while ( v1 );
}
}

original_code:
void paths_clear(struct node *list)
{
 while(list != ((void *)0))
  {
   struct node *temp = list;
   list = list->next;
   free(temp);
  }
}

user_defined_types: struct node { char name[128]; struct node *next; }


readn

repo: jleverenz/cvsps-esr

decompiled_code:
__int64 __fastcall readn(int fd, void *buf, __int64 a3)
{
__int64 v3; // r13
int v5; // ebx
size_t v6; // r12
int v7; // eax
int v8; // er15
__int64 result; // rax
int v10; // [rsp+Ch] [rbp-3Ch]

v3 = a3;
v10 = a3;
if ( (int)a3 <= 0 )
{
v3 = a3 - (int)a3;
LABEL_6:
result = v3;
}
else
{
v5 = a3;
v6 = (int)a3;
do
{
while ( 1 )
{
v7 = read(fd, buf, v6);
v8 = v7;
if ( v7 < 0 )
break;
if ( v7 )
{
v5 -= v7;
if ( !v5 )
goto LABEL_6;
v6 = v5;
buf = (char *)buf + v7;
if ( v5 > 0 )
continue;
}
v3 -= v6;
goto LABEL_6;
}
}
while ( *_errno_location() == 4 && v10 != v5 );
result = v8;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int fd, void *buf, __int64 a3)
{
__int64 v3; // r13
int v5; // ebx
size_t v6; // r12
int v7; // eax
int v8; // er15
__int64 result; // rax
int v10; // [rsp+Ch] [rbp-3Ch]

v3 = a3;
v10 = a3;
if ( (int)a3 <= 0 )
{
v3 = a3 - (int)a3;
LABEL_6:
result = v3;
}
else
{
v5 = a3;
v6 = (int)a3;
do
{
while ( 1 )
{
v7 = read(fd, buf, v6);
v8 = v7;
if ( v7 < 0 )
break;
if ( v7 )
{
v5 -= v7;
if ( !v5 )
goto LABEL_6;
v6 = v5;
buf = (char *)buf + v7;
if ( v5 > 0 )
continue;
}
v3 -= v6;
goto LABEL_6;
}
}
while ( *_errno_location() == 4 && v10 != v5 );
result = v8;
}
return result;
}

original_code:
ssize_t readn(int fd, void *buf, size_t len)
{
  int nleft,nread;
  nleft = len;
  while (nleft > 0)
  {
    nread = read(fd,buf,nleft);
    if (nread < 0)
    {
      if ((*__errno_location ()) == 4 && nleft != (int)len)
        continue;
      else
     return (nread);
    }
    else if (nread == 0)
      break;
    nleft -= nread;
    if (nleft)
      buf = ((char *)buf) + nread;
  }
  return (len - nleft);
}

canonical_original_code:
long readn(int fd, void *buf, unsigned long len)
{
  int nleft; int nread;
  nleft = len;
  while (nleft > 0)
  {
    nread = read(fd,buf,nleft);
    if (nread < 0)
    {
      if ((*__errno_location ()) == 4 && nleft != (int)len)
        continue;
      else
     return (nread);
    }
    else if (nread == 0)
      break;
    nleft -= nread;
    if (nleft)
      buf = ((char *)buf) + nread;
  }
  return (len - nleft);
}

variable_types: fd int

variable_types:
buf
void *

variable_types:
len
unsigned long

variable_types: nleft int

variable_types: nread int

return_type: long


writen

decompiled_code:
__int64 __fastcall writen(int fd, void *buf, __int64 a3)
{
__int64 v3; // rbp
int v5; // er14
size_t v6; // r13
int v7; // eax
int v8; // er12
__int64 result; // rax
int v10; // [rsp+Ch] [rbp-3Ch]

v3 = a3;
v10 = a3;
if ( (int)a3 <= 0 )
{
v3 = a3 - (int)a3;
LABEL_6:
result = v3;
}
else
{
v5 = a3;
v6 = (int)a3;
do
{
while ( 1 )
{
v7 = write(fd, buf, v6);
v8 = v7;
if ( v7 < 0 )
break;
if ( !v7 )
goto LABEL_10;
v5 -= v7;
if ( !v5 )
goto LABEL_6;
v6 = v5;
buf = (char *)buf + v7;
if ( v5 <= 0 )
{
v3 -= v5;
goto LABEL_6;
}
}
}
while ( *_errno_location() == 4 && v10 != v5 );
LABEL_10:
result = v8;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int fd, void *buf, __int64 a3)
{
__int64 v3; // rbp
int v5; // er14
size_t v6; // r13
int v7; // eax
int v8; // er12
__int64 result; // rax
int v10; // [rsp+Ch] [rbp-3Ch]

v3 = a3;
v10 = a3;
if ( (int)a3 <= 0 )
{
v3 = a3 - (int)a3;
LABEL_6:
result = v3;
}
else
{
v5 = a3;
v6 = (int)a3;
do
{
while ( 1 )
{
v7 = write(fd, buf, v6);
v8 = v7;
if ( v7 < 0 )
break;
if ( !v7 )
goto LABEL_10;
v5 -= v7;
if ( !v5 )
goto LABEL_6;
v6 = v5;
buf = (char *)buf + v7;
if ( v5 <= 0 )
{
v3 -= v5;
goto LABEL_6;
}
}
}
while ( *_errno_location() == 4 && v10 != v5 );
LABEL_10:
result = v8;
}
return result;
}

original_code:
ssize_t writen(int fd, const void *buf, size_t len)
{
  int nleft, nwritten;
  nleft = len;
  while (nleft > 0)
  {
    nwritten = write(fd,buf,nleft);
    if (nwritten < 0 && (*__errno_location ()) == 4)
    {
      if (nleft == (int)len)
 return nwritten;
      continue;
    }
    if (nwritten <= 0)
      return nwritten;
    nleft -= nwritten;
    if (nleft)
      buf = ((char *)buf) + nwritten;
  }
  return (len - nleft);
}

canonical_original_code:
long writen(int fd, void *buf, unsigned long len)
{
  int nleft; int nwritten;
  nleft = len;
  while (nleft > 0)
  {
    nwritten = write(fd,buf,nleft);
    if (nwritten < 0 && (*__errno_location ()) == 4)
    {
      if (nleft == (int)len)
 return nwritten;
      continue;
    }
    if (nwritten <= 0)
      return nwritten;
    nleft -= nwritten;
    if (nleft)
      buf = ((char *)buf) + nwritten;
  }
  return (len - nleft);
}

variable_types: nwritten int


hexdump

decompiled_code:
void hexdump(unsigned __int8 *a1, int a2, const char *a3, ...)
{
unsigned __int8 *v3; // r14
unsigned __int8 *v4; // rbp
int v5; // ebx
const unsigned __int16 **v6; // r12
char v7; // al
__int64 v8; // rax
_DWORD *v9; // rdx
char v10; // cl
gcc_va_list va; // [rsp+8h] [rbp-F0h] BYREF

v3 = a1;
if ( (debuglvl & 0x20) != 0 )
{
va_start(va, a3);
vdebug(0x20u, a3, va);
byte_6F0 = 0;
byte_6A0 = 0;
hexbuff_1 = 0LL;
xmmword_6D0 = 0LL;
xmmword_6E0 = 0LL;
printbuff_0 = 0LL;
if ( a2 )
{
v4 = &a1[a2];
v5 = 0;
v6 = _ctype_b_loc();
do
{
while ( 1 )
{
sprintf((char *)&hexbuff_1 + 3 * v5, "%02x ", *v3);
v7 = *v3;
if ( ((*v6)[(char)*v3] & 0x4000) == 0 )
v7 = 46;
++v3;
*((_BYTE *)&printbuff_0 + v5) = v7;
if ( v5 == 15 )
break;
++v5;
if ( v4 == v3 )
goto LABEL_10;
}
v5 = 0;
debug_constprop_0(32LL, (__int64)"%s %s", (const char *)&hexbuff_1, (const char *)&printbuff_0);
byte_6F0 = 0;
byte_6A0 = 0;
hexbuff_1 = 0LL;
xmmword_6D0 = 0LL;
xmmword_6E0 = 0LL;
printbuff_0 = 0LL;
}
while ( v4 != v3 );
LABEL_10:
if ( v5 )
{
if ( (v5 & 0xF) != 0 )
{
v8 = v5 + 1;
v9 = (_DWORD *)((char *)&hexbuff_1 + 3 * v5);
do
{
v10 = v8;
*v9 = 2127992;
++v8;
v9 = (_DWORD *)((char *)v9 + 3);
byte_68E[v8] = 46;
}
while ( (v10 & 0xF) != 0 );
}
debug_constprop_0(32LL, (__int64)"%s %s", (const char *)&hexbuff_1, (const char *)&printbuff_0);
}
}
}
}

canonical_decompiled_code:
void func3(unsigned __int8 *a1, int a2, const char *a3, ...)
{
unsigned __int8 *v3; // r14
unsigned __int8 *v4; // rbp
int v5; // ebx
const unsigned __int16 **v6; // r12
char v7; // al
__int64 v8; // rax
_DWORD *v9; // rdx
char v10; // cl
gcc_va_list va; // [rsp+8h] [rbp-F0h] BYREF

v3 = a1;
if ( (debuglvl & 0x20) != 0 )
{
va_start(va, a3);
func0(0x20u, a3, va);
byte_6F0 = 0;
byte_6A0 = 0;
hexbuff_1 = 0LL;
xmmword_6D0 = 0LL;
xmmword_6E0 = 0LL;
printbuff_0 = 0LL;
if ( a2 )
{
v4 = &a1[a2];
v5 = 0;
v6 = _ctype_b_loc();
do
{
while ( 1 )
{
sprintf((char *)&hexbuff_1 + 3 * v5, "%02x ", *v3);
v7 = *v3;
if ( ((*v6)[(char)*v3] & 0x4000) == 0 )
v7 = 46;
++v3;
*((_BYTE *)&printbuff_0 + v5) = v7;
if ( v5 == 15 )
break;
++v5;
if ( v4 == v3 )
goto LABEL_10;
}
v5 = 0;
func1(32LL, (__int64)"%s %s", (const char *)&hexbuff_1, (const char *)&printbuff_0);
byte_6F0 = 0;
byte_6A0 = 0;
hexbuff_1 = 0LL;
xmmword_6D0 = 0LL;
xmmword_6E0 = 0LL;
printbuff_0 = 0LL;
}
while ( v4 != v3 );
LABEL_10:
if ( v5 )
{
if ( (v5 & 0xF) != 0 )
{
v8 = v5 + 1;
v9 = (_DWORD *)((char *)&hexbuff_1 + 3 * v5);
do
{
v10 = v8;
*v9 = 2127992;
++v8;
v9 = (_DWORD *)((char *)v9 + 3);
byte_68E[v8] = 46;
}
while ( (v10 & 0xF) != 0 );
}
func1(32LL, (__int64)"%s %s", (const char *)&hexbuff_1, (const char *)&printbuff_0);
}
}
}
}

original_code:
void hexdump(const char *ptr, int size, const char *fmt, ...)
{
    static char hexbuff[49];
    static char printbuff[17];
    int count = 0;
    va_list ap;
    if (!(debuglvl & 0x0020))
 return;
    __builtin_va_start(ap,fmt);
    vdebug(0x0020, fmt, ap);
    memset(hexbuff, 0, 49);
    memset(printbuff, 0, 17);
    while (size--)
    {
 sprintf(hexbuff + (count*3), "%02x ", (int)*((unsigned char *)ptr));
 if (((*__ctype_b_loc ())[(int) ((*ptr))] & (unsigned short int) _ISprint))
     printbuff[count] = *ptr;
 else
     printbuff[count] = '.';
 ptr++;
 if ( count++ == 15 )
 {
     count = 0;
     debug(0x0020, "%s %s", hexbuff, printbuff);
     memset(hexbuff, 0, 49);
     memset(printbuff, 0, 17);
 }
    }
    if ( count > 0 ) {
 while ( count % 16 != 0 ) {
     sprintf(hexbuff + (count * 3), "xx ");
     printbuff[count++] = '.';
 }
 debug(0x0020, "%s %s", hexbuff, printbuff);
    }
    __builtin_va_end(ap);
}

canonical_original_code:
void hexdump(char *ptr, int size, char *fmt, ...)
{
    static char hexbuff[49];
    static char printbuff[17];
    int count = 0;
    __builtin_va_list ap;
    if (!(debuglvl & 0x0020))
 return;
    __builtin_va_start(ap,fmt);
    vdebug(0x0020, fmt, ap);
    memset(hexbuff, 0, 49);
    memset(printbuff, 0, 17);
    while (size--)
    {
 sprintf(hexbuff + (count*3), "%02x ", (int)*((unsigned char *)ptr));
 if (((*__ctype_b_loc ())[(int) ((*ptr))] & (unsigned short) _ISprint))
     printbuff[count] = *ptr;
 else
     printbuff[count] = '.';
 ptr++;
 if ( count++ == 15 )
 {
     count = 0;
     debug(0x0020, "%s %s", hexbuff, printbuff);
     memset(hexbuff, 0, 49);
     memset(printbuff, 0, 17);
 }
    }
    if ( count > 0 ) {
 while ( count % 16 != 0 ) {
     sprintf(hexbuff + (count * 3), "xx ");
     printbuff[count++] = '.';
 }
 debug(0x0020, "%s %s", hexbuff, printbuff);
    }
    __builtin_va_end(ap);
}

variable_types:
ptr
char *

variable_types: size int

variable_types:
fmt
char *

variable_types:
hexbuff
char [49]

variable_types:
printbuff
char [17]

variable_types: count int


decompiled_code:
int __fastcall to_hex(char *s, unsigned __int8 *a2, __int64 a3)
{
char *v3; // rbx
char *v5; // r12
__int64 v6; // rdx
char *v7; // rdi
int result; // eax

v3 = s;
if ( a3 )
{
v5 = &s[3 * a3];
do
{
v6 = *a2;
v7 = v3;
v3 += 3;
++a2;
result = sprintf(v7, "%02x ", v6);
}
while ( v5 != v3 );
*v5 = 0;
}
else
{
*s = 0;
}
return result;
}

canonical_decompiled_code:
int __fastcall func4(char *s, unsigned __int8 *a2, __int64 a3)
{
char *v3; // rbx
char *v5; // r12
__int64 v6; // rdx
char *v7; // rdi
int result; // eax

v3 = s;
if ( a3 )
{
v5 = &s[3 * a3];
do
{
v6 = *a2;
v7 = v3;
v3 += 3;
++a2;
result = sprintf(v7, "%02x ", v6);
}
while ( v5 != v3 );
*v5 = 0;
}
else
{
*s = 0;
}
return result;
}

original_code:
void
to_hex( char* dest, const char* src, size_t n )
{
    while ( n-- )
    {
 sprintf( dest, "%02x ", (int)*((unsigned char *)src));
 dest += 3;
 src++;
    }
    *dest = 0;
}

canonical_original_code:
void to_hex(char *dest, char *src, unsigned long n)
{
    while ( n-- )
    {
 sprintf( dest, "%02x ", (int)*((unsigned char *)src));
 dest += 3;
 src++;
    }
    *dest = 0;
}

variable_types:
dest
char *

variable_types:
src
char *

variable_types:
n
unsigned long


decompiled_code:
__int64 __fastcall hash_string(_BYTE *a1)
{
int v1; // edx
__int64 result; // rax

v1 = (char)*a1;
for ( result = 0LL; *a1; v1 = (char)*a1 )
{
++a1;
result = (unsigned int)(v1 + 37 * result);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(_BYTE *a1)
{
int v1; // edx
__int64 result; // rax

v1 = (char)*a1;
for ( result = 0LL; *a1; v1 = (char)*a1 )
{
++a1;
result = (unsigned int)(v1 + 37 * result);
}
return result;
}

original_code:
static unsigned int hash_string(register const char *key)
{
    register unsigned int hash = 0;
    while(*key)
 hash = hash * 37 + *key++;
    return hash;
}

canonical_original_code:
static unsigned int hash_string(char *key)
{
    register unsigned int hash = 0;
    while(*key)
 hash = hash * 37 + *key++;
    return hash;
}

variable_types:
key
char *

variable_types:
hash
unsigned int

return_type: unsigned int


decompiled_code:
void __fastcall reset_hash_iterator(__int64 a1)
{
*(_DWORD *)(a1 + 16) = 0;
*(_QWORD *)(a1 + 24) = 0LL;
}

original_code:
void reset_hash_iterator(struct hash_table *tbl)
{
    tbl->iterator = 0;
    tbl->iterator_ptr = ((void *)0);
}

variable_types: struct hash_table { int ht_size; struct list_head { struct list_head *next; } *ht_lists; int iterator; struct list_head *iterator_ptr; } *

user_defined_types: struct hash_table { int ht_size; struct list_head *ht_lists; int iterator; struct list_head *iterator_ptr; }


original_code:
int put_hash_object_ex(struct hash_table *tbl, const char *key, void *obj, int copy,
         char ** oldkey, void ** oldobj)
{
    struct list_head *head;
    struct hash_entry *entry;
    unsigned int hash;
    int retval = 0;
    hash = hash_string(key) % tbl->ht_size;
    head = &tbl->ht_lists[hash];
    entry = scan_list(head, key);
    if (entry)
    {
 if (oldkey)
     *oldkey = entry->he_key;
 if (oldobj)
     *oldobj = entry->he_obj;
 if (!copy)
     entry->he_key = (char*)key;
 entry->he_obj = obj;
    }
    else
    {
 size_t s = sizeof(*entry);
 if (oldkey)
     *oldkey = ((void *)0);
 if (oldobj)
     *oldobj = ((void *)0);
 if (copy)
     s += strlen(key) + 1;
 entry = (struct hash_entry *)malloc(s);
 if (!entry)
 {
     debug(0x0002,"malloc failed put_hash_object key='%s'",key);
     retval = -1;
 }
 else
 {
     if (copy)
     {
  entry->he_key = (char *)(entry + 1);
  strcpy(entry->he_key, key);
     }
     else
     {
  entry->he_key = (char*)key;
     }
     entry->he_obj = obj;
     list_add(&entry->he_list, head);
 }
    }
    return retval;
}

canonical_original_code:
int put_hash_object_ex(struct hash_table *tbl, char *key, void *obj, int copy, char **oldkey, void **oldobj)
{
    struct list_head *head;
    struct hash_entry *entry;
    unsigned int hash;
    int retval = 0;
    hash = hash_string(key) % tbl->ht_size;
    head = &tbl->ht_lists[hash];
    entry = scan_list(head, key);
    if (entry)
    {
 if (oldkey)
     *oldkey = entry->he_key;
 if (oldobj)
     *oldobj = entry->he_obj;
 if (!copy)
     entry->he_key = (char *)key;
 entry->he_obj = obj;
    }
    else
    {
 unsigned long s = sizeof(*entry);
 if (oldkey)
     *oldkey = ((void *)0);
 if (oldobj)
     *oldobj = ((void *)0);
 if (copy)
     s += strlen(key) + 1;
 entry = (struct hash_entry *)malloc(s);
 if (!entry)
 {
     debug(0x0002,"malloc failed put_hash_object key='%s'",key);
     retval = -1;
 }
 else
 {
     if (copy)
     {
  entry->he_key = (char *)(entry + 1);
  strcpy(entry->he_key, key);
     }
     else
     {
  entry->he_key = (char *)key;
     }
     entry->he_obj = obj;
     list_add(&entry->he_list, head);
 }
    }
    return retval;
}

variable_types:
obj
void *

variable_types: copy int

variable_types:
oldkey
char **

variable_types:
oldobj
void **

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

variable_types: struct hash_entry { char *he_key; void *he_obj; struct list_head { struct list_head *next; } he_list; } *

variable_types: retval int

variable_types:
s
unsigned long

user_defined_types: struct hash_entry { char *he_key; void *he_obj; struct list_head he_list; }


decompiled_code:
__int64 __fastcall put_hash_object(__int64 a1, char *a2, __int64 a3)
{
__int64 v4; // [rsp+8h] [rbp-10h] BYREF

put_hash_object_ex(a1, a2, a3, 1, 0LL, &v4);
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, char *a2, __int64 a3)
{
__int64 v4; // [rsp+8h] [rbp-10h] BYREF

func9(a1, a2, a3, 1, 0LL, &v4);
return v4;
}

original_code:
void *put_hash_object(struct hash_table *tbl, const char *key, void *obj)
{
    void * retval;
    put_hash_object_ex(tbl, key, obj, HT_KEYCOPY, ((void *)0), &retval);
    return retval;
}

canonical_original_code:
void *put_hash_object(struct hash_table *tbl, char *key, void *obj)
{
    void *retval;
    put_hash_object_ex(tbl, key, obj, HT_KEYCOPY, ((void *)0), &retval);
    return retval;
}

variable_types:
retval
void *

user_defined_types: struct list_head { struct list_head *next; }


decompiled_code:
_BOOL8 __fastcall list_empty(_QWORD *a1)
{
return *a1 == (_QWORD)a1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(_QWORD *a1)
{
return *a1 == (_QWORD)a1;
}

original_code:
static __inline__ int list_empty(struct list_head *head)
{
        return head->next == head;
}