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3JlIGRldGFpbHMuCisKKyAgIFlvdSBzaG91bGQgaGF2ZSByZWNlaXZlZCBhIGNvcHkgb2YgdGhlIEdOVSBMZXNzZXIgR2VuZXJhbCBQdWJsaWMKKyAgIExpY2Vuc2UgYWxvbmcgd2l0aCB0aGUgR05VIEMgTGlicmFyeTsgaWYgbm90LCBzZWUKKyAgIDxodHRwOi8vd3d3LmdudS5vcmcvbGljZW5zZXMvPi4gICovCisKKyNpbmNsdWRlIDxhcmd6Lmg+CisjaW5jbHVkZSA8ZXJybm8uaD4KKyNpbmNsdWRlIDxzdGRsaWIuaD4KKyNpbmNsdWRlIDxzdHJpbmcuaD4KKworCitlcnJvcl90CitfX2FyZ3pfYWRkX3NlcCAoY2hhciAqKmFyZ3osIHNpemVfdCAqYXJnel9sZW4sIGNvbnN0IGNoYXIgKnN0cmluZywgaW50IGRlbGltKQoreworICBzaXplX3QgbmxlbiA9IHN0cmxlbiAoc3RyaW5nKSArIDE7CisKKyAgaWYgKG5sZW4gPiAxKQorICAgIHsKKyAgICAgIGNvbnN0IGNoYXIgKnJwOworICAgICAgY2hhciAqd3A7CisKKyAgICAgICphcmd6ID0gKGNoYXIgKikgcmVhbGxvYyAoKmFyZ3osICphcmd6X2xlbiArIG5sZW4pOworICAgICAgaWYgKCphcmd6ID09IE5VTEwpCisJcmV0dXJuIEVOT01FTTsKKworICAgICAgd3AgPSAqYXJneiArICphcmd6X2xlbjsKKyAgICAgIHJwID0gc3RyaW5nOworICAgICAgZG8KKwlpZiAoKnJwID09IGRlbGltKQorCSAgeworCSAgICBpZiAod3AgPiAqYXJneiAmJiB3cFstMV0gIT0gJ1wwJykKKwkgICAgICAqd3ArKyA9ICdcMCc7CisJICAgIGVsc2UKKwkgICAgICAtLW5sZW47CisJICB9CisJZWxzZQorCSAgKndwKysgPSAqcnA7CisgICAgICB3aGlsZSAoKnJwKysgIT0gJ1wwJyk7CisKKyAgICAgICphcmd6X2xlbiArPSBubGVuOworICAgIH0KKworICByZXR1cm4g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ZWRfY29weSkKKwkJICAgIC8qIFdlIGF2b2lkZWQgY29weWluZyBTUkMgdG8gRFNUIHVudGlsIHdlIGZvdW5kIGEgbWF0Y2g7CisgICAgICAgICAgICAgICAgICAgICAgIG5vdyB0aGF0IHdlJ3ZlIGRvbmUgc28sIGNvcHkgZXZlcnl0aGluZyBmcm9tIHRoZSBzdGFydAorICAgICAgICAgICAgICAgICAgICAgICBvZiBTUkMuICAqLworCQkgICAgeworCQkgICAgICBpZiAoYXJnID4gc3JjKQorCQkJZXJyID0gX19hcmd6X2FwcGVuZCAoJmRzdCwgJmRzdF9sZW4sIHNyYywgKGFyZyAtIHNyYykpOworCQkgICAgICBkZWxheWVkX2NvcHkgPSAwOworCQkgICAgfQorCQkgIGlmICghIGVycikKKwkJICAgIGVyciA9IF9fYXJnel9hZGQgKCZkc3QsICZkc3RfbGVuLCB0byk7CisJCSAgZnJlZSAodG8pOworCQl9CisJICAgICAgZWxzZQorCQllcnIgPSBFTk9NRU07CisKKwkgICAgICBpZiAocmVwbGFjZV9jb3VudCkKKwkJKCpyZXBsYWNlX2NvdW50KSsrOworCSAgICB9CisJICBlbHNlIGlmICghIGRlbGF5ZWRfY29weSkKKwkgICAgZXJyID0gX19hcmd6X2FkZCAoJmRzdCwgJmRzdF9sZW4sIGFyZyk7CisJfQorCisgICAgICBpZiAoISBlcnIpCisJeworCSAgaWYgKCEgZGVsYXllZF9jb3B5KQorCSAgICAvKiBXZSBuZXZlciBmb3VuZCBhbnkgaW5zdGFuY2VzIG9mIHN0ci4gICovCisJICAgIHsKKwkgICAgICBmcmVlIChzcmMpOworCSAgICAgICphcmd6ID0gZHN0OworCSAgICAgICphcmd6X2xlbiA9IGRzdF9sZW47CisJICAgIH0KKwl9CisgICAgICBlbHNlIGlmIChkc3RfbGVuID4gMCkKKwlmcmVlIChkc3QpOworICAgIH0KKworICByZXR1cm4gZXJyOworfQord2Vha19hbGlhcyAoX19hcmd6X3JlcGxhY2UsIGFyZ3pfcmVwbGFjZS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ZXQgKHMsIGMsIG4pKSkpCisKKyMgICBkZWZpbmUgX19tZW1zZXRfMShzLCBjKSAoeyB2b2lkICpfX3MgPSAocyk7CQkJCSAgICAgIFwKKwkJCSAgICAqKChfX3VpbnQ4X3QgKikgX19zKSA9IChfX3VpbnQ4X3QpIGM7IF9fczsgfSkKKworIyAgIGRlZmluZSBfX21lbXNldF9nYyhzLCBjLCBuKSBcCisgICh7IHZvaWQgKl9fcyA9IChzKTsJCQkJCQkJICAgICAgXAorICAgICB1bmlvbiB7CQkJCQkJCQkgICAgICBcCisgICAgICAgdW5zaWduZWQgaW50IF9fdWk7CQkJCQkJICAgICAgXAorICAgICAgIHVuc2lnbmVkIHNob3J0IGludCBfX3VzaTsJCQkJCSAgICAgIFwKKyAgICAgICB1bnNpZ25lZCBjaGFyIF9fdWM7CQkJCQkJICAgICAgXAorICAgICB9ICpfX3UgPSBfX3M7CQkJCQkJCSAgICAgIFwKKyAgICAgX191aW50OF90IF9fYyA9IChfX3VpbnQ4X3QpIChjKTsJCQkJCSAgICAgIFwKKwkJCQkJCQkJCSAgICAgIFwKKyAgICAgLyogVGhpcyBgc3dpdGNoJyBzdGF0ZW1lbnQgd2lsbCBiZSByZW1vdmVkIGF0IGNvbXBpbGUtdGltZS4gICovCSAgICAgIFwKKyAgICAgc3dpdGNoICgodW5zaWduZWQgaW50KSAobikpCQkJCQkgICAgICBcCisgICAgICAgewkJCQkJCQkJICAgICAgXAorICAgICAgIGNhc2UgMTU6CQkJCQkJCQkgICAgICBcCisJIF9fdS0+X191aSA9IF9fYyAqIDB4MDEwMTAxMDE7CQkJCQkgICAgICBcCisJIF9fdSA9IF9fZXh0ZW5zaW9uX18gKCh2b2lkICopIF9fdSArIDQpOwkJCSAgICAgIFwKKyAgICAgICBjYXNlIDExOgkJCQkJCQkJICAgICAgXAorCSBfX3UtPl9fdWkgPSBfX2MgKiAweDAxMDEwMTAxOwkJCQkJICAgICAgXAorCSBfX3UgPSBfX2V4dGVuc2lvbl9fICgodm9pZCAqKSBfX3UgKyA0KTsJCQkgICAgICBcCisgICAgICAgY2FzZSA3OgkJCQkJCQkJICAgICAgXAorCSBfX3UtPl9fdWkgPSBfX2MgKiAweDAxMDEwMTAxOwkJCQkJICAgICAgXAorCSBfX3UgPSBfX2V4dGVuc2lvbl9fICgodm9pZCAqKSBfX3UgKyA0KTsJCQkgICAgICBcCisgICAgICAgY2FzZSAzOgkJCQkJCQkJICAgICAgXAorCSBfX3UtPl9fdXNpID0gKHVuc2lnbmVkIHNob3J0IGludCkgX19jICogMHgwMTAxOwkJICAgICAgXAorCSBfX3UgPSBfX2V4dGVuc2lvbl9fICgodm9pZCAqKSBfX3UgKyAyKTsJCQkgICAgICBcCisJIF9fdS0+X191YyA9ICh1bnNpZ25lZCBjaGFyKSBfX2M7CQkJCSAgICAgIFwKKwkgYnJlYWs7CQkJCQkJCQkgICAgICBcCisJCQkJCQkJCQkgICAgICBcCisgICAgICAgY2FzZSAxNDoJCQkJCQkJCSAgICAgIFwKKwkgX191LT5fX3VpID0gX19jICogMHgwMTAxMDEwMTsJCQkJCSAgICAgIFwKKwkgX191ID0gX19leHRlbnNpb25fXyAoKHZvaWQgKikgX191ICsgNCk7CQkJICAgICAgXAorICAgICAgIGNhc2UgMTA6CQkJCQkJCQkgICAgICBcCisJIF9fdS0+X191aSA9IF9fYyAqIDB4MDEwMTAxMDE7CQkJCQkgICAgICBcCisJIF9fdSA9IF9fZXh0ZW5zaW9uX18gKCh2b2lkICopIF9fdSArIDQpOwkJCSAgICAgIFwKKyAgICAgICBjYXNlIDY6CQkJCQkJCQkgICAgICBcCisJIF9fdS0+X191aSA9IF9fYyAqIDB4MDEwMTAxMDE7CQkJCQkgICAgICBcCisJIF9fdSA9IF9fZXh0ZW5zaW9uX18gKCh2b2lkICopIF9fdSArIDQpOwkJCSAgICAgIFwKKyAgICAgICBjYXNlIDI6CQkJCQkJCQkgICAgICBcCisJIF9fdS0+X191c2kgPSAodW5zaWduZWQgc2hvcnQgaW50KSBfX2MgKiAweDAxMDE7CQkgICAgICBcCisJIGJyZWFrOwkJCQkJCQkJICAgICAgXAorCQkJCQkJCQkJICAgICAgXAorICAgICAgIGNhc2UgMTM6CQkJCQkJCQkgICAgICBcCisJIF9fdS0+X191aSA9IF9fYyAqIDB4MDEwMTAxMDE7CQkJCQkgICAgICBcCisJIF9fdSA9IF9fZXh0ZW5zaW9uX18gKCh2b2lkICopIF9fdSArIDQpOwkJCSAgICAgIFwKKyAgICAgICBjYXNlIDk6CQkJCQkJCQkgICAgICBcCisJIF9fdS0+X191aSA9IF9fYyAqIDB4MDEwMTAxMDE7CQkJCQkgICAgICBcCisJIF9fdSA9IF9fZXh0ZW5zaW9uX18gKCh2b2lkICopIF9fdSArIDQpOwkJCSAgICAgIFwKKyAgICAgICBjYXNlIDU6CQkJCQkJCQkgICAgICBcCisJIF9fdS0+X191aSA9IF9fYyAqIDB4MDEwMTAxMDE7CQkJCQkgICAgICBcCisJIF9fdSA9IF9fZXh0ZW5zaW9uX18gKCh2b2lkICopIF9fdSArIDQpOwkJCSAgICAgIFwKKyAgICAgICBjYXNlIDE6CQkJCQkJCQkgICAgICBcCisJIF9fdS0+X191YyA9ICh1bnNpZ25lZCBjaGFyKSBfX2M7CQkJCSAgICAgIFwKKwkgYnJlYWs7CQkJCQkJCQkgICAgICBcCisJCQkJCQkJCQkgICAgICBcCisgICAgICAgY2FzZSAxNjoJCQkJCQkJCSAgICAgIFwKKwkgX191LT5fX3VpID0gX19jICogMHgwMTAxMDEwMTsJCQkJCSAgICAgIFwKKwkgX191ID0gX19leHRlbnNpb25fXyAoKHZvaWQgKikgX191ICsgNCk7CQkJICAgICAgXAorICAgICAgIGNhc2UgMTI6CQkJCQkJCQkgICAgICBcCisJIF9fdS0+X191aSA9IF9fYyAqIDB4MDEwMTAxMDE7CQkJCQkgICAgICBcCisJIF9fdSA9IF9fZXh0ZW5zaW9uX18gKCh2b2lkICopIF9fdSArIDQpOwkJCSAgICAgIFwKKyAgICAgICBj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19TVFJJTkcyX1NNQUxMX0dFVDMyIChzcmMsIDQpCisjICAgIGVuZGlmCitfX1NUUklOR19JTkxJTkUgdm9pZCAqX19tZW1wY3B5X3NtYWxsICh2b2lkICosIGNoYXIsIGNoYXIsIGNoYXIsIGNoYXIsCisJCQkJICAgICAgIF9fdWludDE2X3QsIF9fdWludDE2X3QsIF9fdWludDMyX3QsCisJCQkJICAgICAgIF9fdWludDMyX3QsIHNpemVfdCk7CitfX1NUUklOR19JTkxJTkUgdm9pZCAqCitfX21lbXBjcHlfc21hbGwgKHZvaWQgKl9fZGVzdDEsCisJCSBjaGFyIF9fc3JjMF8xLCBjaGFyIF9fc3JjMl8xLCBjaGFyIF9fc3JjNF8xLCBjaGFyIF9fc3JjNl8xLAorCQkgX191aW50MTZfdCBfX3NyYzBfMiwgX191aW50MTZfdCBfX3NyYzRfMiwKKwkJIF9fdWludDMyX3QgX19zcmMwXzQsIF9fdWludDMyX3QgX19zcmM0XzQsCisJCSBzaXplX3QgX19zcmNsZW4pCit7CisgIHVuaW9uIHsKKyAgICBfX3VpbnQzMl90IF9fdWk7CisgICAgX191aW50MTZfdCBfX3VzaTsKKyAgICB1bnNpZ25lZCBjaGFyIF9fdWM7CisgICAgdW5zaWduZWQgY2hhciBfX2M7CisgIH0gKl9fdSA9IF9fZGVzdDE7CisgIHN3aXRjaCAoKHVuc2lnbmVkIGludCkgX19zcmNsZW4pCisgICAgeworICAgIGNhc2UgMToKKyAgICAgIF9fdS0+X19jID0gX19zcmMwXzE7CisgICAgICBfX3UgPSBfX2V4dGVuc2lvbl9fICgodm9pZCAqKSBfX3UgKyAxKTsKKyAgICAgIGJyZWFrOworICAgIGNhc2UgMjoKKyAgICAgIF9fdS0+X191c2kgPSBfX3NyYzBfMjsKKyAgICAgIF9fdSA9IF9fZXh0ZW5zaW9uX18gKCh2b2lkICopIF9fdSArIDIpOworICAgICAgYnJlYWs7CisgICAgY2FzZSAzOgorICAgICAgX191LT5fX3VzaSA9IF9fc3JjMF8yOworICAgICAgX191ID0gX19leHRlbnNpb25fXyAoKHZvaWQgKikgX191ICsgMik7CisgICAgICBfX3UtPl9fYyA9IF9fc3JjMl8xOworICAgICAgX191ID0gX19leHRlbnNpb25fXyAoKHZvaWQgKikgX191ICsgMSk7CisgICAgICBicmVhazsKKyAgICBjYXNlIDQ6CisgICAgICBfX3UtPl9fdWkgPSBfX3NyYzBfNDsKKyAgICAgIF9fdSA9IF9fZXh0ZW5zaW9uX18gKCh2b2lkICopIF9fdSArIDQpOworICAgICAgYnJlYWs7CisgICAgY2FzZSA1OgorICAgICAgX191LT5fX3VpID0gX19zcmMwXzQ7CisgICAgICBfX3UgPSBfX2V4dGVuc2lvbl9fICgodm9pZCAqKSBfX3UgKyA0KTsKKyAgICAgIF9fdS0+X19jID0gX19zcmM0XzE7CisgICAgICBfX3UgPSBfX2V4dGVuc2lvbl9fICgodm9pZCAqKSBfX3UgKyAxKTsKKyAgICAgIGJyZWFrOworICAgIGNhc2UgNjoKKyAgICAgIF9fdS0+X191aSA9IF9fc3JjMF80OworICAgICAgX191ID0gX19leHRlbnNpb25fXyAoKHZvaWQgKikgX191ICsgNCk7CisgICAgICBfX3UtPl9fdXNpID0gX19zcmM0XzI7CisgICAgICBfX3UgPSBfX2V4dGVuc2lvbl9fICgodm9pZCAqKSBfX3UgKyAyKTsKKyAgICAgIGJyZWFrOworICAgIGNhc2UgNzoKKyAgICAgIF9fdS0+X191aSA9IF9fc3JjMF80OworICAgICAgX191ID0gX19leHRlbnNpb25fXyAoKHZvaWQgKikgX191ICsgNCk7CisgICAgICBfX3UtPl9fdXNpID0gX19zcmM0XzI7CisgICAgICBfX3UgPSBfX2V4dGVuc2lvbl9fICgodm9pZCAqKSBfX3UgKyAyKTsKKyAgICAgIF9fdS0+X19jID0gX19zcmM2XzE7CisgICAgICBfX3UgPSBfX2V4dGVuc2lvbl9fICgodm9pZCAqKSBfX3UgKyAxKTsKKyAgICAgIGJyZWFrOworICAgIGNhc2UgODoKKyAgICAgIF9fdS0+X191aSA9IF9fc3JjMF80OworICAgICAgX191ID0gX19leHRlbnNpb25fXyAoKHZvaWQgKikgX191ICsgNCk7CisgICAgICBfX3UtPl9fdWkgPSBfX3NyYzRfNDsKKyAgICAgIF9fdSA9IF9fZXh0ZW5zaW9uX18gKCh2b2lkICopIF9fdSArIDQpOworICAgICAgYnJlYWs7CisgICAgfQorICByZXR1cm4gKHZvaWQgKikgX191OworfQorIyAgIGVsc2UKKyMgICAgaWZuZGVmIF9GT1JDRV9JTkxJTkVTCisjICAgICBkZWZpbmUgX19tZW1wY3B5X2FyZ3Moc3JjKSBcCisgICAgICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMF0sCQkJCQkJICAgICAgXAorICAgICBfX2V4dGVuc2lvbl9fICgoX19TVFJJTkcyX0NPUFlfQVJSMikJCQkJICAgICAgXAorICAgICAgeyB7ICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMF0sICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMV0gfSB9KSwJICAgICAgXAorICAgICBfX2V4dGVuc2lvbl9fICgoX19TVFJJTkcyX0NPUFlfQVJSMykJCQkJICAgICAgXAorICAgICAgeyB7ICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMF0sICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMV0sCQkgICAgICBcCisJICAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzJdIH0gfSksCQkJCSAgICAgIFwKKyAgICAgX19leHRlbnNpb25fXyAoKF9fU1RSSU5HMl9DT1BZX0FSUjQpCQkJCSAgICAgIFwKKyAgICAgIHsgeyAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzBdLCAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzFdLAkJICAgICAgXAorCSAgKChjb25zdCBjaGFyICopIChzcmMpKVsyXSwgKChjb25zdCBjaGFyICopIChzcmMpKVszXSB9IH0pLAkgICAgICBcCisgICAgIF9fZXh0ZW5zaW9uX18gKChfX1NUUklORzJfQ09QWV9BUlI1KQkJCQkgICAgICBcCisgICAgICB7IHsgKChjb25zdCBjaGFyICopIChzcmMpKVswXSwgKChjb25zdCBjaGFyICopIChzcmMpKVsxXSwJCSAgICAgIFwKKwkgICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMl0sICgoY29uc3QgY2hhciAqKSAoc3JjKSlbM10sCQkgICAgICBcCisJICAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzRdIH0gfSksCQkJCSAgICAgIFwKKyAgICAgX19leHRlbnNpb25fXyAoKF9fU1RSSU5HMl9DT1BZX0FSUjYpCQkJCSAgICAgIFwKKyAgICAgIHsgeyAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzBdLCAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzFdLAkJICAgICAgXAorCSAgKChjb25zdCBjaGFyICopIChzcmMpKVsyXSwgKChjb25zdCBjaGFyICopIChzcmMpKVszXSwJCSAgICAgIFwKKwkgICgoY29uc3QgY2hhciAqKSAoc3JjKSlbNF0sICgoY29uc3QgY2hhciAqKSAoc3JjKSlbNV0gfSB9KSwJICAgICAgXAorICAgICBfX2V4dGVuc2lvbl9fICgoX19TVFJJTkcyX0NPUFlfQVJSNykJCQkJICAgICAgXAorICAgICAgeyB7ICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMF0sICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMV0sCQkgICAgICBcCisJICAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzJdLCAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzNdLAkJICAgICAgXAorCSAgKChjb25zdCBjaGFyICopIChzcmMpKVs0XSwgKChjb25zdCBjaGFyICopIChzcmMpKVs1XSwJCSAgICAgIFwKKwkgICgoY29uc3QgY2hhciAqKSAoc3JjKSlbNl0gfSB9KSwJCQkJICAgICAgXAorICAgICBfX2V4dGVuc2lvbl9fICgoX19TVFJJTkcyX0NPUFlfQVJSOCkJCQkJICAgICAgXAorICAgICAgeyB7ICgoY29uc3QgY2hhciAq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KK3sKKyAgdW5pb24geworICAgIGNoYXIgX19jOworICAgIF9fU1RSSU5HMl9DT1BZX0FSUjIgX19zY2EyOworICAgIF9fU1RSSU5HMl9DT1BZX0FSUjMgX19zY2EzOworICAgIF9fU1RSSU5HMl9DT1BZX0FSUjQgX19zY2E0OworICAgIF9fU1RSSU5HMl9DT1BZX0FSUjUgX19zY2E1OworICAgIF9fU1RSSU5HMl9DT1BZX0FSUjYgX19zY2E2OworICAgIF9fU1RSSU5HMl9DT1BZX0FSUjcgX19zY2E3OworICAgIF9fU1RSSU5HMl9DT1BZX0FSUjggX19zY2E4OworICB9ICpfX3UgPSBfX2Rlc3Q7CisgIHN3aXRjaCAoKHVuc2lnbmVkIGludCkgX19zcmNsZW4pCisgICAgeworICAgIGNhc2UgMToKKyAgICAgIF9fdS0+X19jID0gX19zcmMxOworICAgICAgYnJlYWs7CisgICAgY2FzZSAyOgorICAgICAgX19leHRlbnNpb25fXyBfX3UtPl9fc2NhMiA9IF9fc3JjMjsKKyAgICAgIGJyZWFrOworICAgIGNhc2UgMzoKKyAgICAgIF9fZXh0ZW5zaW9uX18gX191LT5fX3NjYTMgPSBfX3NyYzM7CisgICAgICBicmVhazsKKyAgICBjYXNlIDQ6CisgICAgICBfX2V4dGVuc2lvbl9fIF9fdS0+X19zY2E0ID0gX19zcmM0OworICAgICAgYnJlYWs7CisgICAgY2FzZSA1OgorICAgICAgX19leHRlbnNpb25fXyBfX3UtPl9fc2NhNSA9IF9fc3JjNTsKKyAgICAgIGJyZWFrOworICAgIGNhc2UgNjoKKyAgICAgIF9fZXh0ZW5zaW9uX18gX191LT5fX3NjYTYgPSBfX3NyYzY7CisgICAgICBicmVhazsKKyAgICBjYXNlIDc6CisgICAgICBfX2V4dGVuc2lvbl9fIF9fdS0+X19zY2E3ID0gX19zcmM3OworICAgICAgYnJlYWs7CisgICAgY2FzZSA4OgorICAgICAgX19leHRlbnNpb25fXyBfX3UtPl9fc2NhOCA9IF9fc3JjODsKKyAgICAgIG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kxJTkUgY2hhciAqCitfX3N0cmNweV9zbWFsbCAoY2hhciAqX19kZXN0LAorCQlfX3VpbnQxNl90IF9fc3JjMF8yLCBfX3VpbnQxNl90IF9fc3JjNF8yLAorCQlfX3VpbnQzMl90IF9fc3JjMF80LCBfX3VpbnQzMl90IF9fc3JjNF80LAorCQlzaXplX3QgX19zcmNsZW4pCit7CisgIHVuaW9uIHsKKyAgICBfX3VpbnQzMl90IF9fdWk7CisgICAgX191aW50MTZfdCBfX3VzaTsKKyAgICB1bnNpZ25lZCBjaGFyIF9fdWM7CisgIH0gKl9fdSA9ICh2b2lkICopIF9fZGVzdDsKKyAgc3dpdGNoICgodW5zaWduZWQgaW50KSBfX3NyY2xlbikKKyAgICB7CisgICAgY2FzZSAxOgorICAgICAgX191LT5fX3VjID0gJ1wwJzsKKyAgICAgIGJyZWFrOworICAgIGNhc2UgMjoKKyAgICAgIF9fdS0+X191c2kgPSBfX3NyYzBfMjsKKyAgICAgIGJyZWFrOworICAgIGNhc2UgMzoKKyAgICAgIF9fdS0+X191c2kgPSBfX3NyYzBfMjsKKyAgICAgIF9fdSA9IF9fZXh0ZW5zaW9uX18gKCh2b2lkICopIF9fdSArIDIpOworICAgICAgX191LT5fX3VjID0gJ1wwJzsKKyAgICAgIGJyZWFrOworICAgIGNhc2UgNDoKKyAgICAgIF9fdS0+X191aSA9IF9fc3JjMF80OworICAgICAgYnJlYWs7CisgICAgY2FzZSA1OgorICAgICAgX191LT5fX3VpID0gX19zcmMwXzQ7CisgICAgICBfX3UgPSBfX2V4dGVuc2lvbl9fICgodm9pZCAqKSBfX3UgKyA0KTsKKyAgICAgIF9fdS0+X191YyA9ICdcMCc7CisgICAgICBicmVhazsKKyAgICBjYXNlIDY6CisgICAgICBfX3UtPl9fdWkgPSBfX3NyYzBfNDsKKyAgICAgIF9fdSA9IF9fZXh0ZW5zaW9uX18gKCh2b2lkICopIF9fdSArIDQpOworICAgICAgX191LT5fX3VzaSA9IF9fc3JjNF8yOworICAgICAgYnJlYWs7CisgICAgY2FzZSA3OgorICAgICAgX191LT5fX3VpID0gX19zcmMwXzQ7CisgICAgICBfX3UgPSBfX2V4dGVuc2lvbl9fICgodm9pZCAqKSBfX3UgKyA0KTsKKyAgICAgIF9fdS0+X191c2kgPSBfX3NyYzRfMjsKKyAgICAgIF9fdSA9IF9fZXh0ZW5zaW9uX18gKCh2b2lkICopIF9fdSArIDIpOworICAgICAgX191LT5fX3VjID0gJ1wwJzsKKyAgICAgIGJyZWFrOworICAgIGNhc2UgODoKKyAgICAgIF9fdS0+X191aSA9IF9fc3JjMF80OworICAgICAgX191ID0gX19leHRlbnNpb25fXyAoKHZvaWQgKikgX191ICsgNCk7CisgICAgICBfX3UtPl9fdWkgPSBfX3NyYzRfNDsKKyAgICAgIGJyZWFrOworICAgIH0KKyAgcmV0dXJuIF9fZGVzdDsKK30KKyMgZWxzZQorIyAgaWZuZGVmIF9GT1JDRV9JTkxJTkVTCisjICAgZGVmaW5lIF9fc3RyY3B5X2FyZ3Moc3JjKSBcCisgICAgIF9fZXh0ZW5zaW9uX18gKChfX1NUUklORzJfQ09QWV9BUlIyKQkJCQkgICAgICBcCisgICAgICB7IHsgKChjb25zdCBjaGFyICopIChzcmMpKVswXSwgJ1wwJyB9IH0pLAkJCQkgICAgICBcCisgICAgIF9fZXh0ZW5zaW9uX18gKChfX1NUUklORzJfQ09QWV9BUlIzKQkJCQkgICAgICBcCisgICAgICB7IHsgKChjb25zdCBjaGFyICopIChzcmMpKVswXSwgKChjb25zdCBjaGFyICopIChzcmMpKVsxXSwJCSAgICAgIFwKKwkgICdcMCcgfSB9KSwJCQkJCQkJICAgICAgXAorICAgICBfX2V4dGVuc2lvbl9fICgoX19TVFJJTkcyX0NPUFlfQVJSNCkJCQkJICAgICAgXAorICAgICAgeyB7ICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMF0sICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMV0sCQkgICAgICBcCisJICAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzJdLCAnXDAnIH0gfSksCQkJCSAgICAgIFwKKyAgICAgX19leHRlbnNpb25fXyAoKF9fU1RSSU5HMl9DT1BZX0FSUjUpCQkJCSAgICAgIFwKKyAgICAgIHsgeyAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzBdLCAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzFdLAkJICAgICAgXAorCSAgKChjb25zdCBjaGFyICopIChzcmMpKVsyXSwgKChjb25zdCBjaGFyICopIChzcmMpKVszXSwJCSAgICAgIFwKKwkgICdcMCcgfSB9KSwJCQkJCQkJICAgICAgXAorICAgICBfX2V4dGVuc2lvbl9fICgoX19TVFJJTkcyX0NPUFlfQVJSNikJCQkJICAgICAgXAorICAgICAgeyB7ICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMF0sICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMV0sCQkgICAgICBcCisJICAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzJdLCAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzNdLAkJICAgICAgXAorCSAgKChjb25zdCBjaGFyICopIChzcmMpKVs0XSwgJ1wwJyB9IH0pLAkJCQkgICAgICBcCisgICAgIF9fZXh0ZW5zaW9uX18gKChfX1NUUklORzJfQ09QWV9BUlI3KQkJCQkgICAgICBcCisgICAgICB7IHsgKChjb25zdCBjaGFyICopIChzcmMpKVswXSwgKChjb25zdCBjaGFyICopIChzcmMpKVsxXSwJCSAgICAgIFwKKwkgICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMl0sICgoY29uc3QgY2hhciAqKSAoc3JjKSlbM10sCQkgICAgICBcCisJICAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzRdLCAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzVdLAkJICAgICAgXAorCSAgJ1wwJyB9IH0pLAkJCQkJCQkgICAgICBcCisgICAgIF9fZXh0ZW5zaW9uX18gKChfX1NUUklORzJfQ09QWV9BUlI4KQkJCQkgICAgICBcC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ICAgX19TVFJJTkcyX0NPUFlfQVJSMiBfX3NjYTI7CisgICAgX19TVFJJTkcyX0NPUFlfQVJSMyBfX3NjYTM7CisgICAgX19TVFJJTkcyX0NPUFlfQVJSNCBfX3NjYTQ7CisgICAgX19TVFJJTkcyX0NPUFlfQVJSNSBfX3NjYTU7CisgICAgX19TVFJJTkcyX0NPUFlfQVJSNiBfX3NjYTY7CisgICAgX19TVFJJTkcyX0NPUFlfQVJSNyBfX3NjYTc7CisgICAgX19TVFJJTkcyX0NPUFlfQVJSOCBfX3NjYTg7CisgIH0gKl9fdSA9ICh2b2lkICopIF9fZGVzdDsKKyAgc3dpdGNoICgodW5zaWduZWQgaW50KSBfX3NyY2xlbikKKyAgICB7CisgICAgY2FzZSAxOgorICAgICAgX191LT5fX2MgPSAnXDAnOworICAgICAgYnJlYWs7CisgICAgY2FzZSAyOgorICAgICAgX19leHRlbnNpb25fXyBfX3UtPl9fc2NhMiA9IF9fc3JjMjsKKyAgICAgIGJyZWFrOworICAgIGNhc2UgMzoKKyAgICAgIF9fZXh0ZW5zaW9uX18gX191LT5fX3NjYTMgPSBfX3NyYzM7CisgICAgICBicmVhazsKKyAgICBjYXNlIDQ6CisgICAgICBfX2V4dGVuc2lvbl9fIF9fdS0+X19zY2E0ID0gX19zcmM0OworICAgICAgYnJlYWs7CisgICAgY2FzZSA1OgorICAgICAgX19leHRlbnNpb25fXyBfX3UtPl9fc2NhNSA9IF9fc3JjNTsKKyAgICAgIGJyZWFrOworICAgIGNhc2UgNjoKKyAgICAgIF9fZXh0ZW5zaW9uX18gX191LT5fX3NjYTYgPSBfX3NyYzY7CisgICAgICBicmVhazsKKyAgICBjYXNlIDc6CisgICAgICBfX2V4dGVuc2lvbl9fIF9fdS0+X19zY2E3ID0gX19zcmM3OworICAgICAgYnJlYWs7CisgICAgY2FzZSA4OgorICAgICAgX19leHRlbnNpb25fXyBfX3UtPl9fc2NhOCA9IF9fc3JjODsKKyAgICAgIGJyZWFrOworICB9CisgIHJld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1NUUklOR19JTkxJTkUgY2hhciAqX19zdHBjcHlfc21hbGwgKGNoYXIgKiwgX191aW50MTZfdCwgX191aW50MTZfdCwKKwkJCQkgICAgICBfX3VpbnQzMl90LCBfX3VpbnQzMl90LCBzaXplX3QpOworX19TVFJJTkdfSU5MSU5FIGNoYXIgKgorX19zdHBjcHlfc21hbGwgKGNoYXIgKl9fZGVzdCwKKwkJX191aW50MTZfdCBfX3NyYzBfMiwgX191aW50MTZfdCBfX3NyYzRfMiwKKwkJX191aW50MzJfdCBfX3NyYzBfNCwgX191aW50MzJfdCBfX3NyYzRfNCwKKwkJc2l6ZV90IF9fc3JjbGVuKQoreworICB1bmlvbiB7CisgICAgdW5zaWduZWQgaW50IF9fdWk7CisgICAgdW5zaWduZWQgc2hvcnQgaW50IF9fdXNpOworICAgIHVuc2lnbmVkIGNoYXIgX191YzsKKyAgICBjaGFyIF9fYzsKKyAgfSAqX191ID0gKHZvaWQgKikgX19kZXN0OworICBzd2l0Y2ggKCh1bnNpZ25lZCBpbnQpIF9fc3JjbGVuKQorICAgIHsKKyAgICBjYXNlIDE6CisgICAgICBfX3UtPl9fdWMgPSAnXDAnOworICAgICAgYnJlYWs7CisgICAgY2FzZSAyOgorICAgICAgX191LT5fX3VzaSA9IF9fc3JjMF8yOworICAgICAgX191ID0gX19leHRlbnNpb25fXyAoKHZvaWQgKikgX191ICsgMSk7CisgICAgICBicmVhazsKKyAgICBjYXNlIDM6CisgICAgICBfX3UtPl9fdXNpID0gX19zcmMwXzI7CisgICAgICBfX3UgPSBfX2V4dGVuc2lvbl9fICgodm9pZCAqKSBfX3UgKyAyKTsKKyAgICAgIF9fdS0+X191YyA9ICdcMCc7CisgICAgICBicmVhazsKKyAgICBjYXNlIDQ6CisgICAgICBfX3UtPl9fdWkgPSBfX3NyYzBfNDsKKyAgICAgIF9fdSA9IF9fZXh0ZW5zaW9uX18gKCh2b2lkICopIF9fdSArIDMpOworICAgICAgYnJlYWs7CisgICAgY2FzZSA1OgorICAgICAgX191LT5fX3VpID0gX19zcmMwXzQ7CisgICAgICBfX3UgPSBfX2V4dGVuc2lvbl9fICgodm9pZCAqKSBfX3UgKyA0KTsKKyAgICAgIF9fdS0+X191YyA9ICdcMCc7CisgICAgICBicmVhazsKKyAgICBjYXNlIDY6CisgICAgICBfX3UtPl9fdWkgPSBfX3NyYzBfNDsKKyAgICAgIF9fdSA9IF9fZXh0ZW5zaW9uX18gKCh2b2lkICopIF9fdSArIDQpOworICAgICAgX191LT5fX3VzaSA9IF9fc3JjNF8yOworICAgICAgX191ID0gX19leHRlbnNpb25fXyAoKHZvaWQgKikgX191ICsgMSk7CisgICAgICBicmVhazsKKyAgICBjYXNlIDc6CisgICAgICBfX3UtPl9fdWkgPSBfX3NyYzBfNDsKKyAgICAgIF9fdSA9IF9fZXh0ZW5zaW9uX18gKCh2b2lkICopIF9fdSArIDQpOworICAgICAgX191LT5fX3VzaSA9IF9fc3JjNF8yOworICAgICAgX191ID0gX19leHRlbnNpb25fXyAoKHZvaWQgKikgX191ICsgMik7CisgICAgICBfX3UtPl9fdWMgPSAnXDAnOworICAgICAgYnJlYWs7CisgICAgY2FzZSA4OgorICAgICAgX191LT5fX3VpID0gX19zcmMwXzQ7CisgICAgICBfX3UgPSBfX2V4dGVuc2lvbl9fICgodm9pZCAqKSBfX3UgKyA0KTsKKyAgICAgIF9fdS0+X191aSA9IF9fc3JjNF80OworICAgICAgX191ID0gX19leHRlbnNpb25fXyAoKHZvaWQgKikgX191ICsgMyk7CisgICAgICBicmVhazsKKyAgICB9CisgIHJldHVybiAmX191LT5fX2M7Cit9CisjICAgZWxzZQorIyAgICBpZm5kZWYgX0ZPUkNFX0lOTElORVMKKyMgICAgIGRlZmluZSBfX3N0cGNweV9hcmdzKHNyYykgXAorICAgICBfX2V4dGVuc2lvbl9fICgoX19TVFJJTkcyX0NPUFlfQVJSMikJCQkJICAgICAgXAorICAgICAgeyB7ICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMF0sICdcMCcgfSB9KSwJCQkJICAgICAgXAorICAgICBfX2V4dGVuc2lvbl9fICgoX19TVFJJTkcyX0NPUFlfQVJSMykJCQkJICAgICAgXAorICAgICAgeyB7ICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMF0sICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMV0sCQkgICAgICBcCisJICAnXDAnIH0gfSksCQkJCQkJCSAgICAgIFwKKyAgICAgX19leHRlbnNpb25fXyAoKF9fU1RSSU5HMl9DT1BZX0FSUjQpCQkJCSAgICAgIFwKKyAgICAgIHsgeyAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzBdLCAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzFdLAkJICAgICAgXAorCSAgKChjb25zdCBjaGFyICopIChzcmMpKVsyXSwgJ1wwJyB9IH0pLAkJCQkgICAgICBcCisgICAgIF9fZXh0ZW5zaW9uX18gKChfX1NUUklORzJfQ09QWV9BUlI1KQkJCQkgICAgICBcCisgICAgICB7IHsgKChjb25zdCBjaGFyICopIChzcmMpKVswXSwgKChjb25zdCBjaGFyICopIChzcmMpKVsxXSwJCSAgICAgIFwKKwkgICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMl0sICgoY29uc3QgY2hhciAqKSAoc3JjKSlbM10sCQkgICAgICBcCisJICAnXDAnIH0gfSksCQkJCQkJCSAgICAgIFwKKyAgICAgX19leHRlbnNpb25fXyAoKF9fU1RSSU5HMl9DT1BZX0FSUjYpCQkJCSAgICAgIFwKKyAgICAgIHsgeyAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzBdLCAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzFdLAkJICAgICAgXAorCSAgKChjb25zdCBjaGFyICopIChzcmMpKVsyXSwgKChjb25zdCBjaGFyICopIChzcmMpKVszXSwJCSAgICAgIFwKKwkgICgoY29uc3QgY2hhciAqKSAoc3JjKSlbNF0sICdcMCcgfSB9KSwJCQkJICAgICAgXAorICAgICBfX2V4dGVuc2lvbl9fICgoX19TVFJJTkcyX0NPUFlfQVJSNykJCQkJICAgICAgXAorICAgICAgeyB7ICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMF0sICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMV0sCQkgICAgICBcCisJICAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzJdLCAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzNdLAkJICAgICAgXAorCSAgKChjb25zdCBjaGFyICopIChzcmMpKVs0XSwgKChjb25zdCBjaGFyICopIChzcmMpKVs1XSwJCSAgICAgIFwKKwkgICdcMCcgfSB9KSwJCQkJCQkJICAgICAgXAorICAgICBfX2V4dGVuc2lvbl9fICgoX19TVFJJTkcyX0NPUFlfQVJSOCkJCQkJICAgICAgXAorICAgICAgeyB7ICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMF0sICgoY29uc3QgY2hhciAqKSAoc3JjKSlbMV0sCQkgICAgICBcCisJICAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzJdLCAoKGNvbnN0IGNoYXIgKikgKHNyYykpWzNdLAkJICAgICAgXAorCSAgKChjb25zdCBjaGFyICopIChzcmMpKVs0XSwgKChjb25zdCBjaGFyICopIChzcmMpKVs1XSwJCSAgICAgIFwKKwkgICgoY29uc3QgY2hhciAqKSAoc3JjKSlbNl0sICdcMCcgfSB9KQorIyAgICBlbmRpZgorX19TVFJJTkdfSU5MSU5FIGNoYXIgKl9fc3RwY3B5X3NtYWxsIChjaGFyICosIF9fU1RSSU5HMl9DT1BZX0FSUjIsCisJCQkJICAgICAgX19TVFJJTkcyX0NPUFlfQVJSMywKKwkJCQkgICAgICBfX1NUUklORzJfQ09QWV9BUlI0LAorCQkJCSAgICAgIF9fU1RSSU5HMl9DT1BZX0FSUjUsCisJCQkJICAgICAgX19TVFJJTkcyX0NPUFlfQVJSNiwKKwkJCQkgICAgICBfX1NUUklORzJfQ09QWV9BUlI3LAorCQkJCSAgICAgIF9fU1RSSU5HMl9DT1BZX0FSUjgsIHNpemVfdCk7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fIF9fdS0+X19zY2E0ID0gX19zcmM0OworICAgICAgYnJlYWs7CisgICAgY2FzZSA1OgorICAgICAgX19leHRlbnNpb25fXyBfX3UtPl9fc2NhNSA9IF9fc3JjNTsKKyAgICAgIGJyZWFrOworICAgIGNhc2UgNjoKKyAgICAgIF9fZXh0ZW5zaW9uX18gX191LT5fX3NjYTYgPSBfX3NyYzY7CisgICAgICBicmVhazsKKyAgICBjYXNlIDc6CisgICAgICBfX2V4dGVuc2lvbl9fIF9fdS0+X19zY2E3ID0gX19zcmM3OworICAgICAgYnJlYWs7CisgICAgY2FzZSA4OgorICAgICAgX19leHRlbnNpb25fXyBfX3UtPl9fc2NhOCA9IF9fc3JjODsKKyAgICAgIGJyZWFrOworICB9CisgIHJldHVybiBfX2Rlc3QgKyBfX3NyY2xlbiAtIDE7Cit9CisjICAgZW5kaWYKKyMgIGVuZGlmCisjIGVuZGlmCisjZW5kaWYKKworCisvKiBDb3B5IG5vIG1vcmUgdGhhbiBOIGNoYXJhY3RlcnMgb2YgU1JDIHRvIERFU1QuICAqLworI2lmbmRlZiBfSEFWRV9TVFJJTkdfQVJDSF9zdHJuY3B5CisjIGlmIF9fR05VQ19QUkVSRVEgKDMsIDIpCisjICBkZWZpbmUgc3RybmNweShkZXN0LCBzcmMsIG4pIF9fYnVpbHRpbl9zdHJuY3B5IChkZXN0LCBzcmMsIG4pCisjIGVsc2UKKyMgIGRlZmluZSBzdHJuY3B5KGRlc3QsIHNyYywgbikgXAorICAoX19leHRlbnNpb25fXyAoX19idWlsdGluX2NvbnN0YW50X3AgKHNyYykgJiYgX19idWlsdGluX2NvbnN0YW50X3AgKG4pICAgICAgXAorCQkgID8gKHN0cmxlbiAoc3JjKSArIDEgPj0gKChzaXplX3QpIChuKSkJCQkgICAgICBcCisJCSAgICAgPyAoY2hhciAqKSBtZW1jcHkgKGRlc3QsIHNyYywgbikJCQkgICAgICBcCisJCSAgICAgOiBzdHJuY3B5IChkZXN0LCBzcmMsIG4pKQkJCQk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mcyXzFicHRyX3AgKHMyKQkJICAgICAgXAorCSAgICA/IF9fYnVpbHRpbl9zdHJjbXAgKHMxLCBzMikJCQkJCSAgICAgIFwKKwkgICAgOiBfX3N0cmNtcF9jZyAoczEsIHMyLCBfX3MxX2xlbikpCQkJCSAgICAgIFwKKwkgOiAoX19idWlsdGluX2NvbnN0YW50X3AgKHMyKSAmJiBfX3N0cmluZzJfMWJwdHJfcCAoczIpCQkgICAgICBcCisJICAgICYmIChfX3MyX2xlbiA9IHN0cmxlbiAoczIpLCBfX3MyX2xlbiA8IDQpCQkJICAgICAgXAorCSAgICA/IChfX2J1aWx0aW5fY29uc3RhbnRfcCAoczEpICYmIF9fc3RyaW5nMl8xYnB0cl9wIChzMSkJICAgICAgXAorCSAgICAgICA/IF9fYnVpbHRpbl9zdHJjbXAgKHMxLCBzMikJCQkJICAgICAgXAorCSAgICAgICA6IF9fc3RyY21wX2djIChzMSwgczIsIF9fczJfbGVuKSkJCQkgICAgICBcCisJICAgIDogX19idWlsdGluX3N0cmNtcCAoczEsIHMyKSkpKTsgfSkKKyMgZWxzZQorIyAgZGVmaW5lIHN0cmNtcChzMSwgczIpIFwKKyAgX19leHRlbnNpb25fXwkJCQkJCQkJICAgICAgXAorICAoeyBzaXplX3QgX19zMV9sZW4sIF9fczJfbGVuOwkJCQkJCSAgICAgIFwKKyAgICAgKF9fYnVpbHRpbl9jb25zdGFudF9wIChzMSkgJiYgX19idWlsdGluX2NvbnN0YW50X3AgKHMyKQkJICAgICAgXAorICAgICAgJiYgKF9fczFfbGVuID0gc3RybGVuIChzMSksIF9fczJfbGVuID0gc3RybGVuIChzMiksCQkgICAgICBcCisJICAoIV9fc3RyaW5nMl8xYnB0cl9wIChzMSkgfHwgX19zMV9sZW4gPj0gNCkJCQkgICAgICBcCisJICAmJiAoIV9fc3RyaW5nMl8xYnB0cl9wIChzMikgfHwgX19zMl9sZW4gPj0gNCkpCQkgICAgICBcCisgICAgICA/IG1lbWNtcCAoKGNvbnN0IG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B1bnNpZ25lZCBjaGFyICopIChjb25zdCBjaGFyICopIChzMSkpWzBdCSAgICAgIFwKKwkJICAgICAgIC0gKChjb25zdCB1bnNpZ25lZCBjaGFyICopIChjb25zdCBjaGFyICopKHMyKSlbMF0pOyAgICBcCisJCSAgICBpZiAobCA+IDAgJiYgX19yZXN1bHQgPT0gMCkJCQkJICAgICAgXAorCQkgICAgICB7CQkJCQkJCSAgICAgIFwKKwkJCV9fcmVzdWx0ID0gKCgoY29uc3QgdW5zaWduZWQgY2hhciAqKQkJICAgICAgXAorCQkJCSAgICAgKGNvbnN0IGNoYXIgKikgKHMxKSlbMV0JCSAgICAgIFwKKwkJCQkgICAgLSAoKGNvbnN0IHVuc2lnbmVkIGNoYXIgKikJCSAgICAgIFwKKwkJCQkgICAgICAgKGNvbnN0IGNoYXIgKikgKHMyKSlbMV0pOwkgICAgICBcCisJCQlpZiAobCA+IDEgJiYgX19yZXN1bHQgPT0gMCkJCQkgICAgICBcCisJCQkgIHsJCQkJCQkgICAgICBcCisJCQkgICAgX19yZXN1bHQgPQkJCQkJICAgICAgXAorCQkJICAgICAgKCgoY29uc3QgdW5zaWduZWQgY2hhciAqKQkJCSAgICAgIFwKKwkJCQkoY29uc3QgY2hhciAqKSAoczEpKVsyXQkJCSAgICAgIFwKKwkJCSAgICAgICAtICgoY29uc3QgdW5zaWduZWQgY2hhciAqKQkJICAgICAgXAorCQkJCSAgKGNvbnN0IGNoYXIgKikgKHMyKSlbMl0pOwkJICAgICAgXAorCQkJICAgIGlmIChsID4gMiAmJiBfX3Jlc3VsdCA9PSAwKQkJCSAgICAgIFwKKwkJCSAgICAgIF9fcmVzdWx0ID0JCQkJICAgICAgXAorCQkJCSgoKGNvbnN0IHVuc2lnbmVkIGNoYXIgKikJCSAgICAgIFwKKwkJCQkgIChjb25zdCBjaGFyICopIChzMSkpWzNdCQkgICAgICBcCisJCQkJIC0gKChjb25zdCB1bnNpZ25lZCBjaGFyICopCQkgICAgICBcCisJCQkJICAgICh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XAorCQkJCQkgIChjb25zdCBjaGFyICopICAoczEpKVszXQkgICAgICBcCisJCQkJCSAgLSBfX3MyWzNdKTsJCQkgICAgICBcCisJCQkgIH0JCQkJCQkgICAgICBcCisJCSAgICAgIH0JCQkJCQkJICAgICAgXAorCQkgICAgX19yZXN1bHQ7IH0pKQorCisjIGRlZmluZSBfX3N0cmNtcF9nYyhzMSwgczIsIGwyKSAoLSBfX3N0cmNtcF9jZyAoczIsIHMxLCBsMikpCisjZW5kaWYKKworCisvKiBDb21wYXJlIE4gY2hhcmFjdGVycyBvZiBTMSBhbmQgUzIuICAqLworI2lmbmRlZiBfSEFWRV9TVFJJTkdfQVJDSF9zdHJuY21wCisjIGRlZmluZSBzdHJuY21wKHMxLCBzMiwgbikJCQkJCQkgICAgICBcCisgIChfX2V4dGVuc2lvbl9fIChfX2J1aWx0aW5fY29uc3RhbnRfcCAobikJCQkJICAgICAgXAorCQkgICYmICgoX19idWlsdGluX2NvbnN0YW50X3AgKHMxKQkJCSAgICAgIFwKKwkJICAgICAgICYmIHN0cmxlbiAoczEpIDwgKChzaXplX3QpIChuKSkpCQkJICAgICAgXAorCQkgICAgICB8fCAoX19idWlsdGluX2NvbnN0YW50X3AgKHMyKQkJCSAgICAgIFwKKwkJCSAgJiYgc3RybGVuIChzMikgPCAoKHNpemVfdCkgKG4pKSkpCQkgICAgICBcCisJCSAgPyBzdHJjbXAgKHMxLCBzMikgOiBzdHJuY21wIChzMSwgczIsIG4pKSkKKyNlbmRpZgorCisKKy8qIFJldHVybiB0aGUgbGVuZ3RoIG9mIHRoZSBpbml0aWFsIHNlZ21lbnQgb2YgUyB3aGljaAorICAgY29uc2lzdHMgZW50aXJlbHkgb2YgY2hhcmFjdGVycyBub3QgaW4gUkVKRUNULiAgKi8KKyNpZiAhZGVmaW5lZCBfSEFWRV9TVFJJTkdfQVJDSF9zdHJjc3BuIHx8IGRlZmluZWQgX0ZPUkNFX0lOTElORVMKKyMgaWZuZGVmIF9IQVZFX1NUUkl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gOiBfX2J1aWx0aW5fc3RyY3NwbiAocywgcmVqZWN0KSk7IH0pCisjICBlbHNlCisjICAgZGVmaW5lIHN0cmNzcG4ocywgcmVqZWN0KSBcCisgIF9fZXh0ZW5zaW9uX18JCQkJCQkJCSAgICAgIFwKKyAgKHsgY2hhciBfX3IwLCBfX3IxLCBfX3IyOwkJCQkJCSAgICAgIFwKKyAgICAgKF9fYnVpbHRpbl9jb25zdGFudF9wIChyZWplY3QpICYmIF9fc3RyaW5nMl8xYnB0cl9wIChyZWplY3QpCSAgICAgIFwKKyAgICAgID8gKChfX3IwID0gKChjb25zdCBjaGFyICopIChyZWplY3QpKVswXSwgX19yMCA9PSAnXDAnKQkJICAgICAgXAorCSA/IHN0cmxlbiAocykJCQkJCQkJICAgICAgXAorCSA6ICgoX19yMSA9ICgoY29uc3QgY2hhciAqKSAocmVqZWN0KSlbMV0sIF9fcjEgPT0gJ1wwJykJCSAgICAgIFwKKwkgICAgPyBfX3N0cmNzcG5fYzEgKHMsIF9fcjApCQkJCQkgICAgICBcCisJICAgIDogKChfX3IyID0gKChjb25zdCBjaGFyICopIChyZWplY3QpKVsyXSwgX19yMiA9PSAnXDAnKQkgICAgICBcCisJICAgICAgID8gX19zdHJjc3BuX2MyIChzLCBfX3IwLCBfX3IxKQkJCQkgICAgICBcCisJICAgICAgIDogKCgoY29uc3QgY2hhciAqKSAocmVqZWN0KSlbM10gPT0gJ1wwJwkJCSAgICAgIFwKKwkJICA/IF9fc3RyY3Nwbl9jMyAocywgX19yMCwgX19yMSwgX19yMikJCQkgICAgICBcCisJCSAgOiBzdHJjc3BuIChzLCByZWplY3QpKSkpKQkJCQkgICAgICBcCisgICAgICA6IHN0cmNzcG4gKHMsIHJlamVjdCkpOyB9KQorIyAgZW5kaWYKKyMgZW5kaWYKKworX19TVFJJTkdfSU5MSU5FIHNpemVfdCBfX3N0cmNzcG5fYzEgKGNvbnN0IGNoYXIgKl9fcywgaW50IF9fcmVqZWN0KTsKK19fU1RSSU5HX0lOTElORSBzaXplX3QKK19fc3RyY3Nwbl9jMSAoY29uc3QgY2hhciAqX19zLCBpbnQgX19yZWplY3QpCit7CisgIHNpemVfdCBfX3Jlc3VsdCA9IDA7CisgIHdoaWxlIChfX3NbX19yZXN1bHRdICE9ICdcMCcgJiYgX19zW19fcmVzdWx0XSAhPSBfX3JlamVjdCkKKyAgICArK19fcmVzdWx0OworICByZXR1cm4gX19yZXN1bHQ7Cit9CisKK19fU1RSSU5HX0lOTElORSBzaXplX3QgX19zdHJjc3BuX2MyIChjb25zdCBjaGFyICpfX3MsIGludCBfX3JlamVjdDEsCisJCQkJICAgICBpbnQgX19yZWplY3QyKTsKK19fU1RSSU5HX0lOTElORSBzaXplX3QKK19fc3RyY3Nwbl9jMiAoY29uc3QgY2hhciAqX19zLCBpbnQgX19yZWplY3QxLCBpbnQgX19yZWplY3QyKQoreworICBzaXplX3QgX19yZXN1bHQgPSAwOworICB3aGlsZSAoX19zW19fcmVzdWx0XSAhPSAnXDAnICYmIF9fc1tfX3Jlc3VsdF0gIT0gX19yZWplY3QxCisJICYmIF9fc1tfX3Jlc3VsdF0gIT0gX19yZWplY3QyKQorICAgICsrX19yZXN1bHQ7CisgIHJldHVybiBfX3Jlc3VsdDsKK30KKworX19TVFJJTkdfSU5MSU5FIHNpemVfdCBfX3N0cmNzcG5fYzMgKGNvbnN0IGNoYXIgKl9fcywgaW50IF9fcmVqZWN0MSwKKwkJCQkgICAgIGludCBfX3JlamVjdDIsIGludCBfX3JlamVjdDMpOworX19TVFJJTkdfSU5MSU5FIHNpemVfdAorX19zdHJjc3BuX2MzIChjb25zdCBjaGFyICpfX3MsIGludCBfX3JlamVjdDEsIGludCBfX3JlamVjdDIsCisJICAgICAgaW50IF9fcmVqZWN0MykKK3sKKyAgc2l6ZV90IF9fcmVzdWx0ID0gMDsKKyAgd2hpbGUgKF9fc1tfX3Jlc3VsdF0gIT0gJ1wwJyAmJiBfX3NbX19yZXN1bHRdICE9IF9fcmVqZWN0MQor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AgICBcCisJICAgICAgID8gX19zdHJzcG5fYzEgKHMsIF9fYTApCQkJCQkgICAgICBcCisJICAgICAgIDogKChfX2EyID0gKChjb25zdCBjaGFyICopIChhY2NlcHQpKVsyXSwgX19hMiA9PSAnXDAnKQkgICAgICBcCisJCSAgPyBfX3N0cnNwbl9jMiAocywgX19hMCwgX19hMSkJCQkJICAgICAgXAorCQkgIDogKCgoY29uc3QgY2hhciAqKSAoYWNjZXB0KSlbM10gPT0gJ1wwJwkJICAgICAgXAorCQkgICAgID8gX19zdHJzcG5fYzMgKHMsIF9fYTAsIF9fYTEsIF9fYTIpCQkgICAgICBcCisJCSAgICAgOiBfX2J1aWx0aW5fc3Ryc3BuIChzLCBhY2NlcHQpKSkpKSkJCSAgICAgIFwKKyAgICAgIDogX19idWlsdGluX3N0cnNwbiAocywgYWNjZXB0KSk7IH0pCisjICBlbHNlCisjICAgZGVmaW5lIHN0cnNwbihzLCBhY2NlcHQpIFwKKyAgX19leHRlbnNpb25fXwkJCQkJCQkJICAgICAgXAorICAoeyBjaGFyIF9fYTAsIF9fYTEsIF9fYTI7CQkJCQkJICAgICAgXAorICAgICAoX19idWlsdGluX2NvbnN0YW50X3AgKGFjY2VwdCkgJiYgX19zdHJpbmcyXzFicHRyX3AgKGFjY2VwdCkJICAgICAgXAorICAgICAgPyAoKF9fYTAgPSAoKGNvbnN0IGNoYXIgKikgKGFjY2VwdCkpWzBdLCBfX2EwID09ICdcMCcpCQkgICAgICBcCisJID8gKCh2b2lkKSAocyksIChzaXplX3QpIDApCQkJCQkgICAgICBcCisJIDogKChfX2ExID0gKChjb25zdCBjaGFyICopIChhY2NlcHQpKVsxXSwgX19hMSA9PSAnXDAnKQkJICAgICAgXAorCSAgICA/IF9fc3Ryc3BuX2MxIChzLCBfX2EwKQkJCQkJICAgICAgXAorCSAgICA6ICgoX19hMiA9ICgoY29uc3QgY2hhciAqKSAoYWNjZXB0KSlbMl0sIF9fYTIgPT0gJ1wwJykJICAgICAgXAorCSAg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fX3MsIGludCBfX2FjY2VwdDEsIGludCBfX2FjY2VwdDIpCit7CisgIC8qIFBsZWFzZSBub3RlIHRoYXQgX19hY2NlcHQxIGFuZCBfX2FjY2VwdDIgbmV2ZXIgY2FuIGJlICdcMCcuICAqLworICB3aGlsZSAoKl9fcyAhPSAnXDAnICYmICpfX3MgIT0gX19hY2NlcHQxICYmICpfX3MgIT0gX19hY2NlcHQyKQorICAgICsrX19zOworICByZXR1cm4gKl9fcyA9PSAnXDAnID8gTlVMTCA6IChjaGFyICopIChzaXplX3QpIF9fczsKK30KKworX19TVFJJTkdfSU5MSU5FIGNoYXIgKl9fc3RycGJya19jMyAoY29uc3QgY2hhciAqX19zLCBpbnQgX19hY2NlcHQxLAorCQkJCSAgICBpbnQgX19hY2NlcHQyLCBpbnQgX19hY2NlcHQzKTsKK19fU1RSSU5HX0lOTElORSBjaGFyICoKK19fc3RycGJya19jMyAoY29uc3QgY2hhciAqX19zLCBpbnQgX19hY2NlcHQxLCBpbnQgX19hY2NlcHQyLCBpbnQgX19hY2NlcHQzKQoreworICAvKiBQbGVhc2Ugbm90ZSB0aGF0IF9fYWNjZXB0MSB0byBfX2FjY2VwdDMgbmV2ZXIgY2FuIGJlICdcMCcuICAqLworICB3aGlsZSAoKl9fcyAhPSAnXDAnICYmICpfX3MgIT0gX19hY2NlcHQxICYmICpfX3MgIT0gX19hY2NlcHQyCisJICYmICpfX3MgIT0gX19hY2NlcHQzKQorICAgICsrX19zOworICByZXR1cm4gKl9fcyA9PSAnXDAnID8gTlVMTCA6IChjaGFyICopIChzaXplX3QpIF9fczsKK30KKyNlbmRpZgorCisKKy8qIEZpbmQgdGhlIGZpcnN0IG9jY3VycmVuY2Ugb2YgTkVFRExFIGluIEhBWVNUQUNLLiAgTmV3ZXIgZ2NjIHZlcnNpb25zCisgICBkbyB0aGlzIGl0c2VsZi4gICovCisjaWYgIWRlZmluZWQgX0hBVkVfU1RSSU5HX0FSQ0hfc3Ryc3RyICYmICFfX0dOVUNf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XIgKikgKHNlcCkpWzBdLCBuZXh0cCkgICAgICAgXAorCQkgIDogX19zdHJ0b2tfciAocywgc2VwLCBuZXh0cCkpKQorIyBlbmRpZgorCitfX1NUUklOR19JTkxJTkUgY2hhciAqX19zdHJ0b2tfcl8xYyAoY2hhciAqX19zLCBjaGFyIF9fc2VwLCBjaGFyICoqX19uZXh0cCk7CitfX1NUUklOR19JTkxJTkUgY2hhciAqCitfX3N0cnRva19yXzFjIChjaGFyICpfX3MsIGNoYXIgX19zZXAsIGNoYXIgKipfX25leHRwKQoreworICBjaGFyICpfX3Jlc3VsdDsKKyAgaWYgKF9fcyA9PSBOVUxMKQorICAgIF9fcyA9ICpfX25leHRwOworICB3aGlsZSAoKl9fcyA9PSBfX3NlcCkKKyAgICArK19fczsKKyAgX19yZXN1bHQgPSBOVUxMOworICBpZiAoKl9fcyAhPSAnXDAnKQorICAgIHsKKyAgICAgIF9fcmVzdWx0ID0gX19zKys7CisgICAgICB3aGlsZSAoKl9fcyAhPSAnXDAnKQorCWlmICgqX19zKysgPT0gX19zZXApCisJICB7CisJICAgIF9fc1stMV0gPSAnXDAnOworCSAgICBicmVhazsKKwkgIH0KKyAgICB9CisgICpfX25leHRwID0gX19zOworICByZXR1cm4gX19yZXN1bHQ7Cit9CisjIGlmZGVmIF9fVVNFX1BPU0lYCisjICBkZWZpbmUgc3RydG9rX3Iocywgc2VwLCBuZXh0cCkgX19zdHJ0b2tfciAocywgc2VwLCBuZXh0cCkKKyMgZW5kaWYKKyNlbmRpZgorCisKKyNpZiAhZGVmaW5lZCBfSEFWRV9TVFJJTkdfQVJDSF9zdHJzZXAgfHwgZGVmaW5lZCBfRk9SQ0VfSU5MSU5FUworIyBpZm5kZWYgX0hBVkVfU1RSSU5HX0FSQ0hfc3Ryc2VwCisKK2V4dGVybiBjaGFyICpfX3N0cnNlcF9nIChjaGFyICoqX19zdHJpbmdwLCBjb25zdCBjaGFyICpfX2RlbGltKTsKKyMgIGRlZmluZSBfX3N0cnNlcChzLCByZWplY3QpIFwKKyAgX19leHRlbnNpb25fXwkJCQkJCQkJICAgICAgXAorICAoeyBjaGFyIF9fcjAsIF9fcjEsIF9fcjI7CQkJCQkJICAgICAgXAorICAgICAoX19idWlsdGluX2NvbnN0YW50X3AgKHJlamVjdCkgJiYgX19zdHJpbmcyXzFicHRyX3AgKHJlamVjdCkJICAgICAgXAorICAgICAgJiYgKF9fcjAgPSAoKGNvbnN0IGNoYXIgKikgKHJlamVjdCkpWzBdLAkJCQkgICAgICBcCisJICAoKGNvbnN0IGNoYXIgKikgKHJlamVjdCkpWzBdICE9ICdcMCcpCQkJCSAgICAgIFwKKyAgICAgID8gKChfX3IxID0gKChjb25zdCBjaGFyICopIChyZWplY3QpKVsxXSwJCQkJICAgICAgXAorCSAoKGNvbnN0IGNoYXIgKikgKHJlamVjdCkpWzFdID09ICdcMCcpCQkJCSAgICAgIFwKKwkgPyBfX3N0cnNlcF8xYyAocywgX19yMCkJCQkJCSAgICAgIFwKKwkgOiAoKF9fcjIgPSAoKGNvbnN0IGNoYXIgKikgKHJlamVjdCkpWzJdLCBfX3IyID09ICdcMCcpCQkgICAgICBcCisJICAgID8gX19zdHJzZXBfMmMgKHMsIF9fcjAsIF9fcjEpCQkJCSAgICAgIFwKKwkgICAgOiAoKChjb25zdCBjaGFyICopIChyZWplY3QpKVszXSA9PSAnXDAnCQkJICAgICAgXAorCSAgICAgICA/IF9fc3Ryc2VwXzNjIChzLCBfX3IwLCBfX3IxLCBfX3IyKQkJCSAgICAgIFwKKwkgICAgICAgOiBfX3N0cnNlcF9nIChzLCByZWplY3QpKSkpCQkJCSAgICAgIFwKKyAgICAgIDogX19zdHJzZXBfZyAocywgcmVqZWN0KSk7IH0pCisjIGVuZGlmCisKK19fU1RSSU5HX0lOTElORSBjaGFyICpfX3N0cnNlcF8xYyAoY2hhciAqKl9fcywgY2hhciBfX3JlamVjdCk7CitfX1NUUklOR19JTkxJTkUgY2hhciAqCitfX3N0cnNlcF8xYyAoY2hhciAqKl9fcywgY2hhciBfX3JlamVjdCkKK3sKKyAgY2hhciAqX19yZXR2YWwgPSAqX19zOworICBpZiAoX19yZXR2YWwgIT0gTlVMTCAmJiAoKl9fcyA9IHN0cmNociAoX19yZXR2YWwsIF9fcmVqZWN0KSkgIT0gTlVMTCkKKyAgICAqKCpfX3MpKysgPSAnXDAnOworICByZXR1cm4gX19yZXR2YWw7Cit9CisKK19fU1RSSU5HX0lOTElORSBjaGFyICpfX3N0cnNlcF8yYyAoY2hhciAqKl9fcywgY2hhciBfX3JlamVjdDEsIGNoYXIgX19yZWplY3QyKTsKK19fU1RSSU5HX0lOTElORSBjaGFyICoKK19fc3Ryc2VwXzJjIChjaGFyICoqX19zLCBjaGFyIF9fcmVqZWN0MSwgY2hhciBfX3JlamVjdDIpCit7CisgIGNoYXIgKl9fcmV0dmFsID0gKl9fczsKKyAgaWYgKF9fcmV0dmFsICE9IE5VTEwpCisgICAgeworICAgICAgY2hhciAqX19jcCA9IF9fcmV0dmFsOworICAgICAgd2hpbGUgKDEpCisJeworCSAgaWYgKCpfX2NwID09ICdcMCcpCisJICAgIHsKKwkgICAgICBfX2NwID0gTlVMTDsKKwkgIGJyZWFrOworCSAgICB9CisJICBpZiAoKl9fY3AgPT0gX19yZWplY3QxIHx8ICpfX2NwID09IF9fcmVqZWN0MikKKwkgICAgeworCSAgICAgICpfX2NwKysgPSAnXDAnOworCSAgICAgIGJyZWFrOworCSAgICB9CisJICArK19fY3A7CisJfQorICAgICAgKl9fcyA9IF9fY3A7CisgICAgfQorICByZXR1cm4gX19yZXR2YWw7Cit9CisKK19fU1RSSU5HX0lOTElORSBjaGFyICpfX3N0cnNlcF8zYyAoY2hhciAqKl9fcywgY2hhciBfX3JlamVjdDEsIGNoYXIgX19yZWplY3QyLAorCQkJCSAgIGNoYXIgX19yZWplY3QzKTsKK19fU1RSSU5HX0lOTElORSBjaGFyICoKK19fc3Ryc2VwXzNjIChjaGFyICoqX19zLCBjaGFyIF9fcmVqZWN0M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HNpemVvZiAoc3RycykgLyBzaXplb2YgKHN0cnNbMF0pKQorCisKK3N0YXRpYyBpbnQKK2RvX3Rlc3QgKHZvaWQpCit7CisKKyAgc2l6ZV90IHNpemUgPSAwOworICBjaGFyICpzdHIgPSBtYWxsb2MgKDEwMCk7CisgIGlmIChzdHIgPT0gTlVMTCkKKyAgICB7CisgICAgICBwdXRzICgib3V0IG9mIG1lbW9yeSIpOworICAgICAgcmV0dXJuIDE7CisgICAgfQorCisgIGNoYXIgKiphcmd6ID0gJnN0cjsKKworICBmb3IgKGludCBpID0gMDsgaSA8IG5zdHJzOyArK2kpCisgICAgYXJnel9hZGRfc2VwIChhcmd6LCAmc2l6ZSwgc3Ryc1tpXS5zLCAnXDAnKTsKKworICBwcmludGYgKCJjYWxsaW5nIGVudnpfc3RyaXAgd2l0aCBzaXplPSV6dVxuIiwgc2l6ZSk7CisgIGVudnpfc3RyaXAgKGFyZ3osICZzaXplKTsKKworICBpbnQgcmVzdWx0ID0gMDsKKyAgcHJpbnRmICgibmV3IHNpemU9JXp1XG4iLCBzaXplKTsKKyAgZm9yIChpbnQgaSA9IDA7IGkgPCBuc3RyczsgKytpKQorICAgIGlmIChzdHJzW2ldLmluX3Jlc3VsdCkKKyAgICAgIHsKKyAgICAgICAgY2hhciBuYW1lWzJdOworICAgICAgICBuYW1lWzBdID0gc3Ryc1tpXS5zWzBdOworICAgICAgICBuYW1lWzFdID0gJ1wwJzsKKworICAgICAgICBjaGFyICplID0gZW52el9lbnRyeSAoKmFyZ3osIHNpemUsIG5hbWUpOworICAgICAgICBpZiAoZSA9PSBOVUxMKQorICAgICAgICAgIHsKKyAgICAgICAgICAgIHByaW50ZiAoImVudHJ5ICclcycgbm90IGZvdW5kXG4iLCBuYW1lKTsKKyAgICAgICAgICAgIHJlc3VsdCA9IDE7CisgICAgICAgICAgfQorICAgICAgICBlbHNlIGlmIChzdHJjbXAgKGUsIHN0cnNbaV0ucykgIT0gMCkKKyAgICAgICAgICB7CisgICAgICA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OR19JTkxJTkVTCisjaW5jbHVkZSA8c3RyaW5nLmg+CisjaW5jbHVkZSA8c3RkbGliLmg+CisjaW5jbHVkZSA8c3RkaW8uaD4KKworaW50CittYWluICh2b2lkKQoreworICBjb25zdCBjaGFyICphID0gImFiYyI7CisgIGNvbnN0IGNoYXIgKmIgPSBhOworCisgIHN0cnBicmsgKGIrKywgIiIpOworICBpZiAoYiAhPSBhICsgMSkKKyAgICByZXR1cm4gMTsKKworICByZXR1cm4gMDsKK30KZGlmZiAtLWdpdCBhL2FwL2xpYmMvZ2xpYmMvZ2xpYmMtMi4yMy9zdHJpbmcvYnVnLXN0cnNwbjEuYyBiL2FwL2xpYmMvZ2xpYmMvZ2xpYmMtMi4yMy9zdHJpbmcvYnVnLXN0cnNwbjEuYwpuZXcgZmlsZSBtb2RlIDEwMDY0NAppbmRleCAwMDAwMDAwLi5hNjU3YmFmCi0tLSAvZGV2L251bGwKKysrIGIvYXAvbGliYy9nbGliYy9nbGliYy0yLjIzL3N0cmluZy9idWctc3Ryc3BuMS5jCkBAIC0wLDAgKzEsMTkgQEAKKy8qIFRlc3QgY2FzZSBieSBKb3NlcGggUy4gTXllcnMgPGpzbTI4QGNhbS5hYy51az4uICAqLworI3VuZGVmIF9fVVNFX1NUUklOR19JTkxJTkVTCisjZGVmaW5lIF9fVVNFX1NUUklOR19JTkxJTkVTCisjaW5jbHVkZSA8c3RyaW5nLmg+CisjaW5jbHVkZSA8c3RkbGliLmg+CisjaW5jbHVkZSA8c3RkaW8uaD4KKworaW50CittYWluICh2b2lkKQoreworICBjb25zdCBjaGFyICphID0gImFiYyI7CisgIGNvbnN0IGNoYXIgKmIgPSBhOworCisgIHN0cnNwbiAoYisrLCAiIik7CisgIGlmIChiICE9IGEgKyAxKQorICAgIHJldHVybiAxOworCisgIHJldHVybiAwOworfQpkaWZmIC0tZ2l0IGEvYXAvbGliYy9nbGliYy9nbGliYy0yLjIzL3N0cmluZy9idWctc3RydG9rMS5jIGIvYXAvbGliYy9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jsKKyAgICAgIGxlbiArPSAxOworICAgICAgZ290byBkbzI7CisgICAgY2FzZSAwOgorICAgICAgaWYgKE9QX1RfVEhSRVMgPD0gMyAqIE9QU0laICYmIGxlbiA9PSAwKQorCXJldHVybiAwOworICAgICAgYTAgPSAoKG9wX3QgKikgc3JjcDEpWzBdOworICAgICAgYjAgPSAoKG9wX3QgKikgc3JjcDIpWzBdOworICAgICAgZ290byBkbzM7CisgICAgY2FzZSAxOgorICAgICAgYTEgPSAoKG9wX3QgKikgc3JjcDEpWzBdOworICAgICAgYjEgPSAoKG9wX3QgKikgc3JjcDIpWzBdOworICAgICAgc3JjcDEgKz0gT1BTSVo7CisgICAgICBzcmNwMiArPSBPUFNJWjsKKyAgICAgIGxlbiAtPSAxOworICAgICAgaWYgKE9QX1RfVEhSRVMgPD0gMyAqIE9QU0laICYmIGxlbiA9PSAwKQorCWdvdG8gZG8wOworICAgICAgLyogRmFsbCB0aHJvdWdoLiAgKi8KKyAgICB9CisKKyAgZG8KKyAgICB7CisgICAgICBhMCA9ICgob3BfdCAqKSBzcmNwMSlbMF07CisgICAgICBiMCA9ICgob3BfdCAqKSBzcmNwMilbMF07CisgICAgICBpZiAoYTEgIT0gYjEpCisJcmV0dXJuIENNUF9MVF9PUl9HVCAoYTEsIGIxKTsKKworICAgIGRvMzoKKyAgICAgIGExID0gKChvcF90ICopIHNyY3AxKVsxXTsKKyAgICAgIGIxID0gKChvcF90ICopIHNyY3AyKVsxXTsKKyAgICAgIGlmIChhMCAhPSBiMCkKKwlyZXR1cm4gQ01QX0xUX09SX0dUIChhMCwgYjApOworCisgICAgZG8yOgorICAgICAgYTAgPSAoKG9wX3QgKikgc3JjcDEpWzJdOworICAgICAgYjAgPSAoKG9wX3QgKikgc3JjcDIpWzJdOworICAgICAgaWYgKGExICE9IGIxKQorCXJldHVybiBDTVBfTFRfT1JfR1QgKGExLCBiMSk7CisKKyAgICBkbzE6CisgICAgICBhMSA9ICgob3BfdCAqKSBzcmNwMSlbM107CisgICAgICBiMSA9ICgob3BfdCAqKSBzcmNwMilbM107CisgICAgICBpZiAoYTAgIT0gYjApCisJcmV0dXJuIENNUF9MVF9PUl9HVCAoYTAsIGIwKTsKKworICAgICAgc3JjcDEgKz0gNCAqIE9QU0laOworICAgICAgc3JjcDIgKz0gNCAqIE9QU0laOworICAgICAgbGVuIC09IDQ7CisgICAgfQorICB3aGlsZSAobGVuICE9IDApOworCisgIC8qIFRoaXMgaXMgdGhlIHJpZ2h0IHBvc2l0aW9uIGZvciBkbzAuICBQbGVhc2UgZG9uJ3QgbW92ZQorICAgICBpdCBpbnRvIHRoZSBsb29wLiAgKi8KKyBkbzA6CisgIGlmIChhMSAhPSBiMSkKKyAgICByZXR1cm4gQ01QX0xUX09SX0dUIChhMSwgYjEpOworICByZXR1cm4gMDsKK30KKworc3RhdGljIGludCBtZW1jbXBfbm90X2NvbW1vbl9hbGlnbm1lbnQgKGxvbmcsIGxvbmcsIHNpemVfdCkgX19USFJPVzsKKworLyogbWVtY21wX25vdF9jb21tb25fYWxpZ25tZW50IC0tIENvbXBhcmUgYmxvY2tzIGF0IFNSQ1AxIGFuZCBTUkNQMiB3aXRoIExFTgorICAgYG9wX3QnIG9iamVjdHMgKG5vdCBMRU4gYnl0ZXMhKS4gIFNSQ1AyIHNob3VsZCBiZSBhbGlnbmVkIGZvciBtZW1vcnkKKyAgIG9wZXJhdGlvbnMgb24gYG9wX3QnLCBidXQgU1JDUDEgKnNob3VsZCBiZSB1bmFsaWduZWQqLiAgKi8KK3N0YXRpYyBpbnQKK21lbWNtcF9ub3RfY29tbW9uX2FsaWdubWVudCAobG9uZyBpbnQgc3JjcDEsIGxvbmcgaW50IHNyY3AyLCBzaXplX3QgbGVuKQoreworICBvcF90IGEwLCBhMSwgYTIsIGEzOworICBvcF90IGIwLCBiMSwgYjIsIGIzOworICBvcF90IHg7CisgIGludCBzaGwsIHNocjsKKworICAvKiBDYWxjdWxhdGUgaG93IHRvIHNoaWZ0IGEgd29yZCByZWFkIGF0IHRoZSBtZW1vcnkgb3BlcmF0aW9uCisgICAgIGFsaWduZWQgc3JjcDEgdG8gbWFrZSBpdCBhbGlnbmVkIGZvciBjb21wYXJpc29uLiAgKi8KKworICBzaGwgPSA4ICogKHNyY3AxICUgT1BTSVopOworICBzaHIgPSA4ICogT1BTSVogLSBzaGw7CisKKyAgLyogTWFrZSBTUkNQMSBhbGlnbmVkIGJ5IHJvdW5kaW5nIGl0IGRvd24gdG8gdGhlIGJlZ2lubmluZyBvZiB0aGUgYG9wX3QnCisgICAgIGl0IHBvaW50cyBpbiB0aGUgbWlkZGxlIG9mLiAgKi8KKyAgc3JjcDEgJj0gLU9QU0laOworCisgIHN3aXRjaCAobGVuICUgNCkKKyAgICB7CisgICAgZGVmYXVsdDogLyogQXZvaWQgd2FybmluZyBhYm91dCB1bmluaXRpYWxpemVkIGxvY2FsIHZhcmlhYmxlcy4gICovCisgICAgY2FzZSAyOgorICAgICAgYTEgPSAoKG9wX3QgKikgc3JjcDEpWzBdOworICAgICAgYTIgPSAoKG9wX3QgKikgc3JjcDEpWzFdOworICAgICAgYjIgPSAoKG9wX3QgKikgc3JjcDIpWzBdOworICAgICAgc3JjcDEgLT0gMSAqIE9QU0laOworICAgICAgc3JjcDIgLT0gMiAqIE9QU0laOworICAgICAgbGVuICs9IDI7CisgICAgICBnb3RvIGRvMTsKKyAgICBjYXNlIDM6CisgICAgICBhMCA9ICgob3BfdCAqKSBzcmNwMSlbMF07CisgICAgICBhMSA9ICgob3BfdCAqKSBzcmNwMSlbMV07CisgICAgICBiMSA9ICgob3BfdCAqKSBzcmNwMilbMF07CisgICAgICBzcmNwMiAtPSAxICogT1BTSVo7CisgICAgICBsZW4gKz0gMTsKKyAgICAgIGdvdG8gZG8yOworICAgIGNhc2UgMDoKKyAgICAgIGlmIChPUF9UX1RIUkVTIDw9IDMgKiBPUFNJWiAmJiBsZW4gPT0gMCkKKwlyZXR1cm4gMDsKKyAgICAgIGEzID0gKChvcF90ICopIHNyY3AxKVswXTsKKyAgICAgIGEwID0gKChvcF90ICopIHNyY3AxKVsxXTsKKyAgICAgIGIwID0gKChvcF90ICopIHNyY3AyKVswXTsKKyAgICAgIHNyY3AxICs9IDEgKiBPUFNJWjsKKyAgICAgIGdvdG8gZG8zOworICAgIGNhc2UgMToKKyAgICAgIGEyID0gKChvcF90ICopIHNyY3AxKVswXTsKKyAgICAgIGEzID0gKChvcF90ICopIHNyY3AxKVsxXTsKKyAgICAgIGIzID0gKChvcF90ICopIHNyY3AyKVswXTsKKyAgICAgIHNyY3AxICs9IDIgKiBPUFNJWjsKKyAgICAgIHNyY3AyICs9IDEgKiBPUFNJWjsKKyAgICAgIGxlbiAtPSAxOworICAgICAgaWYgKE9QX1RfVEhSRVMgPD0gMyAqIE9QU0laICYmIGxlbiA9PSAwKQorCWdvdG8gZG8wOworICAgICAgLyogRmFsbCB0aHJvdWdoLiAgKi8KKyAgICB9CisKKyAgZG8KKyAgICB7CisgICAgICBhMCA9ICgob3BfdCAqKSBzcmNwMSlbMF07CisgICAgICBiMCA9ICgob3BfdCAqKSBzcmNwMilbMF07CisgICAgICB4ID0gTUVSR0UoYTIsIHNobCwgYTMsIHNocik7CisgICAgICBpZiAoeCAhPSBiMykKKwlyZXR1cm4gQ01QX0xUX09SX0dUICh4LCBiMyk7CisKKyAgICBkbzM6CisgICAgICBhMSA9ICgob3BfdCAqKSBzcmNwMSlbMV07CisgICAgICBiMSA9ICgob3BfdCAqKSBzcmNwMilbMV07CisgICAgICB4ID0gTUVSR0UoYTMsIHNobCwgYTAsIHNocik7CisgICAgICBpZiAoeCAhPSBiMCkKKwlyZXR1cm4gQ01QX0xUX09SX0dUICh4LCBiMCk7CisKKyAgICBkbzI6CisgICAgICBhMiA9ICgob3BfdCAqKSBzcmNwMSlbMl07CisgICAgICBiMiA9ICgob3BfdCAqKSBzcmNwMilbMl07CisgICAgICB4ID0gTUVSR0UoYTAsIHNobCwgYTEsIHNocik7CisgICAgICBpZiAoeCAhPSBiMSkKKwlyZXR1cm4gQ01QX0xUX09SX0dUICh4LCBiMSk7CisKKyAgICBkbzE6CisgICAgICBhMyA9ICgob3BfdCAqKSBzcmNwMSlbM107CisgICAgICBiMyA9ICgob3BfdCAqKSBzcmNwMilbM107CisgICAgICB4ID0gTUVSR0UoYTEsIHNobCwgYTIsIHNocik7CisgICAgICBpZiAoeCAhPSBiMikKKwlyZXR1cm4gQ01QX0xUX09SX0dUICh4LCBiMik7CisKKyAgICAgIHNyY3AxICs9IDQgKiBPUFNJWjsKKyAgICAgIHNyY3AyICs9IDQgKiBPUFNJWjsKKyAgICAgIGxlbiAtPSA0OworICAgIH0KKyAgd2hpbGUgKGxlbiAhPSAwKTsKKworICAvKiBUaGlzIGlzIHRoZSByaWdodCBwb3NpdGlvbiBmb3IgZG8wLiAgUGxlYXNlIGRvbid0IG1vdmUKKyAgICAgaXQgaW50byB0aGUgbG9vcC4gICovCisgZG8wOgorICB4ID0gTUVSR0UoYTIsIHNobCwgYTMsIHNocik7CisgIGlmICh4ICE9IGIzKQorICAgIHJldHVybiBDTVBfTFRfT1JfR1QgKHgsIGIzKTsKKyAgcmV0dXJuIDA7Cit9CisKK2ludAorTUVNQ01QIChjb25zdCBfX3B0cl90IHMxLCBjb25zdCBfX3B0cl90IHMyLCBzaXplX3QgbGVuKQoreworICBvcF90IGEwOworICBvcF90IGIwOworICBsb25nIGludCBzcmNwMSA9IChsb25nIGludCkgczE7CisgIGxvbmcgaW50IHNyY3AyID0gKGxvbmcgaW50KSBzMjsKKyAgb3BfdCByZXM7CisKKyAgaWYgKGxlbiA+PSBPUF9UX1RIUkVTKQorICAgIHsKKyAgICAgIC8qIFRoZXJlIGFyZSBhdCBsZWFzdCBzb21lIGJ5dGVzIHRvIGNvbXBhcmUuICBObyBuZWVkIHRvIHRlc3QKKwkgZm9yIExFTiA9PSAwIGluIHRoaXMgYWxpZ25tZW50IGxvb3AuICAqLworICAgICAgd2hpbGUgKHNyY3AyICUgT1BTSVogIT0gMCkKKwl7CisJICBhMCA9ICgoYnl0ZSAqKSBzcmNwMSlbMF07CisJICBiMCA9ICgoYnl0ZSAqKSBzcmNwMilbMF07CisJICBzcmNwMSArPSAxOworCSAgc3JjcDIgKz0gMTsKKwkgIHJlcyA9IGEwIC0gYjA7CisJICBpZiAocmVzICE9IDApCisJICAgIHJldHVybiByZXM7CisJICBsZW4gLT0gMTsKKwl9CisKKyAgICAgIC8qIFNSQ1AyIGlzIG5vdyBhbGlnbmVkIGZvciBtZW1vcnkgb3BlcmF0aW9ucyBvbiBgb3BfdCcuCisJIFNSQ1AxIGFsaWdubWVudCBkZXRlcm1pbmVzIGlmIHdlIGNhbiBkbyBhIHNpbXBsZSwKKwkgYWxpZ25lZCBjb21wYXJlIG9yIG5lZWQgdG8gc2h1ZmZsZSBiaXRzLiAgKi8KKworICAgICAgaWYgKHNyY3AxICUgT1BTSVogPT0gMCkKKwlyZXMgPSBtZW1jbXBfY29tbW9uX2FsaWdubWVudCAoc3JjcDEsIHNyY3AyLCBsZW4gLyBPUFNJWik7CisgICAgICBlbHNlCisJcmVzID0gbWVtY21wX25vdF9jb21tb25fYWxpZ25tZW50IChzcmNwMSwgc3JjcDIsIGxlbiAvIE9QU0laKTsKKyAgICAgIGlmIChyZXMgIT0gMCkKKwlyZXR1cm4gcmVzOworCisgICAgICAvKiBOdW1iZXIgb2YgYnl0ZXMgcmVtYWluaW5nIGluIHRoZSBpbnRlcnZhbCBbMC4uT1BTSVotMV0uICAqLworICAgICAgc3JjcDEgKz0gbGVuICYgLU9QU0laOworICAgICAgc3JjcDIgKz0gbGVuICYgLU9QU0laOworICAgICAgbGVuICU9IE9QU0laOworICAgIH0KKworICAvKiBUaGVyZSBhcmUganVzdCBhIGZldyBieXRlcyB0byBjb21wYXJlLiAgVXNlIGJ5dGUgbWVtb3J5IG9wZXJhdGlvbnMuICAqLworICB3aGlsZSAobGVuICE9IDApCisgICAgeworICAgICAgYTAgPSAoKGJ5dGUgKikgc3JjcDEpWzBdOworICAgIC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CQl9CisJICAgIH0KKwl9CisgICAgICBhZHJbbmNoYXJzIC0gMV0gPSBMKCdcMCcpOworCisgICAgICBmb3IgKG91dGVyID0gbmNoYXJzIC0gMTsgb3V0ZXIgPj0gTUFYICgwLCBuY2hhcnMgLSAxMjgpOyAtLW91dGVyKQorCXsKKwkgIGZvciAobWlkZGxlID0gTUFYIChvdXRlciwgbmNoYXJzIC0gNjQpOyBtaWRkbGUgPCBuY2hhcnM7ICsrbWlkZGxlKQorCSAgICB7CisJICAgICAgYWRyW21pZGRsZV0gPSBMKCdcMCcpOworCisJICAgICAgZm9yIChpbm5lciA9IDA7IGlubmVyIDwgbmNoYXJzIC0gb3V0ZXI7ICsrIGlubmVyKQorCQl7CisJCSAgaWYgKChTVFBOQ1BZIChkZXN0LCAmYWRyW291dGVyXSwgaW5uZXIpIC0gZGVzdCkKKwkJICAgICAgIT0gTUlOIChpbm5lciwgbWlkZGxlIC0gb3V0ZXIpKQorCQkgICAgeworCQkgICAgICBwcmludGYgKCIlcyBmbHVua2VkIGZvciBvdXRlciA9ICVkLCBtaWRkbGUgPSAlZCwgIgorCQkJICAgICAgImlubmVyID0gJWRcbiIsCisJCQkgICAgICBTVFJJTkdJRlkgKFNUUE5DUFkpLCBvdXRlciwgbWlkZGxlLCBpbm5lcik7CisJCSAgICAgIHJlc3VsdCA9IDE7CisJCSAgICB9CisJCX0KKworCSAgICAgIGFkclttaWRkbGVdID0gTCgnVCcpOworCSAgICB9CisJfQorCisgICAgICAvKiBtZW1jcHkvd21lbWNweSB0ZXN0ICovCisgICAgICBmb3IgKG91dGVyID0gbmNoYXJzOyBvdXRlciA+PSBNQVggKDAsIG5jaGFycyAtIDEyOCk7IC0tb3V0ZXIpCisJZm9yIChpbm5lciA9IDA7IGlubmVyIDwgbmNoYXJzIC0gb3V0ZXI7ICsraW5uZXIpCisJICBpZiAoTUVNQ1BZIChkZXN0LCAmYWRyW291dGVyXSwgaW5uZXIpICE9ICBkZXN0KQorCSAgICB7CisJICAg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gIElmIGFueSBvZiB0aGUgaG9sZSBiaXRzCisJICAgICAgYXJlIHVuY2hhbmdlZCwgbW9zdCBsaWtlbHkgb25lIG9mIHRoZSBieXRlcyB3YXMgYQorCSAgICAgIHplcm8uICAqLworCSAgICYgfm1hZ2ljX2JpdHMpICE9IDAgfHwKKworCSAgLyogVGhhdCBjYXVnaHQgemVyb2VzLiAgTm93IHRlc3QgZm9yIEMuICAqLworCSAgKCgoKGxvbmd3b3JkIF4gY2hhcm1hc2spICsgbWFnaWNfYml0cykgXiB+KGxvbmd3b3JkIF4gY2hhcm1hc2spKQorCSAgICYgfm1hZ2ljX2JpdHMpICE9IDApCisJeworCSAgLyogV2hpY2ggb2YgdGhlIGJ5dGVzIHdhcyBDIG9yIHplcm8/CisJICAgICBJZiBub25lIG9mIHRoZW0gd2VyZSwgaXQgd2FzIGEgbWlzZmlyZTsgY29udGludWUgdGhlIHNlYXJjaC4gICovCisKKwkgIGNvbnN0IHVuc2lnbmVkIGNoYXIgKmNwID0gKGNvbnN0IHVuc2lnbmVkIGNoYXIgKikgKGxvbmd3b3JkX3B0ciAtIDEpOworCisJICBpZiAoKmNwID09IGMpCisJICAgIHJldHVybiAoY2hhciAqKSBjcDsKKwkgIGVsc2UgaWYgKCpjcCA9PSAnXDAnKQorCSAgICByZXR1cm4gTlVMTDsKKwkgIGlmICgqKytjcCA9PSBjKQorCSAgICByZXR1cm4gKGNoYXIgKikgY3A7CisJICBlbHNlIGlmICgqY3AgPT0gJ1wwJykKKwkgICAgcmV0dXJuIE5VTEw7CisJICBpZiAoKisrY3AgPT0gYykKKwkgICAgcmV0dXJuIChjaGFyICopIGNwOworCSAgZWxzZSBpZiAoKmNwID09ICdcMCcpCisJICAgIHJldHVybiBOVUxMOworCSAgaWYgKCorK2NwID09IGMpCisJICAgIHJldHVybiAoY2hhciAqKSBjcDsKKwkgIGVsc2UgaWYgKCpjcCA9PSAnXDAnKQorCSAgICByZXR1cm4gTlVMTDsKKwkgIGlmIChzaXplb2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czsKKwkgICAgfQorCX0KKyAgICAgIGVsc2UKKwl7CisJICBiYWNrd19zdG9wID0gaWR4bWF4OworCSAgaW50MzJfdCBwcmV2X2lkeCA9IGlkeDsKKworCSAgd2hpbGUgKCp1cyAhPSBMKCdcMCcpKQorCSAgICB7CisJICAgICAgaW50MzJfdCB0bXAgPSBmaW5kaWR4ICh0YWJsZSwgaW5kaXJlY3QsIGV4dHJhLCAmdXMsIC0xKTsKKwkgICAgICB1bnNpZ25lZCBjaGFyIHJ1bGUgPSB0bXAgPj4gMjQ7CisJICAgICAgcHJldl9pZHggPSBpZHg7CisJICAgICAgaWR4ID0gdG1wICYgMHhmZmZmZmY7CisJICAgICAgaWR4Y250ID0gaWR4bWF4Kys7CisKKwkgICAgICAvKiBTYXZlIHRoZSBydWxlIGZvciB0aGUgZmlyc3Qgc2VxdWVuY2UuICAqLworCSAgICAgIGlmIChfX2dsaWJjX3VubGlrZWx5IChpZHhjbnQgPT0gMCkpCisJICAgICAgICBzZXEtPnJ1bGUgPSBydWxlOworCisJICAgICAgaWYgKChydWxlc2V0c1tydWxlICogbnJ1bGVzICsgcGFzc10KKwkJICAgJiBzb3J0X2JhY2t3YXJkKSA9PSAwKQorCQkvKiBObyBtb3JlIGJhY2t3YXJkIGNoYXJhY3RlcnMgdG8gcHVzaC4gICovCisJCWJyZWFrOworCSAgICAgICsraWR4Y250OworCSAgICB9CisKKwkgIGlmIChiYWNrd19zdG9wID49IGlkeGNudCkKKwkgICAgeworCSAgICAgIC8qIE5vIHNlcXVlbmNlIGF0IGFsbCBvciBqdXN0IG9uZS4gICovCisJICAgICAgaWYgKGlkeGNudCA9PSBpZHhtYXggfHwgYmFja3dfc3RvcCA+IGlkeGNudCkKKwkJLyogTm90ZSB0aGF0IGxlbiBpcyBzdGlsbCB6ZXJvLiAgKi8KKwkJYnJlYWs7CisKKwkgICAgICBiYWNrd19zdG9wID0gfjB1bDsKKwkgICAgfQorCSAgZWxzZQorCSAgICB7CisJICAgICAgLyogV2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lcS0+aWR4bWF4ID0gaWR4bWF4OworICBzZXEtPnVzID0gdXM7CisgIHNlcS0+aWR4ID0gaWR4OworfQorCisvKiBDb21wYXJlIHR3byBzZXF1ZW5jZXMuICAqLworc3RhdGljIF9fYWx3YXlzX2lubGluZSBpbnQKK2RvX2NvbXBhcmUgKGNvbGxfc2VxICpzZXExLCBjb2xsX3NlcSAqc2VxMiwgaW50IHBvc2l0aW9uLAorCSAgICBjb25zdCBVU1RSSU5HX1RZUEUgKndlaWdodHMpCit7CisgIGludCBzZXExbGVuID0gc2VxMS0+bGVuOworICBpbnQgc2VxMmxlbiA9IHNlcTItPmxlbjsKKyAgc2l6ZV90IHZhbDEgPSBzZXExLT52YWw7CisgIHNpemVfdCB2YWwyID0gc2VxMi0+dmFsOworICBpbnQgaWR4MSA9IHNlcTEtPmlkeDsKKyAgaW50IGlkeDIgPSBzZXEyLT5pZHg7CisgIGludCByZXN1bHQgPSAwOworCisgIC8qIFRlc3QgZm9yIHBvc2l0aW9uIGlmIG5lY2Vzc2FyeS4gICovCisgIGlmIChwb3NpdGlvbiAmJiB2YWwxICE9IHZhbDIpCisgICAgeworICAgICAgcmVzdWx0ID0gdmFsMSA+IHZhbDIgPyAxIDogLTE7CisgICAgICBnb3RvIG91dDsKKyAgICB9CisKKyAgLyogQ29tcGFyZSB0aGUgdHdvIHNlcXVlbmNlcy4gICovCisgIGRvCisgICAgeworICAgICAgaWYgKHdlaWdodHNbaWR4MV0gIT0gd2VpZ2h0c1tpZHgyXSkKKwl7CisJICAvKiBUaGUgc2VxdWVuY2VzIGRpZmZlci4gICovCisJICByZXN1bHQgPSB3ZWlnaHRzW2lkeDFdIC0gd2VpZ2h0c1tpZHgyXTsKKwkgIGdvdG8gb3V0OworCX0KKworICAgICAgLyogSW5jcmVtZW50IHRoZSBvZmZzZXRzLiAgKi8KKyAgICAgICsraWR4MTsKKyAgICAgICsraWR4MjsKKworICAgICAgLS1zZXExbGVuOworICAgICAgLS1zZXEybGVuOworICAgI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WUgdGhlIEdOVQorICAgTGVzc2VyIEdlbmVyYWwgUHVibGljIExpY2Vuc2UgZm9yIG1vcmUgZGV0YWlscy4KKworICAgWW91IHNob3VsZCBoYXZlIHJlY2VpdmVkIGEgY29weSBvZiB0aGUgR05VIExlc3NlciBHZW5lcmFsIFB1YmxpYworICAgTGljZW5zZSBhbG9uZyB3aXRoIHRoZSBHTlUgQyBMaWJyYXJ5OyBpZiBub3QsIHNlZQorICAgPGh0dHA6Ly93d3cuZ251Lm9yZy9saWNlbnNlcy8+LiAgKi8KKworI2luY2x1ZGUgPHN0cmluZy5oPgorI2luY2x1ZGUgPHN0ZGxpYi5oPgorI2luY2x1ZGUgPHRpbWUuaD4KKyNpbmNsdWRlIDx1bmlzdGQuaD4KKworY2hhciAqCitzdHJmcnkgKGNoYXIgKnN0cmluZykKK3sKKyAgc3RhdGljIGludCBpbml0OworICBzdGF0aWMgc3RydWN0IHJhbmRvbV9kYXRhIHJkYXRhOworCisgIGlmICghaW5pdCkKKyAgICB7CisgICAgICBzdGF0aWMgY2hhciBzdGF0ZVszMl07CisgICAgICByZGF0YS5zdGF0ZSA9IE5VTEw7CisgICAgICBfX2luaXRzdGF0ZV9yICh0aW1lICgodGltZV90ICopIE5VTEwpIF4gZ2V0cGlkICgpLAorCQkgICAgIHN0YXRlLCBzaXplb2YgKHN0YXRlKSwgJnJkYXRhKTsKKyAgICAgIGluaXQgPSAxOworICAgIH0KKworICBzaXplX3QgbGVuID0gc3RybGVuIChzdHJpbmcpOworICBpZiAobGVuID4gMCkKKyAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IGxlbiAtIDE7ICsraSkKKyAgICAgIHsKKwlpbnQzMl90IGo7CisJX19yYW5kb21fciAoJnJkYXRhLCAmaik7CisJaiA9IGogJSAobGVuIC0gaSkgKyBpOworCisJY2hhciBjID0gc3RyaW5nW2ldOworCXN0cmluZ1tpXSA9IHN0cmluZ1tqXTsKKwlzdHJpbmdbal0gPSBjOworICAgICAgfQorCisg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2F0dHJpYnV0ZV9wdXJlX18gX19ub25udWxsICgoMSwgMikpOworCisvKiBTZWFyY2ggTiBieXRlcyBvZiBTIGZvciBDLiAgKi8KKyNpZmRlZiBfX0NPUlJFQ1RfSVNPX0NQUF9TVFJJTkdfSF9QUk9UTworZXh0ZXJuICJDKysiCit7CitleHRlcm4gdm9pZCAqbWVtY2hyICh2b2lkICpfX3MsIGludCBfX2MsIHNpemVfdCBfX24pCisgICAgICBfX1RIUk9XIF9fYXNtICgibWVtY2hyIikgX19hdHRyaWJ1dGVfcHVyZV9fIF9fbm9ubnVsbCAoKDEpKTsKK2V4dGVybiBjb25zdCB2b2lkICptZW1jaHIgKGNvbnN0IHZvaWQgKl9fcywgaW50IF9fYywgc2l6ZV90IF9fbikKKyAgICAgIF9fVEhST1cgX19hc20gKCJtZW1jaHIiKSBfX2F0dHJpYnV0ZV9wdXJlX18gX19ub25udWxsICgoMSkpOworCisjIGlmZGVmIF9fT1BUSU1JWkVfXworX19leHRlcm5fYWx3YXlzX2lubGluZSB2b2lkICoKK21lbWNociAodm9pZCAqX19zLCBpbnQgX19jLCBzaXplX3QgX19uKSBfX1RIUk9XCit7CisgIHJldHVybiBfX2J1aWx0aW5fbWVtY2hyIChfX3MsIF9fYywgX19uKTsKK30KKworX19leHRlcm5fYWx3YXlzX2lubGluZSBjb25zdCB2b2lkICoKK21lbWNociAoY29uc3Qgdm9pZCAqX19zLCBpbnQgX19jLCBzaXplX3QgX19uKSBfX1RIUk9XCit7CisgIHJldHVybiBfX2J1aWx0aW5fbWVtY2hyIChfX3MsIF9fYywgX19uKTsKK30KKyMgZW5kaWYKK30KKyNlbHNlCitleHRlcm4gdm9pZCAqbWVtY2hyIChjb25zdCB2b2lkICpfX3MsIGludCBfX2MsIHNpemVfdCBfX24pCisgICAgICBfX1RIUk9XIF9fYXR0cmlidXRlX3B1cmVfXyBfX25vbm51bGwgKCgxKSk7CisjZW5kaWYKK19fRU5EX05BTUVTUEFDRV9TVEQKKworI2lmZG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gIFRoZQorICAgcmVzdWx0YW50IHN0cmluZyBpcyB0ZXJtaW5hdGVkIGV2ZW4gaWYgbm8gbnVsbCB0ZXJtaW5hdG9yCisgICBhcHBlYXJzIGJlZm9yZSBTVFJJTkdbTl0uICAqLworI2lmIGRlZmluZWQgX19VU0VfWE9QRU4ySzgKK2V4dGVybiBjaGFyICpzdHJuZHVwIChjb25zdCBjaGFyICpfX3N0cmluZywgc2l6ZV90IF9fbikKKyAgICAgX19USFJPVyBfX2F0dHJpYnV0ZV9tYWxsb2NfXyBfX25vbm51bGwgKCgxKSk7CisjZW5kaWYKKworI2lmIGRlZmluZWQgX19VU0VfR05VICYmIGRlZmluZWQgX19HTlVDX18KKy8qIER1cGxpY2F0ZSBTLCByZXR1cm5pbmcgYW4gaWRlbnRpY2FsIGFsbG9jYSdkIHN0cmluZy4gICovCisjIGRlZmluZSBzdHJkdXBhKHMpCQkJCQkJCSAgICAgIFwKKyAgKF9fZXh0ZW5zaW9uX18JCQkJCQkJICAgICAgXAorICAgICh7CQkJCQkJCQkJICAgICAgXAorICAgICAgY29uc3QgY2hhciAqX19vbGQgPSAocyk7CQkJCQkJICAgICAgXAorICAgICAgc2l6ZV90IF9fbGVuID0gc3RybGVuIChfX29sZCkgKyAxOwkJCQkgICAgICBcCisgICAgICBjaGFyICpfX25ldyA9IChjaGFyICopIF9fYnVpbHRpbl9hbGxvY2EgKF9fbGVuKTsJCQkgICAgICBcCisgICAgICAoY2hhciAqKSBtZW1jcHkgKF9fbmV3LCBfX29sZCwgX19sZW4pOwkJCQkgICAgICBcCisgICAgfSkpCisKKy8qIFJldHVybiBhbiBhbGxvY2EnZCBjb3B5IG9mIGF0IG1vc3QgTiBieXRlcyBvZiBzdHJpbmcuICAqLworIyBkZWZpbmUgc3RybmR1cGEocywgbikJCQkJCQkJICAgICAgXAorICAoX19leHRlbnNpb25fXwkJCQkJCQkgICAgICBcCisgICAgKHsJCQkJCQkJCQkgICAgICBcCisgICAgICBjb25zdCBjaGFyICpfX29sZCA9IChzKTsJCQkJCQkgICAgICBcCisgICAgICBzaXplX3QgX19sZW4gPSBzdHJubGVuIChfX29sZCwgKG4pKTsJCQkJICAgICAgXAorICAgICAgY2hhciAqX19uZXcgPSAoY2hhciAqKSBfX2J1aWx0aW5fYWxsb2NhIChfX2xlbiArIDEpOwkJICAgICAgXAorICAgICAgX19uZXdbX19sZW5dID0gJ1wwJzsJCQkJCQkgICAgICBcCisgICAgICAoY2hhciAqKSBtZW1jcHkgKF9fbmV3LCBfX29sZCwgX19sZW4pOwkJCQkgICAgICBcCisgICAgfSkpCisjZW5kaWYKKworX19CRUdJTl9OQU1FU1BBQ0VfU1RECisvKiBGaW5kIHRoZSBmaXJzdCBvY2N1cnJlbmNlIG9mIEMgaW4gUy4gICovCisjaWZkZWYgX19DT1JSRUNUX0lTT19DUFBfU1RSSU5HX0hfUFJPVE8KK2V4dGVybiAiQysrIgoreworZXh0ZXJuIGNoYXIgKnN0cmNociAoY2hhciAqX19zLCBpbnQgX19jKQorICAgICBfX1RIUk9XIF9fYXNtICgic3RyY2hyIikgX19hdHRyaWJ1dGVfcHVyZV9fIF9fbm9ubnVsbCAoKDEpKTsKK2V4dGVybiBjb25zdCBjaGFyICpzdHJjaHIgKGNvbnN0IGNoYXIgKl9fcywgaW50IF9fYykKKyAgICAgX19USFJPVyBfX2FzbSAoInN0cmNociIpIF9fYXR0cmlidXRlX3B1cmVfXyBfX25vbm51bGwgKCgxKSk7CisKKyMgaWZkZWYgX19PUFRJTUlaRV9fCitfX2V4dGVybl9hbHdheXNfaW5saW5lIGNoYXIgKgorc3RyY2hyIChjaGFyICpfX3MsIGludCBfX2MpIF9fVEhST1cKK3sKKyAgcmV0dXJuIF9fYnVpbHRpbl9zdHJjaHIgKF9fcywgX19jKTsKK30KKworX19leHRlcm5fYWx3YXlzX2lubGluZSBjb25zdCBjaGFyICoKK3N0cmNociAoY29uc3QgY2hhciAqX19zLCBpbnQgX19jKSBfX1RIUk9XCit7CisgIHJldHV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aW5kZXggKGNoYXIgKl9fcywgaW50IF9fYykKKyAgICAgX19USFJPVyBfX2FzbSAoInJpbmRleCIpIF9fYXR0cmlidXRlX3B1cmVfXyBfX25vbm51bGwgKCgxKSk7CitleHRlcm4gY29uc3QgY2hhciAqcmluZGV4IChjb25zdCBjaGFyICpfX3MsIGludCBfX2MpCisgICAgIF9fVEhST1cgX19hc20gKCJyaW5kZXgiKSBfX2F0dHJpYnV0ZV9wdXJlX18gX19ub25udWxsICgoMSkpOworCisjICBpZiBkZWZpbmVkIF9fT1BUSU1JWkVfXyAmJiAhZGVmaW5lZCBfX0NPUlJFQ1RfSVNPX0NQUF9TVFJJTkdTX0hfUFJPVE8KK19fZXh0ZXJuX2Fsd2F5c19pbmxpbmUgY2hhciAqCityaW5kZXggKGNoYXIgKl9fcywgaW50IF9fYykgX19USFJPVworeworICByZXR1cm4gX19idWlsdGluX3JpbmRleCAoX19zLCBfX2MpOworfQorCitfX2V4dGVybl9hbHdheXNfaW5saW5lIGNvbnN0IGNoYXIgKgorcmluZGV4IChjb25zdCBjaGFyICpfX3MsIGludCBfX2MpIF9fVEhST1cKK3sKKyAgcmV0dXJuIF9fYnVpbHRpbl9yaW5kZXggKF9fcywgX19jKTsKK30KKyNlbmRpZgorfQorIyBlbHNlCitleHRlcm4gY2hhciAqcmluZGV4IChjb25zdCBjaGFyICpfX3MsIGludCBfX2MpCisgICAgIF9fVEhST1cgX19hdHRyaWJ1dGVfcHVyZV9fIF9fbm9ubnVsbCAoKDEpKTsKKyMgZW5kaWYKKworLyogUmV0dXJuIHRoZSBwb3NpdGlvbiBvZiB0aGUgZmlyc3QgYml0IHNldCBpbiBJLCBvciAwIGlmIG5vbmUgYXJlIHNldC4KKyAgIFRoZSBsZWFzdC1zaWduaWZpY2FudCBiaXQgaXMgcG9zaXRpb24gMSwgdGhlIG1vc3Qtc2lnbmlmaWNhbnQgMzIuICAqLworZXh0ZXJuIGludCBmZnMgKGludCBfX2kpIF9fVEhST1cgX19hdHRy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ciAqX19zLCBpbnQgX19jKQorICAgICBfX1RIUk9XIF9fYXNtICgiaW5kZXgiKSBfX2F0dHJpYnV0ZV9wdXJlX18gX19ub25udWxsICgoMSkpOworZXh0ZXJuIGNvbnN0IGNoYXIgKmluZGV4IChjb25zdCBjaGFyICpfX3MsIGludCBfX2MpCisgICAgIF9fVEhST1cgX19hc20gKCJpbmRleCIpIF9fYXR0cmlidXRlX3B1cmVfXyBfX25vbm51bGwgKCgxKSk7CisKKyMgICBpZiBkZWZpbmVkIF9fT1BUSU1JWkVfXyAmJiAhZGVmaW5lZCBfX0NPUlJFQ1RfSVNPX0NQUF9TVFJJTkdfSF9QUk9UTworX19leHRlcm5fYWx3YXlzX2lubGluZSBjaGFyICoKK2luZGV4IChjaGFyICpfX3MsIGludCBfX2MpIF9fVEhST1cKK3sKKyAgcmV0dXJuIF9fYnVpbHRpbl9pbmRleCAoX19zLCBfX2MpOworfQorCitfX2V4dGVybl9hbHdheXNfaW5saW5lIGNvbnN0IGNoYXIgKgoraW5kZXggKGNvbnN0IGNoYXIgKl9fcywgaW50IF9fYykgX19USFJPVworeworICByZXR1cm4gX19idWlsdGluX2luZGV4IChfX3MsIF9fYyk7Cit9CisjICAgZW5kaWYKK30KKyMgIGVsc2UKK2V4dGVybiBjaGFyICppbmRleCAoY29uc3QgY2hhciAqX19zLCBpbnQgX19jKQorICAgICBfX1RIUk9XIF9fYXR0cmlidXRlX3B1cmVfXyBfX25vbm51bGwgKCgxKSk7CisjICBlbmRpZgorCisvKiBGaW5kIHRoZSBsYXN0IG9jY3VycmVuY2Ugb2YgQyBpbiBTIChzYW1lIGFzIHN0cnJjaHIpLiAgKi8KKyMgIGlmZGVmIF9fQ09SUkVDVF9JU09fQ1BQX1NUUklOR1NfSF9QUk9UTworZXh0ZXJuICJDKysiCit7CitleHRlcm4gY2hhciAqcmluZGV4IChjaGFyICpfX3MsIGludCBfX2MpCisgICAgIF9fVEhST1cgX19hc20gKCJyaW5kZXgiKSBfX2F0dHJp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W55IG9mIHRoZSBmb3VyKiBieXRlcyBpbiB0aGUgbG9uZ3dvcmQgaW4gcXVlc3Rpb24gYXJlIHplcm8uICAqLworICBmb3IgKDs7KQorICAgIHsKKyAgICAgIGxvbmd3b3JkID0gKmxvbmd3b3JkX3B0cisrOworCisgICAgICBpZiAoKChsb25nd29yZCAtIGxvbWFnaWMpICYgfmxvbmd3b3JkICYgaGltYWdpYykgIT0gMCkKKwl7CisJICAvKiBXaGljaCBvZiB0aGUgYnl0ZXMgd2FzIHRoZSB6ZXJvPyAgSWYgbm9uZSBvZiB0aGVtIHdlcmUsIGl0IHdhcworCSAgICAgYSBtaXNmaXJlOyBjb250aW51ZSB0aGUgc2VhcmNoLiAgKi8KKworCSAgY29uc3QgY2hhciAqY3AgPSAoY29uc3QgY2hhciAqKSAobG9uZ3dvcmRfcHRyIC0gMSk7CisKKwkgIGlmIChjcFswXSA9PSAwKQorCSAgICByZXR1cm4gY3AgLSBzdHI7CisJICBpZiAoY3BbMV0gPT0gMCkKKwkgICAgcmV0dXJuIGNwIC0gc3RyICsgMTsKKwkgIGlmIChjcFsyXSA9PSAwKQorCSAgICByZXR1cm4gY3AgLSBzdHIgKyAyOworCSAgaWYgKGNwWzNdID09IDApCisJICAgIHJldHVybiBjcCAtIHN0ciArIDM7CisJICBpZiAoc2l6ZW9mIChsb25nd29yZCkgPiA0KQorCSAgICB7CisJICAgICAgaWYgKGNwWzRdID09IDApCisJCXJldHVybiBjcCAtIHN0ciArIDQ7CisJICAgICAgaWYgKGNwWzVdID09IDApCisJCXJldHVybiBjcCAtIHN0ciArIDU7CisJICAgICAgaWYgKGNwWzZdID09IDApCisJCXJldHVybiBjcCAtIHN0ciArIDY7CisJICAgICAgaWYgKGNwWzddID09IDApCisJCXJldHVybiBjcCAtIHN0ciArIDc7CisJICAgIH0KKwl9CisgICAgfQorfQorbGliY19oaWRkZW5fYnVpbHRpbl9kZWYgKHN0cmxlbikKZGlmZiAtLWdpdCBhL2FwL2xpYmMvZ2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A+PSA0KQorICAgIHsKKyAgICAgIHNpemVfdCBuNCA9IG4gPj4gMjsKKyAgICAgIGRvCisJeworCSAgYzEgPSAodW5zaWduZWQgY2hhcikgKnMxKys7CisJICBjMiA9ICh1bnNpZ25lZCBjaGFyKSAqczIrKzsKKwkgIGlmIChjMSA9PSAnXDAnIHx8IGMxICE9IGMyKQorCSAgICByZXR1cm4gYzEgLSBjMjsKKwkgIGMxID0gKHVuc2lnbmVkIGNoYXIpICpzMSsrOworCSAgYzIgPSAodW5zaWduZWQgY2hhcikgKnMyKys7CisJICBpZiAoYzEgPT0gJ1wwJyB8fCBjMSAhPSBjMikKKwkgICAgcmV0dXJuIGMxIC0gYzI7CisJICBjMSA9ICh1bnNpZ25lZCBjaGFyKSAqczErKzsKKwkgIGMyID0gKHVuc2lnbmVkIGNoYXIpICpzMisrOworCSAgaWYgKGMxID09ICdcMCcgfHwgYzEgIT0gYzIpCisJICAgIHJldHVybiBjMSAtIGMyOworCSAgYzEgPSAodW5zaWduZWQgY2hhcikgKnMxKys7CisJICBjMiA9ICh1bnNpZ25lZCBjaGFyKSAqczIrKzsKKwkgIGlmIChjMSA9PSAnXDAnIHx8IGMxICE9IGMyKQorCSAgICByZXR1cm4gYzEgLSBjMjsKKwl9IHdoaWxlICgtLW40ID4gMCk7CisgICAgICBuICY9IDM7CisgICAgfQorCisgIHdoaWxlIChuID4gMCkKKyAgICB7CisgICAgICBjMSA9ICh1bnNpZ25lZCBjaGFyKSAqczErKzsKKyAgICAgIGMyID0gKHVuc2lnbmVkIGNoYXIpICpzMisrOworICAgICAgaWYgKGMxID09ICdcMCcgfHwgYzEgIT0gYzIpCisJcmV0dXJuIGMxIC0gYzI7CisgICAgICBuLS07CisgICAgfQorCisgIHJldHVybiBjMSAtIGMyOworfQorCitsaWJjX2hpZGRlbl9idWlsdGluX2RlZiAoU1RSTkNNUCkKZGlmZiAtLWdpdCBhL2FwL2xpYmMvZ2xpYmMvZ2xpYmMtMi4yMy9zdHJpbmcvc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RpYyBjaGFyICpnZXRidWZmZXIgKHZvaWQpOworCisKKy8qIFJldHVybiBhIHN0cmluZyBkZXNjcmliaW5nIHRoZSBtZWFuaW5nIG9mIHRoZSBzaWduYWwgbnVtYmVyIFNJR05VTS4gICovCitjaGFyICoKK3N0cnNpZ25hbCAoaW50IHNpZ251bSkKK3sKKyAgX19saWJjX29uY2VfZGVmaW5lIChzdGF0aWMsIG9uY2UpOworICBjb25zdCBjaGFyICpkZXNjOworCisgIC8qIElmIHdlIGhhdmUgbm90IHlldCBpbml0aWFsaXplZCB0aGUgYnVmZmVyIGRvIGl0IG5vdy4gICovCisgIF9fbGliY19vbmNlIChvbmNlLCBpbml0KTsKKworICBpZiAoCisjaWZkZWYgU0lHUlRNSU4KKyAgICAgIChzaWdudW0gPj0gU0lHUlRNSU4gJiYgc2lnbnVtIDw9IFNJR1JUTUFYKSB8fAorI2VuZGlmCisgICAgICBzaWdudW0gPCAwIHx8IHNpZ251bSA+PSBOU0lHCisgICAgICB8fCAoZGVzYyA9IF9zeXNfc2lnbGlzdFtzaWdudW1dKSA9PSBOVUxMKQorICAgIHsKKyAgICAgIGNoYXIgKmJ1ZmZlciA9IGdldGJ1ZmZlciAoKTsKKyAgICAgIGludCBsZW47CisjaWZkZWYgU0lHUlRNSU4KKyAgICAgIGlmIChzaWdudW0gPj0gU0lHUlRNSU4gJiYgc2lnbnVtIDw9IFNJR1JUTUFYKQorCWxlbiA9IF9fc25wcmludGYgKGJ1ZmZlciwgQlVGRkVSU0laIC0gMSwgXygiUmVhbC10aW1lIHNpZ25hbCAlZCIpLAorCQkJICBzaWdudW0gLSBTSUdSVE1JTik7CisgICAgICBlbHNlCisjZW5kaWYKKwlsZW4gPSBfX3NucHJpbnRmIChidWZmZXIsIEJVRkZFUlNJWiAtIDEsIF8oIlVua25vd24gc2lnbmFsICVkIiksCisJCQkgIHNpZ251bSk7CisgICAgICBpZiAobGVuID49IEJVRkZFUlNJWikKKwlidWZmZXIgPSBOVUxMOworICAgIC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OwkvLyB4ID0gImFiYyIsIHNwID0gIj0tZGVmIgorCXggPSBzdHJ0b2tfcihOVUxMLCAiLT0iLCAmc3ApOwkvLyB4ID0gImRlZiIsIHNwID0gTlVMTAorCXggPSBzdHJ0b2tfcihOVUxMLCAiPSIsICZzcCk7CS8vIHggPSBOVUxMCisJCS8vIHMgPSAiYWJjXDAtZGVmXDAiCisqLworY2hhciAqCitfX3N0cnRva19yIChjaGFyICpzLCBjb25zdCBjaGFyICpkZWxpbSwgY2hhciAqKnNhdmVfcHRyKQoreworICBjaGFyICp0b2tlbjsKKworICBpZiAocyA9PSBOVUxMKQorICAgIHMgPSAqc2F2ZV9wdHI7CisKKyAgLyogU2NhbiBsZWFkaW5nIGRlbGltaXRlcnMuICAqLworICBzICs9IHN0cnNwbiAocywgZGVsaW0pOworICBpZiAoKnMgPT0gJ1wwJykKKyAgICB7CisgICAgICAqc2F2ZV9wdHIgPSBzOworICAgICAgcmV0dXJuIE5VTEw7CisgICAgfQorCisgIC8qIEZpbmQgdGhlIGVuZCBvZiB0aGUgdG9rZW4uICAqLworICB0b2tlbiA9IHM7CisgIHMgPSBzdHJwYnJrICh0b2tlbiwgZGVsaW0pOworICBpZiAocyA9PSBOVUxMKQorICAgIC8qIFRoaXMgdG9rZW4gZmluaXNoZXMgdGhlIHN0cmluZy4gICovCisgICAgKnNhdmVfcHRyID0gX19yYXdtZW1jaHIgKHRva2VuLCAnXDAnKTsKKyAgZWxzZQorICAgIHsKKyAgICAgIC8qIFRlcm1pbmF0ZSB0aGUgdG9rZW4gYW5kIG1ha2UgKlNBVkVfUFRSIHBvaW50IHBhc3QgaXQuICAqLworICAgICAgKnMgPSAnXDAnOworICAgICAgKnNhdmVfcHRyID0gcyArIDE7CisgICAgfQorICByZXR1cm4gdG9rZW47Cit9CisjaWZkZWYgd2Vha19hbGlhcworbGliY19oaWRkZW5fZGVmIChfX3N0cnRva19yKQord2Vha19hbGlhcyAoX19zdHJ0b2tfciwgc3RydG9rX3IpCisjZ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gcnVsZSA9IHJ1bGVzZXRzW3J1bGVhcnJbaWR4Y250ICsgMV0gKiBucnVsZXMgKyBwYXNzXTsKKwkgICAgfQorCisKKwkgIGlmIChiYWNrd19zdG9wICE9IH4wdWwpCisJICAgIHsKKwkgICAgICAvKiBIYW5kbGUgdGhlIHB1c2hlZCBlbGVtZW50cyBub3cuICAqLworCSAgICAgIHNpemVfdCBiYWNrdzsKKworCSAgICAgIGJhY2t3ID0gaWR4Y250OworCSAgICAgIHdoaWxlIChiYWNrdyA+IGJhY2t3X3N0b3ApCisJCXsKKwkJICBzaXplX3QgbGVuID0gd2VpZ2h0c1tpZHhhcnJbLS1iYWNrd10rK107CisKKwkJICBpZiAobmVlZGVkICsgbGVuIDwgbikKKwkJICAgIHdoaWxlIChsZW4tLSA+IDApCisJCSAgICAgIGRlc3RbbmVlZGVkKytdID0gd2VpZ2h0c1tpZHhhcnJbYmFja3ddKytdOworCQkgIGVsc2UKKwkJICAgIHsKKwkJICAgICAgLyogTm8gbW9yZSBjaGFyYWN0ZXJzIGZpdCBpbnRvIHRoZSBidWZmZXIuICAqLworCQkgICAgICBuZWVkZWQgKz0gbGVuOworCQkgICAgICBpZHhhcnJbYmFja3ddICs9IGxlbjsKKwkJICAgIH0KKwkJfQorCSAgICB9CisJfQorICAgICAgZWxzZQorCXsKKwkgIGludCB2YWwgPSAxOworI2lmbmRlZiBXSURFX0NIQVJfVkVSU0lPTgorCSAgY2hhciBidWZbN107CisJICBzaXplX3QgYnVmbGVuOworI2VuZGlmCisJICBzaXplX3QgaTsKKworCSAgZm9yIChpZHhjbnQgPSAwOyBpZHhjbnQgPCBpZHhtYXg7ICsraWR4Y250KQorCSAgICB7CisJICAgICAgaWYgKChydWxlICYgc29ydF9mb3J3YXJkKSAhPSAwKQorCQl7CisJCSAgc2l6ZV90IGxlbjsKKworCQkgIGlmIChiYWNrd19zdG9wICE9IH4wdWwpCisJCSAgICB7CisJCSAgICAgLyogSGFuZGxlIHRoZSBwdXNoZWQgZWxlbWVudHMgbm93LiAgKi8KKwkJICAgICAgc2l6ZV90IGJhY2t3OworCisJCSAgICAgIGZvciAoYmFja3cgPSBpZHhjbnQ7IGJhY2t3ID4gYmFja3dfc3RvcDsgKQorCQkJeworCQkJICAtLWJhY2t3OworCQkJICBsZW4gPSB3ZWlnaHRzW2lkeGFycltiYWNrd10rK107CisJCQkgIGlmIChsZW4gIT0gMCkKKwkJCSAgICB7CisjaWZkZWYgV0lERV9DSEFSX1ZFUlNJT04KKwkJCSAgICAgIGlmIChuZWVkZWQgKyAxICsgbGVuIDwgbikKKwkJCQl7CisJCQkJICBkZXN0W25lZWRlZF0gPSB2YWw7CisJCQkJICBmb3IgKGkgPSAwOyBpIDwgbGVuOyArK2kpCisJCQkJICAgIGRlc3RbbmVlZGVkICsgMSArIGldID0KKwkJCQkgICAgICB3ZWlnaHRzW2lkeGFycltiYWNrd10gKyBpXTsKKwkJCQl9CisJCQkgICAgICBuZWVkZWQgKz0gMSArIGxlbjsKKyNlbHNlCisJCQkgICAgICBidWZsZW4gPSB1dGY4X2VuY29kZSAoYnVmLCB2YWwpOworCQkJICAgICAgaWYgKG5lZWRlZCArIGJ1ZmxlbiArIGxlbiA8IG4pCisJCQkJeworCQkJCSAgZm9yIChpID0gMDsgaSA8IGJ1ZmxlbjsgKytpKQorCQkJCSAgICBkZXN0W25lZWRlZCArIGldID0gYnVmW2ldOworCQkJCSAgZm9yIChpID0gMDsgaSA8IGxlbjsgKytpKQorCQkJCSAgICBkZXN0W25lZWRlZCArIGJ1ZmxlbiArIGldID0KKwkJCQkgICAgICB3ZWlnaHRzW2lkeGFycltiYWNrd10gKyBpXTsKKwkJCQl9CisJCQkgICAgICBuZWVkZWQgKz0gYnVmbGVuICsgbGVuOworI2VuZGlmCisJCQkgICAgICBpZHhhcnJbYmFja3ddICs9IGxlbjsKKwkJCSAgICAgIHZhbCA9IDE7CisJCQkgICAgfQorCQkJICBlbHNlCisJCQkgICAgKyt2YWw7CisJCQl9CisKKwkJ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LCBzaXplX3QgbiwKKwkgaW50IG1heF9jaGFyKQoreworICBzaXplX3QgaTsKKyAgY2hhciAqczEsICpzMjsKKworICBhbGlnbjEgJj0gNzsKKyAgaWYgKGFsaWduMSArIGxlbiA+PSBwYWdlX3NpemUpCisgICAgcmV0dXJuOworCisgIGFsaWduMiAmPSA3OworICBpZiAoYWxpZ24yICsgbGVuID49IHBhZ2Vfc2l6ZSkKKyAgICByZXR1cm47CisKKyAgczEgPSAoY2hhciAqKSAoYnVmMSArIGFsaWduMSk7CisgIHMyID0gKGNoYXIgKikgKGJ1ZjIgKyBhbGlnbjIpOworCisgIGZvciAoaSA9IDA7IGkgPCBsZW4gLSAxOyArK2kpCisgICAgeworICAgICAgczFbaV0gPSAzMiArIDIzICogaSAlIChtYXhfY2hhciAtIDMyKTsKKyAgICAgIGlmIChzMVtpXSA9PSAoY2hhcikgYykKKwktLXMxW2ldOworICAgIH0KKyAgczFbbGVuIC0gMV0gPSBjOworICBmb3IgKGkgPSBsZW47IGkgKyBhbGlnbjEgPCBwYWdlX3NpemUgJiYgaSA8IGxlbiArIDY0OyArK2kpCisgICAgczFbaV0gPSAzMiArIDMyICogaSAlIChtYXhfY2hhciAtIDMyKTsKKworICBGT1JfRUFDSF9JTVBMIChpbXBsLCAwKQorICAgIGRvX29uZV90ZXN0IChpbXBsLCBzMiwgczEsIGMsIGxlbiwgbik7Cit9CisKK3N0YXRpYyB2b2lkCitkb19yYW5kb21fdGVzdHMgKHZvaWQpCit7CisgIHNpemVfdCBpLCBqLCBuLCBhbGlnbjEsIGFsaWduMiwgbGVuLCBzaXplLCBtb2RlOworICB1bnNpZ25lZCBjaGFyICpwMSA9IGJ1ZjEgKyBwYWdlX3NpemUgLSA1MTI7CisgIHVuc2lnbmVkIGNoYXIgKnAyID0gYnVmMiArIHBhZ2Vfc2l6ZSAtIDUxMjsKKyAgdW5zaWduZWQgY2hhciAqcmVzLCBjOworCisgIGZvciAobiA9IDA7IG4gPCBJVEVSQVRJT05TOyBuKyspCisgICAgeworICAgICAgbW9kZSA9IHJhbmRvbSAoKTsKKyAgICAgIGMgPSByYW5kb20gKCk7CisgICAgICBpZiAobW9kZSAmIDEpCisJeworCSAgc2l6ZSA9IHJhbmRvbSAoKSAmIDI1NTsKKwkgIGFsaWduMSA9IDUxMiAtIHNpemUgLSAocmFuZG9tICgpICYgMTUpOworCSAgaWYgKG1vZGUgJiAyKQorCSAgICBhbGlnbjIgPSBhbGlnbjEgLSAocmFuZG9tICgpICYgMjQpOworCSAgZWxzZQorCSAgICBhbGlnbjIgPSBhbGlnbjEgLSAocmFuZG9tICgpICYgMzEpOworCSAgaWYgKG1vZGUgJiA0KQorCSAgICB7CisJICAgICAgaiA9IGFsaWduMTsKKwkgICAgICBhbGlnbjEgPSBhbGlnbjI7CisJICAgICAgYWxpZ24yID0gajsKKwkgICAgfQorCSAgaWYgKG1vZGUgJiA4KQorCSAgICBsZW4gPSBzaXplIC0gKHJhbmRvbSAoKSAmIDMxKTsKKwkgIGVsc2UKKwkgICAgbGVuID0gNTEyOworCSAgaWYgKGxlbiA+PSA1MTIpCisJICAgIGxlbiA9IHJhbmRvbSAoKSAmIDUxMTsKKwl9CisgICAgICBlbHNlCisJeworCSAgYWxpZ24xID0gcmFuZG9tICgpICYgMzE7CisJICBpZiAobW9kZSAmIDIpCisJICAgIGFsaWduMiA9IHJhbmRvbSAoKSAmIDMxOworCSAgZWxzZQorCSAgICBhbGlnbjIgPSBhbGlnbjEgKyAocmFuZG9tICgpICYgMjQpOworCSAgbGVuID0gcmFuZG9tICgpICYgNTExOworCSAgaiA9IGFsaWduMTsKKwkgIGlmIChhbGlnbjIgPiBqKQorCSAgICBqID0gYWxpZ24yOworCSAgaWYgKG1vZGUgJiA0KQorCSAgICB7CisJICAgICAgc2l6ZSA9IHJhbmRvbSAoKSAmIDUxMTsKKwkgICAgICBpZiAoc2l6ZSArIGogPiA1MTIpCisJCXNpemUgPSA1MTIgLSBqIC0gKHJhbmRvbSgpICYgMzEpOwor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pOworICBDSEFSICpyZXN1bHQ7CisKKyAgYWxpZ24gJj0gNzsKKyAgaWYgKChhbGlnbiArIGxlbikgKiBzaXplb2YgKENIQVIpID49IHBhZ2Vfc2l6ZSkKKyAgICByZXR1cm47CisKKyAgQ0hBUiAqYnVmID0gKENIQVIgKikgKGJ1ZjEpOworCisgIGZvciAoaSA9IDA7IGkgPCBsZW47ICsraSkKKyAgICB7CisgICAgICBidWZbYWxpZ24gKyBpXSA9IDEgKyAyMyAqIGkgJSBTTUFMTF9DSEFSOworICAgICAgaWYgKGJ1ZlthbGlnbiArIGldID09IHNlZWtfY2hhcikKKwlidWZbYWxpZ24gKyBpXSA9IHNlZWtfY2hhciArIDE7CisgICAgfQorICBidWZbYWxpZ24gKyBsZW5dID0gMDsKKworICBpZiAocG9zIDwgbGVuKQorICAgIHsKKyAgICAgIGJ1ZlthbGlnbiArIHBvc10gPSBzZWVrX2NoYXI7CisgICAgICBidWZbYWxpZ24gKyBsZW5dID0gLXNlZWtfY2hhcjsKKyAgICAgIHJlc3VsdCA9IChDSEFSICopIChidWYgKyBhbGlnbiArIHBvcyk7CisgICAgfQorICBlbHNlCisgICAgeworICAgICAgcmVzdWx0ID0gTlVMTDsKKyAgICAgIGJ1ZlthbGlnbiArIGxlbl0gPSBzZWVrX2NoYXI7CisgICAgfQorCisgIEZPUl9FQUNIX0lNUEwgKGltcGwsIDApCisgICAgZG9fb25lX3Rlc3QgKGltcGwsIChDSEFSICopIChidWYgKyBhbGlnbiksIHNlZWtfY2hhciwgbGVuLCByZXN1bHQpOworfQorCitzdGF0aWMgdm9pZAorZG9fcmFuZG9tX3Rlc3RzICh2b2lkKQoreworICBzaXplX3QgaSwgaiwgbiwgYWxpZ24sIHBvcywgbGVuOworICBpbnQgc2Vla19jaGFyOworICBDSEFSICpyZXN1bHQ7CisgIFVDSEFSICpwID0gKFVDSEFSICopIChidWYxICsgcGFnZV9zaXplKSAtIDUxMjsKKworICBmb3IgKG4gPSAwOyBuIDwgSVRFUkFUSU9OUzsgbisrKQorICAgIHsKKyAgICAgIGFsaWduID0gcmFuZG9tICgpICYgMTU7CisgICAgICBwb3MgPSByYW5kb20gKCkgJiA1MTE7CisgICAgICBpZiAocG9zICsgYWxpZ24gPj0gNTEyKQorCXBvcyA9IDUxMSAtIGFsaWduIC0gKHJhbmRvbSAoKSAmIDcpOworICAgICAgbGVuID0gcmFuZG9tICgpICYgNTExOworICAgICAgaWYgKHBvcyA+PSBsZW4pCisJbGVuID0gcG9zICsgKHJhbmRvbSAoKSAmIDcpOworICAgICAgaWYgKGxlbiArIGFsaWduID49IDUxMikKKwlsZW4gPSA1MTIgLSBhbGlnbiAtIChyYW5kb20gKCkgJiA3KTsKKyAgICAgIHNlZWtfY2hhciA9IHJhbmRvbSAoKSAmIEJJR19DSEFSOworICAgICAgaiA9IGxlbiArIGFsaWduICsgNjQ7CisgICAgICBpZiAoaiA+IDUxMikKKwlqID0gNTEyOworCisgICAgICBmb3IgKGkgPSAwOyBpIDwgajsgaSsrKQorCXsKKwkgIGlmIChpID09IHBvcyArIGFsaWduKQorCSAgICBwW2ldID0gc2Vla19jaGFyOworCSAgZWxzZQorCSAgICB7CisJICAgICAgcFtpXSA9IHJhbmRvbSAoKSAmIEJJR19DSEFSOworCSAgICAgIGlmIChpIDwgcG9zICsgYWxpZ24gJiYgcFtpXSA9PSBzZWVrX2NoYXIpCisJCXBbaV0gPSBzZWVrX2NoYXIgKyAxMzsKKwkgICAgfQorCX0KKworICAgICAgaWYgKHBvcyA8IGxlbikKKwl7CisJICBzaXplX3QgciA9IHJhbmRvbSAoKTsKKwkgIGlmICgociAmIDMxKSA9PSAwKQorCSAgICBsZW4gPSB+KHVpbnRwdHJfdCkgKHAgKyBhbGlnbikgLSAoKHIgPj4gNSkgJiAzMSk7CisJICByZXN1bHQgPSAoQ0hBUiAqKSAocCArIHBvcyArIGFsaWduKTsKKwl9CisgICAgICBlbHNlCisJcmVzdWx0ID0gTlVMTDsKKworICAgICAgRk9SX0VBQ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fdCBpOworICBDSEFSICpzMSwgKnMyOworCisgIGlmIChsZW4gPT0gMCkKKyAgICByZXR1cm47CisKKyAgYWxpZ24xICY9IDYzOworICBpZiAoYWxpZ24xICsgKGxlbiArIDEpICogQ0hBUkJZVEVTID49IHBhZ2Vfc2l6ZSkKKyAgICByZXR1cm47CisKKyAgYWxpZ24yICY9IDYzOworICBpZiAoYWxpZ24yICsgKGxlbiArIDEpICogQ0hBUkJZVEVTID49IHBhZ2Vfc2l6ZSkKKyAgICByZXR1cm47CisKKyAgczEgPSAoQ0hBUiAqKSAoYnVmMSArIGFsaWduMSk7CisgIHMyID0gKENIQVIgKikgKGJ1ZjIgKyBhbGlnbjIpOworCisgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkrKykKKyAgICBzMVtpXSA9IHMyW2ldID0gMSArICgyMyA8PCAoKENIQVJCWVRFUyAtIDEpICogOCkpICogaSAlIENIQVJfX01BWDsKKworICBzMVtsZW5dID0gYWxpZ24xOworICBzMltsZW5dID0gYWxpZ24yOworICBzMltsZW4gLSAxXSAtPSBleHBfcmVzdWx0OworCisgIEZPUl9FQUNIX0lNUEwgKGltcGwsIDApCisgICAgZG9fb25lX3Rlc3QgKGltcGwsIHMxLCBzMiwgbGVuLCBleHBfcmVzdWx0KTsKK30KKworc3RhdGljIHZvaWQKK2RvX3JhbmRvbV90ZXN0cyAodm9pZCkKK3sKKyAgc2l6ZV90IGksIGosIG4sIGFsaWduMSwgYWxpZ24yLCBwb3MsIGxlbjsKKyAgaW50IHJlc3VsdDsKKyAgbG9uZyByOworICBVQ0hBUiAqcDEgPSAgKFVDSEFSICopIChidWYxICsgcGFnZV9zaXplIC0gNTEyICogQ0hBUkJZVEVTKTsKKyAgVUNIQVIgKnAyID0gIChVQ0hBUiAqKSAoYnVmMiArIHBhZ2Vfc2l6ZSAtIDUxMiAqIENIQVJCWVRFUyk7CisKKyAgZm9yIChuID0gMDsgbiA8IElURVJBVElPTlM7IG4rKykKKyAgICB7CisgICBhbGlnbjEgPSByYW5kb20gKCkgJiAzMTsKKyAgICAgIGlmIChyYW5kb20gKCkgJiAxKQorCWFsaWduMiA9IHJhbmRvbSAoKSAmIDMxOworICAgICAgZWxzZQorCWFsaWduMiA9IGFsaWduMSArIChyYW5kb20gKCkgJiAyNCk7CisgICAgICBwb3MgPSByYW5kb20gKCkgJiA1MTE7CisgICAgICBqID0gYWxpZ24xOworICAgICAgaWYgKGFsaWduMiA+IGopCisJaiA9IGFsaWduMjsKKyAgICAgIGlmIChwb3MgKyBqID49IDUxMikKKwlwb3MgPSA1MTEgLSBqIC0gKHJhbmRvbSAoKSAmIDcpOworICAgICAgbGVuID0gcmFuZG9tICgpICYgNTExOworICAgICAgaWYgKGxlbiArIGogPj0gNTEyKQorCWxlbiA9IDUxMSAtIGogLSAocmFuZG9tICgpICYgNyk7CisgICAgICBqID0gbGVuICsgYWxpZ24xICsgNjQ7CisgICAgICBpZiAoaiA+IDUxMikgaiA9IDUxMjsKKyAgICAgIGZvciAoaSA9IDA7IGkgPCBqOyArK2kpCisJcDFbaV0gPSByYW5kb20gKCkgJiAyNTU7CisgICAgICBmb3IgKGkgPSAwOyBpIDwgajsgKytpKQorCXAyW2ldID0gcmFuZG9tICgpICYgMjU1OworCisgICAgICByZXN1bHQgPSAwOworICAgICAgaWYgKHBvcyA+PSBsZW4pCisJTUVNQ1BZICgoQ0hBUiAqKSBwMiArIGFsaWduMiwgKGNvbnN0IENIQVIgKikgcDEgKyBhbGlnbjEsIGxlbik7CisgICAgICBlbHNlCisJeworCSAgTUVNQ1BZICgoQ0hBUiAqKSBwMiArIGFsaWduMiwgKGNvbnN0IENIQVIgKikgcDEgKyBhbGlnbjEsIHBvcyk7CisJICBpZiAocDJbYWxpZ24yICsgcG9zXSA9PSBwMVthbGlnbjEgKyBwb3NdKQorCSAgICB7CisJICAgICAgcDJbYWxpZ24yICsgcG9zXSA9IHJhbmRvbSAoKSAmIDI1NTsKKwkgICAgICBpZiAocDJbYWxpZ24yICsgcG9zXSA9PSBwMVthbGlnbjEgKyBwb3NdKQorCQlwMlthbGlnbjIgKyBwb3NdID0gcDFbYWxpZ24xICsgcG9zXSArIDMgKyAocmFuZG9tICgpICYgMTI3KTsKKwkgICAgfQorCisJICBpZiAocDFbYWxpZ24xICsgcG9zXSA8IHAyW2FsaWduMiArIHBvc10pCisJICAgIHJlc3VsdCA9IC0xOworCSAgZWxzZQorCSAgICByZXN1bHQgPSAxOworCX0KKworICAgICAgRk9SX0VBQ0hfSU1QTCAoaW1wbCwgMSkKKwl7CisJICByID0gQ0FMTCAoaW1wbCwgKENIQVIgKikgcDEgKyBhbGlnbjEsIChjb25zdCBDSEFSICopIHAyICsgYWxpZ24yLAorCQkgICAgbGVuKTsKKwkgIGlmICgociA9PSAwICYmIHJlc3VsdCkKKwkgICAgICB8fCAociA8IDAgJiYgcmVzdWx0ID49IDApCisJICAgICAgfHwgKHIgPiAwICYmIHJlc3VsdCA8PSAwKSkKKwkgICAgeworCSAgICAgIGVycm9yICgwLCAwLCAiSXRlcmF0aW9uICV6ZCAtIHdyb25nIHJlc3VsdCBpbiBmdW5jdGlvbiAlcyAoJXpkLCAlemQsICV6ZCwgJXpkKSAlbGQgIT0gJWQsIHAxICVwIHAyICVwIiwKKwkJICAgICBuLCBpbXBsLT5uYW1lLCBhbGlnbjEgKiBDSEFSQllURVMgJiA2MywgIGFsaWduMiAqIENIQVJCWVRFUyAmIDYzLCBsZW4sIHBvcywgciwgcmVzdWx0LCBwMSwgcDIpOworCSAgICAgIHJldCA9IDE7CisJICAgIH0KKwl9CisgICAgfQorfQorCitzdGF0aWMgdm9pZAorY2hlY2sxICh2b2lkKQoreworICBDSEFSIHMxWzExNl0sIHMyWzExNl07CisgIGludCBuLCBleHBfcmVzdWx0OworCisgIHMxWzBdID0gLTEwODsKKyAgczJbMF0gPSAtMTA4OworICBzMVsxXSA9IDk5OworICBzMlsxXSA9IDk5OworICBzMVsyXSA9IC0xMTM7CisgIHMyWzJdID0gLTExMzsKKyAgczFbM10gPSAxOworICBzMlszXSA9IDE7CisgIHMxWzRdID0gMTE2OworICBzMls0XSA9IDExNjsKKyAgczFbNV0gPSA5OTsKKyAgczJbNV0gPSA5OTsKKyAgczFbNl0gPSAtMTEzOworICBzMls2XSA9IC0xMTM7CisgIHMxWzddID0gMTsKKyAgczJbN10gPSAxOworICBzMVs4XSA9IDg0OworICBzMls4XSA9IDg0OworICBzMVs5XSA9IDk5OworICBzMls5XSA9IDk5OworICBzMVsxMF0gPSAtMTEzOworICBzMlsxMF0gPSAtMTEzOworICBzMVsxMV0gPSAxOworICBzMlsxMV0gPSAxOworICBzMVsxMl0gPSA1MjsKKyAgczJbMTJdID0gNTI7CisgIHMxWzEzXSA9IDk5OworICBzMlsxM10gPSA5OTsKKyAgczFbMTRdID0gLTExMzsKKyAgczJbMTRdID0gLTExMzsKKyAgczFbMTVdID0gMTsKKyAgczJbMTVdID0gMTsKKyAgczFbMTZdID0gLTc2OworICBzMlsxNl0gPSAtNzY7CisgIHMxWzE3XSA9IC0xNDsKKyAgczJbMTddID0gLTE0OworICBzMVsxOF0gPSAtMTA5OworICBzMlsxOF0gPSAtMTA5OworICBzMVsxOV0gPSAxOworICBzMlsxOV0gPSAxOworICBzMVsyMF0gPSAtMTA4OworICBzMlsyMF0gPSAtMTA4OworICBzMVsyMV0gPSAtMTQ7CisgIHMyWzIxXSA9IC0xNDsKKyAgczFbMjJdID0gLTEwOTsKKyAgczJbMjJdID0gLTEwOTsKKyAgczFbMjNdID0gMTsKKyAgczJbMjNdID0gMTsKKyAgczFbMjRdID0gODQ7CisgIHMyWzI0XSA9IDg0OworICBzMVsyNV0gPSAtMTU7CisgIHMyWzI1XSA9IC0xNTsKKyAgczFbMjZdID0gLTEwOTsKKyAgczJbMjZdID0gLTEwOTsKKyAgczFbMjddID0gMTsKKyAgczJbMjddID0gMTsKKyAgczFbMjhdID0gNTI7CisgIHMyWzI4XSA9IDUyOworICBzMVsyOV0gPSAtMTU7CisgIHMyWzI5XSA9IC0xNTsKKyAgczFbMzBdID0gLTEwOTsKKyAgczJbMzBdID0gLTEwOTsKKyAgczFbMzFdID0gMTsKKyAgczJbMzFdID0gMTsKKyAgczFbMzJdID0gMjA7CisgIHMyWzMyXSA9IDIwOworICBzMVszM10gPSAtMTU7CisgIHMyWzMzXSA9IC0xNTsKKyAgczFbMzRdID0gLTEwOTsKKyAgczJbMzRdID0gLTEwOTsKKyAgczFbMzVdID0gMTsKKyAgczJbMzVdID0gMTsKKyAgczFbMzZdID0gMjA7CisgIHMyWzM2XSA9IDIwOworICBzMVszN10gPSAtMTQ7CisgIHMyWzM3XSA9IC0xNDsKKyAgczFbMzhdID0gLTEwOTsKKyAgczJbMzhdID0gLTEwOTsKKyAgczFbMzldID0gMTsKKyAgczJbMzldID0gMTsKKyAgczFbNDBdID0gNTI7CisgIHMyWzQwXSA9IDUyOworICBzMVs0MV0gPSAtMTQ7CisgIHMyWzQxXSA9IC0xNDsKKyAgczFbNDJdID0gLTEwOTsKKyAgczJbNDJdID0gLTEwOTsKKyAgczFbNDNdID0gMTsKKyAgczJbNDNdID0gMTsKKyAgczFbNDRdID0gODQ7CisgIHMyWzQ0XSA9IDg0OworICBzMVs0NV0gPSAtMTQ7CisgIHMyWzQ1XSA9IC0xNDsKKyAgczFbNDZdID0gLTEwOTsKKyAgczJbNDZdID0gLTEwOTsKKyAgczFbNDddID0gMTsKKyAgczJbNDddID0gMTsKKyAgczFbNDhdID0gMTE2OworICBzMls0OF0gPSAxMTY7CisgIHMxWzQ5XSA9IC0xNDsKKyAgczJbNDldID0gLTE0OworICBzMVs1MF0gPSAtMTA5OworICBzMls1MF0gPSAtMTA5OworICBzMVs1MV0gPSAxOworICBzMls1MV0gPSAxOworICBzMVs1Ml0gPSAxMTY7CisgIHMyWzUyXSA9IDExNjsKKyAgczFbNTNdID0gLTE1OworICBzMls1M10gPSAtMTU7CisgIHMxWzU0XSA9IC0xMDk7CisgIHMyWzU0XSA9IC0xMDk7CisgIHMxWzU1XSA9IDE7CisgIHMyWzU1XSA9IDE7CisgIHMxWzU2XSA9IC00NDsKKyAgczJbNTZdID0gLTQ0OworICBzMVs1N10gPSAtMTQ7CisgIHMyWzU3XSA9IC0xNDsKKyAgczFbNThdID0gLTEwOTsKKyAgczJbNThdID0gLTEwOTsKKyAgczFbNTldID0gMTsKKyAgczJbNTldID0gMTsKKyAgczFbNjBdID0gLTEwODsKKyAgczJbNjBdID0gLTEwODsKKyAgczFbNjFdID0gLTE1OworICBzMls2MV0gPSAtMTU7CisgIHMxWzYyXSA9IC0xMDk7CisgIHMyWzYyXSA9IC0xMDk7CisgIHMxWzYzXSA9IDE7CisgIHMyWzYzXSA9IDE7CisgIHMxWzY0XSA9IC03NjsKKyAgczJbNjRdID0gLTc2OworICBzMVs2NV0gPSAtMTU7CisgIHMyWzY1XSA9IC0xNTsKKyAgczFbNjZdID0gLTEwOTsKKyAgczJbNjZdID0gLTEwOTsKKyAgczFbNjddID0gMTsKKyAgczJbNjddID0gMTsKKyAgczFbNjhdID0gLTQ0OworICBzMls2OF0gPSAtNDQ7CisgIHMxWzY5XSA9IC0xNTsKKyAgczJbNjldID0gLTE1OworICBzMVs3MF0gPSAtMTA5OworICBzMls3MF0gPSAtMTA5OworICBzMVs3MV0gPSAxOworICBzMls3MV0gPSAxOworICBzMVs3Ml0gPSAtMTI7CisgIHMyWzcyXSA9IC0xMjsKKyAgczFbNzNdID0gLTE1OworICBzMls3M10gPSAtMTU7CisgIHMxWzc0XSA9IC0xMDk7CisgIHMyWzc0XSA9IC0xMDk7CisgIHMxWzc1XSA9IDE7CisgIHMyWzc1XSA9IDE7CisgIHMxWzc2XSA9IC0xMjsKKyAgczJbNzZdID0gLTEyOworICBzMVs3N10gPSAtMTQ7CisgIHMyWzc3XSA9IC0xNDsKKyAgczFbNzhdID0gLTEwOTsKKyAgczJbNzhdID0gLTEwOTsKKyAgczFbNzldID0gMTsKKyAgczJbNzldID0gMTsKKyAgczFbODBdID0gMjA7CisgIHMyWzgwXSA9IC02ODsKKyAgczFbODFdID0gLTEyOworICBzMls4MV0gPSA2NDsKKyAgczFbODJdID0gLTEwOTsKKyAgczJbODJdID0gLTEwNjsKKyAgczFbODNdID0gMTsKKyAgczJbODNdID0gMTsKKyAgczFbODRdID0gLTEyOworICBzMls4NF0gPSAtMTI7CisgIHMxWzg1XSA9IC0xMzsKKyAgczJbODVdID0gLTEzOworICBzMVs4Nl0gPSAtMTA5OworICBzMls4Nl0gPSAtMTA5OworICBzMVs4N10gPSAxOworICBzMls4N10gPSAxOworICBzMVs4OF0gPSAtNDQ7CisgIHMyWzg4XSA9IC00NDsKKyAgczFbODldID0gLTEzOworICBzMls4OV0gPSAtMTM7CisgIHMxWzkwXSA9IC0xMDk7CisgIHMyWzkwXSA9IC0xMDk7CisgIHMxWzkxXSA9IDE7CisgIHMyWzkxXSA9IDE7CisgIHMxWzkyXSA9IC03NjsKKyAgczJbOTJdID0gLTc2OworICBzMVs5M10gPSAtMTM7CisgIHMyWzkzXSA9IC0xMzsKKyAgczFbOTRdID0gLTEwOTsKKyAgczJbOTRdID0gLTEwOTsKKyAgczFbOTVdID0gMTsKKyAgczJbOTVdID0gMTsKKyAgczFbOTZdID0gLTEwODsKKyAgczJbOTZdID0gLTEwODsKKyAgczFbOTddID0gLTEzOworICBzMls5N10gPSAtMTM7CisgIHMxWzk4XSA9IC0xMDk7CisgIHMyWzk4XSA9IC0xMDk7CisgIHMxWzk5XSA9IDE7CisgIHMyWzk5XSA9IDE7CisgIHMxWzEwMF0gPSAxMTY7CisgIHMyWzEwMF0gPSAxMTY7CisgIHMxWzEwMV0gPSBDSEFSX19NSU47CisgIHMyWzEwMV0gPSBDSEFSX19NQVg7CisgIHMxWzEwMl0gPSAtMTA5OworICBzMlsxMDJdID0gLTEwOTsKKyAgczFbMTAzXSA9IDE7CisgIHMyWzEwM10gPSAxOworICBzMVsxMDRdID0gODQ7CisgIHMyWzEwNF0gPSA4NDsKKyAgczFbMTA1XSA9IC0xMzsKKyAgczJbMTA1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Wx0aW5fbWVtY3B5IChkc3QsIHNyYywgbik7Cit9CisjZW5kaWYKKwordHlwZWRlZiBjaGFyICooKnByb3RvX3QpIChjaGFyICosIGNvbnN0IGNoYXIgKiwgc2l6ZV90KTsKKworc3RhdGljIHZvaWQKK2RvX29uZV90ZXN0IChpbXBsX3QgKmltcGwsIGNoYXIgKmRzdCwgY29uc3QgY2hhciAqc3JjLAorCSAgICAgc2l6ZV90IGxlbikKK3sKKyAgaWYgKENBTEwgKGltcGwsIGRzdCwgc3JjLCBsZW4pICE9IE1FTUNQWV9SRVNVTFQgKGRzdCwgbGVuKSkKKyAgICB7CisgICAgICBlcnJvciAoMCwgMCwgIldyb25nIHJlc3VsdCBpbiBmdW5jdGlvbiAlcyAlcCAlcCIsIGltcGwtPm5hbWUsCisJICAgICBDQUxMIChpbXBsLCBkc3QsIHNyYywgbGVuKSwgTUVNQ1BZX1JFU1VMVCAoZHN0LCBsZW4pKTsKKyAgICAgIHJldCA9IDE7CisgICAgICByZXR1cm47CisgICAgfQorCisgIGlmIChtZW1jbXAgKGRzdCwgc3JjLCBsZW4pICE9IDApCisgICAgeworICAgICAgZXJyb3IgKDAsIDAsICJXcm9uZyByZXN1bHQgaW4gZnVuY3Rpb24gJXMgZHN0ICVwIFwiJS4qc1wiIHNyYyAlcCBcIiUuKnNcIiBsZW4gJXp1IiwKKwkgICAgIGltcGwtPm5hbWUsIGRzdCwgKGludCkgbGVuLCBkc3QsIHNyYywgKGludCkgbGVuLCBzcmMsIGxlbik7CisgICAgICByZXQgPSAxOworICAgICAgcmV0dXJuOworICAgIH0KK30KKworc3RhdGljIHZvaWQKK2RvX3Rlc3QgKHNpemVfdCBhbGlnbjEsIHNpemVfdCBhbGlnbjIsIHNpemVfdCBsZW4pCit7CisgIHNpemVfdCBpLCBqOworICBjaGFyICpzMSwgKnMyOworCisgIGFsaWduMSAmPSA2MzsKKyAgaWYgKGFsaWduMSArIGxlbiA+PSBwYWdlX3NpemUpCisgICAgcmV0dXJuOworCisgIGFsaWduMiAmPSA2MzsKKyAgaWYgKGFsaWduMiArIGxlbiA+PSBwYWdlX3NpemUpCisgICAgcmV0dXJuOworCisgIHMxID0gKGNoYXIgKikgKGJ1ZjEgKyBhbGlnbjEpOworICBzMiA9IChjaGFyICopIChidWYyICsgYWxpZ24yKTsKKworICBmb3IgKGkgPSAwLCBqID0gMTsgaSA8IGxlbjsgaSsrLCBqICs9IDIzKQorICAgIHMxW2ldID0gajsKKworICBGT1JfRUFDSF9JTVBMIChpbXBsLCAwKQorICAgIGRvX29uZV90ZXN0IChpbXBsLCBzMiwgczEsIGxlbik7Cit9CisKK3N0YXRpYyB2b2lkCitkb19yYW5kb21fdGVzdHMgKHZvaWQpCit7CisgIHNpemVfdCBpLCBqLCBuLCBhbGlnbjEsIGFsaWduMiwgbGVuLCBzaXplMSwgc2l6ZTIsIHNpemU7CisgIGludCBjOworICB1bnNpZ25lZCBjaGFyICpwMSwgKnAyOworICB1bnNpZ25lZCBjaGFyICpyZXM7CisKKyAgZm9yIChuID0gMDsgbiA8IElURVJBVElPTlM7IG4rKykKKyAgICB7CisgICAgICBpZiAobiA9PSAwKQorCXsKKwkgIGxlbiA9IGdldHBhZ2VzaXplICgpOworCSAgc2l6ZSA9IGxlbiArIDUxMjsKKwkgIHNpemUxID0gc2l6ZTsKKwkgIHNpemUyID0gc2l6ZTsKKwkgIGFsaWduMSA9IDUxMjsKKwkgIGFsaWduMiA9IDUxMjsKKwl9CisgICAgICBlbHNlCisJeworCSAgaWYgKChyYW5kb20gKCkgJiAyNTUpID09IDApCisJICAgIHNpemUgPSA2NTUzNjsKKwkgIGVsc2UKKwkgICAgc2l6ZSA9IDc2ODsKKwkgIGlmIChzaXplID4gcGFnZV9zaXplKQorCSAgICBzaXplID0gcGFnZV9zaXplOworCSAgc2l6ZTEgPSBzaXplOworCSAgc2l6ZTIgPSBzaXplOworCSAgaSA9IHJhbmRvbSAoKTsKKwkgIGlmIChpICYgMykKKwkgICAgc2l6ZSAtPSAyNTY7CisJICBpZiAoaSAmIDEpCisJICAgIHNpemUxIC09IDI1NjsKKwkgIGlmIChpICYgMikKKwkgICAgc2l6ZTIgLT0gMjU2OworCSAgaWYgKGkgJiA0KQorCSAgICB7CisJICAgICAgbGVuID0gcmFuZG9tICgpICUgc2l6ZTsKKwkgICAgICBhbGlnbjEgPSBzaXplMSAtIGxlbiAtIChyYW5kb20gKCkgJiAzMSk7CisJICAgICAgYWxpZ24yID0gc2l6ZTIgLSBsZW4gLSAocmFuZG9tICgpICYgMzEpOworCSAgICAgIGlmIChhbGlnbjEgPiBzaXplMSkKKwkJYWxpZ24xID0gMDsKKwkgICAgICBpZiAoYWxpZ24yID4gc2l6ZTIpCisJCWFsaWduMiA9IDA7CisJICAgIH0KKwkgIGVsc2UKKwkgICAgeworCSAgICAgIGFsaWduMSA9IHJhbmRvbSAoKSAmIDYzOworCSAgICAgIGFsaWduMiA9IHJhbmRvbSAoKSAmIDYzOworCSAgICAgIGxlbiA9IHJhbmRvbSAoKSAlIHNpemU7CisJICAgICAgaWYgKGFsaWduMSArIGxlbiA+IHNpemUxKQorCQlhbGlnbjEgPSBzaXplMSAtIGxlbjsKKwkgICAgICBpZiAoYWxpZ24yICsgbGVuID4gc2l6ZTIpCisJCWFsaWduMiA9IHNpemUyIC0gbGVuOworCSAgICB9CisJfQorICAgICAgcDEgPSBidWYxICsgcGFnZV9zaXplIC0gc2l6ZTE7CisgICAgICBwMiA9IGJ1ZjIgKyBwYWdlX3NpemUgLSBzaXplMjsKKyAgICAgIGMgPSByYW5kb20gKCkgJiAyNTU7CisgICAgICBqID0gYWxpZ24xICsgbGVuICsgMjU2OworICAgICAgaWYgKGogPiBzaXplMSkKKwlqID0gc2l6ZTE7CisgICAgICBmb3IgKGkgPSAwOyBpIDwgajsgKytpKQorCXAxW2ldID0gcmFuZG9tICgpICYgMjU1OworCisgICAgICBGT1JfRUFDSF9JTVBMIChpbXBsLCAxKQorCXsKKwkgIGogPSBhbGlnbjIgKyBsZW4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pZ24yLCBsZW4pOworCQkgIHJldCA9IDE7CisJCSAgYnJlYWs7CisJCX0KKwkgICAgfQorCSAgaWYgKG1lbWNtcCAocDEgKyBhbGlnbjEsIHAyICsgYWxpZ24yLCBsZW4pKQorCSAgICB7CisJICAgICAgZXJyb3IgKDAsIDAsICJJdGVyYXRpb24gJXpkIC0gZGlmZmVyZW50IHN0cmluZ3MsICVzICglemQsICV6ZCwgJXpkKSIsCisJCSAgICAgbiwgaW1wbC0+bmFtZSwgYWxpZ24xLCBhbGlnbjIsIGxlbik7CisJICAgICAgcmV0ID0gMTsKKwkgICAgfQorCX0KKyAgICB9Cit9CisKK2ludAordGVzdF9tYWluICh2b2lkKQoreworICBzaXplX3QgaTsKKworICB0ZXN0X2luaXQgKCk7CisKKyAgcHJpbnRmICgiJTIzcyIsICIiKTsKKyAgRk9SX0VBQ0hfSU1QTCAoaW1wbCwgMCkKKyAgICBwcmludGYgKCJcdCVzIiwgaW1wbC0+bmFtZSk7CisgIHB1dGNoYXIgKCdcbicpOworCisgIGZvciAoaSA9IDA7IGkgPCAxODsgKytpKQorICAgIHsKKyAgICAgIGRvX3Rlc3QgKDAsIDAsIDEgPDwgaSk7CisgICAgICBkb190ZXN0IChpLCAwLCAxIDw8IGkpOworICAgICAgZG9fdGVzdCAoMCwgaSwgMSA8PCBpKTsKKyAgICAgIGRvX3Rlc3QgKGksIGksIDEgPDwgaSk7CisgICAgfQorCisgIGZvciAoaSA9IDA7IGkgPCAzMjsgKytpKQorICAgIHsKKyAgICAgIGRvX3Rlc3QgKDAsIDAsIGkpOworICAgICAgZG9fdGVzdCAoaSwgMCwgaSk7CisgICAgICBkb190ZXN0ICgwLCBpLCBpKTsKKyAgICAgIGRvX3Rlc3QgKGksIGksIGkpOworICAgIH0KKworICBmb3IgKGkgPSAzOyBpIDwgMzI7ICsraSkKKyAgICB7CisgICAgICBpZiAoKGkgJiAoaSAtIDEpKSA9PSAwKQorCWNvbnRpbnVlOworICAgICAgZG9fdGVzdCA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ChjaGFyICpkc3QsIGNvbnN0IGNoYXIgKnNyYywgc2l6ZV90IG4pCit7CisgIGNoYXIgKnJldCA9IGRzdDsKKyAgaWYgKHNyYyA8IGRzdCkKKyAgICB7CisgICAgICBkc3QgKz0gbjsKKyAgICAgIHNyYyArPSBuOworICAgICAgd2hpbGUgKG4tLSkKKwkqLS1kc3QgPSAqLS1zcmM7CisgICAgfQorICBlbHNlCisgICAgd2hpbGUgKG4tLSkKKyAgICAgICpkc3QrKyA9ICpzcmMrKzsKKyAgcmV0dXJuIHJldDsKK30KKworc3RhdGljIHZvaWQKK2RvX29uZV90ZXN0IChpbXBsX3QgKmltcGwsIGNoYXIgKmRzdCwgY2hhciAqc3JjLCBjb25zdCBjaGFyICpvcmlnX3NyYywKKwkgICAgIHNpemVfdCBsZW4pCit7CisgIG1lbWNweSAoc3JjLCBvcmlnX3NyYywgbGVuKTsKKyNpZmRlZiBURVNUX0JDT1BZCisgIENBTEwgKGltcGwsIHNyYywgZHN0LCBsZW4pOworI2Vsc2UKKyAgY2hhciAqcmVzOworCisgIHJlcyA9IENBTEwgKGltcGwsIGRzdCwgc3JjLCBsZW4pOworICBpZiAocmVzICE9IGRzdCkKKyAgICB7CisgICAgICBlcnJvciAoMCwgMCwgIldyb25nIHJlc3VsdCBpbiBmdW5jdGlvbiAlcyAlcCAlcCIsIGltcGwtPm5hbWUsCisJICAgICByZXMsIGRzdCk7CisgICAgICByZXQgPSAxOworICAgICAgcmV0dXJuOworICAgIH0KKyNlbmRpZgorCisgIGlmIChtZW1jbXAgKGRzdCwgb3JpZ19zcmMsIGxlbikgIT0gMCkKKyAgICB7CisgICAgICBlcnJvciAoMCwgMCwgIldyb25nIHJlc3VsdCBpbiBmdW5jdGlvbiAlcyBkc3QgXCIlc1wiIHNyYyBcIiVzXCIiLAorCSAgICAgaW1wbC0+bmFtZSwgZHN0LCBzcmMpOworICAgICAgcmV0ID0gMTsKKyAgICAgIHJldHVybjsKKyAgICB9Cit9CisKK3N0YXRpYyB2b2lkCitkb190ZXN0IChzaXplX3QgYWxpZ24xLCBzaXplX3QgYWxpZ24yLCBzaXplX3QgbGVuKQoreworICBzaXplX3QgaSwgajsKKyAgY2hhciAqczEsICpzMjsKKworICBhbGlnbjEgJj0gNjM7CisgIGlmIChhbGlnbjEgKyBsZW4gPj0gcGFnZV9zaXplKQorICAgIHJldHVybjsKKworICBhbGlnbjIgJj0gNjM7CisgIGlmIChhbGlnbjIgKyBsZW4gPj0gcGFnZV9zaXplKQorICAgIHJldHVybjsKKworICBzMSA9IChjaGFyICopIChidWYxICsgYWxpZ24xKTsKKyAgczIgPSAoY2hhciAqKSAoYnVmMiArIGFsaWduMik7CisKKyAgZm9yIChpID0gMCwgaiA9IDE7IGkgPCBsZW47IGkrKywgaiArPSAyMykKKyAgICBzMVtpXSA9IGo7CisKKyAgRk9SX0VBQ0hfSU1QTCAoaW1wbCwgMCkKKyAgICBkb19vbmVfdGVzdCAoaW1wbCwgczIsIChjaGFyICopIChidWYyICsgYWxpZ24xKSwgczEsIGxlbik7Cit9CisKK3N0YXRpYyB2b2lkCitkb19yYW5kb21fdGVzdHMgKHZvaWQpCit7CisgIHNpemVfdCBpLCBuLCBhbGlnbjEsIGFsaWduMiwgbGVuLCBzaXplOworICBzaXplX3Qgc3Jjc3RhcnQsIHNyY2VuZCwgZHN0c3RhcnQsIGRzdGVuZDsKKyAgaW50IGM7CisgIHVuc2lnbmVkIGNoYXIgKnAxLCAqcDI7CisjaWZuZGVmIFRFU1RfQkNPUFkKKyAgdW5zaWduZWQgY2hhciAqcmVzOworI2VuZGlmCisKKyAgZm9yIChuID0gMDsgbiA8IElURVJBVElPTlM7IG4rKykKKyAgICB7CisgICAgICBpZiAoKHJhbmRvbSAoKSAmIDI1NSkgPT0gMCkKKwlzaXplID0gNjU1MzY7CisgICAgICBlbHNlCisJc2l6ZSA9IDUxMjsKKyAgICAgIGlmIChzaXplID4gcGFnZV9zaXplKQorCXNpemUgPSBwYWdlX3NpemU7CisgICAgIC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ArIGxlbiA/IHNyY3N0YXJ0IDogYWxpZ24yICsgbGVuOworCSAgaWYgKHNyY2VuZCA+IGFsaWduMiArIGxlbgorCSAgICAgICYmIG1lbWNtcCAocDIgKyBpLCBwMSArIGksIHNyY2VuZCAtIGkpKQorCSAgICB7CisJICAgICAgZXJyb3IgKDAsIDAsICJJdGVyYXRpb24gJXpkIC0gZ2FyYmFnZSBhZnRlciBkc3QsICVzICglemQsICV6ZCwgJXpkKSIsCisJCSAgICAgbiwgaW1wbC0+bmFtZSwgYWxpZ24xLCBhbGlnbjIsIGxlbik7CisJICAgICAgcmV0ID0gMTsKKwkgICAgICBicmVhazsKKwkgICAgfQorCX0KKyAgICB9Cit9CisKK2ludAordGVzdF9tYWluICh2b2lkKQoreworICBzaXplX3QgaTsKKworICB0ZXN0X2luaXQgKCk7CisKKyAgcHJpbnRmICgiJTIzcyIsICIiKTsKKyAgRk9SX0VBQ0hfSU1QTCAoaW1wbCwgMCkKKyAgICBwcmludGYgKCJcdCVzIiwgaW1wbC0+bmFtZSk7CisgIHB1dGNoYXIgKCdcbicpOworCisgIGZvciAoaSA9IDA7IGkgPCAxNDsgKytpKQorICAgIHsKKyAgICAgIGRvX3Rlc3QgKDAsIDMyLCAxIDw8IGkpOworICAgICAgZG9fdGVzdCAoMzIsIDAsIDEgPDwgaSk7CisgICAgICBkb190ZXN0ICgwLCBpLCAxIDw8IGkpOworICAgICAgZG9fdGVzdCAoaSwgMCwgMSA8PCBpKTsKKyAgICB9CisKKyAgZm9yIChpID0gMDsgaSA8IDMyOyArK2kpCisgICAgeworICAgICAgZG9fdGVzdCAoMCwgMzIsIGkpOworICAgICAgZG9fdGVzdCAoMzIsIDAsIGkpOworICAgICAgZG9fdGVzdCAoMCwgaSwgaSk7CisgICAgICBkb190ZXN0IChpLCAwLCBpKTsKKyAgICB9CisKKyAgZm9yIChpID0gMzsgaSA8IDMyOyArK2kpCisgICAgeworICAgICAgaWYgKChpICYgKGkgLSAxKSkgPT0gMCkKKwlj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0dXJuIE5VTEw7Cit9CisKK3N0YXRpYyB2b2lkCitkb19vbmVfdGVzdCAoaW1wbF90ICppbXBsLCBjb25zdCBjaGFyICpzLCBpbnQgYywgc2l6ZV90IG4sIGNoYXIgKmV4cF9yZXMpCit7CisgIGNoYXIgKnJlcyA9IENBTEwgKGltcGwsIHMsIGMsIG4pOworICBpZiAocmVzICE9IGV4cF9yZXMpCisgICAgeworICAgICAgZXJyb3IgKDAsIDAsICJXcm9uZyByZXN1bHQgaW4gZnVuY3Rpb24gJXMgJXAgJXAiLCBpbXBsLT5uYW1lLAorCSAgICAgcmVzLCBleHBfcmVzKTsKKyAgICAgIHJldCA9IDE7CisgICAgICByZXR1cm47CisgICAgfQorfQorCitzdGF0aWMgdm9pZAorZG9fdGVzdCAoc2l6ZV90IGFsaWduLCBzaXplX3QgcG9zLCBzaXplX3QgbGVuLCBpbnQgc2Vla19jaGFyKQoreworICBzaXplX3QgaTsKKyAgY2hhciAqcmVzdWx0OworCisgIGFsaWduICY9IDc7CisgIGlmIChhbGlnbiArIGxlbiA+PSBwYWdlX3NpemUpCisgICAgcmV0dXJuOworCisgIGZvciAoaSA9IDA7IGkgPCBsZW47ICsraSkKKyAgICB7CisgICAgICBidWYxW2FsaWduICsgaV0gPSAxICsgMjMgKiBpICUgMTI3OworICAgICAgaWYgKGJ1ZjFbYWxpZ24gKyBpXSA9PSBzZWVrX2NoYXIpCisgICAgICAgIGJ1ZjFbYWxpZ24gKyBpXSA9IHNlZWtfY2hhciArIDE7CisgICAgfQorICBidWYxW2FsaWduICsgbGVuXSA9IDA7CisKKyAgaWYgKHBvcyA8IGxlbikKKyAgICB7CisgICAgICBidWYxW2FsaWduICsgcG9zXSA9IHNlZWtfY2hhcjsKKyAgICAgIGJ1ZjFbYWxpZ24gKyBsZW5dID0gLXNlZWtfY2hhcjsKKyAgICAgIHJlc3VsdCA9IChjaGFyICopIChidWYxICsgYWxpZ24gKyBwb3MpOworICAgIH0KKyAgZWxzZQorICAgIHsKKyAgICAgIHJlc3VsdCA9IE5VTEw7CisgICAgICBidWYxW2FsaWduICsgbGVuXSA9IHNlZWtfY2hhcjsKKyAgICB9CisKKyAgRk9SX0VBQ0hfSU1QTCAoaW1wbCwgMCkKKyAgICBkb19vbmVfdGVzdCAoaW1wbCwgKGNoYXIgKikgKGJ1ZjEgKyBhbGlnbiksIHNlZWtfY2hhciwgbGVuLCByZXN1bHQpOworfQorCitzdGF0aWMgdm9pZAorZG9fcmFuZG9tX3Rlc3RzICh2b2lkKQoreworICBzaXplX3QgaSwgaiwgbiwgYWxpZ24sIHBvcywgbGVuOworICBpbnQgc2Vla19jaGFyOworICBjaGFyICpyZXN1bHQ7CisgIHVuc2lnbmVkIGNoYXIgKnAgPSBidWYxICsgcGFnZV9zaXplIC0gNTEyOworCisgIGZvciAobiA9IDA7IG4gPCBJVEVSQVRJT05TOyBuKyspCisgICAgeworICAgICAgYWxpZ24gPSByYW5kb20gKCkgJiAxNTsKKyAgICAgIHBvcyA9IHJhbmRvbSAoKSAmIDUxMTsKKyAgICAgIGlmIChwb3MgKyBhbGlnbiA+PSA1MTIpCisJcG9zID0gNTExIC0gYWxpZ24gLSAocmFuZG9tICgpICYgNyk7CisgICAgICBsZW4gPSByYW5kb20gKCkgJiA1MTE7CisgICAgICBpZiAocG9zID49IGxlbikKKwlsZW4gPSBwb3MgKyAocmFuZG9tICgpICYgNyk7CisgICAgICBpZiAobGVuICsgYWxpZ24gPj0gNTEyKQorICAgICAgICBsZW4gPSA1MTIgLSBhbGlnbiAtIChyYW5kb20gKCkgJiA3KTsKKyAgICAgIHNlZWtfY2hhciA9IHJhbmRvbSAoKSAmIDI1NTsKKyAgICAgIGogPSBsZW4gKyBhbGlnbiArIDY0OworICAgICAgaWYgKGogPiA1MTIpCisgICAgICAgIGogPSA1MTI7CisKKyAgICAgIGZvciAoaSA9IDA7IGkgPCBqOyBpKyspCisJeworCSAgaWYgKGkgPT0gcG9zICsgYWxpZ24pCisJICAgIHBbaV0gPSBzZWVrX2NoYXI7CisJICBlbHNlCisJICAgIHsKKwkgICAgICBwW2ldID0gcmFuZG9tICgpICYgMjU1OworCSAgICAgIGlmIChwW2ldID09IHNlZWtfY2hhcikKKwkJcFtpXSA9IHNlZWtfY2hhciArIDEzOworCSAgICB9CisJfQorCisgICAgICBpZiAocG9zIDwgbGVuKQorCXJlc3VsdCA9IChjaGFyICopIChwICsgcG9zICsgYWxpZ24pOworICAgICAgZWxzZQorCXJlc3VsdCA9IE5VTEw7CisKKyAgICAgIEZPUl9FQUNIX0lNUEwgKGltcGwsIDEpCisJaWYgKENBTEwgKGltcGwsIChjaGFyICopIChwICsgYWxpZ24pLCBzZWVrX2NoYXIsIGxlbikgIT0gcmVzdWx0KQorCSAgeworCSAgICBlcnJvciAoMCwgMCwgIkl0ZXJhdGlvbiAlemQgLSB3cm9uZyByZXN1bHQgaW4gZnVuY3Rpb24gJXMgKCV6ZCwgJWQsICV6ZCwgJXpkKSAlcCAhPSAlcCwgcCAlcCIsCisJCSAgIG4sIGltcGwtPm5hbWUsIGFsaWduLCBzZWVrX2NoYXIsIGxlbiwgcG9zLAorCQkgICBDQUxMIChpbXBsLCAoY2hhciAqKSAocCArIGFsaWduKSwgc2Vla19jaGFyLCBsZW4pLAorCQkgICByZXN1bHQsIHApOworCSAgICByZXQgPSAxOworCSAgfQorICAgIH0KK30KKworaW50Cit0ZXN0X21haW4gKHZvaWQpCit7CisgIHNpemVfdCBpOworCisgIHRlc3RfaW5pdCAoKTsKKworICBwcmludGYgKCIlMjBzIiwgIiIpOworICBGT1JfRUFDSF9JTVBMIChpbXBsLCAwKQorICAgIHByaW50ZiAoIlx0JXMiLCBpbXBsLT5uYW1lKTsKKyAgcHV0Y2hhciAoJ1xuJyk7CisKKyAgZm9yIChpID0gMTsgaSA8IDg7ICsraSkKKyAgICB7CisgICAgICBkb190ZXN0ICgwLCAxNiA8PCBpLCAyMDQ4LCAyMyk7CisgICAgICBkb190ZXN0IChpLCA2NCwgMjU2LCAyMyk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2l6ZSkgLSBzaXplOworICAgICAgbGVuID0gcmFuZG9tICgpICYgKHNpemUgLSAxKTsKKyAgICAgIGFsaWduID0gc2l6ZSAtIGxlbiAtIChyYW5kb20gKCkgJiAzMSk7CisgICAgICBpZiAoYWxpZ24gPiBzaXplKQorCWFsaWduID0gc2l6ZSAtIGxlbjsKKyAgICAgIGlmICgocmFuZG9tICgpICYgNykgPT0gMCkKKwlhbGlnbiAmPSB+NjM7CisgICAgICBpZiAoKHJhbmRvbSAoKSAmIDcpID09IDApCisJYyA9IDA7CisgICAgICBlbHNlCisJYyA9IHJhbmRvbSAoKSAmIEJJR19DSEFSOworICAgICAgbyA9IHJhbmRvbSAoKSAmIEJJR19DSEFSOworICAgICAgaWYgKG8gPT0gYykKKwlvID0gKGMgKyAxKSAmIEJJR19DSEFSOworICAgICAgaiA9IGxlbiArIGFsaWduICsgMTI4OworICAgICAgaWYgKGogPiBzaXplKQorCWogPSBzaXplOworICAgICAgaWYgKGFsaWduID49IDEyOCkKKwlrID0gYWxpZ24gLSAxMjg7CisgICAgICBlbHNlCisJayA9IDA7CisgICAgICBmb3IgKGkgPSBrOyBpIDwgYWxpZ247ICsraSkKKwlwW2ldID0gbzsKKyAgICAgIGZvciAoaSA9IGFsaWduICsgbGVuOyBpIDwgajsgKytpKQorCXBbaV0gPSBvOworCisgICAgICBGT1JfRUFDSF9JTVBMIChpbXBsLCAxKQorCXsKKwkgIGZvciAoaSA9IDA7IGkgPCBsZW47ICsraSkKKwkgICAgeworCSAgICAgIHBbaSArIGFsaWduXSA9IHAyW2ldOworCSAgICAgIGlmIChwW2kgKyBhbGlnbl0gPT0gYykKKwkJcFtpICsgYWxpZ25dID0gbzsKKwkgICAgfQorCSAgcmVzID0gKFVDSEFSICopIENBTEwgKGltcGwsIChDSEFSICopIHAgKyBhbGlnbiwgYywgbGVuKTsKKwkgIGlmIChyZXMgIT0gcCArIGFsaWduKQorCSAgICB7CisJICAgICAgZXJyb3IgKDAsIDAsICJJdGVyYXRpb24gJXpkIC0gd3JvbmcgcmVzdWx0IGluIGZ1bmN0aW9uICVzICglemQsICVkLCAlemQpICVwICE9ICVwIiwKKwkJICAgICBuLCBpbXBsLT5uYW1lLCBhbGlnbiwgYywgbGVuLCByZXMsIHAgKyBhbGlnbik7CisJICAgICAgcmV0ID0gMTsKKwkgICAgfQorCSAgZm9yIChpID0gazsgaSA8IGFsaWduOyArK2kpCisJICAgIGlmIChwW2ldICE9IG8pCisJICAgICAgeworCQllcnJvciAoMCwgMCwgIkl0ZXJhdGlvbiAlemQgLSBnYXJiYWdlIGJlZm9yZSAlcyAoJXpkLCAlZCwgJXpkKSIsCisJCSAgICAgICBuLCBpbXBsLT5uYW1lLCBhbGlnbiwgYywgbGVuKTsKKwkJcmV0ID0gMTsKKwkJYnJlYWs7CisJICAgICAgfQorCSAgZm9yICg7IGkgPCBhbGlnbiArIGxlbjsgKytpKQorCSAgICBpZiAocFtpXSAhPSBjKQorCSAgICAgIHsKKwkJZXJyb3IgKDAsIDAsICJJdGVyYXRpb24gJXpkIC0gbm90IGNsZWFyZWQgY29ycmVjdGx5ICVzICglemQsICVkLCAlemQpIiwKKwkJICAgICAgIG4sIGltcGwtPm5hbWUsIGFsaWduLCBjLCBsZW4pOworCQlyZXQgPSAxOworCQlicmVhazsKKwkgICAgICB9CisJICBmb3IgKDsgaSA8IGo7ICsraSkKKwkgICAgaWYgKHBbaV0gIT0gbykKKwkgICAgICB7CisJCWVycm9yICgwLCAwLCAiSXRlcmF0aW9uICV6ZCAtIGdhcmJhZ2UgYWZ0ZXIgJXMgKCV6ZCwgJWQsICV6ZCkiLAorCQkgICAgICAgbiwgaW1wbC0+bmFtZSwgYWxpZ24sIGMsIGxlbik7CisJCXJldCA9IDE7CisJCWJyZWFrOworCSAgICAgIH0KKwl9CisgICAgfQorfQorI2VuZGlmIC8qICFURVNUX0JaRVJPICovCisKK2ludAordGVzdF9tYWluICh2b2lkKQoreworICBzaXplX3QgaTsKKyAgaW50IGMgPSAwOwor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bCBQdWJsaWMKKyAgIExpY2Vuc2UgYWxvbmcgd2l0aCB0aGUgR05VIEMgTGlicmFyeTsgaWYgbm90LCBzZWUKKyAgIDxodHRwOi8vd3d3LmdudS5vcmcvbGljZW5zZXMvPi4gICovCisKKyNpbmNsdWRlIDxhc3NlcnQuaD4KKworI2RlZmluZSBURVNUX01BSU4KKyNkZWZpbmUgVEVTVF9OQU1FICJyYXdtZW1jaHIiCisjaW5jbHVkZSAidGVzdC1zdHJpbmcuaCIKKwordHlwZWRlZiBjaGFyICooKnByb3RvX3QpIChjb25zdCBjaGFyICosIGludCk7CitjaGFyICpzaW1wbGVfcmF3bWVtY2hyIChjb25zdCBjaGFyICosIGludCk7CisKK0lNUEwgKHNpbXBsZV9yYXdtZW1jaHIsIDApCitJTVBMIChyYXdtZW1jaHIsIDEpCisKK2NoYXIgKgorc2ltcGxlX3Jhd21lbWNociAoY29uc3QgY2hhciAqcywgaW50IGMpCit7CisgIHdoaWxlICgxKQorICAgIGlmICgqcysrID09IChjaGFyKSBjKQorICAgICAgcmV0dXJuIChjaGFyICopIHMgLSAxOworICByZXR1cm4gTlVMTDsKK30KKworc3RhdGljIHZvaWQKK2RvX29uZV90ZXN0IChpbXBsX3QgKmltcGwsIGNvbnN0IGNoYXIgKnMsIGludCBjLCBjaGFyICpleHBfcmVzKQoreworICBjaGFyICpyZXMgPSBDQUxMIChpbXBsLCBzLCBjKTsKKyAgaWYgKHJlcyAhPSBleHBfcmVzKQorICAgIHsKKyAgICAgIGVycm9yICgwLCAwLCAiV3JvbmcgcmVzdWx0IGluIGZ1bmN0aW9uICVzICVwICVwIiwgaW1wbC0+bmFtZSwKKwkgICAgIHJlcywgZXhwX3Jlcyk7CisgICAgICByZXQgPSAxOworICAgICAgcmV0dXJuOworICAgIH0KK30KKworc3RhdGljIHZvaWQKK2RvX3Rlc3QgKHNpemVfdCBhbGlnbiwgc2l6ZV90IHBvcywgc2l6ZV90IGxlbiwgaW50IHNlZWtfY2hhcikKK3sKKyAgc2l6ZV90IGk7CisgIGNoYXIgKnJlc3VsdDsKKworICBhbGlnbiAmPSA3OworICBpZiAoYWxpZ24gKyBsZW4gPj0gcGFnZV9zaXplKQorICAgIHJldHVybjsKKworICBmb3IgKGkgPSAwOyBpIDwgbGVuOyArK2kpCisgICAgeworICAgICAgYnVmMVthbGlnbiArIGldID0gMSArIDIzICogaSAlIDEyNzsKKyAgICAgIGlmIChidWYxW2FsaWduICsgaV0gPT0gc2Vla19jaGFyKQorCWJ1ZjFbYWxpZ24gKyBpXSA9IHNlZWtfY2hhciArIDE7CisgICAgfQorICBidWYxW2FsaWduICsgbGVuXSA9IDA7CisKKyAgYXNzZXJ0IChwb3MgPCBsZW4pOworCisgIGJ1ZjFbYWxpZ24gKyBwb3NdID0gc2Vla19jaGFyOworICBidWYxW2FsaWduICsgbGVuXSA9IC1zZWVrX2NoYXI7CisgIHJlc3VsdCA9IChjaGFyICopIChidWYxICsgYWxpZ24gKyBwb3MpOworCisgIEZPUl9FQUNIX0lNUEwgKGltcGwsIDApCisgICAgZG9fb25lX3Rlc3QgKGltcGwsIChjaGFyICopIChidWYxICsgYWxpZ24pLCBzZWVrX2NoYXIsIHJlc3VsdCk7Cit9CisKK3N0YXRpYyB2b2lkCitkb19yYW5kb21fdGVzdHMgKHZvaWQpCit7CisgIHNpemVfdCBpLCBqLCBuLCBhbGlnbiwgcG9zLCBsZW47CisgIGludCBzZWVrX2NoYXI7CisgIGNoYXIgKnJlc3VsdDsKKyAgdW5zaWduZWQgY2hhciAqcCA9IGJ1ZjEgKyBwYWdlX3NpemUgLSA1MTI7CisKKyAgZm9yIChuID0gMDsgbiA8IElURVJBVElPTlM7IG4rKykKKyAgICB7CisgICAgICBhbGlnbiA9IHJhbmRvbSAoKSAmIDE1OworICAgICAgcG9zID0gcmFuZG9tICgpICYgNTExOworICAgICAgaWYgKHBvcyArIGFsaWduID49IDUxMikKKwlwb3MgPSA1MTEgLSBhbGlnbiAtIChyYW5kb20gKCkgJiA3KTsKKyAgICAgIGxlbiA9IHJhbmRvbSAoKSAmIDUxMTsKKyAgICAgIGlmIChsZW4gKyBhbGlnbiA+PSA1MTIpCisJbGVuID0gNTEyIC0gYWxpZ24gLSAocmFuZG9tICgpICYgNyk7CisgICAgICBpZiAocG9zID49IGxlbikKKwljb250aW51ZTsKKyAgICAgIHNlZWtfY2hhciA9IHJhbmRvbSAoKSAmIDI1NTsKKyAgICAgIGogPSBsZW4gKyBhbGlnbiArIDY0OworICAgICAgaWYgKGogPiA1MTIpCisJaiA9IDUxMjsKKworICAgICAgZm9yIChpID0gMDsgaSA8IGo7IGkrKykKKwl7CisJICBpZiAoaSA9PSBwb3MgKyBhbGlnbikKKwkgICAgcFtpXSA9IHNlZWtfY2hhcjsKKwkgIGVsc2UKKwkgICAgeworCSAgICAgIHBbaV0gPSByYW5kb20gKCkgJiAyNTU7CisJICAgICAgaWYgKGkgPCBwb3MgKyBhbGlnbiAmJiBwW2ldID09IHNlZWtfY2hhcikKKwkJcFtpXSA9IHNlZWtfY2hhciArIDEzOworCSAgICB9CisJfQorCisgICAgICBhc3NlcnQgKHBvcyA8IGxlbik7CisgICAgICBzaXplX3QgciA9IHJhbmRvbSAoKTsKKyAgICAgIGlmICgociAmIDMxKSA9PSAwKQorCWxlbiA9IH4odWludHB0cl90KSAocCArIGFsaWduKSAtICgociA+PiA1KSAmIDMxKTsKKyAgICAgIHJlc3VsdCA9IChjaGFyICopIChwICsgcG9zICsgYWxpZ24pOworCisgICAgICBGT1JfRUFDSF9JTVBMIChpbXBsLCAxKQorCWlmIChDQUxMIChpbXBsLCAoY2hhciAqKSAocCArIGFsaWduKSwgc2Vla19jaGFyKSAhPSByZXN1bHQpCisJICB7CisJICAgIGVycm9yICgwLCAwLCAiSXRlcmF0aW9uICV6ZCAtIHdyb25nIHJlc3VsdCBpbiBmdW5jdGlvbiAlcyAoJXpkLCAlZCwgJXpkLCAlemQpICVwICE9ICVwLCBwICVwIiwKKwkJICAgbiwgaW1wbC0+bmF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GUgKChyZXQgPSAoKHVuc2lnbmVkIGNoYXIpIHRvbG93ZXIgKCpzMSkKKwkJIC0gKHVuc2lnbmVkIGNoYXIpIHRvbG93ZXIgKCpzMikpKSA9PSAwCisJICYmICpzMSsrKQorICAgICsrczI7CisgIHJldHVybiByZXQ7Cit9CisKK3N0YXRpYyBpbnQKK3N0dXBpZF9zdHJjYXNlY21wIChjb25zdCBjaGFyICpzMSwgY29uc3QgY2hhciAqczIpCit7CisgIHNpemVfdCBuczEgPSBzdHJsZW4gKHMxKSArIDEsIG5zMiA9IHN0cmxlbiAoczIpICsgMTsKKyAgc2l6ZV90IG4gPSBuczEgPCBuczIgPyBuczEgOiBuczI7CisgIGludCByZXQgPSAwOworCisgIHdoaWxlIChuLS0pCisgICAgeworICAgICAgaWYgKChyZXQgPSAoKHVuc2lnbmVkIGNoYXIpIHRvbG93ZXIgKCpzMSkKKwkJICAtICh1bnNpZ25lZCBjaGFyKSB0b2xvd2VyICgqczIpKSkgIT0gMCkKKwlicmVhazsKKyAgICAgICsrczE7CisgICAgICArK3MyOworICAgIH0KKyAgcmV0dXJuIHJldDsKK30KKworc3RhdGljIHZvaWQKK2RvX29uZV90ZXN0IChpbXBsX3QgKmltcGwsIGNvbnN0IGNoYXIgKnMxLCBjb25zdCBjaGFyICpzMiwgaW50IGV4cF9yZXN1bHQpCit7CisgIGludCByZXN1bHQgPSBDQUxMIChpbXBsLCBzMSwgczIpOworICBpZiAoKGV4cF9yZXN1bHQgPT0gMCAmJiByZXN1bHQgIT0gMCkKKyAgICAgIHx8IChleHBfcmVzdWx0IDwgMCAmJiByZXN1bHQgPj0gMCkKKyAgICAgIHx8IChleHBfcmVzdWx0ID4gMCAmJiByZXN1bHQgPD0gMCkpCisgICAgeworICAgICAgZXJyb3IgKDAsIDAsICJXcm9uZyByZXN1bHQgaW4gZnVuY3Rpb24gJXMgJWQgJWQiLCBpbXBsLT5uYW1lLAorCSAgICAgcmVzdWx0LCBleHBfcmVzdWx0KTsKKyAgICAgIHJldCA9IDE7CisgICAgICByZXR1cm47CisgICAgfQorfQorCitzdGF0aWMgdm9pZAorZG9fdGVzdCAoc2l6ZV90IGFsaWduMSwgc2l6ZV90IGFsaWduMiwgc2l6ZV90IGxlbiwgaW50IG1heF9jaGFyLAorCSBpbnQgZXhwX3Jlc3VsdCkKK3sKKyAgc2l6ZV90IGk7CisgIGNoYXIgKnMxLCAqczI7CisKKyAgaWYgKGxlbiA9PSAwKQorICAgIHJldHVybjsKKworICBhbGlnbjEgJj0gNzsKKyAgaWYgKGFsaWduMSArIGxlbiArIDEgPj0gcGFnZV9zaXplKQorICAgIHJldHVybjsKKworICBhbGlnbjIgJj0gNzsKKyAgaWYgKGFsaWduMiArIGxlbiArIDEgPj0gcGFnZV9zaXplKQorICAgIHJldHVybjsKKworICBzMSA9IChjaGFyICopIChidWYxICsgYWxpZ24xKTsKKyAgczIgPSAoY2hhciAqKSAoYnVmMiArIGFsaWduMik7CisKKyAgZm9yIChpID0gMDsgaSA8IGxlbjsgaSsrKQorICAgIHsKKyAgICAgIHMxW2ldID0gdG91cHBlciAoMSArIDIzICogaSAlIG1heF9jaGFyKTsKKyAgICAgIHMyW2ldID0gdG9sb3dlciAoczFbaV0pOworICAgIH0KKworICBzMVtsZW5dID0gczJbbGVuXSA9IDA7CisgIHMxW2xlbiArIDFdID0gMjM7CisgIHMyW2xlbiArIDFdID0gMjQgKyBleHBfcmVzdWx0OworICBpZiAoKHMyW2xlbiAtIDFdID09ICd6JyAmJiBleHBfcmVzdWx0ID09IC0xKQorICAgICAgfHwgKHMyW2xlbiAtIDFdID09ICdhJyAmJiBleHBfcmVzdWx0ID09IDEpKQorICAgIHMxW2xlbiAtIDFdICs9IGV4cF9yZXN1bHQ7CisgIGVsc2UKKyAgICBzMltsZW4gLSAxXSAtPSBleHBfcmVzdWx0OworCisgIEZPUl9FQUNIX0lNUEwgKGltcGwsIDApCisgICAgZG9fb25lX3Rlc3QgKGltcGwsIHMxLCBzMiwgZXhwX3Jlc3VsdCk7Cit9CisKK3N0YXRpYyB2b2lkCitkb19yYW5kb21fdGVzdHMgKHZvaWQpCit7CisgIHNpemVfdCBpLCBqLCBuLCBhbGlnbjEsIGFsaWduMiwgcG9zLCBsZW4xLCBsZW4yOworICBpbnQgcmVzdWx0OworICBsb25nIHI7CisgIHVuc2lnbmVkIGNoYXIgKnAxID0gYnVmMSArIHBhZ2Vfc2l6ZSAtIDUxMjsKKyAgdW5zaWduZWQgY2hhciAqcDIgPSBidWYyICsgcGFnZV9zaXplIC0gNTEyOworCisgIGZvciAobiA9IDA7IG4gPCBJVEVSQVRJT05TOyBuKyspCisgICAgeworICAgICAgYWxpZ24xID0gcmFuZG9tICgpICYgMzE7CisgICAgICBpZiAocmFuZG9tICgpICYgMSkKKwlhbGlnbjIgPSByYW5kb20gKCkgJiAzMTsKKyAgICAgIGVsc2UKKwlhbGlnbjIgPSBhbGlnbjEgKyAocmFuZG9tICgpICYgMjQpOworICAgICAgcG9zID0gcmFuZG9tICgpICYgNTExOworICAgICAgaiA9IGFsaWduMSA+IGFsaWduMiA/IGFsaWduMSA6IGFsaWduMjsKKyAgICAgIGlmIChwb3MgKyBqID49IDUxMSkKKwlwb3MgPSA1MTAgLSBqIC0gKHJhbmRvbSAoKSAmIDcpOworICAgICAgbGVuMSA9IHJhbmRvbSAoKSAmIDUxMTsKKyAgICAgIGlmIChwb3MgPj0gbGVuMSAmJiAocmFuZG9tICgpICYgMSkpCisJbGVuMSA9IHBvcyArIChyYW5kb20gKCkgJiA3KTsKKyAgICAgIGlmIChsZW4xICsgaiA+PSA1MTIpCisJbGVuMSA9IDUxMSAtIGogLSAocmFuZG9tICgpICYgNyk7CisgICAgICBpZiAocG9zID49IGxlbjEpCisJbGVuMiA9IGxlbjE7CisgICAgICBlbHNlCisJbGVuMiA9IGxlbjEgKyAobGVuMSAhPSA1MTEgLSBqID8gcmFuZG9tICgpICUgKDUxMSAtIGogLSBsZW4xKSA6IDApOworICAgICAgaiA9IChwb3MgPiBsZW4yID8gcG9zIDogbGVuMikgKyBhbGlnbjEgKyA2NDsKKyAgICAgIGlmIChqID4gNTEyKQorCWogPSA1MTI7CisgICAgICBmb3IgKGkgPSAwOyBpIDwgajsgKytpKQorCXsKKwkgIHAxW2ldID0gdG9sb3dlciAocmFuZG9tICgpICYgMjU1KTsKKwkgIGlmIChpIDwgbGVuMSArIGFsaWduMSAmJiAhcDFbaV0pCisJICAgIHsKKwkgICAgICBwMVtpXSA9IHRvbG93ZXIgKHJhbmRvbSAoKSAmIDI1NSk7CisJICAgICAgaWYgKCFwMVtpXSkKKwkJcDFbaV0gPSB0b2xvd2VyICgxICsgKHJhbmRvbSAoKSAmIDEyNykpOworCSAgICB9CisJfQorICAgICAgZm9yIChpID0gMDsgaSA8IGo7ICsraSkKKwl7CisJICBwMltpXSA9IHRvdXBwZXIgKHJhbmRvbSAoKSAmIDI1NSk7CisJICBpZiAoaSA8IGxlbjIgKyBhbGlnbjIgJiYgIXAyW2ldKQorCSAgICB7CisJICAgICAgcDJbaV0gPSB0b3VwcGVyIChyYW5kb20gKCkgJiAyNTUpOworCSAgICAgIGlmICghcDJbaV0pCisJCXRvdXBwZXIgKHAyW2ldID0gMSArIChyYW5kb20gKCkgJiAxMjcpKTsKKwkgICAgfQorCX0KKworICAgICAgcmVzdWx0ID0gMDsKKyAgICAgIG1lbWNweSAocDIgKyBhbGlnbjIsIHAxICsgYWxpZ24xLCBwb3MpOworICAgICAgaWYgKHBvcyA8IGxlbjEpCisJeworCSAgaWYgKHRvbG93ZXIgKHAyW2FsaWduMiArIHBvc10pID09IHAxW2FsaWduMSArIHBvc10pCisJICAgIHsKKwkgICAgICBwMlthbGlnbjIgKyBwb3NdID0gdG91cHBlciAocmFuZG9tICgpICYgMjU1KTsKKwkgICAgICBpZiAodG9sb3dlciAocDJbYWxpZ24yICsgcG9zXSkgPT0gcDFbYWxpZ24xICsgcG9zXSkKKwkJcDJbYWxpZ24yICsgcG9zXSA9IHRvdXBwZXIgKHAxW2FsaWduMSArIHBvc10KKwkJCQkJICAgICsgMyArIChyYW5kb20gKCkgJiAxMjcpKTsKKwkgICAgfQorCisJICBpZiAocDFbYWxpZ24xICsgcG9zXSA8IHRvbG93ZXIgKHAyW2FsaWduMiArIHBvc10pKQorCSAgICByZXN1bHQgPSAtMTsKKwkgIGVsc2UKKwkgICAgcmVzdWx0ID0gMTsKKwl9CisgICAgICBwMVtsZW4xICsgYWxpZ24xXSA9IDA7CisgICAgICBwMltsZW4yICsgYWxpZ24yXSA9IDA7CisKKyAgICAgIEZPUl9FQUNIX0lNUEwgKGltcGwsIDEpCisJeworCSAgciA9IENBTEwgKGltcGwsIChjaGFyICopIChwMSArIGFsaWduMSksIChjaGFyICopIChwMiArIGFsaWduMikpOworCSAgLyogVGVzdCB3aGV0aGVyIG9uIDY0LWJpdCBhcmNoaXRlY3R1cmVzIHdoZXJlIEFCSSByZXF1aXJlcworCSAgICAgY2FsbGVlIHRvIHByb21vdGUgaGFzIHRoZSBwcm9tb3Rpb24gYmVlbiBkb25lLiAgKi8KKwkgIGFzbSAoIiIgOiAiPWciIChyKSA6ICIwIiAocikpOworCSAgaWYgKChyID09IDAgJiYgcmVzdWx0KQorCSAgICAgIHx8IChyIDwgMCAmJiByZXN1bHQgPj0gMCkKKwkgICAgICB8fCAociA+IDAgJiYgcmVzdWx0IDw9IDApKQorCSAgICB7CisJICAgICAgZXJyb3IgKDAsIDAsICJJdGVyYXRpb24gJXpkIC0gd3JvbmcgcmVzdWx0IGluIGZ1bmN0aW9uICVzICglemQsICV6ZCwgJXpkLCAlemQsICV6ZCkgJWxkICE9ICVkLCBwMSAlcCBwMiAlcCIsCisJCSAgICAgbiwgaW1wbC0+bmFtZSwgYWxpZ24xLCBhbGlnbjIsIGxlbjEsIGxlbjIsIHBvcywgciwgcmVzdWx0LCBwMSwgcDIpOworCSAgICAgIHJldCA9IDE7CisJICAgIH0KKwl9CisgICAgfQorfQorCitzdGF0aWMgdm9pZAordGVzdF9sb2NhbGUgKGNvbnN0IGNoYXIgKmxvY2FsZSkKK3sKKyAgc2l6ZV90IGk7CisKKyAgaWYgKHNldGxvY2FsZSAoTENfQ1RZUEUsIGxvY2FsZSkgPT0gTlVMTCkKKyAgICB7CisgICAgICBlcnJvciAoMCwgMCwgImNhbm5vdCBzZXQgbG9jYWxlIFwiJXNcIiIsIGxvY2FsZSk7CisgICAgICByZXQgPSAxOworICAgIH0KKworICBwcmludGYgKCIlLTIzcyIsIGxvY2FsZSk7CisgIEZPUl9FQUNIX0lNUEwgKGltcGwsIDApCisgICAgcHJpbnRmICgiXHQlcyIsIGltcGwtPm5hbWUpOworICBwdXRjaGFyICgnXG4nKTsKKworICBmb3IgKGkgPSAxOyBpIDwgMTY7ICsraSkKKyAgICB7CisgICAgICBkb190ZXN0IChpLCBpLCBpLCAxMjcsIDApOworICAgICAgZG9fdGVzdCAoaSwgaSwgaSwgMTI3LCAxKTsKKyAgICAgIGRvX3Rlc3QgKGksIGksIGksIDEyNywgLTEpOworICAgIH0KKworICBmb3IgKGkgPSAxOyBpIDwgMTA7ICsraSkKKyAgICB7CisgICAgICBkb190ZXN0ICgwLCAwLCAyIDw8IGksIDEyNywgMCk7CisgICAgICBkb190ZXN0ICgwLCAwLCAyIDw8IGksIDI1NCwgMCk7CisgICAgICBkb190ZXN0ICgwLCAwLCAyIDw8IGksIDEyNywgMSk7CisgICAgICBkb190ZXN0ICgwLCAwLCAyIDw8IGksIDI1NCwgMSk7CisgICAgICBkb190ZXN0ICgwLCAwLCAyIDw8IGksIDEyNywgLTEpOworICAgICAgZG9fdGVzdCAoMCwgMCwgMiA8PCBpLCAyNTQsIC0xKTsKKyAgICB9CisKKyAgZm9yIChpID0gMTsgaSA8IDg7ICsraSkKKyAgICB7CisgICAgICBkb190ZXN0IChpLCAyICogaSwgOCA8PCBpLCAxMjcsIDApOworICAgICAgZG9fdGVzdCAoMiAqIGksIGksIDggPDwgaSwgMjU0LCAwKTsKKyAgICAgIGRvX3Rlc3QgKGksIDIgK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isjZGVmaW5lIFRFU1RfTkFNRSAic3RyY2FzZXN0ciIKKyNpbmNsdWRlICJ0ZXN0LXN0cmluZy5oIgorCisKKyNkZWZpbmUgU1RSQ0FTRVNUUiBzaW1wbGVfc3RyY2FzZXN0cgorI2RlZmluZSBOT19BTElBUworI2RlZmluZSBfX3N0cm5jYXNlY21wIHN0cm5jYXNlY21wCisjaW5jbHVkZSAic3RyY2FzZXN0ci5jIgorCisKK3N0YXRpYyBjaGFyICoKK3N0dXBpZF9zdHJjYXNlc3RyIChjb25zdCBjaGFyICpzMSwgY29uc3QgY2hhciAqczIpCit7CisgIHNzaXplX3QgczFsZW4gPSBzdHJsZW4gKHMxKTsKKyAgc3NpemVfdCBzMmxlbiA9IHN0cmxlbiAoczIpOworCisgIGlmIChzMmxlbiA+IHMxbGVuKQorICAgIHJldHVybiBOVUxMOworCisgIGZvciAoc3NpemVfdCBpID0gMDsgaSA8PSBzMWxlbiAtIHMybGVuOyArK2kpCisgICAgeworICAgICAgc2l6ZV90IGo7CisgICAgICBmb3IgKGogPSAwOyBqIDwgczJsZW47ICsraikKKwlpZiAodG9sb3dlciAoczFbaSArIGpdKSAhPSB0b2xvd2VyIChzMltqXSkpCisJICBicmVhazsKKyAgICAgIGlmIChqID09IHMybGVuKQorCXJldHVybiAoY2hhciAqKSBzMSArIGk7CisgICAgfQorCisgIHJldHVybiBOVUxMOworfQorCisKK3R5cGVkZWYgY2hhciAqKCpwcm90b190KSAoY29uc3QgY2hhciAqLCBjb25zdCBjaGFyICopOworCitJTVBMIChzdHVwaWRfc3RyY2FzZXN0ciwgMCkKK0lNUEwgKHNpbXBsZV9zdHJjYXNlc3RyLCAwKQorSU1QTCAoc3RyY2FzZXN0ciwgMSkKKworCitzdGF0aWMgaW50CitjaGVja19yZXN1bHQgKGltcGxfdCAqaW1wbCwgY29uc3QgY2hhciAqczEsIGNvbnN0IGNoYXIgKnMyLAorCSAgICAgIGNoYXIgKmV4cF9yZXN1bHQpCit7CisgIGNoYXIgKnJlc3VsdCA9IENBTEwgKGltcGwsIHMxLCBzMik7CisgIGlmIChyZXN1bHQgIT0gZXhwX3Jlc3VsdCkKKyAgICB7CisgICAgICBlcnJvciAoMCwgMCwgIldyb25nIHJlc3VsdCBpbiBmdW5jdGlvbiAlcyAlcyAlcyIsIGltcGwtPm5hbWUsCisJICAgICByZXN1bHQsIGV4cF9yZXN1bHQpOworICAgICAgcmV0ID0gMTsKKyAgICAgIHJldHVybiAtMTsKKyAgICB9CisgIHJldHVybiAwOworfQorCitzdGF0aWMgdm9pZAorZG9fb25lX3Rlc3QgKGltcGxfdCAqaW1wbCwgY29uc3QgY2hhciAqczEsIGNvbnN0IGNoYXIgKnMyLCBjaGFyICpleHBfcmVzdWx0KQoreworICBpZiAoY2hlY2tfcmVzdWx0IChpbXBsLCBzMSwgczIsIGV4cF9yZXN1bHQpIDwgMCkKKyAgICByZXR1cm47Cit9CisKKworc3RhdGljIHZvaWQKK2RvX3Rlc3QgKHNpemVfdCBhbGlnbjEsIHNpemVfdCBhbGlnbjIsIHNpemVfdCBsZW4xLCBzaXplX3QgbGVuMiwKKwkgaW50IGZhaWwpCit7CisgIGNoYXIgKnMxID0gKGNoYXIgKikgKGJ1ZjEgKyBhbGlnbjEpOworICBjaGFyICpzMiA9IChjaGFyICopIChidWYyICsgYWxpZ24yKTsKKworICBzdGF0aWMgY29uc3QgY2hhciBkW10gPSAiMTIzNDU2Nzg5MGFiY3h5eiI7CisjZGVmaW5lIGRsIChzaXplb2YgKGQpIC0gMSkKKyAgY2hhciAqc3MyID0gczI7CisgIGZvciAoc2l6ZV90IGwgPSBsZW4yOyBsID4gMDsgbCA9IGwgPiBkbCA/IGwgLSBkbCA6IDApCisgICAgeworICAgICAgc2l6ZV90IHQgPSBsID4gZGwgPyBkbCA6IGw7CisgICAgICBzczIgPSBtZW1wY3B5IChzczIsIGQsIHQpOworICAgIH0KKyAgczJbbGVuMl0gPSAnXDAnOworCisgIGlmIChmYWlsKQorICAgIHsKKyAg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gVUNIQVIgKnAyID0gKFVDSEFSICopIChidWYyICsgcGFnZV9zaXplKSAtIDUxMjsKKyAgVUNIQVIgKnAzID0gKFVDSEFSICopIGJ1ZjE7CisgIFVDSEFSICpyZXM7CisKKyAgZm9yIChuID0gMDsgbiA8IElURVJBVElPTlM7IG4rKykKKyAgICB7CisgICAgICBhbGlnbjEgPSByYW5kb20gKCkgJiAzMTsKKyAgICAgIGlmIChyYW5kb20gKCkgJiAxKQorCWFsaWduMiA9IHJhbmRvbSAoKSAmIDMxOworICAgICAgZWxzZQorCWFsaWduMiA9IGFsaWduMSArIChyYW5kb20gKCkgJiAyNCk7CisgICAgICBsZW4xID0gcmFuZG9tICgpICYgNTExOworICAgICAgaWYgKGxlbjEgKyBhbGlnbjIgPiA1MTIpCisJbGVuMiA9IHJhbmRvbSAoKSAmIDc7CisgICAgICBlbHNlCisJbGVuMiA9ICg1MTIgLSBsZW4xIC0gYWxpZ24yKSAqIChyYW5kb20gKCkgJiAoMTAyNCAqIDEwMjQgLSAxKSkKKwkgICAgICAgLyAoMTAyNCAqIDEwMjQpOworICAgICAgaiA9IGFsaWduMTsKKyAgICAgIGlmIChhbGlnbjIgKyBsZW4yID4gaikKKwlqID0gYWxpZ24yICsgbGVuMjsKKyAgICAgIGlmIChsZW4xICsgaiA+PSA1MTEpCisJbGVuMSA9IDUxMCAtIGogLSAocmFuZG9tICgpICYgNyk7CisgICAgICBpZiAobGVuMSA+PSA1MTIpCisJbGVuMSA9IDA7CisgICAgICBpZiAoYWxpZ24xICsgbGVuMSA8IDUxMiAtIDgpCisJeworCSAgaiA9IDUxMCAtIGFsaWduMSAtIGxlbjEgLSAocmFuZG9tICgpICYgMzEpOworCSAgaWYgKGogPiAwICYmIGogPCA1MTIpCisJICAgIGFsaWduMSArPSBqOworCX0KKyAgICAgIGogPSBsZW4xICsgYWxpZ24xICsgNjQ7CisgICAgICBpZiAoaiA+IDUxMikKKwlqID0gNTEyOworICAgICAgZm9yIChpID0gMDsgaSA8I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GVuMSArIDEpKQorCSAgICB7CisJICAgICAgZXJyb3IgKDAsIDAsICJJdGVyYXRpb24gJXpkIC0gZGlmZmVyZW50IHN0cmluZ3MsICVzICglemQsICV6ZCwgJXpkLCAlemQpIiwKKwkJICAgICBuLCBpbXBsLT5uYW1lLCBhbGlnbjEsIGFsaWduMiwgbGVuMSwgbGVuMik7CisJICAgICAgcmV0ID0gMTsKKwkgICAgfQorCX0KKyAgICB9Cit9CisKK2ludAordGVzdF9tYWluICh2b2lkKQoreworICBzaXplX3QgaTsKKworICB0ZXN0X2luaXQgKCk7CisKKyAgcHJpbnRmICgiJTI4cyIsICIiKTsKKyAgRk9SX0VBQ0hfSU1QTCAoaW1wbCwgMCkKKyAgICBwcmludGYgKCJcdCVzIiwgaW1wbC0+bmFtZSk7CisgIHB1dGNoYXIgKCdcbicpOworCisgIGZvciAoaSA9IDA7IGkgPCAxNjsgKytpKQorICAgIHsKKyAgICAgIGRvX3Rlc3QgKDAsIDAsIGksIGksIFNNQUxMX0NIQVIpOworICAgICAgZG9fdGVzdCAoMCwgMCwgaSwgaSwgQklHX0NIQVIpOworICAgICAgZG9fdGVzdCAoMCwgaSwgaSwgaSwgU01BTExfQ0hBUik7CisgICAgICBkb190ZXN0IChpLCAwLCBpLCBpLCBCSUdfQ0hBUik7CisgICAgfQorCisgIGZvciAoaSA9IDE7IGkgPCA4OyArK2kpCisgICAgeworICAgICAgZG9fdGVzdCAoMCwgMCwgOCA8PCBpLCA4IDw8IGksIFNNQUxMX0NIQVIpOworICAgICAgZG9fdGVzdCAoOCAtIGksIDIgKiBpLCA4IDw8IGksIDggPDwgaSwgU01BTExfQ0hBUik7CisgICAgICBkb190ZXN0ICgwLCAwLCA4IDw8IGksIDIgPDwgaSwgU01BTExfQ0hBUik7CisgICAgICBkb190ZXN0ICg4IC0gaSwgMiAqIGksIDggPDwgaSwgMiA8PCBpLCBTTUFMTF9DSEFSKTsKKyAgICB9CisKKyAgZm9yIChpID0gMTsgaSA8IDg7IC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UkNIUiwgMSkKKworc3RhdGljIGludAorY2hlY2tfcmVzdWx0IChpbXBsX3QgKmltcGwsIGNvbnN0IENIQVIgKnMsIGludCBjLCBjb25zdCBDSEFSICpleHBfcmVzKQoreworICBDSEFSICpyZXMgPSBDQUxMIChpbXBsLCBzLCBjKTsKKyAgaWYgKHJlcyAhPSBleHBfcmVzKQorICAgIHsKKyAgICAgIGVycm9yICgwLCAwLCAiV3JvbmcgcmVzdWx0IGluIGZ1bmN0aW9uICVzICUjeCAlcCAlcCIsIGltcGwtPm5hbWUsCisJICAgICBjLCByZXMsIGV4cF9yZXMpOworICAgICAgcmV0ID0gMTsKKyAgICAgIHJldHVybiAtMTsKKyAgICB9CisgIHJldHVybiAwOworfQorCitzdGF0aWMgdm9pZAorZG9fb25lX3Rlc3QgKGltcGxfdCAqaW1wbCwgY29uc3QgQ0hBUiAqcywgaW50IGMsIGNvbnN0IENIQVIgKmV4cF9yZXMpCit7CisgIGlmIChjaGVja19yZXN1bHQgKGltcGwsIHMsIGMsIGV4cF9yZXMpIDwgMCkKKyAgICByZXR1cm47Cit9CisKK3N0YXRpYyB2b2lkCitkb190ZXN0IChzaXplX3QgYWxpZ24sIHNpemVfdCBwb3MsIHNpemVfdCBsZW4sIGludCBzZWVrX2NoYXIsIGludCBtYXhfY2hhcikKKy8qIEZvciB3Y3NjaHI6IGFsaWduIGhlcmUgbWVhbnMgYWxpZ24gbm90IGluIGJ5dGVzLAorICAgYnV0IGluIHdjaGFyX3RzLCBpbiBieXRlcyBpdCB3aWxsIGVxdWFsIHRvIGFsaWduICogKHNpemVvZiAod2NoYXJfdCkpCisgICBsZW4gZm9yIHdjc2NociBoZXJlIGlzbid0IGluIGJ5dGVzIGJ1dCBpdCdzIG51bWJlciBvZiB3Y2hhcl90IHN5bWJvbHMuICAqLworeworICBzaXplX3QgaTsKKyAgQ0hBUiAqcmVzdWx0OworICBDSEFSICpidWYgPSAoQ0hBUiAqKSBidWYxOworICBhbGlnbiAmPSAxNTsKK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d2hpbGUgKChyZXQgPSAqKHVuc2lnbmVkIGNoYXIgKikgczEgLSAqKHVuc2lnbmVkIGNoYXIqKSBzMisrKSA9PSAwICYmICpzMSsrKTsKKyAgcmV0dXJuIHJldDsKK30KKworaW50CitzdHVwaWRfc3RyY21wIChjb25zdCBjaGFyICpzMSwgY29uc3QgY2hhciAqczIpCit7CisgIHNpemVfdCBuczEgPSBzdHJsZW4gKHMxKSArIDE7CisgIHNpemVfdCBuczIgPSBzdHJsZW4gKHMyKSArIDE7CisgIHNpemVfdCBuID0gbnMxIDwgbnMyID8gbnMxIDogbnMyOworICBpbnQgcmV0ID0gMDsKKworICB3aGlsZSAobi0tKQorICAgIGlmICgocmV0ID0gKih1bnNpZ25lZCBjaGFyICopIHMxKysgLSAqKHVuc2lnbmVkIGNoYXIgKikgczIrKykgIT0gMCkKKyAgICAgIGJyZWFrOworICByZXR1cm4gcmV0OworfQorI2VuZGlmCisKK3R5cGVkZWYgaW50ICgqcHJvdG9fdCkgKGNvbnN0IENIQVIgKiwgY29uc3QgQ0hBUiAqKTsKKworSU1QTCAoU1RVUElEX1NUUkNNUCwgMSkKK0lNUEwgKFNJTVBMRV9TVFJDTVAsIDEpCitJTVBMIChTVFJDTVAsIDEpCisKK3N0YXRpYyBpbnQKK2NoZWNrX3Jlc3VsdCAoaW1wbF90ICppbXBsLAorCSAgICAgY29uc3QgQ0hBUiAqczEsIGNvbnN0IENIQVIgKnMyLAorCSAgICAgaW50IGV4cF9yZXN1bHQpCit7CisgIGludCByZXN1bHQgPSBDQUxMIChpbXBsLCBzMSwgczIpOworICBpZiAoKGV4cF9yZXN1bHQgPT0gMCAmJiByZXN1bHQgIT0gMCkKKyAgICAgIHx8IChleHBfcmVzdWx0IDwgMCAmJiByZXN1bHQgPj0gMCkKKyAgICAgIHx8IChleHBfcmVzdWx0ID4gMCAmJiByZXN1bHQgPD0gMCkpCisgICAgeworICAgICAgZXJyb3IgKDAsIDAsICJXcm9uZyByZXN1bHQgaW4gZnVuY3Rpb24gJXMgJWQgJWQiLCBpbXBsLT5uYW1lLAorCSAgICAgcmVzdWx0LCBleHBfcmVzdWx0KTsKKyAgICAgIHJldCA9IDE7CisgICAgICByZXR1cm4gLTE7CisgICAgfQorCisgIHJldHVybiAwOworfQorCitzdGF0aWMgdm9pZAorZG9fb25lX3Rlc3QgKGltcGxfdCAqaW1wbCwKKwkgICAgIGNvbnN0IENIQVIgKnMxLCBjb25zdCBDSEFSICpzMiwKKwkgICAgIGludCBleHBfcmVzdWx0KQoreworICBpZiAoY2hlY2tfcmVzdWx0IChpbXBsLCBzMSwgczIsIGV4cF9yZXN1bHQpIDwgMCkKKyAgICByZXR1cm47Cit9CisKK3N0YXRpYyB2b2lkCitkb190ZXN0IChzaXplX3QgYWxpZ24xLCBzaXplX3QgYWxpZ24yLCBzaXplX3QgbGVuLCBpbnQgbWF4X2NoYXIsCisJIGludCBleHBfcmVzdWx0KQoreworICBzaXplX3QgaTsKKworICBDSEFSICpzMSwgKnMyOworCisgIGlmIChsZW4gPT0gMCkKKyAgICByZXR1cm47CisKKyAgYWxpZ24xICY9IDYzOworICBpZiAoYWxpZ24xICsgKGxlbiArIDEpICogQ0hBUkJZVEVTID49IHBhZ2Vfc2l6ZSkKKyAgICByZXR1cm47CisKKyAgYWxpZ24yICY9IDYzOworICBpZiAoYWxpZ24yICsgKGxlbiArIDEpICogQ0hBUkJZVEVTID49IHBhZ2Vfc2l6ZSkKKyAgICByZXR1cm47CisKKyAgLyogUHV0IHRoZW0gY2xvc2UgdG8gdGhlIGVuZCBvZiBwYWdlLiAgKi8KKyAgaSA9IGFsaWduMSArIENIQVJCWVRFUyAqIChsZW4gKyAyKTsKKyAgczEgPSAoQ0hBUiAqKSAoYnVmMSArICgocGFnZV9zaXplIC0gaSkgLyAxNiAqIDE2KSArIGFsaWduMSk7CisgIGkgPSBhbGlnbjIgKyBDSEFSQllURVMgKiAobGVuICsgMik7CisgIHMyID0gKENIQVIgKikgKGJ1ZjIgKyAoKHBh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orCQkgIHsKKwkJICAgIHAxW2ldID0gcmFuZG9tICgpICYgMjU1OworCQkgICAgaWYgKCFwMVtpXSkKKwkJICAgICAgcDFbaV0gPSAxICsgKHJhbmRvbSAoKSAmIDEyNyk7CisJCSAgfQorCSAgICAgIH0KKwkgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCBqOyArK2kpCisJICAgICAgeworCQlwMltpXSA9IHJhbmRvbSAoKSAmIDI1NTsKKwkJaWYgKGkgPCBsZW4yICsgYWxpZ24yICYmICFwMltpXSkKKwkJICB7CisJCSAgICBwMltpXSA9IHJhbmRvbSAoKSAmIDI1NTsKKwkJICAgIGlmICghcDJbaV0pCisJCSAgICAgIHAyW2ldID0gMSArIChyYW5kb20gKCkgJiAxMjcpOworCQkgIH0KKwkgICAgICB9CisKKwkgICAgaW50IHJlc3VsdCA9IDA7CisJICAgIE1FTUNQWSAocDIgKyBhbGlnbjIsIHAxICsgYWxpZ24xLCBwb3MpOworCSAgICBpZiAocG9zIDwgbGVuMSkKKwkgICAgICB7CisJCWlmIChwMlthbGlnbjIgKyBwb3NdID09IHAxW2FsaWduMSArIHBvc10pCisJCSAgeworCQkgICAgcDJbYWxpZ24yICsgcG9zXSA9IHJhbmRvbSAoKSAmIDI1NTsKKwkJICAgIGlmIChwMlthbGlnbjIgKyBwb3NdID09IHAxW2FsaWduMSArIHBvc10pCisJCSAgICAgIHAyW2FsaWduMiArIHBvc10gPSBwMVthbGlnbjEgKyBwb3NdICsgMyArIChyYW5kb20gKCkgJiAxMjcpOworCQkgIH0KKworCQlpZiAocDFbYWxpZ24xICsgcG9zXSA8IHAyW2FsaWduMiArIHBvc10pCisJCSAgcmVzdWx0ID0gLTE7CisJCWVsc2UKKwkJICByZXN1bHQgPSAxOworCSAgICAgIH0KKwkgICAgcDFbbGVuMSArIGFsaWduMV0gPSAwOworCSAgICBwMltsZW4yICsgYWxpZ24yXSA9IDA7CisKKwkgICAgRk9SX0VBQ0hfSU1QTCAoaW1wbCwgMSkK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ICAgIHMxW2ldID0gMHgwMDsKKyAgICAgIHMyW2ldID0gMHgwMDsKKyAgICB9CisKKyAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCAxNjsgaSsrKQorICAgIHsKKyAgICAgIGludCBleHBfcmVzdWx0OworCisgICAgICBmb3IgKGludCB2YWwgPSAweDAxOyB2YWwgPCAweDEwMDsgdmFsKyspCisJeworCSAgZm9yIChzaXplX3QgaiA9IDA7IGogPCBpOyBqKyspCisJICAgIHsKKwkgICAgICBzMVtqXSA9IHZhbDsKKwkgICAgICBzMltqXSA9IHZhbDsKKwkgICAgfQorCisJICBzMltpXSA9IHZhbDsKKworCSAgZXhwX3Jlc3VsdCA9IFNJTVBMRV9TVFJDTVAgKHMxLCBzMik7CisJICBGT1JfRUFDSF9JTVBMIChpbXBsLCAwKQorCSAgICBjaGVja19yZXN1bHQgKGltcGwsIHMxLCBzMiwgZXhwX3Jlc3VsdCk7CisJfQorICAgIH0KK30KKworCitpbnQKK3Rlc3RfbWFpbiAodm9pZCkKK3sKKyAgc2l6ZV90IGk7CisKKyAgdGVzdF9pbml0ICgpOworICBjaGVjaygpOworCisgIHByaW50ZiAoIiUyM3MiLCAiIik7CisgIEZPUl9FQUNIX0lNUEwgKGltcGwsIDApCisgICAgcHJpbnRmICgiXHQlcyIsIGltcGwtPm5hbWUpOworICBwdXRjaGFyICgnXG4nKTsKKworICBmb3IgKGkgPSAxOyBpIDwgMzI7ICsraSkKKyAgICB7CisgICAgICBkb190ZXN0IChDSEFSQllURVMgKiBpLCBDSEFSQllURVMgKiBpLCBpLCBNSURDSEFSLCAwKTsKKyAgICAgIGRvX3Rlc3QgKENIQVJCWVRFUyAqIGksIENIQVJCWVRFUyAqIGksIGksIE1JRENIQVIsIDEpOworICAgICAgZG9fdGVzdCAoQ0hBUkJZVEVTICogaSwgQ0hBUkJZVEVTICogaSwgaSwgTUlEQ0hBUiwgLTEpOworICAgIH0KKworICBmb3IgKGkgPSAxOyBpIDwgMTAgKyBDSEFSQ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ZW4pOworCQkgIHJldCA9IDE7CisJCSAgYnJlYWs7CisJCX0KKwkgICAgfQorCSAgaWYgKE1FTUNNUCAocDEgKyBhbGlnbjEsIHAyICsgYWxpZ24yLCBsZW4gKyAxKSkKKwkgICAgeworCSAgICAgIGVycm9yICgwLCAwLCAiSXRlcmF0aW9uICV6ZCAtIGRpZmZlcmVudCBzdHJpbmdzLCAlcyAoJXpkLCAlemQsICV6ZCkiLAorCQkgICAgIG4sIGltcGwtPm5hbWUsIGFsaWduMSwgYWxpZ24yLCBsZW4pOworCSAgICAgIHJldCA9IDE7CisJICAgIH0KKwl9CisgICAgfQorfQorCitpbnQKK3Rlc3RfbWFpbiAodm9pZCkKK3sKKyAgc2l6ZV90IGk7CisKKyAgdGVzdF9pbml0ICgpOworCisgIHByaW50ZiAoIiUyM3MiLCAiIik7CisgIEZPUl9FQUNIX0lNUEwgKGltcGwsIDApCisgICAgcHJpbnRmICgiXHQlcyIsIGltcGwtPm5hbWUpOworICBwdXRjaGFyICgnXG4nKTsKKworICBmb3IgKGkgPSAwOyBpIDwgMTY7ICsraSkKKyAgICB7CisgICAgICBkb190ZXN0ICgwLCAwLCBpLCBTTUFMTF9DSEFSKTsKKyAgICAgIGRvX3Rlc3QgKDAsIDAsIGksIEJJR19DSEFSKTsKKyAgICAgIGRvX3Rlc3QgKDAsIGksIGksIFNNQUxMX0NIQVIpOworICAgICAgZG9fdGVzdCAoaSwgMCwgaSwgQklHX0NIQVIpOworICAgIH0KKworICBmb3IgKGkgPSAxOyBpIDwgODsgKytpKQorICAgIHsKKyAgICAgIGRvX3Rlc3QgKDAsIDAsIDggPDwgaSwgU01BTExfQ0hBUik7CisgICAgICBkb190ZXN0ICg4IC0gaSwgMiAqIGksIDggPDwgaSwgU01BTExfQ0hBUik7CisgICAgfQorCisgIGZvciAoaSA9IDE7IGkgPCA4OyArK2kpCisgICAgeworICAgICAgZG9fdGVzdCAoaSwgMiAqIGksIDggPDwgaSwgU01BTExfQ0hBUik7CisgICA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ICAgbGVuID0gcmFuZG9tICgpICYgNTExOworICAgICAgaWYgKGxlbiArIGFsaWduID4gNTEwKQorCWxlbiA9IDUxMSAtIGFsaWduIC0gKHJhbmRvbSAoKSAmIDcpOworICAgICAgaiA9IGxlbiArIGFsaWduICsgNjQ7CisgICAgICBpZiAoaiA+IDUxMikKKwlqID0gNTEyOworCisgICAgICBmb3IgKGkgPSAwOyBpIDwgajsgaSsrKQorCXsKKwkgIGlmIChpID09IGxlbiArIGFsaWduKQorCSAgICBwW2ldID0gMDsKKwkgIGVsc2UKKwkgICAgeworCSAgICAgIHBbaV0gPSByYW5kb20gKCkgJiAyNTU7CisJICAgICAgaWYgKGkgPj0gYWxpZ24gJiYgaSA8IGxlbiArIGFsaWduICYmICFwW2ldKQorCQlwW2ldID0gKHJhbmRvbSAoKSAmIDEyNykgKyAxOworCSAgICB9CisJfQorCisgICAgICBGT1JfRUFDSF9JTVBMIChpbXBsLCAxKQorCWlmIChDQUxMIChpbXBsLCAoQ0hBUiAqKSAocCArIGFsaWduKSkgIT0gbGVuKQorCSAgeworCSAgICBlcnJvciAoMCwgMCwgIkl0ZXJhdGlvbiAlemQgLSB3cm9uZyByZXN1bHQgaW4gZnVuY3Rpb24gJXMgKCV6ZCkgJXpkICE9ICV6ZCwgcCAlcCIsCisJCSAgIG4sIGltcGwtPm5hbWUsIGFsaWduLCBDQUxMIChpbXBsLCAoQ0hBUiAqKSAocCArIGFsaWduKSksCisJCSAgIGxlbiwgcCk7CisJICAgIHJldCA9IDE7CisJICB9CisgICAgfQorfQorCitpbnQKK3Rlc3RfbWFpbiAodm9pZCkKK3sKKyAgc2l6ZV90IGk7CisKKyAgdGVzdF9pbml0ICgpOworCisgIHByaW50ZiAoIiUyMHMiLCAiIik7CisgIEZPUl9FQUNIX0lNUEwgKGltcGwsIDApCisgICAgcHJpbnRmICgiXHQlcyIsIGltcGwtPm5hbWUpOworICBwdXRjaGFyICgnXG4nKTsKKworICAvKiBDaGVja2luZyB3aXRoIG9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7CisgIHNpemVfdCBuczIgPSBzdHJsZW4gKHMyKSArIDE7CisgIHNpemVfdCBuID0gbnMxIDwgbnMyID8gbnMxIDogbnMyOworICBpZiAobiA+IG1heCkKKyAgICBuID0gbWF4OworICBpbnQgcmV0ID0gMDsKKworICB3aGlsZSAobi0tKQorICAgIHsKKyAgICAgIGlmICgocmV0ID0gKCh1bnNpZ25lZCBjaGFyKSB0b2xvd2VyICgqczEpCisJCSAgLSAodW5zaWduZWQgY2hhcikgdG9sb3dlciAoKnMyKSkpICE9IDApCisJYnJlYWs7CisgICAgICArK3MxOworICAgICAgKytzMjsKKyAgICB9CisgIHJldHVybiByZXQ7Cit9CisKK3N0YXRpYyBpbnQKK2NoZWNrX3Jlc3VsdCAoaW1wbF90ICppbXBsLCBjb25zdCBjaGFyICpzMSwgY29uc3QgY2hhciAqczIsIHNpemVfdCBuLAorCSAgICAgIGludCBleHBfcmVzdWx0KQoreworICBpbnQgcmVzdWx0ID0gQ0FMTCAoaW1wbCwgczEsIHMyLCBuKTsKKyAgaWYgKChleHBfcmVzdWx0ID09IDAgJiYgcmVzdWx0ICE9IDApCisgICAgICB8fCAoZXhwX3Jlc3VsdCA8IDAgJiYgcmVzdWx0ID49IDApCisgICAgICB8fCAoZXhwX3Jlc3VsdCA+IDAgJiYgcmVzdWx0IDw9IDApKQorICAgIHsKKyAgICAgIGVycm9yICgwLCAwLCAiV3JvbmcgcmVzdWx0IGluIGZ1bmN0aW9uICVzICVkICVkIiwgaW1wbC0+bmFtZSwKKwkgICAgIHJlc3VsdCwgZXhwX3Jlc3VsdCk7CisgICAgICByZXQgPSAxOworICAgICAgcmV0dXJuIC0xOworICAgIH0KKworICByZXR1cm4gMDsKK30KKworc3RhdGljIHZvaWQKK2RvX29uZV90ZXN0IChpbXBsX3QgKmltcGwsIGNvbnN0IGNoYXIgKnMxLCBjb25zdCBjaGFyICpzMiwgc2l6ZV90IG4sCisJICAgICBpbnQgZXhwX3Jlc3VsdCkKK3sKKyAgaWYg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gKHNldGxvY2FsZSAoTENfQ1RZUEUsIGxvY2FsZSkgPT0gTlVMTCkKKyAgICB7CisgICAgICBlcnJvciAoMCwgMCwgImNhbm5vdCBzZXQgbG9jYWxlIFwiJXNcIiIsIGxvY2FsZSk7CisgICAgICByZXQgPSAxOworICAgIH0KKworICBiejEyMjA1ICgpOworICBiejE0MTk1ICgpOworCisgIHByaW50ZiAoIiUyM3MiLCBsb2NhbGUpOworICBGT1JfRUFDSF9JTVBMIChpbXBsLCAwKQorICAgIHByaW50ZiAoIlx0JXMiLCBpbXBsLT5uYW1lKTsKKyAgcHV0Y2hhciAoJ1xuJyk7CisKKyAgZm9yIChpID0gMTsgaSA8IDE2OyArK2kpCisgICAgeworICAgICAgZG9fdGVzdCAoaSwgaSwgaSAtIDEsIGksIDEyNywgMCk7CisKKyAgICAgIGRvX3Rlc3QgKGksIGksIGksIGksIDEyNywgMCk7CisgICAgICBkb190ZXN0IChpLCBpLCBpLCBpLCAxMjcsIDEpOworICAgICAgZG9fdGVzdCAoaSwgaSwgaSwgaSwgMTI3LCAtMSk7CisKKyAgICAgIGRvX3Rlc3QgKGksIGksIGkgKyAxLCBpLCAxMjcsIDApOworICAgICAgZG9fdGVzdCAoaSwgaSwgaSArIDEsIGksIDEyNywgMSk7CisgICAgICBkb190ZXN0IChpLCBpLCBpICsgMSwgaSwgMTI3LCAtMSk7CisgICAgfQorCisgIGZvciAoaSA9IDE7IGkgPCAxMDsgKytpKQorICAgIHsKKyAgICAgIGRvX3Rlc3QgKDAsIDAsICgyIDw8IGkpIC0gMSwgMiA8PCBpLCAxMjcsIDApOworICAgICAgZG9fdGVzdCAoMCwgMCwgMiA8PCBpLCAyIDw8IGksIDI1NCwgMCk7CisgICAgICBkb190ZXN0ICgwLCAwLCAoMiA8PCBpKSArIDEsIDIgPDwgaSwgMTI3LCAwKTsKKworICAgICAgZG9fdGVzdCAoMCwgMCwgKDIgPDwgaSkgKyAxLCAyIDw8IGksIDI1NCwgMCk7CisKKyAgIC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kgICAgIENBTEwgKGltcGwsIGRzdCwgc3JjLCBuKSwgZHN0KTsKKyAgICAgIHJldCA9IDE7CisgICAgICByZXR1cm47CisgICAgfQorCisgIHNpemVfdCBsZW4gPSBTVFJMRU4gKHNyYyk7CisgIGlmIChNRU1DTVAgKGRzdCArIGssIHNyYywgbGVuICsgMSA+IG4gPyBuIDogbGVuICsgMSkgIT0gMCkKKyAgICB7CisgICAgICBlcnJvciAoMCwgMCwgIkluY29ycmVjdCBjb25jYXRlbmF0aW9uIGluIGZ1bmN0aW9uICVzIiwKKwkgICAgIGltcGwtPm5hbWUpOworICAgICAgcmV0ID0gMTsKKyAgICAgIHJldHVybjsKKyAgICB9CisgIGlmIChuIDwgbGVuICYmIGRzdFtrICsgbl0gIT0gJ1wwJykKKyAgICB7CisgICAgICBlcnJvciAoMCwgMCwgIlRoZXJlIGlzIG5vIHplcm8gaW4gdGhlIGVuZCBvZiBvdXRwdXQgc3RyaW5nIGluICVzIiwKKwkgICAgIGltcGwtPm5hbWUpOworICAgICAgcmV0ID0gMTsKKyAgICAgIHJldHVybjsKKyAgICB9Cit9CisKK3N0YXRpYyB2b2lkCitkb190ZXN0IChzaXplX3QgYWxpZ24xLCBzaXplX3QgYWxpZ24yLCBzaXplX3QgbGVuMSwgc2l6ZV90IGxlbjIsCisJIHNpemVfdCBuLCBpbnQgbWF4X2NoYXIpCit7CisgIHNpemVfdCBpOworICBDSEFSICpzMSwgKnMyOworCisgIGFsaWduMSAmPSA3OworICBpZiAoKGFsaWduMSArIGxlbjEpICogc2l6ZW9mIChDSEFSKSA+PSBwYWdlX3NpemUpCisgICAgcmV0dXJuOworICBpZiAoKGFsaWduMSArIG4pICogc2l6ZW9mIChDSEFSKSA+IHBhZ2Vfc2l6ZSkKKyAgICByZXR1cm47CisgIGFsaWduMiAmPSA3OworICBpZiAoKGFsaWduMiArIGxlbjEgKyBsZW4yKSAqIHNpemVvZiAoQ0hBUikgPj0gcGFnZV9zaXplKQorICAgIHJldHVybjsK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RvbSAoKSAmIDMxOworICAgICAgaWYgKHJhbmRvbSAoKSAmIDEpCisJYWxpZ24yID0gcmFuZG9tICgpICYgMzE7CisgICAgICBlbHNlCisJYWxpZ24yID0gYWxpZ24xICsgKHJhbmRvbSAoKSAmIDI0KTsKKyAgICAgIGxlbjEgPSByYW5kb20gKCkgJiA1MTE7CisgICAgICBpZiAobGVuMSArIGFsaWduMiA+IDUxMikKKwlsZW4yID0gcmFuZG9tICgpICYgNzsKKyAgICAgIGVsc2UKKwlsZW4yID0gKDUxMiAtIGxlbjEgLSBhbGlnbjIpICogKHJhbmRvbSAoKSAmICgxMDI0ICogMTAyNCAtIDEpKQorCSAgLyAoMTAyNCAqIDEwMjQpOworICAgICAgaiA9IGFsaWduMTsKKyAgICAgIGlmIChhbGlnbjIgKyBsZW4yID4gaikKKwlqID0gYWxpZ24yICsgbGVuMjsKKyAgICAgIGlmIChsZW4xICsgaiA+PSA1MTEpCisJbGVuMSA9IDUxMCAtIGogLSAocmFuZG9tICgpICYgNyk7CisgICAgICBpZiAobGVuMSA+PSA1MTIpCisJbGVuMSA9IDA7CisgICAgICBpZiAoYWxpZ24xICsgbGVuMSA8IDUxMiAtIDgpCisJeworCSAgaiA9IDUxMCAtIGFsaWduMSAtIGxlbjEgLSAocmFuZG9tICgpICYgMzEpOworCSAgaWYgKGogPiAwICYmIGogPCA1MTIpCisJICAgIGFsaWduMSArPSBqOworCX0KKyAgICAgIGogPSBsZW4xICsgYWxpZ24xICsgNjQ7CisgICAgICBpZiAoaiA+IDUxMikKKwlqID0gNTEyOworICAgICAgZm9yIChpID0gMDsgaSA8IGo7IGkrKykKKwl7CisJICBpZiAoaSA9PSBsZW4xICsgYWxpZ24xKQorCSAgICBwMVtpXSA9IDA7CisJICBlbHNlCisJICAgIHsKKwkgICAgICBwMVtpXSA9IHJhbmRvbSAoKSAmIEJJR19DSEFSOworCSAgICAgIGlmIChpID49IGFsaWduMSAmJiBpIDwgbGVuMSArIGFsaWduMSAmJiAhcD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fTUFYIENIQVJfTUFYCisjIGRlZmluZSBDSEFSX19NSU4gQ0hBUl9NSU4KKworLyogU3RybmNtcCB1c2VzIHVuc2lnbmVkIHNlbWFudGljcyBmb3IgY29tcGFyaXNvbi4gKi8KK2ludAorc2ltcGxlX3N0cm5jbXAgKGNvbnN0IGNoYXIgKnMxLCBjb25zdCBjaGFyICpzMiwgc2l6ZV90IG4pCit7CisgIGludCByZXQgPSAwOworCisgIHdoaWxlIChuLS0gJiYgKHJldCA9ICoodW5zaWduZWQgY2hhciAqKSBzMSAtICogKHVuc2lnbmVkIGNoYXIgKikgczIrKykgPT0gMAorCSAmJiAqczErKyk7CisgIHJldHVybiByZXQ7Cit9CisKK2ludAorc3R1cGlkX3N0cm5jbXAgKGNvbnN0IGNoYXIgKnMxLCBjb25zdCBjaGFyICpzMiwgc2l6ZV90IG4pCit7CisgIHNpemVfdCBuczEgPSBzdHJubGVuIChzMSwgbikgKyAxLCBuczIgPSBzdHJubGVuIChzMiwgbikgKyAxOworICBpbnQgcmV0ID0gMDsKKworICBuID0gbnMxIDwgbiA/IG5zMSA6IG47CisgIG4gPSBuczIgPCBuID8gbnMyIDogbjsKKyAgd2hpbGUgKG4tLSAmJiAocmV0ID0gKih1bnNpZ25lZCBjaGFyICopIHMxKysgLSAqICh1bnNpZ25lZCBjaGFyICopIHMyKyspID09IDApOworICByZXR1cm4gcmV0OworfQorCisjZW5kaWYKKwordHlwZWRlZiBpbnQgKCpwcm90b190KSAoY29uc3QgQ0hBUiAqLCBjb25zdCBDSEFSICosIHNpemVfdCk7CisKK0lNUEwgKFNUVVBJRF9TVFJOQ01QLCAwKQorSU1QTCAoU0lNUExFX1NUUk5DTVAsIDApCitJTVBMIChTVFJOQ01QLCAxKQorCisKK3N0YXRpYyBpbnQKK2NoZWNrX3Jlc3VsdCAoaW1wbF90ICppbXBsLCBjb25zdCBDSEFSICpzMSwgY29uc3QgQ0hBUiAqczIsIHNpemVfdCBuLAorCSAgICAgaW50IGV4cF9yZXN1bHQpCit7CisgIGludCByZXN1bHQgPSBDQUxMIChpbXBsLCBzMSwgczIsIG4pOworICBpZiAoKGV4cF9yZXN1bHQgPT0gMCAmJiByZXN1bHQgIT0gMCkKKyAgICAgIHx8IChleHBfcmVzdWx0IDwgMCAmJiByZXN1bHQgPj0gMCkKKyAgICAgIHx8IChleHBfcmVzdWx0ID4gMCAmJiByZXN1bHQgPD0gMCkpCisgICAgeworICAgICAgZXJyb3IgKDAsIDAsICJXcm9uZyByZXN1bHQgaW4gZnVuY3Rpb24gJXMgJWQgJWQiLCBpbXBsLT5uYW1lLAorCSAgICAgcmVzdWx0LCBleHBfcmVzdWx0KTsKKyAgICAgIHJldCA9IDE7CisgICAgICByZXR1cm4gLTE7CisgICAgfQorCisgIHJldHVybiAwOworfQorCitzdGF0aWMgdm9pZAorZG9fb25lX3Rlc3QgKGltcGxfdCAqaW1wbCwgY29uc3QgQ0hBUiAqczEsIGNvbnN0IENIQVIgKnMyLCBzaXplX3QgbiwKKwkgICAgIGludCBleHBfcmVzdWx0KQoreworICBpZiAoY2hlY2tfcmVzdWx0IChpbXBsLCBzMSwgczIsIG4sIGV4cF9yZXN1bHQpIDwgMCkKKyAgICByZXR1cm47Cit9CisKK3N0YXRpYyB2b2lkCitkb190ZXN0X2xpbWl0IChzaXplX3QgYWxpZ24xLCBzaXplX3QgYWxpZ24yLCBzaXplX3QgbGVuLCBzaXplX3QgbiwgaW50IG1heF9jaGFyLAorCSBpbnQgZXhwX3Jlc3VsdCkKK3sKKyAgc2l6ZV90IGksIGFsaWduX247CisgIENIQVIgKnMxLCAqczI7CisKKyAgaWYgKG4gPT0gMCkKKyAgICB7CisgICAgICBzMSA9IChDSEFSICopIChidWYxICsgcGFnZV9zaXplKTsKKyAgICAgIHMyID0gKENIQVIgKikgKGJ1ZjIgKyBwYWdlX3NpemUpOworCisgICAgICBGT1JfRUFDSF9JTVBMIChpbXBsLCAwKQorCWRvX29uZV90ZXN0IChpbXBsLCBzMSwgczIsIG4sIDApOworCisgICAgICByZXR1cm47CisgICAgfQorCisgIGFsaWduMSAmPSAxNTsKKyAgYWxpZ24yICY9IDE1OworICBhbGlnbl9uID0gKHBhZ2Vfc2l6ZSAtIG4gKiBDSEFSQllURVMpICYgMTU7CisKKyAgczEgPSAoQ0hBUiAqKSAoYnVmMSArIHBhZ2Vfc2l6ZSAtIG4gKiBDSEFSQllURVMpOworICBzMiA9IChDSEFSICopIChidWYyICsgcGFnZV9zaXplIC0gbiAqIENIQVJCWVRFUyk7CisKKyAgaWYgKGFsaWduMSA8IGFsaWduX24pCisgICAgczEgPSAoQ0hBUiAqKSAoKGNoYXIgKikgczEgLSAoYWxpZ25fbiAtIGFsaWduMSkpOworCisgIGlmIChhbGlnbjIgPCBhbGlnbl9uKQorICAgIHMyID0gKENIQVIgKikgKChjaGFyICopIHMyIC0gKGFsaWduX24gLSBhbGlnbjIpKTsKKworICBmb3IgKGkgPSAwOyBpIDwgbjsgaSsrKQorICAgIHMxW2ldID0gczJbaV0gPSAxICsgMjMgKiBpICUgbWF4X2NoYXI7CisKKyAgaWYgKGxlbiA8IG4pCisgICAgeworICAgICAgczFbbGVuXSA9IDA7CisgICAgICBzMltsZW5dID0gMDsKKyAgICAgIGlmIChleHBfcmVzdWx0IDwgMCkKKwlzMltsZW5dID0gMzI7CisgICAgICBlbHNlIGlmIChleHBfcmVzdWx0ID4gMCkKKwlzMVtsZW5dID0gNjQ7CisgICAgfQorCisgIEZPUl9FQUNIX0lNUEwgKGltcGwsIDApCisgICAgZG9fb25lX3Rlc3QgKGltcGwsIHMxLCBzMiwgbiwgZXhwX3Jlc3VsdCk7Cit9CisKK3N0YXRpYyB2b2lkCitkb190ZXN0IChzaXplX3QgYWxpZ24xLCBzaXplX3QgYWxpZ24yLCBzaXplX3QgbGVuLCBzaXplX3QgbiwgaW50IG1heF9jaGFyLAorCSBpbnQgZXhwX3Jlc3VsdCkKK3sKKyAgc2l6ZV90IGk7CisgIENIQVIgKnMxLCAqczI7CisKKyAgaWYgKG4gPT0gMCkKKyAgICByZXR1cm47CisKKyAgYWxpZ24xICY9IDYzOworICBpZiAoYWxpZ24xICsgKG4gKyAxKSAqIENIQVJCWVRFUyA+PSBwYWdlX3NpemUpCisgICAgcmV0dXJuOworCisgIGFsaWduMiAmPSA2MzsKKyAgaWYgKGFsaWduMiArIChuICsgMSkgKiBDSEFSQllURVMgPj0gcGFnZV9zaXplKQorICAgIHJldHVybjsKKworICBzMSA9IChDSEFSICopIChidWYxICsgYWxpZ24xKTsKKyAgczIgPSAoQ0hBUiAqKSAoYnVmMiArIGFsaWduMik7CisKKyAgZm9yIChpID0gMDsgaSA8IG47IGkrKykKKyAgICBzMVtpXSA9IHMyW2ldID0gMSArICgyMyA8PCAoKENIQVJCWVRFUyAtIDEpICogOCkpICogaSAlIG1heF9jaGFyOworCisgIHMxW25dID0gMjQgKyBleHBfcmVzdWx0OworICBzMltuXSA9IDIzOworICBzMVtsZW5dID0gMDsKKyAgczJbbGVuXSA9IDA7CisgIGlmIChleHBfcmVzdWx0IDwgMCkKKyAgICBzMltsZW5dID0gMzI7CisgIGVsc2UgaWYgKGV4cF9yZXN1bHQgPiAwKQorICAgIHMxW2xlbl0gPSA2NDsKKyAgaWYgKGxlbiA+PSBuKQorICAgIHMyW24gLSAxXSAtPSBleHBfcmVzdWx0OworCisgIEZPUl9FQUNIX0lNUEwgKGltcGwsIDApCisgICAgZG9fb25lX3Rlc3QgKGltcGwsIHMxLCBzMiwgbiwgZXhwX3Jlc3VsdCk7Cit9CisKK3N0YXRpYyB2b2lkCitkb19wYWdlX3Rlc3QgKHNpemVfdCBvZmZzZXQxLCBzaXplX3Qgb2Zmc2V0MiwgQ0hBUiAqczIpCit7CisgIENIQVIgKnMxOworICBpbnQgZXhwX3Jlc3VsdDsKKworICBpZiAob2Zmc2V0MSAqIENIQVJCWVRFUyAgPj0gcGFnZV9zaXplIHx8IG9mZnNldDIgKiBDSEFSQllURVMgPj0gcGFnZV9zaXplKQorICAgIHJldHVyb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AyICsgYWxpZ24yLCBwMSArIGFsaWduMSwgcG9zKTsKKyAgICAgIGlmIChwb3MgPCBsZW4xKQorCXsKKwkgIGlmIChwMlthbGlnbjIgKyBwb3NdID09IHAxW2FsaWduMSArIHBvc10pCisJICAgIHsKKwkgICAgICBwMlthbGlnbjIgKyBwb3NdID0gcmFuZG9tICgpICYgMjU1OworCSAgICAgIGlmIChwMlthbGlnbjIgKyBwb3NdID09IHAxW2FsaWduMSArIHBvc10pCisJCXAyW2FsaWduMiArIHBvc10gPSBwMVthbGlnbjEgKyBwb3NdICsgMyArIChyYW5kb20gKCkgJiAxMjcpOworCSAgICB9CisKKwkgIGlmIChwb3MgPCBzaXplKQorCSAgICB7CisJICAgICAgaWYgKHAxW2FsaWduMSArIHBvc10gPCBwMlthbGlnbjIgKyBwb3NdKQorCQlyZXN1bHQgPSAtMTsKKwkgICAgICBlbHNlCisJCXJlc3VsdCA9IDE7CisJICAgIH0KKwl9CisgICAgICBwMVtsZW4xICsgYWxpZ24xXSA9IDA7CisgICAgICBwMltsZW4yICsgYWxpZ24yXSA9IDA7CisKKyAgICAgIEZPUl9FQUNIX0lNUEwgKGltcGwsIDEpCisJeworCSAgciA9IENBTEwgKGltcGwsIChDSEFSICopIChwMSArIGFsaWduMSksIChDSEFSICopIChwMiArIGFsaWduMiksIHNpemUpOworCSAgLyogVGVzdCB3aGV0aGVyIG9uIDY0LWJpdCBhcmNoaXRlY3R1cmVzIHdoZXJlIEFCSSByZXF1aXJlcworCSAgICAgY2FsbGVlIHRvIHByb21vdGUgaGFzIHRoZSBwcm9tb3Rpb24gYmVlbiBkb25lLiAgKi8KKwkgIGFzbSAoIiIgOiAiPWciIChyKSA6ICIwIiAocikpOworCSAgaWYgKChyID09IDAgJiYgcmVzdWx0KQorCSAgICAgIHx8IChyIDwgMCAmJiByZXN1bHQgPj0gMCkKKwkgICAgICB8fCAociA+IDAgJiYgcmVzdWx0IDw9IDApKQorCSAgICB7CisJICAgICAgZXJyb3IgKDAsI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IHNpemVfdCBuKQoreworICBDSEFSICpyZXQgPSBkc3Q7CisgIHdoaWxlIChuLS0pCisgICAgaWYgKCgqZHN0KysgPSAqc3JjKyspID09ICdcMCcpCisgICAgICB7CisJd2hpbGUgKG4tLSkKKwkgICpkc3QrKyA9ICdcMCc7CisJcmV0dXJuIHJldDsKKyAgICAgIH0KKyAgcmV0dXJuIHJldDsKK30KKworQ0hBUiAqCitTVFVQSURfU1RSTkNQWSAoQ0hBUiAqZHN0LCBjb25zdCBDSEFSICpzcmMsIHNpemVfdCBuKQoreworICBzaXplX3QgbmMgPSBTVFJOTEVOIChzcmMsIG4pOworICBzaXplX3QgaTsKKworICBmb3IgKGkgPSAwOyBpIDwgbmM7ICsraSkKKyAgICBkc3RbaV0gPSBzcmNbaV07CisgIGZvciAoOyBpIDwgbjsgKytpKQorICAgIGRzdFtpXSA9ICdcMCc7CisgIHJldHVybiBkc3Q7Cit9CisjZW5kaWYgLyogIVNUUk5DUFlfUkVTVUxUICovCisKK3R5cGVkZWYgQ0hBUiAqKCpwcm90b190KSAoQ0hBUiAqLCBjb25zdCBDSEFSICosIHNpemVfdCk7CisKK3N0YXRpYyB2b2lkCitkb19vbmVfdGVzdCAoaW1wbF90ICppbXBsLCBDSEFSICpkc3QsIGNvbnN0IENIQVIgKnNyYywgc2l6ZV90IGxlbiwgc2l6ZV90IG4pCit7CisgIGlmIChDQUxMIChpbXBsLCBkc3QsIHNyYywgbikgIT0gU1RSTkNQWV9SRVNVTFQgKGRzdCwgbGVuLCBuKSkKKyAgICB7CisgICAgICBlcnJvciAoMCwgMCwgIldyb25nIHJlc3VsdCBpbiBmdW5jdGlvbiAlcyAlcCAlcCIsIGltcGwtPm5hbWUsCisJICAgICBDQUxMIChpbXBsLCBkc3QsIHNyYywgbiksIGRzdCk7CisgICAgICByZXQgPSAxOworICAgICAgcmV0dXJuOworICAgIH0KKworICBpZiAobWVtY21wIChkc3QsIHNyYywgKGxlbiA+IG4gPyBuIDogbGVuKSAqIHNp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emVfdCBtYXhsZW4sIGludCBtYXhfY2hhcikKK3sKKyAgc2l6ZV90IGk7CisKKyAgYWxpZ24gJj0gNjM7CisgIGlmICgoYWxpZ24gKyBsZW4pICogc2l6ZW9mIChDSEFSKSA+PSBwYWdlX3NpemUpCisgICAgcmV0dXJuOworCisgIENIQVIgKmJ1ZiA9IChDSEFSICopIChidWYxKTsKKworICBmb3IgKGkgPSAwOyBpIDwgbGVuOyArK2kpCisgICAgYnVmW2FsaWduICsgaV0gPSAxICsgMTExMTEgKiBpICUgbWF4X2NoYXI7CisgIGJ1ZlthbGlnbiArIGxlbl0gPSAwOworCisgIEZPUl9FQUNIX0lNUEwgKGltcGwsIDApCisgICAgZG9fb25lX3Rlc3QgKGltcGwsIChDSEFSICopIChidWYgKyBhbGlnbiksIG1heGxlbiwgTUlOIChsZW4sIG1heGxlbikpOworfQorCitzdGF0aWMgdm9pZAorZG9fcmFuZG9tX3Rlc3RzICh2b2lkKQoreworICBzaXplX3QgaSwgaiwgbiwgYWxpZ24sIGxlbjsKKyAgQ0hBUiAqcCA9IChDSEFSICopIChidWYxICsgcGFnZV9zaXplIC0gNTEyICogc2l6ZW9mIChDSEFSKSk7CisKKyAgZm9yIChuID0gMDsgbiA8IElURVJBVElPTlM7IG4rKykKKyAgICB7CisgICAgICBhbGlnbiA9IHJhbmRvbSAoKSAmIDE1OworICAgICAgbGVuID0gcmFuZG9tICgpICYgNTExOworICAgICAgaWYgKGxlbiArIGFsaWduID4gNTEwKQorCWxlbiA9IDUxMSAtIGFsaWduIC0gKHJhbmRvbSAoKSAmIDcpOworICAgICAgaiA9IGxlbiArIGFsaWduICsgNjQ7CisgICAgICBpZiAoaiA+IDUxMikKKwlqID0gNTEyOworCisgICAgICBmb3IgKGkgPSAwOyBpIDwgajsgaSsrKQorCXsKKwkgIGlmIChpID09IGxlbiArIGFsaWduKQorCSAgICBwW2ldID0gMDsKKwkgIGVsc2UKKwkgICAgeworCSAgICAgIHBbaV0gPSByYW5kb20gKCkgJiAyNTU7CisJICAgICAgaWYgKGkgPj0gYWxpZ24gJiYgaSA8IGxlbiArIGFsaWduICYmICFwW2ldKQorCQlwW2ldID0gKHJhbmRvbSAoKSAmIDEyNykgKyAxOworCSAgICB9CisJfQorCisgICAgICBGT1JfRUFDSF9JTVBMIChpbXBsLCAxKQorCXsKKwkgIGlmIChsZW4gPiAwCisJICAgICAgJiYgQ0FMTCAoaW1wbCwgKENIQVIgKikgKHAgKyBhbGlnbiksIGxlbiAtIDEpICE9IGxlbiAtIDEpCisJICAgIHsKKwkgICAgICBlcnJvciAoMCwgMCwgIkl0ZXJhdGlvbiAlemQgKGxpbWl0ZWQpIC0gd3JvbmcgcmVzdWx0IGluIGZ1bmN0aW9uICVzICglemQpICV6ZCAhPSAlemQsIHAgJXAiLAorCQkgICAgIG4sIGltcGwtPm5hbWUsIGFsaWduLAorCQkgICAgIENBTEwgKGltcGwsIChDSEFSICopIChwICsgYWxpZ24pLCBsZW4gLSAxKSwgbGVuIC0gMSwgcCk7CisJICAgICAgcmV0ID0gMTsKKwkgICAgfQorCSAgaWYgKENBTEwgKGltcGwsIChDSEFSICopIChwICsgYWxpZ24pLCBsZW4pICE9IGxlbikKKwkgICAgeworCSAgICAgIGVycm9yICgwLCAwLCAiSXRlcmF0aW9uICV6ZCAoZXhhY3QpIC0gd3JvbmcgcmVzdWx0IGluIGZ1bmN0aW9uICVzICglemQpICV6ZCAhPSAlemQsIHAgJXAiLAorCQkgICAgIG4sIGltcGwtPm5hbWUsIGFsaWduLAorCQkgICAgIENBTEwgKGltcGwsIChDSEFSICopIChwICsgYWxpZ24pLCBsZW4pLCBsZW4sIHApOworCSAgICAgIHJldCA9IDE7CisJICAgIH0KKwkgIGlmIChDQUxMIChpbXBsLCAoQ0hBUiAqKSAocCArIGFsaWduKSwgbGVuICsgMSkgIT0gbGVuKQorCSAgICB7CisJICAgICAgZXJyb3IgKDAsIDAsICJJdGVyYXRpb24gJXpkIChsb25nKSAtIHdyb25nIHJlc3Vs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U0lNUExFX1NUUlBCUksgKGNvbnN0IENIQVIgKiwgY29uc3QgQ0hBUiAqKTsKK0NIQVIgKlNUVVBJRF9TVFJQQlJLIChjb25zdCBDSEFSICosIGNvbnN0IENIQVIgKik7CisKK0lNUEwgKFNUVVBJRF9TVFJQQlJLLCAwKQorSU1QTCAoU0lNUExFX1NUUlBCUkssIDApCitJTVBMIChTVFJQQlJLLCAxKQorCitDSEFSICoKK1NJTVBMRV9TVFJQQlJLIChjb25zdCBDSEFSICpzLCBjb25zdCBDSEFSICpyZWopCit7CisgIGNvbnN0IENIQVIgKnI7CisgIENIQVIgYzsKKworICB3aGlsZSAoKGMgPSAqcysrKSAhPSAnXDAnKQorICAgIGZvciAociA9IHJlajsgKnIgIT0gJ1wwJzsgKytyKQorICAgICAgaWYgKCpyID09IGMpCisJcmV0dXJuIChDSEFSICopIHMgLSAxOworICByZXR1cm4gTlVMTDsKK30KKworQ0hBUiAqCitTVFVQSURfU1RSUEJSSyAoY29uc3QgQ0hBUiAqcywgY29uc3QgQ0hBUiAqcmVqKQoreworICBzaXplX3QgbnMgPSBTVFJMRU4gKHMpLCBucmVqID0gU1RSTEVOIChyZWopOworICBzaXplX3QgaSwgajsKKworICBmb3IgKGkgPSAwOyBpIDwgbnM7ICsraSkKKyAgICBmb3IgKGogPSAwOyBqIDwgbnJlajsgKytqKQorICAgICAgaWYgKHNbaV0gPT0gcmVqW2pdKQorCXJldHVybiAoQ0hBUiAqKSBzICsgaTsKKyAgcmV0dXJuIE5VTEw7Cit9CisjZW5kaWYgLyogIVNUUlBCUktfUkVTVUxUICovCisKK3N0YXRpYyB2b2lkCitkb19vbmVfdGVzdCAoaW1wbF90ICppbXBsLCBjb25zdCBDSEFSICpzLCBjb25zdCBDSEFSICpyZWosIFJFU19UWVBFIGV4cF9yZXMpCit7CisgIFJFU19UWVBFIHJlcyA9IENBTEwgKGltcGwsIHMsIHJlaik7CisgIGlmIChyZXMgIT0gZXhwX3JlcykKKyAgICB7CisgICAgICBlcnJvciAoMCwgMCwgIldyb25nIHJlc3VsdCBpbiBmdW5jdGlvbiAlcyAlcCAlcCIsIGltcGwtPm5hbWUsCisJICAgICAodm9pZCAqKSByZXMsICh2b2lkICopIGV4cF9yZXMpOworICAgICAgcmV0ID0gMTsKKyAgICAgIHJldHVybjsKKyAgICB9Cit9CisKK3N0YXRpYyB2b2lkCitkb190ZXN0IChzaXplX3QgYWxpZ24sIHNpemVfdCBwb3MsIHNpemVfdCBsZW4pCit7CisgIHNpemVfdCBpOworICBpbnQgYzsKKyAgUkVTX1RZUEUgcmVzdWx0OworICBDSEFSICpyZWosICpzOworCisgIGFsaWduICY9IDc7CisgIGlmICgoYWxpZ24gKyBwb3MgKyAxMCkgKiBzaXplb2YgKENIQVIpID49IHBhZ2Vfc2l6ZSB8fCBsZW4gPiAyNDApCisgICAgcmV0dXJuOworCisgIHJlaiA9IChDSEFSICopIChidWYyKSArIChyYW5kb20gKCkgJiAyNTUpOworICBzID0gKENIQVIgKikgKGJ1ZjEpICsgYWxpZ247CisKKyAgZm9yIChpID0gMDsgaSA8IGxlbjsgKytpKQorICAgIHsKKyAgICAgIHJlaltpXSA9IHJhbmRvbSAoKSAmIEJJR19DSEFSOworICAgICAgaWYgKCFyZWpbaV0pCisJcmVqW2ldID0gcmFuZG9tICgpICYgQklHX0NIQVI7CisgICAgICBpZiAoIXJlaltpXSkKKwlyZWpbaV0gPSAxICsgKHJhbmRvbSAoKSAmIFNNQUxMX0NIQVIpOworICAgIH0KKyAgcmVqW2xlbl0gPSAnXDAnOworICBmb3IgKGMgPSAxOyBjIDw9IEJJR19DSEFSOyArK2MpCisgICAgaWYgKFNUUkNIUiAocmVqLCBjKSA9PSBOVUxMKQorICAgICAgYnJlYWs7CisKKyAgZm9yIChpID0gMDsgaSA8IHBvczsgKytpKQorICAgIHsKKyAgICAgIHNbaV0gPSByYW5kb20gKCkgJiBCSUdfQ0hBUjsKKyAgICAgIGlmIChTVFJDSFIgKHJlaiwgc1tpXSkpCisJeworCSAgc1tpXSA9IHJhbmRvbSAoKSAmIEJJR19DSEFSOworCSAgaWYgKFNUUkNIUiAocmVqLCBzW2ldKSkKKwkgICAgc1tpXSA9IGM7CisJfQorICAgIH0KKyAgc1twb3NdID0gcmVqW3JhbmRvbSAoKSAlIChsZW4gKyAxKV07CisgIGlmIChzW3Bvc10pCisgICAgeworICAgICAgZm9yIChpID0gcG9zICsgMTsgaSA8IHBvcyArIDEwOyArK2kpCisJc1tpXSA9IHJhbmRvbSAoKSAmIEJJR19DSEFSOworICAgICAgc1tpXSA9ICdcMCc7CisgICAgfQorICByZXN1bHQgPSBTVFJQQlJLX1JFU1VMVCAocywgcG9zKTsKKworICBGT1JfRUFDSF9JTVBMIChpbXBsLCAwKQorICAgIGRvX29uZV90ZXN0IChpbXBsLCBzLCByZWosIHJlc3VsdCk7Cit9CisKK3N0YXRpYyB2b2lkCitkb19yYW5kb21fdGVzdHMgKHZvaWQpCit7CisgIHNpemVfdCBpLCBqLCBuLCBhbGlnbiwgcG9zLCBsZW4sIHJsZW47CisgIFJFU19UWVBFIHJlc3VsdDsKKyAgaW50IGM7CisgIFVDSEFSICpwID0gKFVDSEFSICopIChidWYxICsgcGFnZV9zaXplKSAtIDUxMjsKKyAgVUNIQVIgKnJlajsKKworICBmb3IgKG4gPSAwOyBuIDwgSVRFUkFUSU9OUzsgbisrKQorICAgIHsKKyAgICAgIGFsaWduID0gcmFuZG9tICgpICYgMTU7CisgICAgICBwb3MgPSByYW5kb20gKCkgJiA1MTE7CisgICAgICBpZiAocG9zICsgYWxpZ24gPj0gNTExKQorCXBvcyA9IDUxMCAtIGFsaWduIC0gKHJhbmRvbSAoKSAmIDcpOworICAgICAgbGVuID0gcmFuZG9tICgpICYgNTExOworICAgICAgaWYgKHBvcyA+PSBsZW4gJiYgKHJhbmRvbSAoKSAmIDEpKQorCWxlbiA9IHBvcyArIDEgKyAocmFuZG9tICgpICYgNyk7CisgICAgICBpZiAobGVuICsgYWxpZ24gPj0gNTEy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X29uZV90ZXN0IChpbXBsX3QgKmltcGwsIGNvbnN0IENIQVIgKnMsIGludCBjLCBDSEFSICpleHBfcmVzKQoreworICBDSEFSICpyZXMgPSBDQUxMIChpbXBsLCBzLCBjKTsKKyAgaWYgKHJlcyAhPSBleHBfcmVzKQorICAgIHsKKyAgICAgIGVycm9yICgwLCAwLCAiV3JvbmcgcmVzdWx0IGluIGZ1bmN0aW9uICVzICVwICVwIiwgaW1wbC0+bmFtZSwKKwkgICAgIHJlcywgZXhwX3Jlcyk7CisgICAgICByZXQgPSAxOworICAgICAgcmV0dXJuOworICAgIH0KK30KKworc3RhdGljIHZvaWQKK2RvX3Rlc3QgKHNpemVfdCBhbGlnbiwgc2l6ZV90IHBvcywgc2l6ZV90IGxlbiwgaW50IHNlZWtfY2hhciwgaW50IG1heF9jaGFyKQorLyogRm9yIHdjc3JjaHI6IGFsaWduIGhlcmUgbWVhbnMgYWxpZ24gbm90IGluIGJ5dGVzLAorICAgYnV0IGluIHdjaGFyX3RzLCBpbiBieXRlcyBpdCB3aWxsIGVxdWFsIHRvIGFsaWduICogKHNpemVvZiAod2NoYXJfdCkpCisgICBsZW4gZm9yIHdjc2NociBoZXJlIGlzbid0IGluIGJ5dGVzIGJ1dCBpdCdzIG51bWJlciBvZiB3Y2hhcl90IHN5bWJvbHMuICAqLworeworICBzaXplX3QgaTsKKyAgQ0hBUiAqcmVzdWx0OworICBDSEFSICpidWYgPSAoQ0hBUiAqKSBidWYxOworCisgIGFsaWduICY9IDc7CisgIGlmICggKGFsaWduICsgbGVuKSAqIHNpemVvZihDSEFSKSA+PSBwYWdlX3NpemUpCisgICAgcmV0dXJuOworCisgIGZvciAoaSA9IDA7IGkgPCBsZW47ICsraSkKKyAgICB7CisgICAgICBidWZbYWxpZ24gKyBpXSA9IChyYW5kb20gKCkgKiByYW5kb20gKCkpICYgbWF4X2NoYXI7CisgICAgICBpZiAoIWJ1ZlthbGlnbiArIGldKQorCWJ1ZlthbGlnbiArIGldID0gKHJh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IHApOworCSAgICByZXQgPSAxOworCSAgfQorICAgIH0KK30KKworaW50Cit0ZXN0X21haW4gKHZvaWQpCit7CisgIHNpemVfdCBpOworCisgIHRlc3RfaW5pdCAoKTsKKworICBwcmludGYgKCIlMjBzIiwgIiIpOworICBGT1JfRUFDSF9JTVBMIChpbXBsLCAwKQorICAgIHByaW50ZiAoIlx0JXMiLCBpbXBsLT5uYW1lKTsKKyAgcHV0Y2hhciAoJ1xuJyk7CisKKyAgZm9yIChpID0gMTsgaSA8IDg7ICsraSkKKyAgICB7CisgICAgICBkb190ZXN0ICgwLCAxNiA8PCBpLCAyMDQ4LCAyMywgU01BTExfQ0hBUik7CisgICAgICBkb190ZXN0IChpLCAxNiA8PCBpLCAyMDQ4LCAyMywgU01BTExfQ0hBUik7CisgICAgfQorCisgIGZvciAoaSA9IDE7IGkgPCA4OyArK2kpCisgICAgeworICAgICAgZG9fdGVzdCAoaSwgNjQsIDI1NiwgMjMsIFNNQUxMX0NIQVIpOworICAgICAgZG9fdGVzdCAoaSwgNjQsIDI1NiwgMjMsIEJJR19DSEFSKTsKKyAgICB9CisKKyAgZm9yIChpID0gMDsgaSA8IDMyOyArK2kpCisgICAgeworICAgICAgZG9fdGVzdCAoMCwgaSwgaSArIDEsIDIzLCBTTUFMTF9DSEFSKTsKKyAgICAgIGRvX3Rlc3QgKDAsIGksIGkgKyAxLCAyMywgQklHX0NIQVIpOworICAgIH0KKworICBmb3IgKGkgPSAxOyBpIDwgODsgKytpKQorICAgIHsKKyAgICAgIGRvX3Rlc3QgKDAsIDE2IDw8IGksIDIwNDgsIDAsIFNNQUxMX0NIQVIpOworICAgICAgZG9fdGVzdCAoaSwgMTYgPDwgaSwgMjA0OCwgMCwgU01BTExfQ0hBUik7CisgICAgfQorCisgIGZvciAoaSA9IDE7IGkgPCA4OyArK2kpCisgICAgeworICAgICAgZG9fdGVzdCAoaSwgNjQsIDI1NiwgMCwgU01BTExfQ0hBUik7CisgICAgICBkb190ZXN0IChpLCA2N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MgPSAqcysrKSAhPSAnXDAnKQorICAgIHsKKyAgICAgIGZvciAociA9IGFjYzsgKnIgIT0gJ1wwJzsgKytyKQorCWlmICgqciA9PSBjKQorCSAgYnJlYWs7CisgICAgICBpZiAoKnIgPT0gJ1wwJykKKwlyZXR1cm4gcyAtIHN0ciAtIDE7CisgICAgfQorICByZXR1cm4gcyAtIHN0ciAtIDE7Cit9CisKK3NpemVfdAorU1RVUElEX1NUUlNQTiAoY29uc3QgQ0hBUiAqcywgY29uc3QgQ0hBUiAqYWNjKQoreworICBzaXplX3QgbnMgPSBTVFJMRU4gKHMpLCBuYWNjID0gU1RSTEVOIChhY2MpOworICBzaXplX3QgaSwgajsKKworICBmb3IgKGkgPSAwOyBpIDwgbnM7ICsraSkKKyAgICB7CisgICAgICBmb3IgKGogPSAwOyBqIDwgbmFjYzsgKytqKQorCWlmIChzW2ldID09IGFjY1tqXSkKKwkgIGJyZWFrOworICAgICAgaWYgKGogPT0gbmFjYykKKwlyZXR1cm4gaTsKKyAgICB9CisgIHJldHVybiBpOworfQorCitzdGF0aWMgdm9pZAorZG9fb25lX3Rlc3QgKGltcGxfdCAqaW1wbCwgY29uc3QgQ0hBUiAqcywgY29uc3QgQ0hBUiAqYWNjLCBzaXplX3QgZXhwX3JlcykKK3sKKyAgc2l6ZV90IHJlcyA9IENBTEwgKGltcGwsIHMsIGFjYyk7CisgIGlmIChyZXMgIT0gZXhwX3JlcykKKyAgICB7CisgICAgICBlcnJvciAoMCwgMCwgIldyb25nIHJlc3VsdCBpbiBmdW5jdGlvbiAlcyAlcCAlcCIsIGltcGwtPm5hbWUsCisJICAgICAodm9pZCAqKSByZXMsICh2b2lkICopIGV4cF9yZXMpOworICAgICAgcmV0ID0gMTsKKyAgICAgIHJldHVybjsKKyAgICB9Cit9CisKK3N0YXRpYyB2b2lkCitkb190ZXN0IChzaXplX3QgYWxpZ24sIHNpemVfdCBwb3MsIHNpemVfdCBsZW4pCit7CisgIHNpemVfdCBpOworICBDSEFSIC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pwID0gKFVDSEFSICopIChidWYxICsgcGFnZV9zaXplKSAtIDUxMjsKKyAgVUNIQVIgKmFjYzsKKworICBmb3IgKG4gPSAwOyBuIDwgSVRFUkFUSU9OUzsgbisrKQorICAgIHsKKyAgICAgIGFsaWduID0gcmFuZG9tICgpICYgMTU7CisgICAgICBpZiAocmFuZG9tICgpICYgMSkKKwlhbGVuID0gcmFuZG9tICgpICYgNjM7CisgICAgICBlbHNlCisJYWxlbiA9IHJhbmRvbSAoKSAmIDE1OworICAgICAgaWYgKCFhbGVuKQorCXBvcyA9IDA7CisgICAgICBlbHNlCisJcG9zID0gcmFuZG9tICgpICYgNTExOworICAgICAgaWYgKHBvcyArIGFsaWduID49IDUxMSkKKwlwb3MgPSA1MTAgLSBhbGlnbiAtIChyYW5kb20gKCkgJiA3KTsKKyAgICAgIGxlbiA9IHJhbmRvbSAoKSAmIDUxMTsKKyAgICAgIGlmIChsZW4gKyBhbGlnbiA+PSA1MTIpCisJbGVuID0gNTExIC0gYWxpZ24gLSAocmFuZG9tICgpICYgNyk7CisgICAgICBhY2MgPSAoVUNIQVIgKikgKGJ1ZjIgKyBwYWdlX3NpemUpIC0gYWxlbiAtIDEgLSAocmFuZG9tICgpICYgNyk7CisgICAgICBmb3IgKGkgPSAwOyBpIDwgYWxlbjsgKytpKQorCXsKKwkgIGFjY1tpXSA9IHJhbmRvbSAoKSAmIEJJR19DSEFSOworCSAgaWYgKCFhY2NbaV0pCisJICAgIGFjY1tpXSA9IHJhbmRvbSAoKSAmIEJJR19DSEFSOworCSAgaWYgKCFhY2NbaV0pCisJICAgIGFjY1tpXSA9IDEgKyAocmFuZG9tICgpICYgU01BTExfQ0hBUik7CisJfQorICAgICAgYWNjW2ldID0gJ1wwJzsKKyAgICAgIGogPSAocG9zID4gbGVuID8gcG9zIDogbGVuKSArIGFsaWduICsgNjQ7CisgICAgICBpZiAoaiA+IDUxMikKKwlqID0gNTEyOworCisgICAgICBmb3IgKGkgPSAwOyBpIDwgajsgaS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mN0aW9uICVzICVzICVzIiwgaW1wbC0+bmFtZSwKKwkgICAgIHJlc3VsdCwgZXhwX3Jlc3VsdCk7CisgICAgICByZXQgPSAxOworICAgICAgcmV0dXJuIC0xOworICAgIH0KKworICByZXR1cm4gMDsKK30KKworc3RhdGljIHZvaWQKK2RvX29uZV90ZXN0IChpbXBsX3QgKmltcGwsIGNvbnN0IGNoYXIgKnMxLCBjb25zdCBjaGFyICpzMiwgY2hhciAqZXhwX3Jlc3VsdCkKK3sKKyAgaWYgKGNoZWNrX3Jlc3VsdCAoaW1wbCwgczEsIHMyLCBleHBfcmVzdWx0KSA8IDApCisgICAgcmV0dXJuOworfQorCisKK3N0YXRpYyB2b2lkCitkb190ZXN0IChzaXplX3QgYWxpZ24xLCBzaXplX3QgYWxpZ24yLCBzaXplX3QgbGVuMSwgc2l6ZV90IGxlbjIsCisJIGludCBmYWlsKQoreworICBjaGFyICpzMSA9IChjaGFyICopIChidWYxICsgYWxpZ24xKTsKKyAgY2hhciAqczIgPSAoY2hhciAqKSAoYnVmMiArIGFsaWduMik7CisKKyAgc3RhdGljIGNvbnN0IGNoYXIgZFtdID0gIjEyMzQ1Njc4OTBhYmNkZWYiOworI2RlZmluZSBkbCAoc2l6ZW9mIChkKSAtIDEpCisgIGNoYXIgKnNzMiA9IHMyOworICBmb3IgKHNpemVfdCBsID0gbGVuMjsgbCA+IDA7IGwgPSBsID4gZGwgPyBsIC0gZGwgOiAwKQorICAgIHsKKyAgICAgIHNpemVfdCB0ID0gbCA+IGRsID8gZGwgOiBsOworICAgICAgc3MyID0gbWVtcGNweSAoc3MyLCBkLCB0KTsKKyAgICB9CisgIHMyW2xlbjJdID0gJ1wwJzsKKworICBpZiAoZmFpbCkKKyAgICB7CisgICAgICBjaGFyICpzczEgPSBzMTsKKyAgICAgIGZvciAoc2l6ZV90IGwgPSBsZW4xOyBsID4gMDsgbCA9IGwgPiBkbCA/IGwgLSBkbCA6IDApCisJeworCSAgc2l6ZV90IHQgPSBsID4g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gIGJ1ZjJbaitrKzFdID0gMDsKKwkgICAgICBjaGVjayAoc3RyY21wIChidWYxK2ksYnVmMitqKSA8IDAsIGNudW0rMyk7CisJICAgICAgY2hlY2sgKHN0cmNtcCAoYnVmMitqLGJ1ZjEraSkgPiAwLCBjbnVtKzQpOworCSAgICAgIGJ1ZjJbaitrXSA9ICdBJyArIGkgKyBrOworCSAgICAgIGJ1ZjFbaV0gPSAnQScgKyBpICsgMHg4MDsKKwkgICAgICBjaGVjayAoc3RyY21wIChidWYxK2ksYnVmMitqKSA+IDAsIGNudW0rNSk7CisJICAgICAgY2hlY2sgKHN0cmNtcCAoYnVmMitqLGJ1ZjEraSkgPCAwLCBjbnVtKzYpOworCSAgICAgIGJ1ZjFbaV0gPSAnQScgKyBpOworCSAgICB9CisJfQorICB9Cit9CisKKyNkZWZpbmUgU0lNUExFX0NPUFkoZm4sIG4sIHN0ciwgbnRlc3QpIFwKKyAgZG8gewkJCQkJCQkJCSAgICAgIFwKKyAgICBpbnQgX19uOwkJCQkJCQkJICAgICAgXAorICAgIGNoYXIgKmNwOwkJCQkJCQkJICAgICAgXAorICAgIGZvciAoX19uID0gMDsgX19uIDwgKGludCkgc2l6ZW9mIChvbmUpOyArK19fbikJCQkgICAgICBcCisgICAgICBvbmVbX19uXSA9ICdaJzsJCQkJCQkJICAgICAgXAorICAgIGZuIChvbmUsIHN0cik7CQkJCQkJCSAgICAgIFwKKyAgICBmb3IgKGNwID0gb25lLCBfX24gPSAwOyBfX24gPCBuOyArK19fbiwgKytjcCkJCQkgICAgICBcCisgICAgICBjaGVjayAoKmNwID09ICcwJyArIChuICUgMTApLCBudGVzdCk7CQkJCSAgICAgIFwKKyAgICBjaGVjayAoKmNwID09ICdcMCcsIG50ZXN0KTsJCQkJCQkgICAgICBcCisgIH0gd2hpbGUgKDApCisKK3N0YXRpYyB2b2lkCit0ZXN0X3N0cmNweSAodm9pZCkKK3sKKyAgaW50IGk7CisgIGl0ID0gInN0cmNweSI7CisgIGNoZ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AqLworCisgICh2b2lkKSBzdHJjcHkgKG9uZSwgImFiY2RlZmdoIik7CisgICh2b2lkKSBzdHJuY3B5IChvbmUsICJ4eXoiLCAyKTsKKyAgZXF1YWwgKG9uZSwgInh5Y2RlZmdoIiwgMyk7CQkJLyogQ29weSBjdXQgYnkgY291bnQuICovCisKKyAgKHZvaWQpIHN0cmNweSAob25lLCAiYWJjZGVmZ2giKTsKKyAgKHZvaWQpIHN0cm5jcHkgKG9uZSwgInh5eiIsIDMpOwkJLyogQ29weSBjdXQganVzdCBiZWZvcmUgTlVMLiAqLworICBlcXVhbCAob25lLCAieHl6ZGVmZ2giLCA0KTsKKworICAodm9pZCkgc3RyY3B5IChvbmUsICJhYmNkZWZnaCIpOworICAodm9pZCkgc3RybmNweSAob25lLCAieHl6IiwgNCk7CQkvKiBDb3B5IGp1c3QgaW5jbHVkZXMgTlVMLiAqLworICBlcXVhbCAob25lLCAieHl6IiwgNSk7CisgIGVxdWFsIChvbmUrNCwgImVmZ2giLCA2KTsJCQkvKiBXcm90ZSB0b28gbXVjaD8gKi8KKworICAodm9pZCkgc3RyY3B5IChvbmUsICJhYmNkZWZnaCIpOworICAodm9pZCkgc3RybmNweSAob25lLCAieHl6IiwgNSk7CQkvKiBDb3B5IGluY2x1ZGVzIHBhZGRpbmcuICovCisgIGVxdWFsIChvbmUsICJ4eXoiLCA3KTsKKyAgZXF1YWwgKG9uZSs0LCAiIiwgOCk7CisgIGVxdWFsIChvbmUrNSwgImZnaCIsIDkpOworCisgICh2b2lkKSBzdHJjcHkgKG9uZSwgImFiYyIpOworICAodm9pZCkgc3RybmNweSAob25lLCAieHl6IiwgMCk7CQkvKiBaZXJvLWxlbmd0aCBjb3B5LiAqLworICBlcXVhbCAob25lLCAiYWJjIiwgMTApOworCisgICh2b2lkKSBzdHJuY3B5IChvbmUsICIiLCAyKTsJCS8qIFplcm8tbGVuZ3RoIHNvdXJjZS4gKi8KKyAgZXF1YWwgKG9uZSwgIiIsIDExKTsKKyAgZXF1YWwgKG9uZSsxLCAiIiwgMTIpOworICBlcXVhbCAob25lKzIsICJjIiwgMTMpOworCisgICh2b2lkKSBzdHJjcHkgKG9uZSwgImhpIHRoZXJlIik7CisgICh2b2lkKSBzdHJuY3B5ICh0d28sIG9uZSwgOSk7CisgIGVxdWFsICh0d28sICJoaSB0aGVyZSIsIDE0KTsJCS8qIEp1c3QgcGFyYW5vaWEuICovCisgIGVxdWFsIChvbmUsICJoaSB0aGVyZSIsIDE1KTsJCS8qIFN0b21wZWQgb24gc291cmNlPyAqLworfQorCitzdGF0aWMgdm9pZAordGVzdF9zdHJsZW4gKHZvaWQpCit7CisgIGl0ID0gInN0cmxlbiI7CisgIGNoZWNrIChzdHJsZW4gKCIiKSA9PSAwLCAxKTsJCS8qIEVtcHR5LiAqLworICBjaGVjayAoc3RybGVuICgiYSIpID09IDEsIDIpOwkJLyogU2luZ2xlIGNoYXIuICovCisgIGNoZWNrIChzdHJsZW4gKCJhYmNkIikgPT0gNCwgMyk7CS8qIE11bHRpcGxlIGNoYXJzLiAqLworICB7CisgICAgY2hhciBidWZbNDA5Nl07CisgICAgaW50IGk7CisgICAgY2hhciAqcDsKKyAgICBmb3IgKGk9MDsgaSA8IDB4MTAwOyBpKyspCisgICAgICB7CisJcCA9IChjaGFyICopICgodW5zaWduZWQgbG9uZyBpbnQpKGJ1ZiArIDB4ZmYpICYgfjB4ZmYpICsgaTsKKwlzdHJjcHkgKHAsICJPSyIpOworCXN0cmNweSAocCszLCAiQkFEL1dST05HIik7CisJY2hlY2sgKHN0cmxlbiAocCkgPT0gMiwgNCtpKTsKKyAgICAgIH0KKyAgIH0KK30KKworc3RhdGljIHZvaWQKK3Rlc3Rfc3RybmxlbiAodm9pZCkKK3sKKyAgaXQgPSAic3RybmxlbiI7CisgIGNoZWNrIChzdHJubGVuICgiIiwgMTApID09IDAsIDEpOwkJLyogRW1wdHkuICovCisgIGNoZWNrIChzdHJubGVuICgiYSIsIDEwKSA9PSAxLCAyKTsJCS8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9uZSwgImFiY2QiKTsKKyAgY2hlY2sgKHN0cmNociAob25lLCAnYycpID09IG9uZSsyLCAyKTsJLyogQmFzaWMgdGVzdC4gKi8KKyAgY2hlY2sgKHN0cmNociAob25lLCAnZCcpID09IG9uZSszLCAzKTsJLyogRW5kIG9mIHN0cmluZy4gKi8KKyAgY2hlY2sgKHN0cmNociAob25lLCAnYScpID09IG9uZSwgNCk7CQkvKiBCZWdpbm5pbmcuICovCisgIGNoZWNrIChzdHJjaHIgKG9uZSwgJ1wwJykgPT0gb25lKzQsIDUpOwkvKiBGaW5kaW5nIE5VTC4gKi8KKyAgKHZvaWQpIHN0cmNweSAob25lLCAiYWJhYmEiKTsKKyAgY2hlY2sgKHN0cmNociAob25lLCAnYicpID09IG9uZSsxLCA2KTsJLyogRmluZGluZyBmaXJzdC4gKi8KKyAgKHZvaWQpIHN0cmNweSAob25lLCAiIik7CisgIGNoZWNrIChzdHJjaHIgKG9uZSwgJ2InKSA9PSBOVUxMLCA3KTsJCS8qIEVtcHR5IHN0cmluZy4gKi8KKyAgY2hlY2sgKHN0cmNociAob25lLCAnXDAnKSA9PSBvbmUsIDgpOwkJLyogTlVMIGluIGVtcHR5IHN0cmluZy4gKi8KKyAgeworICAgIGNoYXIgYnVmWzQwOTZdOworICAgIGludCBpOworICAgIGNoYXIgKnA7CisgICAgZm9yIChpPTA7IGkgPCAweDEwMDsgaSsrKQorICAgICAgeworCXAgPSAoY2hhciAqKSAoKHVuc2lnbmVkIGxvbmcgaW50KSAoYnVmICsgMHhmZikgJiB+MHhmZikgKyBpOworCXN0cmNweSAocCwgIk9LIik7CisJc3RyY3B5IChwKzMsICJCQUQvV1JPTkciKTsKKwljaGVjayAoc3RyY2hyIChwLCAnLycpID09IE5VTEwsIDkraSk7CisgICAgICB9CisgICB9Cit9CisKK3N0YXRpYyB2b2lkCit0ZXN0X3N0cmNocm51bCAodm9pZCkKK3sKKyAgY29uc3QgY2hhciAqb3M7CisgIGl0ID0gInN0cmNocm51bCI7CisgIGNwID0gc3RyY2hybnVsICgob3MgPSAiYWJjZCIpLCAneicpOworICBjaGVjayAoKmNwID09ICdcMCcsIDEpOwkJCS8qIE5vdCBmb3VuZC4gKi8KKyAgY2hlY2sgKGNwID09IG9zICsgNCwgMik7CisgICh2b2lkKSBzdHJjcHkgKG9uZSwgImFiY2QiKTsKKyAgY2hlY2sgKHN0cmNocm51bCAob25lLCAnYycpID09IG9uZSsyLCAzKTsJLyogQmFzaWMgdGVzdC4gKi8KKyAgY2hlY2sgKHN0cmNocm51bCAob25lLCAnZCcpID09IG9uZSszLCA0KTsJLyogRW5kIG9mIHN0cmluZy4gKi8KKyAgY2hlY2sgKHN0cmNocm51bCAob25lLCAnYScpID09IG9uZSwgNSk7CS8qIEJlZ2lubmluZy4gKi8KKyAgY2hlY2sgKHN0cmNocm51bCAob25lLCAnXDAnKSA9PSBvbmUrNCwgNik7CS8qIEZpbmRpbmcgTlVMLiAqLworICAodm9pZCkgc3RyY3B5IChvbmUsICJhYmFiYSIpOworICBjaGVjayAoc3RyY2hybnVsIChvbmUsICdiJykgPT0gb25lKzEsIDcpOwkvKiBGaW5kaW5nIGZpcnN0LiAqLworICAodm9pZCkgc3RyY3B5IChvbmUsICIiKTsKKyAgY2hlY2sgKHN0cmNocm51bCAob25lLCAnYicpID09IG9uZSwgOCk7CS8qIEVtcHR5IHN0cmluZy4gKi8KKyAgY2hlY2sgKHN0cmNocm51bCAob25lLCAnXDAnKSA9PSBvbmUsIDkpOwkvKiBOVUwgaW4gZW1wdHkgc3RyaW5nLiAqLworICB7CisgICAgY2hhciBidWZbNDA5Nl07CisgICAgaW50IGk7CisgICAgY2hhciAqcDsKKyAgICBmb3IgKGk9MDsgaSA8IDB4MTAwOyBpKyspCisgICAgICB7CisJcCA9IChjaGFyICopICgodW5zaWduZWQgbG9uZyBpbnQpIChidWYgKyAweGZmKSAmIH4weGZmKSArIGk7CisJc3RyY3B5IChwLCAiT0siKTsKKwlzdHJjcHkgKHArMywgIkJBRC9XUk9ORyIpOworCWNwID0gc3RyY2hybnVsIChwLCAnLycpOworCWNoZWNrICgqY3AgPT0gJ1wwJywgOSsyKmkpOworCWNoZWNrIChjcCA9PSBwKzIsIDEwKzIqaSk7CisgICAgICB9CisgICB9Cit9CisKK3N0YXRpYyB2b2lkCit0ZXN0X3Jhd21lbWNociAodm9pZCkKK3sKKyAgaXQgPSAicmF3bWVtY2hyIjsKKyAgKHZvaWQpIHN0cmNweSAob25lLCAiYWJjZCIpOworICBjaGVjayAocmF3bWVtY2hyIChvbmUsICdjJykgPT0gb25lKzIsIDEpOwkvKiBCYXNpYyB0ZXN0LiAqLworICBjaGVjayAocmF3bWVtY2hyIChvbmUsICdkJykgPT0gb25lKzMsIDIpOwkvKiBFbmQgb2Ygc3RyaW5nLiAqLworICBjaGVjayAocmF3bWVtY2hyIChvbmUsICdhJykgPT0gb25lLCAzKTsJCS8qIEJlZ2lubmluZy4gKi8KKyAgY2hlY2sgKHJhd21lbWNociAob25lLCAnXDAnKSA9PSBvbmUrNCwgNCk7CS8qIEZpbmRpbmcgTlVMLiAqLworICAodm9pZCkgc3RyY3B5IChvbmUsICJhYmFiYSIpOworICBjaGVjayAocmF3bWVtY2hyIChvbmUsICdiJykgPT0gb25lKzEsIDUpOwkvKiBGaW5kaW5nIGZpcnN0LiAqLworICAodm9pZCkgc3RyY3B5IChvbmUsICIiKTsKKyAgY2hlY2sgKHJhd21lbWNociAob25lLCAnXDAnKSA9PSBvbmUsIDYpOwkvKiBOVUwgaW4gZW1wdHkgc3RyaW5nLiAqLworICB7CisgICAgY2hhciBidWZbNDA5Nl07CisgICAgaW50IGk7CisgICAgY2hhciAqcDsKKyAgICBmb3IgKGk9MDsgaSA8IDB4MTAwOyBpKyspCisgICAgICB7CisJcCA9IChjaGFyICopICgodW5zaWduZWQgbG9uZyBpbnQpIChidWYgKyAweGZmKSAmIH4weGZmKSArIGk7CisJc3RyY3B5IChwLCAiT0siKTsKKwlzdHJjcHkgKHArMywgIkJBRC9XUk9ORyIpOworCWNoZWNrIChyYXdtZW1jaHIgKHAsICdSJykgPT0gcCs4LCA2K2kpOworICAgICAgfQorICAgfQorfQorCitzdGF0aWMgdm9pZAordGVzdF9pbmRleCAodm9pZCkKK3sKKyAgaXQgPSAiaW5kZXgiOworICBjaGVjayAoaW5kZXggKCJhYmNkIiwgJ3onKSA9PSBOVUxMLCAxKTsJLyogTm90IGZvdW5kLiAqLworICAodm9pZCkgc3RyY3B5IChvbmUsICJhYmNkIik7CisgIGNoZWNrIChpbmRleCAob25lLCAnYycpID09IG9uZSsyLCAyKTsJLyogQmFzaWMgdGVzdC4gKi8KKyAgY2hlY2sgKGluZGV4IChvbmUsICdkJykgPT0gb25lKzMsIDMpOwkvKiBFbmQgb2Ygc3RyaW5nLiAqLworICBjaGVjayAoaW5kZXggKG9uZSwgJ2EnKSA9PSBvbmUsIDQpOwkvKiBCZWdpbm5pbmcuICovCisgIGNoZWNrIChpbmRleCAob25lLCAnXDAnKSA9PSBvbmUrNCwgNSk7CS8qIEZpbmRpbmcgTlVMLiAqLworICAodm9pZCkgc3RyY3B5IChvbmUsICJhYmFiYSIpOworICBjaGVjayAoaW5kZXggKG9uZSwgJ2InKSA9PSBvbmUrMSwgNik7CS8qIEZpbmRpbmcgZmlyc3QuICovCisgICh2b2lkKSBzdHJjcHkgKG9uZSwgIiIpOworICBjaGVjayAoaW5kZXggKG9uZSwgJ2InKSA9PSBOVUxMLCA3KTsJLyogRW1wdHkgc3RyaW5nLiAqLworICBjaGVjayAoaW5kZXggKG9uZSwgJ1wwJykgPT0gb25lLCA4KTsJLyogTlVMIGluIGVtcHR5IHN0cmluZy4gKi8KK30KKworc3RhdGljIHZvaWQKK3Rlc3Rfc3RycmNociAodm9pZCkKK3sKKyAgaXQgPSAic3RycmNociI7CisgIGNoZWNrIChzdHJyY2hyICgiYWJjZCIsICd6JykgPT0gTlVMTCwgMSk7CS8qIE5vdCBmb3VuZC4gKi8KKyAgKHZvaWQpIHN0cmNweSAob25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ociI7CisgIGNoZWNrIChtZW1yY2hyICgiYWJjZCIsICd6JywgNSkgPT0gTlVMTCwgMSk7CS8qIE5vdCBmb3VuZC4gKi8KKyAgKHZvaWQpIHN0cmNweSAob25lLCAiYWJjZCIpOworICBsID0gc3RybGVuIChvbmUpICsgMTsKKyAgY2hlY2sgKG1lbXJjaHIgKG9uZSwgJ2MnLCBsKSA9PSBvbmUrMiwgMik7CS8qIEJhc2ljIHRlc3QuICovCisgIGNoZWNrIChtZW1yY2hyIChvbmUsICdkJywgbCkgPT0gb25lKzMsIDMpOwkvKiBFbmQgb2Ygc3RyaW5nLiAqLworICBjaGVjayAobWVtcmNociAob25lLCAnYScsIGwpID09IG9uZSwgNCk7CQkvKiBCZWdpbm5pbmcuICovCisgIGNoZWNrIChtZW1yY2hyIChvbmUsICdcMCcsIGwpID09IG9uZSs0LCA1KTsJLyogRmluZGluZyBOVUwuICovCisgICh2b2lkKSBzdHJjcHkgKG9uZSwgImFiYWJhIik7CisgIGwgPSBzdHJsZW4gKG9uZSkgKyAxOworICBjaGVjayAobWVtcmNociAob25lLCAnYicsIGwpID09IG9uZSszLCA2KTsJLyogRmluZGluZyBsYXN0LiAqLworICAodm9pZCkgc3RyY3B5IChvbmUsICIiKTsKKyAgbCA9IHN0cmxlbiAob25lKSArIDE7CisgIGNoZWNrIChtZW1yY2hyIChvbmUsICdiJywgbCkgPT0gTlVMTCwgNyk7CS8qIEVtcHR5IHN0cmluZy4gKi8KKyAgY2hlY2sgKG1lbXJjaHIgKG9uZSwgJ1wwJywgbCkgPT0gb25lLCA4KTsJLyogTlVMIGluIGVtcHR5IHN0cmluZy4gKi8KKworICAvKiBub3cgdGVzdCBhbGwgcG9zc2libGUgYWxpZ25tZW50IGFuZCBsZW5ndGggY29tYmluYXRpb25zIHRvIGNhdGNoCisgICAgIGJ1Z3MgZHVlIHRvIHVucm9sbGVkIGxvb3BzIChhc3N1bWluZyB1bnJvbGxpbmcgaXMgbGltaXRlZCB0byBubworICAgICBtb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YXNpYyB0ZXN0LiAqLworICBjaGVjayAocmluZGV4IChvbmUsICdkJykgPT0gb25lKzMsIDMpOwkvKiBFbmQgb2Ygc3RyaW5nLiAqLworICBjaGVjayAocmluZGV4IChvbmUsICdhJykgPT0gb25lLCA0KTsJLyogQmVnaW5uaW5nLiAqLworICBjaGVjayAocmluZGV4IChvbmUsICdcMCcpID09IG9uZSs0LCA1KTsJLyogRmluZGluZyBOVUwuICovCisgICh2b2lkKSBzdHJjcHkgKG9uZSwgImFiYWJhIik7CisgIGNoZWNrIChyaW5kZXggKG9uZSwgJ2InKSA9PSBvbmUrMywgNik7CS8qIEZpbmRpbmcgbGFzdC4gKi8KKyAgKHZvaWQpIHN0cmNweSAob25lLCAiIik7CisgIGNoZWNrIChyaW5kZXggKG9uZSwgJ2InKSA9PSBOVUxMLCA3KTsJLyogRW1wdHkgc3RyaW5nLiAqLworICBjaGVjayAocmluZGV4IChvbmUsICdcMCcpID09IG9uZSwgOCk7CS8qIE5VTCBpbiBlbXB0eSBzdHJpbmcuICovCit9CisKK3N0YXRpYyB2b2lkCit0ZXN0X3N0cnBicmsgKHZvaWQpCit7CisgIGl0ID0gInN0cnBicmsiOworICBjaGVjayhzdHJwYnJrKCJhYmNkIiwgInoiKSA9PSBOVUxMLCAxKTsJLyogTm90IGZvdW5kLiAqLworICAodm9pZCkgc3RyY3B5KG9uZSwgImFiY2QiKTsKKyAgY2hlY2soc3RycGJyayhvbmUsICJjIikgPT0gb25lKzIsIDIpOwkvKiBCYXNpYyB0ZXN0LiAqLworICBjaGVjayhzdHJwYnJrKG9uZSwgImQiKSA9PSBvbmUrMywgMyk7CS8qIEVuZCBvZiBzdHJpbmcuICovCisgIGNoZWNrKHN0cnBicmsob25lLCAiYSIpID09IG9uZSwgNCk7CS8qIEJlZ2lubmluZy4gKi8KKyAgY2hlY2soc3RycGJyayhvbmUsICIiKSA9PSBOVUxMLCA1KTsJLyogRW1wdHkgc2VhcmNoIGxpc3QuICovCisgIGNoZWNrKH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gayA8IGk7IGsrKykKKwkgICAgICBpZiAoZGF0YVtrXSAhPSAneCcpCisJCWdvdG8gZmFpbDsKKwkgICAgZm9yIChrID0gaTsgayA8IGkrajsgaysrKQorCSAgICAgIHsKKwkJaWYgKGRhdGFba10gIT0gYykKKwkJICBnb3RvIGZhaWw7CisJCWRhdGFba10gPSAneCc7CisJICAgICAgfQorCSAgICBmb3IgKGsgPSBpK2o7IGsgPCA1MTI7IGsrKykKKwkgICAgICBpZiAoZGF0YVtrXSAhPSAneCcpCisJCWdvdG8gZmFpbDsKKwkgICAgY29udGludWU7CisKKwkgIGZhaWw6CisJICAgIGNoZWNrICgwLCA4ICsgaSArIGogKiAyNTYgKyAoYyAhPSAwKSAqIDI1NiAqIDI1Nik7CisJICB9CisgIH0KK30KKworc3RhdGljIHZvaWQKK3Rlc3RfYmNvcHkgKHZvaWQpCit7CisgIC8qIE11Y2ggbGlrZSBtZW1jcHkuICBCZXJrbGl4IG1hbnVhbCBpcyBzaWxlbnQgYWJvdXQgb3ZlcmxhcCwgc28KKyAgICAgZG9uJ3QgdGVzdCBpdC4gICovCisgIGl0ID0gImJjb3B5IjsKKyAgKHZvaWQpIGJjb3B5KCJhYmMiLCBvbmUsIDQpOworICBlcXVhbChvbmUsICJhYmMiLCAxKTsJCQkvKiBTaW1wbGUgY29weS4gKi8KKworICAodm9pZCkgc3RyY3B5KG9uZSwgImFiY2RlZmdoIik7CisgICh2b2lkKSBiY29weSgieHl6Iiwgb25lKzEsIDIpOworICBlcXVhbChvbmUsICJheHlkZWZnaCIsIDIpOwkJLyogQmFzaWMgdGVzdC4gKi8KKworICAodm9pZCkgc3RyY3B5KG9uZSwgImFiYyIpOworICAodm9pZCkgYmNvcHkoInh5eiIsIG9uZSwgMCk7CisgIGVxdWFsKG9uZSwgImFiYyIsIDMpOwkJCS8qIFplcm8tbGVuZ3RoIGNvcHkuICovCisKKyAgKHZvaWQpIHN0cmNweShvbmUsICJoaSB0aGVyZSIpOworICAodm9pZCkgc3RyY3B5KHR3bywgImZvbyIpOworICAodm9pZCkgYmNvcHkob25lLCB0d28sIDkpOworICBlcXVhbCh0d28sICJoaSB0aGVyZSIsIDQpOwkJLyogSnVzdCBwYXJhbm9pYS4gKi8KKyAgZXF1YWwob25lLCAiaGkgdGhlcmUiLCA1KTsJCS8qIFN0b21wZWQgb24gc291cmNlPyAqLworfQorCitzdGF0aWMgdm9pZAordGVzdF9iemVybyAodm9pZCkKK3sKKyAgaXQgPSAiYnplcm8iOworICAodm9pZCkgc3RyY3B5KG9uZSwgImFiY2RlZiIpOworICBiemVybyhvbmUrMiwgMik7CisgIGVxdWFsKG9uZSwgImFiIiwgMSk7CQkJLyogQmFzaWMgdGVzdC4gKi8KKyAgZXF1YWwob25lKzMsICIiLCAyKTsKKyAgZXF1YWwob25lKzQsICJlZiIsIDMpOworCisgICh2b2lkKSBzdHJjcHkob25lLCAiYWJjZGVmIik7CisgIGJ6ZXJvKG9uZSsyLCAwKTsKKyAgZXF1YWwob25lLCAiYWJjZGVmIiwgNCk7CQkvKiBaZXJvLWxlbmd0aCBjb3B5LiAqLworfQorCitzdGF0aWMgdm9pZAordGVzdF9zdHJuZHVwICh2b2lkKQoreworICBjaGFyICpwLCAqcTsKKyAgaXQgPSAic3RybmR1cCI7CisgIHAgPSBzdHJuZHVwKCJhYmNkZWYiLCAxMik7CisgIGNoZWNrKHAgIT0gTlVMTCwgMSk7CisgIGlmIChwICE9IE5VTEwpCisgICAgeworICAgICAgZXF1YWwocCwgImFiY2RlZiIsIDIpOworICAgICAgcSA9IHN0cm5kdXAocCArIDEsIDIpOworICAgICAgY2hlY2socSAhPSBOVUxMLCAzKTsKKyAgICAgIGlmIChxICE9IE5VTEwpCisJZXF1YWwocSwgImJjIiwgNCk7CisgICAgICBmcmVlIChxKTsKKyAgICB9CisgIGZyZWUgKHApOworICBwID0gc3RybmR1cCgiYWJjIGRlZiIsIDMpOworICBjaGVjayhwICE9IE5VTEwsIDUpOworICBpZiAocCAhPSBOVUxM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HQgPSAwOworCisgIC8qIFRlc3QgdGhlIGZ1bmN0aW9ucyB3aXRoIGNvbnN0YW50IGFyZ3VtZW50cy4gICovCisgIGlmIChic3dhcF8xNiAoMHgxMjM0KSAhPSAweDM0MTIpCisgICAgeworICAgICAgcHV0cyAoImJzd2FwXzE2IChjb25zdGFudCkgZmx1bmtlZCIpOworICAgICAgcmVzdWx0ID0gMTsKKyAgICB9CisgIGlmIChic3dhcF8zMiAoMHgxMjM0NTY3OCkgIT0gMHg3ODU2MzQxMikKKyAgICB7CisgICAgICBwdXRzICgiYnN3YXBfMzIgKGNvbnN0YW50KSBmbHVua2VkIik7CisgICAgICByZXN1bHQgPSAxOworICAgIH0KKyAgaWYgKGJzd2FwXzY0ICgweDEyMzQ1Njc4OTBhYmNkZWZVTEwpICE9IDB4ZWZjZGFiOTA3ODU2MzQxMlVMTCkKKyAgICB7CisgICAgICBwdXRzICgiYnN3YXBfNjQgKGNvbnN0YW50KSBmbHVua2VkIik7CisgICAgICByZXN1bHQgPSAxOworICAgIH0KKworICAvKiBUZXN0IHRoZSBmdW5jdGlvbnMgd2l0aCBub24tY29uc3RhbnQgYXJndW1lbnRzLiAgKi8KKyAgaWYgKGJzd2FwXzE2ICh3YXNoICgweDEyMzQpKSAhPSAweDM0MTIpCisgICAgeworICAgICAgcHV0cyAoImJzd2FwXzE2IChub24tY29uc3RhbnQpIGZsdW5rZWQiKTsKKyAgICAgIHJlc3VsdCA9IDE7CisgICAgfQorICBpZiAoYnN3YXBfMzIgKHdhc2ggKDB4MTIzNDU2NzgpKSAhPSAweDc4NTYzNDEyKQorICAgIHsKKyAgICAgIHB1dHMgKCJic3dhcF8zMiAobm9uLWNvbnN0YW50KSBmbHVua2VkIik7CisgICAgICByZXN1bHQgPSAxOworICAgIH0KKyAgaWYgKGJzd2FwXzY0ICh3YXNoICgweDEyMzQ1Njc4OTBhYmNkZWZVTEwpKSAhPSAweGVmY2RhYjkwNzg1NjM0MTJVTEwpCisgICAgeworICAgICAgc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0b2ggKCUiIFBSSXg2NCAiKSkgPT0gJSIgUFJJeDE2ICJcbiIsCisJCSAgICAgIGksICh1aW50MTZfdCkgaHRvYmUxNiAoYmUxNnRvaCAoaSkpKTsKKwkgICAgICByZXN1bHQgPSAxOworCSAgICB9CisJICBpZiAoaHRvbGUxNiAobGUxNnRvaCAoaSkpICE9IGkpCisJICAgIHsKKwkgICAgICBwcmludGYgKCJodG9sZTE2IChsZTE2dG9oICglIiBQUkl4NjQgIikpID09ICUiIFBSSXgxNiAiXG4iLAorCQkgICAgICBpLCAodWludDE2X3QpIGh0b2xlMTYgKGxlMTZ0b2ggKGkpKSk7CisJICAgICAgcmVzdWx0ID0gMTsKKwkgICAgfQorCSAgRElBR19QT1BfTkVFRFNfQ09NTUVOVDsKKworCSAgdWludDE2X3QgblsyXTsKKwkgIG5bX19CWVRFX09SREVSID09IF9fTElUVExFX0VORElBTl0gPSBic3dhcF8xNiAoaSk7CisJICBuW19fQllURV9PUkRFUiA9PSBfX0JJR19FTkRJQU5dID0gaTsKKwkgIGlmIChodG9sZTE2IChpKSAhPSBuWzBdKQorCSAgICB7CisJICAgICAgcHJpbnRmICgiaHRvbGUxNiAoJSIgUFJJeDY0ICIpID09ICUiIFBSSXgxNiAiICE9ICUiIFBSSXgxNiAiXG4iLAorCQkgICAgICBpLCAodWludDE2X3QpIGh0b2xlMTYgKGkpLCBuWzBdKTsKKwkgICAgICByZXN1bHQgPSAxOworCSAgICB9CisJICBpZiAoaHRvYmUxNiAoaSkgIT0gblsxXSkKKwkgICAgeworCSAgICAgIHByaW50ZiAoImh0b2JlMTYgKCUiIFBSSXg2NCAiKSA9PSAlIiBQUkl4MTYgIiAhPSAlIiBQUkl4MTYgIlxuIiwKKwkJICAgICAgaSwgKHVpbnQxNl90KSBodG9iZTE2IChpKSwgblsxXSk7CisJICAgICAgcmVzdWx0ID0gMTsKKwkgICAgfQorCX0KKworICAgICAgaWYgKGkgPCBVSU5UNjRfQyAoNDI5NDk2NzI5NikpCisJeworCSAgRElBR19QVVNIX05FRURTX0NPTU1FTlQ7CisJICBESUFHX0lHTk9SRV9ORUVEU19DT01NRU5UX1RBVVRPTE9HSUNBTF9DT01QQVJFICgpOworCSAgaWYgKGh0b2JlMzIgKGJlMzJ0b2ggKGkpKSAhPSBpKQorCSAgICB7CisJICAgICAgcHJpbnRmICgiaHRvYmUzMiAoYmUzMnRvaCAoJSIgUFJJeDY0ICIpKSA9PSAlIiBQUkl4MzIgIlxuIiwKKwkJICAgICAgaSwgKHVpbnQzMl90KSBodG9iZTMyIChiZTMydG9oIChpKSkpOworCSAgICAgIHJlc3VsdCA9IDE7CisJICAgIH0KKwkgIGlmIChodG9sZTMyIChsZTMydG9oIChpKSkgIT0gaSkKKwkgICAgeworCSAgICAgIHByaW50ZiAoImh0b2xlMzIgKGxlMzJ0b2ggKCUiIFBSSXg2NCAiKSkgPT0gJSIgUFJJeDMyICJcbiIsCisJCSAgICAgIGksICh1aW50MzJfdCkgaHRvbGUzMiAobGUzMnRvaCAoaSkpKTsKKwkgICAgICByZXN1bHQgPSAxOworCSAgICB9CisJICBESUFHX1BPUF9ORUVEU19DT01NRU5UOworCisJICB1aW50MzJfdCBuWzJdOworCSAgbltfX0JZVEVfT1JERVIgPT0gX19MSVRUTEVfRU5ESUFOXSA9IGJzd2FwXzMyIChpKTsKKwkgIG5bX19CWVRFX09SREVSID09IF9fQklHX0VORElBTl0gPSBpOworCSAgaWYgKGh0b2xlMzIgKGkpICE9IG5bMF0pCisJICAgIHsKKwkgICAgICBwcmludGYgKCJodG9sZTMyICglIiBQUkl4NjQgIikgPT0gJSIgUFJJeDMyICIgIT0gJSIgUFJJeDMyICJcbiIsCisJCSAgICAgIGksICh1aW50MzJfdCkgaHRvbGUzMiAoaSksIG5bMF0pOworCSAgICAgIHJlc3VsdCA9IDE7CisJICAgIH0KKwkgIGlmIChodG9iZTMyIChpKSAhPSBuWzFdKQorCSAgICB7CisJICAgICAgcHJpbnRmICgiaHRvYmUzMiAoJSIg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0aWMgaW50Citkb190ZXN0ICh2b2lkKQoreworICBpbnQgc3RhdHVzOworICBpbnQgZXJyb3JzID0gMDsKKyAgY2hhciBidWYxWzEwMDBdOworICBjaGFyICpjcDsKKyAgY2hhciBjaDsKKworICBjcCA9IHN0cmNweSAoYnVmMSwgImhlbGxvIHdvcmxkIik7CisgIGlmIChzdHJjbXAgKCJoZWxsbyB3b3JsZCIsIGNwKyspICE9IDApCisgICAgeworICAgICAgcHV0cyAoInN0cmNtcCB0ZXN0IDEgZmFpbGVkIik7CisgICAgICArK2Vycm9yczsKKyAgICB9CisKKyAgY3AgPSBidWYxOworICBpZiAoc3RyY21wIChjcCsrLCAiaGVsbG8gd29ybGQiKSAhPSAwKQorICAgIHsKKyAgICAgIHB1dHMgKCJzdHJjbXAgdGVzdCAyIGZhaWxlZCIpOworICAgICAgKytlcnJvcnM7CisgICAgfQorCisgIGNoID0gJ2gnOworICBpZiAoc3RyY2hyICgiaGVsbG8gd29ybGQiLCBjaCsrKSA9PSBOVUxMKQorICAgIHsKKyAgICAgIHB1dHMgKCJzdHJjaHIgdGVzdCAxIGZhaWxlZCIpOworICAgICAgKytlcnJvcnM7CisgICAgfQorCisgIGNvbnN0IGNoYXIgKiBjb25zdCBodyA9ICJoZWxsbyB3b3JsZCI7CisgIGlmIChzdHJwYnJrIChodywgIm8iKSAtIGh3ICE9IDQpCisgICAgeworICAgICAgcHV0cyAoInN0cnBicmsgdGVzdCAxIGZhaWxlZCIpOworICAgICAgKytlcnJvcnM7CisgICAgfQorCisgIGlmIChlcnJvcnMgPT0gMCkKKyAgICB7CisgICAgICBzdGF0dXMgPSBFWElUX1NVQ0NFU1M7CisgICAgICBwdXRzICgiTm8gZXJyb3JzLiIpOworICAgIH0KKyAgZWxzZQorICAgIHsKKyAgICAgIHN0YXR1cyA9IEVYSVRfRkFJTFVSRTsKKyAgICAgIHByaW50ZiAoIiVkIGVycm9ycy5cbiIsIGVycm9ycyk7CisgICAgfQorICByZXR1cm4gc3RhdH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ZSA8c3RyaW5nLmg+CisKKworY2hhciBjb25zdCBzdHJpbmdbXSA9ICIiOworCisKK3N0YXRpYyBpbnQKK3Rlc3QgKGNvbnN0IGNoYXIgKmxvY2FsZSkKK3sKKyAgc2l6ZV90IGJ1ZnNpemU7CisgIHNpemVfdCByOworICBzaXplX3QgbDsKKyAgY2hhciAqYnVmOworICBsb2NhbGVfdCBsb2M7CisgIGludCByZXN1bHQgPSAwOworCisgIGlmIChzZXRsb2NhbGUgKExDX0NPTExBVEUsIGxvY2FsZSkgPT0gTlVMTCkKKyAgICB7CisgICAgICBwcmludGYgKCJjYW5ub3Qgc2V0IGxvY2FsZSBcIiVzXCJcbiIsIGxvY2FsZSk7CisgICAgICByZXR1cm4gMTsKKyAgICB9CisgIGJ1ZnNpemUgPSBzdHJ4ZnJtIChOVUxMLCBzdHJpbmcsIDApICsgMTsKKyAgYnVmID0gbWFsbG9jIChidWZzaXplKTsKKyAgaWYgKGJ1ZiA9PSBOVUxMKQorICAgIHsKKyAgICAgIHByaW50ZiAoImNhbm5vdCBhbGxvY2F0ZSAlemQgYnl0ZXNcbiIsIGJ1ZnNpemUpOworICAgICAgcmV0dXJuIDE7CisgICAgfQorICByID0gc3RyeGZybSAoYnVmLCBzdHJpbmcsIGJ1ZnNpemUpOworICBsID0gc3RybGVuIChidWYpOworICBpZiAociAhPSBsKQorICAgIHsKKyAgICAgICBwcmludGYgKCJsb2NhbGUgXCIlc1wiOiBzdHJ4ZnJtIHJldHVybmVkICV6dSwgc3RybGVuIHJldHVybmVkICV6dVxuIiwKKwkgICAgICAgbG9jYWxlLCByLCBsKTsKKyAgICAgICByZXN1bHQgPSAxOworICAgIH0KKworICBsb2MgPSBuZXdsb2NhbGUgKDEgPDwgTENfQUxMLCBsb2NhbGUsIE5VTEwpOworCisgIHIgPSBzdHJ4ZnJtX2wgKGJ1Ziwgc3RyaW5nLCBidWZzaXplLCBsb2MpOworICBsID0gc3RybGVuIChidWYpOworICBpZiAociAhPSBsKQorICAg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kuaD4KKworLyogX3dvcmRjb3B5X2Z3ZF9hbGlnbmVkIC0tIENvcHkgYmxvY2sgYmVnaW5uaW5nIGF0IFNSQ1AgdG8KKyAgIGJsb2NrIGJlZ2lubmluZyBhdCBEU1RQIHdpdGggTEVOIGBvcF90JyB3b3JkcyAobm90IExFTiBieXRlcyEpLgorICAgQm90aCBTUkNQIGFuZCBEU1RQIHNob3VsZCBiZSBhbGlnbmVkIGZvciBtZW1vcnkgb3BlcmF0aW9ucyBvbiBgb3BfdCdzLiAgKi8KKworI2lmbmRlZiBXT1JEQ09QWV9GV0RfQUxJR05FRAorIyBkZWZpbmUgV09SRENPUFlfRldEX0FMSUdORUQgX3dvcmRjb3B5X2Z3ZF9hbGlnbmVkCisjZW5kaWYKKwordm9pZAorV09SRENPUFlfRldEX0FMSUdORUQgKGxvbmcgaW50IGRzdHAsIGxvbmcgaW50IHNyY3AsIHNpemVfdCBsZW4pCit7CisgIG9wX3QgYTAsIGExOworCisgIHN3aXRjaCAobGVuICUgOCkKKyAgICB7CisgICAgY2FzZSAyOgorICAgICAgYTAgPSAoKG9wX3QgKikgc3JjcClbMF07CisgICAgICBzcmNwIC09IDYgKiBPUFNJWjsKKyAgICAgIGRzdHAgLT0gNyAqIE9QU0laOworICAgICAgbGVuICs9IDY7CisgICAgICBnb3RvIGRvMTsKKyAgICBjYXNlIDM6CisgICAgICBhMSA9ICgob3BfdCAqKSBzcmNwKVswXTsKKyAgICAgIHNyY3AgLT0gNSAqIE9QU0laOworICAgICAgZHN0cCAtPSA2ICogT1BTSVo7CisgICAgICBsZW4gKz0gNTsKKyAgICAgIGdvdG8gZG8yOworICAgIGNhc2UgNDoKKyAgICAgIGEwID0gKChvcF90ICopIHNyY3ApWzBdOworICAgICAgc3JjcCAtPSA0ICogT1BTSVo7CisgICAgICBkc3RwIC09IDUgKiBPUFNJWjsKKyAgICAgIGxlbiArPSA0OworICAgICAgZ290byBkbzM7CisgICAgY2FzZSA1OgorICAgICAgYTEgPSAoKG9wX3QgKikgc3JjcClbMF07CisgICAgICBzcmNwIC09IDMgKiBPUFNJWjsKKyAgICAgIGRzdHAgLT0gNCAqIE9QU0laOworICAgICAgbGVuICs9IDM7CisgICAgICBnb3RvIGRvNDsKKyAgICBjYXNlIDY6CisgICAgICBhMCA9ICgob3BfdCAqKSBzcmNwKVswXTsKKyAgICAgIHNyY3AgLT0gMiAqIE9QU0laOworICAgICAgZHN0cCAtPSAzICogT1BTSVo7CisgICAgICBsZW4gKz0gMjsKKyAgICAgIGdvdG8gZG81OworICAgIGNhc2UgNzoKKyAgICAgIGExID0gKChvcF90ICopIHNyY3ApWzBdOworICAgICAgc3JjcCAtPSAxICogT1BTSVo7CisgICAgICBkc3RwIC09IDIgKiBPUFNJWjsKKyAgICAgIGxlbiArPSAxOworICAgICAgZ290byBkbzY7CisKKyAgICBjYXNlIDA6CisgICAgICBpZiAoT1BfVF9USFJFUyA8PSAzICogT1BTSVogJiYgbGVuID09IDApCisJcmV0dXJuOworICAgICAgYTAgPSAoKG9wX3QgKikgc3JjcClbMF07CisgICAgICBzcmNwIC09IDAgKiBPUFNJWjsKKyAgICAgIGRzdHAgLT0gMSAqIE9QU0laOworICAgICAgZ290byBkbzc7CisgICAgY2FzZSAxOgorICAgICAgYTEgPSAoKG9wX3QgKikgc3JjcClbMF07CisgICAgICBzcmNwIC09LTEgKiBPUFNJWjsKKyAgICAgIGRzdHAgLT0gMCAqIE9QU0laOworICAgICAgbGVuIC09IDE7CisgICAgICBpZiAoT1BfVF9USFJFUyA8PSAzICogT1BTSVogJiYgbGVuID09IDApCisJZ290byBkbzA7CisgICAgICBnb3RvIGRvODsJCQkvKiBOby1vcC4gICovCisgICAgfQorCisgIGRvCisgICAgeworICAgIGRvODoKKyAgICAgIGEwID0gKChvcF90ICopIHNyY3ApWzBdOworICAgICAgKChvcF90ICopIGRzdHApWzBdID0gYTE7CisgICAgZG83OgorICAgICAgYTEgPSAoKG9wX3QgKikgc3JjcClbMV07CisgICAgICAoKG9wX3QgKikgZHN0cClbMV0gPSBhMDsKKyAgICBkbzY6CisgICAgICBhMCA9ICgob3BfdCAqKSBzcmNwKVsyXTsKKyAgICAgICgob3BfdCAqKSBkc3RwKVsyXSA9IGExOworICAgIGRvNToKKyAgICAgIGExID0gKChvcF90ICopIHNyY3ApWzNdOworICAgICAgKChvcF90ICopIGRzdHApWzNdID0gYTA7CisgICAgZG80OgorICAgICAgYTAgPSAoKG9wX3QgKikgc3JjcClbNF07CisgICAgICAoKG9wX3QgKikgZHN0cClbNF0gPSBhMTsKKyAgICBkbzM6CisgICAgICBhMSA9ICgob3BfdCAqKSBzcmNwKVs1XTsKKyAgICAgICgob3BfdCAqKSBkc3RwKVs1XSA9IGEwOworICAgIGRvMjoKKyAgICAgIGEwID0gKChvcF90ICopIHNyY3ApWzZdOworICAgICAgKChvcF90ICopIGRzdHApWzZdID0gYTE7CisgICAgZG8xOgorICAgICAgYTEgPSAoKG9wX3QgKikgc3JjcClbN107CisgICAgICAoKG9wX3QgKikgZHN0cClbN10gPSBhMDsKKworICAgICAgc3JjcCArPSA4ICogT1BTSVo7CisgICAgICBkc3RwICs9IDggKiBPUFNJWjsKKyAgICAgIGxlbiAtPSA4OworICAgIH0KKyAgd2hpbGUgKGxlbiAhPSAwKTsKKworICAvKiBUaGlzIGlzIHRoZSByaWdodCBwb3NpdGlvbiBmb3IgZG8wLiAgUGxlYXNlIGRvbid0IG1vdmUKKyAgICAgaXQgaW50byB0aGUgbG9vcC4gICovCisgZG8wOgorICAoKG9wX3QgKikgZHN0cClbMF0gPSBhMTsKK30KKworLyogX3dvcmRjb3B5X2Z3ZF9kZXN0X2FsaWduZWQgLS0gQ29weSBibG9jayBiZWdpbm5pbmcgYXQgU1JDUCB0bworICAgYmxvY2sgYmVnaW5uaW5nIGF0IERTVFAgd2l0aCBMRU4gYG9wX3QnIHdvcmRzIChub3QgTEVOIGJ5dGVzISkuCisgICBEU1RQIHNob3VsZCBiZSBhbGlnbmVkIGZvciBtZW1vcnk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dOworICAgICAgYTEgPSAoKG9wX3QgKikgc3JjcClbMV07CisgICAgICBzcmNwIC09IDAgKiBPUFNJWjsKKyAgICAgIGRzdHAgLT0gMiAqIE9QU0laOworICAgICAgbGVuICs9IDE7CisgICAgICBnb3RvIGRvMjsKKyAgICBjYXNlIDA6CisgICAgICBpZiAoT1BfVF9USFJFUyA8PSAzICogT1BTSVogJiYgbGVuID09IDApCisJcmV0dXJuOworICAgICAgYTMgPSAoKG9wX3QgKikgc3JjcClbMF07CisgICAgICBhMCA9ICgob3BfdCAqKSBzcmNwKVsxXTsKKyAgICAgIHNyY3AgLT0tMSAqIE9QU0laOworICAgICAgZHN0cCAtPSAxICogT1BTSVo7CisgICAgICBsZW4gKz0gMDsKKyAgICAgIGdvdG8gZG8zOworICAgIGNhc2UgMToKKyAgICAgIGEyID0gKChvcF90ICopIHNyY3ApWzBdOworICAgICAgYTMgPSAoKG9wX3QgKikgc3JjcClbMV07CisgICAgICBzcmNwIC09LTIgKiBPUFNJWjsKKyAgICAgIGRzdHAgLT0gMCAqIE9QU0laOworICAgICAgbGVuIC09IDE7CisgICAgICBpZiAoT1BfVF9USFJFUyA8PSAzICogT1BTSVogJiYgbGVuID09IDApCisJZ290byBkbzA7CisgICAgICBnb3RvIGRvNDsJCQkvKiBOby1vcC4gICovCisgICAgfQorCisgIGRvCisgICAgeworICAgIGRvNDoKKyAgICAgIGEwID0gKChvcF90ICopIHNyY3ApWzBdOworICAgICAgKChvcF90ICopIGRzdHApWzBdID0gTUVSR0UgKGEyLCBzaF8xLCBhMywgc2hfMik7CisgICAgZG8zOgorICAgICAgYTEgPSAoKG9wX3QgKikgc3JjcClbMV07CisgICAgICAoKG9wX3QgKikgZHN0cClbMV0gPSBNRVJHRSAoYTMsIHNoXzEsIGEwLCBzaF8yKTsKKyAgICBkbzI6CisgICAgICBhMiA9ICgob3BfdCAqKSBzcmNwKVsyXTsKKyAgICAgICgob3BfdCAqKSBkc3RwKVsyXSA9IE1FUkdFIChhMCwg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wIC09IDIgKiBPUFNJWjsKKyAgICAgIGRzdHAgLT0gMSAqIE9QU0laOworICAgICAgYTAgPSAoKG9wX3QgKikgc3JjcClbMV07CisgICAgICBsZW4gKz0gNjsKKyAgICAgIGdvdG8gZG8xOworICAgIGNhc2UgMzoKKyAgICAgIHNyY3AgLT0gMyAqIE9QU0laOworICAgICAgZHN0cCAtPSAyICogT1BTSVo7CisgICAgICBhMSA9ICgob3BfdCAqKSBzcmNwKVsyXTsKKyAgICAgIGxlbiArPSA1OworICAgICAgZ290byBkbzI7CisgICAgY2FzZSA0OgorICAgICAgc3JjcCAtPSA0ICogT1BTSVo7CisgICAgICBkc3RwIC09IDMgKiBPUFNJWjsKKyAgICAgIGEwID0gKChvcF90ICopIHNyY3ApWzNdOworICAgICAgbGVuICs9IDQ7CisgICAgICBnb3RvIGRvMzsKKyAgICBjYXNlIDU6CisgICAgICBzcmNwIC09IDUgKiBPUFNJWjsKKyAgICAgIGRzdHAgLT0gNCAqIE9QU0laOworICAgICAgYTEgPSAoKG9wX3QgKikgc3JjcClbNF07CisgICAgICBsZW4gKz0gMzsKKyAgICAgIGdvdG8gZG80OworICAgIGNhc2UgNjoKKyAgICAgIHNyY3AgLT0gNiAqIE9QU0laOworICAgICAgZHN0cCAtPSA1ICogT1BTSVo7CisgICAgICBhMCA9ICgob3BfdCAqKSBzcmNwKVs1XTsKKyAgICAgIGxlbiArPSAyOworICAgICAgZ290byBkbzU7CisgICAgY2FzZSA3OgorICAgICAgc3JjcCAtPSA3ICogT1BTSVo7CisgICAgICBkc3RwIC09IDYgKiBPUFNJWjsKKyAgICAgIGExID0gKChvcF90ICopIHNyY3ApWzZdOworICAgICAgbGVuICs9IDE7CisgICAgICBnb3RvIGRvNjsKKworICAgIGNhc2UgMDoKKyAgICAgIGlmIChPUF9UX1RIUkVTIDw9IDMgKiBPUFNJWiAmJiBsZW4gPT0gMCkKKwlyZXR1cm47CisgICAgICBzcmNwIC09IDggKiBPUFNJWjsKKyAgICAgIGRzdHAgLT0gNyAqIE9QU0laOworICAgICAgYTAgPSAoKG9wX3QgKikgc3JjcClbN107CisgICAgICBnb3RvIGRvNzsKKyAgICBjYXNlIDE6CisgICAgICBzcmNwIC09IDkgKiBPUFNJWjsKKyAgICAgIGRzdHAgLT0gOCAqIE9QU0laOworICAgICAgYTEgPSAoKG9wX3QgKikgc3JjcClbOF07CisgICAgICBsZW4gLT0gMTsKKyAgICAgIGlmIChPUF9UX1RIUkVTIDw9IDMgKiBPUFNJWiAmJiBsZW4gPT0gMCkKKwlnb3RvIGRvMDsKKyAgICAgIGdvdG8gZG84OwkJCS8qIE5vLW9wLiAgKi8KKyAgICB9CisKKyAgZG8KKyAgICB7CisgICAgZG84OgorICAgICAgYTAgPSAoKG9wX3QgKikgc3JjcClbN107CisgICAgICAoKG9wX3QgKikgZHN0cClbN10gPSBhMTsKKyAgICBkbzc6CisgICAgICBhMSA9ICgob3BfdCAqKSBzcmNwKVs2XTsKKyAgICAgICgob3BfdCAqKSBkc3RwKVs2XSA9IGEwOworICAgIGRvNjoKKyAgICAgIGEwID0gKChvcF90ICopIHNyY3ApWzVdOworICAgICAgKChvcF90ICopIGRzdHApWzVdID0gYTE7CisgICAgZG81OgorICAgICAgYTEgPSAoKG9wX3QgKikgc3JjcClbNF07CisgICAgICAoKG9wX3QgKikgZHN0cClbNF0gPSBhMDsKKyAgICBkbzQ6CisgICAgICBhMCA9ICgob3BfdCAqKSBzcmNwKVszXTsKKyAgICAgICgob3BfdCAqKSBkc3RwKVszXSA9IGExOworICAgIGRvMzoKKyAgICAgIGExID0gKChvcF90ICopIHNyY3ApWzJdOworICAgICAgKChvcF90ICopIGRzdHApWzJdID0gYTA7CisgICAgZG8yOgorICAgICAgYTAgPSAoKG9wX3QgKikgc3JjcClbMV07CisgICAgICAoKG9wX3QgKikgZHN0cClbMV0gPSBhMTsKKyAgICBkbzE6CisgICAgICBhMSA9ICgob3BfdCAqKSBzcmNwKVswXTsKKyAgICAgICgob3BfdCAqKSBk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xpZ25lZCBmb3IgY29weS4gICovCisKKyAgc2hfMSA9IDggKiAoc3JjcCAlIE9QU0laKTsKKyAgc2hfMiA9IDggKiBPUFNJWiAtIHNoXzE7CisKKyAgLyogTWFrZSBzcmNwIGFsaWduZWQgYnkgcm91bmRpbmcgaXQgZG93biB0byB0aGUgYmVnaW5uaW5nIG9mIHRoZSBvcF90CisgICAgIGl0IHBvaW50cyBpbiB0aGUgbWlkZGxlIG9mLiAgKi8KKyAgc3JjcCAmPSAtT1BTSVo7CisgIHNyY3AgKz0gT1BTSVo7CisKKyAgc3dpdGNoIChsZW4gJSA0KQorICAgIHsKKyAgICBjYXNlIDI6CisgICAgICBzcmNwIC09IDMgKiBPUFNJWjsKKyAgICAgIGRzdHAgLT0gMSAqIE9QU0laOworICAgICAgYTIgPSAoKG9wX3QgKikgc3JjcClbMl07CisgICAgICBhMSA9ICgob3BfdCAqKSBzcmNwKVsxXTsKKyAgICAgIGxlbiArPSAyOworICAgICAgZ290byBkbzE7CisgICAgY2FzZSAzOgorICAgICAgc3JjcCAtPSA0ICogT1BTSVo7CisgICAgICBkc3RwIC09IDIgKiBPUFNJWjsKKyAgICAgIGEzID0gKChvcF90ICopIHNyY3ApWzNdOworICAgICAgYTIgPSAoKG9wX3QgKikgc3JjcClbMl07CisgICAgICBsZW4gKz0gMTsKKyAgICAgIGdvdG8gZG8yOworICAgIGNhc2UgMDoKKyAgICAgIGlmIChPUF9UX1RIUkVTIDw9IDMgKiBPUFNJWiAmJiBsZW4gPT0gMCkKKwlyZXR1cm47CisgICAgICBzcmNwIC09IDUgKiBPUFNJWjsKKyAgICAgIGRzdHAgLT0gMyAqIE9QU0laOworICAgICAgYTAgPSAoKG9wX3QgKikgc3JjcClbNF07CisgICAgICBhMyA9ICgob3BfdCAqKSBzcmNwKVszXTsKKyAgICAgIGdvdG8gZG8zOworICAgIGNhc2UgMToKKyAgICAgIHNyY3AgLT0gNiAqIE9QU0laOworICAgICAgZHN0cCAtPSA0ICogT1BTSVo7CisgICAgICBhMSA9ICgob3BfdCAqKSBzcmNwKVs1XTsKKyAgICAgIGEwID0gKChvcF90ICopIHNyY3ApWzRdOworICAgICAgbGVuIC09IDE7CisgICAgICBpZiAoT1BfVF9USFJFUyA8PSAzICogT1BTSVogJiYgbGVuID09IDApCisJZ290byBkbzA7CisgICAgICBnb3RvIGRvNDsJCQkvKiBOby1vcC4gICovCisgICAgfQorCisgIGRvCisgICAgeworICAgIGRvNDoKKyAgICAgIGEzID0gKChvcF90ICopIHNyY3ApWzNdOworICAgICAgKChvcF90ICopIGRzdHApWzNdID0gTUVSR0UgKGEwLCBzaF8xLCBhMSwgc2hfMik7CisgICAgZG8zOgorICAgICAgYTIgPSAoKG9wX3QgKikgc3JjcClbMl07CisgICAgICAoKG9wX3QgKikgZHN0cClbMl0gPSBNRVJHRSAoYTMsIHNoXzEsIGEwLCBzaF8yKTsKKyAgICBkbzI6CisgICAgICBhMSA9ICgob3BfdCAqKSBzcmNwKVsxXTsKKyAgICAgICgob3BfdCAqKSBkc3RwKVsxXSA9IE1FUkdFIChhMiwgc2hfMSwgYTMsIHNoXzIpOworICAgIGRvMToKKyAgICAgIGEwID0gKChvcF90ICopIHNyY3ApWzBdOworICAgICAgKChvcF90ICopIGRzdHApWzBdID0gTUVSR0UgKGExLCBzaF8xLCBhMiwgc2hfMik7CisKKyAgICAgIHNyY3AgLT0gNCAqIE9QU0laOworICAgICAgZHN0cCAtPSA0ICogT1BTSVo7CisgICAgICBsZW4gLT0gNDsKKyAgICB9CisgIHdoaWxlIChsZW4gIT0gMCk7CisKKyAgLyogVGhpcyBpcyB0aGUgcmlnaHQgcG9zaXRpb24gZm9yIGRvMC4gIFBsZWFzZSBkb24ndCBtb3ZlCisgICAgIGl0IGludG8gdGhlIGxvb3AuICAqLworIGRvMDoKKyAgKChvcF90ICopIGRzdHApWzNdID0gTUVSR0UgKGEwLCBzaF8xLCBhMSwgc2hfMik7Cit9CmRpZmYgLS1naXQgYS9hcC9saWJjL2dsa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