bytewiseLevenshtein

original_code:
int bytewiseLevenshtein(char *a, size_t asize, char *b, size_t bsize)
{
 if(asize > bsize) {
  char *t = a;
  size_t tsize = asize;
  a = b;
  asize = bsize;
  b = t;
  bsize = tsize;
 }
 if(asize == 0) {
  return bsize;
 }
 int *m[2];
 for(int i = 0; i < 2; i++) {
  m[i] = malloc(asize * sizeof(int));
 }
 for(int y = 0; y < bsize; y++) {
  for(int x = 0; x < asize; x++) {
   int od, ou, ol;
   int cost, p, c;
   od = y == 0 ? x : (x == 0 ? y : m[y & 1][x - 1]);
   ou = y == 0 ? x + 1 : m[y & 1][x];
   ol = x == 0 ? y + 1 : m[!(y & 1)][x - 1];
   cost = a[x] != b[y];
   p = od + cost;
   ou += 1;
   ol += 1;
   if(p > ou)
    p = ou;
   if(p > ol)
    p = ol;
   m[!(y & 1)][x] = p;
  }
 }
 asize = m[bsize & 1][asize - 1];
 for(int i = 0; i < 2; i++) {
  free(m[i]);
 }
 if(asize <= 12) {
  int x = 0;
 }
 return asize;
}

canonical_original_code:
int bytewiseLevenshtein(char *a, unsigned long asize, char *b, unsigned long bsize)
{
 if(asize > bsize) {
  char *t = a;
  unsigned long tsize = asize;
  a = b;
  asize = bsize;
  b = t;
  bsize = tsize;
 }
 if(asize == 0) {
  return bsize;
 }
 int *m[2];
 for(int i = 0; i < 2; i++) {
  m[i] = malloc(asize * sizeof(int));
 }
 for(int y = 0; y < bsize; y++) {
  for(int x = 0; x < asize; x++) {
   int od; int ou; int ol;
   int cost; int p; int c;
   od = y == 0 ? x : (x == 0 ? y : m[y & 1][x - 1]);
   ou = y == 0 ? x + 1 : m[y & 1][x];
   ol = x == 0 ? y + 1 : m[!(y & 1)][x - 1];
   cost = a[x] != b[y];
   p = od + cost;
   ou += 1;
   ol += 1;
   if(p > ou)
    p = ou;
   if(p > ol)
    p = ol;
   m[!(y & 1)][x] = p;
  }
 }
 asize = m[bsize & 1][asize - 1];
 for(int i = 0; i < 2; i++) {
  free(m[i]);
 }
 if(asize <= 12) {
  int x = 0;
 }
 return asize;
}

variable_types:
a
char *

variable_types:
asize
unsigned long


alignedlevenshtein

repo: quickdudley/lineargp

original_code:
int alignedlevenshtein(char *a, size_t asize, char *b, size_t bsize)
{
 if(asize > bsize) {
  char *t = a;
  size_t tsize = asize;
  a = b;
  asize = bsize;
  b = t;
  bsize = tsize;
 }
 if(asize == 0) {
  return bsize * 8;
 }
 int *m[2];
 for(int i = 0; i < 2; i++) {
  m[i] = malloc(asize * sizeof(int));
 }
 for(int y = 0; y < bsize; y++) {
  for(int x = 0; x < asize; x++) {
   int od, ou, ol;
   int cost, p, c;
   od = y == 0 ? x * 8 : (x == 0 ? y * 8 : m[y & 1][x - 1]);
   ou = y == 0 ? (x + 1) * 8 : m[y & 1][x];
   ol = x == 0 ? (y + 1) * 8 : m[!(y & 1)][x - 1];
   cost = 0;
   for(int bit = 0x80; bit != 0; bit = bit >> 1) {
    if((a[x] & bit) != (b[y] & bit)) {
     cost += 1;
    }
   }
   p = od + cost;
   ou += 8;
   ol += 8;
   if(p > ou)
    p = ou;
   if(p > ol)
    p = ol;
   m[!(y & 1)][x] = p;
  }
 }
 asize = m[bsize & 1][asize - 1];
 for(int i = 0; i < 2; i++) {
  free(m[i]);
 }
 if(asize <= 12) {
  int x = 0;
 }
 return asize;
}

canonical_original_code:
int alignedlevenshtein(char *a, unsigned long asize, char *b, unsigned long bsize)
{
 if(asize > bsize) {
  char *t = a;
  unsigned long tsize = asize;
  a = b;
  asize = bsize;
  b = t;
  bsize = tsize;
 }
 if(asize == 0) {
  return bsize * 8;
 }
 int *m[2];
 for(int i = 0; i < 2; i++) {
  m[i] = malloc(asize * sizeof(int));
 }
 for(int y = 0; y < bsize; y++) {
  for(int x = 0; x < asize; x++) {
   int od; int ou; int ol;
   int cost; int p; int c;
   od = y == 0 ? x * 8 : (x == 0 ? y * 8 : m[y & 1][x - 1]);
   ou = y == 0 ? (x + 1) * 8 : m[y & 1][x];
   ol = x == 0 ? (y + 1) * 8 : m[!(y & 1)][x - 1];
   cost = 0;
   for(int bit = 0x80; bit != 0; bit = bit >> 1) {
    if((a[x] & bit) != (b[y] & bit)) {
     cost += 1;
    }
   }
   p = od + cost;
   ou += 8;
   ol += 8;
   if(p > ou)
    p = ou;
   if(p > ol)
    p = ol;
   m[!(y & 1)][x] = p;
  }
 }
 asize = m[bsize & 1][asize - 1];
 for(int i = 0; i < 2; i++) {
  free(m[i]);
 }
 if(asize <= 12) {
  int x = 0;
 }
 return asize;
}

variable_types:
b
char *

variable_types:
bsize
unsigned long

variable_types:
t
char *

variable_types:
tsize
unsigned long

variable_types:
m
int *[2]

variable_types: i int

variable_types: y int

variable_types: x int

variable_types: od int

variable_types: ou int

variable_types: ol int

variable_types: cost int

variable_types: p int

variable_types: c int

variable_types: bit int

return_type: int


errorfreeprogress

decompiled_code:
__int64 __fastcall errorfreeprogress(__int64 a1, unsigned __int64 a2, __int64 a3, unsigned __int64 a4)
{
int v6; // er8
unsigned __int64 v7; // rax
char v8; // dl
char v9; // di
unsigned __int64 v10; // rdx
unsigned __int8 v12; // dl
int v13; // er9
unsigned __int8 v14; // al

v6 = 8 * a4;
if ( a4 && a2 )
{
v7 = 0LL;
while ( 1 )
{
v8 = *(_BYTE *)(a1 + v7);
v9 = *(_BYTE *)(a3 + v7);
if ( v8 != v9 )
break;
v6 -= 8;
++v7;
v10 = a2;
if ( a4 <= a2 )
v10 = a4;
if ( v10 <= v7 )
goto LABEL_8;
}
v12 = v9 ^ v8;
v13 = v6 - 8;
v14 = 0x80;
do
{
if ( (v12 & v14) != 0 )
break;
--v6;
v14 >>= 1;
}
while ( v6 != v13 );
}
LABEL_8:
if ( v6 <= 0 && a4 < a2 )
v6 = 1;
return (unsigned int)v6;
}

original_code:
int errorfreeprogress(char *a, size_t asize, char *b, size_t bsize)
{
 int count = bsize * 8;
 for(int i = 0; i < asize && i < bsize; i++) {
  if(a[i] == b[i]) {
   count -= 8;
  }
  else {
   for(unsigned char j = 0x80; j != 0; j = j >> 1) {
    if((a[i] & j) == (b[i] & j))
     count -= 1;
    else {
     break;
    }
   }
   break;
  }
 }
 if(count <= 0 && asize > bsize) {
  count = 1;
 }
 return count;
}

canonical_original_code:
int errorfreeprogress(char *a, unsigned long asize, char *b, unsigned long bsize)
{
 int count = bsize * 8;
 for(int i = 0; i < asize && i < bsize; i++) {
  if(a[i] == b[i]) {
   count -= 8;
  }
  else {
   for(unsigned char j = 0x80; j != 0; j = j >> 1) {
    if((a[i] & j) == (b[i] & j))
     count -= 1;
    else {
     break;
    }
   }
   break;
  }
 }
 if(count <= 0 && asize > bsize) {
  count = 1;
 }
 return count;
}

variable_types:
a
char *

variable_types: count int

variable_types:
j
unsigned char


gcsDifference

original_code:
int gcsDifference(char *a, size_t asize, char *b, size_t bsize)
{
 int swapped = 0;
 if(asize > bsize) {
  char *t = a;
  size_t tsize = asize;
  a = b;
  asize = bsize;
  b = t;
  bsize = tsize;
  swapped = 1;
 }
 int width = asize * 8;
 int height = bsize * 8;
 if(width == 0) {
  return swapped ? 0 : height;
 }
 int *m[2];
 int gcs = 0;
 for(int i = 0; i < 2; i++) {
  m[i] = malloc(width * sizeof(int));
 }
 for(int y = 0; y < height; y++) {
  for(int x = 0; x < width; x++) {
   int od;
   od = y == 0 ? 0 : (x == 0 ? 0 : m[y & 1][x - 1]);
   if((((a[x / 8]) >> (8 - x % 8)) & 1) == (((b[y / 8]) >> (8 - y % 8)) & 1)) {
    m[!(y & 1)][x] = od + 1;
   }
   else {
    m[!(y & 1)][x] = 0;
   }
   if(m[!(y & 1)][x] > gcs){
    gcs = m[!(y & 1)][x];
   }
  }
 }
 for(int i = 0; i < 2; i++) {
  free(m[i]);
 }
 return (swapped ? width : height) - gcs;
}

canonical_original_code:
int gcsDifference(char *a, unsigned long asize, char *b, unsigned long bsize)
{
 int swapped = 0;
 if(asize > bsize) {
  char *t = a;
  unsigned long tsize = asize;
  a = b;
  asize = bsize;
  b = t;
  bsize = tsize;
  swapped = 1;
 }
 int width = asize * 8;
 int height = bsize * 8;
 if(width == 0) {
  return swapped ? 0 : height;
 }
 int *m[2];
 int gcs = 0;
 for(int i = 0; i < 2; i++) {
  m[i] = malloc(width * sizeof(int));
 }
 for(int y = 0; y < height; y++) {
  for(int x = 0; x < width; x++) {
   int od;
   od = y == 0 ? 0 : (x == 0 ? 0 : m[y & 1][x - 1]);
   if((((a[x / 8]) >> (8 - x % 8)) & 1) == (((b[y / 8]) >> (8 - y % 8)) & 1)) {
    m[!(y & 1)][x] = od + 1;
   }
   else {
    m[!(y & 1)][x] = 0;
   }
   if(m[!(y & 1)][x] > gcs){
    gcs = m[!(y & 1)][x];
   }
  }
 }
 for(int i = 0; i < 2; i++) {
  free(m[i]);
 }
 return (swapped ? width : height) - gcs;
}

variable_types:
asize
unsigned long

variable_types:
b
char *

variable_types:
bsize
unsigned long

variable_types: swapped int

variable_types: width int

variable_types: height int

variable_types: gcs int


manhattanDifference

decompiled_code:
__int64 __fastcall manhattanDifference(__int64 a1, unsigned __int64 a2, __int64 a3, unsigned __int64 a4)
{
bool v4; // cf
int v5; // ebx
__int64 v7; // r8
int v8; // ecx
int v9; // edx
unsigned __int8 v10; // al

v4 = a4 < a2;
v5 = a2;
if ( a4 <= a2 )
a2 = a4;
if ( !v4 )
v5 = a4;
if ( !a2 )
return (unsigned int)(8 * v5);
v7 = 0LL;
v8 = 0;
do
{
v9 = 8;
v10 = 0x80;
do
{
v8 += (v10 & (unsigned __int8)(*(_BYTE *)(a3 + v7) ^ *(_BYTE *)(a1 + v7))) == 0;
v10 >>= 1;
--v9;
}
while ( v9 );
++v7;
}
while ( a2 != v7 );
return (unsigned int)(8 * v5 - v8);
}

original_code:
int manhattanDifference(char *a, size_t asize, char *b, size_t bsize)
{
 size_t l = asize > bsize ? asize : bsize;
 size_t s = asize < bsize ? asize : bsize;
 int total = 0;
 for(int i = 0; i < s; i++) {
  for(unsigned char j = 0x80; j != 0; j = j >> 1) {
   if((a[i] & j) == (b[i] & j)) {
    total++;
   }
  }
 }
 return l * 8 - total;
}

canonical_original_code:
int manhattanDifference(char *a, unsigned long asize, char *b, unsigned long bsize)
{
 unsigned long l = asize > bsize ? asize : bsize;
 unsigned long s = asize < bsize ? asize : bsize;
 int total = 0;
 for(int i = 0; i < s; i++) {
  for(unsigned char j = 0x80; j != 0; j = j >> 1) {
   if((a[i] & j) == (b[i] & j)) {
    total++;
   }
  }
 }
 return l * 8 - total;
}

variable_types:
l
unsigned long

variable_types:
s
unsigned long

variable_types: total int

variable_types: i int


decompiled_code:
__int64 __fastcall malloc_Tabelle(int a1, int a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rbx
_QWORD *v4; // r12
void *v5; // rax

v2 = malloc(8LL * a2);
Tabelle_intern = (__int64)v2;
if ( !v2 )
goto LABEL_7;
if ( a2 > 0 )
{
v3 = v2;
v4 = &v2[a2];
while ( 1 )
{
v5 = malloc(16LL * a1);
*v3 = v5;
if ( !v5 )
break;
if ( ++v3 == v4 )
return 0LL;
}
LABEL_7:
fwrite("Fehler beim Allokieren der Tabelle\n", 1uLL, 0x23uLL, stderr);
exit(1);
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, int a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rbx
_QWORD *v4; // r12
void *v5; // rax

v2 = malloc(8LL * a2);
Tabelle_intern = (__int64)v2;
if ( !v2 )
goto LABEL_7;
if ( a2 > 0 )
{
v3 = v2;
v4 = &v2[a2];
while ( 1 )
{
v5 = malloc(16LL * a1);
*v3 = v5;
if ( !v5 )
break;
if ( ++v3 == v4 )
return 0LL;
}
LABEL_7:
fwrite("Fehler beim Allokieren der Tabelle\n", 1uLL, 0x23uLL, stderr);
exit(1);
}
return 0LL;
}

original_code:
int malloc_Tabelle(int Anzahl_Zeichen, int Anzahl_Zustaende)
{
 int i;
 if(!(Tabelle_intern = malloc(Anzahl_Zustaende * sizeof(struct Tabelle_Eintrag*))))
 {
  fprintf(stderr,"Fehler beim Allokieren der Tabelle\n");
  exit(1);
 }
 for(i = 0; i < Anzahl_Zustaende; i++)
  if(!(Tabelle_intern[i] = malloc(Anzahl_Zeichen * sizeof(struct Tabelle_Eintrag))))
  {
   fprintf(stderr,"Fehler beim Allokieren der Tabelle\n");
   exit(1);
  }
 return 0;
}

canonical_original_code:
int malloc_Tabelle(int Anzahl_Zeichen, int Anzahl_Zustaende)
{
 int i;
 if(!(Tabelle_intern = malloc(Anzahl_Zustaende * sizeof(struct Tabelle_Eintrag *))))
 {
  fprintf(stderr,"Fehler beim Allokieren der Tabelle\n");
  exit(1);
 }
 for(i = 0; i < Anzahl_Zustaende; i++)
  if(!(Tabelle_intern[i] = malloc(Anzahl_Zeichen * sizeof(struct Tabelle_Eintrag))))
  {
   fprintf(stderr,"Fehler beim Allokieren der Tabelle\n");
   exit(1);
  }
 return 0;
}

user_defined_types: struct Tabelle_Eintrag { int Folgezustand; void (*Funktion)(int Zustand, char *Eingabe); }


Aktion

decompiled_code:
int __fastcall Aktion(unsigned int a1, const char *a2)
{
return printf("(Zustand %i) ---%s-->\n", a1, a2);
}

canonical_decompiled_code:
int __fastcall func1(unsigned int a1, const char *a2)
{
return printf("(Zustand %i) ---%s-->\n", a1, a2);
}

original_code:
void Aktion(int Zustand, char *Zeichen)
{
 printf("(Zustand %i) ---%s-->\n",Zustand, Zeichen);
}

variable_types: Zustand int

variable_types:
Zeichen
char *

return_type: void


Fehler

decompiled_code:
void __fastcall __noreturn Fehler(unsigned int a1, const char *a2)
{
if ( a2 )
fprintf(stderr, "Fehler: (Zustand %i), Zeichen '%s'. beende...\n", a1, a2);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func2(unsigned int a1, const char *a2)
{
if ( a2 )
fprintf(stderr, "Fehler: (Zustand %i), Zeichen '%s'. beende...\n", a1, a2);
exit(1);
}

original_code:
void Fehler(int Zustand, char *Zeichen)
{
 if(Zeichen != ((void *)0))
  fprintf(stderr,"Fehler: (Zustand %i), Zeichen '%s'. beende...\n", Zustand, Zeichen);
 exit(1);
}


ok

decompiled_code:
int __fastcall ok(unsigned int a1)
{
return printf("(Endzustand %i), Zeichenkette korrekt!\n", a1);
}

canonical_decompiled_code:
int __fastcall func3(unsigned int a1)
{
return printf("(Endzustand %i), Zeichenkette korrekt!\n", a1);
}

original_code:
void ok(int Zustand)
{
 printf("(Endzustand %i), Zeichenkette korrekt!\n", Zustand);
}


decompiled_code:
_BYTE *lesen_eingabe()
{
void *v0; // r12
_BYTE *result; // rax
_BYTE *v2; // r12
char v3; // al

if ( !zeicheneingabe )
{
v0 = malloc(0x100uLL);
if ( (unsigned int)_isoc99_scanf("%s", v0) != -1 )
return v0;
return 0LL;
}
v2 = malloc(2uLL);
v3 = getchar();
*v2 = v3;
if ( v3 == 10 )
return 0LL;
result = v2;
v2[1] = 0;
return result;
}

canonical_decompiled_code:
_BYTE *func4()
{
void *v0; // r12
_BYTE *result; // rax
_BYTE *v2; // r12
char v3; // al

if ( !zeicheneingabe )
{
v0 = malloc(0x100uLL);
if ( (unsigned int)_isoc99_scanf("%s", v0) != -1 )
return v0;
return 0LL;
}
v2 = malloc(2uLL);
v3 = getchar();
*v2 = v3;
if ( v3 == 10 )
return 0LL;
result = v2;
v2[1] = 0;
return result;
}

original_code:
char* lesen_eingabe(void)
{
 char *tmp;
 if(zeicheneingabe == 0)
 {
  tmp = (char *) malloc(sizeof(char)*256);
  if(scanf("%s",tmp) == (-1))
   return ((void *)0);
 }
 else
 {
  tmp = (char *) malloc(sizeof(char)*2);
  tmp[0] = getchar();
  if(tmp[0] == '\n')
   return ((void *)0);
  tmp[1] = '\0';
 }
 return tmp;
}

canonical_original_code:
char *lesen_eingabe()
{
 char *tmp;
 if(zeicheneingabe == 0)
 {
  tmp = (char *) malloc(sizeof(char)*256);
  if(scanf("%s",tmp) == (-1))
   return ((void *)0);
 }
 else
 {
  tmp = (char *) malloc(sizeof(char)*2);
  tmp[0] = getchar();
  if(tmp[0] == '\n')
   return ((void *)0);
  tmp[1] = '\0';
 }
 return tmp;
}

variable_types:
tmp
char *

return_type: char *


decompiled_code:
__int64 __fastcall eingabe_ok(char *s2)
{
const char **v1; // rbx
int v2; // eax
__int64 result; // rax

v1 = (const char **)woerter;
if ( woerter )
{
while ( 1 )
{
while ( 1 )
{
v2 = strncmp(v1[1], s2, 0x100uLL);
if ( v2 >= 0 )
break;
v1 = (const char **)v1[2];
if ( !v1 )
goto LABEL_5;
}
if ( !v2 )
break;
v1 = (const char **)v1[3];
if ( !v1 )
goto LABEL_5;
}
result = *(unsigned int *)v1;
}
else
{
LABEL_5:
fprintf(stderr, "Wort '%s' nicht im Alphabet!\n", s2);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *s2)
{
const char **v1; // rbx
int v2; // eax
__int64 result; // rax

v1 = (const char **)woerter;
if ( woerter )
{
while ( 1 )
{
while ( 1 )
{
v2 = strncmp(v1[1], s2, 0x100uLL);
if ( v2 >= 0 )
break;
v1 = (const char **)v1[2];
if ( !v1 )
goto LABEL_5;
}
if ( !v2 )
break;
v1 = (const char **)v1[3];
if ( !v1 )
goto LABEL_5;
}
result = *(unsigned int *)v1;
}
else
{
LABEL_5:
fprintf(stderr, "Wort '%s' nicht im Alphabet!\n", s2);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int eingabe_ok(char *id)
{
 struct alphabaum *tmp;
 tmp = woerter;
 while(tmp != ((void *)0))
 {
  if(strncmp(tmp->id,id,256) < 0)
  {
   if(tmp->links != ((void *)0))
   {
    tmp = tmp->links;
    continue;
   }
   else
   {
    fprintf(stderr,"Wort '%s' nicht im Alphabet!\n", id);
    return -1;
   }
  }
  else if(strncmp(tmp->id,id,256) > 0)
  {
   if(tmp->rechts != ((void *)0))
   {
    tmp = tmp->rechts;
    continue;
   }
   else
   {
    fprintf(stderr,"Wort '%s' nicht im Alphabet!\n", id);
    return -1;
   }
  }
  else
   return tmp->idx;
 }
 fprintf(stderr,"Wort '%s' nicht im Alphabet!\n", id);
 return -1;
}

variable_types:
id
char *

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


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

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

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

v2 = malloc(0x20uLL);
if ( !v2 )
{
fwrite("Nicht genug Speicher verfuegbar.\n", 1uLL, 0x21uLL, stderr);
exit(1);
}
*(_DWORD *)v2 = a2;
v3 = woerter;
v4 = v2;
v2[1] = s2;
v2[2] = 0LL;
v2[3] = 0LL;
if ( !v3 )
{
woerter = (__int64)v2;
return (int)v2;
}
while ( 1 )
{
LODWORD(v2) = strncmp(*(const char **)(v3 + 8), s2, 0x100uLL);
if ( (int)v2 < 0 )
break;
if ( !(_DWORD)v2 )
return (int)v2;
v2 = *(_QWORD **)(v3 + 24);
if ( !v2 )
{
*(_QWORD *)(v3 + 24) = v4;
return (int)v2;
}
LABEL_6:
v3 = (__int64)v2;
}
v2 = *(_QWORD **)(v3 + 16);
if ( v2 )
goto LABEL_6;
*(_QWORD *)(v3 + 16) = v4;
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 v0; // rbx
int v1; // esi
char *v2; // rbp
int v3; // er12

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

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

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

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;
}


Automat

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

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

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

while ( 1 )
{
Zeichen = (__int64)func4();
if ( !Zeichen )
break;
v0 = func5((char *)Zeichen);
if ( v0 == -1 )
goto LABEL_11;
v1 = 16LL * v0;
(*(void (__fastcall **)(_QWORD, __int64))(*(_QWORD *)(Tabelle_intern + 8LL * akt_Zustand) + v1 + 8))(
akt_Zustand,
Zeichen);
akt_Zustand = *(_DWORD *)(*(_QWORD *)(Tabelle_intern + 8LL * akt_Zustand) + v1);
}
if ( Anzahl_Endzustaende > 0 )
{
v2 = 0LL;
do
{
if ( *((_DWORD *)&Endzustaende + v2) == akt_Zustand )
{
func3(akt_Zustand);
exit(0);
}
++v2;
}
while ( v2 != Anzahl_Endzustaende );
}
fwrite("Endzustand nicht erreicht!\n", 1uLL, 0x1BuLL, stderr);
LABEL_11:
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)
{
int v3; // er10
int v4; // er9
__int64 v5; // rdi
int v6; // er8
__int64 v7; // rdx
__int64 v8; // rcx
__int64 v9; // rax

TabelleP = (__int64)&Tabelle;
printf("Initialisiere...");
setze_alphabet();
malloc_Tabelle(Anzahl_Zeichen, Anzahl_Zustaende);
v3 = Anzahl_Zustaende;
v4 = Anzahl_Zeichen;
if ( Anzahl_Zustaende > 0 )
{
v5 = 0LL;
v6 = 0;
do
{
if ( v4 > 0 )
{
v7 = TabelleP + 16LL * v6;
v8 = *(_QWORD *)(Tabelle_intern + v5);
v9 = 0LL;
do
{
*(__m128i *)(v8 + v9) = _mm_loadu_si128((const __m128i *)(v7 + v9));
v9 += 16LL;
}
while ( v9 != 16 * ((unsigned int)(v4 - 1) + 1LL) );
}
v5 += 8LL;
v6 += v4;
}
while ( 8LL * v3 != v5 );
}
akt_Zustand = Startzustand;
printf(aFertigZeichenI, (unsigned int)v4, (unsigned int)v3, (unsigned int)Anzahl_Endzustaende);
if ( zeicheneingabe == 1 )
puts(aBitteGew);
else
puts(s);
Automat();
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // er10
int v4; // er9
__int64 v5; // rdi
int v6; // er8
__int64 v7; // rdx
__int64 v8; // rcx
__int64 v9; // rax

TabelleP = (__int64)&Tabelle;
printf("Initialisiere...");
func7();
func0(Anzahl_Zeichen, Anzahl_Zustaende);
v3 = Anzahl_Zustaende;
v4 = Anzahl_Zeichen;
if ( Anzahl_Zustaende > 0 )
{
v5 = 0LL;
v6 = 0;
do
{
if ( v4 > 0 )
{
v7 = TabelleP + 16LL * v6;
v8 = *(_QWORD *)(Tabelle_intern + v5);
v9 = 0LL;
do
{
*(__m128i *)(v8 + v9) = _mm_loadu_si128((const __m128i *)(v7 + v9));
v9 += 16LL;
}
while ( v9 != 16 * ((unsigned int)(v4 - 1) + 1LL) );
}
v5 += 8LL;
v6 += v4;
}
while ( 8LL * v3 != v5 );
}
akt_Zustand = Startzustand;
printf(aFertigZeichenI, (unsigned int)v4, (unsigned int)v3, (unsigned int)Anzahl_Endzustaende);
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


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

result = 0LL;
if ( a1 )
{
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

result = 0LL;
if ( a1 )
{
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

result = 0LL;
if ( a1 )
{
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

result = 0LL;
if ( a1 )
{
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; } *


decompiled_code:
__int64 __fastcall has_did_label_property(__int64 a1)
{
__int64 v1; // r12
__int64 v2; // rbx

v1 = 0LL;
if ( !a1 )
return v1;
if ( *(_DWORD *)a1 != 4 )
return v1;
v1 = *(_QWORD *)(a1 + 520);
if ( !v1 )
return v1;
if ( *(_DWORD *)v1 == 6 )
{
while ( 1 )
{
v2 = *(_QWORD *)(v1 + 528);
if ( *(_DWORD *)v2 == 5 && !strcmp((const char *)(v2 + 4), "label") && strnlen((const char *)(v2 + 260), 0x100uLL) )
break;
v1 = *(_QWORD *)(v1 + 520);
if ( !v1 )
return v1;
}
return v2;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 v1; // r12
__int64 v2; // rbx

v1 = 0LL;
if ( !a1 )
return v1;
if ( *(_DWORD *)a1 != 4 )
return v1;
v1 = *(_QWORD *)(a1 + 520);
if ( !v1 )
return v1;
if ( *(_DWORD *)v1 == 6 )
{
while ( 1 )
{
v2 = *(_QWORD *)(v1 + 528);
if ( *(_DWORD *)v2 == 5 && !strcmp((const char *)(v2 + 4), "label") && strnlen((const char *)(v2 + 260), 0x100uLL) )
break;
v1 = *(_QWORD *)(v1 + 520);
if ( !v1 )
return v1;
}
return v2;
}
return 0LL;
}

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; // r12
__int64 result; // rax
__int64 v4; // r12

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

canonical_decompiled_code:
__int64 __fastcall func3(__int64 *a1, const char *a2)
{
__int64 v2; // r12
__int64 result; // rax
__int64 v4; // r12

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

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; // r12
unsigned int v8; // ebx
_BOOL4 v9; // er12
_BOOL4 v10; // eax

v6 = *a2;
if ( *a2 )
{
while ( strncmp(*(const char **)v6, a3, 0x100uLL) )
{
v6 = *(_QWORD *)(v6 + 56);
if ( !v6 )
goto LABEL_6;
}
}
else
{
LABEL_6:
v8 = index_count_1;
v9 = is_end_state(a1, a3);
v10 = is_start_state(a1, a3);
v6 = generate_id_element(a3, v10, v9, a4, v8);
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; // r12
unsigned int v8; // ebx
_BOOL4 v9; // er12
_BOOL4 v10; // eax

v6 = *a2;
if ( *a2 )
{
while ( strncmp(*(const char **)v6, a3, 0x100uLL) )
{
v6 = *(_QWORD *)(v6 + 56);
if ( !v6 )
goto LABEL_6;
}
}
else
{
LABEL_6:
v8 = index_count_1;
v9 = func5(a1, a3);
v10 = func6(a1, a3);
v6 = generate_id_element(a3, v10, v9, a4, v8);
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

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

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; // rbp
__int64 v4; // r12
__int64 result; // rax

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_6;
}
result = v4;
}
else
{
LABEL_6:
free(v3);
result = 0LL;
}
return result;
}

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

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_6;
}
result = v4;
}
else
{
LABEL_6:
free(v3);
result = 0LL;
}
return result;
}

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) != 2 )
{
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) != 2 )
{
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 *v3; // r13
__int64 *v4; // rbp
__int64 *v5; // r12
__int64 *v6; // r14
const char *v7; // rax
int v8; // er8
unsigned int v9; // er15

fwrite("...libdfa started...\n", 1uLL, 0x15uLL, stderr);
v3 = (__int64 *)get_list_instance();
v4 = (__int64 *)get_list_instance();
v5 = (__int64 *)get_list_instance();
fill_did_list(a1, (__int64)v5, v3, v4);
v6 = fill_state_matrix(v5, (__int64)v3, (__int64)v4);
if ( a2 <= 0 )
{
LABEL_12:
v9 = -1;
goto LABEL_13;
}
v7 = *a3;
v8 = *(unsigned __int8 *)*a3;
if ( v8 != 45 || v7[1] != 105 || v7[2] )
{
if ( !strcmp(*a3, "-dot") )
{
generate_dfa_dot_code(a1 + 4, v3, v5, v6);
v9 = -1;
goto LABEL_13;
}
if ( v8 == 45 && v7[1] == 99 && !v7[2] )
{
v9 = -1;
generate_c_code(v3, v4, v6);
goto LABEL_13;
}
goto LABEL_12;
}
if ( (unsigned int)is_single_symbol_dfa(v4) )
v9 = interpret_input_char(stdin, v5, v6);
else
v9 = interpret_input_string(stdin, v5, v6);
if ( v9 == 1 )
{
v9 = 0;
puts("\n---------------------\nEingabe akzeptiert\n---------------------\n");
}
else if ( v9 )
{
puts("Fehler beim interpretieren\n");
}
else
{
v9 = 1;
puts("!!-------------------\nEingabe nicht akzeptiert\n!!-------------------\n");
}
LABEL_13:
delete_instance(v3);
delete_instance(v4);
delete_instance(v5);
free_matrix(v6);
fwrite("...libdfa ended...\n", 1uLL, 0x13uLL, stderr);
return v9;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, int a2, const char **a3)
{
__int64 *v3; // r13
__int64 *v4; // rbp
__int64 *v5; // r12
__int64 *v6; // r14
const char *v7; // rax
int v8; // er8
unsigned int v9; // er15

fwrite("...libdfa started...\n", 1uLL, 0x15uLL, stderr);
v3 = (__int64 *)get_list_instance();
v4 = (__int64 *)get_list_instance();
v5 = (__int64 *)get_list_instance();
func8(a1, (__int64)v5, v3, v4);
v6 = fill_state_matrix(v5, (__int64)v3, (__int64)v4);
if ( a2 <= 0 )
{
LABEL_12:
v9 = -1;
goto LABEL_13;
}
v7 = *a3;
v8 = *(unsigned __int8 *)*a3;
if ( v8 != 45 || v7[1] != 105 || v7[2] )
{
if ( !strcmp(*a3, "-dot") )
{
generate_dfa_dot_code(a1 + 4, v3, v5, v6);
v9 = -1;
goto LABEL_13;
}
if ( v8 == 45 && v7[1] == 99 && !v7[2] )
{
v9 = -1;
generate_c_code(v3, v4, v6);
goto LABEL_13;
}
goto LABEL_12;
}
if ( (unsigned int)func15(v4) )
v9 = func13(stdin, v5, v6);
else
v9 = func14(stdin, v5, v6);
if ( v9 == 1 )
{
v9 = 0;
puts("\n---------------------\nEingabe akzeptiert\n---------------------\n");
}
else if ( v9 )
{
puts("Fehler beim interpretieren\n");
}
else
{
v9 = 1;
puts("!!-------------------\nEingabe nicht akzeptiert\n!!-------------------\n");
}
LABEL_13:
delete_instance(v3);
delete_instance(v4);
delete_instance(v5);
free_matrix(v6);
fwrite("...libdfa ended...\n", 1uLL, 0x13uLL, stderr);
return v9;
}

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
bool v3; // zf

result = *(_QWORD *)(a1 + 8);
if ( result )
*(_QWORD *)(result + 56) = a2;
v3 = *(_QWORD *)a1 == 0LL;
*(_QWORD *)(a1 + 8) = a2;
if ( v3 )
{
result = *(_QWORD *)(a1 + 8);
++*(_DWORD *)(a1 + 16);
*(_QWORD *)a1 = result;
}
else
{
++*(_DWORD *)(a1 + 16);
}
return result;
}

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

result = *(_QWORD *)(a1 + 8);
if ( result )
*(_QWORD *)(result + 56) = a2;
v3 = *(_QWORD *)a1 == 0LL;
*(_QWORD *)(a1 + 8) = a2;
if ( v3 )
{
result = *(_QWORD *)(a1 + 8);
++*(_DWORD *)(a1 + 16);
*(_QWORD *)a1 = result;
}
else
{
++*(_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
__int64 v2; // rdx

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

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

if ( !a1 )
return 0LL;
result = *a1;
if ( *a1 )
{
v2 = *(_QWORD *)(result + 56);
--*((_DWORD *)a1 + 4);
*a1 = v2;
}
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 :");
for ( ; a1[1] != v1; v1 = (const char **)v1[7] )
printf("Name:%s, Label:%s\n", *v1, v1[5]);
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 :");
for ( ; a1[1] != v1; v1 = (const char **)v1[7] )
printf("Name:%s, Label:%s\n", *v1, v1[5]);
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(__int64 *a1)
{
__int64 v1; // rbx
int result; // eax
const char *v3; // rdx

v1 = *a1;
result = fwrite("\n\t// states\n\n", 1uLL, 0xDuLL, stdout);
if ( v1 )
{
while ( 1 )
{
v3 = *(const char **)v1;
if ( *(_DWORD *)(v1 + 8) )
break;
if ( *(_DWORD *)(v1 + 12) )
{
result = fprintf(stdout, "\t\"%s\" %s\n", v3, "[ shape=doublecircle end=\"yes\" ]\t/* end node */");
LABEL_4:
v1 = *(_QWORD *)(v1 + 56);
if ( !v1 )
return result;
}
else
{
result = fprintf(stdout, "\t\"%s\"\n", v3);
v1 = *(_QWORD *)(v1 + 56);
if ( !v1 )
return result;
}
}
result = fprintf(stdout, "\t\"%s\" %s\n", v3, "[ start=\"yes\" ]\t/* start node */");
goto LABEL_4;
}
return result;
}

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

v1 = *a1;
result = fwrite("\n\t// states\n\n", 1uLL, 0xDuLL, stdout);
if ( v1 )
{
while ( 1 )
{
v3 = *(const char **)v1;
if ( *(_DWORD *)(v1 + 8) )
break;
if ( *(_DWORD *)(v1 + 12) )
{
result = fprintf(stdout, "\t\"%s\" %s\n", v3, "[ shape=doublecircle end=\"yes\" ]\t/* end node */");
LABEL_4:
v1 = *(_QWORD *)(v1 + 56);
if ( !v1 )
return result;
}
else
{
result = fprintf(stdout, "\t\"%s\"\n", v3);
v1 = *(_QWORD *)(v1 + 56);
if ( !v1 )
return result;
}
}
result = fprintf(stdout, "\t\"%s\" %s\n", v3, "[ start=\"yes\" ]\t/* start node */");
goto LABEL_4;
}
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; // r12
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; // r12
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, __int64 *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, __int64 *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; // r12
__int64 v3; // rbx
__int64 v4; // rax
__int64 v5; // rdx
__int64 i; // rbx
const char *v7; // rdx

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) )
{
while ( 1 )
{
v5 = *(unsigned int *)(v3 + 48);
if ( *(_QWORD *)(v2 + 8) == v3 )
break;
fprintf(stdout, "%i, ", v5);
v3 = *(_QWORD *)(v3 + 56);
if ( !v3 )
goto LABEL_6;
}
fprintf(stdout, "%i", v5);
}
LABEL_6:
fwrite("};\n", 1uLL, 3uLL, stdout);
fwrite("char *Alphabet[STRMAX] = {\n", 1uLL, 0x1BuLL, stdout);
for ( i = *a2; i; i = *(_QWORD *)(i + 56) )
{
while ( 1 )
{
v7 = *(const char **)(i + 40);
if ( a2[1] == i )
break;
fprintf(stdout, "\t\"%s\",\n", v7);
i = *(_QWORD *)(i + 56);
if ( !i )
goto LABEL_11;
}
fprintf(stdout, "\t\"%s\"\n", v7);
}
LABEL_11:
fwrite("};\n", 1uLL, 3uLL, stdout);
return delete_instance(v2);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 *a2)
{
__int64 v2; // r12
__int64 v3; // rbx
__int64 v4; // rax
__int64 v5; // rdx
__int64 i; // rbx
const char *v7; // rdx

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) )
{
while ( 1 )
{
v5 = *(unsigned int *)(v3 + 48);
if ( *(_QWORD *)(v2 + 8) == v3 )
break;
fprintf(stdout, "%i, ", v5);
v3 = *(_QWORD *)(v3 + 56);
if ( !v3 )
goto LABEL_6;
}
fprintf(stdout, "%i", v5);
}
LABEL_6:
fwrite("};\n", 1uLL, 3uLL, stdout);
fwrite("char *Alphabet[STRMAX] = {\n", 1uLL, 0x1BuLL, stdout);
for ( i = *a2; i; i = *(_QWORD *)(i + 56) )
{
while ( 1 )
{
v7 = *(const char **)(i + 40);
if ( a2[1] == i )
break;
fprintf(stdout, "\t\"%s\",\n", v7);
i = *(_QWORD *)(i + 56);
if ( !i )
goto LABEL_11;
}
fprintf(stdout, "\t\"%s\"\n", v7);
}
LABEL_11:
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; // rbx
__int64 v2; // r15
__int64 i; // [rsp+8h] [rbp-40h]

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

canonical_decompiled_code:
size_t __fastcall func1(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // r15
__int64 i; // [rsp+8h] [rbp-40h]

fprintf(stdout, "\nstruct Tabelle_Eintrag Tabelle[%i][%i]={\n", *(unsigned int *)(a1 + 8), *(unsigned int *)(a1 + 12));
for ( i = 0LL; *(_DWORD *)(a1 + 8) > (int)i; ++i )
{
v1 = 0LL;
fwrite("{ ", 1uLL, 2uLL, stdout);
if ( *(int *)(a1 + 12) > 0 )
{
do
{
while ( 1 )
{
v2 = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)a1 + 8 * i) + 24 * v1);
fwrite(" {", 1uLL, 2uLL, stdout);
if ( v2 )
fprintf(stdout, "%i,Aktion", *(unsigned int *)(v2 + 48));
else
fwrite("0,Fehler", 1uLL, 8uLL, stdout);
if ( *(_DWORD *)(a1 + 12) - 1 <= (int)v1 )
break;
++v1;
fwrite("},", 1uLL, 2uLL, stdout);
if ( *(_DWORD *)(a1 + 12) <= (int)v1 )
goto LABEL_9;
}
++v1;
fputc(125, stdout);
}
while ( *(_DWORD *)(a1 + 12) > (int)v1 );
}
LABEL_9:
if ( *(_DWORD *)(a1 + 8) - 1 <= (int)i )
fwrite(" }\n", 1uLL, 3uLL, stdout);
else
fwrite(" },\n", 1uLL, 4uLL, stdout);
}
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 v2; // rbx
void *v3; // rdi

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

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

if ( ptr )
{
if ( *((int *)ptr + 2) > 0 )
{
v2 = 0LL;
do
{
v3 = *(void **)(*(_QWORD *)ptr + 8 * v2++);
free(v3);
}
while ( *((_DWORD *)ptr + 2) > (int)v2 );
}
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; // r15
char *v6; // rax
size_t v7; // rax
time_t timer; // [rsp+8h] [rbp-6A0h] BYREF
char dest[16]; // [rsp+10h] [rbp-698h] BYREF
__int64 v11; // [rsp+20h] [rbp-688h]
int v12; // [rsp+28h] [rbp-680h]
__int16 v13; // [rsp+2Ch] [rbp-67Ch]
char buf[1656]; // [rsp+30h] [rbp-678h] BYREF

timer = time(0LL);
v13 = 0;
memset(buf, 0, 0x640uLL);
*(_OWORD *)dest = 0LL;
v11 = 0LL;
v12 = 0;
if ( (int)read(fd, buf, 0x640uLL) < 0 )
{
printf("Error reading from socket");
}
else
{
v4 = ctime(&timer);
strncpy(dest, v4, 0x1EuLL);
v5 = strtok(dest, "\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; // r15
char *v6; // rax
size_t v7; // rax
time_t timer; // [rsp+8h] [rbp-6A0h] BYREF
char dest[16]; // [rsp+10h] [rbp-698h] BYREF
__int64 v11; // [rsp+20h] [rbp-688h]
int v12; // [rsp+28h] [rbp-680h]
__int16 v13; // [rsp+2Ch] [rbp-67Ch]
char buf[1656]; // [rsp+30h] [rbp-678h] BYREF

timer = time(0LL);
v13 = 0;
memset(buf, 0, 0x640uLL);
*(_OWORD *)dest = 0LL;
v11 = 0LL;
v12 = 0;
if ( (int)read(fd, buf, 0x640uLL) < 0 )
{
printf("Error reading from socket");
}
else
{
v4 = ctime(&timer);
strncpy(dest, v4, 0x1EuLL);
v5 = strtok(dest, "\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]; }


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // er12
const char *v4; // rdi
unsigned int v5; // ebp
socklen_t v6; // edx
int v7; // er13
__pid_t v8; // eax
int v9; // ebp
socklen_t addr_len; // [rsp+Ch] [rbp-3Ch] BYREF
struct sockaddr v11; // [rsp+10h] [rbp-38h] BYREF
struct sockaddr addr; // [rsp+20h] [rbp-28h] BYREF

signal(17, (__sighandler_t)1);
if ( argc > 0 )
{
v3 = socket(2, 1, 0);
if ( v3 >= 0 )
{
v4 = argv[1];
v11 = 0LL;
v11.sa_family = 2;
v5 = atoi(v4);
*(_WORD *)v11.sa_data = _bswap_16((unsigned __int16)v5, &v11, 16LL);
if ( bind(v3, &v11, v6) >= 0 )
{
v7 = 0;
listen(v3, 5);
addr_len = 16;
while ( 1 )
{
++v7;
v9 = accept(v3, &addr, &addr_len);
if ( v9 < 0 )
break;
v8 = fork();
if ( v8 < 0 )
{
puts("Error on fork");
exit(1);
}
if ( !v8 )
{
close(v3);
parse_client(v9);
exit(0);
}
close(v9);
}
puts("Error on accept");
exit(1);
}
printf("Error binding socket on port %d\n", v5);
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; // er12
const char *v4; // rdi
unsigned int v5; // ebp
socklen_t v6; // edx
int v7; // er13
__pid_t v8; // eax
int v9; // ebp
socklen_t addr_len; // [rsp+Ch] [rbp-3Ch] BYREF
struct sockaddr v11; // [rsp+10h] [rbp-38h] BYREF
struct sockaddr addr; // [rsp+20h] [rbp-28h] BYREF

signal(17, (__sighandler_t)1);
if ( argc > 0 )
{
v3 = socket(2, 1, 0);
if ( v3 >= 0 )
{
v4 = argv[1];
v11 = 0LL;
v11.sa_family = 2;
v5 = atoi(v4);
*(_WORD *)v11.sa_data = func7((unsigned __int16)v5, &v11, 16LL);
if ( bind(v3, &v11, v6) >= 0 )
{
v7 = 0;
listen(v3, 5);
addr_len = 16;
while ( 1 )
{
++v7;
v9 = accept(v3, &addr, &addr_len);
if ( v9 < 0 )
break;
v8 = fork();
if ( v8 < 0 )
{
puts("Error on fork");
exit(1);
}
if ( !v8 )
{
close(v3);
func9(v9);
exit(0);
}
close(v9);
}
puts("Error on accept");
exit(1);
}
printf("Error binding socket on port %d\n", v5);
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:
argv
char **

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 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]);
}


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

addr->sa_family = 2;
*(_DWORD *)&addr->sa_data[2] = _bswap_32_constprop_0();
v2 = _bswap_16(a2);
*(_QWORD *)&addr[1].sa_data[6] = v3;
*(_WORD *)addr->sa_data = v2;
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)
{
__int16 v2; // ax
__int64 v3; // rdx
int v4; // eax
int result; // eax

addr->sa_family = 2;
*(_DWORD *)&addr->sa_data[2] = func8();
v2 = func7(a2);
*(_QWORD *)&addr[1].sa_data[6] = v3;
*(_WORD *)addr->sa_data = v2;
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; // rax
void *v3; // r12
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;
v3 = v2;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, 1);
result = pthread_create(&newthread, &attr, *(void *(**)(void *))(a1 + 24), v3);
if ( result )
{
perror("Create thread failed");
exit(1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func12(__int64 a1, int a2)
{
_DWORD *v2; // rax
void *v3; // r12
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;
v3 = v2;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, 1);
result = pthread_create(&newthread, &attr, *(void *(**)(void *))(a1 + 24), v3);
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:
__int64 __fastcall wserver_listen(__int64 a1)
{
int v2; // edi
int v3; // eax
__int64 result; // rax
socklen_t addr_len; // [rsp+Ch] [rbp-1Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-18h] BYREF

listen(*(_DWORD *)(a1 + 16), 100);
*(_DWORD *)(a1 + 32) = 1;
do
{
v2 = *(_DWORD *)(a1 + 16);
addr_len = 16;
v3 = accept(v2, &addr, &addr_len);
wserver_new_task(a1, v3);
sleep(1u);
result = *(unsigned int *)(a1 + 32);
}
while ( (_DWORD)result );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1)
{
int v2; // edi
int v3; // eax
__int64 result; // rax
socklen_t addr_len; // [rsp+Ch] [rbp-1Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-18h] BYREF

listen(*(_DWORD *)(a1 + 16), 100);
*(_DWORD *)(a1 + 32) = 1;
do
{
v2 = *(_DWORD *)(a1 + 16);
addr_len = 16;
v3 = accept(v2, &addr, &addr_len);
func12(a1, v3);
sleep(1u);
result = *(unsigned int *)(a1 + 32);
}
while ( (_DWORD)result );
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