bool prime (uint n) { uint i; if (even (n)) return (n == 2); _Pragma("loopbound min 73 max 357") __llvm_pcmarker(0); for (i = 3; i * i <= n; i += 2) { __llvm_pcmarker(1); if (divides (i, n)) /* ai: loop here min 0 max 357 end; */ return 0; } return (n > 1); }
int main( void ) { int i,j, temp; #ifdef PROFILING /* Profiling variables. Remove for actual WCET analyses. */ int iters_i = 0, min_i = 100000, max_i = 0; int iters_a = 0, min_a = 100000, max_a = 0; #endif a[0] = 0; /* assume all data is positive */ a[1] = 11; a[2]=10;a[3]=9; a[4]=8; a[5]=7; a[6]=6; a[7]=5; a[8] =4; a[9]=3; a[10]=2; i = 2; #ifdef PROFILING iters_i = 0; #endif __llvm_pcmarker(2); _Pragma("loopbound min 9 max 9") while(i <= 10){ __llvm_pcmarker(3); cnt1++; #ifdef PROFILING iters_i++; #endif j = i; cnt2 = 0; #ifdef PROFILING iters_a = 0; #endif __llvm_pcmarker(0); _Pragma("loopbound min 1 max 9") while (a[j] < a[j-1]) { __llvm_pcmarker(1); #ifdef PROFILING iters_a++; #endif cnt2++; temp = a[j]; a[j] = a[j-1]; a[j-1] = temp; j--; } #ifdef PROFILING if ( iters_a < min_a ) min_a = iters_a; if ( iters_a > max_a ) max_a = iters_a; #endif #ifdef PRINT_RESULTS printf("insertsort: Inner Loop Counts: %d\n", cnt2); #endif i++; } #ifdef PROFILING if ( iters_i < min_i ) min_i = iters_i; if ( iters_i > max_i ) max_i = iters_i; #endif #ifdef PROFILING printf( "i-loop: [%d, %d]\n", min_i, max_i ); printf( "a-loop: [%d, %d]\n", min_a, max_a ); #endif #ifdef PRINT_RESULTS printf("insertsort: Outer Loop : %d , Inner Loop : %d\n", cnt1, cnt2); printf("insertsort: a[5]=%d\n",a[5]); #endif if(cnt1 != 9 || cnt2 != 9) return 1; if(a[5] != 6) return 1; return 0; }