simulate

decompiled_code:
__int64 simulate()
{
double v0; // rbx
double v1; // xmm0_8
double v2; // xmm0_8
int v3; // xmm0_4
double v4; // xmm0_8
double v5; // xmm0_8
int v6; // xmm0_4
double v7; // rbx
double v8; // xmm1_8
int v9; // xmm0_4
double v10; // xmm0_8
double v11; // xmm0_8
int v12; // xmm1_4
double v13; // xmm0_8
double v14; // xmm0_8
int v15; // xmm0_4
double v16; // xmm0_8
double v17; // xmm0_8
int v18; // xmm0_4
double v19; // xmm0_8
double v20; // xmm0_8
int v21; // xmm1_4
float v23; // [rsp+8h] [rbp-10h]
double v24; // [rsp+8h] [rbp-10h]
double v25; // [rsp+8h] [rbp-10h]
double v26; // [rsp+8h] [rbp-10h]
double v27; // [rsp+8h] [rbp-10h]
double v28; // [rsp+8h] [rbp-10h]

if ( (float)((float)rand() * 4.6566129e-10) < 0.02 )
curLoad = (int)((float)((float)rand() * 5.0) * 4.656612873077393e-10);
v23 = load[curLoad];
*(float *)&voltage = *(float *)&voltage - v23;
if ( chargeMode == 1 )
{
v7 = charge(t_0);
v8 = *(float *)&timer;
if ( *(float *)&timer < 0.0 )
sqrt(v8);
else
v8 = sqrt(v8);
*(float *)&v9 = *(float *)&voltage + v8 * v7;
voltage = v9;
}
else
{
v0 = charge(t_0);
v1 = *(float *)&timer;
if ( *(float *)&timer < 0.0 )
v2 = sqrt(v1);
else
v2 = sqrt(v1);
*(float *)&v3 = v2 * v0 / 10.0 + *(float *)&voltage;
voltage = v3;
}
if ( *(float *)&voltage < 0.0 )
{
voltage = 0;
if ( chargeMode == 1 )
goto LABEL_34;
goto LABEL_19;
}
if ( *(float *)&voltage <= 35.0 )
{
if ( chargeMode == 1 )
{
if ( *(float *)&voltage > 25.0 )
goto LABEL_10;
if ( *(float *)&voltage > 15.0 )
{
v26 = v23;
v13 = *(float *)&timer;
if ( *(float *)&timer < 0.0 )
v14 = sqrt(v13);
else
v14 = sqrt(v13);
*(float *)&v15 = v14 / 20.0 * v26 * 10.0 + *(float *)&temperature;
temperature = v15;
goto LABEL_23;
}
LABEL_34:
v27 = v23;
v16 = *(float *)&timer;
if ( *(float *)&timer < 0.0 )
v17 = sqrt(v16);
else
v17 = sqrt(v16);
*(float *)&v18 = v17 / 15.0 * v27 * 10.0 + *(float *)&temperature;
temperature = v18;
goto LABEL_23;
}
LABEL_19:
if ( *(float *)&temperature <= 20.0 )
{
v28 = v23;
v19 = *(float *)&timer;
if ( *(float *)&timer < 0.0 )
v20 = sqrt(v19);
else
v20 = sqrt(v19);
*(float *)&v21 = *(float *)&temperature - v20 / 100.0 * v28 * 10.0;
temperature = v21;
}
else
{
v25 = v23;
v10 = *(float *)&timer;
if ( *(float *)&timer < 0.0 )
v11 = sqrt(v10);
else
v11 = sqrt(v10);
*(float *)&v12 = *(float *)&temperature - v11 / 20.0 * v25 * 10.0;
temperature = v12;
}
goto LABEL_23;
}
voltage = 1108082688;
if ( chargeMode != 1 )
goto LABEL_19;
LABEL_10:
v24 = v23;
v4 = *(float *)&timer;
if ( *(float *)&timer < 0.0 )
v5 = sqrt(v4);
else
v5 = sqrt(v4);
*(float *)&v6 = v5 / 25.0 * v24 * 10.0 + *(float *)&temperature;
temperature = v6;
LABEL_23:
if ( *(float *)&temperature < 0.0 )
{
temperature = 0;
}
else if ( *(float *)&temperature > 40.0 )
{
temperature = 1109393408;
}
++t_0;
return 0LL;
}

canonical_decompiled_code:
__int64 func13()
{
double v0; // rbx
double v1; // xmm0_8
double v2; // xmm0_8
int v3; // xmm0_4
double v4; // xmm0_8
double v5; // xmm0_8
int v6; // xmm0_4
double v7; // rbx
double v8; // xmm1_8
int v9; // xmm0_4
double v10; // xmm0_8
double v11; // xmm0_8
int v12; // xmm1_4
double v13; // xmm0_8
double v14; // xmm0_8
int v15; // xmm0_4
double v16; // xmm0_8
double v17; // xmm0_8
int v18; // xmm0_4
double v19; // xmm0_8
double v20; // xmm0_8
int v21; // xmm1_4
float v23; // [rsp+8h] [rbp-10h]
double v24; // [rsp+8h] [rbp-10h]
double v25; // [rsp+8h] [rbp-10h]
double v26; // [rsp+8h] [rbp-10h]
double v27; // [rsp+8h] [rbp-10h]
double v28; // [rsp+8h] [rbp-10h]

if ( (float)((float)rand() * 4.6566129e-10) < 0.02 )
curLoad = (int)((float)((float)rand() * 5.0) * 4.656612873077393e-10);
v23 = load[curLoad];
*(float *)&voltage = *(float *)&voltage - v23;
if ( chargeMode == 1 )
{
v7 = func12(t_0);
v8 = *(float *)&timer;
if ( *(float *)&timer < 0.0 )
sqrt(v8);
else
v8 = sqrt(v8);
*(float *)&v9 = *(float *)&voltage + v8 * v7;
voltage = v9;
}
else
{
v0 = func12(t_0);
v1 = *(float *)&timer;
if ( *(float *)&timer < 0.0 )
v2 = sqrt(v1);
else
v2 = sqrt(v1);
*(float *)&v3 = v2 * v0 / 10.0 + *(float *)&voltage;
voltage = v3;
}
if ( *(float *)&voltage < 0.0 )
{
voltage = 0;
if ( chargeMode == 1 )
goto LABEL_34;
goto LABEL_19;
}
if ( *(float *)&voltage <= 35.0 )
{
if ( chargeMode == 1 )
{
if ( *(float *)&voltage > 25.0 )
goto LABEL_10;
if ( *(float *)&voltage > 15.0 )
{
v26 = v23;
v13 = *(float *)&timer;
if ( *(float *)&timer < 0.0 )
v14 = sqrt(v13);
else
v14 = sqrt(v13);
*(float *)&v15 = v14 / 20.0 * v26 * 10.0 + *(float *)&temperature;
temperature = v15;
goto LABEL_23;
}
LABEL_34:
v27 = v23;
v16 = *(float *)&timer;
if ( *(float *)&timer < 0.0 )
v17 = sqrt(v16);
else
v17 = sqrt(v16);
*(float *)&v18 = v17 / 15.0 * v27 * 10.0 + *(float *)&temperature;
temperature = v18;
goto LABEL_23;
}
LABEL_19:
if ( *(float *)&temperature <= 20.0 )
{
v28 = v23;
v19 = *(float *)&timer;
if ( *(float *)&timer < 0.0 )
v20 = sqrt(v19);
else
v20 = sqrt(v19);
*(float *)&v21 = *(float *)&temperature - v20 / 100.0 * v28 * 10.0;
temperature = v21;
}
else
{
v25 = v23;
v10 = *(float *)&timer;
if ( *(float *)&timer < 0.0 )
v11 = sqrt(v10);
else
v11 = sqrt(v10);
*(float *)&v12 = *(float *)&temperature - v11 / 20.0 * v25 * 10.0;
temperature = v12;
}
goto LABEL_23;
}
voltage = 1108082688;
if ( chargeMode != 1 )
goto LABEL_19;
LABEL_10:
v24 = v23;
v4 = *(float *)&timer;
if ( *(float *)&timer < 0.0 )
v5 = sqrt(v4);
else
v5 = sqrt(v4);
*(float *)&v6 = v5 / 25.0 * v24 * 10.0 + *(float *)&temperature;
temperature = v6;
LABEL_23:
if ( *(float *)&temperature < 0.0 )
{
temperature = 0;
}
else if ( *(float *)&temperature > 40.0 )
{
temperature = 1109393408;
}
++t_0;
return 0LL;
}

original_code:
int simulate( void )
{
  extern int chargeMode;
  static int t=0;
  if (((float)rand() / (float)2147483647) < 0.02) {
    curLoad = (int)((float)(5)*rand()/(2147483647 +1.0));
  }
  voltage -= load[curLoad];
  if (chargeMode == 1) {
    voltage += (charge(t) * sqrt(timer));
  } else {
    voltage += ((charge(t) * sqrt(timer)) / 10.0 );
  }
  if (voltage < 0.0) voltage = 0.0;
  else if (voltage > 35.0) voltage = 35.0;
  if (chargeMode == 1) {
    if (voltage > 25) {
      temperature += ((load[curLoad] * (sqrt(timer)/25.0)) * 10.0);
    } else if (voltage > 15) {
      temperature += ((load[curLoad] * (sqrt(timer)/20.0)) * 10.0);
    } else {
      temperature += ((load[curLoad] * (sqrt(timer)/15.0)) * 10.0);
    }
  } else {
    if (temperature > 20.0) {
      temperature -= ((load[curLoad] * (sqrt(timer)/20.0)) * 10.0);
    } else {
      temperature -= ((load[curLoad] * (sqrt(timer)/100.0)) * 10.0);
    }
  }
  if (temperature < 0.0) temperature = 0.0;
  else if (temperature > 40.0) temperature = 40.0;
  t++;
  return 0;
}

canonical_original_code:
int simulate()
{
  extern int chargeMode;
  static int t = 0;
  if (((float)rand() / (float)2147483647) < 0.02) {
    curLoad = (int)((float)(5)*rand()/(2147483647 +1.0));
  }
  voltage -= load[curLoad];
  if (chargeMode == 1) {
    voltage += (charge(t) * sqrt(timer));
  } else {
    voltage += ((charge(t) * sqrt(timer)) / 10.0 );
  }
  if (voltage < 0.0) voltage = 0.0;
  else if (voltage > 35.0) voltage = 35.0;
  if (chargeMode == 1) {
    if (voltage > 25) {
      temperature += ((load[curLoad] * (sqrt(timer)/25.0)) * 10.0);
    } else if (voltage > 15) {
      temperature += ((load[curLoad] * (sqrt(timer)/20.0)) * 10.0);
    } else {
      temperature += ((load[curLoad] * (sqrt(timer)/15.0)) * 10.0);
    }
  } else {
    if (temperature > 20.0) {
      temperature -= ((load[curLoad] * (sqrt(timer)/20.0)) * 10.0);
    } else {
      temperature -= ((load[curLoad] * (sqrt(timer)/100.0)) * 10.0);
    }
  }
  if (temperature < 0.0) temperature = 0.0;
  else if (temperature > 40.0) temperature = 40.0;
  t++;
  return 0;
}

variable_types: chargeMode int


emitNews

decompiled_code:
ssize_t __fastcall emitNews(int fd)
{
char *v1; // rbx
size_t v2; // rax
size_t v3; // rax
size_t v4; // rax
__int64 v5; // rbx
size_t v6; // rax
size_t v7; // rax
const char *v8; // rbx
size_t v9; // rax
size_t v10; // rax
size_t v11; // rax
size_t v12; // rax
size_t v13; // rax
char *v14; // rbx
size_t v15; // rax
char v17[344]; // [rsp+0h] [rbp-158h] BYREF

emitHTTPResponseHeader();
v1 = prologue;
v2 = strlen(prologue);
write(fd, v1, v2);
strcpy(v17, "
Web Agent Results

");
v3 = strlen(v17);
write(fd, v17, v3);
strcpy(v17, "

\n");
v4 = strlen(v17);
write(fd, v17, v4);
v5 = (unsigned int)((_DWORD)&monitors + 84);
do
{
if ( *(_DWORD *)(v5 - 84) && *(_DWORD *)(v5 + 48) )
{
sprintf(
v17,
"
%s	\n%s
\n",
(const char *)v5,
(const char *)(v5 - 80),
(const char *)(v5 - 80));
v6 = strlen(v17);
write(fd, v17, v6);
*(_DWORD *)(v5 + 52) = 1;
}
v5 += 140LL;
}
while ( v5 != (_DWORD)&monitors + 2884 );
strcpy(v17, "

\n");
v7 = strlen(v17);
write(fd, v17, v7);
v8 = (const char *)head[40];
if ( v8 )
{
strcpy(v17, "

\n");
v9 = strlen(v17);
write(fd, v17, v9);
do
{
sprintf(
v17,
"
%s	\n"
"%s	%s
",
&feed[508 * *(int *)v8 + 84],
v8 + 214,
v8 + 12,
v8 + 113);
v10 = strlen(v17);
write(fd, v17, v10);
*((_DWORD *)v8 + 79) = 1;
v8 = (const char *)*((_QWORD *)v8 + 40);
}
while ( v8 );
strcpy(v17, "

\n");
v11 = strlen(v17);
write(fd, v17, v11);
}
strcpy(v17, "<FORM METHOD=\"POST\" ACTION=/clear\">");
v12 = strlen(v17);
write(fd, v17, v12);
strcpy(v17, "

<INPUT TYPE=\"submit\" VALUE=\"Mark Read\">
\n");
v13 = strlen(v17);
write(fd, v17, v13);
v14 = epilogue;
v15 = strlen(epilogue);
return write(fd, v14, v15);
}

canonical_decompiled_code:
ssize_t __fastcall func0(int fd)
{
char *v1; // rbx
size_t v2; // rax
size_t v3; // rax
size_t v4; // rax
__int64 v5; // rbx
size_t v6; // rax
size_t v7; // rax
const char *v8; // rbx
size_t v9; // rax
size_t v10; // rax
size_t v11; // rax
size_t v12; // rax
size_t v13; // rax
char *v14; // rbx
size_t v15; // rax
char v17[344]; // [rsp+0h] [rbp-158h] BYREF

emitHTTPResponseHeader();
v1 = prologue;
v2 = strlen(prologue);
write(fd, v1, v2);
strcpy(v17, "
Web Agent Results

");
v3 = strlen(v17);
write(fd, v17, v3);
strcpy(v17, "

\n");
v4 = strlen(v17);
write(fd, v17, v4);
v5 = (unsigned int)((_DWORD)&monitors + 84);
do
{
if ( *(_DWORD *)(v5 - 84) && *(_DWORD *)(v5 + 48) )
{
sprintf(
v17,
"
%s	\n%s
\n",
(const char *)v5,
(const char *)(v5 - 80),
(const char *)(v5 - 80));
v6 = strlen(v17);
write(fd, v17, v6);
*(_DWORD *)(v5 + 52) = 1;
}
v5 += 140LL;
}
while ( v5 != (_DWORD)&monitors + 2884 );
strcpy(v17, "

\n");
v7 = strlen(v17);
write(fd, v17, v7);
v8 = (const char *)head[40];
if ( v8 )
{
strcpy(v17, "

\n");
v9 = strlen(v17);
write(fd, v17, v9);
do
{
sprintf(
v17,
"
%s	\n"
"%s	%s
",
&feed[508 * *(int *)v8 + 84],
v8 + 214,
v8 + 12,
v8 + 113);
v10 = strlen(v17);
write(fd, v17, v10);
*((_DWORD *)v8 + 79) = 1;
v8 = (const char *)*((_QWORD *)v8 + 40);
}
while ( v8 );
strcpy(v17, "

\n");
v11 = strlen(v17);
write(fd, v17, v11);
}
strcpy(v17, "<FORM METHOD=\"POST\" ACTION=/clear\">");
v12 = strlen(v17);
write(fd, v17, v12);
strcpy(v17, "

<INPUT TYPE=\"submit\" VALUE=\"Mark Read\">
\n");
v13 = strlen(v17);
write(fd, v17, v13);
v14 = epilogue;
v15 = strlen(epilogue);
return write(fd, v14, v15);
}

original_code:
void emitNews( int connfd )
{
  int i;
  char line[300 +1];
  elementType *walker;
  extern monitorEntryType monitors[];
  extern feedEntryType feed;
  extern elementType head;
  emitHTTPResponseHeader( connfd );
  write( connfd, prologue, strlen(prologue));
  strcpy(line,
          "
Web Agent Results

");
  write( connfd, line, strlen(line));
  strcpy(line, "

\n");
  write( connfd, line, strlen(line));
  for (i = 0 ; i < 20 ; i++) {
    if ((monitors[i].active) && (monitors[i].changed)) {
      sprintf(line, "
%s	\n"
                    "%s"
                    "
\n",
               monitors[i].urlName, monitors[i].url, monitors[i].url);
      write( connfd, line, strlen(line));
      monitors[i].shown = 1;
    }
  }
  strcpy(line, "

\n");
  write( connfd, line, strlen(line));
  walker = head.next;
  if (walker) {
    strcpy(line, "

\n");
    write( connfd, line, strlen(line));
    while (walker) {
      sprintf(line, "
%s	\n"
                    "%s	"
                    "%s
",
                    feed.groups[walker->group].groupName,
                    walker->link,
                    walker->subject,
                    walker->msgDate );
      write( connfd, line, strlen(line));
      walker->shown = 1;
      walker = walker->next;
    }
    strcpy(line, "

\n");
    write( connfd, line, strlen(line));
  }
  strcpy(line, "<FORM METHOD=\"POST\" ACTION=/clear\">");
  write( connfd, line, strlen(line));
  strcpy(line, "

<INPUT TYPE=\"submit\" VALUE=\"Mark Read\">
\n");
  write( connfd, line, strlen(line));
  write( connfd, epilogue, strlen(epilogue));
  return;
}

canonical_original_code:
void emitNews(int connfd)
{
  int i;
  char line[-1];
  struct elementStruct *walker;
  extern struct monitorEntryType monitors[];
  extern struct feedEntryType feed;
  extern struct elementStruct head;
  emitHTTPResponseHeader( connfd );
  write( connfd, prologue, strlen(prologue));
  strcpy(line,
          "
Web Agent Results

");
  write( connfd, line, strlen(line));
  strcpy(line, "

\n");
  write( connfd, line, strlen(line));
  for (i = 0 ; i < 20 ; i++) {
    if ((monitors[i].active) && (monitors[i].changed)) {
      sprintf(line, "
%s	\n"
                    "%s"
                    "
\n",
               monitors[i].urlName, monitors[i].url, monitors[i].url);
      write( connfd, line, strlen(line));
      monitors[i].shown = 1;
    }
  }
  strcpy(line, "

\n");
  write( connfd, line, strlen(line));
  walker = head.next;
  if (walker) {
    strcpy(line, "

\n");
    write( connfd, line, strlen(line));
    while (walker) {
      sprintf(line, "
%s	\n"
                    "%s	"
                    "%s
",
                    feed.groups[walker->group].groupName,
                    walker->link,
                    walker->subject,
                    walker->msgDate );
      write( connfd, line, strlen(line));
      walker->shown = 1;
      walker = walker->next;
    }
    strcpy(line, "

\n");
    write( connfd, line, strlen(line));
  }
  strcpy(line, "<FORM METHOD=\"POST\" ACTION=/clear\">");
  write( connfd, line, strlen(line));
  strcpy(line, "

<INPUT TYPE=\"submit\" VALUE=\"Mark Read\">
\n");
  write( connfd, line, strlen(line));
  write( connfd, epilogue, strlen(epilogue));
  return;
}

variable_types: connfd int

variable_types: i int

variable_types:
line
char [-1]

variable_types: struct elementStruct { int group; int rank; int msgId; char subject[-1]; char msgDate[-1]; char link[-1]; int shown; struct elementStruct *next; } *

variable_types: struct monitorEntryType { int active; char url[80]; char urlName[-1]; int length; int changed; int shown; } []

variable_types: struct feedEntryType { char url[80]; struct groupEntryType { int active; char groupName[-1]; int lastMessageRead; char searchString[10][-1]; int numSearchStrings; } groups[20]; }

return_type: void

user_defined_types: struct feedEntryType { char url[80]; struct groupEntryType groups[20]; }


emitConfig

decompiled_code:
ssize_t __fastcall emitConfig(int fd)
{
char *v1; // rbx
size_t v2; // rax
size_t v3; // rax
size_t v4; // rax
size_t v5; // rax
const char *v6; // rbx
size_t v7; // rax
size_t v8; // rax
size_t v9; // rax
size_t v10; // rax
char *v11; // rbp
const char *v12; // r12
int v13; // ebx
size_t v14; // rax
size_t v15; // rax
int v16; // er13
size_t v17; // rax
char *v18; // rbx
size_t v19; // rax
char v21[360]; // [rsp+0h] [rbp-168h] BYREF

emitHTTPResponseHeader();
v1 = prologue;
v2 = strlen(prologue);
write(fd, v1, v2);
strcpy(v21, "
Configuration

");
v3 = strlen(v21);
write(fd, v21, v3);
strcpy(v21, "Sites to Monitor

");
v4 = strlen(v21);
write(fd, v21, v4);
strcpy(v21, "

\n");
v5 = strlen(v21);
write(fd, v21, v5);
v6 = (const char *)(unsigned int)((_DWORD)&monitors + 84);
do
{
if ( *((_DWORD *)v6 - 21) )
{
sprintf(v21, "
%s	%s
\n", v6, v6 - 80);
v7 = strlen(v21);
write(fd, v21, v7);
}
v6 += 140;
}
while ( v6 != (const char *)(unsigned int)((_DWORD)&monitors + 2884) );
strcpy(v21, "

\n");
v8 = strlen(v21);
write(fd, v21, v8);
sprintf(v21, "
Feed %s

\n", feed);
v9 = strlen(v21);
write(fd, v21, v9);
strcpy(v21, "

\n");
v10 = strlen(v21);
write(fd, v21, v10);
v11 = feed;
do
{
if ( *((_DWORD *)v11 + 20) )
{
sprintf(v21, "
Group %s	\n", v11 + 84);
v15 = strlen(v21);
write(fd, v21, v15);
strcpy(v21, "\n");
v16 = *((_DWORD *)v11 + 146);
if ( v16 <= 0 )
{
*(_DWORD *)&v21[strlen(v21)] = 6105691;
}
else
{
v12 = v11 + 172;
v13 = 0;
while ( 1 )
{
strcat(v21, v12);
if ( v16 == ++v13 )
break;
if ( v13 > 0 )
strcat(v21, ", ");
v12 += 41;
}
}
strcat(v21, "
\n");
v14 = strlen(v21);
write(fd, v21, v14);
}
v11 += 508;
}
while ( v11 != (char *)(unsigned int)((_DWORD)feed + 10160) );
strcpy(v21, "

\n");
v17 = strlen(v21);
write(fd, v21, v17);
v18 = epilogue;
v19 = strlen(epilogue);
return write(fd, v18, v19);
}

canonical_decompiled_code:
ssize_t __fastcall func1(int fd)
{
char *v1; // rbx
size_t v2; // rax
size_t v3; // rax
size_t v4; // rax
size_t v5; // rax
const char *v6; // rbx
size_t v7; // rax
size_t v8; // rax
size_t v9; // rax
size_t v10; // rax
char *v11; // rbp
const char *v12; // r12
int v13; // ebx
size_t v14; // rax
size_t v15; // rax
int v16; // er13
size_t v17; // rax
char *v18; // rbx
size_t v19; // rax
char v21[360]; // [rsp+0h] [rbp-168h] BYREF

emitHTTPResponseHeader();
v1 = prologue;
v2 = strlen(prologue);
write(fd, v1, v2);
strcpy(v21, "
Configuration

");
v3 = strlen(v21);
write(fd, v21, v3);
strcpy(v21, "Sites to Monitor

");
v4 = strlen(v21);
write(fd, v21, v4);
strcpy(v21, "

\n");
v5 = strlen(v21);
write(fd, v21, v5);
v6 = (const char *)(unsigned int)((_DWORD)&monitors + 84);
do
{
if ( *((_DWORD *)v6 - 21) )
{
sprintf(v21, "
%s	%s
\n", v6, v6 - 80);
v7 = strlen(v21);
write(fd, v21, v7);
}
v6 += 140;
}
while ( v6 != (const char *)(unsigned int)((_DWORD)&monitors + 2884) );
strcpy(v21, "

\n");
v8 = strlen(v21);
write(fd, v21, v8);
sprintf(v21, "
Feed %s

\n", feed);
v9 = strlen(v21);
write(fd, v21, v9);
strcpy(v21, "

\n");
v10 = strlen(v21);
write(fd, v21, v10);
v11 = feed;
do
{
if ( *((_DWORD *)v11 + 20) )
{
sprintf(v21, "
Group %s	\n", v11 + 84);
v15 = strlen(v21);
write(fd, v21, v15);
strcpy(v21, "\n");
v16 = *((_DWORD *)v11 + 146);
if ( v16 <= 0 )
{
*(_DWORD *)&v21[strlen(v21)] = 6105691;
}
else
{
v12 = v11 + 172;
v13 = 0;
while ( 1 )
{
strcat(v21, v12);
if ( v16 == ++v13 )
break;
if ( v13 > 0 )
strcat(v21, ", ");
v12 += 41;
}
}
strcat(v21, "
\n");
v14 = strlen(v21);
write(fd, v21, v14);
}
v11 += 508;
}
while ( v11 != (char *)(unsigned int)((_DWORD)feed + 10160) );
strcpy(v21, "

\n");
v17 = strlen(v21);
write(fd, v21, v17);
v18 = epilogue;
v19 = strlen(epilogue);
return write(fd, v18, v19);
}

original_code:
void emitConfig( int connfd )
{
  char line[300 +1];
  int i, j;
  extern monitorEntryType monitors[];
  extern feedEntryType feed;
  emitHTTPResponseHeader( connfd );
  write( connfd, prologue, strlen(prologue));
  strcpy(line, "
Configuration

");
  write( connfd, line, strlen(line));
  strcpy(line, "Sites to Monitor

");
  write( connfd, line, strlen(line));
  strcpy(line, "

\n");
  write( connfd, line, strlen(line));
  for (i = 0 ; i < 20 ; i++) {
    if (monitors[i].active) {
      sprintf(line, "
%s	"
                    "%s
\n",
               monitors[i].urlName, monitors[i].url);
      write( connfd, line, strlen(line));
    }
  }
  strcpy(line, "

\n");
  write( connfd, line, strlen(line));
  sprintf(line,
    "
Feed %s

\n", feed.url);
  write( connfd, line, strlen(line));
  strcpy(line, "

\n");
  write( connfd, line, strlen(line));
  for (i = 0 ; i < 20 ; i++) {
    if (feed.groups[i].active) {
      sprintf(line, "
Group %s	\n",
               feed.groups[i].groupName);
      write( connfd, line, strlen(line));
      strcpy(line, "\n");
      if (feed.groups[i].numSearchStrings > 0) {
        for (j = 0 ; j < feed.groups[i].numSearchStrings ; j++) {
          if (j > 0) strcat(line, ", ");
          strcat(line, feed.groups[i].searchString[j]);
        }
      } else {
        strcat(line, "[*]");
      }
      strcat(line, "
\n");
      write( connfd, line, strlen(line) );
    }
  }
  strcpy(line, "

\n");
  write( connfd, line, strlen(line));
  write( connfd, epilogue, strlen(epilogue));
  return;
}

canonical_original_code:
void emitConfig(int connfd)
{
  char line[-1];
  int i; int j;
  extern struct monitorEntryType monitors[];
  extern struct feedEntryType feed;
  emitHTTPResponseHeader( connfd );
  write( connfd, prologue, strlen(prologue));
  strcpy(line, "
Configuration

");
  write( connfd, line, strlen(line));
  strcpy(line, "Sites to Monitor

");
  write( connfd, line, strlen(line));
  strcpy(line, "

\n");
  write( connfd, line, strlen(line));
  for (i = 0 ; i < 20 ; i++) {
    if (monitors[i].active) {
      sprintf(line, "
%s	"
                    "%s
\n",
               monitors[i].urlName, monitors[i].url);
      write( connfd, line, strlen(line));
    }
  }
  strcpy(line, "

\n");
  write( connfd, line, strlen(line));
  sprintf(line,
    "
Feed %s

\n", feed.url);
  write( connfd, line, strlen(line));
  strcpy(line, "

\n");
  write( connfd, line, strlen(line));
  for (i = 0 ; i < 20 ; i++) {
    if (feed.groups[i].active) {
      sprintf(line, "
Group %s	\n",
               feed.groups[i].groupName);
      write( connfd, line, strlen(line));
      strcpy(line, "\n");
      if (feed.groups[i].numSearchStrings > 0) {
        for (j = 0 ; j < feed.groups[i].numSearchStrings ; j++) {
          if (j > 0) strcat(line, ", ");
          strcat(line, feed.groups[i].searchString[j]);
        }
      } else {
        strcat(line, "[*]");
      }
      strcat(line, "
\n");
      write( connfd, line, strlen(line) );
    }
  }
  strcpy(line, "

\n");
  write( connfd, line, strlen(line));
  write( connfd, epilogue, strlen(epilogue));
  return;
}

variable_types: j int

user_defined_types: struct monitorEntryType { int active; char url[80]; char urlName[-1]; int length; int changed; int shown; }

user_defined_types: struct groupEntryType { int active; char groupName[-1]; int lastMessageRead; char searchString[10][-1]; int numSearchStrings; }


emitArticle

decompiled_code:
__int64 __fastcall emitArticle(int fd, __int64 a2)
{
char *v2; // r12
size_t v3; // rax
char *v4; // rbp
size_t v5; // rax
size_t v7; // rax
size_t v8; // rax
size_t v9; // rax
size_t v10; // rax
char *v11; // rbp
size_t v12; // rax
size_t v13; // rax
char v14[304]; // [rsp+0h] [rbp-298h] BYREF
void *ptr; // [rsp+130h] [rbp-168h] BYREF
int v16; // [rsp+138h] [rbp-160h]
char v17[101]; // [rsp+140h] [rbp-158h] BYREF
char v18[101]; // [rsp+1A5h] [rbp-F3h] BYREF
char v19[102]; // [rsp+20Ah] [rbp-8Eh] BYREF
char *s; // [rsp+270h] [rbp-28h]
int v21; // [rsp+278h] [rbp-20h] BYREF
int v22; // [rsp+27Ch] [rbp-1Ch] BYREF

emitHTTPResponseHeader();
v2 = prologue;
v3 = strlen(prologue);
write(fd, v2, v3);
_isoc99_sscanf(a2, "/art%d_%d", &v22, &v21);
ptr = malloc(0x10001uLL);
memset(ptr, 0, 0x10001uLL);
v16 = 0x10000;
prune(feed, v14);
if ( !(unsigned int)nntpConnect(v14)
&& (int)nntpSetGroup(&feed[508 * v22 + 84], (unsigned int)(v21 - 1)) > 0
&& (int)nntpRetrieve(&ptr, 0x10000LL) > 0 )
{
if ( (unsigned int)nntpParse(&ptr, 0LL) )
{
puts("Parse error");
}
else
{
sprintf(v14, "Subject : %s\n

", v17);
v7 = strlen(v14);
write(fd, v14, v7);
sprintf(v14, "Sender : %s\n

", v18);
v8 = strlen(v14);
write(fd, v14, v8);
sprintf(v14, "Group : %s\n

", &feed[508 * v22 + 84]);
v9 = strlen(v14);
write(fd, v14, v9);
sprintf(v14, "Msg Date : %s\n

", v19);
v10 = strlen(v14);
write(fd, v14, v10);
v11 = s;
v12 = strlen(s);
write(fd, v11, v12);
strcpy(v14, "

End of Message\n

");
v13 = strlen(v14);
write(fd, v14, v13);
}
}
v4 = epilogue;
v5 = strlen(epilogue);
write(fd, v4, v5);
free(ptr);
return nntpDisconnect();
}

canonical_decompiled_code:
__int64 __fastcall func2(int fd, __int64 a2)
{
char *v2; // r12
size_t v3; // rax
char *v4; // rbp
size_t v5; // rax
size_t v7; // rax
size_t v8; // rax
size_t v9; // rax
size_t v10; // rax
char *v11; // rbp
size_t v12; // rax
size_t v13; // rax
char v14[304]; // [rsp+0h] [rbp-298h] BYREF
void *ptr; // [rsp+130h] [rbp-168h] BYREF
int v16; // [rsp+138h] [rbp-160h]
char v17[101]; // [rsp+140h] [rbp-158h] BYREF
char v18[101]; // [rsp+1A5h] [rbp-F3h] BYREF
char v19[102]; // [rsp+20Ah] [rbp-8Eh] BYREF
char *s; // [rsp+270h] [rbp-28h]
int v21; // [rsp+278h] [rbp-20h] BYREF
int v22; // [rsp+27Ch] [rbp-1Ch] BYREF

emitHTTPResponseHeader();
v2 = prologue;
v3 = strlen(prologue);
write(fd, v2, v3);
_isoc99_sscanf(a2, "/art%d_%d", &v22, &v21);
ptr = malloc(0x10001uLL);
memset(ptr, 0, 0x10001uLL);
v16 = 0x10000;
prune(feed, v14);
if ( !(unsigned int)nntpConnect(v14)
&& (int)nntpSetGroup(&feed[508 * v22 + 84], (unsigned int)(v21 - 1)) > 0
&& (int)nntpRetrieve(&ptr, 0x10000LL) > 0 )
{
if ( (unsigned int)nntpParse(&ptr, 0LL) )
{
puts("Parse error");
}
else
{
sprintf(v14, "Subject : %s\n

", v17);
v7 = strlen(v14);
write(fd, v14, v7);
sprintf(v14, "Sender : %s\n

", v18);
v8 = strlen(v14);
write(fd, v14, v8);
sprintf(v14, "Group : %s\n

", &feed[508 * v22 + 84]);
v9 = strlen(v14);
write(fd, v14, v9);
sprintf(v14, "Msg Date : %s\n

", v19);
v10 = strlen(v14);
write(fd, v14, v10);
v11 = s;
v12 = strlen(s);
write(fd, v11, v12);
strcpy(v14, "

End of Message\n

");
v13 = strlen(v14);
write(fd, v14, v13);
}
}
v4 = epilogue;
v5 = strlen(epilogue);
write(fd, v4, v5);
free(ptr);
return nntpDisconnect();
}

original_code:
void emitArticle( int connfd, char *filename )
{
  int group, article, count, result;
  news_t news;
  char line[300 +1];
  extern feedEntryType feed;
  emitHTTPResponseHeader( connfd );
  write( connfd, prologue, strlen(prologue));
  sscanf(filename, "/art%d_%d", &group, &article);
  news.msg = (char *)malloc((64*1024)+1);
  bzero( news.msg, (64*1024)+1 );
  news.msgLen = (64*1024);
  prune( feed.url, line );
  count = nntpConnect( line );
  if (count == 0) {
    count = nntpSetGroup( feed.groups[group].groupName, article-1 );
    if (count > 0) {
      result = nntpRetrieve( &news, (64*1024) );
      if (result > 0) {
        result = nntpParse( &news, 0 );
        if (result == 0) {
          sprintf( line, "Subject  : %s\n

",
                    news.subject );
          write( connfd, line, strlen(line) );
          sprintf( line, "Sender   : %s\n

",
                    news.sender );
          write( connfd, line, strlen(line) );
          sprintf( line, "Group    : %s\n

",
                    feed.groups[group].groupName );
          write( connfd, line, strlen(line) );
          sprintf( line, "Msg Date : %s\n"
                         "

",
                    news.msgDate );
          write( connfd, line, strlen(line) );
          write( connfd, news.bodyStart, strlen(news.bodyStart) );
          sprintf(line, "

End of Message\n

");
          write( connfd, line, strlen(line) );
        } else {
          printf("Parse error\n");
        }
      }
    }
  }
  write( connfd, epilogue, strlen(epilogue));
  free( news.msg );
  nntpDisconnect();
  return;
}

canonical_original_code:
void emitArticle(int connfd, char *filename)
{
  int group; int article; int count; int result;
  struct news_t news;
  char line[-1];
  extern struct feedEntryType feed;
  emitHTTPResponseHeader( connfd );
  write( connfd, prologue, strlen(prologue));
  sscanf(filename, "/art%d_%d", &group, &article);
  news.msg = (char *)malloc((64*1024)+1);
  bzero( news.msg, (64*1024)+1 );
  news.msgLen = (64*1024);
  prune( feed.url, line );
  count = nntpConnect( line );
  if (count == 0) {
    count = nntpSetGroup( feed.groups[group].groupName, article-1 );
    if (count > 0) {
      result = nntpRetrieve( &news, (64*1024) );
      if (result > 0) {
        result = nntpParse( &news, 0 );
        if (result == 0) {
          sprintf( line, "Subject  : %s\n

",
                    news.subject );
          write( connfd, line, strlen(line) );
          sprintf( line, "Sender   : %s\n

",
                    news.sender );
          write( connfd, line, strlen(line) );
          sprintf( line, "Group    : %s\n

",
                    feed.groups[group].groupName );
          write( connfd, line, strlen(line) );
          sprintf( line, "Msg Date : %s\n"
                         "

",
                    news.msgDate );
          write( connfd, line, strlen(line) );
          write( connfd, news.bodyStart, strlen(news.bodyStart) );
          sprintf(line, "

End of Message\n

");
          write( connfd, line, strlen(line) );
        } else {
          printf("Parse error\n");
        }
      }
    }
  }
  write( connfd, epilogue, strlen(epilogue));
  free( news.msg );
  nntpDisconnect();
  return;
}

variable_types:
filename
char *

variable_types: group int

variable_types: article int

variable_types: count int

variable_types: result int

variable_types: struct news_t { char *msg; int msgLen; int msgId; char subject[-1]; char sender[-1]; char msgDate[-1]; char *bodyStart; }


findEmptyMemSlot

decompiled_code:
__int64 findEmptyMemSlot()
{
char *v0; // rdx
__int64 result; // rax

v0 = &workingMemory;
result = 0LL;
do
{
if ( !*(_DWORD *)v0 )
break;
result = (unsigned int)(result + 1);
v0 += 96;
}
while ( (_DWORD)result != 40 );
return result;
}

canonical_decompiled_code:
__int64 func0()
{
char *v0; // rdx
__int64 result; // rax

v0 = &workingMemory;
result = 0LL;
do
{
if ( !*(_DWORD *)v0 )
break;
result = (unsigned int)(result + 1);
v0 += 96;
}
while ( (_DWORD)result != 40 );
return result;
}

original_code:
int findEmptyMemSlot( void )
{
  int i;
  for (i = 0 ; i < 40 ; i++) {
    if (!workingMemory[i].active) break;
  }
  return i;
}

canonical_original_code:
int findEmptyMemSlot()
{
  int i;
  for (i = 0 ; i < 40 ; i++) {
    if (!workingMemory[i].active) break;
  }
  return i;
}

return_type: int


performAddCommand

decompiled_code:
int __fastcall performAddCommand(char *src)
{
const char *v1; // rbx
int result; // eax
int v3; // eax
__int64 v4; // rdx

v1 = (const char *)(unsigned int)((_DWORD)&workingMemory + 4);
while ( 1 )
{
if ( *((_DWORD *)v1 - 1) )
{
result = strcmp(v1, src);
if ( !result )
break;
}
v1 += 96;
if ( v1 == (const char *)(unsigned int)((_DWORD)&workingMemory + 3844) )
{
v3 = findEmptyMemSlot();
if ( v3 > 39 )
_assert_fail("0", "rulefire.c", 0x6Cu, "performAddCommand");
v4 = 96LL * v3;
*(_DWORD *)(&workingMemory + v4) = 1;
strcpy(&workingMemory + v4 + 4, src);
return 1;
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(char *src)
{
const char *v1; // rbx
int result; // eax
int v3; // eax
__int64 v4; // rdx

v1 = (const char *)(unsigned int)((_DWORD)&workingMemory + 4);
while ( 1 )
{
if ( *((_DWORD *)v1 - 1) )
{
result = strcmp(v1, src);
if ( !result )
break;
}
v1 += 96;
if ( v1 == (const char *)(unsigned int)((_DWORD)&workingMemory + 3844) )
{
v3 = func0();
if ( v3 > 39 )
_assert_fail("0", "rulefire.c", 0x6Cu, "performAddCommand");
v4 = 96LL * v3;
*(_DWORD *)(&workingMemory + v4) = 1;
strcpy(&workingMemory + v4 + 4, src);
return 1;
}
}
return result;
}

original_code:
int performAddCommand( char *mem )
{
  int slot;
  for (slot = 0 ; slot < 40 ; slot++) {
    if (workingMemory[slot].active) {
      if (!strcmp( workingMemory[slot].element, mem )) {
        return 0;
      }
    }
  }
  slot = findEmptyMemSlot();
  if (slot < 40) {
    workingMemory[slot].active = 1;
    strcpy( workingMemory[slot].element, mem );
  } else {
    ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "rulefire.c", 108, __extension__ __PRETTY_FUNCTION__); }));
  }
  return 1;
}

canonical_original_code:
int performAddCommand(char *mem)
{
  int slot;
  for (slot = 0 ; slot < 40 ; slot++) {
    if (workingMemory[slot].active) {
      if (!strcmp( workingMemory[slot].element, mem )) {
        return 0;
      }
    }
  }
  slot = findEmptyMemSlot();
  if (slot < 40) {
    workingMemory[slot].active = 1;
    strcpy( workingMemory[slot].element, mem );
  } else {
    ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "rulefire.c", 108, __extension__ __PRETTY_FUNCTION__); }));
  }
  return 1;
}

variable_types:
mem
char *

variable_types: slot int


performDeleteCommand

decompiled_code:
__int64 __fastcall performDeleteCommand(__int64 a1)
{
unsigned __int64 v1; // rbx
unsigned int v2; // er13
size_t v3; // rax
size_t v4; // rax
char v6[96]; // [rsp+0h] [rbp-1A8h] BYREF
char s2[96]; // [rsp+60h] [rbp-148h] BYREF
char s1[96]; // [rsp+C0h] [rbp-E8h] BYREF
char s[136]; // [rsp+120h] [rbp-88h] BYREF

_isoc99_sscanf(a1, "(%s %s)", s, s1);
v1 = (unsigned int)((_DWORD)&workingMemory + 4);
v2 = 0;
do
{
if ( *(_DWORD *)(v1 - 4) )
{
_isoc99_sscanf(v1, "(%s %s)", s2, v6);
v3 = strlen(s);
if ( !strncmp(s, s2, v3) )
{
v4 = strlen(s1);
if ( !strncmp(s1, v6, v4) )
{
*(_DWORD *)(v1 - 4) = 0;
*(_QWORD *)v1 = 0LL;
*(_QWORD *)(v1 + 8) = 0LL;
*(_QWORD *)(v1 + 16) = 0LL;
*(_QWORD *)(v1 + 24) = 0LL;
*(_QWORD *)(v1 + 32) = 0LL;
*(_QWORD *)(v1 + 40) = 0LL;
*(_QWORD *)(v1 + 48) = 0LL;
*(_QWORD *)(v1 + 56) = 0LL;
*(_QWORD *)(v1 + 64) = 0LL;
*(_QWORD *)(v1 + 72) = 0LL;
v2 = 1;
}
}
}
v1 += 96LL;
}
while ( v1 != (_DWORD)&workingMemory + 3844 );
return v2;
}

original_code:
int performDeleteCommand( char *mem )
{
  int slot;
  int ret = 0;
  char term1[80 +1];
  char term2[80 +1];
  char wm_term1[80 +1];
  char wm_term2[80 +1];
  sscanf( mem, "(%s %s)", term1, term2 );
  for ( slot = 0 ; slot < 40 ; slot++ ) {
    if ( workingMemory[slot].active ) {
      sscanf( workingMemory[slot].element, "(%s %s)", wm_term1, wm_term2 );
      if (!strncmp(term1, wm_term1, strlen(term1)) &&
          !strncmp(term2, wm_term2, strlen(term2))) {
        workingMemory[slot].active = 0;
        bzero( workingMemory[slot].element, 80 );
        ret = 1;
      }
    }
  }
  return ret;
}

canonical_original_code:
int performDeleteCommand(char *mem)
{
  int slot;
  int ret = 0;
  char term1[-1];
  char term2[-1];
  char wm_term1[-1];
  char wm_term2[-1];
  sscanf( mem, "(%s %s)", term1, term2 );
  for ( slot = 0 ; slot < 40 ; slot++ ) {
    if ( workingMemory[slot].active ) {
      sscanf( workingMemory[slot].element, "(%s %s)", wm_term1, wm_term2 );
      if (!strncmp(term1, wm_term1, strlen(term1)) &&
          !strncmp(term2, wm_term2, strlen(term2))) {
        workingMemory[slot].active = 0;
        bzero( workingMemory[slot].element, 80 );
        ret = 1;
      }
    }
  }
  return ret;
}

variable_types: ret int


performPrintCommand

original_code:
int performPrintCommand( char *element )
{
  char string[40 +1];
  int i=0, j=0;
  while ( element[i] != '"') i++;
  i++;
  while ( element[i] != '"') string[j++] = element[i++];
  string[j] = 0;
  printf("%s\n", string);
  return 1;
}

canonical_original_code:
int performPrintCommand(char *element)
{
  char string[-1];
  int i = 0; int j = 0;
  while ( element[i] != '"') i++;
  i++;
  while ( element[i] != '"') string[j++] = element[i++];
  string[j] = 0;
  printf("%s\n", string);
  return 1;
}

variable_types:
element
char *

variable_types:
string
char [-1]


performEnableCommand

decompiled_code:
__int64 __fastcall performEnableCommand(const char *a1)
{
char *v1; // rax
unsigned int v3; // [rsp+8h] [rbp-10h] BYREF
unsigned int v4; // [rsp+Ch] [rbp-Ch] BYREF

v1 = strstr(a1, "timer");
_isoc99_sscanf(v1, "timer %d %d", &v4, &v3);
startTimer(v4, v3);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(const char *a1)
{
char *v1; // rax
unsigned int v3; // [rsp+8h] [rbp-10h] BYREF
unsigned int v4; // [rsp+Ch] [rbp-Ch] BYREF

v1 = strstr(a1, "timer");
_isoc99_sscanf(v1, "timer %d %d", &v4, &v3);
startTimer(v4, v3);
return 1LL;
}

original_code:
int performEnableCommand( char *element )
{
  char *string;
  int timer, expiration;
  void startTimer( int, int );
  string = strstr( element, "timer" );
  sscanf( string, "timer %d %d", &timer, &expiration );
  startTimer( timer, expiration );
  return 1;
}

canonical_original_code:
int performEnableCommand(char *element)
{
  char *string;
  int timer; int expiration;
  void startTimer(int, int);
  string = strstr( element, "timer" );
  sscanf( string, "timer %d %d", &timer, &expiration );
  startTimer( timer, expiration );
  return 1;
}

variable_types:
string
char *

variable_types: timer int

variable_types: expiration int

variable_types:
startTimer
void (int, int)


fireRule

decompiled_code:
__int64 __fastcall fireRule(int a1, unsigned __int8 *a2, __int64 a3, __int64 a4, unsigned int a5)
{
__int64 v5; // rbx
__int64 v7; // rbp
__int64 v8; // r13
char v10[88]; // [rsp+0h] [rbp-58h] BYREF

v5 = *((_QWORD *)&ruleSet + 13 * a1 + 12);
if ( v5 )
{
v7 = a1;
v8 = 12LL * a1;
do
{
if ( !memcmp((const void *)(v5 + 4), "(add", 4uLL) )
{
constructElement(v10, v5 + 4, a2);
a5 = performAddCommand(v10);
}
else if ( !memcmp((const void *)(v5 + 4), "(delete", 7uLL) )
{
constructElement(v10, v5 + 4, a2);
a5 = performDeleteCommand((__int64)v10);
}
else if ( !memcmp((const void *)(v5 + 4), "(disable", 8uLL) )
{
*((_DWORD *)&ruleSet + 2 * v8 + 2 * v7) = 0;
a5 = 1;
}
else if ( !memcmp((const void *)(v5 + 4), "(print", 6uLL) )
{
a5 = performPrintCommand((_BYTE *)(v5 + 4));
}
else if ( !memcmp((const void *)(v5 + 4), "(enable", 7uLL) )
{
a5 = performEnableCommand((const char *)(v5 + 4));
}
else if ( !memcmp((const void *)(v5 + 4), "(quit", 5uLL) )
{
endRun = 1;
}
v5 = *(_QWORD *)(v5 + 88);
}
while ( v5 );
}
return a5;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1, unsigned __int8 *a2, __int64 a3, __int64 a4, unsigned int a5)
{
__int64 v5; // rbx
__int64 v7; // rbp
__int64 v8; // r13
char v10[88]; // [rsp+0h] [rbp-58h] BYREF

v5 = *((_QWORD *)&ruleSet + 13 * a1 + 12);
if ( v5 )
{
v7 = a1;
v8 = 12LL * a1;
do
{
if ( !memcmp((const void *)(v5 + 4), "(add", 4uLL) )
{
func1(v10, v5 + 4, a2);
a5 = func2(v10);
}
else if ( !memcmp((const void *)(v5 + 4), "(delete", 7uLL) )
{
func1(v10, v5 + 4, a2);
a5 = func3((__int64)v10);
}
else if ( !memcmp((const void *)(v5 + 4), "(disable", 8uLL) )
{
*((_DWORD *)&ruleSet + 2 * v8 + 2 * v7) = 0;
a5 = 1;
}
else if ( !memcmp((const void *)(v5 + 4), "(print", 6uLL) )
{
a5 = func4((_BYTE *)(v5 + 4));
}
else if ( !memcmp((const void *)(v5 + 4), "(enable", 7uLL) )
{
a5 = func5((const char *)(v5 + 4));
}
else if ( !memcmp((const void *)(v5 + 4), "(quit", 5uLL) )
{
endRun = 1;
}
v5 = *(_QWORD *)(v5 + 88);
}
while ( v5 );
}
return a5;
}

original_code:
int fireRule( int rule, const char *arg )
{
  int ret;
  memoryElementType *walker = ruleSet[rule].consequent;
  char newCons[40 +1];
  while (walker) {
    if (!strncmp(walker->element, "(add", 4)) {
      constructElement( newCons, walker->element, arg );
      ret = performAddCommand( newCons );
    } else if (!strncmp(walker->element, "(delete", 7)) {
      constructElement( newCons, walker->element, arg );
      ret = performDeleteCommand( newCons );
    } else if (!strncmp(walker->element, "(disable", 8)) {
      ruleSet[rule].active = 0;
      ret = 1;
    } else if (!strncmp(walker->element, "(print", 6)) {
      ret = performPrintCommand( walker->element );
    } else if (!strncmp(walker->element, "(enable", 7)) {
      ret = performEnableCommand( walker->element );
    } else if (!strncmp(walker->element, "(quit", 5)) {
      extern int endRun;
      endRun = 1;
    }
    walker = walker->next;
  }
  return ret;
}

canonical_original_code:
int fireRule(int rule, char *arg)
{
  int ret;
  struct memoryElementStruct *walker = ruleSet[rule].consequent;
  char newCons[-1];
  while (walker) {
    if (!strncmp(walker->element, "(add", 4)) {
      constructElement( newCons, walker->element, arg );
      ret = performAddCommand( newCons );
    } else if (!strncmp(walker->element, "(delete", 7)) {
      constructElement( newCons, walker->element, arg );
      ret = performDeleteCommand( newCons );
    } else if (!strncmp(walker->element, "(disable", 8)) {
      ruleSet[rule].active = 0;
      ret = 1;
    } else if (!strncmp(walker->element, "(print", 6)) {
      ret = performPrintCommand( walker->element );
    } else if (!strncmp(walker->element, "(enable", 7)) {
      ret = performEnableCommand( walker->element );
    } else if (!strncmp(walker->element, "(quit", 5)) {
      extern int endRun;
      endRun = 1;
    }
    walker = walker->next;
  }
  return ret;
}

variable_types: rule int

variable_types:
arg
char *

variable_types: struct memoryElementStruct { int active; char element[-1]; struct memoryElementStruct *next; } *

variable_types:
newCons
char [-1]

variable_types: endRun int


parseEntry

original_code:
int parseEntry( news_t *news, const char *searchString, char *dest )
{
  int i, index, len;
  if ((!news) || (!dest) || (!searchString)) return -1;
  len = strlen(searchString);
  for (i = 0 ; i < news->msgLen ; i++) {
    if (news->msg[i] == searchString[0]) {
      if (!strncmp(&news->msg[i], searchString, len )) {
        i += (len + 1);
        index = 0;
        while (!((news->msg[i] == 0x0d) && (news->msg[i+1] == 0x0a))) {
          dest[index++] = tolower(news->msg[i++]);
        }
        dest[index] = 0;
        break;
      }
    }
  }
  if (i == news->msgLen) {
    return -1;
  }
  return 0;
}

canonical_original_code:
int parseEntry(struct news_t *news, char *searchString, char *dest)
{
  int i; int index; int len;
  if ((!news) || (!dest) || (!searchString)) return -1;
  len = strlen(searchString);
  for (i = 0 ; i < news->msgLen ; i++) {
    if (news->msg[i] == searchString[0]) {
      if (!strncmp(&news->msg[i], searchString, len )) {
        i += (len + 1);
        index = 0;
        while (!((news->msg[i] == 0x0d) && (news->msg[i+1] == 0x0a))) {
          dest[index++] = tolower(news->msg[i++]);
        }
        dest[index] = 0;
        break;
      }
    }
  }
  if (i == news->msgLen) {
    return -1;
  }
  return 0;
}

variable_types: struct news_t { char *msg; int msgLen; int msgId; char subject[-1]; char sender[-1]; char msgDate[-1]; char *bodyStart; } *

variable_types:
searchString
char *

variable_types:
dest
char *

variable_types: i int

variable_types: index int

variable_types: len int


fixAddress

decompiled_code:
__int64 __fastcall fixAddress(char *dest)
{
char *v1; // rbx
int v2; // esi
char *v3; // rax
int v4; // edx
__int64 v6; // rsi
__int64 v7; // rax
char *v8; // rdx
int v9; // edi
char v10; // cl
char v11[120]; // [rsp+0h] [rbp-78h] BYREF

if ( !dest )
return 0xFFFFFFFFLL;
v1 = dest;
v2 = strlen(dest);
if ( v2 <= 0 )
{
v4 = 0;
}
else
{
v3 = dest;
v4 = 0;
while ( *v3 != 60 )
{
++v4;
++v3;
if ( v2 == v4 )
return 0LL;
}
}
if ( v2 == v4 )
return 0LL;
if ( v2 <= v4 + 1 )
{
v9 = 0;
}
else
{
v6 = (unsigned int)(v2 - 2 - v4);
v7 = 0LL;
v8 = &dest[v4];
while ( 1 )
{
v9 = v7;
v10 = v8[v7 + 1];
if ( v10 == 62 )
break;
v9 = v7 + 1;
v11[v7] = v10;
if ( v7 == v6 )
break;
++v7;
}
}
v11[v9] = 0;
strcpy(v1, v11);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *dest)
{
char *v1; // rbx
int v2; // esi
char *v3; // rax
int v4; // edx
__int64 v6; // rsi
__int64 v7; // rax
char *v8; // rdx
int v9; // edi
char v10; // cl
char v11[120]; // [rsp+0h] [rbp-78h] BYREF

if ( !dest )
return 0xFFFFFFFFLL;
v1 = dest;
v2 = strlen(dest);
if ( v2 <= 0 )
{
v4 = 0;
}
else
{
v3 = dest;
v4 = 0;
while ( *v3 != 60 )
{
++v4;
++v3;
if ( v2 == v4 )
return 0LL;
}
}
if ( v2 == v4 )
return 0LL;
if ( v2 <= v4 + 1 )
{
v9 = 0;
}
else
{
v6 = (unsigned int)(v2 - 2 - v4);
v7 = 0LL;
v8 = &dest[v4];
while ( 1 )
{
v9 = v7;
v10 = v8[v7 + 1];
if ( v10 == 62 )
break;
v9 = v7 + 1;
v11[v7] = v10;
if ( v7 == v6 )
break;
++v7;
}
}
v11[v9] = 0;
strcpy(v1, v11);
return 0LL;
}

original_code:
int fixAddress ( char *address )
{
  int i, j, len;
  char string[100 +1];
  if (!address) return -1;
  len = strlen(address);
  for (i = 0 ; i < len ; i++) {
    if (address[i] == '<') break;
  }
  if (i++ == len) return 0;
  j = 0;
  for ( ; i < len ; i++) {
    if (address[i] == '>') break;
    string[j++] = address[i];
  }
  string[j] = 0;
  strcpy(address, string);
  return 0;
}

canonical_original_code:
int fixAddress(char *address)
{
  int i; int j; int len;
  char string[-1];
  if (!address) return -1;
  len = strlen(address);
  for (i = 0 ; i < len ; i++) {
    if (address[i] == '<') break;
  }
  if (i++ == len) return 0;
  j = 0;
  for ( ; i < len ; i++) {
    if (address[i] == '>') break;
    string[j++] = address[i];
  }
  string[j] = 0;
  strcpy(address, string);
  return 0;
}

variable_types:
address
char *

variable_types: j int


findBody

original_code:
int findBody( news_t *news )
{
  int i, result=-1;
  for (i = 0 ; i < news->msgLen ; i++) {
    if ((news->msg[i] == 0x0d) && (news->msg[i+1] == 0x0a) &&
        (news->msg[i+2] == 0x0d) && (news->msg[i+3] == 0x0a)) {
      i+=4;
      break;
    }
  }
  if (i < news->msgLen) {
    news->bodyStart = &news->msg[i];
    result = 0;
  }
  return result;
}

canonical_original_code:
int findBody(struct news_t *news)
{
  int i; int result = -1;
  for (i = 0 ; i < news->msgLen ; i++) {
    if ((news->msg[i] == 0x0d) && (news->msg[i+1] == 0x0a) &&
        (news->msg[i+2] == 0x0d) && (news->msg[i+3] == 0x0a)) {
      i+=4;
      break;
    }
  }
  if (i < news->msgLen) {
    news->bodyStart = &news->msg[i];
    result = 0;
  }
  return result;
}

variable_types: result int

user_defined_types: struct news_t { char *msg; int msgLen; int msgId; char subject[-1]; char sender[-1]; char msgDate[-1]; char *bodyStart; }


skipWhiteSpace

decompiled_code:
unsigned __int8 *__fastcall skipWhiteSpace(unsigned __int8 *a1)
{
unsigned __int8 *result; // rax
__int64 v2; // rcx
unsigned __int64 v3; // rdx

result = a1;
v2 = 0x2800030000000001LL;
while ( 1 )
{
v3 = *result;
if ( (unsigned __int8)v3 > 0x3Du || !_bittest64(&v2, v3) )
{
do
{
do
v3 = *++result;
while ( (unsigned __int8)v3 > 0x3Du );
}
while ( !_bittest64(&v2, v3) );
}
if ( (_BYTE)v3 != 59 )
break;
do
++result;
while ( *(result - 1) != 10 );
}
return result;
}

canonical_decompiled_code:
unsigned __int8 *__fastcall func0(unsigned __int8 *a1)
{
unsigned __int8 *result; // rax
__int64 v2; // rcx
unsigned __int64 v3; // rdx

result = a1;
v2 = 0x2800030000000001LL;
while ( 1 )
{
v3 = *result;
if ( (unsigned __int8)v3 > 0x3Du || !_bittest64(&v2, v3) )
{
do
{
do
v3 = *++result;
while ( (unsigned __int8)v3 > 0x3Du );
}
while ( !_bittest64(&v2, v3) );
}
if ( (_BYTE)v3 != 59 )
break;
do
++result;
while ( *(result - 1) != 10 );
}
return result;
}

original_code:
char *skipWhiteSpace( char *block )
{
  char ch;
  while (1) {
    ch = *block;
    while ((ch != '(') && (ch != ')') && (ch != '=') &&
           (ch != 0) && (ch != ';')) {
      block++;
      ch = *block;
    }
    if (ch == ';') {
      while (*block++ != 0x0a);
    } else break;
  }
  return block;
}

canonical_original_code:
char *skipWhiteSpace(char *block)
{
  char ch;
  while (1) {
    ch = *block;
    while ((ch != '(') && (ch != ')') && (ch != '=') &&
           (ch != 0) && (ch != ';')) {
      block++;
      ch = *block;
    }
    if (ch == ';') {
      while (*block++ != 0x0a);
    } else break;
  }
  return block;
}

variable_types:
block
char *

variable_types: ch char

return_type: char *


parseAntecedent

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

while ( 1 )
{
result = (char *)skipWhiteSpace(a1);
if ( *result != 40 )
break;
a1 = (unsigned __int8 *)parseElement(result, (__int64 *)(a2 + 88));
}
return result;
}

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

while ( 1 )
{
result = (char *)func0(a1);
if ( *result != 40 )
break;
a1 = (unsigned __int8 *)func1(result, (__int64 *)(a2 + 88));
}
return result;
}

original_code:
char *parseAntecedent( char *block, ruleType *rule )
{
  while (1) {
    block = skipWhiteSpace( block );
    if (*block == '(') {
      block = parseElement( block, &rule->antecedent );
    } else break;
  }
  return block;
}

canonical_original_code:
char *parseAntecedent(char *block, struct ruleType *rule)
{
  while (1) {
    block = skipWhiteSpace( block );
    if (*block == '(') {
      block = parseElement( block, &rule->antecedent );
    } else break;
  }
  return block;
}

variable_types: struct ruleType { int active; char ruleName[-1]; struct memoryElementStruct { int active; char element[-1]; struct memoryElementStruct *next; } *antecedent; struct memoryElementStruct *consequent; } *

user_defined_types: struct ruleType { int active; char ruleName[-1]; struct memoryElementStruct *antecedent; struct memoryElementStruct *consequent; }


parseConsequent

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

while ( 1 )
{
result = (char *)skipWhiteSpace(a1);
if ( *result != 40 )
break;
a1 = (unsigned __int8 *)parseElement(result, (__int64 *)(a2 + 96));
}
return result;
}

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

while ( 1 )
{
result = (char *)func0(a1);
if ( *result != 40 )
break;
a1 = (unsigned __int8 *)func1(result, (__int64 *)(a2 + 96));
}
return result;
}

original_code:
char *parseConsequent( char *block, ruleType *rule )
{
  while (1) {
    block = skipWhiteSpace( block );
    if (*block == '(') {
      block = parseElement(block, &rule->consequent);
    } else break;
  }
  return block;
}

canonical_original_code:
char *parseConsequent(char *block, struct ruleType *rule)
{
  while (1) {
    block = skipWhiteSpace( block );
    if (*block == '(') {
      block = parseElement(block, &rule->consequent);
    } else break;
  }
  return block;
}

user_defined_types: struct memoryElementStruct { int active; char element[-1]; struct memoryElementStruct *next; }


initializePopulation

original_code:
void initializePopulation( void )
{
  int member, index;
  int x, temp;
  for (member = 0 ; member < 100 ; member++) {
    for (index = 0 ; index < 80 ; index++) {
      population[member].solution[index] = index+1;
    }
    for (index = 0 ; index < 80 ; index++) {
      x = (int)((float)(80)*rand()/(2147483647 +1.0));
      temp = population[member].solution[index];
      population[member].solution[index] = population[member].solution[x];
      population[member].solution[x] = temp;
    }
  }
}

canonical_original_code:
void initializePopulation()
{
  int member; int index;
  int x; int temp;
  for (member = 0 ; member < 100 ; member++) {
    for (index = 0 ; index < 80 ; index++) {
      population[member].solution[index] = index+1;
    }
    for (index = 0 ; index < 80 ; index++) {
      x = (int)((float)(80)*rand()/(2147483647 +1.0));
      temp = population[member].solution[index];
      population[member].solution[index] = population[member].solution[x];
      population[member].solution[x] = temp;
    }
  }
}

variable_types: member int

variable_types: x int

variable_types: temp int


simulateAnnealing

decompiled_code:
__int64 __fastcall simulateAnnealing(__m128i a1)
{
__int64 v1; // rbx
unsigned int v2; // er12
unsigned int i; // ebp
__int64 k; // rax
__int64 j; // rax
float v6; // er14
int v7; // er13
float v9; // [rsp+Ch] [rbp-8Ch]
char v10[136]; // [rsp+10h] [rbp-88h] BYREF

v9 = *(float *)a1.m128i_i32;
v1 = 0LL;
v2 = -1;
for ( i = 0; i != 100; ++i )
{
for ( j = 0LL; j != 80; ++j )
v10[j] = population[v1 * 4 + j];
tweakSolution((__int64)v10);
*(float *)a1.m128i_i32 = computeEnergy((__int64)v10);
v6 = COERCE_FLOAT(_mm_cvtsi128_si32(a1));
if ( *(float *)&dword_4040D0[v1] > v6
|| (v7 = rand(),
exp((float)((float)-(float)(v6 - *(float *)&dword_4040D0[v1]) / v9)) > (float)((float)v7 * 4.6566129e-10)) )
{
for ( k = 0LL; k != 80; ++k )
population[v1 * 4 + k] = v10[k];
*(float *)&dword_4040D0[v1] = v6;
}
a1 = 0LL;
if ( *(float *)&dword_4040D0[v1] == 0.0 )
v2 = i;
v1 += 21LL;
}
return v2;
}

original_code:
int simulateAnnealing( float curTemp )
{
  int member, i;
  memberType tempMember;
  float energy;
  int useNew = 0;
  int solution = -1;
  for (member = 0 ; member < 100 ; member++) {
    for (i = 0 ; i < 80 ; i++) {
      tempMember.solution[i] = population[member].solution[i];
    }
    tweakSolution( &tempMember );
    energy = computeEnergy( &tempMember );
    useNew = 0;
    if (energy < population[member].energy) {
      useNew = 1;
    } else {
      float test = ((float)rand() / (float)2147483647);
      float delta = energy - population[member].energy;
      if (exp(-delta/curTemp) > test) {
        useNew = 1;
      }
    }
    if (useNew) {
      for (i = 0 ; i < 80 ; i++) {
        population[member].solution[i] = tempMember.solution[i];
        population[member].energy = energy;
      }
    }
    if (population[member].energy == 0) solution = member;
  }
  return solution;
}

canonical_original_code:
int simulateAnnealing(float curTemp)
{
  int member; int i;
  struct memberType tempMember;
  float energy;
  int useNew = 0;
  int solution = -1;
  for (member = 0 ; member < 100 ; member++) {
    for (i = 0 ; i < 80 ; i++) {
      tempMember.solution[i] = population[member].solution[i];
    }
    tweakSolution( &tempMember );
    energy = computeEnergy( &tempMember );
    useNew = 0;
    if (energy < population[member].energy) {
      useNew = 1;
    } else {
      float test = ((float)rand() / (float)2147483647);
      float delta = energy - population[member].energy;
      if (exp(-delta/curTemp) > test) {
        useNew = 1;
      }
    }
    if (useNew) {
      for (i = 0 ; i < 80 ; i++) {
        population[member].solution[i] = tempMember.solution[i];
        population[member].energy = energy;
      }
    }
    if (population[member].energy == 0) solution = member;
  }
  return solution;
}

variable_types: curTemp float

variable_types: struct memberType { char solution[80]; float energy; }

variable_types: energy float

variable_types: useNew int

variable_types: solution int

variable_types: test float

variable_types: delta float


computeAllEnergy

decompiled_code:
void computeAllEnergy()
{
char *v0; // rbx

v0 = population;
do
{
*((float *)v0 + 20) = computeEnergy((__int64)v0);
v0 += 84;
}
while ( v0 != (char *)&end );
}

canonical_decompiled_code:
void func12()
{
char *v0; // rbx

v0 = population;
do
{
*((float *)v0 + 20) = func10((__int64)v0);
v0 += 84;
}
while ( v0 != (char *)&end );
}

original_code:
void computeAllEnergy( void )
{
  int member;
  for (member = 0 ; member < 100 ; member++) {
    population[member].energy = computeEnergy( &population[member] );
  }
}

canonical_original_code:
void computeAllEnergy()
{
  int member;
  for (member = 0 ; member < 100 ; member++) {
    population[member].energy = computeEnergy( &population[member] );
  }
}


tweakSolution

decompiled_code:
__int64 __fastcall tweakSolution(__int64 a1)
{
int v1; // ebp
__int64 result; // rax
char v3; // dl

v1 = (int)((float)((float)rand() * 80.0) * 4.656612873077393e-10);
do
LODWORD(result) = (int)((float)((float)rand() * 80.0) * 4.656612873077393e-10);
while ( v1 == (_DWORD)result );
v3 = *(_BYTE *)(a1 + v1);
result = (int)result;
*(_BYTE *)(a1 + v1) = *(_BYTE *)(a1 + (int)result);
*(_BYTE *)(a1 + (int)result) = v3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
int v1; // ebp
__int64 result; // rax
char v3; // dl

v1 = (int)((float)((float)rand() * 80.0) * 4.656612873077393e-10);
do
LODWORD(result) = (int)((float)((float)rand() * 80.0) * 4.656612873077393e-10);
while ( v1 == (_DWORD)result );
v3 = *(_BYTE *)(a1 + v1);
result = (int)result;
*(_BYTE *)(a1 + v1) = *(_BYTE *)(a1 + (int)result);
*(_BYTE *)(a1 + (int)result) = v3;
return result;
}

original_code:
void tweakSolution( memberType *member )
{
  int temp, x, y;
  x = (int)((float)(80)*rand()/(2147483647 +1.0));
  do {
    y = (int)((float)(80)*rand()/(2147483647 +1.0));
  } while (x == y);
  temp = member->solution[x];
  member->solution[x] = member->solution[y];
  member->solution[y] = temp;
}

canonical_original_code:
void tweakSolution(struct memberType *member)
{
  int temp; int x; int y;
  x = (int)((float)(80)*rand()/(2147483647 +1.0));
  do {
    y = (int)((float)(80)*rand()/(2147483647 +1.0));
  } while (x == y);
  temp = member->solution[x];
  member->solution[x] = member->solution[y];
  member->solution[y] = temp;
}

variable_types: struct memberType { char solution[80]; float energy; } *

variable_types: y int


emitSolution

original_code:
void emitSolution( memberType *member )
{
  char board[80][80];
  int x, y;
  bzero( (void *)board, 80 * 80 );
  for (x = 0 ; x < 80 ; x++) {
    board[x][member->solution[x]-1] = 'Q';
  }
  printf("board:\n");
  for (y = 0 ; y < 80 ; y++) {
    for (x = 0 ; x < 80 ; x++) {
      if (board[x][y] == 'Q') printf("Q ");
      else printf(". ");
    }
    printf("\n");
  }
  printf("\n\n");
}

canonical_original_code:
void emitSolution(struct memberType *member)
{
  char board[80][80];
  int x; int y;
  bzero( (void *)board, 80 * 80 );
  for (x = 0 ; x < 80 ; x++) {
    board[x][member->solution[x]-1] = 'Q';
  }
  printf("board:\n");
  for (y = 0 ; y < 80 ; y++) {
    for (x = 0 ; x < 80 ; x++) {
      if (board[x][y] == 'Q') printf("Q ");
      else printf(". ");
    }
    printf("\n");
  }
  printf("\n\n");
}

variable_types:
board
char [80][80]

user_defined_types: struct memberType { char solution[80]; float energy; }


computeEnergy

original_code:
float computeEnergy( memberType *member )
{
  int i, j, x, y, tempx, tempy;
  char board[80][80];
  int conflicts;
  const int dx[4] = {-1, 1, -1, 1};
  const int dy[4] = {-1, 1, 1, -1};
  bzero( (void *)board, 80 * 80 );
  for (i = 0 ; i < 80 ; i++) {
    board[i][member->solution[i]-1] = 'Q';
  }
  conflicts = 0;
  for (i = 0 ; i < 80 ; i++) {
    x = i; y = member->solution[i]-1;
    for (j = 0 ; j < 4 ; j++) {
      tempx = x ; tempy = y;
      while(1) {
        tempx += dx[j]; tempy += dy[j];
        if ((tempx < 0) || (tempx >= 80) ||
               (tempy < 0) || (tempy >= 80)) break;
        if (board[tempx][tempy] == 'Q') conflicts++;
      }
    }
  }
  return (float)conflicts;
}

canonical_original_code:
float computeEnergy(struct memberType *member)
{
  int i; int j; int x; int y; int tempx; int tempy;
  char board[80][80];
  int conflicts;
  int dx[4] = {-1, 1, -1, 1};
  int dy[4] = {-1, 1, 1, -1};
  bzero( (void *)board, 80 * 80 );
  for (i = 0 ; i < 80 ; i++) {
    board[i][member->solution[i]-1] = 'Q';
  }
  conflicts = 0;
  for (i = 0 ; i < 80 ; i++) {
    x = i; y = member->solution[i]-1;
    for (j = 0 ; j < 4 ; j++) {
      tempx = x ; tempy = y;
      while(1) {
        tempx += dx[j]; tempy += dy[j];
        if ((tempx < 0) || (tempx >= 80) ||
               (tempy < 0) || (tempy >= 80)) break;
        if (board[tempx][tempy] == 'Q') conflicts++;
      }
    }
  }
  return (float)conflicts;
}

variable_types: i int

variable_types: j int

variable_types: tempx int

variable_types: tempy int

variable_types: conflicts int

variable_types:
dx
int [4]

variable_types:
dy
int [4]

return_type: float


interpretSTM

decompiled_code:
__int64 __fastcall interpretSTM(unsigned int *a1, int a2, __int64 a3, int a4)
{
__int64 v4; // rcx
int v5; // eax
unsigned int *v6; // rax
__int64 v7; // rsi
int v8; // edx
__int64 v9; // rdx
int v10; // edi
int v11; // ecx
unsigned int v12; // edx
__int64 v13; // rdx
int v14; // ecx
int v15; // edx
int v16; // edx

stackPointer = 0;
LODWORD(v4) = a4 - 1;
if ( (int)v4 >= 0 )
{
v4 = (int)v4;
do
{
v5 = stackPointer++;
stack[v5] = *(_DWORD *)(a3 + 4 * v4--);
}
while ( (int)v4 >= 0 );
}
if ( a2 <= 0 )
return 0;
v6 = a1;
v7 = (__int64)&a1[a2 - 1 + 1];
while ( 2 )
{
v12 = *v6;
switch ( *v6 )
{
case 0u:
v8 = stackPointer;
if ( stackPointer != 15 && stackPointer > 0 )
{
++stackPointer;
stack[v8] = stack[v8 - 1];
goto LABEL_11;
}
v12 = 1;
break;
case 1u:
if ( stackPointer > 1 )
{
v9 = stackPointer - 1;
v10 = stack[v9];
v11 = stackPointer - 2;
stack[v9] = stack[stackPointer - 2];
stack[v11] = v10;
goto LABEL_11;
}
break;
case 2u:
if ( stackPointer > 1 )
{
v13 = stackPointer - 2;
v14 = stack[v13];
stack[v13] = stack[--stackPointer] * v14;
goto LABEL_11;
}
v12 = 1;
break;
case 3u:
v15 = stackPointer;
if ( stackPointer > 1 )
{
--stackPointer;
stack[v15 - 2] += stack[v15 - 1];
goto LABEL_11;
}
v12 = 1;
break;
case 4u:
v16 = stackPointer;
if ( stackPointer > 1 )
{
++stackPointer;
stack[v16] = stack[v16 - 2];
goto LABEL_11;
}
v12 = 1;
break;
default:
LABEL_11:
if ( ++v6 != (unsigned int *)v7 )
continue;
v12 = 0;
break;
}
break;
}
return v12;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int *a1, int a2, __int64 a3, int a4)
{
__int64 v4; // rcx
int v5; // eax
unsigned int *v6; // rax
__int64 v7; // rsi
int v8; // edx
__int64 v9; // rdx
int v10; // edi
int v11; // ecx
unsigned int v12; // edx
__int64 v13; // rdx
int v14; // ecx
int v15; // edx
int v16; // edx

stackPointer = 0;
LODWORD(v4) = a4 - 1;
if ( (int)v4 >= 0 )
{
v4 = (int)v4;
do
{
v5 = stackPointer++;
stack[v5] = *(_DWORD *)(a3 + 4 * v4--);
}
while ( (int)v4 >= 0 );
}
if ( a2 <= 0 )
return 0;
v6 = a1;
v7 = (__int64)&a1[a2 - 1 + 1];
while ( 2 )
{
v12 = *v6;
switch ( *v6 )
{
case 0u:
v8 = stackPointer;
if ( stackPointer != 15 && stackPointer > 0 )
{
++stackPointer;
stack[v8] = stack[v8 - 1];
goto LABEL_11;
}
v12 = 1;
break;
case 1u:
if ( stackPointer > 1 )
{
v9 = stackPointer - 1;
v10 = stack[v9];
v11 = stackPointer - 2;
stack[v9] = stack[stackPointer - 2];
stack[v11] = v10;
goto LABEL_11;
}
break;
case 2u:
if ( stackPointer > 1 )
{
v13 = stackPointer - 2;
v14 = stack[v13];
stack[v13] = stack[--stackPointer] * v14;
goto LABEL_11;
}
v12 = 1;
break;
case 3u:
v15 = stackPointer;
if ( stackPointer > 1 )
{
--stackPointer;
stack[v15 - 2] += stack[v15 - 1];
goto LABEL_11;
}
v12 = 1;
break;
case 4u:
v16 = stackPointer;
if ( stackPointer > 1 )
{
++stackPointer;
stack[v16] = stack[v16 - 2];
goto LABEL_11;
}
v12 = 1;
break;
default:
LABEL_11:
if ( ++v6 != (unsigned int *)v7 )
continue;
v12 = 0;
break;
}
break;
}
return v12;
}

original_code:
int interpretSTM(const int *program, int progLength,
                   const int *args, int argsLength)
{
  int pc = 0;
  int i, error = 0;
  int a, b;
  stackPointer = 0;
  for (i = argsLength-1 ; i >= 0 ; i--) {
    (stack[stackPointer++] = args[i]);
  }
  while ((error == 0) && (pc < progLength)) {
    switch(program[pc++]) {
      case 0x00:
        if (stackPointer < 1) { error = 1 ; break; };
        if (stackPointer == 15) { error = 1 ; break; };
        (stack[stackPointer++] = (stack[stackPointer-1]));
        break;
      case 0x01:
        if (stackPointer < 2) { error = 1 ; break; };
        a = stack[stackPointer-1];
        stack[stackPointer-1] = stack[stackPointer-2];
        stack[stackPointer-2] = a;
        break;
      case 0x02:
        if (stackPointer < 2) { error = 1 ; break; };
        a = (stack[--stackPointer]); b = (stack[--stackPointer]);
        (stack[stackPointer++] = a * b);
        break;
      case 0x03:
        if (stackPointer < 2) { error = 1 ; break; };
        a = (stack[--stackPointer]); b = (stack[--stackPointer]);
        (stack[stackPointer++] = a + b);
        break;
      case 0x04:
        if (stackPointer < 2) { error = 1 ; break; };
        (stack[stackPointer++] = stack[stackPointer-2]);
        break;
    }
  }
  return(error);
}

canonical_original_code:
int interpretSTM(int *program, int progLength, int *args, int argsLength)
{
  int pc = 0;
  int i; int error = 0;
  int a; int b;
  stackPointer = 0;
  for (i = argsLength-1 ; i >= 0 ; i--) {
    (stack[stackPointer++] = args[i]);
  }
  while ((error == 0) && (pc < progLength)) {
    switch(program[pc++]) {
      case 0x00:
        if (stackPointer < 1) { error = 1 ; break; };
        if (stackPointer == 15) { error = 1 ; break; };
        (stack[stackPointer++] = (stack[stackPointer-1]));
        break;
      case 0x01:
        if (stackPointer < 2) { error = 1 ; break; };
        a = stack[stackPointer-1];
        stack[stackPointer-1] = stack[stackPointer-2];
        stack[stackPointer-2] = a;
        break;
      case 0x02:
        if (stackPointer < 2) { error = 1 ; break; };
        a = (stack[--stackPointer]); b = (stack[--stackPointer]);
        (stack[stackPointer++] = a * b);
        break;
      case 0x03:
        if (stackPointer < 2) { error = 1 ; break; };
        a = (stack[--stackPointer]); b = (stack[--stackPointer]);
        (stack[stackPointer++] = a + b);
        break;
      case 0x04:
        if (stackPointer < 2) { error = 1 ; break; };
        (stack[stackPointer++] = stack[stackPointer-2]);
        break;
    }
  }
  return(error);
}

variable_types:
program
int *

variable_types: progLength int

variable_types:
args
int *

variable_types: argsLength int

variable_types: pc int

variable_types: error int

variable_types: a int

variable_types: b int


selectParent

original_code:
int selectParent( void )
{
  static int chrom = 0;
  int ret = -1;
  float retFitness = 0.0;
  float fitMarker = ((((float)rand() / (float)2147483647) * totFitness) * 0.25);
  do {
    retFitness += populations[curPop][chrom].fitness;
    if (retFitness >= fitMarker) {
      ret = chrom;
    }
    if (++chrom == 3000) chrom = 0;
  } while (ret == -1);
  return ret;
}

canonical_original_code:
int selectParent()
{
  static int chrom = 0;
  int ret = -1;
  float retFitness = 0.0;
  float fitMarker = ((((float)rand() / (float)2147483647) * totFitness) * 0.25);
  do {
    retFitness += populations[curPop][chrom].fitness;
    if (retFitness >= fitMarker) {
      ret = chrom;
    }
    if (++chrom == 3000) chrom = 0;
  } while (ret == -1);
  return ret;
}

variable_types: chrom int

variable_types: ret int

variable_types: retFitness float

variable_types: fitMarker float


mutate

original_code:
int mutate(int gene)
{
  float temp = ((float)rand() / (float)2147483647);
  if (temp > (1.0 - 0.07)) {
      gene = (int)((float)((0x05 +1))*rand()/(2147483647 +1.0));
      curMutations++;
  }
  return gene;
}

variable_types: gene int

variable_types: temp float


performReproduction

original_code:
int performReproduction( int parentA, int parentB, int childA, int childB )
{
  int crossPoint, i;
  int nextPop = (curPop == 0) ? 1 : 0;
  int mutate( int );
  if (((float)rand() / (float)2147483647) > (1.0 - 0.8)) {
    crossPoint = (int)((float)(((populations[curPop][parentA].progSize-2 > populations[curPop][parentB].progSize-2) ? populations[curPop][parentA].progSize-2 : populations[curPop][parentB].progSize-2))*rand()/(2147483647 +1.0))+1;
    curCrossovers++;
  } else {
    crossPoint = 12;
  }
  for (i = 0 ; i < crossPoint ; i++) {
    populations[nextPop][childA].program[i] =
        mutate(populations[curPop][parentA].program[i]);
    populations[nextPop][childB].program[i] =
        mutate(populations[curPop][parentB].program[i]);
  }
  for ( ; i < 12 ; i++) {
    populations[nextPop][childA].program[i] =
        mutate(populations[curPop][parentB].program[i]);
    populations[nextPop][childB].program[i] =
        mutate(populations[curPop][parentA].program[i]);
  }
  populations[nextPop][childA].progSize =
    populations[curPop][parentA].progSize;
  populations[nextPop][childB].progSize =
    populations[curPop][parentB].progSize;
  return 0;
}

canonical_original_code:
int performReproduction(int parentA, int parentB, int childA, int childB)
{
  int crossPoint; int i;
  int nextPop = (curPop == 0) ? 1 : 0;
  int mutate(int);
  if (((float)rand() / (float)2147483647) > (1.0 - 0.8)) {
    crossPoint = (int)((float)(((populations[curPop][parentA].progSize-2 > populations[curPop][parentB].progSize-2) ? populations[curPop][parentA].progSize-2 : populations[curPop][parentB].progSize-2))*rand()/(2147483647 +1.0))+1;
    curCrossovers++;
  } else {
    crossPoint = 12;
  }
  for (i = 0 ; i < crossPoint ; i++) {
    populations[nextPop][childA].program[i] =
        mutate(populations[curPop][parentA].program[i]);
    populations[nextPop][childB].program[i] =
        mutate(populations[curPop][parentB].program[i]);
  }
  for ( ; i < 12 ; i++) {
    populations[nextPop][childA].program[i] =
        mutate(populations[curPop][parentB].program[i]);
    populations[nextPop][childB].program[i] =
        mutate(populations[curPop][parentA].program[i]);
  }
  populations[nextPop][childA].progSize =
    populations[curPop][parentA].progSize;
  populations[nextPop][childB].progSize =
    populations[curPop][parentB].progSize;
  return 0;
}

variable_types: parentA int

variable_types: parentB int

variable_types: childA int

variable_types: childB int

variable_types: crossPoint int

variable_types: i int

variable_types: nextPop int

variable_types:
mutate
int (int)


performSelection

decompiled_code:
__int64 performSelection()
{
int i; // ebx
int v1; // ebp
int v2; // eax

for ( i = 0; i != 3000; i += 2 )
{
v1 = selectParent();
v2 = selectParent();
performReproduction(v1, v2, i, i + 1);
}
return 0LL;
}

original_code:
int performSelection( void )
{
  int par1, par2;
  int child1, child2;
  int chrom;
  for (chrom = 0 ; chrom < 3000 ; chrom+=2) {
    par1 = selectParent();
    par2 = selectParent();
    child1 = chrom;
    child2 = chrom+1;
    performReproduction( par1, par2, child1, child2 );
  }
  return 0;
}

canonical_original_code:
int performSelection()
{
  int par1; int par2;
  int child1; int child2;
  int chrom;
  for (chrom = 0 ; chrom < 3000 ; chrom+=2) {
    par1 = selectParent();
    par2 = selectParent();
    child1 = chrom;
    child2 = chrom+1;
    performReproduction( par1, par2, child1, child2 );
  }
  return 0;
}


printProgram

original_code:
void printProgram( int index, int curPop )
{
  int i;
  for (i = 0 ; i < populations[curPop][index].progSize ; i++) {
    printf("%s\n", tins[ populations[curPop][index].program[i] ] );
  }
}

canonical_original_code:
void printProgram(int index, int curPop)
{
  int i;
  for (i = 0 ; i < populations[curPop][index].progSize ; i++) {
    printf("%s\n", tins[ populations[curPop][index].program[i] ] );
  }
}

variable_types: index int

variable_types: curPop int


sigmoid

decompiled_code:
double __fastcall sigmoid(double a1)
{
return 1.0 / (exp(-a1) + 1.0);
}

canonical_decompiled_code:
double __fastcall func7(double a1)
{
return 1.0 / (exp(-a1) + 1.0);
}

original_code:
double sigmoid( double val )
{
  return (1.0 / (1.0 + exp(-val)));
}

canonical_original_code:
double sigmoid(double val)
{
  return (1.0 / (1.0 + exp(-val)));
}

variable_types: val double

return_type: double


initializeNetwork

decompiled_code:
int initializeNetwork()
{
int result; // eax

*(double *)&w_hid0inp0 = (double)rand() / 2147483647.0;
*(double *)&w_hid0inp1 = (double)rand() / 2147483647.0;
*(double *)&w_hid1inp0 = (double)rand() / 2147483647.0;
*(double *)&w_hid1inp1 = (double)rand() / 2147483647.0;
*(double *)&w_outh0 = (double)rand() / 2147483647.0;
*(double *)&w_outh1 = (double)rand() / 2147483647.0;
*(double *)&h0_bias = (double)rand() / 2147483647.0;
*(double *)&h1_bias = (double)rand() / 2147483647.0;
result = rand();
*(double *)&out_bias = (double)result / 2147483647.0;
return result;
}


feedforward

decompiled_code:
void feedforward()
{
hid_0 = sigmoid(
*(double *)&inp_0 * *(double *)&w_hid0inp0
+ *(double *)&inp_1 * *(double *)&w_hid0inp1
+ *(double *)&h0_bias);
hid_1 = sigmoid(
*(double *)&inp_0 * *(double *)&w_hid1inp0
+ *(double *)&inp_1 * *(double *)&w_hid1inp1
+ *(double *)&h1_bias);
out = sigmoid(*(double *)&hid_0 * *(double *)&w_outh0 + *(double *)&hid_1 * *(double *)&w_outh1 + *(double *)&out_bias);
}

canonical_decompiled_code:
void func10()
{
hid_0 = func7(
*(double *)&inp_0 * *(double *)&w_hid0inp0
+ *(double *)&inp_1 * *(double *)&w_hid0inp1
+ *(double *)&h0_bias);
hid_1 = func7(
*(double *)&inp_0 * *(double *)&w_hid1inp0
+ *(double *)&inp_1 * *(double *)&w_hid1inp1
+ *(double *)&h1_bias);
out = func7(*(double *)&hid_0 * *(double *)&w_outh0 + *(double *)&hid_1 * *(double *)&w_outh1 + *(double *)&out_bias);
}

original_code:
void feedforward( void )
{
  hid_0 = sigmoid( (inp_0 * w_hid0inp0) + (inp_1 * w_hid0inp1) + h0_bias );
  hid_1 = sigmoid( (inp_0 * w_hid1inp0) + (inp_1 * w_hid1inp1) + h1_bias );
  out = sigmoid(((hid_0 * w_outh0) + (hid_1 * w_outh1) + out_bias));
  return;
}

canonical_original_code:
void feedforward()
{
  hid_0 = sigmoid( (inp_0 * w_hid0inp0) + (inp_1 * w_hid0inp1) + h0_bias );
  hid_1 = sigmoid( (inp_0 * w_hid1inp0) + (inp_1 * w_hid1inp1) + h1_bias );
  out = sigmoid(((hid_0 * w_outh0) + (hid_1 * w_outh1) + out_bias));
  return;
}


batchUpdate

decompiled_code:
void batchUpdate()
{
*(double *)&w_hid0inp0 = *(double *)&w_hid0inp0 + *(double *)&bw_hid0inp0;
*(double *)&w_hid0inp1 = *(double *)&w_hid0inp1 + *(double *)&bw_hid0inp1;
*(double *)&w_hid1inp0 = *(double *)&w_hid1inp0 + *(double *)&bw_hid1inp0;
*(double *)&w_hid1inp1 = *(double *)&w_hid1inp1 + *(double *)&bw_hid1inp1;
*(double *)&w_outh0 = *(double *)&w_outh0 + *(double *)&bw_outh0;
*(double *)&w_outh1 = *(double *)&w_outh1 + *(double *)&bw_outh1;
*(double *)&h0_bias = *(double *)&h0_bias + *(double *)&bh0_bias;
*(double *)&h1_bias = *(double *)&h1_bias + *(double *)&bh1_bias;
*(double *)&out_bias = *(double *)&out_bias + *(double *)&bout_bias;
bw_hid1inp1 = 0LL;
bw_hid1inp0 = 0LL;
bw_hid0inp1 = 0LL;
bw_hid0inp0 = 0LL;
bw_outh1 = 0LL;
bw_outh0 = 0LL;
bout_bias = 0LL;
bh1_bias = 0LL;
bh0_bias = 0LL;
}

canonical_decompiled_code:
void func12()
{
*(double *)&w_hid0inp0 = *(double *)&w_hid0inp0 + *(double *)&bw_hid0inp0;
*(double *)&w_hid0inp1 = *(double *)&w_hid0inp1 + *(double *)&bw_hid0inp1;
*(double *)&w_hid1inp0 = *(double *)&w_hid1inp0 + *(double *)&bw_hid1inp0;
*(double *)&w_hid1inp1 = *(double *)&w_hid1inp1 + *(double *)&bw_hid1inp1;
*(double *)&w_outh0 = *(double *)&w_outh0 + *(double *)&bw_outh0;
*(double *)&w_outh1 = *(double *)&w_outh1 + *(double *)&bw_outh1;
*(double *)&h0_bias = *(double *)&h0_bias + *(double *)&bh0_bias;
*(double *)&h1_bias = *(double *)&h1_bias + *(double *)&bh1_bias;
*(double *)&out_bias = *(double *)&out_bias + *(double *)&bout_bias;
bw_hid1inp1 = 0LL;
bw_hid1inp0 = 0LL;
bw_hid0inp1 = 0LL;
bw_hid0inp0 = 0LL;
bw_outh1 = 0LL;
bw_outh0 = 0LL;
bout_bias = 0LL;
bh1_bias = 0LL;
bh0_bias = 0LL;
}

original_code:
void batchUpdate( void )
{
  w_hid0inp0 += bw_hid0inp0; w_hid0inp1 += bw_hid0inp1;
  w_hid1inp0 += bw_hid1inp0; w_hid1inp1 += bw_hid1inp1;
  w_outh0 += bw_outh0; w_outh1 += bw_outh1;
  h0_bias += bh0_bias; h1_bias += bh1_bias;
  out_bias += bout_bias;
  bw_hid0inp0 = bw_hid0inp1 = bw_hid1inp0 = bw_hid1inp1 = 0.0;
  bw_outh0 = bw_outh1 = 0.0;
  bh0_bias = bh1_bias = bout_bias = 0.0;
  return;
}

canonical_original_code:
void batchUpdate()
{
  w_hid0inp0 += bw_hid0inp0; w_hid0inp1 += bw_hid0inp1;
  w_hid1inp0 += bw_hid1inp0; w_hid1inp1 += bw_hid1inp1;
  w_outh0 += bw_outh0; w_outh1 += bw_outh1;
  h0_bias += bh0_bias; h1_bias += bh1_bias;
  out_bias += bout_bias;
  bw_hid0inp0 = bw_hid0inp1 = bw_hid1inp0 = bw_hid1inp1 = 0.0;
  bw_outh0 = bw_outh1 = 0.0;
  bh0_bias = bh1_bias = bout_bias = 0.0;
  return;
}


storePbest

original_code:
void storePbest( int index )
{
  memcpy( (void *)&pbest[index], (void *)&particles[index],
           sizeof(particle_t) );
  if (pbest[index].fitness > gbest.fitness) {
    gbest.position.x = pbest[index].position.x;
    gbest.position.y = pbest[index].position.y;
    gbest.fitness = pbest[index].fitness;
  }
  return;
}

canonical_original_code:
void storePbest(int index)
{
  memcpy( (void *)&pbest[index], (void *)&particles[index],
           sizeof(particle_t) );
  if (pbest[index].fitness > gbest.fitness) {
    gbest.position.x = pbest[index].position.x;
    gbest.position.y = pbest[index].position.y;
    gbest.fitness = pbest[index].fitness;
  }
  return;
}


closePopulation

decompiled_code:
int closePopulation()
{
FILE **v0; // rbx
int result; // eax

v0 = (FILE **)particles;
do
{
result = fclose(*v0);
v0 += 6;
}
while ( v0 != (FILE **)&end );
return result;
}

canonical_decompiled_code:
int func9()
{
FILE **v0; // rbx
int result; // eax

v0 = (FILE **)particles;
do
{
result = fclose(*v0);
v0 += 6;
}
while ( v0 != (FILE **)&end );
return result;
}

original_code:
void closePopulation( void )
{
  int i;
  for ( i = 0 ; i < 5 ; i++ ) {
    fclose( particles[i].fp );
  }
  return;
}

canonical_original_code:
void closePopulation()
{
  int i;
  for ( i = 0 ; i < 5 ; i++ ) {
    fclose( particles[i].fp );
  }
  return;
}


checkFitness

decompiled_code:
double __fastcall checkFitness(double a1, double a2)
{
double v2; // xmm0_8
double v3; // xmm0_8
double x; // [rsp+8h] [rbp-10h]

v2 = a1 * a1 + a2 * a2;
x = v2;
if ( v2 < 0.0 )
v3 = sqrt(v2);
else
v3 = sqrt(v2);
return cos(v3) * 6.0 / (x + 6.0);
}

canonical_decompiled_code:
double __fastcall func10(double a1, double a2)
{
double v2; // xmm0_8
double v3; // xmm0_8
double x; // [rsp+8h] [rbp-10h]

v2 = a1 * a1 + a2 * a2;
x = v2;
if ( v2 < 0.0 )
v3 = sqrt(v2);
else
v3 = sqrt(v2);
return cos(v3) * 6.0 / (x + 6.0);
}

original_code:
double checkFitness( double x, double y )
{
  return ( (double)(6.0 * cos(sqrt(x*x+y*y))/(x*x+y*y+6.0)) );
}

canonical_original_code:
double checkFitness(double x, double y)
{
  return ( (double)(6.0 * cos(sqrt(x*x+y*y))/(x*x+y*y+6.0)) );
}

variable_types: x double

variable_types: y double


initPopulation

original_code:
void initPopulation( void )
{
  int i;
  char filename[80 +1];
  extern double checkFitness( double, double );
  gbest.fitness = (double)-9999.0;
  for ( i = 0 ; i < 5 ; i++ ) {
    sprintf( filename, "particle%02d.txt", i );
    particles[i].fp = fopen( filename, "w" );
    particles[i].position.x = (((4.0 * ((double)3.1415926)) * ((double)rand() / (double)2147483647)) - (2.0 * ((double)3.1415926)));
    particles[i].position.y = (((4.0 * ((double)3.1415926)) * ((double)rand() / (double)2147483647)) - (2.0 * ((double)3.1415926)));
    particles[i].fitness =
      checkFitness( particles[i].position.x, particles[i].position.y );
    particles[i].velocity.x = (((double)rand() / (double)2147483647) / (double)10.0);
    particles[i].velocity.y = (((double)rand() / (double)2147483647) / (double)10.0);
    storePbest( i );
    fprintf( particles[i].fp, "%lg, %lg, %lg\n",
             particles[i].position.x, particles[i].position.y,
             particles[i].fitness );
  }
  return;
}

canonical_original_code:
void initPopulation()
{
  int i;
  char filename[-1];
  extern double checkFitness(double, double);
  gbest.fitness = (double)-9999.0;
  for ( i = 0 ; i < 5 ; i++ ) {
    sprintf( filename, "particle%02d.txt", i );
    particles[i].fp = fopen( filename, "w" );
    particles[i].position.x = (((4.0 * ((double)3.1415926)) * ((double)rand() / (double)2147483647)) - (2.0 * ((double)3.1415926)));
    particles[i].position.y = (((4.0 * ((double)3.1415926)) * ((double)rand() / (double)2147483647)) - (2.0 * ((double)3.1415926)));
    particles[i].fitness =
      checkFitness( particles[i].position.x, particles[i].position.y );
    particles[i].velocity.x = (((double)rand() / (double)2147483647) / (double)10.0);
    particles[i].velocity.y = (((double)rand() / (double)2147483647) / (double)10.0);
    storePbest( i );
    fprintf( particles[i].fp, "%lg, %lg, %lg\n",
             particles[i].position.x, particles[i].position.y,
             particles[i].fitness );
  }
  return;
}

variable_types:
filename
char [-1]

variable_types:
checkFitness
double (double, double)


clearEntries

decompiled_code:
__int64 clearEntries()
{
_QWORD *v0; // rdi
_QWORD *v1; // rbx
_DWORD *v2; // rax

v0 = &head;
while ( 1 )
{
v1 = v0;
v0 = (_QWORD *)v0[40];
if ( !v0 )
break;
if ( *((_DWORD *)v0 + 79) )
{
v1[40] = v0[40];
free(v0);
v0 = v1;
}
}
v2 = &monitors;
do
{
if ( *v2 && v2[34] )
{
v2[33] = 0;
v2[34] = 0;
}
v2 += 35;
}
while ( v2 != (_DWORD *)(unsigned int)((_DWORD)&monitors + 2800) );
return emitGroupStatus();
}

original_code:
void clearEntries( void )
{
  elementType *walker = &head;
  elementType *temp;
  int i;
  extern monitorEntryType monitors[];
  while (walker->next) {
    if (walker->next->shown) {
      temp = walker->next;
      walker->next = walker->next->next;
      free(temp);
    } else {
      walker = walker->next;
    }
  }
  for (i = 0 ; i < 20 ; i++) {
    if ((monitors[i].active) && (monitors[i].shown)) {
      monitors[i].changed = 0;
      monitors[i].shown = 0;
    }
  }
  emitGroupStatus();
}

canonical_original_code:
void clearEntries()
{
  struct elementStruct *walker = &head;
  struct elementStruct *temp;
  int i;
  extern struct monitorEntryType monitors[];
  while (walker->next) {
    if (walker->next->shown) {
      temp = walker->next;
      walker->next = walker->next->next;
      free(temp);
    } else {
      walker = walker->next;
    }
  }
  for (i = 0 ; i < 20 ; i++) {
    if ((monitors[i].active) && (monitors[i].shown)) {
      monitors[i].changed = 0;
      monitors[i].shown = 0;
    }
  }
  emitGroupStatus();
}

variable_types: struct elementStruct { int group; int rank; int msgId; char subject[-1]; char msgDate[-1]; char link[-1]; int shown; struct elementStruct *next; } *

variable_types: struct monitorEntryType { int active; char url[80]; char urlName[-1]; int length; int changed; int shown; } []


showNewsItems

decompiled_code:
__int64 showNewsItems()
{
__int64 result; // rax
_QWORD *v1; // rbx

puts("Current news items:\n");
result = head[40];
if ( result )
{
v1 = head;
do
{
printf("id : %d\n", *(unsigned int *)(result + 8));
printf("rank : %d\n", *(unsigned int *)(v1[40] + 4LL));
printf("group : %d\n", *(unsigned int *)v1[40]);
printf("subject : %s\n", (const char *)(v1[40] + 12LL));
printf("date : %s\n\n", (const char *)(v1[40] + 113LL));
v1 = (_QWORD *)v1[40];
result = v1[40];
}
while ( result );
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax
_QWORD *v1; // rbx

puts("Current news items:\n");
result = head[40];
if ( result )
{
v1 = head;
do
{
printf("id : %d\n", *(unsigned int *)(result + 8));
printf("rank : %d\n", *(unsigned int *)(v1[40] + 4LL));
printf("group : %d\n", *(unsigned int *)v1[40]);
printf("subject : %s\n", (const char *)(v1[40] + 12LL));
printf("date : %s\n\n", (const char *)(v1[40] + 113LL));
v1 = (_QWORD *)v1[40];
result = v1[40];
}
while ( result );
}
return result;
}

original_code:
void showNewsItems( void )
{
  elementType *walker = &head;
  printf("Current news items:\n\n");
  while (walker->next) {
    printf("id      : %d\n", walker->next->msgId);
    printf("rank    : %d\n", walker->next->rank);
    printf("group   : %d\n", walker->next->group);
    printf("subject : %s\n", walker->next->subject);
    printf("date    : %s\n\n", walker->next->msgDate);
    walker = walker->next;
  }
}

canonical_original_code:
void showNewsItems()
{
  struct elementStruct *walker = &head;
  printf("Current news items:\n\n");
  while (walker->next) {
    printf("id      : %d\n", walker->next->msgId);
    printf("rank    : %d\n", walker->next->rank);
    printf("group   : %d\n", walker->next->group);
    printf("subject : %s\n", walker->next->subject);
    printf("date    : %s\n\n", walker->next->msgDate);
    walker = walker->next;
  }
}

user_defined_types: struct elementStruct { int group; int rank; int msgId; char subject[-1]; char msgDate[-1]; char link[-1]; int shown; struct elementStruct *next; }


checkGroup

decompiled_code:
int __fastcall checkGroup(signed int a1)
{
int v2; // er13
int v3; // ebx
void *ptr; // [rsp+0h] [rbp-1C8h] BYREF
int v5; // [rsp+8h] [rbp-1C0h]
int v6; // [rsp+Ch] [rbp-1BCh]
char v7[120]; // [rsp+150h] [rbp-78h] BYREF

ptr = malloc(0x10001uLL);
memset(ptr, 0, 0x10001uLL);
v5 = 0x10000;
prune(&feed, v7);
printf("checkGroup called %s\n", v7);
if ( !(unsigned int)nntpConnect(v7) )
{
v2 = nntpSetGroup((char *)&feed + 508 * a1 + 84, *((unsigned int *)&feed + 127 * a1 + 42));
printf(
"Group set to %s (last read %d)\n",
(const char *)&feed + 508 * a1 + 84,
*((unsigned int *)&feed + 127 * a1 + 42));
v3 = 100;
if ( v2 <= 100 )
v3 = v2;
if ( v2 > 0 )
{
do
{
if ( (int)nntpPeek(&ptr, 0x10000LL) > 0 && !(unsigned int)nntpParse(&ptr, 1LL) )
testNewsItem(a1, (__int64)&ptr);
*((_DWORD *)&feed + 127 * a1 + 42) = v6;
nntpSkip();
--v3;
}
while ( v3 > 0 );
}
}
free(ptr);
nntpDisconnect();
return puts("Disconnected");
}

canonical_decompiled_code:
int __fastcall func3(signed int a1)
{
int v2; // er13
int v3; // ebx
void *ptr; // [rsp+0h] [rbp-1C8h] BYREF
int v5; // [rsp+8h] [rbp-1C0h]
int v6; // [rsp+Ch] [rbp-1BCh]
char v7[120]; // [rsp+150h] [rbp-78h] BYREF

ptr = malloc(0x10001uLL);
memset(ptr, 0, 0x10001uLL);
v5 = 0x10000;
prune(&feed, v7);
printf("checkGroup called %s\n", v7);
if ( !(unsigned int)nntpConnect(v7) )
{
v2 = nntpSetGroup((char *)&feed + 508 * a1 + 84, *((unsigned int *)&feed + 127 * a1 + 42));
printf(
"Group set to %s (last read %d)\n",
(const char *)&feed + 508 * a1 + 84,
*((unsigned int *)&feed + 127 * a1 + 42));
v3 = 100;
if ( v2 <= 100 )
v3 = v2;
if ( v2 > 0 )
{
do
{
if ( (int)nntpPeek(&ptr, 0x10000LL) > 0 && !(unsigned int)nntpParse(&ptr, 1LL) )
func2(a1, (__int64)&ptr);
*((_DWORD *)&feed + 127 * a1 + 42) = v6;
nntpSkip();
--v3;
}
while ( v3 > 0 );
}
}
free(ptr);
nntpDisconnect();
return puts("Disconnected");
}

original_code:
void checkGroup( int group )
{
  int result, count, index = 0;
  char fqdn[80];
  news_t news;
  news.msg = (char *)malloc((64*1024)+1);
  bzero( news.msg, (64*1024)+1 );
  news.msgLen = (64*1024);
  prune( feed.url, fqdn );
  printf("checkGroup called %s\n", fqdn);
  count = nntpConnect( fqdn );
  if (count == 0) {
    count = nntpSetGroup( feed.groups[group].groupName,
                          feed.groups[group].lastMessageRead );
    printf("Group set to %s (last read %d)\n",
        feed.groups[group].groupName, feed.groups[group].lastMessageRead);
    index = 0;
    if (count > 100) count = 100;
    while (count-- > 0) {
      result = nntpPeek( &news, (64*1024) );
      if (result > 0) {
        result = nntpParse( &news, 1 );
        if (result == 0) {
          testNewsItem( group, &news );
        }
      }
      feed.groups[group].lastMessageRead = news.msgId;
      nntpSkip();
    }
  }
  free( news.msg );
  nntpDisconnect();
  printf("Disconnected\n");
  return;
}

canonical_original_code:
void checkGroup(int group)
{
  int result; int count; int index = 0;
  char fqdn[80];
  struct news_t news;
  news.msg = (char *)malloc((64*1024)+1);
  bzero( news.msg, (64*1024)+1 );
  news.msgLen = (64*1024);
  prune( feed.url, fqdn );
  printf("checkGroup called %s\n", fqdn);
  count = nntpConnect( fqdn );
  if (count == 0) {
    count = nntpSetGroup( feed.groups[group].groupName,
                          feed.groups[group].lastMessageRead );
    printf("Group set to %s (last read %d)\n",
        feed.groups[group].groupName, feed.groups[group].lastMessageRead);
    index = 0;
    if (count > 100) count = 100;
    while (count-- > 0) {
      result = nntpPeek( &news, (64*1024) );
      if (result > 0) {
        result = nntpParse( &news, 1 );
        if (result == 0) {
          testNewsItem( group, &news );
        }
      }
      feed.groups[group].lastMessageRead = news.msgId;
      nntpSkip();
    }
  }
  free( news.msg );
  nntpDisconnect();
  printf("Disconnected\n");
  return;
}

variable_types: group int

variable_types: result int

variable_types: count int

variable_types:
fqdn
char [80]

variable_types: struct news_t { char *msg; int msgLen; int msgId; char subject[-1]; char sender[-1]; char msgDate[-1]; char *bodyStart; }


checkNewsSources

decompiled_code:
int checkNewsSources()
{
unsigned __int64 v0; // rbp
signed int i; // ebx
int result; // eax

v0 = (unsigned int)((_DWORD)&feed + 80);
for ( i = 0; i != 20; ++i )
{
if ( *(_DWORD *)v0 )
result = checkGroup(i);
v0 += 508LL;
}
return result;
}

canonical_decompiled_code:
int func4()
{
unsigned __int64 v0; // rbp
signed int i; // ebx
int result; // eax

v0 = (unsigned int)((_DWORD)&feed + 80);
for ( i = 0; i != 20; ++i )
{
if ( *(_DWORD *)v0 )
result = func3(i);
v0 += 508LL;
}
return result;
}

original_code:
void checkNewsSources( void )
{
  int i;
  extern feedEntryType feed;
  for (i = 0 ; i < 20 ; i++) {
    if ( feed.groups[i].active ) {
      checkGroup( i );
    }
  }
  return;
}

canonical_original_code:
void checkNewsSources()
{
  int i;
  extern struct feedEntryType feed;
  for (i = 0 ; i < 20 ; i++) {
    if ( feed.groups[i].active ) {
      checkGroup( i );
    }
  }
  return;
}

variable_types: i int

variable_types: struct feedEntryType { char url[80]; struct groupEntryType { int active; char groupName[-1]; int lastMessageRead; char searchString[10][-1]; int numSearchStrings; } groups[20]; }


addWord

decompiled_code:
__int64 __fastcall addWord(int a1, __int64 a2)
{
__int64 result; // rax
unsigned __int64 v3; // rcx

result = 0LL;
while ( lexicon[2 * result] )
{
if ( ++result == 30 )
__assert_fail("0", "main.c", 0x25u, "addWord");
}
v3 = 16LL * (int)result;
dword_4040E8[v3 / 4] = a1;
lexicon[v3 / 8] = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1, __int64 a2)
{
__int64 result; // rax
unsigned __int64 v3; // rcx

result = 0LL;
while ( lexicon[2 * result] )
{
if ( ++result == 30 )
__assert_fail("0", "main.c", 0x25u, "addWord");
}
v3 = 16LL * (int)result;
dword_4040E8[v3 / 4] = a1;
lexicon[v3 / 8] = a2;
return result;
}

original_code:
void addWord( int type, char *word )
{
  int i=0;
  while (1) {
    if (lexicon.words[i].word == (char *)((void *)0)) {
      lexicon.words[i].type = type;
      lexicon.words[i].word = word;
      return;
    } else {
      if (++i == 30) break;
    }
  }
  ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "main.c", 37, __extension__ __PRETTY_FUNCTION__); }));
  return;
}

canonical_original_code:
void addWord(int type, char *word)
{
  int i = 0;
  while (1) {
    if (lexicon.words[i].word == (char *)((void *)0)) {
      lexicon.words[i].type = type;
      lexicon.words[i].word = word;
      return;
    } else {
      if (++i == 30) break;
    }
  }
  ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "main.c", 37, __extension__ __PRETTY_FUNCTION__); }));
  return;
}

variable_types: type int

variable_types:
word
char *


findWord

decompiled_code:
int __fastcall findWord(__int64 a1)
{
__int64 v1; // rbx
int result; // eax
const char *v3; // rbp
const char *v4; // r12
size_t v5; // rax

*(_DWORD *)(a1 + 8) = 5;
v1 = 0LL;
while ( 1 )
{
result = 16 * v1;
v3 = (const char *)lexicon[2 * v1];
if ( v3 )
{
v4 = *(const char **)a1;
v5 = strlen(*(const char **)a1);
result = strncmp(v3, v4, v5);
if ( !result )
break;
}
if ( ++v1 == 30 )
return result;
}
result = dword_4040E8[4 * (int)v1];
*(_DWORD *)(a1 + 8) = result;
return result;
}

canonical_decompiled_code:
int __fastcall func8(__int64 a1)
{
__int64 v1; // rbx
int result; // eax
const char *v3; // rbp
const char *v4; // r12
size_t v5; // rax

*(_DWORD *)(a1 + 8) = 5;
v1 = 0LL;
while ( 1 )
{
result = 16 * v1;
v3 = (const char *)lexicon[2 * v1];
if ( v3 )
{
v4 = *(const char **)a1;
v5 = strlen(*(const char **)a1);
result = strncmp(v3, v4, v5);
if ( !result )
break;
}
if ( ++v1 == 30 )
return result;
}
result = dword_4040E8[4 * (int)v1];
*(_DWORD *)(a1 + 8) = result;
return result;
}

original_code:
void findWord( word_t *symbol )
{
  int i;
  symbol->type = 5;
  for (i = 0 ; i < 30 ; i++) {
    if (lexicon.words[i].word != (char *)((void *)0)) {
      if (!strncmp(lexicon.words[i].word,
                    symbol->word, strlen(symbol->word))) {
        symbol->type = lexicon.words[i].type;
        return;
      }
    }
  }
  return;
}

canonical_original_code:
void findWord(struct word_t *symbol)
{
  int i;
  symbol->type = 5;
  for (i = 0 ; i < 30 ; i++) {
    if (lexicon.words[i].word != (char *)((void *)0)) {
      if (!strncmp(lexicon.words[i].word,
                    symbol->word, strlen(symbol->word))) {
        symbol->type = lexicon.words[i].type;
        return;
      }
    }
  }
  return;
}

variable_types: struct word_t { char *word; int type; } *


initSentence

decompiled_code:
char *__fastcall initSentence(char *src)
{
int v1; // ebx
void *v2; // rbp
char *result; // rax

v1 = strlen(src);
v2 = malloc(v1 + 1);
workingString = v2;
result = strncpy((char *)v2, src, v1);
*((_BYTE *)v2 + v1) = 0;
windex = 0;
frame = 0LL;
qword_4040A8 = 0LL;
qword_4040B0 = 0LL;
s = 0LL;
return result;
}

canonical_decompiled_code:
char *__fastcall func10(char *src)
{
int v1; // ebx
void *v2; // rbp
char *result; // rax

v1 = strlen(src);
v2 = malloc(v1 + 1);
workingString = v2;
result = strncpy((char *)v2, src, v1);
*((_BYTE *)v2 + v1) = 0;
windex = 0;
frame = 0LL;
qword_4040A8 = 0LL;
qword_4040B0 = 0LL;
s = 0LL;
return result;
}

original_code:
void initSentence( char *sentence )
{
  int len;
  len = strlen(sentence);
  workingString = malloc( len+1 );
  strncpy( workingString, sentence, len );
  workingString[len] = 0;
  windex = 0;
  frame.actor = ((void *)0);
  frame.action = ((void *)0);
  frame.modifier = ((void *)0);
  frame.object = ((void *)0);
  return;
}

canonical_original_code:
void initSentence(char *sentence)
{
  int len;
  len = strlen(sentence);
  workingString = malloc( len+1 );
  strncpy( workingString, sentence, len );
  workingString[len] = 0;
  windex = 0;
  frame.actor = ((void *)0);
  frame.action = ((void *)0);
  frame.modifier = ((void *)0);
  frame.object = ((void *)0);
  return;
}

variable_types:
sentence
char *

variable_types: len int


destroySentence

decompiled_code:
void destroySentence()
{
free(workingString);
}

canonical_decompiled_code:
void func11()
{
free(workingString);
}

original_code:
void destroySentence( void )
{
  free( workingString );
  return;
}

canonical_original_code:
void destroySentence()
{
  free( workingString );
  return;
}


getWord

decompiled_code:
int __fastcall getWord(__int64 a1)
{
char *v2; // r9
char *v3; // rax
char *v4; // rsi
char v5; // dl
int v6; // edi
int v7; // ecx
char *v8; // rdi
char v9; // dl
char *v10; // rax

v2 = (char *)workingString;
LODWORD(v3) = windex;
v4 = (char *)workingString + windex;
v5 = *v4;
if ( *v4 == 32 )
{
v3 = (char *)workingString + windex + 1;
do
{
v6 = (_DWORD)v3 - (_DWORD)workingString;
v4 = v3++;
v5 = *(v3 - 1);
}
while ( v5 == 32 );
windex = v6;
}
if ( v5 )
{
*(_QWORD *)a1 = v4;
v7 = windex;
v8 = &v2[windex];
v9 = *v8;
if ( (*v8 & 0xDF) != 0 )
{
v10 = &v2[windex + 1];
do
{
v7 = (_DWORD)v10 - (_DWORD)v2;
v8 = v10;
v9 = *v10++;
}
while ( (v9 & 0xDF) != 0 );
windex = v7;
}
if ( v9 == 32 )
{
windex = v7 + 1;
*v8 = 0;
}
LODWORD(v3) = findWord(a1);
}
else
{
*(_DWORD *)(a1 + 8) = 5;
}
return (int)v3;
}

canonical_decompiled_code:
int __fastcall func12(__int64 a1)
{
char *v2; // r9
char *v3; // rax
char *v4; // rsi
char v5; // dl
int v6; // edi
int v7; // ecx
char *v8; // rdi
char v9; // dl
char *v10; // rax

v2 = (char *)workingString;
LODWORD(v3) = windex;
v4 = (char *)workingString + windex;
v5 = *v4;
if ( *v4 == 32 )
{
v3 = (char *)workingString + windex + 1;
do
{
v6 = (_DWORD)v3 - (_DWORD)workingString;
v4 = v3++;
v5 = *(v3 - 1);
}
while ( v5 == 32 );
windex = v6;
}
if ( v5 )
{
*(_QWORD *)a1 = v4;
v7 = windex;
v8 = &v2[windex];
v9 = *v8;
if ( (*v8 & 0xDF) != 0 )
{
v10 = &v2[windex + 1];
do
{
v7 = (_DWORD)v10 - (_DWORD)v2;
v8 = v10;
v9 = *v10++;
}
while ( (v9 & 0xDF) != 0 );
windex = v7;
}
if ( v9 == 32 )
{
windex = v7 + 1;
*v8 = 0;
}
LODWORD(v3) = func8(a1);
}
else
{
*(_DWORD *)(a1 + 8) = 5;
}
return (int)v3;
}

original_code:
void getWord( word_t *symbol )
{
  while (workingString[windex] == ' ') windex++;
  if (workingString[windex] == 0) {
    symbol->type = 5;
    return;
  }
  symbol->word = &workingString[windex];
  while ((workingString[windex] != ' ') &&
         (workingString[windex] != 0)) windex++;
  if (workingString[windex] == ' ') {
    workingString[windex++] = 0;
  }
  findWord(symbol);
  return;
}

canonical_original_code:
void getWord(struct word_t *symbol)
{
  while (workingString[windex] == ' ') windex++;
  if (workingString[windex] == 0) {
    symbol->type = 5;
    return;
  }
  symbol->word = &workingString[windex];
  while ((workingString[windex] != ' ') &&
         (workingString[windex] != 0)) windex++;
  if (workingString[windex] == ' ') {
    workingString[windex++] = 0;
  }
  findWord(symbol);
  return;
}


strtype

decompiled_code:
const char *__fastcall strtype(int a1)
{
const char *result; // rax

switch ( a1 )
{
case 1:
result = "DET";
break;
case 2:
result = "NOUN";
break;
case 3:
result = "VERB";
break;
case 4:
result = "ADJECTIVE";
break;
case 5:
result = "EOS";
break;
default:
result = "BAD TYPE";
break;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func13(int a1)
{
const char *result; // rax

switch ( a1 )
{
case 1:
result = "DET";
break;
case 2:
result = "NOUN";
break;
case 3:
result = "VERB";
break;
case 4:
result = "ADJECTIVE";
break;
case 5:
result = "EOS";
break;
default:
result = "BAD TYPE";
break;
}
return result;
}

original_code:
char *strtype( int type )
{
  switch(type) {
    case 1: return("DET"); break;
    case 2: return("NOUN"); break;
    case 3: return("VERB"); break;
    case 4: return("ADJECTIVE"); break;
    case 5: return("EOS"); break;
  }
  return ("BAD TYPE");
}

canonical_original_code:
char *strtype(int type)
{
  switch(type) {
    case 1: return("DET"); break;
    case 2: return("NOUN"); break;
    case 3: return("VERB"); break;
    case 4: return("ADJECTIVE"); break;
    case 5: return("EOS"); break;
  }
  return ("BAD TYPE");
}


emitFrame

decompiled_code:
int emitFrame()
{
putchar(10);
if ( frame )
printf("Actor: %s\n", (const char *)frame);
if ( qword_4040A8 )
printf(" Action: %s\n", (const char *)qword_4040A8);
if ( s )
{
printf(" Object: ");
if ( qword_4040B0 )
printf("%s ", (const char *)qword_4040B0);
puts(s);
}
return puts("\n");
}

canonical_decompiled_code:
int func14()
{
putchar(10);
if ( frame )
printf("Actor: %s\n", (const char *)frame);
if ( qword_4040A8 )
printf(" Action: %s\n", (const char *)qword_4040A8);
if ( s )
{
printf(" Object: ");
if ( qword_4040B0 )
printf("%s ", (const char *)qword_4040B0);
puts(s);
}
return puts("\n");
}

original_code:
void emitFrame( void )
{
  printf("\n");
  if (frame.actor) printf("Actor: %s\n", frame.actor);
  if (frame.action) printf("  Action: %s\n", frame.action);
  if (frame.object) {
    printf("    Object: ");
    if (frame.modifier) printf("%s ", frame.modifier);
    printf("%s\n", frame.object);
  }
  printf("\n\n");
  return;
}

canonical_original_code:
void emitFrame()
{
  printf("\n");
  if (frame.actor) printf("Actor: %s\n", frame.actor);
  if (frame.action) printf("  Action: %s\n", frame.action);
  if (frame.object) {
    printf("    Object: ");
    if (frame.modifier) printf("%s ", frame.modifier);
    printf("%s\n", frame.object);
  }
  printf("\n\n");
  return;
}