I'm reading quantum computation in Arora and Barak, on page 215 they provide the Lemma 10.10 proving that quantum circuits can simulate boolean circuits.
Lemma 10.10 (Boolean circuits as a subcase of quantum circuits) If $f :\{0,1\}^n\rightarrow\{0, 1\}^m$ is computable by a Boolean circuit of size $S$ then there is a sequence of $2S+m+n$ quantum operations computing the mapping $|x0^{2m+S}\rangle\rightarrow |x\rangle\,|f(x)0^{S+m}\rangle$.
Proof: Replace each Boolean gate (AND, OR, NOT) by its quantum analog as already outlined. The resulting computation maps $|x\rangle\,|0^{2m}\rangle\,|0^S\rangle\rightarrow |x\rangle\,|f(x)0^m\rangle\, |z\rangle$, where $z$ is the string of values taken by the internal wires in the Boolean circuit (these correspond to scratchpad memory used by the quantum operations at the gates) and the string $0^m$ consists of qubits unused so far. Now copy $f(x)$ onto the string $0^m$ using $m$ operations of the form $|bc\rangle\rightarrow |b(b\oplus c)\rangle$. Then run the operations corresponding to the Boolean operations in reverse (applying the inverse of each operation). This erases the original copy of $f(x)$ as well as $|z\rangle$ and leaves behind clean bits in state $|0\rangle$, together with one copy of $f(x)$.
How do we write $f(x)$ immediately after $x$ after applying the gates to get $|x\rangle\,|f(x)0^m\rangle\, |z\rangle$? As far as I know, the "reversible Boolean gates", for example, the "reversible AND" gate is to map $|b_1b_2b_3\rangle\rightarrow|b_1b_2\rangle\,|b_3\oplus(b_1\land b_2)\rangle$, so the result, say, $f(x)$ should be placed after $z$.
Furthermore, why must we copy $f(x)$ onto the unused $0^m$ before reversing the previous operations to erase the original copy of $f(x)$ and $|z\rangle$? In particular, at the state $|x\rangle\,|f(x)0^m\rangle\,|z\rangle$, why don't we just reverse the operations compute $z$ to get $|x\rangle\,|f(x)0^{S+m}\rangle$, but copying $f(x)$ onto $0^m$ to gain $|x\rangle\,|f(x)f(x)\rangle\,|z\rangle$ before reversing? I do not understand the term "reversible" in quantum computation at all.