1 /*
2  * Copyright (C) 2019 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 public class Main {
18 
assertIntEquals(int expected, int result)19     public static void assertIntEquals(int expected, int result) {
20         if (expected != result) {
21             throw new Error("Expected: " + expected + ", found: " + result);
22         }
23     }
24 
loop1()25     public int loop1() {
26         int used1 = 1;
27         int used2 = 2;
28         int used3 = 3;
29         int used4 = 4;
30         int invar1 = 15;
31         int invar2 = 25;
32         int invar3 = 35;
33         int invar4 = 45;
34 
35         for (int i = 0; i < 10000; i++) {
36             used1 += invar1 + invar2;
37             used2 -= used1 + invar2 - invar3;
38             used3 *= used2 + invar3 * invar4;
39             used4 /= used3 + invar1 * invar2 - invar3 + invar4;
40         }
41         assertIntEquals(used1 + used2 + used3 + used4, -1999709997);
42         return used1 + used2 + used3 + used4;
43     }
44 
main(String[] args)45     public static void main(String[] args) {
46         int res = new Main().loop1();
47     }
48 }
49