EnvGetFactList

decompiled_code:
__int64 __fastcall EnvGetFactList(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v5; // rsi
__int64 v6; // r13
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rbx
__int64 i; // rsi
__int64 v12; // rsi
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rbx

SaveCurrentModule();
if ( a3 )
{
EnvSetCurrentModule(a1, a3);
UpdateDeftemplateScope(a1);
v5 = GetNextFactInScope(a1, 0LL);
if ( v5 )
{
v6 = 0LL;
do
{
v5 = GetNextFactInScope(a1, v5);
v7 = v6++;
}
while ( v5 );
}
else
{
v7 = -1LL;
v6 = 0LL;
}
*(_QWORD *)(a2 + 32) = v7;
*(_WORD *)(a2 + 8) = 4;
*(_QWORD *)(a2 + 24) = 0LL;
v8 = EnvCreateMultifield(a1, v6);
*(_QWORD *)(a2 + 16) = v8;
v9 = v8 + 24;
for ( i = GetNextFactInScope(a1, 0LL); i; i = GetNextFactInScope(a1, i) )
{
*(_QWORD *)(v9 + 8) = i;
v9 += 16LL;
*(_WORD *)(v9 - 16) = 6;
}
}
else
{
v12 = EnvGetNextFact(a1, 0LL);
if ( v12 )
{
do
{
v12 = EnvGetNextFact(a1, v12);
v13 = a3++;
}
while ( v12 );
}
else
{
v13 = -1LL;
a3 = 0LL;
}
*(_QWORD *)(a2 + 32) = v13;
*(_WORD *)(a2 + 8) = 4;
*(_QWORD *)(a2 + 24) = 0LL;
v14 = EnvCreateMultifield(a1, a3);
*(_QWORD *)(a2 + 16) = v14;
v15 = v14 + 24;
for ( i = EnvGetNextFact(a1, 0LL); i; i = EnvGetNextFact(a1, i) )
{
*(_QWORD *)(v15 + 8) = i;
v15 += 16LL;
*(_WORD *)(v15 - 16) = 6;
}
}
RestoreCurrentModule(a1, i);
return UpdateDeftemplateScope(a1);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v5; // rsi
__int64 v6; // r13
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rbx
__int64 i; // rsi
__int64 v12; // rsi
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rbx

SaveCurrentModule();
if ( a3 )
{
EnvSetCurrentModule(a1, a3);
UpdateDeftemplateScope(a1);
v5 = GetNextFactInScope(a1, 0LL);
if ( v5 )
{
v6 = 0LL;
do
{
v5 = GetNextFactInScope(a1, v5);
v7 = v6++;
}
while ( v5 );
}
else
{
v7 = -1LL;
v6 = 0LL;
}
*(_QWORD *)(a2 + 32) = v7;
*(_WORD *)(a2 + 8) = 4;
*(_QWORD *)(a2 + 24) = 0LL;
v8 = EnvCreateMultifield(a1, v6);
*(_QWORD *)(a2 + 16) = v8;
v9 = v8 + 24;
for ( i = GetNextFactInScope(a1, 0LL); i; i = GetNextFactInScope(a1, i) )
{
*(_QWORD *)(v9 + 8) = i;
v9 += 16LL;
*(_WORD *)(v9 - 16) = 6;
}
}
else
{
v12 = EnvGetNextFact(a1, 0LL);
if ( v12 )
{
do
{
v12 = EnvGetNextFact(a1, v12);
v13 = a3++;
}
while ( v12 );
}
else
{
v13 = -1LL;
a3 = 0LL;
}
*(_QWORD *)(a2 + 32) = v13;
*(_WORD *)(a2 + 8) = 4;
*(_QWORD *)(a2 + 24) = 0LL;
v14 = EnvCreateMultifield(a1, a3);
*(_QWORD *)(a2 + 16) = v14;
v15 = v14 + 24;
for ( i = EnvGetNextFact(a1, 0LL); i; i = EnvGetNextFact(a1, i) )
{
*(_QWORD *)(v15 + 8) = i;
v15 += 16LL;
*(_WORD *)(v15 - 16) = 6;
}
}
RestoreCurrentModule(a1, i);
return UpdateDeftemplateScope(a1);
}

original_code:
void EnvGetFactList(
  void *theEnv,
  DATA_OBJECT_PTR returnValue,
  void *vTheModule)
  {
   struct fact *theFact;
   unsigned long count;
   struct multifield *theList;
   struct defmodule *theModule = (struct defmodule *) vTheModule;
   SaveCurrentModule(theEnv);
   if (theModule == ((void *)0))
     {
      for (theFact = (struct fact *) EnvGetNextFact(theEnv,((void *)0)), count = 0;
           theFact != ((void *)0);
           theFact = (struct fact *) EnvGetNextFact(theEnv,theFact), count++)
        { }
     }
   else
     {
      EnvSetCurrentModule(theEnv,(void *) theModule);
      UpdateDeftemplateScope(theEnv);
      for (theFact = (struct fact *) GetNextFactInScope(theEnv,((void *)0)), count = 0;
           theFact != ((void *)0);
           theFact = (struct fact *) GetNextFactInScope(theEnv,theFact), count++)
        { }
     }
   ((returnValue)->type = (unsigned short) (4));
   ((returnValue)->begin = (long) ((1) - 1));
   ((returnValue)->end = (long) (((long) count) - 1));
   theList = (struct multifield *) EnvCreateMultifield(theEnv,count);
   ((returnValue)->value = (void *) ((void *) theList));
   if (theModule == ((void *)0))
     {
      for (theFact = (struct fact *) EnvGetNextFact(theEnv,((void *)0)), count = 1;
           theFact != ((void *)0);
           theFact = (struct fact *) EnvGetNextFact(theEnv,theFact), count++)
        {
         (((struct field *) ((struct multifield *) (theList))->theFields)[count-1].type = (unsigned short) (6));
         (((struct field *) ((struct multifield *) (theList))->theFields)[count-1].value = (void *) ((void *) theFact));
        }
     }
   else
     {
      for (theFact = (struct fact *) GetNextFactInScope(theEnv,((void *)0)), count = 1;
           theFact != ((void *)0);
           theFact = (struct fact *) GetNextFactInScope(theEnv,theFact), count++)
        {
         (((struct field *) ((struct multifield *) (theList))->theFields)[count-1].type = (unsigned short) (6));
         (((struct field *) ((struct multifield *) (theList))->theFields)[count-1].value = (void *) ((void *) theFact));
        }
     }
   RestoreCurrentModule(theEnv);
   UpdateDeftemplateScope(theEnv);
  }

canonical_original_code:
void EnvGetFactList(void *theEnv, struct dataObject *returnValue, void *vTheModule)
  {
   struct fact *theFact;
   unsigned long count;
   struct multifield *theList;
   struct defmodule *theModule = (struct defmodule *) vTheModule;
   SaveCurrentModule(theEnv);
   if (theModule == ((void *)0))
     {
      for (theFact = (struct fact *) EnvGetNextFact(theEnv,((void *)0)), count = 0;
           theFact != ((void *)0);
           theFact = (struct fact *) EnvGetNextFact(theEnv,theFact), count++)
        { }
     }
   else
     {
      EnvSetCurrentModule(theEnv,(void *) theModule);
      UpdateDeftemplateScope(theEnv);
      for (theFact = (struct fact *) GetNextFactInScope(theEnv,((void *)0)), count = 0;
           theFact != ((void *)0);
           theFact = (struct fact *) GetNextFactInScope(theEnv,theFact), count++)
        { }
     }
   ((returnValue)->type = (unsigned short) (4));
   ((returnValue)->begin = (long) ((1) - 1));
   ((returnValue)->end = (long) (((long) count) - 1));
   theList = (struct multifield *) EnvCreateMultifield(theEnv,count);
   ((returnValue)->value = (void *) ((void *) theList));
   if (theModule == ((void *)0))
     {
      for (theFact = (struct fact *) EnvGetNextFact(theEnv,((void *)0)), count = 1;
           theFact != ((void *)0);
           theFact = (struct fact *) EnvGetNextFact(theEnv,theFact), count++)
        {
         (((struct field *) ((struct multifield *) (theList))->theFields)[count-1].type = (unsigned short) (6));
         (((struct field *) ((struct multifield *) (theList))->theFields)[count-1].value = (void *) ((void *) theFact));
        }
     }
   else
     {
      for (theFact = (struct fact *) GetNextFactInScope(theEnv,((void *)0)), count = 1;
           theFact != ((void *)0);
           theFact = (struct fact *) GetNextFactInScope(theEnv,theFact), count++)
        {
         (((struct field *) ((struct multifield *) (theList))->theFields)[count-1].type = (unsigned short) (6));
         (((struct field *) ((struct multifield *) (theList))->theFields)[count-1].value = (void *) ((void *) theFact));
        }
     }
   RestoreCurrentModule(theEnv);
   UpdateDeftemplateScope(theEnv);
  }

variable_types:
vTheModule
void *

variable_types:
count
unsigned long

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

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

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

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

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

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

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

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


GetFactListFunction

repo: jarcec/rbclips

decompiled_code:
__int64 __fastcall GetFactListFunction(__int64 a1, __int64 a2)
{
int v2; // eax
__int64 v3; // rdx
_BYTE *v5; // rax
_WORD v6[8]; // [rsp+0h] [rbp-48h] BYREF
__int64 v7; // [rsp+10h] [rbp-38h]

v2 = EnvArgCountCheck(a1, "get-fact-list", 2LL, 1LL);
if ( v2 == -1 )
return EnvSetMultifieldErrorValue(a1, a2);
if ( v2 != 1 )
{
v3 = EnvGetCurrentModule(a1);
return EnvGetFactList(a1, a2, v3);
}
EnvRtnUnknown(a1, 1LL, v6);
if ( v6[4] == 2 )
{
v3 = EnvFindDefmodule(a1, *(_QWORD *)(v7 + 24));
if ( v3 )
return EnvGetFactList(a1, a2, v3);
v5 = *(_BYTE **)(v7 + 24);
if ( *v5 == 42 && !v5[1] )
return EnvGetFactList(a1, a2, v3);
}
EnvSetMultifieldErrorValue(a1, a2);
return ExpectedTypeError1(a1, "get-fact-list", 1LL, "defmodule name");
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
int v2; // eax
__int64 v3; // rdx
_BYTE *v5; // rax
_WORD v6[8]; // [rsp+0h] [rbp-48h] BYREF
__int64 v7; // [rsp+10h] [rbp-38h]

v2 = EnvArgCountCheck(a1, "get-fact-list", 2LL, 1LL);
if ( v2 == -1 )
return EnvSetMultifieldErrorValue(a1, a2);
if ( v2 != 1 )
{
v3 = EnvGetCurrentModule(a1);
return func6(a1, a2, v3);
}
EnvRtnUnknown(a1, 1LL, v6);
if ( v6[4] == 2 )
{
v3 = EnvFindDefmodule(a1, *(_QWORD *)(v7 + 24));
if ( v3 )
return func6(a1, a2, v3);
v5 = *(_BYTE **)(v7 + 24);
if ( *v5 == 42 && !v5[1] )
return func6(a1, a2, v3);
}
EnvSetMultifieldErrorValue(a1, a2);
return ExpectedTypeError1(a1, "get-fact-list", 1LL, "defmodule name");
}

original_code:
void GetFactListFunction(
  void *theEnv,
  DATA_OBJECT_PTR returnValue)
  {
   struct defmodule *theModule;
   DATA_OBJECT result;
   int numArgs;
   if ((numArgs = EnvArgCountCheck(theEnv,"get-fact-list",2,1)) == -1)
     {
      EnvSetMultifieldErrorValue(theEnv,returnValue);
      return;
     }
   if (numArgs == 1)
     {
      EnvRtnUnknown(theEnv,1,&result);
      if (((result).type) != 2)
        {
         EnvSetMultifieldErrorValue(theEnv,returnValue);
         ExpectedTypeError1(theEnv,"get-fact-list",1,"defmodule name");
         return;
        }
      if ((theModule = (struct defmodule *) EnvFindDefmodule(theEnv,(((struct symbolHashNode *) (result.value))->contents))) == ((void *)0))
        {
         if (strcmp("*",(((struct symbolHashNode *) (result.value))->contents)) != 0)
           {
            EnvSetMultifieldErrorValue(theEnv,returnValue);
            ExpectedTypeError1(theEnv,"get-fact-list",1,"defmodule name");
            return;
           }
         theModule = ((void *)0);
        }
     }
   else
     { theModule = ((struct defmodule *) EnvGetCurrentModule(theEnv)); }
   EnvGetFactList(theEnv,returnValue,theModule);
  }

canonical_original_code:
void GetFactListFunction(void *theEnv, struct dataObject *returnValue)
  {
   struct defmodule *theModule;
   struct dataObject result;
   int numArgs;
   if ((numArgs = EnvArgCountCheck(theEnv,"get-fact-list",2,1)) == -1)
     {
      EnvSetMultifieldErrorValue(theEnv,returnValue);
      return;
     }
   if (numArgs == 1)
     {
      EnvRtnUnknown(theEnv,1,&result);
      if (((result).type) != 2)
        {
         EnvSetMultifieldErrorValue(theEnv,returnValue);
         ExpectedTypeError1(theEnv,"get-fact-list",1,"defmodule name");
         return;
        }
      if ((theModule = (struct defmodule *) EnvFindDefmodule(theEnv,(((struct symbolHashNode *) (result.value))->contents))) == ((void *)0))
        {
         if (strcmp("*",(((struct symbolHashNode *) (result.value))->contents)) != 0)
           {
            EnvSetMultifieldErrorValue(theEnv,returnValue);
            ExpectedTypeError1(theEnv,"get-fact-list",1,"defmodule name");
            return;
           }
         theModule = ((void *)0);
        }
     }
   else
     { theModule = ((struct defmodule *) EnvGetCurrentModule(theEnv)); }
   EnvGetFactList(theEnv,returnValue,theModule);
  }

variable_types:
theEnv
void *

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

variable_types: numArgs int

return_type: void

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 symbolHashNode { struct symbolHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int neededSymbol; unsigned int bucket; char *contents; }

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

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

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


EnvPPFact

decompiled_code:
__int64 __fastcall EnvPPFact(__int64 a1, __int64 a2, __int64 a3, unsigned int a4)
{
__int64 result; // rax

if ( a2 )
{
if ( *(char *)(a2 + 57) >= 0 )
{
PrintFact(a1, a3, a2, 1LL, a4);
result = EnvPrintRouter(a1, a3, "\n");
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2, __int64 a3, unsigned int a4)
{
__int64 result; // rax

if ( a2 )
{
if ( *(char *)(a2 + 57) >= 0 )
{
PrintFact(a1, a3, a2, 1LL, a4);
result = EnvPrintRouter(a1, a3, "\n");
}
}
return result;
}

original_code:
void EnvPPFact(
  void *theEnv,
  void *vTheFact,
  char *logicalName,
  int ignoreDefaults)
  {
   struct fact *theFact = (struct fact *) vTheFact;
   if (theFact == ((void *)0)) return;
   if (theFact->garbage) return;
   PrintFact(theEnv,logicalName,theFact,1,ignoreDefaults);
   EnvPrintRouter(theEnv,logicalName,"\n");
  }

canonical_original_code:
void EnvPPFact(void *theEnv, void *vTheFact, char *logicalName, int ignoreDefaults)
  {
   struct fact *theFact = (struct fact *) vTheFact;
   if (theFact == ((void *)0)) return;
   if (theFact->garbage) return;
   PrintFact(theEnv,logicalName,theFact,1,ignoreDefaults);
   EnvPrintRouter(theEnv,logicalName,"\n");
  }

variable_types:
vTheFact
void *

variable_types:
logicalName
char *

variable_types: ignoreDefaults int

variable_types: struct fact { struct patternEntity { struct patternEntityRecord { struct entityRecord { char *name; unsigned int type; unsigned int copyToEvaluate; unsigned int bitMap; unsigned int addsToRuleComplexity; void (*shortPrintFunction)(void *, char *, void *); void (*longPrintFunction)(void *, char *, void *); int (*deleteFunction)(void *, void *); int (*evaluateFunction)(void *, void *, struct dataObject { void *supplementalInfo; unsigned short type; void *value; long begin; long end; struct dataObject *next; } *); void *(*getNextFunction)(void *, void *); void (*decrementBusyCount)(void *, void *); void (*incrementBusyCount)(void *, void *); void (*propagateDepth)(void *, void *); void (*markNeeded)(void *, void *); void (*install)(void *, void *); void (*deinstall)(void *, void *); struct userData { unsigned char dataID; struct userData *next; } *usrData; } base; void (*decrementBasisCount)(void *, void *); void (*incrementBasisCount)(void *, void *); void (*matchFunction)(void *, void *); int (*synchronized)(void *, void *); } *theInfo; void *dependents; unsigned int busyCount; long timeTag; } factHeader; struct deftemplate { struct constructHeader { struct symbolHashNode { struct symbolHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int neededSymbol; unsigned int bucket; char *contents; } *name; char *ppForm; struct defmoduleItemHeader { struct defmodule { struct symbolHashNode *name; char *ppForm; struct defmoduleItemHeader **itemsArray; struct portItem { struct symbolHashNode *moduleName; struct symbolHashNode *constructType; struct symbolHashNode *constructName; struct portItem *next; } *importList; struct portItem *exportList; unsigned int visitedFlag; long bsaveID; struct userData *usrData; struct defmodule *next; } *theModule; struct constructHeader *firstItem; struct constructHeader *lastItem; } *whichModule; long bsaveID; struct constructHeader *next; struct userData *usrData; } header; struct templateSlot { struct symbolHashNode *slotName; unsigned int multislot; unsigned int noDefault; unsigned int defaultPresent; unsigned int defaultDynamic; struct constraintRecord { unsigned int anyAllowed; unsigned int symbolsAllowed; unsigned int stringsAllowed; unsigned int floatsAllowed; unsigned int integersAllowed; unsigned int instanceNamesAllowed; unsigned int instanceAddressesAllowed; unsigned int externalAddressesAllowed; unsigned int factAddressesAllowed; unsigned int voidAllowed; unsigned int anyRestriction; unsigned int symbolRestriction; unsigned int stringRestriction; unsigned int floatRestriction; unsigned int integerRestriction; unsigned int classRestriction; unsigned int instanceNameRestriction; unsigned int multifieldsAllowed; unsigned int singlefieldsAllowed; unsigned short bsaveIndex; struct expr { unsigned short type; void *value; struct expr *argList; struct expr *nextArg; } *classList; struct expr *restrictionList; struct expr *minValue; struct expr *maxValue; struct expr *minFields; struct expr *maxFields; struct constraintRecord *multifield; struct constraintRecord *next; int bucket; int count; } *constraints; struct expr *defaultList; struct templateSlot *next; } *slotList; unsigned int implied; unsigned int watch; unsigned int inScope; unsigned short numberOfSlots; long busyCount; struct factPatternNode { struct patternNodeHeader { struct partialMatch { unsigned int betaMemory; unsigned int busy; unsigned int activationf; unsigned int dependentsf; unsigned int notOriginf; unsigned int counterf; unsigned int bcount; struct partialMatch *next; struct genericMatch { union { void *theValue; struct alphaMatch { struct patternEntity *matchingItem; struct multifieldMarker { int whichField; union { void *whichSlot; short whichSlotNumber; } where; long startPosition; long endPosition; struct multifieldMarker *next; } *markers; struct alphaMatch *next; } *theMatch; } gm; } binds[1]; } *alphaMemory; struct partialMatch *endOfQueue; struct joinNode { unsigned int firstJoin; unsigned int logicalJoin; unsigned int joinFromTheRight; unsigned int patternIsNegated; unsigned int initialize; unsigned int marked; unsigned int rhsType; unsigned int depth; long bsaveID; struct partialMatch *beta; struct expr *networkTest; void *rightSideEntryStructure; struct joinNode *nextLevel; struct joinNode *lastLevel; struct joinNode *rightDriveNode; struct joinNode *rightMatchNode; struct defrule { struct constructHeader header; int salience; int localVarCnt; unsigned int complexity; unsigned int afterBreakpoint; unsigned int watchActivation; unsigned int watchFiring; unsigned int autoFocus; unsigned int executing; struct expr *dynamicSalience; struct expr *actions; struct joinNode *logicalJoin; struct joinNode *lastJoin; struct defrule *disjunct; } *ruleToActivate; } *entryJoin; unsigned int singlefieldNode; unsigned int multifieldNode; unsigned int stopNode; unsigned int initialize; unsigned int marked; unsigned int beginSlot; unsigned int endSlot; } header; long bsaveID; unsigned short whichField; unsigned short whichSlot; unsigned short leaveFields; struct expr *networkTest; struct factPatternNode *nextLevel; struct factPatternNode *lastLevel; struct factPatternNode *leftNode; struct factPatternNode *rightNode; } *patternNetwork; struct fact *factList; struct fact *lastFact; } *whichDeftemplate; void *list; long factIndex; unsigned int depth; unsigned int garbage; struct fact *previousFact; struct fact *nextFact; struct fact *previousTemplateFact; struct fact *nextTemplateFact; struct multifield { unsigned int busyCount; short depth; unsigned long multifieldLength; struct multifield *next; struct field { unsigned short type; void *value; } theFields[1]; } theProposition; } *

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

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

user_defined_types: struct 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; }

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

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

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

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

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

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

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


GetFactAddressOrIndexArgument

decompiled_code:
__int64 __fastcall GetFactAddressOrIndexArgument(__int64 a1, __int64 a2, unsigned int a3, int a4)
{
__int64 v6; // r14
__int64 v7; // r12
__int64 result; // rax
__int64 v9; // r12
char v10[32]; // [rsp+0h] [rbp-78h] BYREF
char v11[8]; // [rsp+20h] [rbp-58h] BYREF
__int16 v12; // [rsp+28h] [rbp-50h]
__int64 v13; // [rsp+30h] [rbp-48h]

EnvRtnUnknown(a1, a3, v11);
if ( v12 == 6 )
{
v9 = v13;
if ( *(char *)(v13 + 57) < 0 )
v9 = 0LL;
result = v9;
}
else
{
if ( v12 == 1 && (v6 = *(_QWORD *)(v13 + 24), v6 >= 0) )
{
v7 = FindIndexedFact(a1, *(_QWORD *)(v13 + 24));
if ( !v7 )
{
if ( a4 )
{
sprintf(v10, "f-%ld", v6);
CantFindItemErrorMessage(a1, "fact", v10);
}
}
}
else
{
ExpectedTypeError1(a1, a2, a3, "fact-address or fact-index");
v7 = 0LL;
}
result = v7;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 a2, unsigned int a3, int a4)
{
__int64 v6; // r14
__int64 v7; // r12
__int64 result; // rax
__int64 v9; // r12
char v10[32]; // [rsp+0h] [rbp-78h] BYREF
char v11[8]; // [rsp+20h] [rbp-58h] BYREF
__int16 v12; // [rsp+28h] [rbp-50h]
__int64 v13; // [rsp+30h] [rbp-48h]

EnvRtnUnknown(a1, a3, v11);
if ( v12 == 6 )
{
v9 = v13;
if ( *(char *)(v13 + 57) < 0 )
v9 = 0LL;
result = v9;
}
else
{
if ( v12 == 1 && (v6 = *(_QWORD *)(v13 + 24), v6 >= 0) )
{
v7 = FindIndexedFact(a1, *(_QWORD *)(v13 + 24));
if ( !v7 )
{
if ( a4 )
{
sprintf(v10, "f-%ld", v6);
CantFindItemErrorMessage(a1, "fact", v10);
}
}
}
else
{
ExpectedTypeError1(a1, a2, a3, "fact-address or fact-index");
v7 = 0LL;
}
result = v7;
}
return result;
}

original_code:
struct fact *GetFactAddressOrIndexArgument(
  void *theEnv,
  char *theFunction,
  int position,
  int noFactError)
  {
   DATA_OBJECT item;
   long factIndex;
   struct fact *theFact;
   char tempBuffer[20];
   EnvRtnUnknown(theEnv,position,&item);
   if (((item).type) == 6)
     {
      if (((struct fact *) ((item).value))->garbage) return(((void *)0));
      else return (((struct fact *) ((item).value)));
     }
   else if (((item).type) == 1)
     {
      factIndex = (((struct integerHashNode *) (item.value))->contents);
      if (factIndex < 0)
        {
         ExpectedTypeError1(theEnv,theFunction,position,"fact-address or fact-index");
         return(((void *)0));
        }
      theFact = FindIndexedFact(theEnv,factIndex);
      if ((theFact == ((void *)0)) && noFactError)
        {
         sprintf(tempBuffer,"f-%ld",factIndex);
         CantFindItemErrorMessage(theEnv,"fact",tempBuffer);
         return(((void *)0));
        }
      return(theFact);
     }
   ExpectedTypeError1(theEnv,theFunction,position,"fact-address or fact-index");
   return(((void *)0));
  }

canonical_original_code:
struct fact *GetFactAddressOrIndexArgument(void *theEnv, char *theFunction, int position, int noFactError)
  {
   struct dataObject item;
   long factIndex;
   struct fact *theFact;
   char tempBuffer[20];
   EnvRtnUnknown(theEnv,position,&item);
   if (((item).type) == 6)
     {
      if (((struct fact *) ((item).value))->garbage) return(((void *)0));
      else return (((struct fact *) ((item).value)));
     }
   else if (((item).type) == 1)
     {
      factIndex = (((struct integerHashNode *) (item.value))->contents);
      if (factIndex < 0)
        {
         ExpectedTypeError1(theEnv,theFunction,position,"fact-address or fact-index");
         return(((void *)0));
        }
      theFact = FindIndexedFact(theEnv,factIndex);
      if ((theFact == ((void *)0)) && noFactError)
        {
         sprintf(tempBuffer,"f-%ld",factIndex);
         CantFindItemErrorMessage(theEnv,"fact",tempBuffer);
         return(((void *)0));
        }
      return(theFact);
     }
   ExpectedTypeError1(theEnv,theFunction,position,"fact-address or fact-index");
   return(((void *)0));
  }

variable_types:
theFunction
char *

variable_types: position int

variable_types: noFactError int

variable_types: factIndex long

variable_types:
tempBuffer
char [20]

return_type: struct fact { struct patternEntity { struct patternEntityRecord { struct entityRecord { char *name; unsigned int type; unsigned int copyToEvaluate; unsigned int bitMap; unsigned int addsToRuleComplexity; void (*shortPrintFunction)(void *, char *, void *); void (*longPrintFunction)(void *, char *, void *); int (*deleteFunction)(void *, void *); int (*evaluateFunction)(void *, void *, struct dataObject { void *supplementalInfo; unsigned short type; void *value; long begin; long end; struct dataObject *next; } *); void *(*getNextFunction)(void *, void *); void (*decrementBusyCount)(void *, void *); void (*incrementBusyCount)(void *, void *); void (*propagateDepth)(void *, void *); void (*markNeeded)(void *, void *); void (*install)(void *, void *); void (*deinstall)(void *, void *); struct userData { unsigned char dataID; struct userData *next; } *usrData; } base; void (*decrementBasisCount)(void *, void *); void (*incrementBasisCount)(void *, void *); void (*matchFunction)(void *, void *); int (*synchronized)(void *, void *); } *theInfo; void *dependents; unsigned int busyCount; long timeTag; } factHeader; struct deftemplate { struct constructHeader { struct symbolHashNode { struct symbolHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int neededSymbol; unsigned int bucket; char *contents; } *name; char *ppForm; struct defmoduleItemHeader { struct defmodule { struct symbolHashNode *name; char *ppForm; struct defmoduleItemHeader **itemsArray; struct portItem { struct symbolHashNode *moduleName; struct symbolHashNode *constructType; struct symbolHashNode *constructName; struct portItem *next; } *importList; struct portItem *exportList; unsigned int visitedFlag; long bsaveID; struct userData *usrData; struct defmodule *next; } *theModule; struct constructHeader *firstItem; struct constructHeader *lastItem; } *whichModule; long bsaveID; struct constructHeader *next; struct userData *usrData; } header; struct templateSlot { struct symbolHashNode *slotName; unsigned int multislot; unsigned int noDefault; unsigned int defaultPresent; unsigned int defaultDynamic; struct constraintRecord { unsigned int anyAllowed; unsigned int symbolsAllowed; unsigned int stringsAllowed; unsigned int floatsAllowed; unsigned int integersAllowed; unsigned int instanceNamesAllowed; unsigned int instanceAddressesAllowed; unsigned int externalAddressesAllowed; unsigned int factAddressesAllowed; unsigned int voidAllowed; unsigned int anyRestriction; unsigned int symbolRestriction; unsigned int stringRestriction; unsigned int floatRestriction; unsigned int integerRestriction; unsigned int classRestriction; unsigned int instanceNameRestriction; unsigned int multifieldsAllowed; unsigned int singlefieldsAllowed; unsigned short bsaveIndex; struct expr { unsigned short type; void *value; struct expr *argList; struct expr *nextArg; } *classList; struct expr *restrictionList; struct expr *minValue; struct expr *maxValue; struct expr *minFields; struct expr *maxFields; struct constraintRecord *multifield; struct constraintRecord *next; int bucket; int count; } *constraints; struct expr *defaultList; struct templateSlot *next; } *slotList; unsigned int implied; unsigned int watch; unsigned int inScope; unsigned short numberOfSlots; long busyCount; struct factPatternNode { struct patternNodeHeader { struct partialMatch { unsigned int betaMemory; unsigned int busy; unsigned int activationf; unsigned int dependentsf; unsigned int notOriginf; unsigned int counterf; unsigned int bcount; struct partialMatch *next; struct genericMatch { union { void *theValue; struct alphaMatch { struct patternEntity *matchingItem; struct multifieldMarker { int whichField; union { void *whichSlot; short whichSlotNumber; } where; long startPosition; long endPosition; struct multifieldMarker *next; } *markers; struct alphaMatch *next; } *theMatch; } gm; } binds[1]; } *alphaMemory; struct partialMatch *endOfQueue; struct joinNode { unsigned int firstJoin; unsigned int logicalJoin; unsigned int joinFromTheRight; unsigned int patternIsNegated; unsigned int initialize; unsigned int marked; unsigned int rhsType; unsigned int depth; long bsaveID; struct partialMatch *beta; struct expr *networkTest; void *rightSideEntryStructure; struct joinNode *nextLevel; struct joinNode *lastLevel; struct joinNode *rightDriveNode; struct joinNode *rightMatchNode; struct defrule { struct constructHeader header; int salience; int localVarCnt; unsigned int complexity; unsigned int afterBreakpoint; unsigned int watchActivation; unsigned int watchFiring; unsigned int autoFocus; unsigned int executing; struct expr *dynamicSalience; struct expr *actions; struct joinNode *logicalJoin; struct joinNode *lastJoin; struct defrule *disjunct; } *ruleToActivate; } *entryJoin; unsigned int singlefieldNode; unsigned int multifieldNode; unsigned int stopNode; unsigned int initialize; unsigned int marked; unsigned int beginSlot; unsigned int endSlot; } header; long bsaveID; unsigned short whichField; unsigned short whichSlot; unsigned short leaveFields; struct expr *networkTest; struct factPatternNode *nextLevel; struct factPatternNode *lastLevel; struct factPatternNode *leftNode; struct factPatternNode *rightNode; } *patternNetwork; struct fact *factList; struct fact *lastFact; } *whichDeftemplate; void *list; long factIndex; unsigned int depth; unsigned int garbage; struct fact *previousFact; struct fact *nextFact; struct fact *previousTemplateFact; struct fact *nextTemplateFact; struct multifield { unsigned int busyCount; short depth; unsigned long multifieldLength; struct multifield *next; struct field { unsigned short type; void *value; } theFields[1]; } theProposition; } *

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

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

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

user_defined_types: struct 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; }


FactRelationFunction

decompiled_code:
__int64 __fastcall FactRelationFunction(__int64 a1)
{
__int64 v2; // rdi
__int64 result; // rax

if ( (unsigned int)EnvArgCountCheck(a1, "fact-relation", 0LL, 1LL) == -1
|| (v2 = GetFactAddressOrIndexArgument(a1, (__int64)"fact-relation", 1u, 0)) == 0 )
{
result = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 392LL) + 8LL);
}
else
{
result = FactRelation(v2);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
__int64 v2; // rdi
__int64 result; // rax

if ( (unsigned int)EnvArgCountCheck(a1, "fact-relation", 0LL, 1LL) == -1
|| (v2 = func9(a1, (__int64)"fact-relation", 1u, 0)) == 0 )
{
result = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 392LL) + 8LL);
}
else
{
result = func1(v2);
}
return result;
}

original_code:
void *FactRelationFunction(
  void *theEnv)
  {
   struct fact *theFact;
   if (EnvArgCountCheck(theEnv,"fact-relation",0,1) == -1) return(((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->FalseSymbolHN);
   theFact = GetFactAddressOrIndexArgument(theEnv,"fact-relation",1,0);
   if (theFact == ((void *)0)) return(((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->FalseSymbolHN);
   return(FactRelation(theFact));
  }

canonical_original_code:
void *FactRelationFunction(void *theEnv)
  {
   struct fact *theFact;
   if (EnvArgCountCheck(theEnv,"fact-relation",0,1) == -1) return(((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->FalseSymbolHN);
   theFact = GetFactAddressOrIndexArgument(theEnv,"fact-relation",1,0);
   if (theFact == ((void *)0)) return(((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->FalseSymbolHN);
   return(FactRelation(theFact));
  }

return_type: void *

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

user_defined_types: struct field { unsigned short type; void *value; }

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

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

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

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

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

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

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


FactExistpFunction

decompiled_code:
__int64 __fastcall FactExistpFunction(__int64 a1)
{
__int64 v1; // rax

if ( (unsigned int)EnvArgCountCheck(a1, "fact-existp", 0LL, 1LL) == -1 )
return 0xFFFFFFFFLL;
v1 = GetFactAddressOrIndexArgument(a1, (__int64)"fact-existp", 1u, 0);
return EnvFactExistp(a1, v1);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
__int64 v1; // rax

if ( (unsigned int)EnvArgCountCheck(a1, "fact-existp", 0LL, 1LL) == -1 )
return 0xFFFFFFFFLL;
v1 = func9(a1, (__int64)"fact-existp", 1u, 0);
return func3(a1, v1);
}

original_code:
int FactExistpFunction(
  void *theEnv)
  {
   struct fact *theFact;
   if (EnvArgCountCheck(theEnv,"fact-existp",0,1) == -1) return(-1L);
   theFact = GetFactAddressOrIndexArgument(theEnv,"fact-existp",1,0);
   return(EnvFactExistp(theEnv,theFact));
  }

canonical_original_code:
int FactExistpFunction(void *theEnv)
  {
   struct fact *theFact;
   if (EnvArgCountCheck(theEnv,"fact-existp",0,1) == -1) return(-1L);
   theFact = GetFactAddressOrIndexArgument(theEnv,"fact-existp",1,0);
   return(EnvFactExistp(theEnv,theFact));
  }

return_type: int

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

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

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

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

user_defined_types: struct 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; }

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

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

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

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

user_defined_types: struct 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 partialMatch { unsigned int betaMemory; unsigned int busy; unsigned int activationf; unsigned int dependentsf; unsigned int notOriginf; unsigned int counterf; unsigned int bcount; struct partialMatch *next; struct genericMatch binds[1]; }

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

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

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


FactSlotValueFunction

decompiled_code:
__int64 __fastcall FactSlotValueFunction(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // r13
_QWORD v4[9]; // [rsp+0h] [rbp-48h] BYREF

*(_WORD *)(a2 + 8) = 2;
*(_QWORD *)(a2 + 16) = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 392LL) + 8LL);
result = EnvArgCountCheck(a1, "fact-slot-value", 0LL, 2LL);
if ( (_DWORD)result != -1 )
{
result = GetFactAddressOrIndexArgument(a1, (__int64)"fact-slot-value", 1u, 1);
v3 = result;
if ( result )
{
result = EnvArgTypeCheck(a1, "fact-slot-value", 2LL, 2LL, v4);
if ( (_DWORD)result )
result = FactSlotValue(a1, v3, *(const char **)(v4[2] + 24LL), a2);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // r13
_QWORD v4[9]; // [rsp+0h] [rbp-48h] BYREF

*(_WORD *)(a2 + 8) = 2;
*(_QWORD *)(a2 + 16) = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 392LL) + 8LL);
result = EnvArgCountCheck(a1, "fact-slot-value", 0LL, 2LL);
if ( (_DWORD)result != -1 )
{
result = func9(a1, (__int64)"fact-slot-value", 1u, 1);
v3 = result;
if ( result )
{
result = EnvArgTypeCheck(a1, "fact-slot-value", 2LL, 2LL, v4);
if ( (_DWORD)result )
result = func4(a1, v3, *(const char **)(v4[2] + 24LL), a2);
}
}
return result;
}

original_code:
void FactSlotValueFunction(
  void *theEnv,
  DATA_OBJECT *returnValue)
  {
   struct fact *theFact;
   DATA_OBJECT theValue;
   returnValue->type = 2;
   returnValue->value = ((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->FalseSymbolHN;
   if (EnvArgCountCheck(theEnv,"fact-slot-value",0,2) == -1) return;
   theFact = GetFactAddressOrIndexArgument(theEnv,"fact-slot-value",1,1);
   if (theFact == ((void *)0)) return;
   if (EnvArgTypeCheck(theEnv,"fact-slot-value",2,2,&theValue) == 0)
     { return; }
   FactSlotValue(theEnv,theFact,(((struct symbolHashNode *) (theValue.value))->contents),returnValue);
  }

canonical_original_code:
void FactSlotValueFunction(void *theEnv, struct dataObject *returnValue)
  {
   struct fact *theFact;
   struct dataObject theValue;
   returnValue->type = 2;
   returnValue->value = ((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->FalseSymbolHN;
   if (EnvArgCountCheck(theEnv,"fact-slot-value",0,2) == -1) return;
   theFact = GetFactAddressOrIndexArgument(theEnv,"fact-slot-value",1,1);
   if (theFact == ((void *)0)) return;
   if (EnvArgTypeCheck(theEnv,"fact-slot-value",2,2,&theValue) == 0)
     { return; }
   FactSlotValue(theEnv,theFact,(((struct symbolHashNode *) (theValue.value))->contents),returnValue);
  }

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

user_defined_types: struct field { unsigned short type; void *value; }

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

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

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

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

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

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


FactSlotNamesFunction

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

*(_WORD *)(a2 + 8) = 2;
*(_QWORD *)(a2 + 16) = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 392LL) + 8LL);
result = EnvArgCountCheck(a1, "fact-slot-names", 0LL, 1LL);
if ( (_DWORD)result != -1 )
{
result = GetFactAddressOrIndexArgument(a1, (__int64)"fact-slot-names", 1u, 1);
if ( result )
result = EnvFactSlotNames(a1, result, a2);
}
return result;
}

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

*(_WORD *)(a2 + 8) = 2;
*(_QWORD *)(a2 + 16) = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 392LL) + 8LL);
result = EnvArgCountCheck(a1, "fact-slot-names", 0LL, 1LL);
if ( (_DWORD)result != -1 )
{
result = func9(a1, (__int64)"fact-slot-names", 1u, 1);
if ( result )
result = func5(a1, result, a2);
}
return result;
}

original_code:
void FactSlotNamesFunction(
  void *theEnv,
  DATA_OBJECT *returnValue)
  {
   struct fact *theFact;
   returnValue->type = 2;
   returnValue->value = ((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->FalseSymbolHN;
   if (EnvArgCountCheck(theEnv,"fact-slot-names",0,1) == -1) return;
   theFact = GetFactAddressOrIndexArgument(theEnv,"fact-slot-names",1,1);
   if (theFact == ((void *)0)) return;
   EnvFactSlotNames(theEnv,theFact,returnValue);
  }

canonical_original_code:
void FactSlotNamesFunction(void *theEnv, struct dataObject *returnValue)
  {
   struct fact *theFact;
   returnValue->type = 2;
   returnValue->value = ((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->FalseSymbolHN;
   if (EnvArgCountCheck(theEnv,"fact-slot-names",0,1) == -1) return;
   theFact = GetFactAddressOrIndexArgument(theEnv,"fact-slot-names",1,1);
   if (theFact == ((void *)0)) return;
   EnvFactSlotNames(theEnv,theFact,returnValue);
  }

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

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

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

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

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

user_defined_types: struct 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; }

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

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

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

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

user_defined_types: struct 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 partialMatch { unsigned int betaMemory; unsigned int busy; unsigned int activationf; unsigned int dependentsf; unsigned int notOriginf; unsigned int counterf; unsigned int bcount; struct partialMatch *next; struct genericMatch binds[1]; }

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

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

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

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


PPFactFunction

decompiled_code:
char __fastcall PPFactFunction(__int64 a1)
{
__int64 v1; // rax
int v2; // ebx
__int64 v3; // r12
unsigned int v4; // er14
const char *v5; // r13
bool v6; // zf
_WORD v8[8]; // [rsp+0h] [rbp-58h] BYREF
__int64 v9; // [rsp+10h] [rbp-48h]

LODWORD(v1) = EnvArgRangeCheck(a1, "ppfact", 1LL, 3LL);
if ( (_DWORD)v1 != -1 )
{
v2 = v1;
v1 = GetFactAddressOrIndexArgument(a1, (__int64)"ppfact", 1u, 1);
v3 = v1;
if ( v1 )
{
v4 = 0;
v5 = "stdout";
if ( v2 == 1 )
goto LABEL_20;
v5 = (const char *)GetLogicalName(a1, 2LL, "stdout");
if ( !v5 )
{
IllegalLogicalNameMessage(a1, "ppfact");
SetHaltExecution(a1, 1LL);
LOBYTE(v1) = SetEvaluationError(a1, 1LL);
return v1;
}
if ( v2 != 3
|| (v4 = 1, EnvRtnUnknown(a1, 3LL, v8), v9 == *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 392LL) + 8LL))
&& v8[4] == 2 )
{
v4 = 0;
}
v6 = strcmp(v5, "nil") == 0;
LOBYTE(v1) = !v6;
if ( !v6 )
{
LABEL_20:
if ( (unsigned int)QueryRouters(a1, v5) )
LOBYTE(v1) = EnvPPFact(a1, v3, (__int64)v5, v4);
else
LOBYTE(v1) = UnrecognizedRouterMessage(a1, v5);
}
}
}
return v1;
}

canonical_decompiled_code:
char __fastcall func14(__int64 a1)
{
__int64 v1; // rax
int v2; // ebx
__int64 v3; // r12
unsigned int v4; // er14
const char *v5; // r13
bool v6; // zf
_WORD v8[8]; // [rsp+0h] [rbp-58h] BYREF
__int64 v9; // [rsp+10h] [rbp-48h]

LODWORD(v1) = EnvArgRangeCheck(a1, "ppfact", 1LL, 3LL);
if ( (_DWORD)v1 != -1 )
{
v2 = v1;
v1 = func9(a1, (__int64)"ppfact", 1u, 1);
v3 = v1;
if ( v1 )
{
v4 = 0;
v5 = "stdout";
if ( v2 == 1 )
goto LABEL_20;
v5 = (const char *)GetLogicalName(a1, 2LL, "stdout");
if ( !v5 )
{
IllegalLogicalNameMessage(a1, "ppfact");
SetHaltExecution(a1, 1LL);
LOBYTE(v1) = SetEvaluationError(a1, 1LL);
return v1;
}
if ( v2 != 3
|| (v4 = 1, EnvRtnUnknown(a1, 3LL, v8), v9 == *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 392LL) + 8LL))
&& v8[4] == 2 )
{
v4 = 0;
}
v6 = strcmp(v5, "nil") == 0;
LOBYTE(v1) = !v6;
if ( !v6 )
{
LABEL_20:
if ( (unsigned int)QueryRouters(a1, v5) )
LOBYTE(v1) = func8(a1, v3, (__int64)v5, v4);
else
LOBYTE(v1) = UnrecognizedRouterMessage(a1, v5);
}
}
}
return v1;
}

original_code:
void PPFactFunction(
  void *theEnv)
  {
   struct fact *theFact;
   int numberOfArguments;
   char *logicalName = ((void *)0);
   int ignoreDefaults = 0;
   DATA_OBJECT theArg;
   if ((numberOfArguments = EnvArgRangeCheck(theEnv,"ppfact",1,3)) == -1) return;
   theFact = GetFactAddressOrIndexArgument(theEnv,"ppfact",1,1);
   if (theFact == ((void *)0)) return;
   if (numberOfArguments == 1)
     { logicalName = "stdout"; }
   else
     {
      logicalName = GetLogicalName(theEnv,2,"stdout");
      if (logicalName == ((void *)0))
        {
         IllegalLogicalNameMessage(theEnv,"ppfact");
         SetHaltExecution(theEnv,1);
         SetEvaluationError(theEnv,1);
         return;
        }
     }
   if (numberOfArguments == 3)
     {
      EnvRtnUnknown(theEnv,3,&theArg);
      if ((theArg.value == ((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->FalseSymbolHN) && (theArg.type == 2))
        { ignoreDefaults = 0; }
      else
        { ignoreDefaults = 1; }
     }
   if (strcmp(logicalName,"nil") == 0)
     { return; }
   else if (QueryRouters(theEnv,logicalName) == 0)
     {
      UnrecognizedRouterMessage(theEnv,logicalName);
      return;
     }
   EnvPPFact(theEnv,theFact,logicalName,ignoreDefaults);
  }

canonical_original_code:
void PPFactFunction(void *theEnv)
  {
   struct fact *theFact;
   int numberOfArguments;
   char *logicalName = ((void *)0);
   int ignoreDefaults = 0;
   struct dataObject theArg;
   if ((numberOfArguments = EnvArgRangeCheck(theEnv,"ppfact",1,3)) == -1) return;
   theFact = GetFactAddressOrIndexArgument(theEnv,"ppfact",1,1);
   if (theFact == ((void *)0)) return;
   if (numberOfArguments == 1)
     { logicalName = "stdout"; }
   else
     {
      logicalName = GetLogicalName(theEnv,2,"stdout");
      if (logicalName == ((void *)0))
        {
         IllegalLogicalNameMessage(theEnv,"ppfact");
         SetHaltExecution(theEnv,1);
         SetEvaluationError(theEnv,1);
         return;
        }
     }
   if (numberOfArguments == 3)
     {
      EnvRtnUnknown(theEnv,3,&theArg);
      if ((theArg.value == ((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->FalseSymbolHN) && (theArg.type == 2))
        { ignoreDefaults = 0; }
      else
        { ignoreDefaults = 1; }
     }
   if (strcmp(logicalName,"nil") == 0)
     { return; }
   else if (QueryRouters(theEnv,logicalName) == 0)
     {
      UnrecognizedRouterMessage(theEnv,logicalName);
      return;
     }
   EnvPPFact(theEnv,theFact,logicalName,ignoreDefaults);
  }

variable_types: numberOfArguments int

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

user_defined_types: struct field { unsigned short type; void *value; }

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

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

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

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

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

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


DeallocateDefglobalBloadData

original_code:
static void DeallocateDefglobalBloadData(
  void *theEnv)
  {
   unsigned long space;
   long i;
   for (i = 0; i < ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobals; i++)
     {
      if (((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->DefglobalArray[i].current.type == 4)
        { ReturnMultifield(theEnv,(struct multifield *) ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->DefglobalArray[i].current.value); }
     }
   space = ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobals * sizeof(struct defglobal);
   if (space != 0)
     { genlongfree(theEnv,(void *) ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->DefglobalArray,space); }
   space = ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobalModules * sizeof(struct defglobalModule);
   if (space != 0)
     { genlongfree(theEnv,(void *) ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->ModuleArray,space); }
  }

canonical_original_code:
static void DeallocateDefglobalBloadData(void *theEnv)
  {
   unsigned long space;
   long i;
   for (i = 0; i < ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobals; i++)
     {
      if (((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->DefglobalArray[i].current.type == 4)
        { ReturnMultifield(theEnv,(struct multifield *) ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->DefglobalArray[i].current.value); }
     }
   space = ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobals * sizeof(struct defglobal);
   if (space != 0)
     { genlongfree(theEnv,(void *) ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->DefglobalArray,space); }
   space = ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobalModules * sizeof(struct defglobalModule);
   if (space != 0)
     { genlongfree(theEnv,(void *) ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->ModuleArray,space); }
  }

variable_types:
space
unsigned long

variable_types: i long

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

user_defined_types: struct defglobalModule { struct defmoduleItemHeader header; }

user_defined_types: struct defglobalBinaryData { struct defglobal *DefglobalArray; long NumberOfDefglobals; struct defglobalModule *ModuleArray; long NumberOfDefglobalModules; }

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

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

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


UpdateDefglobal

original_code:
static void UpdateDefglobal(
  void *theEnv,
  void *buf,
  long obji)
  {
   struct bsaveDefglobal *bdp;
   bdp = (struct bsaveDefglobal *) buf;
   UpdateConstructHeader(theEnv,&bdp->header,&((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->DefglobalArray[obji].header,
                         (int) sizeof(struct defglobalModule),(void *) ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->ModuleArray,
                         (int) sizeof(struct defglobal),(void *) ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->DefglobalArray);
   ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->DefglobalArray[obji].watch = WatchGlobals;
   ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->DefglobalArray[obji].initial = ((struct expr *) (((bdp->initial) == -1L) ? ((void *)0) : &((struct expressionData *) (((struct environmentData *) theEnv)->theData[45]))->ExpressionArray[bdp->initial]));
   ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->DefglobalArray[obji].current.type = 175;
  }

canonical_original_code:
static void UpdateDefglobal(void *theEnv, void *buf, long obji)
  {
   struct bsaveDefglobal *bdp;
   bdp = (struct bsaveDefglobal *) buf;
   UpdateConstructHeader(theEnv,&bdp->header,&((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->DefglobalArray[obji].header,
                         (int) sizeof(struct defglobalModule),(void *) ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->ModuleArray,
                         (int) sizeof(struct defglobal),(void *) ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->DefglobalArray);
   ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->DefglobalArray[obji].watch = WatchGlobals;
   ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->DefglobalArray[obji].initial = ((struct expr *) (((bdp->initial) == -1L) ? ((void *)0) : &((struct expressionData *) (((struct environmentData *) theEnv)->theData[45]))->ExpressionArray[bdp->initial]));
   ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->DefglobalArray[obji].current.type = 175;
  }

variable_types:
buf
void *

variable_types: obji long

variable_types: struct bsaveDefglobal { struct bsaveConstructHeader { long name; long whichModule; long next; } header; long initial; } *

user_defined_types: struct bsaveDefglobal { struct bsaveConstructHeader header; long initial; }

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

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

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

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

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


UpdateDefglobalModule

decompiled_code:
__int64 __fastcall UpdateDefglobalModule(__int64 a1, __int64 a2, __int64 a3)
{
return UpdateDefmoduleItemHeader(
a1,
a2,
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 480LL) + 16LL) + 24 * a3,
120LL,
**(_QWORD **)(*(_QWORD *)(a1 + 32) + 480LL));
}

original_code:
static void UpdateDefglobalModule(
  void *theEnv,
  void *buf,
  long obji)
  {
   struct bsaveDefglobalModule *bdmPtr;
   bdmPtr = (struct bsaveDefglobalModule *) buf;
   UpdateDefmoduleItemHeader(theEnv,&bdmPtr->header,&((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->ModuleArray[obji].header,
                             (int) sizeof(struct defglobal),
                             (void *) ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->DefglobalArray);
  }

canonical_original_code:
static void UpdateDefglobalModule(void *theEnv, void *buf, long obji)
  {
   struct bsaveDefglobalModule *bdmPtr;
   bdmPtr = (struct bsaveDefglobalModule *) buf;
   UpdateDefmoduleItemHeader(theEnv,&bdmPtr->header,&((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->ModuleArray[obji].header,
                             (int) sizeof(struct defglobal),
                             (void *) ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->DefglobalArray);
  }

variable_types:
theEnv
void *

variable_types: struct bsaveDefglobalModule { struct bsaveDefmoduleItemHeader { long theModule; long firstItem; long lastItem; } header; } *

user_defined_types: struct bsaveDefglobalModule { struct bsaveDefmoduleItemHeader header; }

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

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

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


DefglobalBinarySetup

decompiled_code:
__int64 __fastcall DefglobalBinarySetup(__int64 a1)
{
AllocateEnvironmentData(a1, 60LL, 32LL, DeallocateDefglobalBloadData);
AddAfterBloadFunction(a1, "defglobal", &ResetDefglobals, 50LL);
return AddBinaryItem(
a1,
"defglobal",
0LL,
BsaveFind,
0LL,
BsaveStorage,
BsaveBinaryItem,
BloadStorageDefglobals,
BloadBinaryItem,
ClearBload);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
AllocateEnvironmentData(a1, 60LL, 32LL, DeallocateDefglobalBloadData);
AddAfterBloadFunction(a1, "defglobal", &ResetDefglobals, 50LL);
return AddBinaryItem(
a1,
"defglobal",
0LL,
BsaveFind,
0LL,
BsaveStorage,
BsaveBinaryItem,
BloadStorageDefglobals,
BloadBinaryItem,
ClearBload);
}

original_code:
void DefglobalBinarySetup(
  void *theEnv)
  {
   AllocateEnvironmentData(theEnv,60,sizeof(struct defglobalBinaryData),DeallocateDefglobalBloadData);
   AddAfterBloadFunction(theEnv,"defglobal",ResetDefglobals,50);
   AddBinaryItem(theEnv,"defglobal",0,BsaveFind,((void *)0),
                             BsaveStorage,BsaveBinaryItem,
                             BloadStorageDefglobals,BloadBinaryItem,
                             ClearBload);
  }

canonical_original_code:
void DefglobalBinarySetup(void *theEnv)
  {
   AllocateEnvironmentData(theEnv,60,sizeof(struct defglobalBinaryData),DeallocateDefglobalBloadData);
   AddAfterBloadFunction(theEnv,"defglobal",ResetDefglobals,50);
   AddBinaryItem(theEnv,"defglobal",0,BsaveFind,((void *)0),
                             BsaveStorage,BsaveBinaryItem,
                             BloadStorageDefglobals,BloadBinaryItem,
                             ClearBload);
  }

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

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

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


BloadDefglobalModuleReference

decompiled_code:
__int64 __fastcall BloadDefglobalModuleReference(__int64 a1, int a2)
{
return *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 480LL) + 16LL) + 24LL * a2;
}

original_code:
void *BloadDefglobalModuleReference(
  void *theEnv,
  int theIndex)
  {
   return ((void *) &((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->ModuleArray[theIndex]);
  }

canonical_original_code:
void *BloadDefglobalModuleReference(void *theEnv, int theIndex)
  {
   return ((void *) &((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->ModuleArray[theIndex]);
  }

variable_types: theIndex int

user_defined_types: struct defglobalBinaryData { struct defglobal *DefglobalArray; long NumberOfDefglobals; struct defglobalModule *ModuleArray; long NumberOfDefglobalModules; }

user_defined_types: struct defglobalModule { struct defmoduleItemHeader header; }


BloadBinaryItem

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

GenReadBinary(a1, v2, 8LL);
BloadandRefresh(a1, *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 480LL) + 24LL), 24LL, UpdateDefglobalModule);
return BloadandRefresh(a1, *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 480LL) + 8LL), 32LL, UpdateDefglobal);
}

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

GenReadBinary(a1, v2, 8LL);
BloadandRefresh(a1, *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 480LL) + 24LL), 24LL, UpdateDefglobalModule);
return BloadandRefresh(a1, *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 480LL) + 8LL), 32LL, UpdateDefglobal);
}

original_code:
static void BloadBinaryItem(
  void *theEnv)
  {
   unsigned long int space;
   GenReadBinary(theEnv,&space,(unsigned long) sizeof(unsigned long int));
   BloadandRefresh(theEnv,((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobalModules,
                   (unsigned) sizeof(struct bsaveDefglobalModule),
                   UpdateDefglobalModule);
   BloadandRefresh(theEnv,((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobals,
                   (unsigned) sizeof(struct bsaveDefglobal),
                   UpdateDefglobal);
  }

canonical_original_code:
static void BloadBinaryItem(void *theEnv)
  {
   unsigned long space;
   GenReadBinary(theEnv,&space,(unsigned long) sizeof(unsigned long));
   BloadandRefresh(theEnv,((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobalModules,
                   (unsigned int) sizeof(struct bsaveDefglobalModule),
                   UpdateDefglobalModule);
   BloadandRefresh(theEnv,((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobals,
                   (unsigned int) sizeof(struct bsaveDefglobal),
                   UpdateDefglobal);
  }

user_defined_types: struct bsaveDefmoduleItemHeader { long theModule; long firstItem; long lastItem; }

user_defined_types: struct bsaveConstructHeader { long name; long whichModule; long next; }

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

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


BsaveFind

decompiled_code:
__int64 __fastcall BsaveFind(__int64 a1)
{
__int64 v1; // rax
__int64 result; // rax
__int64 v3; // r12
__int64 v4; // rsi
__int64 v5; // rax
__int64 v6; // rbp

SaveBloadCount(a1, *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 480LL) + 24LL));
SaveBloadCount(a1, *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 480LL) + 8LL));
v1 = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 480LL);
*(_QWORD *)(v1 + 8) = 0LL;
*(_QWORD *)(v1 + 24) = 0LL;
result = EnvGetNextDefmodule(a1, 0LL);
if ( result )
{
v3 = result;
do
{
EnvSetCurrentModule(a1, v3);
v4 = 0LL;
++*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 480LL) + 24LL);
while ( 1 )
{
v5 = EnvGetNextDefglobal(a1, v4);
v6 = v5;
if ( !v5 )
break;
++*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 480LL) + 8LL);
MarkConstructHeaderNeededItems(v5);
v4 = v6;
}
result = EnvGetNextDefmodule(a1, v3);
v3 = result;
}
while ( result );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
__int64 v1; // rax
__int64 result; // rax
__int64 v3; // r12
__int64 v4; // rsi
__int64 v5; // rax
__int64 v6; // rbp

SaveBloadCount(a1, *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 480LL) + 24LL));
SaveBloadCount(a1, *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 480LL) + 8LL));
v1 = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 480LL);
*(_QWORD *)(v1 + 8) = 0LL;
*(_QWORD *)(v1 + 24) = 0LL;
result = EnvGetNextDefmodule(a1, 0LL);
if ( result )
{
v3 = result;
do
{
EnvSetCurrentModule(a1, v3);
v4 = 0LL;
++*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 480LL) + 24LL);
while ( 1 )
{
v5 = EnvGetNextDefglobal(a1, v4);
v6 = v5;
if ( !v5 )
break;
++*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 480LL) + 8LL);
MarkConstructHeaderNeededItems(v5);
v4 = v6;
}
result = EnvGetNextDefmodule(a1, v3);
v3 = result;
}
while ( result );
}
return result;
}

original_code:
static void BsaveFind(
  void *theEnv)
  {
   struct defglobal *defglobalPtr;
   struct defmodule *theModule;
   SaveBloadCount(theEnv,((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobalModules);
   SaveBloadCount(theEnv,((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobals);
   ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobals = 0;
   ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobalModules = 0;
   for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,((void *)0));
        theModule != ((void *)0);
        theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule))
     {
      EnvSetCurrentModule(theEnv,(void *) theModule);
      ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobalModules++;
      for (defglobalPtr = (struct defglobal *) EnvGetNextDefglobal(theEnv,((void *)0));
           defglobalPtr != ((void *)0);
           defglobalPtr = (struct defglobal *) EnvGetNextDefglobal(theEnv,defglobalPtr))
        {
         MarkConstructHeaderNeededItems(&defglobalPtr->header,((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobals++);
        }
     }
  }

canonical_original_code:
static void BsaveFind(void *theEnv)
  {
   struct defglobal *defglobalPtr;
   struct defmodule *theModule;
   SaveBloadCount(theEnv,((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobalModules);
   SaveBloadCount(theEnv,((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobals);
   ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobals = 0;
   ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobalModules = 0;
   for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,((void *)0));
        theModule != ((void *)0);
        theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule))
     {
      EnvSetCurrentModule(theEnv,(void *) theModule);
      ((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobalModules++;
      for (defglobalPtr = (struct defglobal *) EnvGetNextDefglobal(theEnv,((void *)0));
           defglobalPtr != ((void *)0);
           defglobalPtr = (struct defglobal *) EnvGetNextDefglobal(theEnv,defglobalPtr))
        {
         MarkConstructHeaderNeededItems(&defglobalPtr->header,((struct defglobalBinaryData *) (((struct environmentData *) theEnv)->theData[60]))->NumberOfDefglobals++);
        }
     }
  }

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

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

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