engine

decompiled_code:
int engine()
{
unsigned __int64 v0; // rax
char v1; // bl
void *v2; // rax
unsigned int v3; // er12
unsigned int v4; // ebp
void *v5; // rax
unsigned int v6; // eax
unsigned int v7; // ebx
unsigned int v8; // er13
unsigned int v9; // eax
unsigned int v10; // er15
int v11; // er12
void *v12; // rbp
char *v13; // r14
_QWORD *v14; // r13
char *v15; // rax
int v16; // edx
__int64 v17; // rdi
__int64 v18; // rsi
char v19; // bl
size_t v20; // r14
struct tm *v21; // rax
unsigned int v23; // [rsp+0h] [rbp-108h]
unsigned int v24; // [rsp+4h] [rbp-104h]
int v25; // [rsp+8h] [rbp-100h]
int v26; // [rsp+Ch] [rbp-FCh]
unsigned int v27; // [rsp+14h] [rbp-F4h] BYREF
int v28; // [rsp+18h] [rbp-F0h] BYREF
int v29; // [rsp+1Ch] [rbp-ECh] BYREF
int v30; // [rsp+20h] [rbp-E8h] BYREF
int v31; // [rsp+24h] [rbp-E4h] BYREF
time_t timer; // [rsp+28h] [rbp-E0h] BYREF
struct sigaction v33; // [rsp+30h] [rbp-D8h] BYREF

cursstat_6 = calloc(1uLL, 0x71538uLL);
presstat_5 = (__int64)calloc(1uLL, 0x71538uLL);
devsstat_4 = (__int64)calloc(1uLL, 0x71538uLL);
curplen_3 = (3 * (unsigned int)countprocs()) >> 1;
curpact_2 = calloc((unsigned int)curplen_3, 0x2E0uLL);
ptrverify(cursstat_6, "Malloc failed for current sysstats\n");
ptrverify(presstat_5, "Malloc failed for prev sysstats\n");
ptrverify(devsstat_4, "Malloc failed for deviate sysstats\n");
ptrverify(curpact_2, "Malloc failed for %d procstats\n", (unsigned int)curplen_3);
memset(&v33.sa_mask, 0, 0x90uLL);
v33.sa_handler = (__sighandler_t)getusr1;
sigaction(10, &v33, 0LL);
memset(&v33.sa_mask, 0, 0x90uLL);
v33.sa_handler = (__sighandler_t)getusr2;
sigaction(12, &v33, 0LL);
memset(&v33.sa_mask, 0, 0x90uLL);
v33.sa_handler = (__sighandler_t)getalarm;
LODWORD(v0) = sigaction(14, &v33, 0LL);
if ( *(_QWORD *)&interval )
LODWORD(v0) = alarm(interval);
v1 = midnightflag;
if ( midnightflag )
{
timer = time(0LL);
v21 = localtime(&timer);
*(_QWORD *)&v21->tm_sec = 0x3B0000003BLL;
v21->tm_hour = 23;
v0 = mktime(v21);
timelimit_1 = v0;
}
sampcnt = 0LL;
if ( nsamples )
{
v0 = 0LL;
while ( !v1 || curtime + *(_QWORD *)&interval <= (unsigned __int64)timelimit_1 )
{
if ( v0 && awaittrigger )
pause();
awaittrigger = 1;
pretime = curtime;
curtime = time(0LL);
v2 = cursstat_6;
cursstat_6 = (void *)presstat_5;
presstat_5 = (__int64)v2;
photosyst();
deviatsyst(cursstat_6, presstat_5, devsstat_4);
while ( 1 )
{
v4 = curplen_3;
v5 = memset(curpact_2, 0, 736LL * curplen_3);
v6 = photoproc(v5, v4);
v7 = v6;
if ( v6 != curplen_3 )
break;
v3 = v6 + 100;
curplen_3 = v6 + 100;
curpact_2 = realloc(curpact_2, 736LL * (int)(v6 + 100));
ptrverify(curpact_2, "Realloc failed for %d tasks\n", v3);
}
v8 = v6;
v9 = acctprocnt();
v10 = v9;
v11 = v9;
if ( v9 <= 0x11642 )
{
if ( v9 )
{
v8 = v7 + v9;
v20 = 736LL * v9;
if ( (supportflags & 0x20) != 0 )
{
v26 = netatop_exitstore();
v12 = malloc(v20);
ptrverify(v12, "Malloc failed for %d exited processes\n", v10);
memset(v12, 0, v20);
acctphotoproc(v12, v10);
}
else
{
v12 = malloc(736LL * v9);
ptrverify(v12, "Malloc failed for %d exited processes\n", v10);
memset(v12, 0, v20);
acctphotoproc(v12, v10);
v26 = 0;
}
}
else
{
v26 = 0;
v12 = 0LL;
}
}
else
{
v23 = v9 - 71234;
if ( (supportflags & 0x20) != 0 )
{
v26 = netatop_exitstore();
v12 = malloc(0x31FFDC0uLL);
ptrverify(v12, "Malloc failed for %d exited processes\n", 71234LL);
memset(v12, 0, 0x31FFDC0uLL);
acctphotoproc(v12, 71234LL);
}
else
{
v12 = malloc(0x31FFDC0uLL);
ptrverify(v12, "Malloc failed for %d exited processes\n", 71234LL);
memset(v12, 0, 0x31FFDC0uLL);
acctphotoproc(v12, 71234LL);
v26 = 0;
}
v8 = v7 + 71234;
v10 = 71234;
v11 = 71234;
acctrepos(v23);
}
v13 = (char *)malloc(736LL * v8);
ptrverify(v13, "Malloc failed for %d modified processes\n", v8);
v25 = deviatproc(
curpact_2,
v7,
v12,
v10,
(unsigned int)deviatonly,
v13,
devsstat_4,
&v27,
&v28,
&v29,
&v30,
&v31,
&timer);
v24 = v27;
v14 = malloc(8LL * v27);
ptrverify(v14, "Malloc failed for %d process ptrs\n", v24);
if ( v25 )
{
v15 = v13;
v16 = 0;
do
{
if ( v15[64] )
{
v17 = v16++;
v14[v17] = v15;
}
v15 += 736;
}
while ( v15 != &v13[736 * (v25 - 1) + 736] );
}
v18 = curtime - pretime;
if ( curtime - pretime <= 0 )
v18 = 1LL;
v19 = vis(curtime, v18, devsstat_4, v13, v14);
if ( v11 )
free(v12);
if ( v26 )
netatop_exiterase();
free(v13);
free(v14);
if ( v19 == 114 )
{
sampcnt = -1LL;
curtime = getboot() / (unsigned __int64)(unsigned __int16)hertz;
memset(cursstat_6, 0, 0x71538uLL);
memset(curpact_2, 0, 736LL * curplen_3);
pdb_makeresidue();
pdb_cleanresidue();
}
v0 = sampcnt + 1;
sampcnt = v0;
if ( v0 >= (unsigned int)nsamples )
break;
v1 = midnightflag;
}
}
return v0;
}

canonical_decompiled_code:
int func4()
{
unsigned __int64 v0; // rax
char v1; // bl
void *v2; // rax
unsigned int v3; // er12
unsigned int v4; // ebp
void *v5; // rax
unsigned int v6; // eax
unsigned int v7; // ebx
unsigned int v8; // er13
unsigned int v9; // eax
unsigned int v10; // er15
int v11; // er12
void *v12; // rbp
char *v13; // r14
_QWORD *v14; // r13
char *v15; // rax
int v16; // edx
__int64 v17; // rdi
__int64 v18; // rsi
char v19; // bl
size_t v20; // r14
struct tm *v21; // rax
unsigned int v23; // [rsp+0h] [rbp-108h]
unsigned int v24; // [rsp+4h] [rbp-104h]
int v25; // [rsp+8h] [rbp-100h]
int v26; // [rsp+Ch] [rbp-FCh]
unsigned int v27; // [rsp+14h] [rbp-F4h] BYREF
int v28; // [rsp+18h] [rbp-F0h] BYREF
int v29; // [rsp+1Ch] [rbp-ECh] BYREF
int v30; // [rsp+20h] [rbp-E8h] BYREF
int v31; // [rsp+24h] [rbp-E4h] BYREF
time_t timer; // [rsp+28h] [rbp-E0h] BYREF
struct sigaction v33; // [rsp+30h] [rbp-D8h] BYREF

cursstat_6 = calloc(1uLL, 0x71538uLL);
presstat_5 = (__int64)calloc(1uLL, 0x71538uLL);
devsstat_4 = (__int64)calloc(1uLL, 0x71538uLL);
curplen_3 = (3 * (unsigned int)countprocs()) >> 1;
curpact_2 = calloc((unsigned int)curplen_3, 0x2E0uLL);
ptrverify(cursstat_6, "Malloc failed for current sysstats\n");
ptrverify(presstat_5, "Malloc failed for prev sysstats\n");
ptrverify(devsstat_4, "Malloc failed for deviate sysstats\n");
ptrverify(curpact_2, "Malloc failed for %d procstats\n", (unsigned int)curplen_3);
memset(&v33.sa_mask, 0, 0x90uLL);
v33.sa_handler = (__sighandler_t)getusr1;
sigaction(10, &v33, 0LL);
memset(&v33.sa_mask, 0, 0x90uLL);
v33.sa_handler = (__sighandler_t)getusr2;
sigaction(12, &v33, 0LL);
memset(&v33.sa_mask, 0, 0x90uLL);
v33.sa_handler = (__sighandler_t)getalarm;
LODWORD(v0) = sigaction(14, &v33, 0LL);
if ( *(_QWORD *)&interval )
LODWORD(v0) = alarm(interval);
v1 = midnightflag;
if ( midnightflag )
{
timer = time(0LL);
v21 = localtime(&timer);
*(_QWORD *)&v21->tm_sec = 0x3B0000003BLL;
v21->tm_hour = 23;
v0 = mktime(v21);
timelimit_1 = v0;
}
sampcnt = 0LL;
if ( nsamples )
{
v0 = 0LL;
while ( !v1 || curtime + *(_QWORD *)&interval <= (unsigned __int64)timelimit_1 )
{
if ( v0 && awaittrigger )
pause();
awaittrigger = 1;
pretime = curtime;
curtime = time(0LL);
v2 = cursstat_6;
cursstat_6 = (void *)presstat_5;
presstat_5 = (__int64)v2;
photosyst();
deviatsyst(cursstat_6, presstat_5, devsstat_4);
while ( 1 )
{
v4 = curplen_3;
v5 = memset(curpact_2, 0, 736LL * curplen_3);
v6 = photoproc(v5, v4);
v7 = v6;
if ( v6 != curplen_3 )
break;
v3 = v6 + 100;
curplen_3 = v6 + 100;
curpact_2 = realloc(curpact_2, 736LL * (int)(v6 + 100));
ptrverify(curpact_2, "Realloc failed for %d tasks\n", v3);
}
v8 = v6;
v9 = acctprocnt();
v10 = v9;
v11 = v9;
if ( v9 <= 0x11642 )
{
if ( v9 )
{
v8 = v7 + v9;
v20 = 736LL * v9;
if ( (supportflags & 0x20) != 0 )
{
v26 = netatop_exitstore();
v12 = malloc(v20);
ptrverify(v12, "Malloc failed for %d exited processes\n", v10);
memset(v12, 0, v20);
acctphotoproc(v12, v10);
}
else
{
v12 = malloc(736LL * v9);
ptrverify(v12, "Malloc failed for %d exited processes\n", v10);
memset(v12, 0, v20);
acctphotoproc(v12, v10);
v26 = 0;
}
}
else
{
v26 = 0;
v12 = 0LL;
}
}
else
{
v23 = v9 - 71234;
if ( (supportflags & 0x20) != 0 )
{
v26 = netatop_exitstore();
v12 = malloc(0x31FFDC0uLL);
ptrverify(v12, "Malloc failed for %d exited processes\n", 71234LL);
memset(v12, 0, 0x31FFDC0uLL);
acctphotoproc(v12, 71234LL);
}
else
{
v12 = malloc(0x31FFDC0uLL);
ptrverify(v12, "Malloc failed for %d exited processes\n", 71234LL);
memset(v12, 0, 0x31FFDC0uLL);
acctphotoproc(v12, 71234LL);
v26 = 0;
}
v8 = v7 + 71234;
v10 = 71234;
v11 = 71234;
acctrepos(v23);
}
v13 = (char *)malloc(736LL * v8);
ptrverify(v13, "Malloc failed for %d modified processes\n", v8);
v25 = deviatproc(
curpact_2,
v7,
v12,
v10,
(unsigned int)deviatonly,
v13,
devsstat_4,
&v27,
&v28,
&v29,
&v30,
&v31,
&timer);
v24 = v27;
v14 = malloc(8LL * v27);
ptrverify(v14, "Malloc failed for %d process ptrs\n", v24);
if ( v25 )
{
v15 = v13;
v16 = 0;
do
{
if ( v15[64] )
{
v17 = v16++;
v14[v17] = v15;
}
v15 += 736;
}
while ( v15 != &v13[736 * (v25 - 1) + 736] );
}
v18 = curtime - pretime;
if ( curtime - pretime <= 0 )
v18 = 1LL;
v19 = vis(curtime, v18, devsstat_4, v13, v14);
if ( v11 )
free(v12);
if ( v26 )
netatop_exiterase();
free(v13);
free(v14);
if ( v19 == 114 )
{
sampcnt = -1LL;
curtime = getboot() / (unsigned __int64)(unsigned __int16)hertz;
memset(cursstat_6, 0, 0x71538uLL);
memset(curpact_2, 0, 736LL * curplen_3);
pdb_makeresidue();
pdb_cleanresidue();
}
v0 = sampcnt + 1;
sampcnt = v0;
if ( v0 >= (unsigned int)nsamples )
break;
v1 = midnightflag;
}
}
return v0;
}

original_code:
static void
engine(void)
{
 int i, j;
 struct sigaction sigact;
 static time_t timelimit;
 void getusr1(int), getusr2(int);
 static struct sstat *cursstat;
 static struct sstat *presstat;
 static struct sstat *devsstat;
 static struct sstat *hlpsstat;
 static struct tstat *curpact;
 static int curplen;
 struct tstat *curpexit;
 struct tstat *devtstat;
 struct tstat **devpstat;
 unsigned int ntask, nexit, nexitnet;
 unsigned int noverflow, ndeviat, nactproc;
 int totproc, totrun, totslpi, totslpu, totzombie;
 cursstat = calloc(1, sizeof(struct sstat));
 presstat = calloc(1, sizeof(struct sstat));
 devsstat = calloc(1, sizeof(struct sstat));
 curplen = countprocs() * 3 / 2;
 curpact = calloc(curplen, sizeof(struct tstat));
 ptrverify(cursstat, "Malloc failed for current sysstats\n");
 ptrverify(presstat, "Malloc failed for prev    sysstats\n");
 ptrverify(devsstat, "Malloc failed for deviate sysstats\n");
 ptrverify(curpact, "Malloc failed for %d procstats\n", curplen);
 memset(&sigact, 0, sizeof sigact);
 sigact.__sigaction_handler.sa_handler = getusr1;
 sigaction(10, &sigact, (struct sigaction *)0);
 memset(&sigact, 0, sizeof sigact);
 sigact.__sigaction_handler.sa_handler = getusr2;
 sigaction(12, &sigact, (struct sigaction *)0);
 memset(&sigact, 0, sizeof sigact);
 sigact.__sigaction_handler.sa_handler = getalarm;
 sigaction(14, &sigact, (struct sigaction *)0);
 if (interval > 0)
  alarm(interval);
 if (midnightflag)
 {
  time_t timenow = time(0);
  struct tm *tp = localtime(&timenow);
  tp->tm_hour = 23;
  tp->tm_min = 59;
  tp->tm_sec = 59;
  timelimit = mktime(tp);
 }
 for (sampcnt=0; sampcnt < nsamples; sampcnt++)
 {
  char lastcmd;
  if (midnightflag && (curtime+interval) > timelimit)
   break;
  if (sampcnt > 0 && awaittrigger)
   pause();
  awaittrigger = 1;
  pretime = curtime;
  curtime = time(0);
  hlpsstat = cursstat;
  cursstat = presstat;
  presstat = hlpsstat;
  photosyst(cursstat);
  deviatsyst(cursstat, presstat, devsstat);
  memset(curpact, 0, curplen * sizeof(struct tstat));
  while ( (ntask = photoproc(curpact, curplen)) == curplen)
  {
   curplen += 100;
   curpact = realloc(curpact,
     curplen * sizeof(struct tstat));
   ptrverify(curpact,
             "Realloc failed for %d tasks\n", curplen);
   memset(curpact, 0, curplen * sizeof(struct tstat));
  }
  nexit = acctprocnt();
  if (nexit > (50*1024*1024/sizeof(struct tstat)))
  {
   noverflow = nexit - (50*1024*1024/sizeof(struct tstat));
   nexit = (50*1024*1024/sizeof(struct tstat));
  }
  else
   noverflow = 0;
  if (nexit > 0 && (supportflags & 0x00000020))
   nexitnet = netatop_exitstore();
  else
   nexitnet = 0;
  if (nexit > 0)
  {
   curpexit = malloc(nexit * sizeof(struct tstat));
   ptrverify(curpexit,
             "Malloc failed for %d exited processes\n",
             nexit);
   memset(curpexit, 0, nexit * sizeof(struct tstat));
   acctphotoproc(curpexit, nexit);
   if (noverflow)
    acctrepos(noverflow);
  }
  else
  {
   curpexit = ((void *)0);
  }
  devtstat = malloc((ntask+nexit) * sizeof(struct tstat));
  ptrverify(devtstat, "Malloc failed for %d modified processes\n",
                 ntask+nexit);
  ndeviat = deviatproc(curpact, ntask, curpexit, nexit,
    deviatonly, devtstat, devsstat, &nactproc,
    &totproc, &totrun, &totslpi, &totslpu,
                  &totzombie);
         devpstat = malloc(sizeof (struct tstat *) * nactproc);
  ptrverify(devpstat, "Malloc failed for %d process ptrs\n",
                 nactproc);
  for (i=0, j=0; i < ndeviat; i++)
  {
   if ( (devtstat+i)->gen.isproc)
    devpstat[j++] = devtstat+i;
  }
  lastcmd = (vis.show_samp)( curtime,
         curtime-pretime > 0 ? curtime-pretime : 1,
                   devsstat, devtstat, devpstat,
                       ndeviat, ntask, nactproc,
                       totproc, totrun, totslpi, totslpu,
                       totzombie, nexit, noverflow, sampcnt==0);
  if (nexit > 0)
   free(curpexit);
  if (nexitnet > 0)
   netatop_exiterase();
  free(devtstat);
  free(devpstat);
  if (lastcmd == 'r')
  {
   sampcnt = -1;
   curtime = getboot() / hertz;
   memset(cursstat, 0, sizeof(struct sstat));
   memset(curpact, 0, curplen * sizeof(struct tstat));
   pdb_makeresidue();
   pdb_cleanresidue();
  }
 }
}

canonical_original_code:
static void engine()
{
 int i; int j;
 struct sigaction sigact;
 static long timelimit;
 void getusr1(int); void getusr2(int);
 static struct sstat *cursstat;
 static struct sstat *presstat;
 static struct sstat *devsstat;
 static struct sstat *hlpsstat;
 static struct tstat *curpact;
 static int curplen;
 struct tstat *curpexit;
 struct tstat *devtstat;
 struct tstat **devpstat;
 unsigned int ntask; unsigned int nexit; unsigned int nexitnet;
 unsigned int noverflow; unsigned int ndeviat; unsigned int nactproc;
 int totproc; int totrun; int totslpi; int totslpu; int totzombie;
 cursstat = calloc(1, sizeof(struct sstat));
 presstat = calloc(1, sizeof(struct sstat));
 devsstat = calloc(1, sizeof(struct sstat));
 curplen = countprocs() * 3 / 2;
 curpact = calloc(curplen, sizeof(struct tstat));
 ptrverify(cursstat, "Malloc failed for current sysstats\n");
 ptrverify(presstat, "Malloc failed for prev    sysstats\n");
 ptrverify(devsstat, "Malloc failed for deviate sysstats\n");
 ptrverify(curpact, "Malloc failed for %d procstats\n", curplen);
 memset(&sigact, 0, sizeof sigact);
 sigact.__sigaction_handler.sa_handler = getusr1;
 sigaction(10, &sigact, (struct sigaction *)0);
 memset(&sigact, 0, sizeof sigact);
 sigact.__sigaction_handler.sa_handler = getusr2;
 sigaction(12, &sigact, (struct sigaction *)0);
 memset(&sigact, 0, sizeof sigact);
 sigact.__sigaction_handler.sa_handler = getalarm;
 sigaction(14, &sigact, (struct sigaction *)0);
 if (interval > 0)
  alarm(interval);
 if (midnightflag)
 {
  long timenow = time(0);
  struct tm *tp = localtime(&timenow);
  tp->tm_hour = 23;
  tp->tm_min = 59;
  tp->tm_sec = 59;
  timelimit = mktime(tp);
 }
 for (sampcnt=0; sampcnt < nsamples; sampcnt++)
 {
  char lastcmd;
  if (midnightflag && (curtime+interval) > timelimit)
   break;
  if (sampcnt > 0 && awaittrigger)
   pause();
  awaittrigger = 1;
  pretime = curtime;
  curtime = time(0);
  hlpsstat = cursstat;
  cursstat = presstat;
  presstat = hlpsstat;
  photosyst(cursstat);
  deviatsyst(cursstat, presstat, devsstat);
  memset(curpact, 0, curplen * sizeof(struct tstat));
  while ( (ntask = photoproc(curpact, curplen)) == curplen)
  {
   curplen += 100;
   curpact = realloc(curpact,
     curplen * sizeof(struct tstat));
   ptrverify(curpact,
             "Realloc failed for %d tasks\n", curplen);
   memset(curpact, 0, curplen * sizeof(struct tstat));
  }
  nexit = acctprocnt();
  if (nexit > (50*1024*1024/sizeof(struct tstat)))
  {
   noverflow = nexit - (50*1024*1024/sizeof(struct tstat));
   nexit = (50*1024*1024/sizeof(struct tstat));
  }
  else
   noverflow = 0;
  if (nexit > 0 && (supportflags & 0x00000020))
   nexitnet = netatop_exitstore();
  else
   nexitnet = 0;
  if (nexit > 0)
  {
   curpexit = malloc(nexit * sizeof(struct tstat));
   ptrverify(curpexit,
             "Malloc failed for %d exited processes\n",
             nexit);
   memset(curpexit, 0, nexit * sizeof(struct tstat));
   acctphotoproc(curpexit, nexit);
   if (noverflow)
    acctrepos(noverflow);
  }
  else
  {
   curpexit = ((void *)0);
  }
  devtstat = malloc((ntask+nexit) * sizeof(struct tstat));
  ptrverify(devtstat, "Malloc failed for %d modified processes\n",
                 ntask+nexit);
  ndeviat = deviatproc(curpact, ntask, curpexit, nexit,
    deviatonly, devtstat, devsstat, &nactproc,
    &totproc, &totrun, &totslpi, &totslpu,
                  &totzombie);
         devpstat = malloc(sizeof (struct tstat *) * nactproc);
  ptrverify(devpstat, "Malloc failed for %d process ptrs\n",
                 nactproc);
  for (i=0, j=0; i < ndeviat; i++)
  {
   if ( (devtstat+i)->gen.isproc)
    devpstat[j++] = devtstat+i;
  }
  lastcmd = (vis.show_samp)( curtime,
         curtime-pretime > 0 ? curtime-pretime : 1,
                   devsstat, devtstat, devpstat,
                       ndeviat, ntask, nactproc,
                       totproc, totrun, totslpi, totslpu,
                       totzombie, nexit, noverflow, sampcnt==0);
  if (nexit > 0)
   free(curpexit);
  if (nexitnet > 0)
   netatop_exiterase();
  free(devtstat);
  free(devpstat);
  if (lastcmd == 'r')
  {
   sampcnt = -1;
   curtime = getboot() / hertz;
   memset(cursstat, 0, sizeof(struct sstat));
   memset(curpact, 0, curplen * sizeof(struct tstat));
   pdb_makeresidue();
   pdb_cleanresidue();
  }
 }
}

variable_types: j 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)(); }

variable_types: timelimit long

variable_types: struct sstat { struct cpustat { long long nrcpu; long long devint; long long csw; long long nprocs; float lavg1; float lavg5; float lavg15; long long cfuture[4]; struct percpu { int cpunr; long long stime; long long utime; long long ntime; long long itime; long long wtime; long long Itime; long long Stime; long long steal; long long guest; struct freqcnt { long long maxfreq; long long cnt; long long ticks; } freqcnt; long long cfuture[1]; } all; struct percpu cpu[2048]; } cpu; struct memstat { long long physmem; long long freemem; long long buffermem; long long slabmem; long long cachemem; long long cachedrt; long long totswap; long long freeswap; long long pgscans; long long pgsteal; long long allocstall; long long swouts; long long swins; long long commitlim; long long committed; long long shmem; long long shmrss; long long shmswp; long long slabreclaim; } mem; struct netstat { struct ipv4_stats { long long Forwarding; long long DefaultTTL; long long InReceives; long long InHdrErrors; long long InAddrErrors; long long ForwDatagrams; long long InUnknownProtos; long long InDiscards; long long InDelivers; long long OutRequests; long long OutDiscards; long long OutNoRoutes; long long ReasmTimeout; long long ReasmReqds; long long ReasmOKs; long long ReasmFails; long long FragOKs; long long FragFails; long long FragCreates; } ipv4; struct icmpv4_stats { long long InMsgs; long long InErrors; long long InDestUnreachs; long long InTimeExcds; long long InParmProbs; long long InSrcQuenchs; long long InRedirects; long long InEchos; long long InEchoReps; long long InTimestamps; long long InTimestampReps; long long InAddrMasks; long long InAddrMaskReps; long long OutMsgs; long long OutErrors; long long OutDestUnreachs; long long OutTimeExcds; long long OutParmProbs; long long OutSrcQuenchs; long long OutRedirects; long long OutEchos; long long OutEchoReps; long long OutTimestamps; long long OutTimestampReps; long long OutAddrMasks; long long OutAddrMaskReps; } icmpv4; struct udpv4_stats { long long InDatagrams; long long NoPorts; long long InErrors; long long OutDatagrams; } udpv4; struct ipv6_stats { long long Ip6InReceives; long long Ip6InHdrErrors; long long Ip6InTooBigErrors; long long Ip6InNoRoutes; long long Ip6InAddrErrors; long long Ip6InUnknownProtos; long long Ip6InTruncatedPkts; long long Ip6InDiscards; long long Ip6InDelivers; long long Ip6OutForwDatagrams; long long Ip6OutRequests; long long Ip6OutDiscards; long long Ip6OutNoRoutes; long long Ip6ReasmTimeout; long long Ip6ReasmReqds; long long Ip6ReasmOKs; long long Ip6ReasmFails; long long Ip6FragOKs; long long Ip6FragFails; long long Ip6FragCreates; long long Ip6InMcastPkts; long long Ip6OutMcastPkts; } ipv6; struct icmpv6_stats { long long Icmp6InMsgs; long long Icmp6InErrors; long long Icmp6InDestUnreachs; long long Icmp6InPktTooBigs; long long Icmp6InTimeExcds; long long Icmp6InParmProblems; long long Icmp6InEchos; long long Icmp6InEchoReplies; long long Icmp6InGroupMembQueries; long long Icmp6InGroupMembResponses; long long Icmp6InGroupMembReductions; long long Icmp6InRouterSolicits; long long Icmp6InRouterAdvertisements; long long Icmp6InNeighborSolicits; long long Icmp6InNeighborAdvertisements; long long Icmp6InRedirects; long long Icmp6OutMsgs; long long Icmp6OutDestUnreachs; long long Icmp6OutPktTooBigs; long long Icmp6OutTimeExcds; long long Icmp6OutParmProblems; long long Icmp6OutEchoReplies; long long Icmp6OutRouterSolicits; long long Icmp6OutNeighborSolicits; long long Icmp6OutNeighborAdvertisements; long long Icmp6OutRedirects; long long Icmp6OutGroupMembResponses; long long Icmp6OutGroupMembReductions; } icmpv6; struct udpv6_stats { long long Udp6InDatagrams; long long Udp6NoPorts; long long Udp6InErrors; long long Udp6OutDatagrams; } udpv6; struct tcp_stats { long long RtoAlgorithm; long long RtoMin; long long RtoMax; long long MaxConn; long long ActiveOpens; long long PassiveOpens; long long AttemptFails; long long EstabResets; long long CurrEstab; long long InSegs; long long OutSegs; long long RetransSegs; long long InErrs; long long OutRsts; } tcp; } net; struct intfstat { int nrintf; struct perintf { char name[16]; long long rbyte; long long rpack; long long rerrs; long long rdrop; long long rfifo; long long rframe; long long rcompr; long long rmultic; long long rfuture[4]; long long sbyte; long long spack; long long serrs; long long sdrop; long long sfifo; long long scollis; long long scarrier; long long scompr; long long sfuture[4]; long speed; char duplex; long long cfuture[4]; } intf[128]; } intf; struct dskstat { int ndsk; int nmdd; int nlvm; struct perdsk { char name[32]; long long nread; long long nrsect; long long nwrite; long long nwsect; long long io_ms; long long avque; long long cfuture[4]; } dsk[512]; struct perdsk mdd[256]; struct perdsk lvm[1024]; } dsk; struct wwwstat { long long accesses; long long totkbytes; long long uptime; int bworkers; int iworkers; } www; } *

variable_types: curplen int

variable_types: struct tstat { struct gen { int tgid; int pid; int ppid; int ruid; int euid; int suid; int fsuid; int rgid; int egid; int sgid; int fsgid; int nthr; char name[-1]; char isproc; char state; int excode; long btime; long elaps; char cmdline[-1]; int nthrslpi; int nthrslpu; int nthrrun; int ifuture[4]; } gen; struct cpu { long long utime; long long stime; int nice; int prio; int rtprio; int policy; int curcpu; int sleepavg; int ifuture[4]; long long cfuture[4]; } cpu; struct dsk { long long rio; long long rsz; long long wio; long long wsz; long long cwsz; long long cfuture[4]; } dsk; struct mem { long long minflt; long long majflt; long long vexec; long long vmem; long long rmem; long long vgrow; long long rgrow; long long vdata; long long vstack; long long vlibs; long long vswap; } mem; struct net { long long tcpsnd; long long tcpssz; long long tcprcv; long long tcprsz; long long udpsnd; long long udpssz; long long udprcv; long long udprsz; long long avail1; long long avail2; long long cfuture[4]; } net; } **

variable_types:
ntask
unsigned int

variable_types:
nexit
unsigned int

variable_types:
nexitnet
unsigned int

variable_types:
noverflow
unsigned int

variable_types:
ndeviat
unsigned int

variable_types:
nactproc
unsigned int

variable_types: totproc int

variable_types: totrun int

variable_types: totslpi int

variable_types: totslpu int

variable_types: totzombie int

variable_types: timenow long

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

variable_types: lastcmd char

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

user_defined_types: struct sstat { struct cpustat cpu; struct memstat mem; struct netstat net; struct intfstat intf; struct dskstat dsk; struct wwwstat www; }

user_defined_types: struct cpustat { long long nrcpu; long long devint; long long csw; long long nprocs; float lavg1; float lavg5; float lavg15; long long cfuture[4]; struct percpu all; struct percpu cpu[2048]; }

user_defined_types: struct netstat { struct ipv4_stats ipv4; struct icmpv4_stats icmpv4; struct udpv4_stats udpv4; struct ipv6_stats ipv6; struct icmpv6_stats icmpv6; struct udpv6_stats udpv6; struct tcp_stats tcp; }

user_defined_types: struct intfstat { int nrintf; struct perintf intf[128]; }

user_defined_types: struct dskstat { int ndsk; int nmdd; int nlvm; struct perdsk dsk[512]; struct perdsk mdd[256]; struct perdsk lvm[1024]; }

user_defined_types: struct percpu { int cpunr; long long stime; long long utime; long long ntime; long long itime; long long wtime; long long Itime; long long Stime; long long steal; long long guest; struct freqcnt freqcnt; long long cfuture[1]; }

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


convtime

repo: samm-git/atop-freebsd

decompiled_code:
char *__fastcall convtime(time_t a1, char *a2)
{
struct tm *v2; // rax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

timer = a1;
v2 = localtime(&timer);
sprintf(a2, "%02d:%02d:%02d", (unsigned int)v2->tm_hour, (unsigned int)v2->tm_min, (unsigned int)v2->tm_sec);
return a2;
}

canonical_decompiled_code:
char *__fastcall func0(time_t a1, char *a2)
{
struct tm *v2; // rax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

timer = a1;
v2 = localtime(&timer);
sprintf(a2, "%02d:%02d:%02d", (unsigned int)v2->tm_hour, (unsigned int)v2->tm_min, (unsigned int)v2->tm_sec);
return a2;
}

original_code:
char *
convtime(time_t utime, char *chartim)
{
 struct tm *tt;
 tt = localtime(&utime);
 sprintf(chartim, "%02d:%02d:%02d", tt->tm_hour, tt->tm_min, tt->tm_sec);
 return chartim;
}

canonical_original_code:
char *convtime(long utime, char *chartim)
{
 struct tm *tt;
 tt = localtime(&utime);
 sprintf(chartim, "%02d:%02d:%02d", tt->tm_hour, tt->tm_min, tt->tm_sec);
 return chartim;
}

variable_types: utime long

variable_types:
chartim
char *

return_type: char *

user_defined_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; }


convdate

decompiled_code:
char *__fastcall convdate(time_t a1, char *a2)
{
struct tm *v2; // rax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

timer = a1;
v2 = localtime(&timer);
sprintf(
a2,
"%04d/%02d/%02d",
(unsigned int)(v2->tm_year + 1900),
(unsigned int)(v2->tm_mon + 1),
(unsigned int)v2->tm_mday);
return a2;
}

canonical_decompiled_code:
char *__fastcall func1(time_t a1, char *a2)
{
struct tm *v2; // rax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

timer = a1;
v2 = localtime(&timer);
sprintf(
a2,
"%04d/%02d/%02d",
(unsigned int)(v2->tm_year + 1900),
(unsigned int)(v2->tm_mon + 1),
(unsigned int)v2->tm_mday);
return a2;
}

original_code:
char *
convdate(time_t utime, char *chardat)
{
 struct tm *tt;
 tt = localtime(&utime);
 sprintf(chardat, "%04d/%02d/%02d",
  tt->tm_year+1900, tt->tm_mon+1, tt->tm_mday);
 return chardat;
}

canonical_original_code:
char *convdate(long utime, char *chardat)
{
 struct tm *tt;
 tt = localtime(&utime);
 sprintf(chardat, "%04d/%02d/%02d",
  tt->tm_year+1900, tt->tm_mon+1, tt->tm_mday);
 return chardat;
}

variable_types:
chardat
char *


decompiled_code:
__int64 __fastcall hhmm2secs(char *a1, _DWORD *a2)
{
char v2; // bl
const unsigned __int16 *v3; // rcx
char *v4; // rax
unsigned int v6; // [rsp+8h] [rbp-20h] BYREF
unsigned int v7; // [rsp+Ch] [rbp-1Ch] BYREF

v2 = *a1;
if ( *a1 )
{
v3 = *_ctype_b_loc();
v4 = a1 + 1;
while ( (v3[v2] & 0x800) != 0 || v2 == 58 )
{
v2 = *v4++;
if ( !v2 )
goto LABEL_6;
}
}
else
{
LABEL_6:
_isoc99_sscanf(a1, "%d:%d", &v6, &v7);
if ( v6 <= 0x17 && v7 <= 0x3B )
{
*a2 = 60 * v7 + 3600 * v6;
return 1LL;
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *a1, _DWORD *a2)
{
char v2; // bl
const unsigned __int16 *v3; // rcx
char *v4; // rax
unsigned int v6; // [rsp+8h] [rbp-20h] BYREF
unsigned int v7; // [rsp+Ch] [rbp-1Ch] BYREF

v2 = *a1;
if ( *a1 )
{
v3 = *_ctype_b_loc();
v4 = a1 + 1;
while ( (v3[v2] & 0x800) != 0 || v2 == 58 )
{
v2 = *v4++;
if ( !v2 )
goto LABEL_6;
}
}
else
{
LABEL_6:
_isoc99_sscanf(a1, "%d:%d", &v6, &v7);
if ( v6 <= 0x17 && v7 <= 0x3B )
{
*a2 = 60 * v7 + 3600 * v6;
return 1LL;
}
}
return 0LL;
}

original_code:
int
hhmm2secs(char *itim, unsigned int *otim)
{
 register int i;
 int hours, minutes;
 for (i=0; *(itim+i); i++)
  if ( !((*__ctype_b_loc ())[(int) ((*(itim+i)))] & (unsigned short int) _ISdigit) && *(itim+i) != ':' )
   return(0);
 sscanf(itim, "%d:%d", &hours, &minutes);
 if ( hours < 0 || hours > 23 || minutes < 0 || minutes > 59 )
  return(0);
 *otim = (hours * 3600) + (minutes * 60);
 if (*otim >= 86400)
  *otim = 86400 -1;
 return(1);
}

canonical_original_code:
int hhmm2secs(char *itim, unsigned int *otim)
{
 register int i;
 int hours; int minutes;
 for (i=0; *(itim+i); i++)
  if ( !((*__ctype_b_loc ())[(int) ((*(itim+i)))] & (unsigned short) _ISdigit) && *(itim+i) != ':' )
   return(0);
 sscanf(itim, "%d:%d", &hours, &minutes);
 if ( hours < 0 || hours > 23 || minutes < 0 || minutes > 59 )
  return(0);
 *otim = (hours * 3600) + (minutes * 60);
 if (*otim >= 86400)
  *otim = 86400 -1;
 return(1);
}

variable_types:
itim
char *

variable_types:
otim
unsigned int *

variable_types: i int

variable_types: hours int

variable_types: minutes int

return_type: int


daysecs

decompiled_code:
__int64 __fastcall daysecs(time_t a1)
{
struct tm *v1; // rax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

timer = a1;
v1 = localtime(&timer);
return (unsigned int)(3600 * v1->tm_hour + 60 * v1->tm_min);
}

canonical_decompiled_code:
__int64 __fastcall func3(time_t a1)
{
struct tm *v1; // rax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

timer = a1;
v1 = localtime(&timer);
return (unsigned int)(3600 * v1->tm_hour + 60 * v1->tm_min);
}

original_code:
int
daysecs(time_t itime)
{
 struct tm *tt;
 tt = localtime(&itime);
 return( (tt->tm_hour*3600) + (tt->tm_min*60) );
}

canonical_original_code:
int daysecs(long itime)
{
 struct tm *tt;
 tt = localtime(&itime);
 return( (tt->tm_hour*3600) + (tt->tm_min*60) );
}

variable_types: itime long


original_code:
char *
val2valstr(count_t value, char *strvalue, int width, int avg, int nsecs)
{
 count_t maxval, remain = 0;
 int exp = 0;
 char *suffix = "";
 if (avg)
 {
  value = (value + (nsecs/2)) / nsecs;
  width = width - 2;
  suffix = "/s";
 }
 maxval = pow(10.0, width) - 1;
 if (value < maxval)
 {
  sprintf(strvalue, "%*lld%s", width, value, suffix);
 }
 else
 {
  if (width < 3)
  {
   sprintf(strvalue, "%lld%s", value, suffix);
  }
  else
  {
   width -= 2;
   maxval = pow(10.0, width) - 1;
   while (value > maxval)
   {
    exp++;
    remain = value % 10;
    value /= 10;
   }
   if (remain >= 5)
    value++;
   sprintf(strvalue, "%*llde%d%s",
     width, value, exp, suffix);
  }
 }
 return strvalue;
}

canonical_original_code:
char *val2valstr(long long value, char *strvalue, int width, int avg, int nsecs)
{
 long long maxval; long long remain = 0;
 int exp = 0;
 char *suffix = "";
 if (avg)
 {
  value = (value + (nsecs/2)) / nsecs;
  width = width - 2;
  suffix = "/s";
 }
 maxval = pow(10.0, width) - 1;
 if (value < maxval)
 {
  sprintf(strvalue, "%*lld%s", width, value, suffix);
 }
 else
 {
  if (width < 3)
  {
   sprintf(strvalue, "%lld%s", value, suffix);
  }
  else
  {
   width -= 2;
   maxval = pow(10.0, width) - 1;
   while (value > maxval)
   {
    exp++;
    remain = value % 10;
    value /= 10;
   }
   if (remain >= 5)
    value++;
   sprintf(strvalue, "%*llde%d%s",
     width, value, exp, suffix);
  }
 }
 return strvalue;
}

variable_types:
value
long long

variable_types:
strvalue
char *

variable_types: width int

variable_types: avg int

variable_types: nsecs int

variable_types:
maxval
long long

variable_types:
remain
long long

variable_types: exp int

variable_types:
suffix
char *


decompiled_code:
__int64 __fastcall val2elapstr(int a1, char *a2)
{
unsigned int v2; // er12
char *v4; // r13
__int64 v5; // rdx
int v6; // er14
char *v7; // rbx
__int64 v8; // rdx
int v9; // er13
char *v10; // rbx

v2 = a1;
if ( a1 > 86400 )
{
v4 = &a2[sprintf(a2, "%dd", (unsigned int)(a1 / 86400))];
v2 = a1 % 86400;
LABEL_7:
v5 = v2 / 0xE10;
v6 = 3600 * v5;
v7 = &v4[sprintf(v4, "%dh", v5)];
v2 -= v6;
LABEL_8:
v8 = v2 / 0x3C;
v9 = 60 * v8;
v10 = &v7[sprintf(v7, "%dm", v8)];
v2 -= v9;
return (unsigned int)(sprintf(v10, "%ds", v2) + (_DWORD)v10 - (_DWORD)a2);
}
if ( a1 > 3600 )
{
v4 = a2;
goto LABEL_7;
}
if ( a1 > 60 )
{
v7 = a2;
goto LABEL_8;
}
if ( !a1 )
return 0LL;
v10 = a2;
return (unsigned int)(sprintf(v10, "%ds", v2) + (_DWORD)v10 - (_DWORD)a2);
}

original_code:
int
val2elapstr(int value, char *strvalue)
{
        char *p=strvalue, doshow=0;
        if (value > (24*60*60))
        {
                p+=sprintf(p, "%dd", value/(24*60*60));
                value %= (24*60*60);
  doshow = 1;
        }
        if (value > (60*60) || doshow)
        {
                p+=sprintf(p, "%dh", value/(60*60));
                value %= (60*60);
  doshow = 1;
        }
        if (value > (60) || doshow)
        {
                p+=sprintf(p, "%dm", value/(60));
                value %= (60);
  doshow = 1;
        }
        if (value || doshow)
        {
                p+=sprintf(p, "%ds", value);
  doshow = 1;
        }
        return p-strvalue;
}

canonical_original_code:
int val2elapstr(int value, char *strvalue)
{
        char *p = strvalue; char doshow = 0;
        if (value > (24*60*60))
        {
                p+=sprintf(p, "%dd", value/(24*60*60));
                value %= (24*60*60);
  doshow = 1;
        }
        if (value > (60*60) || doshow)
        {
                p+=sprintf(p, "%dh", value/(60*60));
                value %= (60*60);
  doshow = 1;
        }
        if (value > (60) || doshow)
        {
                p+=sprintf(p, "%dm", value/(60));
                value %= (60);
  doshow = 1;
        }
        if (value || doshow)
        {
                p+=sprintf(p, "%ds", value);
  doshow = 1;
        }
        return p-strvalue;
}

variable_types: value int

variable_types:
p
char *

variable_types: doshow char


original_code:
char *
val2cpustr(count_t value, char *strvalue)
{
 if (value < (count_t)100000)
 {
  sprintf(strvalue, "%2lld.%02llds", value/1000, value%1000/10);
 }
 else
 {
         value = (value + 500) / 1000;
         if (value < (count_t)6000)
         {
                  sprintf(strvalue, "%2lldm%02llds", value/60, value%60);
  }
  else
  {
   value = (value + 30) / 60;
   if (value < (count_t)6000)
   {
    sprintf(strvalue, "%2lldh%02lldm",
       value/60, value%60);
   }
   else
   {
    value = (value + 30) / 60;
    sprintf(strvalue, "%2lldd%02lldh",
      value/24, value%24);
   }
  }
 }
 return strvalue;
}

canonical_original_code:
char *val2cpustr(long long value, char *strvalue)
{
 if (value < (long long)100000)
 {
  sprintf(strvalue, "%2lld.%02llds", value/1000, value%1000/10);
 }
 else
 {
         value = (value + 500) / 1000;
         if (value < (long long)6000)
         {
                  sprintf(strvalue, "%2lldm%02llds", value/60, value%60);
  }
  else
  {
   value = (value + 30) / 60;
   if (value < (long long)6000)
   {
    sprintf(strvalue, "%2lldh%02lldm",
       value/60, value%60);
   }
   else
   {
    value = (value + 30) / 60;
    sprintf(strvalue, "%2lldd%02lldh",
      value/24, value%24);
   }
  }
 }
 return strvalue;
}


decompiled_code:
char *__fastcall val2Hzstr(__int64 a1, char *a2)
{
__int64 v2; // rdx
double v3; // xmm0_8
char *result; // rax

if ( a1 <= 999 )
{
sprintf(a2, "%4lldMHz", a1);
result = a2;
}
else
{
v2 = 71LL;
v3 = (double)(int)a1 / 1000.0;
if ( v3 >= 1000.0 )
{
v3 = v3 / 1000.0;
v2 = 84LL;
}
sprintf(a2, "%4.2f%cHz", v3, v2);
result = a2;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func7(__int64 a1, char *a2)
{
__int64 v2; // rdx
double v3; // xmm0_8
char *result; // rax

if ( a1 <= 999 )
{
sprintf(a2, "%4lldMHz", a1);
result = a2;
}
else
{
v2 = 71LL;
v3 = (double)(int)a1 / 1000.0;
if ( v3 >= 1000.0 )
{
v3 = v3 / 1000.0;
v2 = 84LL;
}
sprintf(a2, "%4.2f%cHz", v3, v2);
result = a2;
}
return result;
}

original_code:
char *
val2Hzstr(count_t value, char *strvalue)
{
        if (value < 1000)
        {
                sprintf(strvalue, "%4lldMHz", value);
        }
        else
        {
                double fval=value/1000.0;
                char prefix='G';
                if (fval >= 1000.0)
                {
                        prefix='T';
                        fval /= 1000.0;
                }
                sprintf(strvalue, "%4.2f%cHz", fval, prefix);
        }
 return strvalue;
}

canonical_original_code:
char *val2Hzstr(long long value, char *strvalue)
{
        if (value < 1000)
        {
                sprintf(strvalue, "%4lldMHz", value);
        }
        else
        {
                double fval = value/1000.0;
                char prefix = 'G';
                if (fval >= 1000.0)
                {
                        prefix='T';
                        fval /= 1000.0;
                }
                sprintf(strvalue, "%4.2f%cHz", fval, prefix);
        }
 return strvalue;
}

variable_types: fval double

variable_types: prefix char


original_code:
char *
val2memstr(count_t value, char *strvalue, int pformat, int avgval, int nsecs)
{
 char aformat;
 count_t verifyval;
 char *suffix = "";
 int basewidth = 6;
 if (value < 0)
  verifyval = -value * 10;
 else
  verifyval = value;
 if (avgval)
 {
  value /= nsecs;
  verifyval *= 100;
  basewidth -= 2;
  suffix = "/s";
 }
 if (verifyval <= 1024)
  aformat = 0;
 else
  if (verifyval <= 1024*99999L)
   aformat = 1;
  else
   if (verifyval <= 1048576*999L)
    aformat = 2;
   else
    if (verifyval <= 1073741824L*999LL)
     aformat = 3;
    else
     aformat = 4;
 if (aformat <= pformat)
  aformat = pformat;
 switch (aformat)
 {
    case 0:
  sprintf(strvalue, "%*lld%s",
    basewidth, value, suffix);
  break;
    case 1:
  sprintf(strvalue, "%*lldK%s",
    basewidth-1, value/1024, suffix);
  break;
    case 2:
  sprintf(strvalue, "%*.1lfM%s",
   basewidth-1, (double)((double)value/1048576), suffix);
  break;
    case 3:
  sprintf(strvalue, "%*.1lfG%s",
   basewidth-1, (double)((double)value/1073741824L), suffix);
  break;
    case 4:
  sprintf(strvalue, "%*.1lfT%s",
   basewidth-1, (double)((double)value/1099511627776LL), suffix);
  break;
    default:
  sprintf(strvalue, "!TILT!");
 }
 return strvalue;
}

canonical_original_code:
char *val2memstr(long long value, char *strvalue, int pformat, int avgval, int nsecs)
{
 char aformat;
 long long verifyval;
 char *suffix = "";
 int basewidth = 6;
 if (value < 0)
  verifyval = -value * 10;
 else
  verifyval = value;
 if (avgval)
 {
  value /= nsecs;
  verifyval *= 100;
  basewidth -= 2;
  suffix = "/s";
 }
 if (verifyval <= 1024)
  aformat = 0;
 else
  if (verifyval <= 1024*99999L)
   aformat = 1;
  else
   if (verifyval <= 1048576*999L)
    aformat = 2;
   else
    if (verifyval <= 1073741824L*999LL)
     aformat = 3;
    else
     aformat = 4;
 if (aformat <= pformat)
  aformat = pformat;
 switch (aformat)
 {
    case 0:
  sprintf(strvalue, "%*lld%s",
    basewidth, value, suffix);
  break;
    case 1:
  sprintf(strvalue, "%*lldK%s",
    basewidth-1, value/1024, suffix);
  break;
    case 2:
  sprintf(strvalue, "%*.1lfM%s",
   basewidth-1, (double)((double)value/1048576), suffix);
  break;
    case 3:
  sprintf(strvalue, "%*.1lfG%s",
   basewidth-1, (double)((double)value/1073741824L), suffix);
  break;
    case 4:
  sprintf(strvalue, "%*.1lfT%s",
   basewidth-1, (double)((double)value/1099511627776LL), suffix);
  break;
    default:
  sprintf(strvalue, "!TILT!");
 }
 return strvalue;
}

variable_types: pformat int

variable_types: avgval int

variable_types: aformat char

variable_types:
verifyval
long long

variable_types: basewidth int


numeric

decompiled_code:
__int64 __fastcall numeric(_BYTE *a1)
{
while ( 1 )
{
if ( !*a1 )
return 1LL;
if ( (unsigned __int8)(*a1 - 48) > 9u )
break;
++a1;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(_BYTE *a1)
{
while ( 1 )
{
if ( !*a1 )
return 1LL;
if ( (unsigned __int8)(*a1 - 48) > 9u )
break;
++a1;
}
return 0LL;
}

original_code:
int
numeric(char *ns)
{
 register char *s = ns;
 while (*s)
  if (*s < '0' || *s > '9')
   return(0);
  else
   s++;
 return(1);
}

variable_types:
ns
char *

variable_types:
s
char *


getboot

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

result = boottime_0;
if ( !boottime_0 )
{
result = getbootlinux(hertz);
boottime_0 = result;
}
return result;
}

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

result = boottime_0;
if ( !boottime_0 )
{
result = getbootlinux(hertz);
boottime_0 = result;
}
return result;
}

original_code:
unsigned long long
getboot(void)
{
 static unsigned long long boottime;
 unsigned long long getbootlinux(long);
 if (!boottime)
  boottime = getbootlinux(hertz);
 return boottime;
}

canonical_original_code:
unsigned long long getboot()
{
 static unsigned long long boottime;
 unsigned long long getbootlinux(long);
 if (!boottime)
  boottime = getbootlinux(hertz);
 return boottime;
}

variable_types:
boottime
unsigned long long

variable_types:
getbootlinux
unsigned long long (long)

return_type: unsigned long long


ptrverify

decompiled_code:
char *__fastcall ptrverify(__int64 a1, const char *a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, char a7)
{
char *result; // rax
void (*v8)(FILE *, const char *, ...); // rax
char v9[32]; // [rsp+28h] [rbp-20h] BYREF

result = &a7;
if ( !a1 )
{
acctswoff();
netatop_signoff();
v8 = (void (*)(FILE *, const char *, ...))vis[2];
if ( v8 )
v8(0LL, a2);
fprintf(stderr, a2, v9);
exit(13);
}
return result;
}

canonical_decompiled_code:
char *__fastcall func11(__int64 a1, const char *a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, char a7)
{
char *result; // rax
void (*v8)(FILE *, const char *, ...); // rax
char v9[32]; // [rsp+28h] [rbp-20h] BYREF

result = &a7;
if ( !a1 )
{
acctswoff();
netatop_signoff();
v8 = (void (*)(FILE *, const char *, ...))vis[2];
if ( v8 )
v8(0LL, a2);
fprintf(stderr, a2, v9);
exit(13);
}
return result;
}

original_code:
void
ptrverify(const void *ptr, const char *errormsg, ...)
{
 va_list args;
        __builtin_va_start(args,errormsg);
 if (!ptr)
 {
  acctswoff();
  netatop_signoff();
  if (vis.show_end)
   (vis.show_end)();
         va_list args;
  fprintf(stderr, errormsg, args);
         __builtin_va_end(args);
  exit(13);
 }
}

canonical_original_code:
void ptrverify(void *ptr, char *errormsg, ...)
{
 __builtin_va_list args;
        __builtin_va_start(args,errormsg);
 if (!ptr)
 {
  acctswoff();
  netatop_signoff();
  if (vis.show_end)
   (vis.show_end)();
         __builtin_va_list args;
  fprintf(stderr, errormsg, args);
         __builtin_va_end(args);
  exit(13);
 }
}

variable_types:
ptr
void *

variable_types:
errormsg
char *

return_type: void


droprootprivs

decompiled_code:
_BOOL8 droprootprivs()
{
__uid_t v0; // eax
int v1; // er8
_BOOL8 result; // rax

v0 = getuid();
v1 = seteuid(v0);
result = 1LL;
if ( v1 == -1 )
result = *_errno_location() == 1;
return result;
}

canonical_decompiled_code:
_BOOL8 func13()
{
__uid_t v0; // eax
int v1; // er8
_BOOL8 result; // rax

v0 = getuid();
v1 = seteuid(v0);
result = 1LL;
if ( v1 == -1 )
result = *_errno_location() == 1;
return result;
}

original_code:
int
droprootprivs(void)
{
 if (seteuid( getuid() ) == -1 && (*__errno_location ()) != 1)
  return 0;
 else
  return 1;
}

canonical_original_code:
int droprootprivs()
{
 if (seteuid( getuid() ) == -1 && (*__errno_location ()) != 1)
  return 0;
 else
  return 1;
}


regainrootprivs

decompiled_code:
int regainrootprivs()
{
return seteuid(0);
}

canonical_decompiled_code:
int func14()
{
return seteuid(0);
}

original_code:
void
regainrootprivs(void)
{
 seteuid(0);
}

canonical_original_code:
void regainrootprivs()
{
 seteuid(0);
}


decompiled_code:
__int64 __fastcall pdb_gettask(int a1, char a2, int a3, __int64 *a4)
{
__int64 result; // rax
__int64 v6; // rdx
__int64 v7; // rcx

result = phash[(unsigned __int8)a1];
if ( !result )
return 0LL;
while ( *(_DWORD *)(result + 28) != a1
|| *(_BYTE *)(result + 88) != a2
|| (unsigned int)(1 - a3 + *(_DWORD *)(result + 96)) > 2 )
{
result = *(_QWORD *)result;
if ( !result )
return result;
}
v6 = *(_QWORD *)(result + 8);
if ( v6 )
{
v7 = *(_QWORD *)(result + 16);
*(_QWORD *)(v6 + 16) = v7;
*(_QWORD *)(v7 + 8) = v6;
}
*(_QWORD *)(result + 8) = 0LL;
*(_QWORD *)(result + 16) = 0LL;
*a4 = result;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, char a2, int a3, __int64 *a4)
{
__int64 result; // rax
__int64 v6; // rdx
__int64 v7; // rcx

result = phash[(unsigned __int8)a1];
if ( !result )
return 0LL;
while ( *(_DWORD *)(result + 28) != a1
|| *(_BYTE *)(result + 88) != a2
|| (unsigned int)(1 - a3 + *(_DWORD *)(result + 96)) > 2 )
{
result = *(_QWORD *)result;
if ( !result )
return result;
}
v6 = *(_QWORD *)(result + 8);
if ( v6 )
{
v7 = *(_QWORD *)(result + 16);
*(_QWORD *)(v6 + 16) = v7;
*(_QWORD *)(v7 + 8) = v6;
}
*(_QWORD *)(result + 8) = 0LL;
*(_QWORD *)(result + 16) = 0LL;
*a4 = result;
return 1LL;
}

original_code:
int
pdb_gettask(int pid, char isproc, time_t btime, struct pinfo **pinfopp)
{
 register struct pinfo *pp;
 pp = phash[pid&(256 -1)];
 while (pp)
 {
  if (pp->tstat.gen.pid == pid &&
      pp->tstat.gen.isproc == isproc )
  {
   int diff = pp->tstat.gen.btime - btime;
   if (diff > 1 || diff < -1)
   {
    pp = pp->phnext;
    continue;
   }
   if (pp->prnext)
   {
    (pp->prnext)->prprev = pp->prprev;
    (pp->prprev)->prnext = pp->prnext;
   }
   pp->prnext = ((void *)0);
   pp->prprev = ((void *)0);
   *pinfopp = pp;
   return(1);
  }
  pp = pp->phnext;
 }
 return(0);
}

canonical_original_code:
int pdb_gettask(int pid, char isproc, long btime, struct pinfo **pinfopp)
{
 register struct pinfo *pp;
 pp = phash[pid&(256 -1)];
 while (pp)
 {
  if (pp->tstat.gen.pid == pid &&
      pp->tstat.gen.isproc == isproc )
  {
   int diff = pp->tstat.gen.btime - btime;
   if (diff > 1 || diff < -1)
   {
    pp = pp->phnext;
    continue;
   }
   if (pp->prnext)
   {
    (pp->prnext)->prprev = pp->prprev;
    (pp->prprev)->prnext = pp->prnext;
   }
   pp->prnext = ((void *)0);
   pp->prprev = ((void *)0);
   *pinfopp = pp;
   return(1);
  }
  pp = pp->phnext;
 }
 return(0);
}

variable_types: pid int

variable_types: isproc char

variable_types: btime long

variable_types: struct pinfo { struct pinfo *phnext; struct pinfo *prnext; struct pinfo *prprev; struct tstat { struct gen { int tgid; int pid; int ppid; int ruid; int euid; int suid; int fsuid; int rgid; int egid; int sgid; int fsgid; int nthr; char name[-1]; char isproc; char state; int excode; long btime; long elaps; char cmdline[-1]; int nthrslpi; int nthrslpu; int nthrrun; int ifuture[4]; } gen; struct cpu { long long utime; long long stime; int nice; int prio; int rtprio; int policy; int curcpu; int sleepavg; int ifuture[4]; long long cfuture[4]; } cpu; struct dsk { long long rio; long long rsz; long long wio; long long wsz; long long cwsz; long long cfuture[4]; } dsk; struct mem { long long minflt; long long majflt; long long vexec; long long vmem; long long rmem; long long vgrow; long long rgrow; long long vdata; long long vstack; long long vlibs; long long vswap; } mem; struct net { long long tcpsnd; long long tcpssz; long long tcprcv; long long tcprsz; long long udpsnd; long long udpssz; long long udprcv; long long udprsz; long long avail1; long long avail2; long long cfuture[4]; } net; } tstat; } **

variable_types: diff int

user_defined_types: struct pinfo { struct pinfo *phnext; struct pinfo *prnext; struct pinfo *prprev; struct tstat tstat; }

user_defined_types: struct tstat { struct gen gen; struct cpu cpu; struct dsk dsk; struct mem mem; struct net net; }


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

result = phash[a1];
phash[a1] = (__int64)a2;
*a2 = result;
return result;
}

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

result = phash[a1];
phash[a1] = (__int64)a2;
*a2 = result;
return result;
}

original_code:
void
pdb_addtask(int pid, struct pinfo *pinfop)
{
 register int i = pid&(256 -1);
 pinfop->phnext = phash[i];
 phash[i] = pinfop;
}

variable_types: struct pinfo { struct pinfo *phnext; struct pinfo *prnext; struct pinfo *prprev; struct tstat { struct gen { int tgid; int pid; int ppid; int ruid; int euid; int suid; int fsuid; int rgid; int egid; int sgid; int fsgid; int nthr; char name[-1]; char isproc; char state; int excode; long btime; long elaps; char cmdline[-1]; int nthrslpi; int nthrslpu; int nthrrun; int ifuture[4]; } gen; struct cpu { long long utime; long long stime; int nice; int prio; int rtprio; int policy; int curcpu; int sleepavg; int ifuture[4]; long long cfuture[4]; } cpu; struct dsk { long long rio; long long rsz; long long wio; long long wsz; long long cwsz; long long cfuture[4]; } dsk; struct mem { long long minflt; long long majflt; long long vexec; long long vmem; long long rmem; long long vgrow; long long rgrow; long long vdata; long long vstack; long long vlibs; long long vswap; } mem; struct net { long long tcpsnd; long long tcpssz; long long tcprcv; long long tcprsz; long long udpsnd; long long udpssz; long long udprcv; long long udprsz; long long avail1; long long avail2; long long cfuture[4]; } net; } tstat; } *

variable_types: i int


original_code:
int
pdb_deltask(int pid, char isproc)
{
 register struct pinfo *pp, *ppp;
 pp = phash[pid&(256 -1)];
 if (pp->tstat.gen.pid == pid && pp->tstat.gen.isproc == isproc)
 {
  phash[pid&(256 -1)] = pp->phnext;
  if ( pp->prnext )
  {
   (pp->prprev)->prnext = pp->prnext;
   (pp->prnext)->prprev = pp->prprev;
  }
  free(pp);
  return(1);
 }
 ppp = pp;
 pp = pp->phnext;
 while (pp)
 {
  if (pp->tstat.gen.pid == pid && pp->tstat.gen.isproc == isproc)
  {
   ppp->phnext = pp->phnext;
   if ( pp->prnext )
   {
    (pp->prnext)->prprev = pp->prprev;
    (pp->prprev)->prnext = pp->prnext;
   }
   free(pp);
   return(1);
  }
  ppp = pp;
  pp = pp->phnext;
 }
 return(0);
}

canonical_original_code:
int pdb_deltask(int pid, char isproc)
{
 register struct pinfo *pp; register struct pinfo *ppp;
 pp = phash[pid&(256 -1)];
 if (pp->tstat.gen.pid == pid && pp->tstat.gen.isproc == isproc)
 {
  phash[pid&(256 -1)] = pp->phnext;
  if ( pp->prnext )
  {
   (pp->prprev)->prnext = pp->prnext;
   (pp->prnext)->prprev = pp->prprev;
  }
  free(pp);
  return(1);
 }
 ppp = pp;
 pp = pp->phnext;
 while (pp)
 {
  if (pp->tstat.gen.pid == pid && pp->tstat.gen.isproc == isproc)
  {
   ppp->phnext = pp->phnext;
   if ( pp->prnext )
   {
    (pp->prnext)->prprev = pp->prprev;
    (pp->prprev)->prnext = pp->prnext;
   }
   free(pp);
   return(1);
  }
  ppp = pp;
  pp = pp->phnext;
 }
 return(0);
}

user_defined_types: struct gen { int tgid; int pid; int ppid; int ruid; int euid; int suid; int fsuid; int rgid; int egid; int sgid; int fsgid; int nthr; char name[-1]; char isproc; char state; int excode; long btime; long elaps; char cmdline[-1]; int nthrslpi; int nthrslpu; int nthrrun; int ifuture[4]; }

user_defined_types: struct cpu { long long utime; long long stime; int nice; int prio; int rtprio; int policy; int curcpu; int sleepavg; int ifuture[4]; long long cfuture[4]; }

user_defined_types: struct dsk { long long rio; long long rsz; long long wio; long long wsz; long long cwsz; long long cfuture[4]; }

user_defined_types: struct mem { long long minflt; long long majflt; long long vexec; long long vmem; long long rmem; long long vgrow; long long rgrow; long long vdata; long long vstack; long long vlibs; long long vswap; }

user_defined_types: struct net { long long tcpsnd; long long tcpssz; long long tcprcv; long long tcprsz; long long udpsnd; long long udpssz; long long udprcv; long long udprsz; long long avail1; long long avail2; long long cfuture[4]; }


original_code:
int
pdb_makeresidue(void)
{
 register struct pinfo *pp, *pr;
 register int i;
 pr = &presidue;
 pr->prnext = pr;
 pr->prprev = pr;
 for (i=0; i < 256; i++)
 {
  if (!phash[i])
   continue;
  pp = phash[i];
  while (pp)
  {
   pp->prnext = pr->prnext;
   pr->prnext = pp;
    pp->prprev = (pp->prnext)->prprev;
   (pp->prnext)->prprev = pp;
   pp = pp->phnext;
  }
 }
 return(1);
}

canonical_original_code:
int pdb_makeresidue()
{
 register struct pinfo *pp; register struct pinfo *pr;
 register int i;
 pr = &presidue;
 pr->prnext = pr;
 pr->prprev = pr;
 for (i=0; i < 256; i++)
 {
  if (!phash[i])
   continue;
  pp = phash[i];
  while (pp)
  {
   pp->prnext = pr->prnext;
   pr->prnext = pp;
    pp->prprev = (pp->prnext)->prprev;
   (pp->prnext)->prprev = pp;
   pp = pp->phnext;
  }
 }
 return(1);
}


decompiled_code:
__int64 pdb_cleanresidue()
{
__int64 v0; // rbx
int v1; // edi
char v2; // si

v0 = qword_2E8;
while ( (_UNKNOWN *)v0 != &presidue )
{
v1 = *(_DWORD *)(v0 + 28);
v2 = *(_BYTE *)(v0 + 88);
v0 = *(_QWORD *)(v0 + 8);
pdb_deltask(v1, v2);
}
return 1LL;
}

original_code:
int
pdb_cleanresidue(void)
{
 register struct pinfo *pr;
 register int pid;
        char isproc;
 pr = presidue.prnext;
 while (pr != &presidue)
 {
  pid = pr->tstat.gen.pid;
  isproc = pr->tstat.gen.isproc;
  pr = pr->prnext;
  pdb_deltask(pid, isproc);
 }
 return(1);
}

canonical_original_code:
int pdb_cleanresidue()
{
 register struct pinfo *pr;
 register int pid;
        char isproc;
 pr = presidue.prnext;
 while (pr != &presidue)
 {
  pid = pr->tstat.gen.pid;
  isproc = pr->tstat.gen.isproc;
  pr = pr->prnext;
  pdb_deltask(pid, isproc);
 }
 return(1);
}


decompiled_code:
__int64 __fastcall pdb_srchresidue(__int64 a1, __int64 *a2)
{
__int64 v2; // rbx
int v3; // ebp
__int64 v4; // r14
__int64 v5; // rax
__int64 result; // rax

v2 = qword_2E8;
if ( (_UNKNOWN *)qword_2E8 == &presidue )
return 0LL;
v3 = *(_DWORD *)(a1 + 12);
v4 = 0LL;
do
{
while ( *(_DWORD *)(v2 + 36) != v3
|| *(_DWORD *)(v2 + 52) != *(_DWORD *)(a1 + 28)
|| strcmp((const char *)(v2 + 72), (const char *)(a1 + 48)) )
{
v2 = *(_QWORD *)(v2 + 8);
if ( (_UNKNOWN *)v2 == &presidue )
goto LABEL_11;
}
v5 = *(_QWORD *)(v2 + 96) - *(_QWORD *)(a1 + 72);
if ( !v5 )
{
*a2 = v2;
return 1LL;
}
if ( !(v4 | (v5 + 1) & 0xFFFFFFFFFFFFFFFDLL) )
v4 = v2;
v2 = *(_QWORD *)(v2 + 8);
}
while ( (_UNKNOWN *)v2 != &presidue );
LABEL_11:
result = 0LL;
if ( v4 )
{
*a2 = v4;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 *a2)
{
__int64 v2; // rbx
int v3; // ebp
__int64 v4; // r14
__int64 v5; // rax
__int64 result; // rax

v2 = qword_2E8;
if ( (_UNKNOWN *)qword_2E8 == &presidue )
return 0LL;
v3 = *(_DWORD *)(a1 + 12);
v4 = 0LL;
do
{
while ( *(_DWORD *)(v2 + 36) != v3
|| *(_DWORD *)(v2 + 52) != *(_DWORD *)(a1 + 28)
|| strcmp((const char *)(v2 + 72), (const char *)(a1 + 48)) )
{
v2 = *(_QWORD *)(v2 + 8);
if ( (_UNKNOWN *)v2 == &presidue )
goto LABEL_11;
}
v5 = *(_QWORD *)(v2 + 96) - *(_QWORD *)(a1 + 72);
if ( !v5 )
{
*a2 = v2;
return 1LL;
}
if ( !(v4 | (v5 + 1) & 0xFFFFFFFFFFFFFFFDLL) )
v4 = v2;
v2 = *(_QWORD *)(v2 + 8);
}
while ( (_UNKNOWN *)v2 != &presidue );
LABEL_11:
result = 0LL;
if ( v4 )
{
*a2 = v4;
result = 1LL;
}
return result;
}

original_code:
int
pdb_srchresidue(struct tstat *tstatp, struct pinfo **pinfopp)
{
 register struct pinfo *pr, *prmin=((void *)0);
 register long btimediff;
 pr = presidue.prnext;
 while (pr != &presidue)
 {
  if ( pr->tstat.gen.ruid == tstatp->gen.ruid &&
   pr->tstat.gen.rgid == tstatp->gen.rgid &&
   strcmp(pr->tstat.gen.name, tstatp->gen.name) == 0 )
  {
   btimediff = pr->tstat.gen.btime - tstatp->gen.btime;
   if (btimediff == 0)
   {
    *pinfopp = pr;
    return(1);
   }
   if ((btimediff== -1 || btimediff== 1) && prmin== ((void *)0))
    prmin = pr;
  }
  pr = pr->prnext;
 }
 if (prmin)
 {
  *pinfopp = prmin;
  return(1);
 }
 return(0);
}

canonical_original_code:
int pdb_srchresidue(struct tstat *tstatp, struct pinfo **pinfopp)
{
 register struct pinfo *pr; register struct pinfo *prmin = ((void *)0);
 register long btimediff;
 pr = presidue.prnext;
 while (pr != &presidue)
 {
  if ( pr->tstat.gen.ruid == tstatp->gen.ruid &&
   pr->tstat.gen.rgid == tstatp->gen.rgid &&
   strcmp(pr->tstat.gen.name, tstatp->gen.name) == 0 )
  {
   btimediff = pr->tstat.gen.btime - tstatp->gen.btime;
   if (btimediff == 0)
   {
    *pinfopp = pr;
    return(1);
   }
   if ((btimediff== -1 || btimediff== 1) && prmin== ((void *)0))
    prmin = pr;
  }
  pr = pr->prnext;
 }
 if (prmin)
 {
  *pinfopp = prmin;
  return(1);
 }
 return(0);
}

variable_types: struct tstat { struct gen { int tgid; int pid; int ppid; int ruid; int euid; int suid; int fsuid; int rgid; int egid; int sgid; int fsgid; int nthr; char name[-1]; char isproc; char state; int excode; long btime; long elaps; char cmdline[-1]; int nthrslpi; int nthrslpu; int nthrrun; int ifuture[4]; } gen; struct cpu { long long utime; long long stime; int nice; int prio; int rtprio; int policy; int curcpu; int sleepavg; int ifuture[4]; long long cfuture[4]; } cpu; struct dsk { long long rio; long long rsz; long long wio; long long wsz; long long cwsz; long long cfuture[4]; } dsk; struct mem { long long minflt; long long majflt; long long vexec; long long vmem; long long rmem; long long vgrow; long long rgrow; long long vdata; long long vstack; long long vlibs; long long vswap; } mem; struct net { long long tcpsnd; long long tcpssz; long long tcprcv; long long tcprsz; long long udpsnd; long long udpssz; long long udprcv; long long udprsz; long long avail1; long long avail2; long long cfuture[4]; } net; } *

variable_types: struct pinfo { struct pinfo *phnext; struct pinfo *prnext; struct pinfo *prprev; struct tstat tstat; } **

variable_types: btimediff long


getstrvers

decompiled_code:
char *getstrvers()
{
snprintf(vers_0, 0x100uLL, "Version: %s - %s <gerlof.langeveld@atoptool.nl>", atopversion, atopdate);
return vers_0;
}

canonical_decompiled_code:
char *func0()
{
snprintf(vers_0, 0x100uLL, "Version: %s - %s <gerlof.langeveld@atoptool.nl>", atopversion, atopdate);
return vers_0;
}

original_code:
char *
getstrvers(void)
{
 static char vers[256];
 snprintf(vers, sizeof vers,
  "Version: %s - %s     <gerlof.langeveld@atoptool.nl>",
  atopversion, atopdate);
 return vers;
}

canonical_original_code:
char *getstrvers()
{
 static char vers[256];
 snprintf(vers, sizeof vers,
  "Version: %s - %s     <gerlof.langeveld@atoptool.nl>",
  atopversion, atopdate);
 return vers;
}

variable_types:
vers
char [256]


getnumvers

decompiled_code:
__int16 getnumvers()
{
__int16 v1; // [rsp+8h] [rbp-10h] BYREF
__int16 v2; // [rsp+Ch] [rbp-Ch] BYREF

_isoc99_sscanf(atopversion, "%u.%u", &v1, &v2);
return v2 + (v1 << 8);
}

canonical_decompiled_code:
__int16 func1()
{
__int16 v1; // [rsp+8h] [rbp-10h] BYREF
__int16 v2; // [rsp+Ch] [rbp-Ch] BYREF

_isoc99_sscanf(atopversion, "%u.%u", &v1, &v2);
return v2 + (v1 << 8);
}

original_code:
unsigned short
getnumvers(void)
{
 int vers1, vers2;
 sscanf(atopversion, "%u.%u", &vers1, &vers2);
 return (unsigned short) ((vers1 << 8) + vers2);
}

canonical_original_code:
unsigned short getnumvers()
{
 int vers1; int vers2;
 sscanf(atopversion, "%u.%u", &vers1, &vers2);
 return (unsigned short) ((vers1 << 8) + vers2);
}

return_type: unsigned short


getifprop

decompiled_code:
__int64 __fastcall getifprop(char *s1)
{
__int64 v1; // rbx
__int64 v2; // rbp
__int64 v3; // r13
__int64 result; // rax

if ( ifprops[0] )
{
v1 = 0LL;
while ( 1 )
{
v2 = 32 * v1;
if ( !strcmp(s1, &ifprops[32 * v1]) )
break;
++v1;
if ( !byte_280[v2] )
goto LABEL_6;
}
v3 = 2LL * (int)v1;
result = 1LL;
*(__m128i *)s1 = _mm_load_si128((const __m128i *)&ifprops[v3 * 16]);
*((__m128i *)s1 + 1) = _mm_load_si128((const __m128i *)&xmmword_270[v3]);
}
else
{
LABEL_6:
*((_QWORD *)s1 + 2) = 0LL;
result = 0LL;
s1[24] = 0;
}
return result;
}

original_code:
int
getifprop(struct ifprop *ifp)
{
 register int i;
 for (i=0; ifprops[i].name[0]; i++)
 {
  if (strcmp(ifp->name, ifprops[i].name) == 0)
  {
   *ifp = ifprops[i];
   return 1;
  }
 }
 ifp->speed = 0;
 ifp->fullduplex = 0;
 return 0;
}

variable_types: struct ifprop { char name[16]; long speed; char fullduplex; } *


test

repo: samphippen/lsquare

decompiled_code:
__int64 test()
{
void **v0; // r12
int v1; // ebx
unsigned int v2; // ebp
__int64 v3; // rbx
_QWORD *v4; // rbp
__int64 result; // rax

v0 = (void **)malloc(0x20uLL);
init_latin_square("abcd", v0);
if ( (unsigned __int8)col_is_filled(0LL, v0) )
_assert_fail("col_is_filled(0, my_square) == 0", "test.c", 9u, "test");
if ( (unsigned __int8)row_is_filled(0LL, v0) )
_assert_fail("row_is_filled(0, my_square) == 0", "test.c", 0xAu, "test");
if ( !(unsigned __int8)col_is_valid(0LL, v0) )
_assert_fail("col_is_valid(0, my_square) == 1", "test.c", 0xBu, "test");
if ( !(unsigned __int8)row_is_valid(0LL, v0) )
_assert_fail("row_is_valid(0, my_square) == 1", "test.c", 0xCu, "test");
*(_BYTE *)v0[1] = 97;
if ( (unsigned __int8)col_is_filled(0LL, v0) )
_assert_fail("col_is_filled(0, my_square) == 0", "test.c", 0xFu, "test");
if ( (unsigned __int8)row_is_filled(0LL, v0) )
_assert_fail("row_is_filled(0, my_square) == 0", "test.c", 0x10u, "test");
if ( !(unsigned __int8)col_is_valid(0LL, v0) )
_assert_fail("col_is_valid(0, my_square) == 1", "test.c", 0x11u, "test");
if ( !(unsigned __int8)row_is_valid(0LL, v0) )
_assert_fail("row_is_valid(0, my_square) == 1", "test.c", 0x12u, "test");
*((_BYTE *)v0[1] + 1) = 97;
if ( (unsigned __int8)col_is_filled(0LL, v0) )
_assert_fail("col_is_filled(0, my_square) == 0", "test.c", 0x15u, "test");
if ( (unsigned __int8)row_is_filled(0LL, v0) )
_assert_fail("row_is_filled(0, my_square) == 0", "test.c", 0x16u, "test");
if ( !(unsigned __int8)col_is_valid(0LL, v0) )
_assert_fail("col_is_valid(0, my_square) == 1", "test.c", 0x17u, "test");
if ( (unsigned __int8)row_is_valid(0LL, v0) )
_assert_fail("row_is_valid(0, my_square) == 0", "test.c", 0x18u, "test");
*((_BYTE *)v0[1] + 1) = 98;
if ( (unsigned __int8)col_is_filled(0LL, v0) )
_assert_fail("col_is_filled(0, my_square) == 0", "test.c", 0x1Bu, "test");
if ( (unsigned __int8)row_is_filled(0LL, v0) )
_assert_fail("row_is_filled(0, my_square) == 0", "test.c", 0x1Cu, "test");
if ( !(unsigned __int8)col_is_valid(0LL, v0) )
_assert_fail("col_is_valid(0, my_square) == 1", "test.c", 0x1Du, "test");
if ( !(unsigned __int8)row_is_valid(0LL, v0) )
_assert_fail("row_is_valid(0, my_square) == 1", "test.c", 0x1Eu, "test");
v1 = *(_DWORD *)v0;
if ( *(_DWORD *)v0 )
{
v2 = 0;
do
{
v3 = (__int64)v0[1] + v2 * v1;
*(_DWORD *)v3 = *(_DWORD *)v0[3];
if ( !(unsigned __int8)row_is_filled(v2, v0) )
_assert_fail("row_is_filled(i, my_square) == 1", "test.c", 0x24u, "test");
if ( !(unsigned __int8)row_is_valid(v2, v0) )
_assert_fail("row_is_valid(i, my_square) == 1", "test.c", 0x25u, "test");
*(_BYTE *)(v3 + 3) = 46;
if ( (unsigned __int8)row_is_filled(v2, v0) )
_assert_fail("row_is_filled(i, my_square) == 0", "test.c", 0x28u, "test");
if ( !(unsigned __int8)row_is_valid(v2, v0) )
_assert_fail("row_is_valid(i, my_square) == 1", "test.c", 0x29u, "test");
*(_BYTE *)(v3 + 3) = 100;
*(_BYTE *)v3 = 46;
if ( (unsigned __int8)row_is_filled(v2, v0) )
_assert_fail("row_is_filled(i, my_square) == 0", "test.c", 0x2Du, "test");
if ( !(unsigned __int8)row_is_valid(v2, v0) )
_assert_fail("row_is_valid(i, my_square) == 1", "test.c", 0x2Eu, "test");
v1 = *(_DWORD *)v0;
++v2;
}
while ( *(_DWORD *)v0 > v2 );
}
free(v0[1]);
init_latin_square(v0[3], v0);
*(_BYTE *)v0[1] = 97;
*((_BYTE *)v0[1] + 4) = 98;
if ( (unsigned __int8)col_is_filled(0LL, v0) )
_assert_fail("col_is_filled(0, my_square) == 0", "test.c", 0x37u, "test");
if ( !(unsigned __int8)col_is_valid(0LL, v0) )
_assert_fail("col_is_valid(0, my_square) == 1", "test.c", 0x38u, "test");
*((_BYTE *)v0[1] + 8) = 99;
*((_BYTE *)v0[1] + 12) = 100;
if ( !(unsigned __int8)col_is_filled(0LL, v0) )
_assert_fail("col_is_filled(0, my_square) == 1", "test.c", 0x3Cu, "test");
if ( !(unsigned __int8)col_is_valid(0LL, v0) )
_assert_fail("col_is_valid(0, my_square) == 1", "test.c", 0x3Du, "test");
*(_BYTE *)v0[1] = 46;
if ( (unsigned __int8)col_is_filled(0LL, v0) )
_assert_fail("col_is_filled(0, my_square) == 0", "test.c", 0x40u, "test");
if ( !(unsigned __int8)col_is_valid(0LL, v0) )
_assert_fail("col_is_valid(0, my_square) == 1", "test.c", 0x41u, "test");
*(_BYTE *)v0[1] = 97;
*((_BYTE *)v0[1] + 4) = 97;
*((_BYTE *)v0[1] + 8) = 97;
*((_BYTE *)v0[1] + 12) = 97;
if ( !(unsigned __int8)col_is_filled(0LL, v0) )
_assert_fail("col_is_filled(0, my_square) == 1", "test.c", 0x47u, "test");
if ( (unsigned __int8)col_is_valid(0LL, v0) )
_assert_fail("col_is_valid(0, my_square) == 0", "test.c", 0x48u, "test");
v4 = malloc(0x20uLL);
init_latin_square("ab", v4);
v4[1] = "abba";
if ( !(unsigned __int8)square_complete(v4) )
_assert_fail("square_complete(my_square_2)", "test.c", 0x4Du, "test");
init_latin_square("abcd", v4);
solve_latin_square(v4, 0LL);
result = square_complete(v4);
if ( !(_BYTE)result )
_assert_fail("square_complete(my_square_2)", "test.c", 0x51u, "test");
return result;
}

canonical_decompiled_code:
__int64 func0()
{
void **v0; // r12
int v1; // ebx
unsigned int v2; // ebp
__int64 v3; // rbx
_QWORD *v4; // rbp
__int64 result; // rax

v0 = (void **)malloc(0x20uLL);
init_latin_square("abcd", v0);
if ( (unsigned __int8)col_is_filled(0LL, v0) )
_assert_fail("col_is_filled(0, my_square) == 0", "test.c", 9u, "test");
if ( (unsigned __int8)row_is_filled(0LL, v0) )
_assert_fail("row_is_filled(0, my_square) == 0", "test.c", 0xAu, "test");
if ( !(unsigned __int8)col_is_valid(0LL, v0) )
_assert_fail("col_is_valid(0, my_square) == 1", "test.c", 0xBu, "test");
if ( !(unsigned __int8)row_is_valid(0LL, v0) )
_assert_fail("row_is_valid(0, my_square) == 1", "test.c", 0xCu, "test");
*(_BYTE *)v0[1] = 97;
if ( (unsigned __int8)col_is_filled(0LL, v0) )
_assert_fail("col_is_filled(0, my_square) == 0", "test.c", 0xFu, "test");
if ( (unsigned __int8)row_is_filled(0LL, v0) )
_assert_fail("row_is_filled(0, my_square) == 0", "test.c", 0x10u, "test");
if ( !(unsigned __int8)col_is_valid(0LL, v0) )
_assert_fail("col_is_valid(0, my_square) == 1", "test.c", 0x11u, "test");
if ( !(unsigned __int8)row_is_valid(0LL, v0) )
_assert_fail("row_is_valid(0, my_square) == 1", "test.c", 0x12u, "test");
*((_BYTE *)v0[1] + 1) = 97;
if ( (unsigned __int8)col_is_filled(0LL, v0) )
_assert_fail("col_is_filled(0, my_square) == 0", "test.c", 0x15u, "test");
if ( (unsigned __int8)row_is_filled(0LL, v0) )
_assert_fail("row_is_filled(0, my_square) == 0", "test.c", 0x16u, "test");
if ( !(unsigned __int8)col_is_valid(0LL, v0) )
_assert_fail("col_is_valid(0, my_square) == 1", "test.c", 0x17u, "test");
if ( (unsigned __int8)row_is_valid(0LL, v0) )
_assert_fail("row_is_valid(0, my_square) == 0", "test.c", 0x18u, "test");
*((_BYTE *)v0[1] + 1) = 98;
if ( (unsigned __int8)col_is_filled(0LL, v0) )
_assert_fail("col_is_filled(0, my_square) == 0", "test.c", 0x1Bu, "test");
if ( (unsigned __int8)row_is_filled(0LL, v0) )
_assert_fail("row_is_filled(0, my_square) == 0", "test.c", 0x1Cu, "test");
if ( !(unsigned __int8)col_is_valid(0LL, v0) )
_assert_fail("col_is_valid(0, my_square) == 1", "test.c", 0x1Du, "test");
if ( !(unsigned __int8)row_is_valid(0LL, v0) )
_assert_fail("row_is_valid(0, my_square) == 1", "test.c", 0x1Eu, "test");
v1 = *(_DWORD *)v0;
if ( *(_DWORD *)v0 )
{
v2 = 0;
do
{
v3 = (__int64)v0[1] + v2 * v1;
*(_DWORD *)v3 = *(_DWORD *)v0[3];
if ( !(unsigned __int8)row_is_filled(v2, v0) )
_assert_fail("row_is_filled(i, my_square) == 1", "test.c", 0x24u, "test");
if ( !(unsigned __int8)row_is_valid(v2, v0) )
_assert_fail("row_is_valid(i, my_square) == 1", "test.c", 0x25u, "test");
*(_BYTE *)(v3 + 3) = 46;
if ( (unsigned __int8)row_is_filled(v2, v0) )
_assert_fail("row_is_filled(i, my_square) == 0", "test.c", 0x28u, "test");
if ( !(unsigned __int8)row_is_valid(v2, v0) )
_assert_fail("row_is_valid(i, my_square) == 1", "test.c", 0x29u, "test");
*(_BYTE *)(v3 + 3) = 100;
*(_BYTE *)v3 = 46;
if ( (unsigned __int8)row_is_filled(v2, v0) )
_assert_fail("row_is_filled(i, my_square) == 0", "test.c", 0x2Du, "test");
if ( !(unsigned __int8)row_is_valid(v2, v0) )
_assert_fail("row_is_valid(i, my_square) == 1", "test.c", 0x2Eu, "test");
v1 = *(_DWORD *)v0;
++v2;
}
while ( *(_DWORD *)v0 > v2 );
}
free(v0[1]);
init_latin_square(v0[3], v0);
*(_BYTE *)v0[1] = 97;
*((_BYTE *)v0[1] + 4) = 98;
if ( (unsigned __int8)col_is_filled(0LL, v0) )
_assert_fail("col_is_filled(0, my_square) == 0", "test.c", 0x37u, "test");
if ( !(unsigned __int8)col_is_valid(0LL, v0) )
_assert_fail("col_is_valid(0, my_square) == 1", "test.c", 0x38u, "test");
*((_BYTE *)v0[1] + 8) = 99;
*((_BYTE *)v0[1] + 12) = 100;
if ( !(unsigned __int8)col_is_filled(0LL, v0) )
_assert_fail("col_is_filled(0, my_square) == 1", "test.c", 0x3Cu, "test");
if ( !(unsigned __int8)col_is_valid(0LL, v0) )
_assert_fail("col_is_valid(0, my_square) == 1", "test.c", 0x3Du, "test");
*(_BYTE *)v0[1] = 46;
if ( (unsigned __int8)col_is_filled(0LL, v0) )
_assert_fail("col_is_filled(0, my_square) == 0", "test.c", 0x40u, "test");
if ( !(unsigned __int8)col_is_valid(0LL, v0) )
_assert_fail("col_is_valid(0, my_square) == 1", "test.c", 0x41u, "test");
*(_BYTE *)v0[1] = 97;
*((_BYTE *)v0[1] + 4) = 97;
*((_BYTE *)v0[1] + 8) = 97;
*((_BYTE *)v0[1] + 12) = 97;
if ( !(unsigned __int8)col_is_filled(0LL, v0) )
_assert_fail("col_is_filled(0, my_square) == 1", "test.c", 0x47u, "test");
if ( (unsigned __int8)col_is_valid(0LL, v0) )
_assert_fail("col_is_valid(0, my_square) == 0", "test.c", 0x48u, "test");
v4 = malloc(0x20uLL);
init_latin_square("ab", v4);
v4[1] = "abba";
if ( !(unsigned __int8)square_complete(v4) )
_assert_fail("square_complete(my_square_2)", "test.c", 0x4Du, "test");
init_latin_square("abcd", v4);
solve_latin_square(v4, 0LL);
result = square_complete(v4);
if ( !(_BYTE)result )
_assert_fail("square_complete(my_square_2)", "test.c", 0x51u, "test");
return result;
}

original_code:
void test() {
    latin_square* my_square = malloc(sizeof(latin_square));
    init_latin_square("abcd", my_square);
    ((void) sizeof ((col_is_filled(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (col_is_filled(0, my_square) == 0) ; else __assert_fail ("col_is_filled(0, my_square) == 0", "test.c", 9, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((row_is_filled(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (row_is_filled(0, my_square) == 0) ; else __assert_fail ("row_is_filled(0, my_square) == 0", "test.c", 10, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((col_is_valid(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (col_is_valid(0, my_square) == 1) ; else __assert_fail ("col_is_valid(0, my_square) == 1", "test.c", 11, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((row_is_valid(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (row_is_valid(0, my_square) == 1) ; else __assert_fail ("row_is_valid(0, my_square) == 1", "test.c", 12, __extension__ __PRETTY_FUNCTION__); }));
    my_square->grid[0] = 'a';
    ((void) sizeof ((col_is_filled(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (col_is_filled(0, my_square) == 0) ; else __assert_fail ("col_is_filled(0, my_square) == 0", "test.c", 15, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((row_is_filled(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (row_is_filled(0, my_square) == 0) ; else __assert_fail ("row_is_filled(0, my_square) == 0", "test.c", 16, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((col_is_valid(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (col_is_valid(0, my_square) == 1) ; else __assert_fail ("col_is_valid(0, my_square) == 1", "test.c", 17, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((row_is_valid(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (row_is_valid(0, my_square) == 1) ; else __assert_fail ("row_is_valid(0, my_square) == 1", "test.c", 18, __extension__ __PRETTY_FUNCTION__); }));
    my_square->grid[1] = 'a';
    ((void) sizeof ((col_is_filled(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (col_is_filled(0, my_square) == 0) ; else __assert_fail ("col_is_filled(0, my_square) == 0", "test.c", 21, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((row_is_filled(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (row_is_filled(0, my_square) == 0) ; else __assert_fail ("row_is_filled(0, my_square) == 0", "test.c", 22, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((col_is_valid(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (col_is_valid(0, my_square) == 1) ; else __assert_fail ("col_is_valid(0, my_square) == 1", "test.c", 23, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((row_is_valid(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (row_is_valid(0, my_square) == 0) ; else __assert_fail ("row_is_valid(0, my_square) == 0", "test.c", 24, __extension__ __PRETTY_FUNCTION__); }));
    my_square->grid[1] = 'b';
    ((void) sizeof ((col_is_filled(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (col_is_filled(0, my_square) == 0) ; else __assert_fail ("col_is_filled(0, my_square) == 0", "test.c", 27, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((row_is_filled(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (row_is_filled(0, my_square) == 0) ; else __assert_fail ("row_is_filled(0, my_square) == 0", "test.c", 28, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((col_is_valid(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (col_is_valid(0, my_square) == 1) ; else __assert_fail ("col_is_valid(0, my_square) == 1", "test.c", 29, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((row_is_valid(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (row_is_valid(0, my_square) == 1) ; else __assert_fail ("row_is_valid(0, my_square) == 1", "test.c", 30, __extension__ __PRETTY_FUNCTION__); }));
    int i;
    for (i = 0; i < my_square->width; i++) {
        char* row_ptr = my_square->grid + i * my_square->width;
        memcpy(row_ptr, my_square->alphabet, 4);
        ((void) sizeof ((row_is_filled(i, my_square) == 1) ? 1 : 0), __extension__ ({ if (row_is_filled(i, my_square) == 1) ; else __assert_fail ("row_is_filled(i, my_square) == 1", "test.c", 36, __extension__ __PRETTY_FUNCTION__); }));
        ((void) sizeof ((row_is_valid(i, my_square) == 1) ? 1 : 0), __extension__ ({ if (row_is_valid(i, my_square) == 1) ; else __assert_fail ("row_is_valid(i, my_square) == 1", "test.c", 37, __extension__ __PRETTY_FUNCTION__); }));
        row_ptr[3] = '.';
        ((void) sizeof ((row_is_filled(i, my_square) == 0) ? 1 : 0), __extension__ ({ if (row_is_filled(i, my_square) == 0) ; else __assert_fail ("row_is_filled(i, my_square) == 0", "test.c", 40, __extension__ __PRETTY_FUNCTION__); }));
        ((void) sizeof ((row_is_valid(i, my_square) == 1) ? 1 : 0), __extension__ ({ if (row_is_valid(i, my_square) == 1) ; else __assert_fail ("row_is_valid(i, my_square) == 1", "test.c", 41, __extension__ __PRETTY_FUNCTION__); }));
        row_ptr[3] = 'd';
        row_ptr[0] = '.';
        ((void) sizeof ((row_is_filled(i, my_square) == 0) ? 1 : 0), __extension__ ({ if (row_is_filled(i, my_square) == 0) ; else __assert_fail ("row_is_filled(i, my_square) == 0", "test.c", 45, __extension__ __PRETTY_FUNCTION__); }));
        ((void) sizeof ((row_is_valid(i, my_square) == 1) ? 1 : 0), __extension__ ({ if (row_is_valid(i, my_square) == 1) ; else __assert_fail ("row_is_valid(i, my_square) == 1", "test.c", 46, __extension__ __PRETTY_FUNCTION__); }));
    }
    free(my_square->grid);
    init_latin_square(my_square->alphabet, my_square);
    my_square->grid[0] = 'a';
    my_square->grid[4] = 'b';
    ((void) sizeof ((col_is_filled(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (col_is_filled(0, my_square) == 0) ; else __assert_fail ("col_is_filled(0, my_square) == 0", "test.c", 55, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((col_is_valid(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (col_is_valid(0, my_square) == 1) ; else __assert_fail ("col_is_valid(0, my_square) == 1", "test.c", 56, __extension__ __PRETTY_FUNCTION__); }));
    my_square->grid[8] = 'c';
    my_square->grid[12] = 'd';
    ((void) sizeof ((col_is_filled(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (col_is_filled(0, my_square) == 1) ; else __assert_fail ("col_is_filled(0, my_square) == 1", "test.c", 60, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((col_is_valid(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (col_is_valid(0, my_square) == 1) ; else __assert_fail ("col_is_valid(0, my_square) == 1", "test.c", 61, __extension__ __PRETTY_FUNCTION__); }));
    my_square->grid[0] = '.';
    ((void) sizeof ((col_is_filled(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (col_is_filled(0, my_square) == 0) ; else __assert_fail ("col_is_filled(0, my_square) == 0", "test.c", 64, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((col_is_valid(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (col_is_valid(0, my_square) == 1) ; else __assert_fail ("col_is_valid(0, my_square) == 1", "test.c", 65, __extension__ __PRETTY_FUNCTION__); }));
    my_square->grid[0] = 'a';
    my_square->grid[4] = 'a';
    my_square->grid[8] = 'a';
    my_square->grid[12] = 'a';
    ((void) sizeof ((col_is_filled(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (col_is_filled(0, my_square) == 1) ; else __assert_fail ("col_is_filled(0, my_square) == 1", "test.c", 71, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((col_is_valid(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (col_is_valid(0, my_square) == 0) ; else __assert_fail ("col_is_valid(0, my_square) == 0", "test.c", 72, __extension__ __PRETTY_FUNCTION__); }));
    latin_square* my_square_2 = malloc(sizeof(latin_square));
    init_latin_square("ab", my_square_2);
    my_square_2->grid = "abba";
    ((void) sizeof ((square_complete(my_square_2)) ? 1 : 0), __extension__ ({ if (square_complete(my_square_2)) ; else __assert_fail ("square_complete(my_square_2)", "test.c", 77, __extension__ __PRETTY_FUNCTION__); }));
    init_latin_square("abcd", my_square_2);
    solve_latin_square(my_square_2, 0);
    ((void) sizeof ((square_complete(my_square_2)) ? 1 : 0), __extension__ ({ if (square_complete(my_square_2)) ; else __assert_fail ("square_complete(my_square_2)", "test.c", 81, __extension__ __PRETTY_FUNCTION__); }));
}

canonical_original_code:
void test() {
    struct _latin_square *my_square = malloc(sizeof(latin_square));
    init_latin_square("abcd", my_square);
    ((void) sizeof ((col_is_filled(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (col_is_filled(0, my_square) == 0) ; else __assert_fail ("col_is_filled(0, my_square) == 0", "test.c", 9, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((row_is_filled(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (row_is_filled(0, my_square) == 0) ; else __assert_fail ("row_is_filled(0, my_square) == 0", "test.c", 10, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((col_is_valid(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (col_is_valid(0, my_square) == 1) ; else __assert_fail ("col_is_valid(0, my_square) == 1", "test.c", 11, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((row_is_valid(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (row_is_valid(0, my_square) == 1) ; else __assert_fail ("row_is_valid(0, my_square) == 1", "test.c", 12, __extension__ __PRETTY_FUNCTION__); }));
    my_square->grid[0] = 'a';
    ((void) sizeof ((col_is_filled(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (col_is_filled(0, my_square) == 0) ; else __assert_fail ("col_is_filled(0, my_square) == 0", "test.c", 15, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((row_is_filled(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (row_is_filled(0, my_square) == 0) ; else __assert_fail ("row_is_filled(0, my_square) == 0", "test.c", 16, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((col_is_valid(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (col_is_valid(0, my_square) == 1) ; else __assert_fail ("col_is_valid(0, my_square) == 1", "test.c", 17, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((row_is_valid(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (row_is_valid(0, my_square) == 1) ; else __assert_fail ("row_is_valid(0, my_square) == 1", "test.c", 18, __extension__ __PRETTY_FUNCTION__); }));
    my_square->grid[1] = 'a';
    ((void) sizeof ((col_is_filled(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (col_is_filled(0, my_square) == 0) ; else __assert_fail ("col_is_filled(0, my_square) == 0", "test.c", 21, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((row_is_filled(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (row_is_filled(0, my_square) == 0) ; else __assert_fail ("row_is_filled(0, my_square) == 0", "test.c", 22, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((col_is_valid(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (col_is_valid(0, my_square) == 1) ; else __assert_fail ("col_is_valid(0, my_square) == 1", "test.c", 23, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((row_is_valid(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (row_is_valid(0, my_square) == 0) ; else __assert_fail ("row_is_valid(0, my_square) == 0", "test.c", 24, __extension__ __PRETTY_FUNCTION__); }));
    my_square->grid[1] = 'b';
    ((void) sizeof ((col_is_filled(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (col_is_filled(0, my_square) == 0) ; else __assert_fail ("col_is_filled(0, my_square) == 0", "test.c", 27, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((row_is_filled(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (row_is_filled(0, my_square) == 0) ; else __assert_fail ("row_is_filled(0, my_square) == 0", "test.c", 28, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((col_is_valid(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (col_is_valid(0, my_square) == 1) ; else __assert_fail ("col_is_valid(0, my_square) == 1", "test.c", 29, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((row_is_valid(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (row_is_valid(0, my_square) == 1) ; else __assert_fail ("row_is_valid(0, my_square) == 1", "test.c", 30, __extension__ __PRETTY_FUNCTION__); }));
    int i;
    for (i = 0; i < my_square->width; i++) {
        char *row_ptr = my_square->grid + i * my_square->width;
        memcpy(row_ptr, my_square->alphabet, 4);
        ((void) sizeof ((row_is_filled(i, my_square) == 1) ? 1 : 0), __extension__ ({ if (row_is_filled(i, my_square) == 1) ; else __assert_fail ("row_is_filled(i, my_square) == 1", "test.c", 36, __extension__ __PRETTY_FUNCTION__); }));
        ((void) sizeof ((row_is_valid(i, my_square) == 1) ? 1 : 0), __extension__ ({ if (row_is_valid(i, my_square) == 1) ; else __assert_fail ("row_is_valid(i, my_square) == 1", "test.c", 37, __extension__ __PRETTY_FUNCTION__); }));
        row_ptr[3] = '.';
        ((void) sizeof ((row_is_filled(i, my_square) == 0) ? 1 : 0), __extension__ ({ if (row_is_filled(i, my_square) == 0) ; else __assert_fail ("row_is_filled(i, my_square) == 0", "test.c", 40, __extension__ __PRETTY_FUNCTION__); }));
        ((void) sizeof ((row_is_valid(i, my_square) == 1) ? 1 : 0), __extension__ ({ if (row_is_valid(i, my_square) == 1) ; else __assert_fail ("row_is_valid(i, my_square) == 1", "test.c", 41, __extension__ __PRETTY_FUNCTION__); }));
        row_ptr[3] = 'd';
        row_ptr[0] = '.';
        ((void) sizeof ((row_is_filled(i, my_square) == 0) ? 1 : 0), __extension__ ({ if (row_is_filled(i, my_square) == 0) ; else __assert_fail ("row_is_filled(i, my_square) == 0", "test.c", 45, __extension__ __PRETTY_FUNCTION__); }));
        ((void) sizeof ((row_is_valid(i, my_square) == 1) ? 1 : 0), __extension__ ({ if (row_is_valid(i, my_square) == 1) ; else __assert_fail ("row_is_valid(i, my_square) == 1", "test.c", 46, __extension__ __PRETTY_FUNCTION__); }));
    }
    free(my_square->grid);
    init_latin_square(my_square->alphabet, my_square);
    my_square->grid[0] = 'a';
    my_square->grid[4] = 'b';
    ((void) sizeof ((col_is_filled(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (col_is_filled(0, my_square) == 0) ; else __assert_fail ("col_is_filled(0, my_square) == 0", "test.c", 55, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((col_is_valid(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (col_is_valid(0, my_square) == 1) ; else __assert_fail ("col_is_valid(0, my_square) == 1", "test.c", 56, __extension__ __PRETTY_FUNCTION__); }));
    my_square->grid[8] = 'c';
    my_square->grid[12] = 'd';
    ((void) sizeof ((col_is_filled(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (col_is_filled(0, my_square) == 1) ; else __assert_fail ("col_is_filled(0, my_square) == 1", "test.c", 60, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((col_is_valid(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (col_is_valid(0, my_square) == 1) ; else __assert_fail ("col_is_valid(0, my_square) == 1", "test.c", 61, __extension__ __PRETTY_FUNCTION__); }));
    my_square->grid[0] = '.';
    ((void) sizeof ((col_is_filled(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (col_is_filled(0, my_square) == 0) ; else __assert_fail ("col_is_filled(0, my_square) == 0", "test.c", 64, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((col_is_valid(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (col_is_valid(0, my_square) == 1) ; else __assert_fail ("col_is_valid(0, my_square) == 1", "test.c", 65, __extension__ __PRETTY_FUNCTION__); }));
    my_square->grid[0] = 'a';
    my_square->grid[4] = 'a';
    my_square->grid[8] = 'a';
    my_square->grid[12] = 'a';
    ((void) sizeof ((col_is_filled(0, my_square) == 1) ? 1 : 0), __extension__ ({ if (col_is_filled(0, my_square) == 1) ; else __assert_fail ("col_is_filled(0, my_square) == 1", "test.c", 71, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((col_is_valid(0, my_square) == 0) ? 1 : 0), __extension__ ({ if (col_is_valid(0, my_square) == 0) ; else __assert_fail ("col_is_valid(0, my_square) == 0", "test.c", 72, __extension__ __PRETTY_FUNCTION__); }));
    struct _latin_square *my_square_2 = malloc(sizeof(latin_square));
    init_latin_square("ab", my_square_2);
    my_square_2->grid = "abba";
    ((void) sizeof ((square_complete(my_square_2)) ? 1 : 0), __extension__ ({ if (square_complete(my_square_2)) ; else __assert_fail ("square_complete(my_square_2)", "test.c", 77, __extension__ __PRETTY_FUNCTION__); }));
    init_latin_square("abcd", my_square_2);
    solve_latin_square(my_square_2, 0);
    ((void) sizeof ((square_complete(my_square_2)) ? 1 : 0), __extension__ ({ if (square_complete(my_square_2)) ; else __assert_fail ("square_complete(my_square_2)", "test.c", 81, __extension__ __PRETTY_FUNCTION__); }));
}

variable_types: struct _latin_square { unsigned int width; char *grid; char *orig_grid; char *alphabet; } *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
test(argc, argv, envp);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func0(argc, argv, envp);
return 0;
}

original_code:
int main() {
    test();
    return 0;
}

canonical_original_code:
int main() {
    test();
    return 0;
}


decompiled_code:
__int64 __fastcall randomize_char(__int64 a1, int a2, int a3)
{
__int64 v4; // r13
unsigned int v5; // edx
__int64 result; // rax

v4 = *(_QWORD *)(a1 + 24);
v5 = (unsigned int)rand() % *(_DWORD *)a1;
result = (unsigned int)(a3 * *(_DWORD *)a1 + a2);
*(_BYTE *)(*(_QWORD *)(a1 + 8) + result) = *(_BYTE *)(v4 + v5);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, int a2, int a3)
{
__int64 v4; // r13
unsigned int v5; // edx
__int64 result; // rax

v4 = *(_QWORD *)(a1 + 24);
v5 = (unsigned int)rand() % *(_DWORD *)a1;
result = (unsigned int)(a3 * *(_DWORD *)a1 + a2);
*(_BYTE *)(*(_QWORD *)(a1 + 8) + result) = *(_BYTE *)(v4 + v5);
return result;
}

original_code:
static void randomize_char(latin_square* square, unsigned x, unsigned y) {
    square->grid[y * square->width + x] = square->alphabet[rand() % square->width];
}

canonical_original_code:
static void randomize_char(struct _latin_square *square, unsigned int x, unsigned int y) {
    square->grid[y * square->width + x] = square->alphabet[rand() % square->width];
}

variable_types:
x
unsigned int

variable_types:
y
unsigned int

user_defined_types: struct _latin_square { unsigned int width; char *grid; char *orig_grid; char *alphabet; }


strip

decompiled_code:
__int64 __fastcall strip(char *s)
{
unsigned int v1; // ebx
size_t v2; // rcx
__int64 result; // rax
char v4; // dl

v1 = 0;
v2 = strlen(s);
while ( 1 )
{
result = v1;
if ( v1 >= v2 )
break;
v4 = s[v1];
if ( v4 == 10 || v4 == 32 )
{
strcpy(&s[v1], &s[v1 + 1]);
v2 = strlen(s);
}
++v1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(char *s)
{
unsigned int v1; // ebx
size_t v2; // rcx
__int64 result; // rax
char v4; // dl

v1 = 0;
v2 = strlen(s);
while ( 1 )
{
result = v1;
if ( v1 >= v2 )
break;
v4 = s[v1];
if ( v4 == 10 || v4 == 32 )
{
strcpy(&s[v1], &s[v1 + 1]);
v2 = strlen(s);
}
++v1;
}
return result;
}

original_code:
void strip(char* string) {
    unsigned i = 0;
    for (i = 0; i < strlen(string); i++) {
        if (string[i] == '\n' || string[i] == ' ') {
            strcpy(string + i, string + i + 1);
        }
    }
}

canonical_original_code:
void strip(char *string) {
    unsigned int i = 0;
    for (i = 0; i < strlen(string); i++) {
        if (string[i] == '\n' || string[i] == ' ') {
            strcpy(string + i, string + i + 1);
        }
    }
}

variable_types:
string
char *

variable_types:
i
unsigned int


decompiled_code:
void *__fastcall init_latin_square(const char *a1, __int64 a2)
{
unsigned int v2; // eax
size_t v3; // rbx
size_t v4; // r12
void *v5; // rax
void *v6; // r15
void *v7; // rax
void *v8; // r14
void *result; // rax

v2 = strlen(a1);
*(_DWORD *)a2 = v2;
v3 = v2 * (unsigned __int64)v2;
v4 = v2 * v2;
v5 = malloc(v3);
*(_QWORD *)(a2 + 8) = v5;
v6 = v5;
v7 = malloc(v3);
*(_QWORD *)(a2 + 16) = v7;
v8 = v7;
memset(v6, 46, v4);
result = memset(v8, 46, v4);
*(_QWORD *)(a2 + 24) = a1;
return result;
}

canonical_decompiled_code:
void *__fastcall func11(const char *a1, __int64 a2)
{
unsigned int v2; // eax
size_t v3; // rbx
size_t v4; // r12
void *v5; // rax
void *v6; // r15
void *v7; // rax
void *v8; // r14
void *result; // rax

v2 = strlen(a1);
*(_DWORD *)a2 = v2;
v3 = v2 * (unsigned __int64)v2;
v4 = v2 * v2;
v5 = malloc(v3);
*(_QWORD *)(a2 + 8) = v5;
v6 = v5;
v7 = malloc(v3);
*(_QWORD *)(a2 + 16) = v7;
v8 = v7;
memset(v6, 46, v4);
result = memset(v8, 46, v4);
*(_QWORD *)(a2 + 24) = a1;
return result;
}

original_code:
void init_latin_square(char* alphabet, latin_square* square) {
    square->width = strlen(alphabet);
    square->grid = malloc(sizeof(char) * square->width * square->width);
    square->orig_grid = malloc(sizeof(char) * square->width * square->width);
    memset(square->grid, placeholder_char, square->width * square->width);
    memset(square->orig_grid, placeholder_char, square->width * square->width);
    square->alphabet = alphabet;
}

canonical_original_code:
void init_latin_square(char *alphabet, struct _latin_square *square) {
    square->width = strlen(alphabet);
    square->grid = malloc(sizeof(char) * square->width * square->width);
    square->orig_grid = malloc(sizeof(char) * square->width * square->width);
    memset(square->grid, placeholder_char, square->width * square->width);
    memset(square->orig_grid, placeholder_char, square->width * square->width);
    square->alphabet = alphabet;
}

variable_types:
alphabet
char *


decompiled_code:
void *__fastcall take_string_descriptor(void *src, __int64 a2)
{
memcpy(*(void **)(a2 + 8), src, (unsigned int)(*(_DWORD *)a2 * *(_DWORD *)a2));
return memcpy(*(void **)(a2 + 16), src, (unsigned int)(*(_DWORD *)a2 * *(_DWORD *)a2));
}

canonical_decompiled_code:
void *__fastcall func12(void *src, __int64 a2)
{
memcpy(*(void **)(a2 + 8), src, (unsigned int)(*(_DWORD *)a2 * *(_DWORD *)a2));
return memcpy(*(void **)(a2 + 16), src, (unsigned int)(*(_DWORD *)a2 * *(_DWORD *)a2));
}

original_code:
void take_string_descriptor(char* string, latin_square* square) {
    int i;
    memcpy(square->grid, string, square->width * square->width);
    memcpy(square->orig_grid, string, square->width * square->width);
}

canonical_original_code:
void take_string_descriptor(char *string, struct _latin_square *square) {
    int i;
    memcpy(square->grid, string, square->width * square->width);
    memcpy(square->orig_grid, string, square->width * square->width);
}


decompiled_code:
__int64 __fastcall row_is_filled(int a1, __int64 a2)
{
__int64 v2; // rdx
__int64 v3; // rdi
_BYTE *v4; // rax
__int64 v5; // rdx

v2 = *(_QWORD *)(a2 + 8);
v3 = (unsigned int)(*(_DWORD *)a2 * a1);
if ( !*(_DWORD *)a2 )
return 1LL;
v4 = (_BYTE *)(v2 + v3);
v5 = (unsigned int)(*(_DWORD *)a2 - 1) + v2 + v3 + 1;
while ( *v4 != 46 )
{
if ( ++v4 == (_BYTE *)v5 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func13(int a1, __int64 a2)
{
__int64 v2; // rdx
__int64 v3; // rdi
_BYTE *v4; // rax
__int64 v5; // rdx

v2 = *(_QWORD *)(a2 + 8);
v3 = (unsigned int)(*(_DWORD *)a2 * a1);
if ( !*(_DWORD *)a2 )
return 1LL;
v4 = (_BYTE *)(v2 + v3);
v5 = (unsigned int)(*(_DWORD *)a2 - 1) + v2 + v3 + 1;
while ( *v4 != 46 )
{
if ( ++v4 == (_BYTE *)v5 )
return 1LL;
}
return 0LL;
}

original_code:
_Bool row_is_filled(unsigned row, latin_square* square) {
    char* row_ptr = square->grid + row * square->width;
    int i;
    for (i = 0; i < square->width; i++) {
        if (row_ptr[i] == placeholder_char) return 0;
    }
    return 1;
}

canonical_original_code:
_Bool row_is_filled(unsigned int row, struct _latin_square *square) {
    char *row_ptr = square->grid + row * square->width;
    int i;
    for (i = 0; i < square->width; i++) {
        if (row_ptr[i] == placeholder_char) return 0;
    }
    return 1;
}

variable_types:
row
unsigned int


decompiled_code:
__int64 __fastcall col_is_filled(unsigned int a1, int *a2)
{
int v2; // ecx
unsigned int v3; // eax
int v4; // edx
__int64 v5; // rdi

v2 = *a2;
if ( !*a2 )
return 1LL;
v3 = 0;
v4 = 0;
v5 = *((_QWORD *)a2 + 1) + a1;
while ( *(_BYTE *)(v5 + v3) != 46 )
{
++v4;
v3 += v2;
if ( v4 == v2 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func14(unsigned int a1, int *a2)
{
int v2; // ecx
unsigned int v3; // eax
int v4; // edx
__int64 v5; // rdi

v2 = *a2;
if ( !*a2 )
return 1LL;
v3 = 0;
v4 = 0;
v5 = *((_QWORD *)a2 + 1) + a1;
while ( *(_BYTE *)(v5 + v3) != 46 )
{
++v4;
v3 += v2;
if ( v4 == v2 )
return 1LL;
}
return 0LL;
}

original_code:
_Bool col_is_filled(unsigned col, latin_square* square) {
    int i;
    for (i = 0; i < square->width; i++) {
        char* row_ptr = square->grid + i * square->width;
        if (row_ptr[col] == placeholder_char) return 0;
    }
    return 1;
}

canonical_original_code:
_Bool col_is_filled(unsigned int col, struct _latin_square *square) {
    int i;
    for (i = 0; i < square->width; i++) {
        char *row_ptr = square->grid + i * square->width;
        if (row_ptr[col] == placeholder_char) return 0;
    }
    return 1;
}

variable_types:
col
unsigned int