A simultaneous bus orientation and bused pin flipping algorithm