void NS_QuickSort (
extern "C" void NS_QuickSort (
void NS_QuickSort (	void *a,	unsigned int n,    unsigned int es,	cmp_t *cmp,	void *data    ){	char *pa, *pb, *pc, *pd, *pl, *pm, *pn;	int d, r, swaptype, swap_cnt;loop:	SWAPINIT(a, es);	swap_cnt = 0;	if (n < 7) {		for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)			for (pl = pm; pl > (char *)a && cmp(pl - es, pl, data) > 0;			     pl -= es)				swap(pl, pl - es);		return;	}	pm = (char *)a + (n / 2) * es;	if (n > 7) {		pl = (char *)a;		pn = (char *)a + (n - 1) * es;		if (n > 40) {			d = (n / 8) * es;			pl = med3(pl, pl + d, pl + 2 * d, cmp, data);			pm = med3(pm - d, pm, pm + d, cmp, data);			pn = med3(pn - 2 * d, pn - d, pn, cmp, data);		}		pm = med3(pl, pm, pn, cmp, data);	}	swap(a, pm);	pa = pb = (char *)a + es;	pc = pd = (char *)a + (n - 1) * es;	for (;;) {		while (pb <= pc && (r = cmp(pb, a, data)) <= 0) {			if (r == 0) {				swap_cnt = 1;				swap(pa, pb);				pa += es;			}			pb += es;		}		while (pb <= pc && (r = cmp(pc, a, data)) >= 0) {			if (r == 0) {				swap_cnt = 1;				swap(pc, pd);				pd -= es;			}			pc -= es;		}		if (pb > pc)			break;		swap(pb, pc);		swap_cnt = 1;		pb += es;		pc -= es;	}	if (swap_cnt == 0) {  /* Switch to insertion sort */		for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)			for (pl = pm; pl > (char *)a && cmp(pl - es, pl, data) > 0;			     pl -= es)				swap(pl, pl - es);		return;	}	pn = (char *)a + n * es;	r = PR_MIN(pa - (char *)a, pb - pa);	vecswap(a, pb - r, r);	r = PR_MIN(pd - pc, (int)(pn - pd - es));	vecswap(pb, pn - r, r);	if ((r = pb - pa) > (int)es)        NS_QuickSort(a, r / es, es, cmp, data);	if ((r = pd - pc) > (int)es) {		/* Iterate rather than recurse to save stack space */		a = pn - r;		n = r / es;		goto loop;	}/*		NS_QuickSort(pn - r, r / es, es, cmp, data);*/}