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0ZSB0byB0aGUgRnJlZSBTb2Z0d2FyZQogKiBGb3VuZGF0aW9uLCBJbmMuLCA1OSBUZW1wbGUgUGxhY2UsIFN1aXRlIDMzMCwgQm9zdG9uLAogKiBNQSAwMjExMS0xMzA3IFVTQQogKi8KCiNpZm5kZWYgX0ZET1NfSF8KI2RlZmluZSBfRkRPU19IXwoKCiN1bmRlZglGRE9TX0RFQlVHCgojaWZkZWYJRkRPU19ERUJVRwojZGVmaW5lCVBSSU5URihmbXQsYXJncy4uLikJcHJpbnRmIChmbXQgLCMjYXJncykKI2Vsc2UKI2RlZmluZSBQUklOVEYoZm10LGFyZ3MuLi4pCiNlbmRpZgoKLyogRGF0YSBzdHJ1Y3R1cmUgZGVzY3JpYmluZyBtZWRpYSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLwp0eXBlZGVmIHN0cnVjdCBmcwp7CiAgICB1bnNpZ25lZCBsb25nICAgICAgIHRvdF9zZWN0b3JzOwoKICAgIGludCAgICAgICAgICAgICAgICAgY2x1c3Rlcl9zaXplOwogICAgaW50ICAgICAgICAgICAgICAgICBudW1fY2x1czsKICAgIAogICAgaW50ICAgICAgICAgICAgICAgICBmYXRfc3RhcnQ7CiAgICBpbnQgICAgICAgICAgICAgICAgIGZhdF9sZW47CiAgICBpbnQgICAgICAgICAgICAgICAgIG5iX2ZhdDsKICAgIGludCAgICAgICAgICAgICAgICAgbnVtX2ZhdDsKICAgIAogICAgaW50ICAgICAgICAgICAgICAgICBkaXJfc3RhcnQ7CiAgICBpbnQgICAgICAgICAgICAgICAgIGRpcl9sZW47CgogICAgdW5zaWduZWQgY2hhciAgICAgICAqZmF0X2J1ZjsKICAgIAp9IEZzX3Q7CgovKiBEYXRhIHN0cnVjdHVyZSBkZXNjcmliaW5nIG9uZSBmaWxlIHN5c3RlbSBzbG90ICAgICAgICAgICAgICAgICAgICAgICAgICAgICovCnR5cGVkZWYgc3RydWN0IHNsb3QgewogICAgaW50ICgqbWFwKSAoc3RydWN0IGZzICpmcywKICAgICAgICAgICAgICAgIHN0cnVjdCBzbG90ICpmaWxlLAogICAgICAgICAgICAgICAgaW50IHdoZXJlLAogICAgICAgICAgICAgICAgaW50ICpsZW4pOwogICAgdW5zaWduZWQgbG9uZyBGaWxlU2l6ZTsKCiAgICB1bnNpZ25lZCBzaG9ydCBpbnQgRmlyc3RBYnNDbHVOcjsKICAgIHVuc2lnbmVkIHNob3J0IGludCBQcmV2aW91c0Fic0NsdU5yOwogICAgdW5zaWduZWQgc2hvcnQgaW50IFByZXZpb3VzUmVsQ2x1TnI7CgogICAgRGlyZWN0b3J5X3QgZGlyOwp9IFNsb3RfdDsKCnR5cGVkZWYgc3RydWN0IGZpbGUgewogICAgY2hhciAgICAgICAgICAgICAgICAqbmFtZTsKICAgIGludCAgICAgICAgICAgICAgICAgQ2FzZTsKICAgIEZzX3QgICAgICAgICAgICAgICAgKmZzOwogICAgU2xvdF90ICAgICAgICAgICAgICBzdWJkaXI7CiAgICBTbG90X3QgICAgICAgICAgICAgIGZpbGU7Cn0gRmlsZV90OwoKCi8qIGRldi5jICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KaW50IGRldl9yZWFkICh2b2lkICpidWZmZXIsIGludCB3aGVyZSwgaW50IGxlbik7CmludCBkZXZfb3BlbiAodm9pZCk7CmludCBjaGVja19kZXYgKEJvb3RTZWN0b3JfdCAqYm9vdCwgRnNfdCAqZnMpOwoKLyogZmF0LmMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLwp1bnNpZ25lZCBpbnQgZmF0X2RlY29kZSAoRnNfdCAqZnMsIHVuc2lnbmVkIGludCBudW0pOwppbnQgcmVhZF9mYXQgKEJvb3RTZWN0b3JfdCAqYm9vdCwgRnNfdCAqZnMpOwoKLyogdmZhdC5jICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLwppbnQgdmZhdF9sb29rdXAgKFNsb3RfdCAqZGlyLAogICAgICAgICAgICAgICAgIEZzX3QgKmZzLAogICAgICAgICAgICAgICAgIERpcmVjdG9yeV90ICpkaXJlbnQsCiAgICAgICAgICAgICAgICAgaW50ICplbnRyeSwKICAgICAgICAgICAgICAgICBpbnQgKnZmYXRfc3RhcnQsCiAgICAgICAgICAgICAgICAgY2hhciAqZmlsZW5hbWUsIAogICAgICAgICAgICAgICAgIGludCBmbGFncywKICAgICAgICAgICAgICAgICBjaGFyICpvdXRuYW1lLAogICAgICAgICAgICAgICAgIFNsb3RfdCAqZmlsZSk7CgovKiBzdWJkaXIuYyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICovCmNoYXIgKmJhc2VuYW1lIChjaGFyICpuYW1lKTsKaW50IG9wZW5fc3ViZGlyIChGaWxlX3QgKmRlc2MpOwppbnQgb3Blbl9maWxlIChTbG90X3QgKmZpbGUsIERpcmVjdG9yeV90ICpkaXIpOwppbnQgcmVhZF9maWxlIChGc190ICpmcywKICAgICAgICAgICAgICAgU2xvdF90ICpmaWxlLAogICAgICAgICAgICAgICBjaGFyICpidWYsCiAgICAgICAgICAgICAgIGludCB3aGVyZSwKICAgICAgICAgICAgICAgaW50IGxlbik7CnZvaWQgaW5pdF9zdWJkaXIgKHZvaWQpOwoKLyogZnMuYyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqLwppbnQgZnNfaW5pdCAoRnNfdCAqZnMpOwoKCiNlbmRpZgoK