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qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKiC6r8r9w/uzxqO6IHNldF9wc3dhbnN0YXRlCioguabE3MPoyvajuiDJ6NbDcHPN+MLnyeixuElQdjbXtMysTlbWtQoqILLOyv3LtcP3o7ogY19pZChJTikgOlBEULyku+61xGNfaWQKKiAgICAgICAgICAgIHN0YXRlKElOKTrN+MLnyeixuNe0zKwKKiC3tSC72CDWtaO6CiogxuTL/Mu1w/ejugoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KCnN0YXRpYyB2b2lkIHNldF9wc3dhbl92NnN0YXRlKGludCBjX2lkLCBpbnQgc3RhdGUpCnsKCWNoYXIgcHNfd2FuW05WX05BTUVfTEVOXSA9IHswfTsKCWNoYXIgcHN3YW5fc3RhdGVbTkVUSUZfTkFNRV9MRU5dID0gezB9OwoKCXNjX2NmZ19nZXQoInBzd2FuIiwgcHNfd2FuLCBzaXplb2YocHNfd2FuKSk7CgoJc25wcmludGYocHN3YW5fc3RhdGUsIHNpemVvZihwc3dhbl9zdGF0ZSksICIlcyVkX2lwdjZfc3RhdGUiLCBwc193YW4sIGNfaWQpOwoKCWlmIChzdGF0ZSA9PSBERVZfU1RBVEVfV09SS0lORykgewoJCXNjX2NmZ19zZXQocHN3YW5fc3RhdGUsICJ3b3JraW5nIik7CgkJcmV0dXJuOwoJfQoKCWlmIChzdGF0ZSA9PSBERVZfU1RBVEVfQ09OTkVDVCkgewoJCXNjX2NmZ19zZXQocHN3YW5fc3RhdGUsICJjb25uZWN0Iik7CgkJcmV0dXJuOwoJfQoJaWYgKHN0YXRlID09IERFVl9TVEFURV9ERUFEKSB7CgkJc2NfY2ZnX3NldChwc3dhbl9zdGF0ZSwgImRlYWQiKTsKCQlyZXR1cm47Cgl9Cn0KCnN0YXRpYyBpbnQgcGRwX3N0YXRlX2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jE3MnPzeLN+Lrz1Nm199PDo6y38dTyzt63qLvxyKHN4s34v9q9+NDQwfe/2AoqICAgICAgICAgICAgICAgICDV/bOjudi7+tbY0MK/qrv6o6zWrsewyejWw7XEwfe/2NLAyLvT0NCnCioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwppbnQgdGNfY29udHJvbChzdHJ1Y3QgdGNfY29udHJvbF9pbmZvICp0Y2luZm8sIGludCBzcmNfaWQpCnsKCWludCByZXQgPSAwOwoKCXByaW50ZigibmV0YXBpOnRjX2NvbnRyb2wgc3RhcnQhIGNfaWQ6JWQsIGRvd246JXUsIHVwOiV1XG4sIHNyYzolZCBcbiIsIHRjaW5mby0+Y19pZCwgdGNpbmZvLT50Y19kb3dubGluaywgdGNpbmZvLT50Y191cGxpbmssIHNyY19pZCk7CgoJcmV0ID0gaXBjX3NlbmRfbWVzc2FnZShzcmNfaWQsIE1PRFVMRV9JRF9NQUlOX0NUUkwsIE1TR19DTURfTkVUX1RDX0NUUkwsIHNpemVvZihzdHJ1Y3QgdGNfY29udHJvbF9pbmZvKSwgKFVDSEFSICopdGNpbmZvLCAwKTsKCWlmICgwICE9IHJldCkgewoJCXNvZnRhcF9hc3NlcnQoInNlbmQgbXNnIHRvIHp0ZV9yb3V0ZXIgZXJyb3IiKTsKCQlyZXR1cm4gMDsKCX0KCXJldHVybiAxOwp9CgojZGVmaW5lIFNJT0NERVZQUklWQVRFIDBYODlGMAojZGVmaW5lIFNJT0NWTEFOCQlTSU9DREVWUFJJVkFURSsweDAJCgovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKiC6r8r9w/uzxqO6IHNldF9ldGh3YW5fbW9kZQoqILmmxNzD6Mr2o7ogyejWw3N3aXRjaMnosbhldGgwLjIwMM34v9q21NOmtcRwb3J0M86qd2Fuv9q7ucrHbGF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