\newcommand{\newtheoremstyle}[9]{%
\@ifempty{#5}{\dimen@\z@skip}{\dimen@#5\relax}%
\ifdim\dimen@=\z@
\toks@{#4\let\thm@indent\noindent}%
\else
\toks@{#4\def\thm@indent{\noindent\hbox to#5{}}}%
\fi
\def\@tempa{#8}\ifx\space\@tempa
\toks@\@xp{\the\toks@ \thm@headsep\fontdimen\tw@\font\relax}%
\else
\def\@tempb{\newline}%
\ifx\@tempb\@tempa
\toks@\@xp{\the\toks@ \thm@headsep\z@skip
\def\thmheadnl{\newline}}%
\else
\toks@\@xp{\the\toks@ \thm@headsep#8\relax}%