testimgdisplay

decompiled_code:
int __fastcall testimgdisplay(int *a1)
{
int v1; // er12
int result; // eax
int v3; // ebp
int v4; // er14
unsigned int v5; // ebx
int v6; // er15
int v7; // [rsp+Ch] [rbp-3Ch]

v1 = 0;
result = a1[1];
v3 = *a1;
v4 = a1[2];
v7 = result;
if ( result > 0 )
{
do
{
v5 = 0;
if ( v4 > 0 )
{
do
{
v6 = 0;
if ( v3 > 0 )
{
do
{
while ( (unsigned int)get_bit(a1, v5, v6, v1) )
{
++v6;
putchar(88);
if ( v3 == v6 )
goto LABEL_8;
}
++v6;
putchar(32);
}
while ( v3 != v6 );
}
LABEL_8:
++v5;
printf(" | ");
}
while ( v4 != v5 );
}
++v1;
result = putchar(10);
}
while ( v7 != v1 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func5(int *a1)
{
int v1; // er12
int result; // eax
int v3; // ebp
int v4; // er14
unsigned int v5; // ebx
int v6; // er15
int v7; // [rsp+Ch] [rbp-3Ch]

v1 = 0;
result = a1[1];
v3 = *a1;
v4 = a1[2];
v7 = result;
if ( result > 0 )
{
do
{
v5 = 0;
if ( v4 > 0 )
{
do
{
v6 = 0;
if ( v3 > 0 )
{
do
{
while ( (unsigned int)func1(a1, v5, v6, v1) )
{
++v6;
putchar(88);
if ( v3 == v6 )
goto LABEL_8;
}
++v6;
putchar(32);
}
while ( v3 != v6 );
}
LABEL_8:
++v5;
printf(" | ");
}
while ( v4 != v5 );
}
++v1;
result = putchar(10);
}
while ( v7 != v1 );
}
return result;
}

original_code:
void
testimgdisplay(struct image *img)
{
  char *data = img->imgdata;
  int iw = img->width;
  int ih = img->height;
  int imf = img->frames;
  int row, col, slate;
  for(row = 0; row < ih; row++){
    for(slate = 0; slate < imf; slate++){
      for(col = 0; col < iw; col++){
 int c = get_bit(img,slate,col,row);
 if(c != 0){
   printf("X");
 } else
   {
     printf(" ");
   }
      }
      printf(" | ");
    }
    printf("\n");
  }
  return;
}

canonical_original_code:
void testimgdisplay(struct image *img)
{
  char *data = img->imgdata;
  int iw = img->width;
  int ih = img->height;
  int imf = img->frames;
  int row; int col; int slate;
  for(row = 0; row < ih; row++){
    for(slate = 0; slate < imf; slate++){
      for(col = 0; col < iw; col++){
 int c = get_bit(img,slate,col,row);
 if(c != 0){
   printf("X");
 } else
   {
     printf(" ");
   }
      }
      printf(" | ");
    }
    printf("\n");
  }
  return;
}

variable_types: row int

variable_types: col int

variable_types: slate int

variable_types: c int


dshifttop

repo: kkopiec/kamikaze

decompiled_code:
void __fastcall dshifttop(int *a1)
{
unsigned int v1; // ebx
int v2; // er14
int v3; // er13
int v4; // er15
int v5; // er12
int v6; // edx

v1 = 0;
v2 = a1[2];
v3 = *a1;
if ( v2 > 0 )
{
do
{
v4 = 0;
if ( v3 > 0 )
{
LABEL_3:
while ( 2 )
{
v5 = 7;
while ( !(unsigned int)get_bit(a1, v1, v4, v5) )
{
if ( !--v5 )
{
if ( v3 != ++v4 )
goto LABEL_3;
goto LABEL_7;
}
}
v6 = v4++;
set_bit(a1, v1, v6, v5, 0);
if ( v3 != v4 )
continue;
break;
}
}
LABEL_7:
++v1;
}
while ( v2 != v1 );
}
}

canonical_decompiled_code:
void __fastcall func6(int *a1)
{
unsigned int v1; // ebx
int v2; // er14
int v3; // er13
int v4; // er15
int v5; // er12
int v6; // edx

v1 = 0;
v2 = a1[2];
v3 = *a1;
if ( v2 > 0 )
{
do
{
v4 = 0;
if ( v3 > 0 )
{
LABEL_3:
while ( 2 )
{
v5 = 7;
while ( !(unsigned int)func1(a1, v1, v4, v5) )
{
if ( !--v5 )
{
if ( v3 != ++v4 )
goto LABEL_3;
goto LABEL_7;
}
}
v6 = v4++;
func0(a1, v1, v6, v5, 0);
if ( v3 != v4 )
continue;
break;
}
}
LABEL_7:
++v1;
}
while ( v2 != v1 );
}
}

original_code:
void
dshifttop (struct image* img)
{
  char *data = img->imgdata;
  int iw = img->width;
  int ih = img->height;
  int imf = img->frames;
  int bufsize = iw*ih*imf;
  int w,h;
  int frame,col,row;
  for (frame = 0; frame < imf; frame++){
    for(col = 0; col < iw; col++){
      for(row = 7; row > 0 ; row--){
 int c;
 if((c= get_bit(img, frame,col,row)) != 0){
     set_bit(img, frame, col,row,0);
     break;
   }
      }
    }
  }
  return;
}

canonical_original_code:
void dshifttop(struct image *img)
{
  char *data = img->imgdata;
  int iw = img->width;
  int ih = img->height;
  int imf = img->frames;
  int bufsize = iw*ih*imf;
  int w; int h;
  int frame; int col; int row;
  for (frame = 0; frame < imf; frame++){
    for(col = 0; col < iw; col++){
      for(row = 7; row > 0 ; row--){
 int c;
 if((c= get_bit(img, frame,col,row)) != 0){
     set_bit(img, frame, col,row,0);
     break;
   }
      }
    }
  }
  return;
}

variable_types: struct image { int width; int height; int frames; char *imgdata; } *

variable_types:
data
char *

variable_types: iw int

variable_types: ih int

variable_types: imf int

variable_types: bufsize int

variable_types: w int

variable_types: h int

variable_types: frame int

return_type: void


fallingEdge

decompiled_code:
__int64 __fastcall fallingEdge(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 v3; // rcx
__int64 v4; // rdx
__int64 result; // rax
int v6; // eax

v2 = 0LL;
dshifttop();
rshift(a1);
do
{
v6 = *(_DWORD *)(a2 + 4 * v2);
if ( v6 >= 0 )
{
if ( v6 > 7 )
*(_DWORD *)(a2 + 4 * v2) = 7;
}
else
{
*(_DWORD *)(a2 + 4 * v2) = 0;
}
clear_column(a1, 0LL, (unsigned int)v2);
v3 = *(unsigned int *)(a2 + 4 * v2);
v4 = (unsigned int)v2++;
result = set_column(a1, 0LL, v4, v3);
}
while ( v2 != 8 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 v3; // rcx
__int64 v4; // rdx
__int64 result; // rax
int v6; // eax

v2 = 0LL;
dshifttop();
rshift(a1);
do
{
v6 = *(_DWORD *)(a2 + 4 * v2);
if ( v6 >= 0 )
{
if ( v6 > 7 )
*(_DWORD *)(a2 + 4 * v2) = 7;
}
else
{
*(_DWORD *)(a2 + 4 * v2) = 0;
}
clear_column(a1, 0LL, (unsigned int)v2);
v3 = *(unsigned int *)(a2 + 4 * v2);
v4 = (unsigned int)v2++;
result = set_column(a1, 0LL, v4, v3);
}
while ( v2 != 8 );
return result;
}

original_code:
void
fallingEdge(struct image *img, int *mag, int size)
{
  dshifttop(img);
  rshift(img);
  int i;
  for(i = 0 ; i < 8 ; i++){
    if(mag[i] <0)
      mag[i] = 0;
    if(mag[i] >7)
      mag[i] = 7;
    clear_column(img,0,i);
    set_column(img,0,i,mag[i]);
  }
  return;
}

variable_types:
mag
int *

variable_types: size int

variable_types: i int

user_defined_types: struct image { int width; int height; int frames; char *imgdata; }


plainDb

decompiled_code:
__int64 __fastcall plainDb(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 v3; // rcx
__int64 v4; // rdx
__int64 result; // rax
int v6; // eax

v2 = 0LL;
rshift(a1);
do
{
v6 = *(_DWORD *)(a2 + 4 * v2);
if ( v6 >= 0 )
{
if ( v6 > 7 )
*(_DWORD *)(a2 + 4 * v2) = 7;
}
else
{
*(_DWORD *)(a2 + 4 * v2) = 0;
}
clear_column(a1, 0LL, (unsigned int)v2);
v3 = *(unsigned int *)(a2 + 4 * v2);
v4 = (unsigned int)v2++;
result = set_column(a1, 0LL, v4, v3);
}
while ( v2 != 8 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 v3; // rcx
__int64 v4; // rdx
__int64 result; // rax
int v6; // eax

v2 = 0LL;
rshift(a1);
do
{
v6 = *(_DWORD *)(a2 + 4 * v2);
if ( v6 >= 0 )
{
if ( v6 > 7 )
*(_DWORD *)(a2 + 4 * v2) = 7;
}
else
{
*(_DWORD *)(a2 + 4 * v2) = 0;
}
clear_column(a1, 0LL, (unsigned int)v2);
v3 = *(unsigned int *)(a2 + 4 * v2);
v4 = (unsigned int)v2++;
result = set_column(a1, 0LL, v4, v3);
}
while ( v2 != 8 );
return result;
}

original_code:
void
plainDb(struct image *img, int *mag, int size)
{
  rshift(img);
  int i;
  for(i = 0 ; i < 8 ; i++){
    if(mag[i] <0)
      mag[i] = 0;
    if(mag[i] >7)
      mag[i] = 7;
    clear_column(img,0,i);
    set_column(img,0,i,mag[i]);
  }
  return;
}


openSerial

decompiled_code:
__int64 __fastcall openSerial(const char *a1)
{
int v1; // eax
__m128i v2; // xmm0
__m128i v3; // xmm1
__m128i v4; // xmm2
speed_t v5; // eax
size_t v7; // rdx
const char *v8; // rdi
FILE *v9; // rcx

v1 = open(a1, 2306);
fdsl = v1;
if ( v1 == -1 )
{
fprintf(stderr, "cannoct open serial line %s\n", a1);
exit(-1);
}
fcntl(v1, 4, 0LL);
if ( tcgetattr(fdsl, &tty) < 0 )
{
v7 = 29LL;
v8 = "Cannot read port attributes!\n";
v9 = stderr;
LABEL_9:
fwrite(v8, 1uLL, v7, v9);
close(fdsl);
exit(-1);
}
v2 = _mm_load_si128((const __m128i *)&tty);
v3 = _mm_load_si128((const __m128i *)&tty.c_line);
v4 = _mm_load_si128((const __m128i *)&tty.c_cc[15]);
*(_QWORD *)&orig_tty.c_cc[31] = *(_QWORD *)&tty.c_cc[31];
v5 = tty.c_ospeed;
*(__m128i *)&orig_tty.c_iflag = v2;
orig_tty.c_ospeed = v5;
*(__m128i *)&orig_tty.c_line = v3;
*(__m128i *)&orig_tty.c_cc[15] = v4;
cfmakeraw(&tty);
if ( cfsetospeed(&tty, 0x1002u) == -1 )
{
v7 = 37LL;
v8 = "cannot set desired speed of the line\n";
v9 = stderr;
goto LABEL_9;
}
if ( tcsetattr(fdsl, 2, &tty) < 0 )
{
fprintf(stderr, "Cannot set raw terminal on %s\n", a1);
close(fdsl);
exit(-1);
}
sleep(1u);
return (unsigned int)fdsl;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
int v1; // eax
__m128i v2; // xmm0
__m128i v3; // xmm1
__m128i v4; // xmm2
speed_t v5; // eax
size_t v7; // rdx
const char *v8; // rdi
FILE *v9; // rcx

v1 = open(a1, 2306);
fdsl = v1;
if ( v1 == -1 )
{
fprintf(stderr, "cannoct open serial line %s\n", a1);
exit(-1);
}
fcntl(v1, 4, 0LL);
if ( tcgetattr(fdsl, &tty) < 0 )
{
v7 = 29LL;
v8 = "Cannot read port attributes!\n";
v9 = stderr;
LABEL_9:
fwrite(v8, 1uLL, v7, v9);
close(fdsl);
exit(-1);
}
v2 = _mm_load_si128((const __m128i *)&tty);
v3 = _mm_load_si128((const __m128i *)&tty.c_line);
v4 = _mm_load_si128((const __m128i *)&tty.c_cc[15]);
*(_QWORD *)&orig_tty.c_cc[31] = *(_QWORD *)&tty.c_cc[31];
v5 = tty.c_ospeed;
*(__m128i *)&orig_tty.c_iflag = v2;
orig_tty.c_ospeed = v5;
*(__m128i *)&orig_tty.c_line = v3;
*(__m128i *)&orig_tty.c_cc[15] = v4;
cfmakeraw(&tty);
if ( cfsetospeed(&tty, 0x1002u) == -1 )
{
v7 = 37LL;
v8 = "cannot set desired speed of the line\n";
v9 = stderr;
goto LABEL_9;
}
if ( tcsetattr(fdsl, 2, &tty) < 0 )
{
fprintf(stderr, "Cannot set raw terminal on %s\n", a1);
close(fdsl);
exit(-1);
}
sleep(1u);
return (unsigned int)fdsl;
}

original_code:
int openSerial(char* dev_path)
{
  if((fdsl = open(dev_path, 02|0400|04000)) == -1){
    fprintf(stderr, "cannoct open serial line %s\n",dev_path);
    exit(-1);
  }
  fcntl(fdsl, 4, 0);
  if ((tcgetattr(fdsl, &tty) < 0)){
    fprintf(stderr,"Cannot read port attributes!\n");
    close(fdsl);
    exit(-1);
  }
  orig_tty = tty;
  cfmakeraw(&tty);
  if((cfsetospeed (&tty, 0010002)) ==-1){
    fprintf(stderr, "cannot set desired speed of the line\n");
    close(fdsl);
    exit(-1);
  }
  if (tcsetattr(fdsl, 2, &tty) < 0){
    fprintf(stderr, "Cannot set raw terminal on %s\n",dev_path);
    close(fdsl);
    exit (-1);
  }
  sleep(1);
  return fdsl;
}

canonical_original_code:
int openSerial(char *dev_path)
{
  if((fdsl = open(dev_path, 02|0400|04000)) == -1){
    fprintf(stderr, "cannoct open serial line %s\n",dev_path);
    exit(-1);
  }
  fcntl(fdsl, 4, 0);
  if ((tcgetattr(fdsl, &tty) < 0)){
    fprintf(stderr,"Cannot read port attributes!\n");
    close(fdsl);
    exit(-1);
  }
  orig_tty = tty;
  cfmakeraw(&tty);
  if((cfsetospeed (&tty, 0010002)) ==-1){
    fprintf(stderr, "cannot set desired speed of the line\n");
    close(fdsl);
    exit(-1);
  }
  if (tcsetattr(fdsl, 2, &tty) < 0){
    fprintf(stderr, "Cannot set raw terminal on %s\n",dev_path);
    close(fdsl);
    exit (-1);
  }
  sleep(1);
  return fdsl;
}

return_type: int


closeSerial

decompiled_code:
int __fastcall closeSerial(int fd)
{
if ( tcsetattr(fd, 2, &orig_tty) < 0 )
{
fwrite("Cannot set back terminal on /dev/ttyACM0\n", 1uLL, 0x29uLL, stderr);
close(fdsl);
exit(-1);
}
return close(fd);
}

canonical_decompiled_code:
int __fastcall func1(int fd)
{
if ( tcsetattr(fd, 2, &orig_tty) < 0 )
{
fwrite("Cannot set back terminal on /dev/ttyACM0\n", 1uLL, 0x29uLL, stderr);
close(fdsl);
exit(-1);
}
return close(fd);
}

original_code:
void closeSerial(int dev)
{
  if (tcsetattr(dev, 2, &orig_tty) < 0){
    fprintf(stderr, "Cannot set back terminal on /dev/ttyACM0\n");
    close(fdsl);
    exit(-1);
  }
  close(dev);
}

variable_types: dev int


sendData

decompiled_code:
void __fastcall sendData(void *buf, int a2, int a3)
{
char *v4; // rbx

if ( a2 > 0 )
{
v4 = (char *)buf;
do
{
if ( (unsigned int)write(a3, v4, 8uLL) != 8 )
{
fwrite("something wrong went with writting!\n", 1uLL, 0x24uLL, stderr);
close(a3);
exit(-1);
}
v4 += 8;
}
while ( v4 != (char *)buf + 8 * ((unsigned int)(a2 - 1) >> 3) + 8 );
}
}

canonical_decompiled_code:
void __fastcall func2(void *buf, int a2, int a3)
{
char *v4; // rbx

if ( a2 > 0 )
{
v4 = (char *)buf;
do
{
if ( (unsigned int)write(a3, v4, 8uLL) != 8 )
{
fwrite("something wrong went with writting!\n", 1uLL, 0x24uLL, stderr);
close(a3);
exit(-1);
}
v4 += 8;
}
while ( v4 != (char *)buf + 8 * ((unsigned int)(a2 - 1) >> 3) + 8 );
}
}

original_code:
int sendData(unsigned char *data, int size, int dev)
{
  int g = 0;
  int w = 0;
  unsigned char *test = data;
  while(g < size){
    g+=8;
    if ((w = write(dev, test, 8)) != 8){
      fprintf(stderr, "something wrong went with writting!\n");
      close(dev);
      exit (-1);
    }
    test+=8;
  }
}

variable_types:
data
unsigned char *

variable_types: g int

variable_types:
test
unsigned char *


repo: kkpattern/CTCI

original_code:
int set_of_stacks_push(SetOfStacks *stacks, int value) {
  if (stacks->heads[stacks->current_stack] < stacks->max_stack_size) {
    int *current_stack = stacks->stacks[stacks->current_stack];
    size_t current_stack_head = stacks->heads[stacks->current_stack];
    current_stack[current_stack_head] = value;
    stacks->heads[stacks->current_stack] += 1;
  } else {
    if (stacks->current_stack >= stacks->stack_number-1) {
      size_t new_stack_number = stacks->stack_number*2;
      int **new_stacks = (int **) malloc(sizeof(int *) * new_stack_number);
      if (((void *)0) == new_stacks) return 1;
      size_t *new_heads = (size_t *) malloc(sizeof(size_t) * new_stack_number);
      if (((void *)0) == new_heads) {
        free(new_stacks);
        return 1;
      }
      memcpy(new_heads, stacks->heads, sizeof(size_t) * stacks->stack_number);
      memcpy(new_stacks, stacks->stacks, sizeof(int*) * stacks->stack_number);
      free(stacks->heads);
      free(stacks->stacks);
      stacks->stack_number = new_stack_number;
      stacks->heads = new_heads;
      stacks->stacks = new_stacks;
    }
    int *new_stack = (int *) malloc(sizeof(int) * stacks->max_stack_size);
    if (((void *)0) == new_stack) return 1;
    new_stack[0] = value;
    stacks->current_stack += 1;
    stacks->heads[stacks->current_stack] = 1;
    stacks->stacks[stacks->current_stack] = new_stack;
  }
  return 0;
}

canonical_original_code:
int set_of_stacks_push(struct _SetOfStacks *stacks, int value) {
  if (stacks->heads[stacks->current_stack] < stacks->max_stack_size) {
    int *current_stack = stacks->stacks[stacks->current_stack];
    unsigned long current_stack_head = stacks->heads[stacks->current_stack];
    current_stack[current_stack_head] = value;
    stacks->heads[stacks->current_stack] += 1;
  } else {
    if (stacks->current_stack >= stacks->stack_number-1) {
      unsigned long new_stack_number = stacks->stack_number*2;
      int **new_stacks = (int **) malloc(sizeof(int *) * new_stack_number);
      if (((void *)0) == new_stacks) return 1;
      unsigned long *new_heads = (size_t *) malloc(sizeof(size_t) * new_stack_number);
      if (((void *)0) == new_heads) {
        free(new_stacks);
        return 1;
      }
      memcpy(new_heads, stacks->heads, sizeof(unsigned long) * stacks->stack_number);
      memcpy(new_stacks, stacks->stacks, sizeof(int *) * stacks->stack_number);
      free(stacks->heads);
      free(stacks->stacks);
      stacks->stack_number = new_stack_number;
      stacks->heads = new_heads;
      stacks->stacks = new_stacks;
    }
    int *new_stack = (int *) malloc(sizeof(int) * stacks->max_stack_size);
    if (((void *)0) == new_stack) return 1;
    new_stack[0] = value;
    stacks->current_stack += 1;
    stacks->heads[stacks->current_stack] = 1;
    stacks->stacks[stacks->current_stack] = new_stack;
  }
  return 0;
}

variable_types: struct _SetOfStacks { int **stacks; unsigned long stack_number; unsigned long current_stack; unsigned long max_stack_size; unsigned long *heads; } *

variable_types: value int


original_code:
int set_of_stacks_pop_at(SetOfStacks *stacks, size_t stack_number, int *value) {
  if (stack_number > stacks->current_stack) return 1;
  if (stacks->heads[stack_number] > 0) {
    size_t new_stack_head = stacks->heads[stack_number] - 1;
    *value = stacks->stacks[stack_number][new_stack_head];
    stacks->heads[stack_number] = new_stack_head;
  } else {
    return 1;
  }
  return 0;
}

canonical_original_code:
int set_of_stacks_pop_at(struct _SetOfStacks *stacks, unsigned long stack_number, int *value) {
  if (stack_number > stacks->current_stack) return 1;
  if (stacks->heads[stack_number] > 0) {
    unsigned long new_stack_head = stacks->heads[stack_number] - 1;
    *value = stacks->stacks[stack_number][new_stack_head];
    stacks->heads[stack_number] = new_stack_head;
  } else {
    return 1;
  }
  return 0;
}

variable_types:
value
int *

user_defined_types: struct _SetOfStacks { int **stacks; unsigned long stack_number; unsigned long current_stack; unsigned long max_stack_size; unsigned long *heads; }


original_code:
int set_of_stacks_pop(SetOfStacks *stacks, int *value) {
  if (stacks->current_stack == 0 &&
      stacks->heads[stacks->current_stack] == 0) {
    return 1;
  } else {
    if (stacks->heads[stacks->current_stack] == 0) {
      free(stacks->stacks[stacks->current_stack]);
      stacks->current_stack -= 1;
    }
    int new_stack_head = stacks->heads[stacks->current_stack] - 1;
    *value = stacks->stacks[stacks->current_stack][new_stack_head];
    stacks->heads[stacks->current_stack] = new_stack_head;
  }
  return 0;
}

canonical_original_code:
int set_of_stacks_pop(struct _SetOfStacks *stacks, int *value) {
  if (stacks->current_stack == 0 &&
      stacks->heads[stacks->current_stack] == 0) {
    return 1;
  } else {
    if (stacks->heads[stacks->current_stack] == 0) {
      free(stacks->stacks[stacks->current_stack]);
      stacks->current_stack -= 1;
    }
    int new_stack_head = stacks->heads[stacks->current_stack] - 1;
    *value = stacks->stacks[stacks->current_stack][new_stack_head];
    stacks->heads[stacks->current_stack] = new_stack_head;
  }
  return 0;
}


decompiled_code:
__int64 __fastcall set_of_stacks_free(void *ptr)
{
unsigned __int64 v2; // rbx
void *v3; // rdi

v2 = 0LL;
do
{
v3 = *(void **)(*(_QWORD *)ptr + 8 * v2++);
free(v3);
}
while ( *((_QWORD *)ptr + 2) >= v2 );
free(*(void **)ptr);
free(*((void **)ptr + 4));
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func10(void *ptr)
{
unsigned __int64 v2; // rbx
void *v3; // rdi

v2 = 0LL;
do
{
v3 = *(void **)(*(_QWORD *)ptr + 8 * v2++);
free(v3);
}
while ( *((_QWORD *)ptr + 2) >= v2 );
free(*(void **)ptr);
free(*((void **)ptr + 4));
free(ptr);
return 0LL;
}

original_code:
SetOfStacks *set_of_stacks_free(SetOfStacks *stacks) {
  for (size_t i = 0; i <= stacks->current_stack; ++i) {
    free(stacks->stacks[i]);
  }
  free(stacks->stacks);
  free(stacks->heads);
  free(stacks);
  return ((void *)0);
}

canonical_original_code:
struct _SetOfStacks *set_of_stacks_free(struct _SetOfStacks *stacks) {
  for (unsigned long i = 0; i <= stacks->current_stack; ++i) {
    free(stacks->stacks[i]);
  }
  free(stacks->stacks);
  free(stacks->heads);
  free(stacks);
  return ((void *)0);
}

variable_types:
stacks
struct _SetOfStacks *

variable_types:
i
unsigned long

return_type: struct _SetOfStacks { int **stacks; unsigned long stack_number; unsigned long current_stack; unsigned long max_stack_size; unsigned long *heads; } *


original_code:
int stacks_push(Stacks *stacks, int stack_id, int value) {
  if (stack_id < 1 || stack_id > stacks->stack_number) {
    return 1;
  }
  size_t insert_position =
    stacks->stack_head[stack_id-1]*stacks->stack_number+stack_id-1;
  if (insert_position >= stacks->stack_size) {
    size_t new_stack_size = 2*stacks->stack_size;
    int *new_stack = (int *) malloc(sizeof(int) * new_stack_size);
    if (((void *)0) == new_stack) return 2;
    memcpy(new_stack, stacks->stack, sizeof(int)*stacks->stack_size);
    free(stacks->stack);
    stacks->stack = new_stack;
    stacks->stack_size = new_stack_size;
  }
  stacks->stack[insert_position] = value;
  stacks->stack_head[stack_id-1] += 1;
  return 0;
}

canonical_original_code:
int stacks_push(struct _Stacks *stacks, int stack_id, int value) {
  if (stack_id < 1 || stack_id > stacks->stack_number) {
    return 1;
  }
  unsigned long insert_position = stacks->stack_head[stack_id-1]*stacks->stack_number+stack_id-1;
  if (insert_position >= stacks->stack_size) {
    unsigned long new_stack_size = 2*stacks->stack_size;
    int *new_stack = (int *) malloc(sizeof(int) * new_stack_size);
    if (((void *)0) == new_stack) return 2;
    memcpy(new_stack, stacks->stack, sizeof(int)*stacks->stack_size);
    free(stacks->stack);
    stacks->stack = new_stack;
    stacks->stack_size = new_stack_size;
  }
  stacks->stack[insert_position] = value;
  stacks->stack_head[stack_id-1] += 1;
  return 0;
}

variable_types: struct _Stacks { int *stack; unsigned long stack_number; unsigned long *stack_head; unsigned long stack_size; } *


original_code:
int stacks_pop(Stacks *stacks, int stack_id, int *value) {
  if (stack_id < 1 || stack_id > stacks->stack_number) {
    return 1;
  }
  size_t stack_head = stacks->stack_head[stack_id-1];
  if (0 == stack_head) return 2;
  size_t pop_position = (stack_head-1)*stacks->stack_number+stack_id-1;
  *value = stacks->stack[pop_position];
  stacks->stack_head[stack_id-1] -= 1;
  return 0;
}

canonical_original_code:
int stacks_pop(struct _Stacks *stacks, int stack_id, int *value) {
  if (stack_id < 1 || stack_id > stacks->stack_number) {
    return 1;
  }
  unsigned long stack_head = stacks->stack_head[stack_id-1];
  if (0 == stack_head) return 2;
  unsigned long pop_position = (stack_head-1)*stacks->stack_number+stack_id-1;
  *value = stacks->stack[pop_position];
  stacks->stack_head[stack_id-1] -= 1;
  return 0;
}

user_defined_types: struct _Stacks { int *stack; unsigned long stack_number; unsigned long *stack_head; unsigned long stack_size; }


decompiled_code:
__int64 __fastcall stacks_free(void *ptr)
{
free(*((void **)ptr + 2));
free(*(void **)ptr);
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func13(void *ptr)
{
free(*((void **)ptr + 2));
free(*(void **)ptr);
free(ptr);
return 0LL;
}

original_code:
Stacks *stacks_free(Stacks *stacks) {
  free(stacks->stack_head);
  free(stacks->stack);
  free(stacks);
  return ((void *)0);
}

canonical_original_code:
struct _Stacks *stacks_free(struct _Stacks *stacks) {
  free(stacks->stack_head);
  free(stacks->stack);
  free(stacks);
  return ((void *)0);
}

variable_types:
stacks
struct _Stacks *

return_type: struct _Stacks { int *stack; unsigned long stack_number; unsigned long *stack_head; unsigned long stack_size; } *


decompiled_code:
__int64 __fastcall stack_push(__int64 a1, int a2)
{
return stacks_push(a1, 1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, int a2)
{
return func11(a1, 1, a2);
}

original_code:
int stack_push(Stack *stack, int value) {
  return stacks_push(stack, 1, value);
}

canonical_original_code:
int stack_push(struct _Stacks *stack, int value) {
  return stacks_push(stack, 1, value);
}


decompiled_code:
__int64 __fastcall stack_pop(_QWORD *a1, _DWORD *a2)
{
return stacks_pop(a1, 1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func15(_QWORD *a1, _DWORD *a2)
{
return func12(a1, 1, a2);
}

original_code:
int stack_pop(Stack *stack, int *value) {
  return stacks_pop(stack, 1, value);
}

canonical_original_code:
int stack_pop(struct _Stacks *stack, int *value) {
  return stacks_pop(stack, 1, value);
}


decompiled_code:
// attributes: thunk
__int64 __fastcall stack_free(void *a1)
{
return stacks_free(a1);
}

canonical_decompiled_code:
__int64 __fastcall func16(void *a1)
{
return func13(a1);
}

original_code:
Stack *stack_free(Stack *stack) {
  return stacks_free(stack);
}

canonical_original_code:
struct _Stacks *stack_free(struct _Stacks *stack) {
  return stacks_free(stack);
}

variable_types:
stack
struct _Stacks *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // r12
unsigned int v4; // ebx
int v5; // ebp
unsigned int v6; // ebx
int v8; // ebx
int v10[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v10[0] = 0;
v3 = (void *)set_of_stacks_init(3LL, 10LL, envp);
if ( (unsigned int)set_of_stacks_pop(v3, v10) != 1 )
__assert_fail("1 == set_of_stacks_pop(stacks, &value)", "3.3.c", 0x99u, "main");
if ( (unsigned int)set_of_stacks_push(v3, 9LL) )
__assert_fail("0 == set_of_stacks_push(stacks, 9)", "3.3.c", 0x9Au, "main");
v4 = set_of_stacks_pop(v3, v10);
if ( v4 )
__assert_fail("0 == set_of_stacks_pop(stacks, &value)", "3.3.c", 0x9Bu, "main");
if ( v10[0] != 9 )
__assert_fail("9 == value", "3.3.c", 0x9Cu, "main");
do
{
if ( (unsigned int)set_of_stacks_push(v3, v4) )
__assert_fail("0 == set_of_stacks_push(stacks, i)", "3.3.c", 0x9Fu, "main");
++v4;
}
while ( v4 != 100 );
v5 = 99;
do
{
v6 = set_of_stacks_pop(v3, v10);
if ( v6 )
__assert_fail("0 == set_of_stacks_pop(stacks, &value)", "3.3.c", 0xA2u, "main");
if ( v10[0] != v5 )
__assert_fail("max_pushed-1-i == value", "3.3.c", 0xA3u, "main");
}
while ( v5-- != 0 );
if ( (unsigned int)set_of_stacks_pop(v3, v10) != 1 )
__assert_fail("1 == set_of_stacks_pop(stacks, &value)", "3.3.c", 0xA5u, "main");
do
{
if ( (unsigned int)set_of_stacks_push(v3, v6) )
__assert_fail("0 == set_of_stacks_push(stacks, i)", "3.3.c", 0xA8u, "main");
++v6;
}
while ( v6 != 11 );
if ( (unsigned int)set_of_stacks_pop_at(v3, 0LL, v10) )
__assert_fail("0 == set_of_stacks_pop_at(stacks, 0, &value)", "3.3.c", 0xAAu, "main");
if ( v10[0] != 9 )
__assert_fail("9 == value", "3.3.c", 0xABu, "main");
v8 = 10;
do
{
if ( (unsigned int)set_of_stacks_pop(v3, v10) )
__assert_fail("0 == set_of_stacks_pop(stacks, &value)", "3.3.c", 0xADu, "main");
--v8;
}
while ( v8 );
if ( (unsigned int)set_of_stacks_pop(v3, v10) != 1 )
__assert_fail("1 == set_of_stacks_pop(stacks, &value)", "3.3.c", 0xAFu, "main");
set_of_stacks_free(v3);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // r12
unsigned int v4; // ebx
int v5; // ebp
unsigned int v6; // ebx
int v8; // ebx
int v10[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v10[0] = 0;
v3 = (void *)set_of_stacks_init(3LL, 10LL, envp);
if ( (unsigned int)func9(v3, v10) != 1 )
__assert_fail("1 == set_of_stacks_pop(stacks, &value)", "3.3.c", 0x99u, "main");
if ( (unsigned int)func7(v3, 9LL) )
__assert_fail("0 == set_of_stacks_push(stacks, 9)", "3.3.c", 0x9Au, "main");
v4 = func9(v3, v10);
if ( v4 )
__assert_fail("0 == set_of_stacks_pop(stacks, &value)", "3.3.c", 0x9Bu, "main");
if ( v10[0] != 9 )
__assert_fail("9 == value", "3.3.c", 0x9Cu, "main");
do
{
if ( (unsigned int)func7(v3, v4) )
__assert_fail("0 == set_of_stacks_push(stacks, i)", "3.3.c", 0x9Fu, "main");
++v4;
}
while ( v4 != 100 );
v5 = 99;
do
{
v6 = func9(v3, v10);
if ( v6 )
__assert_fail("0 == set_of_stacks_pop(stacks, &value)", "3.3.c", 0xA2u, "main");
if ( v10[0] != v5 )
__assert_fail("max_pushed-1-i == value", "3.3.c", 0xA3u, "main");
}
while ( v5-- != 0 );
if ( (unsigned int)func9(v3, v10) != 1 )
__assert_fail("1 == set_of_stacks_pop(stacks, &value)", "3.3.c", 0xA5u, "main");
do
{
if ( (unsigned int)func7(v3, v6) )
__assert_fail("0 == set_of_stacks_push(stacks, i)", "3.3.c", 0xA8u, "main");
++v6;
}
while ( v6 != 11 );
if ( (unsigned int)func8(v3, 0LL, v10) )
__assert_fail("0 == set_of_stacks_pop_at(stacks, 0, &value)", "3.3.c", 0xAAu, "main");
if ( v10[0] != 9 )
__assert_fail("9 == value", "3.3.c", 0xABu, "main");
v8 = 10;
do
{
if ( (unsigned int)func9(v3, v10) )
__assert_fail("0 == set_of_stacks_pop(stacks, &value)", "3.3.c", 0xADu, "main");
--v8;
}
while ( v8 );
if ( (unsigned int)func9(v3, v10) != 1 )
__assert_fail("1 == set_of_stacks_pop(stacks, &value)", "3.3.c", 0xAFu, "main");
func10(v3);
return 0;
}

original_code:
int main() {
  size_t stack_size = 10;
  SetOfStacks *stacks = set_of_stacks_init(3, stack_size);
  int value = 0;
  ((1 == set_of_stacks_pop(stacks, &value)) ? (void) (0) : __assert_fail ("1 == set_of_stacks_pop(stacks, &value)", "3.3.c", 153, __extension__ __PRETTY_FUNCTION__));
  ((0 == set_of_stacks_push(stacks, 9)) ? (void) (0) : __assert_fail ("0 == set_of_stacks_push(stacks, 9)", "3.3.c", 154, __extension__ __PRETTY_FUNCTION__));
  ((0 == set_of_stacks_pop(stacks, &value)) ? (void) (0) : __assert_fail ("0 == set_of_stacks_pop(stacks, &value)", "3.3.c", 155, __extension__ __PRETTY_FUNCTION__));
  ((9 == value) ? (void) (0) : __assert_fail ("9 == value", "3.3.c", 156, __extension__ __PRETTY_FUNCTION__));
  const int max_pushed = 100;
  for (int i = 0; i < max_pushed; ++i) {
    ((0 == set_of_stacks_push(stacks, i)) ? (void) (0) : __assert_fail ("0 == set_of_stacks_push(stacks, i)", "3.3.c", 159, __extension__ __PRETTY_FUNCTION__));
  }
  for (int i = 0; i < max_pushed; ++i) {
    ((0 == set_of_stacks_pop(stacks, &value)) ? (void) (0) : __assert_fail ("0 == set_of_stacks_pop(stacks, &value)", "3.3.c", 162, __extension__ __PRETTY_FUNCTION__));
    ((max_pushed-1-i == value) ? (void) (0) : __assert_fail ("max_pushed-1-i == value", "3.3.c", 163, __extension__ __PRETTY_FUNCTION__));
  }
  ((1 == set_of_stacks_pop(stacks, &value)) ? (void) (0) : __assert_fail ("1 == set_of_stacks_pop(stacks, &value)", "3.3.c", 165, __extension__ __PRETTY_FUNCTION__));
  for (int i = 0; i < stack_size+1; ++i) {
    ((0 == set_of_stacks_push(stacks, i)) ? (void) (0) : __assert_fail ("0 == set_of_stacks_push(stacks, i)", "3.3.c", 168, __extension__ __PRETTY_FUNCTION__));
  }
  ((0 == set_of_stacks_pop_at(stacks, 0, &value)) ? (void) (0) : __assert_fail ("0 == set_of_stacks_pop_at(stacks, 0, &value)", "3.3.c", 170, __extension__ __PRETTY_FUNCTION__));
  ((9 == value) ? (void) (0) : __assert_fail ("9 == value", "3.3.c", 171, __extension__ __PRETTY_FUNCTION__));
  for (int i = 0; i < stack_size; ++i) {
    ((0 == set_of_stacks_pop(stacks, &value)) ? (void) (0) : __assert_fail ("0 == set_of_stacks_pop(stacks, &value)", "3.3.c", 173, __extension__ __PRETTY_FUNCTION__));
  }
  ((1 == set_of_stacks_pop(stacks, &value)) ? (void) (0) : __assert_fail ("1 == set_of_stacks_pop(stacks, &value)", "3.3.c", 175, __extension__ __PRETTY_FUNCTION__));
  stacks = set_of_stacks_free(stacks);
}

canonical_original_code:
int main() {
  unsigned long stack_size = 10;
  struct _SetOfStacks *stacks = set_of_stacks_init(3, stack_size);
  int value = 0;
  ((1 == set_of_stacks_pop(stacks, &value)) ? (void) (0) : __assert_fail ("1 == set_of_stacks_pop(stacks, &value)", "3.3.c", 153, __extension__ __PRETTY_FUNCTION__));
  ((0 == set_of_stacks_push(stacks, 9)) ? (void) (0) : __assert_fail ("0 == set_of_stacks_push(stacks, 9)", "3.3.c", 154, __extension__ __PRETTY_FUNCTION__));
  ((0 == set_of_stacks_pop(stacks, &value)) ? (void) (0) : __assert_fail ("0 == set_of_stacks_pop(stacks, &value)", "3.3.c", 155, __extension__ __PRETTY_FUNCTION__));
  ((9 == value) ? (void) (0) : __assert_fail ("9 == value", "3.3.c", 156, __extension__ __PRETTY_FUNCTION__));
  int max_pushed = 100;
  for (int i = 0; i < max_pushed; ++i) {
    ((0 == set_of_stacks_push(stacks, i)) ? (void) (0) : __assert_fail ("0 == set_of_stacks_push(stacks, i)", "3.3.c", 159, __extension__ __PRETTY_FUNCTION__));
  }
  for (int i = 0; i < max_pushed; ++i) {
    ((0 == set_of_stacks_pop(stacks, &value)) ? (void) (0) : __assert_fail ("0 == set_of_stacks_pop(stacks, &value)", "3.3.c", 162, __extension__ __PRETTY_FUNCTION__));
    ((max_pushed-1-i == value) ? (void) (0) : __assert_fail ("max_pushed-1-i == value", "3.3.c", 163, __extension__ __PRETTY_FUNCTION__));
  }
  ((1 == set_of_stacks_pop(stacks, &value)) ? (void) (0) : __assert_fail ("1 == set_of_stacks_pop(stacks, &value)", "3.3.c", 165, __extension__ __PRETTY_FUNCTION__));
  for (int i = 0; i < stack_size+1; ++i) {
    ((0 == set_of_stacks_push(stacks, i)) ? (void) (0) : __assert_fail ("0 == set_of_stacks_push(stacks, i)", "3.3.c", 168, __extension__ __PRETTY_FUNCTION__));
  }
  ((0 == set_of_stacks_pop_at(stacks, 0, &value)) ? (void) (0) : __assert_fail ("0 == set_of_stacks_pop_at(stacks, 0, &value)", "3.3.c", 170, __extension__ __PRETTY_FUNCTION__));
  ((9 == value) ? (void) (0) : __assert_fail ("9 == value", "3.3.c", 171, __extension__ __PRETTY_FUNCTION__));
  for (int i = 0; i < stack_size; ++i) {
    ((0 == set_of_stacks_pop(stacks, &value)) ? (void) (0) : __assert_fail ("0 == set_of_stacks_pop(stacks, &value)", "3.3.c", 173, __extension__ __PRETTY_FUNCTION__));
  }
  ((1 == set_of_stacks_pop(stacks, &value)) ? (void) (0) : __assert_fail ("1 == set_of_stacks_pop(stacks, &value)", "3.3.c", 175, __extension__ __PRETTY_FUNCTION__));
  stacks = set_of_stacks_free(stacks);
}


decompiled_code:
__int64 __fastcall compare_char(const void *a1, const void *a2)
{
return (unsigned int)(*(char *)a1 - *(char *)a2);
}

canonical_decompiled_code:
__int64 __fastcall func7(const void *a1, const void *a2)
{
return (unsigned int)(*(char *)a1 - *(char *)a2);
}

original_code:
int compare_char(const void *a, const void *b) {
  return *((char*)a) - *((char*)b);
}

canonical_original_code:
int compare_char(void *a, void *b) {
  return *((char *)a) - *((char *)b);
}

variable_types:
a
void *

variable_types:
b
void *


anagrams

decompiled_code:
__int64 __fastcall anagrams(void *src, void *a2)
{
size_t v2; // r14
char *v3; // rbp
size_t v4; // r14
unsigned int v5; // er13
char *v6; // r12
size_t v7; // rbx
__int64 v8; // rbx
const __int32_t *v9; // rcx
char *v10; // rax
__int64 v11; // rbx
const __int32_t *v12; // rcx
char *v13; // rax
size_t v14; // rax
size_t v15; // rax
char v16; // dl
__int64 v17; // rax

v2 = strlen((const char *)src) + 1;
v3 = (char *)malloc(v2);
memcpy(v3, src, v2);
v4 = strlen((const char *)a2) + 1;
v5 = 0;
v6 = (char *)malloc(v4);
memcpy(v6, a2, v4);
remove_spaces(v3);
remove_spaces(v6);
v7 = strlen(v3);
if ( v7 == strlen(v6) )
{
v8 = *v3;
if ( (_BYTE)v8 )
{
v9 = *__ctype_tolower_loc();
v10 = v3;
do
{
*v10++ = v9[v8];
v8 = *v10;
}
while ( (_BYTE)v8 );
}
v11 = *v6;
if ( (_BYTE)v11 )
{
v12 = *__ctype_tolower_loc();
v13 = v6;
do
{
*v13++ = v12[v11];
v11 = *v13;
}
while ( (_BYTE)v11 );
}
v14 = strlen(v3);
qsort(v3, v14, 1uLL, (__compar_fn_t)compare_char);
v15 = strlen(v6);
qsort(v6, v15, 1uLL, (__compar_fn_t)compare_char);
v16 = *v3;
if ( *v3 )
{
v17 = 0LL;
while ( v6[v17] == v16 )
{
v16 = v3[++v17];
if ( !v16 )
goto LABEL_15;
}
v5 = 0;
}
else
{
LABEL_15:
v5 = 1;
}
free(v6);
free(v3);
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func9(void *src, void *a2)
{
size_t v2; // r14
char *v3; // rbp
size_t v4; // r14
unsigned int v5; // er13
char *v6; // r12
size_t v7; // rbx
__int64 v8; // rbx
const __int32_t *v9; // rcx
char *v10; // rax
__int64 v11; // rbx
const __int32_t *v12; // rcx
char *v13; // rax
size_t v14; // rax
size_t v15; // rax
char v16; // dl
__int64 v17; // rax

v2 = strlen((const char *)src) + 1;
v3 = (char *)malloc(v2);
memcpy(v3, src, v2);
v4 = strlen((const char *)a2) + 1;
v5 = 0;
v6 = (char *)malloc(v4);
memcpy(v6, a2, v4);
func8(v3);
func8(v6);
v7 = strlen(v3);
if ( v7 == strlen(v6) )
{
v8 = *v3;
if ( (_BYTE)v8 )
{
v9 = *__ctype_tolower_loc();
v10 = v3;
do
{
*v10++ = v9[v8];
v8 = *v10;
}
while ( (_BYTE)v8 );
}
v11 = *v6;
if ( (_BYTE)v11 )
{
v12 = *__ctype_tolower_loc();
v13 = v6;
do
{
*v13++ = v12[v11];
v11 = *v13;
}
while ( (_BYTE)v11 );
}
v14 = strlen(v3);
qsort(v3, v14, 1uLL, (__compar_fn_t)compare_char);
v15 = strlen(v6);
qsort(v6, v15, 1uLL, (__compar_fn_t)compare_char);
v16 = *v3;
if ( *v3 )
{
v17 = 0LL;
while ( v6[v17] == v16 )
{
v16 = v3[++v17];
if ( !v16 )
goto LABEL_15;
}
v5 = 0;
}
else
{
LABEL_15:
v5 = 1;
}
free(v6);
free(v3);
}
return v5;
}

original_code:
_Bool anagrams(const char *a, const char *b) {
  char *aa = (char *) malloc(strlen(a)+1);
  strcpy(aa, a);
  char *bb = (char *) malloc(strlen(b)+1);
  strcpy(bb, b);
  remove_spaces(aa);
  remove_spaces(bb);
  size_t length_aa = strlen(aa);
  size_t length_bb = strlen(bb);
  if (length_aa != length_bb) return 0;
  for (char *c = aa; *c != '\0'; ++c) {
    *c = tolower(*c);
  }
  for (char *c = bb; *c != '\0'; ++c) {
    *c = tolower(*c);
  }
  qsort(aa, strlen(aa), sizeof(char), compare_char);
  qsort(bb, strlen(bb), sizeof(char), compare_char);
  _Bool result = 1;
  char *pa = aa;
  char *pb = bb;
  while (*pa != '\0') {
    if (*pa != *pb) {
      result = 0;
      break;
    }
    ++pa;
    ++pb;
  }
  free(bb);
  free(aa);
  return result;
}

canonical_original_code:
_Bool anagrams(char *a, char *b) {
  char *aa = (char *) malloc(strlen(a)+1);
  strcpy(aa, a);
  char *bb = (char *) malloc(strlen(b)+1);
  strcpy(bb, b);
  remove_spaces(aa);
  remove_spaces(bb);
  unsigned long length_aa = strlen(aa);
  unsigned long length_bb = strlen(bb);
  if (length_aa != length_bb) return 0;
  for (char *c = aa; *c != '\0'; ++c) {
    *c = tolower(*c);
  }
  for (char *c = bb; *c != '\0'; ++c) {
    *c = tolower(*c);
  }
  qsort(aa, strlen(aa), sizeof(char), compare_char);
  qsort(bb, strlen(bb), sizeof(char), compare_char);
  _Bool result = 1;
  char *pa = aa;
  char *pb = bb;
  while (*pa != '\0') {
    if (*pa != *pb) {
      result = 0;
      break;
    }
    ++pa;
    ++pb;
  }
  free(bb);
  free(aa);
  return result;
}

variable_types:
a
char *

variable_types:
b
char *

variable_types:
aa
char *

variable_types:
bb
char *

variable_types:
c
char *

variable_types:
pa
char *

variable_types:
pb
char *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
if ( !(unsigned __int8)anagrams("Abcd efg", "gf ecdba") )
__assert_fail("result == true", "1.4.c", 0x42u, "main");
if ( !(unsigned __int8)anagrams("", " ") )
__assert_fail("result == true", "1.4.c", 0x44u, "main");
if ( (unsigned __int8)anagrams("asfd34", "saf3") )
__assert_fail("result == false", "1.4.c", 0x46u, "main");
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
if ( !(unsigned __int8)func9("Abcd efg", "gf ecdba") )
__assert_fail("result == true", "1.4.c", 0x42u, "main");
if ( !(unsigned __int8)func9("", " ") )
__assert_fail("result == true", "1.4.c", 0x44u, "main");
if ( (unsigned __int8)func9("asfd34", "saf3") )
__assert_fail("result == false", "1.4.c", 0x46u, "main");
return 0;
}

original_code:
int main() {
  _Bool result = anagrams("Abcd efg", "gf ecdba");
  ((result == 1) ? (void) (0) : __assert_fail ("result == true", "1.4.c", 66, __extension__ __PRETTY_FUNCTION__));
  result = anagrams("", "  ");
  ((result == 1) ? (void) (0) : __assert_fail ("result == true", "1.4.c", 68, __extension__ __PRETTY_FUNCTION__));
  result = anagrams("asfd34", "saf3");
  ((result == 0) ? (void) (0) : __assert_fail ("result == false", "1.4.c", 70, __extension__ __PRETTY_FUNCTION__));
  return 0;
}


decompiled_code:
__int64 __fastcall all_unique_brute_force(char *a1)
{
char v1; // cl
char v2; // si
_BYTE *v3; // rdi
_BYTE *v4; // rdx
char v5; // al

v1 = *a1;
if ( *a1 )
{
v2 = a1[1];
v3 = a1 + 1;
if ( v2 )
{
do
{
v4 = v3;
v5 = v2;
do
{
if ( v5 == v1 )
return 0LL;
v5 = *++v4;
}
while ( v5 );
++v3;
v1 = v2;
v2 = *v3;
}
while ( *v3 );
}
}
return 1LL;
}

original_code:
_Bool all_unique_brute_force(const char *string) {
  for (const char *test_char = string; *test_char != '\0'; ++test_char) {
    for (const char *target_char = test_char+1;
        *target_char != '\0';
        ++target_char) {
      if (*test_char == *target_char) return 0;
    }
  }
  return 1;
}

canonical_original_code:
_Bool all_unique_brute_force(char *string) {
  for (char *test_char = string; *test_char != '\0'; ++test_char) {
    for (char *target_char = test_char+1;
        *target_char != '\0';
        ++target_char) {
      if (*test_char == *target_char) return 0;
    }
  }
  return 1;
}

variable_types:
string
char *


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rdx

if ( !(unsigned __int8)all_unique_brute_force("abcd", argv, envp) )
__assert_fail("result == true", "1.1.c", 0x16u, "main");
if ( (unsigned __int8)all_unique_brute_force("abb", argv, v3) )
__assert_fail("result == false", "1.1.c", 0x18u, "main");
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rdx

if ( !(unsigned __int8)func7("abcd", argv, envp) )
__assert_fail("result == true", "1.1.c", 0x16u, "main");
if ( (unsigned __int8)func7("abb", argv, v3) )
__assert_fail("result == false", "1.1.c", 0x18u, "main");
return 0;
}

original_code:
int main() {
  _Bool result = all_unique_brute_force("abcd");
  ((result == 1) ? (void) (0) : __assert_fail ("result == true", "1.1.c", 22, __extension__ __PRETTY_FUNCTION__));
  result = all_unique_brute_force("abb");
  ((result == 0) ? (void) (0) : __assert_fail ("result == false", "1.1.c", 24, __extension__ __PRETTY_FUNCTION__));
  return 0;
}


decompiled_code:
_BOOL8 __fastcall my_queue_enqueue(_QWORD *a1, unsigned int a2)
{
return (unsigned int)stacks_push(*a1, 1LL, a2) == 2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func7(_QWORD *a1, unsigned int a2)
{
return (unsigned int)func10(*a1, 1LL, a2) == 2;
}

original_code:
int my_queue_enqueue(MyQueue *queue, int value) {
  int result = stacks_push(queue->stacks, 1, value);
  if (2 == result) return 1;
  return 0;
}

canonical_original_code:
int my_queue_enqueue(struct _MyQueue *queue, int value) {
  int result = stacks_push(queue->stacks, 1, value);
  if (2 == result) return 1;
  return 0;
}

variable_types: struct _MyQueue { struct _Stacks { int *stack; unsigned long stack_number; unsigned long *stack_head; unsigned long stack_size; } *stacks; } *

variable_types: value int

variable_types: result int

user_defined_types: struct _MyQueue { struct _Stacks *stacks; }


decompiled_code:
__int64 __fastcall my_queue_dequeue(_QWORD *a1, __int64 a2)
{
int v2; // er8
__int64 result; // rax
int v4[7]; // [rsp+Ch] [rbp-1Ch] BYREF

while ( !(unsigned int)stacks_pop(*a1, 1LL, v4) )
stacks_push(*a1, 2LL, (unsigned int)v4[0]);
v2 = stacks_pop(*a1, 2LL, a2);
result = 1LL;
if ( v2 != 2 )
{
while ( !(unsigned int)stacks_pop(*a1, 2LL, v4) )
stacks_push(*a1, 1LL, (unsigned int)v4[0]);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(_QWORD *a1, __int64 a2)
{
int v2; // er8
__int64 result; // rax
int v4[7]; // [rsp+Ch] [rbp-1Ch] BYREF

while ( !(unsigned int)func11(*a1, 1LL, v4) )
func10(*a1, 2LL, (unsigned int)v4[0]);
v2 = func11(*a1, 2LL, a2);
result = 1LL;
if ( v2 != 2 )
{
while ( !(unsigned int)func11(*a1, 2LL, v4) )
func10(*a1, 1LL, (unsigned int)v4[0]);
result = 0LL;
}
return result;
}

original_code:
int my_queue_dequeue(MyQueue *queue, int *value) {
  int tmp;
  while (0 == stacks_pop(queue->stacks, 1, &tmp)) {
    stacks_push(queue->stacks, 2, tmp);
  }
  int result = stacks_pop(queue->stacks, 2, value);
  if (result == 2) return 1;
  while (0 == stacks_pop(queue->stacks, 2, &tmp)) {
    stacks_push(queue->stacks, 1, tmp);
  }
  return 0;
}

canonical_original_code:
int my_queue_dequeue(struct _MyQueue *queue, int *value) {
  int tmp;
  while (0 == stacks_pop(queue->stacks, 1, &tmp)) {
    stacks_push(queue->stacks, 2, tmp);
  }
  int result = stacks_pop(queue->stacks, 2, value);
  if (result == 2) return 1;
  while (0 == stacks_pop(queue->stacks, 2, &tmp)) {
    stacks_push(queue->stacks, 1, tmp);
  }
  return 0;
}

variable_types:
value
int *

variable_types: tmp int


decompiled_code:
__int64 __fastcall my_queue_free(void *ptr)
{
stacks_free(*(void **)ptr);
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(void *ptr)
{
func12(*(void **)ptr);
free(ptr);
return 0LL;
}

original_code:
MyQueue *my_queue_free(MyQueue *queue) {
  stacks_free(queue->stacks);
  free(queue);
  return ((void *)0);
}

canonical_original_code:
struct _MyQueue *my_queue_free(struct _MyQueue *queue) {
  stacks_free(queue->stacks);
  free(queue);
  return ((void *)0);
}

variable_types:
queue
struct _MyQueue *

return_type: struct _MyQueue { struct _Stacks { int *stack; unsigned long stack_number; unsigned long *stack_head; unsigned long stack_size; } *stacks; } *


variable_types: struct _Stacks { int *stack; unsigned long stack_number; unsigned long *stack_head; unsigned long stack_size; } *


canonical_decompiled_code:
__int64 __fastcall func12(void *ptr)
{
free(*((void **)ptr + 2));
free(*(void **)ptr);
free(ptr);
return 0LL;
}

variable_types:
stacks
struct _Stacks *


canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, int a2)
{
return func10(a1, 1, a2);
}


canonical_decompiled_code:
__int64 __fastcall func14(_QWORD *a1, _DWORD *a2)
{
return func11(a1, 1, a2);
}


canonical_decompiled_code:
__int64 __fastcall func15(void *a1)
{
return func12(a1);
}

variable_types:
stack
struct _Stacks *


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rbp
unsigned int v4; // ebx
__int64 v5; // rsi
int v7[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v7[0] = 0;
v3 = (void *)my_queue_init(10LL, argv, envp);
if ( (unsigned int)my_queue_dequeue(v3, v7) != 1 )
__assert_fail("1 == my_queue_dequeue(queue, &value)", "3.5.c", 0x46u, "main");
if ( (unsigned int)my_queue_enqueue(v3, 1LL) )
__assert_fail("0 == my_queue_enqueue(queue, 1)", "3.5.c", 0x48u, "main");
v4 = my_queue_dequeue(v3, v7);
if ( v4 )
__assert_fail("0 == my_queue_dequeue(queue, &value)", "3.5.c", 0x49u, "main");
if ( v7[0] != 1 )
__assert_fail("1 == value", "3.5.c", 0x4Au, "main");
do
{
v5 = v4++;
my_queue_enqueue(v3, v5);
}
while ( v4 != 5 );
do
{
if ( (unsigned int)my_queue_dequeue(v3, v7) )
__assert_fail("0 == my_queue_dequeue(queue, &value)", "3.5.c", 0x50u, "main");
--v4;
}
while ( v4 );
my_queue_free(v3);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rbp
unsigned int v4; // ebx
__int64 v5; // rsi
int v7[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v7[0] = 0;
v3 = (void *)my_queue_init(10LL, argv, envp);
if ( (unsigned int)func8(v3, v7) != 1 )
__assert_fail("1 == my_queue_dequeue(queue, &value)", "3.5.c", 0x46u, "main");
if ( (unsigned int)func7(v3, 1LL) )
__assert_fail("0 == my_queue_enqueue(queue, 1)", "3.5.c", 0x48u, "main");
v4 = func8(v3, v7);
if ( v4 )
__assert_fail("0 == my_queue_dequeue(queue, &value)", "3.5.c", 0x49u, "main");
if ( v7[0] != 1 )
__assert_fail("1 == value", "3.5.c", 0x4Au, "main");
do
{
v5 = v4++;
func7(v3, v5);
}
while ( v4 != 5 );
do
{
if ( (unsigned int)func8(v3, v7) )
__assert_fail("0 == my_queue_dequeue(queue, &value)", "3.5.c", 0x50u, "main");
--v4;
}
while ( v4 );
func9(v3);
return 0;
}

original_code:
int main() {
  MyQueue *queue = my_queue_init(10);
  int value = 0;
  ((1 == my_queue_dequeue(queue, &value)) ? (void) (0) : __assert_fail ("1 == my_queue_dequeue(queue, &value)", "3.5.c", 70, __extension__ __PRETTY_FUNCTION__));
  ((0 == my_queue_enqueue(queue, 1)) ? (void) (0) : __assert_fail ("0 == my_queue_enqueue(queue, 1)", "3.5.c", 72, __extension__ __PRETTY_FUNCTION__));
  ((0 == my_queue_dequeue(queue, &value)) ? (void) (0) : __assert_fail ("0 == my_queue_dequeue(queue, &value)", "3.5.c", 73, __extension__ __PRETTY_FUNCTION__));
  ((1 == value) ? (void) (0) : __assert_fail ("1 == value", "3.5.c", 74, __extension__ __PRETTY_FUNCTION__));
  for (int i = 0; i < 5; ++i) {
    my_queue_enqueue(queue, i);
  }
  for (int i = 0; i < 5; ++i) {
    ((0 == my_queue_dequeue(queue, &value)) ? (void) (0) : __assert_fail ("0 == my_queue_dequeue(queue, &value)", "3.5.c", 80, __extension__ __PRETTY_FUNCTION__));
  }
  my_queue_free(queue);
  return 0;
}

canonical_original_code:
int main() {
  struct _MyQueue *queue = my_queue_init(10);
  int value = 0;
  ((1 == my_queue_dequeue(queue, &value)) ? (void) (0) : __assert_fail ("1 == my_queue_dequeue(queue, &value)", "3.5.c", 70, __extension__ __PRETTY_FUNCTION__));
  ((0 == my_queue_enqueue(queue, 1)) ? (void) (0) : __assert_fail ("0 == my_queue_enqueue(queue, 1)", "3.5.c", 72, __extension__ __PRETTY_FUNCTION__));
  ((0 == my_queue_dequeue(queue, &value)) ? (void) (0) : __assert_fail ("0 == my_queue_dequeue(queue, &value)", "3.5.c", 73, __extension__ __PRETTY_FUNCTION__));
  ((1 == value) ? (void) (0) : __assert_fail ("1 == value", "3.5.c", 74, __extension__ __PRETTY_FUNCTION__));
  for (int i = 0; i < 5; ++i) {
    my_queue_enqueue(queue, i);
  }
  for (int i = 0; i < 5; ++i) {
    ((0 == my_queue_dequeue(queue, &value)) ? (void) (0) : __assert_fail ("0 == my_queue_dequeue(queue, &value)", "3.5.c", 80, __extension__ __PRETTY_FUNCTION__));
  }
  my_queue_free(queue);
  return 0;
}

variable_types: i int


decompiled_code:
__int64 __fastcall nodes_at_each_depth(__int64 *a1)
{
__int64 v1; // rbp
__int64 v3; // rbx
__int64 v4; // rax
__int64 v5; // rsi
__int64 v6; // rsi
__int64 v7[4]; // [rsp+8h] [rbp-20h] BYREF

v1 = *a1;
if ( !*a1 )
{
v3 = linked_list_append(0LL, 0LL);
while ( 1 )
{
v7[0] = 0LL;
linked_list_pop_head(v3, v7);
v1 = linked_list_append(v1, v7[0]);
v4 = v7[0];
v5 = *(_QWORD *)(v7[0] + 16);
if ( v5 )
{
linked_list_append(v3, v5);
v4 = v7[0];
}
v6 = *(_QWORD *)(v4 + 24);
if ( v6 )
linked_list_append(v3, v6);
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 *a1)
{
__int64 v1; // rbp
__int64 v3; // rbx
__int64 v4; // rax
__int64 v5; // rsi
__int64 v6; // rsi
__int64 v7[4]; // [rsp+8h] [rbp-20h] BYREF

v1 = *a1;
if ( !*a1 )
{
v3 = linked_list_append(0LL, 0LL);
while ( 1 )
{
v7[0] = 0LL;
linked_list_pop_head(v3, v7);
v1 = linked_list_append(v1, v7[0]);
v4 = v7[0];
v5 = *(_QWORD *)(v7[0] + 16);
if ( v5 )
{
linked_list_append(v3, v5);
v4 = v7[0];
}
v6 = *(_QWORD *)(v4 + 24);
if ( v6 )
linked_list_append(v3, v6);
}
}
return 0LL;
}

original_code:
LinkedList *nodes_at_each_depth(BinarySearchTree *tree) {
  LinkedList *nodes_list = ((void *)0);
  if (((void *)0) != tree->root) return ((void *)0);
  int current_nodes = 0;
  LinkedList *current_nodes_list = ((void *)0);
  current_nodes_list = linked_list_append(current_nodes_list, tree->root);
  ++current_nodes;
  while (current_nodes > 0) {
    LinkedList *nodes = ((void *)0);
    int new_nodes = 0;
    while (current_nodes > 0) {
      BinarySearchTreeNode *n = ((void *)0);
      linked_list_pop_head(current_nodes_list, (void **)&n);
      nodes = linked_list_append(nodes, n);
      if (((void *)0) != n->left) {
        linked_list_append(current_nodes_list, n->left);
        ++new_nodes;
      }
      if (((void *)0) != n->right) {
        linked_list_append(current_nodes_list, n->right);
        ++new_nodes;
      }
    }
    current_nodes = new_nodes;
    nodes_list = linked_list_append(nodes_list, nodes);
  }
  current_nodes_list = linked_list_free(current_nodes_list);
  return nodes_list;
}

canonical_original_code:
struct _LinkedList *nodes_at_each_depth(struct _BinarySearchTree *tree) {
  struct _LinkedList *nodes_list = ((void *)0);
  if (((void *)0) != tree->root) return ((void *)0);
  int current_nodes = 0;
  struct _LinkedList *current_nodes_list = ((void *)0);
  current_nodes_list = linked_list_append(current_nodes_list, tree->root);
  ++current_nodes;
  while (current_nodes > 0) {
    struct _LinkedList *nodes = ((void *)0);
    int new_nodes = 0;
    while (current_nodes > 0) {
      struct _BinarySearchTreeNode *n = ((void *)0);
      linked_list_pop_head(current_nodes_list, (void **)&n);
      nodes = linked_list_append(nodes, n);
      if (((void *)0) != n->left) {
        linked_list_append(current_nodes_list, n->left);
        ++new_nodes;
      }
      if (((void *)0) != n->right) {
        linked_list_append(current_nodes_list, n->right);
        ++new_nodes;
      }
    }
    current_nodes = new_nodes;
    nodes_list = linked_list_append(nodes_list, nodes);
  }
  current_nodes_list = linked_list_free(current_nodes_list);
  return nodes_list;
}

variable_types: struct _BinarySearchTree { struct _BinarySearchTreeNode { void *key; void *value; struct _BinarySearchTreeNode *left; struct _BinarySearchTreeNode *right; struct _BinarySearchTreeNode *parent; } *root; int (*key_compare)(void *a, void *b); int (*value_compare)(void *a, void *b); } *

variable_types: struct _LinkedList { struct _LinkedList *prev; struct _LinkedList *next; void *value; } *

user_defined_types: struct _BinarySearchTree { struct _BinarySearchTreeNode *root; int (*key_compare)(void *a, void *b); int (*value_compare)(void *a, void *b); }


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

if ( (unsigned __int64)(a2 + a1[1] - *a1) > a1[2] )
return 0LL;
result = a1[1];
a1[1] = result + a2;
return result;
}

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

if ( (unsigned __int64)(a2 + a1[1] - *a1) > a1[2] )
return 0LL;
result = a1[1];
a1[1] = result + a2;
return result;
}

original_code:
void *memory_pool_alloc(MemoryPool *pool, size_t size) {
  size_t used_size = (char *)pool->head - (char *)pool->pool;
  if (used_size + size > pool->size) return ((void *)0);
  void *result = pool->head;
  pool->head = (void *)((char *)pool->head + size);
  return result;
}

canonical_original_code:
void *memory_pool_alloc(struct _MemoryPool *pool, unsigned long size) {
  unsigned long used_size = (char *)pool->head - (char *)pool->pool;
  if (used_size + size > pool->size) return ((void *)0);
  void *result = pool->head;
  pool->head = (void *)((char *)pool->head + size);
  return result;
}

variable_types: struct _MemoryPool { void *pool; void *head; unsigned long size; } *

variable_types:
size
unsigned long

variable_types:
result
void *

return_type: void *


decompiled_code:
__int64 __fastcall memory_pool_free(void *ptr)
{
free(*(void **)ptr);
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(void *ptr)
{
free(*(void **)ptr);
free(ptr);
return 0LL;
}

original_code:
MemoryPool *memory_pool_free(MemoryPool *pool) {
  free(pool->pool);
  free(pool);
  return ((void *)0);
}

canonical_original_code:
struct _MemoryPool *memory_pool_free(struct _MemoryPool *pool) {
  free(pool->pool);
  free(pool);
  return ((void *)0);
}

variable_types:
pool
struct _MemoryPool *

return_type: struct _MemoryPool { void *pool; void *head; unsigned long size; } *


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

result = 0xFFFFFFFFLL;
if ( *a1 >= *a2 )
result = *a1 != *a2;
return result;
}

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

result = 0xFFFFFFFFLL;
if ( *a1 >= *a2 )
result = *a1 != *a2;
return result;
}

original_code:
int int_compare_by_pointer(void *pa, void *pb) {
  int a = *(int *)pa;
  int b = *(int *)pb;
  if (a < b) return -1;
  else if (a == b) return 0;
  else return 1;
}

variable_types:
pa
void *

variable_types:
pb
void *

variable_types: a int

variable_types: b int


decompiled_code:
void __fastcall binary_search_tree_node_free(void *ptr)
{
if ( ptr )
{
binary_search_tree_node_free(*((void **)ptr + 2));
binary_search_tree_node_free(*((void **)ptr + 3));
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func11(void *ptr)
{
if ( ptr )
{
func11(*((void **)ptr + 2));
func11(*((void **)ptr + 3));
free(ptr);
}
}

original_code:
BinarySearchTreeNode *binary_search_tree_node_free(BinarySearchTreeNode *node) {
  if (((void *)0) != node) {
    binary_search_tree_node_free(node->left);
    binary_search_tree_node_free(node->right);
    free(node);
  }
}

canonical_original_code:
struct _BinarySearchTreeNode *binary_search_tree_node_free(struct _BinarySearchTreeNode *node) {
  if (((void *)0) != node) {
    binary_search_tree_node_free(node->left);
    binary_search_tree_node_free(node->right);
    free(node);
  }
}

variable_types:
node
struct _BinarySearchTreeNode *

return_type: struct _BinarySearchTreeNode { void *key; void *value; struct _BinarySearchTreeNode *left; struct _BinarySearchTreeNode *right; struct _BinarySearchTreeNode *parent; } *


decompiled_code:
__int64 __fastcall binary_search_tree_insert(__int64 a1, __int64 a2, __int64 a3)
{
_QWORD *v3; // rax
_QWORD *v4; // r13
_QWORD *v5; // rbp
void **v6; // rbx
int v7; // eax
_QWORD *v8; // rdx
__int64 v9; // rcx
__int64 result; // rax

v3 = binary_search_tree_node_alloc(a2, a3);
if ( !v3 )
return 1LL;
v4 = *(_QWORD **)a1;
v5 = v3;
v6 = (void **)a1;
if ( *(_QWORD *)a1 )
{
while ( 1 )
{
v7 = (*(__int64 (__fastcall **)(_QWORD, _QWORD))(a1 + 8))(*v5, *v4);
if ( !v7 )
break;
v8 = *v6;
v9 = (__int64)*v6 + 16;
v6 = (void **)((char *)*v6 + 24);
if ( v7 < 0 )
v6 = (void **)v9;
v4 = *v6;
if ( !*v6 )
{
v4 = v8;
goto LABEL_9;
}
}
v4 = (_QWORD *)*((_QWORD *)*v6 + 4);
binary_search_tree_node_free(*v6);
*v6 = 0LL;
}
LABEL_9:
*v6 = v5;
result = 0LL;
v5[4] = v4;
return result;
}

original_code:
int binary_search_tree_insert(BinarySearchTree *tree, void *key, void *value) {
  BinarySearchTreeNode *new_node = binary_search_tree_node_alloc(key, value);
  if (((void *)0) == new_node) return 1;
  BinarySearchTreeNode **insert_position = &(tree->root);
  BinarySearchTreeNode *parent = ((void *)0);
  while (((void *)0) != *insert_position) {
    int compare_result = tree->key_compare(new_node->key,
                                           (*insert_position)->key);
    if (0 == compare_result) {
      parent = (*insert_position)->parent;
      binary_search_tree_node_free(*insert_position);
      *insert_position = ((void *)0);
    } else if (0 > compare_result) {
      parent = *insert_position;
      insert_position = &((*insert_position)->left);
    } else {
      parent = *insert_position;
      insert_position = &((*insert_position)->right);
    }
  }
  *insert_position = new_node;
  new_node->parent = parent;
  return 0;
}

canonical_original_code:
int binary_search_tree_insert(struct _BinarySearchTree *tree, void *key, void *value) {
  struct _BinarySearchTreeNode *new_node = binary_search_tree_node_alloc(key, value);
  if (((void *)0) == new_node) return 1;
  struct _BinarySearchTreeNode **insert_position = &(tree->root);
  struct _BinarySearchTreeNode *parent = ((void *)0);
  while (((void *)0) != *insert_position) {
    int compare_result = tree->key_compare(new_node->key,
                                           (*insert_position)->key);
    if (0 == compare_result) {
      parent = (*insert_position)->parent;
      binary_search_tree_node_free(*insert_position);
      *insert_position = ((void *)0);
    } else if (0 > compare_result) {
      parent = *insert_position;
      insert_position = &((*insert_position)->left);
    } else {
      parent = *insert_position;
      insert_position = &((*insert_position)->right);
    }
  }
  *insert_position = new_node;
  new_node->parent = parent;
  return 0;
}

variable_types:
key
void *

variable_types:
value
void *

variable_types: struct _BinarySearchTreeNode { void *key; void *value; struct _BinarySearchTreeNode *left; struct _BinarySearchTreeNode *right; struct _BinarySearchTreeNode *parent; } **


decompiled_code:
__int64 __fastcall binary_search_tree_find(__int64 a1, __int64 a2, _QWORD *a3)
{
_QWORD *v3; // rbx
_QWORD *v5; // rax
__int64 result; // rax
bool v7; // sf

v3 = *(_QWORD **)a1;
if ( !*(_QWORD *)a1 )
return 1LL;
while ( 1 )
{
result = (*(__int64 (__fastcall **)(__int64, _QWORD))(a1 + 8))(a2, *v3);
v7 = (int)result < 0;
if ( !(_DWORD)result )
break;
v5 = (_QWORD *)v3[2];
if ( !v7 )
v5 = (_QWORD *)v3[3];
v3 = v5;
if ( !v5 )
return 1LL;
}
*a3 = v3[1];
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2, _QWORD *a3)
{
_QWORD *v3; // rbx
_QWORD *v5; // rax
__int64 result; // rax
bool v7; // sf

v3 = *(_QWORD **)a1;
if ( !*(_QWORD *)a1 )
return 1LL;
while ( 1 )
{
result = (*(__int64 (__fastcall **)(__int64, _QWORD))(a1 + 8))(a2, *v3);
v7 = (int)result < 0;
if ( !(_DWORD)result )
break;
v5 = (_QWORD *)v3[2];
if ( !v7 )
v5 = (_QWORD *)v3[3];
v3 = v5;
if ( !v5 )
return 1LL;
}
*a3 = v3[1];
return result;
}

original_code:
int binary_search_tree_find(BinarySearchTree *tree, void *key, void **value) {
  int result = 1;
  BinarySearchTreeNode *test_node = tree->root;
  while (((void *)0) != test_node) {
    int compare_result = tree->key_compare(key, test_node->key);
    if (0 == compare_result) {
      *value = test_node->value;
      result = 0;
      break;
    } else if (0 > compare_result) {
      test_node = test_node->left;
    } else {
      test_node = test_node->right;
    }
  }
  return result;
}

canonical_original_code:
int binary_search_tree_find(struct _BinarySearchTree *tree, void *key, void **value) {
  int result = 1;
  struct _BinarySearchTreeNode *test_node = tree->root;
  while (((void *)0) != test_node) {
    int compare_result = tree->key_compare(key, test_node->key);
    if (0 == compare_result) {
      *value = test_node->value;
      result = 0;
      break;
    } else if (0 > compare_result) {
      test_node = test_node->left;
    } else {
      test_node = test_node->right;
    }
  }
  return result;
}

variable_types:
value
void **

variable_types: result int

variable_types: struct _BinarySearchTreeNode { void *key; void *value; struct _BinarySearchTreeNode *left; struct _BinarySearchTreeNode *right; struct _BinarySearchTreeNode *parent; } *


decompiled_code:
__int64 __fastcall binary_search_tree_free(void *ptr)
{
binary_search_tree_node_free(*(void **)ptr);
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func14(void *ptr)
{
func11(*(void **)ptr);
free(ptr);
return 0LL;
}

original_code:
BinarySearchTree *binary_search_tree_free(BinarySearchTree *tree) {
  tree->root = binary_search_tree_node_free(tree->root);
  free(tree);
  return ((void *)0);
}

canonical_original_code:
struct _BinarySearchTree *binary_search_tree_free(struct _BinarySearchTree *tree) {
  tree->root = binary_search_tree_node_free(tree->root);
  free(tree);
  return ((void *)0);
}

variable_types:
tree
struct _BinarySearchTree *

return_type: struct _BinarySearchTree { struct _BinarySearchTreeNode { void *key; void *value; struct _BinarySearchTreeNode *left; struct _BinarySearchTreeNode *right; struct _BinarySearchTreeNode *parent; } *root; int (*key_compare)(void *a, void *b); int (*value_compare)(void *a, void *b); } *


decompiled_code:
__int64 __fastcall singly_linked_list_free(void *ptr)
{
_QWORD *v1; // rbx
void *v2; // rdi

if ( !ptr )
return 0LL;
v1 = ptr;
do
{
v2 = v1;
v1 = (_QWORD *)*v1;
free(v2);
}
while ( v1 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func15(void *ptr)
{
_QWORD *v1; // rbx
void *v2; // rdi

if ( !ptr )
return 0LL;
v1 = ptr;
do
{
v2 = v1;
v1 = (_QWORD *)*v1;
free(v2);
}
while ( v1 );
return 0LL;
}

original_code:
SinglyLinkedList *singly_linked_list_free(SinglyLinkedList *list) {
  SinglyLinkedList *node = list;
  while (((void *)0) != node) {
    SinglyLinkedList *tmp = node->next;
    free(node);
    node = tmp;
  }
  return ((void *)0);
}

canonical_original_code:
struct _SinglyLinkedList *singly_linked_list_free(struct _SinglyLinkedList *list) {
  struct _SinglyLinkedList *node = list;
  while (((void *)0) != node) {
    struct _SinglyLinkedList *tmp = node->next;
    free(node);
    node = tmp;
  }
  return ((void *)0);
}

variable_types:
list
struct _SinglyLinkedList *

variable_types: struct _SinglyLinkedList { struct _SinglyLinkedList *next; int value; } *


decompiled_code:
int __fastcall singly_linked_list_print(__int64 **a1)
{
__int64 **v1; // rbx

if ( a1 )
{
v1 = a1;
do
{
printf("%d->", *((unsigned int *)v1 + 2));
v1 = (__int64 **)*v1;
}
while ( v1 );
}
return puts("NULL");
}

canonical_decompiled_code:
int __fastcall func16(__int64 **a1)
{
__int64 **v1; // rbx

if ( a1 )
{
v1 = a1;
do
{
printf("%d->", *((unsigned int *)v1 + 2));
v1 = (__int64 **)*v1;
}
while ( v1 );
}
return puts("NULL");
}

original_code:
void singly_linked_list_print(SinglyLinkedList *list) {
  SinglyLinkedList *node = list;
  while (((void *)0) != node) {
    printf("%d->", node->value);
    node = node->next;
  }
  printf("NULL\n");
}

canonical_original_code:
void singly_linked_list_print(struct _SinglyLinkedList *list) {
  struct _SinglyLinkedList *node = list;
  while (((void *)0) != node) {
    printf("%d->", node->value);
    node = node->next;
  }
  printf("NULL\n");
}

user_defined_types: struct _SinglyLinkedList { struct _SinglyLinkedList *next; int value; }


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

if ( !ptr )
return 0LL;
v1 = ptr;
do
{
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 1);
free(v2);
}
while ( v1 );
return 0LL;
}

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

if ( !ptr )
return 0LL;
v1 = ptr;
do
{
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 1);
free(v2);
}
while ( v1 );
return 0LL;
}

original_code:
LinkedList *linked_list_free(LinkedList *list) {
  LinkedList *node = list;
  while (((void *)0) != node) {
    LinkedList *tmp = node->next;
    free(node);
    node = tmp;
  }
  return ((void *)0);
}

canonical_original_code:
struct _LinkedList *linked_list_free(struct _LinkedList *list) {
  struct _LinkedList *node = list;
  while (((void *)0) != node) {
    struct _LinkedList *tmp = node->next;
    free(node);
    node = tmp;
  }
  return ((void *)0);
}

variable_types:
list
struct _LinkedList *

variable_types: struct _LinkedList { struct _LinkedList *prev; struct _LinkedList *next; void *value; } *


decompiled_code:
int __fastcall linked_list_print(__int64 a1)
{
__int64 v1; // rbx

if ( a1 )
{
v1 = a1;
do
{
printf("%d->", *(_QWORD *)(v1 + 16));
v1 = *(_QWORD *)(v1 + 8);
}
while ( v1 );
}
return puts("NULL");
}

original_code:
void linked_list_print(LinkedList *list) {
  LinkedList *node = list;
  while (((void *)0) != node) {
    printf("%d->", node->value);
    node = node->next;
  }
  printf("NULL\n");
}

canonical_original_code:
void linked_list_print(struct _LinkedList *list) {
  struct _LinkedList *node = list;
  while (((void *)0) != node) {
    printf("%d->", node->value);
    node = node->next;
  }
  printf("NULL\n");
}

user_defined_types: struct _LinkedList { struct _LinkedList *prev; struct _LinkedList *next; void *value; }


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // r12
void *v4; // rbp
void *v5; // rax

v3 = (void *)memory_pool_init(0x190uLL);
v4 = (void *)binary_search_tree_init(int_compare_by_pointer);
v5 = (void *)nodes_at_each_depth(v4);
linked_list_free(v5);
binary_search_tree_free(v4);
memory_pool_free(v3);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // r12
void *v4; // rbp
void *v5; // rax

v3 = (void *)memory_pool_init(0x190uLL);
v4 = (void *)binary_search_tree_init(int_compare_by_pointer);
v5 = (void *)func7(v4);
func17(v5);
func14(v4);
func9(v3);
return 0;
}

original_code:
int main() {
  MemoryPool *pool = memory_pool_init(sizeof(int)*100);
  BinarySearchTree *tree = binary_search_tree_init(int_compare_by_pointer,
                                                   int_compare_by_pointer);
  LinkedList *nodes_list = nodes_at_each_depth(tree);
  nodes_list = linked_list_free(nodes_list);
  tree = binary_search_tree_free(tree);
  memory_pool_free(pool);
  return 0;
}

canonical_original_code:
int main() {
  struct _MemoryPool *pool = memory_pool_init(sizeof(int)*100);
  struct _BinarySearchTree *tree = binary_search_tree_init(int_compare_by_pointer,
                                                   int_compare_by_pointer);
  struct _LinkedList *nodes_list = nodes_at_each_depth(tree);
  nodes_list = linked_list_free(nodes_list);
  tree = binary_search_tree_free(tree);
  memory_pool_free(pool);
  return 0;
}

variable_types: struct _MemoryPool { void *pool; void *head; unsigned long size; } *

variable_types: struct _BinarySearchTree { struct _BinarySearchTreeNode { void *key; void *value; struct _BinarySearchTreeNode *left; struct _BinarySearchTreeNode *right; struct _BinarySearchTreeNode *parent; } *root; int (*key_compare)(void *a, void *b); int (*value_compare)(void *a, void *b); } *


decompiled_code:
__int64 __fastcall delete_node(void **a1, __int64 a2)
{
void **v2; // rdx
void **v3; // rdi

v2 = a1;
v3 = (void **)*a1;
if ( !v3 )
delete_node_cold(0LL, a2, v2);
while ( 1 )
{
*((_DWORD *)v2 + 2) = *((_DWORD *)v3 + 2);
if ( !*v3 )
break;
v2 = v3;
v3 = (void **)*v3;
}
*v2 = 0LL;
return singly_linked_list_free(v3);
}

original_code:
void delete_node(SinglyLinkedList *node) {
  SinglyLinkedList *last_node = ((void *)0);
  while (((void *)0) != node->next) {
    node->value = node->next->value;
    last_node = node;
    node = node->next;
  }
  last_node->next = ((void *)0);
  singly_linked_list_free(node);
}

canonical_original_code:
void delete_node(struct _SinglyLinkedList *node) {
  struct _SinglyLinkedList *last_node = ((void *)0);
  while (((void *)0) != node->next) {
    node->value = node->next->value;
    last_node = node;
    node = node->next;
  }
  last_node->next = ((void *)0);
  singly_linked_list_free(node);
}


canonical_decompiled_code:
__int64 __fastcall func9(void *ptr)
{
_QWORD *v1; // rbx
void *v2; // rdi

if ( !ptr )
return 0LL;
v1 = ptr;
do
{
v2 = v1;
v1 = (_QWORD *)*v1;
free(v2);
}
while ( v1 );
return 0LL;
}

return_type: struct _SinglyLinkedList { struct _SinglyLinkedList *next; int value; } *


canonical_decompiled_code:
int __fastcall func10(__int64 **a1)
{
__int64 **v1; // rbx

if ( a1 )
{
v1 = a1;
do
{
printf("%d->", *((unsigned int *)v1 + 2));
v1 = (__int64 **)*v1;
}
while ( v1 );
}
return puts("NULL");
}


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

if ( !ptr )
return 0LL;
v1 = ptr;
do
{
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 1);
free(v2);
}
while ( v1 );
return 0LL;
}

return_type: struct _LinkedList { struct _LinkedList *prev; struct _LinkedList *next; void *value; } *


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

if ( (unsigned __int64)(a2 + a1[1] - *a1) > a1[2] )
return 0LL;
result = a1[1];
a1[1] = result + a2;
return result;
}

variable_types:
size
unsigned long

variable_types:
result
void *

user_defined_types: struct _MemoryPool { void *pool; void *head; unsigned long size; }


canonical_decompiled_code:
__int64 __fastcall func14(void *ptr)
{
free(*(void **)ptr);
free(ptr);
return 0LL;
}

variable_types:
pool
struct _MemoryPool *


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

result = 0xFFFFFFFFLL;
if ( *a1 >= *a2 )
result = *a1 != *a2;
return result;
}

canonical_original_code:
int int_compare_by_pointer(void *pa, void *pb) {
  int a = *(int *)pa;
  int b = *(int *)pb;
  if (a < b) return -1;
  else if (a == b) return 0;
  else return 1;
}

variable_types:
pa
void *

variable_types:
pb
void *

variable_types: a int

variable_types: b int


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rax
__int64 v4; // rdx
__int64 v5; // rax
__int64 v6; // rdx
__int64 v7; // rax
__int64 v8; // rdx
__int64 v9; // rax
__int64 v10; // rdx
_QWORD **v11; // rbp

v3 = singly_linked_list_append(0LL, 1LL, envp);
v5 = singly_linked_list_append(v3, 2LL, v4);
v7 = singly_linked_list_append(v5, 3LL, v6);
v9 = singly_linked_list_append(v7, 4LL, v8);
v11 = (_QWORD **)singly_linked_list_append(v9, 5LL, v10);
singly_linked_list_print(v11);
delete_node(**v11);
singly_linked_list_print(v11);
singly_linked_list_free(v11);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rax
__int64 v4; // rdx
__int64 v5; // rax
__int64 v6; // rdx
__int64 v7; // rax
__int64 v8; // rdx
__int64 v9; // rax
__int64 v10; // rdx
_QWORD **v11; // rbp

v3 = singly_linked_list_append(0LL, 1LL, envp);
v5 = singly_linked_list_append(v3, 2LL, v4);
v7 = singly_linked_list_append(v5, 3LL, v6);
v9 = singly_linked_list_append(v7, 4LL, v8);
v11 = (_QWORD **)singly_linked_list_append(v9, 5LL, v10);
func10(v11);
func8(**v11);
func10(v11);
func9(v11);
return 0;
}

original_code:
int main() {
  SinglyLinkedList *list = ((void *)0);
  list = singly_linked_list_append(list, 1);
  list = singly_linked_list_append(list, 2);
  list = singly_linked_list_append(list, 3);
  list = singly_linked_list_append(list, 4);
  list = singly_linked_list_append(list, 5);
  singly_linked_list_print(list);
  delete_node(list->next->next);
  singly_linked_list_print(list);
  singly_linked_list_free(list);
}

canonical_original_code:
int main() {
  struct _SinglyLinkedList *list = ((void *)0);
  list = singly_linked_list_append(list, 1);
  list = singly_linked_list_append(list, 2);
  list = singly_linked_list_append(list, 3);
  list = singly_linked_list_append(list, 4);
  list = singly_linked_list_append(list, 5);
  singly_linked_list_print(list);
  delete_node(list->next->next);
  singly_linked_list_print(list);
  singly_linked_list_free(list);
}


original_code:
int min_stack_push(MinStack *stack, int value) {
  if (stack->stack_head >= stack->stack_size) {
    size_t new_stack_size = 2*stack->stack_size;
    int *new_stack = (int *) malloc(sizeof(int)*new_stack_size);
    if (((void *)0) == new_stack) return 1;
    int *new_min_value = (int *) malloc(sizeof(int)*new_stack_size);
    if (((void *)0) == new_min_value) {
      free(new_stack);
      return 1;
    }
    memcpy(new_stack, stack->stack, sizeof(int)*stack->stack_size);
    memcpy(new_min_value, stack->min_value, sizeof(int)*stack->stack_size);
    free(stack->stack);
    free(stack->min_value);
    stack->stack = new_stack;
    stack->min_value = new_min_value;
    stack->stack_size = new_stack_size;
  }
  stack->stack[stack->stack_head] = value;
  if (0 == stack->stack_head) {
    stack->min_value[stack->stack_head] = value;
  } else {
    int last_min_value = stack->min_value[stack->stack_head-1];
    if (value < last_min_value) {
      stack->min_value[stack->stack_head] = value;
    } else {
      stack->min_value[stack->stack_head] = last_min_value;
    }
  }
  stack->stack_head += 1;
  return 0;
}

canonical_original_code:
int min_stack_push(struct _MinStack *stack, int value) {
  if (stack->stack_head >= stack->stack_size) {
    unsigned long new_stack_size = 2*stack->stack_size;
    int *new_stack = (int *) malloc(sizeof(int)*new_stack_size);
    if (((void *)0) == new_stack) return 1;
    int *new_min_value = (int *) malloc(sizeof(int)*new_stack_size);
    if (((void *)0) == new_min_value) {
      free(new_stack);
      return 1;
    }
    memcpy(new_stack, stack->stack, sizeof(int)*stack->stack_size);
    memcpy(new_min_value, stack->min_value, sizeof(int)*stack->stack_size);
    free(stack->stack);
    free(stack->min_value);
    stack->stack = new_stack;
    stack->min_value = new_min_value;
    stack->stack_size = new_stack_size;
  }
  stack->stack[stack->stack_head] = value;
  if (0 == stack->stack_head) {
    stack->min_value[stack->stack_head] = value;
  } else {
    int last_min_value = stack->min_value[stack->stack_head-1];
    if (value < last_min_value) {
      stack->min_value[stack->stack_head] = value;
    } else {
      stack->min_value[stack->stack_head] = last_min_value;
    }
  }
  stack->stack_head += 1;
  return 0;
}

variable_types: struct _MinStack { int *stack; int *min_value; unsigned long stack_size; unsigned long stack_head; } *

variable_types: value int


original_code:
int min_stack_pop(MinStack *stack, int *value) {
  if (0 == stack->stack_head) return 1;
  stack->stack_head -= 1;
  *value = stack->stack[stack->stack_head];
  return 0;
}

canonical_original_code:
int min_stack_pop(struct _MinStack *stack, int *value) {
  if (0 == stack->stack_head) return 1;
  stack->stack_head -= 1;
  *value = stack->stack[stack->stack_head];
  return 0;
}

variable_types:
value
int *

user_defined_types: struct _MinStack { int *stack; int *min_value; unsigned long stack_size; unsigned long stack_head; }


decompiled_code:
__int64 __fastcall min_stack_min(__int64 a1, _DWORD *a2)
{
__int64 v2; // rdx
__int64 result; // rax

v2 = *(_QWORD *)(a1 + 24);
result = 1LL;
if ( v2 )
{
*a2 = *(_DWORD *)(*(_QWORD *)(a1 + 8) + 4 * v2 - 4);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, _DWORD *a2)
{
__int64 v2; // rdx
__int64 result; // rax

v2 = *(_QWORD *)(a1 + 24);
result = 1LL;
if ( v2 )
{
*a2 = *(_DWORD *)(*(_QWORD *)(a1 + 8) + 4 * v2 - 4);
result = 0LL;
}
return result;
}

original_code:
int min_stack_min(MinStack *stack, int *value) {
  if (0 == stack->stack_head) return 1;
  *value = stack->min_value[stack->stack_head-1];
  return 0;
}

canonical_original_code:
int min_stack_min(struct _MinStack *stack, int *value) {
  if (0 == stack->stack_head) return 1;
  *value = stack->min_value[stack->stack_head-1];
  return 0;
}


decompiled_code:
__int64 __fastcall min_stack_free(void *ptr)
{
free(*(void **)ptr);
free(*((void **)ptr + 1));
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func10(void *ptr)
{
free(*(void **)ptr);
free(*((void **)ptr + 1));
free(ptr);
return 0LL;
}

original_code:
MinStack *min_stack_free(MinStack *stack) {
  free(stack->stack);
  free(stack->min_value);
  free(stack);
  return ((void *)0);
}

canonical_original_code:
struct _MinStack *min_stack_free(struct _MinStack *stack) {
  free(stack->stack);
  free(stack->min_value);
  free(stack);
  return ((void *)0);
}

variable_types:
stack
struct _MinStack *

return_type: struct _MinStack { int *stack; int *min_value; unsigned long stack_size; unsigned long stack_head; } *


original_code:
int stacks_push(Stacks *stacks, int stack_id, int value) {
  if (stack_id < 1 || stack_id > stacks->stack_number) {
    return 1;
  }
  size_t insert_position =
    stacks->stack_head[stack_id-1]*stacks->stack_number+stack_id-1;
  if (insert_position >= stacks->stack_size) {
    size_t new_stack_size = 2*stacks->stack_size;
    int *new_stack = (int *) malloc(sizeof(int) * new_stack_size);
    if (((void *)0) == new_stack) return 2;
    memcpy(new_stack, stacks->stack, sizeof(int)*stacks->stack_size);
    free(stacks->stack);
    stacks->stack = new_stack;
    stacks->stack_size = new_stack_size;
  }
  stacks->stack[insert_position] = value;
  stacks->stack_head[stack_id-1] += 1;
  return 0;
}

canonical_original_code:
int stacks_push(struct _Stacks *stacks, int stack_id, int value) {
  if (stack_id < 1 || stack_id > stacks->stack_number) {
    return 1;
  }
  unsigned long insert_position = stacks->stack_head[stack_id-1]*stacks->stack_number+stack_id-1;
  if (insert_position >= stacks->stack_size) {
    unsigned long new_stack_size = 2*stacks->stack_size;
    int *new_stack = (int *) malloc(sizeof(int) * new_stack_size);
    if (((void *)0) == new_stack) return 2;
    memcpy(new_stack, stacks->stack, sizeof(int)*stacks->stack_size);
    free(stacks->stack);
    stacks->stack = new_stack;
    stacks->stack_size = new_stack_size;
  }
  stacks->stack[insert_position] = value;
  stacks->stack_head[stack_id-1] += 1;
  return 0;
}

variable_types: struct _Stacks { int *stack; unsigned long stack_number; unsigned long *stack_head; unsigned long stack_size; } *


original_code:
int stacks_pop(Stacks *stacks, int stack_id, int *value) {
  if (stack_id < 1 || stack_id > stacks->stack_number) {
    return 1;
  }
  size_t stack_head = stacks->stack_head[stack_id-1];
  if (0 == stack_head) return 2;
  size_t pop_position = (stack_head-1)*stacks->stack_number+stack_id-1;
  *value = stacks->stack[pop_position];
  stacks->stack_head[stack_id-1] -= 1;
  return 0;
}

canonical_original_code:
int stacks_pop(struct _Stacks *stacks, int stack_id, int *value) {
  if (stack_id < 1 || stack_id > stacks->stack_number) {
    return 1;
  }
  unsigned long stack_head = stacks->stack_head[stack_id-1];
  if (0 == stack_head) return 2;
  unsigned long pop_position = (stack_head-1)*stacks->stack_number+stack_id-1;
  *value = stacks->stack[pop_position];
  stacks->stack_head[stack_id-1] -= 1;
  return 0;
}


decompiled_code:
__int64 __fastcall stacks_free(void *ptr)
{
free(*((void **)ptr + 2));
free(*(void **)ptr);
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func13(void *ptr)
{
free(*((void **)ptr + 2));
free(*(void **)ptr);
free(ptr);
return 0LL;
}

original_code:
Stacks *stacks_free(Stacks *stacks) {
  free(stacks->stack_head);
  free(stacks->stack);
  free(stacks);
  return ((void *)0);
}

canonical_original_code:
struct _Stacks *stacks_free(struct _Stacks *stacks) {
  free(stacks->stack_head);
  free(stacks->stack);
  free(stacks);
  return ((void *)0);
}

variable_types:
stacks
struct _Stacks *


decompiled_code:
__int64 __fastcall stack_push(__int64 a1, int a2)
{
return stacks_push(a1, 1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, int a2)
{
return func11(a1, 1, a2);
}

original_code:
int stack_push(Stack *stack, int value) {
  return stacks_push(stack, 1, value);
}

canonical_original_code:
int stack_push(struct _Stacks *stack, int value) {
  return stacks_push(stack, 1, value);
}


decompiled_code:
__int64 __fastcall stack_pop(_QWORD *a1, _DWORD *a2)
{
return stacks_pop(a1, 1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func15(_QWORD *a1, _DWORD *a2)
{
return func12(a1, 1, a2);
}

original_code:
int stack_pop(Stack *stack, int *value) {
  return stacks_pop(stack, 1, value);
}

canonical_original_code:
int stack_pop(struct _Stacks *stack, int *value) {
  return stacks_pop(stack, 1, value);
}


decompiled_code:
// attributes: thunk
__int64 __fastcall stack_free(void *a1)
{
return stacks_free(a1);
}

canonical_decompiled_code:
__int64 __fastcall func16(void *a1)
{
return func13(a1);
}

original_code:
Stack *stack_free(Stack *stack) {
  return stacks_free(stack);
}

canonical_original_code:
struct _Stacks *stack_free(struct _Stacks *stack) {
  return stacks_free(stack);
}

variable_types:
stack
struct _Stacks *


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rdi
int v5[3]; // [rsp+Ch] [rbp-Ch] BYREF

v5[0] = 0;
v3 = (void *)min_stack_init(1LL, argv, envp);
if ( (unsigned int)min_stack_pop(v3, v5) != 1 )
__assert_fail("1 == min_stack_pop(stack, &value)", "3.2.c", 0x79u, "main");
if ( (unsigned int)min_stack_min(v3, v5) != 1 )
__assert_fail("1 == min_stack_min(stack, &value)", "3.2.c", 0x7Au, "main");
if ( (unsigned int)min_stack_push(v3, 2LL) )
__assert_fail("0 == min_stack_push(stack, 2)", "3.2.c", 0x7Cu, "main");
if ( (unsigned int)min_stack_min(v3, v5) )
__assert_fail("0 == min_stack_min(stack, &value)", "3.2.c", 0x7Du, "main");
if ( v5[0] != 2 )
__assert_fail("2 == value", "3.2.c", 0x7Eu, "main");
if ( (unsigned int)min_stack_pop(v3, v5) )
__assert_fail("0 == min_stack_pop(stack, &value)", "3.2.c", 0x7Fu, "main");
if ( v5[0] != 2 )
__assert_fail("2 == value", "3.2.c", 0x80u, "main");
if ( (unsigned int)min_stack_push(v3, 2LL) )
__assert_fail("0 == min_stack_push(stack, 2)", "3.2.c", 0x82u, "main");
if ( (unsigned int)min_stack_push(v3, 1LL) )
__assert_fail("0 == min_stack_push(stack, 1)", "3.2.c", 0x83u, "main");
if ( (unsigned int)min_stack_min(v3, v5) )
__assert_fail("0 == min_stack_min(stack, &value)", "3.2.c", 0x84u, "main");
if ( v5[0] != 1 )
__assert_fail("1 == value", "3.2.c", 0x85u, "main");
if ( (unsigned int)min_stack_push(v3, 3LL) )
__assert_fail("0 == min_stack_push(stack, 3)", "3.2.c", 0x86u, "main");
if ( (unsigned int)min_stack_min(v3, v5) )
__assert_fail("0 == min_stack_min(stack, &value)", "3.2.c", 0x87u, "main");
if ( v5[0] != 1 )
__assert_fail("1 == value", "3.2.c", 0x88u, "main");
if ( (unsigned int)min_stack_push(v3, 0LL) )
__assert_fail("0 == min_stack_push(stack, 0)", "3.2.c", 0x89u, "main");
if ( (unsigned int)min_stack_min(v3, v5) )
__assert_fail("0 == min_stack_min(stack, &value)", "3.2.c", 0x8Au, "main");
if ( v5[0] )
__assert_fail("0 == value", "3.2.c", 0x8Bu, "main");
min_stack_free(v3);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rdi
int v5[3]; // [rsp+Ch] [rbp-Ch] BYREF

v5[0] = 0;
v3 = (void *)min_stack_init(1LL, argv, envp);
if ( (unsigned int)func8(v3, v5) != 1 )
__assert_fail("1 == min_stack_pop(stack, &value)", "3.2.c", 0x79u, "main");
if ( (unsigned int)func9(v3, v5) != 1 )
__assert_fail("1 == min_stack_min(stack, &value)", "3.2.c", 0x7Au, "main");
if ( (unsigned int)func7(v3, 2LL) )
__assert_fail("0 == min_stack_push(stack, 2)", "3.2.c", 0x7Cu, "main");
if ( (unsigned int)func9(v3, v5) )
__assert_fail("0 == min_stack_min(stack, &value)", "3.2.c", 0x7Du, "main");
if ( v5[0] != 2 )
__assert_fail("2 == value", "3.2.c", 0x7Eu, "main");
if ( (unsigned int)func8(v3, v5) )
__assert_fail("0 == min_stack_pop(stack, &value)", "3.2.c", 0x7Fu, "main");
if ( v5[0] != 2 )
__assert_fail("2 == value", "3.2.c", 0x80u, "main");
if ( (unsigned int)func7(v3, 2LL) )
__assert_fail("0 == min_stack_push(stack, 2)", "3.2.c", 0x82u, "main");
if ( (unsigned int)func7(v3, 1LL) )
__assert_fail("0 == min_stack_push(stack, 1)", "3.2.c", 0x83u, "main");
if ( (unsigned int)func9(v3, v5) )
__assert_fail("0 == min_stack_min(stack, &value)", "3.2.c", 0x84u, "main");
if ( v5[0] != 1 )
__assert_fail("1 == value", "3.2.c", 0x85u, "main");
if ( (unsigned int)func7(v3, 3LL) )
__assert_fail("0 == min_stack_push(stack, 3)", "3.2.c", 0x86u, "main");
if ( (unsigned int)func9(v3, v5) )
__assert_fail("0 == min_stack_min(stack, &value)", "3.2.c", 0x87u, "main");
if ( v5[0] != 1 )
__assert_fail("1 == value", "3.2.c", 0x88u, "main");
if ( (unsigned int)func7(v3, 0LL) )
__assert_fail("0 == min_stack_push(stack, 0)", "3.2.c", 0x89u, "main");
if ( (unsigned int)func9(v3, v5) )
__assert_fail("0 == min_stack_min(stack, &value)", "3.2.c", 0x8Au, "main");
if ( v5[0] )
__assert_fail("0 == value", "3.2.c", 0x8Bu, "main");
func10(v3);
return 0;
}

original_code:
int main() {
  MinStack *stack = min_stack_init(1);
  int value = 0;
  ((1 == min_stack_pop(stack, &value)) ? (void) (0) : __assert_fail ("1 == min_stack_pop(stack, &value)", "3.2.c", 121, __extension__ __PRETTY_FUNCTION__));
  ((1 == min_stack_min(stack, &value)) ? (void) (0) : __assert_fail ("1 == min_stack_min(stack, &value)", "3.2.c", 122, __extension__ __PRETTY_FUNCTION__));
  ((0 == min_stack_push(stack, 2)) ? (void) (0) : __assert_fail ("0 == min_stack_push(stack, 2)", "3.2.c", 124, __extension__ __PRETTY_FUNCTION__));
  ((0 == min_stack_min(stack, &value)) ? (void) (0) : __assert_fail ("0 == min_stack_min(stack, &value)", "3.2.c", 125, __extension__ __PRETTY_FUNCTION__));
  ((2 == value) ? (void) (0) : __assert_fail ("2 == value", "3.2.c", 126, __extension__ __PRETTY_FUNCTION__));
  ((0 == min_stack_pop(stack, &value)) ? (void) (0) : __assert_fail ("0 == min_stack_pop(stack, &value)", "3.2.c", 127, __extension__ __PRETTY_FUNCTION__));
  ((2 == value) ? (void) (0) : __assert_fail ("2 == value", "3.2.c", 128, __extension__ __PRETTY_FUNCTION__));
  ((0 == min_stack_push(stack, 2)) ? (void) (0) : __assert_fail ("0 == min_stack_push(stack, 2)", "3.2.c", 130, __extension__ __PRETTY_FUNCTION__));
  ((0 == min_stack_push(stack, 1)) ? (void) (0) : __assert_fail ("0 == min_stack_push(stack, 1)", "3.2.c", 131, __extension__ __PRETTY_FUNCTION__));
  ((0 == min_stack_min(stack, &value)) ? (void) (0) : __assert_fail ("0 == min_stack_min(stack, &value)", "3.2.c", 132, __extension__ __PRETTY_FUNCTION__));
  ((1 == value) ? (void) (0) : __assert_fail ("1 == value", "3.2.c", 133, __extension__ __PRETTY_FUNCTION__));
  ((0 == min_stack_push(stack, 3)) ? (void) (0) : __assert_fail ("0 == min_stack_push(stack, 3)", "3.2.c", 134, __extension__ __PRETTY_FUNCTION__));
  ((0 == min_stack_min(stack, &value)) ? (void) (0) : __assert_fail ("0 == min_stack_min(stack, &value)", "3.2.c", 135, __extension__ __PRETTY_FUNCTION__));
  ((1 == value) ? (void) (0) : __assert_fail ("1 == value", "3.2.c", 136, __extension__ __PRETTY_FUNCTION__));
  ((0 == min_stack_push(stack, 0)) ? (void) (0) : __assert_fail ("0 == min_stack_push(stack, 0)", "3.2.c", 137, __extension__ __PRETTY_FUNCTION__));
  ((0 == min_stack_min(stack, &value)) ? (void) (0) : __assert_fail ("0 == min_stack_min(stack, &value)", "3.2.c", 138, __extension__ __PRETTY_FUNCTION__));
  ((0 == value) ? (void) (0) : __assert_fail ("0 == value", "3.2.c", 139, __extension__ __PRETTY_FUNCTION__));
  stack = min_stack_free(stack);
  return 0;
}

canonical_original_code:
int main() {
  struct _MinStack *stack = min_stack_init(1);
  int value = 0;
  ((1 == min_stack_pop(stack, &value)) ? (void) (0) : __assert_fail ("1 == min_stack_pop(stack, &value)", "3.2.c", 121, __extension__ __PRETTY_FUNCTION__));
  ((1 == min_stack_min(stack, &value)) ? (void) (0) : __assert_fail ("1 == min_stack_min(stack, &value)", "3.2.c", 122, __extension__ __PRETTY_FUNCTION__));
  ((0 == min_stack_push(stack, 2)) ? (void) (0) : __assert_fail ("0 == min_stack_push(stack, 2)", "3.2.c", 124, __extension__ __PRETTY_FUNCTION__));
  ((0 == min_stack_min(stack, &value)) ? (void) (0) : __assert_fail ("0 == min_stack_min(stack, &value)", "3.2.c", 125, __extension__ __PRETTY_FUNCTION__));
  ((2 == value) ? (void) (0) : __assert_fail ("2 == value", "3.2.c", 126, __extension__ __PRETTY_FUNCTION__));
  ((0 == min_stack_pop(stack, &value)) ? (void) (0) : __assert_fail ("0 == min_stack_pop(stack, &value)", "3.2.c", 127, __extension__ __PRETTY_FUNCTION__));
  ((2 == value) ? (void) (0) : __assert_fail ("2 == value", "3.2.c", 128, __extension__ __PRETTY_FUNCTION__));
  ((0 == min_stack_push(stack, 2)) ? (void) (0) : __assert_fail ("0 == min_stack_push(stack, 2)", "3.2.c", 130, __extension__ __PRETTY_FUNCTION__));
  ((0 == min_stack_push(stack, 1)) ? (void) (0) : __assert_fail ("0 == min_stack_push(stack, 1)", "3.2.c", 131, __extension__ __PRETTY_FUNCTION__));
  ((0 == min_stack_min(stack, &value)) ? (void) (0) : __assert_fail ("0 == min_stack_min(stack, &value)", "3.2.c", 132, __extension__ __PRETTY_FUNCTION__));
  ((1 == value) ? (void) (0) : __assert_fail ("1 == value", "3.2.c", 133, __extension__ __PRETTY_FUNCTION__));
  ((0 == min_stack_push(stack, 3)) ? (void) (0) : __assert_fail ("0 == min_stack_push(stack, 3)", "3.2.c", 134, __extension__ __PRETTY_FUNCTION__));
  ((0 == min_stack_min(stack, &value)) ? (void) (0) : __assert_fail ("0 == min_stack_min(stack, &value)", "3.2.c", 135, __extension__ __PRETTY_FUNCTION__));
  ((1 == value) ? (void) (0) : __assert_fail ("1 == value", "3.2.c", 136, __extension__ __PRETTY_FUNCTION__));
  ((0 == min_stack_push(stack, 0)) ? (void) (0) : __assert_fail ("0 == min_stack_push(stack, 0)", "3.2.c", 137, __extension__ __PRETTY_FUNCTION__));
  ((0 == min_stack_min(stack, &value)) ? (void) (0) : __assert_fail ("0 == min_stack_min(stack, &value)", "3.2.c", 138, __extension__ __PRETTY_FUNCTION__));
  ((0 == value) ? (void) (0) : __assert_fail ("0 == value", "3.2.c", 139, __extension__ __PRETTY_FUNCTION__));
  stack = min_stack_free(stack);
  return 0;
}


decompiled_code:
__int64 __fastcall list_of_linked_list_free(void *ptr)
{
_QWORD *v1; // rbx
void *v2; // rdi

if ( !ptr )
return 0LL;
v1 = ptr;
do
{
v2 = v1;
v1 = (_QWORD *)*v1;
free(v2);
}
while ( v1 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(void *ptr)
{
_QWORD *v1; // rbx
void *v2; // rdi

if ( !ptr )
return 0LL;
v1 = ptr;
do
{
v2 = v1;
v1 = (_QWORD *)*v1;
free(v2);
}
while ( v1 );
return 0LL;
}

original_code:
ListOfLinkedList *list_of_linked_list_free(ListOfLinkedList *list) {
  while (((void *)0) != list) {
    ListOfLinkedList *tmp = list->next;
    free(list);
    list = tmp;
  }
  return ((void *)0);
}

canonical_original_code:
struct _ListOfLinkedList *list_of_linked_list_free(struct _ListOfLinkedList *list) {
  while (((void *)0) != list) {
    struct _ListOfLinkedList *tmp = list->next;
    free(list);
    list = tmp;
  }
  return ((void *)0);
}

variable_types:
list
struct _ListOfLinkedList *

variable_types: struct _ListOfLinkedList { struct _ListOfLinkedList *next; struct _LinkedList { struct _LinkedList *prev; struct _LinkedList *next; void *value; } *value; } *

user_defined_types: struct _ListOfLinkedList { struct _ListOfLinkedList *next; struct _LinkedList *value; }


decompiled_code:
__int64 __fastcall begining_of_loop(__int64 a1, _DWORD *a2)
{
__int64 v2; // rbx
_QWORD *v3; // r13
_QWORD *v4; // rbp
_QWORD *v5; // rax
__int64 v6; // rax
_QWORD *v7; // rax
__int64 v8; // rdx
__int64 v9; // rcx

v2 = a1;
if ( !*(_QWORD *)(a1 + 8) )
begining_of_loop_cold(a1, a2);
v3 = 0LL;
v4 = 0LL;
while ( 1 )
{
if ( v4 )
{
v5 = list_of_linked_list_alloc(v2);
*v3 = v5;
v3 = v5;
}
else
{
v4 = list_of_linked_list_alloc(v2);
v3 = v4;
}
v6 = *(_QWORD *)(v2 + 8);
*(_QWORD *)(v2 + 8) = 0LL;
if ( !*(_QWORD *)(v6 + 8) )
break;
v2 = v6;
}
*a2 = *(_QWORD *)(v6 + 16);
v7 = (_QWORD *)*v4;
if ( *v4 )
{
v8 = v4[1];
do
{
v9 = v8;
v8 = v7[1];
v7 = (_QWORD *)*v7;
*(_QWORD *)(v9 + 8) = v8;
}
while ( v7 );
}
return list_of_linked_list_free(v4);
}

original_code:
void begining_of_loop(LinkedList *list, int *value) {
  ListOfLinkedList *list_of_linked_list = ((void *)0);
  ListOfLinkedList *tail = ((void *)0);
  while (((void *)0) != list->next) {
    if (((void *)0) == list_of_linked_list) {
      tail = list_of_linked_list = list_of_linked_list_alloc(list);
    } else {
      tail->next = list_of_linked_list_alloc(list);
      tail = tail->next;
    }
    LinkedList *tmp = list->next;
    list->next = ((void *)0);
    list = tmp;
  }
  *value = list->value;
  ListOfLinkedList *p = list_of_linked_list;
  while (((void *)0) != p->next) {
    p->value->next = p->next->value;
    p = p->next;
  }
  list_of_linked_list_free(list_of_linked_list);
}

canonical_original_code:
void begining_of_loop(struct _LinkedList *list, int *value) {
  struct _ListOfLinkedList *list_of_linked_list = ((void *)0);
  struct _ListOfLinkedList *tail = ((void *)0);
  while (((void *)0) != list->next) {
    if (((void *)0) == list_of_linked_list) {
      tail = list_of_linked_list = list_of_linked_list_alloc(list);
    } else {
      tail->next = list_of_linked_list_alloc(list);
      tail = tail->next;
    }
    struct _LinkedList *tmp = list->next;
    list->next = ((void *)0);
    list = tmp;
  }
  *value = list->value;
  struct _ListOfLinkedList *p = list_of_linked_list;
  while (((void *)0) != p->next) {
    p->value->next = p->next->value;
    p = p->next;
  }
  list_of_linked_list_free(list_of_linked_list);
}

variable_types: struct _LinkedList { struct _LinkedList *prev; struct _LinkedList *next; void *value; } *


canonical_decompiled_code:
__int64 __fastcall func10(void *ptr)
{
_QWORD *v1; // rbx
void *v2; // rdi

if ( !ptr )
return 0LL;
v1 = ptr;
do
{
v2 = v1;
v1 = (_QWORD *)*v1;
free(v2);
}
while ( v1 );
return 0LL;
}

original_code:
SinglyLinkedList *singly_linked_list_free(SinglyLinkedList *list) {
  SinglyLinkedList *node = list;
  while (((void *)0) != node) {
    SinglyLinkedList *tmp = node->next;
    free(node);
    node = tmp;
  }
  return ((void *)0);
}

canonical_original_code:
struct _SinglyLinkedList *singly_linked_list_free(struct _SinglyLinkedList *list) {
  struct _SinglyLinkedList *node = list;
  while (((void *)0) != node) {
    struct _SinglyLinkedList *tmp = node->next;
    free(node);
    node = tmp;
  }
  return ((void *)0);
}

variable_types:
list
struct _SinglyLinkedList *

variable_types: struct _SinglyLinkedList { struct _SinglyLinkedList *next; int value; } *


canonical_decompiled_code:
int __fastcall func11(__int64 **a1)
{
__int64 **v1; // rbx

if ( a1 )
{
v1 = a1;
do
{
printf("%d->", *((unsigned int *)v1 + 2));
v1 = (__int64 **)*v1;
}
while ( v1 );
}
return puts("NULL");
}

original_code:
void singly_linked_list_print(SinglyLinkedList *list) {
  SinglyLinkedList *node = list;
  while (((void *)0) != node) {
    printf("%d->", node->value);
    node = node->next;
  }
  printf("NULL\n");
}

canonical_original_code:
void singly_linked_list_print(struct _SinglyLinkedList *list) {
  struct _SinglyLinkedList *node = list;
  while (((void *)0) != node) {
    printf("%d->", node->value);
    node = node->next;
  }
  printf("NULL\n");
}


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

if ( !ptr )
return 0LL;
v1 = ptr;
do
{
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 1);
free(v2);
}
while ( v1 );
return 0LL;
}

original_code:
LinkedList *linked_list_free(LinkedList *list) {
  LinkedList *node = list;
  while (((void *)0) != node) {
    LinkedList *tmp = node->next;
    free(node);
    node = tmp;
  }
  return ((void *)0);
}

canonical_original_code:
struct _LinkedList *linked_list_free(struct _LinkedList *list) {
  struct _LinkedList *node = list;
  while (((void *)0) != node) {
    struct _LinkedList *tmp = node->next;
    free(node);
    node = tmp;
  }
  return ((void *)0);
}

variable_types:
list
struct _LinkedList *


original_code:
void linked_list_print(LinkedList *list) {
  LinkedList *node = list;
  while (((void *)0) != node) {
    printf("%d->", node->value);
    node = node->next;
  }
  printf("NULL\n");
}

canonical_original_code:
void linked_list_print(struct _LinkedList *list) {
  struct _LinkedList *node = list;
  while (((void *)0) != node) {
    printf("%d->", node->value);
    node = node->next;
  }
  printf("NULL\n");
}


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

if ( (unsigned __int64)(a2 + a1[1] - *a1) > a1[2] )
return 0LL;
result = a1[1];
a1[1] = result + a2;
return result;
}

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

if ( (unsigned __int64)(a2 + a1[1] - *a1) > a1[2] )
return 0LL;
result = a1[1];
a1[1] = result + a2;
return result;
}

original_code:
void *memory_pool_alloc(MemoryPool *pool, size_t size) {
  size_t used_size = (char *)pool->head - (char *)pool->pool;
  if (used_size + size > pool->size) return ((void *)0);
  void *result = pool->head;
  pool->head = (void *)((char *)pool->head + size);
  return result;
}

canonical_original_code:
void *memory_pool_alloc(struct _MemoryPool *pool, unsigned long size) {
  unsigned long used_size = (char *)pool->head - (char *)pool->pool;
  if (used_size + size > pool->size) return ((void *)0);
  void *result = pool->head;
  pool->head = (void *)((char *)pool->head + size);
  return result;
}

variable_types: struct _MemoryPool { void *pool; void *head; unsigned long size; } *

variable_types:
size
unsigned long

variable_types:
result
void *


decompiled_code:
__int64 __fastcall memory_pool_free(void *ptr)
{
free(*(void **)ptr);
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func15(void *ptr)
{
free(*(void **)ptr);
free(ptr);
return 0LL;
}

original_code:
MemoryPool *memory_pool_free(MemoryPool *pool) {
  free(pool->pool);
  free(pool);
  return ((void *)0);
}

canonical_original_code:
struct _MemoryPool *memory_pool_free(struct _MemoryPool *pool) {
  free(pool->pool);
  free(pool);
  return ((void *)0);
}

variable_types:
pool
struct _MemoryPool *


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

result = 0xFFFFFFFFLL;
if ( *a1 >= *a2 )
result = *a1 != *a2;
return result;
}

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

result = 0xFFFFFFFFLL;
if ( *a1 >= *a2 )
result = *a1 != *a2;
return result;
}

original_code:
int int_compare_by_pointer(void *pa, void *pb) {
  int a = *(int *)pa;
  int b = *(int *)pb;
  if (a < b) return -1;
  else if (a == b) return 0;
  else return 1;
}

variable_types:
pa
void *

variable_types:
pb
void *

variable_types: a int

variable_types: b int