#include <sys/io.h>

/* The __volatile__ keyword tells the
 * compiler to leave the code in the
 * asm block untouched during optimizations
 */
#define rdtscll(val) \
   __asm__ __volatile__("rdtsc" :"=A"(val))

main()
{
   unsigned long long a, b;
   iopl(3);
   outb(0, 0x200);
   rdtscll(a);
   while(inb(0x200) & 1);
   rdtscll(b);
   printf("%llu\n", b - a);
}
   
