There are actually four different things.
- Maternal surnames, such as
José Nóbrega da Silva.
- Second given names, such as
Ana Carla Pereira.
- The first part of a composite paternal surname, like
Augusto Castelo Branco
- The second part of a composite given name, as in
Maria do Rosário Pereira.
It is necessary to know these lexical entries one by one. Generally, surnames are different from given names, and it is possible to have some loose guidelines: names of animals, trees, cities, professions, are quite certainly surnames (Coelho, Raposo, Tourinho; Pereira, Nogueira, Figueira; Coimbra, Santarém, Lisboa; Cardador, Pastor), as well as ancient patronymics turned surnames (Henriques, Bernardes, Fernandes). But there is overlap, as pointed in other answer. Composite surnames sometimes make sencesense (Castelo Branco, Índio do Brasil), but not always (Monteiro Lobato, Mena Barreto). Composite names are mostly the variosvarious aspects of the Virgin Mary: Maria das Dores, Maria do Socorro, Maria da Conceição; otheranother possibility is the name of historic characters (Paulo de Tarso, Rui Barbosa, Washington Luís). Again there is overlap; Socorro is not a common surname, if at all, but Conceição or Rosário are. In general, you can be sure that the first name is a given name, and the last one is the paternal surname (unless it is a familial descriptor, such as Filho, Neto, Sobrinho, Júnior). Middle names are more complicated; usually native speakers know which is what, but theythere can be difficult cases even for us. They usually become clear if we know the parents' names.