public static ControlFrame handleTimeout(ControlFrame frame, int depth, Object [] MV_returnarray) {
    if ((Stella.$TRACED_KEYWORDS$ != null) &&
        Stella.$TRACED_KEYWORDS$.membP(Logic.KWD_GOAL_TREE)) {
      System.out.println("*** Timeout: start=" + frame.startingClockTicks + " depth=" + depth);
    }
    if ((Logic.$CACHE_SUCCEEDED_GOALSp$ ||
        Logic.$CACHE_FAILED_GOALSp$) &&
        ((Logic.$DUPLICATE_SUBGOAL_STRATEGY$ == Logic.KWD_DUPLICATE_GOALS) &&
         (!((((QueryIterator)(Logic.$QUERYITERATOR$.get())) != null) &&
        (((QueryIterator)(Logic.$QUERYITERATOR$.get())).partialMatchStrategy != null))))) {
      ControlFrame.dontCacheGoalFailureBetweenFrames(frame, ((QueryIterator)(Logic.$QUERYITERATOR$.get())).baseControlFrame);
    }
    ControlFrame.registerInferenceCutoff(frame, Logic.KWD_TIMEOUT);
    ControlFrame.setFrameTruthValue(frame, Logic.UNKNOWN_TRUTH_VALUE);
    if ((((QueryIterator)(Logic.$QUERYITERATOR$.get())) != null) &&
        (((QueryIterator)(Logic.$QUERYITERATOR$.get())).partialMatchStrategy != null)) {
      if (frame.partialMatchFrame == null) {
        ControlFrame.createAndLinkPartialMatchFrame(frame, null);
      }
      frame.partialMatchFrame.setFramePartialTruth(null, 0.0, Stella.NULL_FLOAT, true);
    }
    if (((Boolean)(Logic.$RECORD_JUSTIFICATIONSp$.get())).booleanValue()) {
      { PrimitiveStrategy self000 = PrimitiveStrategy.newPrimitiveStrategy();

        self000.inferenceRule = Logic.KWD_TIMEOUT;
        self000.strategy = Logic.KWD_FAILURE;
        ControlFrame.recordGoalJustification(frame, self000);
      }
    }
    frame.state = Logic.KWD_POPPED;
    frame.up.result = frame;
    frame = frame.up;
    depth = depth - 1;
    { ControlFrame _return_temp = frame;

      MV_returnarray[0] = IntegerWrapper.wrapInteger(depth);
      return (_return_temp);
    }
  }