Implemented div/powmod/gcd that take tmps as params