Seems hard to reverse engineer since there are many template variables input.
What I have done is take the old C5 template and delete everything after the user interface (#Display and #Prompt) to preserve the %Variables.
Search for the first #AT* and delete all that code but leave the #EMBED’s (probably).
The #PREPARE may need some changes.
Delete #GROUP’s only if they cause errors.
Look for any #PROJECT() left and see they are not a problem, e.g. adding a C5 DLL.