// Path: hppc/src/main/java/com/carrotsearch/hppc/XorShift128P.java
// public class XorShift128P {
//   /*
//    * 128 bits of state.
//    */
//   private long state0, state1;
// 
//   public XorShift128P(long seed) {
//     state0 = notZero(BitMixer.mix64(seed));
//     state1 = notZero(BitMixer.mix64(seed + 1));
//   }
// 
//   public XorShift128P() {
//     this(Containers.randomSeed64());
//   }
// 
//   public long nextLong() {
//     long s1 = state0;
//     long s0 = state1;
//     state0 = s0;
//     s1 ^= s1 << 23;
//     return (state1 = (s1 ^ s0 ^ (s1 >>> 17) ^ (s0 >>> 26))) + s0;
//   }
// 
//   public int nextInt() {
//     return (int) nextLong();
//   }
// 
//   private static long notZero(long value) {
//     return value == 0 ? 0xdeadbeefbabeL : value;
//   }
// 
//   public int nextInt(int bound) {
//     if (bound <= 0) {
//       throw new IllegalArgumentException();
//     }
// 
//     int r = (nextInt() >>> 1);
//     int m = bound - 1;
//     if ((bound & m) == 0) {
//       r = (int) ((bound * (long) r) >> 31);
//     } else {
//       for (int u = r; u - (r = u % bound) + m < 0; u = nextInt() >>> 1) {}
//     }
// 
//     return r;
//   }
// }


import static org.junit.Assert.*;
import com.carrotsearch.hppc.XorShift128P;
import java.util.Arrays;
import java.util.Random;
import java.util.function.IntBinaryOperator;
import org.junit.*;
      assertOrder(order, length, intBinaryOperator);
    }
  }

  /** Randomized input, ascending double comparator. */
  @Test
  public void testAscDouble() {
    final int maxSize = 1000;
    final int rounds = 1000;
    final Random rnd = new Random(0x11223344);

    for (int round = 0; round < rounds; round++) {
      final double[] input = generateRandom(maxSize, rnd);

      final IntBinaryOperator comparator = (a, b) -> Double.compare(input[a], input[b]);

      final int start = rnd.nextInt(input.length - 1);
      final int length = (input.length - start);

      int[] order = IndirectSort.mergesort(start, length, comparator);
      assertOrder(order, length, comparator);
    }
  }

  /**
   * Sort random integers from the range 0..0xff based on their 4 upper bits. The relative order of
   * 0xf0-masked integers should be preserved from the input.
   */
  @Test
  public void testMergeSortIsStable() {
// Path: hppc/src/main/java/com/carrotsearch/hppc/XorShift128P.java
// public class XorShift128P {
//   /*
//    * 128 bits of state.
//    */
//   private long state0, state1;
// 
//   public XorShift128P(long seed) {
//     state0 = notZero(BitMixer.mix64(seed));
//     state1 = notZero(BitMixer.mix64(seed + 1));
//   }
// 
//   public XorShift128P() {
//     this(Containers.randomSeed64());
//   }
// 
//   public long nextLong() {
//     long s1 = state0;
//     long s0 = state1;
//     state0 = s0;
//     s1 ^= s1 << 23;
//     return (state1 = (s1 ^ s0 ^ (s1 >>> 17) ^ (s0 >>> 26))) + s0;
//   }
// 
//   public int nextInt() {
//     return (int) nextLong();
//   }
// 
//   private static long notZero(long value) {
//     return value == 0 ? 0xdeadbeefbabeL : value;
//   }
// 
//   public int nextInt(int bound) {
//     if (bound <= 0) {
//       throw new IllegalArgumentException();
//     }
// 
//     int r = (nextInt() >>> 1);
//     int m = bound - 1;
//     if ((bound & m) == 0) {
//       r = (int) ((bound * (long) r) >> 31);
//     } else {
//       for (int u = r; u - (r = u % bound) + m < 0; u = nextInt() >>> 1) {}
//     }
// 
//     return r;
//   }
// }


// Path: hppc/src/test/java/com/carrotsearch/hppc/sorting/IndirectSortTest.java
import static org.junit.Assert.*;
import com.carrotsearch.hppc.XorShift128P;
import java.util.Arrays;
import java.util.Random;
import java.util.function.IntBinaryOperator;
import org.junit.*;

      assertOrder(order, length, intBinaryOperator);
    }
  }

  /** Randomized input, ascending double comparator. */
  @Test
  public void testAscDouble() {
    final int maxSize = 1000;
    final int rounds = 1000;
    final Random rnd = new Random(0x11223344);

    for (int round = 0; round < rounds; round++) {
      final double[] input = generateRandom(maxSize, rnd);

      final IntBinaryOperator comparator = (a, b) -> Double.compare(input[a], input[b]);

      final int start = rnd.nextInt(input.length - 1);
      final int length = (input.length - start);

      int[] order = IndirectSort.mergesort(start, length, comparator);
      assertOrder(order, length, comparator);
    }
  }

  /**
   * Sort random integers from the range 0..0xff based on their 4 upper bits. The relative order of
   * 0xf0-masked integers should be preserved from the input.
   */
  @Test
  public void testMergeSortIsStable() {
    final XorShift128P rnd = new XorShift128P(0xdeadbeefL);