<commit_before>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>

#include "../inc/cc.h"
#include "cc2.h"


static char *opnames[] = {
	[PUSH] = "PUSH", [POP] = "POP", [LD]  = "LD", [ADD] = "ADD",
	[RET]  = "RET" , [ADDI]= "ADD", [LDI] = "LD", [ADDX] = "ADD",
	[ADCX] = "ADC" , [LDX] = "LD" , [LDFX] = "LD"
};

static char *regnames[] = {
	[AF] = "AF", [HL] = "HL", [DE] = "DE", [BC] = "BC", [IX] = "IX",
	[IY] = "IY", [SP] = "SP", [A]  = "A",  [F]  = "F",  [B]  = "B",
	[C]  = "C",  [D]  = "D",  [E]  = "E",  [H]  = "H",  [L]  = "L",
	[IXL]= "IXL",[IXH]= "IXH",[IYL]= "IYL",[IYH]= "IYH", [I] = "I"
};

static char *opfmt[] = {
	[RET]  = "\to",
	[PUSH] = "\to\tr",
	[POP]  = "\to\tr",
	[ADD]  = "\to\tr,r",
	[LD]   = "\to\tr,r",
	[ADDI] = "\to\tr,i",
	[LDI]  = "\to\tr,i",
	[ADDX] = "\to\tr,(r+i)",
	[ADCX] = "\to\tr,(r+i)",
	[LDFX] = "\to\tr,(r+i)",
	[LDX]  = "\to\t(r+i),r",
};

void
code(char op, ...)
{
	va_list va;
	char *cp, c;

	va_start(va, op);
	for (cp = opfmt[op]; c = *cp; ++cp) {
		switch (c) {
		case 'o':
			fputs(opnames[op], stdout);
			break;
		case 'r':
			fputs(regnames[va_arg(va, int)], stdout);
			break;
		case 'i':
			printf("%d", va_arg(va, int));
			break;
		default:
			putchar(c);
			break;
		}
	}
	putchar('\n');

	va_end(va);
}<commit_msg>Convert code in a wrapper function<commit_after>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>

#include "../inc/cc.h"
#include "cc2.h"


static char *opnames[] = {
	[PUSH] = "PUSH", [POP] = "POP", [LD]  = "LD", [ADD] = "ADD",
	[RET]  = "RET" , [ADDI]= "ADD", [LDI] = "LD", [ADDX] = "ADD",
	[ADCX] = "ADC" , [LDX] = "LD" , [LDFX] = "LD"
};

static char *regnames[] = {
	[AF] = "AF", [HL] = "HL", [DE] = "DE", [BC] = "BC", [IX] = "IX",
	[IY] = "IY", [SP] = "SP", [A]  = "A",  [F]  = "F",  [B]  = "B",
	[C]  = "C",  [D]  = "D",  [E]  = "E",  [H]  = "H",  [L]  = "L",
	[IXL]= "IXL",[IXH]= "IXH",[IYL]= "IYL",[IYH]= "IYH", [I] = "I"
};

static char *opfmt[] = {
	[RET]  = "\to",
	[PUSH] = "\to\tr",
	[POP]  = "\to\tr",
	[ADD]  = "\to\tr,r",
	[LD]   = "\to\tr,r",
	[ADDI] = "\to\tr,i",
	[LDI]  = "\to\tr,i",
	[ADDX] = "\to\tr,(r+i)",
	[ADCX] = "\to\tr,(r+i)",
	[LDFX] = "\to\tr,(r+i)",
	[LDX]  = "\to\t(r+i),r",
};

void
code(char op, ...)
{
}
{'fraction_non_alphanumeric': 0.3398184176394293, 'fraction_numerical': 0.0008646779074794639, 'mean_word_length': 3.0103986135181975, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '6023146', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1269, 'n_words': 258}