[step:Prove case (iv): when $d = 0$, the form is a multiple of a perfect square]
Assume $d = 0$, i.e. $b^2 = 4ac$. We consider two cases.
If $a \neq 0$, the identity from the first step gives
\begin{align*}
4a\, f(x, y) = (2ax + by)^2 - 0 \cdot y^2 = (2ax + by)^2.
\end{align*}
So
\begin{align*}
f(x, y) = \frac{(2ax + by)^2}{4a}.
\end{align*}
We want to display $f$ as $l(mx + ny)^2$ with integer $l, m, n$. If $a > 0$, let $g = \gcd(2a, b) \geq 1$ and write $2a = gm$, $b = gn$ with $m, n \in \mathbb{Z}$ and $\gcd(m, n) = 1$. Then $2ax + by = g(mx + ny)$ and
\begin{align*}
f(x, y) = \frac{g^2 (mx + ny)^2}{4a} = \frac{g^2}{4a} (mx + ny)^2.
\end{align*}
Since $f$ has integer values on $\mathbb{Z}^2$ and $(mx + ny)^2$ takes arbitrary non-negative integer values as $(x, y)$ ranges over $\mathbb{Z}^2$ (in particular the value $1$, achieved because $\gcd(m, n) = 1$ implies $\exists (x, y) \in \mathbb{Z}^2$ with $mx + ny = 1$ by [Bezout](/theorems/???)), the rational number $l := g^2/(4a)$ must itself be an integer. Hence $f(x, y) = l(mx + ny)^2$ with $l, m, n \in \mathbb{Z}$. The case $a < 0$ is identical after absorbing a sign into $l$.
If $a = 0$, then $b^2 = 4ac = 0$, so $b = 0$ too, and $f(x, y) = cy^2 = c(0 \cdot x + 1 \cdot y)^2$, which is of the required form with $l = c$, $m = 0$, $n = 1$.
[/step]