clen = 0;
diffreg(char *ofile1, char *ofile2, int flags){	char *file1 = ofile1;	char *file2 = ofile2;	FILE *f1 = NULL;	FILE *f2 = NULL;	int rval = D_SAME;	int i, ostdout = -1;	pid_t pid = -1;	anychange = 0;	context_vec_ptr = context_vec_start - 1;	chrtran = (iflag ? cup2low : clow2low);	if (S_ISDIR(stb1.st_mode) != S_ISDIR(stb2.st_mode))		return (S_ISDIR(stb1.st_mode) ? D_MISMATCH1 : D_MISMATCH2);	if (strcmp(file1, "-") == 0 && strcmp(file2, "-") == 0)		goto notsame;	if (flags & D_EMPTY1)		f1 = fopen(_PATH_DEVNULL, "r");	else {		if (!S_ISREG(stb1.st_mode)) {			if ((f1 = opentemp(file1)) == NULL ||			    fstat(fileno(f1), &stb1) < 0) {				warn("%s", file1);				status |= 2;				goto closem;			}		} else if (strcmp(file1, "-") == 0)			f1 = stdin;		else			f1 = fopen(file1, "r");	}	if (f1 == NULL) {		warn("%s", file1);		status |= 2;		goto closem;	}	if (flags & D_EMPTY2)		f2 = fopen(_PATH_DEVNULL, "r");	else {		if (!S_ISREG(stb2.st_mode)) {			if ((f2 = opentemp(file2)) == NULL ||			    fstat(fileno(f2), &stb2) < 0) {				warn("%s", file2);				status |= 2;				goto closem;			}		} else if (strcmp(file2, "-") == 0)			f2 = stdin;		else			f2 = fopen(file2, "r");	}	if (f2 == NULL) {		warn("%s", file2);		status |= 2;		goto closem;	}	switch (files_differ(f1, f2, flags)) {	case 0:		goto closem;	case 1:		break;	default:		/* error */		status |= 2;		goto closem;	}notsame:	/*	 * Files certainly differ at this point; set status accordingly	 */	status |= 1;	rval = D_DIFFER;	if (!asciifile(f1) || !asciifile(f2)) {		rval = D_BINARY;		goto closem;	}	if (format == D_BRIEF)		goto closem;	if (lflag) {		/* redirect stdout to pr */		int pfd[2];		char *header;		char *prargv[] = { "pr", "-h", NULL, "-f", NULL };		easprintf(&header, "%s %s %s", diffargs, file1, file2);		prargv[2] = header;		fflush(stdout);		rewind(stdout);		pipe(pfd);		switch ((pid = fork())) {		case -1:			warnx("No more processes");			status |= 2;			free(header);			return (D_ERROR);		case 0:			/* child */			if (pfd[0] != STDIN_FILENO) {				dup2(pfd[0], STDIN_FILENO);				close(pfd[0]);			}			close(pfd[1]);			execv(_PATH_PR, prargv);			_exit(127);		default:			/* parent */			if (pfd[1] != STDOUT_FILENO) {				ostdout = dup(STDOUT_FILENO);				dup2(pfd[1], STDOUT_FILENO);				close(pfd[1]);			}			close(pfd[0]);			rewind(stdout);			free(header);		}	} else if (flags & D_HEADER)		printf("%s %s %s\n", diffargs, file1, file2);	prepare(0, f1);	prepare(1, f2);	prune();	sort(sfile[0], slen[0]);	sort(sfile[1], slen[1]);	member = (int *)file[1];	equiv(sfile[0], slen[0], sfile[1], slen[1], member);	member = erealloc(member, (slen[1] + 2) * sizeof(int));	class = (int *)file[0];	unsort(sfile[0], slen[0], class);	class = erealloc(class, (slen[0] + 2) * sizeof(int));	klist = emalloc((slen[0] + 2) * sizeof(int));	clistlen = 100;	clist = emalloc(clistlen * sizeof(cand));	i = stone(class, slen[0], member, klist);	free(member);	free(class);	J = erealloc(J, (len[0] + 2) * sizeof(int));	unravel(klist[i]);	free(clist);	free(klist);	ixold = erealloc(ixold, (len[0] + 2) * sizeof(long));	ixnew = erealloc(ixnew, (len[1] + 2) * sizeof(long));	check(file1, f1, file2, f2);	output(file1, f1, file2, f2);	if (ostdout != -1) {		int wstatus;		/* close the pipe to pr and restore stdout */		fflush(stdout);		rewind(stdout);		if (ostdout != STDOUT_FILENO) {			close(STDOUT_FILENO);			dup2(ostdout, STDOUT_FILENO);			close(ostdout);		}		waitpid(pid, &wstatus, 0);	}closem:	if (f1 != NULL)		fclose(f1);	if (f2 != NULL)		fclose(f2);	if (file1 != ofile1)		free(file1);	if (file2 != ofile2)		free(file2);	return (rval);}