Bain Capital bagged a fortune as an Oregon-based software company it owned fired workers. Now, federal authorities allegedly are probing whether those firings broke the law.

The buyout firm founded by Mitt Romney faces an investigation by the US Equal Employment Opportunity Commission over allegations that Viewpoint Construction Software illegally fired workers based on their age and medical condition as it sought to maximize profits under Bain’s direction, sources told The Post.

Last week, Bain announced the sale of the Portland, Ore.-based company to its larger competitor Trimble for $1.2 billion. Bain will reap a $550 million profit on the deal after investing just $300 million in cash to acquire it in 2015 and saddling it with roughly $330 million in debt, sources said.

Meanwhile, however, the EEOC has received roughly 20 separate complaints about illegal firings at Viewpoint, according to Jan Sadlowski, a former human resources manager at the company. The flaggings sparked an investigation by the agency, which most recently interviewed a former Viewpoint employee last week, she said. It’s not clear whether Bain itself is being targeted in the probe, sources said.

A source close to Bain said the firm is only aware of 9 Viewpoint-related complaints. An EEOC spokeswoman said all charges and investigations are strictly confidential.

In August 2015, Bain hired Manolis Kotzabasakis to replace founder Jay Haladay as the company’s chairman and chief executive. Soon after, the new CEO and his new head of HR Joanna Nikka set a target to cut 182 of the 760 employees then working at the company, Sadlowski said.

They then allegedly asked HR staff to create a spreadsheet that listed all workers who either were making more than $125,000 a year or more than 40 years old. While it’s legal to fire people because their salaries are high, age discrimination is a federal crime.

The executives likewise wanted lists of employees getting benefits under the Americans with Disabilities Act (ADA), the Family and Medical Leave Act (FMLA) and the Oregon Family Leave Act (OFLA), all of which guarantee leave with no threat of job loss, according to multiple sources.

Evidence surfaced in the May 2017 court deposition of Jennifer Yruegas, Viewpoint’s former vice president of human resources, who testified in litigation over another executive’s departure that she was pressured by the new CEO to compile the spreadsheet ahead of a bloodbath.

Kotzabasakis told Yruegas, “I think you should create the spreadsheet,” Yruegas told lawyers. Meanwhile, Yruegas testified that Nikka, her supervisor in HR, told her, “I am going to use this information for layoff purposes.”

Yruegas said she believed that was privileged employee information, and that she quit in early 2016 instead of providing the data.

Sadlowski says Nikka’s demands to her were similarly blunt: “I’m sick of having our insurance crunched with a bunch of old people,” Nikka said, according to Sadlowski.

“They wanted me to illegally fire people,” Sadlowski told The Post.

Viewpoint fired Sadlowski in 2016 shortly after she complained to the Viewpoint board, including Bain Capital Managing Director David Humphrey, she alleges. The Post has reviewed her letter.

Bain also ignored labor laws as it acquired businesses overseas, demanding that they use the same roughshod criteria in the UK and Australia that they used in the US, Sandlowski said.

“Her answer to me when I questioned her about not wanting to break the law was I needed to do what she told me and if there were any issues we could just pay the people [foreign authorities] off,” Sandlowski said of Nikka.

When reached Sunday by a reporter from The Post who asked about Viewpoint, Nikka said, “I don’t want to take this call,” and hung up.

Bain, which recently has gotten unwanted attention for leading Toys ‘R’ Us and iHeart Media into bankruptcy, declined to comment.

Kotzabasakis couldn’t immediately be reached for comment. Viewpoint said in a statement that it hired an independent firm to review the complaints, and that its report found no evidence of bias.

“We unequivocally deny wrongdoing in this matter, and continue to celebrate our commitment to a diverse, engaged workforce,” the company said.