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lmICh0bHZzLT50ZV9pcHY0X3JlYWNocykgewogICAgbGlzdF9kZWxldGUgKHRsdnMtPnRlX2lwdjRfcmVhY2hzKTsKICB9CiNpZmRlZiBIQVZFX0lQVjYKICBpZiAodGx2cy0+aXB2Nl9hZGRycykgewogICAgbGlzdF9kZWxldGUgKHRsdnMtPmlwdjZfYWRkcnMpOwogIH0KICBpZiAodGx2cy0+aXB2Nl9yZWFjaHMpIHsKICAgIGxpc3RfZGVsZXRlICh0bHZzLT5pcHY2X3JlYWNocyk7CiAgfQojZW5kaWYgLyogSEFWRV9JUFY2ICovCiAgcmV0dXJuOwp9CgovKgogKiBQYXJzZXMgdGhlIHRsdnMgZm91bmQgaW4gdGhlIHZhcmlhbnQgbGVuZ3RoIHBhcnQgb2YgdGhlIFBEVS4KICogQ2FsbGVyIHRlbGxzIHdpdGggZmxhZ3MgaW4gImV4cGVjdGVkIiB3aGljaCBUTFYncyBpdCBpcyBpbnRlcmVzdGVkIGluLgogKi8KaW50IApwYXJzZV90bHZzIChjaGFyICphcmVhdGFnLCB1X2NoYXIgKnN0cmVhbSwgaW50IHNpemUsIHVfaW50MzJfdCAqZXhwZWN0ZWQsIAoJICAgIHVfaW50MzJfdCAqZm91bmQsIHN0cnVjdCB0bHZzICp0bHZzKQp7CiAgdV9jaGFyICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlLCBsZW5ndGg7CiAgc3RydWN0IGxhbl9uZWlnaCAgICAgICAgICAgICAgICAgICAgKmxhbl9uZWk7CiAgc3RydWN0IGFyZWFfYWRkciAgICAgICAgICAgICAgICAgICphcmVhX2FkZHI7CiAgc3RydWN0IGlzX25laWdoICAgICAgICAgICAgICAgICAgICAgICppc19uZWk7CiAgc3RydWN0IHRlX2lzX25laWdoICAgICAgICAgICAgICAgICp0ZV9pc19uZWk7CiAgc3RydWN0IGVzX25laWdoICAgICAgICAgICAgICAgICAgICAgICplc19uZWk7CiAgc3RydWN0IGxzcF9lbnRyeSAgICAgICAgICAgICAgICAgICpsc3BfZW50cnk7CiAgc3RydWN0IGluX2FkZHIgICAgICAgICAgICAgICAgICAgICppcHY0X2FkZHI7CiAgc3RydWN0IGlwdjRfcmVhY2hhYmlsaXR5ICAgICAgICAgKmlwdjRfcmVhY2g7CiAgc3RydWN0IHRlX2lwdjRfcmVhY2hhYmlsaXR5ICAgKnRlX2lwdjRfcmVhY2g7CiNpZmRlZiBIQVZFX0lQVjYKICBzdHJ1Y3QgaW42X2FkZHIgICAgICAgICAgICAgICAgICAgKmlwdjZfYWRkcjsKICBzdHJ1Y3QgaXB2Nl9yZWFjaGFiaWxpdHkgICAgICAgICAqaXB2Nl9yZWFjaDsKICBpbnQgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJlZml4X29jdGV0czsKI2VuZGlmIC8qIEhBVkVfSVBWNiAqLwogIHVfY2hhciAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aXJ0dWFsOwogIGludCAgICAgICAgICAgICAgdmFsdWVfbGVuLCByZXR2YWwgPSBJU0lTX09LOwogIHVfY2hhciAgICAgICAgICAgICAgICAgICAqcG50ID0gc3RyZWFtOwoKICAqZm91bmQgPSAwOwogIG1lbXNldCAodGx2cywgMCwgc2l6ZW9mIChzdHJ1Y3QgdGx2cykpOwogIAogIHdoaWxlIChwbnQgPCBzdHJlYW0gKyBzaXplIC0gMikgewogICAgdHlwZSA9ICpwbnQ7CiAgICBsZW5ndGggPSAqKHBudCsxKTsKICAgIHBudCArPSAyOwogICAgdmFsdWVfbGVuID0gMDsKICAgIGlmICggcG50ICsgbGVuZ3RoID4gc3RyZWFtICsgc2l6ZSApIHsKICAgICAgemxvZ193YXJuICgiSVNJUy1UTFYgKCVzKTogVExWICh0eXBlICVkLCBsZW5ndGggJWQpIGV4Y2VlZHMgcGFja2V0ICIKCQkgImJvdW5kYXJpZXMiLCBhcmVhdGFnLCB0eXBlLCBsZW5ndGgpOwogICAgICByZXR2YWwgPSBJU0lTX1dBUk5JTkc7CiAgICAgIGJyZWFrOwogICAgfQogICAgc3dpdGNoICh0eXBlKSB7CiAgICBjYXNlIEFSRUFfQUREUkVTU0VTOgogICAgICAvKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwogICAgICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgQWRkcmVzcyBMZW5ndGggICAgICAgICAgICAgICAgICAgICAgICAgfCAKICAgICAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKICAgICAgICogfCAgICAgICAgICAgICAgICAgICAgICAgICBBcmVhIEFkZHJlc3MgICAgICAgICAgICAgICAgICAgICAgICAgIHwgCiAgICAgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCiAgICAgICAqIDogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6CiAgICAgICAqLwogICAgICAqZm91bmQgfD0gVExWRkxBR19BUkVBX0FERFJTOwojaWZkZWYgRVhUUkVNRV9UTFZfREVCVUcKICAgICAgemxvZ19pbmZvICgiVExWIEFyZWEgQWRyZXNzZXMgbGVuICVkIiwgbGVuZ3RoKTsKI2VuZGlmIC8qIEVYVFJFTUVfVExWX0RFQlVHICovCiAgICAgIGlmICgqZXhwZWN0ZWQgJiBUTFZGTEFHX0FSRUFfQUREUlMpIHsKICAgICAgICB3aGlsZSAobGVuZ3RoID4gdmFsdWVfbGVuKSB7CiAgICAgICAgICBhcmVhX2FkZHIgPSAoc3RydWN0IGFyZWFfYWRkciopcG50OwogICAgICAgICAgdmFsdWVfbGVuICs9IGFyZWFfYWRkci0+YWRkcl9sZW4gKyAxOwogICAgICAgICAgcG50ICs9ICBhcmVhX2FkZHItPmFkZH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tLS0tKy0tLS0tLS0rCiAgICAgICAqIHwgICAwICAgfCAgSS9FICB8ICAgICAgICAgICAgICAgRGVmYXVsdCBNZXRyaWMgICAgICAgICAgICAgICAgICB8IAogICAgICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwogICAgICAgKiB8ICAgUyAgIHwgIEkvRSAgfCAgICAgICAgICAgICAgIERlbGF5IE1ldHJpYyAgICAgICAgICAgICAgICAgICAgfAogICAgICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwogICAgICAgKiB8ICAgUyAgIHwgIEkvRSAgfCAgICAgICAgICAgICAgIEV4cGVuc2UgTWV0cmljICAgICAgICAgICAgICAgICAgfAogICAgICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwogICAgICAgKiB8ICAgUyAgIHwgIEkvRSAgfCAgICAgICAgICAgICAgIEVycm9yIE1ldHJpYyAgICAgICAgICAgICAgICAgICAgfAogICAgICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwogICAgICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgTmVpZ2hib3VyIElEICAgICAgICAgICAgICAgICAgICAgICAgICAgfAogICAgICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwogICAgICAgKiA6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOgogICAgICAgKi8KICAgICAgICB3aGlsZSAobGVuZ3RoID4gdmFsdWVfbGVuKSB7CiAgICAgICAgICBpc19uZWkgPSAoc3RydWN0IGlzX25laWdoKilwbnQ7CiAgICAgICAgICB2YWx1ZV9sZW4gKz0gNCArIElTSVNfU1lTX0lEX0xFTiArIDE7CiAgICAgICAgICBwbnQgKz0gNCArIElTSVNfU1lTX0lEX0xFTiArIDE7CiAgICAgICAgICBpZiAoIXRsdnMtPmlzX25laWdocykgdGx2cy0+aXNfbmVpZ2hzID0gbGlzdF9uZXcgKCk7CiAgICAgICAgICBsaXN0bm9kZV9hZGQgKHRsdnMtPmlzX25laWdocywgaXNfbmVpKTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcG50ICs9IGxlbmd0aDsKICAgICAgfQogICAgICBicmVhazsKCiAgICBjYXNlIFRFX0lTX05FSUdIQk9VUlM6CiAgICAgIC8qICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCiAgICAgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICBOZWlnaGJvdXIgSUQgICAgICAgICAgICAgICAgICAgICAgICAgICB8IDcKICAgICAgICogKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSsKICAgICAgICogfCAgICAgICAgICAgICAgICAgICAgICAgIFRFIE1ldHJpYyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgMwogICAgICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwogICAgICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgU3ViVExWcyBMZW5ndGggICAgICAgICAgICAgICAgICAgICAgICAgfCAxCiAgICAgICAqICstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS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gIGNhc2UgRVNfTkVJR0hCT1VSUzogCiAgICAgIC8qICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCiAgICAgICAqIHwgICAwICAgfCAgSS9FICB8ICAgICAgICAgICAgICAgRGVmYXVsdCBNZXRyaWMgICAgICAgICAgICAgICAgICB8IAogICAgICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwogICAgICAgKiB8ICAgUyAgIHwgIEkvRSAgfCAgICAgICAgICAgICAgIERlbGF5IE1ldHJpYyAgICAgICAgICAgICAgICAgICAgfAogICAgICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwogICAgICAgKiB8ICAgUyAgIHwgIEkvRSAgfCAgICAgICAgICAgICAgIEV4cGVuc2UgTWV0cmljICAgICAgICAgICAgICAgICAgfAogICAgICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwogICAgICAgKiB8ICAgUyAgIHwgIEkvRSAgfCAgICAgICAgICAgICAgIEVycm9yIE1ldHJpYyAgICAgICAgICAgICAgICAgICAgfAogICAgICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwogICAgICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgTmVpZ2hib3VyIElEICAgICAgICAgICAgICAgICAgICAgICAgICAgfAogICAgICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwogICAgICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgTmVpZ2hib3VyIElEICAgICAgICAgICAgICAgICAgICAgICAgICAgfAogICAgICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwogICAgICAgKiA6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOgogICAgICAgKi8KI2lmZGVmIEVYVFJFTUVfVExWX0RFQlVHCiAgICAgIHpsb2dfaW5mbyAoIklTSVMtVExWICglcyk6IEVTIE5laWdoYm91cnMgbGVuZ3RoICVkIiwKCQkgYXJlYXRhZywKCQkgbGVuZ3RoKTsKI2VuZGlmIC8qIEVYVFJFTUVfVExWX0RFQlVHICovCiAgICAgICpmb3VuZCB8PSBUTFZGTEFHX0VTX05FSUdIUzsKICAgICAgaWYgKCpleHBlY3RlZCAmIFRMVkZMQUdfRVNfTkVJR0hTKSB7CiAgICAgICAgZXNfbmVpID0gKHN0cnVjdCBlc19uZWlnaCopcG50OwogICAgICAgIHZhbHVlX2xlbiArPSA0OwogICAgICAgIHBudCArPSA0OwogICAgICAgIHdoaWxlIChsZW5ndGggPiB2YWx1ZV9sZW4pIHsKICAgICAgICAvKiBGSVhNRSBGSVhNRSBGSVhNRSAtIGFkZCB0byB0aGUgbGlzdCAqLwoJLyogICAgICAgICAgc3lzX2lkLT5pZCA9IHBudDsqLwogICAgICAgICAgdmFsdWVfbGVuICs9IElTSVNfU1lTX0lEX0xFTjsKICAgICAgICAgIHBudCArPSBJU0lTX1NZU19JRF9MRU47CiAgICAgICAgLyogIGlmICghZXNfbmVpLT5uZWlnaF9pZHMpIGVzX25laS0+bmVpZ2hfaWRzID0gc3lzaWQ7Ki8KICAgICAgICB9CiAgICAgICAgaWYgKCF0bHZzLT5lc19uZWlnaHMpIHRsdnMtPmVzX25laWdocyA9IGxpc3RfbmV3ICgpOwogICAgICAgIGxpc3Rub2RlX2FkZCAodGx2cy0+ZXNfbmVpZ2hzLCBlc19uZWkpOwogICAgICB9IGVsc2UgewogICAgICAgIHBudCArPSBsZW5ndGg7CiAgICAgIH0KICAgICAgYnJlYWs7CgogICAgY2FzZSBMQU5fTkVJR0hCT1VSUzoKICAgICAgLyogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKICAgICAgICogfCAgICAgICAgICAgICAgICAgICAgICAgIExBTiBBZGRyZXNzICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgCiAgICAgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCiAgICAgICAqIDogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6CiAgICAgICAqLwogICAgICAqZm91bmQgfD0gVExWRkxBR19MQU5fTkVJR0hTOwogICAgICAjaWZkZWYgRVhUUkVNRV9UTFZfREVCVUcKICAgICAgemxvZ19pbmZvICgiSVNJUy1UTFYgKCVzKTogTEFOIE5laWdib3VycyBsZW5ndGggJWQiLAoJCSBhcmVhdGFnLAoJCSBsZW5ndGgpOwogICAgICAjZW5kaWYgLyogRVhUUkVNRV9UTFZfREVCVUcgKi8KICAgICAgaWYgKFRMVkZMQUdfTEFOX05FSUdIUyAmICpleHBlY3RlZCkgewogICAgICAgIHdoaWxlIChsZW5ndGggPiB2YWx1ZV9sZW4pIHsKICAgICAgICAgIGxhbl9uZWkgPSAoc3RydWN0IGxhbl9uZWlnaCopcG50OwogICAgICAgICAgaWYgKCF0bHZzLT5sYW5fbmVpZ2hzKSB0bHZzLT5sYW5fbmVpZ2hzID0gbGlzdF9uZXcgKCk7CiAgICAgICAgICBsaXN0bm9kZV9hZGQgKHRsdnMtPmxhbl9uZWlnaHMsIGxhbl9uZWkpOwogICAgICAgICAgdmFsdWVfbGVuICs9IEVUSF9BTEVOOwogICAgICAgICAgcG50ICs9IEVUSF9BTEVOOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICBwbnQgKz0gbGVuZ3RoOwogICAgICB9CiAgICAgIGJyZWFrOwoKICAgIGNhc2UgUEFERElORzoKI2lmZGVmIEVYVFJFTUVfVExWX0RFQlVHCiAgICAgIHpsb2dfaW5mbyAoIlRMViBwYWRkaW5nICVkIiwgbGVuZ3RoKTsKI2VuZGlmIC8qIEVYVFJFTUVfVExWX0RFQlVHICovCiAgICAgIHBudCArPSBsZW5ndGg7CiAgICAgIGJyZWFrOwoKICAgIGNhc2UgTFNQX0VOVFJJRVM6CiAgICAgIC8qICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCiAgICAgICAqIHwgICAgICAgICAgICAgICAgICAgICBSZW1haW5pbmcgTGlmZXRpbWUgICAgICAgICAgICAgICAgICAgICAgICB8IDIKICAgICAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKICAgICAgICogfCAgICAgICAgICAgICAgICAgICAgICAgICBMU1AgSUQgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgaWQrMgogICAgICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwogICAgICAgKiB8ICAgICAgICAgICAgICAgICAgIExTUCBTZXF1ZW5jZSBOdW1iZXIgICAgICAgICAgICAgICAgICAgICAgICAgfKA0CiAgICAgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCiAgICAgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICBDaGVja3N1bSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8IDIKICAgICAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKICAgICAgICovCiNpZmRlZiBFWFRSRU1FX1RMVl9ERUJVRwogICAgICB6bG9nX2luZm8gKCJMU1AgRW50cmllcyBsZW5ndGggJWQiLAoJCSBhcmVhdGFnLAoJCSBsZW5ndGgpOwojZW5kaWYgLyogRVhUUkVNRV9UTFZfREVCVUcgKi8KICAgICAgKmZvdW5kIHw9IFRMVkZMQUdfTFNQX0VOVFJJRVM7CiAgICAgIGlmIChUTFZGTEFHX0xTUF9FTlRSSUVTICYgKmV4cGVjdGVkKSB7CiAgICAgICAgd2hpbGUgKGxlbmd0aCA+IHZhbHVlX2xlbikgewogICAgICAgICAgbHNwX2VudHJ5ID0gKHN0cnVjdCBsc3BfZW50cnkqKXBudDsKICAgICAgICAgIHZhbHVlX2xlbiArPSAxMCArIElTSVNfU1lTX0lEX0xFTjsKICAgICAgICAgIHBudCArPSAgMTAgKyBJU0lTX1NZU19JRF9MRU47CiAgICAgICAgICBpZiAoIXRsdnMtPmxzcF9lbnRyaWVzKSB0bHZzLT5sc3BfZW50cmllcyA9IGxpc3RfbmV3ICgpOwogICAgICAgICAgbGlzdG5vZGVfYWRkICh0bHZzLT5sc3BfZW50cmllcywgbHNwX2VudHJ5KTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcG50ICs9IGxlbmd0aDsKICAgICAgfQogICAgICBicmVhazsKCiAgICBjYXNlIENIRUNLU1VNOgogICAgICAvKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwogICAgICAgKiB8ICAgICAgICAgICAgICAgICAgIDE2IGJpdCBmbGV0Y2hlciBDSEVDS1NVTSAgICAgICAgICAgICAgICAgICAgfAogICAgICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwogICAgICAgKiA6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOgogICAgICAgKi8KICAgICAgKmZvdW5kIHw9IFRMVkZMQUdfQ0hFQ0tTVU07CiNpZmRlZiBFWFRSRU1FX1RMVl9ERUJVRwogICAgICB6bG9nX2luZm8gKCJJU0lTLVRMViAoJXMpOiBDaGVja3N1bSBsZW5ndGggJWQiLAoJCSBhcmVhdGFnLAoJCSBsZW5ndGgpOwojZW5kaWYgLyogRVhUUkVNRV9UTFZfREVCVUcgKi8KICAgICAgaWYgKCpleHBlY3RlZCAmIFRMVkZMQUdfQ0hFQ0tTVU0pIHsKICAgICAgICB0bHZzLT5jaGVja3N1bSA9IChzdHJ1Y3QgY2hlY2tzdW0qKXBudDsKICAgICAgfQogICAgICBwbnQgKz0gbGVuZ3RoOwogICAgICBicmVhazsKCiAgICBjYXNlIFBST1RPQ09MU19TVVBQT1JURUQ6CiAgICAgIC8qICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCiAgICAgICAqIHwgICAgICAgICAgICAgICAgICAgICAgIE5MUElEICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8CiAgICAgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCiAgICAgICAqIDogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6CiAgICAgICAqLwogICAgICAqZm91bmQgfD0gVExWRkxBR19OTFBJRDsKI2lmZGVmIEVYVFJFTUVfVExWX0RFQlVHCiAgICAgIHpsb2dfaW5mbyAoIklTSVMtVExWICglcyk6IFByb3RvY29scyBTdXBwb3J0ZWQgbGVuZ3RoICVkIiwKCQkgYXJlYXRhZywKCQkgbGVuZ3RoKTsKI2VuZGlmIC8qIEVYVFJFTUVfVExWX0RFQlVHICovCiAgICAgIGlmICgqZXhwZWN0ZWQgJiBUTFZGTEFHX05MUElEKSB7CiAgICAgICAgdGx2cy0+bmxwaWRzID0gKHN0cnVjdCBubHBpZHMqKShwbnQtMSk7CiAgICAgIH0KICAgICAgcG50ICs9IGxlbmd0aDsKICAgICAgYnJlYWs7CgogICAgY2FzZSBJUFY0X0FERFI6CiAgICAgIC8qICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCiAgICAgICAqICsgICAgICAgICAgICAgICAgIElQIHZlcnNpb24gNCBhZGRyZXNzICAgICAgICAgICAgICAgICAgICAgICAgICArIDQKICAgICAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKICAgICAgICogOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDoKICAgICAgICovCiAgICAgICpmb3VuZCB8PSBUTFZGTEFHX0lQVjRfQUREUjsKI2lmZGVmIEVYVFJFTUVfVExWX0RFQlVHCiAgICAgIHpsb2dfaW5mbyAoIklTSVMtVExWICglcyk6IElQdjQgQWRkcmVzcyBsZW5ndGggJWQiLAoJCSBhcmVhdGFnLAoJCSBsZW5ndGgpOwojZW5kaWYgLyogRVhUUkVNRV9UTFZfREVCVUcgKi8KICAgICAgaWYgKCpleHBlY3RlZCAmIFRMVkZMQUdfSVBWNF9BRERSKSB7CiAgICAgICAgd2hpbGUgKGxlbmd0a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gICB0bHZzLT5yb3V0ZXJfaWQgPSAoc3RydWN0IHRlX3JvdXRlcl9pZCopKHBudCk7CiAgICAgIH0KICAgICAgcG50ICs9IGxlbmd0aDsKICAgICAgYnJlYWs7CgogICAgY2FzZSBJUFY0X0lOVF9SRUFDSEFCSUxJVFk6CiAgICAgIC8qICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCiAgICAgICAqIHwgICAwICAgfCAgSS9FICB8ICAgICAgICAgICAgICAgRGVmYXVsdCBNZXRyaWMgICAgICAgICAgICAgICAgICB8IDEKICAgICAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKICAgICAgICogfCAgIFMgICB8ICBJL0UgIHwgICAgICAgICAgICAgICBEZWxheSBNZXRyaWMgICAgICAgICAgICAgICAgICAgIHwgMQogICAgICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwogICAgICAgKiB8ICAgUyAgIHwgIEkvRSAgfCAgICAgICAgICAgICAgIEV4cGVuc2UgTWV0cmljICAgICAgICAgICAgICAgICAgfCAxCiAgICAgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCiAgICAgICAqIHwgICBTICAgfCAgSS9FICB8ICAgICAgICAgICAgICAgRXJyb3IgTWV0cmljICAgICAgICAgICAgICAgICAgICB8IDEKICAgICAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKICAgICAgICogfCAgICAgICAgICAgICAgICAgICAgICAgIGlwIGFkZHJlc3MgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgNAogICAgICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwogICAgICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgYWRkcmVzcyBtYXNrICAgICAgICAgICAgICAgICAgICAgICAgICAgfCA0CiAgICAgICAqICstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0rCiAgICAgICAqIDogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6CiAgICAgICAqLwogICAgICAqZm91bmQgfD0gVExWRkxBR19JUFY0X0lOVF9SRUFDSEFCSUxJVFk7CiNpZmRlZiBFWFRSRU1FX1RMVl9ERUJVRwogICAgICB6bG9nX2luZm8gKCJJU0lTLVRMViAoJXMpOiBJUHY0IGludGVybmFsIFJlYWNoYWJpbGl0eSBsZW5ndGggJWQiLAoJCSBhcmVhdGFnLAoJCSBsZW5ndGgpOwojZW5kaWYgLyogRVhUUkVNRV9UTFZfREVCVUcgKi8KICAgICAgaWYgKCpleHBlY3RlZCAmIFRMVkZMQUdfSVBWNF9JTlRfUkVBQ0hBQklMSVRZKSB7CiAgICAgICAgd2hpbGUgKGxlbmd0aCA+IHZhbHVlX2xlbikgewogICAgICAgICAgaXB2NF9yZWFjaCA9IChzdHJ1Y3QgaXB2NF9yZWFjaGFiaWxpdHkqKXBudDsKICAgICAgICAgIGlmICghdGx2cy0+aXB2NF9pbnRfcmVhY2hzKSB0bHZzLT5pcHY0X2ludF9yZWFjaHMgPSBsaXN0X25ldygpOwogICAgICAgICAgbGlzdG5vZGVfYWRkICh0bHZzLT5pcHY0X2ludF9yZWFjaHMsIGlwdjRfcmVhY2gpOwogICAgICAgICAgdmFsdWVfbGVuICs9IDEyOwogICAgICAgICAgcG50ICs9IDEyOwogICAgICAgIH0KICAgICAgfQogICAgICBlbHNlIHsKICAgICAgICBwbnQgKz0gbGVuZ3RoOwogICAgICB9CiAgICAgIGJyZWFrOwoKICAgIGNhc2UgSVBWNF9FWFRfUkVBQ0hBQklMSVRZOgogICAgICAvKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwogICAgICAgKiB8ICAgMCAgIHwgIEkvRSAgfCAgICAgICAgICAgICAgIERlZmF1bHQgTWV0cmljICAgICAgICAgICAgICAgICAgfCAxCiAgICAgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCiAgICAgICAqIHwgICBTICAgfCAgSS9FICB8ICAgICAgICAgICAgICAgRGVsYXkgTWV0cmljICAgICAgICAgICAgICAgICAgICB8IDEKICAgICAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKICAgICAgICogfCAgIFMgICB8ICBJL0UgIHwgICAgICAgICAgICAgICBFeHBlbnNlIE1ldHJpYyAgICAgICAgICAgICAgICAgIHwgMQogICAgICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwogICAgICAgKiB8ICAgUyAgIHwgIEkvRSAgfCAgICAgICAgICAgICAgIEVycm9yIE1ldHJpYyAgICAgICAgICAgICAgICAgICAgfCAxCiAgICAgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCiAgICAgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICBpcCBhZGRyZXNzICAgICAgIC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ZV9sZW4gKz0gMTI7CiAgICAgICAgICBwbnQgKz0gMTI7CiAgICAgICAgfQogICAgICB9CiAgICAgIGVsc2UgewogICAgICAgIHBudCArPSBsZW5ndGg7CiAgICAgIH0KICAgICAgYnJlYWs7CgogICAgY2FzZSBURV9JUFY0X1JFQUNIQUJJTElUWToKICAgICAgLyogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKICAgICAgICogfCAgICAgICAgICAgICAgICAgICAgICAgIFRFIE1ldHJpYyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgNAogICAgICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwogICAgICAgKiB8ICBVL0QgIHwgc1RMVj8gfCAgICAgICAgICAgICAgIFByZWZpeCBNYXNrIExlbiAgICAgICAgICAgICAgICAgfCAxCiAgICAgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCiAgICAgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICAgICBQcmVmaXggICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8IDAtNAogICAgICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwogICAgICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgIHN1YiB0bHZzICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfAogICAgICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwogICAgICAgKiA6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA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T5jb250cm9sICYgMHgzRiktMSk+PjMpKzEpIDogMCk7CiAgICAgICAgfQogICAgICB9CiAgICAgIGVsc2UgewogICAgICAgIHBudCArPSBsZW5ndGg7CiAgICAgIH0KICAgICAgYnJlYWs7CgojaWZkZWYgIEhBVkVfSVBWNgogICAgY2FzZSBJUFY2X0FERFI6CiAgICAgIC8qICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCiAgICAgICAqICsgICAgICAgICAgICAgICAgIElQIHZlcnNpb24gNiBhZGRyZXNzICAgICAgICAgICAgICAgICAgICAgICAgICArIDE2CiAgICAgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCiAgICAgICAqIDogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6CiAgICAgICAqLwogICAgICAqZm91bmQgfD0gVExWRkxBR19JUFY2X0FERFI7CiNpZmRlZiBFWFRSRU1FX1RMVl9ERUJVRwogICAgICB6bG9nX2luZm8gKCJJU0lTLVRMViAoJXMpOiBJUHY2IEFkZHJlc3MgbGVuZ3RoICVkIiwKCQkgYXJlYXRhZywKCQkgbGVuZ3RoKTsKI2VuZGlmIC8qIEVYVFJFTUVfVExWX0RFQlVHICovCiAgICAgIGlmICgqZXhwZWN0ZWQgJiBUTFZGTEFHX0lQVjZfQUREUikgewogICAgICAgIHdoaWxlIChsZW5ndGggPiB2YWx1ZV9sZW4pIHsKICAgICAgICAgIGlwdjZfYWRkciA9IChzdHJ1Y3QgaW42X2FkZHIqKXBudDsKICAgICAgICAgIGlmICghdGx2cy0+aXB2Nl9hZGRycykgdGx2cy0+aXB2Nl9hZGRycyA9IGxpc3RfbmV3KCk7CiAgICAgICAgICBsaXN0bm9kZV9hZGQgKHRsdnMtPmlwdjZfYWRkcnMsIGlwdjZfYWRkcik7CiAgICAgICAgICB2YWx1ZV9sZW4gKz0gMTY7CiAgICAgICAgICBwbnQgKz0gMTY7CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIHBudCArPSBsZW5ndGg7CiAgICAgIH0KICAgICAgYnJlYWs7CgogICAgY2FzZSBJUFY2X1JFQUNIQUJJTElUWToKICAgICAgLyogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKICAgICAgICogfCAgICAgICAgICAgICAgICAgRGVmYXVsdCBNZXRyaWMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgNCAKICAgICAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKICAgICAgICogfCAgICAgICAgICAgICAgICAgICAgICAgIENvbnRyb2wgSW5mb3JtYW50aW9uICAgICAgICAgICAgICAgICAgIHwKICAgICAgICogKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSsKICAgICAgICogfCAgICAgICAgICAgICAgICAgICAgICAgIElQdjYgUHJlZml4IExlbmd0aCAgICAgICAgICAgICAgICAgICAgIHwtLSsKICAgICAgICogKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSsgIHwKICAgICAgICogfCAgICAgICAgICAgICAgICAgICAgICAgIElQdjYgUHJlZml4ICAgICAgICAgICAgICAgICAgICAgICAgICAgIHw8LSsKICAgICAgICogKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSsKICAgICAgICovCiAgIC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AgICAgICBFeHRlbmRlZCBMb2NhbCBDaXJjdWl0IElEICAgICAgICAgICAgICAgICAgICB8IDQKICAgICAgICogKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSsKICAgICAgICogfCAgICAgICAgICAgICAgICAgIE5laWdoYm9yIFN5c3RlbSBJRCAoSWYga25vd24pICAgICAgICAgICAgICAgIHwgMC04CiAgICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAocHJvYmFibHkgNikKICAgICAgICogKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSsKICAgICAgICogfCAgICAgICAgICAgICAgICAgIE5laWdoYm9yIExvY2FsIENpcmN1aXQgSUQgKElmIGtub3duKSAgICAgICAgIHwgNAogICAgICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwogICAgICAgKi8KICAgICAgKmZvdW5kIHw9IFRMVkZMQUdfM1dBWV9IRUxMTzsKICAgICAgaWYgKCpleHBlY3RlZCAmIFRMVkZMQUdfM1dBWV9IRUxMTykgewogICAgICAgIHdoaWxlIChsZW5ndGggPiB2YWx1ZV9sZW4pIHsKICAgICAgICAvKiBGSVhNRTogbWFrZSB0aGlzIHdvcmsgKi8KLyogICAgICAgICAgIEFkamFjZW5jeSBTdGF0ZSAob25lIG9jdGV0KToKICAgICAgICAgICAgICAwID0gVXAKICAgICAgICAgICAgICAxID0gSW5pdGlhbGl6aW5nCiAgICAgICAgICAgICAgMiA9IERvd24KICAgICAgICAgICAgRXh0ZW5kZWQgTG9jYWwgQ2lyY3VpdCBJRCAoZm91ciBvY3RldHMpCiAgICAgICAgICAgIE5laWdoYm9yIFN5c3RlbSBJRCBpZiBrbm93biAoemVybyB0byBlaWdodCBvY3RldHMpCiAgICAgICAgICAgIE5laWdoYm9yIEV4dGVuZGVkIExvY2FsIENpcmN1aXQgSUQgKGZvdXIgb2N0ZXRzLCBpZiBOZWlnaGJvcgogICAgICAgICAgICAgIFN5c3RlbSBJRCBpcyBwcmVzZW50KSAqLwogICAgICAgICAgcG50ICs9IGxlbmd0aDsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcG50ICs9IGxlbmd0aDsKICAgICAgfQoKICAgICAgYnJlYWs7CiAgICBjYXNlIEdSQUNFRlVMX1JFU1RBUlQ6CiAgICAgIC8qICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCiAgICAgICAqIHwgICAgICAgICBSZXNlcnZlZCAgICAgICAgICAgICAgICAgICAgICB8ICBTQSAgIHwgIFJBICAgfCAgUlIgICB8IDEKICAgICAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKICAgICAgICogfCAgICAgICAgICAgICAgICAgICAgICAgICAgUmVtYWluaW5nIFRpbWUgICAgICAgICAgICAgICAgICAgICAgIHwgMgogICAgICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwogICAgICAgKiB8ICAgICAgICAgICAgICAgIFJlc3RhcnRpbmcgTmVpZ2hib3IgSUQgKElmIGtub3duKSAgICAgICAgICAgICAgfCAwLTgKICAgICAgICogKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSsKICAgICAgICovCiAgICAgICpmb3VuZCB8PSBUTFZGTEFHX0dSQUNFRlVMX1JFU1RBUlQ7CiA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