SkipFactPatternNode

decompiled_code:
__int64 __fastcall SkipFactPatternNode(__int64 a1, __int64 a2)
{
__int64 result; // rax

result = *(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 144LL) + 68LL);
if ( (_DWORD)result )
result = ((*(_BYTE *)(a2 + 24) >> 3) ^ 1) & 1;
return result;
}

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

result = *(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 144LL) + 68LL);
if ( (_DWORD)result )
result = ((*(_BYTE *)(a2 + 24) >> 3) ^ 1) & 1;
return result;
}

original_code:
static int SkipFactPatternNode(
  void *theEnv,
  struct factPatternNode *thePattern)
  {
   if (((struct engineData *) (((struct environmentData *) theEnv)->theData[18]))->IncrementalResetInProgress &&
       (thePattern->header.initialize == 0))
     { return(1); }
   return(0);
  }

canonical_original_code:
static int SkipFactPatternNode(void *theEnv, struct factPatternNode *thePattern)
  {
   if (((struct engineData *) (((struct environmentData *) theEnv)->theData[18]))->IncrementalResetInProgress &&
       (thePattern->header.initialize == 0))
     { return(1); }
   return(0);
  }

variable_types: struct factPatternNode { struct patternNodeHeader { 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]; } *alphaMemory; struct partialMatch *endOfQueue; 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 { unsigned short type; void *value; struct expr *argList; struct expr *nextArg; } *networkTest; void *rightSideEntryStructure; struct joinNode *nextLevel; struct joinNode *lastLevel; struct joinNode *rightDriveNode; struct joinNode *rightMatchNode; struct defrule { 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 *usrData; struct defmodule *next; } *theModule; struct constructHeader *firstItem; struct constructHeader *lastItem; } *whichModule; long bsaveID; struct constructHeader *next; struct userData *usrData; } 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; } *ruleToActivate; } *entryJoin; unsigned int singlefieldNode; unsigned int multifieldNode; unsigned int stopNode; unsigned int initialize; unsigned int marked; unsigned int beginSlot; unsigned int endSlot; } header; long bsaveID; unsigned short whichField; unsigned short whichSlot; unsigned short leaveFields; struct expr *networkTest; struct factPatternNode *nextLevel; struct factPatternNode *lastLevel; struct factPatternNode *leftNode; struct factPatternNode *rightNode; } *

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 dependency { void *dPtr; struct dependency *next; }

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

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 defruleModule { struct defmoduleItemHeader header; struct activation *agenda; }

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


TraceErrorToJoin

repo: jarcec/rbclips

decompiled_code:
void __fastcall TraceErrorToJoin(__int64 a1, __int64 a2, int a3)
{
__int64 v4; // r13
__int64 i; // rbx
unsigned int v6; // eax
char v7[120]; // [rsp-78h] [rbp-78h] BYREF

if ( a2 )
{
v4 = a2;
do
{
if ( (*(_BYTE *)(v4 + 24) & 4) != 0 )
{
for ( i = *(_QWORD *)(v4 + 16); i; i = *(_QWORD *)(i + 64) )
{
v6 = GetPatternNumberFromJoin(i);
sprintf(v7, " Of pattern #%d in rule(s):\n", v6);
EnvPrintRouter(a1, "werror", v7);
TraceErrorToRule(a1, i, " ");
}
}
else
{
TraceErrorToJoin(a1, *(_QWORD *)(v4 + 56), 1LL);
}
if ( !a3 )
break;
v4 = *(_QWORD *)(v4 + 80);
}
while ( v4 );
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, __int64 a2, int a3)
{
__int64 v4; // r13
__int64 i; // rbx
unsigned int v6; // eax
char v7[120]; // [rsp-78h] [rbp-78h] BYREF

if ( a2 )
{
v4 = a2;
do
{
if ( (*(_BYTE *)(v4 + 24) & 4) != 0 )
{
for ( i = *(_QWORD *)(v4 + 16); i; i = *(_QWORD *)(i + 64) )
{
v6 = GetPatternNumberFromJoin(i);
sprintf(v7, " Of pattern #%d in rule(s):\n", v6);
EnvPrintRouter(a1, "werror", v7);
TraceErrorToRule(a1, i, " ");
}
}
else
{
func2(a1, *(_QWORD *)(v4 + 56), 1LL);
}
if ( !a3 )
break;
v4 = *(_QWORD *)(v4 + 80);
}
while ( v4 );
}
}

original_code:
static void TraceErrorToJoin(
  void *theEnv,
  struct factPatternNode *patternPtr,
  int traceRight)
  {
   struct joinNode *joinPtr;
   char buffer[60];
   while (patternPtr != ((void *)0))
     {
      if (patternPtr->header.stopNode)
        {
         for (joinPtr = patternPtr->header.entryJoin;
              joinPtr != ((void *)0);
              joinPtr = joinPtr->rightMatchNode)
           {
            sprintf(buffer,"      Of pattern #%d in rule(s):\n",GetPatternNumberFromJoin(joinPtr));
            EnvPrintRouter(theEnv,"werror",buffer);
            TraceErrorToRule(theEnv,joinPtr,"         ");
           }
        }
      else
        { TraceErrorToJoin(theEnv,patternPtr->nextLevel,1); }
      if (traceRight) patternPtr = patternPtr->rightNode;
      else patternPtr = ((void *)0);
     }
  }

canonical_original_code:
static void TraceErrorToJoin(void *theEnv, struct factPatternNode *patternPtr, int traceRight)
  {
   struct joinNode *joinPtr;
   char buffer[60];
   while (patternPtr != ((void *)0))
     {
      if (patternPtr->header.stopNode)
        {
         for (joinPtr = patternPtr->header.entryJoin;
              joinPtr != ((void *)0);
              joinPtr = joinPtr->rightMatchNode)
           {
            sprintf(buffer,"      Of pattern #%d in rule(s):\n",GetPatternNumberFromJoin(joinPtr));
            EnvPrintRouter(theEnv,"werror",buffer);
            TraceErrorToRule(theEnv,joinPtr,"         ");
           }
        }
      else
        { TraceErrorToJoin(theEnv,patternPtr->nextLevel,1); }
      if (traceRight) patternPtr = patternPtr->rightNode;
      else patternPtr = ((void *)0);
     }
  }

variable_types:
theEnv
void *

variable_types: traceRight int

variable_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 { 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]; } *beta; struct expr { unsigned short type; void *value; struct expr *argList; struct expr *nextArg; } *networkTest; void *rightSideEntryStructure; struct joinNode *nextLevel; struct joinNode *lastLevel; struct joinNode *rightDriveNode; struct joinNode *rightMatchNode; struct defrule { 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 *usrData; struct defmodule *next; } *theModule; struct constructHeader *firstItem; struct constructHeader *lastItem; } *whichModule; long bsaveID; struct constructHeader *next; struct userData *usrData; } 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; } *ruleToActivate; } *

variable_types:
buffer
char [60]

return_type: void

user_defined_types: struct factPatternNode { struct patternNodeHeader header; long bsaveID; unsigned short whichField; unsigned short whichSlot; unsigned short leaveFields; struct expr *networkTest; struct factPatternNode *nextLevel; struct factPatternNode *lastLevel; struct factPatternNode *leftNode; struct factPatternNode *rightNode; }

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 patternNodeHeader { struct partialMatch *alphaMemory; struct partialMatch *endOfQueue; struct joinNode *entryJoin; unsigned int singlefieldNode; unsigned int multifieldNode; unsigned int stopNode; unsigned int initialize; unsigned int marked; unsigned int beginSlot; unsigned int endSlot; }

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 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 constructHeader { struct symbolHashNode *name; char *ppForm; struct defmoduleItemHeader *whichModule; long bsaveID; struct constructHeader *next; struct userData *usrData; }

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

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

user_defined_types: struct alphaMatch { struct patternEntity *matchingItem; struct multifieldMarker *markers; struct alphaMatch *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 patternEntity { struct patternEntityRecord *theInfo; void *dependents; unsigned int busyCount; long timeTag; }

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


MarkFactPatternForIncrementalReset

decompiled_code:
__int64 __fastcall MarkFactPatternForIncrementalReset(__int64 a1, __int64 a2, char a3)
{
int v3; // edx
__int64 result; // rax

v3 = 8 * (a3 & 1);
if ( (*(_BYTE *)(a2 + 24) & 8) != 0 )
{
do
{
result = v3 | *(_BYTE *)(a2 + 24) & 0xF7u;
*(_BYTE *)(a2 + 24) = v3 | *(_BYTE *)(a2 + 24) & 0xF7;
a2 = *(_QWORD *)(a2 + 64);
}
while ( a2 );
}
return result;
}

original_code:
void MarkFactPatternForIncrementalReset(
  void *theEnv,
  struct patternNodeHeader *thePattern,
  int value)
  {
   struct factPatternNode *patternPtr = (struct factPatternNode *) thePattern;
   ;
   if (patternPtr->header.initialize == 0) return;
   while (patternPtr != ((void *)0))
     {
      patternPtr->header.initialize = value;
      patternPtr = patternPtr->lastLevel;
     }
  }

canonical_original_code:
void MarkFactPatternForIncrementalReset(void *theEnv, struct patternNodeHeader *thePattern, int value)
  {
   struct factPatternNode *patternPtr = (struct factPatternNode *) thePattern;
   ;
   if (patternPtr->header.initialize == 0) return;
   while (patternPtr != ((void *)0))
     {
      patternPtr->header.initialize = value;
      patternPtr = patternPtr->lastLevel;
     }
  }

variable_types: struct patternNodeHeader { 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]; } *alphaMemory; struct partialMatch *endOfQueue; 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 { unsigned short type; void *value; struct expr *argList; struct expr *nextArg; } *networkTest; void *rightSideEntryStructure; struct joinNode *nextLevel; struct joinNode *lastLevel; struct joinNode *rightDriveNode; struct joinNode *rightMatchNode; struct defrule { 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 *usrData; struct defmodule *next; } *theModule; struct constructHeader *firstItem; struct constructHeader *lastItem; } *whichModule; long bsaveID; struct constructHeader *next; struct userData *usrData; } 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; } *ruleToActivate; } *entryJoin; unsigned int singlefieldNode; unsigned int multifieldNode; unsigned int stopNode; unsigned int initialize; unsigned int marked; unsigned int beginSlot; unsigned int endSlot; } *

variable_types: value int


FactsIncrementalReset

decompiled_code:
__int64 __fastcall FactsIncrementalReset(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rbp

result = EnvGetNextFact(a1, 0LL);
if ( result )
{
v2 = result;
do
{
FactPatternMatch(a1, v2, *(_QWORD *)(*(_QWORD *)(v2 + 32) + 72LL), 0, 0LL, 0LL);
result = EnvGetNextFact(a1, v2);
v2 = result;
}
while ( result );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rbp

result = EnvGetNextFact(a1, 0LL);
if ( result )
{
v2 = result;
do
{
func5(a1, v2, *(_QWORD *)(*(_QWORD *)(v2 + 32) + 72LL), 0, 0LL, 0LL);
result = EnvGetNextFact(a1, v2);
v2 = result;
}
while ( result );
}
return result;
}

original_code:
void FactsIncrementalReset(
  void *theEnv)
  {
   struct fact *factPtr;
   for (factPtr = (struct fact *) EnvGetNextFact(theEnv,((void *)0));
        factPtr != ((void *)0);
        factPtr = (struct fact *) EnvGetNextFact(theEnv,factPtr))
     {
      FactPatternMatch(theEnv,factPtr,
                       factPtr->whichDeftemplate->patternNetwork,
                       0,((void *)0),((void *)0));
     }
  }

canonical_original_code:
void FactsIncrementalReset(void *theEnv)
  {
   struct fact *factPtr;
   for (factPtr = (struct fact *) EnvGetNextFact(theEnv,((void *)0));
        factPtr != ((void *)0);
        factPtr = (struct fact *) EnvGetNextFact(theEnv,factPtr))
     {
      FactPatternMatch(theEnv,factPtr,
                       factPtr->whichDeftemplate->patternNetwork,
                       0,((void *)0),((void *)0));
     }
  }

variable_types: struct fact { 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; } factHeader; struct deftemplate { 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 *usrData; struct defmodule *next; } *theModule; struct constructHeader *firstItem; struct constructHeader *lastItem; } *whichModule; long bsaveID; struct constructHeader *next; struct userData *usrData; } header; struct templateSlot { struct symbolHashNode *slotName; unsigned int multislot; unsigned int noDefault; unsigned int defaultPresent; unsigned int defaultDynamic; 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; } *constraints; struct expr *defaultList; struct templateSlot *next; } *slotList; unsigned int implied; unsigned int watch; unsigned int inScope; unsigned short numberOfSlots; long busyCount; struct factPatternNode { struct patternNodeHeader { 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 *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]; } *alphaMemory; struct partialMatch *endOfQueue; 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 { 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; } *ruleToActivate; } *entryJoin; unsigned int singlefieldNode; unsigned int multifieldNode; unsigned int stopNode; unsigned int initialize; unsigned int marked; unsigned int beginSlot; unsigned int endSlot; } header; long bsaveID; unsigned short whichField; unsigned short whichSlot; unsigned short leaveFields; struct expr *networkTest; struct factPatternNode *nextLevel; struct factPatternNode *lastLevel; struct factPatternNode *leftNode; struct factPatternNode *rightNode; } *patternNetwork; struct fact *factList; struct fact *lastFact; } *whichDeftemplate; void *list; long factIndex; unsigned int depth; unsigned int garbage; struct fact *previousFact; struct fact *nextFact; struct fact *previousTemplateFact; struct fact *nextTemplateFact; struct multifield { unsigned int busyCount; short depth; unsigned long multifieldLength; struct multifield *next; struct field { unsigned short type; void *value; } theFields[1]; } theProposition; } *

user_defined_types: struct fact { struct patternEntity factHeader; struct deftemplate *whichDeftemplate; void *list; long factIndex; unsigned int depth; unsigned int garbage; struct fact *previousFact; struct fact *nextFact; struct fact *previousTemplateFact; struct fact *nextTemplateFact; struct multifield theProposition; }

user_defined_types: struct multifield { unsigned int busyCount; short depth; unsigned long multifieldLength; struct multifield *next; struct field theFields[1]; }

user_defined_types: struct deftemplate { struct constructHeader header; struct templateSlot *slotList; unsigned int implied; unsigned int watch; unsigned int inScope; unsigned short numberOfSlots; long busyCount; struct factPatternNode *patternNetwork; struct fact *factList; struct fact *lastFact; }

user_defined_types: struct templateSlot { struct symbolHashNode *slotName; unsigned int multislot; unsigned int noDefault; unsigned int defaultPresent; unsigned int defaultDynamic; struct constraintRecord *constraints; struct expr *defaultList; struct templateSlot *next; }

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


ReturnDeffacts

decompiled_code:
__int64 __fastcall ReturnDeffacts(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rdx
__int64 result; // rax

if ( a2 )
{
ExpressionDeinstall(a1, *(_QWORD *)(a2 + 48));
ReturnPackedExpression(a1, *(_QWORD *)(a2 + 48));
DeinstallConstructHeader(a1, a2);
v2 = *(_QWORD *)(a1 + 32);
*(_QWORD *)(*(_QWORD *)(v2 + 472) + 32LL) = a2;
**(_QWORD **)(*(_QWORD *)(v2 + 472) + 32LL) = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(v2 + 472) + 40LL) + 448LL);
v3 = *(_QWORD *)(v2 + 472);
v4 = *(_QWORD *)(v3 + 32);
result = *(_QWORD *)(v3 + 40);
*(_QWORD *)(result + 448) = v4;
}
return result;
}

original_code:
static void ReturnDeffacts(
  void *theEnv,
  void *vTheDeffacts)
  {
   struct deffacts *theDeffacts = (struct deffacts *) vTheDeffacts;
   if (theDeffacts == ((void *)0)) return;
   ExpressionDeinstall(theEnv,theDeffacts->assertList);
   ReturnPackedExpression(theEnv,theDeffacts->assertList);
   DeinstallConstructHeader(theEnv,&theDeffacts->header);
   (((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = (struct memoryPtr *) theDeffacts, ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct deffacts)], ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct deffacts)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr);
  }

canonical_original_code:
static void ReturnDeffacts(void *theEnv, void *vTheDeffacts)
  {
   struct deffacts *theDeffacts = (struct deffacts *) vTheDeffacts;
   if (theDeffacts == ((void *)0)) return;
   ExpressionDeinstall(theEnv,theDeffacts->assertList);
   ReturnPackedExpression(theEnv,theDeffacts->assertList);
   DeinstallConstructHeader(theEnv,&theDeffacts->header);
   (((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = (struct memoryPtr *) theDeffacts, ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct deffacts)], ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct deffacts)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr);
  }

variable_types:
vTheDeffacts
void *

variable_types: struct deffacts { 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; struct expr { unsigned short type; void *value; struct expr *argList; struct expr *nextArg; } *assertList; } *

user_defined_types: struct deffacts { struct constructHeader header; struct expr *assertList; }

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 environmentCleanupFunction { char *name; void (*func)(void *); int priority; struct environmentCleanupFunction *next; }


DestroyDeffactsAction

original_code:
static void DestroyDeffactsAction(
  void *theEnv,
  struct constructHeader *theConstruct,
  void *buffer)
  {
   struct deffacts *theDeffacts = (struct deffacts *) theConstruct;
   if (theDeffacts == ((void *)0)) return;
   ReturnPackedExpression(theEnv,theDeffacts->assertList);
   DestroyConstructHeader(theEnv,&theDeffacts->header);
   (((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = (struct memoryPtr *) theDeffacts, ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct deffacts)], ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct deffacts)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr);
  }

canonical_original_code:
static void DestroyDeffactsAction(void *theEnv, struct constructHeader *theConstruct, void *buffer)
  {
   struct deffacts *theDeffacts = (struct deffacts *) theConstruct;
   if (theDeffacts == ((void *)0)) return;
   ReturnPackedExpression(theEnv,theDeffacts->assertList);
   DestroyConstructHeader(theEnv,&theDeffacts->header);
   (((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = (struct memoryPtr *) theDeffacts, ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct deffacts)], ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct deffacts)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr);
  }

variable_types: 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; } *

variable_types:
buffer
void *

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

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


ReturnModule

original_code:
static void ReturnModule(
  void *theEnv,
  void *theItem)
  {
   FreeConstructHeaderModule(theEnv,(struct defmoduleItemHeader *) theItem,((struct defclassData *) (((struct environmentData *) theEnv)->theData[21]))->DefclassConstruct);
   DeleteSlotName(theEnv,FindIDSlotNameHash(theEnv,0));
   DeleteSlotName(theEnv,FindIDSlotNameHash(theEnv,1));
   (((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = (struct memoryPtr *) theItem, ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct defclassModule)], ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct defclassModule)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr);
  }

canonical_original_code:
static void ReturnModule(void *theEnv, void *theItem)
  {
   FreeConstructHeaderModule(theEnv,(struct defmoduleItemHeader *) theItem,((struct defclassData *) (((struct environmentData *) theEnv)->theData[21]))->DefclassConstruct);
   DeleteSlotName(theEnv,FindIDSlotNameHash(theEnv,0));
   DeleteSlotName(theEnv,FindIDSlotNameHash(theEnv,1));
   (((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = (struct memoryPtr *) theItem, ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct defclassModule)], ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct defclassModule)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr);
  }

variable_types:
theItem
void *

user_defined_types: struct defclassModule { struct defmoduleItemHeader header; }

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

user_defined_types: struct defclassData { struct construct *DefclassConstruct; int DefclassModuleIndex; struct entityRecord DefclassEntityRecord; struct defclass *PrimitiveClassMap[9]; struct defclass **ClassIDMap; struct defclass **ClassTable; unsigned short MaxClassID; unsigned short AvailClassID; struct slotName **SlotNameTable; struct symbolHashNode *ISA_SYMBOL; struct symbolHashNode *NAME_SYMBOL; struct symbolHashNode *INITIAL_OBJECT_SYMBOL; unsigned int WatchInstances; unsigned int WatchSlots; unsigned short CTID; struct token ObjectParseToken; unsigned short ClassDefaultsMode; }

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

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 defclass { struct constructHeader header; unsigned int installed; unsigned int system; unsigned int abstract; unsigned int reactive; unsigned int traceInstances; unsigned int traceSlots; unsigned short id; unsigned int busy; struct packedClassLinks directSuperclasses; struct slotDescriptor *slots; unsigned int *slotNameMap; unsigned int slotCount; struct instance *instanceList; struct messageHandler *handlers; unsigned int *handlerOrderMap; unsigned int handlerCount; struct defclass *nxtHash; struct bitMapHashNode *scopeMap; char traversalRecord[32]; }

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 portItem { struct symbolHashNode *moduleName; struct symbolHashNode *constructType; struct symbolHashNode *constructName; struct portItem *next; }

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

user_defined_types: struct packedClassLinks { unsigned short classCount; struct defclass **classArray; }

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

user_defined_types: struct slotDescriptor { unsigned int shared; unsigned int multiple; unsigned int composite; unsigned int noInherit; unsigned int noWrite; unsigned int initializeOnly; unsigned int dynamicDefault; unsigned int defaultSpecified; unsigned int noDefault; unsigned int reactive; unsigned int publicVisibility; unsigned int createReadAccessor; unsigned int createWriteAccessor; unsigned int overrideMessageSpecified; struct defclass *cls; struct slotName *slotName; struct symbolHashNode *overrideMessage; void *defaultValue; struct constraintRecord *constraint; unsigned int sharedCount; long bsaveIndex; struct instanceSlot sharedValue; }

user_defined_types: struct instance { struct patternEntity header; void *partialMatchList; struct instanceSlot *basisSlots; unsigned int installed; unsigned int garbage; unsigned int initSlotsCalled; unsigned int initializeInProgress; unsigned int reteSynchronized; struct symbolHashNode *name; int depth; unsigned int hashTableIndex; unsigned int busy; struct defclass *cls; struct instance *prvClass; struct instanceSlot **slotAddresses; }

user_defined_types: struct messageHandler { unsigned int system; unsigned int type; unsigned int mark; unsigned int trace; unsigned int busy; struct symbolHashNode *name; struct defclass *cls; int minParams; struct expr *actions; char *ppForm; struct userData *usrData; }

user_defined_types: struct bitMapHashNode { struct bitMapHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int neededBitMap; unsigned int bucket; char *contents; unsigned short size; }

user_defined_types: struct instanceSlot { struct slotDescriptor *desc; unsigned int valueRequired; unsigned int override; unsigned int type; void *value; }

user_defined_types: struct slotName { unsigned int hashTableIndex; struct symbolHashNode *name; struct slotName *nxt; long bsaveIndex; }


EnvIsDeffactsDeletable

decompiled_code:
__int64 __fastcall EnvIsDeffactsDeletable(__int64 a1)
{
__int64 result; // rax

result = ConstructsDeletable();
if ( (_DWORD)result )
result = *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 336LL) + 12LL) == 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
__int64 result; // rax

result = ConstructsDeletable();
if ( (_DWORD)result )
result = *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 336LL) + 12LL) == 0;
return result;
}

original_code:
int EnvIsDeffactsDeletable(
  void *theEnv,
  void *ptr)
  {
   if (! ConstructsDeletable(theEnv))
     { return 0; }
   if (((struct constructData *) (((struct environmentData *) theEnv)->theData[42]))->ResetInProgress) return(0);
   return(1);
  }

canonical_original_code:
int EnvIsDeffactsDeletable(void *theEnv, void *ptr)
  {
   if (! ConstructsDeletable(theEnv))
     { return 0; }
   if (((struct constructData *) (((struct environmentData *) theEnv)->theData[42]))->ResetInProgress) return(0);
   return(1);
  }

variable_types:
ptr
void *

return_type: int

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 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 callFunctionItem { char *name; void (*func)(void *); int priority; struct callFunctionItem *next; short environmentAware; }

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

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


SaveDefmodules

decompiled_code:
__int64 __fastcall SaveDefmodules(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

result = EnvGetDefmodulePPForm();
if ( result )
{
PrintInChunks(a1, a3, result);
result = EnvPrintRouter(a1, a3, &LC0);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

result = EnvGetDefmodulePPForm();
if ( result )
{
PrintInChunks(a1, a3, result);
result = EnvPrintRouter(a1, a3, &LC0);
}
return result;
}

original_code:
static void SaveDefmodules(
  void *theEnv,
  void *theModule,
  char *logicalName)
  {
   char *ppform;
   ppform = EnvGetDefmodulePPForm(theEnv,theModule);
   if (ppform != ((void *)0))
     {
      PrintInChunks(theEnv,logicalName,ppform);
      EnvPrintRouter(theEnv,logicalName,"\n");
     }
  }

canonical_original_code:
static void SaveDefmodules(void *theEnv, void *theModule, char *logicalName)
  {
   char *ppform;
   ppform = EnvGetDefmodulePPForm(theEnv,theModule);
   if (ppform != ((void *)0))
     {
      PrintInChunks(theEnv,logicalName,ppform);
      EnvPrintRouter(theEnv,logicalName,"\n");
     }
  }

variable_types:
theModule
void *

variable_types:
logicalName
char *

variable_types:
ppform
char *


EnvGetDefmoduleList

decompiled_code:
__int64 __fastcall EnvGetDefmoduleList(__int64 a1, __int64 a2)
{
return OldGetConstructList(a1, a2, &EnvGetNextDefmodule, &EnvGetDefmoduleName);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
return OldGetConstructList(a1, a2, &EnvGetNextDefmodule, &EnvGetDefmoduleName);
}

original_code:
void EnvGetDefmoduleList(
  void *theEnv,
  DATA_OBJECT_PTR returnValue)
  {
   OldGetConstructList(theEnv,returnValue,EnvGetNextDefmodule,EnvGetDefmoduleName);
  }

canonical_original_code:
void EnvGetDefmoduleList(void *theEnv, struct dataObject *returnValue)
  {
   OldGetConstructList(theEnv,returnValue,EnvGetNextDefmodule,EnvGetDefmoduleName);
  }

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


DefmoduleBasicCommands

decompiled_code:
__int64 __fastcall DefmoduleBasicCommands(__int64 a1)
{
EnvAddClearFunction(a1, "defmodule", ClearDefmodules, 2000LL);
AddSaveFunction(a1, "defmodule", SaveDefmodules, 1100LL);
EnvDefineFunction2(a1, "get-defmodule-list", 109LL, EnvGetDefmoduleList, "EnvGetDefmoduleList", "00");
EnvDefineFunction2(a1, "list-defmodules", 118LL, ListDefmodulesCommand, "ListDefmodulesCommand", "00");
EnvDefineFunction2(a1, "ppdefmodule", 118LL, PPDefmoduleCommand, "PPDefmoduleCommand", "11w");
DefmoduleBinarySetup(a1);
return DefmoduleCompilerSetup(a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
EnvAddClearFunction(a1, "defmodule", ClearDefmodules, 2000LL);
AddSaveFunction(a1, "defmodule", SaveDefmodules, 1100LL);
EnvDefineFunction2(a1, "get-defmodule-list", 109LL, EnvGetDefmoduleList, "EnvGetDefmoduleList", "00");
EnvDefineFunction2(a1, "list-defmodules", 118LL, ListDefmodulesCommand, "ListDefmodulesCommand", "00");
EnvDefineFunction2(a1, "ppdefmodule", 118LL, PPDefmoduleCommand, "PPDefmoduleCommand", "11w");
DefmoduleBinarySetup(a1);
return DefmoduleCompilerSetup(a1);
}

original_code:
void DefmoduleBasicCommands(
  void *theEnv)
  {
   EnvAddClearFunction(theEnv,"defmodule",ClearDefmodules,2000);
   AddSaveFunction(theEnv,"defmodule",SaveDefmodules,1100);
   EnvDefineFunction2(theEnv,"get-defmodule-list",'m',(int (*)(void *)) EnvGetDefmoduleList,"EnvGetDefmoduleList","00");
   EnvDefineFunction2(theEnv,"list-defmodules",'v', (int (*)(void *)) ListDefmodulesCommand,"ListDefmodulesCommand","00");
   EnvDefineFunction2(theEnv,"ppdefmodule",'v',(int (*)(void *)) PPDefmoduleCommand,"PPDefmoduleCommand","11w");
   DefmoduleBinarySetup(theEnv);
   DefmoduleCompilerSetup(theEnv);
  }

canonical_original_code:
void DefmoduleBasicCommands(void *theEnv)
  {
   EnvAddClearFunction(theEnv,"defmodule",ClearDefmodules,2000);
   AddSaveFunction(theEnv,"defmodule",SaveDefmodules,1100);
   EnvDefineFunction2(theEnv,"get-defmodule-list",'m',(int (*)(void *)) EnvGetDefmoduleList,"EnvGetDefmoduleList","00");
   EnvDefineFunction2(theEnv,"list-defmodules",'v', (int (*)(void *)) ListDefmodulesCommand,"ListDefmodulesCommand","00");
   EnvDefineFunction2(theEnv,"ppdefmodule",'v',(int (*)(void *)) PPDefmoduleCommand,"PPDefmoduleCommand","11w");
   DefmoduleBinarySetup(theEnv);
   DefmoduleCompilerSetup(theEnv);
  }

variable_types:
theEnv
void *


PPDefmodule

decompiled_code:
__int64 __fastcall PPDefmodule(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // r12
__int64 v6; // rax
__int64 result; // rax

v4 = EnvFindDefmodule();
if ( v4 )
{
v5 = v4;
if ( EnvGetDefmodulePPForm(a1, v4) )
{
v6 = EnvGetDefmodulePPForm(a1, v5);
PrintInChunks(a1, a3, v6);
}
result = 1LL;
}
else
{
CantFindItemErrorMessage(a1, "defmodule", a2);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // r12
__int64 v6; // rax
__int64 result; // rax

v4 = EnvFindDefmodule();
if ( v4 )
{
v5 = v4;
if ( EnvGetDefmodulePPForm(a1, v4) )
{
v6 = EnvGetDefmodulePPForm(a1, v5);
PrintInChunks(a1, a3, v6);
}
result = 1LL;
}
else
{
CantFindItemErrorMessage(a1, "defmodule", a2);
result = 0LL;
}
return result;
}

original_code:
int PPDefmodule(
  void *theEnv,
  char *defmoduleName,
  char *logicalName)
  {
   void *defmodulePtr;
   defmodulePtr = EnvFindDefmodule(theEnv,defmoduleName);
   if (defmodulePtr == ((void *)0))
     {
      CantFindItemErrorMessage(theEnv,"defmodule",defmoduleName);
      return(0);
     }
   if (EnvGetDefmodulePPForm(theEnv,defmodulePtr) == ((void *)0)) return(1);
   PrintInChunks(theEnv,logicalName,EnvGetDefmodulePPForm(theEnv,defmodulePtr));
   return(1);
  }

canonical_original_code:
int PPDefmodule(void *theEnv, char *defmoduleName, char *logicalName)
  {
   void *defmodulePtr;
   defmodulePtr = EnvFindDefmodule(theEnv,defmoduleName);
   if (defmodulePtr == ((void *)0))
     {
      CantFindItemErrorMessage(theEnv,"defmodule",defmoduleName);
      return(0);
     }
   if (EnvGetDefmodulePPForm(theEnv,defmodulePtr) == ((void *)0)) return(1);
   PrintInChunks(theEnv,logicalName,EnvGetDefmodulePPForm(theEnv,defmodulePtr));
   return(1);
  }

variable_types:
defmoduleName
char *

variable_types:
defmodulePtr
void *


PPDefmoduleCommand

decompiled_code:
__int64 __fastcall PPDefmoduleCommand(__int64 a1)
{
__int64 result; // rax

result = GetConstructName(a1, "ppdefmodule", "defmodule name");
if ( result )
result = PPDefmodule(a1, result, (__int64)"wdisplay");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 result; // rax

result = GetConstructName(a1, "ppdefmodule", "defmodule name");
if ( result )
result = func4(a1, result, (__int64)"wdisplay");
return result;
}

original_code:
void PPDefmoduleCommand(
  void *theEnv)
  {
   char *defmoduleName;
   defmoduleName = GetConstructName(theEnv,"ppdefmodule","defmodule name");
   if (defmoduleName == ((void *)0)) return;
   PPDefmodule(theEnv,defmoduleName,"wdisplay");
   return;
  }

canonical_original_code:
void PPDefmoduleCommand(void *theEnv)
  {
   char *defmoduleName;
   defmoduleName = GetConstructName(theEnv,"ppdefmodule","defmodule name");
   if (defmoduleName == ((void *)0)) return;
   PPDefmodule(theEnv,defmoduleName,"wdisplay");
   return;
  }


EnvListDefmodules

decompiled_code:
__int64 __fastcall EnvListDefmodules(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rbp
int v4; // ebx
__int64 v5; // rax
__int64 v6; // rdx

v2 = EnvGetNextDefmodule(a1, 0LL);
if ( v2 )
{
v3 = v2;
v4 = 0;
do
{
++v4;
v5 = EnvGetDefmoduleName(a1, v3);
EnvPrintRouter(a1, a2, v5);
EnvPrintRouter(a1, a2, &LC0);
v3 = EnvGetNextDefmodule(a1, v3);
}
while ( v3 );
v6 = v4;
}
else
{
v6 = 0LL;
}
return PrintTally(a1, a2, v6, "defmodule", "defmodules");
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rbp
int v4; // ebx
__int64 v5; // rax
__int64 v6; // rdx

v2 = EnvGetNextDefmodule(a1, 0LL);
if ( v2 )
{
v3 = v2;
v4 = 0;
do
{
++v4;
v5 = EnvGetDefmoduleName(a1, v3);
EnvPrintRouter(a1, a2, v5);
EnvPrintRouter(a1, a2, &LC0);
v3 = EnvGetNextDefmodule(a1, v3);
}
while ( v3 );
v6 = v4;
}
else
{
v6 = 0LL;
}
return PrintTally(a1, a2, v6, "defmodule", "defmodules");
}

original_code:
void EnvListDefmodules(
  void *theEnv,
  char *logicalName)
  {
   void *theModule;
   int count = 0;
   for (theModule = EnvGetNextDefmodule(theEnv,((void *)0));
        theModule != ((void *)0);
        theModule = EnvGetNextDefmodule(theEnv,theModule))
    {
     EnvPrintRouter(theEnv,logicalName,EnvGetDefmoduleName(theEnv,theModule));
     EnvPrintRouter(theEnv,logicalName,"\n");
     count++;
    }
   PrintTally(theEnv,logicalName,count,"defmodule","defmodules");
  }

canonical_original_code:
void EnvListDefmodules(void *theEnv, char *logicalName)
  {
   void *theModule;
   int count = 0;
   for (theModule = EnvGetNextDefmodule(theEnv,((void *)0));
        theModule != ((void *)0);
        theModule = EnvGetNextDefmodule(theEnv,theModule))
    {
     EnvPrintRouter(theEnv,logicalName,EnvGetDefmoduleName(theEnv,theModule));
     EnvPrintRouter(theEnv,logicalName,"\n");
     count++;
    }
   PrintTally(theEnv,logicalName,count,"defmodule","defmodules");
  }

variable_types: count int


ListDefmodulesCommand

decompiled_code:
__int64 __fastcall ListDefmodulesCommand(__int64 a1)
{
__int64 result; // rax

result = EnvArgCountCheck(a1, "list-defmodules", 0LL, 0LL);
if ( (_DWORD)result != -1 )
result = EnvListDefmodules(a1, (__int64)"wdisplay");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
__int64 result; // rax

result = EnvArgCountCheck(a1, "list-defmodules", 0LL, 0LL);
if ( (_DWORD)result != -1 )
result = func6(a1, (__int64)"wdisplay");
return result;
}

original_code:
void ListDefmodulesCommand(
  void *theEnv)
  {
   if (EnvArgCountCheck(theEnv,"list-defmodules",0,0) == -1) return;
   EnvListDefmodules(theEnv,"wdisplay");
  }

canonical_original_code:
void ListDefmodulesCommand(void *theEnv)
  {
   if (EnvArgCountCheck(theEnv,"list-defmodules",0,0) == -1) return;
   EnvListDefmodules(theEnv,"wdisplay");
  }


UpdateFactPatterns

original_code:
static void UpdateFactPatterns(
  void *theEnv,
  void *buf,
  long obji)
  {
   struct bsaveFactPatternNode *bp;
   bp = (struct bsaveFactPatternNode *) buf;
   UpdatePatternNodeHeader(theEnv,&((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[obji].header,&bp->header);
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[obji].bsaveID = 0L;
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[obji].whichField = bp->whichField;
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[obji].leaveFields = bp->leaveFields;
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[obji].whichSlot = bp->whichSlot;
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[obji].networkTest = ((struct expr *) (((bp->networkTest) == -1L) ? ((void *)0) : &((struct expressionData *) (((struct environmentData *) theEnv)->theData[45]))->ExpressionArray[bp->networkTest]));
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[obji].rightNode = ((struct factPatternNode *) ((bp->rightNode == -1L) ? ((void *)0) : &((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[bp->rightNode]));
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[obji].nextLevel = ((struct factPatternNode *) ((bp->nextLevel == -1L) ? ((void *)0) : &((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[bp->nextLevel]));
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[obji].lastLevel = ((struct factPatternNode *) ((bp->lastLevel == -1L) ? ((void *)0) : &((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[bp->lastLevel]));
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[obji].leftNode = ((struct factPatternNode *) ((bp->leftNode == -1L) ? ((void *)0) : &((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[bp->leftNode]));
  }

canonical_original_code:
static void UpdateFactPatterns(void *theEnv, void *buf, long obji)
  {
   struct bsaveFactPatternNode *bp;
   bp = (struct bsaveFactPatternNode *) buf;
   UpdatePatternNodeHeader(theEnv,&((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[obji].header,&bp->header);
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[obji].bsaveID = 0L;
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[obji].whichField = bp->whichField;
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[obji].leaveFields = bp->leaveFields;
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[obji].whichSlot = bp->whichSlot;
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[obji].networkTest = ((struct expr *) (((bp->networkTest) == -1L) ? ((void *)0) : &((struct expressionData *) (((struct environmentData *) theEnv)->theData[45]))->ExpressionArray[bp->networkTest]));
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[obji].rightNode = ((struct factPatternNode *) ((bp->rightNode == -1L) ? ((void *)0) : &((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[bp->rightNode]));
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[obji].nextLevel = ((struct factPatternNode *) ((bp->nextLevel == -1L) ? ((void *)0) : &((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[bp->nextLevel]));
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[obji].lastLevel = ((struct factPatternNode *) ((bp->lastLevel == -1L) ? ((void *)0) : &((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[bp->lastLevel]));
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[obji].leftNode = ((struct factPatternNode *) ((bp->leftNode == -1L) ? ((void *)0) : &((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray[bp->leftNode]));
  }

variable_types:
buf
void *

variable_types: obji long

variable_types: struct bsaveFactPatternNode { struct bsavePatternNodeHeader { long entryJoin; unsigned int singlefieldNode; unsigned int multifieldNode; unsigned int stopNode; unsigned int blocked; unsigned int initialize; unsigned int marked; unsigned int beginSlot; unsigned int endSlot; } header; unsigned short whichSlot; unsigned short whichField; unsigned short leaveFields; long networkTest; long nextLevel; long lastLevel; long leftNode; long rightNode; } *

user_defined_types: struct bsaveFactPatternNode { struct bsavePatternNodeHeader header; unsigned short whichSlot; unsigned short whichField; unsigned short leaveFields; long networkTest; long nextLevel; long lastLevel; long leftNode; long rightNode; }

user_defined_types: struct factBinaryData { struct factPatternNode *FactPatternArray; long NumberOfPatterns; }

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

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 factPatternNode { struct patternNodeHeader header; long bsaveID; unsigned short whichField; unsigned short whichSlot; unsigned short leaveFields; struct expr *networkTest; struct factPatternNode *nextLevel; struct factPatternNode *lastLevel; struct factPatternNode *leftNode; struct factPatternNode *rightNode; }

user_defined_types: struct patternNodeHeader { struct partialMatch *alphaMemory; struct partialMatch *endOfQueue; struct joinNode *entryJoin; unsigned int singlefieldNode; unsigned int multifieldNode; unsigned int stopNode; unsigned int initialize; unsigned int marked; unsigned int beginSlot; unsigned int endSlot; }

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

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 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 genericMatch { union { void *theValue; struct alphaMatch *theMatch; } gm; }

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 alphaMatch { struct patternEntity *matchingItem; struct multifieldMarker *markers; struct alphaMatch *next; }

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 defmoduleItemHeader { struct defmodule *theModule; struct constructHeader *firstItem; struct constructHeader *lastItem; }

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

user_defined_types: struct multifieldMarker { int whichField; union { void *whichSlot; short whichSlotNumber; } where; long startPosition; long endPosition; struct multifieldMarker *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 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; }


FactBinarySetup

decompiled_code:
__int64 __fastcall FactBinarySetup(__int64 a1)
{
AllocateEnvironmentData(a1, 62LL, 16LL, DeallocateFactBloadData);
return AddBinaryItem(
a1,
"facts",
0LL,
BsaveFind,
0LL,
BsaveStorage,
BsaveFactPatterns,
BloadStorage,
BloadBinaryItem,
ClearBload);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
AllocateEnvironmentData(a1, 62LL, 16LL, DeallocateFactBloadData);
return AddBinaryItem(
a1,
"facts",
0LL,
BsaveFind,
0LL,
BsaveStorage,
BsaveFactPatterns,
BloadStorage,
BloadBinaryItem,
ClearBload);
}

original_code:
void FactBinarySetup(
  void *theEnv)
  {
   AllocateEnvironmentData(theEnv,62,sizeof(struct factBinaryData),DeallocateFactBloadData);
   AddBinaryItem(theEnv,"facts",0,BsaveFind,((void *)0),
                            BsaveStorage,BsaveFactPatterns,
                            BloadStorage,BloadBinaryItem,
                            ClearBload);
  }

canonical_original_code:
void FactBinarySetup(void *theEnv)
  {
   AllocateEnvironmentData(theEnv,62,sizeof(struct factBinaryData),DeallocateFactBloadData);
   AddBinaryItem(theEnv,"facts",0,BsaveFind,((void *)0),
                            BsaveStorage,BsaveFactPatterns,
                            BloadStorage,BloadBinaryItem,
                            ClearBload);
  }

user_defined_types: struct factBinaryData { struct factPatternNode *FactPatternArray; long NumberOfPatterns; }

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

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

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

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


ClearBload

decompiled_code:
__int64 __fastcall ClearBload(__int64 a1)
{
_QWORD *v1; // rcx
__int64 result; // rax

v1 = *(_QWORD **)(*(_QWORD *)(a1 + 32) + 496LL);
result = v1[1];
if ( 88 * result )
{
genlongfree(a1, *v1, 88 * result);
result = *(_QWORD *)(a1 + 32);
*(_QWORD *)(*(_QWORD *)(result + 496) + 8LL) = 0LL;
}
else
{
v1[1] = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
_QWORD *v1; // rcx
__int64 result; // rax

v1 = *(_QWORD **)(*(_QWORD *)(a1 + 32) + 496LL);
result = v1[1];
if ( 88 * result )
{
genlongfree(a1, *v1, 88 * result);
result = *(_QWORD *)(a1 + 32);
*(_QWORD *)(*(_QWORD *)(result + 496) + 8LL) = 0LL;
}
else
{
v1[1] = 0LL;
}
return result;
}

original_code:
static void ClearBload(
  void *theEnv)
  {
   unsigned long int space;
   space = ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->NumberOfPatterns * sizeof(struct factPatternNode);
   if (space != 0) genlongfree(theEnv,(void *) ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray,space);
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->NumberOfPatterns = 0;
  }

canonical_original_code:
static void ClearBload(void *theEnv)
  {
   unsigned long space;
   space = ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->NumberOfPatterns * sizeof(struct factPatternNode);
   if (space != 0) genlongfree(theEnv,(void *) ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->FactPatternArray,space);
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->NumberOfPatterns = 0;
  }

variable_types:
space
unsigned long

user_defined_types: struct factPatternNode { struct patternNodeHeader header; long bsaveID; unsigned short whichField; unsigned short whichSlot; unsigned short leaveFields; struct expr *networkTest; struct factPatternNode *nextLevel; struct factPatternNode *lastLevel; struct factPatternNode *leftNode; struct factPatternNode *rightNode; }

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 patternNodeHeader { struct partialMatch *alphaMemory; struct partialMatch *endOfQueue; struct joinNode *entryJoin; unsigned int singlefieldNode; unsigned int multifieldNode; unsigned int stopNode; unsigned int initialize; unsigned int marked; unsigned int beginSlot; unsigned int endSlot; }

user_defined_types: struct environmentCleanupFunction { char *name; void (*func)(void *); int priority; struct environmentCleanupFunction *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 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; }


BloadBinaryItem

decompiled_code:
__int64 __fastcall BloadBinaryItem(__int64 a1)
{
char v2[16]; // [rsp+8h] [rbp-10h] BYREF

GenReadBinary(a1, v2, 8LL);
return BloadandRefresh(a1, *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 496LL) + 8LL), 64LL, UpdateFactPatterns);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
char v2[16]; // [rsp+8h] [rbp-10h] BYREF

GenReadBinary(a1, v2, 8LL);
return BloadandRefresh(a1, *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 496LL) + 8LL), 64LL, UpdateFactPatterns);
}

original_code:
static void BloadBinaryItem(
  void *theEnv)
  {
   unsigned long space;
   GenReadBinary(theEnv,&space,(unsigned long) sizeof(unsigned long int));
   BloadandRefresh(theEnv,((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->NumberOfPatterns,(unsigned) sizeof(struct bsaveFactPatternNode),
                   UpdateFactPatterns);
  }

canonical_original_code:
static void BloadBinaryItem(void *theEnv)
  {
   unsigned long space;
   GenReadBinary(theEnv,&space,(unsigned long) sizeof(unsigned long));
   BloadandRefresh(theEnv,((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->NumberOfPatterns,(unsigned int) sizeof(struct bsaveFactPatternNode),
                   UpdateFactPatterns);
  }

user_defined_types: struct bsaveFactPatternNode { struct bsavePatternNodeHeader header; unsigned short whichSlot; unsigned short whichField; unsigned short leaveFields; long networkTest; long nextLevel; long lastLevel; long leftNode; long rightNode; }

user_defined_types: struct bsavePatternNodeHeader { long entryJoin; unsigned int singlefieldNode; unsigned int multifieldNode; unsigned int stopNode; unsigned int blocked; unsigned int initialize; unsigned int marked; unsigned int beginSlot; unsigned int endSlot; }

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

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 alphaMatch { struct patternEntity *matchingItem; struct multifieldMarker *markers; struct alphaMatch *next; }

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 defmoduleItemHeader { struct defmodule *theModule; struct constructHeader *firstItem; struct constructHeader *lastItem; }

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


BsaveFind

decompiled_code:
__int64 __fastcall BsaveFind(__int64 a1)
{
__int64 result; // rax
__int64 v2; // r12
__int64 i; // rsi
__int64 v4; // rax
__int64 v5; // rbp

SaveBloadCount(a1, *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 496LL) + 8LL));
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 496LL) + 8LL) = 0LL;
result = EnvGetNextDefmodule(a1, 0LL);
if ( result )
{
v2 = result;
do
{
EnvSetCurrentModule(a1, v2);
for ( i = 0LL; ; i = v5 )
{
v4 = EnvGetNextDeftemplate(a1, i);
v5 = v4;
if ( !v4 )
break;
BsaveDriver(a1, 0, 0LL, *(_QWORD **)(v4 + 72));
}
result = EnvGetNextDefmodule(a1, v2);
v2 = result;
}
while ( result );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
__int64 result; // rax
__int64 v2; // r12
__int64 i; // rsi
__int64 v4; // rax
__int64 v5; // rbp

SaveBloadCount(a1, *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 496LL) + 8LL));
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 496LL) + 8LL) = 0LL;
result = EnvGetNextDefmodule(a1, 0LL);
if ( result )
{
v2 = result;
do
{
EnvSetCurrentModule(a1, v2);
for ( i = 0LL; ; i = v5 )
{
v4 = EnvGetNextDeftemplate(a1, i);
v5 = v4;
if ( !v4 )
break;
func6(a1, 0, 0LL, *(_QWORD **)(v4 + 72));
}
result = EnvGetNextDefmodule(a1, v2);
v2 = result;
}
while ( result );
}
return result;
}

original_code:
static void BsaveFind(
  void *theEnv)
  {
   struct deftemplate *theDeftemplate;
   struct defmodule *theModule;
   SaveBloadCount(theEnv,((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->NumberOfPatterns);
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->NumberOfPatterns = 0L;
   for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,((void *)0));
        theModule != ((void *)0);
        theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule))
     {
      EnvSetCurrentModule(theEnv,(void *) theModule);
      for (theDeftemplate = (struct deftemplate *) EnvGetNextDeftemplate(theEnv,((void *)0));
           theDeftemplate != ((void *)0);
           theDeftemplate = (struct deftemplate *) EnvGetNextDeftemplate(theEnv,theDeftemplate))
        { BsaveDriver(theEnv,0,((void *)0),theDeftemplate->patternNetwork); }
     }
  }

canonical_original_code:
static void BsaveFind(void *theEnv)
  {
   struct deftemplate *theDeftemplate;
   struct defmodule *theModule;
   SaveBloadCount(theEnv,((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->NumberOfPatterns);
   ((struct factBinaryData *) (((struct environmentData *) theEnv)->theData[62]))->NumberOfPatterns = 0L;
   for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,((void *)0));
        theModule != ((void *)0);
        theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule))
     {
      EnvSetCurrentModule(theEnv,(void *) theModule);
      for (theDeftemplate = (struct deftemplate *) EnvGetNextDeftemplate(theEnv,((void *)0));
           theDeftemplate != ((void *)0);
           theDeftemplate = (struct deftemplate *) EnvGetNextDeftemplate(theEnv,theDeftemplate))
        { BsaveDriver(theEnv,0,((void *)0),theDeftemplate->patternNetwork); }
     }
  }

variable_types: struct deftemplate { 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; struct templateSlot { struct symbolHashNode *slotName; unsigned int multislot; unsigned int noDefault; unsigned int defaultPresent; unsigned int defaultDynamic; 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; } *constraints; struct expr *defaultList; struct templateSlot *next; } *slotList; unsigned int implied; unsigned int watch; unsigned int inScope; unsigned short numberOfSlots; long busyCount; struct factPatternNode { struct patternNodeHeader { 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 *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]; } *alphaMemory; struct partialMatch *endOfQueue; 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 { 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; } *ruleToActivate; } *entryJoin; unsigned int singlefieldNode; unsigned int multifieldNode; unsigned int stopNode; unsigned int initialize; unsigned int marked; unsigned int beginSlot; unsigned int endSlot; } header; long bsaveID; unsigned short whichField; unsigned short whichSlot; unsigned short leaveFields; struct expr *networkTest; struct factPatternNode *nextLevel; struct factPatternNode *lastLevel; struct factPatternNode *leftNode; struct factPatternNode *rightNode; } *patternNetwork; struct fact { struct patternEntity factHeader; struct deftemplate *whichDeftemplate; void *list; long factIndex; unsigned int depth; unsigned int garbage; struct fact *previousFact; struct fact *nextFact; struct fact *previousTemplateFact; struct fact *nextTemplateFact; struct multifield { unsigned int busyCount; short depth; unsigned long multifieldLength; struct multifield *next; struct field { unsigned short type; void *value; } theFields[1]; } theProposition; } *factList; struct fact *lastFact; } *

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

user_defined_types: struct deftemplate { struct constructHeader header; struct templateSlot *slotList; unsigned int implied; unsigned int watch; unsigned int inScope; unsigned short numberOfSlots; long busyCount; struct factPatternNode *patternNetwork; struct fact *factList; struct fact *lastFact; }

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 factBinaryData { struct factPatternNode *FactPatternArray; long NumberOfPatterns; }

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

user_defined_types: struct templateSlot { struct symbolHashNode *slotName; unsigned int multislot; unsigned int noDefault; unsigned int defaultPresent; unsigned int defaultDynamic; struct constraintRecord *constraints; struct expr *defaultList; struct templateSlot *next; }

user_defined_types: struct fact { struct patternEntity factHeader; struct deftemplate *whichDeftemplate; void *list; long factIndex; unsigned int depth; unsigned int garbage; struct fact *previousFact; struct fact *nextFact; struct fact *previousTemplateFact; struct fact *nextTemplateFact; struct multifield theProposition; }

user_defined_types: struct multifield { unsigned int busyCount; short depth; unsigned long multifieldLength; struct multifield *next; struct field theFields[1]; }

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 patternEntityRecord { struct entityRecord base; void (*decrementBasisCount)(void *, void *); void (*incrementBasisCount)(void *, void *); void (*matchFunction)(void *, void *); int (*synchronized)(void *, void *); }

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