Analysis and Optimization of Divide and Conquer Programs