<commit_before>#include <stdio.h>
#include <stdlib.h>

enum Instructions {
  INUM, // 0
  IADD, // 1
  IMUL, // 2
  ISTORE, // 3
  ILOAD, // 4
  STR, // 5
  POP, // 6
  PRINT, // 7
  PRINTLN, // 8
  HALT // 9
};

const char *ins[10] = {
  "INUM",
  "IADD",
  "IMUL",
  "ISTORE",
  "ILOAD",
  "STR",
  "POP",
  "PRINT",
  "PRINTLN",
  "HALT"
};

/*
  INUM 1
  INUM 2
  IADD
  HALT
*/

const int code[14] = {0, 1,
                      0, 2,
                      1,
                      8,
                      0, 200,
                      3, 0,
                      4, 0,
                      7,
                      9};

void run(const int *code, int startingIndex, int dataSize, int trace) {
  int data[dataSize];
  int stack[1000];
  int sp = -1;
  int ip = startingIndex;
  // int fp = -1;

  int opcode = code[ip]; // fetch

  int x, y, idx;


  while (1) {

    if (trace) {
      fprintf(stderr, "%04d: %s(%d) ", ip, ins[opcode], opcode);
    }

    switch(opcode) { // decode
    case INUM: // execute INUM instruction
      x = code[++ip];
      stack[++sp] = x;
      if (trace) fprintf(stderr, "%i", x);
      break;

    case IADD:
      y = stack[sp--];
      x = stack[sp--];
      stack[++sp] = x + y;
      break;

    case IMUL:
      y = stack[sp--];
      x = stack[sp--];
      stack[++sp] = x * y;
      break;

    case ISTORE:
      idx = code[++ip];
      data[idx] = stack[sp--];
      if (trace) fprintf(stderr, "%i", idx);
      break;

    case ILOAD:
      idx = code[++ip];
      sp++;
      stack[sp] = data[idx];
      if (trace) fprintf(stderr, "%i", idx);
      break;

    case STR:
      break;

    case POP:
      sp--;
      break;

    case PRINT:
      if (trace) fprintf(stderr, "\n");
      printf("%i", stack[sp--]);
      fflush(stdout);
      break;

    case PRINTLN:
      if (trace) fprintf(stderr, "\n");
      printf("%i\n", stack[sp--]);
      break;

    case HALT:
      if (trace) fprintf(stderr, "\n");
      //printf("Top of stack (%i) is %i\n", sp, stack[sp]);
      return;

    default: fprintf(stderr, "Dafaq");
      exit(1);
    }

    if (trace) fprintf(stderr, "\n");

    // move to next opcode
    opcode = code[++ip];

  }
}

int main(int args, char **argv) {
  run(code, 0, 0, argv[1] || 0); // pass 1 as first arg to see disassembly
  return 0;
}<commit_msg>Intialize data area to size 10<commit_after>#include <stdio.h>
#include <stdlib.h>

enum Instructions {
  INUM, // 0
  IADD, // 1
  IMUL, // 2
  ISTORE, // 3
  ILOAD, // 4
  STR, // 5
  POP, // 6
  PRINT, // 7
  PRINTLN, // 8
  HALT // 9
};

const char *ins[10] = {
  "INUM",
  "IADD",
  "IMUL",
  "ISTORE",
  "ILOAD",
  "STR",
  "POP",
  "PRINT",
  "PRINTLN",
  "HALT"
};

/*
  INUM 1
  INUM 2
  IADD
  HALT
*/

const int code[14] = {0, 1,
                      0, 2,
                      1,
                      8,
                      0, 200,
                      3, 2,
                      4, 2,
                      7,
                      9};

void run(const int *code, int startingIndex, int dataSize, int trace) {
  int data[dataSize];
  int stack[1000];
  int sp = -1;
  int ip = startingIndex;
  // int fp = -1;

  int opcode = code[ip]; // fetch

  int x, y, idx;


  while (1) {

    if (trace) {
      fprintf(stderr, "%04d: %s(%d) ", ip, ins[opcode], opcode);
    }

    switch(opcode) { // decode
    case INUM: // execute INUM instruction
      x = code[++ip];
      stack[++sp] = x;
      if (trace) fprintf(stderr, "%i", x);
      break;

    case IADD:
      y = stack[sp--];
      x = stack[sp--];
      stack[++sp] = x + y;
      break;

    case IMUL:
      y = stack[sp--];
      x = stack[sp--];
      stack[++sp] = x * y;
      break;

    case ISTORE:
      idx = code[++ip];
      data[idx] = stack[sp--];
      if (trace) fprintf(stderr, "%i", idx);
      break;

    case ILOAD:
      idx = code[++ip];
      sp++;
      stack[sp] = data[idx];
      if (trace) fprintf(stderr, "%i", idx);
      break;

    case STR:
      break;

    case POP:
      sp--;
      break;

    case PRINT:
      if (trace) fprintf(stderr, "\n");
      printf("%i", stack[sp--]);
      fflush(stdout);
      break;

    case PRINTLN:
      if (trace) fprintf(stderr, "\n");
      printf("%i\n", stack[sp--]);
      break;

    case HALT:
      if (trace) fprintf(stderr, "\n");
      //printf("Top of stack (%i) is %i\n", sp, stack[sp]);
      return;

    default: fprintf(stderr, "Dafaq");
      exit(1);
    }

    if (trace) fprintf(stderr, "\n");

    // move to next opcode
    opcode = code[++ip];

  }
}

int main(int args, char **argv) {
  run(code, 0, 10, argv[1] || 0); // pass 1 as first arg to see disassembly
  return 0;
}
{'fraction_non_alphanumeric': 0.1775501493811353, 'fraction_numerical': 0.02112676056338028, 'mean_word_length': 1.5528322440087146, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1926074', 'n_tokens_mistral': 1858, 'n_tokens_neox': 1731, 'n_words': 485}