main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rdi
const char *v4; // rbp
const char *v6; // rbp

if ( argc != 5 )
{
fwrite("Nombre d'arguments invalide...\n", 1uLL, 0x1FuLL, stderr);
exit(10);
}
v3 = argv[1];
if ( *(_WORD *)v3 != 29741 || v3[2] )
{
if ( !strcmp(v3, "-n") )
{
v6 = argv[3];
infos = (char *)argv[2];
if ( !strcmp(v6, "-t") )
goto LABEL_6;
if ( !strcmp(v6, "-n") )
{
fwrite(&unk_4020F7, 1uLL, 0x1AuLL, stderr);
exit(10);
}
}
LABEL_12:
fwrite("Argument inconnu.\n", 1uLL, 0x12uLL, stderr);
exit(10);
}
v4 = argv[3];
infos = (char *)argv[2];
if ( !strcmp(v4, "-t") )
{
fwrite(&unk_4020DC, 1uLL, 0x1AuLL, stderr);
exit(10);
}
if ( strcmp(v4, "-n") )
goto LABEL_12;
LABEL_6:
infos = (char *)argv[4];
create_tube();
work();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rdi
const char *v4; // rbp
const char *v6; // rbp

if ( argc != 5 )
{
fwrite("Nombre d'arguments invalide...\n", 1uLL, 0x1FuLL, stderr);
exit(10);
}
v3 = argv[1];
if ( *(_WORD *)v3 != 29741 || v3[2] )
{
if ( !strcmp(v3, "-n") )
{
v6 = argv[3];
infos = (char *)argv[2];
if ( !strcmp(v6, "-t") )
goto LABEL_6;
if ( !strcmp(v6, "-n") )
{
fwrite(&unk_4020F7, 1uLL, 0x1AuLL, stderr);
exit(10);
}
}
LABEL_12:
fwrite("Argument inconnu.\n", 1uLL, 0x12uLL, stderr);
exit(10);
}
v4 = argv[3];
infos = (char *)argv[2];
if ( !strcmp(v4, "-t") )
{
fwrite(&unk_4020DC, 1uLL, 0x1AuLL, stderr);
exit(10);
}
if ( strcmp(v4, "-n") )
goto LABEL_12;
LABEL_6:
infos = (char *)argv[4];
func7();
func9();
return 0;
}

original_code:
int
main(int argc, const char **argv)
{
    int tube_set, name_set, cpt;
    if (argc != 5)
        do { do { do { fprintf(stderr, "Nombre d'arguments invalide...\n"); } while (0); if ((10) > 0) exit((10)); } while (0); do { printf("%s -t printer_pipe -n printer_name", argv[0]); } while (0); } while (0);
    tube_set = 0;
    name_set = 0;
    cpt = 1;
    while (cpt < argc)
    {
        if (strcmp(argv[cpt], "-t") == 0)
        {
            if (tube_set == 1)
                do { do { do { fprintf(stderr, "Argument -t déjà saisi.\n"); } while (0); if ((10) > 0) exit((10)); } while (0); do { printf("%s -t printer_pipe -n printer_name", argv[0]); } while (0); } while (0);
            tube_set = 1;
            infos.tube_name = argv[++cpt];
        }
        else if (strcmp(argv[cpt], "-n") == 0)
        {
            if (name_set == 1)
                do { do { do { fprintf(stderr, "Argument -n déjà saisi.\n"); } while (0); if ((10) > 0) exit((10)); } while (0); do { printf("%s -t printer_pipe -n printer_name", argv[0]); } while (0); } while (0);
            name_set = 1;
            infos.tube_name = argv[++cpt];
        }
        else
            do { do { do { fprintf(stderr, "Argument inconnu.\n"); } while (0); if ((10) > 0) exit((10)); } while (0); do { printf("%s -t printer_pipe -n printer_name", argv[0]); } while (0); } while (0);
        ++cpt;
    }
    create_tube();
    work();
    return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
    int tube_set; int name_set; int cpt;
    if (argc != 5)
        do { do { do { fprintf(stderr, "Nombre d'arguments invalide...\n"); } while (0); if ((10) > 0) exit((10)); } while (0); do { printf("%s -t printer_pipe -n printer_name", argv[0]); } while (0); } while (0);
    tube_set = 0;
    name_set = 0;
    cpt = 1;
    while (cpt < argc)
    {
        if (strcmp(argv[cpt], "-t") == 0)
        {
            if (tube_set == 1)
                do { do { do { fprintf(stderr, "Argument -t déjà saisi.\n"); } while (0); if ((10) > 0) exit((10)); } while (0); do { printf("%s -t printer_pipe -n printer_name", argv[0]); } while (0); } while (0);
            tube_set = 1;
            infos.tube_name = argv[++cpt];
        }
        else if (strcmp(argv[cpt], "-n") == 0)
        {
            if (name_set == 1)
                do { do { do { fprintf(stderr, "Argument -n déjà saisi.\n"); } while (0); if ((10) > 0) exit((10)); } while (0); do { printf("%s -t printer_pipe -n printer_name", argv[0]); } while (0); } while (0);
            name_set = 1;
            infos.tube_name = argv[++cpt];
        }
        else
            do { do { do { fprintf(stderr, "Argument inconnu.\n"); } while (0); if ((10) > 0) exit((10)); } while (0); do { printf("%s -t printer_pipe -n printer_name", argv[0]); } while (0); } while (0);
        ++cpt;
    }
    create_tube();
    work();
    return 0;
}

variable_types: argc int

variable_types:
argv
char **


afficherAide

decompiled_code:
int afficherAide()
{
putchar(10);
puts("-h : affiche l'aide de votre commande");
puts(aVPourActiverLe);
puts(aCPourCr);
puts("-t : pour lister les fichiers contenus dans une archive");
puts("-r : pour ajouter de nouveaux fichiers");
puts(aUPourMettre);
puts("-x : pour extraire les fichiers de l'archive");
puts("-f : pour indiquer le nom du fichier archive");
puts("-z : pour compresser le fichier d'archive");
puts("-d : pour suprimer un fichier d'une archive");
puts(aSparsePour);
puts(aMAffciherLesDi);
return putchar(10);
}

canonical_decompiled_code:
int func7()
{
putchar(10);
puts("-h : affiche l'aide de votre commande");
puts(aVPourActiverLe);
puts(aCPourCr);
puts("-t : pour lister les fichiers contenus dans une archive");
puts("-r : pour ajouter de nouveaux fichiers");
puts(aUPourMettre);
puts("-x : pour extraire les fichiers de l'archive");
puts("-f : pour indiquer le nom du fichier archive");
puts("-z : pour compresser le fichier d'archive");
puts("-d : pour suprimer un fichier d'une archive");
puts(aSparsePour);
puts(aMAffciherLesDi);
return putchar(10);
}

original_code:
void afficherAide()
{
 printf("\n");
 printf("-h : affiche l'aide de votre commande\n");
 printf("-v : pour activer le mode verbose (affiche des détails sur l'execution)\n");
 printf("-c : pour créer une archive à partir d'une liste de fichier\n");
 printf("-t : pour lister les fichiers contenus dans une archive\n");
 printf("-r : pour ajouter de nouveaux fichiers\n");
 printf("-u : pour mettre à jour l'archive si les fichiers lités sont plus récents que ceux archivés\n");
 printf("-x : pour extraire les fichiers de l'archive\n");
 printf("-f : pour indiquer le nom du fichier archive\n");
 printf("-z : pour compresser le fichier d'archive\n");
 printf("-d : pour suprimer un fichier d'une archive\n");
 printf("-sparse : pour économiser de la place pour stocker les fichiers contenant beaucoup de zéros consécutifs\n");
 printf("-m : affciher les différences entre les fichiers archivés et les fichiers existants\n");
 printf("\n");
}

return_type: void


compression

decompiled_code:
void __fastcall compression(const char *a1)
{
char *ptr; // [rsp+8h] [rbp-10h] BYREF

asprintf(&ptr, "gzip %s", a1);
system(ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func12(const char *a1)
{
char *ptr; // [rsp+8h] [rbp-10h] BYREF

asprintf(&ptr, "gzip %s", a1);
system(ptr);
free(ptr);
}

original_code:
void compression (char* archive)
{
  char* nomArchive= archive;
  char *buf;
  asprintf(&buf, "gzip %s", nomArchive);
  system(buf);
  free(buf);
}

canonical_original_code:
void compression(char *archive)
{
  char *nomArchive = archive;
  char *buf;
  asprintf(&buf, "gzip %s", nomArchive);
  system(buf);
  free(buf);
}

variable_types:
archive
char *

variable_types:
nomArchive
char *

variable_types:
buf
char *


decompiled_code:
void *__fastcall wysylanie_serwer(void *a1)
{
char *v1; // r14
char *v3; // r12
unsigned __int64 v4; // rbp
int v5; // eax
bool v6; // zf
int v7; // edi

v1 = (char *)a1 + 16;
v3 = (char *)a1 + 280;
v4 = (unsigned __int64)a1 + 24;
while ( 1 )
{
*(_QWORD *)v1 = 0LL;
*((_QWORD *)v3 - 2) = 0LL;
memset((void *)(v4 & 0xFFFFFFFFFFFFFFF8LL), 0, 8 * (((unsigned int)v1 - (v4 & 0xFFFFFFF8) + 256) >> 3));
fgets(v1, 255, stdin);
v7 = *((_DWORD *)a1 + 1);
if ( *((_WORD *)a1 + 8) == 25901 )
break;
v5 = write(v7, v1, 0xFFuLL);
v6 = *((_WORD *)a1 + 8) == 25901;
*((_DWORD *)a1 + 3) = v5;
if ( v6 )
return 0LL;
}
*((_DWORD *)a1 + 3) = write(v7, v1, 0xFFuLL);
puts("Bye!");
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func0(void *a1)
{
char *v1; // r14
char *v3; // r12
unsigned __int64 v4; // rbp
int v5; // eax
bool v6; // zf
int v7; // edi

v1 = (char *)a1 + 16;
v3 = (char *)a1 + 280;
v4 = (unsigned __int64)a1 + 24;
while ( 1 )
{
*(_QWORD *)v1 = 0LL;
*((_QWORD *)v3 - 2) = 0LL;
memset((void *)(v4 & 0xFFFFFFFFFFFFFFF8LL), 0, 8 * (((unsigned int)v1 - (v4 & 0xFFFFFFF8) + 256) >> 3));
fgets(v1, 255, stdin);
v7 = *((_DWORD *)a1 + 1);
if ( *((_WORD *)a1 + 8) == 25901 )
break;
v5 = write(v7, v1, 0xFFuLL);
v6 = *((_WORD *)a1 + 8) == 25901;
*((_DWORD *)a1 + 3) = v5;
if ( v6 )
return 0LL;
}
*((_DWORD *)a1 + 3) = write(v7, v1, 0xFFuLL);
puts("Bye!");
return 0LL;
}

original_code:
void * wysylanie_serwer(void *arguments)
{
  struct ArgumentyProgramu *argumenty1=arguments;
  do
  {
    bzero(argumenty1->buffer,256);
    fgets(argumenty1->buffer,255,stdin);
    if((argumenty1->buffer[0]=='-' && argumenty1->buffer[1]=='e')==1)
    {
 argumenty1->n = write(argumenty1->newsockfd,argumenty1->buffer,255);
 printf("Bye!\n");
       return ((void *)0);
    }
    else {
    argumenty1->n = write(argumenty1->newsockfd,argumenty1->buffer,255); }
  }
    while((argumenty1->buffer[0]=='-' && argumenty1->buffer[1]=='e')==0);
    return ((void *)0);
}

canonical_original_code:
void *wysylanie_serwer(void *arguments)
{
  struct ArgumentyProgramu *argumenty1 = arguments;
  do
  {
    bzero(argumenty1->buffer,256);
    fgets(argumenty1->buffer,255,stdin);
    if((argumenty1->buffer[0]=='-' && argumenty1->buffer[1]=='e')==1)
    {
 argumenty1->n = write(argumenty1->newsockfd,argumenty1->buffer,255);
 printf("Bye!\n");
       return ((void *)0);
    }
    else {
    argumenty1->n = write(argumenty1->newsockfd,argumenty1->buffer,255); }
  }
    while((argumenty1->buffer[0]=='-' && argumenty1->buffer[1]=='e')==0);
    return ((void *)0);
}

variable_types:
arguments
void *

variable_types: struct ArgumentyProgramu { int sockfd; int newsockfd; int portno; int n; char buffer[256]; } *

return_type: void *


decompiled_code:
void *__fastcall sluchanie_serwer(void *a1)
{
_QWORD *v1; // r14
int v2; // eax

v1 = (char *)a1 + 16;
do
{
*v1 = 0LL;
*((_QWORD *)a1 + 33) = 0LL;
memset(
(void *)(((unsigned __int64)a1 + 24) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)v1 - (((_DWORD)a1 + 24) & 0xFFFFFFF8) + 256) >> 3));
v2 = read(*((_DWORD *)a1 + 1), v1, 0xFFuLL);
*((_DWORD *)a1 + 3) = v2;
if ( v2 < 0 )
error("ERROR reading from socket");
printf("client: %s", (const char *)v1);
}
while ( *((int *)a1 + 3) > 0 );
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func3(void *a1)
{
_QWORD *v1; // r14
int v2; // eax

v1 = (char *)a1 + 16;
do
{
*v1 = 0LL;
*((_QWORD *)a1 + 33) = 0LL;
memset(
(void *)(((unsigned __int64)a1 + 24) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)v1 - (((_DWORD)a1 + 24) & 0xFFFFFFF8) + 256) >> 3));
v2 = read(*((_DWORD *)a1 + 1), v1, 0xFFuLL);
*((_DWORD *)a1 + 3) = v2;
if ( v2 < 0 )
func2("ERROR reading from socket");
printf("client: %s", (const char *)v1);
}
while ( *((int *)a1 + 3) > 0 );
return 0LL;
}

original_code:
void * sluchanie_serwer(void *arguments)
{
   struct ArgumentyProgramu *argumenty=arguments;
   do
  {
   bzero(argumenty->buffer,256);
   argumenty->n = read(argumenty->newsockfd,argumenty->buffer,255);
   if (argumenty->n < 0) error("ERROR reading from socket");
   printf("client: %s",argumenty->buffer);
  }
    while(argumenty->n > 0);
    return ((void *)0);
}

canonical_original_code:
void *sluchanie_serwer(void *arguments)
{
   struct ArgumentyProgramu *argumenty = arguments;
   do
  {
   bzero(argumenty->buffer,256);
   argumenty->n = read(argumenty->newsockfd,argumenty->buffer,255);
   if (argumenty->n < 0) error("ERROR reading from socket");
   printf("client: %s",argumenty->buffer);
  }
    while(argumenty->n > 0);
    return ((void *)0);
}

user_defined_types: struct ArgumentyProgramu { int sockfd; int newsockfd; int portno; int n; char buffer[256]; }


error

decompiled_code:
void __fastcall __noreturn error(const char *a1)
{
perror(a1);
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func2(const char *a1)
{
perror(a1);
exit(0);
}

original_code:
void error(const char *msg)
{
    perror(msg);
    exit(0);
}

canonical_original_code:
void error(char *msg)
{
    perror(msg);
    exit(0);
}

variable_types:
msg
char *


server

decompiled_code:
__int64 __fastcall server(int a1)
{
socklen_t v1; // edx
int v2; // er8
socklen_t addr_len; // [rsp+Ch] [rbp-14Ch] BYREF
pthread_t newthread; // [rsp+10h] [rbp-148h] BYREF
pthread_t th; // [rsp+18h] [rbp-140h] BYREF
struct sockaddr v7; // [rsp+20h] [rbp-138h] BYREF
struct sockaddr addr; // [rsp+30h] [rbp-128h] BYREF
int fd; // [rsp+40h] [rbp-118h] BYREF
int v10; // [rsp+44h] [rbp-114h]
int v11; // [rsp+48h] [rbp-110h]

fd = socket(2, 1, 0);
if ( fd < 0 )
error("ERROR opening socket");
v11 = a1;
v7 = 0LL;
v7.sa_family = 2;
*(_WORD *)v7.sa_data = _bswap_16(a1);
if ( bind(v2, &v7, v1) < 0 )
error("ERROR on binding");
listen(fd, 5);
addr_len = 16;
v10 = accept(fd, &addr, &addr_len);
if ( v10 < 0 )
error("ERROR on accept");
pthread_create(&newthread, 0LL, sluchanie_serwer, &fd);
pthread_create(&th, 0LL, wysylanie_serwer, &fd);
pthread_join(th, 0LL);
pthread_cancel(newthread);
close(v10);
close(fd);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
socklen_t v1; // edx
int v2; // er8
socklen_t addr_len; // [rsp+Ch] [rbp-14Ch] BYREF
pthread_t newthread; // [rsp+10h] [rbp-148h] BYREF
pthread_t th; // [rsp+18h] [rbp-140h] BYREF
struct sockaddr v7; // [rsp+20h] [rbp-138h] BYREF
struct sockaddr addr; // [rsp+30h] [rbp-128h] BYREF
int fd; // [rsp+40h] [rbp-118h] BYREF
int v10; // [rsp+44h] [rbp-114h]
int v11; // [rsp+48h] [rbp-110h]

fd = socket(2, 1, 0);
if ( fd < 0 )
func2("ERROR opening socket");
v11 = a1;
v7 = 0LL;
v7.sa_family = 2;
*(_WORD *)v7.sa_data = func1(a1);
if ( bind(v2, &v7, v1) < 0 )
func2("ERROR on binding");
listen(fd, 5);
addr_len = 16;
v10 = accept(fd, &addr, &addr_len);
if ( v10 < 0 )
func2("ERROR on accept");
pthread_create(&newthread, 0LL, sluchanie_serwer, &fd);
pthread_create(&th, 0LL, wysylanie_serwer, &fd);
pthread_join(th, 0LL);
pthread_cancel(newthread);
close(v10);
close(fd);
return 0LL;
}

original_code:
int server(int portno)
{
     pthread_t sluchanies;
     pthread_t wysylanies;
     struct ArgumentyProgramu argumenty;
     socklen_t clilen;
     struct sockaddr_in serv_addr, cli_addr;
     int n;
     argumenty.sockfd = socket(2, SOCK_STREAM, 0);
     if (argumenty.sockfd < 0)
     {
        error("ERROR opening socket");
 return 1;
    }
     bzero((char *) &serv_addr, sizeof(serv_addr));
     argumenty.portno = portno;
     serv_addr.sin_family = 2;
     serv_addr.sin_addr.s_addr = ((in_addr_t) 0x00000000);
     serv_addr.sin_port = htons(argumenty.portno);
     if (bind(argumenty.sockfd, (struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0)
     {
              error("ERROR on binding");
       return 2;
    }
    listen(argumenty.sockfd,5);
     clilen = sizeof(cli_addr);
     argumenty.newsockfd = accept(argumenty.sockfd,
                 (struct sockaddr *) &cli_addr,
                 &clilen);
     if (argumenty.newsockfd < 0)
     {
          error("ERROR on accept");
   return 3;
     }
    pthread_create(&sluchanies,((void *)0),&sluchanie_serwer,(void*)&argumenty);
    pthread_create(&wysylanies,((void *)0),&wysylanie_serwer,(void*)&argumenty);
    pthread_join(wysylanies, ((void *)0));
    pthread_cancel(sluchanies);
    close(argumenty.newsockfd);
     close(argumenty.sockfd);
     return 0;
}

canonical_original_code:
int server(int portno)
{
     unsigned long sluchanies;
     unsigned long wysylanies;
     struct ArgumentyProgramu argumenty;
     unsigned int clilen;
     struct sockaddr_in serv_addr; struct sockaddr_in cli_addr;
     int n;
     argumenty.sockfd = socket(2, SOCK_STREAM, 0);
     if (argumenty.sockfd < 0)
     {
        error("ERROR opening socket");
 return 1;
    }
     bzero((char *) &serv_addr, sizeof(serv_addr));
     argumenty.portno = portno;
     serv_addr.sin_family = 2;
     serv_addr.sin_addr.s_addr = ((unsigned int) 0x00000000);
     serv_addr.sin_port = htons(argumenty.portno);
     if (bind(argumenty.sockfd, (struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0)
     {
              error("ERROR on binding");
       return 2;
    }
    listen(argumenty.sockfd,5);
     clilen = sizeof(cli_addr);
     argumenty.newsockfd = accept(argumenty.sockfd,
                 (struct sockaddr *) &cli_addr,
                 &clilen);
     if (argumenty.newsockfd < 0)
     {
          error("ERROR on accept");
   return 3;
     }
    pthread_create(&sluchanies,((void *)0),&sluchanie_serwer,(void *)&argumenty);
    pthread_create(&wysylanies,((void *)0),&wysylanie_serwer,(void *)&argumenty);
    pthread_join(wysylanies, ((void *)0));
    pthread_cancel(sluchanies);
    close(argumenty.newsockfd);
     close(argumenty.sockfd);
     return 0;
}

variable_types: portno int

variable_types:
sluchanies
unsigned long

variable_types:
wysylanies
unsigned long

variable_types: struct ArgumentyProgramu { int sockfd; int newsockfd; int portno; int n; char buffer[256]; }

variable_types:
clilen
unsigned 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

return_type: 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]; }

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


wczytywanie

decompiled_code:
void *__fastcall wczytywanie(void *a1)
{
printf("podaj numer portu ");
_isoc99_scanf("%d", a1);
puts("podaj kim chcesz byc: \n 1 :serwer \n 2 : klient");
_isoc99_scanf("%d", (char *)a1 + 4);
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func0(void *a1)
{
printf("podaj numer portu ");
_isoc99_scanf("%d", a1);
puts("podaj kim chcesz byc: \n 1 :serwer \n 2 : klient");
_isoc99_scanf("%d", (char *)a1 + 4);
return 0LL;
}

original_code:
void * wczytywanie(void *arguments)
{
  struct zmienne *wybieranie=arguments;
  printf("podaj numer portu ");
  scanf("%d",&wybieranie->portno);
  printf("podaj kim chcesz byc: \n 1 :serwer \n 2 : klient\n");
  scanf("%d",&wybieranie->k);
  return ((void *)0);
}

canonical_original_code:
void *wczytywanie(void *arguments)
{
  struct zmienne *wybieranie = arguments;
  printf("podaj numer portu ");
  scanf("%d",&wybieranie->portno);
  printf("podaj kim chcesz byc: \n 1 :serwer \n 2 : klient\n");
  scanf("%d",&wybieranie->k);
  return ((void *)0);
}

variable_types: struct zmienne { int portno; int k; char hostname[20]; } *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rbp
int v4; // er12
pthread_t newthread; // [rsp+8h] [rbp-40h] BYREF
unsigned int arg; // [rsp+10h] [rbp-38h] BYREF
int v8; // [rsp+14h] [rbp-34h]

v3 = argv[1];
pthread_create(&newthread, 0LL, wczytywanie, &arg);
pthread_join(newthread, 0LL);
puts("\nZaczynam dzialac\n Aby wyjsc z czatu nalezy wpisac -e \n tekst wysylasz po wcisnieciu <Enter> ");
printf("Czekam na polacznie... ");
v4 = v8;
if ( v8 == 1 )
{
server(arg);
v4 = v8;
}
if ( v4 != 2 )
return 0;
if ( argc == 1 )
{
puts("wywolujac jako klient nalezy podac hostname jako argument programu ");
}
else
{
v4 = 0;
client(arg, v3);
}
return v4;
}

original_code:
int main(int argc,char* argv[])
{
  pthread_t wybor;
  struct zmienne zm_glowne;
   char *host=zm_glowne.hostname;
   host=argv[1];
   pthread_create(&wybor,((void *)0),&wczytywanie,(void*)&zm_glowne);
   pthread_join(wybor, ((void *)0));
  printf("\nZaczynam dzialac\n Aby wyjsc z czatu nalezy wpisac -e \n tekst wysylasz po wcisnieciu <Enter> \n");
  printf("Czekam na polacznie... ");
  if(zm_glowne.k==1)
  {
    server(zm_glowne.portno);
  }
  if(zm_glowne.k==2)
  {
    if(argc==1)
  {
    printf("wywolujac jako klient nalezy podac hostname jako argument programu \n");
    return 2; }
    client(zm_glowne.portno,host);
  }
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
  unsigned long wybor;
  struct zmienne zm_glowne;
   char *host = zm_glowne.hostname;
   host=argv[1];
   pthread_create(&wybor,((void *)0),&wczytywanie,(void *)&zm_glowne);
   pthread_join(wybor, ((void *)0));
  printf("\nZaczynam dzialac\n Aby wyjsc z czatu nalezy wpisac -e \n tekst wysylasz po wcisnieciu <Enter> \n");
  printf("Czekam na polacznie... ");
  if(zm_glowne.k==1)
  {
    server(zm_glowne.portno);
  }
  if(zm_glowne.k==2)
  {
    if(argc==1)
  {
    printf("wywolujac jako klient nalezy podac hostname jako argument programu \n");
    return 2; }
    client(zm_glowne.portno,host);
  }
  return 0;
}

variable_types:
argv
char *[]

variable_types:
wybor
unsigned long

variable_types: struct zmienne { int portno; int k; char hostname[20]; }

variable_types:
host
char *


sendmessage

decompiled_code:
void __fastcall __noreturn sendmessage(void *a1)
{
size_t v1; // rbx
void *v2; // r13
size_t v3; // r15
size_t v4; // rax
int v5; // eax
__int128 vars0[5]; // [rsp+0h] [rbp+0h] BYREF
char dest[96]; // [rsp+50h] [rbp+50h] BYREF
int anonymous0; // [rsp+B0h] [rbp+B0h]

v1 = maxx - 4;
v2 = malloc(v1);
while ( 1 )
{
memset(dest, 0, sizeof(dest));
vars0[0] = 0LL;
vars0[1] = 0LL;
vars0[2] = 0LL;
vars0[3] = 0LL;
vars0[4] = 0LL;
anonymous0 = 0;
memset(v2, 0, v1);
wrefresh(top);
wrefresh(bottom);
if ( wmove(bottom, input, 2) != -1 )
wgetnstr(bottom, (char *)vars0, -1);
strcpy(dest, (const char *)a1);
v3 = 100 - strlen((const char *)vars0);
strncat(dest, ": ", v3);
strncat(dest, (const char *)vars0, v3);
if ( !strcmp((const char *)vars0, "exit") )
{
done = 1;
endwin();
pthread_mutex_destroy(&mutexsum);
pthread_exit(0LL);
}
v4 = strlen(dest);
write(sockfd, dest, v4);
mvwprintw(top, line, 2, dest);
pthread_mutex_lock(&mutexsum);
v5 = maxy / 2 - 2;
if ( v5 == line )
{
wscrl(top, 1);
v5 = maxy / 2 - 2;
}
else
{
++line;
}
if ( input == v5 )
wscrl(bottom, 1);
else
++input;
pthread_mutex_unlock(&mutexsum);
}
}

canonical_decompiled_code:
void __fastcall __noreturn func1(void *a1)
{
size_t v1; // rbx
void *v2; // r13
size_t v3; // r15
size_t v4; // rax
int v5; // eax
__int128 vars0[5]; // [rsp+0h] [rbp+0h] BYREF
char dest[96]; // [rsp+50h] [rbp+50h] BYREF
int anonymous0; // [rsp+B0h] [rbp+B0h]

v1 = maxx - 4;
v2 = malloc(v1);
while ( 1 )
{
memset(dest, 0, sizeof(dest));
vars0[0] = 0LL;
vars0[1] = 0LL;
vars0[2] = 0LL;
vars0[3] = 0LL;
vars0[4] = 0LL;
anonymous0 = 0;
memset(v2, 0, v1);
wrefresh(top);
wrefresh(bottom);
if ( wmove(bottom, input, 2) != -1 )
wgetnstr(bottom, (char *)vars0, -1);
strcpy(dest, (const char *)a1);
v3 = 100 - strlen((const char *)vars0);
strncat(dest, ": ", v3);
strncat(dest, (const char *)vars0, v3);
if ( !strcmp((const char *)vars0, "exit") )
{
done = 1;
endwin();
pthread_mutex_destroy(&mutexsum);
pthread_exit(0LL);
}
v4 = strlen(dest);
write(sockfd, dest, v4);
mvwprintw(top, line, 2, dest);
pthread_mutex_lock(&mutexsum);
v5 = maxy / 2 - 2;
if ( v5 == line )
{
wscrl(top, 1);
v5 = maxy / 2 - 2;
}
else
{
++line;
}
if ( input == v5 )
wscrl(bottom, 1);
else
++input;
pthread_mutex_unlock(&mutexsum);
}
}

original_code:
void *sendmessage(void *name)
{
    char str[80];
    char msg[100];
    int bufsize=maxx-4;
    char *buffer=malloc(bufsize);
    while(1)
    {
        bzero(str,80);
        bzero(msg,100);
        bzero(buffer,bufsize);
        wrefresh(top);
        wrefresh(bottom);
        (wmove((bottom),(input),(2)) == (-1) ? (-1) : wgetnstr((bottom), (str), -1));
        strcpy(msg,name);
        strncat(msg,": \0",100-strlen(str));
        strncat(msg,str,100-strlen(str));
        if(strcmp(str,"exit")==0)
        {
            done = 1;
            endwin();
            pthread_mutex_destroy(&mutexsum);
            pthread_exit(((void *)0));
            close(sockfd);
        }
        write(sockfd,msg,strlen(msg));
        mvwprintw(top,line,2,msg);
        pthread_mutex_lock (&mutexsum);
        if(line!=maxy/2-2)
            line++;
        else
            wscrl(top,1);
        if(input!=maxy/2-2)
            input++;
        else
            wscrl(bottom,1);
        pthread_mutex_unlock (&mutexsum);
    }
}

canonical_original_code:
void *sendmessage(void *name)
{
    char str[80];
    char msg[100];
    int bufsize = maxx-4;
    char *buffer = malloc(bufsize);
    while(1)
    {
        bzero(str,80);
        bzero(msg,100);
        bzero(buffer,bufsize);
        wrefresh(top);
        wrefresh(bottom);
        (wmove((bottom),(input),(2)) == (-1) ? (-1) : wgetnstr((bottom), (str), -1));
        strcpy(msg,name);
        strncat(msg,": \0",100-strlen(str));
        strncat(msg,str,100-strlen(str));
        if(strcmp(str,"exit")==0)
        {
            done = 1;
            endwin();
            pthread_mutex_destroy(&mutexsum);
            pthread_exit(((void *)0));
            close(sockfd);
        }
        write(sockfd,msg,strlen(msg));
        mvwprintw(top,line,2,msg);
        pthread_mutex_lock (&mutexsum);
        if(line!=maxy/2-2)
            line++;
        else
            wscrl(top,1);
        if(input!=maxy/2-2)
            input++;
        else
            wscrl(bottom,1);
        pthread_mutex_unlock (&mutexsum);
    }
}

variable_types:
name
void *

variable_types:
str
char [80]

variable_types:
msg
char [100]

variable_types: bufsize int

variable_types:
buffer
char *


listener

decompiled_code:
void __fastcall __noreturn listener(void *a1)
{
size_t v1; // rbp
void *v2; // rbx

v1 = maxx - 4;
v2 = malloc(v1);
while ( 1 )
{
memset(v2, 0, v1);
wrefresh(top);
wrefresh(bottom);
read(sockfd, v2, v1);
mvwprintw(top, line, 3, (const char *)v2);
pthread_mutex_lock(&mutexsum);
if ( maxy / 2 - 2 == line )
wscrl(top, 1);
else
++line;
pthread_mutex_unlock(&mutexsum);
}
}

canonical_decompiled_code:
void __fastcall __noreturn func2(void *a1)
{
size_t v1; // rbp
void *v2; // rbx

v1 = maxx - 4;
v2 = malloc(v1);
while ( 1 )
{
memset(v2, 0, v1);
wrefresh(top);
wrefresh(bottom);
read(sockfd, v2, v1);
mvwprintw(top, line, 3, (const char *)v2);
pthread_mutex_lock(&mutexsum);
if ( maxy / 2 - 2 == line )
wscrl(top, 1);
else
++line;
pthread_mutex_unlock(&mutexsum);
}
}

original_code:
void *listener()
{
    char str[80];
    int bufsize=maxx-4;
    char *buffer=malloc(bufsize);
    while(1)
    {
        bzero(buffer,bufsize);
        wrefresh(top);
        wrefresh(bottom);
        read(sockfd,buffer,bufsize);
        mvwprintw(top,line,3,buffer);
        pthread_mutex_lock (&mutexsum);
        if(line!=maxy/2-2)
            line++;
        else
            wscrl(top,1);
        pthread_mutex_unlock (&mutexsum);
    }
}

canonical_original_code:
void *listener()
{
    char str[80];
    int bufsize = maxx-4;
    char *buffer = malloc(bufsize);
    while(1)
    {
        bzero(buffer,bufsize);
        wrefresh(top);
        wrefresh(bottom);
        read(sockfd,buffer,bufsize);
        mvwprintw(top,line,3,buffer);
        pthread_mutex_lock (&mutexsum);
        if(line!=maxy/2-2)
            line++;
        else
            wscrl(top,1);
        pthread_mutex_unlock (&mutexsum);
    }
}


client

decompiled_code:
__int64 __fastcall client(__int64 a1, __int64 a2)
{
__int16 v2; // bx
const char *v3; // rdx
struct hostent *v4; // rax
socklen_t v5; // edx
const char *v6; // rdx
int v7; // esi
int v8; // edi
struct sockaddr v10; // [rsp+0h] [rbp-78h] BYREF
pthread_t newthread; // [rsp+10h] [rbp-68h] BYREF
pthread_t v12; // [rsp+18h] [rbp-60h] BYREF
pthread_attr_t attr; // [rsp+20h] [rbp-58h] BYREF

printf("Podaj swoj username: ");
_isoc99_scanf("%s", &name);
v2 = atoi(*(const char **)(a2 + 16));
sockfd = socket(2, 1, 0);
if ( sockfd < 0 )
error((int)"ERROR opening socket", 1, v3);
v4 = gethostbyname(*(const char **)(a2 + 8));
if ( !v4 )
{
fwrite("ERROR, no such host\n", 1uLL, 0x14uLL, stderr);
exit(0);
}
v10 = 0LL;
v10.sa_family = 2;
memmove(&v10.sa_data[2], *(const void **)v4->h_addr_list, v4->h_length);
*(_WORD *)v10.sa_data = _bswap_16(v2);
if ( connect(sockfd, &v10, v5) < 0 )
error((int)"ERROR connecting", (int)&v10, v6);
initscr();
if ( stdscr )
{
v7 = stdscr->_maxx + 1;
maxy = stdscr->_maxy + 1;
v8 = maxy / 2;
}
else
{
maxy = -1;
v8 = 0;
v7 = -1;
}
maxx = v7;
top = newwin(v8, v7, 0, 0);
bottom = newwin(maxy / 2, maxx, maxy / 2, 0);
scrollok(top, 1);
scrollok(bottom, 1);
wborder(top, 0x7CuLL, 0x7CuLL, 0x3DuLL, 0x3DuLL, 0LL, 0LL, 0LL, 0LL);
wborder(bottom, 0x7CuLL, 0x7CuLL, 0x2DuLL, 0x2DuLL, 0LL, 0LL, 0LL, 0LL);
wsetscrreg(top, 1, maxy / 2 - 2);
wsetscrreg(bottom, 1, maxy / 2 - 2);
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, 0);
pthread_create(&newthread, &attr, (void *(*)(void *))sendmessage, &name);
pthread_create(&v12, &attr, (void *(*)(void *))listener, 0LL);
if ( !done )
{
while ( 1 )
;
}
close(sockfd);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
__int16 v2; // bx
const char *v3; // rdx
struct hostent *v4; // rax
socklen_t v5; // edx
const char *v6; // rdx
int v7; // esi
int v8; // edi
struct sockaddr v10; // [rsp+0h] [rbp-78h] BYREF
pthread_t newthread; // [rsp+10h] [rbp-68h] BYREF
pthread_t v12; // [rsp+18h] [rbp-60h] BYREF
pthread_attr_t attr; // [rsp+20h] [rbp-58h] BYREF

printf("Podaj swoj username: ");
_isoc99_scanf("%s", &name);
v2 = atoi(*(const char **)(a2 + 16));
sockfd = socket(2, 1, 0);
if ( sockfd < 0 )
error((int)"ERROR opening socket", 1, v3);
v4 = gethostbyname(*(const char **)(a2 + 8));
if ( !v4 )
{
fwrite("ERROR, no such host\n", 1uLL, 0x14uLL, stderr);
exit(0);
}
v10 = 0LL;
v10.sa_family = 2;
memmove(&v10.sa_data[2], *(const void **)v4->h_addr_list, v4->h_length);
*(_WORD *)v10.sa_data = func0(v2);
if ( connect(sockfd, &v10, v5) < 0 )
error((int)"ERROR connecting", (int)&v10, v6);
initscr();
if ( stdscr )
{
v7 = stdscr->_maxx + 1;
maxy = stdscr->_maxy + 1;
v8 = maxy / 2;
}
else
{
maxy = -1;
v8 = 0;
v7 = -1;
}
maxx = v7;
top = newwin(v8, v7, 0, 0);
bottom = newwin(maxy / 2, maxx, maxy / 2, 0);
scrollok(top, 1);
scrollok(bottom, 1);
wborder(top, 0x7CuLL, 0x7CuLL, 0x3DuLL, 0x3DuLL, 0LL, 0LL, 0LL, 0LL);
wborder(bottom, 0x7CuLL, 0x7CuLL, 0x2DuLL, 0x2DuLL, 0LL, 0LL, 0LL, 0LL);
wsetscrreg(top, 1, maxy / 2 - 2);
wsetscrreg(bottom, 1, maxy / 2 - 2);
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, 0);
pthread_create(&newthread, &attr, (void *(*)(void *))sendmessage, &name);
pthread_create(&v12, &attr, (void *(*)(void *))listener, 0LL);
if ( !done )
{
while ( 1 )
;
}
close(sockfd);
return 0LL;
}

original_code:
int client(int argc, char *argv[])
{
 printf("Podaj swoj username: ");
 scanf("%s",name);
 int portno, n;
 struct sockaddr_in serv_addr;
 struct hostent *server;
 portno = atoi(argv[2]);
 sockfd = socket(2, SOCK_STREAM, 0);
 if (sockfd < 0)
  error("ERROR opening socket");
 server = gethostbyname(argv[1]);
 if (server == ((void *)0)) {
  fprintf(stderr, "ERROR, no such host\n");
  exit(0);
 }
 bzero((char *)&serv_addr, sizeof(serv_addr));
 serv_addr.sin_family = 2;
 bcopy((char *)server->h_addr_list[0],
  (char *)&serv_addr.sin_addr.s_addr,
  server->h_length);
 serv_addr.sin_port = htons(portno);
 if (connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
  error("ERROR connecting");
 initscr();
 (maxy = ((0 != (const void *)((stdscr))) ? ((stdscr)->_maxy + 1) : (-1)), maxx = ((0 != (const void *)((stdscr))) ? ((stdscr)->_maxx + 1) : (-1)));
 top = newwin(maxy/2,maxx,0,0);
 bottom= newwin(maxy/2,maxx,maxy/2,0);
 scrollok(top,1);
 scrollok(bottom,1);
  wborder(top, '|', '|', '=', '=', 0, 0, 0, 0);
 wborder(bottom, '|', '|', '-', '-', 0, 0, 0, 0);
  wsetscrreg(top,1,maxy/2-2);
  wsetscrreg(bottom,1,maxy/2-2);
 pthread_t threads[2];
 void *status;
 pthread_attr_t attr;
 pthread_attr_init(&attr);
 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
     pthread_create(&threads[0], &attr, sendmessage, (void *)name);
     pthread_create(&threads[1], &attr, listener, ((void *)0));
     while(!done);
 close(sockfd);
 return 0;
}

canonical_original_code:
int client(int argc, char *argv[])
{
 printf("Podaj swoj username: ");
 scanf("%s",name);
 int portno; int n;
 struct sockaddr_in serv_addr;
 struct hostent *server;
 portno = atoi(argv[2]);
 sockfd = socket(2, SOCK_STREAM, 0);
 if (sockfd < 0)
  error("ERROR opening socket");
 server = gethostbyname(argv[1]);
 if (server == ((void *)0)) {
  fprintf(stderr, "ERROR, no such host\n");
  exit(0);
 }
 bzero((char *)&serv_addr, sizeof(serv_addr));
 serv_addr.sin_family = 2;
 bcopy((char *)server->h_addr_list[0],
  (char *)&serv_addr.sin_addr.s_addr,
  server->h_length);
 serv_addr.sin_port = htons(portno);
 if (connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
  error("ERROR connecting");
 initscr();
 (maxy = ((0 != (void *)((stdscr))) ? ((stdscr)->_maxy + 1) : (-1)), maxx = ((0 != (void *)((stdscr))) ? ((stdscr)->_maxx + 1) : (-1)));
 top = newwin(maxy/2,maxx,0,0);
 bottom= newwin(maxy/2,maxx,maxy/2,0);
 scrollok(top,1);
 scrollok(bottom,1);
  wborder(top, '|', '|', '=', '=', 0, 0, 0, 0);
 wborder(bottom, '|', '|', '-', '-', 0, 0, 0, 0);
  wsetscrreg(top,1,maxy/2-2);
  wsetscrreg(bottom,1,maxy/2-2);
 unsigned long threads[2];
 void *status;
 union pthread_attr_t attr;
 pthread_attr_init(&attr);
 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
     pthread_create(&threads[0], &attr, sendmessage, (void *)name);
     pthread_create(&threads[1], &attr, listener, ((void *)0));
     while(!done);
 close(sockfd);
 return 0;
}

variable_types: argc int

variable_types: portno int

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

variable_types:
threads
unsigned long [2]

variable_types:
status
void *

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


decompiled_code:
void *__fastcall connection_handler(void *a1)
{
int i; // ebx
size_t v2; // rax
int v3; // eax

for ( i = *(_DWORD *)a1; ; write(i, client_message, v2) )
{
v3 = recv(i, client_message, 0x7D0uLL, 0);
if ( v3 <= 0 )
break;
v2 = strlen(client_message);
}
if ( v3 )
{
if ( v3 == -1 )
perror("Err RECV");
}
else
{
puts("Rozlaczono");
fflush(stdout);
}
free(a1);
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func1(void *a1)
{
int i; // ebx
size_t v2; // rax
int v3; // eax

for ( i = *(_DWORD *)a1; ; write(i, client_message, v2) )
{
v3 = recv(i, client_message, 0x7D0uLL, 0);
if ( v3 <= 0 )
break;
v2 = strlen(client_message);
}
if ( v3 )
{
if ( v3 == -1 )
perror("Err RECV");
}
else
{
puts("Rozlaczono");
fflush(stdout);
}
free(a1);
return 0LL;
}

original_code:
void *connection_handler(void *socket_desc)
{
    int sock = *(int*)socket_desc;
    int read_size;
    while( (read_size = recv(sock , client_message , 2000 , 0)) > 0 )
    {
        write(sock , client_message , strlen(client_message));
    }
    if(read_size == 0)
    {
        puts("Rozlaczono");
        fflush(stdout);
    }
    else if(read_size == -1)
    {
        perror("Err RECV");
    }
    free(socket_desc);
    return 0;
}

variable_types: sock int


error

decompiled_code:
void __fastcall __noreturn error(const char *a1)
{
perror(a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func2(const char *a1)
{
perror(a1);
exit(1);
}

original_code:
void error(const char *msg)
{
 perror(msg);
 exit(1);
}

canonical_original_code:
void error(char *msg)
{
 perror(msg);
 exit(1);
}

variable_types:
msg
char *


server

decompiled_code:
__int64 __fastcall server(int a1, __int64 a2)
{
int v2; // ebp
const char *v3; // rdi
__int16 v4; // ax
socklen_t v5; // edx
_DWORD *v6; // rax
int v7; // er12
socklen_t addr_len; // [rsp+4h] [rbp-44h] BYREF
pthread_t newthread; // [rsp+8h] [rbp-40h] BYREF
struct sockaddr v11; // [rsp+10h] [rbp-38h] BYREF
struct sockaddr addr; // [rsp+20h] [rbp-28h] BYREF

if ( a1 <= 1 )
{
fwrite("ERROR, no port provided\n", 1uLL, 0x18uLL, stderr);
exit(1);
}
v2 = socket(2, 1, 0);
if ( v2 < 0 )
perror("ERROR opening socket");
v3 = *(const char **)(a2 + 8);
v11 = 0LL;
v4 = atoi(v3);
v11.sa_family = 2;
*(_WORD *)v11.sa_data = _bswap_16(v4);
if ( bind(v2, &v11, v5) < 0 )
perror("ERROR on binding");
puts("\n Gotowy! ...");
listen(v2, 5);
addr_len = 16;
while ( 1 )
{
v7 = accept(v2, &addr, &addr_len);
if ( !v7 )
{
close(0);
close(v2);
return 0LL;
}
puts("Polaczony");
v6 = malloc(1uLL);
*v6 = v7;
if ( pthread_create(&newthread, 0LL, connection_handler, v6) < 0 )
break;
puts("Klient polaczony");
}
perror("Error with create_thread!");
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, __int64 a2)
{
int v2; // ebp
const char *v3; // rdi
__int16 v4; // ax
socklen_t v5; // edx
_DWORD *v6; // rax
int v7; // er12
socklen_t addr_len; // [rsp+4h] [rbp-44h] BYREF
pthread_t newthread; // [rsp+8h] [rbp-40h] BYREF
struct sockaddr v11; // [rsp+10h] [rbp-38h] BYREF
struct sockaddr addr; // [rsp+20h] [rbp-28h] BYREF

if ( a1 <= 1 )
{
fwrite("ERROR, no port provided\n", 1uLL, 0x18uLL, stderr);
exit(1);
}
v2 = socket(2, 1, 0);
if ( v2 < 0 )
perror("ERROR opening socket");
v3 = *(const char **)(a2 + 8);
v11 = 0LL;
v4 = atoi(v3);
v11.sa_family = 2;
*(_WORD *)v11.sa_data = func0(v4);
if ( bind(v2, &v11, v5) < 0 )
perror("ERROR on binding");
puts("\n Gotowy! ...");
listen(v2, 5);
addr_len = 16;
while ( 1 )
{
v7 = accept(v2, &addr, &addr_len);
if ( !v7 )
{
close(0);
close(v2);
return 0LL;
}
puts("Polaczony");
v6 = malloc(1uLL);
*v6 = v7;
if ( pthread_create(&newthread, 0LL, connection_handler, v6) < 0 )
break;
puts("Klient polaczony");
}
perror("Error with create_thread!");
return 1LL;
}

original_code:
int server(int argc, char *argv[])
{
 int sockfd, newsockfd, portno, *new_sock;
 socklen_t clilen;
 char buffer[256];
 struct sockaddr_in serv_addr, cli_addr;
 int n;
 if (argc < 2) {
  fprintf(stderr, "ERROR, no port provided\n");
  exit(1);
 }
 sockfd = socket(2, SOCK_STREAM, 0);
 if (sockfd < 0)
  perror("ERROR opening socket");
 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)
  perror("ERROR on binding");
 printf("\n Gotowy! ...\n");
 listen(sockfd, 5);
 clilen = sizeof(cli_addr);
 while(newsockfd = accept(sockfd,
  (struct sockaddr *) &cli_addr,
  &clilen))
 {
  puts("Polaczony");
  pthread_t sniffer_thread;
  new_sock = malloc(1);
  *new_sock = newsockfd;
  if( pthread_create( &sniffer_thread , ((void *)0) , connection_handler , (void*) new_sock) < 0 )
  {
   perror("Error with create_thread!");
   return 1;
  }
  puts("Klient polaczony");
 }
 if (newsockfd < 0)
   error("ERROR on accept");
 close(newsockfd);
 close(sockfd);
 return 0;
}

canonical_original_code:
int server(int argc, char *argv[])
{
 int sockfd; int newsockfd; int portno; int *new_sock;
 unsigned int clilen;
 char buffer[256];
 struct sockaddr_in serv_addr; struct sockaddr_in cli_addr;
 int n;
 if (argc < 2) {
  fprintf(stderr, "ERROR, no port provided\n");
  exit(1);
 }
 sockfd = socket(2, SOCK_STREAM, 0);
 if (sockfd < 0)
  perror("ERROR opening socket");
 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)
  perror("ERROR on binding");
 printf("\n Gotowy! ...\n");
 listen(sockfd, 5);
 clilen = sizeof(cli_addr);
 while(newsockfd = accept(sockfd,
  (struct sockaddr *) &cli_addr,
  &clilen))
 {
  puts("Polaczony");
  unsigned long sniffer_thread;
  new_sock = malloc(1);
  *new_sock = newsockfd;
  if( pthread_create( &sniffer_thread , ((void *)0) , connection_handler , (void *) new_sock) < 0 )
  {
   perror("Error with create_thread!");
   return 1;
  }
  puts("Klient polaczony");
 }
 if (newsockfd < 0)
   error("ERROR on accept");
 close(newsockfd);
 close(sockfd);
 return 0;
}

variable_types:
argv
char *[]

variable_types: sockfd int

variable_types: newsockfd 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: n int


decompiled_code:
void *__fastcall sluchanie_client(void *a1)
{
_QWORD *v1; // r14
int v2; // eax
const char *v3; // rdx

v1 = (char *)a1 + 16;
while ( 1 )
{
*v1 = 0LL;
*((_QWORD *)a1 + 33) = 0LL;
memset(
(void *)(((unsigned __int64)a1 + 24) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)v1 - (((_DWORD)a1 + 24) & 0xFFFFFFF8) + 256) >> 3));
v2 = read(*(_DWORD *)a1, v1, 0xFFuLL);
*((_DWORD *)a1 + 3) = v2;
if ( v2 < 0 )
break;
if ( *((_WORD *)a1 + 8) == 25901 )
goto LABEL_6;
LABEL_3:
printf("server: %s", (const char *)v1);
if ( *((int *)a1 + 3) <= 0 )
return 0LL;
}
error((int)"ERROR reading from socket", (int)v1, v3);
if ( *((_WORD *)a1 + 8) != 25901 )
goto LABEL_3;
LABEL_6:
puts("serwer rozlaczony\nBye");
pthread_cancel(*((_QWORD *)a1 + 35));
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func0(void *a1)
{
_QWORD *v1; // r14
int v2; // eax
const char *v3; // rdx

v1 = (char *)a1 + 16;
while ( 1 )
{
*v1 = 0LL;
*((_QWORD *)a1 + 33) = 0LL;
memset(
(void *)(((unsigned __int64)a1 + 24) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)v1 - (((_DWORD)a1 + 24) & 0xFFFFFFF8) + 256) >> 3));
v2 = read(*(_DWORD *)a1, v1, 0xFFuLL);
*((_DWORD *)a1 + 3) = v2;
if ( v2 < 0 )
break;
if ( *((_WORD *)a1 + 8) == 25901 )
goto LABEL_6;
LABEL_3:
printf("server: %s", (const char *)v1);
if ( *((int *)a1 + 3) <= 0 )
return 0LL;
}
error((int)"ERROR reading from socket", (int)v1, v3);
if ( *((_WORD *)a1 + 8) != 25901 )
goto LABEL_3;
LABEL_6:
puts("serwer rozlaczony\nBye");
pthread_cancel(*((_QWORD *)a1 + 35));
return 0LL;
}

original_code:
void * sluchanie_client(void *arguments)
{
   struct ArgumentyProgramu *argumenty=arguments;
   do
  {
   bzero(argumenty->buffer,256);
   argumenty->n = read(argumenty->sockfd,argumenty->buffer,255);
   if (argumenty->n < 0) error("ERROR reading from socket");
   if((argumenty->buffer[0]=='-' && argumenty->buffer[1]=='e')==1)
      {
 printf("serwer rozlaczony\nBye\n");
 pthread_cancel(argumenty->wysylanie);
 return ((void *)0); }
   printf("server: %s",argumenty->buffer);
  }
    while(argumenty->n > 0 );
    return ((void *)0);
}

canonical_original_code:
void *sluchanie_client(void *arguments)
{
   struct ArgumentyProgramu *argumenty = arguments;
   do
  {
   bzero(argumenty->buffer,256);
   argumenty->n = read(argumenty->sockfd,argumenty->buffer,255);
   if (argumenty->n < 0) error("ERROR reading from socket");
   if((argumenty->buffer[0]=='-' && argumenty->buffer[1]=='e')==1)
      {
 printf("serwer rozlaczony\nBye\n");
 pthread_cancel(argumenty->wysylanie);
 return ((void *)0); }
   printf("server: %s",argumenty->buffer);
  }
    while(argumenty->n > 0 );
    return ((void *)0);
}

variable_types:
arguments
void *

variable_types: struct ArgumentyProgramu { int sockfd; int newsockfd; int portno; int n; char buffer[256]; unsigned long sluchanie; unsigned long wysylanie; } *


original_code:
void * wysylanie_client(void *arguments)
{
  struct ArgumentyProgramu *argumenty1=arguments;
  do
  {
    bzero(argumenty1->buffer,256);
    fgets(argumenty1->buffer,255,stdin);
    if((argumenty1->buffer[0]=='-' && argumenty1->buffer[1]=='e')==1 )
    {
 bzero(argumenty1->buffer,256);
 strcpy(argumenty1->buffer,"client rozlaczony wpisz -e aby rowniez sie rozlaczyc\n");
 argumenty1->n = write(argumenty1->sockfd,argumenty1->buffer,255);
 sleep(1);
       return ((void *)0);
    }
    else {
     argumenty1->n = write(argumenty1->sockfd,argumenty1->buffer,255); }
  }
    while((argumenty1->buffer[0]=='-' && argumenty1->buffer[1]=='e')==0);
    return ((void *)0);
}

canonical_original_code:
void *wysylanie_client(void *arguments)
{
  struct ArgumentyProgramu *argumenty1 = arguments;
  do
  {
    bzero(argumenty1->buffer,256);
    fgets(argumenty1->buffer,255,stdin);
    if((argumenty1->buffer[0]=='-' && argumenty1->buffer[1]=='e')==1 )
    {
 bzero(argumenty1->buffer,256);
 strcpy(argumenty1->buffer,"client rozlaczony wpisz -e aby rowniez sie rozlaczyc\n");
 argumenty1->n = write(argumenty1->sockfd,argumenty1->buffer,255);
 sleep(1);
       return ((void *)0);
    }
    else {
     argumenty1->n = write(argumenty1->sockfd,argumenty1->buffer,255); }
  }
    while((argumenty1->buffer[0]=='-' && argumenty1->buffer[1]=='e')==0);
    return ((void *)0);
}

user_defined_types: struct ArgumentyProgramu { int sockfd; int newsockfd; int portno; int n; char buffer[256]; unsigned long sluchanie; unsigned long wysylanie; }


client

decompiled_code:
__int64 __fastcall client(int a1, const char *a2)
{
const char *v2; // rdx
struct hostent *v3; // rax
socklen_t v4; // edx
const char *v5; // rdx
__int64 result; // rax
struct sockaddr v7; // [rsp+0h] [rbp-138h] BYREF
int fd; // [rsp+10h] [rbp-128h] BYREF
int v9; // [rsp+18h] [rbp-120h]
pthread_t newthread; // [rsp+120h] [rbp-18h] BYREF
pthread_t th[2]; // [rsp+128h] [rbp-10h] BYREF

v9 = a1;
fd = socket(2, 1, 0);
if ( fd < 0 )
{
error((int)"ERROR opening socket", 1, v2);
result = 4LL;
}
else
{
v3 = gethostbyname(a2);
if ( !v3 )
{
fwrite("ERROR, no such host\n", 1uLL, 0x14uLL, stderr);
exit(0);
}
v7 = 0LL;
v7.sa_family = 2;
memmove(&v7.sa_data[2], *(const void **)v3->h_addr_list, v3->h_length);
*(_WORD *)v7.sa_data = _bswap_16(v9);
if ( connect(fd, &v7, v4) < 0 )
{
error((int)"ERROR connecting", (int)&v7, v5);
result = 6LL;
}
else
{
pthread_create(&newthread, 0LL, sluchanie_client, &fd);
pthread_create(th, 0LL, wysylanie_client, &fd);
pthread_join(th[0], 0LL);
pthread_cancel(newthread);
close(fd);
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, const char *a2)
{
const char *v2; // rdx
struct hostent *v3; // rax
socklen_t v4; // edx
const char *v5; // rdx
__int64 result; // rax
struct sockaddr v7; // [rsp+0h] [rbp-138h] BYREF
int fd; // [rsp+10h] [rbp-128h] BYREF
int v9; // [rsp+18h] [rbp-120h]
pthread_t newthread; // [rsp+120h] [rbp-18h] BYREF
pthread_t th[2]; // [rsp+128h] [rbp-10h] BYREF

v9 = a1;
fd = socket(2, 1, 0);
if ( fd < 0 )
{
error((int)"ERROR opening socket", 1, v2);
result = 4LL;
}
else
{
v3 = gethostbyname(a2);
if ( !v3 )
{
fwrite("ERROR, no such host\n", 1uLL, 0x14uLL, stderr);
exit(0);
}
v7 = 0LL;
v7.sa_family = 2;
memmove(&v7.sa_data[2], *(const void **)v3->h_addr_list, v3->h_length);
*(_WORD *)v7.sa_data = func2(v9);
if ( connect(fd, &v7, v4) < 0 )
{
error((int)"ERROR connecting", (int)&v7, v5);
result = 6LL;
}
else
{
pthread_create(&newthread, 0LL, sluchanie_client, &fd);
pthread_create(th, 0LL, wysylanie_client, &fd);
pthread_join(th[0], 0LL);
pthread_cancel(newthread);
close(fd);
result = 0LL;
}
}
return result;
}

original_code:
int client(int portno,char host[] )
{
    struct ArgumentyProgramu argumenty;
    struct sockaddr_in serv_addr;
    struct hostent *server;
    argumenty.portno = portno;
    argumenty.sockfd = socket(2, SOCK_STREAM, 0);
    if (argumenty.sockfd < 0)
    {
        error("ERROR opening socket");
 return 4;
    }
    server = gethostbyname(host);
    if (server == ((void *)0)) {
        fprintf(stderr,"ERROR, no such host\n");
        exit(0);
    }
    bzero((char *) &serv_addr, sizeof(serv_addr));
    serv_addr.sin_family = 2;
    bcopy((char *)server->h_addr_list[0],
         (char *)&serv_addr.sin_addr.s_addr,
         server->h_length);
    serv_addr.sin_port = htons(argumenty.portno);
    if (connect(argumenty.sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0)
    {
        error("ERROR connecting");
 return 6;
    }
   pthread_create(&argumenty.sluchanie,((void *)0),&sluchanie_client,(void*)&argumenty);
   pthread_create(&argumenty.wysylanie,((void *)0),&wysylanie_client,(void*)&argumenty);
   pthread_join(argumenty.wysylanie, ((void *)0));
   pthread_cancel(argumenty.sluchanie);
   close(argumenty.sockfd);
   return 0;
}

canonical_original_code:
int client(int portno, char host[])
{
    struct ArgumentyProgramu argumenty;
    struct sockaddr_in serv_addr;
    struct hostent *server;
    argumenty.portno = portno;
    argumenty.sockfd = socket(2, SOCK_STREAM, 0);
    if (argumenty.sockfd < 0)
    {
        error("ERROR opening socket");
 return 4;
    }
    server = gethostbyname(host);
    if (server == ((void *)0)) {
        fprintf(stderr,"ERROR, no such host\n");
        exit(0);
    }
    bzero((char *) &serv_addr, sizeof(serv_addr));
    serv_addr.sin_family = 2;
    bcopy((char *)server->h_addr_list[0],
         (char *)&serv_addr.sin_addr.s_addr,
         server->h_length);
    serv_addr.sin_port = htons(argumenty.portno);
    if (connect(argumenty.sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0)
    {
        error("ERROR connecting");
 return 6;
    }
   pthread_create(&argumenty.sluchanie,((void *)0),&sluchanie_client,(void *)&argumenty);
   pthread_create(&argumenty.wysylanie,((void *)0),&wysylanie_client,(void *)&argumenty);
   pthread_join(argumenty.wysylanie, ((void *)0));
   pthread_cancel(argumenty.sluchanie);
   close(argumenty.sockfd);
   return 0;
}

variable_types:
host
char []

variable_types: struct ArgumentyProgramu { int sockfd; int newsockfd; int portno; int n; char buffer[256]; unsigned long sluchanie; unsigned long wysylanie; }

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


repo: AlertProject/CCCC

decompiled_code:
void __fastcall r_intersect(__int64 a1, __int64 *a2)
{
__int64 v2; // rbx
__int64 v3; // rdx
__int64 v4; // rdi
__int64 v5; // rax
void *v6; // rdx
void *v7; // r12
__int64 v8; // r13
void *v9; // rdi

if ( a1 )
{
v2 = a1;
do
{
if ( *(_DWORD *)(v2 + 4) == operation_no )
break;
v3 = *(unsigned int *)(v2 + 32);
v4 = *(unsigned int *)a2;
*(_DWORD *)(v2 + 4) = operation_no;
v5 = set_and(v4, a2[1], v3, *(_QWORD *)(v2 + 40));
v7 = v6;
v8 = v5;
if ( (unsigned int)set_nil((unsigned int)v5, v6) )
{
if ( v7 )
free(v7);
}
else
{
v9 = (void *)a2[1];
if ( v9 )
free(v9);
*a2 = v8;
a2[1] = (__int64)v7;
}
r_intersect(*(_QWORD *)(v2 + 16), a2);
v2 = *(_QWORD *)(v2 + 24);
}
while ( v2 );
}
}

original_code:
void r_intersect(struct _nfa_node* start,set* maximal_class)
{
 set temp;
 if(start && start->nfa_set != operation_no)
 {
  start->nfa_set = operation_no;
  temp = set_and(*maximal_class,start->label);
  if (!set_nil(temp))
  {
   {if ( (*maximal_class).setword != ((void *)0) ) free((char *)((*maximal_class).setword)); (*maximal_class) = empty;};
   *maximal_class = temp;
  }else{
   {if ( (temp).setword != ((void *)0) ) free((char *)((temp).setword)); (temp) = empty;};
  }
  r_intersect(start->trans[0],maximal_class);
  r_intersect(start->trans[1],maximal_class);
 }
}

canonical_original_code:
void r_intersect(struct _nfa_node *start, struct _set *maximal_class)
{
 struct _set temp;
 if(start && start->nfa_set != operation_no)
 {
  start->nfa_set = operation_no;
  temp = set_and(*maximal_class,start->label);
  if (!set_nil(temp))
  {
   {if ( (*maximal_class).setword != ((void *)0) ) free((char *)((*maximal_class).setword)); (*maximal_class) = empty;};
   *maximal_class = temp;
  }else{
   {if ( (temp).setword != ((void *)0) ) free((char *)((temp).setword)); (temp) = empty;};
  }
  r_intersect(start->trans[0],maximal_class);
  r_intersect(start->trans[1],maximal_class);
 }
}

variable_types: struct _nfa_node { int node_no; int nfa_set; int accept; struct _nfa_node *trans[2]; struct _set { unsigned int n; unsigned int *setword; } label; } *

user_defined_types: struct _nfa_node { int node_no; int nfa_set; int accept; struct _nfa_node *trans[2]; struct _set label; }


decompiled_code:
void __fastcall intersect_nfa_labels(__int64 a1, __int64 *a2)
{
++operation_no;
r_intersect(a1, a2);
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1, __int64 *a2)
{
++operation_no;
func0(a1, a2);
}

original_code:
void intersect_nfa_labels(struct _nfa_node* start,set* maximal_class)
{
 ++operation_no;
 r_intersect(start,maximal_class);
}

canonical_original_code:
void intersect_nfa_labels(struct _nfa_node *start, struct _set *maximal_class)
{
 ++operation_no;
 r_intersect(start,maximal_class);
}

user_defined_types: struct _set { unsigned int n; unsigned int *setword; }


partition

decompiled_code:
void __fastcall partition(__int64 a1, int a2)
{
unsigned int v2; // eax
unsigned int v3; // ebx
void *v4; // rdx
void *i; // rbp
__int64 v6; // rdx
int v7; // eax
__m128i v8; // xmm0
__int64 v9; // rdx
int v10; // er8
__int64 v11; // rax
__int64 v12; // rcx
unsigned int v13; // eax
void *v14; // rdx
void *v15; // r14
unsigned int v16; // eax
__int64 v17; // rdx
__m128i v18; // [rsp+0h] [rbp-38h] BYREF

v2 = set_dup(used_chars, *((_QWORD *)&used_chars + 1));
class_no = 0;
v3 = v2;
for ( i = v4; !(unsigned int)set_nil(v3, i); i = v15 )
{
if ( a2 > 1 )
{
v18.m128i_i32[0] = set_dup(v3, i);
v18.m128i_i64[1] = v6;
intersect_nfa_labels(a1, v18.m128i_i64);
}
else
{
v16 = set_int(v3, i);
v18.m128i_i32[0] = set_of(v16);
v18.m128i_i64[1] = v17;
}
((void (__fastcall *)(_QWORD, void *))set_orel)((unsigned int)class_no, &used_classes);
v7 = set_int(v18.m128i_u32[0], v18.m128i_i64[1]);
v8 = _mm_loadu_si128(&v18);
v9 = v18.m128i_u32[0];
v10 = v7;
v11 = class_no;
v12 = v18.m128i_i64[1];
first_el[class_no] = v10;
class_sets[v11] = (__int128)v8;
v13 = set_dif(v3, i, v9, v12);
v15 = v14;
v3 = v13;
if ( i )
free(i);
++class_no;
}
if ( i )
free(i);
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, int a2)
{
unsigned int v2; // eax
unsigned int v3; // ebx
void *v4; // rdx
void *i; // rbp
__int64 v6; // rdx
int v7; // eax
__m128i v8; // xmm0
__int64 v9; // rdx
int v10; // er8
__int64 v11; // rax
__int64 v12; // rcx
unsigned int v13; // eax
void *v14; // rdx
void *v15; // r14
unsigned int v16; // eax
__int64 v17; // rdx
__m128i v18; // [rsp+0h] [rbp-38h] BYREF

v2 = set_dup(used_chars, *((_QWORD *)&used_chars + 1));
class_no = 0;
v3 = v2;
for ( i = v4; !(unsigned int)set_nil(v3, i); i = v15 )
{
if ( a2 > 1 )
{
v18.m128i_i32[0] = set_dup(v3, i);
v18.m128i_i64[1] = v6;
func1(a1, v18.m128i_i64);
}
else
{
v16 = set_int(v3, i);
v18.m128i_i32[0] = set_of(v16);
v18.m128i_i64[1] = v17;
}
((void (__fastcall *)(_QWORD, void *))set_orel)((unsigned int)class_no, &used_classes);
v7 = set_int(v18.m128i_u32[0], v18.m128i_i64[1]);
v8 = _mm_loadu_si128(&v18);
v9 = v18.m128i_u32[0];
v10 = v7;
v11 = class_no;
v12 = v18.m128i_i64[1];
first_el[class_no] = v10;
class_sets[v11] = (__int128)v8;
v13 = set_dif(v3, i, v9, v12);
v15 = v14;
v3 = v13;
if ( i )
free(i);
++class_no;
}
if ( i )
free(i);
}

original_code:
void partition(struct _nfa_node* start,int level)
{
 set current_class;
 set unpart_chars;
 set temp;
 unpart_chars = set_dup(used_chars);
 class_no = 0;
 while (!set_nil(unpart_chars)){
  if (level <= 1){
   current_class = set_of(set_int(unpart_chars));
  }else{
   current_class = set_dup(unpart_chars);
   intersect_nfa_labels(start,&current_class);
  }
  set_orel(class_no,&used_classes);
  first_el[class_no] = set_int(current_class);
  class_sets[class_no] = current_class;
  temp = set_dif(unpart_chars,current_class);
  {if ( (unpart_chars).setword != ((void *)0) ) free((char *)((unpart_chars).setword)); (unpart_chars) = empty;};
  unpart_chars = temp;
  ++class_no;
 }
 {if ( (unpart_chars).setword != ((void *)0) ) free((char *)((unpart_chars).setword)); (unpart_chars) = empty;};
}

canonical_original_code:
void partition(struct _nfa_node *start, int level)
{
 struct _set current_class;
 struct _set unpart_chars;
 struct _set temp;
 unpart_chars = set_dup(used_chars);
 class_no = 0;
 while (!set_nil(unpart_chars)){
  if (level <= 1){
   current_class = set_of(set_int(unpart_chars));
  }else{
   current_class = set_dup(unpart_chars);
   intersect_nfa_labels(start,&current_class);
  }
  set_orel(class_no,&used_classes);
  first_el[class_no] = set_int(current_class);
  class_sets[class_no] = current_class;
  temp = set_dif(unpart_chars,current_class);
  {if ( (unpart_chars).setword != ((void *)0) ) free((char *)((unpart_chars).setword)); (unpart_chars) = empty;};
  unpart_chars = temp;
  ++class_no;
 }
 {if ( (unpart_chars).setword != ((void *)0) ) free((char *)((unpart_chars).setword)); (unpart_chars) = empty;};
}

variable_types: level int

variable_types: struct _set { unsigned int n; unsigned int *setword; }


decompiled_code:
void __fastcall label_node(__int64 a1)
{
__int64 v2; // rbx
__int64 v3; // rdi
void *v4; // rdi
__int64 v5; // rdi
__m128i v6[2]; // [rsp+0h] [rbp-28h] BYREF

if ( a1 && *(_DWORD *)(a1 + 4) != operation_no )
{
*(_DWORD *)(a1 + 4) = operation_no;
v6[0] = _mm_loadu_si128(&empty);
if ( class_no > 0 )
{
v2 = 0LL;
do
{
while ( !(unsigned int)set_el((unsigned int)first_el[v2], *(unsigned int *)(a1 + 32), *(_QWORD *)(a1 + 40)) )
{
if ( class_no <= (int)++v2 )
goto LABEL_8;
}
v3 = (unsigned int)v2++;
((void (__fastcall *)(__int64, __m128i *))set_orel)(v3, v6);
}
while ( class_no > (int)v2 );
}
LABEL_8:
v4 = *(void **)(a1 + 40);
if ( v4 )
free(v4);
v5 = *(_QWORD *)(a1 + 16);
*(__m128i *)(a1 + 32) = _mm_loadu_si128(v6);
label_node(v5);
label_node(*(_QWORD *)(a1 + 24));
}
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1)
{
__int64 v2; // rbx
__int64 v3; // rdi
void *v4; // rdi
__int64 v5; // rdi
__m128i v6[2]; // [rsp+0h] [rbp-28h] BYREF

if ( a1 && *(_DWORD *)(a1 + 4) != operation_no )
{
*(_DWORD *)(a1 + 4) = operation_no;
v6[0] = _mm_loadu_si128(&empty);
if ( class_no > 0 )
{
v2 = 0LL;
do
{
while ( !(unsigned int)set_el((unsigned int)first_el[v2], *(unsigned int *)(a1 + 32), *(_QWORD *)(a1 + 40)) )
{
if ( class_no <= (int)++v2 )
goto LABEL_8;
}
v3 = (unsigned int)v2++;
((void (__fastcall *)(__int64, __m128i *))set_orel)(v3, v6);
}
while ( class_no > (int)v2 );
}
LABEL_8:
v4 = *(void **)(a1 + 40);
if ( v4 )
free(v4);
v5 = *(_QWORD *)(a1 + 16);
*(__m128i *)(a1 + 32) = _mm_loadu_si128(v6);
func3(v5);
func3(*(_QWORD *)(a1 + 24));
}
}

original_code:
void label_node(struct _nfa_node *start)
{
 set new_label;
 register int i;
 if (start && start->nfa_set != operation_no){
  start->nfa_set = operation_no;
  new_label = empty;
  for (i = 0; i<class_no; ++i){
   if (set_el(first_el[i],start->label))
    set_orel(i,&new_label);
  }
  {if ( (start->label).setword != ((void *)0) ) free((char *)((start->label).setword)); (start->label) = empty;};
  start->label = new_label;
  label_node(start->trans[0]);
  label_node(start->trans[1]);
 }
}

canonical_original_code:
void label_node(struct _nfa_node *start)
{
 struct _set new_label;
 register int i;
 if (start && start->nfa_set != operation_no){
  start->nfa_set = operation_no;
  new_label = empty;
  for (i = 0; i<class_no; ++i){
   if (set_el(first_el[i],start->label))
    set_orel(i,&new_label);
  }
  {if ( (start->label).setword != ((void *)0) ) free((char *)((start->label).setword)); (start->label) = empty;};
  start->label = new_label;
  label_node(start->trans[0]);
  label_node(start->trans[1]);
 }
}

variable_types: i int


decompiled_code:
void __fastcall label_with_classes(__int64 a1)
{
++operation_no;
label_node(a1);
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1)
{
++operation_no;
func3(a1);
}

original_code:
void label_with_classes(struct _nfa_node* start)
{
 ++operation_no;
 label_node(start);
}

canonical_original_code:
void label_with_classes(struct _nfa_node *start)
{
 ++operation_no;
 label_node(start);
}


relabel

decompiled_code:
__int64 __fastcall relabel(__int64 a1, int a2)
{
void *v3; // rdi
__int64 result; // rax

if ( a2 )
{
v3 = (void *)*((_QWORD *)&used_classes + 1);
if ( v3 )
free(v3);
used_classes = _mm_loadu_si128(&empty);
partition(a1, a2);
label_with_classes(a1);
result = (unsigned int)class_no;
}
else
{
class_no = 257;
result = 257LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, int a2)
{
void *v3; // rdi
__int64 result; // rax

if ( a2 )
{
v3 = (void *)*((_QWORD *)&used_classes + 1);
if ( v3 )
free(v3);
used_classes = _mm_loadu_si128(&empty);
func2(a1, a2);
func4(a1);
result = (unsigned int)class_no;
}
else
{
class_no = 257;
result = 257LL;
}
return result;
}

original_code:
int relabel(struct _nfa_node* start,int level)
{
 if (level){
  {if ( (used_classes).setword != ((void *)0) ) free((char *)((used_classes).setword)); (used_classes) = empty;};
  partition(start,level);
  label_with_classes(start);
 }else{
  class_no = (1+(255) - ((-1)));
 }
 return class_no;
}

canonical_original_code:
int relabel(struct _nfa_node *start, int level)
{
 if (level){
  {if ( (used_classes).setword != ((void *)0) ) free((char *)((used_classes).setword)); (used_classes) = empty;};
  partition(start,level);
  label_with_classes(start);
 }else{
  class_no = (1+(255) - ((-1)));
 }
 return class_no;
}


decompiled_code:
void p_comp0()
{
comp_level = 0;
}

canonical_decompiled_code:
void func0()
{
comp_level = 0;
}

original_code: void p_comp0(void) {comp_level = 0;}

canonical_original_code: void p_comp0() {comp_level = 0;}


decompiled_code:
void p_comp1()
{
comp_level = 1;
}

canonical_decompiled_code:
void func1()
{
comp_level = 1;
}

original_code: void p_comp1(void) {comp_level = 1;}

canonical_original_code: void p_comp1() {comp_level = 1;}


decompiled_code:
void p_comp2()
{
comp_level = 2;
}

canonical_decompiled_code:
void func2()
{
comp_level = 2;
}

original_code: void p_comp2(void) {comp_level = 2;}

canonical_original_code: void p_comp2() {comp_level = 2;}


decompiled_code:
__int64 p_stdio()
{
__int64 result; // rax

result = numfiles;
file_str[numfiles] = 0LL;
numfiles = result + 1;
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 result; // rax

result = numfiles;
file_str[numfiles] = 0LL;
numfiles = result + 1;
return result;
}

original_code: void p_stdio(void) { file_str[numfiles++] = ((void *)0);}

canonical_original_code: void p_stdio() { file_str[numfiles++] = ((void *)0);}


decompiled_code:
__int64 __fastcall p_file(__int64 a1)
{
__int64 result; // rax
int v2; // edx

result = numfiles;
v2 = numfiles + 1;
file_str[numfiles] = a1;
numfiles = v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
__int64 result; // rax
int v2; // edx

result = numfiles;
v2 = numfiles + 1;
file_str[numfiles] = a1;
numfiles = v2;
return result;
}

original_code: void p_file(char *s) { file_str[numfiles++] = s;}

variable_types:
s
char *


decompiled_code:
void __fastcall p_mode_file(__int64 a1, char *a2)
{
mode_file = a2;
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1, char *a2)
{
mode_file = a2;
}

original_code: void p_mode_file(char *s, char *t){mode_file=t;}

variable_types:
t
char *


decompiled_code:
void __fastcall p_outdir(__int64 a1, char *a2)
{
OutputDirectory[0] = a2;
}

canonical_decompiled_code:
void __fastcall func6(__int64 a1, char *a2)
{
OutputDirectory[0] = a2;
}

original_code: void p_outdir(char *s,char *t) {OutputDirectory=t;}

canonical_original_code: void p_outdir(char *s, char *t) {OutputDirectory=t;}


decompiled_code:
void p_ansi()
{
gen_ansi = 1;
}

canonical_decompiled_code:
void func7()
{
gen_ansi = 1;
}

original_code: void p_ansi(void) {gen_ansi = 1;}

canonical_original_code: void p_ansi() {gen_ansi = 1;}


decompiled_code:
void p_interactive()
{
interactive = 1;
}

canonical_decompiled_code:
void func8()
{
interactive = 1;
}

original_code: void p_interactive(void) {interactive = 1;}

canonical_original_code: void p_interactive() {interactive = 1;}


decompiled_code:
void p_case_s()
{
case_insensitive = 0;
}

canonical_decompiled_code:
void func9()
{
case_insensitive = 0;
}

original_code: void p_case_s(void) { case_insensitive = 0; }


decompiled_code:
void p_case_i()
{
case_insensitive = 1;
}

canonical_decompiled_code:
void func10()
{
case_insensitive = 1;
}

original_code: void p_case_i(void) { case_insensitive = 1; }


decompiled_code:
void p_warn_ambig()
{
warn_ambig = 1;
}

canonical_decompiled_code:
void func11()
{
warn_ambig = 1;
}

original_code: void p_warn_ambig(void) { warn_ambig = 1; }

canonical_original_code: void p_warn_ambig() { warn_ambig = 1; }


decompiled_code:
void p_cpp()
{
gen_cpp = 1;
}

canonical_decompiled_code:
void func12()
{
gen_cpp = 1;
}

original_code: void p_cpp(void) { gen_cpp = 1; }

canonical_original_code: void p_cpp() { gen_cpp = 1; }


decompiled_code:
__int64 __fastcall p_cl_name(__int64 a1, char *a2)
{
__int64 result; // rax

result = (unsigned int)gen_cpp;
if ( !gen_cpp )
return warning("-cl only valid in C++ mode; -cl ignored...", 0LL);
class_name[0] = a2;
return result;
}

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

result = (unsigned int)gen_cpp;
if ( !gen_cpp )
return warning("-cl only valid in C++ mode; -cl ignored...", 0LL);
class_name[0] = a2;
return result;
}

original_code:
void p_cl_name(char *s, char *t)
 {
  if ( gen_cpp ) {
   class_name = t;
  }
  else {
   warning("-cl only valid in C++ mode; -cl ignored...",0);
  }
 }


decompiled_code:
__int64 new_automaton_mode()
{
void *v0; // rdi

v0 = (void *)*((_QWORD *)&used_chars + 1);
if ( v0 )
free(v0);
used_chars = _mm_loadu_si128(&empty);
return clear_hash();
}

canonical_decompiled_code:
__int64 func17()
{
void *v0; // rdi

v0 = (void *)*((_QWORD *)&used_chars + 1);
if ( v0 )
free(v0);
used_chars = _mm_loadu_si128(&empty);
return clear_hash();
}

original_code:
void
new_automaton_mode(void)
{
 {if ( (used_chars).setword != ((void *)0) ) free((char *)((used_chars).setword)); (used_chars) = empty;};
 clear_hash();
}

canonical_original_code:
void new_automaton_mode()
{
 {if ( (used_chars).setword != ((void *)0) ) free((char *)((used_chars).setword)); (used_chars) = empty;};
 clear_hash();
}


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rax
FILE *v4; // rax
bool v5; // zf
__int64 v6; // rax
int v7; // ebx
int v8; // edx
int v9; // eax
void *v10; // rdi
char **v11; // rbx
char *v12; // rdx
char *v13; // r8
const char *v14; // rcx

init(argc, argv, envp);
fprintf(stderr, "%s Version %s 1989-1999\n", program, version);
if ( argc == 1 )
{
v11 = &options;
fprintf(stderr, "%s [options] f1 f2 ... fn\n", *argv);
v12 = options;
if ( *options != 42 )
{
do
{
v13 = v11[3];
v14 = " ";
if ( *((_DWORD *)v11 + 2) )
v14 = "___";
v11 += 4;
fprintf(stderr, "\t%s %s\t%s\n", v12, v14, v13);
v12 = *v11;
}
while ( **v11 != 42 );
}
}
else
{
ProcessArgs(argc - 1, (__int64)(argv + 1), &options);
if ( interactive && gen_cpp )
{
fputc(10, stderr);
fwrite("Interactive lexer option (\"-i\") has no effect when in C++ mode\n", 1uLL, 0x3FuLL, stderr);
fwrite("because of extra buffering provided by ANTLRTokenBuffer class.\n", 1uLL, 0x3FuLL, stderr);
fputc(10, stderr);
}
input_stream = read_stream(file_str[0]);
if ( input_stream )
{
if ( gen_cpp )
{
v3 = ClassName(".cpp");
v4 = (FILE *)write_stream(v3);
v5 = file_str[1] == 0;
output_stream = v4;
if ( !v5 )
warning("output file implicit in C++ mode; ignored...", 0LL);
v6 = ClassName(".h");
class_stream = (FILE *)write_stream(v6);
mode_stream = class_stream;
}
else
{
output_stream = (FILE *)write_stream(file_str[1]);
mode_stream = (FILE *)write_stream(mode_file);
}
if ( input_stream )
{
if ( output_stream )
{
if ( mode_stream )
{
zzbufsize = 2000;
zzlextext = &zztoktext_0;
zzrdstream();
zzgettok();
v7 = zzasp;
grammar();
v8 = zzasp;
v9 = zzasp;
if ( v7 > zzasp )
{
do
{
v10 = (void *)zzaStack[5 * v9 + 4];
if ( v10 )
{
free(v10);
v8 = zzasp;
}
*(__m128i *)&zzaStack[5 * v8 + 3] = _mm_loadu_si128(&empty);
v9 = v8 + 1;
zzasp = v9;
++v8;
}
while ( v7 > v9 );
}
}
}
}
}
p_class_def2();
}
if ( output_stream )
fclose(output_stream);
if ( !gen_cpp && mode_stream )
fclose(mode_stream);
if ( class_stream )
fclose(class_stream);
exit(0);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rax
FILE *v4; // rax
bool v5; // zf
__int64 v6; // rax
int v7; // ebx
int v8; // edx
int v9; // eax
void *v10; // rdi
char **v11; // rbx
char *v12; // rdx
char *v13; // r8
const char *v14; // rcx

func16(argc, argv, envp);
fprintf(stderr, "%s Version %s 1989-1999\n", program, version);
if ( argc == 1 )
{
v11 = &options;
fprintf(stderr, "%s [options] f1 f2 ... fn\n", *argv);
v12 = options;
if ( *options != 42 )
{
do
{
v13 = v11[3];
v14 = " ";
if ( *((_DWORD *)v11 + 2) )
v14 = "___";
v11 += 4;
fprintf(stderr, "\t%s %s\t%s\n", v12, v14, v13);
v12 = *v11;
}
while ( **v11 != 42 );
}
}
else
{
func15(argc - 1, (__int64)(argv + 1), &options);
if ( interactive && gen_cpp )
{
fputc(10, stderr);
fwrite("Interactive lexer option (\"-i\") has no effect when in C++ mode\n", 1uLL, 0x3FuLL, stderr);
fwrite("because of extra buffering provided by ANTLRTokenBuffer class.\n", 1uLL, 0x3FuLL, stderr);
fputc(10, stderr);
}
input_stream = read_stream(file_str[0]);
if ( input_stream )
{
if ( gen_cpp )
{
v3 = ClassName(".cpp");
v4 = (FILE *)write_stream(v3);
v5 = file_str[1] == 0;
output_stream = v4;
if ( !v5 )
warning("output file implicit in C++ mode; ignored...", 0LL);
v6 = ClassName(".h");
class_stream = (FILE *)write_stream(v6);
mode_stream = class_stream;
}
else
{
output_stream = (FILE *)write_stream(file_str[1]);
mode_stream = (FILE *)write_stream(mode_file);
}
if ( input_stream )
{
if ( output_stream )
{
if ( mode_stream )
{
zzbufsize = 2000;
zzlextext = &zztoktext_0;
zzrdstream();
zzgettok();
v7 = zzasp;
grammar();
v8 = zzasp;
v9 = zzasp;
if ( v7 > zzasp )
{
do
{
v10 = (void *)zzaStack[5 * v9 + 4];
if ( v10 )
{
free(v10);
v8 = zzasp;
}
*(__m128i *)&zzaStack[5 * v8 + 3] = _mm_loadu_si128(&empty);
v9 = v8 + 1;
zzasp = v9;
++v8;
}
while ( v7 > v9 );
}
}
}
}
}
p_class_def2();
}
if ( output_stream )
fclose(output_stream);
if ( !gen_cpp && mode_stream )
fclose(mode_stream);
if ( class_stream )
fclose(class_stream);
exit(0);
}

original_code:
int main(int argc, char *argv[])
{
 init();
 fprintf(stderr, "%s  Version %s   1989-1999\n", &(program[0]),
  &(version[0]));
 if ( argc == 1 )
 {
  Opt *p = options;
  fprintf(stderr, "%s [options] f1 f2 ... fn\n",argv[0]);
  while ( *(p->option) != '*' )
  {
   fprintf(stderr, "\t%s %s\t%s\n",
       p->option,
       (p->arg)?"___":"   ",
       p->descr);
   p++;
  }
 }else{
  ProcessArgs(argc-1, &(argv[1]), options);
  if (interactive && gen_cpp) {
   fprintf(stderr,"\n");
   fprintf(stderr,"Interactive lexer option (\"-i\") has no effect when in C++ mode\n");
   fprintf(stderr,"because of extra buffering provided by ANTLRTokenBuffer class.\n");
   fprintf(stderr,"\n");
  }
  input_stream = read_stream(file_str[0]);
  if (input_stream) {
   if ( gen_cpp ) {
    output_stream = write_stream(ClassName(".cpp"));
    if ( file_str[1]!=((void *)0) ) {
     warning("output file implicit in C++ mode; ignored...",0);
    }
    class_stream = write_stream(ClassName(".h"));
    mode_stream = class_stream;
   }
   else {
    output_stream = write_stream(file_str[1]);
    mode_stream = write_stream(mode_file);
   }
  }
  if (input_stream && output_stream && mode_stream){
   zzbufsize = 2000; {static char zztoktext[2000]; zzlextext = zztoktext; zzrdstream( input_stream ); zzgettok();}; { int zztasp1 = zzasp - 1; grammar(); for (; zzasp<(zztasp1 + 1); zzasp++) { {if ( ((&(zzaStack[zzasp]))->label).setword != ((void *)0) ) free((char *)(((&(zzaStack[zzasp]))->label).setword)); ((&(zzaStack[zzasp]))->label) = empty;};; }; } ;;
  }
  p_class_def2();
 }
 if ( output_stream!=((void *)0) ) fclose(output_stream);
 if ( !gen_cpp && mode_stream!=((void *)0) ) fclose(mode_stream);
 if ( class_stream!=((void *)0) ) fclose(class_stream);
 exit(0);
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 init();
 fprintf(stderr, "%s  Version %s   1989-1999\n", &(program[0]),
  &(version[0]));
 if ( argc == 1 )
 {
  struct Opt *p = options;
  fprintf(stderr, "%s [options] f1 f2 ... fn\n",argv[0]);
  while ( *(p->option) != '*' )
  {
   fprintf(stderr, "\t%s %s\t%s\n",
       p->option,
       (p->arg)?"___":"   ",
       p->descr);
   p++;
  }
 }else{
  ProcessArgs(argc-1, &(argv[1]), options);
  if (interactive && gen_cpp) {
   fprintf(stderr,"\n");
   fprintf(stderr,"Interactive lexer option (\"-i\") has no effect when in C++ mode\n");
   fprintf(stderr,"because of extra buffering provided by ANTLRTokenBuffer class.\n");
   fprintf(stderr,"\n");
  }
  input_stream = read_stream(file_str[0]);
  if (input_stream) {
   if ( gen_cpp ) {
    output_stream = write_stream(ClassName(".cpp"));
    if ( file_str[1]!=((void *)0) ) {
     warning("output file implicit in C++ mode; ignored...",0);
    }
    class_stream = write_stream(ClassName(".h"));
    mode_stream = class_stream;
   }
   else {
    output_stream = write_stream(file_str[1]);
    mode_stream = write_stream(mode_file);
   }
  }
  if (input_stream && output_stream && mode_stream){
   zzbufsize = 2000; {static char zztoktext[2000]; zzlextext = zztoktext; zzrdstream( input_stream ); zzgettok();}; { int zztasp1 = zzasp - 1; grammar(); for (; zzasp<(zztasp1 + 1); zzasp++) { {if ( ((&(zzaStack[zzasp]))->label).setword != ((void *)0) ) free((char *)(((&(zzaStack[zzasp]))->label).setword)); ((&(zzaStack[zzasp]))->label) = empty;};; }; } ;;
  }
  p_class_def2();
 }
 if ( output_stream!=((void *)0) ) fclose(output_stream);
 if ( !gen_cpp && mode_stream!=((void *)0) ) fclose(mode_stream);
 if ( class_stream!=((void *)0) ) fclose(class_stream);
 exit(0);
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct Opt { char *option; int arg; void (*process)(); char *descr; } *

variable_types:
zztoktext
char [2000]


decompiled_code:
_BOOL8 __fastcall ci_strequ(char *a1, char *a2)
{
char *v2; // r13
char *v3; // r12
__int64 v4; // rbp
__int64 v5; // rbx
const __int32_t **v6; // rax

v2 = a1;
v3 = a2;
v4 = *a1;
LOBYTE(v5) = *a2;
if ( (_BYTE)v4 )
{
while ( 1 )
{
v5 = *v3;
if ( !(_BYTE)v5 )
break;
v6 = _ctype_toupper_loc();
if ( (*v6)[v5] != (*v6)[v4] )
return 0LL;
v4 = *++v2;
if ( !(_BYTE)v4 )
{
LOBYTE(v5) = v3[1];
return (_BYTE)v4 == (unsigned __int8)v5;
}
++v3;
}
}
return (_BYTE)v4 == (unsigned __int8)v5;
}

canonical_decompiled_code:
_BOOL8 __fastcall func14(char *a1, char *a2)
{
char *v2; // r13
char *v3; // r12
__int64 v4; // rbp
__int64 v5; // rbx
const __int32_t **v6; // rax

v2 = a1;
v3 = a2;
v4 = *a1;
LOBYTE(v5) = *a2;
if ( (_BYTE)v4 )
{
while ( 1 )
{
v5 = *v3;
if ( !(_BYTE)v5 )
break;
v6 = _ctype_toupper_loc();
if ( (*v6)[v5] != (*v6)[v4] )
return 0LL;
v4 = *++v2;
if ( !(_BYTE)v4 )
{
LOBYTE(v5) = v3[1];
return (_BYTE)v4 == (unsigned __int8)v5;
}
++v3;
}
}
return (_BYTE)v4 == (unsigned __int8)v5;
}

original_code:
static int ci_strequ(char *a,char *b)
{
  for ( ;*a != 0 && *b != 0; a++, b++) {
    if (toupper(*a) != toupper(*b)) return 0;
  }
  return (*a == *b);
}

canonical_original_code:
static int ci_strequ(char *a, char *b)
{
  for ( ;*a != 0 && *b != 0; a++, b++) {
    if (toupper(*a) != toupper(*b)) return 0;
  }
  return (*a == *b);
}

variable_types:
a
char *

variable_types:
b
char *


ProcessArgs

original_code:
void ProcessArgs(int argc, char **argv, Opt *options)
{
 Opt *p;
 while ( argc-- > 0 )
 {
  p = options;
  while ( p->option != ((void *)0) )
  {
   if ( strcmp(p->option, "*") == 0 ||
     ci_strequ(p->option,*argv) )
   {
    if ( p->arg )
    {
     (*p->process)( *argv, *(argv+1) );
     argv++;
     argc--;
    }
    else
     (*p->process)( *argv );
    break;
   }
   p++;
  }
  argv++;
 }
}

canonical_original_code:
void ProcessArgs(int argc, char **argv, struct Opt *options)
{
 struct Opt *p;
 while ( argc-- > 0 )
 {
  p = options;
  while ( p->option != ((void *)0) )
  {
   if ( strcmp(p->option, "*") == 0 ||
     ci_strequ(p->option,*argv) )
   {
    if ( p->arg )
    {
     (*p->process)( *argv, *(argv+1) );
     argv++;
     argc--;
    }
    else
     (*p->process)( *argv );
    break;
   }
   p++;
  }
  argv++;
 }
}

variable_types:
argv
char **

user_defined_types: struct Opt { char *option; int arg; void (*process)(); char *descr; }


init

decompiled_code:
__int64 init()
{
__m128i v0; // xmm0
unsigned int v1; // ebx
__int64 v2; // rdi
__int64 result; // rax

v0 = _mm_loadu_si128(&empty);
v1 = 1;
used_chars = v0;
*(__m128i *)&used_classes = v0;
normal_chars = v0;
do
{
v2 = v1++;
set_orel(v2, &normal_chars);
}
while ( v1 != 257 );
make_nfa_model_node();
result = clear_hash();
func_action = 0;
return result;
}

canonical_decompiled_code:
__int64 func16()
{
__m128i v0; // xmm0
unsigned int v1; // ebx
__int64 v2; // rdi
__int64 result; // rax

v0 = _mm_loadu_si128(&empty);
v1 = 1;
used_chars = v0;
*(__m128i *)&used_classes = v0;
normal_chars = v0;
do
{
v2 = v1++;
set_orel(v2, &normal_chars);
}
while ( v1 != 257 );
make_nfa_model_node();
result = clear_hash();
func_action = 0;
return result;
}

original_code:
void
init(void)
{
 register int i;
 used_chars = empty;
 used_classes = empty;
 normal_chars = empty;
 for (i = 1; i<(1+(255) - ((-1))); ++i){
  set_orel(i,&normal_chars);
 }
 make_nfa_model_node();
 clear_hash();
    func_action = 0;
}

canonical_original_code:
void init()
{
 register int i;
 used_chars = empty;
 used_classes = empty;
 normal_chars = empty;
 for (i = 1; i<(1+(255) - ((-1))); ++i){
  set_orel(i,&normal_chars);
 }
 make_nfa_model_node();
 clear_hash();
    func_action = 0;
}


zzresynch

decompiled_code:
__int64 __fastcall zzresynch(__int64 a1, unsigned __int8 a2)
{
__int64 result; // rax

result = (unsigned int)consumed_2;
if ( consumed_2 )
{
if ( (a2 & *(_BYTE *)(a1 + zztoken)) != 0 || zztoken == 1 )
{
consumed_2 = 0;
}
else
{
do
result = zzgettok();
while ( (*(_BYTE *)(a1 + zztoken) & a2) == 0 && zztoken != 1 );
consumed_2 = 1;
}
}
else
{
result = zzgettok();
consumed_2 = 1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, unsigned __int8 a2)
{
__int64 result; // rax

result = (unsigned int)consumed_2;
if ( consumed_2 )
{
if ( (a2 & *(_BYTE *)(a1 + zztoken)) != 0 || zztoken == 1 )
{
consumed_2 = 0;
}
else
{
do
result = zzgettok();
while ( (*(_BYTE *)(a1 + zztoken) & a2) == 0 && zztoken != 1 );
consumed_2 = 1;
}
}
else
{
result = zzgettok();
consumed_2 = 1;
}
return result;
}

original_code:
void
zzresynch(SetWordType *wd,SetWordType mask)
{
 static int consumed = 1;
 if ( !consumed ) {zzgettok();; consumed=1; return;}
 if ( wd[zztoken]&mask || zztoken == 1 ) {consumed=0; return;}
 while ( !(wd[zztoken]&mask) && zztoken != 1 ) {zzgettok();;}
 consumed=1;
}

canonical_original_code:
void zzresynch(unsigned char *wd, unsigned char mask)
{
 static int consumed = 1;
 if ( !consumed ) {zzgettok();; consumed=1; return;}
 if ( wd[zztoken]&mask || zztoken == 1 ) {consumed=0; return;}
 while ( !(wd[zztoken]&mask) && zztoken != 1 ) {zzgettok();;}
 consumed=1;
}

variable_types:
wd
unsigned char *

variable_types:
mask
unsigned char

variable_types: consumed int


zzconsumeUntilToken

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

for ( result = zztoken; zztoken != 1 && zztoken != a1; result = zztoken )
zzgettok();
return result;
}

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

for ( result = zztoken; zztoken != 1 && zztoken != a1; result = zztoken )
zzgettok();
return result;
}

original_code:
void
zzconsumeUntilToken(int t)
{
    int tmp;
 while ( (tmp=zztoken) !=t && tmp!=1 ) { zzgettok();; }
}

variable_types: t int

variable_types: tmp int


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

v1 = zzlextext;
v2 = (char *)(a1 + 12);
*((_DWORD *)v2 - 3) = zzasp;
*((_DWORD *)v2 - 1) = zztoken;
return strcpy(v2, v1);
}

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

v1 = zzlextext;
v2 = (char *)(a1 + 12);
*((_DWORD *)v2 - 3) = zzasp;
*((_DWORD *)v2 - 1) = zztoken;
return strcpy(v2, v1);
}

original_code:
void
zzsave_antlr_state(zzantlr_state *buf)
{
 buf->asp = zzasp;
 buf->token = zztoken;
 strcpy(buf->text, zzlextext);
}

canonical_original_code:
void zzsave_antlr_state(struct _zzantlr_state *buf)
{
 buf->asp = zzasp;
 buf->token = zztoken;
 strcpy(buf->text, zzlextext);
}

variable_types: struct _zzantlr_state { int asp; int ast_sp; int token; char text[2000]; } *


decompiled_code:
char *__fastcall zzrestore_antlr_state(__int64 a1)
{
zzasp = *(_DWORD *)a1;
zztoken = *(_DWORD *)(a1 + 8);
return strcpy(zzlextext, (const char *)(a1 + 12));
}

canonical_decompiled_code:
char *__fastcall func3(__int64 a1)
{
zzasp = *(_DWORD *)a1;
zztoken = *(_DWORD *)(a1 + 8);
return strcpy(zzlextext, (const char *)(a1 + 12));
}

original_code:
void
zzrestore_antlr_state(zzantlr_state *buf)
{
 zzasp = buf->asp;
 zztoken = buf->token;
 strcpy(zzlextext, buf->text);
}

canonical_original_code:
void zzrestore_antlr_state(struct _zzantlr_state *buf)
{
 zzasp = buf->asp;
 zztoken = buf->token;
 strcpy(zzlextext, buf->text);
}

user_defined_types: struct _zzantlr_state { int asp; int ast_sp; int token; char text[2000]; }


decompiled_code:
__int64 __fastcall zzset_el(unsigned int a1, __int64 a2)
{
return (unsigned __int8)(bitmask[a1 & 7] & *(_BYTE *)(a2 + (a1 >> 3)));
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1, __int64 a2)
{
return (unsigned __int8)(bitmask[a1 & 7] & *(_BYTE *)(a2 + (a1 >> 3)));
}

original_code:
int
zzset_el(unsigned b, SetWordType *p)
{
 return( p[((b) >> 3)] & bitmask[((b) & (8 -1))] );
}

canonical_original_code:
int zzset_el(unsigned int b, unsigned char *p)
{
 return( p[((b) >> 3)] & bitmask[((b) & (8 -1))] );
}

variable_types:
b
unsigned int

variable_types:
p
unsigned char *


zzconsumeUntil

decompiled_code:
__int64 __fastcall zzconsumeUntil(__int64 a1)
{
__int64 result; // rax
int v2; // edx

while ( 1 )
{
result = zzset_el(zztoken, a1);
if ( v2 == 1 || (_DWORD)result )
break;
zzgettok();
}
return result;
}

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

while ( 1 )
{
result = func4(zztoken, a1);
if ( v2 == 1 || (_DWORD)result )
break;
zzgettok();
}
return result;
}

original_code:
void
zzconsumeUntil(SetWordType *st)
{
    int tmp;
 while ( !zzset_el( (tmp=zztoken), st) && tmp!=1 ) {
                                                      zzgettok();; }
}

canonical_original_code:
void zzconsumeUntil(unsigned char *st)
{
    int tmp;
 while ( !zzset_el( (tmp=zztoken), st) && tmp!=1 ) {
                                                      zzgettok();; }
}

variable_types:
st
unsigned char *


zzTraceReset

decompiled_code:
void zzTraceReset()
{
;
}

canonical_decompiled_code:
void func15()
{
;
}

original_code:
void zzTraceReset(void)
{
}

canonical_original_code:
void zzTraceReset()
{
}


zzTraceGuessFail

decompiled_code:
void zzTraceGuessFail()
{
;
}

canonical_decompiled_code:
void func16()
{
;
}

original_code:
void zzTraceGuessFail(void)
{
}

canonical_original_code:
void zzTraceGuessFail()
{
}


zzTraceIn

decompiled_code:
void zzTraceIn()
{
;
}

canonical_decompiled_code:
void func17()
{
;
}

original_code:
void zzTraceIn(char * rule)
{
  return;
}

canonical_original_code:
void zzTraceIn(char *rule)
{
  return;
}

variable_types:
rule
char *


zzTraceGuessDone

decompiled_code:
void zzTraceGuessDone()
{
;
}

canonical_decompiled_code:
void func18()
{
;
}

original_code:
void zzTraceGuessDone(zzantlr_state *state)
{
}

canonical_original_code:
void zzTraceGuessDone(struct _zzantlr_state *state)
{
}


zzTraceOut

decompiled_code:
void zzTraceOut()
{
;
}

canonical_decompiled_code:
void func19()
{
;
}

original_code:
void zzTraceOut(char * rule)
{
}

canonical_original_code:
void zzTraceOut(char *rule)
{
}


zzTraceOption

decompiled_code:
__int64 zzTraceOption()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func20()
{
return 0LL;
}

original_code:
int zzTraceOption(int delta)
{
    return 0;
}

variable_types: delta int


zzTraceGuessOption

decompiled_code:
// attributes: thunk
__int64 zzTraceGuessOption()
{
return zzTraceOption();
}

canonical_decompiled_code:
__int64 func21()
{
return func20();
}

original_code:
int zzTraceGuessOption(int delta)
{
    return 0;
}


decompiled_code:
void __fastcall __noreturn internal_error(char *format, __int64 a2, unsigned int a3)
{
fprintf(stderr, format, a2, a3);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(char *format, __int64 a2, unsigned int a3)
{
fprintf(stderr, format, a2, a3);
exit(1);
}

original_code:
void internal_error(char *s, char *file,int line)
{
 fprintf(stderr,s,file,line);
 exit(1);
}

canonical_original_code:
void internal_error(char *s, char *file, int line)
{
 fprintf(stderr,s,file,line);
 exit(1);
}

variable_types:
s
char *

variable_types:
file
char *

variable_types: line int


decompiled_code:
void *__fastcall dlg_malloc(int a1, __int64 a2, unsigned int a3)
{
void *result; // rax

result = malloc(a1);
if ( !result )
internal_error("%s(%d): unable to allocate memory\n", a2, a3);
return result;
}

canonical_decompiled_code:
void *__fastcall func1(int a1, __int64 a2, unsigned int a3)
{
void *result; // rax

result = malloc(a1);
if ( !result )
func0("%s(%d): unable to allocate memory\n", a2, a3);
return result;
}

original_code:
char *dlg_malloc(int bytes,char *file,int line)
{
 char *t;
 t = (char *) malloc(bytes);
 if (!t){
  internal_error("%s(%d): unable to allocate memory\n",
   file,line);
 }
 return t;
}

canonical_original_code:
char *dlg_malloc(int bytes, char *file, int line)
{
 char *t;
 t = (char *) malloc(bytes);
 if (!t){
  internal_error("%s(%d): unable to allocate memory\n",
   file,line);
 }
 return t;
}

variable_types: bytes int

variable_types:
t
char *

return_type: char *


decompiled_code:
void *__fastcall dlg_calloc(int a1, int a2, __int64 a3, unsigned int a4)
{
void *result; // rax

result = calloc(a1, a2);
if ( !result )
internal_error("%s(%d): unable to allocate memory\n", a3, a4);
return result;
}

canonical_decompiled_code:
void *__fastcall func2(int a1, int a2, __int64 a3, unsigned int a4)
{
void *result; // rax

result = calloc(a1, a2);
if ( !result )
func0("%s(%d): unable to allocate memory\n", a3, a4);
return result;
}

original_code:
char *dlg_calloc(int n,int bytes,char *file,int line)
{
 char *t;
 t = (char *) calloc(n,bytes);
 if (!t){
  internal_error("%s(%d): unable to allocate memory\n",
   file,line);
 }
 return t;
}

canonical_original_code:
char *dlg_calloc(int n, int bytes, char *file, int line)
{
 char *t;
 t = (char *) calloc(n,bytes);
 if (!t){
  internal_error("%s(%d): unable to allocate memory\n",
   file,line);
 }
 return t;
}

variable_types: n int


fatal

decompiled_code:
void __fastcall __noreturn fatal(const char *a1, unsigned int a2)
{
const char *v2; // rdx

v2 = (const char *)file_str;
if ( !file_str )
v2 = "stdin";
fprintf(stderr, "%s, line %d:", v2, a2);
fprintf(stderr, " Fatal: %s\n", a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func4(const char *a1, unsigned int a2)
{
const char *v2; // rdx

v2 = (const char *)file_str;
if ( !file_str )
v2 = "stdin";
fprintf(stderr, "%s, line %d:", v2, a2);
fprintf(stderr, " Fatal: %s\n", a1);
exit(1);
}

original_code:
void fatal(char *message,int line_no)
{
 fprintf(stderr,"%s, line %d:",
  (file_str[0] ? file_str[0] : "stdin"), line_no);
 fprintf(stderr, " Fatal: %s\n", message);
 exit(1);
}

canonical_original_code:
void fatal(char *message, int line_no)
{
 fprintf(stderr,"%s, line %d:",
  (file_str[0] ? file_str[0] : "stdin"), line_no);
 fprintf(stderr, " Fatal: %s\n", message);
 exit(1);
}

variable_types:
message
char *


warning

decompiled_code:
int __fastcall warning(const char *a1, unsigned int a2)
{
const char *v2; // rdx

v2 = (const char *)file_str;
if ( !file_str )
v2 = "stdin";
fprintf(stderr, "%s, line %d:", v2, a2);
return fprintf(stderr, " Warning: %s\n", a1);
}

canonical_decompiled_code:
int __fastcall func6(const char *a1, unsigned int a2)
{
const char *v2; // rdx

v2 = (const char *)file_str;
if ( !file_str )
v2 = "stdin";
fprintf(stderr, "%s, line %d:", v2, a2);
return fprintf(stderr, " Warning: %s\n", a1);
}

original_code:
void warning(char *message,int line_no)
{
 fprintf(stderr,"%s, line %d:",
  (file_str[0] ? file_str[0] : "stdin"), line_no);
 fprintf(stderr, " Warning: %s\n", message);
}

canonical_original_code:
void warning(char *message, int line_no)
{
 fprintf(stderr,"%s, line %d:",
  (file_str[0] ? file_str[0] : "stdin"), line_no);
 fprintf(stderr, " Warning: %s\n", message);
}


error

decompiled_code:
int __fastcall error(const char *a1, unsigned int a2)
{
const char *v2; // rdx
int result; // eax

v2 = (const char *)file_str;
if ( !file_str )
v2 = "stdin";
fprintf(stderr, "%s, line %d:", v2, a2);
result = fprintf(stderr, " Error: %s\n", a1);
err_found = 1;
return result;
}

canonical_decompiled_code:
int __fastcall func5(const char *a1, unsigned int a2)
{
const char *v2; // rdx
int result; // eax

v2 = (const char *)file_str;
if ( !file_str )
v2 = "stdin";
fprintf(stderr, "%s, line %d:", v2, a2);
result = fprintf(stderr, " Error: %s\n", a1);
err_found = 1;
return result;
}

original_code:
void error(char *message,int line_no)
{
 fprintf(stderr,"%s, line %d:",
  (file_str[0] ? file_str[0] : "stdin"), line_no);
 fprintf(stderr, " Error: %s\n", message);
 err_found = 1;
}

canonical_original_code:
void error(char *message, int line_no)
{
 fprintf(stderr,"%s, line %d:",
  (file_str[0] ? file_str[0] : "stdin"), line_no);
 fprintf(stderr, " Error: %s\n", message);
 err_found = 1;
}


OutMetaName

decompiled_code:
char *__fastcall OutMetaName(char *s)
{
char *v1; // rbp
const char *v2; // r12
char *result; // rax
char *v4; // rax
char *v5; // rax

v1 = s;
v2 = OutputDirectory;
if ( *OutputDirectory != 46 || (result = s, OutputDirectory[1]) )
{
v4 = strrchr(s, 47);
if ( v4 )
v1 = v4 + 1;
v5 = stpcpy(newname_0, v2);
if ( *(v5 - 1) != 47 )
*(_WORD *)v5 = 47;
strcat(newname_0, v1);
result = newname_0;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func7(char *s)
{
char *v1; // rbp
const char *v2; // r12
char *result; // rax
char *v4; // rax
char *v5; // rax

v1 = s;
v2 = OutputDirectory;
if ( *OutputDirectory != 46 || (result = s, OutputDirectory[1]) )
{
v4 = strrchr(s, 47);
if ( v4 )
v1 = v4 + 1;
v5 = stpcpy(newname_0, v2);
if ( *(v5 - 1) != 47 )
*(_WORD *)v5 = 47;
strcat(newname_0, v1);
result = newname_0;
}
return result;
}

original_code:
char *OutMetaName(char *n)
{
    static char *dir_sym = "/";
    static char newname[300 +1];
    char *p;
    if (strcmp(OutputDirectory, ".") == 0)
  return n;
 if ((p = strrchr(n, *dir_sym)) != ((void *)0))
  p++;
 else
  p = n;
 strcpy(newname, OutputDirectory);
 if (newname[strlen(newname)-1] != *dir_sym)
  strcat(newname, dir_sym);
 strcat(newname, p);
 return newname;
}

canonical_original_code:
char *OutMetaName(char *n)
{
    static char *dir_sym = "/";
    static char newname[-1];
    char *p;
    if (strcmp(OutputDirectory, ".") == 0)
  return n;
 if ((p = strrchr(n, *dir_sym)) != ((void *)0))
  p++;
 else
  p = n;
 strcpy(newname, OutputDirectory);
 if (newname[strlen(newname)-1] != *dir_sym)
  strcat(newname, dir_sym);
 strcat(newname, p);
 return newname;
}

variable_types:
n
char *

variable_types:
newname
char [-1]

variable_types:
p
char *


newHashTable

decompiled_code:
void *newHashTable()
{
void *result; // rax
void *v1; // r12
void *v2; // rax
const char *v3; // rdx

result = calloc(0x229uLL, 8uLL);
if ( !result )
{
fprintf(stderr, "%s(%d):", "hash.c", 78LL);
v3 = "cannot allocate hash table";
goto LABEL_6;
}
v1 = result;
if ( strings )
return result;
v2 = calloc(0xF4240uLL, 1uLL);
strings = (__int64)v2;
if ( !v2 )
{
fprintf(stderr, "%s(%d):", "hash.c", 82LL);
v3 = "cannot allocate string table";
LABEL_6:
fprintf(stderr, " %s\n", v3);
exit(1);
}
strp = (__int64)v2;
return v1;
}

canonical_decompiled_code:
void *func0()
{
void *result; // rax
void *v1; // r12
void *v2; // rax
const char *v3; // rdx

result = calloc(0x229uLL, 8uLL);
if ( !result )
{
fprintf(stderr, "%s(%d):", "hash.c", 78LL);
v3 = "cannot allocate hash table";
goto LABEL_6;
}
v1 = result;
if ( strings )
return result;
v2 = calloc(0xF4240uLL, 1uLL);
strings = (__int64)v2;
if ( !v2 )
{
fprintf(stderr, "%s(%d):", "hash.c", 82LL);
v3 = "cannot allocate string table";
LABEL_6:
fprintf(stderr, " %s\n", v3);
exit(1);
}
strp = (__int64)v2;
return v1;
}

original_code:
Entry **
newHashTable( void )
{
 Entry **table;
 table = (Entry **) calloc(size, sizeof(Entry *));
 {if ( !(table != ((void *)0)) ) {fprintf(stderr, "%s(%d):", "hash.c", 78); fprintf(stderr, " %s\n", "cannot allocate hash table"); exit(1);};};
 if ( strings == ((void *)0) )
 {
  strings = (char *) calloc(strsize, sizeof(char));
  {if ( !(strings != ((void *)0)) ) {fprintf(stderr, "%s(%d):", "hash.c", 82); fprintf(stderr, " %s\n", "cannot allocate string table"); exit(1);};};
  strp = strings;
 }
 return table;
}

canonical_original_code:
struct _entry **newHashTable()
{
 struct _entry **table;
 table = (struct _entry **) calloc(size, sizeof(struct _entry *));
 {if ( !(table != ((void *)0)) ) {fprintf(stderr, "%s(%d):", "hash.c", 78); fprintf(stderr, " %s\n", "cannot allocate hash table"); exit(1);};};
 if ( strings == ((void *)0) )
 {
  strings = (char *) calloc(strsize, sizeof(char));
  {if ( !(strings != ((void *)0)) ) {fprintf(stderr, "%s(%d):", "hash.c", 82); fprintf(stderr, " %s\n", "cannot allocate string table"); exit(1);};};
  strp = strings;
 }
 return table;
}

variable_types: struct _entry { char *str; struct _entry *next; } **


killHashTable

decompiled_code:
// attributes: thunk
void killHashTable(void *ptr)
{
free(ptr);
}

canonical_decompiled_code:
void func1(void *ptr)
{
free(ptr);
}

original_code:
void
killHashTable( Entry **table )
{
 free( (char *) table );
}

canonical_original_code:
void killHashTable(struct _entry **table)
{
 free( (char *) table );
}

user_defined_types: struct _entry { char *str; struct _entry *next; }


decompiled_code:
__int64 __fastcall hash_add(_QWORD *a1, _BYTE *a2, __int64 a3)
{
int v4; // eax
unsigned int v5; // edx
__int64 result; // rax

if ( a3 == 0 || a1 == 0LL || !a2 )
{
fprintf(stderr, "%s(%d):", "hash.c", 113LL);
fprintf(stderr, " %s\n", "add: invalid addition");
exit(1);
}
v4 = (char)*a2;
v5 = 0;
if ( *a2 )
{
do
{
++a2;
v5 = v4 + 2 * v5;
v4 = (char)*a2;
}
while ( *a2 );
a1 += v5 % 0x229;
}
*(_QWORD *)(a3 + 8) = *a1;
result = a3;
*a1 = a3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1, _BYTE *a2, __int64 a3)
{
int v4; // eax
unsigned int v5; // edx
__int64 result; // rax

if ( a3 == 0 || a1 == 0LL || !a2 )
{
fprintf(stderr, "%s(%d):", "hash.c", 113LL);
fprintf(stderr, " %s\n", "add: invalid addition");
exit(1);
}
v4 = (char)*a2;
v5 = 0;
if ( *a2 )
{
do
{
++a2;
v5 = v4 + 2 * v5;
v4 = (char)*a2;
}
while ( *a2 );
a1 += v5 % 0x229;
}
*(_QWORD *)(a3 + 8) = *a1;
result = a3;
*a1 = a3;
return result;
}

original_code:
Entry *
hash_add( Entry **table, char *key, Entry *rec )
{
 unsigned h=0;
 char *p=key;
 {if ( !(table!=((void *)0) && key!=((void *)0) && rec!=((void *)0)) ) {fprintf(stderr, "%s(%d):", "hash.c", 113); fprintf(stderr, " %s\n", "add: invalid addition"); exit(1);};};
 {while ( *p != '\0' ) h = (h<<1) + *p++; h %= size;};
 rec->next = table[h];
 table[h] = rec;
 return rec;
}

canonical_original_code:
struct _entry *hash_add(struct _entry **table, char *key, struct _entry *rec)
{
 unsigned int h = 0;
 char *p = key;
 {if ( !(table!=((void *)0) && key!=((void *)0) && rec!=((void *)0)) ) {fprintf(stderr, "%s(%d):", "hash.c", 113); fprintf(stderr, " %s\n", "add: invalid addition"); exit(1);};};
 {while ( *p != '\0' ) h = (h<<1) + *p++; h %= size;};
 rec->next = table[h];
 table[h] = rec;
 return rec;
}

variable_types:
table
struct _entry **

variable_types:
key
char *

variable_types:
rec
struct _entry *

variable_types:
h
unsigned int

return_type: struct _entry { char *str; struct _entry *next; } *


decompiled_code:
// write access to const memory has been detected, the output may be wrong!
__int64 __fastcall hash_get(__int64 *a1, const char *a2)
{
int v2; // eax
const char *v3; // rdx
unsigned int v4; // ecx
__int64 i; // r12

if ( !a1 || !a2 )
*(&loc_21 + 1) = 3;
v2 = *a2;
if ( *a2 )
{
v3 = a2;
v4 = 0;
do
{
++v3;
v4 = v2 + 2 * v4;
v2 = *v3;
}
while ( *v3 );
a1 += v4 % 0x229;
}
for ( i = *a1; i; i = *(_QWORD *)(i + 8) )
{
if ( !strcmp(a2, *(const char **)i) )
break;
}
return i;
}

original_code:
Entry *
hash_get( Entry **table, char *key )
{
 unsigned h=0;
 char *p=key;
 Entry *q;
 if ( !(table!=((void *)0) && key!=((void *)0)) ) *((char *) 34) = 3;
 {while ( *p != '\0' ) h = (h<<1) + *p++; h %= size;};
 for (q = table[h]; q != ((void *)0); q = q->next)
 {
  if ( strcmp(key, q->str) == 0 ) return( q );
 }
 return( ((void *)0) );
}

canonical_original_code:
struct _entry *hash_get(struct _entry **table, char *key)
{
 unsigned int h = 0;
 char *p = key;
 struct _entry *q;
 if ( !(table!=((void *)0) && key!=((void *)0)) ) *((char *) 34) = 3;
 {while ( *p != '\0' ) h = (h<<1) + *p++; h %= size;};
 for (q = table[h]; q != ((void *)0); q = q->next)
 {
  if ( strcmp(key, q->str) == 0 ) return( q );
 }
 return( ((void *)0) );
}

variable_types: struct _entry { char *str; struct _entry *next; } *