public static Keyword scanCachedGoals(ControlFrame frame) {
    { Proposition proposition = frame.proposition;
      Iterator iterator = ((Iterator)(KeyValueList.dynamicSlotValue(frame.dynamicSlots, Logic.SYM_STELLA_ITERATOR, null)));
      AtomicGoalCache cachedgoal = null;
      PatternRecord patternrecord = ((QueryIterator)(Logic.$QUERYITERATOR$.get())).currentPatternRecord;
      int ubstackoffset = patternrecord.topUnbindingStackOffset;

      if (!((BooleanWrapper)(KeyValueList.dynamicSlotValue(Logic.surrogateToDescription(((Surrogate)(proposition.operator))).dynamicSlots, Logic.SYM_LOGIC_CHECK_FOR_CACHED_GOALSp, Stella.FALSE_WRAPPER))).wrapperValue) {
        return (Logic.KWD_FAILURE);
      }
      if (iterator == null) {
        iterator = ((Iterator)(KeyValueList.setDynamicSlotValue(frame.dynamicSlots, Logic.SYM_STELLA_ITERATOR, ControlFrame.allCachedPropositions(frame), null)));
      }
      while (iterator.nextP()) {
        cachedgoal = ((AtomicGoalCache)(iterator.value));
        { boolean alwaysP000 = true;

          { Stella_Object arg = null;
            Vector vector000 = proposition.arguments;
            int index000 = 0;
            int length000 = vector000.length();
            Stella_Object cachedbinding = null;
            Cons iter000 = cachedgoal.bindings;

            loop001 : for (;(index000 < length000) &&
                      (!(iter000 == Stella.NIL)); index000 = index000 + 1, iter000 = iter000.rest) {
              arg = (vector000.theArray)[index000];
              cachedbinding = iter000.value;
              if (!Logic.bindArgumentToValueP(arg, cachedbinding, true)) {
                alwaysP000 = false;
                break loop001;
              }
            }
          }
          if (alwaysP000) {
            return (AtomicGoalCache.finishCachedGoalProcessing(cachedgoal, frame, Logic.KWD_SUCCESS, true));
          }
        }
        PatternRecord.unbindVariablesBeginningAt(patternrecord, ubstackoffset + 1);
      }
      return (Logic.KWD_FAILURE);
    }
  }