public static boolean transferPatternQueryBindingsP(ControlFrame frame, boolean futurebindingsP) {
    if ((Stella.$TRACED_KEYWORDS$ != null) &&
        Stella.$TRACED_KEYWORDS$.membP(Logic.KWD_QUERY_STACKS)) {
      System.out.println("TRANSFER-pattern-query-bindings?: ");
    }
    { PatternRecord childpatternrecord = frame.patternRecord;
      BooleanVector booleanvector = childpatternrecord.booleanVector;
      Vector externalarguments = childpatternrecord.externalArguments;
      Vector iovariables = childpatternrecord.optimalPattern.ioVariables;
      int lastindex = booleanvector.length() - 1;
      Cons iovariablevalues = Stella.NIL;
      int topunbindingoffset = Stella.NULL_INTEGER;

      { int i = Stella.NULL_INTEGER;
        int iter000 = 0;
        int upperBound000 = lastindex;
        boolean unboundedP000 = upperBound000 == Stella.NULL_INTEGER;
        Cons collect000 = null;

        for (;unboundedP000 ||
                  (iter000 <= upperBound000); iter000 = iter000 + 1) {
          i = iter000;
          if (collect000 == null) {
            {
              collect000 = Cons.cons(((!BooleanWrapper.coerceWrappedBooleanToBoolean(((BooleanWrapper)((booleanvector.theArray)[i])))) ? (((QueryIterator)(Logic.$QUERYITERATOR$.get())).currentPatternRecord.variableBindings.theArray)[(((PatternVariable)((iovariables.theArray)[i])).boundToOffset)] : null), Stella.NIL);
              if (iovariablevalues == Stella.NIL) {
                iovariablevalues = collect000;
              }
              else {
                Cons.addConsToEndOfConsList(iovariablevalues, collect000);
              }
            }
          }
          else {
            {
              collect000.rest = Cons.cons(((!BooleanWrapper.coerceWrappedBooleanToBoolean(((BooleanWrapper)((booleanvector.theArray)[i])))) ? (((QueryIterator)(Logic.$QUERYITERATOR$.get())).currentPatternRecord.variableBindings.theArray)[(((PatternVariable)((iovariables.theArray)[i])).boundToOffset)] : null), Stella.NIL);
              collect000 = collect000.rest;
            }
          }
        }
      }
      ControlFrame.resetCurrentPatternRecord(frame, Logic.KWD_PARENT);
      { PatternRecord parentpatternrecord = ((QueryIterator)(Logic.$QUERYITERATOR$.get())).currentPatternRecord;

        topunbindingoffset = parentpatternrecord.topUnbindingStackOffset;
        { Stella_Object value = null;
          Cons iter001 = iovariablevalues;
          Stella_Object externalarg = null;
          Vector vector000 = externalarguments;
          int index000 = 0;
          int length000 = vector000.length();
          BooleanWrapper initiallyboundP = null;
          BooleanVector vector001 = booleanvector;
          int index001 = 0;
          int length001 = vector001.length();

          for (;(!(iter001 == Stella.NIL)) &&
                    ((index000 < length000) &&
                     (index001 < length001)); 
                iter001 = iter001.rest,
                index000 = index000 + 1,
                index001 = index001 + 1) {
            value = iter001.value;
            externalarg = (vector000.theArray)[index000];
            initiallyboundP = ((BooleanWrapper)((vector001.theArray)[index001]));
            if (!BooleanWrapper.coerceWrappedBooleanToBoolean(initiallyboundP)) {
              if (!Logic.bindArgumentToValueP(externalarg, value, false)) {
                if ((Stella.$TRACED_KEYWORDS$ != null) &&
                    Stella.$TRACED_KEYWORDS$.membP(Logic.KWD_QUERY_STACKS)) {
                  System.out.println("TRANSFER FAILS! ");
                }
                PatternRecord.unbindVariablesBeginningAt(parentpatternrecord, topunbindingoffset + 1);
                if (futurebindingsP) {
                  ControlFrame.resetCurrentPatternRecord(frame, Logic.KWD_LOCAL);
                }
                return (false);
              }
            }
          }
        }
      }
      return (true);
    }
  }