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yMKKworIyBDb3JlIGZ1bmN0aW9uYWxpdHkuCitvYmotJChDT05GSUdfTVREKQkJKz0gbXRkLm8KK210ZC15CQkJCTo9IG10ZGNvcmUubyBtdGRzdXBlci5vIG10ZGNvbmNhdC5vIG10ZHBhcnQubworCitvYmotJChDT05GSUdfTVREX09GX1BBUlRTKQkrPSBvZnBhcnQubworb2JqLSQoQ09ORklHX01URF9SRURCT09UX1BBUlRTKSArPSByZWRib290Lm8KK29iai0kKENPTkZJR19NVERfQ01ETElORV9QQVJUUykgKz0gY21kbGluZXBhcnQubworb2JqLSQoQ09ORklHX01URF9BRlNfUEFSVFMpCSs9IGFmcy5vCitvYmotJChDT05GSUdfTVREX0FSN19QQVJUUykJKz0gYXI3cGFydC5vCitvYmotJChDT05GSUdfTVREX0JDTTYzWFhfUEFSVFMpCSs9IGJjbTYzeHhwYXJ0Lm8KKworIyAnVXNlcnMnIC0gY29kZSB3aGljaCBwcmVzZW50cyBmdW5jdGlvbmFsaXR5IHRvIHVzZXJzcGFjZS4KK29iai0kKENPTkZJR19NVERfQ0hBUikJCSs9IG10ZGNoYXIubworb2JqLSQoQ09ORklHX01URF9CTEtERVZTKQkrPSBtdGRfYmxrZGV2cy5vCitvYmotJChDT05GSUdfTVREX0JMT0NLKQkJKz0gbXRkYmxvY2subworb2JqLSQoQ09ORklHX01URF9CTE9DS19STykJKz0gbXRkYmxvY2tfcm8ubworb2JqLSQoQ09ORklHX0ZUTCkJCSs9IGZ0bC5vCitvYmotJChDT05GSUdfTkZUTCkJCSs9IG5mdGwubworb2JqLSQoQ09ORklHX0lORlRMKQkJKz0gaW5mdGwubworb2JqLSQoQ09ORklHX1JGRF9GVEwpCQkrPSByZmRfZnRsLm8KK29iai0kKENPTkZJR19TU0ZEQykJCSs9IHNzZmRjLm8KK29iai0kKENPTkZJR19TTV9GVEwpCQkrPSBzbV9mdGwubworb2JqLSQoQ09ORklHX01URF9PT1BTKQkJKz0gbXRkb29wcy5vCitvYmotJChDT05GSUdfTVREX1NXQVApCQkrPSBtdGRzd2FwLm8KKworb2JqLSQoQ09ORklHX1BBUlRTX0dVQVJEKSArPSBwYXJ0aXRpb25fZ3VhcmQubworb2JqLSQoQ09ORklHX01URF9BREFQVEVSKSArPSBtdGRhZGFwdGVyLm8KKworbmZ0bC1vYmpzCQk6PSBuZnRsY29yZS5vIG5mdGxtb3VudC5vCitpbmZ0bC1vYmpzCQk6PSBpbmZ0bGNvcmUubyBpbmZ0bG1vdW50Lm8KKworI29iai15CQkrPSBjaGlwcy8gbHBkZHIvIG1hcHMvIGRldmljZXMvIG5hbmQvIG9uZW5hbmQvIHRlc3RzLworb2JqLXkJCSs9IGNoaXBzLyBscGRkci8gbWFwcy8gZGV2aWNlcy8gb25lbmFuZC8gdGVzdHMvCisKK29iai0kKENPTkZJR19NVERfWlhJQ19TUElGQykJKz0gbmFuZC8KK29iai0kKENPTkZJR19NVERfU1BJX05PUikJKz0gc3BpLW5vci8KK29iai0kKENPTkZJR19NVERfVUJJKQkJKz0gdWJpLwpkaWZmIC0tZ2l0IGEvYXAvb3MvbGludXgvbGludXgtMy40LngvZHJpdmVycy9tdGQvYWZzLmMgYi9hcC9vcy9saW51eC9saW51eC0zLjQueC9kcml2ZXJzL210ZC9hZnMuYwpuZXcgZmlsZSBtb2RlIDEwMDY0NAppbmRleCAwMDAwMDAwLi41YTM5NDJiCi0tLSAvZGV2L251bGwKKysrIGIvYXAvb3MvbGludXgvbGludXgtMy40LngvZHJpdmVycy9tdGQvYWZzLmMKQEAgLTAsMCArMSwyODEgQEAKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorCisgICAgZHJpdmVycy9tdGQvYWZzLmM6IEFSTSBGbGFzaCBMYXlvdXQvUGFydGl0aW9uaW5nCisKKyAgICBDb3B5cmlnaHQgwqkgMjAwMCBBUk0gTGltaXRlZAorCisgICBUaGlzIHByb2dyYW0gaXMgZnJlZSBzb2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mNoaXBzaGlmdCk7CisJdmVjX3NlZWsgPSAwOworCisJZG8geworCQkvKiBXZSBtdXN0IG5vdCBjcm9zcyB3cml0ZSBibG9jayBib3VuZGFyaWVzICovCisJCWludCBzaXplID0gd2J1ZnNpemUgLSAob2ZzICYgKHdidWZzaXplLTEpKTsKKworCQlpZiAoc2l6ZSA+IGxlbikKKwkJCXNpemUgPSBsZW47CisJCXJldCA9IGRvX3dyaXRlX2J1ZmZlcihtYXAsICZjZmktPmNoaXBzW2NoaXBudW1dLAorCQkJCSAgICAgIG9mcywgJnZlY3MsICZ2ZWNfc2Vlaywgc2l6ZSk7CisJCWlmIChyZXQpCisJCQlyZXR1cm4gcmV0OworCisJCW9mcyArPSBzaXplOworCQkoKnJldGxlbikgKz0gc2l6ZTsKKwkJbGVuIC09IHNpemU7CisKKwkJaWYgKG9mcyA+PiBjZmktPmNoaXBzaGlmdCkgeworCQkJY2hpcG51bSArKzsKKwkJCW9mcyA9IDA7CisJCQlpZiAoY2hpcG51bSA9PSBjZmktPm51bWNoaXBzKQorCQkJCXJldHVybiAwOworCQl9CisKKwkJLyogQmUgbmljZSBhbmQgcmVzY2hlZHVsZSB3aXRoIHRoZSBjaGlwIGluIGEgdXNhYmxlIHN0YXRlIGZvciBvdGhlcgorCQkgICBwcm9jZXNzZXMuICovCisJCWNvbmRfcmVzY2hlZCgpOworCisJfSB3aGlsZSAobGVuKTsKKworCXJldHVybiAwOworfQorCitzdGF0aWMgaW50IGNmaV9pbnRlbGV4dF93cml0ZV9idWZmZXJzIChzdHJ1Y3QgbXRkX2luZm8gKm10ZCwgbG9mZl90IHRvLAorCQkJCSAgICAgICBzaXplX3QgbGVuLCBzaXplX3QgKnJldGxlbiwgY29uc3QgdV9jaGFyICpidWYpCit7CisJc3RydWN0IGt2ZWMgdmVjOworCisJdmVjLmlvdl9iYXNlID0gKHZvaWQgKikgYnVmOworCXZlYy5pb3ZfbGVuID0gbGVuOworCisJcmV0dXJuIGNmaV9pbnRlbGV4dF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SAhPSBGTF9XUklUSU5HKSB7CisJCQkvKiBTb21lb25lJ3Mgc3VzcGVuZGVkIHRoZSB3cml0ZS4gU2xlZXAgKi8KKwkJCXNldF9jdXJyZW50X3N0YXRlKFRBU0tfVU5JTlRFUlJVUFRJQkxFKTsKKwkJCWFkZF93YWl0X3F1ZXVlKCZjaGlwLT53cSwgJndhaXQpOworCQkJbXV0ZXhfdW5sb2NrKCZjaGlwLT5tdXRleCk7CisJCQlzY2hlZHVsZSgpOworCQkJcmVtb3ZlX3dhaXRfcXVldWUoJmNoaXAtPndxLCAmd2FpdCk7CisJCQl0aW1lbyA9IGppZmZpZXMgKyAoSFogLyAyKTsgLyogRklYTUUgKi8KKwkJCW11dGV4X2xvY2soJmNoaXAtPm11dGV4KTsKKwkJCWNvbnRpbnVlOworCQl9CisKKwkJc3RhdHVzID0gbWFwX3JlYWQobWFwLCBjbWRfYWRyKTsKKwkJaWYgKG1hcF93b3JkX2FuZGVxdWFsKG1hcCwgc3RhdHVzLCBzdGF0dXNfT0ssIHN0YXR1c19PSykpCisJCQlicmVhazsKKworCQkvKiBPSyBTdGlsbCB3YWl0aW5nICovCisJCWlmICh0aW1lX2FmdGVyKGppZmZpZXMsIHRpbWVvKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgLyogY2xlYXIgc3RhdHVzICovCisgICAgICAgICAgICAgICAgICAgICAgICBtYXBfd3JpdGUobWFwLCBDTUQoMHg1MCksIGNtZF9hZHIpOworICAgICAgICAgICAgICAgICAgICAgICAgLyogcHV0IGJhY2sgaW50byByZWFkIHN0YXR1cyByZWdpc3RlciBtb2RlICovCisgICAgICAgICAgICAgICAgICAgICAgICBtYXBfd3JpdGUobWFwLCBDTUQoMHg3MCksIGFkcik7CisJCQljaGlwLT5zdGF0ZSA9IEZMX1NUQVRVUzsKKwkJCURJU0FCTEVfVlBQKG1hcCk7CisJCQltdXRleF91bmxvY2soJmNoaXAtPm11dGV4KTsKKwkJCXByaW50ayhLRVJOX0VSUiAid2Fp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aygiJXM6IG9mc1sleF0gbGVuWyV4XVxuIiwgX19mdW5jX18sIG9mcywgbGVuKTsKKyNlbmRpZgorCisgICAgICAgIC8qIFdyaXRlIGJ1ZmZlciBpcyB3b3J0aCBpdCBvbmx5IGlmIG1vcmUgdGhhbiBvbmUgd29yZCB0byB3cml0ZS4uLiAqLworICAgICAgICB3aGlsZSAobGVuID4gMCkgeworCQkvKiBXZSBtdXN0IG5vdCBjcm9zcyB3cml0ZSBibG9jayBib3VuZGFyaWVzICovCisJCWludCBzaXplID0gd2J1ZnNpemUgLSAob2ZzICYgKHdidWZzaXplLTEpKTsKKworICAgICAgICAgICAgICAgIGlmIChzaXplID4gbGVuKQorICAgICAgICAgICAgICAgICAgICBzaXplID0gbGVuOworCisgICAgICAgICAgICAgICAgcmV0ID0gZG9fd3JpdGVfYnVmZmVyKG1hcCwgJmNmaS0+Y2hpcHNbY2hpcG51bV0sCisJCQkJICAgICAgb2ZzLCBidWYsIHNpemUpOworCQlpZiAocmV0KQorCQkJcmV0dXJuIHJldDsKKworCQlvZnMgKz0gc2l6ZTsKKwkJYnVmICs9IHNpemU7CisJCSgqcmV0bGVuKSArPSBzaXplOworCQlsZW4gLT0gc2l6ZTsKKworCQlpZiAob2ZzID4+IGNmaS0+Y2hpcHNoaWZ0KSB7CisJCQljaGlwbnVtICsrOworCQkJb2ZzID0gMDsKKwkJCWlmIChjaGlwbnVtID09IGNmaS0+bnVtY2hpcHMpCisJCQkJcmV0dXJuIDA7CisJCX0KKwl9CisKKwlyZXR1cm4gMDsKK30KKworLyoKKyAqIFdyaXRldiBmb3IgRUNDLUZsYXNoZXMgaXMgYSBsaXR0bGUgbW9yZSBjb21wbGljYXRlZC4gV2UgbmVlZCB0byBtYWludGFpbgorICogYSBzbWFsbCBidWZmZXIgZm9yIHRoaXMuCisgKiBYWFg6IElmIHRoZSBidWZmZXIgc2l6ZSBpcyBub3QgYSBtdWx0aXBsZSBvZiAyLCB0aGlzIHdpbGwgYnJlYWsKKyAq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sdDoKKwkJcHJpbnRrKEtFUk5fV0FSTklORworCQkgICAgICAgIk1URCAlcygpOiBVbnN1cHBvcnRlZCBkZXZpY2UgdHlwZSAlZFxuIiwKKwkJICAgICAgIF9fZnVuY19fLCBjZmktPmRldmljZV90eXBlKTsKKwkJZ290byBtYXRjaF9kb25lOworCX0KKwlpZiAoIGNmaS0+bWZyICE9IG1mciB8fCBjZmktPmlkICE9IGlkICkgeworCQlnb3RvIG1hdGNoX2RvbmU7CisJfQorCisJLyogdGhlIHBhcnQgc2l6ZSBtdXN0IGZpdCBpbiB0aGUgbWVtb3J5IHdpbmRvdyAqLworCXByX2RlYnVnKCJNVEQgJXMoKTogQ2hlY2sgZml0IDB4JS44eCArIDB4JS44eCA9IDB4JS44eFxuIiwKKwkgICAgICAgX19mdW5jX18sIGJhc2UsIDEgPDwgZmluZm8tPmRldl9zaXplLCBiYXNlICsgKDEgPDwgZmluZm8tPmRldl9zaXplKSApOworCWlmICggYmFzZSArIGNmaV9pbnRlcmxlYXZlKGNmaSkgKiAoIDEgPDwgZmluZm8tPmRldl9zaXplICkgPiBtYXAtPnNpemUgKSB7CisJCXByX2RlYnVnKCJNVEQgJXMoKTogMHglLjR4IDB4JS40eCAlZEtpQiBkb2Vzbid0IGZpdFxuIiwKKwkJICAgICAgIF9fZnVuY19fLCBmaW5mby0+bWZyX2lkLCBmaW5mby0+ZGV2X2lkLAorCQkgICAgICAgMSA8PCBmaW5mby0+ZGV2X3NpemUgKTsKKwkJZ290byBtYXRjaF9kb25lOworCX0KKworCWlmICghIChmaW5mby0+ZGV2dHlwZXMgJiBjZmktPmRldmljZV90eXBlKSkKKwkJZ290byBtYXRjaF9kb25lOworCisJdWFkZHIgPSBmaW5mby0+dWFkZHI7CisKKwlwcl9kZWJ1ZygiTVREICVzKCk6IGNoZWNrIHVubG9jayBhZGRycyAweCUuNHggMHglLjR4XG4iLAorCSAgICAgICBfX2Z1bmNfXywgY2ZpLT5hZGRyX3VubG9jazEsIGNmaS0+Y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lvbnMsIHRoaXMgZnVuY3Rpb24gY2FsbHMgaXRzZWxmCisgKiByZWN1cnNpdmVseSB1bnRpbCBubyBtb3JlIHBhcnRpdGlvbiBkZWZpbml0aW9ucyBhcmUgZm91bmQuIE5pY2Ugc2lkZQorICogZWZmZWN0OiB0aGUgbWVtb3J5IHRvIGtlZXAgdGhlIG10ZF9wYXJ0aXRpb24gc3RydWN0cyBhbmQgdGhlIG5hbWVzCisgKiBpcyBhbGxvY2F0ZWQgdXBvbiB0aGUgbGFzdCBkZWZpbml0aW9uIGJlaW5nIGZvdW5kLiBBdCB0aGF0IHBvaW50IHRoZQorICogc3ludGF4IGhhcyBiZWVuIHZlcmlmaWVkIG9rLgorICovCitzdGF0aWMgc3RydWN0IG10ZF9wYXJ0aXRpb24gKiBuZXdwYXJ0KGNoYXIgKnMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYXIgKipyZXRwdHIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCAqbnVtX3BhcnRzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgdGhpc19wYXJ0LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBjaGFyICoqZXh0cmFfbWVtX3B0ciwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IGV4dHJhX21lbV9zaXplKQoreworCXN0cnVjdCBtdGRfcGFydGl0aW9uICpwYXJ0czsKKwl1bnNpZ25lZCBsb25nIHNpemU7CisJdW5zaWduZWQgbG9uZyBvZmZzZXQgPSBPRkZTRVRfQ09OVElOVU9VUzsKKwljaGFyICpuYW1lOworCWludCBuYW1lX2xlbjsKKwl1bnNpZ25lZCBjaGFyICpleHRyYV9tZW07CisJY2hhciBkZWxpbTsKKwl1bnNpZ25lZCBpbnQgbWFza19mbGFnczsKKworCS8qIGZldGNoIHRoZSBwYXJ0aXRpb24gc2l6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IFJlYWRET0NfKGRvY3B0ciwgdGhpcy0+aW9yZWcpOworCQl9CisKKwkJaWYgKHN0YXR1cyAmIDEpIHsKKwkJCXByaW50ayhLRVJOX0VSUiAiRXJyb3IgZXJhc2luZyBhdCAweCV4XG4iLCBvZnMpOworCQkJLyogVGhlcmUgd2FzIGFuIGVycm9yICovCisJCQlpbnN0ci0+c3RhdGUgPSBNVERfRVJBU0VfRkFJTEVEOworCQkJZ290byBjYWxsYmFjazsKKwkJfQorCQlvZnMgKz0gbXRkLT5lcmFzZXNpemU7CisJCWxlbiAtPSBtdGQtPmVyYXNlc2l6ZTsKKwl9CisJaW5zdHItPnN0YXRlID0gTVREX0VSQVNFX0RPTkU7CisKKyBjYWxsYmFjazoKKwltdGRfZXJhc2VfY2FsbGJhY2soaW5zdHIpOworCisJbXV0ZXhfdW5sb2NrKCZ0aGlzLT5sb2NrKTsKKwlyZXR1cm4gMDsKK30KKworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICoKKyAqIE1vZHVsZSBzdHVmZgorICoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCitzdGF0aWMgdm9pZCBfX2V4aXQgY2xlYW51cF9kb2MyMDAwKHZvaWQpCit7CisJc3RydWN0IG10ZF9pbmZvICptdGQ7CisJc3RydWN0IERpc2tPbkNoaXAgKnRoaXM7CisKKwl3aGlsZSAoKG10ZCA9IGRvYzJrbGlzdCkpIHsKKwkJdGhpcyA9IG10ZC0+cHJpdjsKKwkJZG9jMmtsaXN0ID0gdGhpcy0+bmV4dGRvYzsKKworCQltdGRfZGV2aWNlX3VucmVnaXN0ZXIobXRkKTsKKworCQlpb3VubWFwKHRoaXMtPnZpcnRhZHIpOworCQlrZnJlZSh0aGlzLT5jaGlwcyk7CisJCWtmcmVlKG10ZCk7CisJf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AgRklYTUU6IGltcGxlbWVudCBCYWQgQmxvY2sgUmVwbGFjZW1lbnQgKGluIG5mdGwuYyA/PykgKi8KKwkJaW5zdHItPnN0YXRlID0gTVREX0VSQVNFX0ZBSUxFRDsKKwl9IGVsc2UKKwkJaW5zdHItPnN0YXRlID0gTVREX0VSQVNFX0RPTkU7CisJZHVtbXkgPSBSZWFkRE9DKGRvY3B0ciwgTGFzdERhdGFSZWFkKTsKKworCW10ZF9lcmFzZV9jYWxsYmFjayhpbnN0cik7CisKKwlyZXR1cm4gMDsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqCisgKiBNb2R1bGUgc3R1ZmYKKyAqCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworc3RhdGljIHZvaWQgX19leGl0IGNsZWFudXBfZG9jMjAwMSh2b2lkKQoreworCXN0cnVjdCBtdGRfaW5mbyAqbXRkOworCXN0cnVjdCBEaXNrT25DaGlwICp0aGlzOworCisJd2hpbGUgKChtdGQ9ZG9jbWlsbGlzdCkpIHsKKwkJdGhpcyA9IG10ZC0+cHJpdjsKKwkJZG9jbWlsbGlzdCA9IHRoaXMtPm5leHRkb2M7CisKKwkJbXRkX2RldmljZV91bnJlZ2lzdGVyKG10ZCk7CisKKwkJaW91bm1hcCh0aGlzLT52aXJ0YWRyKTsKKwkJa2ZyZWUodGhpcy0+Y2hpcHMpOworCQlrZnJlZShtdGQpOworCX0KK30KKworbW9kdWxlX2V4aXQoY2xlYW51cF9kb2MyMDAxKTsKKworTU9EVUxFX0xJQ0VOU0UoIkdQTCIpOworTU9EVUxFX0FVVEhPUigiRGF2aWQgV29vZGhvdXNlIDxkd213MkBpbmZyYWRlYWQub3JnPiBldCBhbC4iKTsKK01PRFVMRV9ERVNDUklQVElPTigiQWx0ZXJuYX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FVCwgZG9jcHRyLCBNcGx1c19FQ0NDb25mKTsKKworCVJlYWRET0MoZG9jcHRyLCBNcGx1c19SZWFkUGlwZUluaXQpOworCVJlYWRET0MoZG9jcHRyLCBNcGx1c19SZWFkUGlwZUluaXQpOworCisJLyogUmVhZCB0aGUgZGF0YSB2aWEgdGhlIGludGVybmFsIHBpcGVsaW5lIHRocm91Z2ggQ0RTTiBJTworCSAgIHJlZ2lzdGVyLCBzZWUgUGlwZWxpbmVkIFJlYWQgT3BlcmF0aW9ucyAxMS4zICovCisJTWVtUmVhZERPQyhkb2NwdHIsIGJ1ZiwgMTA1NCk7CisJYnVmWzEwNTRdID0gUmVhZERPQyhkb2NwdHIsIE1wbHVzX0xhc3REYXRhUmVhZCk7CisJYnVmWzEwNTVdID0gUmVhZERPQyhkb2NwdHIsIE1wbHVzX0xhc3REYXRhUmVhZCk7CisKKwltZW1zZXQoJmNbMF0sIDAsIHNpemVvZihjKSk7CisJcHJpbnRrKCJEVU1QIE9GRlNFVD0leDpcbiIsIChpbnQpZnJvbSk7CisKKyAgICAgICAgZm9yIChpID0gMCwgYnAgPSAmYnVmWzBdOyAoaSA8IDEwNTYpOyBpKyspIHsKKyAgICAgICAgICAgICAgICBpZiAoKGkgJSAxNikgPT0gMCkKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50aygiJTA4eDogIiwgaSk7CisgICAgICAgICAgICAgICAgcHJpbnRrKCIgJTAyeCIsICpicCk7CisgICAgICAgICAgICAgICAgY1soaSAmIDB4ZildID0gKCgqYnAgPj0gMHgyMCkgJiYgKCpicCA8PSAweDdmKSkgPyAqYnAgOiAnLic7CisgICAgICAgICAgICAgICAgYnArKzsKKyAgICAgICAgICAgICAgICBpZiAoKChpICsgMSkgJSAxNikgPT0gMCkKKyAgICAgICAgICAgICAgICAgICAgICAgIHByaW50aygiICAgICVzXG4iLCBjKTsKKyAgICAgICAgfQorCXByaW50aygiXG4iKTsKKworCS8qIERpc2FibGUgZmxhc2ggaW50ZXJ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OworCQkvKiBGSVhNRTogaW1wbGVtZW50IEJhZCBCbG9jayBSZXBsYWNlbWVudCAoaW4gbmZ0bC5jID8/KSAqLworCQlpbnN0ci0+c3RhdGUgPSBNVERfRVJBU0VfRkFJTEVEOworCX0gZWxzZSB7CisJCWluc3RyLT5zdGF0ZSA9IE1URF9FUkFTRV9ET05FOworCX0KKwlkdW1teSA9IFJlYWRET0MoZG9jcHRyLCBNcGx1c19MYXN0RGF0YVJlYWQpOworCisJLyogRGlzYWJsZSBmbGFzaCBpbnRlcm5hbGx5ICovCisJV3JpdGVET0MoMCwgZG9jcHRyLCBNcGx1c19GbGFzaFNlbGVjdCk7CisKKwltdGRfZXJhc2VfY2FsbGJhY2soaW5zdHIpOworCisJcmV0dXJuIDA7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKgorICogTW9kdWxlIHN0dWZmCisgKgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK3N0YXRpYyB2b2lkIF9fZXhpdCBjbGVhbnVwX2RvYzIwMDFwbHVzKHZvaWQpCit7CisJc3RydWN0IG10ZF9pbmZvICptdGQ7CisJc3RydWN0IERpc2tPbkNoaXAgKnRoaXM7CisKKwl3aGlsZSAoKG10ZD1kb2NtaWxwbHVzbGlzdCkpIHsKKwkJdGhpcyA9IG10ZC0+cHJpdjsKKwkJZG9jbWlscGx1c2xpc3QgPSB0aGlzLT5uZXh0ZG9jOworCisJCW10ZF9kZXZpY2VfdW5yZWdpc3RlcihtdGQpOworCisJCWlvdW5tYXAodGhpcy0+dmlydGFkcik7CisJCWtmcmVlKHRoaXMtPmNoaXBzKTsKKwkJa2ZyZWUobXRkKTsKKwl9Cit9CisKK21vZHVsZV9leGl0KGNsZWFudXBfZG9jMjAwMXBsdXMpOworCitNT0RVTEVfTEl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tb2Rubih0bXAgKyAyICogS0sgKiAoQjAraS0xKSpQUklNKTsKKyAgICAgIHNbaV0gPSB0bXA7CisgIH0KKworICBDTEVBUigmbGFtYmRhWzFdLE5OLUtLKTsKKyAgbGFtYmRhWzBdID0gMTsKKworICBpZiAobm9fZXJhcyA+IDApIHsKKyAgICAvKiBJbml0IGxhbWJkYSB0byBiZSB0aGUgZXJhc3VyZSBsb2NhdG9yIHBvbHlub21pYWwgKi8KKyAgICBsYW1iZGFbMV0gPSBBbHBoYV90b1ttb2RubihQUklNICogZXJhc19wb3NbMF0pXTsKKyAgICBmb3IgKGkgPSAxOyBpIDwgbm9fZXJhczsgaSsrKSB7CisgICAgICB1ID0gbW9kbm4oUFJJTSplcmFzX3Bvc1tpXSk7CisgICAgICBmb3IgKGogPSBpKzE7IGogPiAwOyBqLS0pIHsKKwl0bXAgPSBJbmRleF9vZltsYW1iZGFbaiAtIDFdXTsKKwlpZih0bXAgIT0gQTApCisJICBsYW1iZGFbal0gXj0gQWxwaGFfdG9bbW9kbm4odSArIHRtcCldOworICAgICAgfQorICAgIH0KKyNpZiBERUJVR19FQ0MgPj0gMQorICAgIC8qIFRlc3QgY29kZSB0aGF0IHZlcmlmaWVzIHRoZSBlcmFzdXJlIGxvY2F0b3IgcG9seW5vbWlhbCBqdXN0IGNvbnN0cnVjdGVkCisgICAgICAgTmVlZGVkIG9ubHkgZm9yIGRlY29kZXIgZGVidWdnaW5nLiAqLworCisgICAgLyogZmluZCByb290cyBvZiB0aGUgZXJhc3VyZSBsb2NhdGlvbiBwb2x5bm9taWFsICovCisgICAgZm9yKGk9MTtpPD1ub19lcmFzO2krKykKKyAgICAgIHJlZ1tpXSA9IEluZGV4X29mW2xhbWJkYVtpXV07CisgICAgY291bnQgPSAwOworICAgIGZvciAoaSA9IDEsaz1OTi1MZGVjOyBpIDw9IE5OOyBpKyssayA9IG1vZG5uKE5OK2stTGRlYykpIHsKKyAgICAgIHEgPSAxOworICAgICAgZm9yIChqID0gMTsgaiA8PSBub19lcmFzOyBqKyspCisJaWYgKHJlZ1tqXSAhPSBBMCkgeworCSAgcmVnW2pdID0gbW9kbm4ocmVnW2pdICsgaik7CisJICBxIF49IEFscGhhX3RvW3JlZ1tqXV07CisJfQorICAgICAgaWYgKHEgIT0gMCkKKwljb250aW51ZTsKKyAgICAgIC8qIHN0b3JlIHJvb3QgYW5kIGVycm9yIGxvY2F0aW9uIG51bWJlciBpbmRpY2VzICovCisgICAgICByb290W2NvdW50XSA9IGk7CisgICAgICBsb2NbY291bnRdID0gazsKKyAgICAgIGNvdW50Kys7CisgICAgfQorICAgIGlmIChjb3VudCAhPSBub19lcmFzKSB7CisgICAgICBwcmludGYoIlxuIGxhbWJkYSh4KSBpcyBXUk9OR1xuIik7CisgICAgICBjb3VudCA9IC0xOworICAgICAgZ290byBmaW5pc2g7CisgICAgfQorI2lmIERFQlVHX0VDQyA+PSAyCisgICAgcHJpbnRmKCJcbiBFcmFzdXJlIHBvc2l0aW9ucyBhcyBkZXRlcm1pbmVkIGJ5IHJvb3RzIG9mIEVyYXMgTG9jIFBvbHk6XG4iKTsKKyAgICBmb3IgKGkgPSAwOyBpIDwgY291bnQ7IGkrKykKKyAgICAgIHByaW50ZigiJWQgIiwgbG9jW2ldKTsKKyAgICBwcmludGYoIlxuIik7CisjZW5kaWYKKyNlbmRpZgorICB9CisgIGZvcihpPTA7aTxOTi1LSysxO2krKykKKyAgICBiW2ldID0gSW5kZXhfb2ZbbGFtYmRhW2ldXTsKKworICAvKgorICAgKiBCZWdpbiBCZXJsZWthbXAtTWFzc2V5IGFsZ29yaXRobSB0byBkZXRlcm1pbmUgZXJyb3IrZXJhc3VyZQorICAgKiBsb2NhdG9yIHBvbHlub21pYWwKKyAgICovCisgIHIgPSBub19lcmFzOworICBlbCA9IG5vX2VyYXM7CisgIHdoaWxlICgrK3IgPD0gTk4tS0spIHsJLyogciBpcyB0aGUgc3RlcCBudW1iZXIgKi8KKyAgICAvKiBDb21wdXRlIGRpc2NyZ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ChpbmRleC1mb3JtKSBhbmQgZXJyb3IgbG9jYXRpb24gbnVtYmVyICovCisgICAgcm9vdFtjb3VudF0gPSBpOworICAgIGxvY1tjb3VudF0gPSBrOworICAgIC8qIElmIHdlJ3ZlIGFscmVhZHkgZm91bmQgbWF4IHBvc3NpYmxlIHJvb3RzLAorICAgICAqIGFib3J0IHRoZSBzZWFyY2ggdG8gc2F2ZSB0aW1lCisgICAgICovCisgICAgaWYoKytjb3VudCA9PSBkZWdfbGFtYmRhKQorICAgICAgYnJlYWs7CisgIH0KKyAgaWYgKGRlZ19sYW1iZGEgIT0gY291bnQpIHsKKyAgICAvKgorICAgICAqIGRlZyhsYW1iZGEpIHVuZXF1YWwgdG8gbnVtYmVyIG9mIHJvb3RzID0+IHVuY29ycmVjdGFibGUKKyAgICAgKiBlcnJvciBkZXRlY3RlZAorICAgICAqLworICAgIGNvdW50ID0gLTE7CisgICAgZ290byBmaW5pc2g7CisgIH0KKyAgLyoKKyAgICogQ29tcHV0ZSBlcnIrZXJhcyBldmFsdWF0b3IgcG9seSBvbWVnYSh4KSA9IHMoeCkqbGFtYmRhKHgpIChtb2R1bG8KKyAgICogeCoqKE5OLUtLKSkuIGluIGluZGV4IGZvcm0uIEFsc28gZmluZCBkZWcob21lZ2EpLgorICAgKi8KKyAgZGVnX29tZWdhID0gMDsKKyAgZm9yIChpID0gMDsgaSA8IE5OLUtLO2krKyl7CisgICAgdG1wID0gMDsKKyAgICBqID0gKGRlZ19sYW1iZGEgPCBpKSA/IGRlZ19sYW1iZGEgOiBpOworICAgIGZvcig7aiA+PSAwOyBqLS0peworICAgICAgaWYgKChzW2kgKyAxIC0gal0gIT0gQTApICYmIChsYW1iZGFbal0gIT0gQTApKQorCXRtcCBePSBBbHBoYV90b1ttb2RubihzW2kgKyAxIC0gal0gKyBsYW1iZGFbal0pXTsKKyAgICB9CisgICAgaWYodG1wICE9IDApCisgICAgICBkZWdfb21lZ2EgPSBpOworICAgIG9tZWdhW2ldID0gSW5kZXhfb2ZbdG1wXTsKKyAgfQorICBvbWVnYVtOTi1LS10gPSBBMDsKKworICAvKgorICAgKiBDb21wdXRlIGVycm9yIHZhbHVlcyBpbiBwb2x5LWZvcm0uIG51bTEgPSBvbWVnYShpbnYoWChsKSkpLCBudW0yID0KKyAgICogaW52KFgobCkpKiooQjAtMSkgYW5kIGRlbiA9IGxhbWJkYV9wcihpbnYoWChsKSkpIGFsbCBpbiBwb2x5LWZvcm0KKyAgICovCisgIGZvciAoaiA9IGNvdW50LTE7IGogPj0wOyBqLS0pIHsKKyAgICBudW0xID0gMDsKKyAgICBmb3IgKGkgPSBkZWdfb21lZ2E7IGkgPj0gMDsgaS0tKSB7CisgICAgICBpZiAob21lZ2FbaV0gIT0gQTApCisJbnVtMSAgXj0gQWxwaGFfdG9bbW9kbm4ob21lZ2FbaV0gKyBpICogcm9vdFtqXSldOworICAgIH0KKyAgICBudW0yID0gQWxwaGFfdG9bbW9kbm4ocm9vdFtqXSAqIChCMCAtIDEpICsgTk4pXTsKKyAgICBkZW4gPSAwOworCisgICAgLyogbGFtYmRhW2krMV0gZm9yIGkgZXZlbiBpcyB0aGUgZm9ybWFsIGRlcml2YXRpdmUgbGFtYmRhX3ByIG9mIGxhbWJkYVtpXSAqLworICAgIGZvciAoaSA9IG1pbihkZWdfbGFtYmRhLE5OLUtLLTEpICYgfjE7IGkgPj0gMDsgaSAtPTIpIHsKKyAgICAgIGlmKGxhbWJkYVtpKzFdICE9IEEwKQorCWRlbiBePSBBbHBoYV90b1ttb2RubihsYW1iZGFbaSsxXSArIGkgKiByb290W2pdKV07CisgICAgfQorICAgIGlmIChkZW4gPT0gMCkgeworI2lmIERFQlVHX0VDQyA+PSAxCisgICAgICBwcmludGYoIlxuIEVSUk9SOiBkZW5vbWluYXRvciA9IDBcbiIpOworI2VuZGlmCisgICAgICAvKiBDb252ZXJ0IHRvIGR1YWwtIGJhc2lzICovCisgICAgICBjb3VudCA9IC0xOworICAgICAgZ290byBmaW5pc2g7CisgIC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U0VDVE9SX1NJWkVdLCB1bnNpZ25lZCBjaGFyIGVjYzFbNl0pCit7CisgICAgaW50IHBhcml0eSwgaSwgbmJfZXJyb3JzOworICAgIGdmIGJiW05OIC0gS0sgKyAxXTsKKyAgICBnZiBlcnJvcl92YWxbTk4tS0tdOworICAgIGludCBlcnJvcl9wb3NbTk4tS0tdLCBwb3MsIGJpdHBvcywgaW5kZXgsIHZhbDsKKyAgICBkdHlwZSAqQWxwaGFfdG8sICpJbmRleF9vZjsKKworICAgIC8qIGluaXQgbG9nIGFuZCBleHAgdGFibGVzIGhlcmUgdG8gc2F2ZSBtZW1vcnkuIEhvd2V2ZXIsIGl0IGlzIHNsb3dlciAqLworICAgIEFscGhhX3RvID0ga21hbGxvYygoTk4gKyAxKSAqIHNpemVvZihkdHlwZSksIEdGUF9LRVJORUwpOworICAgIGlmICghQWxwaGFfdG8pCisgICAgICAgIHJldHVybiAtMTsKKworICAgIEluZGV4X29mID0ga21hbGxvYygoTk4gKyAxKSAqIHNpemVvZihkdHlwZSksIEdGUF9LRVJORUwpOworICAgIGlmICghSW5kZXhfb2YpIHsKKyAgICAgICAga2ZyZWUoQWxwaGFfdG8pOworICAgICAgICByZXR1cm4gLTE7CisgICAgfQorCisgICAgZ2VuZXJhdGVfZ2YoQWxwaGFfdG8sIEluZGV4X29mKTsKKworICAgIHBhcml0eSA9IGVjYzFbMV07CisKKyAgICBiYlswXSA9ICAoZWNjMVs0XSAmIDB4ZmYpIHwgKChlY2MxWzVdICYgMHgwMykgPDwgOCk7CisgICAgYmJbMV0gPSAoKGVjYzFbNV0gJiAweGZjKSA+PiAyKSB8ICgoZWNjMVsyXSAmIDB4MGYpIDw8IDYpOworICAgIGJiWzJdID0gKChlY2MxWzJdICYgMHhmMCkgPj4gNCkgfCAoKGVjYzFbM10gJiAweDNmKSA8PCA0KTsKKyAgICBiYlszXSA9ICgoZWNjMVszXSAmIDB4YzApID4+IDYpIHwgKChlY2MxWzBdICYgMHhmZikgPDwgMik7CisKKyAgICBuYl9lcnJvcnMgPSBlcmFzX2RlY19ycyhBbHBoYV90bywgSW5kZXhfb2YsIGJiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVycm9yX3ZhbCwgZXJyb3JfcG9zLCAwKTsKKyAgICBpZiAobmJfZXJyb3JzIDw9IDApCisgICAgICAgIGdvdG8gdGhlX2VuZDsKKworICAgIC8qIGNvcnJlY3QgdGhlIGVycm9ycyAqLworICAgIGZvcihpPTA7aTxuYl9lcnJvcnM7aSsrKSB7CisgICAgICAgIHBvcyA9IGVycm9yX3Bvc1tpXTsKKyAgICAgICAgaWYgKHBvcyA+PSBOQl9EQVRBICYmIHBvcyA8IEtLKSB7CisgICAgICAgICAgICBuYl9lcnJvcnMgPSAtMTsKKyAgICAgICAgICAgIGdvdG8gdGhlX2VuZDsKKyAgICAgICAgfQorICAgICAgICBpZiAocG9zIDwgTkJfREFUQSkgeworICAgICAgICAgICAgLyogZXh0cmFjdCBiaXQgcG9zaXRpb24gKE1TQiBmaXJzdCkgKi8KKyAgICAgICAgICAgIHBvcyA9IDEwICogKE5CX0RBVEEgLSAxIC0gcG9zKSAtIDY7CisgICAgICAgICAgICAvKiBub3cgY29ycmVjdCB0aGUgZm9sbG93aW5nIDEwIGJpdHMuIEF0IG1vc3QgdHdvIGJ5dGVzCisgICAgICAgICAgICAgICBjYW4gYmUgbW9kaWZpZWQgc2luY2UgcG9zIGlzIGV2ZW4gKi8KKyAgICAgICAgICAgIGluZGV4ID0gKHBvcyA+PiAzKSBeIDE7CisgICAgICAgICAgICBiaXRwb3MgPSBwb3MgJiA3OworICAgICAgICAgICAgaWYgKChpbmRleCA+PSAwICYmIGluZGV4IDwgU0VDVE9SX1NJWkUpIHx8CisgICAgICAgICAgICAgICAgaW5kZXggPT0gKFNFQ1RPUl9TSVpFICsgMSkpIHsKKyAgICAgICAgICAgICAgICB2YWwgPSBlcnJvcl92YWxbaV0gPj4gKDIgKyBiaXRwb3MpOworICAgICAgICAgICAgICAgIHBhcml0eSBePSB2YWw7CisgICAgICAgICAgICAgICAgaWYgKGluZGV4IDwgU0VDVE9SX1NJWkUpCisgICAgICAgICAgICAgICAgICAgIHNlY3RvcltpbmRleF0gXj0gdmFsOworICAgICAgICAgICAgfQorICAgICAgICAgICAgaW5kZXggPSAoKHBvcyA+PiAzKSArIDEpIF4gMTsKKyAgICAgICAgICAgIGJpdHBvcyA9IChiaXRwb3MgKyAxMCkgJiA3OworICAgICAgICAgICAgaWYgKGJpdHBvcyA9PSAwKQorICAgICAgICAgICAgICAgIGJpdHBvcyA9IDg7CisgICAgICAgICAgICBpZiAoKGluZGV4ID49IDAgJiYgaW5kZXggPCBTRUNUT1JfU0laRSkgfHwKKyAgICAgICAgICAgICAgICBpbmRleCA9PSAoU0VDVE9SX1NJWkUgKyAxKSkgeworICAgICAgICAgICAgICAgIHZhbCA9IGVycm9yX3ZhbFtpXSA8PCAoOCAtIGJpdHBvcyk7CisgICAgICAgICAgICAgICAgcGFyaXR5IF49IHZhbDsKKyAgICAgICAgICAgICAgICBpZiAoaW5kZXggPCBTRUNUT1JfU0laRSkKKyAgICAgICAgICAgICAgICAgICAgc2VjdG9yW2luZGV4XSBePSB2YWw7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICB9CisKKyAgICAvKiB1c2UgcGFyaXR5IHRvIHRlc3QgZXh0cmEgZXJyb3JzICovCisgICAgaWYgKChwYXJpdHkgJiAweGZmKSAhPSAwKQorICAgICAgICBuYl9lcnJvcnMgPSAtMTsKKworIHRoZV9lbmQ6CisgICAga2ZyZWUoQWxwaGFfdG8pOworICAgIGtmcmVlKEluZGV4X29mKTsKKyAgICByZXR1cm4gbmJfZXJyb3JzOworfQorCitFWFBPUlRfU1lNQk9MX0dQTChkb2NfZGVjb2RlX2VjYyk7CisKK01PRFVMRV9MSUNFTlNFKCJHUEwiKTsKK01PRFVMRV9BVVRIT1IoIkZhYnJpY2UgQmVsbGFyZCA8ZmFicmljZS5iZWxsYXJkQG5ldGdlb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EVfRFJJVkVSICovCisJCQlicmVhazsKKworCQljYXNlIERPQ19DaGlwSURfRG9jTWlsUGx1czE2OgorCQljYXNlIERPQ19DaGlwSURfRG9jTWlsUGx1czMyOgorCQkJbmFtZT0iTWlsbGVubml1bVBsdXMiOworCQkJaW5pdHJvdXRpbmUgPSBzeW1ib2xfcmVxdWVzdChEb0NNaWxQbHVzX2luaXQpOworCQkJYnJlYWs7CisJCX0KKworCQlpZiAoaW5pdHJvdXRpbmUpIHsKKwkJCSgqaW5pdHJvdXRpbmUpKG10ZCk7CisJCQlzeW1ib2xfcHV0X2FkZHIoaW5pdHJvdXRpbmUpOworCQkJcmV0dXJuOworCQl9CisJCXByaW50ayhLRVJOX05PVElDRSAiQ2Fubm90IGZpbmQgZHJpdmVyIGZvciBEaXNrT25DaGlwICVzIGF0IDB4JWxYXG4iLCBuYW1lLCBwaHlzYWRyKTsKKwkJa2ZyZWUobXRkKTsKKwl9CisJaW91bm1hcChkb2NwdHIpOworfQorCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKgorICogTW9kdWxlIHN0dWZmCisgKgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK3N0YXRpYyBpbnQgX19pbml0IGluaXRfZG9jKHZvaWQpCit7CisJaW50IGk7CisKKwlpZiAoZG9jX2NvbmZpZ19sb2NhdGlvbikgeworCQlwcmludGsoS0VSTl9JTkZPICJVc2luZyBjb25maWd1cmVkIERpc2tPbkNoaXAgcHJvYmUgYWRkcmVzcyAweCVseFxuIiwgZG9jX2NvbmZpZ19sb2NhdGlvbik7CisJCURvQ19Qcm9iZShkb2NfY29uZmlnX2xvY2F0aW9uKTsKKwl9IGVsc2UgeworCQlmb3IgKGk9MDsgKGRvY19sb2NhdGlvbnNbaV0gIT0gMHhmZmZmZmZmZ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wMDAxMAkJLyogUHJvZ3JhbSBTdGF0dXMgKFBTKSAqLworCisvKgorICogU2VlIHNlY3Rpb24gNC4yIGluICIzIFZvbHQgRmFzdCBCb290IEJsb2NrIEZsYXNoIE1lbW9yeSIgSW50ZWwgRGF0YXNoZWV0CisgKi8KKyNkZWZpbmUgRkxBU0hfTUFOVUZBQ1RVUkVSCQkJMHgwMDg5MDA4OQorI2RlZmluZSBGTEFTSF9ERVZJQ0VfOG1iaXRfVE9QCQkweDg4ZjE4OGYxCisjZGVmaW5lIEZMQVNIX0RFVklDRV84bWJpdF9CT1RUT00JMHg4OGYyODhmMgorI2RlZmluZSBGTEFTSF9ERVZJQ0VfMTZtYml0X1RPUAkJMHg4OGYzODhmMworI2RlZmluZSBGTEFTSF9ERVZJQ0VfMTZtYml0X0JPVFRPTQkweDg4ZjQ4OGY0CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKy8qCisgKiBUaGUgZGF0YSBsaW5lIG1hcHBpbmcgb24gTEFSVCBpcyBhcyBmb2xsb3dzOgorICoKKyAqICAgCSBVMiAgQ1BVIHwgICBVMyAgQ1BVCisgKiAgIAkgLS0tLS0tLS0tLS0tLS0tLS0tLQorICogICAJICAwICAyMCAgfCAgIDAgICAxMgorICogICAJICAxICAyMiAgfCAgIDEgICAxNAorICogICAJICAyICAxOSAgfCAgIDIgICAxMQorICogICAJICAzICAxNyAgfCAgIDMgICA5CisgKiAgIAkgIDQgIDI0ICB8ICAgNCAgIDAKKyAqICAgCSAgNSAgMjYgIHwgICA1ICAgMgorICogICAJICA2ICAzMSAgfCAgIDYgICA3CisgKiAgIAkgIDcgIDI5ICB8ICAgNyAgIDUKKyAqICAgCSAgOCAgMjEgIHwgICA4ICAgMTMKKyAqICAgCSAgOSAgMjMgIHwgICA5ICAgMTUKKyAqICAgCSAgMTAgMTggIHwg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ZQlNQVhfQ01EX1NJWkUJCTYKKworI2lmZGVmIENPTkZJR19NMjVQWFhfVVNFX0ZBU1RfUkVBRAorI2RlZmluZSBPUENPREVfUkVBRCAJT1BDT0RFX0ZBU1RfUkVBRAorI2RlZmluZSBGQVNUX1JFQURfRFVNTVlfQllURSAxCisjZWxzZQorI2RlZmluZSBPUENPREVfUkVBRCAJT1BDT0RFX05PUk1fUkVBRAorI2RlZmluZSBGQVNUX1JFQURfRFVNTVlfQllURSAwCisjZW5kaWYKKworI2RlZmluZSBKRURFQ19NRlIoX2plZGVjX2lkKQkoKF9qZWRlY19pZCkgPj4gMTYpCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCitzdHJ1Y3QgbTI1cCB7CisJc3RydWN0IHNwaV9kZXZpY2UJKnNwaTsKKwlzdHJ1Y3QgbXV0ZXgJCWxvY2s7CisJc3RydWN0IG10ZF9pbmZvCQltdGQ7CisJdTE2CQkJcGFnZV9zaXplOworCXUxNgkJCWFkZHJfd2lkdGg7CisJdTgJCQllcmFzZV9vcGNvZGU7CisJdTgJCQkqY29tbWFuZDsKK307CisKK3N0YXRpYyBpbmxpbmUgc3RydWN0IG0yNXAgKm10ZF90b19tMjVwKHN0cnVjdCBtdGRfaW5mbyAqbXRkKQoreworCXJldHVybiBjb250YWluZXJfb2YobXRkLCBzdHJ1Y3QgbTI1cCwgbXRkKTsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKy8qCisgKiBJbnRlcm5hbCBoZWxwZXIgZnVuY3Rpb25zCisgKi8KKworLyoKKyAqIFJlYWQgdGhlIHN0YXR1cyByZWdpc3RlciwgcmV0dXJuaW5nIGl0cyB2YWx1ZSBpbiB0aGUgbG9jYXRpb24KKyAqIFJldHVybiB0aGUgc3RhdHVzIHJlZ2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HApICs9IDI7CisJfQorCXJldHVybiByZXN1bHQ7Cit9CisKK3N0YXRpYyBpbnQgcGFyc2VfbnVtMzIodWludDMyX3QgKm51bTMyLCBjb25zdCBjaGFyICp0b2tlbikKK3sKKwljaGFyICplbmRwOworCXVuc2lnbmVkIGxvbmcgbjsKKworCW4gPSB1c3RydG91bCh0b2tlbiwgJmVuZHAsIDApOworCWlmICgqZW5kcCkKKwkJcmV0dXJuIC1FSU5WQUw7CisKKwkqbnVtMzIgPSBuOworCXJldHVybiAwOworfQorCitzdGF0aWMgaW50IHBhcnNlX25hbWUoY2hhciAqKnBuYW1lLCBjb25zdCBjaGFyICp0b2tlbikKK3sKKwlzaXplX3QgbGVuOworCWNoYXIgKm5hbWU7CisKKwlsZW4gPSBzdHJsZW4odG9rZW4pICsgMTsKKwlpZiAobGVuID4gNjQpCisJCXJldHVybiAtRU5PU1BDOworCisJbmFtZSA9IGttYWxsb2MobGVuLCBHRlBfS0VSTkVMKTsKKwlpZiAoIW5hbWUpCisJCXJldHVybiAtRU5PTUVNOworCisJc3RyY3B5KG5hbWUsIHRva2VuKTsKKworCSpwbmFtZSA9IG5hbWU7CisJcmV0dXJuIDA7Cit9CisKKworc3RhdGljIGlubGluZSB2b2lkIGtpbGxfZmluYWxfbmV3bGluZShjaGFyICpzdHIpCit7CisJY2hhciAqbmV3bGluZSA9IHN0cnJjaHIoc3RyLCAnXG4nKTsKKwlpZiAobmV3bGluZSAmJiAhbmV3bGluZVsxXSkKKwkJKm5ld2xpbmUgPSAwOworfQorCisKKyNkZWZpbmUgcGFyc2VfZXJyKGZtdCwgYXJncy4uLikgZG8gewlcCisJcHJfZXJyKGZtdCAsICMjIGFyZ3MpOwlcCisJcmV0dXJuIDE7CQlcCit9IHdoaWxlICgwKQorCisvKgorICogVGhpcyBzaGFsbCBjb250YWluIHRoZSBtb2R1bGUgcGFyYW1ldGVyIGlmIGFueS4gSXQgaXMgb2YgdGhlIGZvcm06CisgKiAtIHBocmFtPTxkZXZpY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2x1ZGUgPGxpbnV4L210ZC9tdGQuaD4KKy8qI2RlZmluZSBQU1lDSE9fREVCVUcgKi8KKworI2luY2x1ZGUgPGxpbnV4L2tlcm5lbC5oPgorI2luY2x1ZGUgPGxpbnV4L3B0cmFjZS5oPgorI2luY2x1ZGUgPGxpbnV4L3NsYWIuaD4KKyNpbmNsdWRlIDxsaW51eC9zdHJpbmcuaD4KKyNpbmNsdWRlIDxsaW51eC90aW1lci5oPgorI2luY2x1ZGUgPGxpbnV4L21ham9yLmg+CisjaW5jbHVkZSA8bGludXgvZnMuaD4KKyNpbmNsdWRlIDxsaW51eC9pbml0Lmg+CisjaW5jbHVkZSA8bGludXgvaGRyZWcuaD4KKyNpbmNsdWRlIDxsaW51eC92bWFsbG9jLmg+CisjaW5jbHVkZSA8bGludXgvYmxrcGcuaD4KKyNpbmNsdWRlIDxhc20vdWFjY2Vzcy5oPgorCisjaW5jbHVkZSA8bGludXgvbXRkL2Z0bC5oPgorCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworLyogUGFyYW1ldGVycyB0aGF0IGNhbiBiZSBzZXQgd2l0aCAnaW5zbW9kJyAqLworc3RhdGljIGludCBzaHVmZmxlX2ZyZXEgPSA1MDsKK21vZHVsZV9wYXJhbShzaHVmZmxlX2ZyZXEsIGludCwgMCk7CisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCisvKiBNYWpvciBkZXZpY2UgIyBmb3IgRlRMIGRldmljZSAqLworI2lmbmRlZiBGVExfTUFKT1IKKyNkZWZpbmUgRlRMX01BSk9SCTQ0CisjZW5kaWYKKworCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworLyogTWF4aW11bSBudW1iZXIgb2Ygc2VwYXJhdG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AgdWludDE2X3QJCWJhbV9pbmRleDsKKyAgICB1aW50MzJfdAkJKmJhbV9jYWNoZTsKKyAgICB1aW50MTZfdAkJRGF0YVVuaXRzOworICAgIHVpbnQzMl90CQlCbG9ja3NQZXJVbml0OworICAgIGVyYXNlX3VuaXRfaGVhZGVyX3QJaGVhZGVyOworfSBwYXJ0aXRpb25fdDsKKworLyogUGFydGl0aW9uIHN0YXRlIGZsYWdzICovCisjZGVmaW5lIEZUTF9GT1JNQVRURUQJMHgwMQorCisvKiBUcmFuc2ZlciB1bml0IHN0YXRlcyAqLworI2RlZmluZSBYRkVSX1VOS05PV04JMHgwMAorI2RlZmluZSBYRkVSX0VSQVNJTkcJMHgwMQorI2RlZmluZSBYRkVSX0VSQVNFRAkweDAyCisjZGVmaW5lIFhGRVJfUFJFUEFSRUQJMHgwMworI2RlZmluZSBYRkVSX0ZBSUxFRAkweDA0CisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCisKK3N0YXRpYyB2b2lkIGZ0bF9lcmFzZV9jYWxsYmFjayhzdHJ1Y3QgZXJhc2VfaW5mbyAqZG9uZSk7CisKKworLyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisKKyAgICBTY2FuX2hlYWRlcigpIGNoZWNrcyB0byBzZWUgaWYgYSBtZW1vcnkgcmVnaW9uIGNvbnRhaW5zIGFuIEZUTAorICAgIHBhcnRpdGlvbi4gIGJ1aWxkX21hcHMoKSByZWFkcyBhbGwgdGhlIGVyYXNlIHVuaXQgaGVhZGVycywgYnVpbGRzCisgICAgdGhlIGVyYXNlIHVuaXQgbWFwLCBhbmQgdGhlbiBidWlsZHMgdGhlIHZpcnR1YWwgcGFnZSBtYXAuCisKKz09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09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lMzJfdG9fY3B1KHBhcnQtPmJhbV9jYWNoZVtqXSkpIDwgYmxvY2tzKSkKKwkJcGFydC0+VmlydHVhbEJsb2NrTWFwW0JMT0NLX05VTUJFUihsZTMyX3RvX2NwdShwYXJ0LT5iYW1fY2FjaGVbal0pKV0gPQorCQkgICAgKGkgPDwgaGVhZGVyLkVyYXNlVW5pdFNpemUpICsgKGogPDwgaGVhZGVyLkJsb2NrU2l6ZSk7CisJICAgIGVsc2UgaWYgKEJMT0NLX0RFTEVURUQobGUzMl90b19jcHUocGFydC0+YmFtX2NhY2hlW2pdKSkpCisJCXBhcnQtPkVVTkluZm9baV0uRGVsZXRlZCsrOworCX0KKyAgICB9CisKKyAgICByZXQgPSAwOworICAgIGdvdG8gb3V0OworCitvdXRfYmFtX2NhY2hlOgorICAgIGtmcmVlKHBhcnQtPmJhbV9jYWNoZSk7CitvdXRfVmlydHVhbEJsb2NrTWFwOgorICAgIHZmcmVlKHBhcnQtPlZpcnR1YWxCbG9ja01hcCk7CitvdXRfWGZlckluZm86CisgICAga2ZyZWUocGFydC0+WGZlckluZm8pOworb3V0X0VVTkluZm86CisgICAga2ZyZWUocGFydC0+RVVOSW5mbyk7CitvdXQ6CisgICAgcmV0dXJuIHJldDsKK30gLyogYnVpbGRfbWFwcyAqLworCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKworICAgIEVyYXNlX3hmZXIoKSBzY2hlZHVsZXMgYW4gYXN5bmNocm9ub3VzIGVyYXNlIG9wZXJhdGlvbiBmb3IgYQorICAgIHRyYW5zZmVyIHVuaXQuCisKKz09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCitzdGF0aWMgaW50IGVyYXNlX3hmZXIocGFydGl0aW9uX3QgKnBhcnQsCisJCSAgICAgIHVpbnQxNl90IHhmZXJudW0pCit7CisgICAgaW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yYXNlZCB0cmFuc2ZlciB1bml0IGFuZCBnaXZlcworICAgIGl0IGFuIGFwcHJvcHJpYXRlIGhlYWRlci4KKworPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCisKK3N0YXRpYyB2b2lkIGZ0bF9lcmFzZV9jYWxsYmFjayhzdHJ1Y3QgZXJhc2VfaW5mbyAqZXJhc2UpCit7CisgICAgcGFydGl0aW9uX3QgKnBhcnQ7CisgICAgc3RydWN0IHhmZXJfaW5mb190ICp4ZmVyOworICAgIGludCBpOworCisgICAgLyogTG9vayB1cCB0aGUgdHJhbnNmZXIgdW5pdCAqLworICAgIHBhcnQgPSAocGFydGl0aW9uX3QgKikoZXJhc2UtPnByaXYpOworCisgICAgZm9yIChpID0gMDsgaSA8IHBhcnQtPmhlYWRlci5OdW1UcmFuc2ZlclVuaXRzOyBpKyspCisJaWYgKHBhcnQtPlhmZXJJbmZvW2ldLk9mZnNldCA9PSBlcmFzZS0+YWRkcikgYnJlYWs7CisKKyAgICBpZiAoaSA9PSBwYXJ0LT5oZWFkZXIuTnVtVHJhbnNmZXJVbml0cykgeworCXByaW50ayhLRVJOX05PVElDRSAiZnRsX2NzOiBpbnRlcm5hbCBlcnJvcjogIgorCSAgICAgICAiZXJhc2UgbG9va3VwIGZhaWxlZCFcbiIpOworCXJldHVybjsKKyAgICB9CisKKyAgICB4ZmVyID0gJnBhcnQtPlhmZXJJbmZvW2ldOworICAgIGlmIChlcmFzZS0+c3RhdGUgPT0gTVREX0VSQVNFX0RPTkUpCisJeGZlci0+c3RhdGUgPSBYRkVSX0VSQVNFRDsKKyAgICBlbHNlIHsKKwl4ZmVyLT5zdGF0ZSA9IFhGRVJfRkFJTEVEOworCXByaW50ayhLRVJOX05PVElDRSAiZnRsX2NzOiBlcmFzZSBmYWlsZWQ6IHN0YXRlID0gJWRcbiIsCisJICAgICAgIGVyYXNlLT5zdGF0ZSk7CisgICAgfQ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09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworc3RhdGljIGludCBjb3B5X2VyYXNlX3VuaXQocGFydGl0aW9uX3QgKnBhcnQsIHVpbnQxNl90IHNyY3VuaXQsCisJCQkgICB1aW50MTZfdCB4ZmVydW5pdCkKK3sKKyAgICB1X2NoYXIgYnVmW1NFQ1RPUl9TSVpFXTsKKyAgICBzdHJ1Y3QgZXVuX2luZm9fdCAqZXVuOworICAgIHN0cnVjdCB4ZmVyX2luZm9fdCAqeGZlcjsKKyAgICB1aW50MzJfdCBzcmMsIGRlc3QsIGZyZWUsIGk7CisgICAgdWludDE2X3QgdW5pdDsKKyAgICBpbnQgcmV0OworICAgIHNzaXplX3QgcmV0bGVuOworICAgIGxvZmZfdCBvZmZzZXQ7CisgICAgdWludDE2X3Qgc3JjdW5pdHN3YXAgPSBjcHVfdG9fbGUxNihzcmN1bml0KTsKKworICAgIGV1biA9ICZwYXJ0LT5FVU5JbmZvW3NyY3VuaXRdOworICAgIHhmZXIgPSAmcGFydC0+WGZlckluZm9beGZlcnVuaXRdOworICAgIHByX2RlYnVnKCJmdGxfY3M6IGNvcHlpbmcgYmxvY2sgMHgleCB0byAweCV4XG4iLAorCSAgZXVuLT5PZmZzZXQsIHhmZXItPk9mZnNldCk7CisKKworICAgIC8qIFJlYWQgY3VycmVudCBCQU0gKi8KKyAgICBpZiAocGFydC0+YmFtX2luZGV4ICE9IHNyY3VuaXQpIHsKKworCW9mZnNldCA9IGV1bi0+T2Zmc2V0ICsgbGUzMl90b19jcHUocGFydC0+aGVhZGVyLkJBTU9mZnNldCk7CisKKwlyZXQgPSBtdGRfcmVhZChwYXJ0LT5tYmQubXRkLCBvZmZzZXQsCisgICAgICAgICAgICAgICAgICAgICAgIHBhcnQtPkJsb2Nrc1BlclVuaXQgKiBzaXplb2YodWludDMyX3QpLCAmcmV0bGVuLAorICAgICAgICAgICAgICAgICAgICAgICAodV9jaGFyICopKHBhcnQtPmJhbV9jYWNoZSkpOworCisJLyogbWFyayB0aGUgY2FjaGUgYmFkLCBpbiBjYXNlIHdlIGdldCBhbiBlcnJvciBsYXRlciAqLworCXBhcnQtPmJhbV9pbmRleCA9IDB4ZmZmZjsKKworCWlmIChyZXQpIHsKKwkgICAgcHJpbnRrKCBLRVJOX1dBUk5JTkcgImZ0bDogRmFpbGVkIHRvIHJlYWQgQkFNIGNhY2hlIGluIGNvcHlfZXJhc2VfdW5pdCgpIVxuIik7CisJICAgIHJldHVybiByZXQ7CisJfQorICAgIH0KKworICAgIC8qIFdyaXRlIHRoZSBMb2dpY2FsRVVOIGZvciB0aGUgdHJhbnNmZXIgdW5pdCAqLworICAgIHhmZXItPnN0YXRlID0gWEZFUl9VTktOT1dOOworICAgIG9mZnNldCA9IHhmZXItPk9mZnNldCArIDIwOyAvKiBCYWQhICovCisgICAgdW5pdCA9IGNwdV90b19sZTE2KDB4N2ZmZik7CisKKyAgICByZXQgPSBtdGRfd3JpdGUocGFydC0+bWJkLm10ZCwgb2Zmc2V0LCBzaXplb2YodWludDE2X3QpLCAmcmV0bGVuLAorICAgICAgICAgICAgICAgICAgICAodV9jaGFyICopJnVuaXQpOworCisgICAgaWYgKHJldCkgeworCXByaW50ayggS0VSTl9XQVJOSU5HICJmdGw6IEZhaWxlZCB0byB3cml0ZSBiYWNrIHRvIEJBTSBjYWNoZSBpbiBjb3B5X2VyYXNlX3VuaXQoKSFcbiIpOworCXJldHVybiByZXQ7CisgICAgfQorCisgICAgLyogQ29weSBhbGwgZGF0YSBibG9ja3MgZnJvbSBzb3VyY2UgdW5pdCB0byB0cmFuc2ZlciB1bml0ICovCisgICAgc3JjID0gZXVuLT5PZmZzZXQ7IGRlc3QgPSB4ZmVyLT5PZmZzZXQ7CisKKyAgICBmcmVlID0gMDsKKyAgICByZXQgPSAwOworICAgIGZvciAoaSA9IDA7IGkgPCBwYXJ0LT5CbG9ja3NQZXJVbml0OyBpKyspIHsKKwlzd2l0Y2ggKEJMT0NLX1RZUEUobGUzMl90b19jcHUocGFydC0+YmFtX2NhY2hlW2ldKSkpIHsKKwljYXNlIEJMT0NLX0NPTlRST0w6CisJICAgIC8qIFRoaXMgZ2V0cyB1cGRhdGVkIGxhdGVyICovCisJICAgIGJyZWFrOworCWNhc2UgQkxPQ0tfREFUQToKKwljYXNlIEJMT0NLX1JFUExBQ0VNRU5UOgorCSAgICByZXQgPSBtdGRfcmVhZChwYXJ0LT5tYmQubXRkLCBzcmMsIFNFQ1RPUl9TSVpFLCAmcmV0bGVuLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgKHVfY2hhciAqKWJ1Zik7CisJICAgIGlmIChyZXQpIHsKKwkJcHJpbnRrKEtFUk5fV0FSTklORyAiZnRsOiBFcnJvciByZWFkaW5nIG9sZCB4ZmVyIHVuaXQgaW4gY29weV9lcmFzZV91bml0XG4iKTsKKwkJcmV0dXJuIHJldDsKKyAgICAgICAgICAgIH0KKworCisJICAgIHJldCA9IG10ZF93cml0ZShwYXJ0LT5tYmQubXRkLCBkZXN0LCBTRUNUT1JfU0laRSwgJnJldGxlbiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAodV9jaGFyICopYnVmKTsKKwkgICAgaWYgKHJldCkgIHsKKwkJcHJpbnRrKEtFUk5fV0FSTklORyAiZnRsOiBFcnJvciB3cml0aW5nIG5ldyB4ZmVyIHVuaXQgaW4gY29weV9lcmFzZV91bml0XG4iKTsKKwkJcmV0dXJuIHJldDsKKyAgICAgICAgICAgIH0KKworCSAgICBicmVhazsKKwlkZWZhdWx0OgorCSAgICAvKiBBbGwgb3RoZXIgYmxvY2tzIG11c3QgYmUgZnJlZSAqLworCSAgICBwYXJ0LT5iYW1fY2FjaGVbaV0gPSBjcHVfdG9fbGUzMigweGZmZmZmZmZmKTsKKwkgICAgZnJlZSsrOworCSAgICBicmVhazsKKwl9CisJc3JjICs9IFNFQ1RPUl9TSVpFOworCWRlc3QgKz0gU0VDVE9SX1NJWkU7CisgICAgfQorCisgICAgLyogV3JpdGUgdGhlIEJBTSB0byB0aGUgdHJhbnNmZXIgdW5pdCAqLworICAgIHJldCA9IG10ZF93cml0ZShwYXJ0LT5tYmQubXRkLAorICAgICAgICAgICAgICAgICAgICB4ZmVyLT5PZmZzZXQgKyBsZTMyX3RvX2NwdShwYXJ0LT5oZWFkZXIuQkFNT2Zmc2V0KSwKKyAgICAgICAgICAgICAgICAgICAgcGFydC0+QmxvY2tzUGVyVW5pdCAqIHNpemVvZihpbnQzMl90KSwKKyAgICAgICAgICAgICAgICAgICAgJnJldGxlbiwKKyAgICAgICAgICAgICAgICAgICAgKHVfY2hhciAqKXBhcnQtPmJhbV9jYWNoZSk7CisgICAgaWYgKHJldCkgeworCXByaW50ayggS0VSTl9XQVJOSU5HICJmdGw6IEVycm9yIHdyaXRpbmcgQkFNIGluIGNvcHlfZXJhc2VfdW5pdFxuIik7CisJcmV0dXJuIHJldDsKKyAgICB9CisKKworICAgIC8qIEFsbCBjbGVhcj8gVGhlbiB1cGRhdGUgdGhlIExvZ2ljYWxFVU4gYWdhaW4gKi8KKyAgICByZXQgPSBtdGRfd3JpdGUocGFydC0+bWJkLm10ZCwgeGZlci0+T2Zmc2V0ICsgMjAsIHNpemVvZih1aW50MTZfdCksCisgICAgICAgICAgICAgICAgICAgICZyZXRsZW4sICh1X2NoYXIgKikmc3JjdW5pdHN3YXApOworCisgICAgaWYgKHJldCkgeworCXByaW50ayhLRVJOX1dBUk5JTkcgImZ0bDogRXJyb3Igd3JpdGluZyBuZXcgTG9naWNhbEVVTiBpbiBjb3B5X2VyYXNlX3VuaXRcbiIpOworCXJldHVybiByZXQ7CisgICAgfQorCisKKyAgICAvKiBVcGRhdGUgdGhlIG1hcHMgYW5kIHVzYWdlIHN0YXRzKi8KKyAgICBpID0geGZlci0+RXJhc2VDb3VudDsKKyAgICB4ZmVyLT5FcmFzZUNvdW50ID0gZXVuLT5FcmFzZUNvdW50OworICAgIGV1bi0+RXJhc2VDb3VudCA9IGk7CisgICAgaSA9IHhmZ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ICJubyBmcmVlIGJsb2NrcyFcbiIpOworCSAgICBlbHNlCisJCXByX2RlYnVnKCJmdGxfY3M6IHJlY2xhaW0gZmFpbGVkOiAiCisJCSAgICAgICAibm8gZnJlZSBibG9ja3MhXG4iKTsKKworCSAgICByZXR1cm4gLUVJTzsKKwl9CisgICAgfQorICAgIHJldCA9IGNvcHlfZXJhc2VfdW5pdChwYXJ0LCBldW4sIHhmZXIpOworICAgIGlmICghcmV0KQorCWVyYXNlX3hmZXIocGFydCwgeGZlcik7CisgICAgZWxzZQorCXByaW50ayhLRVJOX05PVElDRSAiZnRsX2NzOiBjb3B5X2VyYXNlX3VuaXQgZmFpbGVkIVxuIik7CisgICAgcmV0dXJuIHJldDsKK30gLyogcmVjbGFpbV9ibG9jayAqLworCisvKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKworICAgIEZpbmRfZnJlZSgpIHNlYXJjaGVzIGZvciBhIGZyZWUgYmxvY2suICBJZiBuZWNlc3NhcnksIGl0IHVwZGF0ZXMKKyAgICB0aGUgQkFNIGNhY2hlIGZvciB0aGUgZXJhc2UgdW5pdCBjb250YWluaW5nIHRoZSBmcmVlIGJsb2NrLiAgSXQKKyAgICByZXR1cm5zIHRoZSBibG9jayBpbmRleCAtLSB0aGUgZXJhc2UgdW5pdCBpcyBqdXN0IHRoZSBjdXJyZW50bHkKKyAgICBjYWNoZWQgdW5pdC4gIElmIHRoZXJlIGFyZSBubyBmcmVlIGJsb2NrcywgaXQgcmV0dXJucyAwIC0tIHRoaXMKKyAgICBpcyBuZXZlciBhIHZhbGlkIGRhdGEgYmxvY2sgYmVjYXVzZSBpdCBjb250YWlucyB0aGUgaGVhZGVyLgorCis9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworI2lmZGVmIFBTWUNIT19ERUJVRworc3RhdGljIHZvaWQg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09IDApCisJcmV0dXJuIDA7CisKKyAgICAvKiBJcyB0aGlzIHVuaXQncyBCQU0gY2FjaGVkPyAqLworICAgIGlmIChldW4gIT0gcGFydC0+YmFtX2luZGV4KSB7CisJLyogSW52YWxpZGF0ZSBjYWNoZSAqLworCXBhcnQtPmJhbV9pbmRleCA9IDB4ZmZmZjsKKworCXJldCA9IG10ZF9yZWFkKHBhcnQtPm1iZC5tdGQsCisgICAgICAgICAgICAgICAgICAgICAgIHBhcnQtPkVVTkluZm9bZXVuXS5PZmZzZXQgKyBsZTMyX3RvX2NwdShwYXJ0LT5oZWFkZXIuQkFNT2Zmc2V0KSwKKyAgICAgICAgICAgICAgICAgICAgICAgcGFydC0+QmxvY2tzUGVyVW5pdCAqIHNpemVvZih1aW50MzJfdCksCisgICAgICAgICAgICAgICAgICAgICAgICZyZXRsZW4sCisgICAgICAgICAgICAgICAgICAgICAgICh1X2NoYXIgKikocGFydC0+YmFtX2NhY2hlKSk7CisKKwlpZiAocmV0KSB7CisJICAgIHByaW50ayhLRVJOX1dBUk5JTkciZnRsOiBFcnJvciByZWFkaW5nIEJBTSBpbiBmaW5kX2ZyZWVcbiIpOworCSAgICByZXR1cm4gMDsKKwl9CisJcGFydC0+YmFtX2luZGV4ID0gZXVuOworICAgIH0KKworICAgIC8qIEZpbmQgYSBmcmVlIGJsb2NrICovCisgICAgZm9yIChibGsgPSAwOyBibGsgPCBwYXJ0LT5CbG9ja3NQZXJVbml0OyBibGsrKykKKwlpZiAoQkxPQ0tfRlJFRShsZTMyX3RvX2NwdShwYXJ0LT5iYW1fY2FjaGVbYmxrXSkpKSBicmVhazsKKyAgICBpZiAoYmxrID09IHBhcnQtPkJsb2Nrc1BlclVuaXQpIHsKKyNpZmRlZiBQU1lDSE9fREVCVUcKKwlzdGF0aWMgaW50IG5lID0gMDsKKwlpZiAoKytuZSA9PSAxKQorCSAgICBkdW1wX2xpc3RzKHBhcnQpOworI2VuZGlmCisJcHJpbnRrKEtFUk5fTk9USUNFICJmdGxfY3M6IGJhZCBmcmVlIGxpc3QhXG4iKTsKKwlyZXR1cm4gMDsKKyAgICB9CisgICAgcHJfZGVidWcoImZ0bF9jczogZm91bmQgZnJlZSBibG9jayBhdCAlZCBpbiAlZFxuIiwgYmxrLCBldW4pOworICAgIHJldHVybiBibGs7CisKK30gLyogZmluZF9mcmVlICovCisKKworLyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisKKyAgICBSZWFkIGEgc2VyaWVzIG9mIHNlY3RvcnMgZnJvbSBhbiBGVEwgcGFydGl0aW9uLgorCis9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ki8KKworc3RhdGljIGludCBmdGxfcmVhZChwYXJ0aXRpb25fdCAqcGFydCwgY2FkZHJfdCBidWZmZXIsCisJCSAgICB1X2xvbmcgc2VjdG9yLCB1X2xvbmcgbmJsb2NrcykKK3sKKyAgICB1aW50MzJfdCBsb2dfYWRkciwgYnNpemU7CisgICAgdV9sb25nIGk7CisgICAgaW50IHJldDsKKyAgICBzaXplX3Qgb2Zmc2V0LCByZXRsZW47CisKKyAgICBwcl9kZWJ1ZygiZnRsX2NzOiBmdGxfcmVhZCgweCVwLCAweCVseCwgJWxkKVxuIiwKKwkgIHBhcnQsIHNlY3RvciwgbmJsb2Nrcyk7CisgICAgaWYgKCEocGFydC0+c3RhdGUgJiBGVExfRk9STUFUVEVEKSkgeworCXByaW50ayhLRVJOX05PVElDRSAiZnRsX2NzOiBiYWQgcGFydGl0aW9uXG4iKTsKKwlyZXR1cm4gLUVJTzsKKyAgICB9CisgICAgYnNpemUgPSAxIDw8IHBhcnQtPmhlYWRlci5FcmFzZVVuaXRTaXplOworCisgICAgZm9yIChpID0gMDsgaSA8IG5ibG9ja3M7IGkrKykgeworCWlmICgoKHNlY3RvcitpKSAqIFNFQ1RPUl9TSVpFKSA+PSBsZTMyX3RvX2NwdShwYXJ0LT5oZWFkZXIuRm9ybWF0dGVkU2l6ZSkpIHsKKwkgICAgcHJpbnRrKEtFUk5fTk9USUNFICJmdGxfY3M6IGJhZCByZWFkIG9mZnNldFxuIik7CisJICAgIHJldHVybiAtRUlPOworCX0KKwlsb2dfYWRkciA9IHBhcnQtPlZpcnR1YWxCbG9ja01hcFtzZWN0b3IraV07CisJaWYgKGxvZ19hZGRyID09IDB4ZmZmZmZmZmYpCisJICAgIG1lbXNldChidWZmZXIsIDAsIFNFQ1RPUl9TSVpFKTsKKwllbHNlIHsKKwkgICAgb2Zmc2V0ID0gKHBhcnQtPkVVTkluZm9bbG9nX2FkZHIgLyBic2l6ZV0uT2Zmc2V0CisJCQkgICsgKGxvZ19hZGRyICUgYnNpemUpKTsKKwkgICAgcmV0ID0gbXRkX3JlYWQocGFydC0+bWJkLm10ZCwgb2Zmc2V0LCBTRUNUT1JfU0laRSwgJnJldGxlbiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICh1X2NoYXIgKilidWZmZXIpOworCisJICAgIGlmIChyZXQpIHsKKwkJcHJpbnRrKEtFUk5fV0FSTklORyAiRXJyb3IgcmVhZGluZyBNVEQgZGV2aWNlIGluIGZ0bF9yZWFkKClcbiIpOworCQlyZXR1cm4gcmV0OworCSAgICB9CisJfQorCWJ1ZmZlciArPSBTRUNUT1JfU0laRTsKKyAgICB9CisgICAgcmV0dXJuIDA7Cit9IC8qIGZ0bF9yZWFkICovCisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorCisgICAgV3JpdGUgYSBzZXJpZXMgb2Ygc2VjdG9ycyB0byBhbiBGVEwgcGFydGl0aW9uCisKKz09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCitzdGF0aWMgaW50IHNldF9iYW1fZW50cnkocGFydGl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dXJuIDA7Cit9CisKK3N0YXRpYyBpbnQgbHBkZHJfZXJhc2Uoc3RydWN0IG10ZF9pbmZvICptdGQsIHN0cnVjdCBlcmFzZV9pbmZvICppbnN0cikKK3sKKwl1bnNpZ25lZCBsb25nIG9mcywgbGVuOworCWludCByZXQ7CisJc3RydWN0IG1hcF9pbmZvICptYXAgPSBtdGQtPnByaXY7CisJc3RydWN0IGxwZGRyX3ByaXZhdGUgKmxwZGRyID0gbWFwLT5mbGRydl9wcml2OworCWludCBzaXplID0gMSA8PCBscGRkci0+cWluZm8tPlVuaWZvcm1CbG9ja1NpemVTaGlmdDsKKworCW9mcyA9IGluc3RyLT5hZGRyOworCWxlbiA9IGluc3RyLT5sZW47CisKKwl3aGlsZSAobGVuID4gMCkgeworCQlyZXQgPSBkb19lcmFzZV9vbmVibG9jayhtdGQsIG9mcyk7CisJCWlmIChyZXQpCisJCQlyZXR1cm4gcmV0OworCQlvZnMgKz0gc2l6ZTsKKwkJbGVuIC09IHNpemU7CisJfQorCWluc3RyLT5zdGF0ZSA9IE1URF9FUkFTRV9ET05FOworCW10ZF9lcmFzZV9jYWxsYmFjayhpbnN0cik7CisKKwlyZXR1cm4gMDsKK30KKworI2RlZmluZSBET19YWExPQ0tfTE9DSwkJMQorI2RlZmluZSBET19YWExPQ0tfVU5MT0NLCTIKK2ludCBkb194eGxvY2soc3RydWN0IG10ZF9pbmZvICptdGQsIGxvZmZfdCBhZHIsIHVpbnQzMl90IGxlbiwgaW50IHRodW5rKQoreworCWludCByZXQgPSAwOworCXN0cnVjdCBtYXBfaW5mbyAqbWFwID0gbXRkLT5wcml2OworCXN0cnVjdCBscGRkcl9wcml2YXRlICpscGRkciA9IG1hcC0+ZmxkcnZfcHJpdjsKKwlpbnQgY2hpcG51bSA9IGFkciA+PiBscGRkci0+Y2hpcHNoaWZ0OworCXN0cnVjdCBmbGNoaXAgKmNoaXAgPSAmbHBkZHItPmNoaXBzW2NoaXBudW1dOworCisJbXV0ZXhfbG9jayg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oQ09ORklHX01URF9EQzIxMjg1KQkrPSBkYzIxMjg1Lm8KK29iai0kKENPTkZJR19NVERfRElMTkVUUEMpCSs9IGRpbG5ldHBjLm8KK29iai0kKENPTkZJR19NVERfTDQ0MEdYKQkrPSBsNDQwZ3gubworb2JqLSQoQ09ORklHX01URF9BTUQ3NlhST00pCSs9IGFtZDc2eHJvbS5vCitvYmotJChDT05GSUdfTVREX0VTQjJST00pCSs9IGVzYjJyb20ubworb2JqLSQoQ09ORklHX01URF9JQ0hYUk9NKQkrPSBpY2h4cm9tLm8KK29iai0kKENPTkZJR19NVERfQ0s4MDRYUk9NKQkrPSBjazgwNHhyb20ubworb2JqLSQoQ09ORklHX01URF9UU1VOQU1JKQkrPSB0c3VuYW1pX2ZsYXNoLm8KK29iai0kKENPTkZJR19NVERfUFhBMlhYKQkrPSBweGEyeHgtZmxhc2gubworb2JqLSQoQ09ORklHX01URF9NQlg4NjApCSs9IG1ieDg2MC5vCitvYmotJChDT05GSUdfTVREX09DVEFHT04pCSs9IG9jdGFnb24tNTA2Ni5vCitvYmotJChDT05GSUdfTVREX1BIWVNNQVApCSs9IHBoeXNtYXAubworb2JqLSQoQ09ORklHX01URF9QSFlTTUFQX09GKQkrPSBwaHlzbWFwX29mLm8KK29iai0kKENPTkZJR19NVERfUElTTU8pCQkrPSBwaXNtby5vCitvYmotJChDT05GSUdfTVREX1BNQ19NU1BfRVZNKSAgICs9IHBtY21zcC1mbGFzaC5vCitvYmotJChDT05GSUdfTVREX1BDTUNJQSkJKz0gcGNtY2lhbXRkLm8KK29iai0kKENPTkZJR19NVERfUlBYTElURSkJKz0gcnB4bGl0ZS5vCitvYmotJChDT05GSUdfTVREX1RRTThYWEwpCSs9IHRxbTh4eGwubworb2JqLSQoQ09ORklHX01URF9TQTExMDApCSs9IHNhMTEwMC1mbGFzaC5vCitvYmotJChDT05GSUdfTVREX1NCQ19HWFgpCSs9IHNiY19neHgubworb2JqLSQoQ09ORklHX01URF9TQzUyMENEUCkJKz0gc2M1MjBjZHAubworb2JqLSQoQ09ORklHX01URF9ORVRTQzUyMCkJKz0gbmV0c2M1MjAubworb2JqLSQoQ09ORklHX01URF9UUzU1MDApCSs9IHRzNTUwMF9mbGFzaC5vCitvYmotJChDT05GSUdfTVREX1NVTl9VRkxBU0gpCSs9IHN1bl91Zmxhc2gubworb2JqLSQoQ09ORklHX01URF9WTUFYKQkJKz0gdm1heDMwMS5vCitvYmotJChDT05GSUdfTVREX1NDeDIwMF9ET0NGTEFTSCkrPSBzY3gyMDBfZG9jZmxhc2gubworb2JqLSQoQ09ORklHX01URF9EQk9YMikJCSs9IGRib3gyLWZsYXNoLm8KK29iai0kKENPTkZJR19NVERfU09MVVRJT05FTkdJTkUpKz0gc29sdXRpb25lbmdpbmUubworb2JqLSQoQ09ORklHX01URF9QQ0kpCQkrPSBwY2kubworb2JqLSQoQ09ORklHX01URF9BVVRDUFUxMikJKz0gYXV0Y3B1MTItbnZyYW0ubworb2JqLSQoQ09ORklHX01URF9JTVBBNykJCSs9IGltcGE3Lm8KK29iai0kKENPTkZJR19NVERfRk9SVFVORVQpCSs9IGZvcnR1bmV0Lm8KK29iai0kKENPTkZJR19NVERfVUNMSU5VWCkJKz0gdWNsaW51eC5vCitvYmotJChDT05GSUdfTVREX05FVHRlbCkJKz0gbmV0dGVsLm8KK29iai0kKENPTkZJR19NVERfU0NCMl9GTEFTSCkJKz0gc2NiMl9mbGFzaC5vCitvYmotJChDT05GSUdfTVREX0g3MjBYKQkJKz0gaDcyMHgtZmxhc2gubworb2JqLSQoQ09ORklHX01URF9JWFA0WFgpCSs9IGl4cDR4eC5vCitvYmotJChDT05GSUdfTVREX0lYUDIwMDApCSs9IGl4cDIwMDAubworb2JqLSQoQ09ORklHX01URF9XUlNCQzgyNjApCSs9IHdyX3NiYzgyeHhfZmxhc2gubworb2JqLSQoQ09ORklHX01URF9ETVYxODIpCSs9IGRtdjE4Mi5vCitvYmotJChDT05GSUdfTVREX1BMQVRSQU0pCSs9IHBs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IFNldHVwIGFuZCBDb250cm9sIChDU0MpCisqKiBhbmQgUEMgQ2FyZCAoUENDKSBpbmRleGVkIHJlZ2lzdGVyczoKKyovCitzdGF0aWMgaW5saW5lIHZvaWQgc2V0Y3NjKGludCByZWcsIHVuc2lnbmVkIGNoYXIgZGF0YSkKK3sKKwlvdXRiKHJlZywgQ1NDX0lOREVYKTsKKwlvdXRiKGRhdGEsIENTQ19EQVRBKTsKK30KKworc3RhdGljIGlubGluZSB1bnNpZ25lZCBjaGFyIGdldGNzYyhpbnQgcmVnKQoreworCW91dGIocmVnLCBDU0NfSU5ERVgpOworCXJldHVybihpbmIoQ1NDX0RBVEEpKTsKK30KKworc3RhdGljIGlubGluZSB2b2lkIHNldHBjYyhpbnQgcmVnLCB1bnNpZ25lZCBjaGFyIGRhdGEpCit7CisJb3V0YihyZWcsIFBDQ19JTkRFWCk7CisJb3V0YihkYXRhLCBQQ0NfREFUQSk7Cit9CisKK3N0YXRpYyBpbmxpbmUgdW5zaWduZWQgY2hhciBnZXRwY2MoaW50IHJlZykKK3sKKwlvdXRiKHJlZywgUENDX0lOREVYKTsKKwlyZXR1cm4oaW5iKFBDQ19EQVRBKSk7Cit9CisKKworLyoKKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorKiogRW5hYmxlIGFjY2VzcyB0byBESUwvTmV0UEMncyBmbGFzaCBieSBtYXBwaW5nIGl0IGludG8KKyoqIHRoZSBTQzR4MCdzIE1NUyBXaW5kb3cgQy4KKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorKi8KK3N0YXRpYyB2b2lkIGRucGNfbWFwX2ZsYXNoKHVuc2lnbmVkIGxvbmcgZmxhc2hfYmFzZSwgdW5zaWduZWQgbG9uZyBmbGFzaF9zaXplKQoreworCXVuc2lnbmVkIGxvbmcgZmxhc2hfZW5kID0gZmxhc2hfYmFzZSArIGZsYX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9CKSAmIH4weDAyKTsKKworCS8qIG5vdyBkaXNhYmxlIFBDIENhcmQgaW5kZXhlZCByZWdpc3RlciBzcGFjZSBhZ2FpbiAqLworCXNldGNzYyhDU0NfQ1IsIGdldGNzYyhDU0NfQ1IpICYgfjB4Mik7Cit9CisKKworCisvKgorKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisqKiBFbmFibGUvRGlzYWJsZSBWUFAgdG8gd3JpdGUgdG8gZmxhc2gKKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorKi8KKworc3RhdGljIERFRklORV9TUElOTE9DSyhkbnBjX3NwaW4pOworc3RhdGljIGludCAgICAgICAgdnBwX2NvdW50ZXIgPSAwOworLyoKKyoqIFRoaXMgaXMgd2hhdCBoYXMgdG8gYmUgZG9uZSBmb3IgdGhlIEROUCBib2FyZCAuLgorKi8KK3N0YXRpYyB2b2lkIGRucF9zZXRfdnBwKHN0cnVjdCBtYXBfaW5mbyAqbm90X3VzZWQsIGludCBvbikKK3sKKwlzcGluX2xvY2tfaXJxKCZkbnBjX3NwaW4pOworCisJaWYgKG9uKQorCXsKKwkJaWYoKyt2cHBfY291bnRlciA9PSAxKQorCQkJc2V0Y3NjKENTQ19SQldSLCBnZXRjc2MoQ1NDX1JCV1IpICYgfjB4NCk7CisJfQorCWVsc2UKKwl7CisJCWlmKC0tdnBwX2NvdW50ZXIgPT0gMCkKKwkJCXNldGNzYyhDU0NfUkJXUiwgZ2V0Y3NjKENTQ19SQldSKSB8IDB4NCk7CisJCWVsc2UKKwkJCUJVR19PTih2cHBfY291bnRlciA8IDApOworCX0KKwlzcGluX3VubG9ja19pcnEoJmRucGNfc3Bpbik7Cit9CisKKy8qCisqKiAuLiBhbmQgdGhpcyB0aGUgQUROUCB2ZXJzaW9uOgorKi8KK3N0YXRpYyB2b2lkIGFkbnBfc2V0X3ZwcChzdHJ1Y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REX1dSSVRFQUJMRQorICAgICAgICB9LHsKKyAgICAgICAgICAgICAgICAubmFtZSA9ICJFbnYiLAorICAgICAgICAgICAgICAgIC5zaXplID0gMHgwMDA0MDAwMCwKKyAgICAgICAgICAgICAgICAub2Zmc2V0ID0gMHgwMDA4MDAwMCwKKyAgICAgICAgICAgICAgICAubWFza19mbGFncyA9IE1URF9XUklURUFCTEUKKyAgICAgICAgfSx7CisgICAgICAgICAgICAgICAgLm5hbWUgPSAiS2VybmVsIiwKKyAgICAgICAgICAgICAgICAuc2l6ZSA9IDB4MDAxODAwMDAsCisgICAgICAgICAgICAgICAgLm9mZnNldCA9IDB4MDAwYzAwMDAsCisgICAgICAgICAgICAgICAgLm1hc2tfZmxhZ3MgPSBNVERfV1JJVEVBQkxFCisgICAgICAgIH0seworICAgICAgICAgICAgICAgIC5uYW1lID0gIlJhbWRpc2siLAorICAgICAgICAgICAgICAgIC5zaXplID0gMHgwMDQwMDAwMCwKKyAgICAgICAgICAgICAgICAub2Zmc2V0ID0gMHgwMDI0MDAwMCwKKyAgICAgICAgICAgICAgICAubWFza19mbGFncyA9IE1URF9XUklURUFCTEUKKyAgICAgICAgfSx7CisgICAgICAgICAgICAgICAgLm5hbWUgPSAiamZmczIiLAorICAgICAgICAgICAgICAgIC5zaXplID0gTVREUEFSVF9TSVpfRlVMTCwKKyAgICAgICAgICAgICAgICAub2Zmc2V0ID0gTVREUEFSVF9PRlNfQVBQRU5ECisgICAgICAgIH0KK307CisKKyNkZWZpbmUgTlVNX1BBUlRJVElPTlMgQVJSQVlfU0laRShoNzIweF9wYXJ0aXRpb25zKQorCisvKgorICogSW5pdGlhbGl6ZSBGTEFTSCBzdXBwb3J0CisgKi8KK3N0YXRpYyBpbnQgX19pbml0IGg3MjB4X210ZF9pbml0KHZvaWQpCit7CisJaDcyMHhfbWFwLnZpcnQgPSBpb3JlbWFwKGg3MjB4X21hcC5waHlzLCBoNzIweF9tYXAuc2l6ZSk7CisKKwlpZiAoIWg3MjB4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IGluaXRfbWJ4KHZvaWQpCit7CisJcHJpbnRrKEtFUk5fTk9USUNFICJNb3Rvcm9sYSBNQlggZmxhc2ggZGV2aWNlOiAweCV4IGF0IDB4JXhcbiIsIFdJTkRPV19TSVpFKjQsIFdJTkRPV19BRERSKTsKKwltYnhfbWFwLnZpcnQgPSBpb3JlbWFwKFdJTkRPV19BRERSLCBXSU5ET1dfU0laRSAqIDQpOworCisJaWYgKCFtYnhfbWFwLnZpcnQpIHsKKwkJcHJpbnRrKCJGYWlsZWQgdG8gaW9yZW1hcFxuIik7CisJCXJldHVybiAtRUlPOworCX0KKwlzaW1wbGVfbWFwX2luaXQoJm1ieF9tYXApOworCisJbXltdGQgPSBkb19tYXBfcHJvYmUoImplZGVjX3Byb2JlIiwgJm1ieF9tYXApOworCWlmIChteW10ZCkgeworCQlteW10ZC0+b3duZXIgPSBUSElTX01PRFVMRTsKKwkJbXRkX2RldmljZV9yZWdpc3RlcihteW10ZCwgTlVMTCwgMCk7CisJCW10ZF9kZXZpY2VfcmVnaXN0ZXIobXltdGQsIHBhcnRpdGlvbl9pbmZvLCBOVU1fUEFSVElUSU9OUyk7CisJCXJldHVybiAwOworCX0KKworCWlvdW5tYXAoKHZvaWQgKiltYnhfbWFwLnZpcnQpOworCXJldHVybiAtRU5YSU87Cit9CisKK3N0YXRpYyB2b2lkIF9fZXhpdCBjbGVhbnVwX21ieCh2b2lkKQoreworCWlmIChteW10ZCkgeworCQltdGRfZGV2aWNlX3VucmVnaXN0ZXIobXltdGQpOworCQltYXBfZGVzdHJveShteW10ZCk7CisJfQorCWlmIChtYnhfbWFwLnZpcnQpIHsKKwkJaW91bm1hcCgodm9pZCAqKW1ieF9tYXAudmlydCk7CisJCW1ieF9tYXAudmlydCA9IDA7CisJfQorfQorCittb2R1bGVfaW5pdChpbml0X21ieCk7Cittb2R1bGVfZXhpdChjbGVhbnVwX21ieCk7CisKK01PRFVMRV9BVVRIT1IoIkFudG9uIFRvZG9yb3YgPGEudG9kb3Jv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ZXJzL210ZC9tYXBzL25ldHRlbC5jCkBAIC0wLDAgKzEsNDU0IEBACisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyoKKyAqICAgICAgbmV0dGVsLmMgLS0gbWFwcGluZ3MgZm9yIE5FVHRlbC9TZWN1cmVFZGdlL1NuYXBHZWFyICh4ODYpIGJvYXJkcy4KKyAqCisgKiAgICAgIChDKSBDb3B5cmlnaHQgMjAwMC0yMDAxLCBHcmVnIFVuZ2VyZXIgKGdlcmdAc25hcGdlYXIuY29tKQorICogICAgICAoQykgQ29weXJpZ2h0IDIwMDEtMjAwMiwgU25hcEdlYXIgKHd3dy5zbmFwZ2Vhci5jb20pCisgKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKyNpbmNsdWRlIDxsaW51eC9tb2R1bGUuaD4KKyNpbmNsdWRlIDxsaW51eC9pbml0Lmg+CisjaW5jbHVkZSA8bGludXgvdHlwZXMuaD4KKyNpbmNsdWRlIDxsaW51eC9rZXJuZWwuaD4KKyNpbmNsdWRlIDxsaW51eC9tdGQvbXRkLmg+CisjaW5jbHVkZSA8bGludXgvbXRkL21hcC5oPgorI2luY2x1ZGUgPGxpbnV4L210ZC9wYXJ0aXRpb25zLmg+CisjaW5jbHVkZSA8bGludXgvbXRkL2NmaS5oPgorI2luY2x1ZGUgPGxpbnV4L3JlYm9vdC5oPgorI2luY2x1ZGUgPGxpbnV4L2Vyci5oPgorI2luY2x1ZGUgPGxpbnV4L2tkZXZfdC5oPgorI2luY2x1ZGUgPGxpbnV4L3Jvb3RfZGV2Lmg+CisjaW5jbHVkZSA8YXNtL2lvLmg+CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworC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GFnZSAqLworCitzdGF0aWMgdm9pZCAqbmV0dGVsX21tY3JwID0gTlVMTDsKKworI2lmZGVmIENPTkZJR19NVERfQ0ZJX0lOVEVMRVhUCitzdGF0aWMgc3RydWN0IG10ZF9pbmZvICppbnRlbF9tdGQ7CisjZW5kaWYKK3N0YXRpYyBzdHJ1Y3QgbXRkX2luZm8gKmFtZF9tdGQ7CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworI2lmZGVmIENPTkZJR19NVERfQ0ZJX0lOVEVMRVhUCitzdGF0aWMgc3RydWN0IG1hcF9pbmZvIG5ldHRlbF9pbnRlbF9tYXAgPSB7CisJLm5hbWUgPSAiU25hcEdlYXIgSW50ZWwiLAorCS5zaXplID0gMCwKKwkuYmFua3dpZHRoID0gSU5URUxfQlVTV0lEVEgsCit9OworCitzdGF0aWMgc3RydWN0IG10ZF9wYXJ0aXRpb24gbmV0dGVsX2ludGVsX3BhcnRpdGlvbnNbXSA9IHsKKwl7CisJCS5uYW1lID0gIlNuYXBHZWFyIGtlcm5lbCIsCisJCS5vZmZzZXQgPSAwLAorCQkuc2l6ZSA9IDB4MDAwZTAwMDAKKwl9LAorCXsKKwkJLm5hbWUgPSAiU25hcEdlYXIgZmlsZXN5c3RlbSIsCisJCS5vZmZzZXQgPSAweDAwMTAwMDAwLAorCX0sCisJeworCQkubmFtZSA9ICJTbmFwR2VhciBjb25maWciLAorCQkub2Zmc2V0ID0gMHgwMDBlMDAwMCwKKwkJLnNpemUgPSAweDAwMDIwMDAwCisJfSwKKwl7CisJCS5uYW1lID0gIlNuYXBHZWFyIEludGVsIiwKKwkJLm9mZnNldCA9IDAKKwl9LAorCXsKKwkJLm5hbWUgPSAiU25hcEdlYXIgQklPUyBD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QkJCSBudW1fYW1kX3BhcnRpdGlvbnMpOworCX0KKworI2lmZGVmIENPTkZJR19NVERfQ0ZJX0lOVEVMRVhUCisJcmVnaXN0ZXJfcmVib290X25vdGlmaWVyKCZuZXR0ZWxfbm90aWZpZXJfYmxvY2spOworI2VuZGlmCisKKwlyZXR1cm4ocmMpOworCisjaWZkZWYgQ09ORklHX01URF9DRklfSU5URUxFWFQKK291dF91bm1hcDE6CisJaW91bm1hcChuZXR0ZWxfaW50ZWxfbWFwLnZpcnQpOworI2VuZGlmCisKK291dF91bm1hcDI6CisJaW91bm1hcChuZXR0ZWxfbW1jcnApOworCWlvdW5tYXAobmV0dGVsX2FtZF9tYXAudmlydCk7CisKKwlyZXR1cm4ocmMpOworCit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCitzdGF0aWMgdm9pZCBfX2V4aXQgbmV0dGVsX2NsZWFudXAodm9pZCkKK3sKKyNpZmRlZiBDT05GSUdfTVREX0NGSV9JTlRFTEVYVAorCXVucmVnaXN0ZXJfcmVib290X25vdGlmaWVyKCZuZXR0ZWxfbm90aWZpZXJfYmxvY2spOworI2VuZGlmCisJaWYgKGFtZF9tdGQpIHsKKwkJbXRkX2RldmljZV91bnJlZ2lzdGVyKGFtZF9tdGQpOworCQltYXBfZGVzdHJveShhbWRfbXRkKTsKKwl9CisJaWYgKG5ldHRlbF9tbWNycCkgeworCQlpb3VubWFwKG5ldHRlbF9tbWNycCk7CisJCW5ldHRlbF9tbWNycCA9IE5VTEw7CisJfQorCWlmIChuZXR0ZWxfYW1kX21hcC52aXJ0KSB7CisJCWlvdW5tYXAobmV0dGVsX2FtZF9tYXAudmlydCk7CisJCW5ldHRlbF9hbWRfbWFwLnZpcnQgPSBOVUxMOworCX0KKyNpZmRlZiBDT05GSUdfTVREX0NGSV9JTlRFTEVYVAorCWlmIChpbnRlbF9tdGQpIHsKKwkJbXRkX2RldmljZV91bnJlZ2lzdGVyKGludGVsX210ZCk7CisJCW1hcF9kZXN0cm95KGludGVsX210ZCk7CisJfQorCWlmIChuZXR0ZWxfaW50ZWxfbWFwLnZpcnQpIHsKKwkJaW91bm1hcChuZXR0ZWxfaW50ZWxfbWFwLnZpcnQpOworCQluZXR0ZWxfaW50ZWxfbWFwLnZpcnQgPSBOVUxMOworCX0KKyNlbmRpZgorfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworbW9kdWxlX2luaXQobmV0dGVsX2luaXQpOworbW9kdWxlX2V4aXQobmV0dGVsX2NsZWFudXApOworCitNT0RVTEVfTElDRU5TRSgiR1BMIik7CitNT0RVTEVfQVVUSE9SKCJHcmVnIFVuZ2VyZXIgPGdlcmdAc25hcGdlYXIuY29tPiIpOworTU9EVUxFX0RFU0NSSVBUSU9OKCJTbmFwR2Vhci9TZWN1cmVFZGdlIEZMQVNIIHN1cHBvcnQiKTsKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCmRpZmYgLS1naXQgYS9hcC9vcy9saW51eC9saW51eC0zLjQueC9kcml2ZXJzL210ZC9tYXBzL29jdGFnb24tNTA2Ni5jIGIvYXAvb3MvbGludXgvbGludXgtMy40LngvZHJpdmVycy9tdGQvbWFwcy9vY3RhZ29uLTUwNjYuYwpuZXcgZmlsZSBtb2RlIDEwMDY0NAppbmRleCAwMDAwMDAwLi44MDdhYzJhCi0tLSAvZGV2L251bGwKKysrIGIvYXAvb3MvbGludXgvbGludXgtMy40LngvZHJpdmVycy9tdGQvbWFwcy9vY3RhZ29uLTUwNjYuYwpAQCAtMCwwICsxLDI0NiBAQAorLyogIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyM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BkZXZpY2Vfbm9kZSAqZHApCit7CisJY29uc3QgY2hhciAqY3A7CisJaW50IGNwbGVuOworCXVuc2lnbmVkIGludCBsOworCXVuc2lnbmVkIGludCBjb3VudDsKKwljb25zdCBjaGFyICoqcmVzOworCisJY3AgPSBvZl9nZXRfcHJvcGVydHkoZHAsICJsaW51eCxwYXJ0LXByb2JlIiwgJmNwbGVuKTsKKwlpZiAoY3AgPT0gTlVMTCkKKwkJcmV0dXJuIHBhcnRfcHJvYmVfdHlwZXNfZGVmOworCisJY291bnQgPSAwOworCWZvciAobCA9IDA7IGwgIT0gY3BsZW47IGwrKykKKwkJaWYgKGNwW2xdID09IDApCisJCQljb3VudCsrOworCisJcmVzID0ga3phbGxvYygoY291bnQgKyAxKSpzaXplb2YoKnJlcyksIEdGUF9LRVJORUwpOworCWNvdW50ID0gMDsKKwl3aGlsZSAoY3BsZW4gPiAwKSB7CisJCXJlc1tjb3VudF0gPSBjcDsKKwkJbCA9IHN0cmxlbihjcCkgKyAxOworCQljcCArPSBsOworCQljcGxlbiAtPSBsOworCQljb3VudCsrOworCX0KKwlyZXR1cm4gcmVzOworfQorCitzdGF0aWMgdm9pZCBfX2RldmluaXQgb2ZfZnJlZV9wcm9iZXMoY29uc3QgY2hhciAqKnByb2JlcykKK3sKKwlpZiAocHJvYmVzICE9IHBhcnRfcHJvYmVfdHlwZXNfZGVmKQorCQlrZnJlZShwcm9iZXMpOworfQorCitzdGF0aWMgc3RydWN0IG9mX2RldmljZV9pZCBvZl9mbGFzaF9tYXRjaFtdOworc3RhdGljIGludCBfX2RldmluaXQgb2ZfZmxhc2hfcHJvYmUoc3RydWN0IHBsYXRmb3JtX2RldmljZSAqZGV2KQoreworCWNvbnN0IGNoYXIgKipwYXJ0X3Byb2JlX3R5cGVzOworCWNvbnN0IHN0cnVjdCBvZl9kZXZpY2VfaWQgKm1hdGNoOworCXN0cnVjdCBkZXZpY2Vfbm9kZSAqZHAgPSBkZXYtPmRldi5vZl9ub2RlOworCXN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saW51eC9tdGQvbWFwLmg+CisKKworI2RlZmluZSBXSU5ET1dfQUREUiAweGZlMDAwMDAwCisjZGVmaW5lIFdJTkRPV19TSVpFIDB4ODAwMDAwCisKK3N0YXRpYyBzdHJ1Y3QgbXRkX2luZm8gKm15bXRkOworCitzdGF0aWMgc3RydWN0IG1hcF9pbmZvIHJweGxpdGVfbWFwID0geworCS5uYW1lID0gIlJQWCIsCisJLnNpemUgPSBXSU5ET1dfU0laRSwKKwkuYmFua3dpZHRoID0gNCwKKwkucGh5cyA9IFdJTkRPV19BRERSLAorfTsKKworc3RhdGljIGludCBfX2luaXQgaW5pdF9ycHhsaXRlKHZvaWQpCit7CisJcHJpbnRrKEtFUk5fTk9USUNFICJSUFggTGl0ZSBvciBDTExGIGZsYXNoIGRldmljZTogJXggYXQgJXhcbiIsIFdJTkRPV19TSVpFKjQsIFdJTkRPV19BRERSKTsKKwlycHhsaXRlX21hcC52aXJ0ID0gaW9yZW1hcChXSU5ET1dfQUREUiwgV0lORE9XX1NJWkUgKiA0KTsKKworCWlmICghcnB4bGl0ZV9tYXAudmlydCkgeworCQlwcmludGsoIkZhaWxlZCB0byBpb3JlbWFwXG4iKTsKKwkJcmV0dXJuIC1FSU87CisJfQorCXNpbXBsZV9tYXBfaW5pdCgmcnB4bGl0ZV9tYXApOworCW15bXRkID0gZG9fbWFwX3Byb2JlKCJjZmlfcHJvYmUiLCAmcnB4bGl0ZV9tYXApOworCWlmIChteW10ZCkgeworCQlteW10ZC0+b3duZXIgPSBUSElTX01PRFVMRTsKKwkJbXRkX2RldmljZV9yZWdpc3RlcihteW10ZCwgTlVMTCwgMCk7CisJCXJldHVybiAwOworCX0KKworCWlvdW5tYXAoKHZvaWQgKilycHhsaXRlX21hcC52aXJ0KTsKKwlyZXR1cm4gLUVOWElPOworfQorCitzdGF0aWMgdm9pZCBfX2V4aXQgY2xlYW51cF9ycHhsaXRlKHZvaWQpCit7CisJaWYgKG15bXRkKSB7CisJCW10ZF9kZXZpY2V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A9IDB4MGUwMDAwLAorCQkuc2l6ZSA9IDB4MDIwMDAwLAorCX0sCisJeworCQkubmFtZSA9ICJEcml2ZSBCIiwKKwkJLm9mZnNldCA9IDB4MTAwMDAwLAorCQkuc2l6ZSA9IDB4MTAwMDAwCisJfQorfTsKKworI2RlZmluZSBOVU1fUEFSVElUSU9OUyBBUlJBWV9TSVpFKHRzNTUwMF9wYXJ0aXRpb25zKQorCitzdGF0aWMgc3RydWN0IG10ZF9pbmZvICpteW10ZDsKKworc3RhdGljIGludCBfX2luaXQgaW5pdF90czU1MDBfbWFwKHZvaWQpCit7CisJaW50IHJjID0gMDsKKworCXRzNTUwMF9tYXAudmlydCA9IGlvcmVtYXBfbm9jYWNoZSh0czU1MDBfbWFwLnBoeXMsIHRzNTUwMF9tYXAuc2l6ZSk7CisKKwlpZiAoIXRzNTUwMF9tYXAudmlydCkgeworCQlwcmludGsoS0VSTl9FUlIgIkZhaWxlZCB0byBpb3JlbWFwX25vY2FjaGVcbiIpOworCQlyYyA9IC1FSU87CisJCWdvdG8gZXJyMjsKKwl9CisKKwlzaW1wbGVfbWFwX2luaXQoJnRzNTUwMF9tYXApOworCisJbXltdGQgPSBkb19tYXBfcHJvYmUoImplZGVjX3Byb2JlIiwgJnRzNTUwMF9tYXApOworCWlmICghbXltdGQpCisJCW15bXRkID0gZG9fbWFwX3Byb2JlKCJtYXBfcm9tIiwgJnRzNTUwMF9tYXApOworCisJaWYgKCFteW10ZCkgeworCQlyYyA9IC1FTlhJTzsKKwkJZ290byBlcnIxOworCX0KKworCW15bXRkLT5vd25lciA9IFRISVNfTU9EVUxFOworCW10ZF9kZXZpY2VfcmVnaXN0ZXIobXltdGQsIHRzNTUwMF9wYXJ0aXRpb25zLCBOVU1fUEFSVElUSU9OUyk7CisKKwlyZXR1cm4gMDsKKworZXJyMToKKwlpb3VubWFwKHRzNTUwMF9tYXAudmlydCk7CitlcnIyOgorCXJldHVybiByYzsKK30KKworc3RhdGljIHZvaWQgX19leGl0IG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sYXNoKTsKZGlmZiAtLWdpdCBhL2FwL29zL2xpbnV4L2xpbnV4LTMuNC54L2RyaXZlcnMvbXRkL21hcHMvdWNsaW51eC5jIGIvYXAvb3MvbGludXgvbGludXgtMy40LngvZHJpdmVycy9tdGQvbWFwcy91Y2xpbnV4LmMKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uY2ZmZjQ1NAotLS0gL2Rldi9udWxsCisrKyBiL2FwL29zL2xpbnV4L2xpbnV4LTMuNC54L2RyaXZlcnMvbXRkL21hcHMvdWNsaW51eC5jCkBAIC0wLDAgKzEsMTIxIEBACisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyoKKyAqCXVjbGludXguYyAtLSBnZW5lcmljIG1lbW9yeSBtYXBwZWQgTVREIGRyaXZlciBmb3IgdWNsaW51eAorICoKKyAqCShDKSBDb3B5cmlnaHQgMjAwMiwgR3JlZyBVbmdlcmVyIChnZXJnQHNuYXBnZWFyLmNvbSkKKyAqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworI2luY2x1ZGUgPGxpbnV4L21vZHVsZS5oPgorI2luY2x1ZGUgPGxpbnV4L3R5cGVzLmg+CisjaW5jbHVkZSA8bGludXgvaW5pdC5oPgorI2luY2x1ZGUgPGxpbnV4L2tlcm5lbC5oPgorI2luY2x1ZGUgPGxpbnV4L2ZzLmg+CisjaW5jbHVkZSA8bGludXgvbW0uaD4KKyNpbmNsdWRlIDxsaW51eC9tYWpvci5oPgorI2luY2x1ZGUgPGxpbnV4L210ZC9tdGQuaD4KKyNpbmNsdWRlIDxsaW51eC9tdGQvbWFwLmg+CisjaW5jbHVkZSA8bGludXgvbXRkL3BhcnRpdGlvbnMuaD4KKyNpbmNsdWRlIDxhc20vaW8uaD4KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK2V4dGVybiBjaGFyIF9lYnNzOworCitzdHJ1Y3QgbWFwX2luZm8gdWNsaW51eF9yYW1fbWFwID0geworCS5uYW1lID0gIlJBTSIsCisJLnBoeXMgPSAodW5zaWduZWQgbG9uZykmX2Vic3MsCisJLnNpemUgPSAwLAorfTsKKworc3RhdGljIHN0cnVjdCBtdGRfaW5mbyAqdWNsaW51eF9yYW1fbXRkaW5mbzsKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK3N0YXRpYyBzdHJ1Y3QgbXRkX3BhcnRpdGlvbiB1Y2xpbnV4X3JvbWZzW10gPSB7CisJeyAubmFtZSA9ICJST01mcyIgfQorfTsKKworI2RlZmluZQlOVU1fUEFSVElUSU9OUwlBUlJBWV9TSVpFKHVjbGludXhfcm9tZnMpCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworCitzdGF0aWMgaW50IHVjbGludXhfcG9pbnQoc3RydWN0IG10ZF9pbmZvICptdGQsIGxvZmZfdCBmcm9tLCBzaXplX3QgbGVuLAorCXNpemVfdCAqcmV0bGVuLCB2b2lkICoqdmlydCwgcmVzb3VyY2Vfc2l6ZV90ICpwaHlzKQoreworCXN0cnVjdCBtYXBfaW5mbyAqbWFwID0gbXRkLT5wcml2OworCSp2aXJ0ID0gbWFwLT52aXJ0ICsgZnJvbTsKKwlpZiAocGh5cykKKwkJKnBoeXMgPSBtYXAtPnBoeXMgKyBmcm9tOworCSpyZXRsZW4gPSBsZW47CisJcmV0dXJuKDApOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworc3RhdGljIGludCBfX2luaXQgdWNsaW51eF9tdGRfaW5pdCh2b2lkKQoreworCXN0cnVjdCBtdGRfaW5mbyAqbXRkOworCXN0cnVjdCBtYXBfaW5mbyAqbWFwcDsKKworCW1hcHAgPSAmdWNsaW51eF9yYW1fbWFwOworCWlmICghbWFwcC0+c2l6ZSkKKwkJbWFwcC0+c2l6ZSA9IFBBR0VfQUxJR04obnRvaGwoKigodW5zaWduZWQgbG9uZyAqKShtYXBwLT5waHlzICsgOCkpKSk7CisJbWFwcC0+YmFua3dpZHRoID0gNDsKKworCXByaW50aygidWNsaW51eFttdGRdOiBSQU0gcHJvYmUgYWRkcmVzcz0weCV4IHNpemU9MHgleFxuIiwKKwkgICAgICAgCShpbnQpIG1hcHAtPnBoeXMsIChpbnQpIG1hcHAtPnNpemUpOworCisJbWFwcC0+dmlydCA9IGlvcmVtYXBfbm9jYWNoZShtYXBwLT5waHlzLCBtYXBwLT5zaXplKTsKKworCWlmIChtYXBwLT52aXJ0ID09IDApIHsKKwkJcHJpbnRrKCJ1Y2xpbnV4W210ZF06IGlvcmVtYXBfbm9jYWNoZSgpIGZhaWxlZFxuIik7CisJCXJldHVybigtRUlPKTsKKwl9CisKKwlzaW1wbGVfbWFwX2luaXQobWFwcCk7CisKKwltdGQgPSBkb19tYXBfcHJvYmUoIm1hcF9yYW0iLCBtYXBwKTsKKwlpZiAoIW10ZCkgeworCQlwcmludGsoInVjbGludXhbbXRkXTogZmFpbGVkIHRvIGZpbmQgYSBtYXBwaW5nP1xuIik7CisJCWlvdW5tYXAobWFwcC0+dmlydCk7CisJCXJldHVybigtRU5YSU8pOworCX0KKworCW10ZC0+b3duZXIgPSBUSElTX01PRFVMRTsKKwltdGQtPl9wb2ludCA9IHVjbGludXhfcG9pbnQ7CisJbXRkLT5wcml2ID0gbWFwcDsKKworCXVjbGludXhfcmFtX210ZGluZm8gPSBtdGQ7CisJbXRkX2RldmljZV9yZWdpc3RlcihtdGQsIHVjbGludXhfcm9tZnMsIE5VTV9QQVJUSVRJT05TKTsKKworCXJldHVybigwKTsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK3N0YXRpYyB2b2lkIF9fZXhpdCB1Y2xpbnV4X210ZF9jbGVhbnVwKHZvaWQpCit7CisJaWYgKHVjbGludXhfcmFtX210ZGluZm8pIHsKKwkJbXRkX2RldmljZV91bnJlZ2lzdGVyKHVjbGludXhfcmFtX210ZGluZm8pOworCQltYXBfZGVzdHJveSh1Y2xpbnV4X3JhbV9tdGRpbmZvKTsKKwkJdWNsaW51eF9yYW1fbXRkaW5mbyA9IE5VTEw7CisJfQorCWlmICh1Y2xpbnV4X3JhbV9tYXAudmlydCkgeworCQlpb3VubWFwKCh2b2lkICopIHVjbGludXhfcmFtX21hcC52aXJ0KTsKKwkJdWNsaW51eF9yYW1fbWFwLnZpcnQgPSAwOworCX0KK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK21vZHVsZV9pbml0KHVjbGludXhfbXRkX2luaXQpOworbW9kdWxlX2V4aXQodWNsaW51eF9tdGRfY2xlYW51cCk7CisKK01PRFVMRV9MSUNFTlNFKCJHUEwiKTsKK01PRFVMRV9BVVRIT1IoIkdyZWcgVW5nZXJlciA8Z2VyZ0BzbmFwZ2Vhci5jb20+Iik7CitNT0RVTEVfREVTQ1JJUFRJT04oIkdlbmVyaWMgUkFNIGJhc2VkIE1URCBmb3IgdUNsaW51eCIpOworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KZGlmZiAtLWdpdCBhL2FwL29zL2xpbnV4L2xpbnV4LTMuNC54L2RyaXZlcnMvbXRkL21hcHMvdm1heDMwMS5jIGIvYXAvb3M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YWcgdG8gZmxhc2guCisqIGZsYWc6IDAsZGwgb2ZmICAgZWxzZSBkbCBvbgorKi8KK3Vuc2lnbmVkIGludCB6RHJ2TmFuZF9Xcml0ZUJvb3RmbGFnKHVuc2lnbmVkIGludCBmbGFnKQoreworCisgICAgdW5zaWduZWQgaW50IHJldCA9IDA7CisJY2hhciB2YWx1ZSA9IDA7CisJaW50IGJvb3RmbGFnID0gMDsKKwlpbnQgcmV0bGVuID0gMDsKKyAgICBzdHJ1Y3QgZXJhc2VfaW5mbyBlaTsKKwkKKyAgICB1bnNpZ25lZCBjaGFyICpidWZmZXIgPSBremFsbG9jKFdSSVRFX1pMT0FERVJfRkxBR19TSVpFLEdGUF9LRVJORUwpOworCisgICAgaWYoIGJ1ZmZlciA9PSBOVUxMICkKKyAgICAgICAgcmV0dXJuIC0xOworCisgICAgaWYobXRkX3JlYWQobXRkX2ZvdGEsMCxXUklURV9aTE9BREVSX0ZMQUdfU0laRSwmcmV0bGVuLGJ1ZmZlcikpLyogQk9PVEZMQUfU2m5hbmS1xLXaMjB+MjfX1r3aICovCisgICAgeworICAgICAgICBrZnJlZShidWZmZXIpOworICAgICAgICByZXR1cm4gLTE7CisgICAgfQorCWlmKGZsYWcgPT0gMCApCisJeworCSAgICBib290ZmxhZyA9IDB4MDA7CisgICAgICAgIG1lbXNldCgmdmFsdWUsIGJvb3RmbGFnLCAxKTsKKwl9CisgICAgZWxzZQorICAgIHsKKyAgICAgICAgYm9vdGZsYWcgPSAweDVhOworICAgICAgICBtZW1zZXQoJnZhbHVlLCBib290ZmxhZywgMSk7CisgICAgfQorCQorICAgIG1lbWNweShidWZmZXIrMiwgJnZhbHVlLCAxKTsKKyAgICBtZW1zZXQoJmVpLCAwLCBzaXplb2Yoc3RydWN0IGVyYXNlX2luZm8pKTsKKyAgICBlaS5tdGQgID0gbXRkX2ZvdGE7CisgICAgZWkuYWRkciA9IDA7CisgICAgZWkubGVuICA9IG10ZF9mb3RhLT5lcmFzZXNpemU7CisJZ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C0+YmFja2luZ19kZXZfaW5mbzsKKwkJdW5sb2NrX25ld19pbm9kZShtdGRfaW5vKTsKKwl9CisJZmlsZS0+Zl9tYXBwaW5nID0gbXRkX2luby0+aV9tYXBwaW5nOworCisJLyogWW91IGNhbid0IG9wZW4gaXQgUlcgaWYgaXQncyBub3QgYSB3cml0ZWFibGUgZGV2aWNlICovCisJaWYgKChmaWxlLT5mX21vZGUgJiBGTU9ERV9XUklURSkgJiYgIShtdGQtPmZsYWdzICYgTVREX1dSSVRFQUJMRSkpIHsKKwkJcmV0ID0gLUVBQ0NFUzsKKwkJZ290byBvdXQyOworCX0KKworCW1maSA9IGt6YWxsb2Moc2l6ZW9mKCptZmkpLCBHRlBfS0VSTkVMKTsKKwlpZiAoIW1maSkgeworCQlyZXQgPSAtRU5PTUVNOworCQlnb3RvIG91dDI7CisJfQorCW1maS0+aW5vID0gbXRkX2lubzsKKwltZmktPm10ZCA9IG10ZDsKKwlmaWxlLT5wcml2YXRlX2RhdGEgPSBtZmk7CisJbXV0ZXhfdW5sb2NrKCZtdGRfbXV0ZXgpOworCXJldHVybiAwOworCitvdXQyOgorCWlwdXQobXRkX2lubyk7CitvdXQxOgorCXB1dF9tdGRfZGV2aWNlKG10ZCk7CitvdXQ6CisJbXV0ZXhfdW5sb2NrKCZtdGRfbXV0ZXgpOworCXNpbXBsZV9yZWxlYXNlX2ZzKCZtbnQsICZjb3VudCk7CisJcmV0dXJuIHJldDsKK30gLyogbXRkY2hhcl9vcGVuICovCisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworCitzdGF0aWMgaW50IG10ZGNoYXJfY2xvc2Uoc3RydWN0IGlub2RlICppbm9kZSwgc3RydWN0IGZpbGUgKmZpbGUpCit7CisJc3RydWN0IG10ZF9maWxlX2luZm8gKm1maSA9IGZpbGUtPnByaXZhdGVfZGF0YTsKKwlzdHJ1Y3QgbXRkX2luZm8gKm10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wcy5kYXRidWYgPSBrYnVmOworCQkJb3BzLm9vYmJ1ZiA9IE5VTEw7CisJCQlvcHMub29ib2ZmcyA9IDA7CisJCQlvcHMubGVuID0gbGVuOworCisJCQlyZXQgPSBtdGRfd3JpdGVfb29iKG10ZCwgKnBwb3MsICZvcHMpOworCQkJcmV0bGVuID0gb3BzLnJldGxlbjsKKwkJCWJyZWFrOworCQl9CisKKwkJZGVmYXVsdDoKKwkJCXJldCA9IG10ZF93cml0ZShtdGQsICpwcG9zLCBsZW4sICZyZXRsZW4sIGtidWYpOworCQl9CisJCWlmICghcmV0KSB7CisJCQkqcHBvcyArPSByZXRsZW47CisJCQl0b3RhbF9yZXRsZW4gKz0gcmV0bGVuOworCQkJY291bnQgLT0gcmV0bGVuOworCQkJYnVmICs9IHJldGxlbjsKKwkJfQorCQllbHNlIHsKKwkJCWtmcmVlKGtidWYpOworCQkJcmV0dXJuIHJldDsKKwkJfQorCX0KKworCWtmcmVlKGtidWYpOworCXJldHVybiB0b3RhbF9yZXRsZW47Cit9IC8qIG10ZGNoYXJfd3JpdGUgKi8KKworLyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisKKyAgICBJT0NUTCBjYWxscyBmb3IgZ2V0dGluZyBkZXZpY2UgcGFyYW1ldGVycy4KKworPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PSovCitzdGF0aWMgdm9pZCBtdGRjaGFyX2VyYXNlX2NhbGxiYWNrIChzdHJ1Y3QgZXJhc2VfaW5mbyAqaW5zdHIpCit7CisJd2FrZV91cCgod2FpdF9xdWV1ZV9oZWFkX3QgKilpbnN0ci0+cHJpdik7Cit9CisKKyNpZmRlZiBDT05GSUdfSEFWRV9NVERfT1RQCitzdGF0aWMgaW50IG90cF9zZWxlY3RfZmlsZW1vZGUoc3RydWN0IG10ZF9maWxlX2luZm8gK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CBlcnIgPSAtRUlOVkFMOworCisJZm9yIChpID0gMDsgaSA8IGNvbmNhdC0+bnVtX3N1YmRldjsgaSsrKSB7CisJCXN0cnVjdCBtdGRfaW5mbyAqc3ViZGV2ID0gY29uY2F0LT5zdWJkZXZbaV07CisJCXVpbnQ2NF90IHNpemU7CisKKwkJaWYgKG9mcyA+PSBzdWJkZXYtPnNpemUpIHsKKwkJCXNpemUgPSAwOworCQkJb2ZzIC09IHN1YmRldi0+c2l6ZTsKKwkJCWNvbnRpbnVlOworCQl9CisJCWlmIChvZnMgKyBsZW4gPiBzdWJkZXYtPnNpemUpCisJCQlzaXplID0gc3ViZGV2LT5zaXplIC0gb2ZzOworCQllbHNlCisJCQlzaXplID0gbGVuOworCisJCWVyciA9IG10ZF9sb2NrKHN1YmRldiwgb2ZzLCBzaXplKTsKKwkJaWYgKGVycikKKwkJCWJyZWFrOworCisJCWxlbiAtPSBzaXplOworCQlpZiAobGVuID09IDApCisJCQlicmVhazsKKworCQllcnIgPSAtRUlOVkFMOworCQlvZnMgPSAwOworCX0KKworCXJldHVybiBlcnI7Cit9CisKK3N0YXRpYyBpbnQgY29uY2F0X3VubG9jayhzdHJ1Y3QgbXRkX2luZm8gKm10ZCwgbG9mZl90IG9mcywgdWludDY0X3QgbGVuKQoreworCXN0cnVjdCBtdGRfY29uY2F0ICpjb25jYXQgPSBDT05DQVQobXRkKTsKKwlpbnQgaSwgZXJyID0gMDsKKworCWZvciAoaSA9IDA7IGkgPCBjb25jYXQtPm51bV9zdWJkZXY7IGkrKykgeworCQlzdHJ1Y3QgbXRkX2luZm8gKnN1YmRldiA9IGNvbmNhdC0+c3ViZGV2W2ldOworCQl1aW50NjRfdCBzaXplOworCisJCWlmIChvZnMgPj0gc3ViZGV2LT5zaXplKSB7CisJCQlzaXplID0gMDsKKwkJCW9mcyAtPSBzdWJkZXYtPnNpemU7CisJCQljb250aW51ZTsKKwkJfQorCQlpZiAob2ZzICsgbGVuID4gc3ViZGV2LT5zaXplKQ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RkX2luZm8gKm10ZCwgc2l6ZV90ICpzaXplKQoreworCWdmcF90IGZsYWdzID0gX19HRlBfTk9XQVJOIHwgX19HRlBfV0FJVCB8CisJCSAgICAgICBfX0dGUF9OT1JFVFJZIHwgX19HRlBfTk9fS1NXQVBEOworCXNpemVfdCBtaW5fYWxsb2MgPSBtYXhfdChzaXplX3QsIG10ZC0+d3JpdGVzaXplLCBQQUdFX1NJWkUpOworCXZvaWQgKmtidWY7CisKKwkqc2l6ZSA9IG1pbl90KHNpemVfdCwgKnNpemUsIEtNQUxMT0NfTUFYX1NJWkUpOworCisJd2hpbGUgKCpzaXplID4gbWluX2FsbG9jKSB7CisJCWtidWYgPSBrbWFsbG9jKCpzaXplLCBmbGFncyk7CisJCWlmIChrYnVmKQorCQkJcmV0dXJuIGtidWY7CisKKwkJKnNpemUgPj49IDE7CisJCSpzaXplID0gQUxJR04oKnNpemUsIG10ZC0+d3JpdGVzaXplKTsKKwl9CisKKwkvKgorCSAqIEZvciB0aGUgbGFzdCByZXNvcnQgYWxsb2NhdGlvbiBhbGxvdyAna21hbGxvYygpJyB0byBkbyBhbGwgc29ydHMgb2YKKwkgKiB0aGluZ3MgKHdyaXRlLWJhY2ssIGRyb3BwaW5nIGNhY2hlcywgZXRjKSBieSB1c2luZyBHRlBfS0VSTkVMLgorCSAqLworCXJldHVybiBrbWFsbG9jKCpzaXplLCBHRlBfS0VSTkVMKTsKK30KK0VYUE9SVF9TWU1CT0xfR1BMKG10ZF9rbWFsbG9jX3VwX3RvKTsKKworI2lmZGVmIENPTkZJR19QUk9DX0ZTCisKKy8qPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLworLyogU3VwcG9ydCBmb3IgL3Byb2MvbXRkICovCisKK3N0YXRpYyBzdHJ1Y3QgcHJvY19kaXJfZW50cnkgKnByb2NfbXRkOworCitzdGF0aWMgaW50IG10ZF9wcm9jX3Nob3coc3RydWN0IHNl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isJCQkvKiBtb3VudCBieSBNVEQgZGV2aWNlIG51bWJlciBuYW1lICovCisJCQljaGFyICplbmRwdHI7CisKKwkJCW10ZG5yID0gc2ltcGxlX3N0cnRvdWwoZGV2X25hbWUgKyAzLCAmZW5kcHRyLCAwKTsKKwkJCWlmICghKmVuZHB0cikgeworCQkJCS8qIEl0IHdhcyBhIHZhbGlkIG51bWJlciAqLworCQkJCXByX2RlYnVnKCJNVERTQjogbXRkJSVkLCBtdGRuciAlZFxuIiwKKwkJCQkgICAgICBtdGRucik7CisJCQkJcmV0dXJuIG1vdW50X210ZF9ucihmc190eXBlLCBmbGFncywKKwkJCQkJCSAgICAgZGV2X25hbWUsIGRhdGEsCisJCQkJCQkgICAgIG10ZG5yLCBmaWxsX3N1cGVyKTsKKwkJCX0KKwkJfQorCX0KKworI2lmZGVmIENPTkZJR19CTE9DSworCS8qIHRyeSB0aGUgb2xkIHdheSAtIHRoZSBoYWNrIHdoZXJlIHdlIGFsbG93ZWQgdXNlcnMgdG8gbW91bnQKKwkgKiAvZGV2L210ZGJsb2NrJChuKSBidXQgZGlkbid0IGFjdHVhbGx5IF91c2VfIHRoZSBibG9ja2RldgorCSAqLworCWJkZXYgPSBsb29rdXBfYmRldihkZXZfbmFtZSk7CisJaWYgKElTX0VSUihiZGV2KSkgeworCQlyZXQgPSBQVFJfRVJSKGJkZXYpOworCQlwcl9kZWJ1ZygiTVREU0I6IGxvb2t1cF9iZGV2KCkgcmV0dXJuZWQgJWRcbiIsIHJldCk7CisJCXJldHVybiBFUlJfUFRSKHJldCk7CisJfQorCXByX2RlYnVnKCJNVERTQjogbG9va3VwX2JkZXYoKSByZXR1cm5lZCAwXG4iKTsKKworCXJldCA9IC1FSU5WQUw7CisKKwltYWpvciA9IE1BSk9SKGJkZXYtPmJkX2Rldik7CisJbXRkbnIgPSBNSU5PUihiZGV2LT5iZF9kZXYpOworCWJkcHV0KGJkZXYpOworCisJaWYgKG1ham9yICE9IE1URF9CTE9DS19NQUpPUikK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pbnV4L2xpbnV4LTMuNC54L2RyaXZlcnMvbXRkL25hbmQvTWFrZWZpbGUKQEAgLTAsMCArMSw1NyBAQAorIworIyBsaW51eC9kcml2ZXJzL25hbmQvTWFrZWZpbGUKKyMKKworb2JqLSQoQ09ORklHX01URF9OQU5EKQkJCSs9IG5hbmQubworb2JqLSQoQ09ORklHX01URF9OQU5EX0VDQykJCSs9IG5hbmRfZWNjLm8KK29iai0kKENPTkZJR19NVERfTkFORF9CQ0gpCQkrPSBuYW5kX2JjaC5vCitvYmotJChDT05GSUdfTVREX05BTkRfSURTKQkJKz0gbmFuZF9pZHMubworb2JqLSQoQ09ORklHX01URF9TTV9DT01NT04pIAkJKz0gc21fY29tbW9uLm8KKworb2JqLSQoQ09ORklHX01URF9OQU5EX0NBRkUpCQkrPSBjYWZlX25hbmQubworb2JqLSQoQ09ORklHX01URF9OQU5EX1NQSUEpCQkrPSBzcGlhLm8KK29iai0kKENPTkZJR19NVERfTkFORF9BTVNfREVMVEEpCSs9IGFtcy1kZWx0YS5vCitvYmotJChDT05GSUdfTVREX05BTkRfQVVUQ1BVMTIpCQkrPSBhdXRjcHUxMi5vCitvYmotJChDT05GSUdfTVREX05BTkRfREVOQUxJKQkJKz0gZGVuYWxpLm8KKyNvYmotJChDT05GSUdfTkFORF9JTlRFUkZBQ0VfTElOVVgpICs9IG5hbmRfaW50ZXJmYWNlX2xpbnV4Lm8KK29iai0kKENPTkZJR19NVERfTkFORF9BVTE1NTApCQkrPSBhdTE1NTBuZC5vCitvYmotJChDT05GSUdfTVREX05BTkRfQkY1WFgpCQkrPSBiZjV4eF9uYW5kLm8KK29iai0kKENPTkZJR19NVERfTkFORF9QUENIQU1FTEVPTkVWQikJKz0gcHBjaGFtZWxlb25ldmIubworb2JqLSQoQ09ORklHX01URF9OQU5EX1MzQzI0MTApCQkrPSBzM2MyNDEwLm8KK29iai0kKENPTkZJR19NVERfTkFORF9EQVZJTkNJKQkJKz0gZGF2aW5jaV9uYW5kLm8KK29iai0kKENPTkZJR19NVERfTkFORF9ESVNLT05DSElQKQkrPSBkaXNrb25jaGlwLm8KK29iai0kKENPTkZJR19NVERfTkFORF9ET0NHNCkJCSs9IGRvY2c0Lm8KK29iai0kKENPTkZJR19NVERfTkFORF9GU01DKQkJKz0gZnNtY19uYW5kLm8KK29iai0kKENPTkZJR19NVERfTkFORF9IMTkwMCkJCSs9IGgxOTEwLm8KK29iai0kKENPTkZJR19NVERfTkFORF9SVENfRlJPTTQpCSs9IHJ0Y19mcm9tNC5vCitvYmotJChDT05GSUdfTVREX05BTkRfU0hBUlBTTCkJCSs9IHNoYXJwc2wubworb2JqLSQoQ09ORklHX01URF9OQU5EX05BTkRTSU0pCQkrPSBuYW5kc2ltLm8KK29iai0kKENPTkZJR19NVERfTkFORF9DUzU1M1gpCQkrPSBjczU1M3hfbmFuZC5vCitvYmotJChDT05GSUdfTVREX05BTkRfTkRGQykJCSs9IG5kZmMubworb2JqLSQoQ09ORklHX01URF9OQU5EX0FUTUVMKQkJKz0gYXRtZWxfbmFuZC5vCitvYmotJChDT05GSUdfTVREX05BTkRfR1BJTykJCSs9IGdwaW8ubworb2JqLSQoQ09ORklHX01URF9OQU5EX09NQVAyKSAJCSs9IG9tYXAyLm8KK29iai0kKENPTkZJR19NVERfTkFORF9DTV9YMjcwKQkJKz0gY214MjcwX25hbmQubworb2JqLSQoQ09ORklHX01URF9OQU5EX1BYQTN4eCkJCSs9IHB4YTN4eF9uYW5kLm8KK29iai0kKENPTkZJR19NVERfTkFORF9UTUlPKQkJKz0gdG1pb19uYW5kLm8KK29iai0kKENPTkZJR19NVERfTkFORF9QTEFURk9STSkJCSs9IHBsYXRfbmFuZC5vCitvYmotJChDT05GSUdfTVREX0FMQVVEQSkJCSs9IGFsYXVkYS5vCitvYmotJChDT05GSUdfTVREX05BTkRfUEFTRU1JKQkJKz0gcGFzZW1pX25hbmQubworb2JqLSQoQ09ORklHX01URF9OQU5EX09SSU9OKQkJKz0gb3Jpb25fbmFuZC5vCitvYmotJChDT05GSUdfTVREX05BTkRfRlNMX0VMQkMpCQkrPSBmc2xfZWxiY19uYW5kLm8KK29iai0kKENPTkZJR19NVERfTkFORF9GU0xfSUZDKQkJKz0gZnNsX2lmY19uYW5kLm8KK29iai0kKENPTkZJR19NVERfTkFORF9GU0xfVVBNKQkJKz0gZnNsX3VwbS5vCitvYmotJChDT05GSUdfTVREX05BTkRfU0hfRkxDVEwpCQkrPSBzaF9mbGN0bC5vCitvYmotJChDT05GSUdfTVREX05BTkRfTVhDKQkJKz0gbXhjX25hbmQubworb2JqLSQoQ09ORklHX01URF9OQU5EX1NPQ1JBVEVTKQkJKz0gc29jcmF0ZXNfbmFuZC5vCitvYmotJChDT05GSUdfTVREX05BTkRfVFhYOU5ERk1DKQkrPSB0eHg5bmRmbWMubworb2JqLSQoQ09ORklHX01URF9OQU5EX05VQzkwMCkJCSs9IG51YzkwMF9uYW5kLm8KK29iai0kKENPTkZJR19NVERfTkFORF9OT01BRElLKQkJKz0gbm9tYWRpa19uYW5kLm8KK29iai0kKENPTkZJR19NVERfTkFORF9CQ01fVU1JKQkJKz0gYmNtX3VtaV9uYW5kLm8gbmFuZF9iY21fdW1pLm8KK29iai0kKENPTkZJR19NVERfTkFORF9NUEM1MTIxX05GQykJKz0gbXBjNTEyMV9uZmMubworb2JqLSQoQ09ORklHX01URF9OQU5EX1JJQ09IKQkJKz0gcjg1Mi5vCitvYmotJChDT05GSUdfTVREX05BTkRfSlo0NzQwKQkJKz0gano0NzQwX25hbmQubworb2JqLSQoQ09ORklHX01URF9OQU5EX0dQTUlfTkFORCkJKz0gZ3BtaS1uYW5kLworb2JqLSQoQ09ORklHX01URF9aWElDX1NQSUZDKQkJKz0genhpY19zcGlmYy5vIHNwaV9uYW5kLm8gc3BpX25hbmRfZGV2aWNlcy5vCisKK25hbmQtb2JqcyA6PSBuYW5kX2Jhc2UubyBuYW5kX2JidC5vCmRpZmYgLS1naXQgYS9hcC9vcy9saW51eC9saW51eC0zLjQueC9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RUdfTkFORF9EQVRBX1BBRERSLCB0bXBfbGVuKTsKKwkJd2FpdF9mb3JfY29tcGxldGlvbigmbmFuZF9jb21wKTsKKworCQlvZmZzZXQgKz0gdG1wX2xlbjsKKwl9CisKKwlkbWFfZnJlZV9jaGFubmVsKGhuZGwpOworfQorCisjZW5kaWYKKworc3RhdGljIGludCBuYW5kX2Rldl9yZWFkeShzdHJ1Y3QgbXRkX2luZm8gKm10ZCkKK3sKKwlyZXR1cm4gbmFuZF9iY21fdW1pX2Rldl9yZWFkeSgpOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorKgorKiAgYmNtX3VtaV9uYW5kX2luaXRodworKgorKiAgIFRoaXMgcm91dGluZSBkb2VzIHRoZSBuZWNlc3NhcnkgaGFyZHdhcmUgKGJvYXJkLXNwZWNpZmljKQorKiAgIGluaXRpYWxpemF0aW9ucy4gIFRoaXMgaW5jbHVkZXMgc2V0dGluZyB1cCB0aGUgdGltaW5ncywgZXRjLgorKgorKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworaW50IGJjbV91bWlfbmFuZF9pbml0aHcodm9pZCkKK3sKKwkvKiBDb25maWd1cmUgbmFuZCB0aW1pbmcgcGFyYW1ldGVycyAqLworCVJFR19VTUlfTkFORF9UQ1IgJj0gfjB4N2ZmZmY7CisJUkVHX1VNSV9OQU5EX1RDUiB8PSBIV19DRkdfTkFORF9UQ1I7CisKKyNpZiAhZGVmaW5lZChDT05GSUdfTVREX05BTkRfQkNNX1VNSV9IV0NTKQorCS8qIGVuYWJsZSBzb2Z0d2FyZSBjb250cm9sIG9mIENTICovCisJUkVHX1VNSV9OQU5EX1RDUiB8PSBSRUdfVU1JX05BTkRfVENSX0NTX1NXQ1RSTDsKKyNlbmRpZgorCisJLyoga2VlcCBOQU5EIGNoaXAg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BR0VfREFUQV9TSVpFKTsKKwkgICAgaW93cml0ZTMyKHNwYXJlX3NpemUsIGRlbmFsaS0+Zmxhc2hfcmVnICsgTE9HSUNBTF9QQUdFX1NQQVJFX1NJWkUpOworCQkKKyAgICAgICAgaW93cml0ZTMyKCgoODAgKiBidXNfZnJlcSkvMTAwMCsyKSB8ICgoKDMwICogYnVzX2ZyZXEpLzEwMDArMik8PDgpLCAKKyAgICAgICAgICAgICAgICBkZW5hbGktPmZsYXNoX3JlZyArIFdFXzJfUkUpOyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiBUd2hyLFRycjEqLworICAgICAgICBpb3dyaXRlMzIoKCgxMjAqIGJ1c19mcmVxKS8xMDAwKzIpIHwgKCgoMzAqIGJ1c19mcmVxKS8xMDAwKzIpPDw4KSwgCisgICAgICAgICAgICAgICAgZGVuYWxpLT5mbGFzaF9yZWcgKyBBRERSXzJfREFUQSk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogVGFkbCxUcnIyICovCisgICAgICAgIGlvd3JpdGUzMigoMTIwICogYnVzX2ZyZXEpLzEwMDArMiwgZGVuYWxpLT5mbGFzaF9yZWcgKyBSRV8yX1dFKTsgICAgICAgLyogVHJodyAqLworICAgICAgICBpb3dyaXRlMzIoKDQwICogYnVzX2ZyZXEpLzEwMDArMiwgZGVuYWxpLT5mbGFzaF9yZWcgKyBSRFdSX0VOX0xPX0NOVCk7IC8qIFRycCAgICovCisgICAgICAgIGlvd3JpdGUzMigoMzAgKiBidXNfZnJlcSkvMTAwMCsyLCBkZW5hbGktPmZsYXNoX3JlZyArIFJEV1JfRU5fSElfQ05UKTsgLyogVHJlaCAqLworICAgICAgICBpb3dyaXRlMzIoKDQwICogYnVzX2ZyZXEpLzEwMDArMiwgZGVuYWxpLT5mbGFzaF9yZWcgKyBDU19TRVRVUF9DTlQpOyAgIC8qIFRjcyAgICovCisgICAgICAgIGlvd3JpdGUzMigoODAgKiBidXNfZnJlcSkvMTAwMC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0OworCXN0cnVjdCBlcmFzZV9pbmZvIGVpOworCXNpemVfdCBmb3RhbGVuID0gMDsKKwlpbnQgb2Zmc2V0ID0gMDsKKwlpbnQgc2l6ZSA9IDA7CisJaW50IGFkZHIgPSAwOworCWludCBpID0wOworCWludCByZXQgPSAwOworCQorCXBhcnQgPSBwYXJ0aXRpb25zOworCWZvcihpPTA7aTxwYXJ0LT5udW1fcGFydHM7aSsrKQorCXsKKwkgICAgaWYgKCBzdHJjbXAoIChjaGFyICopcGFydC0+cGFydHNbaV0ubmFtZSwgImZvdGFmbGFnIiApID09IDAgKQorICAgICAgICAgICAgYnJlYWs7CisJfQorCW9mZnNldCA9IChpbnQpcGFydC0+cGFydHNbaV0ub2Zmc2V0OworCXNpemUgPSAoaW50KXBhcnQtPnBhcnRzW2ldLnNpemU7CisJZmxhZ19idWYgPSBremFsbG9jKG10ZF9mb3RhLT53cml0ZXNpemUsIEdGUF9LRVJORUwpOworCWZvdGFsZW4gPSBtdGRfZm90YS0+d3JpdGVzaXplOworCisJLyogcmVhZCBwYXJ0aXRpb24gKi8KKyAgICBhZGRyID0gb2Zmc2V0OworICAgIHdoaWxlIChhZGRyIDwgKG9mZnNldCtzaXplKSkgCisgICAgeworCQlpZiAobXRkX2ZvdGEtPl9ibG9ja19pc2JhZCAobXRkX2ZvdGEsIGFkZHIpKSAKKyAgICAgICAgeyAgICAgICAgICAKKwkJCWFkZHIgKz0gbXRkX2ZvdGEtPmVyYXNlc2l6ZTsKKwkJCWNvbnRpbnVlOworCQl9CisJCXJldCA9IG10ZF9mb3RhLT5fcmVhZChtdGRfZm90YSwgYWRkciwgZm90YWxlbiwgJnJldGxlbiwgZmxhZ19idWYpOworCQlpZihyZXQgPT0gMCkKKwkJeworCQkgICAgYnJlYWs7CisJCX0KKwkJZWxzZSBpZiAocmV0KSAKKyAgICAgICAgeworCQkJcmV0dXJuIHJldDsKKwkJfQorCX0JCisJcHJpbnRrKCIgZm90YSBmbGFnOiAlcyBcbiIsIGZ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ICAgPDwgRkNSX0NNRDJfU0hJRlQpIHwKKwkJICAgICAgKE5BTkRfQ01EX1BBR0VQUk9HIDw8IEZDUl9DTUQzX1NISUZUKTsKKworCQlpZiAocHJpdi0+cGFnZV9zaXplKSB7CisJCQlvdXRfYmUzMigmbGJjLT5maXIsCisJCQkgICAgICAgICAoRklSX09QX0NNMiA8PCBGSVJfT1AwX1NISUZUKSB8CisJCQkgICAgICAgICAoRklSX09QX0NBICA8PCBGSVJfT1AxX1NISUZUKSB8CisJCQkgICAgICAgICAoRklSX09QX1BBICA8PCBGSVJfT1AyX1NISUZUKSB8CisJCQkgICAgICAgICAoRklSX09QX1dCICA8PCBGSVJfT1AzX1NISUZUKSB8CisJCQkgICAgICAgICAoRklSX09QX0NNMyA8PCBGSVJfT1A0X1NISUZUKSB8CisJCQkgICAgICAgICAoRklSX09QX0NXMSA8PCBGSVJfT1A1X1NISUZUKSB8CisJCQkgICAgICAgICAoRklSX09QX1JTICA8PCBGSVJfT1A2X1NISUZUKSk7CisJCX0gZWxzZSB7CisJCQlvdXRfYmUzMigmbGJjLT5maXIsCisJCQkgICAgICAgICAoRklSX09QX0NNMCA8PCBGSVJfT1AwX1NISUZUKSB8CisJCQkgICAgICAgICAoRklSX09QX0NNMiA8PCBGSVJfT1AxX1NISUZUKSB8CisJCQkgICAgICAgICAoRklSX09QX0NBICA8PCBGSVJfT1AyX1NISUZUKSB8CisJCQkgICAgICAgICAoRklSX09QX1BBICA8PCBGSVJfT1AzX1NISUZUKSB8CisJCQkgICAgICAgICAoRklSX09QX1dCICA8PCBGSVJfT1A0X1NISUZUKSB8CisJCQkgICAgICAgICAoRklSX09QX0NNMyA8PCBGSVJfT1A1X1NISUZUKSB8CisJCQkgICAgICAgICAoRklSX09QX0NXMSA8PCBGSVJfT1A2X1NISUZUKSB8CisJCQkgICAgICAgICAoRklSX09QX1JTICA8PCBGSVJfT1A3X1NISUZUKSk7CisKKwkJCWlmIChlbGJjX2ZjbV9jdHJsLT5vb2IpC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dGVyX2VxKGppZmZpZXMsIGRlYWRsaW5lKSk7CisKKwlpZiAodGltZV9hZnRlcl9lcShqaWZmaWVzLCBkZWFkbGluZSkpIHsKKwkJZGV2X2Vycihob3N0LT5kZXYsICJjYWxjdWxhdGUgZWNjIHRpbWVkIG91dFxuIik7CisJCXJldHVybiAtRVRJTUVET1VUOworCX0KKworCWVjY190bXAgPSByZWFkbChGU01DX05BTkRfUkVHKHJlZ3MsIGJhbmssIEVDQzEpKTsKKwllY2NbMF0gPSAodWludDhfdCkgKGVjY190bXAgPj4gMCk7CisJZWNjWzFdID0gKHVpbnQ4X3QpIChlY2NfdG1wID4+IDgpOworCWVjY1syXSA9ICh1aW50OF90KSAoZWNjX3RtcCA+PiAxNik7CisJZWNjWzNdID0gKHVpbnQ4X3QpIChlY2NfdG1wID4+IDI0KTsKKworCWVjY190bXAgPSByZWFkbChGU01DX05BTkRfUkVHKHJlZ3MsIGJhbmssIEVDQzIpKTsKKwllY2NbNF0gPSAodWludDhfdCkgKGVjY190bXAgPj4gMCk7CisJZWNjWzVdID0gKHVpbnQ4X3QpIChlY2NfdG1wID4+IDgpOworCWVjY1s2XSA9ICh1aW50OF90KSAoZWNjX3RtcCA+PiAxNik7CisJZWNjWzddID0gKHVpbnQ4X3QpIChlY2NfdG1wID4+IDI0KTsKKworCWVjY190bXAgPSByZWFkbChGU01DX05BTkRfUkVHKHJlZ3MsIGJhbmssIEVDQzMpKTsKKwllY2NbOF0gPSAodWludDhfdCkgKGVjY190bXAgPj4gMCk7CisJZWNjWzldID0gKHVpbnQ4X3QpIChlY2NfdG1wID4+IDgpOworCWVjY1sxMF0gPSAodWludDhfdCkgKGVjY190bXAgPj4gMTYpOworCWVjY1sxMV0gPSAodWludDhfdCkgKGVjY190bXAgPj4gMjQpOworCisJZWNjX3RtcCA9IHJlYWRsKEZTTUNfTkFORF9SRUcocmVncywgYmFuaywgU1RTKSk7CisJZWNjWzEyXSA9ICh1aW50OF90KSAoZWNjX3RtcCA+PiAx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mZXJlbmNlIHBlcmlvZCBpcyBlaXRoZXIgdGhlIGNsb2NrIHBlcmlvZCBvciBoYWxmIHRoYXQsIHNvIHRoaXMKKwkgKiBpczoKKwkgKgorCSAqICAgICAgICAgICAgICAgICAgICAgICAgOCAgICAgICBBRCB4IERERgorCSAqICAgICAgICAgU0RGICA9ICBBRCB4IC0tLS0tICA9ICAtLS0tLS0tLQorCSAqICAgICAgICAgICAgICAgICAgICAgIGYgeCBQICAgICAgICBQCisJICoKKwkgKiB3aGVyZToKKwkgKgorCSAqICAgICAgIGYgIGlzIDEgb3IgMS8yLCBkZXBlbmRpbmcgb24gaG93IHdlJ3JlIGRyaXZpbmcgdGhlIERMTC4KKwkgKiAgICAgICBQICBpcyB0aGUgY2xvY2sgcGVyaW9kLgorCSAqICAgICBEREYgIGlzIHRoZSBETEwgRGVsYXkgRmFjdG9yLCBhIGRpbWVuc2lvbmxlc3MgdmFsdWUgdGhhdAorCSAqICAgICAgICAgIGluY29ycG9yYXRlcyBhbGwgdGhlIGNvbnN0YW50cyBpbiB0aGUgY29udmVyc2lvbi4KKwkgKgorCSAqIERERiB3aWxsIGJlIGVpdGhlciA4IG9yIDE2LCBib3RoIG9mIHdoaWNoIGFyZSBwb3dlcnMgb2YgdHdvLiBXZSBjYW4KKwkgKiByZWR1Y2UgdGhlIGNvc3Qgb2YgdGhpcyBjb252ZXJzaW9uIGJ5IHVzaW5nIGJpdCBzaGlmdHMgaW5zdGVhZCBvZgorCSAqIG11bHRpcGxpY2F0aW9uIG9yIGRpdmlzaW9uLiBUaHVzOgorCSAqCisJICogICAgICAgICAgICAgICAgIEFEIDw8IEREUworCSAqICAgICAgICAgU0RGICA9ICAtLS0tLS0tLS0KKwkgKiAgICAgICAgICAgICAgICAgICAgIFAKKwkgKgorCSAqICAgICBvcgorCSAqCisJICogICAgICAgICBBRCAgPSAgKFNERiA+PiBERFMpIHggUAorCSAqCisJICogd2hlcmU6CisJICoKKwkgKiAgICAgRERTICBpcyB0aGUgREx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X25zIC0KKwkJCQkJCShpbnQpZGF0YV9zZXR1cF9pbl9ucykgPj4gMTsKKworCS8qCisJICogVGhlIGZvbGxvd2luZyBmaWd1cmUgaWxsdXN0cmF0ZXMgc29tZSBhc3BlY3RzIG9mIGEgTkFORCBGbGFzaCByZWFkOgorCSAqCisJICoKKwkgKiAgICAgICAgICAgX18gICAgICAgICAgICAgICAgICAgX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fXworCSAqIFJETiAgICAgICAgIFxfX19fX19fX19fX19fX19fXy8KKwkgKgorCSAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA8LS0tLSB0RVlFIC0tLS0tPgorCSAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8tLS0tLS0tLS0tLS0tLS0tLVwKKwkgKiBSZWFkIERhdGEgLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLTwgICAgICAgICAgICAgICAgICAgPi0tLS0tLS0tLQorCSAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwtLS0tLS0tLS0tLS0tLS0tLS8KKwkgKiAgICAgICAgICAgICBeICAgICAgICAgICAgICAgICBeICAgICAgICAgICAgICAgICBeICAgICAgICAgICAgICBeCisJICogICAgICAgICAgICAgfCAgICAgICAgICAgICAgICAgfCAgICAgICAgICAgICAgICAgfCAgICAgICAgICAgICAgfAorCSAqICAgICAgICAgICAgIHw8LS1EYXRhIFNldHVwIC0tPnw8LS1EZWxheSBUaW1lIC0tPnwgICAgICAgICAgICAgIHwKKwkgKiAgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICB8ICAgICAgICAgICAgICB8CisJICogICAgICAgICAgICAgfCAgICAgICAgICAgICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfAorCSAqICAgICAgICAgICAgIHwgICAgICAgICAgICAgICAgIHw8LS0gICBRdWFudGl6ZWQgRGVs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gdGhlCisJICogbmVhcmVzdCAzMi1iaXQgYm91bmRhcnkuCisJICovCisJbWV0YWRhdGFfc2l6ZSA9IEFMSUdOKGdlby0+bWV0YWRhdGFfc2l6ZSwgNCk7CisJc3RhdHVzX3NpemUgICA9IEFMSUdOKGdlby0+ZWNjX2NodW5rX2NvdW50LCA0KTsKKworCWdlby0+YXV4aWxpYXJ5X3NpemUgPSBtZXRhZGF0YV9zaXplICsgc3RhdHVzX3NpemU7CisJZ2VvLT5hdXhpbGlhcnlfc3RhdHVzX29mZnNldCA9IG1ldGFkYXRhX3NpemU7CisKKwlpZiAoIXRoaXMtPnN3YXBfYmxvY2tfbWFyaykKKwkJcmV0dXJuIDA7CisKKwkvKgorCSAqIFdlIG5lZWQgdG8gY29tcHV0ZSB0aGUgYnl0ZSBhbmQgYml0IG9mZnNldHMgb2YKKwkgKiB0aGUgcGh5c2ljYWwgYmxvY2sgbWFyayB3aXRoaW4gdGhlIEVDQy1iYXNlZCB2aWV3IG9mIHRoZSBwYWdlLgorCSAqCisJICogTkFORCBjaGlwIHdpdGggMksgcGFnZSBzaG93cyBiZWxvdzoKKwkgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChCbG9jayBNYXJrKQorCSAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfCAgICAgIHwKKwkgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgIEQgICB8CisJICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8PC0tLS0+fAorCSAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgViAgICAgIFYKKwkgKiAgICArLS0tKy0tLS0tLS0tLS0rLSstLS0tLS0tLS0tKy0rLS0tLS0tLS0tLSstKy0tLS0tLS0tLS0rLSsKKwkgKiAgICB8IE0gfCAgIGRhdGEgICB8RXwgICBkYXRhICAgfEV8ICAgZGF0YSAgIHxFfCAgIGRhdGEgICB8RXwKKwkgKiAgICArLS0tKy0tLS0tLS0tLS0rLSstLS0tLS0tLS0tKy0rLS0tLS0tLS0tLSstKy0tLS0tLS0tLS0rLSsKKwkgKgorCSAqIFRoZSBwb3NpdGlvbiBvZiBibG9jayBtYXJrIG1vdmVzIGZvcndhcmQgaW4gdGhlIEVDQy1iYXNlZCB2aWV3CisJICogb2YgcGFnZSwgYW5kIHRoZSBkZWx0YSBpczoKKwkgKgorCSAqICAgICAgICAgICAgICAgICAgIEUgKiBHICogKE4gLSAxKQorCSAqICAgICAgICAgICAgIEQgPSAoLS0tLS0tLS0tLS0tLS0tLSArIE0pCisJICogICAgICAgICAgICAgICAgICAgICAgICAgIDgKKwkgKgorCSAqIFdpdGggdGhlIGZvcm11bGEgdG8gY29tcHV0ZSB0aGUgRUNDIHN0cmVuZ3RoLCBhbmQgdGhlIGNvbmRpdGlvbgorCSAqICAgICAgIDogQyA+PSBPICAgICAgICAgKEMgaXMgdGhlIGVjYyBjaHVuayBzaXplKQorCSAqCisJICogSXQncyBlYXN5IHRvIGRlZHVjZSB0byB0aGUgZm9sbG93aW5nIHJlc3VsdDoKKwkgKgorCSAqICAgICAgICAgRSAqIEcgICAgICAgKE8gLSBNKSAgICAgIEMgLSBNICAgICAgICAgQyAtIE0KKwkgKiAgICAgIC0tLS0tLS0tLS0tIDw9IC0tLS0tLS0gPD0gIC0tLS0tLS0tICA8ICAtLS0tLS0tLS0KKwkgKiAgICAgICAgICAgOCAgICAgICAgICAgIE4gICAgICAgICAgIE4gICAgICAgICAgKE4gLSAxKQorCSAqCisJICogIFNvLCB3ZSBnZXQ6CisJICoKKwkgKiAgICAgICAgICAgICAgICAgICBFICogRyAqIChOIC0gMSkKKwkgKiAgICAgICAgICAgICBEID0gKC0tLS0tLS0tLS0tLS0tLS0gKyBNKSA8IEMKKwkgKiAgICAgICAgICAgICAgICAgICAgICAgICAgOAorCSAqCis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W5kIHJldHVybiBpdC4gSXQgIHwgICAgICAgICAgICAgICAgICAgICAgICAgfAorICogICAgICAgICAgICAgICAgICAgIHwgY29udGFpbnMgZXhhY3RseSB3aGF0ICAgfCAgICAgICAgICAgICAgICAgICAgICAgICB8CisgKiAgICAgICAgICAgICAgICAgICAgfCB3ZSB3YW50LiAgICAgICAgICAgICAgICB8IFJlYWQgdGhlIGJsb2NrIG1hcmsgYW5kIHwKKyAqICAgICAgIC0tLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSsgcmV0dXJuIGl0IGluIGEgYnVmZmVyICAgfAorICogICAgICAgICAgICAgICAgICAgIHwgUmVhZCB0aGUgY29udmVudGlvbmFsICAgfCBmdWxsIG9mIHNldCBiaXRzLiAgICAgICB8CisgKiAgICAgICAgICAgICAgICAgICAgfCBPT0IgYXQgdGhlIGVuZCBvZiB0aGUgICB8ICAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAqICAgICAgICAgICAgICAgICAgICB8IHBhZ2UgYW5kIGFsc28gdGhlIGJsb2NrIHwgICAgICAgICAgICAgICAgICAgICAgICAgfAorICogICAgICAgVHJhbnNjcmliaW5nIHwgbWFyayBpbiB0aGUgbWV0YWRhdGEuICAgfCAgICAgICAgICAgICAgICAgICAgICAgICB8CisgKiAgICAgICAgICAgICAgICAgICAgfCBDb3B5IHRoZSBibG9jayBtYXJrICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgIHwKKyAqICAgICAgICAgICAgICAgICAgICB8IGludG8gdGhlIGZpcnN0IGJ5dGUgb2YgIHwgICAgICAgICAgICAgICAgICAgICAgICAgfAorICogICAgICAgICAgICAgICAgICAgIHwgdGhlIE9PQi4gICAgICAgICAgICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICB8CisgKiAgICAgICAtLS0tLS0tLS0tLS0tKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSsK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RXUC4gQSBuZWdhdGl2ZSB2YWx1ZQorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5kaWNhdGVzIHRoaXMgY2hhcmFjdGVyaXN0aWMgaXNuJ3Qga25vd24uCisgKiBAZGF0YV9ob2xkX2luX25zOiAgICAgICAgICBUaGUgZGF0YSBob2xkIHRpbWUsIGluIG5hbm9zZWNvbmRzLiBVc3VhbGx5IHRoZQorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4aW11bSBvZiB0REgsIHRXSCBhbmQgdFJFSC4gQSBuZWdhdGl2ZSB2YWx1ZQorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5kaWNhdGVzIHRoaXMgY2hhcmFjdGVyaXN0aWMgaXNuJ3Qga25vd24uCisgKiBAYWRkcmVzc19zZXR1cF9pbl9uczogICAgICBUaGUgYWRkcmVzcyBzZXR1cCB0aW1lLCBpbiBuYW5vc2Vjb25kcy4gVXN1YWxseQorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhlIG1heGltdW0gb2YgdENMUywgdENTIGFuZCB0QUxTLiBBIG5lZ2F0aXZlCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSBpbmRpY2F0ZXMgdGhpcyBjaGFyYWN0ZXJpc3RpYyBpc24ndCBrbm93bi4KKyAqIEBncG1pX3NhbXBsZV9kZWxheV9pbl9uczogIEEgR1BNSS1zcGVjaWZpYyB0aW1pbmcgcGFyYW1ldGVyLiBBIG5lZ2F0aXZlIHZhbHVlCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRpY2F0ZXMgdGhpcyBjaGFyYWN0ZXJpc3RpYyBpc24ndCBrbm93bi4KKyAqIEB0UkVBX2luX25zOiAgICAgICAgICAgICAgIHRSRUEsIGluIG5hbm9zZWNvbmRzLCBmcm9tIHRoZSBkYXRhIHNoZWV0LiBBCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZWdhdGl2ZSB2YWx1ZSBpbmRpY2F0ZXMgdGhpcyBjaGFyYWN0ZXJpc3RpYyBpc24ndAorICogICAgICAgICAgICAgICAgICAgICAgICAgICAga25vd24uCisgKiBAdFJMT0hfaW5fbnM6ICAgICAgICAgICAgICB0UkxPSCwgaW4gbmFub3NlY29uZHMsIGZyb20gdGhlIGRhdGEgc2hlZXQuIEEKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5lZ2F0aXZlIHZhbHVlIGluZGljYXRlcyB0aGlzIGNoYXJhY3RlcmlzdGljIGlzbid0CisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrbm93bi4KKyAqIEB0UkhPSF9pbl9uczogICAgICAgICAgICAgIHRSSE9ILCBpbiBuYW5vc2Vjb25kcywgZnJvbSB0aGUgZGF0YSBzaGVldC4gQQorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmVnYXRpdmUgdmFsdWUgaW5kaWNhdGVzIHRoaXMgY2hhcmFjdGVyaXN0aWMgaXNuJ3QKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtub3duLgorICovCitzdHJ1Y3QgbmFuZF90aW1pbmcgeworCWludDhfdCAgZGF0YV9zZXR1cF9pbl9uczsKKwlpbnQ4X3QgIGRhdGFfaG9sZF9pbl9uczsKKwlpbnQ4X3QgIGFkZHJlc3Nfc2V0dXBfaW5fbnM7CisJaW50OF90ICBncG1pX3NhbXBsZV9kZWxheV9pbl9uczsKKwlpbnQ4X3QgIHRSRUFfaW5fbnM7CisJaW50OF90ICB0UkxPSF9pbl9uczsKKwlpbnQ4X3QgIHRSSE9IX2luX25zOworfTsKKworc3RydWN0IGdwbWlfbmFuZF9kYXRhIHsKKwkvKiBTeXN0ZW0gSW50ZXJmYWNlICovCisJc3RydWN0IGRldmljZQkJKmRldjsKKwlzdHJ1Y3QgcGxhdGZvcm1fZGV2aWNlCSpwZGV2OworCXN0cnVjdCBncG1pX25hbmRfcGxhdGZvcm1fZGF0YQkqcGRhdGE7CisKKwkvKiBSZXNvdXJjZXM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3YXJlX3RpbWluZyB7CisJdWludDhfdCAgZGF0YV9zZXR1cF9pbl9jeWNsZXM7CisJdWludDhfdCAgZGF0YV9ob2xkX2luX2N5Y2xlczsKKwl1aW50OF90ICBhZGRyZXNzX3NldHVwX2luX2N5Y2xlczsKKwlib29sICAgICB1c2VfaGFsZl9wZXJpb2RzOworCXVpbnQ4X3QgIHNhbXBsZV9kZWxheV9mYWN0b3I7Cit9OworCisvKioKKyAqIHN0cnVjdCB0aW1pbmdfdGhyZXNob2QgLSBUaW1pbmcgdGhyZXNob2xkCisgKiBAbWF4X2RhdGFfc2V0dXBfY3ljbGVzOiAgICAgICBUaGUgbWF4aW11bSBudW1iZXIgb2YgZGF0YSBzZXR1cCBjeWNsZXMgdGhhdAorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FuIGJlIGV4cHJlc3NlZCBpbiB0aGUgaGFyZHdhcmUuCisgKiBAaW50ZXJuYWxfZGF0YV9zZXR1cF9pbl9uczogICBUaGUgdGltZSwgaW4gbnMsIHRoYXQgdGhlIE5GQyBoYXJkd2FyZSByZXF1aXJlcworICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIGRhdGEgcmVhZCBpbnRlcm5hbCBzZXR1cC4gSW4gdGhlIFJlZmVyZW5jZQorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTWFudWFsLCBzZWUgdGhlIGNoYXB0ZXIgIkhpZ2gtU3BlZWQgTkFORAorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVGltaW5nIiBmb3IgbW9yZSBkZXRhaWxzLgorICogQG1heF9zYW1wbGVfZGVsYXlfZmFjdG9yOiAgICAgVGhlIG1heGltdW0gc2FtcGxlIGRlbGF5IGZhY3RvciB0aGF0IGNhbiBiZQorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXhwcmVzc2VkIGluIHRoZSBoYXJkd2FyZS4KKyAqIEBtYXhfZGxsX2Nsb2NrX3BlcmlvZF9pbl9uczogIFRoZSBtYXhpbXVtIHBlcmlvZCBvZiB0aGUgR1BNSSBjbG9jayB0aGF0IHRoZQorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2FtcGxlIGRlbGF5IERMTCBoYXJkd2FyZSBjYW4gcG9zc2libHkgd29yaworICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2l0aCAodGhlIERMTCBpcyB1bnVzYWJsZSB3aXRoIGxvbmdlciBwZXJpb2RzKS4KKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIElmIHRoZSBmdWxsLWN5Y2xlIHBlcmlvZCBpcyBncmVhdGVyIHRoYW4gSEFMRgorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcyB2YWx1ZSwgdGhlIERMTCBtdXN0IGJlIGNvbmZpZ3VyZWQgdG8gdXNlCisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYWxmLXBlcmlvZHMuCisgKiBAbWF4X2RsbF9kZWxheV9pbl9uczogICAgICAgICBUaGUgbWF4aW11bSBhbW91bnQgb2YgZGVsYXksIGluIG5zLCB0aGF0IHRoZQorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRExMIGNhbiBpbXBsZW1lbnQuCisgKiBAY2xvY2tfZnJlcXVlbmN5X2luX2h6OiAgICAgICBUaGUgY2xvY2sgZnJlcXVlbmN5LCBpbiBIeiwgZHVyaW5nIHRoZSBjdXJyZW50CisgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJL08gdHJhbnNhY3Rpb24uIElmIG5vIEkvTyB0cmFuc2FjdGlvbiBpcyBpbgorICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvZ3Jlc3MsIHRoaXMgaXMgdGhlIGNsb2NrIGZyZXF1ZW5jeSBkdXJpbmcKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoZSBtb3N0IHJlY2VudCBJL08gdHJhbnNhY3Rpb24uCisgKi8KK3N0cnVjdCB0aW1pbm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Ws7CisKKwlpZih0eXBlLT5uYW1lID09IE5VTEwpCisJeworCQlwcmludGsoInJlYWQgZGV2X2lkIGVycm9yIVxuIik7CisJCXJldHVybiAtMTsKKwl9CQkKKwlzdHJjYXQobmFtZSwgdHlwZS0+bmFtZSk7CisKKwkvKiBUcnkgdG8gaWRlbnRpZnkgbWFudWZhY3R1cmVyICovCisJZm9yIChtYWZfaWR4ID0gMDsgbmFuZF9tYW51Zl9pZHNbbWFmX2lkeF0uaWQgIT0gMHgwOyBtYWZfaWR4KyspIHsKKwkJaWYgKG5hbmRfbWFudWZfaWRzW21hZl9pZHhdLmlkID09ICpmYWNfaWQpCisJCQlicmVhazsKKwl9CisKKwlzdHJjcHkobmFtZSwgbmFuZF9tYW51Zl9pZHNbbWFmX2lkeF0ubmFtZSk7CisJCisJCisJcmV0dXJuIDA7Cit9CitFWFBPUlRfU1lNQk9MX0dQTChuYW5kX2dldF9pbmZvKTsKKworaW50IG5hbmRfZ2V0X2VjY19jYXAoc3RydWN0IG10ZF9pbmZvICptdGQpCit7CisJc3RydWN0IG5hbmRfY2hpcCAqY2hpcCA9IG10ZC0+cHJpdjsKKworCXJldHVybiBjaGlwLT5lY2Muc3RyZW5ndGg7Cit9CitFWFBPUlRfU1lNQk9MX0dQTChuYW5kX2dldF9lY2NfY2FwKTsKKworLyoqIGFkZCBlbmQgKiovCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKworc3RhdGljIGludCBfX2luaXQgbmFuZF9iYXNlX2luaXQodm9pZCkKK3sKKwlsZWRfdHJpZ2dlcl9yZWdpc3Rlcl9zaW1wbGUoIm5hbmQtZGlzayIsICZuYW5kX2xlZF90cmlnZ2VyKTsKKwlyZXR1cm4gMDsKK30KKworc3RhdGljIHZvaWQgX19leGl0IG5hbmRfYmFzZV9leGl0KHZvaWQpCit7CisJbGVkX3RyaWdnZXJfdW5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gKiBhbHNvIHVzZWQgYXMgYSBwZXJmb3JtYW5jZSBpbXByb3ZlbWVudCBmb3IgcnA2LCBycDggYW5kIHJwMTAKKwkgKi8KKwlmb3IgKGkgPSAwOyBpIDwgZWNjc2l6ZV9tdWx0IDw8IDI7IGkrKykgeworCQljdXIgPSAqYnArKzsKKwkJdG1wcGFyID0gY3VyOworCQlycDQgXj0gY3VyOworCQljdXIgPSAqYnArKzsKKwkJdG1wcGFyIF49IGN1cjsKKwkJcnA2IF49IHRtcHBhcjsKKwkJY3VyID0gKmJwKys7CisJCXRtcHBhciBePSBjdXI7CisJCXJwNCBePSBjdXI7CisJCWN1ciA9ICpicCsrOworCQl0bXBwYXIgXj0gY3VyOworCQlycDggXj0gdG1wcGFyOworCisJCWN1ciA9ICpicCsrOworCQl0bXBwYXIgXj0gY3VyOworCQlycDQgXj0gY3VyOworCQlycDYgXj0gY3VyOworCQljdXIgPSAqYnArKzsKKwkJdG1wcGFyIF49IGN1cjsKKwkJcnA2IF49IGN1cjsKKwkJY3VyID0gKmJwKys7CisJCXRtcHBhciBePSBjdXI7CisJCXJwNCBePSBjdXI7CisJCWN1ciA9ICpicCsrOworCQl0bXBwYXIgXj0gY3VyOworCQlycDEwIF49IHRtcHBhcjsKKworCQljdXIgPSAqYnArKzsKKwkJdG1wcGFyIF49IGN1cjsKKwkJcnA0IF49IGN1cjsKKwkJcnA2IF49IGN1cjsKKwkJcnA4IF49IGN1cjsKKwkJY3VyID0gKmJwKys7CisJCXRtcHBhciBePSBjdXI7CisJCXJwNiBePSBjdXI7CisJCXJwOCBePSBjdXI7CisJCWN1ciA9ICpicCsrOworCQl0bXBwYXIgXj0gY3VyOworCQlycDQgXj0gY3VyOworCQlycDggXj0gY3VyOworCQljdXIgPSAqYnArKzsKKwkJdG1wcGFyIF49IGN1cjsKKwkJcnA4IF49IGN1cjsKKworCQljdXIgPSAqYnArKzsKKwkJdG1wcGFyIF49IGN1cjsKKwkJcnA0IF49IGN1cjsKKwkJcnA2IF49IGN1cjsKKwkJY3VyID0gKmJwKys7CisJCXRtcHBhciBePSBjdXI7CisJCXJwNiBePSBjdXI7CisJCWN1ciA9ICpicCsrOworCQl0bXBwYXIgXj0gY3VyOworCQlycDQgXj0gY3VyOworCQljdXIgPSAqYnArKzsKKwkJdG1wcGFyIF49IGN1cjsKKworCQlwYXIgXj0gdG1wcGFyOworCQlpZiAoKGkgJiAweDEpID09IDApCisJCQlycDEyIF49IHRtcHBhcjsKKwkJaWYgKChpICYgMHgyKSA9PSAwKQorCQkJcnAxNCBePSB0bXBwYXI7CisJCWlmIChlY2NzaXplX211bHQgPT0gMiAmJiAoaSAmIDB4NCkgPT0gMCkKKwkJCXJwMTYgXj0gdG1wcGFyOworCX0KKworCS8qCisJICogaGFuZGxlIHRoZSBmYWN0IHRoYXQgd2UgdXNlIGxvbmd3b3JkIG9wZXJhdGlvbnMKKwkgKiB3ZSdsbCBicmluZyBycDQuLnJwMTQuLnJwMTYgYmFjayB0byBzaW5nbGUgYnl0ZSBlbnRpdGllcyBieQorCSAqIHNoaWZ0aW5nIGFuZCB4b3JpbmcgZmlyc3QgZm9sZCB0aGUgdXBwZXIgYW5kIGxvd2VyIDE2IGJpdHMsCisJICogdGhlbiB0aGUgdXBwZXIgYW5kIGxvd2VyIDggYml0cy4KKwkgKi8KKwlycDQgXj0gKHJwNCA+PiAxNik7CisJcnA0IF49IChycDQgPj4gOCk7CisJcnA0ICY9IDB4ZmY7CisJcnA2IF49IChycDYgPj4gMTYpOworCXJwNiBePSAocnA2ID4+IDgpOworCXJwNiAmPSAweGZmOworCXJwOCBePSAocnA4ID4+IDE2KTsKKwlycDggXj0gKHJwOCA+PiA4KTsKKwlycDggJj0gMHhmZjsKKwlycDEwIF49IChycDEwID4+IDE2KTsKKwlycDEwIF49IChycDEwID4+IDgpOworCXJwMTAgJj0gMHhmZjsKKwlycDEyIF49IChycDEyID4+IDE2KTsKKwlycDEyIF49IChycDEyID4+IDgpOworCXJwMTIgJj0gMHhmZj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KiBGaW5hbGx5IGNhbGN1bGF0ZSB0aGUgRUNDIGJpdHMuCisJICogQWdhaW4gaGVyZSBpdCBtaWdodCBzZWVtIHRoYXQgdGhlcmUgYXJlIHBlcmZvcm1hbmNlIG9wdGltaXNhdGlvbnMKKwkgKiBwb3NzaWJsZSwgYnV0IGJlbmNobWFya3Mgc2hvd2VkIHRoYXQgb24gdGhlIHN5c3RlbSB0aGlzIGlzIGRldmVsb3BlZAorCSAqIHRoZSBjb2RlIGJlbG93IGlzIHRoZSBmYXN0ZXN0CisJICovCisjaWZkZWYgQ09ORklHX01URF9OQU5EX0VDQ19TTUMKKwljb2RlWzBdID0KKwkgICAgKGludnBhcml0eVtycDddIDw8IDcpIHwKKwkgICAgKGludnBhcml0eVtycDZdIDw8IDYpIHwKKwkgICAgKGludnBhcml0eVtycDVdIDw8IDUpIHwKKwkgICAgKGludnBhcml0eVtycDRdIDw8IDQpIHwKKwkgICAgKGludnBhcml0eVtycDNdIDw8IDMpIHwKKwkgICAgKGludnBhcml0eVtycDJdIDw8IDIpIHwKKwkgICAgKGludnBhcml0eVtycDFdIDw8IDEpIHwKKwkgICAgKGludnBhcml0eVtycDBdKTsKKwljb2RlWzFdID0KKwkgICAgKGludnBhcml0eVtycDE1XSA8PCA3KSB8CisJICAgIChpbnZwYXJpdHlbcnAxNF0gPDwgNikgfAorCSAgICAoaW52cGFyaXR5W3JwMTNdIDw8IDUpIHwKKwkgICAgKGludnBhcml0eVtycDEyXSA8PCA0KSB8CisJICAgIChpbnZwYXJpdHlbcnAxMV0gPDwgMykgfAorCSAgICAoaW52cGFyaXR5W3JwMTBdIDw8IDIpIHwKKwkgICAgKGludnBhcml0eVtycDldIDw8IDEpICB8CisJICAgIChpbnZwYXJpdHlbcnA4XSk7CisjZWxzZQorCWNvZGVbMV0gPQorCSAgICAoaW52cGFyaXR5W3JwN10gPDwgNykgfAorCSAgICAoaW52cGFyaXR5W3JwNl0gPDwgNikgfAorCSAgICAoaW52cGFyaXR5W3JwNV0gPDwgNSkgfAorCSAgICAoaW52cGFyaXR5W3JwNF0gPDwgNCkgfAorCSAgICAoaW52cGFyaXR5W3JwM10gPDwgMykgfAorCSAgICAoaW52cGFyaXR5W3JwMl0gPDwgMikgfAorCSAgICAoaW52cGFyaXR5W3JwMV0gPDwgMSkgfAorCSAgICAoaW52cGFyaXR5W3JwMF0pOworCWNvZGVbMF0gPQorCSAgICAoaW52cGFyaXR5W3JwMTVdIDw8IDcpIHwKKwkgICAgKGludnBhcml0eVtycDE0XSA8PCA2KSB8CisJICAgIChpbnZwYXJpdHlbcnAxM10gPDwgNSkgfAorCSAgICAoaW52cGFyaXR5W3JwMTJdIDw8IDQpIHwKKwkgICAgKGludnBhcml0eVtycDExXSA8PCAzKSB8CisJICAgIChpbnZwYXJpdHlbcnAxMF0gPDwgMikgfAorCSAgICAoaW52cGFyaXR5W3JwOV0gPDwgMSkgIHwKKwkgICAgKGludnBhcml0eVtycDhdKTsKKyNlbmRpZgorCWlmIChlY2NzaXplX211bHQgPT0gMSkKKwkJY29kZVsyXSA9CisJCSAgICAoaW52cGFyaXR5W3BhciAmIDB4ZjBdIDw8IDcpIHwKKwkJICAgIChpbnZwYXJpdHlbcGFyICYgMHgwZl0gPDwgNikgfAorCQkgICAgKGludnBhcml0eVtwYXIgJiAweGNjXSA8PCA1KSB8CisJCSAgICAoaW52cGFyaXR5W3BhciAmIDB4MzNdIDw8IDQpIHwKKwkJICAgIChpbnZwYXJpdHlbcGFyICYgMHhhYV0gPDwgMykgfAorCQkgICAgKGludnBhcml0eVtwYXIgJiAweDU1XSA8PCAyKSB8CisJCSAgICAzOworCWVsc2UKKwkJY29kZVsyXSA9CisJCSAgICAoaW52cGFyaXR5W3BhciAmIDB4ZjBdIDw8IDcpIHwKKwkJICAgIChpbnZwYXJpdHlbcGFyICYgMHgwZl0gPDwgNikgfAorCQkgICAgKGludnBhcml0eVtwYXIgJiAweGNjXSA8PCA1KSB8CisJCSAgICAoaW52cGFyaXR5W3BhciAm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ioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbmNsdWRlIGZpbGVzCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisgI2luY2x1ZGUgPGxpbnV4L210ZC9tdGQuaD4KKyAjaW5jbHVkZSA8bGludXgvc2xhYi5oPgorICNpbmNsdWRlIDxsaW51eC9tb2R1bGUuaD4KKyAjaW5jbHVkZSA8bGludXgvbXRkL25hbmRfbGludXhfaW50ZXJmYWNlLmg+CisjaW5jbHVkZSA8bGludXgvY3BfdHlwZXMuaD4KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyogCSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBMb2NhbCBUeXBlcworKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyogCSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBMb2NhbCBGdW5jdGlvbiBQcm90b3R5cGVzCisqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworIGV4dGVybiBpbnQgbmFuZF9OdlByb2dyYW0oaW50IGR3U3RhcnQsIGludCBkd0xlbiwgY2hhciogZnJvbSk7CisgZXh0ZXJuIGludCBuYW5kX052UmVhZChpbnQgZHdTdGFydCwgaW50IGR3TGVuLCBjaGFyKiB0byk7CisgZXh0ZXJuIGludCB6ZnRsX3dyYXBwZXJfd3JpdGUoY2hhciAqcGFydF9uYW1lLCBpbnQgZHdTdGFydCwgaW50IGR3TGVuLCBjaGFyKiBmcm9tKTsKKyBleHRlcm4gaW50IHpmdGxfd3JhcHBlcl9yZWFkKGNoYXIgKnBhcnRfbmFtZSwgaW50IGR3U3RhcnQsIGludCBkd0xlbiwgY2hhciogdG8pOworCisjaWZuZGVmIFVTRV9DUFBTX0tPCitleHRlcm4gVUlOVDMyIHpPc3NfTnZJdGVtV3JpdGUoVUlOVDMyIE52SXRlbUlELCBVSU5UOCAqIE52SXRlbURhdGEsIFVJTlQzMiBOdkl0ZW1MZW4pOworZXh0ZXJuIFVJTlQzMiB6T3NzX052SXRlbVJlYWQoVUlOVDMyIE52SXRlbUlELCBVSU5UOCAqIE52SXRlbURhdGEsIFVJTlQzMiBOdkl0ZW1MZW4pOworI2VuZGlmCisgCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorKiAJICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEdsb2JhbCBDb25zdGFudHMKKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisqIAkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgR2xvYmFsIFZhcmlhYmxlcworKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK2V4dGVybiBzdHJ1Y3QgbXRkX2luZm8gKm10ZF9mb3RhOworZXh0ZXJuIGludCBnX3psb2FkX3JlYWRfb25seV9mbGFnOworCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisqIAkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRnVuY3Rpb24gRGVmaW5pdGlvbnMKKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKKyAvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyogRnVuY3Rpb246IG5hbmRfbnZfbWlkX252X3Jfc2V0X3RvX3J3CisqIERlc2NyaXB0aW9uOiAgsNFOVl9StcTWu7bBt9bH+Mno1sPOqr/JtsHQtAorKiBQYXJhbWV0ZXJzOgorKiAgIElucHV0OgorKiAgICAgICAgICAgICAgCisqICAgT3V0cHV0OiBOb25lCisqIFJldHVybnM6CisqCSAgICAgICAgCisqICAgICAgICAgICAgIAorKiBPdGhlcnM6ICAgxKzIz9a1zqogICAgMHgwICDWu7bBCisgICAgICAgICAgICAgICAgICAgICAgICAweDEgILbB0LQKKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyp6ZGQgbmVlZCBtb2RpZnkqLworaW50IHpEcnZOYW5kX0NoYW5nZU52ckF0dHIoIHVuc2lnbmVkIGludCBydyApCit7CisgICAgaW50IHJldCA9IDA7CisgLy8gICByZXQgPSBuYW5kX252X21pZF9yX3NldF90b19ydyhydyk7CisJcmV0dXJuIHJldDsKK30KK0VYUE9SVF9TWU1CT0woekRydk5hbmRfQ2hhbmdlTnZyQXR0cik7CisKKyNpZm5kZWYgQ09ORklHX1NZU1RFTV9SRUNPVkVSWQorIAorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisqIEZ1bmN0aW9uOiB6RHJ2TmFuZF9SZWFkCisqIERlc2NyaXB0aW9uOiAKKyogUGFyYW1ldGVyczoKKyogICBJbnB1dDoKKyogICAgICAgICAgICAgIAorKiAgIE91dHB1dDogTm9uZQorKiBSZXR1cm5zOiAgICAgICAwOiDV/ci3CisgICAgICAgICAgICAgIMbky/s6ILTtzvMKKyoJICAgICAgICAKKyogICAgICAgICAgICAgCisqIE90aGVyczogbnYgtsHIob3Tv9qjrGR3U3RhcnQgtdjWt86qMH41TbXE0OnE4rXY1rcKKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworaW50IHpEcnZOYW5kX1JlYWQodW5zaWduZWQgaW50IGR3U3RhcnQsIHVuc2lnbmVkIGludCBkd0xlbiwgY2hhciogdG8pCit7CisgICAgaW50IHJldCA9IDA7CisKKyNpZmRlZiBVU0VfQ1BQU19LTworCQlyZXQgPSBjcHBzX2NhbGxiYWNrcy56T3NzX052SXRlbVJlYWQoZHdTdGFydCwgdG8sIGR3TGVuKTsKKyNlbHNlCisJCXJldCA9IHpPc3NfTnZJdGVtUmVhZChkd1N0YXJ0LCB0bywgZHdMZW4pOworI2VuZGlmCisKKwlyZXR1cm4gcmV0OworfQorRVhQT1JUX1NZTUJPTCh6RHJ2TmFuZF9SZWFkKTsKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisqIEZ1bmN0aW9uOiB6RHJ2TmFuZF9Qcm9ncmFtCisqIERlc2NyaXB0aW9uOiAKKyogUGFyYW1ldGVyczoKKyogICBJbnB1dDoKKyogICAgICAgICAgICAgIAorKiAgIE91dHB1dDogTm9uZQorKiBSZXR1cm5zOiAgICAgICAwOiDV/ci3CisgICAgICAgICAgICAgIMbky/s6ILTtzvMKKyoJICAgICAgICAKKyogICAgICAgICAgICAgCisqIE90aGVyczogbnYg0LTI673Tv9qjrGR3U3RhcnQgtdjWt86qMX41TbXE0OnE4rXY1rcKKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworaW50IHpEcnZOYW5kX1Byb2dyYW0odW5zaWduZWQgaW50IGR3U3RhcnQsIHVuc2lnbmVkIGludCBkd0xlbiwgY2hhciogZnJvbSkKK3sKKyAgICBpbnQgcmV0ID0gMDsKKworI2lmZGVmIFVTRV9DUFBTX0tPCisJcmV0ID0gY3Bwc19jYWxsYmFja3Muek9zc19Odkl0ZW1SZWFkKGR3U3RhcnQsIGZyb20sIGR3TGVuKTsKKyNlbHNlCisJcmV0ID0gek9zc19Odkl0ZW1SZWFkKGR3U3RhcnQsIGZyb20sIGR3TGVuKTsKKyNlbmRpZgorCisJcmV0dXJuIHJldDsKK30KK0VYUE9SVF9TWU1CT0woekRydk5hbmRfUHJvZ3JhbSk7CisKKyNlbmRpZiAvKiBDT05GSUdfU1lTVEVNX1JFQ09WRVJZICovCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorKiBGdW5jdGlvbjogekRydk5hbmRfU21zUmVhZAorKiBEZXNjcmlwdGlvbjogCisqIFBhcmFtZXRlcnM6CisqICAgSW5wdXQ6CisqICAgICAgICAgICAgICAKKyogICBPdXRwdXQ6IE5vbmUKKyogUmV0dXJuczogICAgICAgMDog1f3ItworICAgICAgICAgICAgICDG5Mv7OiC07c7zCisqCSAgICAgICAgCisqICAgICAgICAgICAgIAorKiBPdGhlcnM6IG52ILbByKG907/ao6xkd1N0YXJ0ILXY1rfOqjB+MU21xNDpxOK12Na3CisqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKy8qemRkIG5lZWQgbW9kaWZ5Ki8KK2ludCB6RHJ2TmFuZF9TbXNSZWFkKHVuc2lnbmVkIGludCBkd1N0YXJ0LCB1bnNpZ25lZCBpbnQgZHdMZW4sIGNoYXIqIHRvKQoreworICAgIGludCByZXQgPSAwOworCisJcmV0ID0gemZ0bF93cmFwcGVyX3JlYWQoKGNoYXIgKikic21zIiwgZHdTdGFydCwgZHdMZW4sIHRvKTsKKyAgICAKKwlyZXR1cm4gcmV0OworfQorRVhQT1JUX1NZTUJPTCh6RHJ2TmFuZF9TbXNSZWFkKTsKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisqIEZ1bmN0aW9uOiB6RHJ2TmFuZF9TbXNQcm9ncmFtCisqIERlc2NyaXB0aW9uOiAKKyogUGFyYW1ldGVyczoKKyogICBJbnB1dDoKKyogICAgICAgICAgICAgIAorKiAgIE91dHB1dDogTm9uZQorKiBSZXR1cm5zOiAgICAgICAwOiDV/ci3CisgICAgICAgICAgICAgIMbky/s6ILTtzvMKKyoJICAgICAgICAKKyogICAgICAgICAgICAgCisqIE90aGVyczogbnYg0LTI673Tv9qjrGR3U3RhcnQgtdjWt86qMH4xTbXE0OnE4rXY1rcKKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyp6ZGQgbmVlZCBtb2RpZnkqLworaW50IHpEcnZOYW5kX1Ntc1Byb2dyYW0odW5zaWduZWQgaW50IGR3U3RhcnQsIHVuc2lnbmVkIGludCBkd0xlbiwgY2hhciogZnJvbSkKK3sKKyAgICBpbnQgcmV0ID0gMDsKKworCXJldCA9IHpmdGxfd3JhcHBlcl93cml0ZSgoY2hhciAqKSJzbXMiLCBkd1N0YXJ0LCBkd0xlbiwgZnJvbSk7CisKKwlyZXR1cm4gcmV0OworfQorRVhQT1JUX1NZTUJPTCh6RHJ2TmFuZF9TbXNQcm9ncmFtKTsKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisqIEZ1bmN0aW9uOiB6RHJ2TmFuZF9OdmZhY1JlYWQKKyogRGVzY3JpcHRpb246IAorKiBQYXJhbWV0ZXJzOgorKiAgIElucHV0OgorKiAgICAgICAgICAgICAgCisqICAgT3V0cHV0OiBOb25lCisqIFJldHVybnM6ICAgICAgIDA6INX9yLcKKyAgICAgICAgICAgICAgxuTL+zogtO3O8worKgkgICAgICAgIAorKiAgICAgICAgICAgICAKKyogT3RoZXJzOiBudiC2wcihvdO/2qOsZHdTdGFydCC12Na3zqowfjFNtcTQ6cTitdjWtworKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKnpkZCBuZWVkIG1vZGlmeSovCitpbnQgekRydk5hbmRfTnZmYWNSZWFkKHVuc2lnbmVkIGludCBkd1N0YXJ0LCB1bnNpZ25lZCBpbnQgZHdMZW4sIGNoYXIqIHRvKQoreworICAgIGludCByZXQgPSAwOworCisJcmV0ID0gemZ0bF93cmFwcGVyX3JlYWQoKGNoYXIgKikibnZmYWMiLCBkd1N0YXJ0LCBkd0xlbiwgdG8pOworICAgIAorCXJldHVybiByZXQ7Cit9CitFWFBPUlRfU1lNQk9MKHpEcnZOYW5kX052ZmFjUmVhZCk7CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorKiBGdW5jdGlvbjogekRydk5hbmRfTnZmYWNQcm9ncmFtCisqIERlc2NyaXB0aW9uOiAKKyogUGFyYW1ldGVyczoKKyogICBJbnB1dDoKKyogICAgICAgICAgICAgIAorKiAgIE91dHB1dDogTm9uZQorKiBSZXR1cm5zOiAgICAgICAwOiDV/ci3CisgICAgICAgICAgICAgIMbky/s6ILTtzvMKKyoJICAgICAgICAKKyogICAgIC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AgICAgICAgICDG5Mv7OiC07c7zCisqCSAgICAgICAgCisqICAgICAgICAgICAgIAorKiBPdGhlcnM6IAorKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitpbnQgekRydk5hbmRfTnZSd0VjY01ha2UodW5zaWduZWQgaW50IGR3U3RhcnQsIHVuc2lnbmVkIGludCBkd0xlbikKK3sKKyAgICBjaGFyIGJ1ZmZlclsyMDQ4XTsKKwkKKwkvL2lmKCBkd1N0YXJ0ID49IE5WUldfU0laRXx8ZHdTdGFydCA8IDAgfHwgKGR3U3RhcnQgK2R3TGVuKT4gTlZSV19TSVpFfHwgZHdMZW4gPiAyMDQ4KQorICAgLy8gICAgIHJldHVybiAtMTsKKy8vZnlpCW5hbmRfbnZyd19taWRfZWNjX21ha2UoZHdTdGFydCxkd0xlbixidWZmZXIpOworCXJldHVybiAwOworfQorRVhQT1JUX1NZTUJPTCh6RHJ2TmFuZF9OdlJ3RWNjTWFrZSk7CisKK2ludCB6RHJ2TmFuZF9FY2NNYWtlKGNoYXIqIHBhcnROYW1lLHVuc2lnbmVkIGludCBkd1N0YXJ0LCB1bnNpZ25lZCBpbnQgZHdMZW4pCit7CisJcmV0dXJuIDA7Cit9CitFWFBPUlRfU1lNQk9MKHpEcnZOYW5kX0VjY01ha2UpOworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyogRnVuY3Rpb246IG5hbmRfUmVhZElECisqIERlc2NyaXB0aW9uOiBnZXQgZmxhc2ggSUQKKyogUGFyYW1ldGVyczoKKyogICBJbnB1dDoKKyogICAgICAgICAgICAgIHBieURldmljZTogcG9pbnRlciBvZiBmbGFzaCBJRCBzdHJ1Y3R1cmUKKyogICBPdXRwdXQ6IE5vbmUKKyogUmV0dXJuczoKKyoJICAgICAgICBOQU5EX09LOiBzdWNjZXNzCisqICAgICAgICAgICAgIDE6IGVycm9yCisqIE90aGVyczogzsS8/s+1zbO907/ao6zU3cqxz8iyu8q1z9YgMjAxMy41LjcKKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworaW50IG5hbmRfUmVhZElEKFRfWkRydk5hbmRfRGV2aWNlSUQgKnBieURldmljZSkKK3sKKyAgICByZXR1cm4gMDsKK30KK0VYUE9SVF9TWU1CT0wobmFuZF9SZWFkSUQpOworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyogRnVuY3Rpb246IHpEcnZOYW5kX1BhcnRSZWFkCisqIERlc2NyaXB0aW9uOnJlYWQgbmFuZCBiYXNlIHBhcnRpdGlvbi4KKyogUGFyYW1ldGVyczoKKyogICBJbnB1dDpOb25lCisqIE91dHB1dDogTm9uZQorKiBSZXR1cm5zOk5vbmUKKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworaW50IHpEcnZOYW5kX1BhcnRSZWFkKGNoYXIqIHBhcnRfbmFtZSx1bnNpZ25lZCBpbnQgb2Zmc2V0LHVuc2lnbmVkIGludCBzaXplLGNoYXIqIGJ1ZmZlcikKK3sKKwlyZXR1cm4gMDsKK30KK0VYUE9SVF9TWU1CT0woekRydk5hbmRfUGFydFJlYWQpOworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyogRnVuY3Rpb246IHpEcnZOYW5kX1BhcnRHZXRTaXplCisqIERlc2NyaXB0aW9uOmdldCBuYW5kIHBhcnRpdGlvbiBzaXplLgorKiBQYXJhbWV0ZXJzOgorKiAgIElucHV0Ok5vbmUKKyogT3V0cHV0OiBOb25lCisqIFJldHVybnM6Tm9uZQorKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCit1bnNpZ25lZCBpbnQgekRydk5hbmRfUGFydEdldFNpemUoY2hhciogcGFydF9uYW1lKQoreworCXJldHVybiAwOworfQorRVhQT1JUX1NZTUJPTCh6RHJ2TmFuZF9QYXJ0R2V0U2l6ZSk7CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBGdW5jdGlvbjogIHpEcnZOYW5kX1JlYWRCb290ZmxhZworICogRGVzY3JpcHRpb246IHJlYWQgdGhlIGJvb3RmbGFnIG9mIHp4Mjk3NTEwCisgKiBQYXJhbWV0ZXJzOiAKKyAqICAgSW5wdXQ6CisgKgorICogICBPdXRwdXQ6CisgKgorICogUmV0dXJuczogMDogb3BlbiBkbCB1c2IKKyAqICAgICAgICAgIDE6IGNsb3NlIGRsIHVzYgorICoKKyAqIE90aGVyczogMHhmZmZmZmZmZl9mZmZmZmZmZjogVVNCIERMOyAKKyAqICAgICAgICAgIlpURTc1MTBcMCIgICAgICAgIDogTk8gVVNCIERMCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCit1bnNpZ25lZCBpbnQgekRydk5hbmRfUmVhZEJvb3RmbGFnKCB2b2lkICkKK3sKKyAgICB1bnNpZ25lZCBpbnQgYm9vdGZsYWcgPSAwOworCQorCWNoYXIgdmFsdWUgPSAwOworICAgIGludCByZXRsZW4gPSAwOworICAgIAorICAgIHVuc2lnbmVkIGNoYXIgKmJ1ZmZlciA9IGttYWxsb2MoKG10ZF9mb3RhLT53cml0ZXNpemUgKyBtdGRfZm90YS0+b29ic2l6ZSksIEdGUF9LRVJORUwpOworICAgIGlmKCBidWZmZXIgPT0gTlVMTCApCisgICAgICAgIHJldHVybiAtMTsKKworICAgIGlmKG10ZF9yZWFkKG10ZF9mb3RhLDAsbXRkX2ZvdGEtPndyaXRlc2l6ZSwmcmV0bGVuLGJ1ZmZlcikpLyogQk9PVEZMQUfU2m5hbmS1xLXaMjB+MjfX1r3aICovCisgICAgeworICAgICAgICBrZnJlZShidWZmZXIpOworICAgICAgICByZXR1cm4gMTsKKyAgICB9CisJbWVtY3B5KCZ2YWx1ZSwgYnVmZmVyKzIsIDEpOyAKKwlib290ZmxhZyA9IHZhbHVlOworICAgCisgICAgaWYoIGJvb3RmbGFnID09IDB4NWEpCisgICAgeworICAgICAgICBib290ZmxhZyA9IDE7CisgICAgfQorCWVsc2UKKwl7CisgICAgICAgIGJvb3RmbGFnID0gMDsKKwl9CisgICAga2ZyZWUoYnVmZmVyKTsKKworCXJldHVybiBib290ZmxhZzsKK30KK0VYUE9SVF9TWU1CT0woekRydk5hbmRfUmVhZEJvb3RmbGFnKTsKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIEZ1bmN0aW9uOiAgekRydk5hbmRfV3JpdGVCb290ZmxhZworICogRGVzY3JpcHRpb246IHdyaXRlIHRoZSBib290ZmxhZyBvZiB6eDI5NzUxMAorICogUGFyYW1ldGVyczogCisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6MCBzdWNjZXNzCisgKiAgICAgICAgIDEgZmFpbAorICoKKyAqCisgKiBPdGhlcnM6IDB4ZmZmZmZmZmZfZmZmZmZmZmY6IFVTQiBETDsgCisgKiAgICAgICAgICJaVEU3NTEwXDAiICAgICAgICA6IE5PIFVTQiBETAorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwordW5zaWduZWQgaW50IHpEcnZOYW5kX1dyaXRlQm9vdG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9mbGFnID0gMTsKKyAgICByZXQgPSBtdGRfZXJhc2UobXRkX2ZvdGEsICZlaSk7ICAgICAgICAgICAgICAgICAgLyqywbP9tdrSu7/pKi8KKwlyZXQgPSBtdGRfd3JpdGUobXRkX2ZvdGEsMCw2KiBtdGRfZm90YS0+d3JpdGVzaXplLCZyZXRsZW4sYnVmZmVyKTsKKwlnX3psb2FkX3JlYWRfb25seV9mbGFnID0gMDsKKyAgICBrZnJlZShidWZmZXIpOworCisgICAgcmV0dXJuIDA7CisKK30KK0VYUE9SVF9TWU1CT0woekRydk5hbmRfV3JpdGVCb290ZmxhZyk7CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBGdW5jdGlvbjogIHpEcnZOYW5kX1JlYWRVc2J0aW1lb3V0CisgKiBEZXNjcmlwdGlvbjogcmVhZCB0aGUgdXNidGltZW91dCBmbGFnIG9mIHp4Mjk3NTEwCisgKiBQYXJhbWV0ZXJzOiAKKyAqICAgSW5wdXQ6CisgKgorICogICBPdXRwdXQ6CisgKgorICogUmV0dXJuczogZmxhZzp1c2IgdGltZSBvdXQgKDF+MTApCisgKgorICoKKyAqIE90aGVyczogCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCit1bnNpZ25lZCBpbnQgekRydk5hbmRfUmVhZFVzYnRpbWVvdXQoIHZvaWQgKQoreworCisgICAgdW5zaWduZWQgaW50IHVzYnRpbWVvdXQgPSAwOworCWNoYXIgdmFsdWUgPSAwOworICAgIGludCByZXRsZW4gPSAwOworICAgIAorICAgIHVuc2lnbmVkIGNoYXIgKmJ1ZmZlciA9IGttYWxsb2MoKG10ZF9mb3RhLT53cml0ZXNpemUgKyBtdGRfZm90YS0+b29ic2l6ZSksIEdGUF9LRVJORUwpOworICAgIGlmKCBidWZmZXIgPT0gTlVMTCApCisgICAgICAgIHJldHVybiAtMTsKKworICAgIGlmKG10ZF9yZWFkKG10ZF9mb3RhLDAsbXRkX2ZvdGEtPndyaXRlc2l6ZSwmcmV0bGVuLGJ1ZmZlcikpLyogQk9PVEZMQUfU2m5hbmS1xLXaMjB+MjfX1r3aICovCisgICAgeworICAgICAgICBrZnJlZShidWZmZXIpOworICAgICAgICByZXR1cm4gLTE7CisgICAgfQorCW1lbWNweSgmdmFsdWUsIGJ1ZmZlciszLCAxKTsgCisJdXNidGltZW91dCA9IHZhbHVlOworCQorICAgIGtmcmVlKGJ1ZmZlcik7CisJcmV0dXJuIHVzYnRpbWVvdXQ7ICAgCisKK30KK0VYUE9SVF9TWU1CT0woekRydk5hbmRfUmVhZFVzYnRpbWVvdXQpOworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogRnVuY3Rpb246ICB6RHJ2TmFuZF9Xcml0ZVVzYnRpbWVvdXQKKyAqIERlc2NyaXB0aW9uOiB3cml0ZSB0aGUgdXNidGltZW91dCBmbGFnIG9mIHp4Mjk3NTEwCisgKiBQYXJhbWV0ZXJzOiAKKyAqICAgSW5wdXQ6ZmxhZyAoMX4xMCkKKyAqCisgKiAgIE91dHB1dDoKKyAqCisgKiBSZXR1cm5zOiAKKyAqCisgKgorICogT3RoZXJzOiAKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3Vuc2lnbmVkIGludCB6RHJ2TmFuZF9Xcml0ZVVzYnRpbWVvdXQoIHVuc2lnbmVkIGludCBmbGFnICkKK3sKKworICAgIHVuc2lnbmVkIGludCByZXQgPSAwOworCWNoYXIgb29iWzI1Nl07CisJaW50IGkgPTA7CisJaW50IHRpbWVzID0gMDsKKwlpbnQgcmV0bGVuID0gMDsKKwljaGFyIHZhbHV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cml0ZVVzYnRpbWVvdXQpOworCisjaWYgMAorCit1bnNpZ25lZCBpbnQgekRydk5hbmRfUmVhZFpsb2FkZXJBbmRQYXJ0aXRpb24oY2hhciAqYnVmZmVyLHVuc2lnbmVkIGludCBsZW4pCit7CisgICAgaW50IHJldGxlbiA9IDA7CisgICAgaW50IGRhdGFfbGVuID0gOCoxMDI0Oy8vOEsKKyAgICB1bnNpZ25lZCBjaGFyICpkYXRhX2J1ZmZlciA9IGttYWxsb2MoZGF0YV9sZW4sIEdGUF9LRVJORUwpOworCisgICAgaWYoIGRhdGFfYnVmZmVyID09IE5VTEwgKQorICAgICAgICByZXR1cm4gLTE7CisKKyAgICBpZihtdGRfcmVhZChtdGRfZm90YSwwLGRhdGFfbGVuLCZyZXRsZW4sZGF0YV9idWZmZXIpKQorICAgIHsKKyAgICAgICAga2ZyZWUoZGF0YV9idWZmZXIpOworICAgICAgICByZXR1cm4gLTE7CisgICAgfQorCisgICAgIG1lbWNweShidWZmZXIsZGF0YV9idWZmZXIsZGF0YV9sZW4pOworICAgIGtmcmVlKGRhdGFfYnVmZmVyKTsKKyAgICAKKyAgICByZXR1cm4gMDsKK30KKwordW5zaWduZWQgaW50IHpEcnZOYW5kX1dyaXRlWmxvYWRlckFuZFBhcnRpdGlvbihjaGFyICpidWZmZXIsdW5zaWduZWQgaW50IGxlbikKK3sKKworICAgIGludCByZXRsZW4gPSAwOworICAgIGludCByZXQgPSAwOworICAgIHN0cnVjdCBlcmFzZV9pbmZvIGVpOworICAgIC8vY2xlYXIgemVybyBpcyBtdXN0CisgICAgbWVtc2V0KCZlaSwgMCwgc2l6ZW9mKHN0cnVjdCBlcmFzZV9pbmZvKSk7CisgICAgZWkubXRkICA9IG10ZF9mb3RhOworICAgIGVpLmFkZHIgPSAwOworICAgIGVpLmxlbiAgPSBtdGRfZm90YS0+ZXJhc2VzaXplOworICAgIHJldCA9IG10ZF9lcmFzZShtdGRfZm90YSwgJmVpKTsgICAgICAgICAgICAgICAgICAvKrLBs/212tK7v+kqLworCisgICAgcmV0ID0gbXRkX3dyaXRlKG10ZF9mb3RhLDAsOCoxMDI0LCZyZXRsZW4sYnVmZmVyKTsKKworICAgIHJldHVybiByZXQ7CisJCit9CisKKyB1bnNpZ25lZCBpbnQgekRydk5hbmRfR2V0Rmxhc2hJZChjaGFyICpidWZlcikKKyB7CisKKyAgICAgICBpZihidWZlcj09TlVMTCkKKyAgICAgICB7CisgICAgICAgICAgICAgIHJldHVybiAtMTsKKyAgICAgICB9CisJICAgCisgLy9meWkgICAgICAgIGJ1ZmVyWzBdID0gZ2V0X21hZl9pZCgpOworLy9meWkJICBidWZlclsxXSA9IGdldF9kZXZfaWQoKTsKKwkgIHJldHVybiAwOworIH0KKyAKKyB1bnNpZ25lZCBpbnQgIHpEcnZOYW5kX0dldEVDT1ZlcigpCisgeyAgIAorIC8vZnlpICAgIHJldHVybiBnZXRfZWNvX2ZsYWcoKTsKKyB9CisgCisgdW5zaWduZWQgaW50ICB6RHJ2TmFuZF9JZlN1cHBvcnQ4Yml0RUNDKCkKKyB7CisJaW50IGVjY19iaXRzOworIC8vZnlpICAgICAgZWNjX2JpdHMgPSBnZXRfZWNjX2JpdHMoKTsKKwkgaWYoZWNjX2JpdHMgPT0gOCkKKwkgeworCQkgcmV0dXJuIDE7CisJIH0KKwkgZWxzZQorCSB7CisJCSByZXR1cm4gMDsKKwkgfQorIH0KKyNlbmRpZgorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisqIEZ1bmN0aW9uOiB6RHJ2TmFuZF9QYXJ0TXRkT3BlbgorKiBEZXNjcmlwdGlvbjpnZXQgbmFuZCBwYXJhbWV0ZXJzIGZvciBGT1RBLgorKiBQYXJhbWV0ZXJzOgorKiAgIElucHV0Ok5vbmUKKyogT3V0cHV0OiBOb25lCisqIFJldHVybnM6Tm9uZQorKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitpbnQgekRydk5hbmRfUGFydE10ZE9wZW4oY2hhciogcGFydF9uYW1lLCBUX05hbmRfUGFydF9JbmZvICpwTmFuZFBhcnRJbmZvKQoreworCXJldHVybiAwOworfQorRVhQT1JUX1NZTUJPTCh6RHJ2TmFuZF9QYXJ0TXRkT3Blbik7CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorKiBGdW5jdGlvbjogekRydk5hbmRfUGFydE10ZFJlYWQKKyogRGVzY3JpcHRpb246cmVhZCBkYXRhIGZvciBGT1RBLgorKiBQYXJhbWV0ZXJzOgorKiAgIElucHV0Ok5vbmUKKyogT3V0cHV0OiBOb25lCisqIFJldHVybnM6Tm9uZQorKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitpbnQgekRydk5hbmRfUGFydE10ZFJlYWQoVF9OYW5kX1BhcnRfSW5mbyAqcE5hbmRQYXJ0SW5mbyx1bnNpZ25lZCBpbnQJZHdBZGRyLCB1bnNpZ25lZCBpbnQJZHdMZW4sIGNoYXIgKnBieUJ1ZikKK3sKKwlyZXR1cm4gMDsKK30KK0VYUE9SVF9TWU1CT0woekRydk5hbmRfUGFydE10ZFJlYWQpOworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyogRnVuY3Rpb246IHpEcnZOYW5kX1BhcnRNdGRXcml0ZQorKiBEZXNjcmlwdGlvbjpyZWFkIGRhdGEgZm9yIEZPVEEuCisqIFBhcmFtZXRlcnM6CisqICAgSW5wdXQ6Tm9uZQorKiBPdXRwdXQ6IE5vbmUKKyogUmV0dXJuczpOb25lCisqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK2ludCB6RHJ2TmFuZF9QYXJ0TXRkV3JpdGUoVF9OYW5kX1BhcnRfSW5mbyAqcE5hbmRQYXJ0SW5mbyx1bnNpZ25lZCBpbnQJZHdBZGRyLCB1bnNpZ25lZCBpbnQJZHdMZW4sIGNoYXIgKnBieUJ1ZikKK3sKKwlyZXR1cm4gMDsKK30KK0VYUE9SVF9TWU1CT0woekRydk5hbmRfUGFydE10ZFdyaXRlKTsKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisqIEZ1bmN0aW9uOiB6RHJ2TmFuZF9QYXJ0TXRkRXJhc2UKKyogRGVzY3JpcHRpb246ZXJhc2UgZGF0YSBmb3IgRk9UQS4KKyogUGFyYW1ldGVyczoKKyogICBJbnB1dDpOb25lCisqIE91dHB1dDogTm9uZQorKiBSZXR1cm5zOk5vbmUKKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworaW50IHpEcnZOYW5kX1BhcnRNdGRFcmFzZShUX05hbmRfUGFydF9JbmZvICpwTmFuZFBhcnRJbmZvLHVuc2lnbmVkIGludCBkd0FkZHIpCit7CisJcmV0dXJuIDA7Cit9CitFWFBPUlRfU1lNQk9MKHpEcnZOYW5kX1BhcnRNdGRFcmFzZSk7CisKKy8qRk9UQSBVUERBVEUgSU5URVJGQUNFICBFTkQqLworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyogRnVuY3Rpb246IHpEcnZOYW5kX0luaXRpYXRlCisqIERlc2NyaXB0aW9uOmluaXRpYWxpemUgbmFuZCBmb3IgaGFsX2luaXQuYworKiBQYXJhbWV0ZXJzOgorKiAgIElucHV0Ok5vbmUKKyogT3V0cHV0OiBOb25lCisqIFJldHVybnM6Tm9uZQorKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitpbnQgekRydk5hbmRfSW5pdGlhdGUoVk9JRCkKK3sgCisKKyAgICBpbnQgcmV0ID0gMDsKKwkKKyAgICAvL3JldCA9IHpEcnZOYW5kX0luaXRpYWxpemUoKTsKKyAgICAvL25hbmRfU2V0SW5zdGFuY2UoKTsKKworICAgIHJldHVybiByZXQ7Cit9CisKK2ludCBuYW5kX2ludGVyX3JlYWQodW5zaWduZWQgaW50IGR3U3RhcnQsIHVuc2lnbmVkIGludCBkd0xlbiwgY2hhciogdG8pCit7CisgICAgaW50IHJldCA9IDA7CisJaW50IHJldGxlbiA9IDA7CisJCisJcmV0ID0gbXRkX3JlYWQobXRkX2ZvdGEsZHdTdGFydCxkd0xlbiwmcmV0bGVuLHRvKTsKKworICAgIHJldHVybiByZXQ7Cit9CitFWFBPUlRfU1lNQk9MKG5hbmRfaW50ZXJfcmVhZCk7CisKK2ludCBuYW5kX2ludGVyX3Byb2dyYW0odW5zaWduZWQgaW50IGR3U3RhcnQsIHVuc2lnbmVkIGludCBkd0xlbiwgY2hhciogZnJvbSkKK3sKKyAgICBpbnQgcmV0ID0gMDsKKwlpbnQgcmV0bGVuID0gMDsKKwkKKwlyZXQgPSBtdGRfd3JpdGUobXRkX2ZvdGEsZHdTdGFydCxkd0xlbiwmcmV0bGVuLGZyb20pOworCisgICAgcmV0dXJuIHJldDsKK30KK0VYUE9SVF9TWU1CT0wobmFuZF9pbnRlcl9wcm9ncmFtKTsKKworaW50IG5hbmRfaW50ZXJfZXJhc2UodW5zaWduZWQgaW50IGR3U3RhcnQpCit7CisgICAgaW50IHJldCA9IDA7CisJc3RydWN0IGVyYXNlX2luZm8gZWk7CisKKwltZW1zZXQoJmVpLCAwLCBzaXplb2Yoc3RydWN0IGVyYXNlX2luZm8pKTsKKyAgICBlaS5tdGQ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4gY29tcDJfYml0WzBdOworCWVjY19iaXRbMjNdID0gdG1wMl9iaXRbMV0gXiBjb21wMl9iaXRbMV07CisKKwlmb3IgKGkgPSAwOyBpIDwgMjQ7IGkrKykKKwkJZWNjX3N1bSArPSBlY2NfYml0W2ldOworCisJc3dpdGNoIChlY2Nfc3VtKSB7CisJY2FzZSAwOgorCQkvKiBOb3QgcmVhY2hlZCBiZWNhdXNlIHRoaXMgZnVuY3Rpb24gaXMgbm90IGNhbGxlZCBpZgorCQkgKiAgRUNDIHZhbHVlcyBhcmUgZXF1YWwKKwkJICovCisJCXJldHVybiAwOworCisJY2FzZSAxOgorCQkvKiBVbmNvcnJlY3RhYmxlIGVycm9yICovCisJCXByX2RlYnVnKCJFQ0MgVU5DT1JSRUNURURfRVJST1IgMVxuIik7CisJCXJldHVybiAtMTsKKworCWNhc2UgMTE6CisJCS8qIFVOLUNvcnJlY3RhYmxlIGVycm9yICovCisJCXByX2RlYnVnKCJFQ0MgVU5DT1JSRUNURURfRVJST1IgQlxuIik7CisJCXJldHVybiAtMTsKKworCWNhc2UgMTI6CisJCS8qIENvcnJlY3RhYmxlIGVycm9yICovCisJCWZpbmRfYnl0ZSA9IChlY2NfYml0WzIzXSA8PCA4KSArCisJCQkgICAgKGVjY19iaXRbMjFdIDw8IDcpICsKKwkJCSAgICAoZWNjX2JpdFsxOV0gPDwgNikgKworCQkJICAgIChlY2NfYml0WzE3XSA8PCA1KSArCisJCQkgICAgKGVjY19iaXRbMTVdIDw8IDQpICsKKwkJCSAgICAoZWNjX2JpdFsxM10gPDwgMykgKworCQkJICAgIChlY2NfYml0WzExXSA8PCAyKSArCisJCQkgICAgKGVjY19iaXRbOV0gIDw8IDEpICsKKwkJCSAgICBlY2NfYml0WzddOworCisJCWZpbmRfYml0ID0gKGVjY19iaXRbNV0gPDwgMikgKyAoZWNjX2JpdFszXSA8PCAxKSArIGVjY19iaXRbMV07CisKKwkJcHJfZGVidWcoIkNvcnJlY3Rpbmcgc2luZ2xl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gZWNjWzNdID4+IDYpICYgMHgwMDMpIHwgKCgodWludDE2X3QpIGVjY1s0XSA8PCAyKSAmIDB4M2ZjKV07CisJcGFyWzFdID0gcnNfZGVjb2Rlci0+aW5kZXhfb2ZbKCgodWludDE2X3QpIGVjY1s1XSA+PiAwKSAmIDB4MGZmKSB8ICgoKHVpbnQxNl90KSBlY2NbNl0gPDwgOCkgJiAweDMwMCldOworCXBhclswXSA9ICgoKHVpbnQxNl90KSBlY2NbNl0gPj4gMikgJiAweDAzZikgfCAoKCh1aW50MTZfdCkgZWNjWzddIDw8IDYpICYgMHgzYzApOworCisJLyogQ29udmVydCB0byBjb21wdXRhYmxlIHN5bmRyb21lICovCisJZm9yIChpID0gMDsgaSA8IDY7IGkrKykgeworCQlzeW5baV0gPSBwYXJbMF07CisJCWZvciAoaiA9IDE7IGogPCA2OyBqKyspCisJCQlpZiAocGFyW2pdICE9IHJzX2RlY29kZXItPm5uKQorCQkJCXN5bltpXSBePSByc19kZWNvZGVyLT5hbHBoYV90b1tyc19tb2Rubihyc19kZWNvZGVyLCBwYXJbal0gKyBpICogaildOworCisJCS8qIENvbnZlcnQgdG8gaW5kZXggZm9ybSAqLworCQlzeW5baV0gPSByc19kZWNvZGVyLT5pbmRleF9vZltzeW5baV1dOworCX0KKworCS8qIExldCB0aGUgbGlicmFyeSBjb2RlIGRvIGl0cyBtYWdpYy4gKi8KKwlyZXMgPSBkZWNvZGVfcnM4KHJzX2RlY29kZXIsICh1aW50OF90ICopIGJ1ZiwgcGFyLCA1MTIsIHN5biwgMCwgTlVMTCwgMHhmZiwgTlVMTCk7CisJaWYgKHJlcyA+IDApIHsKKwkJcHJfZGVidWcoInJ0Y19mcm9tNF9jb3JyZWN0X2RhdGE6ICIgIkVDQyBjb3JyZWN0ZWQgJWQgZXJyb3JzIG9uIHJlYWRcbiIsIHJlcyk7CisJfQorCXJldHVybiByZXM7Cit9CisKKy8qKgorICogcnRjX2Zyb200X2VycnN0YXQgLSBwZXJmb3JtIG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JhdGVzIGJvYXJkIik7CmRpZmYgLS1naXQgYS9hcC9vcy9saW51eC9saW51eC0zLjQueC9kcml2ZXJzL210ZC9uYW5kL3NwaV9uYW5kLmMgYi9hcC9vcy9saW51eC9saW51eC0zLjQueC9kcml2ZXJzL210ZC9uYW5kL3NwaV9uYW5kLmMKbmV3IGZpbGUgbW9kZSAxMDA3NTUKaW5kZXggMDAwMDAwMC4uZTFhYzgyMQotLS0gL2Rldi9udWxsCisrKyBiL2FwL29zL2xpbnV4L2xpbnV4LTMuNC54L2RyaXZlcnMvbXRkL25hbmQvc3BpX25hbmQuYwpAQCAtMCwwICsxLDk3MiBAQAorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorIENvcHlyaWdodCAyMDE0IGJ5ICBaVEUgQ29ycG9yYXRpb24uCisqCisqIEZpbGVOYW1lOjogICAgc3BpX25hbmQuYworKiBGaWxlIE1hcms6CisqIERlc2NyaXB0aW9uOgorKiBPdGhlcnM6CisqIFZlcnNpb246CisqIEF1dGhvcjoKKyogRGF0ZToKKworKiBIaXN0b3J5IDE6CisqICAgICBEYXRlOgorKiAgICAgVmVyc2lvbjoKKyogICAgIEF1dGhvcjoKKyogICAgIE1vZGlmaWNhdGlvbjoKKyogSGlzdG9yeSAyOgorKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKyNpbmNsdWRlIDxsaW51eC9pbnRlcnJ1cHQuaD4KKyNpbmNsdWRlIDxsaW51eC9kZWxheS5oPgorI2luY2x1ZGUgPGxpbnV4L2RtYS1tYXBwaW5nLmg+CisjaW5jbHVkZSA8bGludXgvd2FpdC5oPgorI2luY2x1ZGUgPGxpbnV4L211dGV4Lmg+CisjaW5jbHVkZSA8bGludXgvc2xhYi5oPgorI2luY2x1ZGUgPGxpbnV4L210ZC9tdGQuaD4KKyNpbmNsdWRlIDxs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7fQorI2VuZGlmCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBGdW5jdGlvbjogICAgc3BpX25hbmRfcmVhZF9ieXRlCisgKiBEZXNjcmlwdGlvbjoKKyAqIFBhcmFtZXRlcnM6CisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3N0YXRpYyB1aW50OF90IHNwaV9uYW5kX3JlYWRfYnl0ZShzdHJ1Y3QgbXRkX2luZm8gKm10ZCkKK3sKKyAgICBzdHJ1Y3Qgc3BpX25hbmRfaW5mbyAqc3BpX25hbmQgPSBtdGRfdG9fc3BpX25hbmQobXRkKTsKKyAgICB1aW50OF90IHJlc3VsdCA9IDB4ZmY7CisKKyAgICBpZiAoc3BpX25hbmQtPmJ1Zi5oZWFkIDwgc3BpX25hbmQtPmJ1Zi50YWlsKQorICAgIHsKKyAgICAgICAgcmVzdWx0ID0gc3BpX25hbmQtPmJ1Zi5idWZbc3BpX25hbmQtPmJ1Zi5oZWFkKytdOworICAgIH0KKworICAgIHJldHVybiByZXN1bHQ7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBGdW5jdGlvbjogICAgcmVzZXRfYnVmCisgKiBEZXNjcmlwdGlvbjoKKyAqIFBhcmFtZXRlcnM6CisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3N0YXRpYyB2b2lkIHJlc2V0X2J1ZihzdHJ1Y3Qgc3BpX25hbmRfaW5mbyAqc3BpX25hbmQpCit7CisgICAgc3BpX25hbmQtPmJ1Zi5oZWFkID0gc3BpX25hbmQtPmJ1Zi50YWlsID0gMDsKK30KKworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogRnVuY3Rpb246ICAgIHdyaXRlX2J5dGVfdG9fYnVmCisgKiBEZXNjcmlwdGlvbjoKKyAqIFBhcmFtZXRlcnM6CisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3N0YXRpYyB2b2lkIHdyaXRlX2J5dGVfdG9fYnVmKHN0cnVjdCBzcGlfbmFuZF9pbmZvICpzcGlfbmFuZCwgdWludDhfdCBieXRlKQoreworICAgIEJVR19PTihzcGlfbmFuZC0+YnVmLnRhaWwgPj0gU1BJX05BTkRfQlVGX1NJWkUpOy8vc2l6ZW9mKHNwaV9uYW5kLT5idWYuYnVmKSk7CisgICAgc3BpX25hbmQtPmJ1Zi5idWZbc3BpX25hbmQtPmJ1Zi50YWlsKytdID0gYnl0ZTsKK30KKworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogRnVuY3Rpb246ICAgIHJlYWRfc3RhdHVzCisgKiBEZXNjcmlwdGlvbjoKKyAqIFBhcmFtZXRlcnM6CisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3N0YXRpYyB2b2lkIHJlYWRfc3RhdHVzKHN0cnVjdCBzcGlfbmFuZF9pbmZvICpzcGlfbmFuZCkKK3sKKyAgICB1aW50MzJfdCBzdGF0dXM7CisgICAgc3RhdHVzID0gMFg4MDsKKyAgICBzcGlfbmFuZF9kZWJ1ZygiW1NQSS1OQU5EXVtyZWFkX3N0YXR1c11cbiIpOworICAgIHdyaXRlX2J5dGVfdG9fYnVmKHNwaV9uYW5kLCBzdGF0dXMpOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogRnVuY3Rpb246ICAgIHNwaV9uYW5kX3JlYWRfd29yZAorICogRGVzY3JpcHRpb246IG5hbmRfYmxvY2tfYmFk0KPIoW9vYs+iKG5hbmRfY2hpcC0+b29iX3BvaSnHsDLX1r3aCisgKiBQYXJhbWV0ZXJzOgorICogICBJbnB1dDoKKyAqCisgKiAgIE91dHB1dDoKKyAqCisgKiBSZXR1cm5zOgorICoKKyAqCisgKiBPdGhlcnM6CisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitzdGF0aWMgdWludDE2X3Qgc3BpX25hbmRfcmVhZF93b3JkKHN0cnVjdCBtdGRfaW5mbyAqbXRkKQoreworICAgIHN0cnVjdCBuYW5kX2NoaXAgKmNoaXAgPSBtdGQtPnByaXY7CisgICAgdWludDE2X3QgcmVzdWx0ID0gMHgwOworCisgICAgcmVzdWx0ID0gKHVpbnQxNl90KSgqKGNoaXAtPm9vYl9wb2kpKTsKKyAgICByZXN1bHQgPSByZXN1bHQgPDwgODsKKyAgICByZXN1bHQgfD0gKHVpbnQxNl90KSgqKGNoaXAtPm9vYl9wb2kgKyAxKSk7CisKKyAgICByZXR1cm4gcmVzdWx0OworfQorCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBGdW5jdGlvbjogICAgc3BpX25hbmRfc2VsZWN0X2NoaXAKKyAqIERlc2NyaXB0aW9uOgorICogUGFyYW1ldGVyczoKKyAqICAgSW5wdXQ6CisgKgorICogICBPdXRwdXQ6CisgKgorICogUmV0dXJuczoKKyAqCisgKgorICogT3RoZXJzOgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIHZvaWQgc3BpX25hbmRfc2VsZWN0X2NoaXAoc3RydWN0IG10ZF9pbmZvICptdGQsIGludCBjaGlwKQoreworfQorCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBGdW5jdGlvbjogICAgc3BpX25hbmRfd2FpdGZ1bmMKKyAqIERlc2NyaXB0aW9uOgorICogUGFyYW1ldGVyczoKKyAqICAgSW5wdXQ6CisgKgorICogICBPdXRwdXQ6CisgKgorICogUmV0dXJuczoKKyAqCisgKgorICogT3RoZXJzOgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIGludCBzcGlfbmFuZF93YWl0ZnVuYyhzdHJ1Y3QgbXRkX2luZm8gKm10ZCwgc3RydWN0IG5hbmRfY2hpcCAqY2hpcCkKK3sKKyAgICBzdHJ1Y3Qgc3BpX25hbmRfaW5mbyAqc3BpX25hbmQgPSBtdGRfdG9fc3BpX25hbmQobXRkKTsKKworICAgIGludCBzdGF0dXMgPSBzcGlfbmFuZC0+c3RhdHVzOworICAgIHNwaV9uYW5kLT5zdGF0dXMgPSAwOworCisgICAgcmV0dXJuIHN0YXR1czsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIEZ1bmN0aW9uOiAgICBzcGlfbmFuZF9nZXRfcmVhbF9wYWdlCisgKiBEZXNjcmlwdGlvbjogCisgKiBQYXJhbWV0ZXJzOgorICoJIElucHV0OgorICoKKyAqCSBPdXRwdXQ6CisgKgorICogUmV0dXJuczoKKyAqCisgKgorICogT3RoZXJzOgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIGludCBzcGlfbmFuZF9nZXRfcmVhbF9wYWdlKHN0cnVjdCBtdGRfaW5mbyAqbXRkLCBpbnQgcGFnZSkKK3sKKyAgICBzdHJ1Y3Qgc3BpX25hbmRfaW5mbyAqc3BpX25hbmQgPSBtdGRfdG9fc3BpX25hbmQobXRkKTsKKwlzdHJ1Y3Qgc3BpX25hbmRfY3RybF9vcHMgKmN0cmwgPSBzcGlfbmFuZC0+Y3RybDsKKwlpbnQgZGllOworCisJaWYoc3BpX25hbmQtPnBhcmEtPmRpZV9udW0gPT0gMSkKKwkJcmV0dXJuIHBhZ2U7CisKKwlkaWUgPSBwYWdlL3NwaV9uYW5kLT5wYWdlc19wZXJfZGllOworCWlmKGN0cmwtPnN3aXRjaF9kaWUoZGllKSkKKwkJcmV0dXJuIC0xOworCisJcmV0dXJuIChwYWdlLWRpZSpzcGlfbmFuZC0+cGFnZXNfcGVyX2RpZSk7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBGdW5jdGlvbjogICAgc3BpX25hbmRfZXJhc2UKKyAqIERlc2NyaXB0aW9uOgorICogUGFyYW1ldGVyczoKKyAqICAgSW5wdXQ6CisgKgorICogICBPdXRwdXQ6CisgKgorICogUmV0dXJuczoKKyAqCisgKgorICogT3RoZXJzOgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIHZvaWQgc3BpX25hbmRfZXJhc2Uoc3RydWN0IG10ZF9pbmZvICptdGQsIGludCBwYWdlKQoreworICAgIGludCByZXQgPSAwOworICAgIHN0cnVjdCBzcGlfbmFuZF9pbmZvICpzcGlfbmFuZCA9IG10ZF90b19zcGlfbmFuZChtdGQpOworCXN0cnVjdCBzcGlfbmFuZF9jdHJsX29wcyAqY3RybCA9IHNwaV9uYW5kLT5jdHJsOwkKKwlpbnQgcmVhbF9wYWdlID0gc3BpX25hbmRfZ2V0X3JlYWxfcGFnZShtdGQsIHBhZ2UpOworCisgICAgc3BpX25hbmRfZGVidWcoIlxuW1NQSS1OQU5EXVtzcGlfbmFuZF9lcmFzZV1bcGFnZV0gPSAweCUweFxuIiwgcGFnZSk7CisKKwlyZXQgPSBjdHJsLT53cml0ZV9lbmFibGUoKTsKKyAgICBpZiAoIHJldCAhPSAwICkKKyAgICB7CisgICAgICAgIHByaW50aygiW1NQSS1OQU5EXVtzcGlfZmNfd3JpdGVfZW5hYmxlXVtFUlJPUl1cbiIpOworICAgICAgICAKKyAgICB9CisKKyAgICByZXQgPSBjdHJsLT5lcmFzZShyZWFsX3BhZ2UpOworICAgIGlmICggcmV0ICE9IDAgKQorICAgIHsKKyAgICAgICAgc3BpX25hbmQtPnN0YXR1cyA9IE5BTkRfU1RBVFVTX0ZBSUw7CisgICAgICAgIHByaW50aygiW1NQSS1OQU5EXVtzcGlfbmFuZF9lcmFzZV1bTkFORF9TVEFUVVNfRkFJTF1bcmV0XSA9ICVkXG4iLCByZXQpOworICAgIH0KKyAgICBlbHNlCisgICAgeworICAgICAgICBzcGlfbmFuZC0+c3RhdHVzID0gMDsKKyAgICAgICAgc3BpX25hbmRfZGVidWcoIltTUEktTkFORF1bc3BpX25hbmRfZXJhc2VdW1BBU1NdXG4iKTsKKyAgICB9CisKKwlyZXQgPSBjdHJsLT53cml0ZV9kaXNhYmxlKCk7CisgICAgaWYgKCByZXQgIT0gMCApCisgICAgeworICAgICAgICBwcmludGsoIltTUEktTkFORF1bc3BpX2ZjX3dyaXRlX2Rpc2FibGVdW0VSUk9SXVxuIik7CisgICAgICAgIAorICAgIH0KK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIEZ1bmN0aW9uOiAgICBzcGlfbmFuZF9jbWRmdW5jCisgKiBEZXNjcmlwdGlvbjoKKyAqIFBhcmFtZXRlcnM6CisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3N0YXRpYyB2b2lkIHNwaV9uYW5kX2NtZGZ1bmMoc3RydWN0IG10ZF9pbmZvICptdGQsIHVuc2lnbmVkIGludCBjbWQsIGludCBjb2wsCisgICAgICAgICAgICAgICAgICAgICAgICAgIGludCBwYWdlKQoreworICAgIHN0cnVjdCBzcGlfbmFuZF9pbmZvICpzcGlfbmFuZCA9IG10ZF90b19zcGlfbmFuZChtdGQpOworCXN0cnVjdCBzcGlfbmFuZF9jdHJsX29wcyAqY3RybCA9IHNwaV9uYW5kLT5jdHJsOworCisgICAgc3dpdGNoIChjbWQpCisgICAgeworICAgICAgICBjYXNlIE5BTkRfQ01EX1BBR0VQUk9HOgorICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgTkFORF9DTURfU1RBVFVTOgorICAgICAgICAgICAgcmVzZXRfYnVmKHNwaV9uYW5kKTsKKyAgICAgICAgICAgIHJlYWRfc3RhdHVzKHNwaV9uYW5kKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIE5BTkRfQ01EX1JFQURJRDoKKyAgICAgICAgY2FzZSBOQU5EX0NNRF9QQVJBTToKKwkJCQorICAgICAgICAgICAgcmVzZXRfYnVmKHNwaV9uYW5kKTsKKyAgICAgICAgICAgIHdyaXRlX2J5dGVfdG9fYnVmKHNwaV9uYW5kLCBzcGlfbmFuZC0+bWFmX2lkKTsKKwkJCXByaW50aygiW1NQSS1OQU5EXTogIG1hZl9pZCA9IDB4JTB4XG4iLCBzcGlfbmFuZC0+bWFmX2lkKTsKKyAgICAgICAgICAgIHdyaXRlX2J5dGVfdG9fYnVmKHNwaV9uYW5kLCBzcGlfbmFuZC0+ZGV2X2lkKTsKKwkJCXByaW50aygiW1NQSS1OQU5EXTogIGRldl9pZCA9IDB4JTB4XG4iLCBzcGlfbmFuZC0+ZGV2X2lkKTsKKworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgTkFORF9DTURfUkVBRDA6CisgICAgICAgIGNhc2UgTkFORF9DTURfU0VRSU46CisgICAgICAgICAgICBzcGlfbmFuZC0+cGFnZSA9IHBhZ2U7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBOQU5EX0NNRF9SRVNFVDoKKwkJCWN0cmwtPnJlc2V0KCk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBOQU5EX0NNRF9SRUFET09COgorICAgICAgICAgICAgcmVzZXRfYnVmKHNwaV9uYW5kKTsgICAgICAvL3pob3VxaQorICAgICAgICAgICAgc3BpX25hbmRfcmVhZF9vb2IobXRkLCBtdGQtPnByaXYsIHBhZ2UsIDApOworICAgICAgICAgICAgLyogVE9ETzogUmVhZCBPT0IgZGF0YSAqLworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICBwcmludGsoIjogdW5zdXBwb3J0ZWQgY29tbWFuZCIKKyAgICAgICAgICAgICAgICAgICIgcmVjZWl2ZWQgMHgleFxuIiwgY21kKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgIH0KK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIEZ1bmN0aW9uOiAgICBzcGlfbmFuZF9lY2NfY2FsY3VsYXRlCisgKiBEZXNjcmlwdGlvbjoKKyAqIFBhcmFtZXRlcnM6CisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3N0YXRpYyBpbnQgc3BpX25hbmRfZWNjX2NhbGN1bGF0ZShzdHJ1Y3QgbXRkX2luZm8gKm10ZCwgY29uc3QgdWludDhfdCAqZGF0YSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aW50OF90ICplY2NfY29kZSkKK3sKKyAgICBwcmludGsoInNwaV9uYW5kX2VjY19jYWxjdWxhdGUgY2FsbGVkIHVuZXhwZWN0ZWRseVxuIik7CisgICAgCisgICAgcmV0dXJuIC0xOworfQorCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBGdW5jdGlvbjogICAgc3BpX25hbmRfZWNjX2NvcnJlY3QKKyAqIERlc2NyaXB0aW9uOgorICogUGFyYW1ldGVyczoKKyAqICAgSW5wdXQ6CisgKgorICogICBPdXRwdXQ6CisgKgorICogUmV0dXJuczoKKyAqCisgKgorICogT3RoZXJzOgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIGludCBzcGlfbmFuZF9lY2NfY29ycmVjdChzdHJ1Y3QgbXRkX2luZm8gKm10ZCwgdWludDhfdCAqZGF0YSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdWludDhfdCAqcmVhZF9lY2MsIHVpbnQ4X3QgKmNhbGNfZWNjKQoreworICAgIHByaW50aygic3BpX25hbmRfZWNjX2NvcnJlY3QgY2FsbGVkIHVuZXhwZWN0ZWRseVxuIik7CisgICAgCisgICAgcmV0dXJuIC0xOworfQorCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBGdW5jdGlvbjogICAgc3BpX25hbmRfZWNjX2h3Y3RsCisgKiBEZXNjcmlwdGlvbjoKKyAqIFBhcmFtZXRlcnM6CisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3N0YXRpYyB2b2lkIHNwaV9uYW5kX2VjY19od2N0bChzdHJ1Y3QgbXRkX2luZm8gKm10ZCwgaW50IG1vZGUpCit7CisgICAgcHJpbnRrKCJzcGlfbmFuZF9lY2NfaHdjdGwgY2FsbGVkIHVuZXhwZWN0ZWRseVxuIik7CisgICAgCit9CisKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIEZ1bmN0aW9uOiAgICBzcGlfbmFuZF9jaGVja19lY2MKKyAqIERlc2NyaXB0aW9uOgorICogUGFyYW1ldGVyczoKKyAqICAgSW5wdXQ6CisgKgorICogICBPdXRwdXQ6CisgKgorICogUmV0dXJuczoKKyAqCisgKgorICogT3RoZXJzOgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIGludCBzcGlfbmFuZF9jaGVja19lY2Moc3RydWN0IHNwaV9uYW5kX2luZm8gKnNwaV9uYW5kLCB1aW50MzJfdCAqZWNjKQoreworICAgIGludCByZXQgPSAwOworICAgIHVpbnQ4X3QgZmVhdHVyZSA9IDB4MDsKKworICAgIHJldCA9IHNwaV9uYW5kLT5jdHJsLT5nZXRfZmVhdHVyZShSRUdfU1RBVFVTLCAmZmVhdHVyZSk7CisKKyAgICBzcGlfbmFuZF9kZWJ1ZygiW1NQSS1OQU5EXVtjaGVja19lY2NdW2ZlYXR1cmVdID0gMHglMHggKCVkKVxuIiwgZmVhdHVyZSwgcmV0KTsKKworICAgIGlmICggKChmZWF0dXJlPj5FQ0NfRVJSX0JJVCkgJiAweDMpID09IDIgKQorICAgIHsKKyAgICAgICAgLyogcHJpbnRrKCJbU1BJLU5BTkRdW1JFR19TVEFUVVNdW0VDQy1FUlJPUl1cbiIpOyovCisgICAgICAgICplY2MgPSAxOwkJLyogZWNjIGVycm9yIGRldGVjdCBhbmQgbm8gY29ycmVjdCAqLworICAgIH0KKyAgICBlbHNlCisgICAgeworICAgICAgICAqZWNjID0gMDsKKyAgICB9CisKKyAgICByZXR1cm4gcmV0OworfQorCitzdGF0aWMgaW50IHNwaV9uYW5kX3dyaXRlKHN0cnVjdCBtdGRfaW5mbyAqbXRkLCBpbnQgcmF3LCAKKwkJCQkJCQljb25zdCB1bnNpZ25lZCBjaGFyICpidWYsIHVuc2lnbmVkIGNoYXIgKm9vYl9idWYpIAoreworCWludCByZXQgPSAwOworICAgIHN0cnVjdCBzcGlfbmFuZF9pbmZvICpzcGlfbmFuZCA9IG10ZF90b19zcGlfbmFuZChtdGQpOworCXN0cnVjdCBzcGlfbmFuZF9jdHJsX29wcyAqY3RybCA9IH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kKKwlpZiAoIHJldCAhPSAwICkKKwl7CisJCXByaW50aygiW1NQSS1OQU5EXVtzcGlmY19wYWdlX2xvYWRdW0VSUk9SXVxuIik7CisJCQorCX0KKwlkbWFfc3luY19zaW5nbGVfZm9yX2NwdShzcGlfbmFuZC0+ZGV2LCBzcGlfbmFuZC0+YnVmLmRtYV9idWYsIG10ZC0+b29ic2l6ZSwgRE1BX0JJRElSRUNUSU9OQUwpOworCisJcmV0ID0gY3RybC0+cHJvZ3JhbV9leGVjKHBhZ2UpOworCWlmICggcmV0ICE9IDAgKQorCXsKKwkJc3BpX25hbmQtPnN0YXR1cyA9IE5BTkRfU1RBVFVTX0ZBSUw7CisJCXByaW50aygiW1NQSS1OQU5EXVtzcGlfZmNfcHJvZ3JhbV9leGVjXVtOQU5EX1NUQVRVU19GQUlMXVtyZXRdID0gJWRcbiIsIHJldCk7CisJCQorCX0KKwllbHNlCisJeworCQlzcGlfbmFuZC0+c3RhdHVzID0gMDsKKwkJc3BpX25hbmRfZGVidWcoIltTUEktTkFORF1bd3JpdGVfcGFnZV1bUEFTU11cbiIpOworCX0KKworCXJldCA9IGN0cmwtPndyaXRlX2Rpc2FibGUoKTsKKwlpZiAoIHJldCAhPSAwICkKKwl7CisJCXByaW50aygiW1NQSS1OQU5EXVtzcGlfZmNfd3JpdGVfZGlzYWJsZV1bRVJST1JdXG4iKTsKKwkJCisJfQorCQorCXJldHVybiByZXQ7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBGdW5jdGlvbjogICAgc3BpX25hbmRfd3JpdGVfcGFnZQorICogRGVzY3JpcHRpb246CisgKgorICogUGFyYW1ldGVyczoKKyAqICAgSW5wdXQ6CisgKgorICogICBPdXRwdXQ6CisgKgorICogUmV0dXJuczoKKyAqCisgKgorICogT3RoZXJzOgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIHZvaWQgc3BpX25hbmRfd3JpdGVfcGFnZShzdHJ1Y3QgbXRkX2luZm8gKm10ZCwgc3RydWN0IG5hbmRfY2hpcCAqY2hpcCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdWludDhfdCAqYnVmLCBzdHJ1Y3QgbXRkX29vYl9vcHMgKm9wcykKK3sKKwlzcGlfbmFuZF93cml0ZShtdGQsIGZhbHNlLCBidWYsIGNoaXAtPm9vYl9wb2kpOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogRnVuY3Rpb246ICAgIHNwaV9uYW5kX3dyaXRlX3BhZ2VfcmF3CisgKiBEZXNjcmlwdGlvbjogTVREIEludGVyZmFjZSCyu8q5xNwgRUNDLCDQtCBNQUlOICsgT09CCisgKgorICogUGFyYW1ldGVyczoKKyAqICAgSW5wdXQ6CisgKgorICogICBPdXRwdXQ6CisgKgorICogUmV0dXJuczoKKyAqCisgKgorICogT3RoZXJzOgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIHZvaWQgc3BpX25hbmRfd3JpdGVfcGFnZV9yYXcoc3RydWN0IG10ZF9pbmZvICptdGQsIHN0cnVjdCBuYW5kX2NoaXAgKmNoaXAsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1aW50OF90ICpidWYpCit7CisJc3BpX25hbmRfZW5hYmxlX2VjYyhtdGQsIGZhbHNlKTsKKwlzcGlfbmFuZF93cml0ZShtdGQsIHRydWUsIGJ1ZiwgY2hpcC0+b29iX3BvaSk7CisJc3BpX25hbmRfZW5hYmxlX2VjYyhtdGQsIHRydWUpOwkKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIEZ1bmN0aW9uOiAgICBzcGlfbmFuZF93cml0ZV9vb2IKKyAqIERlc2NyaXB0aW9uOgorICogUGFyYW1ldGVyczoKKyAqICAgSW5wdXQ6CisgKgorICogICBPdXRwdXQ6CisgKgorICogUmV0dXJuczoKKyAqCisgKgorICogT3RoZXJzOgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIGludCBzcGlfbmFuZF93cml0ZV9vb2Ioc3RydWN0IG10ZF9pbmZvICptdGQsIHN0cnVjdCBuYW5kX2NoaXAgKmNoaXAsCisgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgcGFnZSkKK3sKKyAgICBzdHJ1Y3Qgc3BpX25hbmRfaW5mbyAqc3BpX25hbmQgPSBtdGRfdG9fc3BpX25hbmQobXRkKTsKKworICAgIHNwaV9uYW5kLT5wYWdlPXBhZ2U7CisgICAgCisJcmV0dXJuIHNwaV9uYW5kX3dyaXRlKG10ZCwgZmFsc2UsIE5VTEwsIGNoaXAtPm9vYl9wb2kpOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogRnVuY3Rpb246ICAgIHNwaV9uYW5kX3JlYWRfb29iCisgKiBEZXNjcmlwdGlvbjoKKyAqIFBhcmFtZXRlcnM6CisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3N0YXRpYyBpbnQgc3BpX25hbmRfcmVhZF9vb2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bnQ4X3QgKilzcGlfbmFuZC0+YnVmLmRtYV9idWYpOworICAgIGlmICggcmV0ICE9IDAgKQorICAgIHsKKyAgICAgICAgcHJpbnRrKCJbU1BJLU5BTkRdW3NwaV9mY19yZWFkX3BhZ2VfdG9fY2FjaGVdXG4iKTsKKyAgICAgICAgCisgICAgfQorCisJZG1hX3N5bmNfc2luZ2xlX2Zvcl9jcHUoc3BpX25hbmQtPmRldiwgc3BpX25hbmQtPmJ1Zi5kbWFfYnVmLCBtdGQtPm9vYnNpemUsIERNQV9CSURJUkVDVElPTkFMKTsJCisgICAgbWVtY3B5KGNoaXAtPm9vYl9wb2ksICh2b2lkKikoc3BpX25hbmQtPmJ1Zi5idWYpLCBtdGQtPm9vYnNpemUpOworCisgICAgcmV0dXJuIDA7Cit9CisKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIEZ1bmN0aW9uOiAgICBzcGlfbmFuZF9yZWFkX3BhZ2UKKyAqIERlc2NyaXB0aW9uOgorICogUGFyYW1ldGVyczoKKyAqICAgSW5wdXQ6CisgKgorICogICBPdXRwdXQ6CisgKgorICogUmV0dXJuczoKKyAqCisgKgorICogT3RoZXJzOgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIGludCBzcGlfbmFuZF9yZWFkX3BhZ2Uoc3RydWN0IG10ZF9pbmZvICptdGQsIHN0cnVjdCBuYW5kX2NoaXAgKmNoaXAsCisgICAgICAgICAgICAgICAgICAgICAgICAgICB1aW50OF90ICpidWYsIC8qaW50IG9vYl9yZXF1aXJlZCwqL2ludCBwYWdlLCBzdHJ1Y3QgbXRkX29vYl9vcHMgKm9wcykKK3sKKyAgICBpbnQgcmV0ID0gMDsKKyAgICB1aW50MzJfdCBlY2MgPSAwOworICAgIHN0cnVjdCBzcGlfbmFuZF9pbmZvICpzcGlfbmFuZCA9IG10ZF90b19zcGlfbmFuZChtdGQpOworCXN0cnVjdCBzcGlfbmFuZF9jdHJsX29wcyAqY3RybCA9IHNwaV9uYW5kLT5jdHJsOworCWludCByZWFsX3BhZ2U7IAorCXVuc2lnbmVkIGludCAgY29sdW1uX29mZnNldCA9IDA7CisJCisgICAgc3BpX25hbmRfZGVidWcoIltTUEktTkFORF1bc3BpX25hbmRfcmVhZF9wYWdlXVtwYWdlXSA9IDB4JTB4XG4iLCBwYWdlKTsKKworICAgIGlmIChwYWdlICE9IHNwaV9uYW5kLT5wYWdlKQorICAgIHsKKyAgICAgICAgcHJpbnRrKCJJTiAlczogcGFnZSAlZCBpcyBub3QiCisgICAgICAgICAgICAgICIgZXF1YWwgdG8gZGVuYWxpLT5wYWdlICVkLCBpbnZlc3RpZ2F0ZSEhIiwKKyAgICAgICAgICAgICAgX19mdW5jX18sIHBhZ2UsIHNwaV9uYW5kLT5wYWdlKTsKKyAgICAgICAgCisgICAgfQorCisJcmVhbF9wYWdlID0gc3BpX25hbmRfZ2V0X3JlYWxfcGFnZShtdGQsIHBhZ2UpOworCisgICAgcmV0ID0gY3RybC0+cmVhZF9wYWdlX3RvX2NhY2hlKHJlYWxfcGFnZSk7CisgICAgaWYgKCByZXQgIT0gMCApCisgICAgeworICAgICAgICBwcmludGsoIltTUEktTkFORF1bc3BpX2ZjX3JlYWRfcGFnZV90b19jYWNoZV1cbiIpOworICAgICAgICAKKyAgICB9CisKKyAgICByZXQgPSBzcGlfbmFuZF9jaGVja19lY2Moc3BpX25hbmQsICZlY2MpOworICAgIGlmICggcmV0ICE9IDAgKQorICAgIHsKKyAgICAgICAgcHJpbnRrKCJbU1BJLU5BTkRdW3NwaV9uYW5kX2NoZWNrX2VjY11cbiIpOworICAgICAgICAKKyAgICB9CisgICAgaWYgKCBlY2MgIT0gMCApCisgICAgeworCQlnX2N1cl9lY2NfcGFnZV9hZGRyID0gcmVhbF9wYWdlK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gMDsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIEZ1bmN0aW9uOiAgICBzcGlfbmFuZF9yZWFkX3BhZ2VfcmF3CisgKiBEZXNjcmlwdGlvbjogsrvKucTcRUNDo6y2wcihIE1BSU4gKyBPT0IKKyAqIFBhcmFtZXRlcnM6CisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3N0YXRpYyBpbnQgc3BpX25hbmRfcmVhZF9wYWdlX3JhdyhzdHJ1Y3QgbXRkX2luZm8gKm10ZCwgc3RydWN0IG5hbmRfY2hpcCAqY2hpcCwKKwkJCQl1aW50OF90ICpidWYsIGludCBwYWdlKQoreworCWludCByZXQgPSAwOworCQorCXNwaV9uYW5kX2VuYWJsZV9lY2MobXRkLCBmYWxzZSk7CisJcmV0ID0gIHNwaV9uYW5kX3JlYWRfcGFnZShtdGQsIGNoaXAsIGJ1ZiwgcGFnZSwgTlVMTCk7CisJc3BpX25hbmRfZW5hYmxlX2VjYyhtdGQsIHRydWUpOworCisJcmV0dXJuIHJldDsKK30KKworI2RlZmluZSBFQ0NfNEJJVFMgICAzMgorc3RhdGljIHVpbnQ4X3QgYmJ0X3BhdHRlcm5bXSA9IHsnQicsICdiJywgJ3QnLCAnMCcgfTsKK3N0YXRpYyB1aW50OF90IG1pcnJvcl9wYXR0ZXJuW10gPSB7JzEnLCAndCcsICdiJywgJ0InIH07CisKK3N0YXRpYyBzdHJ1Y3QgbmFuZF9iYnRfZGVzY3IgYmJ0X21haW5fZGVzY3IgPQoreworICAgIC5vcHRpb25zID0gTkFORF9CQlRfTEFTVEJMT0NLIHwgTkFORF9CQlR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HVybiAtRU5YSU87CisJfQorCQorCW10ZF9mb3RhID0gbXRkOworCQorCXJldCA9IG10ZF9kZXZpY2VfcmVnaXN0ZXIobXRkLCBOVUxMLCAwKTsKKwlpZiAocmV0KSB7CisJCWRldl9lcnIoc3BpX25hbmQtPmRldiwgIlNwZWN0cmE6IEZhaWxlZCB0byByZWdpc3RlciBNVEQ6ICVkXG4iLAorCQkJCXJldCk7CisJfQorCisJcmV0dXJuIHJldDsKK30KKwpkaWZmIC0tZ2l0IGEvYXAvb3MvbGludXgvbGludXgtMy40LngvZHJpdmVycy9tdGQvbmFuZC9zcGlfbmFuZC5oIGIvYXAvb3MvbGludXgvbGludXgtMy40LngvZHJpdmVycy9tdGQvbmFuZC9zcGlfbmFuZC5oCm5ldyBmaWxlIG1vZGUgMTAwNzU1CmluZGV4IDAwMDAwMDAuLmIyOGU1MWIKLS0tIC9kZXYvbnVsbAorKysgYi9hcC9vcy9saW51eC9saW51eC0zLjQueC9kcml2ZXJzL210ZC9uYW5kL3NwaV9uYW5kLmgKQEAgLTAsMCArMSwyNDIgQEAKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyBDb3B5cmlnaHQgMjAxNCBieSAgWlRFIENvcnBvcmF0aW9uLgorKgorKiBGaWxlTmFtZTo6ICAgIHNwaV9uYW5kLmgKKyogRmlsZSBNYXJrOgorKiBEZXNjcmlwdGlvbjoKKyogT3RoZXJzOgorKiBWZXJzaW9uOgorKiBBdXRob3I6CisqIERhdGU6CisKKyogSGlzdG9yeSAxOgorKiAgICAgRGF0ZTogMjAxNC4xLjE1CisqICAgICBWZXJzaW9uOgorKiAgICAgQXV0aG9yOiB6aG91cWkKKyogICAgIE1vZGlmaWNhdGlvbjoKKyogSGlzdG9yeSAyOgorKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworI2lmbmRlZiBfX1NQSV9OQU5EX0hfXworI2RlZmluZSBfX1NQSV9OQU5EX0hfXworCisjaW5jbHVkZSA8bGludXgvbXRkL25hbmQuaD4KKworI2RlZmluZSBTUElfTkFORF9SRVRSSUUgICAgICAgICAgICAgMworI2RlZmluZSBTVUNDRVNTICAgICAgICAgICAgICAgICAgICAgMAorCisKKyNkZWZpbmUgIFNQSV9OQU5EX0RFQlVHICAgMAorCisvKiBmZnNkZWZzLmggKi8KKyNkZWZpbmUgQ0xFQVIgMCAgICAgICAgICAgICAgICAgLyp1c2UgdGhpcyB0byBjbGVhciBhIGZpZWxkIGluc3RlYWQgb2YgImZhaWwiKi8KKyNkZWZpbmUgU0VUICAgMSAgICAgICAgICAgICAgICAgLyp1c2UgdGhpcyB0byBzZXQgYSBmaWVsZCBpbnN0ZWFkIG9mICJwYXNzIiovCisjZGVmaW5lIEZBSUwgMSAgICAgICAgICAgICAgICAgIC8qZmFpbGVkIGZsYWcqLworI2RlZmluZSBQQVNTIDAgICAgICAgICAgICAgICAgICAvKnN1Y2Nlc3MgZmxhZyovCisjZGVmaW5lIEVSUiAtMSAgICAgICAgICAgICAgICAgIC8qZXJyb3IgZmxhZyovCisKKyNkZWZpbmUgWlg3NTEwIDMKKworLyogU1BJIE5BTkQgQ01EICovCisjZGVmaW5lIENNRF9XUklURV9FTkFCTEUgICAgICAgICAgICAgMHgwNgorI2RlZmluZSBDTURfV1JJVEVfRElTQUJMRSAgICAgICAgICAgIDB4MDQKKworI2RlZmluZSBDTURfR0VUX0ZFQVRVUkUgICAgICAgICAgICAgIDB4MEYKKyNkZWZpbmUgQ01EX1NFVF9GRUFUVVJFICAgICAgICAgICAgICAweDFGCisKKyNkZWZpbmUgQ01EX1JFQURfUEFHRV9UT19DQUNIRSAgICAgICAweDEzCisjZGVmaW5lIENNRF9SRUFEX0ZST01fQ0FDSEUgICAgICAgICAgMHgwMworLy8jZGVmaW5lIENNRF9SRUFEX0ZST01fQ0FDSEVfWDIgICAgICAgMHgzQgorI2RlZmluZSBDTURfUkVBRF9GUk9NX0NBQ0hFX1g0ICAgICAgIDB4NkIKKyNkZWZpbmUgQ01EX1JFQURfRlJPTV9DQUNIRV9RSU8gICAgICAweEVCCisKKyNkZWZpbmUgQ01EX1JFQURfSUQgICAgICAgICAgICAgICAgICAweDlGCisjZGVmaW5lIElEX0FERFIwICAgICAgICAgICAgICAgICAgICAgMHgwMCAgLyptYW51ZmFjdHVyZSBpZCBhZGRyZXNzKi8KKyNkZWZpbmUgSURfQUREUjEgICAgICAgICAgICAgICAgICAgICAweDAxICAvKmRldmljZSBpZCBhZGRyZXNzKi8KKworI2RlZmluZSBDTURfUFJPR1JBTV9MT0FEICAgICAgICAgICAgIDB4MDIKKyNkZWZpbmUgQ01EX1BST0dSQU1fTE9BRF9YNCAgICAgICAgICAweDMyCisjZGVmaW5lIENNRF9QUk9HUkFNX0VYRUNVVEUgICAgICAgICAgMHgxMAorLy8jZGVmaW5lIENNRF9QUk9HUkFNX0xPQURfUkFORE9NICAgICAgMHg4NAorLy8jZGVmaW5lIENNRF9QUk9HUkFNX0xPQURfUkFORE9NX1g0ICAgMHhDNAorLy8jZGVmaW5lIENNRF9QUk9HUkFNX0xPQURfUkFORE9NX1FJTyAgMHg3MgorCisjZGVmaW5lIENNRF9CTE9DS19FUkFTRSAgICAgICAgICAgICAgMHhEOAorCisjZGVmaW5lIENNRF9SRVNFVCAgICAgICAgICAgICAgICAgICAgMHhGRgorCisjZGVmaW5lIENNRF9XSU5CT05EX0RJRV9TV0lUQ0gJCTB4QzIKKworI2RlZmluZSBTSU5HTEVfTU9ERSAgMAorLy8jZGVmaW5lIERVQUxfTU9ERSAgIDEKKyNkZWZpbmUgUkRYNF9NT0RFICAgIDIKKyNkZWZpbmUgUkRRSU9fTU9ERSAgIDMKKyNkZWZpbmUgUExYNF9NT0RFICAgIDQKKworLypyZWFkIGFuZCB3cml0ZSBtb2RlIGNvbmZpZ3VyYXRpb24qLworLy8jZGVmaW5lIFJEX01PREUgIFJEWDRfTU9ERQorI2RlZmluZSBSRF9NT0RFICBSRFFJT19NT0RFCisvLyNkZWZpbmUgUkRfTU9ERSAgU0lOR0xFX01PREUKKyNkZWZpbmUgV1JfTU9ERSAgUExYNF9NT0RFCisKKyNkZWZpbmUJUkVBRF9UUkFOU0ZFUl9NT0RFCQkwCisjZGVmaW5lCVdSSVRFX1RSQU5TRkVSX01PREUJCTEKKworI2RlZmluZSBBRERSX1RYX0VOICAgICAgMSAgIC8qILXY1rfC67eiy83KucTcICovCisjZGVmaW5lIEFERFJfVFhfRElTICAgICAwCisjZGVmaW5lIERBVEFfVFhfRU4gICAgICAxCisjZGVmaW5lIERBVEFfVFhfRElTICAgICAwCisjZGVmaW5lIERBVEFfUlhfRU4gICAgICAxCisjZGVmaW5lIERBVEFfUlhfRElTICAgICAwCisjZGVmaW5lIERVTVlfVFhfRU4gICAgICAxCisjZGVmaW5lIERVTVlfVFhfRElTICAgICAwCisKKyNkZWZpbmUgQUREUl9XSURUSF84ICAgIDAKKyNkZWZpbmUgQUREUl9XSURUSF8xNiAgIDEKKyNkZWZpbmUgQUREUl9XSURUSF8yNCAgIDIKKyNkZWZpbmUgQUREUl9XSURUSF8zMiAgIDMKKworc3RydWN0IHNwaWZsYXNoX2NtZF90Cit7CisgICAgdWludDMyX3QgY21kOworICAgIHVpbnQzMl90IGFkZHJfdHhfZW47ICAgICAgLyogtdjWt8Lrt6LLzcq5xNwgKi8KKyAgICB1aW50MzJfdCBhZGRyX3dpZHRoOyAgICAgIC8qILXY1rfC67/ttsggKi8KKyAgICB1aW50MzJfdCBkYXRhX3R4X2VuOyAgICAgIC8qILeiy83K/b7dyrnE3C0tLdC0ICovCisgICAgdWludDMyX3QgZGF0YV9yeF9lbjsgICAgICAvKiC908rVyv2+3cq5xNwtLS22wSAqLworICAgIHVpbnQzMl90IGR1bXlfdHhfZW47ICAgICAgLyogv9XP0LXItP3W3MbayrnE3CAqLworICAgIHVpbnQzMl90IGR1bXlfYnl0ZXM7ICAgICAgLyogv9XP0LXItP3W3MbaIHg4ICovCisgICAgdWludDMyX3QgZHVteV9iaXRzOyAgICAgICAvKiC/1c/Qtci0/dbcxtogeDEgKi8KK307CisKKy8qIFNQSSBOQU5EIEZFQVRVUkVTIFJFR0lTVEVSUyAqLworI2RlZmluZSBSRUdfUFJPVEVDVElPTiAgICAgICAgICAgICAgMHhBMAorCisjZGVmaW5lIFJFR19GRUFUVVJFICAgICAgICAgICAgICAgICAweEIwCisjZGVmaW5lIEVDQ19FTiAgICAgICAgICAgICAgICAgICAgICAoMHgxPDw0KQorI2RlZmluZSBSRUdfQlVGX1dJTkJPTkQgICAgICAgICAgICAgKDB4MTw8MykKKyNkZWZpbmUgSFNFX0VOICAgICAgICAgICAgICAgICAgICAgICgweDE8PDEpCisjZGVmaW5lIFFFICAgICAgICAgICAgICAgICAgICAgICAgICAoMHgxPDwwKQorCisjZGVmaW5lIFJFR19TVEFUVVMgICAgICAgICAgICAgICAgICAweEMwCisjZGVmaW5lIEVDQ19FUlJfQklUICAgICAgICAgICAgICAgICAoMHg0KSAgICAgICAgLyogRUNDIEVSUiAqLworI2RlZmluZSBFQ0NfRVJSX01BU0sgICAgICAgICAgICAgICAgKDB4Mzw8NCkgICAgIC8qIEVDQyBFUlIgKi8KKyNkZWZpbmUgUF9GQUlMICAgICAgICAgICAgICAgICAgICAgICgweDE8PDMpICAgICAvKiBwcm9ncmFtIGZhaWwqLworI2RlZmluZSBFX0ZBSUwgICAgICAgICAgICAgICAgICAgICAgKDB4MTw8MikgICAgIC8qIGVyYXNlIGZhaWwgKi8KKyNkZWZpbmUgV0VMICAgICAgICAgICAgICAgICAgICAgICAgICgweDE8PDEpICAgICAvKiBXcml0ZSBFbmFibGUgTGF0Y2ggKi8KKyNkZWZpbmUgT0lQICAgICAgICAgICAgICAgICAgICAgICAgICgweDE8PDApICAgICAvKiBPcGVyYXRpb24gSW4gUHJvZ3Jlc3MgKi8KKworI2RlZmluZSBXUkFQX1NJWkVfTUFJ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gICAgICAgICAgICAgICAgICAgICAgIC8qIGNzX2Rlc2VsICovCisgICAgdW5zaWduZWQgY2hhciBUcmh3OyAgLypyZWcgb2Zmc2V0IDB4MTIwKi8KKyAgICB1bnNpZ25lZCBjaGFyIFRyZWE7ICAvKnJlZyBvZmZzZXQgMHgxMzAqLworICAgIHVuc2lnbmVkIGNoYXIgVHJwOyAgIC8qcmVnIG9mZnNldCAweDFmMCwgb3IgVHdwKi8KKyAgICB1bnNpZ25lZCBjaGFyIFRyZWg7ICAvKnJlZyBvZmZzZXQgMHgyMDAsIG9yIFR3ZWgqLworICAgIHVuc2lnbmVkIGNoYXIgVGNzOyAgIC8qcmVnIG9mZnNldCAweDIyMCovCisgICAgdW5zaWduZWQgY2hhciBUcmh6OyAgLypyZWcgb2Zmc2V0IDB4MjkwKi8KK307CisgICAgCisvKm5hbmQgyeixuMPoyva94bm5zOUqLworc3RydWN0IG5hbmRfZmxhc2hfZGV2aWNlX3BhcmEKK3sKKyAgICB1bnNpZ25lZCBjaGFyIG1hbnVmX2lkOyAgICAgICAgICAgIC8qILOnvNJJRCAqLworICAgIHVuc2lnbmVkIGNoYXIgZGV2aWNlX2lkOyAgICAgICAgICAgLyogyeixuElEICovCisgICAgdW5zaWduZWQgY2hhciByZXNfaWQ7ICAgICAgICAgICAgICAvKiDG97z+SUQgKi8KKyAgICB1bnNpZ25lZCBjaGFyIGJ1c19udW07ICAgICAgICAgICAgIC8qIDA6OM67ICAxOjE2zrsgKi8KKyAgICB1bnNpZ25lZCBpbnQgcGFnZV9zaXplOyAgICAgICAgICAgIC8qIMO/0rNtYWlux/jT8rTz0KEgKi8KKyAgICB1bnNpZ25lZCBpbnQgb29iX3NpemU7ICAgICAgICAgICAgIC8qIMO/0rNzcGFyZcf40/K089ChICovCisgICAgdW5zaWduZWQgaW50IGNvbHVtbl9hZGRyX251bTsgICAgIC8qIMHQtdjWt8r9ICovCisgICAgdW5zaWduZWQgaW50IHJvd19hZGRyX251bTsgICAgIC8qINDQtdjWt8r9ICovCisgICAgdW5zaWduZWQgaW50IGJsb2NrX3NpemU7ICAgICAgICAgICAvKiDDv7/ptcS089ChICovCisgICAgdW5zaWduZWQgaW50IHBhZ2VzX3Blcl9ibG9jazsgICAvKiDDv7/ptcS089ChICovCisgICAgdW5zaWduZWQgaW50IGJsb2NrX251bTsgICAgICAgICAgICAvKiC/6cr9ICovCisgICAgdW5zaWduZWQgaW50IGRpZV9udW07CisgICAgdW5zaWduZWQgaW50IHBsYW5lczsJCisgICAgdW5zaWduZWQgaW50IGJhZF9ibG9ja19tYXJrcG9zOyAgICAgLyogu7W/6bHq1r7Ou8671sMstNMwv6rKvCAqLworICAgIHN0cnVjdCBuYW5kX2ZsYXNoX3RpbWluZyBuYW5kX3RpbWVpbmc7Cit9OworCisKK3N0cnVjdCBzcGlfbmFuZF9jdHJsX29wcyB7CisJaW50IAkoKnJlc2V0KSh2b2lkKTsKKwlpbnQgCSgqc3dpdGNoX2RpZSkodW5zaWduZWQgY2hhciBkaWUpOworCWludCAJKCpyZWFkX2lkKSh1aW50MzJfdCByZWdfYWRkciwgdWludDhfdCAqdmFsdWUsIHVpbnQ4X3QgbGVuKTsKKwlpbnQgCSgqZ2V0X2ZlYXR1cmUpKHVpbnQzMl90IHJlZ19hZGRyLCB1aW50OF90ICp2YWx1ZSk7CisJaW50IAkoKnNldF9mZWF0dXJlKSh1aW50MzJfdCByZWdfYWRkciwgdWludDhfdCAqdmFsdWUpOworCWludCAJKCpyZWFkX3BhZ2VfdG9fY2FjaGUpKHVpbnQzMl90IHBhZ2VfYWRkcik7CisJaW50IAkoKnJlYWRfZnJvbV9jYWNoZSkodWludDMyX3QgY29sdW1uX2FkZHIsIHVpbnQzMl90IGxlbiwgdWludDhfdCAqYnVmKTsKKwlpbnQgCSgqcGFnZV9sb2FkKSh1aW50MzJfdCBjb2x1bW5fYWRkciwgdWludDhfdCogYnVmLCB1aW50MzJfdCBwYWdlX2xlbiwgCisJCQkJCQl1aW50OF90ICpvb2IsIHVpbnQzMl90IG9vYl9sZW4pOworCWludCAJKCpwcm9ncmFtX2V4ZWMpKHVpbnQzMl90IHBhZ2VfYWRkcik7CisJaW50IAkoKndyaXRlX2VuYWJsZSkodm9pZCk7CisJaW50IAkoKndyaXRlX2Rpc2FibGUpKHZvaWQpOworCWludCAJKCplcmFzZSkodWludDMyX3QgcGFnZV9hZGRyKTsKKwl2b2lkIAkoKmxvY2spKHZvaWQpOworCXZvaWQgCSgqdW5sb2NrKSh2b2lkKTsKK307CisKK3N0cnVjdCBzcGlfbmFuZF9pbmZvCit7CisgICAgc3RydWN0IG10ZF9pbmZvIG10ZDsKKyAgICBzdHJ1Y3QgbmFuZF9jaGlwIG5hbmQ7CisgICAgc3RydWN0IHNwaV9uYW5kX2J1ZiBidWY7CisJc3RydWN0IHNwaV9uYW5kX2N0cmxfb3BzICpjdHJsOworCXN0cnVjdCBuYW5kX2ZsYXNoX2RldmljZV9wYXJhICpwYXJhOworCXZvaWQgKiBjdHJsX2luZm87CisgICAgaW50IHN0YXR1czsKKyAgICB1aW50MzJfdCBwYWdlOworICAgIHVpbnQzMl90IGRldm51bTsgICAgLyogcmVwcmVzZW50IGhvdyBtYW55IG5hbmRzIGNvbm5lY3RlZCAqLworICAgIHVpbnQzMl90IHRvdGFsX3VzZWRfYmFua3M7CisgICAgdWludDMyX3QgcGFnZXNfcGVyX2RpZTsJCisJdWludDMyX3QgdG90YWxibGtzOworCXVpbnQzMl90IGJsa3NwZXJjaGlwOworICAgIHVpbnQzMl90IGJidHNraXBieXRlczsKKwlpbnQgaWR4OworCXVpbnQzMl90IGZ3YmxrczsgLyogcmVwcmVzZW50IGhvdyBtYW55IGJsb2NrcyBGVyB1c2VkICovCisJdWludDMyX3QgbWF4X2JhbmtzOworCisJaW50IHBsYXRmb3JtOworCXN0cnVjdCBkZXZpY2UgKmRldjsKKworCXVpbnQzMl90IG1hZl9pZDsKKwl1aW50MzJfdCBkZXZfaWQ7CQorfTsKKworCit0eXBlZGVmIHZ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gdm9pZCBfX2V4aXQgdHh4OW5kZm1jX2V4aXQodm9pZCkKK3sKKwlwbGF0Zm9ybV9kcml2ZXJfdW5yZWdpc3RlcigmdHh4OW5kZm1jX2RyaXZlcik7Cit9CisKK21vZHVsZV9pbml0KHR4eDluZGZtY19pbml0KTsKK21vZHVsZV9leGl0KHR4eDluZGZtY19leGl0KTsKKworTU9EVUxFX0xJQ0VOU0UoIkdQTCIpOworTU9EVUxFX0RFU0NSSVBUSU9OKCJUWHg5IFNvQyBOQU5EIGZsYXNoIGNvbnRyb2xsZXIgZHJpdmVyIik7CitNT0RVTEVfQUxJQVMoInBsYXRmb3JtOnR4eDluZGZtYyIpOwpkaWZmIC0tZ2l0IGEvYXAvb3MvbGludXgvbGludXgtMy40LngvZHJpdmVycy9tdGQvbmFuZC96eGljX3NwaWZjLmMgYi9hcC9vcy9saW51eC9saW51eC0zLjQueC9kcml2ZXJzL210ZC9uYW5kL3p4aWNfc3BpZmMuYwpuZXcgZmlsZSBtb2RlIDEwMDc1NQppbmRleCAwMDAwMDAwLi5jNTRiNjYyCi0tLSAvZGV2L251bGwKKysrIGIvYXAvb3MvbGludXgvbGludXgtMy40LngvZHJpdmVycy9tdGQvbmFuZC96eGljX3NwaWZjLmMKQEAgLTAsMCArMSwxODQ3IEBACisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgQ29weXJpZ2h0IDIwMTQgYnkgIFpURSBDb3Jwb3JhdGlvbi4KKyoKKyogRmlsZU5hbWU6OiAgICBzcGlmYy5jCisqIEZpbGUgTWFyazoKKyogRGVzY3JpcHRpb246CisqIE90aGVyczoKKyogVmVyc2lvbjoKKyogQXV0aG9yOgorKiBEYXRlOgorCisqIEhpc3RvcnkgMToKKyogICAgIERhdGU6CisqICAgICBWZXJzaW9uOgorKiAgICAgQXV0aG9yOgorKiAgICAgTW9kaWZpY2F0aW9uOgorKiBIaXN0b3J5IDI6CisqKio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WZjIGVycm9yXG4iKQorCitzdHJ1Y3Qgc3BpZmNfaW5mbyBnX3NwaWZjOworZXh0ZXJuIHVuc2lnbmVkIGNoYXIgIGdfbWFmX2lkOworCitzdGF0aWMgaW50IHNwaWZjX2dldF9mZWF0dXJlKCB1aW50MzJfdCByZWdfYWRkciwgdWludDhfdCAqdmFsdWUpOworc3RhdGljIHVpbnQzMl90IHNwaV9mY193YWl0X2NtZF9lbmQodm9pZCk7CitpbnQgd2luYm9uZF9kZXZfaWQyID0gMDsKKworLyogU1BJIE5BTkQgRkxBU0ggQ09NTUFORCBGT1JNQVQgVFlQRSAqLworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgIFtJbnN0cnVjdGlvbl0gICAgICAgICAgICAgICAgIHwtLXdyaXRlIGVuYWJsZQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8LS13cml0ZSBkaXNhYmxlCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwtLXJlc2V0CisKKyAgW0luc3RydWN0aW9uXSAgICAgICAgICAgICAgICAgfC0tYWRkciB3aWR0aCBpcyAyNCBiaXQKKyAgW2FkZHJdICAgICAgICAgICAgICAgICAgICAgICAgfC0tcGFnZSByZWFkIHRvIGNhY2hlCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwtLWJsb2NrIGVyYXNlCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwtLXByb2dyYW0gZXhlY3V0ZQorCisgIFtJbnN0cnVjdGlvbl0gICAgICAgICAgICAgICAgIHwtLWFkZHIgd2lkdGggaXMgOCBiaXQKKyAgW2FkZHJdICAgICAgICAgICAgICAgICAgICAgICAgfC0tc2V0IGZlYXR1cmUKKyAgW2RhdGFfdHhdICAgICAgICAgICAgICAgICAgICAgfC0tYWRkciB3aWR0aCBpcyAxNiBiaXQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfC0tcHJvZ3JhbSBsb2FkKFgxLFg0KQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8LS1wcm9ncmFtIGxvYWQgcmFuZG9tIGRhdGEoWDEsWDQpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwtLXByb2dyYW0gbG9hZCByYW5kb20gZGF0YSBxdWFkIElPCisKKyAgW0luc3RydWN0aW9uXSAgICAgICAgICAgICAgICAgfC0tYWRkciB3aWR0aCBpcyA4IGJpdAorICBbYWRkcl0gICAgICAgICAgICAgICAgICAgICAgICB8LS1nZXQgZmVhdHVyZQorICBbZGF0YV9yeF0gICAgICAgICAgICAgICAgICAgICB8LS1yZWFkIGlkCisKKyAgW0luc3RydWN0aW9uXSAgICAgICAgICAgICAgICAgfC0tYWRkciB3aWR0aCBpcyAxNiBiaXQKKyAgW2FkZHJdICAgICAgICAgICAgICAgICAgICAgICAgfC0tZHVtbXkgY3ljZWwgOC80LzIKKyAgW2R1bW15XSAgICAgICAgICAgICAgICAgICAgICAgfC0tcmVhZCBmb3JtIGNhY2hlKFgxLFgyLFg0KQorICBbZGF0YV9yeF0gICAgICAgICAgICAgICAgICAgICB8LS1yZWFkIGZvcm0gY2FjaGUoZHVhbCxxdWFkKUlPCisKKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwordWludDMyX3Qgc3BpZmNfZ2V0X3JlZ19iYXNlKHZvaWQpCit7CisJcmV0dXJuICh1aW50MzJfdClnX3NwaWZjLmZsYXNoX3JlZzsKK30KKworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogRnVuY3Rpb246ICAgIHNwaV9mY19lbmFibGUKKyAqIERlc2NyaXB0aW9uOgorICogUGFyYW1ldGVyczoKKyAqICAgSW5wdXQ6CisgKgorICogICBPdXRwdXQ6CisgKgorICogUmV0dXJuczoKKyAqCisgKgorICogT3RoZXJzOgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIHZvaWQgc3BpX2ZjX2VuYWJsZSh2b2lkKQoreworICAgIHZvbGF0aWxlIHN0cnVjdCBzcGlmY19yZWdfdCogc3BpCT0gKHN0cnVjdCBzcGlmY19yZWdfdCopc3BpZmNfZ2V0X3JlZ19iYXNlKCk7CisgICAgCisgICAgaWYoIHNwaS0+U0ZDX0VOICYgRkNfRU5fQkFDSyApCisgICAgICAgIHJldHVybjsKKyAgICAKKyAgICBzcGktPlNGQ19FTiB8PSBGQ19FTjsgIAorICAgIHNwaS0+U0ZDX0NUUkwwIHw9IEZDX1NDTEtfUEFVU0VfRU47Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBGdW5jdGlvbjogICAgc3BpX2ZjX2NsZWFyX2ZpZm8KKyAqIERlc2NyaXB0aW9uOgorICogUGFyYW1ldGVyczoKKyAqICAgSW5wdXQ6CisgKgorICogICBPdXRwdXQ6CisgKgorICogUmV0dXJuczoKKyAqCisgKgorICogT3RoZXJzOgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIHZvaWQgc3BpX2ZjX2NsZWFyX2ZpZm8oIHZvaWQgKQoreworICAgIHZvbGF0aWxlIHN0cnVjdCBzcGlmY19yZWdfdCogc3BpCT0gKHN0cnVjdCBzcGlmY19yZWdfdCopc3BpZmNfZ2V0X3JlZ19iYXNlKCk7CisgICAgCisgICAgc3BpLT5TRkNfQ1RSTDAgfD0gKEZDX1JYRklGT19USFJFUyB8IEZDX1RYRklGT19USFJFUyB8IAorICAgICAgICAgICAgICAgICAgICAgICBGQ19SWEZJRk9fQ0xSIHwgRkNfVFhGSUZPX0NMUik7Cit9CisKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIEZ1bmN0aW9uOiAgICBzcGlfZmNfY29uZmlnX2N0cmwKKyAqIERlc2NyaXB0aW9uOiDH5UZJRk/K/b7do6yyosfSyejWw8rHt/HKudPDRE1BtKvK5AorICogUGFyYW1ldGVyczoKKyAqICAgSW5wdXQ6CisgKgorICogICBPdXRwdXQ6CisgKgorICogUmV0dXJuczoKKyAqCisgKgorICogT3RoZXJzOgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIHZvaWQgc3BpX2ZjX2NvbmZpZ19jdHJsKCB1aW50MzJfdCBkbWEgKQoreworICAgIHZvbGF0aWxlIHN0cnVjdCBzcGlmY19yZWdfdCogc3BpCT0gKHN0cnVjdCBzcGlmY19yZWdfdCopc3BpZmNfZ2V0X3JlZ19iYXNlKCk7CisgICAgCisgICAgLyogY29uZmlnIERNQSAqLworICAgIGlmICggZG1hID09IEZDX0RNQV9UWCApCisgICAgICAgIHNwaS0+U0ZDX0NUUkwwIHw9IEZDX1RYX0RNQV9FTjsKKyAgICBlbHNlIGlmKCBkbWEgPT0gRkNfRE1BX1JYICkKKyAgICAgICAgc3BpLT5TRkNfQ1RSTDAgfD0gRkNfUlhfRE1BX0VOOworCWVsc2UKKwkJc3BpLT5TRkNfQ1RSTDAgJj0gfihGQ19SWF9ETUFfRU58RkNfVFhfRE1BX0VOKTsJCQorfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogRnVuY3Rpb246ICAgIHNwaV9mY19zZXR1cF9jbWQKKyAqIERlc2NyaXB0aW9uOgorICogUGFyYW1ldGVyczoKKyAqICAgSW5wdXQ6CisgKgorICogICBPdXRwdXQ6CisgKgorICogUmV0dXJuczoKKyAqCisgKgorICogT3RoZXJzOgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIHZvaWQgc3BpX2ZjX3NldHVwX2NtZCggc3RydWN0IHNwaWZsYXNoX2NtZF90ICpjbWQsIAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdWludDMyX3QgYWRkciwgdWludDMyX3QgbGVuICkKK3sgICAKKyAgICB2b2xhdGlsZSBzdHJ1Y3Qgc3BpZmNfcmVnX3QqIHNwaQk9IChzdHJ1Y3Qgc3BpZmNfcmVnX3QqKXNwaWZjX2dldF9yZWdfYmFzZSgpOworICAgIHVpbnQzMl90IHdyYXAgPSAwOwkKKyAgICB1aW50MzJfdCB0bXAgPSAwOworCisgICAgLyogw/zB7sLrICovCisgICAgc3BpLT5TRkNfSU5TID0gY21kLT5jbWQ7CisKKyAgICAvKiDK/b7ds6S2yCAqLworICAgIGlmKCBsZW4gKQorICAgICAgICBzcGktPlNGQ19CWVRFX05VTSA9IGxlbiAtIDE7CisgICAgZWxzZQorICAgICAgICBzcGktPlNGQ19CWVRFX05VTSA9IDA7ICAKKworICAgIHN3aXRjaCAoIGxlbiApCisgICAgeworICAgICAgICBjYXNlIDIwNDg6CisgICAgICAgICAgICB3cmFwID0gV1JBUF9TSVpFX01BSU47CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSAyMTEyOgorICAgICAgICAgICAgd3JhcCA9IFdSQVBfU0laRV9NQUlOX09PQjsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIDY0OgorICAgICAgICAgICAgd3JhcCA9IFdSQVBfU0laRV9PT0I7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgIHdyYXAgPSAwOworICAgICAgICAgICAgYnJlYWs7CisgICAgfQorCisgICAgLyogtdjWt8LrICovCisgICAgc3dpdGNoICggc3BpLT5TRkNfSU5TICkKKyAgICB7CisgICAgICAgIGNhc2UgQ01EX1JFQURfRlJPTV9DQUNIRToKKyAgICAgICAgLy8gIGNhc2UgQ01EX1JFQURfRlJPTV9DQUNIRV9YMjoKKyAgICAgICAgY2FzZSBDTURfUkVBRF9GUk9NX0NBQ0hFX1g0OgorICAgICAgICBjYXNlIENNRF9SRUFEX0ZST01fQ0FDSEVfUUlPOgorICAgICAgICBjYXNlIENNRF9QUk9HUkFNX0xPQUQ6CisgICAgICAgIGNhc2UgQ01EX1BST0dSQU1fTE9BRF9YNDoKKyAgICAgICAgICAgIC8vIGNhc2UgQ01EX1BST0dSQU1fTE9BRF9SQU5ET006CisgICAgICAgICAgICAvLyAgY2FzZSBDTURfUFJPR1JBTV9MT0FEX1JBTkRPTV9YNDoKKyAgICAgICAgICAgIC8vY2FzZSBDTURfUFJPR1JBTV9MT0FEX1JBTkRPTV9RSU86CisgICAgICAgICAgICBhZGRyIHw9IHdyYXA7CisgICAgICAgICAgICBicmVhazsKKworICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgYWRkciA9IGFkZHI7CisgICAgICAgICAgICBicmVhazsKKyAgICB9CisgICAgc3BpLT5TRkNfQUREUiA9IGFkZHI7CisKKyAgICAvKiC12Na3wuuhor/V1tzG2qGitsEv0LQgyrnE3Mno1sMgKi8KKyAgICBzcGktPlNGQ19DVFJMMSA9IDA7CisgICAgc3BpLT5TRkNfQ1RSTDEgPSAoKGNtZC0+YWRkcl90eF9lbiA8PCBGQ19BRERSX1RYX0VOKSB8CisgICAgICAgICAgICAgICAgICAgICAgKGNtZC0+ZHVteV90eF9lbiA8PCBGQ19EVU1NWV9UWF9FTikgfAorICAgICAgICAgICAgICAgICAgICAgIChjbWQtPmRhdGFfcnhfZW4gPDwgRkNfUkVBRF9EQVRfRU4pIHwKKyAgICAgICAgICAgICAgICAgICAgICAoY21kLT5kYXRhX3R4X2VuIDw8IEZDX1dSSVRFX0RBVF9FTikpOworCisKKyAgICAvKiC/1dbcxtrK/aGitdjWt7/ttsgoMaOsMqOsM6OsNNfWvdopoaK12Na3L8r9vt3P37bIoaK0q8rkxKPKvSAqLworICAgIHRtcCA9IHNwaS0+U0ZDX0NUUkwyOworICAgIHRtcCAmPSB+KCgweGY8PEZDX0RVTU1ZX0JZVEVfTlVNKSB8CisJCQkgKDB4Nzw8RkNfRFVNTVlfQklUX05VTSkgfAorCQkJICgweDM8PEZDX0FERFJfQllURV9OVU0pKTsKKyAgICB0bXAgfD0gKChjbWQtPmR1bXlfYnl0ZXMgPDwgRkNfRFVNTVlfQllURV9OVU0pIHwKKyAgICAgICAgICAgIChjbWQtPmR1bXlfYml0cyA8PCBGQ19EVU1NWV9CSVRfTlVNKSB8CisgICAgICAgICAgICAoY21kLT5hZGRyX3dpZHRoIDw8IEZDX0FERFJfQllURV9OVU0pKTsKKyAgICBzcGktPlNGQ19DVFJMMiA9IHRtcDsKKwkKK30KKworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogRnVuY3Rpb246ICAgIHNwaV9mY19jbGVhcl9pbnQKKyAqIERlc2NyaXB0aW9uOgorICogUGFyYW1ldGVyczoKKyAqICAgSW5wdXQ6CisgKgorICogICBPdXRwdXQ6CisgKgorICogUmV0dXJuczoKKyAqCisgKgorICogT3RoZXJzOgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIHZvaWQgc3BpX2ZjX2NsZWFyX2ludCggdm9pZCApCit7CisgICAgdm9sYXRpbGUgc3RydWN0IHNwaWZjX3JlZ190KiBzcGkJPSAoc3RydWN0IHNwaWZjX3JlZ190KilzcGlmY19nZXRfcmVnX2Jhc2UoKTsKKworICAgIGlmIChzcGktPlNGQ19JTlRfUkFXICYgMHgyKQorICAgICAgICBwcmludGsoIlNwaS1OYW5kIEludCBGb3JtYXQgZXJyb3IhXG4iKTsKKworICAgIHNwaS0+U0ZDX0lOVF9TV19DTFIgPSAweEZGOyAvL2NsZWFyIGludCA/CisgICAgZ19zcGlmYy5pcnFfc3RhdHVzID0gMHgwOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogRnVuY3Rpb246ICAgIHNwaV9mY19yZWFkX2ZpZm9fb25lX2J5dGUKKyAqIERlc2NyaXB0aW9uOgorICogUGFyYW1ldGVyczoKKyAqICAgSW5wdXQ6CisgKgorICogICBPdXRwdXQ6CisgKgorICogUmV0dXJuczoKKyAqCisgKgorICogT3RoZXJzOiAgb25seSBmb3I6CisgICAgICAgICAgICAgICAgW0luc3RydWN0aW9uXSAgICAgICAgICAgICAgICAgfC0tYWRkciB3aWR0aCBpcyA4IGJpdAorICAgICAgICAgICAgICAgIFthZGRyXSAgICAgICAgICAgICAgICAgICAgICAgIHwtLWdldCBmZWF0dXJlCisgICAgICAgICAgICAgICAgW2RhdGFfcnhdCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitzdGF0aWMgaW50IHNwaV9mY19yZWFkX2ZpZm9fb25lX2J5dGUoIHVpbnQ4X3QgKnZhbHVlICkKK3sKKyAgICB1aW50MzJfdCBzdyA9IDA7CisgICAgdm9sYXRpbGUgc3RydWN0IHNwaWZjX3JlZ190KiBzcGkJPSAoc3RydWN0IHNwaWZjX3JlZ190KilzcGlmY19nZXRfcmVnX2Jhc2UoKTsKKworICAgIHN3ID0gc3BpLT5TRkNfU1c7CisKKyAgICBpZiAoICgoc3cgPj4gRkNfUlhfRklGT19DTlQpICYgRkNfUlhfRklGT19DTlRfTUFTSykgIT0gMSApCisgICAgeworICAgICAgICBwcmludGsoIltTUEktTkFORF1bLUVSUk9SLV1bc3BpX2ZjX3JlYWRfZmlmb19vbmVfYnl0ZV1bU0ZDX1NXXSA9IDB4JTB4XG4iLCBzdyApOworICAgICAgICByZXR1cm4gLTU7CisgICAgfQorCisgICAgKnZhbHVlID0gKHVpbnQ4X3Qpc3BpLT5TRkNfREFUQTsKKworICAgIHJldHVybiAwOworfQorCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBGdW5jdGlvbjogICAgc3BpX2ZjX3JlYWRfZmlmbworICogRGVzY3JpcHRpb246tNNmaWZvtsHK/b7do6zWsbW9tsG1vcbazfu1xLj2yv0KKyAqIFBhcmFtZXRlcnM6CisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3N0YXRpYyB1aW50MzJfdCBzcGlfZmNfcmVhZF9maWZvKCB1aW50MzJfdCBsZW4sIHVpbnQ4X3QgKmJ1ZiApCit7CisgICAgdm9sYXRpbGUgc3RydWN0IHNwaWZjX3JlZ190KiBzcGkJPSAoc3RydWN0IHNwaWZjX3JlZ190KilzcGlmY19nZXRfcmVnX2Jhc2UoKTsKKyAgICB1aW50MzJfdCAqcCA9ICh1aW50MzJfdCAqKWJ1ZjsKKyAgICB1aW50MzJfdCBjbnQgPSAwOworCisgICAgd2hpbGUgKGNudCA8ICgobGVuICszKT4+IDIpKQorICAgIHsKKyAgICAgICAgaWYgKHNwaS0+U0ZDX1NXICYgKEZDX1JYX0ZJRk9fQ05UX01BU0sgPDwgRkNfUlhfRklGT19DTlQpKSAvL3J4IGZpZm8gbm90IGVtcHR5CisgICAgICAgIHsKKyAgICAgICAgICAgIHBbY250KytdID0gc3BpLT5TRkNfREFUQTsKKyAgICAgICAgfQorICAgIH0KKworICAgIHJldHVybiAoY250PDwyKTsKK30KKworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogRnVuY3Rpb246ICAgIHNwaV9mY193cml0ZV9maWZvX29uZV9ieXRlCisgKiBEZXNjcmlwdGlvbjoKKyAqIFBhcmFtZXRlcnM6CisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3N0YXRpYyB1aW50MzJfdCBzcGlfZmNfd3JpdGVfZmlmb19vbmVfYnl0ZSh1aW50MzJfdCBsZW4sIHVpbnQ4X3QqIHZhbHVlKQoreworICAgIHVpbnQzMl90IHN3ID0gMDsKKyAgICB2b2xhdGlsZSBzdHJ1Y3Qgc3BpZmNfcmVnX3QqIHNwaQk9IChzdHJ1Y3Qgc3BpZmNfcmVnX3QqKXNwaWZjX2dldF9yZWdfYmFzZSgpOworCisgICAgc3cgPSBzcGktPlNGQ19TVzsKKworICAgIGlmICggKChzdyA+PiBGQ19UWF9GSUZPX0NOVCkgJiBGQ19UWF9GSUZPX0NOVF9NQVNLKSAhPSAweDEwICkgLyogsrvOqr/V1PKz9rTtICovCisgICAgeworICAgICAgICBwcmludGsoIltTUEktTkFORF1bLUVSUk9SLV1bc3BpX2ZjX3dyaXRlX2ZpZm9fb25lX2J5dGVdW1NGQ19TV10gPSAweCUweFxuIiwgc3cgKTsKKyAgICAgICAgcmV0dXJuIC01OworICAgIH0KKworICAgIHNwaS0+U0ZDX0RBVEEgPSAodWludDMyX3QpKCp2YWx1ZSk7CisKKyAgICByZXR1cm4gMDsKK30KKworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogRnVuY3Rpb246ICAgIHNwaV9mY193cml0ZV9maWZvCisgKiBEZXNjcmlwdGlvbjoKKyAqIFBhcmFtZXRlcnM6CisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3N0YXRpYyB2b2lkIHNwaV9mY193cml0ZV9maWZvKHVpbnQ4X3QqIGJ1ZiwgdWludDMyX3QgYnVmX2xlbiwgdWludDhfdCogb29iLCB1aW50MzJfdCBvb2JfbGVuKQoreworICAgIHVpbnQzMl90ICptYWluX2FyZWEgPSAodWludDMyX3QgKilidWY7CisgICAgdWludDMyX3QgKnNwZWFyX2FyZWEgPSAodWludDMyX3QgKilvb2I7CisgICAgdWludDMyX3QgY250ID0gMDsKKyAgICB1aW50MzJfdCByZXQgPSAwOworICAgIHZvbGF0aWxlIHN0cnVjdCBzcGlmY19yZWdfdCogc3BpID0gKHN0cnVjdCBzcGlmY19yZWdfdCopc3BpZmNfZ2V0X3JlZ19iYXNlKCk7CisKKyAgICB3aGlsZSAoY250IDwgKGJ1Zl9sZW4gPj4gMikpCisgICAgeworICAgICAgICBpZiAoc3BpLT5TRkNfU1cgJiAoRkNfVFhfRklGT19DTlRfTUFTSyA8PCBGQ19UWF9GSUZPX0NOVCkpIC8vdHggZmlmbyBub3QgZnVsbAorICAgICAgICB7CisgICAgICAgICAgICBzcGktPlNGQ19EQVRBID0gbWFpbl9hcmVhW2NudCsrXTsKKyAgICAgICAgfQorICAgIH0KKyNpZiAwCisgICAgaWYgKGxlbiAlIDQpCisgICAgeworICAgICAgICBwcmludGsoIltTUEktTkFORF1bc3BpX2ZjX3JlYWRfZmlmb11bZXJyb3JdXG4iKTsKKyAgICAgICAgQlVHKCk7CisgICAgfQorI2VuZGlmCisgICAgcmV0ID0gY250OworICAgIGNudCA9IDA7CisKKyAgICBpZiAoIG9vYiAhPSBOVUxMICkKKyAgICB7CisgICAgICAgIHdoaWxlICggY250IDwgKG9vYl9sZW4gPj4gMikpCisgICAgICAgIHsKKyAgICAgICAgICAgIGlmIChzcGktPlNGQ19TVyAmIChGQ19UWF9GSUZPX0NOVF9NQVNLIDw8IEZDX1RYX0ZJRk9fQ05UKSkgLy90eCBmaWZvIG5vdCBmdWxsCisgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgc3BpLT5TRkNfREFUQSA9IHNwZWFyX2FyZWFbY250KytdOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgfQorCisjaWYgMAorICAgIHJldCArPSBjbnQ7CisgICAgaWYgKCAocmV0IDw8IDIpICE9IGxlbiApCisgICAgeworICAgICAgICB6RHJ2X0FTU0VSVCgwKTsKKyAgICB9CisjZW5kaWYJCit9CisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogRnVuY3Rpb246ICAgIHNwaV9mY19zdGFydAorICogRGVzY3JpcHRpb246CisgKiBQYXJhbWV0ZXJzOgorICogICBJbnB1dDoKKyAqCisgKiAgIE91dHB1dDoKKyAqCisgKiBSZXR1cm5zOgorICoKKyAqCisgKiBPdGhlcnM6CisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitzdGF0aWMgaW5saW5lIHZvaWQgc3BpX2ZjX3N0YXJ0KCB2b2lkICkKK3sKKyAgICB2b2xhdGlsZSBzdHJ1Y3Qgc3BpZmNfcmVnX3QqIHNwaQk9IChzdHJ1Y3Qgc3BpZmNfcmVnX3QqKXNwaWZjX2dldF9yZWdfYmFzZSgpOworCisgICAgc3BpLT5TRkNfU1RBUlQgfD0gRkNfU1RBUlQ7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBGdW5jdGlvbjogICAgc3BpX2ZjX3NldHVwX3RhbnNtb2QKKyAqIERlc2NyaXB0aW9uOgorICogUGFyYW1ldGVyczoKKyAqICAgSW5wdXQ6CisgKgorICogICBPdXRwdXQ6CisgKgorICogUmV0dXJuczoKKyAqCisgKgorICogT3RoZXJzOgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIHZvaWQgc3BpX2ZjX3NldHVwX3RhbnNtb2QodWludDMyX3QgbW9kKQoreworICAgIHVpbnQzMl90IHRtcFJlZzsKKyAgICB2b2xhdGlsZSBzdHJ1Y3Qgc3BpZmNfcmVnX3QqIHNwaSAgPSAoc3RydWN0IHNwaWZjX3JlZ190KilzcGlmY19nZXRfcmVnX2Jhc2UoKTsKKworICAgIHRtcFJlZyA9IHNwaS0+U0ZDX0NUUkwyOworICAgIHRtcFJlZyAmPSAweGZmZmZmZmUwOworCisgICAgc3dpdGNoIChtb2QpCisgICAgeworICAgICAgICBjYXNlIFJEUUlPX01PREU6CisgICAgICAgICAgICB0bXBSZWcgfD0gRkNfQUREUl9NVUxUSV9MSU5FX0VOIHwKKyAgICAgICAgICAgICAgICAgICAgICBGQ19EQVRfTVVMVElfTElORV9FTiB8CisgICAgICAgICAgICAgICAgICAgICAgRkNfVFJBTlNfTU9EOworICAgICAgICAgICAgYnJlYWs7CisKKyAgICAgICAgY2FzZSBQTFg0X01PREU6CisgICAgICAgIGNhc2UgUkRYNF9NT0RFOgorICAgICAgICAgICAgdG1wUmVnIHw9IEZDX0RBVF9NVUxUSV9MSU5FX0VOIHwgRkNfVFJBTlNfTU9EOworICAgICAgICAgICAgYnJlYWs7CisKKyAgICAgICAgLyogY2FzZSBEVUFMX01PREU6CisgICAgICAgICAgICAgdG1wUmVnIHw9RkNfREFUX01VTFRJX0xJTkVfRU47CisgICAgICAgICAgYnJlYWs7ICovCisKKyAgICAgICAgZGVmYXVsdDogICAvKnNpZ25sZSBtb2RlKi8KKyAgICAgICAgICAgIGJyZWFrOworICAgIH0KKworICAgIHNwaS0+U0ZDX0NUUkwyID0gdG1wUmVnOworfQorCisKKworc3RhdGljIHZvaWQgc3BpZmNfaXJxX2VuYWJsZSh1aW50MzJfdCBpbnRfbWFzaykKK3sKKyAgICB2b2xhdGlsZSBzdHJ1Y3Qgc3BpZmNfcmVnX3QqIHNwaQk9IChzdHJ1Y3Qgc3BpZmNfcmVnX3QqKXNwaWZjX2dldF9yZWdfYmFzZSgpOworCisJc3BpLT5TRkNfSU5UX0VOID0gMDsKKwlzcGktPlNGQ19JTlRfRU4gfD0gaW50X21hc2s7Cit9CisKK3N0YXRpYyB2b2lkIHNwaWZjX2lycV9kaXNhYmxlKHZvaWQpCit7CisgICAgdm9sYXRpbGUgc3RydWN0IHNwaWZjX3JlZ190KiBzcGkJPSAoc3RydWN0IHNwaWZjX3JlZ190KilzcGlmY19nZXRfcmVnX2Jhc2UoKTsKKworCXNwaS0+U0ZDX0lOVF9FTiA9IDA7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBGdW5jdGlvbjogICAgc3BpZmNfc2V0X3RpbWluZworICogRGVzY3JpcHRpb246IAorICogUGFyYW1ldGVyczoKKyAqCSBJbnB1dDoKKyAqCisgKgkgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczoKKyAqKioqKioqKioqK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LyogP6iuqLo/qLp5P1moujE/qLktLS0/qKIgKi8KKwkJCQkJCQkJCTAsCQkJCQkJLyogPz8/RKbMqKih5Hk/qLk/qLKoujE/qLkgKi8KKwkJCQkJCQkJCTAsCQkJCQkJLyogPz8/RKbMqKih5Hk/qLk/qLIgeDggKi8KKwkJCQkJCQkJCTAJCQkJCQkvKiA/Pz9EpsyoqKHkeT+ouT+osiB4MSAqLworCQkJCQkJCQl9OworCisJCisgICAgZG8KKyAgICB7CisgICAgICAgIHNwaV9mY19jbGVhcl9maWZvKCk7CisgICAgICAgIHNwaV9mY19jbGVhcl9pbnQoKTsKKyAgICAgICAgc3BpX2ZjX2NvbmZpZ19jdHJsKEZDX0RNQV9OT05FKTsgICAgICAgCisJCXNwaV9mY19zZXR1cF9jbWQoJmNtZCwgMCwgMSk7CQkvKiA/qLmooj8/Pz8/ICovCSAgCisgICAgICAgIHNwaV9mY193cml0ZV9maWZvX29uZV9ieXRlKDEsICZ2YWx1ZSk7CisgICAgICAgIHNwaV9mY19zdGFydCgpOyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogP2Gouj+h5D+ouj8gKi8KKyAgICAgICAgcmV0ID0gc3BpX2ZjX3dhaXRfY21kX2VuZCgpOyAgICAgICAgICAgICAgICAvKiCmzKiooeR5P6i5qKI/P6iiqLo/ICovCisgICAgICAgIGlmKCByZXQgIT0gU1VDQ0VTUyApCisgICAgICAgIHsKKyAgICAgICAgICAgIGNvbnRpbnVlOyAgIC8qIKHkP6i6P6i6oeyh46i5oeo/P6iiqLo/ocA/oeQ/Py0/oaQyoek/P6HkPyAqLworICAgICAgICB9CisgICAgICAgIGJyZWFrOyAgICAgICAgCisgICAgfSB3aGlsZSggLS1yZXRyaWVzICE9IDAgKTsKKworICAgIHJldHVybiByZXQ7Cit9CisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogRnVuY3Rpb246ICAgIHNwaWZjX3dyaXRlX2VuYWJsZQorICogRGVzY3JpcHRpb246CisgKiBQYXJhbWV0ZXJzOgorICogICBJbnB1dDoKKyAqCisgKiAgIE91dHB1dDoKKyAqCisgKiBSZXR1cm5zOgorICoKKyAqCisgKiBPdGhlcnM6CisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitzdGF0aWMgaW50IHNwaWZjX3dyaXRlX2VuYWJsZSggdm9pZCApCit7CisgICAgaW50IHJldCA9IFNVQ0NFU1M7CisgICAgdWludDMyX3QgcmV0cmllcyA9IFNQSV9OQU5EX1JFVFJJRTsKKwl1aW50OF90IHN0YXR1cyA9IDA7CisgICAgc3RydWN0IHNwaWZsYXNoX2NtZF90IGNtZCA9IHsgICBDTURfV1JJVEVfRU5BQkxFLCAgICAgICAvKiDWuMHuwusgKi8KKyAgICAgICAgICAgICAgIDAsICAgICAgICAgICAgICAgICAgICAgIC8qILXY1rfC67eiy83KucTcICovCisgICAgICAgICAgICAgICAwLCAgICAgICAgICAgICAgICAgICAgICAvKiC12Na3wuuzpLbIICovCisgICAgICAgICAgICAgICAwLCAgICAgICAgICAgICAgICAgICAgICAvKiC3osvNyv2+3cq5xNwtLS3QtCAqLworICAgICAgICAgICAgICAgMCwgICAgICAgICAgICAgICAgICAgICAgLyogvdPK1cr9vt3KucTcLS0ttsEgKi8KKyAgICAgICAgICAgICAgIDAsICAgICAgICAgICAgICAgICAgICAgIC8qIL/Vz9C1yLT91tzG2sq5xNwgKi8KKyAgICAgICAgICAgICAgIDAsICAgICAgICAgICAgICAgICAgICAgIC8qIL/Vz9C1yLT91tzG2iB4OCAqLworICAgICAgICAgICAgICAgMCAgICAgICAgICAgICAgICAgICAgICAgLyogv9XP0LXItP3W3MbaIHgxICovCisgICAgfTsKKwl3aGlsZSgxKQorCXsKKwkgICAgZG8KKwkgICAgeworCSAgICAgICAgc3BpX2ZjX2NsZWFyX2ZpZm8oKTsKKwkgICAgICAgIHNwaV9mY19jbGVhcl9pbnQoKTsKKwkgICAgICAgIHNwaV9mY19jb25maWdfY3RybChGQ19ETUFfTk9ORSk7CisJICAgICAgICBzcGlfZmNfc2V0dXBfY21kKCZjbWQsIDB4MCwgMCk7ICAgICAgICAgIC8qIMP8we7F5NbDICovCisJICAgICAgICBzcGlfZmNfc3RhcnQoKTsgICAgICAgICAgICAgICAgICAgICAgICAgIC8qIL+qyry0q8rkICovCisJICAgICAgICByZXQgPSBzcGlfZmNfd2FpdF9jbWRfZW5kKCk7ICAgICAgICAgICAgIC8qILXItP3D/MHuveHK+CAqLworCSAgICAgICAgaWYgKCByZXQgIT0gU1VDQ0VTUyApCisJICAgICAgICB7CisJICAgICAgICAgICAgY29udGludWU7ICAgLyogtKvK5MqnsNyjrL3hyvixvrTO0a27t7Ki1ti0qyAqLworCSAgICAgICAgfQorCisJICAgICAgICBicmVhazsKKwkgICAgfQorCSAgICB3aGlsZSAoIC0tcmV0cmllcyAhPSAwICk7CisKKwkJLyogtci0/cnPtM7D/MHu1rTQ0M3qs8kgKi8KKwkJZG8KKwkJeworCQkJc3BpZmNfZ2V0X2ZlYXR1cmUoUkVHX1NUQVRVUywgJnN0YXR1cyk7IAorCQl9CisJCXdoaWxlICggc3RhdHVzICYgT0lQKTsgCisJCisJCWlmKHN0YXR1cyZXRUwpLy9zdW56aGFveGluZworCQkJYnJlYWs7CisJCisJCXJldHJpZXMgPSBTUElfTkFORF9SRVRSSUU7CisJfQorICAgIHJldHVybiByZXQ7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBGdW5jdGlvbjogICAgc3BpZmNfd3JpdGVfZGlzYWJsZQorICogRGVzY3JpcHRpb246CisgKiBQYXJhbWV0ZXJzOgorICogICBJbnB1dDoKKyAqCisgKiAgIE91dHB1dDoKKyAqCisgKiBSZXR1cm5zOgorICoKKyAqCisgKiBPdGhlcnM6CisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitzdGF0aWMgaW50IHNwaWZjX3dyaXRlX2Rpc2FibGUoIHZvaWQgKQoreworICAgIGludCByZXQgPSBTVUNDRVNTOworICAgIHVpbnQzMl90IHJldHJpZXMgPSBTUElfTkFORF9SRVRSSUU7CisgICAgc3RydWN0IHNwaWZsYXNoX2NtZF90IGNtZCA9IHsgICBDTURfV1JJVEVfRElTQUJMRSwgICAgICAvKiDWuMHuwusgKi8KKyAgICAgICAgICAgICAgIDAsICAgICAgICAgICAgICAgICAgICAgIC8qILXY1rfC67eiy83KucTcICovCisgICAgICAgICAgICAgICAwLCAgICAgICAgICAgICAgICAgICAgICAvKiC12Na3wuuzpLbIICovCisgICAgICAgICAgICAgICAwLCAgICAgICAgICAgICAgICAgICAgICAvKiC3osvNyv2+3cq5xNwtLS3QtCAqLworICAgICAgICAgICAgICAgMCwgICAgICAgICAgICAgICAgICAgICAgLyogvdPK1cr9vt3KucTcLS0ttsEgKi8KKyAgICAgICAgICAgICAgIDAsICAgICAgICAgICAgICAgICAgICAgIC8qIL/Vz9C1yLT91tzG2sq5xNwgKi8KKyAgICAgICAgICAgICAgIDAsICAgICAgICAgICAgICAgICAgICAgIC8qIL/Vz9C1yLT91tzG2iB4OCAqLworICAgICAgICAgICAgICAgMCAgICAgICAgICAgICAgICAgICAgICAgLyogv9XP0LXItP3W3MbaIHgxICovCisgICAgfTsKKyAgICBkbworICAgIHsKKyAgICAgICAgc3BpX2ZjX2NsZWFyX2ZpZm8oKTsKKyAgICAgICAgc3BpX2ZjX2NsZWFyX2ludCgpOworICAgICAgICBzcGlfZmNfY29uZmlnX2N0cmwoRkNfRE1BX05PTkUpOworICAgICAgICBzcGlfZmNfc2V0dXBfY21kKCZjbWQsIDB4MCwgMCk7ICAgICAgICAgIC8qIMP8we7F5NbDICovCisgICAgICAgIHNwaV9mY19zdGFydCgpOyAgICAgICAgICAgICAgICAgICAgICAgICAgLyogv6rKvLSryuQgKi8KKyAgICAgICAgcmV0ID0gc3BpX2ZjX3dhaXRfY21kX2VuZCgpOyAgICAgICAgICAgICAvKiC1yLT9w/zB7r3hyvggKi8KKyAgICAgICAgaWYgKCByZXQgIT0gU1VDQ0VTUyApCisgICAgICAgIHsKKyAgICAgICAgICAgIGNvbnRpbnVlOyAgIC8qILSryuTKp7Dco6y94cr4sb60ztGtu7eyotbYtKsgKi8KKyAgICAgICAgfQorCisgICAgICAgIGJyZWFrOworICAgIH0KKyAgICB3aGlsZSAoIC0tcmV0cmllcyAhPSAwICk7CisKKyAgICByZXR1cm4gcmV0OworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogRnVuY3Rpb246ICAgIHNwaWZjX3Jlc2V0CisgKiBEZXNjcmlwdGlvbjoKKyAqIFBhcmFtZXRlcnM6CisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3N0YXRpYyBpbnQgc3BpZmNfcmVzZXQoIHZvaWQgKQoreworICAgIGludCByZXQgPSBTVUNDRVNTOworICAgIHVpbnQzMl90IHJldHJpZXMgPSBTUElfTkFORF9SRVRSSUU7CisgICAgdWludDhfdCBzdGF0dXMgPSAwOworICAgIHN0cnVjdCBzcGlmbGFzaF9jbWRfdCBjbWQgPSB7ICAgQ01EX1JFU0VULCAgICAgICAgICAgICAgLyog1rjB7sLrICovCisgICAgICAgICAgICAgICAwLCAgICAgICAgICAgICAgICAgICAgICAvKiC12Na3wuu3osvNyrnE3CAqLworICAgICAgICAgICAgICAgMCwgICAgICAgICAgICAgICAgICAgICAgLyogtdjWt8Lrs6S2yCAqLworICAgICAgICAgICAgICAgMCwgICAgICAgICAgICAgICAgICAgICAgLyogt6LLzcr9vt3KucTcLS0t0LQgKi8KKyAgICAgICAgICAgICAgIDAsICAgICAgICAgICAgICAgICAgICAgIC8qIL3TytXK/b7dyrnE3C0tLbbBICovCisgICAgICAgICAgICAgICAwLCAgICAgICAgICAgICAgICAgICAgICAvKiC/1c/Qtci0/dbcxtrKucTcICovCisgICAgICAgICAgICAgICAwLCAgICAgICAgICAgICAgICAgICAgICAvKiC/1c/Qtci0/dbcxtogeDggKi8KKyAgICAgICAgICAgICAgIDAgICAgICAgICAgICAgICAgICAgICAgIC8qIL/Vz9C1yLT91tzG2iB4MSAqLworICAgIH07CisgICAgZG8KKyAgICB7CisgICAgICAgIHNwaV9mY19zZXR1cF9jbWQoJmNtZCwgMCwgMCk7IC8qIMP8we7F5NbDICovCisJCXNwaV9mY19jbGVhcl9pbnQoKTsKKyAgICAgICAgc3BpX2ZjX3N0YXJ0KCk7ICAgICAgICAgICAgICAgICAgICAgLyogv6rKvLSryuQgKi8KKyAgICAgICAgcmV0ID0gc3BpX2ZjX3dhaXRfY21kX2VuZCgpOyAgICAgICAgLyogtci0/cP8we694cr4ICovCisJCWlmICggcmV0ICE9IFNVQ0NFU1MgKQorICAgICAgICB7CisgICAgICAgICAgICBjb250aW51ZTsgICAgLyogtKvK5MqnsNyjrL3hyvixvrTO0a27t7Ki1ti0qyAqLworICAgICAgICB9CisJCWRvCisJCXsKKwkJCXNwaWZjX2dldF9mZWF0dXJlKFJFR19TVEFUVVMsICZzdGF0dXMpOyAKKwkJfQorCQl3aGlsZSAoIHN0YXR1cyAmIE9JUCk7IAorCisgICAgICAgIGJyZWFrOworICAgIH0KKyAgICB3aGlsZSAoIC0tcmV0cmllcyAhPSAwICk7CisKKyAgICByZXR1cm4gcmV0OworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogRnVuY3Rpb246ICAgIHNwaWZjX2dldF9mZWF0dXJlCisgKiBEZXNjcmlwdGlvbjoKKyAqIFBhcmFtZXRlcnM6CisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczogICBbSW5zdHJ1Y3Rpb25dICAgICAgICAgICAgICAgICB8LS1hZGRyIHdpZHRoIGlzIDggYml0CisgICAgICAgICAgICAgW2FkZHJdICAgICAgICAgICAgICAgICAgICAgICAgfC0tZ2V0IGZlYXR1cmUKKyAgICAgICAgICAgICBbZGF0YV9yeF0gICAgICAgICAgICAgICAgICAgICB8LS1yZWFkIGlkCisKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3N0YXRpYyBpbnQgc3BpZmNfZ2V0X2ZlYXR1cmUoIHVpbnQzMl90IHJlZ19hZGRyLCB1aW50OF90ICp2YWx1ZSkKK3sKKyAgICBpbnQgcmV0ID0gU1VDQ0VTUzsKKyAgICB1aW50MzJfdCByZXRyaWVzID0gU1BJX05BTkRfUkVUUklFOworCisgICAgc3RydWN0IHNwaWZsYXNoX2NtZF90IGNtZCA9IHsgICBDTURfR0VUX0ZFQVRVUkUsICAgICAgICAvKiDWuMHuwusgKi8KKyAgICAgICAgICAgICAgIDEsICAgICAgICAgICAgICAgICAgICAgIC8qILXY1rfC67eiy83KucTcICovCisgICAgICAgICAgICAgICBGQ19BRERSX0JZVEVfTlVNXzgsICAgICAvKiC12Na3wuuzpLbIICovCisgICAgICAgICAgICAgICAwLCAgICAgICAgICAgICAgICAgICAgICAvKiC3osvNyv2+3cq5xNwtLS3QtCAqLworICAgICAgICAgICAgICAgMSwgICAgICAgICAgICAgICAgICAgICAgLyogvdPK1cr9vt3KucTcLS0ttsEgKi8KKyAgICAgICAgICAgICAgIDAsICAgICAgICAgICAgICAgICAgICAgIC8qIL/Vz9C1yLT91tzG2sq5xNwgKi8KKyAgICAgICAgICAgICAgIDAsICAgICAgICAgICAgICAgICAgICAgIC8qIL/Vz9C1yLT91tzG2iB4OCAqLworICAgICAgICAgICAgICAgMCAgICAgICAgICAgICAgICAgICAgICAgLyogv9XP0LXItP3W3MbaIHgxICovCisgICAgfTsKKyAgICBkbworICAgIHsKKyAgICAgICAgc3BpX2ZjX2NsZWFyX2ZpZm8oKTsKKyAgICAgICAgc3BpX2ZjX2NsZWFyX2ludCgpOworICAgICAgICBzcGlfZmNfY29uZmlnX2N0cmwoRkNfRE1BX05PTkUpOworICAgICAgICBzcGlfZmNfc2V0dXBfY21kKCZjbWQsIHJlZ19hZGRyLCAxKTsgICAgICAgIC8qIMP8we7F5NbDICovCisgICAgICAgIHNwaV9mY19zdGFydCgpOyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogv6rKvLSryuQgKi8KKyAgICAgICAgcmV0ID0gc3BpX2ZjX3dhaXRfY21kX2VuZCgpOyAgICAgICAgICAgICAgICAvKiC1yLT9w/zB7r3hyvggKi8KKyAgICAgICAgaWYgKCByZXQgIT0gU1VDQ0VTUyApCisgICAgICAgIHsKKyAgICAgICAgICAgIGNvbnRpbnVlOyAgIC8qILSryuTKp7Dco6y94cr4sb60ztGtu7eyotbYtKsgKi8KKyAgICAgICAgfQorCisgICAgICAgIHJldCA9IHNwaV9mY19yZWFkX2ZpZm9fb25lX2J5dGUodmFsdWUpOyAgICAgICAgICAvKiC2wcihyv2+3SAqLworICAgICAgICBpZiAoIHJldCAhPSBTVUNDRVNTICkKKyAgICAgICAgeworICAgICAgICAgICAgY29udGludWU7ICAgLyogtKvK5MqnsNyjrL3hyvixvrTO0a27t7Ki1ti0qyAqLworICAgICAgICB9CisKKyAgICAgICAgYnJlYWs7CisgICAgfQorICAgIHdoaWxlICggLS1yZXRyaWVzICE9IDAgKTsKKworICAgIHJldHVybiByZXQ7Cit9CisKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIEZ1bmN0aW9uOiAgICBzcGlmY19zZXRfZmVhdHVyZQorICogRGVzY3JpcHRpb246CisgKiBQYXJhbWV0ZXJzOgorICogICBJbnB1dDoKKyAqCisgKiAgIE91dHB1dDoKKyAqCisgKiBSZXR1cm5zOgorICoKKyAqCisgKiBPdGhlcnM6ICAgW0luc3RydWN0aW9uXSAgICAgICAgICAgICAgICAgfC0tYWRkciB3aWR0aCBpcyA4IGJpdAorICAgICAgICAgICAgIFthZGRyXSAgICAgICAgICAgICAgICAgICAgICAgIHwtLXNldCBmZWF0dXJlCisgICAgICAgICAgICAgW2RhdGFfdHhdCisKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3N0YXRpYyBpbnQgc3BpZmNfc2V0X2ZlYXR1cmUoIHVpbnQzMl90IHJlZ19hZGRyLCB1aW50OF90ICp2YWx1ZSkKK3sKKyAgICBpbnQgcmV0ID0gU1VDQ0VTUzsKKyAgICB1aW50MzJfdCByZXRyaWVzID0gU1BJX05BTkRfUkVUUklFOworCisgICAgc3RydWN0IHNwaWZsYXNoX2NtZF90IGNtZCA9IHsgICBDTURfU0VUX0ZFQVRVUkUsICAgICAgICAvKiDWuMHuwusgKi8KKyAgICAgICAgICAgICAgIDEsICAgICAgICAgICAgICAgICAgICAgIC8qILXY1rfC67eiy83KucTcICovCisgICAgICAgICAgICAgICBGQ19BRERSX0JZVEVfTlVNXzgsICAgICAvKiC12Na3wuuzpLbIICovCisgICAgICAgICAgICAgICAxLCAgICAgICAgICAgICAgICAgICAgICAvKiC3osvNyv2+3cq5xNwtLS3QtCAqLworICAgICAgICAgICAgICAgMCwgICAgICAgICAgICAgICAgICAgICAgLyogvdPK1cr9vt3KucTcLS0ttsEgKi8KKyAgICAgICAgICAgICAgIDAsICAgICAgICAgICAgICAgICAgICAgIC8qIL/Vz9C1yLT91tzG2sq5xNwgKi8KKyAgICAgICAgICAgICAgIDAsICAgICAgICAgICAgICAgICAgICAgIC8qIL/Vz9C1yLT91tzG2iB4OCAqLworICAgICAgICAgICAgICAgMCAgICAgICAgICAgICAgICAgICAgICAgLyogv9XP0LXItP3W3MbaIHgxICovCisgICAgfTsKKyAgICBkbworICAgIHsKKyAgICAgICAgc3BpX2ZjX2NsZWFyX2ZpZm8oKTsKKyAgICAgICAgc3BpX2ZjX2NsZWFyX2ludCgpOworICAgICAgICBzcGlfZmNfY29uZmlnX2N0cmwoRkNfRE1BX05PTkUpOworICAgICAgICBzcGlfZmNfc2V0dXBfY21kKCZjbWQsIHJlZ19hZGRyLCAxKTsgICAgICAgIC8qIMP8we7F5NbDICovCisgICAgICAgIHNwaV9mY193cml0ZV9maWZvX29uZV9ieXRlKDEsIHZhbHVlKTsKKyAgICAgICAgc3BpX2ZjX3N0YXJ0KCk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiC/qsq8tKvK5CAqLworICAgICAgICByZXQgPSBzcGlfZmNfd2FpdF9jbWRfZW5kKCk7ICAgICAgICAgICAgICAgIC8qILXItP3D/MHuveHK+CAqLworICAgICAgICBpZiAoIHJldCAhPSBTVUNDRVNTICkKKyAgICAgICAgeworICAgICAgICAgICAgY29udGludWU7ICAgLyogtKvK5MqnsNyjrL3hyvixvrTO0a27t7Ki1ti0qyAqLworICAgICAgICB9CisgICAgICAgIGJyZWFrOworICAgIH0KKyAgICB3aGlsZSAoIC0tcmV0cmllcyAhPSAwICk7CisKKyAgICByZXR1cm4gcmV0OworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogRnVuY3Rpb246ICAgIHNwaWZjX3JlYWRfaWQKKyAqIERlc2NyaXB0aW9uOiAKKyAqIFBhcmFtZXRlcnM6CisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczogIFtJbnN0cnVjdGlvbl0gICAgICAgICAgICAgICAgIHwtLWFkZHIgd2lkdGggaXMgOCBiaXQKKyAgICAgICAgICAgIFthZGRyXSAgICAgICAgICAgICAgICAgICAgICAgIHwtLWdldCBmZWF0dXJlCisgICAgICAgICAgICBbZGF0YV9yeF0gICAgICAgICAgICAgICAgICAgICB8LS1yZWFkIGlkCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisKK3N0YXRpYyBpbnQgc3BpZmNfcmVhZF9pZCh1aW50MzJfdCByZWdfYWRkciwgdWludDhfdCAqdmFsdWUsIHVpbnQ4X3QgbGVuKQoreyAgIAorICAgIGludCByZXQgPSAwOworICAgIHVpbnQzMl90IHJldHJpZXMgPSBTUElfTkFORF9SRVRSSUU7CisKKyAgICBzdHJ1Y3Qgc3BpZmxhc2hfY21kX3QgY21kID0geyAgIENNRF9SRUFEX0lELCAgICAgICAgICAgIC8qINa4we7C6yAqLworICAgICAgICAgICAgICAgMSwgICAgICAgICAgICAgICAgICAgICAgLyogtdjWt8Lrt6LLzcq5xNwgKi8KKyAgICAgICAgICAgICAgIEZDX0FERFJfQllURV9OVU1fOCwgICAgIC8qILXY1rfC67OktsggKi8KKyAgICAgICAgICAgICAgIDAsICAgICAgICAgICAgICAgICAgICAgIC8qILeiy83K/b7dyrnE3C0tLdC0ICovCisgICAgICAgICAgICAgICAxLCAgICAgICAgICAgICAgICAgICAgICAvKiC908rVyv2+3cq5xNwtLS22wSAqLworICAgICAgICAgICAgICAgMCwgICAgICAgICAgICAgICAgICAgICAgLyogv9XP0LXItP3W3MbayrnE3CAqLworICAgICAgICAgICAgICAgMCwgICAgICAgICAgICAgICAgICAgICAgLyogv9XP0LXItP3W3MbaIHg4ICovCisgICAgICAgICAgICAgICAwICAgICAgICAgICAgICAgICAgICAgICAvKiC/1c/Qtci0/dbcxtogeDEgKi8KKyAgICB9OworCisKKyAgICBkbworICAgIHsKKyAgICAgICAgc3BpX2ZjX2NsZWFyX2ZpZm8oKTsKKyAgICAgICAgc3BpX2ZjX2NsZWFyX2ludCgpOworICAgICAgICBzcGlfZmNfY29uZmlnX2N0cmwoRkNfRE1BX05PTkUpOyAgICAgICAgCisgICAgICAgIHNwaV9mY19zZXR1cF9jbWQoJmNtZCwgcmVnX2FkZHIsIGxlbik7ICAgICAgICAvKiDD/MHuxeTWwyAqLyAgICAgIAorICAgICAgICBzcGlfZmNfc3RhcnQoKTsgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qIL+qyry0q8rkICovCisgICAgICAgIHJldCA9IHNwaV9mY193YWl0X2NtZF9lbmQoKTsgICAgICAgICAgICAgICAgLyogtci0/cP8we694cr4ICovCisgICAgICAgIGlmKCByZXQgIT0gU1VDQ0VTUyApCisgICAgICAgIHsKKyAgICAgICAgICAgIC8vc3BpX2ZjX2Rpc2FibGUoKTsKKyAgICAgICAgICAgIGNvbnRpbnVlOyAgIC8qILSryuTKp7Dco6y94cr4sb60ztGtu7eyotbYtKsgKi8KKyAgICAgICAgfQorCisgICAgICAgIHJldCA9IHNwaV9mY19yZWFkX2ZpZm8obGVuLHZhbHVlKTsgICAgIC8qILbByKHK/b7dICovCisJCQorICAgICAgICBpZiAoIHJldCAhPSBTVUNDRVNTICkKKyAgICAgICAgeworICAgICAgICAgICAgLy9zcGlfZmNfZGlzYWJsZSgpOworICAgICAgICAgICAgY29udGludWU7ICAgLyogtKvK5MqnsNyjrL3hyvixvrTO0a27t7Ki1ti0qyAqLworICAgICAgICB9CisKKyAgICAgICAgYnJlYWs7CisgICAgfQorICAgIHdoaWxlICggLS1yZXRyaWVzICE9IDAgKTsKKworICAgIHJldHVybiAwOworfQorCisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBGdW5jdGlvbjogICAgc3BpZmNfZXJhc2UKKyAqIERlc2NyaXB0aW9uOiAKKyAqIFBhcmFtZXRlcnM6CisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczogIFtJbnN0cnVjdGlvbl0gICAgICAgfC0tYWRkciB3aWR0aCBpcyAyNCBiaXQocGFnZS9ibG9jayBhZGRyISEhISkKKyAgICAgICAgICAgIFthZGRyXQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8LS1ibG9jayBlcmFzZQorCisgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitzdGF0aWMgaW50IHNwaWZjX2VyYXNlKHVpbnQzMl90IHBhZ2VfYWRkcikKK3sgICAKKyAgICAvL3ZvbGF0aWxlIHN0cnVjdCBzcGlmY19yZWdfdCogc3BpCT0gKHN0cnVjdCBzcGlmY19yZWdfdCopc3BpZmNfZ2V0X3JlZ19iYXNlKCk7CisgICAgCisgICAgaW50IHJldCA9IFNVQ0NFU1M7CisgICAgdWludDMyX3QgcmV0cmllcyA9IFNQSV9OQU5EX1JFVFJJRTsKKyAgICB1aW50OF90IHN0YXR1cyA9IDA7CisKKyAgICBzdHJ1Y3Qgc3BpZmxhc2hfY21kX3QgY21kID0geyAgIENNRF9CTE9DS19FUkFTRSwgICAgICAgIC8qINa4we7C6yAqLworICAgICAgICAgICAgICAgMSwgICAgICAgICAgICAgICAgICAgICAgLyogtdjWt8Lrt6LLzcq5xNwgKi8KKyAgICAgICAgICAgICAgIEZDX0FERFJfQllURV9OVU1fMjQsICAgIC8qILXY1rfC67OktsggKi8KKyAgICAgICAgICAgICAgIDAsICAgICAgICAgICAgICAgICAgICAgIC8qILeiy83K/b7dyrnE3C0tLdC0ICovCisgICAgICAgICAgICAgICAwLCAgICAgICAgICAgICAgICAgICAgICAvKiC908rVyv2+3cq5xNwtLS22wSAqLworICAgICAgICAgICAgICAgMCwgICAgICAgICAgICAgICAgICAgICAgLyogv9XP0LXItP3W3MbayrnE3CAqLworICAgICAgICAgICAgICAgMCwgICAgICAgICAgICAgICAgICAgICAgLyogv9XP0LXItP3W3MbaIHg4ICovCisgICAgICAgICAgICAgICAwICAgICAgICAgICAgICAgICAgICAgICAvKiC/1c/Qtci0/dbcxtogeDEgKi8KKyAgICB9OworICAgIGRvCisgICAgeworICAgICAgICBzcGlfZmNfY2xlYXJfZmlmbygpOworICAgICAgICBzcGlfZmNfY2xlYXJfaW50KCk7CisgICAgICAgIHNwaV9mY19jb25maWdfY3RybChGQ19ETUFfTk9ORSk7CisgICAgICAgIHNwaV9mY19zZXR1cF9jbWQoJmNtZCwgcGFnZV9hZGRyLCAwKTsgICAvKiDD/MHuxeTWwyAqLworICAgICAgICBzcGlfZmNfc3RhcnQoKTsgICAgICAgICAgICAgICAgICAgICAgICAgIC8qIL+qyry0q8rkICovCisgICAgICAgIHJldCA9IHNwaV9mY193YWl0X2NtZF9lbmQoKTsgICAgICAgICAgICAgLyogtci0/cP8we694cr4ICovCisgICAgICAgIGlmICggcmV0ICE9IFNVQ0NFU1MgKQorICAgICAgICB7CisgICAgICAgICAgICBjb250aW51ZTsgICAvKiC0q8rkyqew3KOsveHK+LG+tM7Rrbu3sqLW2LSrICovCisgICAgICAgIH0KKworICAgICAgICAvKiC1yLT9w/zB7ta00NDN6rPJICovCisgICAgICAgIGRvCisgICAgICAgIHsJCisgICAgICAgIAltc2xlZXAoMSk7CisgICAgICAgICAgICByZXQgPSBzcGlmY19nZXRfZmVhdHVyZShSRUdfU1RBVFVTLCAmc3RhdHVzKTsKKyAgICAgICAgfXdoaWxlKCBzdGF0dXMgJiBPSVApOworCQkKKyAgICAgICAgaWYoIHN0YXR1cyAmIEVfRkFJTCApCisgICAgICAgIHsgICAKKwkJCWlmKChyZXRyaWVzLTEpICE9MCkKKwkJCXsKKwkJCQljb250aW51ZTsKKwkJCX0KKyAgICAgICAgICAgIHJldHVybiBOQU5EX1NUQVRVU19GQUlMOworICAgICAgICB9CisKKyAgICAgICAgYnJlYWs7CisgICAgfQorICAgIHdoaWxlICggLS1yZXRyaWVzICE9IDAgKTsKKworICAgIHJldHVybiByZXQ7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBGdW5jdGlvbjogICAgc3BpZmNfcmVhZF9wYWdlX3RvX2NhY2hlCisgKiBEZXNjcmlwdGlvbjoKKyAqIFBhcmFtZXRlcnM6CisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczogIFtJbnN0cnVjdGlvbl0gICAgICAgfC0tYWRkciB3aWR0aCBpcyAyNCBiaXQocGFnZS9ibG9jayBhZGRyISEhISkKKyAgICAgICAgICAgIFthZGRyXSAgICAgICAgICAgICAgfC0tcGFnZSByZWFkCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwtLWJsb2NrIGVyYXNlCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwtLXByb2dyYW0gZXhlY3V0ZQorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIGludCBzcGlmY19yZWFkX3BhZ2VfdG9fY2FjaGUodWludDMyX3QgcGFnZV9hZGRyKQoreworICAgIC8vdm9sYXRpbGUgc3RydWN0IHNwaV90KiBzcGkgICAgPSAoc3RydWN0IHNwaV90KilTWVNfU1BJX05BTkRfQkFTRTsKKworICAgIGludCByZXQgPSBTVUNDRVNTOworICAgIHVpbnQzMl90IHJldHJpZXMgPSBTUElfTkFORF9SRVRSSUU7CisgICAgdWludDhfdCBzdGF0dXMgPSAwOworCisgICAgc3RydWN0IHNwaWZsYXNoX2NtZF90IGNtZCA9IHsgICBDTURfUkVBRF9QQUdFX1RPX0NBQ0hFLCAvKiDWuMHuwusgKi8KKyAgICAgICAgICAgICAgIDEsICAgICAgICAgICAgICAgICAgICAgIC8qILXY1rfC67eiy83KucTcICovCisgICAgICAgICAgICAgICBGQ19BRERSX0JZVEVfTlVNXzI0LCAgICAvKiC12Na3wuuzpLbIICovCisgICAgICAgICAgICAgICAwLCAgICAgICAgICAgICAgICAgICAgICAvKiC3osvNyv2+3cq5xNwtLS3QtCAqLworICAgICAgICAgICAgICAgMCwgICAgICAgICAgICAgICAgICAgICAgLyogvdPK1cr9vt3KucTcLS0ttsEgKi8KKyAgICAgICAgICAgICAgIDAsICAgICAgICAgICAgICAgICAgICAgIC8qIL/Vz9C1yLT91tzG2sq5xNwgKi8KKyAgICAgICAgICAgICAgIDAsICAgICAgICAgICAgICAgICAgICAgIC8qIL/Vz9C1yLT91tzG2iB4OCAqLworICAgICAgICAgICAgICAgMCAgICAgICAgICAgICAgICAgICAgICAgLyogv9XP0LXItP3W3MbaIHgxICovCisgICAgfTsKKyAgICBkbworICAgIHsKKyAgICAgICAgc3BpX2ZjX2NsZWFyX2ZpZm8oKTsKKyAgICAgICAgc3BpX2ZjX2NsZWFyX2ludCgpOworICAgICAgICBzcGlfZmNfY29uZmlnX2N0cmwoRkNfRE1BX05PTkUpOworICAgICAgICBzcGlfZmNfc2V0dXBfY21kKCZjbWQsIHBhZ2VfYWRkciwgMCk7ICAgLyogw/zB7sXk1sMgKi8KKyAgICAgICAgc3BpX2ZjX3N0YXJ0KCk7ICAgICAgICAgICAgICAgICAgICAgICAgICAvKiC/qsq8tKvK5CAqLworICAgICAgICByZXQgPSBzcGlfZmNfd2FpdF9jbWRfZW5kKCk7ICAgICAgICAgICAgIC8qILXItP3D/MHuveHK+CAqLworICAgICAgICBpZiAoIHJldCAhPSBTVUNDRVNTICkKKyAgICAgICAgeworICAgICAgICAgICAgY29udGludWU7ICAgLyogtKvK5MqnsNyjrL3hyvixvrTO0a27t7Ki1ti0qyAqLworICAgICAgICB9CisKKyAgICAgICAgLyogtci0/cP8we7WtNDQzeqzySAqLworICAgICAgICBkbworICAgICAgICB7CisgICAgICAgICAgICBzcGlmY19nZXRfZmVhdHVyZShSRUdfU1RBVFVTLCAmc3RhdHVzKTsKKyAgICAgICAgfXdoaWxlKCBzdGF0dXMgJiBPSVApOworCisgICAgICAgIGJyZWFrOworICAgIH0KKyAgICB3aGlsZSAoIC0tcmV0cmllcyAhPSAwICk7CisKKyAgICByZXR1cm4gcmV0OworfQorCisjZGVmaW5lCVRSQU5TX1VTRV9ETUEJMQorCitzdGF0aWMgdm9pZCBzcGlmY19kbWFfY2FsbGJhY2sodm9pZCAqZGF0YSkKK3sKKwlpbnQgZGlyID0gKGludClkYXRhOworCisJaWYoZGlyID09IEZDX0RNQV9SWCkKKwkJdXAoJmdfc3BpZmMucnhfc2VtYXBob3JlKTsKKwllbHNlIGlmKGRpciA9PSBGQ19ETUFfVFgpCisJCXVwKCZnX3NwaWZjLnR4X3NlbWFwaG9yZSk7CisJZWxzZQorCQlCVUcoKTsKK30KKworc3RhdGljIGludCBzcGlmY193YWl0X2RtYV9kb25lKGludCBkaXIpCit7CisJaWYoZGlyID09IEZDX0RNQV9SWCkKKwkJZG93bigmZ19zcGlmYy5yeF9zZW1hcGhvcmUpOworCWVsc2UgaWYoZGlyID09IEZDX0RNQV9UWCkKKwkJZG93bigmZ19zcGlmYy50eF9zZW1hcGhvcmUpOworCWVsc2UKKwkJQlVHKCk7CisJCisJcmV0dXJuIDA7Cit9CisKK3N0YXRpYyBpbnQgc3BpZmNfY29uZmlnX2RtYSh1aW50OF90ICpidWYsIHVpbnQzMl90IGxlbiwgaW50IGRpcikKK3sKKwlzdHJ1Y3QgZG1hX2NoYW4gKmNoYW47CisJc3RydWN0IGRtYV9hc3luY190eF9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NoYW4sKHN0cnVjdCBkbWFfc2xhdmVfY29uZmlnKikgJmRtYV9jb25mKTsKKwlpZihyZXQgIT0gMCkKKwl7CisJCXByX2luZm8oImRtYWVuZ2luZV9zbGF2ZV9jb25maWcgZmFpbGVkKCVkKX5+fn5+fiIsIHJldCk7CisJCXJldHVybiByZXQ7CisJfQorCisJZGVzYyA9IGNoYW4tPmRldmljZS0+ZGV2aWNlX3ByZXBfaW50ZXJsZWF2ZWRfZG1hKGNoYW4sIE5VTEwsIDApOworCWRlc2MtPmNhbGxiYWNrIAkJCT0gc3BpZmNfZG1hX2NhbGxiYWNrOworCWRlc2MtPmNhbGxiYWNrX3BhcmFtIAk9IGRpcjsKKwlkbWFlbmdpbmVfc3VibWl0KGRlc2MpOworCWRtYV9hc3luY19pc3N1ZV9wZW5kaW5nKGNoYW4pOworCisJcmV0dXJuIDA7Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisgKiBGdW5jdGlvbjogICAgc3BpZmNfcmVhZF9mcm9tX2NhY2hlCisgKiBEZXNjcmlwdGlvbjogCisgKiBQYXJhbWV0ZXJzOgorICogICBJbnB1dDoKKyAqCisgKiAgIE91dHB1dDoKKyAqCisgKiBSZXR1cm5zOgorICoKKyAqCisgKiBPdGhlcnM6ICBbSW5zdHJ1Y3Rpb25dICAgICAgICAgICAgICAgICB8LS1hZGRyIHdpZHRoIGlzIDE2IGJpdAorICAgICAgICAgICAgW2FkZHJdICAgICAgICAgICAgICAgICAgICAgICAgfC0tZHVtbXkgY3ljZWwgOC80LzIKKyAgICAgICAgICAgIFtkdW1teV0gICAgICAgICAgICAgICAgICAgICAgIHwtLXJlYWQgZm9ybSBjYWNoZShYMSxYMixYNCkKKyAgICAgICAgICAgIFtkYXRhX3J4XSAgICAgICAgICAgICAgICAgICAgIHwtLXJlYWQgZm9ybSBjYWNoZShkdWFsLHF1YWQpSU8KKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3N0YXRpYyBpbnQgc3BpZmNfcmVhZF9mcm9tX2NhY2hlKHVpbnQzMl90IGNvbHVtbl9hZGRyLCB1aW50MzJfdCBsZW4sIHVpbnQ4X3QgKmJ1ZikKK3sgICAKKyAgICBpbnQgcmV0ID0gU1VDQ0VTUzsKKyAgICB1aW50MzJfdCByZXRyaWVzID0gU1BJX05BTkRfUkVUUklFOworICAgIHVpbnQzMl90IGxlbl90bXAgPSAwOworICAgIHN0cnVjdCBzcGlmbGFzaF9jbWRfdCBjbWQ7CisgICAgdWludDMyX3QgdHJhbnNfbW9kZSA9IHNwaV9uYW5kX2dldF90cmFuc19tb2RlKFJFQURfVFJBTlNGRVJfTU9ERSk7CisKKyAgICBzcGlfZmNfc2V0dXBfdGFuc21vZCh0cmFuc19tb2RlKTsKKworICAgIHN3aXRjaCAodHJhbnNfbW9kZSkKKyAgICB7CisgICAgICAgIGNhc2UgUkRRSU9fTU9ERToKKyAgICAgICAgICAgIGNtZC5jbWQgPSBDTURfUkVBRF9GUk9NX0NBQ0hFX1FJTzsgICAgICAgLyog1rjB7sLrICovCisgICAgICAgICAgICBjbWQuZHVteV9ieXRlcyA9IDA7ICAgICAgICAgICAgICAgICAgICAgIC8qIL/Vz9C1yLT91tzG2iB4OCAqLworICAgICAgICAgICAgaWYoZ19tYWZfaWQgPT0gMHhFRikKKwkJCXsKKwkJCQljbWQuZHVteV9iaXRzID0gNDsgICAgICAgICAgICAgICAgICAgICAgLyogv9XP0LXItP3W3MbaIHgxICovCisJCQl9CisJCQllbHNlCisJCQl7CisJCQkJY21kLmR1bXlfYml0cyA9IDI7CQkJCQkJIC8qIL/Vz9C1yLT91tzG2iB4MSAqLworCQkJfQorICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgUkRYNF9NT0RFOiAKKyAgICAgICAgICAgIGNtZC5jbWQgPSBDTURfUkVBRF9GUk9NX0NBQ0hFX1g0OyAgICAgICAgLyog1rjB7sLrICovCisgICAgICAgICAgICBjbWQuZHVteV9ieXRlcyA9IDE7ICAgICAgICAgICAgICAgICAgICAgIC8qIL/Vz9C1yLT91tzG2iB4OCAqLworICAgICAgICAgICAgY21kLmR1bXlfYml0cyA9IDA7ICAgICAgICAgICAgICAgICAgICAgICAvKiC/1c/Qtci0/dbcxtogeDEgKi8KKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgY21kLmNtZCA9IENNRF9SRUFEX0ZST01fQ0FDSEU7ICAgICAgICAgICAvKiDWuMHuwusgKi8KKyAgICAgICAgICAgIGNtZC5kdW15X2J5dGVzID0gMTsgICAgICAgICAgICAgICAgICAgICAgLyogv9XP0LXItP3W3MbaIHg4ICovCisgICAgICAgICAgICBjbWQuZHVteV9iaXRzID0gMDsgICAgICAgICAgICAgICAgICAgICAgIC8qIL/Vz9C1yLT91tzG2iB4MSAqLworICAgICAgICAgICAgYnJlYWs7CisgICAgfQorCQorICAgIGNtZC5hZGRyX3R4X2VuID0gMTsgICAgICAgICAgICAgICAgICAgICAgLyogtdjWt8Lrt6LLzcq5xNwgKi8KKyAgICBjbWQuYWRkcl93aWR0aCA9IEZDX0FERFJfQllURV9OVU1fMTY7ICAgIC8qILXY1rfC67OktsggKi8KKyAgICBjbWQuZGF0YV90eF9lbiA9IDA7ICAgICAgICAgICAgICAgICAgICAgIC8qILeiy83K/b7dyrnE3C0tLdC0ICovCisgICAgY21kLmRhdGFfcnhfZW4gPSAxOyAgICAgICAgICAgICAgICAgICAgICAvKiC908rVyv2+3cq5xNwtLS22wSAqLworICAgIGNtZC5kdW15X3R4X2VuID0gMTsgICAgICAgICAgICAgICAgICAgICAgLyogv9XP0LXItP3W3MbayrnE3CAqLworCisgICAgZG8KKyAgICB7CisgICAgICAgIHNwaV9mY19jbGVhcl9maWZvKCk7CisgICAgICAgIHNwaV9mY19jbGVhcl9pbnQoKTsKKwkJc3BpX2ZjX3NldHVwX2NtZCgmY21kLCBjb2x1bW5fYWRkciwgbGVuKTsJCS8qIMP8we7F5NbDICovCisjaWYJVFJBTlNfVVNFX0RNQQorCQlzcGlmY19jb25maWdfZG1hKGJ1ZiwgbGVuLCBGQ19ETUFfUlgpOwkJCisJCXNwaV9mY19jb25maWdfY3RybChGQ19ETUFfUlgpOworCQlzcGlfZmNfc3RhcnQoKTsgCQkJCQkJCQkvKiC/qsq8tKvK5CAqLwkJCisjZWxzZQorICAgICAgICBzcGlfZmNfY29uZmlnX2N0cmwoRkNfRE1BX05PTkUpOworICAgICAgICBzcGlfZmNfc3RhcnQoKTsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiC/qsq8tKvK5CAqLworCisgICAgICAgIGxlbl90bXAgPSBzcGlfZmNfcmVhZF9maWZvKGxlbiwgYnVmKTsgICAgICAgICAgIC8qILbByKHK/b7dICovCisgICAgICAgIGlmICggbGVuX3RtcCAhPSBsZW4gKQorICAgICAgICB7CisgICAgICAgICAgICByZXQgPSAtMjsKKyAgICAgICAgICAgIGNvbnRpbnVlOyAgIC8qILSryuTKp7Dco6y94cr4sb60ztGtu7eyotbYtKsgKi8KKyAgICAgICAgfQorI2VuZGlmCisgICAgICAgIHJldCA9IHNwaV9mY193YWl0X2NtZF9lbmQoKTsgICAgICAgICAgICAgICAgICAgIC8qILXItP3D/MHuveHK+CAqLworICAgICAgICBpZiAoIHJldCAhPSBTVUNDRVNTICkKKyAgICAgICAgeworICAgICAgICAgICAgY29udGludWU7ICAgLyogtKvK5MqnsNyjrL3hyvixvrTO0a27t7Ki1ti0qyAqLworICAgICAgICB9CisKKyNpZiBUUkFOU19VU0VfRE1BCisJCXNwaWZjX3dhaXRfZG1hX2RvbmUoRkNfRE1BX1JYKTsKKwkJc3BpX2ZjX2NvbmZpZ19jdHJsKEZDX0RNQV9OT05FKTsgCisjZW5kaWYKKworICAgICAgICBicmVhazsKKyAgICB9CisgICAgd2hpbGUgKCAtLXJldHJpZXMgIT0gMCApOworCisgICAgc3BpX2ZjX3NldHVwX3RhbnNtb2QoU0lOR0xFX01PREUpOworCisgICAgcmV0dXJuIHJldDsKK30KKworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogRnVuY3Rpb246ICAgIHNwaWZjX3BhZ2VfbG9hZAorICogRGVzY3JpcHRpb246IAorICogUGFyYW1ldGVyczoKKyAqICAgSW5wdXQ6CisgKgorICogICBPdXRwdXQ6CisgKgorICogUmV0dXJuczoKKyAqCisgKgorICogT3RoZXJzOiAgW0luc3RydWN0aW9uXQorICAgICAgICAgICAgW2FkZHJdCisgICAgICAgICAgICBbZGF0YV90eF0gICAgICAgICAgICAgICAgICAgICB8LS1hZGRyIHdpZHRoIGlzIDE2IGJpdAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfC0tcHJvZ3JhbSBsb2FkKFgxLFg0KQorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIGludCBzcGlmY19wYWdlX2xvYWQodWludDMyX3QgY29sdW1uX2FkZHIsIHVpbnQ4X3QqIGJ1ZiwgdWludDMyX3QgcGFnZV9sZW4sIAorCQkJCQkJdWludDhfdCAqb29iLCB1aW50MzJfdCBvb2JfbGVuKQoreyAgIAorICAgIGludCByZXQgPSBTVUNDRVNTOworICAgIHVpbnQzMl90IHJldHJpZXMgPSBTUElfTkFORF9SRVRSSUU7CisgICAgc3RydWN0IHNwaWZsYXNoX2NtZF90IGNtZDsKKyAgICB1aW50MzJfdCB0cmFuc19tb2RlID0gc3BpX25hbmRfZ2V0X3RyYW5zX21vZGUoV1JJVEVfVFJBTlNGRVJfTU9ERSk7CisKKyAgICBzd2l0Y2ggKHRyYW5zX21vZGUpCisgICAgeworICAgICAgICBjYXNlIFBMWDRfTU9ERToKKyAgICAgICAgICAgICBjbWQuY21kID0gQ01EX1BST0dSQU1fTE9BRF9YNDsgIC8qINa4we7C6yAqLworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgY21kLmNtZCA9IENNRF9QUk9HUkFNX0xPQUQ7CisgICAgICAgICAgICBicmVhazsKKyAgICB9CisJCisgICAgY21kLmFkZHJfdHhfZW4gPSAxOyAgICAgICAgICAgICAgICAgICAgICAvKiC12Na3wuu3osvNyrnE3CAqLworICAgIGNtZC5hZGRyX3dpZHRoID0gRkNfQUREUl9CWVRFX05VTV8xNjsgICAgLyogtdjWt8Lrs6S2yCAqLworICAgIGNtZC5kYXRhX3R4X2VuID0gMTsgICAgICAgICAgICAgICAgICAgICAgLyogt6LLzcr9vt3KucTcLS0t0LQgKi8KKyAgICBjbWQuZGF0YV9yeF9lbiA9IDA7ICAgICAgICAgICAgICAgICAgICAgIC8qIL3TytXK/b7dyrnE3C0tLbbBICovCisgICAgY21kLmR1bXlfdHhfZW4gPSAwOyAgICAgICAgICAgICAgICAgICAgICAvKiC/1c/Qtci0/dbcxtrKucTcICovCisgICAgY21kLmR1bXlfYnl0ZXMgPSAwOyAgICAgICAgICAgICAgICAgICAgICAvKiC/1c/Qtci0/dbcxtogeDggKi8KKyAgICBjbWQuZHVteV9iaXRzID0gMDsgICAgICAgICAgICAgICAgICAgICAgIC8qIL/Vz9C1yLT91tzG2iB4MSAqLworCisgICAgZG8KKyAgICB7CisgICAgICAgIHNwaV9mY19jbGVhcl9maWZvKCk7CisgICAgICAgIHNwaV9mY19jbGVhcl9pbnQoKTsKKyAgICAgICAgc3BpX2ZjX3NldHVwX2NtZCgmY21kLCBjb2x1bW5fYWRkciwgcGFnZV9sZW4rb29iX2xlbik7ICAgICAgIC8qIMP8we7F5NbDICovCisjaWYgVFJBTlNfVVNFX0RNQQorCQlpZihvb2IpCisJCQlzcGlmY19jb25maWdfZG1hKGJ1ZiwgcGFnZV9sZW4rb29iX2xlbiwgRkNfRE1BX1RYKTsKKwkJZWxzZQorCQkJc3BpZmNfY29uZmlnX2RtYShidWYsIHBhZ2VfbGVuLCBGQ19ETUFfVFgpOworCQlzcGlfZmNfY29uZmlnX2N0cmwoRkNfRE1BX1RYKTsKKwkJc3BpX2ZjX3NldHVwX3RhbnNtb2QodHJhbnNfbW9kZSk7CQkKKwkJc3BpX2ZjX3N0YXJ0KCk7IAkJCQkJCQkJLyogv6rKvLSryuQgKi8JCQorI2Vsc2UJCQorICAgICAgICBzcGlfZmNfY29uZmlnX2N0cmwoRkNfRE1BX05PTkUpOworICAgICAgICBzcGlfZmNfc2V0dXBfdGFuc21vZCh0cmFuc19tb2RlKTsKKyAgICAgICAgc3BpX2ZjX3N0YXJ0KCk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogv6rKvLSryuQgKi8KKyAgICAgICAgc3BpX2ZjX3dyaXRlX2ZpZm8oYnVmLCBwYWdlX2xlbiwgb29iLCBvb2JfbGVuKTsgICAgICAgICAgICAgICAvKrGj1qS0q83qKi8KKyNlbmRpZgkJCisgICAgICAgIHJldCA9IHNwaV9mY193YWl0X2NtZF9lbmQoKTsgICAgICAgICAgICAgICAgICAgIC8qILXItP3D/MHuveHK+CAqLworICAgICAgICBpZiAoIHJldCAhPSBTVUNDRVNTICkKKyAgICAgICAgeworICAgICAgICAgICAgY29udGludWU7ICAgLyogtKvK5MqnsNyjrL3hyvixvrTO0a27t7Ki1ti0qyAqLworICAgICAgICB9CisjaWYgVFJBTlNfVVNFX0RNQQorCQlzcGlmY193YWl0X2RtYV9kb25lKEZDX0RNQV9UWCk7CisJCXNwaV9mY19jb25maWdfY3RybChGQ19ETUFfTk9ORSk7IAorI2VuZGlmCQkKKyAgICAgICAgYnJlYWs7CisgICAgfQorICAgIHdoaWxlICggLS1yZXRyaWVzICE9IDAgKTsKKworICAgIHNwaV9mY19zZXR1cF90YW5zbW9kKFNJTkdMRV9NT0RFKTsKKworICAgIHJldHVybiByZXQ7Cit9CisKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIEZ1bmN0aW9uOiAgICBzcGlmY19wcm9ncmFtX2V4ZWMKKyAqIERlc2NyaXB0aW9uOiAKKyAqIFBhcmFtZXRlcnM6CisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczogIFtJbnN0cnVjdGlvbl0gICAgICAgfC0tYWRkciB3aWR0aCBpcyAyNCBiaXQocGFnZS9ibG9jayBhZGRyISEhISkKKyAgICAgICAgICAgIFthZGRyXSAgICAgICAgICAgICAgfC0tcHJvZ3JhbSBleGVjdXRlCisKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3N0YXRpYyBpbnQgc3BpZmNfcHJvZ3JhbV9leGVjKHVpbnQzMl90IHBhZ2VfYWRkcikKK3sgICAgCisgICAgaW50IHJldCA9IFNVQ0NFU1M7CisgICAgdWludDMyX3QgcmV0cmllcyA9IFNQSV9OQU5EX1JFVFJJRTsKKyAgICB1aW50OF90IHN0YXR1cyA9IDA7CisKKyAgICBzdHJ1Y3Qgc3BpZmxhc2hfY21kX3QgY21kID0geyAgIENNRF9QUk9HUkFNX0VYRUNVVEUsICAgIC8qINa4we7C6yAqLworICAgICAgICAgICAgICAgMSwgICAgICAgICAgICAgICAgICAgICAgLyogtdjWt8Lrt6LLzcq5xNwgKi8KKyAgICAgICAgICAgICAgIEZDX0FERFJfQllURV9OVU1fMjQsICAgIC8qILXY1rfC67OktsggKi8KKyAgICAgICAgICAgICAgIDAsICAgICAgICAgICAgICAgICAgICAgIC8qILeiy83K/b7dyrnE3C0tLdC0ICovCisgICAgICAgICAgICAgICAwLCAgICAgICAgICAgICAgICAgICAgICAvKiC908rVyv2+3cq5xNwtLS22wSAqLworICAgICAgICAgICAgICAgMCwgICAgICAgICAgICAgICAgICAgICAgLyogv9XP0LXItP3W3MbayrnE3CAqLworICAgICAgICAgICAgICAgMCwgICAgICAgICAgICAgICAgICAgICAgLyogv9XP0LXItP3W3MbaIHg4ICovCisgICAgICAgICAgICAgICAwICAgICAgICAgICAgICAgICAgICAgICAvKiC/1c/Qtci0/dbcxtogeDEgKi8KKyAgICB9OworICAgIGRvCisgICAgeworICAgICAgICBzcGlfZmNfY2xlYXJfZmlmbygpOworICAgICAgICBzcGlfZmNfY2xlYXJfaW50KCk7CisgICAgICAgIHNwaV9mY19jb25maWdfY3RybChGQ19ETUFfTk9ORSk7CisgICAgICAgIHNwaV9mY19zZXR1cF9jbWQoJmNtZCwgcGFnZV9hZGRyLCAwKTsgICAgICAgLyogw/zB7sXk1sMgKi8KKyAgICAgICAgc3BpX2ZjX3N0YXJ0KCk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiC/qsq8tKvK5CAqLworICAgICAgICByZXQgPSBzcGlfZmNfd2FpdF9jbWRfZW5kKCk7ICAgICAgICAgICAgICAgIC8qILXItP3D/MHuveHK+CAqLworICAgICAgICBpZiAoIHJldCAhPSBTVUNDRVNTICkKKyAgICAgICAgeworICAgICAgICAgICAgY29udGludWU7ICAgLyogtKvK5MqnsNyjrL3hyvixvrTO0a27t7Ki1ti0qyAqLworICAgICAgICB9CisKKyAgICAgICAgLyogtci0/cP8we7WtNDQzeqzySAqLworICAgICAgICBkbworICAgICAgICB7CisgICAgICAgICAgICBzcGlmY19nZXRfZmVhdHVyZShSRUdfU1RBVFVTLCAmc3RhdHVzKTsKKwkJCWlmKCEoc3RhdHVzICYgT0lQKSkKKwkJCXsKKwkJCQlicmVhazsKKwkJCX0KKwkJCXVzbGVlcF9yYW5nZSg1MCw1MCk7CisgICAgICAgIH13aGlsZShzdGF0dXMgJiBPSV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30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKyAqIEZ1bmN0aW9uOiAgICBzcGlmY19od19pbml0CisgKiBEZXNjcmlwdGlvbjoKKyAqIFBhcmFtZXRlcnM6CisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3N0YXRpYyB2b2lkIHNwaWZjX2h3X2luaXQoc3RydWN0IHNwaV9uYW5kX2luZm8gKnNwaWZjKQoreworICAgIGludCByZXQ7CisKKwkvKmNvbmZpZ3VyZSBncGlvMTIgdG8gc2ZjX2RhdGEzKi8KKwlyZXQgPSBncGlvX3JlcXVlc3QoOTgsICJzZmNfZGF0YTMiKTsKKwlpZiAocmV0KQorCXsJCisJCXByaW50aygiZ3BpbyBmYWlsIDFcbiIpOworCQl6RHJ2X0FTU0VSVCgwKTsKKwkJcmV0dXJuOworCX0KKwl6eDI5X2dwaW9fY29uZmlnKDk4LCAweDEpOworCQorCS8qY29uZmlndXJlIGdwaW8xMSB0byBzZmNfZGF0YTIqLworCXJldCA9IGdwaW9fcmVxdWVzdCg5NywgInNmY19kYXRhMiIpOworCWlmIChyZXQpCisJewkKKwkJcHJpbnRrKCJncGlvIGZhaWwgMlxuIik7CisJCXpEcnZfQVNTRVJUKDApOworCQlyZXR1cm47CisJfQorCXp4MjlfZ3Bpb19jb25maWcoOTcsIDB4MSk7CisJCisJLypjb25maWd1cmUgZ3BpbzEwIHRvIHNmY19kYXRhMiovCisJcmV0ID0gZ3Bpb19yZXF1ZXN0KDk2LCAic2ZjX2RhdGExIik7CisJaWYgKHJldCkKKwl7CQorCQlwcmludGsoImdwaW8gZmFpbCAzXG4iKTsKKwkJekRydl9BU1NFUlQoMCk7CisJCXJldHVybjsKKwl9CisJengyOV9ncGlvX2NvbmZpZyg5NiwgMHgxKTsKKwkKKwkvKmNvbmZpZ3VyZSBncGlvOSB0byBzZmNfZGF0YTAqLworCXJldCA9IGdwaW9fcmVxdWVzdCg5NSwgInNmY19kYXRhMCIpOworCWlmIChyZXQpCisJewkKKwkJcHJpbnRrKCJncGlvIGZhaWwgNFxuIik7CisJCXpEcnZfQVNTRVJUKDApOworCQlyZXR1cm47CisJfQorCXp4MjlfZ3Bpb19jb25maWcoOTUsIDB4MSk7CisKKy8qY29uZmlndXJlIGdwaW81IHRvIHNmY19jcyovCisJcmV0ID0gZ3Bpb19yZXF1ZXN0KDkzLCAic2ZjX2NzIik7CisJaWYgKHJldCkKKwl7CQorCQlwcmludGsoImdwaW8gZmFpbCA1XG4iKTsKKwkJekRydl9BU1NFUlQoMCk7CisJCXJldHVybjsKKwl9CisJengyOV9ncGlvX2NvbmZpZyg5MywgMHgxKTsKKworLypjb25maWd1cmUgZ3BpbzMgdG8gc2ZjX3NjbGsqLworCXJldCA9IGdwaW9fcmVxdWVzdCg5NCwgInNmY19zY2xrIik7CisJaWYgKHJldCkKKwl7CQorCQlwcmludGsoImdwaW8gZmFpbCA2XG4iKTsKKwkJekRydl9BU1NFUlQoMCk7CisJCXJldHVybjsKKwl9CisJengyOV9ncGlvX2NvbmZpZyg5NCwgMHgxKTsKKworICAgIHNwaWZjLT5tYXhfYmFua3MgPSAxOwkKKwlzcGlfZmNfZW5hYmxlKCk7CQorCisJcHJpbnRrKCJncGlvLGNsayAsc3BpZmMgZW4gb2tcbiIpOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogRnVuY3Rpb246ICAgIHNwaWZjX2xvY2svdW5sb2NrCisgKiBEZXNjcmlwdGlvbjoKKyAqIFBhcmFtZXRlcnM6CisgKiAgIElucHV0OgorICoKKyAqICAgT3V0cHV0OgorICoKKyAqIFJldHVybnM6CisgKgorICoKKyAqIE90aGVyczoKKyAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK3N0YXRpYyB2b2lkIHNwaWZjX2xvY2sodm9pZCkKK3sKKwlpZighZ19zcGlmYy5pbnRfZW5fZmxhZykKKwl7CisJCWVuYWJsZV9pcnEoZ19zcGlmYy5pcnEpOworCQlnX3NwaWZjLmludF9lbl9mbGFnID0xOworCX0JCit9CisKK3N0YXRpYyB2b2lkIHNwaWZjX3VubG9jayh2b2lkKQoreworCWNsZWFyX2ludGVycnVwdHMoKTsKKwlpZihnX3NwaWZjLmludF9lbl9mbGFnKQorCXsKKwkJZGlzYWJsZV9pcnEoZ19zcGlmYy5pcnEpOworCQlnX3NwaWZjLmludF9lbl9mbGFnID0gMDsKKwl9Cit9CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqYWRkKioqKioqKioqKioqKioqKiovCitzdGF0aWMgdWludDMyX3Qgc3BpX2ZjX3dhaXRfY21kX2VuZCh2b2lkKQoreworCXVuc2lnbmVkIGxvbmcgY29tcF9yZXMsIGZsYWdzID0gMDsKKwl1aW50MzJfdCBpbnRyX3N0YXR1cyA9IDA7CisJYm9vbCByZXRyeSA9IGZhbHNlOworCXVuc2lnbmVkIGxvbmcgdGltZW91dCA9IG1zZWNzX3RvX2ppZmZpZXMoMTAwMCk7CisgICAgdm9sYXRpbGUgc3RydWN0IHNwaWZjX3JlZ190KiBzcGkJPSAoc3RydWN0IHNwaWZjX3JlZ190KilzcGlmY19nZXRfcmVnX2Jhc2UoKTsKKworCXdoaWxlICggc3BpLT5TRkNfU1RBUlQgJiBGQ19CVVNZICk7CisJCisJZG8geworCQkvL2NvbXBfcmVzID0gd2FpdF9mb3JfY29tcGxldGlvbl90aW1lb3V0KCZnX3NwaWZjLmNvbXBsZXRlLCB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jwb3JhdGlvbi4KKyoKKyogRmlsZU5hbWU6OiAgICB6eGljX3NwaWZjLmgKKyogRmlsZSBNYXJrOgorKiBEZXNjcmlwdGlvbjoKKyogT3RoZXJzOgorKiBWZXJzaW9uOgorKiBBdXRob3I6CisqIERhdGU6CisKKyogSGlzdG9yeSAxOgorKiAgICAgRGF0ZTogMjAxNC4xLjE1CisqICAgICBWZXJzaW9uOgorKiAgICAgQXV0aG9yOiB6aG91cWkKKyogICAgIE1vZGlmaWNhdGlvbjoKKyogSGlzdG9yeSAyOgorKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworI2lmbmRlZiBfX1pYSUNfU1BJRkNfSF9fCisjZGVmaW5lIF9fWlhJQ19TUElGQ19IX18KKworI2luY2x1ZGUgPGxpbnV4L3NlbWFwaG9yZS5oPgorCisjZGVmaW5lIFNGX0RBVEEJICAJCShaWDI5X1NQSUZDMF9QSFlTKzB4MzgpCisKKyNkZWZpbmUgU1BJX05BTkRfUkVUUklFIDMKKyNkZWZpbmUgU1VDQ0VTUyAgICAgICAgIDAKKworLyogZmZzZGVmcy5oICovCisjZGVmaW5lIENMRUFSIAkJCTAgICAgICAgICAgICAgICAgIC8qdXNlIHRoaXMgdG8gY2xlYXIgYSBmaWVsZCBpbnN0ZWFkIG9mICJmYWlsIiovCisjZGVmaW5lIFNFVCAgIAkJCTEgICAgICAgICAgICAgICAgIC8qdXNlIHRoaXMgdG8gc2V0IGEgZmllbGQgaW5zdGVhZCBvZiAicGFzcyIqLworI2RlZmluZSBGQUlMIAkJCTEgICAgICAgICAgICAgICAgICAvKmZhaWxlZCBmbGFnKi8KKyNkZWZpbmUgUEFTUyAJCQkwICAgICAgICAgICAgICAgICAgLypzdWNjZXNzIGZsYWcqLworI2RlZmluZSBFUlIgCQkJLTEgICAgICAgICAgICAgICAgICAvKmVycm9yIGZsYWcqLworCisjZGVmaW5lIFpYNzUxMCAzCisKK3N0cnVjdCBzcGlmY19pbmZvCit7CisJdm9pZCBfX2lvbWVtICoJCWZsYXNoX3JlZzsKKwl1aW50MzJfdCAJCQlpcnE7CisJdWludDMyX3QgCQkJaXJxX3N0YXR1czsKKwlzdHJ1Y3Qgc2VtYXBob3JlIAljbWRfZG9uZV9zZW07CisJcmF3X3NwaW5sb2NrX3QgCQlpcnFfbG9jazsKKwlpbnQgCQkJCWludF9lbl9mbGFnOworCXU2NCAJCQkJZG1hX21hc2s7CisJaW50IAkJCQlmbGFzaF9iYW5rOyAvKiBjdXJyZW50bHkgc2VsZWN0ZWQgY2hpcCAqLworCisJc3RydWN0IGRtYV9jaGFuCQkqcnhfY2hhbm5lbDsKKwlzdHJ1Y3QgZG1hX2NoYW4JCSp0eF9jaGFubmVsOworCXN0cnVjdCBzZW1hcGhvcmUJcnhfc2VtYXBob3JlOworCXN0cnVjdCBzZW1hcGhvcmUJdHhfc2VtYXBob3JlOwkKK307CisKK3N0cnVjdCBzcGlmY19yZWdfdAoreworICAgIHVpbnQzMl90ICAgICBWRVJfUkVHOyAgICAgICAgICAgICAgICAgICAgICAgIC8vMHgwMAorICAgIHVpbnQzMl90ICAgICBTRkNfU1RBUlQ7ICAgICAgICAgICAgICAgICAgICAgIC8vMHgwNAorICAgIHVpbnQzMl90ICAgICBTRkNfRU47ICAgICAgICAgICAgICAgICAgICAgICAgIC8vMHgwOAorICAgIHVpbnQzMl90ICAgICBTRkNfQ1RSTDA7ICAgICAgICAgICAgICAgICAgICAgIC8vMHgwYworICAgIHVpbnQzMl90ICAgICBTRkNfQ1RSTDE7ICAgICAgICAgICAgICAgICAgICAgIC8vMHgxMAorICAgIHVpbnQzMl90ICAgICBTRkNfQ1RSTDI7ICAgICAgICAgICAgICAgICAgICAgIC8vMHgxNAorICAgIHVpbnQzMl90ICAgICBTRkNfQllURV9OVU07ICAgICAgICAgICAgICAgICAgIC8vMHgxOAorICAgIHVpbnQzMl90ICAgICBTRkNfQUREUjsgICAgICAgICAgICAgICAgICAgICAgIC8vMHgxYworICAgIHVpbnQzMl90ICAgICBTRkNfSU5TOyAgICAgICAgICAgICAgICAgICAgICAgIC8vMHgyMAorICAgIHVpbnQzMl90ICAgICBTRkNfVElNSU5HOyAgICAgICAgICAgICAgICAgICAgIC8vMHgyNAorICAgIHVpbnQzMl90ICAgICBTRkNfSU5UX0VOOyAgICAgICAgICAgICAgICAgICAgIC8vMHgyOAorICAgIHVpbnQzMl90ICAgICBTRkNfSU5UX1JBVzsgICAgICAgICAgICAgICAgICAgIC8vMHgyYworICAgIHVpbnQzMl90ICAgICBTRkNfSU5UX1NXX0NMUjsgICAgICAgICAgICAgICAgIC8vMHgzMAorICAgIHVpbnQzMl90ICAgICBTRkNfU1c7ICAgICAgICAgICAgICAgICAgICAgICAgIC8vMHgzNAorICAgIHVpbnQzMl90ICAgICBTRkNfREFUQTsgICAgICAgICAgICAgICAgICAgICAgIC8vMHgzOAorfTsKKworLypzcGlmYyBzdGFydCAweDQqLworI2RlZmluZSAgICAgRkNfU1RBUlQgICAgICAgICAgICAJCSgxPDwwKQorI2RlZmluZSAgICAgRkNfQlVTWSAgICAgICAgICAgICAJCSgxPDwwKQorCisvKnNwaWZjIGVuYWJsZSAweDgqLworI2RlZmluZSAgICAgRkNfRU5fQkFDSyAgICAgICAgICAJCSgxPDwxKQorI2RlZmluZSAgICAgRkNfRU4gICAgICAgICAgICAgICAJCSgxPDwwKQorCisvKnNwaWZjIG1haW4gY3RyMCAweGMqLworI2RlZmluZSAgICAgRkNfU0NMS19QQVVTRV9DTFJfQUxMT1cgICAgICgxPDwxNykKKyNkZWZpbmUgICAgIEZDX1NDTEtfUEFVU0VfRU4gICAgICAgICAgICAoMTw8MTYpCisjZGVmaW5lICAgICBGQ19UWEZJRk9fQ0xSICAgICAgICAgICAgICAgKDE8PDE1KQorI2RlZmluZSAgICAgRkNfUlhGSUZPX0NMUiAgICAgICAgICAgICAgICgxPDwxNCkKKyNkZWZpbmUgICAgIEZDX1RYRklGT19USFJFUyAgICAgICAgICAgICAoMTw8MTApCisjZGVmaW5lICAgICBGQ19SWEZJRk9fVEhSRVMgICAgICAgICAgICAgKDE8PDYpCisjZGVmaW5lICAgICBGQ19UWF9ETUFfRU4gICAgICAgICAgICAgICAgKDE8PDUpCisjZGVmaW5lICAgICBGQ19SWF9ETUFfRU4gICAgICAgICAgICAgICAgKDE8PDQpCisjZGVmaW5lICAgICBGQ19XRE9HX0VOICAgICAgICAgICAgICAgICAgKDE8PDMpCisjZGVmaW5lICAgICBGQ19TUElfTU9ERSAgICAgICAgICAgICAgICAgKDE8PDEpCisjZGVmaW5lICAgICBGQ19XUl9QUk9URUNUICAgICAgICAgICAgICAgKDE8PDApCisKKy8qc3BpZmMgY3RybDEgMHgxMCAgaW4gdGhlIGNvbmRpdGlvbiA6IFNGQ19FTiA9IDEgU0ZDX0JVU1kgPSAwKi8KKyNkZWZpbmUgICAgIEZDX0FERFJfVFhfRU4gICAgICAgICAgIAkoNCkKKyNkZWZpbmUgICAgIEZDX0RVTU1ZX1RYX0VOICAgICAgICAgIAkoMikKKyNkZWZpbmUgICAgIEZDX1JFQURfREFUX0VOICAgICAgICAgIAkoMSkKKyNkZWZpbmUgICAgIEZDX1dSSVRFX0RBVF9FTiAgICAgICAgIAkoMCkKKworLypzcGlmYyBjdHJsMiAweDE0Ki8KKyNkZWZpbmUgICAgIEZDX0RVTU1ZX0JZVEVfTlVNICAgICAgICAgICAoMTIpICAvKiBbMTI6MTV9ICovCisjZGVmaW5lICAgICBGQ19EVU1NWV9CSVRfTlVNICAgICAgICAgICAgKDgpICAgLyogWzg6MTBdICovCisjZGVmaW5lICAgICBGQ19BRERSX0JZVEVfTlVNICAgICAgICAgICAgKDUpICAgLyogWzU6Nl0gKi8KKyNkZWZpbmUgICAgIEZDX0FERFJfQllURV9OVU1fOCAgICAgICAgICAoMCkKKyNkZWZpbmUgICAgIEZDX0FERFJfQllURV9OVU1fMTYgICAgICAgICAoMSkKKyNkZWZpbmUgICAgIEZDX0FERFJfQllURV9OVU1fMjQgICAgICAgICAoMikKKyNkZWZpbmUgICAgIEZDX0FERFJfQllURV9OVU1fMzIgICAgICAgICAoMykKKyNkZWZpbmUgICAgIEZDX0FERFJfTVVMVElfTElORV9FTiAgICAgICAoMTw8NCkKKyNkZWZpbmUgICAgIEZDX0RBVF9NVUxUSV9MSU5FX0VOICAgICAgICAoMTw8MikKKyNkZWZpbmUgICAgIEZDX1RSQU5TX01PRCAgICAgICAgICAgICAgICAoMTw8MCkKKworLypzcGlmYyB0aW1pbmcgMHgyNCovCisjZGVmaW5lICAgICBGQ19SRUFEX0RFTEFZICAgICAgICAgICAJKDE8PDE2KSAgIC8qIFsxNzoxNn0gKi8KKyNkZWZpbmUgICAgIEZDX1RfQ1NfU0VUVVAgICAgICAgICAgIAkoMTw8MTEpICAgLyogWzExOjEzfSAqLworI2RlZmluZSAgICAgRkNfVF9DU19IT0xEICAgICAgICAgICAgCSgxPDw2KSAgICAvKiBbODo2fSAqLworI2RlZmluZSAgICAgRkNfVF9DU19ERVNFTCAgICAgICAgICAgCSgxPDwwKSAgICAvKiBbMDozfSAqLworCisKKy8qc3BpZmMgaW50IGVuYWJsZSAweDI4Ki8KKyNkZWZpbmUgICAgIEZDX0lOVF9FTl9UWF9CWURfVEhFUyAgICAgICAoMTw8NykKKyNkZWZpbmUgICAgIEZDX0lOVF9FTl9SWF9CWURfVEhFUyAgICAgICAoMTw8NikKKyNkZWZpbmUgICAgIEZDX0lOVF9FTl9UWF9VTkRFUlJVTiAgICAgICAoMTw8NSkKKyNkZWZpbmUgICAgIEZDX0lOVF9FTl9SWF9PVkVSUlVOICAgICAgICAoMTw8NCkKKyNkZWZpbmUgICAgIEZDX0lOVF9FTl9XRE9HX09WRVJSVU4gICAgICAoMTw8MikKKyNkZWZpbmUgICAgIEZDX0lOVF9FTl9GTVRfRVJSICAgICAgICAgICAoMTw8MSkKKyNkZWZpbmUgICAgIEZDX0lOVF9FTl9DTURfRU5EICAgICAgICAgICAoMTw8MCkKKworLypzcGlmYyByYXcgaW50ZXJydXB0IDB4MmMqLworI2RlZmluZSAgICAgRkNfSU5UX1JBV19UWF9CWURfVEhFUyAgICAgICgxPDw3KQorI2RlZmluZSAgICAgRkNfSU5UX1JBV19SWF9CWURfVEhFUyAgICAgICgxPDw2KQorI2RlZmluZSAgICAgRkNfSU5UX1JBV19UWF9VTkRFUlJVTiAgICAgICgxPDw1KQorI2RlZmluZSAgICAgRkNfSU5UX1JBV19SWF9PVkVSUlVOICAgICAgICgxPDw0KQorI2RlZmluZSAgICAgRkNfSU5UX1JBV19XRE9HX09WRVJSVU4gICAgICgxPDwyKQorI2RlZmluZSAgICAgRkNfSU5UX1JBV19GTVRfRVJSICAgICAgICAgICgxPDwxKQorI2RlZmluZSAgICAgRkNfSU5UX1JBV19DTURfRU5EICAgICAgICAgICgxPDwwKQorI2RlZmluZSAgICAgRkNfSU5UX1JBV19FUlJfTUFTSyAgICAgICAgIChGQ19JTlRfUkFXX1RYX1VOREVSUlVOfFwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBGQ19JTlRfUkFXX1JYX09WRVJSVU58XAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZDX0lOVF9SQVdfV0RPR19PVkVSUlVOfFwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBGQ19JTlRfUkFXX0ZNVF9FUlIpCisKKy8qc3BpZmMgaW50IHN0YXJ0dXMgYW5kIGNsciAweDMwKi8KKyNkZWZpbmUgICAgIEZDX0lOVF9DTFJfVFhfQllEX1RIRVMgICAgICAoMTw8NykKKyNkZWZpbmUgICAgIEZDX0lOVF9DTFJfUlhfQllEX1RIRVMgICAgICAoMTw8NikKKyNkZWZpbmUgICAgIEZDX0lOVF9DTFJfVFhfVU5ERVJSVU4gICAgICAoMTw8NSkKKyNkZWZpbmUgICAgIEZDX0lOVF9DTFJfUlhfT1ZFUlJVTiAgICAgICAoMTw8NCkKKyNkZWZpbmUgICAgIEZDX0lOVF9DTFJfV0RPR19PVkVSUlVOICAgICAoMTw8MikKKyNkZWZpbmUgICAgIEZDX0lOVF9DTFJfRk1UX0VSUiAgICAgICAgICAoMTw8MSkKKyNkZWZpbmUgICAgIEZDX0lOVF9DTFJfQ01EX0VORCAgICAgICAgICAoMTw8MCkKKworLypzcGlmYyBzdyAweDM0Ki8KKyNkZWZpbmUgICAgIEZDX1RYX0ZJRk9fQ05UICAgICAgICAgICAgICAoMTYpCisjZGVmaW5lICAgICBGQ19UWF9GSUZPX0NOVF9NQVNLICAgICAgICAgKDB4MUYpICAgICAgLyogWzE2OjIwfSAqLworI2RlZmluZSAgICAgRkNfUlhfRklGT19DTlQgICAgICAgICAgICAgICg4KQorI2RlZmluZSAgICAgRkNfUlhfRklGT19DTlRfTUFTSyAgICAgICAgICgweDFGKSAgICAgIC8qIFs4OjEyfSAqLworI2RlZmluZSAgICAgRkNfVFhfQllEX1RIUkVTICAgICAgICAgICAgICgxPDw1KQorI2RlZmluZSAgICAgRkNfUlhfQllEX1RIUkVTICAgICAgICAgICAgICgxPDw0KQorI2RlZmluZSAgICAgRkNfU0NMS19QQVVTRV9GTEFHICAgICAgICAgICgxPDwzKQorI2RlZmluZSAgICAgRkNfV0FJVF9GTEFHICAgICAgICAgICAgICAgICgxPDwyKQorI2RlZmluZSAgICAgRkNfRk9STUFUX0VSUiAgICAgICAgICAgICAgICgxPDwxKQorCisKKyNkZWZpbmUgCUZDX0RNQV9OT05FICAgICAgICAgICAJCTAKKyNkZWZpbmUgCUZDX0RNQV9UWCAgICAgICAgICAgICAJCTEKKyNkZWZpbmUgCUZDX0RNQV9SWCAgICAgICAgICAgICAJCTIKKworI2RlZmluZSAJU1BJRkNfSVJRX0FMTAkJCQkoRkNfSU5UX0VOX0NNRF9FTkR8XAorCSAgICAgICAgICAgICAgICAgICAgIAkJCQlGQ19JTlRfRU5fRk1UX0VSUnxcCisJICAgICAgICAgICAgICAgICAgICAgCQk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SwgZG8gbm90aGluZyAqLworCQlpZiAoQmxvY2tNYXBbYmxvY2tdID09IHRhcmdldEVVTiB8fAorCQkgICAgKHBlbmRpbmdibG9jayA9PSAodGhpc1ZVQyAqIChuZnRsLT5FcmFzZVNpemUgLyA1MTIpICsgYmxvY2spKSkgeworCQkJY29udGludWU7CisJCX0KKworCQkvKiBjb3B5IG9ubHkgaW4gbm9uIGZyZWUgYmxvY2sgKGZyZWUgYmxvY2tzIGNhbiBvbmx5CisgICAgICAgICAgICAgICAgICAgaGFwcGVuIGluIGNhc2Ugb2YgbWVkaWEgZXJyb3JzIG9yIGRlbGV0ZWQgYmxvY2tzKSAqLworCQlpZiAoQmxvY2tNYXBbYmxvY2tdID09IEJMT0NLX05JTCkKKwkJCWNvbnRpbnVlOworCisJCXJldCA9IG10ZF9yZWFkKG10ZCwKKwkJCSAgICAgICAobmZ0bC0+RXJhc2VTaXplICogQmxvY2tNYXBbYmxvY2tdKSArIChibG9jayAqIDUxMiksCisJCQkgICAgICAgNTEyLAorCQkJICAgICAgICZyZXRsZW4sCisJCQkgICAgICAgbW92ZWJ1Zik7CisJCWlmIChyZXQgPCAwICYmICFtdGRfaXNfYml0ZmxpcChyZXQpKSB7CisJCQlyZXQgPSBtdGRfcmVhZChtdGQsCisJCQkJICAgICAgIChuZnRsLT5FcmFzZVNpemUgKiBCbG9ja01hcFtibG9ja10pICsgKGJsb2NrICogNTEyKSwKKwkJCQkgICAgICAgNTEyLAorCQkJCSAgICAgICAmcmV0bGVuLAorCQkJCSAgICAgICBtb3ZlYnVmKTsKKwkJCWlmIChyZXQgIT0gLUVJTykKKwkJCQlwcmludGsoIkVycm9yIHdlbnQgYXdheSBvbiByZXRyeS5cbiIpOworCQl9CisJCW1lbXNldCgmb29iLCAweGZmLCBzaXplb2Yoc3RydWN0IG5mdGxfb29iKSk7CisJCW9vYi5iLlN0YXR1cyA9IG9vYi5iLlN0YXR1czEgPSBTRUNUT1JfVVNFRDsKKworCQluZnRsX3dyaXRl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ZnRsX2JhcnJpZXIuYworICoKKyAqICBDb3B5cmlnaHQgKEMpIDIwMDIgVGhvbWFzIEdsZWl4bmVyICh0Z2x4QGxpbnV0cm9uaXguZGUpCisgKgorICogVGhpcyBwcm9ncmFtIGlzIGZyZWUgc29mdHdhcmU7IHlvdSBjYW4gcmVkaXN0cmlidXRlIGl0IGFuZC9vciBtb2RpZnkKKyAqIGl0IHVuZGVyIHRoZSB0ZXJtcyBvZiB0aGUgR05VIEdlbmVyYWwgUHVibGljIExpY2Vuc2UgdmVyc2lvbiAyIGFzCisgKiBwdWJsaXNoZWQgYnkgdGhlIEZyZWUgU29mdHdhcmUgRm91bmRhdGlvbi4KKyAqCisgKi8KKyAKKyNpbmNsdWRlIDxsaW51eC9tdGQvcGFydGl0aW9uX2d1YXJkLmg+CisKKworLyoKKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorKiB6ZnRsIHVzZWQgcGFydGl0aW9uIGZvciBwaG9uZQorKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisqLworLy9jb25zdCB1bnNpZ25lZCBjaGFyICp6ZnRsX3BhcnRpdGlvbl9uYW1lW10gPSB7eyJudmZhYyJ9LHsibnZybyJ9LHsibnZydyJ9LHsibnZyd28ifSx7ImZvdGFmbGFnIn0seyJzbXMifSx7MH19OworI2lmZGVmIENPTkZJR19aWDI5NzUyMFYzX01ETF9BQgorY29uc3QgdW5zaWduZWQgY2hhciAqcmVhZF9vbmx5X3BhcnRpdGlvbl9uYW1lW10gPSB7eyJ6bG9hZGVyIn0seyJ1Ym9vdCJ9LHsidWJvb3QyIn0seyJmbGFncyJ9LHswfX07CisjZWxzZQorY29uc3QgdW5zaWduZWQgY2hhciAqcmVhZF9vbmx5X3BhcnRpdGlvbl9uYW1lW10g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gb29iLT5lY2MyLCBTTV9TTUFMTF9QQUdFKSA8IDApCisJCXJldHVybiAtRUlPOworCXJldHVybiAwOworfQorCisvKiBSZWFkcyBhIHNlY3RvciArIG9vYiovCitzdGF0aWMgaW50IHNtX3JlYWRfc2VjdG9yKHN0cnVjdCBzbV9mdGwgKmZ0bCwKKwkJCSAgaW50IHpvbmUsIGludCBibG9jaywgaW50IGJvZmZzZXQsCisJCQkgIHVpbnQ4X3QgKmJ1ZmZlciwgc3RydWN0IHNtX29vYiAqb29iKQoreworCXN0cnVjdCBtdGRfaW5mbyAqbXRkID0gZnRsLT50cmFucy0+bXRkOworCXN0cnVjdCBtdGRfb29iX29wcyBvcHM7CisJc3RydWN0IHNtX29vYiB0bXBfb29iOworCWludCByZXQgPSAtRUlPOworCWludCB0cnkgPSAwOworCisJLyogRlRMIGNhbiBjb250YWluIC0xIGVudHJpZXMgdGhhdCBhcmUgYnkgZGVmYXVsdCBmaWxsZWQgd2l0aCBiaXRzICovCisJaWYgKGJsb2NrID09IC0xKSB7CisJCW1lbXNldChidWZmZXIsIDB4RkYsIFNNX1NFQ1RPUl9TSVpFKTsKKwkJcmV0dXJuIDA7CisJfQorCisJLyogVXNlciBtaWdodCBub3QgbmVlZCB0aGUgb29iLCBidXQgd2UgZG8gZm9yIGRhdGEgdmVyaWZpY2F0aW9uICovCisJaWYgKCFvb2IpCisJCW9vYiA9ICZ0bXBfb29iOworCisJb3BzLm1vZGUgPSBmdGwtPnNtYWxscGFnZW5hbmQgPyBNVERfT1BTX1JBVyA6IE1URF9PUFNfUExBQ0VfT09COworCW9wcy5vb2JvZmZzID0gMDsKKwlvcHMub29ibGVuID0gU01fT09CX1NJWkU7CisJb3BzLm9vYmJ1ZiA9ICh2b2lkICopb29iOworCW9wcy5sZW4gPSBTTV9TRUNUT1JfU0laRTsKKwlvcHMuZGF0YnVmID0gYnVmZmVyOworCithZ2FpbjoKKwlpZiAodHJ5KyspIHsKKwkJLyogQXZvaWQgaW5maW5pdGUg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DAwMDAwLi43YjY3NjczCi0tLSAvZGV2L251bGwKKysrIGIvYXAvb3MvbGludXgvbGludXgtMy40LngvZHJpdmVycy9tdGQvc3BpLW5vci9NYWtlZmlsZQpAQCAtMCwwICsxLDQgQEAKK29iai0kKENPTkZJR19NVERfU1BJX05PUikJKz0gc3BpLW5vci5vCitvYmotJChDT05GSUdfU1BJX1pYSUNfTk9SKQkrPSBub3Jfc3BpZmMubworCisKZGlmZiAtLWdpdCBhL2FwL29zL2xpbnV4L2xpbnV4LTMuNC54L2RyaXZlcnMvbXRkL3NwaS1ub3Ivbm9yX3NwaWZjLmMgYi9hcC9vcy9saW51eC9saW51eC0zLjQueC9kcml2ZXJzL210ZC9zcGktbm9yL25vcl9zcGlmYy5jCm5ldyBmaWxlIG1vZGUgMTAwNzU1CmluZGV4IDAwMDAwMDAuLjg0Y2JlNzAKLS0tIC9kZXYvbnVsbAorKysgYi9hcC9vcy9saW51eC9saW51eC0zLjQueC9kcml2ZXJzL210ZC9zcGktbm9yL25vcl9zcGlmYy5jCkBAIC0wLDAgKzEsMTE0MCBAQAorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorIENvcHlyaWdodCAyMDE0IGJ5ICBaVEUgQ29ycG9yYXRpb24uCisqCisqIEZpbGVOYW1lOjogICAgc3BpZmMuYworKiBGaWxlIE1hcms6CisqIERlc2NyaXB0aW9uOgorKiBPdGhlcnM6CisqIFZlcnNpb246CisqIEF1dGhvcjoKKyogRGF0ZToKKworKiBIaXN0b3J5IDE6CisqICAgICBEYXRlOgorKiAgICAgVmVyc2lvbjoKKyogICAgIEF1dGhvcjoKKyogICAgIE1vZGlmaWNhdGlvbjoKKyogSGlzdG9yeSAyOgorKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKyNpbmNsdWRlIDxsaW51eC9pbnRlcnJ1cHQ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SSVRFX0RBVF9FTikpOworCisJLyog56m65ZGo5pyf5pWw44CB5Zyw5Z2A5a695bqmKDHvvIwy77yMM++8jDTlrZfoioIp44CB5Zyw5Z2AL+aVsOaNrue6v+W6puOAgeS8oOi+k+aooeW8jyAqLworICAgIHNwaWZjLT5TRkNfQ1RSTDIgPSAwOworICAgIHNwaWZjLT5TRkNfQ1RSTDIgPSAoKGNtZC0+ZHVteV9ieXRlX251bSA8PCBGQ19EVU1NWV9CWVRFX05VTSkgCisgICAgICAgICAgICAJCQl8IChjbWQtPmR1bXlfYml0X251bSA8PCBGQ19EVU1NWV9CSVRfTlVNKSAKKwkgICAgICAgICAgICAJCXwgKGNtZC0+YWRkcl9ieXRlX251bSA8PCBGQ19BRERSX0JZVEVfTlVNKQorCSAgICAgICAgICAgIAkJfCAoY21kLT5hZGRyX211bHRpX2xpbmVfZW4gPDwgRkNfQUREUl9NVUxUSV9MSU5FX0VOKQorCSAgICAgICAgICAgIAkJfCAoY21kLT5kYXRhX211bHRpX2xpbmVfZW4gPDwgRkNfREFUX01VTFRJX0xJTkVfRU4pCisJICAgICAgICAgICAgCQl8IChjbWQtPnRyYW5zX21vZCA8PCBGQ19UUkFOU19NT0QpKTsKKworCS8qIOaVsOaNrumVv+W6piAqLworICAgIGlmKGxlbikKKyAgICAgICAgc3BpZmMtPlNGQ19CWVRFX05VTSA9IGxlbiAtIDE7CisgICAgZWxzZQorICAgICAgICBzcGlmYy0+U0ZDX0JZVEVfTlVNID0gMDsgCisJCisJLyogYWRkciBjb2RlIHJlZ2lzdGVyICovCisJc3BpZmMtPlNGQ19BRERSID0gYWRkcjsgCisJCisJLyog5ZG95Luk56CBICovICAKKyAgICBzcGlmYy0+U0ZDX0lOUyA9IGNtZC0+Y21kOyAgICAgICAgICAKK30KKworaW50IHNwaWZjX3dhaXRfY21kX2VuZChzdHJ1Y3QgZnNsX3FzcGkgKnEpCit7CisgICAgdW5zaWduZWQgbG9uZyBjb21wX3JlcywgZmxhZ3MgPSA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xID0gcGxhdGZvcm1fZ2V0X2lycShwZGV2LCAwKTsKKwlpZihxLT5pcnEgPCAwKSAKKwl7CisJCWRldl9lcnIoJnBkZXYtPmRldiwgIm5vIGlycSBkZWZpbmVkXG4iKTsKKwkJcmV0dXJuIHEtPmlycTsKKwl9CisJCisJcS0+aW9iYXNlID0gKHZvaWQgX19pb21lbSAqKShzcGlfbm9yX3JlZy0+c3RhcnQpOworCWlmKCFxLT5pb2Jhc2UpCisJeworCQlkZXZfZXJyKCZwZGV2LT5kZXYsICJxLT5pb2Jhc2UgaXMgbnVsbCBlcnJvci5cbiIpOworCQlyZXR1cm4gLUVOT01FTTsKKwl9CQorCisJcmV0ID0gc3BpZmNfaW5pdF9kbWEocSk7CQorCisJcmV0dXJuIHJldDsKK30KKworLyogaW5pdGlhbGl6ZSBkcml2ZXIgZGF0YSBzdHJ1Y3R1cmVzICovCit2b2lkIHNwaWZjX2Rydl9pbml0KHN0cnVjdCBmc2xfcXNwaSAqcSkKK3sKKwlzZW1hX2luaXQoJnEtPmMsIDApOworCXJhd19zcGluX2xvY2tfaW5pdCgmcS0+aXJxX2xvY2spOworCisJLyogaW5pdGlhbGl6ZSBvdXIgaXJxX3N0YXR1cyB2YXJpYWJsZSB0byBpbmRpY2F0ZSBubyBpbnRlcnJ1cHRzICovCisJcS0+aXJxX3N0YXR1cyA9IDA7CisJcS0+aW50X2VuX2ZsYWcgPSAxOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgorICogRnVuY3Rpb246ICAgIHNwaWZjX2h3X2luaXQKKyAqIERlc2NyaXB0aW9uOgorICogUGFyYW1ldGVyczoKKyAqICAgSW5wdXQ6CisgKgorICogICBPdXRwdXQ6CisgKgorICogUmV0dXJuczoKKyAqCisgKgorICogT3RoZXJzOgorICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIHZvaWQgc3BpZmNfaHdfaW5pdCh2b2lkKQoreworICAgIGludCByZXQ7CisKKwkvKmNvbmZpZ3VyZSBncGlvMTIgdG8gc2ZjX2RhdGEzKi8KKwlyZXQgPSBncGlvX3JlcXVlc3QoOTgsICJzZmNfZGF0YTMiKTsKKwlpZiAocmV0KQorCXsJCisJCXByaW50aygiZ3BpbyBmYWlsIDFcbiIpOworCQl6RHJ2X0FTU0VSVCgwKTsKKwkJcmV0dXJuOworCX0KKwl6eDI5X2dwaW9fY29uZmlnKDk4LCAweDEpOworCQorCS8qY29uZmlndXJlIGdwaW8xMSB0byBzZmNfZGF0YTIqLworCXJldCA9IGdwaW9fcmVxdWVzdCg5NywgInNmY19kYXRhMiIpOworCWlmIChyZXQpCisJewkKKwkJcHJpbnRrKCJncGlvIGZhaWwgMlxuIik7CisJCXpEcnZfQVNTRVJUKDApOworCQlyZXR1cm47CisJfQorCXp4MjlfZ3Bpb19jb25maWcoOTcsIDB4MSk7CisJCisJLypjb25maWd1cmUgZ3BpbzEwIHRvIHNmY19kYXRhMiovCisJcmV0ID0gZ3Bpb19yZXF1ZXN0KDk2LCAic2ZjX2RhdGExIik7CisJaWYgKHJldCkKKwl7CQorCQlwcmludGsoImdwaW8gZmFpbCAzXG4iKTsKKwkJekRydl9BU1NFUlQoMCk7CisJCXJldHVybjsKKwl9CisJengyOV9ncGlvX2NvbmZpZyg5NiwgMHgxKTsKKwkKKwkvKmNvbmZpZ3VyZSBncGlvOSB0byBzZmNfZGF0YTAqLworCXJldCA9IGdwaW9fcmVxdWVzdCg5NSwgInNmY19kYXRhMCIpOworCWlmIChyZXQpCisJewkKKwkJcHJpbnRrKCJncGlvIGZhaWwgNFxuIik7CisJCXpEcnZfQVNTRVJUKDApOworCQlyZXR1cm47CisJfQorCXp4MjlfZ3Bpb19jb25maWcoOTUsIDB4MSk7CisKKy8qY29uZmlndXJlIGdwaW81IHRvIHNmY19jcy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xYworCXVpbnQzMl90CSBTRkNfSU5TOwkJCQkJLy8weDIwCisJdWludDMyX3QJIFNGQ19USU1JTkc7CQkJCS8vMHgyNAorCXVpbnQzMl90CSBTRkNfSU5UX0VOOwkJCQkvLzB4MjgKKyAgICB1aW50MzJfdCAgICAgU0ZDX0lOVF9SQVc7ICAgICAgICAgICAgICAgLy8weDJjCisgICAgdWludDMyX3QgICAgIFNGQ19JTlRfU1dfQ0xSOyAgICAgICAgICAgIC8vMHgzMAorICAgIHVpbnQzMl90ICAgICBTRkNfU1c7ICAgICAgICAgICAgICAgICAgICAvLzB4MzQKKyAgICB1aW50MzJfdCAgICAgU0ZDX0RBVEE7ICAgICAgICAgICAgICAgICAgLy8weDM4Cit9OworCisvKnNwaWZjIHN0YXJ0IDB4NCovCisjZGVmaW5lICAgICBGQ19TVEFSVCAgICAgICgxPDwwKQorI2RlZmluZSAgICAgRkNfQlVTWSAgICAgICAoMTw8MCkKKworLypzcGlmYyBlbmFibGUgMHg4Ki8KKyNkZWZpbmUgICAgIEZDX0VOX0JBQ0sgICAgICAgICAgKDEpCisjZGVmaW5lICAgICBGQ19FTiAgICAgICAgICAgICAgICgwKQorCisvKnNwaWZjIG1haW4gY3RyMCAweGMqLworI2RlZmluZSAgICAgRkNfU0NMS19QQVVTRV9DTFJfQUxMT1cgICAgICgxNykKKyNkZWZpbmUgICAgIEZDX1NDTEtfUEFVU0VfRU4gICAgICAgICAgICAoMTYpCisjZGVmaW5lICAgICBGQ19UWEZJRk9fQ0xSICAgICAgICAgICAgICAgKDE1KQorI2RlZmluZSAgICAgRkNfUlhGSUZPX0NMUiAgICAgICAgICAgICAgICgxNCkKKyNkZWZpbmUgICAgIEZDX1RYRklGT19USFJFUyAgICAgICAgICAgICAoMTApCisjZGVmaW5lICAgICBGQ19SWEZJRk9fVEhSRVMgICAgICAgICAgICAgKDYpCisjZGVmaW5lICAgICBGQ19UWF9ETUFfRU4gICAgICAgICAgICAgICAgKDUpCisjZGVmaW5lICAgICBGQ19SWF9ETUFfRU4gICAgICAgICAgICAgICAgKDQpCisjZGVmaW5lICAgICBGQ19XRE9HX0VOICAgICAgICAgICAgICAgICAgKDMpCisjZGVmaW5lICAgICBGQ19TUElfTU9ERSAgICAgICAgICAgICAgICAgKDEpCisjZGVmaW5lICAgICBGQ19XUl9QUk9URUNUICAgICAgICAgICAgICAgKDApCisKKy8qc3BpZmMgY3RybDEgMHgxMCAgaW4gdGhlIGNvbmRpdGlvbiA6IFNGQ19FTiA9IDEgU0ZDX0JVU1kgPSAwKi8KKyNkZWZpbmUgICAgIEZDX0FERFJfVFhfRU4gICAgICAgICAgICg0KQorI2RlZmluZSAgICAgRkNfRFVNTVlfVFhfRU4gICAgICAgICAgKDIpCisjZGVmaW5lICAgICBGQ19SRUFEX0RBVF9FTiAgICAgICAgICAoMSkKKyNkZWZpbmUgICAgIEZDX1dSSVRFX0RBVF9FTiAgICAgICAgICgwKQorCisvKnNwaWZjIGN0cmwyIDB4MTQqLworI2RlZmluZSAgICAgRkNfRFVNTVlfQllURV9OVU0gICAgICAgICAgICgxMikgIC8qIFsxMjoxNX0gKi8KKyNkZWZpbmUgICAgIEZDX0RVTU1ZX0JJVF9OVU0gICAgICAgICAgICAoOCkgICAvKiBbODoxMF0gKi8KKyNkZWZpbmUgICAgIEZDX0FERFJfQllURV9OVU0gICAgICAgICAgICAoNSkgICAvKiBbNTo2XSAqLyAKKyNkZWZpbmUgICAgIEZDX0FERFJfTVVMVElfTElORV9FTiAgICAgICAoNCkKKyNkZWZpbmUgICAgIEZDX0RBVF9NVUxUSV9MSU5FX0VOICAgICAgICAoMikKKyNkZWZpbmUgICAgIEZDX1RSQU5TX01PRCAgICAgICAgICAgICAgICAoMCkKKworI2RlZmluZSAgICAgRkNfQUREUl9CWVRFX05VTV84ICAgICAgICAgICAgICgwKSAKKyNkZWZpbmUgICAgIEZDX0FERFJfQllURV9OVU1fMTYgICAgICAgICAgICAoMSkgCisjZGVmaW5lICAgICBGQ19BRERSX0JZVEVfTlVNXzI0ICAgICAgICAgICAgKDIpICAKKyNkZWZpbmUgICAgIEZDX0FERFJfQllURV9OVU1fMzIgICAgICAgICAgICAoMykgIAorCisKKy8qc3BpZmMgdGltaW5nIDB4MjQqLworI2RlZmluZSAgICAgRkNfUkVBRF9ERUxBWSAgICAgICAgICAgKDE8PDE2KSAgIC8qIFsxNzoxNn0gKi8KKyNkZWZpbmUgICAgIEZDX1RfQ1NfU0VUVVAgICAgICAgICAgICgxPDwxMSkgICAvKiBbMTE6MTN9ICovCisjZGVmaW5lICAgICBGQ19UX0NTX0hPTEQgICAgICAgICAgICAoMTw8NikgICAgLyogWzg6Nn0gKi8KKyNkZWZpbmUgICAgIEZDX1RfQ1NfREVTRUwgICAgICAgICAgICgxPDwwKSAgICAvKiBbMDozfSAqLworCisKKy8qc3BpZmMgaW50IGVuYWJsZSAweDI4Ki8KKyNkZWZpbmUgICAgIEZDX0lOVF9FTl9UWF9CWURfVEhFUyAgICAgICAgICAgKDE8PDcpCisjZGVmaW5lICAgICBGQ19JTlRfRU5fUlhfQllEX1RIRVMgICAgICAgICAgICgxPDw2KQorI2RlZmluZSAgICAgRkNfSU5UX0VOX1RYX1VOREVSUlVOICAgICAgICAgICAoMTw8NSkKKyNkZWZpbmUgICAgIEZDX0lOVF9FTl9SWF9PVkVSUlVOICAgICAgICAgICAgKDE8PDQpCisjZGVmaW5lICAgICBGQ19JTlRfRU5fV0RPR19PVkVSUlVOICAgICAgICAgICgxPDwyKQorI2RlZmluZSAgICAgRkNfSU5UX0VOX0ZNVF9FUlIgICAgICAgICAgICAgICAoMTw8MSkKKyNkZWZpbmUgICAgIEZDX0lOVF9FTl9DTURfRU5EICAgICAgICAgICAgICAgKDE8PDApCisKKy8qc3BpZmMgcmF3IGludGVycnVwdCAweDJjKi8KKyNkZWZpbmUgICAgIEZDX0lOVF9SQVdfVFhfQllEX1RIRVMgICAgICAgICAgICgxPDw3KQorI2RlZmluZSAgICAgRkNfSU5UX1JBV19SWF9CWURfVEhFUyAgICAgICAgICAgKDE8PDYpCisjZGVmaW5lICAgICBGQ19JTlRfUkFXX1RYX1VOREVSUlVOICAgICAgICAgICAoMTw8NSkKKyNkZWZpbmUgICAgIEZDX0lOVF9SQVdfUlhfT1ZFUlJVTiAgICAgICAgICAgICgxPDw0KQorI2RlZmluZSAgICAgRkNfSU5UX1JBV19XRE9HX09WRVJSVU4gICAgICAgICAgKDE8PDIpCisjZGVmaW5lICAgICBGQ19JTlRfUkFXX0ZNVF9FUlIgICAgICAgICAgICAgICAoMTw8MSkKKyNkZWZpbmUgICAgIEZDX0lOVF9SQVdfQ01EX0VORCAgICAgICAgICAgICAgICgxPDwwKQorI2RlZmluZSAgICAgRkNfSU5UX1JBV19FUlJfTUFTSyAgICAgICAgICAgICAgKEZDX0lOVF9SQVdfVFhfVU5ERVJSVU58XAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZDX0lOVF9SQVdfUlhfT1ZFUlJVTnxcCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRkNfSU5UX1JBV19XRE9HX09WRVJSVU58XAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZDX0lOVF9SQVdfRk1UX0VSUikKKworLypzcGlmYyBpbnQgc3RhcnR1cyBhbmQgY2xyIDB4MzAqLworI2RlZmluZSAgICAgRkNfSU5UX0NMUl9UWF9CWURfVEhFUyAgICAgICAgICAgKDE8PDcpCisjZGVmaW5lICAgICBGQ19JTlRfQ0xSX1JYX0JZRF9USEVTICAgICAgICAgICAoMTw8NikKKyNkZWZpbmUgICAgIEZDX0lOVF9DTFJfVFhfVU5ERVJSVU4gICAgICAgICAgICgxPDw1KQorI2RlZmluZSAgICAgRkNfSU5UX0NMUl9SWF9PVkVSUlVOICAgICAgICAgICAgKDE8PDQpCisjZGVmaW5lICAgICBGQ19JTlRfQ0xSX1dET0dfT1ZFUlJVTiAgICAgICAgICAoMTw8MikKKyNkZWZpbmUgICAgIEZDX0lOVF9DTFJfRk1UX0VSUiAgICAgICAgICAgICAgICgxPDwxKQorI2RlZmluZSAgICAgRkNfSU5UX0NMUl9DTURfRU5EICAgICAgICAgICAgICAgKDE8PDApCisKKy8qc3BpZmMgc3cgMHgzNCovCisjZGVmaW5lICAgICBGQ19UWF9GSUZPX0NOVCAgICAgICAgICAgICAgKDE2KSAgICAgICAgIC8qIFsxNjoyMH0gKi8KKyNkZWZpbmUgICAgIEZDX1RYX0ZJRk9fQ05UX01BU0sgICAgICAgICAoMHgxRikgICAgICAvKiBbODoxMn0gKi8KKyNkZWZpbmUgICAgIEZDX1JYX0ZJRk9fQ05UICAgICAgICAgICAgICAoOCkgICAgICAgICAgICAgLyogWzg6MTJ9ICovCisjZGVmaW5lICAgICBGQ19SWF9GSUZPX0NOVF9NQVNLICAgICAgICAgKDB4MUYpICAgICAgLyogWzg6MTJ9ICovCisjZGVmaW5lICAgICBGQ19UWF9CWURfVEhSRVMgICAgICAgICAgICAgKDE8PDUpICAKKyNkZWZpbmUgICAgIEZDX1JYX0JZRF9USFJFUyAgICAgICAgICAgICAoMTw8NCkgIAorI2RlZmluZSAgICAgRkNfU0NMS19QQVVTRV9GTEFHICAgICAgICAgICgxPDwzKSAgCisjZGVmaW5lICAgICBGQ19XQUlUX0ZMQUcgICAgICAgICAgICAgICAgKDE8PDIpIAorI2RlZmluZSAgICAgRkNfRk9STUFUX0VSUiAgICAgICAgICAgICAgICgxPDwxKSAgCisKKworI2RlZmluZSAgICAgRkNfRE1BX05PTkUgICAgICAgICAgIAkJMAorI2RlZmluZSAgICAgRkNfRE1BX1RYICAgICAgICAgICAgIAkJMQorI2RlZmluZSAgICAgRkNfRE1BX1JYICAgICAgICAgICAgIAkJMgorCisjZGVmaW5lIAlTUElGQ19JUlFfQUxMCQkJCShGQ19JTlRfRU5fQ01EX0VORHxcCisJICAgICAgICAgICAgICAgICAgICAgCQkJCUZDX0lOVF9FTl9GTVRfRVJSfFwKKwkgICAgICAgICAgICAgICAgICAgICAJCQkJRkNfSU5UX0VOX1JYX09WRVJSVU58XAorCSAgICAgICAgICAgICAgICAgICAgIAkJCQlGQ19JTlRfRU5fVFhfVU5ERVJSVU58XAorCSAgICAgICAgICAgICAgICAgICAgIAkJCQlGQ19JTlRfRU5fRk1UX0VSUikKKworCisKKyNkZWZpbmUgVFhfRE1BX0VOCQkxIAorI2RlZmluZSBUWF9ETUFfRElTICAgICAgMCAKKyNkZWZpbmUgUlhfRE1BX0VOCQkxIAorI2RlZmluZSBSWF9ETUFfRElTICAgICAgMAorI2RlZmluZSBBRERSX1RYX0VOICAgICAgMSAgIAorI2RlZmluZSBBRERSX1RYX0RJUyAgICAgMAorI2RlZmluZSBEQVRBX1RYX0VOICAgICAgMQorI2RlZmluZSBEQVRBX1RYX0RJUyAgICAgMAorI2RlZmluZSBEQVRBX1JYX0VOICAgICAgMQorI2RlZmluZSBEQVRBX1JYX0RJUyAgICAgMAorI2RlZmluZSBEVU1ZX1RYX0VOICAgICAgMQorI2RlZmluZSBEVU1ZX1RYX0RJUyAgICAgMAorI2RlZmluZSBBRERSX01VTFRJX0xJTkVfRU4JCTEgCisjZGVmaW5lIEFERFJfTVVMVElfTElORV9ESVMgICAgICAwCisjZGVmaW5lIERBVEFfTVVMVElfTElORV9FTgkJMSAKKyNkZWZpbmUgREFUQV9NVUxUSV9MSU5FX0RJUyAgICAgIDAKKyNkZWZpbmUgVFJBTlNfTU9EX1FVQUQJCTEgCisjZGVmaW5lIFRSQU5TX01PRF9EVUFMICAgICAgMAorI2RlZmluZSBUUkFOU19NT0RfU0lOR0xFCTIKKworCisjZGVmaW5lIEFERFJfV0lEVEhfOCAgICAwCisjZGVmaW5lIEFERFJfV0lEVEhfMTYgICAxCisjZGVmaW5lIEFERFJfV0lEVEhfMjQgICAyCisjZGVmaW5lIEFERFJfV0lEVEhfMzIgICAzCisKKworCit0eXBlZGVmIHN0cnVjdCBzcGlub3JfY21kCit7CisgICAgdTggY21kOworCXU4IHR4X2RtYV9lbjsKKwl1OCByeF9kbWFfZW47CisgICAgdTggYWRkcl90eF9lbjsKKyAgICB1OCBhZGRyX2J5dGVfbnVtOworICAgIHU4IGRhdGFfdHhfZW47CisgICAgdTggZGF0YV9yeF9lbjsKKyAgICB1OCBkdW15X3R4X2VuOworICAgIHU4IGR1bXlfYnl0ZV9udW07CisJdTggZHVteV9iaXRfbnVtOworCXU4IGFkZHJfbXVsdGlfbGluZV9lbjsKKwl1OCBkYXRhX211bHRpX2xpbmVfZW47CisJdTggdHJhbnNfbW9kOworCXU4IHJlc2VydmVkWzNdOworICAgIHU4ICppbmZvOworfXNwaW5vcl9jbWRfdDsKKworCisjZGVmaW5lIENNRF9XUkVOICAgICAgICAgICAgICAgICAgICAgICAgMHgwNgorI2RlZmluZSBDTURfV1JESSAgICAgICAgICAgICAgICAgICAgICAgIDB4MDQKKyNkZWZpbmUgQ01EX1dSRU5WU1IgICAgICAgICAgICAgICAgICAgICAweDUwCisjZGVmaW5lIENNRF9SRFNSMCAgICAgICAgICAgICAgICAgICAgICAgMHgwNQorI2RlZmluZSBDTURfUkRTUjEgICAgICAgICAgICAgICAgICAgICAgIDB4MzUKKyNkZWZpbmUgQ01EX1dSU1IgICAgICAgICAgICAgICAgICAgICAgICAweDAxCisjZGVmaW5lIENNRF9SREIJCQkgICAgICAgICAgICAJMHgwMworI2RlZmluZSBDTURfUkRGVCAgICAgICAgICAgICAgICAgICAJCTB4MEIKKyNkZWZpbmUgQ01EX1JEREZUICAgICAgICAgICAgICAgICAgICAgICAweDNCCisjZGVmaW5lIENNRF9SRFFGVCAgICAgICAgICAgICAgICAgICAgICAgMHg2QgorI2RlZmluZSBDTURfUFAgICAgICAgICAgICAgICAgICAgICAgICAgIDB4MDIgCisjZGVmaW5lIENNRF9RUFAgICAgICAgICAgICAgICAgICAgICAgICAgMHgzMgorI2RlZmluZSBDTURfU0UgICAgICAgICAgICAgICAgICAgICAgICAgIDB4MjAKKyNkZWZpbmUgQ01EXzMyS0JFICAgICAgICAgICAgICAgICAgICAgICAweDUyCisjZGVmaW5lIENNRF82NEtCRSAgICAgICAgICAgICAgICAgICAgICAgMHhEOAorI2RlZmluZSBDTURfQ0UgICAgICAgICAgICAgICAgICAgICAgICAgIDB4NjAKKyNkZWZpbmUgQ01EX0RQICAgICAgICAgICAgICAgICAgICAgICAgICAweEI5CisjZGVmaW5lIENNRF9SRFBSREkgICAgICAgICAgICAgICAgICAgICAgMHhBQgorI2RlZmluZSBDTURfUkVNUyAgICAgICAgICAgICAgICAgICAgIAkweDkwCisjZGVmaW5lIENNRF9SRElEICAgICAgICAgICAgICAgICAgICAJMHg5RgorI2RlZmluZSBDTURfUEVTICAgICAgICAgICAgICAgICAgICAJCTB4NzUKKyNkZWZpbmUgQ01EX1BFUiAgICAgICAgICAgICAgICAgICAgCQkweDdBCisjZGVmaW5lIENNRF9FU1IgICAgICAgICAgICAgICAgICAgIAkJMHg0NAorI2RlZmluZSBDTURfUFNSICAgICAgICAgICAgICAgICAgICAJCTB4NDIKKyNkZWZpbmUgQ01EX1JTUiAgICAgICAgICAgICAgICAgICAgCQkweDQ4CisjZGVmaW5lIENNRF9FTlJFU0VUICAgICAgICAgICAgICAgICAgICAJMHg2NgorI2RlZmluZSBDTURfUkVTRVQgICAgICAgICAgICAgICAgICAgIAkweDk5CisKKworZW51bSBmc2xfcXNwaV9kZXZ0eXBlIHsKKwlGU0xfUVVBRFNQSV9WWUJSSUQsCisJRlNMX1FVQURTUElfSU1YNlNYLAorCUZTTF9RVUFEU1BJX0lNWDdELAorCUZTTF9RVUFEU1BJX0lNWDZVTCwKK307CisKK3N0cnVjdCBmc2xfcXNwaV9kZXZ0eXBlX2RhdGEgeworCWVudW0gZnNsX3FzcGlfZGV2dHlwZSBkZXZ0eXBlOworCWludCByeGZpZm87CisJaW50IHR4ZmlmbzsKKwlpbnQgYWhiX2J1Zl9zaXplOworCWludCBkcml2ZXJfZGF0YTsKK307CisKKyNkZWZpbmU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QoreworCWludCBzdGF0dXM7CisKKwlzdGF0dXMgPSByZWFkX3NyKG5vcik7CisJaWYgKHN0YXR1cyA8IDApCisJCXJldHVybiBzdGF0dXM7CisKKwlyZXR1cm4gc3RtX2lzX2xvY2tlZF9zcihub3IsIG9mcywgbGVuLCBzdGF0dXMpOworfQorCitzdGF0aWMgaW50IHNwaV9ub3JfbG9jayhzdHJ1Y3QgbXRkX2luZm8gKm10ZCwgbG9mZl90IG9mcywgdWludDY0X3QgbGVuKQoreworCXN0cnVjdCBzcGlfbm9yICpub3IgPSBtdGRfdG9fc3BpX25vcihtdGQpOworCWludCByZXQ7CisKKwlyZXQgPSBzcGlfbm9yX2xvY2tfYW5kX3ByZXAobm9yLCBTUElfTk9SX09QU19MT0NLKTsKKwlpZiAocmV0KQorCQlyZXR1cm4gcmV0OworCisJcmV0ID0gbm9yLT5mbGFzaF9sb2NrKG5vciwgb2ZzLCBsZW4pOworCisJc3BpX25vcl91bmxvY2tfYW5kX3VucHJlcChub3IsIFNQSV9OT1JfT1BTX1VOTE9DSyk7CisJcmV0dXJuIHJldDsKK30KKworc3RhdGljIGludCBzcGlfbm9yX3VubG9jayhzdHJ1Y3QgbXRkX2luZm8gKm10ZCwgbG9mZl90IG9mcywgdWludDY0X3QgbGVuKQoreworCXN0cnVjdCBzcGlfbm9yICpub3IgPSBtdGRfdG9fc3BpX25vcihtdGQpOworCWludCByZXQ7CisKKwlyZXQgPSBzcGlfbm9yX2xvY2tfYW5kX3ByZXAobm9yLCBTUElfTk9SX09QU19VTkxPQ0spOworCWlmIChyZXQpCisJCXJldHVybiByZXQ7CisKKwlyZXQgPSBub3ItPmZsYXNoX3VubG9jayhub3IsIG9mcywgbGVuKTsKKworCXNwaV9ub3JfdW5sb2NrX2FuZF91bnByZXAobm9yLCBTUElfTk9SX09QU19MT0NLKTsKKwlyZXR1cm4gcmV0OworfQorCitzdGF0aWMgaW50IHNwaV9ub3JfaXNfbG9ja2VkKHN0cnVjdCBtdGRfaW5mby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U5UX1BSRUYgInNjYW5uZWQgJWQgZXJhc2VibG9ja3MsICVkIGFyZSBiYWRcbiIsIGksIGJhZCk7CitvdXQ6CisJZ29vZGViY250ID0gZWJjbnQgLSBiYWQ7CisJcmV0dXJuIDA7Cit9CisKKy8qKioKKyAqKioJMS4gcmVhZAorICoqKgkyLiBjaGFuZ2UgYW5kIHdyaXRlCisgKioqCTMuIHJlYWQgYW5kIGNvbXBhcmUKKyAqKioKKyAqLworc3RhdGljIGludCBfX2luaXQgbXRkX2JidHRlc3RfaW5pdCh2b2lkKQoreworCWludCBlcnIgPSAwOworCWludCBpOworCWludCBibG9ja19jbnQsIGJsb2NrOworCWludCBlY2NfY2FwOworCXVpbnQ2NF90IHRtcDsJCisJaW50IGJhZDsKKwlpbnQgbWFya2VkX2Jsb2NrID0gMDsKKwkKKwlwcl9pbmZvKCJcbiIpOworCXByX2luZm8oIj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT1cbiIpOworCisJcHJpbnRrKFBSSU5UX1BSRUYgIk1URCBkZXZpY2U6ICVkXG4iLCBkZXYpOyAKKworCW10ZCA9IGdldF9tdGRfZGV2aWNlKE5VTEwsIGRldik7CisJaWYgKElTX0VSUihtdGQpKSB7CisJCWVyciA9IFBUUl9FUlIobXRkKTsKKwkJcHJpbnRrKFBSSU5UX1BSRUYgImVycm9yOiBDYW5ub3QgZ2V0IE1URCBkZXZpY2VcbiIpOworCQlyZXR1cm4gZXJyOworCX0KKworCWlmIChtdGQtPndyaXRlc2l6ZSA9PSAxKSB7CisJCXByaW50ayhQUklOVF9QUkVGICJub3QgTkFORCBmbGFzaCwgYXNzdW1lIHBhZ2Ugc2l6ZSBpcyA1MTIgIgorCQkJICAgImJ5dGVzLlxuIik7CisJfSAKKworCXRtcCA9IG10ZC0+c2l6ZTsKKwlkb19kaXYodG1wLCBtdGQtPmVyYXNlc2l6ZSk7CisJZWJjbnQgPSB0bXA7CisKKwllcnIgPSAtRU5PTUVN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isJCQlicmVhazsJCQkKKwkJfQorCX0JCisKKwkvKiBkdW1wIGJhZCBibG9jayAqLworCWJhZCA9IDA7CisJcHJfaW5mbygiXG4iKTsJCisJcHJpbnRrKFBSSU5UX1BSRUYgInNjYW4gYmFkIGJsb2NrIGFnYWluLi4uXG4iLCBpKTsKKwlmb3IgKGkgPSAwOyBpIDwgZWJjbnQ7IGkrKykgCisJeworCQlpZihpc19ibG9ja19iYWQoaSkpCisJCXsKKwkJCWJhZCArPSAxOworCQkJcHJpbnRrKCJibG9jayglZCkJICIsIGkpOworCQkJaWYoKGJhZCU0KT09MCkKKwkJCQlwcl9pbmZvKCJcbiIpOworCQl9CisJfQorCXByaW50ayhQUklOVF9QUkVGICJGaW5kIHRvdGFsICVkIGJhZCBibG9ja3MuXG4iLCBiYWQpOworCQkKKwlpZiAoZXJyKQorCQlwcmludGsoUFJJTlRfUFJFRiAiZmluaXNoZWQgd2l0aCBlcnJvcnNcbiIpOworCWVsc2UKKwkJcHJpbnRrKFBSSU5UX1BSRUYgImZpbmlzaGVkXG4iKTsKKworb3V0OgorCWtmcmVlKGlvYnVmKTsKKwlrZnJlZShpb2J1ZjEpOworCWtmcmVlKGJidCk7CisJcHV0X210ZF9kZXZpY2UobXRkKTsKKwlpZiAoZXJyKQorCQlwcmludGsoUFJJTlRfUFJFRiAiZXJyb3IgJWQgb2NjdXJyZWRcbiIsIGVycik7CisJcHJpbnRrKEtFUk5fSU5GTyAiPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PVxuIik7CisJcmV0dXJuIGVycjsKKworfQorCisKK21vZHVsZV9pbml0KG10ZF9iYnR0ZXN0X2luaXQpOworCitzdGF0aWMgdm9pZCBfX2V4aXQgbXRkX2JidHRlc3RfZXhpdCh2b2lkKQoreworCXJldHVybjsKK30KK21vZHVsZV9leGl0KG10ZF9iYnR0ZXN0X2V4aXQpOworCitNT0RVTEVfREVTQ1JJUFRJT04oIk5hbmQgYmJ0IHRlc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HIsICZvcHMpOworCWVyciA9IG10ZC0+X3dyaXRlX29vYihtdGQsIChsb2ZmX3QpYWRkciwgJm9wcyk7CQorCisJcmV0dXJuIGVycjsKK30KKworLyogcmVhZCB0aGUgZmlyc3QgcGFnZSBvZiB0aGUgYmxvY2sgKi8KK3N0YXRpYyBpbnQgcmVhZF9wYWdlKGxvZmZfdCBhZGRyLCB1bnNpZ25lZCBjaGFyICpidWYsIGludCBlbmFibGVfZWNjKQoreworCWludCBlcnIgPSAwOworCXN0cnVjdCBtdGRfb29iX29wcyBvcHM7CisKKwlpZihlbmFibGVfZWNjKQorCQlvcHMubW9kZQkgID0gTVREX09QU19QTEFDRV9PT0I7CisJZWxzZQorCQlvcHMubW9kZQkgID0gTVREX09QU19SQVc7CisJb3BzLmxlbiAJICA9IG10ZC0+d3JpdGVzaXplOworCW9wcy5yZXRsZW4JICA9IDA7CisJb3BzLm9vYmxlbgkgID0gbXRkLT5vb2JzaXplOworCW9wcy5vb2JyZXRsZW4gPSAwOworCW9wcy5vb2JvZmZzICAgPSAwOworCW9wcy5kYXRidWYJICA9IGJ1ZjsKKwlvcHMub29iYnVmCSAgPSBidWYgKyBtdGQtPndyaXRlc2l6ZTsKKwllcnIgPSBtdGRfcmVhZF9vb2IobXRkLCBhZGRyLCAmb3BzKTsKKworCXJldHVybiBlcnI7Cit9CisKKworCitzdGF0aWMgaW50IGVyYXNlX2VyYXNlYmxvY2soaW50IGVibnVtKQoreworCWludCBlcnI7CisJc3RydWN0IGVyYXNlX2luZm8gZWk7CisJbG9mZl90IGFkZHIgPSBlYm51bSAqIG10ZC0+ZXJhc2VzaXplOworCisJbWVtc2V0KCZlaSwgMCwgc2l6ZW9mKHN0cnVjdCBlcmFzZV9pbmZvKSk7CisJZWkubXRkICA9IG10ZDsKKwllaS5hZGRyID0gYWRkcjsKKwllaS5sZW4gID0gbXRkLT5lcmFzZXNpemU7CisKKwllcnIgPSBtdGRfZXJhc2UobXRkLCAmZWkpOworCWlmIChlcnIpIHsKKwkJcHJpbnRrKFBSSU5UX1BSRUYgImVycm9yICVkIHdoaWxlIGVyYXNpbmcgRUIgJWRcbiIsIGVyciwgZWJudW0pOworCQlyZXR1cm4gZXJyOworCX0KKworCWlmIChlaS5zdGF0ZSA9PSBNVERfRVJBU0VfRkFJTEVEKSB7CisJCXByaW50ayhQUklOVF9QUkVGICJzb21lIGVyYXNlIGVycm9yIG9jY3VycmVkIGF0IEVCICVkXG4iLAorCQkgICAgICAgZWJudW0pOworCQlyZXR1cm4gLUVJTzsKKwl9CisKKwlyZXR1cm4gMDsKK30KKworCisKK3N0YXRpYyBpbnQgcHJlcGFyZV9lY2NfYmxvY2soc3RydWN0IG10ZF9pbmZvICptdGQpCit7CisJaW50IGk7CisJaW50IGVycjsKKworCWZvciAoaSA9IDA7IGkgPCBlYmNudDsgKytpKSB7CisJCWlmIChiYnRbaV0pCisJCQljb250aW51ZTsKKwkJZXJyID0gZXJhc2VfZXJhc2VibG9jayhpKTsKKwkJaWYgKGVycikKKwkJCXJldHVybiBlcnI7CisKKy8vCQlzZXRfcmFuZG9tX2RhdGEoaW9idWYsIG10ZC0+d3JpdGVzaXplKTsKKwkJbWVtc2V0KGlvYnVmLCAweDVBLCBtdGQtPndyaXRlc2l6ZSk7CisJCW1lbXNldChpb2J1ZittdGQtPndyaXRlc2l6ZSwgMHhmZiwgbXRkLT5vb2JzaXplKTsKKwkJY29uZF9yZXNjaGVkKCk7CisKKwkJZXJyID0gd3JpdGVfcGFnZShpKm10ZC0+ZXJhc2VzaXplLCBpb2J1ZiwgdHJ1ZSk7CisJCWlmIChlcnIpCisJCQlyZXR1cm4gZXJyOworCisJCXJldHVybiBpOworCX0KKworCXJldHVybiAtMTsKK30KKworc3RhdGljIGludCBtYWtlX2VjY19lcnIodW5zaWduZWQgY2hhciAqYnVmLCB1bnNpZ25lZCBpbnQgYnVmX2xlbiwgaW50IGVjY19jbnQpCit7CisJaW50IGksIGo7CisJaW50IGNvdW50ID0gMDsKKwlpbnQgcmV0ID0gLTE7CisJdW5zaWduZWQgaW50ICpkYXRhID0gKHVuc2lnbmVkIGludCAqKWJ1ZjsKKworCWZvcihpPTA7IGk8YnVmX2xlbi80OyBpKyspCisJeworCQlpZihjb3VudCA9PSBlY2NfY250KQorCQkJcmV0dXJuIDA7CQorCQkKKwkJaWYoKihkYXRhK2kpKQorCQl7CisJCQkqKGRhdGEraSkgJj0gfigxPDwoZmZzKCooZGF0YStpKSktMSkpOworCQkJY291bnQgKys7CisJCX0KKwkJZWxzZQorCQkJY29udGludWU7CisJfQorCisJcmV0dXJuIHJldDsKK30KKworCisvKioqCisgKioqCTEuIGR1bXAgZWNjIGluZm86ICBlY2MgY2FwYWNpdHkoMS80LzguLi4gYml0KSAgaGFuZGxlcihody9zdykKKyAqKioJMi4gbWFrZSBlY2MgYW5kIGNoZWNrCisgKioqCisgKi8KK3N0YXRpYyBpbnQgX19pbml0IG10ZF9lY2N0ZXN0X2luaXQodm9pZCkKK3sKKwlpbnQgZXJyID0gMDsKKwlpbnQgaTsKKwlpbnQgYmxvY2tfY250LCBibG9jazsKKwlpbnQgZWNjX2NhcDsKKwl1aW50NjRfdCB0bXA7CQorCQorCXByX2luZm8oIlxuIik7CisJcHJfaW5mbygiPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PVxuIik7CisKKwlwcmludGsoUFJJTlRfUFJFRiAiTVREIGRldmljZTogJWRcbiIsIGRldik7IAorCisJbXRkID0gZ2V0X210ZF9kZXZpY2UoTlVMTCwgZGV2KTsKKwlpZiAoSVNfRVJSKG10ZCkpIHsKKwkJZXJyID0gUFRSX0VSUihtdGQpOworCQlwcmludGsoUFJJTlRfUFJFRiAiZXJyb3I6IENhbm5vdCBnZXQgTVREIGRldmljZVxuIik7CisJCXJldHVybiBlcnI7CisJfQorCisJaWYgKG10ZC0+d3JpdGVzaXplID09IDEpIHsKKwkJcHJpbnRrKFBSSU5UX1BSRUYgIm5vdCBOQU5EIGZsYXNoLC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l0bXAgPSBtdGQtPnNpemU7CisJCWRvX2Rpdih0bXAsIG10ZC0+ZXJhc2VzaXplKTsKKwkJYmxvY2tfY250ID0gdG1wOworCisJCXRvdGFsX2Jsa3MgKz0gYmxvY2tfY250OworCisJCWZvciAoaiA9IDA7IGogPCBibG9ja19jbnQ7IGorKykgCisJCXsKKwkJCWlmKGlzX2Jsb2NrX2JhZChqKSkKKwkJCXsKKwkJCQliYWQgKz0gMTsKKwkJCQlwcmludGsoImJsb2NrKCVkKQkgIiwgaik7CisJCQkJaWYoKGJhZCU0KT09MCkKKwkJCQkJcHJfaW5mbygiXG4iKTsKKwkJCX0KKwkJfQorCQkKKwkJcHV0X210ZF9kZXZpY2UobXRkKTsKKwl9CisjZWxzZQorCWZvciAoaSA9IDA7IGkgPCBibG9ja19jbnQ7IGkrKykgCisJeworCQlpZihpc19ibG9ja19iYWQoaSkpCisJCXsKKwkJCWJhZCArPSAxOworCQkJcHJpbnRrKCJibG9jayglZCkJICIsIGkpOworCQkJaWYoKGJhZCU0KT09MCkKKwkJCQlwcl9pbmZvKCJcbiIpOworCQl9CisJfQkKKyNlbmRpZgkKKwlwcl9pbmZvKCJcblRvdGFsICVkIGJhZCBibG9ja3MgZm91bmQgaW4gJWQgYmxvY2tzLlxuIiwgYmFkLCB0b3RhbF9ibGtzKTsKKworCitvdXQ6CisJa2ZyZWUoaW9idWYpOworCWlmIChlcnIpCisJCXByaW50ayhQUklOVF9QUkVGICJlcnJvciAlZCBvY2N1cnJlZFxuIiwgZXJyKTsKKwlwcmludGsoS0VSTl9JTkZPICI9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4iKTsKKwlyZXR1cm4gZXJyOworfQorCisKK21vZHVsZV9pbml0KG10ZF9nZXRpbmZvdGVzdF9pbml0KTsKKworc3RhdGljIHZvaWQgX19leGl0IG10ZF9nZXRpbmZvdGVzdF9leGl0KHZvaWQpCit7CisJcmV0dXJuOworfQorbW9kdWxlX2V4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0gbmV4dCAqIDExMDM1MTUyNDUgKyAxMjM0NTsKKwlyZXR1cm4gKHVuc2lnbmVkIGludCkoKG5leHQgLyA2NTUzNikgJSAzMjc2OCk7Cit9CisKK3N0YXRpYyBpbmxpbmUgdm9pZCBzaW1wbGVfc3JhbmQodW5zaWduZWQgbG9uZyBzZWVkKQoreworCW5leHQgPSBzZWVkOworfQorCitzdGF0aWMgdm9pZCBzZXRfcmFuZG9tX2RhdGEodW5zaWduZWQgY2hhciAqYnVmLCBzaXplX3QgbGVuKQoreworCXNpemVfdCBpOworCisJZm9yIChpID0gMDsgaSA8IGxlbjsgKytpKQorCQlidWZbaV0gPSBzaW1wbGVfcmFuZCgpOworfQorCitzdGF0aWMgaW50IGVyYXNlX2VyYXNlYmxvY2soaW50IGVibnVtKQoreworCWludCBlcnI7CisJc3RydWN0IGVyYXNlX2luZm8gZWk7CisJbG9mZl90IGFkZHIgPSBlYm51bSAqIG10ZC0+ZXJhc2VzaXplOworCisJbWVtc2V0KCZlaSwgMCwgc2l6ZW9mKHN0cnVjdCBlcmFzZV9pbmZvKSk7CisJZWkubXRkICA9IG10ZDsKKwllaS5hZGRyID0gYWRkcjsKKwllaS5sZW4gID0gbXRkLT5lcmFzZXNpemU7CisKKwllcnIgPSBtdGRfZXJhc2UobXRkLCAmZWkpOworCWlmIChlcnIpIHsKKwkJcHJpbnRrKFBSSU5UX1BSRUYgImVycm9yICVkIHdoaWxlIGVyYXNpbmcgRUIgJWRcbiIsIGVyciwgZWJudW0pOworCQlyZXR1cm4gZXJyOworCX0KKworCWlmIChlaS5zdGF0ZSA9PSBNVERfRVJBU0VfRkFJTEVEKSB7CisJCXByaW50ayhQUklOVF9QUkVGICJzb21lIGVyYXNlIGVycm9yIG9jY3VycmVkIGF0IEVCICVkXG4iLAorCQkgICAgICAgZWJudW0pOworCQlyZXR1cm4gLUVJTzsKKwl9CisKKwlyZXR1cm4gMDsKK30KKworc3RhdGljIGludCB3cml0ZV9lcmFzZWJsb2NrKGlud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xsb2MobXRkLT5lcmFzZXNpemUsIEdGUF9LRVJORUwpOworCWlmICghaW9idWYpIHsKKwkJcHJpbnRrKFBSSU5UX1BSRUYgImVycm9yOiBjYW5ub3QgYWxsb2NhdGUgbWVtb3J5XG4iKTsKKwkJZ290byBvdXQ7CisJfQorCWlvYnVmMSA9IGttYWxsb2MobXRkLT5lcmFzZXNpemUsIEdGUF9LRVJORUwpOworCWlmICghaW9idWYxKSB7CisJCXByaW50ayhQUklOVF9QUkVGICJlcnJvcjogY2Fubm90IGFsbG9jYXRlIG1lbW9yeVxuIik7CisJCWdvdG8gb3V0OworCX0KKworCWVyciA9IHNjYW5fZm9yX2JhZF9lcmFzZWJsb2NrcygpOworCWlmIChlcnIpCisJCWdvdG8gb3V0OworCisJLyogUmVhZCBhbGwgZXJhc2VibG9ja3MgMSBwYWdlIGF0IGEgdGltZSAqLworCXByaW50ayhQUklOVF9QUkVGICJ0ZXN0aW5nIHBhZ2UgcmVhZFxuIik7CisJZm9yIChpID0gMDsgaSA8IGViY250OyArK2kpIHsKKwkJaW50IHJldDsKKworCQlpZiAoYmJ0W2ldKQorCQkJY29udGludWU7CisJCXJldCA9IHJlYWRfZXJhc2VibG9ja19ieV9wYWdlKGkpOworCQlpZiAocmV0KSB7CisJCQlkdW1wX2VyYXNlYmxvY2soaSk7CisJCQlpZiAoIWVycikKKwkJCQllcnIgPSByZXQ7CisJCX0KKwkJY29uZF9yZXNjaGVkKCk7CisJfQorCisJaWYgKGVycikKKwkJcHJpbnRrKFBSSU5UX1BSRUYgImZpbmlzaGVkIHdpdGggZXJyb3JzXG4iKTsKKwllbHNlCisJCXByaW50ayhQUklOVF9QUkVGICJmaW5pc2hlZFxuIik7CisKK291dDoKKworCWtmcmVlKGlvYnVmKTsKKwlrZnJlZShpb2J1ZjEpOworCWtmcmVlKGJidCk7CisJcHV0X210ZF9kZXZpY2UobXRkKTsKKwlpZiAoZXJyKQorCQlwcmludGsoUFJJTlRfUFJFRiAiZXJyb3IgJWQ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it9CisKK3N0YXRpYyBpbnQgX19pbml0IG10ZF9zcGVlZHRlc3RfaW5pdCh2b2lkKQoreworCWludCBlcnIsIGksIGJsb2NrcywgaiwgazsKKwlsb25nIHNwZWVkOworCXVpbnQ2NF90IHRtcDsKKworCXByaW50ayhLRVJOX0lORk8gIlxuIik7CisJcHJpbnRrKEtFUk5fSU5GTyAiPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PVxuIik7CisKKwlpZiAoZGV2IDwgMCkgeworCQlwcmludGsoUFJJTlRfUFJFRiAiUGxlYXNlIHNwZWNpZnkgYSB2YWxpZCBtdGQtZGV2aWNlIHZpYSBtb2R1bGUgcGFyYW10ZXJcbiIpOworCQlwcmludGsoS0VSTl9DUklUICJDQVJFRlVMOiBUaGlzIHRlc3Qgd2lwZXMgYWxsIGRhdGEgb24gdGhlIHNwZWNpZmllZCBNVEQgZGV2aWNlIVxuIik7CisJCXJldHVybiAtRUlOVkFMOworCX0KKworCWlmIChjb3VudCkKKwkJcHJpbnRrKFBSSU5UX1BSRUYgIk1URCBkZXZpY2U6ICVkICAgIGNvdW50OiAlZFxuIiwgZGV2LCBjb3VudCk7CisJZWxzZQorCQlwcmludGsoUFJJTlRfUFJFRiAiTVREIGRldmljZTogJWRcbiIsIGRldik7CisKKwltdGQgPSBnZXRfbXRkX2RldmljZShOVUxMLCBkZXYpOworCWlmIChJU19FUlIobXRkKSkgeworCQllcnIgPSBQVFJfRVJSKG10ZCk7CisJCXByaW50ayhQUklOVF9QUkVGICJlcnJvcjogY2Fubm90IGdldCBNVEQgZGV2aWNlXG4iKTsKKwkJcmV0dXJuIGVycjsKKwl9CisKKwlpZiAobXRkLT53cml0ZXNpemUgPT0gMSkgeworCQlwcmludGsoUFJJTlRfUFJFRiAibm90IE5BTkQgZmxhc2gsIGFzc3VtZSBwYWdlIHNpemUgaXMgNTEyICIKKwkJICAgICAgICJieXRlcy5cbiIpOworCQlwZ3NpemUgPSA1MTI7CisJf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JaW50IGVyciA9IDAsIGs7CisJbG9mZl90IGFkZHIgPSBlYm51bSAqIG10ZC0+ZXJhc2VzaXplOworCisJZm9yIChrID0gMTsgayA8IDMzOyArK2spIHsKKwkJaWYgKGFkZHIgKyAoc3VicGdzaXplICogaykgPiAoZWJudW0gKyAxKSAqIG10ZC0+ZXJhc2VzaXplKQorCQkJYnJlYWs7CisJCXNldF9yYW5kb21fZGF0YSh3cml0ZWJ1Ziwgc3VicGdzaXplICogayk7CisJCWNsZWFyX2RhdGEocmVhZGJ1Ziwgc3VicGdzaXplICogayk7CisJCWVyciA9IG10ZF9yZWFkKG10ZCwgYWRkciwgc3VicGdzaXplICogaywgJnJlYWQsIHJlYWRidWYpOworCQlpZiAodW5saWtlbHkoZXJyIHx8IHJlYWQgIT0gc3VicGdzaXplICogaykpIHsKKwkJCWlmIChtdGRfaXNfYml0ZmxpcChlcnIpICYmIHJlYWQgPT0gc3VicGdzaXplICogaykgeworCQkJCXByaW50ayhQUklOVF9QUkVGICJFQ0MgY29ycmVjdGlvbiBhdCAlI2xseFxuIiwKKwkJCQkgICAgICAgKGxvbmcgbG9uZylhZGRyKTsKKwkJCQllcnIgPSAwOworCQkJfSBlbHNlIHsKKwkJCQlwcmludGsoUFJJTlRfUFJFRiAiZXJyb3I6IHJlYWQgZmFpbGVkIGF0ICIKKwkJCQkgICAgICAgIiUjbGx4XG4iLCAobG9uZyBsb25nKWFkZHIpOworCQkJCXJldHVybiBlcnIgPyBlcnIgOiAtMTsKKwkJCX0KKwkJfQorCQlpZiAodW5saWtlbHkobWVtY21wKHJlYWRidWYsIHdyaXRlYnVmLCBzdWJwZ3NpemUgKiBrKSkpIHsKKwkJCXByaW50ayhQUklOVF9QUkVGICJlcnJvcjogdmVyaWZ5IGZhaWxlZCBhdCAlI2xseFxuIiwKKwkJCSAgICAgICAobG9uZyBsb25nKWFkZHIpOworCQkJZXJyY250ICs9IDE7CisJCX0KKwkJYWRkciArPSBzdWJwZ3NpemUgKiBrOworCX0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ldKQorCQkJY29udGludWU7CisJCWVyciA9IHZlcmlmeV9lcmFzZWJsb2NrMihpKTsKKwkJaWYgKHVubGlrZWx5KGVycikpCisJCQlnb3RvIG91dDsKKwkJaWYgKGkgJSAyNTYgPT0gMCkKKwkJCXByaW50ayhQUklOVF9QUkVGICJ2ZXJpZmllZCB1cCB0byBlcmFzZWJsb2NrICV1XG4iLCBpKTsKKwkJY29uZF9yZXNjaGVkKCk7CisJfQorCXByaW50ayhQUklOVF9QUkVGICJ2ZXJpZmllZCAldSBlcmFzZWJsb2Nrc1xuIiwgaSk7CisKKwllcnIgPSBlcmFzZV93aG9sZV9kZXZpY2UoKTsKKwlpZiAoZXJyKQorCQlnb3RvIG91dDsKKworCWVyciA9IHZlcmlmeV9hbGxfZXJhc2VibG9ja3NfZmYoKTsKKwlpZiAoZXJyKQorCQlnb3RvIG91dDsKKworCXByaW50ayhQUklOVF9QUkVGICJmaW5pc2hlZCB3aXRoICVkIGVycm9yc1xuIiwgZXJyY250KTsKKworb3V0OgorCWtmcmVlKGJidCk7CisJa2ZyZWUocmVhZGJ1Zik7CisJa2ZyZWUod3JpdGVidWYpOworCXB1dF9tdGRfZGV2aWNlKG10ZCk7CisJaWYgKGVycikKKwkJcHJpbnRrKFBSSU5UX1BSRUYgImVycm9yICVkIG9jY3VycmVkXG4iLCBlcnIpOworCXByaW50ayhLRVJOX0lORk8gIj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT1cbiIpOworCXJldHVybiBlcnI7Cit9Cittb2R1bGVfaW5pdChtdGRfc3VicGFnZXRlc3RfaW5pdCk7CisKK3N0YXRpYyB2b2lkIF9fZXhpdCBtdGRfc3VicGFnZXRlc3RfZXhpdCh2b2lkKQoreworCXJldHVybjsKK30KK21vZHVsZV9leGl0KG10ZF9zdWJwYWdldGVzdF9leGl0KTsKKworTU9EVUxFX0RFU0NSSVBUSU9OKCJTdWJwYWdlIHRlc3QgbW9kdWxlIik7CitNT0RVTE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hciAqaW9idWYxOworc3RhdGljIHVuc2lnbmVkIGNoYXIgKmJidDsKK3N0YXRpYyBpbnQgZWJjbnQ7CisKKyNpZiAxCitpbnQgbmFuZF9TbXNSZWFkKGludCBkd1N0YXJ0LCBpbnQgZHdMZW4sIGNoYXIqIHRvKXtyZXR1cm4gMDt9CitpbnQgbmFuZF9TbXNQcm9ncmFtKGludCBkd1N0YXJ0LCBpbnQgZHdMZW4sIGNoYXIqIGZyb20pe3JldHVybiAwO30KKyNlbHNlCitleHRlcm4gaW50IG5hbmRfU21zUmVhZChpbnQgZHdTdGFydCwgaW50IGR3TGVuLCBjaGFyKiB0byk7CitleHRlcm4gaW50IG5hbmRfU21zUHJvZ3JhbShpbnQgZHdTdGFydCwgaW50IGR3TGVuLCBjaGFyKiBmcm9tKTsKKyNlbmRpZgorLyoqKgorICoqKgkxLiByZWFkCisgKioqCTIuIGNoYW5nZSBhbmQgd3JpdGUKKyAqKioJMy4gcmVhZCBhbmQgY29tcGFyZQorICoqKgorICovCitzdGF0aWMgaW50IF9faW5pdCBtdGRfemZ0bHRlc3RfaW5pdCh2b2lkKQoreworCWludCBlcnIgPSAwOworCWludCBpOworCWludCBibG9ja19jbnQsIGJsb2NrOworCWludCBlY2NfY2FwOworCXVpbnQ2NF90IHRtcDsJCisJCisJcHJfaW5mbygiXG4iKTsKKwlwcl9pbmZvKCI9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09XG4iKTsKKworCXByaW50ayhQUklOVF9QUkVGICJNVEQgZGV2aWNlOiAlZFxuIiwgZGV2KTsgCisKKwltdGQgPSBnZXRfbXRkX2RldmljZShOVUxMLCBkZXYpOworCWlmIChJU19FUlIobXRkKSkgeworCQllcnIgPSBQVFJfRVJSKG10ZCk7CisJCXByaW50ayhQUklOVF9QUkVGICJlcnJvcjogQ2Fubm90IGdldCBNVEQgZGV2aWNlXG4iKTsKKwkJcmV0dXJuIGVycjsKKwl9CisKKwlpZiAobXRkLT53c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N0aW9uIGluY3JlYXNlcyB0aGUKKyAqIGRldmljZSByZWZlcmVuY2UgY291bnQgdG8gcHJldmVudCByZW1vdmFsIG9mIHRoZSBkZXZpY2UuIEluIG90aGVyIHdvcmRzLCB0aGUKKyAqIGRldmljZSBjYW5ub3QgYmUgcmVtb3ZlZCBpZiBpdHMgcmVmZXJlbmNlIGNvdW50IGlzIG5vdCB6ZXJvLgorICovCitzdHJ1Y3QgdWJpX2RldmljZSAqdWJpX2dldF9kZXZpY2UoaW50IHViaV9udW0pCit7CisJc3RydWN0IHViaV9kZXZpY2UgKnViaTsKKworCXNwaW5fbG9jaygmdWJpX2RldmljZXNfbG9jayk7CisJdWJpID0gdWJpX2RldmljZXNbdWJpX251bV07CisJaWYgKHViaSkgeworCQl1YmlfYXNzZXJ0KHViaS0+cmVmX2NvdW50ID49IDApOworCQl1YmktPnJlZl9jb3VudCArPSAxOworCQlnZXRfZGV2aWNlKCZ1YmktPmRldik7CisJfQorCXNwaW5fdW5sb2NrKCZ1YmlfZGV2aWNlc19sb2NrKTsKKworCXJldHVybiB1Ymk7Cit9CisKKy8qKgorICogdWJpX3B1dF9kZXZpY2UgLSBkcm9wIGFuIFVCSSBkZXZpY2UgcmVmZXJlbmNlLgorICogQHViaTogVUJJIGRldmljZSBkZXNjcmlwdGlvbiBvYmplY3QKKyAqLwordm9pZCB1YmlfcHV0X2RldmljZShzdHJ1Y3QgdWJpX2RldmljZSAqdWJpKQoreworCXNwaW5fbG9jaygmdWJpX2RldmljZXNfbG9jayk7CisJdWJpLT5yZWZfY291bnQgLT0gMTsKKwlwdXRfZGV2aWNlKCZ1YmktPmRldik7CisJc3Bpbl91bmxvY2soJnViaV9kZXZpY2VzX2xvY2spOworfQorCisvKioKKyAqIHViaV9nZXRfYnlfbWFqb3IgLSBnZXQgVUJJIGRldmljZSBieSBjaGFyYWN0ZXIgZGV2aWNlIG1ham9yIG51bWJlci4KKyAqIEBtYWpvcjogbWFqb3IgbnVtYmVyCisgKgorICogVG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OworCQlpZiAoZXJyKSB7CisJCQllcnIgPSAtRUZBVUxUOworCQkJYnJlYWs7CisJCX0KKworCQlpZiAocmVxLm10ZF9udW0gPCAwIHx8CisJCSAgICAocmVxLnViaV9udW0gPCAwICYmIHJlcS51YmlfbnVtICE9IFVCSV9ERVZfTlVNX0FVVE8pKSB7CisJCQllcnIgPSAtRUlOVkFMOworCQkJYnJlYWs7CisJCX0KKworCQltdGQgPSBnZXRfbXRkX2RldmljZShOVUxMLCByZXEubXRkX251bSk7CisJCWlmIChJU19FUlIobXRkKSkgeworCQkJZXJyID0gUFRSX0VSUihtdGQpOworCQkJYnJlYWs7CisJCX0KKworCQkvKgorCQkgKiBOb3RlLCBmdXJ0aGVyIHJlcXVlc3QgdmVyaWZpY2F0aW9uIGlzIGRvbmUgYnkKKwkJICogJ3ViaV9hdHRhY2hfbXRkX2RldigpJy4KKwkJICovCisJCW11dGV4X2xvY2soJnViaV9kZXZpY2VzX211dGV4KTsKKwkJZXJyID0gdWJpX2F0dGFjaF9tdGRfZGV2KG10ZCwgcmVxLnViaV9udW0sIHJlcS52aWRfaGRyX29mZnNldCk7CisJCW11dGV4X3VubG9jaygmdWJpX2RldmljZXNfbXV0ZXgpOworCQlpZiAoZXJyIDwgMCkKKwkJCXB1dF9tdGRfZGV2aWNlKG10ZCk7CisJCWVsc2UKKwkJCS8qIEBlcnIgY29udGFpbnMgVUJJIGRldmljZSBudW1iZXIgKi8KKwkJCWVyciA9IHB1dF91c2VyKGVyciwgKF9fdXNlciBpbnQzMl90ICopYXJncCk7CisKKwkJYnJlYWs7CisJfQorCisJLyogRGV0YWNoIGFuIE1URCBkZXZpY2UgY29tbWFuZCAqLworCWNhc2UgVUJJX0lPQ0RFVDoKKwl7CisJCWludCB1YmlfbnVtOworCisJCWRiZ19nZW4oImRldHRhY2ggTVREIGRldmljZSIpOworCQllcnIgPSBnZXRfdXNlcih1YmlfbnVtLCAoX191c2VyIGludDMyX3QgKilhcmdwKTsKKwkJaWYgKGVyc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9ncmFtOyBpZiBub3QsIHdyaXRlIHRvIHRoZSBGcmVlIFNvZnR3YXJlCisgKiBGb3VuZGF0aW9uLCBJbmMuLCA1OSBUZW1wbGUgUGxhY2UsIFN1aXRlIDMzMCwgQm9zdG9uLCBNQSAwMjExMS0xMzA3IFVTQQorICoKKyAqIEF1dGhvcjogQXJ0ZW0gQml0eXV0c2tpeSAo0JHQuNGC0Y7RhtC60LjQuSDQkNGA0YLRkdC8KQorICovCisKKyNpZm5kZWYgX19VQklfREVCVUdfSF9fCisjZGVmaW5lIF9fVUJJX0RFQlVHX0hfXworCisjaWZkZWYgQ09ORklHX01URF9VQklfREVCVUcKKyNpbmNsdWRlIDxsaW51eC9yYW5kb20uaD4KKworI2RlZmluZSB1YmlfYXNzZXJ0KGV4cHIpICBkbyB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisJaWYgKHVubGlrZWx5KCEoZXhwcikpKSB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorCQlwcmludGsoS0VSTl9DUklUICJVQkkgYXNzZXJ0IGZhaWxlZCBpbiAlcyBhdCAldSAocGlkICVkKVxuIiwgXAorCQkgICAgICAgX19mdW5jX18sIF9fTElORV9fLCBjdXJyZW50LT5waWQpOyAgICAgICAgICAgICAgICAgICAgXAorCQl1YmlfZGJnX2R1bXBfc3RhY2soKTsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorCX0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKK30gd2hpbGUgKDApCisKKyNkZWZpbmUgZGJnX2VycihmbXQsIC4uLikgdWJpX2VycihmbXQsICMjX19WQV9BUkdTX18pCisKKyNkZWZpbmUgdWJpX2RiZ19kdW1wX3N0YWNrKCkgZHVtcF9zdGFjaygpCisKKyNkZWZpbmUgdWJpX2RiZ19wcmludF9oZXhfZHVt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orCisjZWxzZQorCisvKiBVc2UgImlmICgwKSIgdG8gbWFrZSBjb21waWxlciBjaGVjayBhcmd1bWVudHMgZXZlbiBpZiBkZWJ1Z2dpbmcgaXMgb2ZmICovCisjZGVmaW5lIHViaV9hc3NlcnQoZXhwcikgIGRvIHsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKwlpZiAoMCkgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisJCXByaW50ayhLRVJOX0NSSVQgIlVCSSBhc3NlcnQgZmFpbGVkIGluICVzIGF0ICV1IChwaWQgJWQpXG4iLCBcCisJCSAgICAgICBfX2Z1bmNfXywgX19MSU5FX18sIGN1cnJlbnQtPnBpZCk7ICAgICAgICAgICAgICAgICAgICBcCisJfSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorfSB3aGlsZSAoMCkKKworI2RlZmluZSBkYmdfZXJyKGZtdCwgLi4uKSBkbyB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisJaWYgKDApICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorCQl1YmlfZXJyKGZtdCwgIyNfX1ZBX0FSR1NfXyk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorfSB3aGlsZSAoMCkKKworI2RlZmluZSB1YmlfZGJnX21zZyhmbXQsIC4uLikgZG8geyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisJaWYgKDApICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorCQlwcmludGsoS0VSTl9ERUJVRyBmbXQgIlxuIiwgIyNfX1ZBX0FSR1NfXyk7ICAgICAgICAgICAgICAgICAgXAorfSB3aGlsZSAoMCkKKworI2RlZmluZSBkYmdfbXNnKGZtdCwgLi4uKSAgdWJpX2RiZ19tc2coZm10LCAjI19fVkFfQVJHU19fKQorI2RlZmluZSBkYmdfZ2VuKGZtdCwgLi4uKSAgdWJpX2RiZ19tc2coZm10LCAjI19fVkFfQVJHU19fKQorI2RlZmluZSBkYmdfZWJhKGZtdCwgLi4uKSAgdWJpX2RiZ19tc2coZm10LCAjI19fVkFfQVJHU19fKQorI2RlZmluZSBkYmdfd2woZm10LCAuLi4pICAgdWJpX2RiZ19tc2coZm10LCAjI19fVkFfQVJHU19fKQorI2RlZmluZSBkYmdfaW8oZm10LCAuLi4pICAgdWJpX2RiZ19tc2coZm10LCAjI19fVkFfQVJHU19fKQorI2RlZmluZSBkYmdfYmxkKGZtdCwgLi4uKSAgdWJpX2RiZ19tc2coZm10LCAjI19fVkFfQVJHU19fKQorCitzdGF0aWMgaW5saW5lIHZvaWQgdWJpX2RiZ19kdW1wX3N0YWNrKHZvaWQpICAgICAgICAgICAgICAgICAgICAgICAgICB7IHJldHVybjsgfQorc3RhdGljIGlubGluZSB2b2lkCit1YmlfZGJnX2R1bXBfZWNfaGRyKGNvbnN0IHN0cnVjdCB1YmlfZWNfaGRyICplY19oZHIpICAgICAgICAgICAgICAgICB7IHJldHVybjsgfQorc3RhdGljIGlubGluZSB2b2lkCit1YmlfZGJnX2R1bXBfdmlkX2hkcihjb25zdCBzdHJ1Y3QgdWJpX3ZpZF9oZHIgKnZpZF9oZHIpICAgICAgICAgICAgICB7IHJldHVybjsgfQorc3RhdGljIGlubGluZSB2b2lkCit1YmlfZGJnX2R1bXBfdm9sX2luZm8oY29uc3Qgc3RydWN0IHViaV92b2x1bWUgKnZvbCkgICAgICAgICAgICAgICAgICB7IHJldHVybjsgfQorc3RhdGljIGlubGluZSB2b2lkCit1YmlfZGJnX2R1bXBfdnRibF9yZWNvcmQoY29uc3Qgc3RydWN0IHViaV92dGJsX3JlY29yZCAqciwgaW50IGlkeCkgICB7IHJldHVybjsgfQorc3RhdGljIGlubGluZSB2b2lkIHViaV9kYmdfZHVtcF9zdihjb25zdCBzdHJ1Y3QgdWJpX3NjYW5fdm9sdW1lICpzdikgeyByZXR1cm47IH0KK3N0YXRpYyBpbmxpbmUgdm9pZCB1YmlfZGJnX2R1bXBfc2ViKGNvbnN0IHN0cnVjdCB1Ymlfc2Nhbl9sZWIgKnNlYiwKKwkJCQkgICAgaW50IHR5cGUpICAgICAgICAgICAgICAgICAgICAgICAgeyByZXR1cm47IH0KK3N0YXRpYyBpbmxpbmUgdm9pZAordWJpX2RiZ19kdW1wX21rdm9sX3JlcShjb25zdCBzdHJ1Y3QgdWJpX21rdm9sX3JlcSAqcmVxKSAgICAgICAgICAgICAgeyByZXR1cm47IH0KK3N0YXRpYyBpbmxpbmUgdm9pZCB1YmlfZGJnX2R1bXBfZmxhc2goc3RydWN0IHViaV9kZXZpY2UgKnViaSwKKwkJCQkgICAgICBpbnQgcG51bSwgaW50IG9mZnNldCwgaW50IGxlbikgeyByZXR1cm47IH0KK3N0YXRpYyBpbmxpbmUgdm9pZAordWJpX2RiZ19wcmludF9oZXhfZHVtcChjb25zdCBjaGFyICpsLCBjb25zdCBjaGFyICpwcywgaW50IHB0LCBpbnQgciwKKwkJICAgICAgIGludCBnLCBjb25zdCB2b2lkICpiLCBzaXplX3QgbGVuLCBib29sIGEpICAgICB7IHJldHVybjsgfQorc3RhdGljIGlubGluZSBpbnQgdWJpX2RiZ19jaGVja19hbGxfZmYoc3RydWN0IHViaV9kZXZpY2UgKnViaSwKKwkJCQkgICAgICAgaW50IHBudW0sIGludCBvZmZzZXQsCisJCQkJICAgICAgIGludCBsZW4pICAgICAgICAgICAgICAgICAgICB7IHJldHVybiAwOyB9CitzdGF0aWMgaW5saW5lIGludCB1YmlfZGJnX2NoZWNrX3dyaXRlKHN0cnVjdCB1YmlfZGV2aWNlICp1YmksCisJCQkJICAgICAgY29uc3Qgdm9pZCAqYnVmLCBpbnQgc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oZXJyKQorCQkJZ290byBvdXRfbGViX3VubG9jazsKKwl9CisKKwl2b2wtPmViYV90YmxbbG51bV0gPSBwbnVtOworCitvdXRfbGViX3VubG9jazoKKwlsZWJfd3JpdGVfdW5sb2NrKHViaSwgdm9sX2lkLCBsbnVtKTsKK291dF9tdXRleDoKKwltdXRleF91bmxvY2soJnViaS0+YWxjX211dGV4KTsKKwl1YmlfZnJlZV92aWRfaGRyKHViaSwgdmlkX2hkcik7CisJcmV0dXJuIGVycjsKKword3JpdGVfZXJyb3I6CisJaWYgKGVyciAhPSAtRUlPIHx8ICF1YmktPmJhZF9hbGxvd2VkKSB7CisJCS8qCisJCSAqIFRoaXMgZmxhc2ggZGV2aWNlIGRvZXMgbm90IGFkbWl0IG9mIGJhZCBlcmFzZWJsb2NrcyBvcgorCQkgKiBzb21ldGhpbmcgbmFzdHkgYW5kIHVuZXhwZWN0ZWQgaGFwcGVuZWQuIFN3aXRjaCB0byByZWFkLW9ubHkKKwkJICogbW9kZSBqdXN0IGluIGNhc2UuCisJCSAqLworCQl1Ymlfcm9fbW9kZSh1YmkpOworCQlnb3RvIG91dF9sZWJfdW5sb2NrOworCX0KKworCWVyciA9IHViaV93bF9wdXRfcGViKHViaSwgcG51bSwgMSk7CisJaWYgKGVyciB8fCArK3RyaWVzID4gVUJJX0lPX1JFVFJJRVMpIHsKKwkJdWJpX3JvX21vZGUodWJpKTsKKwkJZ290byBvdXRfbGViX3VubG9jazsKKwl9CisKKwl2aWRfaGRyLT5zcW51bSA9IGNwdV90b19iZTY0KG5leHRfc3FudW0odWJpKSk7CisJdWJpX21zZygidHJ5IGFub3RoZXIgUEVCIik7CisJZ290byByZXRyeTsKK30KKworLyoqCisgKiBpc19lcnJvcl9zYW5lIC0gY2hlY2sgd2hldGhlciBhIHJlYWQgZXJyb3IgaXMgc2FuZS4KKyAqIEBlcnI6IGNvZGUgb2YgdGhlIGVycm9yIGhhcHBlbmVkIGR1cmluZyByZWFkaW5nCisgKgorICogVGhpcy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zdHJ1Y3QgdWJpX2RldmljZSAqdWJpLCBzdHJ1Y3QgdWJpX3ZvbHVtZSAqdm9sLAorCQkJICAgIHN0cnVjdCB1Ymlfdm9sdW1lX2luZm8gKnZpKTsKKworLyoKKyAqIHViaV9yYl9mb3JfZWFjaF9lbnRyeSAtIHdhbGsgYW4gUkItdHJlZS4KKyAqIEByYjogYSBwb2ludGVyIHRvIHR5cGUgJ3N0cnVjdCByYl9ub2RlJyB0byB1c2UgYXMgYSBsb29wIGNvdW50ZXIKKyAqIEBwb3M6IGEgcG9pbnRlciB0byBSQi10cmVlIGVudHJ5IHR5cGUgdG8gdXNlIGFzIGEgbG9vcCBjb3VudGVyCisgKiBAcm9vdDogUkItdHJlZSdzIHJvb3QKKyAqIEBtZW1iZXI6IHRoZSBuYW1lIG9mIHRoZSAnc3RydWN0IHJiX25vZGUnIHdpdGhpbiB0aGUgUkItdHJlZSBlbnRyeQorICovCisjZGVmaW5lIHViaV9yYl9mb3JfZWFjaF9lbnRyeShyYiwgcG9zLCByb290LCBtZW1iZXIpICAgICAgICAgICAgICAgICAgICAgICAgIFwKKwlmb3IgKHJiID0gcmJfZmlyc3Qocm9vdCksICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisJICAgICBwb3MgPSAocmIgPyBjb250YWluZXJfb2YocmIsIHR5cGVvZigqcG9zKSwgbWVtYmVyKSA6IE5VTEwpOyAgICAgXAorCSAgICAgcmI7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKwkgICAgIHJiID0gcmJfbmV4dChyYiksICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisJICAgICBwb3MgPSAocmIgPyBjb250YWluZXJfb2YocmIsIHR5cGVvZigqcG9zKSwgbWVtYmVyKSA6IE5VTEwpKQorCisvKioKKyAqIHViaV96YWxsb2NfdmlkX2hkciAtIGFsbG9jYXRlIGEgd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fY29sID4+IDEpKSAmIDB4MTUpID09IDB4MTUpKSB7CisJCS8qIFNpbmdsZSBiaXQgKHJlY292ZXJhYmxlKSBlcnJvciBpbiBkYXRhICovCisKKwkJYml0ID0gMDsKKworCQlpZiAoZGVsdGFfY29sICYgMHgyMCkKKwkJCWJpdCB8PSAweDA0OworCQlpZiAoZGVsdGFfY29sICYgMHgwOCkKKwkJCWJpdCB8PSAweDAyOworCQlpZiAoZGVsdGFfY29sICYgMHgwMikKKwkJCWJpdCB8PSAweDAxOworCisJCWlmIChkZWx0YV9saW5lID49IG5fYnl0ZXMpCisJCQlyZXR1cm4gLTE7CisKKwkJZGF0YVtkZWx0YV9saW5lXSBePSAoMSA8PCBiaXQpOworCisJCXJldHVybiAxOwkvKiBjb3JyZWN0ZWQgKi8KKwl9CisKKwlpZiAoKGh3ZWlnaHQzMihkZWx0YV9saW5lKSArCisJICAgICBod2VpZ2h0MzIoZGVsdGFfbGluZV9wcmltZSkgKworCSAgICAgaHdlaWdodDgoZGVsdGFfY29sKSkgPT0gMSkgeworCQkvKiBSZWNjb3ZlcmFibGUgZXJyb3IgaW4gZWNjICovCisKKwkJKnJlYWRfZWNjID0gKnRlc3RfZWNjOworCQlyZXR1cm4gMTsJLyogY29ycmVjdGVkICovCisJfQorCisJLyogVW5yZWNvdmVyYWJsZSBlcnJvciAqLworCisJcmV0dXJuIC0xOworfQpkaWZmIC0tZ2l0IGEvYXAvb3MvbGludXgvbGludXgtMy40LngvZHJpdmVycy9tdGQvemZ0bF92Mi5jIGIvYXAvb3MvbGludXgvbGludXgtMy40LngvZHJpdmVycy9tdGQvemZ0bF92Mi5jCm5ldyBmaWxlIG1vZGUgMTAwNjQ0CmluZGV4IDAwMDAwMDAuLmE3ZWQ3MDMKLS0tIC9kZXYvbnVsbAorKysgYi9hcC9vcy9saW51eC9saW51eC0zLjQueC9kcml2ZXJzL210ZC96ZnRsX3YyLmMKQEAgLTAsMCArMSwxMTk2IEBACisvKgorICogTGludXggZHJpdmV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BjbWRsaW5lX210ZF9wYXJ0aXRpb24geworCXN0cnVjdCBjbWRsaW5lX210ZF9wYXJ0aXRpb24gKm5leHQ7CisJY2hhciAqbXRkX2lkOworCWludCBudW1fcGFydHM7CisJc3RydWN0IG10ZF9wYXJ0aXRpb24gKnBhcnRzOworfTsKKworaW50IHBhcnRudW0gPSAwOworc3RhdGljIHN0cnVjdCBtdXRleCB6ZnRsX211dGV4Oworc3RhdGljIGludCBtdXRleF9pbml0ZWQgPSAwOworaW50IGNkcm9tX3BhcnRzaXplID0gMDsKKworLyogbnZybyBwYXJ0aXRpb24gc2l6ZSAqLworaW50IG52cm9fcGFydHNpemUgPSAwOworCisKKworaW50IG5hbmRfTnZQcm9ncmFtKGludCBkd1N0YXJ0LCBpbnQgZHdMZW4sIGNoYXIqIGZyb20pOworaW50IG5hbmRfTnZSZWFkKGludCBkd1N0YXJ0LCBpbnQgZHdMZW4sIGNoYXIqIHRvKTsKKworCitzdGF0aWMgaW50IG1lbWNtcGIodm9pZCAqYSwgaW50IGMsIGludCBuKQoreworCWludCBpOworCWZvciAoaSA9IDA7IGkgPCBuOyBpKyspIHsKKwkJaWYgKGMgIT0gKCh1bnNpZ25lZCBjaGFyICopYSlbaV0pCisJCQlyZXR1cm4gMTsKKwl9CisJcmV0dXJuIDA7Cit9CisKKy8qIFJlYWQgb29iIGRhdGEgZnJvbSBmbGFzaCAqLworc3RhdGljIGludCB6ZnRsX3JlYWRfb29iKHN0cnVjdCBaRlRMcmVjb3JkICp6ZnRsLCB1aW50MzJfdCBvZmZzLCB1aW50OF90ICpidWYpCit7CisgICAgbmFuZF9pbmZvX3QgICpuYW5kID0gemZ0bC0+bmFuZDsKKwl1aW50MzJfdCBtYXNrID0gemZ0bC0+d3JpdGVzaXplIC0gMTsKKwlzdHJ1Y3QgbXRkX29vYl9vcHMgb3BzOworCWludDMyX3QgcmVzOworCisJb3BzLm1vZGUgPSBNVERfT1BTX1BMQUNFX09PQjsKKwlvcHMub29ib2ZmcyA9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GwtPmJsb2NrVGFibGVbaW5kZXhdID0gQkxPQ0tfQkFEOworICAgICAgICAgICAgY29udGludWU7CisgICAgICAgIH0KKworICAgICAgICAvKiDQtL/ptcTLs9Dyzqogz8jQtLXatv7Ss7+qyry1vdfuuvPSu9Kzo6zU2dC0tdrSu9KzICovCisgICAgICAgIC8qICAgICAgtdrSu9Kzb29iICAgILXatv7Ss29vYiAgIL/p17TMrCAgICAgICAgICAgICAgICAgICAgIMu1w/cgICAgKi8KKyAgICAgICAgICAgIC8qICAgMHhmZiAgICAgICAgIDB4ZmYgICAgQkxPQ0tfRlJFRSAgICAgICAgICAgICC2vMO709C/qsq80LQgKi8KKyAgICAgICAgICAgIC8qICAgMHhmZiAgICAgICAgIC0tLS0gICAgQkxPQ0tfRElSVFkgICAgICAgICAgICC/qsq80LSjrLWrw7vT0NC0zeq12tK70rOjrNbQvOSxu9bQts8gKi8KKyAgICAgICAgICAgIC8qICAgLS0tLSAgICAgICAgIDB4ZmYgICAgQkxPQ0tfVVNFRC9ESVJUWSAgICAgICDQtM3qtdrSu9Kzo6zN6rPJv+nQtMjrICovCisgICAgICAgICAgICAvKiAgIC0tLS0gICAgICAgICAtLS0tICAgIEJMT0NLX1VTRUQvRElSVFkgICAgICAg0LTN6rXa0rvSs6Oszeqzyb/p0LTI6yAqLworICAgICAgICAgCisgICAgICAgIGlmKHpmdGxfcmVhZF9vb2IoemZ0bCwgYWRkciwgKHVpbnQ4X3QgKilvb2IgKSkvKiC2wcihtdrSu9KzICovCisgICAgICAgIHsKKyAgICAgICAgICAgICBwcmludGsoIlt6ZnRsX3NldHVwX3RhYmxlXSByZWFkIG9vYiBlcnJvciBhdCA9IDB4JTA4eFxuIiwgYWRkcik7CisgICAgICAgICAgICAgcmV0dXJuIE5BTkRfUkVBRF9XUklURV9FUlJPUjsKKyAgICAgICAgfQorICAgICAgICAKKwkJbWVtY3B5KHpmdGxfYnVmZmVyLG9vYiArIGdfb29iX3pmdGxfb2Zmc2V0LG9vYnNpemUgLWdfb29iX3pmdGxfb2Zmc2V0KTsKKwkJbWVtY3B5KCh1bnNpZ25lZCBjaGFyICopJnpmdGxfb29iLHpmdGxfYnVmZmVyLHNpemVvZihzdHJ1Y3QgemZ0bF9vb2IpKTsKKyAgICAgICAgaWYobWVtY21wYihvb2IsIDB4ZmYsIG9vYnNpemUpKSAgICAgLyogILXa0rvSs29vYiAhPSAweGZmICovCisgICAgICAgIHsKKyAgICAgICAgICAgIC8vaWYoIG9vYi51c2VkID09IDEgKSAgIC8qIGJsb2NrIGlzIHVzZWQgKi8KKyAgICAgICAgICAgIGlmKCAhbWVtY21wKHpmdGxfb29iLmhlYWQsIENPTkZJR19aRkxUX0hFQUQsIENPTkZJR19aRkxUX0hFQURfQllURSkgKSAgIC8qILD8uqzT0LfWx/jNtyAqLworICAgICAgICAgICAgeworICAgICAgICAgICAgICAgICppc193cml0ZWQgKz0gMTsKKyAgICAgICAgICAgICAgICBpZiggemZ0bF9vb2IudmVyc2lvbiA+IHpmdGwtPnZlcnNpb25UYWJsZVt6ZnRsX29vYi5sb2dpY0Jsb2NrSURdKSAKKyAgICAgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgICAgIC8qIHZlcnNpb24gaXMgbmV3ZXIgKi8KKyAgICAgICAgICAgICAgICAgICAgaWYoemZ0bC0+dmVyc2lvblRhYmxlW3pmdGxfb29iLmxvZ2ljQmxvY2tJRF0gIT0gMCkgIC8qINLRvq3T0LbU06a1xHVzZWS/6cHLICovCisgICAgICAgICAgICAgICAgICAgICAgICB6ZnRsLT5ibG9ja1RhYmxlW3pmdGwtPmJsb2NrUmVwVGFibGVbemZ0bF9vb2IubG9naWNCbG9ja0lEXV0gPSBCTE9DS19ESVJUWTsKKworICAgICAgICAgICAgICAgICAgICB6ZnRsLT5ibG9ja1JlcFRhYmxlW3pmdGxfb29iLmxvZ2ljQmxvY2tJRF0gPSBpbmRleDsKKyAgICAgICAgICAgICAgICAgICAgemZ0bC0+dmVyc2lvblRhYmxlW3pmdGxfb29iLmxvZ2ljQmxvY2tJRF0gPSB6ZnRsX29vYi52ZXJzaW9uOworICAgICAgICAgICAgICAgICAgICB6ZnRsLT5ibG9ja1RhYmxlW2luZGV4XSA9IEJMT0NLX1VTRUQ7CisJCQkJCS8qIEFkZGVkIGJ5IHpob3VxaSBmb3IgeHh4LCAyMDE0LzA0LzIzICovCisgICAgICAgICAgICAgICAgICAgIHpmdGwtPmxhc3RGcmVlQmxvY2sgPSBpbmRleCArIDE7IAorICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBlbHNlCisgICAgICAgICAgICAgICAgICAgIHpmdGwtPmJsb2NrVGFibGVbaW5kZXhdID0gQkxPQ0tfRElSVFk7ICAgICAgICAgICAgICAKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGVsc2UKKyAgICAgICAgICAgICAgICB6ZnRsLT5ibG9ja1RhYmxlW2luZGV4XSA9IEJMT0NLX0RJUlRZOyAKKyAgICAgICAgfQorICAgICAgICBlbHNlICAgIC8qIDB4ZmajrGJsb2NrIGlzIGZyZWUgKi8KKyAgICAgICAgeworICAgICAgICAgICAgaWYoemZ0bF9yZWFkX29vYih6ZnRsLCBhZGRyICsgemZ0bC0+d3JpdGVzaXplLCAodWludDhfdCAqKW9vYiApKS8qILbByKG12rb+0rMgKi8KKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICBwcmludGsoIlt6ZnRsX3NldHVwX3RhYmxlXSByZWFkIG9vYiBlcnJvciBhdCA9IDB4JTA4eFxuIiwgYWRkcik7CisgICAgICAgICAgICAgICAgcmV0dXJuIE5BTkRfUkVBRF9XUklURV9FUlJPUjsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgaWYobWVtY21wYihvb2IsIDB4ZmYsIG9vYnNpemUpKSAgICAgLyogILXatv7Ss29vYiAhPSAweGZmICovCisgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgemZ0bC0+YmxvY2tUYWJsZVtpbmRleF0gPSBCTE9DS19ESVJUWTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGVsc2UgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qICC12rb+0rNvb2IgPSAweGZmICovCisgICAgICAgICAgICAgICAgemZ0bC0+YmxvY2tUYWJsZVtpbmRleF0gPSBCTE9DS19GUkVFOworICAgICAgICB9ICAgICAgICAKKyAgICB9CisKKyAgICByZXR1cm4gMDsKK30KKworCisvKiCywbP90ru/6aOsZWJudW3Oqr/pusUgKi8KK3N0YXRpYyBpbnQgemZ0bF9lcmFzZV9ibG9jayhuYW5kX2luZm9fdCAgKm5hbmQsIHVpbnQzMl90IGVibnVtKQoreworCWludCBlcnIgPSAtMTsKKwlzdHJ1Y3QgZXJhc2VfaW5mbyBlaTsKKwl1aW50MzJfdCBhZGRyID0gZWJudW0gKiBuYW5kLT5lcmFzZXNpemU7CisKKwltZW1zZXQoJmVpLCAwLCBzaXplb2Yoc3RydWN0IGVyYXNlX2luZm8pKTsKKwllaS5tdGQgID0gbmFuZDsKKwllaS5hZGRyID0gKHVpbnQ2NF90KWFkZHI7CisJZWkubGVuICA9ICh1aW50NjRfdCluYW5kLT5lcmFzZXNpemU7CisKKwllcnIgPSBuYW5kLT5fZXJhc2UobmFuZCwgJmVpKTsKKwlpZiAoZXJyKSAKKyAgICB7CisJCXByaW50aygiW3pmdGxfZXJhc2VfYmxvY2tdOiBlcmFzaW5nICVkICBlcnJvciAlZFxuIiwgZWJudW0sIGVycik7CisJCXJldHVybiBlcnI7CisJfQorCisJaWYgKGVpLnN0YXRlID09IE1URF9FUkFTRV9GQUlMRUQpIAorICAgIHsKKwkJcHJpbnRrKCJbemZ0bF9lcmFzZV9ibG9ja106IGVyYXNpbmcgJWRcbiIsZWJudW0pOworCQlyZXR1cm4gLTE7CisJfQorCXJldHVybiAwOworfQorCisKK3ZvaWQgemZ0bF9nYXJiYWdlX2NvbGxlY3Qoc3RydWN0IFpGVExyZWNvcmQgKnpmdGwpCit7Cisg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CkKKyAgICB7CisgICAgICAgIC8qIL/VvOSjrLP1yry7r86qIDB4RkYgKi8KKyAgICAgICAgbWVtc2V0KGJsb2NrYnVmLCAweGZmLCBlcmFzZXNpemUpOworICAgICAgICBtZW1zZXQob29iLCAweGZmLCBvb2Jfc2l6ZSk7CisJCW1lbXNldCh6ZnRsX2J1ZmZlciwweGZmLDI1Nik7CisgICAgICAgCisgICAgICAgIC8qILvxyKHC37ytv+mjrLywv+nE2sar0sYgKi8KKyAgICAgICAgYmxvY2tfbG9nID0gb2Zmc2V0ID4+ICh6ZnRsLT5lcmFzZXNpemVfc2hpZnQpOyAgICAgICAgICAgICAgIAorICAgICAgICBibG9ja19vZmZzZXQgPSBvZmZzZXQgJiAoemZ0bC0+ZXJhc2VzaXplIC0gMSk7ICAvKiC/6cTatcTGq9LGtdjWtyAqLworCisgICAgICAgIC8qIMXQts/C37ytv+nKx7fx09DO78DtttTTpr/po6zI57n709CjrNTyzqq4xNC0yv2+3aO7yOe5+8O709CjrNTyzqq12tK7tM7QtLTLv+kgKi8KKyAgICAgICAgaWYoemZ0bC0+YmxvY2tSZXBUYWJsZVtibG9ja19sb2ddICE9IEJMT0NLX05JTCkKKyAgICAgICAgeworICAgICAgICAgICAgLyogu/HIocLfvK2/6bbU06a1xM7vwO2/6SAqLworICAgICAgICAgICAgb2Zmc2V0X2Jsb2NrX3BoeSA9IHpmdGwtPmJsb2NrUmVwVGFibGVbYmxvY2tfbG9nXTsKKyAgICAgICAgICAgIHpmdGxfZGVidWcoIiAgICBbemZ0bF93cml0ZV0gIHpmdGwtPmJsb2NrUmVwVGFibGVbJWRdID0gJWRcbiIsIGJsb2NrX2xvZywgb2Zmc2V0X2Jsb2NrX3BoeSk7CisgCisgICAgICAgICAgICAvKiDV+7j2tsHIodK7v+nK/b7dICovCisgICAgICAgICAgICB6ZnRsX2RlYnVnKCIgICAgW3pmdGxfcmVhZF0gIG5hbmQtPnJlYWQoIC0weCUweC0sIC0weCUweC0pXG4iLCAKKyAgICAgICAgICAgICAgICAgICAgICAgICgoZmlyc3RCbG9jayArIG9mZnNldF9ibG9ja19waHkpIDw8IGVyYXNlc2l6ZV9zaGlmdCksZXJhc2VzaXplKTsKKyAgICAgICAgICAgIHJldCA9IG5hbmQtPl9yZWFkKG5hbmQsICgoZmlyc3RCbG9jayArIG9mZnNldF9ibG9ja19waHkpIDw8IGVyYXNlc2l6ZV9zaGlmdCksIGVyYXNlc2l6ZSwgJnJldGxlbiwgYmxvY2tidWYpOworICAgICAgICAgICAgaWYgKHJldCB8fCByZXRsZW4gIT0gZXJhc2VzaXplKQorICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0VSUiJbemZsdGxdOiAtemZ0bF9yZWFkLSBlcnJvclxuIik7CisjaWZkZWYgQ09ORklHX01URF9OVlJFU1VNRSAgICAJCSAgIAorICAgIAkJICAgIGlmKCghek9zc19OdkluUmVzdW1lKCkpJiYoemZ0bD09emZ0bF9pbmZvWzFdKSYmKHpmdGxfcmVzICE9IDEpKQorCQkJICAgIHsKKwkJCQkJcmV0dXJuIC0xOworCQkJICAgIH0KKyNlbmRpZgorICAgICAgICAgICAgfQorCisgICAgICAgICAgICAvKiC2wcih1eLSu7/ptcRPT0LQxc+io6yyorj80MIgVkVSU0lPTiwgyOe5+7Tvtb2w5rG+usW1xOPQ1rWjrNTyvfjQ0LvYytUgKi8KKyAgICAgICAgICAgIGlmKHpmdGxfcmVhZF9vb2IoemZ0bCwgKChmaXJzdEJsb2NrICsgb2Zmc2V0X2Jsb2NrX3BoeSkgPDwgZXJhc2VzaXplX3NoaWZ0KSwgKHVpbnQ4X3QgKilvb2IgKSkKKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICAgcHJpbnRrKCIgICAgW3pmdGxfd3JpdGVdIHJlYWQgb29iIGVycm9yIGF0ID0gMHgleFxuIiwgKG9mZnNldF9ibG9ja19waHkgPDwgZXJhc2VzaXplX3NoaWZ0KSk7CisgICAgICAgICAgICAgICAgIC8vcmV0dXJuIC0xOworICAgICAgICAgICAgfQorCQkJbWVtY3B5KHpmdGxfYnVmZmVyLG9vYiArIGdfb29iX3pmdGxfb2Zmc2V0LG9vYl9zaXplLWdfb29iX3pmdGxfb2Zmc2V0KTsgCisJCQltZW1jcHkoKHVuc2lnbmVkIGNoYXIgKikmemZ0bF9vb2IsemZ0bF9idWZmZXIsc2l6ZW9mKHN0cnVjdCB6ZnRsX29vYikpOworICAgICAgICAgICAgaWYoIHpmdGxfb29iLnZlcnNpb24gPT0gQ09ORklHX1pGTFRfVkVSU0lPTl9USFJFU0hPTEQgKQorICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIHpmdGxfZGVidWcoIiAgICBbemZ0bF93cml0ZV0gdXAgdG8gdGhlIC1DT05GSUdfWkZMVF9WRVJTSU9OX1RIUkVTSE9MRC1cbiIpOworICAgICAgICAgICAgICAgIGlzX3VwdGhyZXNob2xkID0gMTsKKyAgICAgICAgICAgICAgICB6ZnRsX2dhcmJhZ2VfY29sbGVjdCh6ZnRsKTsKKyAgICAgICAgICAgICAgICB6ZnRsX29vYi52ZXJzaW9uID0gMTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGVsc2UKKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICAKKyAgICAgICAgICAgICAgICB6ZnRsX29vYi52ZXJzaW9uICs9IDE7CisJCQkJemZ0bF9kZWJ1ZygiICAgIFt6ZnRsX3dyaXRlXSAgb29iLT52ZXJzaW9uID0gJWQsb29iLT5sb2dpY0Jsb2NrSUQgPSAlZFxuIiwgemZ0bF9vb2IudmVyc2lvbiwgemZ0bF9vb2IubG9naWNCbG9ja0lEKTsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgbWVtY3B5KHpmdGxfb29iLmhlYWQsIENPTkZJR19aRkxUX0hFQUQsIENPTkZJR19aRkxUX0hFQURfQllURSk7ICAgLyogv72xtHpmdGzNtyAqLyAKKyAgICAgICAgICAgIHpmdGxfb29iLmxvZ2ljQmxvY2tJRCA9IGJsb2NrX2xvZzsKKworICAgICAgICAgICAgLyogzO6z5Lj80MIgZGF0YSAqLworICAgICAgICAgICAgaWYgKGxlZnRfdG9fd3JpdGUgPCAoZXJhc2VzaXplIC0gYmxvY2tfb2Zmc2V0KSkKKwkJCSAgICB3cml0ZV9sZW5ndGggPSBsZWZ0X3RvX3dyaXRlOworCQkgICAgZWxzZQorCQkJICAgIHdyaXRlX2xlbmd0aCA9IG5hbmQtPmVyYXNlc2l6ZSAtIGJsb2NrX29mZnNldDsKKworICAgICAgICAgICAgbWVtY3B5KGJsb2NrYnVmICsgYmxvY2tfb2Zmc2V0LCBidWZmZXIsIHdyaXRlX2xlbmd0aCk7CisgICAgICAgICAgICB6ZnRsX2RlYnVnKCIgICAgW3pmdGxfd3JpdGVdICB1cGRhdGUgdGhlIGRhdGUgKCAtMHglMHgtLCAtMHglMHgtIClcbiIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmxvY2tfb2Zmc2V0LCB3cml0ZV9sZW5ndGgpOworICAgICAgICAgICAgICAgICAgICAgICAgCisgICAgICAgICAgICAKKyAgICAgICAgICAgIC8qINGw1dLSu7j2IEZSRUUgtcTO78Dtv+kgKi8KKyAgICAgICAgICAgIGZpbmRfbmV4dF9mcmVlX2Jsb2NrXzE6CisgICAgICAgICAgICBpZiggemZ0bF9maW5kX2ZyZWVfYmxvY2soemZ0bCwgJmJsb2NrX25ldykgKS8qIEJMT0NLX1VTRUQgKi8KKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICAvKiDDu9PQ1dK1vUZSRUW/6SAqLworICAgICAgICAgICAgICAgIHByaW50aygiICAgIFt6ZnRsX3dyaXRlXSB0aGVyZSBpcyBlbm91Z2ggYmxvY2ssIHBsZWFzZSBlbmxhcmdlIHRoZSBwYXJ0aXRpb25cbiIpOworICAgICAgICAgICAgICAgIHJldHVybiBDQU5fTk9UX0ZJTkRfRlJFRV9CTE9DSzsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgLyog0LTI69K7v+kgKi8KKyAgICAgICAgICAgIHpmdGxfZGVidWcoIiAgICBbemZ0bF93cml0ZV9ibG9ja10gIG5hbmQtPndyaXRlKCAtMHglMHgtLCAtMHglMHgtKVxuIiwgCisgICAgICAgICAgICAgICAgICAgICAgICAoKGZpcnN0QmxvY2sgKyBibG9ja19uZXcpIDw8IGVyYXNlc2l6ZV9zaGlmdCksIGVyYXNlc2l6ZSk7CisJCQltZW1jcHkob29iICsgZ19vb2JfemZ0bF9vZmZzZXQsKHVpbnQ4X3QgKikmemZ0bF9vb2Isc2l6ZW9mKHN0cnVjdCB6ZnRsX29vYikpOworICAgICAKKyAgICAgICAgICAgIGlmKCB6ZnRsX3dyaXRlX2Jsb2NrKG5hbmQsIChsb2ZmX3QpKChmaXJzdEJsb2NrICsgYmxvY2tfbmV3KSA8PCBlcmFzZXNpemVfc2hpZnQpLCAmcmV0bGVuLAorICAgICAgICAgICAgICAgICAgICAodWludDhfdCAqKW9vYiwgYmxvY2tidWYpICkKKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICAvKiDQtMr9vt3Kp7DcyrGjrLHqvMdCQlSjrLj80MIgVEFCTEWjrNbY0MKy6dXS0MK1xL/p0LQgKi8KKyAgICAgICAgICAgICAgICBwcmludGsoIiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAtRVJST1ItXG4iKTsKKyAgICAgICAgICAgICAgICB6ZnRsLT5ibG9ja1RhYmxlW2Jsb2NrX25ld10gPSBCTE9DS19CQUQ7CisgICAgICAgICAgICAgICAgbmFuZC0+X2Jsb2NrX21hcmtiYWQobmFuZCwgKGxvZmZfdCkoKGZpcnN0QmxvY2sgKyBibG9ja19uZXcpIDw8IGVyYXNlc2l6ZV9zaGlmdCkpOyAgICAgICAgICAgICAgIAorICAgICAgICAgICAgICAgIGdvdG8gZmluZF9uZXh0X2ZyZWV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ICAgCisgICAgICAgICAgICAgICAgICAgIC8qILLBs/3Kp7Dco6yx6rzHzqq7tb/sICovCisgICAgICAgICAgICAgICAgICAgIHpmdGxfZGVidWcoIiAgICBbemZ0bF93cml0ZV0gZXJhc2VibG9jayB6ZnRsLT5ibG9ja1RhYmxlWy0lZC1dICBFUlJPUiFcbiIsIAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoZmlyc3RCbG9jayArIG9mZnNldF9ibG9ja19waHkpIDw8IGVyYXNlc2l6ZSk7CisgICAgICAgICAgICAgICAgICAgIHpmdGwtPmJsb2NrVGFibGVbb2Zmc2V0X2Jsb2NrX3BoeV0gPSBCTE9DS19CQUQ7CisgICAgICAgICAgICAgICAgICAgIG5hbmQtPl9ibG9ja19tYXJrYmFkKG5hbmQsIChsb2ZmX3QpKChmaXJzdEJsb2NrICsgb2Zmc2V0X2Jsb2NrX3BoeSkgPDwgZXJhc2VzaXplX3NoaWZ0KSk7IC8qILHqvMe7tb/po6y4/NDCu7W/6bHtICovCisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGVsc2UKKyAgICAgICAgICAgICAgICAgICAgemZ0bC0+YmxvY2tUYWJsZVtvZmZzZXRfYmxvY2tfcGh5XSA9IEJMT0NLX0ZSRUU7CisgICAgICAgICAgICB9CisgICAgICAgICAgICB6ZnRsX2RlYnVnKCJcbiIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCisgICAgICAgICAgICBsZWZ0X3RvX3dyaXRlICAtPSB3cml0ZV9sZW5ndGg7CisJCSAgICBvZmZzZXQgICAgICAgICArPSB3cml0ZV9sZW5ndGg7CisJCSAgICBidWZmZXIgICAgICAgICArPSB3cml0ZV9sZW5ndGg7CisgICAgICAgIH0KKyAgICAgICAgZWxzZSAvKiB6ZnRsLT5ibG9ja1JlcFRhYmxlW2Jsb2NrX2xvZ10gPT0gQkxPQ0tfTklMICovCisgICAgICAgIHsKKyAgICAgICAgICAgIC8qILTLwt+8rbXY1re12tK7tM6xu9C0yOvK/b7dICovCisgICAgICAgICAgICB6ZnRsX2RlYnVnKCIgICAgW3pmdGxfd3JpdGVdICB6ZnRsLT5ibG9ja1JlcFRhYmxlWyVkXSA9PSBCTE9DS19OSUxcbiIsIGJsb2NrX2xvZyk7ICAgICAgICAgCisgICAgICAgICAgICAKKwkJCS8qILKiuPzQwk9PQiAqLworICAgICAgICAgICAgemZ0bF9vb2IubG9naWNCbG9ja0lEID0gYmxvY2tfbG9nOworICAgICAgICAgICAgemZ0bF9vb2IudXNlZCA9IDB4MTsKKyAgICAgICAgICAgIHpmdGxfb29iLnZlcnNpb24gPSAweDE7CisgICAgICAgICAgICBtZW1jcHkoemZ0bF9vb2IuaGVhZCwgQ09ORklHX1pGTFRfSEVBRCwgQ09ORklHX1pGTFRfSEVBRF9CWVRFKTsgICAvKiC/vbG0emZ0bM23ICovIAorCisgICAgICAgICAgICAvKiDM7rPkuPzQwiBkYXRhICovCisgICAgICAgICAgICBpZiAobGVmdF90b193cml0ZSA8IChlcmFzZXNpemUgLSBibG9ja19vZmZzZXQpKQorCQkJICAgIHdyaXRlX2xlbmd0aCA9IGxlZnRfdG9fd3JpdGU7CisJCSAgICBlbHNlCisJCQkgICAgd3JpdGVfbGVuZ3RoID0gbmFuZC0+ZXJhc2VzaXplIC0gYmxvY2tfb2Zmc2V0OworCisgICAgICAgICAgICBtZW1jcHkoYmxvY2tidWYgKyBibG9ja19vZmZzZXQsIGJ1ZmZlciwgd3JpdGVfbGVuZ3RoKTsKKyAgICAgICAgICAgIHpmdGxfZGVidWcoIiAgICBbemZ0bF93cml0ZV0gIHVwZGF0ZSB0aGUgZGF0ZSAoIC0weCUweC0sIC0weCUweC0gKVxuIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBibG9ja19vZmZzZXQsIHdyaXRlX2xlbmd0aCk7CisgICAgICAgICAgICAKKyAgICAgICAgICAgIC8qINGw1dLSu7j2IEZSRUUgtcTO78Dtv+kgKi8KKyAgICAgICAgICAgIGZpbmRfbmV4dF9mcmVlX2Jsb2NrXzI6CisgICAgICAgICAgICBpZiggemZ0bF9maW5kX2ZyZWVfYmxvY2soemZ0bCwgJmJsb2NrX25ldykgKQorICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIC8qIMO709DV0rW9RlJFRb/pICovCisgICAgICAgICAgICAgICAgcHJpbnRrKCIgICAgW3pmdGxfd3JpdGVdIHRoZXJlIGlzIGVub3VnaCBibG9jaywgcGxlYXNlIGVubGFyZ2UgdGhlIHBhcnRpdGlvblxuIik7CisgICAgICAgICAgICAgICAgcmV0dXJuIENBTl9OT1RfRklORF9GUkVFX0JMT0NLOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICAvKiDQtMjr0ru/6SAqLworICAgICAgICAgICAgemZ0bF9kZWJ1ZygiICAgIFt6ZnRsX3dyaXRlX2Jsb2NrXSAgbmFuZC0+d3JpdGUoIC0weCUweC0sIC0weCUweC0pXG4iLCAKKyAgICAgICAgICAgICAgICAgICAgICAgICgoZmlyc3RCbG9jayArIGJsb2NrX25ldykgPDwgZXJhc2VzaXplX3NoaWZ0KSwgZXJhc2VzaXplKTsKKwkJCW1lbWNweShvb2IgKyBnX29vYl96ZnRsX29mZnNldCwodWludDhfdCAqKSZ6ZnRsX29vYixzaXplb2Yoc3RydWN0IHpmdGxfb29iKSk7CisgICAgICAgICAgICAKKyAgICAgICAgICAgIGlmKCB6ZnRsX3dyaXRlX2Jsb2NrKG5hbmQsIChsb2ZmX3QpKChmaXJzdEJsb2NrICsgYmxvY2tfbmV3KSA8PCBlcmFzZXNpemVfc2hpZnQpLCAmcmV0bGVuLAorICAgICAgICAgICAgICAgICAgICAodWludDhfdCAqKW9vYiwgYmxvY2tidWYpICkKKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICAvKiDQtMr9vt3Kp7DcyrGjrLHqvMdCQlSjrLj80MIgVEFCTEWjrNbY0MKy6dXS0MK1xL/p0LQgKi8KKyAgICAgICAgICAgICAgICBwcmludGsoIiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC1FUlJPUi1cbiIpOworICAgICAgICAgICAgICAgIHpmdGwtPmJsb2NrVGFibGVbYmxvY2tfbmV3XSA9IEJMT0NLX0JBRDsKKyAgICAgICAgICAgICAgICBuYW5kLT5fYmxvY2tfbWFya2JhZChuYW5kLCAobG9mZl90KSgoZmlyc3RCbG9jayArIGJsb2NrX25ldykgPDwgZXJhc2VzaXplX3NoaWZ0KSk7ICAgICAgICAgCisgICAgICAgICAgICAgICAgZ290byBmaW5kX25leHRfZnJlZV9ibG9ja18yOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICAvKiC4/NDCIGJsb2NrUmVwVGFibGWhomJsb2NrVGFibGUgKi8KKyAgICAgICAgICAgIHpmdGwtPmJsb2NrUmVwVGFibGVbemZ0bF9vb2IubG9naWNCbG9ja0lEXSA9IGJsb2NrX25ldzsKKworCQkJemZ0bF9kZWJ1ZygiICAgIFt6ZnRsX3dyaXRlMl0gIHpmdGwtPmJsb2NrUmVwVGFibGVbb29iLT5sb2dpY0Jsb2NrSURdID0gJWQsb29iLT5sb2dpY0Jsb2NrSUQgPSAlZFxuIiwgemZ0bC0+YmxvY2tSZXBUYWJsZVt6ZnRsX29vYi5sb2dpY0Jsb2NrSURdLCB6ZnRsX29vYi5sb2dpY0Jsb2NrSUQpOworCQkJCisgICAgICAgICAgICB6ZnRsLT5ibG9ja1RhYmxlW2Jsb2NrX25ld10gPSBCTE9DS19VU0VEOworCisgICAgICAgICAgICB6ZnRsX2RlYnVnKCJcbiIpOworICAgICAgICAgICAgCisgICAgICAgICAgICBsZWZ0X3RvX3dyaXRlIC09IHdyaXRlX2xlbmd0aDsKKwkJICAgIG9mZnNldCAgICAgICAgKz0gd3JpdGVfbGVuZ3RoOworCQkgICAgYnVmZmVyICAgICAgICArPSB3cml0ZV9sZW5ndGg7CisgICAgICAg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KyAgICAgICAgYmxvY2tfbG9nID0gb2Zmc2V0ID4+IHpmdGwtPmVyYXNlc2l6ZV9zaGlmdDsgCisgICAgICAgIAorICAgICAgICAvKiC78cihwt+8rb/pttTTprXEzu/A7b/pICovCisgICAgICAgIGlmKCB6ZnRsLT5ibG9ja1JlcFRhYmxlW2Jsb2NrX2xvZ10gIT0gQkxPQ0tfTklMICkKKyAgICAgICAgICAgIG9mZnNldF9ibG9ja19waHkgPSB6ZnRsLT5ibG9ja1JlcFRhYmxlW2Jsb2NrX2xvZ107CisgICAgICAgIGVsc2UgCisgICAgICAgIHsgICAKKyAgICAgICAgICAgIC8qILWxw7vT0NC0yOvK/b7dyrGjrMO709DTs8nkudjPtaOstsHIocr9vt3Iq86qIDBYRkYgKi8KKyAgICAgICAgICAgIAorICAgICAgICAgICAgaWYgKGxlZnRfdG9fcmVhZCA8IChlcmFzZXNpemUgLSBibG9ja19vZmZzZXQpKQorCQkJICAgIHJlYWRfbGVuZ3RoID0gbGVmdF90b19yZWFkOworCQkgICAgZWxzZQorCQkJICAgIHJlYWRfbGVuZ3RoID0gbmFuZC0+ZXJhc2VzaXplIC0gYmxvY2tfb2Zmc2V0OworICAgICAgICAgICAgCisgICAgICAgICAgICBtZW1zZXQoYnVmLCAweGZmLCByZWFkX2xlbmd0aCk7CisgICAgICAgICAgICAKKyAgICAgICAgICAgIGxlZnRfdG9fcmVhZCAtPSByZWFkX2xlbmd0aDsKKwkJICAgIG9mZnNldCAgICAgICArPSByZWFkX2xlbmd0aDsKKwkJICAgIGJ1ZiAgICAgICAgICArPSByZWFkX2xlbmd0aDsKKworICAgICAgICAgICAgY29udGludWU7CisgICAgICAgICAgICAKKyAgICAgICAgfQorICAgICAgICAgICAgCisgICAgICAgIGlmIChsZWZ0X3RvX3JlYWQgPCAoZXJhc2VzaXplIC0gYmxvY2tfb2Zmc2V0KSkKKwkJCXJlYWRfbGVuZ3RoID0gbGVmdF90b19yZWFkOworCQllbHNlCisJCQlyZWFkX2xlbmd0aCA9IG5hbmQtPmVyYXNlc2l6ZSAtIGJsb2NrX29mZnNldDsKKyAgICAgICAgCisKKyAgICAgICAgemZ0bF9kZWJ1ZygiICAgIFt6ZnRsX3JlYWRdICBuYW5kLT5yZWFkKCAtMHglMHgtLCAtMHglMHgtKVxuIiwgCisgICAgICAgICAgICAgICAgICAgICAgICAoKGZpcnN0QmxvY2sgKyBvZmZzZXRfYmxvY2tfcGh5KSA8PCBlcmFzZXNpemVfc2hpZnQpICsgYmxvY2tfb2Zmc2V0LAorICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRfbGVuZ3RoKTsKKyAgICAgICAgcmV0ID0gbmFuZC0+X3JlYWQobmFuZCwgKChmaXJzdEJsb2NrICsgb2Zmc2V0X2Jsb2NrX3BoeSkgPDwgZXJhc2VzaXplX3NoaWZ0KSArIGJsb2NrX29mZnNldCwgCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRfbGVuZ3RoLCAmcmV0bGVuLCBidWYpOworICAgICAgICBpZiAocmV0IHx8IHJldGxlbiAhPSByZWFkX2xlbmd0aCkKKyAgICAgICAgeworICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0VSUiJbemZsdGxdOiAtemZ0bF9yZWFkLSBlcnJvclxuIik7CisJCSAgICAgICAgLy9yZXR1cm4gLTE7CisjaWZkZWYgQ09ORklHX01URF9OVlJFU1VNRQorICAgIAkJICAgIGlmKCghek9zc19OdkluUmVzdW1lKCkpJiYoemZ0bD09emZ0bF9pbmZvWzFdKSYmKHpmdGxfcmVzICE9IDEpKQorCQkJICAgIHsKKwkJCQkJcmV0dXJuIC0xOworCQkJICAgIH0KKyNlbmRpZgorICAgICAgICB9CisKKyAgICAgICAgbGVmdF90b19yZWFkIC09IHJlYWRfbGVuZ3RoOworCQlvZmZzZXQgICAgICAgKz0gcmVhZF9sZW5ndGg7CisJCWJ1ZiAgICAgICAgICArPSByZWFkX2xlbmd0aDsKKyAgICB9CisgICAgICAgIAorICAgIHpmdGxfZGVidWcoIlxuIik7CisJcmV0dXJuIDA7Cit9CisKKworc3RydWN0IFpGVExyZWNvcmQgICogemZ0bF9nZXRfWkZUTHJlY29yZF9ieW5hbWUoY2hhciogcGFydF9uYW1lKQoreworICAgIHVpbnQzMl90IGk7CisKKyAgICBmb3IoaSA9IDA7IHpmdGxfcGFydGl0aW9uX25hbWVbaV0gIT0gTlVMTDsgaSsrICkKKyAgICB7CisgICAgICAgIGlmKHpmdGxfaW5mb1tpXSE9TlVMTCkKKyAgICAJeworCQkJaWYoc3RyY21wKHpmdGxfaW5mb1tpXS0+bWJkLm10ZC0+bmFtZSwgcGFydF9uYW1lKSA9PSAwKQorCQkJeworCQkJCXJldHVybiB6ZnRsX2luZm9baV07ICAgICAgICAgICAKKwkJCX0KKyAgICAJfQorICAgICAgICAKKyAgICB9CisgICAgcmV0dXJuIE5VTEw7Cit9CisKKworaW50IHpmdGxfaW5pdCh1bnNpZ25lZCBjaGFyICpwYXJ0X25hbWUsc3RydWN0IFpGVExyZWNvcmQgKnpmdGxpbmZvICkKK3sgIAorICAgIG5hbmRfaW5mb190ICAqbmFuZCA9IG10ZF9mb3RhOworICAgIC8vdWludDMyX3QgaSwgaixrLCBibG9jazsKKyAgICB1aW50MzJfdCBrID0gMDsKKyAgICBzdHJ1Y3QgWkZUTHJlY29yZCAqemZ0bCA9IE5VTEw7CisgICAgdWludDMyX3QgcGFydGl0aW9uX3NpemUgPSAwOworICAgIHVpbnQzMl90IHBhcnRpdGlvbl9vZmZlc3QgPSAwOworICAgIHN0cnVjdCBjbWRsaW5lX210ZF9wYXJ0aXRpb24gKnBhcnQ7CisgICAgCisJcHJpbnRrKCAiemZ0bFslZF0gaXMgJXNcbiIscGFydG51bSxwYXJ0X25hbWUpOworICAgICAgICAgICAKKyAgICAgLyogWkZUTHJlY29yZL3hubnM5cTatObJ6sfrICovICAKKyAgICAJemZ0bF9pbmZvW3BhcnRudW1dID0gemZ0bGluZm87CisgICAgCWlmICghemZ0bF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0YXJ0IDwgbnZyb19wYXJ0c2l6ZSApCisgICAgeworICAgICAgICB6ZnRsID0gemZ0bF9nZXRfWkZUTHJlY29yZF9ieW5hbWUoIm52cm8iKTsgICAgLypOVlIsMH4xTSovICAgICAgCisgICAgfQorICAgIGVsc2UgCisgICAgeworICAgICAgICB6ZnRsID0gemZ0bF9nZXRfWkZUTHJlY29yZF9ieW5hbWUoIm52cnciKTsgICAgLyogTlZSVywgMX41TSovIAorICAgICAgICBkd1N0YXJ0IC09IG52cm9fcGFydHNpemU7CisgICAgfQorCWlmKCF6ZnRsKQorCXsJCisJCW11dGV4X3VubG9jaygmemZ0bF9tdXRleCk7CisJCXJldHVybiAtMjsKKwl9CisJcmV0ID0gemZ0bF9yZWFkKHpmdGwsICh1aW50MzJfdClkd1N0YXJ0LCAodWludDMyX3QpZHdMZW4sICh1X2NoYXIqKXRvKTsKKwltdXRleF91bmxvY2soJnpmdGxfbXV0ZXgpOworI2lmZGVmIENPTkZJR19NVERfTlZSRVNVTUUJCisJaWYocmV0ID09IC0xKQorCXsKKwkJemZ0bF9yZXMgPSAxOworCQl6T3NzX052U2V0RXJyb3JBZGRyKGR3U3RhcnQgKyBudnJvX3BhcnRzaXplKTsKKwkJaGFsX0NvbW1fU29mdF9SZXNldChSRVNFVF9UT19OT1JNQUwpOworCX0KKyNlbmRpZgorCXJldHVybiByZXQ7CisKK30KK0VYUE9SVF9TWU1CT0xfR1BMKG5hbmRfTnZSZWFkKTsKKworaW50IG5hbmRfTnZQcm9ncmFtKGludCBkd1N0YXJ0LCBpbnQgZHdMZW4sIGNoYXIqIGZyb20pCit7CisgICAJbXV0ZXhfbG9jaygmemZ0bF9tdXRleCk7CisgICAgc3RydWN0IFpGVExyZWNvcmQgKnpmdGwgPSBOVUxMOworCWludCByZXQgPSAwOworCisgICAgaWYoIGR3U3RhcnQgPCBudnJvX3BhcnRzaXplICkKKyAgICB7CisgICAgICAgIHpmdGwgPSB6ZnRsX2dldF9aRlRMcmVjb3JkX2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gIGFkZHIgPSAoZmlyc3RfYmxvY2sgKyBpbmRleCkgKiBlcmFzZXNpemU7CisgICAgICAgIGlmKG5hbmQtPl9ibG9ja19pc2JhZChuYW5kLCAobG9mZl90KWFkZHIpKQorICAgICAgICB7CisgICAgICAgICAgICB6ZnRsLT5ibG9ja1RhYmxlW2luZGV4XSA9IEJMT0NLX0JBRDsKKyAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICB9CisKKyAgICAgICAgLyog0LS/6bXEy7PQ8s6qIM/I0LS12rb+0rO/qsq8tb3X7rrz0rvSs6Os1NnQtLXa0rvSsyAqLworICAgICAgICAvKiAgICAgILXa0rvSs29vYiAgICC12rb+0rNvb2IgICC/6de0zKwgICAgICAgICAgICAgICAgICAgICDLtcP3ICAgICovCisgICAgICAgICAgICAvKiAgIDB4ZmYgICAgICAgICAweGZmICAgIEJMT0NLX0ZSRUUgICAgICAgICAgICAgtrzDu9PQv6rKvNC0ICovCisgICAgICAgICAgICAvKiAgIDB4ZmYgICAgICAgICAtLS0tICAgIEJMT0NLX0RJUlRZICAgICAgICAgICAgv6rKvNC0o6y1q8O709DQtM3qtdrSu9Kzo6zW0LzksbvW0LbPICovCisgICAgICAgICAgICAvKiAgIC0tLS0gICAgICAgICAweGZmICAgIEJMT0NLX1VTRUQvRElSVFkgICAgICAg0LTN6rXa0rvSs6Oszeqzyb/p0LTI6yAqLworICAgICAgICAgICAgLyogICAtLS0tICAgICAgICAgLS0tLSAgICBCTE9DS19VU0VEL0RJUlRZICAgICAgINC0zeq12tK70rOjrM3qs8m/6dC0yOsgKi8KKyAgICAgICAgIAorICAgICAgICBpZih6ZnRsX3JlYWRfb29iKHpmdGwsIGFkZHIsICh1aW50OF90ICopb29iICkpLyogtsHIobXa0rvSsyAqLworICAgICAgICB7CisgICAgICAgICAgICAgcHJpbnRrKCJbemZ0bF9zZXR1cF90YWJsZV0gcmVhZCBvb2IgZXJyb3IgYXQgPSAweCUwOHhcbiIsIGFkZHIpOworICAgICAgICAgICAgIHJldHVybiBOQU5EX1JFQURfV1JJVEVfRVJST1I7CisgICAgICAgIH0KKyAgICAgICAgCisgICAgICAgIGlmKG1lbWNtcGIob29iLCAweGZmLCBvb2JzaXplKSkgICAgIC8qICC12tK70rNvb2IgIT0gMHhmZiAqLworICAgICAgICB7CisgICAgICAgICAgICAvL2lmKCBvb2IudXNlZCA9PSAxICkgICAvKiBibG9jayBpcyB1c2VkICovCisgICAgICAgICAgICBpZiggIW1lbWNtcChvb2ItPmhlYWQsIENPTkZJR19aRkxUX0hFQUQsIENPTkZJR19aRkxUX0hFQURfQllURSkgKSAgIC8qILD8uqzT0LfWx/jNtyAqLworICAgICAgICAgICAgeworICAgICAgICAgICAgICAgICppc193cml0ZWQgKz0gMTsKKyAgICAgICAgICAgICAgICBpZiggb29iLT52ZXJzaW9uID4gemZ0bC0+dmVyc2lvblRhYmxlW29vYi0+bG9naWNCbG9ja0lEXSkgCisgICAgICAgICAgICAgICAgeworICAgICAgICAgICAgICAgICAgICAvKiB2ZXJzaW9uIGlzIG5ld2VyICovCisgICAgICAgICAgICAgICAgICAgIGlmKHpmdGwtPnZlcnNpb25UYWJsZVtvb2ItPmxvZ2ljQmxvY2tJRF0gIT0gMCkgIC8qINLRvq3T0LbU06a1xHVzZWS/6cHLICovCisgICAgICAgICAgICAgICAgICAgICAgICB6ZnRsLT5ibG9ja1RhYmxlW3pmdGwtPmJsb2NrUmVwVGFibGVbb29iLT5sb2dpY0Jsb2NrSURdXSA9IEJMT0NLX0RJUlRZOworCisgICAgICAgICAgICAgICAgICAgIHpmdGwtPmJsb2NrUmVwVGFibGVbb29iLT5sb2dpY0Jsb2NrSURdID0gaW5kZXg7CisgICAgICAgICAgICAgICAgICAgIHpmdGwtPnZlcnNpb25UYWJsZVtvb2ItPmxvZ2ljQmxvY2tJRF0gPSBvb2ItPnZlcnNpb247CisgICAgICAgICAgICAgICAgICAgIHpmdGwtPmJsb2NrVGFibGVbaW5kZXhdID0gQkxPQ0tfVVNFRDsKKwkJCQkJLyogQWRkZWQgYnkgemhvdXFpIGZvciB4eHgsIDIwMTQvMDQvMjMgKi8KKyAgICAgICAgICAgICAgICAgICAgemZ0bC0+bGFzdEZyZWVCbG9jayA9IGluZGV4ICsgMTsgCisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGVsc2UKKyAgICAgICAgICAgICAgICAgICAgemZ0bC0+YmxvY2tUYWJsZVtpbmRleF0gPSBCTE9DS19ESVJUWTsgICAgICAgICAgICAgIAorICAgICAgICAgICAgfQorICAgICAgICAgICAgZWxzZQorICAgICAgICAgICAgICAgIHpmdGwtPmJsb2NrVGFibGVbaW5kZXhdID0gQkxPQ0tfRElSVFk7IAorICAgICAgICB9CisgICAgICAgIGVsc2UgICAgLyogMHhmZqOsYmxvY2sgaXMgZnJlZSAqLworICAgICAgICB7CisgICAgICAgICAgICBpZih6ZnRsX3JlYWRfb29iKHpmdGwsIGFkZHIgKyB6ZnRsLT53cml0ZXNpemUsICh1aW50OF90ICopb29iICkpLyogtsHIobXatv7SsyAqLworICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIHByaW50aygiW3pmdGxfc2V0dXBfdGFibGVdIHJlYWQgb29iIGVycm9yIGF0ID0gMHglMDh4XG4iLCBhZGRyKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gTkFORF9SRUFEX1dSSVRFX0VSUk9SOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBpZihtZW1jbXBiKG9vYiwgMHhmZiwgb29ic2l6ZSkpICAgICAvKiAgtdq2/tKzb29iICE9IDB4ZmYgKi8KKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICB6ZnRsLT5ibG9ja1RhYmxlW2luZGV4XSA9IEJMT0NLX0RJUlRZOworICAgICAgICAgICAgfQorICAgICAgICAgICAgZWxzZSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogILXatv7Ss29vYiA9IDB4ZmYgKi8KKyAgICAgICAgICAgICAgICB6ZnRs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AwOworICAgIG5hbmRfaW5mb190ICAqbmFuZCA9IHpmdGwtPm5hbmQ7CisKKyAgICB6ZnRsX2RlYnVnKCJcbiIpOworICAgIAorICAgIGZvciggaW5kZXggPSAwOyBpbmRleCA8IGJsb2NrX251bTsgaW5kZXgrKyApCisgICAgeworICAgICAgICBpZiggemZ0bC0+YmxvY2tUYWJsZVtpbmRleF0gPT0gQkxPQ0tfRElSVFkgKQorICAgICAgICB7CisgICAgICAgICAgICB6ZnRsX2RlYnVnKCIgICAgW3pmdGxfZ2FyYmFnZV9jb2xsZWN0XSBlcmFzZWJsb2NrIHpmdGwtPmJsb2NrVGFibGVbLSVkLV1cbiIsIGluZGV4KTsKKyAgICAgICAgICAgIGlmKCB6ZnRsX2VyYXNlX2Jsb2NrKG5hbmQsIGZpcnN0QmxvY2sgKyBpbmRleCkgKQorICAgICAgICAgICAgeyAgIAorICAgICAgICAgICAgICAgIC8qILLBs/3Kp7Dco6yx6rzHzqq7tb/sICovCisgICAgICAgICAgICAgICAgemZ0bF9kZWJ1ZygiICAgIFt6ZnRsX2dhcmJhZ2VfY29sbGVjdF0gZXJhc2VibG9jayB6ZnRsLT5ibG9ja1RhYmxlWy0lZC1dIEVSUk9SXG4iLCBpbmRleCk7CisgICAgICAgICAgICAgICAgemZ0bC0+YmxvY2tUYWJsZVtpbmRleF0gPSBCTE9DS19CQUQ7CisgICAgICAgICAgICAgICAgLyogseq8x7u1v+mjrLj80MK7tb/pse0gbXRkLT5lcmFzZSDW0KOs0tSw/LqsssGz/cqnsNy4/NDCQkJUKi8KKyAgICAgICAgICAgICAgICBuYW5kLT5fYmxvY2tfbWFya2JhZChuYW5kLCAobG9mZl90KSgoZmlyc3RCbG9jayArIGluZGV4KSA8PCB6ZnRsLT5lcmFzZXNpemVfc2hpZnQpKTsgCisgICAgICAgICAgICB9CisgICAgICAgICAgICBlbHNlCisgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgLyogssGz/bPJuaYgKi8KKyAgICAgICAgICAg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ZXNpemU7CisgICAgdWludDMyX3QgaXNfdXB0aHJlc2hvbGQgPSAwOworICAgIHVpbnQzMl90IG9vYl9zaXplID0gemZ0bC0+b29ic2l6ZTsKKyAgICB1aW50MzJfdCBmaXJzdEJsb2NrID0gemZ0bC0+Zmlyc3RCbG9jazsKKyAgICB1X2NoYXIgKmJsb2NrYnVmID0gemZ0bC0+YmxvY2tidWY7CisKKyAgICB1aW50MzJfdCBsZWZ0X3RvX3dyaXRlID0gbGVuOworICAgIHVpbnQzMl90IHdyaXRlX2xlbmd0aCA9IDA7CisgICAgdWludDMyX3Qgb2Zmc2V0ID0gdG87CisgICAgCisgICAgbmFuZF9pbmZvX3QgICpuYW5kID0gemZ0bC0+bmFuZDsKKwkKKwlpZigoemZ0bCA9PSBOVUxMKSB8fCAoYnVmID09IE5VTEwpKQorCXsKKwkJQlVHKCk7CisJfQorCisgICAgd2hpbGUobGVmdF90b193cml0ZSA+IDApCisgICAgeworICAgICAgICAvKiC/1bzko6yz9cq8u6/OqiAweEZGICovCisgICAgICAgIG1lbXNldChibG9ja2J1ZiwgMHhmZiwgZXJhc2VzaXplKTsKKyAgICAgICAgbWVtc2V0KG9vYiwgMHhmZiwgb29iX3NpemUpOworICAgICAgIAorICAgICAgICAvKiC78cihwt+8rb/po6y8sL/pxNrGq9LGICovCisgICAgICAgIGJsb2NrX2xvZyA9IG9mZnNldCA+PiAoemZ0bC0+ZXJhc2VzaXplX3NoaWZ0KTsgICAgICAgICAgICAgICAKKyAgICAgICAgYmxvY2tfb2Zmc2V0ID0gb2Zmc2V0ICYgKHpmdGwtPmVyYXNlc2l6ZSAtIDEpOyAgLyogv+nE2rXExqvSxrXY1rcgKi8KKworICAgICAgICAvKiDF0LbPwt+8rb/pyse38dPQzu/A7bbU06a/6aOsyOe5+9PQo6zU8s6quMTQtMr9vt2ju8jnufvDu9PQo6zU8s6qtdrSu7TO0LS0y7/pICovCisgICAgICAgIGlmKHpmdGwtPmJsb2NrUmVwVGFibGVbYmxvY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kJCSAgICB9CisjZW5kaWYKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgLyogtsHIodXi0ru/6bXET09C0MXPoqOssqK4/NDCIFZFUlNJT04sIMjnufu077W9sOaxvrrFtcTj0Na1o6zU8r340NC72MrVICovCisgICAgICAgICAgICBpZih6ZnRsX3JlYWRfb29iKHpmdGwsICgoZmlyc3RCbG9jayArIG9mZnNldF9ibG9ja19waHkpIDw8IGVyYXNlc2l6ZV9zaGlmdCksICh1aW50OF90ICopb29iICkpCisgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgIHByaW50aygiICAgIFt6ZnRsX3dyaXRlXSByZWFkIG9vYiBlcnJvciBhdCA9IDB4JXhcbiIsIChvZmZzZXRfYmxvY2tfcGh5IDw8IGVyYXNlc2l6ZV9zaGlmdCkpOworICAgICAgICAgICAgICAgICAvL3JldHVybiAtMTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGlmKCBvb2ItPnZlcnNpb24gPT0gQ09ORklHX1pGTFRfVkVSU0lPTl9USFJFU0hPTEQgKQorICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIHpmdGxfZGVidWcoIiAgICBbemZ0bF93cml0ZV0gdXAgdG8gdGhlIC1DT05GSUdfWkZMVF9WRVJTSU9OX1RIUkVTSE9MRC1cbiIpOworICAgICAgICAgICAgICAgIGlzX3VwdGhyZXNob2xkID0gMTsKKyAgICAgICAgICAgICAgICB6ZnRsX2dhcmJhZ2VfY29sbGVjdCh6ZnRsKTsKKyAgICAgICAgICAgICAgICBvb2ItPnZlcnNpb24gPSAxOworICAgICAgICAgICAgfQorICAgICAgICAgICAgZWxzZQorICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIAorICAgICAgICAgICAgICAgIG9vYi0+dmVyc2lvbiArPSAxOworCQkJCXpmdGxfZGVidWcoIiAgICBbemZ0bF93cml0ZV0gIG9vYi0+dmVyc2lvbiA9ICVkLG9vYi0+bG9naWNCbG9ja0lEID0gJWRcbiIsIG9vYi0+dmVyc2lvbixvb2ItPmxvZ2ljQmxvY2tJRCk7CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIG1lbWNweShvb2ItPmhlYWQsIENPTkZJR19aRkxUX0hFQUQsIENPTkZJR19aRkxUX0hFQURfQllURSk7ICAgLyogv72xtHpmdGzNtyAqLyAKKyAgICAgICAgICAgIG9vYi0+bG9naWNCbG9ja0lEID0gYmxvY2tfbG9nOworCisgICAgICAgICAgICAvKiDM7rPkuPzQwiBkYXRhICovCisgICAgICAgICAgICBpZiAobGVmdF90b193cml0ZSA8IChlcmFzZXNpemUgLSBibG9ja19vZmZzZXQpKQorCQkJICAgIHdyaXRlX2xlbmd0aCA9IGxlZnRfdG9fd3JpdGU7CisJCSAgICBlbHNlCisJCQkgICAgd3JpdGVfbGVuZ3RoID0gbmFuZC0+ZXJhc2VzaXplIC0gYmxvY2tfb2Zmc2V0OworCisgICAgICAgICAgICBtZW1jcHkoYmxvY2tidWYgKyBibG9ja19vZmZzZXQsIGJ1ZmZlciwgd3JpdGVfbGVuZ3RoKTsKKyAgICAgICAgICAgIHpmdGxfZGVidWcoIiAgICBbemZ0bF93cml0ZV0gIHVwZGF0ZSB0aGUgZGF0ZSAoIC0weCUweC0sIC0weCUweC0gKVxuIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBibG9ja19vZmZzZXQsIHdyaXRlX2xlbmd0aCk7CisgICAgICAgICAgICAgICAgICAgICAgICAKKyAgICAgICAgICAgIAorICAgICAgICAgICAgLyog0bDV0tK7uPYgRlJFRSC1xM7vwO2/6SAqLworICAgICAgICAgICAgZmluZF9uZXh0X2ZyZWVfYmxvY2tfMToKKyAgICAgICAgICAgIGlmKCB6ZnRsX2ZpbmRfZnJlZV9ibG9jayh6ZnRsLCAmYmxvY2tfbmV3KSApLyogQkxPQ0tfVVNFRCAqLworICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIC8qIMO709DV0rW9RlJFRb/pICovCisgICAgICAgICAgICAgICAgcHJpbnRrKCIgICAgW3pmdGxfd3JpdGVdIHRoZXJlIGlzIGVub3VnaCBibG9jaywgcGxlYXNlIGVubGFyZ2UgdGhlIHBhcnRpdGlvblxuIik7CisgICAgICAgICAgICAgICAgcmV0dXJuIENBTl9OT1RfRklORF9GUkVFX0JMT0NLOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICAvKiDQtMjr0ru/6SAqLworICAgICAgICAgICAgemZ0bF9kZWJ1ZygiICAgIFt6ZnRsX3dyaXRlX2Jsb2NrXSAgbmFuZC0+d3JpdGUoIC0weCUweC0sIC0weCUweC0pXG4iLCAKKyAgICAgICAgICAgICAgICAgICAgICAgICgoZmlyc3RCbG9jayArIGJsb2NrX25ldykgPDwgZXJhc2VzaXplX3NoaWZ0KSwgZXJhc2VzaXplKTsKKyAgICAgCisgICAgICAgICAgICBpZiggemZ0bF93cml0ZV9ibG9jayhuYW5kLCAobG9mZl90KSgoZmlyc3RCbG9jayArIGJsb2NrX25ldykgPDwgZXJhc2VzaXplX3NoaWZ0KSwgJnJldGxlbiwKKyAgICAgICAgICAgICAgICAgICAgb29iLCBibG9ja2J1ZikgKQorICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIC8qINC0yv2+3cqnsNzKsaOsseq8x0JCVKOsuPzQwiBUQUJMRaOs1tjQwrLp1dLQwrXEv+nQtCAqLworICAgICAgICAgICAgICAgIHByaW50aygiICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC1FUlJPUi1cbiIpOworICAgICAgICAgICAgICAgIHpmdGwtPmJsb2NrVGFibGVbYmxvY2tfbmV3XSA9IEJMT0NLX0JBRDsKKyAgICAgICAgICAgICAgICBuYW5kLT5fYmxvY2tfbWFya2JhZChuYW5kLCAobG9mZl90KSgoZmlyc3RCbG9jayArIGJsb2NrX25ldykgPDwgZXJhc2VzaXplX3NoaWZ0KSk7ICAgICAgICAgICAgICAgCisgICAgICAgICAgICAgICAg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gICAgICAgICAgeyAgIAorICAgICAgICAgICAgICAgICAgICAvKiCywbP9yqew3KOsseq8x86qu7W/7CAqLworICAgICAgICAgICAgICAgICAgICB6ZnRsX2RlYnVnKCIgICAgW3pmdGxfd3JpdGVdIGVyYXNlYmxvY2sgemZ0bC0+YmxvY2tUYWJsZVstJWQtXSAgRVJST1IhXG4iLCAKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGZpcnN0QmxvY2sgKyBvZmZzZXRfYmxvY2tfcGh5KSA8PCBlcmFzZXNpemUpOworICAgICAgICAgICAgICAgICAgICB6ZnRsLT5ibG9ja1RhYmxlW29mZnNldF9ibG9ja19waHldID0gQkxPQ0tfQkFEOworICAgICAgICAgICAgICAgICAgICBuYW5kLT5fYmxvY2tfbWFya2JhZChuYW5kLCAobG9mZl90KSgoZmlyc3RCbG9jayArIG9mZnNldF9ibG9ja19waHkpIDw8IGVyYXNlc2l6ZV9zaGlmdCkpOyAvKiCx6rzHu7W/6aOsuPzQwru1v+mx7SAqLworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBlbHNlCisgICAgICAgICAgICAgICAgICAgIHpmdGwtPmJsb2NrVGFibGVbb2Zmc2V0X2Jsb2NrX3BoeV0gPSBCTE9DS19GUkVFOworICAgICAgICAgICAgfQorICAgICAgICAgICAgemZ0bF9kZWJ1ZygiXG4iKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAorICAgICAgICAgICAgbGVmdF90b193cml0ZSAgLT0gd3JpdGVfbGVuZ3RoOworCQkgICAgb2Zmc2V0ICAgICAgICAgKz0gd3JpdGVfbGVuZ3RoOworCQkgICAgYnVmZmVyICAgICAgICAgKz0gd3JpdGVfbGVuZ3RoOworICAgICAgICB9CisgICAgICAgIGVsc2UgLyogemZ0bC0+YmxvY2tSZXBUYWJsZVtibG9ja19sb2ddID09IEJMT0NLX05JTCAqLworICAgICAgICB7CisgICAgICAgICAgICAvKiC0y8LfvK212Na3tdrSu7TOsbvQtMjryv2+3SAqLworICAgICAgICAgICAgemZ0bF9kZWJ1ZygiICAgIFt6ZnRsX3dyaXRlXSAgemZ0bC0+YmxvY2tSZXBUYWJsZVslZF0gPT0gQkxPQ0tfTklMXG4iLCBibG9ja19sb2cpOyAgICAgICAgIAorICAgICAgICAgICAgCisJCQkvKiCyorj80MJPT0IgKi8KKyAgICAgICAgICAgIG9vYi0+bG9naWNCbG9ja0lEID0gYmxvY2tfbG9nOworICAgICAgICAgICAgb29iLT51c2VkID0gMHgxOworICAgICAgICAgICAgb29iLT52ZXJzaW9uID0gMHgxOworICAgICAgICAgICAgbWVtY3B5KG9vYi0+aGVhZCwgQ09ORklHX1pGTFRfSEVBRCwgQ09ORklHX1pGTFRfSEVBRF9CWVRFKTsgICAvKiC/vbG0emZ0bM23ICovIAorCisgICAgICAgICAgICAvKiDM7rPkuPzQwiBkYXRhICovCisgICAgICAgICAgICBpZiAobGVmdF90b193cml0ZSA8IChlcmFzZXNpemUgLSBibG9ja19vZmZzZXQpKQorCQkJICAgIHdyaXRlX2xlbmd0aCA9IGxlZnRfdG9fd3JpdGU7CisJCSAgICBlbHNlCisJCQkgICAgd3JpdGVfbGVuZ3RoID0gbmFuZC0+ZXJhc2VzaXplIC0gYmxvY2tfb2Zmc2V0OworCisgICAgICAgICAgICBtZW1jcHkoYmxvY2tidWYgKyBibG9ja19vZmZzZXQsIGJ1ZmZlciwgd3JpdGVfbGVuZ3RoKTsKKyAgICAgICAgICAgIHpmdGxfZGVidWcoIiAgICBbemZ0bF93cml0ZV0gIHVwZGF0ZSB0aGUgZGF0ZSAoIC0weCUweC0sIC0weCUweC0gKVxuIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBibG9ja19vZmZzZXQsIHdyaXRlX2xlbmd0aCk7CisgICAgICAgICAgICAKKyAgICAgICAgICAgIC8qINGw1dLSu7j2IEZSRUUgtcTO78Dtv+kgKi8KKyAgICAgICAgICAgIGZpbmRfbmV4dF9mcmVlX2Jsb2NrXzI6CisgICAgICAgICAgICBpZiggemZ0bF9maW5kX2ZyZWVfYmxvY2soemZ0bCwgJmJsb2NrX25ldykgKQorICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIC8qIMO709DV0rW9RlJFRb/pICovCisgICAgICAgICAgICAgICAgcHJpbnRrKCIgICAgW3pmdGxfd3JpdGVdIHRoZXJlIGlzIGVub3VnaCBibG9jaywgcGxlYXNlIGVubGFyZ2UgdGhlIHBhcnRpdGlvblxuIik7CisgICAgICAgICAgICAgICAgcmV0dXJuIENBTl9OT1RfRklORF9GUkVFX0JMT0NLOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICAvKiDQtMjr0ru/6SAqLworICAgICAgICAgICAgemZ0bF9kZWJ1ZygiICAgIFt6ZnRsX3dyaXRlX2Jsb2NrXSAgbmFuZC0+d3JpdGUoIC0weCUweC0sIC0weCUweC0pXG4iLCAKKyAgICAgICAgICAgICAgICAgICAgICAgICgoZmlyc3RCbG9jayArIGJsb2NrX25ldykgPDwgZXJhc2VzaXplX3NoaWZ0KSwgZXJhc2VzaXplKTsKKyAgICAgICAgICAgIAorICAgICAgICAgICAgaWYoIHpmdGxfd3JpdGVfYmxvY2sobmFuZCwgKGxvZmZfdCkoKGZpcnN0QmxvY2sgKyBibG9ja19uZXcpIDw8IGVyYXNlc2l6ZV9zaGlmdCksICZyZXRsZW4sCisgICAgICAgICAgICAgICAgICAgIG9vYiwgYmxvY2tidWYpICkKKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICAvKiDQtMr9vt3Kp7DcyrGjrLHqvMdCQlSjrLj80MIgVEFCTEWjrNbY0MKy6dXS0MK1xL/p0LQgKi8KKyAgICAgICAgICAgICAgICBwcmludGsoIiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC1FUlJPUi1cbiIpOworICAgICAgICAgICAgICAgIHpmdGwtPmJsb2NrVGFibGVbY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CB6ZnRsLT5ibG9ja1JlcFRhYmxlW2Jsb2NrX2xvZ10gIT0gQkxPQ0tfTklMICkKKyAgICAgICAgICAgIG9mZnNldF9ibG9ja19waHkgPSB6ZnRsLT5ibG9ja1JlcFRhYmxlW2Jsb2NrX2xvZ107CisgICAgICAgIGVsc2UgCisgICAgICAgIHsgICAKKyAgICAgICAgICAgIC8qILWxw7vT0NC0yOvK/b7dyrGjrMO709DTs8nkudjPtaOstsHIocr9vt3Iq86qIDBYRkYgKi8KKyAgICAgICAgICAgIAorICAgICAgICAgICAgaWYgKGxlZnRfdG9fcmVhZCA8IChlcmFzZXNpemUgLSBibG9ja19vZmZzZXQpKQorCQkJICAgIHJlYWRfbGVuZ3RoID0gbGVmdF90b19yZWFkOworCQkgICAgZWxzZQorCQkJICAgIHJlYWRfbGVuZ3RoID0gbmFuZC0+ZXJhc2VzaXplIC0gYmxvY2tfb2Zmc2V0OworICAgICAgICAgICAgCisgICAgICAgICAgICBtZW1zZXQoYnVmLCAweGZmLCByZWFkX2xlbmd0aCk7CisgICAgICAgICAgICAKKyAgICAgICAgICAgIGxlZnRfdG9fcmVhZCAtPSByZWFkX2xlbmd0aDsKKwkJICAgIG9mZnNldCAgICAgICArPSByZWFkX2xlbmd0aDsKKwkJICAgIGJ1ZiAgICAgICAgICArPSByZWFkX2xlbmd0aDsKKworICAgICAgICAgICAgY29udGludWU7CisgICAgICAgICAgICAKKyAgICAgICAgfQorICAgICAgICAgICAgCisgICAgICAgIGlmIChsZWZ0X3RvX3JlYWQgPCAoZXJhc2VzaXplIC0gYmxvY2tfb2Zmc2V0KSkKKwkJCXJlYWRfbGVuZ3RoID0gbGVmdF90b19yZWFkOworCQllbHNlCisJCQlyZWFkX2xlbmd0aCA9IG5hbmQtPmVyYXNlc2l6ZSAtIGJsb2NrX29mZnNldDsKKyAgICAgICAgCisKKyAgICAgICAgemZ0bF9kZWJ1ZygiICAgIFt6ZnRsX3JlYWRdICBuYW5kLT5yZWFkKCAtMHglMHgtLCAtMHglMHgtKVxuIiwgCisgICAgICAgICAgICAgICAgICAgICAgICAoKGZpcnN0QmxvY2sgKyBvZmZzZXRfYmxvY2tfcGh5KSA8PCBlcmFzZXNpemVfc2hpZnQpICsgYmxvY2tfb2Zmc2V0LAorICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRfbGVuZ3RoKTsKKyAgICAgICAgcmV0ID0gbmFuZC0+X3JlYWQobmFuZCwgKChmaXJzdEJsb2NrICsgb2Zmc2V0X2Jsb2NrX3BoeSkgPDwgZXJhc2VzaXplX3NoaWZ0KSArIGJsb2NrX29mZnNldCwgCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRfbGVuZ3RoLCAmcmV0bGVuLCBidWYpOworICAgICAgICBpZiAocmV0IHx8IHJldGxlbiAhPSByZWFkX2xlbmd0aCkKKyAgICAgICAgeworICAgICAgICAgICAgICAgIHByaW50ayhLRVJOX0VSUiJbemZsdGxdOiAtemZ0bF9yZWFkLSBlcnJvclxuIik7CisJCSAgICAgICAgLy9yZXR1cm4gLTE7CisjaWZkZWYgQ09ORklHX01URF9OVlJFU1VNRQorICAgIAkJICAgIGlmKCghek9zc19OdkluUmVzdW1lKCkpJiYoemZ0bD09emZ0bF9pbmZvWzFdKSYmKHpmdGxfcmVzICE9IDEpKQorCQkJICAgIHsKKwkJCQkJcmV0dXJuIC0xOworCQkJICAgIH0KKyNlbmRpZgorICAgICAgICB9CisKKyAgICAgICAgbGVmdF90b19yZWFkIC09IHJlYWRfbGVuZ3RoOworCQlvZmZzZXQgICAgICAgKz0gcmVhZF9sZW5ndGg7CisJCWJ1ZiAgICAgICAgICArPSByZWFkX2xlbmd0aDsKKyAgICB9CisgICAgICAgIAorICAgIHpmdGxfZGVidWcoIlxuIik7CisJcmV0dXJuIDA7Cit9CisKKworc3RydWN0IFpGVExyZWNvcmQgICogemZ0bF9nZXRfWkZUTHJlY29yZF9ieW5hbWUoY2hhciogcGFydF9uYW1lKQoreworICAgIHVpbnQ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CXJldHVybiAxOworICAgIAl9CisgICAgICAgIHpmdGwgPSB6ZnRsX2luZm9bcGFydG51bV07CisgICAgICAgIAorICAgICAgICB6ZnRsLT5uYW5kID0gbmFuZDsKKyAgICAgICAgemZ0bC0+ZXJhc2VzaXplID0gbmFuZC0+ZXJhc2VzaXplOyAgICAKKyAgICAgICAgemZ0bC0+d3JpdGVzaXplID0gbmFuZC0+d3JpdGVzaXplOworICAgICAgICB6ZnRsLT5lcmFzZXNpemVfc2hpZnQgPSBmZnMobmFuZC0+ZXJhc2VzaXplKSAtIDE7ICAKKyAgICAgICAgemZ0bC0+d3JpdGVzaXplX3NoaWZ0ID0gZmZzKG5hbmQtPndyaXRlc2l6ZSkgLSAxOworICAgICAgICB6ZnRsLT5vb2JzaXplID0gbmFuZC0+b29ic2l6ZTsKKyAgICAgICAgCisgICAgICAgIHBhcnQgPSBwYXJ0aXRpb25zOworCisJICAgIGZvcihrPTA7azxwYXJ0LT5udW1fcGFydHM7aysrKQorCSAgICB7CisJICAgICAgICBpZiAoIHN0cmNtcCggKGNoYXIgKilwYXJ0LT5wYXJ0c1trXS5uYW1lLCBwYXJ0X25hbWUgKSA9PSAwICkKKyAgICAgICAgICAgIGJyZWFrOworCisJICAgIH0gICAgLyogbnZyICovCisgICAgICAgICAgICAKKyAgICAgICAgcGFydGl0aW9uX29mZmVzdCA9IHBhcnQtPnBhcnRzW2tdLm9mZnNldDsKKyAgICAgICAgcGFydGl0aW9uX3NpemUgPSBwYXJ0LT5wYXJ0c1trXS5zaXplOworICAgICAgICAKKwkJaWYgKCBzdHJjbXAocGFydF9uYW1lLCJjZHJvbSIpID09IDAgKQorCQl7CisJCQljZHJvbV9wYXJ0c2l6ZSA9IHBhcnRpdGlvbl9zaXplOworCQl9CisKKwkJaWYgKCBzdHJjbXAocGFydF9uYW1lLCJudnJvIikgPT0gMCApCisJCXsKKwkJCW52cm9fcGFydHNpemUgPSBwYXJ0aXRpb25fc2l6ZTsKKyAgICAgICAgICAgIHBya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