public static void extractStartupFunctionUnits(List startupunits, Symbol startupfnname) {
    { int remainingunits = startupunits.length();
      int minunitsperfunction = Native.floor((((double)(Stella.$MAX_NUMBER_OF_STARTUP_UNITS$)) / Stella.$STARTUP_TIME_PHASES$.length()) + 1);
      Cons cursor = startupunits.theConsList;
      Cons phasestart = cursor;
      int phaseunits = 0;
      Keyword phase = ((Keyword)(((TranslationUnit)(cursor.value)).codeRegister));
      Keyword unitphase = phase;
      int helpfncounter = 0;

      loop000 : while (!(cursor == Stella.NIL)) {
        unitphase = ((Keyword)(((TranslationUnit)(cursor.value)).codeRegister));
        if (unitphase == phase) {
          phaseunits = phaseunits + 1;
          if (phaseunits < Stella.$MAX_NUMBER_OF_STARTUP_UNITS$) {
            cursor = cursor.rest;
            continue loop000;
          }
        }
        if (phaseunits < minunitsperfunction) {
          phasestart = cursor;
          phaseunits = 0;
          phase = unitphase;
          continue loop000;
        }
        { Symbol functionname = Symbol.internDerivedSymbol(startupfnname, "HELP-" + startupfnname.symbolName + Native.integerToString(((long)(helpfncounter = helpfncounter + 1))));
          Cons helpfntree = ((Cons)(((TranslationUnit)(phasestart.value)).theObject));

          ((TranslationUnit)(phasestart.value)).theObject = Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_SYS_CALL_FUNCTION, Cons.cons(functionname, Cons.cons(Stella.NIL, Stella.NIL)))), Stella.NIL);
          phasestart = phasestart.rest;
          { ConsIterator it = phasestart.allocateIterator();
            int i = Stella.NULL_INTEGER;
            int iter000 = 2;
            int upperBound000 = phaseunits;
            boolean unboundedP000 = upperBound000 == Stella.NULL_INTEGER;

            for (;it.nextP() &&
                      (unboundedP000 ||
                       (iter000 <= upperBound000)); iter000 = iter000 + 1) {
              i = iter000;
              i = i;
              helpfntree = helpfntree.concatenate(((Cons)(((TranslationUnit)(it.value)).theObject)), Stella.NIL);
              TranslationUnit.clearTranslationUnit(((TranslationUnit)(it.value)));
              it.valueSetter(null);
            }
          }
          helpfntree = Cons.list$(Cons.cons(Stella.SYM_STELLA_DEFUN, Cons.cons(functionname, Cons.cons(Cons.list$(Cons.cons(Stella.NIL, Cons.cons(Stella.KWD_PUBLICp, Cons.cons(Stella.SYM_STELLA_FALSE, Cons.cons(Cons.list$(Cons.cons(Stella.SYM_STELLA_VOID_SYS, Cons.cons(Cons.cons(Stella.SYM_STELLA_PROGN, helpfntree.concatenate(Stella.NIL, Stella.NIL)), Cons.cons(Stella.NIL, Stella.NIL)))), Cons.cons(Stella.NIL, Stella.NIL)))))), Stella.NIL))));
          KeyValueList.setDynamicSlotValue(((MethodSlot)(Cons.helpWalkAuxiliaryTree(helpfntree, true).theObject)).dynamicSlots, Stella.SYM_STELLA_METHOD_STARTUP_CLASSNAME, StringWrapper.wrapString(Symbol.yieldStartupFunctionClassname(startupfnname)), Stella.NULL_STRING_WRAPPER);
          remainingunits = remainingunits - (phaseunits - 1);
          if (remainingunits <= Stella.$MAX_NUMBER_OF_STARTUP_UNITS$) {
            break loop000;
          }
          if (unitphase == phase) {
            cursor = cursor.rest;
          }
          phasestart = cursor;
          phaseunits = 0;
          phase = ((Keyword)(((TranslationUnit)(cursor.value)).codeRegister));
        }
      }
      startupunits.remove(null);
    }
  }