run strace or ltrace on it;
grep: works better with editor assistance, such as emacs M-x grep;
write documentation for it;
factor out parts of it;