While this code is pretty bad, I'm going to guess that the NSA reserves their best IT folks for... you know... the assignments other than their public facing website.
Agreed, this code was probably written by a contractor rather than one of their mathematicians I'd imagine
Have you seen mathematicians write code? For a website? We hired a few (we're in the crypto business) and we don't let them near production code. Ever.
General observation, mathematicians excel at functional v. imperative, partially because so many functional concepts are grounded in mathematics/logic.