I am trying to replicate the style of the following pseudocode.

The following minimal working example almost produces what I want except the extra vertical space between lines 7 and 8. How can I resolve this issue? Is there an easier way to format pseudocodes this way?
\documentclass[12pt]{article}
\usepackage[noend]{algpseudocode}
\setlength\parindent{0pt}
\newcommand{\Def}[3]{\textbf{#1}\ \textsc{#2}\ifthenelse{\equal{#3}{}}{}{(#3)}}
\algrenewcommand{\alglinenumber}[1]{\footnotesize#1\hspace{1em}}% <- This line
\begin{document}
\Def{procedure}{Euclidian}{$a,b$}
\begin{algorithmic}[1]
\State $x \gets a$
\State $y \gets b$
\While{$x \not= y$}
\If{$x < y$}
\State $x \gets x - y$
\Else
\State $y \gets y - x$
\EndIf
\EndWhile
\State \textbf{return} $x$
\end{algorithmic}
\end{document}
Edit I have tried clrscode3e this time. It worked, but required me to hack the package code. I still wonder if there is an easier solution.
\documentclass[12pt]{article}
\usepackage{clrscode3e}
\setlength\parindent{0pt}
% Restore \gets
\let\gets=\leftarrow
% Print 'do' and 'then'
\renewcommand{\Do}{\textbf{do}\addtocounter{indent}{1}}
\renewcommand{\Then}{\textbf{then}\addtocounter{indent}{1}}
% Indent recursively (\hspace is used instead of \>)
\renewcommand{\putindents}{\ifnum\value{thisindent}>0%
\hspace{1.5em}\addtocounter{thisindent}{-1}\putindents%
\fi}
% Line number separation (hspace is added)
\makeatletter
\renewcommand{\liprint}{\protected@xdef\@lilabel{\thecodelinenumber}%
\ifnumberedline\thecodelinenumber\fi\'\hspace{0.25em}\Indent%
}
\makeatother
\begin{document}
\begin{codebox}
\Procname{\textbf{procedure} $\proc{Euclidian}(a,b)$}
\li $x \gets a$
\li $y \gets b$
\li \While $x \not= y$ \Do
\li \If $x < y$ \Then
\li $x \gets x - y$
\li \Else
\li $y \gets y - x$
\End
\End
\li \Return $x$
\end{codebox}
\end{document}
Edit 2 The patch proposed by @egreg fixes vertical alignment, but I have one more issue. In the first MWE, the marked line left-aligns the line numbers by increasing the separation. However, it cannot handle multidigit line numbers. What are your suggestions?

noendis the culprit – DG' Feb 07 '18 at 15:29