With all this preparation done, emitting the file boils down to a single function call: PM.run(*M); The ToolOutputFile class automatically…