LyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqDQoqDQoqICAgICAgICAgICAgICAgICAgQ29weXJpZ2h0IChjKSAyMDEzIFpURSBDb3Jwb3JhdGlvbi4NCioNCioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KKiDEoyC/6SDD+yA6IENjDQoqIM7EILz+IMP7IDogQ2NfbWFpbi5jDQoqIM/gudjOxLz+IDoNCiogyrXP1rmmxNwgOiC157uw0rXO8cP8we63osvNus294bn7tKbA7cSjv+m6r8r9tqjS5Q0KKiDX9yAgICDV3yA6IA0KKiCw5iAgICCxviA6IA0KKiDN6rPJyNXG2iA6DQoqIMbky/zLtcP3IDoNCioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLw0KDQovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioNCiog0N64xLzHwrwgOg0KKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLw0KDQovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioNCiogI2luY2x1ZGXH+A0KKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovDQojaW5jbHVkZSA8ZXJybm8uaD4NCi8vI2luY2x1ZGUgPHNpZ25hbC5oPg0KI2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3RyaW5nLmg+DQojaW5jbHVkZSA8c3RkbGliLmg+DQovLyNpbmNsdWRlIDx0aW1lLmg+DQojaW5jbHVkZSA8ZmNudGwuaD4NCiNpbmNsdWRlICJjY19tYWluLmgiDQojaW5jbHVkZSAiY2NfcHJvYy5oIg0KI2luY2x1ZGUgImNjX2NvbS5oIg0KI2luY2x1ZGUgImNjX2F0LmgiDQojaW5jbHVkZSA8c3lzL3R5cGVzLmg+DQojaWZkZWYgVEVTVF9DQ0FQUA0KI2luY2x1ZGUgInNvZnRfdGltZXIuaCINCiNlbmRpZg0KDQoNCg0KLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqDQoqILOjwb+2qNLlx/gNCioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLw0KLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqDQoqIMr9vt294bm5tqjS5cf4DQoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8NCmV4dGVybiBUX0NDX0FQUF9BdEluZFByb2NJdGVtIGdDY0FwcEF0SW5kUHJvY1tdOw0KZXh0ZXJuIFNJTlQzMiBnQ2NBcHBSZWN2QXRJbmRDbnQ7DQpUX3pDY19DYWxsRGV0YWlsIGdfQ2NfQ2FsbERldGFpbDsNCmNoYXIgZ196Q2NBcHBfQXRJbmRCdWZbWkNDX0FQUF9BVF9CVUZfTUFYX0xFTisxXTsNCi8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KKiBzdGF0aWO6r8r9yfnD98f4DQoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8NCi8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KKiDIq77WseTBv7ao0uXH+A0KKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovDQpzdGF0aWMgU0lOVDMyIGdfekNjX01zcUlkID0gTlVMTDsNCi8vc3RhdGljIFNJTlQzMiBnX3pDY19BdEluZFJzcElkID0gTlVMTDsNClNJTlQzMiBnX3pDY19BdFJzcElkID0gTlVMTDsNCg0KDQpzdGF0aWMgU0lOVDMyIGdfekNjX2dldFNsaWNFdl90aHJlYWRJZCA9IC0xOyANCg0KaW50IHpDY19zbGVlcChsb25nIG1zKSANCnsNCiAgICBzdHJ1Y3QgdGltZXZhbCB0djsNCiAgICB0di50dl9zZWMgPSAwOw0KICAgIHR2LnR2X3VzZWMgPSBtcyAqIDEwMDA7DQogICAgcmV0dXJuIHNlbGVjdCgwLCBOVUxMLCBOVUxMLCBOVUxMLCAmdHYpOw0KfQ0KVk9JRCB6Q2NfU2xpY01zZ1Byb2MoTVNHX0JVRiAqcHRNc2dCdWYpDQp7DQogICAgYXNzZXJ0KHB0TXNnQnVmICE9IE5VTEwpOw0KICAgIC8vZ19DY19DYWxsRGV0YWlsLmN1ckV2dCA9IHB0TXNnQnVmLT51c01zZ0NtZDsNCiAgICBpZiAocHRNc2dCdWYtPnVzTXNnQ21kID09IFpDQ19EVE1GX0UgICYmICBnX0NjX0NhbGxEZXRhaWwuZENvdW50IDwgWkRJQUxfTlVNX01BWCkNCiAgICB7DQogICAgICAgIGdfQ2NfQ2FsbERldGFpbC5kaWdpdHNbZ19DY19DYWxsRGV0YWlsLmRDb3VudCsrXSA9IHB0TXNnQnVmLT5hdWNEYXRhQnVmWzBdOw0KICAgICAgICBjY2FwcF9sb2coInpDY19TbGljTXNnUHJvYyBkaWdpdFslZF09JXMiLCBnX0NjX0NhbGxEZXRhaWwuZENvdW50LCBn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nNyY19pZCA9IE1PRFVMRV9JRF9TTElDOw0KICAgICAgICAgICAgICAgIHpDY19TZW5kTXNnVG9TdWIoJm1zZ0J1Zik7IC8qILei1aq7+srCvP64+Nb3z9+zzCAqLw0KICAgICAgICAgICAgICAgIGJyZWFrOw0KICAgICAgICAgICAgY2FzZSBFVl9GWFNfQ09MTEVDVF9ESUc6Ly8gJzAnLSc5JywgJyonLCAnIycNCiAgICAgICAgICAgICAgICBkdG1mID0gZHRtZjE7DQogICAgICAgICAgICAgICAgbXNnQnVmLnVzTXNnQ21kICAgPSBaQ0NfRFRNRl9FOw0KICAgICAgICAgICAgICAgIG1zZ0J1Zi5zcmNfaWQgPSBNT0RVTEVfSURfU0xJQzsNCiAgICAgICAgICAgICAgICBtc2dCdWYuYXVjRGF0YUJ1ZlswXSA9IChVSU5UOCkoZHRtZik7DQogICAgICAgICAgICAgICAgbXNnQnVmLnVzRGF0YUxlbiA9IDE7DQogICAgICAgICAgICAgICAgekNjX1NlbmRNc2dUb1N1YigmbXNnQnVmKTsgLyogt6JEVE1GIMrCvP64+Nb3z9+zzCAqLw0KICAgICAgICAgICAgICAgIGJyZWFrOyAgICAgICAgICAgICAgICANCiAgICAgICAgICAgIGNhc2UgRVZfRlhTX0ZMQVNIOg0KICAgICAgICAgICAgICAgIG1zZ0J1Zi51c01zZ0NtZCAgID0gWkNDX0ZMQVNIX0U7DQogICAgICAgICAgICAgICAgbXNnQnVmLnNyY19pZCA9IE1PRFVMRV9JRF9TTElDOw0KICAgICAgICAgICAgICAgIHpDY19TZW5kTXNnVG9TdWIoJm1zZ0J1Zik7IC8qILeiRkxBU0ggysK8/rj41vfP37PMICovDQogICAgICAgICAgICAgICAgYnJlYWs7DQoJCQljYXNlIEVWX0xUX1JJTkdFUl9SRU46DQogICAgICAgICAgICAgICAgaWYgKGR0bWYxID09IDEpIHsNCgkJCQkJekNjX1NldFJqMTFMZWRTdGF0dXMoImxlZG9uIik7DQogICAgICAgICAgICAgICAgfSBlbHNlI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mQoKTsNCiAgICBBdEluZFJlYWRlclRocmVhZElkID0gcHRocmVhZF9jcmVhdGUoJkF0SW5kUmVhZGVyVGhyZWFkSWQsIE5VTEwsIHpDY0FwcF9BdEluZFJlYWRlciwgKHZvaWQqKSZmZCk7DQogICAgaWYoQXRJbmRSZWFkZXJUaHJlYWRJZCA8IDApIA0KICAgIHsNCiAgICAgIHJldHVybiBOVUxMOw0KICAgIH0NCiAgICB3aGlsZSAoMSkNCiAgICB7ICAgICAgIA0KICAgICAgICByZXQgPSBtc2dyY3YoTWFpblFldWVJZCwgJlF1ZXVlTXNnLCBzaXplb2YoTVNHX0JVRiksIGJNc2dUeXBlLCAwKTsNCiAgICAgICAgaWYocmV0ID09IC0xKQ0KICAgICAgICB7DQogICAgICAgICAgICByZXR1cm4gTlVMTDsNCiAgICAgICAgfQ0KICAgICAgICBlbHNlDQogICAgICAgIHsNCiAgICAgICAgc3dpdGNoIChRdWV1ZU1zZy5zcmNfaWQpDQogICAgICAgICAgICB7DQogICAgICAgICAgICBjYXNlIE1PRFVMRV9JRF9DQUxMX0NUUkw6IC8vIEFUIEluZCBtc2cNCiAgICAgICAgICAgICAgICB6Q2NfQXRSZWN2TXNnUHJvYygmUXVldWVNc2cpOw0KICAgICAgICAgICAgICAgIGJyZWFrOw0KICAgICAgICAgICAgDQogICAgICAgICAgICBjYXNlIE1PRFVMRV9JRF9TTElDOiAvLyBtZXNzYWdlIGZyb20gc2xpYw0KICAgICAgICAgICAgZGVmYXVsdDoNCiAgICAgICAgICAgICAgICB6Q2NfU2xpY01zZ1Byb2MoJlF1ZXVlTXNnKTsNCiAgICAgICAgICAgICAgICBicmVhazsNCiAgICAgICAgICAgIH0gICAgICAgICAgICANCiAgICAgICAgICAgIHpDY19SdW5NYXN0ZXIoJlF1ZXVlTXNnKTsNCiAgICAgICAgfQ0KICAgIH0NCiAgICANCn0NCiNlbmRpZg0KI2lmbmRlZiBURVNUX0NDQVBQDQoNCnN0YXRpYyBpbnQgcG9sYXJ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ZCBlcnJubz0lZFxuIixfX0ZVTkNUSU9OX18scmV0LCBlcnJubyk7DQogICAgICAgICAgICBjb250aW51ZTsNCiAgICAgICAgfQ0KICAgICAgICBlbHNlDQogICAgICAgIHsNCiAgICAgICAgc3dpdGNoIChRdWV1ZU1zZy5zcmNfaWQpDQogICAgICAgICAgICB7ICAgICAgICAgICAgDQogICAgICAgICAgICBjYXNlIE1PRFVMRV9JRF9TTElDOiAvLyBtZXNzYWdlIGZyb20gc2xpYw0KICAgICAgICAgICAgICAgIHpDY19TbGljTXNnUHJvYygmUXVldWVNc2cpOw0KICAgICAgICAgICAgICAgIGJyZWFrOw0KICAgICAgICAgICAgZGVmYXVsdDogLy8gQVQgSW5kIG1zZw0KICAgICAgICAgICAgICAgIHp0ZV9sb2dfYXBwZW5kKF9fRklMRV9fLCBfX0xJTkVfXywgInp0ZV9jY2FwcC5sb2ciLCJyZWN2IG1zZyAlZCBmcm9tIGF0X2N0bFxuIixRdWV1ZU1zZy51c01zZ0NtZCk7DQogICAgICAgICAgICAgICAgaWYgKFF1ZXVlTXNnLnVzTXNnQ21kPT1NU0dfQ01EX1pJTVNQTFVTX0lORA0KICAgICAgICAgICAgICAgICB8fFF1ZXVlTXNnLnVzTXNnQ21kPT1NU0dfQ01EX0RTQ0lfSU5EDQogICAgICAgICAgICAgICAgIHx8UXVldWVNc2cudXNNc2dDbWQ9PU1TR19DTURfWkNQSQ0KICAgICAgICAgICAgICAgICB8fFF1ZXVlTXNnLnVzTXNnQ21kPT1NU0dfQ01EX1pWT0lDRUNITkwpDQogICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICB6Q2NfQ2hlY2tTbGF2ZVN0YXRlKCJpbiB6Q2NfQXRSZWN2TXNnUHJvYyIpOw0KICAgICAgICAgICAgICAgICAgICB6Q2NfQXRSZWN2TXNnUHJvYygmUXVldWVNc2cpOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBicmVhazsNCiAgICAgICAgICAgIH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