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

#define MAX_CRC 3

struct game {
	char name[32];
	unsigned int magic;
	unsigned int crcOffset[MAX_CRC];
	unsigned short (*crcCalculation[MAX_CRC])(unsigned char *data);
};

unsigned short fifa06emyclubcrc(unsigned char *data);
unsigned short fifa07ecrc(unsigned char *data);
unsigned short fifa07ucrc(unsigned char *data);
unsigned short fifa08ecrc(unsigned char *data);
unsigned short fifa09ecrc(unsigned char *data);
unsigned short fifa10ecrc(unsigned char *data);
unsigned short fifa10etournamentscrc(unsigned char *data);
unsigned short fifa10emyclubcrc(unsigned char *data);
unsigned short fifa11ecrc(unsigned char *data);

unsigned short fifaStreet2ecrc(unsigned char *data);
unsigned short fifaStreet2ucrc(unsigned char *data);
unsigned short fifaStreet3ecrc(unsigned char *data);

unsigned short fifaWorldCup2006e(unsigned char *data);

struct game games[] = {
	{
		name: "FIFA 06 E",
		magic: 0xF1FA06AA,
		crcOffset: { 0x10 },
		crcCalculation: { fifa06emyclubcrc, NULL },
	},
	
	{
		name: "FIFA 07 E",
		magic: 0xF1FA07BF,
		crcOffset: { 0x0A },
		crcCalculation: { fifa07ecrc, NULL },
	},
	
	{
		name: "FIFA 07 U",
		magic: 0xF1FA07BD,
		crcOffset: { 0x0A },
		crcCalculation: { fifa07ucrc, NULL },
	},
	
	{
		name: "FIFA 08 E",
		magic: 0x10071981,
		crcOffset: { 0x04 },
		crcCalculation: { fifa08ecrc, NULL },
	},
	
	{
		name: "FIFA 09 E",
		magic: 0x10071982,
		crcOffset: { 0x04 },
		crcCalculation: { fifa09ecrc, NULL },
	},
	
	{
		name: "FIFA 10 E",
		magic: 0x10071983,
		crcOffset: { 0x04, 0x06, 0x10 },
		crcCalculation: { fifa10ecrc, fifa10etournamentscrc, fifa10emyclubcrc },
	},
	
	{
		name: "FIFA 11 E",
		magic: 0x93633892,
		crcOffset: { 0x000005d2 },
		crcCalculation: { fifa11ecrc },
	},
	
	{
		name: "FIFA Street 2 E",
		magic: 0xF1FA06AA,			// FIFA Street 2 E and FIFA 06 E use the same magic...
		crcOffset: { 0x0A },
		crcCalculation: { fifaStreet2ecrc, NULL },
	},
	
	{
		name: "FIFA Street 2 U",
		magic: 0xF1FA06EE,
		crcOffset: { 0x0A },
		crcCalculation: { fifaStreet2ucrc, NULL },
	},
	
	{
		name: "FIFA Street 3 E",
		magic: 0x0BADB00B,			// EA...
		crcOffset: { 0x06 },
		crcCalculation: { fifaStreet3ecrc, NULL },
	},
	
	{
		name: "FIFA World Cup 2006 (E)",
		magic: 0xF1FA06AC,
		crcOffset: { 0x0A },
		crcCalculation: { fifaWorldCup2006e, NULL },
	}
};

unsigned short fifa06emyclubcrc(unsigned char *data) {
	unsigned short crc = 21;
	int m = 0xD98 - 0x000003b8 + 1904;
	
	int i;
	for(i = 0x000003b8; i < 0x00001150; i++) {
		crc += data[i] * (m - (i & ~0x3));
	}
	
	return crc;
}

unsigned short fifa07ecrc(unsigned char *data) {
	unsigned short crc = 26;
	int m = 0x0000026C;
	
	int i;
	for(i = 0x00000028; i < 0x0000026B; i++) {
		crc += data[i] * (m - (i & ~0x3));
	}
	
	return crc;
}

unsigned short fifa07ucrc(unsigned char *data) {
	unsigned short crc = 24;
	int m = 0x0000026C;
	
	int i;
	for(i = 0x00000028; i < 0x0000026B; i++) {
		crc += data[i] * (m - (i & ~0x3));
	}
	
	return crc;
}

unsigned short fifa08ecrc(unsigned char *data) {
	unsigned short crc = 18723;
	int m = 0x000002C4;
	
	int i;
	for(i = 0x00000044; i < 0x00000500; i++) {
		crc += data[i] * (m - (i & ~0x3));
	}
	
	return crc;
}

unsigned short fifa09ecrc(unsigned char *data) {
	unsigned short crc = 19;
	
	int i;
	for(i = 0x00000020; i < 0x0000010D; i++) {
		crc += data[i] * (0x10C - i);
	}
	
	return crc;
}

unsigned short fifa10ecrc(unsigned char *data) {
	unsigned short crc = 19;
	
	int i;
	for(i = 0x00000040; i < 0x00000110; i++) {
		crc += data[i] * (0x10C - i + 4);
	}
	
	return crc;
}

unsigned short fifa10etournamentscrc(unsigned char *data) {
	unsigned short crc = 19;
	
	int i;
	for(i = 0x00000110; i < 0x000005f8; i++) {
		crc += data[i] * (0x4E8 - i + 0x00000110);
	}
	
	return crc;
}

unsigned short fifa10emyclubcrc(unsigned char *data) {
	unsigned short crc = 19;
	
	int i;
	for(i = 0x0000d8fc; i < 0x0000e1b8; i++) {
		crc += data[i] * (0x8BC - i + 0x0000d8fc);
	}
	
	return crc;
}

unsigned short fifa11ecrc(unsigned char *data) {
	unsigned short crc = -57707;
	
	int i;
	for(i = 0x000005d4; i < 0x00000718; i++) {
		crc += data[i] * (0xc7 - i + 0x000005dd);
	}
	
	return crc;<commit_msg>FIFA 11 (E) more CRC sections<commit_after>#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>

#define MAX_CRC 3

struct game {
	char name[32];
	unsigned int magic;
	unsigned int crcOffset[MAX_CRC];
	unsigned short (*crcCalculation[MAX_CRC])(unsigned char *data);
};

unsigned short fifa06emyclubcrc(unsigned char *data);
unsigned short fifa07ecrc(unsigned char *data);
unsigned short fifa07ucrc(unsigned char *data);
unsigned short fifa08ecrc(unsigned char *data);
unsigned short fifa09ecrc(unsigned char *data);
unsigned short fifa10ecrc(unsigned char *data);
unsigned short fifa10etournamentscrc(unsigned char *data);
unsigned short fifa10emyclubcrc(unsigned char *data);
unsigned short fifa11emyprofilecrc(unsigned char *data);
unsigned short fifa11eoptionscrc(unsigned char *data);

unsigned short fifaStreet2ecrc(unsigned char *data);
unsigned short fifaStreet2ucrc(unsigned char *data);
unsigned short fifaStreet3ecrc(unsigned char *data);

unsigned short fifaWorldCup2006e(unsigned char *data);

struct game games[] = {
	{
		name: "FIFA 06 E",
		magic: 0xF1FA06AA,
		crcOffset: { 0x10 },
		crcCalculation: { fifa06emyclubcrc, NULL },
	},
	
	{
		name: "FIFA 07 E",
		magic: 0xF1FA07BF,
		crcOffset: { 0x0A },
		crcCalculation: { fifa07ecrc, NULL },
	},
	
	{
		name: "FIFA 07 U",
		magic: 0xF1FA07BD,
		crcOffset: { 0x0A },
		crcCalculation: { fifa07ucrc, NULL },
	},
	
	{
		name: "FIFA 08 E",
		magic: 0x10071981,
		crcOffset: { 0x04 },
		crcCalculation: { fifa08ecrc, NULL },
	},
	
	{
		name: "FIFA 09 E",
		magic: 0x10071982,
		crcOffset: { 0x04 },
		crcCalculation: { fifa09ecrc, NULL },
	},
	
	{
		name: "FIFA 10 E",
		magic: 0x10071983,
		crcOffset: { 0x04, 0x06, 0x10 },
		crcCalculation: { fifa10ecrc, fifa10etournamentscrc, fifa10emyclubcrc },
	},
	
	{
		name: "FIFA 11 E",
		magic: 0x93633892,
		crcOffset: { 0x000005d2, 0x000006a4 },
		crcCalculation: { fifa11emyprofilecrc, fifa11eoptionscrc, NULL },
	},
	
	{
		name: "FIFA Street 2 E",
		magic: 0xF1FA06AA,			// FIFA Street 2 E and FIFA 06 E use the same magic...
		crcOffset: { 0x0A },
		crcCalculation: { fifaStreet2ecrc, NULL },
	},
	
	{
		name: "FIFA Street 2 U",
		magic: 0xF1FA06EE,
		crcOffset: { 0x0A },
		crcCalculation: { fifaStreet2ucrc, NULL },
	},
	
	{
		name: "FIFA Street 3 E",
		magic: 0x0BADB00B,			// EA...
		crcOffset: { 0x06 },
		crcCalculation: { fifaStreet3ecrc, NULL },
	},
	
	{
		name: "FIFA World Cup 2006 (E)",
		magic: 0xF1FA06AC,
		crcOffset: { 0x0A },
		crcCalculation: { fifaWorldCup2006e, NULL },
	}
};

unsigned short fifa06emyclubcrc(unsigned char *data) {
	unsigned short crc = 21;
	int m = 0xD98 - 0x000003b8 + 1904;
	
	int i;
	for(i = 0x000003b8; i < 0x00001150; i++) {
		crc += data[i] * (m - (i & ~0x3));
	}
	
	return crc;
}

unsigned short fifa07ecrc(unsigned char *data) {
	unsigned short crc = 26;
	int m = 0x0000026C;
	
	int i;
	for(i = 0x00000028; i < 0x0000026B; i++) {
		crc += data[i] * (m - (i & ~0x3));
	}
	
	return crc;
}

unsigned short fifa07ucrc(unsigned char *data) {
	unsigned short crc = 24;
	int m = 0x0000026C;
	
	int i;
	for(i = 0x00000028; i < 0x0000026B; i++) {
		crc += data[i] * (m - (i & ~0x3));
	}
	
	return crc;
}

unsigned short fifa08ecrc(unsigned char *data) {
	unsigned short crc = 18723;
	int m = 0x000002C4;
	
	int i;
	for(i = 0x00000044; i < 0x00000500; i++) {
		crc += data[i] * (m - (i & ~0x3));
	}
	
	return crc;
}

unsigned short fifa09ecrc(unsigned char *data) {
	unsigned short crc = 19;
	
	int i;
	for(i = 0x00000020; i < 0x0000010D; i++) {
		crc += data[i] * (0x10C - i);
	}
	
	return crc;
}

unsigned short fifa10ecrc(unsigned char *data) {
	unsigned short crc = 19;
	
	int i;
	for(i = 0x00000040; i < 0x00000110; i++) {
		crc += data[i] * (0x10C - i + 4);
	}
	
	return crc;
}

unsigned short fifa10etournamentscrc(unsigned char *data) {
	unsigned short crc = 19;
	
	int i;
	for(i = 0x00000110; i < 0x000005f8; i++) {
		crc += data[i] * (0x4E8 - i + 0x00000110);
	}
	
	return crc;
}

unsigned short fifa10emyclubcrc(unsigned char *data) {
	unsigned short crc = 19;
	
	int i;
	for(i = 0x0000d8fc; i < 0x0000e1b8; i++) {
		crc += data[i] * (0x8BC - i + 0x0000d8fc);
	}
	
	return crc;
}

unsigned short fifa11emyprofilecrc(unsigned char *data) {
	unsigned short crc = 19;
	
	int i;
	for(i = 0x000005d4; i < 0x000006a4; i++) {
		crc += data[i] * (0xc7 - i + 0x000005dd);
	}
	
	return crc;
}

unsigned short fifa11eoptionscrc(unsigned char *data) {
	unsigned short crc = 1075;
	
	int i;
	for(i = 0x000006a6; i < 0x00000706; i++) {
		crc += data[i] * (0x60 - i + 0x000006b6);
	}
	
	return crc;
{'fraction_non_alphanumeric': 0.13832689247556262, 'fraction_numerical': 0.10866105933166628, 'mean_word_length': 3.675345377258236, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 11, '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': '192437', 'n_tokens_mistral': 4654, 'n_tokens_neox': 3725, 'n_words': 945}