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S0tLS0rLS0tLS0tLSsKCSAgICAgICAqIHwgICBTICAgfCAgSS9FICB8ICAgICAgICAgICAgICAgRGVsYXkgTWV0cmljICAgICAgICAgICAgICAgICAgICB8CgkgICAgICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgICAgICogfCAgIFMgICB8ICBJL0UgIHwgICAgICAgICAgICAgICBFeHBlbnNlIE1ldHJpYyAgICAgICAgICAgICAgICAgIHwKCSAgICAgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAgICAgKiB8ICAgUyAgIHwgIEkvRSAgfCAgICAgICAgICAgICAgIEVycm9yIE1ldHJpYyAgICAgICAgICAgICAgICAgICAgfAoJICAgICAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICAgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICBOZWlnaGJvdXIgSUQgICAgICAgICAgICAgICAgICAgICAgICAgICB8CgkgICAgICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwoJICAgICAgICogOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDoKCSAgICAgICAqLwoJICAgICAgd2hpbGUgKGxlbmd0aCA+IHZhbHVlX2xlbikKCQl7CgkJICBpc19uZWkgPSAoc3RydWN0IGlzX25laWdoICopIHBudDsKCQkgIHZhbHVlX2xlbiArPSA0ICsgSVNJU19TWVNfSURfTEVOICsgMTsKCQkgIHBudCArPSA0ICsgSVNJU19TWVNfSURfTEVOICsgMTsKCQkg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tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICogfCAgIFMgICB8ICBJL0UgIHwgICAgICAgICAgICAgICBEZWxheSBNZXRyaWMgICAgICAgICAgICAgICAgICAgIHwKCSAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICogfCAgIFMgICB8ICBJL0UgIHwgICAgICAgICAgICAgICBFeHBlbnNlIE1ldHJpYyAgICAgICAgICAgICAgICAgIHwKCSAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICogfCAgIFMgICB8ICBJL0UgIHwgICAgICAgICAgICAgICBFcnJvciBNZXRyaWMgICAgICAgICAgICAgICAgICAgIHwKCSAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICogfCAgICAgICAgICAgICAgICAgICAgICAgIE5laWdoYm91ciBJRCAgICAgICAgICAgICAgICAgICAgICAgICAgIHwKCSAgICogKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSsKCSAgICogfCAgICAgICAgICAgICAgICAgICAgICAgIE5laWdoYm91ciBJRCAgICAgICAgICAgICAgICAgICAgICAgICAgIHwKCSAgICogKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSsKCSAgICogOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDoKCSAgICovCiNpZmRlZiBFWFRSRU1FX1RMV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SAgcG50ICs9IGxlbmd0aDsKCSAgYnJlYWs7CgoJY2FzZSBMU1BfRU5UUklFUzoKCSAgLyogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICogfCAgICAgICAgICAgICAgICAgICAgIFJlbWFpbmluZyBMaWZldGltZSAgICAgICAgICAgICAgICAgICAgICAgIHwgMgoJICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgIExTUCBJRCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfCBpZCsyCgkgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqIHwgICAgICAgICAgICAgICAgICAgTFNQIFNlcXVlbmNlIE51bWJlciAgICAgICAgICAgICAgICAgICAgICAgICB8oDQKCSAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICogfCAgICAgICAgICAgICAgICAgICAgICAgIENoZWNrc3VtICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgMgoJICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKi8KI2lmZGVmIEVYVFJFTUVfVExWX0RFQlVHCgkgIHpsb2dfaW5mbyAoIkxTUCBFbnRyaWVzIGxlbmd0aCAlZCIsIGFyZWF0YWcsIGxlbmd0aCk7CiNlbmRpZiAvKiBFWFRSRU1FX1RMVl9ERUJVRyAqLwoJICAqZm91bmQgfD0gVExWRkxB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B8IDEKCSAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICogfCAgIFMgICB8ICBJL0UgIHwgICAgICAgICAgICAgICBEZWxheSBNZXRyaWMgICAgICAgICAgICAgICAgICAgIHwgMQoJICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKiB8ICAgUyAgIHwgIEkvRSAgfCAgICAgICAgICAgICAgIEV4cGVuc2UgTWV0cmljICAgICAgICAgICAgICAgICAgfCAxCgkgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqIHwgICBTICAgfCAgSS9FICB8ICAgICAgICAgICAgICAgRXJyb3IgTWV0cmljICAgICAgICAgICAgICAgICAgICB8IDEKCSAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICogfCAgICAgICAgICAgICAgICAgICAgICAgIGlwIGFkZHJlc3MgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgNAoJICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwoJICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgYWRkcmVzcyBtYXNrICAgICAgICAgICAgICAgICAgICAgICAgICAgfCA0CgkgICAqICstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0rCgkgICAqIDogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA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S0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqIHwgICBTICAgfCAgSS9FICB8ICAgICAgICAgICAgICAgRGVsYXkgTWV0cmljICAgICAgICAgICAgICAgICAgICB8IDEKCSAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICogfCAgIFMgICB8ICBJL0UgIHwgICAgICAgICAgICAgICBFeHBlbnNlIE1ldHJpYyAgICAgICAgICAgICAgICAgIHwgMQoJICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKiB8ICAgUyAgIHwgIEkvRSAgfCAgICAgICAgICAgICAgIEVycm9yIE1ldHJpYyAgICAgICAgICAgICAgICAgICAgfCAxCgkgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICBpcCBhZGRyZXNzICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8IDQKCSAgICogKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSsKCSAgICogfCAgICAgICAgICAgICAgICAgICAgICAgIGFkZHJlc3MgbWFzayAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgNAoJICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwoJICAgKiA6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOgoJICAgKi8KCSAgKmZvdW5kIHw9IFRMVkZMQUdf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ICAgICAgICAgICAgICAgUHJlZml4IE1hc2sgTGVuICAgICAgICAgICAgICAgICB8IDEKCSAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICogfCAgICAgICAgICAgICAgICAgICAgICAgICAgIFByZWZpeCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgMC00CgkgICAqICstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0rCgkgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICAgc3ViIHRsdnMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8CgkgICAqICstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0rCgkgICAqIDogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6CgkgICAqLwoJICAqZm91bmQgfD0gVExWRkxBR19URV9JUFY0X1JFQUNIQUJJTElUWTsKI2lmZGVmIEVYVFJFTUVfVExWX0RFQlVHCgkgIHpsb2dfaW5mbyAoIklTSVMtVExWICglcyk6IElQdjQgZXh0ZW5kZWQgUmVhY2hhYmlsaXR5IGxlbmd0aCAlZCIsCgkJICAgICBhcmVhdGFnLCBsZW5ndGgpOwojZW5kaWYgLyogRVhUUkVNRV9UTFZfREVCVUcgKi8KCSAgaWYgKCpleHBlY3RlZCAmIFRMVkZMQUdfVEVfSVBWNF9SRUFDSEFCSUxJVFkpCgkgICAgewoJICAgICAgd2hpbGUgKGxlbmd0aCA+IHZhbHVlX2xlbikKCQl7CgkJICB0ZV9pcHY0X3JlYWNoID0gKHN0cnVjdCB0ZV9pcHY0X3JlYWNoYWJpbGl0eSAqKSBwbnQ7CgkJICBpZiAoIXR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