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9scyIgY29tcGF0aWJpbGl0eSBjb2RlIHdpbGwgZXhwb3J0IHRoZXNlIHN5bWJvbHMgbGF0ZXIuCgkgKi8KCXVzZV9rc3ltdGFiID0gb2JqX2ZpbmRfc2VjdGlvbihmLCAiX19rc3ltdGFiIikgfHwgZmxhZ19ub2V4cG9ydDsKCglzZWMgPSBvYmpfZmluZF9zZWN0aW9uKGYsICIudGhpcyIpOwoJaWYgKHNlYykgewoJCS8qIHRhZyB0aGUgbW9kdWxlIGhlYWRlciB3aXRoIHRoZSBvYmplY3QgbmFtZSwgbGFzdCBtb2RpZmllZAoJCSAqIHRpbWVzdGFtcCBhbmQgbW9kdWxlIHZlcnNpb24uICB3b3JzdCBjYXNlIGZvciBtb2R1bGUgdmVyc2lvbgoJCSAqIGlzIDB4ZmZmZmZmLCBkZWNpbWFsIDE2Nzc3MjE1LiAgcHV0dGluZyBhbGwgdGhyZWUgZmllbGRzIGluCgkJICogb25lIHN5bWJvbCBpcyBsZXNzIHJlYWRhYmxlIGJ1dCBzYXZlcyBrZXJuZWwgc3BhY2UuCgkJICovCgkJbCA9IHNpemVvZihzeW1wcmVmaXgpICsgICAgICAgICAgICAgICAgIC8qICJfX2luc21vZF8iICovCgkJCWxtX25hbWUgKyAgICAgICAgICAgICAgICAgICAgICAgLyogbW9kdWxlIG5hbWUgKi8KCQkJMiArICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiAiX08iICovCgkJCWxmaWxlbmFtZSArICAgICAgICAgICAgICAgICAgICAgLyogb2JqZWN0IGZpbGVuYW1lICovCgkJCTIgKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyogIl9NIiAqLwoJCQkyICogc2l6ZW9mKHN0YXRidWYuc3RfbXRpbWUpICsgIC8qIG10aW1lIGluIGhleCAqLwoJCQkyICsgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qICJfViIgKi8KCQkJOCArICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiB2ZXJzaW9uIGluIGRlY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