linux/scripts/atomic/fallbacks/try_cmpxchg

cat <<EOF
	${int} r, o = *old;
	r = raw_${atomic}_cmpxchg${order}(v, o, new);
	if (unlikely(r != o))
		*old = r;
	return likely(r == o);
EOF