formatDate

decompiled_code:
void __fastcall formatDate(char *s, char *a2)
{
char *v2; // r14
char *v3; // rax
int v4; // ebx
char *v5; // r12
char *v6; // r13
char *v7; // rbp

v2 = strdup(a2);
v3 = strtok(v2, "/");
if ( v3 )
{
v4 = 0;
v5 = 0LL;
v6 = 0LL;
v7 = 0LL;
do
{
switch ( v4 )
{
case 1:
v5 = strdup(v3);
break;
case 2:
v7 = strdup(v3);
break;
case 0:
v6 = strdup(v3);
break;
}
++v4;
v3 = strtok(0LL, "/");
}
while ( v3 );
}
else
{
v5 = 0LL;
v6 = 0LL;
v7 = 0LL;
}
sprintf(s, "%s/%s/%s", v7, v6, v5);
free(v6);
free(v5);
free(v7);
free(v2);
}

canonical_decompiled_code:
void __fastcall func5(char *s, char *a2)
{
char *v2; // r14
char *v3; // rax
int v4; // ebx
char *v5; // r12
char *v6; // r13
char *v7; // rbp

v2 = strdup(a2);
v3 = strtok(v2, "/");
if ( v3 )
{
v4 = 0;
v5 = 0LL;
v6 = 0LL;
v7 = 0LL;
do
{
switch ( v4 )
{
case 1:
v5 = strdup(v3);
break;
case 2:
v7 = strdup(v3);
break;
case 0:
v6 = strdup(v3);
break;
}
++v4;
v3 = strtok(0LL, "/");
}
while ( v3 );
}
else
{
v5 = 0LL;
v6 = 0LL;
v7 = 0LL;
}
sprintf(s, "%s/%s/%s", v7, v6, v5);
free(v6);
free(v5);
free(v7);
free(v2);
}

original_code:
void formatDate( char *newDate, char *oldDate )
{
 char *word, *toParse, *year, *month, *day ;
 int numParses ;
 numParses = 0 ;
 word = toParse = year = month = day = ((void *)0) ;
 toParse = strdup( oldDate ) ;
 word = strtok( toParse, "/" ) ;
 while( word != ((void *)0) )
 {
  switch( numParses )
  {
   case 0 : month = strdup( word ) ;
     break ;
   case 1 : day = strdup( word ) ;
     break ;
   case 2 : year = strdup( word ) ;
     break ;
  }
  numParses++ ;
  word = strtok( ((void *)0), "/" ) ;
 }
 sprintf( newDate,"%s/%s/%s", year, month, day ) ;
 free( month ) ;
 free( day ) ;
 free( year ) ;
 free( toParse ) ;
}

canonical_original_code:
void formatDate(char *newDate, char *oldDate)
{
 char *word; char *toParse; char *year; char *month; char *day;
 int numParses;
 numParses = 0 ;
 word = toParse = year = month = day = ((void *)0) ;
 toParse = strdup( oldDate ) ;
 word = strtok( toParse, "/" ) ;
 while( word != ((void *)0) )
 {
  switch( numParses )
  {
   case 0 : month = strdup( word ) ;
     break ;
   case 1 : day = strdup( word ) ;
     break ;
   case 2 : year = strdup( word ) ;
     break ;
  }
  numParses++ ;
  word = strtok( ((void *)0), "/" ) ;
 }
 sprintf( newDate,"%s/%s/%s", year, month, day ) ;
 free( month ) ;
 free( day ) ;
 free( year ) ;
 free( toParse ) ;
}

variable_types:
newDate
char *

variable_types:
oldDate
char *

variable_types:
year
char *

variable_types:
month
char *

variable_types:
day
char *


formatTimeStamp

repo: jnoll/peos

decompiled_code:
void __fastcall formatTimeStamp(char *s, char *a2)
{
char *v2; // rbp
char *v3; // rax
int v4; // ebx
char *v5; // r13
char *v6; // rbx
char dest[8]; // [rsp+8h] [rbp-50h] BYREF
__int16 v8; // [rsp+10h] [rbp-48h]
char v9; // [rsp+12h] [rbp-46h]
char v10[8]; // [rsp+13h] [rbp-45h] BYREF
char v11; // [rsp+1Bh] [rbp-3Dh]
char sa[8]; // [rsp+1Ch] [rbp-3Ch] BYREF
__int16 v13; // [rsp+24h] [rbp-34h]
char v14; // [rsp+26h] [rbp-32h]
char v15[8]; // [rsp+27h] [rbp-31h] BYREF
char v16; // [rsp+2Fh] [rbp-29h]

*(_QWORD *)v15 = 0LL;
v16 = 0;
*(_QWORD *)sa = 0LL;
v13 = 0;
v14 = 0;
*(_QWORD *)v10 = 0LL;
v11 = 0;
*(_QWORD *)dest = 0LL;
v8 = 0;
v9 = 0;
v2 = strdup(a2);
v3 = strtok(v2, "-");
if ( v3 )
{
v4 = 0;
do
{
if ( v4 )
{
if ( v4 == 1 )
strcpy(v10, v3);
}
else
{
strcpy(dest, v3);
}
++v4;
v3 = strtok(0LL, "-");
}
while ( v3 );
}
formatDate(sa, dest);
v5 = strdup(sa);
formatTime(v15, v10);
v6 = strdup(v15);
sprintf(s, "%s %s", v5, v6);
free(v5);
free(v6);
free(v2);
}

canonical_decompiled_code:
void __fastcall func6(char *s, char *a2)
{
char *v2; // rbp
char *v3; // rax
int v4; // ebx
char *v5; // r13
char *v6; // rbx
char dest[8]; // [rsp+8h] [rbp-50h] BYREF
__int16 v8; // [rsp+10h] [rbp-48h]
char v9; // [rsp+12h] [rbp-46h]
char v10[8]; // [rsp+13h] [rbp-45h] BYREF
char v11; // [rsp+1Bh] [rbp-3Dh]
char sa[8]; // [rsp+1Ch] [rbp-3Ch] BYREF
__int16 v13; // [rsp+24h] [rbp-34h]
char v14; // [rsp+26h] [rbp-32h]
char v15[8]; // [rsp+27h] [rbp-31h] BYREF
char v16; // [rsp+2Fh] [rbp-29h]

*(_QWORD *)v15 = 0LL;
v16 = 0;
*(_QWORD *)sa = 0LL;
v13 = 0;
v14 = 0;
*(_QWORD *)v10 = 0LL;
v11 = 0;
*(_QWORD *)dest = 0LL;
v8 = 0;
v9 = 0;
v2 = strdup(a2);
v3 = strtok(v2, "-");
if ( v3 )
{
v4 = 0;
do
{
if ( v4 )
{
if ( v4 == 1 )
strcpy(v10, v3);
}
else
{
strcpy(dest, v3);
}
++v4;
v3 = strtok(0LL, "-");
}
while ( v3 );
}
func5(sa, dest);
v5 = strdup(sa);
func4(v15, v10);
v6 = strdup(v15);
sprintf(s, "%s %s", v5, v6);
free(v5);
free(v6);
free(v2);
}

original_code:
void formatTimeStamp( char *newTimeStamp, char *oldTimeStamp )
{
 void formatTime( char *, char * ) ;
 void formatDate( char *, char * ) ;
 char *word, *toParse, *date, *time ;
 char formattedTime[9] = { '\0' } ;
 char formattedDate[11] = { '\0' } ;
 char oldTime[9] = { '\0' } ;
 char oldDate[11] = { '\0' } ;
 int numParses ;
 numParses = 0 ;
 word = toParse = date = time = ((void *)0) ;
 toParse = strdup( oldTimeStamp ) ;
 word = strtok( toParse, "-" ) ;
 while( word != ((void *)0) )
 {
  switch( numParses )
  {
   case 0 : strcpy( oldDate, word ) ;
     break ;
   case 1 : strcpy( oldTime, word ) ;
     break ;
  }
  numParses++ ;
  word = strtok( ((void *)0), "-" ) ;
 }
 formatDate( formattedDate, oldDate ) ;
 date = strdup( formattedDate ) ;
 formatTime( formattedTime, oldTime ) ;
 time = strdup( formattedTime ) ;
 sprintf( newTimeStamp,"%s %s", date, time ) ;
 free( date ) ;
 free( time ) ;
 free( toParse ) ;
}

canonical_original_code:
void formatTimeStamp(char *newTimeStamp, char *oldTimeStamp)
{
 void formatTime(char *, char *);
 void formatDate(char *, char *);
 char *word; char *toParse; char *date; char *time;
 char formattedTime[9] = { '\0' };
 char formattedDate[11] = { '\0' };
 char oldTime[9] = { '\0' };
 char oldDate[11] = { '\0' };
 int numParses;
 numParses = 0 ;
 word = toParse = date = time = ((void *)0) ;
 toParse = strdup( oldTimeStamp ) ;
 word = strtok( toParse, "-" ) ;
 while( word != ((void *)0) )
 {
  switch( numParses )
  {
   case 0 : strcpy( oldDate, word ) ;
     break ;
   case 1 : strcpy( oldTime, word ) ;
     break ;
  }
  numParses++ ;
  word = strtok( ((void *)0), "-" ) ;
 }
 formatDate( formattedDate, oldDate ) ;
 date = strdup( formattedDate ) ;
 formatTime( formattedTime, oldTime ) ;
 time = strdup( formattedTime ) ;
 sprintf( newTimeStamp,"%s %s", date, time ) ;
 free( date ) ;
 free( time ) ;
 free( toParse ) ;
}

variable_types:
newTimeStamp
char *

variable_types:
oldTimeStamp
char *

variable_types:
formatTime
void (char *, char *)

variable_types:
formatDate
void (char *, char *)

variable_types:
word
char *

variable_types:
toParse
char *

variable_types:
date
char *

variable_types:
time
char *

variable_types:
formattedTime
char [9]

variable_types:
formattedDate
char [11]

variable_types:
oldTime
char [9]

variable_types:
oldDate
char [11]

variable_types: numParses int

return_type: void


decompiled_code:
__int64 yy_linkparse()
{
int v0; // ebp
unsigned __int64 v1; // r14
char *v2; // r12
__int16 *v3; // rbx
__int16 *v4; // r13
int v5; // edx
unsigned int v6; // er15
__int16 *v7; // rdx
__int64 v8; // r15
int v9; // eax
unsigned __int8 v10; // bp
int v11; // eax
int v12; // esi
unsigned int v13; // ecx
unsigned __int64 v14; // rax
signed __int64 v15; // r12
__int16 *v16; // rax
__int16 *v17; // r15
int v18; // er15
unsigned __int8 v19; // dl
__int16 *v20; // rax
unsigned int v21; // ebp
int v22; // eax
unsigned int v23; // eax
char *v25; // [rsp+8h] [rbp-830h]
int v26; // [rsp+14h] [rbp-824h]
__int64 v27; // [rsp+18h] [rbp-820h]
__int64 v28; // [rsp+20h] [rbp-818h]
char *v29; // [rsp+28h] [rbp-810h]
char v30[1600]; // [rsp+30h] [rbp-808h] BYREF
__int16 src[228]; // [rsp+670h] [rbp-1C8h] BYREF

yy_linknerrs = 0;
yy_linkchar = -2;
src[0] = 0;
v26 = 0;
v0 = 0;
v1 = 200LL;
v2 = v30;
v25 = v30;
v3 = src;
v4 = src;
while ( 1 )
{
v18 = yy_linkpact[v0];
if ( v18 == -9 )
break;
if ( yy_linkchar == -2 )
yy_linkchar = yy_linklex();
if ( yy_linkchar <= 0 )
{
yy_linkchar = 0;
v5 = 0;
}
else
{
v5 = 2;
if ( (unsigned int)yy_linkchar <= 0x11F )
v5 = (unsigned __int8)yy_linktranslate[yy_linkchar];
}
v6 = v5 + v18;
if ( v6 > 0xD || (unsigned __int8)yy_linkcheck[v6] != v5 )
break;
v0 = (unsigned __int8)yy_linktable[v6];
if ( yy_linktable[v6] )
{
v26 = (v26 == 0) + v26 - 1;
yy_linkchar = -2;
*((_QWORD *)v2 + 1) = yy_linklval;
v2 += 8;
v7 = v3;
goto LABEL_11;
}
v8 = *((_QWORD *)v2 + 1);
v9 = 0;
v10 = 0;
LABEL_8:
v7 = &v3[-v10];
v2 = &v2[-8 * v10 + 8];
*(_QWORD *)v2 = v8;
v11 = (unsigned __int8)yy_linkr1[v9] - 11;
v12 = *v7;
v13 = v12 + yy_linkpgoto[v11];
if ( v13 <= 0xD && v12 == (unsigned __int8)yy_linkcheck[v13] )
v0 = (unsigned __int8)yy_linktable[v13];
else
v0 = yy_linkdefgoto[v11];
LABEL_11:
v3 = v7 + 1;
v7[1] = v0;
v14 = 2 * v1;
if ( v7 + 1 >= &v4[v1 - 1] )
{
v15 = (char *)v3 - (char *)v4;
v27 = v3 - v4 + 1;
if ( v1 > 0x270F )
goto LABEL_49;
v1 = 10000LL;
if ( v14 <= 0x2710 )
v1 = v14;
v16 = (__int16 *)malloc(10 * v1 + 7);
v17 = v16;
if ( !v16 )
{
LABEL_49:
yy_linkerror("memory exhausted");
v20 = v3;
v3 = v4;
v21 = 2;
goto LABEL_51;
}
memcpy(v16, v4, v15 + 2);
v28 = 8 * v27;
v29 = (char *)&v17[v1];
memcpy(v29, v25, 8 * v27);
if ( v4 != src )
free(v4);
v3 = (__int16 *)((char *)v17 + v15);
v2 = &v29[v28 - 8];
if ( v3 >= &v17[v1 - 1] )
{
if ( v17 == v3 )
{
v3 = v17;
v21 = 1;
goto LABEL_54;
}
v20 = v3;
v3 = v17;
v21 = 1;
goto LABEL_52;
}
v25 = v29;
v4 = v17;
}
if ( v0 == 2 )
{
v20 = v3;
v3 = v4;
v21 = 0;
goto LABEL_51;
}
}
v19 = yy_linkdefact[v0];
v9 = v19;
if ( v19 )
{
v10 = yy_linkr2[v19];
v8 = *(_QWORD *)&v2[8 * (1 - v10)];
switch ( v19 )
{
case 4u:
and_trees(&inputs, *((_QWORD *)v2 - 1));
v9 = 4;
break;
case 5u:
and_trees(&outputs, *((_QWORD *)v2 - 1));
v9 = 5;
break;
case 7u:
v8 = TreeCreate(*((_QWORD *)v2 - 2), *(_QWORD *)v2, &unk_4F8, 274LL);
v9 = 7;
break;
case 0xAu:
v8 = TreeCreate(*((_QWORD *)v2 - 2), *(_QWORD *)v2, &unk_4FB, 282LL);
v9 = 10;
break;
case 0xBu:
v8 = TreeCreate(0LL, 0LL, *(_QWORD *)v2, link_lineno);
v9 = 11;
break;
default:
goto LABEL_8;
}
goto LABEL_8;
}
if ( !v26 )
{
++yy_linknerrs;
yy_linkerror("syntax error");
goto LABEL_44;
}
if ( v26 == 3 )
{
if ( yy_linkchar > 0 )
{
yy_linkchar = -2;
goto LABEL_44;
}
if ( !yy_linkchar )
{
v20 = v3;
v3 = v4;
v21 = 1;
LABEL_51:
if ( v20 == v3 )
goto LABEL_53;
do
LABEL_52:
--v20;
while ( v20 != v3 );
goto LABEL_53;
}
}
while ( 1 )
{
LABEL_44:
v22 = yy_linkpact[v0];
if ( v22 != -9 )
{
v23 = v22 + 1;
if ( v23 <= 0xD && yy_linkcheck[v23] == 1 )
{
v0 = (unsigned __int8)yy_linktable[v23];
if ( yy_linktable[v23] )
{
*((_QWORD *)v2 + 1) = yy_linklval;
v2 += 8;
v7 = v3;
v26 = 3;
goto LABEL_11;
}
}
}
if ( v3 == v4 )
break;
v2 -= 8;
v0 = *--v3;
}
v21 = 1;
LABEL_53:
if ( v3 == src )
return v21;
LABEL_54:
free(v3);
return v21;
}

canonical_decompiled_code:
__int64 func1()
{
int v0; // ebp
unsigned __int64 v1; // r14
char *v2; // r12
__int16 *v3; // rbx
__int16 *v4; // r13
int v5; // edx
unsigned int v6; // er15
__int16 *v7; // rdx
__int64 v8; // r15
int v9; // eax
unsigned __int8 v10; // bp
int v11; // eax
int v12; // esi
unsigned int v13; // ecx
unsigned __int64 v14; // rax
signed __int64 v15; // r12
__int16 *v16; // rax
__int16 *v17; // r15
int v18; // er15
unsigned __int8 v19; // dl
__int16 *v20; // rax
unsigned int v21; // ebp
int v22; // eax
unsigned int v23; // eax
char *v25; // [rsp+8h] [rbp-830h]
int v26; // [rsp+14h] [rbp-824h]
__int64 v27; // [rsp+18h] [rbp-820h]
__int64 v28; // [rsp+20h] [rbp-818h]
char *v29; // [rsp+28h] [rbp-810h]
char v30[1600]; // [rsp+30h] [rbp-808h] BYREF
__int16 src[228]; // [rsp+670h] [rbp-1C8h] BYREF

yy_linknerrs = 0;
yy_linkchar = -2;
src[0] = 0;
v26 = 0;
v0 = 0;
v1 = 200LL;
v2 = v30;
v25 = v30;
v3 = src;
v4 = src;
while ( 1 )
{
v18 = yy_linkpact[v0];
if ( v18 == -9 )
break;
if ( yy_linkchar == -2 )
yy_linkchar = yy_linklex();
if ( yy_linkchar <= 0 )
{
yy_linkchar = 0;
v5 = 0;
}
else
{
v5 = 2;
if ( (unsigned int)yy_linkchar <= 0x11F )
v5 = (unsigned __int8)yy_linktranslate[yy_linkchar];
}
v6 = v5 + v18;
if ( v6 > 0xD || (unsigned __int8)yy_linkcheck[v6] != v5 )
break;
v0 = (unsigned __int8)yy_linktable[v6];
if ( yy_linktable[v6] )
{
v26 = (v26 == 0) + v26 - 1;
yy_linkchar = -2;
*((_QWORD *)v2 + 1) = yy_linklval;
v2 += 8;
v7 = v3;
goto LABEL_11;
}
v8 = *((_QWORD *)v2 + 1);
v9 = 0;
v10 = 0;
LABEL_8:
v7 = &v3[-v10];
v2 = &v2[-8 * v10 + 8];
*(_QWORD *)v2 = v8;
v11 = (unsigned __int8)yy_linkr1[v9] - 11;
v12 = *v7;
v13 = v12 + yy_linkpgoto[v11];
if ( v13 <= 0xD && v12 == (unsigned __int8)yy_linkcheck[v13] )
v0 = (unsigned __int8)yy_linktable[v13];
else
v0 = yy_linkdefgoto[v11];
LABEL_11:
v3 = v7 + 1;
v7[1] = v0;
v14 = 2 * v1;
if ( v7 + 1 >= &v4[v1 - 1] )
{
v15 = (char *)v3 - (char *)v4;
v27 = v3 - v4 + 1;
if ( v1 > 0x270F )
goto LABEL_49;
v1 = 10000LL;
if ( v14 <= 0x2710 )
v1 = v14;
v16 = (__int16 *)malloc(10 * v1 + 7);
v17 = v16;
if ( !v16 )
{
LABEL_49:
yy_linkerror("memory exhausted");
v20 = v3;
v3 = v4;
v21 = 2;
goto LABEL_51;
}
memcpy(v16, v4, v15 + 2);
v28 = 8 * v27;
v29 = (char *)&v17[v1];
memcpy(v29, v25, 8 * v27);
if ( v4 != src )
free(v4);
v3 = (__int16 *)((char *)v17 + v15);
v2 = &v29[v28 - 8];
if ( v3 >= &v17[v1 - 1] )
{
if ( v17 == v3 )
{
v3 = v17;
v21 = 1;
goto LABEL_54;
}
v20 = v3;
v3 = v17;
v21 = 1;
goto LABEL_52;
}
v25 = v29;
v4 = v17;
}
if ( v0 == 2 )
{
v20 = v3;
v3 = v4;
v21 = 0;
goto LABEL_51;
}
}
v19 = yy_linkdefact[v0];
v9 = v19;
if ( v19 )
{
v10 = yy_linkr2[v19];
v8 = *(_QWORD *)&v2[8 * (1 - v10)];
switch ( v19 )
{
case 4u:
func0(&inputs, *((_QWORD *)v2 - 1));
v9 = 4;
break;
case 5u:
func0(&outputs, *((_QWORD *)v2 - 1));
v9 = 5;
break;
case 7u:
v8 = TreeCreate(*((_QWORD *)v2 - 2), *(_QWORD *)v2, &unk_4F8, 274LL);
v9 = 7;
break;
case 0xAu:
v8 = TreeCreate(*((_QWORD *)v2 - 2), *(_QWORD *)v2, &unk_4FB, 282LL);
v9 = 10;
break;
case 0xBu:
v8 = TreeCreate(0LL, 0LL, *(_QWORD *)v2, link_lineno);
v9 = 11;
break;
default:
goto LABEL_8;
}
goto LABEL_8;
}
if ( !v26 )
{
++yy_linknerrs;
yy_linkerror("syntax error");
goto LABEL_44;
}
if ( v26 == 3 )
{
if ( yy_linkchar > 0 )
{
yy_linkchar = -2;
goto LABEL_44;
}
if ( !yy_linkchar )
{
v20 = v3;
v3 = v4;
v21 = 1;
LABEL_51:
if ( v20 == v3 )
goto LABEL_53;
do
LABEL_52:
--v20;
while ( v20 != v3 );
goto LABEL_53;
}
}
while ( 1 )
{
LABEL_44:
v22 = yy_linkpact[v0];
if ( v22 != -9 )
{
v23 = v22 + 1;
if ( v23 <= 0xD && yy_linkcheck[v23] == 1 )
{
v0 = (unsigned __int8)yy_linktable[v23];
if ( yy_linktable[v23] )
{
*((_QWORD *)v2 + 1) = yy_linklval;
v2 += 8;
v7 = v3;
v26 = 3;
goto LABEL_11;
}
}
}
if ( v3 == v4 )
break;
v2 -= 8;
v0 = *--v3;
}
v21 = 1;
LABEL_53:
if ( v3 == src )
return v21;
LABEL_54:
free(v3);
return v21;
}

original_code:
int
yy_linkparse (void)
{
    int yy_linkstate;
    int yy_linkerrstatus;
    yy_linktype_int16 yy_linkssa[200];
    yy_linktype_int16 *yy_linkss;
    yy_linktype_int16 *yy_linkssp;
    YY_LINK_STYPE_TYPE yy_linkvsa[200];
    YY_LINK_STYPE_TYPE *yy_linkvs;
    YY_LINK_STYPE_TYPE *yy_linkvsp;
    long unsigned int yy_linkstacksize;
  int yy_linkn;
  int yy_linkresult;
  int yy_linktoken = 0;
  YY_LINK_STYPE_TYPE yy_linkval;
  int yy_linklen = 0;
  yy_linkssp = yy_linkss = yy_linkssa;
  yy_linkvsp = yy_linkvs = yy_linkvsa;
  yy_linkstacksize = 200;
  ;
  yy_linkstate = 0;
  yy_linkerrstatus = 0;
  yy_linknerrs = 0;
  yy_linkchar = (-2);
  goto yy_linksetstate;
yy_linknewstate:
  yy_linkssp++;
yy_linksetstate:
  *yy_linkssp = (yy_linktype_int16) yy_linkstate;
  if (yy_linkss + yy_linkstacksize - 1 <= yy_linkssp)
    {
      long unsigned int yy_linksize = (long unsigned int) (yy_linkssp - yy_linkss + 1);
      if (10000 <= yy_linkstacksize)
        goto yy_linkexhaustedlab;
      yy_linkstacksize *= 2;
      if (10000 < yy_linkstacksize)
        yy_linkstacksize = 10000;
      {
        yy_linktype_int16 *yy_linkss1 = yy_linkss;
        union yy_linkalloc *yy_linkptr =
          (union yy_linkalloc *) malloc (((yy_linkstacksize) * (sizeof (yy_linktype_int16) + sizeof (YY_LINK_STYPE_TYPE)) + (sizeof (union yy_linkalloc) - 1)));
        if (! yy_linkptr)
          goto yy_linkexhaustedlab;
        do { long unsigned int yy_linknewbytes; __builtin_memcpy (&yy_linkptr->yy_linkss_alloc, yy_linkss, (yy_linksize) * sizeof (*(yy_linkss))); yy_linkss = &yy_linkptr->yy_linkss_alloc; yy_linknewbytes = yy_linkstacksize * sizeof (*yy_linkss) + (sizeof (union yy_linkalloc) - 1); yy_linkptr += yy_linknewbytes / sizeof (*yy_linkptr); } while (0);
        do { long unsigned int yy_linknewbytes; __builtin_memcpy (&yy_linkptr->yy_linkvs_alloc, yy_linkvs, (yy_linksize) * sizeof (*(yy_linkvs))); yy_linkvs = &yy_linkptr->yy_linkvs_alloc; yy_linknewbytes = yy_linkstacksize * sizeof (*yy_linkvs) + (sizeof (union yy_linkalloc) - 1); yy_linkptr += yy_linknewbytes / sizeof (*yy_linkptr); } while (0);
        if (yy_linkss1 != yy_linkssa)
          free (yy_linkss1);
      }
      yy_linkssp = yy_linkss + yy_linksize - 1;
      yy_linkvsp = yy_linkvs + yy_linksize - 1;
      ;
      if (yy_linkss + yy_linkstacksize - 1 <= yy_linkssp)
        goto yy_linkabortlab;
    }
  ;
  if (yy_linkstate == 2)
    goto yy_linkacceptlab;
  goto yy_linkbackup;
yy_linkbackup:
  yy_linkn = yy_linkpact[yy_linkstate];
  if ((!!((yy_linkn) == (-9))))
    goto yy_linkdefault;
  if (yy_linkchar == (-2))
    {
      ;
      yy_linkchar = yy_linklex ();
    }
  if (yy_linkchar <= 0)
    {
      yy_linkchar = yy_linktoken = 0;
      ;
    }
  else
    {
      yy_linktoken = ((unsigned) (yy_linkchar) <= 287 ? yy_linktranslate[yy_linkchar] : 2);
      ;
    }
  yy_linkn += yy_linktoken;
  if (yy_linkn < 0 || 13 < yy_linkn || yy_linkcheck[yy_linkn] != yy_linktoken)
    goto yy_linkdefault;
  yy_linkn = yy_linktable[yy_linkn];
  if (yy_linkn <= 0)
    {
      if (0)
        goto yy_linkerrlab;
      yy_linkn = -yy_linkn;
      goto yy_linkreduce;
    }
  if (yy_linkerrstatus)
    yy_linkerrstatus--;
  ;
  yy_linkchar = (-2);
  yy_linkstate = yy_linkn;

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yy_linkvsp = yy_linklval;

#pragma GCC diagnostic pop

  goto yy_linknewstate;
yy_linkdefault:
  yy_linkn = yy_linkdefact[yy_linkstate];
  if (yy_linkn == 0)
    goto yy_linkerrlab;
  goto yy_linkreduce;
yy_linkreduce:
  yy_linklen = yy_linkr2[yy_linkn];
  yy_linkval = yy_linkvsp[1-yy_linklen];
  ;
  switch (yy_linkn)
    {
        case 4:
    {
           and_trees(&inputs, (yy_linkvsp[-1].tree));
        }
    break;
  case 5:
    {
           and_trees(&outputs, (yy_linkvsp[-1].tree));
        }
    break;
  case 7:
    {
            (yy_linkval.tree) = TreeCreate ((yy_linkvsp[-2].tree), (yy_linkvsp[0].tree), "&&", 274);
         }
    break;
  case 10:
    {
         (yy_linkval.tree) = TreeCreate ((yy_linkvsp[-2].tree), (yy_linkvsp[0].tree), ".", 282);
         }
    break;
  case 11:
    {
      (yy_linkval.tree) = TreeCreate (((void *)0), ((void *)0), (yy_linkvsp[0].string), link_lineno);
  }
    break;
      default: break;
    }
  ;
  (yy_linkvsp -= (yy_linklen), yy_linkssp -= (yy_linklen));
  yy_linklen = 0;
  ;
  *++yy_linkvsp = yy_linkval;
  {
    const int yy_linklhs = yy_linkr1[yy_linkn] - 11;
    const int yy_linki = yy_linkpgoto[yy_linklhs] + *yy_linkssp;
    yy_linkstate = (0 <= yy_linki && yy_linki <= 13 && yy_linkcheck[yy_linki] == *yy_linkssp
               ? yy_linktable[yy_linki]
               : yy_linkdefgoto[yy_linklhs]);
  }
  goto yy_linknewstate;
yy_linkerrlab:
  yy_linktoken = yy_linkchar == (-2) ? (-2) : ((unsigned) (yy_linkchar) <= 287 ? yy_linktranslate[yy_linkchar] : 2);
  if (!yy_linkerrstatus)
    {
      ++yy_linknerrs;
      yy_linkerror ("syntax error");
    }
  if (yy_linkerrstatus == 3)
    {
      if (yy_linkchar <= 0)
        {
          if (yy_linkchar == 0)
            goto yy_linkabortlab;
        }
      else
        {
          yy_linkdestruct ("Error: discarding",
                      yy_linktoken, &yy_linklval);
          yy_linkchar = (-2);
        }
    }
  goto yy_linkerrlab1;
yy_linkerrorlab:
  if (0)
    goto yy_linkerrorlab;
  (yy_linkvsp -= (yy_linklen), yy_linkssp -= (yy_linklen));
  yy_linklen = 0;
  ;
  yy_linkstate = *yy_linkssp;
  goto yy_linkerrlab1;
yy_linkerrlab1:
  yy_linkerrstatus = 3;
  for (;;)
    {
      yy_linkn = yy_linkpact[yy_linkstate];
      if (!(!!((yy_linkn) == (-9))))
        {
          yy_linkn += 1;
          if (0 <= yy_linkn && yy_linkn <= 13 && yy_linkcheck[yy_linkn] == 1)
            {
              yy_linkn = yy_linktable[yy_linkn];
              if (0 < yy_linkn)
                break;
            }
        }
      if (yy_linkssp == yy_linkss)
        goto yy_linkabortlab;
      yy_linkdestruct ("Error: popping",
                  yy_linkstos[yy_linkstate], yy_linkvsp);
      (yy_linkvsp -= (1), yy_linkssp -= (1));
      yy_linkstate = *yy_linkssp;
      ;
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yy_linkvsp = yy_linklval;

#pragma GCC diagnostic pop

  ;
  yy_linkstate = yy_linkn;
  goto yy_linknewstate;
yy_linkacceptlab:
  yy_linkresult = 0;
  goto yy_linkreturn;
yy_linkabortlab:
  yy_linkresult = 1;
  goto yy_linkreturn;
yy_linkexhaustedlab:
  yy_linkerror ("memory exhausted");
  yy_linkresult = 2;
yy_linkreturn:
  if (yy_linkchar != (-2))
    {
      yy_linktoken = ((unsigned) (yy_linkchar) <= 287 ? yy_linktranslate[yy_linkchar] : 2);
      yy_linkdestruct ("Cleanup: discarding lookahead",
                  yy_linktoken, &yy_linklval);
    }
  (yy_linkvsp -= (yy_linklen), yy_linkssp -= (yy_linklen));
  ;
  while (yy_linkssp != yy_linkss)
    {
      yy_linkdestruct ("Cleanup: popping",
                  yy_linkstos[*yy_linkssp], yy_linkvsp);
      (yy_linkvsp -= (1), yy_linkssp -= (1));
    }
  if (yy_linkss != yy_linkssa)
    free (yy_linkss);
  return yy_linkresult;
}

canonical_original_code:
int yy_linkparse()
{
    int yy_linkstate;
    int yy_linkerrstatus;
    short yy_linkssa[200];
    short *yy_linkss;
    short *yy_linkssp;
    union YY_LINK_STYPE_TYPE yy_linkvsa[200];
    union YY_LINK_STYPE_TYPE *yy_linkvs;
    union YY_LINK_STYPE_TYPE *yy_linkvsp;
    unsigned long yy_linkstacksize;
  int yy_linkn;
  int yy_linkresult;
  int yy_linktoken = 0;
  union YY_LINK_STYPE_TYPE yy_linkval;
  int yy_linklen = 0;
  yy_linkssp = yy_linkss = yy_linkssa;
  yy_linkvsp = yy_linkvs = yy_linkvsa;
  yy_linkstacksize = 200;
  ;
  yy_linkstate = 0;
  yy_linkerrstatus = 0;
  yy_linknerrs = 0;
  yy_linkchar = (-2);
  goto yy_linksetstate;
yy_linknewstate:
  yy_linkssp++;
yy_linksetstate:
  *yy_linkssp = (short) yy_linkstate;
  if (yy_linkss + yy_linkstacksize - 1 <= yy_linkssp)
    {
      unsigned long yy_linksize = (long unsigned int) (yy_linkssp - yy_linkss + 1);
      if (10000 <= yy_linkstacksize)
        goto yy_linkexhaustedlab;
      yy_linkstacksize *= 2;
      if (10000 < yy_linkstacksize)
        yy_linkstacksize = 10000;
      {
        short *yy_linkss1 = yy_linkss;
        union yy_linkalloc *yy_linkptr = (union yy_linkalloc *) malloc (((yy_linkstacksize) * (sizeof (yy_linktype_int16) + sizeof (YY_LINK_STYPE_TYPE)) + (sizeof (union yy_linkalloc) - 1)));
        if (! yy_linkptr)
          goto yy_linkexhaustedlab;
        do { unsigned long yy_linknewbytes; __builtin_memcpy (&yy_linkptr->yy_linkss_alloc, yy_linkss, (yy_linksize) * sizeof (*(yy_linkss))); yy_linkss = &yy_linkptr->yy_linkss_alloc; yy_linknewbytes = yy_linkstacksize * sizeof (*yy_linkss) + (sizeof (union yy_linkalloc) - 1); yy_linkptr += yy_linknewbytes / sizeof (*yy_linkptr); } while (0);
        do { unsigned long yy_linknewbytes; __builtin_memcpy (&yy_linkptr->yy_linkvs_alloc, yy_linkvs, (yy_linksize) * sizeof (*(yy_linkvs))); yy_linkvs = &yy_linkptr->yy_linkvs_alloc; yy_linknewbytes = yy_linkstacksize * sizeof (*yy_linkvs) + (sizeof (union yy_linkalloc) - 1); yy_linkptr += yy_linknewbytes / sizeof (*yy_linkptr); } while (0);
        if (yy_linkss1 != yy_linkssa)
          free (yy_linkss1);
      }
      yy_linkssp = yy_linkss + yy_linksize - 1;
      yy_linkvsp = yy_linkvs + yy_linksize - 1;
      ;
      if (yy_linkss + yy_linkstacksize - 1 <= yy_linkssp)
        goto yy_linkabortlab;
    }
  ;
  if (yy_linkstate == 2)
    goto yy_linkacceptlab;
  goto yy_linkbackup;
yy_linkbackup:
  yy_linkn = yy_linkpact[yy_linkstate];
  if ((!!((yy_linkn) == (-9))))
    goto yy_linkdefault;
  if (yy_linkchar == (-2))
    {
      ;
      yy_linkchar = yy_linklex ();
    }
  if (yy_linkchar <= 0)
    {
      yy_linkchar = yy_linktoken = 0;
      ;
    }
  else
    {
      yy_linktoken = ((unsigned int) (yy_linkchar) <= 287 ? yy_linktranslate[yy_linkchar] : 2);
      ;
    }
  yy_linkn += yy_linktoken;
  if (yy_linkn < 0 || 13 < yy_linkn || yy_linkcheck[yy_linkn] != yy_linktoken)
    goto yy_linkdefault;
  yy_linkn = yy_linktable[yy_linkn];
  if (yy_linkn <= 0)
    {
      if (0)
        goto yy_linkerrlab;
      yy_linkn = -yy_linkn;
      goto yy_linkreduce;
    }
  if (yy_linkerrstatus)
    yy_linkerrstatus--;
  ;
  yy_linkchar = (-2);
  yy_linkstate = yy_linkn;

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yy_linkvsp = yy_linklval;

#pragma GCC diagnostic pop

  goto yy_linknewstate;
yy_linkdefault:
  yy_linkn = yy_linkdefact[yy_linkstate];
  if (yy_linkn == 0)
    goto yy_linkerrlab;
  goto yy_linkreduce;
yy_linkreduce:
  yy_linklen = yy_linkr2[yy_linkn];
  yy_linkval = yy_linkvsp[1-yy_linklen];
  ;
  switch (yy_linkn)
    {
        case 4:
    {
           and_trees(&inputs, (yy_linkvsp[-1].tree));
        }
    break;
  case 5:
    {
           and_trees(&outputs, (yy_linkvsp[-1].tree));
        }
    break;
  case 7:
    {
            (yy_linkval.tree) = TreeCreate ((yy_linkvsp[-2].tree), (yy_linkvsp[0].tree), "&&", 274);
         }
    break;
  case 10:
    {
         (yy_linkval.tree) = TreeCreate ((yy_linkvsp[-2].tree), (yy_linkvsp[0].tree), ".", 282);
         }
    break;
  case 11:
    {
      (yy_linkval.tree) = TreeCreate (((void *)0), ((void *)0), (yy_linkvsp[0].string), link_lineno);
  }
    break;
      default: break;
    }
  ;
  (yy_linkvsp -= (yy_linklen), yy_linkssp -= (yy_linklen));
  yy_linklen = 0;
  ;
  *++yy_linkvsp = yy_linkval;
  {
    int yy_linklhs = yy_linkr1[yy_linkn] - 11;
    int yy_linki = yy_linkpgoto[yy_linklhs] + *yy_linkssp;
    yy_linkstate = (0 <= yy_linki && yy_linki <= 13 && yy_linkcheck[yy_linki] == *yy_linkssp
               ? yy_linktable[yy_linki]
               : yy_linkdefgoto[yy_linklhs]);
  }
  goto yy_linknewstate;
yy_linkerrlab:
  yy_linktoken = yy_linkchar == (-2) ? (-2) : ((unsigned int) (yy_linkchar) <= 287 ? yy_linktranslate[yy_linkchar] : 2);
  if (!yy_linkerrstatus)
    {
      ++yy_linknerrs;
      yy_linkerror ("syntax error");
    }
  if (yy_linkerrstatus == 3)
    {
      if (yy_linkchar <= 0)
        {
          if (yy_linkchar == 0)
            goto yy_linkabortlab;
        }
      else
        {
          yy_linkdestruct ("Error: discarding",
                      yy_linktoken, &yy_linklval);
          yy_linkchar = (-2);
        }
    }
  goto yy_linkerrlab1;
yy_linkerrorlab:
  if (0)
    goto yy_linkerrorlab;
  (yy_linkvsp -= (yy_linklen), yy_linkssp -= (yy_linklen));
  yy_linklen = 0;
  ;
  yy_linkstate = *yy_linkssp;
  goto yy_linkerrlab1;
yy_linkerrlab1:
  yy_linkerrstatus = 3;
  for (;;)
    {
      yy_linkn = yy_linkpact[yy_linkstate];
      if (!(!!((yy_linkn) == (-9))))
        {
          yy_linkn += 1;
          if (0 <= yy_linkn && yy_linkn <= 13 && yy_linkcheck[yy_linkn] == 1)
            {
              yy_linkn = yy_linktable[yy_linkn];
              if (0 < yy_linkn)
                break;
            }
        }
      if (yy_linkssp == yy_linkss)
        goto yy_linkabortlab;
      yy_linkdestruct ("Error: popping",
                  yy_linkstos[yy_linkstate], yy_linkvsp);
      (yy_linkvsp -= (1), yy_linkssp -= (1));
      yy_linkstate = *yy_linkssp;
      ;
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yy_linkvsp = yy_linklval;

#pragma GCC diagnostic pop

  ;
  yy_linkstate = yy_linkn;
  goto yy_linknewstate;
yy_linkacceptlab:
  yy_linkresult = 0;
  goto yy_linkreturn;
yy_linkabortlab:
  yy_linkresult = 1;
  goto yy_linkreturn;
yy_linkexhaustedlab:
  yy_linkerror ("memory exhausted");
  yy_linkresult = 2;
yy_linkreturn:
  if (yy_linkchar != (-2))
    {
      yy_linktoken = ((unsigned int) (yy_linkchar) <= 287 ? yy_linktranslate[yy_linkchar] : 2);
      yy_linkdestruct ("Cleanup: discarding lookahead",
                  yy_linktoken, &yy_linklval);
    }
  (yy_linkvsp -= (yy_linklen), yy_linkssp -= (yy_linklen));
  ;
  while (yy_linkssp != yy_linkss)
    {
      yy_linkdestruct ("Cleanup: popping",
                  yy_linkstos[*yy_linkssp], yy_linkvsp);
      (yy_linkvsp -= (1), yy_linkssp -= (1));
    }
  if (yy_linkss != yy_linkssa)
    free (yy_linkss);
  return yy_linkresult;
}

variable_types: union YY_LINK_STYPE_TYPE { struct tree { struct tree *left; struct tree *right; char *sval; int ival; } *tree; char *string; } [200]

variable_types: union YY_LINK_STYPE_TYPE { struct tree { struct tree *left; struct tree *right; char *sval; int ival; } *tree; char *string; } *

variable_types: union yy_linkalloc { short yy_linkss_alloc; union YY_LINK_STYPE_TYPE { struct tree { struct tree *left; struct tree *right; char *sval; int ival; } *tree; char *string; } yy_linkvs_alloc; } *

return_type: int

user_defined_types: union YY_LINK_STYPE_TYPE { struct tree *tree; char *string; }

user_defined_types: union yy_linkalloc { short yy_linkss_alloc; union YY_LINK_STYPE_TYPE yy_linkvs_alloc; }


lostr

decompiled_code:
char *__fastcall lostr(char *s)
{
size_t v1; // rbx

v1 = 0LL;
if ( s )
{
while ( v1 < strlen(s) )
{
s[v1] = (*_ctype_tolower_loc())[s[v1]];
++v1;
}
}
return s;
}

canonical_decompiled_code:
char *__fastcall func0(char *s)
{
size_t v1; // rbx

v1 = 0LL;
if ( s )
{
while ( v1 < strlen(s) )
{
s[v1] = (*_ctype_tolower_loc())[s[v1]];
++v1;
}
}
return s;
}

original_code:
char *lostr(char *inputstr)
{
unsigned long int tempnum = 0;
 if (inputstr != ((void *)0)) {
  for ( ;tempnum < strlen(inputstr);tempnum++) {
   inputstr[tempnum] = tolower(inputstr[tempnum]);
  }
 }
 return(inputstr);
}

canonical_original_code:
char *lostr(char *inputstr)
{
unsigned long tempnum = 0;
 if (inputstr != ((void *)0)) {
  for ( ;tempnum < strlen(inputstr);tempnum++) {
   inputstr[tempnum] = tolower(inputstr[tempnum]);
  }
 }
 return(inputstr);
}

variable_types:
inputstr
char *

variable_types:
tempnum
unsigned long

return_type: char *


upstr

decompiled_code:
char *__fastcall upstr(char *s)
{
size_t v1; // rbx

v1 = 0LL;
if ( s )
{
while ( v1 < strlen(s) )
{
s[v1] = (*_ctype_toupper_loc())[s[v1]];
++v1;
}
}
return s;
}

canonical_decompiled_code:
char *__fastcall func1(char *s)
{
size_t v1; // rbx

v1 = 0LL;
if ( s )
{
while ( v1 < strlen(s) )
{
s[v1] = (*_ctype_toupper_loc())[s[v1]];
++v1;
}
}
return s;
}

original_code:
char *upstr(char *inputstr)
{
unsigned long int tempnum = 0;
 if (inputstr != ((void *)0)) {
  for ( ;tempnum < strlen(inputstr);tempnum++) {
   inputstr[tempnum] = toupper(inputstr[tempnum]);
  }
 }
 return(inputstr);
}

canonical_original_code:
char *upstr(char *inputstr)
{
unsigned long tempnum = 0;
 if (inputstr != ((void *)0)) {
  for ( ;tempnum < strlen(inputstr);tempnum++) {
   inputstr[tempnum] = toupper(inputstr[tempnum]);
  }
 }
 return(inputstr);
}


clrchr

decompiled_code:
char *__fastcall clrchr(char *dest, char a2)
{
size_t v2; // rax
char *v3; // r14
char *v4; // r12
size_t v5; // rbx
char v6; // al

if ( dest )
{
v2 = strlen(dest);
v3 = (char *)malloc(v2 + 1);
v4 = v3;
v5 = 0LL;
do
{
v6 = dest[v5];
if ( v6 != a2 )
*v4++ = v6;
++v5;
}
while ( strlen(dest) >= v5 );
strcpy(dest, v3);
free(v3);
}
return dest;
}

canonical_decompiled_code:
char *__fastcall func2(char *dest, char a2)
{
size_t v2; // rax
char *v3; // r14
char *v4; // r12
size_t v5; // rbx
char v6; // al

if ( dest )
{
v2 = strlen(dest);
v3 = (char *)malloc(v2 + 1);
v4 = v3;
v5 = 0LL;
do
{
v6 = dest[v5];
if ( v6 != a2 )
*v4++ = v6;
++v5;
}
while ( strlen(dest) >= v5 );
strcpy(dest, v3);
free(v3);
}
return dest;
}

original_code:
char *clrchr(char *inputstr,char chrtoclr)
{
char *tempstr, *strpos;
unsigned long int tempnum = 0;
 if (inputstr != ((void *)0)) {
  tempstr = (char *)malloc((strlen(inputstr) + 1) * sizeof(char));
  strpos = tempstr;
  for ( ;tempnum <= strlen(inputstr);tempnum++) {
   if (inputstr[tempnum] != chrtoclr) {
    *strpos = inputstr[tempnum];
    strpos++;
   }
  }
  strcpy(inputstr,tempstr);
  free(tempstr);
 }
 return(inputstr);
}

canonical_original_code:
char *clrchr(char *inputstr, char chrtoclr)
{
char *tempstr; char *strpos;
unsigned long tempnum = 0;
 if (inputstr != ((void *)0)) {
  tempstr = (char *)malloc((strlen(inputstr) + 1) * sizeof(char));
  strpos = tempstr;
  for ( ;tempnum <= strlen(inputstr);tempnum++) {
   if (inputstr[tempnum] != chrtoclr) {
    *strpos = inputstr[tempnum];
    strpos++;
   }
  }
  strcpy(inputstr,tempstr);
  free(tempstr);
 }
 return(inputstr);
}

variable_types: chrtoclr char

variable_types:
tempstr
char *

variable_types:
strpos
char *


ltrim

decompiled_code:
void *__fastcall ltrim(void *dest)
{
__int64 v1; // rbx
char *v2; // r12
char v3; // al
size_t v4; // rax

if ( dest )
{
if ( *(_BYTE *)dest == 32 || *(_BYTE *)dest == 9 )
{
v1 = 0LL;
do
{
do
{
++v1;
v2 = (char *)dest + v1;
v3 = *((_BYTE *)dest + v1);
}
while ( v3 == 32 );
}
while ( v3 == 9 );
}
else
{
v2 = (char *)dest;
v1 = 0LL;
}
v4 = strlen((const char *)dest);
memmove(dest, v2, v4 + 1 - v1);
}
return dest;
}

canonical_decompiled_code:
void *__fastcall func3(void *dest)
{
__int64 v1; // rbx
char *v2; // r12
char v3; // al
size_t v4; // rax

if ( dest )
{
if ( *(_BYTE *)dest == 32 || *(_BYTE *)dest == 9 )
{
v1 = 0LL;
do
{
do
{
++v1;
v2 = (char *)dest + v1;
v3 = *((_BYTE *)dest + v1);
}
while ( v3 == 32 );
}
while ( v3 == 9 );
}
else
{
v2 = (char *)dest;
v1 = 0LL;
}
v4 = strlen((const char *)dest);
memmove(dest, v2, v4 + 1 - v1);
}
return dest;
}

original_code:
char *ltrim(char *inputstr)
{
unsigned long int tempnum = 0;
 if (inputstr != ((void *)0)) {
  while (inputstr[tempnum] == 32 || inputstr[tempnum] == 9)
   tempnum++;
  memmove(inputstr,inputstr+tempnum,(strlen(inputstr)-tempnum+1) * sizeof(char));
 }
 return(inputstr);
}

canonical_original_code:
char *ltrim(char *inputstr)
{
unsigned long tempnum = 0;
 if (inputstr != ((void *)0)) {
  while (inputstr[tempnum] == 32 || inputstr[tempnum] == 9)
   tempnum++;
  memmove(inputstr,inputstr+tempnum,(strlen(inputstr)-tempnum+1) * sizeof(char));
 }
 return(inputstr);
}


rtrim

decompiled_code:
const char *__fastcall rtrim(const char *a1)
{
int v1; // eax
int v2; // edx
unsigned __int64 v3; // rcx
__int64 v4; // rsi
const char *v5; // rax
unsigned __int64 v6; // rcx

if ( a1 )
{
v1 = strlen(a1);
v2 = v1;
v3 = (unsigned __int8)a1[v1];
if ( (unsigned __int8)v3 <= 0x20u )
{
v4 = 0x100002401LL;
if ( _bittest64(&v4, v3) )
{
if ( v1 )
{
v5 = &a1[v1 - 1];
do
{
--v2;
v6 = *(unsigned __int8 *)v5;
if ( (unsigned __int8)v6 > 0x20u )
break;
if ( !_bittest64(&v4, v6) )
break;
--v5;
}
while ( v2 );
}
}
}
a1[v2 + 1] = 0;
}
return a1;
}

canonical_decompiled_code:
const char *__fastcall func4(const char *a1)
{
int v1; // eax
int v2; // edx
unsigned __int64 v3; // rcx
__int64 v4; // rsi
const char *v5; // rax
unsigned __int64 v6; // rcx

if ( a1 )
{
v1 = strlen(a1);
v2 = v1;
v3 = (unsigned __int8)a1[v1];
if ( (unsigned __int8)v3 <= 0x20u )
{
v4 = 0x100002401LL;
if ( _bittest64(&v4, v3) )
{
if ( v1 )
{
v5 = &a1[v1 - 1];
do
{
--v2;
v6 = *(unsigned __int8 *)v5;
if ( (unsigned __int8)v6 > 0x20u )
break;
if ( !_bittest64(&v4, v6) )
break;
--v5;
}
while ( v2 );
}
}
}
a1[v2 + 1] = 0;
}
return a1;
}

original_code:
char *rtrim(char *inputstr)
{
unsigned int tempnum;
 if (inputstr != ((void *)0)) {
  tempnum = strlen(inputstr);
  while (((inputstr[tempnum] == 32) || (inputstr[tempnum]=='\0')
     || (inputstr[tempnum] == '\r') || (inputstr[tempnum] == '\n'))
     && (tempnum > 0))
   tempnum--;
  inputstr[tempnum+1] = '\0';
 }
 return(inputstr);
}

variable_types:
tempnum
unsigned int


alltrim

decompiled_code:
void *__fastcall alltrim(void *a1)
{
ltrim(a1);
rtrim((const char *)a1);
return a1;
}

canonical_decompiled_code:
void *__fastcall func5(void *a1)
{
func3(a1);
func4((const char *)a1);
return a1;
}

original_code:
char *alltrim(char *inputstr)
{
 ltrim(inputstr);
 rtrim(inputstr);
 return(inputstr);
}


cutstr

decompiled_code:
char *__fastcall cutstr(char *src, char *reject)
{
size_t v2; // r13
size_t v3; // rax
char *v4; // r12
size_t v6; // rbp

if ( !src )
return 0LL;
v2 = strcspn(src, reject);
v3 = strlen(src);
v4 = (char *)&unk_339;
if ( v2 != v3 )
{
v4 = (char *)malloc(v3 + 1);
v6 = strcspn(src, reject);
strncpy(v4, src, v6);
v4[v6] = 0;
}
return v4;
}

canonical_decompiled_code:
char *__fastcall func6(char *src, char *reject)
{
size_t v2; // r13
size_t v3; // rax
char *v4; // r12
size_t v6; // rbp

if ( !src )
return 0LL;
v2 = strcspn(src, reject);
v3 = strlen(src);
v4 = (char *)&unk_339;
if ( v2 != v3 )
{
v4 = (char *)malloc(v3 + 1);
v6 = strcspn(src, reject);
strncpy(v4, src, v6);
v4[v6] = 0;
}
return v4;
}

original_code:
char *cutstr(char *inputstr,char *strtofnd)
{
char *tempstr;
unsigned long int matchpos;
 if (inputstr != ((void *)0)) {
  if (strcspn(inputstr,strtofnd) == strlen(inputstr)) return("");
  tempstr=(char *)malloc((strlen(inputstr)*sizeof(char))+1);
  matchpos = strcspn(inputstr,strtofnd);
  strncpy(tempstr,inputstr,matchpos);
  tempstr[matchpos] = '\0';
  return(tempstr);
 } return(((void *)0));
}

canonical_original_code:
char *cutstr(char *inputstr, char *strtofnd)
{
char *tempstr;
unsigned long matchpos;
 if (inputstr != ((void *)0)) {
  if (strcspn(inputstr,strtofnd) == strlen(inputstr)) return("");
  tempstr=(char *)malloc((strlen(inputstr)*sizeof(char))+1);
  matchpos = strcspn(inputstr,strtofnd);
  strncpy(tempstr,inputstr,matchpos);
  tempstr[matchpos] = '\0';
  return(tempstr);
 } return(((void *)0));
}

variable_types:
strtofnd
char *

variable_types:
matchpos
unsigned long


valbyname

decompiled_code:
char *__fastcall valbyname(char *dest, char *s2, char *a3)
{
size_t v5; // rax
char *v6; // r13
size_t v7; // r14
size_t v8; // rax
size_t v9; // rbp
size_t v10; // rax

if ( a3 != 0LL && s2 != 0LL && dest )
{
v5 = strlen(dest);
v6 = (char *)malloc(v5 + 1);
strcpy(v6, dest);
ltrim(v6);
v7 = strlen(s2);
if ( !strncasecmp(v6, s2, v7) )
{
v8 = strlen(v6);
memmove(v6, &v6[v7], v8 - v7 + 1);
ltrim(v6);
if ( *a3 )
{
v9 = strlen(a3);
if ( !strncasecmp(v6, a3, v9) )
{
v10 = strlen(v6);
memmove(v6, &v6[v9], v10 - v9 + 1);
ltrim(v6);
}
}
}
strcpy(dest, v6);
free(v6);
}
return dest;
}

canonical_decompiled_code:
char *__fastcall func7(char *dest, char *s2, char *a3)
{
size_t v5; // rax
char *v6; // r13
size_t v7; // r14
size_t v8; // rax
size_t v9; // rbp
size_t v10; // rax

if ( a3 != 0LL && s2 != 0LL && dest )
{
v5 = strlen(dest);
v6 = (char *)malloc(v5 + 1);
strcpy(v6, dest);
func3(v6);
v7 = strlen(s2);
if ( !strncasecmp(v6, s2, v7) )
{
v8 = strlen(v6);
memmove(v6, &v6[v7], v8 - v7 + 1);
func3(v6);
if ( *a3 )
{
v9 = strlen(a3);
if ( !strncasecmp(v6, a3, v9) )
{
v10 = strlen(v6);
memmove(v6, &v6[v9], v10 - v9 + 1);
func3(v6);
}
}
}
strcpy(dest, v6);
free(v6);
}
return dest;
}

original_code:
char *valbyname(char *inputstr,char *name2fnd,char *sepstr)
{
char *tempstr;
 if (inputstr != ((void *)0) && name2fnd != ((void *)0) && sepstr != ((void *)0)) {
  tempstr=(char *)malloc((strlen(inputstr) + 1) * sizeof(char));
  strcpy(tempstr,inputstr);
  ltrim(tempstr);
  if (strncasecmp(tempstr,name2fnd,strlen(name2fnd)) == 0) {
   memmove(tempstr,tempstr + strlen(name2fnd),
    strlen(tempstr) - strlen(name2fnd) + 1);
   ltrim(tempstr);
   if (strlen(sepstr) > 0) {
    if (strncasecmp(tempstr,sepstr,strlen(sepstr)) == 0) {
     memmove(tempstr,tempstr + strlen(sepstr),
      strlen(tempstr) - strlen(sepstr) + 1);
     ltrim(tempstr);
    }
   }
  }
  strcpy(inputstr,tempstr);
  free(tempstr);
 }
 return(inputstr);
}

canonical_original_code:
char *valbyname(char *inputstr, char *name2fnd, char *sepstr)
{
char *tempstr;
 if (inputstr != ((void *)0) && name2fnd != ((void *)0) && sepstr != ((void *)0)) {
  tempstr=(char *)malloc((strlen(inputstr) + 1) * sizeof(char));
  strcpy(tempstr,inputstr);
  ltrim(tempstr);
  if (strncasecmp(tempstr,name2fnd,strlen(name2fnd)) == 0) {
   memmove(tempstr,tempstr + strlen(name2fnd),
    strlen(tempstr) - strlen(name2fnd) + 1);
   ltrim(tempstr);
   if (strlen(sepstr) > 0) {
    if (strncasecmp(tempstr,sepstr,strlen(sepstr)) == 0) {
     memmove(tempstr,tempstr + strlen(sepstr),
      strlen(tempstr) - strlen(sepstr) + 1);
     ltrim(tempstr);
    }
   }
  }
  strcpy(inputstr,tempstr);
  free(tempstr);
 }
 return(inputstr);
}

variable_types:
sepstr
char *


isEMAILQuery

decompiled_code:
void __fastcall __noreturn isEMAILQuery(char *src)
{
char *v1; // rbx
__int64 v2[2]; // [rsp+0h] [rbp-3F8h] BYREF
char v3[984]; // [rsp+10h] [rbp-3E8h] BYREF

v2[0] = 0LL;
v2[1] = 0LL;
memset(v3, 0, sizeof(v3));
strcpy((char *)v2, src);
v1 = strtok((char *)v2, ":");
assert("EMAILseeker.c", 151LL, v1);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(char *src)
{
char *v1; // rbx
__int64 v2[2]; // [rsp+0h] [rbp-3F8h] BYREF
char v3[984]; // [rsp+10h] [rbp-3E8h] BYREF

v2[0] = 0LL;
v2[1] = 0LL;
memset(v3, 0, sizeof(v3));
strcpy((char *)v2, src);
v1 = strtok((char *)v2, ":");
assert("EMAILseeker.c", 151LL, v1);
}

original_code:
int isEMAILQuery( char *value )
{
 char *repository ;
 char tempValue[1000] = { '\0' } ;
 strcpy( tempValue, value ) ;
 repository = strtok(tempValue , ":" ) ;
 _assert( "EMAILseeker.c", 151, repository ) ;
 if( strcmp( "email", repository) == 0 )
  return 1 ;
 else
  return 0 ;
}

canonical_original_code:
int isEMAILQuery(char *value)
{
 char *repository;
 char tempValue[1000] = { '\0' };
 strcpy( tempValue, value ) ;
 repository = strtok(tempValue , ":" ) ;
 _assert( "EMAILseeker.c", 151, repository ) ;
 if( strcmp( "email", repository) == 0 )
  return 1 ;
 else
  return 0 ;
}

variable_types:
value
char *

variable_types:
repository
char *

variable_types:
tempValue
char [1000]


getMessageID

decompiled_code:
void __fastcall __noreturn getMessageID(__int64 a1, const char *a2)
{
char *v2; // rax
__int64 v3[2]; // [rsp+0h] [rbp-408h] BYREF
char v4[984]; // [rsp+10h] [rbp-3F8h] BYREF

v3[0] = 0LL;
v3[1] = 0LL;
memset(v4, 0, sizeof(v4));
strcpy((char *)v3, a2);
v2 = strchr((const char *)v3, 60);
assert("EMAILseeker.c", 390LL, v2);
}

canonical_decompiled_code:
void __fastcall __noreturn func1(__int64 a1, const char *a2)
{
char *v2; // rax
__int64 v3[2]; // [rsp+0h] [rbp-408h] BYREF
char v4[984]; // [rsp+10h] [rbp-3F8h] BYREF

v3[0] = 0LL;
v3[1] = 0LL;
memset(v4, 0, sizeof(v4));
strcpy((char *)v3, a2);
v2 = strchr((const char *)v3, 60);
assert("EMAILseeker.c", 390LL, v2);
}

original_code:
void getMessageID( char *idBuffer, char *messageLine )
{
 char msg[1000] = { '\0' } ;
 char *ptrMsg1, *ptrMsg2 ;
 int length = 0 ;
 strcpy ( msg, messageLine ) ;
 ptrMsg1 = strchr ( msg, '<' ) ;
 _assert( "EMAILseeker.c", 390, ptrMsg1 ) ;
 ptrMsg2 = strrchr ( msg , '>' ) ;
 _assert( "EMAILseeker.c", 392, ptrMsg2 ) ;
 length = ptrMsg2 - ptrMsg1 ;
 strncpy ( idBuffer, ptrMsg1 + 1, length - 1 ) ;
 idBuffer[ length - 1 ] = '\0' ;
}

canonical_original_code:
void getMessageID(char *idBuffer, char *messageLine)
{
 char msg[1000] = { '\0' };
 char *ptrMsg1; char *ptrMsg2;
 int length = 0;
 strcpy ( msg, messageLine ) ;
 ptrMsg1 = strchr ( msg, '<' ) ;
 _assert( "EMAILseeker.c", 390, ptrMsg1 ) ;
 ptrMsg2 = strrchr ( msg , '>' ) ;
 _assert( "EMAILseeker.c", 392, ptrMsg2 ) ;
 length = ptrMsg2 - ptrMsg1 ;
 strncpy ( idBuffer, ptrMsg1 + 1, length - 1 ) ;
 idBuffer[ length - 1 ] = '\0' ;
}

variable_types:
idBuffer
char *

variable_types:
messageLine
char *

variable_types:
msg
char [1000]

variable_types: length int


EMAILidCompare

decompiled_code:
void __fastcall __noreturn EMAILidCompare(const char *a1)
{
char *v1; // rax

v1 = rindex(a1, 47);
assert("EMAILseeker.c", 412LL, v1);
}

canonical_decompiled_code:
void __fastcall __noreturn func2(const char *a1)
{
char *v1; // rax

v1 = rindex(a1, 47);
assert("EMAILseeker.c", 412LL, v1);
}

original_code:
int EMAILidCompare ( char *queryValue, char *messageID )
{
 char *ptrQuery ;
 ptrQuery = rindex( queryValue, '/' ) ;
 _assert( "EMAILseeker.c", 412, ptrQuery ) ;
 if ( strcmp ( ptrQuery + 1, messageID ) == 0 )
  return 1 ;
 else
  return 0 ;
}

canonical_original_code:
int EMAILidCompare(char *queryValue, char *messageID)
{
 char *ptrQuery;
 ptrQuery = rindex( queryValue, '/' ) ;
 _assert( "EMAILseeker.c", 412, ptrQuery ) ;
 if ( strcmp ( ptrQuery + 1, messageID ) == 0 )
  return 1 ;
 else
  return 0 ;
}

variable_types:
queryValue
char *

variable_types:
messageID
char *

variable_types:
ptrQuery
char *


EMAILsubjectCompare

decompiled_code:
_BOOL8 __fastcall EMAILsubjectCompare(char *needle, char *s)
{
_BOOL4 v2; // edx
char *v3; // rax
bool v5; // zf
char *v6; // rax

v2 = 0;
if ( !*s )
return 0LL;
if ( !strcmp(operatorType, "~") )
{
v3 = strchr(s, 32);
v2 = strstr(v3 + 1, needle) != 0LL;
}
else
{
v5 = strcmp(operatorType, "EQ") == 0;
LOBYTE(v2) = !v5;
if ( v5 )
{
v6 = strchr(s, 32);
v2 = strcmp(v6 + 1, needle) == 0;
}
}
return v2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(char *needle, char *s)
{
_BOOL4 v2; // edx
char *v3; // rax
bool v5; // zf
char *v6; // rax

v2 = 0;
if ( !*s )
return 0LL;
if ( !strcmp(operatorType, "~") )
{
v3 = strchr(s, 32);
v2 = strstr(v3 + 1, needle) != 0LL;
}
else
{
v5 = strcmp(operatorType, "EQ") == 0;
LOBYTE(v2) = !v5;
if ( v5 )
{
v6 = strchr(s, 32);
v2 = strcmp(v6 + 1, needle) == 0;
}
}
return v2;
}

original_code:
int EMAILsubjectCompare ( char *queryValue, char *subjectLine )
{
 if ( strlen ( subjectLine ) == 0 )
  return 0 ;
 else
 {
  if ( strcmp ( operatorType, "~" ) == 0 )
  {
   if( strstr( (strpbrk(subjectLine," ") +1), queryValue) != ((void *)0) )
    return 1 ;
   else
    return 0 ;
  }
  else if ( strcmp ( operatorType, "EQ" ) == 0 )
  {
   if( strcmp( (strpbrk(subjectLine," ") +1), queryValue) == 0 )
    return 1 ;
   else
    return 0 ;
  }
 }
}

canonical_original_code:
int EMAILsubjectCompare(char *queryValue, char *subjectLine)
{
 if ( strlen ( subjectLine ) == 0 )
  return 0 ;
 else
 {
  if ( strcmp ( operatorType, "~" ) == 0 )
  {
   if( strstr( (strpbrk(subjectLine," ") +1), queryValue) != ((void *)0) )
    return 1 ;
   else
    return 0 ;
  }
  else if ( strcmp ( operatorType, "EQ" ) == 0 )
  {
   if( strcmp( (strpbrk(subjectLine," ") +1), queryValue) == 0 )
    return 1 ;
   else
    return 0 ;
  }
 }
}

variable_types:
subjectLine
char *


getMailDate

decompiled_code:
void __fastcall getMailDate(char *s, const char *a2)
{
char *v2; // rbp
char *v3; // r12
char *v4; // r13
char *v5; // r14
int v7; // ebx
char *v8; // rdi
const char *v9; // rax
__int64 v10[2]; // [rsp+0h] [rbp-428h] BYREF
char v11[984]; // [rsp+10h] [rbp-418h] BYREF

v10[0] = 0LL;
v10[1] = 0LL;
memset(v11, 0, sizeof(v11));
strcpy((char *)v10, a2);
v7 = 1;
if ( strtok((char *)v10, " ") )
{
while ( 1 )
{
v8 = strtok(0LL, " ");
if ( !v8 )
break;
if ( ++v7 == 5 )
{
v4 = strdup(v8);
}
else if ( v7 > 5 )
{
if ( v7 == 6 )
v3 = strdup(v8);
}
else if ( v7 == 3 )
{
v2 = strdup(v8);
}
else if ( v7 == 4 )
{
v9 = (const char *)convertMonth(v8);
v5 = strdup(v9);
}
}
}
if ( strlen(v2) == 1 )
sprintf(s, "%s/%s/0%s %s", v4, v5, v2, v3);
else
sprintf(s, "%s/%s/%s %s", v4, v5, v2, v3);
free(v5);
free(v2);
free(v4);
free(v3);
}

canonical_decompiled_code:
void __fastcall func4(char *s, const char *a2)
{
char *v2; // rbp
char *v3; // r12
char *v4; // r13
char *v5; // r14
int v7; // ebx
char *v8; // rdi
const char *v9; // rax
__int64 v10[2]; // [rsp+0h] [rbp-428h] BYREF
char v11[984]; // [rsp+10h] [rbp-418h] BYREF

v10[0] = 0LL;
v10[1] = 0LL;
memset(v11, 0, sizeof(v11));
strcpy((char *)v10, a2);
v7 = 1;
if ( strtok((char *)v10, " ") )
{
while ( 1 )
{
v8 = strtok(0LL, " ");
if ( !v8 )
break;
if ( ++v7 == 5 )
{
v4 = strdup(v8);
}
else if ( v7 > 5 )
{
if ( v7 == 6 )
v3 = strdup(v8);
}
else if ( v7 == 3 )
{
v2 = strdup(v8);
}
else if ( v7 == 4 )
{
v9 = (const char *)convertMonth(v8);
v5 = strdup(v9);
}
}
}
if ( strlen(v2) == 1 )
sprintf(s, "%s/%s/0%s %s", v4, v5, v2, v3);
else
sprintf(s, "%s/%s/%s %s", v4, v5, v2, v3);
free(v5);
free(v2);
free(v4);
free(v3);
}

original_code:
void getMailDate( char *value, char *dateLine )
{
 char* convertMonth( char * ) ;
 char *word, *toParse, *year, *month, *day, *time ;
 char dateValue[1000] = { '\0' } ;
 int numParses ;
 numParses = 0 ;
 word = toParse = ((void *)0) ;
 strcpy ( dateValue, dateLine ) ;
 word = strtok( dateValue, " " ) ;
 while( word != ((void *)0) )
 {
  numParses++ ;
  switch( numParses )
  {
   case 3 : day = strdup( word ) ;
     break ;
   case 4 : month = strdup( convertMonth ( word ) ) ;
     break ;
   case 5 : year = strdup( word ) ;
     break ;
   case 6 : time = strdup( word ) ;
     break ;
  }
  word = strtok( ((void *)0), " " ) ;
 }
 if( strlen( day ) == 1 )
  sprintf( value, "%s/%s/0%s %s", year, month, day, time ) ;
 else
  sprintf( value, "%s/%s/%s %s", year, month, day, time ) ;
 free( month ) ;
 free( day ) ;
 free( year ) ;
 free( time ) ;
}

canonical_original_code:
void getMailDate(char *value, char *dateLine)
{
 char *convertMonth(char *);
 char *word; char *toParse; char *year; char *month; char *day; char *time;
 char dateValue[1000] = { '\0' };
 int numParses;
 numParses = 0 ;
 word = toParse = ((void *)0) ;
 strcpy ( dateValue, dateLine ) ;
 word = strtok( dateValue, " " ) ;
 while( word != ((void *)0) )
 {
  numParses++ ;
  switch( numParses )
  {
   case 3 : day = strdup( word ) ;
     break ;
   case 4 : month = strdup( convertMonth ( word ) ) ;
     break ;
   case 5 : year = strdup( word ) ;
     break ;
   case 6 : time = strdup( word ) ;
     break ;
  }
  word = strtok( ((void *)0), " " ) ;
 }
 if( strlen( day ) == 1 )
  sprintf( value, "%s/%s/0%s %s", year, month, day, time ) ;
 else
  sprintf( value, "%s/%s/%s %s", year, month, day, time ) ;
 free( month ) ;
 free( day ) ;
 free( year ) ;
 free( time ) ;
}

variable_types:
dateLine
char *

variable_types:
convertMonth
char *(char *)

variable_types:
word
char *

variable_types:
toParse
char *

variable_types:
year
char *

variable_types:
month
char *

variable_types:
day
char *

variable_types:
time
char *

variable_types:
dateValue
char [1000]

variable_types: numParses int


EMAILdateCompare

decompiled_code:
char __fastcall EMAILdateCompare(__int64 a1, const char *a2)
{
time_t v2; // rbx
time_t v3; // rdx
char result; // al
double v5; // xmm0_8
bool v6; // zf
double v7; // xmm0_8
__int64 v8[2]; // [rsp+0h] [rbp-48h] BYREF
int v9; // [rsp+10h] [rbp-38h]
__int16 v10; // [rsp+14h] [rbp-34h]
char s[8]; // [rsp+20h] [rbp-28h] BYREF
__int64 v12; // [rsp+28h] [rbp-20h]
int v13; // [rsp+30h] [rbp-18h]
__int16 v14; // [rsp+34h] [rbp-14h]

*(_QWORD *)s = 0LL;
v12 = 0LL;
v13 = 0;
v14 = 0;
v8[0] = 0LL;
v8[1] = 0LL;
v9 = 0;
v10 = 0;
getMailDate(s, a2);
formatTimeStamp(v8, a1);
v2 = (int)parsedate(s, 0LL);
v3 = (int)parsedate(v8, 0LL);
if ( !strcmp(operatorType, "EQ") )
return difftime(v2, v3) == 0.0;
if ( !strcmp(operatorType, "LT") )
return difftime(v2, v3) < 0.0;
if ( !strcmp(operatorType, "LE") )
{
v5 = difftime(v2, v3);
if ( v5 == 0.0 )
result = 1;
else
result = v5 < 0.0;
}
else if ( !strcmp(operatorType, "GT") )
{
result = difftime(v2, v3) > 0.0;
}
else
{
v6 = strcmp(operatorType, "GE") == 0;
result = !v6;
if ( v6 )
{
v7 = difftime(v2, v3);
if ( v7 == 0.0 )
result = 1;
else
result = v7 > 0.0;
}
}
return result;
}

canonical_decompiled_code:
char __fastcall func5(__int64 a1, const char *a2)
{
time_t v2; // rbx
time_t v3; // rdx
char result; // al
double v5; // xmm0_8
bool v6; // zf
double v7; // xmm0_8
__int64 v8[2]; // [rsp+0h] [rbp-48h] BYREF
int v9; // [rsp+10h] [rbp-38h]
__int16 v10; // [rsp+14h] [rbp-34h]
char s[8]; // [rsp+20h] [rbp-28h] BYREF
__int64 v12; // [rsp+28h] [rbp-20h]
int v13; // [rsp+30h] [rbp-18h]
__int16 v14; // [rsp+34h] [rbp-14h]

*(_QWORD *)s = 0LL;
v12 = 0LL;
v13 = 0;
v14 = 0;
v8[0] = 0LL;
v8[1] = 0LL;
v9 = 0;
v10 = 0;
func4(s, a2);
formatTimeStamp(v8, a1);
v2 = (int)parsedate(s, 0LL);
v3 = (int)parsedate(v8, 0LL);
if ( !strcmp(operatorType, "EQ") )
return difftime(v2, v3) == 0.0;
if ( !strcmp(operatorType, "LT") )
return difftime(v2, v3) < 0.0;
if ( !strcmp(operatorType, "LE") )
{
v5 = difftime(v2, v3);
if ( v5 == 0.0 )
result = 1;
else
result = v5 < 0.0;
}
else if ( !strcmp(operatorType, "GT") )
{
result = difftime(v2, v3) > 0.0;
}
else
{
v6 = strcmp(operatorType, "GE") == 0;
result = !v6;
if ( v6 )
{
v7 = difftime(v2, v3);
if ( v7 == 0.0 )
result = 1;
else
result = v7 > 0.0;
}
}
return result;
}

original_code:
int EMAILdateCompare ( char *queryValue, char *dateLine )
{
 void getMailDate( char *, char * ) ;
 char mailDate[22] = { '\0' } ;
 char queryDate[22] = { '\0' } ;
 time_t mailTimeStamp, queryTimeStamp ;
 int x = 9 ;
 getMailDate( mailDate, dateLine ) ;
 formatTimeStamp( queryDate, queryValue ) ;
 mailTimeStamp = parsedate( mailDate, ((void *)0) ) ;
 queryTimeStamp = parsedate( queryDate, ((void *)0)) ;
 if ( strcmp ( operatorType, "EQ" ) == 0 )
 {
  if ( difftime( mailTimeStamp, queryTimeStamp ) == 0 )
   return 1 ;
  else
   return 0 ;
 }
 else if ( strcmp ( operatorType, "LT" ) == 0 )
 {
  if( difftime( mailTimeStamp, queryTimeStamp ) < 0 )
   return 1 ;
  else
   return 0 ;
 }
 else if( strcmp( operatorType, "LE" ) == 0 )
 {
  if( ( difftime( mailTimeStamp, queryTimeStamp ) == 0 ) ||
      ( difftime( mailTimeStamp, queryTimeStamp ) < 0 ) )
   return 1 ;
  else
   return 0 ;
 }
 else if ( strcmp ( operatorType, "GT" ) == 0 )
 {
  if( difftime( mailTimeStamp, queryTimeStamp ) > 0 )
   return 1 ;
  else
   return 0 ;
 }
 else if( strcmp( operatorType, "GE" ) == 0 )
 {
  if( ( difftime( mailTimeStamp, queryTimeStamp ) == 0 ) ||
      ( difftime( mailTimeStamp, queryTimeStamp ) > 0 ) )
   return 1 ;
  else
   return 0 ;
 }
}

canonical_original_code:
int EMAILdateCompare(char *queryValue, char *dateLine)
{
 void getMailDate(char *, char *);
 char mailDate[22] = { '\0' };
 char queryDate[22] = { '\0' };
 long mailTimeStamp; long queryTimeStamp;
 int x = 9;
 getMailDate( mailDate, dateLine ) ;
 formatTimeStamp( queryDate, queryValue ) ;
 mailTimeStamp = parsedate( mailDate, ((void *)0) ) ;
 queryTimeStamp = parsedate( queryDate, ((void *)0)) ;
 if ( strcmp ( operatorType, "EQ" ) == 0 )
 {
  if ( difftime( mailTimeStamp, queryTimeStamp ) == 0 )
   return 1 ;
  else
   return 0 ;
 }
 else if ( strcmp ( operatorType, "LT" ) == 0 )
 {
  if( difftime( mailTimeStamp, queryTimeStamp ) < 0 )
   return 1 ;
  else
   return 0 ;
 }
 else if( strcmp( operatorType, "LE" ) == 0 )
 {
  if( ( difftime( mailTimeStamp, queryTimeStamp ) == 0 ) ||
      ( difftime( mailTimeStamp, queryTimeStamp ) < 0 ) )
   return 1 ;
  else
   return 0 ;
 }
 else if ( strcmp ( operatorType, "GT" ) == 0 )
 {
  if( difftime( mailTimeStamp, queryTimeStamp ) > 0 )
   return 1 ;
  else
   return 0 ;
 }
 else if( strcmp( operatorType, "GE" ) == 0 )
 {
  if( ( difftime( mailTimeStamp, queryTimeStamp ) == 0 ) ||
      ( difftime( mailTimeStamp, queryTimeStamp ) > 0 ) )
   return 1 ;
  else
   return 0 ;
 }
}

variable_types:
getMailDate
void (char *, char *)

variable_types:
mailDate
char [22]

variable_types:
queryDate
char [22]

variable_types: mailTimeStamp long

variable_types: queryTimeStamp long

variable_types: x int


EMAILqueryValidator

decompiled_code:
__int64 __fastcall EMAILqueryValidator(__int64 a1)
{
__int64 v1; // rax
unsigned int v2; // ecx
char v3; // dl
char v5; // [rsp+1h] [rbp-3F9h]
__int64 v6[2]; // [rsp+2h] [rbp-3F8h] BYREF
char v7[984]; // [rsp+12h] [rbp-3E8h] BYREF

v6[0] = 0LL;
v6[1] = 0LL;
memset(v7, 0, sizeof(v7));
strcpy((char *)v6, (const char *)(a1 + 6));
if ( BYTE1(v6[0]) != 47 )
return 0;
v1 = 2LL;
do
{
v2 = v1++;
v3 = *(&v5 + v1);
}
while ( v3 == 47 );
if ( v2 == 2 )
{
if ( !v3 )
v2 = 0;
}
else if ( v2 == 3 )
{
if ( !v3 )
v2 = 0;
}
else
{
v2 = 0;
}
return v2;
}

original_code:
int EMAILqueryValidator( char *value )
{
 char testValue[1000] = { '\0' } ;
 int numslash = 1 ;
 int slashResult = 0 ;
 strcpy( testValue, value + 6 ) ;
 while( strncmp( testValue + numslash, "/", 1 ) == 0 )
  numslash++ ;
 switch( numslash )
 {
  case 2: if( strlen( testValue + numslash ) )
     slashResult = 2 ;
    else
     slashResult = 0 ;
    break ;
  case 3: if( strlen( testValue + numslash ) )
     slashResult = 3 ;
    else
     slashResult = 0 ;
    break ;
  default: slashResult = 0 ;
    break ;
 }
 return slashResult ;
}

canonical_original_code:
int EMAILqueryValidator(char *value)
{
 char testValue[1000] = { '\0' };
 int numslash = 1;
 int slashResult = 0;
 strcpy( testValue, value + 6 ) ;
 while( strncmp( testValue + numslash, "/", 1 ) == 0 )
  numslash++ ;
 switch( numslash )
 {
  case 2: if( strlen( testValue + numslash ) )
     slashResult = 2 ;
    else
     slashResult = 0 ;
    break ;
  case 3: if( strlen( testValue + numslash ) )
     slashResult = 3 ;
    else
     slashResult = 0 ;
    break ;
  default: slashResult = 0 ;
    break ;
 }
 return slashResult ;
}

variable_types:
value
char *

variable_types:
testValue
char [1000]

variable_types: numslash int

variable_types: slashResult int


decompiled_code:
__int64 __fastcall set_attr(__int64 a1, const char *a2, const char *a3)
{
size_t v4; // r13
size_t v5; // rax

v4 = strlen(a3);
v5 = strlen(a2);
return pml_write_attribute(a1, a2, v5 + 1, a3, v4 + 1);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, const char *a2, const char *a3)
{
size_t v4; // r13
size_t v5; // rax

v4 = strlen(a3);
v5 = strlen(a2);
return pml_write_attribute(a1, a2, v5 + 1, a3, v4 + 1);
}

original_code:
int set_attr(pml_obj_t obj, char *name, char *val)
{
  return pml_write_attribute(obj, name, strlen(name) + 1,
         val, strlen(val) + 1);
}

canonical_original_code:
int set_attr(struct pml_rec_t *obj, char *name, char *val)
{
  return pml_write_attribute(obj, name, strlen(name) + 1,
         val, strlen(val) + 1);
}

variable_types: struct pml_rec_t { int deleted; unsigned int natr; long aofs[1024]; unsigned long alen[1024]; unsigned int nval; long vofs[1024]; unsigned long vlen[1024]; } *

variable_types:
name
char *

variable_types:
val
char *


decompiled_code:
int __fastcall get_attr(__int64 a1, const char *a2, const char *a3)
{
size_t v4; // rax
size_t v5; // rax
int result; // eax
_BYTE savedregs[296]; // [rsp+0h] [rbp+0h] BYREF

memset(savedregs, 0, 0x100uLL);
v4 = strlen(a2);
pml_read_attribute(a1, a2, v4 + 1, savedregs, 256LL);
v5 = strlen(a3);
result = memcmp(savedregs, a3, v5 + 1);
if ( result )
result = printf("Object %u: retrieved value '%s' != expected value '%s'\n", a1, savedregs, a3);
return result;
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1, const char *a2, const char *a3)
{
size_t v4; // rax
size_t v5; // rax
int result; // eax
_BYTE savedregs[296]; // [rsp+0h] [rbp+0h] BYREF

memset(savedregs, 0, 0x100uLL);
v4 = strlen(a2);
pml_read_attribute(a1, a2, v4 + 1, savedregs, 256LL);
v5 = strlen(a3);
result = memcmp(savedregs, a3, v5 + 1);
if ( result )
result = printf("Object %u: retrieved value '%s' != expected value '%s'\n", a1, savedregs, a3);
return result;
}

original_code:
int get_attr(pml_obj_t obj, char *name, char *expected_val)
{
  char value[256];
  memset(value, 0, sizeof(value));
  pml_read_attribute(obj, name, strlen(name) + 1, value, sizeof(value));
  if (memcmp(value, expected_val, strlen(expected_val) + 1) != 0) {
      printf("Object %u: retrieved value '%s' != expected value '%s'\n",
      obj, value, expected_val);
  }
}

canonical_original_code:
int get_attr(struct pml_rec_t *obj, char *name, char *expected_val)
{
  char value[256];
  memset(value, 0, sizeof(value));
  pml_read_attribute(obj, name, strlen(name) + 1, value, sizeof(value));
  if (memcmp(value, expected_val, strlen(expected_val) + 1) != 0) {
      printf("Object %u: retrieved value '%s' != expected value '%s'\n",
      obj, value, expected_val);
  }
}

variable_types:
value
char [256]

user_defined_types: struct pml_rec_t { int deleted; unsigned int natr; long aofs[1024]; unsigned long alen[1024]; unsigned int nval; long vofs[1024]; unsigned long vlen[1024]; }


decompiled_code:
__int64 __fastcall list_attr(__int64 a1)
{
int v1; // eax
unsigned int v2; // er13
__int64 v3; // r12
__int64 v4; // rbx
__int64 v6; // [rsp+0h] [rbp-38h] BYREF
__int64 v7[6]; // [rsp+8h] [rbp-30h] BYREF

v1 = pml_list_attributes(a1, v7, &v6);
v2 = v1;
if ( v1 < 0 )
{
printf("list_attr: error listing attributes of object %u\n", a1);
}
else
{
v3 = 8LL * (unsigned int)v1;
v4 = 0LL;
if ( v1 )
{
do
{
get_attr(a1, *(const char **)(v7[0] + v4), *(const char **)(v6 + v4));
v4 += 8LL;
}
while ( v4 != v3 );
}
else
{
printf("list_attr: object %u has %d attributes\n", a1, 0LL);
}
}
pml_free_alist(v7[0], v2);
return pml_free_alist(v6, v2);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
int v1; // eax
unsigned int v2; // er13
__int64 v3; // r12
__int64 v4; // rbx
__int64 v6; // [rsp+0h] [rbp-38h] BYREF
__int64 v7[6]; // [rsp+8h] [rbp-30h] BYREF

v1 = pml_list_attributes(a1, v7, &v6);
v2 = v1;
if ( v1 < 0 )
{
printf("list_attr: error listing attributes of object %u\n", a1);
}
else
{
v3 = 8LL * (unsigned int)v1;
v4 = 0LL;
if ( v1 )
{
do
{
func1(a1, *(const char **)(v7[0] + v4), *(const char **)(v6 + v4));
v4 += 8LL;
}
while ( v4 != v3 );
}
else
{
printf("list_attr: object %u has %d attributes\n", a1, 0LL);
}
}
pml_free_alist(v7[0], v2);
return pml_free_alist(v6, v2);
}

original_code:
int list_attr(pml_obj_t obj) {
    int i, j, nattr;
    char **attrs;
    char **vals;
    if ((nattr = pml_list_attributes(obj, &attrs, &vals)) < 0) {
 printf("list_attr: error listing attributes of object %u\n", obj);
    } else if (nattr == 0) {
 printf("list_attr: object %u has %d attributes\n", obj, nattr);
    }
    for (i = 0; i < nattr; i++) {
 get_attr(obj, attrs[i], vals[i]);
    }
    pml_free_alist(attrs, nattr);
    pml_free_alist(vals, nattr);
}

canonical_original_code:
int list_attr(struct pml_rec_t *obj) {
    int i; int j; int nattr;
    char **attrs;
    char **vals;
    if ((nattr = pml_list_attributes(obj, &attrs, &vals)) < 0) {
 printf("list_attr: error listing attributes of object %u\n", obj);
    } else if (nattr == 0) {
 printf("list_attr: object %u has %d attributes\n", obj, nattr);
    }
    for (i = 0; i < nattr; i++) {
 get_attr(obj, attrs[i], vals[i]);
    }
    pml_free_alist(attrs, nattr);
    pml_free_alist(vals, nattr);
}

variable_types: i int

variable_types: j int

variable_types: nattr int

variable_types:
attrs
char **

variable_types:
vals
char **


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r13
__int64 v4; // r12
int v5; // er14
_QWORD *v6; // rbp
int v7; // ebx
int v8; // er15
_QWORD *v9; // r14
int v10; // ebp
int v11; // er15
_QWORD *v12; // r14
int v13; // ebp
int v14; // er15
_QWORD *v15; // r14
int v16; // ebp
__int64 v18; // [rsp+8h] [rbp-150h]
_QWORD *v19; // [rsp+18h] [rbp-140h] BYREF
char v20[312]; // [rsp+20h] [rbp-138h] BYREF

v19 = 0LL;
if ( (int)pml_open_repository(0LL, 0LL, envp) < 0 )
{
perror("pml_open_repository failed");
exit(1);
}
v3 = pmlstate_create_object();
v4 = pmlstate_create_object();
v18 = pmlstate_create_object();
set_attr(v3, "attr1", "value1.1");
set_attr(v4, "attr1", "value2.1");
set_attr(v18, "attr1", "value3.1");
get_attr(v3, "attr1", "value1.1");
get_attr(v4, "attr1", "value2.1");
get_attr(v18, "attr1", "value3.1");
set_attr(v3, "attr1", "value1.2");
set_attr(v4, "attr1", "value2.2");
set_attr(v18, "attr1", "value3.2");
get_attr(v3, "attr1", "value1.2");
get_attr(v4, "attr1", "value2.2");
get_attr(v18, "attr1", "value3.2");
list_attr(v3);
list_attr(v4);
list_attr(v18);
v5 = pml_query_open(&v19, "attr1", 5LL, 1LL, "value1.1", 8LL);
printf("\nobjects with %s == %s\n", "attr1", "value1.1");
v6 = v19;
if ( v5 > 0 )
{
v7 = 0;
do
{
pml_read_attribute(*v6, "attrib1", 8LL, v20, 256LL);
printf("object %d value = %s\n", (unsigned int)++v7, v20);
++v6;
}
while ( v7 != v5 );
}
pml_query_close(&v19);
v8 = pml_query_open(&v19, "attrib1", 8LL, 2LL, "value2", 7LL);
puts("\nobjects with attrib1 != value2");
v9 = v19;
if ( v8 > 0 )
{
v10 = 0;
do
{
memset(v20, 0, 0x100uLL);
pml_read_attribute(*v9, "attrib1", 8LL, v20, 256LL);
printf("object %d value = %s\n", (unsigned int)++v10, v20);
++v9;
}
while ( v10 != v8 );
}
pml_query_close(&v19);
v11 = pml_query_open(&v19, "attrib1", 8LL, 3LL, "value2", 7LL);
puts("\nobjects with attrib1 > value2");
v12 = v19;
if ( v11 > 0 )
{
v13 = 0;
do
{
memset(v20, 0, 0x100uLL);
pml_read_attribute(*v12, "attrib1", 8LL, v20, 256LL);
printf("object %d value = %s\n", (unsigned int)++v13, v20);
++v12;
}
while ( v13 != v11 );
}
pml_query_close(&v19);
v14 = pml_query_open(&v19, "attrib1", 8LL, 4LL, "value3", 7LL);
puts("\nobjects with attrib1 < value3");
v15 = v19;
if ( v14 > 0 )
{
v16 = 0;
do
{
memset(v20, 0, 0x100uLL);
pml_read_attribute(*v15, "attrib1", 8LL, v20, 256LL);
printf("object %d value = %s\n", (unsigned int)++v16, v20);
++v15;
}
while ( v16 != v14 );
}
pml_query_close(&v19);
pml_delete_object(v3);
pml_delete_object(v4);
pml_delete_object(v18);
pml_pack_objects();
pml_close_repository();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r13
__int64 v4; // r12
int v5; // er14
_QWORD *v6; // rbp
int v7; // ebx
int v8; // er15
_QWORD *v9; // r14
int v10; // ebp
int v11; // er15
_QWORD *v12; // r14
int v13; // ebp
int v14; // er15
_QWORD *v15; // r14
int v16; // ebp
__int64 v18; // [rsp+8h] [rbp-150h]
_QWORD *v19; // [rsp+18h] [rbp-140h] BYREF
char v20[312]; // [rsp+20h] [rbp-138h] BYREF

v19 = 0LL;
if ( (int)pml_open_repository(0LL, 0LL, envp) < 0 )
{
perror("pml_open_repository failed");
exit(1);
}
v3 = pmlstate_create_object();
v4 = pmlstate_create_object();
v18 = pmlstate_create_object();
func0(v3, "attr1", "value1.1");
func0(v4, "attr1", "value2.1");
func0(v18, "attr1", "value3.1");
func1(v3, "attr1", "value1.1");
func1(v4, "attr1", "value2.1");
func1(v18, "attr1", "value3.1");
func0(v3, "attr1", "value1.2");
func0(v4, "attr1", "value2.2");
func0(v18, "attr1", "value3.2");
func1(v3, "attr1", "value1.2");
func1(v4, "attr1", "value2.2");
func1(v18, "attr1", "value3.2");
func2(v3);
func2(v4);
func2(v18);
v5 = pml_query_open(&v19, "attr1", 5LL, 1LL, "value1.1", 8LL);
printf("\nobjects with %s == %s\n", "attr1", "value1.1");
v6 = v19;
if ( v5 > 0 )
{
v7 = 0;
do
{
pml_read_attribute(*v6, "attrib1", 8LL, v20, 256LL);
printf("object %d value = %s\n", (unsigned int)++v7, v20);
++v6;
}
while ( v7 != v5 );
}
pml_query_close(&v19);
v8 = pml_query_open(&v19, "attrib1", 8LL, 2LL, "value2", 7LL);
puts("\nobjects with attrib1 != value2");
v9 = v19;
if ( v8 > 0 )
{
v10 = 0;
do
{
memset(v20, 0, 0x100uLL);
pml_read_attribute(*v9, "attrib1", 8LL, v20, 256LL);
printf("object %d value = %s\n", (unsigned int)++v10, v20);
++v9;
}
while ( v10 != v8 );
}
pml_query_close(&v19);
v11 = pml_query_open(&v19, "attrib1", 8LL, 3LL, "value2", 7LL);
puts("\nobjects with attrib1 > value2");
v12 = v19;
if ( v11 > 0 )
{
v13 = 0;
do
{
memset(v20, 0, 0x100uLL);
pml_read_attribute(*v12, "attrib1", 8LL, v20, 256LL);
printf("object %d value = %s\n", (unsigned int)++v13, v20);
++v12;
}
while ( v13 != v11 );
}
pml_query_close(&v19);
v14 = pml_query_open(&v19, "attrib1", 8LL, 4LL, "value3", 7LL);
puts("\nobjects with attrib1 < value3");
v15 = v19;
if ( v14 > 0 )
{
v16 = 0;
do
{
memset(v20, 0, 0x100uLL);
pml_read_attribute(*v15, "attrib1", 8LL, v20, 256LL);
printf("object %d value = %s\n", (unsigned int)++v16, v20);
++v15;
}
while ( v16 != v14 );
}
pml_query_close(&v19);
pml_delete_object(v3);
pml_delete_object(v4);
pml_delete_object(v18);
pml_pack_objects();
pml_close_repository();
return 0;
}

original_code:
int main(int argc, char *argv[])
{
    int i = 0;
    int nobjs = 0;
    char value[256];
    pml_obj_t objp1 = ((void *)0);
    pml_obj_t objp2 = ((void *)0);
    pml_obj_t objp3 = ((void *)0);
    pml_obj_t *resp = ((void *)0);
    pml_obj_t *atrp = ((void *)0);
    if (pml_open_repository(((void *)0), APPEND) < 0) {
 perror("pml_open_repository failed");
 exit(1);
    }
    objp1 = pmlstate_create_object();
    objp2 = pmlstate_create_object();
    objp3 = pmlstate_create_object();
    set_attr(objp1, "attr1", "value1.1");
    set_attr(objp2, "attr1", "value2.1");
    set_attr(objp3, "attr1", "value3.1");
    get_attr(objp1, "attr1", "value1.1");
    get_attr(objp2, "attr1", "value2.1");
    get_attr(objp3, "attr1", "value3.1");
    set_attr(objp1, "attr1", "value1.2");
    set_attr(objp2, "attr1", "value2.2");
    set_attr(objp3, "attr1", "value3.2");
    get_attr(objp1, "attr1", "value1.2");
    get_attr(objp2, "attr1", "value2.2");
    get_attr(objp3, "attr1", "value3.2");
    list_attr(objp1);
    list_attr(objp2);
    list_attr(objp3);
    nobjs = pml_query_open(&resp, "attr1", strlen("attr1"), 1, "value1.1", strlen("value1.1"));
    printf("\nobjects with %s == %s\n", "attr1", "value1.1");
    for (i = 0, atrp = resp; i < nobjs; i++, atrp++)
 {
     pml_read_attribute(*atrp, "attrib1", 8, value, sizeof(value));
     printf("object %d value = %s\n", i+1, value);
 }
    pml_query_close(&resp);
    nobjs = pml_query_open(&resp, "attrib1", 8, 2, "value2", 7);
    printf("\nobjects with attrib1 != value2\n");
    for (i = 0, atrp = resp; i < nobjs; i++, atrp++)
 {
     memset(value, 0, sizeof(value));
     pml_read_attribute(*atrp, "attrib1", 8, value, sizeof(value));
     printf("object %d value = %s\n", i+1, value);
 }
    pml_query_close(&resp);
    nobjs = pml_query_open(&resp, "attrib1", 8, 3, "value2", 7);
    printf("\nobjects with attrib1 > value2\n");
    for (i = 0, atrp = resp; i < nobjs; i++, atrp++)
 {
     memset(value, 0, sizeof(value));
     pml_read_attribute(*atrp, "attrib1", 8, value, sizeof(value));
     printf("object %d value = %s\n", i+1, value);
 }
    pml_query_close(&resp);
    nobjs = pml_query_open(&resp, "attrib1", 8, 4, "value3", 7);
    printf("\nobjects with attrib1 < value3\n");
    for (i = 0, atrp = resp; i < nobjs; i++, atrp++)
 {
     memset(value, 0, sizeof(value));
     pml_read_attribute(*atrp, "attrib1", 8, value, sizeof(value));
     printf("object %d value = %s\n", i+1, value);
 }
    pml_query_close(&resp);
    pml_delete_object(objp1);
    pml_delete_object(objp2);
    pml_delete_object(objp3);
    pml_pack_objects();
    pml_close_repository();
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    int i = 0;
    int nobjs = 0;
    char value[256];
    struct pml_rec_t *objp1 = ((void *)0);
    struct pml_rec_t *objp2 = ((void *)0);
    struct pml_rec_t *objp3 = ((void *)0);
    struct pml_rec_t **resp = ((void *)0);
    struct pml_rec_t **atrp = ((void *)0);
    if (pml_open_repository(((void *)0), APPEND) < 0) {
 perror("pml_open_repository failed");
 exit(1);
    }
    objp1 = pmlstate_create_object();
    objp2 = pmlstate_create_object();
    objp3 = pmlstate_create_object();
    set_attr(objp1, "attr1", "value1.1");
    set_attr(objp2, "attr1", "value2.1");
    set_attr(objp3, "attr1", "value3.1");
    get_attr(objp1, "attr1", "value1.1");
    get_attr(objp2, "attr1", "value2.1");
    get_attr(objp3, "attr1", "value3.1");
    set_attr(objp1, "attr1", "value1.2");
    set_attr(objp2, "attr1", "value2.2");
    set_attr(objp3, "attr1", "value3.2");
    get_attr(objp1, "attr1", "value1.2");
    get_attr(objp2, "attr1", "value2.2");
    get_attr(objp3, "attr1", "value3.2");
    list_attr(objp1);
    list_attr(objp2);
    list_attr(objp3);
    nobjs = pml_query_open(&resp, "attr1", strlen("attr1"), 1, "value1.1", strlen("value1.1"));
    printf("\nobjects with %s == %s\n", "attr1", "value1.1");
    for (i = 0, atrp = resp; i < nobjs; i++, atrp++)
 {
     pml_read_attribute(*atrp, "attrib1", 8, value, sizeof(value));
     printf("object %d value = %s\n", i+1, value);
 }
    pml_query_close(&resp);
    nobjs = pml_query_open(&resp, "attrib1", 8, 2, "value2", 7);
    printf("\nobjects with attrib1 != value2\n");
    for (i = 0, atrp = resp; i < nobjs; i++, atrp++)
 {
     memset(value, 0, sizeof(value));
     pml_read_attribute(*atrp, "attrib1", 8, value, sizeof(value));
     printf("object %d value = %s\n", i+1, value);
 }
    pml_query_close(&resp);
    nobjs = pml_query_open(&resp, "attrib1", 8, 3, "value2", 7);
    printf("\nobjects with attrib1 > value2\n");
    for (i = 0, atrp = resp; i < nobjs; i++, atrp++)
 {
     memset(value, 0, sizeof(value));
     pml_read_attribute(*atrp, "attrib1", 8, value, sizeof(value));
     printf("object %d value = %s\n", i+1, value);
 }
    pml_query_close(&resp);
    nobjs = pml_query_open(&resp, "attrib1", 8, 4, "value3", 7);
    printf("\nobjects with attrib1 < value3\n");
    for (i = 0, atrp = resp; i < nobjs; i++, atrp++)
 {
     memset(value, 0, sizeof(value));
     pml_read_attribute(*atrp, "attrib1", 8, value, sizeof(value));
     printf("object %d value = %s\n", i+1, value);
 }
    pml_query_close(&resp);
    pml_delete_object(objp1);
    pml_delete_object(objp2);
    pml_delete_object(objp3);
    pml_pack_objects();
    pml_close_repository();
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: nobjs int

variable_types: struct pml_rec_t { int deleted; unsigned int natr; long aofs[1024]; unsigned long alen[1024]; unsigned int nval; long vofs[1024]; unsigned long vlen[1024]; } **


UnixfsRead

decompiled_code:
__int64 __fastcall UnixfsRead(__int64 a1, const char *a2, __int64 a3, char **a4)
{
const char *v5; // rdi

if ( !strcmp(a2, "name") )
{
v5 = **(const char ***)(a1 + 16);
}
else if ( !strcmp(a2, "date") )
{
v5 = *(const char **)(*(_QWORD *)(a1 + 16) + 16LL);
}
else
{
v5 = 0LL;
if ( !strcmp(a2, "size") )
v5 = *(const char **)(*(_QWORD *)(a1 + 16) + 8LL);
}
*a4 = strdup(v5);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, const char *a2, __int64 a3, char **a4)
{
const char *v5; // rdi

if ( !strcmp(a2, "name") )
{
v5 = **(const char ***)(a1 + 16);
}
else if ( !strcmp(a2, "date") )
{
v5 = *(const char **)(*(_QWORD *)(a1 + 16) + 16LL);
}
else
{
v5 = 0LL;
if ( !strcmp(a2, "size") )
v5 = *(const char **)(*(_QWORD *)(a1 + 16) + 8LL);
}
*a4 = strdup(v5);
return 0LL;
}

original_code:
int UnixfsRead(void* objptr, void* attrib, size_t UnusedDummy1, void* val, size_t UnusedDummy2)
{
  repository_object* obj = (repository_object*) objptr;
                char* attribute = (char*) attrib;
                char** value = (char**) val;
  int attr;
  char* cmp_str;
  unixfs_object* u_obj;
  attr = -1;
  if (strcmp(attribute,"name") == 0)
    attr = 1;
  else if (strcmp(attribute,"date") == 0)
    attr = 2;
  else if (strcmp(attribute,"size") == 0)
    attr = 3;
  switch (attr)
  {
    case 1:
     cmp_str = ((unixfs_object *)obj->object)->name;
     break;
    case 2:
     cmp_str = ((unixfs_object *)obj->object)->date;
     break;
    case 3:
     cmp_str = ((unixfs_object *)obj->object)->size;
     break;
    default:
     cmp_str = ((void *)0);
     break;
  }
  *value = strdup(cmp_str);
  return (int)0;
}

canonical_original_code:
int UnixfsRead(void *objptr, void *attrib, unsigned long UnusedDummy1, void *val, unsigned long UnusedDummy2)
{
  struct repository_object *obj = (repository_object*) objptr;
                char *attribute = (char*) attrib;
                char **value = (char**) val;
  int attr;
  char *cmp_str;
  struct unixfs_object *u_obj;
  attr = -1;
  if (strcmp(attribute,"name") == 0)
    attr = 1;
  else if (strcmp(attribute,"date") == 0)
    attr = 2;
  else if (strcmp(attribute,"size") == 0)
    attr = 3;
  switch (attr)
  {
    case 1:
     cmp_str = ((struct unixfs_object *)obj->object)->name;
     break;
    case 2:
     cmp_str = ((struct unixfs_object *)obj->object)->date;
     break;
    case 3:
     cmp_str = ((struct unixfs_object *)obj->object)->size;
     break;
    default:
     cmp_str = ((void *)0);
     break;
  }
  *value = strdup(cmp_str);
  return (int)0;
}

variable_types:
objptr
void *

variable_types:
attrib
void *

variable_types:
val
void *

variable_types: struct repository_object { int type; char *id; void *object; } *

variable_types:
attribute
char *

variable_types:
value
char **

variable_types: attr int

variable_types: struct unixfs_object { char *name; char *size; char *date; } *


UnixfsInit

decompiled_code:
__int64 UnixfsInit()
{
_QWORD *v1; // rax

repository_initexternal(
"UNIXFS",
0LL,
UnixfsOpen,
0LL,
UnixfsClose,
0LL,
0LL,
0LL,
UnixfsRead,
0LL,
0LL,
UnixfsQueryOpen,
UnixfsAssert,
0LL);
if ( !RepListHead )
{
v1 = malloc(0x10uLL);
RepListHead = (__int64)v1;
*v1 = 0LL;
v1[1] = 0LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 func5()
{
_QWORD *v1; // rax

repository_initexternal(
"UNIXFS",
0LL,
UnixfsOpen,
0LL,
UnixfsClose,
0LL,
0LL,
0LL,
UnixfsRead,
0LL,
0LL,
UnixfsQueryOpen,
UnixfsAssert,
0LL);
if ( !RepListHead )
{
v1 = malloc(0x10uLL);
RepListHead = (__int64)v1;
*v1 = 0LL;
v1[1] = 0LL;
}
return 0LL;
}

original_code:
int UnixfsInit()
{
  repository_initexternal("UNIXFS",
        ((void *)0),
                                                                UnixfsOpen,
        ((void *)0),
        UnixfsClose,
        ((void *)0), ((void *)0), ((void *)0),
        UnixfsRead,
        ((void *)0), ((void *)0),
        UnixfsQueryOpen,
        UnixfsAssert,
        ((void *)0));
  if (RepListHead == ((void *)0))
  {
   RepListHead = malloc(sizeof(RepListNode));
   RepListHead->data = ((void *)0);
   RepListHead->link = ((void *)0);
  }
  return (int)0;
}


decompiled_code:
_QWORD *create_rcptlist()
{
_QWORD *result; // rax

result = malloc(0x18uLL);
*result = 0LL;
result[2] = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func2()
{
_QWORD *result; // rax

result = malloc(0x18uLL);
*result = 0LL;
result[2] = 0LL;
return result;
}

original_code:
recipient *create_rcptlist()
{
recipient *head;
 head = (recipient *)malloc(sizeof(recipient));
 head->address = ((void *)0);
 head->next = ((void *)0);
 return(head);
}

canonical_original_code:
struct recipient *create_rcptlist()
{
struct recipient *head;
 head = (struct recipient *)malloc(sizeof(recipient));
 head->address = ((void *)0);
 head->next = ((void *)0);
 return(head);
}

variable_types: struct recipient { char *address; int status; struct recipient *next; } *


decompiled_code:
void __fastcall clear_rcptlist(void *ptr)
{
void **v1; // rbx
void **v2; // rbp

v1 = (void **)ptr;
if ( ptr )
{
do
{
v2 = v1;
v1 = (void **)v1[2];
free(*v2);
free(v2);
}
while ( v1 );
}
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
void **v1; // rbx
void **v2; // rbp

v1 = (void **)ptr;
if ( ptr )
{
do
{
v2 = v1;
v1 = (void **)v1[2];
free(*v2);
free(v2);
}
while ( v1 );
}
}

original_code:
void clear_rcptlist(recipient *head)
{
recipient *tail = head;
 while (tail != ((void *)0)) {
  tail = (recipient *)tail->next;
  free(head->address);
  free(head);
  head = tail;
 }
}

canonical_original_code:
void clear_rcptlist(struct recipient *head)
{
struct recipient *tail = head;
 while (tail != ((void *)0)) {
  tail = (struct recipient *)tail->next;
  free(head->address);
  free(head);
  head = tail;
 }
}

user_defined_types: struct recipient { char *address; int status; struct recipient *next; }


displayrec

decompiled_code:
int __fastcall displayrec(__int64 a1)
{
__int64 i; // rbx
int result; // eax

for ( i = a1; i; i = *(_QWORD *)(i + 16) )
{
if ( *(_QWORD *)i )
result = printf("%d, %s\n", *(unsigned int *)(i + 8), *(const char **)i);
}
return result;
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1)
{
__int64 i; // rbx
int result; // eax

for ( i = a1; i; i = *(_QWORD *)(i + 16) )
{
if ( *(_QWORD *)i )
result = printf("%d, %s\n", *(unsigned int *)(i + 8), *(const char **)i);
}
return result;
}

original_code:
void displayrec(recipient *head)
{
recipient *tail = head;
 while (tail != ((void *)0)) {
  if (tail->address != ((void *)0)) {
   printf("%d, %s\n",tail->status,tail->address);
  }
  tail = (recipient *)tail->next;
 }
}

canonical_original_code:
void displayrec(struct recipient *head)
{
struct recipient *tail = head;
 while (tail != ((void *)0)) {
  if (tail->address != ((void *)0)) {
   printf("%d, %s\n",tail->status,tail->address);
  }
  tail = (struct recipient *)tail->next;
 }
}


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

switch ( a1 )
{
case 258:
result = "action";
break;
case 260:
result = "branch";
break;
case 264:
result = "iter";
break;
case 267:
result = "process";
break;
case 271:
result = "select";
break;
case 272:
result = "sequence";
break;
case 288:
result = "join";
break;
case 289:
result = "rend";
break;
default:
result = "unknown";
break;
}
return result;
}

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

switch ( a1 )
{
case 258:
result = "action";
break;
case 260:
result = "branch";
break;
case 264:
result = "iter";
break;
case 267:
result = "process";
break;
case 271:
result = "select";
break;
case 272:
result = "sequence";
break;
case 288:
result = "join";
break;
case 289:
result = "rend";
break;
default:
result = "unknown";
break;
}
return result;
}

original_code:
char *node_type(int type)
{
    switch (type) {
    case (258): return "action"; break;
    case (260): return "branch"; break;
    case (264): return "iter"; break;
    case (271): return "select"; break;
    case (272): return "sequence"; break;
    case (267): return "process"; break;
    case (288): return "join"; break;
    case (289): return "rend"; break;
    default: return "unknown"; break;
    }
}

variable_types: type int


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

switch ( a1 )
{
case 258:
result = "box, style=rounded";
break;
case 260:
result = "circle, fixedsize = true, style=filled";
break;
case 264:
case 271:
case 288:
result = "diamond, style=filled";
break;
case 267:
result = "plain";
break;
case 289:
result = "circle, fixedsize = true, style=filled";
break;
default:
v2 = node_type(a1);
fprintf(stderr, "Help! %s is unknown!\n", v2);
result = "plaintext";
break;
}
return result;
}

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

switch ( a1 )
{
case 258:
result = "box, style=rounded";
break;
case 260:
result = "circle, fixedsize = true, style=filled";
break;
case 264:
case 271:
case 288:
result = "diamond, style=filled";
break;
case 267:
result = "plain";
break;
case 289:
result = "circle, fixedsize = true, style=filled";
break;
default:
v2 = func0(a1);
fprintf(stderr, "Help! %s is unknown!\n", v2);
result = "plaintext";
break;
}
return result;
}

original_code:
char *node_shape(int type)
{
    switch (type) {
    case (258): return "box, style=rounded"; break;
    case (264): return "diamond, style=filled"; break;
    case (271): return "diamond, style=filled"; break;
    case (288): return "diamond, style=filled"; break;
    case (260): return "circle, fixedsize = true, style=filled"; break;
    case (289): return "circle, fixedsize = true, style=filled"; break;
    case (267): return "plain"; break;
    default: fprintf(stderr, "Help! %s is unknown!\n", node_type(type)); return "plaintext"; break;
    }
}


decompiled_code:
int __fastcall print_resources(__int64 *a1)
{
int v2; // edi
const char *v3; // rax
size_t v4; // rax
const char *v5; // rsi
_BYTE *v6; // rbp
__int64 v7; // r12
const char *v8; // rax

if ( !a1 )
{
LODWORD(v4) = printf("[]");
return v4;
}
if ( *a1 || a1[1] )
{
((void (*)(void))print_resources)();
if ( *a1 )
{
if ( *((_DWORD *)a1 + 6) != 283 )
{
LABEL_5:
v2 = *((_DWORD *)a1 + 6);
LABEL_6:
v3 = op_to_string(v2);
printf(" %s ", v3);
LABEL_7:
LODWORD(v4) = print_resources(a1[1]);
return v4;
}
}
else
{
v2 = 0;
if ( !a1[1] )
goto LABEL_6;
if ( *((_DWORD *)a1 + 6) != 283 )
{
if ( !a1[1] )
{
v2 = 0;
goto LABEL_6;
}
goto LABEL_5;
}
}
v8 = op_to_string(283);
printf("%s", v8);
goto LABEL_7;
}
v5 = (const char *)a1[2];
v6 = (_BYTE *)(node_type + 1);
if ( *v5 == 34 )
{
while ( 1 )
{
v7 = *a1;
if ( *a1 )
{
v4 = strlen(0LL);
if ( v4 <= (unsigned __int64)v6 || *v6 == 34 )
return v4;
v7 = 0LL;
}
else
{
if ( a1[1] )
{
v4 = strlen(0LL);
if ( (unsigned __int64)v6 >= v4 )
return v4;
if ( a1[1] )
{
if ( *v6 == 34 )
return v4;
goto LABEL_16;
}
}
else
{
v4 = strlen((const char *)a1[2]);
if ( (unsigned __int64)v6 >= v4 )
return v4;
}
v4 = a1[2];
if ( v6[v4] == 34 )
return v4;
v7 = a1[2];
}
LABEL_16:
putchar((char)(v6++)[v7]);
}
}
LODWORD(v4) = printf("%s", v5);
return v4;
}

canonical_decompiled_code:
int __fastcall func4(__int64 *a1)
{
int v2; // edi
const char *v3; // rax
size_t v4; // rax
const char *v5; // rsi
_BYTE *v6; // rbp
__int64 v7; // r12
const char *v8; // rax

if ( !a1 )
{
LODWORD(v4) = printf("[]");
return v4;
}
if ( *a1 || a1[1] )
{
((void (*)(void))print_resources)();
if ( *a1 )
{
if ( *((_DWORD *)a1 + 6) != 283 )
{
LABEL_5:
v2 = *((_DWORD *)a1 + 6);
LABEL_6:
v3 = func2(v2);
printf(" %s ", v3);
LABEL_7:
LODWORD(v4) = func4(a1[1]);
return v4;
}
}
else
{
v2 = 0;
if ( !a1[1] )
goto LABEL_6;
if ( *((_DWORD *)a1 + 6) != 283 )
{
if ( !a1[1] )
{
v2 = 0;
goto LABEL_6;
}
goto LABEL_5;
}
}
v8 = func2(283);
printf("%s", v8);
goto LABEL_7;
}
v5 = (const char *)a1[2];
v6 = (_BYTE *)(node_type + 1);
if ( *v5 == 34 )
{
while ( 1 )
{
v7 = *a1;
if ( *a1 )
{
v4 = strlen(0LL);
if ( v4 <= (unsigned __int64)v6 || *v6 == 34 )
return v4;
v7 = 0LL;
}
else
{
if ( a1[1] )
{
v4 = strlen(0LL);
if ( (unsigned __int64)v6 >= v4 )
return v4;
if ( a1[1] )
{
if ( *v6 == 34 )
return v4;
goto LABEL_16;
}
}
else
{
v4 = strlen((const char *)a1[2]);
if ( (unsigned __int64)v6 >= v4 )
return v4;
}
v4 = a1[2];
if ( v6[v4] == 34 )
return v4;
v7 = a1[2];
}
LABEL_16:
putchar((char)(v6++)[v7]);
}
}
LODWORD(v4) = printf("%s", v5);
return v4;
}

variable_types: struct tree { struct tree *left; struct tree *right; char *sval; int ival; } *

variable_types: i int


decompiled_code:
void poll_vr()
{
_QWORD *v0; // rbx
__int64 v1; // rbp
__int64 v2; // rax
int v3; // edx
__int64 v4; // rax
__int64 v5; // rdi

v0 = (_QWORD *)myQueries;
if ( myQueries )
{
if ( repos_ctr <= 0 )
goto LABEL_6;
v1 = 0LL;
do
{
v2 = ((__int64 (__fastcall *)(__int64))repos_list[2 * v1])(myQueries);
v0 = (_QWORD *)v2;
myQueries = v2;
++v1;
}
while ( repos_ctr > (int)v1 );
if ( v2 )
{
LABEL_6:
v3 = 0;
do
{
v4 = *v0;
v5 = *(unsigned int *)(*v0 + 16LL);
if ( (_DWORD)v5 )
{
(*(void (__fastcall **)(__int64, _QWORD, _QWORD))(v4 + 352))(v5, *(_QWORD *)(v4 + 344), *(_QWORD *)(v4 + 8));
*(_DWORD *)*v0 = 1;
v3 = 1;
}
else if ( *(_DWORD *)v4 )
{
v3 = 1;
}
v0 = (_QWORD *)v0[1];
}
while ( v0 );
if ( v3 )
myQueries = filterQueryList(myQueries);
}
}
}

canonical_decompiled_code:
void func0()
{
_QWORD *v0; // rbx
__int64 v1; // rbp
__int64 v2; // rax
int v3; // edx
__int64 v4; // rax
__int64 v5; // rdi

v0 = (_QWORD *)myQueries;
if ( myQueries )
{
if ( repos_ctr <= 0 )
goto LABEL_6;
v1 = 0LL;
do
{
v2 = ((__int64 (__fastcall *)(__int64))repos_list[2 * v1])(myQueries);
v0 = (_QWORD *)v2;
myQueries = v2;
++v1;
}
while ( repos_ctr > (int)v1 );
if ( v2 )
{
LABEL_6:
v3 = 0;
do
{
v4 = *v0;
v5 = *(unsigned int *)(*v0 + 16LL);
if ( (_DWORD)v5 )
{
(*(void (__fastcall **)(__int64, _QWORD, _QWORD))(v4 + 352))(v5, *(_QWORD *)(v4 + 344), *(_QWORD *)(v4 + 8));
*(_DWORD *)*v0 = 1;
v3 = 1;
}
else if ( *(_DWORD *)v4 )
{
v3 = 1;
}
v0 = (_QWORD *)v0[1];
}
while ( v0 );
if ( v3 )
myQueries = filterQueryList(myQueries);
}
}
}

original_code:
void poll_vr( )
{
 queryList *tempQueries ;
 int tag = 0 ;
 int i ;
 if( myQueries != ((void *)0) )
 {
  for( i = 0 ; i < repos_ctr ; i++ )
   myQueries = repos_list[i].queryTool( myQueries ) ;
  tempQueries = myQueries ;
  while( tempQueries != ((void *)0) )
  {
   if( tempQueries -> oneQuery -> numFound )
   {
    tag = 1 ;
    tempQueries -> oneQuery -> callback( tempQueries -> oneQuery -> numFound,
                    tempQueries -> oneQuery -> results,
                    tempQueries -> oneQuery -> data ) ;
    tempQueries -> oneQuery -> removeTag = 1 ;
   }
   else if( tempQueries -> oneQuery -> removeTag )
    tag = 1 ;
   tempQueries = ( queryList* ) tempQueries -> link ;
  }
  if ( tag )
   myQueries = filterQueryList( myQueries ) ;
 }
}

canonical_original_code:
void poll_vr()
{
 struct queryList *tempQueries;
 int tag = 0;
 int i;
 if( myQueries != ((void *)0) )
 {
  for( i = 0 ; i < repos_ctr ; i++ )
   myQueries = repos_list[i].queryTool( myQueries ) ;
  tempQueries = myQueries ;
  while( tempQueries != ((void *)0) )
  {
   if( tempQueries -> oneQuery -> numFound )
   {
    tag = 1 ;
    tempQueries -> oneQuery -> callback( tempQueries -> oneQuery -> numFound,
                    tempQueries -> oneQuery -> results,
                    tempQueries -> oneQuery -> data ) ;
    tempQueries -> oneQuery -> removeTag = 1 ;
   }
   else if( tempQueries -> oneQuery -> removeTag )
    tag = 1 ;
   tempQueries = ( struct queryList * ) tempQueries -> link ;
  }
  if ( tag )
   myQueries = filterQueryList( myQueries ) ;
 }
}

variable_types: struct queryList { struct query { int removeTag; int numClauses; int *data; int numFound; struct clause { char *attribute; char *operator; char *value; char *conjecture; } myClauses[10]; struct resultList { char *oneResult; struct resultList *link; } *results; void (*callback)(int, struct resultList *, void *data); } *oneQuery; struct queryList *link; } *

variable_types: tag int

user_defined_types: struct queryList { struct query *oneQuery; struct queryList *link; }

user_defined_types: struct query { int removeTag; int numClauses; int *data; int numFound; struct clause myClauses[10]; struct resultList *results; void (*callback)(int, struct resultList *, void *data); }


isValidAttribute

decompiled_code:
__int64 __fastcall isValidAttribute(char *s2)
{
char *v1; // rbx
__int64 v3[3]; // [rsp+0h] [rbp-38h] BYREF
char v4; // [rsp+18h] [rbp-20h] BYREF

v3[0] = (__int64)&unk_800;
v3[1] = (__int64)"DATE";
v3[2] = (__int64)"NAME";
if ( !s2 )
return 0LL;
v1 = (char *)v3;
while ( strcmp(*(const char **)v1, s2) )
{
v1 += 8;
if ( v1 == &v4 )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *s2)
{
char *v1; // rbx
__int64 v3[3]; // [rsp+0h] [rbp-38h] BYREF
char v4; // [rsp+18h] [rbp-20h] BYREF

v3[0] = (__int64)&unk_800;
v3[1] = (__int64)"DATE";
v3[2] = (__int64)"NAME";
if ( !s2 )
return 0LL;
v1 = (char *)v3;
while ( strcmp(*(const char **)v1, s2) )
{
v1 += 8;
if ( v1 == &v4 )
return 0LL;
}
return 1LL;
}

original_code:
_Bool isValidAttribute( char *attr )
{
 int i ;
 char *attributes[3] = { "ID","DATE", "NAME" } ;
 if( attr == ((void *)0) )
  return 0;
 for( i = 0 ; i < 3 ; i++ )
 {
  if( ( strcmp( attributes[i], attr ) == 0 ) )
   return 1 ;
 }
 return 0 ;
}

canonical_original_code:
_Bool isValidAttribute(char *attr)
{
 int i;
 char *attributes[3] = { "ID","DATE", "NAME" };
 if( attr == ((void *)0) )
  return 0;
 for( i = 0 ; i < 3 ; i++ )
 {
  if( ( strcmp( attributes[i], attr ) == 0 ) )
   return 1 ;
 }
 return 0 ;
}

variable_types:
attr
char *

variable_types:
attributes
char *[3]


isValidValue

decompiled_code:
bool __fastcall isValidValue(__int64 a1)
{
return a1 != 0;
}

canonical_decompiled_code:
bool __fastcall func3(__int64 a1)
{
return a1 != 0;
}

original_code:
_Bool isValidValue( char *val )
{
 if ( val == ((void *)0) )
  return 0 ;
 return 1 ;
}

canonical_original_code:
_Bool isValidValue(char *val)
{
 if ( val == ((void *)0) )
  return 0 ;
 return 1 ;
}

variable_types:
val
char *


isValidConjecture

decompiled_code:
bool __fastcall isValidConjecture(const char *a1)
{
if ( !a1 )
return 0;
if ( !strcmp("AND", a1) )
return 1;
return strcmp("OR", a1) == 0;
}

canonical_decompiled_code:
bool __fastcall func4(const char *a1)
{
if ( !a1 )
return 0;
if ( !strcmp("AND", a1) )
return 1;
return strcmp("OR", a1) == 0;
}

original_code:
_Bool isValidConjecture( char *con )
{
 int i ;
 char *conjecture[2] = { "AND","OR" } ;
 if( con == ((void *)0) )
  return 0;
 for( i = 0 ; i < 2; i++ )
 {
  if( ( strcmp( conjecture[i], con ) == 0 ) )
   return 1 ;
 }
 return 0 ;
}

canonical_original_code:
_Bool isValidConjecture(char *con)
{
 int i;
 char *conjecture[2] = { "AND","OR" };
 if( con == ((void *)0) )
  return 0;
 for( i = 0 ; i < 2; i++ )
 {
  if( ( strcmp( conjecture[i], con ) == 0 ) )
   return 1 ;
 }
 return 0 ;
}

variable_types:
con
char *

variable_types:
conjecture
char *[2]


timeStampValidator

original_code:
int timeStampValidator( char *timeStamp )
{
 if( ( timeStamp + 2 )[0] == '/' &&
     ( timeStamp + 5 )[0] == '/' &&
     ( timeStamp + 10)[0] == '-' &&
     ( timeStamp + 13)[0] == ':' &&
     ( timeStamp + 16)[0] == ':' &&
     ( timeStamp + 19)[0] == '\0')
  return 1 ;
 else
  return 0 ;
}

canonical_original_code:
int timeStampValidator(char *timeStamp)
{
 if( ( timeStamp + 2 )[0] == '/' &&
     ( timeStamp + 5 )[0] == '/' &&
     ( timeStamp + 10)[0] == '-' &&
     ( timeStamp + 13)[0] == ':' &&
     ( timeStamp + 16)[0] == ':' &&
     ( timeStamp + 19)[0] == '\0')
  return 1 ;
 else
  return 0 ;
}

variable_types:
timeStamp
char *


isValidQuery

decompiled_code:
__int64 __fastcall isValidQuery(__int64 a1, int a2)
{
const char **v3; // rbx
unsigned int v4; // er8
int i; // ebp
const char *v6; // rsi
unsigned int v7; // eax
__int64 v8; // rdx
__int64 v9; // rcx
__int64 v11[2]; // [rsp+0h] [rbp-408h] BYREF
char v12[984]; // [rsp+10h] [rbp-3F8h] BYREF

v11[0] = 0LL;
v11[1] = 0LL;
memset(v12, 0, sizeof(v12));
if ( a2 < 0 )
return 1;
v3 = (const char **)(a1 + 40);
v4 = 1;
for ( i = 0; i <= a2; ++i )
{
if ( !strcmp("ID", *(v3 - 2)) )
{
v6 = *v3;
strcpy((char *)v11, *v3);
if ( (unsigned int)isFileQuery(v11) )
{
v4 = FSqueryValidator(v11);
}
else
{
v7 = isEMAILQuery(v11);
v4 = v7;
if ( v7 )
v4 = EMAILqueryValidator(v11, v6, v8, v9, v7);
}
}
else if ( !strcmp("DATE", *(v3 - 2)) )
{
v4 = timeStampValidator(*v3);
}
v3 += 4;
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, int a2)
{
const char **v3; // rbx
unsigned int v4; // er8
int i; // ebp
const char *v6; // rsi
unsigned int v7; // eax
__int64 v8; // rdx
__int64 v9; // rcx
__int64 v11[2]; // [rsp+0h] [rbp-408h] BYREF
char v12[984]; // [rsp+10h] [rbp-3F8h] BYREF

v11[0] = 0LL;
v11[1] = 0LL;
memset(v12, 0, sizeof(v12));
if ( a2 < 0 )
return 1;
v3 = (const char **)(a1 + 40);
v4 = 1;
for ( i = 0; i <= a2; ++i )
{
if ( !strcmp("ID", *(v3 - 2)) )
{
v6 = *v3;
strcpy((char *)v11, *v3);
if ( (unsigned int)isFileQuery(v11) )
{
v4 = FSqueryValidator(v11);
}
else
{
v7 = isEMAILQuery(v11);
v4 = v7;
if ( v7 )
v4 = EMAILqueryValidator(v11, v6, v8, v9, v7);
}
}
else if ( !strcmp("DATE", *(v3 - 2)) )
{
v4 = func5(*v3);
}
v3 += 4;
}
return v4;
}

original_code:
int isValidQuery( query *theQuery, int numClauses )
{
 int timeStampValidator( char * ) ;
 char testValue[1000] = { '\0' } ;
 int i ;
 int validResult = 1 ;
 for( i = 0 ; i <= numClauses ; i++ )
 {
  if( strcmp( "ID", theQuery -> myClauses[i].attribute ) == 0 )
  {
   strcpy ( testValue ,theQuery -> myClauses[i].value ) ;
   if( isFileQuery( testValue ) )
    validResult = FSqueryValidator( testValue ) ;
   else if( isEMAILQuery( testValue ) )
    validResult = EMAILqueryValidator( testValue ) ;
   else
    validResult = 0 ;
  }
  else if( strcmp( "DATE", theQuery -> myClauses[i].attribute ) == 0 )
   validResult = timeStampValidator( theQuery -> myClauses[i].value ) ;
 }
 return validResult ;
}

canonical_original_code:
int isValidQuery(struct query *theQuery, int numClauses)
{
 int timeStampValidator(char *);
 char testValue[1000] = { '\0' };
 int i;
 int validResult = 1;
 for( i = 0 ; i <= numClauses ; i++ )
 {
  if( strcmp( "ID", theQuery -> myClauses[i].attribute ) == 0 )
  {
   strcpy ( testValue ,theQuery -> myClauses[i].value ) ;
   if( isFileQuery( testValue ) )
    validResult = FSqueryValidator( testValue ) ;
   else if( isEMAILQuery( testValue ) )
    validResult = EMAILqueryValidator( testValue ) ;
   else
    validResult = 0 ;
  }
  else if( strcmp( "DATE", theQuery -> myClauses[i].attribute ) == 0 )
   validResult = timeStampValidator( theQuery -> myClauses[i].value ) ;
 }
 return validResult ;
}

variable_types: struct query { int removeTag; int numClauses; int *data; int numFound; struct clause { char *attribute; char *operator; char *value; char *conjecture; } myClauses[10]; struct resultList { char *oneResult; struct resultList *link; } *results; void (*callback)(int, struct resultList *, void *data); } *

variable_types: numClauses int

variable_types:
timeStampValidator
int (char *)

variable_types:
testValue
char [1000]

variable_types: validResult int