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ltYm9scyIgY29tcGF0aWJpbGl0eSBjb2RlIHdpbGwgZXhwb3J0IHRoZXNlIHN5bWJvbHMgbGF0ZXIuCgkgKi8KCXVzZV9rc3ltdGFiID0gb2JqX2ZpbmRfc2VjdGlvbihmLCAiX19rc3ltdGFiIikgfHwgZmxhZ19ub2V4cG9ydDsKCglzZWMgPSBvYmpfZmluZF9zZWN0aW9uKGYsICIudGhpcyIpOwoJaWYgKHNlYykgewoJCS8qIHRhZyB0aGUgbW9kdWxlIGhlYWRlciB3aXRoIHRoZSBvYmplY3QgbmFtZSwgbGFzdCBtb2RpZmllZAoJCSAqIHRpbWVzdGFtcCBhbmQgbW9kdWxlIHZlcnNpb24uICB3b3JzdCBjYXNlIGZvciBtb2R1bGUgdmVyc2lvbgoJCSAqIGlzIDB4ZmZmZmZmLCBkZWNpbWFsIDE2Nzc3MjE1LiAgcHV0dGluZyBhbGwgdGhyZWUgZmllbGRzIGluCgkJICogb25lIHN5bWJvbCBpcyBsZXNzIHJlYWRhYmxlIGJ1dCBzYXZlcyBrZXJuZWwgc3BhY2UuCgkJICovCgkJbCA9IHNpemVvZihzeW1wcmVmaXgpICsgICAgICAgICAgICAgICAgIC8qICJfX2luc21vZF8iICovCgkJCWxtX25hbWUgKyAgICAgICAgICAgICAgICAgICAgICAgLyogbW9kdWxlIG5hbWUgKi8KCQkJMiArICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiAiX08iICovCgkJCWxmaWxlbmFtZSArICAgICAgICAgICAgICAgICAgICAgLyogb2JqZWN0IGZpbGVuYW1lICovCgkJCTIgKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogIl9NIiAqLwoJCQkyICogc2l6ZW9mKHN0YXRidWYuc3RfbXRpbWUpICsgIC8qIG10aW1lIGluIGhleCAqLwoJCQkyICsgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qICJfViIgKi8KCQkJOCArICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiB2ZXJzaW9uIGluI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