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