I should probably mention a warning that you about using a merged file (a merged file takes MAME's -listXML output and merges in controls.xml and catver.ini and numplayers.ini files) Just use the straight up MAME XML data and ignore all the warning that RL will spit at you about using a non merged file.
THe reason I say this is that when controls and mame's data get merged in, now you have 2 references to the number of buttons in a game, and your output will look something different, as in:
ddragonb=3 & 3
ddragnba=3 & 2
ddragon=3 & 3
etc.
What you're seeing there is MAME's xml data says there are 3 buttons. Then controls.dat(or controls.xml) says no, wait, there are 2 buttons. RL will give you both answers when they exist.
MAME's XML data is often inaccurate as to the actual number of buttons used, or they sometimes could the player start buttons as gameplay buttons. There doesn't seem to be much consistency. The data in the controls file is way more accurate, but it doesn't have data for every game, so pick your poison.
Also, you may see entries in your list that are without any number at all. Those would be games that don't use buttons...
I have probably just muddied the waters.