There is a lot of legal history of doing new designs with influence from reverse engineered sources. The basic rule is that you can't have someone familiar with the original code involved with writing the new code.
LLMs are a new area, but I would expect that feeding the original source into an LLM context and saying "Write this, but different" wouldn't qualify as a clean-room design. There isn't enough general removal from the original subject matter.
How and whether the same principles can be applied to LLMs, I have no idea. I imagine it would involve discussions about creativity, for example.
Not a lawyer.
If some people have now decided they're not going to blink in the face of a risk, we might get to find out whether some of the maybes turn out to be a yes or a no.
Probably impossible if the original code is publicly available since most code oriented LLM just gobble them all.
I have by now deviated quite a bit from the original (well, original...) spec.