Transition between growth of dense and porous films: theory of dual-layer SEI.