I am reading the book "***Opera de Cribro - John B. Friedlander, Henryk Iwaniec***" and in pages 5,6 I do not understand why and how they chose $X$, $A(x)$, $A_d(x)$ and $g(p)$.

any hints will be appreciated.

[![enter image description here][1]][1]


[![enter image description here][2]][2]


  [1]: https://i.sstatic.net/5ygT4.jpg
  [2]: https://i.sstatic.net/NIxPU.jpg