code: function reg2bin(beg, end)
  {
      --end;
      if (beg>>14 == end>>14) return ((1<<15)-1)/7 + (beg>>14);
      if (beg>>17 == end>>17) return ((1<<12)-1)/7 + (beg>>17);
      if (beg>>20 == end>>20) return ((1<<9)-1)/7 + (beg>>20);
      if (beg>>23 == end>>23) return ((1<<6)-1)/7 + (beg>>23);
      if (beg>>26 == end>>26) return ((1<<3)-1)/7 + (beg>>26);
      return 0;
  }
docs: Binning (transliterated from SAM1.3 spec)  /* calculate bin given an alignment covering [beg,end) (zero-based, half-close-half-open)