/* 
 * A program to test the efficiency of constant folding and global constant
 * propagation.
 */

void print_int(int i) {}
void print_newline(void) {}

#define LOOP 10000

void main(void) {
    int a, b, c, d, e, f, g, h, i, j, k, l, m, n, x, y, z;
    a = 1;
    b = 2;
    c = 3;
    d = 4;
    e = 5;
    f = 6;
    g = 7;

    // h, i, j, k are constants
    // l, m, n are not
    
    for (y=0; y<LOOP; y+=1) {
	for (z=0; z<LOOP; z+=1) {
	    h = 6;
	    i = 1 + 4 + 5;	    
	    h = i + 2 + 3;
	    i = h + 7 + a + c*b;
	    
	    j = (h + i) / c;
	    k = h + i + j;

	    l = a + b*k + e*f*g;
	    m = a*a*a*a;

	    // n not a constant anymore
	    n = a*z + k + 2;
	    
	    if (y > 0) {
		h = h + 25*i;
		j = k;
		k = 6*k + 3;
		
		// m not a constant anymore
		m = m + y;
	    } // if

	    if (z > 0) {
		i = j + h*3 + b*b*b;
		m = m + j*k + z;

	    } else {
		for (x=0; x<10; x+=1) {
		    n = n + b + c*d;
		    
		    // k is still constant, but dataflow will not identify
		    // it as such because of the loop
		    k += 1;
		} // 
	    } // if-else
	} // for
    } // for    

    print_int(k);
    print_newline();
} // main
