They aren't shared between agents - The brokers are the ones who are paid the commission.
If there are two brokers (companies) the commission is split between them first - based on the listing agreement and the MLS information.
There is One Broker who owns the company.
Agents and Associate Brokers work under the owner but not "for" the owner - they are not employees.
Each agent then receives their portion of that part of the commission, which is goverened by the particular agreement with their broker (company).
Agent/Associate Brokers within a company can have different agreements which are usually based on production, experience, etc.
If one agent is both the listing and selling agent (or associate broker) in a transaction, they in effect get two checks - one for the listing side and one for the buyer side.
There are often other fees taken out of the agent/associate broker check.
Those fees can include advertising, marketing, corporate branding, etc.
(Please note: when you choose an answer as a Best Answer, or at least give a thumbs up, it helps those who answer questions here.)