I don't think these functions are programmed as it looks like they are in their Math form. Atan2 is something like a line-to rotating, if the given point is close to any pixel of line-to, returns how many times the line to is rotated. It is almost a motion but an algorithm. This is why I'm telling it is a brute force.
We can compute these things using iteration or polynomial approximations (sufficient for 64 bit).