LyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqDQoqDQoqICAgICAgICAgICAgICAgICAgQ29weXJpZ2h0IChjKSAyMDEzIFpURSBDb3Jwb3JhdGlvbi4NCioNCioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KKiDEoyC/6SDD+yA6IENjQXBwDQoqIM7EILz+IMP7IDogYXRfcHJvYy5jDQoqIM/gudjOxLz+IDoNCiogyrXP1rmmxNwgOiBBVMP8we63osvNus294bn7tKbA7cSjv+m6r8r9tqjS5Q0KKiDX9yAgICDV3yA6IHN5eA0KKiCw5iAgICCxviA6IFYxLjANCiogzeqzycjVxtogOiAyMDEzLTAxLTA1DQoqIMbky/zLtcP3IDoNCioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLw0KDQovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioNCiog0N64xLzHwrwgOg0KKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLw0KLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqDQoqINDeuMSx4LrFIDogMDAwMQ0KKiDQ3iC4xCDIyyA6DQoqINDeuMTI1cbaIDoNCiog0N64xMTayN0gOg0KKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovDQoNCi8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KKi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luY29taW5nX2NpZCh2b2lkKTsNCmludCB6Q2NfZmluZF9hbGxfY2FsbG91dChpbnQgc2xhdmVbWkNDX1NMQVZFU10pOw0KaW50IHpDY190YWxraW5nX2NvdW50KHZvaWQpOw0KY2hhciAqZ2V0X2xvY2FsX2RhdGVfdGltZSh2b2lkKTsNCmNoYXIgKmdldF9sb2NhbF9kYXRldGltZShjaGFyICpidWZmKTsNCg0KDQovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioNCiogs6PBv7ao0uXH+A0KKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovDQoNCi8qICB7DQogICAgWkNDX1NfSURMRV9TICAgICAgICA9IDAsDQogICAgWkNDX1NfRFRfUyAgICAgICAgICAgLA0KICAgIFpDQ19TX0RBQ0NNX1MgICAgLA0KICAgIFpDQ19TX0RJQUxJTkdfUyAgLA0KICAgIFpDQ19TX1JJTkdCQUNLX1MgICAsLy8g1ve90Ln9s8zW0LXE1fHB5cysDQogICAgWkNDX1NfQlNZVF9TICAgICAgICwNCiAgICBaQ0NfU19US1lUX1MgICAgICAgLA0KICAgIFpDQ19TX1NJTF9TICAgICAgICAsDQogICAgWkNDX1NfVEFMS0lOR19TICAgICwNCiAgICBaQ0NfU19UUllJTkdfUyAgICAgLA0KICAgIFpDQ19TX1dBSVRfUkVTT1VSQ0VfUyAsDQp9ICovDQpjb25zdCBwQ2NTbGF2ZUZzbUZ1bmMgekNjU2xhdmVGc21GdW5jW10gPSB7ekNjX1NJZGxlU3RhdGUsIA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHpDY19TRHRTdGF0ZSwgDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgekNjX1NEYWNjbVN0YXRlLCANCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB6Q2NfU0RpYWxpbmdTdGF0ZSwgDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgekNjX1NSaW5nYmFja1N0YXRlLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHpDY19TQnN5VG9uZVN0YXRlLCANCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB6Q2NfU1RreXRTdGF0ZSwgDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgekNjX1NTaWxTdGF0ZSwgDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgekNjX1NUYWxraW5nU3RhdGUsIA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHpDY19TVHJ5aW5nU3RhdGUsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgekNjX1NXYWl0UmVzb3VyY2VTdGF0ZQ0KICAgICAgICAgICAgICAgICAgICAgICAgfTsNCiAgICAvKg0KICAgIENCDQogICAgICAgICo1NCpLU1NTUyMgICAgIFJFR0lTVEVSICAgICAgICAgQVQrQ0xDSz0iQU8iLDEsIlNTU1MiDQogICAgICAgICM1NCpLU1NTUyMgICAgIERlUkVHSVNURVIgICAgICBBVCtDTENLPSJBTyIsMCwiU1NTUyINCiAgICAgICAgKiM1NCMgICAgICAgICAgICAgIFFVRVJZL0NIRUNLICAgIEFUK0NMQ0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6DQogICAgICAgIGNhc2UgWkNDX1RJTUVPVVRfU0lHTjoNCiAgICAgICAgICAgIHJldHVybiBaQ0NfRkxBU0hfMjsNCiAgICAgICAgY2FzZSAnMyc6DQogICAgICAgICAgICByZXR1cm4gWkNDX0ZMQVNIXzM7DQogICAgICAgIGNhc2UgJzQnOg0KICAgICAgICAgICAgcmV0dXJuIFpDQ19GTEFTSF80OyAgICANCiAgICAgICAgZGVmYXVsdDoNCiAgICAgICAgICAgIHJldHVybiBaQ0NfTUFUQ0hFUlI7DQogICAgICAgIH0NCiAgICB9DQoNCiAgICAvKmZvciAoaSA9IDA7IGk8c2NTdW07IGkrKykNCiAgICB7DQogICAgICAgIGlmIChzdHJuY21wKChDSEFSICopZ196Q2NfU0NUYWJbaV0uc2MsIChDSEFSICopZ19DY19DYWxsRGV0YWlsLmRpZ2l0cywgDQogICAgICAgICAgICAoVUlOVDMyKShzdHJsZW4oZ196Q2NfU0NUYWJbaV0uc2MpPGdfQ2NfQ2FsbERldGFpbC5kQ291bnQpP3N0cmxlbihnX3pDY19TQ1RhYltpXS5zYyk6Z19DY19DYWxsRGV0YWlsLmRDb3VudCkgPT0gMCkNCiAgICAgICAgeyANCiAgICAgICAgICAgIGlmIChnX0NjX0NhbGxEZXRhaWwuZGlnaXRzW2dfQ2NfQ2FsbERldGFpbC5kQ291bnQtMV0gPT0gJyMnKQ0KICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgIHJldHVybiBnX3pDY19TQ1RhYltpXS5zY05hbWU7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBpZiAoZ19DY19DYWxsRGV0YWlsLmRDb3VudCA8IGdfekNjX1NDVGFiW2ldLnNjTWF4TGVuKQ0KICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgIHJldHVybiBaQ0NfTk9fUkVTVUxUOw0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgaWYgKGdfQ2NfQ2FsbERldGFpbC5kQ291bnQgPT0gZ196Q2NfU0NUYWJbaV0u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CAocmV0KQ0KICAgIHsNCiAgICAgICAgY2FzZSBaQ0NfTk9fUkVTVUxUOg0KICAgICAgICAgICAgc2NfdGltZXJfY3JlYXRlKFpDQ0FQUF9USU1FUl9EVE1GX0RFVEVDVCwNCiAgICAgICAgICAgICAgICAgICAgICAgIDAsDQogICAgICAgICAgICAgICAgICAgICAgICBaQ0NBUFBfVElNRVJfRFRNRl9JTlRFUlZBTCwNCiAgICAgICAgICAgICAgICAgICAgICAgIHpDY0FwcF9EdG1mVGltZXIsDQogICAgICAgICAgICAgICAgICAgICAgICBOVUxMKTsgICAgICAgICAgICAgICAgICAgIA0KICAgICAgICAgICAgenRlX2xvZ19hcHBlbmQoX19GSUxFX18sIF9fTElORV9fLCAienRlX2NjYXBwLmxvZyIsIiVzICB6Q2NfRGlnaXRzTWF0Y2hSbHRQcm9jIHNjX3RpbWVyX2NyZWF0ZSB6Q2NBcHBfRHRtZlRpbWVyXG4iLF9fRlVOQ1RJT05fXyk7DQogICAgICAgICAgICByZXR1cm47DQogICAgICAgICAgICANCiAgICAgICAgY2FzZSBaQ0NfQ0FMTDoNCiAgICAgICAgICAgIGdfQ2NfQ2FsbERldGFpbC5zbGF2ZU9ialtzbGF2ZV0uc01zZyA9IFpDQ19TSU5WX007DQogICAgICAgICAgICBnX0NjX0NhbGxEZXRhaWwuc2xhdmVPYmpbc2xhdmVdLnN0YXRlID0gWkNDX1NfRElBTElOR19TOw0KICAgICAgICAgICAgaWYoZ19DY19DYWxsRGV0YWlsLmRpZ2l0c1swXSE9JyonICYmIChkaWdpdF9tYXBfY2FsbChnX0NjX0NhbGxEZXRhaWwuZGlnaXRzKT09MCkpDQogICAgICAgICAgICB7DQoJICAgICAgICAgICAgZ19DY19DYWxsRGV0YWlsLmRpZ2l0c1tnX0NjX0NhbGxEZXRhaWwuZENvdW50LTFdID0gMDsgDQoJICAgICAgICAgICAgZ19DY19DYWxsRGV0YWlsLmRDb3VudC0tOw0KICAgICAgICAgICAgfQ0KICAgICAgICAg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XywgX19MSU5FX18sICJ6dGVfY2NhcHAubG9nIiwiJXMgIHpDY19EaWdpdHNNYXRjaFJsdFByb2M6IFNMSUNfU3RhcnRfUENNIDwtLS1cbiIsX19GVU5DVElPTl9fKTsNCiAgICAgICAgICAgIGNobGRyZXQgPSB6Q2NfU2VuZEF0Q2hsZFJlcSgwKTsNCiAgICAgICAgICAgIGJyZWFrOw0KICAgICAgICAgICAgDQogICAgICAgIGNhc2UgWkNDX01BVENIRVJSOg0KICAgICAgICAgICAgaWYgKGdfQ2NfQ2FsbERldGFpbC5kaWdpdHNbMF0gIT0gWkNDX0ZMQVNIX1NJR04pDQogICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgekNjX0NsZWFyRGlnaXRzKCk7DQogICAgICAgICAgICAgICAgaWYgKDEgPT0gekNjX0J1c3lUb25lQWxsb3dlZCgpICYmIGdfQ2NfQ2FsbERldGFpbC5zdGF0ZSA9PSBaQ0NfTV9TRUlaRV9TKS8v09DG5Mv7uvS90Mqxsru3xcOm0vQNCiAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgIHNjX3RpbWVyX2NyZWF0ZShaQ0NBUFBfVElNRVJfQlVTWVRPTkVfREVURUNULA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAwLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBaQ0NBUFBfVElNRVJfQlVTWVRPTkVfSU5URVJWQUwsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHpDY0FwcF9CdXN5VG9uZVRpbWVyLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBOVUxMKTsgICAgICAgICAgICAgIA0KICAgICAgICAgICAgICAgICAgICB6dGVfbG9nX2FwcGVuZChfX0ZJTEVfXywgX19MSU5FX18sICJ6dGVfY2NhcHAubG9nIiwiJXMgIHpDY19EaWdpdHNNYXRjaFJsdFByb2Mgc2NfdGltZXJfY3JlYXRlIHpDY0FwcF9CdXN5VG9uZVRpbWVyXG4iLF9fRlVOQ1RJT05fXyk7DQogICAgICAgICAgICAgICAgICAgIGdfQ2NfQ2FsbERldGFpbC5zbGF2ZU9ialtzbGF2ZV0udG9uZSA9IFpDQ19UT05FX0JTWV9BOw0KICAgICAgICAgICAgICAgICAgICBnX0NjX0NhbGxEZXRhaWwuc2xhdmVPYmpbc2xhdmVdLnN0YXRlID0gWkNDX1NfQlNZVF9TOw0KICAgICAgICAgICAgICAgICAgICBnX0NjX0NhbGxEZXRhaWwuc2xhdmVPYmpbc2xhdmVdLmNvbmZjYWxsID0gMDsNCiAgICAgICAgICAgICAgICAgICAgZ19DY19DYWxsRGV0YWlsLnNsYXZlT2JqW3NsYXZlXS5oZWxkY2FsbCA9IDA7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIGVsc2UNCiAgICAgICAgICAgICAgICB7DQogICAgenRlX2xvZ19hcHBlbmQoX19GSUxFX18sIF9fTElORV9fLCAienRlX2NjYXBwLmxvZyIsIiVzICB6Q2NfSW5pdFNsYXZlT2JqOiBzbGF2ZU9ialslZF0gY2xlYXJlZFxuIixfX0ZVTkNUSU9OX18sIHNsYXZlKTsNCiAgICAgICAgICAgICAgICAgICAgekNjX0luaXRTbGF2ZU9iaihzbGF2ZSk7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIHJldHVybjsNCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIGJyZWFrOw0KICAgICAgICAgICAgDQogICAgICAgIGRlZmF1bHQ6IA0KICAgICAgICAgICAgaWYgKHJldCA+PSBaQ0NfQkFPQ19SRUcgJiYgcmV0IDw9IFpDQ19DRkJfREVSRUcpLy8gU1Mgc2xhdmU9MQ0KICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgIGdfQ2NfQ2FsbERldGFpbC5zbGF2ZU9ialtzbGF2ZV0uc01zZyA9IFpDQ19TSU5WX007DQogICAgICAgICAgICAgICAgZ19DY19DYWxsRGV0YWlsLnNsYXZlT2JqW3NsYXZlXS5zdGF0ZSA9IFpDQ19TX0lETEVfUzsvL7Hcw+K688PmudK7+rvht6LG8GNodXANCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIHJldHVybjsNCiAgICAgICAgfSAgIA0KDQogICAgICAgIHpDY19DbGVhckRpZ2l0cygpOw0KICAgICAgICAvL3pDY19Jbml0U2xhdmVPYmooc2xhdmUpOw0KfQ0KI2lmIDANClZPSUQgekNjX1ByZVByb2NSZXMoQ0hBUiAqcFBhcmFMaW5lKQ0Kew0KICAgIFNJTlQzMiAgZmxnICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID0gMDsNCiAgICBVSU5UMzIgIGkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA9IDA7DQogICAgVUlOVDMyICBsZW5ndGggICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPSAwOw0KICAgIENIQVIgICAgKnBTb3VyY2UgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID0gcFBhcmFMaW5lOw0KICAgIENIQVIgICAgKnBEZXN0ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID0gTlVMTDsNCg0KICAgIENIQVIgICAgKnBTdHJEZXN0TWFsbG9jID0gKENIQVIgKiltYWxsb2MoQVRfQ01EX01BWCk7DQogICAgaWYgKE5VTEwgPT0gcFN0ckRlc3RNYWxsb2MpDQogICAgew0KICAgICAgICB6dGVfbG9nX2FwcGVuZChfX0ZJTEVfXywgX19MSU5FX18sICJ6dGVfY2NhcHAubG9nIiwiJXMgIHpDY19QcmVQcm9jUmVzOiBNYWxsb2MgZmFpbGVkICEhIVxuIixfX0ZVTkNUSU9OX18pOw0KICAgICAgICByZXR1cm47DQogICAgfQ0KICAgIG1lbXNldChwU3RyRGVzdE1hbGxvYywgMCwgQVRfQ01EX01BWCk7IA0KDQogICAgYXNzZXJ0KHBQYXJhTGluZSAhPSBOVUxMKTsNCiAgICBwRGVzdCA9IHBTdHJEZXN0TWFsbG9jOw0KICAgIGxlbmd0aCA9IHN0cmxlbihwUGFyYUxpbmUpOw0KICAgIGlmIChsZW5ndGggPT0gMCB8fCBsZW5ndGggPj0gWkFUX01BWF9MRU4pDQogICAgew0KICAgICAgICBmcmVlKHBTdHJEZXN0TWFsbG9jKTsNCiAgICAgICAgcmV0dXJuOw0KICAgIH0NCiAgICBmb3IgKGkgPSAwOyAoaSA8IGxlbmd0aCApJiYgKHBEZXN0IC0gcFN0ckRlc3RNYWxsb2MgPCBBVF9DTURfTUFYKTsgaSsrKQ0KICAgIHsNCiAgICAgICAgaWYgKCciJyA9PSAqcFNvdXJjZSkNCiAgICAgICAgew0KICAgICAgICAgICAgZmxnID0gKDAgPT0gZmxnKT8xOjA7ICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogy6vS/brFIMm+s/0gICovDQogICAgICAgICAgICBpZiAoJyInID09ICoocFNvdXJjZSArIDEpKSAgICAgICAgICAgICAgICAgICAgICAvKiDQx7rFuvPD5r30uPrQx7rFo6yy5cjrv9W0rtW8zru3+yAqLw0KICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICpwRGVzdCsrID0gKENIQVIpWkFUX05VTExfRklMTDsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfQ0KICAgICAgICBlbHNlIGlmICgoJywnID09ICpwU291cmNlKSAmJiAoMCA9PSBmbGcpKQ0KICAgICAgICB7DQogICAgICAgICAgICAqcERlc3QrKyA9ICcgJzsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiDLq9L9usXN4sPmtcS2urrFo6zM5ru7s8m/1bjxICovDQogICAgICAgICAgICBpZiAoJywnID09ICoocFNvdXJjZSArIDEpKSAgICAgICAgICAgICAgICAgICAgICAgLyogtrq6xbrzw+a99Lj6trq6xaOsu/LV39LUtrq6xb3hzrKjrLLlyOu/1bSu1bzOu7f7ICovDQogICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgKnBEZXN0KysgPSAnOSc7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL7GjwfSyzsr908M51N3KsbT6zOYNCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIGVsc2UgaWYgKCdcMCcgPT0gKihwU291cmNlICsgMSkpICAgICAgICAgICAgICAgICAvKiC2urrFuvPD5r30uPq2urrFo6y78tXf0tS2urrFveHOsqOssuXI67/VtK7VvM67t/sgKi8NCiAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAqcERlc3QrKyA9IChDSEFSKVpBVF9OVUxMX0ZJTEw7DQogICAgICAgICAgICB9DQogICAgICAgIH0NCiAgICAgICAgZWxzZSBpZiAoKCdccicgPT0gKnBTb3VyY2UpIHx8KCdcbicgPT0gKnBTb3VyY2UpKQ0KICAgICAgICB7DQogICAgICAgICAgICBwU291cmNlKys7DQogICAgICAgIH0NCiAgICAgICAgZWxzZQ0KICAgICAgICB7DQogICAgICAgICAgICAqcERlc3QrKyA9ICgoJyAnID09ICpwU291cmNlKSAmJiAoMSA9PSBmbGcpKT8oQ0hBUilaQVRfU1BBQ0VfUkVQTEFDRTooKCgnXHQnID09ICpwU291cmNlKSAmJiAoMSA9PSBmbGcpKT8oQ0hBUilaQVRfVEFCX1JFUExBQ0U6KCpwU291cmNlKSk7DQogICAgICAgIH0NCiAgICAgICAgcFNvdXJjZSsrOw0KICAgIH0NCg0KICAgIG1lbXNldChwUGFyYUxpbmUsIDAsIGxlbmd0aCk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogvavUpLSmwO2687XExNrI3b+9sbS72LLOyv3Q0NbQICovDQogICAgc3RyY3B5KHBQYXJhTGluZSwgcFN0ckRlc3RNYWxsb2MpOw0KICAgIGZyZWUocFN0ckRlc3RNYWxsb2MpOw0KfQ0KI2VuZGlmDQpVSU5UOCB6Q2NfQ2FsbENvdW50KFZPSUQpDQp7DQogICAgVUlOVDggICBzbGF2ZSA9IDAsIGNudCA9IDA7DQoNCiAgICBmb3IgKHNsYXZlID0gMTsgc2xhdmUgPCBaQ0NfU0xBVkVTOyBzbG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WdpdHMsIA0KICAgICAgICAgICAgKFVJTlQzMikoc3RybGVuKGdfekNjX1NDVGFiW2ldLnNjKTxnX0NjX0NhbGxEZXRhaWwuZENvdW50KT9zdHJsZW4oZ196Q2NfU0NUYWJbaV0uc2MpOmdfQ2NfQ2FsbERldGFpbC5kQ291bnQpID09IDApDQogICAgICAgIHsNCiAgICAgICAgICAgIHNjTmFtZSA9IGdfekNjX1NDVGFiW2ldLnNjTmFtZTsNCiAgICAgICAgICAgIGJyZWFrOw0KICAgICAgICB9DQogICAgfQ0KICAgIHN3aXRjaChzY05hbWUpDQogICAgew0KICAgICAgICBjYXNlIFpDQ19CQU9DX1JFRzoNCiAgICAgICAgICAgIHNzY2FuZihwQXRDbWRQYXJhLCAiJSo1cyU0cyMiLCBwdyk7DQogICAgICAgICAgICBwd1s0XSA9ICdcMCc7DQogICAgICAgICAgICB0Y2xja3JlcS50eXBlID0gMDsvL0FPDQogICAgICAgICAgICB0Y2xja3JlcS5hY3QgPSAxOw0KICAgICAgICAgICAgc3RybmNweSh0Y2xja3JlcS5wdyxwdyxzaXplb2YodGNsY2tyZXEucHcpLTEpOw0KICAgICAgICAgICAgYnJlYWs7DQogICAgICAgIGNhc2UgWkNDX0JBT0NfREVSRUc6DQogICAgICAgICAgICBzc2NhbmYocEF0Q21kUGFyYSwgIiUqNXMlNHMjIiwgcHcpOw0KICAgICAgICAgICAgcHdbNF0gPSAnXDAnOw0KICAgICAgICAgICAgdGNsY2tyZXEudHlwZSA9IDA7Ly9BTw0KICAgICAgICAgICAgdGNsY2tyZXEuYWN0ID0gMDsNCiAgICAgICAgICAgIHN0cm5jcHkodGNsY2tyZXEucHcscHcsc2l6ZW9mKHRjbGNrcmVxLnB3KS0xKTsNCiAgICAgICAgICAgIGJyZWFrOw0KICAgICAgICBjYXNlIFpDQ19CT0lDX1JFRzogDQogICAgICAgICAgICBzc2NhbmYocEF0Q21kUGFyYSwgIiUqNXMlNHMjIiwgcHcpOw0KICAgICAgICAgICAgcHd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U0N3MjIiwgZG4pOw0KICAgICAgICAgICAgZG5bc3RybGVuKGRuKS0xXSA9ICdcMCc7DQogICAgICAgICAgICB0Y2NmY3JlcS50eXBlID0gMjsNCiAgICAgICAgICAgIHRjY2ZjcmVxLmFjdCA9IDE7DQogICAgICAgICAgICBzdHJuY3B5KHRjY2ZjcmVxLmRuLCBkbiwgc3RybGVuKGRuKSk7DQogICAgICAgICAgICBicmVhazsNCiAgICAgICAgY2FzZSBaQ0NfQ0ZOUllfREVSRUc6DQogICAgICAgICAgICB0Y2NmY3JlcS50eXBlID0gMjsNCiAgICAgICAgICAgIHRjY2ZjcmVxLmFjdCA9IDA7DQogICAgICAgICAgICBicmVhazsNCiAgICAgICAgY2FzZSBaQ0NfQ0ZCX1JFRzoNCiAgICAgICAgICAgIHNzY2FuZihwQXRDbWRQYXJhLCAiJSo0cyU0N3MjIiwgZG4pOw0KICAgICAgICAgICAgZG5bc3RybGVuKGRuKS0xXSA9ICdcMCc7DQogICAgICAgICAgICB0Y2NmY3JlcS50eXBlID0gMTsNCiAgICAgICAgICAgIHRjY2ZjcmVxLmFjdCA9IDE7DQogICAgICAgICAgICBzdHJuY3B5KHRjY2ZjcmVxLmRuLCBkbiwgc3RybGVuKGRuKSk7DQogICAgICAgICAgICBicmVhazsNCiAgICAgICAgY2FzZSBaQ0NfQ0ZCX0RFUkVHOg0KICAgICAgICAgICAgdGNjZmNyZXEudHlwZSA9IDE7DQogICAgICAgICAgICB0Y2NmY3JlcS5hY3QgPSAwOw0KICAgICAgICAgICAgYnJlYWs7DQogICAgfQ0KICAgICAgICANCiAgICANCiAgICBpZiAoc2NOYW1lID4gWkNDX0JPSUNfREVSRUcpDQogICAgew0KICAgICAgICB6Q2NBcHBfQ2NmYygmdGNjZmNyZXEpOw0KICAgIH0NCiAgICBlbHNlDQogICAgew0KICAgICAgICB6Q2NBcHBfQ2xjaygmdGNsY2tyZXEpOw0KICAgIH0NCiAgICAgICAgDQp9DQoNClZPSUQgekNjX1Nlbm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0KCSAgICAgICAgc2NfY2ZnX3NldCgidHpfdnBsb29wIiwgIjEiKTsNCgkgICAgICAgIGlwY19zZW5kX21lc3NhZ2UoTU9EVUxFX0lEX0NBTExfQ1RSTF9MT0NBTCwNCgkgICAgICAgICAgICBNT0RVTEVfSURfQVRfQ1RMLA0KCSAgICAgICAgICAgIE1TR19DTURfU0VUX1ZQTE9PUF9SRVEsDQoJICAgICAgICAgICAgMCwNCgkgICAgICAgICAgICBOVUxMLA0KCSAgICAgICAgICAgIDApOw0KDQoJICAgICAgICB6Q2NfU2hvd0FsbFNsYXZlV2l0aFRpcHMoInRlc3RDYWxsLWVuZCIpOw0KCQkJYnJlYWs7DQogICAgICAgIH0NCg0KICAgICAgICBpbmNvbWluZ19jYWxsX2NpZCA9IHpDY19maW5kX2hlbGRfaW5jb21pbmdfY2lkKCk7DQogICAgICAgIGNjYXBwX2xvZygiaW5jb21pbmdfY2FsbF9jaWQ9JWQgaXNfY2lkY3c9JWQiLA0KICAgICAgICAgICAgaW5jb21pbmdfY2FsbF9jaWQsIA0KICAgICAgICAgICAgZ19DY19DYWxsRGV0YWlsLnNsYXZlT2JqW2luY29taW5nX2NhbGxfY2lkXS5pc19jaWRjdyk7DQogICAgICAgICAgICANCiAgICAgICAgaWYoekNjX2ZpbmRfaGVsZF9jaWQoKSkNCiAgICAgICAgew0KCQkJekNjX1NlbmRBdENobGRSZXEoMSk7DQogICAgICAgIH0NCiAgICAgICAgZWxzZSBpZihpbmNvbWluZ19jYWxsX2NpZCkNCiAgICAgICAgew0KICAgICAgICAgICAgaWYoZ19DY19DYWxsRGV0YWlsLnNsYXZlT2JqW2luY29taW5nX2NhbGxfY2lkXS5pc19jaWRjdyA9PSBUUlVFKQ0KICAgICAgICAgICAgICAgIHpDY19TZW5kQXRDaGxkUmVxKDEpOw0KICAgICAgICAgICAgZWxzZQ0KICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgIGlmIChnX0NjX0NhbGxEZXRhaWwucmluZ0NpZCkNC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1mDQogICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgc2NfdGltZXJfZGVsZXRlKFpDQ0FQUF9USU1FUl9TU0RJQUxUT05FX0RFVEVDVCk7ICAgICANCiAgICAgICAgICAgICAgICBpZiAoZ19DY19DYWxsRGV0YWlsLmRpZ2l0c1swXSAhPSBaQ0NfRkxBU0hfU0lHTikNCiAgICAgICAgICAgICAgICB7ICAgICAgICAgICAgIA0KICAgICAgICAgICAgICAgICAgICBzbGF2ZSA9IHpDY19HZXRTcGVjU2xhdmUoWkNDX1NfVEFMS0lOR19TKTsNCiAgICAgICAgICAgICAgICAgICAgaWYgKDAgPT0gc2xhdmUgKQ0KICAgICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47DQogICAgICAgICAgICAgICAgICAgIH0gICAgICAgIA0KICAgICAgICAgICAgICAgICAgICBnX0NjX0NhbGxEZXRhaWwuZXZ0W3NsYXZlXSA9IFpDQ19EVE1GX0U7DQogICAgICAgICAgICAgICAgICAgIHp0ZV9sb2dfYXBwZW5kKF9fRklMRV9fLCBfX0xJTkVfXywgInp0ZV9jY2FwcC5sb2ciLCIlcyAgekNjX01TZWl6ZVN0YXRlIFpDQ19EVE1GX0UgXG4iLF9fRlVOQ1RJT05fXyk7DQogICAgICAgICAgICAgICAgICAgIGJyZWFrOw0KICAgICAgICAgICAgICAgIH0gICAgICAgIA0KICAgICAgICAgICAgfSAgDQoNCiAgICAgICAgICAgIHNjX3RpbWVyX2RlbGV0ZShaQ0NBUFBfVElNRVJfRFRNRl9ERVRFQ1QpOw0KICAgICAgICAgICAgcmV0ID0gekNjX0RpZ2l0c01hdGNoKCk7DQogICAgICAgICAgICBpZiAoKFpDQ19OT19SRVNVTFQgIT0gcmV0ICYmIFpDQ19NQVRDSEVSUiAhPSByZXQgJiYgZ19DY19DYWxsRGV0YWlsLmxhc3RUb25lID09IFpDQ19UT05FX0RJQUxfQSkNCiAgICAgICAgICAgICAgfHwoWkNDX01BVENIRVJSID09IHJldCAmJiBnX0NjX0NhbGxEZXRhaWwubGFzdFRvbmUgPT0gWkNDX1RPTkVfRElBTF9BICYmIDIgPD0gekNjX0NhbGxDb3VudCgpKSkNCiAgICAgICAgICAgIHsvL2NhbGwgd2FpdGluZ8rVtb1mbGFzaDSjrM2j1rmyprrF0vS71ri0uvS90LXItP3S9A0KICAgICAgICAgICAgICAgIFNMSUNfU3RvcF9TaWduYWwoMCwgVE9ORV9TSUdOQUwpOw0KICAgICAgICB6dGVfbG9nX2FwcGVuZChfX0ZJTEVfXywgX19MSU5FX18sICJ6dGVfY2NhcHAubG9nIiwiJXMgIHpDY19NU2VpemVTdGF0ZTogU0xJQ19TdG9wX1NpZ25hbCA8LS0tXG4iLF9fRlVOQ1RJT05fXyk7DQogICAgICAgICAgICAgICAgZ19DY19DYWxsRGV0YWlsLmxhc3RUb25lID0gWkNDX1RPTkVfT0ZGX0E7DQogICAgICAgICAgICAgICAgaWYgKGdfQ2NfQ2FsbERldGFpbC5zbGF2ZU9ialswXS50b25lICE9IFpDQ19UT05FX09GRl9BKQ0KICAgICAgICAgICAgICAgIHsgICAgICAgICAgICAgICAgICAgDQogICAgICAgICAgICAgICAgICAgIHpDY19Jbml0U2xhdmVPYmooMCk7DQogICAgICAgICAgICAgICAgfSAgDQogICAgICAgICAgICAgICAgaWYgKDAgIT0gekNjX0FjdGl2ZUNhbGwoKSkNCiAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgIFNMSUNfU3RhcnRfUENNKCk7DQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIGlmICgoWkNDX0ZMQVNIXzEgPT0gcmV0IHx8IFpDQ19GTEFTSF8yID09IHJldCkgJiYgKGdfQ2NfQ2FsbERldGFpbC5yaW5nQ2lkICE9IDApKS8vvdPM/XdhaXRpbmcgY2FsbKOsuvS90LXItP3S9NOmx+W/1Q0KICAgICAgICAgICAgICAgIHsNCiAgICAgICAgICAgICAgICAgICAgZ19DY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Jlc2V0DQogICAgICAgIH0NCiAgICAgICAgDQogICAgICAgIGJyZWFrOw0KICAgIGNhc2UgWkNDX0JVU1lUT05FVElNRVJfRToNCiAgICAgICAgZm9yIChzbGF2ZSA9IDA7IHNsYXZlIDwgWkNDX1NMQVZFUzsgc2xhdmUrKykNCiAgICAgICAgew0KICAgICAgICAgICAgaWYoZ19DY19DYWxsRGV0YWlsLnNsYXZlT2JqW3NsYXZlXS50b25lID09IFpDQ19UT05FX0JTWV9BKQ0KICAgICAgICAgICAgYnJlYWs7DQogICAgICAgIH0NCgkJaWYoc2xhdmUgPT0gWkNDX1NMQVZFUykNCgkJCXJldHVybjsNCiAgICAgICAgZ19DY19DYWxsRGV0YWlsLnNsYXZlT2JqW3NsYXZlXS50b25lID0gWkNDX1RPTkVfVEtZX0E7DQogICAgICAgIHNjX3RpbWVyX2NyZWF0ZShaQ0NBUFBfVElNRVJfVEtZVE9ORV9ERVRFQ1QsDQogICAgICAgICAgICAgICAgICAgIDAsDQogICAgICAgICAgICAgICAgICAgIFpDQ0FQUF9USU1FUl9US1lUT05FX0lOVEVSVkFMLA0KICAgICAgICAgICAgICAgICAgICB6Q2NBcHBfVGt5VG9uZVRpbWVyLA0KICAgICAgICAgICAgICAgICAgICBOVUxMKTsgIA0KICAgICAgICB6dGVfbG9nX2FwcGVuZChfX0ZJTEVfXywgX19MSU5FX18sICJ6dGVfY2NhcHAubG9nIiwiJXMgIHpDY19NU2VpemVTdGF0ZSBzY190aW1lcl9jcmVhdGUgekNjQXBwX1RreVRvbmVUaW1lclxuIixfX0ZVTkNUSU9OX18pOw0KICAgICAgICBpZiAoISgwID09IHpDY19HZXRTcGVjU2xhdmUoWkNDX1NfQlNZVF9TKQ0KICAgICAgICAgICAmJihnX0NjX0NhbGxEZXRhaWwuc2xhdmVPYmpbc2xhdmVdLnN0YXRlPT0gWkNDX1NfV0FJVF9SRVNPVVJDRV9TDQogICAgICAgICAgICB8fGdfQ2NfQ2FsbERldGFpbC5zbGF2Z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KOssaOz1sv8o6yyorfFsqa6xdL0DQogICAgICAgIHsNCiAgICAgICAgICAgIGlmIChjYWxsQ250ID4gMSkgLy8gY29uZiBjYWxsLCC3xbKmusXS9A0KICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgIGdfQ2NfQ2FsbERldGFpbC5kaWdpdHNbZ19DY19DYWxsRGV0YWlsLmRDb3VudCsrXSA9IFpDQ19GTEFTSF9TSUdOOw0KICAgICAgICAgICAgICAgIGdfQ2NfQ2FsbERldGFpbC5kaWdpdHNbWkRJQUxfTlVNX01BWC0xXSA9IDE7Ly8gvMfCvLG+tM6y2df3zqrV67bUY29uZiC1xA0KICAgIHp0ZV9sb2dfYXBwZW5kKF9fRklMRV9fLCBfX0xJTkVfXywgInp0ZV9jY2FwcC5sb2ciLCIlcyAgekNjX01TZWl6ZVN0YXRlOlpDQ19GTEFTSF9FXG4iLF9fRlVOQ1RJT05fXyk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlDQogICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgY2hsZHJldCA9IHpDY19TZW5kQXRDaGxkUmVxKDIpOw0KICAgIHp0ZV9sb2dfYXBwZW5kKF9fRklMRV9fLCBfX0xJTkVfXywgInp0ZV9jY2FwcC5sb2ciLCIlcyAgekNjX01TZWl6ZVN0YXRlOlpDQ19GTEFTSF9FXG4iLF9fRlVOQ1RJT05fXyk7DQogICAgICAgICAgICBnX0NjX0NhbGxEZXRhaWwud2FpdGNobGRyZXN1bHQgPSAxOw0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgYnJlYWs7DQogICAgICAgIH0NCiAgICAgICAgDQogICAgICAgIGlmICh6Q2NfSGVsZENhbGwoKSA9PSBjYWxsQ250KSAvL9a709BoZWxkIGNhbGyjrLvWuLQNCiAgICAgICAgew0KICAgICAgICAgICAgaWYgKGNhbGxDbnQgPT0gMSApDQogICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgY2hsZHJldCA9IHpDY19TZW5kQXRDaGxkUmVxKDIpOw0KICAgICAgICAgICAgICAgIHp0ZV9sb2dfYXBwZW5kKF9fRklMRV9fLCBfX0xJTkVfXywgInp0ZV9jY2FwcC5sb2ciLCIlcyAgekNjX01TZWl6ZVN0YXRlOlpDQ19GTEFTSF9FXG4iLF9fRlVOQ1RJT05fXyk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlDQogICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgZ19DY19DYWxsRGV0YWlsLmRpZ2l0c1tnX0NjX0NhbGxEZXRhaWwuZENvdW50KytdID0gWkNDX0ZMQVNIX1NJR047DQogICAgICAgICAgICAgICAgc2NfdGltZXJfY3JlYXRlKFpDQ0FQUF9USU1FUl9TU0RJQUxUT05FX0RFVEVDVCwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDAsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBaQ0NBUFBfVElNRVJfSE9PS09GRl9JTlRFUlZBTCwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHpDY0FwcF9Tc0RpYWxUb25lVGltZXIsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBOVUxMKTsgICANCiAgICAgICAgICAgICAgICB6dGVfbG9nX2FwcGVuZChfX0ZJTEVfXywgX19MSU5FX18sICJ6dGVfY2NhcHAubG9nIiwiJXMgIHpDY19NU2VpemVTdGF0ZTpzY190aW1lcl9jcmVhdGUgekNjQXBwX1NzRGlhbFRvbmVUaW1lclxuIixfX0ZVTkNUSU9OX18pOw0KICAgICAgICAgICAgICAgIGdfQ2NfQ2FsbERldGFpbC5ldnRbMF0gPSBaQ0NfRElBTF9FOw0KICAgICAgICAgICAgICAgIA0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgYnJlYWs7DQogICAgICAgIH0NCiAgICAgICAgLy9hY3RpdmUgKyBoZWxkDQoNCiAgICAgICAgaWYoZ19DY19DYWxsRGV0YWlsLmRpZ2l0c1swXSA9PSBaQ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XRhaWwud2FpdGNobGRyZXN1bHQgPSAwOw0KICAgICAgICAgICAgaWYgKCgoVF96Q2NhcHBfb3B0UnNwKilwdE1zZ0J1Zi0+YXVjRGF0YUJ1ZiktPnJlc3VsdCA9PSAwKQ0KICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgIHNjX3RpbWVyX2NyZWF0ZShaQ0NBUFBfVElNRVJfU1NESUFMVE9ORV9ERVRFQ1QsDQogICAgICAgICAgICAgICAgICAgICAwLA0KICAgICAgICAgICAgICAgICAgICAgWkNDQVBQX1RJTUVSX0hPT0tPRkZfSU5URVJWQUwsDQogICAgICAgICAgICAgICAgICAgICB6Q2NBcHBfU3NEaWFsVG9uZVRpbWVyLA0KICAgICAgICAgICAgICAgICAgICAgTlVMTCk7ICAgDQogICAgICAgICAgICAgICAgenRlX2xvZ19hcHBlbmQoX19GSUxFX18sIF9fTElORV9fLCAienRlX2NjYXBwLmxvZyIsIiVzICB6Q2NfTVNlaXplU3RhdGU6c2NfdGltZXJfY3JlYXRlIHpDY0FwcF9Tc0RpYWxUb25lVGltZXJcbiIsX19GVU5DVElPTl9fKTsNCiAgICAgICAgICAgICAgICBnX0NjX0NhbGxEZXRhaWwuZXZ0WzBdID0gWkNDX0RJQUxfRTsNCiAgICAgICAgICAgICAgICBTTElDX1N0b3BfUENNKCk7IA0KICAgICAgICAgICAgICAgIHp0ZV9sb2dfYXBwZW5kKF9fRklMRV9fLCBfX0xJTkVfXywgInp0ZV9jY2FwcC5sb2ciLCIlcyAgekNjX01TZWl6ZVN0YXRlOlNMSUNfU3RvcF9QQ01cbiIsX19GVU5DVElPTl9fKTsNCiAgICAgICAgICAgICAgICB9DQogICAgICAgIH0NCiAgICAgICAgYnJlYWs7DQoNCiAgICBjYXNlIFpDQ19TRUlaRV9FOiAvLyDVqrv6DQogICAgZGVmYXVsdDoNCiAgICAgICAgLy8gZG8gbm90aGluZw0KICAgICAgICBicmVhazsNCiAgICB9DQp9DQoNCg0KLy9nZXQgbG9jYW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ZW9mKHRTaWcpKTsNCiAgICAgICAgICAgICAgICB0U2lnLnNpZ25hbF90eXBlID0gUklOR19TSUdOQUw7DQogICAgICAgICAgICAgICAgLy9tZW1jcHkodFNpZy5jaWQsIGdfQ2NfQ2FsbERldGFpbC5udW1iZXIsIHN0cmxlbihnX0NjX0NhbGxEZXRhaWwubnVtYmVyKSk7DQoJCQkJc3RybmNweSh0U2lnLmNpZCwgZ19DY19DYWxsRGV0YWlsLm51bWJlciwgc2l6ZW9mKHRTaWcuY2lkKS0xKTsNCiAgICAgICAgICAgICAgICBnZXRfbG9jYWxfZGF0ZXRpbWUodFNpZy5kYXRlX3RpbWUpOw0KICAgICAgICAgICAgICAgIHp0ZV9sb2dfYXBwZW5kKF9fRklMRV9fLCBfX0xJTkVfXywgInp0ZV9jY2FwcC5sb2ciLCIlcyAgekNjX1J1bk1hc3RlciBSSU5HX1NJR05BTCxudW1iZXIgPSAlc1xuIixfX0ZVTkNUSU9OX18sZ19DY19DYWxsRGV0YWlsLm51bWJlcik7DQogICAgICAgICAgICAgICAgU0xJQ19QbGF5X1NpZ25hbCgwLCAwLCAmdFNpZyk7ICANCiAgICAgICAgICAgICAgICB6Q2NfU2V0TGVkU3RhdHVzKCJsZWRibGluayIpOw0KICAgICAgICAgICAgfSAgICAgICAgDQogICAgICAgICAgICBnX0NjX0NhbGxEZXRhaWwuc2xhdmVPYmpbc2xhdmVdLnNNc2cgPSBaQ0NfU05PX007DQogICAgICAgICAgICBicmVhazsNCiAgICAgICAgY2FzZSBaQ0NfU0FOU19NOi8vyrLDtLOhvrA/DQogICAgICAgICAgICBpZiAoekNjX0NhbGxDb3VudCgpID09IDEpDQogICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgU0xJQ19TdG9wX1NpZ25hbCgwLCBUT05FX1NJR05BTCk7DQogICAgICAgIHp0ZV9sb2dfYXBwZW5kKF9fRklMRV9fLCBfX0xJTkVfXywgInp0ZV9jY2FwcC5sb2ciLCIlcyAgOiBTTElDX1N0b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kdfUw0KICAgICAgICAgICAgICAgICAgICAgfHwgZ19DY19DYWxsRGV0YWlsLnNsYXZlT2JqW3NsYXZldG1wXS5zdGF0ZSA9PSBaQ0NfU19SSU5HQkFDS19TDQogICAgICAgICAgICAgICAgICAgICB8fCBnX0NjX0NhbGxEZXRhaWwuc2xhdmVPYmpbc2xhdmV0bXBdLnN0YXRlID09IFpDQ19TX1RBTEtJTkdfUw0KLy8gICAgICAgICAgICAgICAgICAgICB8fCBnX0NjX0NhbGxEZXRhaWwuc2xhdmVPYmpbc2xhdmV0bXBdLnN0YXRlID09IFpDQ19TX1RSWUlOR19TIC8vIGluY29taW5nX2NhbGxfY2lkDQogICAgICAgICAgICAgICAgICAgICB8fCBnX0NjX0NhbGxEZXRhaWwuc2xhdmVPYmpbc2xhdmV0bXBdLnN0YXRlID09IFpDQ19TX1dBSVRfUkVTT1VSQ0VfUykgJiYNCiAgICAgICAgICAgICAgICAgICAgICBnX0NjX0NhbGxEZXRhaWwuc2xhdmVPYmpbc2xhdmV0bXBdLmhlbGRjYWxsPT0wKQ0KICAgICAgICAgICAgICAgICAgICB7DQogICAgICAgICAgICAgICAgICAgICAgICBhY3RpdmVfY2FsbF9jaWQgPSBzbGF2ZXRtcDsNCiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOw0KICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgfQ0KDQoJCQkJY2NhcHBfbG9nKCJaQ0NfU0RJU0NOX00gYWN0aXZlX2NhbGxfY2lkPSVkIiwgYWN0aXZlX2NhbGxfY2lkKTsNCgkJCQkNCiAgICAgICAgICAgICAgICBpZihhY3RpdmVfY2FsbF9jaWQhPTApDQogICAgICAgICAgICAgICAgew0KCQkJCQl6Q2NfU2VuZEF0Q2hsZFJlcSgxMCthY3RpdmVfY2FsbF9jaWQpOw0KDQoJICAgICAgICAgICAgICAgIGdfQ2NfQ2FsbERldGFpbC5jaHVwU2VudCA9IFRSVUU7DQoJICAgICAgICAgICAgICAgIGdfQ2NfQ2FsbERldGFpbC5zdGF0ZSA9IFpDQ19NX1JJTkdJTkdfUzsNCg0KCSAgICAgICAgICAgICAgICAvKk1TR19CVUYgICBtc2dCdWZmICAgICAgPSB7MH07CQkJCS8vIGxldCB3aGlsZSgxKSBydW4gb25lIG1vcmUgdGltZQ0KCSAgICAgICAgICAgICAgICBtc2dCdWZmLnVzTXNnQ21kICAgPSBaQ0NfQVNTSVNUX01TR19FOw0KCSAgICAgICAgICAgICAgICBtc2dCdWZmLnNyY19pZCA9IE1PRFVMRV9JRF9TTElDOw0KCSAgICAgICAgICAgICAgICB6Q2NfU2VuZE1zZ1RvU3ViKCZtc2dCdWZmKTsNCg0KCSAgICAgICAgICAgICAgICBjY2FwcF9sb2coInNlbmRNc2cgWkNDX0FTU0lTVF9NU0dfRSIpOyAqLw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBlbHNlDQogICAgICAgICAgICAgICAgew0KCQkJCQl6Q2NfaHVuZ3VwX2FsbChzbGF2ZSk7DQogICAgICAgICAgICAgICAgfQ0KCQkJfQ0KCQkJZWxzZQ0KICAgICAgICAJew0KCSAgICAgICAgICAgIHpDY19odW5ndXBfYWxsKHNsYXZlKTsgDQoJICAgICAgIAl9ICAgICANCg0KCSAgICAgICAgZ19DY19DYWxsRGV0YWlsLnNsYXZlT2JqW3NsYXZlXS5zTXNnID0gWkNDX1NOT19NOw0KICAgICAgICAgICAgYnJlYWs7DQogICAgICAgIGRlZmF1bHQ6DQogICAgICAgICAgICBicmVhazsNCiAgICAgICAgfQ0KICAgIH0NCg0KICAgIGlmIChnX0NjX0NhbGxEZXRhaWwuc3RhdGUgPT0gWkNDX01fUklOR0lOR19TIA0KICAgICAgICAmJiBnX0NjX0NhbGxEZXRhaWwucmluZ0NpZCA9PSAwDQogICAgICAgICYmIHpDY19maW5kX2hlbGRfY2lkKCk9PTAgDQogICAgICAgICYmIHpDY19maW5kX2hlbGRfaW5jb21pbmdfY2lkKCk9PTANC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BTFNFOw0KICAgICAgICAgICAgc2NfdGltZXJfY3JlYXRlKFpDQ0FQUF9USU1FUl9IT09LT0ZGX0RFVEVDVCwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAwLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIFpDQ0FQUF9USU1FUl9IT09LT0ZGX0lOVEVSVkFMLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHpDY0FwcF9Ib29rT2ZmVGltZXIsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgTlVMTCk7ICANCiAgICB6dGVfbG9nX2FwcGVuZChfX0ZJTEVfXywgX19MSU5FX18sICJ6dGVfY2NhcHAubG9nIiwiJXMgIHpDY19TSWRsZVN0YXRlIHNjX3RpbWVyX2NyZWF0ZSB6Q2NBcHBfSG9va09mZlRpbWVyXG4iLF9fRlVOQ1RJT05fXyk7DQoNCgkJCWdfQ2NfQ2FsbERldGFpbC5zbGF2ZU9ialtzbGF2ZV0uaWRsZV9zZWNvbmQgPSAwOw0KICAgICAgICAgICAgc2NfdGltZXJfY3JlYXRlKFpDQ0FQUF9USU1FUl9IT09LT0ZGX0lETEUsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgVElNRVJfRkxBR19SRVNUQVJULA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIFpDQ0FQUF9USU1FUl9IT09LT0ZGX0lETEVfSU5URVJWQUwsDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgekNjQXBwX0hvb2tPZmZfSWRsZV9UaW1lciwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBOVUxMKTsgIA0KICAgIHp0ZV9sb2dfYXBwZW5kKF9fRklMRV9fLCBfX0xJTkVfXywgInp0ZV9jY2FwcC5sb2ciLCIlcyAgekNjX1NJZGxlU3RhdGUgc2NfdGltZXJfY3JlYXRlIHpDY0FwcF9Ib29rT2ZmX0lkbGVfVGltZXJcbiIsX19GVU5DVElPTl9fKTsNCiAgICAgICAgfQ0KICAgICAgICBic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