Differential cross sections are presented for the prompt and non-prompt production of the hidden-charm states X(3872) and psi(2S), in the decay mode J/psi pi (+) pi (-), measured using 11.4 fb(-1) of pp collisions at root s = 8 Tev by the ATLAS detector at the LHC. The ratio of cross-sections X(3872)/psi(2S) is also given, separately for prompt and non-prompt components, as well as the non-prompt fractions of X(3872) and psi(2S). Assuming independent single effective lifetimes for non-prompt X(3872) and psi(2S) production gives separating short- and long-lived contributions, assuming that the short-lived component is due to B (c) decays, gives R (B) = (3.57 +/- 0.33(stat) +/- 0.11(sys)) x 10(-2), with the fraction of non-prompt X(3872) prod...