If $p_A(x) = x^4 (x+3)^2 (x-4)$ then $A$ is diagonalizable iff $\operatorname{Rank}(A) + \operatorname{Rank}(-3I-A) = 8$ 
Given the Characteristic polynomial of a matrix $A$ is
  $$
  p(x) = x^4 (x+3)^2 (x-4),
$$
  show that $A$ is diagonalizable if and only if
  $$
  \operatorname{Rank}(A) + \operatorname{Rank}(-3I-A) = 8.
$$


Given: $A$ is diagonalizable
Prove: $\operatorname{Rank}(A) + \operatorname{Rank}(-3I-A) = 8$
(Help is needed in the other way around)
The geometric multiplicity equals the algebraic multiplicity, hence the diagonal matrix $D$ will look like
$$
    D
  = \begin{pmatrix}
      -3  &     &   &   &   &   &   \\
          & -3  &   &   &   &   &   \\
          &     & 4 &   &   &   &   \\
          &     &   & 0 &   &   &   \\
          &     &   &   & 0 &   &   \\
          &     &   &   &   & 0 &   \\
          &     &   &   &   &   & 0 
    \end{pmatrix}
$$
Since $D$ and $A$ are similar matrices, their rank must be the same:
$$
 \operatorname{Rank}(A) = \operatorname{Rank}(D) = 3.
$$
Also
$$
    -3I - A
  = \begin{pmatrix}
      0 &   &     &   &     &     &     \\
        & 0 &     &   &     &     &     \\
        &   & -7  &   &     &     &     \\
        &   &     & 0 &     &     &     \\
        &   &     &   & -3  &     &     \\
        &   &     &   &     & -3  &     \\
        &   &     &   &     &     & -3 
    \end{pmatrix}
$$
and therefore
$$
    \operatorname{Rank}(A) + \operatorname{Rank}(-3I-A)
  = 3 + 5
  = 8.
$$
Perfect.
(Is it okay to place $D$ instead of $A$ in $\operatorname{Rank}(-3I-A)$? The rank will be the same, is it not?)

Given: $\operatorname{Rank}(A) + \operatorname{Rank}(-3I-A) = 8$
Prove: $A$ is diagonalizable
No clue really…
I was thinking since geometric multiplicity is less or equal to algebraic multiplicity, I was thinking of finding all possible $D$'s and show that the one that makes the statement $\operatorname{Rank}(A) + \operatorname{Rank}(-3I-A) = 8$ hold makes $A$ diagonal.
Any hint is appreciated.
 A: Look at the possible Jordan form of $A$ 
$$
\begin{bmatrix}
-3 & * & 0 & 0 & 0 & 0 & 0\\
0 & -3 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 4 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & * & 0 & 0\\
0 & 0 & 0 & 0 & 0 & * & 0\\
0 & 0 & 0 & 0 & 0 & 0 & *\\
0 & 0 & 0 & 0 & 0 & 0 & 0
\end{bmatrix}
$$
(* elements are $0$ or $1$) to deduce that 


*

*$\operatorname{rank}A\ge 3$ and
$\operatorname{rank}A=3$ $\iff$ the block with eigenvalue $0$ is diagonal.

*$\operatorname{rank}(-3I-A)\ge 5$ and
$\operatorname{rank}(-3I-A)=5$ $\iff$ the block with eigenvalue $-3$ is diagonal.


Therefore, $\operatorname{rank}A+\operatorname{rank}(-3I-A)\ge 8$ and $\operatorname{rank}A+\operatorname{rank}(-3I-A)=8$ $\iff$ $\operatorname{rank}A=3$, $\operatorname{rank}(-3I-A)=5$. Then...
P.S. To answer your question "is it ok to place $D$ instead of $A$ in $\operatorname{rank}(-3I-A)$": yes, it is ok, since $-3I-A$ and $-3I-D$ are similar as well
$$
\lambda I-A=\lambda I-SDS^{-1}=\lambda SS^{-1}-SDS^{-1}=S(\lambda I-D)S^{-1}.
$$
A: Observe that the problem for diagonalization comes from the eigenvalues $\;0,\,-3\;$ , for which it isn't sure their geometric multiplicity = algebraic multiplicity.
If we denote by $\;V_\lambda\;$ the eigenspace corresponding to the eigenvalue $\;\lambda\;$ ,then it must be that 
$$\;\dim V_0=4\,,\,\,\dim V_{-3}=2\iff \dim V_0+\dim V_{-3}=6$$
the last double arrow and inequality following from the almost trivial fact that $\;V_0\cap V_{-3}=\{0\}\;$
But  by the dimensions theorem we get
$$\dim V_0=\dim\ker A=4\implies\text{rank}\,A=7-\dim\ker A=7-\dim V_0=3$$ and also
$$\dim V_{-3}=\dim\ker(A+3I)\le2\implies 5\le\text{rank}(A+3I)\le6$$
where we used in the last inequality that $\;A+3I\;$ is singular, so now do your math since
$$\text{rank}\,A+\text{rank}\,(A+3I)=8\implies \text{rank}\,(A+3I)=5\implies\ldots$$
