CheckForPrimableJoins

original_code:
static void CheckForPrimableJoins(
  void *theEnv,
  struct defrule *tempRule)
  {
   struct joinNode *joinPtr;
   struct partialMatch *theList;
   for (joinPtr = tempRule->lastJoin;
        joinPtr != ((void *)0);
        joinPtr = (((joinPtr)->joinFromTheRight) ? ((struct joinNode *) (joinPtr)->rightSideEntryStructure) : ((joinPtr)->lastLevel)))
     {
      if ((joinPtr->initialize) && (! joinPtr->marked))
        {
         if (joinPtr->firstJoin == 1)
           {
            if (((struct patternNodeHeader *) (((joinPtr)->joinFromTheRight) ? ((void *)0) : ((joinPtr)->rightSideEntryStructure)))->initialize == 0)
              {
               PrimeJoin(theEnv,joinPtr);
               joinPtr->marked = 1;
              }
           }
         else if (joinPtr->lastLevel->initialize == 0)
           {
            PrimeJoin(theEnv,joinPtr);
            joinPtr->marked = 1;
           }
        }
      else if (joinPtr->ruleToActivate == tempRule)
        {
         for (theList = joinPtr->beta;
              theList != ((void *)0);
              theList = theList->next)
           { AddActivation(theEnv,tempRule,theList); }
        }
     }
  }

canonical_original_code:
static void CheckForPrimableJoins(void *theEnv, struct defrule *tempRule)
  {
   struct joinNode *joinPtr;
   struct partialMatch *theList;
   for (joinPtr = tempRule->lastJoin;
        joinPtr != ((void *)0);
        joinPtr = (((joinPtr)->joinFromTheRight) ? ((struct joinNode *) (joinPtr)->rightSideEntryStructure) : ((joinPtr)->lastLevel)))
     {
      if ((joinPtr->initialize) && (! joinPtr->marked))
        {
         if (joinPtr->firstJoin == 1)
           {
            if (((struct patternNodeHeader *) (((joinPtr)->joinFromTheRight) ? ((void *)0) : ((joinPtr)->rightSideEntryStructure)))->initialize == 0)
              {
               PrimeJoin(theEnv,joinPtr);
               joinPtr->marked = 1;
              }
           }
         else if (joinPtr->lastLevel->initialize == 0)
           {
            PrimeJoin(theEnv,joinPtr);
            joinPtr->marked = 1;
           }
        }
      else if (joinPtr->ruleToActivate == tempRule)
        {
         for (theList = joinPtr->beta;
              theList != ((void *)0);
              theList = theList->next)
           { AddActivation(theEnv,tempRule,theList); }
        }
     }
  }

variable_types: 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 { 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; int salience; int localVarCnt; unsigned int complexity; unsigned int afterBreakpoint; unsigned int watchActivation; unsigned int watchFiring; unsigned int autoFocus; unsigned int executing; struct expr { unsigned short type; void *value; struct expr *argList; struct expr *nextArg; } *dynamicSalience; struct expr *actions; 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 *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 *networkTest; void *rightSideEntryStructure; struct joinNode *nextLevel; struct joinNode *lastLevel; struct joinNode *rightDriveNode; struct joinNode *rightMatchNode; struct defrule *ruleToActivate; } *logicalJoin; struct joinNode *lastJoin; struct defrule *disjunct; } *

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

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


MarkNetworkForIncrementalReset

repo: jarcec/rbclips

decompiled_code:
void __fastcall MarkNetworkForIncrementalReset(__int64 a1, __int64 a2, unsigned int a3)
{
char v3; // r14
__int64 v4; // rbp
char *i; // rbx
char v7; // dl
char v8; // al
char v9; // cl
__int64 v10; // r8
char v11; // dl

v3 = a3 & 1;
if ( a2 )
{
v4 = a2;
do
{
for ( i = *(char **)(v4 + 88); i; i = (char *)*((_QWORD *)i + 6) )
{
while ( 1 )
{
v7 = *i;
v8 = *i & 0xDF;
v9 = *i & 0x14;
*i = v8;
if ( v9 == 16 )
{
v10 = 0LL;
v11 = (16 * v3) | v7 & 0xCF;
*i = v11;
if ( (v11 & 4) == 0 )
v10 = *((_QWORD *)i + 4);
MarkPatternForIncrementalReset(a1, (*(_WORD *)i >> 6) & 7, v10, a3);
v8 = *i;
}
if ( (v8 & 4) == 0 )
break;
i = (char *)*((_QWORD *)i + 4);
if ( !i )
goto LABEL_8;
}
}
LABEL_8:
v4 = *(_QWORD *)(v4 + 96);
}
while ( v4 );
}
}

original_code:
static void MarkNetworkForIncrementalReset(
  void *theEnv,
  struct defrule *tempRule,
  int value)
  {
   struct joinNode *joinPtr;
   struct patternNodeHeader *patternPtr;
   for (;
        tempRule != ((void *)0);
        tempRule = tempRule->disjunct)
     {
      for (joinPtr = tempRule->lastJoin;
           joinPtr != ((void *)0);
           joinPtr = (((joinPtr)->joinFromTheRight) ? ((struct joinNode *) (joinPtr)->rightSideEntryStructure) : ((joinPtr)->lastLevel)))
        {
         joinPtr->marked = 0;
         if ((joinPtr->initialize) && (joinPtr->joinFromTheRight == 0))
           {
            joinPtr->initialize = value;
            patternPtr = (struct patternNodeHeader *) (((joinPtr)->joinFromTheRight) ? ((void *)0) : ((joinPtr)->rightSideEntryStructure));
            MarkPatternForIncrementalReset(theEnv,(int) joinPtr->rhsType,patternPtr,value);
           }
        }
     }
  }

canonical_original_code:
static void MarkNetworkForIncrementalReset(void *theEnv, struct defrule *tempRule, int value)
  {
   struct joinNode *joinPtr;
   struct patternNodeHeader *patternPtr;
   for (;
        tempRule != ((void *)0);
        tempRule = tempRule->disjunct)
     {
      for (joinPtr = tempRule->lastJoin;
           joinPtr != ((void *)0);
           joinPtr = (((joinPtr)->joinFromTheRight) ? ((struct joinNode *) (joinPtr)->rightSideEntryStructure) : ((joinPtr)->lastLevel)))
        {
         joinPtr->marked = 0;
         if ((joinPtr->initialize) && (joinPtr->joinFromTheRight == 0))
           {
            joinPtr->initialize = value;
            patternPtr = (struct patternNodeHeader *) (((joinPtr)->joinFromTheRight) ? ((void *)0) : ((joinPtr)->rightSideEntryStructure));
            MarkPatternForIncrementalReset(theEnv,(int) joinPtr->rhsType,patternPtr,value);
           }
        }
     }
  }

variable_types:
theEnv
void *

variable_types: value int

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

return_type: void

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

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

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


EnvGetIncrementalReset

decompiled_code:
__int64 __fastcall EnvGetIncrementalReset(__int64 a1)
{
return *(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 144LL) + 72LL);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return *(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 144LL) + 72LL);
}

original_code:
int EnvGetIncrementalReset(
  void *theEnv)
  {
   return(((struct engineData *) (((struct environmentData *) theEnv)->theData[18]))->IncrementalResetFlag);
  }

canonical_original_code:
int EnvGetIncrementalReset(void *theEnv)
  {
   return(((struct engineData *) (((struct environmentData *) theEnv)->theData[18]))->IncrementalResetFlag);
  }

return_type: int

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

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

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

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


EnvSetIncrementalReset

decompiled_code:
__int64 __fastcall EnvSetIncrementalReset(__int64 a1, int a2)
{
unsigned int v2; // er12

v2 = *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 144LL) + 72LL);
if ( EnvGetNextDefrule(a1, 0LL) )
return (unsigned int)-1;
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 144LL) + 72LL) = a2;
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, int a2)
{
unsigned int v2; // er12

v2 = *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 144LL) + 72LL);
if ( EnvGetNextDefrule(a1, 0LL) )
return (unsigned int)-1;
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 144LL) + 72LL) = a2;
return v2;
}

original_code:
int EnvSetIncrementalReset(
  void *theEnv,
  int value)
  {
   int ov;
   ov = ((struct engineData *) (((struct environmentData *) theEnv)->theData[18]))->IncrementalResetFlag;
   if (EnvGetNextDefrule(theEnv,((void *)0)) != ((void *)0)) return(-1);
   ((struct engineData *) (((struct environmentData *) theEnv)->theData[18]))->IncrementalResetFlag = value;
   return(ov);
  }

canonical_original_code:
int EnvSetIncrementalReset(void *theEnv, int value)
  {
   int ov;
   ov = ((struct engineData *) (((struct environmentData *) theEnv)->theData[18]))->IncrementalResetFlag;
   if (EnvGetNextDefrule(theEnv,((void *)0)) != ((void *)0)) return(-1);
   ((struct engineData *) (((struct environmentData *) theEnv)->theData[18]))->IncrementalResetFlag = value;
   return(ov);
  }

variable_types: ov int

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

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

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


SetIncrementalResetCommand

decompiled_code:
__int64 __fastcall SetIncrementalResetCommand(__int64 a1)
{
unsigned int v1; // er12
_WORD v3[8]; // [rsp+0h] [rbp-48h] BYREF
__int64 v4; // [rsp+10h] [rbp-38h]

v1 = EnvGetIncrementalReset(a1);
if ( (unsigned int)EnvArgCountCheck(a1, "set-incremental-reset", 0LL, 1LL) == -1 )
return v1;
if ( EnvGetNextDefrule(a1, 0LL) )
{
PrintErrorID(a1, "INCRRSET", 1LL, 0LL);
EnvPrintRouter(a1, "werror", "The incremental reset behavior cannot be changed with rules loaded.\n");
SetEvaluationError(a1, 1LL);
return v1;
}
EnvRtnUnknown(a1, 1LL, v3);
if ( v4 == *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 392LL) + 8LL) && v3[4] == 2 )
{
EnvSetIncrementalReset(a1, 0);
return v1;
}
EnvSetIncrementalReset(a1, 1);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
unsigned int v1; // er12
_WORD v3[8]; // [rsp+0h] [rbp-48h] BYREF
__int64 v4; // [rsp+10h] [rbp-38h]

v1 = func3(a1);
if ( (unsigned int)EnvArgCountCheck(a1, "set-incremental-reset", 0LL, 1LL) == -1 )
return v1;
if ( EnvGetNextDefrule(a1, 0LL) )
{
PrintErrorID(a1, "INCRRSET", 1LL, 0LL);
EnvPrintRouter(a1, "werror", "The incremental reset behavior cannot be changed with rules loaded.\n");
SetEvaluationError(a1, 1LL);
return v1;
}
EnvRtnUnknown(a1, 1LL, v3);
if ( v4 == *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 392LL) + 8LL) && v3[4] == 2 )
{
func5(a1, 0);
return v1;
}
func5(a1, 1);
return v1;
}

original_code:
int SetIncrementalResetCommand(
  void *theEnv)
  {
   int oldValue;
   DATA_OBJECT argPtr;
   oldValue = EnvGetIncrementalReset(theEnv);
   if (EnvArgCountCheck(theEnv,"set-incremental-reset",0,1) == -1)
     { return(oldValue); }
   if (EnvGetNextDefrule(theEnv,((void *)0)) != ((void *)0))
     {
      PrintErrorID(theEnv,"INCRRSET",1,0);
      EnvPrintRouter(theEnv,"werror","The incremental reset behavior cannot be changed with rules loaded.\n");
      SetEvaluationError(theEnv,1);
      return(oldValue);
     }
   EnvRtnUnknown(theEnv,1,&argPtr);
   if ((argPtr.value == ((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->FalseSymbolHN) && (argPtr.type == 2))
     { EnvSetIncrementalReset(theEnv,0); }
   else
     { EnvSetIncrementalReset(theEnv,1); }
   return(oldValue);
  }

canonical_original_code:
int SetIncrementalResetCommand(void *theEnv)
  {
   int oldValue;
   struct dataObject argPtr;
   oldValue = EnvGetIncrementalReset(theEnv);
   if (EnvArgCountCheck(theEnv,"set-incremental-reset",0,1) == -1)
     { return(oldValue); }
   if (EnvGetNextDefrule(theEnv,((void *)0)) != ((void *)0))
     {
      PrintErrorID(theEnv,"INCRRSET",1,0);
      EnvPrintRouter(theEnv,"werror","The incremental reset behavior cannot be changed with rules loaded.\n");
      SetEvaluationError(theEnv,1);
      return(oldValue);
     }
   EnvRtnUnknown(theEnv,1,&argPtr);
   if ((argPtr.value == ((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->FalseSymbolHN) && (argPtr.type == 2))
     { EnvSetIncrementalReset(theEnv,0); }
   else
     { EnvSetIncrementalReset(theEnv,1); }
   return(oldValue);
  }

variable_types: oldValue int

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

user_defined_types: struct symbolData { void *TrueSymbolHN; void *FalseSymbolHN; void *PositiveInfinity; void *NegativeInfinity; void *Zero; struct symbolHashNode **SymbolTable; struct floatHashNode **FloatTable; struct integerHashNode **IntegerTable; struct bitMapHashNode **BitMapTable; struct ephemeron *EphemeralSymbolList; struct ephemeron *EphemeralFloatList; struct ephemeron *EphemeralIntegerList; struct ephemeron *EphemeralBitMapList; long NumberOfSymbols; long NumberOfFloats; long NumberOfIntegers; long NumberOfBitMaps; struct symbolHashNode **SymbolArray; struct floatHashNode **FloatArray; struct integerHashNode **IntegerArray; struct bitMapHashNode **BitMapArray; }

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 ephemeron { struct genericHashNode *associatedValue; struct ephemeron *next; }

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

user_defined_types: struct floatHashNode { struct floatHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int neededFloat; unsigned int bucket; double contents; }

user_defined_types: struct integerHashNode { struct integerHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int neededInteger; unsigned int bucket; long contents; }

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 genericHashNode { struct genericHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int needed; unsigned int bucket; }


GetIncrementalResetCommand

decompiled_code:
__int64 __fastcall GetIncrementalResetCommand(__int64 a1)
{
unsigned int v1; // er12

v1 = EnvGetIncrementalReset(a1);
EnvArgCountCheck(a1, "get-incremental-reset", 0LL, 0LL);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
unsigned int v1; // er12

v1 = func3(a1);
EnvArgCountCheck(a1, "get-incremental-reset", 0LL, 0LL);
return v1;
}

original_code:
int GetIncrementalResetCommand(
  void *theEnv)
  {
   int oldValue;
   oldValue = EnvGetIncrementalReset(theEnv);
   if (EnvArgCountCheck(theEnv,"get-incremental-reset",0,0) == -1)
     { return(oldValue); }
   return(oldValue);
  }

canonical_original_code:
int GetIncrementalResetCommand(void *theEnv)
  {
   int oldValue;
   oldValue = EnvGetIncrementalReset(theEnv);
   if (EnvArgCountCheck(theEnv,"get-incremental-reset",0,0) == -1)
     { return(oldValue); }
   return(oldValue);
  }


CaptureWatchPrints

decompiled_code:
__int64 CaptureWatchPrints()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func1()
{
return 1LL;
}

original_code:
static int CaptureWatchPrints(
  void *theEnv,
  char *logName,
  char *str)
  {
   return(1);
  }

canonical_original_code:
static int CaptureWatchPrints(void *theEnv, char *logName, char *str)
  {
   return(1);
  }

variable_types:
logName
char *

variable_types:
str
char *


ValidWatchItem

decompiled_code:
__int64 __fastcall ValidWatchItem(__int64 a1, const char *a2, _DWORD *a3)
{
__int64 v4; // r12
__int64 result; // rax

*a3 = 1;
if ( !strcmp(a2, "all") )
return 0LL;
v4 = **(_QWORD **)(*(_QWORD *)(a1 + 32) + 432LL);
if ( v4 )
{
while ( strcmp(a2, *(const char **)v4) )
{
v4 = *(_QWORD *)(v4 + 40);
if ( !v4 )
goto LABEL_7;
}
result = v4;
}
else
{
LABEL_7:
*a3 = 0;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, const char *a2, _DWORD *a3)
{
__int64 v4; // r12
__int64 result; // rax

*a3 = 1;
if ( !strcmp(a2, "all") )
return 0LL;
v4 = **(_QWORD **)(*(_QWORD *)(a1 + 32) + 432LL);
if ( v4 )
{
while ( strcmp(a2, *(const char **)v4) )
{
v4 = *(_QWORD *)(v4 + 40);
if ( !v4 )
goto LABEL_7;
}
result = v4;
}
else
{
LABEL_7:
*a3 = 0;
result = 0LL;
}
return result;
}

original_code:
static struct watchItem *ValidWatchItem(
  void *theEnv,
  char *itemName,
  int *recognized)
  {
   struct watchItem *wPtr;
   *recognized = 1;
   if (strcmp(itemName,"all") == 0)
     return(((void *)0));
   for (wPtr = ((struct watchData *) (((struct environmentData *) theEnv)->theData[54]))->ListOfWatchItems; wPtr != ((void *)0); wPtr = wPtr->next)
     { if (strcmp(itemName,wPtr->name) == 0) return(wPtr); }
   *recognized = 0;
   return(((void *)0));
  }

canonical_original_code:
static struct watchItem *ValidWatchItem(void *theEnv, char *itemName, int *recognized)
  {
   struct watchItem *wPtr;
   *recognized = 1;
   if (strcmp(itemName,"all") == 0)
     return(((void *)0));
   for (wPtr = ((struct watchData *) (((struct environmentData *) theEnv)->theData[54]))->ListOfWatchItems; wPtr != ((void *)0); wPtr = wPtr->next)
     { if (strcmp(itemName,wPtr->name) == 0) return(wPtr); }
   *recognized = 0;
   return(((void *)0));
  }

variable_types:
itemName
char *

variable_types:
recognized
int *

variable_types: struct watchItem { char *name; unsigned int *flag; int code; unsigned int (*accessFunc)(void *, int, unsigned int, struct expr { unsigned short type; void *value; struct expr *argList; struct expr *nextArg; } *); unsigned int (*printFunc)(void *, char *, int, struct expr *); struct watchItem *next; } *

user_defined_types: struct watchItem { char *name; unsigned int *flag; int code; unsigned int (*accessFunc)(void *, int, unsigned int, struct expr *); unsigned int (*printFunc)(void *, char *, int, struct expr *); struct watchItem *next; }

user_defined_types: struct watchData { struct watchItem *ListOfWatchItems; }


RecognizeWatchRouters

decompiled_code:
_BOOL8 __fastcall RecognizeWatchRouters(__int64 a1, const char *a2)
{
return strcmp(a2, "wtrace") == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(__int64 a1, const char *a2)
{
return strcmp(a2, "wtrace") == 0;
}

original_code:
static int RecognizeWatchRouters(
  void *theEnv,
  char *logName)
  {
   if (strcmp(logName,"wtrace") == 0) return(1);
   return(0);
  }

canonical_original_code:
static int RecognizeWatchRouters(void *theEnv, char *logName)
  {
   if (strcmp(logName,"wtrace") == 0) return(1);
   return(0);
  }


InitializeWatchData

decompiled_code:
__int64 __fastcall InitializeWatchData(__int64 a1)
{
return AllocateEnvironmentData(a1, 54LL, 8LL, DeallocateWatchData);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
return AllocateEnvironmentData(a1, 54LL, 8LL, DeallocateWatchData);
}

original_code:
void InitializeWatchData(
  void *theEnv)
  {
   AllocateEnvironmentData(theEnv,54,sizeof(struct watchData),DeallocateWatchData);
  }

canonical_original_code:
void InitializeWatchData(void *theEnv)
  {
   AllocateEnvironmentData(theEnv,54,sizeof(struct watchData),DeallocateWatchData);
  }

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


AddWatchItem

original_code:
int AddWatchItem(
  void *theEnv,
  char *name,
  int code,
  unsigned *flag,
  int priority,
  unsigned (*accessFunc)(void *,int,unsigned,struct expr *),
  unsigned (*printFunc)(void *,char *,int,struct expr *))
  {
   struct watchItem *newPtr, *currentPtr, *lastPtr;
   for (currentPtr = ((struct watchData *) (((struct environmentData *) theEnv)->theData[54]))->ListOfWatchItems, lastPtr = ((void *)0);
        currentPtr != ((void *)0);
        currentPtr = currentPtr->next)
     {
      if (strcmp(currentPtr->name,name) == 0) return(0);
      if (priority < currentPtr->priority) lastPtr = currentPtr;
     }
   newPtr = ((((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct watchItem)] == ((void *)0)) ? ((struct watchItem *) genalloc(theEnv,(unsigned) sizeof(struct watchItem))) : ((((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct watchItem)]), ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct watchItem)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next, ((struct watchItem *) ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr)));
   newPtr->name = name;
   newPtr->flag = flag;
   newPtr->code = code;
   newPtr->priority = priority;
   newPtr->accessFunc = accessFunc;
   newPtr->printFunc = printFunc;
   if (lastPtr == ((void *)0))
     {
      newPtr->next = ((struct watchData *) (((struct environmentData *) theEnv)->theData[54]))->ListOfWatchItems;
      ((struct watchData *) (((struct environmentData *) theEnv)->theData[54]))->ListOfWatchItems = newPtr;
     }
   else
     {
      newPtr->next = lastPtr->next;
      lastPtr->next = newPtr;
     }
   return(1);
  }

canonical_original_code:
int AddWatchItem(void *theEnv, char *name, int code, unsigned int *flag, int priority, unsigned int (*accessFunc)(void *, int, unsigned int, struct expr *), unsigned int (*printFunc)(void *, char *, int, struct expr *))
  {
   struct watchItem *newPtr; struct watchItem *currentPtr; struct watchItem *lastPtr;
   for (currentPtr = ((struct watchData *) (((struct environmentData *) theEnv)->theData[54]))->ListOfWatchItems, lastPtr = ((void *)0);
        currentPtr != ((void *)0);
        currentPtr = currentPtr->next)
     {
      if (strcmp(currentPtr->name,name) == 0) return(0);
      if (priority < currentPtr->priority) lastPtr = currentPtr;
     }
   newPtr = ((((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct watchItem)] == ((void *)0)) ? ((struct watchItem *) genalloc(theEnv,(unsigned int) sizeof(struct watchItem))) : ((((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct watchItem)]), ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct watchItem)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next, ((struct watchItem *) ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr)));
   newPtr->name = name;
   newPtr->flag = flag;
   newPtr->code = code;
   newPtr->priority = priority;
   newPtr->accessFunc = accessFunc;
   newPtr->printFunc = printFunc;
   if (lastPtr == ((void *)0))
     {
      newPtr->next = ((struct watchData *) (((struct environmentData *) theEnv)->theData[54]))->ListOfWatchItems;
      ((struct watchData *) (((struct environmentData *) theEnv)->theData[54]))->ListOfWatchItems = newPtr;
     }
   else
     {
      newPtr->next = lastPtr->next;
      lastPtr->next = newPtr;
     }
   return(1);
  }

variable_types:
name
char *

variable_types: code int

variable_types:
flag
unsigned int *

variable_types: priority int

variable_types: unsigned int (*)(void *, int, unsigned int, struct expr { unsigned short type; void *value; struct expr *argList; struct expr *nextArg; } *)

variable_types: unsigned int (*)(void *, char *, int, struct expr *)

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


EnvSetWatchItem

decompiled_code:
__int64 __fastcall EnvSetWatchItem(__int64 a1, const char *a2, unsigned int a3, __int64 a4)
{
__int64 result; // rax
__int64 v7; // rbx
unsigned int (__fastcall *v8)(__int64, _QWORD, _QWORD, __int64); // rax
unsigned int (__fastcall *v9)(__int64, _QWORD, _QWORD, __int64); // rax

result = 0LL;
if ( a3 <= 1 )
{
v7 = **(_QWORD **)(*(_QWORD *)(a1 + 32) + 432LL);
if ( !strcmp(a2, "all") )
{
while ( v7 )
{
if ( !a4 )
**(_DWORD **)(v7 + 8) = a3;
v9 = *(unsigned int (__fastcall **)(__int64, _QWORD, _QWORD, __int64))(v7 + 24);
if ( v9 && !v9(a1, *(unsigned int *)(v7 + 16), a3, a4) )
goto LABEL_19;
v7 = *(_QWORD *)(v7 + 40);
}
}
else
{
if ( !v7 )
return result;
while ( strcmp(a2, *(const char **)v7) )
{
v7 = *(_QWORD *)(v7 + 40);
if ( !v7 )
return 0LL;
}
if ( !a4 )
**(_DWORD **)(v7 + 8) = a3;
v8 = *(unsigned int (__fastcall **)(__int64, _QWORD, _QWORD, __int64))(v7 + 24);
if ( v8 && !v8(a1, *(unsigned int *)(v7 + 16), a3, a4) )
{
LABEL_19:
SetEvaluationError(a1, 1LL);
return 0LL;
}
}
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, const char *a2, unsigned int a3, __int64 a4)
{
__int64 result; // rax
__int64 v7; // rbx
unsigned int (__fastcall *v8)(__int64, _QWORD, _QWORD, __int64); // rax
unsigned int (__fastcall *v9)(__int64, _QWORD, _QWORD, __int64); // rax

result = 0LL;
if ( a3 <= 1 )
{
v7 = **(_QWORD **)(*(_QWORD *)(a1 + 32) + 432LL);
if ( !strcmp(a2, "all") )
{
while ( v7 )
{
if ( !a4 )
**(_DWORD **)(v7 + 8) = a3;
v9 = *(unsigned int (__fastcall **)(__int64, _QWORD, _QWORD, __int64))(v7 + 24);
if ( v9 && !v9(a1, *(unsigned int *)(v7 + 16), a3, a4) )
goto LABEL_19;
v7 = *(_QWORD *)(v7 + 40);
}
}
else
{
if ( !v7 )
return result;
while ( strcmp(a2, *(const char **)v7) )
{
v7 = *(_QWORD *)(v7 + 40);
if ( !v7 )
return 0LL;
}
if ( !a4 )
**(_DWORD **)(v7 + 8) = a3;
v8 = *(unsigned int (__fastcall **)(__int64, _QWORD, _QWORD, __int64))(v7 + 24);
if ( v8 && !v8(a1, *(unsigned int *)(v7 + 16), a3, a4) )
{
LABEL_19:
SetEvaluationError(a1, 1LL);
return 0LL;
}
}
result = 1LL;
}
return result;
}

original_code:
int EnvSetWatchItem(
  void *theEnv,
  char *itemName,
  unsigned newState,
  struct expr *argExprs)
  {
   struct watchItem *wPtr;
   if ((newState != 1) && (newState != 0)) return(0);
   if (strcmp(itemName,"all") == 0)
     {
      for (wPtr = ((struct watchData *) (((struct environmentData *) theEnv)->theData[54]))->ListOfWatchItems; wPtr != ((void *)0); wPtr = wPtr->next)
        {
         if (argExprs == ((void *)0)) *(wPtr->flag) = newState;
         if ((wPtr->accessFunc == ((void *)0)) ? 0 :
             ((*wPtr->accessFunc)(theEnv,wPtr->code,newState,argExprs) == 0))
           {
            SetEvaluationError(theEnv,1);
            return(0);
           }
        }
      return(1);
     }
   for (wPtr = ((struct watchData *) (((struct environmentData *) theEnv)->theData[54]))->ListOfWatchItems; wPtr != ((void *)0); wPtr = wPtr->next)
     {
      if (strcmp(itemName,wPtr->name) == 0)
        {
         if (argExprs == ((void *)0)) *(wPtr->flag) = newState;
         if ((wPtr->accessFunc == ((void *)0)) ? 0 :
             ((*wPtr->accessFunc)(theEnv,wPtr->code,newState,argExprs) == 0))
           {
            SetEvaluationError(theEnv,1);
            return(0);
           }
         return(1);
        }
     }
   return(0);
  }

canonical_original_code:
int EnvSetWatchItem(void *theEnv, char *itemName, unsigned int newState, struct expr *argExprs)
  {
   struct watchItem *wPtr;
   if ((newState != 1) && (newState != 0)) return(0);
   if (strcmp(itemName,"all") == 0)
     {
      for (wPtr = ((struct watchData *) (((struct environmentData *) theEnv)->theData[54]))->ListOfWatchItems; wPtr != ((void *)0); wPtr = wPtr->next)
        {
         if (argExprs == ((void *)0)) *(wPtr->flag) = newState;
         if ((wPtr->accessFunc == ((void *)0)) ? 0 :
             ((*wPtr->accessFunc)(theEnv,wPtr->code,newState,argExprs) == 0))
           {
            SetEvaluationError(theEnv,1);
            return(0);
           }
        }
      return(1);
     }
   for (wPtr = ((struct watchData *) (((struct environmentData *) theEnv)->theData[54]))->ListOfWatchItems; wPtr != ((void *)0); wPtr = wPtr->next)
     {
      if (strcmp(itemName,wPtr->name) == 0)
        {
         if (argExprs == ((void *)0)) *(wPtr->flag) = newState;
         if ((wPtr->accessFunc == ((void *)0)) ? 0 :
             ((*wPtr->accessFunc)(theEnv,wPtr->code,newState,argExprs) == 0))
           {
            SetEvaluationError(theEnv,1);
            return(0);
           }
         return(1);
        }
     }
   return(0);
  }

variable_types:
theEnv
void *

variable_types:
newState
unsigned int

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


EnvWatch

decompiled_code:
__int64 __fastcall EnvWatch(__int64 a1, const char *a2)
{
return EnvSetWatchItem(a1, a2, 1u, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, const char *a2)
{
return func6(a1, a2, 1u, 0LL);
}

original_code:
int EnvWatch(
  void *theEnv,
  char *itemName)
  {
   return(EnvSetWatchItem(theEnv,itemName,1,((void *)0)));
  }

canonical_original_code:
int EnvWatch(void *theEnv, char *itemName)
  {
   return(EnvSetWatchItem(theEnv,itemName,1,((void *)0)));
  }


EnvUnwatch

decompiled_code:
__int64 __fastcall EnvUnwatch(__int64 a1, const char *a2)
{
return EnvSetWatchItem(a1, a2, 0, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, const char *a2)
{
return func6(a1, a2, 0, 0LL);
}

original_code:
int EnvUnwatch(
  void *theEnv,
  char *itemName)
  {
   return(EnvSetWatchItem(theEnv,itemName,0,((void *)0)));
  }

canonical_original_code:
int EnvUnwatch(void *theEnv, char *itemName)
  {
   return(EnvSetWatchItem(theEnv,itemName,0,((void *)0)));
  }


WatchCommand

decompiled_code:
__int64 __fastcall WatchCommand(__int64 a1)
{
__int64 result; // rax
const char *v2; // r12
__int64 v3; // rax
__int64 v4; // rcx
int v5; // [rsp+Ch] [rbp-4Ch] BYREF
char v6[16]; // [rsp+10h] [rbp-48h] BYREF
__int64 v7; // [rsp+20h] [rbp-38h]

result = EnvArgTypeCheck(a1, "watch", 1LL, 2LL, v6);
if ( (_DWORD)result )
{
v2 = *(const char **)(v7 + 24);
v3 = ValidWatchItem(a1, v2, &v5);
if ( v5 )
{
v4 = *(_QWORD *)(*(_QWORD *)(**(_QWORD **)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL) + 24LL);
if ( !v4 || v3 && *(_QWORD *)(v3 + 24) )
{
result = EnvSetWatchItem(a1, v2, 1u, v4);
}
else
{
SetEvaluationError(a1, 1LL);
result = ExpectedCountError(a1, "watch", 0LL, 1LL);
}
}
else
{
SetEvaluationError(a1, 1LL);
result = ExpectedTypeError1(a1, "watch", 1LL, "watchable symbol");
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
__int64 result; // rax
const char *v2; // r12
__int64 v3; // rax
__int64 v4; // rcx
int v5; // [rsp+Ch] [rbp-4Ch] BYREF
char v6[16]; // [rsp+10h] [rbp-48h] BYREF
__int64 v7; // [rsp+20h] [rbp-38h]

result = EnvArgTypeCheck(a1, "watch", 1LL, 2LL, v6);
if ( (_DWORD)result )
{
v2 = *(const char **)(v7 + 24);
v3 = func2(a1, v2, &v5);
if ( v5 )
{
v4 = *(_QWORD *)(*(_QWORD *)(**(_QWORD **)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL) + 24LL);
if ( !v4 || v3 && *(_QWORD *)(v3 + 24) )
{
result = func6(a1, v2, 1u, v4);
}
else
{
SetEvaluationError(a1, 1LL);
result = ExpectedCountError(a1, "watch", 0LL, 1LL);
}
}
else
{
SetEvaluationError(a1, 1LL);
result = ExpectedTypeError1(a1, "watch", 1LL, "watchable symbol");
}
}
return result;
}

original_code:
void WatchCommand(
  void *theEnv)
  {
   DATA_OBJECT theValue;
   char *argument;
   int recognized;
   struct watchItem *wPtr;
   if (EnvArgTypeCheck(theEnv,"watch",1,2,&theValue) == 0) return;
   argument = (((struct symbolHashNode *) (theValue.value))->contents);
   wPtr = ValidWatchItem(theEnv,argument,&recognized);
   if (recognized == 0)
     {
      SetEvaluationError(theEnv,1);
      ExpectedTypeError1(theEnv,"watch",1,"watchable symbol");
      return;
     }
   if (((((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentExpression->argList)->nextArg) != ((void *)0))
     {
      if ((wPtr == ((void *)0)) ? 1 : (wPtr->accessFunc == ((void *)0)))
        {
         SetEvaluationError(theEnv,1);
         ExpectedCountError(theEnv,"watch",0,1);
         return;
        }
     }
   EnvSetWatchItem(theEnv,argument,1,((((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentExpression->argList)->nextArg));
  }

canonical_original_code:
void WatchCommand(void *theEnv)
  {
   struct dataObject theValue;
   char *argument;
   int recognized;
   struct watchItem *wPtr;
   if (EnvArgTypeCheck(theEnv,"watch",1,2,&theValue) == 0) return;
   argument = (((struct symbolHashNode *) (theValue.value))->contents);
   wPtr = ValidWatchItem(theEnv,argument,&recognized);
   if (recognized == 0)
     {
      SetEvaluationError(theEnv,1);
      ExpectedTypeError1(theEnv,"watch",1,"watchable symbol");
      return;
     }
   if (((((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentExpression->argList)->nextArg) != ((void *)0))
     {
      if ((wPtr == ((void *)0)) ? 1 : (wPtr->accessFunc == ((void *)0)))
        {
         SetEvaluationError(theEnv,1);
         ExpectedCountError(theEnv,"watch",0,1);
         return;
        }
     }
   EnvSetWatchItem(theEnv,argument,1,((((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentExpression->argList)->nextArg));
  }

variable_types:
argument
char *

variable_types: recognized int

user_defined_types: struct dataObject { void *supplementalInfo; unsigned short type; void *value; long begin; long end; struct dataObject *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 evaluationData { struct expr *CurrentExpression; int EvaluationError; int HaltExecution; int CurrentEvaluationDepth; struct entityRecord *PrimitivesArray[150]; }

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 userData { unsigned char dataID; struct userData *next; }


UnwatchCommand

decompiled_code:
__int64 __fastcall UnwatchCommand(__int64 a1)
{
__int64 result; // rax
const char *v2; // r12
__int64 v3; // rax
__int64 v4; // rcx
int v5; // [rsp+Ch] [rbp-4Ch] BYREF
char v6[16]; // [rsp+10h] [rbp-48h] BYREF
__int64 v7; // [rsp+20h] [rbp-38h]

result = EnvArgTypeCheck(a1, "unwatch", 1LL, 2LL, v6);
if ( (_DWORD)result )
{
v2 = *(const char **)(v7 + 24);
v3 = ValidWatchItem(a1, v2, &v5);
if ( v5 )
{
v4 = *(_QWORD *)(*(_QWORD *)(**(_QWORD **)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL) + 24LL);
if ( !v4 || v3 && *(_QWORD *)(v3 + 24) )
{
result = EnvSetWatchItem(a1, v2, 0, v4);
}
else
{
SetEvaluationError(a1, 1LL);
result = ExpectedCountError(a1, "unwatch", 0LL, 1LL);
}
}
else
{
SetEvaluationError(a1, 1LL);
result = ExpectedTypeError1(a1, "unwatch", 1LL, "watchable symbol");
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
__int64 result; // rax
const char *v2; // r12
__int64 v3; // rax
__int64 v4; // rcx
int v5; // [rsp+Ch] [rbp-4Ch] BYREF
char v6[16]; // [rsp+10h] [rbp-48h] BYREF
__int64 v7; // [rsp+20h] [rbp-38h]

result = EnvArgTypeCheck(a1, "unwatch", 1LL, 2LL, v6);
if ( (_DWORD)result )
{
v2 = *(const char **)(v7 + 24);
v3 = func2(a1, v2, &v5);
if ( v5 )
{
v4 = *(_QWORD *)(*(_QWORD *)(**(_QWORD **)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL) + 24LL);
if ( !v4 || v3 && *(_QWORD *)(v3 + 24) )
{
result = func6(a1, v2, 0, v4);
}
else
{
SetEvaluationError(a1, 1LL);
result = ExpectedCountError(a1, "unwatch", 0LL, 1LL);
}
}
else
{
SetEvaluationError(a1, 1LL);
result = ExpectedTypeError1(a1, "unwatch", 1LL, "watchable symbol");
}
}
return result;
}

original_code:
void UnwatchCommand(
  void *theEnv)
  {
   DATA_OBJECT theValue;
   char *argument;
   int recognized;
   struct watchItem *wPtr;
   if (EnvArgTypeCheck(theEnv,"unwatch",1,2,&theValue) == 0) return;
   argument = (((struct symbolHashNode *) (theValue.value))->contents);
   wPtr = ValidWatchItem(theEnv,argument,&recognized);
   if (recognized == 0)
     {
      SetEvaluationError(theEnv,1);
      ExpectedTypeError1(theEnv,"unwatch",1,"watchable symbol");
      return;
     }
   if (((((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentExpression->argList)->nextArg) != ((void *)0))
     {
      if ((wPtr == ((void *)0)) ? 1 : (wPtr->accessFunc == ((void *)0)))
        {
         SetEvaluationError(theEnv,1);
         ExpectedCountError(theEnv,"unwatch",0,1);
         return;
        }
     }
   EnvSetWatchItem(theEnv,argument,0,((((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentExpression->argList)->nextArg));
  }

canonical_original_code:
void UnwatchCommand(void *theEnv)
  {
   struct dataObject theValue;
   char *argument;
   int recognized;
   struct watchItem *wPtr;
   if (EnvArgTypeCheck(theEnv,"unwatch",1,2,&theValue) == 0) return;
   argument = (((struct symbolHashNode *) (theValue.value))->contents);
   wPtr = ValidWatchItem(theEnv,argument,&recognized);
   if (recognized == 0)
     {
      SetEvaluationError(theEnv,1);
      ExpectedTypeError1(theEnv,"unwatch",1,"watchable symbol");
      return;
     }
   if (((((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentExpression->argList)->nextArg) != ((void *)0))
     {
      if ((wPtr == ((void *)0)) ? 1 : (wPtr->accessFunc == ((void *)0)))
        {
         SetEvaluationError(theEnv,1);
         ExpectedCountError(theEnv,"unwatch",0,1);
         return;
        }
     }
   EnvSetWatchItem(theEnv,argument,0,((((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentExpression->argList)->nextArg));
  }

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

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


EnvGetWatchItem

decompiled_code:
__int64 __fastcall EnvGetWatchItem(__int64 a1, const char *a2)
{
__int64 v2; // rbx

v2 = **(_QWORD **)(*(_QWORD *)(a1 + 32) + 432LL);
if ( !v2 )
return 0xFFFFFFFFLL;
while ( strcmp(a2, *(const char **)v2) )
{
v2 = *(_QWORD *)(v2 + 40);
if ( !v2 )
return 0xFFFFFFFFLL;
}
return **(unsigned int **)(v2 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, const char *a2)
{
__int64 v2; // rbx

v2 = **(_QWORD **)(*(_QWORD *)(a1 + 32) + 432LL);
if ( !v2 )
return 0xFFFFFFFFLL;
while ( strcmp(a2, *(const char **)v2) )
{
v2 = *(_QWORD *)(v2 + 40);
if ( !v2 )
return 0xFFFFFFFFLL;
}
return **(unsigned int **)(v2 + 8);
}

original_code:
int EnvGetWatchItem(
  void *theEnv,
  char *itemName)
  {
   struct watchItem *wPtr;
   for (wPtr = ((struct watchData *) (((struct environmentData *) theEnv)->theData[54]))->ListOfWatchItems; wPtr != ((void *)0); wPtr = wPtr->next)
     {
      if (strcmp(itemName,wPtr->name) == 0)
        { return((int) *(wPtr->flag)); }
     }
   return(-1);
  }

canonical_original_code:
int EnvGetWatchItem(void *theEnv, char *itemName)
  {
   struct watchItem *wPtr;
   for (wPtr = ((struct watchData *) (((struct environmentData *) theEnv)->theData[54]))->ListOfWatchItems; wPtr != ((void *)0); wPtr = wPtr->next)
     {
      if (strcmp(itemName,wPtr->name) == 0)
        { return((int) *(wPtr->flag)); }
     }
   return(-1);
  }


GetWatchItemCommand

decompiled_code:
_BOOL8 __fastcall GetWatchItemCommand(__int64 a1)
{
const char *v2; // r12
int v3; // [rsp+1Ch] [rbp-4Ch] BYREF
char v4[16]; // [rsp+20h] [rbp-48h] BYREF
__int64 v5; // [rsp+30h] [rbp-38h]

if ( (unsigned int)EnvArgCountCheck(a1, "get-watch-item", 0LL, 1LL) == -1
|| !(unsigned int)EnvArgTypeCheck(a1, "get-watch-item", 1LL, 2LL, v4) )
{
return 0LL;
}
v2 = *(const char **)(v5 + 24);
ValidWatchItem(a1, v2, &v3);
if ( v3 )
return (unsigned int)EnvGetWatchItem(a1, v2) == 1;
SetEvaluationError(a1, 1LL);
ExpectedTypeError1(a1, "get-watch-item", 1LL, "watchable symbol");
return 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func12(__int64 a1)
{
const char *v2; // r12
int v3; // [rsp+1Ch] [rbp-4Ch] BYREF
char v4[16]; // [rsp+20h] [rbp-48h] BYREF
__int64 v5; // [rsp+30h] [rbp-38h]

if ( (unsigned int)EnvArgCountCheck(a1, "get-watch-item", 0LL, 1LL) == -1
|| !(unsigned int)EnvArgTypeCheck(a1, "get-watch-item", 1LL, 2LL, v4) )
{
return 0LL;
}
v2 = *(const char **)(v5 + 24);
func2(a1, v2, &v3);
if ( v3 )
return (unsigned int)func11(a1, v2) == 1;
SetEvaluationError(a1, 1LL);
ExpectedTypeError1(a1, "get-watch-item", 1LL, "watchable symbol");
return 0LL;
}

original_code:
int GetWatchItemCommand(
  void *theEnv)
  {
   DATA_OBJECT theValue;
   char *argument;
   int recognized;
   if (EnvArgCountCheck(theEnv,"get-watch-item",0,1) == -1)
     { return(0); }
   if (EnvArgTypeCheck(theEnv,"get-watch-item",1,2,&theValue) == 0)
     { return(0); }
   argument = (((struct symbolHashNode *) (theValue.value))->contents);
   ValidWatchItem(theEnv,argument,&recognized);
   if (recognized == 0)
     {
      SetEvaluationError(theEnv,1);
      ExpectedTypeError1(theEnv,"get-watch-item",1,"watchable symbol");
      return(0);
     }
   if (EnvGetWatchItem(theEnv,argument) == 1)
     { return(1); }
   return(0);
  }

canonical_original_code:
int GetWatchItemCommand(void *theEnv)
  {
   struct dataObject theValue;
   char *argument;
   int recognized;
   if (EnvArgCountCheck(theEnv,"get-watch-item",0,1) == -1)
     { return(0); }
   if (EnvArgTypeCheck(theEnv,"get-watch-item",1,2,&theValue) == 0)
     { return(0); }
   argument = (((struct symbolHashNode *) (theValue.value))->contents);
   ValidWatchItem(theEnv,argument,&recognized);
   if (recognized == 0)
     {
      SetEvaluationError(theEnv,1);
      ExpectedTypeError1(theEnv,"get-watch-item",1,"watchable symbol");
      return(0);
     }
   if (EnvGetWatchItem(theEnv,argument) == 1)
     { return(1); }
   return(0);
  }


GetNthWatchValue

decompiled_code:
__int64 __fastcall GetNthWatchValue(__int64 a1, int a2)
{
__int64 v2; // rax
int v3; // edx

v2 = **(_QWORD **)(*(_QWORD *)(a1 + 32) + 432LL);
if ( !v2 )
return 0xFFFFFFFFLL;
if ( a2 != 1 )
{
v3 = 1;
while ( 1 )
{
v2 = *(_QWORD *)(v2 + 40);
++v3;
if ( !v2 )
break;
if ( a2 == v3 )
return **(unsigned int **)(v2 + 8);
}
return 0xFFFFFFFFLL;
}
return **(unsigned int **)(v2 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, int a2)
{
__int64 v2; // rax
int v3; // edx

v2 = **(_QWORD **)(*(_QWORD *)(a1 + 32) + 432LL);
if ( !v2 )
return 0xFFFFFFFFLL;
if ( a2 != 1 )
{
v3 = 1;
while ( 1 )
{
v2 = *(_QWORD *)(v2 + 40);
++v3;
if ( !v2 )
break;
if ( a2 == v3 )
return **(unsigned int **)(v2 + 8);
}
return 0xFFFFFFFFLL;
}
return **(unsigned int **)(v2 + 8);
}

original_code:
int GetNthWatchValue(
  void *theEnv,
  int whichItem)
  {
   int i;
   struct watchItem *wPtr;
   for (wPtr = ((struct watchData *) (((struct environmentData *) theEnv)->theData[54]))->ListOfWatchItems, i = 1;
        wPtr != ((void *)0);
        wPtr = wPtr->next, i++)
     { if (i == whichItem) return((int) *(wPtr->flag)); }
   return(-1);
  }

canonical_original_code:
int GetNthWatchValue(void *theEnv, int whichItem)
  {
   int i;
   struct watchItem *wPtr;
   for (wPtr = ((struct watchData *) (((struct environmentData *) theEnv)->theData[54]))->ListOfWatchItems, i = 1;
        wPtr != ((void *)0);
        wPtr = wPtr->next, i++)
     { if (i == whichItem) return((int) *(wPtr->flag)); }
   return(-1);
  }

variable_types: whichItem int

variable_types: i int


WatchFunctionDefinitions

decompiled_code:
__int64 __fastcall WatchFunctionDefinitions(__int64 a1)
{
__int64 v2; // [rsp-8h] [rbp-10h]

EnvDefineFunction2(a1, "watch", 118LL, WatchCommand, "WatchCommand", "1**w");
EnvDefineFunction2(a1, "unwatch", 118LL, UnwatchCommand, "UnwatchCommand", "1**w");
EnvDefineFunction2(a1, "get-watch-item", 98LL, GetWatchItemCommand, "GetWatchItemCommand", "11w");
EnvDefineFunction2(a1, "list-watch-items", 118LL, ListWatchItemsCommand, "ListWatchItemsCommand", "0**w");
EnvAddRouter(a1, "wtrace", 1000LL, RecognizeWatchRouters, CaptureWatchPrints, 0LL, 0LL, 0LL);
return EnvDeactivateRouter(a1, "wtrace", v2);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1)
{
__int64 v2; // [rsp-8h] [rbp-10h]

EnvDefineFunction2(a1, "watch", 118LL, WatchCommand, "WatchCommand", "1**w");
EnvDefineFunction2(a1, "unwatch", 118LL, UnwatchCommand, "UnwatchCommand", "1**w");
EnvDefineFunction2(a1, "get-watch-item", 98LL, GetWatchItemCommand, "GetWatchItemCommand", "11w");
EnvDefineFunction2(a1, "list-watch-items", 118LL, ListWatchItemsCommand, "ListWatchItemsCommand", "0**w");
EnvAddRouter(a1, "wtrace", 1000LL, RecognizeWatchRouters, CaptureWatchPrints, 0LL, 0LL, 0LL);
return EnvDeactivateRouter(a1, "wtrace", v2);
}

original_code:
void WatchFunctionDefinitions(
  void *theEnv)
  {
   EnvDefineFunction2(theEnv,"watch", 'v', (int (*)(void *)) WatchCommand, "WatchCommand", "1**w");
   EnvDefineFunction2(theEnv,"unwatch", 'v', (int (*)(void *)) UnwatchCommand, "UnwatchCommand", "1**w");
   EnvDefineFunction2(theEnv,"get-watch-item", 'b', (int (*)(void *)) GetWatchItemCommand, "GetWatchItemCommand", "11w");
   EnvDefineFunction2(theEnv,"list-watch-items", 'v', (int (*)(void *)) ListWatchItemsCommand,
                   "ListWatchItemsCommand", "0**w");
   EnvAddRouter(theEnv,"wtrace",1000,RecognizeWatchRouters,CaptureWatchPrints,((void *)0),((void *)0),((void *)0));
   EnvDeactivateRouter(theEnv,"wtrace");
  }

canonical_original_code:
void WatchFunctionDefinitions(void *theEnv)
  {
   EnvDefineFunction2(theEnv,"watch", 'v', (int (*)(void *)) WatchCommand, "WatchCommand", "1**w");
   EnvDefineFunction2(theEnv,"unwatch", 'v', (int (*)(void *)) UnwatchCommand, "UnwatchCommand", "1**w");
   EnvDefineFunction2(theEnv,"get-watch-item", 'b', (int (*)(void *)) GetWatchItemCommand, "GetWatchItemCommand", "11w");
   EnvDefineFunction2(theEnv,"list-watch-items", 'v', (int (*)(void *)) ListWatchItemsCommand,
                   "ListWatchItemsCommand", "0**w");
   EnvAddRouter(theEnv,"wtrace",1000,RecognizeWatchRouters,CaptureWatchPrints,((void *)0),((void *)0),((void *)0));
   EnvDeactivateRouter(theEnv,"wtrace");
  }


FindFile

decompiled_code:
_BOOL8 __fastcall FindFile(__int64 a1, const char *a2)
{
return FindFptr(a1, a2) != 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(__int64 a1, const char *a2)
{
return func1(a1, a2) != 0LL;
}

original_code:
int FindFile(
  void *theEnv,
  char *logicalName)
  {
   if (FindFptr(theEnv,logicalName) != ((void *)0)) return(1);
   return(0);
  }

canonical_original_code:
int FindFile(void *theEnv, char *logicalName)
  {
   if (FindFptr(theEnv,logicalName) != ((void *)0)) return(1);
   return(0);
  }

variable_types:
logicalName
char *


ExitFile

decompiled_code:
__int64 __fastcall ExitFile(__int64 a1)
{
CloseAllFiles(a1);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
func8(a1);
return 1LL;
}

original_code:
static int ExitFile(
  void *theEnv,
  int num)
  {
   CloseAllFiles(theEnv);
   return(1);
  }

canonical_original_code:
static int ExitFile(void *theEnv, int num)
  {
   CloseAllFiles(theEnv);
   return(1);
  }

variable_types: num int


InitializePrintUtilityData

decompiled_code:
__int64 __fastcall InitializePrintUtilityData(__int64 a1)
{
return AllocateEnvironmentData(a1, 53LL, 12LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return AllocateEnvironmentData(a1, 53LL, 12LL, 0LL);
}

original_code:
void InitializePrintUtilityData(
  void *theEnv)
  {
   AllocateEnvironmentData(theEnv,53,sizeof(struct printUtilityData),((void *)0));
  }

canonical_original_code:
void InitializePrintUtilityData(void *theEnv)
  {
   AllocateEnvironmentData(theEnv,53,sizeof(struct printUtilityData),((void *)0));
  }

user_defined_types: struct printUtilityData { int PreserveEscapedCharacters; int AddressesToStrings; int InstanceAddressesToNames; }


PrintInChunks

decompiled_code:
void __fastcall PrintInChunks(__int64 a1, __int64 a2, __int64 a3)
{
__int64 i; // r12
char v4; // bl
__int64 v5; // rdx

if ( a3 )
{
for ( i = a3; (int)strlen((const char *)i) > 500; *(_BYTE *)i = v4 )
{
if ( *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 12LL) )
return;
v4 = *(_BYTE *)(i + 500);
v5 = i;
*(_BYTE *)(i + 500) = 0;
i += 500LL;
EnvPrintRouter(a1, a2, v5);
}
EnvPrintRouter(a1, a2, i);
}
}

original_code:
void PrintInChunks(
  void *theEnv,
  char *logicalName,
  char *bigString)
  {
   char tc, *subString;
   subString = bigString;
   if (subString == ((void *)0)) return;
   while (((int) strlen(subString)) > 500)
     {
      if (((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->HaltExecution) return;
      tc = subString[500];
      subString[500] = '\0';
      EnvPrintRouter(theEnv,logicalName,subString);
      subString[500] = tc;
      subString += 500;
     }
   EnvPrintRouter(theEnv,logicalName,subString);
  }

canonical_original_code:
void PrintInChunks(void *theEnv, char *logicalName, char *bigString)
  {
   char tc; char *subString;
   subString = bigString;
   if (subString == ((void *)0)) return;
   while (((int) strlen(subString)) > 500)
     {
      if (((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->HaltExecution) return;
      tc = subString[500];
      subString[500] = '\0';
      EnvPrintRouter(theEnv,logicalName,subString);
      subString[500] = tc;
      subString += 500;
     }
   EnvPrintRouter(theEnv,logicalName,subString);
  }

variable_types:
bigString
char *

variable_types: tc char

variable_types:
subString
char *

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


PrintLongInteger

decompiled_code:
__int64 __fastcall PrintLongInteger(__int64 a1, __int64 a2, __int64 a3)
{
char v4[56]; // [rsp+0h] [rbp-38h] BYREF

sprintf(v4, "%ld", a3);
return EnvPrintRouter(a1, a2, v4);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3)
{
char v4[56]; // [rsp+0h] [rbp-38h] BYREF

sprintf(v4, "%ld", a3);
return EnvPrintRouter(a1, a2, v4);
}

original_code:
void PrintLongInteger(
  void *theEnv,
  char *logicalName,
  long int number)
  {
   char printBuffer[32];
   sprintf(printBuffer,"%ld",number);
   EnvPrintRouter(theEnv,logicalName,printBuffer);
  }

canonical_original_code:
void PrintLongInteger(void *theEnv, char *logicalName, long number)
  {
   char printBuffer[32];
   sprintf(printBuffer,"%ld",number);
   EnvPrintRouter(theEnv,logicalName,printBuffer);
  }

variable_types: number long

variable_types:
printBuffer
char [32]


PrintTally

decompiled_code:
__int64 __fastcall PrintTally(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 result; // rax

if ( a3 )
{
EnvPrintRouter(a1, a2, "For a total of ");
PrintLongInteger(a1, a2, a3);
EnvPrintRouter(a1, a2, " ");
if ( a3 == 1 )
EnvPrintRouter(a1, a2, a4);
else
EnvPrintRouter(a1, a2, a5);
result = EnvPrintRouter(a1, a2, ".\n");
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 result; // rax

if ( a3 )
{
EnvPrintRouter(a1, a2, "For a total of ");
func2(a1, a2, a3);
EnvPrintRouter(a1, a2, " ");
if ( a3 == 1 )
EnvPrintRouter(a1, a2, a4);
else
EnvPrintRouter(a1, a2, a5);
result = EnvPrintRouter(a1, a2, ".\n");
}
return result;
}

original_code:
void PrintTally(
  void *theEnv,
  char *logicalName,
  long count,
  char *singular,
  char *plural)
  {
   if (count == 0) return;
   EnvPrintRouter(theEnv,logicalName,"For a total of ");
   PrintLongInteger(theEnv,logicalName,count);
   EnvPrintRouter(theEnv,logicalName," ");
   if (count == 1) EnvPrintRouter(theEnv,logicalName,singular);
   else EnvPrintRouter(theEnv,logicalName,plural);
   EnvPrintRouter(theEnv,logicalName,".\n");
  }

canonical_original_code:
void PrintTally(void *theEnv, char *logicalName, long count, char *singular, char *plural)
  {
   if (count == 0) return;
   EnvPrintRouter(theEnv,logicalName,"For a total of ");
   PrintLongInteger(theEnv,logicalName,count);
   EnvPrintRouter(theEnv,logicalName," ");
   if (count == 1) EnvPrintRouter(theEnv,logicalName,singular);
   else EnvPrintRouter(theEnv,logicalName,plural);
   EnvPrintRouter(theEnv,logicalName,".\n");
  }

variable_types: count long

variable_types:
singular
char *

variable_types:
plural
char *


PrintErrorID

decompiled_code:
__int64 __fastcall PrintErrorID(__int64 a1, __int64 a2, int a3, int a4)
{
if ( a4 )
EnvPrintRouter(a1, "werror", "\n");
EnvPrintRouter(a1, "werror", "[");
EnvPrintRouter(a1, "werror", a2);
PrintLongInteger(a1, (__int64)"werror", a3);
return EnvPrintRouter(a1, "werror", "] ");
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, int a3, int a4)
{
if ( a4 )
EnvPrintRouter(a1, "werror", "\n");
EnvPrintRouter(a1, "werror", "[");
EnvPrintRouter(a1, "werror", a2);
func2(a1, (__int64)"werror", a3);
return EnvPrintRouter(a1, "werror", "] ");
}

original_code:
void PrintErrorID(
  void *theEnv,
  char *module,
  int errorID,
  int printCR)
  {
   if (printCR) EnvPrintRouter(theEnv,"werror","\n");
   EnvPrintRouter(theEnv,"werror","[");
   EnvPrintRouter(theEnv,"werror",module);
   PrintLongInteger(theEnv,"werror",(long int) errorID);
   EnvPrintRouter(theEnv,"werror","] ");
  }

canonical_original_code:
void PrintErrorID(void *theEnv, char *module, int errorID, int printCR)
  {
   if (printCR) EnvPrintRouter(theEnv,"werror","\n");
   EnvPrintRouter(theEnv,"werror","[");
   EnvPrintRouter(theEnv,"werror",module);
   PrintLongInteger(theEnv,"werror",(long) errorID);
   EnvPrintRouter(theEnv,"werror","] ");
  }

variable_types:
theEnv
void *

variable_types:
module
char *

variable_types: errorID int

variable_types: printCR int


PrintWarningID

decompiled_code:
__int64 __fastcall PrintWarningID(__int64 a1, __int64 a2, int a3, int a4)
{
if ( a4 )
EnvPrintRouter(a1, "wwarning", "\n");
EnvPrintRouter(a1, "wwarning", "[");
EnvPrintRouter(a1, "wwarning", a2);
PrintLongInteger(a1, (__int64)"wwarning", a3);
return EnvPrintRouter(a1, "wwarning", "] WARNING: ");
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2, int a3, int a4)
{
if ( a4 )
EnvPrintRouter(a1, "wwarning", "\n");
EnvPrintRouter(a1, "wwarning", "[");
EnvPrintRouter(a1, "wwarning", a2);
func2(a1, (__int64)"wwarning", a3);
return EnvPrintRouter(a1, "wwarning", "] WARNING: ");
}

original_code:
void PrintWarningID(
  void *theEnv,
  char *module,
  int warningID,
  int printCR)
  {
   if (printCR) EnvPrintRouter(theEnv,"wwarning","\n");
   EnvPrintRouter(theEnv,"wwarning","[");
   EnvPrintRouter(theEnv,"wwarning",module);
   PrintLongInteger(theEnv,"wwarning",(long int) warningID);
   EnvPrintRouter(theEnv,"wwarning","] WARNING: ");
  }

canonical_original_code:
void PrintWarningID(void *theEnv, char *module, int warningID, int printCR)
  {
   if (printCR) EnvPrintRouter(theEnv,"wwarning","\n");
   EnvPrintRouter(theEnv,"wwarning","[");
   EnvPrintRouter(theEnv,"wwarning",module);
   PrintLongInteger(theEnv,"wwarning",(long) warningID);
   EnvPrintRouter(theEnv,"wwarning","] WARNING: ");
  }

variable_types: warningID int


CantFindItemErrorMessage

decompiled_code:
__int64 __fastcall CantFindItemErrorMessage(__int64 a1, __int64 a2, __int64 a3)
{
PrintErrorID(a1, (__int64)"PRNTUTIL", 1, 0);
EnvPrintRouter(a1, "werror", "Unable to find ");
EnvPrintRouter(a1, "werror", a2);
EnvPrintRouter(a1, "werror", " ");
EnvPrintRouter(a1, "werror", a3);
return EnvPrintRouter(a1, "werror", ".\n");
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2, __int64 a3)
{
func4(a1, (__int64)"PRNTUTIL", 1, 0);
EnvPrintRouter(a1, "werror", "Unable to find ");
EnvPrintRouter(a1, "werror", a2);
EnvPrintRouter(a1, "werror", " ");
EnvPrintRouter(a1, "werror", a3);
return EnvPrintRouter(a1, "werror", ".\n");
}

original_code:
void CantFindItemErrorMessage(
  void *theEnv,
  char *itemType,
  char *itemName)
  {
   PrintErrorID(theEnv,"PRNTUTIL",1,0);
   EnvPrintRouter(theEnv,"werror","Unable to find ");
   EnvPrintRouter(theEnv,"werror",itemType);
   EnvPrintRouter(theEnv,"werror"," ");
   EnvPrintRouter(theEnv,"werror",itemName);
   EnvPrintRouter(theEnv,"werror",".\n");
  }

canonical_original_code:
void CantFindItemErrorMessage(void *theEnv, char *itemType, char *itemName)
  {
   PrintErrorID(theEnv,"PRNTUTIL",1,0);
   EnvPrintRouter(theEnv,"werror","Unable to find ");
   EnvPrintRouter(theEnv,"werror",itemType);
   EnvPrintRouter(theEnv,"werror"," ");
   EnvPrintRouter(theEnv,"werror",itemName);
   EnvPrintRouter(theEnv,"werror",".\n");
  }

variable_types:
itemType
char *

variable_types:
itemName
char *


CantFindItemInFunctionErrorMessage

decompiled_code:
__int64 __fastcall CantFindItemInFunctionErrorMessage(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
PrintErrorID(a1, (__int64)"PRNTUTIL", 1, 0);
EnvPrintRouter(a1, "werror", "Unable to find ");
EnvPrintRouter(a1, "werror", a2);
EnvPrintRouter(a1, "werror", " ");
EnvPrintRouter(a1, "werror", a3);
EnvPrintRouter(a1, "werror", " in function ");
EnvPrintRouter(a1, "werror", a4);
return EnvPrintRouter(a1, "werror", ".\n");
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
func4(a1, (__int64)"PRNTUTIL", 1, 0);
EnvPrintRouter(a1, "werror", "Unable to find ");
EnvPrintRouter(a1, "werror", a2);
EnvPrintRouter(a1, "werror", " ");
EnvPrintRouter(a1, "werror", a3);
EnvPrintRouter(a1, "werror", " in function ");
EnvPrintRouter(a1, "werror", a4);
return EnvPrintRouter(a1, "werror", ".\n");
}

original_code:
void CantFindItemInFunctionErrorMessage(
  void *theEnv,
  char *itemType,
  char *itemName,
  char *func)
  {
   PrintErrorID(theEnv,"PRNTUTIL",1,0);
   EnvPrintRouter(theEnv,"werror","Unable to find ");
   EnvPrintRouter(theEnv,"werror",itemType);
   EnvPrintRouter(theEnv,"werror"," ");
   EnvPrintRouter(theEnv,"werror",itemName);
   EnvPrintRouter(theEnv,"werror"," in function ");
   EnvPrintRouter(theEnv,"werror",func);
   EnvPrintRouter(theEnv,"werror",".\n");
  }

canonical_original_code:
void CantFindItemInFunctionErrorMessage(void *theEnv, char *itemType, char *itemName, char *func)
  {
   PrintErrorID(theEnv,"PRNTUTIL",1,0);
   EnvPrintRouter(theEnv,"werror","Unable to find ");
   EnvPrintRouter(theEnv,"werror",itemType);
   EnvPrintRouter(theEnv,"werror"," ");
   EnvPrintRouter(theEnv,"werror",itemName);
   EnvPrintRouter(theEnv,"werror"," in function ");
   EnvPrintRouter(theEnv,"werror",func);
   EnvPrintRouter(theEnv,"werror",".\n");
  }

variable_types:
func
char *


CantDeleteItemErrorMessage

decompiled_code:
__int64 __fastcall CantDeleteItemErrorMessage(__int64 a1, __int64 a2, __int64 a3)
{
PrintErrorID(a1, (__int64)"PRNTUTIL", 4, 0);
EnvPrintRouter(a1, "werror", "Unable to delete ");
EnvPrintRouter(a1, "werror", a2);
EnvPrintRouter(a1, "werror", " ");
EnvPrintRouter(a1, "werror", a3);
return EnvPrintRouter(a1, "werror", ".\n");
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2, __int64 a3)
{
func4(a1, (__int64)"PRNTUTIL", 4, 0);
EnvPrintRouter(a1, "werror", "Unable to delete ");
EnvPrintRouter(a1, "werror", a2);
EnvPrintRouter(a1, "werror", " ");
EnvPrintRouter(a1, "werror", a3);
return EnvPrintRouter(a1, "werror", ".\n");
}

original_code:
void CantDeleteItemErrorMessage(
  void *theEnv,
  char *itemType,
  char *itemName)
  {
   PrintErrorID(theEnv,"PRNTUTIL",4,0);
   EnvPrintRouter(theEnv,"werror","Unable to delete ");
   EnvPrintRouter(theEnv,"werror",itemType);
   EnvPrintRouter(theEnv,"werror"," ");
   EnvPrintRouter(theEnv,"werror",itemName);
   EnvPrintRouter(theEnv,"werror",".\n");
  }

canonical_original_code:
void CantDeleteItemErrorMessage(void *theEnv, char *itemType, char *itemName)
  {
   PrintErrorID(theEnv,"PRNTUTIL",4,0);
   EnvPrintRouter(theEnv,"werror","Unable to delete ");
   EnvPrintRouter(theEnv,"werror",itemType);
   EnvPrintRouter(theEnv,"werror"," ");
   EnvPrintRouter(theEnv,"werror",itemName);
   EnvPrintRouter(theEnv,"werror",".\n");
  }


AlreadyParsedErrorMessage

decompiled_code:
__int64 __fastcall AlreadyParsedErrorMessage(__int64 a1, __int64 a2, __int64 a3)
{
PrintErrorID(a1, (__int64)"PRNTUTIL", 5, 1);
EnvPrintRouter(a1, "werror", "The ");
if ( a2 )
EnvPrintRouter(a1, "werror", a2);
if ( a3 )
EnvPrintRouter(a1, "werror", a3);
return EnvPrintRouter(a1, "werror", " has already been parsed.\n");
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 a2, __int64 a3)
{
func4(a1, (__int64)"PRNTUTIL", 5, 1);
EnvPrintRouter(a1, "werror", "The ");
if ( a2 )
EnvPrintRouter(a1, "werror", a2);
if ( a3 )
EnvPrintRouter(a1, "werror", a3);
return EnvPrintRouter(a1, "werror", " has already been parsed.\n");
}

original_code:
void AlreadyParsedErrorMessage(
  void *theEnv,
  char *itemType,
  char *itemName)
  {
   PrintErrorID(theEnv,"PRNTUTIL",5,1);
   EnvPrintRouter(theEnv,"werror","The ");
   if (itemType != ((void *)0)) EnvPrintRouter(theEnv,"werror",itemType);
   if (itemName != ((void *)0)) EnvPrintRouter(theEnv,"werror",itemName);
   EnvPrintRouter(theEnv,"werror"," has already been parsed.\n");
  }

canonical_original_code:
void AlreadyParsedErrorMessage(void *theEnv, char *itemType, char *itemName)
  {
   PrintErrorID(theEnv,"PRNTUTIL",5,1);
   EnvPrintRouter(theEnv,"werror","The ");
   if (itemType != ((void *)0)) EnvPrintRouter(theEnv,"werror",itemType);
   if (itemName != ((void *)0)) EnvPrintRouter(theEnv,"werror",itemName);
   EnvPrintRouter(theEnv,"werror"," has already been parsed.\n");
  }


SyntaxErrorMessage

decompiled_code:
__int64 __fastcall SyntaxErrorMessage(__int64 a1, __int64 a2)
{
PrintErrorID(a1, (__int64)"PRNTUTIL", 2, 1);
EnvPrintRouter(a1, "werror", "Syntax Error");
if ( a2 )
{
EnvPrintRouter(a1, "werror", ": Check appropriate syntax for ");
EnvPrintRouter(a1, "werror", a2);
}
EnvPrintRouter(a1, "werror", ".\n");
return SetEvaluationError(a1, 1LL);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 a2)
{
func4(a1, (__int64)"PRNTUTIL", 2, 1);
EnvPrintRouter(a1, "werror", "Syntax Error");
if ( a2 )
{
EnvPrintRouter(a1, "werror", ": Check appropriate syntax for ");
EnvPrintRouter(a1, "werror", a2);
}
EnvPrintRouter(a1, "werror", ".\n");
return SetEvaluationError(a1, 1LL);
}

original_code:
void SyntaxErrorMessage(
  void *theEnv,
  char *location)
  {
   PrintErrorID(theEnv,"PRNTUTIL",2,1);
   EnvPrintRouter(theEnv,"werror","Syntax Error");
   if (location != ((void *)0))
     {
      EnvPrintRouter(theEnv,"werror",":  Check appropriate syntax for ");
      EnvPrintRouter(theEnv,"werror",location);
     }
   EnvPrintRouter(theEnv,"werror",".\n");
   SetEvaluationError(theEnv,1);
  }

canonical_original_code:
void SyntaxErrorMessage(void *theEnv, char *location)
  {
   PrintErrorID(theEnv,"PRNTUTIL",2,1);
   EnvPrintRouter(theEnv,"werror","Syntax Error");
   if (location != ((void *)0))
     {
      EnvPrintRouter(theEnv,"werror",":  Check appropriate syntax for ");
      EnvPrintRouter(theEnv,"werror",location);
     }
   EnvPrintRouter(theEnv,"werror",".\n");
   SetEvaluationError(theEnv,1);
  }

variable_types:
location
char *


LocalVariableErrorMessage

decompiled_code:
__int64 __fastcall LocalVariableErrorMessage(__int64 a1, __int64 a2)
{
PrintErrorID(a1, (__int64)"PRNTUTIL", 6, 1);
EnvPrintRouter(a1, "werror", "Local variables can not be accessed by ");
EnvPrintRouter(a1, "werror", a2);
return EnvPrintRouter(a1, "werror", ".\n");
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int64 a2)
{
func4(a1, (__int64)"PRNTUTIL", 6, 1);
EnvPrintRouter(a1, "werror", "Local variables can not be accessed by ");
EnvPrintRouter(a1, "werror", a2);
return EnvPrintRouter(a1, "werror", ".\n");
}

original_code:
void LocalVariableErrorMessage(
  void *theEnv,
  char *byWhat)
  {
   PrintErrorID(theEnv,"PRNTUTIL",6,1);
   EnvPrintRouter(theEnv,"werror","Local variables can not be accessed by ");
   EnvPrintRouter(theEnv,"werror",byWhat);
   EnvPrintRouter(theEnv,"werror",".\n");
  }

canonical_original_code:
void LocalVariableErrorMessage(void *theEnv, char *byWhat)
  {
   PrintErrorID(theEnv,"PRNTUTIL",6,1);
   EnvPrintRouter(theEnv,"werror","Local variables can not be accessed by ");
   EnvPrintRouter(theEnv,"werror",byWhat);
   EnvPrintRouter(theEnv,"werror",".\n");
  }

variable_types:
byWhat
char *


SystemError

decompiled_code:
__int64 __fastcall SystemError(__int64 a1, __int64 a2, int a3)
{
PrintErrorID(a1, (__int64)"PRNTUTIL", 3, 1);
EnvPrintRouter(a1, "werror", "\n*** ");
EnvPrintRouter(a1, "werror", "CLIPS");
EnvPrintRouter(a1, "werror", " SYSTEM ERROR ***\n");
EnvPrintRouter(a1, "werror", "ID = ");
EnvPrintRouter(a1, "werror", a2);
PrintLongInteger(a1, (__int64)"werror", a3);
EnvPrintRouter(a1, "werror", "\n");
EnvPrintRouter(a1, "werror", "CLIPS");
EnvPrintRouter(a1, "werror", " data structures are in an inconsistent or corrupted state.\n");
EnvPrintRouter(a1, "werror", "This error may have occurred from errors in user defined code.\n");
return EnvPrintRouter(a1, "werror", "**************************\n");
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2, int a3)
{
func4(a1, (__int64)"PRNTUTIL", 3, 1);
EnvPrintRouter(a1, "werror", "\n*** ");
EnvPrintRouter(a1, "werror", "CLIPS");
EnvPrintRouter(a1, "werror", " SYSTEM ERROR ***\n");
EnvPrintRouter(a1, "werror", "ID = ");
EnvPrintRouter(a1, "werror", a2);
func2(a1, (__int64)"werror", a3);
EnvPrintRouter(a1, "werror", "\n");
EnvPrintRouter(a1, "werror", "CLIPS");
EnvPrintRouter(a1, "werror", " data structures are in an inconsistent or corrupted state.\n");
EnvPrintRouter(a1, "werror", "This error may have occurred from errors in user defined code.\n");
return EnvPrintRouter(a1, "werror", "**************************\n");
}

original_code:
void SystemError(
  void *theEnv,
  char *module,
  int errorID)
  {
   PrintErrorID(theEnv,"PRNTUTIL",3,1);
   EnvPrintRouter(theEnv,"werror","\n*** ");
   EnvPrintRouter(theEnv,"werror","CLIPS");
   EnvPrintRouter(theEnv,"werror"," SYSTEM ERROR ***\n");
   EnvPrintRouter(theEnv,"werror","ID = ");
   EnvPrintRouter(theEnv,"werror",module);
   PrintLongInteger(theEnv,"werror",(long int) errorID);
   EnvPrintRouter(theEnv,"werror","\n");
   EnvPrintRouter(theEnv,"werror","CLIPS");
   EnvPrintRouter(theEnv,"werror"," data structures are in an inconsistent or corrupted state.\n");
   EnvPrintRouter(theEnv,"werror","This error may have occurred from errors in user defined code.\n");
   EnvPrintRouter(theEnv,"werror","**************************\n");
  }

canonical_original_code:
void SystemError(void *theEnv, char *module, int errorID)
  {
   PrintErrorID(theEnv,"PRNTUTIL",3,1);
   EnvPrintRouter(theEnv,"werror","\n*** ");
   EnvPrintRouter(theEnv,"werror","CLIPS");
   EnvPrintRouter(theEnv,"werror"," SYSTEM ERROR ***\n");
   EnvPrintRouter(theEnv,"werror","ID = ");
   EnvPrintRouter(theEnv,"werror",module);
   PrintLongInteger(theEnv,"werror",(long) errorID);
   EnvPrintRouter(theEnv,"werror","\n");
   EnvPrintRouter(theEnv,"werror","CLIPS");
   EnvPrintRouter(theEnv,"werror"," data structures are in an inconsistent or corrupted state.\n");
   EnvPrintRouter(theEnv,"werror","This error may have occurred from errors in user defined code.\n");
   EnvPrintRouter(theEnv,"werror","**************************\n");
  }


DivideByZeroErrorMessage

decompiled_code:
__int64 __fastcall DivideByZeroErrorMessage(__int64 a1, __int64 a2)
{
PrintErrorID(a1, (__int64)"PRNTUTIL", 7, 0);
EnvPrintRouter(a1, "werror", "Attempt to divide by zero in ");
EnvPrintRouter(a1, "werror", a2);
return EnvPrintRouter(a1, "werror", " function.\n");
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2)
{
func4(a1, (__int64)"PRNTUTIL", 7, 0);
EnvPrintRouter(a1, "werror", "Attempt to divide by zero in ");
EnvPrintRouter(a1, "werror", a2);
return EnvPrintRouter(a1, "werror", " function.\n");
}

original_code:
void DivideByZeroErrorMessage(
  void *theEnv,
  char *functionName)
  {
   PrintErrorID(theEnv,"PRNTUTIL",7,0);
   EnvPrintRouter(theEnv,"werror","Attempt to divide by zero in ");
   EnvPrintRouter(theEnv,"werror",functionName);
   EnvPrintRouter(theEnv,"werror"," function.\n");
  }

canonical_original_code:
void DivideByZeroErrorMessage(void *theEnv, char *functionName)
  {
   PrintErrorID(theEnv,"PRNTUTIL",7,0);
   EnvPrintRouter(theEnv,"werror","Attempt to divide by zero in ");
   EnvPrintRouter(theEnv,"werror",functionName);
   EnvPrintRouter(theEnv,"werror"," function.\n");
  }

variable_types:
functionName
char *


FloatToString

decompiled_code:
__int64 __fastcall FloatToString(__int64 a1, double a2)
{
char v2; // al
__int64 v3; // rdx
size_t v4; // rax
char vars0; // [rsp+0h] [rbp+0h] BYREF
char vars1; // [rsp+1h] [rbp+1h] BYREF

sprintf(&vars0, "%.15g", a2);
v2 = vars0;
if ( vars0 )
{
v3 = (__int64)&vars1;
while ( v2 != 46 && v2 != 101 )
{
v2 = *(_BYTE *)v3++;
if ( !v2 )
goto LABEL_6;
}
}
else
{
LABEL_6:
v4 = strlen(&vars0);
v3 = 12334LL;
strcpy(&vars0 + v4, ".0");
}
return *(_QWORD *)(EnvAddSymbol(a1, &vars0, v3) + 24);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, double a2)
{
char v2; // al
__int64 v3; // rdx
size_t v4; // rax
char vars0; // [rsp+0h] [rbp+0h] BYREF
char vars1; // [rsp+1h] [rbp+1h] BYREF

sprintf(&vars0, "%.15g", a2);
v2 = vars0;
if ( vars0 )
{
v3 = (__int64)&vars1;
while ( v2 != 46 && v2 != 101 )
{
v2 = *(_BYTE *)v3++;
if ( !v2 )
goto LABEL_6;
}
}
else
{
LABEL_6:
v4 = strlen(&vars0);
v3 = 12334LL;
strcpy(&vars0 + v4, ".0");
}
return *(_QWORD *)(EnvAddSymbol(a1, &vars0, v3) + 24);
}

original_code:
char *FloatToString(
  void *theEnv,
  double number)
  {
   char floatString[40];
   int i;
   char x;
   void *thePtr;
   sprintf(floatString,"%.15g",number);
   for (i = 0; (x = floatString[i]) != '\0'; i++)
     {
      if ((x == '.') || (x == 'e'))
        {
         thePtr = EnvAddSymbol(theEnv,floatString);
         return((((struct symbolHashNode *) (thePtr))->contents));
        }
     }
   strcat(floatString,".0");
   thePtr = EnvAddSymbol(theEnv,floatString);
   return((((struct symbolHashNode *) (thePtr))->contents));
  }

canonical_original_code:
char *FloatToString(void *theEnv, double number)
  {
   char floatString[40];
   int i;
   char x;
   void *thePtr;
   sprintf(floatString,"%.15g",number);
   for (i = 0; (x = floatString[i]) != '\0'; i++)
     {
      if ((x == '.') || (x == 'e'))
        {
         thePtr = EnvAddSymbol(theEnv,floatString);
         return((((struct symbolHashNode *) (thePtr))->contents));
        }
     }
   strcat(floatString,".0");
   thePtr = EnvAddSymbol(theEnv,floatString);
   return((((struct symbolHashNode *) (thePtr))->contents));
  }

variable_types: number double

variable_types:
floatString
char [40]

variable_types: i int

variable_types: x char

variable_types:
thePtr
void *

return_type: char *


PrintFloat

decompiled_code:
__int64 __fastcall PrintFloat(__int64 a1, __int64 a2, double a3)
{
__int64 v3; // rax

v3 = FloatToString(a1, a3);
return EnvPrintRouter(a1, a2, v3);
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, __int64 a2, double a3)
{
__int64 v3; // rax

v3 = func14(a1, a3);
return EnvPrintRouter(a1, a2, v3);
}

original_code:
void PrintFloat(
  void *theEnv,
  char *fileid,
  double number)
  {
   char *theString;
   theString = FloatToString(theEnv,number);
   EnvPrintRouter(theEnv,fileid,theString);
  }

canonical_original_code:
void PrintFloat(void *theEnv, char *fileid, double number)
  {
   char *theString;
   theString = FloatToString(theEnv,number);
   EnvPrintRouter(theEnv,fileid,theString);
  }

variable_types:
fileid
char *

variable_types:
theString
char *


PrintAtom

decompiled_code:
void __fastcall PrintAtom(__int64 a1, __int64 a2, int a3, double *a4)
{
__int64 v5; // rax
void (__fastcall *v6)(__int64, __int64, double *); // rax
const char *v7; // rdx
char v8[72]; // [rsp+0h] [rbp-48h] BYREF

if ( a3 > 8 )
{
if ( a3 == 175 )
return;
}
else if ( a3 >= 0 )
{
switch ( a3 )
{
case 0:
PrintFloat(a1, a2, a4[3]);
break;
case 1:
PrintLongInteger(a1, a2, *((_QWORD *)a4 + 3));
break;
case 2:
v7 = (const char *)*((_QWORD *)a4 + 3);
goto LABEL_12;
case 3:
if ( **(_DWORD **)(*(_QWORD *)(a1 + 32) + 424LL) )
{
v7 = (const char *)StringPrintForm(a1, *((_QWORD *)a4 + 3));
}
else
{
EnvPrintRouter(a1, a2, "\"");
EnvPrintRouter(a1, a2, *((_QWORD *)a4 + 3));
v7 = "\"";
}
goto LABEL_12;
case 5:
if ( *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 424LL) + 4LL) )
EnvPrintRouter(a1, a2, "\"");
EnvPrintRouter(a1, a2, "<Pointer-");
sprintf(v8, "%p", a4);
EnvPrintRouter(a1, a2, v8);
EnvPrintRouter(a1, a2, ">");
if ( *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 424LL) + 4LL) )
EnvPrintRouter(a1, a2, "\"");
break;
case 8:
EnvPrintRouter(a1, a2, "[");
EnvPrintRouter(a1, a2, *((_QWORD *)a4 + 3));
v7 = "]";
goto LABEL_12;
default:
goto LABEL_6;
}
return;
}
LABEL_6:
v5 = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 8LL * a3 + 24);
if ( v5 )
{
v6 = *(void (__fastcall **)(__int64, __int64, double *))(v5 + 24);
v7 = "<unknown atom type>";
if ( v6 )
v6(a1, a2, a4);
else
LABEL_12:
EnvPrintRouter(a1, a2, v7);
}
}

canonical_decompiled_code:
void __fastcall func16(__int64 a1, __int64 a2, int a3, double *a4)
{
__int64 v5; // rax
void (__fastcall *v6)(__int64, __int64, double *); // rax
const char *v7; // rdx
char v8[72]; // [rsp+0h] [rbp-48h] BYREF

if ( a3 > 8 )
{
if ( a3 == 175 )
return;
}
else if ( a3 >= 0 )
{
switch ( a3 )
{
case 0:
func15(a1, a2, a4[3]);
break;
case 1:
func2(a1, a2, *((_QWORD *)a4 + 3));
break;
case 2:
v7 = (const char *)*((_QWORD *)a4 + 3);
goto LABEL_12;
case 3:
if ( **(_DWORD **)(*(_QWORD *)(a1 + 32) + 424LL) )
{
v7 = (const char *)StringPrintForm(a1, *((_QWORD *)a4 + 3));
}
else
{
EnvPrintRouter(a1, a2, "\"");
EnvPrintRouter(a1, a2, *((_QWORD *)a4 + 3));
v7 = "\"";
}
goto LABEL_12;
case 5:
if ( *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 424LL) + 4LL) )
EnvPrintRouter(a1, a2, "\"");
EnvPrintRouter(a1, a2, "<Pointer-");
sprintf(v8, "%p", a4);
EnvPrintRouter(a1, a2, v8);
EnvPrintRouter(a1, a2, ">");
if ( *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 424LL) + 4LL) )
EnvPrintRouter(a1, a2, "\"");
break;
case 8:
EnvPrintRouter(a1, a2, "[");
EnvPrintRouter(a1, a2, *((_QWORD *)a4 + 3));
v7 = "]";
goto LABEL_12;
default:
goto LABEL_6;
}
return;
}
LABEL_6:
v5 = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 8LL * a3 + 24);
if ( v5 )
{
v6 = *(void (__fastcall **)(__int64, __int64, double *))(v5 + 24);
v7 = "<unknown atom type>";
if ( v6 )
v6(a1, a2, a4);
else
LABEL_12:
EnvPrintRouter(a1, a2, v7);
}
}

original_code:
void PrintAtom(
  void *theEnv,
  char *logicalName,
  int type,
  void *value)
  {
   char buffer[20];
   switch (type)
     {
      case 0:
        PrintFloat(theEnv,logicalName,(((struct floatHashNode *) (value))->contents));
        break;
      case 1:
        PrintLongInteger(theEnv,logicalName,(((struct integerHashNode *) (value))->contents));
        break;
      case 2:
        EnvPrintRouter(theEnv,logicalName,(((struct symbolHashNode *) (value))->contents));
        break;
      case 3:
        if (((struct printUtilityData *) (((struct environmentData *) theEnv)->theData[53]))->PreserveEscapedCharacters)
          { EnvPrintRouter(theEnv,logicalName,StringPrintForm(theEnv,(((struct symbolHashNode *) (value))->contents))); }
        else
          {
           EnvPrintRouter(theEnv,logicalName,"\"");
           EnvPrintRouter(theEnv,logicalName,(((struct symbolHashNode *) (value))->contents));
           EnvPrintRouter(theEnv,logicalName,"\"");
          }
        break;
      case 5:
        if (((struct printUtilityData *) (((struct environmentData *) theEnv)->theData[53]))->AddressesToStrings) EnvPrintRouter(theEnv,logicalName,"\"");
        EnvPrintRouter(theEnv,logicalName,"<Pointer-");
        sprintf(buffer,"%p",value);
        EnvPrintRouter(theEnv,logicalName,buffer);
        EnvPrintRouter(theEnv,logicalName,">");
        if (((struct printUtilityData *) (((struct environmentData *) theEnv)->theData[53]))->AddressesToStrings) EnvPrintRouter(theEnv,logicalName,"\"");
        break;
      case 8:
        EnvPrintRouter(theEnv,logicalName,"[");
        EnvPrintRouter(theEnv,logicalName,(((struct symbolHashNode *) (value))->contents));
        EnvPrintRouter(theEnv,logicalName,"]");
        break;
      case 175:
        break;
      default:
        if (((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->PrimitivesArray[type] == ((void *)0)) break;
        if (((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->PrimitivesArray[type]->longPrintFunction == ((void *)0))
          {
           EnvPrintRouter(theEnv,logicalName,"<unknown atom type>");
           break;
          }
        (*((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->PrimitivesArray[type]->longPrintFunction)(theEnv,logicalName,value);
        break;
     }
  }

canonical_original_code:
void PrintAtom(void *theEnv, char *logicalName, int type, void *value)
  {
   char buffer[20];
   switch (type)
     {
      case 0:
        PrintFloat(theEnv,logicalName,(((struct floatHashNode *) (value))->contents));
        break;
      case 1:
        PrintLongInteger(theEnv,logicalName,(((struct integerHashNode *) (value))->contents));
        break;
      case 2:
        EnvPrintRouter(theEnv,logicalName,(((struct symbolHashNode *) (value))->contents));
        break;
      case 3:
        if (((struct printUtilityData *) (((struct environmentData *) theEnv)->theData[53]))->PreserveEscapedCharacters)
          { EnvPrintRouter(theEnv,logicalName,StringPrintForm(theEnv,(((struct symbolHashNode *) (value))->contents))); }
        else
          {
           EnvPrintRouter(theEnv,logicalName,"\"");
           EnvPrintRouter(theEnv,logicalName,(((struct symbolHashNode *) (value))->contents));
           EnvPrintRouter(theEnv,logicalName,"\"");
          }
        break;
      case 5:
        if (((struct printUtilityData *) (((struct environmentData *) theEnv)->theData[53]))->AddressesToStrings) EnvPrintRouter(theEnv,logicalName,"\"");
        EnvPrintRouter(theEnv,logicalName,"<Pointer-");
        sprintf(buffer,"%p",value);
        EnvPrintRouter(theEnv,logicalName,buffer);
        EnvPrintRouter(theEnv,logicalName,">");
        if (((struct printUtilityData *) (((struct environmentData *) theEnv)->theData[53]))->AddressesToStrings) EnvPrintRouter(theEnv,logicalName,"\"");
        break;
      case 8:
        EnvPrintRouter(theEnv,logicalName,"[");
        EnvPrintRouter(theEnv,logicalName,(((struct symbolHashNode *) (value))->contents));
        EnvPrintRouter(theEnv,logicalName,"]");
        break;
      case 175:
        break;
      default:
        if (((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->PrimitivesArray[type] == ((void *)0)) break;
        if (((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->PrimitivesArray[type]->longPrintFunction == ((void *)0))
          {
           EnvPrintRouter(theEnv,logicalName,"<unknown atom type>");
           break;
          }
        (*((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->PrimitivesArray[type]->longPrintFunction)(theEnv,logicalName,value);
        break;
     }
  }

variable_types:
theEnv
void *

variable_types:
logicalName
char *

variable_types: type int

variable_types:
value
void *

variable_types:
buffer
char [20]

user_defined_types: struct floatHashNode { struct floatHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int neededFloat; unsigned int bucket; double contents; }


LongIntegerToString

decompiled_code:
__int64 __fastcall LongIntegerToString(__int64 a1, __int64 a2)
{
__int64 v2; // rdx
char v4[56]; // [rsp+0h] [rbp-38h] BYREF

sprintf(v4, "%ld", a2);
return *(_QWORD *)(EnvAddSymbol(a1, v4, v2) + 24);
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, __int64 a2)
{
__int64 v2; // rdx
char v4[56]; // [rsp+0h] [rbp-38h] BYREF

sprintf(v4, "%ld", a2);
return *(_QWORD *)(EnvAddSymbol(a1, v4, v2) + 24);
}

original_code:
char *LongIntegerToString(
  void *theEnv,
  long number)
  {
   char buffer[30];
   void *thePtr;
   sprintf(buffer,"%ld",number);
   thePtr = EnvAddSymbol(theEnv,buffer);
   return((((struct symbolHashNode *) (thePtr))->contents));
  }

canonical_original_code:
char *LongIntegerToString(void *theEnv, long number)
  {
   char buffer[30];
   void *thePtr;
   sprintf(buffer,"%ld",number);
   thePtr = EnvAddSymbol(theEnv,buffer);
   return((((struct symbolHashNode *) (thePtr))->contents));
  }

variable_types: number long

variable_types:
buffer
char [30]