/* Exchange the block from nonopt_start to nonopt_end with the block from nonopt_end to opt_end (keeping the same order of arguments in each block).  */
static void permute_args(int, int, int, char *const *)
/* Exchange the block from nonopt_start to nonopt_end with the block from nonopt_end to opt_end (keeping the same order of arguments in each block).  */
static void permute_args(int, int, int, char *const *)
{
	int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
	char *swap;
	nnonopts = panonopt_end - panonopt_start;
	nopts = opt_end - panonopt_end;
	ncycle = gcd(nnonopts, nopts);
	cyclelen = (opt_end - panonopt_start) / ncycle;
	for (i = 0; i < ncycle; i++) {
		cstart = panonopt_end+i;
		pos = cstart;
		for (j = 0; j < cyclelen; j++) {
			if (pos >= panonopt_end)
				pos -= nnonopts;
			else
				pos += nopts;
			swap = nargv[pos];
			((char **) nargv)[pos] = nargv[cstart];
			((char **)nargv)[cstart] = swap;
		}
	}
}