Skip to content

Instantly share code, notes, and snippets.

Created August 9, 2014 20:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/eab53c545c143ec65a4b to your computer and use it in GitHub Desktop.
Save anonymous/eab53c545c143ec65a4b to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <inttypes.h>
// only works on little-endian machines, i suppose
int main(int argc, char *argv[]) {
FILE *fp = fopen(argv[1], "rb");
fseek(fp, 0L, SEEK_END);
int s = ftell(fp);
fseek(fp, 0L, SEEK_SET);
uint32_t p1, p2, p3, p4;
p1 = p2 = p3 = p4 = 0x11111111;
uint32_t a1, a2, a3, a4;
s -= 16;
while (s > 0) {
fread(&a1, 4, 1, fp);
fread(&a2, 4, 1, fp);
fread(&a3, 4, 1, fp);
fread(&a4, 4, 1, fp);
p1 += a1;
p2 += (p1 < a1) + a2;
p3 += a3;
p4 += (p3 < a3) + a4;
s -= 16;
}
fclose(fp);
printf("%x %x %x %x\n", p1, p2, p3, p4);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment