I'd start by buying a compression tester and checking the compression on each cylnder to see if anything is bent or broken, which would be shown by an extreme drop of pressure compared with the others, or low readings in general. After you make sure that the engine has avoided enough damage to at least build decent compression across the board, then I'd worry about taking it to a shop to get a leakdown test done and having that code sorted out.