Understanding the origin of the pseudogap is an essential step toward elucidating the pairing mechanism in the cuprate superconductors. Recently there has been strong experimental evidence showing that C4 symmetry breaking occurs on the formation of the pseudogap. This form of symmetry breaking was predicted by the fluctuating bond model (FBM), an empirical model based on a strong, local coupling of electrons to the square of the planar oxygen vibrator amplitudes. In this paper we approach the FBM theory from a new direction, starting from ab initio molecular dynamics simulations. The simulations demonstrate a doping-dependent instability of the in-plane oxygens toward displacement off the Cu-O-Cu bond axis. From these results and perturbation theory we derive an improved and quantitative form of the FBM. A mean-field solution of the FBM leads to C4 symmetry breaking in the oxygen vibrational amplitudes and to a d-type pseudogap in the electronic spectrum, the features linked by recent experimental data. The phase diagram of the pseudogap derived from mean-field theory, its doping and temperature dependences, including the phase boundary T*, agree well with experimental data. We extend the theory to include the long-range Coulomb interaction on the same basis as the FBM interaction. When the long-range Coulomb interaction is included in the FBM, a charge density wave (CDW) instability in the charge channel is predicted, which explains the nanoscale, rather than spatially uniform, behavior of the C4 symmetry breaking. Taking the CDW into account, with the theoretical k dependence of the pseudogap, enables the Fermi surface arc phenomenon to be understood. © 2011 American Physical Society.