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

#define TEMP_SOURCE_FILENAME "/tmp/source"
#define TEMP_DEST_BINARY "/tmp/binary"

int main(int argc, char *argv[]){

printf("start");
	//We need 4 arguments "program source -o binary"
	if(argc < 3){
		printf("Insufficient arguments\n");
		return 1;
	}

	char * sourceFilename = argv[1];

	FILE * inputFile;

	inputFile = fopen (sourceFilename, "r");

	if(inputFile == NULL){
		printf("File does not exist");
		return 1;
	}

	printf("before file size");
	//Read source file into buffer
	int sourceFileSize = getFileSize(inputFile);

		printf("Before malloc");
	unsigned char *buffer = (unsigned char *) malloc(sourceFileSize);
	printf("after malloc");
	fread(&buffer, sizeof(unsigned char), sourceFileSize, inputFile);
	fclose(inputFile);


	//Write source to /tmp directory
	FILE * tempDestFile;
	tempDestFile = fopen (TEMP_SOURCE_FILENAME, "w");

	if(inputFile == NULL){
		printf("File does not exist");
		return 1;
	} else {
		printf("file exists");
	}

	fwrite(buffer , sizeof(*buffer), sizeof(buffer), tempDestFile);
	fclose(tempDestFile);
	
	free(buffer);


	

}


int getFileSize(FILE * fp){
	//Go to end of file
	fseek (fp, 0, SEEK_END);

	//Get last position
	int end = ftell (fp);

	//Go back to start of file
	rewind (fp);
	return end;
}<commit_msg>initial compiler<commit_after>#include <stdio.h>
#include <stdlib.h>

void compileWithGCC(char * sourceBuffer, int bufferSize, char * destFilename);

int main(int argc, char *argv[]){

	//We need 4 arguments "program source -o binary"
	if(argc < 4){
		printf("Insufficient arguments\n");
		return 1;
	}

	char * sourceFilename = argv[1];
	char * destFilename = argv[3];

	FILE * inputFile = fopen(sourceFilename, "r");

	if(inputFile == NULL){
		printf("File does not exist");
		return 1;
	}

	
	//Get source file size
	fseek(inputFile, 0 , SEEK_END);
  	int sourceFileSize = ftell (inputFile);
  	rewind(inputFile);

  	//Read source file into buf
	char *buffer = (char *) malloc(sourceFileSize);
	int read = fread(buffer, sizeof(char), sourceFileSize, inputFile);
	fclose(inputFile);

	//We pass the source code to GCC as the backend compiler
	compileWithGCC(buffer, sourceFileSize, destFilename);

	free(buffer);

}



void compileWithGCC(char * sourceBuffer, int bufferSize, char * destFilename){
	char compileCommand[100];

	//Generate compile command, tell GCC to get source code via stdin
	sprintf(compileCommand, "gcc -o %s -xc -", destFilename);

	FILE *fp;
 	fp = popen(compileCommand, "w");
 	
 	//Pass source code to GCC via stdin
 	fwrite(sourceBuffer, sizeof(char), bufferSize, fp);

  	pclose(fp);

}
{'fraction_non_alphanumeric': 0.13536121673003804, 'fraction_numerical': 0.006463878326996198, 'mean_word_length': 4.369387755102041, 'pattern_counts': {'":': 0, '<': 9, '<?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': '7623491', 'n_tokens_mistral': 949, 'n_tokens_neox': 871, 'n_words': 266}