<commit_before>#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif

#include "param.h"
#include "types.h"
#include "tes.h"
#include <em_flag.h>
#include <em_spec.h>
#include <em_mnem.h>
#include "alloc.h"
#include "line.h"
#include "proinf.h"
#include "optim.h"
#include "ext.h"

/*
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 *
 * Author: <NAME>
 */

flow() {

	findreach();	/* determine reachable labels */
	cleaninstrs();	/* throw away unreachable code */
}

findreach() {
	register num_p	*npp,np;

	reach(instrs);
	for(npp=curpro.numhash;npp< &curpro.numhash[NNUMHASH]; npp++)
		for(np= *npp; np != (num_p) 0 ; np = np->n_next)
			if (np->n_flags&NUMDATA) {
				np->n_repl->n_flags |= NUMREACH;
				np->n_repl->n_jumps++;
				if (!(np->n_flags&NUMSCAN)) {
					np->n_flags |= NUMSCAN;
					if (np->n_line) {
						reach(np->n_line->l_next);
						continue;
					}
					if (!(np->n_repl->n_flags&NUMSCAN)) {
						np->n_repl->n_flags |= NUMSCAN;
						if (np->n_repl->n_line)
						    reach(np->n_repl->n_line->l_next);
					}
				}
			}
}

reach(lnp) register line_p lnp; {
	register num_p np;

	for (;lnp != (line_p) 0; lnp = lnp->l_next) {
		if(lnp->l_optyp == OPNUMLAB) {
			/*
			 * Branch instruction or label
			 */
			np = lnp->l_a.la_np;
			if ((lnp->l_instr&BMASK) != op_lab)
				lnp->l_a.la_np = np = np->n_repl;
			np->n_flags |= NUMREACH;
			if (!(np->n_flags&NUMSCAN)) {
				np->n_flags |= NUMSCAN;
				if (np->n_line)
					reach(np->n_line->l_next);
				else {
					np = np->n_repl;
					np->n_flags |= NUMREACH;
					if (!(np->n_flags & NUMSCAN)) {
						np->n_flags |= NUMSCAN;
						if (np->n_line)
							reach(np->n_line->l_next);
					}
				}
			}
			if ((lnp->l_instr&BMASK) == op_lab)
				return;
			else
				np->n_jumps++;
		}
		if ((em_flag[(lnp->l_instr&BMASK)-sp_fmnem]&EM_FLO)==FLO_T)
			return;
	}
}

cleaninstrs() {
	register line_p *lpp,lp,*lastbra;
	bool reachable,superfluous;
	int instr;<commit_msg>Fix: had array bound error<commit_after>#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif

#include "param.h"
#include "types.h"
#include "tes.h"
#include <em_flag.h>
#include <em_spec.h>
#include <em_mnem.h>
#include "alloc.h"
#include "line.h"
#include "proinf.h"
#include "optim.h"
#include "ext.h"

/*
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 *
 * Author: <NAME>
 */

flow() {

	findreach();	/* determine reachable labels */
	cleaninstrs();	/* throw away unreachable code */
}

findreach() {
	register num_p	*npp,np;

	reach(instrs);
	for(npp=curpro.numhash;npp< &curpro.numhash[NNUMHASH]; npp++)
		for(np= *npp; np != (num_p) 0 ; np = np->n_next)
			if (np->n_flags&NUMDATA) {
				np->n_repl->n_flags |= NUMREACH;
				np->n_repl->n_jumps++;
				if (!(np->n_flags&NUMSCAN)) {
					np->n_flags |= NUMSCAN;
					if (np->n_line) {
						reach(np->n_line->l_next);
						continue;
					}
					if (!(np->n_repl->n_flags&NUMSCAN)) {
						np->n_repl->n_flags |= NUMSCAN;
						if (np->n_repl->n_line)
						    reach(np->n_repl->n_line->l_next);
					}
				}
			}
}

reach(lnp) register line_p lnp; {
	register num_p np;

	for (;lnp != (line_p) 0; lnp = lnp->l_next) {
		if(lnp->l_optyp == OPNUMLAB) {
			/*
			 * Branch instruction or label
			 */
			np = lnp->l_a.la_np;
			if ((lnp->l_instr&BMASK) != op_lab)
				lnp->l_a.la_np = np = np->n_repl;
			np->n_flags |= NUMREACH;
			if (!(np->n_flags&NUMSCAN)) {
				np->n_flags |= NUMSCAN;
				if (np->n_line)
					reach(np->n_line->l_next);
				else {
					np = np->n_repl;
					np->n_flags |= NUMREACH;
					if (!(np->n_flags & NUMSCAN)) {
						np->n_flags |= NUMSCAN;
						if (np->n_line)
							reach(np->n_line->l_next);
					}
				}
			}
			if ((lnp->l_instr&BMASK) == op_lab)
				return;
			else
				np->n_jumps++;
		}
		if ((lnp->l_instr & BMASK) > sp_lmnem) continue;
		if ((em_flag[(lnp->l_instr&BMASK)-sp_fmnem]&EM_FLO)==FLO_T)
			return;
	}
}

cleaninstrs() {
	register line_p *lpp,lp,*lastbra;
	bool reachable,superfluous;
	int instr;
{'fraction_non_alphanumeric': 0.1839080459770115, 'fraction_numerical': 0.0028735632183908046, 'mean_word_length': 3.0202117420596726, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 97, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5063256', 'n_tokens_mistral': 2114, 'n_tokens_neox': 1805, 'n_words': 338}