<gh_stars>100-1000
import sys
import struct

def header_check(sval, cval):
	temp = (sval << 16) & 0xffffffff
	temp = ~temp
	temp += sval
	sval = temp & 0xffffffff
	temp = temp >> 5
	temp ^= sval
	temp &= 0xffffffff
	temp *= 9
	temp &= 0xffffffff
	sval = temp
	sval = sval >> 0xd
	temp ^= sval
	temp &= 0xffffffff
	sval = temp << 9
	sval &= 0xffffffff
	sval = ~sval
	temp += sval
	temp &= 0xffffffff
	sval = temp >> 0x11
	sval ^= temp
	sval &= 0xffffffff
	print(hex(sval))
	print(hex(cval))
	if sval == cval:
		return True
	else:
		return False



data = open(sys.argv[1],'rb').read()

key = bytearray(data[:4])

(sval, cval,) = struct.unpack_from('<II', data)

if (header_check(sval, cval)):
	print("Check good!")
data = bytearray(data[14:])

for i in range(len(data)):
	data[i] ^= key[i%len(key)]

print(data)

import sys
import struct

def header_check(sval, cval):
	temp = (sval << 16) & 0xffffffff
	temp = ~temp
	temp += sval
	sval = temp & 0xffffffff
	temp = temp >> 5
	temp ^= sval
	temp &= 0xffffffff
	temp *= 9
	temp &= 0xffffffff
	sval = temp
	sval = sval >> 0xd
	temp ^= sval
	temp &= 0xffffffff
	sval = temp << 9
	sval &= 0xffffffff
	sval = ~sval
	temp += sval
	temp &= 0xffffffff
	sval = temp >> 0x11
	sval ^= temp
	sval &= 0xffffffff
	print(hex(sval))
	print(hex(cval))
	if sval == cval:
		return True
	else:
		return False



data = open(sys.argv[1],'rb').read()

key = bytearray(data[:4])

(sval, cval,) = struct.unpack_from('<II', data)

if (header_check(sval, cval)):
	print("Check good!")
data = bytearray(data[14:])

for i in range(len(data)):
	data[i] ^= key[i%len(key)]

print(data)