1/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/**
18 * Automatically generated fuzz test that exposed bug in the way bounds
19 * check elimination visits basic blocks. If, after dynamic bce, the same
20 * block would be visited again, then static length based bce would incorrectly
21 * feed information back to itself and removed a necessary bounds check.
22 */
23public class Main {
24
25  private static int[][][] mA = new int[10][10][10];
26
27  private static int mX = 17;
28
29  private static int doit() {
30    int l0 = (((++mA[7][2][8]) <= mA[0][1][3]) ? (++mA[9][0][5]) : ((( -mA[0][7][0]) * ((mX == mX) ? 180 : mX)) + (mA[7][8][8]++)));
31    mA[1][0][4] -= mX;
32    int l1 = (((l0 >= ( ~mA[6][7][5])) && ((921 <= l0) && (mA[3][9][6] > l0))) ? mX : (l0--));
33    int l2 = ( -384);
34    for (int i0 = 7 - 1; i0 >= 1; i0--) {
35      mA[6][0][0] -= ((((l0++) == ( -mX)) ? (((mA[3][i0][1] > 503) || (mX <= i0)) ? (--l0) : (l0--)) : mX) - ( ~(mX--)));
36      int l3 = 24;
37      int l4 = ((l2--) & mX);
38      for (int i1 = i0-2 - 1; i1 >= 3; i1--) {
39        for (int i2 = 2; i2 < i0; i2++) {
40          mA[i0][4][l3] >>= 1;
41        }
42      }
43    }
44    return 1;
45  }
46
47  public static void main(String[] args) {
48    int k = 1;
49    for (int i0 = 0; i0 < 10; i0++)
50    for (int i1 = 0; i1 < 10; i1++)
51    for (int i2 = 0; i2 < 10; i2++)
52      mA[i0][i1][i2] = k++;
53    try {
54      k = doit();
55    } catch (Exception e) {
56      System.out.println("exception caught");
57    }
58    System.out.println("FUZZ result = " + k + " " + mX);
59  }
60}
61