The shameless, gleefully sophomoric “Hangover Part III” poses the question, “If this is an R-rated comedy, what on earth would earn an NC-17?” Cocky Phil (Bradley Cooper), fidgety Stu (Ed Helms) and incorrigible Alan (Zach Galifianakis) stumble across the finish line of their misadventure trilogy in rare and raunchy form, dragging the boundaries for perverse comedy along with them.

The three bumbling amigos/sparring partners, who bonded during an epic bender on a Vegas bachelor party, come full circle here. Still cemented in their grudging love-hate for cuddly psycho Alan, his buddies agree to carpool him to a sanitarium.

Their intervention is interrupted by Mike Epps, reprising his role as drug-dealing Black Doug, and mob chief John Goodman, who send the simpleton Sherlocks on a do-or-die mission to capture their old nemesis Mr. Chow (Ken Jeong). The fey, ferocious gangster has evolved from a colorful footnote in the first film into a monster-clown in the tradition of Heath Ledger’s Joker.

Once again, the misadventures involve Sin City debauchery, casino rooftops, drugs, guns, kidnapping, call girls, wrecked cars and chickens. Lots of chickens.

“The Hangover” was a twisted mystery, with the ill-matched amnesiacs trying to unearth what happened during the catastrophic night before, when they tore up Sin City, blasted on Jagermeister and roofies. This episode is a standard catch-the-fugitive chase. “Memento”-style puzzles are unnecessary. The jagged interplay between the stars propels the movie. And this time writer-director Todd Phillips adds aggressively in-your-face gags about the homoerotic subtext of frat-boy humor.

Cooper, Helms and Galifianakis, virtually unknown in 2009, became overnight stars with the original “Hangover.” Now their characters are as well-established as the Three Stooges. Cooper, the straight man of the group, is loyal but with a timorous yellow streak that belies his action-hero looks. Helms is the prissy, professional man of reason (not a dentist, he’ll have you know, but a doctor of dental science), suppressing a kinky side that erupts with absurd consequences.

The most original creation is Galifianakis’ stunted, over-entitled rich boy. Still attached umbilically to his father’s money, Alan is a snobbish, hostile loser, covering up his loneliness with macho bluster. It’s a droll role spiced with just the right touch of melancholia.

The trio’s kettle-on-fire of simmering exasperation boils over often and uproariously. Anyone whose best pals drive them crazy (most of us, I’m guessing) will identify.

Melissa McCarthy shines as a Vegas pawnshop owner who just might be Alan’s match. Still, it’s Jeong who owns the movie. As the mad hatter comic villain, he’s a seething volcano of absurdist malice. He doesn’t just steal his scenes, he holds them captive, bound and gagged. Hang around for the now-traditional epilogue in the end credits and marvel at how far he’s willing to go for a surreal gag.