What can I use to replace a Shimano Deore LX RD-M581?
You can in fact use any modern Shimano derailleur for 7, 8 or 9 speeds that meets the total capacity and largest sprocket requirements. The reason is that Shimano used the same cable actuation ratio (ratio of cable length pulled to lateral cage movement) for MTB groups below 10 speeds.

If you want a derailleur that works as well as possible, get the current highest level 9 speed option. That would be the Alivio RD-M4000 which accommodates 32 to 36t largest sprocket and total capacity of 45. Rear derailleur specs are here: https://productinfo.shimano.com/#/spec/MTB/Rear%20Derailleur. You can look up various options.

Note: when I accessed that page there appeared to be many errors, so Shimano might be in the process of an update. Correct info can be found in the archive PDF files here: https://productinfo.shimano.com/#/archive.