GetVariableDefinition

decompiled_code:
__int64 __fastcall GetVariableDefinition(__int64 a1, __int64 a2, _DWORD *a3, int a4, __int16 *a5)
{
__int16 v7; // ax
unsigned int v8; // er12
__int64 v10; // r15
__int64 v11; // r12
__int64 v12; // rax
__int64 v13; // r13
_BYTE v14[104]; // [rsp+0h] [rbp-68h] BYREF

if ( !a4 )
GetToken(a1, a2, a5);
v7 = *a5;
v8 = 0;
if ( *a5 != 171 )
{
if ( v7 == 35 )
goto LABEL_8;
if ( v7 != 33 )
{
SyntaxErrorMessage(a1, "defglobal");
*a3 = 1;
return 0;
}
v10 = *((_QWORD *)a5 + 1);
SavePPBuffer(a1, " ");
if ( (unsigned int)EnvGetWatchItem(a1, "compilations") == 1 && (unsigned int)GetPrintWhileLoading(a1) )
{
if ( QFindDefglobal(a1, v10) )
{
PrintWarningID(a1, "CSTRCPSR", 1LL, 1LL);
EnvPrintRouter(a1, "wdialog", "Redefining defglobal: ");
}
else
{
EnvPrintRouter(a1, "wdialog", "Defining defglobal: ");
}
EnvPrintRouter(a1, "wdialog", *(_QWORD *)(v10 + 24));
EnvPrintRouter(a1, "wdialog", &LC0);
}
else if ( (unsigned int)GetPrintWhileLoading(a1) )
{
EnvPrintRouter(a1, "wdialog", ":");
}
v11 = *(_QWORD *)(v10 + 24);
v12 = EnvGetCurrentModule(a1);
v8 = FindImportExportConflict(a1, "defglobal", v12, v11);
if ( v8 )
{
ImportExportConflictMessage(a1, "defglobal", *(_QWORD *)(v10 + 24), 0LL, 0LL);
*a3 = 1;
return 0;
}
GetToken(a1, a2, a5);
if ( strcmp(*((const char **)a5 + 2), "=") )
{
LABEL_8:
SyntaxErrorMessage(a1, "defglobal");
*a3 = 1;
return v8;
}
SavePPBuffer(a1, " ");
v13 = ParseAtomOrExpression(a1, a2, 0LL);
if ( !v13 )
{
*a3 = 1;
return 0;
}
v8 = *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 336LL) + 80LL);
if ( v8 )
{
ReturnExpression(a1, v13);
}
else
{
SetEvaluationError(a1, 0LL);
if ( (unsigned int)EvaluateExpression(a1, v13, v14) )
{
ReturnExpression(a1, v13);
*a3 = 1;
return v8;
}
}
SavePPBuffer(a1, ")");
v8 = 1;
if ( !*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 336LL) + 80LL) )
AddDefglobal(a1, v10, (__int64)v14, v13);
}
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, _DWORD *a3, int a4, __int16 *a5)
{
__int16 v7; // ax
unsigned int v8; // er12
__int64 v10; // r15
__int64 v11; // r12
__int64 v12; // rax
__int64 v13; // r13
_BYTE v14[104]; // [rsp+0h] [rbp-68h] BYREF

if ( !a4 )
GetToken(a1, a2, a5);
v7 = *a5;
v8 = 0;
if ( *a5 != 171 )
{
if ( v7 == 35 )
goto LABEL_8;
if ( v7 != 33 )
{
SyntaxErrorMessage(a1, "defglobal");
*a3 = 1;
return 0;
}
v10 = *((_QWORD *)a5 + 1);
SavePPBuffer(a1, " ");
if ( (unsigned int)EnvGetWatchItem(a1, "compilations") == 1 && (unsigned int)GetPrintWhileLoading(a1) )
{
if ( QFindDefglobal(a1, v10) )
{
PrintWarningID(a1, "CSTRCPSR", 1LL, 1LL);
EnvPrintRouter(a1, "wdialog", "Redefining defglobal: ");
}
else
{
EnvPrintRouter(a1, "wdialog", "Defining defglobal: ");
}
EnvPrintRouter(a1, "wdialog", *(_QWORD *)(v10 + 24));
EnvPrintRouter(a1, "wdialog", &LC0);
}
else if ( (unsigned int)GetPrintWhileLoading(a1) )
{
EnvPrintRouter(a1, "wdialog", ":");
}
v11 = *(_QWORD *)(v10 + 24);
v12 = EnvGetCurrentModule(a1);
v8 = FindImportExportConflict(a1, "defglobal", v12, v11);
if ( v8 )
{
ImportExportConflictMessage(a1, "defglobal", *(_QWORD *)(v10 + 24), 0LL, 0LL);
*a3 = 1;
return 0;
}
GetToken(a1, a2, a5);
if ( strcmp(*((const char **)a5 + 2), "=") )
{
LABEL_8:
SyntaxErrorMessage(a1, "defglobal");
*a3 = 1;
return v8;
}
SavePPBuffer(a1, " ");
v13 = ParseAtomOrExpression(a1, a2, 0LL);
if ( !v13 )
{
*a3 = 1;
return 0;
}
v8 = *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 336LL) + 80LL);
if ( v8 )
{
ReturnExpression(a1, v13);
}
else
{
SetEvaluationError(a1, 0LL);
if ( (unsigned int)EvaluateExpression(a1, v13, v14) )
{
ReturnExpression(a1, v13);
*a3 = 1;
return v8;
}
}
SavePPBuffer(a1, ")");
v8 = 1;
if ( !*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 336LL) + 80LL) )
func0(a1, v10, (__int64)v14, v13);
}
return v8;
}

original_code:
static int GetVariableDefinition(
  void *theEnv,
  char *readSource,
  int *defglobalError,
  int tokenRead,
  struct token *theToken)
  {
   SYMBOL_HN *variableName;
   struct expr *assignPtr;
   DATA_OBJECT assignValue;
   if (! tokenRead) GetToken(theEnv,readSource,theToken);
   if (theToken->type == 171) return(0);
   if (theToken->type == 35)
     {
      SyntaxErrorMessage(theEnv,"defglobal");
      *defglobalError = 1;
      return(0);
     }
   else if (theToken->type != 33)
     {
      SyntaxErrorMessage(theEnv,"defglobal");
      *defglobalError = 1;
      return(0);
     }
   variableName = (SYMBOL_HN *) theToken->value;
   SavePPBuffer(theEnv," ");
   if ((EnvGetWatchItem(theEnv,"compilations") == 1) && GetPrintWhileLoading(theEnv))
     {
      if (QFindDefglobal(theEnv,variableName) != ((void *)0))
        {
         PrintWarningID(theEnv,"CSTRCPSR",1,1);
         EnvPrintRouter(theEnv,"wdialog","Redefining defglobal: ");
        }
      else EnvPrintRouter(theEnv,"wdialog","Defining defglobal: ");
      EnvPrintRouter(theEnv,"wdialog",(((struct symbolHashNode *) (variableName))->contents));
      EnvPrintRouter(theEnv,"wdialog","\n");
     }
   else
     { if (GetPrintWhileLoading(theEnv)) EnvPrintRouter(theEnv,"wdialog",":"); }
   if (FindImportExportConflict(theEnv,"defglobal",((struct defmodule *) EnvGetCurrentModule(theEnv)),(((struct symbolHashNode *) (variableName))->contents)))
     {
      ImportExportConflictMessage(theEnv,"defglobal",(((struct symbolHashNode *) (variableName))->contents),((void *)0),((void *)0));
      *defglobalError = 1;
      return(0);
     }
   GetToken(theEnv,readSource,theToken);
   if (strcmp(theToken->printForm,"=") != 0)
     {
      SyntaxErrorMessage(theEnv,"defglobal");
      *defglobalError = 1;
      return(0);
     }
   SavePPBuffer(theEnv," ");
   assignPtr = ParseAtomOrExpression(theEnv,readSource,((void *)0));
   if (assignPtr == ((void *)0))
     {
      *defglobalError = 1;
      return(0);
     }
   if (! ((struct constructData *) (((struct environmentData *) theEnv)->theData[42]))->CheckSyntaxMode)
     {
      SetEvaluationError(theEnv,0);
      if (EvaluateExpression(theEnv,assignPtr,&assignValue))
        {
         ReturnExpression(theEnv,assignPtr);
         *defglobalError = 1;
         return(0);
        }
     }
   else
     { ReturnExpression(theEnv,assignPtr); }
   SavePPBuffer(theEnv,")");
   if (! ((struct constructData *) (((struct environmentData *) theEnv)->theData[42]))->CheckSyntaxMode)
     { AddDefglobal(theEnv,variableName,&assignValue,assignPtr); }
   return(1);
  }

canonical_original_code:
static int GetVariableDefinition(void *theEnv, char *readSource, int *defglobalError, int tokenRead, struct token *theToken)
  {
   struct symbolHashNode *variableName;
   struct expr *assignPtr;
   struct dataObject assignValue;
   if (! tokenRead) GetToken(theEnv,readSource,theToken);
   if (theToken->type == 171) return(0);
   if (theToken->type == 35)
     {
      SyntaxErrorMessage(theEnv,"defglobal");
      *defglobalError = 1;
      return(0);
     }
   else if (theToken->type != 33)
     {
      SyntaxErrorMessage(theEnv,"defglobal");
      *defglobalError = 1;
      return(0);
     }
   variableName = (struct symbolHashNode *) theToken->value;
   SavePPBuffer(theEnv," ");
   if ((EnvGetWatchItem(theEnv,"compilations") == 1) && GetPrintWhileLoading(theEnv))
     {
      if (QFindDefglobal(theEnv,variableName) != ((void *)0))
        {
         PrintWarningID(theEnv,"CSTRCPSR",1,1);
         EnvPrintRouter(theEnv,"wdialog","Redefining defglobal: ");
        }
      else EnvPrintRouter(theEnv,"wdialog","Defining defglobal: ");
      EnvPrintRouter(theEnv,"wdialog",(((struct symbolHashNode *) (variableName))->contents));
      EnvPrintRouter(theEnv,"wdialog","\n");
     }
   else
     { if (GetPrintWhileLoading(theEnv)) EnvPrintRouter(theEnv,"wdialog",":"); }
   if (FindImportExportConflict(theEnv,"defglobal",((struct defmodule *) EnvGetCurrentModule(theEnv)),(((struct symbolHashNode *) (variableName))->contents)))
     {
      ImportExportConflictMessage(theEnv,"defglobal",(((struct symbolHashNode *) (variableName))->contents),((void *)0),((void *)0));
      *defglobalError = 1;
      return(0);
     }
   GetToken(theEnv,readSource,theToken);
   if (strcmp(theToken->printForm,"=") != 0)
     {
      SyntaxErrorMessage(theEnv,"defglobal");
      *defglobalError = 1;
      return(0);
     }
   SavePPBuffer(theEnv," ");
   assignPtr = ParseAtomOrExpression(theEnv,readSource,((void *)0));
   if (assignPtr == ((void *)0))
     {
      *defglobalError = 1;
      return(0);
     }
   if (! ((struct constructData *) (((struct environmentData *) theEnv)->theData[42]))->CheckSyntaxMode)
     {
      SetEvaluationError(theEnv,0);
      if (EvaluateExpression(theEnv,assignPtr,&assignValue))
        {
         ReturnExpression(theEnv,assignPtr);
         *defglobalError = 1;
         return(0);
        }
     }
   else
     { ReturnExpression(theEnv,assignPtr); }
   SavePPBuffer(theEnv,")");
   if (! ((struct constructData *) (((struct environmentData *) theEnv)->theData[42]))->CheckSyntaxMode)
     { AddDefglobal(theEnv,variableName,&assignValue,assignPtr); }
   return(1);
  }

variable_types:
readSource
char *

variable_types:
defglobalError
int *

variable_types: tokenRead int

variable_types: struct token { unsigned short type; void *value; char *printForm; } *

variable_types: struct symbolHashNode { struct symbolHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int neededSymbol; unsigned int bucket; char *contents; } *

variable_types: struct expr { unsigned short type; void *value; struct expr *argList; struct expr *nextArg; } *

variable_types: struct dataObject { void *supplementalInfo; unsigned short type; void *value; long begin; long end; struct dataObject *next; }

user_defined_types: struct defmodule { struct symbolHashNode *name; char *ppForm; struct defmoduleItemHeader **itemsArray; struct portItem *importList; struct portItem *exportList; unsigned int visitedFlag; long bsaveID; struct userData *usrData; struct defmodule *next; }

user_defined_types: struct constructData { int ClearReadyInProgress; int ClearInProgress; int ResetReadyInProgress; int ResetInProgress; struct callFunctionItem *ListOfSaveFunctions; int PrintWhileLoading; unsigned int WatchCompilations; struct construct *ListOfConstructs; struct callFunctionItem *ListOfResetFunctions; struct callFunctionItem *ListOfClearFunctions; struct callFunctionItem *ListOfClearReadyFunctions; int Executing; int (*BeforeResetFunction)(void *); int CheckSyntaxMode; }

user_defined_types: struct callFunctionItem { char *name; void (*func)(void *); int priority; struct callFunctionItem *next; short environmentAware; }

user_defined_types: struct construct { char *constructName; char *pluralName; int (*parseFunction)(void *, char *); void *(*findFunction)(void *, char *); struct symbolHashNode *(*getConstructNameFunction)(struct constructHeader *); char *(*getPPFormFunction)(void *, struct constructHeader *); struct defmoduleItemHeader *(*getModuleItemFunction)(struct constructHeader *); void *(*getNextItemFunction)(void *, void *); void (*setNextItemFunction)(struct constructHeader *, struct constructHeader *); int (*isConstructDeletableFunction)(void *, void *); int (*deleteFunction)(void *, void *); void (*freeFunction)(void *, void *); struct construct *next; }

user_defined_types: struct defmoduleItemHeader { struct defmodule *theModule; struct constructHeader *firstItem; struct constructHeader *lastItem; }


ParseDefglobal

repo: jarcec/rbclips

decompiled_code:
__int64 __fastcall ParseDefglobal(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
__int64 v3; // rax
__int64 v4; // rax
int v5; // ecx
__int64 v6; // r12
__int64 v7; // rax
__int64 v8; // rax
__int16 v10; // [rsp+0h] [rbp-38h] BYREF
__int64 v11; // [rsp+8h] [rbp-30h]
__int64 v12; // [rsp+10h] [rbp-28h]
unsigned int v13[7]; // [rsp+1Ch] [rbp-1Ch] BYREF

v13[0] = 0;
SetPPBufferStatus(a1, 1LL);
FlushPPBuffer(a1);
SetIndentDepth(a1, 3LL);
SavePPBuffer(a1, "(defglobal ");
if ( (unsigned int)Bloaded(a1) == 1 && (v2 = 1, !*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 336LL) + 80LL)) )
{
CannotLoadWithBloadMessage(a1, "defglobal");
}
else
{
GetToken(a1, a2, &v10);
if ( v10 == 2 )
{
if ( (unsigned int)FindModuleSeparator(*(_QWORD *)(v11 + 24)) )
{
SyntaxErrorMessage(a1, "defglobal");
return 1;
}
v6 = EnvFindDefmodule(a1, *(_QWORD *)(v11 + 24));
if ( !v6 )
{
CantFindItemErrorMessage(a1, "defmodule", *(_QWORD *)(v11 + 24));
return 1;
}
SavePPBuffer(a1, " ");
EnvSetCurrentModule(a1, v6);
v5 = 0;
}
else
{
PPBackup(a1);
v3 = EnvGetCurrentModule(a1);
v4 = EnvGetDefmoduleName(a1, v3);
SavePPBuffer(a1, v4);
SavePPBuffer(a1, " ");
SavePPBuffer(a1, v12);
v5 = 1;
}
while ( (unsigned int)GetVariableDefinition(a1, a2, v13, v5, &v10) )
{
FlushPPBuffer(a1);
SavePPBuffer(a1, "(defglobal ");
v7 = EnvGetCurrentModule(a1);
v8 = EnvGetDefmoduleName(a1, v7);
SavePPBuffer(a1, v8);
SavePPBuffer(a1, " ");
v5 = 0;
}
v2 = v13[0];
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
__int64 v3; // rax
__int64 v4; // rax
int v5; // ecx
__int64 v6; // r12
__int64 v7; // rax
__int64 v8; // rax
__int16 v10; // [rsp+0h] [rbp-38h] BYREF
__int64 v11; // [rsp+8h] [rbp-30h]
__int64 v12; // [rsp+10h] [rbp-28h]
unsigned int v13[7]; // [rsp+1Ch] [rbp-1Ch] BYREF

v13[0] = 0;
SetPPBufferStatus(a1, 1LL);
FlushPPBuffer(a1);
SetIndentDepth(a1, 3LL);
SavePPBuffer(a1, "(defglobal ");
if ( (unsigned int)Bloaded(a1) == 1 && (v2 = 1, !*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 336LL) + 80LL)) )
{
CannotLoadWithBloadMessage(a1, "defglobal");
}
else
{
GetToken(a1, a2, &v10);
if ( v10 == 2 )
{
if ( (unsigned int)FindModuleSeparator(*(_QWORD *)(v11 + 24)) )
{
SyntaxErrorMessage(a1, "defglobal");
return 1;
}
v6 = EnvFindDefmodule(a1, *(_QWORD *)(v11 + 24));
if ( !v6 )
{
CantFindItemErrorMessage(a1, "defmodule", *(_QWORD *)(v11 + 24));
return 1;
}
SavePPBuffer(a1, " ");
EnvSetCurrentModule(a1, v6);
v5 = 0;
}
else
{
PPBackup(a1);
v3 = EnvGetCurrentModule(a1);
v4 = EnvGetDefmoduleName(a1, v3);
SavePPBuffer(a1, v4);
SavePPBuffer(a1, " ");
SavePPBuffer(a1, v12);
v5 = 1;
}
while ( (unsigned int)func1(a1, a2, v13, v5, &v10) )
{
FlushPPBuffer(a1);
SavePPBuffer(a1, "(defglobal ");
v7 = EnvGetCurrentModule(a1);
v8 = EnvGetDefmoduleName(a1, v7);
SavePPBuffer(a1, v8);
SavePPBuffer(a1, " ");
v5 = 0;
}
v2 = v13[0];
}
return v2;
}

original_code:
int ParseDefglobal(
  void *theEnv,
  char *readSource)
  {
   int defglobalError = 0;
   struct token theToken;
   int tokenRead = 1;
   struct defmodule *theModule;
   SetPPBufferStatus(theEnv,1);
   FlushPPBuffer(theEnv);
   SetIndentDepth(theEnv,3);
   SavePPBuffer(theEnv,"(defglobal ");
   if ((Bloaded(theEnv) == 1) && (! ((struct constructData *) (((struct environmentData *) theEnv)->theData[42]))->CheckSyntaxMode))
     {
      CannotLoadWithBloadMessage(theEnv,"defglobal");
      return(1);
     }
   GetToken(theEnv,readSource,&theToken);
   if (theToken.type == 2)
     {
      tokenRead = 0;
      if (FindModuleSeparator((((struct symbolHashNode *) (theToken.value))->contents)))
        {
         SyntaxErrorMessage(theEnv,"defglobal");
         return(1);
        }
      theModule = (struct defmodule *) EnvFindDefmodule(theEnv,(((struct symbolHashNode *) (theToken.value))->contents));
      if (theModule == ((void *)0))
        {
         CantFindItemErrorMessage(theEnv,"defmodule",(((struct symbolHashNode *) (theToken.value))->contents));
         return(1);
        }
      SavePPBuffer(theEnv," ");
      EnvSetCurrentModule(theEnv,(void *) theModule);
     }
   else
     {
      PPBackup(theEnv);
      SavePPBuffer(theEnv,EnvGetDefmoduleName(theEnv,((struct defmodule *) EnvGetCurrentModule(theEnv))));
      SavePPBuffer(theEnv," ");
      SavePPBuffer(theEnv,theToken.printForm);
     }
   while (GetVariableDefinition(theEnv,readSource,&defglobalError,tokenRead,&theToken))
     {
      tokenRead = 0;
      FlushPPBuffer(theEnv);
      SavePPBuffer(theEnv,"(defglobal ");
      SavePPBuffer(theEnv,EnvGetDefmoduleName(theEnv,((struct defmodule *) EnvGetCurrentModule(theEnv))));
      SavePPBuffer(theEnv," ");
     }
   return(defglobalError);
  }

canonical_original_code:
int ParseDefglobal(void *theEnv, char *readSource)
  {
   int defglobalError = 0;
   struct token theToken;
   int tokenRead = 1;
   struct defmodule *theModule;
   SetPPBufferStatus(theEnv,1);
   FlushPPBuffer(theEnv);
   SetIndentDepth(theEnv,3);
   SavePPBuffer(theEnv,"(defglobal ");
   if ((Bloaded(theEnv) == 1) && (! ((struct constructData *) (((struct environmentData *) theEnv)->theData[42]))->CheckSyntaxMode))
     {
      CannotLoadWithBloadMessage(theEnv,"defglobal");
      return(1);
     }
   GetToken(theEnv,readSource,&theToken);
   if (theToken.type == 2)
     {
      tokenRead = 0;
      if (FindModuleSeparator((((struct symbolHashNode *) (theToken.value))->contents)))
        {
         SyntaxErrorMessage(theEnv,"defglobal");
         return(1);
        }
      theModule = (struct defmodule *) EnvFindDefmodule(theEnv,(((struct symbolHashNode *) (theToken.value))->contents));
      if (theModule == ((void *)0))
        {
         CantFindItemErrorMessage(theEnv,"defmodule",(((struct symbolHashNode *) (theToken.value))->contents));
         return(1);
        }
      SavePPBuffer(theEnv," ");
      EnvSetCurrentModule(theEnv,(void *) theModule);
     }
   else
     {
      PPBackup(theEnv);
      SavePPBuffer(theEnv,EnvGetDefmoduleName(theEnv,((struct defmodule *) EnvGetCurrentModule(theEnv))));
      SavePPBuffer(theEnv," ");
      SavePPBuffer(theEnv,theToken.printForm);
     }
   while (GetVariableDefinition(theEnv,readSource,&defglobalError,tokenRead,&theToken))
     {
      tokenRead = 0;
      FlushPPBuffer(theEnv);
      SavePPBuffer(theEnv,"(defglobal ");
      SavePPBuffer(theEnv,EnvGetDefmoduleName(theEnv,((struct defmodule *) EnvGetCurrentModule(theEnv))));
      SavePPBuffer(theEnv," ");
     }
   return(defglobalError);
  }

variable_types:
theEnv
void *

variable_types: defglobalError int

variable_types: struct token { unsigned short type; void *value; char *printForm; }

variable_types: struct defmodule { struct symbolHashNode { struct symbolHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int neededSymbol; unsigned int bucket; char *contents; } *name; char *ppForm; struct defmoduleItemHeader { struct defmodule *theModule; struct constructHeader { struct symbolHashNode *name; char *ppForm; struct defmoduleItemHeader *whichModule; long bsaveID; struct constructHeader *next; struct userData { unsigned char dataID; struct userData *next; } *usrData; } *firstItem; struct constructHeader *lastItem; } **itemsArray; struct portItem { struct symbolHashNode *moduleName; struct symbolHashNode *constructType; struct symbolHashNode *constructName; struct portItem *next; } *importList; struct portItem *exportList; unsigned int visitedFlag; long bsaveID; struct userData *usrData; struct defmodule *next; } *

return_type: int

user_defined_types: struct environmentData { unsigned int initialized; unsigned long environmentIndex; void *context; void *routerContext; void **theData; void (**cleanupFunctions)(void *); struct environmentCleanupFunction *listOfCleanupEnvironmentFunctions; struct environmentData *next; }

user_defined_types: struct environmentCleanupFunction { char *name; void (*func)(void *); int priority; struct environmentCleanupFunction *next; }

user_defined_types: struct constructHeader { struct symbolHashNode *name; char *ppForm; struct defmoduleItemHeader *whichModule; long bsaveID; struct constructHeader *next; struct userData *usrData; }


GlobalReferenceErrorMessage

decompiled_code:
__int64 __fastcall GlobalReferenceErrorMessage(__int64 a1, __int64 a2)
{
PrintErrorID(a1, "GLOBLPSR", 1LL, 1LL);
EnvPrintRouter(a1, "werror", "\nGlobal variable ?*");
EnvPrintRouter(a1, "werror", a2);
return EnvPrintRouter(a1, "werror", "* was referenced, but is not defined.\n");
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
PrintErrorID(a1, "GLOBLPSR", 1LL, 1LL);
EnvPrintRouter(a1, "werror", "\nGlobal variable ?*");
EnvPrintRouter(a1, "werror", a2);
return EnvPrintRouter(a1, "werror", "* was referenced, but is not defined.\n");
}

original_code:
void GlobalReferenceErrorMessage(
  void *theEnv,
  char *variableName)
  {
   PrintErrorID(theEnv,"GLOBLPSR",1,1);
   EnvPrintRouter(theEnv,"werror","\nGlobal variable ?*");
   EnvPrintRouter(theEnv,"werror",variableName);
   EnvPrintRouter(theEnv,"werror","* was referenced, but is not defined.\n");
  }

canonical_original_code:
void GlobalReferenceErrorMessage(void *theEnv, char *variableName)
  {
   PrintErrorID(theEnv,"GLOBLPSR",1,1);
   EnvPrintRouter(theEnv,"werror","\nGlobal variable ?*");
   EnvPrintRouter(theEnv,"werror",variableName);
   EnvPrintRouter(theEnv,"werror","* was referenced, but is not defined.\n");
  }

variable_types:
variableName
char *

return_type: void


ReplaceGlobalVariable

decompiled_code:
__int64 __fastcall ReplaceGlobalVariable(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 result; // rax
int v4[7]; // [rsp+14h] [rbp-1Ch] BYREF

v2 = FindImportedConstruct(a1, "defglobal", 0LL, *(_QWORD *)(*(_QWORD *)(a2 + 8) + 24LL), v4, 1LL, 0LL);
if ( v2 )
{
if ( v4[0] > 1 )
{
AmbiguousReferenceErrorMessage(a1, "defglobal", *(_QWORD *)(*(_QWORD *)(a2 + 8) + 24LL));
result = 0LL;
}
else
{
*(_WORD *)a2 = 90;
*(_QWORD *)(a2 + 8) = v2;
result = 1LL;
}
}
else
{
GlobalReferenceErrorMessage(a1, *(_QWORD *)(*(_QWORD *)(a2 + 8) + 24LL));
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 result; // rax
int v4[7]; // [rsp+14h] [rbp-1Ch] BYREF

v2 = FindImportedConstruct(a1, "defglobal", 0LL, *(_QWORD *)(*(_QWORD *)(a2 + 8) + 24LL), v4, 1LL, 0LL);
if ( v2 )
{
if ( v4[0] > 1 )
{
AmbiguousReferenceErrorMessage(a1, "defglobal", *(_QWORD *)(*(_QWORD *)(a2 + 8) + 24LL));
result = 0LL;
}
else
{
*(_WORD *)a2 = 90;
*(_QWORD *)(a2 + 8) = v2;
result = 1LL;
}
}
else
{
func3(a1, *(_QWORD *)(*(_QWORD *)(a2 + 8) + 24LL));
result = 0LL;
}
return result;
}

original_code:
int ReplaceGlobalVariable(
  void *theEnv,
  struct expr *ePtr)
  {
   struct defglobal *theGlobal;
   int count;
   theGlobal = (struct defglobal *)
               FindImportedConstruct(theEnv,"defglobal",((void *)0),(((struct symbolHashNode *) (ePtr->value))->contents),
                                     &count,1,((void *)0));
   if (theGlobal == ((void *)0))
     {
      GlobalReferenceErrorMessage(theEnv,(((struct symbolHashNode *) (ePtr->value))->contents));
      return(0);
     }
   if (count > 1)
     {
      AmbiguousReferenceErrorMessage(theEnv,"defglobal",(((struct symbolHashNode *) (ePtr->value))->contents));
      return(0);
     }
   ePtr->type = 90;
   ePtr->value = (void *) theGlobal;
   return(1);
  }

canonical_original_code:
int ReplaceGlobalVariable(void *theEnv, struct expr *ePtr)
  {
   struct defglobal *theGlobal;
   int count;
   theGlobal = (struct defglobal *)
               FindImportedConstruct(theEnv,"defglobal",((void *)0),(((struct symbolHashNode *) (ePtr->value))->contents),
                                     &count,1,((void *)0));
   if (theGlobal == ((void *)0))
     {
      GlobalReferenceErrorMessage(theEnv,(((struct symbolHashNode *) (ePtr->value))->contents));
      return(0);
     }
   if (count > 1)
     {
      AmbiguousReferenceErrorMessage(theEnv,"defglobal",(((struct symbolHashNode *) (ePtr->value))->contents));
      return(0);
     }
   ePtr->type = 90;
   ePtr->value = (void *) theGlobal;
   return(1);
  }

variable_types: struct defglobal { struct constructHeader { struct symbolHashNode { struct symbolHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int neededSymbol; unsigned int bucket; char *contents; } *name; char *ppForm; struct defmoduleItemHeader { struct defmodule { struct symbolHashNode *name; char *ppForm; struct defmoduleItemHeader **itemsArray; struct portItem { struct symbolHashNode *moduleName; struct symbolHashNode *constructType; struct symbolHashNode *constructName; struct portItem *next; } *importList; struct portItem *exportList; unsigned int visitedFlag; long bsaveID; struct userData { unsigned char dataID; struct userData *next; } *usrData; struct defmodule *next; } *theModule; struct constructHeader *firstItem; struct constructHeader *lastItem; } *whichModule; long bsaveID; struct constructHeader *next; struct userData *usrData; } header; unsigned int watch; unsigned int inScope; long busyCount; struct dataObject { void *supplementalInfo; unsigned short type; void *value; long begin; long end; struct dataObject *next; } current; struct expr { unsigned short type; void *value; struct expr *argList; struct expr *nextArg; } *initial; } *

variable_types: count int

user_defined_types: struct defglobal { struct constructHeader header; unsigned int watch; unsigned int inScope; long busyCount; struct dataObject current; struct expr *initial; }


RemoveEntityDependencies

original_code:
void RemoveEntityDependencies(
  void *theEnv,
  struct patternEntity *theEntity)
  {
   struct dependency *fdPtr, *nextPtr, *theList;
   struct partialMatch *theBinds;
   fdPtr = (struct dependency *) theEntity->dependents;
   while (fdPtr != ((void *)0))
     {
      nextPtr = fdPtr->next;
      theBinds = (struct partialMatch *) fdPtr->dPtr;
      theList = (struct dependency *)
                theBinds->binds[theBinds->bcount + theBinds->activationf].gm.theValue;
      theList = DetachAssociatedDependencies(theEnv,theList,(void *) theEntity);
      theBinds->binds[theBinds->bcount + theBinds->activationf].gm.theValue = (void *) theList;
      (((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = (struct memoryPtr *) fdPtr, ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct dependency)], ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct dependency)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr);
      fdPtr = nextPtr;
     }
   theEntity->dependents = ((void *)0);
  }

canonical_original_code:
void RemoveEntityDependencies(void *theEnv, struct patternEntity *theEntity)
  {
   struct dependency *fdPtr; struct dependency *nextPtr; struct dependency *theList;
   struct partialMatch *theBinds;
   fdPtr = (struct dependency *) theEntity->dependents;
   while (fdPtr != ((void *)0))
     {
      nextPtr = fdPtr->next;
      theBinds = (struct partialMatch *) fdPtr->dPtr;
      theList = (struct dependency *)
                theBinds->binds[theBinds->bcount + theBinds->activationf].gm.theValue;
      theList = DetachAssociatedDependencies(theEnv,theList,(void *) theEntity);
      theBinds->binds[theBinds->bcount + theBinds->activationf].gm.theValue = (void *) theList;
      (((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = (struct memoryPtr *) fdPtr, ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct dependency)], ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct dependency)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr);
      fdPtr = nextPtr;
     }
   theEntity->dependents = ((void *)0);
  }

variable_types: struct dependency { void *dPtr; struct dependency *next; } *

variable_types: struct partialMatch { unsigned int betaMemory; unsigned int busy; unsigned int activationf; unsigned int dependentsf; unsigned int notOriginf; unsigned int counterf; unsigned int bcount; struct partialMatch *next; struct genericMatch { union { void *theValue; struct alphaMatch { struct patternEntity { struct patternEntityRecord { struct entityRecord { char *name; unsigned int type; unsigned int copyToEvaluate; unsigned int bitMap; unsigned int addsToRuleComplexity; void (*shortPrintFunction)(void *, char *, void *); void (*longPrintFunction)(void *, char *, void *); int (*deleteFunction)(void *, void *); int (*evaluateFunction)(void *, void *, struct dataObject { void *supplementalInfo; unsigned short type; void *value; long begin; long end; struct dataObject *next; } *); void *(*getNextFunction)(void *, void *); void (*decrementBusyCount)(void *, void *); void (*incrementBusyCount)(void *, void *); void (*propagateDepth)(void *, void *); void (*markNeeded)(void *, void *); void (*install)(void *, void *); void (*deinstall)(void *, void *); struct userData { unsigned char dataID; struct userData *next; } *usrData; } base; void (*decrementBasisCount)(void *, void *); void (*incrementBasisCount)(void *, void *); void (*matchFunction)(void *, void *); int (*synchronized)(void *, void *); } *theInfo; void *dependents; unsigned int busyCount; long timeTag; } *matchingItem; struct multifieldMarker { int whichField; union { void *whichSlot; short whichSlotNumber; } where; long startPosition; long endPosition; struct multifieldMarker *next; } *markers; struct alphaMatch *next; } *theMatch; } gm; } binds[1]; } *

user_defined_types: struct patternEntity { struct patternEntityRecord *theInfo; void *dependents; unsigned int busyCount; long timeTag; }

user_defined_types: struct partialMatch { unsigned int betaMemory; unsigned int busy; unsigned int activationf; unsigned int dependentsf; unsigned int notOriginf; unsigned int counterf; unsigned int bcount; struct partialMatch *next; struct genericMatch binds[1]; }

user_defined_types: struct memoryData { long MemoryAmount; long MemoryCalls; int ConserveMemory; int (*OutOfMemoryFunction)(void *, unsigned long); struct memoryPtr *TempMemoryPtr; struct memoryPtr **MemoryTable; unsigned int TempSize; unsigned long TempSize2; }

user_defined_types: struct memoryPtr { struct memoryPtr *next; }

user_defined_types: struct patternEntityRecord { struct entityRecord base; void (*decrementBasisCount)(void *, void *); void (*incrementBasisCount)(void *, void *); void (*matchFunction)(void *, void *); int (*synchronized)(void *, void *); }

user_defined_types: struct genericMatch { union { void *theValue; struct alphaMatch *theMatch; } gm; }

user_defined_types: struct entityRecord { char *name; unsigned int type; unsigned int copyToEvaluate; unsigned int bitMap; unsigned int addsToRuleComplexity; void (*shortPrintFunction)(void *, char *, void *); void (*longPrintFunction)(void *, char *, void *); int (*deleteFunction)(void *, void *); int (*evaluateFunction)(void *, void *, struct dataObject *); void *(*getNextFunction)(void *, void *); void (*decrementBusyCount)(void *, void *); void (*incrementBusyCount)(void *, void *); void (*propagateDepth)(void *, void *); void (*markNeeded)(void *, void *); void (*install)(void *, void *); void (*deinstall)(void *, void *); struct userData *usrData; }

user_defined_types: struct alphaMatch { struct patternEntity *matchingItem; struct multifieldMarker *markers; struct alphaMatch *next; }


AddLogicalDependencies

original_code:
int AddLogicalDependencies(
  void *theEnv,
  struct patternEntity *theEntity,
  int existingEntity)
  {
   struct partialMatch *theBinds;
   struct dependency *newDependency;
   if (((struct engineData *) (((struct environmentData *) theEnv)->theData[18]))->TheLogicalJoin == ((void *)0))
     {
      if (existingEntity) RemoveEntityDependencies(theEnv,theEntity);
      return(1);
     }
   else if (existingEntity && (theEntity->dependents == ((void *)0)))
     { return(1); }
   theBinds = FindLogicalBind(((struct engineData *) (((struct environmentData *) theEnv)->theData[18]))->TheLogicalJoin,((struct engineData *) (((struct environmentData *) theEnv)->theData[18]))->GlobalLHSBinds);
   if (theBinds == ((void *)0)) return(0);
   newDependency = ((((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct dependency)] == ((void *)0)) ? ((struct dependency *) genalloc(theEnv,(unsigned) sizeof(struct dependency))) : ((((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct dependency)]), ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct dependency)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next, ((struct dependency *) ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr)));
   newDependency->dPtr = (void *) theEntity;
   newDependency->next = (struct dependency *)
                         theBinds->binds[theBinds->bcount + theBinds->activationf].gm.theValue;
   theBinds->binds[theBinds->bcount + theBinds->activationf].gm.theValue = (void *) newDependency;
   newDependency = ((((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct dependency)] == ((void *)0)) ? ((struct dependency *) genalloc(theEnv,(unsigned) sizeof(struct dependency))) : ((((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct dependency)]), ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct dependency)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next, ((struct dependency *) ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr)));
   newDependency->dPtr = (void *) theBinds;
   newDependency->next = (struct dependency *) theEntity->dependents;
   theEntity->dependents = (void *) newDependency;
   return(1);
  }

canonical_original_code:
int AddLogicalDependencies(void *theEnv, struct patternEntity *theEntity, int existingEntity)
  {
   struct partialMatch *theBinds;
   struct dependency *newDependency;
   if (((struct engineData *) (((struct environmentData *) theEnv)->theData[18]))->TheLogicalJoin == ((void *)0))
     {
      if (existingEntity) RemoveEntityDependencies(theEnv,theEntity);
      return(1);
     }
   else if (existingEntity && (theEntity->dependents == ((void *)0)))
     { return(1); }
   theBinds = FindLogicalBind(((struct engineData *) (((struct environmentData *) theEnv)->theData[18]))->TheLogicalJoin,((struct engineData *) (((struct environmentData *) theEnv)->theData[18]))->GlobalLHSBinds);
   if (theBinds == ((void *)0)) return(0);
   newDependency = ((((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct dependency)] == ((void *)0)) ? ((struct dependency *) genalloc(theEnv,(unsigned int) sizeof(struct dependency))) : ((((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct dependency)]), ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct dependency)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next, ((struct dependency *) ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr)));
   newDependency->dPtr = (void *) theEntity;
   newDependency->next = (struct dependency *)
                         theBinds->binds[theBinds->bcount + theBinds->activationf].gm.theValue;
   theBinds->binds[theBinds->bcount + theBinds->activationf].gm.theValue = (void *) newDependency;
   newDependency = ((((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct dependency)] == ((void *)0)) ? ((struct dependency *) genalloc(theEnv,(unsigned int) sizeof(struct dependency))) : ((((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct dependency)]), ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct dependency)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next, ((struct dependency *) ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr)));
   newDependency->dPtr = (void *) theBinds;
   newDependency->next = (struct dependency *) theEntity->dependents;
   theEntity->dependents = (void *) newDependency;
   return(1);
  }

variable_types: struct patternEntity { struct patternEntityRecord { struct entityRecord { char *name; unsigned int type; unsigned int copyToEvaluate; unsigned int bitMap; unsigned int addsToRuleComplexity; void (*shortPrintFunction)(void *, char *, void *); void (*longPrintFunction)(void *, char *, void *); int (*deleteFunction)(void *, void *); int (*evaluateFunction)(void *, void *, struct dataObject { void *supplementalInfo; unsigned short type; void *value; long begin; long end; struct dataObject *next; } *); void *(*getNextFunction)(void *, void *); void (*decrementBusyCount)(void *, void *); void (*incrementBusyCount)(void *, void *); void (*propagateDepth)(void *, void *); void (*markNeeded)(void *, void *); void (*install)(void *, void *); void (*deinstall)(void *, void *); struct userData { unsigned char dataID; struct userData *next; } *usrData; } base; void (*decrementBasisCount)(void *, void *); void (*incrementBasisCount)(void *, void *); void (*matchFunction)(void *, void *); int (*synchronized)(void *, void *); } *theInfo; void *dependents; unsigned int busyCount; long timeTag; } *

variable_types: existingEntity int

user_defined_types: struct dependency { void *dPtr; struct dependency *next; }

user_defined_types: struct engineData { struct defrule *ExecutingRule; int HaltRules; struct joinNode *TheLogicalJoin; struct dependency *UnsupportedDataEntities; int alreadyEntered; struct callFunctionItem *ListOfRunFunctions; struct focus *CurrentFocus; int FocusChanged; unsigned int WatchStatistics; unsigned int WatchFocus; int IncrementalResetInProgress; int IncrementalResetFlag; int JoinOperationInProgress; struct partialMatch *GlobalLHSBinds; struct partialMatch *GlobalRHSBinds; struct joinNode *GlobalJoin; struct rdriveinfo *DriveRetractionList; struct partialMatch *GarbagePartialMatches; struct alphaMatch *GarbageAlphaMatches; int AlreadyRunning; }

user_defined_types: struct defrule { struct constructHeader header; int salience; int localVarCnt; unsigned int complexity; unsigned int afterBreakpoint; unsigned int watchActivation; unsigned int watchFiring; unsigned int autoFocus; unsigned int executing; struct expr *dynamicSalience; struct expr *actions; struct joinNode *logicalJoin; struct joinNode *lastJoin; struct defrule *disjunct; }

user_defined_types: struct focus { struct defmodule *theModule; struct defruleModule *theDefruleModule; struct focus *next; }

user_defined_types: struct rdriveinfo { struct partialMatch *link; struct joinNode *jlist; struct rdriveinfo *next; }

user_defined_types: struct expr { unsigned short type; void *value; struct expr *argList; struct expr *nextArg; }

user_defined_types: struct joinNode { unsigned int firstJoin; unsigned int logicalJoin; unsigned int joinFromTheRight; unsigned int patternIsNegated; unsigned int initialize; unsigned int marked; unsigned int rhsType; unsigned int depth; long bsaveID; struct partialMatch *beta; struct expr *networkTest; void *rightSideEntryStructure; struct joinNode *nextLevel; struct joinNode *lastLevel; struct joinNode *rightDriveNode; struct joinNode *rightMatchNode; struct defrule *ruleToActivate; }

user_defined_types: struct defruleModule { struct defmoduleItemHeader header; struct activation *agenda; }

user_defined_types: struct symbolHashNode { struct symbolHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int neededSymbol; unsigned int bucket; char *contents; }

user_defined_types: struct activation { struct defrule *theRule; struct partialMatch *basis; int salience; unsigned long timetag; struct partialMatch *sortedBasis; int randomID; struct activation *prev; struct activation *next; }

user_defined_types: struct multifieldMarker { int whichField; union { void *whichSlot; short whichSlotNumber; } where; long startPosition; long endPosition; struct multifieldMarker *next; }

user_defined_types: struct defmodule { struct symbolHashNode *name; char *ppForm; struct defmoduleItemHeader **itemsArray; struct portItem *importList; struct portItem *exportList; unsigned int visitedFlag; long bsaveID; struct userData *usrData; struct defmodule *next; }

user_defined_types: struct portItem { struct symbolHashNode *moduleName; struct symbolHashNode *constructType; struct symbolHashNode *constructName; struct portItem *next; }


ReturnEntityDependencies

original_code:
void ReturnEntityDependencies(
  void *theEnv,
  struct patternEntity *theEntity)
  {
   struct dependency *fdPtr, *nextPtr;
   fdPtr = (struct dependency *) theEntity->dependents;
   while (fdPtr != ((void *)0))
     {
      nextPtr = fdPtr->next;
      (((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = (struct memoryPtr *) fdPtr, ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct dependency)], ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct dependency)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr);
      fdPtr = nextPtr;
     }
   theEntity->dependents = ((void *)0);
  }

canonical_original_code:
void ReturnEntityDependencies(void *theEnv, struct patternEntity *theEntity)
  {
   struct dependency *fdPtr; struct dependency *nextPtr;
   fdPtr = (struct dependency *) theEntity->dependents;
   while (fdPtr != ((void *)0))
     {
      nextPtr = fdPtr->next;
      (((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = (struct memoryPtr *) fdPtr, ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct dependency)], ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct dependency)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr);
      fdPtr = nextPtr;
     }
   theEntity->dependents = ((void *)0);
  }

user_defined_types: struct patternEntity { struct patternEntityRecord *theInfo; void *dependents; unsigned int busyCount; long timeTag; }

user_defined_types: struct memoryData { long MemoryAmount; long MemoryCalls; int ConserveMemory; int (*OutOfMemoryFunction)(void *, unsigned long); struct memoryPtr *TempMemoryPtr; struct memoryPtr **MemoryTable; unsigned int TempSize; unsigned long TempSize2; }

user_defined_types: struct environmentData { unsigned int initialized; unsigned long environmentIndex; void *context; void *routerContext; void **theData; void (**cleanupFunctions)(void *); struct environmentCleanupFunction *listOfCleanupEnvironmentFunctions; struct environmentData *next; }

user_defined_types: struct memoryPtr { struct memoryPtr *next; }

user_defined_types: struct patternEntityRecord { struct entityRecord base; void (*decrementBasisCount)(void *, void *); void (*incrementBasisCount)(void *, void *); void (*matchFunction)(void *, void *); int (*synchronized)(void *, void *); }

user_defined_types: struct environmentCleanupFunction { char *name; void (*func)(void *); int priority; struct environmentCleanupFunction *next; }

user_defined_types: struct userData { unsigned char dataID; struct userData *next; }

user_defined_types: struct dataObject { void *supplementalInfo; unsigned short type; void *value; long begin; long end; struct dataObject *next; }


Dependencies

decompiled_code:
__int64 __fastcall Dependencies(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbx
__int64 result; // rax

v2 = *(_QWORD **)(a2 + 8);
if ( !v2 )
return EnvPrintRouter(a1, "wdisplay", "None\n");
do
{
result = GetHaltExecution(a1);
if ( (_DWORD)result == 1 )
break;
PrintPartialMatch(a1, "wdisplay", *v2);
result = EnvPrintRouter(a1, "wdisplay", "\n");
v2 = (_QWORD *)v2[1];
}
while ( v2 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbx
__int64 result; // rax

v2 = *(_QWORD **)(a2 + 8);
if ( !v2 )
return EnvPrintRouter(a1, "wdisplay", "None\n");
do
{
result = GetHaltExecution(a1);
if ( (_DWORD)result == 1 )
break;
PrintPartialMatch(a1, "wdisplay", *v2);
result = EnvPrintRouter(a1, "wdisplay", "\n");
v2 = (_QWORD *)v2[1];
}
while ( v2 );
return result;
}

original_code:
void Dependencies(
  void *theEnv,
  struct patternEntity *theEntity)
  {
   struct dependency *fdPtr;
   if (theEntity->dependents == ((void *)0))
     {
      EnvPrintRouter(theEnv,"wdisplay","None\n");
      return;
     }
   for (fdPtr = (struct dependency *) theEntity->dependents;
        fdPtr != ((void *)0);
        fdPtr = fdPtr->next)
     {
      if (GetHaltExecution(theEnv) == 1) return;
      PrintPartialMatch(theEnv,"wdisplay",(struct partialMatch *) fdPtr->dPtr);
      EnvPrintRouter(theEnv,"wdisplay","\n");
     }
  }

canonical_original_code:
void Dependencies(void *theEnv, struct patternEntity *theEntity)
  {
   struct dependency *fdPtr;
   if (theEntity->dependents == ((void *)0))
     {
      EnvPrintRouter(theEnv,"wdisplay","None\n");
      return;
     }
   for (fdPtr = (struct dependency *) theEntity->dependents;
        fdPtr != ((void *)0);
        fdPtr = fdPtr->next)
     {
      if (GetHaltExecution(theEnv) == 1) return;
      PrintPartialMatch(theEnv,"wdisplay",(struct partialMatch *) fdPtr->dPtr);
      EnvPrintRouter(theEnv,"wdisplay","\n");
     }
  }

user_defined_types: struct dependency { void *dPtr; struct dependency *next; }

user_defined_types: struct partialMatch { unsigned int betaMemory; unsigned int busy; unsigned int activationf; unsigned int dependentsf; unsigned int notOriginf; unsigned int counterf; unsigned int bcount; struct partialMatch *next; struct genericMatch binds[1]; }

user_defined_types: struct genericMatch { union { void *theValue; struct alphaMatch *theMatch; } gm; }

user_defined_types: struct entityRecord { char *name; unsigned int type; unsigned int copyToEvaluate; unsigned int bitMap; unsigned int addsToRuleComplexity; void (*shortPrintFunction)(void *, char *, void *); void (*longPrintFunction)(void *, char *, void *); int (*deleteFunction)(void *, void *); int (*evaluateFunction)(void *, void *, struct dataObject *); void *(*getNextFunction)(void *, void *); void (*decrementBusyCount)(void *, void *); void (*incrementBusyCount)(void *, void *); void (*propagateDepth)(void *, void *); void (*markNeeded)(void *, void *); void (*install)(void *, void *); void (*deinstall)(void *, void *); struct userData *usrData; }

user_defined_types: struct alphaMatch { struct patternEntity *matchingItem; struct multifieldMarker *markers; struct alphaMatch *next; }


DependenciesCommand

decompiled_code:
__int64 __fastcall DependenciesCommand(__int64 a1)
{
__int64 result; // rax
__int64 v2; // [rsp+0h] [rbp-38h] BYREF

result = EnvArgCountCheck(a1, "dependencies", 0LL, 1LL);
if ( (_DWORD)result != -1 )
{
result = GetFactOrInstanceArgument(a1, 1LL, &v2, "dependencies");
if ( result )
result = Dependencies(a1, result);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
__int64 result; // rax
__int64 v2; // [rsp+0h] [rbp-38h] BYREF

result = EnvArgCountCheck(a1, "dependencies", 0LL, 1LL);
if ( (_DWORD)result != -1 )
{
result = GetFactOrInstanceArgument(a1, 1LL, &v2, "dependencies");
if ( result )
result = func7(a1, result);
}
return result;
}

original_code:
void DependenciesCommand(
  void *theEnv)
  {
   DATA_OBJECT item;
   void *ptr;
   if (EnvArgCountCheck(theEnv,"dependencies",0,1) == -1) return;
   ptr = GetFactOrInstanceArgument(theEnv,1,&item,"dependencies");
   if (ptr == ((void *)0)) return;
   Dependencies(theEnv,(struct patternEntity *) ptr);
  }

canonical_original_code:
void DependenciesCommand(void *theEnv)
  {
   struct dataObject item;
   void *ptr;
   if (EnvArgCountCheck(theEnv,"dependencies",0,1) == -1) return;
   ptr = GetFactOrInstanceArgument(theEnv,1,&item,"dependencies");
   if (ptr == ((void *)0)) return;
   Dependencies(theEnv,(struct patternEntity *) ptr);
  }

variable_types:
ptr
void *


DependentsCommand

decompiled_code:
__int64 __fastcall DependentsCommand(__int64 a1)
{
__int64 result; // rax
__int64 v2; // [rsp+0h] [rbp-38h] BYREF

result = EnvArgCountCheck(a1, "dependents", 0LL, 1LL);
if ( (_DWORD)result != -1 )
{
result = GetFactOrInstanceArgument(a1, 1LL, &v2, "dependents");
if ( result )
result = Dependents(a1, result);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
__int64 result; // rax
__int64 v2; // [rsp+0h] [rbp-38h] BYREF

result = EnvArgCountCheck(a1, "dependents", 0LL, 1LL);
if ( (_DWORD)result != -1 )
{
result = GetFactOrInstanceArgument(a1, 1LL, &v2, "dependents");
if ( result )
result = func8(a1, result);
}
return result;
}

original_code:
void DependentsCommand(
  void *theEnv)
  {
   DATA_OBJECT item;
   void *ptr;
   if (EnvArgCountCheck(theEnv,"dependents",0,1) == -1) return;
   ptr = GetFactOrInstanceArgument(theEnv,1,&item,"dependents");
   if (ptr == ((void *)0)) return;
   Dependents(theEnv,(struct patternEntity *) ptr);
  }

canonical_original_code:
void DependentsCommand(void *theEnv)
  {
   struct dataObject item;
   void *ptr;
   if (EnvArgCountCheck(theEnv,"dependents",0,1) == -1) return;
   ptr = GetFactOrInstanceArgument(theEnv,1,&item,"dependents");
   if (ptr == ((void *)0)) return;
   Dependents(theEnv,(struct patternEntity *) ptr);
  }


InitializeFunctionNeededFlags

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

for ( result = GetFunctionList(); result; result = *(_QWORD *)(result + 56) )
*(_WORD *)(result + 54) = 0;
return result;
}

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

for ( result = GetFunctionList(); result; result = *(_QWORD *)(result + 56) )
*(_WORD *)(result + 54) = 0;
return result;
}

original_code:
static void InitializeFunctionNeededFlags(
  void *theEnv)
  {
   struct FunctionDefinition *functionList;
   for (functionList = GetFunctionList(theEnv);
        functionList != ((void *)0);
        functionList = functionList->next)
     { functionList->bsaveIndex = 0; }
  }

canonical_original_code:
static void InitializeFunctionNeededFlags(void *theEnv)
  {
   struct FunctionDefinition *functionList;
   for (functionList = GetFunctionList(theEnv);
        functionList != ((void *)0);
        functionList = functionList->next)
     { functionList->bsaveIndex = 0; }
  }

variable_types: struct FunctionDefinition { struct symbolHashNode { struct symbolHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int neededSymbol; unsigned int bucket; char *contents; } *callFunctionName; char *actualFunctionName; char returnValueType; int (*functionPointer)(); struct expr { unsigned short type; void *value; struct expr *argList; struct expr *nextArg; } *(*parser)(void *, struct expr *, char *); char *restrictions; short overloadable; short sequenceuseok; short environmentAware; short bsaveIndex; struct FunctionDefinition *next; struct userData { unsigned char dataID; struct userData *next; } *usrData; } *

user_defined_types: struct FunctionDefinition { struct symbolHashNode *callFunctionName; char *actualFunctionName; char returnValueType; int (*functionPointer)(); struct expr *(*parser)(void *, struct expr *, char *); char *restrictions; short overloadable; short sequenceuseok; short environmentAware; short bsaveIndex; struct FunctionDefinition *next; struct userData *usrData; }


FunctionBinarySize

decompiled_code:
__int64 FunctionBinarySize()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 v2; // rbp

v0 = GetFunctionList();
if ( !v0 )
return 0LL;
v1 = v0;
v2 = 0LL;
do
{
if ( *(__int16 *)(v1 + 54) >= 0 )
v2 += strlen(*(const char **)(*(_QWORD *)v1 + 24LL)) + 1;
v1 = *(_QWORD *)(v1 + 56);
}
while ( v1 );
return v2;
}

original_code:
static unsigned long int FunctionBinarySize(
  void *theEnv)
  {
   unsigned long int size = 0;
   struct FunctionDefinition *functionList;
   for (functionList = GetFunctionList(theEnv);
        functionList != ((void *)0);
        functionList = functionList->next)
     {
      if (functionList->bsaveIndex >= 0)
        { size += strlen((((struct symbolHashNode *) (functionList->callFunctionName))->contents)) + 1; }
     }
   return(size);
  }

canonical_original_code:
static unsigned long FunctionBinarySize(void *theEnv)
  {
   unsigned long size = 0;
   struct FunctionDefinition *functionList;
   for (functionList = GetFunctionList(theEnv);
        functionList != ((void *)0);
        functionList = functionList->next)
     {
      if (functionList->bsaveIndex >= 0)
        { size += strlen((((struct symbolHashNode *) (functionList->callFunctionName))->contents)) + 1; }
     }
   return(size);
  }

variable_types:
size
unsigned long

return_type: unsigned long

user_defined_types: struct symbolHashNode { struct symbolHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int neededSymbol; unsigned int bucket; char *contents; }

user_defined_types: struct expr { unsigned short type; void *value; struct expr *argList; struct expr *nextArg; }


BsaveCommand

decompiled_code:
_BOOL8 __fastcall BsaveCommand(__int64 a1)
{
int v1; // edx
_BOOL8 result; // rax
__int64 v3; // rsi

v1 = EnvArgCountCheck(a1, "bsave", 0LL, 1LL);
result = 0LL;
if ( v1 != -1 )
{
v3 = GetFileName(a1, "bsave", 1LL);
result = 0LL;
if ( v3 )
result = (unsigned int)EnvBsave(a1, v3) != 0;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func8(__int64 a1)
{
int v1; // edx
_BOOL8 result; // rax
__int64 v3; // rsi

v1 = EnvArgCountCheck(a1, "bsave", 0LL, 1LL);
result = 0LL;
if ( v1 != -1 )
{
v3 = GetFileName(a1, "bsave", 1LL);
result = 0LL;
if ( v3 )
result = (unsigned int)func7(a1, v3) != 0;
}
return result;
}

original_code:
int BsaveCommand(
  void *theEnv)
  {
   char *fileName;
   if (EnvArgCountCheck(theEnv,"bsave",0,1) == -1) return(0);
   fileName = GetFileName(theEnv,"bsave",1);
   if (fileName != ((void *)0))
     { if (EnvBsave(theEnv,fileName)) return(1); }
   return(0);
  }

canonical_original_code:
int BsaveCommand(void *theEnv)
  {
   char *fileName;
   if (EnvArgCountCheck(theEnv,"bsave",0,1) == -1) return(0);
   fileName = GetFileName(theEnv,"bsave",1);
   if (fileName != ((void *)0))
     { if (EnvBsave(theEnv,fileName)) return(1); }
   return(0);
  }

variable_types:
fileName
char *


CopyFromBsaveConstraintRecord

original_code:
static void CopyFromBsaveConstraintRecord(
  void *theEnv,
  void *buf,
  long theIndex)
  {
   BSAVE_CONSTRAINT_RECORD *bsaveConstraints;
   CONSTRAINT_RECORD *constraints;
   bsaveConstraints = (BSAVE_CONSTRAINT_RECORD *) buf;
   constraints = (CONSTRAINT_RECORD *) &((struct constraintData *) (((struct environmentData *) theEnv)->theData[43]))->ConstraintArray[theIndex];
   constraints->anyAllowed = bsaveConstraints->anyAllowed;
   constraints->symbolsAllowed = bsaveConstraints->symbolsAllowed;
   constraints->stringsAllowed = bsaveConstraints->stringsAllowed;
   constraints->floatsAllowed = bsaveConstraints->floatsAllowed;
   constraints->integersAllowed = bsaveConstraints->integersAllowed;
   constraints->instanceNamesAllowed = bsaveConstraints->instanceNamesAllowed;
   constraints->instanceAddressesAllowed = bsaveConstraints->instanceAddressesAllowed;
   constraints->externalAddressesAllowed = bsaveConstraints->externalAddressesAllowed;
   constraints->voidAllowed = 0;
   constraints->multifieldsAllowed = bsaveConstraints->multifieldsAllowed;
   constraints->singlefieldsAllowed = bsaveConstraints->singlefieldsAllowed;
   constraints->factAddressesAllowed = bsaveConstraints->factAddressesAllowed;
   constraints->anyRestriction = bsaveConstraints->anyRestriction;
   constraints->symbolRestriction = bsaveConstraints->symbolRestriction;
   constraints->stringRestriction = bsaveConstraints->stringRestriction;
   constraints->floatRestriction = bsaveConstraints->floatRestriction;
   constraints->integerRestriction = bsaveConstraints->integerRestriction;
   constraints->classRestriction = bsaveConstraints->classRestriction;
   constraints->instanceNameRestriction = bsaveConstraints->instanceNameRestriction;
   constraints->restrictionList = ((struct expr *) (((bsaveConstraints->restrictionList) == -1L) ? ((void *)0) : &((struct expressionData *) (((struct environmentData *) theEnv)->theData[45]))->ExpressionArray[bsaveConstraints->restrictionList]));
   constraints->classList = ((struct expr *) (((bsaveConstraints->classList) == -1L) ? ((void *)0) : &((struct expressionData *) (((struct environmentData *) theEnv)->theData[45]))->ExpressionArray[bsaveConstraints->classList]));
   constraints->minValue = ((struct expr *) (((bsaveConstraints->minValue) == -1L) ? ((void *)0) : &((struct expressionData *) (((struct environmentData *) theEnv)->theData[45]))->ExpressionArray[bsaveConstraints->minValue]));
   constraints->maxValue = ((struct expr *) (((bsaveConstraints->maxValue) == -1L) ? ((void *)0) : &((struct expressionData *) (((struct environmentData *) theEnv)->theData[45]))->ExpressionArray[bsaveConstraints->maxValue]));
   constraints->minFields = ((struct expr *) (((bsaveConstraints->minFields) == -1L) ? ((void *)0) : &((struct expressionData *) (((struct environmentData *) theEnv)->theData[45]))->ExpressionArray[bsaveConstraints->minFields]));
   constraints->maxFields = ((struct expr *) (((bsaveConstraints->maxFields) == -1L) ? ((void *)0) : &((struct expressionData *) (((struct environmentData *) theEnv)->theData[45]))->ExpressionArray[bsaveConstraints->maxFields]));
   constraints->multifield = ((void *)0);
  }

canonical_original_code:
static void CopyFromBsaveConstraintRecord(void *theEnv, void *buf, long theIndex)
  {
   struct bsaveConstraintRecord *bsaveConstraints;
   struct constraintRecord *constraints;
   bsaveConstraints = (struct bsaveConstraintRecord *) buf;
   constraints = (struct constraintRecord *) &((struct constraintData *) (((struct environmentData *) theEnv)->theData[43]))->ConstraintArray[theIndex];
   constraints->anyAllowed = bsaveConstraints->anyAllowed;
   constraints->symbolsAllowed = bsaveConstraints->symbolsAllowed;
   constraints->stringsAllowed = bsaveConstraints->stringsAllowed;
   constraints->floatsAllowed = bsaveConstraints->floatsAllowed;
   constraints->integersAllowed = bsaveConstraints->integersAllowed;
   constraints->instanceNamesAllowed = bsaveConstraints->instanceNamesAllowed;
   constraints->instanceAddressesAllowed = bsaveConstraints->instanceAddressesAllowed;
   constraints->externalAddressesAllowed = bsaveConstraints->externalAddressesAllowed;
   constraints->voidAllowed = 0;
   constraints->multifieldsAllowed = bsaveConstraints->multifieldsAllowed;
   constraints->singlefieldsAllowed = bsaveConstraints->singlefieldsAllowed;
   constraints->factAddressesAllowed = bsaveConstraints->factAddressesAllowed;
   constraints->anyRestriction = bsaveConstraints->anyRestriction;
   constraints->symbolRestriction = bsaveConstraints->symbolRestriction;
   constraints->stringRestriction = bsaveConstraints->stringRestriction;
   constraints->floatRestriction = bsaveConstraints->floatRestriction;
   constraints->integerRestriction = bsaveConstraints->integerRestriction;
   constraints->classRestriction = bsaveConstraints->classRestriction;
   constraints->instanceNameRestriction = bsaveConstraints->instanceNameRestriction;
   constraints->restrictionList = ((struct expr *) (((bsaveConstraints->restrictionList) == -1L) ? ((void *)0) : &((struct expressionData *) (((struct environmentData *) theEnv)->theData[45]))->ExpressionArray[bsaveConstraints->restrictionList]));
   constraints->classList = ((struct expr *) (((bsaveConstraints->classList) == -1L) ? ((void *)0) : &((struct expressionData *) (((struct environmentData *) theEnv)->theData[45]))->ExpressionArray[bsaveConstraints->classList]));
   constraints->minValue = ((struct expr *) (((bsaveConstraints->minValue) == -1L) ? ((void *)0) : &((struct expressionData *) (((struct environmentData *) theEnv)->theData[45]))->ExpressionArray[bsaveConstraints->minValue]));
   constraints->maxValue = ((struct expr *) (((bsaveConstraints->maxValue) == -1L) ? ((void *)0) : &((struct expressionData *) (((struct environmentData *) theEnv)->theData[45]))->ExpressionArray[bsaveConstraints->maxValue]));
   constraints->minFields = ((struct expr *) (((bsaveConstraints->minFields) == -1L) ? ((void *)0) : &((struct expressionData *) (((struct environmentData *) theEnv)->theData[45]))->ExpressionArray[bsaveConstraints->minFields]));
   constraints->maxFields = ((struct expr *) (((bsaveConstraints->maxFields) == -1L) ? ((void *)0) : &((struct expressionData *) (((struct environmentData *) theEnv)->theData[45]))->ExpressionArray[bsaveConstraints->maxFields]));
   constraints->multifield = ((void *)0);
  }

variable_types:
buf
void *

variable_types: theIndex long

variable_types: struct bsaveConstraintRecord { unsigned int anyAllowed; unsigned int symbolsAllowed; unsigned int stringsAllowed; unsigned int floatsAllowed; unsigned int integersAllowed; unsigned int instanceNamesAllowed; unsigned int instanceAddressesAllowed; unsigned int externalAddressesAllowed; unsigned int factAddressesAllowed; unsigned int anyRestriction; unsigned int symbolRestriction; unsigned int stringRestriction; unsigned int numberRestriction; unsigned int floatRestriction; unsigned int integerRestriction; unsigned int classRestriction; unsigned int instanceNameRestriction; unsigned int multifieldsAllowed; unsigned int singlefieldsAllowed; long classList; long restrictionList; long minValue; long maxValue; long minFields; long maxFields; } *

variable_types: struct constraintRecord { unsigned int anyAllowed; unsigned int symbolsAllowed; unsigned int stringsAllowed; unsigned int floatsAllowed; unsigned int integersAllowed; unsigned int instanceNamesAllowed; unsigned int instanceAddressesAllowed; unsigned int externalAddressesAllowed; unsigned int factAddressesAllowed; unsigned int voidAllowed; unsigned int anyRestriction; unsigned int symbolRestriction; unsigned int stringRestriction; unsigned int floatRestriction; unsigned int integerRestriction; unsigned int classRestriction; unsigned int instanceNameRestriction; unsigned int multifieldsAllowed; unsigned int singlefieldsAllowed; unsigned short bsaveIndex; struct expr { unsigned short type; void *value; struct expr *argList; struct expr *nextArg; } *classList; struct expr *restrictionList; struct expr *minValue; struct expr *maxValue; struct expr *minFields; struct expr *maxFields; struct constraintRecord *multifield; struct constraintRecord *next; int bucket; int count; } *

user_defined_types: struct constraintRecord { unsigned int anyAllowed; unsigned int symbolsAllowed; unsigned int stringsAllowed; unsigned int floatsAllowed; unsigned int integersAllowed; unsigned int instanceNamesAllowed; unsigned int instanceAddressesAllowed; unsigned int externalAddressesAllowed; unsigned int factAddressesAllowed; unsigned int voidAllowed; unsigned int anyRestriction; unsigned int symbolRestriction; unsigned int stringRestriction; unsigned int floatRestriction; unsigned int integerRestriction; unsigned int classRestriction; unsigned int instanceNameRestriction; unsigned int multifieldsAllowed; unsigned int singlefieldsAllowed; unsigned short bsaveIndex; struct expr *classList; struct expr *restrictionList; struct expr *minValue; struct expr *maxValue; struct expr *minFields; struct expr *maxFields; struct constraintRecord *multifield; struct constraintRecord *next; int bucket; int count; }

user_defined_types: struct constraintData { struct constraintRecord **ConstraintHashtable; int StaticConstraintChecking; int DynamicConstraintChecking; struct constraintRecord *ConstraintArray; long NumberOfConstraints; }

user_defined_types: struct expressionData { void *PTR_AND; void *PTR_OR; void *PTR_EQ; void *PTR_NEQ; void *PTR_NOT; struct exprHashNode **ExpressionHashTable; long NumberOfExpressions; struct expr *ExpressionArray; long ExpressionCount; struct saved_contexts *svContexts; int ReturnContext; int BreakContext; int SequenceOpMode; }

user_defined_types: struct saved_contexts { int rtn; int brk; struct saved_contexts *nxt; }

user_defined_types: struct exprHashNode { unsigned int hashval; unsigned int count; struct expr *exp; struct exprHashNode *next; long bsaveID; }


CopyToBsaveConstraintRecord

original_code:
static void CopyToBsaveConstraintRecord(
  void *theEnv,
  CONSTRAINT_RECORD *constraints,
  BSAVE_CONSTRAINT_RECORD *bsaveConstraints)
  {
   bsaveConstraints->anyAllowed = constraints->anyAllowed;
   bsaveConstraints->symbolsAllowed = constraints->symbolsAllowed;
   bsaveConstraints->stringsAllowed = constraints->stringsAllowed;
   bsaveConstraints->floatsAllowed = constraints->floatsAllowed;
   bsaveConstraints->integersAllowed = constraints->integersAllowed;
   bsaveConstraints->instanceNamesAllowed = constraints->instanceNamesAllowed;
   bsaveConstraints->instanceAddressesAllowed = constraints->instanceAddressesAllowed;
   bsaveConstraints->externalAddressesAllowed = constraints->externalAddressesAllowed;
   bsaveConstraints->multifieldsAllowed = constraints->multifieldsAllowed;
   bsaveConstraints->singlefieldsAllowed = constraints->singlefieldsAllowed;
   bsaveConstraints->factAddressesAllowed = constraints->factAddressesAllowed;
   bsaveConstraints->anyRestriction = constraints->anyRestriction;
   bsaveConstraints->symbolRestriction = constraints->symbolRestriction;
   bsaveConstraints->stringRestriction = constraints->stringRestriction;
   bsaveConstraints->floatRestriction = constraints->floatRestriction;
   bsaveConstraints->integerRestriction = constraints->integerRestriction;
   bsaveConstraints->classRestriction = constraints->classRestriction;
   bsaveConstraints->instanceNameRestriction = constraints->instanceNameRestriction;
   bsaveConstraints->restrictionList = HashedExpressionIndex(theEnv,constraints->restrictionList);
   bsaveConstraints->classList = HashedExpressionIndex(theEnv,constraints->classList);
   bsaveConstraints->minValue = HashedExpressionIndex(theEnv,constraints->minValue);
   bsaveConstraints->maxValue = HashedExpressionIndex(theEnv,constraints->maxValue);
   bsaveConstraints->minFields = HashedExpressionIndex(theEnv,constraints->minFields);
   bsaveConstraints->maxFields = HashedExpressionIndex(theEnv,constraints->maxFields);
  }

canonical_original_code:
static void CopyToBsaveConstraintRecord(void *theEnv, struct constraintRecord *constraints, struct bsaveConstraintRecord *bsaveConstraints)
  {
   bsaveConstraints->anyAllowed = constraints->anyAllowed;
   bsaveConstraints->symbolsAllowed = constraints->symbolsAllowed;
   bsaveConstraints->stringsAllowed = constraints->stringsAllowed;
   bsaveConstraints->floatsAllowed = constraints->floatsAllowed;
   bsaveConstraints->integersAllowed = constraints->integersAllowed;
   bsaveConstraints->instanceNamesAllowed = constraints->instanceNamesAllowed;
   bsaveConstraints->instanceAddressesAllowed = constraints->instanceAddressesAllowed;
   bsaveConstraints->externalAddressesAllowed = constraints->externalAddressesAllowed;
   bsaveConstraints->multifieldsAllowed = constraints->multifieldsAllowed;
   bsaveConstraints->singlefieldsAllowed = constraints->singlefieldsAllowed;
   bsaveConstraints->factAddressesAllowed = constraints->factAddressesAllowed;
   bsaveConstraints->anyRestriction = constraints->anyRestriction;
   bsaveConstraints->symbolRestriction = constraints->symbolRestriction;
   bsaveConstraints->stringRestriction = constraints->stringRestriction;
   bsaveConstraints->floatRestriction = constraints->floatRestriction;
   bsaveConstraints->integerRestriction = constraints->integerRestriction;
   bsaveConstraints->classRestriction = constraints->classRestriction;
   bsaveConstraints->instanceNameRestriction = constraints->instanceNameRestriction;
   bsaveConstraints->restrictionList = HashedExpressionIndex(theEnv,constraints->restrictionList);
   bsaveConstraints->classList = HashedExpressionIndex(theEnv,constraints->classList);
   bsaveConstraints->minValue = HashedExpressionIndex(theEnv,constraints->minValue);
   bsaveConstraints->maxValue = HashedExpressionIndex(theEnv,constraints->maxValue);
   bsaveConstraints->minFields = HashedExpressionIndex(theEnv,constraints->minFields);
   bsaveConstraints->maxFields = HashedExpressionIndex(theEnv,constraints->maxFields);
  }

variable_types:
theEnv
void *

user_defined_types: struct bsaveConstraintRecord { unsigned int anyAllowed; unsigned int symbolsAllowed; unsigned int stringsAllowed; unsigned int floatsAllowed; unsigned int integersAllowed; unsigned int instanceNamesAllowed; unsigned int instanceAddressesAllowed; unsigned int externalAddressesAllowed; unsigned int factAddressesAllowed; unsigned int anyRestriction; unsigned int symbolRestriction; unsigned int stringRestriction; unsigned int numberRestriction; unsigned int floatRestriction; unsigned int integerRestriction; unsigned int classRestriction; unsigned int instanceNameRestriction; unsigned int multifieldsAllowed; unsigned int singlefieldsAllowed; long classList; long restrictionList; long minValue; long maxValue; long minFields; long maxFields; }


ReadNeededConstraints

decompiled_code:
__int64 __fastcall ReadNeededConstraints(__int64 a1)
{
__int64 v1; // rbp
__int64 result; // rax

GenReadBinary(a1, *(_QWORD *)(*(_QWORD *)(a1 + 32) + 344LL) + 24LL, 8LL);
v1 = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 344LL);
result = *(_QWORD *)(v1 + 24);
if ( result )
{
*(_QWORD *)(v1 + 16) = genlongalloc(a1, 80 * result);
result = BloadandRefresh(
a1,
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 344LL) + 24LL),
56LL,
CopyFromBsaveConstraintRecord);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 v1; // rbp
__int64 result; // rax

GenReadBinary(a1, *(_QWORD *)(*(_QWORD *)(a1 + 32) + 344LL) + 24LL, 8LL);
v1 = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 344LL);
result = *(_QWORD *)(v1 + 24);
if ( result )
{
*(_QWORD *)(v1 + 16) = genlongalloc(a1, 80 * result);
result = BloadandRefresh(
a1,
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 344LL) + 24LL),
56LL,
CopyFromBsaveConstraintRecord);
}
return result;
}

original_code:
void ReadNeededConstraints(
  void *theEnv)
  {
   GenReadBinary(theEnv,(void *) &((struct constraintData *) (((struct environmentData *) theEnv)->theData[43]))->NumberOfConstraints,(unsigned long)
                                         sizeof(unsigned long int));
   if (((struct constraintData *) (((struct environmentData *) theEnv)->theData[43]))->NumberOfConstraints == 0) return;
   ((struct constraintData *) (((struct environmentData *) theEnv)->theData[43]))->ConstraintArray = (CONSTRAINT_RECORD *)
           genlongalloc(theEnv,(unsigned long) (sizeof(CONSTRAINT_RECORD) *
                                        ((struct constraintData *) (((struct environmentData *) theEnv)->theData[43]))->NumberOfConstraints));
   BloadandRefresh(theEnv,((struct constraintData *) (((struct environmentData *) theEnv)->theData[43]))->NumberOfConstraints,sizeof(BSAVE_CONSTRAINT_RECORD),
                   CopyFromBsaveConstraintRecord);
  }

canonical_original_code:
void ReadNeededConstraints(void *theEnv)
  {
   GenReadBinary(theEnv,(void *) &((struct constraintData *) (((struct environmentData *) theEnv)->theData[43]))->NumberOfConstraints,(unsigned long)
                                         sizeof(unsigned long));
   if (((struct constraintData *) (((struct environmentData *) theEnv)->theData[43]))->NumberOfConstraints == 0) return;
   ((struct constraintData *) (((struct environmentData *) theEnv)->theData[43]))->ConstraintArray = (struct constraintRecord *)
           genlongalloc(theEnv,(unsigned long) (sizeof(CONSTRAINT_RECORD) *
                                        ((struct constraintData *) (((struct environmentData *) theEnv)->theData[43]))->NumberOfConstraints));
   BloadandRefresh(theEnv,((struct constraintData *) (((struct environmentData *) theEnv)->theData[43]))->NumberOfConstraints,sizeof(BSAVE_CONSTRAINT_RECORD),
                   CopyFromBsaveConstraintRecord);
  }

user_defined_types: struct environmentData { unsigned int initialized; unsigned long environmentIndex; void *context; void *routerContext; void **theData; void (**cleanupFunctions)(void *); struct environmentCleanupFunction *listOfCleanupEnvironmentFunctions; struct environmentData *next; }

user_defined_types: struct environmentCleanupFunction { char *name; void (*func)(void *); int priority; struct environmentCleanupFunction *next; }


ClearBloadedConstraints

decompiled_code:
__int64 __fastcall ClearBloadedConstraints(__int64 a1)
{
__int64 v1; // rdx
__int64 result; // rax

v1 = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 344LL);
result = *(_QWORD *)(v1 + 24);
if ( result )
{
genlongfree(a1, *(_QWORD *)(v1 + 16), 80 * result);
result = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 344LL);
*(_QWORD *)(result + 24) = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
__int64 v1; // rdx
__int64 result; // rax

v1 = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 344LL);
result = *(_QWORD *)(v1 + 24);
if ( result )
{
genlongfree(a1, *(_QWORD *)(v1 + 16), 80 * result);
result = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 344LL);
*(_QWORD *)(result + 24) = 0LL;
}
return result;
}

original_code:
void ClearBloadedConstraints(
  void *theEnv)
  {
   if (((struct constraintData *) (((struct environmentData *) theEnv)->theData[43]))->NumberOfConstraints != 0)
     {
      genlongfree(theEnv,(void *) ((struct constraintData *) (((struct environmentData *) theEnv)->theData[43]))->ConstraintArray,
                  (unsigned long) (sizeof(CONSTRAINT_RECORD) *
                                  ((struct constraintData *) (((struct environmentData *) theEnv)->theData[43]))->NumberOfConstraints));
      ((struct constraintData *) (((struct environmentData *) theEnv)->theData[43]))->NumberOfConstraints = 0;
     }
  }

canonical_original_code:
void ClearBloadedConstraints(void *theEnv)
  {
   if (((struct constraintData *) (((struct environmentData *) theEnv)->theData[43]))->NumberOfConstraints != 0)
     {
      genlongfree(theEnv,(void *) ((struct constraintData *) (((struct environmentData *) theEnv)->theData[43]))->ConstraintArray,
                  (unsigned long) (sizeof(CONSTRAINT_RECORD) *
                                  ((struct constraintData *) (((struct environmentData *) theEnv)->theData[43]))->NumberOfConstraints));
      ((struct constraintData *) (((struct environmentData *) theEnv)->theData[43]))->NumberOfConstraints = 0;
     }
  }


NoSuchTemplateError

decompiled_code:
__int64 __fastcall NoSuchTemplateError(__int64 a1, __int64 a2)
{
PrintErrorID(a1, "FACTRHS", 1LL, 0LL);
EnvPrintRouter(a1, "werror", "Template ");
EnvPrintRouter(a1, "werror", a2);
return EnvPrintRouter(a1, "werror", " does not exist for assert.\n");
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
PrintErrorID(a1, "FACTRHS", 1LL, 0LL);
EnvPrintRouter(a1, "werror", "Template ");
EnvPrintRouter(a1, "werror", a2);
return EnvPrintRouter(a1, "werror", " does not exist for assert.\n");
}

original_code:
static void NoSuchTemplateError(
  void *theEnv,
  char *templateName)
  {
   PrintErrorID(theEnv,"FACTRHS",1,0);
   EnvPrintRouter(theEnv,"werror","Template ");
   EnvPrintRouter(theEnv,"werror",templateName);
   EnvPrintRouter(theEnv,"werror"," does not exist for assert.\n");
  }

canonical_original_code:
static void NoSuchTemplateError(void *theEnv, char *templateName)
  {
   PrintErrorID(theEnv,"FACTRHS",1,0);
   EnvPrintRouter(theEnv,"werror","Template ");
   EnvPrintRouter(theEnv,"werror",templateName);
   EnvPrintRouter(theEnv,"werror"," does not exist for assert.\n");
  }

variable_types:
templateName
char *


GetAssertArgument

decompiled_code:
__int64 __fastcall GetAssertArgument(__int64 a1, __int64 a2, unsigned __int16 *a3, _DWORD *a4, int a5, int a6, _DWORD *a7)
{
unsigned __int16 v11; // ax
__int64 v12; // r12

*a7 = 1;
GetToken();
v11 = *a3;
if ( *a3 == a5 )
return 0LL;
if ( v11 == 2 )
{
if ( strcmp(*(const char **)(*((_QWORD *)a3 + 1) + 24LL), "=") )
return GenConstant(a1, *a3, *((_QWORD *)a3 + 1));
if ( a6 )
{
LABEL_18:
*a4 = 1;
return 0LL;
}
v12 = Function0Parse(a1, a2);
}
else
{
if ( v11 != 170 )
{
if ( v11 != 8 && v11 > 3u )
{
if ( (unsigned __int16)(v11 - 33) > 3u )
{
*a4 = 1;
return 0LL;
}
if ( a6 )
{
*a4 = 1;
return 0LL;
}
}
return GenConstant(a1, *a3, *((_QWORD *)a3 + 1));
}
if ( a6 )
goto LABEL_18;
v12 = Function1Parse(a1, a2);
}
if ( v12 )
{
*a3 = 171;
*((_QWORD *)a3 + 1) = EnvAddSymbol(a1, ")");
*((_QWORD *)a3 + 2) = ")";
}
else
{
*a7 = 0;
*a4 = 1;
}
return v12;
}

original_code:
struct expr *GetAssertArgument(
  void *theEnv,
  char *logicalName,
  struct token *theToken,
  int *error,
  int endType,
  int constantsOnly,
  int *printError)
  {
   struct expr *nextField;
   *printError = 1;
   GetToken(theEnv,logicalName,theToken);
   if (theToken->type == endType) return(((void *)0));
   if ((theToken->type == 2) ?
       (strcmp((((struct symbolHashNode *) (theToken->value))->contents),"=") == 0) :
       (theToken->type == 170))
     {
      if (constantsOnly)
        {
         *error = 1;
         return(((void *)0));
        }
      if (theToken->type == 170) nextField = Function1Parse(theEnv,logicalName);
      else nextField = Function0Parse(theEnv,logicalName);
      if (nextField == ((void *)0))
        {
         *printError = 0;
         *error = 1;
        }
      else
        {
         theToken->type= 171;
         theToken->value = (void *) EnvAddSymbol(theEnv,")");
         theToken->printForm = ")";
        }
      return(nextField);
     }
   if ((theToken->type == 2) || (theToken->type == 3) ||
           (theToken->type == 8) ||
           (theToken->type == 0) || (theToken->type == 1))
     { return(GenConstant(theEnv,theToken->type,theToken->value)); }
   if ((theToken->type == 35) ||
            (theToken->type == 33) ||
            (theToken->type == 34) ||
            (theToken->type == 36))
     {
      if (constantsOnly)
        {
         *error = 1;
         return(((void *)0));
        }
      return(GenConstant(theEnv,theToken->type,theToken->value));
     }
   *error = 1;
   return(((void *)0));
  }

canonical_original_code:
struct expr *GetAssertArgument(void *theEnv, char *logicalName, struct token *theToken, int *error, int endType, int constantsOnly, int *printError)
  {
   struct expr *nextField;
   *printError = 1;
   GetToken(theEnv,logicalName,theToken);
   if (theToken->type == endType) return(((void *)0));
   if ((theToken->type == 2) ?
       (strcmp((((struct symbolHashNode *) (theToken->value))->contents),"=") == 0) :
       (theToken->type == 170))
     {
      if (constantsOnly)
        {
         *error = 1;
         return(((void *)0));
        }
      if (theToken->type == 170) nextField = Function1Parse(theEnv,logicalName);
      else nextField = Function0Parse(theEnv,logicalName);
      if (nextField == ((void *)0))
        {
         *printError = 0;
         *error = 1;
        }
      else
        {
         theToken->type= 171;
         theToken->value = (void *) EnvAddSymbol(theEnv,")");
         theToken->printForm = ")";
        }
      return(nextField);
     }
   if ((theToken->type == 2) || (theToken->type == 3) ||
           (theToken->type == 8) ||
           (theToken->type == 0) || (theToken->type == 1))
     { return(GenConstant(theEnv,theToken->type,theToken->value)); }
   if ((theToken->type == 35) ||
            (theToken->type == 33) ||
            (theToken->type == 34) ||
            (theToken->type == 36))
     {
      if (constantsOnly)
        {
         *error = 1;
         return(((void *)0));
        }
      return(GenConstant(theEnv,theToken->type,theToken->value));
     }
   *error = 1;
   return(((void *)0));
  }

variable_types:
logicalName
char *

variable_types: struct token { unsigned short type; void *value; char *printForm; } *

variable_types:
error
int *

variable_types: endType int

variable_types: constantsOnly int

variable_types:
printError
int *

variable_types: struct expr { unsigned short type; void *value; struct expr *argList; struct expr *nextArg; } *