import struct


def guid2bytes(s):
    """Converts a GUID to the serialized bytes representation"""

    assert isinstance(s, str)
    assert len(s) == 36

    p = struct.pack
    return b"".join([
        p("<IHH", int(s[:8], 16), int(s[9:13], 16), int(s[14:18], 16)),
        p(">H", int(s[19:23], 16)),
        p(">Q", int(s[24:], 16))[2:],
    ])