Hybrid Sequence:
The starting point of the hybrid proof is library $\lib{xor-samp-1}$.
We first introduce a new variable $X'$, which is not used anywhere. This change has no effect on the calling program.
You can check for yourself (using the algebraic properties of \xor) that $X$ and $X'$ always hold the same value. It therefore has no effect on the calling program to change a reference to $X$ into a reference to $X'$.
We want to argue that $Y$ is uniformly distributed, and we can do so by observing that $Y$ looks like an OTP ciphertext with $X$ as the key and $M$ as the plaintext. To use this fact, we first ``factor out'' the computation of $Y$ in terms of the $\lib{otp-real}$ library from \claimref{provsec.clm.otp}. Factoring out these statements leaves us with a compound library, but has no effect on the calling program.
Now we are in a situation where we can use \claimref{provsec.clm.otp} and the chain rule (\claimref{provsec.clm.chain-rule}). Replacing $\lib{otp-real}$ with $\lib{otp-rand}$ in this compound library (while keeping the other part $\lib{hyb-3-4}$ the same) has no effect on any calling program.
It has no effect on the calling program to inline a subroutine call.
Finally, we globally rename variable $X'$ to $X$. This change clearly has no effect on the calling program. The result is the library $\lib{xor-samp-2}$.
$\lib{xor-samp-1}$
sample($M$):
$X \gets \bits^n$
$Y $
${}:= {}$
$X \oplus M$
$\otpenc(M)$
${}\gets \bits^n$
return
$(X,Y)$
$(X',Y)$
$(X,Y)$
$\link$
$\lib{otp-real}$
$\otpenc$($\ptxt$):
$\key \gets \bits^n$
$\ctxt := \key \oplus \ptxt$
return $\ctxt$
$\lib{otp-rand}$
$\otpenc$($\ptxt$):
$\ctxt \gets \bits^n$
return $\ctxt$