Specialize branched loops

Continuation of PR #469 inside the main repo.
It looks like you can maybe *almost* statically compute the size of new_args before generating it. Since it isn't used if it is too big, it seems like it could avoid a significant amount of work if you used an upper bound on the size of new_args to avoid exceeding branching_limit. I assume branching_limit is fairly arbitrary anyways.

At the very least, would it be worth checking branching_limit up front, so if the limit is exceeded right from the start it doesn't bother doing the work of constructing new_args?