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IGh0b25sIChncm91cCk7CiAgcCA9IGlyZHBfZ2V0X3ByZWZpeChpZnApOwoKICBpZighcCkgewogICAgICAgIHpsb2dfd2FybiAoIklSRFA6IGNhbid0IGdldCBhZGRyZXNzIGZvciAlcyIsIGlmcC0+bmFtZSk7CglyZXR1cm4gMTsKICB9CgogIG0uaW1yX2ludGVyZmFjZSA9IHAtPnUucHJlZml4NDsKCiAgcmV0ID0gc2V0c29ja29wdCAoc29jaywgSVBQUk9UT19JUCwgYWRkX2xlYXZlLAoJCSAgICAoY2hhciAqKSAmbSwgc2l6ZW9mIChzdHJ1Y3QgaXBfbXJlcSkpOwogIGlmIChyZXQgPCAwKQogICAgemxvZ193YXJuICgiSVJEUDogJXMgY2FuJ3Qgc2V0c29ja29wdCAlczogJXMiLAoJICAgICAgIGFkZF9sZWF2ZSA9PSBJUF9BRERfTUVNQkVSU0hJUD8gImpvaW4gZ3JvdXAiOiJsZWF2ZSBncm91cCIsIAogICAgICAgICAgICAgICBpbmV0XzJhKGdyb3VwLCBiMSksCiAgICAgICAgICAgICAgIHN0cmVycm9yIChlcnJubykpOwoKICByZXR1cm4gcmV0Owp9CgppbnQgaWZfYWRkX2dyb3VwIChzdHJ1Y3QgaW50ZXJmYWNlICppZnApCnsKICBzdHJ1Y3QgemVicmFfaWYgKnppPSBpZnAtPmluZm87CiAgc3RydWN0IGlyZHBfaW50ZXJmYWNlICppcmRwID0gJnppLT5pcmRwOwogIGludCByZXQ7CgogIHJldCA9IGlmX2dyb3VwIChpZnAsIGlyZHBfc29jaywgSU5BRERSX0FMTFJUUlNfR1JPVVAsIElQX0FERF9NRU1CRVJTSElQKTsKICBpZiAocmV0IDwgMCkgewogICAgcmV0dXJuIHJldDsKICB9CgogIGlmKGlyZHAtPmZsYWdzICYgSUZfREVCVUdfTUlTQyApCiAgICB6bG9nX3dhcm4oIklSRFA6IEFkZGluZyBncm91cCAlcyBmb3IgJXNcbiIsIAoJICAgICAgaW5ldF8yYShodG9ubChJTkFERFJf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