Sneak Attack reads: put a creature card from your hand onto the battlefield. That creature gains haste. Sacrifice it at the beginning of the next end step. The key point is that the sacrifice is a triggered ability that goes on the stack at the beginning of the end step — it does not happen immediately.
Because the creature enters with haste (CR 702.10), it can attack and also activate or be used as a sacrifice target the same turn it enters, even though it was just put onto the battlefield (CR 302.6 covers the general rule that creatures with haste are exempt from summoning sickness).
Altar of Dementia is an activated ability you can use any time you have priority. You can activate it during your main phase (or even during combat) to sacrifice the Sneak Attack creature before the end step ever arrives. If you sacrifice the creature this way, it is already gone when the end-of-turn trigger would try to sacrifice it, so the trigger simply fails to find a legal target/object and does nothing (CR 603.4).
Concrete example: You use Sneak Attack to put Emrakul, the Aeons Torn onto the battlefield. It gains haste. You attack with it for 15, triggering its annihilator ability. After combat, in your second main phase, you activate Altar of Dementia, sacrificing Emrakul to mill 15 cards. When your end step arrives, Sneak Attack's trigger sees Emrakul is no longer on the battlefield and simply does nothing.
This is a well-known synergy in Commander and Legacy combo decks. The sacrifice to Altar of Dementia is entirely legal and preempts Sneak Attack's cleanup trigger.
Unofficial fan resource — not affiliated with or endorsed by Wizards of the Coast. Answers are AI-generated estimates grounded in the Comprehensive Rules and are not a substitute for an official judge. Verify anything match-critical.