Original link: Branch Prediction: The Definitive Guide for High-Performance C++ / John Farrier blog.
Interesting.
All examples are in C++, but I believe most of the content is relevant for any language let us call it "reasonable close to the metal".