As someone pointed out to me on another thread, he could have bought it illegally through a friend or whatever.
As far as I know, mental illness would probably negate his ability to legally own a gun, let alone a fully automatic weapon.
At least we’ve dispatched the notion that any gun he would plausibly be possessing is required to be registered.