Decidability and Undecidability Results for Nelson-Oppen and Rewrite-Based Decision Procedures