<s>[INST] Asymptotic expansion of $\int_0^1 \frac{\operatorname{K}(r x)}{\sqrt{(1-r^2 x^2)(1-x^2)}} \, \mathrm{d} x $ Notation: For $\varphi \in [0,\frac{\pi}{2}]$ and $k \in [0,1)$ the definitions
$$ \operatorname{F}(\varphi,k) = \int \limits_0^\varphi \frac{\mathrm{d} \theta}{\sqrt{1-k^2 \sin^2(\theta)}} = \int \limits_0^{\sin(\varphi)} \frac{\mathrm{d} x}{\sqrt{(1 - k^2 x^2)(1-x^2)}} $$
and $\operatorname{K}(k) = \operatorname{F}(\frac{\pi}{2},k)$ will be used for the elliptic integrals of the first kind.
When answering this question, I came across the function
$$ \psi \colon [0,1) \to (0,\infty) \, , \, \psi(k) = \int \limits_0^1 \frac{\operatorname{K}(k x)}{\sqrt{(1-k^2 x^2)(1-x^2)}} \, \mathrm{d}x = \int \limits_0^{\pi/2} \frac{\operatorname{K}(k \sin(\theta))}{\sqrt{1-k^2 \sin^2 (\theta)}} \, \mathrm{d} \theta \, .$$
While $\psi(k) = \frac{\pi^2}{4} [1+ \frac{3}{8} k^2 + \mathcal{O}(k^4)]$ near $k=0$ is readily found using Maclaurin series, the expansion at $k=1$ is more elusive. 
The naive attempt of replacing $\operatorname{K}(kx)$ by $\operatorname{K}(k)$ (since the largest contribution to the integral comes from the region near $x=1$) yields $\psi(k) \simeq \operatorname{K}^2 (k)$, which according to plots is not too far off but also not quite right. Integration by parts reproduces this term, but the remaining integral does not look very nice:
\begin{align}
\psi(k) &= \operatorname{K}^2 (k) - k \int \limits_0^1 \operatorname{K}'(k x) \operatorname{F}(\arcsin(x),k) \, \mathrm{d} x \\
&= \operatorname{K}^2 (k) - \int \limits_0^1 \left[\frac{\operatorname{E}(k x)}{1-k^2 x^2} - \operatorname{K}(kx)\right] \frac{\operatorname{F}(\arcsin(x),k)}{x} \, \mathrm{d} x \, .
\end{align}
The expansion $\operatorname{K}(k) = -\frac{1}{2} \log(\frac{1-k}{8}) + \mathcal{o}(1)$ is useful for the final steps, but I do not know how to extract all the leading terms, so:

How can we find the asymptotic expansion (ideally up to and including the constant terms) of $\psi(k)$ as $k \nearrow 1$ ?

 [/INST] EllipitcElena's answer and Maxim's correction show that we have
$$ \psi(k) = - \frac{1}{4} \operatorname{K}(k) \log(1-k^2) + 2 \log(2) \operatorname{K}(k) + \chi(k) \, ,$$
where ($\psi_0$ is the digamma function, so $\psi$ was not the best choice)
$$ \chi (k) = \sum \limits_{m=1}^\infty \frac{\left(\frac{1}{2}\right)_m^2}{m!^2} \int \limits_0^1 \frac{(1-k^2 x^2)^{m-\frac{1}{2}}}{\sqrt{1-x^2}} \left[-\frac{1}{2} \log(1-k^2 x^2) + \psi_0(m+1)-\psi_0 \left(m + \frac{1}{2}\right)\right] \, \mathrm{d} x \, . $$
Near $k=1$ we find
$$ \psi (k) = \frac{1}{8} \left[\log^2 \left(\frac{1-k}{32}\right) - 4 \log^2 (2)\right] + \chi(1) + \mathcal{o}(1) \, .$$
$\chi(1)$ can be computed exactly:
\begin{align}
\chi(1) &= \sum \limits_{m=1}^\infty \frac{\left(\frac{1}{2}\right)_m^2}{m!^2} \int \limits_0^1 (1-x^2)^{m-1} \left[-\frac{1}{2} \log(1- x^2) + \psi_0(m+1)-\psi_0 \left(m + \frac{1}{2}\right)\right] \, \mathrm{d} x \\
&= \frac{1}{2} \sum \limits_{m=1}^\infty \frac{\left(\frac{1}{2}\right)_m^2}{m!^2} \left[-\frac{1}{2} \partial_1 \operatorname{B}\left(m,\frac{1}{2}\right) + \left(\psi_0(m+1)-\psi_0 \left(m + \frac{1}{2}\right)\right) \operatorname{B}\left(m,\frac{1}{2}\right) \right] \\
&= \frac{1}{2} \sum \limits_{m=1}^\infty \frac{\left(\frac{1}{2}\right)_m^2}{m!^2} \operatorname{B}\left(m,\frac{1}{2}\right) \left[\frac{1}{2}\left(\psi_0 \left(m + \frac{1}{2}\right) - \psi_0(m)\right) + \psi_0(m+1)-\psi_0 \left(m + \frac{1}{2}\right) \right] \, .
\end{align}
Using $\operatorname{B}(m,\frac{1}{2}) = \frac{(m-1)!}{\left(\frac{1}{2}\right)_m}$, $\left(\frac{1}{2}\right)_m = \frac{(2m)!}{4^m m!}$ and special values of $\psi_0$ this expression can be simplified:
$$ \chi(1) = \sum \limits_{m=1}^\infty \frac{{2m \choose m}}{2m 4^m} \left[\log(2) + H_m - H_{2m-1}\right] = \frac{1}{2} \log^2 (2) \, .$$
The final sum follows from the series
$$ \sum \limits_{m=1}^\infty \frac{{2m \choose m}}{2m 4^m} x^m = \log(2) - \log(1+\sqrt{1-x}) \, , \, x \in [-1,1] \, , $$
and is discussed in this question as well.
Putting everything together we obtain the rather nice result
$$ \boxed{\psi (k) = \frac{1}{8} \log^2 \left(\frac{1-k}{32}\right) + \mathcal{o} (1)} $$
as $k \nearrow 1$.
</s>