<commit_before>#ifndef _XOPEN_SOURCE
#  define _XOPEN_SOURCE 500 /* getopt */
#endif
#include "backend/compile.h"
#include "core/cli.h"
#include "core/parse.h"
#include "core/string.h"
#include "core/symbol.h"
#include "frontend/input.h"
#include "frontend/preprocess.h"

#include <assert.h>
#include <stdio.h>
#include <unistd.h>

static void help(const char *prog)
{
    fprintf(stderr, "Usage: %s [-S] [-E] [-v] [-I <path>] [-o <file>] <file>\n",
        prog);
}

int main(int argc, char* argv[])
{
    enum compile_target target = TARGET_IR_DOT;
    char *input = NULL;
    FILE *output = stdout;
    int c;

    /* Handle command line parameters. */
    while ((c = getopt(argc, argv, "SEo:vI:")) != -1) {
        switch (c) {
        case 'S':
            target = TARGET_x86_64_ASM;
            break;
        case 'E':
            target = TARGET_NONE;
            break;
        case 'o':
            output = fopen(optarg, "w");
            break;
        case 'v':
            verbose_level += 1;
            break;
        case 'I':
            add_include_search_path(optarg);
            break;
        default:
            help(argv[0]);
            return 1;
        }
    }

    if (optind == argc - 1) {
        input = argv[optind];
    } else if (optind < argc - 1) {
        help(argv[0]);
        return 1;
    }

    /* Add default search paths last, with lowest priority. These are searched
     * after anything specified with -I. */
    add_include_search_path("/usr/include");
    add_include_search_path("/usr/local/include");

    init(input);
    register_builtin_definitions();
    set_compile_target(output, target);

    if (target == TARGET_NONE) {
        preprocess(output);
    } else {<commit_msg>Handle argument parsing in separate function<commit_after>#ifndef _XOPEN_SOURCE
#  define _XOPEN_SOURCE 500 /* getopt */
#endif
#include "backend/compile.h"
#include "core/cli.h"
#include "core/parse.h"
#include "core/string.h"
#include "core/symbol.h"
#include "frontend/input.h"
#include "frontend/preprocess.h"

#include <assert.h>
#include <stdio.h>
#include <unistd.h>

static char *input;
static FILE *output;

static void help(const char *prog)
{
    fprintf(stderr, "Usage: %s [-S] [-E] [-v] [-I <path>] [-o <file>] <file>\n",
        prog);
}

static enum compile_target parse_args(int argc, char *argv[])
{
    enum compile_target target;
    int c;

    target = TARGET_IR_DOT;
    output = stdout;

    while ((c = getopt(argc, argv, "SEo:vI:")) != -1) {
        switch (c) {
        case 'S':
            target = TARGET_x86_64_ASM;
            break;
        case 'E':
            target = TARGET_NONE;
            break;
        case 'o':
            output = fopen(optarg, "w");
            break;
        case 'v':
            verbose_level += 1;
            break;
        case 'I':
            add_include_search_path(optarg);
            break;
        default:
            help(argv[0]);
            exit(1);
        }
    }

    if (optind == argc - 1)
        input = argv[optind];
    else if (optind < argc - 1) {
        help(argv[0]);
        exit(1);
    }

    return target;
}

int main(int argc, char *argv[])
{
    enum compile_target target = parse_args(argc, argv);

    /* Add default search paths last, with lowest priority. These are searched
     * after anything specified with -I. */
    add_include_search_path("/usr/include");
    add_include_search_path("/usr/local/include");

    init(input);
    register_builtin_definitions();
    set_compile_target(output, target);

    if (target == TARGET_NONE) {
        preprocess(output);
    } else {
{'fraction_non_alphanumeric': 0.13962472406181015, 'fraction_numerical': 0.008278145695364239, 'mean_word_length': 2.1910211267605635, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, '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': '1291539', 'n_tokens_mistral': 1228, 'n_tokens_neox': 1191, 'n_words': 302}