Buggy code:
class BlockSort { private static final int QSORT_STACK_SIZE = 1000 ; private static final int FALLBACK_QSORT_STACK_SIZE = 100 ; private static final int STACK_SIZE = ( ( BlockSort . QSORT_STACK_SIZE ) < ( BlockSort . FALLBACK_QSORT_STACK_SIZE ) ) ? BlockSort . FALLBACK_QSORT_STACK_SIZE : BlockSort . QSORT_STACK_SIZE ; private int workDone ; private int workLimit ; private boolean firstAttempt ; private final int [ ] stack_ll = new int [ BlockSort . STACK_SIZE ] ; private final int [ ] stack_hh = new int [ BlockSort . STACK_SIZE ] ; private final int [ ] stack_dd = new int [ BlockSort . QSORT_STACK_SIZE ] ; private final int [ ] mainSort_runningOrder = new int [ 256 ] ; private final int [ ] mainSort_copy = new int [ 256 ] ; private final boolean [ ] mainSort_bigDone = new boolean [ 256 ] ; private final int [ ] ftab = new int [ 65537 ] ; private final char [ ] quadrant ; BlockSort ( final BZip2CompressorOutputStream . Data data ) { } void blockSort ( final BZip2CompressorOutputStream . Data data , final int last ) { } final void fallbackSort ( final BZip2CompressorOutputStream . Data data , final int last ) { } private void fallbackSimpleSort ( int [ ] fmap , int [ ] eclass , int lo , int hi ) { } private static final int FALLBACK_QSORT_SMALL_THRESH = 10 ; private void fswap ( int [ ] fmap , int zz1 , int zz2 ) { } private void fvswap ( int [ ] fmap , int yyp1 , int yyp2 , int yyn ) { } private int fmin ( int a , int b ) { } private void fpush ( int sp , int lz , int hz ) { } private int [ ] fpop ( int sp ) { } private void fallbackQSort3 ( int [ ] fmap , int [ ] eclass , int loSt , int hiSt ) { int lo ; int unLo ; int ltLo ; int hi ; int unHi ; int gtHi ; int n ; long r = 0 ; int sp = 0 ; fpush ( ( sp ++ ) , loSt , hiSt ) ; while ( sp > 0 ) { int [ ] s = fpop ( ( -- sp ) ) ; lo = s [ 0 ] ; hi = s [ 1 ] ; if ( ( hi - lo ) < ( BlockSort . FALLBACK_QSORT_SMALL_THRESH ) ) { fallbackSimpleSort ( fmap , eclass , lo , hi ) ; continue ; } r = ( ( r * 7621 ) + 1 ) % 32768 ; long r3 = r % 3 ; long med ; if ( r3 == 0 ) { med = eclass [ fmap [ lo ] ] ; } else if ( r3 == 1 ) { <START_BUG> med = eclass [ fmap [ ( ( lo + hi ) > > 1 ) ] ] ; <END_BUG> } else { med = eclass [ fmap [ hi ] ] ; } unLo = ltLo = lo ; unHi = gtHi = hi ; while ( true ) { while ( true ) { if ( unLo > unHi ) { break ; } n = ( eclass [ fmap [ unLo ] ] ) - ( ( int ) ( med ) ) ; if ( n == 0 ) { fswap ( fmap , unLo , ltLo ) ; ltLo ++ ; unLo ++ ; continue ; } if ( n > 0 ) { break ; } unLo ++ ; } while ( true ) { if ( unLo > unHi ) { break ; } n = ( eclass [ fmap [ unHi ] ] ) - ( ( int ) ( med ) ) ; if ( n == 0 ) { fswap ( fmap , unHi , gtHi ) ; gtHi -- ; unHi -- ; continue ; } if ( n < 0 ) { break ; } unHi -- ; } if ( unLo > unHi ) { break ; } fswap ( fmap , unLo , unHi ) ; unLo ++ ; unHi -- ; } if ( gtHi < ltLo ) { continue ; } n = fmin ( ( ltLo - lo ) , ( unLo - ltLo ) ) ; fvswap ( fmap , lo , ( unLo - n ) , n ) ; int m = fmin ( ( hi - gtHi ) , ( gtHi - unHi ) ) ; fvswap ( fmap , ( unHi + 1 ) , ( ( hi - m ) + 1 ) , m ) ; n = ( ( lo + unLo ) - ltLo ) - 1 ; m = ( hi - ( gtHi - unHi ) ) + 1 ; if ( ( n - lo ) > ( hi - m ) ) { fpush ( ( sp ++ ) , lo , n ) ; fpush ( ( sp ++ ) , m , hi ) ; } else { fpush ( ( sp ++ ) , m , hi ) ; fpush ( ( sp ++ ) , lo , n ) ; } } } private int [ ] eclass ; private int [ ] getEclass ( ) { } final void fallbackSort ( int [ ] fmap , byte [ ] block , int nblock ) { } private static final int [ ] INCS = new int [ ] { 1 , 4 , 13 , 40 , 121 , 364 , 1093 , 3280 , 9841 , 29524 , 88573 , 265720 , 797161 , 2391484 } ; private boolean mainSimpleSort ( final BZip2CompressorOutputStream . Data dataShadow , final int lo , final int hi , final int d , final int lastShadow ) { }

Fix:
med = eclass [ fmap [ ( ( lo + hi ) > > > 1 ) ] ] ;