main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int16 v3; // bp
struct hostent *v4; // r13
int v5; // er12
__int64 v6; // rax
int v7; // ebx
int v8; // ebp
int v9; // eax
char v11[112]; // [rsp+0h] [rbp-518h] BYREF
char dest[112]; // [rsp+70h] [rbp-4A8h] BYREF
char s[512]; // [rsp+E0h] [rbp-438h] BYREF
char name[512]; // [rsp+2E0h] [rbp-238h] BYREF
struct sockaddr addr; // [rsp+4E0h] [rbp-38h] BYREF

if ( argc != 8 )
{
fprintf(stderr, "Usage: %s host port DATREQ station.[location-]channel yyyy/mm/dd hh:mm:ss duration(secs)\n", *argv);
exit(10);
}
strcpy(dest, argv[3]);
Upcase(dest);
strcpy(v11, argv[4]);
Upcase(v11);
strcpy(name, argv[1]);
v3 = atoi(argv[2]);
v4 = gethostbyname(name);
if ( !v4 )
{
fprintf(stderr, "%s: unknown host\n", name);
exit(1);
}
v5 = socket(2, 1, 0);
if ( v5 < 0 )
{
perror("socket");
exit(1);
}
memmove(&addr.sa_data[2], *(const void **)v4->h_addr_list, v4->h_length);
addr.sa_family = 2;
*(_WORD *)addr.sa_data = _bswap_16(v3);
if ( connect(v5, &addr, 0x10u) < 0 )
{
perror("connect");
exit(1);
}
LODWORD(v6) = atoi(argv[7]);
sprintf(s, "%s %s %s %s %d\n", dest, v11, argv[5], argv[6], v6);
fprintf(stderr, "Command: %s\n", s);
v7 = strlen(s);
if ( v7 != (unsigned int)write(v5, s, v7) )
{
perror("Net write");
exit(1);
}
v8 = 0;
while ( 1 )
{
v9 = read(v5, s, 0x200uLL);
if ( v9 < 0 )
{
perror("network read");
exit(1);
}
v8 += v9;
if ( !v9 )
break;
if ( v9 != (unsigned int)write(1, s, v9) )
{
perror("Terminal write");
exit(1);
}
}
fwrite("Exit on read 0 bytes\n", 1uLL, 0x15uLL, stderr);
fprintf(stderr, "Read %d records\n", (unsigned int)(v8 / 512));
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int16 v3; // bp
struct hostent *v4; // r13
int v5; // er12
__int64 v6; // rax
int v7; // ebx
int v8; // ebp
int v9; // eax
char v11[112]; // [rsp+0h] [rbp-518h] BYREF
char dest[112]; // [rsp+70h] [rbp-4A8h] BYREF
char s[512]; // [rsp+E0h] [rbp-438h] BYREF
char name[512]; // [rsp+2E0h] [rbp-238h] BYREF
struct sockaddr addr; // [rsp+4E0h] [rbp-38h] BYREF

if ( argc != 8 )
{
fprintf(stderr, "Usage: %s host port DATREQ station.[location-]channel yyyy/mm/dd hh:mm:ss duration(secs)\n", *argv);
exit(10);
}
strcpy(dest, argv[3]);
func8(dest);
strcpy(v11, argv[4]);
func8(v11);
strcpy(name, argv[1]);
v3 = atoi(argv[2]);
v4 = gethostbyname(name);
if ( !v4 )
{
fprintf(stderr, "%s: unknown host\n", name);
exit(1);
}
v5 = socket(2, 1, 0);
if ( v5 < 0 )
{
perror("socket");
exit(1);
}
memmove(&addr.sa_data[2], *(const void **)v4->h_addr_list, v4->h_length);
addr.sa_family = 2;
*(_WORD *)addr.sa_data = func7(v3);
if ( connect(v5, &addr, 0x10u) < 0 )
{
perror("connect");
exit(1);
}
LODWORD(v6) = atoi(argv[7]);
sprintf(s, "%s %s %s %s %d\n", dest, v11, argv[5], argv[6], v6);
fprintf(stderr, "Command: %s\n", s);
v7 = strlen(s);
if ( v7 != (unsigned int)write(v5, s, v7) )
{
perror("Net write");
exit(1);
}
v8 = 0;
while ( 1 )
{
v9 = read(v5, s, 0x200uLL);
if ( v9 < 0 )
{
perror("network read");
exit(1);
}
v8 += v9;
if ( !v9 )
break;
if ( v9 != (unsigned int)write(1, s, v9) )
{
perror("Terminal write");
exit(1);
}
}
fwrite("Exit on read 0 bytes\n", 1uLL, 0x15uLL, stderr);
fprintf(stderr, "Read %d records\n", (unsigned int)(v8 / 512));
return 0;
}

original_code:
int main(int argc,char **argv)
{
  struct sockaddr_in sin;
  struct hostent *hp, *gethostbyname();
  char host[512];
  int fd, count, wcount;
  char buf[512];
  char savebuf[512];
  int port;
  int total=0;
  char cmd[100];
  char chan[100];
  if (argc!=8)
  {
    fprintf(stderr,"Usage: %s host port DATREQ station.[location-]channel yyyy/mm/dd hh:mm:ss duration(secs)\n",argv[0]);
    exit(10);
  }
  strcpy(cmd,argv[3]);
  Upcase(cmd);
  strcpy(chan,argv[4]);
  Upcase(chan);
  strcpy(host,argv[1]);
  port = atoi(argv[2]);
  hp = gethostbyname(host);
  if(hp == 0) {
    fprintf(stderr, "%s: unknown host\n",host);
    exit(1);
  }
  fd = socket(2, SOCK_STREAM, 0);
  if(fd < 0) {
    perror("socket");
    exit(1);
  }
  bcopy(hp->h_addr_list[0], (char *)&sin.sin_addr, hp->h_length);
  sin.sin_family = 2;
  sin.sin_port = htons(port);
  if(connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
    perror("connect");
    exit(1);
  }
  sprintf(buf,"%s %s %s %s %d\n",
   cmd,chan,argv[5],argv[6],atoi(argv[7]));
  fprintf(stderr,"Command: %s\n",buf);
  count = strlen(buf);
  wcount = write(fd, buf, count);
  if(wcount != count) {
    perror("Net write");
    exit(1);
  }
  while (1) {
    count = read(fd, buf, sizeof(buf));
    if(count < 0)
    {
      perror("network read");
      exit(1);
    }
    total += count;
    if (count==0)
    {
      fprintf(stderr, "Exit on read 0 bytes\n");
      break;
    }
    memcpy(savebuf, buf, sizeof(buf));
    wcount = write(1, buf, count);
    if(wcount != count) {
      perror("Terminal write");
      exit(1);
    }
  }
  fprintf(stderr,"Read %d records\n",
          total/512);
  return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
  struct sockaddr_in sin;
  struct hostent *hp; struct hostent *gethostbyname();
  char host[512];
  int fd; int count; int wcount;
  char buf[512];
  char savebuf[512];
  int port;
  int total = 0;
  char cmd[100];
  char chan[100];
  if (argc!=8)
  {
    fprintf(stderr,"Usage: %s host port DATREQ station.[location-]channel yyyy/mm/dd hh:mm:ss duration(secs)\n",argv[0]);
    exit(10);
  }
  strcpy(cmd,argv[3]);
  Upcase(cmd);
  strcpy(chan,argv[4]);
  Upcase(chan);
  strcpy(host,argv[1]);
  port = atoi(argv[2]);
  hp = gethostbyname(host);
  if(hp == 0) {
    fprintf(stderr, "%s: unknown host\n",host);
    exit(1);
  }
  fd = socket(2, SOCK_STREAM, 0);
  if(fd < 0) {
    perror("socket");
    exit(1);
  }
  bcopy(hp->h_addr_list[0], (char *)&sin.sin_addr, hp->h_length);
  sin.sin_family = 2;
  sin.sin_port = htons(port);
  if(connect(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
    perror("connect");
    exit(1);
  }
  sprintf(buf,"%s %s %s %s %d\n",
   cmd,chan,argv[5],argv[6],atoi(argv[7]));
  fprintf(stderr,"Command: %s\n",buf);
  count = strlen(buf);
  wcount = write(fd, buf, count);
  if(wcount != count) {
    perror("Net write");
    exit(1);
  }
  while (1) {
    count = read(fd, buf, sizeof(buf));
    if(count < 0)
    {
      perror("network read");
      exit(1);
    }
    total += count;
    if (count==0)
    {
      fprintf(stderr, "Exit on read 0 bytes\n");
      break;
    }
    memcpy(savebuf, buf, sizeof(buf));
    wcount = write(1, buf, count);
    if(wcount != count) {
      perror("Terminal write");
      exit(1);
    }
  }
  fprintf(stderr,"Read %d records\n",
          total/512);
  return 0;
}

variable_types: argc int

variable_types:
argv
char **

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: struct hostent { char *h_name; char **h_aliases; int h_addrtype; int h_length; char **h_addr_list; } *()

variable_types:
host
char [512]

variable_types: fd int

variable_types: count int

variable_types: wcount int

variable_types:
buf
char [512]

variable_types:
savebuf
char [512]

variable_types: port int

variable_types: total int

variable_types:
cmd
char [100]

variable_types:
chan
char [100]

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


gpsInit

repo: joeledwards/asl-station-processor

decompiled_code:
__int64 gpsInit()
{
__int64 v0; // rax

v0 = bcStartPci();
hBC_PCI = v0;
if ( !v0 )
return 0xFFFFFFFFLL;
bcSetMode(v0, 6LL);
bcSetTimeFormat(hBC_PCI, 1LL);
bcSetGpsTmFmt(hBC_PCI, 0LL);
bcSetYearAutoIncFlag(hBC_PCI, 1LL);
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rax

v0 = bcStartPci();
hBC_PCI = v0;
if ( !v0 )
return 0xFFFFFFFFLL;
bcSetMode(v0, 6LL);
bcSetTimeFormat(hBC_PCI, 1LL);
bcSetGpsTmFmt(hBC_PCI, 0LL);
bcSetYearAutoIncFlag(hBC_PCI, 1LL);
return 0LL;
}

original_code:
int gpsInit()
{
  hBC_PCI = bcStartPci();
  if (!hBC_PCI)
    return -1;
  bcSetMode(hBC_PCI, MODE_GPS);
  bcSetTimeFormat(hBC_PCI, FORMAT_BINARY);
  bcSetGpsTmFmt(hBC_PCI, UTC_TIME_FMT);
  bcSetYearAutoIncFlag(hBC_PCI, YEAR_AUTO_ENA);
  return 0;
}

return_type: int


gpsTime

decompiled_code:
__int64 __fastcall gpsTime(_QWORD *a1, _BYTE *a2)
{
char v3; // [rsp+Dh] [rbp-2Bh] BYREF
char v4[2]; // [rsp+Eh] [rbp-2Ah] BYREF
__int64 v5; // [rsp+10h] [rbp-28h] BYREF
__int64 v6[4]; // [rsp+18h] [rbp-20h] BYREF

if ( !bcReadBinTimeEx(hBC_PCI, v6, &v5, v4, &v3) )
return 0xFFFFFFFFLL;
*a2 = v3;
*a1 = v6[0];
a1[1] = v5;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1, _BYTE *a2)
{
char v3; // [rsp+Dh] [rbp-2Bh] BYREF
char v4[2]; // [rsp+Eh] [rbp-2Ah] BYREF
__int64 v5; // [rsp+10h] [rbp-28h] BYREF
__int64 v6[4]; // [rsp+18h] [rbp-20h] BYREF

if ( !bcReadBinTimeEx(hBC_PCI, v6, &v5, v4, &v3) )
return 0xFFFFFFFFLL;
*a2 = v3;
*a1 = v6[0];
a1[1] = v5;
return 0LL;
}

original_code:
int gpsTime(
        struct timeval *uxtime,
 unsigned char *status)
{
  DWORD maj, minor;
  WORD nano;
  BYTE stat;
  time_t *movetime;
  if ( bcReadBinTimeEx (hBC_PCI, &maj, &minor, &nano, &stat) == 0 )
  {
    return -1;
  }
  *status = stat;
  uxtime->tv_sec = maj;
  uxtime->tv_usec = minor;
  return 0;
}

canonical_original_code:
int gpsTime(struct timeval *uxtime, unsigned char *status)
{
  unsigned long maj; unsigned long minor;
  unsigned short nano;
  unsigned char stat;
  long *movetime;
  if ( bcReadBinTimeEx (hBC_PCI, &maj, &minor, &nano, &stat) == 0 )
  {
    return -1;
  }
  *status = stat;
  uxtime->tv_sec = maj;
  uxtime->tv_usec = minor;
  return 0;
}

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

variable_types:
status
unsigned char *

variable_types:
maj
unsigned long

variable_types:
minor
unsigned long

variable_types:
nano
unsigned short

variable_types:
stat
unsigned char

variable_types:
movetime
long *


decompiled_code:
int print_memory_info()
{
struct rusage v1; // [rsp+0h] [rbp-98h] BYREF

getrusage(RUSAGE_SELF, &v1);
puts("Memory Usage Statistics:");
printf(" User time used ---------------- %li.%06lli sec.\n", v1.ru_utime.tv_sec, v1.ru_utime.tv_usec % 1000000);
printf(" System time used -------------- %li.%06lli sec.\n", v1.ru_stime.tv_sec, v1.ru_stime.tv_usec % 1000000);
printf(" Maximum resident set size ----- %li\n", v1.ru_maxrss);
printf(" Integral shared memory size --- %li\n", v1.ru_ixrss);
printf(" Integral unshared data size --- %li\n", v1.ru_idrss);
printf(" Integral unshared stack size -- %li\n", v1.ru_isrss);
printf(" Page reclaims ----------------- %li\n", v1.ru_minflt);
printf(" Page faults ------------------- %li\n", v1.ru_majflt);
printf(" Swaps ------------------------- %li\n", v1.ru_nswap);
printf(" Block input operations -------- %li\n", v1.ru_inblock);
printf(" Block output operations ------- %li\n", v1.ru_oublock);
printf(" Messages sent ----------------- %li\n", v1.ru_msgsnd);
printf(" Messages received ------------- %li\n", v1.ru_msgrcv);
printf(" Signals received -------------- %li\n", v1.ru_nsignals);
printf(" Voluntary context switches ---- %li\n", v1.ru_nvcsw);
return printf(" Involuntary context switches -- %li\n", v1.ru_nivcsw);
}

canonical_decompiled_code:
int func2()
{
struct rusage v1; // [rsp+0h] [rbp-98h] BYREF

getrusage(RUSAGE_SELF, &v1);
puts("Memory Usage Statistics:");
printf(" User time used ---------------- %li.%06lli sec.\n", v1.ru_utime.tv_sec, v1.ru_utime.tv_usec % 1000000);
printf(" System time used -------------- %li.%06lli sec.\n", v1.ru_stime.tv_sec, v1.ru_stime.tv_usec % 1000000);
printf(" Maximum resident set size ----- %li\n", v1.ru_maxrss);
printf(" Integral shared memory size --- %li\n", v1.ru_ixrss);
printf(" Integral unshared data size --- %li\n", v1.ru_idrss);
printf(" Integral unshared stack size -- %li\n", v1.ru_isrss);
printf(" Page reclaims ----------------- %li\n", v1.ru_minflt);
printf(" Page faults ------------------- %li\n", v1.ru_majflt);
printf(" Swaps ------------------------- %li\n", v1.ru_nswap);
printf(" Block input operations -------- %li\n", v1.ru_inblock);
printf(" Block output operations ------- %li\n", v1.ru_oublock);
printf(" Messages sent ----------------- %li\n", v1.ru_msgsnd);
printf(" Messages received ------------- %li\n", v1.ru_msgrcv);
printf(" Signals received -------------- %li\n", v1.ru_nsignals);
printf(" Voluntary context switches ---- %li\n", v1.ru_nvcsw);
return printf(" Involuntary context switches -- %li\n", v1.ru_nivcsw);
}

original_code:
void print_memory_info() {
    struct rusage mem_usage;
    getrusage( RUSAGE_SELF, &mem_usage );
    printf( "Memory Usage Statistics:\n" );
    printf( "  User time used ---------------- %li.%06lli sec.\n",
            mem_usage.ru_utime.tv_sec,
            mem_usage.ru_utime.tv_usec % 1000000LL );
    printf( "  System time used -------------- %li.%06lli sec.\n",
            mem_usage.ru_stime.tv_sec,
            mem_usage.ru_stime.tv_usec % 1000000LL );
    printf( "  Maximum resident set size ----- %li\n", mem_usage.ru_maxrss );
    printf( "  Integral shared memory size --- %li\n", mem_usage.ru_ixrss );
    printf( "  Integral unshared data size --- %li\n", mem_usage.ru_idrss );
    printf( "  Integral unshared stack size -- %li\n", mem_usage.ru_isrss );
    printf( "  Page reclaims ----------------- %li\n", mem_usage.ru_minflt );
    printf( "  Page faults ------------------- %li\n", mem_usage.ru_majflt );
    printf( "  Swaps ------------------------- %li\n", mem_usage.ru_nswap );
    printf( "  Block input operations -------- %li\n", mem_usage.ru_inblock );
    printf( "  Block output operations ------- %li\n", mem_usage.ru_oublock );
    printf( "  Messages sent ----------------- %li\n", mem_usage.ru_msgsnd );
    printf( "  Messages received ------------- %li\n", mem_usage.ru_msgrcv );
    printf( "  Signals received -------------- %li\n", mem_usage.ru_nsignals );
    printf( "  Voluntary context switches ---- %li\n", mem_usage.ru_nvcsw );
    printf( "  Involuntary context switches -- %li\n", mem_usage.ru_nivcsw );
}

variable_types: struct rusage { struct timeval { long tv_sec; long tv_usec; } ru_utime; struct timeval ru_stime; union { long ru_maxrss; long __ru_maxrss_word; }; union { long ru_ixrss; long __ru_ixrss_word; }; union { long ru_idrss; long __ru_idrss_word; }; union { long ru_isrss; long __ru_isrss_word; }; union { long ru_minflt; long __ru_minflt_word; }; union { long ru_majflt; long __ru_majflt_word; }; union { long ru_nswap; long __ru_nswap_word; }; union { long ru_inblock; long __ru_inblock_word; }; union { long ru_oublock; long __ru_oublock_word; }; union { long ru_msgsnd; long __ru_msgsnd_word; }; union { long ru_msgrcv; long __ru_msgrcv_word; }; union { long ru_nsignals; long __ru_nsignals_word; }; union { long ru_nvcsw; long __ru_nvcsw_word; }; union { long ru_nivcsw; long __ru_nivcsw_word; }; }

return_type: void

user_defined_types: struct rusage { struct timeval ru_utime; struct timeval ru_stime; union { long ru_maxrss; long __ru_maxrss_word; }; union { long ru_ixrss; long __ru_ixrss_word; }; union { long ru_idrss; long __ru_idrss_word; }; union { long ru_isrss; long __ru_isrss_word; }; union { long ru_minflt; long __ru_minflt_word; }; union { long ru_majflt; long __ru_majflt_word; }; union { long ru_nswap; long __ru_nswap_word; }; union { long ru_inblock; long __ru_inblock_word; }; union { long ru_oublock; long __ru_oublock_word; }; union { long ru_msgsnd; long __ru_msgsnd_word; }; union { long ru_msgrcv; long __ru_msgrcv_word; }; union { long ru_nsignals; long __ru_nsignals_word; }; union { long ru_nvcsw; long __ru_nvcsw_word; }; union { long ru_nivcsw; long __ru_nivcsw_word; }; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rbp
char v4; // r15
int v5; // eax
const char *v6; // rdx
__int64 j; // rax
char v8; // dl
__int16 *v9; // rbx
__int16 v10; // r12
__int16 v11; // bp
__int64 v12; // r13
__int64 i; // r14
__int64 v14; // rbx
size_t v16; // [rsp+8h] [rbp-2C0h]
void *ptr; // [rsp+10h] [rbp-2B8h]
char v18; // [rsp+1Bh] [rbp-2ADh]
unsigned int v19; // [rsp+1Ch] [rbp-2ACh]
FILE *stream; // [rsp+20h] [rbp-2A8h]
char v21; // [rsp+28h] [rbp-2A0h]
char v22; // [rsp+29h] [rbp-29Fh]
char v23; // [rsp+2Ah] [rbp-29Eh]
char v24; // [rsp+2Bh] [rbp-29Dh]
char v25; // [rsp+2Ch] [rbp-29Ch]
char v26; // [rsp+2Dh] [rbp-29Bh]
unsigned __int8 v27; // [rsp+2Eh] [rbp-29Ah]
char v28; // [rsp+2Fh] [rbp-299h]
char v29[6]; // [rsp+3Ah] [rbp-28Eh] BYREF
__int64 v30[5]; // [rsp+40h] [rbp-288h] BYREF
__int64 v31; // [rsp+68h] [rbp-260h]
char v32[64]; // [rsp+70h] [rbp-258h] BYREF
char v33[192]; // [rsp+B0h] [rbp-218h] BYREF
char v34[160]; // [rsp+170h] [rbp-158h] BYREF
__int16 v35[2]; // [rsp+210h] [rbp-B8h] BYREF
unsigned __int16 v36; // [rsp+214h] [rbp-B4h]
unsigned __int16 v37; // [rsp+216h] [rbp-B2h]
unsigned int v38; // [rsp+218h] [rbp-B0h]
char v39; // [rsp+21Ch] [rbp-ACh]
unsigned __int8 v40; // [rsp+21Dh] [rbp-ABh]
char v41; // [rsp+21Fh] [rbp-A9h]
char v42; // [rsp+220h] [rbp-A8h]
char v43[58]; // [rsp+230h] [rbp-98h] BYREF
__int16 v44; // [rsp+26Ah] [rbp-5Eh]
__int64 v45[8]; // [rsp+288h] [rbp-40h] BYREF

v45[0] = 0LL;
v30[0] = 0LL;
v30[1] = 0LL;
v30[2] = 0LL;
v30[3] = 0LL;
v30[4] = 0LL;
v31 = 0LL;
if ( argc <= 1 )
{
print_usage(argv, 0LL);
}
else
{
v3 = argv[argc - 1];
v19 = 0;
v28 = 0;
v4 = 0;
v23 = 0;
v26 = 0;
v27 = 0;
v22 = 0;
v18 = 0;
v25 = 0;
v24 = 0;
while ( 1 )
{
v5 = getopt(argc, (char *const *)argv, "fghlmrCcTtw");
if ( v5 == -1 )
break;
switch ( v5 )
{
case 'C':
v26 = 1;
break;
case 'T':
v22 = 1;
break;
case 'c':
v27 = 1;
break;
case 'f':
v25 = 1;
break;
case 'g':
v24 = 1;
break;
case 'h':
v4 = 1;
break;
case 'l':
v18 = 1;
break;
case 'm':
v28 = 1;
break;
case 'r':
v23 = 1;
break;
case 't':
LOBYTE(v31) = 1;
v22 = 1;
break;
case 'w':
v19 = 1;
break;
default:
fwrite("Got Filename\n", 1uLL, 0xDuLL, stderr);
break;
}
}
ptr = malloc(0x2000uLL);
if ( ptr )
{
stream = fopen(v3, "rb");
if ( stream )
{
do
{
v16 = fread(ptr, 0x200uLL, 0x10uLL, stream);
v14 = ftell(stream);
fprintf(stdout, "Read %d record(s)\n", v16);
fprintf(stdout, "File position is %ld\n", v14);
if ( feof(stream) || (v21 = 0, ferror(stream)) )
{
fwrite("EOF reached\n", 1uLL, 0xCuLL, stdout);
v21 = 1;
}
if ( v23 )
{
fwrite("Raw Data:\n", 1uLL, 0xAuLL, stdout);
dump_hex(ptr, v16 << 9, 16LL, 32LL);
}
if ( v16 )
{
v12 = (__int64)ptr;
for ( i = 0LL; i != v16; ++i )
{
v45[0] = v12;
loadseedhdr(v45, v43, 0LL);
v9 = (__int16 *)(v12 + v44);
if ( v44 )
{
do
{
v10 = _bswap_16(*v9);
v11 = _bswap_16(v9[1]);
if ( v10 == 2000 )
{
v45[0] = (__int64)v9;
loadopaquehdr(v45, v35);
if ( v4 )
{
puts("Found an opaque blockette:");
jprintf(1LL, "Blockette type: %lu\n", (unsigned __int16)v35[0]);
jprintf(1LL, "Next blockette: %lu\n", (unsigned __int16)v35[1]);
jprintf(1LL, "Blockette length: %lu\n", v36);
jprintf(1LL, "Data offset: %lu\n", v37);
jprintf(1LL, "Record number: %lu\n", v38);
v6 = "Big Endian";
if ( !v39 )
v6 = "Little Endian";
jprintf(1LL, "Data word order: %s\n", v6);
jprintf(1LL, "Opaque data flags: 0x%02lx\n", v40);
for ( j = 0LL; j != 5; ++j )
{
v8 = *(&v41 + j);
v29[j] = v8;
if ( !v8 )
break;
if ( v8 == 126 )
break;
}
v29[j + 1] = 0;
jprintf(1LL, "Record type: %s\n", v29);
jprintf(1LL, "========== RECORD DATA ========== \n");
}
v45[0] = (__int64)v9 + v37;
switch ( v41 )
{
case 'G':
if ( v42 == 76 )
{
loadglob(v45, v34);
if ( v24 )
{
jprintf(2LL, "Global Config:\n");
print_global(v34, 3LL, v19);
}
}
break;
case 'F':
if ( v42 == 88 )
{
loadfix(v45, v33);
if ( v25 )
{
jprintf(2LL, "Fixed Config:\n");
print_fixed(v33, 3LL, v19);
}
}
break;
case 'L':
loadlog(v45, v32);
if ( v18 )
{
jprintf(2LL, "Log Config:\n");
print_log(v32, 3LL, v19);
}
break;
case 'T':
append_tokens(v30, (char *)v9 + v37, v36 - (unsigned __int64)v37, v40);
if ( (unsigned __int8)tokens_complete(v30) )
{
if ( v22 )
{
jprintf(2LL, "Token Config:\n");
print_tokens(v30, 3LL, v19);
}
else if ( v26 )
{
jprintf(2LL, "Token Config (manual):\n");
parse_tokens(v30, v27, 3LL);
}
else if ( v27 )
{
jprintf(2LL, "Token Config (raw):\n");
dump_tokens(v30);
}
}
break;
}
}
v9 = (__int16 *)(v12 + v11);
}
while ( v11 );
}
v12 += 512LL;
}
}
}
while ( !v21 );
if ( v28 )
print_memory_info();
fclose(stream);
}
else
{
fprintf(stderr, "Unable to open file '%s' for reading.\n", v3);
}
free(ptr);
}
else
{
fwrite("Could not allocate memory for read buffer.\n", 1uLL, 0x2BuLL, stderr);
}
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rbp
char v4; // r15
int v5; // eax
const char *v6; // rdx
__int64 j; // rax
char v8; // dl
__int16 *v9; // rbx
__int16 v10; // r12
__int16 v11; // bp
__int64 v12; // r13
__int64 i; // r14
__int64 v14; // rbx
size_t v16; // [rsp+8h] [rbp-2C0h]
void *ptr; // [rsp+10h] [rbp-2B8h]
char v18; // [rsp+1Bh] [rbp-2ADh]
unsigned int v19; // [rsp+1Ch] [rbp-2ACh]
FILE *stream; // [rsp+20h] [rbp-2A8h]
char v21; // [rsp+28h] [rbp-2A0h]
char v22; // [rsp+29h] [rbp-29Fh]
char v23; // [rsp+2Ah] [rbp-29Eh]
char v24; // [rsp+2Bh] [rbp-29Dh]
char v25; // [rsp+2Ch] [rbp-29Ch]
char v26; // [rsp+2Dh] [rbp-29Bh]
unsigned __int8 v27; // [rsp+2Eh] [rbp-29Ah]
char v28; // [rsp+2Fh] [rbp-299h]
char v29[6]; // [rsp+3Ah] [rbp-28Eh] BYREF
__int64 v30[5]; // [rsp+40h] [rbp-288h] BYREF
__int64 v31; // [rsp+68h] [rbp-260h]
char v32[64]; // [rsp+70h] [rbp-258h] BYREF
char v33[192]; // [rsp+B0h] [rbp-218h] BYREF
char v34[160]; // [rsp+170h] [rbp-158h] BYREF
__int16 v35[2]; // [rsp+210h] [rbp-B8h] BYREF
unsigned __int16 v36; // [rsp+214h] [rbp-B4h]
unsigned __int16 v37; // [rsp+216h] [rbp-B2h]
unsigned int v38; // [rsp+218h] [rbp-B0h]
char v39; // [rsp+21Ch] [rbp-ACh]
unsigned __int8 v40; // [rsp+21Dh] [rbp-ABh]
char v41; // [rsp+21Fh] [rbp-A9h]
char v42; // [rsp+220h] [rbp-A8h]
char v43[58]; // [rsp+230h] [rbp-98h] BYREF
__int16 v44; // [rsp+26Ah] [rbp-5Eh]
__int64 v45[8]; // [rsp+288h] [rbp-40h] BYREF

v45[0] = 0LL;
v30[0] = 0LL;
v30[1] = 0LL;
v30[2] = 0LL;
v30[3] = 0LL;
v30[4] = 0LL;
v31 = 0LL;
if ( argc <= 1 )
{
func1(argv, 0LL);
}
else
{
v3 = argv[argc - 1];
v19 = 0;
v28 = 0;
v4 = 0;
v23 = 0;
v26 = 0;
v27 = 0;
v22 = 0;
v18 = 0;
v25 = 0;
v24 = 0;
while ( 1 )
{
v5 = getopt(argc, (char *const *)argv, "fghlmrCcTtw");
if ( v5 == -1 )
break;
switch ( v5 )
{
case 'C':
v26 = 1;
break;
case 'T':
v22 = 1;
break;
case 'c':
v27 = 1;
break;
case 'f':
v25 = 1;
break;
case 'g':
v24 = 1;
break;
case 'h':
v4 = 1;
break;
case 'l':
v18 = 1;
break;
case 'm':
v28 = 1;
break;
case 'r':
v23 = 1;
break;
case 't':
LOBYTE(v31) = 1;
v22 = 1;
break;
case 'w':
v19 = 1;
break;
default:
fwrite("Got Filename\n", 1uLL, 0xDuLL, stderr);
break;
}
}
ptr = malloc(0x2000uLL);
if ( ptr )
{
stream = fopen(v3, "rb");
if ( stream )
{
do
{
v16 = fread(ptr, 0x200uLL, 0x10uLL, stream);
v14 = ftell(stream);
fprintf(stdout, "Read %d record(s)\n", v16);
fprintf(stdout, "File position is %ld\n", v14);
if ( feof(stream) || (v21 = 0, ferror(stream)) )
{
fwrite("EOF reached\n", 1uLL, 0xCuLL, stdout);
v21 = 1;
}
if ( v23 )
{
fwrite("Raw Data:\n", 1uLL, 0xAuLL, stdout);
dump_hex(ptr, v16 << 9, 16LL, 32LL);
}
if ( v16 )
{
v12 = (__int64)ptr;
for ( i = 0LL; i != v16; ++i )
{
v45[0] = v12;
loadseedhdr(v45, v43, 0LL);
v9 = (__int16 *)(v12 + v44);
if ( v44 )
{
do
{
v10 = func0(*v9);
v11 = func0(v9[1]);
if ( v10 == 2000 )
{
v45[0] = (__int64)v9;
loadopaquehdr(v45, v35);
if ( v4 )
{
puts("Found an opaque blockette:");
jprintf(1LL, "Blockette type: %lu\n", (unsigned __int16)v35[0]);
jprintf(1LL, "Next blockette: %lu\n", (unsigned __int16)v35[1]);
jprintf(1LL, "Blockette length: %lu\n", v36);
jprintf(1LL, "Data offset: %lu\n", v37);
jprintf(1LL, "Record number: %lu\n", v38);
v6 = "Big Endian";
if ( !v39 )
v6 = "Little Endian";
jprintf(1LL, "Data word order: %s\n", v6);
jprintf(1LL, "Opaque data flags: 0x%02lx\n", v40);
for ( j = 0LL; j != 5; ++j )
{
v8 = *(&v41 + j);
v29[j] = v8;
if ( !v8 )
break;
if ( v8 == 126 )
break;
}
v29[j + 1] = 0;
jprintf(1LL, "Record type: %s\n", v29);
jprintf(1LL, "========== RECORD DATA ========== \n");
}
v45[0] = (__int64)v9 + v37;
switch ( v41 )
{
case 'G':
if ( v42 == 76 )
{
loadglob(v45, v34);
if ( v24 )
{
jprintf(2LL, "Global Config:\n");
print_global(v34, 3LL, v19);
}
}
break;
case 'F':
if ( v42 == 88 )
{
loadfix(v45, v33);
if ( v25 )
{
jprintf(2LL, "Fixed Config:\n");
print_fixed(v33, 3LL, v19);
}
}
break;
case 'L':
loadlog(v45, v32);
if ( v18 )
{
jprintf(2LL, "Log Config:\n");
print_log(v32, 3LL, v19);
}
break;
case 'T':
append_tokens(v30, (char *)v9 + v37, v36 - (unsigned __int64)v37, v40);
if ( (unsigned __int8)tokens_complete(v30) )
{
if ( v22 )
{
jprintf(2LL, "Token Config:\n");
print_tokens(v30, 3LL, v19);
}
else if ( v26 )
{
jprintf(2LL, "Token Config (manual):\n");
parse_tokens(v30, v27, 3LL);
}
else if ( v27 )
{
jprintf(2LL, "Token Config (raw):\n");
dump_tokens(v30);
}
}
break;
}
}
v9 = (__int16 *)(v12 + v11);
}
while ( v11 );
}
v12 += 512LL;
}
}
}
while ( !v21 );
if ( v28 )
func2();
fclose(stream);
}
else
{
fprintf(stderr, "Unable to open file '%s' for reading.\n", v3);
}
free(ptr);
}
else
{
fwrite("Could not allocate memory for read buffer.\n", 1uLL, 0x2BuLL, stderr);
}
}
return 0;
}

original_code:
int main ( int argc, char **argv )
{
    int file_times;
    int c = 0;
    bool single_file = 0;
    int verbosity = 0;
    if ( argc < 3 ) {
        print_usage( argv, ((void *)0) );
        goto clean;
    }
    while ((c = getopt( argc, argv, "sv" )) != -1) {
        switch (c) {
            case 's':
                single_file = 1;
                break;
            case 'v':
                verbosity++;
                break;
            default:
                fprintf( stderr, "Got Filename\n" );
                break;
        }
    }
    if ( single_file ) {
        diff_in_file( argv[argc - 1], verbosity );
    } else {
        diff_files( argv[argc - 1], argv[argc - 2], verbosity );
    }
clean:
    return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
    int file_times;
    int c = 0;
    unsigned char single_file = 0;
    int verbosity = 0;
    if ( argc < 3 ) {
        print_usage( argv, ((void *)0) );
        goto clean;
    }
    while ((c = getopt( argc, argv, "sv" )) != -1) {
        switch (c) {
            case 's':
                single_file = 1;
                break;
            case 'v':
                verbosity++;
                break;
            default:
                fprintf( stderr, "Got Filename\n" );
                break;
        }
    }
    if ( single_file ) {
        diff_in_file( argv[argc - 1], verbosity );
    } else {
        diff_files( argv[argc - 1], argv[argc - 2], verbosity );
    }
clean:
    return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: c int

variable_types: verbosity int


decompiled_code:
__int64 __fastcall get_page(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
__int64 v3; // rax

v2 = url_resource_new();
v3 = url_new();
*(_QWORD *)v2 = v3;
url_init(v3, a1);
*(_BYTE *)(v2 + 40) |= 0x14u;
http_transfer(v2, a2);
url_resource_destroy(v2);
buffer_seek_end(a2);
return buffer_terminate(a2);
}

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

v2 = url_resource_new();
v3 = url_new();
*(_QWORD *)v2 = v3;
url_init(v3, a1);
*(_BYTE *)(v2 + 40) |= 0x14u;
http_transfer(v2, a2);
url_resource_destroy(v2);
buffer_seek_end(a2);
return buffer_terminate(a2);
}

original_code:
void get_page( char* url_str, buffer_t* buf )
{
    UrlResource* rsc;
    rsc = (UrlResource*)url_resource_new();
    rsc->url = (Url*)url_new();
    url_init(rsc->url, url_str);
    rsc->options |= (1 << 4) | (1 << 2);
    http_transfer(rsc, buf);
    url_resource_destroy(rsc);
    rsc = ((void *)0);
    buffer_seek_end(buf);
    buffer_terminate(buf);
}

canonical_original_code:
void get_page(char *url_str, struct _buffer *buf)
{
    struct _UrlResource *rsc;
    rsc = (struct _UrlResource *)url_resource_new();
    rsc->url = (struct _Url *)url_new();
    url_init(rsc->url, url_str);
    rsc->options |= (1 << 4) | (1 << 2);
    http_transfer(rsc, buf);
    url_resource_destroy(rsc);
    rsc = ((void *)0);
    buffer_seek_end(buf);
    buffer_terminate(buf);
}

variable_types: struct _buffer { unsigned char *content; unsigned long length; unsigned long capacity; unsigned long offset; } *

variable_types: struct _UrlResource { struct _Url { char *full_url; int service_type; char *username; char *password; char *host; int port; char *path; char *file; } *url; char *outfile; char *proxy; char *proxy_username; char *proxy_password; unsigned char options; long outfile_size; long outfile_offset; } *

user_defined_types: struct _UrlResource { struct _Url *url; char *outfile; char *proxy; char *proxy_username; char *proxy_password; unsigned char options; long outfile_size; long outfile_offset; }


WildMatch

original_code:
int WildMatch(char *pattern, char *target)
{
 int link[1025];
 register int first, last;
 register int here, next;
 char lowch;
 first = last = 0;
 link[0] = -1;
 for (; *target; ++target)
 {
  lowch = tolower(*target);
  last = -1;
  for (here = first; here >= 0; here = next)
  {
   next = link[here];
   switch (pattern[here])
   {
   case '*':
    if (next != here + 1)
    {
     link[here + 1] = next;
     next = here + 1;
    }
    break;
   default:
    if (tolower(pattern[here]) != lowch)
     continue;
   case '?':
    ++here;
    break;
   }
   if (last < 0)
    first = here;
   else
    link[last] = here;
   last = here;
  }
  if (last == -1) return(0);
  link[last] = -1;
 }
 while (pattern[last] == '*')
  ++last;
 return(pattern[last] == '\0');
}

canonical_original_code:
int WildMatch(char *pattern, char *target)
{
 int link[1025];
 register int first; register int last;
 register int here; register int next;
 char lowch;
 first = last = 0;
 link[0] = -1;
 for (; *target; ++target)
 {
  lowch = tolower(*target);
  last = -1;
  for (here = first; here >= 0; here = next)
  {
   next = link[here];
   switch (pattern[here])
   {
   case '*':
    if (next != here + 1)
    {
     link[here + 1] = next;
     next = here + 1;
    }
    break;
   default:
    if (tolower(pattern[here]) != lowch)
     continue;
   case '?':
    ++here;
    break;
   }
   if (last < 0)
    first = here;
   else
    link[last] = here;
   last = here;
  }
  if (last == -1) return(0);
  link[last] = -1;
 }
 while (pattern[last] == '*')
  ++last;
 return(pattern[last] == '\0');
}

variable_types:
pattern
char *

variable_types:
target
char *

variable_types:
link
int [1025]

variable_types: first int

variable_types: last int

variable_types: here int

variable_types: next int

variable_types: lowch char


decompiled_code:
char *__fastcall ST_PrintDate2(unsigned __int64 a1, __int16 a2, char a3)
{
__int16 v3; // r13
unsigned int v4; // ebx
unsigned __int64 v5; // rbp
unsigned __int64 v6; // r12
unsigned __int64 v7; // rdi
char s[48]; // [rsp+18h] [rbp-30h] BYREF

v3 = a1;
v4 = WORD1(a1);
v5 = HIDWORD(a1);
v6 = a1 >> 40;
v7 = HIWORD(a1);
if ( a3 )
{
sprintf(
odata_0,
"%04d,%03d,%02d:%02d:%02d.%04d",
(unsigned int)v3,
(unsigned int)(__int16)v4,
(unsigned int)(char)v5,
(unsigned int)(char)v6,
(unsigned int)(char)v7,
(unsigned int)a2);
}
else
{
if ( a2 )
{
if ( a2 == 1000 * (a2 / 1000LL) )
{
sprintf(s, ".%01d", (unsigned int)(a2 / 1000));
}
else if ( a2 == 100 * (a2 / 100LL) )
{
sprintf(s, ".%02d", (unsigned int)(a2 / 100));
}
else if ( a2 == 10 * (a2 / 10LL) )
{
sprintf(s, ".%03d", (unsigned int)(a2 / 10));
}
else
{
sprintf(s, ".%04d", (unsigned int)a2);
}
}
else
{
s[0] = 0;
}
sprintf(
odata_0,
"%d,%d,%d:%02d:%02d%s",
(unsigned int)v3,
(unsigned int)(__int16)v4,
(unsigned int)(char)v5,
(unsigned int)(char)v6,
(unsigned int)(char)v7,
s);
}
return odata_0;
}

canonical_decompiled_code:
char *__fastcall func0(unsigned __int64 a1, __int16 a2, char a3)
{
__int16 v3; // r13
unsigned int v4; // ebx
unsigned __int64 v5; // rbp
unsigned __int64 v6; // r12
unsigned __int64 v7; // rdi
char s[48]; // [rsp+18h] [rbp-30h] BYREF

v3 = a1;
v4 = WORD1(a1);
v5 = HIDWORD(a1);
v6 = a1 >> 40;
v7 = HIWORD(a1);
if ( a3 )
{
sprintf(
odata_0,
"%04d,%03d,%02d:%02d:%02d.%04d",
(unsigned int)v3,
(unsigned int)(__int16)v4,
(unsigned int)(char)v5,
(unsigned int)(char)v6,
(unsigned int)(char)v7,
(unsigned int)a2);
}
else
{
if ( a2 )
{
if ( a2 == 1000 * (a2 / 1000LL) )
{
sprintf(s, ".%01d", (unsigned int)(a2 / 1000));
}
else if ( a2 == 100 * (a2 / 100LL) )
{
sprintf(s, ".%02d", (unsigned int)(a2 / 100));
}
else if ( a2 == 10 * (a2 / 10LL) )
{
sprintf(s, ".%03d", (unsigned int)(a2 / 10));
}
else
{
sprintf(s, ".%04d", (unsigned int)a2);
}
}
else
{
s[0] = 0;
}
sprintf(
odata_0,
"%d,%d,%d:%02d:%02d%s",
(unsigned int)v3,
(unsigned int)(__int16)v4,
(unsigned int)(char)v5,
(unsigned int)(char)v6,
(unsigned int)(char)v7,
s);
}
return odata_0;
}

original_code:
UBYTE *ST_PrintDate2(STDTIME2 odate, BOOL fixfmt) {
  static UBYTE _odata[60];
  long tenth_ms;
  UBYTE msprt[8];
  if (fixfmt) {
    sprintf(_odata,"%04d,%03d,%02d:%02d:%02d.%04d",
     (int) odate.year,
     (int) odate.day,
     (int) odate.hour,
     (int) odate.minute,
     (int) odate.second,
     (int) odate.tenth_msec);
    return(_odata);
  }
  tenth_ms = odate.tenth_msec;
  if (tenth_ms == 0)
    msprt[0] = '\0';
  else
    if (tenth_ms%1000 == 0)
      sprintf(msprt,".%01d", (int)tenth_ms/1000);
    else
      if (tenth_ms%100 == 0)
        sprintf(msprt,".%02d", (int) tenth_ms/100);
      else
        if (tenth_ms%10 == 0)
          sprintf(msprt,".%03d", (int) tenth_ms/10);
        else
          sprintf(msprt,".%04d", (int) tenth_ms);
  sprintf(_odata,"%d,%d,%d:%02d:%02d%s",
   (int) odate.year,
   (int) odate.day,
   (int) odate.hour,
   (int) odate.minute,
   (int) odate.second,
   msprt);
  return(_odata);
}

canonical_original_code:
unsigned char *ST_PrintDate2(struct __sjtim2 odate, unsigned char fixfmt) {
  static unsigned char _odata[60];
  long tenth_ms;
  unsigned char msprt[8];
  if (fixfmt) {
    sprintf(_odata,"%04d,%03d,%02d:%02d:%02d.%04d",
     (int) odate.year,
     (int) odate.day,
     (int) odate.hour,
     (int) odate.minute,
     (int) odate.second,
     (int) odate.tenth_msec);
    return(_odata);
  }
  tenth_ms = odate.tenth_msec;
  if (tenth_ms == 0)
    msprt[0] = '\0';
  else
    if (tenth_ms%1000 == 0)
      sprintf(msprt,".%01d", (int)tenth_ms/1000);
    else
      if (tenth_ms%100 == 0)
        sprintf(msprt,".%02d", (int) tenth_ms/100);
      else
        if (tenth_ms%10 == 0)
          sprintf(msprt,".%03d", (int) tenth_ms/10);
        else
          sprintf(msprt,".%04d", (int) tenth_ms);
  sprintf(_odata,"%d,%d,%d:%02d:%02d%s",
   (int) odate.year,
   (int) odate.day,
   (int) odate.hour,
   (int) odate.minute,
   (int) odate.second,
   msprt);
  return(_odata);
}

variable_types: struct __sjtim2 { short year; short day; char hour; char minute; char second; short tenth_msec; }

variable_types:
fixfmt
unsigned char

variable_types:
msprt
unsigned char [8]

return_type: unsigned char *


push

decompiled_code:
int __fastcall push(double a1)
{
int result; // eax

result = dword_404380;
if ( dword_404380 > 99 )
return printf("error: stack full, can't push %g\n", a1);
++dword_404380;
val[result] = a1;
return result;
}

canonical_decompiled_code:
int __fastcall func7(double a1)
{
int result; // eax

result = dword_404380;
if ( dword_404380 > 99 )
return printf("error: stack full, can't push %g\n", a1);
++dword_404380;
val[result] = a1;
return result;
}

original_code:
void push(double f)
{
 if(sp < 100){
  val[sp++] = f;
 }
 else{
  printf("error: stack full, can't push %g\n",f);
 }
}

variable_types: f double


pop

decompiled_code:
double pop()
{
int v0; // eax
double result; // xmm0_8

v0 = dword_404380;
if ( dword_404380 <= 0 )
{
puts("error: stack empty");
result = 0.0;
}
else
{
--dword_404380;
result = val[v0 - 1];
}
return result;
}

canonical_decompiled_code:
double func8()
{
int v0; // eax
double result; // xmm0_8

v0 = dword_404380;
if ( dword_404380 <= 0 )
{
puts("error: stack empty");
result = 0.0;
}
else
{
--dword_404380;
result = val[v0 - 1];
}
return result;
}

original_code:
double pop()
{
 if(sp > 0){
  return val[--sp];
 }
 else {
  printf("error: stack empty\n");
  return 0.0;
 }
}

return_type: double


peek

decompiled_code:
double peek()
{
if ( dword_404380 > 0 )
return val[dword_404380 - 1];
puts("error: stack empty");
return 0.0;
}

canonical_decompiled_code:
double func9()
{
if ( dword_404380 > 0 )
return val[dword_404380 - 1];
puts("error: stack empty");
return 0.0;
}

original_code:
double peek()
{
 if(sp > 0){
  return val[sp-1];
 }
 else {
  printf("error: stack empty\n");
  return 0.0;
 }
}


switchtoptwo

decompiled_code:
int switchtoptwo()
{
__int64 v0; // rdx
double v1; // xmm0_8
int result; // eax

if ( dword_404380 <= 1 )
return puts("error: insufficient number of elements in stack. ");
v0 = dword_404380 - 1;
v1 = val[v0];
result = dword_404380 - 2;
val[v0] = val[dword_404380 - 2];
val[result] = v1;
return result;
}

canonical_decompiled_code:
int func10()
{
__int64 v0; // rdx
double v1; // xmm0_8
int result; // eax

if ( dword_404380 <= 1 )
return puts("error: insufficient number of elements in stack. ");
v0 = dword_404380 - 1;
v1 = val[v0];
result = dword_404380 - 2;
val[v0] = val[dword_404380 - 2];
val[result] = v1;
return result;
}

original_code:
void switchtoptwo()
{
 double temp;
 if(sp > 1){
  temp = val[sp -1];
  val[sp -1] = val[sp -2];
  val[sp -2] = temp;
 }
 else{
  printf("error: insufficient number of elements in stack. \n");
 }
}

variable_types: temp double


clearstack

decompiled_code:
void clearstack()
{
dword_404380 = 0;
}

original_code:
void clearstack()
{
 sp = 0;
}

canonical_original_code:
void clearstack()
{
 sp = 0;
}


ungets

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

result = strlen(a1);
if ( result > 0 )
{
v2 = (char *)&a1[result - 1];
v3 = (__int64)&a1[result - 2 - (result - 1)];
do
result = ungetch(*v2--);
while ( v2 != (char *)v3 );
}
return result;
}

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

result = strlen(a1);
if ( result > 0 )
{
v2 = (char *)&a1[result - 1];
v3 = (__int64)&a1[result - 2 - (result - 1)];
do
result = func8(*v2--);
while ( v2 != (char *)v3 );
}
return result;
}

original_code:
void ungets(char s[])
{
 int i = strlen(s);
 while(i-- > 0){
  ungetch(s[i]);
 }
}

variable_types:
s
char []

variable_types: i int


getch

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

v0 = bufp;
if ( bufp <= 0 )
return getchar();
--bufp;
return buf[v0 - 1];
}

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

v0 = bufp;
if ( bufp <= 0 )
return getchar();
--bufp;
return buf[v0 - 1];
}

original_code:
int getch()
{
 return (bufp > 0)? buf[--bufp]: getchar();
}


ungetch

decompiled_code:
int __fastcall ungetch(char a1)
{
int result; // eax

result = bufp;
if ( bufp > 99 )
return puts("ungetch: too many characters!");
++bufp;
buf[result] = a1;
return result;
}

canonical_decompiled_code:
int __fastcall func8(char a1)
{
int result; // eax

result = bufp;
if ( bufp > 99 )
return puts("ungetch: too many characters!");
++bufp;
buf[result] = a1;
return result;
}

original_code:
void ungetch(int c)
{
 if(bufp >= 100){
  printf("ungetch: too many characters!\n");
 }
 else{
  buf[bufp++] = c;
 }
}

variable_types: c int


push

decompiled_code:
int __fastcall push(double a1)
{
int result; // eax

result = dword_4044A0;
if ( dword_4044A0 > 99 )
return printf("error: stack full, can't push %g\n", a1);
++dword_4044A0;
val[result] = a1;
return result;
}

canonical_decompiled_code:
int __fastcall func7(double a1)
{
int result; // eax

result = dword_4044A0;
if ( dword_4044A0 > 99 )
return printf("error: stack full, can't push %g\n", a1);
++dword_4044A0;
val[result] = a1;
return result;
}

canonical_original_code:
void push(double f)
{
 if(sp < 100){
  val[sp++] = f;
 }
 else{
  printf("error: stack full, can't push %g\n",f);
 }
}


pop

decompiled_code:
double pop()
{
int v0; // eax
double result; // xmm0_8

v0 = dword_4044A0;
if ( dword_4044A0 <= 0 )
{
puts("error: stack empty");
result = 0.0;
}
else
{
--dword_4044A0;
result = val[v0 - 1];
}
return result;
}

canonical_decompiled_code:
double func8()
{
int v0; // eax
double result; // xmm0_8

v0 = dword_4044A0;
if ( dword_4044A0 <= 0 )
{
puts("error: stack empty");
result = 0.0;
}
else
{
--dword_4044A0;
result = val[v0 - 1];
}
return result;
}

canonical_original_code:
double pop()
{
 if(sp > 0){
  return val[--sp];
 }
 else {
  printf("error: stack empty\n");
  return 0.0;
 }
}


mathfunctions

decompiled_code:
double __fastcall mathfunctions(const char *a1)
{
double result; // xmm0_8
double v2; // rbx
double v3; // xmm0_8
double v4; // xmm1_8
double v5; // xmm0_8
double v6; // xmm0_8
double v7; // xmm0_8
double v8; // xmm0_8
double v9; // xmm0_8
double v10; // xmm0_8
double v11; // xmm0_8
double v12; // xmm0_8
double v13; // xmm0_8
double v14; // xmm0_8
double v15; // xmm0_8
double v16; // xmm0_8
double v17; // xmm0_8
double v18; // xmm0_8

if ( !strcmp(a1, "sin") )
{
v6 = pop();
return sin(v6);
}
if ( !strcmp(a1, "cos") )
{
v7 = pop();
return cos(v7);
}
if ( !strcmp(a1, "tan") )
{
v8 = pop();
return tan(v8);
}
if ( !strcmp(a1, "asin") )
{
v9 = pop();
if ( v9 <= 1.0 && v9 >= -1.0 )
return asin(v9);
goto LABEL_28;
}
if ( !strcmp(a1, "acos") )
{
v10 = pop();
if ( v10 <= 1.0 && v10 >= -1.0 )
return acos(v10);
LABEL_28:
printf("Input outside of function range");
return 0.0;
}
if ( !strcmp(a1, "atan") )
{
v11 = pop();
return atan(v11);
}
if ( !strcmp(a1, "sinh") )
{
v12 = pop();
return sinh(v12);
}
if ( !strcmp(a1, "cosh") )
{
v13 = pop();
return cosh(v13);
}
if ( !strcmp(a1, "tanh") )
{
v14 = pop();
return tanh(v14);
}
if ( !strcmp(a1, "exp") )
{
v15 = pop();
return exp(v15);
}
if ( !strcmp(a1, "log") )
{
v16 = pop();
if ( v16 > 0.0 )
return log(v16);
goto LABEL_41;
}
if ( !strcmp(a1, "log10") )
{
v17 = pop();
if ( v17 > 0.0 )
return log10(v17);
LABEL_41:
printf("Input must be greater than zero");
return 0.0;
}
if ( !strcmp(a1, "sqrt") )
{
v18 = pop();
if ( v18 < 0.0 )
{
printf("Input must be equal or greater than zero");
result = 0.0;
}
else
{
result = sqrt(v18);
}
}
else
{
result = 0.0;
if ( strcmp(a1, "ceil") && strcmp(a1, "floor") )
{
if ( !strcmp(a1, "pow") )
{
v2 = pop();
v3 = pop();
v4 = v3;
if ( v2 == 0.0 && v3 < 0.0 || v2 <= 0.0 && (v5 = v3 - (double)(int)v3, v5 != 0.0) )
{
printf("Domain error");
result = 0.0;
}
else
{
result = pow(v2, v4);
}
}
else
{
printf("error: unkown command %s\n", a1);
result = 0.0;
}
}
}
return result;
}

canonical_decompiled_code:
double __fastcall func12(const char *a1)
{
double result; // xmm0_8
double v2; // rbx
double v3; // xmm0_8
double v4; // xmm1_8
double v5; // xmm0_8
double v6; // xmm0_8
double v7; // xmm0_8
double v8; // xmm0_8
double v9; // xmm0_8
double v10; // xmm0_8
double v11; // xmm0_8
double v12; // xmm0_8
double v13; // xmm0_8
double v14; // xmm0_8
double v15; // xmm0_8
double v16; // xmm0_8
double v17; // xmm0_8
double v18; // xmm0_8

if ( !strcmp(a1, "sin") )
{
v6 = func8();
return sin(v6);
}
if ( !strcmp(a1, "cos") )
{
v7 = func8();
return cos(v7);
}
if ( !strcmp(a1, "tan") )
{
v8 = func8();
return tan(v8);
}
if ( !strcmp(a1, "asin") )
{
v9 = func8();
if ( v9 <= 1.0 && v9 >= -1.0 )
return asin(v9);
goto LABEL_28;
}
if ( !strcmp(a1, "acos") )
{
v10 = func8();
if ( v10 <= 1.0 && v10 >= -1.0 )
return acos(v10);
LABEL_28:
printf("Input outside of function range");
return 0.0;
}
if ( !strcmp(a1, "atan") )
{
v11 = func8();
return atan(v11);
}
if ( !strcmp(a1, "sinh") )
{
v12 = func8();
return sinh(v12);
}
if ( !strcmp(a1, "cosh") )
{
v13 = func8();
return cosh(v13);
}
if ( !strcmp(a1, "tanh") )
{
v14 = func8();
return tanh(v14);
}
if ( !strcmp(a1, "exp") )
{
v15 = func8();
return exp(v15);
}
if ( !strcmp(a1, "log") )
{
v16 = func8();
if ( v16 > 0.0 )
return log(v16);
goto LABEL_41;
}
if ( !strcmp(a1, "log10") )
{
v17 = func8();
if ( v17 > 0.0 )
return log10(v17);
LABEL_41:
printf("Input must be greater than zero");
return 0.0;
}
if ( !strcmp(a1, "sqrt") )
{
v18 = func8();
if ( v18 < 0.0 )
{
printf("Input must be equal or greater than zero");
result = 0.0;
}
else
{
result = sqrt(v18);
}
}
else
{
result = 0.0;
if ( strcmp(a1, "ceil") && strcmp(a1, "floor") )
{
if ( !strcmp(a1, "pow") )
{
v2 = func8();
v3 = func8();
v4 = v3;
if ( v2 == 0.0 && v3 < 0.0 || v2 <= 0.0 && (v5 = v3 - (double)(int)v3, v5 != 0.0) )
{
printf("Domain error");
result = 0.0;
}
else
{
result = pow(v2, v4);
}
}
else
{
printf("error: unkown command %s\n", a1);
result = 0.0;
}
}
}
return result;
}

original_code:
double mathfunctions(char s[])
{
 double pop(void);
 double op1,op2;
 op1 = op2 = 0;
 if(strcmp(s,"sin")== 0){
  return sin(pop());
 }
 else if(strcmp(s,"cos")==0){
  return cos(pop());
 }
 else if(strcmp(s,"tan")==0){
  return tan(pop());
 }
 else if(strcmp(s,"asin")==0){
  op1 = pop();
  if(op1 <= 1.0 && op1 >= -1.0){
   return asin(op1);
  }
  else{
   printf("Input outside of function range");
   return 0.0;
  }
 }
 else if(strcmp(s,"acos")==0){
  op1 = pop();
  if(op1 <= 1.0 && op1 >= -1.0){
   return acos(op1);
  }
  else{
   printf("Input outside of function range");
  }
 }
 else if(strcmp(s,"atan")==0){
  return atan(pop());
 }
 else if(strcmp(s,"sinh")==0){
  return sinh(pop());
 }
 else if(strcmp(s,"cosh")==0){
  return cosh(pop());
 }
 else if(strcmp(s,"tanh")==0){
  return tanh(pop());
 }
 else if(strcmp(s,"exp")==0){
  return exp(pop());
 }
 else if(strcmp(s,"log")==0){
  op1 = pop();
  if(op1 >0){
   return log(op1);
  }
  else{
   printf("Input must be greater than zero");
   return 0.0;
  }
 }
 else if(strcmp(s,"log10")==0){
  op1 = pop();
  if(op1 >0){
   return log10(op1);
  }
  else{
   printf("Input must be greater than zero");
   return 0.0;
  }
 }
 else if(strcmp(s,"sqrt")==0){
  op1 = pop();
  if(op1 >=0){
   return sqrt(op1);
  }
  else{
   printf("Input must be equal or greater than zero");
   return 0.0;
  }
 }
 else if(strcmp(s,"ceil")==0){
  return ceil(op1);
 }
 else if(strcmp(s,"floor")==0){
  return floor(op1);
 }
 else if(strcmp(s,"pow")==0){
  op1 = pop();
  op2 = pop();
  if((op1 != 0 || op2 >= 0)&&(op1>0||(op2 -(int)op2)==0.0)){
   return pow(op1,op2);
  }
  else{
   printf("Domain error");
  }
 }
 else{
  printf("error: unkown command %s\n",s);
 }
 return 0.0;
}

canonical_original_code:
double mathfunctions(char s[])
{
 double pop();
 double op1; double op2;
 op1 = op2 = 0;
 if(strcmp(s,"sin")== 0){
  return sin(pop());
 }
 else if(strcmp(s,"cos")==0){
  return cos(pop());
 }
 else if(strcmp(s,"tan")==0){
  return tan(pop());
 }
 else if(strcmp(s,"asin")==0){
  op1 = pop();
  if(op1 <= 1.0 && op1 >= -1.0){
   return asin(op1);
  }
  else{
   printf("Input outside of function range");
   return 0.0;
  }
 }
 else if(strcmp(s,"acos")==0){
  op1 = pop();
  if(op1 <= 1.0 && op1 >= -1.0){
   return acos(op1);
  }
  else{
   printf("Input outside of function range");
  }
 }
 else if(strcmp(s,"atan")==0){
  return atan(pop());
 }
 else if(strcmp(s,"sinh")==0){
  return sinh(pop());
 }
 else if(strcmp(s,"cosh")==0){
  return cosh(pop());
 }
 else if(strcmp(s,"tanh")==0){
  return tanh(pop());
 }
 else if(strcmp(s,"exp")==0){
  return exp(pop());
 }
 else if(strcmp(s,"log")==0){
  op1 = pop();
  if(op1 >0){
   return log(op1);
  }
  else{
   printf("Input must be greater than zero");
   return 0.0;
  }
 }
 else if(strcmp(s,"log10")==0){
  op1 = pop();
  if(op1 >0){
   return log10(op1);
  }
  else{
   printf("Input must be greater than zero");
   return 0.0;
  }
 }
 else if(strcmp(s,"sqrt")==0){
  op1 = pop();
  if(op1 >=0){
   return sqrt(op1);
  }
  else{
   printf("Input must be equal or greater than zero");
   return 0.0;
  }
 }
 else if(strcmp(s,"ceil")==0){
  return ceil(op1);
 }
 else if(strcmp(s,"floor")==0){
  return floor(op1);
 }
 else if(strcmp(s,"pow")==0){
  op1 = pop();
  op2 = pop();
  if((op1 != 0 || op2 >= 0)&&(op1>0||(op2 -(int)op2)==0.0)){
   return pow(op1,op2);
  }
  else{
   printf("Domain error");
  }
 }
 else{
  printf("error: unkown command %s\n",s);
 }
 return 0.0;
}

variable_types:
pop
double ()


obtenermutex

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

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

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

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; // ebp

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; // ebp

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

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

sops.sem_num = 0;
sops.sem_op = -1;
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

sops.sem_num = 0;
sops.sem_op = -1;
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; }


devolversem

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

sops.sem_num = 0;
sops.sem_op = 1;
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

sops.sem_num = 0;
sops.sem_op = 1;
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;
while ( 1 )
{
if ( (unsigned int)sacar_de_cola((_QWORD **)&cola, &dato) )
{
kill(dato, 15);
wait((__WAIT_STATUS)&stat_loc);
}
if ( !--v4 )
{
v5 = 6;
do
{
wait((__WAIT_STATUS)&stat_loc);
--v5;
}
while ( v5 );
exit(0);
}
}
}
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;
while ( 1 )
{
if ( (unsigned int)func5((_QWORD **)&cola, &dato) )
{
kill(dato, 15);
wait((__WAIT_STATUS)&stat_loc);
}
if ( !--v4 )
{
v5 = 6;
do
{
wait((__WAIT_STATUS)&stat_loc);
--v5;
}
while ( v5 );
exit(0);
}
}
}
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


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; // rdx

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

canonical_decompiled_code:
__int64 __fastcall func5(_QWORD **a1, _DWORD *a2)
{
_QWORD *v3; // rdi
_QWORD *v4; // rdx

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

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 )
exit(0);
piddem = getpid();
v4 = getpid();
printf("PID Demonio: %d", v4);
if ( getpid() == piddem )
{
crear_cola(&cola);
if ( setsid() < 0 )
exit(1);
v6 = 0;
if ( chdir("/") < 0 )
exit(1);
do
{
v7 = fork();
if ( v7 == -1 )
{
puts("Error al crear el hijo");
exit(1);
}
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) )
exit(0);
++v6;
}
while ( v6 != 6 );
signal(15, manejador);
signal(10, manejador);
sigaction(14, &v8, 0LL);
if ( getpid() == piddem )
{
while ( 1 )
pause();
}
}
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 )
exit(0);
piddem = getpid();
v4 = getpid();
printf("PID Demonio: %d", v4);
if ( getpid() == piddem )
{
func0(&cola);
if ( setsid() < 0 )
exit(1);
v6 = 0;
if ( chdir("/") < 0 )
exit(1);
do
{
v7 = fork();
if ( v7 == -1 )
{
puts("Error al crear el hijo");
exit(1);
}
if ( v7 <= 0 )
{
numerodehijo = v6 + 1;
signal(10, manejador);
signal(15, manejador);
while ( 1 )
pause();
}
dato = v7;
if ( !(unsigned int)func2(&cola, &dato) )
exit(0);
++v6;
}
while ( v6 != 6 );
signal(15, manejador);
signal(10, manejador);
sigaction(14, &v8, 0LL);
if ( getpid() == piddem )
{
while ( 1 )
pause();
}
}
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: i 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 )
{
ALTO = stdscr->_maxy + 1;
v0 = stdscr->_maxx + 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 )
{
ALTO = stdscr->_maxy + 1;
v0 = stdscr->_maxx + 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; // ebp
int v1; // er13
int v2; // er14
int v3; // ebx
int v4; // er12
int v5; // er14
int v6; // er14
int v7; // er14
int v8; // er15
int v9; // er14
int i; // er14
int v11; // er14
int v12; // er14
int j; // eax
int v14; // eax
int k; // er15
int v16; // er13
int l; // eax
int v19; // [rsp+Ch] [rbp-4Ch]
int v20; // [rsp+10h] [rbp-48h]
int v21; // [rsp+10h] [rbp-48h]
int v22; // [rsp+18h] [rbp-40h]

v0 = (ANCHO - 72) / 2;
v1 = ALTO / 2;
v22 = ALTO / 2 - 2;
wattr_on(stdscr, 0x100uLL, 0LL);
v2 = v0 + 2;
v3 = v1 - 4;
do
{
if ( wmove(stdscr, v3, v2) != -1 )
waddch(stdscr, 0x20uLL);
v4 = v1 - 1;
if ( wmove(stdscr, v1 - 1, v2) != -1 )
waddch(stdscr, 0x20uLL);
++v2;
}
while ( v2 <= v0 + 5 );
v5 = v0 + 12;
v20 = v0 + 15;
do
{
if ( wmove(stdscr, v3, v5) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v4, v5) != -1 )
waddch(stdscr, 0x20uLL);
++v5;
}
while ( v5 <= v20 );
v6 = v0 + 32;
do
{
if ( wmove(stdscr, v3, v6) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v4, v6) != -1 )
waddch(stdscr, 0x20uLL);
++v6;
}
while ( v6 <= v0 + 35 );
v7 = v0 + 52;
v8 = v1 + 1;
do
{
if ( wmove(stdscr, v3, v7) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v8, v7) != -1 )
waddch(stdscr, 0x20uLL);
++v7;
}
while ( v7 <= v0 + 55 );
v9 = v0 + 66;
do
{
if ( wmove(stdscr, v3, v9) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v8, v9) != -1 )
waddch(stdscr, 0x20uLL);
++v9;
}
while ( v9 <= v0 + 69 );
v19 = v1 - 3;
for ( i = v1 - 3; ; ++i )
{
if ( v4 != i )
{
if ( wmove(stdscr, i, v0 + 17) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, i, v0 + 16) != -1 )
waddch(stdscr, 0x20uLL);
}
if ( v1 < i )
break;
}
v11 = v22;
do
{
if ( wmove(stdscr, v11, v0 + 23) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v11, v0 + 22) != -1 )
waddch(stdscr, 0x20uLL);
++v11;
}
while ( v1 != v11 );
v12 = v1 - 3;
for ( j = wmove(stdscr, v19, v0 + 25); ; j = wmove(stdscr, v14, v0 + 25) )
{
if ( j != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v12, v0 + 24) != -1 )
waddch(stdscr, 0x20uLL);
v14 = v12 + 1;
if ( v1 + 1 == v12 + 1 )
break;
++v12;
}
for ( k = v1 - 4; ; ++k )
{
if ( v22 != k && v4 != k )
{
if ( wmove(stdscr, k, v0 + 27) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, k, v0 + 26) != -1 )
waddch(stdscr, 0x20uLL);
}
if ( k + 1 == v1 + 2 )
break;
}
if ( wmove(stdscr, v1, v20) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v1, v0 + 14) != -1 )
waddch(stdscr, 0x20uLL);
v21 = v1 - 1;
v16 = v1 - 3;
for ( l = wmove(stdscr, v19, v0 + 43); ; l = wmove(stdscr, v16, v0 + 43) )
{
if ( l != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v16, v0 + 42) != -1 )
waddch(stdscr, 0x20uLL);
if ( ++v16 == v21 )
break;
}
while ( 1 )
{
if ( wmove(stdscr, v4, v0 + 45) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v4, v0 + 44) != -1 )
waddch(stdscr, 0x20uLL);
if ( v12 == v4 )
break;
++v4;
}
while ( 1 )
{
if ( wmove(stdscr, v19, v0 + 71) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v19, v0 + 70) != -1 )
waddch(stdscr, 0x20uLL);
if ( v12 == v19 )
break;
++v19;
}
while ( 1 )
{
if ( wmove(stdscr, v3, v0) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 1) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 6) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 7) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 10) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 11) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 20) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 21) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 30) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 31) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 36) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 37) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 40) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 41) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 46) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 47) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 50) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 51) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 56) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 57) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 60) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 61) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 64) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 65) != -1 )
waddch(stdscr, 0x20uLL);
if ( k == v3 )
break;
++v3;
}
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; // ebp
int v1; // er13
int v2; // er14
int v3; // ebx
int v4; // er12
int v5; // er14
int v6; // er14
int v7; // er14
int v8; // er15
int v9; // er14
int i; // er14
int v11; // er14
int v12; // er14
int j; // eax
int v14; // eax
int k; // er15
int v16; // er13
int l; // eax
int v19; // [rsp+Ch] [rbp-4Ch]
int v20; // [rsp+10h] [rbp-48h]
int v21; // [rsp+10h] [rbp-48h]
int v22; // [rsp+18h] [rbp-40h]

v0 = (ANCHO - 72) / 2;
v1 = ALTO / 2;
v22 = ALTO / 2 - 2;
wattr_on(stdscr, 0x100uLL, 0LL);
v2 = v0 + 2;
v3 = v1 - 4;
do
{
if ( wmove(stdscr, v3, v2) != -1 )
waddch(stdscr, 0x20uLL);
v4 = v1 - 1;
if ( wmove(stdscr, v1 - 1, v2) != -1 )
waddch(stdscr, 0x20uLL);
++v2;
}
while ( v2 <= v0 + 5 );
v5 = v0 + 12;
v20 = v0 + 15;
do
{
if ( wmove(stdscr, v3, v5) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v4, v5) != -1 )
waddch(stdscr, 0x20uLL);
++v5;
}
while ( v5 <= v20 );
v6 = v0 + 32;
do
{
if ( wmove(stdscr, v3, v6) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v4, v6) != -1 )
waddch(stdscr, 0x20uLL);
++v6;
}
while ( v6 <= v0 + 35 );
v7 = v0 + 52;
v8 = v1 + 1;
do
{
if ( wmove(stdscr, v3, v7) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v8, v7) != -1 )
waddch(stdscr, 0x20uLL);
++v7;
}
while ( v7 <= v0 + 55 );
v9 = v0 + 66;
do
{
if ( wmove(stdscr, v3, v9) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v8, v9) != -1 )
waddch(stdscr, 0x20uLL);
++v9;
}
while ( v9 <= v0 + 69 );
v19 = v1 - 3;
for ( i = v1 - 3; ; ++i )
{
if ( v4 != i )
{
if ( wmove(stdscr, i, v0 + 17) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, i, v0 + 16) != -1 )
waddch(stdscr, 0x20uLL);
}
if ( v1 < i )
break;
}
v11 = v22;
do
{
if ( wmove(stdscr, v11, v0 + 23) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v11, v0 + 22) != -1 )
waddch(stdscr, 0x20uLL);
++v11;
}
while ( v1 != v11 );
v12 = v1 - 3;
for ( j = wmove(stdscr, v19, v0 + 25); ; j = wmove(stdscr, v14, v0 + 25) )
{
if ( j != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v12, v0 + 24) != -1 )
waddch(stdscr, 0x20uLL);
v14 = v12 + 1;
if ( v1 + 1 == v12 + 1 )
break;
++v12;
}
for ( k = v1 - 4; ; ++k )
{
if ( v22 != k && v4 != k )
{
if ( wmove(stdscr, k, v0 + 27) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, k, v0 + 26) != -1 )
waddch(stdscr, 0x20uLL);
}
if ( k + 1 == v1 + 2 )
break;
}
if ( wmove(stdscr, v1, v20) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v1, v0 + 14) != -1 )
waddch(stdscr, 0x20uLL);
v21 = v1 - 1;
v16 = v1 - 3;
for ( l = wmove(stdscr, v19, v0 + 43); ; l = wmove(stdscr, v16, v0 + 43) )
{
if ( l != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v16, v0 + 42) != -1 )
waddch(stdscr, 0x20uLL);
if ( ++v16 == v21 )
break;
}
while ( 1 )
{
if ( wmove(stdscr, v4, v0 + 45) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v4, v0 + 44) != -1 )
waddch(stdscr, 0x20uLL);
if ( v12 == v4 )
break;
++v4;
}
while ( 1 )
{
if ( wmove(stdscr, v19, v0 + 71) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v19, v0 + 70) != -1 )
waddch(stdscr, 0x20uLL);
if ( v12 == v19 )
break;
++v19;
}
while ( 1 )
{
if ( wmove(stdscr, v3, v0) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 1) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 6) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 7) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 10) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 11) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 20) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 21) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 30) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 31) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 36) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 37) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 40) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 41) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 46) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 47) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 50) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 51) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 56) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 57) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 60) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 61) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 64) != -1 )
waddch(stdscr, 0x20uLL);
if ( wmove(stdscr, v3, v0 + 65) != -1 )
waddch(stdscr, 0x20uLL);
if ( k == v3 )
break;
++v3;
}
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 v2; // esi
int v3; // esi

if ( a1 == 20 )
{
wattr_on(stdscr, 0x100uLL, 0LL);
v2 = ANCHO - 8;
if ( ANCHO - 8 < 0 )
v2 = ANCHO - 5;
mvprintw(ALTO - 6, (v2 >> 2) - 1, "PLAYER 1");
wattr_off(stdscr, 0x100uLL, 0LL);
LABEL_4:
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);
}
return wrefresh(stdscr);
}
if ( a1 != 21 )
{
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);
return wrefresh(stdscr);
}
goto LABEL_4;
}
wattr_on(stdscr, 0x200uLL, 0LL);
v3 = 3 * ANCHO - 8;
if ( v3 < 0 )
v3 = 3 * ANCHO - 5;
mvprintw(ALTO - 6, (v3 >> 2) - 3, "PLAYER 2");
wattr_off(stdscr, 0x200uLL, 0LL);
return wrefresh(stdscr);
}

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

if ( a1 == 20 )
{
wattr_on(stdscr, 0x100uLL, 0LL);
v2 = ANCHO - 8;
if ( ANCHO - 8 < 0 )
v2 = ANCHO - 5;
mvprintw(ALTO - 6, (v2 >> 2) - 1, "PLAYER 1");
wattr_off(stdscr, 0x100uLL, 0LL);
LABEL_4:
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);
}
return wrefresh(stdscr);
}
if ( a1 != 21 )
{
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);
return wrefresh(stdscr);
}
goto LABEL_4;
}
wattr_on(stdscr, 0x200uLL, 0LL);
v3 = 3 * ANCHO - 8;
if ( v3 < 0 )
v3 = 3 * ANCHO - 5;
mvprintw(ALTO - 6, (v3 >> 2) - 3, "PLAYER 2");
wattr_off(stdscr, 0x200uLL, 0LL);
return wrefresh(stdscr);
}

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");
mvprintw(ALTO - 4, 32, "PLAYER 3");
mvprintw(ALTO - 4, 42, "PLAYER 4");
break;
case ')':
wattr_on(stdscr, 0x200uLL, 0LL);
mvprintw(ALTO - 4, 22, "PLAYER 2");
wattr_off(stdscr, 0x200uLL, 0LL);
mvprintw(ALTO - 4, 12, "PLAYER 1");
mvprintw(ALTO - 4, 32, "PLAYER 3");
mvprintw(ALTO - 4, 42, "PLAYER 4");
return wrefresh(stdscr);
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");
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");
mvprintw(ALTO - 4, 32, "PLAYER 3");
mvprintw(ALTO - 4, 42, "PLAYER 4");
break;
case ')':
wattr_on(stdscr, 0x200uLL, 0LL);
mvprintw(ALTO - 4, 22, "PLAYER 2");
wattr_off(stdscr, 0x200uLL, 0LL);
mvprintw(ALTO - 4, 12, "PLAYER 1");
mvprintw(ALTO - 4, 32, "PLAYER 3");
mvprintw(ALTO - 4, 42, "PLAYER 4");
return wrefresh(stdscr);
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");
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 v3[6]; // [rsp+14h] [rbp-14h] BYREF
char s[14]; // [rsp+1Ah] [rbp-Eh] BYREF

sprintf(s, "%d", HIDWORD(a1));
sprintf(v3, "%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", v3);
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", v3);
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", v3);
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", v3);
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 v3[6]; // [rsp+14h] [rbp-14h] BYREF
char s[14]; // [rsp+1Ah] [rbp-Eh] BYREF

sprintf(s, "%d", HIDWORD(a1));
sprintf(v3, "%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", v3);
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", v3);
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", v3);
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", v3);
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:
wattr_on(stdscr, 0x400uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
goto LABEL_20;
case -3:
wattr_on(stdscr, 0x300uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
goto LABEL_17;
case -2:
wattr_on(stdscr, 0x200uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
goto LABEL_14;
case -1:
wattr_on(stdscr, 0x100uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
goto LABEL_11;
case 0:
wattr_on(stdscr, 0LL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
wattr_off(stdscr, 0LL, 0LL);
return wrefresh(stdscr);
case 1:
wattr_on(stdscr, 0x100uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
LABEL_11:
wattr_off(stdscr, 0x100uLL, 0LL);
break;
case 2:
wattr_on(stdscr, 0x200uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
LABEL_14:
wattr_off(stdscr, 0x200uLL, 0LL);
break;
case 3:
wattr_on(stdscr, 0x300uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
LABEL_17:
wattr_off(stdscr, 0x300uLL, 0LL);
break;
case 4:
wattr_on(stdscr, 0x400uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
LABEL_20:
wattr_off(stdscr, 0x400uLL, 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:
wattr_on(stdscr, 0x400uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
goto LABEL_20;
case -3:
wattr_on(stdscr, 0x300uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
goto LABEL_17;
case -2:
wattr_on(stdscr, 0x200uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
goto LABEL_14;
case -1:
wattr_on(stdscr, 0x100uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
goto LABEL_11;
case 0:
wattr_on(stdscr, 0LL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
wattr_off(stdscr, 0LL, 0LL);
return wrefresh(stdscr);
case 1:
wattr_on(stdscr, 0x100uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
LABEL_11:
wattr_off(stdscr, 0x100uLL, 0LL);
break;
case 2:
wattr_on(stdscr, 0x200uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
LABEL_14:
wattr_off(stdscr, 0x200uLL, 0LL);
break;
case 3:
wattr_on(stdscr, 0x300uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
LABEL_17:
wattr_off(stdscr, 0x300uLL, 0LL);
break;
case 4:
wattr_on(stdscr, 0x400uLL, 0LL);
if ( wmove(stdscr, SHIDWORD(a1), a2) != -1 )
waddch(stdscr, 0x20uLL);
LABEL_20:
wattr_off(stdscr, 0x400uLL, 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