decompiled_code:
__int64 __fastcall play_game(char *s, const char *a2, const char *a3)
{
size_t v3; // rbx
void *v4; // rsp
unsigned int v5; // ebx
int v6; // eax
unsigned int v7; // edx
int v8; // er14
int v9; // eax
size_t v10; // rax
unsigned __int64 v11; // r9
int v12; // edx
unsigned __int64 v13; // rsi
int v14; // er15
size_t v15; // rax
int v16; // eax
char v18[8]; // [rsp+0h] [rbp-50h] BYREF
const char *v19; // [rsp+8h] [rbp-48h]
const char *v20; // [rsp+10h] [rbp-40h]
unsigned __int64 v21; // [rsp+18h] [rbp-38h]

v3 = 0LL;
v20 = a2;
v19 = a3;
v4 = alloca(strlen(s));
while ( strlen(s) > v3 )
{
v18[v3] = 95;
printf("%c ", 95LL);
++v3;
}
v5 = 7;
putchar(10);
while ( 1 )
{
printf("\nCategory: %s ", v20);
v6 = getch_like();
v7 = v6 - 97;
v8 = v6;
v9 = v6 - 32;
if ( v7 < 0x1A )
v8 = v9;
v10 = strlen(s);
v11 = 0LL;
v12 = 0;
v13 = v10;
while ( 1 )
{
v14 = v11;
if ( v13 <= v11 )
break;
if ( v8 == s[v11] )
{
v21 = v11;
update(v8, v13, v11, v18, v5);
v15 = strlen(s);
v11 = v21;
v12 = 1;
v13 = v15;
}
++v11;
}
if ( !v12 )
{
update(v8, v13, v11, v18, --v5);
if ( !v5 )
break;
}
if ( (unsigned int)check(v18) )
{
v16 = strlen(s);
update(v8, v16, v14, v18, 0xFFFFFFFF);
print_trivia(v19);
return (unsigned int)++game;
}
}
print_trivia(v19);
puts("\nGAME OVER");
return (unsigned int)++game;
}

canonical_decompiled_code:
__int64 __fastcall func7(char *s, const char *a2, const char *a3)
{
size_t v3; // rbx
void *v4; // rsp
unsigned int v5; // ebx
int v6; // eax
unsigned int v7; // edx
int v8; // er14
int v9; // eax
size_t v10; // rax
unsigned __int64 v11; // r9
int v12; // edx
unsigned __int64 v13; // rsi
int v14; // er15
size_t v15; // rax
int v16; // eax
char v18[8]; // [rsp+0h] [rbp-50h] BYREF
const char *v19; // [rsp+8h] [rbp-48h]
const char *v20; // [rsp+10h] [rbp-40h]
unsigned __int64 v21; // [rsp+18h] [rbp-38h]

v3 = 0LL;
v20 = a2;
v19 = a3;
v4 = alloca(strlen(s));
while ( strlen(s) > v3 )
{
v18[v3] = 95;
printf("%c ", 95LL);
++v3;
}
v5 = 7;
putchar(10);
while ( 1 )
{
printf("\nCategory: %s ", v20);
v6 = getch_like();
v7 = v6 - 97;
v8 = v6;
v9 = v6 - 32;
if ( v7 < 0x1A )
v8 = v9;
v10 = strlen(s);
v11 = 0LL;
v12 = 0;
v13 = v10;
while ( 1 )
{
v14 = v11;
if ( v13 <= v11 )
break;
if ( v8 == s[v11] )
{
v21 = v11;
func5(v8, v13, v11, v18, v5);
v15 = strlen(s);
v11 = v21;
v12 = 1;
v13 = v15;
}
++v11;
}
if ( !v12 )
{
func5(v8, v13, v11, v18, --v5);
if ( !v5 )
break;
}
if ( (unsigned int)func1(v18) )
{
v16 = strlen(s);
func5(v8, v16, v14, v18, 0xFFFFFFFF);
func6(v19);
return (unsigned int)++game;
}
}
func6(v19);
puts("\nGAME OVER");
return (unsigned int)++game;
}

original_code:
int play_game(char *s, char *t, char *r)
{
 int guess;
 boolean correct = 0;
 char new_word[strlen(s)];
 int i, remaining_lives = 7;
 for (i = 0; i < strlen(s); i++) {
  new_word[i] = '_';
  printf("%c ", new_word[i]);
 }
 printf("\n");
 for (;;) {
  printf("\nCategory: %s ", t);
  guess = getch_like();
  if (guess >= 97 && guess <= 122)
   guess -= 32;
  for (i = 0; i < strlen(s); i++)
   if (guess == s[i]) {
    update(guess, strlen(s), i, new_word, remaining_lives);
    correct = 1;
   }
  if (!correct)
   update(guess, strlen(s), i, new_word, --remaining_lives);
  correct = 0;
  if (remaining_lives == 0) {
   print_trivia(r);
   printf("\nGAME OVER\n");
   return ++game;
  } else if (check(new_word)) {
   update(guess, strlen(s), i, new_word, -1);
   print_trivia(r);
   return ++game;
  }
 }
}

canonical_original_code:
int play_game(char *s, char *t, char *r)
{
 int guess;
 int correct = 0;
 char new_word[-1];
 int i; int remaining_lives = 7;
 for (i = 0; i < strlen(s); i++) {
  new_word[i] = '_';
  printf("%c ", new_word[i]);
 }
 printf("\n");
 for (;;) {
  printf("\nCategory: %s ", t);
  guess = getch_like();
  if (guess >= 97 && guess <= 122)
   guess -= 32;
  for (i = 0; i < strlen(s); i++)
   if (guess == s[i]) {
    update(guess, strlen(s), i, new_word, remaining_lives);
    correct = 1;
   }
  if (!correct)
   update(guess, strlen(s), i, new_word, --remaining_lives);
  correct = 0;
  if (remaining_lives == 0) {
   print_trivia(r);
   printf("\nGAME OVER\n");
   return ++game;
  } else if (check(new_word)) {
   update(guess, strlen(s), i, new_word, -1);
   print_trivia(r);
   return ++game;
  }
 }
}

variable_types:
t
char *

variable_types:
r
char *

variable_types: guess int

variable_types: correct int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
char v4; // bl
char v6[32]; // [rsp+0h] [rbp-148h] BYREF
char v7[32]; // [rsp+20h] [rbp-128h] BYREF
char v8[264]; // [rsp+40h] [rbp-108h] BYREF

do
{
game_init();
get_word(v6, v7, v8);
v3 = play_game(v6, v7, v8);
printf("\nGames played: %d\n", v3);
printf("Play again? (y/n): ");
v4 = getchar();
getchar();
}
while ( (v4 & 0xDF) != 78 );
system("clear");
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
char v4; // bl
char v6[32]; // [rsp+0h] [rbp-148h] BYREF
char v7[32]; // [rsp+20h] [rbp-128h] BYREF
char v8[264]; // [rsp+40h] [rbp-108h] BYREF

do
{
func4();
get_word(v6, v7, v8);
v3 = func7(v6, v7, v8);
printf("\nGames played: %d\n", v3);
printf("Play again? (y/n): ");
v4 = getchar();
getchar();
}
while ( (v4 & 0xDF) != 78 );
system("clear");
return 0;
}

original_code:
int main(void)
{
 char word[25 + 1], category[25 + 1], trivia[240 + 1],
      again;
 int games_played;
 game_init();
 for (;;) {
  get_word(word, category, trivia);
  games_played = play_game(word, category, trivia);
  printf("\nGames played: %d\n", games_played);
  printf("Play again? (y/n): ");
  again = getchar();
  getchar();
  if (again == 'n' || again == 'N') {
   system("clear");
   break;
  }
  game_init();
 }
 return 0;
}

canonical_original_code:
int main()
{
 char word[-1]; char category[-1]; char trivia[-1]; char again;
 int games_played;
 game_init();
 for (;;) {
  get_word(word, category, trivia);
  games_played = play_game(word, category, trivia);
  printf("\nGames played: %d\n", games_played);
  printf("Play again? (y/n): ");
  again = getchar();
  getchar();
  if (again == 'n' || again == 'N') {
   system("clear");
   break;
  }
  game_init();
 }
 return 0;
}

variable_types:
word
char [-1]

variable_types:
category
char [-1]

variable_types:
trivia
char [-1]

variable_types: again char

return_type: int


newgap

repo: jdussouillez/libsort

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

result = 1LL;
if ( 10 * a1 > 12 )
{
result = (unsigned int)(10 * a1 / 13);
if ( (unsigned int)(result - 9) <= 1 )
result = 11LL;
}
return result;
}

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

result = 1LL;
if ( 10 * a1 > 12 )
{
result = (unsigned int)(10 * a1 / 13);
if ( (unsigned int)(result - 9) <= 1 )
result = 11LL;
}
return result;
}

original_code:
static int newgap(int gap) {
  gap = (gap * 10) / 13;
  if (gap < 1)
    return 1;
  return (gap == 9 || gap == 10) ? 11 : gap;
}

variable_types: gap int


combsort

original_code:
void combsort(void* base, size_t nmemb, size_t size, int(*compare)(const void*, const void*)) {
  if (base == ((void *)0) || compare == ((void *)0))
    return;
  int gap = nmemb, swapped, i;
  do {
    swapped = 0;
    gap = newgap(gap);
    for (i = 0; i < (nmemb - gap); i++) {
      if (compare(base + (i * size), base + ((i + gap) * size)) > 0) {
 swapped = 1;
 swap(base + (i * size), base + ((i + gap) * size), size);
      }
    }
  } while (gap > 1 || swapped);
}

canonical_original_code:
void combsort(void *base, unsigned long nmemb, unsigned long size, int (*compare)(void *, void *)) {
  if (base == ((void *)0) || compare == ((void *)0))
    return;
  int gap = nmemb; int swapped; int i;
  do {
    swapped = 0;
    gap = newgap(gap);
    for (i = 0; i < (nmemb - gap); i++) {
      if (compare(base + (i * size), base + ((i + gap) * size)) > 0) {
 swapped = 1;
 swap(base + (i * size), base + ((i + gap) * size), size);
      }
    }
  } while (gap > 1 || swapped);
}

variable_types:
base
void *

variable_types:
nmemb
unsigned long

variable_types:
size
unsigned long

variable_types:
compare
int (*)(void *, void *)

variable_types: swapped int

variable_types: i int

return_type: void


siftdown

decompiled_code:
__int64 __fastcall siftdown(__int64 a1, __int64 a2, __int64 (__fastcall *a3)(__int64, __int64), int a4, int a5)
{
__int64 v6; // rbp
__int64 result; // rax
int v8; // er14
__int64 v9; // r15
int v10; // eax
__int64 v11; // rbp

v6 = a4;
result = (unsigned int)(2 * a4);
if ( a5 > (int)result )
{
while ( 1 )
{
v8 = result + 1;
v9 = a1 + a2 * ((int)result + 1);
if ( a5 > (int)result + 1 )
{
v10 = a3(a1 + a2 * v8, a1 + a2 * (2 * (int)v6 + 2));
if ( v10 < 0 )
v9 = a1 + a2 * (2 * (int)v6 + 2);
if ( v10 < 0 )
v8 = 2 * v6 + 2;
}
v11 = a1 + a2 * v6;
result = a3(v11, v9);
if ( (int)result >= 0 )
break;
swap(v11, v9, a2);
result = (unsigned int)(2 * v8);
if ( (int)result >= a5 )
break;
v6 = v8;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 (__fastcall *a3)(__int64, __int64), int a4, int a5)
{
__int64 v6; // rbp
__int64 result; // rax
int v8; // er14
__int64 v9; // r15
int v10; // eax
__int64 v11; // rbp

v6 = a4;
result = (unsigned int)(2 * a4);
if ( a5 > (int)result )
{
while ( 1 )
{
v8 = result + 1;
v9 = a1 + a2 * ((int)result + 1);
if ( a5 > (int)result + 1 )
{
v10 = a3(a1 + a2 * v8, a1 + a2 * (2 * (int)v6 + 2));
if ( v10 < 0 )
v9 = a1 + a2 * (2 * (int)v6 + 2);
if ( v10 < 0 )
v8 = 2 * v6 + 2;
}
v11 = a1 + a2 * v6;
result = a3(v11, v9);
if ( (int)result >= 0 )
break;
swap(v11, v9, a2);
result = (unsigned int)(2 * v8);
if ( (int)result >= a5 )
break;
v6 = v8;
}
}
return result;
}

original_code:
static void siftdown(void* base, size_t size, int(*compare)(const void*, const void*), int start, int end) {
  int root = start, child;
  void *proot, *pchild;
  while (((root * 2) + 1) <= end) {
    child = (root * 2) + 1;
    if (child + 1 <= end && compare(base + (child * size), base + ((child + 1) * size)) < 0) {
      child++;
    }
    proot = base + (root * size);
    pchild = base + (child * size);
    if (compare(proot, pchild) < 0) {
      swap(proot, pchild, size);
      root = child;
    }
    else
      return;
  }
}

canonical_original_code:
static void siftdown(void *base, unsigned long size, int (*compare)(void *, void *), int start, int end) {
  int root = start; int child;
  void *proot; void *pchild;
  while (((root * 2) + 1) <= end) {
    child = (root * 2) + 1;
    if (child + 1 <= end && compare(base + (child * size), base + ((child + 1) * size)) < 0) {
      child++;
    }
    proot = base + (root * size);
    pchild = base + (child * size);
    if (compare(proot, pchild) < 0) {
      swap(proot, pchild, size);
      root = child;
    }
    else
      return;
  }
}

variable_types: start int

variable_types: end int

variable_types: root int

variable_types: child int

variable_types:
proot
void *

variable_types:
pchild
void *


heapify

decompiled_code:
__int64 __fastcall heapify(__int64 a1, __int64 a2, __int64 (__fastcall *a3)(__int64, __int64), int a4)
{
__int64 result; // rax
int v5; // ebx
int v6; // er14

result = (unsigned int)(a4 - 2);
v5 = (a4 - 2) / 2;
if ( a4 > 0 )
{
v6 = a4 - 1;
do
result = siftdown(a1, a2, a3, v5, v6);
while ( v5-- != 0 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 (__fastcall *a3)(__int64, __int64), int a4)
{
__int64 result; // rax
int v5; // ebx
int v6; // er14

result = (unsigned int)(a4 - 2);
v5 = (a4 - 2) / 2;
if ( a4 > 0 )
{
v6 = a4 - 1;
do
result = func0(a1, a2, a3, v5, v6);
while ( v5-- != 0 );
}
return result;
}

original_code:
static void heapify(void* base, size_t size, int(*compare)(const void*, const void*), int count) {
  int start = (count - 2) / 2;
  while (start >= 0) {
    siftdown(base, size, compare, start, count - 1);
    start--;
  }
}

canonical_original_code:
static void heapify(void *base, unsigned long size, int (*compare)(void *, void *), int count) {
  int start = (count - 2) / 2;
  while (start >= 0) {
    siftdown(base, size, compare, start, count - 1);
    start--;
  }
}

variable_types: count int


heapsort

decompiled_code:
__int64 __fastcall heapsort(__int64 a1, int a2, __int64 a3, __int64 (__fastcall *a4)(__int64, __int64))
{
int v6; // ebx
__int64 result; // rax
__int64 v8; // r12

if ( a1 )
{
if ( a4 )
{
v6 = a2 - 1;
result = heapify(a1, a3, a4, a2);
if ( a2 - 1 > 0 )
{
v8 = a1 + a3 * v6;
do
{
--v6;
swap(v8, a1, a3);
v8 -= a3;
result = siftdown(a1, a3, a4, 0, v6);
}
while ( v6 );
}
}
}
return result;
}

original_code:
void heapsort(void* base, size_t nmemb, size_t size, int(*compare)(const void*, const void*)) {
  if (base == ((void *)0) || compare == ((void *)0))
    return;
  int end = nmemb - 1;
  heapify(base, size, compare, nmemb);
  while (end > 0) {
    swap(base + (end * size), base, size);
    siftdown(base, size, compare, 0, --end);
  }
}

canonical_original_code:
void heapsort(void *base, unsigned long nmemb, unsigned long size, int (*compare)(void *, void *)) {
  if (base == ((void *)0) || compare == ((void *)0))
    return;
  int end = nmemb - 1;
  heapify(base, size, compare, nmemb);
  while (end > 0) {
    swap(base + (end * size), base, size);
    siftdown(base, size, compare, 0, --end);
  }
}


selectionsort

original_code:
void selectionsort(void* base, size_t nmemb, size_t size, int(*compare)(const void*, const void*)) {
  if (base == ((void *)0) || compare == ((void *)0))
    return;
  int i, j, min;
  for (i = 0; i < nmemb - 1; i++) {
    min = i;
    for (j = i + 1; j < nmemb; j++) {
      if (compare(base + (j * size), base + (min * size)) < 0)
 min = j;
    }
    if (min != i)
      swap(base + (i * size), base + (min * size), size);
  }
}

canonical_original_code:
void selectionsort(void *base, unsigned long nmemb, unsigned long size, int (*compare)(void *, void *)) {
  if (base == ((void *)0) || compare == ((void *)0))
    return;
  int i; int j; int min;
  for (i = 0; i < nmemb - 1; i++) {
    min = i;
    for (j = i + 1; j < nmemb; j++) {
      if (compare(base + (j * size), base + (min * size)) < 0)
 min = j;
    }
    if (min != i)
      swap(base + (i * size), base + (min * size), size);
  }
}

variable_types: j int

variable_types: min int


insertionsort

decompiled_code:
void __fastcall insertionsort(char *a1, unsigned __int64 a2, size_t a3, int (__fastcall *a4)(char *, void *))
{
void *v6; // r13
char *v7; // r15
int v8; // ebp
void *v9; // rbx
void *v10; // rdi
__int64 v12; // [rsp+0h] [rbp-58h]
char *src; // [rsp+8h] [rbp-50h]

if ( a1 && a4 )
{
v12 = 0LL;
v6 = malloc(a3);
src = &a1[a3];
if ( a2 > 1 )
{
do
{
v7 = src;
memcpy(v6, src, a3);
v8 = v12;
while ( 1 )
{
v9 = v7;
v7 -= a3;
v10 = v9;
if ( a4(v7, v6) <= 0 )
break;
memcpy(v9, v7, a3);
if ( v8-- == 0 )
{
v10 = a1;
break;
}
}
memcpy(v10, v6, a3);
++v12;
src += a3;
}
while ( a2 - 1 != v12 );
}
free(v6);
}
}

canonical_decompiled_code:
void __fastcall func0(char *a1, unsigned __int64 a2, size_t a3, int (__fastcall *a4)(char *, void *))
{
void *v6; // r13
char *v7; // r15
int v8; // ebp
void *v9; // rbx
void *v10; // rdi
__int64 v12; // [rsp+0h] [rbp-58h]
char *src; // [rsp+8h] [rbp-50h]

if ( a1 && a4 )
{
v12 = 0LL;
v6 = malloc(a3);
src = &a1[a3];
if ( a2 > 1 )
{
do
{
v7 = src;
memcpy(v6, src, a3);
v8 = v12;
while ( 1 )
{
v9 = v7;
v7 -= a3;
v10 = v9;
if ( a4(v7, v6) <= 0 )
break;
memcpy(v9, v7, a3);
if ( v8-- == 0 )
{
v10 = a1;
break;
}
}
memcpy(v10, v6, a3);
++v12;
src += a3;
}
while ( a2 - 1 != v12 );
}
free(v6);
}
}

original_code:
void insertionsort(void* base, size_t nmemb, size_t size, int(*compare)(const void*, const void*)) {
  if (base == ((void *)0) || compare == ((void *)0))
    return;
  int i, j;
  void* value = malloc(size);
  for (i = 1; i < nmemb; i++) {
    memcpy(value, base + (i * size), size);
    for (j = i - 1; j >= 0 && compare(base + (j * size), value) > 0; j--) {
      memcpy(base + ((j + 1) * size), base + (j * size), size);
    }
    memcpy(base + ((j + 1) * size), value, size);
  }
  free(value);
}

canonical_original_code:
void insertionsort(void *base, unsigned long nmemb, unsigned long size, int (*compare)(void *, void *)) {
  if (base == ((void *)0) || compare == ((void *)0))
    return;
  int i; int j;
  void *value = malloc(size);
  for (i = 1; i < nmemb; i++) {
    memcpy(value, base + (i * size), size);
    for (j = i - 1; j >= 0 && compare(base + (j * size), value) > 0; j--) {
      memcpy(base + ((j + 1) * size), base + (j * size), size);
    }
    memcpy(base + ((j + 1) * size), value, size);
  }
  free(value);
}

variable_types:
value
void *


shellsort

original_code:
void shellsort(void* base, size_t nmemb, size_t size, int(*compare)(const void*, const void*)) {
  if (base == ((void *)0) || compare == ((void *)0))
    return;
  int i, j, gap;
  void* tmp = malloc(size);
  for (gap = nmemb / 2; gap > 0; gap /= 2) {
    for (i = gap; i < nmemb; i++) {
      memcpy(tmp, base + (i * size), size);
      j = i;
      while (j >= gap && compare(tmp, base + ((j - gap) * size)) < 0) {
        memmove(base + (j * size), base + ((j - gap) * size), size);
 j -= gap;
      }
      memmove(base + (j * size), tmp, size);
    }
  }
  free(tmp);
}

canonical_original_code:
void shellsort(void *base, unsigned long nmemb, unsigned long size, int (*compare)(void *, void *)) {
  if (base == ((void *)0) || compare == ((void *)0))
    return;
  int i; int j; int gap;
  void *tmp = malloc(size);
  for (gap = nmemb / 2; gap > 0; gap /= 2) {
    for (i = gap; i < nmemb; i++) {
      memcpy(tmp, base + (i * size), size);
      j = i;
      while (j >= gap && compare(tmp, base + ((j - gap) * size)) < 0) {
        memmove(base + (j * size), base + ((j - gap) * size), size);
 j -= gap;
      }
      memmove(base + (j * size), tmp, size);
    }
  }
  free(tmp);
}

variable_types: gap int

variable_types:
tmp
void *


partition

original_code:
static int partition(void* base, int begin, int end, size_t size, int pivot, int(*compare)(const void*, const void*)) {
  int i, index = begin;
  void* pivot_value = malloc(size);
  memcpy(pivot_value, base + (pivot * size), size);
  swap(base + (pivot * size), base + (end * size), size);
  for (i = begin; i < end; i++) {
    if (compare(base + (i * size), pivot_value) < 0) {
      swap(base + (i * size), base + (index * size), size);
      index++;
    }
  }
  swap(base + (index * size), base + (end * size), size);
  free(pivot_value);
  return index;
}

canonical_original_code:
static int partition(void *base, int begin, int end, unsigned long size, int pivot, int (*compare)(void *, void *)) {
  int i; int index = begin;
  void *pivot_value = malloc(size);
  memcpy(pivot_value, base + (pivot * size), size);
  swap(base + (pivot * size), base + (end * size), size);
  for (i = begin; i < end; i++) {
    if (compare(base + (i * size), pivot_value) < 0) {
      swap(base + (i * size), base + (index * size), size);
      index++;
    }
  }
  swap(base + (index * size), base + (end * size), size);
  free(pivot_value);
  return index;
}

variable_types:
base
void *

variable_types: begin int

variable_types: pivot int

variable_types: index int


decompiled_code:
void __fastcall quicksort_rec(__int64 a1, int a2, int a3, size_t a4, int (__fastcall *a5)(size_t, void *))
{
unsigned int v8; // ebp
int v9; // ebx

if ( a3 > a2 )
{
v8 = a2;
do
{
v9 = partition(a1, v8, a3, a4, (int)(a3 + v8) / 2, a5);
quicksort_rec(a1, v8, (unsigned int)(v9 - 1), a4, a5);
v8 = v9 + 1;
}
while ( v9 + 1 < a3 );
}
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1, int a2, int a3, size_t a4, int (__fastcall *a5)(size_t, void *))
{
unsigned int v8; // ebp
int v9; // ebx

if ( a3 > a2 )
{
v8 = a2;
do
{
v9 = func0(a1, v8, a3, a4, (int)(a3 + v8) / 2, a5);
func1(a1, v8, (unsigned int)(v9 - 1), a4, a5);
v8 = v9 + 1;
}
while ( v9 + 1 < a3 );
}
}

original_code:
static void quicksort_rec(void* base, int begin, int end, size_t size, int(*compare)(const void*, const void*)) {
  int pivot, pivotIndex;
  if (begin < end) {
    pivotIndex = (begin + end) / 2;
    pivot = partition(base, begin, end, size, pivotIndex, compare);
    quicksort_rec(base, begin, pivot - 1, size, compare);
    quicksort_rec(base, pivot + 1, end, size, compare);
  }
}

canonical_original_code:
static void quicksort_rec(void *base, int begin, int end, unsigned long size, int (*compare)(void *, void *)) {
  int pivot; int pivotIndex;
  if (begin < end) {
    pivotIndex = (begin + end) / 2;
    pivot = partition(base, begin, end, size, pivotIndex, compare);
    quicksort_rec(base, begin, pivot - 1, size, compare);
    quicksort_rec(base, pivot + 1, end, size, compare);
  }
}

variable_types:
size
unsigned long

variable_types:
compare
int (*)(void *, void *)

variable_types: pivotIndex int


quicksort

decompiled_code:
void __fastcall quicksort(__int64 a1, int a2, size_t a3, int (__fastcall *a4)(size_t, void *))
{
if ( a1 )
{
if ( a4 )
quicksort_rec(a1, 0, a2 - 1, a3, a4);
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, int a2, size_t a3, int (__fastcall *a4)(size_t, void *))
{
if ( a1 )
{
if ( a4 )
func1(a1, 0, a2 - 1, a3, a4);
}
}

original_code:
void quicksort(void* base, size_t nmemb, size_t size, int(*compare)(const void*, const void*)) {
  if (base == ((void *)0) || compare == ((void *)0))
    return;
  quicksort_rec(base, 0, nmemb - 1, size, compare);
}

canonical_original_code:
void quicksort(void *base, unsigned long nmemb, unsigned long size, int (*compare)(void *, void *)) {
  if (base == ((void *)0) || compare == ((void *)0))
    return;
  quicksort_rec(base, 0, nmemb - 1, size, compare);
}

variable_types:
nmemb
unsigned long


main

repo: je-so/testcode

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // r12
__int64 v6; // r13
__int64 v7; // rax
__int64 v8; // r14
__int64 v9; // r15
__int64 v10; // rax
FILE *v11; // rax
int v12; // eax
FILE *v13; // r11
__int64 v14; // rax
int v15; // eax
void *v16; // rax
size_t v17; // rax
FILE *v18; // r9
__int64 v19; // rax
FILE *v20; // r9
FILE *v21; // rcx
FILE *v22; // r11
int v23; // er10
FILE *v25; // [rsp+8h] [rbp-60h]
FILE *v26; // [rsp+8h] [rbp-60h]
FILE *stream; // [rsp+10h] [rbp-58h]
FILE *streama; // [rsp+10h] [rbp-58h]
FILE *streamc; // [rsp+10h] [rbp-58h]
FILE *streamb; // [rsp+10h] [rbp-58h]
FILE *streamd; // [rsp+10h] [rbp-58h]
FILE *v32; // [rsp+18h] [rbp-50h]
size_t size; // [rsp+20h] [rbp-48h]
size_t sizea; // [rsp+20h] [rbp-48h]
FILE *v35; // [rsp+28h] [rbp-40h]

if ( argc <= 7 )
{
fprintf(stderr, "Usage: %s <file.gray> width height xoff yoff charwidth charheight\n", *argv);
v23 = 1;
}
else
{
v3 = atol(argv[2]);
v4 = atol(argv[3]);
v5 = v4;
if ( v3 <= 0
|| v4 <= 0
|| (v6 = atol(argv[4]), v7 = atol(argv[5]), v8 = v7, v6 < 0)
|| v7 < 0
|| (v9 = atol(argv[6]), v10 = atol(argv[7]), v25 = (FILE *)v10, v9 <= 0)
|| v10 <= 0 )
{
fprintf(stderr, "%s: Error: Parameter <= 0\n", *argv);
v23 = 1;
}
else if ( v9 > 32 )
{
fprintf(stderr, "%s: Error: charwidth > 32\n", *argv);
v23 = 1;
}
else
{
v11 = fopen(argv[1], "r+");
if ( !v11 )
{
fprintf(stderr, "Cannot open file '%s'\n", argv[1]);
return 1;
}
stream = v11;
v12 = fseek(v11, 0LL, 2);
v13 = stream;
if ( v12 )
goto LABEL_22;
v14 = ftell(stream);
if ( v14 != v5 * v3 )
{
fprintf(stderr, "%s: Error: file_size != %ld\n", *argv, v5 * v3);
return 1;
}
size = v14;
v15 = fseek(stream, 0LL, 0);
v13 = stream;
if ( v15 )
goto LABEL_22;
v35 = stream;
streama = (FILE *)size;
v16 = malloc(size);
if ( !v16 )
{
fprintf(stderr, "%s: Error: Out of memory\n", *argv);
return 1;
}
sizea = (size_t)v16;
v17 = fread(v16, 1uLL, (size_t)streama, v35);
v13 = v35;
if ( (FILE *)v17 != streama )
{
LABEL_22:
v26 = v13;
fprintf(stderr, "Read error in file '%s'\n", argv[1]);
fclose(v26);
v23 = 1;
}
else if ( nrcolor(v17, sizea) == 2 )
{
streamc = v18;
v19 = getyoff(v3, v5, v18);
v20 = streamc;
streamb = (FILE *)v19;
v32 = v20;
v21 = (FILE *)(getcharheight(v3, v5, v19, v20) + v19 - v8);
if ( v25 == v21 )
{
streamd = v22;
fonttable_constprop_0(v3, v6, v8, v9, v25, v32);
fclose(streamd);
v23 = 0;
}
else
{
fprintf(stderr, "%s: Error: charheight != %ld (yoff2:%ld)\n", *argv, v21, streamb);
v23 = 1;
}
}
else
{
fprintf(stderr, "%s: Error: Picture not black and white\n", *argv);
v23 = 1;
}
}
}
return v23;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
__int64 v4; // rax
__int64 v5; // r12
__int64 v6; // r13
__int64 v7; // rax
__int64 v8; // r14
__int64 v9; // r15
__int64 v10; // rax
FILE *v11; // rax
int v12; // eax
FILE *v13; // r11
__int64 v14; // rax
int v15; // eax
void *v16; // rax
size_t v17; // rax
FILE *v18; // r9
__int64 v19; // rax
FILE *v20; // r9
FILE *v21; // rcx
FILE *v22; // r11
int v23; // er10
FILE *v25; // [rsp+8h] [rbp-60h]
FILE *v26; // [rsp+8h] [rbp-60h]
FILE *stream; // [rsp+10h] [rbp-58h]
FILE *streama; // [rsp+10h] [rbp-58h]
FILE *streamc; // [rsp+10h] [rbp-58h]
FILE *streamb; // [rsp+10h] [rbp-58h]
FILE *streamd; // [rsp+10h] [rbp-58h]
FILE *v32; // [rsp+18h] [rbp-50h]
size_t size; // [rsp+20h] [rbp-48h]
size_t sizea; // [rsp+20h] [rbp-48h]
FILE *v35; // [rsp+28h] [rbp-40h]

if ( argc <= 7 )
{
fprintf(stderr, "Usage: %s <file.gray> width height xoff yoff charwidth charheight\n", *argv);
v23 = 1;
}
else
{
v3 = atol(argv[2]);
v4 = atol(argv[3]);
v5 = v4;
if ( v3 <= 0
|| v4 <= 0
|| (v6 = atol(argv[4]), v7 = atol(argv[5]), v8 = v7, v6 < 0)
|| v7 < 0
|| (v9 = atol(argv[6]), v10 = atol(argv[7]), v25 = (FILE *)v10, v9 <= 0)
|| v10 <= 0 )
{
fprintf(stderr, "%s: Error: Parameter <= 0\n", *argv);
v23 = 1;
}
else if ( v9 > 32 )
{
fprintf(stderr, "%s: Error: charwidth > 32\n", *argv);
v23 = 1;
}
else
{
v11 = fopen(argv[1], "r+");
if ( !v11 )
{
fprintf(stderr, "Cannot open file '%s'\n", argv[1]);
return 1;
}
stream = v11;
v12 = fseek(v11, 0LL, 2);
v13 = stream;
if ( v12 )
goto LABEL_22;
v14 = ftell(stream);
if ( v14 != v5 * v3 )
{
fprintf(stderr, "%s: Error: file_size != %ld\n", *argv, v5 * v3);
return 1;
}
size = v14;
v15 = fseek(stream, 0LL, 0);
v13 = stream;
if ( v15 )
goto LABEL_22;
v35 = stream;
streama = (FILE *)size;
v16 = malloc(size);
if ( !v16 )
{
fprintf(stderr, "%s: Error: Out of memory\n", *argv);
return 1;
}
sizea = (size_t)v16;
v17 = fread(v16, 1uLL, (size_t)streama, v35);
v13 = v35;
if ( (FILE *)v17 != streama )
{
LABEL_22:
v26 = v13;
fprintf(stderr, "Read error in file '%s'\n", argv[1]);
fclose(v26);
v23 = 1;
}
else if ( func7(v17, sizea) == 2 )
{
streamc = v18;
v19 = func8(v3, v5, v18);
v20 = streamc;
streamb = (FILE *)v19;
v32 = v20;
v21 = (FILE *)(func9(v3, v5, v19, v20) + v19 - v8);
if ( v25 == v21 )
{
streamd = v22;
func10(v3, v6, v8, v9, v25, v32);
fclose(streamd);
v23 = 0;
}
else
{
fprintf(stderr, "%s: Error: charheight != %ld (yoff2:%ld)\n", *argv, v21, streamb);
v23 = 1;
}
}
else
{
fprintf(stderr, "%s: Error: Picture not black and white\n", *argv);
v23 = 1;
}
}
}
return v23;
}

original_code:
int main(int argc, const char* argv[])
{
   int err = 0;
   if (argc > 3) err = 22;
   if (argc == 3) {
      if (0 == strcmp(argv[2], "thread")) {
         isthread = 1;
      } else if (0 == strcmp(argv[2], "process")) {
         isthread = 0;
      } else {
         err = 22;
      }
      -- argc;
   }
   if (argc == 2) {
      nrinstance = 0;
      sscanf(argv[1], "%d", &nrinstance);
      if (nrinstance <= 0 || nrinstance >= 256) err = 22;
   }
   if (err) {
      printf("Usage: %s [nr-test-instances] [thread|process]\n", argv[0]);
      printf("With: 0 < nr-test-instances < 256\n");
      exit(err);
   }
   printf("Run %d test %s%s\n", nrinstance, isthread ? "thread" : "process", nrinstance == 1 ? "" : isthread ? "s" : "es");
   instance = (instance_t*) malloc(sizeof(instance_t) * (size_t)nrinstance);
   if (! instance) err = 12;
   if (! err) {
      err = setpgid(0, 0);
      if (err) err = (*__errno_location ());
   }
   if (err) {
      print_error(-1, err);
   } else {
      prepare_instances();
      long long nrops = 1;
      run_instances(&nrops);
      long long sec = endtime.tv_sec - starttime.tv_sec;
      long long usec = endtime.tv_usec - starttime.tv_usec;
      usec = 1000000ll * sec + usec;
      printf("\nRESULT: %lld usec for %lld operations (%lld operations/usec)\n", usec, nrops, nrops/usec);
   }
   return err;
}

canonical_original_code:
int main(int argc, char *argv[])
{
   int err = 0;
   if (argc > 3) err = 22;
   if (argc == 3) {
      if (0 == strcmp(argv[2], "thread")) {
         isthread = 1;
      } else if (0 == strcmp(argv[2], "process")) {
         isthread = 0;
      } else {
         err = 22;
      }
      -- argc;
   }
   if (argc == 2) {
      nrinstance = 0;
      sscanf(argv[1], "%d", &nrinstance);
      if (nrinstance <= 0 || nrinstance >= 256) err = 22;
   }
   if (err) {
      printf("Usage: %s [nr-test-instances] [thread|process]\n", argv[0]);
      printf("With: 0 < nr-test-instances < 256\n");
      exit(err);
   }
   printf("Run %d test %s%s\n", nrinstance, isthread ? "thread" : "process", nrinstance == 1 ? "" : isthread ? "s" : "es");
   instance = (struct instance_t *) malloc(sizeof(instance_t) * (unsigned long)nrinstance);
   if (! instance) err = 12;
   if (! err) {
      err = setpgid(0, 0);
      if (err) err = (*__errno_location ());
   }
   if (err) {
      print_error(-1, err);
   } else {
      prepare_instances();
      long long nrops = 1;
      run_instances(&nrops);
      long long sec = endtime.tv_sec - starttime.tv_sec;
      long long usec = endtime.tv_usec - starttime.tv_usec;
      usec = 1000000ll * sec + usec;
      printf("\nRESULT: %lld usec for %lld operations (%lld operations/usec)\n", usec, nrops, nrops/usec);
   }
   return err;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: err int

variable_types:
nrops
long long

variable_types:
sec
long long

variable_types:
usec
long long

user_defined_types: struct instance_t { unsigned long thr; int child; struct iperf_param_t param; int preparedfd; int startfd; int resultfd; }

user_defined_types: struct iperf_param_t { int tid; int nrinstance; int isthread; int nrops; void *addr; unsigned long size; }


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rsi
__int64 v4; // rdx
__int64 v5; // rsi
__int64 v6; // rdx
unsigned __int8 v7; // al
unsigned __int8 v8; // al
unsigned int v9; // eax
char v11[4104]; // [rsp+0h] [rbp-1008h] BYREF

v3 = (unsigned __int8)w1_isfile("w1ce.h", argv, envp);
printf("Should be true : %d\n", v3);
v5 = (unsigned __int8)w1_isfile(&unk_402048, v3, v4);
printf("Should be false: %d\n", v5);
v7 = w1_isfile(".", v5, v6);
printf("Should be false: %d\n", v7);
v8 = w1_isdir(".");
printf("Should be true : %d\n", v8);
w1_abspath(".", v11, 4096LL);
printf("Abs path : %s\n", v11);
puts("Press key...");
v9 = w1_getch();
printf("Key pressed is: %d\n", v9);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rsi
__int64 v4; // rdx
__int64 v5; // rsi
__int64 v6; // rdx
unsigned __int8 v7; // al
unsigned __int8 v8; // al
unsigned int v9; // eax
char v11[4104]; // [rsp+0h] [rbp-1008h] BYREF

v3 = (unsigned __int8)func7("w1ce.h", argv, envp);
printf("Should be true : %d\n", v3);
v5 = (unsigned __int8)func7(&unk_402048, v3, v4);
printf("Should be false: %d\n", v5);
v7 = func7(".", v5, v6);
printf("Should be false: %d\n", v7);
v8 = func8(".");
printf("Should be true : %d\n", v8);
func9(".", v11, 4096LL);
printf("Abs path : %s\n", v11);
puts("Press key...");
v9 = func10();
printf("Key pressed is: %d\n", v9);
return 0;
}

original_code:
int main()
{
    printf("Should be true : %d\n", w1_isfile("w1ce.h"));
    printf("Should be false: %d\n", w1_isfile("skjdfnskdw1ce.h"));
    printf("Should be false: %d\n", w1_isfile("."));
    printf("Should be true : %d\n", w1_isdir("."));
    char abspath[4096];
    w1_abspath(".", abspath, 4096);
    printf("Abs path       : %s\n", abspath);
    printf("Press key...\n");
    int c = w1_getch();
    printf("Key pressed is: %d\n", c);
    return 0;
}

variable_types:
abspath
char [4096]

variable_types: c int


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

stat(a1, &v2);
return (v2.st_mode & 0xF000) == 0x8000;
}

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

func13(a1, &v2);
return (v2.st_mode & 0xF000) == 0x8000;
}

original_code:
_Bool w1_isfile(const char* path)
{
        struct stat sb;
        stat(path, &sb);
        return ((((sb.st_mode)) & 0170000) == (0100000));
}

canonical_original_code:
_Bool w1_isfile(char *path)
{
        struct stat sb;
        stat(path, &sb);
        return ((((sb.st_mode)) & 0170000) == (0100000));
}

variable_types:
path
char *

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

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


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

stat(a1, &v2);
return (v2.st_mode & 0xF000) == 0x4000;
}

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

func13(a1, &v2);
return (v2.st_mode & 0xF000) == 0x4000;
}

original_code:
_Bool w1_isdir(const char* path)
{
        struct stat sb;
        stat(path, &sb);
        return ((((sb.st_mode)) & 0170000) == (0040000));
}

canonical_original_code:
_Bool w1_isdir(char *path)
{
        struct stat sb;
        stat(path, &sb);
        return ((((sb.st_mode)) & 0170000) == (0040000));
}

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


decompiled_code:
__int64 __fastcall w1_abspath(const char *a1, char *a2, unsigned int a3)
{
if ( a3 <= 0xFFF )
__assert_fail("buf_length >= PATH_MAX", "w1ce.c", 0x2Du, "w1_abspath");
realpath(a1, a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(const char *a1, char *a2, unsigned int a3)
{
if ( a3 <= 0xFFF )
__assert_fail("buf_length >= PATH_MAX", "w1ce.c", 0x2Du, "w1_abspath");
realpath(a1, a2);
return 0LL;
}

original_code:
unsigned int w1_abspath(const char* path, char* buf, unsigned int buf_length)
{
        ((void) sizeof ((buf_length >= 4096) ? 1 : 0), __extension__ ({ if (buf_length >= 4096) ; else __assert_fail ("buf_length >= PATH_MAX", "w1ce.c", 45, __extension__ __PRETTY_FUNCTION__); }));
        realpath(path, buf);
        return 0;
}

canonical_original_code:
unsigned int w1_abspath(char *path, char *buf, unsigned int buf_length)
{
        ((void) sizeof ((buf_length >= 4096) ? 1 : 0), __extension__ ({ if (buf_length >= 4096) ; else __assert_fail ("buf_length >= PATH_MAX", "w1ce.c", 45, __extension__ __PRETTY_FUNCTION__); }));
        realpath(path, buf);
        return 0;
}

variable_types:
buf
char *

return_type: unsigned int


decompiled_code:
__int64 w1_getch()
{
__m128i v0; // xmm0
__m128i v1; // xmm2
unsigned int v2; // er12
struct termios v4; // [rsp+0h] [rbp-88h] BYREF
struct termios termios_p; // [rsp+40h] [rbp-48h] BYREF

tcgetattr(0, &v4);
v0 = _mm_loadu_si128((const __m128i *)&v4);
v1 = _mm_loadu_si128((const __m128i *)&v4.c_cc[15]);
*(__m128i *)&termios_p.c_line = _mm_loadu_si128((const __m128i *)&v4.c_line);
*(_QWORD *)&termios_p.c_cc[31] = *(_QWORD *)&v4.c_cc[31];
*(__m128i *)&termios_p.c_iflag = v0;
*(__m128i *)&termios_p.c_cc[15] = v1;
termios_p.c_lflag = v0.m128i_i32[3] & 0xFFFFFFF5;
termios_p.c_ospeed = v4.c_ospeed;
tcsetattr(0, 0, &termios_p);
v2 = getchar();
tcsetattr(0, 0, &v4);
return v2;
}

canonical_decompiled_code:
__int64 func10()
{
__m128i v0; // xmm0
__m128i v1; // xmm2
unsigned int v2; // er12
struct termios v4; // [rsp+0h] [rbp-88h] BYREF
struct termios termios_p; // [rsp+40h] [rbp-48h] BYREF

tcgetattr(0, &v4);
v0 = _mm_loadu_si128((const __m128i *)&v4);
v1 = _mm_loadu_si128((const __m128i *)&v4.c_cc[15]);
*(__m128i *)&termios_p.c_line = _mm_loadu_si128((const __m128i *)&v4.c_line);
*(_QWORD *)&termios_p.c_cc[31] = *(_QWORD *)&v4.c_cc[31];
*(__m128i *)&termios_p.c_iflag = v0;
*(__m128i *)&termios_p.c_cc[15] = v1;
termios_p.c_lflag = v0.m128i_i32[3] & 0xFFFFFFF5;
termios_p.c_ospeed = v4.c_ospeed;
tcsetattr(0, 0, &termios_p);
v2 = getchar();
tcsetattr(0, 0, &v4);
return v2;
}

original_code:
int w1_getch()
{
        struct termios old;
        struct termios new;
        tcgetattr(0, &old);
        new = old;
        new.c_lflag &= ~0000002;
        new.c_lflag &= ~0000010;
        tcsetattr(0, 0, &new);
        int ch = getchar();
        tcsetattr(0, 0, &old);
        return ch;
}

variable_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }

variable_types: ch int


repo: jeanbroid/mips

decompiled_code:
__int64 __fastcall get_byte(__int64 a1, unsigned int a2, _BYTE *a3)
{
__int64 v4; // rbx
__int64 result; // rax

v4 = (int)get_section();
result = 0LL;
if ( (_DWORD)v4 != -1 )
{
*a3 = *(_BYTE *)(*(_QWORD *)(a1 + 24 * v4 + 152) + (int)get_offset(a1, a2, (unsigned int)v4));
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, unsigned int a2, _BYTE *a3)
{
__int64 v4; // rbx
__int64 result; // rax

v4 = (int)get_section();
result = 0LL;
if ( (_DWORD)v4 != -1 )
{
*a3 = *(_BYTE *)(*(_QWORD *)(a1 + 24 * v4 + 152) + (int)get_offset(a1, a2, (unsigned int)v4));
result = 1LL;
}
return result;
}

original_code:
int get_byte(ARCH arch, uint addr, uchar* val)
{
 int section_index, offset;
 section_index = get_section(arch, addr);
 if (section_index == -1)
  return 0;
 offset = get_offset(arch, addr, section_index);
 *val = *((arch->sections)[section_index].data + offset);
 return 1;
}

canonical_original_code:
int get_byte(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, unsigned int addr, unsigned char *val)
{
 int section_index; int offset;
 section_index = get_section(arch, addr);
 if (section_index == -1)
  return 0;
 offset = get_offset(arch, addr, section_index);
 *val = *((arch->sections)[section_index].data + offset);
 return 1;
}

variable_types: struct { unsigned int registers[36]; struct section_t { char *name; unsigned char *data; unsigned int start_addr; unsigned int size; } sections[4]; enum state_t { NOT_LOADED=0, PAUSED=1, FINISHED=2 } state; struct list_elt { void *val; struct list_elt *next; } *breakpoints; struct Elf32_Sym { unsigned int st_name; unsigned int st_value; unsigned int st_size; unsigned char st_info; unsigned char st_other; unsigned short st_shndx; } *symbols; unsigned int symbols_num; char *symbols_names; } *

variable_types:
addr
unsigned int

variable_types:
val
unsigned char *

variable_types: offset int


decompiled_code:
__int64 __fastcall get_byte_details(__int64 a1, unsigned int a2, _BYTE *a3, unsigned int *a4)
{
unsigned int v6; // eax
__int64 v7; // rdx
__int64 result; // rax

v6 = get_section();
v7 = v6;
*a4 = v6;
result = 0LL;
if ( (_DWORD)v7 != -1 )
{
*a3 = *(_BYTE *)(*(_QWORD *)(a1 + 24LL * (int)*a4 + 152) + (int)get_offset(a1, a2, v7));
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, unsigned int a2, _BYTE *a3, unsigned int *a4)
{
unsigned int v6; // eax
__int64 v7; // rdx
__int64 result; // rax

v6 = get_section();
v7 = v6;
*a4 = v6;
result = 0LL;
if ( (_DWORD)v7 != -1 )
{
*a3 = *(_BYTE *)(*(_QWORD *)(a1 + 24LL * (int)*a4 + 152) + (int)get_offset(a1, a2, v7));
result = 1LL;
}
return result;
}

original_code:
int get_byte_details(ARCH arch, uint addr, uchar* val, int* section_index)
{
 int offset;
 *section_index = get_section(arch, addr);
 if (*section_index == -1)
  return 0;
 offset = get_offset(arch, addr, *section_index);
 *val = *((arch->sections)[*section_index].data + offset);
 return 1;
}

canonical_original_code:
int get_byte_details(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, unsigned int addr, unsigned char *val, int *section_index)
{
 int offset;
 *section_index = get_section(arch, addr);
 if (*section_index == -1)
  return 0;
 offset = get_offset(arch, addr, *section_index);
 *val = *((arch->sections)[*section_index].data + offset);
 return 1;
}

user_defined_types: enum state_t { NOT_LOADED=0, PAUSED=1, FINISHED=2 }

user_defined_types: struct section_t { char *name; unsigned char *data; unsigned int start_addr; unsigned int size; }

user_defined_types: struct list_elt { void *val; struct list_elt *next; }

user_defined_types: struct Elf32_Sym { unsigned int st_name; unsigned int st_value; unsigned int st_size; unsigned char st_info; unsigned char st_other; unsigned short st_shndx; }


decompiled_code:
__int64 __fastcall display_byte(__int64 a1, unsigned int a2)
{
unsigned int v2; // er12
char v4[9]; // [rsp+Fh] [rbp-9h] BYREF

v2 = get_byte(a1, a2, v4);
if ( v2 )
printf("%02x ", (unsigned __int8)v4[0]);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned int a2)
{
unsigned int v2; // er12
char v4[9]; // [rsp+Fh] [rbp-9h] BYREF

v2 = func0(a1, a2, v4);
if ( v2 )
printf("%02x ", (unsigned __int8)v4[0]);
return v2;
}

original_code:
int display_byte(ARCH arch, uint addr)
{
 uchar val;
 int res = get_byte(arch, addr, &val);
 if (res)
  printf("%02x ", val);
 return res;
}

canonical_original_code:
int display_byte(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, unsigned int addr)
{
 unsigned char val;
 int res = get_byte(arch, addr, &val);
 if (res)
  printf("%02x ", val);
 return res;
}

variable_types:
val
unsigned char

variable_types: res int


original_code:
int display_range_addr(ARCH arch, uint addr_start, int bytes_nb)
{
 int i;
 uint c = 0;
 int res;
 int section_index = -1;
 int section_index_old = -1;
 uchar val;
 for (i = 0; i < bytes_nb ; i++) {
  if (section_index != -1 && section_index < 2) {
   if (c == (arch->sections[section_index]).size) {
    i = arch->sections[section_index+1].start_addr - 1;
    c = 0;
    continue;
   }
  }
  res = get_byte_details(arch, addr_start + i, &val, &section_index);
     if (section_index != section_index_old && section_index >= 0) {
      switch (section_index) {
   case 0:
    printf("=== section .text");
    break;
   case 2:
    printf("\n=== section .bss");
    break;
   case 1:
    printf("\n=== section .data");
    break;
      }
      if (arch->sections[section_index].size < (uint) bytes_nb - i)
       printf(" (%d", arch->sections[section_index].size);
      else
       printf(" (%d", bytes_nb - i);
      printf(" bytes) ===\n");
      section_index_old = section_index;
     }
     if (res) {
   if (i%16 == 0)
       printf("%08x: ", addr_start+i);
      printf("%02x ", val);
      if ((i+1)%16 == 0)
       printf("\n");
  }
     c++;
 }
    printf("\n");
 return 1;
}

canonical_original_code:
int display_range_addr(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, unsigned int addr_start, int bytes_nb)
{
 int i;
 unsigned int c = 0;
 int res;
 int section_index = -1;
 int section_index_old = -1;
 unsigned char val;
 for (i = 0; i < bytes_nb ; i++) {
  if (section_index != -1 && section_index < 2) {
   if (c == (arch->sections[section_index]).size) {
    i = arch->sections[section_index+1].start_addr - 1;
    c = 0;
    continue;
   }
  }
  res = get_byte_details(arch, addr_start + i, &val, &section_index);
     if (section_index != section_index_old && section_index >= 0) {
      switch (section_index) {
   case 0:
    printf("=== section .text");
    break;
   case 2:
    printf("\n=== section .bss");
    break;
   case 1:
    printf("\n=== section .data");
    break;
      }
      if (arch->sections[section_index].size < (unsigned int) bytes_nb - i)
       printf(" (%d", arch->sections[section_index].size);
      else
       printf(" (%d", bytes_nb - i);
      printf(" bytes) ===\n");
      section_index_old = section_index;
     }
     if (res) {
   if (i%16 == 0)
       printf("%08x: ", addr_start+i);
      printf("%02x ", val);
      if ((i+1)%16 == 0)
       printf("\n");
  }
     c++;
 }
    printf("\n");
 return 1;
}

variable_types: i int

variable_types:
c
unsigned int


decompiled_code:
__int64 __fastcall display_addr(__int64 a1, unsigned int a2)
{
unsigned int v2; // er12
unsigned int v3; // ebx
unsigned int v4; // esi

v2 = a2 + 4;
v3 = a2;
do
{
v4 = v3++;
display_byte(a1, v4);
}
while ( v2 != v3 );
putchar(10);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, unsigned int a2)
{
unsigned int v2; // er12
unsigned int v3; // ebx
unsigned int v4; // esi

v2 = a2 + 4;
v3 = a2;
do
{
v4 = v3++;
func2(a1, v4);
}
while ( v2 != v3 );
putchar(10);
return 1LL;
}

original_code:
int display_addr(ARCH arch, uint addr)
{
 uint i;
 for (i = 0; i < 4; i++)
  display_byte(arch, addr + i);
 printf("\n");
 return 1;
}

canonical_original_code:
int display_addr(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, unsigned int addr)
{
 unsigned int i;
 for (i = 0; i < 4; i++)
  display_byte(arch, addr + i);
 printf("\n");
 return 1;
}

variable_types:
i
unsigned int


decompiled_code:
__int64 __fastcall display_addr_to_addr(__int64 a1, _QWORD *a2)
{
unsigned int v3; // [rsp+8h] [rbp-20h] BYREF
unsigned int v4[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( !(unsigned int)parse_addr(*a2, &v3) || !(unsigned int)parse_addr(a2[2], v4) )
return 4294967294LL;
if ( v3 > v4[0] )
return 0xFFFFFFFFLL;
return display_range_addr(a1, v3, v4[0] + 1 - v3);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, _QWORD *a2)
{
unsigned int v3; // [rsp+8h] [rbp-20h] BYREF
unsigned int v4[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( !(unsigned int)parse_addr(*a2, &v3) || !(unsigned int)parse_addr(a2[2], v4) )
return 4294967294LL;
if ( v3 > v4[0] )
return 0xFFFFFFFFLL;
return func3(a1, v3, v4[0] + 1 - v3);
}

original_code:
int display_addr_to_addr(ARCH arch, char** args)
{
 uint addr0, addr1;
 if (!parse_addr(args[0], &addr0) || !parse_addr(args[2], &addr1))
  return -2;
 if (addr0 > addr1)
  return -1;
 return display_range_addr(arch, addr0, (addr1 - addr0 + 1));
}

canonical_original_code:
int display_addr_to_addr(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, char **args)
{
 unsigned int addr0; unsigned int addr1;
 if (!parse_addr(args[0], &addr0) || !parse_addr(args[2], &addr1))
  return -2;
 if (addr0 > addr1)
  return -1;
 return display_range_addr(arch, addr0, (addr1 - addr0 + 1));
}

variable_types:
args
char **


decompiled_code:
__int64 __fastcall display_bytes_from_addr(__int64 a1, _QWORD *a2)
{
__int64 result; // rax
int v3; // [rsp+8h] [rbp-20h] BYREF
int v4; // [rsp+Ch] [rbp-1Ch] BYREF

if ( !(unsigned int)parse_addr(*a2, &v3) )
return 4294967294LL;
if ( (unsigned int)_isoc99_sscanf(a2[2], "%d", &v4) == 1 )
{
if ( v4 < 0 )
{
fprintf(stderr, "%c[%d;%dm", 27LL, 1LL, 34LL);
fprintf(stderr, "[WARNING:: %s:%s:%d] ", "src/arch/address.c", "display_bytes_from_addr", 170LL);
fprintf(stderr, "%c[%d;%dm", 27LL, 1LL, 33LL);
fwrite("invalid number (positive expected)", 1uLL, 0x22uLL, stderr);
fwrite(".\n", 1uLL, 2uLL, stderr);
fprintf(stderr, "%c[%dm", 27LL, 0LL);
result = 0xFFFFFFFFLL;
}
else
{
result = display_range_addr(a1, v3, v4);
}
}
else
{
print_error("Invalid bytes range");
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, _QWORD *a2)
{
__int64 result; // rax
int v3; // [rsp+8h] [rbp-20h] BYREF
int v4; // [rsp+Ch] [rbp-1Ch] BYREF

if ( !(unsigned int)parse_addr(*a2, &v3) )
return 4294967294LL;
if ( (unsigned int)_isoc99_sscanf(a2[2], "%d", &v4) == 1 )
{
if ( v4 < 0 )
{
fprintf(stderr, "%c[%d;%dm", 27LL, 1LL, 34LL);
fprintf(stderr, "[WARNING:: %s:%s:%d] ", "src/arch/address.c", "display_bytes_from_addr", 170LL);
fprintf(stderr, "%c[%d;%dm", 27LL, 1LL, 33LL);
fwrite("invalid number (positive expected)", 1uLL, 0x22uLL, stderr);
fwrite(".\n", 1uLL, 2uLL, stderr);
fprintf(stderr, "%c[%dm", 27LL, 0LL);
result = 0xFFFFFFFFLL;
}
else
{
result = func3(a1, v3, v4);
}
}
else
{
print_error("Invalid bytes range");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int display_bytes_from_addr(ARCH arch, char** args)
{
 uint addr;
 int bytes_nb;
 if (!parse_addr(args[0], &addr))
  return -2;
 if (sscanf(args[2], "%d", &bytes_nb) != 1) {
  print_error("Invalid bytes range");
  return -1;
 }
 if (bytes_nb < 0) {
  do { fprintf( stderr, "%c[%d;%dm", 0x1B, 0x01, 34 ); fprintf( stderr, "[WARNING:: %s:%s:%d] ", "src/arch/address.c", __FUNCTION__, 170 ); fprintf( stderr, "%c[%d;%dm", 0x1B, (0x01 == 0x00 ? 0x05 : (0x01 == 0x01 ? 0x01 : 0x01 )), (0x01 == 0x00 ? 31 : (0x01 == 0x01 ? 33 : 32 )) ); fprintf( stderr, "invalid number (positive expected)" ); fprintf( stderr, ".\n" ); fprintf( stderr, "%c[%dm", 0x1B, 0 ); } while( 0 );
  return -1;
 }
 return display_range_addr(arch, addr, bytes_nb);
}

canonical_original_code:
int display_bytes_from_addr(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, char **args)
{
 unsigned int addr;
 int bytes_nb;
 if (!parse_addr(args[0], &addr))
  return -2;
 if (sscanf(args[2], "%d", &bytes_nb) != 1) {
  print_error("Invalid bytes range");
  return -1;
 }
 if (bytes_nb < 0) {
  do { fprintf( stderr, "%c[%d;%dm", 0x1B, 0x01, 34 ); fprintf( stderr, "[WARNING:: %s:%s:%d] ", "src/arch/address.c", __FUNCTION__, 170 ); fprintf( stderr, "%c[%d;%dm", 0x1B, (0x01 == 0x00 ? 0x05 : (0x01 == 0x01 ? 0x01 : 0x01 )), (0x01 == 0x00 ? 31 : (0x01 == 0x01 ? 33 : 32 )) ); fprintf( stderr, "invalid number (positive expected)" ); fprintf( stderr, ".\n" ); fprintf( stderr, "%c[%dm", 0x1B, 0 ); } while( 0 );
  return -1;
 }
 return display_range_addr(arch, addr, bytes_nb);
}


decompiled_code:
__int64 __fastcall display_one_addr(__int64 a1, _QWORD *a2)
{
int v2; // er8
__int64 result; // rax
int v4; // ebx
unsigned int v5; // esi
char v6; // [rsp+Bh] [rbp-1Dh] BYREF
unsigned int v7[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( !(unsigned int)parse_addr(*a2, v7) )
return 4294967294LL;
v2 = get_byte(a1, v7[0], &v6);
result = 1LL;
if ( v2 )
{
v4 = 0;
printf("%08x: ", v7[0]);
do
{
v5 = v4 + v7[0];
++v4;
display_byte(a1, v5);
}
while ( v4 != 4 );
putchar(10);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, _QWORD *a2)
{
int v2; // er8
__int64 result; // rax
int v4; // ebx
unsigned int v5; // esi
char v6; // [rsp+Bh] [rbp-1Dh] BYREF
unsigned int v7[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( !(unsigned int)parse_addr(*a2, v7) )
return 4294967294LL;
v2 = func0(a1, v7[0], &v6);
result = 1LL;
if ( v2 )
{
v4 = 0;
printf("%08x: ", v7[0]);
do
{
v5 = v4 + v7[0];
++v4;
func2(a1, v5);
}
while ( v4 != 4 );
putchar(10);
result = 1LL;
}
return result;
}

original_code:
int display_one_addr(ARCH arch, char** args)
{
 uint addr;
 uchar val;
 if (!parse_addr(args[0], &addr))
  return -2;
 if (get_byte(arch, addr, &val)) {
  printf("%08x: ", addr);
  for (int j = 0; j < 4; j++) {
   display_byte(arch, addr + j);
  }
  printf("\n");
 }
 return 1;
}

canonical_original_code:
int display_one_addr(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, char **args)
{
 unsigned int addr;
 unsigned char val;
 if (!parse_addr(args[0], &addr))
  return -2;
 if (get_byte(arch, addr, &val)) {
  printf("%08x: ", addr);
  for (int j = 0; j < 4; j++) {
   display_byte(arch, addr + j);
  }
  printf("\n");
 }
 return 1;
}

variable_types: j int


usage

decompiled_code:
int __fastcall usage(const char *a1)
{
return printf("Usage: %s [file]\n", a1);
}

canonical_decompiled_code:
int __fastcall func0(const char *a1)
{
return printf("Usage: %s [file]\n", a1);
}

original_code:
void usage(char *arg)
{
 printf("Usage: %s [file]\n", arg);
}

variable_types:
arg
char *


decompiled_code:
int __fastcall print_str(const char *a1, const char *a2, unsigned int a3)
{
struct tm *v4; // rax
time_t timer; // [rsp+8h] [rbp-40h] BYREF
char s[56]; // [rsp+10h] [rbp-38h] BYREF

time(&timer);
v4 = localtime(&timer);
strftime(s, 0x19uLL, "%H:%M:%S", v4);
return fprintf(stderr, "\x1B[%dm[ %s | %s: %s ]\n\x1B[0m", a3, s, a2, a1);
}

canonical_decompiled_code:
int __fastcall func2(const char *a1, const char *a2, unsigned int a3)
{
struct tm *v4; // rax
time_t timer; // [rsp+8h] [rbp-40h] BYREF
char s[56]; // [rsp+10h] [rbp-38h] BYREF

time(&timer);
v4 = localtime(&timer);
strftime(s, 0x19uLL, "%H:%M:%S", v4);
return fprintf(stderr, "\x1B[%dm[ %s | %s: %s ]\n\x1B[0m", a3, s, a2, a1);
}

original_code:
void print_str(char *str, char *type, int color)
{
 time_t timer;
 char buffer[25];
 struct tm *tm_info;
 time(&timer);
 tm_info = localtime(&timer);
 strftime(buffer, 25, "%H:%M:%S", tm_info);
 fprintf(stderr, "\x1b[%dm[ %s | %s: %s ]\n\x1b[0m", color, buffer,
  type, str);
}

canonical_original_code:
void print_str(char *str, char *type, int color)
{
 long timer;
 char buffer[25];
 struct tm *tm_info;
 time(&timer);
 tm_info = localtime(&timer);
 strftime(buffer, 25, "%H:%M:%S", tm_info);
 fprintf(stderr, "\x1b[%dm[ %s | %s: %s ]\n\x1b[0m", color, buffer,
  type, str);
}

variable_types:
str
char *

variable_types:
type
char *

variable_types: color int

variable_types: timer long

variable_types:
buffer
char [25]

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long __tm_gmtoff; char *__tm_zone; } *


decompiled_code:
int __fastcall print_info(const char *a1)
{
return print_str(a1, "Info", 0x22u);
}

canonical_decompiled_code:
int __fastcall func3(const char *a1)
{
return func2(a1, "Info", 0x22u);
}

original_code:
void print_info(char *str)
{
 print_str(str, "Info", 34);
}


quit

decompiled_code:
void __fastcall __noreturn quit(__int64 a1)
{
print_info("Exiting...");
free_arch(a1);
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func4(__int64 a1)
{
func3("Exiting...");
free_arch(a1);
exit(0);
}

original_code:
int quit(ARCH arch)
{
 print_info("Exiting...");
 free_arch(arch);
 exit(0);
}

canonical_original_code:
int quit(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch)
{
 print_info("Exiting...");
 free_arch(arch);
 exit(0);
}

variable_types: struct { unsigned int registers[36]; struct section_t { char *name; unsigned char *data; unsigned int start_addr; unsigned int size; } sections[4]; enum state_t { NOT_LOADED=0, PAUSED=1, FINISHED=2 } state; struct list_elt { void *val; struct list_elt *next; } *breakpoints; struct Elf32_Sym { unsigned int st_name; unsigned int st_value; unsigned int st_size; unsigned char st_info; unsigned char st_other; unsigned short st_shndx; } *symbols; unsigned int symbols_num; char *symbols_names; } *


decompiled_code:
int __fastcall print_error(const char *a1)
{
return print_str(a1, "Error", 0x1Fu);
}

canonical_decompiled_code:
int __fastcall func5(const char *a1)
{
return func2(a1, "Error", 0x1Fu);
}

original_code:
void print_error(char *str)
{
 print_str(str, "Error", 31);
}


die

decompiled_code:
void __fastcall __noreturn die(__int64 a1)
{
if ( a1 )
free_arch(a1);
print_error("Exiting...");
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func6(__int64 a1)
{
if ( a1 )
free_arch(a1);
func5("Exiting...");
exit(1);
}

original_code:
int die(ARCH arch)
{
 if (arch != ((void *)0))
  free_arch(arch);
 print_error("Exiting...");
 exit(1);
}

canonical_original_code:
int die(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch)
{
 if (arch != ((void *)0))
  free_arch(arch);
 print_error("Exiting...");
 exit(1);
}


decompiled_code:
int __fastcall print_section_info(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rcx
__int64 v3; // r8
const char *v4; // rdx
int result; // eax

v1 = a1 + 144;
do
{
v2 = *(unsigned int *)(v1 + 16);
v3 = *(unsigned int *)(v1 + 20);
v4 = *(const char **)v1;
v1 += 24LL;
result = fprintf(stderr, "%-7s: %08x %d \n", v4, v2, v3);
}
while ( v1 != a1 + 240 );
return result;
}

canonical_decompiled_code:
int __fastcall func7(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rcx
__int64 v3; // r8
const char *v4; // rdx
int result; // eax

v1 = a1 + 144;
do
{
v2 = *(unsigned int *)(v1 + 16);
v3 = *(unsigned int *)(v1 + 20);
v4 = *(const char **)v1;
v1 += 24LL;
result = fprintf(stderr, "%-7s: %08x %d \n", v4, v2, v3);
}
while ( v1 != a1 + 240 );
return result;
}

original_code:
void print_section_info(ARCH arch)
{
 for (int i = 0; i < 4; i++)
  fprintf(stderr, "%-7s: %08x %d \n", (arch->sections)[i].name,
   (arch->sections)[i].start_addr, (arch->sections)[i].size);
}

canonical_original_code:
void print_section_info(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch)
{
 for (int i = 0; i < 4; i++)
  fprintf(stderr, "%-7s: %08x %d \n", (arch->sections)[i].name,
   (arch->sections)[i].start_addr, (arch->sections)[i].size);
}


decompiled_code:
__int64 __fastcall get_hash(const char *a1)
{
size_t v1; // rax
unsigned int v2; // er8
size_t v3; // rdx
size_t v4; // rax
int v5; // ecx

v1 = strlen(a1);
v2 = 0;
v3 = v1;
v4 = 0LL;
do
{
if ( v3 <= v4 )
break;
v5 = a1[v4++];
v2 = 100 * v2 + v5 - 96;
}
while ( (_DWORD)v4 != 2 );
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func8(const char *a1)
{
size_t v1; // rax
unsigned int v2; // er8
size_t v3; // rdx
size_t v4; // rax
int v5; // ecx

v1 = strlen(a1);
v2 = 0;
v3 = v1;
v4 = 0LL;
do
{
if ( v3 <= v4 )
break;
v5 = a1[v4++];
v2 = 100 * v2 + v5 - 96;
}
while ( (_DWORD)v4 != 2 );
return v2;
}

original_code:
uint get_hash(char *cmd)
{
 uint res = 0;
 for (uint i = 0; i < strlen(cmd) && i < 2; i++) {
  res = res * 100;
  res = res + (*(cmd + i) - 'a' + 1);
 }
 return res;
}

canonical_original_code:
unsigned int get_hash(char *cmd)
{
 unsigned int res = 0;
 for (unsigned int i = 0; i < strlen(cmd) && i < 2; i++) {
  res = res * 100;
  res = res + (*(cmd + i) - 'a' + 1);
 }
 return res;
}

variable_types:
cmd
char *

variable_types:
res
unsigned int


decompiled_code:
__int64 __fastcall bin_to_dec(const char *a1)
{
size_t v1; // rax
unsigned int v2; // er8
unsigned __int64 v3; // rcx
unsigned int i; // eax
int v5; // edx

v1 = strlen(a1);
v2 = 0;
v3 = v1;
for ( i = 0; i < v3; ++i )
{
v5 = (unsigned __int8)a1[i];
v2 = v5 + 2 * v2 - 48;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func9(const char *a1)
{
size_t v1; // rax
unsigned int v2; // er8
unsigned __int64 v3; // rcx
unsigned int i; // eax
int v5; // edx

v1 = strlen(a1);
v2 = 0;
v3 = v1;
for ( i = 0; i < v3; ++i )
{
v5 = (unsigned __int8)a1[i];
v2 = v5 + 2 * v2 - 48;
}
return v2;
}

original_code:
char bin_to_dec(char *n)
{
 char res = 0;
 for (uint i = 0; i < strlen(n); i++)
  res = res * 2 + (n[i] - (int) '0');
 return res;
}

canonical_original_code:
char bin_to_dec(char *n)
{
 char res = 0;
 for (unsigned int i = 0; i < strlen(n); i++)
  res = res * 2 + (n[i] - (int) '0');
 return res;
}

variable_types:
n
char *

variable_types: res char

return_type: char


decompiled_code:
int __fastcall print_bits(unsigned int a1)
{
int v1; // ebx

v1 = 31;
do
fprintf(stderr, "%d", (a1 >> v1) & 1);
while ( v1-- != 0 );
return fputc(10, stderr);
}

canonical_decompiled_code:
int __fastcall func12(unsigned int a1)
{
int v1; // ebx

v1 = 31;
do
fprintf(stderr, "%d", (a1 >> v1) & 1);
while ( v1-- != 0 );
return fputc(10, stderr);
}

original_code:
void print_bits(uint val)
{
 for (int i = 31; i >= 0; i--)
  fprintf(stderr, "%d", (val >> i) & 1);
 fprintf(stderr, "\n");
}

canonical_original_code:
void print_bits(unsigned int val)
{
 for (int i = 31; i >= 0; i--)
  fprintf(stderr, "%d", (val >> i) & 1);
 fprintf(stderr, "\n");
}

variable_types:
val
unsigned int

variable_types: i int


decompiled_code:
size_t __fastcall lower_string(char *s)
{
unsigned int i; // ebp
char *v2; // rbx
size_t result; // rax

for ( i = 0; ; ++i )
{
result = strlen(s);
if ( i >= result )
break;
v2 = &s[i];
*v2 = (*_ctype_tolower_loc())[*v2];
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func14(char *s)
{
unsigned int i; // ebp
char *v2; // rbx
size_t result; // rax

for ( i = 0; ; ++i )
{
result = strlen(s);
if ( i >= result )
break;
v2 = &s[i];
*v2 = (*_ctype_tolower_loc())[*v2];
}
return result;
}

original_code:
void lower_string(char* str)
{
 for (uint i = 0; i < strlen(str); i++)
  *(str+i) = tolower(*(str+i));
}

canonical_original_code:
void lower_string(char *str)
{
 for (unsigned int i = 0; i < strlen(str); i++)
  *(str+i) = tolower(*(str+i));
}

variable_types:
i
unsigned int


decompiled_code:
__int64 execute_cmd_ex()
{
return 11LL;
}

canonical_decompiled_code:
__int64 func0()
{
return 11LL;
}

original_code:
int execute_cmd_ex()
{
 ;
 return 11;
}

canonical_original_code:
int execute_cmd_ex()
{
 ;
 return 11;
}


decompiled_code:
__int64 __fastcall execute_cmd_testcmd(__int64 a1, _QWORD *a2)
{
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( (unsigned int)_isoc99_sscanf(*a2, &unk_948, v3) != 1 )
return 0LL;
printf("CMD TEST RESULT 0x%x\n", (unsigned int)(v3[0] + 1));
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, _QWORD *a2)
{
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( (unsigned int)_isoc99_sscanf(*a2, &unk_948, v3) != 1 )
return 0LL;
printf("CMD TEST RESULT 0x%x\n", (unsigned int)(v3[0] + 1));
return 1LL;
}

original_code:
int execute_cmd_testcmd(ARCH arch, char** args)
{
 uint addr;
 (void)(arch);
 ;
 if (sscanf(args[0], "%x", &addr) != 1)
  return 0;
 ;
 addr++;
 printf("CMD TEST RESULT 0x%x\n", addr);
 return 1;
}

canonical_original_code:
int execute_cmd_testcmd(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, char **args)
{
 unsigned int addr;
 (void)(arch);
 ;
 if (sscanf(args[0], "%x", &addr) != 1)
  return 0;
 ;
 addr++;
 printf("CMD TEST RESULT 0x%x\n", addr);
 return 1;
}

variable_types:
args
char **

variable_types:
addr
unsigned int


decompiled_code:
__int64 __fastcall execute_cmd_lm(__int64 a1, _QWORD *a2)
{
unsigned int v3; // eax
__int64 v4; // rbx
__int64 v5; // rax
__int64 v6; // rdi
char *v7; // rbp
__int64 result; // rax
char v9[4]; // [rsp+8h] [rbp-20h] BYREF
unsigned int v10[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( !(unsigned int)parse_addr_value(a2[1], v9) )
return 4294967275LL;
if ( !(unsigned int)parse_addr(*a2, v10) )
return 4294967294LL;
v3 = get_section(a1, v10[0]);
v4 = (int)v3;
if ( v3 == -1 )
{
print_error("address not in sections");
result = 0LL;
}
else
{
v5 = (int)get_offset(a1, v10[0], v3);
v6 = (int)v5 + 4LL;
v7 = &v9[-(int)v5];
do
{
*(_BYTE *)(*(_QWORD *)(a1 + 24 * v4 + 152) + v5) = v7[v5];
++v5;
}
while ( v5 != v6 );
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, _QWORD *a2)
{
unsigned int v3; // eax
__int64 v4; // rbx
__int64 v5; // rax
__int64 v6; // rdi
char *v7; // rbp
__int64 result; // rax
char v9[4]; // [rsp+8h] [rbp-20h] BYREF
unsigned int v10[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( !(unsigned int)parse_addr_value(a2[1], v9) )
return 4294967275LL;
if ( !(unsigned int)parse_addr(*a2, v10) )
return 4294967294LL;
v3 = get_section(a1, v10[0]);
v4 = (int)v3;
if ( v3 == -1 )
{
print_error("address not in sections");
result = 0LL;
}
else
{
v5 = (int)get_offset(a1, v10[0], v3);
v6 = (int)v5 + 4LL;
v7 = &v9[-(int)v5];
do
{
*(_BYTE *)(*(_QWORD *)(a1 + 24 * v4 + 152) + v5) = v7[v5];
++v5;
}
while ( v5 != v6 );
result = 1LL;
}
return result;
}

original_code:
int execute_cmd_lm(ARCH arch, char** args)
{
 INSTR val;
 int i = 0;
 int section_index, offset;
 uint addr;
 ;
 if (!parse_addr_value(args[1], &val.word))
  return -21;
 if (!parse_addr(args[0], &addr))
  return -2;
 section_index = get_section(arch, addr);
 if (section_index == -1) {
  print_error("address not in sections");
  return 0;
 }
 offset = get_offset(arch, addr, section_index);
 for (i = 0; i < 4; i++) {
  *((arch->sections)[section_index].data + offset + i) = val.bytes[i];
 }
 return 1;
}

canonical_original_code:
int execute_cmd_lm(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, char **args)
{
 union INSTR val;
 int i = 0;
 int section_index; int offset;
 unsigned int addr;
 ;
 if (!parse_addr_value(args[1], &val.word))
  return -21;
 if (!parse_addr(args[0], &addr))
  return -2;
 section_index = get_section(arch, addr);
 if (section_index == -1) {
  print_error("address not in sections");
  return 0;
 }
 offset = get_offset(arch, addr, section_index);
 for (i = 0; i < 4; i++) {
  *((arch->sections)[section_index].data + offset + i) = val.bytes[i];
 }
 return 1;
}

variable_types: union INSTR { unsigned int word; unsigned char bytes[4]; }

variable_types: offset int


decompiled_code:
__int64 __fastcall execute_cmd_lr(__int64 a1, _QWORD *a2)
{
int v2; // eax
__int64 v3; // rbx
__int64 result; // rax
int v5[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v2 = parse_register(*a2);
v3 = v2;
if ( v2 == -1 )
return 4294967293LL;
if ( v2 )
{
if ( (unsigned int)parse_reg_value(a2[1], v5) )
{
*(_DWORD *)(a1 + 4 * v3) = v5[0];
result = 1LL;
}
else
{
result = 4294967265LL;
}
}
else
{
print_error("$zero can't be modified");
result = 4294967293LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, _QWORD *a2)
{
int v2; // eax
__int64 v3; // rbx
__int64 result; // rax
int v5[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v2 = parse_register(*a2);
v3 = v2;
if ( v2 == -1 )
return 4294967293LL;
if ( v2 )
{
if ( (unsigned int)parse_reg_value(a2[1], v5) )
{
*(_DWORD *)(a1 + 4 * v3) = v5[0];
result = 1LL;
}
else
{
result = 4294967265LL;
}
}
else
{
print_error("$zero can't be modified");
result = 4294967293LL;
}
return result;
}

original_code:
int execute_cmd_lr(ARCH arch, char** args)
{
 int reg;
 uint val;
 ;
 reg = parse_register(args[0]);
 if (reg == -1 ) {
  return -3;
 }
 else if (reg == 0) {
  print_error("$zero can't be modified");
  return -3;
 }
 if (!parse_reg_value(args[1], &val)) {
  return -31;
 }
 (arch->registers)[reg] = (uint) val;
 return 1;
}

canonical_original_code:
int execute_cmd_lr(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, char **args)
{
 int reg;
 unsigned int val;
 ;
 reg = parse_register(args[0]);
 if (reg == -1 ) {
  return -3;
 }
 else if (reg == 0) {
  print_error("$zero can't be modified");
  return -3;
 }
 if (!parse_reg_value(args[1], &val)) {
  return -31;
 }
 (arch->registers)[reg] = (unsigned int) val;
 return 1;
}

variable_types: reg int


decompiled_code:
__int64 __fastcall execute_cmd_dr(__int64 a1, __int64 *a2)
{
__int64 v3; // rbx
__int64 v4; // rdi
unsigned int v5; // eax
int v6; // er13
__int64 result; // rax

v3 = 1LL;
v4 = *a2;
if ( *a2 )
{
do
{
while ( 1 )
{
v5 = parse_register(v4);
if ( v5 == -1 )
{
putchar(10);
return 4294967293LL;
}
display_reg(a1, v5);
v6 = v3 & 3;
if ( (v3 & 3) == 0 )
break;
v4 = a2[v3++];
if ( !v4 )
goto LABEL_7;
}
++v3;
putchar(10);
v4 = a2[v3 - 1];
}
while ( v4 );
LABEL_7:
if ( !v6 )
goto LABEL_8;
putchar(10);
result = 1LL;
}
else
{
display_reg_all(a1);
LABEL_8:
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 *a2)
{
__int64 v3; // rbx
__int64 v4; // rdi
unsigned int v5; // eax
int v6; // er13
__int64 result; // rax

v3 = 1LL;
v4 = *a2;
if ( *a2 )
{
do
{
while ( 1 )
{
v5 = parse_register(v4);
if ( v5 == -1 )
{
putchar(10);
return 4294967293LL;
}
display_reg(a1, v5);
v6 = v3 & 3;
if ( (v3 & 3) == 0 )
break;
v4 = a2[v3++];
if ( !v4 )
goto LABEL_7;
}
++v3;
putchar(10);
v4 = a2[v3 - 1];
}
while ( v4 );
LABEL_7:
if ( !v6 )
goto LABEL_8;
putchar(10);
result = 1LL;
}
else
{
display_reg_all(a1);
LABEL_8:
result = 1LL;
}
return result;
}

original_code:
int execute_cmd_dr(ARCH arch, char** args) {
 int reg_index;
 int i = 0;
 ;
 if (!*args) {
  display_reg_all(arch);
  return 1;
 }
 while (*(args+i)) {
  ;
     reg_index = parse_register(*(args+i));
     if (reg_index == -1) {
      printf("\n");
      return -3;
  }
     display_reg(arch, reg_index);
     if ((i+1)%4 == 0)
      printf("\n");
     i++;
 }
 if (i%4 != 0)
  printf("\n");
 return 1;
}

canonical_original_code:
int execute_cmd_dr(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, char **args) {
 int reg_index;
 int i = 0;
 ;
 if (!*args) {
  display_reg_all(arch);
  return 1;
 }
 while (*(args+i)) {
  ;
     reg_index = parse_register(*(args+i));
     if (reg_index == -1) {
      printf("\n");
      return -3;
  }
     display_reg(arch, reg_index);
     if ((i+1)%4 == 0)
      printf("\n");
     i++;
 }
 if (i%4 != 0)
  printf("\n");
 return 1;
}


decompiled_code:
__int64 __fastcall execute_cmd_da(__int64 a1, _QWORD *a2)
{
_BYTE *v2; // rax
int v3; // er13
unsigned int v4; // eax
unsigned int v5; // esi
int v6; // ebp
__int64 v7; // r15
__int64 v8; // rsi
unsigned int v10; // [rsp+Ch] [rbp-4Ch]
unsigned int v11; // [rsp+14h] [rbp-44h] BYREF
int v12; // [rsp+18h] [rbp-40h] BYREF
unsigned int v13[15]; // [rsp+1Ch] [rbp-3Ch] BYREF

v2 = (_BYTE *)a2[1];
if ( !v2 )
return (unsigned int)-1;
if ( *v2 != 58 )
return (unsigned int)-1;
v3 = (unsigned __int8)v2[1];
if ( v2[1] )
return (unsigned int)-1;
if ( !(unsigned int)parse_addr(*a2, v13) )
return (unsigned int)-2;
v10 = _isoc99_sscanf(a2[2], "%d", &v12);
if ( v10 == 1 )
{
v4 = *(_DWORD *)(a1 + 160);
v5 = v13[0];
if ( v4 > v13[0] || v13[0] >= *(_DWORD *)(a1 + 164) + v4 )
{
print_error("address not in .text");
v10 = -1;
}
else if ( (v13[0] & 3) != 0 )
{
print_error("address does not start an instruction");
v10 = -1;
}
else if ( v12 > 0 )
{
LABEL_10:
v6 = 4 * v3;
v7 = 0LL;
display_reloc_symbol(a1, 4 * v3 + v5);
while ( (unsigned int)get_byte(a1, (unsigned int)(v7 + v6 + v13[0]), (char *)&v11 - v7 + 3) )
{
v8 = v6 + v13[0];
if ( v7 )
{
display_byte(a1, (unsigned int)(v7 + v8));
if ( v7 == 3 )
{
if ( (unsigned int)display_instruction(a1, v11, stdout) == -1 )
{
putchar(10);
print_error("no match, unknown instruction");
}
if ( v12 > ++v3 )
{
v5 = v13[0];
goto LABEL_10;
}
return v10;
}
}
else
{
printf("%08x: ", v8);
display_byte(a1, v6 + v13[0]);
}
++v7;
}
}
}
else
{
print_error("Invalid instructions number");
v10 = -1;
}
return v10;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, _QWORD *a2)
{
_BYTE *v2; // rax
int v3; // er13
unsigned int v4; // eax
unsigned int v5; // esi
int v6; // ebp
__int64 v7; // r15
__int64 v8; // rsi
unsigned int v10; // [rsp+Ch] [rbp-4Ch]
unsigned int v11; // [rsp+14h] [rbp-44h] BYREF
int v12; // [rsp+18h] [rbp-40h] BYREF
unsigned int v13[15]; // [rsp+1Ch] [rbp-3Ch] BYREF

v2 = (_BYTE *)a2[1];
if ( !v2 )
return (unsigned int)-1;
if ( *v2 != 58 )
return (unsigned int)-1;
v3 = (unsigned __int8)v2[1];
if ( v2[1] )
return (unsigned int)-1;
if ( !(unsigned int)parse_addr(*a2, v13) )
return (unsigned int)-2;
v10 = _isoc99_sscanf(a2[2], "%d", &v12);
if ( v10 == 1 )
{
v4 = *(_DWORD *)(a1 + 160);
v5 = v13[0];
if ( v4 > v13[0] || v13[0] >= *(_DWORD *)(a1 + 164) + v4 )
{
print_error("address not in .text");
v10 = -1;
}
else if ( (v13[0] & 3) != 0 )
{
print_error("address does not start an instruction");
v10 = -1;
}
else if ( v12 > 0 )
{
LABEL_10:
v6 = 4 * v3;
v7 = 0LL;
display_reloc_symbol(a1, 4 * v3 + v5);
while ( (unsigned int)get_byte(a1, (unsigned int)(v7 + v6 + v13[0]), (char *)&v11 - v7 + 3) )
{
v8 = v6 + v13[0];
if ( v7 )
{
display_byte(a1, (unsigned int)(v7 + v8));
if ( v7 == 3 )
{
if ( (unsigned int)display_instruction(a1, v11, stdout) == -1 )
{
putchar(10);
print_error("no match, unknown instruction");
}
if ( v12 > ++v3 )
{
v5 = v13[0];
goto LABEL_10;
}
return v10;
}
}
else
{
printf("%08x: ", v8);
display_byte(a1, v6 + v13[0]);
}
++v7;
}
}
}
else
{
print_error("Invalid instructions number");
v10 = -1;
}
return v10;
}

original_code:
int execute_cmd_da(ARCH arch, char** args)
{
 INSTR lgn_instr;
 int instr, i, j;
 uint addr;
 ;
 if (!*(args+1))
  return -1;
 if (strcmp(*(args+1), ":") != 0) {
  ;
  return -1;
 }
 if (!parse_addr(args[0], &addr))
  return -2;
 if (sscanf(args[2], "%d", &instr) != 1) {
  print_error("Invalid instructions number");
  return -1;
 }
 if (addr < arch->sections[0].start_addr ||
  addr >= arch->sections[0].size + arch->sections[0].start_addr) {
  print_error("address not in .text");
  return -1;
 }
 if (addr%4 != 0) {
  print_error("address does not start an instruction");
  return -1;
 }
 for (i = 0; i < instr; i++) {
  display_reloc_symbol(arch, addr + 4*i);
  for (j = 0; j < 4; j++) {
   if (get_byte(arch, addr + 4*i + j, &(lgn_instr.bytes[3-j])) == 0)
    return 1;
   if (j == 0)
    printf("%08x: ", addr + 4*i);
   display_byte(arch, addr + 4*i + j);
  }
  if (display_instruction(arch, lgn_instr.word, stdout) == -1) {
   printf("\n");
   print_error("no match, unknown instruction");
  }
 }
 return 1;
}

canonical_original_code:
int execute_cmd_da(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, char **args)
{
 union INSTR lgn_instr;
 int instr; int i; int j;
 unsigned int addr;
 ;
 if (!*(args+1))
  return -1;
 if (strcmp(*(args+1), ":") != 0) {
  ;
  return -1;
 }
 if (!parse_addr(args[0], &addr))
  return -2;
 if (sscanf(args[2], "%d", &instr) != 1) {
  print_error("Invalid instructions number");
  return -1;
 }
 if (addr < arch->sections[0].start_addr ||
  addr >= arch->sections[0].size + arch->sections[0].start_addr) {
  print_error("address not in .text");
  return -1;
 }
 if (addr%4 != 0) {
  print_error("address does not start an instruction");
  return -1;
 }
 for (i = 0; i < instr; i++) {
  display_reloc_symbol(arch, addr + 4*i);
  for (j = 0; j < 4; j++) {
   if (get_byte(arch, addr + 4*i + j, &(lgn_instr.bytes[3-j])) == 0)
    return 1;
   if (j == 0)
    printf("%08x: ", addr + 4*i);
   display_byte(arch, addr + 4*i + j);
  }
  if (display_instruction(arch, lgn_instr.word, stdout) == -1) {
   printf("\n");
   print_error("no match, unknown instruction");
  }
 }
 return 1;
}

variable_types: instr int

variable_types: j int

user_defined_types: union INSTR { unsigned int word; unsigned char bytes[4]; }


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

v2 = *(unsigned __int8 **)(a2 + 8);
if ( !*(_QWORD *)(a2 + 16) )
{
if ( v2 )
return 0xFFFFFFFFLL;
return display_one_addr();
}
if ( !v2 )
return display_one_addr();
v3 = *v2;
if ( v3 == 58 && !v2[1] )
return display_bytes_from_addr();
if ( v3 == 126 && !v2[1] )
return display_addr_to_addr();
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
unsigned __int8 *v2; // rax
int v3; // edx

v2 = *(unsigned __int8 **)(a2 + 8);
if ( !*(_QWORD *)(a2 + 16) )
{
if ( v2 )
return 0xFFFFFFFFLL;
return display_one_addr();
}
if ( !v2 )
return display_one_addr();
v3 = *v2;
if ( v3 == 58 && !v2[1] )
return display_bytes_from_addr();
if ( v3 == 126 && !v2[1] )
return display_addr_to_addr();
return 0xFFFFFFFFLL;
}

original_code:
int execute_cmd_dm(ARCH arch, char** args)
{
 if ((*(args+2) != ((void *)0)) && (*(args+1) != ((void *)0))) {
  if (strcmp(*(args+1), ":") == 0) {
   ;
   return display_bytes_from_addr(arch, args);
  }
  else if (strcmp(*(args+1), "~") == 0) {
   ;
   return display_addr_to_addr(arch, args);
  }
  else {
   return -1;
  }
 }
 else if (!(*(args+1))) {
  ;
  return display_one_addr(arch, args);
 }
 else {
  return -1;
 }
}

canonical_original_code:
int execute_cmd_dm(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, char **args)
{
 if ((*(args+2) != ((void *)0)) && (*(args+1) != ((void *)0))) {
  if (strcmp(*(args+1), ":") == 0) {
   ;
   return display_bytes_from_addr(arch, args);
  }
  else if (strcmp(*(args+1), "~") == 0) {
   ;
   return display_addr_to_addr(arch, args);
  }
  else {
   return -1;
  }
 }
 else if (!(*(args+1))) {
  ;
  return display_one_addr(arch, args);
 }
 else {
  return -1;
 }
}


decompiled_code:
__int64 execute_cmd_di()
{
display_desc_array();
return 1LL;
}

canonical_decompiled_code:
__int64 func8()
{
display_desc_array();
return 1LL;
}

original_code:
int execute_cmd_di()
{
 display_desc_array();
 return 1;
}


decompiled_code:
__int64 __fastcall execute_cmd_ds(__int64 a1)
{
const char **v1; // rbx
const char *v2; // rsi

v1 = (const char **)(a1 + 144);
do
{
v2 = *v1;
v1 += 3;
printf("Section: %s\n", v2);
printf("Start address: %0x\n", *((unsigned int *)v1 - 2));
printf("Size: %d\n", *((unsigned int *)v1 - 1));
putchar(10);
}
while ( v1 != (const char **)(a1 + 216) );
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
const char **v1; // rbx
const char *v2; // rsi

v1 = (const char **)(a1 + 144);
do
{
v2 = *v1;
v1 += 3;
printf("Section: %s\n", v2);
printf("Start address: %0x\n", *((unsigned int *)v1 - 2));
printf("Size: %d\n", *((unsigned int *)v1 - 1));
putchar(10);
}
while ( v1 != (const char **)(a1 + 216) );
return 1LL;
}

original_code:
int execute_cmd_ds(ARCH arch)
{
 for (int i = 0; i < 3; i++) {
  printf("Section: %s\n", arch->sections[i].name);
  printf("Start address: %0x\n", arch->sections[i].start_addr);
  printf("Size: %d\n", arch->sections[i].size);
  printf("\n");
 }
 return 1;
}

canonical_original_code:
int execute_cmd_ds(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch)
{
 for (int i = 0; i < 3; i++) {
  printf("Section: %s\n", arch->sections[i].name);
  printf("Start address: %0x\n", arch->sections[i].start_addr);
  printf("Size: %d\n", arch->sections[i].size);
  printf("\n");
 }
 return 1;
}


decompiled_code:
__int64 __fastcall execute_cmd_run(_DWORD *a1, _QWORD *a2)
{
unsigned int v3[3]; // [rsp+0h] [rbp-Ch] BYREF

if ( !a1[60] )
return 4294967255LL;
if ( *a2 )
{
if ( !(unsigned int)parse_addr(*a2, v3) )
return 4294967294LL;
if ( a1[40] + a1[41] <= v3[0] )
{
print_error("address not in text");
return 4294967294LL;
}
if ( (v3[0] & 3) != 0 )
{
print_error("address does not start an instruction");
return 4294967294LL;
}
set_register(a1, 35LL);
}
run(a1, 0LL);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func10(_DWORD *a1, _QWORD *a2)
{
unsigned int v3[3]; // [rsp+0h] [rbp-Ch] BYREF

if ( !a1[60] )
return 4294967255LL;
if ( *a2 )
{
if ( !(unsigned int)parse_addr(*a2, v3) )
return 4294967294LL;
if ( a1[40] + a1[41] <= v3[0] )
{
print_error("address not in text");
return 4294967294LL;
}
if ( (v3[0] & 3) != 0 )
{
print_error("address does not start an instruction");
return 4294967294LL;
}
set_register(a1, 35LL);
}
run(a1, 0LL);
return 1LL;
}

original_code:
int execute_cmd_run(ARCH arch, char** args)
{
 uint32_t addr;
 ;
 if (arch->state == NOT_LOADED)
  return -41;
 if (!(*args)) {
  run(arch, 0);
  return 1;
 }
 if (!parse_addr(args[0], &addr))
  return -2;
 if (addr >= arch->sections[0].start_addr + arch->sections[0].size) {
  print_error("address not in text");
  return -2;
 }
 if (addr%4 != 0) {
  print_error("address does not start an instruction");
  return -2;
 }
 set_register(arch, 35, addr);
 run(arch, 0);
 return 1;
}

canonical_original_code:
int execute_cmd_run(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, char **args)
{
 unsigned int addr;
 ;
 if (arch->state == NOT_LOADED)
  return -41;
 if (!(*args)) {
  run(arch, 0);
  return 1;
 }
 if (!parse_addr(args[0], &addr))
  return -2;
 if (addr >= arch->sections[0].start_addr + arch->sections[0].size) {
  print_error("address not in text");
  return -2;
 }
 if (addr%4 != 0) {
  print_error("address does not start an instruction");
  return -2;
 }
 set_register(arch, 35, addr);
 run(arch, 0);
 return 1;
}


decompiled_code:
__int64 __fastcall execute_cmd_s(__int64 a1)
{
int v1; // eax
int v2; // eax
__int64 result; // rax

v1 = *(_DWORD *)(a1 + 240);
if ( !v1 )
return 4294967255LL;
if ( v1 == 2 )
{
add_breakpoint(a1, 4LL);
}
else
{
v2 = get_register(a1, 35LL);
add_breakpoint(a1, (unsigned int)(v2 + 4));
}
run(a1, 0LL);
result = 1LL;
*(_DWORD *)(a1 + 240) = 1;
return result;
}

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

v1 = *(_DWORD *)(a1 + 240);
if ( !v1 )
return 4294967255LL;
if ( v1 == 2 )
{
add_breakpoint(a1, 4LL);
}
else
{
v2 = get_register(a1, 35LL);
add_breakpoint(a1, (unsigned int)(v2 + 4));
}
run(a1, 0LL);
result = 1LL;
*(_DWORD *)(a1 + 240) = 1;
return result;
}

original_code:
int execute_cmd_s(ARCH arch)
{
 if (arch->state == NOT_LOADED)
  return -41;
 if (arch->state == FINISHED)
  add_breakpoint(arch, 4);
 else
  add_breakpoint(arch, get_register(arch, 35) + 4);
 run(arch, 0);
 arch->state = PAUSED;
 return 1;
}

canonical_original_code:
int execute_cmd_s(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch)
{
 if (arch->state == NOT_LOADED)
  return -41;
 if (arch->state == FINISHED)
  add_breakpoint(arch, 4);
 else
  add_breakpoint(arch, get_register(arch, 35) + 4);
 run(arch, 0);
 arch->state = PAUSED;
 return 1;
}


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

if ( !*(_DWORD *)(a1 + 240) )
return 4294967255LL;
run(a1, 1LL);
result = 1LL;
*(_DWORD *)(a1 + 240) = 1;
return result;
}

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

if ( !*(_DWORD *)(a1 + 240) )
return 4294967255LL;
run(a1, 1LL);
result = 1LL;
*(_DWORD *)(a1 + 240) = 1;
return result;
}

original_code:
int execute_cmd_si(ARCH arch)
{
 if (arch->state == NOT_LOADED)
  return -41;
 run(arch, 1);
 arch->state = PAUSED;
 return 1;
}

canonical_original_code:
int execute_cmd_si(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch)
{
 if (arch->state == NOT_LOADED)
  return -41;
 run(arch, 1);
 arch->state = PAUSED;
 return 1;
}


decompiled_code:
__int64 __fastcall execute_cmd_bp(__int64 a1, _QWORD *a2)
{
__int64 result; // rax
unsigned int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( !(unsigned int)parse_addr(*a2, v3) )
return 4294967294LL;
if ( *(_DWORD *)(a1 + 160) + *(_DWORD *)(a1 + 164) <= v3[0] )
{
print_error("address not in text");
result = 4294967294LL;
}
else if ( (v3[0] & 3) != 0 )
{
print_error("address does not start an instruction");
result = 4294967294LL;
}
else if ( (unsigned int)get_breakpoint_id(a1) == -1 )
{
add_breakpoint(a1, v3[0]);
fprintf(stdout, "bp at 0x%08x added\n", v3[0]);
result = 1LL;
}
else
{
print_error("breakpoint already exists");
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, _QWORD *a2)
{
__int64 result; // rax
unsigned int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( !(unsigned int)parse_addr(*a2, v3) )
return 4294967294LL;
if ( *(_DWORD *)(a1 + 160) + *(_DWORD *)(a1 + 164) <= v3[0] )
{
print_error("address not in text");
result = 4294967294LL;
}
else if ( (v3[0] & 3) != 0 )
{
print_error("address does not start an instruction");
result = 4294967294LL;
}
else if ( (unsigned int)get_breakpoint_id(a1) == -1 )
{
add_breakpoint(a1, v3[0]);
fprintf(stdout, "bp at 0x%08x added\n", v3[0]);
result = 1LL;
}
else
{
print_error("breakpoint already exists");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int execute_cmd_bp(ARCH arch, char** args)
{
 uint32_t addr;
 ;
 if (!parse_addr(args[0], &addr))
  return -2;
 if (addr >= arch->sections[0].start_addr + arch->sections[0].size) {
  print_error("address not in text");
  return -2;
 }
 if (addr%4 != 0) {
  print_error("address does not start an instruction");
  return -2;
 }
 if (get_breakpoint_id(arch, addr) != -1) {
  print_error("breakpoint already exists");
  return -1;
 }
 add_breakpoint(arch, addr);
 fprintf(stdout, "bp at 0x%08x added\n", addr);
 return 1;
}

canonical_original_code:
int execute_cmd_bp(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, char **args)
{
 unsigned int addr;
 ;
 if (!parse_addr(args[0], &addr))
  return -2;
 if (addr >= arch->sections[0].start_addr + arch->sections[0].size) {
  print_error("address not in text");
  return -2;
 }
 if (addr%4 != 0) {
  print_error("address does not start an instruction");
  return -2;
 }
 if (get_breakpoint_id(arch, addr) != -1) {
  print_error("breakpoint already exists");
  return -1;
 }
 add_breakpoint(arch, addr);
 fprintf(stdout, "bp at 0x%08x added\n", addr);
 return 1;
}


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

if ( !(unsigned int)parse_addr(*a2, v4) )
return 4294967294LL;
if ( *(_DWORD *)(a1 + 160) + *(_DWORD *)(a1 + 164) < v4[0] )
{
print_error("address not in text");
result = 4294967294LL;
}
else if ( (v4[0] & 3) != 0 )
{
print_error("address does not start an instruction");
result = 4294967294LL;
}
else
{
v2 = get_breakpoint_id(a1);
if ( v2 == -1 )
{
print_error("breakpoint does not exist");
result = 0xFFFFFFFFLL;
}
else
{
del_breakpoint_by_id(a1, v2);
fprintf(stdout, "bp at 0x%08x deleted\n", v4[0]);
result = 1LL;
}
}
return result;
}

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

if ( !(unsigned int)parse_addr(*a2, v4) )
return 4294967294LL;
if ( *(_DWORD *)(a1 + 160) + *(_DWORD *)(a1 + 164) < v4[0] )
{
print_error("address not in text");
result = 4294967294LL;
}
else if ( (v4[0] & 3) != 0 )
{
print_error("address does not start an instruction");
result = 4294967294LL;
}
else
{
v2 = get_breakpoint_id(a1);
if ( v2 == -1 )
{
print_error("breakpoint does not exist");
result = 0xFFFFFFFFLL;
}
else
{
del_breakpoint_by_id(a1, v2);
fprintf(stdout, "bp at 0x%08x deleted\n", v4[0]);
result = 1LL;
}
}
return result;
}

original_code:
int execute_cmd_er(ARCH arch, char** args)
{
 uint32_t addr;
 int id;
 ;
 if (!parse_addr(args[0], &addr))
  return -2;
 if (addr > (arch->sections[0].start_addr + arch->sections[0].size)) {
  print_error("address not in text");
  return -2;
 }
 if ((addr%4) != 0) {
  print_error("address does not start an instruction");
  return -2;
 }
 if ((id = get_breakpoint_id(arch, addr)) == -1) {
  print_error("breakpoint does not exist");
  return -1;
 }
 del_breakpoint_by_id(arch, id);
 fprintf(stdout, "bp at 0x%08x deleted\n", addr);
 return 1;
}

canonical_original_code:
int execute_cmd_er(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, char **args)
{
 unsigned int addr;
 int id;
 ;
 if (!parse_addr(args[0], &addr))
  return -2;
 if (addr > (arch->sections[0].start_addr + arch->sections[0].size)) {
  print_error("address not in text");
  return -2;
 }
 if ((addr%4) != 0) {
  print_error("address does not start an instruction");
  return -2;
 }
 if ((id = get_breakpoint_id(arch, addr)) == -1) {
  print_error("breakpoint does not exist");
  return -1;
 }
 del_breakpoint_by_id(arch, id);
 fprintf(stdout, "bp at 0x%08x deleted\n", addr);
 return 1;
}

variable_types: id int


decompiled_code:
__int64 __fastcall execute_cmd_db(__int64 a1)
{
fwrite("breakpoints\n", 1uLL, 0xCuLL, stdout);
if ( !(unsigned int)is_list_empty(*(_QWORD *)(a1 + 248)) )
display_breakpoints(a1);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1)
{
fwrite("breakpoints\n", 1uLL, 0xCuLL, stdout);
if ( !(unsigned int)is_list_empty(*(_QWORD *)(a1 + 248)) )
display_breakpoints(a1);
return 1LL;
}

original_code:
int execute_cmd_db(ARCH arch)
{
 fprintf(stdout, "breakpoints\n");
 if (is_list_empty(arch->breakpoints))
  return 1;
 display_breakpoints(arch);
 return 1;
}

canonical_original_code:
int execute_cmd_db(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch)
{
 fprintf(stdout, "breakpoints\n");
 if (is_list_empty(arch->breakpoints))
  return 1;
 display_breakpoints(arch);
 return 1;
}


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

if ( *a2 )
{
v2 = find_cmd();
if ( v2 )
{
print_help(v2);
result = 1LL;
}
else
{
result = 4294967292LL;
}
}
else
{
print_help_all();
result = 1LL;
}
return result;
}

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

if ( *a2 )
{
v2 = find_cmd();
if ( v2 )
{
print_help(v2);
result = 1LL;
}
else
{
result = 4294967292LL;
}
}
else
{
print_help_all();
result = 1LL;
}
return result;
}

original_code:
int execute_cmd_help(ARCH arch, char** args)
{
 (void)(arch);
 struct command* command;
 if (!(*args)) {
  print_help_all();
  return 1;
 }
 if (!(command = find_cmd(args[0])))
  return -4;
 print_help(command);
 return 1;
}

canonical_original_code:
int execute_cmd_help(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, char **args)
{
 (void)(arch);
 struct command *command;
 if (!(*args)) {
  print_help_all();
  return 1;
 }
 if (!(command = find_cmd(args[0])))
  return -4;
 print_help(command);
 return 1;
}

variable_types: struct command { char *command; int (*ptr)(); char *usage; char *help; int min; } *


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

result = del_elt_n(*(_QWORD *)(a1 + 248));
*(_QWORD *)(a1 + 248) = result;
return result;
}

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

result = del_elt_n(*(_QWORD *)(a1 + 248));
*(_QWORD *)(a1 + 248) = result;
return result;
}

original_code:
void del_breakpoint_by_id(ARCH arch, int id)
{
 arch->breakpoints = (list_t) del_elt_n(arch->breakpoints, id);
}

canonical_original_code:
void del_breakpoint_by_id(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, int id)
{
 arch->breakpoints = (struct list_elt *) del_elt_n(arch->breakpoints, id);
}

variable_types: struct { unsigned int registers[36]; struct section_t { char *name; unsigned char *data; unsigned int start_addr; unsigned int size; } sections[4]; enum state_t { NOT_LOADED=0, PAUSED=1, FINISHED=2 } state; struct list_elt { void *val; struct list_elt *next; } *breakpoints; struct Elf32_Sym { unsigned int st_name; unsigned int st_value; unsigned int st_size; unsigned char st_info; unsigned char st_other; unsigned short st_shndx; } *symbols; unsigned int symbols_num; char *symbols_names; } *


decompiled_code:
__int64 __fastcall get_breakpoint_id(__int64 a1, int a2)
{
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = a2;
return find_elt_int(v3, *(_QWORD *)(a1 + 248));
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2)
{
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = a2;
return find_elt_int(v3, *(_QWORD *)(a1 + 248));
}

original_code:
int get_breakpoint_id(ARCH arch, uint address)
{
 return find_elt_int(&address, arch->breakpoints);
}

canonical_original_code:
int get_breakpoint_id(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, unsigned int address)
{
 return find_elt_int(&address, arch->breakpoints);
}

variable_types:
address
unsigned int


decompiled_code:
__int64 __fastcall add_breakpoint(__int64 a1, int a2)
{
__int64 result; // rax
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = a2;
result = get_breakpoint_id(a1, a2);
if ( (_DWORD)result == -1 )
{
result = add_sort(v3, *(_QWORD *)(a1 + 248), 4LL);
*(_QWORD *)(a1 + 248) = result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2)
{
__int64 result; // rax
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

v3[0] = a2;
result = func1(a1, a2);
if ( (_DWORD)result == -1 )
{
result = add_sort(v3, *(_QWORD *)(a1 + 248), 4LL);
*(_QWORD *)(a1 + 248) = result;
}
return result;
}

original_code:
void add_breakpoint(ARCH arch, uint address)
{
 if (get_breakpoint_id(arch, address) == -1)
  arch->breakpoints = (list_t) add_sort(&address, arch->breakpoints, sizeof(uint));
}

canonical_original_code:
void add_breakpoint(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, unsigned int address)
{
 if (get_breakpoint_id(arch, address) == -1)
  arch->breakpoints = (struct list_elt *) add_sort(&address, arch->breakpoints, sizeof(uint));
}


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

result = get_breakpoint_id(a1, a2);
if ( (_DWORD)result != -1 )
result = del_breakpoint_by_id(a1);
return result;
}

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

result = func1(a1, a2);
if ( (_DWORD)result != -1 )
result = func0(a1);
return result;
}

original_code:
void del_breakpoint_by_addr(ARCH arch, uint address)
{
 int id;
 if ((id = get_breakpoint_id(arch, address)) != -1)
  del_breakpoint_by_id(arch, id);
}

canonical_original_code:
void del_breakpoint_by_addr(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, unsigned int address)
{
 int id;
 if ((id = get_breakpoint_id(arch, address)) != -1)
  del_breakpoint_by_id(arch, id);
}


decompiled_code:
void __fastcall reset_breakpoints(__int64 a1)
{
*(_QWORD *)(a1 + 248) = 0LL;
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1)
{
*(_QWORD *)(a1 + 248) = 0LL;
}

original_code:
void reset_breakpoints(ARCH arch)
{
 arch->breakpoints = (list_t) ((void *)0);
}

canonical_original_code:
void reset_breakpoints(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch)
{
 arch->breakpoints = (list_t) ((void *)0);
}


decompiled_code:
__int64 __fastcall get_section_end(__int64 a1, int a2)
{
return (unsigned int)(*(_DWORD *)(a1 + 24LL * a2 + 164) + *(_DWORD *)(a1 + 24LL * a2 + 160));
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, int a2)
{
return (unsigned int)(*(_DWORD *)(a1 + 24LL * a2 + 164) + *(_DWORD *)(a1 + 24LL * a2 + 160));
}

original_code:
uint get_section_end(ARCH arch, int section_id)
{
 return arch->sections[section_id].start_addr + arch->sections[section_id].size;
}

canonical_original_code:
unsigned int get_section_end(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, int section_id)
{
 return arch->sections[section_id].start_addr + arch->sections[section_id].size;
}


decompiled_code:
void __fastcall set_register(__int64 a1, int a2, int a3)
{
*(_DWORD *)(a1 + 4LL * a2) = a3;
}

canonical_decompiled_code:
void __fastcall func6(__int64 a1, int a2, int a3)
{
*(_DWORD *)(a1 + 4LL * a2) = a3;
}

original_code:
void set_register(ARCH arch, int index, uint value)
{
 arch->registers[index] = value;
}

canonical_original_code:
void set_register(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, int index, unsigned int value)
{
 arch->registers[index] = value;
}

variable_types: index int

variable_types:
value
unsigned int


decompiled_code:
void __fastcall reset_register(__int64 a1, int a2)
{
set_register(a1, a2, 0);
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1, int a2)
{
func6(a1, a2, 0);
}

original_code:
void reset_register(ARCH arch, int index)
{
 set_register(arch, index, 0);
}

canonical_original_code:
void reset_register(struct { unsigned int registers[36]; struct section_t sections[4]; enum state_t state; struct list_elt *breakpoints; struct Elf32_Sym *symbols; unsigned int symbols_num; char *symbols_names; } *arch, int index)
{
 set_register(arch, index, 0);
}