I tried cleaning it up a bit: https://gist.github.com/lukechampine/f54fce8fd756254cefb2
But the actual meaning of the program is still lost on me. I can only guess it has something to do with parsing files (note the checks for curly braces). Feeding it its own source code produces some output, but I have no idea what it actually modified.