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HsiDQorCQkiXCJFSURcIjogXCIlc1wiLCINCisJCSJcIklNRUlcIjogXCIlc1wiIg0KKwkifSINCisifSI7DQorDQorc3RhdGljIGNoYXIgdHJpZ2dlcl9odHRwc191cGRhdGFbXSA9DQorInsiDQorCSJcIkhFQURcIjogeyINCisJCSJcIkFQUElEXCI6IFwiJXNcIiwiDQorCQkiXCJUSU1FXCI6IFwiJXNcIiwiDQorCQkiXCJUUkFOU0lEXCI6IFwiJXNcIiwiDQorCQkiXCJUT0tFTlwiOiBcIiVzXCIiDQorCSJ9LCINCisJIlwiQk9EWVwiOiB7Ig0KKwkJIlwiRUlEXCI6IFwiJXNcIiwiDQorCQkiXCJJTUVJXCI6IFwiJXNcIiwiDQorCQkiXCJFWEVDX1JFU1VMVFwiOiAlZCwiDQorCQkiXCJFWEVDX1JFQVNPTlwiOiBcIiVzXCIsIg0KKwkJIlwiREFUQV9JTkZPXCI6IFslc10iDQorCSJ9Ig0KKyJ9IjsNCisNCisNCitjaGFyIGdfaW1laVtNQVhfSU1FSV9MRU5dID0gezB9Ow0KKw0KKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovDQorLy8NCisvL2ltZWkNCisvLw0KKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovDQorc3RhdGljIGludCBscGFfZ2V0X2ltZWkoY2hhciAqaW1laSwgaW50IHNpemUpDQorew0KKwlpbnQgcmV0ID0gLTE7DQorCWNoYXIgdF9pbWVpW01BWF9JTUVJX0xFTl0gPSB7MH07DQorCXZvaWQgKnAyW10gPSB7dF9pbWVpfTsNCisNCisJc2NfY2ZnX2dldCAoImltZWkiLCBpbWVpLCBzaXplKTsNCisJaWYgKHN0cmxlbihpbWVpKSA8IDE1KSB7DQorCQlyZXQgPSBnZXRfbW9kZW1faW5mbygiQVQrQ0dTTlxyXG4iLCAiJXMiLCBwMik7DQorCQlpZihyZXQgPT0gMCkgew0KKwkJCXNucHJpbnRmKGltZWksIHNpemUsICIlcyIsIHRfaW1laSk7DQorCQl9DQorCQlyZXR1cm4gcmV0Ow0KKwl9DQorDQorCXJldHVybiAwOw0KK30NCisNCitzdGF0aWMgaW50IGxwYV9nZXRfaWNjaWQoY2hhciAqaWNjaWQsIGludCBzaXplKQ0KK3sNCisJaW50IHJldCA9IC0xOw0KKwljaGFyIHRfaWNjaWRbSUNDSURfTEVOKzFdID0gezB9Ow0KKwl2b2lkICpwMltdID0ge3RfaWNjaWR9Ow0KKw0KKw0KKwlyZXQgPSBnZXRfbW9kZW1faW5mbygiQVQrWklDQ0lEP1xyXG4iLCAiJXMiLCBwMik7DQorCWlmKHJldCA9PSAwKSB7DQorCQlzbnByaW50ZihpY2NpZCwgc2l6ZSwgIiVzIiwgdF9pY2NpZCk7DQorCX0NCisJcmV0dXJuIHJldDsNCisNCit9DQorDQorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8NCisvLw0KKy8vdGltZQ0KKy8vDQorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8NCitzdGF0aWMgaW50IGxwYV9nZXRfdGltZShjaGFyICp0aW1lLCBpbnQgc2l6ZSkNCit7DQorCXN0cnVjdCB0bSBwdG0gPSB7MH07CQ0KKwlzdHJ1Y3QgdGltZXZhbCBub3dfdGltZSA9IHswfTsNCisJDQorCWdldHRpbWVvZmRheSgmbm93X3RpbWUsIE5VTEwpOw0KKwlsb2NhbHRpbWVfcigmbm93X3RpbWUudHZfc2VjLCAmcHRtKTsNCisNCisJc25wcmludGYodGltZSwgc2l6ZSwgIiVkLSUwMmQtJTAyZCAlMDJkOiUwMmQ6JTAyZCAlMDNkIiwgDQorCQlwdG0udG1feWVhciArIDE5MDAsIHB0bS50bV9tb24gKyAxLCBwdG0udG1fbWRheSwgcHR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VyX2ljY2lkKTsNCisJfQ0KKw0KKwlyZXR1cm4gLTE7DQorfQ0KKw0KKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovDQorLy8NCisvLw0KKy8vDQorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8NCitzdGF0aWMgY2hhciAqbHBhX3BhcnNlX3RyaWdnZXJfcmVzcChjaGFyICpzcmNTdHIsIGludCAqbmV4dF9zdGVwKQ0KK3sNCisJY0pTT04gKnJvb3QgPSBOVUxMOw0KKwljSlNPTiAqb2JqZWN0ID0gTlVMTDsNCisJY0pTT04gKm9iamVjdDIgPSBOVUxMOw0KKwljSlNPTiAqYXJyYXkgPSBOVUxMOw0KKwljaGFyICphY2NvZGVfYXBkdSA9IE5VTEw7DQorDQorCXJvb3QgPSBjSlNPTl9QYXJzZShzcmNTdHIpOw0KKwlpZiAocm9vdCA9PSBOVUxMKSB7DQorCQlwcmludGYoInJvb3QgPT0gTlVMTFxuIik7DQorCQlyZXR1cm4gTlVMTDsNCisJfQ0KKw0KKwlvYmplY3QgPSBjSlNPTl9HZXRPYmplY3RJdGVtKHJvb3QsICJCT0RZIik7DQorCWlmIChvYmplY3QgPT0gTlVMTCkgew0KKwkJcHJpbnRmKCJCT0RZIG5vdCBmaW5kXG4iKTsNCisJCWNKU09OX0RlbGV0ZShyb290KTsNCisJCXJldHVybiBOVUxMOw0KKwl9DQorDQorCW9iamVjdDIgPSBjSlNPTl9HZXRPYmplY3RJdGVtKG9iamVjdCwgIk5FWFRfU1RFUCIpOw0KKwlpZiAob2JqZWN0MiA9PSBOVUxMKSB7DQorCQlwcmludGYoIk5FWFRfU1RFUCBub3QgZmluZFxuIik7DQorCQljSlNPTl9EZWxldGUocm9vdCk7DQorCQlyZXR1cm4gTlVMTDsNCisJfQ0KKwlwcmludGYoIk5FWFRfU1RFUDolZFxuIiwgb2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JCQlmcmVlKGh0dHBzX3JlcSk7DQorCQkJcHJpbnRmKCJbdHJpZ2dlcl0gaHR0cHNfcmVzcF9jb250IE5VTEwuXG4iKTsNCisJCQlyZXR1cm4gTlVMTDsNCisJCX0NCisNCisJCW1lbXNldChodHRwc19yZXNwLCAwLCBjb250X2xlbiArIDEpOw0KKwkJcmV0ID0gaHR0cHNfcmVhZF9jb250ZW50KCZodHRwc19jdCwgaHR0cHNfcmVzcCwgY29udF9sZW4pOw0KKwkJaWYoY29udF9sZW4gPT0gcmV0KQ0KKwkJew0KKwkJCWh0dHBzX3Jlc3BbcmV0XSA9ICdcMCc7CS8v19a3+7SuveHK+LHqyrYNCisJCQlwcmludGYoIlt0cmlnZ2VyXSBodHRwc193cml0ZSBodHRwc19yZXNwX2NvbnRlbnQgPSBcbiAlcy5cbiIsIGh0dHBzX3Jlc3ApOw0KKwkJfQ0KKwl9DQorCQ0KKwlodHRwc191bmluaXQoJmh0dHBzX2N0KTsNCisJZnJlZShodHRwc19yZXEpOw0KKwlyZXR1cm4gaHR0cHNfcmVzcDsNCit9DQorDQorLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8NCisvLw0KKy8vtNO0pbeit/7O8cb3sunRr9a4we4NCisvLw0KKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovDQorY2hhciAqbHBhX3RyaWdnZXJfZXZlbnQoaW50ICpuZXh0X3N0ZXApDQorew0KKwljaGFyICp0cmlnZ2VyX2RhdGEgPSBOVUxMOw0KKwljaGFyICpodHRwc19yZXNwX2NvbnQgPSBOVUxMOw0KKwljaGFyICpjb21tYW5kID0gTlVMTDsNCisJY2hhciB0cmlnZ2VyX2V2ZW50W01BWF9VUkxfTEVOXSA9IHswfTsNCisNCisJdHJpZ2dlcl9kYXRhID0gbHBhX2dldF90cmlnZ2VyX2RhdGEoKTsNCisJaWYg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