You may be tempted to walk out of “Daddy’s Home” after ten minutes or so; the opening reel of the picture is that bad. Rest assured, however, that though limply directed by Sean Anders, it gets better—though not enough to go beyond mediocrity. And parents should be warned that though its slapstick might quality as suitable for family-oriented entertainment, its raunchiness certainly doesn’t.

The movie reunites Will Ferrell and Mark Wahlberg, who first teamed in “The Other Guys,” where they were ill-matched police detectives, one primly rule-bound and the other the proverbial loose cannon. This time around they’re rivals for the affection of two obnoxious moppets, with Ferrell the milquetoast stepdad and Wahlberg the rough-and-tumble biological father who returns unexpectedly to make sure his kids don’t bond with “the other dad.”

Ferrell’s Brad Whitaker is a middle-management guy at a “smooth jazz” radio station who’s doing everything he can to make his stepkids Megan (Scarlett Estevez) and Dylan (Owen Vaccaro) like him while their mom Sara (Linda Cardellini, bland) tolerates their insulting the poor schlub at the drop of a hat. (Isn’t it just a riot to hear the girl call him a “little bitch” when he cries?) Still Brad perseveres like a saint, and when Sara’s ex Dusty (Wahlberg) calls up, he’s too dumb to concoct a reason why the guy shouldn’t stay with them for a spell.

Thus begins the men’s battle for the children’s love, with Brad too stupid to realize that Dusty is using the situation to undermine him at every turn despite warnings to that effect from his cynical, foul-mouthed boss (Thomas Haden Church, barely going through the motions). So even when Brad, encouraged by Dusty, revs up an overpowered motorcycle and crashes it into the house, he shakes it off as an accident; and when Dusty encourages Brad to fire Griff (Hannibal Buress, appearing to sleepwalk throughout), the black contractor hired to repair the damage, so that they can fix the house themselves, it leads to Griff charging Brad with racism and the repentant Brad taking the fellow in as an unwanted houseguest. Before long Dusty has pretty much taken over not only the homestead but Brad’s workplace, where he’s hired as the new on-air “voice” of the station (and is soon making more than Brad).

By this time even a dullard like Brad has gotten wise to Dusty’s schemes. But when he tries to challenge his rival on a skateboard, he winds up sailing into a nearby electric line—leading Dusty to teach the urchins CPR. His final, desperate ploy is to buy horrendously expensive tickets for a Lakers game, only to have Dusty score seats behind the bench; that leads him to drink himself to oblivion and throw a basketball into a cheerleader’s face during a half-time stunt. (He’ll also stage a spring version of Christmas, literally trying to buy the kids’ affection–the materialistic slant of the script gets cringingly obvious at times. Even worse, the sequence features a shot of a grubby dog Dusty has named Tumor humping a Mrs. Santa Claus doll. How droll.)

All of that is bad enough, but it pales beside a truly icky sub-plot involving Brad’s infertility, the result of an accident with a dental x-ray machine (which is shown in an excruciating flashback). Dusty takes him and Sara to a clinic run by his pal (Bobby Cannavale, mugging awfully), which introduces some sleazy humor involving testicles and sperm that seems radically out of place in a PG-13 rated family flick.

Of course Brad and Dusty join together in the end for the benefit of the kids—at a daddy-daughter school dance where Dylan must also confront the bully who’s been tormenting him. The outcome features one of those quirky twists that Ferrell seems to invite, but on the negative side it also gives him the chance to strip off his shirt and once again exhibit, as he has done so often, his flabby physique. There’s also a coda in which Dusty finds what it’s like playing the stepdad against somebody even more muscled that he—wrestler John Cena, who’s making a habit of appearing in fare like this (see “Trainwreck” and “Sisters”). One fervently prays it doesn’t mean a sequel is on the way.

Thoroughly pedestrian in both conception and execution when it’s not downright offensive, this is a movie that might have its heart in the right place. Now, as the Tin Man might say, if it only had a brain!