int EventSet = PAPI_NULL;
int status = 0;
if (PAPI_create_eventset(&EventSet) != PAPI_OK)
handle_error(1);
/* Add Total Instructions Executed to our EventSet */
if (PAPI_add_event(EventSet, PAPI_TOT_INS) != PAPI_OK)
handle_error(1);
/* Start counting */
if (PAPI_state(EventSet, &status) != PAPI_OK)
handle_error(1);
printf("State is now %d\n",status);
if (PAPI_start(EventSet) != PAPI_OK)
handle_error(1);
if (PAPI_state(EventSet, &status) != PAPI_OK)
handle_error(1);
printf("State is now %d\n",status);