obtenermutex

decompiled_code:
__int64 __fastcall obtenermutex(key_t a1)
{
unsigned int v1; // er12

v1 = semget(a1, 1, 896);
semctl(v1, 0, 16, 1LL);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func0(key_t a1)
{
unsigned int v1; // er12

v1 = semget(a1, 1, 896);
semctl(v1, 0, 16, 1LL);
return v1;
}

original_code:
int obtenermutex (key_t clave)
{
  int idsem;
  union semun ctlsem;
  idsem = semget (clave, 1, 01000 | 0600);
  ctlsem.val = 1;
  semctl(idsem, 0, 16 , ctlsem);
  return idsem;
}

canonical_original_code:
int obtenermutex(int clave)
{
  int idsem;
  union semun ctlsem;
  idsem = semget (clave, 1, 01000 | 0600);
  ctlsem.val = 1;
  semctl(idsem, 0, 16 , ctlsem);
  return idsem;
}

variable_types: clave int

variable_types: idsem int

variable_types: union semun { int val; struct semid_ds { struct ipc_perm { int __key; unsigned int uid; unsigned int gid; unsigned int cuid; unsigned int cgid; unsigned short mode; unsigned short __pad1; unsigned short __seq; unsigned short __pad2; unsigned long __glibc_reserved1; unsigned long __glibc_reserved2; } sem_perm; long sem_otime; unsigned long __glibc_reserved1; long sem_ctime; unsigned long __glibc_reserved2; unsigned long sem_nsems; unsigned long __glibc_reserved3; unsigned long __glibc_reserved4; } *buf; unsigned short *array; struct seminfo { int semmap; int semmni; int semmns; int semmnu; int semmsl; int semopm; int semume; int semusz; int semvmx; int semaem; } *__buf; }

user_defined_types: union semun { int val; struct semid_ds *buf; unsigned short *array; struct seminfo *__buf; }

user_defined_types: struct semid_ds { struct ipc_perm sem_perm; long sem_otime; unsigned long __glibc_reserved1; long sem_ctime; unsigned long __glibc_reserved2; unsigned long sem_nsems; unsigned long __glibc_reserved3; unsigned long __glibc_reserved4; }


obtenersemaforo

decompiled_code:
__int64 __fastcall obtenersemaforo(key_t a1, unsigned int a2)
{
unsigned int v2; // er12

v2 = semget(a1, 1, 896);
semctl(v2, 0, 16, a2);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(key_t a1, unsigned int a2)
{
unsigned int v2; // er12

v2 = semget(a1, 1, 896);
semctl(v2, 0, 16, a2);
return v2;
}

original_code:
int obtenersemaforo (key_t clave, int val)
{
 int idsem;
 union semun ctlsem;
 idsem = semget (clave, 1, 01000 | 0600);
 ctlsem.val = val;
 semctl (idsem, 0, 16, ctlsem);
 return idsem;
}

canonical_original_code:
int obtenersemaforo(int clave, int val)
{
 int idsem;
 union semun ctlsem;
 idsem = semget (clave, 1, 01000 | 0600);
 ctlsem.val = val;
 semctl (idsem, 0, 16, ctlsem);
 return idsem;
}

variable_types: val int

return_type: int

user_defined_types: struct seminfo { int semmap; int semmni; int semmns; int semmnu; int semmsl; int semopm; int semume; int semusz; int semvmx; int semaem; }

user_defined_types: struct ipc_perm { int __key; unsigned int uid; unsigned int gid; unsigned int cuid; unsigned int cgid; unsigned short mode; unsigned short __pad1; unsigned short __seq; unsigned short __pad2; unsigned long __glibc_reserved1; unsigned long __glibc_reserved2; }


pedirsem

decompiled_code:
int __fastcall pedirsem(int a1)
{
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

*(_DWORD *)&sops.sem_num = -65536;
sops.sem_flg = 0;
return semop(a1, &sops, 1uLL);
}

canonical_decompiled_code:
int __fastcall func2(int a1)
{
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

*(_DWORD *)&sops.sem_num = -65536;
sops.sem_flg = 0;
return semop(a1, &sops, 1uLL);
}

original_code:
void pedirsem (int id)
{
 struct sembuf opsem;
 opsem.sem_num= 0 ;
 opsem.sem_op = -1;
 opsem.sem_flg= 0;
 semop (id , &opsem , 1);
}

canonical_original_code:
void pedirsem(int id)
{
 struct sembuf opsem;
 opsem.sem_num= 0 ;
 opsem.sem_op = -1;
 opsem.sem_flg= 0;
 semop (id , &opsem , 1);
}

variable_types: id int

variable_types: struct sembuf { unsigned short sem_num; short sem_op; short sem_flg; }

return_type: void


devolversem

decompiled_code:
int __fastcall devolversem(int a1)
{
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

*(_DWORD *)&sops.sem_num = 0x10000;
sops.sem_flg = 0;
return semop(a1, &sops, 1uLL);
}

canonical_decompiled_code:
int __fastcall func3(int a1)
{
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

*(_DWORD *)&sops.sem_num = 0x10000;
sops.sem_flg = 0;
return semop(a1, &sops, 1uLL);
}

original_code:
void devolversem (int id)
{
 struct sembuf opsem;
 opsem.sem_num = 0;
 opsem.sem_op = 1;
 opsem.sem_flg = 0;
 semop (id, &opsem , 1 );
}

canonical_original_code:
void devolversem(int id)
{
 struct sembuf opsem;
 opsem.sem_num = 0;
 opsem.sem_op = 1;
 opsem.sem_flg = 0;
 semop (id, &opsem , 1 );
}

user_defined_types: struct sembuf { unsigned short sem_num; short sem_op; short sem_flg; }


eliminarsem

decompiled_code:
int __fastcall eliminarsem(int a1)
{
return semctl(a1, 0, 0);
}

canonical_decompiled_code:
int __fastcall func4(int a1)
{
return semctl(a1, 0, 0);
}

original_code:
void eliminarsem (int id)
{
 semctl(id, 0, 0);
}

canonical_original_code:
void eliminarsem(int id)
{
 semctl(id, 0, 0);
}


decompiled_code:
_BOOL8 __fastcall cola_vacia(_QWORD *a1)
{
return *a1 == 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(_QWORD *a1)
{
return *a1 == 0LL;
}

original_code:
int cola_vacia(t_lista *pl)
{
    return *pl==((void *)0);
}

canonical_original_code:
int cola_vacia(struct s_nodo **pl)
{
    return *pl==((void *)0);
}

variable_types: struct s_nodo { struct t_dato { int pid; } info; struct s_nodo *psig; } **

user_defined_types: struct s_nodo { struct t_dato info; struct s_nodo *psig; }


decompiled_code:
void __fastcall manejador_alarma(int a1, __int64 a2)
{
int v2[3]; // [rsp+0h] [rbp-Ch] BYREF

if ( a1 == 14 && getpid() == piddem )
{
v2[0] = *(_DWORD *)(a2 + 16);
if ( !(unsigned int)poner_en_cola(&cola, v2) )
exit(0);
}
}

canonical_decompiled_code:
void __fastcall func3(int a1, __int64 a2)
{
int v2[3]; // [rsp+0h] [rbp-Ch] BYREF

if ( a1 == 14 && getpid() == piddem )
{
v2[0] = *(_DWORD *)(a2 + 16);
if ( !(unsigned int)func2(&cola, v2) )
exit(0);
}
}

original_code:
void manejador_alarma(int sig, siginfo_t *info, void *ni)
{
  t_dato dato;
 if(sig==14)
 {
  if(getpid()==piddem)
  {
   dato.pid=info->_sifields._kill.si_pid;
   if(!poner_en_cola(&cola,&dato) )
   {exit(0);}
  }
 }
}

canonical_original_code:
void manejador_alarma(int sig, struct siginfo_t *info, void *ni)
{
  struct t_dato dato;
 if(sig==14)
 {
  if(getpid()==piddem)
  {
   dato.pid=info->_sifields._kill.si_pid;
   if(!poner_en_cola(&cola,&dato) )
   {exit(0);}
  }
 }
}

variable_types: sig int

variable_types: struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval { int sival_int; void *sival_ptr; } si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; } *

variable_types:
ni
void *

variable_types:
dato
struct t_dato { int pid; }

user_defined_types: struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; }


manejador

decompiled_code:
void __fastcall manejador(int a1)
{
unsigned int v1; // eax
int v2; // eax
__pid_t v3; // eax
int v4; // ebx
int v5; // ebx
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-Ch] BYREF

LODWORD(stat_loc.__uptr) = 0;
if ( a1 == 10 )
{
if ( getpid() == piddem )
{
if ( (unsigned int)sacar_de_cola((_QWORD **)&cola, &dato) )
kill(dato, 10);
}
else
{
++cantviajes;
v1 = getpid();
srand(v1);
v2 = rand();
sleep(v2 % 10 + 1);
v3 = getppid();
kill(v3, 14);
}
}
else if ( a1 == 15 )
{
if ( getpid() == piddem )
{
v4 = 6;
do
{
while ( !(unsigned int)sacar_de_cola((_QWORD **)&cola, &dato) )
{
if ( !--v4 )
goto LABEL_11;
}
kill(dato, 15);
wait((__WAIT_STATUS)&stat_loc);
--v4;
}
while ( v4 );
LABEL_11:
v5 = 6;
do
{
wait((__WAIT_STATUS)&stat_loc);
--v5;
}
while ( v5 );
}
else
{
printf("El remis numero %d viajo %d veces\n", (unsigned int)numerodehijo, (unsigned int)cantviajes);
}
exit(0);
}
}

canonical_decompiled_code:
void __fastcall func6(int a1)
{
unsigned int v1; // eax
int v2; // eax
__pid_t v3; // eax
int v4; // ebx
int v5; // ebx
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-Ch] BYREF

LODWORD(stat_loc.__uptr) = 0;
if ( a1 == 10 )
{
if ( getpid() == piddem )
{
if ( (unsigned int)func5((_QWORD **)&cola, &dato) )
kill(dato, 10);
}
else
{
++cantviajes;
v1 = getpid();
srand(v1);
v2 = rand();
sleep(v2 % 10 + 1);
v3 = getppid();
kill(v3, 14);
}
}
else if ( a1 == 15 )
{
if ( getpid() == piddem )
{
v4 = 6;
do
{
while ( !(unsigned int)func5((_QWORD **)&cola, &dato) )
{
if ( !--v4 )
goto LABEL_11;
}
kill(dato, 15);
wait((__WAIT_STATUS)&stat_loc);
--v4;
}
while ( v4 );
LABEL_11:
v5 = 6;
do
{
wait((__WAIT_STATUS)&stat_loc);
--v5;
}
while ( v5 );
}
else
{
printf("El remis numero %d viajo %d veces\n", (unsigned int)numerodehijo, (unsigned int)cantviajes);
}
exit(0);
}
}

original_code:
void manejador(int sig)
{
 int status=0,i;
 if(sig==10)
 {
   if(getpid()==piddem)
    {
 if(sacar_de_cola(&cola,&dato))
 {
   kill(dato.pid,10);
 }
    }
   else
    {
       cantviajes++;
       srand(getpid());
       sleep(rand()%10+1);
       kill(getppid(),14);
    }
 }
 if(sig==15)
 {
  if(getpid()==piddem)
  {
    for(i=0;i<6;i++)
    {
   if(sacar_de_cola(&cola,&dato))
    {
        kill(dato.pid,15);
                    wait(&status);
     }
    }
                  for(i=0;i<6;i++)
    {wait(&status);}
                  exit(0);
               }
  else
  {
    printf("El remis numero %d viajo %d veces\n",numerodehijo,cantviajes);
                  exit(0);
  }
 }
}

canonical_original_code:
void manejador(int sig)
{
 int status = 0; int i;
 if(sig==10)
 {
   if(getpid()==piddem)
    {
 if(sacar_de_cola(&cola,&dato))
 {
   kill(dato.pid,10);
 }
    }
   else
    {
       cantviajes++;
       srand(getpid());
       sleep(rand()%10+1);
       kill(getppid(),14);
    }
 }
 if(sig==15)
 {
  if(getpid()==piddem)
  {
    for(i=0;i<6;i++)
    {
   if(sacar_de_cola(&cola,&dato))
    {
        kill(dato.pid,15);
                    wait(&status);
     }
    }
                  for(i=0;i<6;i++)
    {wait(&status);}
                  exit(0);
               }
  else
  {
    printf("El remis numero %d viajo %d veces\n",numerodehijo,cantviajes);
                  exit(0);
  }
 }
}

variable_types: status int

variable_types: i int


original_code:
int poner_en_cola(t_lista *pl, const t_dato *d)
{
    t_nodo* pn=(t_nodo*)malloc(sizeof(t_nodo));
    if(!pn)
    return 0;
    pn->info=*d;
    if(!*pl)
    {
        pn->psig=pn;
        *pl=pn;
        return 1;
    }
    pn->psig=(*pl)->psig;
    (*pl)->psig=pn;
    *pl=pn;
    return 1;
}

canonical_original_code:
int poner_en_cola(struct s_nodo **pl, struct t_dato *d)
{
    struct s_nodo *pn = (t_nodo*)malloc(sizeof(t_nodo));
    if(!pn)
    return 0;
    pn->info=*d;
    if(!*pl)
    {
        pn->psig=pn;
        *pl=pn;
        return 1;
    }
    pn->psig=(*pl)->psig;
    (*pl)->psig=pn;
    *pl=pn;
    return 1;
}

variable_types:
d
struct t_dato *

variable_types: struct s_nodo { struct t_dato { int pid; } info; struct s_nodo *psig; } *


decompiled_code:
__int64 __fastcall frente_de_cola(__int64 a1, _DWORD *a2)
{
if ( !*(_QWORD *)a1 )
return 3LL;
*a2 = **(_DWORD **)(*(_QWORD *)a1 + 8LL);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, _DWORD *a2)
{
if ( !*(_QWORD *)a1 )
return 3LL;
*a2 = **(_DWORD **)(*(_QWORD *)a1 + 8LL);
return 1LL;
}

original_code:
int frente_de_cola(const t_lista * pl, t_dato *d)
{
    if(!*pl)
    return 3;
    *d=(*pl)->psig->info;
    return 1;
}

canonical_original_code:
int frente_de_cola(struct s_nodo **pl, struct t_dato *d)
{
    if(!*pl)
    return 3;
    *d=(*pl)->psig->info;
    return 1;
}


decompiled_code:
__int64 __fastcall sacar_de_cola(_QWORD **a1, _DWORD *a2)
{
_QWORD *v3; // rdi
_QWORD *v4; // r8

v3 = *a1;
if ( !v3 )
return 3LL;
v4 = (_QWORD *)v3[1];
if ( v3 == v4 )
{
*a2 = *(_DWORD *)v3;
*a1 = 0LL;
free(v3);
}
else
{
v3[1] = v4[1];
*a2 = *(_DWORD *)v4;
free(v4);
}
return 1LL;
}

original_code:
int sacar_de_cola (t_lista *pl, t_dato *d)
{t_nodo *aux;
    if(!*pl)
    return 3;
    if(*pl != (*pl)->psig)
    {
    aux=(*pl)->psig;
    (*pl)->psig=aux->psig;
    *d=aux->info;
     free(aux);
    return 1;
    }
    aux=*pl;
    *d=aux->info;
    *pl=((void *)0);
    free(aux);
    return 1;
}

canonical_original_code:
int sacar_de_cola(struct s_nodo **pl, struct t_dato *d)
{struct s_nodo *aux;
    if(!*pl)
    return 3;
    if(*pl != (*pl)->psig)
    {
    aux=(*pl)->psig;
    (*pl)->psig=aux->psig;
    *d=aux->info;
     free(aux);
    return 1;
    }
    aux=*pl;
    *d=aux->info;
    *pl=((void *)0);
    free(aux);
    return 1;
}


original_code:
int vaciar_cola (t_lista*pl)
{t_nodo* aux;
    if(!*pl)
    return 3;
    while(*pl!=(*pl)->psig)
    {
        aux=(*pl)->psig;
        (*pl)->psig=aux->psig;
        free(aux);
    }
    *pl=((void *)0);
    return 1;
}

canonical_original_code:
int vaciar_cola(struct s_nodo **pl)
{struct s_nodo *aux;
    if(!*pl)
    return 3;
    while(*pl!=(*pl)->psig)
    {
        aux=(*pl)->psig;
        (*pl)->psig=aux->psig;
        free(aux);
    }
    *pl=((void *)0);
    return 1;
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__pid_t v3; // eax
unsigned int v4; // eax
int v6; // ebx
__pid_t v7; // eax
struct sigaction v8; // [rsp+0h] [rbp-A8h] BYREF

v8.sa_handler = (__sighandler_t)manejador_alarma;
v8.sa_flags = 4;
v3 = fork();
piddem = v3;
if ( v3 == -1 )
{
puts("Error al crear el demonio");
exit(1);
}
if ( v3 > 0 )
LABEL_3:
exit(0);
piddem = getpid();
v4 = getpid();
printf("PID Demonio: %d", v4);
if ( getpid() == piddem )
{
crear_cola(&cola);
if ( setsid() >= 0 && chdir("/") >= 0 )
{
v6 = 0;
while ( 1 )
{
v7 = fork();
if ( v7 == -1 )
break;
if ( v7 <= 0 )
{
numerodehijo = v6 + 1;
signal(10, manejador);
signal(15, manejador);
while ( 1 )
pause();
}
dato = v7;
if ( !(unsigned int)poner_en_cola(&cola, &dato) )
goto LABEL_3;
if ( ++v6 == 6 )
{
signal(15, manejador);
signal(10, manejador);
sigaction(14, &v8, 0LL);
if ( getpid() == piddem )
{
while ( 1 )
{
pause();
pause();
}
}
return 0;
}
}
puts("Error al crear el hijo");
}
exit(1);
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__pid_t v3; // eax
unsigned int v4; // eax
int v6; // ebx
__pid_t v7; // eax
struct sigaction v8; // [rsp+0h] [rbp-A8h] BYREF

v8.sa_handler = (__sighandler_t)manejador_alarma;
v8.sa_flags = 4;
v3 = fork();
piddem = v3;
if ( v3 == -1 )
{
puts("Error al crear el demonio");
exit(1);
}
if ( v3 > 0 )
LABEL_3:
exit(0);
piddem = getpid();
v4 = getpid();
printf("PID Demonio: %d", v4);
if ( getpid() == piddem )
{
func0(&cola);
if ( setsid() >= 0 && chdir("/") >= 0 )
{
v6 = 0;
while ( 1 )
{
v7 = fork();
if ( v7 == -1 )
break;
if ( v7 <= 0 )
{
numerodehijo = v6 + 1;
signal(10, manejador);
signal(15, manejador);
while ( 1 )
pause();
}
dato = v7;
if ( !(unsigned int)func2(&cola, &dato) )
goto LABEL_3;
if ( ++v6 == 6 )
{
signal(15, manejador);
signal(10, manejador);
sigaction(14, &v8, 0LL);
if ( getpid() == piddem )
{
while ( 1 )
{
pause();
pause();
}
}
return 0;
}
}
puts("Error al crear el hijo");
}
exit(1);
}
return 0;
}

original_code:
int main (int argc, char * argv[])
{
 pid_t sid, pidhijo;
 int status=0, i, fd;
 struct sigaction act;
 act.__sigaction_handler.sa_sigaction=manejador_alarma;
 act.sa_flags=4;
 piddem=fork();
 if(piddem==-1)
 {
  printf("Error al crear el demonio\n");
  exit(1);
     }
 if(piddem>0)
 {
  exit(0);
 }
 piddem=getpid();
 printf("PID Demonio: %d",getpid());
 if(getpid()==piddem)
 {
 crear_cola(&cola);
 sid=setsid();
 if(sid<0)
 {exit(1);}
 if(chdir("/")<0)
 {exit(1);}
 for(i=0;i<6;i++)
 {
 pidhijo=fork();
  if(pidhijo==-1)
  {
   printf("Error al crear el hijo\n");
   exit(1);
       }
  if(pidhijo>0)
  {
   dato.pid=pidhijo;
   if(!poner_en_cola(&cola,&dato))
   {
            exit(0);
   }
  }
    else
  {
   numerodehijo=i+1;
   signal(10,manejador);
   signal(15,manejador);
   while(1)
     {pause();}
  }
 }
 signal(15,manejador);
 signal(10,manejador);
 sigaction(14, &act, ((void *)0));
 if(getpid()==piddem)
 { while(1)
      pause();
 }
   }
}

canonical_original_code:
int main(int argc, char *argv[])
{
 int sid; int pidhijo;
 int status = 0; int i; int fd;
 struct sigaction act;
 act.__sigaction_handler.sa_sigaction=manejador_alarma;
 act.sa_flags=4;
 piddem=fork();
 if(piddem==-1)
 {
  printf("Error al crear el demonio\n");
  exit(1);
     }
 if(piddem>0)
 {
  exit(0);
 }
 piddem=getpid();
 printf("PID Demonio: %d",getpid());
 if(getpid()==piddem)
 {
 crear_cola(&cola);
 sid=setsid();
 if(sid<0)
 {exit(1);}
 if(chdir("/")<0)
 {exit(1);}
 for(i=0;i<6;i++)
 {
 pidhijo=fork();
  if(pidhijo==-1)
  {
   printf("Error al crear el hijo\n");
   exit(1);
       }
  if(pidhijo>0)
  {
   dato.pid=pidhijo;
   if(!poner_en_cola(&cola,&dato))
   {
            exit(0);
   }
  }
    else
  {
   numerodehijo=i+1;
   signal(10,manejador);
   signal(15,manejador);
   while(1)
     {pause();}
  }
 }
 signal(15,manejador);
 signal(10,manejador);
 sigaction(14, &act, ((void *)0));
 if(getpid()==piddem)
 { while(1)
      pause();
 }
   }
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: sid int

variable_types: pidhijo int

variable_types: fd int

variable_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval { int sival_int; void *sival_ptr; } si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; } *, void *); } __sigaction_handler; struct __sigset_t { unsigned long __val[-1]; } sa_mask; int sa_flags; void (*sa_restorer)(); }

user_defined_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t *, void *); } __sigaction_handler; struct __sigset_t sa_mask; int sa_flags; void (*sa_restorer)(); }


decompiled_code:
int inicializar_pantalla()
{
int v0; // eax

initscr();
keypad(stdscr, 1);
nonl();
cbreak();
start_color();
curs_set(0);
noecho();
if ( stdscr )
{
v0 = stdscr->_maxx + 1;
ALTO = stdscr->_maxy + 1;
}
else
{
ALTO = -1;
v0 = -1;
}
ANCHO = v0;
init_pair(11, 7, 6);
init_pair(10, 7, 3);
init_pair(0, 7, 0);
init_pair(5, 0, 7);
init_pair(12, 0, 7);
init_pair(1, 7, 4);
init_pair(2, 7, 2);
init_pair(3, 7, 5);
init_pair(4, 7, 1);
init_pair(6, 4, 7);
init_pair(7, 2, 7);
init_pair(8, 5, 7);
return init_pair(9, 1, 7);
}

canonical_decompiled_code:
int func0()
{
int v0; // eax

initscr();
keypad(stdscr, 1);
nonl();
cbreak();
start_color();
curs_set(0);
noecho();
if ( stdscr )
{
v0 = stdscr->_maxx + 1;
ALTO = stdscr->_maxy + 1;
}
else
{
ALTO = -1;
v0 = -1;
}
ANCHO = v0;
init_pair(11, 7, 6);
init_pair(10, 7, 3);
init_pair(0, 7, 0);
init_pair(5, 0, 7);
init_pair(12, 0, 7);
init_pair(1, 7, 4);
init_pair(2, 7, 2);
init_pair(3, 7, 5);
init_pair(4, 7, 1);
init_pair(6, 4, 7);
init_pair(7, 2, 7);
init_pair(8, 5, 7);
return init_pair(9, 1, 7);
}

original_code:
void inicializar_pantalla(void)
{
 initscr();
 keypad(stdscr,1);
 nonl();
 cbreak();
 start_color();
 curs_set(0);
 noecho();
 (ALTO = ((0 != (const void *)((stdscr))) ? ((stdscr)->_maxy + 1) : (-1)), ANCHO = ((0 != (const void *)((stdscr))) ? ((stdscr)->_maxx + 1) : (-1)));
 init_pair(11,7,6);
 init_pair(10,7,3);
 init_pair(0,7,0);
 init_pair(5,0,7);
 init_pair(12,0,7);
 init_pair(1,7,4);
 init_pair(2,7,2);
 init_pair(3,7,5);
 init_pair(4,7,1);
 init_pair(6,4,7);
 init_pair(7,2,7);
 init_pair(8,5,7);
 init_pair(9,1,7);
}

canonical_original_code:
void inicializar_pantalla()
{
 initscr();
 keypad(stdscr,1);
 nonl();
 cbreak();
 start_color();
 curs_set(0);
 noecho();
 (ALTO = ((0 != (void *)((stdscr))) ? ((stdscr)->_maxy + 1) : (-1)), ANCHO = ((0 != (void *)((stdscr))) ? ((stdscr)->_maxx + 1) : (-1)));
 init_pair(11,7,6);
 init_pair(10,7,3);
 init_pair(0,7,0);
 init_pair(5,0,7);
 init_pair(12,0,7);
 init_pair(1,7,4);
 init_pair(2,7,2);
 init_pair(3,7,5);
 init_pair(4,7,1);
 init_pair(6,4,7);
 init_pair(7,2,7);
 init_pair(8,5,7);
 init_pair(9,1,7);
}


presentacion

decompiled_code:
int presentacion()
{
int v0; // er13
int v1; // ebp
int v2; // ebx
int v3; // er12
int v4; // er14
int v5; // er15
int v6; // er12
int v7; // er15
int i; // ebp
int v9; // ebp
int v10; // er13
int j; // ebx
int v12; // ebx
int k; // er12
int v14; // eax
int v15; // er12
int v16; // er14
int v17; // ebp
int v18; // ebp
int v19; // er12
int v20; // er14
int v21; // ebx
int v22; // er13
int v23; // er15
int v25; // [rsp+0h] [rbp-88h]
int v26; // [rsp+0h] [rbp-88h]
int v27; // [rsp+4h] [rbp-84h]
int v28; // [rsp+4h] [rbp-84h]
int v29; // [rsp+8h] [rbp-80h]
int v30; // [rsp+8h] [rbp-80h]
int v31; // [rsp+Ch] [rbp-7Ch]
int v32; // [rsp+10h] [rbp-78h]
int v33; // [rsp+10h] [rbp-78h]
int v34; // [rsp+10h] [rbp-78h]
int v35; // [rsp+10h] [rbp-78h]
int v36; // [rsp+14h] [rbp-74h]
int v37; // [rsp+18h] [rbp-70h]
int v38; // [rsp+1Ch] [rbp-6Ch]
int v39; // [rsp+20h] [rbp-68h]
int v40; // [rsp+24h] [rbp-64h]
int v41; // [rsp+28h] [rbp-60h]
int v42; // [rsp+2Ch] [rbp-5Ch]
int v43; // [rsp+30h] [rbp-58h]
int v44; // [rsp+34h] [rbp-54h]
int v45; // [rsp+38h] [rbp-50h]
int v46; // [rsp+3Ch] [rbp-4Ch]
int v47; // [rsp+40h] [rbp-48h]
int v48; // [rsp+44h] [rbp-44h]
int v49; // [rsp+48h] [rbp-40h]
int v50; // [rsp+4Ch] [rbp-3Ch]

v25 = (ANCHO - 72) / 2;
v0 = v25 + 2;
v27 = ALTO / 2;
v29 = ALTO / 2 - 2;
v1 = ALTO / 2 - 4;
v2 = ALTO / 2 - 1;
wattr_on(stdscr, 0x100uLL, 0LL);
do
{
if ( wmove(stdscr, v1, v0) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v2, v0) != -1 )
waddch(stdscr, 0x20uLL);
++v0;
}
while ( v0 <= v25 + 5 );
v3 = v25 + 12;
do
{
if ( wmove(stdscr, v1, v3) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v2, v3) != -1 )
waddch(stdscr, 0x20uLL);
++v3;
}
while ( v3 <= v25 + 15 );
v4 = v25 + 32;
do
{
if ( wmove(stdscr, v1, v4) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v2, v4) != -1 )
waddch(stdscr, 0x20uLL);
++v4;
}
while ( v4 <= v25 + 35 );
v5 = v25 + 52;
v6 = v27 + 1;
do
{
if ( wmove(stdscr, v1, v5) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v6, v5) != -1 )
waddch(stdscr, 0x20uLL);
++v5;
}
while ( v5 <= v25 + 55 );
v7 = v25 + 66;
do
{
if ( wmove(stdscr, v1, v7) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v6, v7) != -1 )
waddch(stdscr, 0x20uLL);
++v7;
}
while ( v7 <= v25 + 69 );
v32 = v1;
for ( i = v27 - 3; ; ++i )
{
if ( v2 != i )
{
if ( wmove(stdscr, i, v25 + 17) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, i, v25 + 16) != -1 )
waddch(stdscr, 0x20uLL);
}
if ( v27 < i )
break;
}
v9 = v32;
v10 = v29;
do
{
if ( wmove(stdscr, v10, v25 + 23) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v10, v25 + 22) != -1 )
waddch(stdscr, 0x20uLL);
++v10;
}
while ( v27 != v10 );
v33 = v2;
for ( j = v27 - 3; ; ++j )
{
if ( wmove(stdscr, j, v25 + 25) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, j, v25 + 24) != -1 )
waddch(stdscr, 0x20uLL);
if ( v27 == j )
break;
}
v12 = v33;
v34 = v9;
for ( k = v9; ; ++k )
{
if ( v29 != k && v12 != k )
{
if ( wmove(stdscr, k, v25 + 27) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, k, v25 + 26) != -1 )
waddch(stdscr, 0x20uLL);
}
if ( v27 + 2 == k + 1 )
break;
}
v14 = k;
v15 = v27 - 3;
v16 = v14;
if ( wmove(stdscr, v27, v25 + 15) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v27, v25 + 14) != -1 )
waddch(stdscr, 0x20uLL);
v17 = v27 - 3;
do
{
if ( wmove(stdscr, v17, v25 + 43) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v17, v25 + 42) != -1 )
waddch(stdscr, 0x20uLL);
++v17;
}
while ( v12 != v17 );
v18 = v34;
while ( 1 )
{
if ( wmove(stdscr, v12, v25 + 45) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v12, v25 + 44) != -1 )
waddch(stdscr, 0x20uLL);
if ( v27 == v12 )
break;
++v12;
}
while ( 1 )
{
if ( wmove(stdscr, v15, v25 + 71) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v15, v25 + 70) != -1 )
waddch(stdscr, 0x20uLL);
if ( v27 == v15 )
break;
++v15;
}
v50 = v16;
v19 = v25 + 1;
v20 = v25;
v43 = v25 + 6;
v21 = v25 + 7;
v44 = v25 + 11;
v22 = v25 + 10;
v49 = v25 + 21;
v23 = v25 + 20;
v42 = v25 + 30;
v36 = v25 + 31;
v41 = v25 + 36;
v35 = v25 + 37;
v48 = v25 + 40;
v47 = v25 + 41;
v40 = v25 + 46;
v31 = v25 + 47;
v39 = v25 + 50;
v30 = v25 + 51;
v38 = v25 + 56;
v28 = v25 + 57;
v45 = v25 + 60;
v46 = v25 + 61;
v37 = v25 + 64;
v26 = v25 + 65;
while ( 1 )
{
if ( wmove(stdscr, v18, v20) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v19) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v43) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v21) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v22) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v44) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v23) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v49) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v42) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v36) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v41) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v35) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v48) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v47) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v40) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v31) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v39) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v30) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v38) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v28) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v45) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v46) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v37) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v26) != -1 )
waddch(stdscr, 0x20uLL);
if ( v50 == v18 )
break;
++v18;
}
wattr_off(stdscr, 0x100uLL, 0LL);
wattr_on(stdscr, 0x200000uLL, 0LL);
wattr_on(stdscr, 0x80000uLL, 0LL);
mvprintw(ALTO / 2 + 7, (unsigned __int64)(ANCHO - 10LL) >> 1, "Cargando..");
wrefresh(stdscr);
return wclear(stdscr);
}

canonical_decompiled_code:
int func1()
{
int v0; // er13
int v1; // ebp
int v2; // ebx
int v3; // er12
int v4; // er14
int v5; // er15
int v6; // er12
int v7; // er15
int i; // ebp
int v9; // ebp
int v10; // er13
int j; // ebx
int v12; // ebx
int k; // er12
int v14; // eax
int v15; // er12
int v16; // er14
int v17; // ebp
int v18; // ebp
int v19; // er12
int v20; // er14
int v21; // ebx
int v22; // er13
int v23; // er15
int v25; // [rsp+0h] [rbp-88h]
int v26; // [rsp+0h] [rbp-88h]
int v27; // [rsp+4h] [rbp-84h]
int v28; // [rsp+4h] [rbp-84h]
int v29; // [rsp+8h] [rbp-80h]
int v30; // [rsp+8h] [rbp-80h]
int v31; // [rsp+Ch] [rbp-7Ch]
int v32; // [rsp+10h] [rbp-78h]
int v33; // [rsp+10h] [rbp-78h]
int v34; // [rsp+10h] [rbp-78h]
int v35; // [rsp+10h] [rbp-78h]
int v36; // [rsp+14h] [rbp-74h]
int v37; // [rsp+18h] [rbp-70h]
int v38; // [rsp+1Ch] [rbp-6Ch]
int v39; // [rsp+20h] [rbp-68h]
int v40; // [rsp+24h] [rbp-64h]
int v41; // [rsp+28h] [rbp-60h]
int v42; // [rsp+2Ch] [rbp-5Ch]
int v43; // [rsp+30h] [rbp-58h]
int v44; // [rsp+34h] [rbp-54h]
int v45; // [rsp+38h] [rbp-50h]
int v46; // [rsp+3Ch] [rbp-4Ch]
int v47; // [rsp+40h] [rbp-48h]
int v48; // [rsp+44h] [rbp-44h]
int v49; // [rsp+48h] [rbp-40h]
int v50; // [rsp+4Ch] [rbp-3Ch]

v25 = (ANCHO - 72) / 2;
v0 = v25 + 2;
v27 = ALTO / 2;
v29 = ALTO / 2 - 2;
v1 = ALTO / 2 - 4;
v2 = ALTO / 2 - 1;
wattr_on(stdscr, 0x100uLL, 0LL);
do
{
if ( wmove(stdscr, v1, v0) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v2, v0) != -1 )
waddch(stdscr, 0x20uLL);
++v0;
}
while ( v0 <= v25 + 5 );
v3 = v25 + 12;
do
{
if ( wmove(stdscr, v1, v3) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v2, v3) != -1 )
waddch(stdscr, 0x20uLL);
++v3;
}
while ( v3 <= v25 + 15 );
v4 = v25 + 32;
do
{
if ( wmove(stdscr, v1, v4) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v2, v4) != -1 )
waddch(stdscr, 0x20uLL);
++v4;
}
while ( v4 <= v25 + 35 );
v5 = v25 + 52;
v6 = v27 + 1;
do
{
if ( wmove(stdscr, v1, v5) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v6, v5) != -1 )
waddch(stdscr, 0x20uLL);
++v5;
}
while ( v5 <= v25 + 55 );
v7 = v25 + 66;
do
{
if ( wmove(stdscr, v1, v7) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v6, v7) != -1 )
waddch(stdscr, 0x20uLL);
++v7;
}
while ( v7 <= v25 + 69 );
v32 = v1;
for ( i = v27 - 3; ; ++i )
{
if ( v2 != i )
{
if ( wmove(stdscr, i, v25 + 17) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, i, v25 + 16) != -1 )
waddch(stdscr, 0x20uLL);
}
if ( v27 < i )
break;
}
v9 = v32;
v10 = v29;
do
{
if ( wmove(stdscr, v10, v25 + 23) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v10, v25 + 22) != -1 )
waddch(stdscr, 0x20uLL);
++v10;
}
while ( v27 != v10 );
v33 = v2;
for ( j = v27 - 3; ; ++j )
{
if ( wmove(stdscr, j, v25 + 25) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, j, v25 + 24) != -1 )
waddch(stdscr, 0x20uLL);
if ( v27 == j )
break;
}
v12 = v33;
v34 = v9;
for ( k = v9; ; ++k )
{
if ( v29 != k && v12 != k )
{
if ( wmove(stdscr, k, v25 + 27) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, k, v25 + 26) != -1 )
waddch(stdscr, 0x20uLL);
}
if ( v27 + 2 == k + 1 )
break;
}
v14 = k;
v15 = v27 - 3;
v16 = v14;
if ( wmove(stdscr, v27, v25 + 15) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v27, v25 + 14) != -1 )
waddch(stdscr, 0x20uLL);
v17 = v27 - 3;
do
{
if ( wmove(stdscr, v17, v25 + 43) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v17, v25 + 42) != -1 )
waddch(stdscr, 0x20uLL);
++v17;
}
while ( v12 != v17 );
v18 = v34;
while ( 1 )
{
if ( wmove(stdscr, v12, v25 + 45) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v12, v25 + 44) != -1 )
waddch(stdscr, 0x20uLL);
if ( v27 == v12 )
break;
++v12;
}
while ( 1 )
{
if ( wmove(stdscr, v15, v25 + 71) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v15, v25 + 70) != -1 )
waddch(stdscr, 0x20uLL);
if ( v27 == v15 )
break;
++v15;
}
v50 = v16;
v19 = v25 + 1;
v20 = v25;
v43 = v25 + 6;
v21 = v25 + 7;
v44 = v25 + 11;
v22 = v25 + 10;
v49 = v25 + 21;
v23 = v25 + 20;
v42 = v25 + 30;
v36 = v25 + 31;
v41 = v25 + 36;
v35 = v25 + 37;
v48 = v25 + 40;
v47 = v25 + 41;
v40 = v25 + 46;
v31 = v25 + 47;
v39 = v25 + 50;
v30 = v25 + 51;
v38 = v25 + 56;
v28 = v25 + 57;
v45 = v25 + 60;
v46 = v25 + 61;
v37 = v25 + 64;
v26 = v25 + 65;
while ( 1 )
{
if ( wmove(stdscr, v18, v20) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v19) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v43) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v21) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v22) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v44) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v23) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v49) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v42) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v36) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v41) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v35) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v48) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v47) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v40) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v31) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v39) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v30) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v38) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v28) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v45) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v46) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v37) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v18, v26) != -1 )
waddch(stdscr, 0x20uLL);
if ( v50 == v18 )
break;
++v18;
}
wattr_off(stdscr, 0x100uLL, 0LL);
wattr_on(stdscr, 0x200000uLL, 0LL);
wattr_on(stdscr, 0x80000uLL, 0LL);
mvprintw(ALTO / 2 + 7, (unsigned __int64)(ANCHO - 10LL) >> 1, "Cargando..");
wrefresh(stdscr);
return wclear(stdscr);
}

variable_types: x int

variable_types: y int


decompiled_code:
int __fastcall pintar_zona(int a1)
{
int result; // eax
int v2; // esi
int v3; // esi

if ( a1 == 20 )
{
wattr_on(stdscr, 0x100uLL, 0LL);
v3 = ANCHO - 8;
if ( ANCHO - 8 < 0 )
v3 = ANCHO - 5;
mvprintw(ALTO - 6, (v3 >> 2) - 1, "PLAYER 1");
wattr_off(stdscr, 0x100uLL, 0LL);
result = wrefresh(stdscr);
}
else if ( a1 == 21 )
{
wattr_on(stdscr, 0x200uLL, 0LL);
v2 = 3 * ANCHO - 8;
if ( v2 < 0 )
v2 = 3 * ANCHO - 5;
mvprintw(ALTO - 6, (v2 >> 2) - 3, "PLAYER 2");
wattr_off(stdscr, 0x200uLL, 0LL);
result = wrefresh(stdscr);
}
else if ( a1 == 22 )
{
wattr_on(stdscr, 0x300uLL, 0LL);
mvprintw(ALTO / 2 - 7, 0, "P");
mvprintw(ALTO / 2 - 6, 0, "L");
mvprintw(ALTO / 2 - 5, 0, "A");
mvprintw(ALTO / 2 - 4, 0, "Y");
mvprintw(ALTO / 2 - 3, 0, "E");
mvprintw(ALTO / 2 - 2, 0, "R");
mvprintw(ALTO / 2, 0, "3");
wattr_off(stdscr, 0x300uLL, 0LL);
result = wrefresh(stdscr);
}
else
{
if ( a1 == 23 )
{
wattr_on(stdscr, 0x400uLL, 0LL);
mvprintw(ALTO / 2 - 7, ANCHO - 2, "P");
mvprintw(ALTO / 2 - 6, ANCHO - 2, "L");
mvprintw(ALTO / 2 - 5, ANCHO - 2, "A");
mvprintw(ALTO / 2 - 4, ANCHO - 2, "Y");
mvprintw(ALTO / 2 - 3, ANCHO - 2, "E");
mvprintw(ALTO / 2 - 2, ANCHO - 2, "R");
mvprintw(ALTO / 2, ANCHO - 2, "4");
wattr_off(stdscr, 0x400uLL, 0LL);
}
result = wrefresh(stdscr);
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(int a1)
{
int result; // eax
int v2; // esi
int v3; // esi

if ( a1 == 20 )
{
wattr_on(stdscr, 0x100uLL, 0LL);
v3 = ANCHO - 8;
if ( ANCHO - 8 < 0 )
v3 = ANCHO - 5;
mvprintw(ALTO - 6, (v3 >> 2) - 1, "PLAYER 1");
wattr_off(stdscr, 0x100uLL, 0LL);
result = wrefresh(stdscr);
}
else if ( a1 == 21 )
{
wattr_on(stdscr, 0x200uLL, 0LL);
v2 = 3 * ANCHO - 8;
if ( v2 < 0 )
v2 = 3 * ANCHO - 5;
mvprintw(ALTO - 6, (v2 >> 2) - 3, "PLAYER 2");
wattr_off(stdscr, 0x200uLL, 0LL);
result = wrefresh(stdscr);
}
else if ( a1 == 22 )
{
wattr_on(stdscr, 0x300uLL, 0LL);
mvprintw(ALTO / 2 - 7, 0, "P");
mvprintw(ALTO / 2 - 6, 0, "L");
mvprintw(ALTO / 2 - 5, 0, "A");
mvprintw(ALTO / 2 - 4, 0, "Y");
mvprintw(ALTO / 2 - 3, 0, "E");
mvprintw(ALTO / 2 - 2, 0, "R");
mvprintw(ALTO / 2, 0, "3");
wattr_off(stdscr, 0x300uLL, 0LL);
result = wrefresh(stdscr);
}
else
{
if ( a1 == 23 )
{
wattr_on(stdscr, 0x400uLL, 0LL);
mvprintw(ALTO / 2 - 7, ANCHO - 2, "P");
mvprintw(ALTO / 2 - 6, ANCHO - 2, "L");
mvprintw(ALTO / 2 - 5, ANCHO - 2, "A");
mvprintw(ALTO / 2 - 4, ANCHO - 2, "Y");
mvprintw(ALTO / 2 - 3, ANCHO - 2, "E");
mvprintw(ALTO / 2 - 2, ANCHO - 2, "R");
mvprintw(ALTO / 2, ANCHO - 2, "4");
wattr_off(stdscr, 0x400uLL, 0LL);
}
result = wrefresh(stdscr);
}
return result;
}

variable_types:
pint
struct t_pintar { int valor; }


decompiled_code:
int __fastcall pintar_puntajes(int a1)
{
wattr_on(stdscr, 0x200000uLL, 0LL);
wattr_on(stdscr, 0x80000uLL, 0LL);
mvprintw(ALTO - 3, 2, "PUNTOS");
mvprintw(ALTO - 2, 2, "VIDAS");
switch ( a1 )
{
case '(':
wattr_on(stdscr, 0x100uLL, 0LL);
mvprintw(ALTO - 4, 12, "PLAYER 1");
wattr_off(stdscr, 0x100uLL, 0LL);
mvprintw(ALTO - 4, 22, "PLAYER 2");
goto LABEL_10;
case ')':
wattr_on(stdscr, 0x200uLL, 0LL);
mvprintw(ALTO - 4, 22, "PLAYER 2");
wattr_off(stdscr, 0x200uLL, 0LL);
mvprintw(ALTO - 4, 12, "PLAYER 1");
LABEL_10:
mvprintw(ALTO - 4, 32, "PLAYER 3");
goto LABEL_8;
case '*':
wattr_on(stdscr, 0x300uLL, 0LL);
mvprintw(ALTO - 4, 32, "PLAYER 3");
wattr_off(stdscr, 0x300uLL, 0LL);
mvprintw(ALTO - 4, 12, "PLAYER 1");
mvprintw(ALTO - 4, 22, "PLAYER 2");
LABEL_8:
mvprintw(ALTO - 4, 42, "PLAYER 4");
return wrefresh(stdscr);
case '+':
wattr_on(stdscr, 0x400uLL, 0LL);
mvprintw(ALTO - 4, 42, "PLAYER 4");
wattr_off(stdscr, 0x400uLL, 0LL);
mvprintw(ALTO - 4, 12, "PLAYER 1");
mvprintw(ALTO - 4, 22, "PLAYER 2");
mvprintw(ALTO - 4, 32, "PLAYER 3");
break;
}
return wrefresh(stdscr);
}

canonical_decompiled_code:
int __fastcall func3(int a1)
{
wattr_on(stdscr, 0x200000uLL, 0LL);
wattr_on(stdscr, 0x80000uLL, 0LL);
mvprintw(ALTO - 3, 2, "PUNTOS");
mvprintw(ALTO - 2, 2, "VIDAS");
switch ( a1 )
{
case '(':
wattr_on(stdscr, 0x100uLL, 0LL);
mvprintw(ALTO - 4, 12, "PLAYER 1");
wattr_off(stdscr, 0x100uLL, 0LL);
mvprintw(ALTO - 4, 22, "PLAYER 2");
goto LABEL_10;
case ')':
wattr_on(stdscr, 0x200uLL, 0LL);
mvprintw(ALTO - 4, 22, "PLAYER 2");
wattr_off(stdscr, 0x200uLL, 0LL);
mvprintw(ALTO - 4, 12, "PLAYER 1");
LABEL_10:
mvprintw(ALTO - 4, 32, "PLAYER 3");
goto LABEL_8;
case '*':
wattr_on(stdscr, 0x300uLL, 0LL);
mvprintw(ALTO - 4, 32, "PLAYER 3");
wattr_off(stdscr, 0x300uLL, 0LL);
mvprintw(ALTO - 4, 12, "PLAYER 1");
mvprintw(ALTO - 4, 22, "PLAYER 2");
LABEL_8:
mvprintw(ALTO - 4, 42, "PLAYER 4");
return wrefresh(stdscr);
case '+':
wattr_on(stdscr, 0x400uLL, 0LL);
mvprintw(ALTO - 4, 42, "PLAYER 4");
wattr_off(stdscr, 0x400uLL, 0LL);
mvprintw(ALTO - 4, 12, "PLAYER 1");
mvprintw(ALTO - 4, 22, "PLAYER 2");
mvprintw(ALTO - 4, 32, "PLAYER 3");
break;
}
return wrefresh(stdscr);
}


decompiled_code:
int __fastcall actualizar_puntajes(unsigned __int64 a1, unsigned int a2)
{
char s[6]; // [rsp+14h] [rbp-14h] BYREF
char v4[14]; // [rsp+1Ah] [rbp-Eh] BYREF

sprintf(s, "%d", HIDWORD(a1));
sprintf(v4, "%d", a2);
wattr_on(stdscr, 0LL, 0LL);
switch ( (int)a1 )
{
case 20:
case 30:
if ( wmove(stdscr, ALTO - 3, 12) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 13) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 14) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 15) != -1 )
waddch(stdscr, 0x20uLL);
mvprintw(ALTO - 3, 12, "%s", v4);
if ( wmove(stdscr, ALTO - 2, 12) != -1 )
waddch(stdscr, 0x20uLL);
mvprintw(ALTO - 2, 12, "%s", s);
break;
case 21:
case 31:
if ( wmove(stdscr, ALTO - 3, 22) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 23) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 24) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 25) != -1 )
waddch(stdscr, 0x20uLL);
mvprintw(ALTO - 3, 22, "%s", v4);
if ( wmove(stdscr, ALTO - 2, 22) != -1 )
waddch(stdscr, 0x20uLL);
mvprintw(ALTO - 2, 22, "%s", s);
break;
case 22:
case 32:
if ( wmove(stdscr, ALTO - 3, 32) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 33) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 34) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 35) != -1 )
waddch(stdscr, 0x20uLL);
mvprintw(ALTO - 3, 32, "%s", v4);
if ( wmove(stdscr, ALTO - 2, 32) != -1 )
waddch(stdscr, 0x20uLL);
mvprintw(ALTO - 2, 32, "%s", s);
break;
case 23:
case 33:
if ( wmove(stdscr, ALTO - 3, 42) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 43) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 44) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 45) != -1 )
waddch(stdscr, 0x20uLL);
mvprintw(ALTO - 3, 42, "%s", v4);
if ( wmove(stdscr, ALTO - 2, 42) != -1 )
waddch(stdscr, 0x20uLL);
mvprintw(ALTO - 2, 42, "%s", s);
break;
default:
return wattr_off(stdscr, 0LL, 0LL);
}
return wattr_off(stdscr, 0LL, 0LL);
}

canonical_decompiled_code:
int __fastcall func4(unsigned __int64 a1, unsigned int a2)
{
char s[6]; // [rsp+14h] [rbp-14h] BYREF
char v4[14]; // [rsp+1Ah] [rbp-Eh] BYREF

sprintf(s, "%d", HIDWORD(a1));
sprintf(v4, "%d", a2);
wattr_on(stdscr, 0LL, 0LL);
switch ( (int)a1 )
{
case 20:
case 30:
if ( wmove(stdscr, ALTO - 3, 12) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 13) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 14) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 15) != -1 )
waddch(stdscr, 0x20uLL);
mvprintw(ALTO - 3, 12, "%s", v4);
if ( wmove(stdscr, ALTO - 2, 12) != -1 )
waddch(stdscr, 0x20uLL);
mvprintw(ALTO - 2, 12, "%s", s);
break;
case 21:
case 31:
if ( wmove(stdscr, ALTO - 3, 22) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 23) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 24) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 25) != -1 )
waddch(stdscr, 0x20uLL);
mvprintw(ALTO - 3, 22, "%s", v4);
if ( wmove(stdscr, ALTO - 2, 22) != -1 )
waddch(stdscr, 0x20uLL);
mvprintw(ALTO - 2, 22, "%s", s);
break;
case 22:
case 32:
if ( wmove(stdscr, ALTO - 3, 32) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 33) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 34) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 35) != -1 )
waddch(stdscr, 0x20uLL);
mvprintw(ALTO - 3, 32, "%s", v4);
if ( wmove(stdscr, ALTO - 2, 32) != -1 )
waddch(stdscr, 0x20uLL);
mvprintw(ALTO - 2, 32, "%s", s);
break;
case 23:
case 33:
if ( wmove(stdscr, ALTO - 3, 42) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 43) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 44) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, ALTO - 3, 45) != -1 )
waddch(stdscr, 0x20uLL);
mvprintw(ALTO - 3, 42, "%s", v4);
if ( wmove(stdscr, ALTO - 2, 42) != -1 )
waddch(stdscr, 0x20uLL);
mvprintw(ALTO - 2, 42, "%s", s);
break;
default:
return wattr_off(stdscr, 0LL, 0LL);
}
return wattr_off(stdscr, 0LL, 0LL);
}

variable_types:
vidas
char [6]

variable_types:
puntos
char [6]


pintar

decompiled_code:
int __fastcall pintar(__int64 a1, int a2)
{
switch ( (int)a1 )
{
case -4:
case 4:
wattr_on(stdscr, 0x400uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
wattr_off(stdscr, 0x400uLL, 0LL);
break;
case -3:
case 3:
wattr_on(stdscr, 0x300uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
wattr_off(stdscr, 0x300uLL, 0LL);
break;
case -2:
case 2:
wattr_on(stdscr, 0x200uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
wattr_off(stdscr, 0x200uLL, 0LL);
break;
case -1:
case 1:
wattr_on(stdscr, 0x100uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
wattr_off(stdscr, 0x100uLL, 0LL);
break;
case 0:
wattr_on(stdscr, 0LL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
wattr_off(stdscr, 0LL, 0LL);
break;
case 5:
wattr_on(stdscr, 0x500uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
wattr_off(stdscr, 0x500uLL, 0LL);
break;
case 6:
wattr_on(stdscr, 0x600uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x6FuLL);
wattr_off(stdscr, 0x600uLL, 0LL);
break;
case 7:
wattr_on(stdscr, 0x700uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x6FuLL);
wattr_off(stdscr, 0x700uLL, 0LL);
break;
case 8:
wattr_on(stdscr, 0x800uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x6FuLL);
wattr_off(stdscr, 0x800uLL, 0LL);
break;
case 9:
wattr_on(stdscr, 0x900uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x6FuLL);
wattr_off(stdscr, 0x900uLL, 0LL);
break;
case 10:
wattr_on(stdscr, 0xA00uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
wattr_off(stdscr, 0xA00uLL, 0LL);
break;
case 11:
wattr_on(stdscr, 0xB00uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
wattr_off(stdscr, 0xB00uLL, 0LL);
break;
case 12:
wattr_on(stdscr, 0xC00uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x58uLL);
wattr_off(stdscr, 0xC00uLL, 0LL);
break;
default:
return wrefresh(stdscr);
}
return wrefresh(stdscr);
}

canonical_decompiled_code:
int __fastcall func5(__int64 a1, int a2)
{
switch ( (int)a1 )
{
case -4:
case 4:
wattr_on(stdscr, 0x400uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
wattr_off(stdscr, 0x400uLL, 0LL);
break;
case -3:
case 3:
wattr_on(stdscr, 0x300uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
wattr_off(stdscr, 0x300uLL, 0LL);
break;
case -2:
case 2:
wattr_on(stdscr, 0x200uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
wattr_off(stdscr, 0x200uLL, 0LL);
break;
case -1:
case 1:
wattr_on(stdscr, 0x100uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
wattr_off(stdscr, 0x100uLL, 0LL);
break;
case 0:
wattr_on(stdscr, 0LL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
wattr_off(stdscr, 0LL, 0LL);
break;
case 5:
wattr_on(stdscr, 0x500uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
wattr_off(stdscr, 0x500uLL, 0LL);
break;
case 6:
wattr_on(stdscr, 0x600uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x6FuLL);
wattr_off(stdscr, 0x600uLL, 0LL);
break;
case 7:
wattr_on(stdscr, 0x700uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x6FuLL);
wattr_off(stdscr, 0x700uLL, 0LL);
break;
case 8:
wattr_on(stdscr, 0x800uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x6FuLL);
wattr_off(stdscr, 0x800uLL, 0LL);
break;
case 9:
wattr_on(stdscr, 0x900uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x6FuLL);
wattr_off(stdscr, 0x900uLL, 0LL);
break;
case 10:
wattr_on(stdscr, 0xA00uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
wattr_off(stdscr, 0xA00uLL, 0LL);
break;
case 11:
wattr_on(stdscr, 0xB00uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
wattr_off(stdscr, 0xB00uLL, 0LL);
break;
case 12:
wattr_on(stdscr, 0xC00uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x58uLL);
wattr_off(stdscr, 0xC00uLL, 0LL);
break;
default:
return wrefresh(stdscr);
}
return wrefresh(stdscr);
}


esopcion

decompiled_code:
_BOOL8 __fastcall esopcion(_BYTE **a1)
{
return **a1 == 45;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(_BYTE **a1)
{
return **a1 == 45;
}

original_code:
int esopcion(char** cad)
{
 int i, modif = 0;
 if (*(*cad) == '-')
  modif=1;
 return modif;
}

canonical_original_code:
int esopcion(char **cad)
{
 int i; int modif = 0;
 if (*(*cad) == '-')
  modif=1;
 return modif;
}

variable_types:
cad
char **

variable_types: modif int


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
int v4; // esi
_BOOL4 v5; // eax
int v6; // er13
size_t v7; // r12
char **v8; // rcx
size_t v9; // rdx
__pid_t v10; // eax
int v11; // [rsp+0h] [rbp-58h]
int v12; // [rsp+0h] [rbp-58h]
int i; // [rsp+0h] [rbp-58h]
int v14; // [rsp+4h] [rbp-54h]
__pid_t v16; // [rsp+10h] [rbp-48h]
__WAIT_STATUS stat_loc; // [rsp+2Ch] [rbp-2Ch] BYREF

v11 = argc - 1;
LODWORD(stat_loc.__uptr) = 0;
v16 = getpid();
if ( getpid() != v16 )
goto LABEL_2;
if ( argc <= 1 )
{
printf("Error de invocacion. Uso: %s [comando a ejecutar]\n", *argv);
exit(1);
}
v3 = 0;
if ( v11 <= 0 )
{
v6 = argc;
v7 = argc + 2;
aux = (char **)malloc(v7 * 8);
v8 = aux;
}
else
{
do
{
++v3;
v4 = v11;
v5 = esopcion((_BYTE **)&argv[v11--]);
}
while ( !v5 && v4 > 1 );
v6 = argc - v3;
v7 = argc - v3 + 2;
aux = (char **)malloc(v7 * 8);
v8 = aux;
if ( argc - v3 <= 0 )
{
LABEL_11:
v12 = 0;
v14 = v3 - 1;
v8[v7 - 1] = 0LL;
while ( v14 > v12 )
{
if ( getpid() == v16 )
{
aux[argc - v3] = (char *)(&argv[v12 + 1])[argc - v3];
v10 = vfork();
if ( v10 == -1 )
{
puts("Error al crear hijo ");
}
else
{
if ( !v10 )
{
if ( execvp(*aux, aux) >= 0 )
exit(0);
puts("Error al ejecutar comando ");
exit(1);
}
wait((__WAIT_STATUS)&stat_loc);
}
}
++v12;
}
if ( v14 > 0 )
{
for ( i = 0; i < v14; ++i )
wait((__WAIT_STATUS)&stat_loc);
}
LABEL_2:
exit(0);
}
}
v9 = 8LL * v6;
if ( v6 <= 0 )
v9 = 8LL;
v8 = (char **)memcpy(v8, argv + 1, v9);
goto LABEL_11;
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
int v4; // esi
_BOOL4 v5; // eax
int v6; // er13
size_t v7; // r12
char **v8; // rcx
size_t v9; // rdx
__pid_t v10; // eax
int v11; // [rsp+0h] [rbp-58h]
int v12; // [rsp+0h] [rbp-58h]
int i; // [rsp+0h] [rbp-58h]
int v14; // [rsp+4h] [rbp-54h]
__pid_t v16; // [rsp+10h] [rbp-48h]
__WAIT_STATUS stat_loc; // [rsp+2Ch] [rbp-2Ch] BYREF

v11 = argc - 1;
LODWORD(stat_loc.__uptr) = 0;
v16 = getpid();
if ( getpid() != v16 )
goto LABEL_2;
if ( argc <= 1 )
{
printf("Error de invocacion. Uso: %s [comando a ejecutar]\n", *argv);
exit(1);
}
v3 = 0;
if ( v11 <= 0 )
{
v6 = argc;
v7 = argc + 2;
aux = (char **)malloc(v7 * 8);
v8 = aux;
}
else
{
do
{
++v3;
v4 = v11;
v5 = func0((_BYTE **)&argv[v11--]);
}
while ( !v5 && v4 > 1 );
v6 = argc - v3;
v7 = argc - v3 + 2;
aux = (char **)malloc(v7 * 8);
v8 = aux;
if ( argc - v3 <= 0 )
{
LABEL_11:
v12 = 0;
v14 = v3 - 1;
v8[v7 - 1] = 0LL;
while ( v14 > v12 )
{
if ( getpid() == v16 )
{
aux[argc - v3] = (char *)(&argv[v12 + 1])[argc - v3];
v10 = vfork();
if ( v10 == -1 )
{
puts("Error al crear hijo ");
}
else
{
if ( !v10 )
{
if ( execvp(*aux, aux) >= 0 )
exit(0);
puts("Error al ejecutar comando ");
exit(1);
}
wait((__WAIT_STATUS)&stat_loc);
}
}
++v12;
}
if ( v14 > 0 )
{
for ( i = 0; i < v14; ++i )
wait((__WAIT_STATUS)&stat_loc);
}
LABEL_2:
exit(0);
}
}
v9 = 8LL * v6;
if ( v6 <= 0 )
v9 = 8LL;
v8 = (char **)memcpy(v8, argv + 1, v9);
goto LABEL_11;
}

original_code:
int main (int argc, char *argv[])
{
 int i = argc - 1;
 int opcion = 0;
 int cantarch = 0;
 pid_t padre, hijopid;
 int status = 0;
 int tam = 0;
 int cantopc = 0;
 padre = getpid();
 if (getpid() == padre)
 {
  if (argc < 2)
  {
   printf("Error de invocacion. Uso: %s [comando a ejecutar]\n",argv[0]);
   exit(1);
  }
  while (opcion == 0 && i > 0)
  {
   opcion = esopcion(&argv[i]);
   i--;
   cantarch++;
  }
  cantopc = argc - cantarch - 1;
  tam = cantopc + 3;
  aux = (char **) malloc (tam * sizeof(char *));
  for (i = 0; i <= cantopc; i++)
   aux[i] = argv[i+1];
  aux[tam - 1] = ((void *)0);
  for (i = 0; i < cantarch - 1; i++)
  {
   cantopc = argc - cantarch - 1;
   if (getpid() == padre)
   {
    aux[cantopc + 1] = argv[cantopc + 2 + i];
    hijopid = vfork();
    switch (hijopid)
    {
     case -1: printf("Error al crear hijo \n");
        break;
     case 0: if(execvp(aux[0], &aux[0]) < 0)
        {
         printf("Error al ejecutar comando \n");
         _exit(1);
        }
        _exit(0);
     default: wait(&status);
    }
   }
  }
 }
 for(i = 0; i < cantarch - 1; i++)
  wait(&status);
 exit(0);
}

canonical_original_code:
int main(int argc, char *argv[])
{
 int i = argc - 1;
 int opcion = 0;
 int cantarch = 0;
 int padre; int hijopid;
 int status = 0;
 int tam = 0;
 int cantopc = 0;
 padre = getpid();
 if (getpid() == padre)
 {
  if (argc < 2)
  {
   printf("Error de invocacion. Uso: %s [comando a ejecutar]\n",argv[0]);
   exit(1);
  }
  while (opcion == 0 && i > 0)
  {
   opcion = esopcion(&argv[i]);
   i--;
   cantarch++;
  }
  cantopc = argc - cantarch - 1;
  tam = cantopc + 3;
  aux = (char **) malloc (tam * sizeof(char *));
  for (i = 0; i <= cantopc; i++)
   aux[i] = argv[i+1];
  aux[tam - 1] = ((void *)0);
  for (i = 0; i < cantarch - 1; i++)
  {
   cantopc = argc - cantarch - 1;
   if (getpid() == padre)
   {
    aux[cantopc + 1] = argv[cantopc + 2 + i];
    hijopid = vfork();
    switch (hijopid)
    {
     case -1: printf("Error al crear hijo \n");
        break;
     case 0: if(execvp(aux[0], &aux[0]) < 0)
        {
         printf("Error al ejecutar comando \n");
         _exit(1);
        }
        _exit(0);
     default: wait(&status);
    }
   }
  }
 }
 for(i = 0; i < cantarch - 1; i++)
  wait(&status);
 exit(0);
}

variable_types: opcion int

variable_types: cantarch int

variable_types: padre int

variable_types: hijopid int

variable_types: status int

variable_types: tam int

variable_types: cantopc int


obtenerSemaforo

decompiled_code:
__int64 __fastcall obtenerSemaforo(key_t a1, unsigned int a2)
{
unsigned int v2; // er12

v2 = semget(a1, 1, 896);
semctl(v2, 0, 16, a2);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(key_t a1, unsigned int a2)
{
unsigned int v2; // er12

v2 = semget(a1, 1, 896);
semctl(v2, 0, 16, a2);
return v2;
}

original_code:
int obtenerSemaforo(key_t clave, int valor)
{
 int IdSemaforo;
 union semun CtlSem;
 IdSemaforo = semget(clave, 1, 01000 | 0600);
 CtlSem.val = valor;
 semctl(IdSemaforo, 0, 16, CtlSem);
 return IdSemaforo;
}

canonical_original_code:
int obtenerSemaforo(int clave, int valor)
{
 int IdSemaforo;
 union semun CtlSem;
 IdSemaforo = semget(clave, 1, 01000 | 0600);
 CtlSem.val = valor;
 semctl(IdSemaforo, 0, 16, CtlSem);
 return IdSemaforo;
}

variable_types: clave int

variable_types: valor int

variable_types: IdSemaforo int

variable_types: union semun { int val; struct semid_ds { struct ipc_perm { int __key; unsigned int uid; unsigned int gid; unsigned int cuid; unsigned int cgid; unsigned short mode; unsigned short __pad1; unsigned short __seq; unsigned short __pad2; unsigned long __glibc_reserved1; unsigned long __glibc_reserved2; } sem_perm; long sem_otime; unsigned long __glibc_reserved1; long sem_ctime; unsigned long __glibc_reserved2; unsigned long sem_nsems; unsigned long __glibc_reserved3; unsigned long __glibc_reserved4; } *buf; unsigned short *array; struct seminfo { int semmap; int semmni; int semmns; int semmnu; int semmsl; int semopm; int semume; int semusz; int semvmx; int semaem; } *__buf; }


pedirSemaforo

decompiled_code:
int __fastcall pedirSemaforo(int a1)
{
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

*(_DWORD *)&sops.sem_num = -65536;
sops.sem_flg = 0;
return semop(a1, &sops, 1uLL);
}

canonical_decompiled_code:
int __fastcall func1(int a1)
{
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

*(_DWORD *)&sops.sem_num = -65536;
sops.sem_flg = 0;
return semop(a1, &sops, 1uLL);
}

original_code:
void pedirSemaforo(int IdSemaforo)
{
 struct sembuf OpSem;
 OpSem.sem_num = 0;
 OpSem.sem_op = -1;
 OpSem.sem_flg = 0;
 semop(IdSemaforo, &OpSem, 1);
}

variable_types: struct sembuf { unsigned short sem_num; short sem_op; short sem_flg; }


devolverSemaforo

decompiled_code:
int __fastcall devolverSemaforo(int a1)
{
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

*(_DWORD *)&sops.sem_num = 0x10000;
sops.sem_flg = 0;
return semop(a1, &sops, 1uLL);
}

canonical_decompiled_code:
int __fastcall func2(int a1)
{
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

*(_DWORD *)&sops.sem_num = 0x10000;
sops.sem_flg = 0;
return semop(a1, &sops, 1uLL);
}

original_code:
void devolverSemaforo(int IdSemaforo)
{
 struct sembuf OpSem;
 OpSem.sem_num = 0;
 OpSem.sem_op = 1;
 OpSem.sem_flg = 0;
 semop(IdSemaforo, &OpSem, 1);
}


eliminarSemaforo

decompiled_code:
int __fastcall eliminarSemaforo(int a1)
{
return semctl(a1, 0, 0);
}

canonical_decompiled_code:
int __fastcall func3(int a1)
{
return semctl(a1, 0, 0);
}

original_code:
void eliminarSemaforo(int IdSemaforo)
{
 semctl(IdSemaforo, 0, 0);
}


substr

decompiled_code:
char *__fastcall substr(const char *a1, int a2, int a3)
{
size_t v3; // r12
char *v4; // rax

if ( !a3 )
a3 = strlen(a1) + ~a2;
v3 = a3;
v4 = (char *)malloc(a3);
return strncpy(v4, &a1[a2], v3);
}

canonical_decompiled_code:
char *__fastcall func2(const char *a1, int a2, int a3)
{
size_t v3; // r12
char *v4; // rax

if ( !a3 )
a3 = strlen(a1) + ~a2;
v3 = a3;
v4 = (char *)malloc(a3);
return strncpy(v4, &a1[a2], v3);
}

original_code:
char * substr(char * cadena, int comienzo, int longitud)
{
 if(longitud == 0)
  longitud = strlen(cadena)-comienzo-1;
 char *nuevo = (char*)malloc(sizeof(char) * longitud);
 strncpy(nuevo, cadena + comienzo, longitud);
 return nuevo;
}

canonical_original_code:
char *substr(char *cadena, int comienzo, int longitud)
{
 if(longitud == 0)
  longitud = strlen(cadena)-comienzo-1;
 char *nuevo = (char*)malloc(sizeof(char) * longitud);
 strncpy(nuevo, cadena + comienzo, longitud);
 return nuevo;
}

variable_types:
cadena
char *

variable_types: comienzo int

variable_types: longitud int

variable_types:
nuevo
char *

return_type: char *


indexOf

decompiled_code:
__int64 __fastcall indexOf(__int64 a1, char a2)
{
__int64 v2; // rax
unsigned int v3; // er8

if ( !a1 )
return (unsigned int)-1;
v2 = 0LL;
do
v3 = v2++;
while ( *(_BYTE *)(a1 + v2 - 1) != a2 );
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, char a2)
{
__int64 v2; // rax
unsigned int v3; // er8

if ( !a1 )
return (unsigned int)-1;
v2 = 0LL;
do
v3 = v2++;
while ( *(_BYTE *)(a1 + v2 - 1) != a2 );
return v3;
}

original_code:
int indexOf(char * cadena, char caracter)
{
 int pos=0;
 while(cadena != ((void *)0))
 {
  if(*cadena == caracter)
   return pos;
  cadena++;
  pos++;
 }
 return -1;
}

canonical_original_code:
int indexOf(char *cadena, char caracter)
{
 int pos = 0;
 while(cadena != ((void *)0))
 {
  if(*cadena == caracter)
   return pos;
  cadena++;
  pos++;
 }
 return -1;
}

variable_types: caracter char

variable_types: pos int


decompiled_code:
__int64 __fastcall abrir_socket_escucha(__int16 a1)
{
unsigned int v1; // er12
socklen_t v2; // edx
int optval; // [rsp+Ch] [rbp-2Ch] BYREF
struct sockaddr v5[2]; // [rsp+10h] [rbp-28h] BYREF

optval = 1;
v1 = socket(2, 1, 0);
if ( setsockopt(v1, 1, 2, &optval, 4u) < 0 )
puts("ERROR AL SETEAR OPCIONES DE SOCKET ESCUCHA");
*(_QWORD *)&v5[0].sa_data[6] = 0LL;
v5[0].sa_family = 2;
*(_WORD *)v5[0].sa_data = _bswap_16(a1);
*(_DWORD *)&v5[0].sa_data[2] = _bswap_32_constprop_0(v1, v5);
bind(v1, v5, v2);
listen(v1, 4);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int16 a1)
{
unsigned int v1; // er12
socklen_t v2; // edx
int optval; // [rsp+Ch] [rbp-2Ch] BYREF
struct sockaddr v5[2]; // [rsp+10h] [rbp-28h] BYREF

optval = 1;
v1 = socket(2, 1, 0);
if ( setsockopt(v1, 1, 2, &optval, 4u) < 0 )
puts("ERROR AL SETEAR OPCIONES DE SOCKET ESCUCHA");
*(_QWORD *)&v5[0].sa_data[6] = 0LL;
v5[0].sa_family = 2;
*(_WORD *)v5[0].sa_data = func0(a1);
*(_DWORD *)&v5[0].sa_data[2] = func1(v1, v5);
bind(v1, v5, v2);
listen(v1, 4);
return v1;
}

original_code:
int abrir_socket_escucha(int puerto)
{
 int listen_socket,reuse=1;
 struct sockaddr_in listen_address;
 unsigned short int listen_port=0;
 unsigned long int listen_ip_address=0;
 listen_socket=socket(2,SOCK_STREAM,0);
 if(setsockopt(listen_socket,1,2,(char*)&reuse,sizeof(reuse))<0)
  printf("ERROR AL SETEAR OPCIONES DE SOCKET ESCUCHA\n");
 bzero(&listen_address,sizeof(listen_address));
 listen_address.sin_family=2;
 listen_port=htons(puerto);
 listen_address.sin_port=listen_port;
 listen_ip_address=htonl(((in_addr_t) 0x00000000));
 listen_address.sin_addr.s_addr=listen_ip_address;
 bind(listen_socket,(struct sockaddr*)&listen_address,sizeof(struct sockaddr));
 listen(listen_socket,4);
 return listen_socket;
}

canonical_original_code:
int abrir_socket_escucha(int puerto)
{
 int listen_socket; int reuse = 1;
 struct sockaddr_in listen_address;
 unsigned short listen_port = 0;
 unsigned long listen_ip_address = 0;
 listen_socket=socket(2,SOCK_STREAM,0);
 if(setsockopt(listen_socket,1,2,(char *)&reuse,sizeof(reuse))<0)
  printf("ERROR AL SETEAR OPCIONES DE SOCKET ESCUCHA\n");
 bzero(&listen_address,sizeof(listen_address));
 listen_address.sin_family=2;
 listen_port=htons(puerto);
 listen_address.sin_port=listen_port;
 listen_ip_address=htonl(((unsigned int) 0x00000000));
 listen_address.sin_addr.s_addr=listen_ip_address;
 bind(listen_socket,(struct sockaddr *)&listen_address,sizeof(struct sockaddr));
 listen(listen_socket,4);
 return listen_socket;
}

variable_types: puerto int

variable_types: reuse int

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

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

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


decompiled_code:
__int64 __fastcall conectar_al_server(__int16 a1, const char *a2)
{
unsigned int v2; // er12
struct sockaddr v4; // [rsp+0h] [rbp-28h] BYREF

v2 = socket(2, 1, 0);
v4 = 0LL;
v4.sa_family = 2;
*(_WORD *)v4.sa_data = _bswap_16(a1);
*(_DWORD *)&v4.sa_data[2] = inet_addr(a2);
if ( connect(v2, &v4, 0x10u) == -1 )
v2 = -1;
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int16 a1, const char *a2)
{
unsigned int v2; // er12
struct sockaddr v4; // [rsp+0h] [rbp-28h] BYREF

v2 = socket(2, 1, 0);
v4 = 0LL;
v4.sa_family = 2;
*(_WORD *)v4.sa_data = func0(a1);
*(_DWORD *)&v4.sa_data[2] = inet_addr(a2);
if ( connect(v2, &v4, 0x10u) == -1 )
v2 = -1;
return v2;
}

original_code:
int conectar_al_server(int puerto, char *IP_server)
{
 int caller_socket;
 struct sockaddr_in listen_address;
 unsigned short int listen_port=0;
 unsigned long int listen_ip_address=0;
 caller_socket=socket(2,SOCK_STREAM,0);
 bzero(&listen_address,sizeof(listen_address));
 listen_address.sin_family=2;
 listen_port=htons(puerto);
 listen_address.sin_port=listen_port;
 listen_ip_address=htonl(((in_addr_t) 0x00000000));
 listen_address.sin_addr.s_addr=inet_addr(IP_server);
 if((connect(caller_socket,(struct sockaddr*)&listen_address,sizeof(struct sockaddr)))==-1)
  return -1;
 return caller_socket;
}

canonical_original_code:
int conectar_al_server(int puerto, char *IP_server)
{
 int caller_socket;
 struct sockaddr_in listen_address;
 unsigned short listen_port = 0;
 unsigned long listen_ip_address = 0;
 caller_socket=socket(2,SOCK_STREAM,0);
 bzero(&listen_address,sizeof(listen_address));
 listen_address.sin_family=2;
 listen_port=htons(puerto);
 listen_address.sin_port=listen_port;
 listen_ip_address=htonl(((unsigned int) 0x00000000));
 listen_address.sin_addr.s_addr=inet_addr(IP_server);
 if((connect(caller_socket,(struct sockaddr *)&listen_address,sizeof(struct sockaddr)))==-1)
  return -1;
 return caller_socket;
}


decompiled_code:
int __fastcall aceptar_conexion(int a1)
{
return accept(a1, 0LL, 0LL);
}

canonical_decompiled_code:
int __fastcall func4(int a1)
{
return accept(a1, 0LL, 0LL);
}

original_code:
int aceptar_conexion(int listen_socket)
{
 int comm_socket=0;
 comm_socket=accept(listen_socket, 0, 0);
 return comm_socket;
}

canonical_original_code:
int aceptar_conexion(int listen_socket)
{
 int comm_socket = 0;
 comm_socket=accept(listen_socket, 0, 0);
 return comm_socket;
}


decompiled_code:
__int64 __fastcall capturar_senal(int a1, __int64 a2)
{
int v2; // eax
__int64 result; // rax

if ( a1 == 10 )
{
v2 = contador;
alarma[contador] = *(_DWORD *)(a2 + 16);
result = (unsigned int)(v2 + 1);
contador = result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, __int64 a2)
{
int v2; // eax
__int64 result; // rax

if ( a1 == 10 )
{
v2 = contador;
alarma[contador] = *(_DWORD *)(a2 + 16);
result = (unsigned int)(v2 + 1);
contador = result;
}
return result;
}

original_code:
void capturar_senal(int iNumSen, siginfo_t *info, void *ni) {
if(iNumSen==10)
{
 alarma[contador] =info->_sifields._kill.si_pid;
 contador++;
}
}

canonical_original_code:
void capturar_senal(int iNumSen, struct siginfo_t *info, void *ni) {
if(iNumSen==10)
{
 alarma[contador] =info->_sifields._kill.si_pid;
 contador++;
}
}

variable_types: iNumSen int

variable_types: struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval { int sival_int; void *sival_ptr; } si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; } *

variable_types:
ni
void *


CancelarAlarma

decompiled_code:
int __fastcall CancelarAlarma(__pid_t a1)
{
return kill(a1, 15);
}

canonical_decompiled_code:
int __fastcall func2(__pid_t a1)
{
return kill(a1, 15);
}

original_code:
void CancelarAlarma(pid_t pid)
{
 kill(pid,15);
}

canonical_original_code:
void CancelarAlarma(int pid)
{
 kill(pid,15);
}

variable_types: pid int


SetearActYConjSen

decompiled_code:
void __fastcall SetearActYConjSen(__int64 a1)
{
*(_QWORD *)a1 = handler;
*(_DWORD *)(a1 + 136) = 4;
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1)
{
*(_QWORD *)a1 = handler;
*(_DWORD *)(a1 + 136) = 4;
}

original_code:
void SetearActYConjSen(struct sigaction * act)
{
 act->__sigaction_handler.sa_sigaction=handler;
 act->sa_flags=4;
}

canonical_original_code:
void SetearActYConjSen(struct sigaction *act)
{
 act->__sigaction_handler.sa_sigaction=handler;
 act->sa_flags=4;
}

variable_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval { int sival_int; void *sival_ptr; } si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; } *, void *); } __sigaction_handler; struct __sigset_t { unsigned long __val[-1]; } sa_mask; int sa_flags; void (*sa_restorer)(); } *


NuevaAlarma

decompiled_code:
__pid_t __fastcall NuevaAlarma(unsigned int seconds, int a2, int a3)
{
__pid_t result; // eax
struct sigaction *v5; // rdx
__pid_t v6; // eax
unsigned int v7; // eax
unsigned int v8; // eax
struct sigaction v9; // [rsp+0h] [rbp-B8h] BYREF

result = getpid();
if ( result == a2 )
{
SetearActYConjSen((__int64)&v9);
sigaction(17, &v9, v5);
result = fork();
if ( !result )
{
sigaction(14, &v9, 0LL);
sigaction(15, &v9, 0LL);
v6 = getppid();
kill(v6, 10);
if ( a3 == 1 )
{
while ( 1 )
{
v7 = getpid();
printf("\n Comienza la alarma.%d \n", v7);
alarm(seconds);
pause();
}
}
v8 = getpid();
printf("Comienza la alarma: %d \n", v8);
alarm(seconds);
pause();
exit(0);
}
if ( result == -1 )
{
printf("\n Error al crear el proceso hijo.");
exit(1);
}
}
return result;
}

canonical_decompiled_code:
__pid_t __fastcall func4(unsigned int seconds, int a2, int a3)
{
__pid_t result; // eax
struct sigaction *v5; // rdx
__pid_t v6; // eax
unsigned int v7; // eax
unsigned int v8; // eax
struct sigaction v9; // [rsp+0h] [rbp-B8h] BYREF

result = getpid();
if ( result == a2 )
{
func3((__int64)&v9);
sigaction(17, &v9, v5);
result = fork();
if ( !result )
{
sigaction(14, &v9, 0LL);
sigaction(15, &v9, 0LL);
v6 = getppid();
kill(v6, 10);
if ( a3 == 1 )
{
while ( 1 )
{
v7 = getpid();
printf("\n Comienza la alarma.%d \n", v7);
alarm(seconds);
pause();
}
}
v8 = getpid();
printf("Comienza la alarma: %d \n", v8);
alarm(seconds);
pause();
exit(0);
}
if ( result == -1 )
{
printf("\n Error al crear el proceso hijo.");
exit(1);
}
}
return result;
}

original_code:
void NuevaAlarma(int seg,pid_t padre,int recurrente)
{
 pid_t pidHijo;
 int status=0;
 if(getpid()==padre)
 {
  struct sigaction act;
  SetearActYConjSen(&act);
  sigaction(17, &act, ((void *)0));
  pidHijo = fork();
  if(pidHijo == 0)
   {
       sigaction(14, &act, ((void *)0));
              sigaction(15, &act, ((void *)0));
              kill(getppid(),10);
       if(recurrente==1)
   {
          for(;;)
    {
     printf("\n Comienza la alarma.%d \n",getpid());
     alarm(seg);
     pause();
    }
   }
   else
   { printf("Comienza la alarma: %d \n",getpid());
     alarm(seg);
     pause();
     exit(0);
   }
  }
  else
  {
   if(pidHijo == -1)
   {
   printf("\n Error al crear el proceso hijo.");
   exit(1);
   }
  }
 }
}

canonical_original_code:
void NuevaAlarma(int seg, int padre, int recurrente)
{
 int pidHijo;
 int status = 0;
 if(getpid()==padre)
 {
  struct sigaction act;
  SetearActYConjSen(&act);
  sigaction(17, &act, ((void *)0));
  pidHijo = fork();
  if(pidHijo == 0)
   {
       sigaction(14, &act, ((void *)0));
              sigaction(15, &act, ((void *)0));
              kill(getppid(),10);
       if(recurrente==1)
   {
          for(;;)
    {
     printf("\n Comienza la alarma.%d \n",getpid());
     alarm(seg);
     pause();
    }
   }
   else
   { printf("Comienza la alarma: %d \n",getpid());
     alarm(seg);
     pause();
     exit(0);
   }
  }
  else
  {
   if(pidHijo == -1)
   {
   printf("\n Error al crear el proceso hijo.");
   exit(1);
   }
  }
 }
}

variable_types: seg int

variable_types: padre int

variable_types: recurrente int

variable_types: pidHijo int

variable_types: status int

variable_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval { int sival_int; void *sival_ptr; } si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; } *, void *); } __sigaction_handler; struct __sigset_t { unsigned long __val[-1]; } sa_mask; int sa_flags; void (*sa_restorer)(); }


handler

decompiled_code:
void __fastcall handler(int a1, __int64 a2)
{
int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax

switch ( a1 )
{
case 14:
v3 = getpid();
printf("\n Ha finalizado el tiempo de la alarma:%d \n", v3);
break;
case 15:
v4 = getpid();
printf("\nAlarma cancelada: %d", v4);
exit(0);
case 17:
v2 = *(_DWORD *)(a2 + 8);
if ( v2 == 1 )
{
puts("\n Finalizo proceso hijo.");
}
else if ( v2 == 5 )
{
puts("\n proceso hijo se detuvo.");
}
break;
}
}

canonical_decompiled_code:
void __fastcall func1(int a1, __int64 a2)
{
int v2; // eax
unsigned int v3; // eax
unsigned int v4; // eax

switch ( a1 )
{
case 14:
v3 = getpid();
printf("\n Ha finalizado el tiempo de la alarma:%d \n", v3);
break;
case 15:
v4 = getpid();
printf("\nAlarma cancelada: %d", v4);
exit(0);
case 17:
v2 = *(_DWORD *)(a2 + 8);
if ( v2 == 1 )
{
puts("\n Finalizo proceso hijo.");
}
else if ( v2 == 5 )
{
puts("\n proceso hijo se detuvo.");
}
break;
}
}

original_code:
void handler(int sig, siginfo_t *info, void *ni)
{
 if(sig==14)
        {
  printf("\n Ha finalizado el tiempo de la alarma:%d \n",getpid());
 }
 else
 if(sig==15)
 {
  printf("\nAlarma cancelada: %d",getpid());
  exit(0);
 }
 else
 if(sig==17)
 {
  switch(info->si_code)
  {
   case CLD_EXITED:
     printf("\n Finalizo proceso hijo.\n");
     break;
   case CLD_STOPPED:
     printf("\n proceso hijo se detuvo.\n");
     break;
  }
 }
}

canonical_original_code:
void handler(int sig, struct siginfo_t *info, void *ni)
{
 if(sig==14)
        {
  printf("\n Ha finalizado el tiempo de la alarma:%d \n",getpid());
 }
 else
 if(sig==15)
 {
  printf("\nAlarma cancelada: %d",getpid());
  exit(0);
 }
 else
 if(sig==17)
 {
  switch(info->si_code)
  {
   case CLD_EXITED:
     printf("\n Finalizo proceso hijo.\n");
     break;
   case CLD_STOPPED:
     printf("\n proceso hijo se detuvo.\n");
     break;
  }
 }
}

variable_types: sig int

user_defined_types: union sigval { int sival_int; void *sival_ptr; }


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebx
int stat_loc; // [rsp+Ch] [rbp-ACh] BYREF
struct sigaction stat_loc_4; // [rsp+10h] [rbp-A8h] BYREF

stat_loc = 0;
stat_loc_4.sa_handler = (__sighandler_t)capturar_senal;
v3 = getpid();
stat_loc_4.sa_flags = 4;
sigaction(10, &stat_loc_4, 0LL);
if ( getpid() == v3 )
printf("\n Soy el padre y mi pid es:%d \n", v3);
NuevaAlarma(0xAu, v3, 0);
pause();
NuevaAlarma(2u, v3, 1);
pause();
if ( getpid() == v3 )
{
sleep(0x32u);
CancelarAlarma(alarma[0]);
CancelarAlarma(alarma[1]);
}
wait((__WAIT_STATUS)&stat_loc);
exit(0);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebx
int stat_loc; // [rsp+Ch] [rbp-ACh] BYREF
struct sigaction stat_loc_4; // [rsp+10h] [rbp-A8h] BYREF

stat_loc = 0;
stat_loc_4.sa_handler = (__sighandler_t)capturar_senal;
v3 = getpid();
stat_loc_4.sa_flags = 4;
sigaction(10, &stat_loc_4, 0LL);
if ( getpid() == v3 )
printf("\n Soy el padre y mi pid es:%d \n", v3);
func4(0xAu, v3, 0);
pause();
func4(2u, v3, 1);
pause();
if ( getpid() == v3 )
{
sleep(0x32u);
func2(alarma[0]);
func2(alarma[1]);
}
wait((__WAIT_STATUS)&stat_loc);
exit(0);
}

original_code:
int main()
{
 int status=0;
 pid_t padre=getpid();
 pid_t pidHijo;
 struct sigaction act;
 act.__sigaction_handler.sa_sigaction=capturar_senal;
 act.sa_flags=4;
 sigaction(10, &act, ((void *)0));
 if(getpid()==padre)
  printf("\n Soy el padre y mi pid es:%d \n",padre);
 NuevaAlarma(10,padre,0);
 pause();
 NuevaAlarma(2,padre,1);
 pause();
 if(getpid()==padre)
 {
  sleep(50);
  CancelarAlarma(alarma[0]);
  CancelarAlarma(alarma[1]);
 }
wait(&status);
exit(0);
}

canonical_original_code:
int main()
{
 int status = 0;
 int padre = getpid();
 int pidHijo;
 struct sigaction act;
 act.__sigaction_handler.sa_sigaction=capturar_senal;
 act.sa_flags=4;
 sigaction(10, &act, ((void *)0));
 if(getpid()==padre)
  printf("\n Soy el padre y mi pid es:%d \n",padre);
 NuevaAlarma(10,padre,0);
 pause();
 NuevaAlarma(2,padre,1);
 pause();
 if(getpid()==padre)
 {
  sleep(50);
  CancelarAlarma(alarma[0]);
  CancelarAlarma(alarma[1]);
 }
wait(&status);
exit(0);
}

user_defined_types: struct __sigset_t { unsigned long __val[-1]; }


comparar

decompiled_code:
__int64 __fastcall comparar(__int64 a1, __int64 a2)
{
return (unsigned int)*(_QWORD *)(a1 + 56) - *(_DWORD *)(a2 + 56);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
return (unsigned int)*(_QWORD *)(a1 + 56) - *(_DWORD *)(a2 + 56);
}

original_code:
int comparar (const t_info *d, const t_info *dnodo)
{
 return d->dni-dnodo->dni;
}

canonical_original_code:
int comparar(struct t_info *d, struct t_info *dnodo)
{
 return d->dni-dnodo->dni;
}

variable_types: struct t_info { char empresa[21]; char apynom[31]; long dni; float sueldo; int antiguedad; char posee_tarjeta[2]; long tel; } *

variable_types:
dnodo
struct t_info *


cargarenArbol

original_code:
int cargarenArbol (t_arbol *p, const t_info *d)
{
 int cmp;
 if (*p)
 {
    cmp=comparar (d, &(*p)->info);
    if (!cmp)
    {
   (*p)->info=*d;
   return 1;
  }
    if (cmp<0)
     return cargarenArbol (&(*p)->izq, d);
    else
     return cargarenArbol (&(*p)->der, d);
 }
 *p=(t_nodo *)malloc(sizeof (t_nodo));
 if (!*p)
  return 0;
 (*p)->info=*d;
 (*p)->izq=(*p)->der=((void *)0);
 return 1;
}

canonical_original_code:
int cargarenArbol(struct s_nodo **p, struct t_info *d)
{
 int cmp;
 if (*p)
 {
    cmp=comparar (d, &(*p)->info);
    if (!cmp)
    {
   (*p)->info=*d;
   return 1;
  }
    if (cmp<0)
     return cargarenArbol (&(*p)->izq, d);
    else
     return cargarenArbol (&(*p)->der, d);
 }
 *p=(struct s_nodo *)malloc(sizeof (t_nodo));
 if (!*p)
  return 0;
 (*p)->info=*d;
 (*p)->izq=(*p)->der=((void *)0);
 return 1;
}

variable_types: struct s_nodo { struct t_info { char empresa[21]; char apynom[31]; long dni; float sueldo; int antiguedad; char posee_tarjeta[2]; long tel; } info; struct s_nodo *izq; } **

variable_types:
d
struct t_info *

variable_types: cmp int

user_defined_types: struct s_nodo { struct t_info info; struct s_nodo *izq; }


eliminarArbol

decompiled_code:
void __fastcall eliminarArbol(__int64 a1)
{
_QWORD *v2; // rdi
_QWORD *v3; // rdi

v2 = *(_QWORD **)a1;
if ( v2 )
{
eliminarArbol(v2 + 11);
eliminarArbol(*(_QWORD *)a1 + 96LL);
v3 = *(_QWORD **)a1;
if ( !*(_QWORD *)(*(_QWORD *)a1 + 88LL) && !v3[12] )
{
free(v3);
*(_QWORD *)a1 = 0LL;
}
}
}

original_code:
void eliminarArbol (t_arbol *p)
{
   if (*p)
   {
      eliminarArbol (&(*p)->izq);
      eliminarArbol (&(*p)->der);
      if (!(*p)->izq&&!(*p)->der)
      {
         free (*p);
         *p=((void *)0);
      }
   }
}

canonical_original_code:
void eliminarArbol(struct s_nodo **p)
{
   if (*p)
   {
      eliminarArbol (&(*p)->izq);
      eliminarArbol (&(*p)->der);
      if (!(*p)->izq&&!(*p)->der)
      {
         free (*p);
         *p=((void *)0);
      }
   }
}

user_defined_types: struct t_info { char empresa[21]; char apynom[31]; long dni; float sueldo; int antiguedad; char posee_tarjeta[2]; long tel; }


handlerserver

decompiled_code:
void __fastcall handlerserver(int a1)
{
if ( a1 == 10 )
{
printf("Soy el servidor y termino ");
msj = 1;
send(socketpadre, &msj, 4uLL, 0);
close(socketpadre);
exit(0);
}
}

canonical_decompiled_code:
void __fastcall func0(int a1)
{
if ( a1 == 10 )
{
printf("Soy el servidor y termino ");
msj = 1;
send(socketpadre, &msj, 4uLL, 0);
close(socketpadre);
exit(0);
}
}

original_code:
void handlerserver(int S)
{
  if (S==10)
{ printf("Soy el servidor y termino ");
  msj=1;
  send(socketpadre,&msj,sizeof(msj),0);
  close(socketpadre);
   exit(0); }
}

variable_types: S int


main

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

signal(10, handlerserver);
*(_QWORD *)&v8.sa_data[6] = 0LL;
v3 = (unsigned int)socket(2, 1, 0);
v8.sa_family = 2;
*(_WORD *)v8.sa_data = _bswap_16_constprop_0(v3, &v8, 16LL);
*(_DWORD *)&v8.sa_data[2] = _bswap_32_constprop_0();
bind(v3, &v8, v4);
listen(v3, 10);
puts("Comenzamos a escuchar conexiones");
v5 = getpid();
printf("mi pid es %d\n", v5);
addr = 0LL;
socketpadre = accept(v3, &addr, &addr_len);
printf("Conexion padre recibida");
while ( 1 )
{
addr = 0LL;
send(socketpadre, &msj, 4uLL, 0);
v6 = accept(v3, &addr, &addr_len);
puts(aConexi);
system("df >logservidor.txt");
comparar_informar();
close(v6);
}
}

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

signal(10, handlerserver);
*(_QWORD *)&v8.sa_data[6] = 0LL;
v3 = (unsigned int)socket(2, 1, 0);
v8.sa_family = 2;
*(_WORD *)v8.sa_data = func2(v3, &v8, 16LL);
*(_DWORD *)&v8.sa_data[2] = func1();
bind(v3, &v8, v4);
listen(v3, 10);
puts("Comenzamos a escuchar conexiones");
v5 = getpid();
printf("mi pid es %d\n", v5);
addr = 0LL;
socketpadre = accept(v3, &addr, &addr_len);
printf("Conexion padre recibida");
while ( 1 )
{
addr = 0LL;
send(socketpadre, &msj, 4uLL, 0);
v6 = accept(v3, &addr, &addr_len);
puts(aConexi);
system("df >logservidor.txt");
func3();
close(v6);
}
}

original_code:
int main() {
int listen_socket = 0, comm_socket = 0;
unsigned short int listen_port = 0;
unsigned long int listen_ip_address = 0;
struct sockaddr_in listen_address, con_address;
socklen_t con_addr_len;
char buffer[1024];
signal(10,handlerserver);
listen_socket = socket(2, SOCK_STREAM, 0);
bzero(&listen_address, sizeof(listen_address));
listen_address.sin_family = 2;
listen_port = htons(51244);
listen_address.sin_port = listen_port;
listen_ip_address = htonl(((in_addr_t) 0x00000000));
listen_address.sin_addr.s_addr = listen_ip_address;
bind(listen_socket,(struct sockaddr *)&listen_address,sizeof(struct sockaddr));
listen(listen_socket, 10);
printf("Comenzamos a escuchar conexiones\n");
printf("mi pid es %d\n", getpid());
bzero(&con_address, sizeof(con_address));
socketpadre= accept(listen_socket, (struct sockaddr *)(&con_address),&con_addr_len);
printf("Conexion padre recibida");
while (1) {
bzero(&con_address, sizeof(con_address));
send(socketpadre,&msj,sizeof(msj),0);
comm_socket = accept(listen_socket, (struct sockaddr *)(&con_address),&con_addr_len);
printf("Conexión recibida\n");
system("df >logservidor.txt");
comparar_informar();
close(comm_socket);
}
close(listen_socket);
printf("Se desconectó\n");
return 0;
}

canonical_original_code:
int main() {
int listen_socket = 0; int comm_socket = 0;
unsigned short listen_port = 0;
unsigned long listen_ip_address = 0;
struct sockaddr_in listen_address; struct sockaddr_in con_address;
unsigned int con_addr_len;
char buffer[1024];
signal(10,handlerserver);
listen_socket = socket(2, SOCK_STREAM, 0);
bzero(&listen_address, sizeof(listen_address));
listen_address.sin_family = 2;
listen_port = htons(51244);
listen_address.sin_port = listen_port;
listen_ip_address = htonl(((unsigned int) 0x00000000));
listen_address.sin_addr.s_addr = listen_ip_address;
bind(listen_socket,(struct sockaddr *)&listen_address,sizeof(struct sockaddr));
listen(listen_socket, 10);
printf("Comenzamos a escuchar conexiones\n");
printf("mi pid es %d\n", getpid());
bzero(&con_address, sizeof(con_address));
socketpadre= accept(listen_socket, (struct sockaddr *)(&con_address),&con_addr_len);
printf("Conexion padre recibida");
while (1) {
bzero(&con_address, sizeof(con_address));
send(socketpadre,&msj,sizeof(msj),0);
comm_socket = accept(listen_socket, (struct sockaddr *)(&con_address),&con_addr_len);
printf("Conexión recibida\n");
system("df >logservidor.txt");
comparar_informar();
close(comm_socket);
}
close(listen_socket);
printf("Se desconectó\n");
return 0;
}

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

variable_types:
buffer
char [1024]


threadPromedio

original_code:
void *threadPromedio(void *idHilo)
{
 int i, marc = 0, jTemp, nroHilo;
 float random, max, min, acum = 0.;
 nroHilo = *((int *)idHilo);
 while (j < 23)
 {
  jTemp = j;
  for (i = 0; i < n; i++)
  {
   random = ((float)rand()/2147483647) * 100 + jTemp * 100;
   if (marc == 0)
   {
    max = random;
    min = random;
    marc = 1;
   }
   else if (random > max)
    max = random;
   else if (random < min)
    min = random;
   acum += random;
  }
  printf("HILO %d\nMáximo: %.4f\nMínimo: %.4f\nPromedio: %.4f\n", nroHilo, max, min, acum/n);
  marc = 0;
  acum = 0;
  sleep(1);
  j++;
 }
}

canonical_original_code:
void *threadPromedio(void *idHilo)
{
 int i; int marc = 0; int jTemp; int nroHilo;
 float random; float max; float min; float acum = 0.;
 nroHilo = *((int *)idHilo);
 while (j < 23)
 {
  jTemp = j;
  for (i = 0; i < n; i++)
  {
   random = ((float)rand()/2147483647) * 100 + jTemp * 100;
   if (marc == 0)
   {
    max = random;
    min = random;
    marc = 1;
   }
   else if (random > max)
    max = random;
   else if (random < min)
    min = random;
   acum += random;
  }
  printf("HILO %d\nMáximo: %.4f\nMínimo: %.4f\nPromedio: %.4f\n", nroHilo, max, min, acum/n);
  marc = 0;
  acum = 0;
  sleep(1);
  j++;
 }
}

variable_types:
idHilo
void *

variable_types: i int

variable_types: marc int

variable_types: jTemp int

variable_types: nroHilo int

variable_types: random float

variable_types: max float

variable_types: min float

variable_types: acum float

return_type: void *


activarThread

decompiled_code:
void __fastcall activarThread(int a1)
{
pthread_t newthread[2]; // [rsp+0h] [rbp-10h] BYREF

if ( a1 == 10 )
{
if ( j > 22 )
{
puts("No se pueden crear mas Threads");
}
else
{
++id;
pthread_create(newthread, 0LL, threadPromedio, &id);
}
}
}

canonical_decompiled_code:
void __fastcall func1(int a1)
{
pthread_t newthread[2]; // [rsp+0h] [rbp-10h] BYREF

if ( a1 == 10 )
{
if ( j > 22 )
{
puts("No se pueden crear mas Threads");
}
else
{
++id;
pthread_create(newthread, 0LL, threadPromedio, &id);
}
}
}

original_code:
void activarThread(int sig)
{
 int res;
 pthread_t hilo;
 if (sig == 10)
  if (j < 23)
  {
   id++;
   res = pthread_create(&hilo, ((void *)0), threadPromedio, (void *)&id);
  }
  else
   printf("No se pueden crear mas Threads\n");
}

canonical_original_code:
void activarThread(int sig)
{
 int res;
 unsigned long hilo;
 if (sig == 10)
  if (j < 23)
  {
   id++;
   res = pthread_create(&hilo, ((void *)0), threadPromedio, (void *)&id);
  }
  else
   printf("No se pueden crear mas Threads\n");
}

variable_types: sig int

variable_types: res int

variable_types:
hilo
unsigned long


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rdi
unsigned int v4; // eax
unsigned int v5; // eax
int i; // ebx
int v7; // eax
float v8; // xmm2_4
float v9; // xmm1_4
int v10; // ebx
float v11; // xmm0_4
int v12; // eax
float v14; // [rsp+4h] [rbp-14h]
float v15; // [rsp+Ch] [rbp-Ch]

v3 = argv[1];
if ( !v3 )
{
puts("ERROR. Modo: ./EJ4 n (n=cantidad de numeros aleatorios a calcular en cada rango)");
exit(1);
}
n = atoi(v3);
v4 = getpid();
srand(v4);
signal(10, activarThread);
if ( n > 1000000 )
{
puts("Se debe pasar un N menor a 1000000");
exit(1);
}
v5 = getpid();
printf("PID: %d\n", v5);
for ( i = j; i <= 22; j = i )
{
v7 = n;
v8 = 0.0;
if ( n > 0 )
{
v8 = 0.0;
v9 = (float)(100 * i);
v10 = 0;
v11 = (float)((float)((float)rand() * 4.6566129e-10) * 100.0) + v9;
v15 = v11;
v14 = v11;
while ( 1 )
{
v7 = n;
++v10;
v8 = v8 + v11;
if ( n <= v10 )
break;
v12 = rand();
v11 = (float)((float)((float)v12 * 4.6566129e-10) * 100.0) + v9;
if ( v11 > v14 )
v14 = (float)((float)((float)v12 * 4.6566129e-10) * 100.0) + v9;
else
v15 = fminf(v11, v15);
}
}
printf(aHilo0M, v14, v15, (float)(v8 / (float)v7));
sleep(1u);
i = j + 1;
}
return 0;
}

original_code:
int main(int argc, char * argv[])
{
 int i, marc = 0, jTemp;
 float random, max, min, acum = 0.;
 if (argv[1]==((void *)0))
 {
  printf("ERROR. Modo: ./EJ4 n (n=cantidad de numeros aleatorios a calcular en cada rango)\n");
  exit(1);
 }
 n = atoi(argv[1]);
 srand(getpid());
 signal(10, activarThread);
 if (n <= 1000000)
 {
  printf ("PID: %d\n", getpid());
  while (j < 23)
  {
   jTemp = j;
   for (i = 0; i < n; i++)
   {
    random = ((float)rand()/2147483647) * 100 + jTemp * 100;
    if (marc == 0)
    {
     max = random;
     min = random;
     marc = 1;
    }
    else if (random > max)
     max = random;
    else if (random < min)
     min = random;
    acum += random;
   }
   printf("HILO 0\nMáximo: %.4f\nMínimo: %.4f\nPromedio: %.4f\n", max, min, acum/n);
   marc = 0;
   acum = 0;
   sleep(1);
   j++;
  }
 }
 else
 {
  printf("Se debe pasar un N menor a 1000000\n");
  exit(1);
 }
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 int i; int marc = 0; int jTemp;
 float random; float max; float min; float acum = 0.;
 if (argv[1]==((void *)0))
 {
  printf("ERROR. Modo: ./EJ4 n (n=cantidad de numeros aleatorios a calcular en cada rango)\n");
  exit(1);
 }
 n = atoi(argv[1]);
 srand(getpid());
 signal(10, activarThread);
 if (n <= 1000000)
 {
  printf ("PID: %d\n", getpid());
  while (j < 23)
  {
   jTemp = j;
   for (i = 0; i < n; i++)
   {
    random = ((float)rand()/2147483647) * 100 + jTemp * 100;
    if (marc == 0)
    {
     max = random;
     min = random;
     marc = 1;
    }
    else if (random > max)
     max = random;
    else if (random < min)
     min = random;
    acum += random;
   }
   printf("HILO 0\nMáximo: %.4f\nMínimo: %.4f\nPromedio: %.4f\n", max, min, acum/n);
   marc = 0;
   acum = 0;
   sleep(1);
   j++;
  }
 }
 else
 {
  printf("Se debe pasar un N menor a 1000000\n");
  exit(1);
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]


decompiled_code:
void __fastcall __noreturn thread_pantalla(void *a1)
{
while ( !FIN_THREAD )
{
while ( 1 )
{
recv(caller_socket, &pint, 0xCuLL, 0);
if ( (unsigned int)(pint + 4) > 0x10 )
break;
pintar(pint, *((unsigned int *)&pint + 2));
if ( FIN_THREAD )
goto LABEL_11;
}
if ( (unsigned int)(pint - 20) <= 3 )
{
pintar_zona(pint, *((unsigned int *)&pint + 2));
actualizar_puntajes(pint, *((unsigned int *)&pint + 2));
}
else if ( (unsigned int)(pint - 30) <= 3 )
{
actualizar_puntajes(pint, *((unsigned int *)&pint + 2));
}
else if ( (unsigned int)(pint - 40) <= 3 )
{
pintar_puntajes(pint, *((unsigned int *)&pint + 2));
}
else
{
switch ( (_DWORD)pint )
{
case 'c':
terminar("HAS SALIDO DEL JUEGO.. PRESIONE UNA TECLA PARA CONTINUAR");
case 'b':
terminar("HUBO UN PROBLEMA CON EL SERVIDOR.. PRESIONE UNA TECLA PARA CONTINUAR");
case 'a':
terminar("GAME OVER.. PRESIONE UNA TECLA PARA CONTINUAR");
}
}
}
LABEL_11:
pthread_exit(0LL);
}

canonical_decompiled_code:
void __fastcall __noreturn func2(void *a1)
{
while ( !FIN_THREAD )
{
while ( 1 )
{
recv(caller_socket, &pint, 0xCuLL, 0);
if ( (unsigned int)(pint + 4) > 0x10 )
break;
pintar(pint, *((unsigned int *)&pint + 2));
if ( FIN_THREAD )
goto LABEL_11;
}
if ( (unsigned int)(pint - 20) <= 3 )
{
pintar_zona(pint, *((unsigned int *)&pint + 2));
actualizar_puntajes(pint, *((unsigned int *)&pint + 2));
}
else if ( (unsigned int)(pint - 30) <= 3 )
{
actualizar_puntajes(pint, *((unsigned int *)&pint + 2));
}
else if ( (unsigned int)(pint - 40) <= 3 )
{
pintar_puntajes(pint, *((unsigned int *)&pint + 2));
}
else
{
switch ( (_DWORD)pint )
{
case 'c':
func1("HAS SALIDO DEL JUEGO.. PRESIONE UNA TECLA PARA CONTINUAR");
case 'b':
func1("HUBO UN PROBLEMA CON EL SERVIDOR.. PRESIONE UNA TECLA PARA CONTINUAR");
case 'a':
func1("GAME OVER.. PRESIONE UNA TECLA PARA CONTINUAR");
}
}
}
LABEL_11:
pthread_exit(0LL);
}

original_code:
void *thread_pantalla(void)
{
 while(!FIN_THREAD)
 {
  recv(caller_socket, &pint,sizeof(t_pintar),0);
  if (pint.valor>=-4&&pint.valor<=12)
   pintar(pint);
  else if (pint.valor>=20&&pint.valor<=23)
  {
   pintar_zona(pint);
   actualizar_puntajes(pint);
  }
  else if (pint.valor>=30&&pint.valor<=33)
   actualizar_puntajes(pint);
  else if (pint.valor>=40&&pint.valor<=43)
   pintar_puntajes(pint);
  else if (pint.valor==99)
   terminar("HAS SALIDO DEL JUEGO.. PRESIONE UNA TECLA PARA CONTINUAR");
  else if (pint.valor==98)
   terminar("HUBO UN PROBLEMA CON EL SERVIDOR.. PRESIONE UNA TECLA PARA CONTINUAR");
  else if (pint.valor==97)
   terminar("GAME OVER.. PRESIONE UNA TECLA PARA CONTINUAR");
 }
 pthread_exit(0);
}

canonical_original_code:
void *thread_pantalla()
{
 while(!FIN_THREAD)
 {
  recv(caller_socket, &pint,sizeof(t_pintar),0);
  if (pint.valor>=-4&&pint.valor<=12)
   pintar(pint);
  else if (pint.valor>=20&&pint.valor<=23)
  {
   pintar_zona(pint);
   actualizar_puntajes(pint);
  }
  else if (pint.valor>=30&&pint.valor<=33)
   actualizar_puntajes(pint);
  else if (pint.valor>=40&&pint.valor<=43)
   pintar_puntajes(pint);
  else if (pint.valor==99)
   terminar("HAS SALIDO DEL JUEGO.. PRESIONE UNA TECLA PARA CONTINUAR");
  else if (pint.valor==98)
   terminar("HUBO UN PROBLEMA CON EL SERVIDOR.. PRESIONE UNA TECLA PARA CONTINUAR");
  else if (pint.valor==97)
   terminar("GAME OVER.. PRESIONE UNA TECLA PARA CONTINUAR");
 }
 pthread_exit(0);
}


terminar

decompiled_code:
void __fastcall __noreturn terminar(char *a1)
{
size_t v1; // rax
size_t v2; // rax

FIN_THREAD = 1;
close(caller_socket);
wclear(stdscr);
wattr_on(stdscr, 0x200000uLL, 0LL);
wattr_on(stdscr, 0x80000uLL, 0LL);
v1 = strlen(a1);
mvprintw(ALTO / 2 - 2, (ANCHO - v1) >> 1, a1);
v2 = strlen(creditos);
mvprintw(ALTO / 2 + 2, (ANCHO - v2) >> 1, creditos);
wrefresh(stdscr);
pthread_cancel(IDpantalla);
wgetch(stdscr);
wclear(stdscr);
wrefresh(stdscr);
endwin();
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func1(char *a1)
{
size_t v1; // rax
size_t v2; // rax

FIN_THREAD = 1;
close(caller_socket);
wclear(stdscr);
wattr_on(stdscr, 0x200000uLL, 0LL);
wattr_on(stdscr, 0x80000uLL, 0LL);
v1 = strlen(a1);
mvprintw(ALTO / 2 - 2, (ANCHO - v1) >> 1, a1);
v2 = strlen(creditos);
mvprintw(ALTO / 2 + 2, (ANCHO - v2) >> 1, creditos);
wrefresh(stdscr);
pthread_cancel(IDpantalla);
wgetch(stdscr);
wclear(stdscr);
wrefresh(stdscr);
endwin();
exit(0);
}

original_code:
void terminar(char *cad)
{
 FIN_THREAD=1;
 close(caller_socket);
 wclear(stdscr);
 wattr_on(stdscr, (attr_t)((((chtype)((1U)) << ((13) + 8)))), ((void *)0));
 wattr_on(stdscr, (attr_t)((((chtype)((1U)) << ((11) + 8)))), ((void *)0));
 mvprintw(ALTO/2-2,(ANCHO-strlen(cad))/2,cad);
 mvprintw(ALTO/2+2,(ANCHO-strlen(creditos))/2,creditos);
 wrefresh(stdscr);
 pthread_cancel(IDpantalla);
 wgetch(stdscr);
 wclear(stdscr);
 wrefresh(stdscr);
 endwin();
 exit(0);
}

variable_types:
cad
char *