/*
 * Tests the effectiveness of constant folding (and a bit of easy constant
 * propagation).
 */

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

#define LOOP 10000

void main(void) {
    int a, b, c, d, e, f, g, h, i, j;
    a = 1;
    b = 2;
    c = 3;
    d = 4;

    
    for (i=0; i<LOOP; i+=1) {
	for (j=0; j<LOOP; j+=1) {
	    // basic folding, one op per assignment eliminated
	    e = 1 + 2;
	    f = 1 + 2 + a;
	    g = 1 + a + 2;
	    h = a + 1 + 2;

	    // more complex folding, fold away 3 ops
	    e = 2*3 + a - b + 3 - 5;
	    f = d*c + 3 - a + b - c;

	    // more complex folding still
	    g = (a + 1)*2 - (b + c)/3 + (a*2 + 3*3)*(2*(1 + b) + 3);
	    h = (a + 1 + 3) + (2 + b) + ((c + d) + 1) + 2 + 3 + c;
	} // for
    } // for

    print_int(e);
    print_space(1);
    print_int(f);
    print_space(1);
    print_int(g);
    print_space(1);
    print_int(h);
    print_newline();
} // main
