#include <stdio.h>

main() {
	FILE *arq;
	char img[66];
	int i;
	char quanto,byte;
	arq=fopen("xpak.olinux","rb");
	if (arq==NULL) {
		printf("Arquivo xpak.olinux nao existe\n");
		exit(0);
	}
	// Pegando largura
	fread(&byte,1,1,arq);
	img[0]=byte;
	// Pegando altura
	fread(&byte,1,1,arq);
	img[1]=byte;

	// Descompactando
	i=2;
	while (i<66) { // Ja sabemos que descompactado vai ter tamanho 66
		fread(&quanto,1,1,arq);
		fread(&byte,1,1,arq);
		while (quanto != 0) {
			img[i]=byte;
			i++;
			quanto--;
		}
	}
	fclose(arq);

	arq=fopen("unpak.olinux","wb");
	fwrite(img,1,66,arq);
	fclose(arq);
}
