Dealing with a legacy code is a nightmare. They are written in old ways using old language features. no comments or description. thousands of lines
(1) take a simple example and debug the code
(2) convert it to a language that you are familiar with (say matlab or python from complicated c) using chat GPT or any AI and then analyze it
(3) once you understand the code or function, prepare a document on that (at least, in high level), otherwise when you come after several months or years, you need lot of time to understand it
(3) add comments to code (e.g. for a function, define inputs outputs clearly, what is the purpose of the function, any reference documents/papers etc. )
happy coding