Sort the control regexps topoligically to improve the generated code.

When they are sorted topologically, we all the control transitions can be
evaluated in one pass. When that could not be done we use the previous slow code
instead.