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yICovCgkJCWRmLT56YVtkZi0+ZjIgJiBEX0ZSRUdfTUFTS10uejIgPSAoenAtPnoyICsgdG90YWwpICYgKERfRklGT19TSVpFIC0gMSk7CgoJCQlza2JfcXVldWVfdGFpbCgmY3MtPnJxLCBza2IpOwoJCQlzY2hlZF9ldmVudF9EX3BjaShjcywgRF9SQ1ZCVUZSRUFEWSk7CgkJfSBlbHNlCgkJCXByaW50ayhLRVJOX1dBUk5JTkcgIkhGQy1QQ0k6IEQgcmVjZWl2ZSBvdXQgb2YgbWVtb3J5XG4iKTsKCX0KCXRlc3RfYW5kX2NsZWFyX2JpdChGTEdfTE9DS19BVE9NSUMsICZjcy0+SFdfRmxhZ3MpOwoJcmV0dXJuICgxKTsKfQoKLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qIGNoZWNrIGZvciB0cmFuc3BhcmVudCByZWNlaXZlIGRhdGEgYW5kIHJlYWQgbWF4IG9uZSB0aHJlc2hvbGQgc2l6ZSBpZiBhdmFpbCAqLwovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8Kc3RhdGljIGludApoZmNwY2lfZW1wdHlfZmlmb190cmFucyhzdHJ1Y3QgQkNTdGF0ZSAqYmNzLCBiemZpZm9fdHlwZSAqIGJ6LCB1X2NoYXIgKiBiZGF0YSkKewoJdW5zaWduZWQgc2hvcnQgKnoxciwgKnoycjsKCWludCBuZXdfejIsIGZjbnQsIG1heGxlbjsKCXN0cnVjdCBza19idWZmICpza2I7Cgl1X2NoYXIgKnB0ciwgKnB0cjE7CgoJejFyID0gJmJ6LT56YVtNQVhfQl9GUkFNRVNdLnoxOwkJLyogcG9pbnRlciB0byB6IHJlZyAqLwoJejJyID0gejFyICsgMTsKCglpZiAoIShmY250ID0gKnoxciAtICp6MnIpKQoJCXJldHVybiA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