WHEN Pope Francis declared recently that God might redeem atheists, nowhere did afterlife eligibility standards increase more broadly than Hollywood.

Although, as Francis cautioned, such redemption would be predicated on good works, and that clearly does not include "Hangover III."

A much more interesting case is "This is the End," a movie that could best be described as funny as hell. In no small part because it takes the pope's heaven-for-atheists idea and spins it into a horror-comedy about the moral panic of sinners on Judgment Day.

No, really.

"End" unfolds among celebrities attending a party at the home of James Franco (all actors play themselves). A nearby Hollywood sign pegs the location as Los Angeles, but certain guests behave as though they're at the intersection of Sodom and Gomorrah.

Michael Cera (doing his best Charlie Sheen) snorts mounds of coke and entertains groupies two at a time. Seth Rogen is high when he shows up, dragging an anti-social Jay Baruchel, who doesn't like Rogen's phony Hollywood friends - that means you, Jonah Hill.

Also on hand are other guys from "Pineapple Express" and "Superbad," not to mention Kevin Hart, Rihanna, Mindy Kaling, and, of all people, Emma Watson, of the "Harry Potter" movies.

The book of the day, however, is not "The Goblet of Fire." It's "Revelation." The ground trembles. Fire and brimstone rain from the sky. Beasts with cloven hooves (and Cialis prescriptions) roam the land. The earth splits open and swallows the wicked and when that happens, believe me, you don't want to be Mr. Cera.

Or any Hollywood personage, really. Blue shafts of light snatch up the faithful, not the famous. Salvation is suddenly the most exclusive club in SoCal, and self-absorbed celebrities are outside the velvet rope.

And inside Franco's house, where Rogen, Baruchel, Hill, Craig Robinson and Danny McBride confront the reality of apocalypse - poorly. They are a hilariously solipsistic, vain, cowardly, Darwinist bunch - it's like the "Titanic" and everybody is Billy Zane.

"The End" was co-written and directed by Rogen, and he and the others have savage fun at their own expense - jokes about "Flyboys" and "Green Hornet" and "Your Highness."

But "End" isn't a movie about people who've made awful movies.

It's about awful people, and how they react when they realize that someone's been keeping score after all.

It's Baruchel, hastily scanning the Bible as demons bang on the door, who suggests that they spend their few remaining hours being a little less selfish, so as to perhaps qualify for redemption. This produces some of the best movie comedy since Bill and Ted played Battleship with Death.

At the same time, "End" also engages in some fairly sophisticated moral algebra. The actors learn that you can't act "good" merely to meet some entrance requirement - sincerity counts. And if you do qualify for the blue pneumatic rapture tube, you must not gloat - a lesson that accounts for the funniest bit I've seen in movies this year.

"This is the End," for the devout, is a conundrum. It is flagrantly, screamingly R-rated. Like listening to Michael Douglas diagnose his throat ailments. It's vile. Vulgar. Obscene. Profane. Shameful.

And yet it has more spiritual density than 15 Kirk Cameron movies.

And, it's sinfully funny.

I don't know if it's the sort of good works that the pope had in mind, but I have heard that the Lord works in mysterious ways.