Ask about a non-RE language I have a question about undecidability. And I hope you could point out where I am wrong.

The question is: to decide the following question as (A) recursive, (B) RE but not recursive, (C) not RE.

$L = \{\langle M\rangle|M \text{ is a TM and } |L(M)| \geq 3\}$

If we use $HP$ as halting problem and $\overline{HP}$ as the complement of halting problem. Then the solution could be (B) RE but not recursive (Taken from the Internet):



I understand this proof. But I have another proof as follows, and I can't figure it out why it is wrong.



We prove this by a reduction from $\overline{HP}$. Simulate $M'$ on input $w$ works as follows: it runs $M$ on $x$ and rejects if $M$ halts on $x$.

(1) $\langle M, x\rangle \in \overline{HP}$ $\rightarrow$ $M$ doesn't halt on $x$ $\rightarrow$ $M'$ accepts all inputs $\rightarrow$ $|L(M')| \geq 3 $ $\rightarrow$ $M' \in L$

(2) $\langle M, x\rangle \notin \overline{HP}$ $\rightarrow$ $M$ halts on $x$ $\rightarrow$ $M'$ doesn't accept any input $\rightarrow$ $|L(M')| &lt; 3$$\rightarrow$ $M' \notin L$

Thus $\overline{HP} \leq_m L$. As $\overline{HP}$ is not RE, $L$ is not RE, which is wrong.



So where is wrong?

Thanks!
Recall that if a TM $M$ doesn't halt on input $x$, then $x \notin L(M)$

Your mistake is in (1), if $M$ doesn't halt on $x$, then $M'$ doesn't halt too (since the simulation of $M$ on $x$ doesn't halt). so  $M'$ doesn't accept any input, that is $L(M')=\phi$.