ParseQueryNoAction

decompiled_code:
__int64 __fastcall ParseQueryNoAction(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbp
__int16 v6[36]; // [rsp+0h] [rbp-48h] BYREF

v4 = ParseQueryRestrictions(a1, a2, a3, (__int64)v6);
if ( v4 )
{
IncrementIndentDepth(a1, 3LL);
PPCRAndIndent(a1);
if ( (unsigned int)ParseQueryTestExpression(a1, a2, a3) )
{
DecrementIndentDepth(a1, 3LL);
GetToken(a1, a3, v6);
if ( v6[0] == 171 )
{
ReplaceInstanceVariables(a1, v4, *(_QWORD *)(a2 + 16), 1u, 0);
ReturnExpression(a1, v4);
v4 = a2;
}
else
{
SyntaxErrorMessage(a1, "instance-set query function");
ReturnExpression(a1, a2);
ReturnExpression(a1, v4);
v4 = 0LL;
}
}
else
{
DecrementIndentDepth(a1, 3LL);
ReturnExpression(a1, v4);
v4 = 0LL;
}
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbp
__int16 v6[36]; // [rsp+0h] [rbp-48h] BYREF

v4 = func2(a1, a2, a3, (__int64)v6);
if ( v4 )
{
IncrementIndentDepth(a1, 3LL);
PPCRAndIndent(a1);
if ( (unsigned int)func3(a1, a2, a3) )
{
DecrementIndentDepth(a1, 3LL);
GetToken(a1, a3, v6);
if ( v6[0] == 171 )
{
func5(a1, v4, *(_QWORD *)(a2 + 16), 1u, 0);
ReturnExpression(a1, v4);
v4 = a2;
}
else
{
SyntaxErrorMessage(a1, "instance-set query function");
ReturnExpression(a1, a2);
ReturnExpression(a1, v4);
v4 = 0LL;
}
}
else
{
DecrementIndentDepth(a1, 3LL);
ReturnExpression(a1, v4);
v4 = 0LL;
}
}
return v4;
}

original_code:
EXPRESSION *ParseQueryNoAction(
  void *theEnv,
  EXPRESSION *top,
  char *readSource)
  {
   EXPRESSION *insQuerySetVars;
   struct token queryInputToken;
   insQuerySetVars = ParseQueryRestrictions(theEnv,top,readSource,&queryInputToken);
   if (insQuerySetVars == ((void *)0))
     return(((void *)0));
   IncrementIndentDepth(theEnv,3);
   PPCRAndIndent(theEnv);
   if (ParseQueryTestExpression(theEnv,top,readSource) == 0)
     {
      DecrementIndentDepth(theEnv,3);
      ReturnExpression(theEnv,insQuerySetVars);
      return(((void *)0));
     }
   DecrementIndentDepth(theEnv,3);
   GetToken(theEnv,readSource,&queryInputToken);
   if (((queryInputToken).type) != 171)
     {
      SyntaxErrorMessage(theEnv,"instance-set query function");
      ReturnExpression(theEnv,top);
      ReturnExpression(theEnv,insQuerySetVars);
      return(((void *)0));
     }
   ReplaceInstanceVariables(theEnv,insQuerySetVars,top->argList,1,0);
   ReturnExpression(theEnv,insQuerySetVars);
   return(top);
  }

canonical_original_code:
struct expr *ParseQueryNoAction(void *theEnv, struct expr *top, char *readSource)
  {
   struct expr *insQuerySetVars;
   struct token queryInputToken;
   insQuerySetVars = ParseQueryRestrictions(theEnv,top,readSource,&queryInputToken);
   if (insQuerySetVars == ((void *)0))
     return(((void *)0));
   IncrementIndentDepth(theEnv,3);
   PPCRAndIndent(theEnv);
   if (ParseQueryTestExpression(theEnv,top,readSource) == 0)
     {
      DecrementIndentDepth(theEnv,3);
      ReturnExpression(theEnv,insQuerySetVars);
      return(((void *)0));
     }
   DecrementIndentDepth(theEnv,3);
   GetToken(theEnv,readSource,&queryInputToken);
   if (((queryInputToken).type) != 171)
     {
      SyntaxErrorMessage(theEnv,"instance-set query function");
      ReturnExpression(theEnv,top);
      ReturnExpression(theEnv,insQuerySetVars);
      return(((void *)0));
     }
   ReplaceInstanceVariables(theEnv,insQuerySetVars,top->argList,1,0);
   ReturnExpression(theEnv,insQuerySetVars);
   return(top);
  }

variable_types:
top
struct expr *

variable_types:
readSource
char *

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

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


ParseQueryAction

repo: jarcec/rbclips

decompiled_code:
__int64 __fastcall ParseQueryAction(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbp
__int16 v6[36]; // [rsp+0h] [rbp-48h] BYREF

v4 = ParseQueryRestrictions(a1, a2, a3, (__int64)v6);
if ( v4 )
{
IncrementIndentDepth(a1, 3LL);
PPCRAndIndent(a1);
if ( (unsigned int)ParseQueryTestExpression(a1, a2, a3)
&& (PPCRAndIndent(a1), (unsigned int)ParseQueryActionExpression(a1, a2, a3, v4, (__int64)v6)) )
{
DecrementIndentDepth(a1, 3LL);
if ( v6[0] == 171 )
{
ReplaceInstanceVariables(a1, v4, *(_QWORD *)(a2 + 16), 1u, 0);
ReplaceInstanceVariables(a1, v4, *(_QWORD *)(*(_QWORD *)(a2 + 16) + 24LL), 0, 0);
ReturnExpression(a1, v4);
v4 = a2;
}
else
{
SyntaxErrorMessage(a1, "instance-set query function");
ReturnExpression(a1, a2);
ReturnExpression(a1, v4);
v4 = 0LL;
}
}
else
{
DecrementIndentDepth(a1, 3LL);
ReturnExpression(a1, v4);
v4 = 0LL;
}
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rbp
__int16 v6[36]; // [rsp+0h] [rbp-48h] BYREF

v4 = func2(a1, a2, a3, (__int64)v6);
if ( v4 )
{
IncrementIndentDepth(a1, 3LL);
PPCRAndIndent(a1);
if ( (unsigned int)func3(a1, a2, a3)
&& (PPCRAndIndent(a1), (unsigned int)func6(a1, a2, a3, v4, (__int64)v6)) )
{
DecrementIndentDepth(a1, 3LL);
if ( v6[0] == 171 )
{
func5(a1, v4, *(_QWORD *)(a2 + 16), 1u, 0);
func5(a1, v4, *(_QWORD *)(*(_QWORD *)(a2 + 16) + 24LL), 0, 0);
ReturnExpression(a1, v4);
v4 = a2;
}
else
{
SyntaxErrorMessage(a1, "instance-set query function");
ReturnExpression(a1, a2);
ReturnExpression(a1, v4);
v4 = 0LL;
}
}
else
{
DecrementIndentDepth(a1, 3LL);
ReturnExpression(a1, v4);
v4 = 0LL;
}
}
return v4;
}

original_code:
EXPRESSION *ParseQueryAction(
  void *theEnv,
  EXPRESSION *top,
  char *readSource)
  {
   EXPRESSION *insQuerySetVars;
   struct token queryInputToken;
   insQuerySetVars = ParseQueryRestrictions(theEnv,top,readSource,&queryInputToken);
   if (insQuerySetVars == ((void *)0))
     return(((void *)0));
   IncrementIndentDepth(theEnv,3);
   PPCRAndIndent(theEnv);
   if (ParseQueryTestExpression(theEnv,top,readSource) == 0)
     {
      DecrementIndentDepth(theEnv,3);
      ReturnExpression(theEnv,insQuerySetVars);
      return(((void *)0));
     }
   PPCRAndIndent(theEnv);
   if (ParseQueryActionExpression(theEnv,top,readSource,insQuerySetVars,&queryInputToken) == 0)
     {
      DecrementIndentDepth(theEnv,3);
      ReturnExpression(theEnv,insQuerySetVars);
      return(((void *)0));
     }
   DecrementIndentDepth(theEnv,3);
   if (((queryInputToken).type) != 171)
     {
      SyntaxErrorMessage(theEnv,"instance-set query function");
      ReturnExpression(theEnv,top);
      ReturnExpression(theEnv,insQuerySetVars);
      return(((void *)0));
     }
   ReplaceInstanceVariables(theEnv,insQuerySetVars,top->argList,1,0);
   ReplaceInstanceVariables(theEnv,insQuerySetVars,top->argList->nextArg,0,0);
   ReturnExpression(theEnv,insQuerySetVars);
   return(top);
  }

canonical_original_code:
struct expr *ParseQueryAction(void *theEnv, struct expr *top, char *readSource)
  {
   struct expr *insQuerySetVars;
   struct token queryInputToken;
   insQuerySetVars = ParseQueryRestrictions(theEnv,top,readSource,&queryInputToken);
   if (insQuerySetVars == ((void *)0))
     return(((void *)0));
   IncrementIndentDepth(theEnv,3);
   PPCRAndIndent(theEnv);
   if (ParseQueryTestExpression(theEnv,top,readSource) == 0)
     {
      DecrementIndentDepth(theEnv,3);
      ReturnExpression(theEnv,insQuerySetVars);
      return(((void *)0));
     }
   PPCRAndIndent(theEnv);
   if (ParseQueryActionExpression(theEnv,top,readSource,insQuerySetVars,&queryInputToken) == 0)
     {
      DecrementIndentDepth(theEnv,3);
      ReturnExpression(theEnv,insQuerySetVars);
      return(((void *)0));
     }
   DecrementIndentDepth(theEnv,3);
   if (((queryInputToken).type) != 171)
     {
      SyntaxErrorMessage(theEnv,"instance-set query function");
      ReturnExpression(theEnv,top);
      ReturnExpression(theEnv,insQuerySetVars);
      return(((void *)0));
     }
   ReplaceInstanceVariables(theEnv,insQuerySetVars,top->argList,1,0);
   ReplaceInstanceVariables(theEnv,insQuerySetVars,top->argList->nextArg,0,0);
   ReturnExpression(theEnv,insQuerySetVars);
   return(top);
  }

variable_types:
theEnv
void *

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

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


ReplaceClassNameWithReference

decompiled_code:
__int64 __fastcall ReplaceClassNameWithReference(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // r12
__int64 v4; // rax

result = 1LL;
if ( *(_WORD *)a2 == 2 )
{
v3 = *(_QWORD *)(*(_QWORD *)(a2 + 8) + 24LL);
v4 = LookupDefclassByMdlOrScope(a1, v3);
if ( v4 )
{
*(_WORD *)a2 = 82;
*(_QWORD *)(a2 + 8) = v4;
result = 1LL;
}
else
{
CantFindItemErrorMessage(a1, "class", v3);
result = 0LL;
}
}
return result;
}

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

result = 1LL;
if ( *(_WORD *)a2 == 2 )
{
v3 = *(_QWORD *)(*(_QWORD *)(a2 + 8) + 24LL);
v4 = LookupDefclassByMdlOrScope(a1, v3);
if ( v4 )
{
*(_WORD *)a2 = 82;
*(_QWORD *)(a2 + 8) = v4;
result = 1LL;
}
else
{
CantFindItemErrorMessage(a1, "class", v3);
result = 0LL;
}
}
return result;
}

original_code:
static int ReplaceClassNameWithReference(
  void *theEnv,
  EXPRESSION *theExp)
  {
   char *theClassName;
   void *theDefclass;
   if (theExp->type == 2)
     {
      theClassName = (((struct symbolHashNode *) (theExp->value))->contents);
      theDefclass = (void *) LookupDefclassByMdlOrScope(theEnv,theClassName);
      if (theDefclass == ((void *)0))
        {
         CantFindItemErrorMessage(theEnv,"class",theClassName);
         return(0);
        }
      theExp->type = 82;
      theExp->value = theDefclass;
     }
   return(1);
  }

canonical_original_code:
static int ReplaceClassNameWithReference(void *theEnv, struct expr *theExp)
  {
   char *theClassName;
   void *theDefclass;
   if (theExp->type == 2)
     {
      theClassName = (((struct symbolHashNode *) (theExp->value))->contents);
      theDefclass = (void *) LookupDefclassByMdlOrScope(theEnv,theClassName);
      if (theDefclass == ((void *)0))
        {
         CantFindItemErrorMessage(theEnv,"class",theClassName);
         return(0);
        }
      theExp->type = 82;
      theExp->value = theDefclass;
     }
   return(1);
  }

variable_types:
theClassName
char *

variable_types:
theDefclass
void *

return_type: int

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


DefaultOutOfMemoryFunction

decompiled_code:
__int64 __fastcall DefaultOutOfMemoryFunction(__int64 a1)
{
PrintErrorID(a1, "MEMORY", 1LL, 1LL);
EnvPrintRouter(a1, "werror", "Out of memory.\n");
EnvExitRouter(a1, 1LL);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
PrintErrorID(a1, "MEMORY", 1LL, 1LL);
EnvPrintRouter(a1, "werror", "Out of memory.\n");
EnvExitRouter(a1, 1LL);
return 1LL;
}

original_code:
int DefaultOutOfMemoryFunction(
  void *theEnv,
  unsigned long size)
  {
   PrintErrorID(theEnv,"MEMORY",1,1);
   EnvPrintRouter(theEnv,"werror","Out of memory.\n");
   EnvExitRouter(theEnv,1);
   return(1);
  }

canonical_original_code:
int DefaultOutOfMemoryFunction(void *theEnv, unsigned long size)
  {
   PrintErrorID(theEnv,"MEMORY",1,1);
   EnvPrintRouter(theEnv,"werror","Out of memory.\n");
   EnvExitRouter(theEnv,1);
   return(1);
  }

variable_types:
size
unsigned long


EnvSetOutOfMemoryFunction

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

v2 = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 472LL);
v3 = *(_QWORD *)(v2 + 24);
*(_QWORD *)(v2 + 24) = a2;
return v3;
}

original_code:
int (*EnvSetOutOfMemoryFunction(void *theEnv,int (*functionPtr)(void *,unsigned long)))(void *,unsigned long)
  {
   int (*tmpPtr)(void *,unsigned long);
   tmpPtr = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->OutOfMemoryFunction;
   ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->OutOfMemoryFunction = functionPtr;
   return(tmpPtr);
  }

canonical_original_code:
int (*EnvSetOutOfMemoryFunction(void *theEnv, int (*functionPtr)(void *, unsigned long)))(void *, unsigned long)
  {
   int (*tmpPtr)(void *, unsigned long);
   tmpPtr = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->OutOfMemoryFunction;
   ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->OutOfMemoryFunction = functionPtr;
   return(tmpPtr);
  }

variable_types:
functionPtr
int (*)(void *, unsigned long)

variable_types:
tmpPtr
int (*)(void *, unsigned long)

return_type: int (*)(void *, unsigned long)

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

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

user_defined_types: struct memoryPtr { struct memoryPtr *next; }

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


genfree

original_code:
int genfree(
  void *theEnv,
  void *waste,
  unsigned size)
  {
   free(waste);
   ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryAmount -= (long) size;
   ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryCalls--;
   return(0);
  }

canonical_original_code:
int genfree(void *theEnv, void *waste, unsigned int size)
  {
   free(waste);
   ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryAmount -= (long) size;
   ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryCalls--;
   return(0);
  }

variable_types:
waste
void *

variable_types:
size
unsigned int


genlongfree

decompiled_code:
__int64 __fastcall genlongfree(__int64 a1, void *a2, __int64 a3)
{
__int64 result; // rax

if ( a3 == (unsigned int)a3 )
result = genfree(a1, a2, a3);
else
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, void *a2, __int64 a3)
{
__int64 result; // rax

if ( a3 == (unsigned int)a3 )
result = func3(a1, a2, a3);
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int genlongfree(
  void *theEnv,
  void *ptr,
  unsigned long size)
  {
   unsigned int test;
   if (sizeof(unsigned int) == sizeof(unsigned long))
     { return(genfree(theEnv,(void *) ptr,(unsigned) size)); }
   test = (unsigned int) size;
   if (test != size) return(-1);
   return(genfree(theEnv,(void *) ptr,(unsigned) test));
  }

canonical_original_code:
int genlongfree(void *theEnv, void *ptr, unsigned long size)
  {
   unsigned int test;
   if (sizeof(unsigned int) == sizeof(unsigned long))
     { return(genfree(theEnv,(void *) ptr,(unsigned int) size)); }
   test = (unsigned int) size;
   if (test != size) return(-1);
   return(genfree(theEnv,(void *) ptr,(unsigned int) test));
  }

variable_types:
ptr
void *

variable_types:
test
unsigned int


EnvMemUsed

decompiled_code:
__int64 __fastcall EnvMemUsed(__int64 a1)
{
return **(_QWORD **)(*(_QWORD *)(a1 + 32) + 472LL);
}

original_code:
long int EnvMemUsed(
  void *theEnv)
  {
   return(((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryAmount);
  }

canonical_original_code:
long EnvMemUsed(void *theEnv)
  {
   return(((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryAmount);
  }

return_type: long


EnvMemRequests

decompiled_code:
__int64 __fastcall EnvMemRequests(__int64 a1)
{
return *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 472LL) + 8LL);
}

original_code:
long int EnvMemRequests(
  void *theEnv)
  {
   return(((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryCalls);
  }

canonical_original_code:
long EnvMemRequests(void *theEnv)
  {
   return(((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryCalls);
  }


UpdateMemoryUsed

original_code:
long int UpdateMemoryUsed(
  void *theEnv,
  long int value)
  {
   ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryAmount += value;
   return(((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryAmount);
  }

canonical_original_code:
long UpdateMemoryUsed(void *theEnv, long value)
  {
   ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryAmount += value;
   return(((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryAmount);
  }

variable_types: value long


UpdateMemoryRequests

original_code:
long int UpdateMemoryRequests(
  void *theEnv,
  long int value)
  {
   ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryCalls += value;
   return(((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryCalls);
  }

canonical_original_code:
long UpdateMemoryRequests(void *theEnv, long value)
  {
   ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryCalls += value;
   return(((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryCalls);
  }


EnvReleaseMem

decompiled_code:
__int64 __fastcall EnvReleaseMem(__int64 a1, __int64 a2, int a3)
{
__int64 v3; // r12
__int64 v4; // r13
__int64 v5; // rbx
void *v6; // rsi
_QWORD *v7; // rbp

if ( a3 == 1 )
EnvPrintRouter(a1, "wdialog", "\n*** DEALLOCATING MEMORY ***\n");
v3 = 499LL;
v4 = 0LL;
v5 = 0LL;
do
{
YieldTime(a1);
v7 = *(_QWORD **)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 472LL) + 40LL) + 8 * v3);
while ( v7 )
{
v6 = v7;
v7 = (_QWORD *)*v7;
genfree(a1, v6, v3);
v4 += v3;
++v5;
if ( v5 == 100 * (v5 / 100) )
YieldTime(a1);
}
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 472LL) + 40LL) + 8 * v3) = 0LL;
if ( a2 < v4 && a2 > 0 )
{
if ( a3 != 1 )
return v4;
goto LABEL_13;
}
--v3;
}
while ( v3 != 7 );
if ( a3 == 1 )
LABEL_13:
EnvPrintRouter(a1, "wdialog", "*** MEMORY DEALLOCATED ***\n");
return v4;
}

original_code:
long int EnvReleaseMem(
  void *theEnv,
  long int maximum,
  int printMessage)
  {
   struct memoryPtr *tmpPtr, *memPtr;
   int i;
   long int returns = 0;
   long int amount = 0;
   if (printMessage == 1)
     { EnvPrintRouter(theEnv,"wdialog","\n*** DEALLOCATING MEMORY ***\n"); }
   for (i = (500 - 1) ; i >= (int) sizeof(char *) ; i--)
     {
      YieldTime(theEnv);
      memPtr = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[i];
      while (memPtr != ((void *)0))
        {
         tmpPtr = memPtr->next;
         genfree(theEnv,(void *) memPtr,(unsigned) i);
         memPtr = tmpPtr;
         amount += i;
         returns++;
         if ((returns % 100) == 0)
           { YieldTime(theEnv); }
        }
      ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[i] = ((void *)0);
      if ((amount > maximum) && (maximum > 0))
        {
         if (printMessage == 1)
           { EnvPrintRouter(theEnv,"wdialog","*** MEMORY  DEALLOCATED ***\n"); }
         return(amount);
        }
     }
   if (printMessage == 1)
     { EnvPrintRouter(theEnv,"wdialog","*** MEMORY  DEALLOCATED ***\n"); }
   return(amount);
  }

canonical_original_code:
long EnvReleaseMem(void *theEnv, long maximum, int printMessage)
  {
   struct memoryPtr *tmpPtr; struct memoryPtr *memPtr;
   int i;
   long returns = 0;
   long amount = 0;
   if (printMessage == 1)
     { EnvPrintRouter(theEnv,"wdialog","\n*** DEALLOCATING MEMORY ***\n"); }
   for (i = (500 - 1) ; i >= (int) sizeof(char *) ; i--)
     {
      YieldTime(theEnv);
      memPtr = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[i];
      while (memPtr != ((void *)0))
        {
         tmpPtr = memPtr->next;
         genfree(theEnv,(void *) memPtr,(unsigned int) i);
         memPtr = tmpPtr;
         amount += i;
         returns++;
         if ((returns % 100) == 0)
           { YieldTime(theEnv); }
        }
      ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[i] = ((void *)0);
      if ((amount > maximum) && (maximum > 0))
        {
         if (printMessage == 1)
           { EnvPrintRouter(theEnv,"wdialog","*** MEMORY  DEALLOCATED ***\n"); }
         return(amount);
        }
     }
   if (printMessage == 1)
     { EnvPrintRouter(theEnv,"wdialog","*** MEMORY  DEALLOCATED ***\n"); }
   return(amount);
  }

variable_types: maximum long

variable_types: printMessage int

variable_types: struct memoryPtr { struct memoryPtr *next; } *

variable_types: i int

variable_types: returns long

variable_types: amount long


genalloc

decompiled_code:
void *__fastcall genalloc(__int64 a1, unsigned int a2)
{
void *i; // rbp
unsigned int v4; // eax

i = malloc(a2);
if ( !i )
{
v4 = 5 * a2;
if ( 5 * a2 < 0x1000 )
v4 = 4096;
EnvReleaseMem(a1, v4, 0);
i = malloc(a2);
if ( !i )
{
EnvReleaseMem(a1, -1LL, 1);
for ( i = malloc(a2); !i; i = malloc(a2) )
{
if ( (*(unsigned int (__fastcall **)(__int64, _QWORD))(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 472LL) + 24LL))(
a1,
a2) )
{
return i;
}
}
}
}
**(_QWORD **)(*(_QWORD *)(a1 + 32) + 472LL) += a2;
++*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 472LL) + 8LL);
return i;
}

original_code:
void *genalloc(
  void *theEnv,
  unsigned int size)
  {
   char *memPtr;
   memPtr = (char *) malloc((size_t) size);
   if (memPtr == ((void *)0))
     {
      EnvReleaseMem(theEnv,(long) ((size * 5 > 4096) ? size * 5 : 4096),0);
      memPtr = (char *) malloc((size_t) size);
      if (memPtr == ((void *)0))
        {
         EnvReleaseMem(theEnv,-1L,1);
         memPtr = (char *) malloc((size_t) size);
         while (memPtr == ((void *)0))
           {
            if ((*((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->OutOfMemoryFunction)(theEnv,(unsigned long) size))
              return(((void *)0));
            memPtr = (char *) malloc((size_t) size);
           }
        }
     }
   ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryAmount += (long) size;
   ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryCalls++;
   return((void *) memPtr);
  }

canonical_original_code:
void *genalloc(void *theEnv, unsigned int size)
  {
   char *memPtr;
   memPtr = (char *) malloc((unsigned long) size);
   if (memPtr == ((void *)0))
     {
      EnvReleaseMem(theEnv,(long) ((size * 5 > 4096) ? size * 5 : 4096),0);
      memPtr = (char *) malloc((unsigned long) size);
      if (memPtr == ((void *)0))
        {
         EnvReleaseMem(theEnv,-1L,1);
         memPtr = (char *) malloc((unsigned long) size);
         while (memPtr == ((void *)0))
           {
            if ((*((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->OutOfMemoryFunction)(theEnv,(unsigned long) size))
              return(((void *)0));
            memPtr = (char *) malloc((unsigned long) size);
           }
        }
     }
   ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryAmount += (long) size;
   ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryCalls++;
   return((void *) memPtr);
  }

variable_types:
theEnv
void *

variable_types:
memPtr
char *

return_type: void *


genlongalloc

decompiled_code:
void *__fastcall genlongalloc(__int64 a1, __int64 a2)
{
if ( a2 != (unsigned int)a2 )
{
PrintErrorID(a1, "MEMORY", 3LL, 1LL);
EnvPrintRouter(a1, "werror", "Unable to allocate memory block > 32K.\n");
EnvExitRouter(a1, 1LL);
}
return genalloc(a1, a2);
}

canonical_decompiled_code:
void *__fastcall func11(__int64 a1, __int64 a2)
{
if ( a2 != (unsigned int)a2 )
{
PrintErrorID(a1, "MEMORY", 3LL, 1LL);
EnvPrintRouter(a1, "werror", "Unable to allocate memory block > 32K.\n");
EnvExitRouter(a1, 1LL);
}
return func10(a1, a2);
}

original_code:
void *genlongalloc(
  void *theEnv,
  unsigned long size)
  {
   unsigned int test;
   if (sizeof(int) == sizeof(long))
     { return(genalloc(theEnv,(unsigned) size)); }
   test = (unsigned int) size;
   if (test != size)
     {
      PrintErrorID(theEnv,"MEMORY",3,1);
      EnvPrintRouter(theEnv,"werror","Unable to allocate memory block > 32K.\n");
      EnvExitRouter(theEnv,1);
     }
   return((void *) genalloc(theEnv,(unsigned) test));
  }

canonical_original_code:
void *genlongalloc(void *theEnv, unsigned long size)
  {
   unsigned int test;
   if (sizeof(int) == sizeof(long))
     { return(genalloc(theEnv,(unsigned int) size)); }
   test = (unsigned int) size;
   if (test != size)
     {
      PrintErrorID(theEnv,"MEMORY",3,1);
      EnvPrintRouter(theEnv,"werror","Unable to allocate memory block > 32K.\n");
      EnvExitRouter(theEnv,1);
     }
   return((void *) genalloc(theEnv,(unsigned int) test));
  }


rm

decompiled_code:
__int64 __fastcall rm(__int64 a1, _QWORD *a2, unsigned int a3)
{
if ( !a3 )
{
SystemError(a1, "MEMORY", 1LL);
EnvExitRouter(a1, 1LL);
a3 = 8;
goto LABEL_4;
}
if ( a3 <= 7 )
{
a3 = 8;
goto LABEL_4;
}
if ( a3 <= 0x1F3 )
{
LABEL_4:
*a2 = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 472LL) + 40LL) + 8LL * a3);
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 472LL) + 40LL) + 8LL * a3) = a2;
return 1LL;
}
return genfree(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, _QWORD *a2, unsigned int a3)
{
if ( !a3 )
{
SystemError(a1, "MEMORY", 1LL);
EnvExitRouter(a1, 1LL);
a3 = 8;
goto LABEL_4;
}
if ( a3 <= 7 )
{
a3 = 8;
goto LABEL_4;
}
if ( a3 <= 0x1F3 )
{
LABEL_4:
*a2 = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 472LL) + 40LL) + 8LL * a3);
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 472LL) + 40LL) + 8LL * a3) = a2;
return 1LL;
}
return func3(a1, a2, a3);
}

original_code:
int rm(
  void *theEnv,
  void *str,
  unsigned size)
  {
   struct memoryPtr *memPtr;
   if (size == 0)
     {
      SystemError(theEnv,"MEMORY",1);
      EnvExitRouter(theEnv,1);
     }
   if (size < sizeof(char *)) size = sizeof(char *);
   if (size >= 500) return(genfree(theEnv,(void *) str,(unsigned) size));
   memPtr = (struct memoryPtr *) str;
   memPtr->next = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[size];
   ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[size] = memPtr;
   return(1);
  }

canonical_original_code:
int rm(void *theEnv, void *str, unsigned int size)
  {
   struct memoryPtr *memPtr;
   if (size == 0)
     {
      SystemError(theEnv,"MEMORY",1);
      EnvExitRouter(theEnv,1);
     }
   if (size < sizeof(char *)) size = sizeof(char *);
   if (size >= 500) return(genfree(theEnv,(void *) str,(unsigned int) size));
   memPtr = (struct memoryPtr *) str;
   memPtr->next = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[size];
   ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[size] = memPtr;
   return(1);
  }

variable_types:
str
void *


decompiled_code:
__int64 __fastcall rm3(__int64 a1, _QWORD *a2, __int64 a3)
{
if ( !a3 )
{
SystemError(a1, "MEMORY", 1LL);
EnvExitRouter(a1, 1LL);
LODWORD(a3) = 8;
goto LABEL_4;
}
if ( a3 <= 7 )
{
LODWORD(a3) = 8;
goto LABEL_4;
}
if ( a3 <= 499 )
{
LABEL_4:
*a2 = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 472LL) + 40LL) + 8LL * (int)a3);
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 472LL) + 40LL) + 8LL * (int)a3) = a2;
return 1LL;
}
return genlongfree(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, _QWORD *a2, __int64 a3)
{
if ( !a3 )
{
SystemError(a1, "MEMORY", 1LL);
EnvExitRouter(a1, 1LL);
LODWORD(a3) = 8;
goto LABEL_4;
}
if ( a3 <= 7 )
{
LODWORD(a3) = 8;
goto LABEL_4;
}
if ( a3 <= 499 )
{
LABEL_4:
*a2 = *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 472LL) + 40LL) + 8LL * (int)a3);
*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 472LL) + 40LL) + 8LL * (int)a3) = a2;
return 1LL;
}
return func4(a1, a2, a3);
}

original_code:
int rm3(
  void *theEnv,
  void *str,
  long size)
  {
   struct memoryPtr *memPtr;
   if (size == 0)
     {
      SystemError(theEnv,"MEMORY",1);
      EnvExitRouter(theEnv,1);
     }
   if (size < (long) sizeof(char *)) size = sizeof(char *);
   if (size >= 500) return(genlongfree(theEnv,(void *) str,(unsigned long) size));
   memPtr = (struct memoryPtr *) str;
   memPtr->next = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[(int) size];
   ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[(int) size] = memPtr;
   return(1);
  }

canonical_original_code:
int rm3(void *theEnv, void *str, long size)
  {
   struct memoryPtr *memPtr;
   if (size == 0)
     {
      SystemError(theEnv,"MEMORY",1);
      EnvExitRouter(theEnv,1);
     }
   if (size < (long) sizeof(char *)) size = sizeof(char *);
   if (size >= 500) return(genlongfree(theEnv,(void *) str,(unsigned long) size));
   memPtr = (struct memoryPtr *) str;
   memPtr->next = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[(int) size];
   ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[(int) size] = memPtr;
   return(1);
  }

variable_types: size long


PoolSize

original_code:
unsigned long PoolSize(
  void *theEnv)
  {
   register int i;
   struct memoryPtr *memPtr;
   unsigned long cnt = 0;
   for (i = sizeof(char *) ; i < 500 ; i++)
     {
      memPtr = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[i];
      while (memPtr != ((void *)0))
        {
         cnt += (unsigned long) i;
         memPtr = memPtr->next;
        }
     }
   return(cnt);
  }

canonical_original_code:
unsigned long PoolSize(void *theEnv)
  {
   register int i;
   struct memoryPtr *memPtr;
   unsigned long cnt = 0;
   for (i = sizeof(char *) ; i < 500 ; i++)
     {
      memPtr = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[i];
      while (memPtr != ((void *)0))
        {
         cnt += (unsigned long) i;
         memPtr = memPtr->next;
        }
     }
   return(cnt);
  }

variable_types:
cnt
unsigned long

return_type: unsigned long


ActualPoolSize

decompiled_code:
__int64 __fastcall ActualPoolSize(__int64 a1)
{
return PoolSize(a1);
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1)
{
return func14(a1);
}

original_code:
unsigned long ActualPoolSize(
  void *theEnv)
  {
   return(PoolSize(theEnv));
  }

canonical_original_code:
unsigned long ActualPoolSize(void *theEnv)
  {
   return(PoolSize(theEnv));
  }


EnvSetConserveMemory

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

v2 = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 472LL);
v3 = *(_DWORD *)(v2 + 16);
*(_DWORD *)(v2 + 16) = a2;
return v3;
}

original_code:
int EnvSetConserveMemory(
  void *theEnv,
  int value)
  {
   int ov;
   ov = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->ConserveMemory;
   ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->ConserveMemory = value;
   return(ov);
  }

canonical_original_code:
int EnvSetConserveMemory(void *theEnv, int value)
  {
   int ov;
   ov = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->ConserveMemory;
   ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->ConserveMemory = value;
   return(ov);
  }

variable_types: value int

variable_types: ov int


EnvGetConserveMemory

decompiled_code:
__int64 __fastcall EnvGetConserveMemory(__int64 a1)
{
return *(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 472LL) + 16LL);
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1)
{
return *(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 472LL) + 16LL);
}

original_code:
int EnvGetConserveMemory(
  void *theEnv)
  {
   return(((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->ConserveMemory);
  }

canonical_original_code:
int EnvGetConserveMemory(void *theEnv)
  {
   return(((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->ConserveMemory);
  }


genmemcpy

original_code:
void genmemcpy(
  char *dst,
  char *src,
  unsigned long size)
  {
   unsigned long i;
   for (i = 0L ; i < size ; i++)
     dst[i] = src[i];
  }

canonical_original_code:
void genmemcpy(char *dst, char *src, unsigned long size)
  {
   unsigned long i;
   for (i = 0L ; i < size ; i++)
     dst[i] = src[i];
  }

variable_types:
dst
char *

variable_types:
src
char *

variable_types:
size
unsigned long

variable_types:
i
unsigned long

return_type: void


PrintDefglobalValueForm

decompiled_code:
__int64 __fastcall PrintDefglobalValueForm(__int64 a1, __int64 a2, __int64 a3)
{
EnvPrintRouter(a1, a2, &LC0);
EnvPrintRouter(a1, a2, *(_QWORD *)(*(_QWORD *)a3 + 24LL));
EnvPrintRouter(a1, a2, "* = ");
return PrintDataObject(a1, a2, a3 + 64);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
EnvPrintRouter(a1, a2, &LC0);
EnvPrintRouter(a1, a2, *(_QWORD *)(*(_QWORD *)a3 + 24LL));
EnvPrintRouter(a1, a2, "* = ");
return PrintDataObject(a1, a2, a3 + 64);
}

original_code:
static void PrintDefglobalValueForm(
  void *theEnv,
  char *logicalName,
  void *vTheGlobal)
  {
   struct defglobal *theGlobal = (struct defglobal *) vTheGlobal;
   EnvPrintRouter(theEnv,logicalName,"?*");
   EnvPrintRouter(theEnv,logicalName,(((struct symbolHashNode *) (theGlobal->header.name))->contents));
   EnvPrintRouter(theEnv,logicalName,"* = ");
   PrintDataObject(theEnv,logicalName,&theGlobal->current);
  }

canonical_original_code:
static void PrintDefglobalValueForm(void *theEnv, char *logicalName, void *vTheGlobal)
  {
   struct defglobal *theGlobal = (struct defglobal *) vTheGlobal;
   EnvPrintRouter(theEnv,logicalName,"?*");
   EnvPrintRouter(theEnv,logicalName,(((struct symbolHashNode *) (theGlobal->header.name))->contents));
   EnvPrintRouter(theEnv,logicalName,"* = ");
   PrintDataObject(theEnv,logicalName,&theGlobal->current);
  }

variable_types:
logicalName
char *

variable_types:
vTheGlobal
void *

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

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

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

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

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


DefglobalCommandDefinitions

decompiled_code:
__int64 __fastcall DefglobalCommandDefinitions(__int64 a1)
{
EnvDefineFunction2(a1, "set-reset-globals", 98LL, SetResetGlobalsCommand, "SetResetGlobalsCommand", "11");
EnvDefineFunction2(a1, "get-reset-globals", 98LL, GetResetGlobalsCommand, "GetResetGlobalsCommand", "00");
return EnvDefineFunction2(a1, "show-defglobals", 118LL, ShowDefglobalsCommand, "ShowDefglobalsCommand", "01w");
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
EnvDefineFunction2(a1, "set-reset-globals", 98LL, SetResetGlobalsCommand, "SetResetGlobalsCommand", "11");
EnvDefineFunction2(a1, "get-reset-globals", 98LL, GetResetGlobalsCommand, "GetResetGlobalsCommand", "00");
return EnvDefineFunction2(a1, "show-defglobals", 118LL, ShowDefglobalsCommand, "ShowDefglobalsCommand", "01w");
}

original_code:
void DefglobalCommandDefinitions(
  void *theEnv)
  {
   EnvDefineFunction2(theEnv,"set-reset-globals",'b',
                  SetResetGlobalsCommand,"SetResetGlobalsCommand", "11");
   EnvDefineFunction2(theEnv,"get-reset-globals",'b',
                   GetResetGlobalsCommand,"GetResetGlobalsCommand", "00");
   EnvDefineFunction2(theEnv,"show-defglobals",'v',
                   (int (*)(void *)) ShowDefglobalsCommand,"ShowDefglobalsCommand", "01w");
  }

canonical_original_code:
void DefglobalCommandDefinitions(void *theEnv)
  {
   EnvDefineFunction2(theEnv,"set-reset-globals",'b',
                  SetResetGlobalsCommand,"SetResetGlobalsCommand", "11");
   EnvDefineFunction2(theEnv,"get-reset-globals",'b',
                   GetResetGlobalsCommand,"GetResetGlobalsCommand", "00");
   EnvDefineFunction2(theEnv,"show-defglobals",'v',
                   (int (*)(void *)) ShowDefglobalsCommand,"ShowDefglobalsCommand", "01w");
  }


SetResetGlobalsCommand

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

v1 = EnvGetResetGlobals(a1);
if ( (unsigned int)EnvArgCountCheck(a1, "set-reset-globals", 0LL, 1LL) != -1 )
{
EnvRtnUnknown(a1, 1LL, v3);
if ( v4 == *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 392LL) + 8LL) && v3[4] == 2 )
EnvSetResetGlobals(a1, 0);
else
EnvSetResetGlobals(a1, 1);
}
return v1;
}

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

v1 = func3(a1);
if ( (unsigned int)EnvArgCountCheck(a1, "set-reset-globals", 0LL, 1LL) != -1 )
{
EnvRtnUnknown(a1, 1LL, v3);
if ( v4 == *(_QWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 392LL) + 8LL) && v3[4] == 2 )
func2(a1, 0);
else
func2(a1, 1);
}
return v1;
}

original_code:
int SetResetGlobalsCommand(
  void *theEnv)
  {
   int oldValue;
   DATA_OBJECT arg_ptr;
   oldValue = EnvGetResetGlobals(theEnv);
   if (EnvArgCountCheck(theEnv,"set-reset-globals",0,1) == -1)
     { return(oldValue); }
   EnvRtnUnknown(theEnv,1,&arg_ptr);
   if ((arg_ptr.value == ((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->FalseSymbolHN) && (arg_ptr.type == 2))
     { EnvSetResetGlobals(theEnv,0); }
   else
     { EnvSetResetGlobals(theEnv,1); }
   return(oldValue);
  }

canonical_original_code:
int SetResetGlobalsCommand(void *theEnv)
  {
   int oldValue;
   struct dataObject arg_ptr;
   oldValue = EnvGetResetGlobals(theEnv);
   if (EnvArgCountCheck(theEnv,"set-reset-globals",0,1) == -1)
     { return(oldValue); }
   EnvRtnUnknown(theEnv,1,&arg_ptr);
   if ((arg_ptr.value == ((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->FalseSymbolHN) && (arg_ptr.type == 2))
     { EnvSetResetGlobals(theEnv,0); }
   else
     { EnvSetResetGlobals(theEnv,1); }
   return(oldValue);
  }

variable_types: oldValue int

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

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

user_defined_types: struct ephemeron { struct genericHashNode *associatedValue; struct ephemeron *next; }

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

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

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

user_defined_types: struct genericHashNode { struct genericHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int needed; unsigned int bucket; }


GetResetGlobalsCommand

decompiled_code:
__int64 __fastcall GetResetGlobalsCommand(__int64 a1)
{
unsigned int v1; // ebp

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

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
unsigned int v1; // ebp

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

original_code:
int GetResetGlobalsCommand(
  void *theEnv)
  {
   int oldValue;
   oldValue = EnvGetResetGlobals(theEnv);
   if (EnvArgCountCheck(theEnv,"get-reset-globals",0,0) == -1)
     { return(oldValue); }
   return(oldValue);
  }

canonical_original_code:
int GetResetGlobalsCommand(void *theEnv)
  {
   int oldValue;
   oldValue = EnvGetResetGlobals(theEnv);
   if (EnvArgCountCheck(theEnv,"get-reset-globals",0,0) == -1)
     { return(oldValue); }
   return(oldValue);
  }


ShowDefglobalsCommand

decompiled_code:
__int64 __fastcall ShowDefglobalsCommand(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rdx
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

result = EnvArgCountCheck(a1, "show-defglobals", 2LL, 1LL);
if ( (_DWORD)result != -1 )
{
if ( (_DWORD)result == 1 )
{
result = GetModuleName(a1, "show-defglobals", 1LL, v3);
v2 = result;
if ( v3[0] )
return result;
}
else
{
v2 = EnvGetCurrentModule(a1);
}
result = EnvShowDefglobals(a1, (__int64)"wdisplay", v2);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rdx
int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

result = EnvArgCountCheck(a1, "show-defglobals", 2LL, 1LL);
if ( (_DWORD)result != -1 )
{
if ( (_DWORD)result == 1 )
{
result = GetModuleName(a1, "show-defglobals", 1LL, v3);
v2 = result;
if ( v3[0] )
return result;
}
else
{
v2 = EnvGetCurrentModule(a1);
}
result = func6(a1, (__int64)"wdisplay", v2);
}
return result;
}

original_code:
void ShowDefglobalsCommand(
  void *theEnv)
  {
   struct defmodule *theModule;
   int numArgs, error;
   if ((numArgs = EnvArgCountCheck(theEnv,"show-defglobals",2,1)) == -1) return;
   if (numArgs == 1)
     {
      theModule = GetModuleName(theEnv,"show-defglobals",1,&error);
      if (error) return;
     }
   else
     { theModule = ((struct defmodule *) EnvGetCurrentModule(theEnv)); }
   EnvShowDefglobals(theEnv,"wdisplay",theModule);
  }

canonical_original_code:
void ShowDefglobalsCommand(void *theEnv)
  {
   struct defmodule *theModule;
   int numArgs; int error;
   if ((numArgs = EnvArgCountCheck(theEnv,"show-defglobals",2,1)) == -1) return;
   if (numArgs == 1)
     {
      theModule = GetModuleName(theEnv,"show-defglobals",1,&error);
      if (error) return;
     }
   else
     { theModule = ((struct defmodule *) EnvGetCurrentModule(theEnv)); }
   EnvShowDefglobals(theEnv,"wdisplay",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; } *

variable_types: numArgs int

variable_types: error int


decompiled_code:
void PrintFactJNCompVars2()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void PrintFactJNCompVars2(
  void *theEnv,
  char *logicalName,
  void *theValue)
  {
  }

canonical_original_code:
void PrintFactJNCompVars2(void *theEnv, char *logicalName, void *theValue)
  {
  }

variable_types:
theEnv
void *

variable_types:
theValue
void *


decompiled_code:
void PrintFactPNCompVars1()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void PrintFactPNCompVars1(
  void *theEnv,
  char *logicalName,
  void *theValue)
  {
  }

canonical_original_code:
void PrintFactPNCompVars1(void *theEnv, char *logicalName, void *theValue)
  {
  }


PrintFactSlotLength

decompiled_code:
void PrintFactSlotLength()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
void PrintFactSlotLength(
  void *theEnv,
  char *logicalName,
  void *theValue)
  {
  }

canonical_original_code:
void PrintFactSlotLength(void *theEnv, char *logicalName, void *theValue)
  {
  }


decompiled_code:
void PrintFactJNGetVar1()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
void PrintFactJNGetVar1(
  void *theEnv,
  char *logicalName,
  void *theValue)
  {
  }

canonical_original_code:
void PrintFactJNGetVar1(void *theEnv, char *logicalName, void *theValue)
  {
  }


decompiled_code:
void PrintFactJNGetVar2()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code:
void PrintFactJNGetVar2(
  void *theEnv,
  char *logicalName,
  void *theValue)
  {
  }

canonical_original_code:
void PrintFactJNGetVar2(void *theEnv, char *logicalName, void *theValue)
  {
  }


decompiled_code:
void PrintFactJNGetVar3()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code:
void PrintFactJNGetVar3(
  void *theEnv,
  char *logicalName,
  void *theValue)
  {
  }

canonical_original_code:
void PrintFactJNGetVar3(void *theEnv, char *logicalName, void *theValue)
  {
  }


decompiled_code:
void PrintFactPNGetVar1()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
void PrintFactPNGetVar1(
  void *theEnv,
  char *logicalName,
  void *theValue)
  {
  }

canonical_original_code:
void PrintFactPNGetVar1(void *theEnv, char *logicalName, void *theValue)
  {
  }


decompiled_code:
void PrintFactPNGetVar2()
{
;
}

canonical_decompiled_code:
void func8()
{
;
}

original_code:
void PrintFactPNGetVar2(
  void *theEnv,
  char *logicalName,
  void *theValue)
  {
  }

canonical_original_code:
void PrintFactPNGetVar2(void *theEnv, char *logicalName, void *theValue)
  {
  }


decompiled_code:
void PrintFactPNGetVar3()
{
;
}

canonical_decompiled_code:
void func9()
{
;
}

original_code:
void PrintFactPNGetVar3(
  void *theEnv,
  char *logicalName,
  void *theValue)
  {
  }

canonical_original_code:
void PrintFactPNGetVar3(void *theEnv, char *logicalName, void *theValue)
  {
  }


decompiled_code:
void PrintFactPNConstant1()
{
;
}

canonical_decompiled_code:
void func10()
{
;
}

original_code:
void PrintFactPNConstant1(
  void *theEnv,
  char *logicalName,
  void *theValue)
  {
  }

canonical_original_code:
void PrintFactPNConstant1(void *theEnv, char *logicalName, void *theValue)
  {
  }


decompiled_code:
void PrintFactPNConstant2()
{
;
}

canonical_decompiled_code:
void func11()
{
;
}

original_code:
void PrintFactPNConstant2(
  void *theEnv,
  char *logicalName,
  void *theValue)
  {
  }

canonical_original_code:
void PrintFactPNConstant2(void *theEnv, char *logicalName, void *theValue)
  {
  }


InvalidDeftemplateSlotMessage

decompiled_code:
__int64 __fastcall InvalidDeftemplateSlotMessage(__int64 a1, __int64 a2, __int64 a3)
{
PrintErrorID(a1, "TMPLTDEF", 1LL);
EnvPrintRouter(a1, "werror", "Invalid slot ");
EnvPrintRouter(a1, "werror", a2);
EnvPrintRouter(a1, "werror", " not defined in corresponding deftemplate ");
EnvPrintRouter(a1, "werror", a3);
return EnvPrintRouter(a1, "werror", ".\n");
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
PrintErrorID(a1, "TMPLTDEF", 1LL);
EnvPrintRouter(a1, "werror", "Invalid slot ");
EnvPrintRouter(a1, "werror", a2);
EnvPrintRouter(a1, "werror", " not defined in corresponding deftemplate ");
EnvPrintRouter(a1, "werror", a3);
return EnvPrintRouter(a1, "werror", ".\n");
}

original_code:
void InvalidDeftemplateSlotMessage(
  void *theEnv,
  char *slotName,
  char *deftemplateName,
  int printCR)
  {
   PrintErrorID(theEnv,"TMPLTDEF",1,printCR);
   EnvPrintRouter(theEnv,"werror","Invalid slot ");
   EnvPrintRouter(theEnv,"werror",slotName);
   EnvPrintRouter(theEnv,"werror"," not defined in corresponding deftemplate ");
   EnvPrintRouter(theEnv,"werror",deftemplateName);
   EnvPrintRouter(theEnv,"werror",".\n");
  }

canonical_original_code:
void InvalidDeftemplateSlotMessage(void *theEnv, char *slotName, char *deftemplateName, int printCR)
  {
   PrintErrorID(theEnv,"TMPLTDEF",1,printCR);
   EnvPrintRouter(theEnv,"werror","Invalid slot ");
   EnvPrintRouter(theEnv,"werror",slotName);
   EnvPrintRouter(theEnv,"werror"," not defined in corresponding deftemplate ");
   EnvPrintRouter(theEnv,"werror",deftemplateName);
   EnvPrintRouter(theEnv,"werror",".\n");
  }

variable_types:
slotName
char *

variable_types:
deftemplateName
char *

variable_types: printCR int


SingleFieldSlotCardinalityError

decompiled_code:
__int64 __fastcall SingleFieldSlotCardinalityError(__int64 a1, __int64 a2)
{
PrintErrorID(a1, "TMPLTDEF", 2LL);
EnvPrintRouter(a1, "werror", "The single field slot ");
EnvPrintRouter(a1, "werror", a2);
return EnvPrintRouter(a1, "werror", " can only contain a single field value.\n");
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
PrintErrorID(a1, "TMPLTDEF", 2LL);
EnvPrintRouter(a1, "werror", "The single field slot ");
EnvPrintRouter(a1, "werror", a2);
return EnvPrintRouter(a1, "werror", " can only contain a single field value.\n");
}

original_code:
void SingleFieldSlotCardinalityError(
  void *theEnv,
  char *slotName)
  {
   PrintErrorID(theEnv,"TMPLTDEF",2,1);
   EnvPrintRouter(theEnv,"werror","The single field slot ");
   EnvPrintRouter(theEnv,"werror",slotName);
   EnvPrintRouter(theEnv,"werror"," can only contain a single field value.\n");
  }

canonical_original_code:
void SingleFieldSlotCardinalityError(void *theEnv, char *slotName)
  {
   PrintErrorID(theEnv,"TMPLTDEF",2,1);
   EnvPrintRouter(theEnv,"werror","The single field slot ");
   EnvPrintRouter(theEnv,"werror",slotName);
   EnvPrintRouter(theEnv,"werror"," can only contain a single field value.\n");
  }


MultiIntoSingleFieldSlotError

decompiled_code:
__int64 __fastcall MultiIntoSingleFieldSlotError(__int64 a1, __int64 a2, __int64 a3)
{
PrintErrorID(a1, "TMPLTFUN", 2LL);
EnvPrintRouter(a1, "werror", "Attempted to assert a multifield value \n");
EnvPrintRouter(a1, "werror", "into the single field slot ");
if ( a2 )
EnvPrintRouter(a1, "werror", *(_QWORD *)(*(_QWORD *)a2 + 24LL));
else
EnvPrintRouter(a1, "werror", "<<unknown>>");
EnvPrintRouter(a1, "werror", " of deftemplate ");
if ( a3 )
EnvPrintRouter(a1, "werror", *(_QWORD *)(*(_QWORD *)a3 + 24LL));
else
EnvPrintRouter(a1, "werror", "<<unknown>>");
EnvPrintRouter(a1, "werror", ".\n");
return SetEvaluationError(a1, 1LL);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, __int64 a3)
{
PrintErrorID(a1, "TMPLTFUN", 2LL);
EnvPrintRouter(a1, "werror", "Attempted to assert a multifield value \n");
EnvPrintRouter(a1, "werror", "into the single field slot ");
if ( a2 )
EnvPrintRouter(a1, "werror", *(_QWORD *)(*(_QWORD *)a2 + 24LL));
else
EnvPrintRouter(a1, "werror", "<<unknown>>");
EnvPrintRouter(a1, "werror", " of deftemplate ");
if ( a3 )
EnvPrintRouter(a1, "werror", *(_QWORD *)(*(_QWORD *)a3 + 24LL));
else
EnvPrintRouter(a1, "werror", "<<unknown>>");
EnvPrintRouter(a1, "werror", ".\n");
return SetEvaluationError(a1, 1LL);
}

original_code:
void MultiIntoSingleFieldSlotError(
  void *theEnv,
  struct templateSlot *theSlot,
  struct deftemplate *theDeftemplate)
  {
   PrintErrorID(theEnv,"TMPLTFUN",2,1);
   EnvPrintRouter(theEnv,"werror","Attempted to assert a multifield value \n");
   EnvPrintRouter(theEnv,"werror","into the single field slot ");
   if (theSlot != ((void *)0)) EnvPrintRouter(theEnv,"werror",theSlot->slotName->contents);
   else EnvPrintRouter(theEnv,"werror","<<unknown>>");
   EnvPrintRouter(theEnv,"werror"," of deftemplate ");
   if (theDeftemplate != ((void *)0)) EnvPrintRouter(theEnv,"werror",theDeftemplate->header.name->contents);
   else EnvPrintRouter(theEnv,"werror","<<unknown>>");
   EnvPrintRouter(theEnv,"werror",".\n");
   SetEvaluationError(theEnv,1);
  }

canonical_original_code:
void MultiIntoSingleFieldSlotError(void *theEnv, struct templateSlot *theSlot, struct deftemplate *theDeftemplate)
  {
   PrintErrorID(theEnv,"TMPLTFUN",2,1);
   EnvPrintRouter(theEnv,"werror","Attempted to assert a multifield value \n");
   EnvPrintRouter(theEnv,"werror","into the single field slot ");
   if (theSlot != ((void *)0)) EnvPrintRouter(theEnv,"werror",theSlot->slotName->contents);
   else EnvPrintRouter(theEnv,"werror","<<unknown>>");
   EnvPrintRouter(theEnv,"werror"," of deftemplate ");
   if (theDeftemplate != ((void *)0)) EnvPrintRouter(theEnv,"werror",theDeftemplate->header.name->contents);
   else EnvPrintRouter(theEnv,"werror","<<unknown>>");
   EnvPrintRouter(theEnv,"werror",".\n");
   SetEvaluationError(theEnv,1);
  }

variable_types: struct templateSlot { struct symbolHashNode { struct symbolHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int neededSymbol; unsigned int bucket; char *contents; } *slotName; unsigned int multislot; unsigned int noDefault; unsigned int defaultPresent; unsigned int defaultDynamic; struct constraintRecord { unsigned int anyAllowed; unsigned int symbolsAllowed; unsigned int stringsAllowed; unsigned int floatsAllowed; unsigned int integersAllowed; unsigned int instanceNamesAllowed; unsigned int instanceAddressesAllowed; unsigned int externalAddressesAllowed; unsigned int factAddressesAllowed; unsigned int voidAllowed; unsigned int anyRestriction; unsigned int symbolRestriction; unsigned int stringRestriction; unsigned int floatRestriction; unsigned int integerRestriction; unsigned int classRestriction; unsigned int instanceNameRestriction; unsigned int multifieldsAllowed; unsigned int singlefieldsAllowed; unsigned short bsaveIndex; struct expr { unsigned short type; void *value; struct expr *argList; struct expr *nextArg; } *classList; struct expr *restrictionList; struct expr *minValue; struct expr *maxValue; struct expr *minFields; struct expr *maxFields; struct constraintRecord *multifield; struct constraintRecord *next; int bucket; int count; } *constraints; struct expr *defaultList; struct templateSlot *next; } *

variable_types: struct deftemplate { 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; } header; struct templateSlot *slotList; unsigned int implied; unsigned int watch; unsigned int inScope; unsigned short numberOfSlots; long busyCount; struct factPatternNode { struct patternNodeHeader { struct partialMatch { unsigned int betaMemory; unsigned int busy; unsigned int activationf; unsigned int dependentsf; unsigned int notOriginf; unsigned int counterf; unsigned int bcount; struct partialMatch *next; struct genericMatch { union { void *theValue; struct alphaMatch { struct patternEntity { struct patternEntityRecord { struct entityRecord { char *name; unsigned int type; unsigned int copyToEvaluate; unsigned int bitMap; unsigned int addsToRuleComplexity; void (*shortPrintFunction)(void *, char *, void *); void (*longPrintFunction)(void *, char *, void *); int (*deleteFunction)(void *, void *); int (*evaluateFunction)(void *, void *, struct dataObject { void *supplementalInfo; unsigned short type; void *value; long begin; long end; struct dataObject *next; } *); void *(*getNextFunction)(void *, void *); void (*decrementBusyCount)(void *, void *); void (*incrementBusyCount)(void *, void *); void (*propagateDepth)(void *, void *); void (*markNeeded)(void *, void *); void (*install)(void *, void *); void (*deinstall)(void *, void *); struct userData *usrData; } base; void (*decrementBasisCount)(void *, void *); void (*incrementBasisCount)(void *, void *); void (*matchFunction)(void *, void *); int (*synchronized)(void *, void *); } *theInfo; void *dependents; unsigned int busyCount; long timeTag; } *matchingItem; struct multifieldMarker { int whichField; union { void *whichSlot; short whichSlotNumber; } where; long startPosition; long endPosition; struct multifieldMarker *next; } *markers; struct alphaMatch *next; } *theMatch; } gm; } binds[1]; } *alphaMemory; struct partialMatch *endOfQueue; struct joinNode { unsigned int firstJoin; unsigned int logicalJoin; unsigned int joinFromTheRight; unsigned int patternIsNegated; unsigned int initialize; unsigned int marked; unsigned int rhsType; unsigned int depth; long bsaveID; struct partialMatch *beta; struct expr *networkTest; void *rightSideEntryStructure; struct joinNode *nextLevel; struct joinNode *lastLevel; struct joinNode *rightDriveNode; struct joinNode *rightMatchNode; struct defrule { struct constructHeader header; int salience; int localVarCnt; unsigned int complexity; unsigned int afterBreakpoint; unsigned int watchActivation; unsigned int watchFiring; unsigned int autoFocus; unsigned int executing; struct expr *dynamicSalience; struct expr *actions; struct joinNode *logicalJoin; struct joinNode *lastJoin; struct defrule *disjunct; } *ruleToActivate; } *entryJoin; unsigned int singlefieldNode; unsigned int multifieldNode; unsigned int stopNode; unsigned int initialize; unsigned int marked; unsigned int beginSlot; unsigned int endSlot; } header; long bsaveID; unsigned short whichField; unsigned short whichSlot; unsigned short leaveFields; struct expr *networkTest; struct factPatternNode *nextLevel; struct factPatternNode *lastLevel; struct factPatternNode *leftNode; struct factPatternNode *rightNode; } *patternNetwork; struct fact { struct patternEntity factHeader; struct deftemplate *whichDeftemplate; void *list; long factIndex; unsigned int depth; unsigned int garbage; struct fact *previousFact; struct fact *nextFact; struct fact *previousTemplateFact; struct fact *nextTemplateFact; struct multifield { unsigned int busyCount; short depth; unsigned long multifieldLength; struct multifield *next; struct field { unsigned short type; void *value; } theFields[1]; } theProposition; } *factList; struct fact *lastFact; } *

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

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

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

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

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


CheckTemplateFact

decompiled_code:
__int64 __fastcall CheckTemplateFact(__int64 a1, __int64 *a2)
{
__int64 result; // rax
__int64 v3; // rbx
__int64 *i; // r12
__int64 v5; // rbp
char v6[32]; // [rsp+0h] [rbp-88h] BYREF
char v7[8]; // [rsp+20h] [rbp-68h] BYREF
__int16 v8; // [rsp+28h] [rbp-60h]
__int64 v9; // [rsp+30h] [rbp-58h]
__int64 v10; // [rsp+38h] [rbp-50h]
__int64 v11; // [rsp+40h] [rbp-48h]

result = EnvGetDynamicConstraintChecking();
if ( (_DWORD)result )
{
result = a2[4];
if ( result )
{
if ( (*(_BYTE *)(result + 56) & 1) == 0 )
{
v3 = *(_QWORD *)(result + 48);
if ( v3 )
{
for ( i = a2 + 16; ; i += 2 )
{
if ( (*(_BYTE *)(v3 + 8) & 1) != 0 )
{
v8 = 4;
v9 = *i;
v10 = 0LL;
v11 = *(_QWORD *)(v9 + 8) - 1LL;
}
else
{
v8 = *((_WORD *)i - 4);
v9 = *i;
}
result = ConstraintCheckDataObject(a1, v7, *(_QWORD *)(v3 + 16));
v5 = (unsigned int)result;
if ( (_DWORD)result )
break;
v3 = *(_QWORD *)(v3 + 32);
if ( !v3 )
return result;
}
sprintf(v6, "fact f-%-5ld ", a2[6]);
PrintErrorID(a1, "CSTRNCHK", 1LL);
EnvPrintRouter(a1, "werror", "Slot value ");
PrintDataObject(a1, "werror", v7);
EnvPrintRouter(a1, "werror", " ");
ConstraintViolationErrorMessage(a1, 0LL, v6, 0LL, 0LL, *(_QWORD *)v3, 0LL, v5, *(_QWORD *)(v3 + 16), 1LL);
result = SetHaltExecution(a1, 1LL);
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 *a2)
{
__int64 result; // rax
__int64 v3; // rbx
__int64 *i; // r12
__int64 v5; // rbp
char v6[32]; // [rsp+0h] [rbp-88h] BYREF
char v7[8]; // [rsp+20h] [rbp-68h] BYREF
__int16 v8; // [rsp+28h] [rbp-60h]
__int64 v9; // [rsp+30h] [rbp-58h]
__int64 v10; // [rsp+38h] [rbp-50h]
__int64 v11; // [rsp+40h] [rbp-48h]

result = EnvGetDynamicConstraintChecking();
if ( (_DWORD)result )
{
result = a2[4];
if ( result )
{
if ( (*(_BYTE *)(result + 56) & 1) == 0 )
{
v3 = *(_QWORD *)(result + 48);
if ( v3 )
{
for ( i = a2 + 16; ; i += 2 )
{
if ( (*(_BYTE *)(v3 + 8) & 1) != 0 )
{
v8 = 4;
v9 = *i;
v10 = 0LL;
v11 = *(_QWORD *)(v9 + 8) - 1LL;
}
else
{
v8 = *((_WORD *)i - 4);
v9 = *i;
}
result = ConstraintCheckDataObject(a1, v7, *(_QWORD *)(v3 + 16));
v5 = (unsigned int)result;
if ( (_DWORD)result )
break;
v3 = *(_QWORD *)(v3 + 32);
if ( !v3 )
return result;
}
sprintf(v6, "fact f-%-5ld ", a2[6]);
PrintErrorID(a1, "CSTRNCHK", 1LL);
EnvPrintRouter(a1, "werror", "Slot value ");
PrintDataObject(a1, "werror", v7);
EnvPrintRouter(a1, "werror", " ");
ConstraintViolationErrorMessage(a1, 0LL, v6, 0LL, 0LL, *(_QWORD *)v3, 0LL, v5, *(_QWORD *)(v3 + 16), 1LL);
result = SetHaltExecution(a1, 1LL);
}
}
}
}
return result;
}

original_code:
void CheckTemplateFact(
  void *theEnv,
  struct fact *theFact)
  {
   struct field *sublist;
   int i;
   struct deftemplate *theDeftemplate;
   struct templateSlot *slotPtr;
   DATA_OBJECT theData;
   char thePlace[20];
   int rv;
   if (! EnvGetDynamicConstraintChecking(theEnv)) return;
   sublist = theFact->theProposition.theFields;
   theDeftemplate = theFact->whichDeftemplate;
   if (theDeftemplate == ((void *)0)) return;
   if (theDeftemplate->implied) return;
   i = 0;
   for (slotPtr = theDeftemplate->slotList;
        slotPtr != ((void *)0);
        slotPtr = slotPtr->next)
     {
      if (slotPtr->multislot == 0)
        {
         theData.type = sublist[i].type;
         theData.value = sublist[i].value;
         i++;
        }
      else
        {
         theData.type = 4;
         theData.value = (void *) sublist[i].value;
         ((theData).begin = (long) ((1) - 1));
         ((theData).end = (long) ((((struct multifield *) sublist[i].value)->multifieldLength) - 1));
         i++;
        }
      rv = ConstraintCheckDataObject(theEnv,&theData,slotPtr->constraints);
      if (rv != 0)
        {
         sprintf(thePlace,"fact f-%-5ld ",theFact->factIndex);
         PrintErrorID(theEnv,"CSTRNCHK",1,1);
         EnvPrintRouter(theEnv,"werror","Slot value ");
         PrintDataObject(theEnv,"werror",&theData);
         EnvPrintRouter(theEnv,"werror"," ");
         ConstraintViolationErrorMessage(theEnv,((void *)0),thePlace,0,0,slotPtr->slotName,
                                         0,rv,slotPtr->constraints,1);
         SetHaltExecution(theEnv,1);
         return;
        }
     }
   return;
  }

canonical_original_code:
void CheckTemplateFact(void *theEnv, struct fact *theFact)
  {
   struct field *sublist;
   int i;
   struct deftemplate *theDeftemplate;
   struct templateSlot *slotPtr;
   struct dataObject theData;
   char thePlace[20];
   int rv;
   if (! EnvGetDynamicConstraintChecking(theEnv)) return;
   sublist = theFact->theProposition.theFields;
   theDeftemplate = theFact->whichDeftemplate;
   if (theDeftemplate == ((void *)0)) return;
   if (theDeftemplate->implied) return;
   i = 0;
   for (slotPtr = theDeftemplate->slotList;
        slotPtr != ((void *)0);
        slotPtr = slotPtr->next)
     {
      if (slotPtr->multislot == 0)
        {
         theData.type = sublist[i].type;
         theData.value = sublist[i].value;
         i++;
        }
      else
        {
         theData.type = 4;
         theData.value = (void *) sublist[i].value;
         ((theData).begin = (long) ((1) - 1));
         ((theData).end = (long) ((((struct multifield *) sublist[i].value)->multifieldLength) - 1));
         i++;
        }
      rv = ConstraintCheckDataObject(theEnv,&theData,slotPtr->constraints);
      if (rv != 0)
        {
         sprintf(thePlace,"fact f-%-5ld ",theFact->factIndex);
         PrintErrorID(theEnv,"CSTRNCHK",1,1);
         EnvPrintRouter(theEnv,"werror","Slot value ");
         PrintDataObject(theEnv,"werror",&theData);
         EnvPrintRouter(theEnv,"werror"," ");
         ConstraintViolationErrorMessage(theEnv,((void *)0),thePlace,0,0,slotPtr->slotName,
                                         0,rv,slotPtr->constraints,1);
         SetHaltExecution(theEnv,1);
         return;
        }
     }
   return;
  }

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

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

variable_types: i int

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

variable_types:
thePlace
char [20]

variable_types: rv int

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

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

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


CheckRHSSlotTypes

decompiled_code:
__int64 __fastcall CheckRHSSlotTypes(__int64 a1, __int64 a2, _QWORD *a3, __int64 a4)
{
int v6; // edx
__int64 result; // rax
__int64 v8; // rdx
const char *v9; // rsi

v6 = EnvGetStaticConstraintChecking();
result = 1LL;
if ( v6 )
{
v8 = (unsigned int)ConstraintCheckExpressionChain(a1, a2, a3[2]);
result = 1LL;
if ( (_DWORD)v8 )
{
v9 = "A literal slot value";
if ( (_DWORD)v8 == 5 )
v9 = "Literal slot values";
ConstraintViolationErrorMessage(a1, v9, a4, 1LL, 0LL, *a3, 0LL, v8, a3[2], 1LL);
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, _QWORD *a3, __int64 a4)
{
int v6; // edx
__int64 result; // rax
__int64 v8; // rdx
const char *v9; // rsi

v6 = EnvGetStaticConstraintChecking();
result = 1LL;
if ( v6 )
{
v8 = (unsigned int)ConstraintCheckExpressionChain(a1, a2, a3[2]);
result = 1LL;
if ( (_DWORD)v8 )
{
v9 = "A literal slot value";
if ( (_DWORD)v8 == 5 )
v9 = "Literal slot values";
ConstraintViolationErrorMessage(a1, v9, a4, 1LL, 0LL, *a3, 0LL, v8, a3[2], 1LL);
result = 0LL;
}
}
return result;
}

original_code:
int CheckRHSSlotTypes(
  void *theEnv,
  struct expr *rhsSlots,
  struct templateSlot *slotPtr,
  char *thePlace)
  {
   int rv;
   char *theName;
   if (EnvGetStaticConstraintChecking(theEnv) == 0) return(1);
      rv = ConstraintCheckExpressionChain(theEnv,rhsSlots,slotPtr->constraints);
      if (rv != 0)
        {
         if (rv != 5) theName = "A literal slot value";
         else theName = "Literal slot values";
         ConstraintViolationErrorMessage(theEnv,theName,thePlace,1,0,
                                         slotPtr->slotName,0,rv,slotPtr->constraints,1);
         return(0);
        }
   return(1);
  }

canonical_original_code:
int CheckRHSSlotTypes(void *theEnv, struct expr *rhsSlots, struct templateSlot *slotPtr, char *thePlace)
  {
   int rv;
   char *theName;
   if (EnvGetStaticConstraintChecking(theEnv) == 0) return(1);
      rv = ConstraintCheckExpressionChain(theEnv,rhsSlots,slotPtr->constraints);
      if (rv != 0)
        {
         if (rv != 5) theName = "A literal slot value";
         else theName = "Literal slot values";
         ConstraintViolationErrorMessage(theEnv,theName,thePlace,1,0,
                                         slotPtr->slotName,0,rv,slotPtr->constraints,1);
         return(0);
        }
   return(1);
  }

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

variable_types: struct templateSlot { struct symbolHashNode { struct symbolHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int neededSymbol; unsigned int bucket; char *contents; } *slotName; unsigned int multislot; unsigned int noDefault; unsigned int defaultPresent; unsigned int defaultDynamic; struct constraintRecord { unsigned int anyAllowed; unsigned int symbolsAllowed; unsigned int stringsAllowed; unsigned int floatsAllowed; unsigned int integersAllowed; unsigned int instanceNamesAllowed; unsigned int instanceAddressesAllowed; unsigned int externalAddressesAllowed; unsigned int factAddressesAllowed; unsigned int voidAllowed; unsigned int anyRestriction; unsigned int symbolRestriction; unsigned int stringRestriction; unsigned int floatRestriction; unsigned int integerRestriction; unsigned int classRestriction; unsigned int instanceNameRestriction; unsigned int multifieldsAllowed; unsigned int singlefieldsAllowed; unsigned short bsaveIndex; struct expr *classList; struct expr *restrictionList; struct expr *minValue; struct expr *maxValue; struct expr *minFields; struct expr *maxFields; struct constraintRecord *multifield; struct constraintRecord *next; int bucket; int count; } *constraints; struct expr *defaultList; struct templateSlot *next; } *

variable_types:
thePlace
char *

variable_types:
theName
char *

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


GetNthSlot

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

result = *(_QWORD *)(a1 + 48);
if ( result && a2 )
{
v3 = 0;
do
{
result = *(_QWORD *)(result + 32);
++v3;
}
while ( result && a2 != v3 );
}
return result;
}

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

result = *(_QWORD *)(a1 + 48);
if ( result && a2 )
{
v3 = 0;
do
{
result = *(_QWORD *)(result + 32);
++v3;
}
while ( result && a2 != v3 );
}
return result;
}

original_code:
struct templateSlot *GetNthSlot(
  struct deftemplate *theDeftemplate,
  int position)
  {
   struct templateSlot *slotPtr;
   int i = 0;
   slotPtr = theDeftemplate->slotList;
   while (slotPtr != ((void *)0))
     {
      if (i == position) return(slotPtr);
      slotPtr = slotPtr->next;
      i++;
     }
   return(((void *)0));
  }

canonical_original_code:
struct templateSlot *GetNthSlot(struct deftemplate *theDeftemplate, int position)
  {
   struct templateSlot *slotPtr;
   int i = 0;
   slotPtr = theDeftemplate->slotList;
   while (slotPtr != ((void *)0))
     {
      if (i == position) return(slotPtr);
      slotPtr = slotPtr->next;
      i++;
     }
   return(((void *)0));
  }

variable_types: position int

return_type: struct templateSlot { struct symbolHashNode { struct symbolHashNode *next; long count; int depth; unsigned int permanent; unsigned int markedEphemeral; unsigned int neededSymbol; unsigned int bucket; char *contents; } *slotName; unsigned int multislot; unsigned int noDefault; unsigned int defaultPresent; unsigned int defaultDynamic; struct constraintRecord { unsigned int anyAllowed; unsigned int symbolsAllowed; unsigned int stringsAllowed; unsigned int floatsAllowed; unsigned int integersAllowed; unsigned int instanceNamesAllowed; unsigned int instanceAddressesAllowed; unsigned int externalAddressesAllowed; unsigned int factAddressesAllowed; unsigned int voidAllowed; unsigned int anyRestriction; unsigned int symbolRestriction; unsigned int stringRestriction; unsigned int floatRestriction; unsigned int integerRestriction; unsigned int classRestriction; unsigned int instanceNameRestriction; unsigned int multifieldsAllowed; unsigned int singlefieldsAllowed; unsigned short bsaveIndex; struct expr { unsigned short type; void *value; struct expr *argList; struct expr *nextArg; } *classList; struct expr *restrictionList; struct expr *minValue; struct expr *maxValue; struct expr *minFields; struct expr *maxFields; struct constraintRecord *multifield; struct constraintRecord *next; int bucket; int count; } *constraints; struct expr *defaultList; struct templateSlot *next; } *

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 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 defrule { struct constructHeader header; int salience; int localVarCnt; unsigned int complexity; unsigned int afterBreakpoint; unsigned int watchActivation; unsigned int watchFiring; unsigned int autoFocus; unsigned int executing; struct expr *dynamicSalience; struct expr *actions; struct joinNode *logicalJoin; struct joinNode *lastJoin; struct defrule *disjunct; }

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

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


FindSlotPosition

decompiled_code:
__int64 __fastcall FindSlotPosition(__int64 a1, __int64 a2)
{
_QWORD *v2; // rax
unsigned int v3; // edx

v2 = *(_QWORD **)(a1 + 48);
if ( !v2 )
return 0;
v3 = 1;
while ( *v2 != a2 )
{
v2 = (_QWORD *)v2[4];
++v3;
if ( !v2 )
return 0;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2)
{
_QWORD *v2; // rax
unsigned int v3; // edx

v2 = *(_QWORD **)(a1 + 48);
if ( !v2 )
return 0;
v3 = 1;
while ( *v2 != a2 )
{
v2 = (_QWORD *)v2[4];
++v3;
if ( !v2 )
return 0;
}
return v3;
}

original_code:
int FindSlotPosition(
  struct deftemplate *theDeftemplate,
  SYMBOL_HN *name)
  {
   struct templateSlot *slotPtr;
   int position;
   for (slotPtr = theDeftemplate->slotList, position = 1;
        slotPtr != ((void *)0);
        slotPtr = slotPtr->next, position++)
     {
      if (slotPtr->slotName == name)
        { return(position); }
     }
   return(0);
  }

canonical_original_code:
int FindSlotPosition(struct deftemplate *theDeftemplate, struct symbolHashNode *name)
  {
   struct templateSlot *slotPtr;
   int position;
   for (slotPtr = theDeftemplate->slotList, position = 1;
        slotPtr != ((void *)0);
        slotPtr = slotPtr->next, position++)
     {
      if (slotPtr->slotName == name)
        { return(position); }
     }
   return(0);
  }

variable_types:
name
struct symbolHashNode *

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

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

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