A quip attributed to the late Sen. Everett Dirksen - "A billion here, a billion there, pretty soon you're talking about real money" - is coming painfully true for federal bank regulators.

The $4 billion rescue of First RepublicBank Corp. of Dallas and the closing and rescue of other banks this year will cause the government insurance fund that backs deposits in commercial banks to suffer the first loss in its 54-year history.Add in billions of dollars being spent to assist the even more troubled savings and loan industry and it means "real money" - enough to hamper the government's fight to curb the massive federal budget deficit.

Money spent by the federal deposit insurance agencies - the Federal Deposit Insurance Corp. for the nation's 13,500 commercial banks and the Federal Savings and Loan Insurance Corp. for 3,100 savings institutions - does not come from taxpayers, at least not yet. Both the FDIC and the FSLIC derive their money from an assessment on member institutions.

However, revenue to the funds counts as a government receipt for federal budget purposes. When spending exceeds receipts, it inflates the budget deficit, projected by the administration to hit $152.3 billion for fiscal 1988.

So far this year, FSLIC has had two multibillion-dollar transactions. It spent $2 billion to help Southwest Savings Association of Dallas take over four smaller institutions in May and $1.3 billion a month later to close two severely insolvent S&Ls in Costa Mesa, Calif.

FSLIC is looking at spending $1.3 billion to $2 billion more early this fall on Irvine, Calif.-based Financial Corp. of America, the nation's second-largest thrift holding company.

It's unknown if the FDIC faces any other big expenditures, but analysts have been watching the efforts of MCorp, another large Dallas bank, to pull itself out of its hole by attracting additional investors.

According to a congressional aide, who spoke on condition of anonymity, budget watchers earlier this year were worried that federal spending on sick financial institutions could trigger automatic, across-the-board spending cuts under the Gramm-Rudman deficit reduction.

Stronger than expected tax collections in May and June have eased the concern, for now.

Still, the White House Office of Management and Budget, in a mid-year budget review released Thursday, boosted its estimate of FDIC spending this year by $1.7 billion and by $1.2 billion in 1989. The estimate for FSLIC was increased by $2.9 billion for 1988 and $1.7 billion for next year.

FDIC Chairman L. William Seidman, in announcing the First RepublicBank rescue late Friday night, told reporters he expected the FDIC to suffer its first loss since its founding in 1934.

Until now, revenue from banks and interest on investments has always outweighed whatever it spent to protect depositors in failures and forced mergers.

Even in 1984, when the FDIC bailed out Continental Illinois Corp. of Chicago with $4.5 billion in the largest rescue ever, the agency made money. But all bank failures only totaled 79 in 1984. This year, they are expected to equal or surpass the post-Depression record of 184 set in 1987.