EnvGetDefruleWatchActivations

decompiled_code:
__int64 __fastcall EnvGetDefruleWatchActivations(__int64 a1, __int64 a2)
{
if ( !a2 )
return 0LL;
while ( (*(_BYTE *)(a2 + 57) & 0x10) == 0 )
{
a2 = *(_QWORD *)(a2 + 96);
if ( !a2 )
return 0LL;
}
return 1LL;
}

original_code:
unsigned EnvGetDefruleWatchActivations(
  void *theEnv,
  void *rulePtr)
  {
   struct defrule *thePtr;
   for (thePtr = (struct defrule *) rulePtr;
        thePtr != ((void *)0);
        thePtr = thePtr->disjunct)
     { if (thePtr->watchActivation) return(1); }
   return(0);
  }

canonical_original_code:
unsigned int EnvGetDefruleWatchActivations(void *theEnv, void *rulePtr)
  {
   struct defrule *thePtr;
   for (thePtr = (struct defrule *) rulePtr;
        thePtr != ((void *)0);
        thePtr = thePtr->disjunct)
     { if (thePtr->watchActivation) return(1); }
   return(0);
  }

variable_types:
rulePtr
void *

variable_types: struct defrule { struct constructHeader { struct symbolHashNode { struct symbolHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int neededSymbol; unsigned int bucket; char *contents; } *name; char *ppForm; struct defmoduleItemHeader { struct defmodule { struct symbolHashNode *name; char *ppForm; struct defmoduleItemHeader **itemsArray; struct portItem { struct symbolHashNode *moduleName; struct symbolHashNode *constructType; struct symbolHashNode *constructName; struct portItem *next; } *importList; struct portItem *exportList; unsigned int visitedFlag; long bsaveID; struct userData { unsigned char dataID; struct userData *next; } *usrData; struct defmodule *next; } *theModule; struct constructHeader *firstItem; struct constructHeader *lastItem; } *whichModule; long bsaveID; struct constructHeader *next; struct userData *usrData; } header; int salience; int localVarCnt; unsigned int complexity; unsigned int afterBreakpoint; unsigned int watchActivation; unsigned int watchFiring; unsigned int autoFocus; unsigned int executing; struct expr { unsigned short type; void *value; struct expr *argList; struct expr *nextArg; } *dynamicSalience; struct expr *actions; struct joinNode { unsigned int firstJoin; unsigned int logicalJoin; unsigned int joinFromTheRight; unsigned int patternIsNegated; unsigned int initialize; unsigned int marked; unsigned int rhsType; unsigned int depth; long bsaveID; struct partialMatch { unsigned int betaMemory; unsigned int busy; unsigned int activationf; unsigned int dependentsf; unsigned int notOriginf; unsigned int counterf; unsigned int bcount; struct partialMatch *next; struct genericMatch { union { void *theValue; struct alphaMatch { struct patternEntity { struct patternEntityRecord { struct entityRecord { char *name; unsigned int type; unsigned int copyToEvaluate; unsigned int bitMap; unsigned int addsToRuleComplexity; void (*shortPrintFunction)(void *, char *, void *); void (*longPrintFunction)(void *, char *, void *); int (*deleteFunction)(void *, void *); int (*evaluateFunction)(void *, void *, struct dataObject { void *supplementalInfo; unsigned short type; void *value; long begin; long end; struct dataObject *next; } *); void *(*getNextFunction)(void *, void *); void (*decrementBusyCount)(void *, void *); void (*incrementBusyCount)(void *, void *); void (*propagateDepth)(void *, void *); void (*markNeeded)(void *, void *); void (*install)(void *, void *); void (*deinstall)(void *, void *); struct userData *usrData; } base; void (*decrementBasisCount)(void *, void *); void (*incrementBasisCount)(void *, void *); void (*matchFunction)(void *, void *); int (*synchronized)(void *, void *); } *theInfo; void *dependents; unsigned int busyCount; long timeTag; } *matchingItem; struct multifieldMarker { int whichField; union { void *whichSlot; short whichSlotNumber; } where; long startPosition; long endPosition; struct multifieldMarker *next; } *markers; struct alphaMatch *next; } *theMatch; } gm; } binds[1]; } *beta; struct expr *networkTest; void *rightSideEntryStructure; struct joinNode *nextLevel; struct joinNode *lastLevel; struct joinNode *rightDriveNode; struct joinNode *rightMatchNode; struct defrule *ruleToActivate; } *logicalJoin; struct joinNode *lastJoin; struct defrule *disjunct; } *

return_type: unsigned int

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

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

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

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

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

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

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

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


EnvGetDefruleWatchFirings

repo: jarcec/rbclips

decompiled_code:
__int64 __fastcall EnvGetDefruleWatchFirings(__int64 a1, __int64 a2)
{
if ( !a2 )
return 0LL;
while ( (*(_BYTE *)(a2 + 57) & 0x20) == 0 )
{
a2 = *(_QWORD *)(a2 + 96);
if ( !a2 )
return 0LL;
}
return 1LL;
}

original_code:
unsigned EnvGetDefruleWatchFirings(
  void *theEnv,
  void *rulePtr)
  {
   struct defrule *thePtr;
   for (thePtr = (struct defrule *) rulePtr;
        thePtr != ((void *)0);
        thePtr = thePtr->disjunct)
     { if (thePtr->watchFiring) return(1); }
   return(0);
  }

canonical_original_code:
unsigned int EnvGetDefruleWatchFirings(void *theEnv, void *rulePtr)
  {
   struct defrule *thePtr;
   for (thePtr = (struct defrule *) rulePtr;
        thePtr != ((void *)0);
        thePtr = thePtr->disjunct)
     { if (thePtr->watchFiring) return(1); }
   return(0);
  }

variable_types:
theEnv
void *

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

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

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 defmodule { struct symbolHashNode *name; char *ppForm; struct defmoduleItemHeader **itemsArray; struct portItem *importList; struct portItem *exportList; unsigned int visitedFlag; long bsaveID; struct userData *usrData; struct defmodule *next; }

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

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

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

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


EnvSetDefruleWatchActivations

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

if ( a3 )
{
v3 = 16 * (a2 & 1);
do
{
result = v3 | *(_BYTE *)(a3 + 57) & 0xEFu;
*(_BYTE *)(a3 + 57) = v3 | *(_BYTE *)(a3 + 57) & 0xEF;
a3 = *(_QWORD *)(a3 + 96);
}
while ( a3 );
}
return result;
}

original_code:
void EnvSetDefruleWatchActivations(
  void *theEnv,
  unsigned newState,
  void *rulePtr)
  {
   struct defrule *thePtr;
   for (thePtr = (struct defrule *) rulePtr;
        thePtr != ((void *)0);
        thePtr = thePtr->disjunct)
     { thePtr->watchActivation = newState; }
  }

canonical_original_code:
void EnvSetDefruleWatchActivations(void *theEnv, unsigned int newState, void *rulePtr)
  {
   struct defrule *thePtr;
   for (thePtr = (struct defrule *) rulePtr;
        thePtr != ((void *)0);
        thePtr = thePtr->disjunct)
     { thePtr->watchActivation = newState; }
  }

variable_types:
newState
unsigned int

return_type: void

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


EnvSetDefruleWatchFirings

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

if ( a3 )
{
v3 = 32 * (a2 & 1);
do
{
result = v3 | *(_BYTE *)(a3 + 57) & 0xDFu;
*(_BYTE *)(a3 + 57) = v3 | *(_BYTE *)(a3 + 57) & 0xDF;
a3 = *(_QWORD *)(a3 + 96);
}
while ( a3 );
}
return result;
}

original_code:
void EnvSetDefruleWatchFirings(
  void *theEnv,
  unsigned newState,
  void *rulePtr)
  {
   struct defrule *thePtr;
   for (thePtr = (struct defrule *) rulePtr;
        thePtr != ((void *)0);
        thePtr = thePtr->disjunct)
     { thePtr->watchFiring = newState; }
  }

canonical_original_code:
void EnvSetDefruleWatchFirings(void *theEnv, unsigned int newState, void *rulePtr)
  {
   struct defrule *thePtr;
   for (thePtr = (struct defrule *) rulePtr;
        thePtr != ((void *)0);
        thePtr = thePtr->disjunct)
     { thePtr->watchFiring = newState; }
  }

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


ClearDefrules

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

v1 = EnvFindDefmodule(a1, "MAIN");
return EnvFocus(a1, v1);
}

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

v1 = EnvFindDefmodule(a1, "MAIN");
return EnvFocus(a1, v1);
}

original_code:
static void ClearDefrules(
  void *theEnv)
  {
   struct defmodule *theModule;
   theModule = (struct defmodule *) EnvFindDefmodule(theEnv,"MAIN");
   EnvFocus(theEnv,(void *) theModule);
  }

canonical_original_code:
static void ClearDefrules(void *theEnv)
  {
   struct defmodule *theModule;
   theModule = (struct defmodule *) EnvFindDefmodule(theEnv,"MAIN");
   EnvFocus(theEnv,(void *) theModule);
  }

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


FindConstructBeginning

decompiled_code:
__int64 __fastcall FindConstructBeginning(__int64 a1, __int64 a2, __int16 *a3, int a4, _DWORD *a5)
{
__int16 v5; // ax
int v7; // er13
int v8; // ebp

v5 = *a3;
if ( *a3 == 172 )
return 0LL;
v7 = 1;
v8 = 0;
while ( 1 )
{
if ( v5 == 170 )
{
v8 = 1;
goto LABEL_10;
}
if ( !v8 || v5 != 2 )
{
if ( v7 && !a4 )
goto LABEL_16;
v7 = 0;
v8 = 0;
goto LABEL_10;
}
if ( FindConstruct(a1, *(_QWORD *)(*((_QWORD *)a3 + 1) + 24LL)) )
return 1LL;
if ( v7 && !a4 )
{
LABEL_16:
*a5 = 0;
PrintErrorID(a1, "CSTRCPSR", 1LL, 1LL);
EnvPrintRouter(a1, "werror", "Expected the beginning of a construct.\n");
v7 = 0;
v8 = 0;
a4 = 1;
goto LABEL_10;
}
v7 = 0;
v8 = 0;
LABEL_10:
GetToken(a1, a2, a3);
v5 = *a3;
if ( *a3 == 172 )
return 0LL;
}
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int16 *a3, int a4, _DWORD *a5)
{
__int16 v5; // ax
int v7; // er13
int v8; // ebp

v5 = *a3;
if ( *a3 == 172 )
return 0LL;
v7 = 1;
v8 = 0;
while ( 1 )
{
if ( v5 == 170 )
{
v8 = 1;
goto LABEL_10;
}
if ( !v8 || v5 != 2 )
{
if ( v7 && !a4 )
goto LABEL_16;
v7 = 0;
v8 = 0;
goto LABEL_10;
}
if ( FindConstruct(a1, *(_QWORD *)(*((_QWORD *)a3 + 1) + 24LL)) )
return 1LL;
if ( v7 && !a4 )
{
LABEL_16:
*a5 = 0;
PrintErrorID(a1, "CSTRCPSR", 1LL, 1LL);
EnvPrintRouter(a1, "werror", "Expected the beginning of a construct.\n");
v7 = 0;
v8 = 0;
a4 = 1;
goto LABEL_10;
}
v7 = 0;
v8 = 0;
LABEL_10:
GetToken(a1, a2, a3);
v5 = *a3;
if ( *a3 == 172 )
return 0LL;
}
}

original_code:
static int FindConstructBeginning(
  void *theEnv,
  char *readSource,
  struct token *theToken,
  int errorCorrection,
  int *noErrors)
  {
   int leftParenthesisFound = 0;
   int firstAttempt = 1;
   while (theToken->type != 172)
     {
      if (theToken->type == 170)
        { leftParenthesisFound = 1; }
      else if ((theToken->type == 2) && (leftParenthesisFound == 1))
        {
         if (FindConstruct(theEnv,(((struct symbolHashNode *) (theToken->value))->contents)) != ((void *)0)) return(1);
         if (firstAttempt && (! errorCorrection))
           {
            errorCorrection = 1;
            *noErrors = 0;
            PrintErrorID(theEnv,"CSTRCPSR",1,1);
            EnvPrintRouter(theEnv,"werror","Expected the beginning of a construct.\n");
           }
         firstAttempt = 0;
         leftParenthesisFound = 0;
        }
      else
        {
         if (firstAttempt && (! errorCorrection))
           {
            errorCorrection = 1;
            *noErrors = 0;
            PrintErrorID(theEnv,"CSTRCPSR",1,1);
            EnvPrintRouter(theEnv,"werror","Expected the beginning of a construct.\n");
           }
         firstAttempt = 0;
         leftParenthesisFound = 0;
        }
      GetToken(theEnv,readSource,theToken);
     }
   return(0);
  }

canonical_original_code:
static int FindConstructBeginning(void *theEnv, char *readSource, struct token *theToken, int errorCorrection, int *noErrors)
  {
   int leftParenthesisFound = 0;
   int firstAttempt = 1;
   while (theToken->type != 172)
     {
      if (theToken->type == 170)
        { leftParenthesisFound = 1; }
      else if ((theToken->type == 2) && (leftParenthesisFound == 1))
        {
         if (FindConstruct(theEnv,(((struct symbolHashNode *) (theToken->value))->contents)) != ((void *)0)) return(1);
         if (firstAttempt && (! errorCorrection))
           {
            errorCorrection = 1;
            *noErrors = 0;
            PrintErrorID(theEnv,"CSTRCPSR",1,1);
            EnvPrintRouter(theEnv,"werror","Expected the beginning of a construct.\n");
           }
         firstAttempt = 0;
         leftParenthesisFound = 0;
        }
      else
        {
         if (firstAttempt && (! errorCorrection))
           {
            errorCorrection = 1;
            *noErrors = 0;
            PrintErrorID(theEnv,"CSTRCPSR",1,1);
            EnvPrintRouter(theEnv,"werror","Expected the beginning of a construct.\n");
           }
         firstAttempt = 0;
         leftParenthesisFound = 0;
        }
      GetToken(theEnv,readSource,theToken);
     }
   return(0);
  }

variable_types:
readSource
char *

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

variable_types: errorCorrection int

variable_types:
noErrors
int *

variable_types: leftParenthesisFound int

variable_types: firstAttempt int

return_type: int


ParseConstruct

decompiled_code:
__int64 __fastcall ParseConstruct(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rbp
unsigned int v6; // er13
unsigned int v7; // ebp

v4 = FindConstruct(a1, a2);
if ( !v4 )
return (unsigned int)-1;
v5 = v4;
v6 = GetHaltExecution(a1);
SetEvaluationError(a1, 0LL);
SetHaltExecution(a1, 0LL);
ClearParsedBindNames(a1);
PushRtnBrkContexts(a1);
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 360LL) + 80LL) = 0;
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 360LL) + 84LL) = 0;
++*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL);
v7 = (*(__int64 (__fastcall **)(__int64, __int64))(v5 + 16))(a1, a3);
--*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL);
PopRtnBrkContexts(a1);
ClearParsedBindNames(a1);
SetPPBufferStatus(a1, 0LL);
SetHaltExecution(a1, v6);
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rbp
unsigned int v6; // er13
unsigned int v7; // ebp

v4 = FindConstruct(a1, a2);
if ( !v4 )
return (unsigned int)-1;
v5 = v4;
v6 = GetHaltExecution(a1);
SetEvaluationError(a1, 0LL);
SetHaltExecution(a1, 0LL);
ClearParsedBindNames(a1);
PushRtnBrkContexts(a1);
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 360LL) + 80LL) = 0;
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 360LL) + 84LL) = 0;
++*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL);
v7 = (*(__int64 (__fastcall **)(__int64, __int64))(v5 + 16))(a1, a3);
--*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL);
PopRtnBrkContexts(a1);
ClearParsedBindNames(a1);
SetPPBufferStatus(a1, 0LL);
SetHaltExecution(a1, v6);
return v7;
}

original_code:
int ParseConstruct(
  void *theEnv,
  char *name,
  char *logicalName)
  {
   struct construct *currentPtr;
   int rv, ov;
   currentPtr = FindConstruct(theEnv,name);
   if (currentPtr == ((void *)0)) return(-1);
   ov = GetHaltExecution(theEnv);
   SetEvaluationError(theEnv,0);
   SetHaltExecution(theEnv,0);
   ClearParsedBindNames(theEnv);
   PushRtnBrkContexts(theEnv);
   ((struct expressionData *) (((struct environmentData *) theEnv)->theData[45]))->ReturnContext = 0;
   ((struct expressionData *) (((struct environmentData *) theEnv)->theData[45]))->BreakContext = 0;
   ((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentEvaluationDepth++;
   rv = (*currentPtr->parseFunction)(theEnv,logicalName);
   ((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentEvaluationDepth--;
   PopRtnBrkContexts(theEnv);
   ClearParsedBindNames(theEnv);
   SetPPBufferStatus(theEnv,0);
   SetHaltExecution(theEnv,ov);
   return(rv);
  }

canonical_original_code:
int ParseConstruct(void *theEnv, char *name, char *logicalName)
  {
   struct construct *currentPtr;
   int rv; int ov;
   currentPtr = FindConstruct(theEnv,name);
   if (currentPtr == ((void *)0)) return(-1);
   ov = GetHaltExecution(theEnv);
   SetEvaluationError(theEnv,0);
   SetHaltExecution(theEnv,0);
   ClearParsedBindNames(theEnv);
   PushRtnBrkContexts(theEnv);
   ((struct expressionData *) (((struct environmentData *) theEnv)->theData[45]))->ReturnContext = 0;
   ((struct expressionData *) (((struct environmentData *) theEnv)->theData[45]))->BreakContext = 0;
   ((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentEvaluationDepth++;
   rv = (*currentPtr->parseFunction)(theEnv,logicalName);
   ((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentEvaluationDepth--;
   PopRtnBrkContexts(theEnv);
   ClearParsedBindNames(theEnv);
   SetPPBufferStatus(theEnv,0);
   SetHaltExecution(theEnv,ov);
   return(rv);
  }

variable_types:
name
char *

variable_types:
logicalName
char *

variable_types: struct construct { char *constructName; char *pluralName; int (*parseFunction)(void *, char *); void *(*findFunction)(void *, char *); struct symbolHashNode { struct symbolHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int neededSymbol; unsigned int bucket; char *contents; } *(*getConstructNameFunction)(struct constructHeader { struct symbolHashNode *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; } *); char *(*getPPFormFunction)(void *, struct constructHeader *); struct defmoduleItemHeader *(*getModuleItemFunction)(struct constructHeader *); void *(*getNextItemFunction)(void *, void *); void (*setNextItemFunction)(struct constructHeader *, struct constructHeader *); int (*isConstructDeletableFunction)(void *, void *); int (*deleteFunction)(void *, void *); void (*freeFunction)(void *, void *); struct construct *next; } *

variable_types: rv int

variable_types: ov int

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

user_defined_types: struct 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 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 evaluationData { struct expr *CurrentExpression; int EvaluationError; int HaltExecution; int CurrentEvaluationDepth; struct entityRecord *PrimitivesArray[150]; }

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

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

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


LoadConstructsFromLogicalName

decompiled_code:
__int64 __fastcall LoadConstructsFromLogicalName(__int64 a1, __int64 a2)
{
__int64 v2; // rax
int v3; // ebp
unsigned int v5; // [rsp+Ch] [rbp-4Ch] BYREF
__int16 v6; // [rsp+10h] [rbp-48h] BYREF
__int64 v7; // [rsp+18h] [rbp-40h]

v5 = 1;
if ( !*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL) )
SetHaltExecution(a1, 0LL);
SetEvaluationError(a1, 0LL);
++*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL);
GetToken(a1, a2, &v6);
if ( (unsigned int)FindConstructBeginning(a1, a2, &v6, 0, &v5) == 1 )
{
while ( !(unsigned int)GetHaltExecution(a1) )
{
FlushPPBuffer(a1);
if ( (unsigned int)ParseConstruct(a1, *(_QWORD *)(v7 + 24), a2) == 1 )
{
EnvPrintRouter(a1, "werror", "\nERROR:\n");
v2 = GetPPBuffer(a1);
PrintInChunks(a1, "werror", v2);
EnvPrintRouter(a1, "werror", "\n");
v5 = 0;
GetToken(a1, a2, &v6);
v3 = FindConstructBeginning(a1, a2, &v6, 1, &v5);
}
else
{
GetToken(a1, a2, &v6);
v3 = FindConstructBeginning(a1, a2, &v6, 0, &v5);
}
if ( !v3 )
{
--*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL);
PeriodicCleanup(a1, 0LL, 1LL);
YieldTime(a1);
++*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL);
break;
}
++*(_QWORD *)(v7 + 8);
--*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL);
PeriodicCleanup(a1, 0LL, 1LL);
YieldTime(a1);
++*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL);
DecrementSymbolCount(a1, v7);
if ( v3 != 1 )
break;
}
}
--*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL);
if ( (unsigned int)EnvGetWatchItem(a1, "compilations") != 1 && (unsigned int)GetPrintWhileLoading(a1) )
EnvPrintRouter(a1, "wdialog", "\n");
DestroyPPBuffer(a1);
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 v2; // rax
int v3; // ebp
unsigned int v5; // [rsp+Ch] [rbp-4Ch] BYREF
__int16 v6; // [rsp+10h] [rbp-48h] BYREF
__int64 v7; // [rsp+18h] [rbp-40h]

v5 = 1;
if ( !*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL) )
SetHaltExecution(a1, 0LL);
SetEvaluationError(a1, 0LL);
++*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL);
GetToken(a1, a2, &v6);
if ( (unsigned int)func0(a1, a2, &v6, 0, &v5) == 1 )
{
while ( !(unsigned int)GetHaltExecution(a1) )
{
FlushPPBuffer(a1);
if ( (unsigned int)func1(a1, *(_QWORD *)(v7 + 24), a2) == 1 )
{
EnvPrintRouter(a1, "werror", "\nERROR:\n");
v2 = GetPPBuffer(a1);
PrintInChunks(a1, "werror", v2);
EnvPrintRouter(a1, "werror", "\n");
v5 = 0;
GetToken(a1, a2, &v6);
v3 = func0(a1, a2, &v6, 1, &v5);
}
else
{
GetToken(a1, a2, &v6);
v3 = func0(a1, a2, &v6, 0, &v5);
}
if ( !v3 )
{
--*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL);
PeriodicCleanup(a1, 0LL, 1LL);
YieldTime(a1);
++*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL);
break;
}
++*(_QWORD *)(v7 + 8);
--*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL);
PeriodicCleanup(a1, 0LL, 1LL);
YieldTime(a1);
++*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL);
DecrementSymbolCount(a1, v7);
if ( v3 != 1 )
break;
}
}
--*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 352LL) + 16LL);
if ( (unsigned int)EnvGetWatchItem(a1, "compilations") != 1 && (unsigned int)GetPrintWhileLoading(a1) )
EnvPrintRouter(a1, "wdialog", "\n");
DestroyPPBuffer(a1);
return v5;
}

original_code:
int LoadConstructsFromLogicalName(
  void *theEnv,
  char *readSource)
  {
   int constructFlag;
   struct token theToken;
   int noErrors = 1;
   int foundConstruct;
   if (((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentEvaluationDepth == 0) SetHaltExecution(theEnv,0);
   SetEvaluationError(theEnv,0);
   ((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentEvaluationDepth++;
   GetToken(theEnv,readSource,&theToken);
   foundConstruct = FindConstructBeginning(theEnv,readSource,&theToken,0,&noErrors);
   while ((foundConstruct == 1) && (GetHaltExecution(theEnv) == 0))
     {
      FlushPPBuffer(theEnv);
      constructFlag = ParseConstruct(theEnv,(((struct symbolHashNode *) (theToken.value))->contents),readSource);
      if (constructFlag == 1)
        {
         EnvPrintRouter(theEnv,"werror","\nERROR:\n");
         PrintInChunks(theEnv,"werror",GetPPBuffer(theEnv));
         EnvPrintRouter(theEnv,"werror","\n");
         noErrors = 0;
         GetToken(theEnv,readSource,&theToken);
         foundConstruct = FindConstructBeginning(theEnv,readSource,&theToken,1,&noErrors);
        }
      else
        {
         GetToken(theEnv,readSource,&theToken);
         foundConstruct = FindConstructBeginning(theEnv,readSource,&theToken,0,&noErrors);
        }
       if (foundConstruct)
         { (((SYMBOL_HN *) theToken.value)->count++); }
       ((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentEvaluationDepth--;
       PeriodicCleanup(theEnv,0,1);
       YieldTime(theEnv);
       ((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentEvaluationDepth++;
       if (foundConstruct)
         { DecrementSymbolCount(theEnv,(SYMBOL_HN *) theToken.value); }
     }
   ((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentEvaluationDepth--;
   if ((EnvGetWatchItem(theEnv,"compilations") != 1) && GetPrintWhileLoading(theEnv))
     { EnvPrintRouter(theEnv,"wdialog","\n"); }
   DestroyPPBuffer(theEnv);
   return(noErrors);
  }

canonical_original_code:
int LoadConstructsFromLogicalName(void *theEnv, char *readSource)
  {
   int constructFlag;
   struct token theToken;
   int noErrors = 1;
   int foundConstruct;
   if (((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentEvaluationDepth == 0) SetHaltExecution(theEnv,0);
   SetEvaluationError(theEnv,0);
   ((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentEvaluationDepth++;
   GetToken(theEnv,readSource,&theToken);
   foundConstruct = FindConstructBeginning(theEnv,readSource,&theToken,0,&noErrors);
   while ((foundConstruct == 1) && (GetHaltExecution(theEnv) == 0))
     {
      FlushPPBuffer(theEnv);
      constructFlag = ParseConstruct(theEnv,(((struct symbolHashNode *) (theToken.value))->contents),readSource);
      if (constructFlag == 1)
        {
         EnvPrintRouter(theEnv,"werror","\nERROR:\n");
         PrintInChunks(theEnv,"werror",GetPPBuffer(theEnv));
         EnvPrintRouter(theEnv,"werror","\n");
         noErrors = 0;
         GetToken(theEnv,readSource,&theToken);
         foundConstruct = FindConstructBeginning(theEnv,readSource,&theToken,1,&noErrors);
        }
      else
        {
         GetToken(theEnv,readSource,&theToken);
         foundConstruct = FindConstructBeginning(theEnv,readSource,&theToken,0,&noErrors);
        }
       if (foundConstruct)
         { (((struct symbolHashNode *) theToken.value)->count++); }
       ((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentEvaluationDepth--;
       PeriodicCleanup(theEnv,0,1);
       YieldTime(theEnv);
       ((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentEvaluationDepth++;
       if (foundConstruct)
         { DecrementSymbolCount(theEnv,(struct symbolHashNode *) theToken.value); }
     }
   ((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->CurrentEvaluationDepth--;
   if ((EnvGetWatchItem(theEnv,"compilations") != 1) && GetPrintWhileLoading(theEnv))
     { EnvPrintRouter(theEnv,"wdialog","\n"); }
   DestroyPPBuffer(theEnv);
   return(noErrors);
  }

variable_types: constructFlag int

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

variable_types: noErrors int

variable_types: foundConstruct int

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

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


RemoveConstructFromModule

original_code:
void RemoveConstructFromModule(
  void *theEnv,
  struct constructHeader *theConstruct)
  {
   struct constructHeader *lastConstruct,*currentConstruct;
   lastConstruct = ((void *)0);
   currentConstruct = theConstruct->whichModule->firstItem;
   while (currentConstruct != theConstruct)
     {
      lastConstruct = currentConstruct;
      currentConstruct = currentConstruct->next;
     }
   if (currentConstruct == ((void *)0))
     {
      SystemError(theEnv,"CSTRCPSR",1);
      EnvExitRouter(theEnv,1);
     }
   if (lastConstruct == ((void *)0))
     { theConstruct->whichModule->firstItem = theConstruct->next; }
   else
     { lastConstruct->next = theConstruct->next; }
   if (theConstruct == theConstruct->whichModule->lastItem)
     { theConstruct->whichModule->lastItem = lastConstruct; }
  }

canonical_original_code:
void RemoveConstructFromModule(void *theEnv, struct constructHeader *theConstruct)
  {
   struct constructHeader *lastConstruct; struct constructHeader *currentConstruct;
   lastConstruct = ((void *)0);
   currentConstruct = theConstruct->whichModule->firstItem;
   while (currentConstruct != theConstruct)
     {
      lastConstruct = currentConstruct;
      currentConstruct = currentConstruct->next;
     }
   if (currentConstruct == ((void *)0))
     {
      SystemError(theEnv,"CSTRCPSR",1);
      EnvExitRouter(theEnv,1);
     }
   if (lastConstruct == ((void *)0))
     { theConstruct->whichModule->firstItem = theConstruct->next; }
   else
     { lastConstruct->next = theConstruct->next; }
   if (theConstruct == theConstruct->whichModule->lastItem)
     { theConstruct->whichModule->lastItem = lastConstruct; }
  }

variable_types:
theEnv
void *

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

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

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


ImportExportConflictMessage

decompiled_code:
__int64 __fastcall ImportExportConflictMessage(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
PrintErrorID(a1, "CSTRCPSR", 3LL, 1LL);
EnvPrintRouter(a1, "werror", "Cannot define ");
EnvPrintRouter(a1, "werror", a2);
EnvPrintRouter(a1, "werror", " ");
EnvPrintRouter(a1, "werror", a3);
EnvPrintRouter(a1, "werror", " because of an import/export conflict");
if ( a4 )
{
EnvPrintRouter(a1, "werror", " caused by the ");
EnvPrintRouter(a1, "werror", a4);
EnvPrintRouter(a1, "werror", " ");
EnvPrintRouter(a1, "werror", a5);
}
return EnvPrintRouter(a1, "werror", ".\n");
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
PrintErrorID(a1, "CSTRCPSR", 3LL, 1LL);
EnvPrintRouter(a1, "werror", "Cannot define ");
EnvPrintRouter(a1, "werror", a2);
EnvPrintRouter(a1, "werror", " ");
EnvPrintRouter(a1, "werror", a3);
EnvPrintRouter(a1, "werror", " because of an import/export conflict");
if ( a4 )
{
EnvPrintRouter(a1, "werror", " caused by the ");
EnvPrintRouter(a1, "werror", a4);
EnvPrintRouter(a1, "werror", " ");
EnvPrintRouter(a1, "werror", a5);
}
return EnvPrintRouter(a1, "werror", ".\n");
}

original_code:
void ImportExportConflictMessage(
  void *theEnv,
  char *constructName,
  char *itemName,
  char *causedByConstruct,
  char *causedByName)
  {
   PrintErrorID(theEnv,"CSTRCPSR",3,1);
   EnvPrintRouter(theEnv,"werror","Cannot define ");
   EnvPrintRouter(theEnv,"werror",constructName);
   EnvPrintRouter(theEnv,"werror"," ");
   EnvPrintRouter(theEnv,"werror",itemName);
   EnvPrintRouter(theEnv,"werror"," because of an import/export conflict");
   if (causedByConstruct == ((void *)0)) EnvPrintRouter(theEnv,"werror",".\n");
   else
     {
      EnvPrintRouter(theEnv,"werror"," caused by the ");
      EnvPrintRouter(theEnv,"werror",causedByConstruct);
      EnvPrintRouter(theEnv,"werror"," ");
      EnvPrintRouter(theEnv,"werror",causedByName);
      EnvPrintRouter(theEnv,"werror",".\n");
     }
  }

canonical_original_code:
void ImportExportConflictMessage(void *theEnv, char *constructName, char *itemName, char *causedByConstruct, char *causedByName)
  {
   PrintErrorID(theEnv,"CSTRCPSR",3,1);
   EnvPrintRouter(theEnv,"werror","Cannot define ");
   EnvPrintRouter(theEnv,"werror",constructName);
   EnvPrintRouter(theEnv,"werror"," ");
   EnvPrintRouter(theEnv,"werror",itemName);
   EnvPrintRouter(theEnv,"werror"," because of an import/export conflict");
   if (causedByConstruct == ((void *)0)) EnvPrintRouter(theEnv,"werror",".\n");
   else
     {
      EnvPrintRouter(theEnv,"werror"," caused by the ");
      EnvPrintRouter(theEnv,"werror",causedByConstruct);
      EnvPrintRouter(theEnv,"werror"," ");
      EnvPrintRouter(theEnv,"werror",causedByName);
      EnvPrintRouter(theEnv,"werror",".\n");
     }
  }

variable_types:
constructName
char *

variable_types:
itemName
char *

variable_types:
causedByConstruct
char *

variable_types:
causedByName
char *


GetConstructNameAndComment

decompiled_code:
__int64 __fastcall GetConstructNameAndComment(__int64 a1, __int64 a2, __int16 *a3, __int64 a4, __int64 (__fastcall *a5)(__int64, _QWORD), unsigned int (__fastcall *a6)(__int64, __int64), __int64 a7, int a8, int a9, int a10)
{
__int64 v11; // r12
unsigned int v12; // eax
unsigned int v13; // er14
__int64 v14; // rax
__int64 v15; // r15
int v16; // er15
__int64 v17; // rax
__int16 v18; // ax
__int64 v20; // rax
__int64 v22; // [rsp+8h] [rbp-50h]

GetToken(a1, a2, a3);
if ( *a3 != 2 )
{
PrintErrorID(a1, "CSTRCPSR", 2LL, 1LL);
EnvPrintRouter(a1, "werror", "Missing name for ");
EnvPrintRouter(a1, "werror", a4);
EnvPrintRouter(a1, "werror", " construct\n");
return 0LL;
}
v11 = *((_QWORD *)a3 + 1);
v12 = FindModuleSeparator(*(_QWORD *)(v11 + 24));
v13 = v12;
if ( v12 )
{
if ( !a10 )
{
SyntaxErrorMessage(a1, "module specifier");
return 0LL;
}
v14 = ExtractModuleName(a1, v12, *(_QWORD *)(v11 + 24));
v15 = v14;
if ( !v14 )
{
SyntaxErrorMessage(a1, "construct name");
return 0LL;
}
v22 = EnvFindDefmodule(a1, *(_QWORD *)(v14 + 24));
if ( !v22 )
{
CantFindItemErrorMessage(a1, "defmodule", *(_QWORD *)(v15 + 24));
return 0LL;
}
EnvSetCurrentModule(a1, v22);
v11 = ExtractConstructName(a1, v13, *(_QWORD *)(v11 + 24));
if ( !v11 )
{
SyntaxErrorMessage(a1, "construct name");
return v11;
}
}
else
{
v22 = EnvGetCurrentModule(a1);
if ( a10 )
{
PPBackup(a1);
v20 = EnvGetDefmoduleName(a1, v22);
SavePPBuffer(a1, v20);
SavePPBuffer(a1, "::");
SavePPBuffer(a1, *(_QWORD *)(v11 + 24));
}
}
v16 = FindImportExportConflict(a1, a4, v22, *(_QWORD *)(v11 + 24));
if ( v16 )
{
ImportExportConflictMessage(a1, a4, *(_QWORD *)(v11 + 24), 0LL, 0LL);
return 0LL;
}
if ( a5 && !*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 336LL) + 80LL) )
{
v17 = a5(a1, *(_QWORD *)(v11 + 24));
if ( v17 )
{
if ( a6 )
{
v16 = 1;
if ( !a6(a1, v17) )
{
PrintErrorID(a1, "CSTRCPSR", 4LL, 1LL);
EnvPrintRouter(a1, "werror", "Cannot redefine ");
EnvPrintRouter(a1, "werror", a4);
EnvPrintRouter(a1, "werror", " ");
EnvPrintRouter(a1, "werror", *(_QWORD *)(v11 + 24));
EnvPrintRouter(a1, "werror", " while it is in use.\n");
return 0LL;
}
}
else
{
v16 = 1;
}
}
else
{
v16 = 0;
}
}
if ( (unsigned int)EnvGetWatchItem(a1, "compilations") == 1
&& (unsigned int)GetPrintWhileLoading(a1)
&& !*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 336LL) + 80LL) )
{
if ( v16 )
{
PrintWarningID(a1, "CSTRCPSR", 1LL, 1LL);
EnvPrintRouter(a1, "wdialog", "Redefining ");
}
else
{
EnvPrintRouter(a1, "wdialog", "Defining ");
}
EnvPrintRouter(a1, "wdialog", a4);
EnvPrintRouter(a1, "wdialog", ": ");
EnvPrintRouter(a1, "wdialog", *(_QWORD *)(v11 + 24));
if ( a8 )
EnvPrintRouter(a1, "wdialog", "\n");
else
EnvPrintRouter(a1, "wdialog", " ");
}
else if ( (unsigned int)GetPrintWhileLoading(a1) && !*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 336LL) + 80LL) )
{
EnvPrintRouter(a1, "wdialog", a7);
}
GetToken(a1, a2, a3);
v18 = *a3;
if ( a9 && v18 == 3 )
{
PPBackup(a1);
SavePPBuffer(a1, " ");
SavePPBuffer(a1, *((_QWORD *)a3 + 2));
GetToken(a1, a2, a3);
if ( *a3 == 171 )
return v11;
goto LABEL_20;
}
if ( v18 != 171 )
{
LABEL_20:
PPBackup(a1);
SavePPBuffer(a1, "\n ");
SavePPBuffer(a1, *((_QWORD *)a3 + 2));
}
return v11;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2, __int16 *a3, __int64 a4, __int64 (__fastcall *a5)(__int64, _QWORD), unsigned int (__fastcall *a6)(__int64, __int64), __int64 a7, int a8, int a9, int a10)
{
__int64 v11; // r12
unsigned int v12; // eax
unsigned int v13; // er14
__int64 v14; // rax
__int64 v15; // r15
int v16; // er15
__int64 v17; // rax
__int16 v18; // ax
__int64 v20; // rax
__int64 v22; // [rsp+8h] [rbp-50h]

GetToken(a1, a2, a3);
if ( *a3 != 2 )
{
PrintErrorID(a1, "CSTRCPSR", 2LL, 1LL);
EnvPrintRouter(a1, "werror", "Missing name for ");
EnvPrintRouter(a1, "werror", a4);
EnvPrintRouter(a1, "werror", " construct\n");
return 0LL;
}
v11 = *((_QWORD *)a3 + 1);
v12 = FindModuleSeparator(*(_QWORD *)(v11 + 24));
v13 = v12;
if ( v12 )
{
if ( !a10 )
{
SyntaxErrorMessage(a1, "module specifier");
return 0LL;
}
v14 = ExtractModuleName(a1, v12, *(_QWORD *)(v11 + 24));
v15 = v14;
if ( !v14 )
{
SyntaxErrorMessage(a1, "construct name");
return 0LL;
}
v22 = EnvFindDefmodule(a1, *(_QWORD *)(v14 + 24));
if ( !v22 )
{
CantFindItemErrorMessage(a1, "defmodule", *(_QWORD *)(v15 + 24));
return 0LL;
}
EnvSetCurrentModule(a1, v22);
v11 = ExtractConstructName(a1, v13, *(_QWORD *)(v11 + 24));
if ( !v11 )
{
SyntaxErrorMessage(a1, "construct name");
return v11;
}
}
else
{
v22 = EnvGetCurrentModule(a1);
if ( a10 )
{
PPBackup(a1);
v20 = EnvGetDefmoduleName(a1, v22);
SavePPBuffer(a1, v20);
SavePPBuffer(a1, "::");
SavePPBuffer(a1, *(_QWORD *)(v11 + 24));
}
}
v16 = FindImportExportConflict(a1, a4, v22, *(_QWORD *)(v11 + 24));
if ( v16 )
{
func5(a1, a4, *(_QWORD *)(v11 + 24), 0LL, 0LL);
return 0LL;
}
if ( a5 && !*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 336LL) + 80LL) )
{
v17 = a5(a1, *(_QWORD *)(v11 + 24));
if ( v17 )
{
if ( a6 )
{
v16 = 1;
if ( !a6(a1, v17) )
{
PrintErrorID(a1, "CSTRCPSR", 4LL, 1LL);
EnvPrintRouter(a1, "werror", "Cannot redefine ");
EnvPrintRouter(a1, "werror", a4);
EnvPrintRouter(a1, "werror", " ");
EnvPrintRouter(a1, "werror", *(_QWORD *)(v11 + 24));
EnvPrintRouter(a1, "werror", " while it is in use.\n");
return 0LL;
}
}
else
{
v16 = 1;
}
}
else
{
v16 = 0;
}
}
if ( (unsigned int)EnvGetWatchItem(a1, "compilations") == 1
&& (unsigned int)GetPrintWhileLoading(a1)
&& !*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 336LL) + 80LL) )
{
if ( v16 )
{
PrintWarningID(a1, "CSTRCPSR", 1LL, 1LL);
EnvPrintRouter(a1, "wdialog", "Redefining ");
}
else
{
EnvPrintRouter(a1, "wdialog", "Defining ");
}
EnvPrintRouter(a1, "wdialog", a4);
EnvPrintRouter(a1, "wdialog", ": ");
EnvPrintRouter(a1, "wdialog", *(_QWORD *)(v11 + 24));
if ( a8 )
EnvPrintRouter(a1, "wdialog", "\n");
else
EnvPrintRouter(a1, "wdialog", " ");
}
else if ( (unsigned int)GetPrintWhileLoading(a1) && !*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 336LL) + 80LL) )
{
EnvPrintRouter(a1, "wdialog", a7);
}
GetToken(a1, a2, a3);
v18 = *a3;
if ( a9 && v18 == 3 )
{
PPBackup(a1);
SavePPBuffer(a1, " ");
SavePPBuffer(a1, *((_QWORD *)a3 + 2));
GetToken(a1, a2, a3);
if ( *a3 == 171 )
return v11;
goto LABEL_20;
}
if ( v18 != 171 )
{
LABEL_20:
PPBackup(a1);
SavePPBuffer(a1, "\n ");
SavePPBuffer(a1, *((_QWORD *)a3 + 2));
}
return v11;
}

original_code:
SYMBOL_HN *GetConstructNameAndComment(
  void *theEnv,
  char *readSource,
  struct token *inputToken,
  char *constructName,
  void *(*findFunction)(void *,char *),
  int (*deleteFunction)(void *,void *),
  char *constructSymbol,
  int fullMessageCR,
  int getComment,
  int moduleNameAllowed)
  {
   SYMBOL_HN *name, *moduleName;
   int redefining = 0;
   void *theConstruct;
   unsigned separatorPosition;
   struct defmodule *theModule;
   GetToken(theEnv,readSource,inputToken);
   if (inputToken->type != 2)
     {
      PrintErrorID(theEnv,"CSTRCPSR",2,1);
      EnvPrintRouter(theEnv,"werror","Missing name for ");
      EnvPrintRouter(theEnv,"werror",constructName);
      EnvPrintRouter(theEnv,"werror"," construct\n");
      return(((void *)0));
     }
   name = (SYMBOL_HN *) inputToken->value;
   separatorPosition = FindModuleSeparator((((struct symbolHashNode *) (name))->contents));
   if (separatorPosition)
     {
      if (moduleNameAllowed == 0)
        {
         SyntaxErrorMessage(theEnv,"module specifier");
         return(((void *)0));
        }
      moduleName = ExtractModuleName(theEnv,separatorPosition,(((struct symbolHashNode *) (name))->contents));
      if (moduleName == ((void *)0))
        {
         SyntaxErrorMessage(theEnv,"construct name");
         return(((void *)0));
        }
      theModule = (struct defmodule *) EnvFindDefmodule(theEnv,(((struct symbolHashNode *) (moduleName))->contents));
      if (theModule == ((void *)0))
        {
         CantFindItemErrorMessage(theEnv,"defmodule",(((struct symbolHashNode *) (moduleName))->contents));
         return(((void *)0));
        }
      EnvSetCurrentModule(theEnv,(void *) theModule);
      name = ExtractConstructName(theEnv,separatorPosition,(((struct symbolHashNode *) (name))->contents));
      if (name == ((void *)0))
        {
         SyntaxErrorMessage(theEnv,"construct name");
         return(((void *)0));
        }
     }
   else
     {
      theModule = ((struct defmodule *) EnvGetCurrentModule(theEnv));
      if (moduleNameAllowed)
        {
         PPBackup(theEnv);
         SavePPBuffer(theEnv,EnvGetDefmoduleName(theEnv,theModule));
         SavePPBuffer(theEnv,"::");
         SavePPBuffer(theEnv,(((struct symbolHashNode *) (name))->contents));
        }
     }
   if (FindImportExportConflict(theEnv,constructName,theModule,(((struct symbolHashNode *) (name))->contents)))
     {
      ImportExportConflictMessage(theEnv,constructName,(((struct symbolHashNode *) (name))->contents),((void *)0),((void *)0));
      return(((void *)0));
     }
   if ((findFunction != ((void *)0)) && (! ((struct constructData *) (((struct environmentData *) theEnv)->theData[42]))->CheckSyntaxMode))
     {
      theConstruct = (*findFunction)(theEnv,(((struct symbolHashNode *) (name))->contents));
      if (theConstruct != ((void *)0))
        {
         redefining = 1;
         if (deleteFunction != ((void *)0))
           {
            if ((*deleteFunction)(theEnv,theConstruct) == 0)
              {
               PrintErrorID(theEnv,"CSTRCPSR",4,1);
               EnvPrintRouter(theEnv,"werror","Cannot redefine ");
               EnvPrintRouter(theEnv,"werror",constructName);
               EnvPrintRouter(theEnv,"werror"," ");
               EnvPrintRouter(theEnv,"werror",(((struct symbolHashNode *) (name))->contents));
               EnvPrintRouter(theEnv,"werror"," while it is in use.\n");
               return(((void *)0));
              }
           }
        }
     }
   if ((EnvGetWatchItem(theEnv,"compilations") == 1) &&
       GetPrintWhileLoading(theEnv) && (! ((struct constructData *) (((struct environmentData *) theEnv)->theData[42]))->CheckSyntaxMode))
     {
      if (redefining)
        {
         PrintWarningID(theEnv,"CSTRCPSR",1,1);
         EnvPrintRouter(theEnv,"wdialog","Redefining ");
        }
      else EnvPrintRouter(theEnv,"wdialog","Defining ");
      EnvPrintRouter(theEnv,"wdialog",constructName);
      EnvPrintRouter(theEnv,"wdialog",": ");
      EnvPrintRouter(theEnv,"wdialog",(((struct symbolHashNode *) (name))->contents));
      if (fullMessageCR) EnvPrintRouter(theEnv,"wdialog","\n");
      else EnvPrintRouter(theEnv,"wdialog"," ");
     }
   else
     {
      if (GetPrintWhileLoading(theEnv) && (! ((struct constructData *) (((struct environmentData *) theEnv)->theData[42]))->CheckSyntaxMode))
        { EnvPrintRouter(theEnv,"wdialog",constructSymbol); }
     }
   GetToken(theEnv,readSource,inputToken);
   if ((inputToken->type == 3) && getComment)
     {
      PPBackup(theEnv);
      SavePPBuffer(theEnv," ");
      SavePPBuffer(theEnv,inputToken->printForm);
      GetToken(theEnv,readSource,inputToken);
      if (inputToken->type != 171)
        {
         PPBackup(theEnv);
         SavePPBuffer(theEnv,"\n   ");
         SavePPBuffer(theEnv,inputToken->printForm);
        }
     }
   else if (inputToken->type != 171)
     {
      PPBackup(theEnv);
      SavePPBuffer(theEnv,"\n   ");
      SavePPBuffer(theEnv,inputToken->printForm);
     }
   return(name);
  }

canonical_original_code:
struct symbolHashNode *GetConstructNameAndComment(void *theEnv, char *readSource, struct token *inputToken, char *constructName, void *(*findFunction)(void *, char *), int (*deleteFunction)(void *, void *), char *constructSymbol, int fullMessageCR, int getComment, int moduleNameAllowed)
  {
   struct symbolHashNode *name; struct symbolHashNode *moduleName;
   int redefining = 0;
   void *theConstruct;
   unsigned int separatorPosition;
   struct defmodule *theModule;
   GetToken(theEnv,readSource,inputToken);
   if (inputToken->type != 2)
     {
      PrintErrorID(theEnv,"CSTRCPSR",2,1);
      EnvPrintRouter(theEnv,"werror","Missing name for ");
      EnvPrintRouter(theEnv,"werror",constructName);
      EnvPrintRouter(theEnv,"werror"," construct\n");
      return(((void *)0));
     }
   name = (struct symbolHashNode *) inputToken->value;
   separatorPosition = FindModuleSeparator((((struct symbolHashNode *) (name))->contents));
   if (separatorPosition)
     {
      if (moduleNameAllowed == 0)
        {
         SyntaxErrorMessage(theEnv,"module specifier");
         return(((void *)0));
        }
      moduleName = ExtractModuleName(theEnv,separatorPosition,(((struct symbolHashNode *) (name))->contents));
      if (moduleName == ((void *)0))
        {
         SyntaxErrorMessage(theEnv,"construct name");
         return(((void *)0));
        }
      theModule = (struct defmodule *) EnvFindDefmodule(theEnv,(((struct symbolHashNode *) (moduleName))->contents));
      if (theModule == ((void *)0))
        {
         CantFindItemErrorMessage(theEnv,"defmodule",(((struct symbolHashNode *) (moduleName))->contents));
         return(((void *)0));
        }
      EnvSetCurrentModule(theEnv,(void *) theModule);
      name = ExtractConstructName(theEnv,separatorPosition,(((struct symbolHashNode *) (name))->contents));
      if (name == ((void *)0))
        {
         SyntaxErrorMessage(theEnv,"construct name");
         return(((void *)0));
        }
     }
   else
     {
      theModule = ((struct defmodule *) EnvGetCurrentModule(theEnv));
      if (moduleNameAllowed)
        {
         PPBackup(theEnv);
         SavePPBuffer(theEnv,EnvGetDefmoduleName(theEnv,theModule));
         SavePPBuffer(theEnv,"::");
         SavePPBuffer(theEnv,(((struct symbolHashNode *) (name))->contents));
        }
     }
   if (FindImportExportConflict(theEnv,constructName,theModule,(((struct symbolHashNode *) (name))->contents)))
     {
      ImportExportConflictMessage(theEnv,constructName,(((struct symbolHashNode *) (name))->contents),((void *)0),((void *)0));
      return(((void *)0));
     }
   if ((findFunction != ((void *)0)) && (! ((struct constructData *) (((struct environmentData *) theEnv)->theData[42]))->CheckSyntaxMode))
     {
      theConstruct = (*findFunction)(theEnv,(((struct symbolHashNode *) (name))->contents));
      if (theConstruct != ((void *)0))
        {
         redefining = 1;
         if (deleteFunction != ((void *)0))
           {
            if ((*deleteFunction)(theEnv,theConstruct) == 0)
              {
               PrintErrorID(theEnv,"CSTRCPSR",4,1);
               EnvPrintRouter(theEnv,"werror","Cannot redefine ");
               EnvPrintRouter(theEnv,"werror",constructName);
               EnvPrintRouter(theEnv,"werror"," ");
               EnvPrintRouter(theEnv,"werror",(((struct symbolHashNode *) (name))->contents));
               EnvPrintRouter(theEnv,"werror"," while it is in use.\n");
               return(((void *)0));
              }
           }
        }
     }
   if ((EnvGetWatchItem(theEnv,"compilations") == 1) &&
       GetPrintWhileLoading(theEnv) && (! ((struct constructData *) (((struct environmentData *) theEnv)->theData[42]))->CheckSyntaxMode))
     {
      if (redefining)
        {
         PrintWarningID(theEnv,"CSTRCPSR",1,1);
         EnvPrintRouter(theEnv,"wdialog","Redefining ");
        }
      else EnvPrintRouter(theEnv,"wdialog","Defining ");
      EnvPrintRouter(theEnv,"wdialog",constructName);
      EnvPrintRouter(theEnv,"wdialog",": ");
      EnvPrintRouter(theEnv,"wdialog",(((struct symbolHashNode *) (name))->contents));
      if (fullMessageCR) EnvPrintRouter(theEnv,"wdialog","\n");
      else EnvPrintRouter(theEnv,"wdialog"," ");
     }
   else
     {
      if (GetPrintWhileLoading(theEnv) && (! ((struct constructData *) (((struct environmentData *) theEnv)->theData[42]))->CheckSyntaxMode))
        { EnvPrintRouter(theEnv,"wdialog",constructSymbol); }
     }
   GetToken(theEnv,readSource,inputToken);
   if ((inputToken->type == 3) && getComment)
     {
      PPBackup(theEnv);
      SavePPBuffer(theEnv," ");
      SavePPBuffer(theEnv,inputToken->printForm);
      GetToken(theEnv,readSource,inputToken);
      if (inputToken->type != 171)
        {
         PPBackup(theEnv);
         SavePPBuffer(theEnv,"\n   ");
         SavePPBuffer(theEnv,inputToken->printForm);
        }
     }
   else if (inputToken->type != 171)
     {
      PPBackup(theEnv);
      SavePPBuffer(theEnv,"\n   ");
      SavePPBuffer(theEnv,inputToken->printForm);
     }
   return(name);
  }

variable_types:
readSource
char *

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

variable_types:
findFunction
void *(*)(void *, char *)

variable_types:
deleteFunction
int (*)(void *, void *)

variable_types:
constructSymbol
char *

variable_types: fullMessageCR int

variable_types: getComment int

variable_types: moduleNameAllowed int

variable_types: redefining int

variable_types:
theConstruct
void *

variable_types:
separatorPosition
unsigned int

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 defmodule { struct symbolHashNode *name; char *ppForm; struct defmoduleItemHeader **itemsArray; struct portItem *importList; struct portItem *exportList; unsigned int visitedFlag; long bsaveID; struct userData *usrData; struct defmodule *next; }

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

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


EnvGetDeftemplateWatch

decompiled_code:
_BOOL8 __fastcall EnvGetDeftemplateWatch(__int64 a1, __int64 a2)
{
return (*(_BYTE *)(a2 + 56) & 2) != 0;
}

original_code:
unsigned EnvGetDeftemplateWatch(
  void *theEnv,
  void *theTemplate)
  {
   return(((struct deftemplate *) theTemplate)->watch);
  }

canonical_original_code:
unsigned int EnvGetDeftemplateWatch(void *theEnv, void *theTemplate)
  {
   return(((struct deftemplate *) theTemplate)->watch);
  }

variable_types:
theEnv
void *

variable_types:
theTemplate
void *

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

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

user_defined_types: struct 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 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 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 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 multifield { unsigned int busyCount; short depth; unsigned long multifieldLength; struct multifield *next; struct field theFields[1]; }

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

user_defined_types: struct 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 field { unsigned short type; void *value; }

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

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

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

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

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

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

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

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


EnvSetDeftemplateWatch

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

result = 2 * (a2 & 1u);
*(_BYTE *)(a3 + 56) = (2 * (a2 & 1)) | *(_BYTE *)(a3 + 56) & 0xFD;
return result;
}

original_code:
void EnvSetDeftemplateWatch(
  void *theEnv,
  unsigned newState,
  void *theTemplate)
  {
   ((struct deftemplate *) theTemplate)->watch = newState;
  }

canonical_original_code:
void EnvSetDeftemplateWatch(void *theEnv, unsigned int newState, void *theTemplate)
  {
   ((struct deftemplate *) theTemplate)->watch = newState;
  }

variable_types:
newState
unsigned int

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

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

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

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


ClearDeftemplates

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

v1 = EnvAddSymbol(a1, "initial-fact");
return CreateImpliedDeftemplate(a1, v1, 0LL);
}

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

v1 = EnvAddSymbol(a1, "initial-fact");
return CreateImpliedDeftemplate(a1, v1, 0LL);
}

original_code:
static void ClearDeftemplates(
  void *theEnv)
  {
   CreateImpliedDeftemplate(theEnv,(SYMBOL_HN *) EnvAddSymbol(theEnv,"initial-fact"),0);
  }

canonical_original_code:
static void ClearDeftemplates(void *theEnv)
  {
   CreateImpliedDeftemplate(theEnv,(struct symbolHashNode *) EnvAddSymbol(theEnv,"initial-fact"),0);
  }

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


DeftemplateBasicCommands

decompiled_code:
__int64 __fastcall DeftemplateBasicCommands(__int64 a1)
{
EnvAddClearFunction(a1, "deftemplate", ClearDeftemplates, 0LL);
AddSaveFunction(a1, "deftemplate", SaveDeftemplates, 10LL);
EnvDefineFunction2(a1, "get-deftemplate-list", 109LL, GetDeftemplateListFunction, "GetDeftemplateListFunction", "01w");
EnvDefineFunction2(a1, "undeftemplate", 118LL, UndeftemplateCommand, "UndeftemplateCommand", "11w");
EnvDefineFunction2(a1, "deftemplate-module", 119LL, DeftemplateModuleFunction, "DeftemplateModuleFunction", "11w");
EnvDefineFunction2(a1, "list-deftemplates", 118LL, ListDeftemplatesCommand, "ListDeftemplatesCommand", "01w");
EnvDefineFunction2(a1, "ppdeftemplate", 118LL, PPDeftemplateCommand, "PPDeftemplateCommand", "11w");
DeftemplateBinarySetup(a1);
return DeftemplateCompilerSetup(a1);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
EnvAddClearFunction(a1, "deftemplate", ClearDeftemplates, 0LL);
AddSaveFunction(a1, "deftemplate", SaveDeftemplates, 10LL);
EnvDefineFunction2(a1, "get-deftemplate-list", 109LL, GetDeftemplateListFunction, "GetDeftemplateListFunction", "01w");
EnvDefineFunction2(a1, "undeftemplate", 118LL, UndeftemplateCommand, "UndeftemplateCommand", "11w");
EnvDefineFunction2(a1, "deftemplate-module", 119LL, DeftemplateModuleFunction, "DeftemplateModuleFunction", "11w");
EnvDefineFunction2(a1, "list-deftemplates", 118LL, ListDeftemplatesCommand, "ListDeftemplatesCommand", "01w");
EnvDefineFunction2(a1, "ppdeftemplate", 118LL, PPDeftemplateCommand, "PPDeftemplateCommand", "11w");
DeftemplateBinarySetup(a1);
return DeftemplateCompilerSetup(a1);
}

original_code:
void DeftemplateBasicCommands(
  void *theEnv)
  {
   EnvAddClearFunction(theEnv,"deftemplate",ClearDeftemplates,0);
   AddSaveFunction(theEnv,"deftemplate",SaveDeftemplates,10);
   EnvDefineFunction2(theEnv,"get-deftemplate-list",'m',(int (*)(void *)) GetDeftemplateListFunction,"GetDeftemplateListFunction","01w");
   EnvDefineFunction2(theEnv,"undeftemplate",'v',(int (*)(void *)) UndeftemplateCommand,"UndeftemplateCommand","11w");
   EnvDefineFunction2(theEnv,"deftemplate-module",'w',(int (*)(void *)) DeftemplateModuleFunction,"DeftemplateModuleFunction","11w");
   EnvDefineFunction2(theEnv,"list-deftemplates",'v', (int (*)(void *)) ListDeftemplatesCommand,"ListDeftemplatesCommand","01w");
   EnvDefineFunction2(theEnv,"ppdeftemplate",'v',(int (*)(void *)) PPDeftemplateCommand,"PPDeftemplateCommand","11w");
   DeftemplateBinarySetup(theEnv);
   DeftemplateCompilerSetup(theEnv);
  }

canonical_original_code:
void DeftemplateBasicCommands(void *theEnv)
  {
   EnvAddClearFunction(theEnv,"deftemplate",ClearDeftemplates,0);
   AddSaveFunction(theEnv,"deftemplate",SaveDeftemplates,10);
   EnvDefineFunction2(theEnv,"get-deftemplate-list",'m',(int (*)(void *)) GetDeftemplateListFunction,"GetDeftemplateListFunction","01w");
   EnvDefineFunction2(theEnv,"undeftemplate",'v',(int (*)(void *)) UndeftemplateCommand,"UndeftemplateCommand","11w");
   EnvDefineFunction2(theEnv,"deftemplate-module",'w',(int (*)(void *)) DeftemplateModuleFunction,"DeftemplateModuleFunction","11w");
   EnvDefineFunction2(theEnv,"list-deftemplates",'v', (int (*)(void *)) ListDeftemplatesCommand,"ListDeftemplatesCommand","01w");
   EnvDefineFunction2(theEnv,"ppdeftemplate",'v',(int (*)(void *)) PPDeftemplateCommand,"PPDeftemplateCommand","11w");
   DeftemplateBinarySetup(theEnv);
   DeftemplateCompilerSetup(theEnv);
  }


GetNextPortItem

decompiled_code:
__int64 __fastcall GetNextPortItem(__int64 a1, _QWORD *a2, __int64 *a3, _DWORD *a4, _DWORD *a5)
{
__int64 result; // rax

if ( *a2 || (*a2 = EnvGetNextDefmodule(a1, 0LL), *a3 = 0LL, *a4 = 0, *a5 = 0, (result = *a2) != 0) )
{
while ( 1 )
{
if ( *a3 )
{
result = *(_QWORD *)(*a3 + 24);
*a3 = result;
if ( result )
return result;
}
if ( !*a4 )
break;
if ( !*a5 )
{
*a5 = 1;
*a3 = *(_QWORD *)(*a2 + 32LL);
LABEL_7:
result = *a3;
if ( *a3 )
return result;
}
*a2 = EnvGetNextDefmodule(a1, *a2);
*a4 = 0;
*a5 = 0;
result = *a2;
if ( !*a2 )
return result;
}
*a3 = *(_QWORD *)(*a2 + 24LL);
*a4 = 1;
result = *a3;
if ( *a3 )
return result;
*a3 = *(_QWORD *)(*a2 + 32LL);
*a5 = 1;
goto LABEL_7;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, _QWORD *a2, __int64 *a3, _DWORD *a4, _DWORD *a5)
{
__int64 result; // rax

if ( *a2 || (*a2 = EnvGetNextDefmodule(a1, 0LL), *a3 = 0LL, *a4 = 0, *a5 = 0, (result = *a2) != 0) )
{
while ( 1 )
{
if ( *a3 )
{
result = *(_QWORD *)(*a3 + 24);
*a3 = result;
if ( result )
return result;
}
if ( !*a4 )
break;
if ( !*a5 )
{
*a5 = 1;
*a3 = *(_QWORD *)(*a2 + 32LL);
LABEL_7:
result = *a3;
if ( *a3 )
return result;
}
*a2 = EnvGetNextDefmodule(a1, *a2);
*a4 = 0;
*a5 = 0;
result = *a2;
if ( !*a2 )
return result;
}
*a3 = *(_QWORD *)(*a2 + 24LL);
*a4 = 1;
result = *a3;
if ( *a3 )
return result;
*a3 = *(_QWORD *)(*a2 + 32LL);
*a5 = 1;
goto LABEL_7;
}
return result;
}

original_code:
static struct portItem *GetNextPortItem(
  void *theEnv,
  struct defmodule **theDefmodule,
  struct portItem **thePortItem,
  int *importChecked,
  int *exportChecked)
  {
   if (*theDefmodule == ((void *)0))
     {
      *theDefmodule = (struct defmodule *) EnvGetNextDefmodule(theEnv,((void *)0));
      *thePortItem = ((void *)0);
      *importChecked = 0;
      *exportChecked = 0;
     }
   while (*theDefmodule != ((void *)0))
     {
      if (*thePortItem != ((void *)0)) *thePortItem = (*thePortItem)->next;
      if (*thePortItem != ((void *)0)) return(*thePortItem);
      if (! (*importChecked))
        {
         *thePortItem = (*theDefmodule)->importList;
         *importChecked = 1;
         if (*thePortItem == ((void *)0))
           {
            *thePortItem = (*theDefmodule)->exportList;
            *exportChecked = 1;
           }
        }
      else if (! (*exportChecked))
        {
         *exportChecked = 1;
         *thePortItem = (*theDefmodule)->exportList;
        }
      if (*thePortItem != ((void *)0)) return(*thePortItem);
      *theDefmodule = (struct defmodule *) EnvGetNextDefmodule(theEnv,*theDefmodule);
      *importChecked = 0;
      *exportChecked = 0;
     }
   return(((void *)0));
  }

canonical_original_code:
static struct portItem *GetNextPortItem(void *theEnv, struct defmodule **theDefmodule, struct portItem **thePortItem, int *importChecked, int *exportChecked)
  {
   if (*theDefmodule == ((void *)0))
     {
      *theDefmodule = (struct defmodule *) EnvGetNextDefmodule(theEnv,((void *)0));
      *thePortItem = ((void *)0);
      *importChecked = 0;
      *exportChecked = 0;
     }
   while (*theDefmodule != ((void *)0))
     {
      if (*thePortItem != ((void *)0)) *thePortItem = (*thePortItem)->next;
      if (*thePortItem != ((void *)0)) return(*thePortItem);
      if (! (*importChecked))
        {
         *thePortItem = (*theDefmodule)->importList;
         *importChecked = 1;
         if (*thePortItem == ((void *)0))
           {
            *thePortItem = (*theDefmodule)->exportList;
            *exportChecked = 1;
           }
        }
      else if (! (*exportChecked))
        {
         *exportChecked = 1;
         *thePortItem = (*theDefmodule)->exportList;
        }
      if (*thePortItem != ((void *)0)) return(*thePortItem);
      *theDefmodule = (struct defmodule *) EnvGetNextDefmodule(theEnv,*theDefmodule);
      *importChecked = 0;
      *exportChecked = 0;
     }
   return(((void *)0));
  }

variable_types: struct defmodule { struct symbolHashNode *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 *importList; struct portItem *exportList; unsigned int visitedFlag; long bsaveID; struct userData *usrData; struct defmodule *next; } **

variable_types:
thePortItem
struct portItem **

variable_types:
importChecked
int *

variable_types:
exportChecked
int *

return_type: struct portItem { struct symbolHashNode { struct symbolHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int neededSymbol; unsigned int bucket; char *contents; } *moduleName; struct symbolHashNode *constructType; struct symbolHashNode *constructName; struct portItem *next; } *

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


BeforeDefmodulesToCode

decompiled_code:
__int64 __fastcall BeforeDefmodulesToCode(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rsi
__int64 v3; // rbx

result = EnvGetNextDefmodule(a1, 0LL);
if ( result )
{
v2 = result;
v3 = 0LL;
do
{
*(_QWORD *)(v2 + 48) = v3;
result = EnvGetNextDefmodule(a1, v2);
v2 = result;
++v3;
}
while ( result );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rsi
__int64 v3; // rbx

result = EnvGetNextDefmodule(a1, 0LL);
if ( result )
{
v2 = result;
v3 = 0LL;
do
{
*(_QWORD *)(v2 + 48) = v3;
result = EnvGetNextDefmodule(a1, v2);
v2 = result;
++v3;
}
while ( result );
}
return result;
}

original_code:
static void BeforeDefmodulesToCode(
  void *theEnv)
  {
   int value = 0;
   struct defmodule *theModule;
   for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,((void *)0));
        theModule != ((void *)0);
        theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule))
     { theModule->bsaveID = value++; }
  }

canonical_original_code:
static void BeforeDefmodulesToCode(void *theEnv)
  {
   int value = 0;
   struct defmodule *theModule;
   for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,((void *)0));
        theModule != ((void *)0);
        theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule))
     { theModule->bsaveID = value++; }
  }

variable_types: value int

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


FindStringRouter

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

for ( i = **(_QWORD **)(*(_QWORD *)(a1 + 32) + 384LL); i; i = *(_QWORD *)(i + 32) )
{
if ( !strcmp(*(const char **)i, a2) )
break;
}
return i;
}

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

for ( i = **(_QWORD **)(*(_QWORD *)(a1 + 32) + 384LL); i; i = *(_QWORD *)(i + 32) )
{
if ( !strcmp(*(const char **)i, a2) )
break;
}
return i;
}

original_code:
static struct stringRouter *FindStringRouter(
  void *theEnv,
  char *name)
  {
   struct stringRouter *head;
   head = ((struct stringRouterData *) (((struct environmentData *) theEnv)->theData[48]))->ListOfStringRouters;
   while (head != ((void *)0))
     {
      if (strcmp(head->name,name) == 0)
        { return(head); }
      head = head->next;
     }
   return(((void *)0));
  }

canonical_original_code:
static struct stringRouter *FindStringRouter(void *theEnv, char *name)
  {
   struct stringRouter *head;
   head = ((struct stringRouterData *) (((struct environmentData *) theEnv)->theData[48]))->ListOfStringRouters;
   while (head != ((void *)0))
     {
      if (strcmp(head->name,name) == 0)
        { return(head); }
      head = head->next;
     }
   return(((void *)0));
  }

variable_types:
name
char *

variable_types: struct stringRouter { char *name; char *str; int currentPosition; unsigned int maximumPosition; int readWriteType; struct stringRouter *next; } *

user_defined_types: struct stringRouterData { struct stringRouter *ListOfStringRouters; }

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

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


UngetcString

decompiled_code:
__int64 __fastcall UngetcString(__int64 a1, __int64 a2, const char *a3)
{
__int64 v3; // rbx
__int64 result; // rax
int v5; // edx

v3 = FindStringRouter(a1, a3);
if ( !v3 )
{
SystemError(a1, "ROUTER", 2LL);
EnvExitRouter(a1, 1LL);
}
result = 0LL;
if ( !*(_DWORD *)(v3 + 24) )
{
v5 = *(_DWORD *)(v3 + 16);
result = 1LL;
if ( v5 > 0 )
*(_DWORD *)(v3 + 16) = v5 - 1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, const char *a3)
{
__int64 v3; // rbx
__int64 result; // rax
int v5; // edx

v3 = func0(a1, a3);
if ( !v3 )
{
SystemError(a1, "ROUTER", 2LL);
EnvExitRouter(a1, 1LL);
}
result = 0LL;
if ( !*(_DWORD *)(v3 + 24) )
{
v5 = *(_DWORD *)(v3 + 16);
result = 1LL;
if ( v5 > 0 )
*(_DWORD *)(v3 + 16) = v5 - 1;
}
return result;
}

original_code:
static int UngetcString(
  void *theEnv,
  int ch,
  char *logicalName)
  {
   struct stringRouter *head;
   head = FindStringRouter(theEnv,logicalName);
   if (head == ((void *)0))
     {
      SystemError(theEnv,"ROUTER",2);
      EnvExitRouter(theEnv,1);
     }
   if (head->readWriteType != 0) return(0);
   if (head->currentPosition > 0)
     { head->currentPosition--; }
   return(1);
  }

canonical_original_code:
static int UngetcString(void *theEnv, int ch, char *logicalName)
  {
   struct stringRouter *head;
   head = FindStringRouter(theEnv,logicalName);
   if (head == ((void *)0))
     {
      SystemError(theEnv,"ROUTER",2);
      EnvExitRouter(theEnv,1);
     }
   if (head->readWriteType != 0) return(0);
   if (head->currentPosition > 0)
     { head->currentPosition--; }
   return(1);
  }

variable_types: ch int

variable_types:
logicalName
char *

user_defined_types: struct stringRouter { char *name; char *str; int currentPosition; unsigned int maximumPosition; int readWriteType; struct stringRouter *next; }


GetcString

decompiled_code:
__int64 __fastcall GetcString(__int64 a1, const char *a2)
{
__int64 v2; // rbx
int v3; // eax
unsigned int v4; // edx

v2 = FindStringRouter(a1, a2);
if ( !v2 )
{
SystemError(a1, "ROUTER", 1LL);
EnvExitRouter(a1, 1LL);
}
if ( *(_DWORD *)(v2 + 24) )
return (unsigned int)-1;
v3 = *(_DWORD *)(v2 + 16);
if ( v3 >= *(_DWORD *)(v2 + 20) )
{
*(_DWORD *)(v2 + 16) = v3 + 1;
v4 = -1;
}
else
{
v4 = *(unsigned __int8 *)(*(_QWORD *)(v2 + 8) + v3);
*(_DWORD *)(v2 + 16) = v3 + 1;
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, const char *a2)
{
__int64 v2; // rbx
int v3; // eax
unsigned int v4; // edx

v2 = func0(a1, a2);
if ( !v2 )
{
SystemError(a1, "ROUTER", 1LL);
EnvExitRouter(a1, 1LL);
}
if ( *(_DWORD *)(v2 + 24) )
return (unsigned int)-1;
v3 = *(_DWORD *)(v2 + 16);
if ( v3 >= *(_DWORD *)(v2 + 20) )
{
*(_DWORD *)(v2 + 16) = v3 + 1;
v4 = -1;
}
else
{
v4 = *(unsigned __int8 *)(*(_QWORD *)(v2 + 8) + v3);
*(_DWORD *)(v2 + 16) = v3 + 1;
}
return v4;
}

original_code:
static int GetcString(
  void *theEnv,
  char *logicalName)
  {
   struct stringRouter *head;
   int rc;
   head = FindStringRouter(theEnv,logicalName);
   if (head == ((void *)0))
     {
      SystemError(theEnv,"ROUTER",1);
      EnvExitRouter(theEnv,1);
     }
   if (head->readWriteType != 0) return((-1));
   if (head->currentPosition >= (int) head->maximumPosition)
     {
      head->currentPosition++;
      return((-1));
     }
   rc = (unsigned char) head->str[head->currentPosition];
   head->currentPosition++;
   return(rc);
  }

canonical_original_code:
static int GetcString(void *theEnv, char *logicalName)
  {
   struct stringRouter *head;
   int rc;
   head = FindStringRouter(theEnv,logicalName);
   if (head == ((void *)0))
     {
      SystemError(theEnv,"ROUTER",1);
      EnvExitRouter(theEnv,1);
     }
   if (head->readWriteType != 0) return((-1));
   if (head->currentPosition >= (int) head->maximumPosition)
     {
      head->currentPosition++;
      return((-1));
     }
   rc = (unsigned char) head->str[head->currentPosition];
   head->currentPosition++;
   return(rc);
  }

variable_types: rc int


FindString

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

v2 = **(_QWORD **)(*(_QWORD *)(a1 + 32) + 384LL);
if ( !v2 )
return 0LL;
while ( strcmp(*(const char **)v2, a2) )
{
v2 = *(_QWORD *)(v2 + 32);
if ( !v2 )
return 0LL;
}
return 1LL;
}

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

v2 = **(_QWORD **)(*(_QWORD *)(a1 + 32) + 384LL);
if ( !v2 )
return 0LL;
while ( strcmp(*(const char **)v2, a2) )
{
v2 = *(_QWORD *)(v2 + 32);
if ( !v2 )
return 0LL;
}
return 1LL;
}

original_code:
static int FindString(
  void *theEnv,
  char *fileid)
  {
   struct stringRouter *head;
   head = ((struct stringRouterData *) (((struct environmentData *) theEnv)->theData[48]))->ListOfStringRouters;
   while (head != ((void *)0))
     {
      if (strcmp(head->name,fileid) == 0)
        { return(1); }
      head = head->next;
     }
   return(0);
  }

canonical_original_code:
static int FindString(void *theEnv, char *fileid)
  {
   struct stringRouter *head;
   head = ((struct stringRouterData *) (((struct environmentData *) theEnv)->theData[48]))->ListOfStringRouters;
   while (head != ((void *)0))
     {
      if (strcmp(head->name,fileid) == 0)
        { return(1); }
      head = head->next;
     }
   return(0);
  }

variable_types:
fileid
char *


PrintString

decompiled_code:
__int64 __fastcall PrintString(__int64 a1, const char *a2, const char *a3)
{
__int64 v4; // rbx
int v5; // edi
int v6; // edx

v4 = FindStringRouter(a1, a2);
if ( !v4 )
{
SystemError(a1, "ROUTER", 3LL);
EnvExitRouter(a1, 1LL);
}
if ( *(_DWORD *)(v4 + 24) == 1 )
{
v5 = *(_DWORD *)(v4 + 16);
v6 = *(_DWORD *)(v4 + 20);
if ( v5 < v6 - 1 )
{
strncpy((char *)(*(_QWORD *)(v4 + 8) + v5), a3, (unsigned int)(v6 - v5) - 1LL);
*(_DWORD *)(v4 + 16) += strlen(a3);
}
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, const char *a2, const char *a3)
{
__int64 v4; // rbx
int v5; // edi
int v6; // edx

v4 = func0(a1, a2);
if ( !v4 )
{
SystemError(a1, "ROUTER", 3LL);
EnvExitRouter(a1, 1LL);
}
if ( *(_DWORD *)(v4 + 24) == 1 )
{
v5 = *(_DWORD *)(v4 + 16);
v6 = *(_DWORD *)(v4 + 20);
if ( v5 < v6 - 1 )
{
strncpy((char *)(*(_QWORD *)(v4 + 8) + v5), a3, (unsigned int)(v6 - v5) - 1LL);
*(_DWORD *)(v4 + 16) += strlen(a3);
}
}
return 1LL;
}

original_code:
static int PrintString(
  void *theEnv,
  char *logicalName,
  char *str)
  {
   struct stringRouter *head;
   head = FindStringRouter(theEnv,logicalName);
   if (head == ((void *)0))
     {
      SystemError(theEnv,"ROUTER",3);
      EnvExitRouter(theEnv,1);
     }
   if (head->readWriteType != 1) return(1);
   if (head->currentPosition >= (int) (head->maximumPosition - 1)) return(1);
   strncpy(&head->str[head->currentPosition],
           str,(size_t) (head->maximumPosition - head->currentPosition) - 1);
   head->currentPosition += (int) strlen(str);
   return(1);
  }

canonical_original_code:
static int PrintString(void *theEnv, char *logicalName, char *str)
  {
   struct stringRouter *head;
   head = FindStringRouter(theEnv,logicalName);
   if (head == ((void *)0))
     {
      SystemError(theEnv,"ROUTER",3);
      EnvExitRouter(theEnv,1);
     }
   if (head->readWriteType != 1) return(1);
   if (head->currentPosition >= (int) (head->maximumPosition - 1)) return(1);
   strncpy(&head->str[head->currentPosition],
           str,(unsigned long) (head->maximumPosition - head->currentPosition) - 1);
   head->currentPosition += (int) strlen(str);
   return(1);
  }

variable_types:
str
char *


CreateReadStringSource

original_code:
static int CreateReadStringSource(
  void *theEnv,
  char *name,
  char *str,
  int currentPosition,
  unsigned maximumPosition)
  {
   struct stringRouter *newStringRouter;
   if (FindStringRouter(theEnv,name) != ((void *)0)) return(0);
   newStringRouter = ((((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct stringRouter)] == ((void *)0)) ? ((struct stringRouter *) genalloc(theEnv,(unsigned) sizeof(struct stringRouter))) : ((((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct stringRouter)]), ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct stringRouter)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next, ((struct stringRouter *) ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr)));
   newStringRouter->name = (char *) gm1(theEnv,(int) strlen(name) + 1);
   strcpy(newStringRouter->name,name);
   newStringRouter->str = str;
   newStringRouter->currentPosition = currentPosition;
   newStringRouter->readWriteType = 0;
   newStringRouter->maximumPosition = maximumPosition;
   newStringRouter->next = ((struct stringRouterData *) (((struct environmentData *) theEnv)->theData[48]))->ListOfStringRouters;
   ((struct stringRouterData *) (((struct environmentData *) theEnv)->theData[48]))->ListOfStringRouters = newStringRouter;
   return(1);
  }

canonical_original_code:
static int CreateReadStringSource(void *theEnv, char *name, char *str, int currentPosition, unsigned int maximumPosition)
  {
   struct stringRouter *newStringRouter;
   if (FindStringRouter(theEnv,name) != ((void *)0)) return(0);
   newStringRouter = ((((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct stringRouter)] == ((void *)0)) ? ((struct stringRouter *) genalloc(theEnv,(unsigned int) sizeof(struct stringRouter))) : ((((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct stringRouter)]), ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct stringRouter)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next, ((struct stringRouter *) ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr)));
   newStringRouter->name = (char *) gm1(theEnv,(int) strlen(name) + 1);
   strcpy(newStringRouter->name,name);
   newStringRouter->str = str;
   newStringRouter->currentPosition = currentPosition;
   newStringRouter->readWriteType = 0;
   newStringRouter->maximumPosition = maximumPosition;
   newStringRouter->next = ((struct stringRouterData *) (((struct environmentData *) theEnv)->theData[48]))->ListOfStringRouters;
   ((struct stringRouterData *) (((struct environmentData *) theEnv)->theData[48]))->ListOfStringRouters = newStringRouter;
   return(1);
  }

variable_types: currentPosition int

variable_types:
maximumPosition
unsigned int

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

user_defined_types: struct memoryPtr { struct memoryPtr *next; }


InitializeStringRouter

decompiled_code:
__int64 __fastcall InitializeStringRouter(__int64 a1)
{
AllocateEnvironmentData(a1, 48LL, 8LL, DeallocateStringRouterData);
return EnvAddRouter(a1, "string", 0LL, FindString, PrintString, GetcString, UngetcString, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
AllocateEnvironmentData(a1, 48LL, 8LL, DeallocateStringRouterData);
return EnvAddRouter(a1, "string", 0LL, FindString, PrintString, GetcString, UngetcString, 0LL);
}

original_code:
void InitializeStringRouter(
  void *theEnv)
  {
   AllocateEnvironmentData(theEnv,48,sizeof(struct stringRouterData),DeallocateStringRouterData);
   EnvAddRouter(theEnv,"string",0,FindString,PrintString,GetcString,UngetcString,((void *)0));
  }

canonical_original_code:
void InitializeStringRouter(void *theEnv)
  {
   AllocateEnvironmentData(theEnv,48,sizeof(struct stringRouterData),DeallocateStringRouterData);
   EnvAddRouter(theEnv,"string",0,FindString,PrintString,GetcString,UngetcString,((void *)0));
  }

variable_types:
theEnv
void *


OpenStringSource

decompiled_code:
__int64 __fastcall OpenStringSource(__int64 a1, const char *a2, const char *a3, int a4)
{
int v6; // er8

if ( a3 )
{
v6 = strlen(a3);
}
else
{
v6 = 0;
a4 = 0;
}
return CreateReadStringSource(a1, a2, (__int64)a3, a4, v6);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, const char *a2, const char *a3, int a4)
{
int v6; // er8

if ( a3 )
{
v6 = strlen(a3);
}
else
{
v6 = 0;
a4 = 0;
}
return func5(a1, a2, (__int64)a3, a4, v6);
}

original_code:
int OpenStringSource(
  void *theEnv,
  char *name,
  char *str,
  int currentPosition)
  {
   unsigned maximumPosition;
   if (str == ((void *)0))
     {
      currentPosition = 0;
      maximumPosition = 0;
     }
   else
     { maximumPosition = strlen(str); }
   return(CreateReadStringSource(theEnv,name,str,currentPosition,maximumPosition));
  }

canonical_original_code:
int OpenStringSource(void *theEnv, char *name, char *str, int currentPosition)
  {
   unsigned int maximumPosition;
   if (str == ((void *)0))
     {
      currentPosition = 0;
      maximumPosition = 0;
     }
   else
     { maximumPosition = strlen(str); }
   return(CreateReadStringSource(theEnv,name,str,currentPosition,maximumPosition));
  }


OpenTextSource

decompiled_code:
__int64 __fastcall OpenTextSource(__int64 a1, const char *a2, __int64 a3, int a4, int a5)
{
if ( !a3 )
a5 = 0;
if ( !a3 )
a4 = 0;
return CreateReadStringSource(a1, a2, a3, a4, a5);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, const char *a2, __int64 a3, int a4, int a5)
{
if ( !a3 )
a5 = 0;
if ( !a3 )
a4 = 0;
return func5(a1, a2, a3, a4, a5);
}

original_code:
int OpenTextSource(
  void *theEnv,
  char *name,
  char *str,
  int currentPosition,
  unsigned maximumPosition)
  {
   if (str == ((void *)0))
     {
      currentPosition = 0;
      maximumPosition = 0;
     }
   return(CreateReadStringSource(theEnv,name,str,currentPosition,maximumPosition));
  }

canonical_original_code:
int OpenTextSource(void *theEnv, char *name, char *str, int currentPosition, unsigned int maximumPosition)
  {
   if (str == ((void *)0))
     {
      currentPosition = 0;
      maximumPosition = 0;
     }
   return(CreateReadStringSource(theEnv,name,str,currentPosition,maximumPosition));
  }


CloseStringSource

original_code:
int CloseStringSource(
  void *theEnv,
  char *name)
  {
   struct stringRouter *head, *last;
   last = ((void *)0);
   head = ((struct stringRouterData *) (((struct environmentData *) theEnv)->theData[48]))->ListOfStringRouters;
   while (head != ((void *)0))
     {
      if (strcmp(head->name,name) == 0)
        {
         if (last == ((void *)0))
           {
            ((struct stringRouterData *) (((struct environmentData *) theEnv)->theData[48]))->ListOfStringRouters = head->next;
            rm(theEnv,head->name,strlen(head->name) + 1);
            (((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = (struct memoryPtr *) head, ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct stringRouter)], ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct stringRouter)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr);
            return(1);
           }
         else
           {
            last->next = head->next;
            rm(theEnv,head->name,strlen(head->name) + 1);
            (((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = (struct memoryPtr *) head, ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct stringRouter)], ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct stringRouter)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr);
            return(1);
           }
        }
      last = head;
      head = head->next;
     }
   return(0);
  }

canonical_original_code:
int CloseStringSource(void *theEnv, char *name)
  {
   struct stringRouter *head; struct stringRouter *last;
   last = ((void *)0);
   head = ((struct stringRouterData *) (((struct environmentData *) theEnv)->theData[48]))->ListOfStringRouters;
   while (head != ((void *)0))
     {
      if (strcmp(head->name,name) == 0)
        {
         if (last == ((void *)0))
           {
            ((struct stringRouterData *) (((struct environmentData *) theEnv)->theData[48]))->ListOfStringRouters = head->next;
            rm(theEnv,head->name,strlen(head->name) + 1);
            (((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = (struct memoryPtr *) head, ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct stringRouter)], ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct stringRouter)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr);
            return(1);
           }
         else
           {
            last->next = head->next;
            rm(theEnv,head->name,strlen(head->name) + 1);
            (((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = (struct memoryPtr *) head, ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct stringRouter)], ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct stringRouter)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr);
            return(1);
           }
        }
      last = head;
      head = head->next;
     }
   return(0);
  }