//
// Insertion Sort Routine
//
void insertion_sort(int n,int *A, int &lc){
   int i,j, key;           
   for (j = 1; j <= n-1; j++) {
        lc = lc+2;         // this counts loop test and incrementing j in loop
	key = A[j]; lc++;
	i = j-1; lc++;
	while (i >= 0 && A[i] > key) {
 	  lc = lc + 2;     // this counts the two tests in the while loop
	  A[i+1] = A[i]; lc++;
	  i=i-1; lc++;
		}
	A[i+1] = key; lc++;
	}
   return;
}

