decompiled_code:
int __fastcall wort_hinzufuegen(char *s2, int a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rbp
__int64 v4; // rbx

v2 = malloc(0x20uLL);
if ( !v2 )
{
fwrite("Nicht genug Speicher verfuegbar.\n", 1uLL, 0x21uLL, stderr);
exit(1);
}
v3 = v2;
*(_DWORD *)v2 = a2;
v2[1] = s2;
v2[2] = 0LL;
v2[3] = 0LL;
v4 = woerter;
if ( woerter )
{
while ( 1 )
{
LODWORD(v2) = strncmp(*(const char **)(v4 + 8), s2, 0x100uLL);
if ( (int)v2 < 0 )
{
v2 = *(_QWORD **)(v4 + 16);
if ( !v2 )
{
*(_QWORD *)(v4 + 16) = v3;
return (int)v2;
}
}
else
{
if ( (int)v2 <= 0 )
return (int)v2;
v2 = *(_QWORD **)(v4 + 24);
if ( !v2 )
{
*(_QWORD *)(v4 + 24) = v3;
return (int)v2;
}
}
v4 = (__int64)v2;
}
}
woerter = (__int64)v2;
return (int)v2;
}

canonical_decompiled_code:
int __fastcall func6(char *s2, int a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rbp
__int64 v4; // rbx

v2 = malloc(0x20uLL);
if ( !v2 )
{
fwrite("Nicht genug Speicher verfuegbar.\n", 1uLL, 0x21uLL, stderr);
exit(1);
}
v3 = v2;
*(_DWORD *)v2 = a2;
v2[1] = s2;
v2[2] = 0LL;
v2[3] = 0LL;
v4 = woerter;
if ( woerter )
{
while ( 1 )
{
LODWORD(v2) = strncmp(*(const char **)(v4 + 8), s2, 0x100uLL);
if ( (int)v2 < 0 )
{
v2 = *(_QWORD **)(v4 + 16);
if ( !v2 )
{
*(_QWORD *)(v4 + 16) = v3;
return (int)v2;
}
}
else
{
if ( (int)v2 <= 0 )
return (int)v2;
v2 = *(_QWORD **)(v4 + 24);
if ( !v2 )
{
*(_QWORD *)(v4 + 24) = v3;
return (int)v2;
}
}
v4 = (__int64)v2;
}
}
woerter = (__int64)v2;
return (int)v2;
}

original_code:
void wort_hinzufuegen(char *id, int idx)
{
 struct alphabaum *tmp, *tmp2;
 tmp = (struct alphabaum *) malloc(sizeof(struct alphabaum));
 if(tmp == ((void *)0))
 {
  fprintf(stderr,"Nicht genug Speicher verfuegbar.\n");
  exit(1);
 }
 tmp->idx = idx;
 tmp->id = id;
 tmp->links = ((void *)0);
 tmp->rechts = ((void *)0);
 if(woerter == ((void *)0))
 {
  woerter = tmp;
  return ;
 }
 tmp2 = woerter;
 while(tmp2 != ((void *)0))
 {
  if(strncmp(tmp2->id,id,256) < 0)
  {
   if(tmp2->links != ((void *)0))
   {
    tmp2 = tmp2->links;
    continue;
   }
   else
   {
    tmp2->links = tmp;
    return ;
   }
  }
  else if(strncmp(tmp2->id,id,256) > 0)
  {
   if(tmp2->rechts != ((void *)0))
   {
    tmp2 = tmp2->rechts;
    continue;
   }
   else
   {
    tmp2->rechts = tmp;
    return ;
   }
  }
  else
   return ;
 }
}

canonical_original_code:
void wort_hinzufuegen(char *id, int idx)
{
 struct alphabaum *tmp; struct alphabaum *tmp2;
 tmp = (struct alphabaum *) malloc(sizeof(struct alphabaum));
 if(tmp == ((void *)0))
 {
  fprintf(stderr,"Nicht genug Speicher verfuegbar.\n");
  exit(1);
 }
 tmp->idx = idx;
 tmp->id = id;
 tmp->links = ((void *)0);
 tmp->rechts = ((void *)0);
 if(woerter == ((void *)0))
 {
  woerter = tmp;
  return ;
 }
 tmp2 = woerter;
 while(tmp2 != ((void *)0))
 {
  if(strncmp(tmp2->id,id,256) < 0)
  {
   if(tmp2->links != ((void *)0))
   {
    tmp2 = tmp2->links;
    continue;
   }
   else
   {
    tmp2->links = tmp;
    return ;
   }
  }
  else if(strncmp(tmp2->id,id,256) > 0)
  {
   if(tmp2->rechts != ((void *)0))
   {
    tmp2 = tmp2->rechts;
    continue;
   }
   else
   {
    tmp2->rechts = tmp;
    return ;
   }
  }
  else
   return ;
 }
}

variable_types: idx int

user_defined_types: struct alphabaum { int idx; char *id; struct alphabaum *links; struct alphabaum *rechts; }


decompiled_code:
void setze_alphabet()
{
__int64 i; // rbx
int v1; // er12
char *v2; // rbp

zeicheneingabe = 1;
for ( i = 0LL; i != 200; ++i )
{
v1 = i;
v2 = (char *)*((_QWORD *)&Alphabet + i);
if ( !v2 )
break;
if ( zeicheneingabe == 1 && strlen(*((const char **)&Alphabet + i)) > 1 )
zeicheneingabe = 0;
wort_hinzufuegen(v2, i);
v1 = i + 1;
}
Anzahl_Zeichen = v1;
}

canonical_decompiled_code:
void func7()
{
__int64 i; // rbx
int v1; // er12
char *v2; // rbp

zeicheneingabe = 1;
for ( i = 0LL; i != 200; ++i )
{
v1 = i;
v2 = (char *)*((_QWORD *)&Alphabet + i);
if ( !v2 )
break;
if ( zeicheneingabe == 1 && strlen(*((const char **)&Alphabet + i)) > 1 )
zeicheneingabe = 0;
func6(v2, i);
v1 = i + 1;
}
Anzahl_Zeichen = v1;
}

original_code:
void setze_alphabet()
{
 int i;
 zeicheneingabe = 1;
 for(i = 0; i < 200 && Alphabet[i] != ((void *)0); i++)
 {
  if(zeicheneingabe == 1 && strlen(Alphabet[i]) > 1)
   zeicheneingabe = 0;
  wort_hinzufuegen(Alphabet[i], i);
 }
 Anzahl_Zeichen = i;
}

variable_types: i int

return_type: void


Automat

decompiled_code:
void __noreturn Automat()
{
__int64 v0; // rbx
char *v1; // rdi
int v2; // eax
__int64 v3; // rax

while ( 1 )
{
v1 = lesen_eingabe();
Zeichen = (__int64)v1;
if ( !v1 )
break;
v2 = eingabe_ok(v1);
if ( v2 == -1 )
Fehler(akt_Zustand, (const char *)Zeichen);
v0 = 16LL * v2;
(*(void (__fastcall **)(_QWORD, __int64))(*(_QWORD *)(Tabelle_intern + 8LL * akt_Zustand) + v0 + 8))(
(unsigned int)akt_Zustand,
Zeichen);
akt_Zustand = *(_DWORD *)(*(_QWORD *)(Tabelle_intern + 8LL * akt_Zustand) + v0);
}
if ( Anzahl_Endzustaende > 0 )
{
v3 = 0LL;
do
{
if ( *((_DWORD *)&Endzustaende + v3) == akt_Zustand )
{
ok(akt_Zustand);
exit(0);
}
++v3;
}
while ( v3 != Anzahl_Endzustaende );
}
fwrite("Endzustand nicht erreicht!\n", 1uLL, 0x1BuLL, stderr);
Fehler(akt_Zustand, (const char *)Zeichen);
}

canonical_decompiled_code:
void __noreturn func8()
{
__int64 v0; // rbx
char *v1; // rdi
int v2; // eax
__int64 v3; // rax

while ( 1 )
{
v1 = func4();
Zeichen = (__int64)v1;
if ( !v1 )
break;
v2 = func5(v1);
if ( v2 == -1 )
func2(akt_Zustand, (const char *)Zeichen);
v0 = 16LL * v2;
(*(void (__fastcall **)(_QWORD, __int64))(*(_QWORD *)(Tabelle_intern + 8LL * akt_Zustand) + v0 + 8))(
(unsigned int)akt_Zustand,
Zeichen);
akt_Zustand = *(_DWORD *)(*(_QWORD *)(Tabelle_intern + 8LL * akt_Zustand) + v0);
}
if ( Anzahl_Endzustaende > 0 )
{
v3 = 0LL;
do
{
if ( *((_DWORD *)&Endzustaende + v3) == akt_Zustand )
{
func3(akt_Zustand);
exit(0);
}
++v3;
}
while ( v3 != Anzahl_Endzustaende );
}
fwrite("Endzustand nicht erreicht!\n", 1uLL, 0x1BuLL, stderr);
func2(akt_Zustand, (const char *)Zeichen);
}

original_code:
void Automat()
{
 int i, wort;
 while((Zeichen = lesen_eingabe()) != ((void *)0))
 {
  i = eingabe_ok(Zeichen);
  if(i == -1)
   Fehler(akt_Zustand, Zeichen);
  else
   wort = i;
   Tabelle_intern[akt_Zustand][wort].Funktion(akt_Zustand, Zeichen);
  akt_Zustand = Tabelle_intern[akt_Zustand][wort].Folgezustand;
 }
 for(i = 0; i < Anzahl_Endzustaende; i++)
 {
  if(akt_Zustand == Endzustaende[i])
  {
   ok(akt_Zustand);
   exit(0);
  }
 }
 fprintf(stderr,"Endzustand nicht erreicht!\n");
 Fehler(akt_Zustand, Zeichen);
}

canonical_original_code:
void Automat()
{
 int i; int wort;
 while((Zeichen = lesen_eingabe()) != ((void *)0))
 {
  i = eingabe_ok(Zeichen);
  if(i == -1)
   Fehler(akt_Zustand, Zeichen);
  else
   wort = i;
   Tabelle_intern[akt_Zustand][wort].Funktion(akt_Zustand, Zeichen);
  akt_Zustand = Tabelle_intern[akt_Zustand][wort].Folgezustand;
 }
 for(i = 0; i < Anzahl_Endzustaende; i++)
 {
  if(akt_Zustand == Endzustaende[i])
  {
   ok(akt_Zustand);
   exit(0);
  }
 }
 fprintf(stderr,"Endzustand nicht erreicht!\n");
 Fehler(akt_Zustand, Zeichen);
}

variable_types: wort int


main

canonical_name: main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rdx
__int64 i; // r9
int v5; // eax
__int64 j; // rdx

TabelleP = (__int64)&Tabelle;
printf("Initialisiere...");
setze_alphabet();
malloc_Tabelle(Anzahl_Zeichen, Anzahl_Zustaende);
v3 = (unsigned int)Anzahl_Zustaende;
for ( i = 0LL; Anzahl_Zustaende > (int)i; ++i )
{
v5 = Anzahl_Zeichen;
for ( j = 0LL; Anzahl_Zeichen > (int)j; ++j )
{
*(__m128i *)(*(_QWORD *)(Tabelle_intern + 8 * i) + 16 * j) = _mm_loadu_si128((const __m128i *)(TabelleP + 16LL * ((int)j + (int)i * v5)));
v5 = Anzahl_Zeichen;
}
v3 = (unsigned int)Anzahl_Zustaende;
}
akt_Zustand = Startzustand;
printf(
aFertigZeichenI,
(unsigned int)Anzahl_Zeichen,
v3,
(unsigned int)Anzahl_Endzustaende,
(unsigned int)Startzustand,
i);
if ( zeicheneingabe == 1 )
puts(aBitteGew);
else
puts(s);
Automat();
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rdx
__int64 i; // r9
int v5; // eax
__int64 j; // rdx

TabelleP = (__int64)&Tabelle;
printf("Initialisiere...");
func7();
func0(Anzahl_Zeichen, Anzahl_Zustaende);
v3 = (unsigned int)Anzahl_Zustaende;
for ( i = 0LL; Anzahl_Zustaende > (int)i; ++i )
{
v5 = Anzahl_Zeichen;
for ( j = 0LL; Anzahl_Zeichen > (int)j; ++j )
{
*(__m128i *)(*(_QWORD *)(Tabelle_intern + 8 * i) + 16 * j) = _mm_loadu_si128((const __m128i *)(TabelleP + 16LL * ((int)j + (int)i * v5)));
v5 = Anzahl_Zeichen;
}
v3 = (unsigned int)Anzahl_Zustaende;
}
akt_Zustand = Startzustand;
printf(
aFertigZeichenI,
(unsigned int)Anzahl_Zeichen,
v3,
(unsigned int)Anzahl_Endzustaende,
(unsigned int)Startzustand,
i);
if ( zeicheneingabe == 1 )
puts(aBitteGew);
else
puts(s);
func8();
}

original_code:
int main(int argc, char* argv[])
{
 int i,j;
 TabelleP=&Tabelle[0];
 printf("Initialisiere...");
 setze_alphabet();
 malloc_Tabelle(Anzahl_Zeichen, Anzahl_Zustaende);
 for(i = 0; i < Anzahl_Zustaende; i++)
  for(j = 0; j < Anzahl_Zeichen; j++)
   Tabelle_intern[i][j] = TabelleP[i*(Anzahl_Zeichen)+j];
 akt_Zustand = Startzustand;
 printf("fertig.\n\nZeichen: %i Zustände: %i Endzustände: %i Startzustand: %i\n\n", Anzahl_Zeichen, Anzahl_Zustaende, Anzahl_Endzustaende, Startzustand);
 if(zeicheneingabe == 1)
  printf("Bitte gewünschte Zeichenkette eingeben (Beenden mit \\n):\n");
 else
  printf("Bitte gewünschte Woerter eingeben (Beenden mit Strg + d):\n");
 Automat();
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 int i; int j;
 TabelleP=&Tabelle[0];
 printf("Initialisiere...");
 setze_alphabet();
 malloc_Tabelle(Anzahl_Zeichen, Anzahl_Zustaende);
 for(i = 0; i < Anzahl_Zustaende; i++)
  for(j = 0; j < Anzahl_Zeichen; j++)
   Tabelle_intern[i][j] = TabelleP[i*(Anzahl_Zeichen)+j];
 akt_Zustand = Startzustand;
 printf("fertig.\n\nZeichen: %i Zustände: %i Endzustände: %i Startzustand: %i\n\n", Anzahl_Zeichen, Anzahl_Zustaende, Anzahl_Endzustaende, Startzustand);
 if(zeicheneingabe == 1)
  printf("Bitte gewünschte Zeichenkette eingeben (Beenden mit \\n):\n");
 else
  printf("Bitte gewünschte Woerter eingeben (Beenden mit Strg + d):\n");
 Automat();
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: j int

return_type: int


decompiled_code:
__int64 __fastcall has_end_property(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rdx

if ( !a1 )
return 0LL;
result = 0LL;
if ( *(_DWORD *)a1 == 3 )
{
result = *(_QWORD *)(a1 + 520);
if ( result )
{
if ( *(_DWORD *)result == 6 )
{
while ( 1 )
{
v2 = *(_QWORD *)(result + 528);
if ( *(_DWORD *)v2 == 5 && !strcmp((const char *)(v2 + 4), "end") && !strcmp((const char *)(v2 + 260), "yes") )
break;
result = *(_QWORD *)(result + 520);
if ( !result )
return result;
}
result = *(_QWORD *)(result + 528);
}
else
{
result = 0LL;
}
}
}
return result;
}

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

if ( !a1 )
return 0LL;
result = 0LL;
if ( *(_DWORD *)a1 == 3 )
{
result = *(_QWORD *)(a1 + 520);
if ( result )
{
if ( *(_DWORD *)result == 6 )
{
while ( 1 )
{
v2 = *(_QWORD *)(result + 528);
if ( *(_DWORD *)v2 == 5 && !strcmp((const char *)(v2 + 4), "end") && !strcmp((const char *)(v2 + 260), "yes") )
break;
result = *(_QWORD *)(result + 520);
if ( !result )
return result;
}
result = *(_QWORD *)(result + 528);
}
else
{
result = 0LL;
}
}
}
return result;
}

original_code:
t_graphnode* has_end_property( t_graphnode *node)
{
 t_graphnode *rechter_ast;
 t_graphnode *h;
 if( node == ((void *)0)) return ((void *)0);
 rechter_ast = node;
 if( rechter_ast !=((void *)0) && (rechter_ast->type == 3) ){
  if(rechter_ast->left != ((void *)0) && (rechter_ast->left->type == 6)){
   h = rechter_ast->left;
   while ( h != ((void *)0)){
    if ( h->right->type == 5
     && strncmp(h->right->name, "end", 256) == 0
     && strncmp(h->right->value, "yes", 256)== 0
    ){
     return h->right;
    }
    h= h->left;
   }
  }
 }
 return ((void *)0);
}

canonical_original_code:
struct graphnode *has_end_property(struct graphnode *node)
{
 struct graphnode *rechter_ast;
 struct graphnode *h;
 if( node == ((void *)0)) return ((void *)0);
 rechter_ast = node;
 if( rechter_ast !=((void *)0) && (rechter_ast->type == 3) ){
  if(rechter_ast->left != ((void *)0) && (rechter_ast->left->type == 6)){
   h = rechter_ast->left;
   while ( h != ((void *)0)){
    if ( h->right->type == 5
     && strncmp(h->right->name, "end", 256) == 0
     && strncmp(h->right->value, "yes", 256)== 0
    ){
     return h->right;
    }
    h= h->left;
   }
  }
 }
 return ((void *)0);
}

variable_types:
node
struct graphnode *

variable_types: struct graphnode { int type; char name[256]; char value[256]; char arrow[3]; struct graphnode *left; struct graphnode *right; } *


decompiled_code:
__int64 __fastcall has_start_property(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rdx

if ( !a1 )
return 0LL;
result = 0LL;
if ( *(_DWORD *)a1 == 3 )
{
result = *(_QWORD *)(a1 + 520);
if ( result )
{
if ( *(_DWORD *)result == 6 )
{
while ( 1 )
{
v2 = *(_QWORD *)(result + 528);
if ( *(_DWORD *)v2 == 5
&& !strcmp((const char *)(v2 + 4), "start")
&& !strcmp((const char *)(v2 + 260), "yes") )
{
break;
}
result = *(_QWORD *)(result + 520);
if ( !result )
return result;
}
result = *(_QWORD *)(result + 528);
}
else
{
result = 0LL;
}
}
}
return result;
}

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

if ( !a1 )
return 0LL;
result = 0LL;
if ( *(_DWORD *)a1 == 3 )
{
result = *(_QWORD *)(a1 + 520);
if ( result )
{
if ( *(_DWORD *)result == 6 )
{
while ( 1 )
{
v2 = *(_QWORD *)(result + 528);
if ( *(_DWORD *)v2 == 5
&& !strcmp((const char *)(v2 + 4), "start")
&& !strcmp((const char *)(v2 + 260), "yes") )
{
break;
}
result = *(_QWORD *)(result + 520);
if ( !result )
return result;
}
result = *(_QWORD *)(result + 528);
}
else
{
result = 0LL;
}
}
}
return result;
}

original_code:
t_graphnode* has_start_property( t_graphnode *node){
 t_graphnode *rechter_ast;
 t_graphnode *h;
 if( node == ((void *)0))
  return ((void *)0);
 rechter_ast = node;
 if( rechter_ast !=((void *)0) && (rechter_ast->type == 3) )
 {
  if(rechter_ast->left != ((void *)0) && (rechter_ast->left->type == 6))
  {
   h = rechter_ast->left;
   while ( h != ((void *)0)){
    if( h->right->type == 5
    && strncmp(h->right->name, "start", 256) == 0
    && strncmp(h->right->value, "yes", 256)== 0
    )
    {
     return h->right;
    }
    h= h->left;
   }
  }
 }
 return ((void *)0);
}

canonical_original_code:
struct graphnode *has_start_property(struct graphnode *node){
 struct graphnode *rechter_ast;
 struct graphnode *h;
 if( node == ((void *)0))
  return ((void *)0);
 rechter_ast = node;
 if( rechter_ast !=((void *)0) && (rechter_ast->type == 3) )
 {
  if(rechter_ast->left != ((void *)0) && (rechter_ast->left->type == 6))
  {
   h = rechter_ast->left;
   while ( h != ((void *)0)){
    if( h->right->type == 5
    && strncmp(h->right->name, "start", 256) == 0
    && strncmp(h->right->value, "yes", 256)== 0
    )
    {
     return h->right;
    }
    h= h->left;
   }
  }
 }
 return ((void *)0);
}

return_type: struct graphnode { int type; char name[256]; char value[256]; char arrow[3]; struct graphnode *left; struct graphnode *right; } *


original_code:
t_graphnode* has_did_label_property(t_graphnode* node)
{
 t_graphnode *rechter_ast, *h;
 if( node == ((void *)0) )
  return ((void *)0);
 rechter_ast = node;
 if(rechter_ast != ((void *)0) && (rechter_ast->type == 4))
 {
  if(rechter_ast->left != ((void *)0) && (rechter_ast->left->type == 6))
  {
   h = rechter_ast->left;
   while ( h != ((void *)0))
   {
    if(h->right->type == 5
    && strncmp (h->right->name, "label", 256) == 0
    && strnlen(h->right->value,256) > 0
    )
    {
     return h->right;
    }
    h = h->left;
   }
  }
 }
 return ((void *)0);
}

canonical_original_code:
struct graphnode *has_did_label_property(struct graphnode *node)
{
 struct graphnode *rechter_ast; struct graphnode *h;
 if( node == ((void *)0) )
  return ((void *)0);
 rechter_ast = node;
 if(rechter_ast != ((void *)0) && (rechter_ast->type == 4))
 {
  if(rechter_ast->left != ((void *)0) && (rechter_ast->left->type == 6))
  {
   h = rechter_ast->left;
   while ( h != ((void *)0))
   {
    if(h->right->type == 5
    && strncmp (h->right->name, "label", 256) == 0
    && strnlen(h->right->value,256) > 0
    )
    {
     return h->right;
    }
    h = h->left;
   }
  }
 }
 return ((void *)0);
}

user_defined_types: struct graphnode { int type; char name[256]; char value[256]; char arrow[3]; struct graphnode *left; struct graphnode *right; }


decompiled_code:
__int64 __fastcall insert_once_label(__int64 *a1, const char *a2)
{
__int64 v2; // rbx

v2 = *a1;
if ( *a1 )
{
while ( strncmp(*(const char **)(v2 + 40), a2, 0x100uLL) )
{
v2 = *(_QWORD *)(v2 + 56);
if ( !v2 )
goto LABEL_4;
}
}
else
{
LABEL_4:
v2 = generate_label_element(a2, (unsigned int)index_count_0);
put(a1, v2);
++index_count_0;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 *a1, const char *a2)
{
__int64 v2; // rbx

v2 = *a1;
if ( *a1 )
{
while ( strncmp(*(const char **)(v2 + 40), a2, 0x100uLL) )
{
v2 = *(_QWORD *)(v2 + 56);
if ( !v2 )
goto LABEL_4;
}
}
else
{
LABEL_4:
v2 = generate_label_element(a2, (unsigned int)index_count_0);
put(a1, v2);
++index_count_0;
}
return v2;
}

original_code:
t_element* insert_once_label(t_list* labels, char* label)
{
 static int index_count= 0;
 t_element* h = labels->first;
 while(h != ((void *)0))
 {
  if(strncmp(h->label, label, 256) == 0)
   return h;
  h = h->next;
 }
 h = generate_label_element(label, index_count);
 put (labels, h);
 index_count++;
 return h;
}

canonical_original_code:
struct element *insert_once_label(struct list *labels, char *label)
{
 static int index_count = 0;
 struct element *h = labels->first;
 while(h != ((void *)0))
 {
  if(strncmp(h->label, label, 256) == 0)
   return h;
  h = h->next;
 }
 h = generate_label_element(label, index_count);
 put (labels, h);
 index_count++;
 return h;
}

variable_types: struct list { struct element *first; struct element *last; int size; } *

variable_types:
label
char *

variable_types: struct element { char *name; int is_start; int is_end; struct element *source; struct element *destination; struct element *transition; char *label; int index; struct element *next; } *


original_code:
t_graphnode* get_id_by_name(t_graphnode* graph,char* name)
{
 t_graphnode* h = graph->left;
 while(h != ((void *)0))
 {
  if(h->right->type == 3)
  {
   if(strncmp(h->right->name, name, 256) == 0)
   {
    return h->right;
   }
  }
  h = h->left;
 }
 return ((void *)0);
}

canonical_original_code:
struct graphnode *get_id_by_name(struct graphnode *graph, char *name)
{
 struct graphnode *h = graph->left;
 while(h != ((void *)0))
 {
  if(h->right->type == 3)
  {
   if(strncmp(h->right->name, name, 256) == 0)
   {
    return h->right;
   }
  }
  h = h->left;
 }
 return ((void *)0);
}

variable_types:
graph
struct graphnode *

variable_types:
name
char *


decompiled_code:
_BOOL8 __fastcall is_end_state(__int64 a1, const char *a2)
{
__int64 v2; // rax

v2 = get_id_by_name(a1, a2);
return has_end_property(v2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(__int64 a1, const char *a2)
{
__int64 v2; // rax

v2 = func4(a1, a2);
return func0(v2) != 0;
}

original_code:
int is_end_state(t_graphnode* graph, char* name)
{
 if(has_end_property(get_id_by_name(graph, name)) != ((void *)0))
  return 1;
 return 0;
}

canonical_original_code:
int is_end_state(struct graphnode *graph, char *name)
{
 if(has_end_property(get_id_by_name(graph, name)) != ((void *)0))
  return 1;
 return 0;
}


decompiled_code:
_BOOL8 __fastcall is_start_state(__int64 a1, const char *a2)
{
__int64 v2; // rax

v2 = get_id_by_name(a1, a2);
return has_start_property(v2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(__int64 a1, const char *a2)
{
__int64 v2; // rax

v2 = func4(a1, a2);
return func1(v2) != 0;
}

original_code:
int is_start_state(t_graphnode* graph, char* name)
{
 if(has_start_property(get_id_by_name(graph, name)) != ((void *)0))
  return 1;
 return 0;
}

canonical_original_code:
int is_start_state(struct graphnode *graph, char *name)
{
 if(has_start_property(get_id_by_name(graph, name)) != ((void *)0))
  return 1;
 return 0;
}


decompiled_code:
__int64 __fastcall insert_once_id(__int64 a1, __int64 *a2, const char *a3, __int64 a4)
{
__int64 v6; // rbx
unsigned int v7; // er15
_BOOL4 v8; // ebx
_BOOL4 v9; // eax

v6 = *a2;
if ( *a2 )
{
while ( strncmp(*(const char **)v6, a3, 0x100uLL) )
{
v6 = *(_QWORD *)(v6 + 56);
if ( !v6 )
goto LABEL_4;
}
}
else
{
LABEL_4:
v7 = index_count_1;
v8 = is_end_state(a1, a3);
v9 = is_start_state(a1, a3);
v6 = generate_id_element(a3, v9, v8, a4, v7);
put(a2, v6);
++index_count_1;
}
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 *a2, const char *a3, __int64 a4)
{
__int64 v6; // rbx
unsigned int v7; // er15
_BOOL4 v8; // ebx
_BOOL4 v9; // eax

v6 = *a2;
if ( *a2 )
{
while ( strncmp(*(const char **)v6, a3, 0x100uLL) )
{
v6 = *(_QWORD *)(v6 + 56);
if ( !v6 )
goto LABEL_4;
}
}
else
{
LABEL_4:
v7 = index_count_1;
v8 = func5(a1, a3);
v9 = func6(a1, a3);
v6 = generate_id_element(a3, v9, v8, a4, v7);
put(a2, v6);
++index_count_1;
}
return v6;
}

original_code:
t_element* insert_once_id(t_graphnode* graph, t_list* ids, char* name, char* label)
{
 static int index_count= 0;
 t_element* h = ids->first;
 while(h != ((void *)0))
 {
  if(strncmp(h->name, name, 256) == 0)
   return h;
  h = h->next;
 }
 h = generate_id_element(name, is_start_state(graph, name), is_end_state(graph, name) ,label, index_count);
 put(ids, h);
 index_count++;
 return h;
}

canonical_original_code:
struct element *insert_once_id(struct graphnode *graph, struct list *ids, char *name, char *label)
{
 static int index_count = 0;
 struct element *h = ids->first;
 while(h != ((void *)0))
 {
  if(strncmp(h->name, name, 256) == 0)
   return h;
  h = h->next;
 }
 h = generate_id_element(name, is_start_state(graph, name), is_end_state(graph, name) ,label, index_count);
 put(ids, h);
 index_count++;
 return h;
}

return_type: struct element { char *name; int is_start; int is_end; struct element *source; struct element *destination; struct element *transition; char *label; int index; struct element *next; } *

user_defined_types: struct list { struct element *first; struct element *last; int size; }


original_code:
void fill_did_list(t_graphnode* graph, t_list* dids, t_list* ids, t_list* labels)
{
 t_graphnode* h = graph->left;
 t_graphnode* label_prop ;
 t_element* elem;
 t_element* source;
 t_element* dest;
 t_element* label;
 int index=0;
 while( h != ((void *)0))
 {
  if (h->right->type == 4)
  {
   label_prop=has_did_label_property(h->right);
   if( label_prop != ((void *)0))
   {
    source = insert_once_id(graph,ids, h->right->name, ((void *)0));
    dest = insert_once_id(graph,ids, h->right->value, ((void *)0));
    label = insert_once_label(labels, label_prop->value);
    elem= generate_did_element( label_prop->value, source, dest, label, index);
    put(dids, elem);
    index++;
   }
  }
  h = h->left;
 }
}

canonical_original_code:
void fill_did_list(struct graphnode *graph, struct list *dids, struct list *ids, struct list *labels)
{
 struct graphnode *h = graph->left;
 struct graphnode *label_prop;
 struct element *elem;
 struct element *source;
 struct element *dest;
 struct element *label;
 int index = 0;
 while( h != ((void *)0))
 {
  if (h->right->type == 4)
  {
   label_prop=has_did_label_property(h->right);
   if( label_prop != ((void *)0))
   {
    source = insert_once_id(graph,ids, h->right->name, ((void *)0));
    dest = insert_once_id(graph,ids, h->right->value, ((void *)0));
    label = insert_once_label(labels, label_prop->value);
    elem= generate_did_element( label_prop->value, source, dest, label, index);
    put(dids, elem);
    index++;
   }
  }
  h = h->left;
 }
}

variable_types: struct list { struct element { char *name; int is_start; int is_end; struct element *source; struct element *destination; struct element *transition; char *label; int index; struct element *next; } *first; struct element *last; int size; } *

variable_types:
ids
struct list *

variable_types:
labels
struct list *

variable_types: index int


decompiled_code:
__int64 __fastcall find_start_state(__int64 *a1)
{
__int64 v1; // rax
__int64 v2; // rdx

v1 = *a1;
if ( !*a1 )
return 0LL;
while ( 1 )
{
v2 = *(_QWORD *)(v1 + 16);
if ( *(_DWORD *)(v2 + 8) )
break;
v1 = *(_QWORD *)(v1 + 56);
if ( !v1 )
return 0LL;
}
return v2;
}

original_code:
t_element* find_start_state(t_list* dids)
{
 t_element* h = dids->first;
 while(h != ((void *)0))
 {
  if(h->source->is_start != 0)
   return h->source;
  h = h->next;
 }
 return ((void *)0);
}

canonical_original_code:
struct element *find_start_state(struct list *dids)
{
 struct element *h = dids->first;
 while(h != ((void *)0))
 {
  if(h->source->is_start != 0)
   return h->source;
  h = h->next;
 }
 return ((void *)0);
}

user_defined_types: struct element { char *name; int is_start; int is_end; struct element *source; struct element *destination; struct element *transition; char *label; int index; struct element *next; }


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

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

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

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

original_code:
t_element* get_start_state(t_list* states)
{
 t_element* h;
 h= states->first;
 while( h != ((void *)0))
 {
  if(h->is_start != 0){
   return h;
  }
  h = h->next;
 }
 return ((void *)0);
}

canonical_original_code:
struct element *get_start_state(struct list *states)
{
 struct element *h;
 h= states->first;
 while( h != ((void *)0))
 {
  if(h->is_start != 0){
   return h;
  }
  h = h->next;
 }
 return ((void *)0);
}


original_code:
t_list* get_end_states(t_list* states)
{
 t_list* end_states;
 t_element* h;
 t_element* copy;
 end_states = get_list_instance();
 h= states->first;
 while( h != ((void *)0))
 {
  if(h->is_end != 0){
   copy = malloc(sizeof(t_element));
   copy->name = h->name;
   copy->is_start = h->is_start;
   copy->is_end = h->is_end;
   copy->index = h->index;
   put(end_states, copy);
  }
  h = h->next;
 }
 return end_states;
}

canonical_original_code:
struct list *get_end_states(struct list *states)
{
 struct list *end_states;
 struct element *h;
 struct element *copy;
 end_states = get_list_instance();
 h= states->first;
 while( h != ((void *)0))
 {
  if(h->is_end != 0){
   copy = malloc(sizeof(t_element));
   copy->name = h->name;
   copy->is_start = h->is_start;
   copy->is_end = h->is_end;
   copy->index = h->index;
   put(end_states, copy);
  }
  h = h->next;
 }
 return end_states;
}

variable_types:
states
struct list *

return_type: struct list { struct element { char *name; int is_start; int is_end; struct element *source; struct element *destination; struct element *transition; char *label; int index; struct element *next; } *first; struct element *last; int size; } *


decompiled_code:
__int64 __fastcall get_transition_by_label(const char *a1, __int64 *a2)
{
__int64 v2; // rbx
char *v3; // r12
__int64 v4; // rbp

v2 = *a2;
v3 = no_new_line(a1);
if ( v2 )
{
while ( 1 )
{
v4 = *(_QWORD *)(v2 + 32);
if ( !strncmp(*(const char **)(v4 + 40), v3, 0x100uLL) )
break;
v2 = *(_QWORD *)(v2 + 56);
if ( !v2 )
goto LABEL_4;
}
}
else
{
LABEL_4:
free(v3);
v4 = 0LL;
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func12(const char *a1, __int64 *a2)
{
__int64 v2; // rbx
char *v3; // r12
__int64 v4; // rbp

v2 = *a2;
v3 = no_new_line(a1);
if ( v2 )
{
while ( 1 )
{
v4 = *(_QWORD *)(v2 + 32);
if ( !strncmp(*(const char **)(v4 + 40), v3, 0x100uLL) )
break;
v2 = *(_QWORD *)(v2 + 56);
if ( !v2 )
goto LABEL_4;
}
}
else
{
LABEL_4:
free(v3);
v4 = 0LL;
}
return v4;
}

original_code:
t_element* get_transition_by_label(char* label, t_list* dids)
{
 char* p_label;
 t_element* h = dids->first;
 p_label = no_new_line(label);
 while(h != ((void *)0))
 {
  if( strncmp( h->transition->label, p_label , 256 ) == 0)
   return h->transition;
  h = h->next;
 }
 free(p_label);
 return ((void *)0);
}

canonical_original_code:
struct element *get_transition_by_label(char *label, struct list *dids)
{
 char *p_label;
 struct element *h = dids->first;
 p_label = no_new_line(label);
 while(h != ((void *)0))
 {
  if( strncmp( h->transition->label, p_label , 256 ) == 0)
   return h->transition;
  h = h->next;
 }
 free(p_label);
 return ((void *)0);
}


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

v1 = *a1;
if ( !*a1 )
return 1LL;
while ( strnlen(*(const char **)(v1 + 40), 2uLL) <= 1 )
{
v1 = *(_QWORD *)(v1 + 56);
if ( !v1 )
return 1LL;
}
return 0LL;
}

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

v1 = *a1;
if ( !*a1 )
return 1LL;
while ( strnlen(*(const char **)(v1 + 40), 2uLL) <= 1 )
{
v1 = *(_QWORD *)(v1 + 56);
if ( !v1 )
return 1LL;
}
return 0LL;
}

original_code:
int is_single_symbol_dfa(t_list* labels)
{
 t_element* h = labels->first;
 while(h != ((void *)0))
 {
  if(strnlen(h->label, 2) > 1)
   return 0;
  h = h->next;
 }
 return 1;
}

canonical_original_code:
int is_single_symbol_dfa(struct list *labels)
{
 struct element *h = labels->first;
 while(h != ((void *)0))
 {
  if(strnlen(h->label, 2) > 1)
   return 0;
  h = h->next;
 }
 return 1;
}


decompiled_code:
__int64 __fastcall dfa_start(__int64 a1, int a2, const char **a3)
{
__int64 *v5; // r12
__int64 *v6; // rbx
char *v7; // rbp
const char *v8; // rsi
_QWORD *v9; // r13
bool v10; // dl
bool v11; // cf
bool v12; // zf
__int64 v13; // rcx
const char *v14; // rdi
unsigned int v15; // er15

fwrite("...libdfa started...\n", 1uLL, 0x15uLL, stderr);
v5 = (__int64 *)get_list_instance();
v6 = (__int64 *)get_list_instance();
v7 = (char *)get_list_instance();
fill_did_list(a1, (__int64)v7, v5, v6);
v8 = (const char *)v5;
v9 = fill_state_matrix(v7, (__int64)v5, (__int64)v6);
if ( a2 <= 0 )
{
v15 = -1;
}
else if ( !strcmp(*a3, "-i") )
{
v8 = v7;
if ( (unsigned int)is_single_symbol_dfa(v6) )
v15 = interpret_input_char(stdin, (__int64 *)v7, v9);
else
v15 = interpret_input_string(stdin, (__int64 *)v7, v9);
if ( v15 == 1 )
{
puts("\n---------------------\nEingabe akzeptiert\n---------------------\n");
v15 = 0;
}
else if ( v15 )
{
puts("Fehler beim interpretieren\n");
}
else
{
puts("!!-------------------\nEingabe nicht akzeptiert\n!!-------------------\n");
v15 = 1;
}
}
else
{
v10 = strcmp(*a3, "-dot") != 0;
v11 = 0;
v12 = !v10;
if ( v10 )
{
v13 = 3LL;
v14 = "-c";
v8 = *a3;
do
{
if ( !v13 )
break;
v11 = *v8 < (unsigned int)*v14;
v12 = *v8++ == *v14++;
--v13;
}
while ( v12 );
v15 = -1;
if ( (!v11 && !v12) == v11 )
{
v8 = (const char *)v6;
generate_c_code(v5, v6, v9);
}
}
else
{
v8 = (const char *)v5;
generate_dfa_dot_code(a1 + 4, v5, v7, v9);
v15 = -1;
}
}
delete_instance(v5, v8);
delete_instance(v6, v8);
delete_instance(v7, v8);
free_matrix(v9);
fwrite("...libdfa ended...\n", 1uLL, 0x13uLL, stderr);
return v15;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, int a2, const char **a3)
{
__int64 *v5; // r12
__int64 *v6; // rbx
char *v7; // rbp
const char *v8; // rsi
_QWORD *v9; // r13
bool v10; // dl
bool v11; // cf
bool v12; // zf
__int64 v13; // rcx
const char *v14; // rdi
unsigned int v15; // er15

fwrite("...libdfa started...\n", 1uLL, 0x15uLL, stderr);
v5 = (__int64 *)get_list_instance();
v6 = (__int64 *)get_list_instance();
v7 = (char *)get_list_instance();
func8(a1, (__int64)v7, v5, v6);
v8 = (const char *)v5;
v9 = fill_state_matrix(v7, (__int64)v5, (__int64)v6);
if ( a2 <= 0 )
{
v15 = -1;
}
else if ( !strcmp(*a3, "-i") )
{
v8 = v7;
if ( (unsigned int)func15(v6) )
v15 = func13(stdin, (__int64 *)v7, v9);
else
v15 = func14(stdin, (__int64 *)v7, v9);
if ( v15 == 1 )
{
puts("\n---------------------\nEingabe akzeptiert\n---------------------\n");
v15 = 0;
}
else if ( v15 )
{
puts("Fehler beim interpretieren\n");
}
else
{
puts("!!-------------------\nEingabe nicht akzeptiert\n!!-------------------\n");
v15 = 1;
}
}
else
{
v10 = strcmp(*a3, "-dot") != 0;
v11 = 0;
v12 = !v10;
if ( v10 )
{
v13 = 3LL;
v14 = "-c";
v8 = *a3;
do
{
if ( !v13 )
break;
v11 = *v8 < (unsigned int)*v14;
v12 = *v8++ == *v14++;
--v13;
}
while ( v12 );
v15 = -1;
if ( (!v11 && !v12) == v11 )
{
v8 = (const char *)v6;
generate_c_code(v5, v6, v9);
}
}
else
{
v8 = (const char *)v5;
generate_dfa_dot_code(a1 + 4, v5, v7, v9);
v15 = -1;
}
}
delete_instance(v5, v8);
delete_instance(v6, v8);
delete_instance(v7, v8);
free_matrix(v9);
fwrite("...libdfa ended...\n", 1uLL, 0x13uLL, stderr);
return v15;
}

original_code:
int dfa_start(t_graphnode *graph, int argc, char *argv[])
{
 int erg = -1;
 char* parameter_one;
 t_list* ids;
 t_list* dids;
 t_list* labels;
 t_matrix* state_matrix;
 fprintf(stderr,"...libdfa started...\n");
 ids = get_list_instance();
 labels = get_list_instance();
 dids= get_list_instance();
 fill_did_list(graph, dids, ids, labels);
 state_matrix= fill_state_matrix(dids, ids, labels);
 if(argc > 0)
 { parameter_one = argv[0];
  if(strncmp(parameter_one, "-i", 3) == 0)
  {
   if(is_single_symbol_dfa(labels))
   {
    erg =interpret_input_char(stdin, dids, state_matrix);
   }
   else
   {
    erg =interpret_input_string(stdin, dids, state_matrix);
   }
   if(erg == 1)
   {
    printf("\n---------------------\nEingabe akzeptiert\n---------------------\n\n");
    erg = 0;
   }
   else if( erg == 0)
   {
    printf("!!-------------------\nEingabe nicht akzeptiert\n!!-------------------\n\n");
    erg = 1;
   }
   else
    printf("Fehler beim interpretieren\n\n");
  }
  else if(strncmp(parameter_one, "-dot", 5) == 0)
  {
   generate_dfa_dot_code(graph->name, ids, dids, state_matrix);
  }
  else if(strncmp(parameter_one, "-c", 3) == 0)
  {
   generate_c_code(ids, labels, state_matrix);
  }
 }
 delete_instance(ids);
 delete_instance(labels);
 delete_instance(dids);
 free_matrix(state_matrix);
 fprintf(stderr,"...libdfa ended...\n");
 return erg;
}

canonical_original_code:
int dfa_start(struct graphnode *graph, int argc, char *argv[])
{
 int erg = -1;
 char *parameter_one;
 struct list *ids;
 struct list *dids;
 struct list *labels;
 struct matrix *state_matrix;
 fprintf(stderr,"...libdfa started...\n");
 ids = get_list_instance();
 labels = get_list_instance();
 dids= get_list_instance();
 fill_did_list(graph, dids, ids, labels);
 state_matrix= fill_state_matrix(dids, ids, labels);
 if(argc > 0)
 { parameter_one = argv[0];
  if(strncmp(parameter_one, "-i", 3) == 0)
  {
   if(is_single_symbol_dfa(labels))
   {
    erg =interpret_input_char(stdin, dids, state_matrix);
   }
   else
   {
    erg =interpret_input_string(stdin, dids, state_matrix);
   }
   if(erg == 1)
   {
    printf("\n---------------------\nEingabe akzeptiert\n---------------------\n\n");
    erg = 0;
   }
   else if( erg == 0)
   {
    printf("!!-------------------\nEingabe nicht akzeptiert\n!!-------------------\n\n");
    erg = 1;
   }
   else
    printf("Fehler beim interpretieren\n\n");
  }
  else if(strncmp(parameter_one, "-dot", 5) == 0)
  {
   generate_dfa_dot_code(graph->name, ids, dids, state_matrix);
  }
  else if(strncmp(parameter_one, "-c", 3) == 0)
  {
   generate_c_code(ids, labels, state_matrix);
  }
 }
 delete_instance(ids);
 delete_instance(labels);
 delete_instance(dids);
 free_matrix(state_matrix);
 fprintf(stderr,"...libdfa ended...\n");
 return erg;
}

variable_types: erg int

variable_types: struct matrix { struct ma_element { struct element { char *name; int is_start; int is_end; struct element *source; struct element *destination; struct element *transition; char *label; int index; struct element *next; } *dest_state; struct element *source_state; char *name; } **values; int rows; int columns; } *

user_defined_types: struct matrix { struct ma_element **values; int rows; int columns; }

user_defined_types: struct ma_element { struct element *dest_state; struct element *source_state; char *name; }


decompiled_code:
_DWORD *get_list_instance()
{
_DWORD *result; // rax

result = malloc(0x18uLL);
result[4] = 0;
*(_QWORD *)result = 0LL;
*((_QWORD *)result + 1) = 0LL;
return result;
}

canonical_decompiled_code:
_DWORD *func0()
{
_DWORD *result; // rax

result = malloc(0x18uLL);
result[4] = 0;
*(_QWORD *)result = 0LL;
*((_QWORD *)result + 1) = 0LL;
return result;
}

original_code:
t_list* get_list_instance()
{
 t_list* ins;
 ins = (t_list*) malloc(sizeof(t_list));
 ins->size = 0;
 ins->first = ((void *)0);
 ins->last = ((void *)0);
 return ins;
}

canonical_original_code:
struct list *get_list_instance()
{
 struct list *ins;
 ins = (struct list *) malloc(sizeof(t_list));
 ins->size = 0;
 ins->first = ((void *)0);
 ins->last = ((void *)0);
 return ins;
}


decompiled_code:
void __fastcall delete_instance(void *ptr)
{
_QWORD *v2; // rdi

v2 = *(_QWORD **)ptr;
if ( v2 )
{
do
{
*(_QWORD *)ptr = v2[7];
free(v2);
v2 = *(_QWORD **)ptr;
}
while ( *(_QWORD *)ptr );
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
_QWORD *v2; // rdi

v2 = *(_QWORD **)ptr;
if ( v2 )
{
do
{
*(_QWORD *)ptr = v2[7];
free(v2);
v2 = *(_QWORD **)ptr;
}
while ( *(_QWORD *)ptr );
}
free(ptr);
}

original_code:
void delete_instance( t_list* list)
{
 t_element* h = list->first;
 while(h != ((void *)0))
 {
  list->first= h->next;
  free(h);
  h= list->first;
 }
 free(list);
}

canonical_original_code:
void delete_instance(struct list *list)
{
 struct element *h = list->first;
 while(h != ((void *)0))
 {
  list->first= h->next;
  free(h);
  h= list->first;
 }
 free(list);
}


put

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

result = *(_QWORD *)(a1 + 8);
if ( result )
*(_QWORD *)(result + 56) = a2;
*(_QWORD *)(a1 + 8) = a2;
if ( !*(_QWORD *)a1 )
{
result = *(_QWORD *)(a1 + 8);
*(_QWORD *)a1 = result;
}
++*(_DWORD *)(a1 + 16);
return result;
}

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

result = *(_QWORD *)(a1 + 8);
if ( result )
*(_QWORD *)(result + 56) = a2;
*(_QWORD *)(a1 + 8) = a2;
if ( !*(_QWORD *)a1 )
{
result = *(_QWORD *)(a1 + 8);
*(_QWORD *)a1 = result;
}
++*(_DWORD *)(a1 + 16);
return result;
}

original_code:
void put(t_list* list, t_element* val)
{
 if(list->last == ((void *)0))
 {
  list->last = val;
 }
 else{
  list->last->next = val;
  list->last = val;
 }
 if(list->first == ((void *)0))
  list->first = list->last;
 list->size++;
}

canonical_original_code:
void put(struct list *list, struct element *val)
{
 if(list->last == ((void *)0))
 {
  list->last = val;
 }
 else{
  list->last->next = val;
  list->last = val;
 }
 if(list->first == ((void *)0))
  list->first = list->last;
 list->size++;
}

variable_types:
val
struct element *


get

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

if ( !a1 )
return 0LL;
result = *a1;
if ( *a1 )
{
*a1 = *(_QWORD *)(result + 56);
--*((_DWORD *)a1 + 4);
}
return result;
}

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

if ( !a1 )
return 0LL;
result = *a1;
if ( *a1 )
{
*a1 = *(_QWORD *)(result + 56);
--*((_DWORD *)a1 + 4);
}
return result;
}

original_code:
t_element* get( t_list* list)
{
 t_element* ret;
 t_element* h;
 if(list == ((void *)0))
  return ((void *)0);
 if(list->first == ((void *)0))
  return ((void *)0);
 h = list->first;
 list->first = h->next;
 ret = h;
 list->size--;
 return ret;
}

canonical_original_code:
struct element *get(struct list *list)
{
 struct element *ret;
 struct element *h;
 if(list == ((void *)0))
  return ((void *)0);
 if(list->first == ((void *)0))
  return ((void *)0);
 h = list->first;
 list->first = h->next;
 ret = h;
 list->size--;
 return ret;
}


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

v1 = *a1;
if ( *a1 && a1[1] )
{
puts("PRINT LIST :");
if ( v1 == a1[1] )
{
v1 = a1[1];
}
else
{
do
{
printf("Name:%s, Label:%s\n", *v1, v1[5]);
v1 = (const char **)v1[7];
}
while ( a1[1] != v1 );
}
result = printf("Name:%s, Label:%s\n", *v1, v1[5]);
}
return result;
}

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

v1 = *a1;
if ( *a1 && a1[1] )
{
puts("PRINT LIST :");
if ( v1 == a1[1] )
{
v1 = a1[1];
}
else
{
do
{
printf("Name:%s, Label:%s\n", *v1, v1[5]);
v1 = (const char **)v1[7];
}
while ( a1[1] != v1 );
}
result = printf("Name:%s, Label:%s\n", *v1, v1[5]);
}
return result;
}

original_code:
void print_list(t_list* list){
 t_element* h;
 h = list->first;
 if( list == ((void *)0))
  return;
 if(list->first == ((void *)0) || list->last == ((void *)0))
  return;
  printf("PRINT LIST :\n");
  while(h != list->last){
   printf("Name:%s, Label:%s\n", h->name, h->label);
   h = h->next;
  }
  printf("Name:%s, Label:%s\n", list->last->name, list->last->label);;
}

canonical_original_code:
void print_list(struct list *list){
 struct element *h;
 h = list->first;
 if( list == ((void *)0))
  return;
 if(list->first == ((void *)0) || list->last == ((void *)0))
  return;
  printf("PRINT LIST :\n");
  while(h != list->last){
   printf("Name:%s, Label:%s\n", h->name, h->label);
   h = h->next;
  }
  printf("Name:%s, Label:%s\n", list->last->name, list->last->label);;
}


printtabs

decompiled_code:
int __fastcall printtabs(int a1)
{
int i; // ebx
int result; // eax

if ( a1 > 0 )
{
for ( i = 0; i != a1; ++i )
result = fputc(9, stdout);
}
return result;
}

canonical_decompiled_code:
int __fastcall func6(int a1)
{
int i; // ebx
int result; // eax

if ( a1 > 0 )
{
for ( i = 0; i != a1; ++i )
result = fputc(9, stdout);
}
return result;
}

original_code:
void printtabs(int x)
{
 int i;
 for(i = 0; i < x; i++)
 {
  fprintf(stdout,"\t");
 }
}

variable_types: x int

variable_types: i int


decompiled_code:
__int64 __fastcall tp_start(__int64 a1)
{
fwrite("...gv_tp started...\n", 1uLL, 0x14uLL, stderr);
printtree_rec_localalias(a1, 0LL);
fwrite("...gv_tp ended...\n", 1uLL, 0x12uLL, stderr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
fwrite("...gv_tp started...\n", 1uLL, 0x14uLL, stderr);
func7(a1, 0LL);
fwrite("...gv_tp ended...\n", 1uLL, 0x12uLL, stderr);
return 0LL;
}

original_code:
int tp_start(t_graphnode *graph, int argc, char *argv[])
{
 fprintf(stderr,"...gv_tp started...\n");
 printtree_rec(graph,0);
 fprintf(stderr,"...gv_tp ended...\n");
 return 0;
}

canonical_original_code:
int tp_start(struct graphnode *graph, int argc, char *argv[])
{
 fprintf(stderr,"...gv_tp started...\n");
 printtree_rec(graph,0);
 fprintf(stderr,"...gv_tp ended...\n");
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]


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

v1 = *a1;
for ( result = fwrite("\n\t// states\n\n", 1uLL, 0xDuLL, stdout); v1; v1 = (const char **)v1[7] )
{
if ( *((_DWORD *)v1 + 2) )
{
result = fprintf(stdout, "\t\"%s\" %s\n", *v1, "[ start=\"yes\" ]\t/* start node */");
}
else if ( *((_DWORD *)v1 + 3) )
{
result = fprintf(stdout, "\t\"%s\" %s\n", *v1, "[ shape=doublecircle end=\"yes\" ]\t/* end node */");
}
else
{
result = fprintf(stdout, "\t\"%s\"\n", *v1);
}
}
return result;
}

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

v1 = *a1;
for ( result = fwrite("\n\t// states\n\n", 1uLL, 0xDuLL, stdout); v1; v1 = (const char **)v1[7] )
{
if ( *((_DWORD *)v1 + 2) )
{
result = fprintf(stdout, "\t\"%s\" %s\n", *v1, "[ start=\"yes\" ]\t/* start node */");
}
else if ( *((_DWORD *)v1 + 3) )
{
result = fprintf(stdout, "\t\"%s\" %s\n", *v1, "[ shape=doublecircle end=\"yes\" ]\t/* end node */");
}
else
{
result = fprintf(stdout, "\t\"%s\"\n", *v1);
}
}
return result;
}

original_code:
void write_states(t_list* states)
{
 char* start_state_props = "[ start=\"yes\" ]\t/* start node */";
 char* end_state_props = "[ shape=doublecircle end=\"yes\" ]\t/* end node */";
 char* start_end_state_props = "[ shape=doublecircle start=\"yes\" end=\"yes\" ]\t/* start and end node */";
 t_element* h = states->first;
 fprintf(stdout,"\n\t// states\n\n");
 while(h != ((void *)0))
 {
  if(h->is_start != 0)
  {
       fprintf(stdout,"\t\"%s\" %s\n", h->name, start_state_props);
  }
  else if (h->is_end != 0)
  {
   fprintf(stdout,"\t\"%s\" %s\n", h->name, end_state_props);
  }
  else if (h->is_start != 0 && h->is_end != 0)
  {
   fprintf(stdout,"\t\"%s\" %s\n", h->name, start_end_state_props);
  }
  else
  {
   fprintf(stdout,"\t\"%s\"\n", h->name);
  }
  h= h->next;
 }
}

canonical_original_code:
void write_states(struct list *states)
{
 char *start_state_props = "[ start=\"yes\" ]\t/* start node */";
 char *end_state_props = "[ shape=doublecircle end=\"yes\" ]\t/* end node */";
 char *start_end_state_props = "[ shape=doublecircle start=\"yes\" end=\"yes\" ]\t/* start and end node */";
 struct element *h = states->first;
 fprintf(stdout,"\n\t// states\n\n");
 while(h != ((void *)0))
 {
  if(h->is_start != 0)
  {
       fprintf(stdout,"\t\"%s\" %s\n", h->name, start_state_props);
  }
  else if (h->is_end != 0)
  {
   fprintf(stdout,"\t\"%s\" %s\n", h->name, end_state_props);
  }
  else if (h->is_start != 0 && h->is_end != 0)
  {
   fprintf(stdout,"\t\"%s\" %s\n", h->name, start_end_state_props);
  }
  else
  {
   fprintf(stdout,"\t\"%s\"\n", h->name);
  }
  h= h->next;
 }
}


decompiled_code:
int __fastcall write_transitions(__int64 *a1)
{
__int64 v1; // rbx
const char **v2; // rbp
int result; // eax

v1 = *a1;
v2 = (const char **)find_start_state();
fwrite("\n\t//transitions\n\n", 1uLL, 0x11uLL, stdout);
for ( result = fprintf(stdout, "\t\"starter\" -> \"%s\"\n", *v2); v1; v1 = *(_QWORD *)(v1 + 56) )
result = fprintf(
stdout,
"\t\"%s\" -> \"%s\" [ label=\"%s\" ]\n",
**(const char ***)(v1 + 16),
**(const char ***)(v1 + 24),
*(const char **)(*(_QWORD *)(v1 + 32) + 40LL));
return result;
}

canonical_decompiled_code:
int __fastcall func1(__int64 *a1)
{
__int64 v1; // rbx
const char **v2; // rbp
int result; // eax

v1 = *a1;
v2 = (const char **)find_start_state();
fwrite("\n\t//transitions\n\n", 1uLL, 0x11uLL, stdout);
for ( result = fprintf(stdout, "\t\"starter\" -> \"%s\"\n", *v2); v1; v1 = *(_QWORD *)(v1 + 56) )
result = fprintf(
stdout,
"\t\"%s\" -> \"%s\" [ label=\"%s\" ]\n",
**(const char ***)(v1 + 16),
**(const char ***)(v1 + 24),
*(const char **)(*(_QWORD *)(v1 + 32) + 40LL));
return result;
}

original_code:
void write_transitions(t_list* dids)
{
 t_element* h = dids->first;
 t_element* start_state = find_start_state(dids);
 fprintf(stdout,"\n\t//transitions\n\n");
 fprintf(stdout,"\t\"starter\" -> \"%s\"\n", start_state->name);
 while(h != ((void *)0))
 {
  fprintf(stdout,"\t\"%s\" -> \"%s\" [ label=\"%s\" ]\n", h->source->name, h->destination->name, h->transition->label);
  h = h->next;
 }
}

canonical_original_code:
void write_transitions(struct list *dids)
{
 struct element *h = dids->first;
 struct element *start_state = find_start_state(dids);
 fprintf(stdout,"\n\t//transitions\n\n");
 fprintf(stdout,"\t\"starter\" -> \"%s\"\n", start_state->name);
 while(h != ((void *)0))
 {
  fprintf(stdout,"\t\"%s\" -> \"%s\" [ label=\"%s\" ]\n", h->source->name, h->destination->name, h->transition->label);
  h = h->next;
 }
}


decompiled_code:
size_t __fastcall generate_dfa_dot_code(const char *a1, const char ***a2, __int64 *a3)
{
fwrite("/*\n* Generated code by graphval's dfa plugin\n*/\n", 1uLL, 0x30uLL, stdout);
fprintf(stdout, "digraph %s {\n", a1);
fwrite("\trankdir = LR\n", 1uLL, 0xEuLL, stdout);
fwrite("\tnode [ shape=circle ];\n", 1uLL, 0x18uLL, stdout);
fwrite("\t\"starter\" [", 1uLL, 0xCuLL, stdout);
fwrite(" label=\"\"", 1uLL, 9uLL, stdout);
fwrite(" shape=\"plaintext\"", 1uLL, 0x12uLL, stdout);
fwrite(" ]\n", 1uLL, 3uLL, stdout);
write_states(a2);
write_transitions(a3);
return fwrite("}\n", 1uLL, 2uLL, stdout);
}

canonical_decompiled_code:
size_t __fastcall func2(const char *a1, const char ***a2, __int64 *a3)
{
fwrite("/*\n* Generated code by graphval's dfa plugin\n*/\n", 1uLL, 0x30uLL, stdout);
fprintf(stdout, "digraph %s {\n", a1);
fwrite("\trankdir = LR\n", 1uLL, 0xEuLL, stdout);
fwrite("\tnode [ shape=circle ];\n", 1uLL, 0x18uLL, stdout);
fwrite("\t\"starter\" [", 1uLL, 0xCuLL, stdout);
fwrite(" label=\"\"", 1uLL, 9uLL, stdout);
fwrite(" shape=\"plaintext\"", 1uLL, 0x12uLL, stdout);
fwrite(" ]\n", 1uLL, 3uLL, stdout);
func0(a2);
func1(a3);
return fwrite("}\n", 1uLL, 2uLL, stdout);
}

original_code:
void generate_dfa_dot_code(char* automaton_name, t_list* states, t_list* dids, t_matrix* state_matrix)
{
 fprintf(stdout,"/*\n* Generated code by graphval's dfa plugin\n*/\n");
 fprintf(stdout,"digraph %s {\n", automaton_name);
 fprintf(stdout,"\trankdir = LR\n");
 fprintf(stdout,"\tnode [ shape=circle ];\n");
 fprintf(stdout,"\t\"starter\" [");
 fprintf(stdout," label=\"\"");
 fprintf(stdout," shape=\"plaintext\"");
 fprintf(stdout," ]\n");
 write_states(states);
 write_transitions(dids);
 fprintf(stdout,"}\n");
}

canonical_original_code:
void generate_dfa_dot_code(char *automaton_name, struct list *states, struct list *dids, struct matrix *state_matrix)
{
 fprintf(stdout,"/*\n* Generated code by graphval's dfa plugin\n*/\n");
 fprintf(stdout,"digraph %s {\n", automaton_name);
 fprintf(stdout,"\trankdir = LR\n");
 fprintf(stdout,"\tnode [ shape=circle ];\n");
 fprintf(stdout,"\t\"starter\" [");
 fprintf(stdout," label=\"\"");
 fprintf(stdout," shape=\"plaintext\"");
 fprintf(stdout," ]\n");
 write_states(states);
 write_transitions(dids);
 fprintf(stdout,"}\n");
}

variable_types:
dids
struct list *

variable_types: struct matrix { struct ma_element { struct element *dest_state; struct element *source_state; char *name; } **values; int rows; int columns; } *


decompiled_code:
__int64 __fastcall write_declaration(__int64 a1, __int64 *a2)
{
__int64 v2; // rbp
__int64 v3; // rbx
__int64 v4; // rax
__int64 i; // rbx

v2 = get_end_states();
v3 = *(_QWORD *)v2;
fwrite("/* Generated code by graphval dfa plugin */\n", 1uLL, 0x2CuLL, stdout);
fwrite("\n#include \"dfa.h\"\n\n", 1uLL, 0x13uLL, stdout);
fprintf(stdout, "int Anzahl_Zustaende = %i;\n", *(unsigned int *)(a1 + 16));
fprintf(stdout, "int Anzahl_Endzustaende = %i;\n", *(unsigned int *)(v2 + 16));
v4 = get_start_state(a1);
fprintf(stdout, "int Startzustand = %i;\n", *(unsigned int *)(v4 + 48));
fwrite("int Endzustaende[] = {", 1uLL, 0x16uLL, stdout);
for ( ; v3; v3 = *(_QWORD *)(v3 + 56) )
{
if ( *(_QWORD *)(v2 + 8) == v3 )
fprintf(stdout, "%i", *(unsigned int *)(v3 + 48));
else
fprintf(stdout, "%i, ", *(unsigned int *)(v3 + 48));
}
fwrite("};\n", 1uLL, 3uLL, stdout);
fwrite("char *Alphabet[STRMAX] = {\n", 1uLL, 0x1BuLL, stdout);
for ( i = *a2; i; i = *(_QWORD *)(i + 56) )
{
if ( a2[1] == i )
fprintf(stdout, "\t\"%s\"\n", *(const char **)(i + 40));
else
fprintf(stdout, "\t\"%s\",\n", *(const char **)(i + 40));
}
fwrite("};\n", 1uLL, 3uLL, stdout);
return delete_instance(v2);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 *a2)
{
__int64 v2; // rbp
__int64 v3; // rbx
__int64 v4; // rax
__int64 i; // rbx

v2 = get_end_states();
v3 = *(_QWORD *)v2;
fwrite("/* Generated code by graphval dfa plugin */\n", 1uLL, 0x2CuLL, stdout);
fwrite("\n#include \"dfa.h\"\n\n", 1uLL, 0x13uLL, stdout);
fprintf(stdout, "int Anzahl_Zustaende = %i;\n", *(unsigned int *)(a1 + 16));
fprintf(stdout, "int Anzahl_Endzustaende = %i;\n", *(unsigned int *)(v2 + 16));
v4 = get_start_state(a1);
fprintf(stdout, "int Startzustand = %i;\n", *(unsigned int *)(v4 + 48));
fwrite("int Endzustaende[] = {", 1uLL, 0x16uLL, stdout);
for ( ; v3; v3 = *(_QWORD *)(v3 + 56) )
{
if ( *(_QWORD *)(v2 + 8) == v3 )
fprintf(stdout, "%i", *(unsigned int *)(v3 + 48));
else
fprintf(stdout, "%i, ", *(unsigned int *)(v3 + 48));
}
fwrite("};\n", 1uLL, 3uLL, stdout);
fwrite("char *Alphabet[STRMAX] = {\n", 1uLL, 0x1BuLL, stdout);
for ( i = *a2; i; i = *(_QWORD *)(i + 56) )
{
if ( a2[1] == i )
fprintf(stdout, "\t\"%s\"\n", *(const char **)(i + 40));
else
fprintf(stdout, "\t\"%s\",\n", *(const char **)(i + 40));
}
fwrite("};\n", 1uLL, 3uLL, stdout);
return delete_instance(v2);
}

original_code:
void write_declaration(t_list* states, t_list* transitions)
{
 t_element* h;
 t_list* end_states;
 end_states = get_end_states(states);
 h= end_states->first;
 fprintf(stdout,"/* Generated code by graphval dfa plugin */\n");
 fprintf(stdout,"\n#include \"dfa.h\"\n\n");
 fprintf(stdout,"int Anzahl_Zustaende = %i;\n", states->size);
 fprintf(stdout,"int Anzahl_Endzustaende = %i;\n", end_states->size);
 fprintf(stdout,"int Startzustand = %i;\n", get_start_state(states)->index);
 fprintf(stdout,"int Endzustaende[] = {");
 while(h != ((void *)0))
 {
  if(h == end_states->last)
   fprintf(stdout,"%i", h->index);
  else
   fprintf(stdout,"%i, ", h->index);
  h = h->next;
 }
 fprintf(stdout,"};\n");
 fprintf(stdout,"char *Alphabet[STRMAX] = {\n");
 h = transitions->first;
 while(h != ((void *)0))
 {
  if(h == transitions->last)
   fprintf(stdout,"\t\"%s\"\n", h->label);
  else
   fprintf(stdout,"\t\"%s\",\n", h->label);
  h = h->next;
 }
 fprintf(stdout,"};\n");
 delete_instance(end_states);
}

canonical_original_code:
void write_declaration(struct list *states, struct list *transitions)
{
 struct element *h;
 struct list *end_states;
 end_states = get_end_states(states);
 h= end_states->first;
 fprintf(stdout,"/* Generated code by graphval dfa plugin */\n");
 fprintf(stdout,"\n#include \"dfa.h\"\n\n");
 fprintf(stdout,"int Anzahl_Zustaende = %i;\n", states->size);
 fprintf(stdout,"int Anzahl_Endzustaende = %i;\n", end_states->size);
 fprintf(stdout,"int Startzustand = %i;\n", get_start_state(states)->index);
 fprintf(stdout,"int Endzustaende[] = {");
 while(h != ((void *)0))
 {
  if(h == end_states->last)
   fprintf(stdout,"%i", h->index);
  else
   fprintf(stdout,"%i, ", h->index);
  h = h->next;
 }
 fprintf(stdout,"};\n");
 fprintf(stdout,"char *Alphabet[STRMAX] = {\n");
 h = transitions->first;
 while(h != ((void *)0))
 {
  if(h == transitions->last)
   fprintf(stdout,"\t\"%s\"\n", h->label);
  else
   fprintf(stdout,"\t\"%s\",\n", h->label);
  h = h->next;
 }
 fprintf(stdout,"};\n");
 delete_instance(end_states);
}

variable_types:
transitions
struct list *

variable_types: struct element { char *name; int is_start; int is_end; struct element *source; struct element *destination; struct element *transition; char *label; int index; struct element *next; } *


decompiled_code:
size_t __fastcall write_table(__int64 a1)
{
__int64 v1; // r15
__int64 v2; // rbx
__int64 v3; // r12

fprintf(stdout, "\nstruct Tabelle_Eintrag Tabelle[%i][%i]={\n", *(unsigned int *)(a1 + 8), *(unsigned int *)(a1 + 12));
if ( *(int *)(a1 + 8) > 0 )
{
v1 = 0LL;
do
{
fwrite("{ ", 1uLL, 2uLL, stdout);
if ( *(int *)(a1 + 12) > 0 )
{
v2 = 0LL;
do
{
v3 = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)a1 + 8 * v1) + 24 * v2);
fwrite(" {", 1uLL, 2uLL, stdout);
if ( v3 )
fprintf(stdout, "%i,Aktion", *(unsigned int *)(v3 + 48));
else
fwrite("0,Fehler", 1uLL, 8uLL, stdout);
if ( *(_DWORD *)(a1 + 12) - 1 <= (int)v2 )
fputc(125, stdout);
else
fwrite("},", 1uLL, 2uLL, stdout);
++v2;
}
while ( *(_DWORD *)(a1 + 12) > (int)v2 );
}
if ( *(_DWORD *)(a1 + 8) - 1 <= (int)v1 )
fwrite(" }\n", 1uLL, 3uLL, stdout);
else
fwrite(" },\n", 1uLL, 4uLL, stdout);
++v1;
}
while ( *(_DWORD *)(a1 + 8) > (int)v1 );
}
return fwrite("};\n", 1uLL, 3uLL, stdout);
}

canonical_decompiled_code:
size_t __fastcall func1(__int64 a1)
{
__int64 v1; // r15
__int64 v2; // rbx
__int64 v3; // r12

fprintf(stdout, "\nstruct Tabelle_Eintrag Tabelle[%i][%i]={\n", *(unsigned int *)(a1 + 8), *(unsigned int *)(a1 + 12));
if ( *(int *)(a1 + 8) > 0 )
{
v1 = 0LL;
do
{
fwrite("{ ", 1uLL, 2uLL, stdout);
if ( *(int *)(a1 + 12) > 0 )
{
v2 = 0LL;
do
{
v3 = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)a1 + 8 * v1) + 24 * v2);
fwrite(" {", 1uLL, 2uLL, stdout);
if ( v3 )
fprintf(stdout, "%i,Aktion", *(unsigned int *)(v3 + 48));
else
fwrite("0,Fehler", 1uLL, 8uLL, stdout);
if ( *(_DWORD *)(a1 + 12) - 1 <= (int)v2 )
fputc(125, stdout);
else
fwrite("},", 1uLL, 2uLL, stdout);
++v2;
}
while ( *(_DWORD *)(a1 + 12) > (int)v2 );
}
if ( *(_DWORD *)(a1 + 8) - 1 <= (int)v1 )
fwrite(" }\n", 1uLL, 3uLL, stdout);
else
fwrite(" },\n", 1uLL, 4uLL, stdout);
++v1;
}
while ( *(_DWORD *)(a1 + 8) > (int)v1 );
}
return fwrite("};\n", 1uLL, 3uLL, stdout);
}

original_code:
void write_table(t_matrix* matrix)
{
 int i,j;
 t_element* h;
 fprintf(stdout, "\nstruct Tabelle_Eintrag Tabelle[%i][%i]={\n", matrix->rows, matrix->columns);
 for(i = 0; i< matrix->rows; i++)
 {
  fprintf(stdout,"{ ");
  for(j = 0; j < matrix->columns; j++)
  {
   h = matrix->values[i][j].dest_state;
   fprintf(stdout," {");
   if(h == ((void *)0))
   {
    fprintf(stdout,"0,Fehler");
   }
   else
   {
    fprintf(stdout,"%i,Aktion", h->index);
   }
   if(j < matrix->columns -1)
    fprintf(stdout,"},");
   else
    fprintf(stdout,"}");
  }
  if(i < matrix->rows -1)
   fprintf(stdout," },\n");
  else
   fprintf(stdout," }\n");
 }
 fprintf(stdout,"};\n");
}

canonical_original_code:
void write_table(struct matrix *matrix)
{
 int i; int j;
 struct element *h;
 fprintf(stdout, "\nstruct Tabelle_Eintrag Tabelle[%i][%i]={\n", matrix->rows, matrix->columns);
 for(i = 0; i< matrix->rows; i++)
 {
  fprintf(stdout,"{ ");
  for(j = 0; j < matrix->columns; j++)
  {
   h = matrix->values[i][j].dest_state;
   fprintf(stdout," {");
   if(h == ((void *)0))
   {
    fprintf(stdout,"0,Fehler");
   }
   else
   {
    fprintf(stdout,"%i,Aktion", h->index);
   }
   if(j < matrix->columns -1)
    fprintf(stdout,"},");
   else
    fprintf(stdout,"}");
  }
  if(i < matrix->rows -1)
   fprintf(stdout," },\n");
  else
   fprintf(stdout," }\n");
 }
 fprintf(stdout,"};\n");
}

variable_types: j int


decompiled_code:
size_t __fastcall generate_c_code(__int64 a1, __int64 *a2, __int64 a3)
{
write_declaration(a1, a2);
return write_table(a3);
}

canonical_decompiled_code:
size_t __fastcall func2(__int64 a1, __int64 *a2, __int64 a3)
{
func0(a1, a2);
return func1(a3);
}

original_code:
void generate_c_code(t_list* states, t_list* transitions, t_matrix* matrix)
{
 write_declaration(states, transitions);
 write_table(matrix);
}

canonical_original_code:
void generate_c_code(struct list *states, struct list *transitions, struct matrix *matrix)
{
 write_declaration(states, transitions);
 write_table(matrix);
}

variable_types: struct list { struct element { char *name; int is_start; int is_end; struct element *source; struct element *destination; struct element *transition; char *label; int index; struct element *next; } *first; struct element *last; int size; } *


decompiled_code:
void __fastcall free_matrix(void *ptr)
{
__int64 v1; // rbx

if ( ptr )
{
if ( *((int *)ptr + 2) > 0 )
{
v1 = 0LL;
do
free(*(void **)(*(_QWORD *)ptr + 8 * v1++));
while ( *((_DWORD *)ptr + 2) > (int)v1 );
}
free(*(void **)ptr);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
__int64 v1; // rbx

if ( ptr )
{
if ( *((int *)ptr + 2) > 0 )
{
v1 = 0LL;
do
free(*(void **)(*(_QWORD *)ptr + 8 * v1++));
while ( *((_DWORD *)ptr + 2) > (int)v1 );
}
free(*(void **)ptr);
free(ptr);
}
}

original_code:
void free_matrix(t_matrix* m)
{
 int i;
 if(m == ((void *)0)) return;
 for (i=0; i< m->rows; i++)
 {
  free(m->values[i]);
 }
 free(m->values);
 free(m);
}

canonical_original_code:
void free_matrix(struct matrix *m)
{
 int i;
 if(m == ((void *)0)) return;
 for (i=0; i< m->rows; i++)
 {
  free(m->values[i]);
 }
 free(m->values);
 free(m);
}


original_code:
void print_matrix(t_matrix* m)
{
 int i,j;
 t_element* row;
 char* labels[m->columns];
 printf("\n");
 for(i=0; i < m->rows; i++)
 {
  for(j=0; j< m->columns; j++)
  {
   if(m->values[i][j].dest_state != ((void *)0)){
    printf("%s ", m->values[i][j].dest_state->name);
    row = m->values[i][j].source_state;
    labels[j] = m->values[i][j].name;
   }
   else
    printf("--");
  }
  printf(" | %i, %s\n", row->index, row->name);
 }
 for(j=0; j< m->columns; j++)
 {
  printf("_");
 }
 printf("\n");
  for(j=0; j< m->columns; j++)
 {
  printf(" %s ", labels[j]);
 }
 printf("\n");
}

canonical_original_code:
void print_matrix(struct matrix *m)
{
 int i; int j;
 struct element *row;
 char *labels[-1];
 printf("\n");
 for(i=0; i < m->rows; i++)
 {
  for(j=0; j< m->columns; j++)
  {
   if(m->values[i][j].dest_state != ((void *)0)){
    printf("%s ", m->values[i][j].dest_state->name);
    row = m->values[i][j].source_state;
    labels[j] = m->values[i][j].name;
   }
   else
    printf("--");
  }
  printf(" | %i, %s\n", row->index, row->name);
 }
 for(j=0; j< m->columns; j++)
 {
  printf("_");
 }
 printf("\n");
  for(j=0; j< m->columns; j++)
 {
  printf(" %s ", labels[j]);
 }
 printf("\n");
}

variable_types:
labels
char *[-1]


repo: quiteconfused/CatImageInfo

decompiled_code:
__int64 __fastcall parse_client(int fd, struct in_addr *a2, unsigned int a3)
{
char *v4; // rax
char *v5; // r13
char *v6; // rax
size_t v7; // rax
__int64 v9[3]; // [rsp+0h] [rbp-698h] BYREF
int v10; // [rsp+18h] [rbp-680h]
__int16 v11; // [rsp+1Ch] [rbp-67Ch]
time_t timer; // [rsp+28h] [rbp-670h] BYREF
char buf[1640]; // [rsp+30h] [rbp-668h] BYREF

timer = time(0LL);
v9[0] = 0LL;
v9[1] = 0LL;
v9[2] = 0LL;
v10 = 0;
v11 = 0;
memset(buf, 0, 0x640uLL);
if ( (int)read(fd, buf, 0x640uLL) < 0 )
{
printf("Error reading from socket");
}
else
{
v4 = ctime(&timer);
strncpy((char *)v9, v4, 0x1EuLL);
v5 = strtok((char *)v9, "\n");
v6 = inet_ntoa(a2[1]);
printf("[0x%08x], [%s], [%s], [%s]\n", a3, v5, v6, buf);
fflush(_bss_start);
fflush(_bss_start);
memset(buf, 0, 0x640uLL);
sprintf(buf, "Message Key: %d accepted\n", a3);
v7 = strlen(buf);
if ( (int)write(fd, buf, v7) < 0 )
printf("Error writing to socket");
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(int fd, struct in_addr *a2, unsigned int a3)
{
char *v4; // rax
char *v5; // r13
char *v6; // rax
size_t v7; // rax
__int64 v9[3]; // [rsp+0h] [rbp-698h] BYREF
int v10; // [rsp+18h] [rbp-680h]
__int16 v11; // [rsp+1Ch] [rbp-67Ch]
time_t timer; // [rsp+28h] [rbp-670h] BYREF
char buf[1640]; // [rsp+30h] [rbp-668h] BYREF

timer = time(0LL);
v9[0] = 0LL;
v9[1] = 0LL;
v9[2] = 0LL;
v10 = 0;
v11 = 0;
memset(buf, 0, 0x640uLL);
if ( (int)read(fd, buf, 0x640uLL) < 0 )
{
printf("Error reading from socket");
}
else
{
v4 = ctime(&timer);
strncpy((char *)v9, v4, 0x1EuLL);
v5 = strtok((char *)v9, "\n");
v6 = inet_ntoa(a2[1]);
printf("[0x%08x], [%s], [%s], [%s]\n", a3, v5, v6, buf);
fflush(_bss_start);
fflush(_bss_start);
memset(buf, 0, 0x640uLL);
sprintf(buf, "Message Key: %d accepted\n", a3);
v7 = strlen(buf);
if ( (int)write(fd, buf, v7) < 0 )
printf("Error writing to socket");
}
return 0LL;
}

original_code:
unsigned int parse_client(int sock, struct sockaddr_in *cli_addr, unsigned int message_key){
 int n;
 char buffer[1600];
 time_t times = time(((void *)0));
 char date[30]={0};
 char *date_copy=((void *)0);
 bzero(buffer,1600);
 n = read(sock,buffer,1600);
 if (n < 0){
  printf("Error reading from socket");
  return 0;
 }
 strncpy(date, ctime(&times), 30);
 date_copy = strtok(date, "\n");
 printf("[0x%08x], [%s], [%s], [%s]\n", message_key, date_copy, inet_ntoa(cli_addr->sin_addr), buffer); fflush(stdout);
 fflush(stdout);
 memset(buffer, 0, 1600);
 sprintf(buffer, "Message Key: %d accepted\n", message_key);
 n = write(sock,buffer,strlen(buffer));
 if (n < 0){
  printf("Error writing to socket");
 }
 return 0;
}

canonical_original_code:
unsigned int parse_client(int sock, struct sockaddr_in *cli_addr, unsigned int message_key){
 int n;
 char buffer[1600];
 long times = time(((void *)0));
 char date[30] = {0};
 char *date_copy = ((void *)0);
 bzero(buffer,1600);
 n = read(sock,buffer,1600);
 if (n < 0){
  printf("Error reading from socket");
  return 0;
 }
 strncpy(date, ctime(&times), 30);
 date_copy = strtok(date, "\n");
 printf("[0x%08x], [%s], [%s], [%s]\n", message_key, date_copy, inet_ntoa(cli_addr->sin_addr), buffer); fflush(stdout);
 fflush(stdout);
 memset(buffer, 0, 1600);
 sprintf(buffer, "Message Key: %d accepted\n", message_key);
 n = write(sock,buffer,strlen(buffer));
 if (n < 0){
  printf("Error writing to socket");
 }
 return 0;
}

variable_types: sock int

variable_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } *

variable_types: n int

variable_types:
buffer
char [1600]

variable_types: times long

variable_types:
date
char [30]

return_type: unsigned int

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }


decompiled_code:
int __fastcall print_usage(const char **a1)
{
return printf("Usage: %s <port>\n", *a1);
}

canonical_decompiled_code:
int __fastcall func8(const char **a1)
{
return printf("Usage: %s <port>\n", *a1);
}

original_code:
void print_usage(char** argv){
 printf("Usage: %s <port>\n", argv[0]);
}

canonical_original_code:
void print_usage(char **argv){
 printf("Usage: %s <port>\n", argv[0]);
}

variable_types:
argv
char **


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
unsigned int v4; // ebx
unsigned int v5; // er12
int v6; // ebx
__pid_t v7; // eax
struct sockaddr v8; // [rsp+0h] [rbp-48h] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-38h] BYREF
socklen_t addr_len[7]; // [rsp+2Ch] [rbp-1Ch] BYREF

signal(17, (__sighandler_t)1);
if ( argc > 0 )
{
v3 = socket(2, 1, 0);
if ( v3 >= 0 )
{
*(_QWORD *)&addr.sa_family = 0LL;
*(_QWORD *)&addr.sa_data[6] = 0LL;
v4 = atoi(argv[1]);
addr.sa_family = 2;
*(_WORD *)addr.sa_data = _bswap_16(v4);
if ( bind(v3, &addr, 0x10u) >= 0 )
{
listen(v3, 5);
addr_len[0] = 16;
v5 = 0;
while ( 1 )
{
v6 = accept(v3, &v8, addr_len);
++v5;
if ( v6 < 0 )
break;
v7 = fork();
if ( v7 < 0 )
{
puts("Error on fork");
exit(1);
}
if ( !v7 )
{
close(v3);
parse_client(v6, (struct in_addr *)&v8, v5);
exit(0);
}
close(v6);
}
puts("Error on accept");
exit(1);
}
printf("Error binding socket on port %d\n", v4);
exit(1);
}
puts("Error opening socket");
exit(1);
}
print_usage(argv);
exit(1);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
unsigned int v4; // ebx
unsigned int v5; // er12
int v6; // ebx
__pid_t v7; // eax
struct sockaddr v8; // [rsp+0h] [rbp-48h] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-38h] BYREF
socklen_t addr_len[7]; // [rsp+2Ch] [rbp-1Ch] BYREF

signal(17, (__sighandler_t)1);
if ( argc > 0 )
{
v3 = socket(2, 1, 0);
if ( v3 >= 0 )
{
*(_QWORD *)&addr.sa_family = 0LL;
*(_QWORD *)&addr.sa_data[6] = 0LL;
v4 = atoi(argv[1]);
addr.sa_family = 2;
*(_WORD *)addr.sa_data = func7(v4);
if ( bind(v3, &addr, 0x10u) >= 0 )
{
listen(v3, 5);
addr_len[0] = 16;
v5 = 0;
while ( 1 )
{
v6 = accept(v3, &v8, addr_len);
++v5;
if ( v6 < 0 )
break;
v7 = fork();
if ( v7 < 0 )
{
puts("Error on fork");
exit(1);
}
if ( !v7 )
{
close(v3);
func9(v6, (struct in_addr *)&v8, v5);
exit(0);
}
close(v6);
}
puts("Error on accept");
exit(1);
}
printf("Error binding socket on port %d\n", v4);
exit(1);
}
puts("Error opening socket");
exit(1);
}
func8(argv);
exit(1);
}

original_code:
int main(int argc, char** argv){
     int sockfd, newsockfd, portno;
     socklen_t clilen;
     char buffer[256];
     struct sockaddr_in serv_addr, cli_addr;
     int n;
     pid_t pid;
     unsigned int message_key=0;
 signal(17, ((__sighandler_t) 1));
 if(argc<1){
  print_usage(argv);
  exit(1);
 }
 sockfd = socket(2, SOCK_STREAM, 0);
 if (sockfd < 0) {
  printf("Error opening socket\n");
  exit(1);
 }
     bzero((char *) &serv_addr, sizeof(serv_addr));
     portno = atoi(argv[1]);
     serv_addr.sin_family = 2;
     serv_addr.sin_addr.s_addr = ((in_addr_t) 0x00000000);
     serv_addr.sin_port = htons(portno);
     if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0){
      printf("Error binding socket on port %d\n", portno);
      exit(1);
     }
     listen(sockfd,5);
     clilen = sizeof(struct sockaddr_in);
     while (1) {
         newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
         message_key++;
         if (newsockfd < 0){
             printf("Error on accept\n");
             exit(1);
         }
         pid = fork();
         if (pid < 0){
             printf("Error on fork\n");
             exit(1);
         }
         if (pid == 0) {
             close(sockfd);
             parse_client(newsockfd, &cli_addr, message_key);
             exit(0);
         }
         else{
          close(newsockfd);
         }
     }
     close(sockfd);
     return 0;
}

canonical_original_code:
int main(int argc, char **argv){
     int sockfd; int newsockfd; int portno;
     unsigned int clilen;
     char buffer[256];
     struct sockaddr_in serv_addr; struct sockaddr_in cli_addr;
     int n;
     int pid;
     unsigned int message_key = 0;
 signal(17, ((void (*)(int)) 1));
 if(argc<1){
  print_usage(argv);
  exit(1);
 }
 sockfd = socket(2, SOCK_STREAM, 0);
 if (sockfd < 0) {
  printf("Error opening socket\n");
  exit(1);
 }
     bzero((char *) &serv_addr, sizeof(serv_addr));
     portno = atoi(argv[1]);
     serv_addr.sin_family = 2;
     serv_addr.sin_addr.s_addr = ((unsigned int) 0x00000000);
     serv_addr.sin_port = htons(portno);
     if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0){
      printf("Error binding socket on port %d\n", portno);
      exit(1);
     }
     listen(sockfd,5);
     clilen = sizeof(struct sockaddr_in);
     while (1) {
         newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
         message_key++;
         if (newsockfd < 0){
             printf("Error on accept\n");
             exit(1);
         }
         pid = fork();
         if (pid < 0){
             printf("Error on fork\n");
             exit(1);
         }
         if (pid == 0) {
             close(sockfd);
             parse_client(newsockfd, &cli_addr, message_key);
             exit(0);
         }
         else{
          close(newsockfd);
         }
     }
     close(sockfd);
     return 0;
}

variable_types: sockfd int

variable_types: newsockfd int

variable_types: portno int

variable_types:
clilen
unsigned int

variable_types:
buffer
char [256]

variable_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; }

variable_types: pid int

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }


decompiled_code:
int __fastcall wserver_init(struct sockaddr *addr, __int16 a2, __int64 a3)
{
int v4; // eax
int result; // eax

addr->sa_family = 2;
*(_DWORD *)&addr->sa_data[2] = _bswap_32(0);
*(_WORD *)addr->sa_data = _bswap_16(a2);
*(_QWORD *)&addr[1].sa_data[6] = a3;
v4 = socket(2, 1, 0);
*(_DWORD *)&addr[1].sa_family = v4;
if ( v4 < 0 )
{
perror("Creation socket error");
exit(1);
}
result = bind(v4, addr, 0x10u);
if ( result )
{
perror("Bind error");
exit(1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func9(struct sockaddr *addr, __int16 a2, __int64 a3)
{
int v4; // eax
int result; // eax

addr->sa_family = 2;
*(_DWORD *)&addr->sa_data[2] = func7(0);
*(_WORD *)addr->sa_data = func8(a2);
*(_QWORD *)&addr[1].sa_data[6] = a3;
v4 = socket(2, 1, 0);
*(_DWORD *)&addr[1].sa_family = v4;
if ( v4 < 0 )
{
perror("Creation socket error");
exit(1);
}
result = bind(v4, addr, 0x10u);
if ( result )
{
perror("Bind error");
exit(1);
}
return result;
}

original_code:
void wserver_init(wserver* self, int port, client_handler handler)
{
    self->serv_addr.sin_family = 2;
    self->serv_addr.sin_addr.s_addr = htonl(((in_addr_t) 0x00000000));
    self->serv_addr.sin_port = htons(port);
    self->handler = handler;
    self->listenfd = socket(2, SOCK_STREAM, 0);
    if (self->listenfd < 0) {
        do { perror("Creation socket error"); exit(1); } while (0);
    }
    if (bind(self->listenfd, (struct sockaddr*)&self->serv_addr, sizeof(self->serv_addr))) {
        do { perror("Bind error"); exit(1); } while (0);
    }
}

canonical_original_code:
void wserver_init(struct _wserver *self, int port, void *(*handler)(void *socket))
{
    self->serv_addr.sin_family = 2;
    self->serv_addr.sin_addr.s_addr = htonl(((unsigned int) 0x00000000));
    self->serv_addr.sin_port = htons(port);
    self->handler = handler;
    self->listenfd = socket(2, SOCK_STREAM, 0);
    if (self->listenfd < 0) {
        do { perror("Creation socket error"); exit(1); } while (0);
    }
    if (bind(self->listenfd, (struct sockaddr *)&self->serv_addr, sizeof(self->serv_addr))) {
        do { perror("Bind error"); exit(1); } while (0);
    }
}

variable_types: struct _wserver { struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } serv_addr; int listenfd; void *(*handler)(void *socket); int running; } *

variable_types: port int

variable_types:
handler
void *(*)(void *socket)

user_defined_types: struct _wserver { struct sockaddr_in serv_addr; int listenfd; void *(*handler)(void *socket); int running; }


decompiled_code:
int __fastcall wserver_finalize(__int64 a1)
{
return close(*(_DWORD *)(a1 + 16));
}

canonical_decompiled_code:
int __fastcall func10(__int64 a1)
{
return close(*(_DWORD *)(a1 + 16));
}

original_code:
void wserver_finalize(wserver* self)
{
    close(self->listenfd);
}

canonical_original_code:
void wserver_finalize(struct _wserver *self)
{
    close(self->listenfd);
}


decompiled_code:
void __fastcall wserver_stop(__int64 a1)
{
*(_DWORD *)(a1 + 32) = 0;
}

original_code:
void wserver_stop(wserver* self)
{
    self->running = 0;
}

canonical_original_code:
void wserver_stop(struct _wserver *self)
{
    self->running = 0;
}


decompiled_code:
int __fastcall wserver_new_task(__int64 a1, int a2)
{
_DWORD *v2; // rbx
int result; // eax
pthread_t newthread; // [rsp+8h] [rbp-60h] BYREF
pthread_attr_t attr; // [rsp+10h] [rbp-58h] BYREF

v2 = malloc(4uLL);
*v2 = a2;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, 1);
result = pthread_create(&newthread, &attr, *(void *(**)(void *))(a1 + 24), v2);
if ( result )
{
perror("Create thread failed");
exit(1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func12(__int64 a1, int a2)
{
_DWORD *v2; // rbx
int result; // eax
pthread_t newthread; // [rsp+8h] [rbp-60h] BYREF
pthread_attr_t attr; // [rsp+10h] [rbp-58h] BYREF

v2 = malloc(4uLL);
*v2 = a2;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, 1);
result = pthread_create(&newthread, &attr, *(void *(**)(void *))(a1 + 24), v2);
if ( result )
{
perror("Create thread failed");
exit(1);
}
return result;
}

original_code:
void wserver_new_task(wserver* self, int connfd) {
    int* param;
    param = malloc(sizeof(int));
    *param = connfd;
    pthread_attr_t attr;
    pthread_t tid;
    pthread_attr_init(&attr);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
    if (pthread_create(&tid, &attr, self->handler, param)) {
        do { perror("Create thread failed"); exit(1); } while (0);
    }
}

canonical_original_code:
void wserver_new_task(struct _wserver *self, int connfd) {
    int *param;
    param = malloc(sizeof(int));
    *param = connfd;
    union pthread_attr_t attr;
    unsigned long tid;
    pthread_attr_init(&attr);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
    if (pthread_create(&tid, &attr, self->handler, param)) {
        do { perror("Create thread failed"); exit(1); } while (0);
    }
}

variable_types: connfd int

variable_types:
param
int *

variable_types: union pthread_attr_t { char __size[56]; long __align; }

variable_types:
tid
unsigned long


decompiled_code:
unsigned int __fastcall wserver_listen(__int64 a1)
{
int v1; // eax
unsigned int result; // eax
struct sockaddr v3; // [rsp+0h] [rbp-28h] BYREF
socklen_t addr_len[3]; // [rsp+1Ch] [rbp-Ch] BYREF

listen(*(_DWORD *)(a1 + 16), 100);
*(_DWORD *)(a1 + 32) = 1;
do
{
addr_len[0] = 16;
v1 = accept(*(_DWORD *)(a1 + 16), &v3, addr_len);
wserver_new_task(a1, v1);
result = sleep(1u);
}
while ( *(_DWORD *)(a1 + 32) );
return result;
}

canonical_decompiled_code:
unsigned int __fastcall func13(__int64 a1)
{
int v1; // eax
unsigned int result; // eax
struct sockaddr v3; // [rsp+0h] [rbp-28h] BYREF
socklen_t addr_len[3]; // [rsp+1Ch] [rbp-Ch] BYREF

listen(*(_DWORD *)(a1 + 16), 100);
*(_DWORD *)(a1 + 32) = 1;
do
{
addr_len[0] = 16;
v1 = accept(*(_DWORD *)(a1 + 16), &v3, addr_len);
func12(a1, v1);
result = sleep(1u);
}
while ( *(_DWORD *)(a1 + 32) );
return result;
}

original_code:
void wserver_listen(wserver* self)
{
    int connfd;
    socklen_t client_len;
    struct sockaddr_in client_addr;
    listen(self->listenfd, 100);
    self->running = 1;
    while (self->running)
    {
        client_len = sizeof(client_addr);
        connfd = accept(self->listenfd, (struct sockaddr *)&client_addr, &client_len);
        wserver_new_task(self, connfd);
        sleep(1);
    }
}

canonical_original_code:
void wserver_listen(struct _wserver *self)
{
    int connfd;
    unsigned int client_len;
    struct sockaddr_in client_addr;
    listen(self->listenfd, 100);
    self->running = 1;
    while (self->running)
    {
        client_len = sizeof(client_addr);
        connfd = accept(self->listenfd, (struct sockaddr *)&client_addr, &client_len);
        wserver_new_task(self, connfd);
        sleep(1);
    }
}


decompiled_code:
ssize_t __fastcall write_bad_request(int a1)
{
return write(
a1,
"HTTP/1.1 400 Bad Request\r\n"
"Content-Type: text/html; charset=UTF-8\r\n"
"Connection: close\r\n"
"\r\n"
"
Bad Request
\r\n",
0x6DuLL);
}

canonical_decompiled_code:
ssize_t __fastcall func14(int a1)
{
return write(
a1,
"HTTP/1.1 400 Bad Request\r\n"
"Content-Type: text/html; charset=UTF-8\r\n"
"Connection: close\r\n"
"\r\n"
"
Bad Request
\r\n",
0x6DuLL);
}

original_code:
void write_bad_request(int sock)
{
    static const char bad_response_msg[] =
        "HTTP/1.1 400 Bad Request\r\nContent-Type: text/html; charset=UTF-8\r\nConnection: close\r\n\r\n
Bad Request
\r\n";
    write(sock, bad_response_msg, strlen(bad_response_msg));
}

canonical_original_code:
void write_bad_request(int sock)
{
    static char bad_response_msg[] = "HTTP/1.1 400 Bad Request\r\nContent-Type: text/html; charset=UTF-8\r\nConnection: close\r\n\r\n
Bad Request
\r\n";
    write(sock, bad_response_msg, strlen(bad_response_msg));
}

variable_types: sock int


decompiled_code:
__int64 __fastcall client_connect(char *name, __int16 a2)
{
int v2; // eax
unsigned int v3; // ebx
struct hostent *v4; // rax
struct sockaddr dest[2]; // [rsp+0h] [rbp-28h] BYREF

v2 = socket(2, 1, 0);
if ( v2 < 0 )
{
perror("Creation socket failed");
exit(1);
}
v3 = v2;
v4 = gethostbyname(name);
if ( !v4 )
{
perror("Hostname error");
exit(1);
}
*(_QWORD *)&dest[0].sa_family = 2LL;
*(_QWORD *)&dest[0].sa_data[6] = 0LL;
memmove(&dest[0].sa_data[2], *(const void **)v4->h_addr_list, v4->h_length);
*(_WORD *)dest[0].sa_data = _bswap_16(a2);
if ( connect(v3, dest, 0x10u) < 0 )
{
perror("Connection error");
exit(1);
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func8(char *name, __int16 a2)
{
int v2; // eax
unsigned int v3; // ebx
struct hostent *v4; // rax
struct sockaddr dest[2]; // [rsp+0h] [rbp-28h] BYREF

v2 = socket(2, 1, 0);
if ( v2 < 0 )
{
perror("Creation socket failed");
exit(1);
}
v3 = v2;
v4 = gethostbyname(name);
if ( !v4 )
{
perror("Hostname error");
exit(1);
}
*(_QWORD *)&dest[0].sa_family = 2LL;
*(_QWORD *)&dest[0].sa_data[6] = 0LL;
memmove(&dest[0].sa_data[2], *(const void **)v4->h_addr_list, v4->h_length);
*(_WORD *)dest[0].sa_data = func7(a2);
if ( connect(v3, dest, 0x10u) < 0 )
{
perror("Connection error");
exit(1);
}
return v3;
}

original_code:
int client_connect(const char * hostname, int port)
{
    struct sockaddr_in serv_addr;
    struct hostent *server;
    int sockfd = socket(2, SOCK_STREAM, 0);
    if (sockfd < 0) {
        do { perror("Creation socket failed"); exit(1); } while (0);
    }
    server = gethostbyname(hostname);
    if (server == ((void *)0)) {
        do { perror("Hostname error"); exit(1); } while (0);
    }
    bzero((char *) &serv_addr, sizeof(serv_addr));
    serv_addr.sin_family = 2;
    bcopy((char *)server->h_addr_list[0], (char *)&serv_addr.sin_addr.s_addr, server->h_length);
    serv_addr.sin_port = htons(port);
    if (connect(sockfd, (struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0) {
        do { perror("Connection error"); exit(1); } while (0);
    }
    return sockfd;
}

canonical_original_code:
int client_connect(char *hostname, int port)
{
    struct sockaddr_in serv_addr;
    struct hostent *server;
    int sockfd = socket(2, SOCK_STREAM, 0);
    if (sockfd < 0) {
        do { perror("Creation socket failed"); exit(1); } while (0);
    }
    server = gethostbyname(hostname);
    if (server == ((void *)0)) {
        do { perror("Hostname error"); exit(1); } while (0);
    }
    bzero((char *) &serv_addr, sizeof(serv_addr));
    serv_addr.sin_family = 2;
    bcopy((char *)server->h_addr_list[0], (char *)&serv_addr.sin_addr.s_addr, server->h_length);
    serv_addr.sin_port = htons(port);
    if (connect(sockfd, (struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0) {
        do { perror("Connection error"); exit(1); } while (0);
    }
    return sockfd;
}

variable_types:
hostname
char *

variable_types: struct hostent { char *h_name; char **h_aliases; int h_addrtype; int h_length; char **h_addr_list; } *


decompiled_code:
ssize_t __fastcall client_getfile(int fd, const char *a2, const char *a3)
{
int v3; // eax
ssize_t result; // rax
char v5[1032]; // [rsp+0h] [rbp-408h] BYREF

v3 = snprintf(v5, 0x3FFuLL, "GET /%s HTTP/1.1\r\nHost: %s\r\n\r\n", a2, a3);
write(fd, v5, v3);
while ( 1 )
{
result = read(fd, v5, 0x3FFuLL);
if ( (int)result <= 0 )
break;
v5[(int)result] = 0;
fputs(v5, stdout);
}
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func9(int fd, const char *a2, const char *a3)
{
int v3; // eax
ssize_t result; // rax
char v5[1032]; // [rsp+0h] [rbp-408h] BYREF

v3 = snprintf(v5, 0x3FFuLL, "GET /%s HTTP/1.1\r\nHost: %s\r\n\r\n", a2, a3);
write(fd, v5, v3);
while ( 1 )
{
result = read(fd, v5, 0x3FFuLL);
if ( (int)result <= 0 )
break;
v5[(int)result] = 0;
fputs(v5, stdout);
}
return result;
}

original_code:
void client_getfile(int sock, const char* file, const char* hostname) {
    int n;
    char buf[1024];
    int writen = snprintf(buf, sizeof(buf) - 1, "GET /%s HTTP/1.1\r\nHost: %s\r\n\r\n", file, hostname);
    write(sock, buf, writen);
    while ( (n = read(sock, buf, sizeof(buf) - 1) ) > 0 )
    {
        buf[n] = 0;
        fputs(buf, stdout);
    }
}

canonical_original_code:
void client_getfile(int sock, char *file, char *hostname) {
    int n;
    char buf[1024];
    int writen = snprintf(buf, sizeof(buf) - 1, "GET /%s HTTP/1.1\r\nHost: %s\r\n\r\n", file, hostname);
    write(sock, buf, writen);
    while ( (n = read(sock, buf, sizeof(buf) - 1) ) > 0 )
    {
        buf[n] = 0;
        fputs(buf, stdout);
    }
}

variable_types:
file
char *

variable_types: n int

variable_types:
buf
char [1024]

variable_types: writen int


decompiled_code:
int __fastcall client_disconnect(int a1)
{
return close(a1);
}

canonical_decompiled_code:
int __fastcall func10(int a1)
{
return close(a1);
}

original_code:
void client_disconnect(int sockfd)
{
    close(sockfd);
}

variable_types: sockfd int


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int16 v3; // ax
int v4; // ebp

if ( argc <= 3 )
{
fwrite("Usage: get <hostname> <port> <file>", 1uLL, 0x23uLL, stderr);
exit(1);
}
v3 = atoi(argv[2]);
v4 = client_connect((char *)argv[1], v3);
client_getfile(v4, argv[3], argv[1]);
client_disconnect(v4);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int16 v3; // ax
int v4; // ebp

if ( argc <= 3 )
{
fwrite("Usage: get <hostname> <port> <file>", 1uLL, 0x23uLL, stderr);
exit(1);
}
v3 = atoi(argv[2]);
v4 = func8((char *)argv[1], v3);
func9(v4, argv[3], argv[1]);
func10(v4);
return 0;
}

original_code:
int main(int argc, char *argv[])
{
    int sockfd;
    if (argc < 4) {
        fputs("Usage: get <hostname> <port> <file>", stderr);
        exit(1);
    }
    sockfd = client_connect(argv[1], atoi(argv[2]));
    client_getfile(sockfd, argv[3], argv[1]);
    client_disconnect(sockfd);
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]


configureOptions

repo: qwc/cmdlineoptions

decompiled_code:
__int64 configureOptions()
{
CmdLO_Init();
CmdLO_Add();
CmdLO_Add();
return CmdLO_AddDescription();
}

canonical_decompiled_code:
__int64 func7()
{
CmdLO_Init();
CmdLO_Add();
CmdLO_Add();
return CmdLO_AddDescription();
}

original_code:
void configureOptions() {
 CmdLO_Init(1);
 CmdLO_Add("test","--test");
 CmdLO_Add("test","-t");
 CmdLO_AddDescription("test", "This is a test Option.");
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
configureOptions(argc, argv, envp);
CmdLO_Parse();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func7(argc, argv, envp);
CmdLO_Parse();
return 0;
}

original_code:
int main(int argc, char** argv) {
 configureOptions();
 CmdLO_Parse(argc,argv);
}

canonical_original_code:
int main(int argc, char **argv) {
 configureOptions();
 CmdLO_Parse(argc,argv);
}

variable_types:
argv
char **


decompiled_code:
__int64 CmdLO_IsSet()
{
return (unsigned int)*(char *)(*(_QWORD *)(CmdLO_Create() + 8) + 76LL);
}

canonical_decompiled_code:
__int64 func2()
{
return (unsigned int)*(char *)(*(_QWORD *)(CmdLO_Create() + 8) + 76LL);
}

original_code:
int CmdLO_IsSet(char* name) {
 CONode* node = CmdLO_Create(name);
 return node->option->set;
}

canonical_original_code:
int CmdLO_IsSet(char *name) {
 struct _CONode *node = CmdLO_Create(name);
 return node->option->set;
}

variable_types:
name
char *

variable_types: struct _CONode { struct _CONode *next; struct _Option { char *name; char **options; unsigned int optionscount; char **possibleparameters; unsigned int possibleparametercount; char *description; char **defaultparameters; unsigned int defaultparametercount; char **values; unsigned int valuecount; char set; } *option; } *

user_defined_types: struct _CONode { struct _CONode *next; struct _Option *option; }


decompiled_code:
__int64 __fastcall CmdLO_Get(__int64 a1)
{
__int64 v1; // rbp
int v2; // edx
__int64 result; // rax
__int64 v4; // rdx

v1 = CmdLO_Create();
v2 = CmdLO_IsSet(a1);
result = 0LL;
if ( v2 )
{
v4 = *(_QWORD *)(v1 + 8);
if ( *(_DWORD *)(v4 + 72) )
result = **(_QWORD **)(v4 + 64);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 v1; // rbp
int v2; // edx
__int64 result; // rax
__int64 v4; // rdx

v1 = CmdLO_Create();
v2 = func2(a1);
result = 0LL;
if ( v2 )
{
v4 = *(_QWORD *)(v1 + 8);
if ( *(_DWORD *)(v4 + 72) )
result = **(_QWORD **)(v4 + 64);
}
return result;
}

original_code:
char* CmdLO_Get(char* name) {
 CONode* node = CmdLO_Create(name);
 if (CmdLO_IsSet(name) && node->option->valuecount > 0)
  return node->option->values[0];
 return 0;
}

canonical_original_code:
char *CmdLO_Get(char *name) {
 struct _CONode *node = CmdLO_Create(name);
 if (CmdLO_IsSet(name) && node->option->valuecount > 0)
  return node->option->values[0];
 return 0;
}

return_type: char *

user_defined_types: struct _Option { char *name; char **options; unsigned int optionscount; char **possibleparameters; unsigned int possibleparametercount; char *description; char **defaultparameters; unsigned int defaultparametercount; char **values; unsigned int valuecount; char set; }


decompiled_code:
int CmdLO_GetInt()
{
const char *v0; // rax

v0 = (const char *)CmdLO_Get();
return atoi(v0);
}

canonical_decompiled_code:
int func4()
{
const char *v0; // rax

v0 = (const char *)func3();
return atoi(v0);
}

original_code:
int CmdLO_GetInt(char* name) {
 return atoi(CmdLO_Get(name));
}

canonical_original_code:
int CmdLO_GetInt(char *name) {
 return atoi(CmdLO_Get(name));
}


decompiled_code:
__int64 CmdLO_GetLong()
{
const char *v0; // rax

v0 = (const char *)CmdLO_Get();
return atol(v0);
}

canonical_decompiled_code:
__int64 func5()
{
const char *v0; // rax

v0 = (const char *)func3();
return atol(v0);
}

original_code:
long CmdLO_GetLong(char* name) {
 return atol(CmdLO_Get(name));
}

canonical_original_code:
long CmdLO_GetLong(char *name) {
 return atol(CmdLO_Get(name));
}

return_type: long


decompiled_code:
double CmdLO_GetDouble()
{
const char *v0; // rax

v0 = (const char *)CmdLO_Get();
return atof(v0);
}

canonical_decompiled_code:
double func6()
{
const char *v0; // rax

v0 = (const char *)func3();
return atof(v0);
}

original_code:
double CmdLO_GetDouble(char* name) {
 return atof(CmdLO_Get(name));
}

canonical_original_code:
double CmdLO_GetDouble(char *name) {
 return atof(CmdLO_Get(name));
}

return_type: double


decompiled_code:
__int64 __fastcall CmdLO_GetAll(__int64 a1, __int64 a2, _DWORD *a3)
{
__int64 v4; // rax

v4 = CmdLO_Create();
if ( !v4 )
return 1LL;
*a3 = *(_DWORD *)(*(_QWORD *)(v4 + 8) + 72LL);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, _DWORD *a3)
{
__int64 v4; // rax

v4 = CmdLO_Create();
if ( !v4 )
return 1LL;
*a3 = *(_DWORD *)(*(_QWORD *)(v4 + 8) + 72LL);
return 0LL;
}

original_code:
int CmdLO_GetAll(char* name, char** values, unsigned int* count) {
 CONode* node = CmdLO_Create(name);
 if (node == 0)
  return 1;
 values = node->option->values;
 *count = node->option->valuecount;
 return 0;
}

canonical_original_code:
int CmdLO_GetAll(char *name, char **values, unsigned int *count) {
 struct _CONode *node = CmdLO_Create(name);
 if (node == 0)
  return 1;
 values = node->option->values;
 *count = node->option->valuecount;
 return 0;
}

variable_types:
values
char **

variable_types:
count
unsigned int *


decompiled_code:
void __fastcall CmdLO_AddElement(void **a1, unsigned int *a2, const char *a3)
{
void *v4; // r14
unsigned int v5; // er15
_QWORD *v6; // rax
_QWORD *v7; // rbp
__int64 v8; // r13
size_t v9; // rax
size_t v10; // rax
size_t v11; // rax
void *v12; // r13
size_t v13; // rax
unsigned int dest; // [rsp+8h] [rbp-40h]
void *desta; // [rsp+8h] [rbp-40h]

v4 = *a1;
dest = *a2;
v5 = *a2 + 1;
v6 = malloc(8LL * v5);
v7 = v6;
*a1 = v6;
if ( v4 )
{
v8 = dest;
memcpy(v6, v4, 8LL * dest);
v9 = strlen(a3);
desta = malloc(v9 + 1);
v7[v8] = desta;
v10 = strlen(a3);
memcpy(desta, a3, v10 + 1);
free(v4);
}
else
{
v11 = strlen(a3);
v12 = malloc(v11 + 1);
v7[dest] = v12;
v13 = strlen(a3);
memcpy(v12, a3, v13 + 1);
}
*a2 = v5;
}

canonical_decompiled_code:
void __fastcall func8(void **a1, unsigned int *a2, const char *a3)
{
void *v4; // r14
unsigned int v5; // er15
_QWORD *v6; // rax
_QWORD *v7; // rbp
__int64 v8; // r13
size_t v9; // rax
size_t v10; // rax
size_t v11; // rax
void *v12; // r13
size_t v13; // rax
unsigned int dest; // [rsp+8h] [rbp-40h]
void *desta; // [rsp+8h] [rbp-40h]

v4 = *a1;
dest = *a2;
v5 = *a2 + 1;
v6 = malloc(8LL * v5);
v7 = v6;
*a1 = v6;
if ( v4 )
{
v8 = dest;
memcpy(v6, v4, 8LL * dest);
v9 = strlen(a3);
desta = malloc(v9 + 1);
v7[v8] = desta;
v10 = strlen(a3);
memcpy(desta, a3, v10 + 1);
free(v4);
}
else
{
v11 = strlen(a3);
v12 = malloc(v11 + 1);
v7[dest] = v12;
v13 = strlen(a3);
memcpy(v12, a3, v13 + 1);
}
*a2 = v5;
}

original_code:
void CmdLO_AddElement(char*** target, unsigned int* counter, char* element) {
 unsigned int cnt = *counter;
 char** old = 0;
 if (*target != 0)
  old = *target;
 *target = malloc((cnt + 1) * sizeof(char*));
 if (old != 0)
  memcpy(*target, old, (cnt) * sizeof(char*));
 *(*target + cnt) = malloc((strlen(element) + 1) * sizeof(char));
 memcpy(*(*target + cnt), element, strlen(element) + 1);
 if (old != 0)
  free(old);
 *counter = cnt + 1;
}

canonical_original_code:
void CmdLO_AddElement(char ***target, unsigned int *counter, char *element) {
 unsigned int cnt = *counter;
 char **old = 0;
 if (*target != 0)
  old = *target;
 *target = malloc((cnt + 1) * sizeof(char *));
 if (old != 0)
  memcpy(*target, old, (cnt) * sizeof(char *));
 *(*target + cnt) = malloc((strlen(element) + 1) * sizeof(char));
 memcpy(*(*target + cnt), element, strlen(element) + 1);
 if (old != 0)
  free(old);
 *counter = cnt + 1;
}

variable_types:
target
char ***

variable_types:
counter
unsigned int *

variable_types:
element
char *

variable_types:
cnt
unsigned int

variable_types:
old
char **


decompiled_code:
__int64 CmdLO_Add()
{
CmdLO_Create();
return CmdLO_AddElement();
}

canonical_decompiled_code:
__int64 func10()
{
CmdLO_Create();
return func8();
}

original_code:
void CmdLO_Add(char* name, char* option) {
 CONode* node = CmdLO_Create(name);
 CmdLO_AddElement(&(node->option->options), &(node->option->optionscount),
   option);
}

canonical_original_code:
void CmdLO_Add(char *name, char *option) {
 struct _CONode *node = CmdLO_Create(name);
 CmdLO_AddElement(&(node->option->options), &(node->option->optionscount),
   option);
}

variable_types:
option
char *


decompiled_code:
void __fastcall CmdLO_InitCmd(char a1, char a2)
{
char v2; // al

if ( !LOBYTE(cmdoptions[0]) )
{
v2 = a2;
LOBYTE(cmdoptions[0]) = 1;
if ( !a2 )
v2 = 45;
LOBYTE(cmdoptions[2]) = v2;
if ( a1 )
{
CmdLO_Add("help", &unk_2146);
CmdLO_Add("help", "-h");
CmdLO_Add("help", "-?");
CmdLO_AddDescription("help", "Display the help text.");
}
}
}

canonical_decompiled_code:
void __fastcall func11(char a1, char a2)
{
char v2; // al

if ( !LOBYTE(cmdoptions[0]) )
{
v2 = a2;
LOBYTE(cmdoptions[0]) = 1;
if ( !a2 )
v2 = 45;
LOBYTE(cmdoptions[2]) = v2;
if ( a1 )
{
func10("help", &unk_2146);
func10("help", "-h");
func10("help", "-?");
func1("help", "Display the help text.");
}
}
}

original_code:
void CmdLO_InitCmd(char addhelp, char cmdchar) {
 if (cmdoptions.init == 0) {
  cmdoptions.init = 1;
  if (cmdchar != 0)
   cmdoptions.cmdchar = cmdchar;
  else
   cmdoptions.cmdchar = '-';
  if (addhelp != 0) {
   CmdLO_Add("help", "--help");
   CmdLO_Add("help", "-h");
   CmdLO_Add("help", "-?");
   CmdLO_AddDescription("help", "Display the help text.");
  }
 }
}

variable_types: addhelp char

variable_types: cmdchar char


decompiled_code:
__int64 __fastcall CmdLO_Init(char a1)
{
return CmdLO_InitCmd((unsigned int)a1, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func12(char a1)
{
return func11((unsigned int)a1, 0LL);
}

original_code:
void CmdLO_Init(char addhelp) {
 CmdLO_InitCmd(addhelp, 0);
}


decompiled_code:
__int64 CmdLO_AddDefaultParameter()
{
CmdLO_Create();
return CmdLO_AddElement();
}

canonical_decompiled_code:
__int64 func13()
{
CmdLO_Create();
return func8();
}

original_code:
void CmdLO_AddDefaultParameter(char* name, char* defaultparameter) {
 CONode* node = CmdLO_Create(name);
 CmdLO_AddElement(&(node->option->defaultparameters),
   &(node->option->defaultparametercount), defaultparameter);
}

canonical_original_code:
void CmdLO_AddDefaultParameter(char *name, char *defaultparameter) {
 struct _CONode *node = CmdLO_Create(name);
 CmdLO_AddElement(&(node->option->defaultparameters),
   &(node->option->defaultparametercount), defaultparameter);
}

variable_types:
defaultparameter
char *


decompiled_code:
__int64 CmdLO_AddPossibleParameter()
{
CmdLO_Create();
return CmdLO_AddElement();
}

canonical_decompiled_code:
__int64 func14()
{
CmdLO_Create();
return func8();
}

original_code:
void CmdLO_AddPossibleParameter(char* name, char* possibleParameter) {
 CONode* node = CmdLO_Create(name);
 CmdLO_AddElement(&(node->option->possibleparameters),
   &(node->option->possibleparametercount), possibleParameter);
}

canonical_original_code:
void CmdLO_AddPossibleParameter(char *name, char *possibleParameter) {
 struct _CONode *node = CmdLO_Create(name);
 CmdLO_AddElement(&(node->option->possibleparameters),
   &(node->option->possibleparametercount), possibleParameter);
}

variable_types:
possibleParameter
char *


original_code:
void CmdLO_Destroy() {
 CONode * node = cmdoptions.options;
 int i = 0;
 while (node != 0) {
  if (node->option->optionscount > 0) {
   i = 0;
   for (; i < node->option->optionscount; ++i)
    free(node->option->options[i]);
   free(node->option->options);
  }
  if (node->option->defaultparametercount > 0) {
   i = 0;
   for (; i < node->option->defaultparametercount; ++i)
    free(node->option->defaultparameters[i]);
   free(node->option->defaultparameters);
  }
  if (node->option->possibleparametercount > 0) {
   i = 0;
   for (; i < node->option->possibleparametercount; ++i)
    free(node->option->possibleparameters[i]);
   free(node->option->possibleparameters);
  }
  if (node->option->valuecount > 0) {
   i = 0;
   for (; i < node->option->valuecount; ++i)
    free(node->option->values[i]);
   free(node->option->values);
  }
  free(node->option);
  CONode* old = node;
  node = node->next;
  free(old);
 }
 cmdoptions.options = 0;
 cmdoptions.init = 0;
}

canonical_original_code:
void CmdLO_Destroy() {
 struct _CONode *node = cmdoptions.options;
 int i = 0;
 while (node != 0) {
  if (node->option->optionscount > 0) {
   i = 0;
   for (; i < node->option->optionscount; ++i)
    free(node->option->options[i]);
   free(node->option->options);
  }
  if (node->option->defaultparametercount > 0) {
   i = 0;
   for (; i < node->option->defaultparametercount; ++i)
    free(node->option->defaultparameters[i]);
   free(node->option->defaultparameters);
  }
  if (node->option->possibleparametercount > 0) {
   i = 0;
   for (; i < node->option->possibleparametercount; ++i)
    free(node->option->possibleparameters[i]);
   free(node->option->possibleparameters);
  }
  if (node->option->valuecount > 0) {
   i = 0;
   for (; i < node->option->valuecount; ++i)
    free(node->option->values[i]);
   free(node->option->values);
  }
  free(node->option);
  struct _CONode *old = node;
  node = node->next;
  free(old);
 }
 cmdoptions.options = 0;
 cmdoptions.init = 0;
}

variable_types: i int


repo: qzchenwl/hashtable

decompiled_code:
__int64 __fastcall bkdr_hash(char *a1)
{
char v1; // dl
__int64 result; // rax

v1 = *a1;
if ( !*a1 )
return 0LL;
result = 0LL;
do
{
++a1;
result = v1 + 131 * result;
v1 = *a1;
}
while ( *a1 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(char *a1)
{
char v1; // dl
__int64 result; // rax

v1 = *a1;
if ( !*a1 )
return 0LL;
result = 0LL;
do
{
++a1;
result = v1 + 131 * result;
v1 = *a1;
}
while ( *a1 );
return result;
}

original_code:
static HSIZE bkdr_hash(const char *key)
{
    HSIZE seed = 131;
    HSIZE hash = 0;
    while (*key)
        hash = hash * seed + (*key++);
    return hash;
}

canonical_original_code:
static unsigned long bkdr_hash(char *key)
{
    unsigned long seed = 131;
    unsigned long hash = 0;
    while (*key)
        hash = hash * seed + (*key++);
    return hash;
}

variable_types:
key
char *

variable_types:
seed
unsigned long

variable_types:
hash
unsigned long

return_type: unsigned long