ZGlmZiAtLWdpdCBhL2FwL2hvc3RhcHAvemR1bXBfcmVmL3JhbWR1bXAuYyBiL2FwL2hvc3RhcHAvemR1bXBfcmVmL3JhbWR1bXAuYwpuZXcgZmlsZSBtb2RlIDEwMDc1NQppbmRleCAwMDAwMDAwLi5mNDgyODBiCi0tLSAvZGV2L251bGwKKysrIGIvYXAvaG9zdGFwcC96ZHVtcF9yZWYvcmFtZHVtcC5jCkBAIC0wLDAgKzEsNjQ1IEBACisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorKiCw5sioy/nT0CAoQykyMDE2LCDW0NDLzajRtrnJt93T0M/euavLvqGjCisqIAorKiDOxLz+w/uzxjogICAgIHJhbWR1bXAuYworKiDOxLz+serKtjogICAgIHJhbWR1bXAuYworKiDE2sjd1arSqjogICAgIHJhbWR1bXAgbGludXi1vLP2uaS+3worKiAKKyog0N64xMjVxtogICAgICAgILDmsb66xSAgICAgINDeuMSx6rzHICAgICAgICDQ3rjEyMsgICAgICAgICAg0N64xMTayN0KKyogLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCisqIDIwMTYvMy8xMCAgICAgIFYxLjAgICAgICAgIENyZWF0ZSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgtLS9qAorKiAKKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICDNt87EvP4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKyNpbmNsdWRlPHN0ZGxpYi5oPgorI2luY2x1ZGU8c3RkaW8uaD4KKyNpbmNsdWRlPHN0cmluZy5oPgorI2luY2x1ZGU8c3lzL3R5cGVzLmg+CisjaW5jbHVkZTxzeXMvc3RhdC5oPgorI2luY2x1ZGU8ZmNudGwuaD4KKyNpbmNsdWRlPGVycm5vLmg+CisjaW5jbHVkZTxnZXRvcHQuaD4KKyNpbmNsdWRlPHN0ZGFyZy5oPgorI2luY2x1ZGU8dGVybWlvcy5oPgorI2luY2x1ZGU8c3RkZGVmLmg+CisjaW5jbHVkZTxkaXJlbnQuaD4KKyNpbmNsdWRlIDx1bmlzdGQuaD4KKyNpbmNsdWRlPHRpbWUuaD4KKy8vI2luY2x1ZGU8cHJvcGVydGllcy5oPgorLy8jaW5jbHVkZTxjdXRpbHMvcHJvcGVydGllcy5oPgorLy8jaW5jbHVkZTxjdXRpbHMvbG9nLmg+CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgILOjwb+2qNLlICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgILrqtqjS5SAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqK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IChVSU5UMzIpNSAgICAgICAvL8frx/O2wcih1ri2qLHgusXOxLz+xNrI3QorI2RlZmluZSBEVU1QRklMRV9SRUFEX1JTUCAgICAgICAoVUlOVDMyKTYgICAgICAgLy/OxLz+xNrI3bbByKHTprTwo6y4vbT4zsS8/sTayN0KKyNkZWZpbmUgRFVNUEZJTEVfRU5EX1JFUSAgICAgICAgKFVJTlQzMik3ICAgICAgIC8vtKvK5L3hyvgKKyNkZWZpbmUgRFVNUEZJTEVfRU5EX1JTUCAgICAgICAgKFVJTlQzMik4ICAgICAgIC8vtKvK5L3hyvjTprTwCisjZGVmaW5lIERVTVBGSUxFX0NNRF9GQUlMICAgICAgIChVSU5UMzIpOSAgICAgICAvL9a4we607cilCisjZGVmaW5lIERVTVBGSUxFX05PX0ZBSUwgICAgICAgIChVSU5UMzIpMTAgICAgICAvL87EvP6x4LrFtO3O8worI2RlZmluZSBEVU1QRklMRV9MRU5HVEhfRkFJTCAgICAoVUlOVDMyKTExICAgICAgLy/OxLz+zrvWw7Tz0KG07c7zCisjZGVmaW5lIENNRF9CVUZGRVJfTEVOICAgICAgICAgIChVSU5UMzIpMTYgICAgICAvL9a4we6ywbfAtr4KKyNkZWZpbmUgRklMRU5BTUVfTEVOICAgICAgICAgICAgKFVJTlQzMikzMiAgICAgIC8vzsS8/sP7s6S2yAorI2RlZmluZSBGSUxFTkFNRV9NQVhfTEVOICAgICAgICAoVUlOVDMyKTI1NiAgICAgIC8vzsS8/sP71+6087OktsgKKyNkZWZpbmUgREFUQV9CTE9DS19TSVpFICAgICAgICAgKDB4NDAwMDApIC8vIMr9vt27urPltPPQoQorLy8jZGVmaW5lIERBVEFfQkxPQ0tfU0laRSAgICAgICAgICgweDAwODAwKSAvLyDK/b7du7qz5bTz0KEsMmsKKworI2RlZmluZSBNSU4oYSwgYikgKChhKTwgKGIpID8gKGEpOiAoYikpCisjZGVmaW5lIERFRkFVTFRfUkFNRFVNUF9GT0xEICAgIi9ob21lL2R1amluZy9jb2RlL3YzL3JhbWR1bXAvcmFtZHVtcF9maWxlLyIgICAvLyIvbW50L3NkY2FyZC9yYW1kdW1wIgorCisvLyNkZWZpbmUgWlRFX0xPR19QQVRIICAgICAgIi9ob21lL2R1amluZy9jb2RlL3YzL3JhbWR1bXAvenRlX2ZpbGUiCisjZGVmaW5lIENQTE9HX1BBVEggICJwZXJzaXN0LnNlcnZpY2UuenRlbG9nLnBhdGgiCisvLyNkZWZpbmUgQ1BMT0dfVElNRVNUQU1QX0RJUiAgInBlcnNpc3Quc2VydmljZS56dGVsb2cudGltZWRpciIKKyNkZWZpbmUgX19GVU5DVElPTl9fICJyYW1kdW1wZnVjIgorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIMr9vt3A4NDNtqjS5SAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwordHlwZWRlZiBzdHJ1Y3QgeworCWNoYXIgZmlsZV9uYW1lWzMyXTsKKwl1bnNpZ25lZCBpbnQgZmlsZV9zaXplOworfSBmaWxlX2luZm9fdDsKK3R5cGVkZWYgdW5zaWduZWQgaW50IFVJTlQzMjsKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgILqvyv3J+cP3ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoKKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitleHRlcm4gaW50IGRldl9nZXRfdXNic3lzX3ZhbChjb25zdCBjaGFyICpzeXNfZmlsZW5hbWUsIGludCBiYXNlKTsKK2V4dGVybiBpbnQgZGV2X3N0clN0YXJ0c1dpdGgoY29uc3QgY2hhciAqbGluZSwgY29uc3QgY2hhciAqc3JjKTsKK2V4dGVybiBpbnQgZGV2X2dldF90dHlwb3J0X2J5X3N5c3BhdGgoY2hhciAqc3lzcGF0aCk7CitleHRlcm4gaW50IGRldl9nZXRfZGV2aWNlKHZvaWQpOworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIL7Wsr++ssysseTBv7ao0uUgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICoKKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitzdGF0aWMgaW50IGdfbW9kZW1fZmQgPSAtMTsKK3N0YXRpYyBpbnQgZ19yZWJvb3RfZmxhZyA9IDA7CitzdGF0aWMgaW50IGdfbW9uaXRlcl90aW1lID0gMDsKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIMirvtax5MG/tqjS5SAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworaW50IFBST1BFUlRZX1ZBTFVFX01BWCA9IDI1NjsKK2V4dGVybiBpbnQgZ191c2JfZGV2OworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIL7Wsr+6r8r9yrXP1iAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqCisqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIHZvaWQgbWRwX3ByaW50X2FycmF5KGNvbnN0IGNoYXIqIHByZWZpeCwgY29uc3QgY2hhciAqYnVmLCBpbnQgbGVuZ3RoKQoreworI2lmIDAKKwlpbnQgaSA9IDA7CisJaW50IGxlbiA9IE1JTihsZW5ndGgsMTYgKTsKKwlwcmludGYoIiVzICIsIHByZWZpeCApOworCWZvciAoaSA9IDA7IGk8IGxlbjsgaSsrKSB7CisJCXByaW50ZigiJTAyWCAiLCBidWZbaV0pOworCX0KKwlpZiAobGVuZ3RoID4gbGVuKQorCQlwcmludGYoIi4uLiIpOworCXByaW50ZigiXG4iKTsKKyNlbmRpZgorfQorCitzdGF0aWMgaW50IHR0eV93cml0ZShpbnQgZmQsIGNvbnN0IGNoYXIgKmJ1ZiwgaW50IHNpemUpCit7CisJaW50IHJldCA9IDA7CisJaW50IHJlcGVhdF9jb3VudCA9IDA7CitXUklURToKKwlyZXQgPSB3cml0ZShmZCwgYnVmLCBzaXplKTsKKwlpZiAoMCA9PSByZXQpIHsKKwkJcHJpbnRmKCIlcyBlcnJvcjogJXNcbiIsIF9fRlVOQ1RJT05fXywgc3RyZXJyb3IoZXJybm8pKTsKKwkJcmVwZWF0X2NvdW50ICs9IDE7CisJCWlmICgzID4gcmVwZWF0X2NvdW50KSB7CisJCQlzbGVlcCgxKTsKKwkJICAgIGdvdG8gV1JJVEU7CisJCX0KKwl9CisJaWYgKHJldCAhPSBzaXplKSB7CisJCXByaW50ZigiJXMgZmFpbGVkLCBzaXplPSVkLCByZXQ9JWRcbiIsIF9fRlVOQ1RJT05fXywgc2l6ZSwgcmV0KTsKKwkJcmV0dXJuIC0xOworCX0KKwlyZXR1cm4gMDsKK30KKworc3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jU2XSA9IHswfTsKKworCXdoaWxlKDEpCisJeworCQlpZiAoKHJldCA9PSAtMSkgJiYgKG1vbml0ZXJfdGltZSA+PSAwKSkKKwkJCXNsZWVwKG1vbml0ZXJfdGltZSk7CisJCWVsc2UKKwkJCWJyZWFrOworCQlyZXQgPSBkZXZfZ2V0X2RldmljZSgpOworCX0KKwlpZiAoZ191c2JfZGV2IDwgMCkKKwkJcmV0dXJuIC0xOworCisJc25wcmludGYoZGV2X3R0eSwgMjU2LCAiL2Rldi90dHlVU0IlZCIsIGdfdXNiX2Rldik7CisJcmV0ID0gZG9fbW9kZW1fcmFtZHVtcChkZXZfdHR5LCBkdW1wX3BhdGgpOworCWlmIChyZXQgPj0gMCkgeworCQlwcmludGYoImdldCB0aGUgcmFtZHVtcCBkYXRhIGZyb20gJXMgc3VjY2Vzc1xuIiwgZGV2X3R0eSk7CisJfSBlbHNlIGlmIChyZXQgPT0gLTEpIHsKKwkJcHJpbnRmKCJ0cnkgdG8gcmVwZWF0IGRvX21vZGVtX3JhbWR1bXAgYmVnaW5cbiIpOworCQlyZXQgPSBkb19tb2RlbV9yYW1kdW1wKGRldl90dHksIGR1bXBfcGF0aCk7CisJCWlmIChyZXQgPj0gMCkgeworCQkJcHJpbnRmKCJnZXQgdGhlIHJhbWR1bXAgZGF0YSBmcm9tICVzIHN1Y2Nlc3NcbiIsIGRldl90dHkpOworCQl9ZWxzZXsKKwkJCXByaW50ZigiZ2V0IHRoZSByYW1kdW1wIGRhdGEgZnJvbSAlcyBmYWlsZWRcbiIsIGRldl90dHkpOworCQl9CisJfQorCXJldHVybiByZXQ7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICDIq77Wuq/K/cq1z9YgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKgorKioqKioqKioqKioqKioqKioqK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