Modify skip stages support to handle external array functions. Code is
perhaps a bit ad hoc, but should be reliable.

Add test for skipping calls to external array functions. Based on
existing skip_stages support and covers all the same cases.
Add additional checks to verify the right number of bounds inference queries.