I am going to answer my question to share my knowledge. First of all, we note that instability occurs when x is near zero. However, we can also translate this as abs(x) << abs(y) . So, first we divide the plane (assuming that we are on the unit circle) into two areas: one, where |x| <= |y| |x| <= |y| and another, where |x| > |y| |x| > |y| as below:

We know that atan(x,y) is much more stable in the green area - when x is close to zero, we just have something close to atan (0.0), which is very stable numerically, while the usual atan(y,x) more stable in the orange area. You can also convince yourself that this relationship:
atan(x,y) = PI/2 - atan(y,x)
is executed for all non-origin (x, y), where it is undefined, and we are talking about atan(y,x) , which can return the value of the angle in the entire range -PI, PI, and not atan(y_over_x) which only returns the angle between -PI / 2, PI / 2. Therefore, our robust atan2() procedure for GLSL is pretty simple:
float atan2(in float y, in float x) { bool s = (abs(x) > abs(y)); return mix(PI/2.0 - atan(x,y), atan(y,x), s); }
As a side note, the identity for the mathematical function atan(x) is actually:
atan(x) + atan(1/x) = sgn(x) * PI/2
which is true because its range is (-PI / 2, PI / 2).
