public static QueryIterator makeCachedQuery(Cons variables, Cons querybody, Cons inputbindings, Stella_Object options, Symbol cacheid) {
    { QueryIterator queryiterator = Logic.findCachedQuery(cacheid);
      Cons cursor = inputbindings;

      if (!(variables.length() == inputbindings.length())) {
        System.out.println("make-cached-query: number of variables does not equal number of input bindings.");
        return (null);
      }
      while (!(cursor == Stella.NIL)) {
        if (cursor.value != null) {
          cursor.value = Logic.valueOf(cursor.value);
        }
        cursor = cursor.rest;
      }
      if ((queryiterator != null) &&
          ((!(Logic.$QUERY_OPTIMIZATION_STRATEGY$ == Logic.KWD_NONE)) &&
           (!((Logic.$QUERY_OPTIMIZATION_STRATEGY$ == Logic.KWD_DYNAMIC) ||
          (Logic.$QUERY_OPTIMIZATION_STRATEGY$ == Logic.KWD_DYNAMIC_WITH_CLUSTERING))))) {
        { Stella_Object oldb = null;
          Vector vector000 = ((Vector)(KeyValueList.dynamicSlotValue(queryiterator.dynamicSlots, Logic.SYM_LOGIC_INITIAL_BINDINGS, null)));
          int index000 = 0;
          int length000 = vector000.length();
          Stella_Object newb = null;
          Cons iter000 = inputbindings;

          loop001 : for (;(index000 < length000) &&
                    (!(iter000 == Stella.NIL)); index000 = index000 + 1, iter000 = iter000.rest) {
            oldb = (vector000.theArray)[index000];
            newb = iter000.value;
            if (!((oldb == null) == (newb == null))) {
              queryiterator = null;
              break loop001;
            }
          }
        }
      }
      if (queryiterator == null) {
        {
          try {
            queryiterator = Logic.makeQuery(Cons.copyConsList(variables), ((Cons)(Stella_Object.copyConsTree(querybody))), inputbindings, options);
          } catch (LogicException e) {
            Stella.STANDARD_ERROR.nativeStream.print(Stella.exceptionMessage(e));
            return (null);
          }
        }
      }
      else {
        {
          { Stella_Object newb = null;
            Cons iter001 = inputbindings;
            int i = Stella.NULL_INTEGER;
            int iter002 = 0;

            for (;!(iter001 == Stella.NIL); iter001 = iter001.rest, iter002 = iter002 + 1) {
              newb = iter001.value;
              i = iter002;
              (((Vector)(KeyValueList.dynamicSlotValue(queryiterator.dynamicSlots, Logic.SYM_LOGIC_INITIAL_BINDINGS, null))).theArray)[i] = newb;
            }
          }
          queryiterator.reset();
        }
      }
      if (options != null) {
        QueryIterator.processQueryOptions(queryiterator, options);
      }
      return (queryiterator);
    }
  }