#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>

static int a;
static int b;

int main(int argc, char* argv[]) {

    int limit, time, i;
    struct timeval start, end;

    limit = atoi(argv[1]);
    a = 32768;
    printf ("Iterations = %d\n", limit);
    gettimeofday(&start, NULL);
    for (i=0; i<limit; i++) {
        b = a/2;
    }
    gettimeofday(&end, NULL);
    printf("Division test = %d\n", ((end.tv_sec - start.tv_sec) * 1000) +
           ((end.tv_usec - start.tv_usec) / 1000));
    gettimeofday(&start, NULL);
    for (i=0; i<limit; i++) {
        b = (a >> 2);
    }
    gettimeofday(&end, NULL);
    printf("Bitwise test = %d\n", ((end.tv_sec - start.tv_sec) * 1000) +
           ((end.tv_usec - start.tv_usec) / 1000));
    return 0;
}

