#include <stdlib.h>
#include <string.h>

#define BOOL bool
#define UINT64 unsigned long long


BOOL VerifySerial(UINT64 name, UINT64 serial)
{
    UINT64 result = 0;
    UINT64 a = (UINT64)1 << 63;
    UINT64 b = 0xA348FCCD93AEA5A7LL;

    if(name & a)
        name ^= b;
    if(serial & a)
        serial ^= b;

    while(serial)
    {
        if(serial & 1)
            result ^= name;

        serial >>= 1;
        name <<= 1;

        if(name & a)
            name ^= b;
    }

    return (result == 1);
}

int main(int argc, char** argv)
{
	char name[8];

	if (argc != 3)
		return 1;

	memset(name,0,8);
	strncpy(name,argv[1],8);
	return !VerifySerial(*((UINT64*)name), strtoull(argv[2], NULL, 16));
}
