I've accidentally written a procedure which appears to compute both outputs of a long-running function $f: \{0,1\} \to \{1...n\}$ using one run of $f$ plus $\mathcal{O}(n)$ time. I thought this couldn't be done. Where's the bug in my "perpetuum mobile"? If I'm wrong, what's the name of this technique?

* Initialize with $\sum\_ic\_i|i\rangle\_x$, with $c\_0$ initially, say, $\sqrt½$, and the invariant $\sum\_ic\_i^2 = 1$.
* Compute $f(x)$, producing: $\sum\_ic\_i|i\rangle\_x|f\_i\rangle$ (1). We never evaluate $f$ again, and our goal is to extract these $f\_i$.
* Produce:
$$
\sqrt½\sum\_ic\_i|i\rangle\_x|f\_i\rangle(|i^{|a|}\rangle\_a|f\_i\rangle\_b+2^{-|a+b|/2}\sum\_{rs}|r\rangle\_a|s\rangle\_b)
$$
* Measure and discard the $a$ and $b$ registers, getting (1) with $c\_0^2 \in \{1/(2+2^{|a|+|b|}), ½, 1-1/(2+2^{|a|+|b|})\}$, and in all probability we know which.
* Use amplitude amplification, where the good and bad subspaces are distinguished using the $x$ qubit, to get $c\_0^2$ between ⅛ and ⅞.
* Repeat the last 3 \*s a bunch of times.
* In all probability, we've measured $f\_0$ and $f\_1$.