Battery Lifetime Optimization for Energy-Aware Circuits