public static int binarySearch(int[] a, int key) { int low = 0; int high = RoopsArray.getLength(a) - 1; int mid; int midVal; while (low <= high) { mid = (low + high) / 2; if (mid < 0) { { /*$goal 0 reachable*/ } } midVal = a[mid]; if (midVal < key) { low = mid + 1; } else if (midVal > key) { high = mid - 1; } else { return(mid); // key found } } return(-(low + 1)); }
//$goals 2 //$benchmark public void DirectWriteFollowedByDirectRead(int[] a, int v) { if (a != null && RoopsArray.getLength(a) >= 10) { a[4] = v; if (a[4] == 42) { /*$goal 0*/ } else { /*$goal 1*/ } } }
//$goals 3 //$benchmark public void BigArrayManyUpdates0(int k) { int[] a = new int[10]; for (int i = 0; i < RoopsArray.getLength(a); i++) { a[i] = i; } if (k >= 0 && k < RoopsArray.getLength(a) && a[k] == 50) { /*$goal 0*/ } else { /*$goal 1*/ } }
//$goals 3 //$benchmark public void BigArrayManyUpdates2(int j, int k) { int[] a = new int[100000]; for (int i = 0; i < RoopsArray.getLength(a); i++) { a[i] = i == (j - 100) ? 1 : 2; } if (k >= 0 && k < 100000 && a[k] == 1) { /*$goal 0*/ } else { /*$goal 1*/ } }
//$goals 3 //$benchmark public void IndirectWriteFollowedByIndirectRead(int[] a, int i, int j, int v) { if (a != null) { if (i >= 0 && i < RoopsArray.getLength(a) && j >= 0 && j < RoopsArray.getLength(a)) { a[i] = v; if (a[j] == 42) { /*$goal 0*/ } else { /*$goal 1*/ } } else { /*$goal 2*/ } } }