// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>

using namespace std;

#include <windows.h>

static int z = 0;

static void crap(int x)
{
    if(x < 0) z++;
}

int func( int param1 )
{
    int x = 0;
    unsigned int uTicks = timeGetTime();
    for(int j = 0; j < 10; j++) {
        for( int i=0;i< 30000000; i++)
        {
            x = x + param1;
            x = x * 2;
            x = x + 1;
            crap(x);
        }
        for( int i=0;i< 30000000; i++)
        {
            x = x - 1;
            x = x / 2;
            x = x - param1;
            crap(x);
        }
    }
    unsigned int uTimePassed = timeGetTime() - uTicks;
    cout << "Milliseconds: " << uTimePassed << endl;
    return x;
}

int main(int argc, char* argv[])
{
    int x = func(1) + func(2) + func(3) + func(4) + func(5) + func(6) + func(7) + func(8) + func(9);
    return 0;
}
