Bohr-Sommerfeld phases for avoided crossings