Finding integer coprime to a given number I yesterday asked here about whether or not the following can be proven:

If $x$ is an odd positive integer which is not a power of $3$, then we find some prime factor $p\geq 5$ of $x$ and some integer $0<a<x$ for which $a^2p^2+3ap+3$ is coprime to $x$.

As it turns out, this is indeed true, and John Omielan provided a nice and short proof for this. In fact, we can take any prime factor $p\geq 5$ of $x$, and define $a=\frac{x}{3^kp}$, where $k$ is the $3$-adic valuation of $x$.
What one can observe is that $0<a\leq\frac{x}{p}$. The last inequality is strict in case $x$ is divisible by $3$. It cannot be made strict in case $x$ is a prime number.
One may thus wonder if the following is true:

If $x$ is an odd positive integer which is neither prime nor a power of $3$, then we find some prime factor $p\geq 5$ of $x$ and some integer $0<a<\frac xp$ for which $a^2p^2+3ap+3$ is coprime to $x$.

Unfortunately, I believe the proof given by John Omielan cannot be applied to prove this. As stated above, it would suffice to prove this in case $x$ is not a multiple of $3$.
 A: As stated in the question, it's sufficient to consider $x$ with no factor of $3$. If $x$ is a prime power, i.e., it has only one prime factor $p$, then every $0 \lt a \lt \frac{x}{p}$ works since $p \nmid a^{2}p^{2} + 3ap + 3$. Otherwise, let $p = p_1$ be one of the prime factors of $x$, and $p_2$ be any other distinct prime factor of $x$. Then with $k = \operatorname{ord}_{p_2}(x)$ (i.e., the $p$-adic valuation of $x$), have
$$a_m = \frac{mx}{p_{1}p_{2}^{k}}, \; \; b_m = a_{m}p_{1} = \frac{mx}{p_{2}^{k}}, \; \; 1 \le m \le p_2 - 1 \tag{1}\label{eq1A}$$
Next, note that
$$\begin{equation}\begin{aligned}
y_m & = a_m^{2}p_{1}^{2} + 3a_{m}p_{1} + 3 \\
& = b_{m}^2 + 3b_{m} + 3 \\
& = (b_m + 1)(b_m + 2) + 1
\end{aligned}\end{equation}\tag{2}\label{eq2A}$$
Considering the second line of \eqref{eq2A}, all prime factors of $x$ other than $p_2$ divide the first & second terms, but not the third, so they are coprime with $y_m$.
Thus, we just need to find at least one $1 \le m \le p_2 - 1$ where $p_2 \not\mid y_m$. Note that $p_2 \not\mid b_m$, and each of the $p_2 - 1$ values of $b_m$ are distinct modulo $p_2$, so this means each value from $1$ to $p_2 - 1$ is congruent to a $b_m$ for some $m$. As such, there are values of $m$ where $b_m \equiv -1 \pmod{p_2}$ and $b_m \equiv -2 \pmod{p_2}$ which, using the last line of \eqref{eq2A}, shows that $y_m \equiv 1 \pmod{p_2}$. Similarly, there's a value of $m$ where $b_m \equiv -3 \pmod{p_2}$ so $y_m \equiv (-2)(-1) + 1 \equiv 3 \pmod{p_2}$. In all these cases, we have $p_2 \nmid y_m$. This proves there's always at least $3$ such $m$, with $a = a_m$, where $0 \lt a \lt \frac{x}{p}$.
