Let $\bf C$ be a category with pullbacks. Define $Span\colon (A,B)\mapsto \{ (X,f,g)\mid A\xleftarrow{f}X\xrightarrow{g}B\}$ and notice that it is a profunctor $s\colon \bf C^\text{op}\rightsquigarrow C$, namely a functor $\bf C\times C\to Sets$:

- $h\colon B\to B'$ induce $s(A,h)\colon \big(A\xleftarrow{f}X\xrightarrow{g}B\big)\mapsto \big( A\xleftarrow{f}X\xrightarrow{hg}B'\big)$;
- $k\colon A\to A'$ induce $s(k,B)\colon \big(A\xleftarrow{f}X\xrightarrow{g}B\big)\mapsto \big( A'\xleftarrow{kf}X\xrightarrow{g}B\big)$.

Similarly there is a cospan profucntor $Cospan =c\colon \bf C \rightsquigarrow C^\text{op}$.

Problem (click): Composition of spans, defined via a suitable pullback, gives $Span(\bf C)$ the structure of a bicategory, and can be interpreted as a morphism of profunctors $s\diamond c\diamond s\Rightarrow s$, where $\diamond$ is the composition law $$ \phi\diamond\psi(A,B) := \int^X \phi(A,X)\times \psi(X,B) $$ I'm stuck in trying to explicitly write the content of the coend $$ \int^{X}\int^Y s(A,X)\times c(X,Y)\times s(Y,B) $$ Even the slightest help is welcome, thanks for your time. Unfortunately I'm not able to find any reference about that result which is only sketched in the linked notes.