Answer the following questions based on the information given below.
Sixteen teams have been invited to participate in the ABC Gold Cup cricket tournament. The tournament is conducted in two stages. In the first stage, the teams are divided into two groups. Each group consists of eight teams, with each team playing every other team in its group exactly once. At the end of the first stage, the top four teams from each group advance to the second stage while the rest are eliminated. The second stage comprises of several rounds. A round involves one match for each team. The winner of a match in a round advances to the next round, while the loser is eliminated. The team that remains undefeated in the second stage is declared the winner and claims the Gold Cup.
The tournament rules are such that each match results in a winner and a loser with no possibility of a tie. In the first stage, a team earns one point for each win and no points for a loss. At the end of the first stage teams in each group are ranked on the basis of total points to determine the qualifiers advancing to the next stage. Ties are resolved by a series of complex tie-breaking rules so that exactly four teams from each group advance to the next stage.
What is the total number of matches played in the tournament?