PlaceActivation

decompiled_code:
__int64 __fastcall PlaceActivation(__int64 a1, __int64 *a2, __int64 a3)
{
__int64 v5; // rdi
__int64 result; // rax
__int64 v7; // rax
__int64 v8; // rdx

EnvSetAgendaChanged(a1, 1LL);
v5 = *a2;
if ( !*a2 )
{
LABEL_4:
*(_QWORD *)(a3 + 56) = v5;
*a2 = a3;
result = *(_QWORD *)(a3 + 56);
if ( !result )
return result;
goto LABEL_5;
}
switch ( *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 136LL) + 32LL) )
{
case 0:
v7 = PlaceDepthActivation_isra_0(v5, *(_DWORD *)(a3 + 16), *(_QWORD *)(a3 + 24));
break;
case 1:
v7 = PlaceBreadthActivation_isra_0(v5, *(_DWORD *)(a3 + 16), *(_QWORD *)(a3 + 24));
break;
case 2:
v7 = PlaceLEXActivation(a1, *a2, a3);
break;
case 3:
v7 = PlaceMEAActivation(a1, *a2, a3);
break;
case 4:
v7 = PlaceComplexityActivation(v5, a3);
break;
case 5:
v7 = PlaceSimplicityActivation(v5, a3);
break;
case 6:
v7 = PlaceRandomActivation_isra_0(v5, *(_DWORD *)(a3 + 16), *(_QWORD *)(a3 + 24), *(_DWORD *)(a3 + 40));
break;
default:
goto LABEL_4;
}
if ( !v7 )
{
v5 = *a2;
goto LABEL_4;
}
v8 = *(_QWORD *)(v7 + 56);
*(_QWORD *)(a3 + 48) = v7;
*(_QWORD *)(a3 + 56) = v8;
*(_QWORD *)(v7 + 56) = a3;
result = *(_QWORD *)(a3 + 56);
if ( result )
LABEL_5:
*(_QWORD *)(result + 48) = a3;
return result;
}

original_code:
void PlaceActivation(
  void *theEnv,
  ACTIVATION **whichAgenda,
  ACTIVATION *newActivation)
  {
   ACTIVATION *placeAfter = ((void *)0);
   EnvSetAgendaChanged(theEnv,1);
   if (*whichAgenda != ((void *)0)) switch (((struct agendaData *) (((struct environmentData *) theEnv)->theData[17]))->Strategy)
     {
      case 0:
        placeAfter = PlaceDepthActivation(*whichAgenda,newActivation);
        break;
      case 1:
        placeAfter = PlaceBreadthActivation(*whichAgenda,newActivation);
        break;
      case 2:
        placeAfter = PlaceLEXActivation(theEnv,*whichAgenda,newActivation);
        break;
      case 3:
        placeAfter = PlaceMEAActivation(theEnv,*whichAgenda,newActivation);
        break;
      case 4:
        placeAfter = PlaceComplexityActivation(*whichAgenda,newActivation);
        break;
      case 5:
        placeAfter = PlaceSimplicityActivation(*whichAgenda,newActivation);
        break;
      case 6:
        placeAfter = PlaceRandomActivation(*whichAgenda,newActivation);
        break;
     }
   if (placeAfter == ((void *)0))
     {
      newActivation->next = *whichAgenda;
      *whichAgenda = newActivation;
      if (newActivation->next != ((void *)0)) newActivation->next->prev = newActivation;
     }
   else
     {
      newActivation->next = placeAfter->next;
      newActivation->prev = placeAfter;
      placeAfter->next = newActivation;
      if (newActivation->next != ((void *)0))
        { newActivation->next->prev = newActivation; }
     }
  }

canonical_original_code:
void PlaceActivation(void *theEnv, struct activation **whichAgenda, struct activation *newActivation)
  {
   struct activation *placeAfter = ((void *)0);
   EnvSetAgendaChanged(theEnv,1);
   if (*whichAgenda != ((void *)0)) switch (((struct agendaData *) (((struct environmentData *) theEnv)->theData[17]))->Strategy)
     {
      case 0:
        placeAfter = PlaceDepthActivation(*whichAgenda,newActivation);
        break;
      case 1:
        placeAfter = PlaceBreadthActivation(*whichAgenda,newActivation);
        break;
      case 2:
        placeAfter = PlaceLEXActivation(theEnv,*whichAgenda,newActivation);
        break;
      case 3:
        placeAfter = PlaceMEAActivation(theEnv,*whichAgenda,newActivation);
        break;
      case 4:
        placeAfter = PlaceComplexityActivation(*whichAgenda,newActivation);
        break;
      case 5:
        placeAfter = PlaceSimplicityActivation(*whichAgenda,newActivation);
        break;
      case 6:
        placeAfter = PlaceRandomActivation(*whichAgenda,newActivation);
        break;
     }
   if (placeAfter == ((void *)0))
     {
      newActivation->next = *whichAgenda;
      *whichAgenda = newActivation;
      if (newActivation->next != ((void *)0)) newActivation->next->prev = newActivation;
     }
   else
     {
      newActivation->next = placeAfter->next;
      newActivation->prev = placeAfter;
      placeAfter->next = newActivation;
      if (newActivation->next != ((void *)0))
        { newActivation->next->prev = newActivation; }
     }
  }

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

user_defined_types: struct agendaData { unsigned int WatchActivations; unsigned long NumberOfActivations; unsigned long CurrentTimetag; int AgendaChanged; int SalienceEvaluation; int Strategy; }

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

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


EnvSetStrategy

repo: jarcec/rbclips

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

v2 = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 136LL);
v3 = *(_DWORD *)(v2 + 32);
*(_DWORD *)(v2 + 32) = a2;
if ( v3 != a2 )
EnvReorderAgenda(a1, 0LL);
return v3;
}

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

v2 = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 136LL);
v3 = *(_DWORD *)(v2 + 32);
*(_DWORD *)(v2 + 32) = a2;
if ( v3 != a2 )
EnvReorderAgenda(a1, 0LL);
return v3;
}

original_code:
int EnvSetStrategy(
  void *theEnv,
  int value)
  {
   int oldStrategy;
   oldStrategy = ((struct agendaData *) (((struct environmentData *) theEnv)->theData[17]))->Strategy;
   ((struct agendaData *) (((struct environmentData *) theEnv)->theData[17]))->Strategy = value;
   if (oldStrategy != ((struct agendaData *) (((struct environmentData *) theEnv)->theData[17]))->Strategy) EnvReorderAgenda(theEnv,((void *)0));
   return(oldStrategy);
  }

canonical_original_code:
int EnvSetStrategy(void *theEnv, int value)
  {
   int oldStrategy;
   oldStrategy = ((struct agendaData *) (((struct environmentData *) theEnv)->theData[17]))->Strategy;
   ((struct agendaData *) (((struct environmentData *) theEnv)->theData[17]))->Strategy = value;
   if (oldStrategy != ((struct agendaData *) (((struct environmentData *) theEnv)->theData[17]))->Strategy) EnvReorderAgenda(theEnv,((void *)0));
   return(oldStrategy);
  }

variable_types:
theEnv
void *

variable_types: value int

variable_types: oldStrategy int

return_type: int


EnvGetStrategy

decompiled_code:
__int64 __fastcall EnvGetStrategy(__int64 a1)
{
return *(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 136LL) + 32LL);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
return *(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 136LL) + 32LL);
}

original_code:
int EnvGetStrategy(
  void *theEnv)
  {
   return(((struct agendaData *) (((struct environmentData *) theEnv)->theData[17]))->Strategy);
  }

canonical_original_code:
int EnvGetStrategy(void *theEnv)
  {
   return(((struct agendaData *) (((struct environmentData *) theEnv)->theData[17]))->Strategy);
  }


GetStrategyCommand

decompiled_code:
__int64 __fastcall GetStrategyCommand(__int64 a1)
{
int v1; // eax
const char *v2; // rax

EnvArgCountCheck(a1, "get-strategy", 0LL, 0LL);
v1 = EnvGetStrategy(a1);
v2 = GetStrategyName(v1);
return EnvAddSymbol(a1, v2);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1)
{
int v1; // eax
const char *v2; // rax

EnvArgCountCheck(a1, "get-strategy", 0LL, 0LL);
v1 = func12(a1);
v2 = func2(v1);
return EnvAddSymbol(a1, v2);
}

original_code:
void *GetStrategyCommand(
  void *theEnv)
  {
   EnvArgCountCheck(theEnv,"get-strategy",0,0);
   return((SYMBOL_HN *) EnvAddSymbol(theEnv,GetStrategyName(EnvGetStrategy(theEnv))));
  }

canonical_original_code:
void *GetStrategyCommand(void *theEnv)
  {
   EnvArgCountCheck(theEnv,"get-strategy",0,0);
   return((struct symbolHashNode *) EnvAddSymbol(theEnv,GetStrategyName(EnvGetStrategy(theEnv))));
  }

return_type: void *

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


SetStrategyCommand

decompiled_code:
__int64 __fastcall SetStrategyCommand(__int64 a1)
{
int v1; // er12
const char *v2; // rax
__int64 result; // rax
int v4; // eax
const char *v5; // rax
int v6; // eax
const char *v7; // rax
__int64 v8; // [rsp+0h] [rbp-48h] BYREF
__int64 v9; // [rsp+10h] [rbp-38h]

v1 = *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 136LL) + 32LL);
if ( (unsigned int)EnvArgCountCheck(a1, "set-strategy", 0LL, 1LL) == -1 )
{
v4 = EnvGetStrategy(a1);
v5 = GetStrategyName(v4);
result = EnvAddSymbol(a1, v5);
}
else
{
if ( (unsigned int)EnvArgTypeCheck(a1, "set-strategy", 1LL, 2LL, &v8) )
{
if ( !strcmp(*(const char **)(v9 + 24), "depth") )
{
EnvSetStrategy(a1, 0);
goto LABEL_12;
}
if ( !strcmp(*(const char **)(v9 + 24), "breadth") )
{
EnvSetStrategy(a1, 1);
goto LABEL_12;
}
if ( !strcmp(*(const char **)(v9 + 24), "lex") )
{
EnvSetStrategy(a1, 2);
goto LABEL_12;
}
if ( !strcmp(*(const char **)(v9 + 24), "mea") )
{
EnvSetStrategy(a1, 3);
goto LABEL_12;
}
if ( !strcmp(*(const char **)(v9 + 24), "complexity") )
{
EnvSetStrategy(a1, 4);
goto LABEL_12;
}
if ( !strcmp(*(const char **)(v9 + 24), "simplicity") )
{
EnvSetStrategy(a1, 5);
goto LABEL_12;
}
if ( !strcmp(*(const char **)(v9 + 24), "random") )
{
EnvSetStrategy(a1, 6);
LABEL_12:
v2 = GetStrategyName(v1);
return EnvAddSymbol(a1, v2);
}
ExpectedTypeError1(
a1,
"set-strategy",
1LL,
"symbol with value depth, breadth, lex, mea, complexity, simplicity, or random");
}
v6 = EnvGetStrategy(a1);
v7 = GetStrategyName(v6);
result = EnvAddSymbol(a1, v7);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1)
{
int v1; // er12
const char *v2; // rax
__int64 result; // rax
int v4; // eax
const char *v5; // rax
int v6; // eax
const char *v7; // rax
__int64 v8; // [rsp+0h] [rbp-48h] BYREF
__int64 v9; // [rsp+10h] [rbp-38h]

v1 = *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 136LL) + 32LL);
if ( (unsigned int)EnvArgCountCheck(a1, "set-strategy", 0LL, 1LL) == -1 )
{
v4 = func12(a1);
v5 = func2(v4);
result = EnvAddSymbol(a1, v5);
}
else
{
if ( (unsigned int)EnvArgTypeCheck(a1, "set-strategy", 1LL, 2LL, &v8) )
{
if ( !strcmp(*(const char **)(v9 + 24), "depth") )
{
func11(a1, 0);
goto LABEL_12;
}
if ( !strcmp(*(const char **)(v9 + 24), "breadth") )
{
func11(a1, 1);
goto LABEL_12;
}
if ( !strcmp(*(const char **)(v9 + 24), "lex") )
{
func11(a1, 2);
goto LABEL_12;
}
if ( !strcmp(*(const char **)(v9 + 24), "mea") )
{
func11(a1, 3);
goto LABEL_12;
}
if ( !strcmp(*(const char **)(v9 + 24), "complexity") )
{
func11(a1, 4);
goto LABEL_12;
}
if ( !strcmp(*(const char **)(v9 + 24), "simplicity") )
{
func11(a1, 5);
goto LABEL_12;
}
if ( !strcmp(*(const char **)(v9 + 24), "random") )
{
func11(a1, 6);
LABEL_12:
v2 = func2(v1);
return EnvAddSymbol(a1, v2);
}
ExpectedTypeError1(
a1,
"set-strategy",
1LL,
"symbol with value depth, breadth, lex, mea, complexity, simplicity, or random");
}
v6 = func12(a1);
v7 = func2(v6);
result = EnvAddSymbol(a1, v7);
}
return result;
}

original_code:
void *SetStrategyCommand(
  void *theEnv)
  {
   DATA_OBJECT argPtr;
   char *argument;
   int oldStrategy;
   oldStrategy = ((struct agendaData *) (((struct environmentData *) theEnv)->theData[17]))->Strategy;
   if (EnvArgCountCheck(theEnv,"set-strategy",0,1) == -1)
     { return((SYMBOL_HN *) EnvAddSymbol(theEnv,GetStrategyName(EnvGetStrategy(theEnv)))); }
   if (EnvArgTypeCheck(theEnv,"set-strategy",1,2,&argPtr) == 0)
     { return((SYMBOL_HN *) EnvAddSymbol(theEnv,GetStrategyName(EnvGetStrategy(theEnv)))); }
   argument = (((struct symbolHashNode *) (argPtr.value))->contents);
   if (strcmp(argument,"depth") == 0)
     { EnvSetStrategy(theEnv,0); }
   else if (strcmp(argument,"breadth") == 0)
     { EnvSetStrategy(theEnv,1); }
   else if (strcmp(argument,"lex") == 0)
     { EnvSetStrategy(theEnv,2); }
   else if (strcmp(argument,"mea") == 0)
     { EnvSetStrategy(theEnv,3); }
   else if (strcmp(argument,"complexity") == 0)
     { EnvSetStrategy(theEnv,4); }
   else if (strcmp(argument,"simplicity") == 0)
     { EnvSetStrategy(theEnv,5); }
   else if (strcmp(argument,"random") == 0)
     { EnvSetStrategy(theEnv,6); }
   else
     {
      ExpectedTypeError1(theEnv,"set-strategy",1,
      "symbol with value depth, breadth, lex, mea, complexity, simplicity, or random");
      return((SYMBOL_HN *) EnvAddSymbol(theEnv,GetStrategyName(EnvGetStrategy(theEnv))));
     }
   return((SYMBOL_HN *) EnvAddSymbol(theEnv,GetStrategyName(oldStrategy)));
  }

canonical_original_code:
void *SetStrategyCommand(void *theEnv)
  {
   struct dataObject argPtr;
   char *argument;
   int oldStrategy;
   oldStrategy = ((struct agendaData *) (((struct environmentData *) theEnv)->theData[17]))->Strategy;
   if (EnvArgCountCheck(theEnv,"set-strategy",0,1) == -1)
     { return((struct symbolHashNode *) EnvAddSymbol(theEnv,GetStrategyName(EnvGetStrategy(theEnv)))); }
   if (EnvArgTypeCheck(theEnv,"set-strategy",1,2,&argPtr) == 0)
     { return((struct symbolHashNode *) EnvAddSymbol(theEnv,GetStrategyName(EnvGetStrategy(theEnv)))); }
   argument = (((struct symbolHashNode *) (argPtr.value))->contents);
   if (strcmp(argument,"depth") == 0)
     { EnvSetStrategy(theEnv,0); }
   else if (strcmp(argument,"breadth") == 0)
     { EnvSetStrategy(theEnv,1); }
   else if (strcmp(argument,"lex") == 0)
     { EnvSetStrategy(theEnv,2); }
   else if (strcmp(argument,"mea") == 0)
     { EnvSetStrategy(theEnv,3); }
   else if (strcmp(argument,"complexity") == 0)
     { EnvSetStrategy(theEnv,4); }
   else if (strcmp(argument,"simplicity") == 0)
     { EnvSetStrategy(theEnv,5); }
   else if (strcmp(argument,"random") == 0)
     { EnvSetStrategy(theEnv,6); }
   else
     {
      ExpectedTypeError1(theEnv,"set-strategy",1,
      "symbol with value depth, breadth, lex, mea, complexity, simplicity, or random");
      return((struct symbolHashNode *) EnvAddSymbol(theEnv,GetStrategyName(EnvGetStrategy(theEnv))));
     }
   return((struct symbolHashNode *) EnvAddSymbol(theEnv,GetStrategyName(oldStrategy)));
  }

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

variable_types:
argument
char *


FindModuleSeparator

decompiled_code:
__int64 __fastcall FindModuleSeparator(char *a1)
{
char v1; // dl
int v2; // ecx
__int64 result; // rax

v1 = *a1;
if ( !*a1 )
return 0LL;
v2 = 0;
result = 0LL;
while ( 1 )
{
while ( v1 != 58 )
{
v2 = 0;
result = (unsigned int)(result + 1);
v1 = a1[result];
if ( !v1 )
return 0LL;
}
if ( v2 )
break;
v2 = 1;
result = (unsigned int)(result + 1);
v1 = a1[result];
if ( !v1 )
return 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *a1)
{
char v1; // dl
int v2; // ecx
__int64 result; // rax

v1 = *a1;
if ( !*a1 )
return 0LL;
v2 = 0;
result = 0LL;
while ( 1 )
{
while ( v1 != 58 )
{
v2 = 0;
result = (unsigned int)(result + 1);
v1 = a1[result];
if ( !v1 )
return 0LL;
}
if ( v2 )
break;
v2 = 1;
result = (unsigned int)(result + 1);
v1 = a1[result];
if ( !v1 )
return 0LL;
}
return result;
}

original_code:
unsigned FindModuleSeparator(
  char *theString)
  {
   unsigned i, foundColon;
   for (i = 0, foundColon = 0; theString[i] != '\0'; i++)
     {
      if (theString[i] == ':')
        {
         if (foundColon) return(i);
         foundColon = 1;
        }
      else
        { foundColon = 0; }
     }
   return(0);
  }

canonical_original_code:
unsigned int FindModuleSeparator(char *theString)
  {
   unsigned int i; unsigned int foundColon;
   for (i = 0, foundColon = 0; theString[i] != '\0'; i++)
     {
      if (theString[i] == ':')
        {
         if (foundColon) return(i);
         foundColon = 1;
        }
      else
        { foundColon = 0; }
     }
   return(0);
  }

variable_types:
theString
char *

variable_types:
i
unsigned int

variable_types:
foundColon
unsigned int

return_type: unsigned int


ExtractModuleName

decompiled_code:
__int64 __fastcall ExtractModuleName(__int64 a1, unsigned int a2, const char *a3)
{
__int64 v3; // r14
char *v5; // rbp

v3 = 0LL;
if ( a2 > 1 )
{
v5 = (char *)gm2();
strncpy(v5, a3, a2 - 1LL);
v5[a2 - 1] = 0;
v3 = EnvAddSymbol(a1, v5);
rm(a1, v5, a2);
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned int a2, const char *a3)
{
__int64 v3; // r14
char *v5; // rbp

v3 = 0LL;
if ( a2 > 1 )
{
v5 = (char *)gm2();
strncpy(v5, a3, a2 - 1LL);
v5[a2 - 1] = 0;
v3 = EnvAddSymbol(a1, v5);
rm(a1, v5, a2);
}
return v3;
}

original_code:
SYMBOL_HN *ExtractModuleName(
  void *theEnv,
  unsigned thePosition,
  char *theString)
  {
   char *newString;
   SYMBOL_HN *returnValue;
   if (thePosition <= 1) return(((void *)0));
   newString = (char *) gm2(theEnv,thePosition);
   strncpy(newString,theString,
           (size_t) thePosition - 1);
   newString[thePosition-1] = '\0';
   returnValue = (SYMBOL_HN *) EnvAddSymbol(theEnv,newString);
   rm(theEnv,newString,thePosition);
   return(returnValue);
  }

canonical_original_code:
struct symbolHashNode *ExtractModuleName(void *theEnv, unsigned int thePosition, char *theString)
  {
   char *newString;
   struct symbolHashNode *returnValue;
   if (thePosition <= 1) return(((void *)0));
   newString = (char *) gm2(theEnv,thePosition);
   strncpy(newString,theString,
           (unsigned long) thePosition - 1);
   newString[thePosition-1] = '\0';
   returnValue = (struct symbolHashNode *) EnvAddSymbol(theEnv,newString);
   rm(theEnv,newString,thePosition);
   return(returnValue);
  }

variable_types:
thePosition
unsigned int

variable_types:
newString
char *

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


ExtractConstructName

decompiled_code:
__int64 __fastcall ExtractConstructName(__int64 a1, unsigned int a2, const char *a3)
{
__int64 v4; // r15
size_t v5; // rax
size_t v6; // r12
char *v7; // r14
unsigned int v9; // [rsp+Ch] [rbp-3Ch]

if ( !a2 )
return EnvAddSymbol(a1, a3);
v4 = 0LL;
v5 = strlen(a3);
v6 = v5;
if ( a2 + 1 < v5 )
{
v9 = v5 - a2;
v7 = (char *)gm2(a1, (unsigned int)v5 - a2);
strncpy(v7, &a3[a2 + 1], v6 - a2);
v4 = EnvAddSymbol(a1, v7);
rm(a1, v7, v9);
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned int a2, const char *a3)
{
__int64 v4; // r15
size_t v5; // rax
size_t v6; // r12
char *v7; // r14
unsigned int v9; // [rsp+Ch] [rbp-3Ch]

if ( !a2 )
return EnvAddSymbol(a1, a3);
v4 = 0LL;
v5 = strlen(a3);
v6 = v5;
if ( a2 + 1 < v5 )
{
v9 = v5 - a2;
v7 = (char *)gm2(a1, (unsigned int)v5 - a2);
strncpy(v7, &a3[a2 + 1], v6 - a2);
v4 = EnvAddSymbol(a1, v7);
rm(a1, v7, v9);
}
return v4;
}

original_code:
SYMBOL_HN *ExtractConstructName(
  void *theEnv,
  unsigned thePosition,
  char *theString)
  {
   size_t theLength;
   char *newString;
   SYMBOL_HN *returnValue;
   if (thePosition == 0) return((SYMBOL_HN *) EnvAddSymbol(theEnv,theString));
   theLength = strlen(theString);
   if (theLength <= (thePosition + 1)) return(((void *)0));
   newString = (char *) gm2(theEnv,theLength - thePosition);
   strncpy(newString,&theString[thePosition+1],
           (size_t) theLength - thePosition);
   returnValue = (SYMBOL_HN *) EnvAddSymbol(theEnv,newString);
   rm(theEnv,newString,theLength - thePosition);
   return(returnValue);
  }

canonical_original_code:
struct symbolHashNode *ExtractConstructName(void *theEnv, unsigned int thePosition, char *theString)
  {
   unsigned long theLength;
   char *newString;
   struct symbolHashNode *returnValue;
   if (thePosition == 0) return((struct symbolHashNode *) EnvAddSymbol(theEnv,theString));
   theLength = strlen(theString);
   if (theLength <= (thePosition + 1)) return(((void *)0));
   newString = (char *) gm2(theEnv,theLength - thePosition);
   strncpy(newString,&theString[thePosition+1],
           (unsigned long) theLength - thePosition);
   returnValue = (struct symbolHashNode *) EnvAddSymbol(theEnv,newString);
   rm(theEnv,newString,theLength - thePosition);
   return(returnValue);
  }

variable_types:
theLength
unsigned long

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


ExtractModuleAndConstructName

decompiled_code:
char *__fastcall ExtractModuleAndConstructName(__int64 a1, char *a2)
{
unsigned int v3; // eax
unsigned int v5; // ebp
__int64 v6; // rax
__int64 v7; // rdx
__int64 v8; // rsi

v3 = FindModuleSeparator(a2);
if ( !v3 )
return a2;
v5 = v3;
v6 = ExtractModuleName(a1, v3, a2);
if ( !v6 )
return 0LL;
v8 = EnvFindDefmodule(a1, *(_QWORD *)(v6 + 24));
if ( !v8 )
return 0LL;
EnvSetCurrentModule(a1, v8, v7);
return *(char **)(ExtractConstructName(a1, v5, a2) + 24);
}

canonical_decompiled_code:
char *__fastcall func4(__int64 a1, char *a2)
{
unsigned int v3; // eax
unsigned int v5; // ebp
__int64 v6; // rax
__int64 v7; // rdx
__int64 v8; // rsi

v3 = func1(a2);
if ( !v3 )
return a2;
v5 = v3;
v6 = func2(a1, v3, a2);
if ( !v6 )
return 0LL;
v8 = EnvFindDefmodule(a1, *(_QWORD *)(v6 + 24));
if ( !v8 )
return 0LL;
EnvSetCurrentModule(a1, v8, v7);
return *(char **)(func3(a1, v5, a2) + 24);
}

original_code:
char *ExtractModuleAndConstructName(
  void *theEnv,
  char *theName)
  {
   unsigned separatorPosition;
   SYMBOL_HN *moduleName, *shortName;
   struct defmodule *theModule;
   separatorPosition = FindModuleSeparator(theName);
   if (! separatorPosition) return(theName);
   moduleName = ExtractModuleName(theEnv,separatorPosition,theName);
   if (moduleName == ((void *)0)) return(((void *)0));
   theModule = (struct defmodule *) EnvFindDefmodule(theEnv,(((struct symbolHashNode *) (moduleName))->contents));
   if (theModule == ((void *)0)) return(((void *)0));
   EnvSetCurrentModule(theEnv,(void *) theModule);
   shortName = ExtractConstructName(theEnv,separatorPosition,theName);
   return((((struct symbolHashNode *) (shortName))->contents));
  }

canonical_original_code:
char *ExtractModuleAndConstructName(void *theEnv, char *theName)
  {
   unsigned int separatorPosition;
   struct symbolHashNode *moduleName; struct symbolHashNode *shortName;
   struct defmodule *theModule;
   separatorPosition = FindModuleSeparator(theName);
   if (! separatorPosition) return(theName);
   moduleName = ExtractModuleName(theEnv,separatorPosition,theName);
   if (moduleName == ((void *)0)) return(((void *)0));
   theModule = (struct defmodule *) EnvFindDefmodule(theEnv,(((struct symbolHashNode *) (moduleName))->contents));
   if (theModule == ((void *)0)) return(((void *)0));
   EnvSetCurrentModule(theEnv,(void *) theModule);
   shortName = ExtractConstructName(theEnv,separatorPosition,theName);
   return((((struct symbolHashNode *) (shortName))->contents));
  }

variable_types:
theName
char *

variable_types:
separatorPosition
unsigned int

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

return_type: char *

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

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

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


AmbiguousReferenceErrorMessage

decompiled_code:
__int64 __fastcall AmbiguousReferenceErrorMessage(__int64 a1, __int64 a2, __int64 a3)
{
EnvPrintRouter(a1, "werror", "Ambiguous reference to ");
EnvPrintRouter(a1, "werror", a2);
EnvPrintRouter(a1, "werror", " ");
EnvPrintRouter(a1, "werror", a3);
return EnvPrintRouter(a1, "werror", ".\nIt is imported from more than one module.\n");
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2, __int64 a3)
{
EnvPrintRouter(a1, "werror", "Ambiguous reference to ");
EnvPrintRouter(a1, "werror", a2);
EnvPrintRouter(a1, "werror", " ");
EnvPrintRouter(a1, "werror", a3);
return EnvPrintRouter(a1, "werror", ".\nIt is imported from more than one module.\n");
}

original_code:
void AmbiguousReferenceErrorMessage(
  void *theEnv,
  char *constructName,
  char *findName)
  {
   EnvPrintRouter(theEnv,"werror","Ambiguous reference to ");
   EnvPrintRouter(theEnv,"werror",constructName);
   EnvPrintRouter(theEnv,"werror"," ");
   EnvPrintRouter(theEnv,"werror",findName);
   EnvPrintRouter(theEnv,"werror",".\nIt is imported from more than one module.\n");
  }

canonical_original_code:
void AmbiguousReferenceErrorMessage(void *theEnv, char *constructName, char *findName)
  {
   EnvPrintRouter(theEnv,"werror","Ambiguous reference to ");
   EnvPrintRouter(theEnv,"werror",constructName);
   EnvPrintRouter(theEnv,"werror"," ");
   EnvPrintRouter(theEnv,"werror",findName);
   EnvPrintRouter(theEnv,"werror",".\nIt is imported from more than one module.\n");
  }

variable_types:
constructName
char *

variable_types:
findName
char *

return_type: void


ListItemsDriver

original_code:
void ListItemsDriver(
  void *theEnv,
  char *logicalName,
  struct defmodule *theModule,
  char *singleName,
  char *pluralName,
  void *(*nextFunction)(void *,void *),
  char *(*nameFunction)(void *),
  void (*printFunction)(void *,char *,void *),
  int (*doItFunction)(void *,void *))
  {
   void *constructPtr;
   char *constructName;
   long count = 0;
   int allModules = 0;
   int doIt;
   SaveCurrentModule(theEnv);
   if (theModule == ((void *)0))
     {
      theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,((void *)0));
      allModules = 1;
     }
   while (theModule != ((void *)0))
     {
      if (allModules)
        {
         EnvPrintRouter(theEnv,logicalName,EnvGetDefmoduleName(theEnv,theModule));
         EnvPrintRouter(theEnv,logicalName,":\n");
        }
      EnvSetCurrentModule(theEnv,(void *) theModule);
      constructPtr = (*nextFunction)(theEnv,((void *)0));
      while (constructPtr != ((void *)0))
        {
         if (((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->HaltExecution == 1) return;
         if (doItFunction == ((void *)0)) doIt = 1;
         else doIt = (*doItFunction)(theEnv,constructPtr);
         if (! doIt) {}
         else if (nameFunction != ((void *)0))
           {
            constructName = (*nameFunction)(constructPtr);
            if (constructName != ((void *)0))
              {
               if (allModules) EnvPrintRouter(theEnv,logicalName,"   ");
               EnvPrintRouter(theEnv,logicalName,constructName);
               EnvPrintRouter(theEnv,logicalName,"\n");
              }
           }
         else if (printFunction != ((void *)0))
           {
            if (allModules) EnvPrintRouter(theEnv,logicalName,"   ");
            (*printFunction)(theEnv,logicalName,constructPtr);
            EnvPrintRouter(theEnv,logicalName,"\n");
           }
         constructPtr = (*nextFunction)(theEnv,constructPtr);
         count++;
        }
      if (allModules) theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule);
      else theModule = ((void *)0);
     }
   if (singleName != ((void *)0)) PrintTally(theEnv,logicalName,count,singleName,pluralName);
   RestoreCurrentModule(theEnv);
  }

canonical_original_code:
void ListItemsDriver(void *theEnv, char *logicalName, struct defmodule *theModule, char *singleName, char *pluralName, void *(*nextFunction)(void *, void *), char *(*nameFunction)(void *), void (*printFunction)(void *, char *, void *), int (*doItFunction)(void *, void *))
  {
   void *constructPtr;
   char *constructName;
   long count = 0;
   int allModules = 0;
   int doIt;
   SaveCurrentModule(theEnv);
   if (theModule == ((void *)0))
     {
      theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,((void *)0));
      allModules = 1;
     }
   while (theModule != ((void *)0))
     {
      if (allModules)
        {
         EnvPrintRouter(theEnv,logicalName,EnvGetDefmoduleName(theEnv,theModule));
         EnvPrintRouter(theEnv,logicalName,":\n");
        }
      EnvSetCurrentModule(theEnv,(void *) theModule);
      constructPtr = (*nextFunction)(theEnv,((void *)0));
      while (constructPtr != ((void *)0))
        {
         if (((struct evaluationData *) (((struct environmentData *) theEnv)->theData[44]))->HaltExecution == 1) return;
         if (doItFunction == ((void *)0)) doIt = 1;
         else doIt = (*doItFunction)(theEnv,constructPtr);
         if (! doIt) {}
         else if (nameFunction != ((void *)0))
           {
            constructName = (*nameFunction)(constructPtr);
            if (constructName != ((void *)0))
              {
               if (allModules) EnvPrintRouter(theEnv,logicalName,"   ");
               EnvPrintRouter(theEnv,logicalName,constructName);
               EnvPrintRouter(theEnv,logicalName,"\n");
              }
           }
         else if (printFunction != ((void *)0))
           {
            if (allModules) EnvPrintRouter(theEnv,logicalName,"   ");
            (*printFunction)(theEnv,logicalName,constructPtr);
            EnvPrintRouter(theEnv,logicalName,"\n");
           }
         constructPtr = (*nextFunction)(theEnv,constructPtr);
         count++;
        }
      if (allModules) theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule);
      else theModule = ((void *)0);
     }
   if (singleName != ((void *)0)) PrintTally(theEnv,logicalName,count,singleName,pluralName);
   RestoreCurrentModule(theEnv);
  }

variable_types:
theEnv
void *

variable_types:
logicalName
char *

variable_types:
singleName
char *

variable_types:
pluralName
char *

variable_types:
nextFunction
void *(*)(void *, void *)

variable_types:
nameFunction
char *(*)(void *)

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

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

variable_types:
constructPtr
void *

variable_types: count long

variable_types: allModules int

variable_types: doIt int

user_defined_types: struct evaluationData { struct expr *CurrentExpression; int EvaluationError; int HaltExecution; int CurrentEvaluationDepth; struct entityRecord *PrimitivesArray[150]; }

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

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

user_defined_types: struct entityRecord { char *name; unsigned int type; unsigned int copyToEvaluate; unsigned int bitMap; unsigned int addsToRuleComplexity; void (*shortPrintFunction)(void *, char *, void *); void (*longPrintFunction)(void *, char *, void *); int (*deleteFunction)(void *, void *); int (*evaluateFunction)(void *, void *, struct dataObject *); void *(*getNextFunction)(void *, void *); void (*decrementBusyCount)(void *, void *); void (*incrementBusyCount)(void *, void *); void (*propagateDepth)(void *, void *); void (*markNeeded)(void *, void *); void (*install)(void *, void *); void (*deinstall)(void *, void *); struct userData *usrData; }

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

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


DoForAllModules

decompiled_code:
__int64 __fastcall DoForAllModules(__int64 a1, void (__fastcall *a2)(__int64, __int64), int a3, __int64 a4)
{
__int64 v6; // rax
__int64 v7; // rdx
__int64 v8; // rbp
__int64 v9; // r13

SaveCurrentModule(a1);
v6 = EnvGetNextDefmodule(a1, 0LL);
if ( v6 )
{
v8 = v6;
v9 = 0LL;
while ( 1 )
{
EnvSetCurrentModule(a1, v8, v7);
if ( a3 )
{
if ( (unsigned int)GetHaltExecution(a1) )
break;
}
++v9;
a2(v8, a4);
v8 = EnvGetNextDefmodule(a1, v8);
if ( !v8 )
goto LABEL_8;
}
v9 = -1LL;
RestoreCurrentModule(a1);
}
else
{
v9 = 0LL;
LABEL_8:
RestoreCurrentModule(a1);
}
return v9;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, void (__fastcall *a2)(__int64, __int64), int a3, __int64 a4)
{
__int64 v6; // rax
__int64 v7; // rdx
__int64 v8; // rbp
__int64 v9; // r13

SaveCurrentModule(a1);
v6 = EnvGetNextDefmodule(a1, 0LL);
if ( v6 )
{
v8 = v6;
v9 = 0LL;
while ( 1 )
{
EnvSetCurrentModule(a1, v8, v7);
if ( a3 )
{
if ( (unsigned int)GetHaltExecution(a1) )
break;
}
++v9;
a2(v8, a4);
v8 = EnvGetNextDefmodule(a1, v8);
if ( !v8 )
goto LABEL_8;
}
v9 = -1LL;
RestoreCurrentModule(a1);
}
else
{
v9 = 0LL;
LABEL_8:
RestoreCurrentModule(a1);
}
return v9;
}

original_code:
long DoForAllModules(
  void *theEnv,
  void (*actionFunction)(struct defmodule *,void *),
  int interruptable,
  void *userBuffer)
  {
   void *theModule;
   long moduleCount = 0L;
   SaveCurrentModule(theEnv);
   for (theModule = EnvGetNextDefmodule(theEnv,((void *)0));
        theModule != ((void *)0);
        theModule = EnvGetNextDefmodule(theEnv,theModule), moduleCount++)
     {
      EnvSetCurrentModule(theEnv,(void *) theModule);
      if ((interruptable) && GetHaltExecution(theEnv))
        {
         RestoreCurrentModule(theEnv);
         return(-1L);
        }
      (*actionFunction)((struct defmodule *) theModule,userBuffer);
     }
   RestoreCurrentModule(theEnv);
   return(moduleCount);
  }

canonical_original_code:
long DoForAllModules(void *theEnv, void (*actionFunction)(struct defmodule *, void *), int interruptable, void *userBuffer)
  {
   void *theModule;
   long moduleCount = 0L;
   SaveCurrentModule(theEnv);
   for (theModule = EnvGetNextDefmodule(theEnv,((void *)0));
        theModule != ((void *)0);
        theModule = EnvGetNextDefmodule(theEnv,theModule), moduleCount++)
     {
      EnvSetCurrentModule(theEnv,(void *) theModule);
      if ((interruptable) && GetHaltExecution(theEnv))
        {
         RestoreCurrentModule(theEnv);
         return(-1L);
        }
      (*actionFunction)((struct defmodule *) theModule,userBuffer);
     }
   RestoreCurrentModule(theEnv);
   return(moduleCount);
  }

variable_types: void (*)(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; } *, void *)

variable_types: interruptable int

variable_types:
userBuffer
void *

variable_types:
theModule
void *

variable_types: moduleCount long

return_type: long


SetAnyAllowedFlags

original_code:
void SetAnyAllowedFlags(
  CONSTRAINT_RECORD *theConstraint,
  int justOne)
  {
   int flag1, flag2;
   if (justOne)
     {
      flag1 = 1;
      flag2 = 0;
     }
   else
     {
      flag1 = 0;
      flag2 = 1;
     }
   theConstraint->anyAllowed = flag1;
   theConstraint->symbolsAllowed = flag2;
   theConstraint->stringsAllowed = flag2;
   theConstraint->floatsAllowed = flag2;
   theConstraint->integersAllowed = flag2;
   theConstraint->instanceNamesAllowed = flag2;
   theConstraint->instanceAddressesAllowed = flag2;
   theConstraint->externalAddressesAllowed = flag2;
   theConstraint->voidAllowed = flag2;
   theConstraint->factAddressesAllowed = flag2;
  }

canonical_original_code:
void SetAnyAllowedFlags(struct constraintRecord *theConstraint, int justOne)
  {
   int flag1; int flag2;
   if (justOne)
     {
      flag1 = 1;
      flag2 = 0;
     }
   else
     {
      flag1 = 0;
      flag2 = 1;
     }
   theConstraint->anyAllowed = flag1;
   theConstraint->symbolsAllowed = flag2;
   theConstraint->stringsAllowed = flag2;
   theConstraint->floatsAllowed = flag2;
   theConstraint->integersAllowed = flag2;
   theConstraint->instanceNamesAllowed = flag2;
   theConstraint->instanceAddressesAllowed = flag2;
   theConstraint->externalAddressesAllowed = flag2;
   theConstraint->voidAllowed = flag2;
   theConstraint->factAddressesAllowed = flag2;
  }

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

variable_types: justOne int

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


GetConstraintRecord

original_code:
struct constraintRecord *GetConstraintRecord(
  void *theEnv)
  {
   CONSTRAINT_RECORD *constraints;
   unsigned i;
   constraints = ((((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct constraintRecord)] == ((void *)0)) ? ((struct constraintRecord *) genalloc(theEnv,(unsigned) sizeof(struct constraintRecord))) : ((((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct constraintRecord)]), ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct constraintRecord)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next, ((struct constraintRecord *) ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr)));
   for (i = 0 ; i < sizeof(CONSTRAINT_RECORD) ; i++)
     { ((char *) constraints)[i] = '\0'; }
   SetAnyAllowedFlags(constraints,1);
   constraints->multifieldsAllowed = 0;
   constraints->singlefieldsAllowed = 1;
   constraints->anyRestriction = 0;
   constraints->symbolRestriction = 0;
   constraints->stringRestriction = 0;
   constraints->floatRestriction = 0;
   constraints->integerRestriction = 0;
   constraints->classRestriction = 0;
   constraints->instanceNameRestriction = 0;
   constraints->classList = ((void *)0);
   constraints->restrictionList = ((void *)0);
   constraints->minValue = GenConstant(theEnv,2,((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->NegativeInfinity);
   constraints->maxValue = GenConstant(theEnv,2,((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->PositiveInfinity);
   constraints->minFields = GenConstant(theEnv,1,((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->Zero);
   constraints->maxFields = GenConstant(theEnv,2,((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->PositiveInfinity);
   constraints->bucket = -1;
   constraints->count = 0;
   constraints->multifield = ((void *)0);
   constraints->next = ((void *)0);
   return(constraints);
  }

canonical_original_code:
struct constraintRecord *GetConstraintRecord(void *theEnv)
  {
   struct constraintRecord *constraints;
   unsigned int i;
   constraints = ((((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct constraintRecord)] == ((void *)0)) ? ((struct constraintRecord *) genalloc(theEnv,(unsigned int) sizeof(struct constraintRecord))) : ((((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct constraintRecord)]), ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->MemoryTable[sizeof(struct constraintRecord)] = ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr->next, ((struct constraintRecord *) ((struct memoryData *) (((struct environmentData *) theEnv)->theData[59]))->TempMemoryPtr)));
   for (i = 0 ; i < sizeof(CONSTRAINT_RECORD) ; i++)
     { ((char *) constraints)[i] = '\0'; }
   SetAnyAllowedFlags(constraints,1);
   constraints->multifieldsAllowed = 0;
   constraints->singlefieldsAllowed = 1;
   constraints->anyRestriction = 0;
   constraints->symbolRestriction = 0;
   constraints->stringRestriction = 0;
   constraints->floatRestriction = 0;
   constraints->integerRestriction = 0;
   constraints->classRestriction = 0;
   constraints->instanceNameRestriction = 0;
   constraints->classList = ((void *)0);
   constraints->restrictionList = ((void *)0);
   constraints->minValue = GenConstant(theEnv,2,((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->NegativeInfinity);
   constraints->maxValue = GenConstant(theEnv,2,((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->PositiveInfinity);
   constraints->minFields = GenConstant(theEnv,1,((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->Zero);
   constraints->maxFields = GenConstant(theEnv,2,((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->PositiveInfinity);
   constraints->bucket = -1;
   constraints->count = 0;
   constraints->multifield = ((void *)0);
   constraints->next = ((void *)0);
   return(constraints);
  }

variable_types:
theEnv
void *

variable_types:
i
unsigned int

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

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 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 memoryPtr { struct memoryPtr *next; }

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


SetAnyRestrictionFlags

original_code:
void SetAnyRestrictionFlags(
  CONSTRAINT_RECORD *theConstraint,
  int justOne)
  {
   int flag1, flag2;
   if (justOne)
     {
      flag1 = 1;
      flag2 = 0;
     }
   else
     {
      flag1 = 0;
      flag2 = 1;
     }
   theConstraint->anyRestriction = flag1;
   theConstraint->symbolRestriction = flag2;
   theConstraint->stringRestriction = flag2;
   theConstraint->floatRestriction = flag2;
   theConstraint->integerRestriction = flag2;
   theConstraint->instanceNameRestriction = flag2;
  }

canonical_original_code:
void SetAnyRestrictionFlags(struct constraintRecord *theConstraint, int justOne)
  {
   int flag1; int flag2;
   if (justOne)
     {
      flag1 = 1;
      flag2 = 0;
     }
   else
     {
      flag1 = 0;
      flag2 = 1;
     }
   theConstraint->anyRestriction = flag1;
   theConstraint->symbolRestriction = flag2;
   theConstraint->stringRestriction = flag2;
   theConstraint->floatRestriction = flag2;
   theConstraint->integerRestriction = flag2;
   theConstraint->instanceNameRestriction = flag2;
  }


SetConstraintType

decompiled_code:
__int64 __fastcall SetConstraintType(int a1, unsigned __int8 *a2)
{
__int64 result; // rax
unsigned __int8 v3; // cl
unsigned __int8 v4; // al
unsigned __int8 v5; // al
char v6; // al
unsigned __int8 v7; // cl
unsigned __int8 v8; // al
unsigned __int8 v9; // cl
unsigned __int8 v10; // al
char v11; // al
char v12; // al
unsigned __int8 v13; // al
char v14; // al
char v15; // al
char v16; // al
char v17; // al
char v18; // al

if ( a1 > 8 )
{
switch ( a1 )
{
case 173:
v5 = *a2;
*a2 |= 1u;
result = v5 & 1;
break;
case 175:
v6 = a2[1] >> 1;
a2[1] |= 2u;
result = v6 & 1;
goto LABEL_6;
case 180:
v7 = *a2;
v8 = *a2 >> 3;
*a2 |= 0x18u;
result = ((v7 >> 4) | v8) & 1;
goto LABEL_6;
case 181:
v9 = *a2;
v10 = *a2 >> 1;
*a2 |= 6u;
result = ((v9 >> 2) | v10) & 1;
goto LABEL_6;
case 182:
v3 = *a2;
v4 = *a2 >> 6;
*a2 |= 0x60u;
result = ((v3 >> 5) | v4) & 1;
goto LABEL_6;
default:
result = 1LL;
if ( a1 != 173 )
goto LABEL_6;
break;
}
}
else
{
result = 1LL;
if ( a1 >= 0 )
{
switch ( a1 )
{
case 1:
v12 = *a2 >> 4;
*a2 |= 0x10u;
result = v12 & 1;
break;
case 2:
v15 = *a2 >> 1;
*a2 |= 2u;
result = v15 & 1;
break;
case 3:
v16 = *a2 >> 2;
*a2 |= 4u;
result = v16 & 1;
break;
case 4:
v17 = a2[2] >> 1;
a2[2] |= 2u;
result = v17 & 1;
break;
case 5:
LOBYTE(result) = *a2 >> 7;
*a2 |= 0x80u;
result = (unsigned __int8)result;
break;
case 6:
v13 = a2[1];
a2[1] = v13 | 1;
result = v13 & 1;
break;
case 7:
v14 = *a2 >> 6;
*a2 |= 0x40u;
result = v14 & 1;
break;
case 8:
v11 = *a2 >> 5;
*a2 |= 0x20u;
result = v11 & 1;
break;
default:
v18 = *a2 >> 3;
*a2 |= 8u;
result = v18 & 1;
break;
}
}
LABEL_6:
*a2 &= 0xFEu;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1, unsigned __int8 *a2)
{
__int64 result; // rax
unsigned __int8 v3; // cl
unsigned __int8 v4; // al
unsigned __int8 v5; // al
char v6; // al
unsigned __int8 v7; // cl
unsigned __int8 v8; // al
unsigned __int8 v9; // cl
unsigned __int8 v10; // al
char v11; // al
char v12; // al
unsigned __int8 v13; // al
char v14; // al
char v15; // al
char v16; // al
char v17; // al
char v18; // al

if ( a1 > 8 )
{
switch ( a1 )
{
case 173:
v5 = *a2;
*a2 |= 1u;
result = v5 & 1;
break;
case 175:
v6 = a2[1] >> 1;
a2[1] |= 2u;
result = v6 & 1;
goto LABEL_6;
case 180:
v7 = *a2;
v8 = *a2 >> 3;
*a2 |= 0x18u;
result = ((v7 >> 4) | v8) & 1;
goto LABEL_6;
case 181:
v9 = *a2;
v10 = *a2 >> 1;
*a2 |= 6u;
result = ((v9 >> 2) | v10) & 1;
goto LABEL_6;
case 182:
v3 = *a2;
v4 = *a2 >> 6;
*a2 |= 0x60u;
result = ((v3 >> 5) | v4) & 1;
goto LABEL_6;
default:
result = 1LL;
if ( a1 != 173 )
goto LABEL_6;
break;
}
}
else
{
result = 1LL;
if ( a1 >= 0 )
{
switch ( a1 )
{
case 1:
v12 = *a2 >> 4;
*a2 |= 0x10u;
result = v12 & 1;
break;
case 2:
v15 = *a2 >> 1;
*a2 |= 2u;
result = v15 & 1;
break;
case 3:
v16 = *a2 >> 2;
*a2 |= 4u;
result = v16 & 1;
break;
case 4:
v17 = a2[2] >> 1;
a2[2] |= 2u;
result = v17 & 1;
break;
case 5:
LOBYTE(result) = *a2 >> 7;
*a2 |= 0x80u;
result = (unsigned __int8)result;
break;
case 6:
v13 = a2[1];
a2[1] = v13 | 1;
result = v13 & 1;
break;
case 7:
v14 = *a2 >> 6;
*a2 |= 0x40u;
result = v14 & 1;
break;
case 8:
v11 = *a2 >> 5;
*a2 |= 0x20u;
result = v11 & 1;
break;
default:
v18 = *a2 >> 3;
*a2 |= 8u;
result = v18 & 1;
break;
}
}
LABEL_6:
*a2 &= 0xFEu;
}
return result;
}

original_code:
int SetConstraintType(
  int theType,
  CONSTRAINT_RECORD *constraints)
  {
   int rv = 1;
   switch(theType)
     {
      case 173:
         rv = constraints->anyAllowed;
         constraints->anyAllowed = 1;
         break;
      case 2:
         rv = constraints->symbolsAllowed;
         constraints->symbolsAllowed = 1;
         break;
      case 3:
         rv = constraints->stringsAllowed;
         constraints->stringsAllowed = 1;
         break;
      case 181:
         rv = (constraints->stringsAllowed | constraints->symbolsAllowed);
         constraints->symbolsAllowed = 1;
         constraints->stringsAllowed = 1;
         break;
      case 1:
         rv = constraints->integersAllowed;
         constraints->integersAllowed = 1;
         break;
      case 0:
         rv = constraints->floatsAllowed;
         constraints->floatsAllowed = 1;
         break;
      case 180:
         rv = (constraints->integersAllowed | constraints->floatsAllowed);
         constraints->integersAllowed = 1;
         constraints->floatsAllowed = 1;
         break;
      case 7:
         rv = constraints->instanceAddressesAllowed;
         constraints->instanceAddressesAllowed = 1;
         break;
      case 8:
         rv = constraints->instanceNamesAllowed;
         constraints->instanceNamesAllowed = 1;
         break;
      case 182:
         rv = (constraints->instanceNamesAllowed | constraints->instanceAddressesAllowed);
         constraints->instanceNamesAllowed = 1;
         constraints->instanceAddressesAllowed = 1;
         break;
      case 5:
         rv = constraints->externalAddressesAllowed;
         constraints->externalAddressesAllowed = 1;
         break;
      case 175:
         rv = constraints->voidAllowed;
         constraints->voidAllowed = 1;
         break;
      case 6:
         rv = constraints->factAddressesAllowed;
         constraints->factAddressesAllowed = 1;
         break;
      case 4:
         rv = constraints->multifieldsAllowed;
         constraints->multifieldsAllowed = 1;
         break;
     }
   if (theType != 173) constraints->anyAllowed = 0;
   return(rv);
  }

canonical_original_code:
int SetConstraintType(int theType, struct constraintRecord *constraints)
  {
   int rv = 1;
   switch(theType)
     {
      case 173:
         rv = constraints->anyAllowed;
         constraints->anyAllowed = 1;
         break;
      case 2:
         rv = constraints->symbolsAllowed;
         constraints->symbolsAllowed = 1;
         break;
      case 3:
         rv = constraints->stringsAllowed;
         constraints->stringsAllowed = 1;
         break;
      case 181:
         rv = (constraints->stringsAllowed | constraints->symbolsAllowed);
         constraints->symbolsAllowed = 1;
         constraints->stringsAllowed = 1;
         break;
      case 1:
         rv = constraints->integersAllowed;
         constraints->integersAllowed = 1;
         break;
      case 0:
         rv = constraints->floatsAllowed;
         constraints->floatsAllowed = 1;
         break;
      case 180:
         rv = (constraints->integersAllowed | constraints->floatsAllowed);
         constraints->integersAllowed = 1;
         constraints->floatsAllowed = 1;
         break;
      case 7:
         rv = constraints->instanceAddressesAllowed;
         constraints->instanceAddressesAllowed = 1;
         break;
      case 8:
         rv = constraints->instanceNamesAllowed;
         constraints->instanceNamesAllowed = 1;
         break;
      case 182:
         rv = (constraints->instanceNamesAllowed | constraints->instanceAddressesAllowed);
         constraints->instanceNamesAllowed = 1;
         constraints->instanceAddressesAllowed = 1;
         break;
      case 5:
         rv = constraints->externalAddressesAllowed;
         constraints->externalAddressesAllowed = 1;
         break;
      case 175:
         rv = constraints->voidAllowed;
         constraints->voidAllowed = 1;
         break;
      case 6:
         rv = constraints->factAddressesAllowed;
         constraints->factAddressesAllowed = 1;
         break;
      case 4:
         rv = constraints->multifieldsAllowed;
         constraints->multifieldsAllowed = 1;
         break;
     }
   if (theType != 173) constraints->anyAllowed = 0;
   return(rv);
  }

variable_types: theType int

variable_types: rv int


CompareNumbers

decompiled_code:
__int64 __fastcall CompareNumbers(__int64 a1, unsigned int a2, __int64 a3, int a4, __int64 a5)
{
__int64 v6; // rax
__int64 v7; // rsi
__int64 v8; // rax
__int64 v9; // rcx
__int64 result; // rax
double v11; // xmm0_8
double v12; // xmm1_8

if ( a3 == a5 )
return 2LL;
v6 = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 392LL);
v7 = *(_QWORD *)(v6 + 16);
if ( v7 == a3 )
return 1LL;
v8 = *(_QWORD *)(v6 + 24);
if ( v8 == a3 || v7 == a5 )
return 0LL;
if ( v8 == a5 )
return 1LL;
if ( a2 == 1 && a4 == 1 )
{
v9 = *(_QWORD *)(a5 + 24);
result = 0LL;
if ( *(_QWORD *)(a3 + 24) >= v9 )
{
result = 1LL;
if ( *(_QWORD *)(a3 + 24) <= v9 )
result = 2LL;
}
return result;
}
result = a4 | a2;
if ( !(a4 | a2) )
{
v12 = *(double *)(a3 + 24);
v11 = *(double *)(a5 + 24);
if ( v11 > v12 )
return result;
return (unsigned int)(v12 <= v11) + 1;
}
if ( !a4 && a2 == 1 )
{
v11 = *(double *)(a5 + 24);
result = 0LL;
v12 = (double)(int)*(_QWORD *)(a3 + 24);
if ( v11 > v12 )
return result;
return (unsigned int)(v12 <= v11) + 1;
}
if ( a2 || a4 != 1 )
return 0xFFFFFFFFLL;
v12 = *(double *)(a3 + 24);
result = 0LL;
v11 = (double)(int)*(_QWORD *)(a5 + 24);
if ( v11 <= v12 )
return (unsigned int)(v12 <= v11) + 1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, unsigned int a2, __int64 a3, int a4, __int64 a5)
{
__int64 v6; // rax
__int64 v7; // rsi
__int64 v8; // rax
__int64 v9; // rcx
__int64 result; // rax
double v11; // xmm0_8
double v12; // xmm1_8

if ( a3 == a5 )
return 2LL;
v6 = *(_QWORD *)(*(_QWORD *)(a1 + 32) + 392LL);
v7 = *(_QWORD *)(v6 + 16);
if ( v7 == a3 )
return 1LL;
v8 = *(_QWORD *)(v6 + 24);
if ( v8 == a3 || v7 == a5 )
return 0LL;
if ( v8 == a5 )
return 1LL;
if ( a2 == 1 && a4 == 1 )
{
v9 = *(_QWORD *)(a5 + 24);
result = 0LL;
if ( *(_QWORD *)(a3 + 24) >= v9 )
{
result = 1LL;
if ( *(_QWORD *)(a3 + 24) <= v9 )
result = 2LL;
}
return result;
}
result = a4 | a2;
if ( !(a4 | a2) )
{
v12 = *(double *)(a3 + 24);
v11 = *(double *)(a5 + 24);
if ( v11 > v12 )
return result;
return (unsigned int)(v12 <= v11) + 1;
}
if ( !a4 && a2 == 1 )
{
v11 = *(double *)(a5 + 24);
result = 0LL;
v12 = (double)(int)*(_QWORD *)(a3 + 24);
if ( v11 > v12 )
return result;
return (unsigned int)(v12 <= v11) + 1;
}
if ( a2 || a4 != 1 )
return 0xFFFFFFFFLL;
v12 = *(double *)(a3 + 24);
result = 0LL;
v11 = (double)(int)*(_QWORD *)(a5 + 24);
if ( v11 <= v12 )
return (unsigned int)(v12 <= v11) + 1;
return result;
}

original_code:
int CompareNumbers(
  void *theEnv,
  int type1,
  void *vptr1,
  int type2,
  void *vptr2)
  {
   if (vptr1 == vptr2) return(2);
   if (vptr1 == ((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->PositiveInfinity) return(1);
   if (vptr1 == ((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->NegativeInfinity) return(0);
   if (vptr2 == ((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->PositiveInfinity) return(0);
   if (vptr2 == ((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->NegativeInfinity) return(1);
   if ((type1 == 1) && (type2 == 1))
     {
      if ((((struct integerHashNode *) (vptr1))->contents) < (((struct integerHashNode *) (vptr2))->contents))
        { return(0); }
      else if ((((struct integerHashNode *) (vptr1))->contents) > (((struct integerHashNode *) (vptr2))->contents))
        { return(1); }
      return(2);
     }
   if ((type1 == 0) && (type2 == 0))
     {
      if ((((struct floatHashNode *) (vptr1))->contents) < (((struct floatHashNode *) (vptr2))->contents))
        { return(0); }
      else if ((((struct floatHashNode *) (vptr1))->contents) > (((struct floatHashNode *) (vptr2))->contents))
        { return(1); }
      return(2);
     }
   if ((type1 == 1) && (type2 == 0))
     {
      if (((double) (((struct integerHashNode *) (vptr1))->contents)) < (((struct floatHashNode *) (vptr2))->contents))
        { return(0); }
      else if (((double) (((struct integerHashNode *) (vptr1))->contents)) > (((struct floatHashNode *) (vptr2))->contents))
        { return(1); }
      return(2);
     }
   if ((type1 == 0) && (type2 == 1))
     {
      if ((((struct floatHashNode *) (vptr1))->contents) < ((double) (((struct integerHashNode *) (vptr2))->contents)))
        { return(0); }
      else if ((((struct floatHashNode *) (vptr1))->contents) > ((double) (((struct integerHashNode *) (vptr2))->contents)))
        { return(1); }
      return(2);
     }
   return(-1);
  }

canonical_original_code:
int CompareNumbers(void *theEnv, int type1, void *vptr1, int type2, void *vptr2)
  {
   if (vptr1 == vptr2) return(2);
   if (vptr1 == ((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->PositiveInfinity) return(1);
   if (vptr1 == ((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->NegativeInfinity) return(0);
   if (vptr2 == ((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->PositiveInfinity) return(0);
   if (vptr2 == ((struct symbolData *) (((struct environmentData *) theEnv)->theData[49]))->NegativeInfinity) return(1);
   if ((type1 == 1) && (type2 == 1))
     {
      if ((((struct integerHashNode *) (vptr1))->contents) < (((struct integerHashNode *) (vptr2))->contents))
        { return(0); }
      else if ((((struct integerHashNode *) (vptr1))->contents) > (((struct integerHashNode *) (vptr2))->contents))
        { return(1); }
      return(2);
     }
   if ((type1 == 0) && (type2 == 0))
     {
      if ((((struct floatHashNode *) (vptr1))->contents) < (((struct floatHashNode *) (vptr2))->contents))
        { return(0); }
      else if ((((struct floatHashNode *) (vptr1))->contents) > (((struct floatHashNode *) (vptr2))->contents))
        { return(1); }
      return(2);
     }
   if ((type1 == 1) && (type2 == 0))
     {
      if (((double) (((struct integerHashNode *) (vptr1))->contents)) < (((struct floatHashNode *) (vptr2))->contents))
        { return(0); }
      else if (((double) (((struct integerHashNode *) (vptr1))->contents)) > (((struct floatHashNode *) (vptr2))->contents))
        { return(1); }
      return(2);
     }
   if ((type1 == 0) && (type2 == 1))
     {
      if ((((struct floatHashNode *) (vptr1))->contents) < ((double) (((struct integerHashNode *) (vptr2))->contents)))
        { return(0); }
      else if ((((struct floatHashNode *) (vptr1))->contents) > ((double) (((struct integerHashNode *) (vptr2))->contents)))
        { return(1); }
      return(2);
     }
   return(-1);
  }

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

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

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


FactFunctionDefinitions

decompiled_code:
__int64 __fastcall FactFunctionDefinitions(__int64 a1)
{
EnvDefineFunction2(a1, "fact-existp", 98LL, FactExistpFunction, "FactExistpFunction", &LC0);
EnvDefineFunction2(a1, "fact-relation", 119LL, FactRelationFunction, "FactRelationFunction", &LC0);
EnvDefineFunction2(a1, "fact-slot-value", 117LL, FactSlotValueFunction, "FactSlotValueFunction", "22*zw");
EnvDefineFunction2(a1, "fact-slot-names", 117LL, FactSlotNamesFunction, "FactSlotNamesFunction", &LC0);
EnvDefineFunction2(a1, "get-fact-list", 109LL, GetFactListFunction, "GetFactListFunction", "01w");
return EnvDefineFunction2(a1, "ppfact", 118LL, PPFactFunction, "PPFactFunction", "13*z");
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
EnvDefineFunction2(a1, "fact-existp", 98LL, FactExistpFunction, "FactExistpFunction", &LC0);
EnvDefineFunction2(a1, "fact-relation", 119LL, FactRelationFunction, "FactRelationFunction", &LC0);
EnvDefineFunction2(a1, "fact-slot-value", 117LL, FactSlotValueFunction, "FactSlotValueFunction", "22*zw");
EnvDefineFunction2(a1, "fact-slot-names", 117LL, FactSlotNamesFunction, "FactSlotNamesFunction", &LC0);
EnvDefineFunction2(a1, "get-fact-list", 109LL, GetFactListFunction, "GetFactListFunction", "01w");
return EnvDefineFunction2(a1, "ppfact", 118LL, PPFactFunction, "PPFactFunction", "13*z");
}

original_code:
void FactFunctionDefinitions(
  void *theEnv)
  {
   EnvDefineFunction2(theEnv,"fact-existp", 'b', (int (*)(void *)) FactExistpFunction, "FactExistpFunction", "11z");
   EnvDefineFunction2(theEnv,"fact-relation",'w', (int (*)(void *)) FactRelationFunction,"FactRelationFunction", "11z");
   EnvDefineFunction2(theEnv,"fact-slot-value",'u', (int (*)(void *)) FactSlotValueFunction,"FactSlotValueFunction", "22*zw");
   EnvDefineFunction2(theEnv,"fact-slot-names",'u', (int (*)(void *)) FactSlotNamesFunction,"FactSlotNamesFunction", "11z");
   EnvDefineFunction2(theEnv,"get-fact-list",'m',(int (*)(void *)) GetFactListFunction,"GetFactListFunction","01w");
   EnvDefineFunction2(theEnv,"ppfact",'v',(int (*)(void *)) PPFactFunction,"PPFactFunction","13*z");
  }

canonical_original_code:
void FactFunctionDefinitions(void *theEnv)
  {
   EnvDefineFunction2(theEnv,"fact-existp", 'b', (int (*)(void *)) FactExistpFunction, "FactExistpFunction", "11z");
   EnvDefineFunction2(theEnv,"fact-relation",'w', (int (*)(void *)) FactRelationFunction,"FactRelationFunction", "11z");
   EnvDefineFunction2(theEnv,"fact-slot-value",'u', (int (*)(void *)) FactSlotValueFunction,"FactSlotValueFunction", "22*zw");
   EnvDefineFunction2(theEnv,"fact-slot-names",'u', (int (*)(void *)) FactSlotNamesFunction,"FactSlotNamesFunction", "11z");
   EnvDefineFunction2(theEnv,"get-fact-list",'m',(int (*)(void *)) GetFactListFunction,"GetFactListFunction","01w");
   EnvDefineFunction2(theEnv,"ppfact",'v',(int (*)(void *)) PPFactFunction,"PPFactFunction","13*z");
  }


FactRelation

decompiled_code:
__int64 __fastcall FactRelation(__int64 a1)
{
return **(_QWORD **)(a1 + 32);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return **(_QWORD **)(a1 + 32);
}

original_code:
void *FactRelation(
  void *vTheFact)
  {
   struct fact *theFact = (struct fact *) vTheFact;
   return((void *) theFact->whichDeftemplate->header.name);
  }

canonical_original_code:
void *FactRelation(void *vTheFact)
  {
   struct fact *theFact = (struct fact *) vTheFact;
   return((void *) theFact->whichDeftemplate->header.name);
  }

variable_types:
vTheFact
void *

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

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

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

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

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

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

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

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

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

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

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

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

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

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


EnvFactDeftemplate

decompiled_code:
__int64 __fastcall EnvFactDeftemplate(__int64 a1, __int64 a2)
{
return *(_QWORD *)(a2 + 32);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
return *(_QWORD *)(a2 + 32);
}

original_code:
void *EnvFactDeftemplate(
  void *theEnv,
  void *vTheFact)
  {
   struct fact *theFact = (struct fact *) vTheFact;
   return((void *) theFact->whichDeftemplate);
  }

canonical_original_code:
void *EnvFactDeftemplate(void *theEnv, void *vTheFact)
  {
   struct fact *theFact = (struct fact *) vTheFact;
   return((void *) theFact->whichDeftemplate);
  }

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

user_defined_types: struct entityRecord { char *name; unsigned int type; unsigned int copyToEvaluate; unsigned int bitMap; unsigned int addsToRuleComplexity; void (*shortPrintFunction)(void *, char *, void *); void (*longPrintFunction)(void *, char *, void *); int (*deleteFunction)(void *, void *); int (*evaluateFunction)(void *, void *, struct dataObject *); void *(*getNextFunction)(void *, void *); void (*decrementBusyCount)(void *, void *); void (*incrementBusyCount)(void *, void *); void (*propagateDepth)(void *, void *); void (*markNeeded)(void *, void *); void (*install)(void *, void *); void (*deinstall)(void *, void *); struct userData *usrData; }

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

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 dataObject { void *supplementalInfo; unsigned short type; void *value; long begin; long end; struct dataObject *next; }

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

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

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

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


EnvFactExistp

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

if ( a2 )
result = *(char *)(a2 + 57) >= 0;
else
result = 0LL;
return result;
}

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

if ( a2 )
result = *(char *)(a2 + 57) >= 0;
else
result = 0LL;
return result;
}

original_code:
int EnvFactExistp(
  void *theEnv,
  void *vTheFact)
  {
   struct fact *theFact = (struct fact *) vTheFact;
   if (theFact == ((void *)0)) return(0);
   if (theFact->garbage) return(0);
   return(1);
  }

canonical_original_code:
int EnvFactExistp(void *theEnv, void *vTheFact)
  {
   struct fact *theFact = (struct fact *) vTheFact;
   if (theFact == ((void *)0)) return(0);
   if (theFact->garbage) return(0);
   return(1);
  }

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

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

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

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

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

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

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

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


FactSlotValue

decompiled_code:
__int64 __fastcall FactSlotValue(__int64 a1, __int64 a2, const char *a3, __int64 a4)
{
__int64 result; // rax
__int64 v7; // rax
char v8[42]; // [rsp+Eh] [rbp-2Ah] BYREF

if ( (*(_BYTE *)(*(_QWORD *)(a2 + 32) + 56LL) & 1) != 0 )
{
if ( !strcmp(a3, "implied") )
return EnvGetFactSlot(a1, a2, 0LL, a4);
SetEvaluationError(a1, 1LL);
result = InvalidDeftemplateSlotMessage(a1, a3, *(_QWORD *)(**(_QWORD **)(a2 + 32) + 24LL), 0LL);
}
else
{
v7 = EnvAddSymbol(a1, a3);
if ( FindSlot(*(_QWORD *)(a2 + 32), v7, v8) )
{
if ( (*(_BYTE *)(*(_QWORD *)(a2 + 32) + 56LL) & 1) != 0 )
return EnvGetFactSlot(a1, a2, 0LL, a4);
result = EnvGetFactSlot(a1, a2, a3, a4);
}
else
{
SetEvaluationError(a1, 1LL);
result = InvalidDeftemplateSlotMessage(a1, a3, *(_QWORD *)(**(_QWORD **)(a2 + 32) + 24LL), 0LL);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, const char *a3, __int64 a4)
{
__int64 result; // rax
__int64 v7; // rax
char v8[42]; // [rsp+Eh] [rbp-2Ah] BYREF

if ( (*(_BYTE *)(*(_QWORD *)(a2 + 32) + 56LL) & 1) != 0 )
{
if ( !strcmp(a3, "implied") )
return EnvGetFactSlot(a1, a2, 0LL, a4);
SetEvaluationError(a1, 1LL);
result = InvalidDeftemplateSlotMessage(a1, a3, *(_QWORD *)(**(_QWORD **)(a2 + 32) + 24LL), 0LL);
}
else
{
v7 = EnvAddSymbol(a1, a3);
if ( FindSlot(*(_QWORD *)(a2 + 32), v7, v8) )
{
if ( (*(_BYTE *)(*(_QWORD *)(a2 + 32) + 56LL) & 1) != 0 )
return EnvGetFactSlot(a1, a2, 0LL, a4);
result = EnvGetFactSlot(a1, a2, a3, a4);
}
else
{
SetEvaluationError(a1, 1LL);
result = InvalidDeftemplateSlotMessage(a1, a3, *(_QWORD *)(**(_QWORD **)(a2 + 32) + 24LL), 0LL);
}
}
return result;
}

original_code:
void FactSlotValue(
  void *theEnv,
  void *vTheFact,
  char *theSlotName,
  DATA_OBJECT *returnValue)
  {
   struct fact *theFact = (struct fact *) vTheFact;
   short position;
   if (theFact->whichDeftemplate->implied)
     {
      if (strcmp(theSlotName,"implied") != 0)
        {
         SetEvaluationError(theEnv,1);
         InvalidDeftemplateSlotMessage(theEnv,theSlotName,
                                       (((struct symbolHashNode *) (theFact->whichDeftemplate->header.name))->contents),0);
         return;
        }
     }
   else if (FindSlot(theFact->whichDeftemplate,(SYMBOL_HN *) EnvAddSymbol(theEnv,theSlotName),&position) == ((void *)0))
     {
      SetEvaluationError(theEnv,1);
      InvalidDeftemplateSlotMessage(theEnv,theSlotName,
                                    (((struct symbolHashNode *) (theFact->whichDeftemplate->header.name))->contents),0);
      return;
     }
   if (theFact->whichDeftemplate->implied)
     { EnvGetFactSlot(theEnv,theFact,((void *)0),returnValue); }
   else
     { EnvGetFactSlot(theEnv,theFact,theSlotName,returnValue); }
  }

canonical_original_code:
void FactSlotValue(void *theEnv, void *vTheFact, char *theSlotName, struct dataObject *returnValue)
  {
   struct fact *theFact = (struct fact *) vTheFact;
   short position;
   if (theFact->whichDeftemplate->implied)
     {
      if (strcmp(theSlotName,"implied") != 0)
        {
         SetEvaluationError(theEnv,1);
         InvalidDeftemplateSlotMessage(theEnv,theSlotName,
                                       (((struct symbolHashNode *) (theFact->whichDeftemplate->header.name))->contents),0);
         return;
        }
     }
   else if (FindSlot(theFact->whichDeftemplate,(struct symbolHashNode *) EnvAddSymbol(theEnv,theSlotName),&position) == ((void *)0))
     {
      SetEvaluationError(theEnv,1);
      InvalidDeftemplateSlotMessage(theEnv,theSlotName,
                                    (((struct symbolHashNode *) (theFact->whichDeftemplate->header.name))->contents),0);
      return;
     }
   if (theFact->whichDeftemplate->implied)
     { EnvGetFactSlot(theEnv,theFact,((void *)0),returnValue); }
   else
     { EnvGetFactSlot(theEnv,theFact,theSlotName,returnValue); }
  }

variable_types:
theSlotName
char *

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

variable_types: position short

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

user_defined_types: struct entityRecord { char *name; unsigned int type; unsigned int copyToEvaluate; unsigned int bitMap; unsigned int addsToRuleComplexity; void (*shortPrintFunction)(void *, char *, void *); void (*longPrintFunction)(void *, char *, void *); int (*deleteFunction)(void *, void *); int (*evaluateFunction)(void *, void *, struct dataObject *); void *(*getNextFunction)(void *, void *); void (*decrementBusyCount)(void *, void *); void (*incrementBusyCount)(void *, void *); void (*propagateDepth)(void *, void *); void (*markNeeded)(void *, void *); void (*install)(void *, void *); void (*deinstall)(void *, void *); struct userData *usrData; }

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

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

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

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

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

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