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V0cmljICAgICAgICAgICAgICAgICAgICB8CgkgICAgICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgICAgICogfCAgIFMgICB8ICBJL0UgIHwgICAgICAgICAgICAgICBFeHBlbnNlIE1ldHJpYyAgICAgICAgICAgICAgICAgIHwKCSAgICAgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAgICAgKiB8ICAgUyAgIHwgIEkvRSAgfCAgICAgICAgICAgICAgIEVycm9yIE1ldHJpYyAgICAgICAgICAgICAgICAgICAgfAoJICAgICAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICAgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICBOZWlnaGJvdXIgSUQgICAgICAgICAgICAgICAgICAgICAgICAgICB8CgkgICAgICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwoJICAgICAgICogOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDoKCSAgICAgICAqLwoJICAgICAgd2hpbGUgKGxlbmd0aCA+IHZhbHVlX2xlbikKCQl7CgkJICBpc19uZWkgPSAoc3RydWN0IGlzX25laWdoICopIHBudDsKCQkgIHZhbHVlX2xlbiArPSA0ICsgSVNJU19TWVNfSURfTEVOICsgMTsKCQkgIHBudCArPSA0ICsgSVNJU19TWVNfSURfTEVOICsgMTsKCQkgIGlmICghdGx2cy0+aXNfbmVpZ2hzKQoJCSAgICB0bHZzLT5pc19uZWlnaHMgPSBsaXN0X25ldyAoKTsKCQkgIGxpc3Rub2RlX2FkZCAodGx2cy0+aXNfbmVpZ2hzLCBpc19uZWkpOwoJCX0KCSAgICB9CgkgIGVsc2UKCSAgICB7CgkgICAgICBwbnQgKz0gbGVuZ3RoOwoJICAgIH0KCSAgYnJlYWs7CgoJY2FzZSBURV9JU19ORUlHSEJPVVJTOgoJICAvKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgTmVpZ2hib3VyIElEICAgICAgICAgICAgICAgICAgICAgICAgICAgfCA3CgkgICAqICstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0rCgkgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICBURSBNZXRyaWMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8IDMKCSAgICogKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSsKCSAgICogfCAgICAgICAgICAgICAgICAgICAgICAgIFN1YlRMVnMgTGVuZ3RoICAgICAgICAgICAgICAgICAgICAgICAgIHwgMQoJICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwoJICAgKiA6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOgoJICAgKi8KCSAgKmZvdW5kIHw9IFRMVkZMQUdfVEVfSVNfTkVJR0hTOwojaWZkZWYgRVhUUkVNRV9UTFZfREVCVUcKCSAgemxvZ19kZWJ1ZyAoIklTSVMtVExWICglcyk6IEV4dGVuZGVkIElTIE5laWdoYm91cnMgbGVuZ3RoICV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ICAgICAgICAgRGVsYXkgTWV0cmljICAgICAgICAgICAgICAgICAgICB8CgkgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqIHwgICBTICAgfCAgSS9FICB8ICAgICAgICAgICAgICAgRXhwZW5zZSBNZXRyaWMgICAgICAgICAgICAgICAgICB8CgkgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqIHwgICBTICAgfCAgSS9FICB8ICAgICAgICAgICAgICAgRXJyb3IgTWV0cmljICAgICAgICAgICAgICAgICAgICB8CgkgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICBOZWlnaGJvdXIgSUQgICAgICAgICAgICAgICAgICAgICAgICAgICB8CgkgICAqICstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0rCgkgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICBOZWlnaGJvdXIgSUQgICAgICAgICAgICAgICAgICAgICAgICAgICB8CgkgICAqICstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0rCgkgICAqIDogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6CgkgICAqLwojaWZkZWYgRVhUUkVNRV9UTFZfREVCVUcKCSAgemxvZ19kZWJ1ZyAoIklTSVMtVExWICglcyk6IEVTIE5laWdoYm91cnMgbGVuZ3RoICVkIiwKCQkgICAgIGFyZWF0YW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S0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKiB8ICAgICAgICAgICAgICAgICAgICAgUmVtYWluaW5nIExpZmV0aW1lICAgICAgICAgICAgICAgICAgICAgICAgfCAyCgkgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICAgTFNQIElEICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8IGlkKzIKCSAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICogfCAgICAgICAgICAgICAgICAgICBMU1AgU2VxdWVuY2UgTnVtYmVyICAgICAgICAgICAgICAgICAgICAgICAgIHygNAoJICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgQ2hlY2tzdW0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfCAyCgkgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqLwojaWZkZWYgRVhUUkVNRV9UTFZfREVCVUcKCSAgemxvZ19kZWJ1ZyAoIklTSVMtVExWICglcyk6IExTUCBFbnRyaWVzIGxlbmd0aCAlZCIsIGFyZWF0YWcsIGxlbmd0aCk7CiNlbmRpZiAvKiBFWFRSRU1FX1RMVl9ERUJVRyAqLwoJICAqZm91bmQgfD0gVExWRkxBR19MU1BfRU5UUklFUzsKCSAgaWYgKFRMVkZMQUdfTFNQX0VOVFJJRVMgJiAqZXhwZWN0ZWQpCgkgICAgewoJICAgICAgd2hpbGUgKGxl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tLSsKCSAgICogfCAgIFMgICB8ICBJL0UgIHwgICAgICAgICAgICAgICBEZWxheSBNZXRyaWMgICAgICAgICAgICAgICAgICAgIHwgMQoJICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKiB8ICAgUyAgIHwgIEkvRSAgfCAgICAgICAgICAgICAgIEV4cGVuc2UgTWV0cmljICAgICAgICAgICAgICAgICAgfCAxCgkgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqIHwgICBTICAgfCAgSS9FICB8ICAgICAgICAgICAgICAgRXJyb3IgTWV0cmljICAgICAgICAgICAgICAgICAgICB8IDEKCSAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICogfCAgICAgICAgICAgICAgICAgICAgICAgIGlwIGFkZHJlc3MgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgNAoJICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwoJICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgYWRkcmVzcyBtYXNrICAgICAgICAgICAgICAgICAgICAgICAgICAgfCA0CgkgICAqICstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0rCgkgICAqIDogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6CgkgICAqLwoJICAqZm91bmQgfD0gVExWRkxBR19JUFY0X0lOVF9SRUFDSEFCSUxJVFk7CiNpZmRl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ZWxheSBNZXRyaWMgICAgICAgICAgICAgICAgICAgIHwgMQoJICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKiB8ICAgUyAgIHwgIEkvRSAgfCAgICAgICAgICAgICAgIEV4cGVuc2UgTWV0cmljICAgICAgICAgICAgICAgICAgfCAxCgkgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqIHwgICBTICAgfCAgSS9FICB8ICAgICAgICAgICAgICAgRXJyb3IgTWV0cmljICAgICAgICAgICAgICAgICAgICB8IDEKCSAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICogfCAgICAgICAgICAgICAgICAgICAgICAgIGlwIGFkZHJlc3MgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgNAoJICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwoJICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgYWRkcmVzcyBtYXNrICAgICAgICAgICAgICAgICAgICAgICAgICAgfCA0CgkgICAqICstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0rCgkgICAqIDogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6CgkgICAqLwoJICAqZm91bmQgfD0gVExWRkxBR19JUFY0X0VYVF9SRUFDSEFCSUxJVFk7CiNpZmRlZiBFWFRSRU1FX1RMVl9ERUJVRwoJICB6bG9nX2RlYnVnICgiSVN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