public static Cons combineStartupFunctionUnits(Symbol startupfnname) {
    { Cons earlystartuptrees = Stella.NIL;
      Cons startuptrees = Stella.NIL;
      Cons startupphasetrees = Stella.NIL;
      List startupunits = List.newList();

      { ListIterator it = ((ListIterator)(((List)(Stella.$TRANSLATIONUNITS$.get())).allocateIterator()));

        while (it.nextP()) {
          if (((TranslationUnit)(it.value)).category == Stella.SYM_STELLA_STARTUP_TIME_PROGN) {
            startupunits.push(((TranslationUnit)(it.value)));
            it.valueSetter(null);
          }
        }
      }
      ((List)(Stella.$TRANSLATIONUNITS$.get())).remove(null);
      startupunits.sort(Native.find_java_method("edu.isi.stella.TranslationUnit", "earlierStartupUnitP", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.TranslationUnit"), Native.find_java_class("edu.isi.stella.TranslationUnit")}));
      if ((startupfnname != null) &&
          (startupunits.length() > Stella.$MAX_NUMBER_OF_STARTUP_UNITS$)) {
        List.extractStartupFunctionUnits(startupunits, startupfnname);
      }
      { Keyword phase = null;
        Cons iter000 = Stella.$STARTUP_TIME_PHASES$.theConsList;

        for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
          phase = ((Keyword)(iter000.value));
          while (startupunits.nonEmptyP() &&
              (((TranslationUnit)(startupunits.first())).codeRegister == phase)) {
            startupphasetrees = startupphasetrees.concatenate(((Cons)(((TranslationUnit)(startupunits.first())).theObject)), Stella.NIL);
            TranslationUnit.clearTranslationUnit(((TranslationUnit)(startupunits.pop())));
          }
          if (!(startupphasetrees == Stella.NIL)) {
            startupphasetrees = Cons.list$(Cons.cons(Stella.SYM_STELLA_VOID_SYS, Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_WHEN, Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_SYS_CALL_FUNCTION, Cons.cons(Stella.SYM_STELLA_CURRENT_STARTUP_TIME_PHASEp, Cons.cons(IntegerWrapper.wrapInteger(Keyword.encodeStartupTimePhase(phase)), Cons.cons(Stella.NIL, Stella.NIL))))), Cons.cons(startupphasetrees.concatenate(Stella.NIL, Stella.NIL), Stella.NIL)))), Cons.cons(Stella.NIL, Stella.NIL))));
            if (Keyword.encodeStartupTimePhase(phase) <= Keyword.encodeStartupTimePhase(Stella.KWD_MODULES)) {
              earlystartuptrees = Cons.cons(startupphasetrees, earlystartuptrees);
            }
            else {
              startuptrees = Cons.cons(startupphasetrees, startuptrees);
            }
            startupphasetrees = Stella.NIL;
          }
        }
      }
      if (!(startuptrees == Stella.NIL)) {
        startuptrees = Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_WITHIN_MODULE, Cons.cons(((((Module)(Stella.$MODULE$.get())) == Stella.$STELLA_MODULE$) ? ((StandardObject)(Stella.SYM_STELLA_$STELLA_MODULE$)) : ((StandardObject)(Cons.list$(Cons.cons(Stella.SYM_STELLA_GET_STELLA_MODULE, Cons.cons(StringWrapper.wrapString(((Module)(Stella.$MODULE$.get())).moduleFullName), Cons.cons(Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_g, Cons.cons(Stella.SYM_STELLA_$STARTUP_TIME_PHASE$, Cons.cons(IntegerWrapper.wrapInteger(Keyword.encodeStartupTimePhase(Stella.KWD_MODULES)), Cons.cons(Stella.NIL, Stella.NIL))))), Stella.NIL), Stella.NIL))))))), Cons.cons(startuptrees.reverse().concatenate(Stella.NIL, Stella.NIL), Stella.NIL)))), Stella.NIL);
      }
      if ((!(earlystartuptrees == Stella.NIL)) ||
          (!(startuptrees == Stella.NIL))) {
        startuptrees = earlystartuptrees.reverse().concatenate(startuptrees, Stella.NIL);
      }
      return (startuptrees);
    }
  }