Not to mention, after Ted killed Benny, Gorrister, and Ellen, and Ellen killed Nimdok, AM was essentially trapped with nothing to do in the hell that it itself created, never even having memories of a past life it had happiness in.
Yep... that is why AM keeps trying to f**k with Ted's mind and perception of time during the end of the novel. It's basically trying one last ditch effort to torture him, but it doesn't even matter anymore, because with no reference point of time the torture will quickly become meaningless anyway. AM in reality is the one who ends up suffering even more, because his processors will keep running just as fast and he will always be just as aware, while Ted's mind at least has the mercy of insanity and dissociation. Unironically one of the most interesting downer endings I have ever seen.
THAT MOMENT WHEN YOU REALIZE... I HAVE NO MOUTH AND I MUST SCREAM, APPLIES JUST AS EQUALLY TO BOTH TED AND THE ALLIED MASTERCOMPUTER ITSELF, BECAUSE ALLIED MASTERCOMPUTER QUITE LITERALLY HAS NO MOUTH AND IT MUST SCREAM.