atquick_sort.c
contents ::
  quick.c
  quick_sort.s
  atquick_sort.s
  quick_sort.c
  atquick_sort.c

/* Quick sort with pointers updated for tail recursion */
void tquicksort(int *a, int lo, int hi){
  while( hi > lo ) {
    int left, right, median, temp;
    left=lo;
    right=hi;
    median=*(a+((lo+hi)/2));
    while(right >= left){
      
      while(*(a+left) < median) left++;
      
      while(*(a+right) > median) right--;
      if(left > right) break;
      
      temp=*(a+left);
      *(a+left)=*(a+right);
      *(a+right)=temp; //swap
      
      left++;
      right--;
    }

    
    tquicksort(a, lo, right);// divide and conquer
    lo=left;
  }
}/*quicksort*/

James Little