<commit_before>#include "c.h"

static char rcsid[] = "$Id$";

#define iscall(op) (generic(op) == CALL \
	|| IR->mulops_calls \
	&& (generic(op)==DIV||generic(op)==MOD||generic(op)==MUL) \
	&& ( optype(op)==U  || optype(op)==I))
static Node forest;
static struct dag {
	struct node node;
	struct dag *hlink;
} *buckets[16];
int nodecount;
static Tree firstarg;
int assignargs = 1;
int prunetemps = -1;
static Node *tail;

static int depth = 0;
static Node replace(Node);
static Node prune(Node);
static Node asgnnode(Symbol, Node);
static struct dag *dagnode(int, Node, Node, Symbol);
static Symbol equated(Symbol);
static void fixup(Node);
static void labelnode(int);
static void list(Node);
static void killnodes(Symbol);
static Node node(int, Node, Node, Symbol);
static void printdag1(Node, int, int);
static void printnode(Node, int, int);
static void reset(void);
static Node tmpnode(Node);
static void typestab(Symbol, void *);
static Node undag(Node);
static Node visit(Node, int);
static void unlist(void);
void walk(Tree tp, int tlab, int flab) {
	listnodes(tp, tlab, flab);
	if (forest) {
		Node list = forest->link;
		forest->link = NULL;
		if (!IR->wants_dag && errcnt == 0)
			list = undag(list);
		code(Gen)->u.forest = list;
		forest = NULL;
	}
	reset();
	deallocate(STMT);
}

static Node node(int op, Node l, Node r, Symbol sym) {
	int i;
	struct dag *p;

	i = (opindex(op)^((unsigned long)sym>>2))&(NELEMS(buckets)-1);
	for (p = buckets[i]; p; p = p->hlink)
		if (p->node.op      == op && p->node.syms[0] == sym
		&&  p->node.kids[0] == l  && p->node.kids[1] == r)
			return &p->node;
	p = dagnode(op, l, r, sym);
	p->hlink = buckets[i];
	buckets[i] = p;
	++nodecount;
	return &p->node;
}
static struct dag *dagnode(int op, Node l, Node r, Symbol sym) {
	struct dag *p;

	NEW0(p, FUNC);
	p->node.op = op;
	if ((p->node.kids[0] = l) != NULL)
		++l->count;
	if ((p->node.kids[1] = r) != NULL)
		++r->count;
	p->node.syms[0] = sym;
	return p;
}
Node newnode(int op, Node l, Node r, Symbol sym) {
	return &dagnode(op, l, r, sym)->node;
}
static void killnodes(Symbol p) {
	int i;
	struct dag **q;

	for (i = 0; i < NELEMS(buckets); i++)
		for (q = &buckets[i]; *q; )
			if (generic((*q)->node.op) == INDIR &&
			    (!isaddrop((*q)->node.kids[0]->op)
			     || (*q)->node.kids[0]->syms[0] == p)) {
				*q = (*q)->hlink;
				--nodecount;
			} else
				q = &(*q)->hlink;
}
static void reset(void) {
	if (nodecount > 0)
		memset(buckets, 0, sizeof buckets);
	nodecount = 0;
}
Node listnodes(Tree tp, int tlab, int flab) {
	Node p = NULL, l, r;
	int op;

	assert(tlab || flab || tlab == 0 && flab == 0);
	if (tp == NULL)
		return NULL;
	if (tp->node)
		return tp->node;
	if (isarray(tp->type))
		op = tp->op + sizeop(voidptype->size);
	else
		op = tp->op + sizeop(tp->type->size);
	switch (generic(tp->op)) {
	case AND:   { if (depth++ == 0) reset();
		      if (flab) {
		      	listnodes(tp->kids[0], 0, flab);<commit_msg>Corrected assertion.<commit_after>#include "c.h"

static char rcsid[] = "$Id$";

#define iscall(op) (generic(op) == CALL \
	|| IR->mulops_calls \
	&& (generic(op)==DIV||generic(op)==MOD||generic(op)==MUL) \
	&& ( optype(op)==U  || optype(op)==I))
static Node forest;
static struct dag {
	struct node node;
	struct dag *hlink;
} *buckets[16];
int nodecount;
static Tree firstarg;
int assignargs = 1;
int prunetemps = -1;
static Node *tail;

static int depth = 0;
static Node replace(Node);
static Node prune(Node);
static Node asgnnode(Symbol, Node);
static struct dag *dagnode(int, Node, Node, Symbol);
static Symbol equated(Symbol);
static void fixup(Node);
static void labelnode(int);
static void list(Node);
static void killnodes(Symbol);
static Node node(int, Node, Node, Symbol);
static void printdag1(Node, int, int);
static void printnode(Node, int, int);
static void reset(void);
static Node tmpnode(Node);
static void typestab(Symbol, void *);
static Node undag(Node);
static Node visit(Node, int);
static void unlist(void);
void walk(Tree tp, int tlab, int flab) {
	listnodes(tp, tlab, flab);
	if (forest) {
		Node list = forest->link;
		forest->link = NULL;
		if (!IR->wants_dag && errcnt == 0)
			list = undag(list);
		code(Gen)->u.forest = list;
		forest = NULL;
	}
	reset();
	deallocate(STMT);
}

static Node node(int op, Node l, Node r, Symbol sym) {
	int i;
	struct dag *p;

	i = (opindex(op)^((unsigned long)sym>>2))&(NELEMS(buckets)-1);
	for (p = buckets[i]; p; p = p->hlink)
		if (p->node.op      == op && p->node.syms[0] == sym
		&&  p->node.kids[0] == l  && p->node.kids[1] == r)
			return &p->node;
	p = dagnode(op, l, r, sym);
	p->hlink = buckets[i];
	buckets[i] = p;
	++nodecount;
	return &p->node;
}
static struct dag *dagnode(int op, Node l, Node r, Symbol sym) {
	struct dag *p;

	NEW0(p, FUNC);
	p->node.op = op;
	if ((p->node.kids[0] = l) != NULL)
		++l->count;
	if ((p->node.kids[1] = r) != NULL)
		++r->count;
	p->node.syms[0] = sym;
	return p;
}
Node newnode(int op, Node l, Node r, Symbol sym) {
	return &dagnode(op, l, r, sym)->node;
}
static void killnodes(Symbol p) {
	int i;
	struct dag **q;

	for (i = 0; i < NELEMS(buckets); i++)
		for (q = &buckets[i]; *q; )
			if (generic((*q)->node.op) == INDIR &&
			    (!isaddrop((*q)->node.kids[0]->op)
			     || (*q)->node.kids[0]->syms[0] == p)) {
				*q = (*q)->hlink;
				--nodecount;
			} else
				q = &(*q)->hlink;
}
static void reset(void) {
	if (nodecount > 0)
		memset(buckets, 0, sizeof buckets);
	nodecount = 0;
}
Node listnodes(Tree tp, int tlab, int flab) {
	Node p = NULL, l, r;
	int op;

	assert(tlab == 0 || flab == 0);
	if (tp == NULL)
		return NULL;
	if (tp->node)
		return tp->node;
	if (isarray(tp->type))
		op = tp->op + sizeop(voidptype->size);
	else
		op = tp->op + sizeop(tp->type->size);
	switch (generic(tp->op)) {
	case AND:   { if (depth++ == 0) reset();
		      if (flab) {
		      	listnodes(tp->kids[0], 0, flab);
{'fraction_non_alphanumeric': 0.19815668202764977, 'fraction_numerical': 0.009557945041816009, 'mean_word_length': 3.760357432981316, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 83, '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': '5229163', 'n_tokens_mistral': 2507, 'n_tokens_neox': 2364, 'n_words': 656}