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uZXIKICAgRGVzY3JpcHRpb246IEJsb2NrIHN3aXRjaGluZwoKKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwoKLyoqKioqKioqKioqKioqKioqKiBJbmNsdWRlcyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KCiNpbmNsdWRlICJibG9ja19zd2l0Y2guaCIKI2luY2x1ZGUgImdlbmVyaWNTdGRzLmgiCgoKI2RlZmluZSBMT1dPVl9XSU5ET1cgX0xPV09WX1dJTkRPVwoKLyoqKioqKioqKioqKioqKiogaW50ZXJuYWwgZnVuY3Rpb24gcHJvdG90eXBlcyAqKioqKioqKioqKi8KCnN0YXRpYyBGSVhQX0RCTCBGREthYWNFbmNfR2V0V2luZG93RW5lcmd5KGNvbnN0IEZJWFBfREJMIGluW10sIGNvbnN0IElOVCBibFN3V25kSWR4KTsKCnN0YXRpYyB2b2lkIEZES2FhY0VuY19DYWxjV2luZG93RW5lcmd5KCBCTE9DS19TV0lUQ0hJTkdfQ09OVFJPTCAqUkVTVFJJQ1QgYmxvY2tTd2l0Y2hpbmdDb250cm9sLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJTlQgICAgICAgICAgICAgICAgICAgICAgd2luZG93TGVuKTsKCgovKioqKioqKioqKioqKioqKioqIENvbnN0YW50cyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBMT05HICAgICAgICAgU1RBUlQgICAgICAgIFNIT1JUICAgICAgICAgU1RPUCAgICAgICAgIExPV09WICAgICAgICAgICAgICAgICAgKi8Kc3RhdGljIGNvbnN0IElOVCBibG9ja1R5cGUyd2luZG93U2hhcGVbMl1bNV0gPSB7IHtTSU5FX1dJTkRPVywgS0JEX1dJTkRPVywgIFdST05HX1dJTkRPVywgU0lORV9XSU5ET1csIEtCRF9XSU5ET1d9L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