Madness abounds in “The Accountant,” an intense, intricate, darkly amusing and action-infused thriller that doesn’t always add up but who cares, it’s BIG FUN.

The next time Ben Affleck runs into his old “Hunting” mate Matt Damon, they could have a legitimate debate about Affleck’s Christian Wolff vs. Damon’s Jason Bourne, covering at least three main points:

Who would win in a fight? They’re both crack shots, handy with all manner of weapons, masters in the art of hand-to-hand combat and fast healers when sustaining injuries that would mean lights-out for mere mortals. Who has the more obviously symbolic name — Jason Bourne (Again), who has to reinvent himself time and again, or Christian Wolff, a seemingly mild-mannered accountant savant who also is arguably the most dangerous killing machine on the planet, aka a Wolf in Sheep’s Clothing? Which one of these deeply troubled, always-on-the-move loners with serious father-figure issues would require more time on the therapist’s couch?

I’d call it a toss-up on all three fronts.

Affleck, a genuine movie star who has never been the most expressive of actors, puts his deadpan, tightly controlled charisma to perfect use as Christian. He’s autistic but on the highly functioning side of the scale: a genius accountant with math skills out of “A Beautiful Mind,” capable of taking care of himself — but lacking most basic social graces, obsessed with completing tasks, dependent on heavy doses of medication and susceptible to seizures.

Christian hides in plain site as a CPA with the ZZZ Accounting Firm in a strip mall in Plainfield, Illinois. (Note to the filmmakers: Plainfield is about twice as far from Chicago as the “20 miles” you mention in the title card.) He drives a truck, lives in a simple home with a nice backyard, keeps to himself — and waits for calls from a British-accented woman, who gives him his next assignment “un-cooking the books” for the highest-level criminal organizations around the world.

Sometimes Christian’s work involves moving tens of millions of dollars around. Sometimes it involves taking out some seriously bad people.

He’s not just an accountant. He’s … THE ACCOUNTANT.

The invaluable J.K. Simmons is the obligatory Law Enforcement Veteran on the Verge of Retirement, in this case one Ray King (the names in this movie!), the legendary head of the Treasury Department’s Crime Enforcement Division.

For the better part of a decade, Ray has been trying to learn the true identity of The Accountant. He enlists the help of Agent Marybeth Medina (an excellent Cynthia Addai-Robinson), essentially blackmailing her into finding The Accountant or face the consequences of her checkered past.

Working from a clever jigsaw puzzle of a script by Bill Dubuque, director Gavin O’Connor jumps back and forth from the present day to Christian’s childhood, with Seth Lee playing young Christian. We learn how Christian was molded into the fighting machine he’s become, and we’re also provided with repeated and obvious clues about the supposedly shocking twist that comes late in the story.

Anna Kendrick is smack dab in the middle of her acting comfort zone as Dana Cummings, a whip-smart accountant at a bio-medical robotics firm who notices a serious discrepancy in the books — which leads the head of the firm (John Lithgow) to bring in Christian to go through 15 years of insanely complicated ledgers to dig for possible malfeasance. Dana recognizes something of herself in the outsider Christian, and he develops a certain fondness for her, the closest thing to a human connection he’s ever known. (Dana tells a story about feeling like an outcast at Naperville North High School and wanting to buy an expensive Vera Wang gown so she could go to the prom and be noticed, just once.)

Jon Bernthal is a wisecracking assassin named Braxton who seems destined to cross paths with Christian. Jeffrey Tambor is Tambor-great as a convicted accountant who mentors Christian in prison.

Wearing unfashionable spectacles and a “Walk-Ins Welcome!” haircut, avoiding eye contact and speaking without any kind of filter, Affleck’s Christian is an oddball charmer who is funny because he’s almost never trying to be funny.

Christian takes his payment in cash, gold and priceless works of art, all of it hidden away in a trailer in a storage facility. His hobbies include painting emoji faces on cantaloupes and then shattering those cantaloupes at long-distance range with an anti-aircraft assault weapon. Each night, he assaults his senses with pounding music, pulsating electric lights — and occasionally pounding a rolling pin against his shin.

He’s a Bat-bleep version of Batman.

“The Accountant” is at its best when Christian is outsmarting all the other smart people, taking down henchmen and interacting with Kendrick’s Dana. The big-picture plot is wobbly and at times flat-out nuts; all of a sudden we’re in “The Usual Suspects” territory, but few films can match the mastery of that beautifully spun tale.

But it’s immensely satisfying. Just about everyone gets what he or she deserves, in more ways than one.

★★★1⁄2

Warner Bros. Pictures presents a film directed by Gavin O’Connor and written by Bill Dubuque. Rated R (for strong violence and language throughout). Running time: 128 minutes. Opens Friday at local theaters.