Many of Tor's complex functions should be refactored

See some discussion on #6177 (moved).

I'm attaching a list of the most complex functions in Tor (by cyclomatic complexity).

Possibly cyclomatic-complexity-per-line would be another good thing to look at.