In this particular case, the answer is: none
fair use is any copying of copyrighted material done for a limited and “transformative” purpose, such as to comment upon, criticize, or parody a copyrighted work.
(source)
What you are describing is the creation of a derivative work, which falls entirely under copyright laws the moment you use any of the original code at all.
And since the GPL is a copyleft licence, by using code that is covered by the GPL, your entire software can now be distributed only under the terms of the GPL. Thank you for your (involuntary) contribution to Free Software.
The way to avoid this scenario is to either write all the code internally, or if you absolutely want to copy how someone else did it without getting into copyright issues, to use a clean-room implementation where the people actually writing the code never see the design you are copying and instead have it explained to them by those who have. With good procedures and extensive documentation of what exactly passed between these two teams.
In most cases, proper clean-room implementations are more effort than just writing it all from scratch.