Decidability and undecidability results for Nelson-Oppen and rewrite-based decision procedures