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Iga3cKKwkJCQkJd3AtPnF1ZXJ5W2xlbisrXSA9ICcmJzsKKwkJCQkJZ3N0cmNweSgmd3AtPnF1ZXJ5W2xlbl0sIHRleHQpOworCisJCQkJfSBlbHNlIHsKKworICAgICAgICAgICAgICAgLy9pZiAodGV4dCAhPSBOVUxMKS8vZm9yIGt3CisgICAgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgICBsZW4gPSBnc3RybGVuKHdwLT5xdWVyeSk7CisgICAgICAgICAgICAgICAgICB3cC0+cXVlcnkgPSBicmVhbGxvYyhCX0wsIHdwLT5xdWVyeSwgKGxlbiArCWdzdHJsZW4odGV4dCkgKworICAgICAgICAgICAgICAgICAgICAgMSkgKiBzaXplb2YoY2hhcl90KSk7CisgICAgICAgICAgICAgICAgICBpZiAod3AtPnF1ZXJ5KSB7CisgICAgICAgICAgICAgICAgICAgICBnc3RyY3B5KCZ3cC0+cXVlcnlbbGVuXSwgdGV4dCk7CisgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICB9CisJCQkJfQorCisJCQl9IGVsc2UgeworCQkJCXdwLT5xdWVyeSA9IGJzdHJkdXAoQl9MLCB0ZXh0KTsKKwkJCX0KKyNpZiAwIC8vZm9yIGt3CQkJCisgICAgICAgICAgICAvL0FkZCBCeSBsaXV5aW5nbmFuIGZvciBYTUwgQ09NTSBBUEkgU1RBUlQKKyAgICAgICAgICAgIGlmKHdwLT5mbGFncyAmIFdFQlNfWE1MX0NMSUVOVF9SRVFVRVNUKQorICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIHNsb2coTUlTQ19QUklOVCxTTE9HX0RFQlVHLCJbd2Vic1JlYWRFdmVudF06enRlX2NoYW5nZV93cF9xdWVyeSBmdW5jdGlvbjolc1xuIix3ZWJzUmVjdkh0dHBCdWZmZXJfWE1MKTsKKyAgICAgICAgICAgICAgICAvL3p0ZV9jaGFuZ2Vfd3BfcXVlcnkod3Asd2Vic1JlY3ZIdHRwQnVmZmVyX0pzb24pOworICA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GludCBzYWZlTGVuID0gMDsKKyAgIGNoYXJfdCogc2FmZVVybCA9IE5VTEw7CisgICBjaGFyX3QqIHNyYyA9IE5VTEw7CisgICBjaGFyX3QqIGRlc3QgPSBOVUxMOworCisgICBpZiAoTlVMTCAhPSB1cmwpCisgICB7CisgICAgICBzYWZlTGVuID0gZ3N0cmxlbih1cmwpOworICAgICAgaWYgKGx0Q291bnQgPT0gMCAmJiBndENvdW50ID09IDApCisgICAgICB7CisgICAgICAgICBzYWZlVXJsID0gYnN0cmR1cChCX0wsIChjaGFyX3QqKSB1cmwpOworICAgICAgfQorICAgICAgZWxzZQorICAgICAgeworICAgICAgICAgc2FmZUxlbiArPSAobHRDb3VudCAqIDQpOworICAgICAgICAgc2FmZUxlbiArPSAoZ3RDb3VudCAqIDQpOworCisgICAgICAgICBzYWZlVXJsID0gYmFsbG9jKEJfTCwgc2FmZUxlbik7CisgICAgICAgICBpZiAoc2FmZVVybCAhPSBOVUxMKQorICAgICAgICAgeworICAgICAgICAgICAgc3JjID0gKGNoYXJfdCopIHVybDsKKyAgICAgICAgICAgIGRlc3QgPSBzYWZlVXJsOworICAgICAgICAgICAgd2hpbGUgKCpzcmMpCisgICAgICAgICAgICB7CisgICAgICAgICAgICAgICBpZiAoKnNyYyA9PSBrTHQpCisgICAgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgICBnc3RyY3B5KGRlc3QsIGtMZXNzVGhhbik7CisgICAgICAgICAgICAgICAgICBkZXN0ICs9IGdzdHJsZW4oa0xlc3NUaGFuKTsKKyAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgIGVsc2UgaWYgKCpzcmMgPT0ga0d0KQorICAgICAgICAgICAgICAgeworICAgICAgICAgICAgICAgICAgZ3N0cmNweShkZXN0LCBrR3JlYXRlclRoYW4pOworICAgICAgICAgICAgICAgICAgZGVzdCArPSBnc3RybGVuKGtHcmVhdGVyVGhhbik7CisgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICBlbHNlCisgICAgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgICAqZGVzdCsrID0gKnNyYzsKKyAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICsrc3JjOworICAgICAgICAgICAgfQorICAgICAgICAgICAgLyogZG9uJ3QgZm9yZ2V0IHRvIHRlcm1pbmF0ZSB0aGUgc3RyaW5nLi4uKi8KKyAgICAgICAgICAgICpkZXN0ID0gJ1wwJzsKKyAgICAgICAgIH0KKyAgICAgIH0KKyAgIH0KKyAgIHJldHVybiBzYWZlVXJsOworfQorCitzdGF0aWMgaW50IGNoYXJDb3VudChjb25zdCBjaGFyX3QqIHN0ciwgY2hhcl90IGNoKQoreworICAgaW50IGNvdW50ID0gMDsKKyAgIGNoYXJfdCogcCA9IChjaGFyX3QqKSBzdHI7CisgICAKKyAgIGlmIChOVUxMID09IHN0cikKKyAgIHsKKyAgICAgIHJldHVybiAwOworICAgfQorCisgICB3aGlsZSAoMSkKKyAgIHsKKyAgICAgIHAgPSBnc3RyY2hyKHAsIGNoKTsKKyAgICAgIGlmIChOVUxMID09IHApCisgICAgICB7CisgICAgICAgICBicmVhazsKKyAgICAgIH0KKworICAgICAgKytjb3VudDsKKyAgICAgICsrcDsKKyAgIH0KKyAgIHJldHVybiBjb3VudDsKK30KKworCitjaGFyX3QgKndlYnNFcnJvck1zZyhpbnQgY29kZSkKK3sKKwl3ZWJzRXJyb3JUeXBlCSplcDsKKworCWZvciAoZXAgPSB3ZWJzRXJyb3JzOyBlcC0+Y29kZTsgZXArKykgeworCQlpZiAoY29kZSA9PSBlcC0+Y29kZSkgeworCQkJcmV0dXJuIGVwLT5tc2c7CisJCX0KKwl9CisJYV9hc3NlcnQoMCk7CisJcmV0dXJuIFQoIiIpOworfQorCisKKyNpZmRlZiBxUmljaEVycm9yUGFnZQorZXh0ZXJuIGludCBkbWZSaWNoRXJyb3Iod2Vic190IHdwLCBpbnQgY29kZSwgY2hhcl90KiB1c2VyTXNnKTsKKyNlbmRpZgordm9pZC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gPSB6dGVfd2ViX3JlYWQoTlZfTE9HSU5GTywgbG9naW5faW5mbyk7CisKKyAgICBpZigwID09IHN0cmNtcChsb2dpbl9pbmZvLCJvayIpKQorICAgIHsKKworICAgICAgICB6dGVfd2ViX3JlYWQoInVzZXJfbG9naW5fdGltZW1hcmsiLCB1c2VyX2xvZ2luX3RpbWVtYXJrKTsKKworICAgICAgICBsdXNlcl9sb2dpbl90aW1lbWFyayA9IGF0b2wodXNlcl9sb2dpbl90aW1lbWFyayk7CisJCWlmKGx1c2VyX2xvZ2luX3RpbWVtYXJrIDwgMCB8fCBsdXNlcl9sb2dpbl90aW1lbWFyayA+IExPTkdfTUFYLTEpeworICAgICAgICAgICAgbHVzZXJfbG9naW5fdGltZW1hcmsgPSBMT05HX01BWDsKKwkJfQorCQkKKyAgICAgICAgdGltZW1hcmtfY2hlY2sgPSB0aW1lKDApIC0gbHVzZXJfbG9naW5fdGltZW1hcms7ICAKKyAgICAgICAgaWYodGltZW1hcmtfY2hlY2sgPiBMT0dJTl9USU1FT1VUKQorICAgICAgICB7CisgICAgICAgICAgICAodm9pZCl6dGVfd2ViX3dyaXRlKE5WX1VTRVJfSVBfQUREUiwiIik7CisgICAgICAgICAgICAodm9pZCl6dGVfd2ViX3dyaXRlKE5WX0xPR0lORk8sInRpbWVvdXQiKTsKKwkJCSh2b2lkKXp0ZV93ZWJfd3JpdGUoTlZfQ09PS0lFX0lELCAiIik7CisgICAgICAgICAgICAodm9pZCl6dGVfd2ViX3dyaXRlKE5WX1VTRVJfTE9HSU5fVElNRU1BUkssIjAiKTsKKyAgICAgICAgICAgIHNsb2coTUlTQ19QUklOVCxTTE9HX0VSUiwienRlX21nbXRfbG9naW5fdGltZW1hcmtfY2hlY2s6IHRoZSBsb2dpbiBpcyB0aW1lb3V0IC5cbiIpOworICAgICAgICB9CisgICAgICAgIGVsc2UKKyAgICAgICAgeworICAgICAgICAgICAgaXBfYWRkcmVzcyA9IHdlYnNHZXRSZXF1ZXN0SXBhZGRyKHdwKTsKKyNpZiAwCQkgLy8ga3cgMyBJTlZBUklBTlRfQ09ORElUSU9OLlVOUkVBQ0gJICB3cC0+aXBhZGRyIGlzIGFycmF5LCBhZGRyZXNzIGNhbiBub3QgYmUgbnVsbAorICAgICAgICAgICAgaWYgKE5VTEwgPT0gaXBfYWRkcmVzcykKKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICBzbG9nKE1JU0NfUFJJTlQsU0xPR19FUlIsIndlYnNTZXRMb2dpblRpbWVtYXJrOiBpcF9hZGRyZXNzIGlzIG51bGwuXG4iKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gOworICAgICAgICAgICAgfQorI2VuZGlmCisgICAgICAgICAgICB6dGVfd2ViX3JlYWQoTlZfVVNFUl9JUF9BRERSLCBudl9pcGFkZHIpOworICAgICAgICAgICAKKworICAgICAgICAgICAgaWYgKDAgPT0gc3RyY21wKGlwX2FkZHJlc3MsbnZfaXBhZGRyKSkKKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICB0aW1lbWFyayA9IHRpbWUoMCk7CisgICAgICAgICAgICAgICAgc3ByaW50Zihsb2dpbl90aW1lbWFyaywiJWxkIix0aW1lbWFyayk7ICAKKyAgICAgICAgICAgICAgICAodm9pZCl6dGVfd2ViX3dyaXRlKE5WX1VTRVJfTE9HSU5fVElNRU1BUkssIGxvZ2luX3RpbWVtYXJrKTsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgfQorICAgIH0gIAorCit9CisK