Let us classify the words to compare between Spanish and Portuguese into three numbered categories.
- The default category: Latin origin words.
- Loanwords from Spanish adopted into Portuguese and vice versa.
- Loanwords from other languages.
Spanish words with "ll" (originally pronounced /ʎ/, the pronunciation was changed to /y/ through Yeísmo, and also uses other pronunciations like /dʒ/, /ʃ/, /ʒ/; words under Category 3 above may pronounce "ll" as /ll/ or /l/ or whatever is the original language pronunciation) will also fall under one of these categories.
On the other hand "ll" usually does not occur in native Portuguese words, so Portuguese words with "ll" will usually fall under Category 3 above or maybe under Category 2 above if it is borrowed from Spanish.
The Spanish verb "llamar" falls under Category 1 above as it originates from Latin "clamare". Its Portuguese equivalent is "chamar".
On the other hand "llama" the animal falls under Category 2 above and is called "lhama" in Portuguese (the pronunciation of Portuguese "lh" is between /ʎ/ and /y/).
My question here is, when does the Spanish "ll" transform to "lh", when does it transform to "ch", and when does it transform to just "l" in Portuguese?