public static String extractModuleNameFromStream(InputStream stream) {
    { Stella_Object tree = null;
      SExpressionIterator iter000 = InputStream.sExpressions(stream);
      int i = Stella.NULL_INTEGER;
      int iter001 = 1;
      int upperBound000 = 20;

      for (;iter000.nextP() &&
                (iter001 <= upperBound000); iter001 = iter001 + 1) {
        tree = iter000.value;
        i = iter001;
        i = i;
        if (Stella_Object.safePrimaryType(tree) == GuiServer.SGT_STELLA_CONS) {
          { Cons tree000 = ((Cons)(tree));

            { Stella_Object operator = tree000.value;
              String modulename = null;

              if (Surrogate.subtypeOfSymbolP(Stella_Object.safePrimaryType(operator))) {
                { Symbol operator000 = ((Symbol)(operator));

                  if (Stella.stringEqlP((((Module)(Stella.$MODULE$.get())).caseSensitiveP ? Native.stringUpcase(operator000.symbolName) : operator000.symbolName), "IN-MODULE")) {
                    modulename = Stella_Object.coerceToModuleName(tree000.rest.value, false);
                    if (modulename == null) {
                      { OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

                        stream000.nativeStream.print("Illegal IN-MODULE declaration: `" + tree000 + "'");
                        throw ((ReadException)(ReadException.newReadException(stream000.theStringReader()).fillInStackTrace()));
                      }
                    }
                    else {
                      return (modulename);
                    }
                  }
                  else {
                  }
                }
              }
              else {
              }
            }
          }
        }
        else {
        }
      }
    }
    return ("**NOTFOUND**");
  }