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WVvdXQiLCBDTURJTkZPKENVUlJFTlRfU0MpKTsKCQkJCWRpc3BfcG9ydHMoc2hwbnQpOwoJCQkJYnJlYWs7CgkJCX0KCgkJCWZpZm9kYXRhID0gR0VUUE9SVChGSUZPU1RBVCk7CgkJfQoKCQlpZihDVVJSRU5UX1NDLT5TQ3AudGhpc19yZXNpZHVhbD4wKSB7CgkJCXdoaWxlKGZpZm9kYXRhPjAgJiYgQ1VSUkVOVF9TQy0+U0NwLnRoaXNfcmVzaWR1YWw+MCkgewogICAgICAgICAgICAgICAgICAgICAgICAJZGF0YV9jb3VudCA9IGZpZm9kYXRhPkNVUlJFTlRfU0MtPlNDcC50aGlzX3Jlc2lkdWFsID8KCQkJCQkJQ1VSUkVOVF9TQy0+U0NwLnRoaXNfcmVzaWR1YWwgOgoJCQkJCQlmaWZvZGF0YTsKCQkJCWZpZm9kYXRhIC09IGRhdGFfY291bnQ7CgogICAgICAgICAgICAgICAgICAgICAgICAJaWYoZGF0YV9jb3VudCAmIDEpIHsKCQkJCQlEUFJJTlRLKGRlYnVnX2RhdGFpLCBERUJVR19MRUFEICI4Yml0XG4iLCBDTURJTkZPKENVUlJFTlRfU0MpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAJU0VUUE9SVChETUFDTlRSTDAsIEVORE1BfF84QklUKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAJKkNVUlJFTlRfU0MtPlNDcC5wdHIrKyA9IEdFVFBPUlQoREFUQVBPUlQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAlDVVJSRU5UX1NDLT5TQ3AudGhpc19yZXNpZHVhbC0tOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAlEQVRBX0xFTisrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAlTRVRQT1JUKERNQUNOVFJMMCwgRU5ETUEpOwogICAgICAgICAgICAgICAgICAgICAgICAJfQoJCiAgICAgICAgICAgICAgICAgICAgICAgIAlpZihkYXRhX2NvdW50ID4gMSkgewoJCQkJCURQUklOVEsoZGVidWdfZGF0YWksIERFQlVHX0xFQUQgIjE2Yml0KCVkKVxuIiwgQ01ESU5GTyhDVVJSRU5UX1NDKSwgZGF0YV9jb3VudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCWRhdGFfY291bnQgPj49IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCWluc3coREFUQVBPUlQsIENVUlJFTlRfU0MtPlNDcC5wdHIsIGRhdGFfY291bnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAlDVVJSRU5UX1NDLT5TQ3AucHRyICAgICAgICAgICArPSAyICogZGF0YV9jb3VudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAJQ1VSUkVOVF9TQy0+U0NwLnRoaXNfcmVzaWR1YWwgLT0gMiAqIGRhdGFfY291bnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCURBVEFfTEVOICAgICAgICAgICAgICAgICAgICAgICs9IDIgKiBkYXRhX2NvdW50OwogICAgICAgICAgICAgICAgICAgICAgICAJfQoJCiAgICAgICAgICAgICAgICAgICAgICAgIAlpZihDVVJSRU5UX1NDLT5TQ3AudGhpc19yZXNpZHVhbD09MCAmJiBDVVJSRU5UX1NDLT5TQ3AuYnVmZmVyc19yZXNpZHVhbD4wKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAJCS8qIGFkdmFuY2UgdG8gbmV4dCBidWZmZXIgKi8KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAkJQ1VSUkVOVF9TQy0+U0NwLmJ1ZmZlcnNfcmVzaWR1YWwtLTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAkJQ1VSUkVOVF9TQy0+U0NwLmJ1ZmZlcisrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCQlDVVJSRU5UX1NDLT5TQ3AucHRyICAgICAgICAgICA9IFNHX0FERFJFU1M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TsgIiwgcyAmIChTRlVMTCB8IFNGQ05UKSk7CgoJcyA9IEdFVFBPUlQoU1NUQVQzKTsKCXByaW50aygiU0NTSUNOVCAoJWQpLCBPRkZDTlQoJWQpLCAiLCAocyAmIDB4ZjApID4+IDQsIHMgJiAweDBmKTsKCglwcmludGsoIlNTVEFUNCggIik7CglzID0gR0VUUE9SVChTU1RBVDQpOwoJaWYgKHMgJiBTWU5DRVJSKQoJCXByaW50aygiU1lOQ0VSUiAiKTsKCWlmIChzICYgRldFUlIpCgkJcHJpbnRrKCJGV0VSUiAiKTsKCWlmIChzICYgRlJFUlIpCgkJcHJpbnRrKCJGUkVSUiAiKTsKCXByaW50aygiKTsgIik7CgoJcHJpbnRrKCJETUFDTlRSTDAoICIpOwoJcyA9IEdFVFBPUlQoRE1BQ05UUkwwKTsKCXByaW50aygiJXMgIiwgcyAmIF84QklUID8gIjhCSVQiIDogIjE2QklUIik7CglwcmludGsoIiVzICIsIHMgJiBETUEgPyAiRE1BIiA6ICJQSU8iKTsKCXByaW50aygiJXMgIiwgcyAmIFdSSVRFX1JFQUQgPyAiV1JJVEUiIDogIlJFQUQiKTsKCWlmIChzICYgRU5ETUEpCgkJcHJpbnRrKCJFTkRNQSAiKTsKCWlmIChzICYgSU5URU4pCgkJcHJpbnRrKCJJTlRFTiAiKTsKCWlmIChzICYgUlNURklGTykKCQlwcmludGsoIlJTVEZJRk8gIik7CglpZiAocyAmIFNXSU5UKQoJCXByaW50aygiU1dJTlQgIik7CglwcmludGsoIik7ICIpOwoKCXByaW50aygiRE1BU1RBVCggIik7CglzID0gR0VUUE9SVChETUFTVEFUKTsKCWlmIChzICYgQVRET05FKQoJCXByaW50aygiQVRET05FICIpOwoJaWYgKHMgJiBXT1JEUkRZKQoJCXByaW50aygiV09SRFJEWSAiKTsKCWlmIChzICYgREZJRk9GVUxMKQoJCXByaW50aygiREZJRk9GVUxMICIpOwoJaWYgKHMgJiBERklGT0VNUCkKCQlwcmludGsoIkRGSUZPRU1QIC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