Begin splitting out the large chunks of functional logic from the
syscall handler into separate helper functions. This keeps it separate
from the syscall control-flow logic, resulting in better readability
overall. It also wins back a level of indentation.
Try to keep copyin()/copyout() calls outside of the helper functions in
most cases. The changes are intended to have no functional impact, but
do address style issues.