main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
int v4; // er12
pthread_t *v5; // rax
pthread_t *v6; // rbp
pthread_t *v7; // rbx
__int64 v8; // r12

if ( argc == 2 )
{
v4 = atoi(argv[1]);
v5 = (pthread_t *)malloc(8LL * v4);
v6 = v5;
if ( v4 <= 0 )
{
result = 0;
}
else
{
v7 = v5;
v8 = (__int64)&v5[(unsigned int)(v4 - 1) + 1];
do
pthread_create(v6++, 0LL, thread, 0LL);
while ( v6 != (pthread_t *)v8 );
do
{
pthread_join(*v7, 0LL);
printf("tid: %ld finished\n", *v7++);
}
while ( v7 != (pthread_t *)v8 );
result = 0;
}
}
else
{
printf("Usage: %s thread_num\n", *argv);
result = 1;
}
return result;
}

original_code:
int main(int argc, char **argv) {
 int n = 0, i;
 pthread_t * tidp;
 if (argc != 2) {
  printf("Usage: %s thread_num\n", argv[0]);
  return 1;
 }
 n = atoi(argv[1]);
 tidp = malloc(n * sizeof(pthread_t));
 for (i=0; i<n; i++) {
  pthread_create(&tidp[i], ((void *)0), thread, ((void *)0));
 }
 for (i=0; i<n; i++) {
  pthread_join(tidp[i], ((void *)0));
  printf("tid: %ld finished\n", tidp[i]);
 }
 return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
 int n = 0; int i;
 unsigned long *tidp;
 if (argc != 2) {
  printf("Usage: %s thread_num\n", argv[0]);
  return 1;
 }
 n = atoi(argv[1]);
 tidp = malloc(n * sizeof(pthread_t));
 for (i=0; i<n; i++) {
  pthread_create(&tidp[i], ((void *)0), thread, ((void *)0));
 }
 for (i=0; i<n; i++) {
  pthread_join(tidp[i], ((void *)0));
  printf("tid: %ld finished\n", tidp[i]);
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: i int

variable_types:
tidp
unsigned long *


even

repo: leroux/libfc

decompiled_code:
__int64 __fastcall even(unsigned __int8 a1)
{
return (a1 ^ 1) & 1;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 a1)
{
return (a1 ^ 1) & 1;
}

original_code:
_Bool even(int a) {
  return a % 2 == 0;
}

variable_types: a int


odd

decompiled_code:
__int64 __fastcall odd(char a1)
{
return a1 & 1;
}

canonical_decompiled_code:
__int64 __fastcall func1(char a1)
{
return a1 & 1;
}

original_code:
_Bool odd(int a) {
  return a % 2 != 0;
}

canonical_original_code:
_Bool odd(int a) {
  return a % 2 != 0;
}


decompiled_code:
int __fastcall list_print(int *a1)
{
int v1; // eax
__int64 v2; // rbx

putchar(91);
v1 = *a1;
if ( *a1 > 2 )
{
v2 = 1LL;
do
{
printf("%d, ", (unsigned int)a1[v2]);
v1 = *a1;
++v2;
}
while ( *a1 - 1 > (int)v2 );
}
return printf("%d]\n", (unsigned int)a1[v1 - 1]);
}

canonical_decompiled_code:
int __fastcall func0(int *a1)
{
int v1; // eax
__int64 v2; // rbx

putchar(91);
v1 = *a1;
if ( *a1 > 2 )
{
v2 = 1LL;
do
{
printf("%d, ", (unsigned int)a1[v2]);
v1 = *a1;
++v2;
}
while ( *a1 - 1 > (int)v2 );
}
return printf("%d]\n", (unsigned int)a1[v1 - 1]);
}

original_code:
void list_print(int *xs) {
  printf("[");
  int i = 0;
  for (i = 1; i < (xs[0]) - 1; i++) {
    printf("%d, ", xs[i]);
  }
  printf("%d]\n", xs[(xs[0]) - 1]);
  return;
}

variable_types:
xs
int *

return_type: void


head

decompiled_code:
__int64 __fastcall head(__int64 a1)
{
return *(unsigned int *)(a1 + 4);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return *(unsigned int *)(a1 + 4);
}

original_code:
int head(int *xs) {
  return xs[1];
}

canonical_original_code:
int head(int *xs) {
  return xs[1];
}

return_type: int


sum

decompiled_code:
__int64 __fastcall sum(__int64 a1)
{
return foldl(&add, 0LL, a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return foldl(&add, 0LL, a1);
}

original_code:
int sum(int *xs) {
  return foldl(add, 0, xs);
}


product

decompiled_code:
__int64 __fastcall product(__int64 a1)
{
return foldl(&mul, 1LL, a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return foldl(&mul, 1LL, a1);
}

original_code:
int product(int *xs) {
  return foldl(mul, 1, xs);
}


foldl

decompiled_code:
__int64 __fastcall foldl(__int64 (__fastcall *a1)(__int64, _QWORD), unsigned int a2, int *a3)
{
__int64 v4; // rdi
__int64 v6; // rbx

v4 = a2;
if ( *a3 > 1 )
{
v6 = 1LL;
do
LODWORD(v4) = a1(v4, (unsigned int)a3[v6++]);
while ( *a3 > (int)v6 );
}
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 (__fastcall *a1)(__int64, _QWORD), unsigned int a2, int *a3)
{
__int64 v4; // rdi
__int64 v6; // rbx

v4 = a2;
if ( *a3 > 1 )
{
v6 = 1LL;
do
LODWORD(v4) = a1(v4, (unsigned int)a3[v6++]);
while ( *a3 > (int)v6 );
}
return (unsigned int)v4;
}

original_code:
int foldl(bfunc f, int accumulator, int *xs) {
  int i = 0;
  for (i = 1; i < (xs[0]); i++) {
    accumulator = f(accumulator, xs[i]);
  }
  return accumulator;
}

canonical_original_code:
int foldl(int (*f)(int a, int b), int accumulator, int *xs) {
  int i = 0;
  for (i = 1; i < (xs[0]); i++) {
    accumulator = f(accumulator, xs[i]);
  }
  return accumulator;
}

variable_types:
f
int (*)(int a, int b)

variable_types: accumulator int


add

decompiled_code:
__int64 __fastcall add(int a1, int a2)
{
return (unsigned int)(a1 + a2);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, int a2)
{
return (unsigned int)(a1 + a2);
}

original_code:
int add(int a, int b) {
  return a + b;
}

canonical_original_code:
int add(int a, int b) {
  return a + b;
}

variable_types: b int


sub

decompiled_code:
__int64 __fastcall sub(int a1, int a2)
{
return (unsigned int)(a1 - a2);
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, int a2)
{
return (unsigned int)(a1 - a2);
}

original_code:
int sub(int a, int b) {
  return a - b;
}

canonical_original_code:
int sub(int a, int b) {
  return a - b;
}


mul

decompiled_code:
__int64 __fastcall mul(int a1, int a2)
{
return (unsigned int)(a2 * a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, int a2)
{
return (unsigned int)(a2 * a1);
}

original_code:
int mul(int a, int b) {
  return a * b;
}

canonical_original_code:
int mul(int a, int b) {
  return a * b;
}


repo: lesbeben/projetSE

decompiled_code:
__int64 __fastcall create_request(char *s1)
{
char *v1; // rbx
__int64 result; // rax

if ( s1 )
{
v1 = dl_list;
if ( dl_list )
{
while ( strncmp(s1, v1, 3uLL) )
{
v1 = (char *)*((_QWORD *)v1 + 4);
if ( !v1 )
goto LABEL_5;
}
result = (*((__int64 (__fastcall **)(char *))v1 + 1))(s1);
}
else
{
LABEL_5:
fprintf(stderr, "Commande %.3s inconnue\n", s1);
result = 0LL;
}
}
else
{
fwrite("Impossible de traiter une commande NULL\n", 1uLL, 0x28uLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *s1)
{
char *v1; // rbx
__int64 result; // rax

if ( s1 )
{
v1 = dl_list;
if ( dl_list )
{
while ( strncmp(s1, v1, 3uLL) )
{
v1 = (char *)*((_QWORD *)v1 + 4);
if ( !v1 )
goto LABEL_5;
}
result = (*((__int64 (__fastcall **)(char *))v1 + 1))(s1);
}
else
{
LABEL_5:
fprintf(stderr, "Commande %.3s inconnue\n", s1);
result = 0LL;
}
}
else
{
fwrite("Impossible de traiter une commande NULL\n", 1uLL, 0x28uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
request_t* create_request(const char* cmd) {
 if (cmd != ((void *)0)) {
  dl_list_t elmnt = dl_list;
  while (elmnt != ((void *)0)) {
   if (strncmp(cmd, elmnt->cmd.cmd_name, 3) == 0) {
    return elmnt->cmd.request_cmd_func(cmd);
   }
   elmnt = elmnt->next;
  }
  fprintf(stderr, "Commande %.3s inconnue\n", cmd);
 } else {
  fprintf(stderr, "Impossible de traiter une commande NULL\n");
 }
 return ((void *)0);
}

canonical_original_code:
struct request_t *create_request(char *cmd) {
 if (cmd != ((void *)0)) {
  struct DL_LIST *elmnt = dl_list;
  while (elmnt != ((void *)0)) {
   if (strncmp(cmd, elmnt->cmd.cmd_name, 3) == 0) {
    return elmnt->cmd.request_cmd_func(cmd);
   }
   elmnt = elmnt->next;
  }
  fprintf(stderr, "Commande %.3s inconnue\n", cmd);
 } else {
  fprintf(stderr, "Impossible de traiter une commande NULL\n");
 }
 return ((void *)0);
}

variable_types:
cmd
char *

variable_types: struct DL_LIST { struct request_cmd_t { char cmd_name[4]; struct request_t { unsigned long size; int clientpid; char cmdname[4]; char data[1]; } *(*request_cmd_func)(char *); void (*help)(); } cmd; void *handler; struct DL_LIST *next; } *

user_defined_types: struct DL_LIST { struct request_cmd_t cmd; void *handler; struct DL_LIST *next; }

user_defined_types: struct request_cmd_t { char cmd_name[4]; struct request_t *(*request_cmd_func)(char *); void (*help)(); }


decompiled_code:
void __fastcall delete_request(void *a1)
{
if ( a1 )
free(a1);
else
fwrite("Impossible de supprimer une requete NULL\n", 1uLL, 0x29uLL, stderr);
}

canonical_decompiled_code:
void __fastcall func2(void *a1)
{
if ( a1 )
free(a1);
else
fwrite("Impossible de supprimer une requete NULL\n", 1uLL, 0x29uLL, stderr);
}

original_code:
void delete_request(request_t* req) {
 if (req != ((void *)0)) {
  free(req);
 } else {
  fprintf(stderr, "Impossible de supprimer une requete NULL\n");
 }
}

canonical_original_code:
void delete_request(struct request_t *req) {
 if (req != ((void *)0)) {
  free(req);
 } else {
  fprintf(stderr, "Impossible de supprimer une requete NULL\n");
 }
}

variable_types: struct request_t { unsigned long size; int clientpid; char cmdname[4]; char data[1]; } *


decompiled_code:
__int64 request_manager_helpAll()
{
char *i; // rbx
__int64 result; // rax

for ( i = dl_list; i; i = (char *)*((_QWORD *)i + 4) )
result = (*((__int64 (**)(void))i + 2))();
return result;
}

canonical_decompiled_code:
__int64 func3()
{
char *i; // rbx
__int64 result; // rax

for ( i = dl_list; i; i = (char *)*((_QWORD *)i + 4) )
result = (*((__int64 (**)(void))i + 2))();
return result;
}

original_code:
void request_manager_helpAll() {
 dl_list_t elmnt = dl_list;
 while (elmnt != ((void *)0)) {
  elmnt->cmd.help();
  elmnt = elmnt->next;
 }
}

canonical_original_code:
void request_manager_helpAll() {
 struct DL_LIST *elmnt = dl_list;
 while (elmnt != ((void *)0)) {
  elmnt->cmd.help();
  elmnt = elmnt->next;
 }
}

user_defined_types: struct request_t { unsigned long size; int clientpid; char cmdname[4]; char data[1]; }


decompiled_code:
int __fastcall request_manager_help(char *s1)
{
char *i; // rbx

for ( i = dl_list; i; i = (char *)*((_QWORD *)i + 4) )
{
if ( !strncmp(s1, i, 3uLL) )
(*((void (**)(void))i + 2))();
}
return fprintf(stderr, "Commande %s inconnue\n", s1);
}

canonical_decompiled_code:
int __fastcall func4(char *s1)
{
char *i; // rbx

for ( i = dl_list; i; i = (char *)*((_QWORD *)i + 4) )
{
if ( !strncmp(s1, i, 3uLL) )
(*((void (**)(void))i + 2))();
}
return fprintf(stderr, "Commande %s inconnue\n", s1);
}

original_code:
void request_manager_help(const char* cmd) {
 dl_list_t elmnt = dl_list;
 while (elmnt != ((void *)0)) {
  if (strncmp(cmd, elmnt->cmd.cmd_name, 3) == 0) {
   elmnt->cmd.help();
  }
  elmnt = elmnt->next;
 }
 fprintf(stderr, "Commande %s inconnue\n", cmd);
}

canonical_original_code:
void request_manager_help(char *cmd) {
 struct DL_LIST *elmnt = dl_list;
 while (elmnt != ((void *)0)) {
  if (strncmp(cmd, elmnt->cmd.cmd_name, 3) == 0) {
   elmnt->cmd.help();
  }
  elmnt = elmnt->next;
 }
 fprintf(stderr, "Commande %s inconnue\n", cmd);
}


decompiled_code:
void request_manager_close()
{
char *v0; // rbx
char *v1; // rbp
char *v2; // rax

v0 = dl_list;
if ( dl_list )
{
while ( 1 )
{
if ( dlclose(*((void **)v0 + 3)) == -1 )
{
v2 = dlerror();
fprintf(stderr, "dlclose : %s\n", v2);
raise(15);
}
v1 = (char *)*((_QWORD *)v0 + 4);
free(v0);
if ( !v1 )
break;
v0 = v1;
}
}
}

canonical_decompiled_code:
void func5()
{
char *v0; // rbx
char *v1; // rbp
char *v2; // rax

v0 = dl_list;
if ( dl_list )
{
while ( 1 )
{
if ( dlclose(*((void **)v0 + 3)) == -1 )
{
v2 = dlerror();
fprintf(stderr, "dlclose : %s\n", v2);
raise(15);
}
v1 = (char *)*((_QWORD *)v0 + 4);
free(v0);
if ( !v1 )
break;
v0 = v1;
}
}
}

original_code:
void request_manager_close() {
 dl_list_t elmnt = dl_list;
 while (elmnt != ((void *)0)) {
  if (dlclose(elmnt->handler) == -1) {
   fprintf(stderr, "dlclose : %s\n", dlerror());
   raise(15);
  }
  dl_list_t next = elmnt->next;
  free(elmnt);
  elmnt = next;
 }
}

canonical_original_code:
void request_manager_close() {
 struct DL_LIST *elmnt = dl_list;
 while (elmnt != ((void *)0)) {
  if (dlclose(elmnt->handler) == -1) {
   fprintf(stderr, "dlclose : %s\n", dlerror());
   raise(15);
  }
  struct DL_LIST *next = elmnt->next;
  free(elmnt);
  elmnt = next;
 }
}


send

decompiled_code:
__int64 __fastcall send(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rbx

result = create_request(a2);
if ( result )
{
v3 = result;
if ( (int)stream_write(a1, result, 0x2000LL) < 0 )
fwrite("Erreur d'envoie d'une requete\n", 1uLL, 0x1EuLL, stderr);
result = delete_request(v3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rbx

result = create_request(a2);
if ( result )
{
v3 = result;
if ( (int)stream_write(a1, result, 0x2000LL) < 0 )
fwrite("Erreur d'envoie d'une requete\n", 1uLL, 0x1EuLL, stderr);
result = delete_request(v3);
}
return result;
}

original_code:
void send(stream_t* stream, char* cmd, int size) {
 request_t* req = create_request(cmd);
 if (req != ((void *)0)) {
  if (stream_write(stream, req, 8192) < 0) {
   fprintf(stderr, "Erreur d'envoie d'une requete\n");
  }
  delete_request(req);
 }
}

canonical_original_code:
void send(struct stream_t *stream, char *cmd, int size) {
 struct request_t *req = create_request(cmd);
 if (req != ((void *)0)) {
  if (stream_write(stream, req, 8192) < 0) {
   fprintf(stderr, "Erreur d'envoie d'une requete\n");
  }
  delete_request(req);
 }
}

variable_types: struct stream_t { struct operation_t { int (*_create)(struct streamd_t { void *data; } *, char *, unsigned long); int (*_open)(struct streamd_t *, char *, int); int (*_close)(struct streamd_t *); int (*_read)(struct streamd_t *, void *, unsigned long); int (*_write)(struct streamd_t *, void *, unsigned long); int (*_getfd)(struct streamd_t *); int (*_unlink)(char *); char name[4]; } op; struct streamd_t sd; } *

variable_types: size int

user_defined_types: struct stream_t { struct operation_t op; struct streamd_t sd; }

user_defined_types: struct operation_t { int (*_create)(struct streamd_t *, char *, unsigned long); int (*_open)(struct streamd_t *, char *, int); int (*_close)(struct streamd_t *); int (*_read)(struct streamd_t *, void *, unsigned long); int (*_write)(struct streamd_t *, void *, unsigned long); int (*_getfd)(struct streamd_t *); int (*_unlink)(char *); char name[4]; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rax
unsigned int v4; // ebx
const char *v5; // rax
char *v6; // rax
__int64 v7; // rcx
char *v8; // rdi
__m128i *v9; // rsi
char *v10; // rax
__int64 v11; // rcx
__int128 *v12; // rdi
__m128i *v13; // rsi
__int64 v14; // rax
int *v15; // rbx
__int64 v16; // rax
__int64 v17; // r12
int v18; // er13
__m128i v20; // [rsp+0h] [rbp-4918h] BYREF
__m128i v21; // [rsp+10h] [rbp-4908h] BYREF
__m128i v22; // [rsp+20h] [rbp-48F8h] BYREF
__m128i v23; // [rsp+30h] [rbp-48E8h] BYREF
__int64 v24; // [rsp+40h] [rbp-48D8h]
__int128 v25[32]; // [rsp+50h] [rbp-48C8h] BYREF
char dest[512]; // [rsp+250h] [rbp-46C8h] BYREF
char v27[80]; // [rsp+450h] [rbp-44C8h] BYREF
__int128 v28[4]; // [rsp+4A0h] [rbp-4478h] BYREF
__int64 v29; // [rsp+4E0h] [rbp-4438h]
char v30[512]; // [rsp+4F0h] [rbp-4428h] BYREF
char src[8192]; // [rsp+6F0h] [rbp-4228h] BYREF
char v32[8192]; // [rsp+26F0h] [rbp-2228h] BYREF
char s[552]; // [rsp+46F0h] [rbp-228h] BYREF

setSignals(argc, argv, envp);
manager_init();
request_manager_init();
strcpy(v30, "FIF");
manager_getstream(&v20, v30);
v28[0] = (__int128)_mm_loadu_si128(&v20);
v28[1] = (__int128)_mm_loadu_si128(&v21);
v28[2] = (__int128)_mm_loadu_si128(&v22);
v28[3] = (__int128)_mm_loadu_si128(&v23);
v29 = v24;
v3 = ((__int64 (*)(void))getRequestName)();
if ( (int)stream_open(v28, v3, 1LL) < 0 )
raise(15);
v4 = getpid();
v5 = (const char *)getAnswerPrefix();
sprintf(s, "%s%i", v5, v4);
manager_getstream(v27, "FIF");
if ( (int)stream_create(v27, s, 0x1FFFLL) < 0 || (int)stream_open(v27, s, 0LL) < 0 )
raise(15);
if ( !(unsigned int)isDone() )
{
send((__int64)v28, (__int64)"CON");
v25[0] = 0xAuLL;
stream_set_clear(dest);
stream_set_add(dest, v27);
if ( (int)stream_set_select(dest, v25) > 0 && (int)stream_read(v27, v32, 0x1FFFLL) < 0 )
fwrite("Erreur de reception des donnees\n", 1uLL, 0x20uLL, stderr);
if ( v25[0] == 0 )
{
fwrite("Impossible de se connecter au serveur\n", 1uLL, 0x26uLL, stderr);
done();
}
}
while ( !(unsigned int)isDone() )
{
printf("Entrez une commande : ");
fflush(stdout);
fgets(src, 0x2000, stdin);
v15 = _errno_location();
if ( *v15 )
goto LABEL_30;
if ( !memcmp(src, "EXIT", 4uLL) )
{
strlen(src);
send((__int64)v28, (__int64)src);
done();
}
else if ( !memcmp(src, "SETIN", 5uLL) )
{
strncpy(dest, src, 0x200uLL);
strtok(dest, " ");
v6 = strtok(0LL, " ");
if ( !v6 )
goto LABEL_37;
strncpy(v30, v6, 3uLL);
v30[3] = 0;
stream_close(v27);
stream_unlink(v27, s);
manager_getstream(&v20, v30);
v7 = 18LL;
v8 = v27;
v9 = &v20;
while ( v7 )
{
*(_DWORD *)v8 = v9->m128i_i32[0];
v9 = (__m128i *)((char *)v9 + 4);
v8 += 4;
--v7;
}
stream_create(v27, s, 0x1FFFLL);
stream_open(v27, s, 0LL);
strlen(src);
send((__int64)v28, (__int64)src);
printf("Changement du mode de reponse en %s\n", v30);
}
else if ( !memcmp(src, "SETOUT", 6uLL) )
{
strncpy((char *)v25, src, 0x200uLL);
strtok((char *)v25, " ");
v10 = strtok(0LL, " ");
if ( !v10 )
goto LABEL_37;
strncpy(dest, v10, 3uLL);
dest[3] = 0;
stream_close(v28);
manager_getstream(&v20, dest);
v11 = 18LL;
v12 = v28;
v13 = &v20;
while ( v11 )
{
*(_DWORD *)v12 = v13->m128i_i32[0];
v13 = (__m128i *)((char *)v13 + 4);
v12 = (__int128 *)((char *)v12 + 4);
--v11;
}
v14 = getRequestName(v12, v13);
stream_open(v28, v14, 1LL);
printf("Changement du mode de requete en %s\n", dest);
}
else if ( !memcmp(src, "HELP", 4uLL) )
{
request_manager_helpAll();
}
else
{
LABEL_37:
v16 = create_request(src);
v17 = v16;
if ( v16 )
{
if ( (int)stream_write(v28, v16, 0x2000LL) < 0 )
raise(15);
v25[0] = 0xAuLL;
stream_set_clear(dest);
stream_set_add(dest, v27);
if ( (int)stream_set_select(dest, v25) > 0 )
{
v18 = stream_read(v27, v32, 0x1FFFLL);
if ( v18 < 0 )
fwrite("Erreur de reception des donnees\n", 1uLL, 0x20uLL, stderr);
v32[v18] = 0;
puts(v32);
}
if ( v25[0] == 0 )
fwrite("Timeout de reception de donnees\n", 1uLL, 0x20uLL, stderr);
delete_request(v17);
}
LABEL_30:
*v15 = 0;
}
}
if ( (int)stream_close(v28) < 0 )
fwrite("Impossible de fermer le flux de requetes\n", 1uLL, 0x29uLL, stderr);
if ( (int)stream_close(v27) < 0 )
fwrite("Impossible de fermer le flux de reponses\n", 1uLL, 0x29uLL, stderr);
manager_clean();
manager_close();
request_manager_close();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rax
unsigned int v4; // ebx
const char *v5; // rax
char *v6; // rax
__int64 v7; // rcx
char *v8; // rdi
__m128i *v9; // rsi
char *v10; // rax
__int64 v11; // rcx
__int128 *v12; // rdi
__m128i *v13; // rsi
__int64 v14; // rax
int *v15; // rbx
__int64 v16; // rax
__int64 v17; // r12
int v18; // er13
__m128i v20; // [rsp+0h] [rbp-4918h] BYREF
__m128i v21; // [rsp+10h] [rbp-4908h] BYREF
__m128i v22; // [rsp+20h] [rbp-48F8h] BYREF
__m128i v23; // [rsp+30h] [rbp-48E8h] BYREF
__int64 v24; // [rsp+40h] [rbp-48D8h]
__int128 v25[32]; // [rsp+50h] [rbp-48C8h] BYREF
char dest[512]; // [rsp+250h] [rbp-46C8h] BYREF
char v27[80]; // [rsp+450h] [rbp-44C8h] BYREF
__int128 v28[4]; // [rsp+4A0h] [rbp-4478h] BYREF
__int64 v29; // [rsp+4E0h] [rbp-4438h]
char v30[512]; // [rsp+4F0h] [rbp-4428h] BYREF
char src[8192]; // [rsp+6F0h] [rbp-4228h] BYREF
char v32[8192]; // [rsp+26F0h] [rbp-2228h] BYREF
char s[552]; // [rsp+46F0h] [rbp-228h] BYREF

setSignals(argc, argv, envp);
manager_init();
request_manager_init();
strcpy(v30, "FIF");
manager_getstream(&v20, v30);
v28[0] = (__int128)_mm_loadu_si128(&v20);
v28[1] = (__int128)_mm_loadu_si128(&v21);
v28[2] = (__int128)_mm_loadu_si128(&v22);
v28[3] = (__int128)_mm_loadu_si128(&v23);
v29 = v24;
v3 = ((__int64 (*)(void))getRequestName)();
if ( (int)stream_open(v28, v3, 1LL) < 0 )
raise(15);
v4 = getpid();
v5 = (const char *)getAnswerPrefix();
sprintf(s, "%s%i", v5, v4);
manager_getstream(v27, "FIF");
if ( (int)stream_create(v27, s, 0x1FFFLL) < 0 || (int)stream_open(v27, s, 0LL) < 0 )
raise(15);
if ( !(unsigned int)isDone() )
{
func0((__int64)v28, (__int64)"CON");
v25[0] = 0xAuLL;
stream_set_clear(dest);
stream_set_add(dest, v27);
if ( (int)stream_set_select(dest, v25) > 0 && (int)stream_read(v27, v32, 0x1FFFLL) < 0 )
fwrite("Erreur de reception des donnees\n", 1uLL, 0x20uLL, stderr);
if ( v25[0] == 0 )
{
fwrite("Impossible de se connecter au serveur\n", 1uLL, 0x26uLL, stderr);
done();
}
}
while ( !(unsigned int)isDone() )
{
printf("Entrez une commande : ");
fflush(stdout);
fgets(src, 0x2000, stdin);
v15 = _errno_location();
if ( *v15 )
goto LABEL_30;
if ( !memcmp(src, "EXIT", 4uLL) )
{
strlen(src);
func0((__int64)v28, (__int64)src);
done();
}
else if ( !memcmp(src, "SETIN", 5uLL) )
{
strncpy(dest, src, 0x200uLL);
strtok(dest, " ");
v6 = strtok(0LL, " ");
if ( !v6 )
goto LABEL_37;
strncpy(v30, v6, 3uLL);
v30[3] = 0;
stream_close(v27);
stream_unlink(v27, s);
manager_getstream(&v20, v30);
v7 = 18LL;
v8 = v27;
v9 = &v20;
while ( v7 )
{
*(_DWORD *)v8 = v9->m128i_i32[0];
v9 = (__m128i *)((char *)v9 + 4);
v8 += 4;
--v7;
}
stream_create(v27, s, 0x1FFFLL);
stream_open(v27, s, 0LL);
strlen(src);
func0((__int64)v28, (__int64)src);
printf("Changement du mode de reponse en %s\n", v30);
}
else if ( !memcmp(src, "SETOUT", 6uLL) )
{
strncpy((char *)v25, src, 0x200uLL);
strtok((char *)v25, " ");
v10 = strtok(0LL, " ");
if ( !v10 )
goto LABEL_37;
strncpy(dest, v10, 3uLL);
dest[3] = 0;
stream_close(v28);
manager_getstream(&v20, dest);
v11 = 18LL;
v12 = v28;
v13 = &v20;
while ( v11 )
{
*(_DWORD *)v12 = v13->m128i_i32[0];
v13 = (__m128i *)((char *)v13 + 4);
v12 = (__int128 *)((char *)v12 + 4);
--v11;
}
v14 = getRequestName(v12, v13);
stream_open(v28, v14, 1LL);
printf("Changement du mode de requete en %s\n", dest);
}
else if ( !memcmp(src, "HELP", 4uLL) )
{
request_manager_helpAll();
}
else
{
LABEL_37:
v16 = create_request(src);
v17 = v16;
if ( v16 )
{
if ( (int)stream_write(v28, v16, 0x2000LL) < 0 )
raise(15);
v25[0] = 0xAuLL;
stream_set_clear(dest);
stream_set_add(dest, v27);
if ( (int)stream_set_select(dest, v25) > 0 )
{
v18 = stream_read(v27, v32, 0x1FFFLL);
if ( v18 < 0 )
fwrite("Erreur de reception des donnees\n", 1uLL, 0x20uLL, stderr);
v32[v18] = 0;
puts(v32);
}
if ( v25[0] == 0 )
fwrite("Timeout de reception de donnees\n", 1uLL, 0x20uLL, stderr);
delete_request(v17);
}
LABEL_30:
*v15 = 0;
}
}
if ( (int)stream_close(v28) < 0 )
fwrite("Impossible de fermer le flux de requetes\n", 1uLL, 0x29uLL, stderr);
if ( (int)stream_close(v27) < 0 )
fwrite("Impossible de fermer le flux de reponses\n", 1uLL, 0x29uLL, stderr);
manager_clean();
manager_close();
request_manager_close();
return 0;
}

original_code:
int main(int argc, char **argv) {
 setSignals();
 manager_init();
 request_manager_init();
 request_t *req = ((void *)0);
 char ans_name[512];
 char ans_buf[8192];
 char cmd_buf[8192];
 char ans_stream_type[512];
 sprintf(ans_stream_type, "%s", "FIF");
 stream_t req_str;
 req_str = manager_getstream(ans_stream_type);
 if (stream_open(&req_str, getRequestName(), 01) < 0) {
  raise(15);
 }
    sprintf(ans_name, "%s%i", getAnswerPrefix(), getpid());
    stream_t ans_str = manager_getstream("FIF");
    if (stream_create(&ans_str, ans_name, 8192 -1) < 0) {
  raise(15);
 } else {
  if (stream_open(&ans_str, ans_name, 00) < 0) {
   raise(15);
  }
 }
 if (!isDone()) {
  send(&req_str, "CON", strlen("CON"));
  struct timeval timeout = {10, 0};
  stream_set_t sset;
  stream_set_clear(&sset);
  stream_set_add(&sset, &ans_str);
  if (stream_set_select(&sset, &timeout) > 0) {
   if (stream_read(&ans_str, &ans_buf, 8192 -1) < 0) {
    fprintf(stderr, "Erreur de reception des donnees\n");
   }
  }
  if ((timeout.tv_sec == 0) && (timeout.tv_usec == 0)) {
   fprintf(stderr, "Impossible de se connecter au serveur\n");
   done();
  }
 }
 while (!isDone()) {
     printf("Entrez une commande : ");
     fflush(stdout);
  fgets(cmd_buf, 8192, stdin);
  if ((*__errno_location ()) == 0) {
   if (strncmp(cmd_buf, "EXIT", 4) == 0) {
    send(&req_str, cmd_buf, strlen(cmd_buf));
    done();
    continue;
   } else if (strncmp(cmd_buf, "SETIN", 5) == 0) {
    char buf[512];
    strncpy(buf, cmd_buf, 512);
    strtok(buf, " ");
    char* res = strtok(((void *)0), " ");
    if (res != ((void *)0)) {
     strncpy(ans_stream_type, res, 3);
     ans_stream_type[3] = '\0';
     stream_close(&ans_str);
     stream_unlink(&ans_str, ans_name);
     ans_str = manager_getstream(ans_stream_type);
     stream_create(&ans_str, ans_name, 8192 -1);
     stream_open(&ans_str, ans_name, 00);
     send(&req_str, cmd_buf, strlen(cmd_buf));
     printf("Changement du mode de reponse en %s\n", ans_stream_type);
     continue;
    }
   } else if (strncmp(cmd_buf, "SETOUT", 6) == 0) {
    char buf[512];
    strncpy(buf, cmd_buf, 512);
    strtok(buf, " ");
    char* res = strtok(((void *)0), " ");
    if (res != ((void *)0)) {
     char name[512];
     strncpy(name, res, 3);
     name[3] = '\0';
     stream_close(&req_str);
     req_str = manager_getstream(name);
     stream_open(&req_str, getRequestName(), 01);
     printf("Changement du mode de requete en %s\n", name);
     continue;
    }
   } else if (strncmp(cmd_buf, "HELP", 4) == 0) {
    request_manager_helpAll();
    continue;
   }
   req = create_request(cmd_buf);
   if (req != ((void *)0)) {
    if (stream_write(&req_str, req, 8192) < 0) {
     raise(15);
    }
    int n = 0;
    struct timeval timeout = {10, 0};
    stream_set_t sset;
    stream_set_clear(&sset);
    stream_set_add(&sset, &ans_str);
    if (stream_set_select(&sset, &timeout) > 0) {
     if ((n = stream_read(&ans_str, &ans_buf, 8192 -1)) < 0) {
      fprintf(stderr, "Erreur de reception des donnees\n");
     }
     ans_buf[n] = '\0';
     printf("%s\n", ans_buf);
    }
    if ((timeout.tv_sec == 0) && (timeout.tv_usec == 0)) {
     fprintf(stderr, "Timeout de reception de donnees\n");
    }
    delete_request(req);
   }
  }
  (*__errno_location ()) = 0;
 }
 if (stream_close(&req_str) < 0) {
  fprintf(stderr, "Impossible de fermer le flux de requetes\n");
 }
 if (stream_close(&ans_str) < 0) {
  fprintf(stderr, "Impossible de fermer le flux de reponses\n");
 }
 manager_clean();
 manager_close();
 request_manager_close();
 return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
 setSignals();
 manager_init();
 request_manager_init();
 struct request_t *req = ((void *)0);
 char ans_name[512];
 char ans_buf[8192];
 char cmd_buf[8192];
 char ans_stream_type[512];
 sprintf(ans_stream_type, "%s", "FIF");
 struct stream_t req_str;
 req_str = manager_getstream(ans_stream_type);
 if (stream_open(&req_str, getRequestName(), 01) < 0) {
  raise(15);
 }
    sprintf(ans_name, "%s%i", getAnswerPrefix(), getpid());
    struct stream_t ans_str = manager_getstream("FIF");
    if (stream_create(&ans_str, ans_name, 8192 -1) < 0) {
  raise(15);
 } else {
  if (stream_open(&ans_str, ans_name, 00) < 0) {
   raise(15);
  }
 }
 if (!isDone()) {
  send(&req_str, "CON", strlen("CON"));
  struct timeval timeout = {10, 0};
  struct stream_set_t sset;
  stream_set_clear(&sset);
  stream_set_add(&sset, &ans_str);
  if (stream_set_select(&sset, &timeout) > 0) {
   if (stream_read(&ans_str, &ans_buf, 8192 -1) < 0) {
    fprintf(stderr, "Erreur de reception des donnees\n");
   }
  }
  if ((timeout.tv_sec == 0) && (timeout.tv_usec == 0)) {
   fprintf(stderr, "Impossible de se connecter au serveur\n");
   done();
  }
 }
 while (!isDone()) {
     printf("Entrez une commande : ");
     fflush(stdout);
  fgets(cmd_buf, 8192, stdin);
  if ((*__errno_location ()) == 0) {
   if (strncmp(cmd_buf, "EXIT", 4) == 0) {
    send(&req_str, cmd_buf, strlen(cmd_buf));
    done();
    continue;
   } else if (strncmp(cmd_buf, "SETIN", 5) == 0) {
    char buf[512];
    strncpy(buf, cmd_buf, 512);
    strtok(buf, " ");
    char *res = strtok(((void *)0), " ");
    if (res != ((void *)0)) {
     strncpy(ans_stream_type, res, 3);
     ans_stream_type[3] = '\0';
     stream_close(&ans_str);
     stream_unlink(&ans_str, ans_name);
     ans_str = manager_getstream(ans_stream_type);
     stream_create(&ans_str, ans_name, 8192 -1);
     stream_open(&ans_str, ans_name, 00);
     send(&req_str, cmd_buf, strlen(cmd_buf));
     printf("Changement du mode de reponse en %s\n", ans_stream_type);
     continue;
    }
   } else if (strncmp(cmd_buf, "SETOUT", 6) == 0) {
    char buf[512];
    strncpy(buf, cmd_buf, 512);
    strtok(buf, " ");
    char *res = strtok(((void *)0), " ");
    if (res != ((void *)0)) {
     char name[512];
     strncpy(name, res, 3);
     name[3] = '\0';
     stream_close(&req_str);
     req_str = manager_getstream(name);
     stream_open(&req_str, getRequestName(), 01);
     printf("Changement du mode de requete en %s\n", name);
     continue;
    }
   } else if (strncmp(cmd_buf, "HELP", 4) == 0) {
    request_manager_helpAll();
    continue;
   }
   req = create_request(cmd_buf);
   if (req != ((void *)0)) {
    if (stream_write(&req_str, req, 8192) < 0) {
     raise(15);
    }
    int n = 0;
    struct timeval timeout = {10, 0};
    struct stream_set_t sset;
    stream_set_clear(&sset);
    stream_set_add(&sset, &ans_str);
    if (stream_set_select(&sset, &timeout) > 0) {
     if ((n = stream_read(&ans_str, &ans_buf, 8192 -1)) < 0) {
      fprintf(stderr, "Erreur de reception des donnees\n");
     }
     ans_buf[n] = '\0';
     printf("%s\n", ans_buf);
    }
    if ((timeout.tv_sec == 0) && (timeout.tv_usec == 0)) {
     fprintf(stderr, "Timeout de reception de donnees\n");
    }
    delete_request(req);
   }
  }
  (*__errno_location ()) = 0;
 }
 if (stream_close(&req_str) < 0) {
  fprintf(stderr, "Impossible de fermer le flux de requetes\n");
 }
 if (stream_close(&ans_str) < 0) {
  fprintf(stderr, "Impossible de fermer le flux de reponses\n");
 }
 manager_clean();
 manager_close();
 request_manager_close();
 return 0;
}

variable_types: struct stream_t { struct operation_t { int (*_create)(struct streamd_t { void *data; } *, char *, unsigned long); int (*_open)(struct streamd_t *, char *, int); int (*_close)(struct streamd_t *); int (*_read)(struct streamd_t *, void *, unsigned long); int (*_write)(struct streamd_t *, void *, unsigned long); int (*_getfd)(struct streamd_t *); int (*_unlink)(char *); char name[4]; } op; struct streamd_t sd; }

variable_types: struct timeval { long tv_sec; long tv_usec; }

variable_types: struct stream_set_t { struct fd_set { long fds_bits[-1]; } _set; int _maxfd; }

variable_types:
buf
char [512]

variable_types:
res
char *

variable_types:
name
char [512]

variable_types: n int

user_defined_types: struct stream_set_t { struct fd_set _set; int _maxfd; }


decompiled_code:
void set_help()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code:
void set_help() {
}

canonical_original_code:
void set_help() {
}


decompiled_code:
char *__fastcall set_request_func(char *src)
{
char *v1; // rbx
char *v2; // rax
char v4[536]; // [rsp+0h] [rbp-218h] BYREF

v1 = (char *)malloc(0x1BuLL);
*(_QWORD *)v1 = 27LL;
strncpy(v1 + 12, src, 3uLL);
v1[15] = 0;
*((_DWORD *)v1 + 2) = getpid();
strncpy(v4, src, 0x200uLL);
strtok(v4, " ");
v2 = strtok(0LL, " ");
if ( v2 )
strncpy(v1 + 16, v2, 3uLL);
return v1;
}

canonical_decompiled_code:
char *__fastcall func7(char *src)
{
char *v1; // rbx
char *v2; // rax
char v4[536]; // [rsp+0h] [rbp-218h] BYREF

v1 = (char *)malloc(0x1BuLL);
*(_QWORD *)v1 = 27LL;
strncpy(v1 + 12, src, 3uLL);
v1[15] = 0;
*((_DWORD *)v1 + 2) = getpid();
strncpy(v4, src, 0x200uLL);
strtok(v4, " ");
v2 = strtok(0LL, " ");
if ( v2 )
strncpy(v1 + 16, v2, 3uLL);
return v1;
}

original_code:
request_t* set_request_func(const char* cmd) {
 request_t* req = malloc(sizeof(request_t) + 3 * sizeof(char));
 req->size = sizeof(request_t) + 3 * sizeof(char);
 strncpy(req->cmdname, cmd, 3);
 req->cmdname[3] = '\0';
 req->clientpid = getpid();
 char buf[512];
 strncpy(buf, cmd, 512);
 strtok(buf, " ");
 char* res = strtok(((void *)0), " ");
 if (res != ((void *)0)) {
  strncpy(((char*)req->data), res, 3);
 }
 return req;
}

canonical_original_code:
struct request_t *set_request_func(char *cmd) {
 struct request_t *req = malloc(sizeof(request_t) + 3 * sizeof(char));
 req->size = sizeof(request_t) + 3 * sizeof(char);
 strncpy(req->cmdname, cmd, 3);
 req->cmdname[3] = '\0';
 req->clientpid = getpid();
 char buf[512];
 strncpy(buf, cmd, 512);
 strtok(buf, " ");
 char *res = strtok(((void *)0), " ");
 if (res != ((void *)0)) {
  strncpy(((char *)req->data), res, 3);
 }
 return req;
}

return_type: struct request_t { unsigned long size; int clientpid; char cmdname[4]; char data[1]; } *


decompiled_code:
void *__fastcall manager_addstream(__int64 a1, const char *a2)
{
_QWORD *v2; // rbx
size_t v3; // rax
char *v4; // rax
void *result; // rax

v2 = malloc(0x20uLL);
v3 = strlen(a2);
v4 = (char *)malloc(v3 + 1);
v2[1] = v4;
strcpy(v4, a2);
*v2 = a1;
*((_DWORD *)v2 + 4) = getpid();
result = stream_list;
v2[3] = stream_list;
stream_list = v2;
return result;
}

canonical_decompiled_code:
void *__fastcall func1(__int64 a1, const char *a2)
{
_QWORD *v2; // rbx
size_t v3; // rax
char *v4; // rax
void *result; // rax

v2 = malloc(0x20uLL);
v3 = strlen(a2);
v4 = (char *)malloc(v3 + 1);
v2[1] = v4;
strcpy(v4, a2);
*v2 = a1;
*((_DWORD *)v2 + 4) = getpid();
result = stream_list;
v2[3] = stream_list;
stream_list = v2;
return result;
}

original_code:
void manager_addstream(stream_t* stream, const char* name) {
 stream_list_t element = malloc(sizeof(struct STREAM_LIST));
 element->stream_name = malloc(strlen(name) + 1);
 strcpy(element->stream_name, name);
 element->stream = stream;
 element->ownerpid = getpid();
 element->next = stream_list;
 stream_list = element;
}

canonical_original_code:
void manager_addstream(struct stream_t *stream, char *name) {
 struct STREAM_LIST *element = malloc(sizeof(struct STREAM_LIST));
 element->stream_name = malloc(strlen(name) + 1);
 strcpy(element->stream_name, name);
 element->stream = stream;
 element->ownerpid = getpid();
 element->next = stream_list;
 stream_list = element;
}

variable_types:
name
char *

variable_types: struct STREAM_LIST { struct stream_t { struct operation_t { int (*_create)(struct streamd_t { void *data; } *, char *, unsigned long); int (*_open)(struct streamd_t *, char *, int); int (*_close)(struct streamd_t *); int (*_read)(struct streamd_t *, void *, unsigned long); int (*_write)(struct streamd_t *, void *, unsigned long); int (*_getfd)(struct streamd_t *); int (*_unlink)(char *); char name[4]; } op; struct streamd_t sd; } *stream; char *stream_name; int ownerpid; struct STREAM_LIST *next; } *

user_defined_types: struct STREAM_LIST { struct stream_t *stream; char *stream_name; int ownerpid; struct STREAM_LIST *next; }


decompiled_code:
void __fastcall manager_removestream(__int64 a1)
{
_QWORD *v2; // rdi
_QWORD *v3; // rcx
__int64 v4; // rax

v2 = stream_list;
v3 = 0LL;
while ( v2 )
{
v4 = v2[3];
if ( *v2 == a1 )
{
if ( v4 )
{
if ( v3 )
v3[3] = v4;
else
stream_list = (void *)v2[3];
free(v2);
}
return;
}
v3 = v2;
v2 = (_QWORD *)v2[3];
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1)
{
_QWORD *v2; // rdi
_QWORD *v3; // rcx
__int64 v4; // rax

v2 = stream_list;
v3 = 0LL;
while ( v2 )
{
v4 = v2[3];
if ( *v2 == a1 )
{
if ( v4 )
{
if ( v3 )
v3[3] = v4;
else
stream_list = (void *)v2[3];
free(v2);
}
return;
}
v3 = v2;
v2 = (_QWORD *)v2[3];
}
}

original_code:
void manager_removestream(stream_t* stream) {
 stream_list_t prev = ((void *)0);
 stream_list_t element = ((void *)0);
 stream_list_t next = stream_list;
 while (next != ((void *)0)) {
  prev = element;
  element = next;
  next = element->next;
  if (element->stream == stream) {
   break;
  }
 }
 if (next != ((void *)0)) {
  if (prev == ((void *)0)) {
   stream_list = next;
  } else {
   prev->next = next;
  }
  free(element);
 }
}

canonical_original_code:
void manager_removestream(struct stream_t *stream) {
 struct STREAM_LIST *prev = ((void *)0);
 struct STREAM_LIST *element = ((void *)0);
 struct STREAM_LIST *next = stream_list;
 while (next != ((void *)0)) {
  prev = element;
  element = next;
  next = element->next;
  if (element->stream == stream) {
   break;
  }
 }
 if (next != ((void *)0)) {
  if (prev == ((void *)0)) {
   stream_list = next;
  } else {
   prev->next = next;
  }
  free(element);
 }
}


decompiled_code:
void manager_clean()
{
__int64 *v0; // rbx
__pid_t v1; // ebp
__int64 *v2; // rax

v0 = (__int64 *)stream_list;
v1 = getpid();
while ( v0 )
{
v2 = v0;
v0 = (__int64 *)v0[3];
if ( *((_DWORD *)v2 + 4) == v1 )
stream_unlink(*v2, v2[1]);
else
manager_removestream(*v2);
}
stream_list = 0LL;
}

canonical_decompiled_code:
void func3()
{
__int64 *v0; // rbx
__pid_t v1; // ebp
__int64 *v2; // rax

v0 = (__int64 *)stream_list;
v1 = getpid();
while ( v0 )
{
v2 = v0;
v0 = (__int64 *)v0[3];
if ( *((_DWORD *)v2 + 4) == v1 )
stream_unlink(*v2, v2[1]);
else
func2(*v2);
}
stream_list = 0LL;
}

original_code:
void manager_clean() {
 stream_list_t element = ((void *)0);
 stream_list_t next = stream_list;
 pid_t pid = getpid();
 while (next != ((void *)0)) {
  element = next;
  next = element->next;
  if (element->ownerpid == pid) {
   stream_unlink(element->stream, element->stream_name);
  } else {
   manager_removestream(element->stream);
  }
 }
 stream_list = ((void *)0);
}

canonical_original_code:
void manager_clean() {
 struct STREAM_LIST *element = ((void *)0);
 struct STREAM_LIST *next = stream_list;
 int pid = getpid();
 while (next != ((void *)0)) {
  element = next;
  next = element->next;
  if (element->ownerpid == pid) {
   stream_unlink(element->stream, element->stream_name);
  } else {
   manager_removestream(element->stream);
  }
 }
 stream_list = ((void *)0);
}

variable_types: pid int


decompiled_code:
void manager_close()
{
void **v0; // rbx
void **v1; // rbp
char *v2; // rax

v0 = (void **)dl_list;
if ( dl_list )
{
while ( 1 )
{
if ( dlclose(v0[8]) == -1 )
{
v2 = dlerror();
fprintf(stderr, "dlclose : %s\n", v2);
raise(15);
}
v1 = (void **)v0[9];
free(v0);
if ( !v1 )
break;
v0 = v1;
}
}
}

canonical_decompiled_code:
void func4()
{
void **v0; // rbx
void **v1; // rbp
char *v2; // rax

v0 = (void **)dl_list;
if ( dl_list )
{
while ( 1 )
{
if ( dlclose(v0[8]) == -1 )
{
v2 = dlerror();
fprintf(stderr, "dlclose : %s\n", v2);
raise(15);
}
v1 = (void **)v0[9];
free(v0);
if ( !v1 )
break;
v0 = v1;
}
}
}

original_code:
void manager_close() {
 dl_list_t elmnt = dl_list;
 while (elmnt != ((void *)0)) {
  if (dlclose(elmnt->handler) == -1) {
   fprintf(stderr, "dlclose : %s\n", dlerror());
   raise(15);
  }
  dl_list_t next = elmnt->next;
  free(elmnt);
  elmnt = next;
 }
}

canonical_original_code:
void manager_close() {
 struct DL_LIST *elmnt = dl_list;
 while (elmnt != ((void *)0)) {
  if (dlclose(elmnt->handler) == -1) {
   fprintf(stderr, "dlclose : %s\n", dlerror());
   raise(15);
  }
  struct DL_LIST *next = elmnt->next;
  free(elmnt);
  elmnt = next;
 }
}

variable_types: struct DL_LIST { struct operation_t { int (*_create)(struct streamd_t { void *data; } *, char *, unsigned long); int (*_open)(struct streamd_t *, char *, int); int (*_close)(struct streamd_t *); int (*_read)(struct streamd_t *, void *, unsigned long); int (*_write)(struct streamd_t *, void *, unsigned long); int (*_getfd)(struct streamd_t *); int (*_unlink)(char *); char name[4]; } op; void *handler; struct DL_LIST *next; } *

user_defined_types: struct DL_LIST { struct operation_t op; void *handler; struct DL_LIST *next; }


decompiled_code:
int time_help()
{
puts("Commande TIM");
puts(" Affiche l'heure du serveur");
puts(" Usage : ");
return puts(" \"TIM\"");
}

canonical_decompiled_code:
int func6()
{
puts("Commande TIM");
puts(" Affiche l'heure du serveur");
puts(" Usage : ");
return puts(" \"TIM\"");
}

original_code:
void time_help() {
    printf("Commande TIM\n");
    printf("  Affiche l'heure du serveur\n");
    printf("  Usage : \n");
    printf("    \"TIM\"\n");
}


decompiled_code:
char *__fastcall time_request_func(char *src)
{
char *v1; // rbx

v1 = (char *)malloc(0x18uLL);
*(_QWORD *)v1 = 24LL;
strncpy(v1 + 12, src, 3uLL);
v1[15] = 0;
*((_DWORD *)v1 + 2) = getpid();
return v1;
}

canonical_decompiled_code:
char *__fastcall func7(char *src)
{
char *v1; // rbx

v1 = (char *)malloc(0x18uLL);
*(_QWORD *)v1 = 24LL;
strncpy(v1 + 12, src, 3uLL);
v1[15] = 0;
*((_DWORD *)v1 + 2) = getpid();
return v1;
}

original_code:
request_t* time_request_func(const char* cmd) {
 request_t* req = malloc(sizeof(request_t));
 req->size = sizeof(request_t);
 strncpy(req->cmdname, cmd, 3);
 req->cmdname[3] = '\0';
 req->clientpid = getpid();
 return req;
}

canonical_original_code:
struct request_t *time_request_func(char *cmd) {
 struct request_t *req = malloc(sizeof(request_t));
 req->size = sizeof(request_t);
 strncpy(req->cmdname, cmd, 3);
 req->cmdname[3] = '\0';
 req->clientpid = getpid();
 return req;
}


addChild

decompiled_code:
void __fastcall addChild(int a1, int a2)
{
_QWORD *v2; // rdx
_QWORD *v3; // rax
_QWORD *v4; // rcx

if ( a2 != -1 && !(unsigned int)childExist(a1) )
{
v2 = malloc(0x10uLL);
v3 = child_list;
if ( child_list && *(_DWORD *)child_list < a1 )
{
do
{
v4 = v3;
v3 = (_QWORD *)v3[1];
}
while ( v3 && *(_DWORD *)v3 < a1 );
v2[1] = v3;
*(_DWORD *)v2 = a1;
*((_DWORD *)v2 + 1) = a2;
v4[1] = v2;
}
else
{
v2[1] = child_list;
*(_DWORD *)v2 = a1;
*((_DWORD *)v2 + 1) = a2;
child_list = v2;
}
}
}

canonical_decompiled_code:
void __fastcall func1(int a1, int a2)
{
_QWORD *v2; // rdx
_QWORD *v3; // rax
_QWORD *v4; // rcx

if ( a2 != -1 && !(unsigned int)func0(a1) )
{
v2 = malloc(0x10uLL);
v3 = child_list;
if ( child_list && *(_DWORD *)child_list < a1 )
{
do
{
v4 = v3;
v3 = (_QWORD *)v3[1];
}
while ( v3 && *(_DWORD *)v3 < a1 );
v2[1] = v3;
*(_DWORD *)v2 = a1;
*((_DWORD *)v2 + 1) = a2;
v4[1] = v2;
}
else
{
v2[1] = child_list;
*(_DWORD *)v2 = a1;
*((_DWORD *)v2 + 1) = a2;
child_list = v2;
}
}
}

original_code:
void addChild(pid_t clientPid, int pipe) {
 if (pipe != -1) {
  if (!childExist(clientPid)) {
   child_list_t elmnt = malloc(sizeof(struct CHILD_LIST));
   child_list_t l = child_list;
   if ((l != ((void *)0)) && (l->client < clientPid)) {
    while ((l->next != ((void *)0)) && (l->next->client < clientPid)) {
     l = l->next;
    }
    elmnt->next = l->next;
    elmnt->client = clientPid;
    elmnt->pipe = pipe;
    l->next = elmnt;
   } else {
    elmnt->next = l;
    elmnt->client = clientPid;
    elmnt->pipe = pipe;
    child_list = elmnt;
   }
  }
 }
}

canonical_original_code:
void addChild(int clientPid, int pipe) {
 if (pipe != -1) {
  if (!childExist(clientPid)) {
   struct CHILD_LIST *elmnt = malloc(sizeof(struct CHILD_LIST));
   struct CHILD_LIST *l = child_list;
   if ((l != ((void *)0)) && (l->client < clientPid)) {
    while ((l->next != ((void *)0)) && (l->next->client < clientPid)) {
     l = l->next;
    }
    elmnt->next = l->next;
    elmnt->client = clientPid;
    elmnt->pipe = pipe;
    l->next = elmnt;
   } else {
    elmnt->next = l;
    elmnt->client = clientPid;
    elmnt->pipe = pipe;
    child_list = elmnt;
   }
  }
 }
}

variable_types: clientPid int

variable_types: pipe int

variable_types: struct CHILD_LIST { int client; int pipe; struct CHILD_LIST *next; } *


getPipe

decompiled_code:
__int64 __fastcall getPipe(int a1)
{
_QWORD *v1; // rax
__int64 result; // rax

v1 = child_list;
if ( !child_list )
return 0xFFFFFFFFLL;
while ( *(_DWORD *)v1 < a1 )
{
v1 = (_QWORD *)v1[1];
if ( !v1 )
return 0xFFFFFFFFLL;
}
if ( *(_DWORD *)v1 == a1 )
result = *((unsigned int *)v1 + 1);
else
result = 0xFFFFFFFFLL;
return result;
}

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

v1 = child_list;
if ( !child_list )
return 0xFFFFFFFFLL;
while ( *(_DWORD *)v1 < a1 )
{
v1 = (_QWORD *)v1[1];
if ( !v1 )
return 0xFFFFFFFFLL;
}
if ( *(_DWORD *)v1 == a1 )
result = *((unsigned int *)v1 + 1);
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int getPipe(pid_t clientPid) {
 child_list_t elmnt = child_list;
 while ((elmnt != ((void *)0)) && (elmnt->client < clientPid)) {
  elmnt = elmnt->next;
 }
 if ((elmnt != ((void *)0)) && (elmnt->client == clientPid)) {
  return elmnt->pipe;
 }
 return -1;
}

canonical_original_code:
int getPipe(int clientPid) {
 struct CHILD_LIST *elmnt = child_list;
 while ((elmnt != ((void *)0)) && (elmnt->client < clientPid)) {
  elmnt = elmnt->next;
 }
 if ((elmnt != ((void *)0)) && (elmnt->client == clientPid)) {
  return elmnt->pipe;
 }
 return -1;
}

user_defined_types: struct CHILD_LIST { int client; int pipe; struct CHILD_LIST *next; }


removeChild

decompiled_code:
void __fastcall removeChild(int a1)
{
void *v1; // rax
_QWORD *v2; // rcx

v1 = child_list;
if ( child_list )
{
if ( *(_DWORD *)child_list == a1 )
{
child_list = (void *)*((_QWORD *)child_list + 1);
*((_QWORD *)v1 + 1) = deleted;
deleted = (__int64)v1;
if ( close(*((_DWORD *)v1 + 1)) == -1 )
LABEL_9:
perror("close");
}
else
{
while ( 1 )
{
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 1);
if ( !v1 )
break;
if ( *(_DWORD *)v1 >= a1 )
{
if ( *(_DWORD *)v1 != a1 )
return;
v2[1] = *((_QWORD *)v1 + 1);
*((_QWORD *)v1 + 1) = deleted;
deleted = (__int64)v1;
if ( close(*((_DWORD *)v1 + 1)) != -1 )
return;
goto LABEL_9;
}
}
}
}
}

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

v1 = child_list;
if ( child_list )
{
if ( *(_DWORD *)child_list == a1 )
{
child_list = (void *)*((_QWORD *)child_list + 1);
*((_QWORD *)v1 + 1) = deleted;
deleted = (__int64)v1;
if ( close(*((_DWORD *)v1 + 1)) == -1 )
LABEL_9:
perror("close");
}
else
{
while ( 1 )
{
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 1);
if ( !v1 )
break;
if ( *(_DWORD *)v1 >= a1 )
{
if ( *(_DWORD *)v1 != a1 )
return;
v2[1] = *((_QWORD *)v1 + 1);
*((_QWORD *)v1 + 1) = deleted;
deleted = (__int64)v1;
if ( close(*((_DWORD *)v1 + 1)) != -1 )
return;
goto LABEL_9;
}
}
}
}
}

original_code:
void removeChild(pid_t clientPid) {
 child_list_t l = child_list;
 if ((l != ((void *)0)) && (l->client != clientPid)) {
  while ((l->next != ((void *)0)) && (l->next->client < clientPid)) {
   l = l->next;
  }
  if ((l->next != ((void *)0)) && (l->next->client == clientPid)) {
   child_list_t elmnt = l->next;
   l->next = elmnt->next;
   elmnt->next = deleted;
   deleted = elmnt;
   if (close(elmnt->pipe) == -1) {
    perror("close");
   }
  }
 } else if ((l != ((void *)0)) && (l->client == clientPid)) {
  child_list_t elmnt = l;
  child_list = elmnt->next;
  elmnt->next = deleted;
  deleted = elmnt;
  if (close(elmnt->pipe) == -1) {
   perror("close");
  }
 }
}

canonical_original_code:
void removeChild(int clientPid) {
 struct CHILD_LIST *l = child_list;
 if ((l != ((void *)0)) && (l->client != clientPid)) {
  while ((l->next != ((void *)0)) && (l->next->client < clientPid)) {
   l = l->next;
  }
  if ((l->next != ((void *)0)) && (l->next->client == clientPid)) {
   struct CHILD_LIST *elmnt = l->next;
   l->next = elmnt->next;
   elmnt->next = deleted;
   deleted = elmnt;
   if (close(elmnt->pipe) == -1) {
    perror("close");
   }
  }
 } else if ((l != ((void *)0)) && (l->client == clientPid)) {
  struct CHILD_LIST *elmnt = l;
  child_list = elmnt->next;
  elmnt->next = deleted;
  deleted = elmnt;
  if (close(elmnt->pipe) == -1) {
   perror("close");
  }
 }
}


childsClean

decompiled_code:
__int64 childsClean()
{
_QWORD *v0; // rbx
__int64 result; // rax
_QWORD *v2; // rax

v0 = child_list;
if ( child_list )
{
do
{
v2 = v0;
v0 = (_QWORD *)v0[1];
if ( close(*((_DWORD *)v2 + 1)) == -1 )
perror("close");
free(child_list);
child_list = v0;
}
while ( v0 );
}
for ( result = deleted; result; deleted = result )
result = *(_QWORD *)(result + 8);
return result;
}

canonical_decompiled_code:
__int64 func4()
{
_QWORD *v0; // rbx
__int64 result; // rax
_QWORD *v2; // rax

v0 = child_list;
if ( child_list )
{
do
{
v2 = v0;
v0 = (_QWORD *)v0[1];
if ( close(*((_DWORD *)v2 + 1)) == -1 )
perror("close");
free(child_list);
child_list = v0;
}
while ( v0 );
}
for ( result = deleted; result; deleted = result )
result = *(_QWORD *)(result + 8);
return result;
}

original_code:
void childsClean() {
 while (child_list != ((void *)0)) {
  child_list_t next = child_list->next;
  if (close(child_list->pipe) == -1) {
   perror("close");
  }
  free(child_list);
  child_list = next;
 }
 while (deleted != ((void *)0)) {
  child_list_t next = deleted->next;
  free(child_list);
  deleted = next;
 }
}

canonical_original_code:
void childsClean() {
 while (child_list != ((void *)0)) {
  struct CHILD_LIST *next = child_list->next;
  if (close(child_list->pipe) == -1) {
   perror("close");
  }
  free(child_list);
  child_list = next;
 }
 while (deleted != ((void *)0)) {
  struct CHILD_LIST *next = deleted->next;
  free(child_list);
  deleted = next;
 }
}


decompiled_code:
int pid_help()
{
puts("Commande PID");
puts(" Affiche le nom du processus 'numpid'");
puts(" Usage : ");
return puts(" \"PID numpid\"");
}

canonical_decompiled_code:
int func6()
{
puts("Commande PID");
puts(" Affiche le nom du processus 'numpid'");
puts(" Usage : ");
return puts(" \"PID numpid\"");
}

original_code:
void pid_help() {
    printf("Commande PID\n");
    printf("  Affiche le nom du processus 'numpid'\n");
    printf("  Usage : \n");
    printf("    \"PID numpid\"\n");
}


decompiled_code:
char *__fastcall pid_request_func(char *src)
{
int v1; // er12
char *v2; // rbx
char *endptr; // [rsp+8h] [rbp-20h] BYREF

endptr = 0LL;
v1 = strtol(src + 3, &endptr, 0);
if ( *__errno_location() && !v1 )
{
fprintf(stderr, "%s n'est pas un entier\n", src + 3);
pid_help();
v2 = 0LL;
}
else
{
v2 = (char *)malloc(0x1CuLL);
*(_QWORD *)v2 = 28LL;
strncpy(v2 + 12, src, 3uLL);
v2[15] = 0;
*((_DWORD *)v2 + 2) = getpid();
*((_DWORD *)v2 + 4) = v1;
}
return v2;
}

canonical_decompiled_code:
char *__fastcall func7(char *src)
{
int v1; // er12
char *v2; // rbx
char *endptr; // [rsp+8h] [rbp-20h] BYREF

endptr = 0LL;
v1 = strtol(src + 3, &endptr, 0);
if ( *__errno_location() && !v1 )
{
fprintf(stderr, "%s n'est pas un entier\n", src + 3);
func6();
v2 = 0LL;
}
else
{
v2 = (char *)malloc(0x1CuLL);
*(_QWORD *)v2 = 28LL;
strncpy(v2 + 12, src, 3uLL);
v2[15] = 0;
*((_DWORD *)v2 + 2) = getpid();
*((_DWORD *)v2 + 4) = v1;
}
return v2;
}

original_code:
request_t* pid_request_func(const char* cmd) {
 char* tailptr[] = { ((void *)0) };
 pid_t pid = strtol(cmd + 3, tailptr, 0);
 if (((*__errno_location ()) == 34 && (pid == 0x7fffffffffffffffL || pid == (-0x7fffffffffffffffL - 1L)))
     || ((*__errno_location ()) != 0 && pid == 0)) {
     fprintf(stderr, "%s n'est pas un entier\n", cmd + 3);
     pid_help();
     return ((void *)0);
 }
 request_t* req = malloc(sizeof(request_t) + sizeof(pid_t));
 req->size = sizeof(request_t) + sizeof(pid_t);
 strncpy(req->cmdname, cmd, 3);
 req->cmdname[3] = '\0';
 req->clientpid = getpid();
 *((int*)req->data) = pid;
 return req;
}

canonical_original_code:
struct request_t *pid_request_func(char *cmd) {
 char *tailptr[] = { ((void *)0) };
 int pid = strtol(cmd + 3, tailptr, 0);
 if (((*__errno_location ()) == 34 && (pid == 0x7fffffffffffffffL || pid == (-0x7fffffffffffffffL - 1L)))
     || ((*__errno_location ()) != 0 && pid == 0)) {
     fprintf(stderr, "%s n'est pas un entier\n", cmd + 3);
     pid_help();
     return ((void *)0);
 }
 struct request_t *req = malloc(sizeof(request_t) + sizeof(pid_t));
 req->size = sizeof(request_t) + sizeof(pid_t);
 strncpy(req->cmdname, cmd, 3);
 req->cmdname[3] = '\0';
 req->clientpid = getpid();
 *((int *)req->data) = pid;
 return req;
}

variable_types:
cmd
char *

variable_types:
tailptr
char *[]

variable_types: struct request_t { unsigned long size; int clientpid; char cmdname[4]; char data[1]; } *


getRequestName

decompiled_code:
const char *getRequestName()
{
return "request_stream";
}

canonical_decompiled_code:
const char *func0()
{
return "request_stream";
}

original_code:
const char* getRequestName() {
 return request_name;
}

canonical_original_code:
char *getRequestName() {
 return request_name;
}

return_type: char *


getAnswerPrefix

decompiled_code:
const char *getAnswerPrefix()
{
return "answer_stream";
}

canonical_decompiled_code:
const char *func1()
{
return "answer_stream";
}

original_code:
const char* getAnswerPrefix() {
 return answer_prefix;
}

canonical_original_code:
char *getAnswerPrefix() {
 return answer_prefix;
}


decompiled_code:
int uid_help()
{
puts("Commande UID");
puts(" Affiche le nom de l'utilisateur 'numuid'");
puts(" Usage : ");
return puts(" \"UID numuid\"");
}

canonical_decompiled_code:
int func6()
{
puts("Commande UID");
puts(" Affiche le nom de l'utilisateur 'numuid'");
puts(" Usage : ");
return puts(" \"UID numuid\"");
}

original_code:
void uid_help() {
    printf("Commande UID\n");
    printf("  Affiche le nom de l'utilisateur 'numuid'\n");
    printf("  Usage : \n");
    printf("    \"UID numuid\"\n");
}


decompiled_code:
char *__fastcall uid_request_func(char *src)
{
int v1; // er12
char *v2; // rbx
char *endptr; // [rsp+8h] [rbp-20h] BYREF

endptr = 0LL;
v1 = strtol(src + 3, &endptr, 0);
if ( *__errno_location() && !v1 )
{
fprintf(stderr, "%s n'est pas un entier\n", src + 3);
uid_help();
v2 = 0LL;
}
else
{
v2 = (char *)malloc(0x1CuLL);
*(_QWORD *)v2 = 28LL;
strncpy(v2 + 12, src, 3uLL);
v2[15] = 0;
*((_DWORD *)v2 + 2) = getpid();
*((_DWORD *)v2 + 4) = v1;
}
return v2;
}

original_code:
request_t* uid_request_func(const char* cmd) {
 char* tailptr[] = { ((void *)0) };
 uid_t uid = strtol(cmd + 3, tailptr, 0);
 if (((*__errno_location ()) == 34 && (uid == 0x7fffffffffffffffL || uid == (-0x7fffffffffffffffL - 1L)))
     || ((*__errno_location ()) != 0 && uid == 0)) {
     fprintf(stderr, "%s n'est pas un entier\n", cmd + 3);
     uid_help();
     return ((void *)0);
 }
 request_t* req = malloc(sizeof(request_t) + sizeof(uid_t));
 req->size = sizeof(request_t) + sizeof(uid_t);
 strncpy(req->cmdname, cmd, 3);
 req->cmdname[3] = '\0';
 req->clientpid = getpid();
 *((int*)req->data) = uid;
 return req;
}

canonical_original_code:
struct request_t *uid_request_func(char *cmd) {
 char *tailptr[] = { ((void *)0) };
 unsigned int uid = strtol(cmd + 3, tailptr, 0);
 if (((*__errno_location ()) == 34 && (uid == 0x7fffffffffffffffL || uid == (-0x7fffffffffffffffL - 1L)))
     || ((*__errno_location ()) != 0 && uid == 0)) {
     fprintf(stderr, "%s n'est pas un entier\n", cmd + 3);
     uid_help();
     return ((void *)0);
 }
 struct request_t *req = malloc(sizeof(request_t) + sizeof(uid_t));
 req->size = sizeof(request_t) + sizeof(uid_t);
 strncpy(req->cmdname, cmd, 3);
 req->cmdname[3] = '\0';
 req->clientpid = getpid();
 *((int *)req->data) = uid;
 return req;
}

variable_types:
uid
unsigned int


decompiled_code:
int gid_help()
{
puts("Commande GID");
puts(" Affiche le nom du groupe 'numgid'");
puts(" Usage : ");
return puts(" \"GID numgid\"");
}

canonical_decompiled_code:
int func6()
{
puts("Commande GID");
puts(" Affiche le nom du groupe 'numgid'");
puts(" Usage : ");
return puts(" \"GID numgid\"");
}

original_code:
void gid_help() {
    printf("Commande GID\n");
    printf("  Affiche le nom du groupe 'numgid'\n");
    printf("  Usage : \n");
    printf("    \"GID numgid\"\n");
}


decompiled_code:
char *__fastcall gid_request_func(char *src)
{
int v1; // er12
char *v2; // rbx
char *endptr; // [rsp+8h] [rbp-20h] BYREF

endptr = 0LL;
v1 = strtol(src + 3, &endptr, 0);
if ( *__errno_location() )
{
perror("strtol");
v2 = 0LL;
}
else if ( !v1 && endptr )
{
fprintf(stderr, "%s n'est pas un entier\n", src);
gid_help();
v2 = 0LL;
}
else
{
v2 = (char *)malloc(0x1CuLL);
*(_QWORD *)v2 = 28LL;
strncpy(v2 + 12, src, 3uLL);
v2[15] = 0;
*((_DWORD *)v2 + 2) = getpid();
*((_DWORD *)v2 + 4) = v1;
}
return v2;
}

canonical_decompiled_code:
char *__fastcall func7(char *src)
{
int v1; // er12
char *v2; // rbx
char *endptr; // [rsp+8h] [rbp-20h] BYREF

endptr = 0LL;
v1 = strtol(src + 3, &endptr, 0);
if ( *__errno_location() )
{
perror("strtol");
v2 = 0LL;
}
else if ( !v1 && endptr )
{
fprintf(stderr, "%s n'est pas un entier\n", src);
func6();
v2 = 0LL;
}
else
{
v2 = (char *)malloc(0x1CuLL);
*(_QWORD *)v2 = 28LL;
strncpy(v2 + 12, src, 3uLL);
v2[15] = 0;
*((_DWORD *)v2 + 2) = getpid();
*((_DWORD *)v2 + 4) = v1;
}
return v2;
}

original_code:
request_t* gid_request_func(const char* cmd) {
 char* tailptr[] = { ((void *)0) };
 gid_t gid = strtol(cmd + 3, tailptr, 0);
 if ((*__errno_location ()) != 0) {
  perror("strtol");
  return ((void *)0);
 }
 if ((gid == 0) && (tailptr[0] != ((void *)0))) {
  fprintf(stderr, "%s n'est pas un entier\n", cmd);
        gid_help();
  return ((void *)0);
 }
 request_t* req = malloc(sizeof(request_t) + sizeof(gid_t));
 req->size = sizeof(request_t) + sizeof(gid_t);
 strncpy(req->cmdname, cmd, 3);
 req->cmdname[3] = '\0';
 req->clientpid = getpid();
 *((int*)req->data) = gid;
 return req;
}

canonical_original_code:
struct request_t *gid_request_func(char *cmd) {
 char *tailptr[] = { ((void *)0) };
 unsigned int gid = strtol(cmd + 3, tailptr, 0);
 if ((*__errno_location ()) != 0) {
  perror("strtol");
  return ((void *)0);
 }
 if ((gid == 0) && (tailptr[0] != ((void *)0))) {
  fprintf(stderr, "%s n'est pas un entier\n", cmd);
        gid_help();
  return ((void *)0);
 }
 struct request_t *req = malloc(sizeof(request_t) + sizeof(gid_t));
 req->size = sizeof(request_t) + sizeof(gid_t);
 strncpy(req->cmdname, cmd, 3);
 req->cmdname[3] = '\0';
 req->clientpid = getpid();
 *((int *)req->data) = gid;
 return req;
}

variable_types:
gid
unsigned int


decompiled_code:
int __fastcall process_request(__m128i *a1, __int64 a2)
{
int result; // eax
unsigned int v3; // er12
const char *v4; // rax
__m128i v5; // [rsp+0h] [rbp-2268h] BYREF
__m128i v6; // [rsp+10h] [rbp-2258h] BYREF
__m128i v7; // [rsp+20h] [rbp-2248h] BYREF
__m128i v8; // [rsp+30h] [rbp-2238h] BYREF
__int64 v9; // [rsp+40h] [rbp-2228h]
char s[512]; // [rsp+50h] [rbp-2218h] BYREF
char v11[8216]; // [rsp+250h] [rbp-2018h] BYREF

result = get_answer(a2, v11, 0x2000LL);
if ( result == -2 )
{
v3 = *(_DWORD *)(a2 + 8);
v4 = (const char *)getAnswerPrefix();
sprintf(s, "%s%i", v4, v3);
if ( (int)stream_close(a1) < 0 )
fwrite("Erreur de fermeture d'un flux", 1uLL, 0x1DuLL, stderr);
manager_getstream(&v5, v11);
*a1 = _mm_loadu_si128(&v5);
a1[1] = _mm_loadu_si128(&v6);
a1[2] = _mm_loadu_si128(&v7);
a1[3] = _mm_loadu_si128(&v8);
a1[4].m128i_i64[0] = v9;
if ( (int)stream_open(a1, s, 1LL) < 0 )
raise(15);
result = printf("Changement de communication avec %d en %s\n", *(unsigned int *)(a2 + 8), v11);
}
else if ( result == -3 )
{
printf("Terminaison du client %d\n", *(unsigned int *)(a2 + 8));
result = done();
}
else if ( result >= 0 )
{
result = stream_write(a1, v11, 0x1FFFLL);
if ( result < 0 )
result = raise(15);
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(__m128i *a1, __int64 a2)
{
int result; // eax
unsigned int v3; // er12
const char *v4; // rax
__m128i v5; // [rsp+0h] [rbp-2268h] BYREF
__m128i v6; // [rsp+10h] [rbp-2258h] BYREF
__m128i v7; // [rsp+20h] [rbp-2248h] BYREF
__m128i v8; // [rsp+30h] [rbp-2238h] BYREF
__int64 v9; // [rsp+40h] [rbp-2228h]
char s[512]; // [rsp+50h] [rbp-2218h] BYREF
char v11[8216]; // [rsp+250h] [rbp-2018h] BYREF

result = get_answer(a2, v11, 0x2000LL);
if ( result == -2 )
{
v3 = *(_DWORD *)(a2 + 8);
v4 = (const char *)getAnswerPrefix();
sprintf(s, "%s%i", v4, v3);
if ( (int)stream_close(a1) < 0 )
fwrite("Erreur de fermeture d'un flux", 1uLL, 0x1DuLL, stderr);
manager_getstream(&v5, v11);
*a1 = _mm_loadu_si128(&v5);
a1[1] = _mm_loadu_si128(&v6);
a1[2] = _mm_loadu_si128(&v7);
a1[3] = _mm_loadu_si128(&v8);
a1[4].m128i_i64[0] = v9;
if ( (int)stream_open(a1, s, 1LL) < 0 )
raise(15);
result = printf("Changement de communication avec %d en %s\n", *(unsigned int *)(a2 + 8), v11);
}
else if ( result == -3 )
{
printf("Terminaison du client %d\n", *(unsigned int *)(a2 + 8));
result = done();
}
else if ( result >= 0 )
{
result = stream_write(a1, v11, 0x1FFFLL);
if ( result < 0 )
result = raise(15);
}
return result;
}

original_code:
static void process_request(stream_t* stream, request_t *req) {
    char buf[8192];
 int n = get_answer(req, buf, 8192);
 if (n == -2) {
  char ans_name[512];
  sprintf(ans_name, "%s%i", getAnswerPrefix(), req->clientpid);
  if (stream_close(stream) < 0) {
   fprintf(stderr, "Erreur de fermeture d'un flux");
  }
  *stream = manager_getstream(buf);
  if (stream_open(stream, ans_name, 01) < 0) {
   raise(15);
  }
  printf("Changement de communication avec %d en %s\n", req->clientpid, buf);
 } else if (n == -3) {
  printf("Terminaison du client %d\n", req->clientpid);
  done();
 } else if (n >= 0) {
  if (stream_write(stream, buf, 8192 -1) < 0) {
   raise(15);
  }
 }
}

canonical_original_code:
static void process_request(struct stream_t *stream, struct request_t *req) {
    char buf[8192];
 int n = get_answer(req, buf, 8192);
 if (n == -2) {
  char ans_name[512];
  sprintf(ans_name, "%s%i", getAnswerPrefix(), req->clientpid);
  if (stream_close(stream) < 0) {
   fprintf(stderr, "Erreur de fermeture d'un flux");
  }
  *stream = manager_getstream(buf);
  if (stream_open(stream, ans_name, 01) < 0) {
   raise(15);
  }
  printf("Changement de communication avec %d en %s\n", req->clientpid, buf);
 } else if (n == -3) {
  printf("Terminaison du client %d\n", req->clientpid);
  done();
 } else if (n >= 0) {
  if (stream_write(stream, buf, 8192 -1) < 0) {
   raise(15);
  }
 }
}

variable_types: struct stream_t { struct operation_t { int (*_create)(struct streamd_t { void *data; } *, char *, unsigned long); int (*_open)(struct streamd_t *, char *, int); int (*_close)(struct streamd_t *); int (*_read)(struct streamd_t *, void *, unsigned long); int (*_write)(struct streamd_t *, void *, unsigned long); int (*_getfd)(struct streamd_t *); int (*_unlink)(char *); char name[4]; } op; struct streamd_t sd; } *

variable_types:
buf
char [8192]


createChild

decompiled_code:
size_t __fastcall createChild(int fd, unsigned int a2)
{
const char *v2; // rax
int v3; // eax
size_t result; // rax
__m128i v5[5]; // [rsp+0h] [rbp-2268h] BYREF
char s[512]; // [rsp+50h] [rbp-2218h] BYREF
char buf[8216]; // [rsp+250h] [rbp-2018h] BYREF

setSignals();
manager_getstream(v5, "FIF");
v2 = (const char *)getAnswerPrefix();
sprintf(s, "%s%i", v2, a2);
if ( (int)stream_open(v5, s, 1LL) < 0 )
raise(15);
while ( !(unsigned int)isDone() )
{
v3 = read(fd, buf, 0x2000uLL);
if ( v3 > 0 )
{
process_request(v5, (__int64)buf);
}
else if ( v3 == -1 && (*_errno_location() & 0xFFFFFFFB) != 0 )
{
perror("read");
done();
}
}
result = stream_close(v5);
if ( (result & 0x80000000) != 0LL )
result = fwrite("Erreur de fermeture d'un flux", 1uLL, 0x1DuLL, stderr);
return result;
}

canonical_decompiled_code:
size_t __fastcall func3(int fd, unsigned int a2)
{
const char *v2; // rax
int v3; // eax
size_t result; // rax
__m128i v5[5]; // [rsp+0h] [rbp-2268h] BYREF
char s[512]; // [rsp+50h] [rbp-2218h] BYREF
char buf[8216]; // [rsp+250h] [rbp-2018h] BYREF

func1();
manager_getstream(v5, "FIF");
v2 = (const char *)getAnswerPrefix();
sprintf(s, "%s%i", v2, a2);
if ( (int)stream_open(v5, s, 1LL) < 0 )
raise(15);
while ( !(unsigned int)isDone() )
{
v3 = read(fd, buf, 0x2000uLL);
if ( v3 > 0 )
{
func2(v5, (__int64)buf);
}
else if ( v3 == -1 && (*_errno_location() & 0xFFFFFFFB) != 0 )
{
perror("read");
done();
}
}
result = stream_close(v5);
if ( (result & 0x80000000) != 0LL )
result = fwrite("Erreur de fermeture d'un flux", 1uLL, 0x1DuLL, stderr);
return result;
}

original_code:
void createChild(int pipe, pid_t clientPid) {
 _setSignals();
 char buffer[8192];
 int n = 0;
 char ans_name[512];
 stream_t ans_str = manager_getstream("FIF");
    sprintf(ans_name, "%s%i", getAnswerPrefix(), clientPid);
    if (stream_open(&ans_str, ans_name, 01) < 0) {
  raise(15);
 }
 while (!isDone()) {
  if ((n = read(pipe, buffer, 8192)) > 0) {
   process_request(&ans_str, (request_t*) buffer);
  }
  if ((n == -1) && ((*__errno_location ()) != 4) && ((*__errno_location ()) != 0)) {
   perror("read");
   done();
  }
 }
    if (stream_close(&ans_str) < 0) {
  fprintf(stderr, "Erreur de fermeture d'un flux");
 }
}

canonical_original_code:
void createChild(int pipe, int clientPid) {
 _setSignals();
 char buffer[8192];
 int n = 0;
 char ans_name[512];
 struct stream_t ans_str = manager_getstream("FIF");
    sprintf(ans_name, "%s%i", getAnswerPrefix(), clientPid);
    if (stream_open(&ans_str, ans_name, 01) < 0) {
  raise(15);
 }
 while (!isDone()) {
  if ((n = read(pipe, buffer, 8192)) > 0) {
   process_request(&ans_str, (struct request_t *) buffer);
  }
  if ((n == -1) && ((*__errno_location ()) != 4) && ((*__errno_location ()) != 0)) {
   perror("read");
   done();
  }
 }
    if (stream_close(&ans_str) < 0) {
  fprintf(stderr, "Erreur de fermeture d'un flux");
 }
}

variable_types:
buffer
char [8192]

variable_types: struct stream_t { struct operation_t { int (*_create)(struct streamd_t { void *data; } *, char *, unsigned long); int (*_open)(struct streamd_t *, char *, int); int (*_close)(struct streamd_t *); int (*_read)(struct streamd_t *, void *, unsigned long); int (*_write)(struct streamd_t *, void *, unsigned long); int (*_getfd)(struct streamd_t *); int (*_unlink)(char *); char name[4]; } op; struct streamd_t sd; }


decompiled_code:
__int64 __fastcall exi_answer_func(__int64 a1, _BYTE *a2)
{
*a2 = 0;
return 4294967293LL;
}

original_code:
int exi_answer_func(request_t* req, char* buffer, size_t buffsize) {
 strcpy(buffer, "");
 return -3;
}

canonical_original_code:
int exi_answer_func(struct request_t *req, char *buffer, unsigned long buffsize) {
 strcpy(buffer, "");
 return -3;
}

variable_types:
buffer
char *

variable_types:
buffsize
unsigned long


getCommand

decompiled_code:
__int64 getCommand()
{
return exi_answer_cmd;
}

canonical_decompiled_code:
__int64 func6()
{
return exi_answer_cmd;
}

canonical_original_code:
struct answer_cmd_t getCommand() {
 return exi_answer_cmd;
}

return_type: struct answer_cmd_t { char cmd_name[4]; int (*answer_cmd_func)(struct request_t { unsigned long size; int clientpid; char cmdname[4]; char data[1]; } *, char *, unsigned long); }

user_defined_types: struct answer_cmd_t { char cmd_name[4]; int (*answer_cmd_func)(struct request_t *, char *, unsigned long); }


decompiled_code:
__int64 __fastcall stream_create(__int64 (__fastcall **a1)(__int64, __int64, __int64), __int64 a2, __int64 a3)
{
int v4; // ebp
int v5; // ebp

v4 = check_error_noquit(a1 == 0LL, "stream_create : stream == NULL\n");
v5 = check_error_noquit(a2 == 0, "stream_create : name == NULL\n") | v4;
if ( v5 | (unsigned int)check_error_noquit(a3 == 0, "stream_create : size <= 0\n") )
return 4294967294LL;
manager_addstream(a1, a2);
return (*a1)((__int64)(a1 + 8), a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 (__fastcall **a1)(__int64, __int64, __int64), __int64 a2, __int64 a3)
{
int v4; // ebp
int v5; // ebp

v4 = check_error_noquit(a1 == 0LL, "stream_create : stream == NULL\n");
v5 = check_error_noquit(a2 == 0, "stream_create : name == NULL\n") | v4;
if ( v5 | (unsigned int)check_error_noquit(a3 == 0, "stream_create : size <= 0\n") )
return 4294967294LL;
manager_addstream(a1, a2);
return (*a1)((__int64)(a1 + 8), a2, a3);
}

original_code:
int stream_create(stream_t* stream, const char* name, size_t size) {
    int error = 0;
    error = error | check_error_noquit((stream == ((void *)0))
        , "stream_create : stream == NULL\n");
    error = error | check_error_noquit((name == ((void *)0))
        , "stream_create : name == NULL\n");
    error = error | check_error_noquit((size <= 0)
        , "stream_create : size <= 0\n");
    if (error){
  return -2;
 }
 manager_addstream(stream, name);
    return stream->op._create(&stream->sd, name, size);
}

canonical_original_code:
int stream_create(struct stream_t *stream, char *name, unsigned long size) {
    int error = 0;
    error = error | check_error_noquit((stream == ((void *)0))
        , "stream_create : stream == NULL\n");
    error = error | check_error_noquit((name == ((void *)0))
        , "stream_create : name == NULL\n");
    error = error | check_error_noquit((size <= 0)
        , "stream_create : size <= 0\n");
    if (error){
  return -2;
 }
 manager_addstream(stream, name);
    return stream->op._create(&stream->sd, name, size);
}

variable_types:
name
char *

variable_types:
size
unsigned long

variable_types: error int


decompiled_code:
__int64 __fastcall stream_open(__int64 a1, __int64 a2, unsigned int a3)
{
int v4; // ebx
int v5; // ebx
__int64 result; // rax

v4 = check_error_noquit(a1 == 0, "stream_open : stream == NULL\n");
v5 = check_error_noquit(a2 == 0, "stream_open : name == NULL\n") | v4;
if ( v5 | (unsigned int)check_error_noquit((a3 == 0) == (a3 == 1), "stream_open : oflag invalide\n") )
result = 4294967294LL;
else
result = (*(__int64 (__fastcall **)(__int64, __int64, _QWORD))(a1 + 8))(a1 + 64, a2, a3);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, unsigned int a3)
{
int v4; // ebx
int v5; // ebx
__int64 result; // rax

v4 = check_error_noquit(a1 == 0, "stream_open : stream == NULL\n");
v5 = check_error_noquit(a2 == 0, "stream_open : name == NULL\n") | v4;
if ( v5 | (unsigned int)check_error_noquit((a3 == 0) == (a3 == 1), "stream_open : oflag invalide\n") )
result = 4294967294LL;
else
result = (*(__int64 (__fastcall **)(__int64, __int64, _QWORD))(a1 + 8))(a1 + 64, a2, a3);
return result;
}

original_code:
int stream_open(stream_t* stream, const char* name, int oflag) {
    int flagcheck = (oflag == 00) ^ (oflag == 01);
    int error = 0;
    error = error | check_error_noquit((stream == ((void *)0))
        , "stream_open : stream == NULL\n");
    error = error | check_error_noquit((name == ((void *)0))
        , "stream_open : name == NULL\n");
    error = error | check_error_noquit(!flagcheck
        , "stream_open : oflag invalide\n");
    if (error) {
        return -2;
    }
    return stream->op._open(&(stream->sd), name, oflag);
}

canonical_original_code:
int stream_open(struct stream_t *stream, char *name, int oflag) {
    int flagcheck = (oflag == 00) ^ (oflag == 01);
    int error = 0;
    error = error | check_error_noquit((stream == ((void *)0))
        , "stream_open : stream == NULL\n");
    error = error | check_error_noquit((name == ((void *)0))
        , "stream_open : name == NULL\n");
    error = error | check_error_noquit(!flagcheck
        , "stream_open : oflag invalide\n");
    if (error) {
        return -2;
    }
    return stream->op._open(&(stream->sd), name, oflag);
}

variable_types: oflag int

variable_types: flagcheck int


decompiled_code:
__int64 __fastcall stream_close(__int64 a1)
{
_BOOL4 v1; // er12
int v2; // ebp
__int64 result; // rax

v1 = *(_QWORD *)(a1 + 64) == 0LL;
v2 = check_error_noquit(0LL, "stream_close : stream == NULL\n");
if ( (unsigned int)check_error_noquit(v1, "stream_close : Le flux n'est pas ouvert\n") | v2 )
result = 4294967294LL;
else
result = (*(__int64 (__fastcall **)(__int64))(a1 + 16))(a1 + 64);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
_BOOL4 v1; // er12
int v2; // ebp
__int64 result; // rax

v1 = *(_QWORD *)(a1 + 64) == 0LL;
v2 = check_error_noquit(0LL, "stream_close : stream == NULL\n");
if ( (unsigned int)check_error_noquit(v1, "stream_close : Le flux n'est pas ouvert\n") | v2 )
result = 4294967294LL;
else
result = (*(__int64 (__fastcall **)(__int64))(a1 + 16))(a1 + 64);
return result;
}

original_code:
int stream_close(stream_t* stream) {
    int openflag = (stream->sd.data == ((void *)0));
    int error = 0;
    error = error | check_error_noquit((stream == ((void *)0))
        , "stream_close : stream == NULL\n");
    error = error | check_error_noquit(openflag
        , "stream_close : Le flux n'est pas ouvert\n");
    if (error) {
        return -2;
    }
 return stream->op._close(&stream->sd);
}

canonical_original_code:
int stream_close(struct stream_t *stream) {
    int openflag = (stream->sd.data == ((void *)0));
    int error = 0;
    error = error | check_error_noquit((stream == ((void *)0))
        , "stream_close : stream == NULL\n");
    error = error | check_error_noquit(openflag
        , "stream_close : Le flux n'est pas ouvert\n");
    if (error) {
        return -2;
    }
 return stream->op._close(&stream->sd);
}

variable_types: openflag int


decompiled_code:
__int64 __fastcall stream_read(__int64 a1, __int64 a2, __int64 a3)
{
_BOOL4 v4; // er14
int v5; // ebx
int v6; // ebx
int v7; // ebx
__int64 result; // rax

v4 = *(_QWORD *)(a1 + 64) == 0LL;
v5 = check_error_noquit(0LL, "stream_read : stream == NULL\n");
v6 = check_error_noquit(v4, "stream_read : Le flux n'est pas ouvert\n") | v5;
v7 = check_error_noquit(a2 == 0, "stream_read : buffer == NULL\n") | v6;
if ( v7 | (unsigned int)check_error_noquit(a3 == 0, "stream_read : size <= 0\n") )
result = 4294967294LL;
else
result = (*(__int64 (__fastcall **)(__int64, __int64, __int64))(a1 + 24))(a1 + 64, a2, a3);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3)
{
_BOOL4 v4; // er14
int v5; // ebx
int v6; // ebx
int v7; // ebx
__int64 result; // rax

v4 = *(_QWORD *)(a1 + 64) == 0LL;
v5 = check_error_noquit(0LL, "stream_read : stream == NULL\n");
v6 = check_error_noquit(v4, "stream_read : Le flux n'est pas ouvert\n") | v5;
v7 = check_error_noquit(a2 == 0, "stream_read : buffer == NULL\n") | v6;
if ( v7 | (unsigned int)check_error_noquit(a3 == 0, "stream_read : size <= 0\n") )
result = 4294967294LL;
else
result = (*(__int64 (__fastcall **)(__int64, __int64, __int64))(a1 + 24))(a1 + 64, a2, a3);
return result;
}

original_code:
int stream_read(stream_t* stream, void* buffer, size_t size) {
    int openflag = (stream->sd.data == ((void *)0));
    int error = 0;
    error = error | check_error_noquit((stream == ((void *)0))
        , "stream_read : stream == NULL\n");
    error = error | check_error_noquit(openflag
        , "stream_read : Le flux n'est pas ouvert\n");
    error = error | check_error_noquit((buffer == ((void *)0))
        , "stream_read : buffer == NULL\n");
    error = error | check_error_noquit((size <= 0)
        , "stream_read : size <= 0\n");
    if (error) {
        return -2;
    }
 return stream->op._read(&stream->sd, buffer, size);
}

canonical_original_code:
int stream_read(struct stream_t *stream, void *buffer, unsigned long size) {
    int openflag = (stream->sd.data == ((void *)0));
    int error = 0;
    error = error | check_error_noquit((stream == ((void *)0))
        , "stream_read : stream == NULL\n");
    error = error | check_error_noquit(openflag
        , "stream_read : Le flux n'est pas ouvert\n");
    error = error | check_error_noquit((buffer == ((void *)0))
        , "stream_read : buffer == NULL\n");
    error = error | check_error_noquit((size <= 0)
        , "stream_read : size <= 0\n");
    if (error) {
        return -2;
    }
 return stream->op._read(&stream->sd, buffer, size);
}

variable_types:
buffer
void *


decompiled_code:
__int64 __fastcall stream_write(__int64 a1, __int64 a2, __int64 a3)
{
_BOOL4 v4; // er14
int v5; // ebx
int v6; // ebx
int v7; // ebx
__int64 result; // rax

v4 = *(_QWORD *)(a1 + 64) == 0LL;
v5 = check_error_noquit(0LL, "stream_write : stream == NULL\n");
v6 = check_error_noquit(v4, "stream_write : Le flux n'est pas ouvert\n") | v5;
v7 = check_error_noquit(a2 == 0, "stream_write : buffer == NULL\n") | v6;
if ( v7 | (unsigned int)check_error_noquit(a3 == 0, "stream_write : size <= 0\n") )
result = 4294967294LL;
else
result = (*(__int64 (__fastcall **)(__int64, __int64, __int64))(a1 + 32))(a1 + 64, a2, a3);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 a3)
{
_BOOL4 v4; // er14
int v5; // ebx
int v6; // ebx
int v7; // ebx
__int64 result; // rax

v4 = *(_QWORD *)(a1 + 64) == 0LL;
v5 = check_error_noquit(0LL, "stream_write : stream == NULL\n");
v6 = check_error_noquit(v4, "stream_write : Le flux n'est pas ouvert\n") | v5;
v7 = check_error_noquit(a2 == 0, "stream_write : buffer == NULL\n") | v6;
if ( v7 | (unsigned int)check_error_noquit(a3 == 0, "stream_write : size <= 0\n") )
result = 4294967294LL;
else
result = (*(__int64 (__fastcall **)(__int64, __int64, __int64))(a1 + 32))(a1 + 64, a2, a3);
return result;
}

original_code:
int stream_write(stream_t* stream, void* buffer, size_t size) {
    int openflag = (stream->sd.data == ((void *)0));
    int error = 0;
    error = error | check_error_noquit((stream == ((void *)0))
        , "stream_write : stream == NULL\n");
    error = error | check_error_noquit(openflag
        , "stream_write : Le flux n'est pas ouvert\n");
    error = error | check_error_noquit((buffer == ((void *)0))
        , "stream_write : buffer == NULL\n");
    error = error | check_error_noquit((size <= 0)
        , "stream_write : size <= 0\n");
    if (error) {
        return -2;
    }
 return stream->op._write(&stream->sd, buffer, size);
}

canonical_original_code:
int stream_write(struct stream_t *stream, void *buffer, unsigned long size) {
    int openflag = (stream->sd.data == ((void *)0));
    int error = 0;
    error = error | check_error_noquit((stream == ((void *)0))
        , "stream_write : stream == NULL\n");
    error = error | check_error_noquit(openflag
        , "stream_write : Le flux n'est pas ouvert\n");
    error = error | check_error_noquit((buffer == ((void *)0))
        , "stream_write : buffer == NULL\n");
    error = error | check_error_noquit((size <= 0)
        , "stream_write : size <= 0\n");
    if (error) {
        return -2;
    }
 return stream->op._write(&stream->sd, buffer, size);
}


decompiled_code:
__int64 __fastcall stream_unlink(__int64 a1, __int64 a2)
{
int v2; // er12

v2 = check_error_noquit(a1 == 0, "stream_unlink : stream == NULL\n");
if ( (unsigned int)check_error_noquit(a2 == 0, "stream_unlink : name == NULL\n") | v2 )
return 4294967294LL;
manager_removestream(a1);
return (*(__int64 (__fastcall **)(__int64))(a1 + 48))(a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
int v2; // er12

v2 = check_error_noquit(a1 == 0, "stream_unlink : stream == NULL\n");
if ( (unsigned int)check_error_noquit(a2 == 0, "stream_unlink : name == NULL\n") | v2 )
return 4294967294LL;
manager_removestream(a1);
return (*(__int64 (__fastcall **)(__int64))(a1 + 48))(a2);
}

original_code:
int stream_unlink(stream_t* stream, const char* name) {
    int error = 0;
    error = error | check_error_noquit((stream == ((void *)0))
        , "stream_unlink : stream == NULL\n");
    error = error | check_error_noquit((name == ((void *)0))
        , "stream_unlink : name == NULL\n");
    if (error) {
        return -2;
    }
    manager_removestream(stream);
 return stream->op._unlink(name);
}

canonical_original_code:
int stream_unlink(struct stream_t *stream, char *name) {
    int error = 0;
    error = error | check_error_noquit((stream == ((void *)0))
        , "stream_unlink : stream == NULL\n");
    error = error | check_error_noquit((name == ((void *)0))
        , "stream_unlink : name == NULL\n");
    if (error) {
        return -2;
    }
    manager_removestream(stream);
 return stream->op._unlink(name);
}


decompiled_code:
__int64 __fastcall add_answer_func(__int64 a1, char *a2, size_t a3)
{
snprintf(a2, a3, "%d", (unsigned int)(*(_DWORD *)(a1 + 20) + *(_DWORD *)(a1 + 16)));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, char *a2, size_t a3)
{
snprintf(a2, a3, "%d", (unsigned int)(*(_DWORD *)(a1 + 20) + *(_DWORD *)(a1 + 16)));
return 0LL;
}

original_code:
int add_answer_func(request_t* req, char* buffer, size_t buffsize) {
 int res = 0;
 int x = *((int*) (req->data));
 int y = *((int*) (req->data) + 1);
 snprintf(buffer, buffsize, "%d", x + y);
 return res;
}

canonical_original_code:
int add_answer_func(struct request_t *req, char *buffer, unsigned long buffsize) {
 int res = 0;
 int x = *((int*) (req->data));
 int y = *((int*) (req->data) + 1);
 snprintf(buffer, buffsize, "%d", x + y);
 return res;
}

variable_types: res int

variable_types: x int

variable_types: y int


decompiled_code:
__int64 getCommand()
{
return add_answer_cmd;
}

canonical_decompiled_code:
__int64 func7()
{
return add_answer_cmd;
}

canonical_original_code:
struct answer_cmd_t getCommand() {
 return add_answer_cmd;
}


decompiled_code:
int add_help()
{
puts("Commande ADD");
puts(" Additionne 2 entiers x et y");
puts(" Usage : ");
return puts(" \"ADD x y\"");
}

canonical_decompiled_code:
int func6()
{
puts("Commande ADD");
puts(" Additionne 2 entiers x et y");
puts(" Usage : ");
return puts(" \"ADD x y\"");
}

original_code:
void add_help() {
    printf("Commande ADD\n");
    printf("  Additionne 2 entiers x et y\n");
    printf("  Usage : \n");
    printf("    \"ADD x y\"\n");
}


decompiled_code:
char *__fastcall add_request_func(char *src)
{
int v1; // er12
int *v2; // rax
int *v3; // rbx
int v4; // eax
int v5; // er13
char *v6; // rbx
char *v8; // [rsp+0h] [rbp-38h] BYREF
char *endptr; // [rsp+8h] [rbp-30h] BYREF

v1 = strtol(src + 3, &endptr, 0);
v2 = __errno_location();
v3 = v2;
if ( *v2 && !v1 )
{
fprintf(stderr, "%s n'est pas un entier\n", src + 3);
add_help();
v6 = 0LL;
}
else
{
*v2 = 0;
v4 = strtol(endptr, &v8, 0);
v5 = v4;
if ( *v3 && !v4 )
{
fprintf(stderr, "%s n'est pas un entier\n", v8);
add_help();
v6 = 0LL;
}
else
{
*v3 = 0;
v6 = (char *)malloc(0x20uLL);
*(_QWORD *)v6 = 32LL;
strncpy(v6 + 12, src, 3uLL);
v6[15] = 0;
*((_DWORD *)v6 + 2) = getpid();
*((_DWORD *)v6 + 4) = v1;
*((_DWORD *)v6 + 5) = v5;
}
}
return v6;
}

canonical_decompiled_code:
char *__fastcall func7(char *src)
{
int v1; // er12
int *v2; // rax
int *v3; // rbx
int v4; // eax
int v5; // er13
char *v6; // rbx
char *v8; // [rsp+0h] [rbp-38h] BYREF
char *endptr; // [rsp+8h] [rbp-30h] BYREF

v1 = strtol(src + 3, &endptr, 0);
v2 = __errno_location();
v3 = v2;
if ( *v2 && !v1 )
{
fprintf(stderr, "%s n'est pas un entier\n", src + 3);
func6();
v6 = 0LL;
}
else
{
*v2 = 0;
v4 = strtol(endptr, &v8, 0);
v5 = v4;
if ( *v3 && !v4 )
{
fprintf(stderr, "%s n'est pas un entier\n", v8);
func6();
v6 = 0LL;
}
else
{
*v3 = 0;
v6 = (char *)malloc(0x20uLL);
*(_QWORD *)v6 = 32LL;
strncpy(v6 + 12, src, 3uLL);
v6[15] = 0;
*((_DWORD *)v6 + 2) = getpid();
*((_DWORD *)v6 + 4) = v1;
*((_DWORD *)v6 + 5) = v5;
}
}
return v6;
}

original_code:
request_t* add_request_func(const char* cmd) {
 char* tailptr;
 char* tailptr2;
 int x = 0;
 int y = 0;
 x = strtol(cmd + 3, &tailptr, 0);
 if (((*__errno_location ()) == 34 && (x == 0x7fffffffffffffffL || x == (-0x7fffffffffffffffL - 1L)))
     || ((*__errno_location ()) != 0 && x == 0)) {
     fprintf(stderr, "%s n'est pas un entier\n", cmd + 3);
     add_help();
     return ((void *)0);
 }
 (*__errno_location ()) = 0;
 y = strtol(tailptr, &tailptr2, 0);
 if (((*__errno_location ()) == 34 && (y == 0x7fffffffffffffffL || y == (-0x7fffffffffffffffL - 1L)))
     || ((*__errno_location ()) != 0 && y == 0)) {
     fprintf(stderr, "%s n'est pas un entier\n", tailptr2);
     add_help();
     return ((void *)0);
 }
 (*__errno_location ()) = 0;
 request_t* req = malloc(sizeof(request_t) + 2 * sizeof(int));
 req->size = sizeof(request_t) + 2 * sizeof(int);
 strncpy(req->cmdname, cmd, 3);
 req->cmdname[3] = '\0';
 req->clientpid = getpid();
 *((int*)req->data) = x;
 *((int*)req->data + 1) = y;
 return req;
}

canonical_original_code:
struct request_t *add_request_func(char *cmd) {
 char *tailptr;
 char *tailptr2;
 int x = 0;
 int y = 0;
 x = strtol(cmd + 3, &tailptr, 0);
 if (((*__errno_location ()) == 34 && (x == 0x7fffffffffffffffL || x == (-0x7fffffffffffffffL - 1L)))
     || ((*__errno_location ()) != 0 && x == 0)) {
     fprintf(stderr, "%s n'est pas un entier\n", cmd + 3);
     add_help();
     return ((void *)0);
 }
 (*__errno_location ()) = 0;
 y = strtol(tailptr, &tailptr2, 0);
 if (((*__errno_location ()) == 34 && (y == 0x7fffffffffffffffL || y == (-0x7fffffffffffffffL - 1L)))
     || ((*__errno_location ()) != 0 && y == 0)) {
     fprintf(stderr, "%s n'est pas un entier\n", tailptr2);
     add_help();
     return ((void *)0);
 }
 (*__errno_location ()) = 0;
 struct request_t *req = malloc(sizeof(request_t) + 2 * sizeof(int));
 req->size = sizeof(request_t) + 2 * sizeof(int);
 strncpy(req->cmdname, cmd, 3);
 req->cmdname[3] = '\0';
 req->clientpid = getpid();
 *((int *)req->data) = x;
 *((int *)req->data + 1) = y;
 return req;
}

variable_types:
cmd
char *

variable_types:
tailptr
char *

variable_types: struct request_t { unsigned long size; int clientpid; char cmdname[4]; char data[1]; } *


decompiled_code:
__int64 __fastcall get_answer(__int64 a1, char *a2, size_t a3)
{
char *v4; // rbx
__int64 result; // rax

if ( a1 && a2 )
{
v4 = dl_list;
if ( dl_list )
{
while ( strncmp((const char *)(a1 + 12), v4, 3uLL) )
{
v4 = (char *)*((_QWORD *)v4 + 3);
if ( !v4 )
goto LABEL_6;
}
result = (*((__int64 (__fastcall **)(__int64, char *, size_t))v4 + 1))(a1, a2, a3);
}
else
{
LABEL_6:
fprintf(stderr, "Commande %s inconnue\n", (const char *)(a1 + 12));
snprintf(a2, a3, "Commande %s inconnue", (const char *)(a1 + 12));
result = 0xFFFFFFFFLL;
}
}
else
{
snprintf(a2, a3, "Erreur interne du server");
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, char *a2, size_t a3)
{
char *v4; // rbx
__int64 result; // rax

if ( a1 && a2 )
{
v4 = dl_list;
if ( dl_list )
{
while ( strncmp((const char *)(a1 + 12), v4, 3uLL) )
{
v4 = (char *)*((_QWORD *)v4 + 3);
if ( !v4 )
goto LABEL_6;
}
result = (*((__int64 (__fastcall **)(__int64, char *, size_t))v4 + 1))(a1, a2, a3);
}
else
{
LABEL_6:
fprintf(stderr, "Commande %s inconnue\n", (const char *)(a1 + 12));
snprintf(a2, a3, "Commande %s inconnue", (const char *)(a1 + 12));
result = 0xFFFFFFFFLL;
}
}
else
{
snprintf(a2, a3, "Erreur interne du server");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int get_answer(request_t* req, char* buffer, size_t buffsize) {
 if ((req != ((void *)0)) && (buffer != ((void *)0))) {
  dl_list_t elmnt = dl_list;
  while (elmnt != ((void *)0)) {
   if (strncmp(req->cmdname, elmnt->cmd.cmd_name, 3) == 0) {
    return elmnt->cmd.answer_cmd_func(req, buffer, buffsize);
   }
   elmnt = elmnt->next;
  }
  fprintf(stderr, "Commande %s inconnue\n", req->cmdname);
  snprintf(buffer, buffsize, "Commande %s inconnue", req->cmdname);
 }else {
  snprintf(buffer, buffsize, "Erreur interne du server");
 }
 return -1;
}

canonical_original_code:
int get_answer(struct request_t *req, char *buffer, unsigned long buffsize) {
 if ((req != ((void *)0)) && (buffer != ((void *)0))) {
  struct DL_LIST *elmnt = dl_list;
  while (elmnt != ((void *)0)) {
   if (strncmp(req->cmdname, elmnt->cmd.cmd_name, 3) == 0) {
    return elmnt->cmd.answer_cmd_func(req, buffer, buffsize);
   }
   elmnt = elmnt->next;
  }
  fprintf(stderr, "Commande %s inconnue\n", req->cmdname);
  snprintf(buffer, buffsize, "Commande %s inconnue", req->cmdname);
 }else {
  snprintf(buffer, buffsize, "Erreur interne du server");
 }
 return -1;
}

variable_types: struct DL_LIST { struct answer_cmd_t { char cmd_name[4]; int (*answer_cmd_func)(struct request_t { unsigned long size; int clientpid; char cmdname[4]; char data[1]; } *, char *, unsigned long); } cmd; void *handler; struct DL_LIST *next; } *

user_defined_types: struct DL_LIST { struct answer_cmd_t cmd; void *handler; struct DL_LIST *next; }


decompiled_code:
void request_manager_close()
{
char *v0; // rbx
char *v1; // rbp
char *v2; // rax

v0 = dl_list;
if ( dl_list )
{
while ( 1 )
{
if ( dlclose(*((void **)v0 + 2)) == -1 )
{
v2 = dlerror();
fprintf(stderr, "dlclose : %s\n", v2);
raise(15);
}
v1 = (char *)*((_QWORD *)v0 + 3);
free(v0);
if ( !v1 )
break;
v0 = v1;
}
}
}

canonical_decompiled_code:
void func2()
{
char *v0; // rbx
char *v1; // rbp
char *v2; // rax

v0 = dl_list;
if ( dl_list )
{
while ( 1 )
{
if ( dlclose(*((void **)v0 + 2)) == -1 )
{
v2 = dlerror();
fprintf(stderr, "dlclose : %s\n", v2);
raise(15);
}
v1 = (char *)*((_QWORD *)v0 + 3);
free(v0);
if ( !v1 )
break;
v0 = v1;
}
}
}

original_code:
void request_manager_close() {
 dl_list_t elmnt = dl_list;
 while (elmnt != ((void *)0)) {
  if (dlclose(elmnt->handler) == -1) {
   fprintf(stderr, "dlclose : %s\n", dlerror());
   raise(15);
  }
  dl_list_t next = elmnt->next;
  free(elmnt);
  elmnt = next;
 }
}

canonical_original_code:
void request_manager_close() {
 struct DL_LIST *elmnt = dl_list;
 while (elmnt != ((void *)0)) {
  if (dlclose(elmnt->handler) == -1) {
   fprintf(stderr, "dlclose : %s\n", dlerror());
   raise(15);
  }
  struct DL_LIST *next = elmnt->next;
  free(elmnt);
  elmnt = next;
 }
}

variable_types: struct DL_LIST { struct request_cmd_t { char cmd_name[4]; struct request_t { unsigned long size; int clientpid; char cmdname[4]; char data[1]; } *(*request_cmd_func)(char *); void (*help)(); } cmd; void *handler; struct DL_LIST *next; } *


decompiled_code:
__int64 __fastcall con_answer_func(__int64 a1, _BYTE *a2)
{
*a2 = 0;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, _BYTE *a2)
{
*a2 = 0;
return 0LL;
}

original_code:
int con_answer_func(request_t* req, char* buffer, size_t buffsize) {
 strcpy(buffer, "");
 return 0;
}

canonical_original_code:
int con_answer_func(struct request_t *req, char *buffer, unsigned long buffsize) {
 strcpy(buffer, "");
 return 0;
}

variable_types:
buffer
char *


decompiled_code:
__int64 getCommand()
{
return con_answer_cmd;
}

canonical_decompiled_code:
__int64 func6()
{
return con_answer_cmd;
}

canonical_original_code:
struct answer_cmd_t getCommand() {
 return con_answer_cmd;
}


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

result = 0xFFFFFFFFLL;
if ( a3 > 3 )
{
strncpy(a2, (const char *)(a1 + 16), 3uLL);
a2[3] = 0;
result = 4294967294LL;
}
return result;
}

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

result = 0xFFFFFFFFLL;
if ( a3 > 3 )
{
strncpy(a2, (const char *)(a1 + 16), 3uLL);
a2[3] = 0;
result = 4294967294LL;
}
return result;
}

original_code:
int set_answer_func(request_t* req, char* buffer, size_t buffsize) {
 if (buffsize < 4) {
  return -1;
 }
 strncpy(buffer, ((char*)req->data), 3);
 buffer[3] = '\0';
 return -2;
}

canonical_original_code:
int set_answer_func(struct request_t *req, char *buffer, unsigned long buffsize) {
 if (buffsize < 4) {
  return -1;
 }
 strncpy(buffer, ((char *)req->data), 3);
 buffer[3] = '\0';
 return -2;
}

variable_types:
buffsize
unsigned long


decompiled_code:
__int64 getCommand()
{
return set_answer_cmd;
}

canonical_decompiled_code:
__int64 func7()
{
return set_answer_cmd;
}

canonical_original_code:
struct answer_cmd_t getCommand() {
 return set_answer_cmd;
}


done

decompiled_code:
void done()
{
is_done = 1;
}

canonical_decompiled_code:
void func0()
{
is_done = 1;
}

original_code:
void done() {
 is_done = 1;
}

canonical_original_code:
void done() {
 is_done = 1;
}


isDone

decompiled_code:
__int64 isDone()
{
return (unsigned int)is_done;
}

canonical_decompiled_code:
__int64 func2()
{
return (unsigned int)is_done;
}

original_code:
int isDone() {
 return is_done;
}

canonical_original_code:
int isDone() {
 return is_done;
}


decompiled_code:
__int64 __fastcall gid_answer_func(__int64 a1, char *a2, size_t a3)
{
struct group *v4; // rax
__int64 result; // rax

v4 = getgrgid(*(_DWORD *)(a1 + 16));
if ( v4 )
{
snprintf(a2, a3, "%s", v4->gr_name);
result = 0LL;
}
else
{
snprintf(a2, a3, "Erreur lors de la lecture du gid : %d", *(unsigned int *)(a1 + 16));
fprintf(stderr, "%s\n", a2);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, char *a2, size_t a3)
{
struct group *v4; // rax
__int64 result; // rax

v4 = getgrgid(*(_DWORD *)(a1 + 16));
if ( v4 )
{
snprintf(a2, a3, "%s", v4->gr_name);
result = 0LL;
}
else
{
snprintf(a2, a3, "Erreur lors de la lecture du gid : %d", *(unsigned int *)(a1 + 16));
fprintf(stderr, "%s\n", a2);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int gid_answer_func(request_t* req, char* buffer, size_t buffsize) {
 int res = 0;
 struct group* grp = getgrgid(*((int*) (req->data)));
 if (grp == ((void *)0)) {
  snprintf(buffer, buffsize
    , "Erreur lors de la lecture du gid : %d"
    , *((int*) (req->data)));
  fprintf(stderr, "%s\n", buffer);
  res = -1;
 } else {
  snprintf(buffer, buffsize, "%s", grp->gr_name);
 }
 return res;
}

canonical_original_code:
int gid_answer_func(struct request_t *req, char *buffer, unsigned long buffsize) {
 int res = 0;
 struct group *grp = getgrgid(*((int*) (req->data)));
 if (grp == ((void *)0)) {
  snprintf(buffer, buffsize
    , "Erreur lors de la lecture du gid : %d"
    , *((int *) (req->data)));
  fprintf(stderr, "%s\n", buffer);
  res = -1;
 } else {
  snprintf(buffer, buffsize, "%s", grp->gr_name);
 }
 return res;
}

variable_types: struct group { char *gr_name; char *gr_passwd; unsigned int gr_gid; char **gr_mem; } *


getCommand

decompiled_code:
__int64 getCommand()
{
return gid_answer_cmd;
}

canonical_decompiled_code:
__int64 func7()
{
return gid_answer_cmd;
}

canonical_original_code:
struct answer_cmd_t getCommand() {
 return gid_answer_cmd;
}


decompiled_code:
void exi_help()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code:
void exi_help() {
}

canonical_original_code:
void exi_help() {
}


decompiled_code:
char *__fastcall exi_request_func(char *src)
{
char *v1; // rbx

v1 = (char *)malloc(0x18uLL);
*(_QWORD *)v1 = 24LL;
strncpy(v1 + 12, src, 3uLL);
v1[15] = 0;
*((_DWORD *)v1 + 2) = getpid();
return v1;
}

canonical_decompiled_code:
char *__fastcall func7(char *src)
{
char *v1; // rbx

v1 = (char *)malloc(0x18uLL);
*(_QWORD *)v1 = 24LL;
strncpy(v1 + 12, src, 3uLL);
v1[15] = 0;
*((_DWORD *)v1 + 2) = getpid();
return v1;
}

original_code:
request_t* exi_request_func(const char* cmd) {
 request_t* req = malloc(sizeof(request_t));
 req->size = sizeof(request_t);
 strncpy(req->cmdname, cmd, 3);
 req->cmdname[3] = '\0';
 req->clientpid = getpid();
 return req;
}

canonical_original_code:
struct request_t *exi_request_func(char *cmd) {
 struct request_t *req = malloc(sizeof(request_t));
 req->size = sizeof(request_t);
 strncpy(req->cmdname, cmd, 3);
 req->cmdname[3] = '\0';
 req->clientpid = getpid();
 return req;
}


decompiled_code:
__int64 __fastcall time_answer_func(__int64 a1, char *a2, size_t a3)
{
struct tm *v4; // rdi
char *v5; // rax
__int64 result; // rax
time_t timer; // [rsp+8h] [rbp-20h] BYREF

timer = time(0LL);
if ( timer == -1 )
{
perror("time");
snprintf(a2, a3, "Erreur lors de la lecture de l'heure");
fprintf(stderr, "%s\n", a2);
result = 0xFFFFFFFFLL;
}
else
{
v4 = localtime(&timer);
if ( v4 )
{
v5 = asctime(v4);
snprintf(a2, a3, "%s", v5);
result = 0LL;
}
else
{
perror("localtime");
snprintf(a2, a3, "Erreur lors de la lecture de l'heure");
fprintf(stderr, "%s\n", a2);
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, char *a2, size_t a3)
{
struct tm *v4; // rdi
char *v5; // rax
__int64 result; // rax
time_t timer; // [rsp+8h] [rbp-20h] BYREF

timer = time(0LL);
if ( timer == -1 )
{
perror("time");
snprintf(a2, a3, "Erreur lors de la lecture de l'heure");
fprintf(stderr, "%s\n", a2);
result = 0xFFFFFFFFLL;
}
else
{
v4 = localtime(&timer);
if ( v4 )
{
v5 = asctime(v4);
snprintf(a2, a3, "%s", v5);
result = 0LL;
}
else
{
perror("localtime");
snprintf(a2, a3, "Erreur lors de la lecture de l'heure");
fprintf(stderr, "%s\n", a2);
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
int time_answer_func(request_t* req, char* buffer, size_t buffsize) {
 time_t heure;
 struct tm* h;
 heure = time(((void *)0));
 if (heure == -1) {
  perror("time");
  snprintf(buffer, buffsize
    , "Erreur lors de la lecture de l'heure");
  fprintf(stderr, "%s\n", buffer);
  return -1;
 }
 h = localtime(&heure);
 if (h != ((void *)0)) {
  snprintf(buffer, buffsize
    , "%s", asctime(h));
 } else {
  perror("localtime");
  snprintf(buffer, buffsize
    , "Erreur lors de la lecture de l'heure");
  fprintf(stderr, "%s\n", buffer);
  return -1;
 }
 return 0;
}

canonical_original_code:
int time_answer_func(struct request_t *req, char *buffer, unsigned long buffsize) {
 long heure;
 struct tm *h;
 heure = time(((void *)0));
 if (heure == -1) {
  perror("time");
  snprintf(buffer, buffsize
    , "Erreur lors de la lecture de l'heure");
  fprintf(stderr, "%s\n", buffer);
  return -1;
 }
 h = localtime(&heure);
 if (h != ((void *)0)) {
  snprintf(buffer, buffsize
    , "%s", asctime(h));
 } else {
  perror("localtime");
  snprintf(buffer, buffsize
    , "Erreur lors de la lecture de l'heure");
  fprintf(stderr, "%s\n", buffer);
  return -1;
 }
 return 0;
}

variable_types: heure long

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


decompiled_code:
__int64 getCommand()
{
return time_answer_cmd;
}

canonical_decompiled_code:
__int64 func7()
{
return time_answer_cmd;
}

canonical_original_code:
struct answer_cmd_t getCommand() {
 return time_answer_cmd;
}


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

result = 0LL;
if ( a1 > 0 )
{
fputs(a2, stderr);
result = 1LL;
}
return result;
}

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

result = 0LL;
if ( a1 > 0 )
{
fputs(a2, stderr);
result = 1LL;
}
return result;
}

original_code:
int check_error_noquit(int value, const char* str) {
    if (value > 0) {
        fprintf(stderr, "%s", str);
        return 1;
    }
    return 0;
}

canonical_original_code:
int check_error_noquit(int value, char *str) {
    if (value > 0) {
        fprintf(stderr, "%s", str);
        return 1;
    }
    return 0;
}

variable_types: value int

variable_types:
str
char *


decompiled_code:
int __fastcall check_error(int a1, const char *a2)
{
int result; // eax

if ( a1 > 0 )
{
fputs(a2, stderr);
result = raise(15);
}
return result;
}

canonical_decompiled_code:
int __fastcall func1(int a1, const char *a2)
{
int result; // eax

if ( a1 > 0 )
{
fputs(a2, stderr);
result = raise(15);
}
return result;
}

original_code:
void check_error(int value, const char* str) {
    if (value > 0) {
        fprintf(stderr, "%s", str);
        raise(15);
    }
}

canonical_original_code:
void check_error(int value, char *str) {
    if (value > 0) {
        fprintf(stderr, "%s", str);
        raise(15);
    }
}


decompiled_code:
int __fastcall check_error2(int a1, const char *a2)
{
int result; // eax

if ( a1 > 0 )
{
perror(a2);
result = raise(15);
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(int a1, const char *a2)
{
int result; // eax

if ( a1 > 0 )
{
perror(a2);
result = raise(15);
}
return result;
}

original_code:
void check_error2(int value, const char* str) {
    if (value > 0) {
        perror(str);
        raise(15);
    }
}

canonical_original_code:
void check_error2(int value, char *str) {
    if (value > 0) {
        perror(str);
        raise(15);
    }
}


decompiled_code:
void con_help()
{
;
}

original_code:
void con_help() {
}

canonical_original_code:
void con_help() {
}