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SstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICAgICAqIHwgICBTICAgfCAgSS9FICB8ICAgICAgICAgICAgICAgRXhwZW5zZSBNZXRyaWMgICAgICAgICAgICAgICAgICB8CgkgICAgICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgICAgICogfCAgIFMgICB8ICBJL0UgIHwgICAgICAgICAgICAgICBFcnJvciBNZXRyaWMgICAgICAgICAgICAgICAgICAgIHwKCSAgICAgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAgICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgTmVpZ2hib3VyIElEICAgICAgICAgICAgICAgICAgICAgICAgICAgfAoJICAgICAgICogKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSsKCSAgICAgICAqIDogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6CgkgICAgICAgKi8KCSAgICAgIHdoaWxlIChsZW5ndGggPiB2YWx1ZV9sZW4pCgkJewoJCSAgaXNfbmVpID0gKHN0cnVjdCBpc19uZWlnaCAqKSBwbnQ7CgkJICB2YWx1ZV9sZW4gKz0gNCArIElTSVNfU1lTX0lEX0xFTiArIDE7CgkJICBwbnQgKz0gNCArIElTSVNfU1lTX0lEX0xFTiArIDE7CgkJICBpZiAoIXRsdnMtPmlzX25laWdocykKCQkgICAgdGx2cy0+aXNfbmVpZ2hzID0gbGlzdF9uZXcgKCk7CgkJICBsaXN0bm9kZV9hZGQgKHRsdnMtPmlzX25laWdocywgaXNfbmVpKTsKCQl9CgkgICAgfQoJICBlbHNlCgkgICAgewoJICAgICAgcG50ICs9IGxlbmd0aDsKCSAgICB9CgkgIGJyZWFrOwoKCWNhc2UgVEVfSVNfTkVJR0hCT1VSUzoKCSAgLyogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICogfCAgICAgICAgICAgICAgICAgICAgICAgIE5laWdoYm91ciBJRCAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgNwoJICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwoJICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgVEUgTWV0cmljICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfCAzCgkgICAqICstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0rCgkgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICBTdWJUTFZzIExlbmd0aCAgICAgICAgICAgICAgICAgICAgICAgICB8IDEKCSAgICogKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSsKCSAgICogOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDoKCSAgICovCgkgICpmb3VuZCB8PSBUTFZGTEFHX1RFX0lTX05FSUdIUzsKI2lmZGVmIEVYVFJFTUVfVExWX0RFQlVHCgkgIHpsb2dfZGVidWcgKCJJU0lTLVRMViAoJXMpOiBFeHRlbmRlZCBJUyBOZWlnaGJvdXJzIGxlbmd0aCAlZCIsCgkJICAgICBhcmVhdGFnLCBsZW5ndGgpOwojZW5kaWYgLyogRVhUUkVNRV9UTFZfREVCVUcgKi8KCSAgaWYgKFRMVkZMQ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tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKiB8ICAgUyAgIHwgIEkvRSAgfCAgICAgICAgICAgICAgIEV4cGVuc2UgTWV0cmljICAgICAgICAgICAgICAgICAgfAoJICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKiB8ICAgUyAgIHwgIEkvRSAgfCAgICAgICAgICAgICAgIEVycm9yIE1ldHJpYyAgICAgICAgICAgICAgICAgICAgfAoJICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgTmVpZ2hib3VyIElEICAgICAgICAgICAgICAgICAgICAgICAgICAgfAoJICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwoJICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgTmVpZ2hib3VyIElEICAgICAgICAgICAgICAgICAgICAgICAgICAgfAoJICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwoJICAgKiA6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOgoJICAgKi8KI2lmZGVmIEVYVFJFTUVfVExWX0RFQlVHCgkgIHpsb2dfZGVidWcgKCJJU0lTLVRMViAoJXMpOiBFUyBOZWlnaGJvdXJzIGxlbmd0aCAlZCIsCgkJICAgICBhcmVhdGFnLCBsZW5ndGgpOwojZW5kaWYgLyogRVhUUkVNRV9UTFZfREVCVUcgKi8KCSAgKmZvdW5kI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AgICAgICAgICAgIFJlbWFpbmluZyBMaWZldGltZSAgICAgICAgICAgICAgICAgICAgICAgIHwgMgoJICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgIExTUCBJRCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfCBpZCsyCgkgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqIHwgICAgICAgICAgICAgICAgICAgTFNQIFNlcXVlbmNlIE51bWJlciAgICAgICAgICAgICAgICAgICAgICAgICB8oDQKCSAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICogfCAgICAgICAgICAgICAgICAgICAgICAgIENoZWNrc3VtICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgMgoJICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKi8KI2lmZGVmIEVYVFJFTUVfVExWX0RFQlVHCgkgIHpsb2dfZGVidWcgKCJJU0lTLVRMViAoJXMpOiBMU1AgRW50cmllcyBsZW5ndGggJWQiLCBhcmVhdGFnLCBsZW5ndGgpOwojZW5kaWYgLyogRVhUUkVNRV9UTFZfREVCVUcgKi8KCSAgKmZvdW5kIHw9IFRMVkZMQUdfTFNQX0VOVFJJRVM7CgkgIGlmIChUTFZGTEFHX0xTUF9FTlRSSUVTICYgKmV4cGVjdGVkKQoJICAgIHsKCSAgICAgIHdoaWxlIChsZW5ndGggPiB2YWx1ZV9sZW4pCgkJewoJCSAgbHNwX2VudHJ5ID0gKHN0cn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KSBwbnQ7CgkgICAgfQoJICBwbnQgKz0gbGVuZ3RoOwoJICBicmVhazsKCgljYXNlIFBST1RPQ09MU19TVVBQT1JURUQ6CgkgIC8qICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqIHwgICAgICAgICAgICAgICAgICAgICAgIE5MUElEICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8CgkgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqIDogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6CgkgICAqLwoJICAqZm91bmQgfD0gVExWRkxBR19OTFBJRDsKI2lmZGVmIEVYVFJFTUVfVExWX0RFQlVHCgkgIHpsb2dfZGVidWcgKCJJU0lTLVRMViAoJXMpOiBQcm90b2NvbHMgU3VwcG9ydGVkIGxlbmd0aCAlZCIsCgkJICAgICAgYXJlYXRhZywgbGVuZ3RoKTsKI2VuZGlmIC8qIEVYVFJFTUVfVExWX0RFQlVHICovCgkgIGlmICgqZXhwZWN0ZWQgJiBUTFZGTEFHX05MUElEKQoJICAgIHsKCSAgICAgIHRsdnMtPm5scGlkcyA9IChzdHJ1Y3QgbmxwaWRzICopIChwbnQgLSAxKTsKCSAgICB9CgkgIHBudCArPSBsZW5ndGg7CgkgIGJyZWFrOwoKCWNhc2UgSVBWNF9BRERSOgoJICAvKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKiArICAgICAgICAgICAgICAgICBJUCB2ZXJzaW9uIDQgYWRkcmVzcyAgICAgICAgICAgICAgICAgICAgICAgICAgKyA0CgkgICAqICstLS0tLS0tKy0tLS0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WV0cmljICAgICAgICAgICAgICAgICAgICB8IDEKCSAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICogfCAgIFMgICB8ICBJL0UgIHwgICAgICAgICAgICAgICBFeHBlbnNlIE1ldHJpYyAgICAgICAgICAgICAgICAgIHwgMQoJICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKiB8ICAgUyAgIHwgIEkvRSAgfCAgICAgICAgICAgICAgIEVycm9yIE1ldHJpYyAgICAgICAgICAgICAgICAgICAgfCAxCgkgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICBpcCBhZGRyZXNzICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8IDQKCSAgICogKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSsKCSAgICogfCAgICAgICAgICAgICAgICAgICAgICAgIGFkZHJlc3MgbWFzayAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgNAoJICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwoJICAgKiA6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOgoJICAgKi8KCSAgKmZvdW5kIHw9IFRMVkZMQUdfSVBWNF9JTlRfUkVBQ0hBQklMSVRZOwojaWZkZWYgRVhUUkVNRV9UTFZfREVCVUcKCSAgemxvZ19kZWJ1ZyAoIklTS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LS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICogfCAgIFMgICB8ICBJL0UgIHwgICAgICAgICAgICAgICBFeHBlbnNlIE1ldHJpYyAgICAgICAgICAgICAgICAgIHwgMQoJICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKiB8ICAgUyAgIHwgIEkvRSAgfCAgICAgICAgICAgICAgIEVycm9yIE1ldHJpYyAgICAgICAgICAgICAgICAgICAgfCAxCgkgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICBpcCBhZGRyZXNzICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8IDQKCSAgICogKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSsKCSAgICogfCAgICAgICAgICAgICAgICAgICAgICAgIGFkZHJlc3MgbWFzayAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgNAoJICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwoJICAgKiA6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOgoJICAgKi8KCSAgKmZvdW5kIHw9IFRMVkZMQUdfSVBWNF9FWFRfUkVBQ0hBQklMSVRZOwojaWZkZWYgRVhUUkVNRV9UTFZfREVCVUcKCSAgemxvZ19kZWJ1ZyAoIklTSVMtVExWICglcyk6IElQdjQgZXh0ZXJuYWwgUmVhY2hhYmlsaXR5IGxlb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xlbikKCQl7CgkJICAvKiBGSVhNRTogbWFrZSB0aGlzIHdvcmsgKi8KLyogICAgICAgICAgIEFkamFjZW5jeSBTdGF0ZSAob25lIG9jdGV0KToKICAgICAgICAgICAgICAwID0gVXAKICAgICAgICAgICAgICAxID0gSW5pdGlhbGl6aW5nCiAgICAgICAgICAgICAgMiA9IERvd24KICAgICAgICAgICAgRXh0ZW5kZWQgTG9jYWwgQ2lyY3VpdCBJRCAoZm91ciBvY3RldHMpCiAgICAgICAgICAgIE5laWdoYm9yIFN5c3RlbSBJRCBpZiBrbm93biAoemVybyB0byBlaWdodCBvY3RldHMpCiAgICAgICAgICAgIE5laWdoYm9yIEV4dGVuZGVkIExvY2FsIENpcmN1aXQgSUQgKGZvdXIgb2N0ZXRzLCBpZiBOZWlnaGJvcgogICAgICAgICAgICAgIFN5c3RlbSBJRCBpcyBwcmVzZW50KSAqLwoJCSAgcG50ICs9IGxlbmd0aDsKCQl9CgkgICAgfQoJICBlbHNlCgkgICAgewoJICAgICAgcG50ICs9IGxlbmd0aDsKCSAgICB9CgoJICBicmVhazsKCWNhc2UgR1JBQ0VGVUxfUkVTVEFSVDoKCSAgLyogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICogfCAgICAgICAgIFJlc2VydmVkICAgICAgICAgICAgICAgICAgICAgIHwgIFNBICAgfCAgUkEgICB8ICBSUiAgIHwgMQoJICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgICBSZW1haW5pbmcgVGltZSAgICAgICAgICAgICAgICAgICAgICAgfCAyCgkgICAqICstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS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