Differentiable Safe Controller Design Through Control Barrier Functions