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