LyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKiCw5sioy/nT0CAoQykyMDE2LCDW0NDLzajRtrnJt93T0M/euavLvqGjCiogCiogzsS8/sP7s8Y6ICAgICByYW1kdW1wLmMKKiDOxLz+serKtjogICAgIHJhbWR1bXAuYwoqIMTayN3VqtKqOiAgICAgcmFtZHVtcCBsaW51eLW8s/a5pL7fCiogCiog0N64xMjVxtogICAgICAgILDmsb66xSAgICAgINDeuMSx6rzHICAgICAgICDQ3rjEyMsgICAgICAgICAg0N64xMTayN0KKiAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KKiAyMDE2LzMvMTAgICAgICBWMS4wICAgICAgICBDcmVhdGUgICAgICAgICAgICAgICAgICAgICAgICAgICAgILS0vagKKiAKKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KCi8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCiogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIM23zsS8/iAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCiNpbmNsdWRlPHN0ZGxpYi5oPgojaW5jbHVkZTxzdGRpby5oPgojaW5jbHVkZTxzdHJpbmcuaD4KI2luY2x1ZGU8c3lzL3R5cGVzLmg+CiNpbmNsdWRlPHN5cy9zdGF0Lmg+CiNpbmNsdWRlPGZjbnRsLmg+CiNpbmNsdWRlPGVycm5vLmg+CiNpbmNsdWRlPGdldG9wdC5oPgojaW5jbHVkZTxzdGRhcmcuaD4KI2luY2x1ZGU8dGVybWlvcy5oPgojaW5jbHVkZTxzdGRkZWYuaD4KI2luY2x1ZGU8ZGlyZW50Lmg+CiNpbmNsdWRlIDx1bmlzdGQuaD4KI2luY2x1ZGU8dGltZS5oPgovLyNpbmNsdWRlPHByb3BlcnRpZXMuaD4KLy8jaW5jbHVkZTxjdXRpbHMvcHJvcGVydGllcy5oPgovLyNpbmNsdWRlPGN1dGlscy9sb2cuaD4KCi8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCiogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgs6PBv7ao0uUgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCgovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgoqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICC66rao0uUgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwojZGVmaW5lIE1PREVNX1RSQVBfUEFUSCAiL2Rldi90dHlVU0IwIgojZGVmaW5lIE1PREVNX1RSQVBfUEFUSDIgIi9kZXYvdHR5VVNCMSIKLy8gI2RlZmluZSBNT0RFTV9SQU1EVU1QX1BBVEggIi9kYXRhL2xvY2FsL2xvZy9SYW1kdW1wIgojZGVmaW5lIFJBTURVTVBfREVGQVVMVF9CQVVEIEIxMTUyMDAKI2RlZmluZSBSQU1EVU1QX0RFRkFVTFRfREV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JyYW1kdW1wZnVjIgovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgoqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICDK/b7dwODQzbao0uUgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwp0eXBlZGVmIHN0cnVjdCB7CgljaGFyIGZpbGVfbmFtZVszMl07Cgl1bnNpZ25lZCBpbnQgZmlsZV9zaXplOwp9IGZpbGVfaW5mb190Owp0eXBlZGVmIHVuc2lnbmVkIGludCBVSU5UMzI7CgovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgoqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICC6r8r9yfnD9yAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCmV4dGVybiBpbnQgZGV2X2dldF91c2JzeXNfdmFsKGNvbnN0IGNoYXIgKnN5c19maWxlbmFtZSwgaW50IGJhc2UpOwpleHRlcm4gaW50IGRldl9zdHJTdGFydHNXaXRoKGNvbnN0IGNoYXIgKmxpbmUsIGNvbnN0IGNoYXIgKnNyYyk7CmV4dGVybiBpbnQgZGV2X2dldF90dHlwb3J0X2J5X3N5c3BhdGgoY2hhciAqc3lzcGF0aCk7CmV4dGVybiBpbnQgZGV2X2dldF9kZXZpY2Uodm9pZCk7CgovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgoqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgvtayv76yzKyx5MG/tqjS5SAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwpzdGF0aWMgaW50IGdfbW9kZW1fZmQgPSAtMTsKc3RhdGljIGludCBnX3JlYm9vdF9mbGFnID0gMDsKc3RhdGljIGludCBnX21vbml0ZXJfdGltZSA9IDA7CgovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgoqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICDIq77WseTBv7ao0uUgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwppbnQgUFJPUEVSVFlfVkFMVUVfTUFYID0gMjU2OwpleHRlcm4gaW50IGdfdXNiX2RldjsKLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgvtayv7qvyv3Ktc/WICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoKKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8Kc3RhdGljIHZvaWQgbWRwX3ByaW50X2FycmF5KGNvbnN0IGNoYXIqIHByZWZpeCwgY29uc3QgY2hhciAqYnVmLCBpbnQgbGVuZ3RoKQp7CiNpZiAwCglpbnQgaSA9IDA7CglpbnQgbGVuID0gTUlOKGxlbmd0aCwxNiApOwoJcHJpbnRmKCIlcyAiLCBwcmVmaXggKTsKCWZvciAoaSA9IDA7I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tX3JhbWR1bXAoZGV2X3R0eSwgZHVtcF9wYXRoKTsKCQlpZiAocmV0ID49IDApIHsKCQkJcHJpbnRmKCJnZXQgdGhlIHJhbWR1bXAgZGF0YSBmcm9tICVzIHN1Y2Nlc3NcbiIsIGRldl90dHkpOwoJCX1lbHNlewoJCQlwcmludGYoImdldCB0aGUgcmFtZHVtcCBkYXRhIGZyb20gJXMgZmFpbGVkXG4iLCBkZXZfdHR5KTsKCQl9Cgl9CglyZXR1cm4gcmV0Owp9CgovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgoqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICDIq77Wuq/K/cq1z9YgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwppbnQgbWFpbihpbnQgYXJnYywgY2hhciogYXJndltdKQp7CglpbnQgcmV0ID0gLTE7CglpbnQgb3B0ID0gMDsKCWludCBkdW1wX3BhdGhfZmxhZyA9IDA7CgljaGFyIGR1bXBfcGF0aFsyNTZdID0gezB9OwoJY2hhciB0aW1lX3N0cls2NF0gPSB7MH07CgoJLy8gcHJvcGVydHlfc2V0KCJjdGwuc3RvcCIsICJ6dGVtb2RlbWxvZyIpOwoJLy9zbGVlcCgxKTsKCWlmKGdldF90aW1lX3N0cih0aW1lX3N0ciwgNjQpIDwgMCl7CgkJcHJpbnRmKCJDYW4ndCBnZXQgdGhlIHRpbWUgc3RyXG4iKTsKCQlyZXR1cm4gLTE7Cgl9CgoJaWYgKGFyZ2MgPT0gMSl7CgkJZ2V0X3JhbWR1bXBfZm9sZF9uYW1lKGR1bXBfcGF0aCwgMjU2LCBERUZBVUxUX1JBTURVTVBfRk9MRCwgdGltZV9zdHIpOwoJCWR1bXBfcGF0aF9mbGFnID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