/**
   * Computes the state resulting from performing the bitwise xor-operation on this state and the
   * given state. If one of the states is bottom, bottom is returned. If both states represent
   * single values, a state representing the value obtained by the bit-wise xor-operation on the
   * states' values is returned. Otherwise, top is returned.
   *
   * @param pState the state to bit-wise-xor with this state.
   * @return the state resulting from performing the bitwise xor-operation on this state and the
   *     given state. If one of the states is bottom, bottom is returned. If both states represent
   *     single values, a state representing the value obtained by the bit-wise xor-operation on the
   *     states' values is returned. Otherwise, top is returned.
   */
public CompoundBitVectorInterval binaryXor(
      CompoundBitVectorInterval pState,
      boolean pAllowSignedWrapAround,
      final OverflowEventHandler pOverflowEventHandler) {
    checkBitVectorCompatibilityWith(pState.info);
    if (isBottom() || pState.isBottom()) {
      return bottom(info);
    }
    if (isSingleton() && pState.isSingleton()) {
      return of(
          BitVectorInterval.cast(
              info,
              getValue().xor(pState.getValue()),
              pAllowSignedWrapAround,
              pOverflowEventHandler));
    }
    if (pState.isSingleton() && pState.containsZero()) {
      return this;
    }
    if (isSingleton() && containsZero()) {
      return pState;
    }
    // [0,1] ^ 1 = [0,1]
    if (pState.isSingleton() && pState.contains(1) && equals(getZeroToOne(info))) {
      return this;
    }
    // 1 ^ [0,1] = [0,1]
    if (isSingleton() && contains(1) && pState.equals(getZeroToOne(info))) {
      return getZeroToOne(info);
    }
    if (pState.isSingleton()) {
      CompoundBitVectorInterval result = bottom(info);
      for (BitVectorInterval interval : intervals) {
        if (!interval.isSingleton()) {
          return getInternal(info.getRange());
        }
        result =
            result.unionWith(
                BitVectorInterval.cast(
                    info,
                    interval.getLowerBound().xor(pState.getValue()),
                    pAllowSignedWrapAround,
                    pOverflowEventHandler));
      }
      return result;
    } else if (isSingleton()) {
      return pState.binaryXor(this, pAllowSignedWrapAround, pOverflowEventHandler);
    }
    // TODO maybe a more exact implementation is possible?
    return getInternal(info.getRange());
  }
public CompoundBitVectorInterval binaryXor(
CompoundBitVectorInterval pState,
boolean pAllowSignedWrapAround,
final OverflowEventHandler pOverflowEventHandler) {
checkBitVectorCompatibilityWith(pState.info);
if (isBottom() || pState.isBottom()) {
return bottom(info);
}
if (isSingleton() && pState.isSingleton()) {
return of(
BitVectorInterval.cast(
info,
getValue().xor(pState.getValue()),
pAllowSignedWrapAround,
pOverflowEventHandler));
}
if (pState.isSingleton() && pState.containsZero()) {
return this;
}
if (isSingleton() && containsZero()) {
return pState;
}
// [0,1] ^ 1 = [0,1]
if (pState.isSingleton() && pState.contains(1) && equals(getZeroToOne(info))) {
return this;
}
// 1 ^ [0,1] = [0,1]
if (isSingleton() && contains(1) && pState.equals(getZeroToOne(info))) {
return getZeroToOne(info);
}
if (pState.isSingleton()) {
CompoundBitVectorInterval result = bottom(info);
for (BitVectorInterval interval : intervals) {
if (!interval.isSingleton()) {
return getInternal(info.getRange());
}
result =
result.unionWith(
BitVectorInterval.cast(
info,
interval.getLowerBound().xor(pState.getValue()),
pAllowSignedWrapAround,
pOverflowEventHandler));
}
return result;
} else if (isSingleton()) {
return pState.binaryXor(this, pAllowSignedWrapAround, pOverflowEventHandler);
}
// TODO maybe a more exact implementation is possible?
return getInternal(info.getRange());
}
public CompoundBitVectorInterval binaryXor(
CompoundBitVectorInterval pState,
boolean pAllowSignedWrapAround,
final OverflowEventHandler pOverflowEventHandler) {
checkBitVectorCompatibilityWith(pState.info);
if (isBottom() || pState.isBottom()) {
return bottom(info);
}
if (isSingleton() && pState.isSingleton()) {
return of(
BitVectorInterval.cast(
info,
getValue().xor(pState.getValue()),
pAllowSignedWrapAround,
pOverflowEventHandler));
}
if (pState.isSingleton() && pState.containsZero()) {
return this;
}
if (isSingleton() && containsZero()) {
return pState;
}
// [0,1] ^ 1 = [0,1]
if (pState.isSingleton() && pState.contains(1) && equals(getZeroToOne(info))) {
return this;
}
// 1 ^ [0,1] = [0,1]
if (isSingleton() && contains(1) && pState.equals(getZeroToOne(info))) {
return getZeroToOne(info);
}
if (pState.isSingleton()) {
CompoundBitVectorInterval result = bottom(info);
for (BitVectorInterval interval : intervals) {
if (!interval.isSingleton()) {
return getInternal(info.getRange());
}
result =
result.unionWith(
BitVectorInterval.cast(
info,
interval.getLowerBound().xor(pState.getValue()),
pAllowSignedWrapAround,
pOverflowEventHandler));
}
return result;
} else if (isSingleton()) {
return pState.binaryXor(this, pAllowSignedWrapAround, pOverflowEventHandler);
}
// TODO maybe a more exact implementation is possible?
return getInternal(info.getRange());
}
public CompoundBitVectorInterval binaryXor(
CompoundBitVectorInterval pState,
boolean pAllowSignedWrapAround,
final OverflowEventHandler pOverflowEventHandler) {
checkBitVectorCompatibilityWith(pState.info);
if (isBottom() || pState.isBottom()) {
return bottom(info);
}
if (isSingleton() && pState.isSingleton()) {
return of(
BitVectorInterval.cast(
info,
getValue().xor(pState.getValue()),
pAllowSignedWrapAround,
pOverflowEventHandler));
}
if (pState.isSingleton() && pState.containsZero()) {
return this;
}
if (isSingleton() && containsZero()) {
return pState;
}
// [0,1] ^ 1 = [0,1]
if (pState.isSingleton() && pState.contains(1) && equals(getZeroToOne(info))) {
return this;
}
// 1 ^ [0,1] = [0,1]
if (isSingleton() && contains(1) && pState.equals(getZeroToOne(info))) {
return getZeroToOne(info);
}
if (pState.isSingleton()) {
CompoundBitVectorInterval result = bottom(info);
for (BitVectorInterval interval : intervals) {
if (!interval.isSingleton()) {
return getInternal(info.getRange());
}
result =
result.unionWith(
BitVectorInterval.cast(
info,
interval.getLowerBound().xor(pState.getValue()),
pAllowSignedWrapAround,
pOverflowEventHandler));
}
return result;
} else if (isSingleton()) {
return pState.binaryXor(this, pAllowSignedWrapAround, pOverflowEventHandler);
}
// TODO maybe a more exact implementation is possible?
return getInternal(info.getRange());
}