Todd Phillips scored a hit in 2003 with the raucous R-rated comedy Old School, then for some reason moved to tamer waters for Starsky & Hutch and School for Scoundrels, neither of which amounted to anything. Duly chastened, he now returns home with The Hangover, a movie that's as gleefully dirty as Old School, and maybe funnier.

It's a story of friendship, camaraderie, and alcohol. As such, it can only be set in Las Vegas. That is where Doug (Justin Bartha), who is getting married Sunday, is taken by his friends for an epic bachelor party: Phil (Bradley Cooper), a schoolteacher who hates his students almost as much as he hates being married, is the ringleader; Stu (Ed Helms), a wimpy dentist with a controlling shrew for a girlfriend, is the nervous nellie; Alan (Zach Galifianakis), Doug's soon-to-be brother-in-law, is the spacey, grubby, possibly mentally handicapped one who recalls Will Ferrell in Old School (which means he also recalls John Belushi in Animal House).

The four embark on a night of revelry. The next morning, Phil, Stu, and Alan wake up in their hotel suite with a tiger and a baby. There's no sign of Doug, the groom-to-be. And no one can remember anything that happened the night before.

As comedy premises go, this one is brilliantly simple. Three hungover guys stumble around Las Vegas in search of clues as to their missing friend's whereabouts, not to mention the origin of the baby and the tiger, and not to mention the other various things that have gone awry that, well, I won't mention. (Spoiler: Ed Helms is missing that tooth in real life.)

One perfectly constructed scene at an outdoor breakfast table hints at the sublime genius of the situation, with three well-defined comic characters bickering while examining their clothes, bodies, and memories for hints. It's good writing (from the Ghosts of Girlfriends Past duo of Jon Lucas and Scott Moore), and the trio of actors work together like seasoned pros.

Bartha is missing in action for most of the picture, so it's primarily the Helms-Cooper-Galifianakis show. Helms isn't much different from the way he appears on The Office (which is fine), Cooper has been developing his comedy chops in smaller roles the last few years, and Galifianakis -- wow. Fans of his standup won't be surprised by how funny he is, but I don't think anyone was expecting him to create a character as instantly classic as Alan. Whether misunderstanding basic human interactions, being suckered by an untrustworthy drug dealer, or thinking he can count cards like Rain Man, Alan is a treasure trove of WTF? moments. He's this summer's Brick Tamland or McLovin: the secondary character who steals the show.

This is the first film Phillips has directed that he wasn't credited with co-writing, too. I don't know how much to read into that; written by him or not, The Hangover clearly reflects his frat-boy sensibilities, and bless him for that. The movie, sunny and fast-paced from beginning to end, is intently focused not on life lessons or character development but on bawdy shenanigans and boisterous hijinks. It barely even bothers to let its characters learn anything. In fact, I was disappointed when the marriage-hating Phil came around to appreciating his wife and kid by the end. It was funnier when he considered them a burden.

About halfway in, the story starts veering into craziness (Mike Tyson? Angry Chinese gangsters?) without being any funnier than when it was in the realm of the vaguely plausible. You take a risk when comedy leaves the familiar and heads into crazyland, and it doesn't always pay off here, the cast's willingness to try anything notwithstanding. I also wonder about Heather Graham's character, a stripper who takes a liking to Stu. She seems like she ought to have more screen time, especially since she's played by a fairly well-known actress. I'm guessing some of her scenes got cut in favor of more no-girls-allowed male-bonding episodes.

A series of actors such as Jeffrey Tambor, Rob Riggle, Mike Epps, Matt Walsh, and the indispensable Ken Jeong parade through the film, giving it the feel of a movie that was at least as much fun to make as it is to watch. It's hard to be shocked by a comedy anymore, especially so soon after Observe & Report, but there are moments in The Hangover that ... well, just watch. Some of those images will be scarred on your retinas for years to come.