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VRTXSwgc2RsZW4gPSAwOwojZW5kaWYgICAgICAgICAgICAgICAgICAgICAgICAgIC8qIFVTSU5HX1NNVVhfTU9EVUxFICovCgovKgogKiBQcm90b3R5cGVzLgogKi8KaW50ICAgICAgICAgICAgIHNubXBfcmVhZF9wYWNrZXQoaW50KTsKaW50ICAgICAgICAgICAgIHNubXBfaW5wdXQoaW50LCBuZXRzbm1wX3Nlc3Npb24gKiwgaW50LCBuZXRzbm1wX3BkdSAqLAogICAgICAgICAgICAgICAgICAgICAgICAgICB2b2lkICopOwpzdGF0aWMgdm9pZCAgICAgdXNhZ2UoY2hhciAqKTsKc3RhdGljIHZvaWQgICAgIFNubXBUcmFwTm9kZURvd24odm9pZCk7CnN0YXRpYyBpbnQgICAgICByZWNlaXZlKHZvaWQpOwojaWZkZWYgV0lOMzJTRVJWSUNFCnZvaWQgICAgICAgICAgICBTdG9wU25tcEFnZW50KHZvaWQpOwppbnQgICAgICAgICAgICAgU25tcERhZW1vbk1haW4oaW50IGFyZ2MsIFRDSEFSICogYXJndltdKTsKaW50IF9fY2RlY2wgICAgIF90bWFpbihpbnQgYXJnYywgVENIQVIgKiBhcmd2W10pOwojZWxzZQppbnQgICAgICAgICAgICAgbWFpbihpbnQsIGNoYXIgKiopOwojZW5kaWYKCi8qCiAqIFRoZXNlIGRlZmluaXRpb25zIGhhbmRsZSA0LjIgc3lzdGVtcyB3aXRob3V0IGFkZGl0aW9uYWwgc3lzbG9nIGZhY2lsaXRpZXMuCiAqLwojaWZuZGVmIExPR19DT05TCiNkZWZpbmUgTE9HX0NPTlMJMCAgICAgICAvKiBEb24ndCBib3RoZXIgaWYgbm90IGRlZmluZWQuLi4gKi8KI2VuZGlmCiNpZm5kZWYgTE9HX1BJRAojZGVmaW5lIExPR19QSUQJCTAgICAgICAgLyogRG9uJ3QgYm90aGVyIGlmIG5vdCBkZWZpbmVkLi4uICovCiNlbmRpZgojaWZuZGVmIExPR19MT0NBTDAKI2RlZmluZSBMT0dfTE9DQUw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qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiotby0qKioqKioKICogbWFpbiAtIE5vbiBXaW5kb3dzCiAqIFNubXBEYWVtb25NYWluIC0gV2luZG93cyB0byBzdXBwb3J0IHdpbmRvd3Mgc2VydmljZQogKgogKiBQYXJhbWV0ZXJzOgogKgkgYXJnYwogKgkqYXJndltdCiAqICAgICAgCiAqIFJldHVybnM6CiAqCTAJQWx3YXlzIHN1Y2NlZWRzLiAgKD8pCiAqCiAqCiAqIFNldHVwIGFuZCBzdGFydCB0aGUgYWdlbnQgZGFlbW9uLgogKgogKiBBbHNvIHN1Y2Nlc3NmdWxseSBFWElUcyB3aXRoIHplcm8gZm9yIHNvbWUgb3B0aW9ucy4KICovCmludAojaWZkZWYgV0lOMzJTRVJWSUNFClNubXBEYWVtb25NYWluKGludCBhcmdjLCBUQ0hBUiAqIGFyZ3ZbXSkKI2Vsc2UKbWFpbihpbnQgYXJnYywgY2hhciAqYXJndltdKQojZW5kaWYKewogICAgY2hhciAgICAgICAgICAgIG9wdGlvbnNbMTI4XSA9ICJhQWM6Q2REOjpmaEhJOmw6TDptOk06cDpQOnFyc1M6VXZWLToiOwogICAgaW50ICAgICAgICAgICAgIGFyZywgaSwgcmV0OwogICAgaW50ICAgICAgICAgICAgIGRvbnRfZm9yayA9IDA7CiAgICBpbnQgICAgICAgICAgICAgZG9udF96ZXJvX2xvZyA9IDAsIGxvZ19zZXQgPSAwOwogICAgaW50ICAgICAgICAgICAgIHVpZCA9IDAsIGdpZCA9IDA7CiAgICBpbnQgICAgICAgICAgICAgYWdlbnRfbW9kZSA9IC0xOwogICAgY2hhciAgICAgICAgICAgKmNwdHIsICoqYXJndnB0cjsKICAgIGNoYXIgICAgICAgICAgICpwaWRfZmlsZSA9IE5VTEw7CiAgICBjaGFyICAgICAgICAgICAgb3B0aW9uX2NvbXBhdGFiaWxpdHlbXSA9ICItTGUiOwojaWYgSEFWRV9HRVRQSUQKICAgIGludC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JBR0VOVF9NT0RVTEUpfHwgZGVmaW5lZChVU0lOR19BR0VOVFhfTUFTVEVSX01PRFVMRSkKICAgIHN0cmNhdChvcHRpb25zLCAieDoiKTsKI2VuZGlmCiNpZmRlZiBVU0lOR19BR0VOVFhfU1VCQUdFTlRfTU9EVUxFCiAgICBzdHJjYXQob3B0aW9ucywgIlgiKTsKI2VuZGlmCgogICAgLyoKICAgICAqIFRoaXMgaXMgaW5jcmVkaWJseSB1Z2x5LCBidXQgaXQncyBwcm9iYWJseSB0aGUgc2ltcGxlc3Qgd2F5CiAgICAgKiAgdG8gaGFuZGxlIHRoZSBvbGQgJy1MJyBvcHRpb24gYXMgd2VsbCBhcyB0aGUgbmV3ICctTHgnIHN0eWxlCiAgICAgKi8KICAgIGZvciAoaT0wOyBpPGFyZ2M7IGkrKykgewogICAgICAgIGlmICghc3RyY21wKGFyZ3ZbaV0sICItTCIpKQogICAgICAgICAgICBhcmd2W2ldID0gb3B0aW9uX2NvbXBhdGFiaWxpdHk7ICAgICAgICAgICAgCiAgICB9CgogICAgc25tcF9sb2dfc3lzbG9nbmFtZShhcHBfbmFtZSk7CgogICAgLyoKICAgICAqIE5vdyBwcm9jZXNzIG9wdGlvbnMgbm9ybWFsbHkuICAKICAgICAqLwogICAgd2hpbGUgKChhcmcgPSBnZXRvcHQoYXJnYywgYXJndiwgb3B0aW9ucykpICE9IEVPRikgewogICAgICAgIHN3aXRjaCAoYXJnKSB7CiAgICAgICAgY2FzZSAnLSc6CiAgICAgICAgICAgIGlmIChzdHJjYXNlY21wKG9wdGFyZywgImhlbHAiKSA9PSAwKSB7CiAgICAgICAgICAgICAgICB1c2FnZShhcmd2WzBdKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoc3RyY2FzZWNtcChvcHRhcmcsICJ2ZXJzaW9uIikgPT0gMCkgewogICAgICAgICAgICAgICAgdmVyc2lvbigpOwogICAgICAgICAgICB9CgogICAgICAgICAgICBoYW5kbGVfbG9uZ19vcHQob3B0YXJnKTsKICAgICAgICAgICAgYnJlYWs7CgogICAgICAgIGNhc2UgJ2EnOgogICAgICAgICAgICBsb2dfYWRkcmVzc2VzKys7CiAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICBjYXNlICdBJzoKICAgICAgICAgICAgZG9udF96ZXJvX2xvZyA9IDE7CiAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICBjYXNlICdjJzoKICAgICAgICAgICAgaWYgKG9wdGFyZyAhPSBOVUxMKSB7CiAgICAgICAgICAgICAgICBuZXRzbm1wX2RzX3NldF9zdHJpbmcoTkVUU05NUF9EU19MSUJSQVJZX0lELCAKCQkJCSAgICAgIE5FVFNOTVBfRFNfTElCX09QVElPTkFMQ09ORklHLCBvcHRhcmcpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgdXNhZ2UoYXJndlswXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CgogICAgICAgIGNhc2UgJ0MnOgogICAgICAgICAgICBuZXRzbm1wX2RzX3NldF9ib29sZWFuKE5FVFNOTVBfRFNfTElCUkFSWV9JRCwgCgkJCQkgICBORVRTTk1QX0RTX0xJQl9ET05UX1JFQURfQ09ORklHUywgMSk7CiAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICBjYXNlICdkJzoKICAgICAgICAgICAgc25tcF9zZXRfZHVtcF9wYWNrZXQoKytzbm1wX2R1bXBfcGFja2V0KTsKICAgICAgICAgICAgbmV0c25tcF9kc19zZXRfYm9vbGVhbihORVRTTk1QX0RTX0FQUExJQ0FUSU9OX0lELCAKCQkJCSAgIE5FVFNOTVBfRFNfQUdFTlRfVkVSQk9TRSwgMSk7CiAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICBjYXNlICdEJzoKICAgICAgICAgICAgZGVidWdfcmVnaXN0ZXJfdG9rZW5zKG9wdGFyZyk7CiAgICAgICAgICAgIHNubXBfc2V0X2RvX2RlYnVnZ2luZygxKTsKICAgICAgICAgICAgYnJlYWs7CgogICAgICAgIGNhc2UgJ2YnOgogICAgICAgICAgICBkb250X2ZvcmsgPSAxOwogICAgICAgICAgICBicmVhazsKCiNpZiBIQVZFX1VOSVNURF9ICiAgICAgICAgY2FzZSAnZyc6CiAgICAgICAgICAgIGlmIChvcHRhcmcgIT0gTlVMTCkgewogICAgICAgICAgICAgICAgbmV0c25tcF9kc19zZXRfaW50KE5FVFNOTVBfRFNfQVBQTElDQVRJT05fSUQsIAoJCQkJICAgTkVUU05NUF9EU19BR0VOVF9HUk9VUElELCBhdG9pKG9wdGFyZykpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgdXNhZ2UoYXJndlswXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiNlbmRpZgoKICAgICAgICBjYXNlICdoJzoKICAgICAgICAgICAgdXNhZ2UoYXJndlswXSk7CiAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICBjYXNlICdIJzoKICAgICAgICAgICAgbmV0c25tcF9kc19zZXRfYm9vbGVhbihORVRTTk1QX0RTX0FQUExJQ0FUSU9OX0lELCAKCQkJCSAgIE5FVFNOTVBfRFNfQUdFTlRfTk9fUk9PVF9BQ0NFU1MsIDEpOwogICAgICAgICAgICBpbml0X2FnZW50KCJzbm1wZCIpOyAgICAgICAgLyogcmVnaXN0ZXIgb3VyIC5jb25mIGhhbmRsZXJzICovCiAgICAgICAgICAgIGluaXRfbWliX21vZHVsZXMoKTsKICAgICAgICAgICAgaW5pdF9zbm1wKCJzbm1wZCIpOwogICAgICAgICAgICBmcHJpbnRmKHN0ZGVyciwgIkNvbmZpZ3VyYXRpb24gZGlyZWN0aXZlcyB1bmRlcnN0b29kOlxuIik7CiAgICAgICAgICAgIHJlYWRfY29uZmlnX3ByaW50X3VzYWdlKCIgICIpOwogICAgICAgICAgICBleGl0KDApOwoKICAgICAgICBjYXNlICdJJzoKICAgICAgICAgICAgaWYgKG9wdGFyZyAhPSBOVUxMKSB7CiAgICAgICAgICAgICAgICBhZGRfdG9faW5pdF9saXN0KG9wdGFyZyk7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICB1c2FnZShhcmd2WzBdKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKCiAgICAgICAgY2FzZSAnbCc6CiAgICAgICAgICAgIHByaW50ZigiV2FybmluZzogLWwgb3B0aW9uIGlzIGRlcHJlY2F0ZWQsIHVzZSAtTGYgPGZpbGU+IGluc3RlYWRcbiIpOwogICAgICAgICAgICBpZiAob3B0YXJnICE9IE5VTEwpIHsKICAgICAgICAgICAgICAgIGlmIChzdHJsZW4ob3B0YXJnKSA+IFBBVEhfTUFYKSB7CiAgICAgICAgICAgICAgICAgICAgZnByaW50ZihzdGRlcnIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAiJXM6IGxvZ2ZpbGUgcGF0aCB0b28gbG9uZyAobGltaXQgJWQgY2hhcnMpXG4iLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJndlswXSwgUEFUSF9NQVgpOwogICAgICAgICAgICAgICAgICAgIGV4aXQoMSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBzbm1wX2VuYWJsZV9maWxlbG9nKG9wdGFyZywgZG9udF96ZXJvKTsKICAgICAgICAgICAgICAgIGxvZ19zZXQgPSAxOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgdXNhZ2UoYXJndlswXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CgogICAgICAgIGNhc2UgJ0wnOgoJICAgIGlmICAoc25tcF9sb2dfb3B0aW9ucyggb3B0YXJnLCBhcmdjLCBhcmd2ICkgPCAwICkgewogICAgICAgICAgICAgICAgdXNhZ2UoYXJndlswXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbG9nX3NldCA9IDE7CiAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICBjYXNlICdtJzoKICAgICAgICAgICAgaWYgKG9wdGFyZyAhPSBOVUxMKSB7CiAgICAgICAgICAgICAgICBzZXRlbnYoIk1JQlMiLCBvcHRhcmcsIDEpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgdXNhZ2UoYXJndlswXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CgogICAgICAgIGNhc2UgJ00nOgogICAgICAgICAgICBpZiAob3B0YXJnICE9IE5VTEwpIHsKICAgICAgICAgICAgICAgIHNldGVudigiTUlCRElSUyIsIG9wdGFyZywgMSk7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICB1c2FnZShhcmd2WzBdKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKCiAgICAgICAgY2FzZSAnUCc6CiAgICAgICAgICAgIHByaW50ZigiV2FybmluZzogLVAgb3B0aW9uIGlzIGRlcHJlY2F0ZWQsIHVzZSAtcCBpbnN0ZWFkXG4iKTsKICAgICAgICBjYXNlICdwJzoKICAgICAgICAgICAgaWYgKG9wdGFyZyAhPSBOVUxMKSB7CiAgICAgICAgICAgICAgICBwaWRfZmlsZSA9IG9wdGFyZzsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHVzYWdlKGFyZ3ZbMF0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICBjYXNlICdxJzoKICAgICAgICAgICAgc25tcF9zZXRfcXVpY2tfcHJpbnQoMSk7CiAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICBjYXNlICdyJzoKICAgICAgICAgICAgbmV0c25tcF9kc190b2dnbGVfYm9vbGVhbihORVRTTk1QX0RTX0FQUExJQ0FUSU9OX0lELCAKCQkJCSAgICAgIE5FVFNOTVBfRFNfQUdFTlRfTk9fUk9PVF9BQ0NFU1MpOwogICAgICAgICAgICBicmVhazsKCiAgICAgICAgY2FzZSAncyc6CiAgICAgICAgICAgIHByaW50ZigiV2FybmluZzogLXMgb3B0aW9uIGlzIGRlcHJlY2F0ZWQsIHVzZSAtTHNkIGluc3RlYWRcbiIpOwogICAgICAgICAgICBzeXNsb2dfbG9nID0gMTsKICAgICAgICAgICAgYnJlYWs7CgogICAgICAgIGNhc2UgJ1MnOgogICAgICAgICAgICBwcmludGYoIldhcm5pbmc6IC1TIG9wdGlvbiBpcyBkZXByZWNhdGVkLCB1c2UgLUxzIDxmYWNpbGl0eT4gaW5zdGVhZFxuIik7CiAgICAgICAgICAgIGlmIChvcHRhcmcgIT0gTlVMTCkgewogICAgICAgICAgICAgICAgc3dpdGNoICgqb3B0YXJnKSB7CiAgICAgICAgICAgICAgICBjYXNlICdkJzoKICAgICAgICAgICAgICAgIGNhc2UgJ0QnOgogICAgICAgICAgICAgICAgICAgIEZhY2lsaXR5ID0gTE9HX0RBRU1PTjsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIGNhc2UgJ2knOgogICAgICAgICAgICAgICAgY2FzZSAnSSc6CiAgICAgICAgICAgICAgICAgICAgRmFjaWxpdHkgPSBMT0dfSU5GTzsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIGNhc2UgJzAnOgogICAgICAgICAgICAgICAgICAgIEZhY2lsaXR5ID0gTE9HX0xPQ0FMMDsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIGNhc2UgJzEnOgogICAgICAgICAgICAgICAgICAgIEZhY2lsaXR5ID0gTE9HX0xPQ0FMMTsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIGNhc2UgJzInOgogICAgICAgICAgICAgICAgICAgIEZhY2lsaXR5ID0gTE9HX0xPQ0FMMjsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIGNhc2UgJzMnOgogICAgICAgICAgICAgICAgICAgIEZhY2lsaXR5ID0gTE9HX0xPQ0FMMzsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIGNhc2UgJzQnOgogICAgICAgICAgICAgICAgICAgIEZhY2lsaXR5ID0gTE9HX0xPQ0FMNDsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIGNhc2UgJzUnOgogICAgICAgICAgICAgICAgICAgIEZhY2lsaXR5ID0gTE9HX0xPQ0FMNTsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIGNhc2UgJzYnOgogICAgICAgICAgICAgICAgICAgIEZhY2lsaXR5ID0gTE9HX0xPQ0FMNjsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIGNhc2UgJzcnOgogICAgICAgICAgICAgICAgICAgIEZhY2lsaXR5ID0gTE9HX0xPQ0FMNzsKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgZnByaW50ZihzdGRlcnIsICJpbnZhbGlkIHN5c2xvZyBmYWNpbGl0eTogLVMlY1xuIiwqb3B0YXJnKTsKICAgICAgICAgICAgICAgICAgICB1c2FnZShhcmd2WzBdKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIGZwcmludGYoc3RkZXJyLCAibm8gc3lzbG9nIGZhY2lsaXR5IHNwZWNpZmllZFxuIik7CiAgICAgICAgICAgICAgICB1c2FnZShhcmd2WzBdKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKCiAgICAgICAgY2FzZSAnVSc6CiAgICAgICAgICAgIG5ldHNubXBfZHNfdG9nZ2xlX2Jvb2xlYW4oTkVUU05NUF9EU19BUFBMSUNBVElPTl9JRCwgCgkJCQkgICAgICBORVRTTk1QX0RTX0FHRU5UX0xFQVZFX1BJREZJTEUpOwogICAgICAgICAgICBicmVhazsKCiNpZiBIQVZFX1VOSVNURF9ICiAgICAgICAgY2FzZSAndSc6CiAgICAgICAgICAgIGlmIChvcHRhcmcgIT0gTlVMTCkgewogICAgICAgICAgICAgICAgY2hhciAgICAgICAgICAgKmVjcDsKICAgICAgICAgICAgICAgIGludCAgICAgICAgICAgICB1aWQ7CgogICAgICAgICAgICAgICAgdWlkID0gc3RydG91bChvcHRhcmcsICZlY3AsIDEwKTsKICAgICAgICAgICAgICAgIGlmICgqZWNwKSB7CiNpZiBIQVZFX0dFVFBXTkFNICYmIEhBVkVfUFdEX0gKICAgICAgICAgICAgICAgICAgICBzdHJ1Y3QgcGFzc3dkICAqaW5mbzsKICAgICAgICAgICAgICAgICAgICBpbmZvID0gZ2V0cHduYW0ob3B0YXJnKTsKICAgICAgICAgICAgICAgICAgICBpZiAoaW5mbykgewogICAgICAgICAgICAgICAgICAgICAgICB1aWQgPSBpbmZvLT5wd191aWQ7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKI2VuZGlmCiAgICAgICAgICAgICAgICAgICAgICAgIGZwcmludGYoc3RkZXJyLCAiQmFkIHVzZXIgaWQ6ICVzXG4iLCBvcHRhcmcpOwogICAgICAgICAgICAgICAgICAgICAgICBleGl0KDEpOwojaWYgSEFWRV9HRVRQV05BTSAmJiBIQVZFX1BXRF9ICiAgICAgICAgICAgICAgICAgICAgfQojZW5kaWYKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIG5ldHNubXBfZHNfc2V0X2ludChORVRTTk1QX0RTX0FQUExJQ0FUSU9OX0lELCAKCQkJCSAgIE5FVFNOTVBfRFNfQUdFTlRfVVNFUklELCB1aWQpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgdXNhZ2UoYXJndlswXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiNlbmRpZgoKICAgICAgICBjYXNlICd2JzoKICAgICAgICAgICAgdmVyc2lvbigpOwoKICAgICAgICBjYXNlICdWJzoKICAgICAgICAgICAgbmV0c25tcF9kc19zZXRfYm9vbGVhbihORVRTTk1QX0RTX0FQUExJQ0FUSU9OX0lELC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gICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgfQoKICAgIGlmIChvcHRpbmQgPCBhcmdjKSB7CiAgICAgICAgLyoKICAgICAgICAgKiBUaGVyZSBhcmUgb3B0aW9uYWwgdHJhbnNwb3J0IGFkZHJlc3NlcyBvbiB0aGUgY29tbWFuZCBsaW5lLiAgCiAgICAgICAgICovCiAgICAgICAgREVCVUdNU0dUTCgoInNubXBkL21haW4iLCAib3B0aW5kICVkLCBhcmdjICVkXG4iLCBvcHRpbmQsIGFyZ2MpKTsKICAgICAgICBmb3IgKGkgPSBvcHRpbmQ7IGkgPCBhcmdjOyBpKyspIHsKICAgICAgICAgICAgY2hhciAqYywgKmFzdHJpbmc7CiAgICAgICAgICAgIGlmICgoYyA9IG5ldHNubXBfZHNfZ2V0X3N0cmluZyhORVRTTk1QX0RTX0FQUExJQ0FUSU9OX0lELCAKCQkJCQkgICBORVRTTk1QX0RTX0FHRU5UX1BPUlRTKSkpIHsKICAgICAgICAgICAgICAgIGFzdHJpbmcgPSBtYWxsb2Moc3RybGVuKGMpICsgMiArIHN0cmxlbihhcmd2W2ldKSk7CiAgICAgICAgICAgICAgICBpZiAoYXN0cmluZyA9PSBOVUxMKSB7CiAgICAgICAgICAgICAgICAgICAgZnByaW50ZihzdGRlcnIsICJtYWxsb2MgZmFpbHVyZSBwcm9jZXNzaW5nIGFyZ3ZbJWRdXG4iLCBpKTsKICAgICAgICAgICAgICAgICAgICBleGl0KDEpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgc3ByaW50Zihhc3RyaW5nLCAiJXMsJXMiLCBjLCBhcmd2W2ldKTsKICAgICAgICAgICAgICAgIG5ldHNubXBfZHNfc2V0X3N0cmluZyhORVRTTk1QX0RTX0FQUExJQ0FUSU9OX0lELCAKCQkJCSAgICAgIE5FVFNOTVBfRFNfQUdFTlRfUE9SVFMsIGFzdHJpbmcpOwogICAgICAgICAgICAgICAgU05NUF9GUkVFKGFzdHJpbmcpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgbmV0c25tcF9kc19zZXRfc3RyaW5nKE5FVFNOTVBfRFNfQVBQTElDQVRJT05fSUQsIAoJCQkJICAgICAgTkVUU05NUF9EU19BR0VOVF9QT1JUUywgYXJndltpXSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgREVCVUdNU0dUTCgoInNubXBkL21haW4iLCAicG9ydCBzcGVjOiAlc1xuIiwKICAgICAgICAgICAgICAgICAgICBuZXRzbm1wX2RzX2dldF9zdHJpbmcoTkVUU05NUF9EU19BUFBMSUNBVElPTl9JRCwgCgkJCQkJICBORVRTTk1QX0RTX0FHRU5UX1BPUlRTKSkpOwogICAgfQoKI2lmZGVmIExPR0ZJTEUKICAgIGlmICgwID09IGxvZ19zZXQpCiAgICAgICAgc25tcF9lbmFibGVfZmlsZWxvZyhMT0dGSUxFLCBkb250X3plcm8pOwojZW5kaWYKCiAgICAvKgogICAgICogSW5pdGlhbGl6ZSBhIGFyZ3Ygc2V0IHRvIHRoZSBjdXJyZW50IGZvciByZXN0YXJ0aW5nIHRoZSBhZ2VudC4gICAKICAgICAqLwogICAgYXJndnJlc3RhcnRwID0gKGNoYXIgKiopbWFsbG9jKChhcmdjICsgMikgKiBzaXplb2YoY2hhciAqKSk7CiAgICBhcmd2cHRyID0gYXJndnJlc3RhcnRwOwogICAgZm9yIChpID0gMCwgcmV0ID0gMTsgaSA8IGFyZ2M7IGkrKykgewogICAgICAgIHJldCArPSBzdHJsZW4oYXJndltpXSkgKyAxOwogICAgfQogICAgYXJndnJlc3RhcnQgPSAoY2hhciAqKSBtYWxsb2MocmV0KTsKICAgIGFyZ3ZyZXN0YXJ0bmFtZSA9IChjaGFyICopIG1hbGxvYyhzdHJsZW4oYXJndlswXSkgKyAxKTsKICAgIGlmICghYXJndnJlc3RhcnRwIHx8ICFhcmd2cmVzdGFydCB8fCAhYXJndnJlc3RhcnRuYW1lKSB7CiAgICAgICAgZnByaW50ZihzdGRlc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gICogSW5pdGlhbGl6ZSB0aGUgd29ybGQuICBEZXRhY2ggZnJvbSB0aGUgc2hlbGwuICBDcmVhdGUgaW5pdGlhbCB1c2VyLiAgCiAgICAgKi8KICAgIGlmKCFkb250X2ZvcmspIHsKICAgICAgICBpbnQgcXVpdCA9ICEgbmV0c25tcF9kc19nZXRfYm9vbGVhbihORVRTTk1QX0RTX0FQUExJQ0FUSU9OX0lELAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE5FVFNOTVBfRFNfQUdFTlRfUVVJVF9JTU1FRElBVEVMWSk7CiAgICAgICAgcmV0ID0gbmV0c25tcF9kYWVtb25pemUocXVpdCwgc3RkZXJyX2xvZyk7CiAgICAgICAgLyoKICAgICAgICAgKiB4eHgtcmtzOiBkbyB3ZSBjYXJlIGlmIGZvcmsgZmFpbHM/IEkgdGhpbmsgd2Ugc2hvdWxkLi4uCiAgICAgICAgICovCiAgICAgICAgaWYocmV0ICE9IDApCiAgICAgICAgICAgIEV4aXQoMSk7ICAgICAgICAgICAgICAgIC8qICBFeGl0IGxvZ3MgZXhpdCB2YWwgZm9yIHVzICAqLwogICAgfQoKICAgIFNPQ0tfU1RBUlRVUDsKICAgIGluaXRfYWdlbnQoInNubXBkIik7ICAgICAgICAvKiBkbyB3aGF0IHdlIG5lZWQgdG8gZG8gZmlyc3QuICovCiAgICBpbml0X21pYl9tb2R1bGVzKCk7CgogICAgLyoKICAgICAqIHN0YXJ0IGxpYnJhcnkgCiAgICAgKi8KICAgIGluaXRfc25tcCgic25tcGQiKTsKCiAgICBpZiAoKHJldCA9IGluaXRfbWFzdGVyX2FnZW50KCkpICE9IDApIHsKICAgICAgICAvKgogICAgICAgICAqIFNvbWUgZXJyb3Igb3BlbmluZyBvbmUgb2YgdGhlIHNwZWNpZmllZCBhZ2VudCB0cmFuc3BvcnRzLiAgCiAgICAgICAgICovCiAgICAgICAgRXhpdCgxKTsgICAgICAgICAgICAgICAgLyogIEV4aXQgbG9ncy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2ggbGF0ZXIuICAKICAgICAqLwogICAgc25tcF9zdG9yZSgic25tcGQiKTsKCiAgICAvKgogICAgICogU2VuZCBjb2xkc3RhcnQgdHJhcCBpZiBwb3NzaWJsZS4gIAogICAgICovCiAgICBzZW5kX2Vhc3lfdHJhcCgwLCAwKTsKCiNpZiBIQVZFX0dFVFBJRAogICAgaWYgKHBpZF9maWxlICE9IE5VTEwpIHsKICAgICAgICAvKgogICAgICAgICAqIHVubGluayB0aGUgcGlkX2ZpbGUsIGlmIGl0IGV4aXN0cywgcHJpb3IgdG8gb3Blbi4gIFdpdGhvdXQKICAgICAgICAgKiBkb2luZyB0aGlzIHRoZSBvcGVuIHdpbGwgZmFpbCBpZiB0aGUgdXNlciBzcGVjaWZpZWQgcGlkX2ZpbGUKICAgICAgICAgKiBhbHJlYWR5IGV4aXN0cy4KICAgICAgICAgKi8KICAgICAgICB1bmxpbmsocGlkX2ZpbGUpOwogICAgICAgIGZkID0gb3BlbihwaWRfZmlsZSwgT19DUkVBVCB8IE9fRVhDTCB8IE9fV1JPTkxZLCAwNjAwKTsKICAgICAgICBpZiAoZmQgPT0gLTEpIHsKICAgICAgICAgICAgc25tcF9sb2dfcGVycm9yKHBpZF9maWxlKTsKICAgICAgICAgICAgaWYgKCFuZXRzbm1wX2RzX2dldF9ib29sZWFuKE5FVFNOTVBfRFNfQVBQTElDQVRJT05fSUQsIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTkVUU05NUF9EU19BR0VOVF9OT19ST09UX0FDQ0VTUykpIHsKICAgICAgICAgICAgICAgIGV4aXQoMSk7CiAgICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBpZiAoKFBJRCA9IGZkb3BlbihmZCwgInciKSkgPT0gTlVMTCkgewogICAgICAgICAgICAgICAgc25tcF9sb2dfcGVycm9yKHBpZF9maWxlKTsKICAgICAgICAgICAgICAgIGV4aXQoMSk7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBmcHJpbnRmKFBJRCwgIiVkXG4iLCAoaW50KSBnZXRwaWQoKSk7CiAgICAgICAgICAgICAgICBmY2xvc2UoUElEKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjbG9zZShmZCk7CiAgICAgICAgfQogICAgfQojZW5kaWYKCiNpZiBIQVZFX1VOSVNURF9ICiNpZmRlZiBIQVZFX1NFVEdJRAogICAgaWYgKChnaWQgPSBuZXRzbm1wX2RzX2dldF9pbnQoTkVUU05NUF9EU19BUFBMSUNBVElPTl9JRCwgCgkJCQkgIE5FVFNOTVBfRFNfQUdFTlRfR1JPVVBJRCkpICE9IDApIHsKICAgICAgICBERUJVR01TR1RMKCgic25tcGQvbWFpbiIsICJDaGFuZ2luZyBnaWQgdG8gJWQuXG4iLCBnaWQpKTsKICAgICAgICBpZiAoc2V0Z2lkKGdpZCkgPT0gLTEKI2lmZGVmIEhBVkVfU0VUR1JPVVBTCiAgICAgICAgICAgIHx8IHNldGdyb3VwcygxLCAoZ2lkX3QgKikmZ2lkKSA9PSAtMQojZW5kaWYKICAgICAgICAgICAgKSB7CiAgICAgICAgICAgIHNubXBfbG9nX3BlcnJvcigic2V0Z2lkIGZhaWxlZCIpOwogICAgICAgICAgICBpZiAoIW5ldHNubXBfZHNfZ2V0X2Jvb2xlYW4oTkVUU05NUF9EU19BUFBMSUNBVElPTl9JRCwgCgkJCQkJTkVUU05NUF9EU19BR0VOVF9OT19ST09UX0FDQ0VTUykpIHsKICAgICAgICAgICAgICAgIGV4aXQoMSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiNlbmRpZgojaWZkZWYgSEFWRV9TRVRVSUQKICAgIGlmICgodWlkID0gbmV0c25tcF9kc19nZXRfaW50KE5FVFNOTVBfRFNfQVBQTElDQVRJT05fSUQsIAoJCQkJICBORVRTTk1QX0RTX0FHRU5UX1VTRVJJRCkpICE9IDApIHsKICAgICAgICBERUJVR01TR1RMKCgic25tcGQvbWFpbiIsICJDaG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hcnQoKTsKCSAgICBzbm1wX2xvZyhMT0dfSU5GTywgIk5FVC1TTk1QIHZlcnNpb24gJXMgcmVzdGFydGVkXG4iLAoJCSAgICAgbmV0c25tcF9nZXRfdmVyc2lvbigpKTsKICAgICAgICAgICAgdXBkYXRlX2NvbmZpZygpOwogICAgICAgICAgICBzZW5kX2Vhc3lfdHJhcChTTk1QX1RSQVBfRU5URVJQUklTRVNQRUNJRklDLCAzKTsKICAgICAgICB9CgogICAgICAgIGZvciAoaSA9IDA7IGkgPCBOVU1fRVhURVJOQUxfU0lHUzsgaSsrKSB7CiAgICAgICAgICAgIGlmIChleHRlcm5hbF9zaWduYWxfc2NoZWR1bGVkW2ldKSB7CiAgICAgICAgICAgICAgICBleHRlcm5hbF9zaWduYWxfc2NoZWR1bGVkW2ldLS07CiAgICAgICAgICAgICAgICBleHRlcm5hbF9zaWduYWxfaGFuZGxlcltpXShpKTsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgLyoKICAgICAgICAgKiBkZWZhdWx0IHRvIHNsZWVwaW5nIGZvciBhIHJlYWxseSBsb25nIHRpbWUKICAgICAgICAgKi8KICAgICAgICB0dnAgPSAmdGltZW91dDsKICAgICAgICB0dnAtPnR2X3NlYyA9IExPTkdfTUFYOwogICAgICAgIHR2cC0+dHZfdXNlYyA9IDA7CgogICAgICAgIG51bWZkcyA9IDA7CiAgICAgICAgRkRfWkVSTygmcmVhZGZkcyk7CiAgICAgICAgRkRfWkVSTygmd3JpdGVmZHMpOwogICAgICAgIEZEX1pFUk8oJmV4Y2VwdGZkcyk7CiAgICAgICAgYmxvY2sgPSAwOwogICAgICAgIHNubXBfc2VsZWN0X2luZm8oJm51bWZkcywgJnJlYWRmZHMsIHR2cCwgJmJsb2NrKTsKICAgICAgICBpZiAoYmxvY2sgPT0gMSkgewogICAgICAgICAgICB0dnAgPSBOVUxMOyAgICAgICAgIC8qIGJsb2NrIHdpdGhvdXQgdGltZW91dCAqLwoJfQoKI2lmZGVmCVVTSU5HX1NNVVhfTU9EVUxFCiAgICAgICAgaWYgKHNtdXhfbGlzdGVuX3NkID49IDApIHsKICAgICAgICAgICAgRkRfU0VUKHNtdXhfbGlzdGVuX3NkLCAmcmVhZGZkcyk7CiAgICAgICAgICAgIG51bWZkcyA9CiAgICAgICAgICAgICAgICBzbXV4X2xpc3Rlbl9zZCA+PSBudW1mZHMgPyBzbXV4X2xpc3Rlbl9zZCArIDEgOiBudW1mZHM7CiAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBzZGxlbjsgaSsrKSB7CiAgICAgICAgICAgICAgICBGRF9TRVQoc2RsaXN0W2ldLCAmcmVhZGZkcyk7CiAgICAgICAgICAgICAgICBudW1mZHMgPSBzZGxpc3RbaV0gPj0gbnVtZmRzID8gc2RsaXN0W2ldICsgMSA6IG51bWZkczsKICAgICAgICAgICAgfQogICAgICAgIH0KI2VuZGlmICAgICAgICAgICAgICAgICAgICAgICAgICAvKiBVU0lOR19TTVVYX01PRFVMRSAqLwoKICAgICAgICBuZXRzbm1wX2V4dGVybmFsX2V2ZW50X2luZm8oJm51bWZkcywgJnJlYWRmZHMsICZ3cml0ZWZkcywgJmV4Y2VwdGZkcyk7CgogICAgcmVzZWxlY3Q6CiAgICAgICAgREVCVUdNU0dUTCgoInNubXBkL3NlbGVjdCIsICJzZWxlY3QoIG51bWZkcz0lZCwgLi4uLCB0dnA9JXApXG4iLAogICAgICAgICAgICAgICAgICAgIG51bWZkcywgdHZwKSk7CiAgICAgICAgaWYodHZwKQogICAgICAgICAgICBERUJVR01TR1RMKCgidGltZXIiLCAidHZwICVkLiVkXG4iLCB0dnAtPnR2X3NlYywgdHZwLT50dl91c2VjKSk7CiAgICAgICAgY291bnQgPSBzZWxlY3QobnVtZmRzLCAmcmVhZGZkcywgJndyaXRlZmRzLCAmZXhjZXB0ZmRzLCB0dnApOwogICAgICAgIERFQlVHTVNHVEwoKCJzbm1wZC9zZWxlY3QiLCAicmV0dXJuZWQsIGNvdW50ID0gJWRcbiIsIGNvdW50KSk7CgogICAgICAgIGlmIChjb3VudCA+IDApIHsKCiNpZmRlZiBVU0lOR19TTVVYX01PRFVMRQogICAgICAgICAgICAvKgogICAgICAgICAgICAgKiBoYW5kbGUgdGhlIFNNVVggc2QncyAKICAgICAgICAgICAgICovCiAgICAgICAgICAgIGlmIChzbXV4X2xpc3Rlbl9zZCA+PSAwKSB7CiAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgc2RsZW47IGkrKykgewogICAgICAgICAgICAgICAgICAgIGlmIChGRF9JU1NFVChzZGxpc3RbaV0sICZyZWFkZmRzKSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoc211eF9wcm9jZXNzKHNkbGlzdFtpXSkgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKDsgaSA8IChzZGxlbiAtIDEpOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZGxpc3RbaV0gPSBzZGxpc3RbaSArIDFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2RsZW4tLTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIC8qCiAgICAgICAgICAgICAgICAgKiBuZXcgY29ubmVjdGlvbiAKICAgICAgICAgICAgICAgICAqLwogICAgICAgICAgICAgICAgaWYgKEZEX0lTU0VUKHNtdXhfbGlzdGVuX3NkLCAmcmVhZGZkcykpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoKHNkID0gc211eF9hY2NlcHQoc211eF9saXN0ZW5fc2QpKSA+PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHNkbGlzdFtzZGxlbisrXSA9IHNkOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQojZW5kaWYgICAgICAgICAgICAgICAgICAgICAgICAgIC8qIFVTSU5HX1NNVVhfTU9EVUxFICovCiAgICAgICAgICAgIG5ldHNubXBfZGlzcGF0Y2hfZXh0ZXJuYWxfZXZlbnRzKCZjb3VudCwgJnJlYWRmZHMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmd3JpdGVmZHMsICZleGNlcHRmZHMpOwogICAgICAgICAgICAvKiBJZiB0aGVyZSBhcmUgc3RpbGwgZXZlbnRzIGxlZnRvdmVyLCBwcm9jZXNzIHRoZW0gKi8KICAgICAgICAgICAgaWYgKGNvdW50ID4gMCkgewogICAgICAgICAgICAgIHNubXBfcmVhZCgmcmVhZGZkcyk7CiAgICAgICAgICAgIH0KICAgICAgICB9IGVsc2UKICAgICAgICAgICAgc3dpdGNoIChjb3VudCkgewogICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICBzbm1wX3RpbWVvdXQoKTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIC0xOgogICAgICAgICAgICAgICAgREVCVUdNU0dUTCgoInNubXBkL3NlbGVjdCIsICIgIGVycm5vID0gJWRcbiIsIGVycm5vKSk7CiAgICAgICAgICAgICAgICBpZiAoZXJybm8gPT0gRUlOVFIpIHsKICAgICAgICAgICAgICAgICAgICAvKgogICAgICAgICAgICAgICAgICAgICAqIGxpa2VseSB0aGF0IHdlIGdvdCBhIHNpZ25hbC4gQ2hlY2sgb3VyIHNwZWNpYWwgc2lnbmFsCiAgICAgICAgICAgICAgICAgICAgICogZmxhZ3MgYmVmb3JlIHJldHJ5aW5nIHNlbGVjdC4KICAgICAgICAgICAgICAgICAgICAgKi8KCQkgICAgaWYgKHJ1bm5pbmcgJiYgIXJlY29uZmlnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGdvdG8gcmVzZWxlY3Q7CgkJICAgIH0KICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgc25tcF9sb2dfcGVycm9yKCJzZWxlY3QiKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHNubXBfbG9nKExPR19FUlIsICJzZWxlY3QgcmV0dXJuZWQgJWRcbiIsIGNvdW50KTsKICAgICAgICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICAgICAgfSAgICAgICAgICAgICAgICAgICAvKiBlbmRpZiAtLSBjb3VudD4wICovCgogICAgICAgIC8qCiAgICAgICAgICogcnVuIHJlcXVlc3RlZCBhbGFybXMgCiAgICAgICAgICovCiAgICAgICAgcnVuX2FsYXJtcygpOwoKICAgICAgICBuZXRzbm1wX2NoZWNrX291dHN0YW5kaW5nX2FnZW50X3JlcXVlc3RzKCk7CgogICAgfSAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qIGVuZHdoaWxlICovCgogICAgc25tcF9sb2coTE9HX0lORk8sICJSZWNlaXZlZCBURVJNIG9yIFNUT1Agc2lnbmFsLi4uICBzaHV0dGluZyBkb3duLi4uXG4iKTsKICAgIHJldHVybiAwOwoKfSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiBlbmQgcmVjZWl2ZSgpICovCgoKCi8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLW8tKioqKioqCiAqIHNubXBfaW5wdXQKICoKICogUGFyYW1ldGVyczoKICoJIG9wCiAqCSpzZXNzaW9uCiAqCSByZXF1aWQKICoJKnBkdQogKgkqbWFnaWMKICogICAgICAKICogUmV0dXJuczoKICoJMQkJT24gc3VjY2VzcwktT1ItCiAqCVBhc3NlcyB0aHJvdWdoCVJldHVybiBmcm9tIGFsYXJtR2V0UmVzcG9uc2UoKSB3aGVuIAogKgkgIAkJICBVU0lOR19WMlBBUlRZX0FMQVJNX01PRFVMRSBpcyBkZWZpbmVkLgogKgogKiBDYWxsLWJhY2sgZnVuY3Rpb24gdG8gbWFuYWdlIHJlc3BvbnNlcyB0byB0cmFwcyAoaW5mb3JtcykgYW5kIGFsYXJtcy4KICogTm90IHVzZWQgYnkgdGhlIGFnZW50IHRvIHByb2Nlc3Mgb3RoZXIgUmVzcG9uc2UgUERVcy4KICovCmludApzbm1wX2lucHV0KGludCBvcCwKICAgICAgICAgICBuZXRzbm1wX3Nlc3Npb24gKiBzZXNzaW9uLAogICAgICAgICAgIGludCByZXFpZCwgbmV0c25tcF9wZHUgKnBkdSwgdm9pZCAqbWFnaWMpCnsKICAgIHN0cnVjdCBnZXRfcmVxX3N0YXRlICpzdGF0ZSA9IChzdHJ1Y3QgZ2V0X3JlcV9zdGF0ZSAqKSBtYWdpYzsKCiAgICBpZiAob3AgPT0gTkVUU05NUF9DQUxMQkFDS19PUF9SRUNFSVZFRF9NRVNTQUdFKSB7CiAgICAgICAgaWYgKHBkdS0+Y29tbWFuZCA9PSBTTk1QX01TR19HRVQpIHsKICAgICAgICAgICAgaWYgKHN0YXRlLT50eXBlID09IEVWRU5UX0dFVF9SRVEpIHsKICAgICAgICAgICAgICAgIC8qCiAgICAgICAgICAgICAgICAgKiB0aGlzIGlzIGp1c3QgdGhlIGFjayB0byBvdXIgaW5mb3JtIHBkdSAKICAgICAgICAgICAgICAgICAqLwogICAgICAgICAgICAgICAgcmV0dXJuIDE7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9IGVsc2UgaWYgKG9wID09IE5FVFNOTVBfQ0FMTEJBQ0tfT1BfVElNRURfT1VUKSB7CiAgICAgICAgaWYgKHN0YXRlLT50eXBlID09IEFMQVJNX0dFVF9SRVEpIHsKICAgICAgICAgICAgLyoKICAgICAgICAgICAgICogTmVlZCBhIG1lY2hhbmlzbSB0byByZXBsYWNlIG9ic29sZXRlIFNOTVB2MnAgYWxhcm0gCiAgICAgICAgICAgICAqLwogICAgICAgIH0KICAgIH0KICAgIHJldHVybiAxOwoKfSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiBlbmQgc25tcF9pbnB1dCgpICovCgoKCi8qCiAqIFdpbmRvd3MgU2VydmljZSBSZWxhdGVkIGZ1bmN0aW9ucyAKICovCiNpZmRlZiBXSU4zMlNFUlZJQ0UKLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgoqIG1haW4gZnVuY3Rpb24gZm9yIFdpbmRvd3MKKiBQYXJzZSBjb21tYW5kIGxpbmUgYXJndW1lbnRzIGZvciBzdGFydHVwIG9wdGlvbnMsCiogdG8gc3RhcnQgYXMgc2VydmljZSBvciBjb25zb2xlIG1vZGUgYXBwbGljYXRpb24gaW4gd2luZG93cy4KKiBJbnZva2VzIGFwcHJvcHJpYXRlIHN0YXJ0dXAgZnVuY3Rpb25zIGRlcGVuZGluZyBvbiB0aGUgCiogcGFyYW1ldGVycyBwYXNzZWQKKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KaW50CiAgICBfX2NkZWNsCl90bWFpbihpbnQgYXJnYywgVENIQVIgKiBhcmd2W10pCnsKICAgIC8qCiAgICAgKiBEZWZpbmUgU2VydmljZSBOYW1lIGFuZCBEZXNjcmlwdGlvbiwgd2hpY2ggYXBwZWFycyBpbiB3aW5kb3dzIFNDTSAKICAgICAqLwogICAgTFBDVFNUUiAgICAgICAgIGxwc3pTZXJ2aWNlTmFtZSA9IGFwcF9uYW1lOyAgICAgIC8qIFNlcnZpY2UgUmVnaXN0cnkgTmFtZSAqLwogICAgTFBDVFNUUiAgICAgICAgIGxwc3pTZXJ2aWNlRGlzcGxheU5hbWUgPSBfVCgiTmV0LVNOTVAgQWdlbnQiKTsgICAgICAgLyogRGlzcGxheSBOYW1lICovCiAgICBMUENUU1RSICAgICAgICAgbHBzelNlcnZpY2VEZXNjcmlwdGlvbiA9CiNpZmRlZiBJRkRFU0NSCiAgICAgICAgX1Qo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ZXhpdCAoVW5yZWdpc3RlclNlcnZpY2UobHBzelNlcnZpY2VOYW1lLCBxdWlldCkpOwogICAgICAgIGJyZWFrOwogICAgY2FzZSBSVU5fQVNfU0VSVklDRToKICAgICAgICAvKgogICAgICAgICAqIFJ1biBhcyBzZXJ2aWNlIAogICAgICAgICAqLwogICAgICAgIC8qCiAgICAgICAgICogUmVnaXN0ZXIgU3RvcCBGdW5jdGlvbiAKICAgICAgICAgKi8KICAgICAgICBSZWdpc3RlclN0b3BGdW5jdGlvbihTdG9wU25tcEFnZW50KTsKICAgICAgICByZXR1cm4gUnVuQXNTZXJ2aWNlKFNubXBEYWVtb25NYWluKTsKICAgICAgICBicmVhazsKICAgIGRlZmF1bHQ6CiAgICAgICAgLyoKICAgICAgICAgKiBSdW4gaW4gY29uc29sZSBtb2RlIAogICAgICAgICAqLwogICAgICAgIHJldHVybiBTbm1wRGFlbW9uTWFpbihhcmdjLCBhcmd2KTsKICAgICAgICBicmVhazsKICAgIH0KfQoKLyoKICogVG8gc3RvcCBTbm1wIEFnZW50IGRhZW1vbgogKiBUaGlzIHBvcnRpb24gaXMgc3RpbGwgbm90IHdvcmtpbmcKICovCnZvaWQKU3RvcFNubXBBZ2VudCh2b2lkKQp7CiAgICAvKgogICAgICogU2h1dCBEb3duIEFnZW50IAogICAgICovCiAgICBTbm1wZFNodXREb3duKDEpOwoKICAgIC8qCiAgICAgKiBXYWl0IHRpbGwgYWdlbnQgaXMgY29tcGxldGVseSBzdG9wcGVkIAogICAgICovCgogICAgd2hpbGUgKGFnZW50X3N0YXR1cyAhPSBBR0VOVF9TVE9QUEVEKSB7CiAgICAgICAgU2xlZXAoMTAwKTsKICAgIH0KfQoKI2VuZGlmIC8qV0lOMzJTRVJWSUNFKi8K