This answer refers to a version of the question in which $x$ is sampled by dividing two random numbers.
As mentioned by Rick Decker's answer, given $x$, we can approximate the running time by $O(\max(\log x,1))$. Assuming that rand returns a random number in $[0,1]$, the running time should be proportional (up to an additive constant) to
$$
\int_0^1 \int_0^1 \max(\log \tfrac{x}{y},0) \, dx \, dy.
$$
Let us start by computing the inner integral:
$$
\int_0^1 \max(\log \tfrac{x}{y},0) \, dx =
\int_y^1 \log \tfrac{x}{y} \, dx = (1-y)\log y + \int_y^1 \log x \, dx = \\
-(1-y)\log y + \left. x(\log x-1) \right|_y^1 = -(1-y)\log y-1-y(\log y-1) = \\
y-\log y-1.
$$
Integrating this over $y$, we get
$$
\int_0^1 (y-\log y-1) \, dy =
\left. \tfrac{1}{2} y^2 - y\log y \right|_0^1 = \frac{1}{2}.
$$
This shows that in this idealized setting, the expected running time is $O(1)$ (rather than infinity, which could also have been the case).