Best way to find a segment of code (output) that matches a given input segment?

I need to develop an application where I give an llm a piece of code, like a function, and then the llm finds the closest match that does the same thing. It would look in one or more source files. The thing found may be worded differently. If the search finds the identical code then it should consider that the match.

Is this feasable at all? How hard would this be to develop? Thanks in advance.