Had to put a local version of the ExprUsesVar visitor inside SpecializeBranchedLoops so that I could check if variables in my scope reference the var I am searching for.
Fixed a bug in my visitor that tests if an Expr or Stmt branches in a particular var. The scope was not being correctly populated with let bound vars.
Fixed a bug in specialize_branched_loops that was incorrectly counting free variables. By free variable in this case we mean a loop variable introduced by a For stmt. The fix was to explicitly track these variables in a scope and look up the free variables in that scope.