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gICAgRGVsYXkgTWV0cmljICAgICAgICAgICAgICAgICAgICB8CgkgICAgICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgICAgICogfCAgIFMgICB8ICBJL0UgIHwgICAgICAgICAgICAgICBFeHBlbnNlIE1ldHJpYyAgICAgICAgICAgICAgICAgIHwKCSAgICAgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAgICAgKiB8ICAgUyAgIHwgIEkvRSAgfCAgICAgICAgICAgICAgIEVycm9yIE1ldHJpYyAgICAgICAgICAgICAgICAgICAgfAoJICAgICAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICAgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICBOZWlnaGJvdXIgSUQgICAgICAgICAgICAgICAgICAgICAgICAgICB8CgkgICAgICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwoJICAgICAgICogOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDoKCSAgICAgICAqLwoJICAgICAgd2hpbGUgKGxlbmd0aCA+IHZhbHVlX2xlbikKCQl7CgkJICBpc19uZWkgPSAoc3RydWN0IGlzX25laWdoICopIHBudDsKCQkgIHZhbHVlX2xlbiArPSA0ICsgSVNJU19TWVNfSURfTEVOICsgMTsKCQkgIHBudCArPSA0ICsgSVNJU19TWVNfSURfTEVOICsgMTsKCQkgIGlmICghdGx2cy0+aXNfbmVpZ2hzKQoJCSAgICB0bHZzLT5pc19uZWlnaHMgPSBsaXN0X25ldyAoKTsKCQkgIGxpc3Rub2RlX2FkZCAodGx2cy0+aXNfbmVpZ2hzLCBpc19uZWkpOwoJCX0KCSAgICB9CgkgIGVsc2UKCSAgICB7CgkgICAgICBwbnQgKz0gbGVuZ3RoOwoJICAgIH0KCSAgYnJlYWs7CgoJY2FzZSBURV9JU19ORUlHSEJPVVJTOgoJICAvKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgTmVpZ2hib3VyIElEICAgICAgICAgICAgICAgICAgICAgICAgICAgfCA3CgkgICAqICstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0rCgkgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICBURSBNZXRyaWMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8IDMKCSAgICogKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSsKCSAgICogfCAgICAgICAgICAgICAgICAgICAgICAgIFN1YlRMVnMgTGVuZ3RoICAgICAgICAgICAgICAgICAgICAgICAgIHwgMQoJICAgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKwoJICAgKiA6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOgoJICAgKi8KCSAgKmZvdW5kIHw9IFRMVkZMQUdfVEVfSVNfTkVJR0hTOwojaWZkZWYgRVhUUkVNRV9UTFZfREVCVUcKCSAgemxvZ19kZWJ1ZyAoIklTSVMtVExWICglcyk6IEV4dGVuZGVkIElTIE5laWdoYm91c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SS9FICB8ICAgICAgICAgICAgICAgRGVsYXkgTWV0cmljICAgICAgICAgICAgICAgICAgICB8CgkgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqIHwgICBTICAgfCAgSS9FICB8ICAgICAgICAgICAgICAgRXhwZW5zZSBNZXRyaWMgICAgICAgICAgICAgICAgICB8CgkgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqIHwgICBTICAgfCAgSS9FICB8ICAgICAgICAgICAgICAgRXJyb3IgTWV0cmljICAgICAgICAgICAgICAgICAgICB8CgkgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICBOZWlnaGJvdXIgSUQgICAgICAgICAgICAgICAgICAgICAgICAgICB8CgkgICAqICstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0rCgkgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICBOZWlnaGJvdXIgSUQgICAgICAgICAgICAgICAgICAgICAgICAgICB8CgkgICAqICstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0rCgkgICAqIDogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6CgkgICAqLwojaWZkZWYgRVhUUkVNRV9UTFZfREVCVUcKCSAgemxvZ19kZWJ1ZyAoIklTSVMtVExWICglcyk6IEVTIE5laWdoYm91cnMgbGVuZ3RoICVkIiwKCQk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0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKiB8ICAgICAgICAgICAgICAgICAgICAgUmVtYWluaW5nIExpZmV0aW1lICAgICAgICAgICAgICAgICAgICAgICAgfCAyCgkgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICAgTFNQIElEICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8IGlkKzIKCSAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICogfCAgICAgICAgICAgICAgICAgICBMU1AgU2VxdWVuY2UgTnVtYmVyICAgICAgICAgICAgICAgICAgICAgICAgIHygNAoJICAgKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgQ2hlY2tzdW0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfCAyCgkgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqLwojaWZkZWYgRVhUUkVNRV9UTFZfREVCVUcKCSAgemxvZ19kZWJ1ZyAoIklTSVMtVExWICglcyk6IExTUCBFbnRyaWVzIGxlbmd0aCAlZCIsIGFyZWF0YWcsIGxlbmd0aCk7CiNlbmRpZiAvKiBFWFRSRU1FX1RMVl9ERUJVRyAqLwoJICAqZm91bmQgfD0gVExWRkxBR19MU1BfRU5UUklFUzsKCSAgaWYgKFRMVkZMQUdfTFNQX0VOVFJJRVMgJiAqZXhwZWN0ZWQpCgkgICAgewoJICAgIC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GVuZ3RoOwoJICAgIH0KCSAgYnJlYWs7CgoJY2FzZSBBVVRIX0lORk86CgkgICpmb3VuZCB8PSBUTFZGTEFHX0FVVEhfSU5GTzsKI2lmZGVmIEVYVFJFTUVfVExWX0RFQlVHCgkgIHpsb2dfZGVidWcgKCJJU0lTLVRMViAoJXMpOiBJUy1JUyBBdXRoZW50aWNhdGlvbiBJbmZvcm1hdGlvbiIsCgkJICAgICAgYXJlYXRhZyk7CiNlbmRpZgoJICBpZiAoKmV4cGVjdGVkICYgVExWRkxBR19BVVRIX0lORk8pCgkgICAgewoJICAgICAgdGx2cy0+YXV0aF9pbmZvLnR5cGUgPSAqcG50OwogICAgICAgICAgICAgIGlmIChsZW5ndGggPT0gMCkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgemxvZ193YXJuICgiSVNJUy1UTFYgKCVzKTogVExWICh0eXBlICVkLCBsZW5ndGggJWQpICIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiaW5jb3JyZWN0LiIsIGFyZWF0YWcsIHR5cGUsIGxlbmd0aCk7CiAgICAgICAgICAgICAgICAgIHJldHVybiBJU0lTX1dBUk5JTkc7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgLS1sZW5ndGg7CgkgICAgICB0bHZzLT5hdXRoX2luZm8ubGVuID0gbGVuZ3RoOwoJICAgICAgcG50Kys7CgkgICAgICBtZW1jcHkgKHRsdnMtPmF1dGhfaW5mby5wYXNzd2QsIHBudCwgbGVuZ3RoKTsKICAgICAgICAgICAgICAvKiBSZXR1cm4gdGhlIGF1dGhlbnRpY2F0aW9uIHRsdiBwb3MgZm9yIGxhdGVyIGNvbXB1dGF0aW9uCiAgICAgICAgICAgICAgICogb2YgTUQ1IChSRkMgNTMwNCwgMikKICAgICAgICAgICAgICAgKi8KICAgICAgICAgICAgICBpZiAoYXV0aF90bHZfb2Zmc2V0KQogICAgICAgICAgICAgICAgKmF1dGhfdGx2X29mZnNldCArPSAocG50IC0gc3R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X3JlYWNocywgaXB2NF9yZWFjaCk7CgkJICB2YWx1ZV9sZW4gKz0gMTI7CgkJICBwbnQgKz0gMTI7CgkJfQoJICAgIH0KCSAgZWxzZQoJICAgIHsKCSAgICAgIHBudCArPSBsZW5ndGg7CgkgICAgfQoJICBicmVhazsKCgljYXNlIFRFX0lQVjRfUkVBQ0hBQklMSVRZOgoJICAvKiArLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKwoJICAgKiB8ICAgICAgICAgICAgICAgICAgICAgICAgVEUgTWV0cmljICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfCA0CgkgICAqICstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rCgkgICAqIHwgIFUvRCAgfCBzVExWPyB8ICAgICAgICAgICAgICAgUHJlZml4IE1hc2sgTGVuICAgICAgICAgICAgICAgICB8IDEKCSAgICogKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSstLS0tLS0tKy0tLS0tLS0rLS0tLS0tLSsKCSAgICogfCAgICAgICAgICAgICAgICAgICAgICAgICAgIFByZWZpeCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgMC00CgkgICAqICstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0rCgkgICAqIHwgICAgICAgICAgICAgICAgICAgICAgICAgc3ViIHRsdnMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8CgkgICAqICstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0rCgkgICAqIDogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC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