  Given an elliptic curve $E$ over $\mathbb{Q}$ and non-zero integer $r$, the
Lang--Trotter conjecture predicts a striking asymptotic formula for the number
of good primes $p\leqslant x$, denoted by $\pi_{E,r}(x)$, such that the
Frobenius trace of $E$ at $p$ is equal to the given integer $r$. We focus on
the CM case in this memoir, and show how to realize the following two goals:
  (1) to give an unconditional estimate for $\pi_{E,r}(x)$, which confirms the
upper bound part of the conjecture up to a constant multiple;
  (2) to give a conditional explicit asymptotic formula for $\pi_{E,r}(x)$
based on the Hardy--Littlewood conjecture on primes represented by quadratic
polynomials.
  For completeness, we also summarize classical results on quadratic, cubic and
quartic residues, as well as the corresponding reciprocity laws. This part
should be of independent interests and could provide useful materials for more
junior readers. We also highlight some possible extensions of the arguments in
this memoir that may work for other statistical problems of CM elliptic curves.
