#include "cyccounter.h" #include #include int main(int argc, char *argv[]){ cycles start, stop; int i, n; void *loopptr; if (argc != 2) { printf ("You need exactly one argument\n"); exit(0); } sscanf(argv[1], "%d", &n); /* This block of code is to trick the compiler into thinking loopptr is not constant. If it were a constant, the compiler could optimize away the pointer's use. */ start = read_cyccounter(); if (start >= 10) loopptr = &&loop; else loopptr = &&loopEnd; /* end of block */ start = read_cyccounter(); i = 0; loop: if(i >= n){ goto loopEnd; } i++; goto loop; loopEnd: stop = read_cyccounter(); printf("%llu\n", stop - start); return 0; }