No you're right, this code is terrible. Running a linter like clang-tidy would surface many issues. Not sure why the LLM didn't think of ever doing that.