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QpOworCQlyZXR1cm4gLTE7CisgICAgfWVsc2V7CisJCWNsb3NlKGZkKTsKKwkJdGltZSA9ICBhdG9sbChidWYpOyAKKyAgICAgICAgaWYodGltZSA8IDAgfHwgdGltZSA+IExMT05HX01BWC0xKQorICAgICAgICB7CisgICAgICAgICAgICB0aW1lICA9IDA7CisgICAgICAgIH0KKworICAgICAgICByZXR1cm4gdGltZTsKKyAgICB9CisjZWxzZQorCWlmIChyZWFkKGZkLCBidWYsIDEyNykgPiAwKSB7CisJCWNsb3NlKGZkKTsKKwkJcmV0dXJuICBhdG9sbChidWYpOworCX0gZWxzZSB7CisJCWNsb3NlKGZkKTsKKwkJcmV0dXJuIC0xOworCX0KKyNlbmRpZiAgICAKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCisqILqvyv3D+7PGo7ogc29jX3NlbmRfY29uZGl0aW9uX2NoZWNrCisqILmmxNzD6Mr2o7ogvOyy4srHt/HC+tfjU09Dz/vPoreiy83M9bz+o6zI57n7yse000FQt6LLzbW9Q1CjrNTyc3JjX2lksdjQ686qQVCy4LXEbW9kdWxlaWSjrGRzdF9pZLHY0OvOqgorKiAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZHVsZWlkOyAgyOe5+8rHtNNDULeiy821vUFQo6zU8nNyY19pZLHY0OvOqkNQsuC1xG1vZHVsZWlko6xkc3RfaWSx2NDrzqpBULLgtcRtb2R1bGVpZC4KKyogss7K/cu1w/ejunNyY19pZDrP+8+it6LLzcSjv+lJRCAgIGRlc3RfaWQ6z/vPor3TytXEo7/pSUQKKyogt7Ugu9gg1rWjuiAxOrf7us/M9bz+MDqyu7f7us/M9bz+CisqIMbky/zLtcP3o7oKKyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworc3RhdGljIGludCBzb2Nfc2VuZF9jb25k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