setRT

decompiled_code:
void setRT()
{
struct sched_param param; // [rsp+Ch] [rbp-Ch] BYREF

param.__sched_priority = sched_get_priority_max(1);
if ( sched_setscheduler(0, 1, &param) )
perror("Unable to elevate to real time scheduling");
}

canonical_decompiled_code:
void func15()
{
struct sched_param param; // [rsp+Ch] [rbp-Ch] BYREF

param.__sched_priority = sched_get_priority_max(1);
if ( sched_setscheduler(0, 1, &param) )
perror("Unable to elevate to real time scheduling");
}

original_code:
static void setRT()
{
    int scheduler = 1;
    struct sched_param schedparam;
    memset(&schedparam, 0, sizeof (struct sched_param));
    schedparam.sched_priority = sched_get_priority_max(scheduler);
    if (sched_setscheduler(0, scheduler, &schedparam) != 0) {
        perror("Unable to elevate to real time scheduling");
    }
}

variable_types: scheduler int

variable_types: struct sched_param { int sched_priority; }


repo: andywarduk/LEDs

decompiled_code:
__int64 led_init()
{
__int64 result; // rax
int *v1; // r12
int *v2; // rbx
int *v3; // rbp
int v4; // eax

result = gpio_setup();
if ( (_DWORD)result )
{
redpin = get_pin(0xBu, "Red");
greenpin = get_pin(0xDu, "Green");
bluepin = get_pin(0xFu, "Blue");
v1 = ledpins;
ledpins[0] = get_pin(7u, "LED 5");
ledpins[1] = get_pin(0x16u, "LED 4");
ledpins[2] = get_pin(0x12u, "LED 3");
ledpins[3] = get_pin(0x10u, "LED 2");
ledpins[4] = get_pin(0xCu, "LED 1");
v2 = ledpins;
v3 = &ledpins[5];
do
setup_pin(*v1++);
while ( v1 != v3 );
setup_pin(redpin);
setup_pin(greenpin);
setup_pin(bluepin);
do
{
v4 = *v2 + 31;
if ( *v2 >= 0 )
v4 = *v2;
*(_DWORD *)(gpio + 4LL * ((v4 >> 5) + 7)) = 1 << (*v2++ % 32);
}
while ( v2 != v3 );
setRT();
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 func16()
{
__int64 result; // rax
int *v1; // r12
int *v2; // rbx
int *v3; // rbp
int v4; // eax

result = func12();
if ( (_DWORD)result )
{
redpin = func14(0xBu, "Red");
greenpin = func14(0xDu, "Green");
bluepin = func14(0xFu, "Blue");
v1 = ledpins;
ledpins[0] = func14(7u, "LED 5");
ledpins[1] = func14(0x16u, "LED 4");
ledpins[2] = func14(0x12u, "LED 3");
ledpins[3] = func14(0x10u, "LED 2");
ledpins[4] = func14(0xCu, "LED 1");
v2 = ledpins;
v3 = &ledpins[5];
do
func13(*v1++);
while ( v1 != v3 );
func13(redpin);
func13(greenpin);
func13(bluepin);
do
{
v4 = *v2 + 31;
if ( *v2 >= 0 )
v4 = *v2;
*(_DWORD *)(gpio + 4LL * ((v4 >> 5) + 7)) = 1 << (*v2++ % 32);
}
while ( v2 != v3 );
func15();
result = 1LL;
}
return result;
}

original_code:
int led_init()
{
    unsigned int i;
    if (!gpio_setup()) return 0;
    redpin = get_pin(11, "Red");
    greenpin = get_pin(13, "Green");
    bluepin = get_pin(15, "Blue");
    ledpins[0] = get_pin(7, "LED 5");
    ledpins[1] = get_pin(22, "LED 4");
    ledpins[2] = get_pin(18, "LED 3");
    ledpins[3] = get_pin(16, "LED 2");
    ledpins[4] = get_pin(12, "LED 1");
    for (i = 0; i < sizeof (ledpins) / sizeof (int); i++) {
        setup_pin(ledpins[i]);
    }
    setup_pin(redpin);
    setup_pin(greenpin);
    setup_pin(bluepin);
    for (i = 0; i < sizeof (ledpins) / sizeof (int); i++) {
        ((*(gpio + (7 + ((ledpins[i]) / 32)))) = (1 << ((ledpins[i]) % 32)));
    }
    setRT();
    return 1;
}

variable_types:
i
unsigned int

return_type: int


usage

repo: angmouzakitis/stegtool

decompiled_code:
void __noreturn usage()
{
puts("Give some arguments\nUSAGE: stegtool.exe <--encrypt|--decrypt> <TextToCrypt>");
exit(1);
}

canonical_decompiled_code:
void __noreturn func7()
{
puts("Give some arguments\nUSAGE: stegtool.exe <--encrypt|--decrypt> <TextToCrypt>");
exit(1);
}

original_code:
void usage()
{
 printf("Give some arguments\nUSAGE: stegtool.exe <--encrypt|--decrypt> <TextToCrypt>\n");
 exit(1);
}

return_type: void


power

decompiled_code:
__int64 __fastcall power(int a1)
{
unsigned int v1; // edx
int i; // eax

if ( a1 <= 0 )
return 1;
v1 = 1;
for ( i = 0; i != a1; ++i )
v1 *= 2;
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1)
{
unsigned int v1; // edx
int i; // eax

if ( a1 <= 0 )
return 1;
v1 = 1;
for ( i = 0; i != a1; ++i )
v1 *= 2;
return v1;
}

original_code:
int power(int n)
{
 int i, p = 1;
 for (i = 0; i < n; i++) p *= 2;
 return p;
}

canonical_original_code:
int power(int n)
{
 int i; int p = 1;
 for (i = 0; i < n; i++) p *= 2;
 return p;
}

variable_types: n int

variable_types: i int

variable_types: p int


original_code:
int8_t bit2char(int8_t *ptr)
{
 int i, y = 7;
 int8_t ret = 0;
 for (i = 0;i < 8; i++) {
  if (ptr[y] & 1)
   ret += power(i);
  y--;
 }
 return ret;
}

canonical_original_code:
char bit2char(char *ptr)
{
 int i; int y = 7;
 char ret = 0;
 for (i = 0;i < 8; i++) {
  if (ptr[y] & 1)
   ret += power(i);
  y--;
 }
 return ret;
}

variable_types:
ptr
char *

variable_types: y int

variable_types: ret char

return_type: char


decompiled_code:
__int64 __fastcall decrypt_bits(int a1)
{
return bit2char(qword_4041C8 + 8 * a1 - 8);
}

canonical_decompiled_code:
__int64 __fastcall func11(int a1)
{
return func10(qword_4041C8 + 8 * a1 - 8);
}

original_code:
int8_t decrypt_bits(int i)
{
 uint8_t *ptr, ret;
 ptr = header.offset;
 ptr += (i-1) * 8;
 ret = bit2char(ptr);
 return ret;
}

canonical_original_code:
char decrypt_bits(int i)
{
 unsigned char *ptr; unsigned char ret;
 ptr = header.offset;
 ptr += (i-1) * 8;
 ret = bit2char(ptr);
 return ret;
}

variable_types:
ptr
unsigned char *

variable_types:
ret
unsigned char


decompiled_code:
int __fastcall char2bit(char a1)
{
char *v1; // rdx
char *v2; // rax
char v3; // al
char v5[7]; // [rsp+8h] [rbp-10h] BYREF
char v6; // [rsp+Fh] [rbp-9h] BYREF

v1 = &v6;
do
{
*v1 = a1 % 2;
a1 >>= 1;
v2 = v1--;
}
while ( v2 != v5 );
putchar(10);
v3 = bit2char((__int64)v5);
return printf("einai %d\n", (unsigned int)v3);
}

canonical_decompiled_code:
int __fastcall func12(char a1)
{
char *v1; // rdx
char *v2; // rax
char v3; // al
char v5[7]; // [rsp+8h] [rbp-10h] BYREF
char v6; // [rsp+Fh] [rbp-9h] BYREF

v1 = &v6;
do
{
*v1 = a1 % 2;
a1 >>= 1;
v2 = v1--;
}
while ( v2 != v5 );
putchar(10);
v3 = func10((__int64)v5);
return printf("einai %d\n", (unsigned int)v3);
}

original_code:
void char2bit(int8_t c)
{
 int8_t i, bytes[8];
 for (i = 7; i >= 0; i--) {
  bytes[i] = c%2;
  c = c >> 1;
 }
 putchar('\n');
 printf("einai %d\n", bit2char(bytes));
}

canonical_original_code:
void char2bit(char c)
{
 char i; char bytes[8];
 for (i = 7; i >= 0; i--) {
  bytes[i] = c%2;
  c = c >> 1;
 }
 putchar('\n');
 printf("einai %d\n", bit2char(bytes));
}

variable_types: c char

variable_types: i char

variable_types:
bytes
char [8]


GetNextCharacter

decompiled_code:
unsigned __int8 *__fastcall GetNextCharacter(unsigned __int8 *a1, int a2)
{
int v2; // ebp
unsigned __int8 *v3; // rdx
unsigned __int8 *v4; // rbx
int v5; // ecx
char v6; // kr00_1
unsigned __int8 *v7; // rax

v2 = a2;
printf("GETNEXTCHARACTER : Character %c ", (unsigned int)(char)a2);
v3 = a1 + 7;
v4 = a1;
do
{
v5 = v2;
LOBYTE(v5) = (unsigned __int8)v2 >> 7;
*v3 = (char)v2 % 2;
v6 = v2;
v2 += v5;
LOBYTE(v2) = v6 / 2;
v7 = v3--;
}
while ( v7 != a1 );
do
printf("%d", *v4++);
while ( v4 != a1 + 8 );
putchar(10);
return a1;
}

canonical_decompiled_code:
unsigned __int8 *__fastcall func13(unsigned __int8 *a1, int a2)
{
int v2; // ebp
unsigned __int8 *v3; // rdx
unsigned __int8 *v4; // rbx
int v5; // ecx
char v6; // kr00_1
unsigned __int8 *v7; // rax

v2 = a2;
printf("GETNEXTCHARACTER : Character %c ", (unsigned int)(char)a2);
v3 = a1 + 7;
v4 = a1;
do
{
v5 = v2;
LOBYTE(v5) = (unsigned __int8)v2 >> 7;
*v3 = (char)v2 % 2;
v6 = v2;
v2 += v5;
LOBYTE(v2) = v6 / 2;
v7 = v3--;
}
while ( v7 != a1 );
do
printf("%d", *v4++);
while ( v4 != a1 + 8 );
putchar(10);
return a1;
}

original_code:
uint8_t *GetNextCharacter(uint8_t text[], int8_t ch)
{
 int i;
 printf("GETNEXTCHARACTER : Character %c ", ch);
 for (i = 7;i >= 0;i--) {
  text[i] = ch % 2;
  ch /= 2;
 }
 for (i = 0; i < 8; i++)
  printf("%d", text[i]);
 putchar('\n');
 return text;
}

canonical_original_code:
unsigned char *GetNextCharacter(unsigned char text[], char ch)
{
 int i;
 printf("GETNEXTCHARACTER : Character %c ", ch);
 for (i = 7;i >= 0;i--) {
  text[i] = ch % 2;
  ch /= 2;
 }
 for (i = 0; i < 8; i++)
  printf("%d", text[i]);
 putchar('\n');
 return text;
}

variable_types:
text
unsigned char []

variable_types: ch char

return_type: unsigned char *


decompiled_code:
int __fastcall encrypt_bits(__int64 a1, char *a2)
{
unsigned __int8 *v3; // rax
__int64 v4; // rbx
char v5; // si
unsigned __int8 *v6; // rdi
unsigned __int8 v7; // bp
__int64 i; // rax
_BYTE *v9; // rax
_BYTE *v10; // rbx

v3 = (unsigned __int8 *)malloc(8uLL);
v4 = qword_4041C8;
v5 = *a2;
if ( v5 )
{
v6 = v3;
v7 = 0;
do
{
v6 = GetNextCharacter(v6, v5);
++v7;
for ( i = 0LL; i != 8; ++i )
{
if ( v6[i] )
*(_BYTE *)(v4 + i) |= 1u;
else
*(_BYTE *)(v4 + i) &= 0xFEu;
}
v4 += 8LL;
v5 = a2[v7];
}
while ( v5 );
}
else
{
v7 = 0;
}
v9 = (_BYTE *)v4;
v10 = (_BYTE *)(v4 + 8);
do
*v9++ &= 0xFEu;
while ( v9 != v10 );
return printf("\nCHANGEBITS : Changed successfully %d bits\n", v7);
}

canonical_decompiled_code:
int __fastcall func14(__int64 a1, char *a2)
{
unsigned __int8 *v3; // rax
__int64 v4; // rbx
char v5; // si
unsigned __int8 *v6; // rdi
unsigned __int8 v7; // bp
__int64 i; // rax
_BYTE *v9; // rax
_BYTE *v10; // rbx

v3 = (unsigned __int8 *)malloc(8uLL);
v4 = qword_4041C8;
v5 = *a2;
if ( v5 )
{
v6 = v3;
v7 = 0;
do
{
v6 = func13(v6, v5);
++v7;
for ( i = 0LL; i != 8; ++i )
{
if ( v6[i] )
*(_BYTE *)(v4 + i) |= 1u;
else
*(_BYTE *)(v4 + i) &= 0xFEu;
}
v4 += 8LL;
v5 = a2[v7];
}
while ( v5 );
}
else
{
v7 = 0;
}
v9 = (_BYTE *)v4;
v10 = (_BYTE *)(v4 + 8);
do
*v9++ &= 0xFEu;
while ( v9 != v10 );
return printf("\nCHANGEBITS : Changed successfully %d bits\n", v7);
}

original_code:
void encrypt_bits(uint8_t *ptr, int8_t TextToCrypt[])
{
 int i = 0;
 uint8_t *bytes, poschar = 0;
 bytes = (uint8_t *) malloc(8);
 ptr = header.offset;
 while (TextToCrypt[poschar]) {
  bytes = GetNextCharacter(bytes, TextToCrypt[poschar]);
  poschar++;
  for (i = 0; i < 8; i++) {
   if (bytes[i] == 0)
    ptr[i] &=0xFE;
   else
    ptr[i] |=0x01;
  }
  ptr += 8;
 }
 for (i = 0; i < 8; i++)
  ptr[i] &= 0xFE;
 printf("\nCHANGEBITS : Changed successfully %d bits\n", poschar);
}

canonical_original_code:
void encrypt_bits(unsigned char *ptr, char TextToCrypt[])
{
 int i = 0;
 unsigned char *bytes; unsigned char poschar = 0;
 bytes = (unsigned char *) malloc(8);
 ptr = header.offset;
 while (TextToCrypt[poschar]) {
  bytes = GetNextCharacter(bytes, TextToCrypt[poschar]);
  poschar++;
  for (i = 0; i < 8; i++) {
   if (bytes[i] == 0)
    ptr[i] &=0xFE;
   else
    ptr[i] |=0x01;
  }
  ptr += 8;
 }
 for (i = 0; i < 8; i++)
  ptr[i] &= 0xFE;
 printf("\nCHANGEBITS : Changed successfully %d bits\n", poschar);
}

variable_types:
TextToCrypt
char []

variable_types:
bytes
unsigned char *

variable_types:
poschar
unsigned char


decompiled_code:
__int64 __fastcall set_headers(unsigned __int8 *a1)
{
__int64 result; // rax

dword_4041C4 = header + 10 - *a1;
dword_4041D0 = a1[22];
dword_4041D4 = a1[18];
result = a1[10];
qword_4041C8 = (__int64)&a1[result];
return result;
}

canonical_decompiled_code:
__int64 __fastcall func16(unsigned __int8 *a1)
{
__int64 result; // rax

dword_4041C4 = header + 10 - *a1;
dword_4041D0 = a1[22];
dword_4041D4 = a1[18];
result = a1[10];
qword_4041C8 = (__int64)&a1[result];
return result;
}

original_code:
void set_headers(uint8_t *ptr)
{
 header.rawsize = header.fullsize - *ptr + 0x0a;
 header.height = ptr[0x16];
 header.width = ptr[0x12];
 header.offset = &ptr[ptr[0x0a]];
}

canonical_original_code:
void set_headers(unsigned char *ptr)
{
 header.rawsize = header.fullsize - *ptr + 0x0a;
 header.height = ptr[0x16];
 header.width = ptr[0x12];
 header.offset = &ptr[ptr[0x0a]];
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int8 *v3; // rbp
char v4; // al
__int64 v6; // rbx
int v7; // ebp
char v8; // al
__int64 v9; // rbx
char v10; // al
__int64 v11; // rbx
char v12; // [rsp+8h] [rbp-2730h]
char v13; // [rsp+10h] [rbp-2728h]
char v14[10023]; // [rsp+11h] [rbp-2727h] BYREF

if ( argc == 1 )
usage(argc, argv, envp);
puts("What encryption method ? plain/xor");
__isoc99_scanf();
v3 = (unsigned __int8 *)copy_to_mem();
set_headers(v3);
v4 = argv[1][2];
if ( v4 == 100 )
{
if ( v12 == 112 )
{
v6 = 1LL;
while ( 1 )
{
v7 = v6;
v8 = decrypt_bits(v6);
*(&v13 + v6++) = v8;
if ( !v8 )
break;
printf("MAIN : To ch einai %d kai %c\n", (unsigned int)v8, (unsigned int)v8);
}
}
else
{
if ( v12 != 120 )
{
printf("ERROR SWITCH DEFAULT , NO SUCH ENCRYPTION METHOD ... QUITING");
return 0;
}
v9 = 1LL;
while ( 1 )
{
v7 = v9;
v10 = decrypt_bits(v9);
*(&v13 + v9++) = v10;
if ( !v10 )
break;
printf("MAIN : To ch einai %d kai %c\n", (unsigned int)v10, (unsigned int)v10);
}
makeXOR(v14);
}
printf("\n\nHIDDEN MESSAGE FOUND : ");
if ( v7 > 0 )
{
v11 = 1LL;
do
putchar(*(&v13 + v11++));
while ( v7 >= (int)v11 );
}
putchar(10);
}
else if ( v4 == 101 )
{
printf("MAIN : Text to hide : %s\n\n", argv[2]);
puts("______________________________________________________\n\n");
if ( v12 != 112 )
{
if ( v12 != 120 )
{
LABEL_8:
save_file(v3);
return 0;
}
argv[2] = makeXOR((char *)argv[2]);
}
encrypt_bits((__int64)v3, (char *)argv[2]);
goto LABEL_8;
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned __int8 *v3; // rbp
char v4; // al
__int64 v6; // rbx
int v7; // ebp
char v8; // al
__int64 v9; // rbx
char v10; // al
__int64 v11; // rbx
char v12; // [rsp+8h] [rbp-2730h]
char v13; // [rsp+10h] [rbp-2728h]
char v14[10023]; // [rsp+11h] [rbp-2727h] BYREF

if ( argc == 1 )
func7(argc, argv, envp);
puts("What encryption method ? plain/xor");
__isoc99_scanf();
v3 = (unsigned __int8 *)func15();
func16(v3);
v4 = argv[1][2];
if ( v4 == 100 )
{
if ( v12 == 112 )
{
v6 = 1LL;
while ( 1 )
{
v7 = v6;
v8 = func11(v6);
*(&v13 + v6++) = v8;
if ( !v8 )
break;
printf("MAIN : To ch einai %d kai %c\n", (unsigned int)v8, (unsigned int)v8);
}
}
else
{
if ( v12 != 120 )
{
printf("ERROR SWITCH DEFAULT , NO SUCH ENCRYPTION METHOD ... QUITING");
return 0;
}
v9 = 1LL;
while ( 1 )
{
v7 = v9;
v10 = func11(v9);
*(&v13 + v9++) = v10;
if ( !v10 )
break;
printf("MAIN : To ch einai %d kai %c\n", (unsigned int)v10, (unsigned int)v10);
}
func8(v14);
}
printf("\n\nHIDDEN MESSAGE FOUND : ");
if ( v7 > 0 )
{
v11 = 1LL;
do
putchar(*(&v13 + v11++));
while ( v7 >= (int)v11 );
}
putchar(10);
}
else if ( v4 == 101 )
{
printf("MAIN : Text to hide : %s\n\n", argv[2]);
puts("______________________________________________________\n\n");
if ( v12 != 112 )
{
if ( v12 != 120 )
{
LABEL_8:
func17(v3);
return 0;
}
argv[2] = func8((char *)argv[2]);
}
func14((__int64)v3, (char *)argv[2]);
goto LABEL_8;
}
return 0;
}

original_code:
int main(int argc, char *argv[])
{
 uint8_t *ptr;
 int8_t *action, ch[10000], encryption[8];
 int i = 0, j;
 int8_t *decryptptr;
 decryptptr = (int8_t *) malloc(sizeof(int8_t) * 10000);
 if (argc == 1)
  usage();
 printf("What encryption method ? plain/xor\n");
 scanf("%s", encryption);
 ptr = copy_to_mem(argv[1]);
 set_headers(ptr);
 switch (argv[1][2]) {
 case 'e' :
  printf("MAIN : Text to hide : %s\n\n", argv[2]);
  printf("______________________________________________________\n\n\n");
  switch (encryption[0]) {
  case 'x' :
   argv[2] = makeXOR(argv[2]);
  case 'p' :
   encrypt_bits(ptr, argv[2]);
   break;
  }
  save_file(ptr);
  break;
 case 'd' :
  switch (encryption[0]) {
  case 'p' :
   for (i = 1; ch[i] = decrypt_bits(i); i++)
    printf("MAIN : To ch einai %d kai %c\n", ch[i], ch[i]);
   break;
  case 'x' :
   for (i = 1; ch[i] = decrypt_bits(i); i++)
    printf("MAIN : To ch einai %d kai %c\n", ch[i], ch[i]);
   decryptptr = &ch[1];
   decryptptr = makeXOR(decryptptr);
   break;
  default:
   printf("ERROR SWITCH DEFAULT , NO SUCH ENCRYPTION METHOD ... QUITING");
   return 0;
  }
  printf("\n\nHIDDEN MESSAGE FOUND : ");
  for (j = 1; j <= i; j++)
   printf("%c", ch[j]);
  printf("\n");
 }
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 unsigned char *ptr;
 char *action; char ch[10000]; char encryption[8];
 int i = 0; int j;
 char *decryptptr;
 decryptptr = (char *) malloc(sizeof(char) * 10000);
 if (argc == 1)
  usage();
 printf("What encryption method ? plain/xor\n");
 scanf("%s", encryption);
 ptr = copy_to_mem(argv[1]);
 set_headers(ptr);
 switch (argv[1][2]) {
 case 'e' :
  printf("MAIN : Text to hide : %s\n\n", argv[2]);
  printf("______________________________________________________\n\n\n");
  switch (encryption[0]) {
  case 'x' :
   argv[2] = makeXOR(argv[2]);
  case 'p' :
   encrypt_bits(ptr, argv[2]);
   break;
  }
  save_file(ptr);
  break;
 case 'd' :
  switch (encryption[0]) {
  case 'p' :
   for (i = 1; ch[i] = decrypt_bits(i); i++)
    printf("MAIN : To ch einai %d kai %c\n", ch[i], ch[i]);
   break;
  case 'x' :
   for (i = 1; ch[i] = decrypt_bits(i); i++)
    printf("MAIN : To ch einai %d kai %c\n", ch[i], ch[i]);
   decryptptr = &ch[1];
   decryptptr = makeXOR(decryptptr);
   break;
  default:
   printf("ERROR SWITCH DEFAULT , NO SUCH ENCRYPTION METHOD ... QUITING");
   return 0;
  }
  printf("\n\nHIDDEN MESSAGE FOUND : ");
  for (j = 1; j <= i; j++)
   printf("%c", ch[j]);
  printf("\n");
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
action
char *

variable_types:
encryption
char [8]

variable_types: j int

variable_types:
decryptptr
char *


repo: aniketpansare/Process-Hibernation

decompiled_code:
void __fastcall sig_handler(unsigned int a1)
{
printf("Got signal %d!\n", a1);
}

canonical_decompiled_code:
void __fastcall func7(unsigned int a1)
{
printf("Got signal %d!\n", a1);
}

original_code:
void sig_handler(int sig) {
 printf("Got signal %d!\n", sig);
}

variable_types: sig int


decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
signal(10, (__sighandler_t)sig_handler);
signal(12, (__sighandler_t)sig_handler);
while ( 1 )
{
raise(10);
sleep(2u);
raise(12);
sleep(2u);
}
}

original_code:
int main() {
 signal(10, sig_handler);
 signal(12, sig_handler);
 for(;;) {
  raise(10);
  sleep(2);
  raise(12);
  sleep(2);
 }
 return 0;
}


decompiled_code:
__int64 __fastcall set_last_pid(int a1)
{
__int64 v1; // rax
__off64_t v2; // rbp
int v3; // eax
unsigned int v4; // ebx
int buf[7]; // [rsp+Ch] [rbp-1Ch] BYREF

buf[0] = a1;
v1 = get_last_pid_location();
if ( !v1 )
return (unsigned int)-1;
v2 = v1;
v3 = open("/dev/kmem", 2);
v4 = v3;
if ( v3 != -1 )
{
if ( lseek64(v3, v2, 0) == -1 )
{
v4 = -1;
}
else if ( write(v4, buf, 4uLL) == -1 )
{
v4 = -1;
}
else
{
close(v4);
v4 = 0;
}
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1)
{
__int64 v1; // rax
__off64_t v2; // rbp
int v3; // eax
unsigned int v4; // ebx
int buf[7]; // [rsp+Ch] [rbp-1Ch] BYREF

buf[0] = a1;
v1 = func7();
if ( !v1 )
return (unsigned int)-1;
v2 = v1;
v3 = open("/dev/kmem", 2);
v4 = v3;
if ( v3 != -1 )
{
if ( lseek64(v3, v2, 0) == -1 )
{
v4 = -1;
}
else if ( write(v4, buf, 4uLL) == -1 )
{
v4 = -1;
}
else
{
close(v4);
v4 = 0;
}
}
return v4;
}

original_code:
int set_last_pid(int pid)
{
 int fd;
 off64_t last_pid_loc;
 last_pid_loc = get_last_pid_location();
 if (!last_pid_loc)
  return -1;
 fd = open("/dev/kmem", 02|0);
 if (fd == -1)
  return -1;
 if (lseek64(fd, last_pid_loc, 0) == -1)
  return -1;
 if (write(fd, &pid, sizeof(pid)) == -1)
  return -1;
 close(fd);
 return 0;
}

canonical_original_code:
int set_last_pid(int pid)
{
 int fd;
 long last_pid_loc;
 last_pid_loc = get_last_pid_location();
 if (!last_pid_loc)
  return -1;
 fd = open("/dev/kmem", 02|0);
 if (fd == -1)
  return -1;
 if (lseek64(fd, last_pid_loc, 0) == -1)
  return -1;
 if (write(fd, &pid, sizeof(pid)) == -1)
  return -1;
 close(fd);
 return 0;
}

variable_types: pid int

variable_types: fd int


decompiled_code:
__int64 get_last_pid()
{
unsigned int v0; // ebx
__off64_t v1; // rax
unsigned int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( !get_last_pid_location() )
return (unsigned int)-1;
v0 = open("/dev/kmem", 0);
if ( v0 != -1 )
{
v1 = get_last_pid_location();
if ( lseek64(v0, v1, 0) == -1 )
{
v0 = -1;
}
else if ( read(v0, buf, 4uLL) == -1 )
{
v0 = -1;
}
else
{
close(v0);
v0 = buf[0];
}
}
return v0;
}

canonical_decompiled_code:
__int64 func9()
{
unsigned int v0; // ebx
__off64_t v1; // rax
unsigned int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( !func7() )
return (unsigned int)-1;
v0 = open("/dev/kmem", 0);
if ( v0 != -1 )
{
v1 = func7();
if ( lseek64(v0, v1, 0) == -1 )
{
v0 = -1;
}
else if ( read(v0, buf, 4uLL) == -1 )
{
v0 = -1;
}
else
{
close(v0);
v0 = buf[0];
}
}
return v0;
}

original_code:
int get_last_pid()
{
 int fd, last_pid;
 off64_t last_pid_loc;
 last_pid_loc = get_last_pid_location();
 if (!last_pid_loc)
  return -1;
 fd = open("/dev/kmem", 00|0);
 if (fd == -1)
  return -1;
 if (lseek64(fd, (off64_t)get_last_pid_location(), 0) == -1)
  return -1;
 if (read(fd, &last_pid, sizeof(last_pid)) == -1)
  return -1;
 close(fd);
 return last_pid;
}

canonical_original_code:
int get_last_pid()
{
 int fd; int last_pid;
 long last_pid_loc;
 last_pid_loc = get_last_pid_location();
 if (!last_pid_loc)
  return -1;
 fd = open("/dev/kmem", 00|0);
 if (fd == -1)
  return -1;
 if (lseek64(fd, (long)get_last_pid_location(), 0) == -1)
  return -1;
 if (read(fd, &last_pid, sizeof(last_pid)) == -1)
  return -1;
 close(fd);
 return last_pid;
}


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
int v5; // eax
char *endptr; // [rsp+8h] [rbp-20h] BYREF

if ( argc != 3 )
goto LABEL_4;
v3 = 3;
if ( strcmp(*argv, "farewell") || strcmp(argv[1], "kitty") )
goto LABEL_4;
if ( !geteuid() )
{
v5 = strtol(argv[2], &endptr, 10);
if ( *endptr )
{
LABEL_4:
fwrite("This program is a helper for CryoPID and should not be called directly.\n", 1uLL, 0x48uLL, stderr);
return 1;
}
v3 = 0;
if ( (unsigned int)set_last_pid(v5 - 1) == -1 )
{
perror("set_last_pid");
v3 = 2;
}
}
return v3;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
int v5; // eax
char *endptr; // [rsp+8h] [rbp-20h] BYREF

if ( argc != 3 )
goto LABEL_4;
v3 = 3;
if ( strcmp(*argv, "farewell") || strcmp(argv[1], "kitty") )
goto LABEL_4;
if ( !geteuid() )
{
v5 = strtol(argv[2], &endptr, 10);
if ( *endptr )
{
LABEL_4:
fwrite("This program is a helper for CryoPID and should not be called directly.\n", 1uLL, 0x48uLL, stderr);
return 1;
}
v3 = 0;
if ( (unsigned int)func8(v5 - 1) == -1 )
{
perror("set_last_pid");
v3 = 2;
}
}
return v3;
}

original_code:
int main(int argc, char **argv)
{
 int want_pid;
 if (argc == 3 && strcmp(argv[0], "farewell") == 0 &&
   strcmp(argv[1], "kitty") == 0) {
  char *endptr;
  if (geteuid() != 0)
   return 3;
  want_pid = strtol(argv[2], &endptr, 10);
  if (*endptr == '\0') {
   if (set_last_pid(want_pid-1) == -1) {
    perror("set_last_pid");
    return 2;
   }
   return 0;
  }
 }
 fprintf(stderr, "This program is a helper for CryoPID and should not be called directly.\n");
 return 1;
}

variable_types:
argv
char **

variable_types:
endptr
char *


d

decompiled_code:
int d()
{
int v0; // eax

v0 = 0x20000000;
do
--v0;
while ( v0 );
puts("meep");
return fflush(_bss_start);
}

canonical_decompiled_code:
int func7()
{
int v0; // eax

v0 = 0x20000000;
do
--v0;
while ( v0 );
puts("meep");
return fflush(_bss_start);
}

original_code:
void d() {
    int k = 0;
foo:
    k = k + 1;
    if(k < 0x20000000)
        goto foo;
    printf("meep\n");
    fflush(stdout);
}

variable_types: k int


c

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

if ( a1 )
result = d();
return result;
}

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

if ( a1 )
result = func7();
return result;
}

original_code: void c(int z) { if(z)d(); }

canonical_original_code: void c(int z) { if(z)d(); }

variable_types: z int


b

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

if ( a1 )
result = c(a1);
return result;
}

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

if ( a1 )
result = func8(a1);
return result;
}

original_code: void b(int z) { if(z)c(z); }

canonical_original_code: void b(int z) { if(z)c(z); }


a

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

if ( a1 )
result = b(a1);
return result;
}

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

if ( a1 )
result = func9(a1);
return result;
}

original_code: void a(int z) { if(z)b(z); }

canonical_original_code: void a(int z) { if(z)b(z); }


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
a(0);
b(0);
c(0);
d();
puts("moo");
fflush(_bss_start);
exit(42);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
func10(0);
func9(0);
func8(0);
func7();
puts("moo");
fflush(_bss_start);
exit(42);
}

original_code:
int main() {
    int j = 0;
    a(0);
    b(0);
    c(0);
    d();
    printf("moo\n");
    fflush(stdout);
    exit(42);
 return 0;
}


decompiled_code:
__pid_t __fastcall fork2(unsigned int a1)
{
int *v1; // rbp
__pid_t result; // eax
char *v3[5]; // [rsp+0h] [rbp-48h] BYREF
int stat_loc; // [rsp+2Ch] [rbp-1Ch] BYREF

if ( kill(a1, 0) != -1 || (v1 = _errno_location(), *v1 != 3) )
{
*_errno_location() = 17;
return -1;
}
result = fork();
if ( result != -1 )
{
if ( !result )
{
result = waitpid(0, &stat_loc, 0);
if ( result == -1 )
return result;
if ( (stat_loc & 0x7F) != 0 )
return -1;
result = BYTE1(stat_loc);
if ( BYTE1(stat_loc) == 3 )
{
*v1 = 1;
return -1;
}
if ( (stat_loc & 0xFC00) != 0 )
{
if ( BYTE1(stat_loc) == 50 )
{
fwrite("Could not find fork2_helper\n", 1uLL, 0x1CuLL, stderr);
*v1 = 2;
return -1;
}
}
else
{
if ( !BYTE1(stat_loc) )
return result;
if ( BYTE1(stat_loc) == 2 )
{
*v1 = 6;
return -1;
}
}
}
v3[0] = "farewell";
v3[1] = "kitty";
v3[2] = "XXXXXXXXXX";
v3[3] = 0LL;
snprintf("XXXXXXXXXX", 0xAuLL, "%d", a1);
execve("fork2_helper", v3, environ);
perror("execve");
exit(50);
}
return result;
}

canonical_decompiled_code:
__pid_t __fastcall func0(unsigned int a1)
{
int *v1; // rbp
__pid_t result; // eax
char *v3[5]; // [rsp+0h] [rbp-48h] BYREF
int stat_loc; // [rsp+2Ch] [rbp-1Ch] BYREF

if ( kill(a1, 0) != -1 || (v1 = _errno_location(), *v1 != 3) )
{
*_errno_location() = 17;
return -1;
}
result = fork();
if ( result != -1 )
{
if ( !result )
{
result = waitpid(0, &stat_loc, 0);
if ( result == -1 )
return result;
if ( (stat_loc & 0x7F) != 0 )
return -1;
result = BYTE1(stat_loc);
if ( BYTE1(stat_loc) == 3 )
{
*v1 = 1;
return -1;
}
if ( (stat_loc & 0xFC00) != 0 )
{
if ( BYTE1(stat_loc) == 50 )
{
fwrite("Could not find fork2_helper\n", 1uLL, 0x1CuLL, stderr);
*v1 = 2;
return -1;
}
}
else
{
if ( !BYTE1(stat_loc) )
return result;
if ( BYTE1(stat_loc) == 2 )
{
*v1 = 6;
return -1;
}
}
}
v3[0] = "farewell";
v3[1] = "kitty";
v3[2] = "XXXXXXXXXX";
v3[3] = 0LL;
snprintf("XXXXXXXXXX", 0xAuLL, "%d", a1);
execve("fork2_helper", v3, environ);
perror("execve");
exit(50);
}
return result;
}

original_code:
int fork2(pid_t pid)
{
 extern char** environ;
 pid_t helper_pid;
 int status;
 if (kill(pid, 0) != -1 || (*__errno_location ()) != 3) {
  (*__errno_location ()) = 17;
  return -1;
 }
 switch (helper_pid = fork()) {
  case -1:
   return -1;
  case 0:
   if (waitpid(helper_pid, &status, 0) == -1)
    return -1;
   if ((((status) & 0x7f) == 0)) {
    switch ((((status) & 0xff00) >> 8)) {
     case 0:
      return 0;
     case 2:
      (*__errno_location ()) = 6;
      return -1;
     case 3:
      (*__errno_location ()) = 1;
      return -1;
     case 50:
      fprintf(stderr, "Could not find fork2_helper\n");
      (*__errno_location ()) = 2;
      return -1;
    }
   } else
    return -1;
  default:
   {
    char *argv[] = {"farewell", "kitty", "XXXXXXXXXX", ((void *)0)};
    snprintf(argv[2], 10, "%d", pid);
    execve("fork2_helper", argv, environ);
    perror("execve");
    _exit(50);
   }
 }
 return fork();
}

canonical_original_code:
int fork2(int pid)
{
 extern char **environ;
 int helper_pid;
 int status;
 if (kill(pid, 0) != -1 || (*__errno_location ()) != 3) {
  (*__errno_location ()) = 17;
  return -1;
 }
 switch (helper_pid = fork()) {
  case -1:
   return -1;
  case 0:
   if (waitpid(helper_pid, &status, 0) == -1)
    return -1;
   if ((((status) & 0x7f) == 0)) {
    switch ((((status) & 0xff00) >> 8)) {
     case 0:
      return 0;
     case 2:
      (*__errno_location ()) = 6;
      return -1;
     case 3:
      (*__errno_location ()) = 1;
      return -1;
     case 50:
      fprintf(stderr, "Could not find fork2_helper\n");
      (*__errno_location ()) = 2;
      return -1;
    }
   } else
    return -1;
  default:
   {
    char *argv[] = {"farewell", "kitty", "XXXXXXXXXX", ((void *)0)};
    snprintf(argv[2], 10, "%d", pid);
    execve("fork2_helper", argv, environ);
    perror("execve");
    _exit(50);
   }
 }
 return fork();
}

variable_types:
environ
char **

variable_types: status int


decompiled_code:
void *gimme_some_memory()
{
return malloc(0x100000uLL);
}

canonical_decompiled_code:
void *func7()
{
return malloc(0x100000uLL);
}

original_code:
void* gimme_some_memory() {
 return malloc((1024*1024));
}

canonical_original_code:
void *gimme_some_memory() {
 return malloc((1024*1024));
}

return_type: void *


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

v3 = gimme_some_memory();
v4 = gimme_some_memory();
fill_in((__int64)v3);
fill_in((__int64)v4);
play_with((__int64)v3, (__int64)v4, 0);
printf("Loop done, offset = %d\n", 0LL);
sleep(1u);
for ( i = 1; ; i = 0 )
{
do
{
play_with((__int64)v3, (__int64)v4, i);
printf("Loop done, offset = %d\n", (unsigned int)i);
sleep(1u);
++i;
}
while ( i < 257 );
}
}

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

v3 = func7();
v4 = func7();
func8((__int64)v3);
func8((__int64)v4);
func9((__int64)v3, (__int64)v4, 0);
printf("Loop done, offset = %d\n", 0LL);
sleep(1u);
for ( i = 1; ; i = 0 )
{
do
{
func9((__int64)v3, (__int64)v4, i);
printf("Loop done, offset = %d\n", (unsigned int)i);
sleep(1u);
++i;
}
while ( i < 257 );
}
}

original_code:
int main() {
 unsigned char *mem1, *mem2;
 int offset;
 mem1 = (unsigned char*)gimme_some_memory();
 mem2 = (unsigned char*)gimme_some_memory();
 fill_in(mem1);
 fill_in(mem2);
 offset = 0;
 do {
        int j;
  play_with(mem1, mem2, offset);
        printf("Loop done, offset = %d\n", offset);
  sleep(1);
  offset++;
  if (offset > 256) offset = 0;
 } while(1);
 return 0;
}

canonical_original_code:
int main() {
 unsigned char *mem1; unsigned char *mem2;
 int offset;
 mem1 = (unsigned char *)gimme_some_memory();
 mem2 = (unsigned char *)gimme_some_memory();
 fill_in(mem1);
 fill_in(mem2);
 offset = 0;
 do {
        int j;
  play_with(mem1, mem2, offset);
        printf("Loop done, offset = %d\n", offset);
  sleep(1);
  offset++;
  if (offset > 256) offset = 0;
 } while(1);
 return 0;
}

variable_types: offset int


decompiled_code:
__int64 __fastcall allprefixed_traverse(__int64 a1, __int64 (__fastcall *a2)(__int64, __int64), __int64 a3)
{
int v3; // eax
__int64 result; // rax

if ( (a1 & 1) == 0 )
return a2(a1, a3);
v3 = allprefixed_traverse(*(_QWORD *)(a1 - 1));
if ( v3 )
{
if ( v3 != 1 )
return 0xFFFFFFFFLL;
result = allprefixed_traverse(*(_QWORD *)(a1 + 7));
if ( (_DWORD)result )
{
if ( (_DWORD)result == 1 )
return result;
return 0xFFFFFFFFLL;
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 (__fastcall *a2)(__int64, __int64), __int64 a3)
{
int v3; // eax
__int64 result; // rax

if ( (a1 & 1) == 0 )
return a2(a1, a3);
v3 = func7(*(_QWORD *)(a1 - 1));
if ( v3 )
{
if ( v3 != 1 )
return 0xFFFFFFFFLL;
result = func7(*(_QWORD *)(a1 + 7));
if ( (_DWORD)result )
{
if ( (_DWORD)result == 1 )
return result;
return 0xFFFFFFFFLL;
}
}
return 0LL;
}

original_code:
static int
allprefixed_traverse (uint8_t * top,
        int (*handle) (const char *, void *), void *arg)
{
    if (1 & (intptr_t) top) {
        int direction;
        critbit0_node *q = (void *) (top - 1);
        for (direction = 0; direction < 2; ++direction)
            switch (allprefixed_traverse (q->child[direction], handle, arg)) {
                case 1:
                    break;
                case 0:
                    return 0;
                default:
                    return -1;
            }
        return 1;
    }
  return handle ((const char *) top, arg);
}

canonical_original_code:
static int allprefixed_traverse(unsigned char *top, int (*handle)(char *, void *), void *arg)
{
    if (1 & (long) top) {
        int direction;
        struct critbit0_node *q = (void *) (top - 1);
        for (direction = 0; direction < 2; ++direction)
            switch (allprefixed_traverse (q->child[direction], handle, arg)) {
                case 1:
                    break;
                case 0:
                    return 0;
                default:
                    return -1;
            }
        return 1;
    }
  return handle ((char *) top, arg);
}

variable_types:
top
unsigned char *

variable_types:
handle
int (*)(char *, void *)

variable_types:
arg
void *

variable_types: direction int

variable_types: struct critbit0_node { void *child[2]; unsigned int byte; unsigned char otherbits; } *


traverse

decompiled_code:
void __fastcall traverse(__int64 a1)
{
if ( (a1 & 1) != 0 )
{
traverse(*(_QWORD *)(a1 - 1));
traverse(*(_QWORD *)(a1 + 7));
free((void *)(a1 - 1));
}
else
{
free((void *)a1);
}
}

original_code:
static void
traverse (void *top)
{
    uint8_t *p = top;
    if (1 & (intptr_t) p) {
        critbit0_node *q = (void *) (p - 1);
        traverse (q->child[0]);
        traverse (q->child[1]);
        free (q);
    } else {
        free (p);
    }
}

canonical_original_code:
static void traverse(void *top)
{
    unsigned char *p = top;
    if (1 & (long) p) {
        struct critbit0_node *q = (void *) (p - 1);
        traverse (q->child[0]);
        traverse (q->child[1]);
        free (q);
    } else {
        free (p);
    }
}

variable_types:
top
void *

variable_types:
p
unsigned char *

user_defined_types: struct critbit0_node { void *child[2]; unsigned int byte; unsigned char otherbits; }


decompiled_code:
__int64 __fastcall critbit0_contains(__int64 *a1, const char *a2, _QWORD *a3)
{
__int64 v3; // rbx
size_t i; // rbp
size_t v6; // rdx
char v7; // al
int v8; // edx
__int64 result; // rax

v3 = *a1;
if ( !*a1 )
return 0LL;
for ( i = strlen(a2);
(v3 & 1) != 0;
v3 = *(_QWORD *)(v3 + 8LL * (((unsigned __int8)(*(_BYTE *)(v3 + 19) | v7) + 1) >> 8) - 1) )
{
v6 = *(unsigned int *)(v3 + 15);
v7 = 0;
if ( v6 < i )
v7 = a2[v6];
}
v8 = strcmp(a2, (const char *)v3);
result = 0LL;
if ( !v8 )
{
*a3 = *(_QWORD *)(v3 + i + 1);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 *a1, const char *a2, _QWORD *a3)
{
__int64 v3; // rbx
size_t i; // rbp
size_t v6; // rdx
char v7; // al
int v8; // edx
__int64 result; // rax

v3 = *a1;
if ( !*a1 )
return 0LL;
for ( i = strlen(a2);
(v3 & 1) != 0;
v3 = *(_QWORD *)(v3 + 8LL * (((unsigned __int8)(*(_BYTE *)(v3 + 19) | v7) + 1) >> 8) - 1) )
{
v6 = *(unsigned int *)(v3 + 15);
v7 = 0;
if ( v6 < i )
v7 = a2[v6];
}
v8 = strcmp(a2, (const char *)v3);
result = 0LL;
if ( !v8 )
{
*a3 = *(_QWORD *)(v3 + i + 1);
result = 1LL;
}
return result;
}

original_code:
int
critbit0_contains (critbit0_tree * t, const char *u, void *opq)
{
  const uint8_t *ubytes = (void *) u;
  const size_t ulen = strlen (u);
  uint8_t *p = t->root;
  if (!p)
    return 0;
  while (1 & (intptr_t) p) {
      critbit0_node *q = (void *) (p - 1);
      uint8_t c = 0;
      if (q->byte < ulen)
          c = ubytes[q->byte];
      const int direction = (1 + (q->otherbits | c)) >> 8;
      p = q->child[direction];
  }
  if (0 == strcmp (u, (const char *) p)) {
      memcpy(opq, p + ulen + 1, sizeof(void*));
      return 1;
  }
  return 0;
}

canonical_original_code:
int critbit0_contains(struct critbit0_tree *t, char *u, void *opq)
{
  unsigned char *ubytes = (void *) u;
  unsigned long ulen = strlen (u);
  unsigned char *p = t->root;
  if (!p)
    return 0;
  while (1 & (long) p) {
      struct critbit0_node *q = (void *) (p - 1);
      unsigned char c = 0;
      if (q->byte < ulen)
          c = ubytes[q->byte];
      int direction = (1 + (q->otherbits | c)) >> 8;
      p = q->child[direction];
  }
  if (0 == strcmp (u, (char *) p)) {
      memcpy(opq, p + ulen + 1, sizeof(void *));
      return 1;
  }
  return 0;
}

variable_types:
t
struct critbit0_tree { void *root; } *

variable_types:
u
char *

variable_types:
opq
void *

variable_types:
ubytes
unsigned char *

variable_types:
ulen
unsigned long

variable_types:
c
unsigned char


original_code:
int
critbit0_insert (critbit0_tree * t, const char *u, void *opq)
{
  const uint8_t *const ubytes = (void *) u;
  const size_t ulen = strlen (u);
  uint8_t *p = t->root;
  if (!p) {
      char *x;
      if (posix_memalign ((void **) &x, sizeof (void *), ulen + 1 + sizeof (void*)))
          return 0 ;
      memcpy (x, u, ulen + 1);
      memcpy (x + ulen + 1, &opq, sizeof(void*));
      t->root = x;
      return 2;
  }
  while (1 & (intptr_t) p) {
      critbit0_node *q = (void *) (p - 1);
      uint8_t c = 0;
      if (q->byte < ulen)
          c = ubytes[q->byte];
      const int direction = (1 + (q->otherbits | c)) >> 8;
      p = q->child[direction];
  }
  uint32_t newbyte;
  uint32_t newotherbits;
  for (newbyte = 0; newbyte < ulen; ++newbyte) {
      if (p[newbyte] != ubytes[newbyte]) {
          newotherbits = p[newbyte] ^ ubytes[newbyte];
          goto different_byte_found;
      }
  }
  if (p[newbyte] != 0) {
      newotherbits = p[newbyte];
      goto different_byte_found;
  }
  return 1;
different_byte_found:
  newotherbits |= newotherbits >> 1;
  newotherbits |= newotherbits >> 2;
  newotherbits |= newotherbits >> 4;
  newotherbits = (newotherbits & ~(newotherbits >> 1)) ^ 255;
  uint8_t c = p[newbyte];
  int newdirection = (1 + (newotherbits | c)) >> 8;
  critbit0_node *newnode;
  if (posix_memalign
      ((void **) &newnode, sizeof (void *), sizeof (critbit0_node)))
    return 0;
  char *x;
  if (posix_memalign ((void **) &x, sizeof (void *), ulen + 1 + sizeof(void*))) {
      free (newnode);
      return 0;
  }
  memcpy (x, ubytes, ulen + 1);
  memcpy (x + ulen + 1, &opq, sizeof(void*));
  newnode->byte = newbyte;
  newnode->otherbits = newotherbits;
  newnode->child[1 - newdirection] = x;
  void **wherep = &t->root;
  for (;;) {
      uint8_t *p = *wherep;
      if (!(1 & (intptr_t) p))
          break;
      critbit0_node *q = (void *) (p - 1);
      if (q->byte > newbyte)
          break;
      if (q->byte == newbyte && q->otherbits > newotherbits)
          break;
      uint8_t c = 0;
      if (q->byte < ulen)
          c = ubytes[q->byte];
      const int direction = (1 + (q->otherbits | c)) >> 8;
      wherep = q->child + direction;
  }
  newnode->child[newdirection] = *wherep;
  *wherep = (void *) (1 + (char *) newnode);
  return 2;
}

canonical_original_code:
int critbit0_insert(struct critbit0_tree *t, char *u, void *opq)
{
  unsigned char *ubytes = (void *) u;
  unsigned long ulen = strlen (u);
  unsigned char *p = t->root;
  if (!p) {
      char *x;
      if (posix_memalign ((void **) &x, sizeof (void *), ulen + 1 + sizeof (void *)))
          return 0 ;
      memcpy (x, u, ulen + 1);
      memcpy (x + ulen + 1, &opq, sizeof(void *));
      t->root = x;
      return 2;
  }
  while (1 & (long) p) {
      struct critbit0_node *q = (void *) (p - 1);
      unsigned char c = 0;
      if (q->byte < ulen)
          c = ubytes[q->byte];
      int direction = (1 + (q->otherbits | c)) >> 8;
      p = q->child[direction];
  }
  unsigned int newbyte;
  unsigned int newotherbits;
  for (newbyte = 0; newbyte < ulen; ++newbyte) {
      if (p[newbyte] != ubytes[newbyte]) {
          newotherbits = p[newbyte] ^ ubytes[newbyte];
          goto different_byte_found;
      }
  }
  if (p[newbyte] != 0) {
      newotherbits = p[newbyte];
      goto different_byte_found;
  }
  return 1;
different_byte_found:
  newotherbits |= newotherbits >> 1;
  newotherbits |= newotherbits >> 2;
  newotherbits |= newotherbits >> 4;
  newotherbits = (newotherbits & ~(newotherbits >> 1)) ^ 255;
  unsigned char c = p[newbyte];
  int newdirection = (1 + (newotherbits | c)) >> 8;
  struct critbit0_node *newnode;
  if (posix_memalign
      ((void **) &newnode, sizeof (void *), sizeof (critbit0_node)))
    return 0;
  char *x;
  if (posix_memalign ((void **) &x, sizeof (void *), ulen + 1 + sizeof(void *))) {
      free (newnode);
      return 0;
  }
  memcpy (x, ubytes, ulen + 1);
  memcpy (x + ulen + 1, &opq, sizeof(void *));
  newnode->byte = newbyte;
  newnode->otherbits = newotherbits;
  newnode->child[1 - newdirection] = x;
  void **wherep = &t->root;
  for (;;) {
      unsigned char *p = *wherep;
      if (!(1 & (long) p))
          break;
      struct critbit0_node *q = (void *) (p - 1);
      if (q->byte > newbyte)
          break;
      if (q->byte == newbyte && q->otherbits > newotherbits)
          break;
      unsigned char c = 0;
      if (q->byte < ulen)
          c = ubytes[q->byte];
      int direction = (1 + (q->otherbits | c)) >> 8;
      wherep = q->child + direction;
  }
  newnode->child[newdirection] = *wherep;
  *wherep = (void *) (1 + (char *) newnode);
  return 2;
}

variable_types:
x
char *

variable_types:
newbyte
unsigned int

variable_types:
newotherbits
unsigned int

variable_types: newdirection int

variable_types:
wherep
void **


decompiled_code:
__int64 __fastcall critbit0_delete(char *a1, const char *a2, _QWORD *a3)
{
char *v3; // rbp
size_t v4; // r13
int v5; // ebx
const char **v6; // rax
char *v7; // r12
size_t v8; // rax
char v9; // bl
int v10; // edx
__int64 result; // rax
int v12; // edx
char *v13; // [rsp+0h] [rbp-48h]

v3 = *(char **)a1;
if ( !*(_QWORD *)a1 )
return 0LL;
v4 = strlen(a2);
if ( ((unsigned __int8)v3 & 1) == 0 )
{
v12 = strcmp(a2, v3);
result = 0LL;
if ( v12 )
return result;
*a3 = *(_QWORD *)&v3[v4 + 1];
free(v3);
LABEL_15:
*(_QWORD *)a1 = 0LL;
return 1LL;
}
v13 = a1;
while ( 1 )
{
v8 = *(unsigned int *)(v3 + 15);
v9 = 0;
if ( v8 < v4 )
v9 = a2[v8];
v5 = ((unsigned __int8)(v3[19] | v9) + 1) >> 8;
v6 = (const char **)&v3[8 * v5 - 1];
v7 = (char *)*v6;
if ( ((unsigned __int8)*v6 & 1) == 0 )
break;
v13 = &v3[8 * v5 - 1];
v3 = (char *)*v6;
}
v10 = strcmp(a2, *v6);
result = 0LL;
if ( !v10 )
{
*a3 = *(_QWORD *)&v7[v4 + 1];
free(v7);
if ( v13 )
{
*(_QWORD *)v13 = *(_QWORD *)&v3[8 * (1 - v5) - 1];
free(v3 - 1);
return 1LL;
}
goto LABEL_15;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(char *a1, const char *a2, _QWORD *a3)
{
char *v3; // rbp
size_t v4; // r13
int v5; // ebx
const char **v6; // rax
char *v7; // r12
size_t v8; // rax
char v9; // bl
int v10; // edx
__int64 result; // rax
int v12; // edx
char *v13; // [rsp+0h] [rbp-48h]

v3 = *(char **)a1;
if ( !*(_QWORD *)a1 )
return 0LL;
v4 = strlen(a2);
if ( ((unsigned __int8)v3 & 1) == 0 )
{
v12 = strcmp(a2, v3);
result = 0LL;
if ( v12 )
return result;
*a3 = *(_QWORD *)&v3[v4 + 1];
free(v3);
LABEL_15:
*(_QWORD *)a1 = 0LL;
return 1LL;
}
v13 = a1;
while ( 1 )
{
v8 = *(unsigned int *)(v3 + 15);
v9 = 0;
if ( v8 < v4 )
v9 = a2[v8];
v5 = ((unsigned __int8)(v3[19] | v9) + 1) >> 8;
v6 = (const char **)&v3[8 * v5 - 1];
v7 = (char *)*v6;
if ( ((unsigned __int8)*v6 & 1) == 0 )
break;
v13 = &v3[8 * v5 - 1];
v3 = (char *)*v6;
}
v10 = strcmp(a2, *v6);
result = 0LL;
if ( !v10 )
{
*a3 = *(_QWORD *)&v7[v4 + 1];
free(v7);
if ( v13 )
{
*(_QWORD *)v13 = *(_QWORD *)&v3[8 * (1 - v5) - 1];
free(v3 - 1);
return 1LL;
}
goto LABEL_15;
}
return result;
}

original_code:
int
critbit0_delete (critbit0_tree * t, const char *u, void *opq)
{
  const uint8_t *ubytes = (void *) u;
  const size_t ulen = strlen (u);
  uint8_t *p = t->root;
  void **wherep = &t->root;
  void **whereq = 0;
  critbit0_node *q = 0;
  int direction = 0;
  if (!p)
    return 0;
  while (1 & (intptr_t) p) {
      whereq = wherep;
      q = (void *) (p - 1);
      uint8_t c = 0;
      if (q->byte < ulen)
          c = ubytes[q->byte];
      direction = (1 + (q->otherbits | c)) >> 8;
      wherep = q->child + direction;
      p = *wherep;
  }
  if (0 != strcmp (u, (const char *) p))
    return 0;
  memcpy(opq, p + ulen + 1, sizeof(void*));
  free (p);
  if (!whereq) {
      t->root = 0;
      return 1;
  }
  *whereq = q->child[1 - direction];
  free (q);
  return 1;
}

canonical_original_code:
int critbit0_delete(struct critbit0_tree *t, char *u, void *opq)
{
  unsigned char *ubytes = (void *) u;
  unsigned long ulen = strlen (u);
  unsigned char *p = t->root;
  void **wherep = &t->root;
  void **whereq = 0;
  struct critbit0_node *q = 0;
  int direction = 0;
  if (!p)
    return 0;
  while (1 & (long) p) {
      whereq = wherep;
      q = (void *) (p - 1);
      unsigned char c = 0;
      if (q->byte < ulen)
          c = ubytes[q->byte];
      direction = (1 + (q->otherbits | c)) >> 8;
      wherep = q->child + direction;
      p = *wherep;
  }
  if (0 != strcmp (u, (char *) p))
    return 0;
  memcpy(opq, p + ulen + 1, sizeof(void *));
  free (p);
  if (!whereq) {
      t->root = 0;
      return 1;
  }
  *whereq = q->child[1 - direction];
  free (q);
  return 1;
}

variable_types:
whereq
void **


decompiled_code:
void __fastcall critbit0_clear(__int64 *a1)
{
__int64 v2; // rdi

v2 = *a1;
if ( v2 )
traverse(v2);
*a1 = 0LL;
}

canonical_decompiled_code:
void __fastcall func12(__int64 *a1)
{
__int64 v2; // rdi

v2 = *a1;
if ( v2 )
func8(v2);
*a1 = 0LL;
}

original_code:
void
critbit0_clear (critbit0_tree * t)
{
  if (t->root)
    traverse (t->root);
  t->root = ((void *)0);
}

canonical_original_code:
void critbit0_clear(struct critbit0_tree *t)
{
  if (t->root)
    traverse (t->root);
  t->root = ((void *)0);
}


original_code:
int
critbit0_allprefixed (critbit0_tree * t, const char *prefix,
        int (*handle) (const char *, void *), void *arg)
{
  const uint8_t *ubytes = (void *) prefix;
  const size_t ulen = strlen (prefix);
  uint8_t *p = t->root;
  uint8_t *top = p;
  if (!p)
    return 1;
  while (1 & (intptr_t) p) {
      critbit0_node *q = (void *) (p - 1);
      uint8_t c = 0;
      if (q->byte < ulen)
          c = ubytes[q->byte];
      const int direction = (1 + (q->otherbits | c)) >> 8;
      p = q->child[direction];
      if (q->byte < ulen)
          top = p;
  }
  size_t i;
  for (i = 0; i < ulen; ++i) {
      if (p[i] != ubytes[i])
          return 1;
  }
  return allprefixed_traverse (top, handle, arg);
}

canonical_original_code:
int critbit0_allprefixed(struct critbit0_tree *t, char *prefix, int (*handle)(char *, void *), void *arg)
{
  unsigned char *ubytes = (void *) prefix;
  unsigned long ulen = strlen (prefix);
  unsigned char *p = t->root;
  unsigned char *top = p;
  if (!p)
    return 1;
  while (1 & (long) p) {
      struct critbit0_node *q = (void *) (p - 1);
      unsigned char c = 0;
      if (q->byte < ulen)
          c = ubytes[q->byte];
      int direction = (1 + (q->otherbits | c)) >> 8;
      p = q->child[direction];
      if (q->byte < ulen)
          top = p;
  }
  unsigned long i;
  for (i = 0; i < ulen; ++i) {
      if (p[i] != ubytes[i])
          return 1;
  }
  return allprefixed_traverse (top, handle, arg);
}

variable_types:
prefix
char *

variable_types:
handle
int (*)(char *, void *)

variable_types:
arg
void *

variable_types:
top
unsigned char *

variable_types:
i
unsigned long


cbk

decompiled_code:
__int64 __fastcall cbk(const char *a1)
{
unsigned int *v1; // rbp

v1 = *(unsigned int **)&a1[strlen(a1) + 1];
printf("\n ToFree PTRs: p [%s], %p, =%d=", a1, v1, *v1);
free(v1);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func14(const char *a1)
{
unsigned int *v1; // rbp

v1 = *(unsigned int **)&a1[strlen(a1) + 1];
printf("\n ToFree PTRs: p [%s], %p, =%d=", a1, v1, *v1);
free(v1);
return 1LL;
}

original_code:
int cbk (const char *e, void *p)
{
    int *v;
    memcpy(&v, e+strlen(e)+1, sizeof(void*));
    printf ("\n ToFree PTRs: p [%s], %p, =%d=", e, (v) , *v);
    free(v);
    return 1;
}

canonical_original_code:
int cbk(char *e, void *p)
{
    int *v;
    memcpy(&v, e+strlen(e)+1, sizeof(void *));
    printf ("\n ToFree PTRs: p [%s], %p, =%d=", e, (v) , *v);
    free(v);
    return 1;
}

variable_types:
e
char *

variable_types:
p
void *

variable_types:
v
int *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // r12
const char **v4; // r13
const char *v5; // rbp
_DWORD *v6; // rbx
__int64 v7; // rdx
const char *v8; // rbx
unsigned int *v10; // [rsp+0h] [rbp-38h] BYREF
__int64 v11[6]; // [rsp+8h] [rbp-30h] BYREF

v11[0] = 0LL;
v3 = (const char **)elems_0;
v4 = (const char **)elems_0;
v5 = "10.10.1.0";
do
{
v6 = malloc(4uLL);
v7 = (unsigned int)strlen(v5) + 10;
*v6 = v7;
printf("\n Insert %s = %d at %p\n", v5, v7, v6);
critbit0_insert(v11, v5, (__int64)v6);
v5 = *++v4;
}
while ( *v4 );
v8 = "10.10.1.0";
do
{
if ( (unsigned int)critbit0_contains(v11, v8, &v10) )
printf("\n Contains: %s %lx, > %d\n", v8, v10, *v10);
v8 = *++v3;
}
while ( *v3 );
critbit0_allprefixed(v11, "", (__int64 (__fastcall *)(__int64, __int64))cbk, 0LL);
critbit0_clear(v11);
puts("\n");
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // r12
const char **v4; // r13
const char *v5; // rbp
_DWORD *v6; // rbx
__int64 v7; // rdx
const char *v8; // rbx
unsigned int *v10; // [rsp+0h] [rbp-38h] BYREF
__int64 v11[6]; // [rsp+8h] [rbp-30h] BYREF

v11[0] = 0LL;
v3 = (const char **)elems_0;
v4 = (const char **)elems_0;
v5 = "10.10.1.0";
do
{
v6 = malloc(4uLL);
v7 = (unsigned int)strlen(v5) + 10;
*v6 = v7;
printf("\n Insert %s = %d at %p\n", v5, v7, v6);
func10(v11, v5, (__int64)v6);
v5 = *++v4;
}
while ( *v4 );
v8 = "10.10.1.0";
do
{
if ( (unsigned int)func9(v11, v8, &v10) )
printf("\n Contains: %s %lx, > %d\n", v8, v10, *v10);
v8 = *++v3;
}
while ( *v3 );
func13(v11, "", (__int64 (__fastcall *)(__int64, __int64))cbk, 0LL);
func12(v11);
puts("\n");
return 0;
}

original_code:
int main()
{
    critbit0_tree tree = { 0 };
    int *v;
    int i;
    static const char *elems[] =
       { "10.10.1.0", "10.10.255.0", "10.10.12.0", ((void *)0)};
    for (i = 0; elems[i]; ++i) {
        v = malloc(sizeof(int));
        *v = 10+strlen(elems[i]);
        printf ("\n Insert %s = %d at %p\n", elems[i], *v, v );
 critbit0_insert(&tree, elems[i], v);
    }
    int x;
    uintptr_t p;
    for (i = 0; elems[i]; ++i) {
        if (critbit0_contains(&tree, elems[i], &p)) {
            x = *(int*)p;
            printf ("\n Contains: %s %""l" "x"", > %d\n",elems[i], p, x);
        }
    }
    critbit0_allprefixed(&tree, "", cbk, ((void *)0));
    critbit0_clear(&tree);
    printf ("\n\n");
    return 0;
}

canonical_original_code:
int main()
{
    struct critbit0_tree tree = { 0 };
    int *v;
    int i;
    static char *elems[] = { "10.10.1.0", "10.10.255.0", "10.10.12.0", ((void *)0)};
    for (i = 0; elems[i]; ++i) {
        v = malloc(sizeof(int));
        *v = 10+strlen(elems[i]);
        printf ("\n Insert %s = %d at %p\n", elems[i], *v, v );
 critbit0_insert(&tree, elems[i], v);
    }
    int x;
    unsigned long p;
    for (i = 0; elems[i]; ++i) {
        if (critbit0_contains(&tree, elems[i], &p)) {
            x = *(int *)p;
            printf ("\n Contains: %s %""l" "x"", > %d\n",elems[i], p, x);
        }
    }
    critbit0_allprefixed(&tree, "", cbk, ((void *)0));
    critbit0_clear(&tree);
    printf ("\n\n");
    return 0;
}

variable_types:
tree
struct critbit0_tree { void *root; }

variable_types: i int

variable_types:
elems
char *[]

variable_types: x int

variable_types:
p
unsigned long


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

if ( (unsigned int)CU_initialize_registry(argc, argv, envp) )
return CU_get_error();
v3 = CU_add_suite("Suite_UTIL", &init_suite_UTIL, &clean_suite_UTIL);
v4 = v3;
if ( v3
&& CU_add_test(v3, "test of type_c_to_composite()", &type_c_to_composite_test)
&& CU_add_test(v4, "test of type_c_from_str()", &type_c_from_str_test)
&& CU_add_test(v4, "test of type_c_to_str()", &type_c_to_str_test)
&& CU_add_test(v4, "test of type_composite_from_str()", &type_composite_from_str_test)
&& CU_add_test(v4, "test of type_composite_to_str()", &type_composite_to_str_test)
&& CU_add_test(v4, "test of function_header()", &function_header_test)
&& CU_add_test(v4, "test of function_set_name()", &function_set_name_test)
&& CU_add_test(v4, "test of parameter_declaration_set()", &parameter_declaration_set_test)
&& CU_add_test(v4, "test of function_var()", &function_var_test)
&& CU_add_test(v4, "test of init_declarator_set()", &init_declarator_set_test)
&& CU_add_test(v4, "test of function_add_command()", &function_add_command_test)
&& CU_add_test(v4, "test of function_code()", &function_code_test)
&& CU_add_test(v4, "test of function_get_var()", &function_get_var_test)
&& CU_add_test(v4, "test of function_copy_var()", &function_copy_var_test)
&& CU_add_test(v4, "test of unique_label_name()", &unique_label_name_test)
&& CU_add_test(v4, "test of unique_var_name()", &unique_var_name_test)
&& CU_add_test(v4, "test of function_get_type()", &function_get_type_test) )
{
if ( CU_add_test(v4, "test of implicit_cast_type()", &implicit_cast_type_test) )
{
CU_basic_set_mode(2LL);
CU_basic_run_tests();
}
}
CU_cleanup_registry();
return CU_get_error();
}

original_code:
int main(int argc, char **argv)
{
 CU_pSuite psuite = ((void *)0);
 if (CU_initialize_registry() != CUE_SUCCESS)
  return CU_get_error();
 psuite = CU_add_suite("Suite_UTIL", init_suite_UTIL, clean_suite_UTIL);
 if (psuite == ((void *)0))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of type_c_to_composite()", type_c_to_composite_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of type_c_from_str()", type_c_from_str_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of type_c_to_str()", type_c_to_str_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of type_composite_from_str()", type_composite_from_str_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of type_composite_to_str()", type_composite_to_str_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of function_header()", function_header_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of function_set_name()", function_set_name_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  parameter_declaration_set()", parameter_declaration_set_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  function_var()", function_var_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  init_declarator_set()", init_declarator_set_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  function_add_command()", function_add_command_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  function_code()", function_code_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  function_get_var()", function_get_var_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  function_copy_var()", function_copy_var_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  unique_label_name()", unique_label_name_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  unique_var_name()", unique_var_name_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  function_get_type()", function_get_type_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  implicit_cast_type()", implicit_cast_type_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 CU_basic_set_mode(CU_BRM_VERBOSE);
 CU_basic_run_tests();
 CU_cleanup_registry();
 return CU_get_error();
}

canonical_original_code:
int main(int argc, char **argv)
{
 struct CU_Suite *psuite = ((void *)0);
 if (CU_initialize_registry() != CUE_SUCCESS)
  return CU_get_error();
 psuite = CU_add_suite("Suite_UTIL", init_suite_UTIL, clean_suite_UTIL);
 if (psuite == ((void *)0))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of type_c_to_composite()", type_c_to_composite_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of type_c_from_str()", type_c_from_str_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of type_c_to_str()", type_c_to_str_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of type_composite_from_str()", type_composite_from_str_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of type_composite_to_str()", type_composite_to_str_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of function_header()", function_header_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of function_set_name()", function_set_name_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  parameter_declaration_set()", parameter_declaration_set_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  function_var()", function_var_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  init_declarator_set()", init_declarator_set_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  function_add_command()", function_add_command_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  function_code()", function_code_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  function_get_var()", function_get_var_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  function_copy_var()", function_copy_var_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  unique_label_name()", unique_label_name_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  unique_var_name()", unique_var_name_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  function_get_type()", function_get_type_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 if((CU_add_test(psuite, "test of  implicit_cast_type()", implicit_cast_type_test) == ((void *)0)))
 {
  CU_cleanup_registry();
  return CU_get_error();
 }
 CU_basic_set_mode(CU_BRM_VERBOSE);
 CU_basic_run_tests();
 CU_cleanup_registry();
 return CU_get_error();
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct CU_Suite { char *pName; int fActive; struct CU_Test { char *pName; int fActive; void (*pTestFunc)(); struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } (*pJumpBuf)[1]; struct CU_Test *pNext; struct CU_Test *pPrev; } *pTest; int (*pInitializeFunc)(); int (*pCleanupFunc)(); void (*pSetUpFunc)(); void (*pTearDownFunc)(); unsigned int uiNumberOfTests; struct CU_Suite *pNext; struct CU_Suite *pPrev; unsigned int uiNumberOfTestsFailed; unsigned int uiNumberOfTestsSuccess; } *

user_defined_types: struct CU_Suite { char *pName; int fActive; struct CU_Test *pTest; int (*pInitializeFunc)(); int (*pCleanupFunc)(); void (*pSetUpFunc)(); void (*pTearDownFunc)(); unsigned int uiNumberOfTests; struct CU_Suite *pNext; struct CU_Suite *pPrev; unsigned int uiNumberOfTestsFailed; unsigned int uiNumberOfTestsSuccess; }

user_defined_types: struct CU_Test { char *pName; int fActive; void (*pTestFunc)(); struct __jmp_buf_tag (*pJumpBuf)[1]; struct CU_Test *pNext; struct CU_Test *pPrev; }

user_defined_types: struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t __saved_mask; }


BuildOneTwoThree

repo: ankitC/rev

decompiled_code:
__int64 BuildOneTwoThree()
{
__int64 v1[2]; // [rsp+8h] [rbp-10h] BYREF

v1[0] = 0LL;
Push(v1, 3);
Push(v1, 2);
Push(v1, 1);
return v1[0];
}

original_code:
struct node* BuildOneTwoThree()
{
 struct node* head = ((void *)0);
 Push(&head, 3);
 Push(&head, 2);
 Push(&head, 1);
 return(head);
}

canonical_original_code:
struct node *BuildOneTwoThree()
{
 struct node *head = ((void *)0);
 Push(&head, 3);
 Push(&head, 2);
 Push(&head, 1);
 return(head);
}

variable_types: struct node { int data; struct node *next; } *


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

if ( !a1 )
return 0LL;
LODWORD(result) = 0;
do
{
result = (unsigned int)(result + 1);
a1 = *(_QWORD *)(a1 + 8);
}
while ( a1 );
return result;
}

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

if ( !a1 )
return 0LL;
LODWORD(result) = 0;
do
{
result = (unsigned int)(result + 1);
a1 = *(_QWORD *)(a1 + 8);
}
while ( a1 );
return result;
}

original_code:
int list_length(struct node* head)
{
 int count = 0;
 struct node* current = head;
 while(current!=((void *)0))
 {
  count++;
  current = current->next;
 }
 return count;
}

canonical_original_code:
int list_length(struct node *head)
{
 int count = 0;
 struct node *current = head;
 while(current!=((void *)0))
 {
  count++;
  current = current->next;
 }
 return count;
}

variable_types: count int

user_defined_types: struct node { int data; struct node *next; }


decompiled_code:
int __fastcall print_list(unsigned int *a1)
{
unsigned int *v1; // rbx

v1 = a1;
if ( !a1 )
return puts("List is empty!");
do
{
printf("%d\t", *v1);
v1 = (unsigned int *)*((_QWORD *)v1 + 1);
}
while ( v1 );
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func9(unsigned int *a1)
{
unsigned int *v1; // rbx

v1 = a1;
if ( !a1 )
return puts("List is empty!");
do
{
printf("%d\t", *v1);
v1 = (unsigned int *)*((_QWORD *)v1 + 1);
}
while ( v1 );
return putchar(10);
}

original_code:
void print_list(struct node* head)
{
 if( head == ((void *)0) )
  printf("List is empty!\n");
 else
 {
  struct node* current = head;
  while(current!=((void *)0))
  {
   printf("%d\t", current->data);
   current = current->next;
  }
  printf("\n");
 }
}

canonical_original_code:
void print_list(struct node *head)
{
 if( head == ((void *)0) )
  printf("List is empty!\n");
 else
 {
  struct node *current = head;
  while(current!=((void *)0))
  {
   printf("%d\t", current->data);
   current = current->next;
  }
  printf("\n");
 }
}


Count

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

if ( !a1 )
return 0LL;
LODWORD(result) = 0;
do
{
result = (*(_DWORD *)a1 == a2) + (unsigned int)result;
a1 = *(_QWORD *)(a1 + 8);
}
while ( a1 );
return result;
}

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

if ( !a1 )
return 0LL;
LODWORD(result) = 0;
do
{
result = (*(_DWORD *)a1 == a2) + (unsigned int)result;
a1 = *(_QWORD *)(a1 + 8);
}
while ( a1 );
return result;
}

original_code:
int Count(struct node* head, int search_for)
{
 int count = 0;
 if( head == ((void *)0))
  return 0;
 struct node* current = head;
 while(current != ((void *)0))
 {
  if(current->data == search_for)
   count++;
  current=current->next;
 }
 return count;
}

canonical_original_code:
int Count(struct node *head, int search_for)
{
 int count = 0;
 if( head == ((void *)0))
  return 0;
 struct node *current = head;
 while(current != ((void *)0))
 {
  if(current->data == search_for)
   count++;
  current=current->next;
 }
 return count;
}


decompiled_code:
__int64 __fastcall get_nth(__int64 a1, int a2)
{
unsigned int *v2; // rbx
int v3; // eax
__int64 result; // rax

v2 = (unsigned int *)a1;
if ( (int)list_length(a1) <= a2 )
{
puts("Invalid Position.");
result = 0LL;
}
else
{
v3 = 0;
if ( a2 > 0 )
{
do
{
v2 = (unsigned int *)*((_QWORD *)v2 + 1);
++v3;
}
while ( a2 != v3 );
}
result = *v2;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, int a2)
{
unsigned int *v2; // rbx
int v3; // eax
__int64 result; // rax

v2 = (unsigned int *)a1;
if ( (int)func8(a1) <= a2 )
{
puts("Invalid Position.");
result = 0LL;
}
else
{
v3 = 0;
if ( a2 > 0 )
{
do
{
v2 = (unsigned int *)*((_QWORD *)v2 + 1);
++v3;
}
while ( a2 != v3 );
}
result = *v2;
}
return result;
}

original_code:
int get_nth(struct node* head, int position)
{
 int i = 0;
 int data;
 struct node* current = head;
 if(position > list_length(head) - 1)
 {
  printf("Invalid Position.\n");
  return 0;
 }
 for(i = 0; i< position; i++)
 {
  current = current->next;
 }
 data = current->data;
 return data;
}

canonical_original_code:
int get_nth(struct node *head, int position)
{
 int i = 0;
 int data;
 struct node *current = head;
 if(position > list_length(head) - 1)
 {
  printf("Invalid Position.\n");
  return 0;
 }
 for(i = 0; i< position; i++)
 {
  current = current->next;
 }
 data = current->data;
 return data;
}

variable_types: position int

variable_types: data int


pop

decompiled_code:
__int64 __fastcall pop(void **a1)
{
int *v1; // rax
unsigned int v2; // ebx

v1 = (int *)*a1;
v2 = 0;
if ( *a1 )
{
v2 = *v1;
*a1 = (void *)*((_QWORD *)v1 + 1);
free(v1);
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func13(void **a1)
{
int *v1; // rax
unsigned int v2; // ebx

v1 = (int *)*a1;
v2 = 0;
if ( *a1 )
{
v2 = *v1;
*a1 = (void *)*((_QWORD *)v1 + 1);
free(v1);
}
return v2;
}

original_code:
int pop(struct node** headRef)
{
 struct node* head = *headRef;
 if(head == ((void *)0))
  return 0;
 int retval = head->data;
 *headRef = (*headRef)->next;
 free(head);
 return retval;
}

canonical_original_code:
int pop(struct node **headRef)
{
 struct node *head = *headRef;
 if(head == ((void *)0))
  return 0;
 int retval = head->data;
 *headRef = (*headRef)->next;
 free(head);
 return retval;
}

variable_types: struct node { int data; struct node *next; } **

variable_types: retval int


decompiled_code:
int __fastcall insert_nth(__int64 *a1, int a2, int a3)
{
__int64 v4; // rbx
_QWORD *v5; // rax
_QWORD *v6; // rcx
int v7; // eax

v4 = *a1;
if ( (int)(list_length(*a1) + 1) < a2 )
{
LODWORD(v5) = puts("Trying to insert at invalid position!");
}
else
{
v5 = malloc(0x10uLL);
v6 = v5;
*(_DWORD *)v5 = a3;
if ( a2 )
{
v7 = 0;
if ( a2 > 1 )
{
do
{
v4 = *(_QWORD *)(v4 + 8);
++v7;
}
while ( a2 - 1 != v7 );
}
v5 = *(_QWORD **)(v4 + 8);
v6[1] = v5;
*(_QWORD *)(v4 + 8) = v6;
}
else
{
v5[1] = v4;
*a1 = (__int64)v5;
}
}
return (int)v5;
}

canonical_decompiled_code:
int __fastcall func14(__int64 *a1, int a2, int a3)
{
__int64 v4; // rbx
_QWORD *v5; // rax
_QWORD *v6; // rcx
int v7; // eax

v4 = *a1;
if ( (int)(func8(*a1) + 1) < a2 )
{
LODWORD(v5) = puts("Trying to insert at invalid position!");
}
else
{
v5 = malloc(0x10uLL);
v6 = v5;
*(_DWORD *)v5 = a3;
if ( a2 )
{
v7 = 0;
if ( a2 > 1 )
{
do
{
v4 = *(_QWORD *)(v4 + 8);
++v7;
}
while ( a2 - 1 != v7 );
}
v5 = *(_QWORD **)(v4 + 8);
v6[1] = v5;
*(_QWORD *)(v4 + 8) = v6;
}
else
{
v5[1] = v4;
*a1 = (__int64)v5;
}
}
return (int)v5;
}

original_code:
void insert_nth(struct node** headRef, int pos, int element)
{
 struct node* head = *headRef;
 struct node* current = head;
 int i = 0;
 if(pos > (list_length(head) + 1))
 {
  printf("Trying to insert at invalid position!\n");
  return;
 }
 struct node* new_node = (struct node*) malloc(sizeof(struct node));
 new_node->data = element;
 if(pos == 0)
 {
  new_node->next = head;
  *headRef = new_node;
  return;
 }
 for(i=0; i<pos-1; i++)
  current = current->next;
 new_node->next = current->next;
 current->next = new_node;
}

canonical_original_code:
void insert_nth(struct node **headRef, int pos, int element)
{
 struct node *head = *headRef;
 struct node *current = head;
 int i = 0;
 if(pos > (list_length(head) + 1))
 {
  printf("Trying to insert at invalid position!\n");
  return;
 }
 struct node *new_node = (struct node*) malloc(sizeof(struct node));
 new_node->data = element;
 if(pos == 0)
 {
  new_node->next = head;
  *headRef = new_node;
  return;
 }
 for(i=0; i<pos-1; i++)
  current = current->next;
 new_node->next = current->next;
 current->next = new_node;
}

variable_types: pos int

variable_types: element int


original_code:
void remove_duplicates(struct node* head)
{
 if(head == ((void *)0)||head->next == ((void *)0))
  return;
 struct node* current = head;
 struct node* next_node = head->next;
 struct node* to_free = ((void *)0);
 do
 {
  if(current->data == next_node->data)
  {
   to_free = next_node;
   next_node = next_node->next;
   current->next = next_node;
   free(to_free);
   continue;
  }
  current=current->next;
  next_node = next_node->next;
 }while(next_node!=((void *)0));
}

canonical_original_code:
void remove_duplicates(struct node *head)
{
 if(head == ((void *)0)||head->next == ((void *)0))
  return;
 struct node *current = head;
 struct node *next_node = head->next;
 struct node *to_free = ((void *)0);
 do
 {
  if(current->data == next_node->data)
  {
   to_free = next_node;
   next_node = next_node->next;
   current->next = next_node;
   free(to_free);
   continue;
  }
  current=current->next;
  next_node = next_node->next;
 }while(next_node!=((void *)0));
}


decompiled_code:
__int64 __fastcall alternating_split(__int64 a1, _QWORD *a2, _QWORD *a3)
{
__int64 result; // rax
__int64 v5[3]; // [rsp+0h] [rbp-18h] BYREF

v5[0] = a1;
*a2 = 0LL;
*a3 = 0LL;
while ( v5[0] )
{
result = move_node(a2, v5);
if ( v5[0] )
result = move_node(a3, v5);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1, _QWORD *a2, _QWORD *a3)
{
__int64 result; // rax
__int64 v5[3]; // [rsp+0h] [rbp-18h] BYREF

v5[0] = a1;
*a2 = 0LL;
*a3 = 0LL;
while ( v5[0] )
{
result = func19(a2, v5);
if ( v5[0] )
result = func19(a3, v5);
}
return result;
}

original_code:
void alternating_split(struct node* source, struct node** aRef, struct node** bRef)
{
 *aRef = ((void *)0);
 *bRef = ((void *)0);
 while(source!=((void *)0))
 {
  move_node(aRef, &source);
  if(source!=((void *)0))
   move_node(bRef, &source);
 }
}

canonical_original_code:
void alternating_split(struct node *source, struct node **aRef, struct node **bRef)
{
 *aRef = ((void *)0);
 *bRef = ((void *)0);
 while(source!=((void *)0))
 {
  move_node(aRef, &source);
  if(source!=((void *)0))
   move_node(bRef, &source);
 }
}

variable_types:
aRef
struct node **

variable_types:
bRef
struct node **


original_code:
struct node* shuffle_merge(struct node* a, struct node* b)
{
 struct node* returned;
 if(a == ((void *)0) && b == ((void *)0))
  return ((void *)0);
 else if(a == ((void *)0) && b!=((void *)0))
 {
  returned = shuffle_merge(((void *)0), b->next);
  b->next = returned;
  return b;
 }
 else if(a!=((void *)0) && b==((void *)0))
 {
  returned = shuffle_merge(a->next, ((void *)0));
  a->next = returned;
  return a;
 }
 else if(a!=((void *)0) && b!=((void *)0))
 {
  returned = shuffle_merge(a->next, b->next);
  b->next = returned;
  a->next = b;
  return a;
 }
}

canonical_original_code:
struct node *shuffle_merge(struct node *a, struct node *b)
{
 struct node *returned;
 if(a == ((void *)0) && b == ((void *)0))
  return ((void *)0);
 else if(a == ((void *)0) && b!=((void *)0))
 {
  returned = shuffle_merge(((void *)0), b->next);
  b->next = returned;
  return b;
 }
 else if(a!=((void *)0) && b==((void *)0))
 {
  returned = shuffle_merge(a->next, ((void *)0));
  a->next = returned;
  return a;
 }
 else if(a!=((void *)0) && b!=((void *)0))
 {
  returned = shuffle_merge(a->next, b->next);
  b->next = returned;
  a->next = b;
  return a;
 }
}

variable_types:
a
struct node *

variable_types:
b
struct node *

return_type: struct node { int data; struct node *next; } *


original_code:
struct node* sorted_merge(struct node* a, struct node* b)
{
 struct node* returned = ((void *)0);
 if(a==((void *)0) && b==((void *)0))
  return ((void *)0);
 else if(a!=((void *)0) && b==((void *)0))
 {
  returned = sorted_merge(a->next, ((void *)0));
  move_node(&returned, &a);
 }
 else if(a==((void *)0) && b!=((void *)0))
 {
  returned = sorted_merge(((void *)0), b->next);
  move_node(&returned, &b);
 }
 else if(a!=((void *)0) && b!=((void *)0))
 {
  if(b->data <= a->data)
  {
   returned = sorted_merge(a, b->next);
   b->next == ((void *)0);
   move_node(&returned,&b);
  }
  else
  {
   returned = sorted_merge(a->next, b);
   a->next == ((void *)0);
   move_node(&returned,&a);
  }
 }
 return returned;
}

canonical_original_code:
struct node *sorted_merge(struct node *a, struct node *b)
{
 struct node *returned = ((void *)0);
 if(a==((void *)0) && b==((void *)0))
  return ((void *)0);
 else if(a!=((void *)0) && b==((void *)0))
 {
  returned = sorted_merge(a->next, ((void *)0));
  move_node(&returned, &a);
 }
 else if(a==((void *)0) && b!=((void *)0))
 {
  returned = sorted_merge(((void *)0), b->next);
  move_node(&returned, &b);
 }
 else if(a!=((void *)0) && b!=((void *)0))
 {
  if(b->data <= a->data)
  {
   returned = sorted_merge(a, b->next);
   b->next == ((void *)0);
   move_node(&returned,&b);
  }
  else
  {
   returned = sorted_merge(a->next, b);
   a->next == ((void *)0);
   move_node(&returned,&a);
  }
 }
 return returned;
}


decompiled_code:
int __fastcall merge_sort(unsigned int **a1)
{
int result; // eax
unsigned int *v3; // rdi
unsigned int *v4; // rax
unsigned int *v5; // [rsp+0h] [rbp-18h] BYREF
unsigned int *v6[2]; // [rsp+8h] [rbp-10h] BYREF

v6[0] = 0LL;
v5 = 0LL;
result = print_list(*a1);
v3 = *a1;
if ( *((_QWORD *)*a1 + 1) )
{
front_back_split((__int64)v3, (__int64 *)v6, &v5);
if ( v6[0] )
merge_sort(v6);
print_list(v6[0]);
if ( v5 )
merge_sort(&v5);
print_list(v5);
v4 = (unsigned int *)sorted_merge((__int64)v6[0], (__int64)v5);
*a1 = v4;
result = print_list(v4);
}
return result;
}

canonical_decompiled_code:
int __fastcall func23(unsigned int **a1)
{
int result; // eax
unsigned int *v3; // rdi
unsigned int *v4; // rax
unsigned int *v5; // [rsp+0h] [rbp-18h] BYREF
unsigned int *v6[2]; // [rsp+8h] [rbp-10h] BYREF

v6[0] = 0LL;
v5 = 0LL;
result = func9(*a1);
v3 = *a1;
if ( *((_QWORD *)*a1 + 1) )
{
func17((__int64)v3, (__int64 *)v6, &v5);
if ( v6[0] )
func23(v6);
func9(v6[0]);
if ( v5 )
func23(&v5);
func9(v5);
v4 = (unsigned int *)func22((__int64)v6[0], (__int64)v5);
*a1 = v4;
result = func9(v4);
}
return result;
}

original_code:
void merge_sort(struct node** headRef)
{
 struct node* part1 = ((void *)0);
 struct node* part2 = ((void *)0);
 print_list(*headRef);
 if((*headRef)->next == ((void *)0))
  return;
 front_back_split(*headRef,&part1,&part2);
 if(part1!=((void *)0))
  merge_sort(&part1);
 print_list(part1);
 if(part2!=((void *)0))
  merge_sort(&part2);
 print_list(part2);
 *headRef = sorted_merge(part1,part2);
 print_list(*headRef);
 return;
}

canonical_original_code:
void merge_sort(struct node **headRef)
{
 struct node *part1 = ((void *)0);
 struct node *part2 = ((void *)0);
 print_list(*headRef);
 if((*headRef)->next == ((void *)0))
  return;
 front_back_split(*headRef,&part1,&part2);
 if(part1!=((void *)0))
  merge_sort(&part1);
 print_list(part1);
 if(part2!=((void *)0))
  merge_sort(&part2);
 print_list(part2);
 *headRef = sorted_merge(part1,part2);
 print_list(*headRef);
 return;
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int *v4[2]; // [rsp+8h] [rbp-10h] BYREF

v4[0] = (unsigned int *)BuildOneTwoThree(argc, argv, envp);
print_list(v4[0]);
insert_nth((__int64 *)v4, 0, 10);
insert_nth((__int64 *)v4, 1, 20);
insert_nth((__int64 *)v4, 3, 14);
insert_nth((__int64 *)v4, 4, 78);
insert_nth((__int64 *)v4, 1, 32);
insert_nth((__int64 *)v4, 3, 42);
print_list(v4[0]);
reverse((__int64 *)v4);
return print_list(v4[0]);
}

original_code:
void main()
{
 struct node* head = BuildOneTwoThree();
 print_list(head);
 insert_nth(&head,0,10);
 insert_nth(&head,1,20);
 insert_nth(&head,3,14);
 insert_nth(&head,4,78);
 insert_nth(&head,1,32);
 insert_nth(&head,3,42);
 print_list(head);
 reverse(&head);
 print_list(head);
}

canonical_original_code:
void main()
{
 struct node *head = BuildOneTwoThree();
 print_list(head);
 insert_nth(&head,0,10);
 insert_nth(&head,1,20);
 insert_nth(&head,3,14);
 insert_nth(&head,4,78);
 insert_nth(&head,1,32);
 insert_nth(&head,3,42);
 print_list(head);
 reverse(&head);
 print_list(head);
}


decompiled_code:
__int64 __fastcall print_inorder(unsigned int *a1)
{
__int64 result; // rax

if ( a1 )
{
print_inorder(*((_QWORD *)a1 + 1));
printf("%d\t", *a1);
result = print_inorder(*((_QWORD *)a1 + 2));
}
return result;
}

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

if ( a1 )
{
func2(*((_QWORD *)a1 + 1));
printf("%d\t", *a1);
result = func2(*((_QWORD *)a1 + 2));
}
return result;
}

original_code:
void print_inorder(struct node* node)
{
 if(node == ((void *)0))
  return;
 print_inorder(node->left);
 printf("%d\t",node->data);
 print_inorder(node->right);
}

canonical_original_code:
void print_inorder(struct node *node)
{
 if(node == ((void *)0))
  return;
 print_inorder(node->left);
 printf("%d\t",node->data);
 print_inorder(node->right);
}

variable_types: struct node { int data; struct node *left; struct node *right; } *


decompiled_code:
int __fastcall print_postorder(unsigned int **a1)
{
int result; // eax

if ( a1 )
{
print_inorder(a1[1]);
print_inorder(a1[2]);
result = printf("%d\t", *(unsigned int *)a1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func3(unsigned int **a1)
{
int result; // eax

if ( a1 )
{
func2(a1[1]);
func2(a1[2]);
result = printf("%d\t", *(unsigned int *)a1);
}
return result;
}

original_code:
void print_postorder(struct node* node)
{
 if(node == ((void *)0))
  return;
 print_inorder(node->left);
 print_inorder(node->right);
 printf("%d\t",node->data);
}

canonical_original_code:
void print_postorder(struct node *node)
{
 if(node == ((void *)0))
  return;
 print_inorder(node->left);
 print_inorder(node->right);
 printf("%d\t",node->data);
}

user_defined_types: struct node { int data; struct node *left; struct node *right; }


decompiled_code:
unsigned int *build123()
{
__int64 v0; // rax
__int64 v1; // rax
unsigned int *v2; // rax
unsigned int *v3; // rbx

insert(0LL, 2);
insert(v0, 1);
insert(v1, 3);
v3 = v2;
print_inorder(v2);
putchar(10);
return v3;
}

canonical_decompiled_code:
unsigned int *func4()
{
__int64 v0; // rax
__int64 v1; // rax
unsigned int *v2; // rax
unsigned int *v3; // rbx

func1(0LL, 2);
func1(v0, 1);
func1(v1, 3);
v3 = v2;
func2(v2);
putchar(10);
return v3;
}

original_code:
struct node* build123()
{
 struct node* root = ((void *)0);
 root = insert(root, 2);
 root = insert(root, 1);
 root = insert(root, 3);
 print_inorder(root);
 printf("\n");
 return root;
}

canonical_original_code:
struct node *build123()
{
 struct node *root = ((void *)0);
 root = insert(root, 2);
 root = insert(root, 1);
 root = insert(root, 3);
 print_inorder(root);
 printf("\n");
 return root;
}

return_type: struct node { int data; struct node *left; struct node *right; } *


size

decompiled_code:
__int64 __fastcall size(__int64 a1)
{
__int64 result; // rax
int v2; // ebp

result = 0LL;
if ( a1 )
{
v2 = size(*(_QWORD *)(a1 + 8));
result = v2 + (unsigned int)size(*(_QWORD *)(a1 + 16)) + 1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 result; // rax
int v2; // ebp

result = 0LL;
if ( a1 )
{
v2 = func5(*(_QWORD *)(a1 + 8));
result = v2 + (unsigned int)func5(*(_QWORD *)(a1 + 16)) + 1;
}
return result;
}

original_code:
int size(struct node* node)
{
 if(node == ((void *)0))
  return 0;
 int n = 1 + size(node->left) + size(node->right);
 return n;
}

canonical_original_code:
int size(struct node *node)
{
 if(node == ((void *)0))
  return 0;
 int n = 1 + size(node->left) + size(node->right);
 return n;
}

variable_types: n int


decompiled_code:
__int64 __fastcall max_depth(__int64 a1)
{
__int64 result; // rax
int v2; // ebp
int v3; // edx

result = 0LL;
if ( a1 )
{
v2 = max_depth(*(_QWORD *)(a1 + 8));
v3 = max_depth(*(_QWORD *)(a1 + 16));
result = (unsigned int)(v2 + 1);
if ( v2 <= v3 )
result = (unsigned int)(v3 + 1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
__int64 result; // rax
int v2; // ebp
int v3; // edx

result = 0LL;
if ( a1 )
{
v2 = func7(*(_QWORD *)(a1 + 8));
v3 = func7(*(_QWORD *)(a1 + 16));
result = (unsigned int)(v2 + 1);
if ( v2 <= v3 )
result = (unsigned int)(v3 + 1);
}
return result;
}

original_code:
int max_depth(struct node* node)
{
 if(node == ((void *)0))
  return 0;
 int left_depth = 1+max_depth(node->left);
 int right_depth = 1+max_depth(node->right);
 if(right_depth >= left_depth)
  return right_depth;
 else
  return left_depth;
}

canonical_original_code:
int max_depth(struct node *node)
{
 if(node == ((void *)0))
  return 0;
 int left_depth = 1+max_depth(node->left);
 int right_depth = 1+max_depth(node->right);
 if(right_depth >= left_depth)
  return right_depth;
 else
  return left_depth;
}


decompiled_code:
__int64 __fastcall min_value(signed int *a1)
{
signed int v1; // ebp
signed int v2; // eax
signed int v3; // eax

v1 = *a1;
if ( *((_QWORD *)a1 + 1) )
{
v2 = min_value();
if ( v1 > v2 )
v1 = v2;
}
if ( *((_QWORD *)a1 + 2) )
{
v3 = min_value();
if ( v1 > v3 )
v1 = v3;
}
return (unsigned int)v1;
}

canonical_decompiled_code:
__int64 __fastcall func8(signed int *a1)
{
signed int v1; // ebp
signed int v2; // eax
signed int v3; // eax

v1 = *a1;
if ( *((_QWORD *)a1 + 1) )
{
v2 = func8();
if ( v1 > v2 )
v1 = v2;
}
if ( *((_QWORD *)a1 + 2) )
{
v3 = func8();
if ( v1 > v3 )
v1 = v3;
}
return (unsigned int)v1;
}

original_code:
int min_value(struct node* node)
{
 int min_val;
 int left_value, right_value;
 min_val = node->data;
 if(node->left != ((void *)0))
 {
  left_value = min_value(node->left);
  if(min_val > left_value)
   min_val = left_value;
 }
 if(node->right!=((void *)0))
 {
  right_value = min_value(node->right);
  if(min_val > right_value)
   min_val = right_value;
 }
 return min_val;
}

canonical_original_code:
int min_value(struct node *node)
{
 int min_val;
 int left_value; int right_value;
 min_val = node->data;
 if(node->left != ((void *)0))
 {
  left_value = min_value(node->left);
  if(min_val > left_value)
   min_val = left_value;
 }
 if(node->right!=((void *)0))
 {
  right_value = min_value(node->right);
  if(min_val > right_value)
   min_val = right_value;
 }
 return min_val;
}


decompiled_code:
__int64 __fastcall max_value(signed int *a1)
{
signed int v1; // ebp
signed int v2; // eax
signed int v3; // eax

v1 = *a1;
if ( *((_QWORD *)a1 + 1) )
{
v2 = max_value();
if ( v1 < v2 )
v1 = v2;
}
if ( *((_QWORD *)a1 + 2) )
{
v3 = max_value();
if ( v1 < v3 )
v1 = v3;
}
return (unsigned int)v1;
}

canonical_decompiled_code:
__int64 __fastcall func9(signed int *a1)
{
signed int v1; // ebp
signed int v2; // eax
signed int v3; // eax

v1 = *a1;
if ( *((_QWORD *)a1 + 1) )
{
v2 = func9();
if ( v1 < v2 )
v1 = v2;
}
if ( *((_QWORD *)a1 + 2) )
{
v3 = func9();
if ( v1 < v3 )
v1 = v3;
}
return (unsigned int)v1;
}

original_code:
int max_value(struct node* node)
{
 int max_val;
 int left_value, right_value;
 max_val = node->data;
 if(node->left != ((void *)0))
 {
  left_value = max_value(node->left);
  if(max_val < left_value)
   max_val = left_value;
 }
 if(node->right!=((void *)0))
 {
  right_value = max_value(node->right);
  if(max_val < right_value)
   max_val = right_value;
 }
 return max_val;
}

canonical_original_code:
int max_value(struct node *node)
{
 int max_val;
 int left_value; int right_value;
 max_val = node->data;
 if(node->left != ((void *)0))
 {
  left_value = max_value(node->left);
  if(max_val < left_value)
   max_val = left_value;
 }
 if(node->right!=((void *)0))
 {
  right_value = max_value(node->right);
  if(max_val < right_value)
   max_val = right_value;
 }
 return max_val;
}


decompiled_code:
__int64 __fastcall has_path_sum(int *a1, int a2)
{
int v3; // eax
unsigned int v4; // ebx
__int64 v5; // rdi
__int64 result; // rax
__int64 v7; // rdi

v3 = *a1;
if ( *a1 == a2 )
{
result = 0LL;
if ( !*((_QWORD *)a1 + 2) )
result = *((_QWORD *)a1 + 1) == 0LL;
}
else
{
v4 = a2 - v3;
if ( a2 - v3 <= 0 )
{
result = 0LL;
}
else
{
v5 = *((_QWORD *)a1 + 1);
result = 0LL;
if ( v5 )
result = has_path_sum(v5, v4);
v7 = *((_QWORD *)a1 + 2);
if ( v7 )
{
if ( !(_DWORD)result )
result = has_path_sum(v7, v4);
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(int *a1, int a2)
{
int v3; // eax
unsigned int v4; // ebx
__int64 v5; // rdi
__int64 result; // rax
__int64 v7; // rdi

v3 = *a1;
if ( *a1 == a2 )
{
result = 0LL;
if ( !*((_QWORD *)a1 + 2) )
result = *((_QWORD *)a1 + 1) == 0LL;
}
else
{
v4 = a2 - v3;
if ( a2 - v3 <= 0 )
{
result = 0LL;
}
else
{
v5 = *((_QWORD *)a1 + 1);
result = 0LL;
if ( v5 )
result = func10(v5, v4);
v7 = *((_QWORD *)a1 + 2);
if ( v7 )
{
if ( !(_DWORD)result )
result = func10(v7, v4);
}
}
}
return result;
}

original_code:
int has_path_sum(struct node* node, int sum)
{
 int chksum = sum;
 int retval = 0;
 if(node->data == sum && node->right == ((void *)0) && node->left == ((void *)0))
  return 1;
 chksum = sum - node->data;
 if(chksum > 0 && node->left!=((void *)0) && !retval)
  retval = has_path_sum(node->left, chksum);
 if(chksum > 0 && node->right!=((void *)0) && !retval)
  retval = has_path_sum(node->right, chksum);
 return retval;
}

canonical_original_code:
int has_path_sum(struct node *node, int sum)
{
 int chksum = sum;
 int retval = 0;
 if(node->data == sum && node->right == ((void *)0) && node->left == ((void *)0))
  return 1;
 chksum = sum - node->data;
 if(chksum > 0 && node->left!=((void *)0) && !retval)
  retval = has_path_sum(node->left, chksum);
 if(chksum > 0 && node->right!=((void *)0) && !retval)
  retval = has_path_sum(node->right, chksum);
 return retval;
}

variable_types: sum int

variable_types: chksum int


mirror

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

if ( a1 )
{
mirror(*(_QWORD *)(a1 + 8));
mirror(*(_QWORD *)(a1 + 16));
result = *(_QWORD *)(a1 + 8);
*(_QWORD *)(a1 + 8) = *(_QWORD *)(a1 + 16);
*(_QWORD *)(a1 + 16) = result;
}
return result;
}

original_code:
void mirror(struct node* node)
{
 if(node == ((void *)0))
  return;
 struct node* right_node = ((void *)0);
 struct node* left_node = ((void *)0);
 mirror(node->left);
 mirror(node->right);
 struct node* temp = node->left;
 node->left = node->right;
 node->right = temp;
 return;
}

canonical_original_code:
void mirror(struct node *node)
{
 if(node == ((void *)0))
  return;
 struct node *right_node = ((void *)0);
 struct node *left_node = ((void *)0);
 mirror(node->left);
 mirror(node->right);
 struct node *temp = node->left;
 node->left = node->right;
 node->right = temp;
 return;
}


decompiled_code:
int __fastcall print_paths_recur(__int64 a1, __int64 a2, int a3)
{
int result; // eax
unsigned int v6; // ebx
__int64 v7; // rdi
__int64 v8; // rdi
__int64 v9; // r12

if ( *(_QWORD *)(a1 + 8) || *(_QWORD *)(a1 + 16) )
{
result = a3;
*(_DWORD *)(a2 + 4LL * a3) = *(_DWORD *)a1;
v6 = a3 + 1;
v7 = *(_QWORD *)(a1 + 8);
if ( v7 )
result = print_paths_recur(v7, a2, v6);
v8 = *(_QWORD *)(a1 + 16);
if ( v8 )
result = print_paths_recur(v8, a2, v6);
}
else
{
*(_DWORD *)(a2 + 4LL * a3) = *(_DWORD *)a1;
if ( a3 >= 0 )
{
v9 = 0LL;
do
printf("%d\t", *(unsigned int *)(a2 + 4 * v9++));
while ( a3 >= (int)v9 );
}
result = putchar(10);
}
return result;
}

canonical_decompiled_code:
int __fastcall func12(__int64 a1, __int64 a2, int a3)
{
int result; // eax
unsigned int v6; // ebx
__int64 v7; // rdi
__int64 v8; // rdi
__int64 v9; // r12

if ( *(_QWORD *)(a1 + 8) || *(_QWORD *)(a1 + 16) )
{
result = a3;
*(_DWORD *)(a2 + 4LL * a3) = *(_DWORD *)a1;
v6 = a3 + 1;
v7 = *(_QWORD *)(a1 + 8);
if ( v7 )
result = func12(v7, a2, v6);
v8 = *(_QWORD *)(a1 + 16);
if ( v8 )
result = func12(v8, a2, v6);
}
else
{
*(_DWORD *)(a2 + 4LL * a3) = *(_DWORD *)a1;
if ( a3 >= 0 )
{
v9 = 0LL;
do
printf("%d\t", *(unsigned int *)(a2 + 4 * v9++));
while ( a3 >= (int)v9 );
}
result = putchar(10);
}
return result;
}

original_code:
void print_paths_recur(struct node* node, int a[], int position)
{
 int i = 0;
 if(node->left == ((void *)0) && node->right == ((void *)0))
 {
  a[position] = node->data;
  for(i=0; i<=position; i++)
   printf("%d\t",a[i]);
  printf("\n");
  return;
 }
 a[position] = node->data;
 position++;
 if(node->left!=((void *)0))
  print_paths_recur(node->left, a, position);
 if(node->right!=((void *)0))
  print_paths_recur(node->right,a, position);
}

canonical_original_code:
void print_paths_recur(struct node *node, int a[], int position)
{
 int i = 0;
 if(node->left == ((void *)0) && node->right == ((void *)0))
 {
  a[position] = node->data;
  for(i=0; i<=position; i++)
   printf("%d\t",a[i]);
  printf("\n");
  return;
 }
 a[position] = node->data;
 position++;
 if(node->left!=((void *)0))
  print_paths_recur(node->left, a, position);
 if(node->right!=((void *)0))
  print_paths_recur(node->right,a, position);
}

variable_types:
a
int []

variable_types: i int


decompiled_code:
int __fastcall print_paths(__int64 a1)
{
void *v1; // rsp
__int64 v3; // [rsp+0h] [rbp-10h] BYREF

v1 = alloca(4LL * (int)max_depth(a1));
return print_paths_recur(a1, (__int64)&v3, 0);
}

canonical_decompiled_code:
int __fastcall func13(__int64 a1)
{
void *v1; // rsp
__int64 v3; // [rsp+0h] [rbp-10h] BYREF

v1 = alloca(4LL * (int)max_depth(a1));
return func12(a1, (__int64)&v3, 0);
}

original_code:
void print_paths(struct node* node)
{
 int size = max_depth(node);
 int a[size];
 int position = 0;
 print_paths_recur(node, a, position);
}

canonical_original_code:
void print_paths(struct node *node)
{
 int size = max_depth(node);
 int a[-1];
 int position = 0;
 print_paths_recur(node, a, position);
}

variable_types: size int

variable_types:
a
int [-1]


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

if ( a1 )
{
double_tree(*(_QWORD *)(a1 + 8));
double_tree(*(_QWORD *)(a1 + 16));
new_node();
*(_QWORD *)(v1 + 8) = *(_QWORD *)(a1 + 8);
*(_QWORD *)(a1 + 8) = v1;
}
}

original_code:
void double_tree(struct node* node)
{
 if(node==((void *)0))
  return;
 double_tree(node->left);
 double_tree(node->right);
 struct node* new_node1 = new_node(node->data);
 new_node1->left = node->left;
 node->left = new_node1;
}

canonical_original_code:
void double_tree(struct node *node)
{
 if(node==((void *)0))
  return;
 double_tree(node->left);
 double_tree(node->right);
 struct node *new_node1 = new_node(node->data);
 new_node1->left = node->left;
 node->left = new_node1;
}


original_code:
int same_tree(struct node* a, struct node* b)
{
 int right_value = 0, left_value = 0;
 if((a == ((void *)0) && b!=((void *)0)) || (a!=((void *)0) && b == ((void *)0)))
  return 0;
 if(a->left!=((void *)0) && b->left!=((void *)0))
  left_value = same_tree(a->left, b->left);
 else if(a->left==((void *)0) && b->left==((void *)0))
  left_value = 1;
 if(a->right!=((void *)0) && b->right!=((void *)0))
  right_value = same_tree(a->right, b->right);
 else if(a->right==((void *)0) && b->right==((void *)0))
  right_value = 1;
 if(a->data == b->data)
  return (1 && left_value && right_value);
 else
  return 0;
}

canonical_original_code:
int same_tree(struct node *a, struct node *b)
{
 int right_value = 0; int left_value = 0;
 if((a == ((void *)0) && b!=((void *)0)) || (a!=((void *)0) && b == ((void *)0)))
  return 0;
 if(a->left!=((void *)0) && b->left!=((void *)0))
  left_value = same_tree(a->left, b->left);
 else if(a->left==((void *)0) && b->left==((void *)0))
  left_value = 1;
 if(a->right!=((void *)0) && b->right!=((void *)0))
  right_value = same_tree(a->right, b->right);
 else if(a->right==((void *)0) && b->right==((void *)0))
  right_value = 1;
 if(a->data == b->data)
  return (1 && left_value && right_value);
 else
  return 0;
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int *v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
unsigned int *v8; // rax
__int64 v9; // rbx
unsigned int *v10; // rax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax
unsigned int *v15; // rax
__int64 v16; // rbp
unsigned int v17; // eax

v3 = build123();
insert((__int64)v3, 5);
insert(v4, 9);
insert(v5, 4);
insert(v6, 6);
insert(v7, 10);
v9 = (__int64)v8;
print_inorder(v8);
putchar(10);
v10 = build123();
insert((__int64)v10, 5);
insert(v11, 10);
insert(v12, 9);
insert(v13, 4);
insert(v14, 6);
v16 = (__int64)v15;
print_inorder(v15);
putchar(10);
v17 = same_tree(v9, v16);
return printf("Same:%d\n", v17);
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int *v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
unsigned int *v8; // rax
__int64 v9; // rbx
unsigned int *v10; // rax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax
unsigned int *v15; // rax
__int64 v16; // rbp
unsigned int v17; // eax

v3 = func4();
func1((__int64)v3, 5);
func1(v4, 9);
func1(v5, 4);
func1(v6, 6);
func1(v7, 10);
v9 = (__int64)v8;
func2(v8);
putchar(10);
v10 = func4();
func1((__int64)v10, 5);
func1(v11, 10);
func1(v12, 9);
func1(v13, 4);
func1(v14, 6);
v16 = (__int64)v15;
func2(v15);
putchar(10);
v17 = func15(v9, v16);
return printf("Same:%d\n", v17);
}

original_code:
void main()
{
 int n = 0;
 struct node* root = build123();
 root = insert(root, 5);
 root = insert(root, 9);
 root = insert(root, 4);
 root = insert(root , 6);
 root = insert(root , 10);
 print_inorder(root);
 printf("\n");
 struct node* root1 = build123();
 root1 = insert(root1, 5);
 root1 = insert(root1 , 10);
 root1 = insert(root1, 9);
 root1 = insert(root1, 4);
 root1 = insert(root1 , 6);
 print_inorder(root1);
 printf("\n");
 n=same_tree(root, root1);
 printf("Same:%d\n", n);
 return;
}

canonical_original_code:
void main()
{
 int n = 0;
 struct node *root = build123();
 root = insert(root, 5);
 root = insert(root, 9);
 root = insert(root, 4);
 root = insert(root , 6);
 root = insert(root , 10);
 print_inorder(root);
 printf("\n");
 struct node *root1 = build123();
 root1 = insert(root1, 5);
 root1 = insert(root1 , 10);
 root1 = insert(root1, 9);
 root1 = insert(root1, 4);
 root1 = insert(root1 , 6);
 print_inorder(root1);
 printf("\n");
 n=same_tree(root, root1);
 printf("Same:%d\n", n);
 return;
}


decompiled_code:
int __fastcall print_array(unsigned int *a1, int a2)
{
unsigned int *v2; // rbx

if ( a2 > 0 )
{
v2 = a1;
do
printf("%d ", *v2++);
while ( v2 != &a1[a2 - 1 + 1] );
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func7(unsigned int *a1, int a2)
{
unsigned int *v2; // rbx

if ( a2 > 0 )
{
v2 = a1;
do
printf("%d ", *v2++);
while ( v2 != &a1[a2 - 1 + 1] );
}
return putchar(10);
}

original_code:
void print_array(int a[], int length)
{
 int i = 0;
 for(i = 0; i<length; i++)
  printf("%d ",a[i]);
 printf("\n");
}

variable_types: length int


decompiled_code:
void __fastcall generate_array(int *a1, int a2)
{
unsigned int v2; // eax
int *v3; // rbx

v2 = time(0LL);
srand(v2);
if ( a2 > 0 )
{
v3 = a1;
do
*v3++ = rand() % 100;
while ( v3 != &a1[a2 - 1 + 1] );
}
}

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

v2 = time(0LL);
srand(v2);
if ( a2 > 0 )
{
v3 = a1;
do
*v3++ = rand() % 100;
while ( v3 != &a1[a2 - 1 + 1] );
}
}

original_code:
void generate_array(int a[], int length)
{
 int i = 0;
 srand ( time(((void *)0)) );
 for(i=0;i<length; i++)
  a[i] = rand()%100;
}


original_code:
void selection_sort(int a[], int length)
{
 int i, j, temp;
 int min;
 for(i=0; i<length; i++)
 {
  min = i;
  for(j=i; j<length; j++)
  {
   if(a[j]<a[min])
    min = j;
  }
  temp = a[i];
  a[i] = a[min];
  a[min] = temp;
 }
}

canonical_original_code:
void selection_sort(int a[], int length)
{
 int i; int j; int temp;
 int min;
 for(i=0; i<length; i++)
 {
  min = i;
  for(j=i; j<length; j++)
  {
   if(a[j]<a[min])
    min = j;
  }
  temp = a[i];
  a[i] = a[min];
  a[min] = temp;
 }
}

variable_types: j int

variable_types: temp int

variable_types: min int


original_code:
void bubble_sort(int a[], int length)
{
 int i, j, temp;
 for(i=0; i<length; i++)
 {
  for(j=0; j<length - i - 1; j++)
  {
   if(a[j] > a[j+1])
   {
    temp = a[j];
    a[j] = a[j+1];
    a[j+1] = temp;
   }
  }
 }
}

canonical_original_code:
void bubble_sort(int a[], int length)
{
 int i; int j; int temp;
 for(i=0; i<length; i++)
 {
  for(j=0; j<length - i - 1; j++)
  {
   if(a[j] > a[j+1])
   {
    temp = a[j];
    a[j] = a[j+1];
    a[j+1] = temp;
   }
  }
 }
}


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v4[7]; // [rsp+0h] [rbp-38h] BYREF

v4[0] = 0LL;
v4[1] = 0LL;
v4[2] = 0LL;
v4[3] = 0LL;
v4[4] = 0LL;
generate_array((int *)v4, 10);
print_array((unsigned int *)v4, 10);
puts("sorting...");
selection_sort((__int64)v4, 10);
return print_array((unsigned int *)v4, 10);
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v4[7]; // [rsp+0h] [rbp-38h] BYREF

v4[0] = 0LL;
v4[1] = 0LL;
v4[2] = 0LL;
v4[3] = 0LL;
v4[4] = 0LL;
func8((int *)v4, 10);
func7((unsigned int *)v4, 10);
puts("sorting...");
func9((__int64)v4, 10);
return func7((unsigned int *)v4, 10);
}

original_code:
void main()
{
 int a[10] = {0};
 generate_array(a, 10);
 print_array(a,10);
 printf("sorting...\n");
 selection_sort(a, 10);
 print_array(a,10);
 return;
}

variable_types:
a
int [10]