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k7CiAgICAgbUhpc3RvZ3JhbUNvdW50cyA9IHN0ZDo6bW92ZShoaXN0b2dyYW1Db3VudHMpOworICAgIG1EeW5hbWljUmFuZ2VQcm9maWxlID0gZHluYW1pY1JhbmdlUHJvZmlsZTsKKyAgICBtU3RyZWFtVXNlQ2FzZSA9IHN0cmVhbVVzZUNhc2U7CiAKICAgICByZXR1cm4gT0s7CiB9CkBAIC0xNTIsNiArMTczLDExIEBACiAgICAgICAgIHJldHVybiBlcnI7CiAgICAgfQogCisgICAgaWYgKChlcnIgPSBwYXJjZWwtPndyaXRlRmxvYXQobU1heFByZXZpZXdGcHMpKSAhPSBPSykgeworICAgICAgICBBTE9HRSgiJXM6IEZhaWxlZCB0byB3cml0ZSBzdHJlYW0gbWF4UHJldmlld0ZwcyEiLCBfX0ZVTkNUSU9OX18pOworICAgICAgICByZXR1cm4gZXJyOworICAgIH0KKwogICAgIGlmICgoZXJyID0gcGFyY2VsLT53cml0ZUludDMyKG1EYXRhU3BhY2UpKSAhPSBPSykgewogICAgICAgICBBTE9HRSgiJXM6IEZhaWxlZCB0byB3cml0ZSBzdHJlYW0gZGF0YVNwYWNlISIsIF9fRlVOQ1RJT05fXyk7CiAgICAgICAgIHJldHVybiBlcnI7CkBAIC0yMDIsNiArMjI4LDE2IEBACiAgICAgICAgIHJldHVybiBlcnI7CiAgICAgfQogCisgICAgaWYgKChlcnIgPSBwYXJjZWwtPndyaXRlSW50NjQobUR5bmFtaWNSYW5nZVByb2ZpbGUpKSAhPSBPSykgeworICAgICAgICBBTE9HRSgiJXM6IEZhaWxlZCB0byB3cml0ZSBkeW5hbWljIHJhbmdlIHByb2ZpbGUgdHlwZSIsIF9fRlVOQ1RJT05fXyk7CisgICAgICAgIHJldHVybiBlcnI7CisgICAgfQorCisgICAgaWYgKChlcnIgPSBwYXJjZWwtPndyaXRlSW50NjQobVN0cmVhbVVzZUNhc2UpKSAhPSBPSykgeworICAgICAgICBBTE9HRSgiJXM6IEZhaWxlZCB0byB3cml0ZSBzdHJlYW0gdXNlIGNhc2UhIiwgX19GVU5DVElPTl9fKTsKKyAgICAgICAgcmV0dXJuIGVycjsKKyAgICB9CisKICAgICByZXR1cm4gT0s7CiB9CiAKQEAgLTIyMywxMSArMjU5LDEzIEBACiAgICAgICAgIG1BcGlMZXZlbCgwKSwKICAgICAgICAgbUlzTmRrKGZhbHNlKSwKICAgICAgICAgbUxhdGVuY3lNcygtMSksCisgICAgICAgIG1NYXhQcmV2aWV3RnBzKDApLAogICAgICAgICBtU2Vzc2lvblR5cGUoMCksCiAgICAgICAgIG1JbnRlcm5hbFJlY29uZmlndXJlKDApLAogICAgICAgICBtUmVxdWVzdENvdW50KDApLAogICAgICAgICBtUmVzdWx0RXJyb3JDb3VudCgwKSwKLSAgICAgICAgbURldmljZUVycm9yKGZhbHNlKSB7fQorICAgICAgICBtRGV2aWNlRXJyb3IoZmFsc2UpLAorICAgICAgICBtVmlkZW9TdGFiaWxpemF0aW9uTW9kZSgtMSkge30KIAogQ2FtZXJhU2Vzc2lvblN0YXRzOjpDYW1lcmFTZXNzaW9uU3RhdHMoY29uc3QgU3RyaW5nMTYmIGNhbWVyYUlkLAogICAgICAgICBpbnQgZmFjaW5nLCBpbnQgbmV3Q2FtZXJhU3RhdGUsIGNvbnN0IFN0cmluZzE2JiBjbGllbnROYW1lLApAQCAtMjM5LDExICsyNzcsMTMgQEAKICAgICAgICAgICAgICAgICBtQXBpTGV2ZWwoYXBpTGV2ZWwpLAogICAgICAgICAgICAgICAgIG1Jc05kayhpc05kayksCiAgICAgICAgICAgICAgICAgbUxhdGVuY3lNcyhsYXRlbmN5TXMpLAorICAgICAgICAgICAgICAgIG1NYXhQcmV2aWV3RnBzKDApLAogICAgICAgICAgICAgICAgIG1TZXNzaW9uVHlwZSgwKSwKICAgICAgICAgICAgICAgICBtSW50ZXJuYWxSZWNvbmZpZ3VyZSgwKSwKICAgICAgICAgICAgICAgICBtUmVxdWVzdENvdW50KDApLAogICAgICAgICAgICAgICAgI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UlSUk9SX01PREVfQVVUTyAmJgorICAgICAgICAgICAgZW50cnlGYWNpbmcuZGF0YS51OFswXSA9PSBBTkRST0lEX0xFTlNfRkFDSU5HX0ZST05UKSB7CisgICAgICAgIG1pcnJvciA9IE5BVElWRV9XSU5ET1dfVFJBTlNGT1JNX0ZMSVBfSDsKKyAgICB9IGVsc2UgaWYgKG1pcnJvck1vZGUgPT0gT3V0cHV0Q29uZmlndXJhdGlvbjo6TUlSUk9SX01PREVfSCkgeworICAgICAgICBtaXJyb3IgPSBOQVRJVkVfV0lORE9XX1RSQU5TRk9STV9GTElQX0g7CisgICAgfSBlbHNlIGlmIChtaXJyb3JNb2RlID09IE91dHB1dENvbmZpZ3VyYXRpb246Ok1JUlJPUl9NT0RFX1YpIHsKKyAgICAgICAgbWlycm9yID0gTkFUSVZFX1dJTkRPV19UUkFOU0ZPUk1fRkxJUF9WOworICAgIH0KKwogICAgIGludCBvcmllbnRhdGlvbiA9IGVudHJ5LmRhdGEuaTMyWzBdOwotICAgIGlmICghbWlycm9yKSB7CisgICAgaWYgKG1pcnJvciA9PSAwKSB7CiAgICAgICAgIHN3aXRjaCAob3JpZW50YXRpb24pIHsKICAgICAgICAgICAgIGNhc2UgMDoKICAgICAgICAgICAgICAgICBmbGFncyA9IDA7CkBAIC03NywyNSArODcsMjUgQEAKICAgICAgICAgICAgICAgICByZXR1cm4gSU5WQUxJRF9PUEVSQVRJT047CiAgICAgICAgIH0KICAgICB9IGVsc2UgewotICAgICAgICAvLyBGcm9udCBjYW1lcmEgbmVlZHMgdG8gYmUgaG9yaXpvbnRhbGx5IGZsaXBwZWQgZm9yIG1pcnJvci1saWtlIGJlaGF2aW9yLgorICAgICAgICAvLyAtIEZyb250IGNhbWVyYSBuZWVkcyB0byBiZSBob3Jpem9udGFsbHkgZmxpcHBlZCBmb3IgbWlycm9yLWxpa2UgYmVoYXZpb3IuCisgICAgICAgIC8vIC0gQXBwbGljYXRpb24tc3BlY2lmaWVkIG1pcnJvcmluZyBuZWVkcyB0byBiZSBhcHBsaWVkLgogICAgICAgICAvLyBOb3RlOiBGbGlwcyBhcmUgYXBwbGllZCBiZWZvcmUgcm90YXRlczsgdXNpbmcgWE9SIGhlcmUgYXMgc29tZSBvZiB0aGVzZSBmbGFncyBhcmUKICAgICAgICAgLy8gY29tcG9zZWQgaW4gdGVybXMgb2Ygb3RoZXIgZmxpcC9yb3RhdGlvbiBmbGFncywgYW5kIGFyZSBub3QgYml0d2lzZS1PUmFibGUuCiAgICAgICAgIHN3aXRjaCAob3JpZW50YXRpb24pIHsKICAgICAgICAgICAgIGNhc2UgMDoKLSAgICAgICAgICAgICAgICBmbGFncyA9IE5BVElWRV9XSU5ET1dfVFJBTlNGT1JNX0ZMSVBfSDsKKyAgICAgICAgICAgICAgICBmbGFncyA9IG1pcnJvcjsKICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgOTA6Ci0gICAgICAgICAgICAgICAgZmxhZ3MgPSBOQVRJVkVfV0lORE9XX1RSQU5TRk9STV9GTElQX0ggXgorICAgICAgICAgICAgICAgIGZsYWdzID0gbWlycm9yIF4KICAgICAgICAgICAgICAgICAgICAgICAgIE5BVElWRV9XSU5ET1dfVFJBTlNGT1JNX1JPVF8yNzA7CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICBjYXNlIDE4MDoKLSAgICAgICAgICAgICAgICBmbGFncyA9IE5BVElWRV9XSU5ET1dfVFJBTlNGT1JNX0ZMSVBfSCBeCisgICAgICAgICAgICAgICAgZmxhZ3MgPSBtaXJyb3IgXgogICAgICAgICAgICAgICAgICAgICAgICAgTkFUSVZFX1dJTkRPV19UUkFOU0ZPUk1fUk9UXzE4MDsKICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgMjcwOgotICAgICAgICAgICAgICAgIGZsYWdzID0gTkFUSVZFX1dJTkRPV19UUkFOU0ZPUk1fRkxJUF9IIF4KKyAgICAgICAgICAgICAgICBmbG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NRVNUQU1QX0JBU0VfU0VOU09SID0gMSwKKyAgICAgICAgVElNRVNUQU1QX0JBU0VfTU9OT1RPTklDID0gMiwKKyAgICAgICAgVElNRVNUQU1QX0JBU0VfUkVBTFRJTUUgPSAzLAorICAgICAgICBUSU1FU1RBTVBfQkFTRV9DSE9SRU9HUkFQSEVSX1NZTkNFRCA9IDQKKyAgICB9OworICAgIGVudW0gTWlycm9yTW9kZVR5cGUgeworICAgICAgICBNSVJST1JfTU9ERV9BVVRPID0gMCwKKyAgICAgICAgTUlSUk9SX01PREVfTk9ORSA9IDEsCisgICAgICAgIE1JUlJPUl9NT0RFX0ggPSAyLAorICAgICAgICBNSVJST1JfTU9ERV9WID0gMywKKyAgICB9OworCiAgICAgY29uc3Qgc3RkOjp2ZWN0b3I8c3A8SUdyYXBoaWNCdWZmZXJQcm9kdWNlcj4+JiBnZXRHcmFwaGljQnVmZmVyUHJvZHVjZXJzKCkgY29uc3Q7CiAgICAgaW50ICAgICAgICAgICAgICAgICAgICAgICAgZ2V0Um90YXRpb24oKSBjb25zdDsKICAgICBpbnQgICAgICAgICAgICAgICAgICAgICAgICBnZXRTdXJmYWNlU2V0SUQoKSBjb25zdDsKICAgICBpbnQgICAgICAgICAgICAgICAgICAgICAgICBnZXRTdXJmYWNlVHlwZSgpIGNvbnN0OwogICAgIGludCAgICAgICAgICAgICAgICAgICAgICAgIGdldFdpZHRoKCkgY29uc3Q7CiAgICAgaW50ICAgICAgICAgICAgICAgICAgICAgICAgZ2V0SGVpZ2h0KCkgY29uc3Q7CisgICAgaW50NjRfdCAgICAgICAgICAgICAgICAgICAgZ2V0RHluYW1pY1JhbmdlUHJvZmlsZSgpIGNvbnN0OwogICAgIGJvb2wgICAgICAgICAgICAgICAgICAgICAgIGlzRGVmZXJyZWQoKSBjb25zdDsKICAgICBib29sICAgICAgICAgICAgICAgICAgICAgICBpc1NoYXJlZCgpIGNvbnN0OwogICAgIFN0cmluZzE2ICAgICAgICAgICAgICAgICAgIGdldFBoeXNpY2FsQ2FtZXJhSWQoKSBjb25zdDsKICAgICBib29sICAgICAgICAgICAgICAgICAgICAgICBpc011bHRpUmVzb2x1dGlvbigpIGNvbnN0OworICAgIGludDY0X3QgICAgICAgICAgICAgICAgICAgIGdldFN0cmVhbVVzZUNhc2UoKSBjb25zdDsKKyAgICBpbnQgICAgICAgICAgICAgICAgICAgICAgICBnZXRUaW1lc3RhbXBCYXNlKCkgY29uc3Q7CisgICAgaW50ICAgICAgICAgICAgICAgICAgICAgICAgZ2V0TWlycm9yTW9kZSgpIGNvbnN0OwogCiAgICAgLy8gc2V0IG9mIHNlbnNvciBwaXhlbCBtb2RlIHJlc29sdXRpb25zIGFsbG93ZWQge01BWF9SRVNPTFVUSU9OLCBERUZBVUxUX01PREV9OwogICAgIGNvbnN0IHN0ZDo6dmVjdG9yPGludDMyX3Q+JiAgICAgICAgICAgIGdldFNlbnNvclBpeGVsTW9kZXNVc2VkKCkgY29uc3Q7CkBAIC04OSw3ICsxMDcsMTEgQEAKICAgICAgICAgICAgICAgICBnYnBzRXF1YWwob3RoZXIpICYmCiAgICAgICAgICAgICAgICAgbVBoeXNpY2FsQ2FtZXJhSWQgPT0gb3RoZXIubVBoeXNpY2FsQ2FtZXJhSWQgJiYKICAgICAgICAgICAgICAgICBtSXNNdWx0aVJlc29sdXRpb24gPT0gb3RoZXIubUlzTXVsdGlSZXNvbHV0aW9uICYmCi0gICAgICAgICAgICAgICAgc2Vuc29yUGl4ZWxNb2Rlc1VzZWRFcXVhbChvdGhlcikpOworICAgICAgICAgICAgICAgIHNlbnNvclBpeGVsTW9kZXNVc2VkRXF1YWwob3RoZXIpICYmCisgICAgICAgICAgICAgICAgbUR5bmFtaWNSYW5nZVByb2ZpbGUgPT0gb3RoZXIubUR5bmFtaWNSYW5nZVByb2ZpbGUgJiYKKyAgICAgICAgICAgICAgICBtU3RyZWFtVXNlQ2FzZSA9PSBvdGhlci5tU3RyZWFtVXNlQ2FzZSAmJgorICAgICAgICAgICAgICAgIG1UaW1lc3RhbXBCYXNlID09IG90aGVyLm1UaW1lc3RhbXBCYXNlICYmCisgICAgICAgICAgICAgICAgbU1pcnJvck1vZGUgPT0gb3RoZXIubU1pcnJvck1vZGUpOwogICAgIH0KICAgICBib29sIG9wZXJhdG9yICE9IChjb25zdCBPdXRwdXRDb25maWd1cmF0aW9uJiBvdGhlcikgY29uc3QgewogICAgICAgICByZXR1cm4gISgqdGhpcyA9PSBvdGhlcik7CkBAIC0xMjYsNiArMTQ4LDE4IEBACiAgICAgICAgIGlmICghc2Vuc29yUGl4ZWxNb2Rlc1VzZWRFcXVhbChvdGhlcikpIHsKICAgICAgICAgICAgIHJldHVybiBzZW5zb3JQaXhlbE1vZGVzVXNlZExlc3NUaGFuKG90aGVyKTsKICAgICAgICAgfQorICAgICAgICBpZiAobUR5bmFtaWNSYW5nZVByb2ZpbGUgIT0gb3RoZXIubUR5bmFtaWNSYW5nZVByb2ZpbGUpIHsKKyAgICAgICAgICAgIHJldHVybiBtRHluYW1pY1JhbmdlUHJvZmlsZSA8IG90aGVyLm1EeW5hbWljUmFuZ2VQcm9maWxlOworICAgICAgICB9CisgICAgICAgIGlmIChtU3RyZWFtVXNlQ2FzZSAhPSBvdGhlci5tU3RyZWFtVXNlQ2FzZSkgeworICAgICAgICAgICAgcmV0dXJuIG1TdHJlYW1Vc2VDYXNlIDwgb3RoZXIubVN0cmVhbVVzZUNhc2U7CisgICAgICAgIH0KKyAgICAgICAgaWYgKG1UaW1lc3RhbXBCYXNlICE9IG90aGVyLm1UaW1lc3RhbXBCYXNlKSB7CisgICAgICAgICAgICByZXR1cm4gbVRpbWVzdGFtcEJhc2UgPCBvdGhlci5tVGltZXN0YW1wQmFzZTsKKyAgICAgICAgfQorICAgICAgICBpZiAobU1pcnJvck1vZGUgIT0gb3RoZXIubU1pcnJvck1vZGUpIHsKKyAgICAgICAgICAgIHJldHVybiBtTWlycm9yTW9kZSA8IG90aGVyLm1NaXJyb3JNb2RlOworICAgICAgICB9C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OgogICAgICAgICBjYXNlIGtXaGF0Q2FwdHVyZUZhaWw6CkBAIC0xMDA0LDYgKzEwMDQsNyBAQAogICAgICAgICAgICAgc3A8Q2FwdHVyZVJlcXVlc3Q+IHJlcXVlc3RTcCA9IG51bGxwdHI7CiAgICAgICAgICAgICBzd2l0Y2ggKG1zZy0+d2hhdCgpKSB7CiAgICAgICAgICAgICAgICAgY2FzZSBrV2hhdENhcHR1cmVTdGFydDoKKyAgICAgICAgICAgICAgICBjYXNlIGtXaGF0Q2FwdHVyZVN0YXJ0MjoKICAgICAgICAgICAgICAgICBjYXNlIGtXaGF0Q2FwdHVyZVJlc3VsdDoKICAgICAgICAgICAgICAgICBjYXNlIGtXaGF0TG9naWNhbENhcHR1cmVSZXN1bHQ6CiAgICAgICAgICAgICAgICAgY2FzZSBrV2hhdENhcHR1cmVGYWlsOgpAQCAtMTA1NSw2ICsxMDU2LDM1IEBACiAgICAgICAgICAgICAgICAgICAgIGZyZWVBQ2FwdHVyZVJlcXVlc3QocmVxdWVzdCk7CiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBjYXNlIGtXaGF0Q2FwdHVyZVN0YXJ0MjoKKyAgICAgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgICAgIEFDYW1lcmFDYXB0dXJlU2Vzc2lvbl9jYXB0dXJlQ2FsbGJhY2tfc3RhcnRWMiBvblN0YXJ0MjsKKyAgICAgICAgICAgICAgICAgICAgZm91bmQgPSBtc2ctPmZpbmRQb2ludGVyKGtDYWxsYmFja0ZwS2V5LCAodm9pZCoqKSAmb25TdGFydDIpOworICAgICAgICAgICAgICAgICAgICBpZiAoIWZvdW5kKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IENhbm5vdCBmaW5kIGNhcHR1cmUgc3RhcnRWMiBjYWxsYmFjayEiLCBfX0ZVTkNUSU9OX18pOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIGlmIChvblN0YXJ0MiA9PSBudWxscHRyKSB7CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgaW50NjRfdCB0aW1lc3RhbXA7CisgICAgICAgICAgICAgICAgICAgIGZvdW5kID0gbXNnLT5maW5kSW50NjQoa1RpbWVTdGFtcEtleSwgJnRpbWVzdGFtcCk7CisgICAgICAgICAgICAgICAgICAgIGlmICghZm91bmQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIEFMT0dFKCIlczogQ2Fubm90IGZpbmQgdGltZXN0YW1wISIsIF9fRlVOQ1RJT05fXyk7CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgaW50NjRfdCBmcmFtZU51bWJlcjsKKyAgICAgICAgICAgICAgICAgICAgZm91bmQgPSBtc2ctPmZpbmRJbnQ2NChrRnJhbWVOdW1iZXJLZXksICZmcmFtZU51bWJlcik7CisgICAgICAgICAgICAgICAgICAgIGlmICghZm91bmQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIEFMT0dFKCIlczogQ2Fubm90IGZpbmQgZnJhbWUgbnVtYmVyISIsIF9fRlVOQ1RJT05fXyk7CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgICAgICBBQ2FwdHVyZVJlcXVlc3QqIHJlcXVlc3QgPSBhbGxvY2F0ZUFDYXB0dXJlUmVxdWVzdChyZXF1ZXN0U3AsIG1JZCk7CisgICAgICAgICAgICAgICAgICAgICgqb25TdGFydDIpKGNvbnRleHQsIHNlc3Npb24uZ2V0KCksIHJlcXVlc3QsIHRpbWVzdGFtcCwgZnJhbWVOdW1iZXIpOworICAgICAgICAgICAgICAg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TUsMTggQEAKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgVmVjdG9yPHNwPENhcHR1cmVSZXF1ZXN0PiA+JiByZXF1ZXN0cywKICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlcGVhdGluZywKICAgICAgICAgICAgICAgICAgICAgICAgQUNhbWVyYUNhcHR1cmVTZXNzaW9uX2xvZ2ljYWxDYW1lcmFfY2FwdHVyZUNhbGxiYWNrcyogbGNicyk7Ci0KLSAgICAgICAgdGVtcGxhdGUgPGNsYXNzIFQ+Ci0gICAgICAgIHZvaWQgaW5pdENhcHR1cmVDYWxsYmFja3MoVCogY2JzKSB7CisgICAgICAgIENhbGxiYWNrSG9sZGVyKHNwPEFDYW1lcmFDYXB0dXJlU2Vzc2lvbj4gICAgICAgICAgc2Vzc2lvbiwKKyAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgVmVjdG9yPHNwPENhcHR1cmVSZXF1ZXN0PiA+JiByZXF1ZXN0cywKKyAgICAgICAgICAgICAgICAgICAgICAgYm9vbCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlcGVhdGluZywKKyAgICAgICAgICAgICAgICAgICAgICAgQUNhbWVyYUNhcHR1cmVTZXNzaW9uX2NhcHR1cmVDYWxsYmFja3NWMiogY2JzKTsKKyAgICAgICAgQ2FsbGJhY2tIb2xkZXIoc3A8QUNhbWVyYUNhcHR1cmVTZXNzaW9uPiAgICAgICAgICBzZXNzaW9uLAorICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBWZWN0b3I8c3A8Q2FwdHVyZVJlcXVlc3Q+ID4mIHJlcXVlc3RzLAorICAgICAgICAgICAgICAgICAgICAgICBib29sICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVwZWF0aW5nLAorICAgICAgICAgICAgICAgICAgICAgICBBQ2FtZXJhQ2FwdHVyZVNlc3Npb25fbG9naWNhbENhbWVyYV9jYXB0dX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isgICAgLyoqCisgICAgICogPHA+VGhpcyBpcyB0aGUgcG93ZXIgb3B0aW1pemVkIG1vZGUgZm9yIDEwLWJpdCBEb2xieSBWaXNpb24gSERSIFJlZmVyZW5jZSBNb2RlLjwvcD4KKyAgICAgKi8KKyAgICBBQ0FNRVJBX1JFUVVFU1RfQVZBSUxBQkxFX0RZTkFNSUNfUkFOR0VfUFJPRklMRVNfTUFQX0RPTEJZX1ZJU0lPTl8xMEJfSERSX1JFRl9QTworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID0gMHgyMCwKKworICAgIC8qKgorICAgICAqIDxwPlRoaXMgaXMgdGhlIGNhbWVyYSBtb2RlIGZvciB0aGUgZGVmYXVsdCBEb2xieSBWaXNpb24gY2FwdHVyZSBtb2RlIGZvciB0aGUKKyAgICAgKiBzcGVjaWZpYyBkZXZpY2UuIFRoaXMgd291bGQgYmUgdHVuZWQgYnkgZWFjaCBzcGVjaWZpYyBkZXZpY2UgZm9yIGNvbnN1bWVyCisgICAgICogcGxlYXNpbmcgcmVzdWx0cyB0aGF0IHJlc29uYXRlIHdpdGggdGhlaXIgcGFydGljdWxhciBhdWRpZW5jZS4gV2UgZXhwZWN0CisgICAgICogdGhhdCBlYWNoIHNwZWNpZmljIGRldmljZSB3b3VsZCBoYXZlIGEgZGlmZmVyZW50IGxvb2sgZm9yIHRoZWlyIGRlZmF1bHQKKyAgICAgKiBEb2xieSBWaXNpb24gY2FwdHVyZS48L3A+CisgICAgICovCisgICAgQUNBTUVSQV9SRVFVRVNUX0FWQUlMQUJMRV9EWU5BTUlDX1JBTkdFX1BST0ZJTEVTX01BUF9ET0xCWV9WSVNJT05fMTBCX0hEUl9PRU0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA9IDB4NDAsCisKKyAgICAvKioKKyAgICAgKiA8cD5UaGlzIGlzIHRoZSBwb3dlciBvcHRpbWl6ZWQgbW9kZSBmb3IgMTAtYml0IERvbGJ5IFZpc2lvbiBIRFIgZGV2aWNlIHNwZWNpZmljCisgICAgICogY2FwdHVyZSBNb2RlLjwvcD4KKyAgICAgKi8KKyAgICBBQ0FNRVJBX1JFUVVFU1RfQVZBSUxBQkxFX0RZTkFNSUNfUkFOR0VfUFJPRklMRVNfTUFQX0RPTEJZX1ZJU0lPTl8xMEJfSERSX09FTV9QTworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID0gMHg4MCwKKworICAgIC8qKgorICAgICAqIDxwPlRoaXMgaXMgdGhlIDgtYml0IHZlcnNpb24gb2YgdGhlIERvbGJ5IFZpc2lvbiByZWZlcmVuY2UgY2FwdHVyZSBtb2RlIG9wdGltaXplZAorICAgICAqIGZvciBzY2VuZSBhY2N1cmFjeS48L3A+CisgICAgICovCisgICAgQUNBTUVSQV9SRVFVRVNUX0FWQUlMQUJMRV9EWU5BTUlDX1JBTkdFX1BST0ZJTEVTX01BUF9ET0xCWV9WSVNJT05fOEJfSERSX1JFRgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID0gMHgxMDAsCisKKyAgICAvKioKKyAgICAgKiA8cD5UaGlzIGlzIHRoZSBwb3dlciBvcHRpbWl6ZWQgbW9kZSBmb3IgOC1iaXQgRG9sYnkgVmlzaW9uIEhEUiBSZWZlcmVuY2UgTW9kZS48L3A+CisgICAgICovCisgICAgQUNBTUVSQV9SRVFVRVNUX0FWQUlMQUJMRV9EWU5BTUlDX1JBTkdFX1BST0ZJTEVTX01BUF9ET0xCWV9WSVNJT05fOEJfSERSX1JFRl9QTworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID0gMHgyMDAsCisKKyAgICAvKioKKyAg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W4gdGhlIGNhcHR1cmUgcmVxdWVzdCBhbmQgc2VlIHdoaWNoCisgICAgICAgICAgICAgICAgLy8gb25lcyBtYXRjaCB0aGUgc3VyZmFjZXMgaW4gdGhlIGVycm9yIHN0cmVhbS4KKyAgICAgICAgICAgICAgICBpbnQzMl90IHJlcXVlc3RXaW5kb3dJZCA9IHJlcXVlc3RTdHJlYW1BbmRXaW5kb3dJZC53aW5kb3dJZDsKKyAgICAgICAgICAgICAgICBhdXRvIHJlcXVlc3RTdXJmYWNlUGFpckl0ID0KKyAgICAgICAgICAgICAgICAgICAgICAgIG1Db25maWd1cmVkT3V0cHV0cy5maW5kKHJlcXVlc3RTdHJlYW1BbmRXaW5kb3dJZC5zdHJlYW1JZCk7CisgICAgICAgICAgICAgICAgaWYgKHJlcXVlc3RTdXJmYWNlUGFpckl0ID09IG1Db25maWd1cmVkT3V0cHV0cy5lbmQoKSkgeworICAgICAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IEVycm9yOiByZXF1ZXN0IHN0cmVhbSBpZCAlZCBkb2VzIG5vdCBleGlzdCIsIF9fRlVOQ1RJT05fXywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3RTdHJlYW1BbmRXaW5kb3dJZC5zdHJlYW1JZCk7CisgICAgICAgICAgICAgICAgICAgIHNldENhbWVyYURldmljZUVycm9yTG9ja2VkKEFDQU1FUkFfRVJST1JfQ0FNRVJBX1NFUlZJQ0UpOworICAgICAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgICAgY29uc3QgYXV0byAmcmVxdWVzdFdpbmRvd0hhbmRsZXMgPQorICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdFN1cmZhY2VQYWlySXQtPnNlY29uZC5zZWNvbmQubU91dHB1dENvbmZpZ3VyYXRpb24ud2luZG93SGFuZGxlczsKKyAgICAgICAgICAgICAgICBpZiAodXRpbHM6OmlzV2luZG93TmF0aXZlSG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ogICAgICAgICBjYXNlIGtXaGF0Q2FwdHVyZUZhaWw6CkBAIC0xMDAyLDYgKzEwMjUsNyBAQAogICAgICAgICAgICAgY29uc3QgY2hhciAqaWRfY3N0ciA9IG1JZC5jX3N0cigpOwogICAgICAgICAgICAgc3dpdGNoIChtc2ctPndoYXQoKSkgewogICAgICAgICAgICAgICAgIGNhc2Uga1doYXRDYXB0dXJlU3RhcnQ6CisgICAgICAgICAgICAgICAgY2FzZSBrV2hhdENhcHR1cmVTdGFydDI6CiAgICAgICAgICAgICAgICAgY2FzZSBrV2hhdENhcHR1cmVSZXN1bHQ6CiAgICAgICAgICAgICAgICAgY2FzZSBrV2hhdExvZ2ljYWxDYXB0dXJlUmVzdWx0OgogICAgICAgICAgICAgICAgIGNhc2Uga1doYXRDYXB0dXJlRmFpbDoKQEAgLTEwNTMsNiArMTA3NywzNSBAQAogICAgICAgICAgICAgICAgICAgICBmcmVlQUNhcHR1cmVSZXF1ZXN0KHJlcXVlc3QpOwogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgY2FzZSBrV2hhdENhcHR1cmVTdGFydDI6CisgICAgICAgICAgICAgICAgeworICAgICAgICAgICAgICAgICAgICBBQ2FtZXJhQ2FwdHVyZVNlc3Npb25fY2FwdHVyZUNhbGxiYWNrX3N0YXJ0VjIgb25TdGFydDI7CisgICAgICAgICAgICAgICAgICAgIGZvdW5kID0gbXNnLT5maW5kUG9pbnRlcihrQ2FsbGJhY2tGcEtleSwgKHZvaWQqKikgJm9uU3RhcnQyKTsKKyAgICAgICAgICAgICAgICAgICAgaWYgKCFmb3VuZCkgeworICAgICAgICAgICAgICAgICAgICAgICAgQUxPR0UoIiVzOiBDYW5ub3QgZmluZCBjYXB0dXJlIHN0YXJ0VjIgY2FsbGJhY2shIiwgX19GVU5DVElPTl9fKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICBpZiAob25TdGFydDIgPT0gbnVsbHB0cikgeworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIGludDY0X3QgdGltZXN0YW1wOworICAgICAgICAgICAgICAgICAgICBmb3VuZCA9IG1zZy0+ZmluZEludDY0KGtUaW1lU3RhbXBLZXksICZ0aW1lc3RhbXApOworICAgICAgICAgICAgICAgICAgICBpZiAoIWZvdW5kKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IENhbm5vdCBmaW5kIHRpbWVzdGFtcCEiLCBfX0ZVTkNUSU9OX18pOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIGludDY0X3QgZnJhbWVOdW1iZXI7CisgICAgICAgICAgICAgICAgICAgIGZvdW5kID0gbXNnLT5maW5kSW50NjQoa0ZyYW1lTnVtYmVyS2V5LCAmZnJhbWVOdW1iZXIpOworICAgICAgICAgICAgICAgICAgICBpZiAoIWZvdW5kKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IENhbm5vdCBmaW5kIGZyYW1lIG51bWJlciEiLCBfX0ZVTkNUSU9OX18pOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOworICAgICAgICAgICAgICAgICAgICB9CisKKyAgICAgICAgICAgICAgICAgICAgQUNhcHR1cmVSZXF1ZXN0KiByZXF1ZXN0ID0gYWxsb2NhdGVBQ2FwdHVyZVJlcXVlc3QocmVxdWVzdFNwLCBpZF9jc3RyKTsKKyAgICAgICAgICAgICAgICAgICAgKCpvblN0YXJ0MikoY29udGV4dCwgc2Vzc2lvbi5nZXQoKSwgcmVxdWVzdCwgdGltZXN0YW1wLCBmcmFtZU51bWJlcik7CisgICAgICAgICAgICAgICAgICAgIGZyZWVBQ2FwdHVyZVJlcXVlc3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sCisgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFZlY3RvcjxzcDxDYXB0dXJlUmVxdWVzdD4gPiYgcmVxdWVzdHMsCisgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZXBlYXRpbmcsCisgICAgICAgICAgICAgICAgICAgICAgIEFDYW1lcmFDYXB0dXJlU2Vzc2lvbl9jYXB0dXJlQ2FsbGJhY2tzVjIqIGNicyk7CisgICAgICAgIENhbGxiYWNrSG9sZGVyKHNwPEFDYW1lcmFDYXB0dXJlU2Vzc2lvbj4gICAgICAgICAgc2Vzc2lvbiwKKyAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgVmVjdG9yPHNwPENhcHR1cmVSZXF1ZXN0PiA+JiByZXF1ZXN0cywKKyAgICAgICAgICAgICAgICAgICAgICAgYm9vbCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlcGVhdGluZywKKyAgICAgICAgICAgICAgICAgICAgICAgQUNhbWVyYUNhcHR1cmVTZXNzaW9uX2xvZ2ljYWxDYW1lcmFfY2FwdHVyZUNhbGxiYWNrc1YyKiBsY2JzKTsKKyAgICAgICAgdm9pZCBjbGVhckNhbGxiYWNrcygpIHsKICAgICAgICAgICAgIG1Db250ZXh0ID0gbnVsbHB0cjsKICAgICAgICAgICAgIG1PbkNhcHR1cmVTdGFydGVkID0gbnVsbHB0cjsKKyAgICAgICAgICAgIG1PbkNhcHR1cmVTdGFydGVkMiA9IG51bGxwdHI7CiAgICAgICAgICAgICBtT25DYXB0dXJlUHJvZ3Jlc3NlZCA9IG51bGxwdHI7CiAgICAgICAgICAgICBtT25DYXB0dXJlQ29tcGxldGVkID0gbnVsbHB0cjsKICAgICAgICAgICAgIG1PbkxvZ2ljYWxDYW1lcmFDYXB0dXJlQ29tcGxldGVkID0gbnVsbHB0cjsKQEAgLTMyMiw2ICszMzAsMjQgQEAKICAgICAgICAgICAgIG1PbkNhcHR1cmVTZXF1ZW5jZUNvbXBsZXRlZCA9IG51bGxwdHI7CiAgICAgICAgICAgICBtT25DYXB0dXJlU2VxdWVuY2VBYm9ydGVkID0gbnVsbHB0cjsKICAgICAgICAgICAgIG1PbkNhcHR1cmVCdWZmZXJMb3N0ID0gbnVsbHB0cjsKKyAgICAgICAgfQorCisgICAgICAgIHRlbXBsYXRlIDxjbGFzcyBUPgorICAgICAgICB2b2lkIGluaXRDYXB0dXJlQ2FsbGJhY2tzVjIoVCogY2JzKSB7CisgICAgICAgICAgICBjbGVhckNhbGxiYWNrcygpOworICAgICAgICAgICAgaWYgKGNicyAhPSBudWxscHRyKSB7CisgICAgICAgICAgICAgICAgbUNvbnRleHQgPSBjYnMtPmNvbnRleHQ7CisgICAgICAgICAgICAgICAgbU9uQ2FwdHVyZVN0YXJ0ZWQyID0gY2JzLT5vbkNhcHR1cmVTdGFydGVkOworICAgICAgICAgICAgICAgIG1PbkNhcHR1cmVQcm9ncmVzc2VkID0gY2JzLT5vbkNhcHR1cmVQcm9ncmVzc2VkOworICAgICAgICAgICAgICAgIG1PbkNhcHR1cmVTZXF1ZW5jZUNvbXBsZXRlZCA9IGNicy0+b25DYXB0dXJlU2VxdWVuY2VDb21wbGV0ZWQ7CisgICAgICAgICAgICAgICAgbU9uQ2FwdHVyZVNlcXVlbmNlQWJvcnRlZCA9IGNicy0+b25DYXB0dXJlU2VxdWVuY2VBYm9ydGVkOworICAgICAgICAgICAgICAgIG1PbkNhcHR1cmVCdWZmZXJMb3N0ID0gY2JzLT5vbkNhcHR1cmVCdWZmZXJMb3N0OworICAgICAgICAgICAgfQorICAgICAgICB9CisKKyAgICAgICAgdGVtcGxhdGUgPGNsYXNzIFQ+CisgICAgICAgIHZvaWQgaW5pdENhcHR1cmVDYWxsYmFja3MoVCogY2JzKSB7CisgICAgICAgICAgICBjbGVhckNhbGxiYWNrcygpOwogICAgICAgICAgICAgaWYgKGNicyAhPSBudWxscHRyKSB7CiAgICAgICAgICAgICAgICAgbUNv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iAgICAgICAgIH0KIAogICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IHBpY3R1cmVDb3VudDsgaSsrKSB7Ci0gICAgICAgICAgICByZXQgPSBjYW1lcmFIZWxwZXIudGFrZVBpY3R1cmUoKTsKKyAgICAgICAgICAgIGlmICh2MikgeworICAgICAgICAgICAgICAgIHJldCA9IGNhbWVyYUhlbHBlci50YWtlUGljdHVyZTIoKTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgcmV0ID0gY2FtZXJhSGVscGVyLnRha2VQaWN0dXJlKCk7CisgICAgICAgICAgICB9CiAgICAgICAgICAgICBpZiAocmV0IDwgMCkgewogICAgICAgICAgICAgICAgIEFMT0dFKCJVbmFibGUgdG8gdGFrZSBwaWN0dXJlIik7CiAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwpAQCAtNjE3LDcgKzY3Nyw4IEBACiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICAgICAgcmV0dXJuIHRlc3RDYXNlLmdldEFjcXVpcmVkSW1hZ2VDb3VudCgpID09IHBpY3R1cmVDb3VudCAmJgotICAgICAgICAgICAgICAgIGNhbWVyYUhlbHBlci5jaGVja0NhbGxiYWNrcyhwaWN0dXJlQ291bnQpOworICAgICAgICAgICAgICAgdjIgPyBjYW1lcmFIZWxwZXIuY2hlY2tDYWxsYmFja3NWMihwaWN0dXJlQ291bnQpIDoKKyAgICAgICAgICAgICAgICAgICAgY2FtZXJhSGVscGVyLmNoZWNrQ2FsbGJhY2tzKHBpY3R1cmVDb3VudCk7CiAgICAgfQogCiAgICAgYm9vbCB0ZXN0VGFrZVBpY3R1cmVzTmF0aXZlKGNvbnN0IGNoYXIqIGlkKSB7CkBAIC02MjYsMTIgKzY4NywxNCBAQAogICAgICAgICAgICAgZm9yIChhdXRvJiByZWFkZXJNYXhJbWFnZXMgOiB7MSwgNCwgOH0pIHsKICAgICAgICAgICAgICAgICBmb3IgKGF1dG8mIHJlYWRlckFzeW5jIDoge3RydWUsIGZhbHNlfSkgewogICAgICAgICAgICAgICAgICAgICBmb3IgKGF1dG8mIHBpY3R1cmVDb3VudCA6IHsxLCA0LCA4fSkgewotICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0YWtlUGljdHVyZXMoaWQsIHJlYWRlclVzYWdlLCByZWFkZXJNYXhJbWFnZXMsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRlckFzeW5jLCBwaWN0dXJlQ291bnQpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgQUxPR0UoIlRlc3QgdGFrZVBpY3R1cmVzIGZhaWxlZCBmb3IgdGVzdCBjYXNlIHVzYWdlPSUiIFBSSXU2NAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIsIG1heEltYWdlcz0lZCwgYXN5bmM9JWQsIHBpY3R1cmVDb3VudD0lZCIsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZGVyVXNhZ2UsIHJlYWRlck1heEltYWdlcywgcmVhZGVyQXN5bmMsIHBpY3R1cmVDb3VudCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOworICAgICAgICAgICAgICAgICAgICAgICAgZm9yICggYXV0byAmIHYyIDoge3RydWUsIGZhbHNlfSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGFrZVBpY3R1cmVzKGlkLCByZWFkZXJVc2FnZSwgcmVhZGVyTWF4SW1hZ2VzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZGVyQXN5bmMsIHBpY3R1cmVDb3VudCwgdjIpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFMT0dFKCJUZXN0IHRha2VQaWN0dXJlcyBmYWlsZWQgZm9yIHRlc3QgY2FzZSB1c2FnZT0lIiBQUkl1NjQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIiwgbWF4SW1hZ2VzPSVkLCBhc3luYz0lZCwgcGljdHVyZUNvdW50PSVkIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZGVyVXNhZ2UsIHJlYWRlck1heEltYWdlcywgcmVhZGVyQXN5bmMsIHBpY3R1cmVDb3VudCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9CkBAIC03MjUsNyArNzg4LDcgQEAKICAgICAgICAgcmV0dXJuOwogICAgIH0KIAotICAgIHZvaWQgdGVzdExvZ2ljYWxDYW1lcmFQaHlzaWNhbFN0cmVhbShib29sIHVzZVBoeXNpY2FsU2V0dGluZ3MpIHsKKyAgICB2b2lkIHRlc3RMb2dpY2FsQ2FtZXJhUGh5c2ljYWxTdHJlYW0oYm9vbCB1c2VQaHlzaWNhbFNldHRpbmdzLCBib29sIHYyKSB7CiAgICAgICAgIGNvbnN0IGNoYXIqIGNhbWVyYUlkID0gbnVsbHB0cjsKICAgICAgICAgQUNhbWVyYU1ldGFkYXRhKiBzdGF0aWNNZXRhZGF0YSA9IG51bGxwdHI7CiAgICAgICAgIHN0ZDo6dmVjdG9yPGNvbnN0IGNoYXIqPiBwaHlzaWNhbENhbWVyYUlkczsKQEAgLTc3Miw3ICs4MzUsMTIgQEAKICAgICAgICAgfQogCiAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgcGljdHVyZUNvdW50OyBpKyspIHsKLSAgICAgICAgICAgIHJldCA9IGNhbWVyYUhlbHBlci50YWtlTG9naWNhbENhbWVyYVBpY3R1cmUoKTsKKyAgICAgICAgICAgIGlmICh2MikgeworICAgICAgICAgICAgICByZXQgPSBjYW1lcmFIZWxwZXIudGFrZUxvZ2ljYWxDYW1lcmFQaWN0dXJlMigpOworICA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lzaWNhbERpc3BsYXlJZCA9IFBoeXNpY2FsRGlzcGxheUlkKGF0b2xsKG9wdGFyZykpOwotICAgICAgICAgICAgaWYgKGdQaHlzaWNhbERpc3BsYXlJZC52YWx1ZSA9PSAwKSB7Ci0gICAgICAgICAgICAgICAgZnByaW50ZihzdGRlcnIsICJQbGVhc2Ugc3BlY2lmeSBhIHZhbGlkIHBoeXNpY2FsIGRpc3BsYXkgaWRcbiIpOwotICAgICAgICAgICAgICAgIHJldHVybiAyOwotICAgICAgICAgICAgfSBlbHNlIGlmIChTdXJmYWNlQ29tcG9zZXJDbGllbnQ6OgotICAgICAgICAgICAgICAgICAgICBnZXRQaHlzaWNhbERpc3BsYXlUb2tlbihnUGh5c2ljYWxEaXNwbGF5SWQpID09IG51bGxwdHIpIHsKLSAgICAgICAgICAgICAgICBmcHJpbnRmKHN0ZGVyciwgIkludmFsaWQgcGh5c2ljYWwgZGlzcGxheSBpZDogJXNcbiIsCi0gICAgICAgICAgICAgICAgICAgICAgICB0b19zdHJpbmcoZ1BoeXNpY2FsRGlzcGxheUlkKS5jX3N0cigpKTsKLSAgICAgICAgICAgICAgICByZXR1cm4gMjsKKyAgICAgICAgICAgIGlmIChjb25zdCBhdXRvIGlkID0gYW5kcm9pZDo6RGlzcGxheUlkOjpmcm9tVmFsdWU8UGh5c2ljYWxEaXNwbGF5SWQ+KGF0b2xsKG9wdGFyZykpOworICAgICAgICAgICAgICAgIGlkICYmIFN1cmZhY2VDb21wb3NlckNsaWVudDo6Z2V0UGh5c2ljYWxEaXNwbGF5VG9rZW4oKmlkKSkgeworICAgICAgICAgICAgICAgIGdQaHlzaWNhbERpc3BsYXlJZCA9ICppZDsKKyAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGJyZWFrOworCisgICAgICAgICAgICBmcHJpbnRmKHN0ZGVyciwgIkludmFsaWQgcGh5c2ljYWwgZGlzcGxheSBJRFxuIik7CisgICAgICAgICAgICByZXR1cm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isgICAgICAgICJzdGFnZWZyaWdodC5jcHAiLAorICAgICAgICAianBlZy5jcHAiLAorICAgICAgICAiU2luZVNvdXJjZS5jcHAiLAorICAgIF0sCisKKyAgICBoZWFkZXJfbGliczogWworICAgICAgICAibGlibWVkaWFtZXRyaWNzX2hlYWRlcnMiLAorICAgICAgICAibGlic3RhZ2VmcmlnaHRfaGVhZGVycyIsCisgICAgXSwKKworICAgIHNoYXJlZF9saWJzOiBbCisgICAgICAgICJsaWJzdGFnZWZyaWdodCIsCisgICAgICAgICJsaWJtZWRpYSIsCisgICAgICAgICJsaWJtZWRpYV9jb2RlY2xpc3QiLAorICAgICAgICAibGlidXRpbHMiLAorICAgICAgICAibGliYmluZGVyIiwKKyAgICAgICAgImxpYnN0YWdlZnJpZ2h0X2ZvdW5kYXRpb24iLAorICAgICAgICAibGlianBlZyIsCisgICAgICAgICJsaWJ1aSIsCisgICAgICAgICJsaWJndWkiLAorICAgICAgICAibGliY3V0aWxzIiwKKyAgICAgICAgImxpYmxvZyIsCisgICAgICAgICJsaWJoaWRsYmFzZSIsCisgICAgICAgICJsaWJkYXRhc291cmNlIiwKKyAgICAgICAgImxpYmF1ZGlvY2xpZW50IiwKKyAgICAgICAgImFuZHJvaWQuaGFyZHdhcmUubWVkaWEub214QDEuMCIsCisgICAgICAgICJmcmFtZXdvcmstcGVybWlzc2lvbi1haWRsLWNwcCIsCisgICAgXSwKKworICAgIHN0YXRpY19saWJzOiBbImZyYW1ld29yay1wZXJtaXNzaW9uLWFpZGwtY3BwIl0sCisKKyAgICBjZmxhZ3M6IFsKKyAgICAgICAgIi1Xbm8tbXVsdGljaGFyIiwKKyAgICBdLAorCisgICAgc3lzdGVtX2V4dF9zcGVjaWZpYzogdHJ1ZSwKK30KKworY2NfYmluYXJ5IHsKKyAgICBuYW1lOiAicmVjb3JkIiwKKworICAgIHNyY3M6IFsKKyAgICAgICAgIkF1ZGlvUGxheWVyLmNwcCIsCisgICAgICAgICJTaW5lU291cmNlLmNwcCIsCisgICAgICAgICJyZWNvcmQuY3BwIiwKKyAgICBdLAorCisgICAgaGVhZGVyX2xpYnM6IFsKKyAgICAgICAgImxpYm1lZGlhbWV0cmljc19oZWFkZXJzIiwKKyAgICAgICAgImxpYnN0YWdlZnJpZ2h0X2hlYWRlcnMiLAorICAgICAgICAiY2FtZXJhX2hlYWRlcnMiLAorICAgIF0sCisKKyAgICBzaGFyZWRfbGliczogWworICAgICAgICAibGlic3RhZ2VmcmlnaHQiLAorICAgICAgICAibGlibWVkaWEiLAorICAgICAgICAibGlibG9nIiwKKyAgICAgICAgImxpYnV0aWxzIiwKKyAgICAgICAgImxpYmJpbmRlciIsCisgICAgICAgICJsaWJzdGFnZWZyaWdodF9mb3VuZGF0aW9uIiwKKyAgICAgICAgImxpYmRhdGFzb3VyY2UiLAorICAgICAgICAibGliYXVkaW9jbGllbnQiLAorICAgICAgICAiZnJhbWV3b3JrLXBlcm1pc3Npb24tYWlkbC1jcHAiLAorICAgIF0sCisKKyAgICBjZmxhZ3M6IFsKKyAgICAgICAgIi1Xbm8tbXVsdGljaGFyIiwKKyAgICBdLAorfQorCitjY19iaW5hcnkgeworICAgIG5hbWU6ICJyZWNvcmR2aWRlbyIsCisKKyAgICBzcmNzOiBbCisgICAgICAgICJBdWRpb1BsYXllci5jcHAiLAorICAgICAgICAicmVjb3JkdmlkZW8uY3BwIiwKKyAgICBdLAorCisgICAgaGVhZGVyX2xpYnM6IFsKKyAgICAgICAgImxpYm1lZGlhbWV0cmljc19oZWFkZXJzIiwKKyAgICAgICAgImxpYnN0YWdlZnJpZ2h0X2hlYWRlcnMiLAorICAgIF0sCisKKyAgICBzaGFyZWRfbGliczogWworICAgICAgICAibGlic3RhZ2VmcmlnaHQiLAorICAgICAgICAibGlibWVkaWEiLAorICAgICAgICAibGlibG9nIiwKKyAgICAgICAgImxpYnV0aWxzIiwKKyAgICAgICAgImxpYmJpbmRlciIsCisgICAgICAgICJsaWJzdGFnZWZyaWdodF9mb3VuZGF0aW9uIiwKKyAgICAgICAgImxpYmF1ZGlvY2xpZW50IiwKKyAgICAgICAgImZyYW1ld29yay1wZXJtaXNzaW9uLWFpZGwtY3BwIiwKKyAgICBdLAorCisgICAgY2ZsYWdzOiBbCisgICAgICAgICItV25vLW11bHRpY2hhciIsCisgICAgXSwKK30KKworY2NfYmluYXJ5IHsKKyAgICBuYW1lOiAiYXVkaW9sb29wIiwKKworICAgIHNyY3M6IFsKKyAgICAgICAgIkF1ZGlvUGxheWVyLmNwcCIsCisgICAgICAgICJTaW5lU291cmNlLmNwcCIsCisgICAgICAgICJhdWRpb2xvb3AuY3BwIiwKKyAgICBdLAorCisgICAgaGVhZGVyX2xpYnM6IFsKKyAgICAgICAgImxpYm1lZGlhbWV0cmljc19oZWFkZXJzIiwKKyAgICAgICAgImxpYnN0YWdlZnJpZ2h0X2hlYWRlcnMiLAorICAgIF0sCisKKyAgICBzaGFyZWRfbGliczogWworICAgICAgICAibGlic3RhZ2VmcmlnaHQiLAorICAgICAgICAibGlibWVkaWEiLAorICAgICAgICAibGlibG9nIiwKKyAgICAgICAgImxpYnV0aWxzIiwKKyAgICAgICAgImxpYmJpbmRlciIsCisgICAgICAgICJsaWJzdGFnZWZyaWdodF9mb3VuZGF0aW9uIiwKKyAgICAgICAgImxpYmF1ZGlvY2xpZW50IiwKKyAgICAgICAgImZyYW1ld29yay1wZXJtaXNzaW9uLWFpZGwtY3BwIiwKKyAgICBdLAorCisgICAgY2ZsYWdzOiBbCisgICAgICAgICItV25vLW11bHRpY2hhciIsCisgICAgXSwKK30KKworY2NfYmluYXJ5IHsKKyAgICBuYW1lOiAic3RyZWFtIiwKKworICAgIHNyY3M6IFsic3RyZWFtLmNwcCJdLAorCisgICAgaGVhZGVyX2xpYnM6IFsKKyAgICAgICAgImxpYm1lZGlhbWV0cmljc19oZWFkZXJzIiwKKyAgICAgICAgImxpYnN0YWdlZnJpZ2h0X2hlYWRlcnMiLAorICAgIF0sCisKKyAgICBzaGFyZWRfbGliczogWworICAgICAgICAibGlic3RhZ2VmcmlnaHQiLAorICAgICAgICAibGlibG9nIiwKKyAgICAgICAgImxpYnV0aWxzIiwKKyAgICAgICAgImxpYmJpbmRlciIsCisgICAgICAgICJsaWJ1aSIsCisgICAgICAgICJsaWJndWkiLAorICAgICAgICAibGlic3RhZ2VmcmlnaHRfZm91bmRhdGlvbiIsCisgICAgICAgICJsaWJtZWRpYSIsCisgICAgICAgICJsaWJjdXRpbHMiLAorICAgICAgICAibGliZGF0YXNvdXJjZSIsCisgICAgXSwKKworICAgIGNmbGFnczogWworICAgICAgICAiLVduby1tdWx0aWNoYXIiLAorICAgIF0sCit9CisKK2NjX2JpbmFyeSB7CisgICAgbmFtZTogImNvZGVjIiwKKworICAgIHNyY3M6IFsKKyAgICAgICAgImNvZGVjLmNwcCIsCisgICAgICAgICJTaW1wbGVQbGF5ZXIuY3BwIiwKKyAgICBdLAorCisgICAgaGVhZGVyX2xpYnM6IFsKKyAgICAgICAgImxpYm1lZGlhZHJtX2hlYWRlcnMiLAorICAgICAgICAibGlibWVkaWFtZXRyaWNzX2hlYWRlcnMiLAorICAgICAgICAibGlic3RhZ2VmcmlnaHRfaGVhZGVycyIsCisgICAgXSwKKworICAgIHNoYXJlZF9saWJzOiBbCisgICAgICAgICJsaWJzdGFnZWZyaWdodCIsCisgICAgICAgICJsaWJsb2ciLAorICAgICAgICAibGlidXRpbHMiLAorICAgICAgICAibGliYmluZGVyIiwKKyAgICAgICAgImxpYnN0YWdlZnJpZ2h0X2ZvdW5kYXRpb24iLAorICAgICAgICAibGlibWVkaWEiLAorICAgICAgICAibGlibWVkaWFfb214IiwKKyAgICAgICAgImxpYmF1ZGlvY2xpZW50IiwKKyAgICAgICAgImxpYnVpIiwKKyAgICAgICAgImxpYmd1aSIsCisgICAgICAgICJsaWJjdXRpbHMiLAorICAgIF0sCisKKyAgICBjZmxhZ3M6IFsKKyAgICAgICAgIi1Xbm8tbXVsdGljaGFyIiwKKyAgICBdLAorfQorCitjY19iaW5hcnkgeworICAgIG5hbWU6ICJtZWRpYWZpbHRlciIsCisKKyAgICBzcmNzOiBbCisgICAgICAgICJmaWx0ZXJzL2FyZ2J0b3JnYmEucnNjcmlwdCIsCisgICAgICAgICJmaWx0ZXJzL25pZ2h0dmlzaW9uLnJzY3JpcHQiLAorICAgICAgICAiZmlsdGVycy9zYXR1cmF0aW9uLnJzY3JpcHQiLAorICAgICAgICAibWVkaWFmaWx0ZXIuY3BwIiwKKyAgICBdLAorCisgICAgaGVhZGVyX2xpYnM6IFsKKyAgICAgICAgImxpYm1lZGlhZHJtX2hlYWRlcnMiLAorICAgICAgICAibGlibWVkaWFtZXRyaWNzX2hlYWRlcnMiLAorICAgICAgICAibGlic3RhZ2VmcmlnaHRfaGVhZGVycyIsCisgICAgICAgICJycy1oZWFkZXJzIiwKKyAgICBdLAorCisgICAgc2hhcmVkX2xpYnM6IFsKKyAgICAgICAgImxpYnN0YWdlZnJpZ2h0IiwKKyAgICAgICAgImxpYmxvZyIsCisgICAgICAgICJsaWJ1dGlscyIsCisgICAgICAgICJsaWJiaW5kZXIiLAorICAgICAgICAibGlic3RhZ2VmcmlnaHRfZm91bmRhdGlvbiIsCisgICAgICAgICJsaWJtZWRpYV9vbXgiLAorICAgICAgICAibGlidWkiLAorICAgICAgICAibGliZ3VpIiwKKyAgICAgICAgImxpYlJTY3BwIiwKKyAgICBdLAorCisgICAgc3RhdGljX2xpYnM6IFsibGlic3RhZ2VmcmlnaHRfbWVkaWFmaWx0ZXIiXSwKKworICAgIGNmbGFnczogWworICAgICAgICAiLVduby1tdWx0aWNoYXIiLAorICAgIF0sCisKKyAgICBzYW5pdGl6ZTogeworICAgICAgICBjZmk6IHRydWUsCisgICAgfSwKK30KKworY2NfYmluYXJ5IHsKKyAgICBuYW1lOiAibXV4ZXIiLAorCisgICAgc3JjczogWyJtdXhlci5jcHAiXSwKKworICAgIGhlYWRlcl9saWJzOiBbCisgICAgICAgICJsaWJtZWRpYW1ldHJpY3NfaGVhZGVycyIsCisgICAgICAgICJsaWJzdGFnZWZyaWdodF9oZWFkZXJzIiwKKyAgICBdLAorCisgICAgc2hhcmVkX2xpYnM6IFsKKyAgICAgICAgImxpYnN0YWdlZnJpZ2h0IiwKKyAgICAgICAgImxpYmxvZyIsCisgICAgICAgICJsaWJ1dGlscyIsCisgICAgICAgICJsaWJiaW5kZXIiLAorICAgICAgICAibGlic3RhZ2VmcmlnaHRfZm91bmRhdGlvbiIsCisgICAgICAgICJsaWJjdXRpbHMiLAorICAgICAgICAibGliYyIsCisgICAgXSwKKworICAgIGNmbGFnczogWworICAgICAgICAiLVduby1tdWx0aWNoYXIiLAorICAgIF0sCit9CmRpZmYgLS1naXQgYS9jbWRzL3N0YWdlZnJpZ2h0L0FuZHJvaWQubWsgYi9jbWRzL3N0YWdlZnJpZ2h0L0FuZHJvaWQubWsKZGVsZXRlZCBmaWxlIG1vZGUgMTAwNjQ0CmluZGV4IDgwM2M0YTQuLjAwMDAwMDAKLS0tIGEvY21kcy9zdGFnZWZyaWdodC9BbmRyb2lkLm1rCisrKyAvZGV2L251bGwKQEAgLTEsMjc2ICswLDAgQEAKLUxPQ0FMX1BBVEg6PSAkKGNhbGwgbXktZGlyKQotCi1pbmNsdWRlICQoQ0xFQVJfVkFSUykKLQotTE9DQUxfU1JDX0ZJTEVTOj0gICAgICAgXAotICAgICAgICBBdWRpb1BsYXllci5jcHAgXAotICAgICAgICBzdGFnZWZyaWdodC5jcHAgXAotICAgICAgICBqcGVnLmNwcCAgICAgICAgXAotICAgICAgICBTaW5lU291cmNlLmNwcAotCi1MT0NBTF9IRUFERVJfTElCUkFSSUVTIDo9IFwKLSAgICAgICAgbGlibWVkaWFtZXRyaWNzX2hlYWRlcnMgXAotCi1MT0NBTF9TSEFSRURfTElCUkFSSUVTIDo9IFwKLSAgICAgICAgbGlic3RhZ2VmcmlnaHQgbGlibWVkaWEgbGlibWVkaWFfY29kZWNsaXN0IGxpYnV0aWxzIGxpYmJpbmRlciBcCi0gICAgICA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ZhbHNlOworICAgIGludDMyX3QgcGl4ZWxGb3JtYXQgPSAwOyAgICAgICAgLy8gdGh1bWJuYWlsIHBpeGVsIGZvcm1hdAogICAgIFN0cmluZzggZHVtcFN0cmVhbUZpbGVuYW1lOwogICAgIGdOdW1SZXBldGl0aW9ucyA9IDE7CiAgICAgZ01heE51bUZyYW1lcyA9IDA7CkBAIC04MDAsNyArODA5LDcgQEAKICAgICBzcDxhbmRyb2lkOjpBTG9vcGVyPiBsb29wZXI7CiAKICAgICBpbnQgcmVzOwotICAgIHdoaWxlICgocmVzID0gZ2V0b3B0KGFyZ2MsIGFyZ3YsICJ2aGFxbjpsbTpiOml0c3JvdzprTjp4U1RkOkQ6IikpID49IDApIHsKKyAgICB3aGlsZSAoKHJlcyA9IGdldG9wdChhcmdjLCBhcmd2LCAidmhhcW46bG06YjppdHNyb3c6a046eFNUZDpEOlA6IikpID49IDApIHsKICAgICAgICAgc3dpdGNoIChyZXMpIHsKICAgICAgICAgICAgIGNhc2UgJ2EnOgogICAgICAgICAgICAgewpAQCAtODQxLDYgKzg1MCw3IEBACiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICB9CiAKKyAgICAgICAgICAgIGNhc2UgJ1AnOgogICAgICAgICAgICAgY2FzZSAnbSc6CiAgICAgICAgICAgICBjYXNlICduJzoKICAgICAgICAgICAgIGNhc2UgJ2InOgpAQCAtODU2LDYgKzg2Niw4IEBACiAgICAgICAgICAgICAgICAgICAgIGdOdW1SZXBldGl0aW9ucyA9IHg7CiAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChyZXMgPT0gJ20nKSB7CiAgICAgICAgICAgICAgICAgICAgIGdNYXhOdW1GcmFtZXMgPSB4OworICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAocmVzID09ICdQJykgeworICAgICAgICAgICAgICAgICAgICBwaXhlbEZvcm1hdCA9IHg7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgQ0hFQ0tfRVEocmVzLCAnYicpOwogICAgICAgICAgICAgICAgICAgICBnUmVwcm9kdWNlQnVnID0geDsKQEAgLTk3OCwyNCArOTkwLDcxIEBACiAgICAgICAgICAgICBjbG9zZShmZCk7CiAgICAgICAgICAgICBmZCA9IC0xOwogCisgICAgICAgICAgICB1aW50MzJfdCByZXRyaWV2ZXJQaXhlbEZvcm1hdCA9IEhBTF9QSVhFTF9GT1JNQVRfUkdCXzU2NTsKKyAgICAgICAgICAgIGlmIChwaXhlbEZvcm1hdCA9PSBQSVhFTF9GT1JNQVRfUkdCQV8xMDEwMTAyX0FTXzg4ODgpIHsKKyAgICAgICAgICAgICAgICByZXRyaWV2ZXJQaXhlbEZvcm1hdCA9IEhBTF9QSVhFTF9GT1JNQVRfUkdCQV8xMDEwMTAyOworICAgICAgICAgICAgfSBlbHNlIGlmIChwaXhlbEZvcm1hdCkgeworICAgICAgICAgICAgICAgIHJldHJpZXZlclBpeGVsRm9ybWF0ID0gcGl4ZWxGb3JtYXQ7CisgICAgICAgICAgICB9CiAgICAgICAgICAgICBzcDxJTWVtb3J5PiBtZW0gPQogICAgICAgICAgICAgICAgICAgICByZXRyaWV2ZXItPmdldEZyYW1lQXRUaW1lKC0xLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1lZGlhU291cmNlOjpSZWFkT3B0aW9uczo6U0VFS19QUkVWSU9VU19TWU5DLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIEhBTF9QSVhFTF9GT1JNQVRfUkdCXzU2NSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBmYWxzZSAvKm1ldGFPbmx5Ki8pOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHJpZXZlclBpeGVsRm9ybWF0LCBmYWxzZSAvKm1ldGFPbmx5Ki8pOwogCiAgICAgICAgICAgICBpZiAobWVtICE9IE5VTEwpIHsKICAgICAgICAgICAgICAgICBmYWlsZWQgPSBmYWxzZTsKLSAgICAgICAgICAgICAgICBwcmludGYoImdldEZyYW1lQXRUaW1lKCVzKSA9PiBPS1xuIiwgZmlsZW5hbWUpOworICAgICAgICAgICAgICAgIHByaW50ZigiZ2V0RnJhbWVBdFRpbWUoJXMpIGZvcm1hdD0lZCA9PiBPS1xuIiwgZmlsZW5hbWUsIHJldHJpZXZlclBpeGVsRm9ybWF0KTsKIAogICAgICAgICAgICAgICAgIFZpZGVvRnJhbWUgKmZyYW1lID0gKFZpZGVvRnJhbWUgKiltZW0tPnVuc2VjdXJlUG9pbnRlcigpOwogCi0gICAgICAgICAgICAgICAgQ0hFQ0tfRVEod3JpdGVKcGVnRmlsZSgiL3NkY2FyZC9vdXQuanBnIiwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcmFtZS0+Z2V0RmxhdHRlbmVkRGF0YSgpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyYW1lLT5tV2lkdGgsIGZyYW1lLT5tSGVpZ2h0KSwgMCk7CisgICAgICAgICAgICAgICAgaWYgKHBpeGVsRm9ybWF0KSB7CisgICAgICAgICAgICAgICAgICAgIGludCBicHAgPSAwOworICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHBpeGVsRm9ybWF0KSB7CisgICAgICAgICAgICAgICAgICAgIGNhc2UgSEFMX1BJWEVMX0ZPUk1BVF9SR0JfNTY1OgorICAgICAgICAgICAgICAgICAgICAgICAgYnBwID0gMjsKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICBjYXNlIFBJWEVMX0ZPUk1BVF9SR0JBXzEwMTAxMDJfQVNfODg4ODoKKyAgICAgICAgICAgICAgICAgICAgICAgIC8vIGNvbnZlcnQgUkdCQV8xMDEwMTAyIHRvIFJHQkFfODg4OAorICAgICAgICAgICAgICAgICAgICAgICAgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVpbnQzMl90ICpkYXRhID0gKHVpbnQzMl90ICopZnJhbWUtPmdldEZsYXR0ZW5lZERhdGEoKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aW50MzJfdCAqZW5kID0gZGF0YSArIGZyYW1lLT5tV2lkdGggKiBmcmFtZS0+bUhlaWdodDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKDsgZGF0YSA8IGVuZDsgKytkYXRhKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICpkYXRhID0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHBpY2sgb3V0IDgtYml0IFIsIEcsIEIgdmFsdWVzIGFuZCBtb3ZlIHRoZW0gdG8gdGhlCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBjb3JyZWN0IHBvc2l0aW9uCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoICgqZGF0YSAmICAgICAgMHgzZmMpID4+IDIpIHwgLy8gUgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKCAoKmRhdGEgJiAgICAweGZmMDAwKSA+PiA0KSB8IC8vIEcKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICggKCpkYXRhICYgMHgzZmMwMDAwMCkgPj4gNikgfCAvLyBCCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBwaWNrIG91dCAyLWJpdCBBIGFuZCBleHBhbmQgdG8gOC1iaXRzCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoKCgqZGF0YSAmIDB4YzAwMDAwMDApID4+IDYpICogMHg1NSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgICAgICAgICAgICBGQUxMVEhST1VHSF9JTlRFTkRFRDsKKworICAgICAgICAgICAgICAgICAgICBjYXNlIEhBTF9QSVhFTF9GT1JNQVRfUkdCQV8xMDEwMTAyOgorICAgICAgICAgICAgICAgICAgICBjYXNlIEhBTF9QSVhFTF9GT1JNQVRfUkdCQV84ODg4OgorICAgICAgICAgICAgICAgICAgICBjYXNlIEhBTF9QSVhFTF9GT1JNQVRfQkdSQV84ODg4OgorICAgICAgICAgICAgICAgICAgICAgICAgYnBwID0gNDsKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIGlmIChicHApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIEZJTEUgKm91dCA9IGZvcGVuKCIvc2RjYXJkL291dC5yYXciLCAid2IiKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGZ3cml0ZShmcmFtZS0+Z2V0RmxhdHRlbmVkRGF0YSgpLCBicHAgKiBmcmFtZS0+bVdpZHRoLCBmcmFtZS0+bUhlaWdodCwgb3V0KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGZjbG9zZShvdXQpOworCisgICAgICAgICAgICAgICAgICAgICAgICBwcmludGYoIndyaXRlIG91dCAlZCB4ICVkIHggJWRicHBcbiIsIGZyYW1lLT5tV2lkdGgsIGZyYW1lLT5tSGVpZ2h0LCBicHApOworICAgICAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRmKCJ1bmtub3duIHBpeGVsIGZvcm1hdC5cbiIpOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgQ0hFQ0tfRVEod3JpdGVKcGVnRmlsZSgiL3NkY2FyZC9vdXQuanBnIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJhbWUtPmdldEZsYXR0ZW5lZERhdGEoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJhbWUtPm1XaWR0aCwgZnJhbWUtPm1IZWlnaHQpLCAwKTsKKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAKLSAgICAgICAgICAgIHsKKyAgICAgICAgICAgIGlm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Y2sgYXMgY291bnQgb2YgZW51bSBlbGVtZW50cyBhcmUgMgorICAgIHN3aXRjaChidWZmZXIudHlwZSkgeworICAgICAgICBjYXNlIEJ1ZmZlclR5cGVIaWRsOjpTSEFSRURfTUVNT1JZOgorICAgICAgICAgICAgYWlkbGRiLnNldDxEZXN0aW5hdGlvbkJ1ZmZlckFpZGw6OlRhZzo6bm9uc2VjdXJlTWVtb3J5PigKKyAgICAgICAgICAgICAgICBoaWRsU2hhcmVkQnVmZmVyVG9BaWRsU2hhcmVkQnVmZmVyKGJ1ZmZlci5ub25zZWN1cmVNZW1vcnkpKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgYXV0byBoYW5kbGUgPSBidWZmZXIuc2VjdXJlTWVtb3J5LmdldE5hdGl2ZUhhbmRsZSgpOworICAgICAgICAgICAgaWYgKGhhbmRsZSkgeworICAgICAgICAgICAgICAgIGFpZGxkYi5zZXQ8RGVzdGluYXRpb25CdWZmZXJBaWRsOjpUYWc6OnNlY3VyZU1lbW9yeT4oCisgICAgICAgICAgICAgICAgICAgIDo6YW5kcm9pZDo6ZHVwVG9BaWRsKGhhbmRsZSkpOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICBOYXRpdmVIYW5kbGVBaWRsQ29tbW9uIGVtcHR5aGFuZGxlOworICAgICAgICAgICAgICAgIGFpZGxkYi5zZXQ8RGVzdGluYXRpb25CdWZmZXJBaWRsOjpUYWc6OnNlY3VyZU1lbW9yeT4oCisgICAgICAgICAgICAgICAgICAgIHN0ZDo6bW92ZShlbXB0eWhhbmRsZSkpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgYnJlYWs7CisgICAgfQorCisgICAgcmV0dXJuIGFpZGxkYjsKK30KKworc3RhdGljIGhpZGxfdmVjPHVpbnQ4X3Q+IHRvSGlkbFZlYyhjb25zdCB2b2lkKiBwdHIsIHNpemVfdCBzaXplKSB7CisgICAgaGlkbF92Z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itDcnlwdG9IYWxIaWRsOjp+Q3J5cHRvSGFsSGlkbCgpIHt9CisKK1ZlY3RvcjxzcDxJQ3J5cHRvRmFjdG9yeT4+IENyeXB0b0hhbEhpZGw6Om1ha2VDcnlwdG9GYWN0b3JpZXMoKSB7CisgICAgVmVjdG9yPHNwPElDcnlwdG9GYWN0b3J5Pj4gZmFjdG9yaWVzOworCisgICAgYXV0byBtYW5hZ2VyID0gaGFyZHdhcmU6OmRlZmF1bHRTZXJ2aWNlTWFuYWdlcjFfMigpOworICAgIGlmIChtYW5hZ2VyICE9IE5VTEwpIHsKKyAgICAgICAgbWFuYWdlci0+bGlzdE1hbmlmZXN0QnlJbnRlcmZhY2UoCisgICAgICAgICAgICAgICAgZHJtOjpWMV8wOjpJQ3J5cHRvRmFjdG9yeTo6ZGVzY3JpcHRvciwKKyAgICAgICAgICAgICAgICBbJmZhY3Rvcmllc10oY29uc3QgaGlkbF92ZWM8aGlkbF9zdHJpbmc+JiByZWdpc3RlcmVkKSB7CisgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgYXV0byYgaW5zdGFuY2UgOiByZWdpc3RlcmVkKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBhdXRvIGZhY3RvcnkgPSBkcm06OlYxXzA6OklDcnlwdG9GYWN0b3J5OjpnZXRTZXJ2aWNlKGluc3RhbmNlKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmYWN0b3J5ICE9IE5VTEwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBBTE9HRCgiZm91bmQgZHJtQDEuMCBJQ3J5cHRvRmFjdG9yeSAlcyIsIGluc3RhbmNlLmNfc3RyKCkpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZhY3Rvcmllcy5wdXNoX2JhY2soZmFjdG9yeSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9KTsKKyAgICAgICAgbWFuYWdlci0+bGlzdE1hbmlmZXN0QnlJbnRlcmZhY2UoCisgICAgICAgICAgICAgICAgZHJtOjpWMV8xOjpJQ3J5cHRvRmFjdG9yeTo6ZGVzY3JpcHRvciwKKyAgICAgICAgICAgICAgICBbJmZhY3Rvcmllc10oY29uc3QgaGlkbF92ZWM8aGlkbF9zdHJpbmc+JiByZWdpc3RlcmVkKSB7CisgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgYXV0byYgaW5zdGFuY2UgOiByZWdpc3RlcmVkKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBhdXRvIGZhY3RvcnkgPSBkcm06OlYxXzE6OklDcnlwdG9GYWN0b3J5OjpnZXRTZXJ2aWNlKGluc3RhbmNlKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmYWN0b3J5ICE9IE5VTEwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBBTE9HRCgiZm91bmQgZHJtQDEuMSBJQ3J5cHRvRmFjdG9yeSAlcyIsIGluc3RhbmNlLmNfc3RyKCkpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZhY3Rvcmllcy5wdXNoX2JhY2soZmFjdG9yeSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9KTsKKyAgICB9CisKKyAgICBpZiAoZmFjdG9yaWVzLnNpemUoKSA9PSAwKSB7CisgICAgICAgIC8vIG11c3QgYmUgaW4gcGFzc3Rocm91Z2ggbW9kZSwgbG9hZCB0aGUgZGVmYXVsdCBwYXNzdGhyb3VnaCBzZXJ2aWNlCisgICAgICAgIGF1dG8gcGFzc3Rocm91Z2ggPSBJQ3J5cHRvRmFjdG9yeTo6Z2V0U2VydmljZSgpOworICAgICAgICBpZiAocGFzc3Rocm91Z2ggIT0gTlVMTCkgeworICAgICAgICAgICAgQUxPR0koIm1ha2VDcnlwdG9GYWN0b3JpZXM6IHVzaW5nIGRlZmF1bHQgcGFzc3Rocm91Z2ggY3J5cHRvIGluc3RhbmNlIik7CisgICAgICAgICAgICBmYWN0b3JpZXMucHVzaF9iYWNrKHBhc3N0aHJvdWdoKTsKKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIEFMT0dFKCJGYWlsZWQgdG8gZmluZCBhbnkgY3J5cHRvIGZhY3RvcmllcyIpOworICAgICAgICB9CisgICAgfQorICAgIHJldHVybiBmYWN0b3JpZXM7Cit9CisKK3NwPElDcnlwdG9QbHVnaW4+IENyeXB0b0hhbEhpZGw6Om1ha2VDcnlwdG9QbHVnaW4oY29uc3Qgc3A8SUNyeXB0b0ZhY3Rvcnk+JiBmYWN0b3J5LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1aW50OF90IHV1aWRbMTZdLCBjb25zdCB2b2lkKiBpbml0RGF0YSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90IGluaXREYXRhU2l6ZSkgeworICAgIHNwPElDcnlwdG9QbHVnaW4+IHBsdWdpbjsKKyAgICBSZXR1cm48dm9pZD4gaFJlc3VsdCA9CisgICAgICAgICAgICBmYWN0b3J5LT5jcmVhdGVQbHVnaW4odG9IaWRsQXJyYXkxNih1dWlkKSwgdG9IaWRsVmVjKGluaXREYXRhLCBpbml0RGF0YVNpemUpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFsmXShTdGF0dXMgc3RhdHVzLCBjb25zdCBzcDxJQ3J5cHRvUGx1Z2luPiYgaFBsdWdpbikgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdHVzICE9IFN0YXR1czo6T0spIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFMT0dFKCJGYWlsZWQgdG8gbWFrZSBjcnlwdG8gcGx1Z2luIik7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGx1Z2luID0gaFBsdWdpbjsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKKyAgICBpZiAoIWhSZXN1bHQuaXNPaygpKSB7CisgICAgICAgIG1Jbml0Q2hlY2sgPSBERUFEX09CSkVDVDsKKyAgICB9CisgICAgcmV0dXJuIHBsdWdpbjsKK30KKworc3RhdHVzX3QgQ3J5cHRvSGFsSGlkbDo6aW5pdENoZWNrKCkgY29uc3QgeworICAgIHJldHVybiBtSW5pdENoZWNrOworfQorCitib29sIENyeXB0b0hhbEhpZGw6OmlzQ3J5cHRvU2NoZW1lU3VwcG9ydGVkKGNvbnN0IHVpbnQ4X3QgdXVpZFsxNl0pIHsKKyAgICBNdXRleDo6QXV0b2xvY2sgYXV0b0xvY2sobUxvY2spOworCisgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCBtRmFjdG9yaWVzLnNpemUoKTsgaSsrKSB7CisgICAgICAgIGlmIChtRmFjdG9yaWVzW2ldLT5pc0NyeXB0b1NjaGVtZVN1cHBvcnRlZCh1dWlkKSkgeworICAgICAgICAgICAgcmV0dXJuIHRydWU7CisgICAgICAgIH0KKyAgICB9CisgICAgcmV0dXJuIGZhbHNlOworfQorCitzdGF0dXNfdCBDcnlwdG9IYWxIaWRsOjpjcmVhdGVQbHVnaW4oY29uc3QgdWludDhfdCB1dWlkWzE2XSwgY29uc3Qgdm9pZCogZGF0YSwgc2l6ZV90IHNpemUpIHsKKyAgICBNdXRleDo6QXV0b2xvY2sgYXV0b0xvY2sobUxvY2spOworCisgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCBtRmFjdG9yaWVzLnNpemUoKTsgaSsrKSB7CisgICAgICAgIGlmIChtRmFjdG9yaWVzW2ldLT5pc0NyeXB0b1NjaGVtZVN1cHBvcnRlZCh1dWlkKSkgeworICAgICAgICAgICAgbVBsdWdpbiA9IG1ha2VDcnlwdG9QbHVnaW4obUZhY3Rvcmllc1tpXSwgdXVpZCwgZGF0YSwgc2l6ZSk7CisgICAgICAgICAgICBpZiAobVBsdWdpbiAhPSBOVUxMKSB7CisgICAgICAgICAgICAgICAgbVBsdWdpblYxXzIgPSBkcm06OlYxXzI6OklDcnlwdG9QbHVnaW46OmNhc3RGcm9tKG1QbHVnaW4pOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgfQorCisgICAgaWYgKG1Jbml0Q2hlY2sgPT0gTk9fSU5JVCkgeworICAgICAgICBtSW5pdENoZWNrID0gbVBsdWdpbiA9PSBOVUxMID8gRVJST1JfVU5TVVBQT1JURUQgOiBPSzsKKyAgICB9CisKKyAgICByZXR1cm4gbUluaXRDaGVjazsKK30KKworc3RhdHVzX3QgQ3J5cHRvSGFsSGlkbDo6ZGVzdHJveVBsdWdpbigpIHsKKyAgICBNdXRleDo6QXV0b2xvY2sgYXV0b0xvY2sobUxvY2spOworCisgICAgaWYgKG1Jbml0Q2hlY2sgIT0gT0spIHsKKyAgICAgICAgcmV0dXJuIG1Jbml0Q2hlY2s7CisgICAgfQorCisgICAgbVBsdWdpbi5jbGVhcigpOworICAgIG1QbHVnaW5WMV8yLmNsZWFyKCk7CisgICAgbUluaXRDaGVjayA9IE5PX0lOSVQ7CisgICAgcmV0dXJuIE9LOworfQorCitib29sIENyeXB0b0hhbEhpZGw6OnJlcXVpcmVzU2VjdXJlRGVjb2RlckNvbXBvbmVudChjb25zdCBjaGFyKiBtaW1lKSBjb25zdCB7CisgICAgTXV0ZXg6OkF1dG9sb2NrIGF1dG9Mb2NrKG1Mb2NrKTsKKworICAgIGlmIChtSW5pdENoZWNrICE9IE9LKSB7CisgICAgICAgIHJldHVybiBmYWxzZTsKKyAgICB9CisKKyAgICBSZXR1cm48Ym9vbD4gaFJlc3VsdCA9IG1QbHVnaW4tPnJlcXVpcmVzU2VjdXJlRGVj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AgICAgICAgICAgICBDcnlwdG9QbHVnaW46Ok1vZGUgbW9kZSwgY29uc3QgQ3J5cHRvUGx1Z2luOjpQYXR0ZXJuJiBwYXR0ZXJuLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRybTo6VjFfMDo6U2hhcmVkQnVmZmVyJiBoU291cmNlLCBzaXplX3Qgb2Zmc2V0LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IENyeXB0b1BsdWdpbjo6U3ViU2FtcGxlKiBzdWJTYW1wbGVzLCBzaXplX3QgbnVtU3ViU2FtcGxlcywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkcm06OlYxXzA6OkRlc3RpbmF0aW9uQnVmZmVyJiBoRGVzdGluYXRpb24sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQVN0cmluZyogZXJyb3JEZXRhaWxNc2cpIHsKKyAgICBNdXRleDo6QXV0b2xvY2sgYXV0b0xvY2sobUxvY2spOworCisgICAgaWYgKG1Jbml0Q2hlY2sgIT0gT0spIHsKKyAgICAgICAgcmV0dXJuIG1Jbml0Q2hlY2s7CisgICAgfQorCisgICAgTW9kZSBoTW9kZTsKKyAgICBzd2l0Y2ggKG1vZGUpIHsKKyAgICAgICAgY2FzZSBDcnlwdG9QbHVnaW46OmtNb2RlX1VuZW5jcnlwdGVkOgorICAgICAgICAgICAgaE1vZGUgPSBNb2RlOjpVTkVOQ1JZUFRFRDsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIENyeXB0b1BsdWdpbjo6a01vZGVfQUVTX0NUUjoKKyAgICAgICAgICAgIGhNb2RlID0gTW9kZTo6QUVTX0NUUjsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIENyeXB0b1BsdWdpbjo6a01vZGVfQUVTX1dWOgorICAgICAgICAgICAgaE1vZGUgPSBNb2RlOjpBRVNfQ0JDX0NUUzsKKyAgICAgICAgICAgIGJyZW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kpOworICAgICAgICBpZiAoc3RhdHVzICE9IE9LKSB7CisgICAgICAgICAgICByZXR1cm4gc3RhdHVzOworICAgICAgICB9CisgICAgICAgIHNlY3VyZSA9IGZhbHNlOworICAgIH0gZWxzZSBpZiAoaERlc3RpbmF0aW9uLnR5cGUgPT0gQnVmZmVyVHlwZTo6TkFUSVZFX0hBTkRMRSkgeworICAgICAgICBzZWN1cmUgPSB0cnVlOworICAgIH0gZWxzZSB7CisgICAgICAgIGFuZHJvaWRfZXJyb3JXcml0ZUxvZygweDUzNGU0NTU0LCAiNzA1MjY3MDIiKTsKKyAgICAgICAgcmV0dXJuIFVOS05PV05fRVJST1I7CisgICAgfQorCisgICAgc3RhdHVzX3Qgc3RhdHVzID0gY2hlY2tTaGFyZWRCdWZmZXIoaFNvdXJjZSk7CisgICAgaWYgKHN0YXR1cyAhPSBPSykgeworICAgICAgICByZXR1cm4gc3RhdHVzOworICAgIH0KKworICAgIHN0YXR1c190IGVyciA9IFVOS05PV05fRVJST1I7CisgICAgdWludDMyX3QgYnl0ZXNXcml0dGVuID0gMDsKKworICAgIFJldHVybjx2b2lkPiBoUmVzdWx0OworCisgICAgbUxvY2sudW5sb2NrKCk7CisgICAgaWYgKG1QbHVnaW5WMV8yICE9IE5VTEwpIHsKKyAgICAgICAgaFJlc3VsdCA9IG1QbHVnaW5WMV8yLT5kZWNyeXB0XzFfMigKKyAgICAgICAgICAgICAgICBzZWN1cmUsIHRvSGlkbEFycmF5MTYoa2V5SWQpLCB0b0hpZGxBcnJheTE2KGl2KSwgaE1vZGUsIGhQYXR0ZXJuLCBoU3ViU2FtcGxlcywKKyAgICAgICAgICAgICAgICBoU291cmNlLCBvZmZzZXQsIGhEZXN0aW5hdGlvbiwKKyAgICAgICAgICAgICAgICBbJl0oU3RhdHVzX1YxXzIgc3RhdHVzLCB1aW50MzJfdCBoQnl0ZXNXcml0dGVuLCBoaWRsX3N0cmluZyBoRGV0YWlsZWRFcnJvcikgeworICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdHVzID09IFN0YXR1c19WMV8yOjpPSykgeworICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZXNXcml0dGVuID0gaEJ5dGVzV3JpdHRlbjsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnJvckRldGFpbE1zZyAhPSBudWxscHRyKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgKmVycm9yRGV0YWlsTXNnID0gdG9TdHJpbmc4KGhEZXRhaWxlZEVycm9yKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICBlcnIgPSB0b1N0YXR1c1Qoc3RhdHVzKTsKKyAgICAgICAgICAgICAgICB9KTsKKyAgICB9IGVsc2UgeworICAgICAgICBoUmVzdWx0ID0gbVBsdWdpbi0+ZGVjcnlwdCgKKyAgICAgICAgICAgICAgICBzZWN1cmUsIHRvSGlkbEFycmF5MTYoa2V5SWQpLCB0b0hpZGxBcnJheTE2KGl2KSwgaE1vZGUsIGhQYXR0ZXJuLCBoU3ViU2FtcGxlcywKKyAgICAgICAgICAgICAgICBoU291cmNlLCBvZmZzZXQsIGhEZXN0aW5hdGlvbiwKKyAgICAgICAgICAgICAgICBbJl0oU3RhdHVzIHN0YXR1cywgdWludDMyX3QgaEJ5dGVzV3JpdHRlbiwgaGlkbF9zdHJpbmcgaERldGFpbGVkRXJyb3IpIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXR1cyA9PSBTdGF0dXM6Ok9LKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBieXRlc1dyaXR0ZW4gPSBoQnl0ZXNXcml0dGVuOworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycm9yRGV0YWlsTXNnICE9IG51bGxwdHIpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAqZXJyb3JEZXRhaWxNc2cgPSB0b1N0cmluZzgoaERldGFpbGVkRXJyb3IpOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIGVyciA9IHRvU3RhdHVzVChzdGF0dXMpOworICAgICAgICAgICAgICAgIH0pOworICAgIH0KKworICAgIGVyciA9IGhSZXN1bHQuaXNPaygpID8gZXJyIDogREVBRF9PQkpFQ1Q7CisgICAgaWYgKGVyciA9PSBPSykgeworICAgICAgICByZXR1cm4gYnl0ZXNXcml0dGVuOworICAgIH0KKyAgICByZXR1cm4gZXJyOworfQorCit2b2lkIENyeXB0b0hhbEhpZGw6Om5vdGlmeVJlc29sdXRpb24odWludDMyX3Qgd2lkdGgsIHVpbnQzMl90IGhlaWdodCkgeworICAgIE11dGV4OjpBdXRvbG9jayBhdXRvTG9jayhtTG9jayk7CisKKyAgICBpZiAobUluaXRDaGVjayAhPSBPSykgeworICAgICAgICByZXR1cm47CisgICAgfQorCisgICAgYXV0byBoUmVzdWx0ID0gbVBsdWdpbi0+bm90aWZ5UmVzb2x1dGlvbih3aWR0aCwgaGVpZ2h0KTsKKyAgICBBTE9HRV9JRighaFJlc3VsdC5pc09rKCksICJub3RpZnlSZXNvbHV0aW9uIHR4biBmYWlsZWQgJXMiLCBoUmVzdWx0LmRlc2NyaXB0aW9uKCkuY19zdHIoKSk7Cit9CisKK3N0YXR1c190IENyeXB0b0hhbEhpZGw6OnNldE1lZGlhRHJtU2Vzc2lvbihjb25zdCBWZWN0b3I8dWludDhfdD4mIHNlc3Npb25JZCkgeworICAgIE11dGV4OjpBdXRvbG9jayBhdXRvTG9jayhtTG9jayk7CisKKyAgICBpZiAobUluaXRDaGVjayAhPSBPSykgeworICAgICAgICByZXR1cm4gbUluaXRDaGVjazsKKyAgICB9CisKKyAgICBhdXRvIGVyciA9IG1QbHVnaW4tPnNldE1lZGlhRHJtU2Vzc2lvbih0b0hpZGxWZWMoc2Vzc2lvbklkKSk7CisgICAgcmV0dXJuIGVyci5pc09rKCkgPyB0b1N0YXR1c1QoZXJyKSA6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dGF0dXNUeXBlX1VzYWJsZTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIGNhc2UgS2V5U3RhdHVzVHlwZTo6RVhQSVJFRDoKLSAgICAgICAgICAgICAgICB0eXBlID0gRHJtUGx1Z2luOjprS2V5U3RhdHVzVHlwZV9FeHBpcmVkOwotICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgY2FzZSBLZXlTdGF0dXNUeXBlOjpPVVRQVVROT1RBTExPV0VEOgotICAgICAgICAgICAgICAgIHR5cGUgPSBEcm1QbHVnaW46OmtLZXlTdGF0dXNUeXBlX091dHB1dE5vdEFsbG93ZWQ7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICBjYXNlIEtleVN0YXR1c1R5cGU6OlNUQVRVU1BFTkRJTkc6Ci0gICAgICAgICAgICAgICAgdHlwZSA9IERybVBsdWdpbjo6a0tleVN0YXR1c1R5cGVfU3RhdHVzUGVuZGluZzsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIGNhc2UgS2V5U3RhdHVzVHlwZTo6VVNBQkxFSU5GVVRVUkU6Ci0gICAgICAgICAgICAgICAgdHlwZSA9IERybVBsdWdpbjo6a0tleVN0YXR1c1R5cGVfVXNhYmxlSW5GdXR1cmU7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICBjYXNlIEtleVN0YXR1c1R5cGU6OklOVEVSTkFMRVJST1I6Ci0gICAgICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAgICAgIHR5cGUgPSBEcm1QbHVnaW46OmtLZXlTdGF0dXNUeXBlX0ludGVybmFsRXJyb3I7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBrZXlTdGF0dXNMaXN0LnB1c2hfYmFjayh7dHlwZSwga2V5U3RhdHVzLmtleUlkfSk7Ci0gICAgICAgICAgICBtTWV0cmljcy5tS2V5U3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2lvbklkKTsKLSAgICB9Ci0gICAgcmV0dXJuIFZvaWQoKTsKLX0KLQotc3RhdHVzX3QgRHJtSGFsOjptYXRjaE1pbWVUeXBlQW5kU2VjdXJpdHlMZXZlbChjb25zdCBzcDxJRHJtRmFjdG9yeT4gJmZhY3RvcnksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVpbnQ4X3QgdXVpZFsxNl0sCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFN0cmluZzggJm1pbWVUeXBlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBEcm1QbHVnaW46OlNlY3VyaXR5TGV2ZWwgbGV2ZWwsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgKmlzU3VwcG9ydGVkKSB7Ci0gICAgKmlzU3VwcG9ydGVkID0gZmFsc2U7Ci0KLSAgICAvLyBoYW5kbGUgZGVmYXVsdCB2YWx1ZSBjYXNlcwotICAgIGlmIChsZXZlbCA9PSBEcm1QbHVnaW46OmtTZWN1cml0eUxldmVsVW5rbm93bikgewotICAgICAgICBpZiAobWltZVR5cGUgPT0gIiIpIHsKLSAgICAgICAgICAgIC8vIGlzQ3J5cHRvU2NoZW1lU3VwcG9ydGVkKHV1aWQpCi0gICAgICAgICAgICAqaXNTdXBwb3J0ZWQgPSB0cnVlOwotICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgLy8gaXNDcnlwdG9TY2hlbWVTdXBwb3J0ZWQodXVpZCwgbWltZVR5cGUpCi0gICAgICAgICAgICAqaXNTdXBwb3J0ZWQgPSBmYWN0b3J5LT5pc0NvbnRlbnRUeXBlU3VwcG9ydGVkKG1pbWVUeXBlLnN0cmluZygpKTsKLSAgICAgICAgfQotICAgICAgICByZXR1cm4gT0s7Ci0gICAgfSBlbHNlIGlmIChtaW1lVHlwZS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HJtUGx1Z2luOjpjYXN0RnJvbShtUGx1Z2luKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLSAgICAgICAgfQotICAgIH0KLQotICAgIGlmIChtUGx1Z2luID09IE5VTEwpIHsKLSAgICAgICAgRHJtVXRpbHM6OkxPRzJCRSh1dWlkLCAiTm8gc3VwcG9ydGVkIGhhbCBpbnN0YW5jZSBmb3VuZCIpOwotICAgICAgICBtSW5pdENoZWNrID0gRVJST1JfVU5TVVBQT1JURUQ7Ci0gICAgfSBlbHNlIHsKLSAgICAgICAgbUluaXRDaGVjayA9IE9LOwotICAgICAgICBpZiAobVBsdWdpblYxXzIgIT0gTlVMTCkgewotICAgICAgICAgICAgaWYgKCFtUGx1Z2luVjFfMi0+c2V0TGlzdGVuZXIodGhpcykuaXNPaygpKSB7Ci0gICAgICAgICAgICAgICAgbUluaXRDaGVjayA9IERFQURfT0JKRUNUOwotICAgICAgICAgICAgfQotICAgICAgICB9IGVsc2UgaWYgKCFtUGx1Z2luLT5zZXRMaXN0ZW5lcih0aGlzKS5pc09rKCkpIHsKLSAgICAgICAgICAgIG1Jbml0Q2hlY2sgPSBERUFEX09CSkVDVDsKLSAgICAgICAgfQotICAgICAgICBpZiAobUluaXRDaGVjayAhPSBPSykgewotICAgICAgICAgICAgbVBsdWdpbi5jbGVhcigpOwotICAgICAgICAgICAgbVBsdWdpblYxXzEuY2xlYXIoKTsKLSAgICAgICAgICAgIG1QbHVnaW5WMV8yLmNsZWFyKCk7Ci0gICAgICAgICAgICBtUGx1Z2luVjFfNC5jbGVhcigpOwotICAgICAgICB9Ci0gICAgfQotCi0KLSAgICByZXR1cm4gbUluaXRDaGVjazsKK3N0YXR1c190IERybUhhbDo6Y3JlYXRlUGx1Z2luKGNvbnN0IHVpbnQ4X3QgdXVpZFsxNl0sIGNvbnN0IFN0cmluZzgmIGFwcFBhY2thZ2VOYW1lKSB7CisgICAgc3RhdHVzX3Qgc3RhdHVzUmVzdWx0Owor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KLSAgICAgICAgaWYgKGhTZWN1cml0eUxldmVsID09IFNlY3VyaXR5TGV2ZWw6OlVOS05PV04pIHsKLSAgICAgICAgICAgIHJldHVybiBFUlJPUl9EUk1fQ0FOTk9UX0hBTkRMRTsKLSAgICAgICAgfQotICAgIH0KLQotICAgIHN0YXR1c190ICBlcnIgPSBVTktOT1dOX0VSUk9SOwotICAgIGJvb2wgcmV0cnkgPSB0cnVlOwotICAgIGRvIHsKLSAgICAgICAgaGlkbF92ZWM8dWludDhfdD4gaFNlc3Npb25JZDsKLQotICAgICAgICBSZXR1cm48dm9pZD4gaFJlc3VsdDsKLSAgICAgICAgaWYgKG1QbHVnaW5WMV8xID09IE5VTEwgfHwgIXNldFNlY3VyaXR5TGV2ZWwpIHsKLSAgICAgICAgICAgIGhSZXN1bHQgPSBtUGx1Z2luLT5vcGVuU2Vzc2lvbigKLSAgICAgICAgICAgICAgICAgICAgWyZdKFN0YXR1cyBzdGF0dXMsY29uc3QgaGlkbF92ZWM8dWludDhfdD4mIGlkKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdHVzID09IFN0YXR1czo6T0spIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXNzaW9uSWQgPSB0b1ZlY3RvcihpZCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgICAgICBlcnIgPSB0b1N0YXR1c1Qoc3RhdHVzKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICk7Ci0gICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBoUmVzdWx0ID0gbVBsdWdpblYxXzEtPm9wZW5TZXNzaW9uXzFfMShoU2VjdXJpdHlMZXZlbCwKLSAgICAgICAgICAgICAgICAgICAgWyZdKFN0YXR1cyBzdGF0dXMsIGNvbnN0IGhpZGxfdmVjPHVpbnQ4X3Q+JiBpZCkgewotICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXR1cyA9PSBTdGF0dXM6Ok9LKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2Vzc2lvbklkID0gdG9WZWN0b3IoaWQpOwotICAgICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICAgICAgZXJyID0gdG9TdGF0dXNUKHN0YXR1cyk7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICApOwotICAgICAgICB9Ci0KLSAgICAgICAgaWYgKCFoUmVzdWx0LmlzT2soKSkgewotICAgICAgICAgICAgZXJyID0gREVBRF9PQkpFQ1Q7Ci0gICAgICAgIH0KLQotICAgICAgICBpZiAoZXJyID09IEVSUk9SX0RSTV9SRVNPVVJDRV9CVVNZICYmIHJldHJ5KSB7Ci0gICAgICAgICAgICBtTG9jay51bmxvY2soKTsKLSAgICAgICAgICAgIC8vIHJlY2xhaW1TZXNzaW9uIG1heSBjYWxsIGJhY2sgdG8gY2xvc2VTZXNzaW9uLCBzaW5jZSBtTG9jayBpcwotICAgICAgICAgICAgLy8gc2hhcmVkIGJldHdlZW4gRHJtIGluc3RhbmNlcywgd2Ugc2hvdWxkIHVubG9jayBoZXJlIHRvIGF2b2lkCi0gICAgICAgICAgICAvLyBkZWFkbG9jay4KLSAgICAgICAgICAgIHJldHJ5ID0gRHJtU2Vzc2lvbk1hbmFnZXI6Okluc3RhbmNlKCktPnJlY2xhaW1TZXNzaW9uKEFJQmluZGVyX2dldENhbGxpbmdQaWQoKSk7Ci0gICAgICAgICAgICBtTG9jay5sb2NrKCk7Ci0gICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICByZXRyeSA9IGZhbHNlOwotICAgICAgICB9Ci0gICAgfSB3aGlsZSAocmV0cnkpOwotCi0gICAgaWYgKGVyciA9PSBPSykgewotICAgICAgICBzdGQ6OnNoYXJlZF9wdHI8RHJtU2Vzc2lvbkNsaWVudD4gY2xpZW50ID0KLSAgICAgICAgICAgICAgICBuZGs6OlNoYXJlZFJlZ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0gICAgICAgICAgICAgICAgfSk7Ci0gICAgfSBlbHNlIGlmIChtUGx1Z2luVjFfMSAhPSBOVUxMKSB7Ci0gICAgICAgIGhSZXN1bHQgPSBtUGx1Z2luVjFfMS0+Z2V0S2V5UmVxdWVzdF8xXzEoCi0gICAgICAgICAgICAgICAgdG9IaWRsVmVjKHNlc3Npb25JZCksIHRvSGlkbFZlYyhpbml0RGF0YSksCi0gICAgICAgICAgICAgICAgdG9IaWRsU3RyaW5nKG1pbWVUeXBlKSwgaEtleVR5cGUsIGhPcHRpb25hbFBhcmFtZXRlcnMsCi0gICAgICAgICAgICAgICAgWyZdKFN0YXR1cyBzdGF0dXMsIGNvbnN0IGhpZGxfdmVjPHVpbnQ4X3Q+JiBoUmVxdWVzdCwKLSAgICAgICAgICAgICAgICAgICAgICAgIEtleVJlcXVlc3RUeXBlX1YxXzEgaEtleVJlcXVlc3RUeXBlLAotICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGlkbF9zdHJpbmcmIGhEZWZhdWx0VXJsKSB7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChzdGF0dXMgPT0gU3RhdHVzOjpPSykgewotICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdCA9IHRvVmVjdG9yKGhSZXF1ZXN0KTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHRVcmwgPSB0b1N0cmluZzgoaERlZmF1bHRVcmwpOwotICAgICAgICAgICAgICAgICAgICAgICAgKmtleVJlcXVlc3RUeXBlID0gdG9LZXlSZXF1ZXN0VHlwZV8xXzEoaEtleVJlcXVlc3RUeXBlKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBlcnIgPSB0b1N0YXR1c1Qoc3RhdHVzKTsKLSAgICAgICAgICAgICAgICB9KTsKLSAgICB9IGVsc2UgewotICAgICAgICBoUmVzdWx0ID0gbVBsdWdpbi0+Z2V0S2V5UmVxdWVzdCgKLSAgICAgICAgICAgICAgICB0b0hpZGxWZWMoc2Vzc2lvbklkKSwgdG9IaWRsVmVjKGluaXREYXRhKSwKLSAgICAgICAgICAgICAgICB0b0hpZGxTdHJpbmcobWltZVR5cGUpLCBoS2V5VHlwZSwgaE9wdGlvbmFsUGFyYW1ldGVycywKLSAgICAgICAgICAgICAgICBbJl0oU3RhdHVzIHN0YXR1cywgY29uc3QgaGlkbF92ZWM8dWludDhfdD4mIGhSZXF1ZXN0LAotICAgICAgICAgICAgICAgICAgICAgICAgS2V5UmVxdWVzdFR5cGUgaEtleVJlcXVlc3RUeXBlLAotICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGlkbF9zdHJpbmcmIGhEZWZhdWx0VXJsKSB7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChzdGF0dXMgPT0gU3RhdHVzOjpPSykgewotICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdCA9IHRvVmVjdG9yKGhSZXF1ZXN0KTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHRVcmwgPSB0b1N0cmluZzgoaERlZmF1bHRVcmwpOwotICAgICAgICAgICAgICAgICAgICAgICAgKmtleVJlcXVlc3RUeXBlID0gdG9LZXlSZXF1ZXN0VHlwZShoS2V5UmVxdWVzdFR5cGUpOwotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIGVyciA9IHRvU3RhdHVzVChzdGF0dXMpOwotICAgICAgICAgICAgICAgIH0pOwotICAgIH0KLQotICAgIGVyciA9IGhSZXN1bHQuaXNPaygpID8gZXJyIDogREVBRF9PQkpFQ1Q7Ci0gICAga2V5UmVxdWVzdFRpbWVyLlNldEF0dHJpYnV0ZShlcnIpOwotICAgIHJldHVybiBlcnI7CitzdGF0dXNfdCBEcm1IYWw6OnJlbW92ZUtleXMoVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0JiBrZXlTZXRJZCkgeworICAgIGlmIChtRHJtSGFsQWlkbC0+aW5pdENoZWNrKCkgPT0gT0spIHJldH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NlcnRBdXRob3JpdHkpLAotICAgICAgICAgICAgICAgIFsmXShTdGF0dXNfVjFfMiBzdGF0dXMsIGNvbnN0IGhpZGxfdmVjPHVpbnQ4X3Q+JiBoUmVxdWVzdCwKLSAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhpZGxfc3RyaW5nJiBoRGVmYXVsdFVybCkgewotICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdHVzID09IFN0YXR1c19WMV8yOjpPSykgewotICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdCA9IHRvVmVjdG9yKGhSZXF1ZXN0KTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHRVcmwgPSB0b1N0cmluZzgoaERlZmF1bHRVcmwpOwotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIGVyciA9IHRvU3RhdHVzVChzdGF0dXMpOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICk7Ci0gICAgfSBlbHNlIHsKLSAgICAgICAgaFJlc3VsdCA9IG1QbHVnaW4tPmdldFByb3Zpc2lvblJlcXVlc3QoCi0gICAgICAgICAgICAgICAgdG9IaWRsU3RyaW5nKGNlcnRUeXBlKSwgdG9IaWRsU3RyaW5nKGNlcnRBdXRob3JpdHkpLAotICAgICAgICAgICAgICAgIFsmXShTdGF0dXMgc3RhdHVzLCBjb25zdCBoaWRsX3ZlYzx1aW50OF90PiYgaFJlcXVlc3QsCi0gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoaWRsX3N0cmluZyYgaERlZmF1bHRVcmwpIHsKLSAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXR1cyA9PSBTdGF0dXM6Ok9LKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0ID0gdG9WZWN0b3IoaFJlcXVlc3QpOwotICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFVybCA9IHRvU3RyaW5nOChoRGVmYXVsdFVybCk7Ci0gICAgICA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UxMKSB7Ci0gICAgICAgIHJldHVybiBCQURfVkFMVUU7Ci0gICAgfQotICAgIHN0YXR1c190IGVyciA9IFVOS05PV05fRVJST1I7Ci0KLSAgICAqb3BlbiA9IDA7Ci0gICAgKm1heCA9IDA7Ci0KLSAgICBpZiAobVBsdWdpblYxXzEgPT0gTlVMTCkgewotICAgICAgICByZXR1cm4gRVJST1JfRFJNX0NBTk5PVF9IQU5ETEU7Ci0gICAgfQotCi0gICAgUmV0dXJuPHZvaWQ+IGhSZXN1bHQgPSBtUGx1Z2luVjFfMS0+Z2V0TnVtYmVyT2ZTZXNzaW9ucygKLSAgICAgICAgICAgIFsmXShTdGF0dXMgc3RhdHVzLCB1aW50MzJfdCBoT3BlbiwgdWludDMyX3QgaE1heCkgewotICAgICAgICAgICAgICAgIGlmIChzdGF0dXMgPT0gU3RhdHVzOjpPSykgewotICAgICAgICAgICAgICAgICAgICAqb3BlbiA9IGhPcGVuOwotICAgICAgICAgICAgICAgICAgICAqbWF4ID0gaE1heDsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgZXJyID0gdG9TdGF0dXNUKHN0YXR1cyk7Ci0gICAgICAgICAgICB9Ci0gICAgKTsKLQotICAgIHJldHVybiBoUmVzdWx0LmlzT2soKSA/IGVyciA6IERFQURfT0JKRUNUOworc3RhdHVzX3QgRHJtSGFsOjpnZXROdW1iZXJPZlNlc3Npb25zKHVpbnQzMl90KiBjdXJyZW50U2Vzc2lvbnMsIHVpbnQzMl90KiBtYXhTZXNzaW9ucykgY29uc3QgeworICAgIGlmIChtRHJtSGFsQWlkbC0+aW5pdENoZWNrKCkgPT0gT0spCisgICAgICAgIHJldHVybiBtRHJtSGFsQWlkbC0+Z2V0TnVtYmVyT2ZTZXNzaW9ucyhjdXJyZW50U2Vzc2lvbnMsIG1heFNlc3Npb25zKTsKKyAgICByZXR1cm4gbURybUhhbEhpZGwtPmdldE51bWJlck9mU2Vzc2lvbnMoY3VycmVudFNlc3Npb25zLCB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dD4gY29uc3QmIHNlc3Npb25JZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBEcm1QbHVnaW46OlNlY3VyaXR5TGV2ZWwqIGxldmVsKSBjb25zdCB7CisgICAgaWYgKG1Ecm1IYWxBaWRsLT5pbml0Q2hlY2soKSA9PSBPSykgcmV0dXJuIG1Ecm1IYWxBaWRsLT5nZXRTZWN1cml0eUxldmVsKHNlc3Npb25JZCwgbGV2ZWwpOworICAgIHJldHVybiBtRHJtSGFsSGlkbC0+Z2V0U2VjdXJpdHlMZXZlbChzZXNzaW9uSWQsIGxldmVsKTsKIH0KIAotc3RhdHVzX3QgRHJtSGFsOjpnZXRPZmZsaW5lTGljZW5zZUtleVNldElkcyhMaXN0PFZlY3Rvcjx1aW50OF90Pj4gJmtleVNldElkcykgY29uc3QgewotICAgIE11dGV4OjpBdXRvbG9jayBhdXRvTG9jayhtTG9jayk7Ci0KLSAgICBpZiAobUluaXRDaGVjayAhPSBPSykgewotICAgICAgICByZXR1cm4gbUluaXRDaGVjazsKLSAgICB9Ci0KLSAgICBpZiAobVBsdWdpblYxXzIgPT0gTlVMTCkgewotICAgICAgICByZXR1cm4gRVJST1JfVU5TVVBQT1JURUQ7Ci0gICAgfQotCi0gICAgc3RhdHVzX3QgZXJyID0gVU5LTk9XTl9FUlJPUjsKLQotICAgIFJldHVybjx2b2lkPiBoUmVzdWx0ID0gbVBsdWdpblYxXzItPmdldE9mZmxpbmVMaWNlbnNlS2V5U2V0SWRzKAotICAgICAgICAgICAgWyZdKFN0YXR1cyBzdGF0dXMsIGNvbnN0IGhpZGxfdmVjPEtleVNldElkPiYgaEtleVNldElkcykgewotICAgICAgICAgICAgICAgIGlmIChzdGF0dXMgPT0gU3RhdHVzOjpPSykgewotICAgICAgICAgICAgICAgICAgICBrZXlTZXRJZHMgPSB0b0tleVNldElkcyhoS2V5U2V0SWRzKTsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgZXJyID0gdG9Td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ldFByb3BlcnR5U3RyaW5nSW50ZXJuYWwoU3RyaW5nOCgiZGVzY3JpcHRpb24iKSwgZGVzY3JpcHRpb24pID09IE9LICYmCi0gICAgICAgICAgICBnZXRQcm9wZXJ0eUJ5dGVBcnJheUludGVybmFsKFN0cmluZzgoIm1ldHJpY3MiKSwgbWV0cmljc1ZlY3RvcikgPT0gT0spIHsKLSAgICAgICAgbWV0cmljc1N0cmluZyA9IHRvQmFzZTY0U3RyaW5nTm9QYWQobWV0cmljc1ZlY3Rvci5hcnJheSgpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXRyaWNzVmVjdG9yLnNpemUoKSk7Ci0gICAgICAgIHN0YXR1c190IHJlcyA9IGFuZHJvaWQ6OnJlcG9ydERybVBsdWdpbk1ldHJpY3MobWV0cmljc1N0cmluZywgdmVuZG9yLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc2NyaXB0aW9uLCBtTWV0cmljcy5HZXRBcHBVaWQoKSk7Ci0gICAgICAgIGlmIChyZXMgIT0gT0spIHsKLSAgICAgICAgICAgIEFMT0dFKCJNZXRyaWNzIHdlcmUgcmV0cmlldmVkIGJ1dCBjb3VsZCBub3QgYmUgcmVwb3J0ZWQ6ICVkIiwgcmVzKTsKLSAgICAgICAgfQotICAgIH0KLSAgICByZXR1cm4gbWV0cmljc1N0cmluZzsKK3N0YXR1c190IERybUhhbDo6c2V0UGxheWJhY2tJZChWZWN0b3I8dWludDhfdD4gY29uc3QmIHNlc3Npb25JZCwgY29uc3QgY2hhciogcGxheWJhY2tJZCkgeworICAgIGlmIChtRHJtSGFsQWlkbC0+aW5pdENoZWNrKCkgPT0gT0spIHJldHVybiBtRHJtSGFsQWlkbC0+c2V0UGxheWJhY2tJZChzZXNzaW9uSWQsIHBsYXliYWNrSWQpOworICAgIHJldHVybiBtRHJtSGFsSGlkbC0+c2V0UGxheWJhY2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ZSkgeworICAgICAgICBjYXNlIE9mZmxpbmVMaWNlbnNlU3RhdGU6OlVTQUJMRToKKyAgICAgICAgICAgIHJldHVybiBEcm1QbHVnaW46OmtPZmZsaW5lTGljZW5zZVN0YXRlVXNhYmxlOworICAgICAgICBjYXNlIE9mZmxpbmVMaWNlbnNlU3RhdGU6OklOQUNUSVZFOgorICAgICAgICAgICAgcmV0dXJuIERybVBsdWdpbjo6a09mZmxpbmVMaWNlbnNlU3RhdGVSZWxlYXNlZDsKKyAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgIHJldHVybiBEcm1QbHVnaW46OmtPZmZsaW5lTGljZW5zZVN0YXRlVW5rbm93bjsKKyAgICB9Cit9CisKK011dGV4IERybUhhbEFpZGw6Om1Mb2NrOworCitzdGF0aWMgaGlkbF92ZWM8RHJtTWV0cmljR3JvdXBIaWRsPiB0b0RybU1ldHJpY0dyb3VwSGlkbChzdGQ6OnZlY3RvcjxEcm1NZXRyaWNHcm91cEFpZGw+IHJlc3VsdCkgeworICAgIHN0ZDo6dmVjdG9yPERybU1ldHJpY0dyb3VwSGlkbD4gcmVzdWx0SGlkbDsKKyAgICBmb3IgKGF1dG8gciA6IHJlc3VsdCkgeworICAgICAgICBEcm1NZXRyaWNHcm91cEhpZGwgcmU7CisgICAgICAgIHN0ZDo6dmVjdG9yPERybU1ldHJpY0hpZGw+IHRtcE1ldHJpYzsKKyAgICAgICAgZm9yIChhdXRvIG0gOiByLm1ldHJpY3MpIHsKKyAgICAgICAgICAgIERybU1ldHJpY0hpZGwgbWU7CisgICAgICAgICAgICBtZS5uYW1lID0gbS5uYW1lOworICAgICAgICAgICAgc3RkOjp2ZWN0b3I8QXR0cmlidXRlSGlkbD4gYVRtcDsKKyAgICAgICAgICAgIGZvciAoYXV0byBhdHRyIDogbS5hdHRyaWJ1dGVzKSB7CisgICAgICAgICAgICAgICAgQXR0cmlidXRlSGlkbCBhdHRySGlkbDsKKyAgICAgICAgICAgICAgICBhdHRySGlkbC5uYW1lID0gYXR0ci5uYW1lOworCisgICAgICAgICAgICAgICAgc3dpdGNoIChhdHRyLnZhbHVlLmdldFRhZygpKSB7CisgICAgICAgICAgICAgICAgICAgIGNhc2UgRHJtTWV0cmljVmFsdWU6OlRhZzo6aW50NjRWYWx1ZToKKyAgICAgICAgICAgICAgICAgICAgICAgIGF0dHJIaWRsLnR5cGUgPSBEcm1NZXRyaWNHcm91cEhpZGw6OlZhbHVlVHlwZTo6SU5UNjRfVFlQRTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGF0dHJIaWRsLmludDY0VmFsdWUgPSBhdHRyLnZhbHVlLmdldDxEcm1NZXRyaWNWYWx1ZTo6VGFnOjppbnQ2NFZhbHVlPigpOworICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgICAgIGNhc2UgRHJtTWV0cmljVmFsdWU6OlRhZzo6ZG91YmxlVmFsdWU6CisgICAgICAgICAgICAgICAgICAgICAgICBhdHRySGlkbC50eXBlID0gRHJtTWV0cmljR3JvdXBIaWRsOjpWYWx1ZVR5cGU6OkRPVUJMRV9UWVBFOworICAgICAgICAgICAgICAgICAgICAgICAgYXR0ckhpZGwuZG91YmxlVmFsdWUgPSBhdHRyLnZhbHVlLmdldDxEcm1NZXRyaWNWYWx1ZTo6VGFnOjpkb3VibGVWYWx1ZT4oKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICBjYXNlIERybU1ldHJpY1ZhbHVlOjpUYWc6OnN0cmluZ1ZhbHVlOgorICAgICAgICAgICAgICAgICAgICAgICAgYXR0ckhpZGwudHlwZSA9IERybU1ldHJpY0dyb3VwSGlkbDo6VmFsdWVUeXBlOjpTVFJJTkdfVFlQRTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGF0dHJIaWRsLnN0cmluZ1ZhbHVlID0gYXR0ci52YWx1ZS5nZXQ8RHJtTWV0cmljVmFsdWU6OlRhZzo6c3RyaW5nVmFsdWU+KCk7CisgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgIGFUbXAucHVzaF9iYWNrKGF0dHJIaWRsKTsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgbWUuYXR0cmlidXRlcyA9IGFUbXA7CisKKyAgICAgICAgICAgIHN0ZDo6dmVjdG9yPFZhbHVlSGlkbD4gdlRtcDsKKyAgICAgICAgICAgIGZvciAoYXV0byB2YWx1ZSA6IG0udmFsdWVzKSB7CisgICAgICAgICAgICAgICAgVmFsdWVIaWRsIHZhbHVlSGlkbDsKKyAgICAgICAgICAgICAgICB2YWx1ZUhpZGwuY29tcG9uZW50TmFtZSA9IHZhbHVlLm5hbWU7CisgICAgICAgICAgICAgICAgc3dpdGNoICh2YWx1ZS52YWx1ZS5nZXRUYWcoKSkgeworICAgICAgICAgICAgICAgICAgICBjYXNlIERybU1ldHJpY1ZhbHVlOjpUYWc6OmludDY0VmFsdWU6CisgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZUhpZGwudHlwZSA9IERybU1ldHJpY0dyb3VwSGlkbDo6VmFsdWVUeXBlOjpJTlQ2NF9UWVBFOworICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWVIaWRsLmludDY0VmFsdWUgPSB2YWx1ZS52YWx1ZS5nZXQ8RHJtTWV0cmljVmFsdWU6OlRhZzo6aW50NjRWYWx1ZT4oKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICBjYXNlIERybU1ldHJpY1ZhbHVlOjpUYWc6OmRvdWJsZVZhbHVlOgorICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWVIaWRsLnR5cGUgPSBEcm1NZXRyaWNHcm91cEhpZGw6OlZhbHVlVHlwZTo6RE9VQkxFX1RZUEU7CisgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZUhpZGwuZG91YmxlVmFsdWUgPSB2YWx1ZS52YWx1ZS5nZXQ8RHJtTWV0cmljVmFsdWU6OlRhZzo6ZG91YmxlVmFsdWU+KCk7CisgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgY2FzZSBEcm1NZXRyaWNWYWx1ZTo6VGFnOjpzdHJpbmdWYWx1ZToKKyAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlSGlkbC50eXBlID0gRHJtTWV0cmljR3JvdXBIaWRsOjpWYWx1ZVR5cGU6OlNUUklOR19UWVBFOworICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWVIaWRsLnN0cmluZ1ZhbHVlID0gdmFsdWUudmFsdWUuZ2V0PERybU1ldHJpY1ZhbHVlOjpUYWc6OnN0cmluZ1ZhbHVlPigpOworICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICB9CisKKyAgICAgICAgICAgICAgICB2VG1wLnB1c2hfYmFjayh2YWx1ZUhpZGwpOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBtZS52YWx1ZXMgPSB2VG1wOworICAgICAgICAgICAgdG1wTWV0cmljLnB1c2hfYmFjayhtZSk7CisgICAgICAgIH0KKworICAgICAgICByZS5tZXRyaWNzID0gdG1wTWV0cmljOworICAgICAgICByZXN1bHRIaWRsLnB1c2hfYmFjayhyZSk7CisgICAgfQorCisgICAgcmV0dXJuIHJlc3VsdEhpZGw7Cit9CisKKy8vIERybVNlc3Npb25DbGllbnQgRGVmaW5pdGlvbgorCitzdHJ1Y3QgRHJtSGFsQWlkbDo6RHJtU2Vzc2lvbkNsaWVudCA6IHB1YmxpYyBhaWRsOjphbmRyb2lkOjptZWRpYTo6Qm5SZXNvdXJjZU1hbmFnZXJDbG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vLyBoYW5kbGUgZGVmYXVsdCB2YWx1ZSBjYXNlcworICAgICAgICBpZiAobGV2ZWxBaWRsID09IFNlY3VyaXR5TGV2ZWw6OkRFRkFVTFQgfHwgbGV2ZWxBaWRsID09IFNlY3VyaXR5TGV2ZWw6OlVOS05PV04pIHsKKyAgICAgICAgICAgIGlmIChtaW1lVHlwZSA9PSAiIikgeworICAgICAgICAgICAgICAgIC8vIGlzQ3J5cHRvU2NoZW1lU3VwcG9ydGVkKHV1aWQpCisgICAgICAgICAgICAgICAgKmlzU3VwcG9ydGVkID0gdHJ1ZTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgLy8gaXNDcnlwdG9TY2hlbWVTdXBwb3J0ZWQodXVpZCwgbWltZVR5cGUpCisgICAgICAgICAgICAgICAgKmlzU3VwcG9ydGVkID0gY29udGVudFR5cGVzLmNvdW50KG1pbWVUeXBlU3RyKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIHJldHVybiBPSzsKKyAgICAgICAgfSBlbHNlIGlmIChtaW1lVHlwZSA9PSAiIikgeworICAgICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKKyAgICAgICAgfQorCisgICAgICAgIGF1dG8gY3QgPSBjb250ZW50VHlwZXNbbWltZVR5cGVTdHJdOworICAgICAgICBpZiAobGV2ZWxBaWRsID4gY3QubWF4TGV2ZWwgfHwgbGV2ZWxBaWRsIDwgY3QubWluTGV2ZWwpIHsKKyAgICAgICAgICAgICAgY29udGludWU7CisgICAgICAgIH0KKworICAgICAgICAqaXNTdXBwb3J0ZWQgPSB0cnVlOworICAgICAgICBicmVhazsKKyAgICB9CisKKyAgICByZXR1cm4gT0s7Cit9CisKK3N0YXR1c190IERybUhhbEFpZGw6OmNyZWF0ZVBsdWdpbihjb25zdCB1aW50OF90IHV1aWRbMTZdLCBjb25zdCBTdHJpbmc4JiBhcHBQYWNrYWdlTmFtZSkgeworICAgIE11dGV4OjpBdXRvbG9jayBhdXRv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29wZWRBU3RhdHVzIHN0YXR1cyA9IG1QbHVnaW4tPmNsb3NlU2Vzc2lvbihzZXNzaW9uSWRBaWRsKTsKKyAgICBzdGF0dXNfdCByZXNwb25zZSA9IHN0YXR1c0FpZGxUb1N0YXR1c1Qoc3RhdHVzKTsKKyAgICBpZiAoc3RhdHVzLmlzT2soKSkgeworICAgICAgICBEcm1TZXNzaW9uTWFuYWdlcjo6SW5zdGFuY2UoKS0+cmVtb3ZlU2Vzc2lvbihzZXNzaW9uSWQpOworICAgICAgICBmb3IgKGF1dG8gaSA9IG1PcGVuU2Vzc2lvbnMuYmVnaW4oKTsgaSAhPSBtT3BlblNlc3Npb25zLmVuZCgpOyBpKyspIHsKKyAgICAgICAgICAgIGlmIChpc0VxdWFsU2Vzc2lvbklkKCgqaSktPm1TZXNzaW9uSWQsIHNlc3Npb25JZCkpIHsKKyAgICAgICAgICAgICAgICBtT3BlblNlc3Npb25zLmVyYXNlKGkpOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgfQorICAgICAgICB9CisKKyAgICAgICAgbU1ldHJpY3MuU2V0U2Vzc2lvbkVuZChzZXNzaW9uSWQpOworICAgIH0KKworICAgIG1NZXRyaWNzLm1DbG9zZVNlc3Npb25Db3VudGVyLkluY3JlbWVudChyZXNwb25zZSk7CisgICAgcmV0dXJuIHJlc3BvbnNlOworfQorCitzdGF0dXNfdCBEcm1IYWxBaWRsOjpnZXRLZXlSZXF1ZXN0KFZlY3Rvcjx1aW50OF90PiBjb25zdCYgc2Vzc2lvbklkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QmIGluaXREYXRhLCBTdHJpbmc4IGNvbnN0JiBtaW1lVHlwZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRHJtUGx1Z2luOjpLZXlUeXBlIGtleVR5cGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEtleWVkVmVj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BOVUxMKSB7CisgICAgICAgIHJldHVybiBCQURfVkFMVUU7CisgICAgfQorCisgICAgKmxldmVsID0gRHJtUGx1Z2luOjprU2VjdXJpdHlMZXZlbFVua25vd247CisKKyAgICBTZWN1cml0eUxldmVsIHJlc3VsdDsKKyAgICA6Om5kazo6U2NvcGVkQVN0YXR1cyBzdGF0dXMgPSBtUGx1Z2luLT5nZXRTZWN1cml0eUxldmVsKHRvU3RkVmVjKHNlc3Npb25JZCksICZyZXN1bHQpOworCisgICAgKmxldmVsID0gdG9TZWN1cml0eUxldmVsKHJlc3VsdCk7CisKKyAgICByZXR1cm4gc3RhdHVzQWlkbFRvU3RhdHVzVChzdGF0dXMpOworfQorCitzdGF0dXNfdCBEcm1IYWxBaWRsOjpnZXRPZmZsaW5lTGljZW5zZUtleVNldElkcyhMaXN0PFZlY3Rvcjx1aW50OF90Pj4mIGtleVNldElkcykgY29uc3QgeworICAgIE11dGV4OjpBdXRvbG9jayBhdXRvTG9jayhtTG9jayk7CisgICAgSU5JVF9DSEVDSygpOworCisgICAgc3RkOjp2ZWN0b3I8S2V5U2V0SWQ+IHJlc3VsdDsKKyAgICA6Om5kazo6U2NvcGVkQVN0YXR1cyBzdGF0dXMgPSBtUGx1Z2luLT5nZXRPZmZsaW5lTGljZW5zZUtleVNldElkcygmcmVzdWx0KTsKKworICAgIGtleVNldElkcyA9IHRvS2V5U2V0SWRzKHJlc3VsdCk7CisKKyAgICByZXR1cm4gc3RhdHVzQWlkbFRvU3RhdHVzVChzdGF0dXMpOworfQorCitzdGF0dXNfdCBEcm1IYWxBaWRsOjpyZW1vdmVPZmZsaW5lTGljZW5zZShWZWN0b3I8dWludDhfdD4gY29uc3QmIGtleVNldElkKSB7CisgICAgTXV0ZXg6OkF1dG9sb2NrIGF1dG9Mb2NrKG1Mb2NrKTsKKyAgICBJTklUX0NIRUNLKCk7CisKKyAgICBLZXlTZXRJZCBrZXlTZXRJZEFpZGw7CisgICAga2V5U2V0SWRBaWRsLmtleVNld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AgICAgICAgICBWZWN0b3I8dWludDhfdD4mIG91dHB1dCkgeworICAgIE11dGV4OjpBdXRvbG9jayBhdXRvTG9jayhtTG9jayk7CisgICAgSU5JVF9DSEVDSygpOworCisgICAgRHJtU2Vzc2lvbk1hbmFnZXI6Okluc3RhbmNlKCktPnVzZVNlc3Npb24oc2Vzc2lvbklkKTsKKworICAgIHN0ZDo6dmVjdG9yPHVpbnQ4X3Q+IHJlc3VsdDsKKyAgICA6Om5kazo6U2NvcGVkQVN0YXR1cyBzdGF0dXMgPSBtUGx1Z2luLT5lbmNyeXB0KHRvU3RkVmVjKHNlc3Npb25JZCksIHRvU3RkVmVjKGtleUlkKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvU3RkVmVjKGlucHV0KSwgdG9TdGRWZWMoaXYpLCAmcmVzdWx0KTsKKworICAgIG91dHB1dCA9IHRvVmVjdG9yKHJlc3VsdCk7CisKKyAgICByZXR1cm4gc3RhdHVzQWlkbFRvU3RhdHVzVChzdGF0dXMpOworfQorCitzdGF0dXNfdCBEcm1IYWxBaWRsOjpkZWNyeXB0KFZlY3Rvcjx1aW50OF90PiBjb25zdCYgc2Vzc2lvbklkLCBWZWN0b3I8dWludDhfdD4gY29uc3QmIGtleUlkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QmIGlucHV0LCBWZWN0b3I8dWludDhfdD4gY29uc3QmIGl2LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4mIG91dHB1dCkgeworICAgIE11dGV4OjpBdXRvbG9jayBhdXRvTG9jayhtTG9jayk7CisgICAgSU5JVF9DSEVDSygpOworCisgICAgRHJtU2Vzc2lvbk1hbmFnZXI6Okluc3RhbmNlKCktPnVzZVNlc3Npb24oc2Vzc2lvbklkKTsKKworICAgIHN0ZDo6dmVjdG9yPHVpbnQ4X3Q+IHJlc3VsdDsKKyAg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HRvU2NoZW1lcyBjdXJTY2hlbWVze307CisgICAgICAgIGF1dG8gZXJyID0gbUZhY3Rvcmllc1tpXS0+Z2V0U3VwcG9ydGVkQ3J5cHRvU2NoZW1lcygmY3VyU2NoZW1lcyk7CisgICAgICAgIGlmICghZXJyLmlzT2soKSkgeworICAgICAgICAgICAgY29udGludWU7CisgICAgICAgIH0KKworICAgICAgICBmb3IgKGF1dG8gdXVpZE9iaiA6IGN1clNjaGVtZXMudXVpZHMpIHsKKyAgICAgICAgICAgIHNjaGVtZXMuaW5zZXJ0KHNjaGVtZXMuZW5kKCksIHV1aWRPYmoudXVpZC5iZWdpbigpLCB1dWlkT2JqLnV1aWQuZW5kKCkpOworICAgICAgICB9CisgICAgfQorCisgICAgcmV0dXJuIE9LOworfQorCit2b2lkIERybUhhbEFpZGw6OmNsZWFudXAoKSB7CisgICAgY2xvc2VPcGVuU2Vzc2lvbnMoKTsKKworICAgIE11dGV4OjpBdXRvbG9jayBhdXRvTG9jayhtTG9jayk7CisgICAgcmVwb3J0RnJhbWV3b3JrTWV0cmljcyhyZXBvcnRQbHVnaW5NZXRyaWNzKCkpOworCisgICAgc2V0TGlzdGVuZXIoTlVMTCk7CisgICAgbUluaXRDaGVjayA9IE5PX0lOSVQ7CisgICAgaWYgKG1QbHVnaW4gIT0gTlVMTCkgeworICAgICAgICBpZiAoIW1QbHVnaW4tPnNldExpc3RlbmVyKE5VTEwpLmlzT2soKSkgeworICAgICAgICAgICAgbUluaXRDaGVjayA9IERFQURfT0JKRUNUOworICAgICAgICB9CisgICAgfQorCisgICAgbVBsdWdpbi5yZXNldCgpOworfQorCitzdGF0dXNfdCBEcm1IYWxBaWRsOjpkZXN0cm95UGx1Z2luKCkgeworICAgIGNsZWFudXAoKTsKKyAgICByZXR1cm4gT0s7Cit9CisKKzo6bmRrOjpTY29wZWRBU3RhdHVzIERybUhhbEFpZGw6Om9uRXZlbnQoRXZlbnRUeXBlQWlkbCBldmVudFR5cGVBaWRsLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnZlY3Rvcjx1aW50OF90PiYgc2Vzc2lvbklkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnZlY3Rvcjx1aW50OF90PiYgZGF0YSkgeworICAgIHJldHVybiBtTGlzdGVuZXItPm9uRXZlbnQoZXZlbnRUeXBlQWlkbCwgc2Vzc2lvbklkLCBkYXRhKTsKK30KKworOjpuZGs6OlNjb3BlZEFTdGF0dXMgRHJtSGFsQWlkbDo6b25FeHBpcmF0aW9uVXBkYXRlKGNvbnN0IHN0ZDo6dmVjdG9yPHVpbnQ4X3Q+JiBzZXNzaW9uSWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50NjRfdCBleHBpcnlUaW1lSW5NUykgeworICAgIHJldHVybiBtTGlzdGVuZXItPm9uRXhwaXJhdGlvblVwZGF0ZShzZXNzaW9uSWQsIGV4cGlyeVRpbWVJbk1TKTsKK30KKworOjpuZGs6OlNjb3BlZEFTdGF0dXMgRHJtSGFsQWlkbDo6b25LZXlzQ2hhbmdlKGNvbnN0IHN0ZDo6dmVjdG9yPHVpbnQ4X3Q+JiBzZXNzaW9uSWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjp2ZWN0b3I8S2V5U3RhdHVzPiYga2V5U3RhdHVzTGlzdEFpZGwsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBoYXNOZXdVc2FibGVLZXkpIHsKKyAgICByZXR1cm4gbUxpc3RlbmVyLT5vbktleXNDaGFuZ2Uoc2Vzc2lvbklkLCBrZXlTdGF0dXNMaXN0QWlkbCwgaGFzTmV3VXNhYmxlS2V5KTsKK30KKworOjpuZGs6OlNjb3BlZEFTdGF0dXMgRHJtSGFsQWlkbDo6b25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oIGFycmF5cyBvZiBzaW5nbGUtYnl0ZQorICAgIC8vIHZhbHVlcy4gSWYgdGhlIHNvdXJjZSBpcyBlbXB0eSBvciBpcyBub3QgYW4gYXJyYXkgb2Ygc2luZ2xlLWJ5dGUgdmFsdWVzLAorICAgIC8vIHJldHVybiBlbXB0eSBzdHJpbmcuCisgICAgaWYgKHNpemUgPT0gMCB8fCBzaXplb2YoZGF0YVswXSkgIT0gMSkgeworICAgICAgICByZXR1cm4gIiI7CisgICAgfQorCisgICAgYW5kcm9pZDo6QVN0cmluZyBvdXRwdXRTdHJpbmc7CisgICAgZW5jb2RlQmFzZTY0KGRhdGEsIHNpemUsICZvdXRwdXRTdHJpbmcpOworICAgIC8vIFJlbW92ZSB0cmFpbGluZyBlcXVhbHMgcGFkZGluZyBpZiBpdCBleGlzdHMuCisgICAgd2hpbGUgKG91dHB1dFN0cmluZy5zaXplKCkgPiAwICYmIG91dHB1dFN0cmluZy5lbmRzV2l0aChrRXF1YWxzU2lnbikpIHsKKyAgICAgICAgb3V0cHV0U3RyaW5nLmVyYXNlKG91dHB1dFN0cmluZy5zaXplKCkgLSAxLCAxKTsKKyAgICB9CisKKyAgICByZXR1cm4gc3RkOjpzdHJpbmcob3V0cHV0U3RyaW5nLmNfc3RyKCksIG91dHB1dFN0cmluZy5zaXplKCkpOworfQorCit9ICAvLyBhbm9ueW1vdXMgbmFtZXNwYWNlCisKK25hbWVzcGFjZSBhbmRyb2lkIHsKKworI2RlZmluZSBJTklUX0NIRUNLKCkgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgIGlmIChtSW5pdENoZWNrICE9IE9LKSByZXR1cm4gbUluaXRDaGVjazsgXAorICAgIH0KKworc3RhdGljIGNvbnN0IFZlY3Rvcjx1aW50OF90PiB0b1ZlY3Rvcihjb25zdCBoaWRsX3ZlYzx1aW50OF90PiYgdmVjKSB7Cis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TGV2ZWxfVjFfMjo6SERDUF9OT05FOgorICAgICAgICAgICAgcmV0dXJuIERybVBsdWdpbjo6a0hkY3BOb25lOworICAgICAgICBjYXNlIEhkY3BMZXZlbF9WMV8yOjpIRENQX1YxOgorICAgICAgICAgICAgcmV0dXJuIERybVBsdWdpbjo6a0hkY3BWMTsKKyAgICAgICAgY2FzZSBIZGNwTGV2ZWxfVjFfMjo6SERDUF9WMjoKKyAgICAgICAgICAgIHJldHVybiBEcm1QbHVnaW46OmtIZGNwVjI7CisgICAgICAgIGNhc2UgSGRjcExldmVsX1YxXzI6OkhEQ1BfVjJfMToKKyAgICAgICAgICAgIHJldHVybiBEcm1QbHVnaW46OmtIZGNwVjJfMTsKKyAgICAgICAgY2FzZSBIZGNwTGV2ZWxfVjFfMjo6SERDUF9WMl8yOgorICAgICAgICAgICAgcmV0dXJuIERybVBsdWdpbjo6a0hkY3BWMl8yOworICAgICAgICBjYXNlIEhkY3BMZXZlbF9WMV8yOjpIRENQX1YyXzM6CisgICAgICAgICAgICByZXR1cm4gRHJtUGx1Z2luOjprSGRjcFYyXzM7CisgICAgICAgIGNhc2UgSGRjcExldmVsX1YxXzI6OkhEQ1BfTk9fT1VUUFVUOgorICAgICAgICAgICAgcmV0dXJuIERybVBsdWdpbjo6a0hkY3BOb091dHB1dDsKKyAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgIHJldHVybiBEcm1QbHVnaW46OmtIZGNwTGV2ZWxVbmtub3duOworICAgIH0KK30KK3N0YXRpYyA6OktleWVkVmVjdG9yIHRvSGlkbEtleWVkVmVjdG9yKGNvbnN0IEtleWVkVmVjdG9yPFN0cmluZzgsIFN0cmluZzg+JiBrZXllZFZlY3RvcikgeworICAgIHN0ZDo6dmVjdG9yPEtleVZhbHVlPiBzdGRLZXllZFZlY3RvcjsKKyAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IGtleWVkVmVjdG9yLnNpemUoKTsgaSsrKSB7CisgICAgICAgIEtleVZhbHVlIG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ZCBwYXNzdGhyb3VnaCBkcm0gZmFjdG9yaWVzIik7CisgICAgICAgIH0KKyAgICB9CisgICAgcmV0dXJuIGZhY3RvcmllczsKK30KKworc3A8SURybVBsdWdpbj4gRHJtSGFsSGlkbDo6bWFrZURybVBsdWdpbihjb25zdCBzcDxJRHJtRmFjdG9yeT4mIGZhY3RvcnksIGNvbnN0IHVpbnQ4X3QgdXVpZFsxNl0sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFN0cmluZzgmIGFwcFBhY2thZ2VOYW1lKSB7CisgICAgbUFwcFBhY2thZ2VOYW1lID0gYXBwUGFja2FnZU5hbWU7CisgICAgbU1ldHJpY3MuU2V0QXBwUGFja2FnZU5hbWUoYXBwUGFja2FnZU5hbWUpOworICAgIG1NZXRyaWNzLlNldEFwcFVpZChBSUJpbmRlcl9nZXRDYWxsaW5nVWlkKCkpOworCisgICAgc3A8SURybVBsdWdpbj4gcGx1Z2luOworICAgIFJldHVybjx2b2lkPiBoUmVzdWx0ID0gZmFjdG9yeS0+Y3JlYXRlUGx1Z2luKAorICAgICAgICAgICAgdXVpZCwgYXBwUGFja2FnZU5hbWUuc3RyaW5nKCksIFsmXShTdGF0dXMgc3RhdHVzLCBjb25zdCBzcDxJRHJtUGx1Z2luPiYgaFBsdWdpbikgeworICAgICAgICAgICAgICAgIGlmIChzdGF0dXMgIT0gU3RhdHVzOjpPSykgeworICAgICAgICAgICAgICAgICAgICBEcm1VdGlsczo6TE9HMkJFKHV1aWQsICJGYWlsZWQgdG8gbWFrZSBkcm0gcGx1Z2luOiAlZCIsIHN0YXR1cyk7CisgICAgICAgICAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgcGx1Z2luID0gaFBsdWdpbjsKKyAgICAgICAgICAgIH0pOworCisgICAgaWYgKCFoUmVzdWx0LmlzT2soKSkgeworICAgICAgICBEcm1VdGlsczo6TE9HMkJFKHV1aWQsICJjcmVhdGVQbHVnaW4gcmVtb3RlIGNhbGwgZmFpbGVkOiAlcyIsCisgICAgICAgICAgICAgICAgICAgICAgICAgaFJlc3VsdC5kZXNjcmlwdGlvbigpLmNfc3RyKCkpOworICAgIH0KKworICAgIHJldHVybiBwbHVnaW47Cit9CisKK3N0YXR1c190IERybUhhbEhpZGw6OmluaXRDaGVjaygpIGNvbnN0IHsKKyAgICByZXR1cm4gbUluaXRDaGVjazsKK30KKworc3RhdHVzX3QgRHJtSGFsSGlkbDo6c2V0TGlzdGVuZXIoY29uc3Qgc3A8SURybUNsaWVudD4mIGxpc3RlbmVyKSB7CisgICAgTXV0ZXg6OkF1dG9sb2NrIGxvY2sobUV2ZW50TG9jayk7CisgICAgbUxpc3RlbmVyID0gbGlzdGVuZXI7CisgICAgcmV0dXJuIE5PX0VSUk9SOworfQorCitSZXR1cm48dm9pZD4gRHJtSGFsSGlkbDo6c2VuZEV2ZW50KEV2ZW50VHlwZSBoRXZlbnRUeXBlLCBjb25zdCBoaWRsX3ZlYzx1aW50OF90PiYgc2Vzc2lvbklkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoaWRsX3ZlYzx1aW50OF90PiYgZGF0YSkgeworICAgIG1NZXRyaWNzLm1FdmVudENvdW50ZXIuSW5jcmVtZW50KCh1aW50MzJfdCloRXZlbnRUeXBlKTsKKworICAgIG1FdmVudExvY2subG9jaygpOworICAgIHNwPElEcm1DbGllbnQ+IGxpc3RlbmVyID0gbUxpc3RlbmVyOworICAgIG1FdmVudExvY2sudW5sb2NrKCk7CisKKyAgICBpZiAobGlzdGVuZXIgIT0gTlVMTCkgeworICAgICAgICBNdXRleDo6QXV0b2xvY2sgbG9jayhtTm90aWZ5TG9jayk7CisgICAgICAgIERybVBsdWdpbjo6RXZlbnRUeXBlIGV2ZW50VHlwZTsKKyAgICAgICAgc3dpdGNoIChoRXZlbnRUeXBlKSB7CisgICAgICAgICAgICBjYXNlIEV2ZW50VHlwZTo6UFJPVklTSU9OX1JFUVVJUkVEOgorICAgICAgICAgICAgICAgIGV2ZW50VHlwZSA9IERybVBsdWdpbjo6a0RybVBsdWdpbkV2ZW50UHJvdmlzaW9uUmVxdWlyZWQ7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIEV2ZW50VHlwZTo6S0VZX05FRURFRDoKKyAgICAgICAgICAgICAgICBldmVudFR5cGUgPSBEcm1QbHVnaW46OmtEcm1QbHVnaW5FdmVudEtleU5lZWRlZDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgRXZlbnRUeXBlOjpLRVlfRVhQSVJFRDoKKyAgICAgICAgICAgICAgICBldmVudFR5cGUgPSBEcm1QbHVnaW46OmtEcm1QbHVnaW5FdmVudEtleUV4cGlyZWQ7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIEV2ZW50VHlwZTo6VkVORE9SX0RFRklORUQ6CisgICAgICAgICAgICAgICAgZXZlbnRUeXBlID0gRHJtUGx1Z2luOjprRHJtUGx1Z2luRXZlbnRWZW5kb3JEZWZpbmVkOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBFdmVudFR5cGU6OlNFU1NJT05fUkVDTEFJTUVEOgorICAgICAgICAgICAgICAgIGV2ZW50VHlwZSA9IERybVBsdWdpbjo6a0RybVBsdWdpbkV2ZW50U2Vzc2lvblJlY2xhaW1lZDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgcmV0dXJuIFZvaWQoKTsKKyAgICAgICAgfQorICAgICAgICBsaXN0ZW5lci0+c2VuZEV2ZW50KGV2ZW50VHlwZSwgc2Vzc2lvbklkLCBkYXRhKTsKKyAgICB9CisgICAgcmV0dXJuIFZvaWQoKTsKK30KKworUmV0dXJuPHZvaWQ+IERybUhhbEhpZGw6OnNlbmRFeHBpcmF0aW9uVXBkYXRlKGNvbnN0IGhpZGxfdmVjPHVpbnQ4X3Q+JiBzZXNzaW9uSWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50NjRfdCBleHBpcnlUaW1lSW5NUykgeworICAgIG1FdmVudExvY2subG9jaygpOworICAgIHNwPElEcm1DbGllbnQ+IGxpc3RlbmVyID0gbUxpc3RlbmVyOworICAgIG1FdmVudExvY2sudW5sb2NrKCk7CisKKyAgICBpZiAobGlzdGVuZXIgIT0gTlVMTCkgeworICAgICAgICBNdXRleDo6QXV0b2xvY2sgbG9jayhtTm90aWZ5TG9jayk7CisgICAgICAgIGxpc3RlbmVyLT5zZW5kRXhwaXJhdGlvblVwZGF0ZShzZXNzaW9uSWQsIGV4cGlyeVRpbWVJbk1TKTsKKyAgICB9CisgICAgcmV0dXJuIFZvaWQoKTsKK30KKworUmV0dXJuPHZvaWQ+IERybUhhbEhpZGw6OnNlbmRLZXlzQ2hhbmdlKGNvbnN0IGhpZGxfdmVjPHVpbnQ4X3Q+JiBzZXNzaW9uSWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGlkbF92ZWM8S2V5U3RhdHVzX1YxXzA+JiBrZXlTdGF0dXNMaXN0X1YxXzAsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBoYXNOZXdVc2FibGVLZXkpIHsKKyAgICBzdGQ6OnZlY3RvcjxLZXlTdGF0dXM+IGtleVN0YXR1c1ZlYzsKKyAgICBmb3IgKGNvbnN0IGF1dG8mIGtleVN0YXR1c19WMV8wIDoga2V5U3RhdHVzTGlzdF9WMV8wKSB7CisgICAgICAgIGtleVN0YXR1c1ZlYy5wdXNoX2JhY2soCisgICAgICAgICAgICAgICAge2tleVN0YXR1c19WMV8wLmtleUlkLCBzdGF0aWNfY2FzdDxLZXlTdGF0dXNUeXBlPihrZXlTdGF0dXNfVjFfMC50eXBlKX0pOworICAgIH0KKyAgICBoaWRsX3ZlYzxLZXlTdGF0dXM+IGtleVN0YXR1c0xpc3RfVjFfMihrZXlTdGF0dXNWZWMpOworICAgIHJldHVybiBzZW5kS2V5c0NoYW5nZV8xXzIoc2Vzc2lvbklkLCBrZXlTdGF0dXNMaXN0X1YxXzIsIGhhc05ld1VzYWJsZUtleSk7Cit9CisKK1JldHVybjx2b2lkPiBEcm1IYWxIaWRsOjpzZW5kS2V5c0NoYW5nZV8xXzIoY29uc3QgaGlkbF92ZWM8dWludDhfdD4mIHNlc3Npb25JZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGlkbF92ZWM8S2V5U3RhdHVzPiYgaEtleVN0YXR1c0xpc3QsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgaGFzTmV3VXNhYmxlS2V5KSB7CisgICAgbUV2ZW50TG9jay5sb2NrKCk7CisgICAgc3A8SURybUNsaWVudD4gbGlzdGVuZXIgPSBtTGlzdGVuZXI7CisgICAgbUV2ZW50TG9jay51bmxvY2soKTsKKworICAgIGlmIChsaXN0ZW5lciAhPSBOVUxMKSB7CisgICAgICAgIHN0ZDo6dmVjdG9yPERybUtleVN0YXR1cz4ga2V5U3RhdHVzTGlzdDsKKyAgICAgICAgc2l6ZV90IG5LZXlzID0gaEtleVN0YXR1c0xpc3Quc2l6ZSgpOworICAgICAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IG5LZXlzOyArK2kpIHsKKyAgICAgICAgICAgIGNvbnN0IEtleVN0YXR1cyYga2V5U3RhdHVzID0gaEtleVN0YXR1c0xpc3RbaV07CisgICAgICAgICAgICB1aW50MzJfdCB0eXBlOworICAgICAgICAgICAgc3dpdGNoIChrZXlTdGF0dXMudHlwZSkgeworICAgICAgICAgICAgICAgIGNhc2UgS2V5U3RhdHVzVHlwZTo6VVNBQkxFOgorICAgICAgICAgICAgICAgICAgICB0eXBlID0gRHJtUGx1Z2luOjprS2V5U3RhdHVzVHlwZV9Vc2FibGU7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgS2V5U3RhdHVzVHlwZTo6RVhQSVJFRDoKKyAgICAgICAgICAgICAgICAgICAgdHlwZSA9IERybVBsdWdpbjo6a0tleVN0YXR1c1R5cGVfRXhwaXJlZDsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSBLZXlTdGF0dXNUeXBlOjpPVVRQVVROT1RBTExPV0VEOgorICAgICAgICAgICAgICAgICAgICB0eXBlID0gRHJtUGx1Z2luOjprS2V5U3RhdHVzVHlwZV9PdXRwdXROb3RBbGxvd2VkOworICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICBjYXNlIEtleVN0YXR1c1R5cGU6OlNUQVRVU1BFTkRJTkc6CisgICAgICAgICAgICAgICAgICAgIHR5cGUgPSBEcm1QbHVnaW46OmtLZXlTdGF0dXNUeXBlX1N0YXR1c1BlbmRpbmc7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgS2V5U3RhdHVzVHlwZTo6VVNBQkxFSU5GVVRVUkU6CisgICAgICAgICAgICAgICAgICAgIHR5cGUgPSBEcm1QbHVnaW46OmtLZXlTdGF0dXNUeXBlX1VzYWJsZUluRnV0dXJlOworICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICBjYXNlIEtleVN0YXR1c1R5cGU6OklOVEVSTkFMRVJST1I6CisgICAgICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICAgICAgdHlwZSA9IERybVBsdWdpbjo6a0tleVN0YXR1c1R5cGVfSW50ZXJuYWxFcnJvcjsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBrZXlTdGF0dXNMaXN0LnB1c2hfYmFjayh7d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2spOworICAgICAgICBsaXN0ZW5lci0+c2VuZFNlc3Npb25Mb3N0U3RhdGUoc2Vzc2lvbklkKTsKKyAgICB9CisgICAgcmV0dXJuIFZvaWQoKTsKK30KKworc3RhdHVzX3QgRHJtSGFsSGlkbDo6bWF0Y2hNaW1lVHlwZUFuZFNlY3VyaXR5TGV2ZWwoY29uc3Qgc3A8SURybUZhY3Rvcnk+JiBmYWN0b3J5LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdWludDhfdCB1dWlkWzE2XSwgY29uc3QgU3RyaW5nOCYgbWltZVR5cGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBEcm1QbHVnaW46OlNlY3VyaXR5TGV2ZWwgbGV2ZWwsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sKiBpc1N1cHBvcnRlZCkgeworICAgICppc1N1cHBvcnRlZCA9IGZhbHNlOworCisgICAgLy8gaGFuZGxlIGRlZmF1bHQgdmFsdWUgY2FzZXMKKyAgICBpZiAobGV2ZWwgPT0gRHJtUGx1Z2luOjprU2VjdXJpdHlMZXZlbFVua25vd24pIHsKKyAgICAgICAgaWYgKG1pbWVUeXBlID09ICIiKSB7CisgICAgICAgICAgICAvLyBpc0NyeXB0b1NjaGVtZVN1cHBvcnRlZCh1dWlkKQorICAgICAgICAgICAgKmlzU3VwcG9ydGVkID0gdHJ1ZTsKKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIC8vIGlzQ3J5cHRvU2NoZW1lU3VwcG9ydGVkKHV1aWQsIG1pbWVUeXBlKQorICAgICAgICAgICAgKmlzU3VwcG9ydGVkID0gZmFjdG9yeS0+aXNDb250ZW50VHlwZVN1cHBvcnRlZChtaW1lVHlwZS5zdHJpbmcoKSk7CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIE9LOworICAgIH0gZWxzZSBp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gICAgICAgICB9CisgICAgICAgIH0KKyAgICB9CisKKyAgICBpZiAobVBsdWdpbiA9PSBOVUxMKSB7CisgICAgICAgIERybVV0aWxzOjpMT0cyQkUodXVpZCwgIk5vIHN1cHBvcnRlZCBoYWwgaW5zdGFuY2UgZm91bmQiKTsKKyAgICAgICAgbUluaXRDaGVjayA9IEVSUk9SX1VOU1VQUE9SVEVEOworICAgIH0gZWxzZSB7CisgICAgICAgIG1Jbml0Q2hlY2sgPSBPSzsKKyAgICAgICAgaWYgKG1QbHVnaW5WMV8yICE9IE5VTEwpIHsKKyAgICAgICAgICAgIGlmICghbVBsdWdpblYxXzItPnNldExpc3RlbmVyKHRoaXMpLmlzT2soKSkgeworICAgICAgICAgICAgICAgIG1Jbml0Q2hlY2sgPSBERUFEX09CSkVDVDsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfSBlbHNlIGlmICghbVBsdWdpbi0+c2V0TGlzdGVuZXIodGhpcykuaXNPaygpKSB7CisgICAgICAgICAgICBtSW5pdENoZWNrID0gREVBRF9PQkpFQ1Q7CisgICAgICAgIH0KKyAgICAgICAgaWYgKG1Jbml0Q2hlY2sgIT0gT0spIHsKKyAgICAgICAgICAgIG1QbHVnaW4uY2xlYXIoKTsKKyAgICAgICAgICAgIG1QbHVnaW5WMV8xLmNsZWFyKCk7CisgICAgICAgICAgICBtUGx1Z2luVjFfMi5jbGVhcigpOworICAgICAgICAgICAgbVBsdWdpblYxXzQuY2xlYXIoKTsKKyAgICAgICAgfQorICAgIH0KKworICAgIHJldHVybiBtSW5pdENoZWNrOworfQorCitzdGF0dXNfdCBEcm1IYWxIaWRsOjpkZXN0cm95UGx1Z2luKCkgeworICAgIGNsZWFudXAoKTsKKyAgICByZXR1cm4gT0s7Cit9CisKK3N0YXR1c190IERybUhhbEhpZGw6Om9wZW5TZXNzaW9uKERybVBsdWdpbjo6U2VjdXJpdHlMZXZlbCBsZXZlbCwgVmVjdG9yPHVpbnQ4X3Q+JiBzZXNzaW9uSWQpIHsKKyAgICBNdXRleDo6QXV0b2xvY2sgYXV0b0xvY2sobUxvY2spOworICAgIElOSVRfQ0hFQ0soKTsKKworICAgIFNlY3VyaXR5TGV2ZWwgaFNlY3VyaXR5TGV2ZWwgPSB0b0hpZGxTZWN1cml0eUxldmVsKGxldmVsKTsKKyAgICBib29sIHNldFNlY3VyaXR5TGV2ZWwgPSB0cnVlOworCisgICAgaWYgKGxldmVsID09IERybVBsdWdpbjo6a1NlY3VyaXR5TGV2ZWxNYXgpIHsKKyAgICAgICAgc2V0U2VjdXJpdHlMZXZlbCA9IGZhbHNlOworICAgIH0gZWxzZSB7CisgICAgICAgIGlmIChoU2VjdXJpdHlMZXZlbCA9PSBTZWN1cml0eUxldmVsOjpVTktOT1dOKSB7CisgICAgICAgICAgICByZXR1cm4gRVJST1JfRFJNX0NBTk5PVF9IQU5ETEU7CisgICAgICAgIH0KKyAgICB9CisKKyAgICBzdGF0dXNfdCBlcnIgPSBVTktOT1dOX0VSUk9SOworICAgIGJvb2wgcmV0cnkgPSB0cnVlOworICAgIGRvIHsKKyAgICAgICAgaGlkbF92ZWM8dWludDhfdD4gaFNlc3Npb25JZDsKKworICAgICAgICBSZXR1cm48dm9pZD4gaFJlc3VsdDsKKyAgICAgICAgaWYgKG1QbHVnaW5WMV8xID09IE5VTEwgfHwgIXNldFNlY3VyaXR5TGV2ZWwpIHsKKyAgICAgICAgICAgIGhSZXN1bHQgPSBtUGx1Z2luLT5vcGVuU2Vzc2lvbihbJl0oU3RhdHVzIHN0YXR1cywgY29uc3QgaGlkbF92ZWM8dWludDhfdD4mIGlkKSB7CisgICAgICAgICAgICAgICAgaWYgKHN0YXR1cyA9PSBTdGF0dXM6Ok9LKSB7CisgICAgICAgICAgICAgICAgICAgIHNlc3Npb25JZCA9IHRvVmVjdG9yKGlkKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgZXJyID0gdG9TdGF0dXNUKHN0YXR1cyk7CisgICAgICAgICAgICB9KTsKKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIGhSZXN1bHQgPSBtUGx1Z2luVjFfMS0+b3BlblNlc3Npb25fMV8xKGhTZWN1cml0eUxldmVsLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgWyZdKFN0YXR1cyBzdGF0dXMsIGNvbnN0IGhpZGxfdmVjPHVpbnQ4X3Q+JiBpZCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0dXMgPT0gU3RhdHVzOjpPSykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXNzaW9uSWQgPSB0b1ZlY3RvcihpZCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVyciA9IHRvU3RhdHVzVChzdGF0dXMpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CisgICAgICAgIH0KKworICAgICAgICBpZiAoIWhSZXN1bHQuaXNPaygpKSB7CisgICAgICAgICAgICBlcnIgPSBERUFEX09CSkVDVDsKKyAgICAgICAgfQorCisgICAgICAgIGlmIChlcnIgPT0gRVJST1JfRFJNX1JFU09VUkNFX0JVU1kgJiYgcmV0cnkpIHsKKyAgICAgICAgICAgIG1Mb2NrLnVubG9jaygpOworICAgICAgICAgICAgLy8gcmVjbGFpbVNlc3Npb24gbWF5IGNhbGwgYmFjayB0byBjbG9zZVNlc3Npb24sIHNpbmNlIG1Mb2NrIGlzCisgICAgICAgICAgICAvLyBzaGFyZWQgYmV0d2VlbiBEcm0gaW5zdGFuY2VzLCB3ZSBzaG91bGQgdW5sb2NrIGhlcmUgdG8gYXZvaWQKKyAgICAgICAgICAgIC8vIGRl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gICBJTklUX0NIRUNLKCk7CisKKyAgICBSZXR1cm48U3RhdHVzPiBzdGF0dXMgPSBtUGx1Z2luLT5jbG9zZVNlc3Npb24odG9IaWRsVmVjKHNlc3Npb25JZCkpOworICAgIGlmIChzdGF0dXMuaXNPaygpKSB7CisgICAgICAgIGlmIChzdGF0dXMgPT0gU3RhdHVzOjpPSykgeworICAgICAgICAgICAgRHJtU2Vzc2lvbk1hbmFnZXI6Okluc3RhbmNlKCktPnJlbW92ZVNlc3Npb24oc2Vzc2lvbklkKTsKKyAgICAgICAgICAgIGZvciAoYXV0byBpID0gbU9wZW5TZXNzaW9ucy5iZWdpbigpOyBpICE9IG1PcGVuU2Vzc2lvbnMuZW5kKCk7IGkrKykgeworICAgICAgICAgICAgICAgIGlmIChpc0VxdWFsU2Vzc2lvbklkKCgqaSktPm1TZXNzaW9uSWQsIHNlc3Npb25JZCkpIHsKKyAgICAgICAgICAgICAgICAgICAgbU9wZW5TZXNzaW9ucy5lcmFzZShpKTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgICAgIHN0YXR1c190IHJlc3BvbnNlID0gdG9TdGF0dXNUKHN0YXR1cyk7CisgICAgICAgIG1NZXRyaWNzLlNldFNlc3Npb25FbmQoc2Vzc2lvbklkKTsKKyAgICAgICAgbU1ldHJpY3MubUNsb3NlU2Vzc2lvbkNvdW50ZXIuSW5jcmVtZW50KHJlc3BvbnNlKTsKKyAgICAgICAgcmV0dXJuIHJlc3BvbnNlOworICAgIH0KKyAgICBtTWV0cmljcy5tQ2xvc2VTZXNzaW9uQ291bnRlci5JbmNyZW1lbnQoREVBRF9PQkpFQ1QpOworICAgIHJldHVybiBERUFEX09CSkVDVDsKK30KKworc3RhdGljIERybVBsdWdpbjo6S2V5UmVxdWVzdFR5cGUgdG9LZXlSZXF1ZXN0VHlwZShLZXlSZXF1ZXN0VHlwZSBrZXlSZXF1ZXN0VHlwZSkgeworICAgIHN3aXRjaCAoa2V5UmVxdWVzdFR5cGUpIHsKKyAgICAgICAgY2FzZSBLZXlSZXF1ZXN0VHlwZTo6SU5JVElBTDoKKyAgICAgICAgICAgIHJldHVybiBEcm1QbHVnaW46OmtLZXlSZXF1ZXN0VHlwZV9Jbml0aWFsOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgS2V5UmVxdWVzdFR5cGU6OlJFTkVXQUw6CisgICAgICAgICAgICByZXR1cm4gRHJtUGx1Z2luOjprS2V5UmVxdWVzdFR5cGVfUmVuZXdhbDsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIEtleVJlcXVlc3RUeXBlOjpSRUxFQVNFOgorICAgICAgICAgICAgcmV0dXJuIERybVBsdWdpbjo6a0tleVJlcXVlc3RUeXBlX1JlbGVhc2U7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgIHJldHVybiBEcm1QbHVnaW46OmtLZXlSZXF1ZXN0VHlwZV9Vbmtub3duOworICAgICAgICAgICAgYnJlYWs7CisgICAgfQorfQorCitzdGF0aWMgRHJtUGx1Z2luOjpLZXlSZXF1ZXN0VHlwZSB0b0tleVJlcXVlc3RUeXBlXzFfMShLZXlSZXF1ZXN0VHlwZV9WMV8xIGtleVJlcXVlc3RUeXBlKSB7CisgICAgc3dpdGNoIChrZXlSZXF1ZXN0VHlwZSkgeworICAgICAgICBjYXNlIEtleVJlcXVlc3RUeXBlX1YxXzE6Ok5PTkU6CisgICAgICAgICAgICByZXR1cm4gRHJtUGx1Z2luOjprS2V5UmVxdWVzdFR5cGVfTm9uZTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIEtleVJlcXVlc3RUeXBlX1YxXzE6OlVQREFURToKKyAgICAgICAgICAgIHJldHVybiBEcm1QbHVnaW46OmtLZXlSZXF1ZXN0VHlwZV9VcGRhdGU7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgIHJldHVybiB0b0tleVJlcXVlc3RUeXBlKHN0YXRpY19jYXN0PEtleVJlcXVlc3RUeXBlPihrZXlSZXF1ZXN0VHlwZSkpOworICAgICAgICAgICAgYnJlYWs7CisgICAgfQorfQorCitzdGF0dXNfdCBEcm1IYWxIaWRsOjpnZXRLZXlSZXF1ZXN0KFZlY3Rvcjx1aW50OF90PiBjb25zdCYgc2Vzc2lvbklkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QmIGluaXREYXRhLCBTdHJpbmc4IGNvbnN0JiBtaW1lVHlwZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRHJtUGx1Z2luOjpLZXlUeXBlIGtleVR5cGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEtleWVkVmVjdG9yPFN0cmluZzgsIFN0cmluZzg+IGNvbnN0JiBvcHRpb25hbFBhcmFtZXRlcnMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiYgcmVxdWVzdCwgU3RyaW5nOCYgZGVmYXVsdFVybCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRHJtUGx1Z2luOjpLZXlSZXF1ZXN0VHlwZSoga2V5UmVxdWVzdFR5cGUpIHsKKyAgICBNdXRleDo6QXV0b2xvY2sgYXV0b0xvY2sobUxvY2spOworICAgIElOSVRfQ0hFQ0soKTsKKyAgICBFdmVudFRpbWVyPHN0YXR1c190PiBrZXlSZXF1ZXN0VGltZXIoJm1NZXRyaWNzLm1HZXRLZXlSZXF1ZXN0VGltZVVzKTsKKworICAgIERybVNlc3Npb25NYW5hZ2VyOjpJbnN0YW5jZSgpLT51c2VTZXNzaW9uKHNlc3Npb25JZCk7CisKKyAgICBLZXlUeXBlIGhLZXlUeXBlOworICAgIGlmIChrZXlUeXBlID09IERybVBsd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WMV8xIGhLZXlSZXF1ZXN0VHlwZSwgY29uc3QgaGlkbF9zdHJpbmcmIGhEZWZhdWx0VXJsKSB7CisgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0dXMgPT0gU3RhdHVzX1YxXzI6Ok9LKSB7CisgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0ID0gdG9WZWN0b3IoaFJlcXVlc3QpOworICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFVybCA9IHRvU3RyaW5nOChoRGVmYXVsdFVybCk7CisgICAgICAgICAgICAgICAgICAgICAgICAqa2V5UmVxdWVzdFR5cGUgPSB0b0tleVJlcXVlc3RUeXBlXzFfMShoS2V5UmVxdWVzdFR5cGUpOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIGVyciA9IHRvU3RhdHVzVChzdGF0dXMpOworICAgICAgICAgICAgICAgIH0pOworICAgIH0gZWxzZSBpZiAobVBsdWdpblYxXzEgIT0gTlVMTCkgeworICAgICAgICBoUmVzdWx0ID0gbVBsdWdpblYxXzEtPmdldEtleVJlcXVlc3RfMV8xKAorICAgICAgICAgICAgICAgIHRvSGlkbFZlYyhzZXNzaW9uSWQpLCB0b0hpZGxWZWMoaW5pdERhdGEpLCB0b0hpZGxTdHJpbmcobWltZVR5cGUpLCBoS2V5VHlwZSwKKyAgICAgICAgICAgICAgICBoT3B0aW9uYWxQYXJhbWV0ZXJzLAorICAgICAgICAgICAgICAgIFsmXShTdGF0dXMgc3RhdHVzLCBjb25zdCBoaWRsX3ZlYzx1aW50OF90PiYgaFJlcXVlc3QsCisgICAgICAgICAgICAgICAgICAgIEtleVJlcXVlc3RUeXBlX1YxXzEgaEtleVJlcXVlc3RUeXBlLCBjb25zdCBoaWRsX3N0cmluZyYgaERlZmF1bHRVcmwpIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXR1cyA9PSBTdGF0dXM6Ok9LKSB7CisgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0ID0gdG9WZWN0b3IoaFJlcXVlc3QpOworICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFVybCA9IHRvU3RyaW5nOChoRGVmYXVsdFVybCk7CisgICAgICAgICAgICAgICAgICAgICAgICAqa2V5UmVxdWVzdFR5cGUgPSB0b0tleVJlcXVlc3RUeXBlXzFfMShoS2V5UmVxdWVzdFR5cGUpOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIGVyciA9IHRvU3RhdHVzVChzdGF0dXMpOworICAgICAgICAgICAgICAgIH0pOworICAgIH0gZWxzZSB7CisgICAgICAgIGhSZXN1bHQgPSBtUGx1Z2luLT5nZXRLZXlSZXF1ZXN0KAorICAgICAgICAgICAgICAgIHRvSGlkbFZlYyhzZXNzaW9uSWQpLCB0b0hpZGxWZWMoaW5pdERhdGEpLCB0b0hpZGxTdHJpbmcobWltZVR5cGUpLCBoS2V5VHlwZSwKKyAgICAgICAgICAgICAgICBoT3B0aW9uYWxQYXJhbWV0ZXJzLAorICAgICAgICAgICAgICAgIFsmXShTdGF0dXMgc3RhdHVzLCBjb25zdCBoaWRsX3ZlYzx1aW50OF90PiYgaFJlcXVlc3QsCisgICAgICAgICAgICAgICAgICAgIEtleVJlcXVlc3RUeXBlIGhLZXlSZXF1ZXN0VHlwZSwgY29uc3QgaGlkbF9zdHJpbmcmIGhEZWZhdWx0VXJsKSB7CisgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0dXMgPT0gU3RhdHVzOjpPSykgeworICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdCA9IHRvVmVjdG9yKGhSZXF1ZXN0KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHRVcmwgPSB0b1N0cmluZzgoaERlZmF1bHRVcmwpOworICAgICAgICAgICAgICAgICAgICAgICAgKmtleVJlcXVlc3RUeXBlID0gdG9LZXlSZXF1ZXN0VHlwZShoS2V5UmVxdWVzdFR5cGUpOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIGVyciA9IHRvU3RhdHVzVChzdGF0dXMpOworICAgICAgICAgICAgICAgIH0pOworICAgIH0KKworICAgIGVyciA9IGhSZXN1bHQuaXNPaygpID8gZXJyIDogREVBRF9PQkpFQ1Q7CisgICAga2V5UmVxdWVzdFRpbWVyLlNldEF0dHJpYnV0ZShlcnIpOworICAgIHJldHVybiBlcnI7Cit9CisKK3N0YXR1c190IERybUhhbEhpZGw6OnByb3ZpZGVLZXlSZXNwb25zZShWZWN0b3I8dWludDhfdD4gY29uc3QmIHNlc3Npb25JZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QmIHJlc3BvbnNlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiYga2V5U2V0SWQpIHsKKyAgICBNdXRleDo6QXV0b2xvY2sgYXV0b0xvY2sobUxvY2spOworICAgIElOSVRfQ0hFQ0soKTsKKyAgICBFdmVudFRpbWVyPHN0YXR1c190PiBrZXlSZXNwb25zZVRpbWVyKCZtTWV0cmljcy5tUHJvdmlkZUtleVJlc3BvbnNlVGltZVVzKTsKKworICAgIERybVNlc3Npb25NYW5hZ2VyOjpJbnN0YW5jZSgpLT51c2VTZXNzaW9uKHNlc3Npb25JZCk7CisKKyAgICBzdGF0dXNfdCBlcnIgPSBVTktOT1dOX0VSUk9SOworCisgICAgUmV0dXJuPHZvaWQ+IGhSZXN1bHQgPQorICAgICAgICAgICAgbVBsdWdpbi0+cHJvdmlkZUtleVJlc3BvbnNlKHRvSGlkbFZlYyhzZXNzaW9uSWQpLCB0b0hpZGxWZWMocmVzcG9uc2UpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFsmXShTdGF0dXMgc3RhdHVzLCBjb25zdCBoaWRsX3ZlYzx1aW50OF90PiYgaEtleVNldElkKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0dXMgPT0gU3RhdHVzOjpPSykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5U2V0SWQgPSB0b1ZlY3RvcihoS2V5U2V0SWQpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVyciA9IHRvU3RhdHVzVChzdGF0dXMpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOworICAgIGVyciA9IGhSZXN1bHQuaXNPaygpID8gZXJyIDogREVBRF9PQkpFQ1Q7CisgICAga2V5UmVzcG9uc2VUaW1lci5TZXRBdHRyaWJ1dGUoZXJyKTsKKyAgICByZXR1cm4gZXJyOworfQorCitzdGF0dXNfdCBEcm1IYWxIaWRsOjpyZW1vdmVLZXlzKFZlY3Rvcjx1aW50OF90PiBjb25zdCYga2V5U2V0SWQpIHsKKyAgICBNdXRleDo6QXV0b2xvY2sgYXV0b0xvY2sobUxvY2spOworICAgIElOSVRfQ0hFQ0soKTsKKworICAgIFJldHVybjxTdGF0dXM+IHN0YXR1cyA9IG1QbHVnaW4tPnJlbW92ZUtleXModG9IaWRsVmVjKGtleVNldElkKSk7CisgICAgcmV0dXJuIHN0YXR1cy5pc09rKCkgPyB0b1N0YXR1c1Qoc3RhdHVzKSA6IERFQURfT0JKRUNUOworfQorCitzdGF0dXNfdCBEcm1IYWxIaWRsOjpyZXN0b3JlS2V5cyhWZWN0b3I8dWludDhfdD4gY29uc3QmIHNlc3Npb25JZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiBjb25zdCYga2V5U2V0SWQpIHsKKyAgICBNdXRleDo6QXV0b2xvY2sgYXV0b0xvY2sobUxvY2spOworICAgIElOSVRfQ0hFQ0soKTsKKworICAgIERybVN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c1Qoc3RhdHVzKTsKKyAgICAgICAgICAgIH0pOworCisgICAgcmV0dXJuIGhSZXN1bHQuaXNPaygpID8gZXJyIDogREVBRF9PQkpFQ1Q7Cit9CisKK3N0YXR1c190IERybUhhbEhpZGw6OmdldFByb3Zpc2lvblJlcXVlc3QoU3RyaW5nOCBjb25zdCYgY2VydFR5cGUsIFN0cmluZzggY29uc3QmIGNlcnRBdXRob3JpdHksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiYgcmVxdWVzdCwgU3RyaW5nOCYgZGVmYXVsdFVybCkgeworICAgIE11dGV4OjpBdXRvbG9jayBhdXRvTG9jayhtTG9jayk7CisgICAgSU5JVF9DSEVDSygpOworCisgICAgc3RhdHVzX3QgZXJyID0gVU5LTk9XTl9FUlJPUjsKKyAgICBSZXR1cm48dm9pZD4gaFJlc3VsdDsKKworICAgIGlmIChtUGx1Z2luVjFfMiAhPSBOVUxMKSB7CisgICAgICAgIGhSZXN1bHQgPSBtUGx1Z2luVjFfMi0+Z2V0UHJvdmlzaW9uUmVxdWVzdF8xXzIoCisgICAgICAgICAgICAgICAgdG9IaWRsU3RyaW5nKGNlcnRUeXBlKSwgdG9IaWRsU3RyaW5nKGNlcnRBdXRob3JpdHkpLAorICAgICAgICAgICAgICAgIFsmXShTdGF0dXNfVjFfMiBzdGF0dXMsIGNvbnN0IGhpZGxfdmVjPHVpbnQ4X3Q+JiBoUmVxdWVzdCwKKyAgICAgICAgICAgICAgICAgICAgY29uc3QgaGlkbF9zdHJpbmcmIGhEZWZhdWx0VXJsKSB7CisgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0dXMgPT0gU3RhdHVzX1YxXzI6Ok9LKSB7CisgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0ID0gdG9WZWN0b3IoaFJlcXVlc3QpOworICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFVybCA9IHRvU3RyaW5nOChoRGVmYXVsdFVybCk7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgZXJyID0gdG9TdGF0dXNUKHN0YXR1cyk7CisgICAgICAgICAgICAgICAgfSk7CisgICAgfSBlbHNlIHsKKyAgICAgICAgaFJlc3VsdCA9IG1QbHVnaW4tPmdldFByb3Zpc2lvblJlcXVlc3QodG9IaWRsU3RyaW5nKGNlcnRUeXBlKSwgdG9IaWRsU3RyaW5nKGNlcnRBdXRob3JpdHkpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBbJl0oU3RhdHVzIHN0YXR1cywgY29uc3QgaGlkbF92ZWM8dWludDhfdD4mIGhSZXF1ZXN0LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGlkbF9zdHJpbmcmIGhEZWZhdWx0VXJsKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdHVzID09IFN0YXR1czo6T0spIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0ID0gdG9WZWN0b3IoaFJlcXVlc3QpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHRVcmwgPSB0b1N0cmluZzgoaERlZmF1bHRVcmwpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXJyID0gdG9TdGF0dXNUKHN0YXR1cyk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOworICAgIH0KKworICAgIGVyciA9IGhSZXN1bHQuaXNPaygpID8gZXJyIDogREVBRF9PQkpFQ1Q7CisgICAgbU1ldHJpY3MubUdldFByb3Zpc2lvblJlcXVlc3RDb3VudGVyLkluY3JlbWVudChlcnIpOworICAgIHJldHVybiBlcnI7Cit9CisKK3N0YXR1c190IERybUhhbEhpZGw6OnByb3ZpZGVQcm92aXNpb25SZXNwb25zZShWZWN0b3I8dWludDhfdD4gY29uc3QmIHJlc3BvbnNlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiYgY2VydGlmaWNhdGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+JiB3cmFwcGVkS2V5KSB7CisgICAgTXV0ZXg6OkF1dG9sb2NrIGF1dG9Mb2NrKG1Mb2NrKTsKKyAgICBJTklUX0NIRUNLKCk7CisKKyAgICBzdGF0dXNfdCBlcnIgPSBVTktOT1dOX0VSUk9SOworCisgICAgUmV0dXJuPHZvaWQ+IGhSZXN1bHQgPSBtUGx1Z2luLT5wcm92aWRlUHJvdmlzaW9uUmVzcG9uc2UoCisgICAgICAgICAgICB0b0hpZGxWZWMocmVzcG9uc2UpLCBbJl0oU3RhdHVzIHN0YXR1cywgY29uc3QgaGlkbF92ZWM8dWludDhfdD4mIGhDZXJ0aWZpY2F0ZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoaWRsX3ZlYzx1aW50OF90PiYgaFdyYXBwZWRLZXkpIHsKKyAgICAgICAgICAgICAgICBpZiAoc3RhdHVzID09IFN0YXR1czo6T0spIHsKKyAgICAgICAgICAgICAgICAgICAgY2VydGlmaWNhdGUgPSB0b1ZlY3RvcihoQ2VydGlmaWNhdGUpOworICAgICAgICAgICAgICAgICAgICB3cmFwcGVkS2V5ID0gdG9WZWN0b3IoaFdyYXBwZWRLZXkpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBlcnIgPSB0b1N0YXR1c1Qoc3RhdHVzKTsKKyAgICAgICAgICAg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scyhEcm1QbHVnaW46OkhkY3BMZXZlbCogY29ubmVjdGVkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBEcm1QbHVnaW46OkhkY3BMZXZlbCogbWF4KSBjb25zdCB7CisgICAgTXV0ZXg6OkF1dG9sb2NrIGF1dG9Mb2NrKG1Mb2NrKTsKKyAgICBJTklUX0NIRUNLKCk7CisKKyAgICBpZiAoY29ubmVjdGVkID09IE5VTEwgfHwgbWF4ID09IE5VTEwpIHsKKyAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKKyAgICB9CisgICAgc3RhdHVzX3QgZXJyID0gVU5LTk9XTl9FUlJPUjsKKworICAgICpjb25uZWN0ZWQgPSBEcm1QbHVnaW46OmtIZGNwTGV2ZWxVbmtub3duOworICAgICptYXggPSBEcm1QbHVnaW46OmtIZGNwTGV2ZWxVbmtub3duOworCisgICAgUmV0dXJuPHZvaWQ+IGhSZXN1bHQ7CisgICAgaWYgKG1QbHVnaW5WMV8yICE9IE5VTEwpIHsKKyAgICAgICAgaFJlc3VsdCA9IG1QbHVnaW5WMV8yLT5nZXRIZGNwTGV2ZWxzXzFfMihbJl0oU3RhdHVzX1YxXzIgc3RhdHVzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBIZGNwTGV2ZWxfVjFfMiYgaENvbm5lY3RlZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgSGRjcExldmVsX1YxXzImIGhNYXgpIHsKKyAgICAgICAgICAgIGlmIChzdGF0dXMgPT0gU3RhdHVzX1YxXzI6Ok9LKSB7CisgICAgICAgICAgICAgICAgKmNvbm5lY3RlZCA9IHRvSGRjcExldmVsKGhDb25uZWN0ZWQpOworICAgICAgICAgICAgICAgICptYXggPSB0b0hkY3BMZXZlbChoTWF4KTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGVyciA9IHRvU3RhdHVzVChzdGF0dXMpOworICAgICAgICB9KTsKKyAgICB9IGVsc2UgaWYgKG1QbHVnaW5WMV8xICE9IE5VTEwpIHsKKyAgICAgICAgaFJlc3VsdCA9IG1QbHVnaW5WMV8xLT5nZXRIZGNwTGV2ZWxzKAorICAgICAgICAgICAgICAgIFsmXShTdGF0dXMgc3RhdHVzLCBjb25zdCBIZGNwTGV2ZWwmIGhDb25uZWN0ZWQsIGNvbnN0IEhkY3BMZXZlbCYgaE1heCkgeworICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdHVzID09IFN0YXR1czo6T0spIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICpjb25uZWN0ZWQgPSB0b0hkY3BMZXZlbChzdGF0aWNfY2FzdDxIZGNwTGV2ZWxfVjFfMj4oaENvbm5lY3RlZCkpOworICAgICAgICAgICAgICAgICAgICAgICAgKm1heCA9IHRvSGRjcExldmVsKHN0YXRpY19jYXN0PEhkY3BMZXZlbF9WMV8yPihoTWF4KSk7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgZXJyID0gdG9TdGF0dXNUKHN0YXR1cyk7CisgICAgICAgICAgICAgICAgfSk7CisgICAgfSBlbHNlIHsKKyAgICAgICAgcmV0dXJuIEVSUk9SX0RSTV9DQU5OT1RfSEFORExFOworICAgIH0KKworICAgIHJldHVybiBoUmVzdWx0LmlzT2soKSA/IGVyciA6IERFQURfT0JKRUNUOworfQorCitzdGF0dXNfdCBEcm1IYWxIaWRsOjpnZXROdW1iZXJPZlNlc3Npb25zKHVpbnQzMl90KiBvcGVuLCB1aW50MzJfdCogbWF4KSBjb25zdCB7CisgICAgTXV0ZXg6OkF1dG9sb2NrIGF1dG9Mb2NrKG1Mb2NrKTsKKyAgICBJTklUX0NIRUNLKCk7CisKKyAgICBpZiAob3BlbiA9PSBOVUxMIHx8IG1heCA9PSBOVUxMKSB7CisgICAgICAgIHJldHVybiBCQURfVkFMVUU7CisgICAgfQorICAgIHN0YXR1c190IGVyciA9IFVOS05PV05fRVJST1I7CisKKyAgICAqb3BlbiA9IDA7CisgICAgKm1heCA9IDA7CisKKyAgICBpZiAobVBsdWdpblYxXzEgPT0gTlVMTCkgeworICAgICAgICByZXR1cm4gRVJST1JfRFJNX0NBTk5PVF9IQU5ETEU7CisgICAgfQorCisgICAgUmV0dXJuPHZvaWQ+IGhSZXN1bHQgPQorICAgICAgICAgICAgbVBsdWdpblYxXzEtPmdldE51bWJlck9mU2Vzc2lvbnMoWyZdKFN0YXR1cyBzdGF0dXMsIHVpbnQzMl90IGhPcGVuLCB1aW50MzJfdCBoTWF4KSB7CisgICAgICAgICAgICAgICAgaWYgKHN0YXR1cyA9PSBTdGF0dXM6Ok9LKSB7CisgICAgICAgICAgICAgICAgICAgICpvcGVuID0gaE9wZW47CisgICAgICAgICAgICAgICAgICAgICptYXggPSBoTWF4OworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBlcnIgPSB0b1N0YXR1c1Qoc3RhdHVzKTsKKyAgICAgICAgICAgIH0pOworCisgICAgcmV0dXJuIGhSZXN1bHQuaXNPaygpID8gZXJyIDogREVBRF9PQkpFQ1Q7Cit9CisKK3N0YXR1c190IERybUhhbEhpZGw6OmdldFNlY3VyaXR5TGV2ZWwoVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0JiBzZXNzaW9uSWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIERybVBsdWdpbjo6U2VjdXJpdHlMZXZlbCogbGV2ZWwpIGNvbnN0IHsKKyAgICBNdXRleDo6QXV0b2xvY2sgYXV0b0xvY2sobUxvY2spOworICAgIElOSVRfQ0hFQ0soKTsKKworICAgIGlmIChsZXZlbCA9PSBOVUxMKSB7CisgICAgICAgIHJldHVybiBCQURfVkFMVUU7CisgICAgfQorICAgIHN0YXR1c190IGVyciA9IFVOS05PV05fRVJST1I7CisKKyAgICBpZiAobVBsdWdpblYxXzEgPT0gTlVMTCkgeworICAgICAgICByZXR1cm4gRVJST1JfRFJNX0NBTk5PVF9IQU5ETEU7CisgICAgfQorCisgICAgKmxldmVsID0gRHJtUGx1Z2luOjprU2VjdXJpdHlMZXZlbFVua25vd247CisKKyAgICBSZXR1cm48dm9pZD4gaFJlc3VsdCA9IG1QbHVnaW5WMV8xLT5nZXRTZWN1cml0eUxldmVsKHRvSGlkbFZlYyhzZXNzaW9uSWQpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgWyZdKFN0YXR1cyBzdGF0dXMsIFNlY3VyaXR5TGV2ZWwgaExldmVsKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXR1cyA9PSBTdGF0dXM6Ok9LKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICpsZXZlbCA9IHRvU2VjdXJpdHlMZXZlbChoTGV2ZWwpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnIgPSB0b1N0YXR1c1Qoc3RhdHVzKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOworCisgICAgcmV0dXJuIGhSZXN1bHQuaXNPaygpID8gZXJyIDogREVBRF9PQkpFQ1Q7Cit9CisKK3N0YXR1c190IERybUhhbEhpZGw6OmdldE9mZmxpbmVMaWNlbnNlS2V5U2V0SWRzKExpc3Q8VmVjdG9yPHVpbnQ4X3Q+PiYga2V5U2V0SWRzKSBjb25zdCB7CisgICAgTXV0ZXg6OkF1dG9sb2NrIGF1dG9Mb2NrKG1Mb2NrKTsKKworICAgIGlmIChtSW5pdENoZWNrICE9IE9LKSB7Cis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Tk9ORSI7CisgICAgICAgIH0KKyAgICAgICAgdmVuZG9yICs9ICIuIjsKKyAgICAgICAgdmVuZG9yICs9IGRlc2NyaXB0aW9uOworCisgICAgICAgIGhpZGxfdmVjPERybU1ldHJpY0dyb3VwPiBwbHVnaW5NZXRyaWNzOworICAgICAgICBzdGF0dXNfdCBlcnIgPSBVTktOT1dOX0VSUk9SOworCisgICAgICAgIFJldHVybjx2b2lkPiBzdGF0dXMgPQorICAgICAgICAgICAgICAgIG1QbHVnaW5WMV8xLT5nZXRNZXRyaWNzKFsmXShTdGF0dXMgc3RhdHVzLCBoaWRsX3ZlYzxEcm1NZXRyaWNHcm91cD4gcGx1Z2luTWV0cmljcykgeworICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdHVzICE9IFN0YXR1czo6T0spIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIEFMT0dWKCJFcnJvciBnZXR0aW5nIHBsdWdpbiBtZXRyaWNzOiAlZCIsIHN0YXR1cyk7CisgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICBjb25zdW1lci0+Y29uc3VtZUhpZGxNZXRyaWNzKHZlbmRvciwgcGx1Z2luTWV0cmljcyk7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgZXJyID0gdG9TdGF0dXNUKHN0YXR1cyk7CisgICAgICAgICAgICAgICAgfSk7CisgICAgICAgIHJldHVybiBzdGF0dXMuaXNPaygpID8gZXJyIDogREVBRF9PQkpFQ1Q7CisgICAgfQorCisgICAgcmV0dXJuIE9LOworfQorCitzdGF0dXNfdCBEcm1IYWxIaWRsOjpzZXRDaXBoZXJBbGdvcml0aG0oVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0JiBzZXNzaW9uSWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nOCBjb25zdCYgYWxnb3JpdGhtKSB7CisgICAgTXV0ZXg6OkF1dG9sb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XQsIFZlY3Rvcjx1aW50OF90PiBjb25zdCYgaXYsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiYgb3V0cHV0KSB7CisgICAgTXV0ZXg6OkF1dG9sb2NrIGF1dG9Mb2NrKG1Mb2NrKTsKKyAgICBJTklUX0NIRUNLKCk7CisKKyAgICBEcm1TZXNzaW9uTWFuYWdlcjo6SW5zdGFuY2UoKS0+dXNlU2Vzc2lvbihzZXNzaW9uSWQpOworCisgICAgc3RhdHVzX3QgZXJyID0gVU5LTk9XTl9FUlJPUjsKKworICAgIFJldHVybjx2b2lkPiBoUmVzdWx0ID0KKyAgICAgICAgICAgIG1QbHVnaW4tPmVuY3J5cHQodG9IaWRsVmVjKHNlc3Npb25JZCksIHRvSGlkbFZlYyhrZXlJZCksIHRvSGlkbFZlYyhpbnB1dCksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvSGlkbFZlYyhpdiksIFsmXShTdGF0dXMgc3RhdHVzLCBjb25zdCBoaWRsX3ZlYzx1aW50OF90PiYgaE91dHB1dCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXR1cyA9PSBTdGF0dXM6Ok9LKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0ID0gdG9WZWN0b3IoaE91dHB1dCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnIgPSB0b1N0YXR1c1Qoc3RhdHVzKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CisKKyAgICByZXR1cm4gaFJlc3VsdC5pc09rKCkgPyBlcnIgOiBERUFEX09CSkVDVDsKK30KKworc3RhdHVzX3QgRHJtSGFsSGlkbDo6ZGVjcnlwdChWZWN0b3I8dWludDhfdD4gY29uc3QmIHNlc3Npb25JZCwgVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0JiBrZXlJZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0JiBpbnB1dCwgVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0JiBpdiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+JiBvdXRwdXQpIHsKKyAgICBNdXRleDo6QXV0b2xvY2sgYXV0b0xvY2sobUxvY2spOworICAgIElOSVRfQ0hFQ0soKTsKKworICAgIERybVNlc3Npb25NYW5hZ2VyOjpJbnN0YW5jZSgpLT51c2VTZXNzaW9uKHNlc3Npb25JZCk7CisKKyAgICBzdGF0dXNfdCBlcnIgPSBVTktOT1dOX0VSUk9SOworCisgICAgUmV0dXJuPHZvaWQ+IGhSZXN1bHQgPQorICAgICAgICAgICAgbVBsdWdpbi0+ZGVjcnlwdCh0b0hpZGxWZWMoc2Vzc2lvbklkKSwgdG9IaWRsVmVjKGtleUlkKSwgdG9IaWRsVmVjKGlucHV0KSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG9IaWRsVmVjKGl2KSwgWyZdKFN0YXR1cyBzdGF0dXMsIGNvbnN0IGhpZGxfdmVjPHVpbnQ4X3Q+JiBoT3V0cHV0KSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdHVzID09IFN0YXR1czo6T0spIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXQgPSB0b1ZlY3RvcihoT3V0cHV0KTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVyciA9IHRvU3RhdHVzVChzdGF0dXMpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKKworICAgIHJldHVybiBoUmVzdWx0LmlzT2soKSA/IGVyciA6IERFQURfT0JKRUNUOworfQorCitzdGF0dXNfdCBEcm1IYWxIaWRsOjpzaWduKFZlY3Rvcjx1aW50OF90PiBjb25zdCYgc2Vzc2lvbklkLCBWZWN0b3I8dWludDhfdD4gY29uc3QmIGtleUlkLAorICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QmIG1lc3NhZ2UsIFZlY3Rvcjx1aW50OF90PiYgc2lnbmF0dXJlKSB7CisgICAgTXV0ZXg6OkF1dG9sb2NrIGF1dG9Mb2NrKG1Mb2NrKTsKKyAgICBJTklUX0NIRUNLKCk7CisKKyAgICBEcm1TZXNzaW9uTWFuYWdlcjo6SW5zdGFuY2UoKS0+dXNlU2Vzc2lvbihzZXNzaW9uSWQpOworCisgICAgc3RhdHVzX3QgZXJyID0gVU5LTk9XTl9FUlJPUjsKKworICAgIFJldHVybjx2b2lkPiBoUmVzdWx0ID0gbVBsdWdpbi0+c2lnbih0b0hpZGxWZWMoc2Vzc2lvbklkKSwgdG9IaWRsVmVjKGtleUlkKSwgdG9IaWRsVmVjKG1lc3NhZ2UpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBbJl0oU3RhdHVzIHN0YXR1cywgY29uc3QgaGlkbF92ZWM8dWludDhfdD4mIGhTaWduYXR1cmUpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0dXMgPT0gU3RhdHVzOjpPSykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpZ25hdHVyZSA9IHRvVmVjdG9yKGhTaWduYXR1cmUpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXJyID0gdG9TdGF0dXNUKHN0YXR1cyk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOworCisgICAgcmV0dXJuIGhSZXN1bHQuaXNPaygpID8gZXJyIDogREVBRF9PQkpFQ1Q7Cit9CisKK3N0YXR1c190IERybUhhbEhpZGw6OnZlcmlmeShWZWN0b3I8dWludDhfdD4gY29uc3QmIHNlc3Npb25JZCwgVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0JiBrZXlJZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QmIG1lc3NhZ2UsIFZlY3Rvcjx1aW50OF90PiBjb25zdCYgc2lnbmF0dXJlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wmIG1hdGNoKSB7CisgICAgTXV0ZXg6OkF1dG9sb2NrIGF1dG9Mb2NrKG1Mb2NrKTsKKyAgICBJTklUX0NIRUNLKCk7CisKKyAgICBEcm1TZXNzaW9uTWFuYWdlcjo6SW5zdGFuY2UoKS0+dXNlU2Vzc2lvbihzZXNzaW9uSWQpOworCisgICAgc3RhdHVzX3QgZXJyID0gVU5LTk9XTl9FUlJPUjsKKworICAgIFJldHVybjx2b2lkPiBoUmVzdWx0ID0KKyAgICAgICAgICAgIG1QbHVnaW4tPnZlcmlmeSh0b0hpZGxWZWMoc2Vzc2lvbklkKSwgdG9IaWRsVmVjKGtleUlkKSwgdG9IaWRsVmVjKG1lc3NhZ2UpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvSGlkbFZlYyhzaWduYXR1cmUpLCBbJl0oU3RhdHVzIHN0YXR1cywgYm9vbCBoTWF0Y2gpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXR1cyA9PSBTdGF0dXM6Ok9LKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXRjaCA9IGhNYXRjaDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hdGNoID0gZmFsc2U7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXJyID0gdG9TdGF0dXNUKHN0YXR1cyk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CisKKyAgICByZXR1cm4gaFJlc3VsdC5pc09rKCkgPyBlcnIgOiBERUFEX09CSkVDVDsKK30KKworc3RhdHVzX3QgRHJtSGFsSGlkbDo6c2lnblJTQShWZWN0b3I8dWludDhfdD4gY29uc3QmIHNlc3Npb25JZCwgU3RyaW5nOCBjb25zdCYgYWxnb3JpdGhtLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QmIG1lc3NhZ2UsIFZlY3Rvcjx1aW50OF90PiBjb25zdCYgd3JhcHBlZEtleSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+JiBzaWduYXR1cmUpIHsKKyAgICBNdXRleDo6QXV0b2xvY2sgYXV0b0xvY2sobUxvY2spOworICAgIElOSVRfQ0hFQ0soKTsKKworICAgIERybVNlc3Npb25NYW5hZ2VyOjpJbnN0YW5jZSgpLT51c2VTZXNzaW9uKHNlc3Npb25JZCk7CisKKyAgICBzdGF0dXNfdCBlcnIgPSBVTktOT1dOX0VSUk9SOworCisgICAgUmV0dXJuPHZvaWQ+IGhSZXN1bHQgPSBtUGx1Z2luLT5zaWduUlNBKAorICAgICAgICAgICAgdG9IaWRsVmVjKHNlc3Npb25JZCksIHRvSGlkbFN0cmluZyhhbGdvcml0aG0pLCB0b0hpZGxWZWMobWVzc2FnZSksCisgICAgICAgICAgICB0b0hpZGxWZWMod3JhcHBlZEtleSksIFsmXShTdGF0dXMgc3RhdHVzLCBjb25zdCBoaWRsX3ZlYzx1aW50OF90PiYgaFNpZ25hdHVyZSkgeworICAgICAgICAgICAgICAgIGlmIChzdGF0dXMgPT0gU3RhdHVzOjpPSykgeworICAgICAgICAgICAgICAgICAgICBzaWduYXR1cmUgPSB0b1ZlY3Rvc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2xvY2sgbG9jayhtRXZlbnRMb2NrKTsKKyAgICBtTGlzdGVuZXIgPSBsaXN0ZW5lcjsKK30KKworOjpuZGs6OlNjb3BlZEFTdGF0dXMgRHJtSGFsTGlzdGVuZXI6Om9uRXZlbnQoRXZlbnRUeXBlQWlkbCBldmVudFR5cGVBaWRsLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnZlY3Rvcjx1aW50OF90PiYgc2Vzc2lvbklkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnZlY3Rvcjx1aW50OF90PiYgZGF0YSkgeworICAgIG1NZXRyaWNzLT5tRXZlbnRDb3VudGVyLkluY3JlbWVudCgodWludDMyX3QpZXZlbnRUeXBlQWlkbCk7CisKKyAgICBtRXZlbnRMb2NrLmxvY2soKTsKKyAgICBzcDxJRHJtQ2xpZW50PiBsaXN0ZW5lciA9IG1MaXN0ZW5lcjsKKyAgICBtRXZlbnRMb2NrLnVubG9jaygpOworCisgICAgaWYgKGxpc3RlbmVyICE9IE5VTEwpIHsKKyAgICAgICAgTXV0ZXg6OkF1dG9sb2NrIGxvY2sobU5vdGlmeUxvY2spOworICAgICAgICBEcm1QbHVnaW46OkV2ZW50VHlwZSBldmVudFR5cGU7CisgICAgICAgIHN3aXRjaCAoZXZlbnRUeXBlQWlkbCkgeworICAgICAgICAgICAgY2FzZSBFdmVudFR5cGVBaWRsOjpQUk9WSVNJT05fUkVRVUlSRUQ6CisgICAgICAgICAgICAgICAgZXZlbnRUeXBlID0gRHJtUGx1Z2luOjprRHJtUGx1Z2luRXZlbnRQcm92aXNpb25SZXF1aXJlZDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgRXZlbnRUeXBlQWlkbDo6S0VZX05FRURFRDoKKyAgICAgICAgICAgICAgICBldmVudFR5cGUgPSBEcm1QbHVnaW46OmtEcm1QbHVnaW5FdmVudEtleU5lZWRlZDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgRXZlbnRUeXBlQWlkbDo6S0VZX0VYUElSRUQ6CisgICAgICAgICAgICAgICAgZXZlbnRUeXBlID0gRHJtUGx1Z2luOjprRHJtUGx1Z2luRXZlbnRLZXlFeHBpcmVkOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBFdmVudFR5cGVBaWRsOjpWRU5ET1JfREVGSU5FRDoKKyAgICAgICAgICAgICAgICBldmVudFR5cGUgPSBEcm1QbHVnaW46OmtEcm1QbHVnaW5FdmVudFZlbmRvckRlZmluZWQ7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIEV2ZW50VHlwZUFpZGw6OlNFU1NJT05fUkVDTEFJTUVEOgorICAgICAgICAgICAgICAgIGV2ZW50VHlwZSA9IERybVBsdWdpbjo6a0RybVBsdWdpbkV2ZW50U2Vzc2lvblJlY2xhaW1lZDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgcmV0dXJuIDo6bmRrOjpTY29wZWRBU3RhdHVzOjpvaygpOworICAgICAgICB9CisKKyAgICAgICAgbGlzdGVuZXItPnNlbmRFdmVudChldmVudFR5cGUsIHRvSGlkbFZlYyh0b1ZlY3RvcihzZXNzaW9uSWQpKSwgdG9IaWRsVmVjKHRvVmVjdG9yKGRhdGEpKSk7CisgICAgfQorCisgICAgcmV0dXJuIDo6bmRrOjpTY29wZWRBU3RhdHVzOjpvaygpOworfQorCis6Om5kazo6U2NvcGVkQVN0YXR1cyBEcm1IYWxMaXN0ZW5lcjo6b25FeHBpcmF0aW9uVXBkYXRlKGNvbnN0IHN0ZDo6dmVjdG9yPHVpbnQ4X3Q+JiBzZXNzaW9uSWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50NjRfdCBleHBpcnlUaW1lSW5NUykgeworICAgIG1FdmVudExvY2subG9jaygpOworICAgIHNwPElEcm1DbGllbnQ+IGxpc3RlbmVyID0gbUxpc3RlbmVyOworICAgIG1FdmVudExvY2sudW5sb2NrKCk7CisKKyAgICBpZiAobGlzdGVuZXIgIT0gTlVMTCkgeworICAgICAgICBNdXRleDo6QXV0b2xvY2sgbG9jayhtTm90aWZ5TG9jayk7CisgICAgICAgIGxpc3RlbmVyLT5zZW5kRXhwaXJhdGlvblVwZGF0ZSh0b0hpZGxWZWModG9WZWN0b3Ioc2Vzc2lvbklkKSksIGV4cGlyeVRpbWVJbk1TKTsKKyAgICB9CisKKyAgICByZXR1cm4gOjpuZGs6OlNjb3BlZEFTdGF0dXM6Om9rKCk7Cit9CisKKzo6bmRrOjpTY29wZWRBU3RhdHVzIERybUhhbExpc3RlbmVyOjpvbktleXNDaGFuZ2UoY29uc3Qgc3RkOjp2ZWN0b3I8dWludDhfdD4mIHNlc3Npb25JZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnZlY3RvcjxLZXlTdGF0dXNBaWRsPiYga2V5U3RhdHVzTGlzdEFpZGwsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBoYXNOZXdVc2FibGVLZXkpIHsKKyAgICBtRXZlbnRMb2NrLmxvY2soKTsKKyAgICBzcDxJRHJtQ2xpZW50PiBsaXN0ZW5lciA9IG1MaXN0ZW5lcjsKKyAgICBtRXZlbnRMb2NrLnVubG9jaygpOworCisgICAgaWYgKGxpc3RlbmVyICE9IE5VTEwpIHsKKyAgICAgICAgc3RkOjp2ZWN0b3I8RHJtS2V5U3RhdHVzPiBrZXlTdGF0dXNMaXN0OworICAgICAgICBzaXplX3QgbktleXMgPSBrZXlTdGF0dXNMaXN0QWlkbC5zaXplKCk7CisgICAgICAgIGZvciAoc2l6ZV90IGkgPSAwOyBpIDwgbktleXM7ICsraSkgeworICAgICAgICAgICAgY29uc3QgS2V5U3RhdHVzQWlkbCBrZXlTdGF0dXMgPSBrZXlTdGF0dXNMaXN0QWlkbFtpXTsKKyAgICAgICAgICAgIHVpbnQzMl90IHR5cGU7CisgICAgICAgICAgICBzd2l0Y2ggKGtleVN0YXR1cy50eXBlKSB7CisgICAgICAgICAgICAgICAgY2FzZSBLZXlTdGF0dXNUeXBlOjpVU0FCTEU6CisgICAgICAgICAgICAgICAgICAgIHR5cGUgPSBEcm1QbHVnaW46OmtLZXlTdGF0dXNUeXBlX1VzYWJsZTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSBLZXlTdGF0dXNUeXBlOjpFWFBJUkVEOgorICAgICAgICAgICAgICAgICAgICB0eXBlID0gRHJtUGx1Z2luOjprS2V5U3RhdHVzVHlwZV9FeHBpcmVkOworICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICBjYXNlIEtleVN0YXR1c1R5cGU6Ok9VVFBVVF9OT1RfQUxMT1dFRDoKKyAgICAgICAgICAgICAgICAgICAgdHlwZSA9IERybVBsdWdpbjo6a0tleVN0YXR1c1R5cGVfT3V0cHV0Tm90QWxsb3dlZDsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSBLZXlTdGF0dXNUeXBlOjpTVEFUVVNfUEVORElORzoKKyAgICAgICAgICAgICAgICAgICAgdHlwZSA9IERybVBsdWdpbjo6a0tleVN0YXR1c1R5cGVfU3RhdHVzUGVuZGluZzsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSBLZXlTdGF0dXNUeXBlOjpVU0FCTEVfSU5fRlVUVVJFOgorICAgICAgICAgICAgICAgICAgICB0eXBlID0gRHJtUGx1Z2luOjprS2V5U3RhdHVzVHlwZV9Vc2FibGVJbkZ1dHVyZTsKKyAgICAgICAgICAgICAgICAg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l0oY29uc3QgS2V5U3RhdHVzVHlwZSBrZXlfc3RhdHVzX3R5cGUsIGNvbnN0IGludDY0X3QgdmFsdWUpIHsKKyAgICAgICAgWyZdKGNvbnN0IHVpbnQzMl90IGtleV9zdGF0dXNfdHlwZSwgY29uc3QgaW50NjRfdCB2YWx1ZSkgewogICAgICAgICAgICAgRHJtRnJhbWV3b3JrTWV0cmljczo6Q291bnRlciAqY291bnRlciA9CiAgICAgICAgICAgICAgICAgbWV0cmljcy5hZGRfa2V5X3N0YXR1c19jaGFuZ2VfY291bnRlcigpOwogICAgICAgICAgICAgY291bnRlci0+c2V0X2NvdW50KHZhbHVlKTsKLSAgICAgICAgICAgIGNvdW50ZXItPm11dGFibGVfYXR0cmlidXRlcygpLT5zZXRfa2V5X3N0YXR1c190eXBlKAotICAgICAgICAgICAgICAgICh1aW50MzJfdClrZXlfc3RhdHVzX3R5cGUpOworICAgICAgICAgICAgY291bnRlci0+bXV0YWJsZV9hdHRyaWJ1dGVzKCktPnNldF9rZXlfc3RhdHVzX3R5cGUoa2V5X3N0YXR1c190eXBlKTsKICAgICAgICAgfSk7CiAKICAgICBtRXZlbnRDb3VudGVyLkV4cG9ydFZhbHVlcygKLSAgICAgICAgWyZdKGNvbnN0IEV2ZW50VHlwZSBldmVudF90eXBlLCBjb25zdCBpbnQ2NF90IHZhbHVlKSB7CisgICAgICAgIFsmXShjb25zdCB1aW50MzJfdCBldmVudF90eXBlLCBjb25zdCBpbnQ2NF90IHZhbHVlKSB7CiAgICAgICAgICAgICBEcm1GcmFtZXdvcmtNZXRyaWNzOjpDb3VudGVyICpjb3VudGVyID0KICAgICAgICAgICAgICAgICBtZXRyaWNzLmFkZF9ldmVudF9jYWxsYmFja19jb3VudGVyKCk7CiAgICAgICAgICAgICBjb3VudGVyLT5zZXRfY291bnQodmFsdWUpOwotICAgICAgICAgICAgY291bnRlci0+bXV0YWJsZV9hdHRyaWJ1dGVzKCktPnNldF9ldmVudF90eXBlKCh1aW50MzJfdClldm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gICAgICAgIk9VVFBVVF9OT1RfQUxMT1dFRCIsICJTVEFUVVNfUEVORElORyIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiSU5URVJOQUxfRVJST1IiLCAiVVNBQkxFX0lOX0ZVVFVSRSJ9OwotICAgIGlmICgoKHNpemVfdCl0eXBlKSA+PSBhcnJheXNpemUodHlwZV9uYW1lcykpIHsKLSAgICAgICAgcmV0dXJuICJVTktOT1dOX1RZUEUiOworICAgICAgICBpZiAoYXR0cmlidXRlID49IGFycmF5c2l6ZSh0eXBlX25hbWVzKSkgeworICAgICAgICAgICAgcmV0dXJuICJVTktOT1dOX1RZUEUiOworICAgICAgICB9CisgICAgICAgIHJldHVybiB0eXBlX25hbWVzW2F0dHJpYnV0ZV07CiAgICAgfQotICAgIHJldHVybiB0eXBlX25hbWVzWyhzaXplX3QpdHlwZV07Ci19Ci0KLXRlbXBsYXRlIDw+IHN0ZDo6c3RyaW5nIEdldEF0dHJpYnV0ZU5hbWU8RXZlbnRUeXBlPihFdmVudFR5cGUgdHlwZSkgeworICAgIAogICAgIHN0YXRpYyBjb25zdCBjaGFyICp0eXBlX25hbWVzW10gPSB7IlBST1ZJU0lPTl9SRVFVSVJFRCIsICJLRVlfTkVFREVEIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJLRVlfRVhQSVJFRCIsICJWRU5ET1JfREVGSU5FRCIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiU0VTU0lPTl9SRUNMQUlNRUQifTsKLSAgICBpZiAoKChzaXplX3QpdHlwZSkgPj0gYXJyYXlzaXplKHR5cGVfbmFtZXMpKSB7CisgICAgaWYgKGF0dHJpYnV0ZSA+PSBhcnJheXNpemUodHlwZV9uYW1lcykpIHsKICAgICAgICAgcmV0dXJuICJVTktOT1dOX1RZUEUiOwogICAgIH0KLSAgICByZXR1cm4gdHlwZV9uYW1lc1soc2l6ZV90KXR5cGVdOworICAgI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29uc3QgaGlkbF92ZWM8aGlkbF9zdHJpbmc+ICZyZWdpc3RlcmVkKSB7Ci0gICAgICAgIGZvciAoY29uc3QgYXV0byAmaW5zdGFuY2UgOiByZWdpc3RlcmVkKSB7Ci0gICAgICAgICAgICBhdXRvIGZhY3RvcnkgPSBIYWw6OmdldFNlcnZpY2UoaW5zdGFuY2UpOwotICAgICAgICAgICAgaWYgKGZhY3RvcnkgIT0gbnVsbHB0cikgewotICAgICAgICAgICAgICAgIGluc3RhbmNlc1tpbnN0YW5jZS5jX3N0cigpXSA9IEhhbDo6ZGVzY3JpcHRvcjsKLSAgICAgICAgICAgICAgICBpZiAoIXV1aWQpIHsKLSAgICAgICAgICAgICAgICAgICAgZmFjdG9yaWVzLnB1c2hfYmFjayhmYWN0b3J5KTsKLSAgICAgICAgICAgICAgICAgICAgY29udGludWU7CisgICAgc2VydmljZU1hbmFnZXItPmxpc3RNYW5pZmVzdEJ5SW50ZXJmYWNlKAorICAgICAgICAgICAgSGFsOjpkZXNjcmlwdG9yLCBbJl0oY29uc3QgaGlkbF92ZWM8aGlkbF9zdHJpbmc+JiByZWdpc3RlcmVkKSB7CisgICAgICAgICAgICAgICAgZm9yIChjb25zdCBhdXRvJiBpbnN0YW5jZSA6IHJlZ2lzdGVyZWQpIHsKKyAgICAgICAgICAgICAgICAgICAgYXV0byBmYWN0b3J5ID0gSGFsOjpnZXRTZXJ2aWNlKGluc3RhbmNlKTsKKyAgICAgICAgICAgICAgICAgICAgaWYgKGZhY3RvcnkgIT0gbnVsbHB0cikgeworICAgICAgICAgICAgICAgICAgICAgICAgaW5zdGFuY2VzW2luc3RhbmNlLmNfc3RyKCldID0gSGFsOjpkZXNjcmlwdG9yOworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF1dWlkKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmFjdG9yaWVzLnB1c2hfYmFjayhmYWN0b3J5KTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIGF1dG8gc3VwcG9ydGVkID0gZmFjdG9yeS0+aXNDcnlwdG9TY2hlbWVTdXBwb3J0ZWQodXVpZCk7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXN1cHBvcnRlZC5pc09rKCkpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBMT0cyQkUodXVpZCwgImlzQ3J5cHRvU2NoZW1lU3VwcG9ydGVkIHR4biBmYWlsZWQ6ICVzIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3VwcG9ydGVkLmRlc2NyaXB0aW9uKCkuY19zdHIoKSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3VwcG9ydGVkKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmFjdG9yaWVzLnB1c2hfYmFjayhmYWN0b3J5KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBhdXRvIHN1cHBvcnRlZCA9IGZhY3RvcnktPmlzQ3J5cHRvU2NoZW1lU3VwcG9ydGVkKHV1aWQpOwotICAgICAgICAgICAgICAgIGlmICghc3VwcG9ydGVkLmlzT2soKSkgewotICAgICAgICAgICAgICAgICAgICBMT0cyQkUodXVpZCwgImlzQ3J5cHRvU2NoZW1lU3VwcG9ydGVkIHR4biBmYWlsZWQ6ICVzIiwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1cHBvcnRlZC5kZXNjcmlwdGlvbigpLmNfc3RyKCkpOwotICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgaWYgKHN1cHBvcnRlZCkgew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OiAlZCIsIHN0YXR1cyk7CiAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKQEAgLTE0MSwxMyArMTQzLDEzIEBACiAgICAgfQogfQogCi1zcDw6OlYxXzA6OklDcnlwdG9QbHVnaW4+IE1ha2VDcnlwdG9QbHVnaW4oY29uc3Qgc3A8OjpWMV8wOjpJQ3J5cHRvRmFjdG9yeT4gJmZhY3RvcnksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdWludDhfdCB1dWlkWzE2XSwgY29uc3Qgdm9pZCAqaW5pdERhdGEsCitzcDw6OlYxXzA6OklDcnlwdG9QbHVnaW4+IE1ha2VDcnlwdG9QbHVnaW4oY29uc3Qgc3A8OjpWMV8wOjpJQ3J5cHRvRmFjdG9yeT4mIGZhY3RvcnksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdWludDhfdCB1dWlkWzE2XSwgY29uc3Qgdm9pZCogaW5pdERhdGEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90IGluaXREYXRhU2l6ZSkgewogICAgIHNwPDo6VjFfMDo6SUNyeXB0b1BsdWdpbj4gcGx1Z2luOwogICAgIGF1dG8gZXJyID0gZmFjdG9yeS0+Y3JlYXRlUGx1Z2luKAogICAgICAgICAgICAgdG9IaWRsQXJyYXkxNih1dWlkKSwgdG9IaWRsVmVjKGluaXREYXRhLCBpbml0RGF0YVNpemUpLAotICAgICAgICAgICAgWyZdKDo6VjFfMDo6U3RhdHVzIHN0YXR1cywgY29uc3Qgc3A8OjpWMV8wOjpJQ3J5cHRvUGx1Z2luPiAmaFBsdWdpbikgeworICAgICAgICAgICAgWyZdKDo6VjFfMDo6U3RhdHVzIHN0YXR1cywgY29uc3Qgc3A8OjpWMV8wOjpJQ3J5cHRvUGx1Z2luPiYgaFBsdWdpbikgewogICAgICAgICAgICAgICAgIGlmIChzdGF0dXMgIT0gO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ICAgYnJlYWs7CisgICAgICAgIGNhc2UgOjpWMV80OjpMb2dQcmlvcml0eTo6SU5GTzoKKyAgICAgICAgICAgIHAgPSAnSSc7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSA6OlYxXzQ6OkxvZ1ByaW9yaXR5OjpXQVJOOgorICAgICAgICAgICAgcCA9ICdXJzsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIDo6VjFfNDo6TG9nUHJpb3JpdHk6OkVSUk9SOgorICAgICAgICAgICAgcCA9ICdFJzsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIDo6VjFfNDo6TG9nUHJpb3JpdHk6OkZBVEFMOgorICAgICAgICAgICAgcCA9ICdGJzsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgcCA9ICdVJzsKKyAgICAgICAgICAgIGJyZWFrOwogICAgIH0KICAgICByZXR1cm4gcDsKIH0KIH0gIC8vIG5hbWVzcGFjZQogCi1zdGQ6OnN0cmluZyBHZXRFeGNlcHRpb25NZXNzYWdlKHN0YXR1c190IGVyciwgY29uc3QgY2hhciAqbXNnLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBWZWN0b3I8OjpWMV80OjpMb2dNZXNzYWdlPiAmbG9ncykgeworc3RkOjpzdHJpbmcgR2V0RXhjZXB0aW9uTWVzc2FnZShzdGF0dXNfdCBlcnIsIGNvbnN0IGNoYXIqIG1zZywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgVmVjdG9yPDo6VjFfNDo6TG9nTWVzc2FnZT4mIGxvZ3MpIHsKICAgICBzdGQ6OnN0cmluZyBydWxlcigiPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Iik7CiAgICAgc3RkOjpzdHJpbmcgaGVhZGVyKCJCZWdpbm5pbmcgb2YgRFJNIFBsdWdpbiBMb2ciKTsKICAgICBzdGQ6OnN0cmluZyBmb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KSA9PSAwOwotfQotCi1zdHJ1Y3QgRHJtSGFsIDogcHVibGljIElEcm0sCi0gICAgICAgICAgICAgICAgcHVibGljIElEcm1QbHVnaW5MaXN0ZW5lcl9WMV8yIHsKLQotICAgIHN0cnVjdCBEcm1TZXNzaW9uQ2xpZW50OwotCitzdHJ1Y3QgRHJtSGFsIDogcHVibGljIElEcm0gewogICAgIERybUhhbCgpOwogICAgIHZpcnR1YWwgfkRybUhhbCgpOwotCiAgICAgdmlydHVhbCBzdGF0dXNfdCBpbml0Q2hlY2soKSBjb25zdDsKLQogICAgIHZpcnR1YWwgc3RhdHVzX3QgaXNDcnlwdG9TY2hlbWVTdXBwb3J0ZWQoY29uc3QgdWludDhfdCB1dWlkWzE2XSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFN0cmluZzgmIG1pbWVUeXBlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRHJtUGx1Z2luOjpTZWN1cml0eUxldmVsIGxldmVsLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCAqaXNTdXBwb3J0ZWQpOwotCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBTdHJpbmc4ICZtaW1lVHlwZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIERybVBsdWdpbjo6U2VjdXJpdHlMZXZlbCBzZWN1cml0eUxldmVsLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCAqcmVzdWx0KTsKICAgICB2aXJ0dWFsIHN0YXR1c190IGNyZWF0ZVBsdWdpbihjb25zdCB1aW50OF90IHV1aWRbMTZdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFN0cmluZzggJmFwcFBhY2thZ2VOYW1lKTsKLQogICAgIHZpcnR1Y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AgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+ICZrZXlTZXRJZCk7Ci0KICAgICB2aXJ0dWFsIHN0YXR1c190IHJlbW92ZUtleXMoVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0ICZrZXlTZXRJZCk7Ci0KICAgICB2aXJ0dWFsIHN0YXR1c190IHJlc3RvcmVLZXlzKFZlY3Rvcjx1aW50OF90PiBjb25zdCAmc2Vzc2lvbklkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0ICZrZXlTZXRJZCk7Ci0KICAgICB2aXJ0dWFsIHN0YXR1c190IHF1ZXJ5S2V5U3RhdHVzKFZlY3Rvcjx1aW50OF90PiBjb25zdCAmc2Vzc2lvbklkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgS2V5ZWRWZWN0b3I8U3RyaW5nOCwgU3RyaW5nOD4gJmluZm9NYXApIGNvbnN0OwotCiAgICAgdmlydHVhbCBzdGF0dXNfdCBnZXRQcm92aXNpb25SZXF1ZXN0KFN0cmluZzggY29uc3QgJmNlcnRUeXBlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmc4IGNvbnN0ICZjZXJ0QXV0aG9yaXR5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gJnJlcXVlc3QsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZzggJmRlZmF1bFVybCk7Ci0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nOCAmZGVmYXVsdFVybCk7CiAgICAgdmlydHVhbCBzdGF0dXNfdCBwcm92aWRlUHJvdmlzaW9uUmVzcG9uc2UoVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0ICZyZXNwb25zZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC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AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+ICZ2YWx1ZSkgY29uc3Q7CisgICAgdmlydHVhbCBzdGF0dXNfdCBzZXRQcm9wZXJ0eVN0cmluZyhTdHJpbmc4IGNvbnN0ICZuYW1lLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nOCBjb25zdCAmdmFsdWUgKSBjb25zdDsKICAgICB2aXJ0dWFsIHN0YXR1c190IHNldFByb3BlcnR5Qnl0ZUFycmF5KFN0cmluZzggY29uc3QgJm5hbWUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QgJnZhbHVlICkgY29uc3Q7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QgJnZhbHVlKSBjb25zdDsKICAgICB2aXJ0dWFsIHN0YXR1c190IGdldE1ldHJpY3MoY29uc3Qgc3A8SURybU1ldHJpY3NDb25zdW1lcj4gJmNvbnN1bWVyKTsKLQogICAgIHZpcnR1YWwgc3RhdHVzX3Qgc2V0Q2lwaGVyQWxnb3JpdGhtKFZlY3Rvcjx1aW50OF90PiBjb25zdCAmc2Vzc2lvbklkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZzggY29uc3QgJmFsZ29yaXRobSk7Ci0KICAgICB2aXJ0dWFsIHN0YXR1c190IHNldE1hY0FsZ29yaXRobShWZWN0b3I8dWludDhfdD4gY29uc3QgJnNlc3Npb25JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmc4IGNvbnN0ICZhbGdvcml0aG0pOwotCiAgICAgdmlydHVhbCBzdGF0dXNfdCBlbmNyeXB0KFZlY3Rvcjx1aW50OF90PiBjb25zdCAmc2Vzc2lvbklkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QgJmtleUlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QgJmlucHV0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QgJml2LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gJm91dHB1dCk7Ci0KICAgICB2aXJ0dWFsIHN0YXR1c190IGRlY3J5cHQoVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0ICZzZXNzaW9uSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiBjb25zdCAma2V5SWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiBjb25zdCAmaW5wdXQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiBjb25zdCAmaXYsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiAmb3V0cHV0KTsKLQogICAgIHZpcnR1YWwgc3RhdHVzX3Qgc2lnbihWZWN0b3I8dWludDhfdD4gY29uc3QgJnNlc3Npb25JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0ICZrZXlJZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0ICZtZXNzYWdlLAogICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gJnNpZ25hdHVyZSk7Ci0KICAgICB2aXJ0dWFsIHN0YXR1c190IHZlcmlmeShWZWN0b3I8dWludDhfdD4gY29uc3QgJnNlc3Npb25JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QgJmtleUlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiBjb25zdCAmbWVzc2FnZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QgJnNpZ25hdHVyZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sICZtYXRjaCk7Ci0KICAgICB2aXJ0dWFsIHN0YXR1c190IHNpZ25SU0EoVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0ICZzZXNzaW9uSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZzggY29uc3QgJmFsZ29yaXRobSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0ICZtZXNzYWdlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QgJndyYXBwZWRLZXksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiAmc2lnbmF0dXJlKTsKLQogICAgIHZpcnR1YWwgc3RhdHVzX3Qgc2V0TGlzdGVuZXIoY29uc3Qgc3A8SURybUNsaWVudD4mIGxpc3RlbmVyKTsKLQogICAgIHZpcnR1YWwgc3RhdHVzX3QgcmVxdWlyZXNTZWN1cmVEZWNvZGVyKGNvbnN0IGNoYXIgKm1pbWUsIGJvb2wgKnJlcXVpcmVkKSBjb25zdDsKLQogICAgIHZpcnR1YWwgc3RhdHVzX3QgcmVxdWlyZXNTZWN1cmVEZWNvZGVyKGNvbnN0IGNoYXIgKm1pbWUsIERybVBsdWdpbjo6U2VjdXJpdHlMZXZlbCBzZWN1cml0eUxldmVsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgKnJlcXVpcmVkKSBjb25zdDsKLQogICAgIHZpcnR1YWwgc3RhdHVzX3Qgc2V0UGxheWJhY2tJZCgKICAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiB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N0b3J5PiAmZmFjdG9yeSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1aW50OF90IHV1aWRbMTZdLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFN0cmluZzggJm1pbWVUeXBlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIERybVBsdWdpbjo6U2VjdXJpdHlMZXZlbCBsZXZlbCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sICppc1N1cHBvcnRlZCk7Ci0KKyAgICBzcDxJRHJtPiBtRHJtSGFsSGlkbDsKKyAgICBzcDxJRHJtPiBtRHJtSGFsQWlkbDsKICAgICBESVNBTExPV19FVklMX0NPTlNUUlVDVE9SUyhEcm1IYWwpOwogfTsKIAotfSAgLy8gbmFtZXNwYWNlIGFuZHJvaWQKK30gLy8gbmFtZXNwYWNlIGFuZHJvaWQKIAotI2VuZGlmICAvLyBEUk1fSEFMX0hfCisjZW5kaWYgIC8vIERSTV9IQUxfSF8KXCBObyBuZXdsaW5lIGF0IGVuZCBvZiBmaWxlCmRpZmYgLS1naXQgYS9kcm0vbGlibWVkaWFkcm0vaW5jbHVkZS9tZWRpYWRybS9Ecm1IYWxBaWRsLmggYi9kcm0vbGlibWVkaWFkcm0vaW5jbHVkZS9tZWRpYWRybS9Ecm1IYWxBaWRsLmgKbmV3IGZpbGUgbW9kZSAxMDA2NDQKaW5kZXggMDAwMDAwMC4uMGY1MWNlOQotLS0gL2Rldi9udWxsCisrKyBiL2RybS9saWJtZWRpYWRybS9pbmNsdWRlL21lZGlhZHJtL0RybUhhbEFpZGwuaApAQCAtMCwwICsxLDEzOCBAQAorLyoKKyAqIENvcHlyaWdodCAoQykgMjAyMSBUaGUgQW5kcm9pZCBPcGVuIFNvdXJjZSBQcm9qZWN0CisgKgorICogTGljZW5zZWQgdW5kZXIgdGhlIEFwYWNoZS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gICAgICAgRHJtUGx1Z2luOjpTZWN1cml0eUxldmVsIHNlY3VyaXR5TGV2ZWwsIGJvb2wqIHJlc3VsdCk7CisgICAgdmlydHVhbCBzdGF0dXNfdCBjcmVhdGVQbHVnaW4oY29uc3QgdWludDhfdCB1dWlkWzE2XSwgY29uc3QgU3RyaW5nOCYgYXBwUGFja2FnZU5hbWUpOworICAgIHZpcnR1YWwgc3RhdHVzX3QgZGVzdHJveVBsdWdpbigpOworICAgIHZpcnR1YWwgc3RhdHVzX3Qgb3BlblNlc3Npb24oRHJtUGx1Z2luOjpTZWN1cml0eUxldmVsIHNlY3VyaXR5TGV2ZWwsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4mIHNlc3Npb25JZCk7CisgICAgdmlydHVhbCBzdGF0dXNfdCBjbG9zZVNlc3Npb24oVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0JiBzZXNzaW9uSWQpOworICAgIHZpcnR1YWwgc3RhdHVzX3QgZ2V0S2V5UmVxdWVzdChWZWN0b3I8dWludDhfdD4gY29uc3QmIHNlc3Npb25JZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0JiBpbml0RGF0YSwgU3RyaW5nOCBjb25zdCYgbWltZVR5cGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIERybVBsdWdpbjo6S2V5VHlwZSBrZXlUeXBlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBLZXllZFZlY3RvcjxTdHJpbmc4LCBTdHJpbmc4PiBjb25zdCYgb3B0aW9uYWxQYXJhbWV0ZXJzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4mIHJlcXVlc3QsIFN0cmluZzgmIGRlZmF1bHRVcmwsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIERybVBsdWdpbjo6S2V5UmVxdWVzdFR5cGUqIGtleVJlcXVlc3RUeXBlKTsKKyAgICB2aXJ0dWFsIHN0YXR1c190IHByb3ZpZGVLZXlSZXNwb25zZShWZWN0b3I8dWludDhfdD4gY29uc3QmIHNlc3Npb25JZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QmIHJlc3BvbnNlLCBWZWN0b3I8dWludDhfdD4mIGtleVNldElkKTsKKyAgICB2aXJ0dWFsIHN0YXR1c190IHJlbW92ZUtleXMoVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0JiBrZXlTZXRJZCk7CisgICAgdmlydHVhbCBzdGF0dXNfdCByZXN0b3JlS2V5cyhWZWN0b3I8dWludDhfdD4gY29uc3QmIHNlc3Npb25JZCwgVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0JiBrZXlTZXRJZCk7CisgICAgdmlydHVhbCBzdGF0dXNfdCBxdWVyeUtleVN0YXR1cyhWZWN0b3I8dWludDhfdD4gY29uc3QmIHNlc3Npb25JZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEtleWVkVmVjdG9yPFN0cmluZzgsIFN0cmluZzg+JiBpbmZvTWFwKSBjb25zdDsKKyAgICB2aXJ0dWFsIHN0YXR1c190IGdldFByb3Zpc2lvblJlcXVlc3QoU3RyaW5nOCBjb25zdCYgY2VydFR5cGUsIFN0cmluZzggY29uc3QmIGNlcnRBdXRob3JpdHksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiYgcmVxdWVzdCwgU3RyaW5nOCYgZGVmYXVsdFVybCk7CisgICAgdmlydHVhbCBzdGF0dXNfdCBwcm92aWRlUHJvdmlzaW9uUmVzcG9uc2UoVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0JiByZXNwb25zZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0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B2YWx1ZSkgY29uc3Q7CisgICAgdmlydHVhbCBzdGF0dXNfdCBnZXRNZXRyaWNzKGNvbnN0IHNwPElEcm1NZXRyaWNzQ29uc3VtZXI+JiBjb25zdW1lcik7CisgICAgdmlydHVhbCBzdGF0dXNfdCBzZXRDaXBoZXJBbGdvcml0aG0oVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0JiBzZXNzaW9uSWQsIFN0cmluZzggY29uc3QmIGFsZ29yaXRobSk7CisgICAgdmlydHVhbCBzdGF0dXNfdCBzZXRNYWNBbGdvcml0aG0oVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0JiBzZXNzaW9uSWQsIFN0cmluZzggY29uc3QmIGFsZ29yaXRobSk7CisgICAgdmlydHVhbCBzdGF0dXNfdCBlbmNyeXB0KFZlY3Rvcjx1aW50OF90PiBjb25zdCYgc2Vzc2lvbklkLCBWZWN0b3I8dWludDhfdD4gY29uc3QmIGtleUlkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QmIGlucHV0LCBWZWN0b3I8dWludDhfdD4gY29uc3QmIGl2LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4mIG91dHB1dCk7CisgICAgdmlydHVhbCBzdGF0dXNfdCBkZWNyeXB0KFZlY3Rvcjx1aW50OF90PiBjb25zdCYgc2Vzc2lvbklkLCBWZWN0b3I8dWludDhfdD4gY29uc3QmIGtleUlkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QmIGlucHV0LCBWZWN0b3I8dWludDhfdD4gY29uc3QmIGl2LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4mIG91dHB1dCk7CisgICAgdmlydHVhbCBzdGF0dXNfdCBzaWduKFZlY3Rvcjx1aW50OF90PiBjb25zdCYgc2Vzc2lvbklkLCBWZWN0b3I8dWludDhfdD4gY29uc3QmIG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MV8yIHsKKworICAgIHN0cnVjdCBEcm1TZXNzaW9uQ2xpZW50OworCisgICAgRHJtSGFsSGlkbCgpOworICAgIHZpcnR1YWwgfkRybUhhbEhpZGwoKTsKKworICAgIHZpcnR1YWwgc3RhdHVzX3QgaW5pdENoZWNrKCkgY29uc3Q7CisKKyAgICB2aXJ0dWFsIHN0YXR1c190IGlzQ3J5cHRvU2NoZW1lU3VwcG9ydGVkKGNvbnN0IHVpbnQ4X3QgdXVpZFsxNl0sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBTdHJpbmc4JiBtaW1lVHlwZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIERybVBsdWdpbjo6U2VjdXJpdHlMZXZlbCBsZXZlbCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgKmlzU3VwcG9ydGVkKTsKKworICAgIHZpcnR1YWwgc3RhdHVzX3QgY3JlYXRlUGx1Z2luKGNvbnN0IHVpbnQ4X3QgdXVpZFsxNl0sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgU3RyaW5nOCAmYXBwUGFja2FnZU5hbWUpOworCisgICAgdmlydHVhbCBzdGF0dXNfdCBkZXN0cm95UGx1Z2luKCk7CisKKyAgICB2aXJ0dWFsIHN0YXR1c190IG9wZW5TZXNzaW9uKERybVBsdWdpbjo6U2VjdXJpdHlMZXZlbCBsZXZlbCwKKyAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiAmc2Vzc2lvbklkKTsKKworICAgIHZpcnR1YWwgc3RhdHVzX3QgY2xvc2VTZXNzaW9uKFZlY3Rvcjx1aW50OF90PiBjb25zdCAmc2Vzc2lvbklkKTsKKworICAgIHZpcnR1YWwgc3RhdHVzX3QKKyAgICAgICAgZ2V0S2V5UmVxdWVzdChWZWN0b3I8dWludDhfdD4gY29uc3QgJnNlc3Npb25JZCwKKyAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QgJmluaXREYXRhLAorICAgICAgICAgICAgICAgICAgICAgIFN0cmluZzggY29uc3QgJm1pbWVUeXBlLCBEcm1QbHVnaW46OktleVR5cGUga2V5VHlwZSwKKyAgICAgICAgICAgICAgICAgICAgICBLZXllZFZlY3RvcjxTdHJpbmc4LCBTdHJpbmc4PiBjb25zdCAmb3B0aW9uYWxQYXJhbWV0ZXJzLAorICAgICAgICAgICAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiAmcmVxdWVzdCwgU3RyaW5nOCAmZGVmYXVsdFVybCwKKyAgICAgICAgICAgICAgICAgICAgICBEcm1QbHVnaW46OktleVJlcXVlc3RUeXBlICprZXlSZXF1ZXN0VHlwZSk7CisKKyAgICB2aXJ0dWFsIHN0YXR1c190IHByb3ZpZGVLZXlSZXNwb25zZShWZWN0b3I8dWludDhfdD4gY29uc3QgJnNlc3Npb25JZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QgJnJlc3BvbnNlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiAma2V5U2V0SWQpOworCisgICAgdmlydHVhbCBzdGF0dXNfdCByZW1vdmVLZXlzKFZlY3Rvcjx1aW50OF90PiBjb25zdCAma2V5U2V0SWQpOworCisgICAgdmlydHVhbCBzdGF0dXNfdCByZXN0b3JlS2V5cyhWZWN0b3I8dWludDhfdD4gY29uc3QgJnNlc3Npb25JZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiBjb25zdCAma2V5U2V0SWQpOworCisgICAgdmlydHVhbCBzdGF0dXNfdCBxdWVyeUtleVN0YXR1cyhWZWN0b3I8dWludDhfdD4gY29uc3QgJnNlc3Npb25JZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEtleWVkVmVjdG9yPFN0cmluZzgsIFN0cmluZzg+ICZpbmZvTWFwKSBjb25zdDsKKworICAgIHZpcnR1YWwgc3RhdHVzX3QgZ2V0UHJvdmlzaW9uUmVxdWVzdChTdHJpbmc4IGNvbnN0ICZjZXJ0VHlwZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nOCBjb25zdCAmY2VydEF1dGhvcml0eSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+ICZyZXF1ZXN0LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmc4ICZkZWZhdWx0VXJsKTsKKworICAgIHZpcnR1YWwgc3RhdHVzX3QgcHJvdmlkZVByb3Zpc2lvblJlc3BvbnNlKFZlY3Rvcjx1aW50OF90PiBjb25zdCAmcmVzcG9uc2UsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+ICZjZXJ0aWZpY2F0ZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gJndyYXBwZWRLZXkpOworCisgICAgdmlydHVhbCBzdGF0dXNfdCBnZXRTZWN1cmVTdG9wcyhMaXN0PFZlY3Rvcjx1aW50OF90Pj4gJnNlY3VyZVN0b3BzKTsKKyAgICB2aXJ0dWFsIHN0YXR1c190IGdldFNlY3VyZVN0b3BJZHMoTGlzdDxWZWN0b3I8dWludDhfdD4+ICZzZWN1cmVTdG9wSWRzKTsKKyAgICB2aXJ0dWFsIHN0YXR1c190IGdldFNlY3VyZVN0b3AoVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0ICZzc2lkLCBWZWN0b3I8dWludDhfdD4gJnNlY3VyZVN0b3ApOworCisgICAgdmlydHVhbCBzdGF0dXNfdCByZWxlYXNlU2Vj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nNlU3RhdGUgKmxpY2Vuc2VTdGF0ZSkgY29uc3Q7CisKKyAgICB2aXJ0dWFsIHN0YXR1c190IGdldFByb3BlcnR5U3RyaW5nKFN0cmluZzggY29uc3QgJm5hbWUsIFN0cmluZzggJnZhbHVlICkgY29uc3Q7CisgICAgdmlydHVhbCBzdGF0dXNfdCBnZXRQcm9wZXJ0eUJ5dGVBcnJheShTdHJpbmc4IGNvbnN0ICZuYW1lLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+ICZ2YWx1ZSApIGNvbnN0OworICAgIHZpcnR1YWwgc3RhdHVzX3Qgc2V0UHJvcGVydHlTdHJpbmcoU3RyaW5nOCBjb25zdCAmbmFtZSwgU3RyaW5nOCBjb25zdCAmdmFsdWUgKSBjb25zdDsKKyAgICB2aXJ0dWFsIHN0YXR1c190IHNldFByb3BlcnR5Qnl0ZUFycmF5KFN0cmluZzggY29uc3QgJm5hbWUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QgJnZhbHVlICkgY29uc3Q7CisgICAgdmlydHVhbCBzdGF0dXNfdCBnZXRNZXRyaWNzKGNvbnN0IHNwPElEcm1NZXRyaWNzQ29uc3VtZXI+ICZjb25zdW1lcik7CisKKyAgICB2aXJ0dWFsIHN0YXR1c190IHNldENpcGhlckFsZ29yaXRobShWZWN0b3I8dWludDhfdD4gY29uc3QgJnNlc3Npb25JZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmc4IGNvbnN0ICZhbGdvcml0aG0pOworCisgICAgdmlydHVhbCBzdGF0dXNfdCBzZXRNYWNBbGdvcml0aG0oVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0ICZzZXNzaW9uSWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RyaW5nOCBjb25zdCAmYWxnb3JpdGhtKTsKKworICAgIHZpcnR1YWwgc3RhdHVzX3QgZW5jcnlwdChWZWN0b3I8dWludDhfdD4gY29uc3QgJnNlc3Npb25JZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0ICZrZXlJZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0ICZpbnB1dCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0ICZpdiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+ICZvdXRwdXQpOworCisgICAgdmlydHVhbCBzdGF0dXNfdCBkZWNyeXB0KFZlY3Rvcjx1aW50OF90PiBjb25zdCAmc2Vzc2lvbklkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QgJmtleUlkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QgJmlucHV0LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QgJml2LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gJm91dHB1dCk7CisKKyAgICB2aXJ0dWFsIHN0YXR1c190IHNpZ24oVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0ICZzZXNzaW9uSWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiBjb25zdCAma2V5SWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiBjb25zdCAmbWVzc2FnZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+ICZzaWduYXR1cmUpOworCisgICAgdmlydHVhbCBzdGF0dXNfdCB2ZXJpZnkoVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0ICZzZXNzaW9uSWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0ICZrZXlJZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gY29uc3QgJm1lc3NhZ2UsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0ICZzaWduYXR1cmUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCAmbWF0Y2gpOworCisgICAgdmlydHVhbCBzdGF0dXNfdCBzaWduUlNBKFZlY3Rvcjx1aW50OF90PiBjb25zdCAmc2Vzc2lvbklkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTdHJpbmc4IGNvbnN0ICZhbGdvcml0aG0sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZlY3Rvcjx1aW50OF90PiBjb25zdCAmbWVzc2FnZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVmVjdG9yPHVpbnQ4X3Q+IGNvbnN0ICZ3cmFwcGVkS2V5LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICBWZWN0b3I8dWludDhfdD4gJnNpZ25hdHVyZSk7CisKKyAgICB2aXJ0dWFsIHN0YXR1c190IHNldExpc3RlbmVyKGNvbnN0IHNwPElEcm1DbGllbnQ+JiBsaXN0ZW5lcik7CisKKyAgICB2aXJ0dWFsIHN0YXR1c190IHJlcXVpcmVzU2VjdXJlRGVjb2Rlcihjb25zdCBjaGFyICptaW1lLCBib29sICpyZXF1aXJlZCkgY29uc3Q7CisKKyAgICB2aXJ0dWFsIHN0YXR1c190IHJlcXVpcmVzU2VjdXJlRGVjb2Rlcihjb25zdCBjaGFyICptaW1lLCBEcm1QbHVnaW46OlNlY3VyaXR5TGV2ZWwgc2VjdXJpdHlMZXZlbCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICA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YmxlX2xpY2Vuc2VzOiBbImZyYW1ld29ya3NfYXZfbGljZW5zZSJdLAorfQorCitjY19kZWZhdWx0cyB7CisgICAgbmFtZTogImFpZGxfY2xlYXJrZXlfc2VydmljZV9kZWZhdWx0cyIsCisgICAgdmVuZG9yOiB0cnVlLAorCisgICAgc3JjczogWworICAgICAgICAiQ3JlYXRlUGx1Z2luRmFjdG9yaWVzLmNwcCIsCisgICAgICAgICJDcnlwdG9QbHVnaW4uY3BwIiwKKyAgICAgICAgIkRybUZhY3RvcnkuY3BwIiwKKyAgICAgICAgIkRybVBsdWdpbi5jcHAiLAorICAgIF0sCisKKyAgICByZWxhdGl2ZV9pbnN0YWxsX3BhdGg6ICJodyIsCisKKyAgICBjZmxhZ3M6IFsiLVdhbGwiLCAiLVdlcnJvciIsICItV3RocmVhZC1zYWZldHkiXSwKKworICAgIGluY2x1ZGVfZGlyczogWyJmcmFtZXdvcmtzL2F2L2luY2x1ZGUiXSwKKworICAgIHNoYXJlZF9saWJzOiBbCisgICAgICAgICJsaWJiYXNlIiwKKyAgICAgICAgImxpYmJpbmRlcl9uZGsiLAorICAgICAgICAibGliY3J5cHRvIiwKKyAgICAgICAgImxpYmxvZyIsCisgICAgICAgICJsaWJwcm90b2J1Zi1jcHAtbGl0ZSIsCisgICAgICAgICJsaWJ1dGlscyIsCisgICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLmRybS1WMS1uZGsiLAorICAgIF0sCisKKyAgICBzdGF0aWNfbGliczogWworICAgICAgICAiYW5kcm9pZC5oYXJkd2FyZS5jb21tb24tVjItbmRrIiwKKyAgICAgICAgImxpYmNsZWFya2V5YmFzZSIsCisgICAgXSwKKworICAgIGxvY2FsX2luY2x1ZGVfZGlyczogWyJpbmNsdWRlIl0sCisKKyAgICBzYW5pdGl6ZTogeworICAgICAgICBpbnRlZ2VyX292ZXJmbG93OiB0cnVlLAorICAgIH0sCit9CisKK2NjX2JpbmFyeSB7CisgICAgbmFtZTogImFuZHJvaWQuaGF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kU3Vic2FtcGxlcykgeworICAgICAgICAgICAgZGV0YWlsZWRFcnJvciA9ICJFbmNyeXB0ZWQgc3Vic2FtcGxlcyBmb3VuZCBpbiBhbGxlZ2VkbHkgdW5lbmNyeXB0ZWQgZGF0YS4iOworICAgICAgICAgICAgcmV0dXJuIHRvTmRrU2NvcGVkQVN0YXR1cyhTdGF0dXM6OkVSUk9SX0RSTV9DQU5OT1RfSEFORExFLCBkZXRhaWxlZEVycm9yKTsKKyAgICAgICAgfQorCisgICAgICAgIHNpemVfdCBvZmZzZXQgPSAwOworICAgICAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IGluX2FyZ3Muc3ViU2FtcGxlcy5zaXplKCk7ICsraSkgeworICAgICAgICAgICAgY29uc3QgU3ViU2FtcGxlJiBzdWJTYW1wbGUgPSBpbl9hcmdzLnN1YlNhbXBsZXNbaV07CisgICAgICAgICAgICBpZiAoc3ViU2FtcGxlLm51bUJ5dGVzT2ZDbGVhckRhdGEgIT0gMCkgeworICAgICAgICAgICAgICAgIG1lbWNweShyZWludGVycHJldF9jYXN0PHVpbnQ4X3QqPihkZXN0UHRyKSArIG9mZnNldCwKKyAgICAgICAgICAgICAgICAgICAgICAgcmVpbnRlcnByZXRfY2FzdDxjb25zdCB1aW50OF90Kj4oc3JjUHRyKSArIG9mZnNldCwKKyAgICAgICAgICAgICAgICAgICAgICAgc3ViU2FtcGxlLm51bUJ5dGVzT2ZDbGVhckRhdGEpOworICAgICAgICAgICAgICAgIG9mZnNldCArPSBzdWJTYW1wbGUubnVtQnl0ZXNPZkNsZWFyRGF0YTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorCisgICAgICAgICpfYWlkbF9yZXR1cm4gPSBzdGF0aWNfY2FzdDxzc2l6ZV90PihvZmZzZXQpOworICAgICAgICByZXR1cm4gdG9OZGtTY29wZWRBU3RhdHVzKFN0YXR1czo6T0spOworICAgIH0gZWxzZSBpZiAoaW5fYXJncy5tb2RlID09IE1vZGU6OkFFU19DVFIpIHsKKyAgICAgICAgc2l6ZV90IGJ5dGVzRGVjcnlwdGVke307CisgICAgICAgIHN0ZDo6dmVjdG9yPGludDMyX3Q+IGNsZWFyRGF0YUxlbmd0aHM7CisgICAgICAgIHN0ZDo6dmVjdG9yPGludDMyX3Q+IGVuY3J5cHRlZERhdGFMZW5ndGhzOworICAgICAgICBmb3IgKGF1dG8gc3MgOiBpbl9hcmdzLnN1YlNhbXBsZXMpIHsKKyAgICAgICAgICAgIGNsZWFyRGF0YUxlbmd0aHMucHVzaF9iYWNrKHNzLm51bUJ5dGVzT2ZDbGVhckRhdGEpOworICAgICAgICAgICAgZW5jcnlwdGVkRGF0YUxlbmd0aHMucHVzaF9iYWNrKHNzLm51bUJ5dGVzT2ZFbmNyeXB0ZWREYXRhKTsKKyAgICAgICAgfQorICAgICAgICBhdXRvIHJlcyA9CisgICAgICAgICAgICAgICAgbVNlc3Npb24tPmRlY3J5cHQoaW5fYXJncy5rZXlJZC5kYXRhKCksIGluX2FyZ3MuaXYuZGF0YSgpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNyY1B0ciwgc3RhdGljX2Nhc3Q8dWludDhfdCo+KGRlc3RQdHIpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFyRGF0YUxlbmd0aHMsIGVuY3J5cHRlZERhdGFMZW5ndGhzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZieXRlc0RlY3J5cHRlZCk7CisgICAgICAgIGlmIChyZXMgPT0gY2xlYXJrZXlkcm06Ok9LKSB7CisgICAgICAgICAgICAqX2FpZGxfcmV0dXJuID0gc3RhdGljX2Nhc3Q8c3NpemVfdD4oYnl0ZXNEZWNyeXB0ZWQpOworICAgICAgICAgICAgcmV0dXJuIHRvTmRrU2NvcGVkQVN0YXR1cyhTdGF0dXM6Ok9LKTsKKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICpfYWlkbF9yZXR1cm4gPSAwOworICA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zLCA6OmFpZGw6OmFuZHJvaWQ6OmhhcmR3YXJlOjpkcm06OkxvZ1ByaW9yaXR5OjpFUlJPUiwKKyAgICAgICAgICAgICBzdGQ6OnN0cmluZygiTm90IGltcGxlbWVudGVkIil9fTsKKyAgICAqX2FpZGxfcmV0dXJuID0gbG9nczsKKyAgICByZXR1cm4gdG9OZGtTY29wZWRBU3RhdHVzKFN0YXR1czo6T0spOworfQorCis6Om5kazo6U2NvcGVkQVN0YXR1cyBDcnlwdG9QbHVnaW46Om5vdGlmeVJlc29sdXRpb24oaW50MzJfdCBpbl93aWR0aCwgaW50MzJfdCBpbl9oZWlnaHQpIHsKKyAgICBVTlVTRUQoaW5fd2lkdGgpOworICAgIFVOVVNFRChpbl9oZWlnaHQpOworICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6b2soKTsKK30KKworOjpuZGs6OlNjb3BlZEFTdGF0dXMgQ3J5cHRvUGx1Z2luOjpyZXF1aXJlc1NlY3VyZURlY29kZXJDb21wb25lbnQoY29uc3Qgc3RkOjpzdHJpbmcmIGluX21pbWUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sKiBfYWlkbF9yZXR1cm4pIHsKKyAgICBVTlVTRUQoaW5fbWltZSk7CisgICAgKl9haWRsX3JldHVybiA9IGZhbHNlOworICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6b2soKTsKK30KKworOjpuZGs6OlNjb3BlZEFTdGF0dXMgQ3J5cHRvUGx1Z2luOjpzZXRNZWRpYURybVNlc3Npb24oY29uc3Qgc3RkOjp2ZWN0b3I8dWludDhfdD4mIGluX3Nlc3Npb25JZCkgeworICAgIFN0YXR1cyBzdGF0dXMgPSBTdGF0dXM6Ok9LOworICAgIGlmICghaW5fc2Vzc2lvbklkLnNpemUoKSkgeworICAgICAgICBtU2Vzc2lvbiA9IG51bGxwdHI7CisgICAgfSBlbHNlIHsKK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isKKyAgICAgICAgICAgICAgICBib29sIG9rID0gbUZpbGVIYW5kbGUuU3RvcmVMaWNlbnNlKAorICAgICAgICAgICAgICAgICAgICAgICAga2V5U2V0SWQsIERldmljZUZpbGVzOjprTGljZW5zZVN0YXRlQWN0aXZlLAorICAgICAgICAgICAgICAgICAgICAgICAgc3RkOjpzdHJpbmcoaW5fcmVzcG9uc2UuYmVnaW4oKSwgaW5fcmVzcG9uc2UuZW5kKCkpKTsKKyAgICAgICAgICAgICAgICBpZiAoIW9rKSB7CisgICAgICAgICAgICAgICAgICAgIEFMT0dFKCJGYWlsZWQgdG8gc3RvcmUgb2ZmbGluZSBsaWNlbnNlIik7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorICAgICAgICB9CisKKyAgICAgICAgLy8gVGVzdCBjYWxsaW5nIEFNZWRpYURybSBsaXN0ZW5lcnMuCisgICAgICAgIHNlbmRFdmVudChFdmVudFR5cGU6OlZFTkRPUl9ERUZJTkVELCBzZXNzaW9uSWQsIHNlc3Npb25JZCk7CisKKyAgICAgICAgc2VuZEV4cGlyYXRpb25VcGRhdGUoc2Vzc2lvbklkLCAxMDApOworCisgICAgICAgIHN0ZDo6dmVjdG9yPEtleVN0YXR1cz4ga2V5c1N0YXR1cyA9IHt9OworICAgICAgICBLZXlTdGF0dXMga2V5U3RhdHVzOworCisgICAgICAgIHN0ZDo6dmVjdG9yPHVpbnQ4X3Q+IGtleUlkMSA9IHsweEEsIDB4QiwgMHhDfTsKKyAgICAgICAga2V5U3RhdHVzLmtleUlkID0ga2V5SWQxOworICAgICAgICBrZXlTdGF0dXMudHlwZSA9IEtleVN0YXR1c1R5cGU6OlVTQUJMRTsKKyAgICAgICAga2V5c1N0YXR1cy5wdXNoX2JhY2soa2V5U3RhdHVzKTsKKworICAgICAgICBzdGQ6OnZlY3Rvcjx1aW50OF90PiBrZXlJZDIgPSB7MHhELCAweEUsIDB4Rn07CisgICAgICAgIGtleVN0YXR1cy5rZXlJZCA9IGtleU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ICAgfQorICAgIHJldHVybiB0b05ka1Njb3BlZEFTdGF0dXMocmVzKTsKK30KKwordm9pZCBEcm1QbHVnaW46OnNlbmRFdmVudCg6OmFpZGw6OmFuZHJvaWQ6OmhhcmR3YXJlOjpkcm06OkV2ZW50VHlwZSBpbl9ldmVudFR5cGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnZlY3Rvcjx1aW50OF90PiYgaW5fc2Vzc2lvbklkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjp2ZWN0b3I8dWludDhfdD4mIGluX2RhdGEpIHsKKyAgICBpZiAobUxpc3RlbmVyICE9IG51bGxwdHIpIHsKKyAgICAgICAgbUxpc3RlbmVyLT5vbkV2ZW50KGluX2V2ZW50VHlwZSwgaW5fc2Vzc2lvbklkLCBpbl9kYXRhKTsKKyAgICB9IGVsc2UgeworICAgICAgICBBTE9HRSgiTnVsbCBldmVudCBsaXN0ZW5lciwgZXZlbnQgbm90IHNlbnQiKTsKKyAgICB9CisgICAgcmV0dXJuOworfQorCit2b2lkIERybVBsdWdpbjo6c2VuZEV4cGlyYXRpb25VcGRhdGUoY29uc3Qgc3RkOjp2ZWN0b3I8dWludDhfdD4mIGluX3Nlc3Npb25JZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50NjRfdCBpbl9leHBpcnlUaW1lSW5NUykgeworICAgIGlmIChtTGlzdGVuZXIgIT0gbnVsbHB0cikgeworICAgICAgICBtTGlzdGVuZXItPm9uRXhwaXJhdGlvblVwZGF0ZShpbl9zZXNzaW9uSWQsIGluX2V4cGlyeVRpbWVJbk1TKTsKKyAgICB9IGVsc2UgeworICAgICAgICBBTE9HRSgiTnVsbCBldmVudCBsaXN0ZW5lciwgZXZlbnQgbm90IHNlbnQiKTsKKyAgICB9CisgICAgcmV0dXJuOworfQorCit2b2lkIERyb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dHVzKFN0YXR1czo6T0spOworfQorCis6Om5kazo6U2NvcGVkQVN0YXR1cyBEcm1QbHVnaW46OnNpZ24oY29uc3Qgc3RkOjp2ZWN0b3I8dWludDhfdD4mIC8qaW5fc2Vzc2lvbklkKi8sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjp2ZWN0b3I8dWludDhfdD4mIC8qaW5fa2V5SWQqLywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnZlY3Rvcjx1aW50OF90PiYgLyppbl9tZXNzYWdlKi8sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RkOjp2ZWN0b3I8dWludDhfdD4qIF9haWRsX3JldHVybikgeworICAgICpfYWlkbF9yZXR1cm4gPSB7fTsKKyAgICByZXR1cm4gdG9OZGtTY29wZWRBU3RhdHVzKFN0YXR1czo6RVJST1JfRFJNX0NBTk5PVF9IQU5ETEUpOworfQorCis6Om5kazo6U2NvcGVkQVN0YXR1cyBEcm1QbHVnaW46OnNpZ25SU0EoY29uc3Qgc3RkOjp2ZWN0b3I8dWludDhfdD4mIC8qaW5fc2Vzc2lvbklkKi8sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjpzdHJpbmcmIC8qaW5fYWxnb3JpdGhtKi8sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjp2ZWN0b3I8dWludDhfdD4mIC8qaW5fbWVzc2FnZSovLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ZDo6dmVjdG9yPHVpbnQ4X3Q+JiAvKmluX3dyYXBwZWRrZXkqLywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGQ6OnZlY3Rvcjx1aW50OF90PiogX2FpZGxfcmV0dXJuKSB7CisgICAgKl9haWRs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jpTY29wZWRBU3RhdHVzIHNldFByb3BlcnR5Qnl0ZUFycmF5KGNvbnN0IHN0ZDo6c3RyaW5nJiBpbl9wcm9wZXJ0eU5hbWUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjp2ZWN0b3I8dWludDhfdD4mIGluX3ZhbHVlKSBvdmVycmlkZTsKKyAgICA6Om5kazo6U2NvcGVkQVN0YXR1cyBzZXRQcm9wZXJ0eVN0cmluZyhjb25zdCBzdGQ6OnN0cmluZyYgaW5fcHJvcGVydHlOYW1lLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ZDo6c3RyaW5nJiBpbl92YWx1ZSkgb3ZlcnJpZGU7CisgICAgOjpuZGs6OlNjb3BlZEFTdGF0dXMgc2lnbihjb25zdCBzdGQ6OnZlY3Rvcjx1aW50OF90PiYgaW5fc2Vzc2lvbklkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjp2ZWN0b3I8dWludDhfdD4mIGluX2tleUlkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjp2ZWN0b3I8dWludDhfdD4mIGluX21lc3NhZ2UsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGQ6OnZlY3Rvcjx1aW50OF90PiogX2FpZGxfcmV0dXJuKSBvdmVycmlkZTsKKyAgICA6Om5kazo6U2NvcGVkQVN0YXR1cyBzaWduUlNBKGNvbnN0IHN0ZDo6dmVjdG9yPHVpbnQ4X3Q+JiBpbl9zZXNzaW9uSWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnN0cmluZyYgaW5fYWxnb3JpdGhtLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjp2ZWN0b3I8dWludDhfdD4mIGluX21lc3NhZ2UsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnZlY3Rvcjx1aW50OF90PiYgaW5fd3JhcHBlZGtleSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0ZDo6dmVjdG9yPHVpbnQ4X3Q+KiBfYWlkbF9yZXR1cm4pIG92ZXJyaWRlOworICAgIDo6bmRrOjpTY29wZWRBU3RhdHVzIHZlcmlmeShjb25zdCBzdGQ6OnZlY3Rvcjx1aW50OF90PiYgaW5fc2Vzc2lvbklkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnZlY3Rvcjx1aW50OF90PiYgaW5fa2V5SWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ZDo6dmVjdG9yPHVpbnQ4X3Q+JiBpbl9tZXNzYWdlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnZlY3Rvcjx1aW50OF90PiYgaW5fc2lnbmF0dXJlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sKiBfYWlkbF9yZXR1cm4pIG92ZXJyaWRlOworCisgIHByaXZhdGU6CisgICAgdm9pZCBpbml0UHJvcGVydGllcygpOworICAgIHZvaWQgaW5zdGFsbFNlY3VyZVN0b3AoY29uc3Qgc3RkOjp2ZWN0b3I8dWludDhfdD4mIHNlc3Npb25JZCk7CisgICAgYm9vbCBtYWtlS2V5U2V0SWQoc3RkOjpzdHJpbmcqIGtleVNldElkKTsKKyAgICB2b2lkIHNldFBsYXlQb2xpY3koKTsKKworICAgIHZvaWQgc2VuZEV2ZW50KDo6YWlkbDo6YW5kcm9pZDo6aGFyZHdhcmU6OmRybTo6RXZlbnRUeXBlIGluX2V2ZW50VHlwZSwKKyAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnZlY3Rvcjx1aW50OF90PiYgaW5fc2Vzc2lvbklkLAorICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0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cnlfc3RhdGljIHsKKyAgICBuYW1lOiAibGliY2xlYXJrZXliYXNlIiwKKyAgICB2ZW5kb3I6IHRydWUsCisKKyAgICBzcmNzOiBbCisgICAgICAgICJBZXNDdHJEZWNyeXB0b3IuY3BwIiwKKyAgICAgICAgIkJhc2U2NC5jcHAiLAorICAgICAgICAiQnVmZmVyLmNwcCIsCisgICAgICAgICJDbGVhcktleVVVSUQuY3BwIiwKKyAgICAgICAgIkRldmljZUZpbGVzLmNwcCIsCisgICAgICAgICJJbml0RGF0YVBhcnNlci5jcHAiLAorICAgICAgICAiSnNvbldlYktleS5jcHAiLAorICAgICAgICAiTWVtb3J5RmlsZVN5c3RlbS5jcHAiLAorICAgICAgICAiU2Vzc2lvbi5jcHAiLAorICAgICAgICAiU2Vzc2lvbkxpYnJhcnkuY3BwIiwKKyAgICAgICAgIlV0aWxzLmNwcCIsCisgICAgXSwKKworICAgIGNmbGFnczogWyItV2FsbCIsICItV2Vycm9yIl0sCisKKyAgICBpbmNsdWRlX2RpcnM6IFsiZnJhbWV3b3Jrcy9hdi9pbmNsdWRlIl0sCisKKyAgICBzaGFyZWRfbGliczogWworICAgICAgICAibGlidXRpbHMiLAorICAgICAgICAibGliY3J5cHRvIiwKKyAgICBdLAorCisgICAgd2hvbGVfc3RhdGljX2xpYnM6IFsKKyAgICAgICAgImxpYmpzbW4iLAorICAgICAgICAibGliY2xlYXJrZXlkZXZpY2VmaWxlcy1wcm90b3MuY29tbW9uIiwKKyAgICBdLAorCisgICAgZXhwb3J0X2luY2x1ZGVfZGlyczogWworICAgICAgICAiaW5jbHVkZSIsCisgICAgICAgICJpbmNsdWRlL2NsZWFya2V5ZHJtIiwKKyAgICBdLAorCisgICAgc2FuaXRpemU6IHsKKyAgICAgICAgaW50ZWdlcl9vdmVyZmxvdzogdHJ1ZSwKKyAgICB9LAorfQpkaWZmIC0tZ2l0IGEvZHJtL21lZGlhZHJtL3BsdWdpbnMvY2xlYXJrZXkvY29tbW9uL0Jhc2U2N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KKyAqLworI2RlZmluZSBMT0dfVEFHICJjbGVhcmtleS1CYXNlNjQiCisKKyNpbmNsdWRlICJCYXNlNjQuaCIKKworI2luY2x1ZGUgPHN0cmluZz4KKworbmFtZXNwYWNlIGNsZWFya2V5ZHJtIHsKKworOjphbmRyb2lkOjpzcDxCdWZmZXI+IGRlY29kZUJhc2U2NChjb25zdCBzdGQ6OnN0cmluZyYgcykgeworICAgIHNpemVfdCBuID0gcy5zaXplKCk7CisKKyAgICBpZiAoKG4gJSA0KSAhPSAwKSB7CisgICAgICAgIHJldHVybiBudWxscHRyOworICAgIH0KKworICAgIHNpemVfdCBwYWRkaW5nID0gMDsKKyAgICBpZiAobiA+PSAxICYmIHMuY19zdHIoKVtuIC0gMV0gPT0gJz0nKSB7CisgICAgICAgIHBhZGRpbmcgPSAxOworCisgICAgICAgIGlmIChuID49IDIgJiYgcy5jX3N0cigpW24gLSAyXSA9PSAnPScpIHsKKyAgICAgICAgICAgIHBhZGRpbmcgPSAyOworCisgICAgICAgICAgICBpZiAobiA+PSAzICYmIHMuY19zdHIoKVtuIC0gM10gPT0gJz0nKSB7CisgICAgICAgICAgICAgICAgcGFkZGluZyA9IDM7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICB9CisKKyAgICAvLyBXZSBkaXZpZGUgZmlyc3QgdG8gYXZvaWQgb3ZlcmZsb3cuIEl0J3MgT0sgdG8gZG8gdGhpcyBiZWNhdXNlIHdlCisgICAgLy8gYWxyZWFkeSBtYWRlIHN1cmUgdGhhdCBuICUgNCA9PSAwLgorICAgIHNpemVfdCBvdXRMZW4gPSAobiAvIDQpICogMyAtIHBhZGRpbmc7CisKKyAgICA6OmFuZHJvaWQ6OnNwPEJ1ZmZlcj4gYnVmZmVyID0gbmV3IEJ1ZmZlcihvdXRMZW4pOworICAgIHVpbnQ4X3QqIG91dCA9IGJ1ZmZlci0+ZGF0YSgpOworICAgIGlmIChvdXQgPT0gbnVsbHB0ciB8fCBidWZmZXItPnNpemUoKSA8IG91dExlbikgeworICAgICAgICByZXR1cm4gbnVsbHB0cjsKKyAgICB9CisKKyAgICBzaXplX3QgaiA9IDA7CisgICAgdWludDMyX3QgYWNjdW0gPSAwOworICAgIGZvciAoc2l6ZV90IGkgPSAwOyBpIDwgbjsgKytpKSB7CisgICAgICAgIGNoYXIgYyA9IHMuY19zdHIoKVtpXTsKKyAgICAgICAgdW5zaWduZWQgdmFsdWU7CisgICAgICAgIGlmIChjID49ICdBJyAmJiBjIDw9ICdaJykgeworICAgICAgICAgICAgdmFsdWUgPSBjIC0gJ0EnOworICAgICAgICB9IGVsc2UgaWYgKGMgPj0gJ2EnICYmIGMgPD0gJ3onKSB7CisgICAgICAgICAgICB2YWx1ZSA9IDI2ICsgYyAtICdhJzsKKyAgICAgICAgfSBlbHNlIGlmIChjID49ICcwJyAmJiBjIDw9ICc5JykgeworICAgICAgICAgICAgdmFsdWUgPSA1MiArIGMgLSAnMCc7CisgICAgICAgIH0gZWxzZSBpZiAoYyA9PSAnKycgfHwgYyA9PSAnLScpIHsKKyAgICAgICAgICAgIHZhbHVlID0gNjI7CisgICAgICAgIH0gZWxzZSBpZiAoYyA9PSAnLycgfHwgYyA9PSAnXycpIHsKKyAgICAgICAgICAgIHZhbHVlID0gNjM7CisgICAgICAgIH0gZWxzZSBpZiAoYyAhPSAnPScpIHsKKyAgICAgICAgICAgIHJldHVybiBudWxscHRyOworICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgaWYgKGkgPCBuIC0gcGFkZGluZykgeworICAgICAgICAgICAgICAgIHJldHVybiBudWxscHRyOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICB2YWx1ZSA9IDA7CisgICAgICAgIH0KKworICAgICAgICBhY2N1bSA9IChhY2N1bSA8PCA2KSB8IHZhbHVlOworCisgICAgICAgIGlmICgoKGkgKyAxKSAlIDQpID09IDApIHsKKyAgICAgICAgICAgIGlmIChqIDwgb3V0TGVuKSB7CisgICAgICAgICAgICAgICAgb3V0W2orK10gPSAoYWNjdW0gPj4gMTYpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgaWYgKGogPCBvdXRMZW4pIHsKKyAgICAgICAgICAgICAgICBvdXRbaisrXSA9IChhY2N1bSA+PiA4KSAmIDB4ZmY7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBpZiAoaiA8IG91dExlbikgeworICAgICAgICAgICAgICAgIG91dFtqKytdID0gYWNjdW0gJiAweGZmOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBhY2N1bSA9IDA7CisgICAgICAgIH0KKyAgICB9CisKKyAgICByZXR1cm4gYnVmZmVyOworfQorCitzdGF0aWMgY2hhciBlbmNvZGU2Qml0KHVuc2lnbmVkIHgpIHsKKyAgICBpZiAoeCA8PSAyNSkgeworICAgICAgICByZXR1cm4gJ0EnICsgeDsKKyAgICB9IGVsc2UgaWYgKHggPD0gNTEpIHsKKyAgICAgICAgcmV0dXJuICdhJyArIHggLSAyNjsKKyAgICB9IGVsc2UgaWYgKHggPD0gNjEpIHsKKyAgICAgICAgcmV0dXJuICcwJyArIHggLSA1MjsKKyAgICB9IGVsc2UgaWYgKHggPT0gNjIpIHsKKyAgICAgICAgcmV0dXJuICcrJzsKKyAgICB9IGVsc2UgeworICAgICAgICByZXR1cm4gJy8nOworICAgIH0KK30KKwordm9pZCBlbmNvZGVCYXNlNjQoY29uc3Qgdm9pZCogX2RhdGEsIHNpemVfdCBzaXplLCBzdGQ6OnN0cmluZyogb3V0KSB7CisgICAgb3V0LT5jbGVhcigpOworCisgICAgY29uc3QgdWludDhfdCogZGF0YSA9IChjb25zdCB1aW50OF90KilfZGF0YTsKKworICAgIHNpemVfdCBpOworICAgIGZvciAoaSA9IDA7IGkgPCAoc2l6ZSAvIDMpICogMzsgaSArPSAzKSB7CisgICAgICAgIHVpbnQ4X3QgeDEgPSBkYXRhW2ldOworICAgICAgICB1aW50OF90IHgyID0gZGF0YVtpICsgMV07CisgICAgICAgIHVpbnQ4X3QgeDMgPSBkYXRhW2kgKyAyXTsKKworICAgICAgICBvdXQtPnB1c2hfYmFjayhlbmNvZGU2Qml0KHgxID4+IDIpKTsKKyAgICAgICAgb3V0LT5wdXNoX2JhY2soZW5jb2RlNkJpdCgoeDEgPDwgNCB8IHgyID4+IDQpICYgMHgzZikpOworICAgICAgICBvdXQtPnB1c2hfYmFjayhlbmNvZGU2Qml0KCh4MiA8PCAyIHwgeDMgPj4gNikgJiAweDNmKSk7CisgICAgICAgIG91dC0+cHVzaF9iYWNrKGVuY29kZTZCaXQoeDMgJiAweDNmKSk7CisgICAgfQorICAgIHN3aXRjaCAoc2l6ZSAlIDMpIHsKKyAgICAgICAgY2FzZSAwOgorICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgMjogeworICAgICAgICAgICAgdWludDhfdCB4MSA9IGRhdGFbaV07CisgICAgICAgICAgICB1aW50OF90IHgyID0gZGF0YVtpICsgMV07CisgICAgICAgICAgICBvdXQtPnB1c2hfYmFjayhlbmNvZGU2Qml0KHgxID4+IDIpKTsKKyAgICAgICAgICAgIG91dC0+cHVzaF9iYWNrKGVuY29kZTZCaXQoKHgxIDw8IDQgfCB4MiA+PiA0KSAmIDB4M2YpKTsKKyAgICAgICAgICAgIG91dC0+cHVzaF9iYWNrKGVuY29kZTZCaXQoKHgyIDw8IDIpICYgMHgzZikpOworICAgICAgICAgICAgb3V0LT5wdXNoX2JhY2soJz0nKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CisgICAgICAgIGRlZmF1bHQ6IHsKKyAgICAgICAgICAgIHVpbnQ4X3QgeDEgPSBkYXRhW2ldOworICAgICAgICAgICAgb3V0LT5wdXNoX2JhY2soZW5jb2RlNkJpdCh4MSA+PiAyKSk7CisgICAgICAgICAgICBvdXQtPnB1c2hfYmFjayhlbmNvZGU2Qml0KCh4MSA8PCA0KSAmIDB4M2YpKTsKKyAgICAgICAgICAgIG91dC0+YXBwZW5kKCI9PSIpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KK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lIGtleSBJRHMKKyAgICBzdGQ6OnZlY3Rvcjxjb25zdCB1aW50OF90Kj4ga2V5SWRzOworCisgICAgaWYgKG1pbWVUeXBlID09IGtJc29CbWZmVmlkZW9NaW1lVHlwZS5jX3N0cigpIHx8IG1pbWVUeXBlID09IGtJc29CbWZmQXVkaW9NaW1lVHlwZS5jX3N0cigpIHx8CisgICAgICAgIG1pbWVUeXBlID09IGtDZW5jSW5pdERhdGFGb3JtYXQuY19zdHIoKSkgeworICAgICAgICBhdXRvIHJlcyA9IHBhcnNlUHNzaChpbml0RGF0YSwgJmtleUlkcyk7CisgICAgICAgIGlmIChyZXMgIT0gY2xlYXJrZXlkcm06Ok9LKSB7CisgICAgICAgICAgICByZXR1cm4gcmVzOworICAgICAgICB9CisgICAgfSBlbHNlIGlmIChtaW1lVHlwZSA9PSBrV2VibVZpZGVvTWltZVR5cGUuY19zdHIoKSB8fCBtaW1lVHlwZSA9PSBrV2VibUF1ZGlvTWltZVR5cGUuY19zdHIoKSB8fAorICAgICAgICAgICAgICAgbWltZVR5cGUgPT0ga1dlYm1Jbml0RGF0YUZvcm1hdC5jX3N0cigpKSB7CisgICAgICAgIC8vIFdlYk0gImluaXQgZGF0YSIgaXMganVzdCBhIHNpbmdsZSBrZXkgSUQKKyAgICAgICAgaWYgKGluaXREYXRhLnNpemUoKSAhPSBrS2V5SWRTaXplKSB7CisgICAgICAgICAgICByZXR1cm4gY2xlYXJrZXlkcm06OkVSUk9SX0NBTk5PVF9IQU5ETEU7CisgICAgICAgIH0KKyAgICAgICAga2V5SWRzLnB1c2hfYmFjayhpbml0RGF0YS5kYXRhKCkpOworICAgIH0gZWxzZSB7CisgICAgICAgIHJldHVybiBjbGVhcmtleWRybTo6RVJST1JfQ0FOTk9UX0hBTkRMRTsKKyAgICB9CisKKyAgICBpZiAoa2V5VHlwZSA9PSBjbGVhcmtleWRybTo6S0VZX1RZUEVfUkVMRUFTRSkgeworICAgICAgICAvLyByZXN0b3JlIGtleQorICAgIH0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KKworICAgICAgICBpZiAoIXBhcnNlSnNvbk9iamVjdChtSnNvbk9iamVjdHNbaV0sICZtVG9rZW5zKSkgcmV0dXJuIGZhbHNlOworCisgICAgICAgIGlmIChmaW5kS2V5KG1Kc29uT2JqZWN0c1tpXSwgJmVuY29kZWRLZXlJZCwgJmVuY29kZWRLZXkpKSB7CisgICAgICAgICAgICBpZiAoZW5jb2RlZEtleUlkLmVtcHR5KCkgfHwgZW5jb2RlZEtleS5lbXB0eSgpKSB7CisgICAgICAgICAgICAgICAgQUxPR0UoIk11c3QgaGF2ZSBib3RoIGtleSBpZCBhbmQga2V5IGluIHRoZSBKc29uV2ViS2V5IHNldC4iKTsKKyAgICAgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgaWYgKCFkZWNvZGVCYXNlNjRTdHJpbmcoZW5jb2RlZEtleUlkLCAmZGVjb2RlZEtleUlkKSkgeworICAgICAgICAgICAgICAgIEFMT0dFKCJGYWlsZWQgdG8gZGVjb2RlIGtleSBpZCglcykiLCBlbmNvZGVkS2V5SWQuY19zdHIoKSk7CisgICAgICAgICAgICAgICAgY29udGludWU7CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIGlmICghZGVjb2RlQmFzZTY0U3RyaW5nKGVuY29kZWRLZXksICZkZWNvZGVkS2V5KSkgeworICAgICAgICAgICAgICAgIEFMT0dFKCJGYWlsZWQgdG8gZGVjb2RlIGtleSglcykiLCBlbmNvZGVkS2V5LmNfc3RyKCkpOworICAgICAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBrZXlzLT5pbnNlcnQoc3RkOjpwYWlyPHN0ZDo6dmVjdG9yPHVpbnQ4X3Q+LCBzdGQ6OnZlY3Rvcjx1aW50OF90Pj4oZGVjb2RlZEtleUlkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg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KyAgICByZXR1cm4gdHJ1ZTsKK30KKwordm9pZCBKc29uV2ViS2V5OjpmaW5kVmFsdWUoY29uc3Qgc3RkOjpzdHJpbmcmIGtleSwgc3RkOjpzdHJpbmcqIHZhbHVlKSB7CisgICAgdmFsdWUtPmNsZWFyKCk7CisgICAgY29uc3QgY2hhciogdmFsdWVUb2tlbjsKKyAgICBmb3IgKHN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPjo6Y29uc3RfaXRlcmF0b3IgbmV4dFRva2VuID0gbVRva2Vucy5iZWdpbigpOworICAgICAgICAgbmV4dFRva2VuICE9IG1Ub2tlbnMuZW5kKCk7ICsrbmV4dFRva2VuKSB7CisgICAgICAgIGlmICgwID09ICgqbmV4dFRva2VuKS5jb21wYXJlKGtleSkpIHsKKyAgICAgICAgICAgIGlmIChuZXh0VG9rZW4gKyAxID09IG1Ub2tlbnMuZW5kKCkpIGJyZWFrOworICAgICAgICAgICAgdmFsdWVUb2tlbiA9ICgqKG5leHRUb2tlbiArIDEpKS5jX3N0cigpOworICAgICAgICAgICAgdmFsdWUtPmFzc2lnbih2YWx1ZVRva2VuKTsKKyAgICAgICAgICAgIG5leHRUb2tlbisrOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICB9Cit9CisKK2Jvb2wgSnNvbldlYktleTo6aXNKc29uV2ViS2V5U2V0KGNvbnN0IHN0ZDo6c3RyaW5nJiBqc29uT2JqZWN0KSBjb25zdCB7CisgICAgaWYgKGpzb25PYmplY3QuZmluZChrS2V5c1RhZykgPT0gc3RkOjpzdHJpbmc6Om5wb3MpIHsKKyAgICAgICAgQUxPR0UoIkpTT04gV2ViIEtleSBkb2VzIG5vdCBjb250YWluIGtleXMuIik7CisgICAgICAgIHJldHVybiBmYWxzZTsKKyAgICB9CisgICAgcmV0dXJuIHRydWU7Cit9CisKKy8qCisgKiBQYXJzZXMgYSBKU09OIG9iamVjdHMgc3RyaW5nIGFuZCBpbml0aWFsaXplcyBhIHZlY3RvciBvZiB0b2tlbnMuCisgKgorICogQHJldHVybiBSZXR1cm5zIGZhbHNlIGZvciBlcnJvcnMsIHRydWUgZm9yIHN1Y2Nlc3MuCisgKi8KK2Jvb2wgSnNvbldlYktleTo6cGFyc2VKc29uT2JqZWN0KGNvbnN0IHN0ZDo6c3RyaW5nJiBqc29uT2JqZWN0LCBzdGQ6OnZlY3RvcjxzdGQ6OnN0cmluZz4qIHRva2VucykgeworICAgIGpzbW5fcGFyc2VyIHBhcnNlcjsKKworICAgIGpzbW5faW5pdCgmcGFyc2VyKTsKKyAgICBpbnQgbnVtVG9rZW5zID0ganNtbl9wYXJzZSgmcGFyc2VyLCBqc29uT2JqZWN0LmNfc3RyKCksIGpzb25PYmplY3Quc2l6ZSgpLCBudWxscHRyLCAwKTsKKyAgICBpZiAobnVtVG9rZW5zIDwgMCkgeworICAgICAgICBBTE9HRSgiUGFyc2VyIHJldHVybnMgZXJyb3IgY29kZT0lZCIsIG51bVRva2Vucyk7CisgICAgICAgIHJldHVybiBmYWxzZTsKKyAgICB9CisKKyAgICB1bnNpZ25lZCBpbnQganNtblRva2Vuc1NpemUgPSBudW1Ub2tlbnMgKiBzaXplb2YoanNtbnRva190KTsKKyAgICBtSnNtblRva2Vucy5jbGVhcigpOworICAgIG1Kc21uVG9rZW5zLnJlc2l6ZShqc21uVG9rZW5zU2l6ZSk7CisKKyAgICBqc21uX2luaXQoJnBhcnNlcik7CisgICAgaW50IHN0YXR1cyA9IGpzbW5fcGFyc2UoJnBhcnNlciwganNvbk9iamVjdC5jX3N0cigpLCBqc29uT2JqZWN0LnNpemUoKSwgbUpzbW5Ub2tlbnMuZGF0YSgpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIG51bVRva2Vucyk7CisgICAgaWYgKHN0YXR1cyA8IDApIHsKKyAgICAgICAgQUxPR0UoIlBhcnNlciByZXR1cm5zIGVycm9yIGNvZGU9JWQiLCBzdGF0dXMpOworICAgICAgICByZXR1cm4gZmFsc2U7CisgICAgfQorCisgICAgdG9rZW5zLT5jbGVhcigpOworICAgIHN0ZDo6c3RyaW5nIHRva2VuOworICAgIGNvbnN0IGNoYXIqIHBqczsKKyAgICBmb3IgKGludCBqID0gMDsgaiA8IG51bVRva2VuczsgKytqKSB7CisgICAgICAgIHBqcyA9IGpzb25PYmplY3QuY19zdHIoKSArIG1Kc21uVG9rZW5zW2pdLnN0YXJ0OworICAgICAgICBpZiAobUpzbW5Ub2tlbnNbal0udHlwZSA9PSBKU01OX1NUUklORyB8fCBtSnNtblRva2Vuc1tqXS50eXBlID09IEpTTU5fUFJJTUlUSVZFKSB7CisgICAgICAgICAgICB0b2tlbi5hc3NpZ24ocGpzLCBtSnNtblRva2Vuc1tqXS5lbmQgLSBtSnNtblRva2Vuc1tqXS5zdGFydCk7CisgICAgICAgICAgICB0b2tlbnMtPnB1c2hfYmFjayh0b2tlbik7CisgICAgICAgIH0KKyAgICB9CisgICAgcmV0dXJuIHRydWU7Cit9CisKKy8qCisgKiBQYXJzZXMgSlNPTiBXZWIgS2V5IFNldCBzdHJpbmcgYW5kIGluaXRpYWxpemVzIGEgdmVjdG9yIG9mIEpTT04gb2JqZWN0cy4KKyAqCisgKiBAcmV0dXJuIFJldHVybnMgZmFsc2UgZm9yIGVycm9ycywgdHJ1ZSBmb3Igc3VjY2Vzcy4KKyAqLworYm9vbCBKc29uV2ViS2V5OjpwYXJzZUpzb25XZWJLZXlTZXQoY29uc3Qgc3RkOjpzdHJpbmcmIGpzb25XZWJLZXlTZXQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGQ6OnZlY3RvcjxzdGQ6OnN0cmluZz4qIGpzb25PYmplY3RzKSB7CisgICAgaWYgKGpzb25XZWJLZXlTZXQuZW1wdHkoKSkgeworICAgICAgICBBTE9HRSgiRW1wdHkgSlNPTiBXZWIgS2V5Iik7CisgICAgICAgIHJldHVybiBmYWxzZTsKKyAgICB9CisKKyAgICAvLyBUaGUganNtbiBwYXJzZXIgb25seSBzdXBwb3J0cyB1bmljb2RlIGVuY29kaW5nLgorICAgIGpzbW5fcGFyc2VyIHBhcnNlcjsKKworICAgIC8vIENvbXB1dGVzIG51bWJlciBvZiB0b2tlbnMuIEEgdG9rZW4gbWFya3MgdGhlIHR5cGUsIG9mZnNldCBpbgorICAgIC8vIHRoZSBvcmlnaW5hbCBzdHJpbmcuCisgICAganNtbl9pbml0KCZwYXJzZXIpOworICAgIGludCBudW1Ub2tlbnMgPSBqc21uX3BhcnNlKCZwYXJzZXIsIGpzb25XZWJLZXlTZXQuY19zdHIoKSwganNvbldlYktleVNldC5zaXplKCksIG51bGxwdHIsIDApOworICAgIGlmIChudW1Ub2tlbnMgPCAwKSB7CisgICAgICAgIEFMT0dFKCJQYXJzZXIgcmV0dXJucyBlcnJvciBjb2RlPSVkIiwgbnVtVG9rZW5zKTsKKyAgICAgICAgcmV0dXJuIGZhbHNlOworICAgIH0KKworICAgIHVuc2lnbmVkIGludCBqc21uVG9rZW5zU2l6ZSA9IG51bVRva2VucyAqIHNpemVvZihqc21udG9rX3QpOworICAgIG1Kc21uVG9rZW5zLnJlc2l6ZShqc21uVG9rZW5zU2l6ZSk7CisKKyAgICBqc21uX2luaXQoJnBhcnNlcik7CisgICAgaW50IHN0YXR1cyA9IGpzbW5fcGFyc2UoJnBhcnNlciwganNvbldlYktleVNldC5jX3N0cigpLCBqc29uV2ViS2V5U2V0LnNpemUoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtSnNtblRva2Vucy5kYXRhKCksIG51bVRva2Vucyk7CisgICAgaWYgKHN0YXR1cyA8IDApIHsKKyAgICAgICAgQUxPR0UoIlBhcnNlciByZXR1cm5zIGVycm9yIGNvZGU9JWQiLCBzdGF0dXMpOworICAgICAgICByZXR1cm4gZmFsc2U7CisgICAgfQorCisgICAgc3RkOjpzdHJpbmcgdG9rZW47CisgICAgY29uc3QgY2hhciogcGpzOworICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbnVtVG9rZW5zOyArK2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iYgaW5pdERhdGEsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnN0cmluZyYgbWltZVR5cGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDZG1LZXlUeXBlIGtleVR5cGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGQ6OnZlY3Rvcjx1aW50OF90Pioga2V5UmVxdWVzdCkgY29uc3QgeworICAgIEluaXREYXRhUGFyc2VyIHBhcnNlcjsKKyAgICByZXR1cm4gcGFyc2VyLnBhcnNlKGluaXREYXRhLCBtaW1lVHlwZSwga2V5VHlwZSwga2V5UmVxdWVzdCk7Cit9CisKK0NkbVJlc3BvbnNlVHlwZSBTZXNzaW9uOjpwcm92aWRlS2V5UmVzcG9uc2UoY29uc3Qgc3RkOjp2ZWN0b3I8dWludDhfdD4mIHJlc3BvbnNlKSB7CisgICAgc3RkOjpzdHJpbmcgcmVzcG9uc2VTdHJpbmcocmVpbnRlcnByZXRfY2FzdDxjb25zdCBjaGFyKj4ocmVzcG9uc2UuZGF0YSgpKSwgcmVzcG9uc2Uuc2l6ZSgpKTsKKyAgICBLZXlNYXAga2V5czsKKworICAgIE11dGV4OjpBdXRvbG9jayBsb2NrKG1NYXBMb2NrKTsKKyAgICBKc29uV2ViS2V5IHBhcnNlcjsKKyAgICBpZiAocGFyc2VyLmV4dHJhY3RLZXlzRnJvbUpzb25XZWJLZXlTZXQocmVzcG9uc2VTdHJpbmcsICZrZXlzKSkgeworICAgICAgICBmb3IgKGF1dG8mIGtleSA6IGtleXMpIHsKKyAgICAgICAgICAgIHN0ZDo6c3RyaW5nIGZpcnN0KGtleS5maXJzdC5iZWdpbigpLCBrZXkuZmlyc3QuZW5kKCkpOworICAgICAgICAgICAgc3RkOjpzdHJpbmcgc2Vjb25kKGtleS5zZWNvbmQuYmVnaW4oKSwga2V5LnNlY29uZC5lbmQoKSk7CisgICAgICAgICAgICBtS2V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sMyArMTMxLDM3IEBACiAgICAgaW5pdF9yYzogWyJhbmRyb2lkLmhhcmR3YXJlLmRybUAxLjQtc2VydmljZS1sYXp5LmNsZWFya2V5LnJjIl0sCiAgICAgdmludGZfZnJhZ21lbnRzOiBbIm1hbmlmZXN0X2FuZHJvaWQuaGFyZHdhcmUuZHJtQDEuNC1zZXJ2aWNlLmNsZWFya2V5LnhtbCJdLAogfQorCitjY19mdXp6IHsKKyAgICBuYW1lOiAiY2xlYXJrZXlWMS40X2Z1enplciIsCisgICAgdmVuZG9yOiB0cnVlLAorICAgIHNyY3M6IFsKKyAgICAgICAgImZ1enplci9jbGVhcmtleVYxLjRfZnV6emVyLmNwcCIsCisgICAgXSwKKyAgICBzdGF0aWNfbGliczogWworICAgICAgICAibGliY2xlYXJrZXloaWRsIiwKKyAgICAgICAgImxpYmNsZWFya2V5Y29tbW9uIiwKKyAgICAgICAgImxpYmNsZWFya2V5ZGV2aWNlZmlsZXMtcHJvdG9zIiwKKyAgICAgICAgImxpYmpzbW4iLAorICAgICAgICAibGlicHJvdG9idWYtY3BwLWxpdGUiLAorICAgIF0sCisgICAgc2hhcmVkX2xpYnM6IFsKKyAgICAgICAgImFuZHJvaWQuaGlkbC5hbGxvY2F0b3JAMS4wIiwKKyAgICAgICAgImFuZHJvaWQuaGFyZHdhcmUuZHJtQDEuMCIsCisgICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLmRybUAxLjEiLAorICAgICAgICAiYW5kcm9pZC5oYXJkd2FyZS5kcm1AMS4yIiwKKyAgICAgICAgImFuZHJvaWQuaGFyZHdhcmUuZHJtQDEuMyIsCisgICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLmRybUAxLjQiLAorICAgICAgICAibGliY3J5cHRvIiwKKyAgICAgICAgImxpYmhpZGxiYXNlIiwKKyAgICAgICAgImxpYmhpZGxtZW1vcnkiLAorICAgICAgICAibGlibG9nIiwKKyAgICAgICAgImxpYnV0aWxzIiwKKyAgICBdLAorICAgIGZ1enp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ga2V5U2V0SWQuZW5kKCkpOwotICAgICAgICAgICAgTXV0ZXg6OkF1dG9sb2NrIGxvY2sobUZpbGVIYW5kbGVMb2NrKTsKICAgICAgICAgICAgIGlmICghbUZpbGVIYW5kbGUuU3RvcmVMaWNlbnNlKGtleVNldElkU3RyaW5nLAogICAgICAgICAgICAgICAgICAgICBEZXZpY2VGaWxlczo6a0xpY2Vuc2VTdGF0ZVJlbGVhc2luZywKICAgICAgICAgICAgICAgICAgICAgZW1wdHlSZXNwb25zZSkpIHsKQEAgLTMzNyw3ICszMzYsNiBAQAogICAgICAgICB9CiAgICAgICAgICprZXlTZXRJZCA9IGtLZXlTZXRJZFByZWZpeCArIEJ5dGVBcnJheVRvSGV4U3RyaW5nKAogICAgICAgICAgICAgICAgIHJlaW50ZXJwcmV0X2Nhc3Q8Y29uc3QgdWludDhfdCo+KHJhbmRvbURhdGEuZGF0YSgpKSwgcmFuZG9tRGF0YS5zaXplKCkpOwotICAgICAgICBNdXRleDo6QXV0b2xvY2sgbG9jayhtRmlsZUhhbmRsZUxvY2spOwogICAgICAgICBpZiAobUZpbGVIYW5kbGUuTGljZW5zZUV4aXN0cygqa2V5U2V0SWQpKSB7CiAgICAgICAgICAgICAvLyBjb2xsaXNpb24sIHJlZ2VuZXJhdGUKICAgICAgICAgICAgIEFMT0dWKCJSZXRyeSBnZW5lcmF0aW5nIEtleVNldElkIik7CkBAIC0zOTUsNyArMzkzLDYgQEAKICAgICBpZiAoc3RhdHVzID09IFN0YXR1czo6T0spIHsKICAgICAgICAgaWYgKGlzT2ZmbGluZUxpY2Vuc2UpIHsKICAgICAgICAgICAgIGlmIChpc1JlbGVhc2UpIHsKLSAgICAgICAgICAgICAgICBNdXRleDo6QXV0b2xvY2sgbG9jayhtRmlsZUhhbmRsZUxvY2spOwogICAgICAgICAgICAgICAgIG1GaWxlSGFuZGxlLkRlbGV0ZUxpY2Vuc2Uoa2V5U2V0SWQpOwogICAgICAgICAgICAgICAgIG1TZXNzaW9uTGl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6SFdfU0VDVVJFX0NSWVBUTywKKyAgICBTZWN1cml0eUxldmVsOjpIV19TRUNVUkVfREVDT0RFLCBTZWN1cml0eUxldmVsOjpIV19TRUNVUkVfQUxMfTsKKworY29uc3QgY2hhciAqa01pbWVUeXBlW10gPSB7CisgICAgInZpZGVvL21wNCIsICAidmlkZW8vbXBlZyIsICAidmlkZW8veC1mbHYiLCAgICJ2aWRlby9tajIiLCAgICAidmlkZW8vM2dwMiIsCisgICAgInZpZGVvLzNncHAiLCAidmlkZW8vM2dwcDIiLCAiYXVkaW8vbXA0IiwgICAgICJhdWRpby9tcGVnIiwgICAiYXVkaW8vYWFjIiwKKyAgICAiYXVkaW8vM2dwMiIsICJhdWRpby8zZ3BwIiwgICJhdWRpby8zZ3BwMiIsICAgImF1ZGlvL3dlYm0iLCAgICJ2aWRlby93ZWJtIiwKKyAgICAid2VibSIsICAgICAgICJjZW5jIiwgICAgICAgICJ2aWRlby91bmtub3duIiwgImF1ZGlvL3Vua25vd24ifTsKKworY29uc3QgY2hhciAqa0NpcGhlckFsZ29yaXRobVtdID0geyJBRVMvQ0JDL05vUGFkZGluZyIsICIifTsKKworY29uc3QgY2hhciAqa01hY0FsZ29yaXRobVtdID0geyJIbWFjU0hBMjU2IiwgIiJ9OworCitjb25zdCBjaGFyICprUlNBQWxnb3JpdGhtW10gPSB7IlJTQVNTQS1QU1MtU0hBMSIsICIifTsKKworY29uc3Qgc3RkOjpzdHJpbmcga1Byb3BlcnR5W10gPSB7a1ZlbmRvcktleSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtWZXJzaW9uS2V5LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga1BsdWdpbkRlc2NyaXB0aW9uS2V5LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga0FsZ29yaXRobXNLZXksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrTGlzdGVuZXJUZXN0U3VwcG9ydEtleSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtEcm1FcnJvclRlc3RLZXksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrRGV2aWNlSWRLZXksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrQ2xpZW50SWRLZXksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrTWV0cmljc0tleSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJwbGFjZWhvbGRlciJ9OworCitjb25zdCBLZXlUeXBlIGtLZXlUeXBlW10gPSB7S2V5VHlwZTo6T0ZGTElORSwgS2V5VHlwZTo6U1RSRUFNSU5HLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIEtleVR5cGU6OlJFTEVBU0V9OworCitjb25zdCBNb2RlIGtDcnlwdG9Nb2RlW10gPSB7TW9kZTo6VU5FTkNSWVBURUQsIE1vZGU6OkFFU19DVFIsIE1vZGU6OkFFU19DQkNfQ1RTLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1vZGU6OkFFU19DQkN9OworCitjb25zdCBoaWRsX3ZlYzx1aW50OF90PiB2YWxpZEluaXREYXRhID0geworICAgIC8vIEJNRkYgYm94IGhlYWRlciAoNCBieXRlcyBzaXplICsgJ3Bzc2gnKQorICAgIDB4MDAsIDB4MDAsIDB4MDAsIDB4MzQsIDB4NzAsIDB4NzMsIDB4NzMsIDB4NjgsCisgICAgLy8gZnVsbCBib3ggaGVhZGVyICh2ZXJzaW9uID0gMSBmbGFncyA9IDApCisgICAgMHgwMSwgMHgwMCwgMHgwMCwgMHgwMCwKKyAgICAvLyBzeXN0ZW0gaWQKKyAgICAweDEwLCAweDc3LCAweGVmLCAweGVjLCAweGMwLCAweGIyLCAweDRkLCAweDAyLCAweGFjLCAweGUzLCAweDNjLCAweDFlLAorICAgIDB4NTIsIDB4ZTIsIDB4ZmIsIDB4NGIsCisgICAgLy8gbnVtYmVyIG9mIGtleSBpZHMKKyAgICAweDAwLCAweDAwLCA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gICAgICAgICAgIGludDY0X3QgLypleHBpcnlUaW1lSW5NUyovKSBvdmVycmlkZSB7CisgICAgcmV0dXJuIFJldHVybjx2b2lkPigpOworICB9CisKKyAgdmlydHVhbCBSZXR1cm48dm9pZD4KKyAgc2VuZEtleXNDaGFuZ2UoY29uc3QgaGlkbF92ZWM8dWludDhfdD4gJiAvKnNlc3Npb25JZCovLAorICAgICAgICAgICAgICAgICBjb25zdCBoaWRsX3ZlYzxLZXlTdGF0dXM+ICYgLyprZXlTdGF0dXNMaXN0Ki8sCisgICAgICAgICAgICAgICAgIGJvb2wgLypoYXNOZXdVc2FibGVLZXkqLykgb3ZlcnJpZGUgeworICAgIHJldHVybiBSZXR1cm48dm9pZD4oKTsKKyAgfQorfTsKKworY2xhc3MgQ2xlYXJLZXlGdXp6ZXIgeworcHVibGljOgorICB+Q2xlYXJLZXlGdXp6ZXIoKSB7IGRlSW5pdCgpOyB9CisgIGJvb2wgaW5pdCgpOworICB2b2lkIHByb2Nlc3MoY29uc3QgdWludDhfdCAqZGF0YSwgc2l6ZV90IHNpemUpOworCitwcml2YXRlOgorICB2b2lkIGRlSW5pdCgpOworICB2b2lkIGludm9rZURybVBsdWdpbihjb25zdCB1aW50OF90ICpkYXRhLCBzaXplX3Qgc2l6ZSk7CisgIHZvaWQgaW52b2tlQ3J5cHRvUGx1Z2luKGNvbnN0IHVpbnQ4X3QgKmRhdGEpOworICB2b2lkIGludm9rZURybShjb25zdCB1aW50OF90ICpkYXRhLCBzaXplX3Qgc2l6ZSk7CisgIHZvaWQgaW52b2tlQ3J5cHRvKGNvbnN0IHVpbnQ4X3QgKmRhdGEpOworICB2b2lkIGludm9rZURybURlY3J5cHRFbmNyeXB0QVBJKGNvbnN0IHVpbnQ4X3QgKmRhdGEsIHNpemVfdCBzaXplKTsKKyAgYm9vbCBpbnZva2VEcm1GYWN0b3J5KCk7CisgIGJvb2wgaW52b2tlQ3J5cHRvRmFjdG9yeSgpOworICB2b2lkIGludm9rZURybVYxXz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tcHR5U2Vzc2lvbklkID0ge307CisgIHJldHVybiBtRkRQLT5Db25zdW1lQm9vbCgpID8gbVNlc3Npb25JZCA6IGVtcHR5U2Vzc2lvbklkOworfQorCit2b2lkIENsZWFyS2V5RnV6emVyOjppbnZva2VEcm1EZWNyeXB0RW5jcnlwdEFQSShjb25zdCB1aW50OF90ICpkYXRhLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90IHNpemUpIHsKKyAgdWludDMyX3QgY3VyclNlc3Npb25zLCBtYXhpbXVtU2Vzc2lvbnM7CisgIG1Ecm1QbHVnaW5WMV8yLT5nZXROdW1iZXJPZlNlc3Npb25zKAorICAgICAgWyZdKFN0YXR1cyBzdGF0dXMsIHVpbnQzMl90IGhDdXJyZW50U2Vzc2lvbnMsIHVpbnQzMl90IGhNYXhTZXNzaW9ucykgeworICAgICAgICBpZiAoc3RhdHVzID09IFN0YXR1czo6T0spIHsKKyAgICAgICAgICBjdXJyU2Vzc2lvbnMgPSBoQ3VycmVudFNlc3Npb25zOworICAgICAgICAgIG1heGltdW1TZXNzaW9ucyA9IGhNYXhTZXNzaW9uczsKKyAgICAgICAgfQorICAgICAgfSk7CisKKyAgSGRjcExldmVsIGNvbm5lY3RlZCwgbWF4aW11bTsKKyAgbURybVBsdWdpblYxXzItPmdldEhkY3BMZXZlbHMoWyZdKFN0YXR1cyBzdGF0dXMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBIZGNwTGV2ZWwgJmhDb25uZWN0ZWRMZXZlbCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IEhkY3BMZXZlbCAmaE1heExldmVsKSB7CisgICAgaWYgKHN0YXR1cyA9PSBTdGF0dXM6Ok9LKSB7CisgICAgICBjb25uZWN0ZWQgPSBoQ29ubmVjdGVkTGV2ZWw7CisgICAgICBtYXhpbXVtID0gaE1heExldmVsOworICAgIH0KKyAgfSk7CisKKyAgZHJtOjpWMV8yOjpIZGNwTGV2ZWwgY29ubmVjdGVkVjFfMiwgbWF4aW11bVYxXzI7CisgIG1Ecm1QbHVnaW5WMV8yLT5nZXRIZGNwTGV2ZWxzXzFfMigKKyAgICAgIFsmXShkcm06OlYxXzI6OlN0YXR1cyBzdGF0dXMsIGNvbnN0IGRybTo6VjFfMjo6SGRjcExldmVsICZjb25uZWN0ZWRMZXZlbCwKKyAgICAgICAgICBjb25zdCBkcm06OlYxXzI6OkhkY3BMZXZlbCAmbWF4TGV2ZWwpIHsKKyAgICAgICAgaWYgKHN0YXR1cyA9PSBkcm06OlYxXzI6OlN0YXR1czo6T0spIHsKKyAgICAgICAgICBjb25uZWN0ZWRWMV8yID0gY29ubmVjdGVkTGV2ZWw7CisgICAgICAgICAgbWF4aW11bVYxXzIgPSBtYXhMZXZlbDsKKyAgICAgICAgfQorICAgICAgfSk7CisKKyAgU2VjdXJpdHlMZXZlbCBzZWN1cml0eUxldmVsOworICBtRHJtUGx1Z2luVjFfMi0+Z2V0U2VjdXJpdHlMZXZlbChtU2Vzc2lvbklkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBbJl0oU3RhdHVzIHN0YXR1cywgU2VjdXJpdHlMZXZlbCBoTGV2ZWwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdHVzID09IFN0YXR1czo6T0spIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlY3VyaXR5TGV2ZWwgPSBoTGV2ZWw7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKKworICBoaWRsX3ZlYzxEcm1NZXRyaWNHcm91cD4gbWV0cmljczsKKyAgbURybVBsdWdpblYxXzItPmdldE1ldHJpY3MoCisgICAgICBbJl0oU3RhdHVzIHN0YXR1cywgaGlkbF92ZWM8RHJtTWV0cmljR3JvdXA+IGhNZXRyaWNHcm91cHMpIHsKKyAgICAgICAgaWYgKHN0YXR1cyA9PSBTdGF0dXM6Ok9LKSB7CisgICAgICAgICAgbWV0cmljcyA9IGhNZXRyaWNHcm91cHM7CisgICAgICAgIH0KKyAgICAgIH0pOworCisgIGhpZGxfc3RyaW5nIGNlcnRpZmljYXRlVHlwZTsKKyAgaGlkbF9zdHJpbmcgY2VydGlmaWNhdGVBdXRob3JpdHk7CisgIG1Ecm1QbHVnaW5WMV8yLT5nZXRQcm92aXNpb25SZXF1ZXN0KGNlcnRpZmljYXRlVHlwZSwgY2VydGlmaWNhdGVBdXRob3JpdHksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFsmXShbW21heWJlX3VudXNlZF1dIFN0YXR1cyBzdGF0dXMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoaWRsX3ZlYzx1aW50OF90PiAmLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGlkbF9zdHJpbmcgJikge30pOworCisgIG1Ecm1QbHVnaW5WMV8yLT5nZXRQcm92aXNpb25SZXF1ZXN0XzFfMigKKyAgICAgIGNlcnRpZmljYXRlVHlwZSwgY2VydGlmaWNhdGVBdXRob3JpdHksCisgICAgICBbJl0oW1ttYXliZV91bnVzZWRdXSBkcm06OlYxXzI6OlN0YXR1cyBzdGF0dXMsIGNvbnN0IGhpZGxfdmVjPHVpbnQ4X3Q+ICYsCisgICAgICAgICAgY29uc3QgaGlkbF9zdHJpbmcgJikge30pOworCisgIGhpZGxfdmVjPHVpbnQ4X3Q+IHJlc3BvbnNlOworICBtRHJtUGx1Z2luVjFfMi0+cHJvdmlkZVByb3Zpc2lvblJlc3BvbnNlKAorICAgICAgcmVzcG9uc2UsIFsmXShbW21heWJlX3VudXNlZF1dIFN0YXR1cyBzdGF0dXMsIGNvbnN0IGhpZGxfdmVjPHVpbnQ4X3Q+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aW52b2tlRHJtT2ZmbGluZUxpY2Vuc2VBUEkoY29uc3QgdWludDhfdCAqZGF0YSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemVfdCBzaXplKSB7CisgIGhpZGxfdmVjPEtleVNldElkPiBrZXlTZXRJZHMgPSB7fTsKKyAgbURybVBsdWdpblYxXzItPmdldE9mZmxpbmVMaWNlbnNlS2V5U2V0SWRzKAorICAgICAgWyZdKFN0YXR1cyBzdGF0dXMsIGNvbnN0IGhpZGxfdmVjPEtleVNldElkPiAmaEtleVNldElkcykgeworICAgICAgICBpZiAoc3RhdHVzID09IFN0YXR1czo6T0spIHsKKyAgICAgICAgICBrZXlTZXRJZHMgPSBoS2V5U2V0SWRzOworICAgICAgICB9CisgICAgICB9KTsKKworICBPZmZsaW5lTGljZW5zZVN0YXRlIGxpY2Vuc2VTdGF0ZTsKKyAgS2V5U2V0SWQga2V5U2V0SWQgPSB7fTsKKyAgaWYgKGtleVNldElkcy5zaXplKCkgPiAwKSB7CisgICAga2V5U2V0SWQgPSBrZXlTZXRJZHNbbUZEUC0+Q29uc3VtZUludGVncmFsSW5SYW5nZTxzaXplX3Q+KAorICAgICAgICAwLCBrZXlTZXRJZHMuc2l6ZSgpIC0gMSldOworICB9IGVsc2UgeworICAgIGtleVNldElkLnNldFRvRXh0ZXJuYWwoY29uc3RfY2FzdDx1aW50OF90ICo+KGRhdGEpLCBzaXplKTsKKyAgfQorICBtRHJtUGx1Z2luVjFfMi0+Z2V0T2ZmbGluZUxpY2Vuc2VTdGF0ZSgKKyAgICAgIGtleVNldElkLCBbJl0oU3RhdHVzIHN0YXR1cywgT2ZmbGluZUxpY2Vuc2VTdGF0ZSBoTGljZW5zZVN0YXRlKSB7CisgICAgICAgIGlmIChzdGF0dXMgPT0gU3RhdHVzOjpPSykgeworICAgICAgICAgIGxpY2Vuc2VTdGF0ZSA9IGhMaWNlbnNlU3RhdGU7CisgICAgICAgIH0KKyAgICAg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Q0Ci0tLSBhL21lZGlhL1RFU1RfTUFQUElORworKysgYi9tZWRpYS9URVNUX01BUFBJTkcKQEAgLTEsMjQgKzEsNyBAQAogLy8gZm9yIGZyYW1ld29ya3MvYXYvbWVkaWEKIHsKLSAgICAicHJlc3VibWl0LWxhcmdlIjogWwotICAgICAgICAvLyBydW5zIHdoZW5ldmVyIHdlIGNoYW5nZSBzb21ldGhpbmcgaW4gdGhpcyB0cmVlCi0gICAgICAgIHsKLSAgICAgICAgICAgICJuYW1lIjogIkN0c01lZGlhVGVzdENhc2VzIiwKLSAgICAgICAgICAgICJvcHRpb25zIjogWwotICAgICAgICAgICAgICAgIHsKLSAgICAgICAgICAgICAgICAgICAgImluY2x1ZGUtZmlsdGVyIjogImFuZHJvaWQubWVkaWEuY3RzLkVuY29kZURlY29kZVRlc3QiCi0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgXQotICAgICAgICB9LAotICAgICAgICB7Ci0gICAgICAgICAgICAibmFtZSI6ICJDdHNNZWRpYVRlc3RDYXNlcyIsCi0gICAgICAgICAgICAib3B0aW9ucyI6IFsKLSAgICAgICAgICAgICAgICB7Ci0gICAgICAgICAgICAgICAgICAgICJpbmNsdWRlLWZpbHRlciI6ICJhbmRyb2lkLm1lZGlhLmN0cy5EZWNvZGVFZGl0RW5jb2RlVGVzdCIKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICBdCi0gICAgICAgIH0KLSAgICBdLAorICAgIC8vIFRPRE8gKGIvMjI5Mjg2NDA3KSBBZGQgRW5jb2RlRGVjb2RlVGVzdCBhbmQgRGVjb2RlRWRpdEVuY29kZVRlc3QgdG8KKyAgICAvLyBwcmVzdWJtaXQtbGFyZ2Ugb25jZSBpc3N1ZXMgaW4gY3V0dGxlZmlzaCBhcmUgZml4ZWQKICAgICAicHJlc3VibWl0IjogWwogICAgICAgICB7CiAgICAgICAgICAgICAibmFtZSI6ICJHdHNNZWRpYVRlc3RDYXNlcyIsCkBAIC00MCwyNiArMjMsOCBAQAogICAgICAgICB7CiAgICAgICAgICAgICAicGF0aCI6ICJmcmFtZXdvcmtzL2F2L2RybS9tZWRpYWRybS9wbHVnaW5zIgogICAgICAgICB9Ci0gICAgXSwKLQotICAgICJwbGF0aW51bS1wb3N0c3VibWl0IjogWwotICAgICAgICAvLyBydW5zIHJlZ3VsYXJseSwgaW5kZXBlbmRlbnQgb2YgY2hhbmdlcyBpbiB0aGlzIHRyZWUuCi0gICAgICAgIC8vIHNpZ25hbHMgaWYgY2hhbmdlcyBlbHNld2hlcmUgYnJlYWsgbWVkaWEgZnVuY3Rpb25hbGl0eQotICAgICAgICB7Ci0gICAgICAgICAgICAibmFtZSI6ICJDdHNNZWRpYVRlc3RDYXNlcyIsCi0gICAgICAgICAgICAib3B0aW9ucyI6IFsKLSAgICAgICAgICAgICAgICB7Ci0gICAgICAgICAgICAgICAgICAgICJpbmNsdWRlLWZpbHRlciI6ICJhbmRyb2lkLm1lZGlhLmN0cy5FbmNvZGVEZWNvZGVUZXN0IgotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIF0KLSAgICAgICAgfSwKLSAgICAgICAgewotICAgICAgICAgICAgIm5hbWUiOiAiQ3RzTWVkaWFUZXN0Q2FzZXMiLAotICAgICAgICAgICAgIm9wdGlvbnMiOiBbCi0gICAgICAgICAgICAgICAgewotICAgICAgICAgICAgICAgICAgICAiaW5jbHVkZS1maWx0ZXIiOiAiYW5kcm9pZC5tZWRpYS5jdHMuRGVjb2RlRWRpdEVuY29kZVRlc3QiCi0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgXQotICAgICAgICB9CiAgICAgXQorCisgICAgLy8gVE9ETyAoYi8yMjkyODY0MDcpIEFkZCBFbmNvZGVEZWNvZGVUZXN0IGFuZCBEZWNvZGVFZGl0RW5jb2RlVGVzdCB0bworICAgIC8vIHBsYXRpbnVtLXBvc3RzdWJtaXQgb25jZSBpc3N1ZXMgaW4gY3V0dGxlZmlzaCBhcmUgZml4ZWQKIH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hZFBvb2woKTsKICAgICAgICAgZm9yICg7OykgewogICAgICAgICAgICAgc2lnaW5mb190IGluZm87Ci0gICAgICAgICAgICBpbnQgcmV0ID0gd2FpdGlkKFBfUElELCBjaGlsZFBpZCwgJmluZm8sIFdFWElURUQgfCBXU1RPUFBFRCB8IFdDT05USU5VRUQpOwotICAgICAgICAgICAgaWYgKHJldCA9PSBFSU5UUikgewotICAgICAgICAgICAgICAgIGNvbnRpbnVlOwotICAgICAgICAgICAgfQorICAgICAgICAgICAgaW50IHJldCA9IFRFTVBfRkFJTFVSRV9SRVRSWSh3YWl0aWQoUF9QSUQsIGNoaWxkUGlkLCAmaW5mbywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFdFWElURUQgfCBXU1RPUFBFRCB8IFdDT05USU5VRUQpKTsKICAgICAgICAgICAgIGlmIChyZXQgPCAwKSB7CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICB9CkBAIC0xNDYsMTAgKzE1MywyNCBAQAogICAgICAgICAvLyBBQXVkaW9TZXJ2aWNlIHNob3VsZCBvbmx5IGJlIHVzZWQgaW4gT0MtTVIxIGFuZCBsYXRlci4KICAgICAgICAgLy8gQW5kIG9ubHkgZW5hYmxlIHRoZSBBQXVkaW9TZXJ2aWNlIGlmIHRoZSBzeXN0ZW0gTU1BUCBwb2xpY3kgZXhwbGljaXRseSBhbGxvd3MgaXQuCiAgICAgICAgIC8vIFRoaXMgcHJldmVudHMgYSBjbGllbnQgZnJvbSBtaXN1c2luZyBBQXVkaW9TZXJ2aWNlIHdoZW4gaXQgaXMgbm90IHN1cHBvcnRlZC4KLSAgICAgICAgYWF1ZGlvX3BvbGljeV90IG1tYXBQb2xpY3kgPSBwcm9wZXJ0eV9nZXRfaW50MzIoQUFVRElPX1BST1BfTU1BUF9QT0xJQ1ksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFBVUR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PT0gMCkgPDwgInBpcGUgY29ubmVjdGlvbiBmYWlsZWQgZm9yIHJlc3VsdFBpcGVcbiI7CisKKyAgICAgICAgbVJlY2VpdmVyUGlkID0gZm9yaygpOworICAgICAgICBBU1NFUlRfVFJVRShtUmVjZWl2ZXJQaWQgPj0gMCkgPDwgImZvcmsgZmFpbGVkXG4iOworCisgICAgICAgIGlmIChtUmVjZWl2ZXJQaWQgPT0gMCkgeworICAgICAgICAgICAgZG9SZWNlaXZlcigpOworICAgICAgICAgICAgLy8gSW4gb3JkZXIgdG8gaWdub3JlIGd0ZXN0IGJlaGF2aW91ciwgd2FpdCBmb3IgYmVpbmcga2lsbGVkIGZyb20gdGVhckRvd24KKyAgICAgICAgICAgIHBhdXNlKCk7CisgICAgICAgIH0KKyAgICAgICAgc2V0dXBCdWZmZXJwb29sTWFuYWdlcigpOworICAgIH0KKworICAgIHZpcnR1YWwgdm9pZCBUZWFyRG93bigpIG92ZXJyaWRlIHsKKyAgICAgICAgaWYgKG1SZWNlaXZlclBpZCA+IDApIHsKKyAgICAgICAgICAgIGtpbGwobVJlY2VpdmVyUGlkLCBTSUdLSUxMKTsKKyAgICAgICAgICAgIGludCB3c3RhdHVzOworICAgICAgICAgICAgd2FpdCgmd3N0YXR1cyk7CisgICAgICAgIH0KKyAgICB9CisKKyAgcHJvdGVjdGVkOgorICAgIHBpZF90IG1SZWNlaXZlclBpZDsKKyAgICBpbnQgbUNvbW1hbmRQaXBlRmRzWzJdOworICAgIGludCBtUmVzdWx0UGlwZUZkc1syXTsKKworICAgIGJvb2wgc2VuZE1lc3NhZ2UoaW50KiBwaXBlcywgY29uc3QgUGlwZU1lc3NhZ2UmIG1lc3NhZ2UpIHsKKyAgICAgICAgaW50IHJldCA9IHdyaXRlKHBpcGVzWzFdLCBtZXNzYWdlLmFycmF5LCBzaXplb2YoUGlwZU1lc3NhZ2UpKTsKKyAgICAgICAgcmV0dXJuIHJldCA9PSBzaXplb2YoUGlwZU1lc3NhZ2UpOworICA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HsKKyAgICAgICAgICAgICAgICAgICAgbWVzc2FnZS5kYXRhLmNvbW1hbmQgPSBQaXBlQ29tbWFuZDo6SU5JVF9FUlJPUjsKKyAgICAgICAgICAgICAgICAgICAgc2VuZE1lc3NhZ2UobVJlc3VsdFBpcGVGZHMsIG1lc3NhZ2UpOworICAgICAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgICAgYW5kcm9pZDo6c3RhdHVzX3Qgc3RhdHVzID0gbU1hbmFnZXItPnJlZ2lzdGVyQXNTZXJ2aWNlKCk7CisgICAgICAgICAgICAgICAgaWYgKHN0YXR1cyAhPSBhbmRyb2lkOjpPSykgeworICAgICAgICAgICAgICAgICAgICBtZXNzYWdlLmRhdGEuY29tbWFuZCA9IFBpcGVDb21tYW5kOjpJTklUX0VSUk9SOworICAgICAgICAgICAgICAgICAgICBzZW5kTWVzc2FnZShtUmVzdWx0UGlwZUZkcywgbWVzc2FnZSk7CisgICAgICAgICAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgbWVzc2FnZS5kYXRhLmNvbW1hbmQgPSBQaXBlQ29tbWFuZDo6SU5JVF9PSzsKKyAgICAgICAgICAgICAgICBzZW5kTWVzc2FnZShtUmVzdWx0UGlwZUZkcywgbWVzc2FnZSk7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBjYXNlIFBpcGVDb21tYW5kOjpUUkFOU0ZFUjogeworICAgICAgICAgICAgICAgIG5hdGl2ZV9oYW5kbGVfdCogcmVjZWl2ZUhhbmRsZSA9IG51bGxwdHI7CisgICAgICAgICAgICAgICAgc3RkOjpzaGFyZWRfcHRyPEJ1ZmZlclBvb2xEYXRhPiByZWNlaXZlQnVmZmVyOworICAgICAgICAgICAgICAgIGVyciA9IG1NYW5hZ2VyLT5yZWNlaXZlKG1lc3NhZ2UuZGF0YS5jb25uZWN0aW9uSWQsIG1lc3NhZ2UuZGF0YS50cmFuc2FjdGlvbklkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2UuZGF0YS5idWZmZXJJZCwgbWVzc2FnZS5kYXRhLnRpbWVzdGFtcFVzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZyZWNlaXZlSGFuZGxlLCAmcmVjZWl2ZUJ1ZmZlcik7CisgICAgICAgICAgICAgICAgaWYgKGVyciAhPSBSZXN1bHRTdGF0dXM6Ok9LKSB7CisgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2UuZGF0YS5jb21tYW5kID0gUGlwZUNvbW1hbmQ6OlRSQU5TRkVSX0VSUk9SOworICAgICAgICAgICAgICAgICAgICBzZW5kTWVzc2FnZShtUmVzdWx0UGlwZUZkcywgbWVzc2FnZSk7CisgICAgICAgICAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgaWYgKCFUZXN0QnVmZmVyUG9vbEFsbG9jYXRvcjo6VmVyaWZ5KHJlY2VpdmVIYW5kbGUsIG1lc3NhZ2UuZGF0YS5tZW1zZXRWYWx1ZSkpIHsKKyAgICAgICAgICAgICAgICAgICAgbWVzc2FnZS5kYXRhLmNvbW1hbmQgPSBQaXBlQ29tbWFuZDo6VFJBTlNGRVJfRVJST1I7CisgICAgICAgICAgICAgICAgICAgIHNlbmRNZXNzYWdlKG1SZXN1bHRQaXBlRmRzLCBtZXNzYWdlKTsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBpZiAocmVjZWl2ZUhhbmRsZSkgeworICAgICAgICAgICAgICAgICAgICBuYXRpdmVfaGFuZGxlX2Nsb3NlKHJlY2VpdmVIYW5kbGUpOworICAgICAgICAgICAgICAgICAgICBuYXRpdmVfaGFuZGxlX2RlbGV0ZShyZWNlaXZlSGFuZGxlKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgcmVjZWl2ZUhhbmRsZSA9IG51bGxwdHI7CisgICAgICAgICAgICAgICAgcmVjZWl2ZUJ1ZmZlci5yZXNldCgpOworICAgICAgICAgICAgICAgIG1lc3NhZ2UuZGF0YS5jb21tYW5kID0gUGlwZUNvbW1hbmQ6OlRSQU5TRkVSX09LOworICAgICAgICAgICAgICAgIHNlbmRNZXNzYWdlKG1SZXN1bHRQaXBlRmRzLCBtZXNzYWdlKTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGNhc2UgUGlwZUNvbW1hbmQ6OlNUT1A6IHsKKyAgICAgICAgICAgICAgICBlcnIgPSBtTWFuYWdlci0+Y2xvc2UobWVzc2FnZS5kYXRhLmNvbm5lY3Rpb25JZCk7CisgICAgICAgICAgICAgICAgaWYgKGVyciAhPSBSZXN1bHRTdGF0dXM6Ok9LKSB7CisgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2UuZGF0YS5jb21tYW5kID0gUGlwZUNvbW1hbmQ6OlNUT1BfRVJST1I7CisgICAgICAgICAgICAgICAgICAgIHNlbmRNZXNzYWdlKG1SZXN1bHRQaXBlRmRzLCBtZXNzYWdlKTsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBtZXNzYWdlLmRhdGEuY29tbWFuZCA9IFBpcGVDb21tYW5kOjpTVE9QX09LOworICAgICAgICAgICAgICAgIHNlbmRNZXNzYWdlKG1SZXN1bHRQaXBlRmRzLCBtZXNzYWdlKTsKKyAgICAgICAgICAgICAgICByZWNlaXZlclJ1bm5pbmcgPSBmYWxzZTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgQUxPR0UoInVua25vd24gY29tbWFuZC4gdHJ5IGFnYWluIik7Cisg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CBhL21lZGlhL2NvZGVjMi9PV05FUlMgYi9tZWRpYS9jb2RlYzIvT1dORVJTCmluZGV4IDQ2YTlmY2EuLjdkNDAwNDEgMTAwNjQ0Ci0tLSBhL21lZGlhL2NvZGVjMi9PV05FUlMKKysrIGIvbWVkaWEvY29kZWMyL09XTkVSUwpAQCAtMSw1ICsxLDQgQEAKIHNldCBub3BhcmVudAogd29uc2lrQGdvb2dsZS5jb20KIGxham9zQGdvb2dsZS5jb20KLXBhd2luQGdvb2dsZS5jb20KIHRha2xlZUBnb29nbGUuY29tCmRpZmYgLS1naXQgYS9tZWRpYS9jb2RlYzIvVEVTVF9NQVBQSU5HIGIvbWVkaWEvY29kZWMyL1RFU1RfTUFQUElORwppbmRleCA2YWM0MjEwLi45MGJiMDU0IDEwMDY0NAotLS0gYS9tZWRpYS9jb2RlYzIvVEVTVF9NQVBQSU5HCisrKyBiL21lZGlhL2NvZGVjMi9URVNUX01BUFBJTkcKQEAgLTgsNyArOCwxOCBAQAogICBdLAogICAicHJlc3VibWl0LWxhcmdlIjogWwogICAgIHsKLSAgICAgICJuYW1lIjogIkN0c01lZGlhVGVzdENhc2VzIiwKKyAgICAgICJuYW1lIjogIkN0c01lZGlhTWlzY1Rlc3RDYXNlcyIsCisgICAgICAib3B0aW9ucyI6IFsKKyAgICAgICAgeworICAgICAgICAgICJpbmNsdWRlLWFubm90YXRpb24iOiAiYW5kcm9pZC5wbGF0Zm9ybS50ZXN0LmFubm90YXRpb25zLlByZXN1Ym1pdCIKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICJleGNsdWRlLWFubm90YXRpb24iOiAiYW5kcm9pZC5wbGF0Zm9ybS50ZXN0LmFubm90YXRpb25zLlJlcXVpcmVzRGV2aWNlIgorICAgICAgICB9CisgICAgICBdCisgICAgfSwKKyAgICB7CisgICAgICAibmFtZSI6ICJDdHNNZWRpYUF1ZGlvVGVzdENhc2VzIiwKICAgICAgICJvcHRpb25zIjogWwogICAgICAgICB7CiA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ICAgIm9wdGlvbnMiOiBbCisgICAgICAgIHsKKyAgICAgICAgICAiaW5jbHVkZS1hbm5vdGF0aW9uIjogImFuZHJvaWQucGxhdGZvcm0udGVzdC5hbm5vdGF0aW9ucy5QcmVzdWJtaXQiCisgICAgICAgIH0sCisgICAgICAgIHsKKyAgICAgICAgICAiZXhjbHVkZS1hbm5vdGF0aW9uIjogImFuZHJvaWQucGxhdGZvcm0udGVzdC5hbm5vdGF0aW9ucy5SZXF1aXJlc0RldmljZSIKKyAgICAgICAgfQorICAgICAgXQorICAgIH0sCisgICAgeworICAgICAgIm5hbWUiOiAiQ3RzTWVkaWFDb2RlY1Rlc3RDYXNlcyIsCisgICAgICAib3B0aW9ucyI6IFsKKyAgICAgICAgeworICAgICAgICAgICJpbmNsdWRlLWFubm90YXRpb24iOiAiYW5kcm9pZC5wbGF0Zm9ybS50ZXN0LmFubm90YXRpb25zLlByZXN1Ym1pdCIKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICJleGNsdWRlLWFubm90YXRpb24iOiAiYW5kcm9pZC5wbGF0Zm9ybS50ZXN0LmFubm90YXRpb25zLlJlcXVpcmVzRGV2aWNlIgorICAgICAgICB9CisgICAgICBdCisgICAgfSwKKyAgICB7CisgICAgICAibmFtZSI6ICJDdHNNZWRpYVBsYXllclRlc3RDYXNlcyIsCisgICAgICAib3B0aW9ucyI6IFsKKyAgICAgICAgeworICAgICAgICAgICJpbmNsdWRlLWFubm90YXRpb24iOiAiYW5kcm9pZC5wbGF0Zm9ybS50ZXN0LmFubm90YXRpb25zLlByZXN1Ym1pdCIKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICJleGNsdWRlLWFubm90YXRpb24iOiAiYW5kcm9pZC5wbGF0Zm9ybS50ZXN0LmFubm90YXRpb25zLlJlcXVpcmVzRGV2aWNlIgogICAgICAgICB9CiAgICAgICBdCiAgICAgfQpkaWZmIC0tZ2l0IGEvbWVkaWEvY29kZWMyL2NvbXBvbmVudHM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YWlsdXJlczsKICAgICAgICAgICAgICAgICBjMl9zdGF0dXNfdCBlcnIgPSBtSW50Zi0+Y29uZmlnKAotICAgICAgICAgICAgICAgICAgICAgICAgeyAmc2FtcGxlUmF0ZUluZm8sICZjaGFubmVsQ291bnRJbmZvIH0sCisgICAgICAgICAgICAgICAgICAgICAgICB7ICZzYW1wbGVSYXRlSW5mbywgJmNoYW5uZWxDb3VudEluZm8sICZjaGFubmVsTWFza0luZm8gfSwKICAgICAgICAgICAgICAgICAgICAgICAgIEMyX01BWV9CTE9DSywKICAgICAgICAgICAgICAgICAgICAgICAgICZmYWlsdXJlcyk7CiAgICAgICAgICAgICAgICAgaWYgKGVyciA9PSBPSykgewpAQCAtODQwLDYgKzg0OSw3IEBACiAgICAgICAgICAgICAgICAgICAgIEMyRnJhbWVEYXRhICZvdXRwdXQgPSB3b3JrLT53b3JrbGV0cy5mcm9udCgpLT5vdXRwdXQ7CiAgICAgICAgICAgICAgICAgICAgIG91dHB1dC5jb25maWdVcGRhdGUucHVzaF9iYWNrKEMyUGFyYW06OkNvcHkoc2FtcGxlUmF0ZUluZm8pKTsKICAgICAgICAgICAgICAgICAgICAgb3V0cHV0LmNvbmZpZ1VwZGF0ZS5wdXNoX2JhY2soQzJQYXJhbTo6Q29weShjaGFubmVsQ291bnRJbmZvKSk7CisgICAgICAgICAgICAgICAgICAgIG91dHB1dC5jb25maWdVcGRhdGUucHVzaF9iYWNrKEMyUGFyYW06OkNvcHkoY2hhbm5lbE1hc2tJbmZvKSk7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgQUxPR0UoIkNvbmZpZyBVcGRhdGUgZmFpbGVkIik7CiAgICAgICAgICAgICAgICAgICAgIG1TaWduYWxsZWRFcnJvciA9IHRydWU7CkBAIC0xMDU2LDYgKzEwNjYsNDcgQEAKICAgICB9CiB9CiAKKy8vIGRlZmluaXRpb25zIGJhc2VkIG9uIGFuZHJvaWQubWVkaWEuQXVkaW9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90ICpkc3RCb3QgPSAodWludDMyX3QgKikgKGRzdCArIGRzdFN0cmlkZSk7Ci0gICAgICAgIHVpbnQxNl90ICp5U3JjVG9wID0gKHVpbnQxNl90Kikgc3JjWTsKLSAgICAgICAgdWludDE2X3QgKnlTcmNCb3QgPSAodWludDE2X3QqKSAoc3JjWSArIHNyY1lTdHJpZGUpOwotICAgICAgICB1aW50MTZfdCAqdVNyYyA9ICh1aW50MTZfdCopIHNyY1U7Ci0gICAgICAgIHVpbnQxNl90ICp2U3JjID0gKHVpbnQxNl90Kikgc3JjVjsKLQotICAgICAgICB1aW50MzJfdCB1MDEsIHYwMSwgeTAxLCB5MjMsIHk0NSwgeTY3LCB1djAsIHV2MTsKLSAgICAgICAgc2l6ZV90IHggPSAwOwotICAgICAgICBmb3IgKDsgeCA8IHdpZHRoIC0gMzsgeCArPSA0KSB7Ci0KLSAgICAgICAgICAgIHUwMSA9ICooKHVpbnQzMl90Kil1U3JjKTsgdVNyYyArPSAyOwotICAgICAgICAgICAgdjAxID0gKigodWludDMyX3QqKXZTcmMpOyB2U3JjICs9IDI7Ci0KLSAgICAgICAgICAgIHkwMSA9ICooKHVpbnQzMl90Kil5U3JjVG9wKTsgeVNyY1RvcCArPSAyOwotICAgICAgICAgICAgeTIzID0gKigodWludDMyX3QqKXlTcmNUb3ApOyB5U3JjVG9wICs9IDI7Ci0gICAgICAgICAgICB5NDUgPSAqKCh1aW50MzJfdCopeVNyY0JvdCk7IHlTcmNCb3QgKz0gMjsKLSAgICAgICAgICAgIHk2NyA9ICooKHVpbnQzMl90Kil5U3JjQm90KTsgeVNyY0JvdCArPSAyOwotCi0gICAgICAgICAgICB1djAgPSAodTAxICYgMHgzRkYpIHwgKCh2MDEgJiAweDNGRikgPDwgMjApOwotICAgICAgICAgICAgdXYxID0gKHUwMSA+PiAxNikgfCAoKHYwMSA+PiAxNikgPDwgMjApOwotCi0gICAgICAgICAgICAqZHN0VG9wKysgPSAzIDw8IDMwIHwgKCh5MDEgJiA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KyAgICAgICAgICAgIGNvbnZlcnRZVVY0MjBQbGFuYXIxNlRvWTQxME9yUkdCQTEwMTAxMDIoCisgICAgICAgICAgICAgICAgICAgICh1aW50MzJfdCAqKWRzdFksIHNyY1ksIHNyY1UsIHNyY1YsIHNyY1lTdHJpZGUgLyAyLCBzcmNVU3RyaWRlIC8gMiwKKyAgICAgICAgICAgICAgICAgICAgc3JjVlN0cmlkZSAvIDIsIGRzdFlTdHJpZGUgLyBzaXplb2YodWludDMyX3QpLCBtV2lkdGgsIG1IZWlnaHQsCisgICAgICAgICAgICAgICAgICAgIHN0ZDo6c3RhdGljX3BvaW50ZXJfY2FzdDxjb25zdCBDMkNvbG9yQXNwZWN0c1N0cnVjdD4oZGVmYXVsdENvbG9yQXNwZWN0cykpOwogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgY29udmVydFlVVjQyMFBsYW5hcjE2VG9ZVVY0MjBQbGFuYXIoZHN0WSwgZHN0VSwgZHN0ViwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNyY1ksIHNyY1UsIHNyY1YsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcmNZU3RyaWRlIC8gMiwgc3JjVVN0cmlkZSAvIDIsIHNyY1ZTdHJpZGUgLyAyLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZHN0WVN0cmlkZSwgZHN0VVZTdHJpZGUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtV2lkdGgsIG1IZWlnaHQpOworICAgICAgICAgICAgY29udmVydFlVVjQyMFBsYW5hcjE2VG9ZVjEyKGRzdFksIGRzdFUsIGRzdFYsIHNyY1ksIHNyY1UsIHNyY1YsIHNyY1lTdHJpZGUgLyAyLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNyY1VTdHJpZGUgLyAyLCBzcmNWU3RyaWRlIC8gMiwgZHN0WVN0cmlkZSwgZHN0VVZTdHJpZGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbVdpZHRoLCBtSGVpZ2h0KTsKICAgICAgICAgfQogICAgIH0gZWxzZSB7CiAgICAgICAgIGNvbnN0IHVpbnQ4X3QgKnNyY1kgPSAoY29uc3QgdWludDhfdCAqKWltZy0+cGxhbmVzW0FPTV9QTEFORV9ZXTsKICAgICAgICAgY29uc3QgdWludDhfdCAqc3JjVSA9IChjb25zdCB1aW50OF90ICopaW1nLT5wbGFuZXNbQU9NX1BMQU5FX1VdOwogICAgICAgICBjb25zdCB1aW50OF90ICpzcmNWID0gKGNvbnN0IHVpbnQ4X3QgKilpbWctPnBsYW5lc1tBT01fUExBTkVfVl07Ci0gICAgICAgIGNvcHlPdXRwdXRCdWZmZXJUb1l1dlBsYW5hckZyYW1lKAotICAgICAgICAgICAgICAgIGRzdFksIGRzdFUsIGRzdFYsIHNyY1ksIHNyY1UsIHNyY1YsCi0gICAgICAgICAgICAgICAgc3JjWVN0cmlkZSwgc3JjVVN0cmlkZSwgc3JjVlN0cmlkZSwKLSAgICAgICAgICAgICAgICBkc3RZU3RyaWRlLCBkc3RVVlN0cmlkZSwKLSAgICAgICAgICAgICAgICBtV2lkdGgsIG1IZWlnaHQpOworICAgICAgICBjb252ZXJ0WVVWNDIwUGxhbmFyOFRvWVYxMihkc3RZLCBkc3RVLCBkc3RWLCBzcmNZLCBzcmNVLCBzcmNWLCBzcmNZU3RyaWRlLCBzcmNVU3RyaWRlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcmNWU3RyaWRlLCBkc3RZU3RyaWRlLCBkc3RVVlN0cmlkZSwgbVdpZHRoLCBtSGVpZ2h0KTsKICAgICB9CiAgICAgZmluaXNoV29yaygqKGludDY0X3QqKWltZy0+dXNlcl9wcml2LCB3b3JrLCBzdGQ6Om1vdmUoYmxvY2spKTsKICAgICBibG9jayA9IG51bGxwdHI7CmRpZmYgLS1naXQgYS9tZWRpYS9jb2RlYzIv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GRlY29kZSgpCi0gICAgc3RydWN0IHRpbWV2YWwgbVRpbWVFbmQ7ICAgICAvLyBUaW1lIGF0IHRoZSBlbmQgb2YgZGVjb2RlKCkKKyAgICBuc2Vjc190IG1UaW1lU3RhcnQgPSAwOyAgIC8vIFRpbWUgYXQgdGhlIHN0YXJ0IG9mIGRlY29kZSgpCisgICAgbnNlY3NfdCBtVGltZUVuZCA9IDA7ICAgICAvLyBUaW1lIGF0IHRoZSBlbmQgb2YgZGVjb2RlKCkKIAogICAgIHN0YXR1c190IGluaXREZWNvZGVyKCk7CiAgICAgc3RhdHVzX3QgZGVzdHJveURlY29kZXIoKTsKQEAgLTg1LDE0ICs4MiwxMyBAQAogI2RlZmluZSBPVVRQVVRfRFVNUF9FWFQgImF2MSIKICNkZWZpbmUgR0VORVJBVEVfRklMRV9OQU1FUygpICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKICAgICB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKLSAgICAgICAgR0VUVElNRSgmbVRpbWVTdGFydCwgTlVMTCk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKLSAgICAgICAgc3RyY3B5KG1JbkZpbGUsICIiKTsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgbnNlY3NfdCBub3cgPSBzeXN0ZW1UaW1lKCk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKICAgICAgICAgQUxPR0QoIkdFTkVSQVRFX0ZJTEVfTkFNRVMiKTsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKLSAgICAgICAgc3ByaW50ZihtSW5GaWxlLCAiJXNfJWxkLiVsZC4lcyIsIElOUFVUX0RVTVBfUEFUSCwgbVRpbWVTdGFydC50dl9zZWMsIFwKLSAgICAgICAgICAgICAgICBtVGltZVN0YXJ0LnR2X3VzZWMsIElOUFVUX0RVTVBfRVhUKTsgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgc3ByaW50ZihtSW5GaWxlLCAiJXNfJSIgUFJJZDY0ICIuJXMiLCBJTlBVVF9EVU1QX1BBVEgsICAgICAgICAgICAgICAgIFwKKyAgICAgICAgICAgICAgICBub3csIElOUFVUX0RVTVBfRVhUKTsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKICAgICAgICAgc3RyY3B5KG1PdXRGaWxlLCAiIik7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKLSAgICAgICAgc3ByaW50ZihtT3V0RmlsZSwgIiVzXyVsZC4lbGQuJXMiLCBPVVRQVVRfRFVNUF9QQVRILCAgICAgICAgICAgICAgICAgIFwKLSAgICAgICAgICAgICAgICBtVGltZVN0YXJ0LnR2X3NlYywgbVRpbWVTdGFydC50dl91c2VjLCBPVVRQVVRfRFVNUF9FWFQpOyAgICAgIFwKKyAgICAgICAgc3ByaW50ZihtT3V0RmlsZSwgIiVzXyUiIFBSSWQ2NCAiLiVzIiwgT1VUUFVUX0RVTVBfUEFUSCwgICAgICAgICAgICAgIFwKKyAgICAgICAgICAgICAgICBub3csIE9VVFBVVF9EVU1QX0VYVCk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKICAgICB9CiAKICNkZWZpbmUgQ1JFQVRFX0RVTVBfRklMRShtX2ZpbGVuYW1lKSAgICAgICAgICAgICAgICAgICAgIFwKZGlmZiAtLWdpdCBhL21lZGlhL2NvZGVjMi9jb21wb25lbnRzL2F2Yy9BbmRyb2lkLmJwIGIvbWVkaWEvY29kZWMyL2NvbXBvbmVudHMvYXZjL0FuZHJvaWQuYnAKaW5kZXggMGJlMWJlZC4uYTdhZTg1YiAxMDA2NDQKLS0tIGEvbWVk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gKHN0YXJ0KS50dl91c2VjKTsKIAogI2lmZGVmIEZJTEVfRFVNUF9FTkFCTEUKICAgICAjZGVmaW5lIElOUFVUX0RVTVBfUEFUSCAgICAgIi9zZGNhcmQvY2xpcHMvYXZjZF9pbnB1dCIKICAgICAjZGVmaW5lIElOUFVUX0RVTVBfRVhUICAgICAgImgyNjQiCiAgICAgI2RlZmluZSBHRU5FUkFURV9GSUxFX05BTUVTKCkgeyAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgICAgIEdFVFRJTUUoJm1UaW1lU3RhcnQsIE5VTEwpOyAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgIG5zZWNzX3Qgbm93ID0gc3lzdGVtVGltZSgpOyAgICAgICAgICAgICAgICAgICAgICAgICBcCiAgICAgICAgIHN0cmNweShtSW5GaWxlLCAiIik7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgICAgIHNwcmludGYobUluRmlsZSwgIiVzXyVsZC4lbGQuJXMiLCBJTlBVVF9EVU1QX1BBVEgsICBcCi0gICAgICAgICAgICAgICAgbVRpbWVTdGFydC50dl9zZWMsIG1UaW1lU3RhcnQudHZfdXNlYywgICAgICBcCisgICAgICAgIHNwcmludGYobUluRmlsZSwgIiVzXyUiIFBSSWQ2NCAiZC4lcyIsICAgICAgICAgICAgICBcCisgICAgICAgICAgICAgICAgSU5QVVRfRFVNUF9QQVRILCBub3csICAgICAgICAgICAgICAgICAgICAgICBcCiAgICAgICAgICAgICAgICAgSU5QVVRfRFVNUF9FWFQpOyAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCiAgICAgfQogICAgICNkZWZpbmUgQ1JFQVRFX0RVTVBfRklMRShtX2ZpbGVuYW1lKSB7ICAgICAgICAgICAgICAgICAgXApAQCAtMTgzLDggKzE4MCw4IEBACiAgICAgfSBtQml0c3RyZWFtQ29sb3JBc3BlY3RzOwogCiAgICAgLy8gcHJvZmlsZQotICAgIHN0cnVjdCB0aW1ldmFsIG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FQgICAgICJoMjY0IgogCiAjZGVmaW5lIEdFTkVSQVRFX0ZJTEVfTkFNRVMoKSB7ICAgICAgICAgICAgICAgICAgICAgICAgIFwKLSAgICBHRVRUSU1FKCZtVGltZVN0YXJ0LCBOVUxMKTsgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgIG5zZWNzX3Qgbm93ID0gc3lzdGVtVGltZSgpOyAgICAgICAgICAgICAgICAgICAgICAgICBcCiAgICAgc3RyY3B5KG1JbkZpbGUsICIiKTsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKLSAgICBzcHJpbnRmKG1JbkZpbGUsICIlc18lbGQuJWxkLiVzIiwgSU5QVVRfRFVNUF9QQVRILCAgXAotICAgICAgICAgICAgbVRpbWVTdGFydC50dl9zZWMsIG1UaW1lU3RhcnQudHZfdXNlYywgICAgICBcCisgICAgc3ByaW50ZihtSW5GaWxlLCAiJXNfJSIgUFJJZDY0ICJkLiVzIiwgICAgICAgICAgICAgIFwKKyAgICAgICAgICAgIElOUFVUX0RVTVBfUEFUSCwgbm93LCAgICAgICAgICAgICAgICAgICAgICAgXAogICAgICAgICAgICAgSU5QVVRfRFVNUF9FWFQpOyAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCiAgICAgc3RyY3B5KG1PdXRGaWxlLCAiIik7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKLSAgICBzcHJpbnRmKG1PdXRGaWxlLCAiJXNfJWxkLiVsZC4lcyIsIE9VVFBVVF9EVU1QX1BBVEgsXAotICAgICAgICAgICAgbVRpbWVTdGFydC50dl9zZWMsIG1UaW1lU3RhcnQudHZfdXNlYywgICAgICBcCisgICAgc3ByaW50ZihtT3V0RmlsZSwgIiVzXyUiIFBSSWQ2NCAiZC4lcyIsICAgICAgICAgICAgIFwKKyAgICAgICAgICAgIE9VVFBVVF9EVU1QX1BBVEgsIG5vdywgICAgICAgICAgICAgICAgICAgICAgXAogICAgICAgICAgICAgT1VUUFVUX0RVTVBfRVh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vIGZvciBwcm9wZXJ0aWVzCiAgICAgICAgICJsaWJsb2ciLCAvLyBmb3IgQUxPRwpAQCAtMzQsNiArNDksMTIgQEAKICAgICAgICAgImxpYnN0YWdlZnJpZ2h0X2ZvdW5kYXRpb24iLCAvLyBmb3IgTXV0ZXhlZAogICAgIF0sCiAKKyAgICBtaW5fc2RrX3ZlcnNpb246ICIyOSIsCisgICAgYXBleF9hdmFpbGFibGU6IFsKKyAgICAgICAgIi8vYXBleF9hdmFpbGFibGU6cGxhdGZvcm0iLAorICAgICAgICAiY29tLmFuZHJvaWQubWVkaWEuc3djb2RlYyIsCisgICAgXSwKKwogICAgIHNhbml0aXplOiB7CiAgICAgICAgIG1pc2NfdW5kZWZpbmVkOiBbCiAgICAgICAgICAgICAidW5zaWduZWQtaW50ZWdlci1vdmVyZmxvdyIsCkBAIC02MSw2ICs4MiwxMSBAQAogICAgICAgICAibGlic2ZwbHVnaW5fY2NvZGVjX3V0aWxzIiwKICAgICBdLAogCisgICAgaGVhZGVyX2xpYnM6IFsKKyAgICAgICAgImxpYmFyZWN0X2hlYWRlcnMiLAorICAgICAgICAibGlibmF0aXZld2luZG93X2hlYWRlcnMiLAorICAgIF0sCisKICAgICBzaGFyZWRfbGliczogWwogICAgICAgICAibGliY29kZWMyX3NvZnRfY29tbW9uIiwKICAgICAgICAgImxpYmN1dGlscyIsIC8vIGZvciBwcm9wZXJ0aWVzCkBAIC03NSw2ICsxMDEsMTIgQEAKICAgICBdLAogCiAgICAgbGRmbGFnczogWyItV2wsLUJzeW1ib2xpYyJdLAorCisgICAgbWluX3Nka192ZXJzaW9uOiAiMjkiLAorICAgIGFwZXhfYXZhaWxhYmxlOiBbCisgICAgICAgICIvL2FwZXhfYXZhaWxhYmxlOnBsYXRmb3JtIiwKKyAgICAgICAgImNvbS5hbmRyb2lkLm1lZGlhLnN3Y29kZWMiLAorICAgIF0sCiB9CiAKIC8vIHB1YmxpYyBkZXBlbmRlbmN5IGZvciBzb2Z0d2FyZSBj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CBjb252ZXJ0WVVWNDIwUGxhbmFyOFRvWVYxMih1aW50OF90ICpkc3RZLCB1aW50OF90ICpkc3RVLCB1aW50OF90ICpkc3RWLCBjb25zdCB1aW50OF90ICpzcmNZLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1aW50OF90ICpzcmNVLCBjb25zdCB1aW50OF90ICpzcmNWLCBzaXplX3Qgc3JjWVN0cmlkZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90IHNyY1VTdHJpZGUsIHNpemVfdCBzcmNWU3RyaWRlLCBzaXplX3QgZHN0WVN0cmlkZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90IGRzdFVWU3RyaWRlLCB1aW50MzJfdCB3aWR0aCwgdWludDMyX3QgaGVpZ2h0LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIGlzTW9ub2Nocm9tZSkgeworICAgIGZvciAoc2l6ZV90IGkgPSAwOyBpIDwgaGVpZ2h0OyArK2kpIHsKKyAgICAgICAgbWVtY3B5KGRzdFksIHNyY1ksIHdpZHRoKTsKKyAgICAgICAgc3JjWSArPSBzcmNZU3RyaWRlOworICAgICAgICBkc3RZICs9IGRzdFlTdHJpZGU7CisgICAgfQorCisgICAgaWYgKGlzTW9ub2Nocm9tZSkgeworICAgICAgICAvLyBGaWxsIHdpdGggbmV1dHJhbCBVL1YgdmFsdWVzLgorICAgICAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IChoZWlnaHQgKyAxKSAvIDI7ICsraSkgeworICAgICAgICAgICAgbWVtc2V0KGRzdFYsIGtOZXV0cmFsVVZCaXREZXB0aDgsICh3aWR0aCArIDEpIC8gMik7CisgICAgICAgICAgICBtZW1zZXQoZHN0VSwga05ldXRyYWxVVkJpdERlcHRoOCwgKHdpZHRoICsgMSkgLyAyKTsKKyAgICAgICAgICAgIGRzdFYgKz0gZHN0VVZTdHJpZGU7CisgICAgICAgICAgICBkc3RVICs9IGRzdFVWU3RyaWRlOworICAgICAgICB9CisgICAgICAgIHJldHVybjsKKyAgICB9CisKKyAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IChoZWlnaHQgKyAxKSAvIDI7ICsraSkgeworICAgICAgICBtZW1jcHkoZHN0Viwgc3JjViwgKHdpZHRoICsgMSkgLyAyKTsKKyAgICAgICAgc3JjViArPSBzcmNWU3RyaWRlOworICAgICAgICBkc3RWICs9IGRzdFVWU3RyaWRlOworICAgIH0KKworICAgIGZvciAoc2l6ZV90IGkgPSAwOyBpIDwgKGhlaWdodCArIDEpIC8gMjsgKytpKSB7CisgICAgICAgIG1lbWNweShkc3RVLCBzcmNVLCAod2lkdGggKyAxKSAvIDIpOworICAgICAgICBzcmNVICs9IHNyY1VTdHJpZGU7CisgICAgICAgIGRzdFUgKz0gZHN0VVZTdHJpZGU7CisgICAgfQorfQorCit2b2lkIGNvbnZlcnRZVVY0MjBQbGFuYXIxNlRvWTQxMCh1aW50MzJfdCAqZHN0LCBjb25zdCB1aW50MTZfdCAqc3JjWSwgY29uc3QgdWludDE2X3QgKnNyY1UsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1aW50MTZfdCAqc3JjViwgc2l6ZV90IHNyY1lTdHJpZGUsIHNpemVfdCBzcmNVU3RyaWRlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90IHNyY1ZTdHJpZGUsIHNpemVfdCBkc3RTdHJpZGUsIHNpemVfdCB3aWR0aCwgc2l6ZV90IGhlaWdodCkgeworICAgIC8vIENvbnZlcnRpbmcgdHdvIGxpbmVzIGF0IGEgdGltZSwgc2xpZ2h0bHkgZmFzdGVyCisgICAgZm9yIChzaXplX3QgeSA9IDA7IHkgPCBoZWlnaHQ7IHkgKz0gMikgeworICAgICAgICB1aW50MzJfdCAqZHN0VG9wID0gKHVpbnQzMl90ICopZHN0OworICAgICAgICB1aW50MzJfdCAqZHN0Qm90ID0gKHVpbnQzMl90ICopKGRzdCArIGRzdFN0cmlkZSk7CisgICAgICAgIHVpbnQxNl90ICp5U3JjVG9wID0gKHVpbnQxNl90ICopc3JjWTsKKyAgICAgICAgdWludDE2X3QgKnlTcmNCb3QgPSAodWludDE2X3QgKikoc3JjWSArIHNyY1lTdHJpZGUpOworICAgICAgICB1aW50MTZfdCAqdVNyYyA9ICh1aW50MTZfdCAqKXNyY1U7CisgICAgICAgIHVpbnQxNl90ICp2U3JjID0gKHVpbnQxNl90ICopc3JjVjsKKworICAgICAgICB1aW50MzJfdCB1MDEsIHYwMSwgeTAxLCB5MjMsIHk0NSwgeTY3LCB1djAsIHV2MTsKKyAgICAgICAgc2l6ZV90IHggPSAwOworICAgICAgICBmb3IgKDsgeCA8IHdpZHRoIC0gMzsgeCArPSA0KSB7CisgICAgICAgICAgICB1MDEgPSAqKCh1aW50MzJfdCAqKXVTcmMpOworICAgICAgICAgICAgdVNyYyArPSAyOworICAgICAgICAgICAgdjAxID0gKigodWludDMyX3QgKil2U3JjKTsKKyAgICAgICAgICAgIHZTcmMgKz0gMjsKKworICAgICAgICAgICAgeTAxID0gKigodWludDMyX3QgKil5U3JjVG9wKTsKKyAgICAgICAgICAgIHlTcmNUb3AgKz0gMjsKKyAgICAgICAgICAgIHkyMyA9ICooKHVpbnQzMl90ICopeVNyY1RvcCk7CisgICAgICAgICAgICB5U3JjVG9wICs9IDI7CisgICAgICAgICAgICB5NDUgPSAqKCh1aW50MzJfdCAqKXlTcmNCb3QpOworICAgICAgICAgICAgeVNyY0JvdCArPSAyOworICAgICAgICAgICAgeTY3ID0gKigodWludDMyX3QgKil5U3JjQm90KTsKKyAgICAgICAgICAgIHlTcmNCb3QgKz0gMjsKKworICAgICAgICAgICAgdXYwID0gKHUwMSAmIDB4M0ZGKSB8ICgodjAxICYgMHgzRkYpIDw8IDIwKTsKKyAgICAgICAgICAgIHV2MSA9ICh1MDEgPj4gMTYpIHwgKCh2MDEgPj4gMTYpIDw8IDIwKTsKKworICAgICAgICAgICAgKmRzdFRvcCsrID0gMyA8PCAzMCB8ICgoeTAxICYgMHgzRkYpIDw8IDEwKSB8IHV2MDsKKyAgICAgICAgICAgICpkc3RUb3ArKyA9IDMgPDwgMzAgfCAoKHkwMSA+PiAxNikgPDwgMTApIHwgdXYwOworICAgICAgICAgICAgKmRzdFRvcCsrID0gMyA8PCAzMCB8ICgoeTIzICYgMHgzRkYpIDw8IDEwKSB8IHV2MTsKKyAgICAgICAgICAgICpkc3RUb3ArKyA9IDMgPDwgMzAgfCAoKHkyMyA+PiAxNikgPDwgMTApIHwgdXYxOworCisgICAgICAgICAgICAqZHN0Qm90KysgPSAzIDw8IDMwIHwgKCh5NDUgJiAweDNGRikgPDwgMTApIHwgdXYwOworICAgICAgICAgICAgKmRzdEJvdCsrID0gMyA8PCAzMCB8ICgoeTQ1ID4+IDE2KSA8PCAxMCkgfCB1djA7CisgICAgICAgICAgICAqZHN0Qm90KysgPSAzIDw8IDMwIHwgKCh5NjcgJiAweDNGRikgPDwgMTApIHwgdXYxOworICAgICAgICAgICAgKmRzdEJvdCsrID0gMyA8PCAzMCB8ICgoeTY3ID4+IDE2KSA8PCAxMCkgfCB1djE7CisgICAgICAgIH0KKworICAgICAgICAvLyBUaGVyZSBzaG91bGQgYmUgYXQgbW9zdCAyIG1vcmUgcGl4ZWxzIHRvIHByb2Nlc3MuIE5vdGUgdGhhdCB3ZSBkb24ndAorICAgICAgICAvLyBuZWVkIHRvIGNvbnNpZGVyIG9kZCBjYXNlIGFzIHRoZSBidWZmZXIgaXMgYWx3YXlzIGFsaWduZWQgdG8gZXZlbi4KKyAgICAgICAgaWYgKHggPCB3aWR0aCkgeworICAgICAgICAgICAgdTAxID0gKnVTcmM7CisgICAgICAgICAgICB2MDEgPSAqdlNyYzsKKyAgICAgICAgICAgIHkwMSA9ICooKHVpbnQzMl90ICopeVNyY1RvcCk7CisgICAgICAgICAgICB5NDUgPSAqKCh1aW50MzJfdCAqKXlTcmNCb3QpOworICAg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IDw9IDU3NikKKyAgICAgICAgICAgICAgICAgICAgfHwgKGhlaWdodCA8PSA3MjAgJiYgd2lkdGggPD0gNTc2KSkgeworICAgICAgICAgICAgICAgIC8vIG5vdGU6IGl0IGRvZXMgbm90IGFjdHVhbGx5IG1hdHRlciB3aGV0aGVyIHRvIHVzZSA1MjUgb3IgNjI1IGhlcmUgYXMgdGhlCisgICAgICAgICAgICAgICAgLy8gY29udmVyc2lvbiBpcyB0aGUgc2FtZQorICAgICAgICAgICAgICAgIF9hc3BlY3RzLnByaW1hcmllcyA9IEMyQ29sb3I6OlBSSU1BUklFU19CVDYwMV82MjU7CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIF9hc3BlY3RzLnByaW1hcmllcyA9IEMyQ29sb3I6OlBSSU1BUklFU19CVDcwOTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorCisgICAgICAgIHN3aXRjaCAoX2FzcGVjdHMucHJpbWFyaWVzKSB7CisgICAgICAgIGNhc2UgQzJDb2xvcjo6UFJJTUFSSUVTX0JUNjAxXzUyNToKKyAgICAgICAgY2FzZSBDMkNvbG9yOjpQUklNQVJJRVNfQlQ2MDFfNjI1OgorICAgICAgICAgICAgX2FzcGVjdHMubWF0cml4ID0gQzJDb2xvcjo6TUFUUklYX0JUNjAxOworICAgICAgICAgICAgYnJlYWs7CisKKyAgICAgICAgY2FzZSBDMkNvbG9yOjpQUklNQVJJRVNfQlQ3MDk6CisgICAgICAgICAgICBfYXNwZWN0cy5tYXRyaXggPSBDMkNvbG9yOjpNQVRSSVhfQlQ3MDk7CisgICAgICAgICAgICBicmVhazsKKworICAgICAgICBjYXNlIEMyQ29sb3I6OlBSSU1BUklFU19CVDIwMjA6CisgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICBfYXNwZWN0cy5tYXRyaXggPSBDMkNvbG9yOjpNQVRSSVhfQlQyMDIwOworICAgICAgICB9CisgICAgfQorCisgICAgcmV0dXJuIF9hc3BlY3RzOworf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7IDEwMjQsIDE2MTMsIDE5MiwgNDc5LCAxOTAwLCAwIH07CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICByZXR1cm4gQ29lZmZzIHsgMTE5NiwgMTg0MSwgMjE5LCA1NDcsIDIxNjksIDY0IH07CisgICAgICAgIH0KKyAgICAgICAgYnJlYWs7CisKKyAgICBjYXNlIEMyQ29sb3I6Ok1BVFJJWF9CVDIwMjA6CisgICAgZGVmYXVsdDoKKyAgICAgICAgLyoqCisgICAgICAgICAqIEJULjIwMjA6ICBLX1IgPSAwLjI2Mjc7ICBLX0IgPSAwLjA1OTMKKyAgICAgICAgICovCisgICAgICAgIGlmIChpc0Z1bGxSYW5nZSkgeworICAgICAgICAgICAgcmV0dXJuIENvZWZmcyB7IDEwMjQsIDE1MTAsIDE2OSwgNTg1LCAxOTI3LCAwIH07CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICByZXR1cm4gQ29lZmZzIHsgMTE5NiwgMTcyNCwgMTkyLCA2NjgsIDIyMDAsIDY0IH07CisgICAgICAgIH0KKyAgICB9Cit9CisKK30KKworI2RlZmluZSBDTElQMyhtaW4sIHYsIG1heCkgKCgodikgPCAobWluKSkgPyAobWluKSA6ICgoKG1heCkgPiAodikpID8gKHYpIDogKG1heCkpKQordm9pZCBjb252ZXJ0WVVWNDIwUGxhbmFyMTZUb1JHQkExMDEwMTAyKAorICAgICAgICB1aW50MzJfdCAqZHN0LCBjb25zdCB1aW50MTZfdCAqc3JjWSwgY29uc3QgdWludDE2X3QgKnNyY1UsCisgICAgICAgIGNvbnN0IHVpbnQxNl90ICpzcmNWLCBzaXplX3Qgc3JjWVN0cmlkZSwgc2l6ZV90IHNyY1VTdHJpZGUsCisgICAgICAgIHNpemVfdCBzcmNWU3RyaWRlLCBzaXplX3QgZHN0U3RyaWRlLCBzaXplX3Qgd2lkdGgsCisgICAgICAgIHNpemVfdCBoZWlnaHQsCisgICAgICAgIHN0ZDo6c2hhcmVkX3B0cjxjb25zdC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IpIHsKKyAgICAgICAgICAgIGludDMyX3QgdSwgdiwgeTAwLCB5MDEsIHkxMCwgeTExOworICAgICAgICAgICAgdSA9ICp1U3JjIC0gNTEyOworICAgICAgICAgICAgdVNyYyArPSAxOworICAgICAgICAgICAgdiA9ICp2U3JjIC0gNTEyOworICAgICAgICAgICAgdlNyYyArPSAxOworCisgICAgICAgICAgICB5MDAgPSAqeVNyY1RvcCAtIF9jMTY7CisgICAgICAgICAgICB5U3JjVG9wICs9IDE7CisgICAgICAgICAgICB5MDEgPSAqeVNyY1RvcCAtIF9jMTY7CisgICAgICAgICAgICB5U3JjVG9wICs9IDE7CisgICAgICAgICAgICB5MTAgPSAqeVNyY0JvdCAtIF9jMTY7CisgICAgICAgICAgICB5U3JjQm90ICs9IDE7CisgICAgICAgICAgICB5MTEgPSAqeVNyY0JvdCAtIF9jMTY7CisgICAgICAgICAgICB5U3JjQm90ICs9IDE7CisKKyAgICAgICAgICAgIGludDMyX3QgdV9iID0gdSAqIF9iX3U7CisgICAgICAgICAgICBpbnQzMl90IHVfZyA9IHUgKiBfbmVnX2dfdTsKKyAgICAgICAgICAgIGludDMyX3Qgdl9nID0gdiAqIF9uZWdfZ192OworICAgICAgICAgICAgaW50MzJfdCB2X3IgPSB2ICogX3JfdjsKKworICAgICAgICAgICAgaW50MzJfdCB5TXVsdCwgYiwgZywgcjsKKyAgICAgICAgICAgIHlNdWx0ID0geTAwICogX3kgKyA1MTI7CisgICAgICAgICAgICBiID0gKHlNdWx0ICsgdV9iKSAvIDEwMjQ7CisgICAgICAgICAgICBnID0gKHlNdWx0ICsgdl9nICsgdV9nKSAvIDEwMjQ7CisgICAgICAgICAgICByID0gKHlNdWx0ICsgdl9yKSAvIDEwMjQ7CisgICAgICAgICAgICBiID0gQ0xJUDMoMCwgYiwgMTAyMyk7CisgICAgICAgICAgICBnID0gQ0xJUDMoMCwgZywgMTAyMyk7CisgICAgICAgICAgICByID0gQ0xJUDMoMCwgciwgMTAyMyk7CisgICAgICAgICAgICAqZHN0VG9wKysgPSAzIDw8IDMwIHwgKGIgPDwgMjApIHwgKGcgPDwgMTApIHwgcjsKKworICAgICAgICAgICAgeU11bHQgPSB5MDEgKiBfeSArIDUxMjsKKyAgICAgICAgICAgIGIgPSAoeU11bHQgKyB1X2IpIC8gMTAyNDsKKyAgICAgICAgICAgIGcgPSAoeU11bHQgKyB2X2cgKyB1X2cpIC8gMTAyNDsKKyAgICAgICAgICAgIHIgPSAoeU11bHQgKyB2X3IpIC8gMTAyNDsKKyAgICAgICAgICAgIGIgPSBDTElQMygwLCBiLCAxMDIzKTsKKyAgICAgICAgICAgIGcgPSBDTElQMygwLCBnLCAxMDIzKTsKKyAgICAgICAgICAgIHIgPSBDTElQMygwLCByLCAxMDIzKTsKKyAgICAgICAgICAgICpkc3RUb3ArKyA9IDMgPDwgMzAgfCAoYiA8PCAyMCkgfCAoZyA8PCAxMCkgfCByOworCisgICAgICAgICAgICB5TXVsdCA9IHkxMCAqIF95ICsgNTEyOworICAgICAgICAgICAgYiA9ICh5TXVsdCArIHVfYikgLyAxMDI0OworICAgICAgICAgICAgZyA9ICh5TXVsdCArIHZfZyArIHVfZykgLyAxMDI0OworICAgICAgICAgICAgciA9ICh5TXVsdCArIHZfcikgLyAxMDI0OworICAgICAgICAgICAgYiA9IENMSVAzKDAsIGIsIDEwMjMpOworICAgICAgICAgICAgZyA9IENMSVAzKDAsIGcsIDEwMjMpOworICAgICAgICAgICAgciA9IENMSVAzKDAsIHIsIDEwMjMpOworICAgICAgICAgICAgKmRzdEJvdCsrID0gMyA8PCAzMCB8IChiIDw8IDIwKSB8IChnIDw8IDEwKSB8IHI7CisKKyAgICAgICAgICAgIHlNdWx0ID0geTExICogX3kgKyA1MTI7CisgICAgICAgICAgICBiID0gKHlNdWx0ICsgdV9iKSAvIDEwMjQ7CisgICAgICAgICAgICBnID0gKHlNdWx0ICsgdl9nICsgdV9nKSAvIDEwMjQ7CisgICAgICAgICAgICByID0gKHlNdWx0ICsgdl9y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N0cmlkZSwgd2lkdGgsIGhlaWdodCwgYXNwZWN0cyk7CisgICAgfSBlbHNlIHsKKyAgICAgICAgY29udmVydFlVVjQyMFBsYW5hcjE2VG9ZNDEwKGRzdCwgc3JjWSwgc3JjVSwgc3JjViwgc3JjWVN0cmlkZSwgc3JjVVN0cmlkZSwgc3JjVlN0cmlkZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRzdFN0cmlkZSwgd2lkdGgsIGhlaWdodCk7CisgICAgfQorfQorCit2b2lkIGNvbnZlcnRZVVY0MjBQbGFuYXIxNlRvWVYxMih1aW50OF90ICpkc3RZLCB1aW50OF90ICpkc3RVLCB1aW50OF90ICpkc3RWLCBjb25zdCB1aW50MTZfdCAqc3JjWSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVpbnQxNl90ICpzcmNVLCBjb25zdCB1aW50MTZfdCAqc3JjViwgc2l6ZV90IHNyY1lTdHJpZGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplX3Qgc3JjVVN0cmlkZSwgc2l6ZV90IHNyY1ZTdHJpZGUsIHNpemVfdCBkc3RZU3RyaWRlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90IGRzdFVWU3RyaWRlLCBzaXplX3Qgd2lkdGgsIHNpemVfdCBoZWlnaHQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIGlzTW9ub2Nocm9tZSkgeworICAgIGZvciAoc2l6ZV90IHkgPSAwOyB5IDwgaGVpZ2h0OyArK3kpIHsKKyAgICAgICAgZm9yIChzaXplX3QgeCA9IDA7IHggPCB3aWR0aDsgKyt4KSB7CisgICAgICAgICAgICBkc3RZW3hdID0gKHVpbnQ4X3QpKHNyY1lbeF0gPj4gMik7CisgICAgICAgIH0KKyAgICAgICAgc3JjWSArPSBzcmNZU3RyaWRlOworICAgICAgICBkc3RZICs9IGRzdFlTdHJpZGU7CisgICAgfQorCisgICAgaWYgKGlzTW9ub2Nocm9tZSkgeworICAgICAgICAvLyBGaWxsIHdpdGggbmV1dHJhbCBVL1YgdmFsdWVzLgorICAgICAgICBmb3IgKHNpemVfdCB5ID0gMDsgeSA8IChoZWlnaHQgKyAxKSAvIDI7ICsreSkgeworICAgICAgICAgICAgbWVtc2V0KGRzdFYsIGtOZXV0cmFsVVZCaXREZXB0aDgsICh3aWR0aCArIDEpIC8gMik7CisgICAgICAgICAgICBtZW1zZXQoZHN0VSwga05ldXRyYWxVVkJpdERlcHRoOCwgKHdpZHRoICsgMSkgLyAyKTsKKyAgICAgICAgICAgIGRzdFYgKz0gZHN0VVZTdHJpZGU7CisgICAgICAgICAgICBkc3RVICs9IGRzdFVWU3RyaWRlOworICAgICAgICB9CisgICAgICAgIHJldHVybjsKKyAgICB9CisKKyAgICBmb3IgKHNpemVfdCB5ID0gMDsgeSA8IChoZWlnaHQgKyAxKSAvIDI7ICsreSkgeworICAgICAgICBmb3IgKHNpemVfdCB4ID0gMDsgeCA8ICh3aWR0aCArIDEpIC8gMjsgKyt4KSB7CisgICAgICAgICAgICBkc3RVW3hdID0gKHVpbnQ4X3QpKHNyY1VbeF0gPj4gMik7CisgICAgICAgICAgICBkc3RWW3hdID0gKHVpbnQ4X3QpKHNyY1ZbeF0gPj4gMik7CisgICAgICAgIH0KKyAgICAgICAgc3JjVSArPSBzcmNVU3RyaWRlOworICAgICAgICBzcmNWICs9IHNyY1ZTdHJpZGU7CisgICAgICAgIGRzdFUgKz0gZHN0VVZTdHJpZGU7CisgICAgICAgIGRzdFYgKz0gZHN0VVZTdHJpZGU7CisgICAgfQorfQorCit2b2lkIGNvbnZlcnRZVVY0MjBQbGFuYXIxNlRvUDAxMCh1aW50MTZfdCAqZHN0WSwgdWludDE2X3QgKmRzdFVWLCBjb25zdCB1aW50MTZfdCAqc3JjWSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVpbnQxNl90ICpzcmNVLCBjb25zdCB1aW50MTZfdCAqc3JjViwgc2l6ZV90IHNyY1lTdHJpZGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplX3Qgc3JjVVN0cmlkZSwgc2l6ZV90IHNyY1ZTdHJpZGUsIHNpemVfdCBkc3RZU3RyaWRlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90IGRzdFVWU3RyaWRlLCBzaXplX3Qgd2lkdGgsIHNpemVfdCBoZWlnaHQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIGlzTW9ub2Nocm9tZSkgeworICAgIGZvciAoc2l6ZV90IHkgPSAwOyB5IDwgaGVpZ2h0OyArK3kpIHsKKyAgICAgICAgZm9yIChzaXplX3QgeCA9IDA7IHggPCB3aWR0aDsgKyt4KSB7CisgICAgICAgICAgICBkc3RZW3hdID0gc3JjWVt4XSA8PCA2OworICAgICAgICB9CisgICAgICAgIHNyY1kgKz0gc3JjWVN0cmlkZTsKKyAgICAgICAgZHN0WSArPSBkc3RZU3RyaWRlOworICAgIH0KKworICAgIGlmIChpc01vbm9jaHJvbWUpIHsKKyAgICAgICAgLy8gRmlsbCB3aXRoIG5ldXRyYWwgVS9WIHZhbHVlcy4KKyAgICAgICAgZm9yIChzaXplX3QgeSA9IDA7IHkgPCAoaGVpZ2h0ICsgMSkgLyAyOyArK3kpIHsKKyAgICAgICAgICAgIGZvciAoc2l6ZV90IHggPSAwOyB4IDwgKHdpZHRoICsgMSkgLyAyOyArK3gpIHsKKyAgICAgICAgICAgICAgICBkc3RVVlsyICogeF0gPSBrTmV1dHJhbFVWQml0RGVwdGgxMCA8PCA2OworICAgICAgICAgICAgICAgIGRzdFVWWzIgKiB4ICsgMV0gPSBrTmV1dHJhbFVWQml0RGVwdGgxMCA8PCA2OworICAgICAgICAgICAgfQorICAgICAgICAgICAgZHN0VVYgKz0gZHN0VVZTdHJpZGU7CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuOworIC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gICAgICAgICAgICAgICAgICAgICAgIHNpemVfdCBkc3RVVlN0cmlkZSwgc2l6ZV90IHdpZHRoLCBzaXplX3QgaGVpZ2h0LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBpc01vbm9jaHJvbWUgPSBmYWxzZSk7CisKK3ZvaWQgY29udmVydFlVVjQyMFBsYW5hcjE2VG9QMDEwKHVpbnQxNl90ICpkc3RZLCB1aW50MTZfdCAqZHN0VVYsIGNvbnN0IHVpbnQxNl90ICpzcmNZLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdWludDE2X3QgKnNyY1UsIGNvbnN0IHVpbnQxNl90ICpzcmNWLCBzaXplX3Qgc3JjWVN0cmlkZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemVfdCBzcmNVU3RyaWRlLCBzaXplX3Qgc3JjVlN0cmlkZSwgc2l6ZV90IGRzdFlTdHJpZGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplX3QgZHN0VVZTdHJpZGUsIHNpemVfdCB3aWR0aCwgc2l6ZV90IGhlaWdodCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgaXNNb25vY2hyb21lID0gZmFsc2UpOworCiBjbGFzcyBTaW1wbGVDMkNvbXBvbmVudAogICAgICAgICA6IHB1YmxpYyBDMkNvbXBvbmVudCwgcHVibGljIHN0ZDo6ZW5hYmxlX3NoYXJlZF9mcm9tX3RoaXM8U2ltcGxlQzJDb21wb25lbnQ+IHsKIHB1YmxpYzoKQEAgLTE0OSw2ICsxNzYsNyBAQAogICAgIHN0YXRpYyBjb25zdGV4cHIgdWludDMyX3QgTk9fRFJBSU4gPSB+MHU7CiAKICAgICBDMlJlYWRWaWV3IG1EdW1teVJlYWRWaWV3OworICAgIGludCBnZXRIYWxQaXhlbEZvcm1hdEZvckJpdERlcHRoMTAoYm9vbCBhbGxvd1JHQkExMDEwMTAyKTsKIA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XRoRmllbGRzKHsKLSAgICAgICAgICAgICAgICBDMkYobVNpemUsIHdpZHRoKS5pblJhbmdlKDIsIDQwOTYsIDIpLAotICAgICAgICAgICAgICAgIEMyRihtU2l6ZSwgaGVpZ2h0KS5pblJhbmdlKDIsIDQwOTYsIDIpLAorICAgICAgICAgICAgICAgIEMyRihtU2l6ZSwgd2lkdGgpLmluUmFuZ2UoMiwgNDA5NiksCisgICAgICAgICAgICAgICAgQzJGKG1TaXplLCBoZWlnaHQpLmluUmFuZ2UoMiwgNDA5NiksCiAgICAgICAgICAgICB9KQogICAgICAgICAgICAgLndpdGhTZXR0ZXIoU2l6ZVNldHRlcikKICAgICAgICAgICAgIC5idWlsZCgpKTsKQEAgLTExMyw4ICsxMTMsNyBAQAogICAgICAgICAgICAgLmJ1aWxkKCkpOwogCiAgICAgYWRkUGFyYW1ldGVyKERlZmluZVBhcmFtKG1NYXhJbnB1dFNpemUsIEMyX1BBUkFNS0VZX0lOUFVUX01BWF9CVUZGRVJfU0laRSkKLSAgICAgICAgICAgICAgICAgICAgIC53aXRoRGVmYXVsdChuZXcgQzJTdHJlYW1NYXhCdWZmZXJTaXplSW5mbzo6aW5wdXQoCi0gICAgICAgICAgICAgICAgICAgICAgICAgMHUsIDMyMCAqIDI0MCAqIDMgLyA0KSkKKyAgICAgICAgICAgICAgICAgICAgIC53aXRoRGVmYXVsdChuZXcgQzJTdHJlYW1NYXhCdWZmZXJTaXplSW5mbzo6aW5wdXQoMHUsIGtNaW5JbnB1dEJ1ZmZlclNpemUpKQogICAgICAgICAgICAgICAgICAgICAgLndpdGhGaWVsZHMoewogICAgICAgICAgICAgICAgICAgICAgICAgIEMyRihtTWF4SW5wdXRTaXplLCB2YWx1ZSkuYW55KCksCiAgICAgICAgICAgICAgICAgICAgICB9KQpAQCAtMTU2LDExICsxNTUsNTkgQEAKICAgICAgICAgICAgIC53aXRoU2V0dGVyKERlZmF1bHRDb2xvckFzcGVjdHNTZXR0ZXIpCiAgICAgICAgICAgICAuYnVpbGQoKSk7CiAKKyAgICAgIGFkZFBhcmFtZXRlcigKKyAgICAgICAgICAgICAgRGVmaW5lUGFyYW0obUNvZGVkQ29sb3JBc3BlY3RzLCBDMl9QQVJBTUtFWV9WVUlfQ09MT1JfQVNQRUNUUykKKyAgICAgICAgICAgICAgLndpdGhEZWZhdWx0KG5ldyBDMlN0cmVhbUNvbG9yQXNwZWN0c0luZm86OmlucHV0KAorICAgICAgICAgICAgICAgICAgICAgIDB1LCBDMkNvbG9yOjpSQU5HRV9MSU1JVEVELCBDMkNvbG9yOjpQUklNQVJJRVNfVU5TUEVDSUZJRUQsCisgICAgICAgICAgICAgICAgICAgICAgQzJDb2xvcjo6VFJBTlNGRVJfVU5TUEVDSUZJRUQsIEMyQ29sb3I6Ok1BVFJJWF9VTlNQRUNJRklFRCkpCisgICAgICAgICAgICAgIC53aXRoRmllbGRzKHsKKyAgICAgICAgICAgICAgICAgIEMyRihtQ29kZWRDb2xvckFzcGVjdHMsIHJhbmdlKS5pblJhbmdlKAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQzJDb2xvcjo6UkFOR0VfVU5TUEVDSUZJRUQsICAgICBDMkNvbG9yOjpSQU5HRV9PVEhFUiksCisgICAgICAgICAgICAgICAgICBDMkYobUNvZGVkQ29sb3JBc3BlY3RzLCBwcmltYXJpZXMpLmluUmFuZ2UoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDMkNvbG9yOjpQUklNQVJJRVNfVU5TUEVDSUZJRUQsIEMyQ29sb3I6OlBSSU1BUklFU19PVEhFUiksCisgICAgICAgICAgICAgICAgICBDMkYobUNvZGVkQ29sb3JBc3BlY3RzLCB0cmFuc2ZlcikuaW5SYW5nZSgKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEMyQ29sb3I6OlRSQU5TRkVSX1VOU1BFQ0lGSUVELCAgQzJDb2xvcjo6VFJBTlNGRVJfT1RIRVIpLAorICAgICAgICAgICAgICAgICAgQzJGKG1Db2RlZENvbG9yQXNwZWN0cywgbWF0cml4KS5pblJhbmdlKAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQzJDb2xvcjo6TUFUUklYX1VOU1BFQ0lGSUVELCAgICBDMkNvbG9yOjpNQVRSSVhfT1RIRVIpCisgICAgICAgICAgICAgIH0pCisgICAgICAgICAgICAgIC53aXRoU2V0dGVyKENvZGVkQ29sb3JBc3BlY3RzU2V0dGVyKQorICAgICAgICAgICAgICAuYnVpbGQoKSk7CisKKyAgICAgIGFkZFBhcmFtZXRlcigKKyAgICAgICAgICAgICAgRGVmaW5lUGFyYW0obUNvbG9yQXNwZWN0cywgQzJfUEFSQU1LRVlfQ09MT1JfQVNQRUNUUykKKyAgICAgICAgICAgICAgLndpdGhEZWZhdWx0KG5ldyBDMlN0cmVhbUNvbG9yQXNwZWN0c0luZm86Om91dHB1dCgKKyAgICAgICAgICAgICAgICAgICAgICAwdSwgQzJDb2xvcjo6UkFOR0VfVU5TUEVDSUZJRUQsIEMyQ29sb3I6OlBSSU1BUklFU19VTlNQRUNJRklFRCwKKyAgICAgICAgICAgICAgICAgICAgICBDMkNvbG9yOjpUUkFOU0ZFUl9VTlNQRUNJRklFRCwgQzJDb2xvcjo6TUFUUklYX1VOU1BFQ0lGSUVEKSkKKyAgICAgICAgICAgICAgLndpdGhGaWVsZHMoeworICAgICAgICAgICAgICAgICAgQzJGKG1Db2xvckFzcGVjdHMsIHJhbmdlKS5pblJhbmdlKAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQzJDb2xvcjo6UkFOR0VfVU5TUEVDSUZJRUQsICAgICBDMkNvbG9yOjpSQU5HRV9PVEhFUiksCisgICAgICAgICAgICAgICAgICBDMkYobUNvbG9yQXNwZWN0cywgcHJpbWFyaWVzKS5pblJhbmdlKAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQzJDb2xvcjo6UFJJTUFSSUVTX1VOU1BFQ0lGSUVELCBDMkNvbG9yOjpQUklNQVJJRVNfT1RIRVIpL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B2b2lkIGNvbnZlcnRZVVY0MjBQbGFuYXIxNlRvWTQxMCh1aW50MzJfdCAqZHN0LCBjb25zdCB1aW50MTZfdCAqc3JjWSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1aW50MTZfdCAqc3JjVSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1aW50MTZfdCAqc3JjViwgc2l6ZV90IHNyY1lTdHJpZGUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90IHNyY1VTdHJpZGUsIHNpemVfdCBzcmNWU3RyaWRlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemVfdCBkc3RTdHJpZGUsIHNpemVfdCB3aWR0aCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplX3QgaGVpZ2h0KSB7Ci0gIC8vIENvbnZlcnRpbmcgdHdvIGxpbmVzIGF0IGEgdGltZSwgc2xpZ2h0bHkgZmFzdGVyCi0gIGZvciAoc2l6ZV90IHkgPSAwOyB5IDwgaGVpZ2h0OyB5ICs9IDIpIHsKLSAgICB1aW50MzJfdCAqZHN0VG9wID0gKHVpbnQzMl90ICopZHN0OwotICAgIHVpbnQzMl90ICpkc3RCb3QgPSAodWludDMyX3QgKikoZHN0ICsgZHN0U3RyaWRlKTsKLSAgICB1aW50MTZfdCAqeVNyY1RvcCA9ICh1aW50MTZfdCAqKXNyY1k7Ci0gICAgdWludDE2X3QgKnlTcmNCb3QgPSAodWludDE2X3QgKikoc3JjWSArIHNyY1lTdHJpZGUpOwotICAgIHVpbnQxNl90ICp1U3JjID0gKHVpbnQxNl90ICopc3JjVTsKLSAgICB1aW50MTZfdCAqdlNyYyA9ICh1aW50MTZfdCAqKXNyY1Y7Ci0KLSAgICB1aW50MzJfdCB1MDEsIHYwMSwgeTAxLCB5MjMsIHk0NSwgeTY3LCB1djA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AgICAgICAgICAgICAud2l0aERlZmF1bHQobmV3IEMyU3RyZWFtTWF4QnVmZmVyU2l6ZUluZm86OmlucHV0KDB1LCAzMjAgKiAyNDAgKiAzIC8gNCkpCisgICAgICAgICAgICAgICAgLndpdGhEZWZhdWx0KG5ldyBDMlN0cmVhbU1heEJ1ZmZlclNpemVJbmZvOjppbnB1dCgwdSwga01pbklucHV0QnVmZmVyU2l6ZSkpCiAgICAgICAgICAgICAgICAgLndpdGhGaWVsZHMoewogICAgICAgICAgICAgICAgICAgICBDMkYobU1heElucHV0U2l6ZSwgdmFsdWUpLmFueSgpLAogICAgICAgICAgICAgICAgIH0pCkBAIC0yMjAsOCArMjIxLDkgQEAKICAgICBzdGF0aWMgQzJSIE1heElucHV0U2l6ZVNldHRlcihib29sIG1heUJsb2NrLCBDMlA8QzJTdHJlYW1NYXhCdWZmZXJTaXplSW5mbzo6aW5wdXQ+ICZtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDMlA8QzJTdHJlYW1NYXhQaWN0dXJlU2l6ZVR1bmluZzo6b3V0cHV0PiAmbWF4U2l6ZSkgewogICAgICAgICAodm9pZCltYXlCbG9jazsKLSAgICAgICAgLy8gYXNzdW1lIGNvbXByZXNzaW9uIHJhdGlvIG9mIDIKLSAgICAgICAgbWUuc2V0KCkudmFsdWUgPSAoKChtYXhTaXplLnYud2lkdGggKyA2MykgLyA2NCkgKiAoKG1heFNpemUudi5oZWlnaHQgKyA2MykgLyA2NCkgKiAzMDcyKTsKKyAgICAgICAgLy8gYXNzdW1lIGNvbXByZXNzaW9uIHJhdGlvIG9mIDIsIGJ1dCBlbmZvcmNlIGEgZmxvb3IKKyAgICAgICAgbWUuc2V0KCkudmFsdWUgPSBjMl9tYXgoKCgobWF4U2l6ZS52LndpZHRoICsgNjMpIC8gNjQpCisgICAgICAgICAgICAgICAgICAgICogKChtYXhTaXplLnYuaGVpZ2h0ICsgNjMpIC8gNjQpICogMzA3MiksIGtNaW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LyBtYXRjaGVzIHNpemUgbGltaXRzIGluIGNvZGVjIGxpYnJhcnkKICAgICAgICAgYWRkUGFyYW1ldGVyKAogICAgICAgICAgICAgRGVmaW5lUGFyYW0obVNpemUsIEMyX1BBUkFNS0VZX1BJQ1RVUkVfU0laRSkKLSAgICAgICAgICAgICAgICAud2l0aERlZmF1bHQobmV3IEMyU3RyZWFtUGljdHVyZVNpemVJbmZvOjppbnB1dCgwdSwgMzIwLCAyNDApKQorICAgICAgICAgICAgICAgIC53aXRoRGVmYXVsdChuZXcgQzJTdHJlYW1QaWN0dXJlU2l6ZUluZm86OmlucHV0KDB1LCA2NCwgNjQpKQogICAgICAgICAgICAgICAgIC53aXRoRmllbGRzKHsKICAgICAgICAgICAgICAgICAgICAgQzJGKG1TaXplLCB3aWR0aCkuaW5SYW5nZSgyLCAxOTIwLCAyKSwKICAgICAgICAgICAgICAgICAgICAgQzJGKG1TaXplLCBoZWlnaHQpLmluUmFuZ2UoMiwgMTA4OCwgMiksCkBAIC0xMzMsNyArMTMzLDcgQEAKIAogICAgICAgICBhZGRQYXJhbWV0ZXIoCiAgICAgICAgICAgICBEZWZpbmVQYXJhbShtRnJhbWVSYXRlLCBDMl9QQVJBTUtFWV9GUkFNRV9SQVRFKQotICAgICAgICAgICAgICAgIC53aXRoRGVmYXVsdChuZXcgQzJTdHJlYW1GcmFtZVJhdGVJbmZvOjpvdXRwdXQoMHUsIDMwLikpCisgICAgICAgICAgICAgICAgLndpdGhEZWZhdWx0KG5ldyBDMlN0cmVhbUZyYW1lUmF0ZUluZm86Om91dHB1dCgwdSwgMS4pKQogICAgICAgICAgICAgICAgIC53aXRoRmllbGRzKHtDMkYobUZyYW1lUmF0ZSwgdmFsdWUpLmdyZWF0ZXJUaGFuKDAuKX0pCiAgICAgICAgICAgICAgICAgLndpdGhTZXR0ZXIoCiAgICAgICAgICAgICAgICAgICAgIFNldHRlcjxkZWNsdHlwZSgqbUZyYW1lUmF0ZSk+OjpTdHJpY3RWYWx1ZVdpdGhOb0RlcHMpCkBAIC0yNDUsNiArMjQ1LDE5IEBACiAgICAgICAgICAgICAgICAgfSkKICAgICAgICAgICAgICAgICAud2l0aFNldHRlcihDb2RlZENvbG9yQXNwZWN0c1NldHRlciwgbUNvbG9yQXNwZWN0cykKICAgICAgICAgICAgICAgICAuYnVpbGQoKSk7CisKKyAgICAgICAgYWRkUGFyYW1ldGVyKAorICAgICAgICAgICAgICAgIERlZmluZVBhcmFtKG1QaWN0dXJlUXVhbnRpemF0aW9uLCBDMl9QQVJBTUtFWV9QSUNUVVJFX1FVQU5USVpBVElPTikKKyAgICAgICAgICAgICAgICAud2l0aERlZmF1bHQoQzJTdHJlYW1QaWN0dXJlUXVhbnRpemF0aW9uVHVuaW5nOjpvdXRwdXQ6OkFsbG9jU2hhcmVkKAorICAgICAgICAgICAgICAgICAgICAgICAgMCAvKiBmbGV4Q291bnQgKi8sIDB1IC8qIHN0cmVhbSAqLykpCisgICAgICAgICAgICAgICAgLndpdGhGaWVsZHMoe0MyRihtUGljdHVyZVF1YW50aXphdGlvbiwgbS52YWx1ZXNbMF0udHlwZV8pLm9uZU9mKAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7QzJDb25maWc6OnBpY3R1cmVfdHlwZV90KElfRlJBTUUpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEMyQ29uZmlnOjpwaWN0dXJlX3R5cGVfdChQX0ZSQU1FKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDMkNvbmZpZzo6cGljdHVyZV90eXBlX3QoQl9GUkFNRSl9KSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQzJGKG1QaWN0dXJlUXVhbnRpemF0aW9uLCBtLnZhbHVlc1swXS5taW4pLmFueSgpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDMkYobVBpY3R1cmVRdWFudGl6YXRpb24sIG0udmFsdWVzWzBdLm1heCkuYW55KCl9KQorICAgICAgICAgICAgICAgIC53aXRoU2V0dGVyKFBpY3R1cmVRdWFudGl6YXRpb25TZXR0ZXIpCisgICAgICAgICAgICAgICAgLmJ1aWxkKCkpOwogICAgIH0KIAogICAgIHN0YXRpYyBDMlIgSW5wdXREZWxheVNldHRlcigKQEAgLTQ2NCw5ICs0NzcsNjkgQEAKICAgICAgICAgbWUuc2V0KCkubWF0cml4ID0gY29kZWQudi5tYXRyaXg7CiAgICAgICAgIHJldHVybiBDMlI6Ok9rKCk7CiAgICAgfQorICAgIHN0YXRpYyBDMlIgUGljdHVyZVF1YW50aXphdGlvblNldHRlcihib29sIG1heUJsb2NrLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDMlA8QzJTdHJlYW1QaWN0dXJlUXVhbnRpemF0aW9uVHVuaW5nOjpvdXRwdXQ+ICZtZSkgeworICAgICAgICAodm9pZCltYXlCbG9jazsKKworICAgICAgICAvLyB0aGVzZSBhcmUgdGhlIG9uZXMgd2UncmUgZ29pbmcgdG8gc2V0LCBzbyB3YW50IHRoZW0gdG8gZGVmYXVsdAorICAgICAgICAvLyB0byB0aGUgREVGQVVMVCB2YWx1ZXMgZm9yIHRoZSBjb2RlYworICAgICAgICBpbnQzMl90IGlNaW4gPSBIRVZDX1FQX01JTiwgcE1pbiA9IEhFVkNfUVBfTUlOLCBiTWluID0gSEVWQ19RUF9NSU47CisgICAgICAgIGludDMyX3QgaU1heCA9IEhFVkNfUVBfTUFYLCBwTWF4ID0gSEVWQ19RUF9NQVgsIGJNYXggPSBIRVZDX1FQX01BWDsKKworICAgICAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IG1lLnYuZmxleENvdW50KCk7ICsraSkgeworICAgICAgICAgICAgY29uc3QgQzJQaWN0dXJlUXVhbnRpemF0aW9uU3RydWN0ICZsYXllciA9IG1lLnYubS52YWx1ZXNbaV07CisKKyAgICAgICAgICAgIC8vIGxheWVyTWluIGlzIGNsYW1wZWQgdG8gW0hFVkNfUVBfTUlOLCBsYXllck1heF0gdG8gYXZvaWQgZXJyb3IKKyAgICAgICAgICAgIC8vIGNhc2VzIHdoZXJlIGxheWVyLm1pbiA+IGxheWVyLm1heAorICAgICAgICAgICAgaW50MzJfdCBsYXllck1heCA9IHN0ZDo6Y2xhbXAobGF5ZXIubWF4LCBIRVZDX1FQX01JTiwgSEVWQ19RUF9NQVgpOworICAgICAgICAgICAgaW50MzJfdCBsYXllck1pbiA9IHN0ZDo6Y2xhbXAobGF5ZXIubWluLCBIRVZDX1FQX01JTiwgbGF5ZXJNYXgpOworICAgICAgICAgICAgaWYgKGxheWVyLnR5cGVfID09IEMyQ29uZmlnOjpwaWN0dXJlX3R5cGVfdChJX0ZSQU1FKSkgeworICAgICAgICAgICAgICAgIGlNYXggPSBsYXllck1heDsKKyAgICAgICAgICAgICAgICBpTWluID0gbGF5ZXJNaW47CisgICAgICAgICAgICAgICAgQUxPR1YoImlNaW4gJWQgaU1heCAlZCIsIGlNaW4sIGlNYXgpOworICAgICAgICAgICAgfSBlbHNlIGlmIChsYXllci50eXBlXyA9PSBDMkNvbmZpZzo6cGljdHVyZV90eXBlX3QoUF9GUkFNRSkpIHsKKyAgICAgICAgICAgICAgICBwTWF4ID0gbGF5ZXJNYXg7CisgICAgICAgICAgICAgICAgcE1pbiA9IGxheWVyTWluOworICAgICAgICAgICAgICAgIEFMT0dWKCJwTWluICVkIHBNYXggJWQiLCBwTWluLCBwTWF4KTsKKyAgICAgICAgICAgIH0gZWxzZSBpZiAobGF5ZXIudHlwZV8gPT0gQzJDb25maWc6OnBpY3R1cmVfdHlwZV90KEJfRlJBTUUpKSB7CisgICAgICAgICAgICAgICAgYk1heCA9IGxheWVyTWF4OworICAgICAgICAgICAgICAgIGJNaW4gPSBsYXllck1pbjsKKyAgICAgICAgICAgICAgICBBTE9HVigiYk1pbiAlZCBiTWF4ICVkIiwgYk1pbiwgYk1heCk7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKworICAgICAgICBBTE9HVigiUGljdHVyZVF1YW50aXphdGlvblNldHRlcihlbnRyeSk6IGkgJWQtJWQgcCAlZC0lZCBiICVkLSVkIiwKKyAgICAgICAgICAgICAgaU1pbiwgaU1heCwgcE1pbiwgcE1heCwgYk1pbiwgYk1heCk7CisKKyAgICAgICAgaW50MzJfdCBtYXhGcmFtZVFQID0gc3RkOjptaW4oc3RkOjptaW4oaU1heCwgcE1heCksIGJNYXgpOworICAgICAgICBpbnQzMl90IG1pbkZyYW1lUVAgPSBzdGQ6Om1heChzdGQ6Om1heChpTWluLCBwTWluKSwgYk1pbik7CisgICAgICAgIGlmIChtaW5GcmFtZVFQID4gbWF4RnJhbWVRUCkgeworICAgICAgICAgICAgbWluRnJhbWVRUCA9IG1heEZyYW1lUVA7CisgICAgICAgIH0KKworICAgICAgICAvLyBwdXQgdGhlbSBiYWNrIGludG8gdGhlIHN0cnVjdHVyZQorICAgICAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IG1lLnYuZmxleENvdW50KCk7ICsraSkgeworICAgICAgICAgICAgY29uc3QgQzJQaWN0dXJlUXVhbnRpemF0aW9uU3RydWN0ICZsYXllciA9IG1lLnYubS52YWx1ZXNbaV07CisKKyAgICAgICAgICAgIGlmIChsYXllci50eXBlXyA9PSBDMkNvbmZpZzo6cGljdHVyZV90eXBlX3QoSV9GUkFNRSkgfHwKKyAgICAgICAgICAgICAgICBsYXllci50eXBlXyA9PSBDMkNvbmZpZzo6cGljdHVyZV90eXBlX3QoUF9GUkFNRSkgfHwKKyAgICAgICAgICAgICAgICBsYXllci50eXBlXyA9PSBDMkNvbmZpZzo6cGljdHVyZV90eXBlX3QoQl9GUkFNRSkpIHsKKyAgICAgICAgICAgICAgICBtZS5zZXQoKS5tLnZhbHVlc1tpXS5tYXggPSBtYXhGcmFtZVFQOworICAgICAgICAgICAgICAgIG1lLnNldCgpLm0udmFsdWVzW2ldLm1pbiA9IG1pbkZyYW1lUVA7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKworICAgICAgICBBTE9HVigi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isgICAgICAgIG1RcEJvdW5kcyA9IG1JbnRmLT5nZXRQaWN0dXJlUXVhbnRpemF0aW9uX2woKTs7CiAgICAgfQogCiAgICAgYzJfc3RhdHVzX3Qgc3RhdHVzID0gaW5pdEVuY1BhcmFtcygpOwpAQCAtNzk4LDcgKzkwMSw4IEBACiAgICAgICAgICAgICB5U3RyaWRlID0gd2lkdGg7CiAgICAgICAgICAgICB1U3RyaWRlID0gdlN0cmlkZSA9IHlTdHJpZGUgLyAyOwogICAgICAgICAgICAgQ29udmVydFJHQlRvUGxhbmFyWVVWKHlQbGFuZSwgeVN0cmlkZSwgaGVpZ2h0LAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnZlcnNpb25CdWZmZXIuc2l6ZSgpLCAqaW5wdXQpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnZlcnNpb25CdWZmZXIuc2l6ZSgpLCAqaW5wdXQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNvbG9yQXNwZWN0cy0+bWF0cml4LCBtQ29sb3JBc3BlY3RzLT5yYW5nZSk7CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogICAgICAgICBjYXNlIEMyUGxhbmFyTGF5b3V0OjpUWVBFX1lVVjogewpAQCAtMTA5OSwxMSArMTIwMywxMSBAQAogICAgICAgICB9CiAgICAgfQogCi0gICAgdWludDY0X3QgdGltZURlbGF5ID0gMDsKLSAgICB1aW50NjRfdCB0aW1lVGFrZW4gPSAwOworICAgIG5zZWNzX3QgdGltZURlbGF5ID0gMDsKKyAgICBuc2Vjc190IHRpbWVUYWtlbiA9IDA7CiAgICAgbWVtc2V0KCZzX2VuY29kZV9vcCwgMCwgc2l6ZW9mKHNfZW5jb2RlX29wKSk7Ci0gICAgR0VUVElNRSgmbVRpbWVTdGFydCwgbnVsbHB0cik7Ci0gICAgVElNRV9ESUZGKG1UaW1lRW5kLCBtVGltZVN0YXJ0LCB0aW1lRGVsYXkp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gIGMyX3N0YXR1c190IGluaXRFbmNQYXJhbXMoKTsKICAgICBjMl9zdGF0dXNfdCBpbml0RW5jb2RlcigpOwpAQCAtMTIxLDE0ICsxMjAsMTIgQEAKICNkZWZpbmUgT1VUUFVUX0RVTVBfRVhUICJoMjY1IgogI2RlZmluZSBHRU5FUkFURV9GSUxFX05BTUVTKCkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCiB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKLSAgICBHRVRUSU1FKCZtVGltZVN0YXJ0LCBOVUxMKTsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAotICAgIHN0cmNweShtSW5GaWxlLCAiIik7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgbnNlY3NfdCBub3cgPSBzeXN0ZW1UaW1lKCk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKICAgICBBTE9HRCgiR0VORVJBVEVfRklMRV9OQU1FUyIpOyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAotICAgIHNwcmludGYobUluRmlsZSwgIiVzXyVsZC4lbGQuJXMiLCBJTlBVVF9EVU1QX1BBVEgsIG1UaW1lU3RhcnQudHZfc2VjLCBcCi0gICAgICAgICAgICBtVGltZVN0YXJ0LnR2X3VzZWMsIElOUFVUX0RVTVBfRVhUKTsgICAgICAgICAgICAgICAgICAgICAgICAgIFwKLSAgICBzdHJjcHkobU91dEZpbGUsICIiKTsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAotICAgIHNwcmludGYobU91dEZpbGUsICIlc18lbGQuJWxkLiVzIiwgT1VUUFVUX0RVTVBfUEFUSCwgICAgICAgICAgICAgICAgICBcCi0gICAgICAgICAgICBt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BTUVTKCkgeyAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgICAgIEdFVFRJTUUoJm1UaW1lU3RhcnQsIE5VTEwpOyAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgICAgIHN0cmNweShtSW5GaWxlLCAiIik7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgICAgIHNwcmludGYobUluRmlsZSwgIiVzXyVsZC4lbGQuJXMiLCBJTlBVVF9EVU1QX1BBVEgsICBcCi0gICAgICAgICAgICAgICAgbVRpbWVTdGFydC50dl9zZWMsIG1UaW1lU3RhcnQudHZfdXNlYywgICAgICBcCisgICAgICAgIG5zZWNzX3Qgbm93ID0gc3lzdGVtVGltZSgpOyAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgIHNwcmludGYobUluRmlsZSwgIiVzXyUiIFBSSWQ2NCAiLiVzIiwgICAgICAgICAgICAgICBcCisgICAgICAgICAgICAgICAgSU5QVVRfRFVNUF9QQVRILCBub3csICAgICAgICAgICAgICAgICAgICAgICBcCiAgICAgICAgICAgICAgICAgSU5QVVRfRFVNUF9FWFQpOyAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCiAgICAgfQogICAgICNkZWZpbmUgQ1JFQVRFX0RVTVBfRklMRShtX2ZpbGVuYW1lKSB7ICAgICAgICAgICAgICAgICAgXApAQCAtMTgzLDggKzE3OSw4IEBACiAgICAgfSBtQml0c3RyZWFtQ29sb3JBc3BlY3RzOwogCiAgICAgLy8gcHJvZmlsZQotICAgIHN0cnVjdCB0aW1ldmFsIG1UaW1lU3RhcnQ7Ci0gICAgc3RydWN0IHRpbWV2YWwgbVRpbWVFbmQ7CisgICAgbnNlY3NfdCBtVGltZVN0YXJ0ID0gMDsKKyAgICBuc2Vjc190IG1UaW1lRW5kID0gMDsKICNpZmRlZiBGSUxFX0RVTVBfRU5BQkxFCiAgICAgY2hhciBtSW5GaWxlWzIwMF07CiAjZW5kaWYgLyogRklMRV9EVU1QX0VO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AgIHJldHVybjsKICAgICAgICAgfQogCi0gICAgICAgIHVpbnQzMl90IHlGcmFtZVNpemUgPSBzaXplb2YodWludDgpICogbURlY0hhbmRsZS0+c2l6ZTsKKyAgICAgICAgdWludDMyX3QgeUZyYW1lU2l6ZSA9IHNpemVvZih1aW50OCkgKiBtVmlkZW9EZWNDb250cm9scy5zaXplOwogICAgICAgICBpZiAobU91dHB1dEJ1ZmZlclNpemUgPCB5RnJhbWVTaXplICogMyAvIDIpewogICAgICAgICAgICAgQUxPR0UoIlRvbyBzbWFsbCBvdXRwdXQgYnVmZmVyOiAlenUgYnl0ZXMiLCBtT3V0cHV0QnVmZmVyU2l6ZSk7CiAgICAgICAgICAgICBtU2lnbmFsbGVkRXJyb3IgPSB0cnVlOwpAQCAtNTk5LDcgKzU0MCw3IEBACiAgICAgICAgIH0KIAogICAgICAgICBpZiAoIW1GcmFtZXNDb25maWd1cmVkKSB7Ci0gICAgICAgICAgICBQVlNldFJlZmVyZW5jZVlVVihtRGVjSGFuZGxlLG1PdXRwdXRCdWZmZXJbMV0pOworICAgICAgICAgICAgUFZTZXRSZWZlcmVuY2VZVVYoJm1WaWRlb0RlY0NvbnRyb2xzLG1PdXRwdXRCdWZmZXJbMV0pOwogICAgICAgICAgICAgbUZyYW1lc0NvbmZpZ3VyZWQgPSB0cnVlOwogICAgICAgICB9CiAKQEAgLTYxMCw3ICs1NTEsNyBAQAogICAgICAgICB1aW50OF90ICpiaXRzdHJlYW1UbXAgPSBiaXRzdHJlYW07CiAgICAgICAgIHVpbnQzMl90IHRpbWVzdGFtcCA9IHdvcmtJbmRleDsKICAgICAgICAgaWYgKFBWRGVjb2RlVm9wSGVhZGVyKAotICAgICAgICAgICAgICAgICAgICBtRGVjSGFuZGxlLCAmYml0c3RyZWFtVG1wLCAmdGltZXN0YW1wLCAmdG1wSW5TaXplLAorICAgICAgICAgICAgICAgICAgICAmbVZpZGVvRGVjQ29udHJvbHMsICZiaXRzdHJlYW1UbXAsICZ0aW1lc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sIG91dHB1dEJ1ZmZlclYsCi0gICAgICAgICAgICAgICAgbU91dHB1dEJ1ZmZlclttTnVtU2FtcGxlc091dHB1dCAmIDFdLAotICAgICAgICAgICAgICAgIGRzdFlTdHJpZGUsIGRzdFVWU3RyaWRlLAotICAgICAgICAgICAgICAgIGFsaWduKG1XaWR0aCwgMTYpLCBtV2lkdGgsIG1IZWlnaHQpOworICAgICAgICBzaXplX3Qgc3JjWVN0cmlkZSA9IGFsaWduKG1XaWR0aCwgMTYpOworICAgICAgICBzaXplX3Qgc3JjVVN0cmlkZSA9IHNyY1lTdHJpZGUgLyAyOworICAgICAgICBzaXplX3Qgc3JjVlN0cmlkZSA9IHNyY1lTdHJpZGUgLyAyOworICAgICAgICBzaXplX3QgdlN0cmlkZSA9IGFsaWduKG1IZWlnaHQsIDE2KTsKKyAgICAgICAgY29uc3QgdWludDhfdCAqc3JjWSA9IChjb25zdCB1aW50OF90ICopbU91dHB1dEJ1ZmZlclttTnVtU2FtcGxlc091dHB1dCAmIDFdOworICAgICAgICBjb25zdCB1aW50OF90ICpzcmNVID0gKGNvbnN0IHVpbnQ4X3QgKilzcmNZICsgdlN0cmlkZSAqIHNyY1lTdHJpZGU7CisgICAgICAgIGNvbnN0IHVpbnQ4X3QgKnNyY1YgPSAoY29uc3QgdWludDhfdCAqKXNyY1kgKyB2U3RyaWRlICogc3JjWVN0cmlkZSAqIDUgLyA0OworCisgICAgICAgIGNvbnZlcnRZVVY0MjBQbGFuYXI4VG9ZVjEyKG91dHB1dEJ1ZmZlclksIG91dHB1dEJ1ZmZlclUsIG91dHB1dEJ1ZmZlclYsIHNyY1ksIHNyY1UsIHNyY1YsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNyY1lTdHJpZGUsIHNyY1VTdHJpZGUsIHNyY1ZTdHJpZGUsIGRzdFlTdHJpZGUsIGRzdFVWU3RyaWRlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtV2lkdGgsIG1IZW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LAogICAgIHNyY3M6IFsKICAgICAgICAgIkMyU29mdENvZGVjVGVzdC5jcHAiLAogICAgIF0sCiAKLSAgICBzdGF0aWNfbGliczogWwotICAgICAgICAibGlibG9nIiwKLSAgICAgICAgImxpYmlvbiIsCi0gICAgICAgICJsaWJmbXEiLAotICAgICAgICAibGliYmFzZSIsCi0gICAgICAgICJsaWJ1dGlscyIsCi0gICAgICAgICJsaWJjdXRpbHMiLAotICAgICAgICAibGliY29kZWMyIiwKLSAgICAgICAgImxpYmhpZGxiYXNlIiwKLSAgICAgICAgImxpYmRtYWJ1ZmhlYXAiLAotICAgICAgICAibGliY29kZWMyX3ZuZGsiLAotICAgICAgICAibGlibmF0aXZld2luZG93IiwKLSAgICAgICAgImxpYmNvZGVjMl9zb2Z0X2NvbW1vbiIsCi0gICAgICAgICJsaWJzZnBsdWdpbl9jY29kZWNfdXRpbHMiLAotICAgICAgICAibGlic3RhZ2VmcmlnaHRfZm91bmRhdGlvbiIsCi0gICAgICAgICJsaWJzdGFnZWZyaWdodF9idWZmZXJwb29sQDIuMC4xIiwKLSAgICAgICAgImFuZHJvaWQuaGFyZHdhcmUuZ3JhcGhpY3MubWFwcGVyQDIuMCIsCi0gICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLmdyYXBoaWNzLm1hcHBlckAzLjAiLAotICAgICAgICAiYW5kcm9pZC5oYXJkd2FyZS5tZWRpYS5idWZmZXJwb29sQDIuMCIsCi0gICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLmdyYXBoaWNzLmFsbG9jYXRvckAyLjAiLAotICAgICAgICAiYW5kcm9pZC5oYXJkd2FyZS5ncmFwaGljcy5hbGxvY2F0b3JAMy4wIiwKLSAgICAgICAgImFuZHJvaWQuaGFyZHdhcmUuZ3JhcGhpY3MuYnVmZmVycXVldWVAMi4wIiwKLSAgICBdLAotCi0gICAgc2hhcmVkX2xpYnM6IFsKLSAgICAgICAgImxpYnVpIiwKLSAgICAgICAgImxpYmRsIiwKLSAgICAgIC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ZWwsIEMyX1BBUkFNS0VZX1BST0ZJTEVfTEVWRUwpCi0gICAgICAgICAgICAgICAgLndpdGhDb25zdFZhbHVlKG5ldyBDMlN0cmVhbVByb2ZpbGVMZXZlbEluZm86OmlucHV0KDB1LAotICAgICAgICAgICAgICAgICAgICAgICAgQzJDb25maWc6OlBST0ZJTEVfVU5VU0VELCBDMkNvbmZpZzo6TEVWRUxfVU5VU0VEKSkKKyAgICAgICAgICAgICAgICAud2l0aERlZmF1bHQobmV3IEMyU3RyZWFtUHJvZmlsZUxldmVsSW5mbzo6aW5wdXQoMHUsCisgICAgICAgICAgICAgICAgICAgICAgICBDMkNvbmZpZzo6UFJPRklMRV9WUDhfMCwgQzJDb25maWc6OkxFVkVMX1VOVVNFRCkpCisgICAgICAgICAgICAgICAgLndpdGhGaWVsZHMoeworICAgICAgICAgICAgICAgICAgICBDMkYobVByb2ZpbGVMZXZlbCwgcHJvZmlsZSkuZXF1YWxUbygKKyAgICAgICAgICAgICAgICAgICAgICAgIFBST0ZJTEVfVlA4XzAKKyAgICAgICAgICAgICAgICAgICAgKSwKKyAgICAgICAgICAgICAgICAgICAgQzJGKG1Qcm9maWxlTGV2ZWwsIGxldmVsKS5lcXVhbFRvKAorICAgICAgICAgICAgICAgICAgICAgICAgTEVWRUxfVU5VU0VEKSwKKyAgICAgICAgICAgICAgICB9KQorICAgICAgICAgICAgICAgIC53aXRoU2V0dGVyKFByb2ZpbGVMZXZlbFNldHRlciwgbVNpemUpCiAgICAgICAgICAgICAgICAgLmJ1aWxkKCkpOwogI2VuZGlmCiAKQEAgLTIwOSwxMSArMjE4LDI0IEBACiAgICAgICAgICAgICAgICAgLmJ1aWxkKCkpOwogCiAgICAgICAgIC8vIFRPRE86IHN1cHBvcnQgbW9yZSBmb3JtYXRzPworICAgICAgICBzdGQ6OnZlY3Rvcjx1aW50MzJfdD4gcGl4ZWxGb3JtYXRzID0ge0hBTF9QSVhFTF9GT1JNQVRfWUNCQ1JfNDIwXzg4OH07Cis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ICAgICAgICAgICAgICB3aWR0aCA9IG1XaWR0aCwgaGVpZ2h0ID0gc3RkOjptaW4obUhlaWdodCAtIGksIGtIZWlnaHQpXSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udmVydFlVVjQyMFBsYW5hcjE2VG9ZNDEwKAorICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoID0gbVdpZHRoLCBoZWlnaHQgPSBzdGQ6Om1pbihtSGVpZ2h0IC0gaSwga0hlaWdodCksCisgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdENvbG9yQXNwZWN0c10geworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnZlcnRZVVY0MjBQbGFuYXIxNlRvWTQxME9yUkdCQTEwMTAxMDIoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAodWludDMyX3QgKilkc3RZLCBzcmNZLCBzcmNVLCBzcmNWLCBzcmNZU3RyaWRlIC8gMiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNyY1VTdHJpZGUgLyAyLCBzcmNWU3RyaWRlIC8gMiwgZHN0WVN0cmlkZSAvIHNpemVvZih1aW50MzJfdCksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCwgaGVpZ2h0KTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLCBoZWlnaHQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGQ6OnN0YXRpY19wb2ludGVyX2Nhc3Q8Y29uc3QgQzJDb2xvckFzcGVjdHNTdHJ1Y3Q+KAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0Q29sb3JBc3BlY3RzKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICBzcmNZICs9IHNyY1lTdHJpZGUgLyAyICoga0hlaWdodDsKICAgICAgICAgICAgICAgICBzcmNVICs9IHNyY1VTdHJpZGUgLyAyICogKGtIZWlnaHQgLyAyKTsKQEAgLTg1OSwyNCArNzk2LDIyIEBACiAgICAgICAgICAgICAgICAgcXVldWUtPmNvbmQuc2lnbmFsKCk7CiAgICAgICAgICAgICAgICAgcXVldWUud2FpdEZvckNvbmRpdGlvbihxdWV1ZS0+Y29uZCk7CiAgICAgICAgICAgICB9CisgICAgICAgIH0gZWxzZSBpZiAoZm9ybWF0ID09IEhBTF9QSVhFTF9GT1JNQVRfWUNCQ1JfUDAxMCkgeworICAgICAgICAgICAgY29udmVydFlVVjQyMFBsYW5hcjE2VG9QMDEwKCh1aW50MTZfdCAqKWRzdFksICh1aW50MTZfdCAqKWRzdFUsIHNyY1ksIHNyY1UsIHNyY1YsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3JjWVN0cmlkZSAvIDIsIHNyY1VTdHJpZGUgLyAyLCBzcmNWU3RyaWRlIC8gMiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkc3RZU3RyaWRlIC8gMiwgZHN0VVZTdHJpZGUgLyAyLCBtV2lkdGgsIG1IZWlnaHQpOwogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgY29udmVydFlVVjQyMFBsYW5hcjE2VG9ZVVY0MjBQbGFuYXIoZHN0WSwgZHN0VSwgZHN0ViwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNyY1ksIHNyY1UsIHNyY1YsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcmNZU3RyaWRlIC8gMiwgc3JjVVN0cmlkZSAvIDIsIHNyY1ZTdHJpZGUgLyAyLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZHN0WVN0cmlkZSwgZHN0VVZTdHJpZGUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC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MoKTsKKyAgICBub091dHB1dFJlZmVyZW5jZXMoKTsKKyAgICBub0lucHV0TGF0ZW5jeSgpOworICAgIG5vVGltZVN0cmV0Y2goKTsKKyAgICBzZXREZXJpdmVkSW5zdGFuY2UodGhpcyk7CisKKyAgICBhZGRQYXJhbWV0ZXIoCisgICAgICAgICAgICBEZWZpbmVQYXJhbShtQXR0cmliLCBDMl9QQVJBTUtFWV9DT01QT05FTlRfQVRUUklCVVRFUykKKyAgICAgICAgICAgIC53aXRoQ29uc3RWYWx1ZShuZXcgQzJDb21wb25lbnRBdHRyaWJ1dGVzU2V0dGluZygKKyAgICAgICAgICAgICAgICBDMkNvbXBvbmVudDo6QVRUUklCX0lTX1RFTVBPUkFMKSkKKyAgICAgICAgICAgIC5idWlsZCgpKTsKKworICAgIGFkZFBhcmFtZXRlcigKKyAgICAgICAgICAgIERlZmluZVBhcmFtKG1Vc2FnZSwgQzJfUEFSQU1LRVlfSU5QVVRfU1RSRUFNX1VTQUdFKQorICAgICAgICAgICAgLndpdGhDb25zdFZhbHVlKG5ldyBDMlN0cmVhbVVzYWdlVHVuaW5nOjppbnB1dCgKKyAgICAgICAgICAgICAgICAgICAgMHUsICh1aW50NjRfdClDMk1lbW9yeVVzYWdlOjpDUFVfUkVBRCkpCisgICAgICAgICAgICAuYnVpbGQoKSk7CisKKyAgICBhZGRQYXJhbWV0ZXIoCisgICAgICAgIERlZmluZVBhcmFtKG1TaXplLCBDMl9QQVJBTUtFWV9QSUNUVVJFX1NJWkUpCisgICAgICAgICAgICAud2l0aERlZmF1bHQobmV3IEMyU3RyZWFtUGljdHVyZVNpemVJbmZvOjppbnB1dCgwdSwgMzIwLCAyNDApKQorICAgICAgICAgICAgLndpdGhGaWVsZHMoeworICAgICAgICAgICAgICAgIEMyRihtU2l6ZSwgd2lkdGgpLmluUmFuZ2UoMiwgMjA0OCwgMiksCisgICAgICAgICAgICAgICAgQzJGKG1TaXplLCBoZWlnaHQpLmluUmFuZ2UoMiwgMjA0OCwgMiksCisgICAgICAgICAgICB9KQorICAgICAgICAgICAgLndpdGhTZXR0ZXIoU2l6ZVNldHRlcikKKyAgICAgICAgICAgIC5idWlsZCgpKTsKKworICAgIGFkZFBhcmFtZXRlcigKKyAgICAgICAgRGVmaW5lUGFyYW0obUJpdHJhdGVNb2RlLCBDMl9QQVJBTUtFWV9CSVRSQVRFX01PREUpCisgICAgICAgICAgICAud2l0aERlZmF1bHQobmV3IEMyU3RyZWFtQml0cmF0ZU1vZGVUdW5pbmc6Om91dHB1dCgKKyAgICAgICAgICAgICAgICAgICAgMHUsIEMyQ29uZmlnOjpCSVRSQVRFX1ZBUklBQkxFKSkKKyAgICAgICAgICAgIC53aXRoRmllbGRzKHsKKyAgICAgICAgICAgICAgICBDMkYobUJpdHJhdGVNb2RlLCB2YWx1ZSkub25lT2YoeworICAgICAgICAgICAgICAgICAgICBDMkNvbmZpZzo6QklUUkFURV9DT05TVCwgQzJDb25maWc6OkJJVFJBVEVfVkFSSUFCTEUgfSkKKyAgICAgICAgICAgIH0pCisgICAgICAgICAgICAud2l0aFNldHRlcigKKyAgICAgICAgICAgICAgICBTZXR0ZXI8ZGVjbHR5cGUoKm1CaXRyYXRlTW9kZSk+OjpTdHJpY3RWYWx1ZVdpdGhOb0RlcHMpCisgICAgICAgICAgICAuYnVpbGQoKSk7CisKKyAgICBhZGRQYXJhbWV0ZXIoCisgICAgICAgIERlZmluZVBhcmFtKG1GcmFtZVJhdGUsIEMyX1BBUkFNS0VZX0ZSQU1FX1JBVEUpCisgICAgICAgICAgICAud2l0aERlZmF1bHQobmV3IEMyU3RyZWFtRnJhbWVSYXRlSW5mbzo6b3V0cHV0KDB1LCAzMC4pKQorICAgICAgICAgICAgLy8gVE9ETzogTW9yZSByZXN0cmljdGlvbj8KKyAgICAgICAgICAgIC53aXRoRmllbGRzKHtDMkYobUZyYW1lUmF0ZSwgdmFsdWUpLmdyZWF0ZXJUaGFuKDAuKX0pCisgICAgICAgICAgICAud2l0aFNldHRlcigKKyAgICAgICAgICAgICAgICBTZXR0ZXI8ZGVjbHR5cGUoKm1GcmFtZVJhdGUpPjo6U3RyaWN0VmFsdWVXaXRoTm9EZXBzKQorICAgICAgICAgICAgLmJ1aWxkKCkpOworCisgICAgYWRkUGFyYW1ldGVyKAorICAgICAgICBEZWZpbmVQYXJhbShtTGF5ZXJpbmcsIEMyX1BBUkFNS0VZX1RFTVBPUkFMX0xBWUVSSU5HKQorICAgICAgICAgICAgLndpdGhEZWZhdWx0KEMyU3RyZWFtVGVtcG9yYWxMYXllcmluZ1R1bmluZzo6b3V0cHV0OjpBbGxvY1NoYXJlZCgwdSwgMCwgMCwgMCkpCisgICAgICAgICAgICAud2l0aEZpZWxkcyh7CisgICAgICAgICAgICAgICAgQzJGKG1MYXllcmluZywgbS5sYXllckNvdW50KS5pblJhbmdlKDAsIDQpLAorICAgICAgICAgICAgICAgIEMyRihtTGF5ZXJpbmcsIG0uYkxheWVyQ291bnQpLmluUmFuZ2UoMCwgMCksCisgICAgICAgICAgICAgICAgQzJGKG1MYXllcmluZywgbS5iaXRyYXRlUmF0aW9zKS5pblJhbmdlKDAuLCAxLikKKyAgICAgICAgICAgIH0pCisgICAgICAgICAgICAud2l0aFNldHRlcihMYXllcmluZ1NldHRlcikKKyAgICAgICAgICAgIC5idWlsZCgpKTsKKworICAgIGFkZFBhcmFtZXRlcigKKyAgICAgICAgICAgIERlZmluZVBhcmFtKG1TeW5jRnJhbWVQZXJpb2QsIEMyX1BBUkFNS0VZX1NZTkNfRlJBTUVfSU5URVJWQUwpCisgICAgICAgICAgICAud2l0aERlZmF1bHQobmV3IEMyU3RyZWFtU3luY0ZyYW1lSW50ZXJ2YWxUdW5pbmc6Om91dHB1dCgwdSwgMTAwMDAwMCkpCisgICAgICAgICAgICAud2l0aEZpZWxkcyh7QzJGKG1TeW5jRnJhbWVQZXJpb2QsIHZhbHVlKS5hbnkoKX0pCisgICAgICAgICAgICAud2l0aFNldHRlcihTZXR0ZXI8ZGVjbHR5cG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mllbGRzKHsKKyAgICAgICAgICAgICAgICBDMkYobVByb2ZpbGVMZXZlbCwgcHJvZmlsZSkuZXF1YWxUbygKKyAgICAgICAgICAgICAgICAgICAgUFJPRklMRV9WUDlfMAorICAgICAgICAgICAgICAgICksCisgICAgICAgICAgICAgICAgQzJGKG1Qcm9maWxlTGV2ZWwsIGxldmVsKS5lcXVhbFRvKAorICAgICAgICAgICAgICAgICAgICBMRVZFTF9WUDlfNF8xKSwKKyAgICAgICAgICAgIH0pCisgICAgICAgICAgICAud2l0aFNldHRlcihQcm9maWxlTGV2ZWxTZXR0ZXIpCisgICAgICAgICAgICAuYnVpbGQoKSk7CisjZWxzZQorICAgIGFkZFBhcmFtZXRlcigKKyAgICAgICAgICAgIERlZmluZVBhcmFtKG1Qcm9maWxlTGV2ZWwsIEMyX1BBUkFNS0VZX1BST0ZJTEVfTEVWRUwpCisgICAgICAgICAgICAud2l0aERlZmF1bHQobmV3IEMyU3RyZWFtUHJvZmlsZUxldmVsSW5mbzo6b3V0cHV0KAorICAgICAgICAgICAgICAgICAgICAwdSwgUFJPRklMRV9WUDhfMCwgTEVWRUxfVU5VU0VEKSkKKyAgICAgICAgICAgIC53aXRoRmllbGRzKHsKKyAgICAgICAgICAgICAgICBDMkYobVByb2ZpbGVMZXZlbCwgcHJvZmlsZSkuZXF1YWxUbygKKyAgICAgICAgICAgICAgICAgICAgUFJPRklMRV9WUDhfMAorICAgICAgICAgICAgICAgICksCisgICAgICAgICAgICAgICAgQzJGKG1Qcm9maWxlTGV2ZWwsIGxldmVsKS5lcXVhbFRvKAorICAgICAgICAgICAgICAgICAgICBMRVZFTF9VTlVTRUQpLAorICAgICAgICAgICAgfSkKKyAgICAgICAgICAgIC53aXRoU2V0dGVyKFByb2ZpbGVMZXZlbFNldHRlcikKKyAgICAgICAgICAgIC5idWlsZCgpKTsKKyNlbmRpZgorICAgIGFkZFBhcmFtZXRlcigKKyAgICAgICAgICAgIERlZmluZVBhcmFtKG1SZXF1ZXN0U3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XMpLmluUmFuZ2UoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgQzJDb2xvcjo6UFJJTUFSSUVTX1VOU1BFQ0lGSUVELCBDMkNvbG9yOjpQUklNQVJJRVNfT1RIRVIpLAorICAgICAgICAgICAgICAgIEMyRihtQ29sb3JBc3BlY3RzLCB0cmFuc2ZlcikuaW5SYW5nZSgKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBDMkNvbG9yOjpUUkFOU0ZFUl9VTlNQRUNJRklFRCwgIEMyQ29sb3I6OlRSQU5TRkVSX09USEVSKSwKKyAgICAgICAgICAgICAgICBDMkYobUNvbG9yQXNwZWN0cywgbWF0cml4KS5pblJhbmdlKAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIEMyQ29sb3I6Ok1BVFJJWF9VTlNQRUNJRklFRCwgICAgQzJDb2xvcjo6TUFUUklYX09USEVSKQorICAgICAgICAgICAgfSkKKyAgICAgICAgICAgIC53aXRoU2V0dGVyKENvbG9yQXNwZWN0c1NldHRlcikKKyAgICAgICAgICAgIC5idWlsZCgpKTsKKworICAgIGFkZFBhcmFtZXRlcigKKyAgICAgICAgICAgIERlZmluZVBhcmFtKG1Db2RlZENvbG9yQXNwZWN0cywgQzJfUEFSQU1LRVlfVlVJX0NPTE9SX0FTUEVDVFMpCisgICAgICAgICAgICAud2l0aERlZmF1bHQobmV3IEMyU3RyZWFtQ29sb3JBc3BlY3RzSW5mbzo6b3V0cHV0KAorICAgICAgICAgICAgICAgICAgICAwdSwgQzJDb2xvcjo6UkFOR0VfTElNSVRFRCwgQzJDb2xvcjo6UFJJTUFSSUVTX1VOU1BFQ0lGSUVELAorICAgICAgICAgICAgICAgICAgICBDMkNvbG9yOjpUUkFOU0ZFUl9VTlNQRUNJRklFRCwgQzJDb2xvcjo6TUFUUklYX1VOU1BFQ0lGSUVEKSkKKyAgICAgICAgICAgIC53aXRoRmllbGRzKHsKKyAgICAgICAgICAgICAgICBDMkYobUNvZGVkQ29sb3JBc3BlY3RzLCByYW5nZSkuaW5SYW5nZSgKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBDMkNvbG9yOjpSQU5HRV9VTlNQRUNJRklFRCwgICAgIEMyQ29sb3I6OlJBTkdFX09USEVSKSwKKyAgICAgICAgICAgICAgICBDMkYobUNvZGVkQ29sb3JBc3BlY3RzLCBwcmltYXJpZXMpLmluUmFuZ2UoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgQzJDb2xvcjo6UFJJTUFSSUVTX1VOU1BFQ0lGSUVELCBDMkNvbG9yOjpQUklNQVJJRVNfT1RIRVIpLAorICAgICAgICAgICAgICAgIEMyRihtQ29kZWRDb2xvckFzcGVjdHMsIHRyYW5zZmVyKS5pblJhbmdlKAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIEMyQ29sb3I6OlRSQU5TRkVSX1VOU1BFQ0lGSUVELCAgQzJDb2xvcjo6VFJBTlNGRVJfT1RIRVIpLAorICAgICAgICAgICAgICAgIEMyRihtQ29kZWRDb2xvckFzcGVjdHMsIG1hdHJpeCkuaW5SYW5nZSgKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBDMkNvbG9yOjpNQVRSSVhfVU5TUEVDSUZJRUQsICAgIEMyQ29sb3I6Ok1BVFJJWF9PVEhFUikKKyAgICAgICAgICAgIH0pCisgICAgICAgICAgICAud2l0aFNldHRlcihDb2RlZENvbG9yQXNwZWN0c1NldHRlciwgbUNvbG9yQXNwZWN0cykKKyAgICAgICAgICAgIC5idWlsZCgpKTsKK30KKworQzJSIEMyU29mdFZweEVuYzo6SW50ZkltcGw6OkJpdHJhdGVTZXR0ZXIoYm9vbCBtYXlCbG9jaywgQzJQPEMyU3RyZWFtQml0cmF0ZUluZm86Om91dHB1dD4gJm1lKSB7CisgICAgKHZvaWQpbWF5QmxvY2s7CisgICAgQzJSIHJlcyA9IEMyUjo6T2soKTsKKyAgICBpZiAobWUudi52YWx1ZSA8IDQwOTYpIHsKKyAgICAgICAgbWUuc2V0KCkudmFsdWUgPSA0MDk2OworICAgIH0KKyAgICByZXR1cm4gcmVzOworfQorCitDMlIgQzJTb2Z0VnB4RW5jOjpJbnRmSW1wbDo6U2l6ZVNldHRlcihib29sIG1heUJsb2NrLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQzJQPEMyU3RyZWFtUGljdHVyZVNpemVJbmZvOjppbnB1dD4mIG9sZE1lLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQzJQPEMyU3RyZWFtUGljdHVyZVNpemVJbmZvOjppbnB1dD4mIG1lKSB7CisgICAgKHZvaWQpbWF5QmxvY2s7CisgICAgQzJSIHJlcyA9IEMyUjo6T2soKTsKKyAgICBpZiAoIW1lLkYobWUudi53aWR0aCkuc3VwcG9ydHNBdEFsbChtZS52LndpZHRoKSkgeworICAgICAgICByZXMgPSByZXMucGx1cyhDMlNldHRpbmdSZXN1bHRCdWlsZGVyOjpCYWRWYWx1ZShtZS5GKG1lLnYud2lkdGgpKSk7CisgICAgICAgIG1lLnNldCgpLndpZHRoID0gb2xkTWUudi53aWR0aDsKKyAgICB9CisgICAgaWYgKCFtZS5GKG1lLnYuaGVpZ2h0KS5zdXBwb3J0c0F0QWxsKG1lLnYuaGVpZ2h0KSkgeworICAgICAgICByZXMgPSByZXMucGx1cyhDMlNldHRpbmdSZXN1bHRCdWlsZGVyOjpCYWRWYWx1ZShtZS5GKG1lLnYuaGVpZ2h0KSkpOworICAgICAgICBtZS5zZXQoKS5oZWlnaHQgPSBvbGRNZS52LmhlaWdodDsKKyAgICB9CisgICAgcmV0dXJuIHJlczsKK30KKworQzJSIEMyU29mdFZweEVuYzo6SW50ZkltcGw6OlByb2ZpbGVMZXZlbFNldHRlcihib29sIG1heUJsb2NrLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDMlA8QzJTdHJlYW1Qcm9maWxlTGV2ZWxJbmZvOjpvdXRwdXQ+JiBtZSkgeworICAgICh2b2lkKW1heUJsb2NrOworICAgIGlmICghbWUuRihtZS52LnByb2ZpbGUpLnN1cHBvcnRzQXRBbGwobWUudi5wcm9maWxlKSkgeworICAgICAgICBtZS5zZXQoKS5wcm9maWxlID0gUFJPRklMRV9WUDlfMDsKKyAgICB9CisgICAgaWYgKCFtZS5GKG1lLnYubGV2ZWwpLnN1cHBvcnRzQXRBbGwobWUudi5sZXZlbCkpIHsKKyAgICAgICAgbWUuc2V0KCkubGV2ZWwgPSBMRVZFTF9WUDlfNF8xOworICAgIH0KKyAgICByZXR1cm4gQzJSOjpPaygpOworfQorCitDMlIgQzJTb2Z0VnB4RW5jOjpJbnRmSW1wbDo6TGF5ZXJpbmdTZXR0ZXIoYm9vbCBtYXlCbG9jaywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDMlA8QzJTdHJlYW1UZW1wb3JhbExheWVyaW5nVHVuaW5nOjpvdXRwdXQ+JiBtZSkgeworICAgICh2b2lkKW1heUJsb2NrOworICAgIEMyUiByZXMgPSBDMlI6Ok9rKCk7CisgICAgaWYgKG1lLnYubS5sYXllckNvdW50ID4gNCkgeworICAgICAgICBtZS5zZXQoKS5tLmxheWVyQ291bnQgPSA0OworICAgIH0KKyAgICBtZS5zZXQoKS5tLmJMYXllckNvdW50ID0gMDsKKyAgICAvLyBlbnN1cmUgcmF0aW9zIGFyZSBtb25vdG9uaWMgYW5kIGNsYW1wZWQgYmV0d2VlbiAwIGFuZCAxCisgICAgZm9yIChzaXplX3QgaXggPSAwOyBpeCA8IG1lLnYuZmxleENvdW50KCk7ICsraXgpIHsKKyAgICAgICAgbWUuc2V0KCkubS5iaXRyYXRlUmF0aW9zW2l4XSA9IGMyX2NsYW1wKAorICAgICAgICAgICAgaXggPiAwID8gbWUudi5tLmJpdHJhdGVSYXRpb3NbaXggLSAxXSA6IDAsIG1lLnYubS5iaXRyYXRlUmF0aW9zW2l4XSwgMS4pOworICAgIH0KKyAgICBBTE9HSSgic2V0d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Agc3RkOjpzaGFyZWRfcHRyPEMyU3RyZWFtQ29sb3JBc3BlY3RzSW5mbzo6b3V0cHV0PiBjb2xvckFzcGVjdHM7CisgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgSW50ZkltcGw6OkxvY2sgbG9jayA9IG1JbnRmLT5sb2NrKCk7CisgICAgICAgICAgICAgICAgY29sb3JBc3BlY3RzID0gbUludGYtPmdldENvZGVkQ29sb3JBc3BlY3RzX2woKTsKKyAgICAgICAgICAgIH0KICAgICAgICAgICAgIENvbnZlcnRSR0JUb1BsYW5hcllVVihtQ29udmVyc2lvbkJ1ZmZlci5kYXRhKCksIHN0cmlkZSwgdnN0cmlkZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtQ29udmVyc2lvbkJ1ZmZlci5zaXplKCksICpyVmlldy5nZXQoKSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNvbnZlcnNpb25CdWZmZXIuc2l6ZSgpLCAqclZpZXcuZ2V0KCksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sb3JBc3BlY3RzLT5tYXRyaXgsIGNvbG9yQXNwZWN0cy0+cmFuZ2UpOwogICAgICAgICAgICAgdnB4X2ltZ193cmFwKCZyYXdfZnJhbWUsIFZQWF9JTUdfRk1UX0k0MjAsIHdpZHRoLCBoZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgbVN0cmlkZUFsaWduLCBtQ29udmVyc2lvbkJ1ZmZlci5kYXRhKCkpOwogICAgICAgICAgICAgYnJlYWs7CmRpZmYgLS1naXQgYS9tZWRpYS9jb2RlYzIvY29tcG9uZW50cy92cHgvQzJTb2Z0VnB4RW5jLmggYi9tZWRpYS9jb2RlYzIvY29tcG9uZW50cy92cHgvQzJTb2Z0VnB4RW5jLmgKaW5kZXggYzk4YjgwMi4uNzE0ZmFkYiAxMDA2NDQKLS0tIGEvbWVkaWEvY29kZWMyL2NvbXBvbmVudHMvdnB4L0My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HJpYnV0ZXNTZXR0aW5nKAotICAgICAgICAgICAgICAgICAgICBDMkNvbXBvbmVudDo6QVRUUklCX0lTX1RFTVBPUkFMKSkKLSAgICAgICAgICAgICAgICAuYnVpbGQoKSk7Ci0KLSAgICAgICAgYWRkUGFyYW1ldGVyKAotICAgICAgICAgICAgICAgIERlZmluZVBhcmFtKG1Vc2FnZSwgQzJfUEFSQU1LRVlfSU5QVVRfU1RSRUFNX1VTQUdFKQotICAgICAgICAgICAgICAgIC53aXRoQ29uc3RWYWx1ZShuZXcgQzJTdHJlYW1Vc2FnZVR1bmluZzo6aW5wdXQoCi0gICAgICAgICAgICAgICAgICAgICAgICAwdSwgKHVpbnQ2NF90KUMyTWVtb3J5VXNhZ2U6OkNQVV9SRUFEKSkKLSAgICAgICAgICAgICAgICAuYnVpbGQoKSk7Ci0KLSAgICAgICAgYWRkUGFyYW1ldGVyKAotICAgICAgICAgICAgRGVmaW5lUGFyYW0obVNpemUsIEMyX1BBUkFNS0VZX1BJQ1RVUkVfU0laRSkKLSAgICAgICAgICAgICAgICAud2l0aERlZmF1bHQobmV3IEMyU3RyZWFtUGljdHVyZVNpemVJbmZvOjppbnB1dCgwdSwgMzIwLCAyNDApKQotICAgICAgICAgICAgICAgIC53aXRoRmllbGRzKHsKLSAgICAgICAgICAgICAgICAgICAgQzJGKG1TaXplLCB3aWR0aCkuaW5SYW5nZSgyLCAyMDQ4LCAyKSwKLSAgICAgICAgICAgICAgICAgICAgQzJGKG1TaXplLCBoZWlnaHQpLmluUmFuZ2UoMiwgMjA0OCwgMiksCi0gICAgICAgICAgICAgICAgfSkKLSAgICAgICAgICAgICAgICAud2l0aFNldHRlcihTaXplU2V0dGVyKQotICAgICAgICAgICAgICAgIC5idWlsZCgpKTsKLQotICAgICAgICBhZGRQYXJhbWV0ZXIoCi0gICAgICAgICAgICBEZWZpbmVQYXJhbShtQml0cmF0ZU1vZGUsIEMyX1BBUkFNS0VZX0JJVFJBVEVfTU9ERSkKLSAgICAgICAgICAgICAgICAud2l0aERlZmF1bHQobmV3IEMyU3RyZWFtQml0cmF0ZU1vZGVUdW5pbmc6Om91dHB1dCgKLSAgICAgICAgICAgICAgICAgICAgICAgIDB1LCBDMkNvbmZpZzo6QklUUkFURV9WQVJJQUJMRSkpCi0gICAgICAgICAgICAgICAgLndpdGhGaWVsZHMoewotICAgICAgICAgICAgICAgICAgICBDMkYobUJpdHJhdGVNb2RlLCB2YWx1ZSkub25lT2YoewotICAgICAgICAgICAgICAgICAgICAgICAgQzJDb25maWc6OkJJVFJBVEVfQ09OU1QsIEMyQ29uZmlnOjpCSVRSQVRFX1ZBUklBQkxFIH0pCi0gICAgICAgICAgICAgICAgfSkKLSAgICAgICAgICAgICAgICAud2l0aFNldHRlcigKLSAgICAgICAgICAgICAgICAgICAgU2V0dGVyPGRlY2x0eXBlKCptQml0cmF0ZU1vZGUpPjo6U3RyaWN0VmFsdWVXaXRoTm9EZXBzKQotICAgICAgICAgICAgICAgIC5idWlsZCgpKTsKLQotICAgICAgICBhZGRQYXJhbWV0ZXIoCi0gICAgICAgICAgICBEZWZpbmVQYXJhbShtRnJhbWVSYXRlLCBDMl9QQVJBTUtFWV9GUkFNRV9SQVRFKQotICAgICAgICAgICAgICAgIC53aXRoRGVmYXVsdChuZXcgQzJTdHJlYW1GcmFtZVJhdGVJbmZvOjpvdXRwdXQoMHUsIDMwLikpCi0gICAgICAgICAgICAgICAgLy8gVE9ETzogTW9yZSByZXN0cmljdGlvbj8KLSAgICAgICAgICAgICAgICAud2l0aEZpZWxkcyh7QzJGKG1GcmFtZVJhdGUsIHZhbHVlKS5ncmVhdGVyVGhhbigwLil9KQotICAgICAgICAgICAgICAgIC53aXRoU2V0dGVyKAotICAgICAgICAgICAgICAgICAgICBTZXR0ZXI8ZGVjbHR5cGUoKm1GcmFtZVJhdGUpPjo6U3RyaWN0VmFsdWVXaXRoTm9EZXBzKQotICAgICAgICAgICAgICAgIC5idWlsZCgpKTsKLQotICAgICAgICBhZGRQYXJhbWV0ZXIoCi0gICAgICAgICAgICBEZWZpbmVQYXJhbShtTGF5ZXJpbmcsIEMyX1BBUkFNS0VZX1RFTVBPUkFMX0xBWUVSSU5HKQotICAgICAgICAgICAgICAgIC53aXRoRGVmYXVsdChDMlN0cmVhbVRlbXBvcmFsTGF5ZXJpbmdUdW5pbmc6Om91dHB1dDo6QWxsb2NTaGFyZWQoMHUsIDAsIDAsIDApKQotICAgICAgICAgICAgICAgIC53aXRoRmllbGRzKHsKLSAgICAgICAgICAgICAgICAgICAgQzJGKG1MYXllcmluZywgbS5sYXllckNvdW50KS5pblJhbmdlKDAsIDQpLAotICAgICAgICAgICAgICAgICAgICBDMkYobUxheWVyaW5nLCBtLmJMYXllckNvdW50KS5pblJhbmdlKDAsIDApLAotICAgICAgICAgICAgICAgICAgICBDMkYobUxheWVyaW5nLCBtLmJpdHJhdGVSYXRpb3MpLmluUmFuZ2UoMC4sIDEuKQotICAgICAgICAgICAgICAgIH0pCi0gICAgICAgICAgICAgICAgLndpdGhTZXR0ZXIoTGF5ZXJpbmdTZXR0ZXIpCi0gICAgICAgICAgICAgICAgLmJ1aWxkKCkpOwotCi0gICAgICAgIGFkZFBhcmFtZXRlcigKLSAgICAgICAgICAgICAgICBEZWZpbmVQYXJhbShtU3luY0ZyYW1lUGVyaW9kLCBDMl9QQVJBTUtFWV9TWU5DX0ZSQU1FX0lOVEVSVkFMKQotICAgICAgICAgICAgICAgIC53aXRoRGVmYXVsdChuZXcgQzJTdHJlYW1TeW5jRnJhbWVJbnRlcnZhbFR1bmluZzo6b3V0cHV0KDB1LCAxMDAwMDAwKSkKLSAgICAgICAgICAgICAgICAud2l0aEZpZWxkcyh7QzJGKG1TeW5jRnJhbWVQZXJpb2QsIHZhbHVlKS5hbnkoKX0pCi0gICAgICAgICAgICAgICAgLndpdGhTZXR0ZXIoU2V0dGVyPGRlY2x0eXBlKCptU3luY0ZyYW1lUGVyaW9kKT46OlN0cmljdFZhbHVlV2l0aE5vRGVwcykKLSAg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JRUQsIEMyQ29sb3I6OlBSSU1BUklFU19VTlNQRUNJRklFRCwKLSAgICAgICAgICAgICAgICAgICAgICAgIEMyQ29sb3I6OlRSQU5TRkVSX1VOU1BFQ0lGSUVELCBDMkNvbG9yOjpNQVRSSVhfVU5TUEVDSUZJRUQpKQotICAgICAgICAgICAgICAgIC53aXRoRmllbGRzKHsKLSAgICAgICAgICAgICAgICAgICAgQzJGKG1Db2xvckFzcGVjdHMsIHJhbmdlKS5pblJhbmdlKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDMkNvbG9yOjpSQU5HRV9VTlNQRUNJRklFRCwgICAgIEMyQ29sb3I6OlJBTkdFX09USEVSKSwKLSAgICAgICAgICAgICAgICAgICAgQzJGKG1Db2xvckFzcGVjdHMsIHByaW1hcmllcykuaW5SYW5nZSgKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQzJDb2xvcjo6UFJJTUFSSUVTX1VOU1BFQ0lGSUVELCBDMkNvbG9yOjpQUklNQVJJRVNfT1RIRVIpLAotICAgICAgICAgICAgICAgICAgICBDMkYobUNvbG9yQXNwZWN0cywgdHJhbnNmZXIpLmluUmFuZ2UoCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEMyQ29sb3I6OlRSQU5TRkVSX1VOU1BFQ0lGSUVELCAgQzJDb2xvcjo6VFJBTlNGRVJfT1RIRVIpLAotICAgICAgICAgICAgICAgICAgICBDMkYobUNvbG9yQXNwZWN0cywgbWF0cml4KS5pblJhbmdlKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDMkNvbG9yOjpNQVRSSVhfVU5TUEVDSUZJRUQsICAgIEMyQ29sb3I6Ok1BVFJJWF9PVEhFUikKLSAgICAgICAgICAgICAgICB9KQotICAgICAgICAgICAgICAgIC53aXRoU2V0dGVyKENvbG9yQXNwZWN0c1NldHRlcikKLSAgICAgICAgICAgICAgICAuYnVpbGQoKSk7Ci0KLSAgICAgICAgYWRkUGFyYW1ldGVyKAotICAgICAgICAgICAgICAgIERlZmluZVBhcmFtKG1Db2RlZENvbG9yQXNwZWN0cywgQzJfUEFSQU1LRVlfVlVJX0NPTE9SX0FTUEVDVFMpCi0gICAgICAgICAgICAgICAgLndpdGhEZWZhdWx0KG5ldyBDMlN0cmVhbUNvbG9yQXNwZWN0c0luZm86Om91dHB1dCgKLSAgICAgICAgICAgICAgICAgICAgICAgIDB1LCBDMkNvbG9yOjpSQU5HRV9MSU1JVEVELCBDMkNvbG9yOjpQUklNQVJJRVNfVU5TUEVDSUZJRUQsCi0gICAgICAgICAgICAgICAgICAgICAgICBDMkNvbG9yOjpUUkFOU0ZFUl9VTlNQRUNJRklFRCwgQzJDb2xvcjo6TUFUUklYX1VOU1BFQ0lGSUVEKSkKLSAgICAgICAgICAgICAgICAud2l0aEZpZWxkcyh7Ci0gICAgICAgICAgICAgICAgICAgIEMyRihtQ29kZWRDb2xvckFzcGVjdHMsIHJhbmdlKS5pblJhbmdlKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDMkNvbG9yOjpSQU5HRV9VTlNQRUNJRklFRCwgICAgIEMyQ29sb3I6OlJBTkdFX09USEVSKSwKLSAgICAgICAgICAgICAgICAgICAgQzJGKG1Db2RlZENvbG9yQXNwZWN0cywgcHJpbWFyaWVzKS5pblJhbmdlKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDMkNvbG9yOjpQUklNQVJJRVNfVU5TUEVDSUZJRUQsIEMyQ29sb3I6OlBSSU1BUklFU19PVEhFUiksCi0gICAgICAgICAgICAgICAgICAgIEMyRihtQ29kZWRDb2xvckFzcGVjdHMsIHRyYW5zZmVyKS5pblJhbmdlKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDMkNvbG9yOjpUUkFOU0ZFUl9VTlNQRUNJRklFRCwgIEMyQ29sb3I6OlRSQU5TRkVSX09USEVSKSwKLSAgICAgICAgICAgICAgICAgICAgQzJGKG1Db2RlZENvbG9yQXNwZWN0cywgbW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kgewotICAgICAgICAgICAgbWUuc2V0KCkubGV2ZWwgPSBMRVZFTF9WUDlfNF8xOwotICAgICAgICB9Ci0gICAgICAgIHJldHVybiBDMlI6Ok9rKCk7Ci0gICAgfQorICAgICAgICAgICAgQzJQPEMyU3RyZWFtUHJvZmlsZUxldmVsSW5mbzo6b3V0cHV0PiAmbWUpOwogCi0gICAgc3RhdGljIEMyUiBMYXllcmluZ1NldHRlcihib29sIG1heUJsb2NrLCBDMlA8QzJTdHJlYW1UZW1wb3JhbExheWVyaW5nVHVuaW5nOjpvdXRwdXQ+JiBtZSkgewotICAgICAgICAodm9pZCltYXlCbG9jazsKLSAgICAgICAgQzJSIHJlcyA9IEMyUjo6T2soKTsKLSAgICAgICAgaWYgKG1lLnYubS5sYXllckNvdW50ID4gNCkgewotICAgICAgICAgICAgbWUuc2V0KCkubS5sYXllckNvdW50ID0gNDsKLSAgICAgICAgfQotICAgICAgICBtZS5zZXQoKS5tLmJMYXllckNvdW50ID0gMDsKLSAgICAgICAgLy8gZW5zdXJlIHJhdGlvcyBhcmUgbW9ub3RvbmljIGFuZCBjbGFtcGVkIGJldHdlZW4gMCBhbmQgMQotICAgICAgICBmb3IgKHNpemVfdCBpeCA9IDA7IGl4IDwgbWUudi5mbGV4Q291bnQoKTsgKytpeCkgewotICAgICAgICAgICAgbWUuc2V0KCkubS5iaXRyYXRlUmF0aW9zW2l4XSA9IGMyX2NsYW1wKAotICAgICAgICAgICAgICAgIGl4ID4gMCA/IG1lLnYubS5iaXRyYXRlUmF0aW9zW2l4IC0gMV0gOiAwLCBtZS52Lm0uYml0cmF0ZVJhdGlvc1tpeF0sIDEuKTsKLSAgICAgICAgfQotICAgICAgICBBTE9HSSgic2V0dGluZyB0ZW1wb3JhbCBsYXllcmluZyAldSArICV1IiwgbWUudi5tLmxheWVyQ291bnQsIG1lLnYubS5iTGF5ZXJDb3VudCk7Ci0gICAgICAgIHJldHVybiByZXM7Ci0gICAgfQorICAgIHN0YXRpYyBDMlIgTG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y8vPCBEb2xieSBWaXNpb24gbWFpbiB0aWVyIHVoZDQ4CiAgICAgTEVWRUxfRFZfTUFJTl9VSERfNjAsICAgICAgICAgICAgICAgICAgICAgICAvLy88IERvbGJ5IFZpc2lvbiBtYWluIHRpZXIgdWhkNjAKKyAgICBMRVZFTF9EVl9NQUlOX1VIRF8xMjAsICAgICAgICAgICAgICAgICAgICAgIC8vLzwgRG9sYnkgVmlzaW9uIG1haW4gdGllciB1aGQxMjAKKyAgICBMRVZFTF9EVl9NQUlOXzhLXzMwLCAgICAgICAgICAgICAgICAgICAgICAgIC8vLzwgRG9sYnkgVmlzaW9uIG1haW4gdGllciA4azMwCisgICAgTEVWRUxfRFZfTUFJTl84S182MCwgICAgICAgICAgICAgICAgICAgICAgICAvLy88IERvbGJ5IFZpc2lvbiBtYWluIHRpZXIgOGs2MAogCiAgICAgTEVWRUxfRFZfSElHSF9IRF8yNCA9IF9DMl9QTF9EVl9CQVNFICsgMHgxMDAsICAvLy88IERvbGJ5IFZpc2lvbiBoaWdoIHRpZXIgaGQyNAogICAgIExFVkVMX0RWX0hJR0hfSERfMzAsICAgICAgICAgICAgICAgICAgICAgICAgLy8vPCBEb2xieSBWaXNpb24gaGlnaCB0aWVyIGhkMzAKQEAgLTY5MCw2ICs3MDcsOSBAQAogICAgIExFVkVMX0RWX0hJR0hfVUhEXzMwLCAgICAgICAgICAgICAgICAgICAgICAgLy8vPCBEb2xieSBWaXNpb24gaGlnaCB0aWVyIHVoZDMwCiAgICAgTEVWRUxfRFZfSElHSF9VSERfNDgsICAgICAgICAgICAgICAgICAgICAgICAvLy88IERvbGJ5IFZpc2lvbiBoaWdoIHRpZXIgdWhkNDgKICAgICBMRVZFTF9EVl9ISUdIX1VIRF82MCwgICAgICAgICAgICAgICAgICAgICAgIC8vLzwgRG9sYnkgVmlzaW9uIGhpZ2ggdGllciB1aGQ2MAorICAgIExFVkVMX0RWX0hJR0hfVUhEXzEyMCwgICAgICAgICAgICAgICAgICAgICAgLy8v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GliY29kZWMyX3ZuZGsiLAotICAgICAgICAibGlibmF0aXZld2luZG93IiwKLSAgICAgICAgImxpYmNvZGVjMl9zb2Z0X2NvbW1vbiIsCi0gICAgICAgICJsaWJzZnBsdWdpbl9jY29kZWNfdXRpbHMiLAotICAgICAgICAibGlic3RhZ2VmcmlnaHRfZm91bmRhdGlvbiIsCi0gICAgICAgICJsaWJzdGFnZWZyaWdodF9idWZmZXJwb29sQDIuMC4xIiwKLSAgICAgICAgImFuZHJvaWQuaGFyZHdhcmUuZ3JhcGhpY3MubWFwcGVyQDIuMCIsCi0gICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLmdyYXBoaWNzLm1hcHBlckAzLjAiLAotICAgICAgICAiYW5kcm9pZC5oYXJkd2FyZS5tZWRpYS5idWZmZXJwb29sQDIuMCIsCi0gICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLmdyYXBoaWNzLmFsbG9jYXRvckAyLjAiLAotICAgICAgICAiYW5kcm9pZC5oYXJkd2FyZS5ncmFwaGljcy5hbGxvY2F0b3JAMy4wIiwKLSAgICAgICAgImFuZHJvaWQuaGFyZHdhcmUuZ3JhcGhpY3MuYnVmZmVycXVldWVAMi4wIiwKLSAgICBdLAotCi0gICAgc2hhcmVkX2xpYnM6IFsKLSAgICAgICAgImxpYnVpIiwKLSAgICAgICAgImxpYmRsIiwKLSAgICAgICAgImxpYmJpbmRlciIsCi0gICAgICAgICJsaWJoYXJkd2FyZSIsCi0gICAgICAgICJsaWJ2bmRrc3VwcG9ydCIsCi0gICAgICAgICJsaWJwcm9jZXNzZ3JvdXAiLAotICAgIF0sCi0KICAgICBjZmxhZ3M6IFsKICAgICAgICAgIi1XYWxsIiwKICAgICAgICAgIi1XZXJyb3IiLAogICAgIF0sCisKKyAgICBmdXp6X2NvbmZpZzogeworICAgICAgICBjYzogWworICAgICAgICAgICAgIndvbnNpa0Bnb29nbGUuY29tIiwKKyAgICAgICAgXSwKKyAgICB9LAogfQogCiBjY19mdXp6IHsKZ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nN0IHdwPENvbXBvbmVudD4mIGNvbXApCisgICAgICAgICAgICA6IG1Db21wb25lbnR7Y29tcH0geworICAgICAgICB9CisKKyAgICAgICAgdmlydHVhbCB2b2lkIHNlcnZpY2VEaWVkKAorICAgICAgICAgICAgICAgIHVpbnQ2NF90IC8qIGNvb2tpZSAqLywKKyAgICAgICAgICAgICAgICBjb25zdCB3cDw6OmFuZHJvaWQ6OmhpZGw6OmJhc2U6OlYxXzA6OklCYXNlPiYgLyogd2hvICovCisgICAgICAgICAgICAgICAgKSBvdmVycmlkZSB7CisgICAgICAgICAgICBhdXRvIHN0cm9uZ0NvbXBvbmVudCA9IG1Db21wb25lbnQucHJvbW90ZSgpOworICAgICAgICAgICAgaWYgKHN0cm9uZ0NvbXBvbmVudCkgeworICAgICAgICAgICAgICAgIExPRyhJTkZPKSA8PCAiQ2xpZW50IGRpZWQgISByZWxlYXNlIHRoZSBjb21wb25lbnQgISEiOworICAgICAgICAgICAgICAgIHN0cm9uZ0NvbXBvbmVudC0+cmVsZWFzZSgpOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICBMT0coRVJST1IpIDw8ICJDbGllbnQgZGllZCAhIG5vIGNvbXBvbmVudCB0byByZWxlYXNlICEhIjsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorCisgICAgICAgIHdwPENvbXBvbmVudD4gbUNvbXBvbmVudDsKKyAgICB9OworCisgICAgbURlYXRoUmVjaXBpZW50ID0gbmV3IExpc3RlbmVyRGVhdGhSZWNpcGllbnQoc2VsZik7CisgICAgUmV0dXJuPGJvb2w+IHRyYW5zU3RhdHVzID0gbUxpc3RlbmVyLT5saW5rVG9EZWF0aCgKKyAgICAgICAgICAgIG1EZWF0aFJlY2lwaWVudCwgMCk7CisgICAgaWYgKCF0cmFuc1N0YXR1cy5pc09rKCkpIHsKKyAgICAgICAgTE9HKEVSUk9SKSA8PCAiTGlzdGVuZXIgbGlua1RvRGVhdGgoKSB0cmFuc2FjdGlvb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sKKyAgICAgICAgICAgIGF1dG8gc3Ryb25nQ29tcG9uZW50ID0gY29tcG9uZW50LnByb21vdGUoKTsKKyAgICAgICAgICAgIGlmIChzdHJvbmdDb21wb25lbnQpIHsKKyAgICAgICAgICAgICAgICBMT0coSU5GTykgPDwgIkNsaWVudCBkaWVkICEgcmVsZWFzZSB0aGUgY29tcG9uZW50ICEhIjsKKyAgICAgICAgICAgICAgICBzdHJvbmdDb21wb25lbnQtPnJlbGVhc2UoKTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgTE9HKEVSUk9SKSA8PCAiQ2xpZW50IGRpZWQgISBubyBjb21wb25lbnQgdG8gcmVsZWFzZSAhISI7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKworICAgICAgICB3cDxDb21wb25lbnQ+IGNvbXBvbmVudDsKKyAgICB9OworCisgICAgbURlYXRoUmVjaXBpZW50ID0gbmV3IExpc3RlbmVyRGVhdGhSZWNpcGllbnQoc2VsZik7CisgICAgUmV0dXJuPGJvb2w+IHRyYW5zU3RhdHVzID0gbUxpc3RlbmVyLT5saW5rVG9EZWF0aCgKKyAgICAgICAgICAgIG1EZWF0aFJlY2lwaWVudCwgMCk7CisgICAgaWYgKCF0cmFuc1N0YXR1cy5pc09rKCkpIHsKKyAgICAgICAgTE9HKEVSUk9SKSA8PCAiTGlzdGVuZXIgbGlua1RvRGVhdGgoKSB0cmFuc2FjdGlvbiBmYWlsZWQuIjsKKyAgICB9CisgICAgaWYgKCFzdGF0aWNfY2FzdDxib29sPih0cmFuc1N0YXR1cykpIHsKKyAgICAgICAgTE9HKERFQlVHKSA8PCAiTGlzdGVuZXIgbGlua1RvRGVhdGgoKSBjYWxsIGZhaWxlZC4iOworICAgIH0KIH0KIAogQ29tcG9uZW50Ojp+Q29tcG9uZW50KCkgewpkaWZmIC0tZ2l0IGEvbWVkaWEvY29kZWMyL2hpZGwvMS4xL3V0aWxzL2luY2x1ZGUvY29kZWMyL2hpZGwvMS4xL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pZW50IDogcHVibGljIEh3RGVhdGhSZWNpcGllbnQgeworICAgICAgICBMaXN0ZW5lckRlYXRoUmVjaXBpZW50KGNvbnN0IHdwPENvbXBvbmVudD4mIGNvbXApCisgICAgICAgICAgICA6IGNvbXBvbmVudHtjb21wfSB7CisgICAgICAgIH0KKworICAgICAgICB2aXJ0dWFsIHZvaWQgc2VydmljZURpZWQoCisgICAgICAgICAgICAgICAgdWludDY0X3QgLyogY29va2llICovLAorICAgICAgICAgICAgICAgIGNvbnN0IHdwPDo6YW5kcm9pZDo6aGlkbDo6YmFzZTo6VjFfMDo6SUJhc2U+JiAvKiB3aG8gKi8KKyAgICAgICAgICAgICAgICApIG92ZXJyaWRlIHsKKyAgICAgICAgICAgIGF1dG8gc3Ryb25nQ29tcG9uZW50ID0gY29tcG9uZW50LnByb21vdGUoKTsKKyAgICAgICAgICAgIGlmIChzdHJvbmdDb21wb25lbnQpIHsKKyAgICAgICAgICAgICAgICBMT0coSU5GTykgPDwgIkNsaWVudCBkaWVkICEgcmVsZWFzZSB0aGUgY29tcG9uZW50ICEhIjsKKyAgICAgICAgICAgICAgICBzdHJvbmdDb21wb25lbnQtPnJlbGVhc2UoKTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgTE9HKEVSUk9SKSA8PCAiQ2xpZW50IGRpZWQgISBubyBjb21wb25lbnQgdG8gcmVsZWFzZSAhISI7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKworICAgICAgICB3cDxDb21wb25lbnQ+IGNvbXBvbmVudDsKKyAgICB9OworCisgICAgbURlYXRoUmVjaXBpZW50ID0gbmV3IExpc3RlbmVyRGVhdGhSZWNpcGllbnQoc2VsZik7CisgICAgUmV0dXJuPGJvb2w+IHRyYW5zU3RhdHVzID0gbUxpc3RlbmVyLT5saW5rVG9EZWF0aCgKKyAgICAgICAgICAgIG1EZWF0aFJlY2lwaWVudCwgMCk7CisgICAgaWYgKCF0cmFuc1N0YXR1cy5pc09rKCkpIH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9uKHN0YWNrUGFyYW1zTGlzdC5iZWdpbigpLCBzdGFja1BhcmFtc0xpc3Quc2l6ZSgpLCBzdGFja1BhcmFtc0ZvckludGYuYmVnaW4oKSk7CisgICAgICAgIGZvciAoQzJQYXJhbSAqcGFyYW0gOiBzdGFja1BhcmFtc0xpc3QpIHsKKyAgICAgICAgICAgIGlmIChtQ29udHJvbFBhcmFtVHlwZXMuY291bnQocGFyYW0tPnR5cGUoKSkgIT0gMCkgeworICAgICAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICAgICAgfQorICAgICAgICAgICAgc3RhY2tQYXJhbXNGb3JJbnRmLnB1c2hfYmFjayhwYXJhbSk7CisgICAgICAgIH0KIAogICAgICAgICAvLyBHYXRoZXIgaGVhcCBwYXJhbXMgdGhhdCBkaWQgbm90IGdldCBxdWVyaWVkIGZyb20gdGhlIGZpbHRlciBpbnRlcmZhY2VzIGFib3ZlLgogICAgICAgICAvLyBUaGVzZSBuZWVkIHRvIGJlIHF1ZXJpZWQgZnJvbSB0aGUgZGVjb2RlciBpbnRlcmZhY2UuCkBAIC0xOTcsNiArMjA3LDkgQEAKICAgICAgICAgICAgIGlmIChtVHlwZVRvSW5kZXhGb3JRdWVyeS5maW5kKHR5cGUpICE9IG1UeXBlVG9JbmRleEZvclF1ZXJ5LmVuZCgpKSB7CiAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICB9CisgICAgICAgICAgICBpZiAobUNvbnRyb2xQYXJhbVR5cGVzLmNvdW50KHR5cGUpICE9IDApIHsKKyAgICAgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgICAgIH0KICAgICAgICAgICAgIGhlYXBQYXJhbUluZGljZXNGb3JJbnRmLnB1c2hfYmFjayhoZWFwUGFyYW1JbmRpY2VzW2pdKTsKICAgICAgICAgfQogCkBAIC0yNTEsMTEgKzI2NCwxNCBAQAogICAgICAgICAgICAgc3RkOjp2ZWN0b3I8QzJQYXJhbSAqPiBwYXJhbXNGb3JG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5jbHVkZSAidXRpbHMvQ29kZWMyTWFwcGVyLmgiCiAjaW5jbHVkZSAiQzJPTVhOb2RlLmgiCisjaW5jbHVkZSAiQ29kZWMyQnVmZmVyLmgiCiAKIG5hbWVzcGFjZSBhbmRyb2lkIHsKIApAQCAtNDY2LDYgKzQ2NywxOCBAQAogICAgICAgICAgICAgICAgIG5ldyBCdWZmZXIyRChibG9jay0+c2hhcmUoCiAgICAgICAgICAgICAgICAgICAgICAgICBDMlJlY3QoYmxvY2stPndpZHRoKCksIGJsb2NrLT5oZWlnaHQoKSksIDo6QzJGZW5jZSgpKSkpOwogICAgICAgICB3b3JrLT5pbnB1dC5idWZmZXJzLnB1c2hfYmFjayhjMkJ1ZmZlcik7CisgICAgICAgIHN0ZDo6c2hhcmVkX3B0cjxDMlN0cmVhbUhkclN0YXRpY0luZm86OmlucHV0PiBzdGF0aWNJbmZvOworICAgICAgICBzdGQ6OnNoYXJlZF9wdHI8QzJTdHJlYW1IZHJEeW5hbWljTWV0YWRhdGFJbmZvOjppbnB1dD4gZHluYW1pY0luZm87CisgICAgICAgIEdldEhkck1ldGFkYXRhRnJvbUdyYWxsb2M0SGFuZGxlKAorICAgICAgICAgICAgICAgIGJsb2NrLT5oYW5kbGUoKSwKKyAgICAgICAgICAgICAgICAmc3RhdGljSW5mbywKKyAgICAgICAgICAgICAgICAmZHluYW1pY0luZm8pOworICAgICAgICBpZiAoc3RhdGljSW5mbyAmJiAqc3RhdGljSW5mbykgeworICAgICAgICAgICAgYzJCdWZmZXItPnNldEluZm8oc3RhdGljSW5mbyk7CisgICAgICAgIH0KKyAgICAgICAgaWYgKGR5bmFtaWNJbmZvICYmICpkeW5hbWljSW5mbykgeworICAgICAgICAgICAgYzJCdWZmZXItPnNldEluZm8oZHluYW1pY0luZm8pOworICAgICAgICB9CiAgICAgfQogICAgIHdvcmstPndvcmtsZXRzLmNsZWFyKCk7CiAgICAgd29yay0+d29ya2xldHMuZW1wbGFjZV9iYWNrKG5ldyBDMldvc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AgcmV0dXJuIE9LOworICAgICAgICByZXR1cm4gR2V0U3RhdHVzKG1Tb3VyY2UtPmNvbmZpZ3VyZSgKKyAgICAgICAgICAgICAgICBtT214Tm9kZSwgc3RhdGljX2Nhc3Q8aGFyZHdhcmU6OmdyYXBoaWNzOjpjb21tb246OlYxXzA6OkRhdGFzcGFjZT4obURhdGFTcGFjZSkpKTsKICAgICB9CiAKICAgICB2b2lkIGRpc2Nvbm5lY3QoKSBvdmVycmlkZSB7CkBAIC04NzIsNiArODcyLDExIEBACiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWctPm1UdW5uZWxlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgICAgICBpbnQzMl90IHB1c2hCbGFua0J1ZmZlcnNPblN0b3AgPSAwOworICAgICAgICAgICAgICAgICAgICBpZiAobXNnLT5maW5kSW50MzIoS0VZX1BVU0hfQkxBTktfQlVGRkVSU19PTl9TVE9QLCAmcHVzaEJsYW5rQnVmZmVyc09uU3RvcCkpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpZy0+bVB1c2hCbGFua0J1ZmZlcnNPblN0b3AgPSBwdXNoQmxhbmtCdWZmZXJzT25TdG9wID09IDE7CisgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBzZXRTdXJmYWNlKHN1cmZhY2UpOwpAQCAtMTAwNyw3ICsxMDEyLDkgQEAKICAgICAgICAgICAgIC8vIFF1ZXJ5IHZlbmRvciBmb3JtYXQgZm9yIEZsZXhpYmxlIFlVVgogICAgICAgICAgICAgc3RkOjp2ZWN0b3I8c3RkOjp1bmlxdWVfcHRyPEMyUGFyYW0+PiBoZWFwUGFyYW1zOwogICAgICAgICAgICAgQzJTdG9yZUZsZXhpYmxlUGl4ZWxGb3JtYXREZXNjcmlwdG9yc0luZm8gKnBpeGVsRm9ybWF0SW5mbyA9IG51bGxwdHI7Ci0gICAgICAgICAgICBpZiAobUNsaWVudC0+cXVlcnkoCisgICAgICAgICAgICBpbnQgdmVuZG9yU2RrVmVyc2lvbiA9IGJhc2U6OkdldEludFByb3BlcnR5KAorICAgICAgICAgICAgICAgICAgICAicm8udmVuZG9yLmJ1aWxkLnZlcnNpb24uc2RrIiwgYW5kcm9pZF9nZXRfZGV2aWNlX2FwaV9sZXZlbCgpKTsKKyAgICAgICAgICAgIGlmICh2ZW5kb3JTZGtWZXJzaW9uID49IF9fQU5EUk9JRF9BUElfU19fICYmIG1DbGllbnQtPnF1ZXJ5KAogICAgICAgICAgICAgICAgICAgICAgICAge30sCiAgICAgICAgICAgICAgICAgICAgICAgICB7QzJTdG9yZUZsZXhpYmxlUGl4ZWxGb3JtYXREZXNjcmlwdG9yc0luZm86OlBBUkFNX1RZUEV9LAogICAgICAgICAgICAgICAgICAgICAgICAgQzJfTUFZX0JMT0NLLApAQCAtMTAxOCwyOSArMTAyNSwzMSBAQAogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICBwaXhlbEZvcm1hdEluZm8gPSBudWxscHRyOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgc3RkOjpvcHRpb25hbDx1aW50MzJfdD4gZmxleFBpeGVsRm9ybWF0e307Ci0gICAgICAgICAgICBzdGQ6Om9wdGlvbmFsPHVpbnQzMl90PiBmbGV4UGxhbmFyUGl4ZWxGb3JtYXR7fTsKLSAgICAgICAgICAgIHN0ZDo6b3B0aW9uYWw8dWludDMyX3Q+IGZsZXhTZW1pUGxhbmFyUGl4ZWxGb3JtYXR7fTsKKyAgICAgICAgICAgIC8vIGJpdCBkZXB0aCAtPiBmb3JtYXQKKyAgICAgICAgICAgIHN0ZDo6bWFwPHVpbnQzMl90LCB1aW50MzJfdD4gZmxleFBpeGVsRm9ybWF0OworICAgICAgICAgICAgc3RkOjptYXA8dWludDMyX3QsIHVpbnQzMl90PiBmbGV4UGxhbmFyUGl4ZWxGb3JtYXQ7CisgICAgICAgICAgICBzdGQ6Om1hcDx1aW50MzJfdCwgdWludDMyX3Q+IGZsZXhTZW1pUGxhbmFyUGl4ZWxGb3JtYXQ7CiAgICAgICAgICAgICBpZiAocGl4ZWxGb3JtYXRJbmZvICYmICpwaXhlbEZvcm1hdEluZm8pIHsKICAgICAgICAgICAgICAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IHBpeGVsRm9ybWF0SW5mby0+ZmxleENvdW50KCk7ICsraSkgewogICAgICAgICAgICAgICAgICAgICBjb25zdCBDMkZsZXhpYmxlUGl4ZWxGb3JtYXREZXNjcmlwdG9yU3RydWN0ICZkZXNjID0KICAgICAgICAgICAgICAgICAgICAgICAgIHBpeGVsRm9ybWF0SW5mby0+bS52YWx1ZXNbaV07Ci0gICAgICAgICAgICAgICAgICAgIGlmIChkZXNjLmJpdERlcHRoICE9IDgKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICB8fCBkZXNjLnN1YnNhbXBsaW5nICE9IEMyQ29sb3I6OllVVl80MjAKKyAgICAgICAgICAgICAgICAgICAgaWYgKGRlc2Muc3Vic2FtcGxpbmcgIT0gQzJDb2xvcjo6WVVWXzQyMAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIFRPRE8oYi8xODAwNzYxMDUpOiBzb21lIGRldmljZSByZXBvcnQgd3JvbmcgbGF5b3V0CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gfHwgZGVzYy5sYXlvdXQgPT0gQzJDb2xvcjo6SU5URVJMRUFWRURfUEFDS0VECiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gfHwgZGVzYy5sYXlvdXQgPT0gQzJDb2xvcjo6SU5URVJMRUFWRURfQUxJR05FRAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHx8IGRlc2MubGF5b3V0ID09IEMyQ29sb3I6OlVOS05PV05fTEFZT1VUKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBpZiAoIWZsZXhQaXhlbEZvcm1hdCkgewotICAgICAgICAgICAgICAgICAgICAgICAgZmxleFBpeGVsRm9ybWF0ID0gZGVzYy5waXhlbEZvcm1hdDsKKyAgICAgICAgICAgICAgICAgICAgaWYgKGZsZXhQaXhlbEZvcm1hdC5jb3VudChkZXNjLmJpdERlcHRoKSA9PSAwKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBmbGV4UGl4ZWxGb3JtYXQuZW1wbGFjZShkZXNjLmJpdERlcHRoLCBkZXNjLnBpeGVsRm9ybWF0KTsKICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBpZiAoZGVzYy5sYXlvdXQgPT0gQzJDb2xvcjo6UExBTkFSX1BBQ0tFRCAmJiAhZmxleFBsYW5hclBpeGVsRm9ybWF0KSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBmbGV4UGxhbmFyUGl4ZWxGb3JtYXQgPSBkZXNjLnBpeGVsRm9ybWF0OworICAgICAgICAgICAgICAgICAgICBpZiAoZGVzYy5sYXlvdXQgPT0gQzJDb2xvcjo6UExBTkFSX1BBQ0tFRAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICYmIGZsZXhQbGFuYXJQaXhlbEZvcm1hdC5jb3VudChkZXNjLmJpdERlcHRoKSA9PSAwKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBmbGV4UGxhbmFyUGl4ZWxGb3JtYXQuZW1wbGFjZShkZXNjLmJpdERlcHRoLCBkZXNjLnBpeGVsRm9ybWF0KTsKICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBpZiAoZGVzYy5sYXlvdXQgPT0gQzJDb2xvcjo6U0VNSVBMQU5BUl9QQUNLRUQgJiYgIWZsZXhTZW1pUGxhbmFyUGl4ZWxGb3JtYXQpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGZsZXhTZW1pUGxhbmFyUGl4ZWxGb3JtYXQgPSBkZXNjLnBpeGVsRm9ybWF0OworICAgICAgICAgICAgICAgICAgICBpZiAoZGVzYy5sYXlvdXQgPT0gQzJDb2xvcjo6U0VNSVBMQU5BUl9QQUNLRUQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAmJiBmbGV4U2VtaVBsYW5hclBpeGVsRm9ybWF0LmNvdW50KGRlc2MuYml0RGVwdGgpID09IDApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGZsZXhTZW1pUGxhbmFyUGl4ZWxGb3JtYXQuZW1wbGFjZShkZXNjLmJpdERlcHRoLCBkZXNjLnBpeGVsRm9ybWF0KTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KQEAgLTEwNTAsNyArMTA1OSw3IEBACiAgICAgICAgICAgICAgICAgaWYgKCEoY29uZmlnLT5tRG9tYWluICYgQ29uZmlnOjpJU19FTkNPREVSKSkgewogICAgICAgICAgICAgICAgICAgICBpZiAoc3VyZmFjZSA9PSBudWxscHRyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyICpwcmVmaXggPSAiIjsKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmbGV4U2VtaVBsYW5hclBpeGVsRm9ybWF0KSB7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZmxleFNlbWlQbGFuYXJQaXhlbEZvcm1hdC5jb3VudCg4KSAhPSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9ybWF0ID0gQ09MT1JfRm9ybWF0WVVWNDIwU2VtaVBsYW5hcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmVmaXggPSAic2VtaS0iOwogICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKQEAgLTEwNjUsMTkgKzEwNzQsNDcgQEAKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgIGlmICgoY29uZmlnLT5tRG9tYWluICYgQ29uZmlnOjpJU19FTkNPREVSKSB8fCAhc3VyZmFjZSkgeworICAgICAgICAgICAgICAgICAgICBpZiAodmVuZG9yU2RrVmVyc2lvbiA8IF9fQU5EUk9JRF9BUElfU19fICYmCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGZvcm1hdCA9PSBDT0xPUl9Gb3JtYXRZVVY0MjBGbGV4aWJsZSB8fAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JtYXQgPT0gQ09MT1JfRm9ybWF0WVVWNDIwUGxhbmFyIHx8CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcm1hdCA9PSBDT0xPUl9Gb3JtYXRZVVY0MjBQYWNrZWRQbGFuYXIgfHwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9ybWF0ID09IENPTE9SX0Zvcm1hdFlVVjQyMFNlbWlQbGFuYXIgfHwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9ybWF0ID09IENPTE9SX0Zvcm1hdFlVVjQyMFBhY2tlZFNlbWlQbGFuYXIpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAvLyBwcmUtUyBmcmFtZXdvcmsgdXNlZCB0byBtYXAgdGhlc2UgY29sb3IgZm9ybWF0cyBpbnRvIFlWMTIuCisgICAgICAgICAgICAgICAgICAgICAgICAvLyBDb2RlY3MgZnJvbSBvbGRlciB2ZW5kb3IgcGFydGl0aW9uIG1heSBiZSByZWx5aW5nIG9uCisgICAgICAgICAgICAgICAgICAgICAgICAvLyB0aGlzIGFzc3VtcHRpb24uCisgICAgICAgICAgICAgICAgICAgICAgICBmb3JtYXQgPSBIQUxfUElYRUxfRk9STUFUX1lWMTI7CisgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChmb3JtYXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgQ09MT1JfRm9ybWF0WVVWNDIwRmxleGlibGU6Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9ybWF0ID0gZmxleFBpeGVsRm9ybWF0LnZhbHVlX29yKENPTE9SX0Zvcm1hdFlVVjQyMFBsYW5hcik7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9ybWF0ID0gQ09MT1JfRm9ybWF0WVVWNDIwUGxhbmFyOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmbGV4UGl4ZWxGb3JtYXQuY291bnQoOCkgIT0gMCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JtYXQgPSBmbGV4UGl4ZWxGb3JtYXRbOF07CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBDT0xPUl9Gb3JtYXRZVVY0MjBQbGFuYXI6CiAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIENPTE9SX0Zvcm1hdFlVVjQyMFBhY2tlZFBsYW5hcjoKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JtYXQgPSBmbGV4UGxhbmFyUGl4ZWxGb3JtYXQudmFsdWVfb3IoCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbGV4UGl4ZWxGb3JtYXQudmFsdWVfb3IoZm9ybWF0KSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZsZXhQbGFuYXJQaXhlbEZvcm1hdC5jb3VudCg4KSAhPSAwKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcm1hdCA9IGZsZXhQbGFuYXJQaXhlbEZvcm1hdFs4XTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGZsZXhQaXhlbEZvcm1hdC5jb3VudCg4KSAhPSAwKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcm1hdCA9IGZsZXhQaXhlbEZvcm1hdFs4XTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIENPTE9SX0Zvcm1hdFlVVjQyMFNlbWlQbGFuYXI6CiAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIENPTE9SX0Zvcm1hdFlVVjQyMFBhY2tlZFNlbWlQbGFuYXI6Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9ybWF0ID0gZmxleFNlbWlQbGFuYXJQaXhlbEZvcm1hdC52YWx1ZV9vcigKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZsZXhQaXhlbEZvcm1hdC52YWx1ZV9vcihmb3JtYXQpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZmxleFNlbWlQbGFuYXJQaXhlbEZvcm1hdC5jb3VudCg4KSAhPSAwKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcm1hdCA9IGZsZXhTZW1pUGxhbmFyUGl4ZWxGb3JtYXRbOF07CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChmbGV4UGl4ZWxGb3JtYXQuY291bnQoOCkgIT0gMCkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JtYXQgPSBmbGV4UGl4ZWxGb3JtYXRbOF07CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBDT0xPUl9Gb3JtYXRZVVZQMDEwOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcm1hdCA9IENPTE9SX0Zvcm1hdFlVVlAwMTA7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZsZXhTZW1pUGxhbmFyUGl4ZWxGb3JtYXQuY291bnQoMTApICE9IDApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9ybWF0ID0gZmxleFNlbWlQbGFuYXJQaXhlbEZvcm1hdFsxMF07CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChmbGV4UGl4ZWxGb3JtYXQuY291bnQoMTApICE9IDApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9ybWF0ID0gZmxleFBpeGVsRm9ybWF0WzEwXTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIE5vLW9wCkBAIC0xMjEzLDExICsxMjUwLDI1IEBACiAgICAgICAgIHN0ZDo6aW5pdGlhbGl6ZXJfbGlzdDxDMlBhcmFtOjpJbmRleD4gaW5kaWNlcyB7CiAgICAgICAgICAgICBjb2xvckFzcGVjdHNSZXF1ZXN0SW5kZXgud2l0aFN0cmVhbSgwdSksCiAgICAgICAgIH07Ci0gICAgICAgIGMyX3N0YXR1c190IGMyZXJyID0gY29tcC0+cXVlcnkoCi0gICAgICAgICAgICAgICAgeyAmdXNhZ2UsICZtYXhJbnB1dFNpemUsICZwcmVwZW5kIH0sCi0gICAgICAgICAgICAgICAgaW5kaWNlcywKLSAgICAgICAgICAgICAgICBDMl9ET05UX0JMT0NLLAotICAgICAgICAgICAgICAgICZwYXJhbXMpOworICAgICAgICBpbnQzMl90IGNvbG9yVHJhbnNmZXJSZXF1ZXN0ID0gMDsKKyAgICAgICAgaWYgKGNvbmZpZy0+bURvbWFpbiAmIChDb25maWc6OklTX0lNQUdFIHwgQ29uZmlnOjpJU19WSURFTykKKyAgICAgICAgICAgICAgICAmJiAhc2RrUGFyYW1zLT5maW5kSW50MzIoImNvbG9yLXRyYW5zZmVyLXJlcXVlc3QiLCAmY29sb3JUcmFuc2ZlclJlcXVlc3QpKSB7CisgICAgICAgICAgICBjb2xvclRyYW5zZmVyUmVxdWVzdCA9IDA7CisgICAgICAgIH0KKyAgICAgICAgYzJfc3RhdHVzX3QgYzJlcnIgPSBDMl9PSzsKKyAgICAgICAgaWYgKGNvbG9yVHJhbnNmZXJSZXF1ZXN0ICE9IDApIHsKKyAgICAgICAgICAgIGMyZXJyID0gY29tcC0+cXVlcnkoCisgICAgICAgICAgICAgICAgICAgIHsgJnVzYWdlLCAmbWF4SW5wdXRTaXplLCAmcHJlcGVuZCB9LAorICAgICAgICAgICAgICAgICAgICBpbmRpY2VzLAorICAgICAgICAgICAgICAgICAgICBDMl9ET05UX0JMT0NLLAorICAgICAgICAgICAgICAgICAgICAmcGFyYW1zKTsKKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIGMyZXJyID0gY29tcC0+cXVlcnkoCisgICAgICAgICAgICAgICAgICAgIHsgJnVzYWdlLCAmbWF4SW5wdXRTaXplLCAmcHJlcGVuZCB9LAorICAgICAgICAgICAgICAgICAgICB7fSwKKyAgICAgICAgICAgICAgICAgICAgQzJfRE9OVF9CTE9DSywKKyAgICAgICAgICAgICAgICAgICAgJnBhcmFtcyk7CisgICAgICAgIH0KICAgICAgICAgaWYgKGMyZXJyICE9IEMyX09LICYmIGMyZXJyICE9IEMyX0JBRF9JTkRFWCkgewogICAgICAgICAgICAgQUxPR0UoIkZhaWxlZCB0byBxdWVyeSBjb21wb25lbnQgaW50ZXJmYWNlOiAlZCIsIGMyZXJyKTsKICAgICAgICAgICAgIHJldHVybiBVTktOT1dOX0VSUk9SOwpAQCAtMTMzMiw4ICsxMzgzLDggQEAKICAgICAgICAgICAgIH0KICAgICAgICAgfQogCi0gICAgICAgIC8vIHNldCBjaGFubmVsLW1hc2sKICAgICAgICAgaWYgKGNvbmZpZy0+bURvbWFpbiAmIENvbmZpZzo6SVNfQVVESU8pIHsKKyAgICAgICAgICAgIC8vIHNldCBjaGFubmVsLW1hc2sKICAgICAgICAgICAgIGludDMyX3QgbWFzazsKICAgICAgICAgICAgIGlmIChtc2ctPmZpbmRJbnQzMihLRVlfQ0hBTk5FTF9NQVNLLCAmbWFzaykpIHsKICAgICAgICAgICAgICAgICBpZiAoY29uZmlnLT5tRG9tYWluICYgQ29uZmlnOjpJU19FTkNPREVSKSB7CkBAIC0xMzQyLDYgKzEzOTMsMTUgQEAKICAgICAgICAgICAgICAgICAgICAgY29uZmlnLT5tT3V0cHV0Rm9ybWF0LT5zZXRJbnQzMihLRVlfQ0hBTk5FTF9NQVNLLCBtYXNrKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIC8vIHNldCBQQ00gZW5jb2RpbmcKKyAgICAgICAgICAgIGludDMyX3QgcGNtRW5jb2RpbmcgPSBrQXVkaW9FbmNvZGluZ1BjbTE2Yml0OworICAgICAgICAgICAgbXNnLT5maW5kSW50MzIoS0VZX1BDTV9FTkNPRElORywgJnBjbUVuY29kaW5nKTsKKyAgICAgICAgICAgIGlmIChlbmNvZGVyKSB7CisgICAgICAgICAgICAgICAgY29uZmlnLT5tSW5wdXRGb3JtYXQtPnNldEludDMyKCJhbmRyb2lkLl9jb25maWctcGNtLWVuY29kaW5nIiwgcGNtRW5jb2RpbmcpOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICBjb25maWctPm1PdXRwdXRGb3JtYXQtPnNldEludDMyKCJhbmRyb2lkLl9jb25maWctcGNtLWVuY29kaW5nIiwgcGNtRW5jb2RpbmcpOworICAgICAgICAgICAgfQogICAgICAgICB9CiAKICAgICAgICAgc3RkOjp1bmlxdWVfcHRyPEMyUGFyYW0+IGNvbG9yVHJhbnNmZXJSZXF1ZXN0UGFyYW07CkBAIC0xMzUxLDExICsxNDExLDYgQEAKICAgICAgICAgICAgICAgICBjb2xvclRyYW5zZmVyUmVxdWVzdFBhcmFtID0gc3RkOjptb3ZlKHBhcmFtKTsKICAgICAgICAgICAgIH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AgICAgICAgICAgICAgICBpZiAoYmxvY2spIHsKICAgICAgICAgICAgICAgICAgICAgYnVmZmVyID0gR3JhcGhpY0Jsb2NrQnVmZmVyOjpBbGxvY2F0ZSgKQEAgLTE0MjEsNiArMTQ3NiwzNSBAQAogICAgICAgICAgICAgfQogICAgICAgICB9CiAKKyAgICAgICAgaWYgKGNvbmZpZy0+bVR1bm5lbGVkKSB7CisgICAgICAgICAgICBjb25maWctPm1PdXRwdXRGb3JtYXQtPnNldEludDMyKCJhbmRyb2lkLl90dW5uZWxlZCIsIDEpOworICAgICAgICB9CisKKyAgICAgICAgLy8gQ29udmVydCBhbiBlbmNvZGluZyBzdGF0aXN0aWNzIGxldmVsIHRvIGNvcnJlc3BvbmRpbmcgZW5jb2Rpbmcgc3RhdGlzdGljcworICAgICAgICAvLyBraW5kcworICAgICAgICBpbnQzMl90IGVuY29kaW5nU3RhdGlzdGljc0xldmVsID0gVklERU9fRU5DT0RJTkdfU1RBVElTVElDU19MRVZFTF9OT05FOworICAgICAgICBpZiAoKGNvbmZpZy0+bURvbWFpbiAmIENvbmZpZzo6SVNfRU5DT0RFUikKKyAgICAgICAgICAgICYmIChjb25maWctPm1Eb21haW4gJiBDb25maWc6OklTX1ZJREVPKQorICAgICAgICAgICAgJiYgbXNnLT5maW5kSW50MzIoS0VZX1ZJREVPX0VOQ09ESU5HX1NUQVRJU1RJQ1NfTEVWRUwsICZlbmNvZGluZ1N0YXRpc3RpY3NMZXZlbCkpIHsKKyAgICAgICAgICAgIC8vIEhpZ2hlciBsZXZlbCBpbmNsdWRlIGFsbCB0aGUgZW5jIHN0YXRzIGJlbG9uZyB0byBsb3dlciBsZXZlbC4KKyAgICAgICAgICAgIHN3aXRjaCAoZW5jb2RpbmdTdGF0aXN0aWNzTGV2ZWwpIHsKKyAgICAgICAgICAgICAgICAvLyBjYXNlIFZJREVPX0VOQ09ESU5HX1NUQVRJU1RJQ1NfTEVWRUxfMjogLy8gcmVzZXJ2ZWQgZm9yIHRoZSBmdXR1cmUgbGV2ZWwgMgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyB3aXRoIG1vcmUgZW5jIHN0YXQga2luZHMKKyAgICAgICAgICAgICAgICAvLyBGdXR1cmUgZXh0ZW5kZWQgZW5jb2Rpbmcgc3RhdGlzdGljcyBmb3IgdGhlIGxldmVsIDIgc2hvdWxkIGJlIGFkZGVkIGhlcmUKKyAgICAgICAgICAgICAgICBjYXNlIFZJREVPX0VOQ09ESU5HX1NUQVRJU1RJQ1NfTEVWRUxfMToKKyAgICAgICAgICAgICAgICAgICAgY29uZmlnLT5zdWJzY3JpYmVUb0NvbmZpZ1VwZGF0ZSgKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQzJBbmRyb2lkU3RyZWFtQXZlcmFnZUJsb2NrUXVhbnRpemF0aW9uSW5mbzo6b3V0cHV0OjpQQVJBTV9UWVBFLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDMlN0cmVhbVBpY3R1cmVUeXBlSW5mbzo6b3V0cHV0OjpQQVJBTV9UWVBFLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOworICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICBjYXNlIFZJREVPX0VOQ09ESU5HX1NUQVRJU1RJQ1NfTEVWRUxfTk9ORToKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICAgICAgQUxPR0QoImVuY29kaW5nIHN0YXRpc3RpY3MgbGV2ZWwgPSAlZCIsIGVuY29kaW5nU3RhdGlzdGljc0xldmVsKTsKKwogICAgICAgICBBTE9HRCgic2V0dXAgZm9ybWF0cyBpbnB1dDogJXMiLAogICAgICAgICAgICAgICAgIGNvbmZpZy0+bUlucH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XaW5kb3cgKj4oc3VyZmFjZS5nZXQoKSk7CisgICAgICAgIHN0YXR1c190IGVyciA9IE9LOworCiAgICAgICAgIGlmIChjb25maWctPm1UdW5uZWxlZCAmJiBjb25maWctPm1TaWRlYmFuZEhhbmRsZSAhPSBudWxscHRyKSB7Ci0gICAgICAgICAgICBzcDxBTmF0aXZlV2luZG93PiBuYXRpdmVXaW5kb3cgPSBzdGF0aWNfY2FzdDxBTmF0aXZlV2luZG93ICo+KHN1cmZhY2UuZ2V0KCkpOwotICAgICAgICAgICAgc3RhdHVzX3QgZXJyID0gbmF0aXZlX3dpbmRvd19zZXRfc2lkZWJhbmRfc3RyZWFtKAorICAgICAgICAgICAgZXJyID0gbmF0aXZlX3dpbmRvd19zZXRfc2lkZWJhbmRfc3RyZWFtKAogICAgICAgICAgICAgICAgICAgICBuYXRpdmVXaW5kb3cuZ2V0KCksCiAgICAgICAgICAgICAgICAgICAgIGNvbnN0X2Nhc3Q8bmF0aXZlX2hhbmRsZV90ICo+KGNvbmZpZy0+bVNpZGViYW5kSGFuZGxlLT5oYW5kbGUoKSkpOwogICAgICAgICAgICAgaWYgKGVyciAhPSBPSykgewpAQCAtMTkwNiw2ICsyMDIwLDE1IEBACiAgICAgICAgICAgICAgICAgICAgICAgICBuYXRpdmVXaW5kb3cuZ2V0KCksIGNvbmZpZy0+bVNpZGViYW5kSGFuZGxlLT5oYW5kbGUoKSwgZXJyKTsKICAgICAgICAgICAgICAgICByZXR1cm4gZXJyOwogICAgICAgICAgICAgfQorICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgLy8gRXhwbGljaXRseSByZXNldCB0aGUgc2lkZWJhbmQgaGFuZGxlIG9mIHRoZSB3aW5kb3cgZm9yCisgICAgICAgICAgICAvLyBub24tdHVubmVsZWQgdmlkZW8gaW4gY2FzZSB0aGUgd2luZG93IHdhcyBwcmV2aW91c2x5IHVzZWQKKyAgICAgICAgICAgIC8vIGZvciBhIHR1bm5lbGVkIHZpZGVvIHBsYXli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25hbFNldFBhcmFtZXRlcnMoY29uc3Qgc3A8QU1lc3NhZ2U+ICZtc2cpIHsKQEAgLTIyOTksNyArMjQyOSw4IEBACiAgICAgICAgICAgICAgICAgICAgICAgICBDMlN0cmVhbUNvbG9yQXNwZWN0c0luZm86Om91dHB1dDo6UEFSQU1fVFlQRSwKICAgICAgICAgICAgICAgICAgICAgICAgIEMyU3RyZWFtRGF0YVNwYWNlSW5mbzo6b3V0cHV0OjpQQVJBTV9UWVBFLAogICAgICAgICAgICAgICAgICAgICAgICAgQzJTdHJlYW1IZHJTdGF0aWNJbmZvOjpvdXRwdXQ6OlBBUkFNX1RZUEUsCi0gICAgICAgICAgICAgICAgICAgICAgICBDMlN0cmVhbUhkcjEwUGx1c0luZm86Om91dHB1dDo6UEFSQU1fVFlQRSwKKyAgICAgICAgICAgICAgICAgICAgICAgIEMyU3RyZWFtSGRyMTBQbHVzSW5mbzo6b3V0cHV0OjpQQVJBTV9UWVBFLCAgLy8gd2lsbCBiZSBkZXByZWNhdGVkCisgICAgICAgICAgICAgICAgICAgICAgICBDMlN0cmVhbUhkckR5bmFtaWNNZXRhZGF0YUluZm86Om91dHB1dDo6UEFSQU1fVFlQRSwKICAgICAgICAgICAgICAgICAgICAgICAgIEMyU3RyZWFtUGl4ZWxBc3BlY3RSYXRpb0luZm86Om91dHB1dDo6UEFSQU1fVFlQRSwKICAgICAgICAgICAgICAgICAgICAgICAgIEMyU3RyZWFtU3VyZmFjZVNjYWxpbmdJbmZvOjpvdXRwdXQ6OlBBUkFNX1RZUEUKICAgICAgICAgICAgICAgICAgICAgfTsKQEAgLTI1NDYsNyArMjY3NywxMCBAQAogICAgICAgICBzdGQ6OnZlY3RvcjxzdGQ6OnVuaXF1ZV9wdHI8QzJQYXJhbT4+IHBhcmFtczsKICAgICAgICAgZXJyID0gaW50Zi0+cXVlcnkoCiAgICAgICAgICAgICAgICAgeyZtQXBpRmVhdHVyZXN9LAotICAgICAgICAgICAgICAgIHtDMlBvcnRBbGxvY2F0b3JzVHVuaW5nOjppbnB1dDo6UEFSQU1fVFlQRX0sCisgICAgICAgICAgICAgICAgeworICAgICAgICAgICAgICAgICAgICBDMlN0cmVhbUJ1ZmZlclR5cGVTZXR0aW5nOjppbnB1dDo6UEFSQU1fVFlQRSwKKyAgICAgICAgICAgICAgICAgICAgQzJQb3J0QWxsb2NhdG9yc1R1bmluZzo6aW5wdXQ6OlBBUkFNX1RZUEUKKyAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgIEMyX01BWV9CTE9DSywKICAgICAgICAgICAgICAgICAmcGFyYW1zKTsKICAgICAgICAgaWYgKGVyciAhPSBDMl9PSyAmJiBlcnIgIT0gQzJfQkFEX0lOREVYKSB7CkBAIC0yNTU5LDcgKzI2OTMsMTAgQEAKICAgICAgICAgICAgIGlmICghcGFyYW0pIHsKICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGlmIChwYXJhbS0+dHlwZSgpID09IEMyUG9ydEFsbG9jYXRvcnNUdW5pbmc6OmlucHV0OjpQQVJBTV9UWVBFKSB7CisgICAgICAgICAgICBpZiAocGFyYW0tPnR5cGUoKSA9PSBDMlN0cmVhbUJ1ZmZlclR5cGVTZXR0aW5nOjppbnB1dDo6UEFSQU1fVFlQRSkgeworICAgICAgICAgICAgICAgIG1JbnB1dFN0cmVhbUZvcm1hdC5yZXNldCgKKyAgICAgICAgICAgICAgICAgICAgICAgIEMyU3RyZWFtQnVmZmVyVHlwZVNldHRpbmc6OmlucHV0OjpGcm9tKHBhcmFtKSk7CisgICAgICAgICAgICB9IGVsc2UgaWYgKHBhcmFtLT50eXBlKCkgPT0gQzJQb3J0QWxsb2NhdG9yc1R1bmluZzo6aW5wdXQ6OlBBUkFNX1RZUEUpIHsKICAgICAgICAgICAgICAgICBtSW5wdXRBbGxvY2F0b3JzLnJlc2V0KAogICAgICAgICAgICAgICAgICAgICAgICAgQzJQb3J0QWxsb2NhdG9yc1R1bm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ucHV0QnVmZmVyOiBidWZmZXIgY29waWVkOyAlc3JlbGVhc2VkIiwKICAgICAgICAgICAgICAgICAgICAgICBtTmFtZSwgcmVsZWFzZWQgPyAiIiA6ICJub3QgIik7Ci0gICAgICAgICAgICAgICAgYnVmZmVyLmNsZWFyKCk7CisgICAgICAgICAgICAgICAgYnVmZmVyID0gY29weTsKICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgQUxPR1coIlslc10gcXVldWVJbnB1dEJ1ZmZlcjogZmFpbGVkIHRvIGNvcHkgYSBidWZmZXI7IHRoaXMgbWF5IGNhdXNlIGlucHV0ICIKICAgICAgICAgICAgICAgICAgICAgICAiYnVmZmVyIHN0YXJ2YXRpb24gb24gY29tcG9uZW50LiIsIG1OYW1lKTsKQEAgLTI4Miw2ICsyODUsMTIgQEAKICAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgIH0gZWxzZSBpZiAoZW9zKSB7CisgICAgICAgIE11dGV4ZWQ8SW5wdXQ+OjpMb2NrZWQgaW5wdXQobUlucHV0KTsKKyAgICAgICAgaWYgKGlucHV0LT5mcmFtZVJlYXNzZW1ibGVyKSB7CisgICAgICAgICAgICB1c2VzRnJhbWVSZWFzc2VtYmxlciA9IHRydWU7CisgICAgICAgICAgICAvLyBkcmFpbiBhbnkgcGVuZGluZyBpdGVtcyB3aXRoIGVvcworICAgICAgICAgICAgaW5wdXQtPmZyYW1lUmVhc3NlbWJsZXIucHJvY2VzcyhidWZmZXIsICZpdGVtcyk7CisgICAgICAgIH0KICAgICAgICAgZmxhZ3MgfD0gQzJGcmFtZURhdGE6OkZMQUdfRU5EX09GX1NUUkVBTTsKICAgICB9CiAgICAgaWYgKHVzZXNGcmFtZVJlYXNzZW1ibGVyKSB7CkBAIC0zMjEsNiArMzMwLDggQEAKICAgICB9CiAgICAgYzJfc3RhdHVzX3QgZXJyID0gQzJfT0s7CiAgICAgaWYgKCFpdGVtcy5lbXB0eSgpKSB7CisgICAgICAgIFNjb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WN0dXJlIGRlZmluaXRpb25zIHNob3VsZCBtYXRjaCBhcyBjaGVja2VkIGluIERlc2NyYW1ibGVySW1wbC5jcHAuCkBAIC01MTIsMTYgKzUyMCwyMiBAQAogICAgICAgICB9CiAKICAgICAgICAgaWYgKHJlc3VsdCA8IGNvZGVjRGF0YU9mZnNldCkgewotICAgICAgICAgICAgQUxPR0QoImludmFsaWQgY29kZWMgZGF0YSBvZmZzZXQ6ICV6ZCwgcmVzdWx0ICV6ZCIsIGNvZGVjRGF0YU9mZnNldCwgcmVzdWx0KTsKKyAgICAgICAgICAgIEFMT0dEKCJbJXNdIGludmFsaWQgY29kZWMgZGF0YSBvZmZzZXQ6ICV6ZCwgcmVzdWx0ICV6ZCIsCisgICAgICAgICAgICAgICAgICBtTmFtZSwgY29kZWNEYXRhT2Zmc2V0LCByZXN1bHQpOwogICAgICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKICAgICAgICAgfQogICAgIH0KICAgICBpZiAoIXNlY3VyZSkgewogICAgICAgICBDMldyaXRlVmlldyB2aWV3ID0gYmxvY2stPm1hcCgpLmdldCgpOwogICAgICAgICBpZiAodmlldy5lcnJvcigpICE9IEMyX09LKSB7CisgICAgICAgICAgICBBTE9HSSgiWyVzXSBhdHRhY2hFbmNyeXB0ZWRCdWZmZXI6IGJsb2NrIG1hcCBlcnJvcjogJWQgKG5vbi1zZWN1cmUpIiwKKyAgICAgICAgICAgICAgICAgIG1OYW1lLCB2aWV3LmVycm9yKCkpOwogICAgICAgICAgICAgcmV0dXJuIFVOS05PV05fRVJST1I7CiAgICAgICAgIH0KICAgICAgICAgaWYgKHZpZXcuc2l6ZSgpIDwgcmVzdWx0KSB7CisgICAgICAgICAgICBBTE9HSSgiWyVzXSBhdHRhY2hFbmNyeXB0ZWRCdWZmZXI6IGJsb2NrIHNpemUgdG9vIHNtYWxsOiBzaXplPSV1IHJlc3VsdD0lemQgIgorICAgICAgICAgICAgICAgICAgIihub24tc2VjdXJlKSIsCisgICAg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EFSQU1fVFlQRSkpOworICAgIC8vIFRPRE86IG1ha2UgdGhpcyBzdGlja3kgJiBlbmFibGUgdW5zZXQKKyAgICBpZiAoaGRyRHluYW1pY0luZm8gJiYgaGRyRHluYW1pY0luZm8tPmZsZXhDb3VudCgpID09IDApIHsKKyAgICAgICAgaGRyRHluYW1pY0luZm8ucmVzZXQoKTsKKyAgICB9CisKKyAgICBpZiAoaGRyMTBQbHVzSW5mbykgeworICAgICAgICAvLyBDMlN0cmVhbUhkcjEwUGx1c0luZm8gaXMgZGVwcmVjYXRlZDsgY29tcG9uZW50cyBzaG91bGQgdXNlCisgICAgICAgIC8vIEMyU3RyZWFtSGRyRHluYW1pY01ldGFkYXRhSW5mbworICAgICAgICAvLyBUT0RPOiAjbWV0cmljCisgICAgICAgIGlmIChoZHJEeW5hbWljSW5mbykgeworICAgICAgICAgICAgLy8gSXQgaXMgdW5leHBlY3RlZCB0aGF0IEMyU3RyZWFtSGRyMTBQbHVzSW5mbyBhbmQKKyAgICAgICAgICAgIC8vIEMyU3RyZWFtSGRyRHluYW1pY01ldGFkYXRhSW5mbyBpcyBib3RoIHByZXNlbnQuCisgICAgICAgICAgICAvLyBDMlN0cmVhbUhkckR5bmFtaWNNZXRhZGF0YUluZm8gdGFrZXMgcHJpb3JpdHkuCisgICAgICAgICAgICAvLyBUT0RPOiAjbWV0cmljCisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICBzdGQ6OnNoYXJlZF9wdHI8QzJTdHJlYW1IZHJEeW5hbWljTWV0YWRhdGFJbmZvOjpvdXRwdXQ+IGluZm8gPQorICAgICAgICAgICAgICAgICAgICBDMlN0cmVhbUhkckR5bmFtaWNNZXRhZGF0YUluZm86Om91dHB1dDo6QWxsb2NTaGFyZWQoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGRyMTBQbHVzSW5mby0+ZmxleENvdW50KCksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgMHUsCisgICAgICAgICAgICAgICAgICAgICAgIC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NlPjo6bWFrZShmZW5jZUZkKTsKKyAgICAgICAgaWYgKCFmZW5jZSkgeworICAgICAgICAgICAgQUxPR0UoIlslc10gRmFpbGVkIHRvIGFsbG9jYXRlIGEgZmVuY2UiLCBtTmFtZSk7CisgICAgICAgICAgICBjbG9zZShmZW5jZUZkKTsKKyAgICAgICAgICAgIHJldHVybiBOT19NRU1PUlk7CisgICAgICAgIH0KKyAgICB9CiAKICAgICAvLyBUT0RPOiByZXZpc2l0IHRoaXMgYWZ0ZXIgQzJGZW5jZSBpbXBsZW1lbnRhdGlvbi4KICAgICBhbmRyb2lkOjpJR3JhcGhpY0J1ZmZlclByb2R1Y2VyOjpRdWV1ZUJ1ZmZlcklucHV0IHFiaSgKQEAgLTg1Miw4ICs5MDksOCBAQAogICAgICAgICAgICAgICAgICBibG9ja3MuZnJvbnQoKS5jcm9wKCkuYm90dG9tKCkpLAogICAgICAgICAgICAgdmlkZW9TY2FsaW5nTW9kZSwKICAgICAgICAgICAgIHRyYW5zZm9ybSwKLSAgICAgICAgICAgIEZlbmNlOjpOT19GRU5DRSwgMCk7Ci0gICAgaWYgKGhkclN0YXRpY0luZm8gfHwgaGRyMTBQbHVzSW5mbykgeworICAgICAgICAgICAgZmVuY2UsIDApOworICAgIGlmIChoZHJTdGF0aWNJbmZvIHx8IGhkckR5bmFtaWNJbmZvKSB7CiAgICAgICAgIEhkck1ldGFkYXRhIGhkcjsKICAgICAgICAgaWYgKGhkclN0YXRpY0luZm8pIHsKICAgICAgICAgICAgIC8vIElmIG1hc3RlcmluZyBtYXggYW5kIG1pbiBsdW1pbmFuY2UgZmllbGRzIGFyZSAwLCBkbyBub3QgdXNlIHRoZW0uCkBAIC04ODksMTQgKzk0NiwyMiBAQAogICAgICAgICAgICAgICAgIGhkci52YWxpZFR5cGVzIHw9IEhkck1ldGFkYXRhOjpDVEE4NjFfMzsKICAgICAgICAgICAgICAgICBoZHIuY3RhODYxMyA9IGN0YTg2MV9tZXRhOwogICAgICAgICAgICAgfQorCisgICAgICAgICAgICAvLyBkb2VzIG5vdCBoYXZlIHZhbGlkIGluZm8KKyAgICAgICAgICAgIGlmICghKGhkci52YWxpZFR5cGVzICYgKEhkck1ldGFkYXRhOjpTTVBURTIwODYgfCBIZHJNZXRhZGF0YTo6Q1RBODYxXzMpKSkgeworICAgICAgICAgICAgICAgIGhkclN0YXRpY0luZm8ucmVzZXQoKTsKKyAgICAgICAgICAgIH0KICAgICAgICAgfQotICAgICAgICBpZiAoaGRyMTBQbHVzSW5mbykgeworICAgICAgICBpZiAoaGRyRHluYW1pY0luZm8KKyAgICAgICAgICAgICAgICAmJiBoZHJEeW5hbWljSW5mby0+bS50eXBlXyA9PSBDMkNvbmZpZzo6SERSX0RZTkFNSUNfTUVUQURBVEFfVFlQRV9TTVBURV8yMDk0XzQwKSB7CiAgICAgICAgICAgICBoZHIudmFsaWRUeXBlcyB8PSBIZHJNZXRhZGF0YTo6SERSMTBQTFVTOwogICAgICAgICAgICAgaGRyLmhkcjEwcGx1cy5hc3NpZ24oCi0gICAgICAgICAgICAgICAgICAgIGhkcjEwUGx1c0luZm8tPm0udmFsdWUsCi0gICAgICAgICAgICAgICAgICAgIGhkcjEwUGx1c0luZm8tPm0udmFsdWUgKyBoZHIxMFBsdXNJbmZvLT5mbGV4Q291bnQoKSk7CisgICAgICAgICAgICAgICAgICAgIGhkckR5bmFtaWNJbmZvLT5tLmRhdGEsCisgICAgICAgICAgICAgICAgICAgIGhkckR5bmFtaWNJbmZvLT5tLmRhdGEgKyBoZHJEeW5hbWljSW5mby0+ZmxleENvdW50KCkpOwogICAgICAgICB9CiAgICAgICAgIHFiaS5zZXRIZHJNZXRhZGF0YShoZHIpOworCisgICAgICAgIFNldEhkck1ldGFkYXRhVG9HcmFsbG9jNEhhbmRsZShoZHJTdGF0aWNJbmZvLCBoZHJEeW5hbWljSW5mbywgYmxvY2suaGFuZGxlKCkpOwogICAgIH0KICAgICAvLyB3ZSBkb24ndCBoYXZlIGRpcnR5IHJlZ2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yIEBACiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogICAgICAgICB9CisKKyAgICAgICAgaW50MzJfdCB0dW5uZWxlZCA9IDA7CisgICAgICAgIGlmICghb3V0cHV0Rm9ybWF0LT5maW5kSW50MzIoImFuZHJvaWQuX3R1bm5lbGVkIiwgJnR1bm5lbGVkKSkgeworICAgICAgICAgICAgdHVubmVsZWQgPSAwOworICAgICAgICB9CisgICAgICAgIG1UdW5uZWxlZCA9ICh0dW5uZWxlZCAhPSAwKTsKICAgICB9CiAKICAgICAvLyBTZXQgdXAgcGlwZWxpbmUgY29udHJvbC4gVGhpcyBoYXMgdG8gYmUgZG9uZSBhZnRlciBtSW5wdXRCdWZmZXJzIGFuZApAQCAtMTQwMyw1NCArMTQ4MSw0NyBAQAogICAgIHJldHVybiBPSzsKIH0KIAotc3RhdHVzX3QgQ0NvZGVjQnVmZmVyQ2hhbm5lbDo6cmVxdWVzdEluaXRpYWxJbnB1dEJ1ZmZlcnMoKSB7CitzdGF0dXNfdCBDQ29kZWNCdWZmZXJDaGFubmVsOjpwcmVwYXJlSW5pdGlhbElucHV0QnVmZmVycygKKyAgICAgICAgc3RkOjptYXA8c2l6ZV90LCBzcDxNZWRpYUNvZGVjQnVmZmVyPj4gKmNsaWVudElucHV0QnVmZmVycykgewogICAgIGlmIChtSW5wdXRTdXJmYWNlKSB7CiAgICAgICAgIHJldHVybiBPSzsKICAgICB9CiAKKyAgICBzaXplX3QgbnVtSW5wdXRTbG90cyA9IG1JbnB1dC5sb2NrKCktPm51bVNsb3RzOworCisgICAgeworICAgICAgICBNdXRleGVkPElucHV0Pjo6TG9ja2VkIGlucHV0KG1JbnB1dCk7CisgICAgICAgIHdoaWxlIChjbGllbnRJbnB1dEJ1ZmZlcnMtPnNpemUoKSA8IG51bUlucHV0U2xvdHMpIHsKKyAgICAgICAgICAgIHNpemVfdCBpbmRleDsKKyAgICAgICAgICAgIHNwPE1lZGlhQ29kZWNCdWZmZXI+IGJ1ZmZ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fSUYobURhdGFDb252ZXJ0ZXIsICJbJXNdIENvbnZlcnRlciBjcmVhdGVkIGZyb20gJWQgdG8gJWQiLAorICAgICAgICAgICAgICAgICAgICAgICAgIG1OYW1lLCBjb2RlY0VuY29kaW5nLCBjb25maWdFbmNvZGluZyk7CisgICAgICAgICAgICAgICAgbUZvcm1hdFdpdGhDb252ZXJ0ZXIgPSBtRm9ybWF0LT5kdXAoKTsKKyAgICAgICAgICAgICAgICBtRm9ybWF0V2l0aENvbnZlcnRlci0+c2V0SW50MzIoS0VZX1BDTV9FTkNPRElORywgY29uZmlnRW5jb2RpbmcpOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICBtRGF0YUNvbnZlcnRlciA9IG51bGxwdHI7CisgICAgICAgICAgICAgICAgbUZvcm1hdFdpdGhDb252ZXJ0ZXIgPSBudWxscHRyOworICAgICAgICAgICAgfQorICAgICAgICAgICAgbVNyY0VuY29kaW5nID0gY29kZWNFbmNvZGluZzsKKyAgICAgICAgICAgIG1Ec3RFbmNvZGluZyA9IGNvbmZpZ0VuY29kaW5nOworICAgICAgICB9CisgICAgICAgIGlmIChpbnQgZW5jb2Rpbmc7ICFtRm9ybWF0LT5maW5kSW50MzIoS0VZX1BDTV9FTkNPRElORywgJmVuY29kaW5nKQorICAgICAgICAgICAgICAgIHx8IGVuY29kaW5nICE9IG1Ec3RFbmNvZGluZykgeworICAgICAgICB9CisgICAgfQorICAgIGlmICghbURhdGFDb252ZXJ0ZXIpIHsKKyAgICAgICAgcmV0dXJuIGZhbHNlOworICAgIH0KKyAgICBzcDxNZWRpYUNvZGVjQnVmZmVyPiBzcmNCdWZmZXI7CisgICAgaWYgKHNyYykgeworICAgICAgICBzcmNCdWZmZXIgPSBDb25zdExpbmVhckJsb2NrQnVmZmVyOjpBbGxvY2F0ZShtRm9ybWF0LCBzcmMpOworICAgIH0gZWxzZSB7CisgICAgICAgIHNyY0J1ZmZlciA9IG5ldyBNZWRpYUNvZGVjQnVmZ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XBwZXIoS0VZX1NBTVBMRV9SQVRFLCAgIEMyX1BBUkFNS0VZX0NPREVEX1NBTVBMRV9SQVRFLCAgInZhbHVlIikKICAgICAgICAgLmxpbWl0VG8oRDo6QVVESU8gJiBEOjpDT0RFRCkpOwogCi0gICAgYWRkKENvbmZpZ01hcHBlcihLRVlfUENNX0VOQ09ESU5HLCAgQzJfUEFSQU1LRVlfUENNX0VOQ09ESU5HLCAgICAgICAidmFsdWUiKQorICAgIGF1dG8gcGNtRW5jb2RpbmdNYXBwZXIgPSBbXShDMlZhbHVlIHYpIC0+IEMyVmFsdWUgeworICAgICAgICBpbnQzMl90IHZhbHVlOworICAgICAgICBDMkNvbmZpZzo6cGNtX2VuY29kaW5nX3QgdG87CisgICAgICAgIGlmICh2LmdldCgmdmFsdWUpICYmIEMyTWFwcGVyOjptYXAodmFsdWUsICZ0bykpIHsKKyAgICAgICAgICAgIHJldHVybiB0bzsKKyAgICAgICAgfQorICAgICAgICByZXR1cm4gQzJWYWx1ZSgpOworICAgIH07CisgICAgYXV0byBwY21FbmNvZGluZ1JldmVyc2UgPSBbXShDMlZhbHVlIHYpIC0+IEMyVmFsdWUgeworICAgICAgICBDMkNvbmZpZzo6cGNtX2VuY29kaW5nX3QgdmFsdWU7CisgICAgICAgIGludDMyX3QgdG87CisgICAgICAgIHVzaW5nIEMyVmFsdWVUeXBlPXR5cGVuYW1lIF9jMl9yZWR1Y2VfZW51bV90b191bmRlcmx5aW5nX3R5cGU8ZGVjbHR5cGUodmFsdWUpPjo6dHlwZTsKKyAgICAgICAgaWYgKHYuZ2V0KChDMlZhbHVlVHlwZSopJnZhbHVlKSAmJiBDMk1hcHBlcjo6bWFwKHZhbHVlLCAmdG8pKSB7CisgICAgICAgICAgICByZXR1cm4gdG87CisgICAgICAgIH0KKyAgICAgICAgcmV0dXJuIEMyVmFsdWUoKTsKKyAgICB9OworICAgIGFkZChDb25maWdNYXBwZXIoS0VZX1BDTV9FTkNPRElORywgICAgICAgICAgICAgIE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eworICAgICAgICAgICAgaW50MzJfdCBzZGs7CisgICAgICAgICAgICBDMkNvbmZpZzo6cGljdHVyZV90eXBlX3QgYzI7CisgICAgICAgICAgICBpZiAodi5nZXQoJnNkaykgJiYgQzJNYXBwZXI6Om1hcChzZGssICZjMikpIHsKKyAgICAgICAgICAgICAgICByZXR1cm4gQzJWYWx1ZShjMik7CisgICAgICAgICAgICB9CisgICAgICAgICAgICByZXR1cm4gQzJWYWx1ZSgpOworICAgICAgICB9LCBbXShDMlZhbHVlIHYpIC0+IEMyVmFsdWUgeworICAgICAgICAgICAgQzJDb25maWc6OnBpY3R1cmVfdHlwZV90IGMyOworICAgICAgICAgICAgaW50MzJfdCBzZGsgPSBQSUNUVVJFX1RZUEVfVU5LTk9XTjsKKyAgICAgICAgICAgIHVzaW5nIEMyVmFsdWVUeXBlPXR5cGVuYW1lIF9jMl9yZWR1Y2VfZW51bV90b191bmRlcmx5aW5nX3R5cGU8ZGVjbHR5cGUoYzIpPjo6dHlwZTsKKyAgICAgICAgICAgIGlmICh2LmdldCgoQzJWYWx1ZVR5cGUqKSZjMikgJiYgQzJNYXBwZXI6Om1hcChjMiwgJnNkaykpIHsKKyAgICAgICAgICAgICAgICByZXR1cm4gc2RrOworICAgICAgICAgICAgfQorICAgICAgICAgICAgcmV0dXJuIEMyVmFsdWUoKTsKKyAgICAgICAgfSkpOworCisgICAgLyogc3RpbGwgdG8gZG8KICAgICAgICBub3QgeWV0IHVzZWQgYnkgTWVkaWFDb2RlYywgYnV0IGRlZmluZWQgYXMgTWVkaWFGb3JtYXQKICAgICBLRVlfQVVESU9fU0VTU0lPTl9JRCAvLyB3ZSB1c2UgImF1ZGlvLWh3LXN5bmMiCiAgICAgS0VZX09VVFBVVF9SRU9SREVSX0RFUFRICkBAIC0xMDYwLDYgKzExMjcsMTMgQEAKICAgICAgICAgICAgICAgICAgICAgQzJfUEFSQU1LRVlfU1VSRkFDRV9TQ0FMSU5HX01PREUpOwogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgYWRkTG9jYWxQYXJhbShuZXcgQzJTdHJlYW1Db2xvckFzcGVjdHNJbmZvOjppbnB1dCgwdSksIEMyX1BBUkFNS0VZX0NPTE9SX0FTUEVDVFMpOworCisgICAgICAgICAgICBpZiAoZG9tYWluLnZhbHVlID09IEMyQ29tcG9uZW50OjpET01BSU5fVklERU8pIHsKKyAgICAgICAgICAgICAgICBhZGRMb2NhbFBhcmFtKG5ldyBDMkFuZHJvaWRTdHJlYW1BdmVyYWdlQmxvY2tRdWFudGl6YXRpb25JbmZvOjpvdXRwdXQoMHUsIDApLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQzJfUEFSQU1LRVlfQVZFUkFHRV9RUCk7CisgICAgICAgICAgICAgICAgYWRkTG9jYWxQYXJhbShuZXcgQzJTdHJlYW1QaWN0dXJlVHlwZUluZm86Om91dHB1dCgwdSwgMCksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDMl9QQVJBTUtFWV9QSUNUVVJFX1RZUEUpOworICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgfQogCkBAIC0xMDk0LDYgKzExNjgsMTcgQEAKICAgICAgICAgfQogICAgIH0KIAorICAgIC8vIFBhcmFtZXRlcnMgdGhhdCBhcmUgbm90IHN1YnNjcmliZWQgaW5pdGlhbGx5LCBidXQgY2FuIGJlIHN1YnNjcmliZWQKKyAgICAvLyB1cG9uIGV4cGxpY2l0IHJlcXVlc3QuCisgICAgc3RhdGljIGNvbnN0IHN0ZDo6aW5pdGlhbGl6ZXJfbGlzdDxDMlBhcmFtOjpJbmRleD4ga09wdGlvbmFsUGFyYW1zID0geworICAgICAgICBDMkFuZHJvaWRTdHJlYW1BdmVyYWdlQmxvY2tRdWFudGl6YXRpb25JbmZvOjpvdXRwdXQ6OlBBUkFNX1RZUEUsCisgICAgICAgIEMyU3RyZWFtUGljdHVyZVR5cGVJbmZvOjpvdXRwdXQ6OlBBUkFNX1RZUEUsCisgICAgfTsKKyAgICBmb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gaWYgKHAgJiYgKnApIHsKKyAgICAgICAgICAgIC8vIEFsbG93IHVuc3Vic2NyaWJlZCB2ZW5kb3IgcGFyYW1ldGVycyB0byBnbyB0aHJvdWdoIC0tLSBpdCBtYXkgYmUKKyAgICAgICAgICAgIC8vIGxhdGVyIGhhbmRsZWQgYnkgdGhlIGZvcm1hdCBzaGFwZXIuCisgICAgICAgICAgICBpZiAoIXAtPmlzVmVuZG9yKCkgJiYgbVN1YnNjcmliZWRJbmRpY2VzLmNvdW50KHAtPmluZGV4KCkpID09IDApIHsKKyAgICAgICAgICAgICAgICBBTE9HVigidXBkYXRlQ29uZmlndXJhdGlvbjogc2tpcHBlZCB1bnN1YnNjcmliZWQgcGFyYW0gJTA4eCIsIHAtPmluZGV4KCkpOworICAgICAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICAgICAgfQogICAgICAgICAgICAgYXV0byBpbnNlcnRpb24gPSBtQ3VycmVudENvbmZpZy5lbXBsYWNlKHAtPmluZGV4KCksIG51bGxwdHIpOwogICAgICAgICAgICAgaWYgKGluc2VydGlvbi5zZWNvbmQgfHwgKmluc2VydGlvbi5maXJzdC0+c2Vjb25kICE9ICpwKSB7CiAgICAgICAgICAgICAgICAgaWYgKG1TdXBwb3J0ZWRJbmRpY2VzLmNvdW50KHAtPmluZGV4KCkpIHx8IG1Mb2NhbFBhcmFtcy5jb3VudChwLT5pbmRleCgpKSkgewpAQCAtMTUxMyw2ICsxNjI0LDIyIEBACiAgICAgICAgICAgICBtc2ctPnJlbW92ZUVudHJ5QXQobXNnLT5maW5kRW50cnlCeU5hbWUoImN0YTg2MS5tYXgtY2xsIikpOwogICAgICAgICAgICAgbXNnLT5yZW1vdmVFbnRyeUF0KG1zZy0+ZmluZEVudHJ5QnlOYW1lKCJjdGE4NjEubWF4LWZhbGwiKSk7CiAgICAgICAgIH0KKworICAgICAgICAvLyBIRFIgZHluYW1pYyBpbmZvCisgICAgICAgIHN0ZDo6c3RyaW5nIGtleVByZWZpeCA9IGlucHV0ID8gQzJfUEFSQU1LRVlfSU5QVVRfSERSX0RZTkFNSUNfSU5GTworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6IEMyX1BBUkFNS0VZX09VVFBVVF9IRFJfRFlOQU1JQ19JTkZPOworICAgICAgICBzdGQ6OnN0cmluZyB0eXBlS2V5ID0ga2V5UHJlZml4ICsgIi50eXBlIjsKKyAgICAgICAgc3RkOjpzdHJpbmcgZGF0YUtleSA9IGtleVByZWZpeCArICIuZGF0YSI7CisgICAgICAgIGludDMyX3QgdHlwZTsKKyAgICAgICAgc3A8QUJ1ZmZlcj4gZGF0YTsKKyAgICAgICAgaWYgKG1zZy0+ZmluZEludDMyKHR5cGVLZXkuY19zdHIoKSwgJnR5cGUpCisgICAgICAgICAgICAgICAgJiYgbXNnLT5maW5kQnVmZmVyKGRhdGFLZXkuY19zdHIoKSwgJmRhdGEpKSB7CisgICAgICAgICAgICBpZiAodHlwZSA9PSBIRFJfRFlOQU1JQ19NRVRBREFUQV9UWVBFX1NNUFRFXzIwOTRfNDApIHsKKyAgICAgICAgICAgICAgICBtc2ctPnNldEJ1ZmZlcihLRVlfSERSMTBfUExVU19JTkZPLCBkYXRhKTsKKyAgICAgICAgICAgICAgICBtc2ctPnJlbW92ZUVudHJ5QXQobXNnLT5maW5kRW50cnlCeU5hbWUodHlwZUtleS5jX3N0cigpKSk7CisgICAgICAgICAgICAgICAgbXNnLT5yZW1vdmVFbnRyeUF0KG1zZy0+ZmluZEVudHJ5QnlOYW1lKGRhdGFLZXkuY19zdHIoKSkpOworICAgICAgICAgICAgfQorICAgICAgICB9CiAgICAgfQogCiAgICAgQUxPR1YoImNvbnZlcnRlZCB0byBTREsgdmFsdWVzIGFzICVzIiwgbXNnLT5kZWJ1Z1N0cmluZygpLmNfc3RyKCkpOwpAQCAtMTU5Niw2ICsxNzIzLDI3IEBACiAgICAgICAgICAgICAgICAgcGFyYW1zLT5zZXRGbG9hdChDMl9QQVJBTUtFWV9JTlBVVF9USU1FX1NUUkVUQ0gsIGNhcHR1cmVSYXRlIC8gZnJhbWVSYXRlKTsKICAgICAgICAgICAgIH0KICAgICAgICAgfQorCisgICAgICAgIC8vIGFkZCBIRFIgZm9ybWF0IGZvciB2aWRlbyBlbmNvZGluZworICAgICAgICBpZiAoY29uZmlnRG9tYWluID09IElTX0NPTkZJRykgeworICAgICAgICAgICAgLy8gZG9uJ3QgYXNzdW1lIGhlcmUgdGhhdCB0cmFuc2ZlciBpcyBzZXQgZm9yIEhEUiwgb25seSByZXF1aXJlIGl0IGZvciBITEcKKyAgICAgICAgICAgIGludCB0cmFuc2ZlciA9IDA7CisgICAgICAgICAgICBwYXJhbXMtPmZpbmRJbnQzMihLRVlfQ09MT1JfVFJBTlNGRVIsICZ0cmFuc2Zlcik7CisKKyAgICAgICAgICAgIGludCBwcm9maWxlOworICAgICAgICAgICAgaWYgKHBhcmFtcy0+ZmluZEludDMyKEtFWV9QUk9GSUxFLCAmcHJvZmlsZSkpIHsKKyAgICAgICAgICAgICAgICBzdGQ6OnNoYXJlZF9wdHI8QzJNYXBwZXI6OlByb2ZpbGVMZXZlbE1hcHBlcj4gbWFwcGVyID0KKyAgICAgICAgICAgICAgICAgICAgQzJNYXBwZXI6OkdldFByb2ZpbGVMZXZlbE1hcHBlcihtQ29kaW5nTWVkaWFUeXBlKTsKKyAgICAgICAgICAgICAgICBDMkNvbmZpZzo6aGRyX2Zvcm1hdF90IGMyID0gQzJDb25maWc6Omhkcl9mb3JtYXRfdDo6VU5LTk9XTjsKKyAgICAgICAgICAgICAgICBpZiAobWFwcGVyICYmIG1hcHBlci0+bWFwSGRyRm9ybWF0KHByb2ZpbGUsICZjMikpIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKGMyID09IEMyQ29uZmlnOjpoZHJfZm9ybWF0X3Q6OkhMRyAmJgorICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmZXIgIT0gQ09MT1JfVFJBTlNGRVJfSExHKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBjMiA9IEMyQ29uZmlnOjpoZHJfZm9ybWF0X3Q6OlVOS05PV047CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgcGFyYW1zLT5zZXRJbnQzMihDMl9QQVJBTUtFWV9IRFJfRk9STUFULCBjMik7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorICAgICAgICB9CiAgICAgfQogCiAgICAgeyAgIC8vIHJlZmxlY3QgdGVtcG9yYWwgbGF5ZXJpbmcgaW50byBhIGJpbmFyeSBibG9iCkBAIC0xNjkzLDYgKzE4NDEsMTYgQEAKICAgICAgICAgICAgICAgICBwYXJhbXMtPnNldEZsb2F0KCJjdGE4NjEubWF4LWZhbGwiLCBtZXRhLT5zVHlwZTEubU1heEZyYW1lQXZlcmFnZUxpZ2h0TGV2ZWwpOwogICAgICAgICAgICAgfQogICAgICAgICB9CisKKyAgICAgICAgc3A8QUJ1ZmZlcj4gaGRyRHluYW1pY0luZm87CisgICAgICAgIGlmIChwYXJhbXMtPmZpbmRCdWZmZXIoS0VZX0hEUjEwX1BMVVNfSU5GTywgJmhkckR5bmFtaWNJbmZvKSkgeworICAgICAgICAgICAgZm9yIChjb25zdCBzdGQ6OnN0cmluZyAmcHJlZml4IDogeyBDMl9QQVJBTUtFWV9JTlBVVF9IRFJfRFlOQU1JQ19JTkZPLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDMl9QQVJBTUtFWV9PVVRQVVRfSERSX0RZTkFNSUNfSU5GTyB9KSB7CisgICAgICAgICAgICAgICAgcGFyYW1zLT5zZXRJbnQzMigocHJlZml4ICsgIi50eXBlIikuY19zdHIoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEhEUl9EWU5BTUlDX01FVEFEQVRBX1RZUEVfU01QVEVfMjA5NF80MCk7CisgICAgICAgICAgICAgICAgcGFyYW1zLT5zZXRCdWZmZXIoKHByZWZpeC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A6CisgICAgICAgICAgICAgICAgICAgICAgICBjbGllbnRCaXREZXB0aCA9IDEwOworICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgICAgIGNhc2UgQ09MT1JfRm9ybWF0WVVWNDExUGFja2VkUGxhbmFyOgorICAgICAgICAgICAgICAgICAgICBjYXNlIENPTE9SX0Zvcm1hdFlVVjQxMVBsYW5hcjoKKyAgICAgICAgICAgICAgICAgICAgY2FzZSBDT0xPUl9Gb3JtYXRZVVY0MjBGbGV4aWJsZToKKyAgICAgICAgICAgICAgICAgICAgY2FzZSBDT0xPUl9Gb3JtYXRZVVY0MjBQYWNrZWRQbGFuYXI6CisgICAgICAgICAgICAgICAgICAgIGNhc2UgQ09MT1JfRm9ybWF0WVVWNDIwUGFja2VkU2VtaVBsYW5hcjoKKyAgICAgICAgICAgICAgICAgICAgY2FzZSBDT0xPUl9Gb3JtYXRZVVY0MjBQbGFuYXI6CisgICAgICAgICAgICAgICAgICAgIGNhc2UgQ09MT1JfRm9ybWF0WVVWNDIwU2VtaVBsYW5hcjoKKyAgICAgICAgICAgICAgICAgICAgY2FzZSBDT0xPUl9Gb3JtYXRZVVY0MjJGbGV4aWJsZToKKyAgICAgICAgICAgICAgICAgICAgY2FzZSBDT0xPUl9Gb3JtYXRZVVY0MjJQYWNrZWRQbGFuYXI6CisgICAgICAgICAgICAgICAgICAgIGNhc2UgQ09MT1JfRm9ybWF0WVVWNDIyUGFja2VkU2VtaVBsYW5hcjoKKyAgICAgICAgICAgICAgICAgICAgY2FzZSBDT0xPUl9Gb3JtYXRZVVY0MjJQbGFuYXI6CisgICAgICAgICAgICAgICAgICAgIGNhc2UgQ09MT1JfRm9ybWF0WVVWNDIyU2VtaVBsYW5hcjoKKyAgICAgICAgICAgICAgICAgICAgY2FzZSBDT0xPUl9Gb3JtYXRZVVY0NDRGbGV4aWJsZToKKyAgICAgICAgICAgICAgICAgICAgY2FzZSBDT0xPUl9Gb3JtYXRZVVY0NDRJbnRlcmxlYXZlZDoKKyAgICAgICAgICAgICAgICAgICAgICAgIGNsaWVudEJpdERlcHRoID0gODsKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgICAgICAgICAgLy8gbm8tb3A7IHVzZWQgd2l0aCBvcHRpb25hbAorICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgLy8gY29udmVyc2lvbiBmYWlscyBpZiBjbGllbnQgYml0LWRlcHRoIGFuZCB0aGUgY29tcG9uZW50IGJpdC1kZXB0aCBkaWZmZXJzCisgICAgICAgICAgICAgICAgaWYgKChjbGllbnRCaXREZXB0aCkgJiYgKGJpdERlcHRoICE9IGNsaWVudEJpdERlcHRoLnZhbHVlKCkpKSB7CisgICAgICAgICAgICAgICAgICAgIEFMT0dEKCJCaXQgZGVwdGggb2YgY2xpZW50OiAlZCBhbmQgY29tcG9uZW50OiAlZCBkaWZmZXJzIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICpjbGllbnRCaXREZXB0aCwgYml0RGVwdGgpOworICAgICAgICAgICAgICAgICAgICBtSW5pdENoZWNrID0gQkFEX1ZBTFVFOworICAgICAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIEMyUGxhbmVJbmZvIHlQbGFuZSA9IGxheW91dC5wbGFuZXNbQzJQbGFuYXJMYXlvdXQ6OlBMQU5FX1ldOwogICAgICAgICAgICAgICAgIEMyUGxhbmVJbmZvIHVQbGFuZSA9IGxheW91dC5wbGFuZXNbQzJQbGFuYXJMYXlvdXQ6OlBMQU5FX1VdOwogICAgICAgICAgICAgICAgIEMyUGxhbmVJbmZvIHZQbGFuZSA9IGxheW91dC5wbGFuZXNbQzJQbGFuYXJMYXlvdXQ6OlBMQU5FX1ZdOwpAQCAtMzU4LDIxICszOTksMjIgQEAKICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogCiAgICAgICAgICAgICAgICAgICAgIGNhc2UgQ09MT1JfRm9ybWF0WVVWUDAxMDoKKyAgICAgICAgICAgICAgICAgICAgICAgIC8vIHN0cmlkZSBpcyBpbiBieXRlcwogICAgICAgICAgICAgICAgICAgICAgICAgbWVkaWFJbWFnZS0+bVBsYW5lW21lZGlhSW1hZ2UtPlldLm1PZmZzZXQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgbWVkaWFJbWFnZS0+bVBsYW5lW21lZGlhSW1hZ2UtPlldLm1Db2xJbmMgPSAyOwotICAgICAgICAgICAgICAgICAgICAgICAgbWVkaWFJbWFnZS0+bVBsYW5lW21lZGlhSW1hZ2UtPlldLm1Sb3dJbmMgPSBzdHJpZGUgKiAyOworICAgICAgICAgICAgICAgICAgICAgICAgbWVkaWFJbWFnZS0+bVBsYW5lW21lZGlhSW1hZ2UtPlldLm1Sb3dJbmMgPSBzdHJpZGU7CiAgICAgICAgICAgICAgICAgICAgICAgICBtZWRpYUltYWdlLT5tUGxhbmVbbWVkaWFJbWFnZS0+WV0ubUhvcml6U3Vic2FtcGxpbmcgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgbWVkaWFJbWFnZS0+bVBsYW5lW21lZGlhSW1hZ2UtPlldLm1WZXJ0U3Vic2FtcGxpbmcgPSAxOwogCi0gICAgICAgICAgICAgICAgICAgICAgICBtZWRpYUltYWdlLT5tUGxhbmVbbWVkaWFJbWFnZS0+VV0ubU9mZnNldCA9IHN0cmlkZSAqIHZTdHJpZGUgKiAyOworICAgICAgICAgICAgICAgICAgICAgICAgbWVkaWFJbWFnZS0+bVBsYW5lW21lZGlhSW1hZ2UtPlVdLm1PZmZzZXQgPSBzdHJpZGUgKiB2U3RyaWRlOwogICAgICAgICAgICAgICAgICAgICAgICAgbWVkaWFJbWFnZS0+bVBsYW5lW21lZGlhSW1hZ2UtPlVdLm1Db2xJbmMgPSA0OwotICAg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ICpuaCA9IFVud3JhcE5hdGl2ZUNvZGVjMkdyYWxsb2NIYW5kbGUoaGFuZGxlKTsKKyAgICAgICAgaWYgKCFuaCkgeworICAgICAgICAgICAgcmV0dXJuOworICAgICAgICB9CisgICAgICAgIC8vIEltcG9ydCB0aGUgcmF3IGhhbmRsZSBzbyBJTWFwcGVyIGNhbiB1c2UgdGhlIGJ1ZmZlci4gVGhlIGltcG9ydGVkCisgICAgICAgIC8vIGhhbmRsZSBtdXN0IGJlIGZyZWVkIHdoZW4gdGhlIGNsaWVudCBpcyBkb25lIHdpdGggdGhlIGJ1ZmZlci4KKyAgICAgICAgbWFwcGVyLT5pbXBvcnRCdWZmZXIoCisgICAgICAgICAgICAgICAgaGFyZHdhcmU6OmhpZGxfaGFuZGxlKG5oKSwKKyAgICAgICAgICAgICAgICBbJl0oY29uc3QgRXJyb3I0ICZlcnJvciwgdm9pZCAqYnVmZmVyKSB7CisgICAgICAgICAgICAgICAgICAgIGlmIChlcnJvciA9PSBFcnJvcjQ6Ok5PTkUpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1CdWZmZXIgPSBidWZmZXI7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9KTsKKworICAgICAgICAvLyBUUklDS1k6IFVud3JhcE5hdGl2ZUNvZGVjMkdyYWxsb2NIYW5kbGUgY3JlYXRlcyBhIG5ldyBoYW5kbGUgYnV0CisgICAgICAgIC8vICAgICAgICAgZG9lcyBub3QgY2xvbmUgdGhlIGZkcy4gVGh1cyB3ZSBuZWVkIHRvIGRlbGV0ZSB0aGUgaGFuZGxlCisgICAgICAgIC8vICAgICAgICAgd2l0aG91dCBjbG9zaW5nIGl0LgorICAgICAgICBuYXRpdmVfaGFuZGxlX2RlbGV0ZShuaCk7CisgICAgfQorCisgICAgfkdyYWxsb2M0QnVmZmVyKCkgeworICAgICAgICBzcDxJTWFwcGVyND4gbWFwcGVyID0gR2V0TWFwcGVyNCgpOworICAgICAgICBpZiAob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ZiAoIXJldC5pc09rKCkpIHsKKyAgICAgICAgICAgIGVyciA9IEMyX1JFRlVTRUQ7CisgICAgICAgIH0gZWxzZSBpZiAobWFwcGVyRXJyICE9IEVycm9yNDo6Tk9ORSkgeworICAgICAgICAgICAgZXJyID0gQzJfQ09SUlVQVEVEOworICAgICAgICB9CisgICAgICAgIGNiID0gWyZtYXBwZXJFcnIsIHN0YXRpY0luZm9dKEVycm9yNCBlcnIsIGNvbnN0IGhpZGxfdmVjPHVpbnQ4X3Q+ICZ2ZWMpIHsKKyAgICAgICAgICAgIG1hcHBlckVyciA9IGVycjsKKyAgICAgICAgICAgIGlmIChlcnIgIT0gRXJyb3I0OjpOT05FKSB7CisgICAgICAgICAgICAgICAgcmV0dXJuOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBzdGQ6Om9wdGlvbmFsPEN0YTg2MV8zPiBjdGE4NjFfMzsKKyAgICAgICAgICAgIGdyYWxsb2M0OjpkZWNvZGVDdGE4NjFfMyh2ZWMsICZjdGE4NjFfMyk7CisgICAgICAgICAgICBpZiAoY3RhODYxXzMpIHsKKyAgICAgICAgICAgICAgICAoKnN0YXRpY0luZm8pLT5tYXhDbGwgICA9IGN0YTg2MV8zLT5tYXhDb250ZW50TGlnaHRMZXZlbDsKKyAgICAgICAgICAgICAgICAoKnN0YXRpY0luZm8pLT5tYXhGYWxsICA9IGN0YTg2MV8zLT5tYXhGcmFtZUF2ZXJhZ2VMaWdodExldmVsOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICBtYXBwZXJFcnIgPSBFcnJvcjQ6OkJBRF9WQUxVRTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfTsKKyAgICAgICAgcmV0ID0gbWFwcGVyLT5nZXQoYnVmZmVyLmdldCgpLCBNZXRhZGF0YVR5cGVfQ3RhODYxXzMsIGNiKTsKKyAgICAgICAgaWYgKCFyZXQuaXNPaygpKSB7CisgICAgICAgICAgICBlcnIgPSBDMl9SRUZVU0VEOworICAgICAgICB9IGVsc2UgaWYgKG1hcHBlckVyciAhPSBFcnJvcjQ6Ok5PTkUpIHsKKyAgICAgICAgICAgIGVyciA9IEMyX0NPUlJVUFRFRDsKKyAgICAgICAgfQorICAgIH0KKyAgICBpZiAoZHluYW1pY0luZm8pIHsKKyAgICAgICAgQUxPR1YoIkdyYWJiaW5nIGR5bmFtaWMgSERSIGluZm8gZnJvbSBncmFsbG9jNCBtZXRhZGF0YSIpOworICAgICAgICBkeW5hbWljSW5mby0+cmVzZXQoKTsKKyAgICAgICAgSU1hcHBlcjQ6OmdldF9jYiBjYiA9IFsmbWFwcGVyRXJyLCBkeW5hbWljSW5mb10oRXJyb3I0IGVyciwgY29uc3QgaGlkbF92ZWM8dWludDhfdD4gJnZlYykgeworICAgICAgICAgICAgbWFwcGVyRXJyID0gZXJyOworICAgICAgICAgICAgaWYgKGVyciAhPSBFcnJvcjQ6Ok5PTkUpIHsKKyAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICB9CisgICAgICAgICAgICBpZiAoIWR5bmFtaWNJbmZvKSB7CisgICAgICAgICAgICAgICAgcmV0dXJuOworICAgICAgICAgICAgfQorICAgICAgICAgICAgKmR5bmFtaWNJbmZvID0gQzJTdHJlYW1IZHJEeW5hbWljTWV0YWRhdGFJbmZvOjppbnB1dDo6QWxsb2NTaGFyZWQoCisgICAgICAgICAgICAgICAgICAgIHZlYy5zaXplKCksIDB1LCBDMkNvbmZpZzo6SERSX0RZTkFNSUNfTUVUQURBVEFfVFlQRV9TTVBURV8yMDk0XzQwKTsKKyAgICAgICAgICAgIG1lbWNweSgoKmR5bmFtaWNJbmZvKS0+bS5kYXRhLCB2ZWMuZGF0YSgpLCB2ZWMuc2l6ZSgpKTsKKyAgICAgICAgfTsKKyAgICAgICAgUmV0dXJuPHZvaWQ+IHJldCA9IG1hcHBlci0+Z2V0KGJ1ZmZlci5nZXQoKSwgTWV0YWRhdGFUeXBlX1NtcHRlMjA5NF80MCwgY2IpOworIC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YgMC4wIDw9IGN0YTg2MV8zLT5tYXhGcmFtZUF2ZXJhZ2VMaWdodExldmVsCisgICAgICAgICAgICAgICAgJiYgZ3JhbGxvYzQ6OmVuY29kZUN0YTg2MV8zKGN0YTg2MV8zLCAmdmVjKSA9PSBPSykgeworICAgICAgICAgICAgUmV0dXJuPEVycm9yND4gcmV0ID0gbWFwcGVyLT5zZXQoYnVmZmVyLmdldCgpLCBNZXRhZGF0YVR5cGVfQ3RhODYxXzMsIHZlYyk7CisgICAgICAgICAgICBpZiAoIXJldC5pc09rKCkpIHsKKyAgICAgICAgICAgICAgICBlcnIgPSBDMl9SRUZVU0VEOworICAgICAgICAgICAgfSBlbHNlIGlmIChyZXQgIT0gRXJyb3I0OjpOT05FKSB7CisgICAgICAgICAgICAgICAgZXJyID0gQzJfQ09SUlVQVEVEOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgfQorICAgIGlmIChkeW5hbWljSW5mbyAmJiAqZHluYW1pY0luZm8gJiYgZHluYW1pY0luZm8tPmZsZXhDb3VudCgpID4gMCkgeworICAgICAgICBBTE9HVigiU2V0dGluZyBkeW5hbWljIEhEUiBpbmZvIGFzIGdyYWxsb2M0IG1ldGFkYXRhIik7CisgICAgICAgIHN0ZDo6b3B0aW9uYWw8SU1hcHBlcjQ6Ok1ldGFkYXRhVHlwZT4gbWV0YWRhdGFUeXBlOworICAgICAgICBzd2l0Y2ggKGR5bmFtaWNJbmZvLT5tLnR5cGVfKSB7CisgICAgICAgIGNhc2UgQzJDb25maWc6OkhEUl9EWU5BTUlDX01FVEFEQVRBX1RZUEVfU01QVEVfMjA5NF8xMDoKKyAgICAgICAgICAgIC8vIFRPRE8KKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIEMyQ29uZmlnOjpIRFJfRFlOQU1JQ19NRVRBREFUQV9UWVBFX1NNUFRFXzIwOTRfNDA6CisgICAgICAgICAgICBtZXRhZGF0YVR5cGUgPSBNZXRhZGF0YVR5cGVfU21wdGUyMDk0XzQwOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKworICAgICAgICBpZiAobWV0YWRhdGFUeXBlKSB7CisgICAgICAgICAgICBzdGQ6OnZlY3Rvcjx1aW50OF90PiBzbXB0ZTIwOTRfNDA7CisgICAgICAgICAgICBzbXB0ZTIwOTRfNDAucmVzaXplKGR5bmFtaWNJbmZvLT5mbGV4Q291bnQoKSk7CisgICAgICAgICAgICBtZW1jcHkoc21wdGUyMDk0XzQwLmRhdGEoKSwgZHluYW1pY0luZm8tPm0uZGF0YSwgZHluYW1pY0luZm8tPmZsZXhDb3VudCgpKTsKKworICAgICAgICAgICAgaGlkbF92ZWM8dWludDhfdD4gdmVjOworICAgICAgICAgICAgaWYgKGdyYWxsb2M0OjplbmNvZGVTbXB0ZTIwOTRfNDAoeyBzbXB0ZTIwOTRfNDAgfSwgJnZlYykgPT0gT0spIHsKKyAgICAgICAgICAgICAgICBSZXR1cm48RXJyb3I0PiByZXQgPSBtYXBwZXItPnNldChidWZmZXIuZ2V0KCksICptZXRhZGF0YVR5cGUsIHZlYyk7CisgICAgICAgICAgICAgICAgaWYgKCFyZXQuaXNPaygpKSB7CisgICAgICAgICAgICAgICAgICAgIGVyciA9IEMyX1JFRlVTRUQ7CisgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChyZXQgIT0gRXJyb3I0OjpOT05FKSB7CisgICAgICAgICAgICAgICAgICAgIGVyciA9IEMyX0NPUlJVUFRFRDsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICBlcnIgPSBDMl9CQURfVkFMVUU7CisgICAgICAgIH0KKyAgICB9CisKKyAgICByZXR1cm4gZXJyOworfQorCiB9ICAvLyBuYW1lc3BhY2UgYW5kcm9pZApkaWZmIC0tZ2l0IGEvbWVkaWEvY29kZWMyL3NmcGx1Z2luL0NvZGVjMkJ1ZmZlci5oIGIvbWVkaWEvY29kZWMyL3NmcGx1Z2luL0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mlsZXMgaWYgY29tcG9uZW50IHN1cHBvcnRzIEhEUiBhbmQgZGV2aWNlIGhhcyBIRFIgZGlzcGxheQorICAgICAgICAgICAgaWYgKHN1cHBvcnRzSGRyICYmIGhhc0hEUkRpc3BsYXkpIHsKICAgICAgICAgICAgICAgICBhdXRvIGhkck1hcHBlciA9IEMyTWFwcGVyOjpHZXRIZHJQcm9maWxlTGV2ZWxNYXBwZXIodHJhaXQubWVkaWFUeXBlKTsKICAgICAgICAgICAgICAgICBpZiAoaGRyTWFwcGVyICYmIGhkck1hcHBlci0+bWFwUHJvZmlsZShwbC5wcm9maWxlLCAmc2RrUHJvZmlsZSkpIHsKICAgICAgICAgICAgICAgICAgICAgY2Fwcy0+YWRkUHJvZmlsZUxldmVsKCh1aW50MzJfdClzZGtQcm9maWxlLCAodWludDMyX3Qpc2RrTGV2ZWwpOwpAQCAtMTY1LDYgKzIwNiwxMiBAQAogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQorICAgICAgICAgICAgaWYgKHN1cHBvcnRzMTBCaXQpIHsKKyAgICAgICAgICAgICAgICBhdXRvIGJpdG5lc3NNYXBwZXIgPSBDMk1hcHBlcjo6R2V0Qml0RGVwdGhQcm9maWxlTGV2ZWxNYXBwZXIodHJhaXQubWVkaWFUeXBlLCAxMCk7CisgICAgICAgICAgICAgICAgaWYgKGJpdG5lc3NNYXBwZXIgJiYgYml0bmVzc01hcHBlci0+bWFwUHJvZmlsZShwbC5wcm9maWxlLCAmc2RrUHJvZmlsZSkpIHsKKyAgICAgICAgICAgICAgICAgICAgY2Fwcy0+YWRkUHJvZmlsZUxldmVsKCh1aW50MzJfdClzZGtQcm9maWxlLCAodWludDMyX3Qpc2RrTGV2ZWwpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KICAgICAgICAgfSBlbHNlIGlmICghbWFwcGVyKSB7CiAgICAgICAgICAgICBjYXBzLT5hZGRQcm9maWxlTGV2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ICAgaWYgKGl0ICE9IHBpeGVsRm9ybWF0TWFwLmVuZCgpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXV0byBpdDIgPSBzdGQ6OmZpbmQoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdXBwb3J0ZWRDb2xvckZvcm1hdHMuYmVnaW4oKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1cHBvcnRlZENvbG9yRm9ybWF0cy5lbmQoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0LT5zZWNvbmQpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpdDIgPT0gc3VwcG9ydGVkQ29sb3JGb3JtYXRzLmVuZCgpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1cHBvcnRlZENvbG9yRm9ybWF0cy5wdXNoX2JhY2soaXQtPnNlY29uZCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgICAgIGF1dG8gYWRkRGVmYXVsdENvbG9yRm9ybWF0ID0gW2NhcHMsICZzdXBwb3J0ZWRDb2xvckZvcm1hdHNdKGludDMyX3QgY29sb3JGb3JtYXQpIHsKKyAgICAgICAgICAgIGNhcHMtPmFkZENvbG9yRm9ybWF0KGNvbG9yRm9ybWF0KTsKKyAgICAgICAgICAgIGF1dG8gaXQgPSBzdGQ6OmZpbmQoCisgICAgICAgICAgICAgICAgICAgIHN1cHBvcnRlZENvbG9yRm9ybWF0cy5iZWdpbigpLCBzdXBwb3J0ZWRDb2xvckZvcm1hdHMuZW5kKCksIGNvbG9yRm9ybWF0KTsKKyAgICAgICAgICAgIGlmIChpdCAhPSBzdXBwb3J0ZWRDb2xvckZvcm1hdHMuZW5kKCkpIHsKKyAgICAg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GllbnQ+IGNsaWVudDsKICAgICAgICAgICAgIHN0ZDo6c2hhcmVkX3B0cjxDb2RlYzJDbGllbnQ6OkludGVyZmFjZT4gaW50ZiA9Ci0gICAgICAgICAgICAgICAgQ29kZWMyQ2xpZW50OjpDcmVhdGVJbnRlcmZhY2VCeU5hbWUobmFtZU9yQWxpYXMuY19zdHIoKSk7CisgICAgICAgICAgICAgICAgQ29kZWMyQ2xpZW50OjpDcmVhdGVJbnRlcmZhY2VCeU5hbWUobmFtZU9yQWxpYXMuY19zdHIoKSwgJmNsaWVudCk7CiAgICAgICAgICAgICBpZiAoIWludGYpIHsKICAgICAgICAgICAgICAgICBBTE9HRCgiY291bGQgbm90IGNyZWF0ZSBpbnRlcmZhY2UgZm9yICVzJyVzJyIsCiAgICAgICAgICAgICAgICAgICAgICAgICBpc0FsaWFzID8gImFsaWFzICIgOiAiIiwKQEAgLTYxOCw3ICs3MTgsNDAgQEAKICAgICAgICAgICAgICAgICAgICAgICAgIGNhcHMtPmFkZFByb2ZpbGVMZXZlbChWUDhQcm9maWxlTWFpbiwgVlA4TGV2ZWxfVmVyc2lvbjApOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIGFkZFN1cHBvcnRlZENvbG9yRm9ybWF0cyhpbnRmLCBjYXBzLmdldCgpLCB0cmFpdCwgbWVkaWFUeXBlKTsKKworICAgICAgICAgICAgICAgIGF1dG8gaXQgPSBuYW1lVG9QaXhlbEZvcm1hdE1hcC5maW5kKGNsaWVudC0+Z2V0U2VydmljZU5hbWUoKSk7CisgICAgICAgICAgICAgICAgaWYgKGl0ID09IG5hbWVUb1BpeGVsRm9ybWF0TWFwLmVuZCgpKSB7CisgICAgICAgICAgICAgICAgICAgIGl0ID0gbmFtZVRvUGl4ZWxGb3JtYXRNYXAudHJ5X2VtcGxhY2UoY2xpZW50LT5nZXRTZXJ2aWNlTmFtZSgpKS5maXJzdDsKKyAgICAgICAgICAgICAgICAg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AgICAgICAgJmhlYXBQYXJhbXMpID09IEMyX09LCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgJiYgaGVhcFBhcmFtcy5zaXplKCkgPT0gMXUpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBpeGVsRm9ybWF0SW5mby5yZXNldChDMlN0b3JlRmxleGlibGVQaXhlbEZvcm1hdERlc2NyaXB0b3JzSW5mbzo6RnJvbSgKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVhcFBhcmFtc1swXS5yZWxlYXNlKCkpKTsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICBpZiAocGl4ZWxGb3JtYXRJbmZvICYmICpwaXhlbEZvcm1hdEluZm8pIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoc2l6ZV90IGkgPSAwOyBpIDwgcGl4ZWxGb3JtYXRJbmZvLT5mbGV4Q291bnQoKTsgKytpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgQzJGbGV4aWJsZVBpeGVsRm9ybWF0RGVzY3JpcHRvclN0cnVjdCAmZGVzYyA9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBpeGVsRm9ybWF0SW5mby0+bS52YWx1ZXNbaV07CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RkOjpvcHRpb25hbDxpbnQzMl90PiBjb2xvckZvcm1hdCA9IGZpbmRGcmFtZXdvcmtDb2xvckZvcm1hdChkZXNjKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY29sb3JGb3JtYXQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGl4ZWxGb3JtYXRNYXBbZGVzYy5waXhlbEZvcm1hdF0gPSAqY29sb3JGb3JtYXQ7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfQorICAgICA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gICAgICAgICAgICAgIGFkZFBhcmFtZXRlcigKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBEZWZpbmVQYXJhbShtT3V0cHV0UHJvZmlsZUxldmVsLCBDMl9QQVJBTUtFWV9QUk9GSUxFX0xFVkVMKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIC53aXRoRGVmYXVsdChuZXcgQzJTdHJlYW1Qcm9maWxlTGV2ZWxJbmZvOjpvdXRwdXQoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAwdSwgUFJPRklMRV9VTlVTRUQsIExFVkVMX1VOVVNFRCkpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgLndpdGhGaWVsZHMoeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDMkYobU91dHB1dFByb2ZpbGVMZXZlbCwgcHJvZmlsZSkuYW55KCksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEMyRihtT3V0cHV0UHJvZmlsZUxldmVsLCBsZXZlbCkuYW55KCksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAud2l0aFNldHRlcihTZXR0ZXI8QzJTdHJlYW1Qcm9maWxlTGV2ZWxJbmZvOjpvdXRwdXQ+KQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5idWlsZCgpKTsKICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICAvLyBUT0RPOiBtb3JlIFNESyBwYXJhbXMKQEAgLTI0MSw2ICsyNTIsOCBAQAogICAgICAgICAgICAgc3RkOjpzaGFyZWRfcHRyPEMyU3RyZWFtUGl4ZWxBc3BlY3RSYXRpb0luZm86Om91dHB1dD4gbVBpeGVsQXNwZWN0UmF0aW87CiAgICAgICAgICAgICBzdGQ6OnNoYXJlZF9wdHI8QzJTdHJlYW1CaXRyYXRlSW5mbzo6aW5wdXQ+IG1JbnB1dEJpdHJhdGU7CiAgICAgICAgICAgICBzdGQ6OnNo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DxNZWRpYUNvZGVjQnVmZmVyPiBidWZmZXIgPSBuZXcgTWVkaWFDb2RlY0J1ZmZlcigKICAgICAgICAgICAgICAgICAgICAgbmV3IEFNZXNzYWdlLCBuZXcgQUJ1ZmZlcihpbnB1dEZyYW1lU2l6ZUluQnl0ZXMpKTsKICAgICAgICAgICAgIGJ1ZmZlci0+c2V0UmFuZ2UoMCwgaW5wdXRGcmFtZVNpemVJbkJ5dGVzKTsKQEAgLTc3LDggKzc4LDEyIEBACiAgICAgICAgICAgICBpZiAoaSA9PSBjb3VudCAtIDEpIHsKICAgICAgICAgICAgICAgICBidWZmZXItPm1ldGEoKS0+c2V0SW50MzIoImVvcyIsIDEpOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgZm9yIChzaXplX3QgaiA9IDA7IGogPCBpbnB1dEZyYW1lU2l6ZUluQnl0ZXM7ICsraiwgKytpbnB1dEluZGV4KSB7Ci0gICAgICAgICAgICAgICAgYnVmZmVyLT5iYXNlKClbal0gPSAoaW5wdXRJbmRleCAmIDB4RkYpOworICAgICAgICAgICAgaWYgKGkgPT0gY291bnQgJiYgc2VwYXJhdGVFb3MpIHsKKyAgICAgICAgICAgICAgICBidWZmZXItPnNldFJhbmdlKDAsIDApOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICBmb3IgKHNpemVfdCBqID0gMDsgaiA8IGlucHV0RnJhbWVTaXplSW5CeXRlczsgKytqLCArK2lucHV0SW5kZXgpIHsKKyAgICAgICAgICAgICAgICAgICAgYnVmZmVyLT5iYXNlKClbal0gPSAoaW5wdXRJbmRleCAmIDB4RkYpOworICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KICAgICAgICAgICAgIHN0ZDo6bGlzdDxzdGQ6OnVuaXF1ZV9wdHI8QzJXb3JrPj4gaXRlbXM7CiAgICAgICAgICAgICBBU1NFUlRfRVEoQzJfT0ssIGZyYW1lUmVhc3NlbWJsZXIucHJvY2VzcyhidWZmZXIsICZpdGVtcykpOwpAQCAtMTA1LDcgKzExMCw4IEBACiAgICAgICAgICAgICAgICAgQVNTRVJUX0VRKGVuY29kZXJGcmFtZVNpemUgKiBCeXRlc1BlclNhbXBsZShlbmNvZGluZyksIHZpZXcuY2FwYWNpdHkoKSk7CiAgICAgICAgICAgICAgICAgZm9yIChzaXplX3QgaiA9IDA7IGogPCB2aWV3LmNhcGFjaXR5KCk7ICsraiwgKytvdXRwdXRJbmRleCkgewogICAgICAgICAgICAgICAgICAgICBBU1NFUlRfVFJVRShvdXRwdXRJbmRleCA8IGlucHV0SW5kZXgKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfHwgaW5wdXRJbmRleCA9PSBpbnB1dEZyYW1lU2l6ZUluQnl0ZXMgKiBjb3VudCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHx8IGlucHV0SW5kZXggPT0gaW5wdXRGcmFtZVNpemVJbkJ5dGVzICogY291bnQpCisgICAgICAgICAgICAgICAgICAgICAgICA8PCAiaW5wdXRJbmRleCA9ICIgPDwgaW5wdXRJbmRleCA8PCAiIG91dHB1dEluZGV4ID0gIiA8PCBvdXRwdXRJbmRleDsKICAgICAgICAgICAgICAgICAgICAgdWludDhfdCBleHBlY3RlZCA9IG91dHB1dEluZGV4IDwgaW5wdXRJbmRleCA/IChvdXRwdXRJbmRleCAmIDB4RkYpIDogMDsKICAgICAgICAgICAgICAgICAgICAgaWYgKGV4cGVjdENvdW50IDwgMTApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICsrZXhwZWN0Q291bnQ7CkBAIC0xMzcsMjA0ICsxNDMsMjM5IEBACiAvLyBQdXNoIGZyYW1lcyB3aXRoIGV4YWN0bHkgdGhlIHNhbWUgc2l6ZSBhcyB0aGUgZW5jb2RlciByZXF1ZXN0ZWQuCiBURVNUX0YoRnJhbWVSZWFzc2VtYmxlclRlc3QsIFB1c2hFeGFjdEZyYW1lU2l6ZSkgewogICAgIEFTU0VSVF9FUShPSywgaW5pdFN0YXR1cyg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ICAxIC8qIGNoYW5uZWwgY291bnQgKi8sCi0gICAgICAgICAgICBQQ01fRkxPQVQsCi0gICAgICAgICAgICA0MDk2IC8qIGlucHV0IGZyYW1lIHNpemUgaW4gYnl0ZXMgPSAxMDI0IHNhbXBsZXMgKiAxIGNoYW5uZWwgKiA0IGJ5dGVzL3NhbXBsZSAqLywKLSAgICAgICAgICAgIDEwIC8qIGNvdW50ICovLAotICAgICAgICAgICAgNDA5NjAgLyogZXhwZWN0ZWQgb3V0cHV0IHNpemUgPSAxMCAqIDQwOTYgYnl0ZXMvZnJhbWUgKi8pOworICAgIGZvciAoYm9vbCBzZXBhcmF0ZUVvcyA6IHtmYWxzZSwgdHJ1ZX0pIHsKKyAgICAgICAgdGVzdFB1c2hTYW1lU2l6ZSgKKyAgICAgICAgICAgICAgICAxMDI0IC8qIGZyYW1lIHNpemUgaW4gc2FtcGxlcyAqLywKKyAgICAgICAgICAgICAgICA0ODAwMCAvKiBzYW1wbGUgcmF0ZSAqLywKKyAgICAgICAgICAgICAgICAxIC8qIGNoYW5uZWwgY291bnQgKi8sCisgICAgICAgICAgICAgICAgUENNXzgsCisgICAgICAgICAgICAgICAgMTAyNCAvKiBpbnB1dCBmcmFtZSBzaXplIGluIGJ5dGVzID0gMTAyNCBzYW1wbGVzICogMSBjaGFubmVsICogMSBieXRlcy9zYW1wbGUgKi8sCisgICAgICAgICAgICAgICAgMTAgLyogY291bnQgKi8sCisgICAgICAgICAgICAgICAgMTAyNDAgLyogZXhwZWN0ZWQgb3V0cHV0IHNpemUgPSAxMCAqIDEwMjQgYnl0ZXMvZnJhbWUgKi8sCisgICAgICAgICAgICAgICAgc2VwYXJhdGVFb3MpOworICAgICAgICB0ZXN0UHVzaFNhbWVTaXplKAorICAgICAgICAgICAgICAgIDEwMjQgLyogZnJhbWUgc2l6ZSBpbiBzYW1wbGVzICovLAorICAgICAgICAgICAgICAgIDQ4MDAwIC8qIHNhbXBsZSByYXRlICovLAorICAgICAgICAgICAgICAgIDEgLyogY2hhbm5lbCBjb3VudCAqLywKKyAgICAgICAgICAgICAgICBQQ01fMTYsCisgICAgICAgICAgICAgICAgMjA0OCAvKiBpbnB1dCBmcmFtZSBzaXplIGluIGJ5dGVzID0gMTAyNCBzYW1wbGVzICogMSBjaGFubmVsICogMiBieXRlcy9zYW1wbGUgKi8sCisgICAgICAgICAgICAgICAgMTAgLyogY291bnQgKi8sCisgICAgICAgICAgICAgICAgMjA0ODAgLyogZXhwZWN0ZWQgb3V0cHV0IHNpemUgPSAxMCAqIDIwNDggYnl0ZXMvZnJhbWUgKi8sCisgICAgICAgICAgICAgICAgc2VwYXJhdGVFb3MpOworICAgICAgICB0ZXN0UHVzaFNhbWVTaXplKAorICAgICAgICAgICAgICAgIDEwMjQgLyogZnJhbWUgc2l6ZSBpbiBzYW1wbGVzICovLAorICAgICAgICAgICAgICAgIDQ4MDAwIC8qIHNhbXBsZSByYXRlICovLAorICAgICAgICAgICAgICAgIDEgLyogY2hhbm5lbCBjb3VudCAqLywKKyAgICAgICAgICAgICAgICBQQ01fRkxPQVQsCisgICAgICAgICAgICAgICAgNDA5NiAvKiBpbnB1dCBmcmFtZSBzaXplIGluIGJ5dGVzID0gMTAyNCBzYW1wbGVzICogMSBjaGFubmVsICogNCBieXRlcy9zYW1wbGUgKi8sCisgICAgICAgICAgICAgICAgMTAgLyogY291bnQgKi8sCisgICAgICAgICAgICAgICAgNDA5NjAgLyogZXhwZWN0ZWQgb3V0cHV0IHNpemUgPSAxMCAqIDQwOTYgYnl0ZXMvZnJhbWUgKi8sCisgICAgICAgICAgICAgICAgc2VwYXJhdGVFb3MpOworICAgIH0KIH0KIAogLy8gUHVzaCBmcmFtZXMgd2l0aCBoYWxmIHRoZSBzaXplIHRoYXQgdGhlIGVuY29kZXIgcmVxdWVzdGVkLgogVEVTVF9GKEZyYW1lUmVhc3NlbWJsZXJUZXN0LCBQdXNoSGFsZkZyYW1lU2l6ZSkgewogICAgIEFTU0VSVF9FUShPSywgaW5pdFN0Y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LSAgICAgICAgICAgIDEgLyogY2hhbm5lbCBjb3VudCAqLywKLSAgICAgICAgICAgIFBDTV9GTE9BVCwKLSAgICAgICAgICAgIDIwNDggLyogaW5wdXQgZnJhbWUgc2l6ZSBpbiBieXRlcyA9IDUxMiBzYW1wbGVzICogMSBjaGFubmVsICogNCBieXRlcyBwZXIgc2FtcGxlICovLAotICAgICAgICAgICAgMTAgLyogY291bnQgKi8sCi0gICAgICAgICAgICAyMDQ4MCAvKiBleHBlY3RlZCBvdXRwdXQgc2l6ZSA9IDUgKiA0MDk2IGJ5dGVzL2ZyYW1lICovKTsKKyAgICBmb3IgKGJvb2wgc2VwYXJhdGVFb3MgOiB7ZmFsc2UsIHRydWV9KSB7CisgICAgICAgIHRlc3RQdXNoU2FtZVNpemUoCisgICAgICAgICAgICAgICAgMTAyNCAvKiBmcmFtZSBzaXplIGluIHNhbXBsZXMgKi8sCisgICAgICAgICAgICAgICAgNDgwMDAgLyogc2FtcGxlIHJhdGUgKi8sCisgICAgICAgICAgICAgICAgMSAvKiBjaGFubmVsIGNvdW50ICovLAorICAgICAgICAgICAgICAgIFBDTV84LAorICAgICAgICAgICAgICAgIDUxMiAvKiBpbnB1dCBmcmFtZSBzaXplIGluIGJ5dGVzID0gNTEyIHNhbXBsZXMgKiAxIGNoYW5uZWwgKiAxIGJ5dGVzL3NhbXBsZSAqLywKKyAgICAgICAgICAgICAgICAxMCAvKiBjb3VudCAqLywKKyAgICAgICAgICAgICAgICA1MTIwIC8qIGV4cGVjdGVkIG91dHB1dCBzaXplID0gNSAqIDEwMjQgYnl0ZXMvZnJhbWUgKi8sCisgICAgICAgICAgICAgICAgc2VwYXJhdGVFb3MpOworICAgICAgICB0ZXN0UHVzaFNhbWVTaXplKAorICAgICAgICAgICAgICAgIDEwMjQgLyogZnJhbWUgc2l6ZSBpbiBzYW1wbGVzICovLAorICAgICAgICAgICAgICAgIDQ4MDAwIC8qIHNhbXBsZSByYXRlICovLAorICAgICAgICAgICAgICAgIDEgLyogY2hhbm5lbCBjb3VudCAqLywKKyAgICAgICAgICAgICAgICBQQ01fMTYsCisgICAgICAgICAgICAgICAgMTAyNCAvKiBpbnB1dCBmcmFtZSBzaXplIGluIGJ5dGVzID0gNTEyIHNhbXBsZXMgKiAxIGNoYW5uZWwgKiAyIGJ5dGVzL3NhbXBsZSAqLywKKyAgICAgICAgICAgICAgICAxMCAvKiBjb3VudCAqLywKKyAgICAgICAgICAgICAgICAxMDI0MCAvKiBleHBlY3RlZCBvdXRwdXQgc2l6ZSA9IDUgKiAyMDQ4IGJ5dGVzL2ZyYW1lICovLAorICAgICAgICAgICAgICAgIHNlcGFyYXRlRW9zKTsKKyAgICAgICAgdGVzdFB1c2hTYW1lU2l6ZSgKKyAgICAgICAgICAgICAgICAxMDI0IC8qIGZyYW1lIHNpemUgaW4gc2FtcGxlcyAqLywKKyAgICAgICAgICAgICAgICA0ODAwMCAvKiBzYW1wbGUgcmF0ZSAqLywKKyAgICAgICAgICAgICAgICAxIC8qIGNoYW5uZWwgY291bnQgKi8sCisgICAgICAgICAgICAgICAgUENNX0ZMT0FULAorICAgICAgICAgICAgICAgIDIwNDggLyogaW5wdXQgZnJhbWUgc2l6ZSBpbiBieXRlcyA9IDUxMiBzYW1wbGVzICogMSBjaGFubmVsICogNCBieXRlcy9zYW1wbGUgKi8sCisgICAgICAgICAgICAgICAgMTAgLyogY291bnQgKi8sCisgICAgICAgICAgICAgICAgMjA0ODAgLyogZXhwZWN0ZWQgb3V0cHV0IHNpemUgPSA1ICogNDA5NiBieXRlcy9mcmFtZSAqLywKKyAgICAgICAgICAgICAgICBzZXBhcmF0ZUVvcyk7CisgICAgfQogfQogCiAvLyBQdXNoIGZyYW1lcyB3aXRoIHR3aWNlIHRoZSBzaXplIHRoYXQgdGhlIGVuY29kZXIgcmVxdWVzdGVkLgogVEVTVF9GKEZyYW1lUmVhc3NlbWJsZXJUZXN0LCBQdXNoRG91YmxlRnJhbWVTaXplKSB7CiAgICAgQVNTRVJUX0V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wIC8qIHNhbXBsZSByYXRlICovLAotICAgICAgICAgICAgMSAvKiBjaGFubmVsIGNvdW50ICovLAotICAgICAgICAgICAgUENNX0ZMT0FULAotICAgICAgICAgICAgODE5MiAvKiBpbnB1dCBmcmFtZSBzaXplIGluIGJ5dGVzID0gMjA0OCBzYW1wbGVzICogMSBjaGFubmVsICogNCBieXRlcyBwZXIgc2FtcGxlICovLAotICAgICAgICAgICAgMTAgLyogY291bnQgKi8sCi0gICAgICAgICAgICA4MTkyMCAvKiBleHBlY3RlZCBvdXRwdXQgc2l6ZSA9IDIwICogNDA5NiBieXRlcy9mcmFtZSAqLyk7CisgICAgZm9yIChib29sIHNlcGFyYXRlRW9zIDoge2ZhbHNlLCB0cnVlfSkgeworICAgICAgICB0ZXN0UHVzaFNhbWVTaXplKAorICAgICAgICAgICAgICAgIDEwMjQgLyogZnJhbWUgc2l6ZSBpbiBzYW1wbGVzICovLAorICAgICAgICAgICAgICAgIDQ4MDAwIC8qIHNhbXBsZSByYXRlICovLAorICAgICAgICAgICAgICAgIDEgLyogY2hhbm5lbCBjb3VudCAqLywKKyAgICAgICAgICAgICAgICBQQ01fOCwKKyAgICAgICAgICAgICAgICAyMDQ4IC8qIGlucHV0IGZyYW1lIHNpemUgaW4gYnl0ZXMgPSAyMDQ4IHNhbXBsZXMgKiAxIGNoYW5uZWwgKiAxIGJ5dGVzL3NhbXBsZSAqLywKKyAgICAgICAgICAgICAgICAxMCAvKiBjb3VudCAqLywKKyAgICAgICAgICAgICAgICAyMDQ4MCAvKiBleHBlY3RlZCBvdXRwdXQgc2l6ZSA9IDIwICogMTAyNCBieXRlcy9mcmFtZSAqLywKKyAgICAgICAgICAgICAgICBzZXBhcmF0ZUVvcyk7CisgICAgICAgIHRlc3RQdXNoU2FtZVNpemUoCisgICAgICAgICAgICAgICAgMTAyNCAvKiBmcmFtZSBzaXplIGluIHNhbXBsZXMgKi8sCisgICAgICAgICAgICAgICAgNDgwMDAgLyogc2FtcGxlIHJhdGUgKi8sCisgICAgICAgICAgICAgICAgMSAvKiBjaGFubmVsIGNvdW50ICovLAorICAgICAgICAgICAgICAgIFBDTV8xNiwKKyAgICAgICAgICAgICAgICA0MDk2IC8qIGlucHV0IGZyYW1lIHNpemUgaW4gYnl0ZXMgPSAyMDQ4IHNhbXBsZXMgKiAxIGNoYW5uZWwgKiAyIGJ5dGVzL3NhbXBsZSAqLywKKyAgICAgICAgICAgICAgICAxMCAvKiBjb3VudCAqLywKKyAgICAgICAgICAgICAgICA0MDk2MCAvKiBleHBlY3RlZCBvdXRwdXQgc2l6ZSA9IDIwICogMjA0OCBieXRlcy9mcmFtZSAqLywKKyAgICAgICAgICAgICAgICBzZXBhcmF0ZUVvcyk7CisgICAgICAgIHRlc3RQdXNoU2FtZVNpemUoCisgICAgICAgICAgICAgICAgMTAyNCAvKiBmcmFtZSBzaXplIGluIHNhbXBsZXMgKi8sCisgICAgICAgICAgICAgICAgNDgwMDAgLyogc2FtcGxlIHJhdGUgKi8sCisgICAgICAgICAgICAgICAgMSAvKiBjaGFubmVsIGNvdW50ICovLAorICAgICAgICAgICAgICAgIFBDTV9GTE9BVCwKKyAgICAgICAgICAgICAgICA4MTkyIC8qIGlucHV0IGZyYW1lIHNpemUgaW4gYnl0ZXMgPSAyMDQ4IHNhbXBsZXMgKiAxIGNoYW5uZWwgKiA0IGJ5dGVzL3NhbXBsZSAqLywKKyAgICAgICAgICAgICAgICAxMCAvKiBjb3VudCAqLywKKyAgICAgICAgICAgICAgICA4MTkyMCAvKiBleHBlY3RlZCBvdXRwdXQgc2l6ZSA9IDIwICogNDA5NiBieXRlcy9mcmFtZSAqLywKKyAgICAgICAgICAgICAgICBzZXBhcmF0ZUVvcyk7CisgICAgfQogfQogCiAvLyBQdXNoIGZyYW1lcyB3aXRoIGEgbGl0dGxlIGJpdCBsYXJnZXIgKCs1IHNhbXBsZXMpIHRoYW4gdGhlIHJlcXVlc3RlZCBzaXplLgogVEVTVF9GKEZyYW1lUmVhc3NlbWJsZX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0IC8qIGZyYW1lIHNpemUgaW4gc2FtcGxlcyAqLywKLSAgICAgICAgICAgIDQ4MDAwIC8qIHNhbXBsZSByYXRlICovLAotICAgICAgICAgICAgMSAvKiBjaGFubmVsIGNvdW50ICovLAotICAgICAgICAgICAgUENNX0ZMT0FULAotICAgICAgICAgICAgNDExNiAvKiBpbnB1dCBmcmFtZSBzaXplIGluIGJ5dGVzID0gMTAyOSBzYW1wbGVzICogMSBjaGFubmVsICogNCBieXRlcyBwZXIgc2FtcGxlICovLAotICAgICAgICAgICAgMTAgLyogY291bnQgKi8sCi0gICAgICAgICAgICA0NTA1NiAvKiBleHBlY3RlZCBvdXRwdXQgc2l6ZSA9IDExICogNDA5NiBieXRlcy9mcmFtZSAqLyk7CisgICAgZm9yIChib29sIHNlcGFyYXRlRW9zIDoge2ZhbHNlLCB0cnVlfSkgeworICAgICAgICB0ZXN0UHVzaFNhbWVTaXplKAorICAgICAgICAgICAgICAgIDEwMjQgLyogZnJhbWUgc2l6ZSBpbiBzYW1wbGVzICovLAorICAgICAgICAgICAgICAgIDQ4MDAwIC8qIHNhbXBsZSByYXRlICovLAorICAgICAgICAgICAgICAgIDEgLyogY2hhbm5lbCBjb3VudCAqLywKKyAgICAgICAgICAgICAgICBQQ01fOCwKKyAgICAgICAgICAgICAgICAxMDI5IC8qIGlucHV0IGZyYW1lIHNpemUgaW4gYnl0ZXMgPSAxMDI5IHNhbXBsZXMgKiAxIGNoYW5uZWwgKiAxIGJ5dGVzL3NhbXBsZSAqLywKKyAgICAgICAgICAgICAgICAxMCAvKiBjb3VudCAqLywKKyAgICAgICAgICAgICAgICAxMTI2NCAvKiBleHBlY3RlZCBvdXRwdXQgc2l6ZSA9IDExICogMTAyNCBieXRlcy9mcmFtZSAqLywKKyAgICAgICAgICAgICAgICBzZXBhcmF0ZUVvcyk7CisgICAgICAgIHRlc3RQdXNoU2FtZVNpemUoCisgICAgICAgICAgICAgICAgMTAyNCAvKiBmcmFtZSBzaXplIGluIHNhbXBsZXMgKi8sCisgICAgICAgICAgICAgICAgNDgwMDAgLyogc2FtcGxlIHJhdGUgKi8sCisgICAgICAgICAgICAgICAgMSAvKiBjaGFubmVsIGNvdW50ICovLAorICAgICAgICAgICAgICAgIFBDTV8xNiwKKyAgICAgICAgICAgICAgICAyMDU4IC8qIGlucHV0IGZyYW1lIHNpemUgaW4gYnl0ZXMgPSAxMDI5IHNhbXBsZXMgKiAxIGNoYW5uZWwgKiAyIGJ5dGVzL3NhbXBsZSAqLywKKyAgICAgICAgICAgICAgICAxMCAvKiBjb3VudCAqLywKKyAgICAgICAgICAgICAgICAyMjUyOCAvKiBleHBlY3RlZCBvdXRwdXQgc2l6ZSA9IDExICogMjA0OCBieXRlcy9mcmFtZSAqLywKKyAgICAgICAgICAgICAgICBzZXBhcmF0ZUVvcyk7CisgICAgICAgIHRlc3RQdXNoU2FtZVNpemUoCisgICAgICAgICAgICAgICAgMTAyNCAvKiBmcmFtZSBzaXplIGluIHNhbXBsZXMgKi8sCisgICAgICAgICAgICAgICAgNDgwMDAgLyogc2FtcGxlIHJhdGUgKi8sCisgICAgICAgICAgICAgICAgMSAvKiBjaGFubmVsIGNvdW50ICovLAorICAgICAgICAgICAgICAgIFBDTV9GTE9BVCwKKyAgICAgICAgICAgICAgICA0MTE2IC8qIGlucHV0IGZyYW1lIHNpemUgaW4gYnl0ZXMgPSAxMDI5IHNhbXBsZXMgKiAxIGNoYW5uZWwgKiA0IGJ5dGVzL3NhbXBsZSAqLywKKyAgICAgICAgICAgICAgICAxMCAvKiBjb3VudCAqLywKKyAgICAgICAgICAgICAgICA0NTA1NiAvKiBleHBlY3RlZCBvdXRwdXQgc2l6ZSA9IDExICogNDA5NiBieXRlcy9mcmFtZSAqLywKKyAgICAgICAgICAgICAgICBzZXBhcmF0ZUVvcyk7CisgICAgfQogfQogCiAvLyBQdXNoIGZyYW1lcyB3aXRoIGEgbGl0dGxlIGJpdCBzbWFsbGVyICgtNSBzYW1wbGVzKSB0aGFuIHRoZS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ci0gICAgdGVzdFB1c2hTYW1lU2l6ZSgKLSAgICAgICAgICAgIDEwMjQgLyogZnJhbWUgc2l6ZSBpbiBzYW1wbGVzICovLAotICAgICAgICAgICAgNDgwMDAgLyogc2FtcGxlIHJhdGUgKi8sCi0gICAgICAgICAgICAxIC8qIGNoYW5uZWwgY291bnQgKi8sCi0gICAgICAgICAgICBQQ01fRkxPQVQsCi0gICAgICAgICAgICA0MDc2IC8qIGlucHV0IGZyYW1lIHNpemUgaW4gYnl0ZXMgPSAxMDE5IHNhbXBsZXMgKiAxIGNoYW5uZWwgKiA0IGJ5dGVzIHBlciBzYW1wbGUgKi8sCi0gICAgICAgICAgICAxMCAvKiBjb3VudCAqLywKLSAgICAgICAgICAgIDQwOTYwIC8qIGV4cGVjdGVkIG91dHB1dCBzaXplID0gMTAgKiA0MDk2IGJ5dGVzL2ZyYW1lICovKTsKKyAgICBmb3IgKGJvb2wgc2VwYXJhdGVFb3MgOiB7ZmFsc2UsIHRydWV9KSB7CisgICAgICAgIHRlc3RQdXNoU2FtZVNpemUoCisgICAgICAgICAgICAgICAgMTAyNCAvKiBmcmFtZSBzaXplIGluIHNhbXBsZXMgKi8sCisgICAgICAgICAgICAgICAgNDgwMDAgLyogc2FtcGxlIHJhdGUgKi8sCisgICAgICAgICAgICAgICAgMSAvKiBjaGFubmVsIGNvdW50ICovLAorICAgICAgICAgICAgICAgIFBDTV84LAorICAgICAgICAgICAgICAgIDEwMTkgLyogaW5wdXQgZnJhbWUgc2l6ZSBpbiBieXRlcyA9IDEwMTkgc2FtcGxlcyAqIDEgY2hhbm5lbCAqIDEgYnl0ZXMvc2FtcGxlICovLAorICAgICAgICAgICAgICAgIDEwIC8qIGNvdW50ICovLAorICAgICAgICAgICAgICAgIDEwMjQwIC8qIGV4cGVjdGVkIG91dHB1dCBzaXplID0gMTAgKiAxMDI0IGJ5dGVzL2ZyYW1lICovLAorICAgICAgICAgICAgICAgIHNlcGFyYXRlRW9zKTsKKyAgICAgICAgdGVzdFB1c2hTYW1lU2l6ZSgKKyAgICAgICAgICAgICAgICAxMDI0IC8qIGZyYW1lIHNpemUgaW4gc2FtcGxlcyAqLywKKyAgICAgICAgICAgICAgICA0ODAwMCAvKiBzYW1wbGUgcmF0ZSAqLywKKyAgICAgICAgICAgICAgICAxIC8qIGNoYW5uZWwgY291bnQgKi8sCisgICAgICAgICAgICAgICAgUENNXzE2LAorICAgICAgICAgICAgICAgIDIwMzggLyogaW5wdXQgZnJhbWUgc2l6ZSBpbiBieXRlcyA9IDEwMTkgc2FtcGxlcyAqIDEgY2hhbm5lbCAqIDIgYnl0ZXMvc2FtcGxlICovLAorICAgICAgICAgICAgICAgIDEwIC8qIGNvdW50ICovLAorICAgICAgICAgICAgICAgIDIwNDgwIC8qIGV4cGVjdGVkIG91dHB1dCBzaXplID0gMTAgKiAyMDQ4IGJ5dGVzL2ZyYW1lICovLAorICAgICAgICAgICAgICAgIHNlcGFyYXRlRW9zKTsKKyAgICAgICAgdGVzdFB1c2hTYW1lU2l6ZSgKKyAgICAgICAgICAgICAgICAxMDI0IC8qIGZyYW1lIHNpemUgaW4gc2FtcGxlcyAqLywKKyAgICAgICAgICAgICAgICA0ODAwMCAvKiBzYW1wbGUgcmF0ZSAqLywKKyAgICAgICAgICAgICAgICAxIC8qIGNoYW5uZWwgY291bnQgKi8sCisgICAgICAgICAgICAgICAgUENNX0ZMT0FULAorICAgICAgICAgICAgICAgIDQwNzYgLyogaW5wdXQgZnJhbWUgc2l6ZSBpbiBieXRlcyA9IDEwMTkgc2FtcGxlcyAqIDEgY2hhbm5lbCAqIDQgYnl0ZXMvc2FtcGxlICovLAorICAgICAgICAgICAgICAgIDEwIC8qIGNvdW50ICovLAorICAgICAgICAgICAgICAgIDQwOTYwIC8qIGV4cGVjdGVkIG91dHB1dCBzaXplID0gMTAgKiA0MDk2IGJ5dGVzL2ZyYW1lICovLAorICAgICAgICAgICAgICAgIHNlcGFyYXRlRW9zKTsKKyAgICB9CiB9CiAKIC8vIFB1c2ggc2luZ2xlLWJ5dGUgZnJhbWVzCiBURVNUX0YoRnJhbWVSZWFzc2VtYmxlclRlc3QsIFB1c2hTaW5nbGVCeXRlKSB7CiAgICAgQVNTRVJUX0VRKE9LLCBpbml0U3RhdHVzKCkpOwotICAgIHRlc3RQdXNoU2FtZVNpemUoCi0gICAgICAgICAgICAxMDI0IC8qIGZyYW1lIHNpemUgaW4gc2FtcGxlcyAqLywKLSAgICAgICAgICAgIDQ4MDAwIC8qIHNhbXBsZSByYXRlICovLAotICAgICAgICAgICAgMSAvKiBjaGFubmVsIGNvdW50ICovLAotICAgICAgICAgICAgUENNXzgsCi0gICAgICAgICAgICAxIC8qIGlucHV0IGZyYW1lIHNpemUgaW4gYnl0ZXMgKi8sCi0gICAgICAgICAgICAxMDAwMDAgLyogY291bnQgKi8sCi0gICAgICAgICAgICAxMDAzNTIgLyogZXhwZWN0ZWQgb3V0cHV0IHNpemUgPSA5OCAqIDEwMjQgYnl0ZXMvZnJhbWUgKi8pOwotICAgIHRlc3RQdXNoU2FtZVNpemUoCi0gICAgICAgICAgICAxMDI0IC8qIGZyYW1lIHNpemUgaW4gc2FtcGxlcyAqLywKLSAgICAgICAgICAgIDQ4MDAwIC8qIHNhbXBsZSByYXRlICovLAotICAgICAgICAgICAgMSAvKiBjaGFubmVsIGNvdW50ICovLAotICAgICAgICAgICAgUENNXzE2LAotICAgICAgICAgICAgMSAvKiBpbnB1dCBmcmFtZSBzaXplIGluIGJ5dGVzICovLAotICAgICAgICAgICAgMTAwMDAwIC8qIGNvdW50ICovLAotICAgICAgICAgICAgMTAwMzUyIC8qIGV4cGVjdGVkIG91dHB1dCBzaXplID0gNDkgKiAyMDQ4IGJ5dGVzL2ZyYW1lICovKTsKLSAgICB0ZXN0UHVzaFNhbWVTaXplKAotICAgICAgICAgICAgMTAyNCAvKiBmcmFtZSBzaXplIGluIHNhbXBsZXMgKi8sCi0gICAgICAgICAgICA0ODAwMCAvKiBzYW1wbGUgcmF0ZSAqLywKLSAgICAgICAgICAgIDEgLyogY2hhbm5lbCBjb3VudCAqLywKLSAgICAgICAgICAgIFBDTV9GTE9BVCwKLSAgICAgICAgICAgIDEgLyogaW5wdXQgZnJhbWUgc2l6ZSBpbiBieXRlcyAqLywKLSAgICAgICAgICAgIDEwMDAwMCAvKiBjb3VudCAqLywKLSAgICAgICAgICAgIDEwMjQwMCAvKiBleHBlY3RlZCBvdXRwdXQgc2l6ZSA9IDI1ICogNDA5NiBieXRlcy9mcmFtZSAqLyk7CisgICAgZm9yIChib29sIHNlcGFyYXRlRW9zIDoge2ZhbHNlLCB0cnVlfSkgeworICAgICAgICB0ZXN0UHVzaFNhbWVTaXplKAorICAgICAgICAgICAgICAgIDEwMjQgLyogZnJhbWUgc2l6ZSBpbiBzYW1wbGVzICovLAorICAgICAgICAgICAgICAgIDQ4MDAwIC8qIHNhbXBsZSByYXRlICovLAorICAgICAgICAgICAgICAgIDEgLyogY2hhbm5lbCBjb3VudCAqLywKKyAgICAgICAgICAgICAgICBQQ01fOCwKKyAgICAgICAgICAgICAgICAxIC8qIGlucHV0IGZyYW1lIHNpemUgaW4gYnl0ZXMgKi8sCisgICAgICAgICAgICAgICAgMTAwMDAwIC8qIGNvdW50ICovLAorICAgICAgICAgICAgICAgIDEwMDM1MiAvKiBleHBlY3RlZCBvdXRwdXQgc2l6ZSA9IDk4ICogMTAyNCBieXRlcy9mcmFtZSAqLywKKyAgICAgICAgICAgICAgICBzZXBhcmF0ZUVvcyk7CisgICAgICAgIHRlc3RQdXNoU2FtZVNpemUoCisgICAgICAgICAgICAgICAgMTAyNCAvKiBmcmFtZSBzaXplIGluIHNhbXBsZXMgKi8sCisgICAgICAgICAgICAgICAgNDgwMDAgLyogc2FtcGxlIHJhdGUgKi8sCisgICAgICAgICAgICAgICAgMSAvKiBjaGFubmVsIGNvdW50ICovLAorICAgICAgICAgICAgICAgIFBDTV8xNiwKKyAgICAgICAgICAgICAgICAxIC8qIGlucHV0IGZyYW1lIHNpemUgaW4gYnl0ZXMgKi8sCisgICAgICAgICAgICAgICAgMTAwMDAwIC8qIGNvdW50ICovLAorICAgICAgICAgICAgICAgIDEwMDM1MiAvKiBleHBlY3RlZCBvdXRwdXQgc2l6ZSA9IDQ5ICogMjA0OCBieXRlcy9mcmFtZSAqLywKKyAgICAgICAgICAgICAgICBzZXBhcmF0ZUVvcyk7CisgICAgICAgIHRlc3RQdXNoU2FtZVNpemUoCisgICAgICAgICAgICAgICAgMTAyNCAvKiBmcmFtZSBzaXplIGluIHNhbXBsZXMgKi8sCisgICAgICAgICAgICAgICAgNDgwMDAgLyogc2FtcGxlIHJhdGUgKi8sCisgICAgICAgICAgICAgICAgMSAvKiBjaGFubmVsIGNvdW50ICovLAorICAgICAgICAgICAgICAgIFBDTV9GTE9BVCwKKyAgICAgICAgICAgICAgICAxIC8qIGlucHV0IGZyYW1lIHNpemUgaW4gYnl0ZXMgKi8sCisgICAgICAgICAgICAgICAgMTAwMDAwIC8qIGNvdW50ICovLAorICAgICAgICAgICAgICAgIDEwMjQwMCAvKiBleHBlY3RlZCBvdXRwdXQgc2l6ZSA9IDI1ICogNDA5NiBieXRlcy9mcmFtZSAqLywKKyAgICAgICAgICAgICAgICBzZXBhcmF0ZUVvcyk7CisgICAgfQogfQogCiAvLyBQdXNoIG9uZSBiaWcgY2h1bmsuCiBURVNUX0YoRnJhbWVSZWFzc2VtYmxlclRlc3QsIFB1c2hCaWdDaHVuaykgewogICAgIEFTU0VSVF9FUShPSywgaW5pdFN0YXR1cygpKTsKLSAgICB0ZXN0UHVzaFNhbWVTaXplKAotICAgICAgICAgICAgMTAyNCAvKiBmcmFtZSBzaXplIGluIHNhbXBsZXMgKi8sCi0gICAgICAgICAgICA0ODAwMCAvKiBzYW1wbGUgcmF0ZSAqLywKLSAgICAgICAgICAgIDEgLyogY2hhbm5lbCBjb3VudCAqLywKLSAgICAgICAgICAgIFBDTV84LAotICAgICAgICAgICAgMTAwMDAwIC8qIGlucHV0IGZyYW1lIHNpemUga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AgICAgICAxMDI0IC8qIGZyYW1lIHNpemUgaW4gc2FtcGxlcyAqLywKKyAgICAgICAgICAgICAgICA0ODAwMCAvKiBzYW1wbGUgcmF0ZSAqLywKKyAgICAgICAgICAgICAgICAxIC8qIGNoYW5uZWwgY291bnQgKi8sCisgICAgICAgICAgICAgICAgUENNXzgsCisgICAgICAgICAgICAgICAgMTAwMDAwIC8qIGlucHV0IGZyYW1lIHNpemUgaW4gYnl0ZXMgKi8sCisgICAgICAgICAgICAgICAgMSAvKiBjb3VudCAqLywKKyAgICAgICAgICAgICAgICAxMDAzNTIgLyogZXhwZWN0ZWQgb3V0cHV0IHNpemUgPSA5OCAqIDEwMjQgYnl0ZXMvZnJhbWUgKi8sCisgICAgICAgICAgICAgICAgc2VwYXJhdGVFb3MpOworICAgICAgICB0ZXN0UHVzaFNhbWVTaXplKAorICAgICAgICAgICAgICAgIDEwMjQgLyogZnJhbWUgc2l6ZSBpbiBzYW1wbGVzICovLAorICAgICAgICAgICAgICAgIDQ4MDAwIC8qIHNhbXBsZSByYXRlICovLAorICAgICAgICAgICAgICAgIDEgLyogY2hhbm5lbCBjb3VudCAqLywKKyAgICAgICAgICAgICAgICBQQ01fMTYsCisgICAgICAgICAgICAgICAgMTAwMDAwIC8qIGlucHV0IGZyYW1lIHNpemUgaW4gYnl0ZXMgKi8sCisgICAgICAgICAgICAgICAgMSAvKiBjb3VudCAqLywKKyAgICAgICAgICAgICAgICAxMDAzNTIgLyogZXhwZWN0ZWQgb3V0cHV0IHNpemUgPSA0OSAqIDIwNDggYnl0ZXMvZnJhbWUgKi8sCisgICAgICAgICAgICAgICAgc2VwYXJhdGVFb3MpOworICAgICAgICB0ZXN0UHVzaFNhbWVTaXplKAorICAgICAgICAgICAgICAgIDEwMjQgLyogZnJhbWUgc2l6ZSBpbiBzYW1wbGVzICovLAorICAgICAgICAgICAgICAgIDQ4MDAwIC8qIHNhbXBsZSByYXRlICovLAorICAgICAgICAgICAgICAgIDEgLyogY2hhbm5lb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WxzZSBpZiAoSXNOVjIxKGltZykpIHsKKyAgICAgICAgICAgIFNjb3BlZFRyYWNlIHRyYWNlKEFUUkFDRV9UQUcsICJJbWFnZUNvcHk6IE5WMTItPk5WMjEiKTsKICAgICAgICAgICAgIGlmICghbGlieXV2OjpOVjIxVG9OVjEyKHNyY195LCBzcmNfc3RyaWRlX3ksIHNyY191LCBzcmNfc3RyaWRlX3UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkc3RfeSwgZHN0X3N0cmlkZV95LCBkc3RfdiwgZHN0X3N0cmlkZV92LCB3aWR0aCwgaGVpZ2h0KSkgewogICAgICAgICAgICAgICAgIHJldHVybiBPSzsKICAgICAgICAgICAgIH0KICAgICAgICAgfSBlbHNlIGlmIChJc0k0MjAoaW1nKSkgeworICAgICAgICAgICAgU2NvcGVkVHJhY2UgdHJhY2UoQVRSQUNFX1RBRywgIkltYWdlQ29weTogTlYxMi0+STQyMCIpOwogICAgICAgICAgICAgaWYgKCFsaWJ5dXY6Ok5WMTJUb0k0MjAoc3JjX3ksIHNyY19zdHJpZGVfeSwgc3JjX3UsIHNyY19zdHJpZGVfdSwgZHN0X3ksIGRzdF9zdHJpZGVfeSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRzdF91LCBkc3Rfc3RyaWRlX3UsIGRzdF92LCBkc3Rfc3RyaWRlX3YsIHdpZHRoLCBoZWlnaHQpKSB7CiAgICAgICAgICAgICAgICAgcmV0dXJuIE9LOwpAQCAtMTU1LDE1ICsxNjMsMTggQEAKICAgICAgICAgfQogICAgIH0gZWxzZSBpZiAoSXNOVjIxKHZpZXcpKSB7CiAgICAgICAgIGlmIChJc05WMTIoaW1nKSkgeworICAgICAgICAgICAgU2NvcGVkVHJhY2UgdHJhY2UoQVRSQUNFX1RBRywgIkltYWdlQ29weTogTlYyMS0+TlYxMiIpOwogICAgICAgICAgICAgaWYgKCFsaWJ5dXY6Ok5WMjFUb05WMTIoc3JjX3ksIH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ICAgICAgfQogICAgIH0gZWxzZSBpZiAoSXNJNDIwKHZpZXcpKSB7CiAgICAgICAgIGlmIChJc05WMTIoaW1nKSkgeworICAgICAgICAgICAgU2NvcGVkVHJhY2UgdHJhY2UoQVRSQUNFX1RBRywgIkltYWdlQ29weTogSTQyMC0+TlYxMiIpOwogICAgICAgICAgICAgaWYgKCFsaWJ5dXY6Okk0MjBUb05WMTIoc3JjX3ksIHNyY19zdHJpZGVfeSwgc3JjX3UsIHNyY19zdHJpZGVfdSwgc3JjX3YsIHNyY19zdHJpZGVfdiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRzdF95LCBkc3Rfc3RyaWRlX3ksIGRzdF91LCBkc3Rfc3RyaWRlX3UsIHdpZHRoLCBoZWlnaHQpKSB7CiAgICAgICAgICAgICAgICAgcmV0dXJuIE9LOwogICAgICAgICAgICAgfQogICAgICAgICB9IGVsc2UgaWYgKElzTlYyMShpbWcpKSB7CisgICAgICAgICAgICBTY29wZWRUcmFjZSB0cmFjZShBVFJBQ0VfVEFHLCAiSW1hZ2VDb3B5OiBJNDIwLT5OVjIxIik7CiAgICAgICAgICAgICBpZiAoIWxpYnl1djo6STQyMFRvTlYyMShzcmNfeSwgc3JjX3N0cmlkZV95LCBzcmNfdSwgc3JjX3N0cmlkZV91LCBzcmNfdiwgc3JjX3N0cmlkZV92LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZHN0X3ksIGRzdF9zdHJpZGVfeSwgZHN0X3YsIGRzdF9zdHJpZGVfdiwgd2lkdGgsIGhlaWdodCkpIHsKICAgICAgICAgICAgICAgICByZXR1cm4gT0s7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0gZWxzZSBpZiAoSXNJNDIwKGltZykpIHsKKyAgICAgICAgICAgIFNjb3BlZFRyYWNlIHRyYWNlKEFUUkFDRV9UQUcsICJJbWFnZUNvcHk6IEk0MjAtPkk0MjAiKTsKICAgICAgICAgICAgIGxpYnl1djo6Q29we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3RyaWRlX3YsIHdpZHRoLCBoZWlnaHQgLyAyKTsKICAgICAgICAgICAgIHJldHVybiBPSzsKICAgICAgICAgfSBlbHNlIGlmIChJc0k0MjAodmlldykpIHsKKyAgICAgICAgICAgIFNjb3BlZFRyYWNlIHRyYWNlKEFUUkFDRV9UQUcsICJJbWFnZUNvcHk6IE5WMjEtPkk0MjAiKTsKICAgICAgICAgICAgIGlmICghbGlieXV2OjpOVjIxVG9JNDIwKHNyY195LCBzcmNfc3RyaWRlX3ksIHNyY192LCBzcmNfc3RyaWRlX3YsIGRzdF95LCBkc3Rfc3RyaWRlX3ksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkc3RfdSwgZHN0X3N0cmlkZV91LCBkc3RfdiwgZHN0X3N0cmlkZV92LCB3aWR0aCwgaGVpZ2h0KSkgewogICAgICAgICAgICAgICAgIHJldHVybiBPSzsKQEAgLTI0MiwyMiArMjY2LDI2IEBACiAgICAgICAgIH0KICAgICB9IGVsc2UgaWYgKElzSTQyMChpbWcpKSB7CiAgICAgICAgIGlmIChJc05WMTIodmlldykpIHsKKyAgICAgICAgICAgIFNjb3BlZFRyYWNlIHRyYWNlKEFUUkFDRV9UQUcsICJJbWFnZUNvcHk6IEk0MjAtPk5WMTIiKTsKICAgICAgICAgICAgIGlmICghbGlieXV2OjpJNDIwVG9OVjEyKHNyY195LCBzcmNfc3RyaWRlX3ksIHNyY191LCBzcmNfc3RyaWRlX3UsIHNyY192LCBzcmNfc3RyaWRlX3YsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkc3RfeSwgZHN0X3N0cmlkZV95LCBkc3RfdSwgZHN0X3N0cmlkZV91LCB3aWR0aCwgaGVpZ2h0KSkgewogICAgICAgICAgICAgICAgIHJldHVybiBPSzsKICAgICAgICAgICAgIH0KICAgICAgICAgfSBlbHNlIGlmIChJc05WMjEodmlldykpIHsKKyAgICAgICAgICAgIFNjb3BlZFRyYWNlIHRyYWNlKEFUUkFD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SGRyMTBQbHVzKGlzSGRyMTBQbHVzKSwgbUJpdERlcHRoKGJpdERlcHRoKSB7fQogCiAgICAgdmlydHVhbCBib29sIHNpbXBsZU1hcChDMkNvbmZpZzo6bGV2ZWxfdCBmcm9tLCBpbnQzMl90ICp0bykgewogICAgICAgICByZXR1cm4gc0F2MUxldmVscy5tYXAoZnJvbSwgdG8pOwpAQCAtNjE0LDIzICs2OTksMzYgQEAKICAgICAgICAgcmV0dXJuIHNBdjFMZXZlbHMubWFwKGZyb20sIHRvKTsKICAgICB9CiAgICAgdmlydHVhbCBib29sIHNpbXBsZU1hcChDMkNvbmZpZzo6cHJvZmlsZV90IGZyb20sIGludDMyX3QgKnRvKSB7Ci0gICAgICAgIHJldHVybiBtSXNIZHIxMFBsdXMgPyBzQXYxSGRyMTBQbHVzUHJvZmlsZXMubWFwKGZyb20sIHRvKSA6Ci0gICAgICAgICAgICAgICAgICAgICBtSXNIZHIgPyBzQXYxSGRyUHJvZmlsZXMubWFwKGZyb20sIHRvKSA6Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzQXYxUHJvZmlsZXMubWFwKGZyb20sIHRvKTsKKyAgICAgICAgcmV0dXJuIChtQml0RGVwdGggPT0gMTApID8gc0F2MVRlbmJpdFByb2ZpbGVzLm1hcChmcm9tLCB0bykgOgorICAgICAgICAgICAgICAgICAgICBtSXNIZHIxMFBsdXMgPyBzQXYxSGRyMTBQbHVzUHJvZmlsZXMubWFwKGZyb20sIHRvKSA6CisgICAgICAgICAgICAgICAgICAgICAgICAgIG1Jc0hkciA/IHNBdjFIZHJQcm9maWxlcy5tYXAoZnJvbSwgdG8pIDoKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc0F2MVByb2ZpbGVzLm1hcChmcm9tLCB0byk7CiAgICAgfQogICAgIHZpcnR1YWwgYm9vbCBzaW1wbGVNYXAoaW50MzJfdCBmcm9tLCBDMkNvbmZpZzo6cHJvZmlsZV90ICp0bykgewotICAgICAgICByZXR1cm4gbUlzSGRyMTBQbHVzID8gc0F2MUhkcjEwUGx1c1Byb2ZpbGVzLm1hcChmcm9tLCB0bykgOgotICAgICAgICAgICAgICAgICAgICAgbUlzSGRyID8gc0F2MUhkclByb2ZpbGVzLm1hcChmcm9tLCB0bykgOgotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc0F2MVByb2ZpbGVzLm1hcChmcm9tLCB0byk7CisgICAgICAgIHJldHVybiAobUJpdERlcHRoID09IDEwKSA/IHNBdjFUZW5iaXRQcm9maWxlcy5tYXAoZnJvbSwgdG8pIDoKKyAgICAgICAgICAgICAgICAgICAgbUlzSGRyMTBQbHVzID8gc0F2MUhkcjEwUGx1c1Byb2ZpbGVzLm1hcChmcm9tLCB0bykgOgorICAgICAgICAgICAgICAgICAgICAgICAgICBtSXNIZHIgPyBzQXYxSGRyUHJvZmlsZXMubWFwKGZyb20sIHRvKSA6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNBdjFQcm9maWxlcy5tYXAoZnJvbSwgdG8pOworICAgIH0KKyAgICB2aXJ0dWFsIGJvb2wgbWFwSGRyRm9ybWF0KGludDMyX3QgZnJvbSwgQzJDb25maWc6Omhkcl9mb3JtYXRfdCAqdG8pIG92ZXJyaWRlIHsKKyAgICAgICAgcmV0dXJuIHNBdjFIZHJGb3JtYXRzLm1hcChmcm9tLCB0byk7CiAgICAgfQogCiBwcml2YXRlOgogICAgIGJvb2wgbUlzSGRyOwogICAgIGJvb2wgbUlzSGRyMTBQbHVzOworICAgIGludDMyX3QgbUJpdERlcHRoOwogfTsKIAogfSAvLyBuYW1lc3BhY2UKIAorLy8gdGhlIGRlZmF1bHQgbWFwcGVyIGlzIHVzZWQgZm9yIG1lZGlhIHR5cGVzIHRoYXQgZG8gbm90IHN1cHBvcnQgSERSCitib29sIEMyTWFwcGVyOjpQcm9maWxlTGV2ZWxNYXBwZXI6Om1hcEhkckZvcm1hdChpbnQzMl90LCBDMkNvbmZpZzo6aGRyX2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ExZISEhCkBAIC0yOCw2ICs0NywxMSBAQAogICAgIG1pbl9zZGtfdmVyc2lvbjogIjI5IiwKICAgICAvLyBUT0RPOiBiLzE0NzE0Nzg4MwogICAgIGRvdWJsZV9sb2FkYWJsZTogdHJ1ZSwKKyAgICBhcGV4X2F2YWlsYWJsZTogWworICAgICAgICAiLy9hcGV4X2F2YWlsYWJsZTpwbGF0Zm9ybSIsCisgICAgICAgICJjb20uYW5kcm9pZC5tZWRpYS5zd2NvZGVjIiwKKyAgICBdLAorCiAKICAgICBzcmNzOiBbCiAgICAgICAgICJDMkFsbG9jYXRvckJsb2IuY3BwIiwKQEAgLTU0LDYgKzc4LDcgQEAKIAogICAgIGV4cG9ydF9zaGFyZWRfbGliX2hlYWRlcnM6IFsKICAgICAgICAgImxpYmJhc2UiLAorICAgICAgICAibGliZG1hYnVmaGVhcCIsCiAgICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLm1lZGlhLmJ1ZmZlcnBvb2xAMi4wIiwKICAgICBdLAogCkBAIC03MywxMSArOTgsMTEgQEAKICAgICAgICAgImxpYmJhc2UiLAogICAgICAgICAibGliY3V0aWxzIiwKICAgICAgICAgImxpYmRsIiwKLSAgICAgICAgImxpYmhhcmR3YXJlIiwKLSAgICAgICAgImxpYmhpZGxiYXNlIiwKLSAgICAgICAgImxpYmlvbiIsCiAgICAgICAgICJsaWJkbWFidWZoZWFwIiwKICAgICAgICAgImxpYmZtcSIsCisgICAgICAgICJsaWJncmFsbG9jdHlwZXMiLAorICAgICAgICAibGliaGlkbGJhc2UiLAorICAgICAgICAibGliaW9uIiwKICAgICAgICAgImxpYmxvZyIsCiAgICAgICAgICJsaWJuYXRpdmV3aW5kb3ciLAogICAgICAgICAibGlic3RhZ2VmcmlnaHRfZm91bmRhdGlvbiIsCkBAIC05Miw2ICsxMTcsNDMgQEAKICAgICBdLAogfQogCisvLyBwdWJsaWMgZGVwZW5kZW5jeSBmb3Igc3RhdGljYWxseSBsaW5raW5nIHRvIGxpYmNvZGVjMl92bmRrIGZvciB1bml0IHRlc3RzCitjY19kZWZhdWx0cyB7CisgICAgbmFtZTogImxpYmNvZGVjMi1zdGF0aWMtZGVmYXVsdHMiLAorCisgICAgc3RhdGljX2xpYnM6IFsKKyAgICAgICAgImxpYmxvZyIsCisgICAgICAgICJsaWJpb24iLAorICAgICAgICAibGliZm1xIiwKKyAgICAgICAgImxpYmJhc2UiLAorICAgICAgICAibGlidXRpbHMiLAorICAgICAgICAibGliY3V0aWxzIiwKKyAgICAgICAgImxpYmNvZGVjMiIsCisgICAgICAgICJsaWJoaWRsYmFzZSIsCisgICAgICAgICJsaWJkbWFidWZoZWFwIiwKKyAgICAgICAgImxpYmNvZGVjMl92bmRrIiwKKyAgICAgICAgImxpYm5hdGl2ZXdpbmRvdyIsCisgICAgICAgICJsaWJjb2RlYzJfc29mdF9jb21tb24iLAorICAgICAgICAibGlic2ZwbHVnaW5fY2NvZGVjX3V0aWxzIiwKKyAgICAgICAgImxpYnN0YWdlZnJpZ2h0X2ZvdW5kYXRpb24iLAorICAgICAgICAibGlic3RhZ2VmcmlnaHRfYnVmZmVycG9vbEAyLjAuMSIsCisgICAgICAgICJsaWJncmFsbG9jdHlwZXMiLAorICAgICAgICAiYW5kcm9pZC5oYXJkd2FyZS5ncmFwaGljcy5tYXBwZXJAMi4wIiwKKyAgICAgICAgImFuZHJvaWQuaGFyZHdhcmUuZ3JhcGhpY3MubWFwcGVyQDMuMCIsCisgICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLm1lZGlhLmJ1ZmZlcnBvb2xAMi4wIiwKKyAgICAgICAgImFuZHJvaWQuaGFyZHdhcmUuZ3JhcGhpY3MuYWxsb2NhdG9yQDIuMCIsCisgICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLmdyYXBoaWNzLmFsbG9jYXRvckAzLjAiLAorICAgICAgICAiYW5kcm9pZC5oYXJkd2FyZS5ncmFwaGljcy5idWZmZXJxdWV1ZUAyLjAiLAorICAgIF0sCisKKyAg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xwdHIpIHsKKyAgICAgICAgcmV0dXJuIEMyX0NPUlJVUFRFRDsKKyAgICB9CisKKyAgICB1c2luZyBhaWRsOjphbmRyb2lkOjpoYXJkd2FyZTo6Z3JhcGhpY3M6OmNvbW1vbjo6UGxhbmVMYXlvdXRDb21wb25lbnRUeXBlOworICAgIHVzaW5nIGFpZGw6OmFuZHJvaWQ6OmhhcmR3YXJlOjpncmFwaGljczo6Y29tbW9uOjpQbGFuZUxheW91dENvbXBvbmVudDsKKworICAgIGxheW91dC0+dHlwZSA9IEMyUGxhbmFyTGF5b3V0OjpUWVBFX1lVVjsKKyAgICBsYXlvdXQtPm51bVBsYW5lcyA9IDA7CisgICAgbGF5b3V0LT5yb290UGxhbmVzID0gMDsKKworICAgIGZvciAoY29uc3QgdWk6OlBsYW5lTGF5b3V0ICZwbGFuZSA6IHBsYW5lcykgeworICAgICAgICBsYXlvdXQtPnJvb3RQbGFuZXMrKzsKKyAgICAgICAgdWludDMyX3QgbGFzdE9mZnNldEluQml0cyA9IDA7CisgICAgICAgIHVpbnQzMl90IHJvb3RJeCA9IGxheW91dC0+bnVtUGxhbmVzOworCisgICAgICAgIGZvciAoY29uc3QgUGxhbmVMYXlvdXRDb21wb25lbnQgJmNvbXBvbmVudCA6IHBsYW5lLmNvbXBvbmVudHMpIHsKKyAgICAgICAgICAgIGlmICghZ3JhbGxvYzQ6OmlzU3RhbmRhcmRQbGFuZUxheW91dENvbXBvbmVudFR5cGUoY29tcG9uZW50LnR5cGUpKSB7CisgICAgICAgICAgICAgICAgbWFwcGVyLnVubG9jayhoYW5kbGUpOworICAgICAgICAgICAgICAgIHJldHVybiBDMl9DQU5OT1RfRE87CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIHVpbnQzMl90IHJpZ2h0U2hpZnRCaXRzID0gY29tcG9uZW50Lm9mZnNldEluQml0cyAtIGxhc3RPZmZzZXRJbkJpdHM7CisgICAgICAgICAgICB1aW50MzJfdCBhbGxvY2F0ZWREZXB0aEluQml0cyA9IGNvbXBvbmVudC5zaXplSW5CaXRzICsgcmlnaHRTaGlmdEJpdHM7CisgICAgICAgICAgICBDMlBsYW5hckxheW91dDo6cGxhbmVfaW5kZXhfdCBwbGFuZUlkOworICAgICAgICAgICAgQzJQbGFuZUluZm86OmNoYW5uZWxfdCBjaGFubmVsOworCisgICAgICAgICAgICBzd2l0Y2ggKHN0YXRpY19jYXN0PFBsYW5lTGF5b3V0Q29tcG9uZW50VHlwZT4oY29tcG9uZW50LnR5cGUudmFsdWUpKSB7CisgICAgICAgICAgICAgICAgY2FzZSBQbGFuZUxheW91dENvbXBvbmVudFR5cGU6Olk6CisgICAgICAgICAgICAgICAgICAgIHBsYW5lSWQgPSBDMlBsYW5hckxheW91dDo6UExBTkVfWTsKKyAgICAgICAgICAgICAgICAgICAgY2hhbm5lbCA9IEMyUGxhbmVJbmZvOjpDSEFOTkVMX1k7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgUGxhbmVMYXlvdXRDb21wb25lbnRUeXBlOjpDQjoKKyAgICAgICAgICAgICAgICAgICAgcGxhbmVJZCA9IEMyUGxhbmFyTGF5b3V0OjpQTEFORV9VOworICAgICAgICAgICAgICAgICAgICBjaGFubmVsID0gQzJQbGFuZUluZm86OkNIQU5ORUxfQ0I7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgUGxhbmVMYXlvdXRDb21wb25lbnRUeXBlOjpDUjoKKyAgICAgICAgICAgICAgICAgICAgcGxhbmVJZCA9IEMyUGxhbmFyTGF5b3V0OjpQTEFORV9WOworICAgICAgICAgICAgICAgICAgICBjaGFubmVsID0gQzJQbGFuZUluZm86OkNIQU5ORUxfQ1I7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgICAgIG1hcHBlci51bmxvY2soaGFuZGxlKTsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEMyX0NPUlJVUFRFRDsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgYWRkcltwbGFuZUlkXSA9IHBvaW50ZXIgKyBwbGFuZS5vZmZzZXRJbkJ5dGVzICsgKGNvbXBvbmVudC5vZmZzZXRJbkJpdHMgLyA4KTsKKyAgICAgICAgICAgIGxheW91dC0+cGxhbmVzW3BsYW5lSWRdID0geworICAgICAgICAgICAgICAgIGNoYW5uZWwsICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gY2hhbm5lbAorICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PGludDMyX3Q+KHBsYW5lLnNhbXBsZUluY3JlbWVudEluQml0cyAvIDgpLCAgLy8gY29sSW5jCisgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8aW50MzJfdD4ocGxhbmUuc3RyaWRlSW5CeXRlcyksICAgICAgICAgICAgICAvLyByb3dJbmMKKyAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDx1aW50MzJfdD4ocGxhbmUuaG9yaXpvbnRhbFN1YnNhbXBsaW5nKSwgICAgIC8vIG1Db2xTYW1wbGluZworICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PHVpbnQzMl90PihwbGFuZS52ZXJ0aWNhbFN1YnNhbXBsaW5nKSwgICAgICAgLy8gbVJvd1NhbXBsaW5nCisgICAgICAgICAgICAgICAgYWxsb2NhdGVkRGVwdGhJbkJpdHMsICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBhbGxvY2F0ZWREZXB0aCAoYml0cykKKyAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDx1aW50MzJfdD4oY29tcG9uZW50LnNpemVJbkJpdHMpLCAgICAgICAgICAgIC8vIGJpdERlcHRoIChiaXRzKQorICAgICAgICAgICAgICAgIHJpZ2h0U2hpZnRCaXRzLCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gcmlnaHRTaGlmdCAoYml0cykKKyAgICAgICAgICAgICAgICBDMlBsYW5lSW5mbzo6TkFUSVZFLCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGVuZGlhbm5lc3MKKyAgICAgICAgICAgICAgICByb290SXgsICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHJvb3RJeAorICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PHVpbnQzMl90Pihjb21wb25lbnQub2Zmc2V0SW5CaXRzIC8gOCksICAgICAgLy8gb2Zmc2V0IChieXRlcykKKyAgICAgICAgICAgIH07CisKKyAgICAgICAgICAgIGxheW91dC0+bnVtUGxhbmVzKys7CisgICAgICAgICAgICBsYXN0T2Zmc2V0SW5CaXRzID0gY29tcG9uZW50Lm9mZnNldEluQml0cyArIGNvbXBvbmVudC5zaXplSW5CaXRzOworICAgICAgICB9CisgICAgfQorICAgIHJldHVybiBDMl9PSzsKK30KKwogfSAvLyB1bm5hbWVkIG5hbWVzcGFjZQogCisKIG5hdGl2ZV9oYW5kbGVfdCAqVW53cmFwTmF0aXZlQ29kZWMyR3JhbGxvY0hhbmRsZShjb25zdCBDMkhhbmRsZSAqY29uc3QgaGFuZGxlKSB7CiAgICAgcmV0dXJuIEMySGFuZGxlR3JhbGxvYzo6VW53cmFwTmF0aXZlSGFuZGxlKGhhbmRsZSk7CiB9CkBAIC0zODUsNiArNDcwLDEwIEBACiAgICAgICAgICAgICAgICAgbUJ1ZmZlciwgbVdpZHRoLCBtSGVpZ2h0LCBtRm9ybWF0LCBtR3JhbGxvY1VzYWdlLAogICAgICAgICAgICAgICAgIG1TdHJpZGUsIGdlbmVyYXRpb24sIGlnYnBfaWQsIGlnYnBfc2xvdCk7CiAgICAgfQorCisgICAgLy8gJ05BVElWRScgb24gQW5kcm9pZCBtZWFucyBMSVRUTEVfRU5ESUFOCisgICAgY29uc3RleHByIEMyUGxhbmVJbmZvOjplbmRpYW5uZXNzX3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0gZWxzZSBpZiAodXZPZmZzZXQgPCAwICYmIHV2T2Zmc2V0ID4gLShpbnRwdHJfdCl5Y2JjckxheW91dC5jaHJvbWFfc3RlcCkgewotICAgICAgICAgICAgICAgIGxheW91dC0+cm9vdFBsYW5lcyA9IDI7Ci0gICAgICAgICAgICAgICAgbGF5b3V0LT5wbGFuZXNbQzJQbGFuYXJMYXlvdXQ6OlBMQU5FX1VdLnJvb3RJeCA9IEMyUGxhbmFyTGF5b3V0OjpQTEFORV9WOwotICAgICAgICAgICAgICAgIGxheW91dC0+cGxhbmVzW0MyUGxhbmFyTGF5b3V0OjpQTEFORV9VXS5vZmZzZXQgPSAtdXZPZmZzZXQ7Ci0gICAgICAgICAgICB9CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogCkBAIC02NDYsNyArNzI0LDcgQEAKICAgICAgICAgICAgICAgICAxNiwgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGFsbG9jYXRlZERlcHRoCiAgICAgICAgICAgICAgICAgMTAsICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBiaXREZXB0aAogICAgICAgICAgICAgICAgIDYsICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gcmlnaHRTaGlmdAotICAgICAgICAgICAgICAgIEMyUGxhbmVJbmZvOjpMSVRUTEVfRU5ELCAgICAgICAgLy8gZW5kaWFubmVzcworICAgICAgICAgICAgICAgIGtFbmRpYW5uZXNzLCAgICAgICAgICAgICAgICAgICAgLy8gZW5kaWFubmVzcwogICAgICAgICAgICAgICAgIEMyUGxhbmFyTGF5b3V0OjpQTEFORV9ZLCAgICAgICAgLy8gcm9vdEl4CiAgICAgICAgICAgICAgICAgMCwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBvZmZzZXQKICAgICAgICAgICAgIH07CkBAIC02NTksNyArNzM3LDcgQEAKICAgICAgICAgICAgICAgICAxNiwgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGFsbG9jYXRlZERlcHRoCiAgICAgICAgICAgICAgICAgMTAsICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBiaXREZXB0aAogICAgICAgICAgICAgICAgIDYsICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gcmlnaHRTaGlmdAotICAgICAgICAgICAgICAgIEMyUGxhbmVJbmZvOjpMSVRUTEVfRU5ELCAgICAgICAgLy8gZW5kaWFubmVzcworICAgICAgICAgICAgICAgIGtFbmRpYW5uZXNzLCAgICAgICAgICAgICAgICAgICAgLy8gZW5kaWFubmVzcwogICAgICAgICAgICAgICAgIEMyUGxhbmFyTGF5b3V0OjpQTEFORV9VLCAgICAgICAgLy8gcm9vdEl4CiAgICAgICAgICAgICAgICAgMCwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBvZmZzZXQKICAgICAgICAgICAgIH07CkBAIC02NzIsNyArNzUwLDcgQEAKICAgICAgICAgICAgICAgICAxNiwgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGFsbG9jYXRlZERlcHRoCiAgICAgICAgICAgICAgICAgMTAsICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBiaXREZXB0aAogICAgICAgICAgICAgICAgIDYsICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gcmlnaHRTaGlmdAotICAgICAgICAgICAgICAgIEMyUGxhbmVJbmZvOjpMSVRUTEVfRU5ELCAgICAgICAgLy8gZW5kaWFubmVzcworICAgICAgICAgICAgICAgIGtFbmRpYW5uZXNzLCAgICAgICAgICAgICAgICAgICAgLy8gZW5kaWFubmVzcwogICAgICAgICAgICAgICAgIEMyUGxhbmFyTGF5b3V0OjpQTEFORV9VLCAgICAgICAgLy8gcm9vdEl4CiAgICAgICAgICAgICAgICAgMiwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBvZmZzZXQKICAgICAgICAgICAgIH07CkBAIC02ODAsOSArNzU4LDE1IEBACiAgICAgICAgIH0KIAogICAgICAgICBkZWZhdWx0OiB7Ci0gICAgICAgICAgICAvLyBXZSBkb24ndCBrbm93IHdoYXQgaXQgaXMsIGJ1dCBsZXQncyB0cnkgdG8gbG9jayBpdC4KKyAgICAgICAgICAgIC8vIFdlIGRvbid0IGtub3cgd2hhdCBpdCBpcywgbGV0J3MgdHJ5IHRvIGxvY2sgaXQgd2l0aCBncmFsbG9jNAogICAgICAgICAgICAgYW5kcm9pZF95Y2JjciB5Y2JjckxheW91dDsKKyAgICAgICAgICAgIGMyX3N0YXR1c190IHN0YXR1cyA9IEdyYWxsb2M0TWFwcGVyX2xvY2soCisgICAgICAgICAgICAgICAgICAgIGNvbnN0X2Nhc3Q8bmF0aXZlX2hhbmRsZV90Kj4obUJ1ZmZlciksIGdyYWxsb2NVc2FnZSwgcmVjdCwgbGF5b3V0LCBhZGRyKTsKKyAgICAgICAgICAgIGlmIChzdGF0dXMgPT0gQzJfT0spIHsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIH0KIAorICAgICAgICAgICAgLy8gZmFsbGJhY2sgdG8gbG9ja1lDYkNyCiAgICAgICAgICAgICBzdGF0dXNfdCBlcnIgPSBHcmFwaGljQnVmZmVyTWFwcGVyOjpnZXQoKS5sb2NrWUNiQ3IoCiAgICAgICAgICAgICAgICAgICAgIGNvbnN0X2Nhc3Q8bmF0aXZlX2hhbmRsZV90Kj4obUJ1ZmZlciksIGdyYWxsb2NVc2FnZSwgcmVjdCwgJnljYmNyTGF5b3V0KTsKICAgICAgICAgICAgIGlmIChlcnIgPT0gT0sgJiYgeWNiY3JMYXlvdXQueSAmJiB5Y2JjckxheW91dC5jYiAmJiB5Y2JjckxheW91dC5jcgpAQCAtNzM0LDE3ICs4MTgsNiBAQAogICAgICAgICAgICAgICAgICAgICBDMlBsYW5hckxheW91dDo6UExBTkVfViwgICAgICAgICAgLy8gcm9vdEl4CiAgICAgICAgICAgICAgICAgICAgIDAsICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBvZmZzZXQKICAgICAgICAgICAgICAgICB9OwotICAgICAgICAgICAgICAgIC8vIGhhbmRsZSBpbnRlcmxlYXZlZCBmb3JtYXRzCi0gICAgICAgICAgICAgICAgaW50cHRyX3QgdXZPZmZzZXQgPSBhZGRyW0MyUGxhbmFyTGF5b3V0OjpQTEFORV9WXSAtIGFkZHJbQzJQbGFuYXJMYXlvdXQ6OlBMQU5FX1VdOwotICAgICAgICAgICAgICAgIGlmICh1dk9mZnNldCA+IDAgJiYgdXZPZmZzZXQgPCAoaW50cHRyX3QpeWNiY3JMYXlvdXQuY2hyb21hX3N0ZXApIHsKLSAgICAgICAgICAgICAgICAgICAgbGF5b3V0LT5yb290UGxhbmVzID0gMjsKLSAgICAgICAgICAgICAgICAgICAgbGF5b3V0LT5wbGFuZXNbQzJQbGFuYXJMYXlvdXQ6OlBMQU5FX1ZdLnJvb3RJeCA9IEMyUGxhbmFyTGF5b3V0OjpQTEFORV9VOwotICAgICAgICAgICAgICAgICAgICBsYXlvdXQtPnBsYW5lc1tDMlBsYW5hckxheW91dDo6UExBTkVfVl0ub2Zmc2V0ID0gdXZPZmZzZXQ7Ci0gICAgICAgICAgICAgICAgfSBlbHNlIGlmICh1dk9mZnNldCA8IDAgJiYgdXZPZmZzZXQgPiAtKGludHB0cl90KXljYmNyTGF5b3V0LmNocm9tYV9zdGVwKSB7Ci0gICAgICAgICAgICAgICAgICAgIGxheW91dC0+cm9vdFBsYW5lcyA9IDI7Ci0gICAgICAgICAgICAgICAgICAgIGxheW91dC0+cGxhbmVzW0MyUGxhbmFyTGF5b3V0OjpQTEFORV9VXS5yb290SXggPSBDMlBsYW5hckxheW91dDo6UExBTkVfVjsKLSAgICAgICAgICAgICAgICAgICAgbGF5b3V0LT5wbGFuZXNbQzJQbGFuYXJMYXlvdXQ6OlBMQU5FX1VdLm9mZnNldCA9IC11dk9mZnNldDsKLSAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICB9CiAKQEAgLTc5MCw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zcGFjZSBhbmRyb2lkOworCitjbGFzcyBfQzJGZW5jZUZhY3Rvcnk6OlN5bmNGZW5jZUltcGwgOiBwdWJsaWMgQzJGZW5jZTo6SW1wbCB7CitwdWJsaWM6CisgICAgdmlydHVhbCBjMl9zdGF0dXNfdCB3YWl0KGMyX25zZWNzX3QgdGltZW91dE5zKSB7CisgICAgICAgIGMyX25zZWNzX3QgdGltZW91dE1zID0gdGltZW91dE5zIC8gMTAwMDsKKyAgICAgICAgaWYgKHRpbWVvdXRNcyA+IElOVF9NQVgpIHsKKyAgICAgICAgICAgIHRpbWVvdXRNcyA9IElOVF9NQVg7CisgICAgICAgIH0KKworICAgICAgICBzd2l0Y2ggKG1GZW5jZS0+d2FpdCgoaW50KXRpbWVvdXRNcykpIHsKKyAgICAgICAgICAgIGNhc2UgTk9fRVJST1I6CisgICAgICAgICAgICAgICAgcmV0dXJuIEMyX09LOworICAgICAgICAgICAgY2FzZSAtRVRJTUU6CisgICAgICAgICAgICAgICAgcmV0dXJuIEMyX1RJTUVEX09VVDsKKyAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgcmV0dXJuIEMyX0NPUlJVUFRFRDsKKyAgICAgICAgfQorICAgIH0KKworICAgIHZpcnR1YWwgYm9vbCB2YWxpZCgpIGNvbnN0IHsKKyAgICAgICAgcmV0dXJuIG1GZW5jZS0+Z2V0U3RhdHVzKCkgIT0gRmVuY2U6OlN0YXR1czo6SW52YWxpZDsKKyAgICB9CisKKyAgICB2aXJ0dWFsIGJvb2wgcmVhZHkoKSBjb25zdCB7CisgICAgICAgIHJldHVybiBtRmVuY2UtPmdldFN0YXR1cygpID09IEZlbmNlOjpTdGF0dXM6OlNpZ25hbGVkOworICAgIH0KKworICAgIHZpcnR1YWwgaW50IGZkKCkgY29uc3QgeworICAgICAgICByZXR1cm4gbUZlbmNlLT5kdXAoKTsKKyAgICB9CisKKyAgICB2aXJ0dWFsIGJvb2wgaXNIVygpIGNvbnN0IHsKKyAgIC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gICAgICAgICBIQnVmZmVyIGNvbnN0JiBoQnVmZmVyLAogICAgICAgICAgICAgICAgICAgICB1aW50MzJfdCBnZW5lcmF0aW9uTnVtYmVyKXsKICAgICAgICAgICAgICAgICBpZiAoaDJiKGhTdGF0dXMsICZzdGF0dXMpICYmCi0gICAgICAgICAgICAgICAgICAgICAgICBoMmIoaEJ1ZmZlciwgJnNsb3RCdWZmZXIpICYmCisgICAgICAgICAgICAgICAgICAgICAgICBoZ2JwX2gyYihoQnVmZmVyLCAmc2xvdEJ1ZmZlcikgJiYKICAgICAgICAgICAgICAgICAgICAgICAgIHNsb3RCdWZmZXIpIHsKICAgICAgICAgICAgICAgICAgICAgKmdlbmVyYXRpb24gPSBnZW5lcmF0aW9uTnVtYmVyOwogICAgICAgICAgICAgICAgICAgICAqdXNhZ2UgPSBzbG90QnVmZmVyLT5nZXRVc2FnZSgpOwpAQCAtNDAyLDcgKzQ4OCw3IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSEJ1ZmZlciBjb25zdCYgaEJ1ZmZlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aW50MzJfdCBnZW5lcmF0aW9uTnVtYmVyKXsKICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoMmIoaFN0YXR1cywgJnN0YXR1cykgJiYKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaDJiKGhCdWZmZXIsICZzbG90QnVmZmVyKSAmJgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZ2JwX2gyYihoQnVmZmVyLCAmc2xvdEJ1ZmZlcikgJiYKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2xvdEJ1ZmZlcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNsb3RCdWZmZXItPnNldEdlbmVyYXRpb25OdW1iZXIoZ2VuZXJhdGlvbk51bWJlcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0R2VuZXJhdGlvbiA9IGdlbmVyYXRpb25OdW1iZXI7CkBAIC00NTYsNyArNTQyLDcgQEAKICAgICAgICAgICAgICAgICAgICAgICAgIHN0ZDo6bWFrZV9zaGFyZWQ8QzJCdWZmZXJRdWV1ZUJsb2NrUG9vbERhdGE+KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzbG90QnVmZmVyLT5nZXRHZW5lcmF0aW9uTnVtYmVyKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1Qcm9kdWNlcklkLCBzbG90LAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtUHJvZHVjZXIsIG1TeW5jTWVtLCAwKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUlnYnBWYWxpZGl0eVRva2VuLCBtUHJvZHVjZXIsIG1TeW5jTWVtKTsKICAgICAgICAgICAgICAgICBtUG9vbERhdGFzW3Nsb3RdID0gcG9vbERhdGE7CiAgICAgICAgICAgICAgICAgKmJsb2NrID0gX0MyQmxvY2tGYWN0b3J5OjpDcmVhdGVHcmFwaGljQmxvY2soYWxsb2MsIHBvb2xEYXRhKTsKICAgICAgICAgICAgICAgICByZXR1cm4gQzJfT0s7CkBAIC00ODUsMTkgKzU3MSwxMyBAQAogcHVibGljOgogICAgIEltcGwoY29uc3Qgc3RkOjpzaGFyZWRfcHRyPEMyQWxsb2NhdG9yPiAmYWxsb2NhdG9yKQogICAgICAgICA6IG1Jbml0KEMyX09LKSwgbVByb2R1Y2VySWQoMCksIG1HZW5lcmF0aW9uKDApLAotICAgICAgICAgIG1EcUZhaWx1cmUoMCksIG1MYXN0RHFUcygwKSwgbUxhc3REcUxvZ1RzKDApLAotICAgICAgICAgIG1BbGxvY2F0b3IoYWxsb2NhdG9yKSB7CisgICAgICAgICAgbUNvbnN1bWVyVXNhZ2UoMCksIG1EcUZhaWx1cmUoMCksIG1MYXN0RHFUcygwKSwKKyAgICAgICAgICBtTGFzdERxTG9nVHMoMCksIG1BbGxvY2F0b3IoYWxsb2NhdG9yKSwgbUlnYnBWYWxpZGl0eVRva2VuKHN0ZDo6bWFrZV9zaGFyZWQ8aW50PigwKSkgewogICAgIH0KIAogICAgIH5JbXBsKCkgewotICAgICAgICBib29sIG5vSW5pdCA9IGZhbHNlOworICAgICAgICBtSWdicFZhbGlkaXR5VG9rZW4ucmVzZXQoKTsKICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBOVU1fQlVGRkVSX1NMT1RTOyArK2kpIHsKLSAgICAgICAgICAgIGlmICghbm9Jbml0ICYmIG1Qcm9kdWNlcikgewotICAgICAgICAgICAgICAgIFJldHVybjxIU3RhdHVzPiB0cmFuc1Jlc3VsdCA9Ci0gICAgICAgICAgICAgICAgICAgICAgICBtUHJvZHVjZXItPmRldGFjaEJ1ZmZlcihzdGF0aWNfY2FzdDxpbnQzMl90PihpKSk7Ci0gICAgICAgICAgICAgICAgbm9Jbml0ID0gIXRyYW5zUmVzdWx0LmlzT2soKSB8fAotICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PEhTdGF0dXM+KHRyYW5zUmVzdWx0KSA9PSBIU3RhdHVzOjpOT19JTklUOwotICAgICAgICAgICAgfQogICAgICAgICAgICAgbUJ1ZmZlcnNbaV0uY2xlYXIoKTsKICAgICAgICAgfQogICAgIH0KQEAgLTUzOSw3ICs2MTksNyBAQAogICAgICAgICAgICAgfQogICAgICAgICAgICAgc3RkOjpzaGFyZWRfcHRyPEMyQnVmZmVyUXVldWVCbG9ja1Bvb2xEYXRhPiBwb29sRGF0YSA9CiAgICAgICAgICAgICAgICAgICAgIHN0ZDo6bWFrZV9zaGFyZWQ8QzJCdWZmZXJRdWV1ZUJsb2NrUG9vbERhdGE+KAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIDAsICh1aW50NjRfdCkwLCB+MCwgbnVsbHB0ciwgbnVsbHB0ciwgMCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgMCwgKHVpbnQ2NF90KTAsIH4wLCBudWxscHRyLCBudWxscHRyLCBudWxscHRyKTsKICAgICAgICAgICAgICpibG9jayA9IF9DMkJsb2NrRmFjdG9yeTo6Q3JlYXRlR3JhcGhpY0Jsb2NrKGFsbG9jLCBwb29sRGF0YSk7CiAgICAgICAgICAgICBBTE9HVigiYWxsb2NhdGVkIGEgYnVmZmVyIHN1Y2Nlc3NmdWxseSIpOwogCkBAIC02MDYsMTUgKzY4Niw2IEBACiAgICAgICAgIHsKICAgICAgICAgICAgIHNwPEdyYXBoaWNCdWZmZXI+IGJ1ZmZlcnNbTlVNX0JVRkZFUl9TTE9UU107CiAgICAgICAgICAgICBzdGQ6OnNjb3BlZF9sb2NrPHN0ZDo6bXV0ZXg+IGxvY2sobU11dGV4KTsKLSAgICAgICAgICAgIGJvb2wgbm9Jbml0ID0gZmFsc2U7Ci0gICAgICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IE5VTV9CVUZGRVJfU0xPVFM7ICsraSkgewotICAgICAgICAgICAgICAgIGlmICghbm9Jbml0ICYmIG1Qcm9kdWNlcikgewotICAgICAgICAgICAgICAgICAgICBSZXR1cm48SFN0YXR1cz4gdHJhbnNSZXN1bHQgPQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1Qcm9kdWNlci0+ZGV0YWNoQnVmZmVyKHN0YXRpY19jYXN0PGludDMyX3Q+KGkpKTsKLSAgICAgICAgICAgICAgICAgICAgbm9Jbml0ID0gIXRyYW5zUmVzdWx0LmlzT2soKSB8fAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxIU3RhdHVzPih0cmFuc1Jlc3VsdCkgPT0gSFN0YXR1czo6Tk9fSU5JVDsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICB9CiAgICAgICAgICAgICBpbnQzMl90IG9sZEdlbmVyYXRpb24gPSBtR2VuZXJhdGlvbjsKICAgICAgICAgICAgIGlmIChwcm9kdWNlcikgewogICAgICAgICAgICAgICAgIG1Qcm9kdWNlciA9IHByb2R1Y2VyOwpAQCAtNjI0LDggKzY5NSw3IEBACiAgICAgICAgICAgICAgICAgbVByb2R1Y2VyID0gbnVsbHB0cjsKICAgICAgICAgICAgICAgICBtUHJvZHVjZXJJZCA9IDA7CiAgICAgICAgICAgICAgICAgbUdlbmVyYXRpb24gPSAwOwotICAgICAgICAgICAgICAgIEFMT0dXKCJpbnZhbGlkIHByb2R1Y2VyIHByb2R1Y2VyKCVkKSwgZ2VuZXJhdGlvbiglZCkiLAotICAgICAgICAgICAgICAgICAgICAgIChib29sKXByb2R1Y2VyLCBicUluZm9ybWF0aW9uKTsKKyAgICAgICAgICAgICAgICBBTE9HRCgiY29uZmlndXJpbmcgbnVsbCBwcm9kdWNlcjogaWdicF9pbmZvcm1hdGlvbiglZCkiLCBicUluZm9ybWF0aW9uKTsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIG9sZE1lbSA9IG1TeW5jTWVtOyAvLyBwcmV2ZW4gZGVzdHJ1Y3Rpb24gd2hpbGUgbG9ja2VkLgogICAgICAgICAgICAgbVN5bmNNZW0gPSBjMlN5bmNNZW07CkBAIC02NTAsNiArNzIwLDEwIEBACiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIC8vIG9sZCBidWZmZXJzIHNob3VsZCBub3QgYmUgY2FuY2VsbGVkIHNpbmNlIHRoZSBhc3NvY2lhdGVkIElHQlAKKyAgICAgICAgICAgICAgICAvLyBpcyBubyBsb25nZXIgdmFsaWQuCisgICAgICAgICAgICAgICAgbUlnYnBWYWxpZGl0eVRva2VuID0gc3RkOjptYWtlX3NoYXJlZDxpbnQ+KDApOwogICAgICAgICAgICAgfQogICAgICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBOVU1fQlVGRkVSX1NMT1RTOyArK2kpIHsKICAgICAgICAgICAgICAgICBtQnVmZmVyc1tpXSA9IGJ1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NyYy92b3AuY3BwCkBAIC0xMDcsMjYgKzEwNyw1NyBAQAogI2lmbmRlZiBQVl9UT0xFUkFURV9WT0xfRVJST1JTCiAgICAgICAgIGlmIChsYXllcikgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiAgICAqLwogICAgICAgICB7Ci0gICAgICAgICAgICAvKiBzdXBwb3J0IFNTUEwwLTIgICovCi0gICAgICAgICAgICBpZiAodG1wdmFyICE9IDB4MTAgJiYgdG1wdmFyICE9IDB4MTEgJiYgdG1wdmFyICE9IDB4MTIgJiYKLSAgICAgICAgICAgICAgICAgICAgdG1wdmFyICE9IDB4QTEgJiYgdG1wdmFyICE9IDB4QTIgICYmIHRtcHZhciAhPSAweEEzLyogQ29yZSBTUEBMMS1MMyAqLykKLSAgICAgICAgICAgICAgICByZXR1cm4gUFZfRkFJTDsKKyAgICAgICAgICAgIHN3aXRjaCAodG1wdmFyKQorICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIC8qIFNpbXBsZSBTY2FsYWJsZSBQcm9maWxlIExldmVscyAqLworICAgICAgICAgICAgICAgIGNhc2UgMHgxMDoKKyAgICAgICAgICAgICAgICBjYXNlIDB4MTE6CisgICAgICAgICAgICAgICAgY2FzZSAweDEyOgorICAgICAgICAgICAgICAgIC8qIENvcmUgU2NhbGFibGUgUHJvZmlsZSBMZXZlbHMgKi8KKyAgICAgICAgICAgICAgICBjYXNlIDB4QTE6CisgICAgICAgICAgICAgICAgY2FzZSAweEEyOgorICAgICAgICAgICAgICAgIGNhc2UgMHhBMzoKKyAgICAgICAgICAgICAgICAgICAgLy8gRG8gTm90aGluZywgdGhlIGNhc2VzIGxpc3RlZCBhYm92ZSBhcmUgc3VwcG9ydGVkIHZhbHVlcworICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgICAgICAvLyBVbnN1cHBvcnQgcHJvZmlsZSBsZXZlbAorICAgICAgICAgICAgICAgICAgICByZXR1cm4gUFZfRkFJTDsKKyAgICAgICAgICAgICAgfQogICAgICAgICB9CiAgICAgICAgIGVsc2UKICAgICAgICAgewotICAgICAgICAgICAgLyogc3VwcG9ydCBTUEwwLTMgJiBTU1BMMC0yICAgKi8KLSAgICAgICAgICAgIGlmICh0bXB2YXIgIT0gMHgwMSAmJiB0bXB2YXIgIT0gMHgwMiAmJiB0bXB2YXIgIT0gMHgwMyAmJiB0bXB2YXIgIT0gMHgwOCAmJgotICAgICAgICAgICAgICAgICAgICAvKiBXaGlsZSBub3QgdGVjaG5pY2FsbHkgc3VwcG9ydGVkLCB0cnkgdG8gZGVjb2RlIFNQTDQmU1BMNSBmaWxlcyBhcyB3ZWxsLiAqLwotICAgICAgICAgICAgICAgICAgICAvKiBXZSdsbCBmYWlsIGxhdGVyIGlmIHRoZSBzaXplIGlzIHRvbyBsYXJnZS4gIFRoaXMgaXMgdG8gYWxsb3cgcGxheWJhY2sgb2YgKi8KLSAgICAgICAgICAgICAgICAgICAgLyogc29tZSA8PUNJRiBmaWxlcyBnZW5lcmF0ZWQgYnkgb3RoZXIgZW5jb2RlcnMuICovCi0gICAgICAgICAgICAgICAgICAgIHRtcHZhciAhPSAweDA0ICYmIHRtcHZhciAhPSAweDA1ICYmCi0gICAgICAgICAgICAgICAgICAgIHRtcHZhciAhPSAweDEwICYmIHRtcHZhciAhPSAweDExICYmIHRtcHZhciAhPSAweDEyICYmCi0gICAgICAgICAgICAgICAgICAgIHRtcHZhciAhPSAweDIxICYmIHRtcHZhciAhPSAweDIyICYmICAvKiBDb3JlIFByb2ZpbGUgTGV2ZWxzICovCi0gICAgICAgICAgICAgICAgICAgIHRtcHZhciAhPSAweEExICYmIHRtcHZhciAhPSAweEEyICYmIHRtcHZhciAhPSAweEEzICYmCi0gICAgICAgICAgICAgICAgICAgIHRtcHZhciAhPSAweEYwICYmIHRtcHZhciAhPSAweEYxICYmIC8qIEFkdmFuY2VkIFNpbXBsZSBQcm9maWxlIExldmVscyovCi0gICAgICAgICAgICAgICAgICAgIHRtcHZhciAhPSAweEYyICYmIHRtcHZhciAhPSAweEYzICYmCi0gICAgICAgICAgICAgICAgICAgIHRtcHZhciAhPSAweEY0ICYmIHRtcHZhciAhPSAweEY1KQotICAgICAgICAgICAgICAgIHJldHVybiBQVl9GQUlMOworICAgICAgICAgICAgc3dpdGNoICh0bXB2YXIpCisgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgLyogU2ltcGxlIFByb2ZpbGUgTGV2ZWxzICovCisgICAgICAgICAgICAgICAgY2FzZSAweDAxOgorICAgICAgICAgICAgICAgIGNhc2UgMHgwMjoKKyAgICAgICAgICAgICAgICBjYXNlIDB4MDM6CisgICAgICAgICAgICAgICAgY2FzZSAweDA0OgorICAgICAgICAgICAgICAgIGNhc2UgMHgwNToKKyAgICAgICAgICAgICAgICBjYXNlIDB4MDY6CisgICAgICAgICAgICAgICAgY2FzZSAweDA4OgorICAgICAgICAgICAgICAgIGNhc2UgMHgxMDoKKyAgICAgICAgICAgICAgICBjYXNlIDB4MTE6CisgICAgICAgICAgICAgICAgY2FzZSAweDEyOgorICAgICAgICAgICAgICAgIC8qIENvcmUgUHJvZmlsZSBMZXZlbHMgKi8KKyAgICAgICAgICAgICAgICBjYXNlIDB4MjE6CisgICAgICAgICAgICAgICAgY2FzZSAweDIyOgorICAgICAgICAgICAgICAgIGNhc2UgMHhBMToKKyAgICAgICAgICAgICAgICBjYXNlIDB4QTI6CisgICAgICAgICAgICAgICAgY2FzZSAweEEzOgorICAgICAgICAgICAgICAgIC8qIEFkdmFuY2VkIFNpbXBsZSBQcm9maWxlIExldmVscyovCisgICAgICAgICAgICAgICAgY2FzZSAweEYwOgorICAgICAgICAgICAgICAgIGNhc2UgMHhGMToKKyAgICAgICAgICAgICAgICBjYXNlIDB4RjI6CisgICAgICAgICAgICAgICAgY2FzZSAweEYzOgorICAgICAgICAgICAgICAgIGNhc2UgMHhGNDoKKyAgICAgICAgIC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WRpYS9leHRyYWN0b3JzL2FtciIsCi0gICAgXSwKLQogICAgIHN0YXRpY19saWJzOiBbCiAgICAgICAgICJsaWJhbXJleHRyYWN0b3IiLAogICAgIF0sCkBAIC0xOTMsMTAgKzE3Miw2IEBACiAgICAgICAgICJta3ZfZXh0cmFjdG9yX2Z1enplci5jcHAiLAogICAgIF0sCiAKLSAgICBpbmNsdWRlX2RpcnM6IFsKLSAgICAgICAgImZyYW1ld29ya3MvYXYvbWVkaWEvZXh0cmFjdG9ycy9ta3YiLAotICAgIF0sCi0KICAgICBzdGF0aWNfbGliczogWwogICAgICAgICAibGlid2VibSIsCiAgICAgICAgICJsaWJzdGFnZWZyaWdodF9mbGFjZGVjIiwKQEAgLTIxNyw5ICsxOTIsNiBAQAogICAgICAgICAib2dnX2V4dHJhY3Rvcl9mdXp6ZXIuY3BwIiwKICAgICBdLAogCi0gICAgaW5jbHVkZV9kaXJzOiBbCi0gICAgICAgICJmcmFtZXdvcmtzL2F2L21lZGlhL2V4dHJhY3RvcnMvb2dnIiwKLSAgICBdLAogCiAgICAgc3RhdGljX2xpYnM6IFsKICAgICAgICAgImxpYnN0YWdlZnJpZ2h0X21ldGFkYXRhdXRpbHMiLApAQCAtMjY1LDEwICsyMzcsNiBAQAogICAgICAgICAibXAzX2V4dHJhY3Rvcl9mdXp6ZXIuY3BwIiwKICAgICBdLAogCi0gICAgaW5jbHVkZV9kaXJzOiBbCi0gICAgICAgICJmcmFtZXdvcmtzL2F2L21lZGlhL2V4dHJhY3RvcnMvbXAzIiwKLSAgICBdLAotCiAgICAgc3RhdGljX2xpYnM6IFsKICAgICAgICAgImxpYmZpZm8iLAogICAgICAgICAibGlibXAzZXh0cmFjdG9yIiwKQEAgLTI4NSwxMCArMjUzLDYgQEAKICAgICAgICAgImFhY19leHRyYWN0b3JfZnV6emVyLmNwcCIsCiAgICAgXSwKIAotICAgIGluY2x1ZGVfZGlyczogWwotICAgICAgICAiZnJhbWV3b3Jrcy9hdi9tZWRpYS9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oY29uc3QgdWludDhfdCAqKWRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1aW50OF90IHByb2ZpbGUgPSBwdHJbMl0gPj4gMTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVpbnQ4X3QgYmxfY29tcGF0aWJpbGl0eV9pZCA9IChwdHJbNF0pID4+IDQ7CisgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1aW50OF90IGJsQ29tcGF0aWJpbGl0eUlkID0gKHB0cls0XSkgPj4gNDsKICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgY3JlYXRlX3R3b190cmFja3MgPSBmYWxzZTsKIAotICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJsX2NvbXBhdGliaWxpdHlfaWQgJiYgYmxfY29tcGF0aWJpbGl0eV9pZCAhPSAxNSkgeworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJsQ29tcGF0aWJpbGl0eUlkICYmIGJsQ29tcGF0aWJpbGl0eUlkICE9IDE1KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlX3R3b190cmFja3MgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgfQogCkBAIC0xMTQ3LDEzICsxMTQ3LDE1IEBACiAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFja19iLT50aW1lc2NhbGUgPSBtTGFzdFRyYWNrLT50aW1lc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhY2tfYi0+c2FtcGxlVGFibGUgPSBtTGFzdFRyYWNrLT5zYW1wbGVUYWJsZTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFja19iLT5pbmNsdWRlc19leHBlbnNpdmVfbWV0YWRhdGEgPSBtTGFzdFRyYWNrLT5pbmNsdWRlc19leHBlbnNpdmVfbWV0YWRhdGE7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhY2tfYi0+aW5jbHVkZXNfZXhwZW5zaXZlX21ldGFkYXRhID0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUxhc3RUcmFjay0+aW5jbHVkZXNfZXhwZW5zaXZlX21ldGFkYXRhOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYWNrX2ItPnNraXBUcmFjayA9IG1MYXN0VHJhY2stPnNraXBUcmFjazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFja19iLT5lbHN0X25lZWRzX3Byb2Nlc3NpbmcgPSBtTGFzdFRyYWNrLT5lbHN0X25lZWRzX3Byb2Nlc3Npbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhY2tfYi0+ZWxzdF9tZWRpYV90aW1lID0gbUxhc3RUcmFjay0+ZWxzdF9tZWRpYV90aW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYWNrX2ItPmVsc3Rfc2VnbWVudF9kdXJhdGlvbiA9IG1MYXN0VHJhY2stPmVsc3Rfc2VnbWVudF9kdXJhdGlvbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFja19iLT5lbHN0X3NoaWZ0X3N0YXJ0X3RpY2tzID0gbUxhc3RUcmFjay0+ZWxzdF9zaGlmdF9zdGFydF90aWNrczsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFja19iLT5lbHN0X2luaXRpYWxfZW1wdHlfZWRpdF90aWNrcyA9IG1MYXN0VHJhY2stPmVsc3RfaW5pdGlhbF9lbXB0eV9lZGl0X3RpY2tzOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYWNrX2ItPmVsc3RfaW5pdGlhbF9lbXB0eV9lZGl0X3RpY2tzID0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUxhc3RUcmFjay0+ZWxzdF9pbml0aWFsX2VtcHR5X2VkaXRfdGlja3M7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhY2tfYi0+c3Vic2FtcGxlX2VuY3J5cHRpb24gPSBtTGFzdFRyYWNrLT5zdWJzYW1wbGVfZW5jcnlwdGlvbjsKIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYWNrX2ItPm1UeDNnQnVmZmVyID0gbUxhc3RUcmFjay0+bVR4M2dCdWZmZXI7CkBAIC0yNTkxLDkgKzI1OTMsMTEgQEAKICAgICAgICAgICAgICpvZmZzZXQgKz0gY2h1bmtfc2l6ZTsKICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICB9Ci0gICAgICAgIGNhc2UgRk9VUkNDKCJkdmNDIik6Ci0gICAgICAgIGNhc2UgRk9VUkNDKCJkdnZDIik6IHsKIAorICAgICAgICBjYXNlIEZPVVJDQygiZHZjQyIpOgorICAgICAgICBjYXNlIEZPVVJDQygiZHZ2QyIpOgorICAgICAgICBjYXNlIEZPVVJDQygiZHZ3QyIpOgorICAgICAgICB7CiAgICAgICAgICAgICBpZiAoY2h1bmtfZGF0YV9zaXplICE9IDI0KSB7CiAgICAgICAgICAgICAgICAgcmV0dXJuIEVSUk9SX01BTEZPUk1FRDsKICAgICAgICAgICAgIH0KQEAgLTI2MTMsMTMgKzI2MTcsMTQgQEAKICAgICAgICAgICAgICAgICByZXR1cm4gRVJST1JfTUFMRk9STUVEOwogCiAgICAgICAgICAgICBBTWVkaWFGb3JtYXRfc2V0QnVmZmVyKG1MYXN0VHJhY2stPm1ldGEsIEFNRURJQUZPUk1BVF9LRVlfQ1NEXzIsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ1ZmZlci5nZXQoKSwgY2h1bmtfZGF0YV9zaXplKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ1ZmZlci5nZXQoKSwgY2h1bmtfZGF0YV9zaXplKTsKICAgICAgICAgICAgIEFNZWRpYUZvcm1hdF9zZXRTdHJpbmcobUxhc3RUcmFjay0+bWV0YSwgQU1FRElBRk9STUFUX0tFWV9NSU1FLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNRURJQV9NSU1FVFlQRV9WSURFT19ET0xCWV9WSVNJT04pOwogCiAgICAgICAgICAgICAqb2Zmc2V0ICs9IGNodW5rX3NpemU7CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQorCiAgICAgICAgIGNhc2UgRk9VUkNDKCJkMjYzIik6CiAgICAgICAgIHsKICAgICAgICAgICAgICpvZmZzZXQgKz0gY2h1bmtfc2l6ZTsKQEAgLTM0ODAsNyArMzQ4NSw3IEBACiAgICAgICAgIH0KICAgICAgICAgdW5zaWduZWQgbWFzayA9IGJyLmdldEJpdHMoOCk7CiAgICAgICAgIGZvciAodW5zaWduZWQgaSA9IDA7IGkgPCA4OyBpKyspIHsKLSAgICAgICAgICAgIGlmICgoKDB4MSA8PCBpKSAmJiBtYXNrKSA9PSAwKQorICAgICAgICAgICAgaWYgKCgoMHgxIDw8IGkpICYgbWFzaykgPT0gMCkKICAgICAgICAgICAgICAgICBjb250aW51ZTsKIAogICAgICAgICAgICAgaWYgKGJyLm51bUJpdHNMZWZ0KCkgPCA4KSB7CkBAIC00NDU4LDcgKzQ0NjMsNiBAQAogICAgIGlmICghQU1lZGlhRm9ybWF0X2dldFN0cmluZyh0cmFjay0+bWV0YSwgQU1FRElBRk9STUFUX0tFWV9NSU1FLCAmbWltZSkpIHsKICAgICAgICAgcmV0dXJuIE5VTEw7CiAgICAgfQotCiAgICAgc3A8SXRlbVRhYmxlPiBpdGVtVGFibGU7CiAgICAgaWYgKCFzdHJjYXNlY21wKG1pbWUsIE1FRElBX01JTUVUWVBFX1ZJREVPX0FWQykpIHsKICAgICAgICAgdm9pZCAqZGF0YTsKQEAgLTQ0OTEsMTQgKzQ0OTUsMTQgQEAKICAgICB9IGVsc2UgaWYgKCFzdHJjYXNlY21wKG1pbWUsIE1FRElBX01JTUVUWVBFX1ZJREVPX0RPTEJZX1ZJU0lPTikpIHsKICAgICAgICAgdm9pZCAqZGF0YTsKICAgICAgICAgc2l6ZV90IHNpemU7Ci0gICAgICAg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IGJldHdlZW4gLTEuMCBhbmQgKzEuMAorICovCitzdGF0aWMgZmxvYXQgc19idXJuQ1BVKGludDMyX3Qgd29ya2xvYWQpIHsKKyAgICB1aW50MzJfdCByYW5kb20gPSAwOworICAgIGZvciAoaW50MzJfdCBpID0gMDsgaSA8IHdvcmtsb2FkOyBpKyspIHsKKyAgICAgICAgZm9yIChpbnQzMl90IGogPSAwOyBqIDwgMTA7IGorKykgeworICAgICAgICAgICAgcmFuZG9tID0gcmFuZG9tIF4gc19yYW5kb20xNigpOworICAgICAgICB9CisgICAgfQorICAgIHJldHVybiAocmFuZG9tIC0gMzI3NjgpICogKDEuMCAvIDMyNzY4KTsKK30KKwogLyoqCiAgKiBTaW1wbGUgd3JhcHBlciBmb3IgQUF1ZGlvIHRoYXQgb3BlbnMgYW4gb3V0cHV0IHN0cmVhbSBlaXRoZXIgaW4gY2FsbGJhY2sgb3IgYmxvY2tpbmcgd3JpdGUgbW9kZS4KICAqLwpAQCAtMjY4LDExICsyOTMsMTMgQEAKICAgICBpbnQzMl90ICAgICAgICAgICAgdGltZXN0YW1wQ291bnQgPSAwOyAvLyBpbiB0aW1lc3RhbXBzCiAgICAgaW50MzJfdCAgICAgICAgICAgIHNhbXBsZVJhdGUgPSA0ODAwMDsKICAgICBpbnQzMl90ICAgICAgICAgICAgcHJlZml4VG9uZUZyYW1lcyA9IDA7CisgICAgZG91YmxlICAgICAgICAgICAgIHdvcmtsb2FkID0gMC4wOwogICAgIGJvb2wgICAgICAgICAgICAgICBzd2VlcFNldHVwID0gZmFsc2U7CiAKICAgICBpbnQgICAgICAgICAgICAgICAgc2NoZWR1bGVyID0gMDsKICAgICBib29sICAgICAgICAgICAgICAgc2NoZWR1bGVyQ2hlY2tlZCA9IGZhbHNlOwogICAgIGludDMyX3QgICAgICAgICAgICBoYW5nVGltZU1TZWMgPSAwOworICAgIGludCAgICAgICAgICAgICAgICBjcHVBZmZpbml0eSA9IC0xOwogCiAgICAgQUF1ZGlvU2ltcGxlU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ZpbmUgQVBQX1ZFUlNJT04gICIwLjIuMSIKIAotY29uc3RleHByIGludDMyX3Qga0RlZmF1bHRIYW5nVGltZU1TZWMgPSAxMDsKLQorc3RhdGljIGNvbnN0ZXhwciBpbnQzMl90IGtEZWZhdWx0SGFuZ1RpbWVNU2VjID0gMTA7CitzdGF0aWMgY29uc3RleHByIGludDMyX3Qga1dvcmtQZXJpb2RTZWNvbmRzID0gNjsKIC8qKgogICogT3BlbiBzdHJlYW0sIHBsYXkgc29tZSBzaW5lIHdhdmVzLCB0aGVuIGNsb3NlIHRoZSBzdHJlYW0uCiAgKgpAQCAtNDQsNyArNDQsMTEgQEAKIHN0YXRpYyBhYXVkaW9fcmVzdWx0X3QgdGVzdE9wZW5QbGF5Q2xvc2UoQUF1ZGlvQXJnc1BhcnNlciAmYXJnUGFyc2VyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQzMl90IGxvb3BDb3VudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBwcmVmaXhUb25lTXNlYywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBoYW5nVGltZU1TZWMpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3QgaGFuZ1RpbWVNU2VjLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgICAgIGNwdUFmZmluaXR5LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb3VibGUgIGxvd1dvcmtMb2FkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb3VibGUgIGhpZ2hXb3JrTG9hZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCB3b3JrUGVyaW9kU2Vjb25kcykKIHsKICAgICBTaW5lVGhyZWFkZWREYXRhX3QgbX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hZCAlOGQgPSAlOGQiCisgICAgICAgICAgICAgICAgICAgIiwgd29yayA9ICU1LjFmLCB1bmRlcnJ1bnMgPSAlZFxuIiwKICAgICAgICAgICAgICAgICAgICByZXN1bHQsIChpbnQpIG1pbGxpcywKICAgICAgICAgICAgICAgICAgICBzZWNvbmQsCiAgICAgICAgICAgICAgICAgICAgZnJhbWVzV3JpdHRlbiwKICAgICAgICAgICAgICAgICAgICBmcmFtZXNSZWFkLAogICAgICAgICAgICAgICAgICAgIGZyYW1lc1dyaXR0ZW4gLSBmcmFtZXNSZWFkLAorICAgICAgICAgICAgICAgICAgIG15RGF0YS53b3JrbG9hZCwKICAgICAgICAgICAgICAgICAgICB4cnVucyk7CiAgICAgICAgICAgICBpZiAocmVzdWx0ICE9IEFBVURJT19PSykgewogICAgICAgICAgICAgICAgIGRpc2Nvbm5lY3RlZCA9IChyZXN1bHQgPT0gQUFVRElPX0VSUk9SX0RJU0NPTk5FQ1RFRCk7CkBAIC0yMjAsNiArMjI5LDExIEBACiAgICAgQUF1ZGlvQXJnc1BhcnNlcjo6dXNhZ2UoKTsKICAgICBwcmludGYoIiAgICAgIC1se2NvdW50fSBsb29wQ291bnQgc3RhcnQvc3RvcCwgZXZlcnkgb3RoZXIgb25lIGlzIHNpbGVudFxuIik7CiAgICAgcHJpbnRmKCIgICAgICAtdHttc2VjfSAgcGxheSBhIGhpZ2ggcGl0Y2hlZCB0b25lIGF0IHRoZSBiZWdpbm5pbmdcbiIpOworICAgIHByaW50ZigiICAgICAgLXd7d29ya2xvYWR9ICBzZXQgYmFzZSB3b3JrbG9hZCwgZGVmYXVsdCAwLjBcbiIpOworICAgIHByaW50ZigiICAgICAgLVd7d29ya2xvYWR9ICBhbHRlcm5hdGUgYmV0d2VlbiB0aGlzIGhpZ2hlciB3b3JrbG9hZCBhbmQgYmFzZSB3b3JrbG9hZFxuIik7CisgICAgcHJpbnRmKCIgICAgICAtWntkdXJhdGlvbn0gIG51bWJlciBvZiBzZWNvbmRzIHRvIHNwZW5kIGF0IGVhY2ggd29ya2xvYWQsIGRlZmF1bHQgPSAlZFxuIiwKKyAgICAgICAgICAga1dvcmtQZXJpb2RTZWNvbmRzKTsKKyAgICBwcmludGYoIiAgICAgIC1he2NwdX0gICBzZXQgQ1BVIGFmZmluaXR5LCBkZWZhdWx0IG5vbmVcbiIpOwogICAgIHByaW50ZigiICAgICAgLWh7bXNlY30gIGZvcmNlIHBlcmlvZGljIHVuZGVycnVucyBieSBoYW5naW5nIGluIGNhbGxiYWNrXG4iKTsKICAgICBwcmludGYoIiAgICAgICAgICAgICAgICBJZiBubyB2YWx1ZSBzcGVjaWZpZWQgdGhlbiAlZCB1c2VkLlxuIiwKICAgICAgICAgICAgIGtEZWZhdWx0SGFuZ1RpbWVNU2VjKTsKQEAgLTIzMiw2ICsyNDYsMTAgQEAKICAgICBpbnQzMl90ICAgICAgICAgICAgbG9vcENvdW50ID0gMTsKICAgICBpbnQzMl90ICAgICAgICAgICAgcHJlZml4VG9uZU1zZWMgPSAwOwogICAgIGludDMyX3QgICAgICAgICAgICBoYW5nVGltZU1TZWMgPSAwOworICAgIGludCAgICAgICAgICAgICAgICBjcHVBZmZpbml0eSA9IC0xOworICAgIGRvdWJsZSAgICAgICAgICAgICBsb3dXb3JrTG9hZCA9IDAuMDsKKyAgICBkb3VibGUgICAgICAgICAgICAgaGlnaFdvcmtMb2FkID0gLTEuMDsKKyAgICBpbnQzMl90ICAgICAgICAgICAgd29ya1BlcmlvZFNlY29uZHMgPSBrV29ya1BlcmlvZFNlY29uZHM7CiAKICAgICAvLyBNYWtlIHByaW50ZiBwcmludCBpbW1lZGlhdGVseSBzbyB0aGF0IGRlYnVnIGluZm8gaXMgbm90IHN0dWNrCiAgICAgLy8gaW4gYSBidWZmZXIgaWYgd2UgaGFuZyBvciBjcmFzaC4KQEAgLTI0Nyw2ICsyNjUsOSBAQAogICAgICAgICAgICAgaWYgKGFyZ1swXSA9PSAnLScpIHsKICAgICAgICAgICAgICAgICBjaGFyIG9wdGlvbiA9IGFyZ1sxXTsKICAgICAgICAgICAgICAgICBzd2l0Y2ggKG9wdGlvbikgeworICAgICAgICAgICAgICAgICAgICBjYXNlICdhJzoKKyAgICAgICAgICAgICAgICAgICAgICAgIGNwdUFmZmluaXR5ID0gYXRvaSgmYXJnWzJdKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICBjYXNlICdsJzoKICAgICAgICAgICAgICAgICAgICAgICAgIGxvb3BDb3VudCA9IGF0b2koJmFyZ1syXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKQEAgLTI1OCw2ICsyNzksMTUgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgPyBhdG9pKCZhcmdbMl0pCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDoga0RlZmF1bHRIYW5nVGltZU1TZWM7CiAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgY2FzZSAndyc6CisgICAgICAgICAgICAgICAgICAgICAgICBsb3dXb3JrTG9hZCA9IGF0b2YoJmFyZ1syXSk7CisgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgY2FzZSAnVyc6CisgICAgICAgICAgICAgICAgICAgICAgICBoaWdoV29ya0xvYWQgPSBhdG9mKCZhcmdbMl0pOworICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1onOgorICAgICAgICAgICAgICAgICAgICAgICAgd29ya1BlcmlvZFNlY29uZHMgPSBhdG9pKCZhcmdbMl0pOworICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICB1c2FnZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgZXhpdChFWElUX0ZBSUxVUkUpOwpAQC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W5zZS1mYXEKKyAgICAvLyBBIGxhcmdlLXNjYWxlLWNoYW5nZSBhZGRlZCAnZGVmYXVsdF9hcHBsaWNhYmxlX2xpY2Vuc2VzJyB0byBpbXBvcnQKKyAgICAvLyBhbGwgb2YgdGhlICdsaWNlbnNlX2tpbmRzJyBmcm9tICJmcmFtZXdvcmtzX2F2X2xpY2Vuc2UiCisgICAgLy8gdG8gZ2V0IHRoZSBiZWxvdyBsaWNlbnNlIGtpbmRzOgorICAgIC8vICAgU1BEWC1saWNlbnNlLWlkZW50aWZpZXItQXBhY2hlLTIuMAorICAgIGRlZmF1bHRfYXBwbGljYWJsZV9saWNlbnNlczogWyJmcmFtZXdvcmtzX2F2X2xpY2Vuc2UiXSwKK30KKworY2NfZnV6eiB7CisgICAgbmFtZTogImxpYmFhdWRpb19mdXp6ZXIiLAorICAgIHNyY3M6IFsKKyAgICAgICAgImxpYmFhdWRpb19mdXp6ZXIuY3BwIiwKKyAgICBdLAorICAgIGhlYWRlcl9saWJzOiBbCisgICAgICAgICJsaWJhYXVkaW9faGVhZGVycyIsCisgICAgXSwKKyAgICBzaGFyZWRfbGliczogWworICAgICAgICAibGliYmluZGVyIiwKKyAgICAgICAgImxpYmF1ZGlvbWFuYWdlciIsCisgICAgICAgICJsaWJhdWRpb3BvbGljeSIsCisgICAgICAgICJsaWJhdWRpb2NsaWVudF9haWRsX2NvbnZlcnNpb24iLAorICAgICAgICAibGlidXRpbHMiLAorICAgIF0sCisgICAgc3RhdGljX2xpYnM6IFsKKyAgICAgICAgImFuZHJvaWQubWVkaWEuYXVkaW8uY29tbW9uLnR5cGVzLVYxLWNwcCIsCisgICAgICAgICJsaWJsb2ciLAorICAgICAgICAibGliY3V0aWxzIiwKKyAgICAgICAgImxpYmFhdWRpbyIsCisgICAgICAgICJsaWJqc29uY3BwIiwKKyAgICAgICAgImxpYmJhc2VfbmRrIiwKKyAgICAgICAgImxpYmNncm91cHJjIiwKKyAgICAgICAgImxpYmF1ZGlvdXRpbHM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ESU9fRk9STUFUX1BDTV9JMjRfUEFDS0VELCBBQVVESU9fRk9STUFUX1BDTV9JMzJ9OworCitjb25zdGV4cHIgYWF1ZGlvX3NoYXJpbmdfbW9kZV90IGtTaGFyaW5nTW9kZXNbXSA9IHsKKyAgICBBQVVESU9fU0hBUklOR19NT0RFX0VYQ0xVU0lWRSwgQUFVRElPX1NIQVJJTkdfTU9ERV9TSEFSRUR9OworCitjb25zdGV4cHIgaW50MzJfdCBrU2FtcGxlUmF0ZXNbXSA9IHtBQVVESU9fVU5TUEVDSUZJRUQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA4MDAwLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMTEwMjUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAxNjAwMCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDIyMDUwLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMzIwMDAsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA0NDEwMCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDQ4MDAwLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgODgyMDAsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA5NjAwMH07CisKK2NvbnN0ZXhwciBhYXVkaW9fdXNhZ2VfdCBrVXNhZ2VzW10gPSB7CisgICAgQUFVRElPX1VTQUdFX01FRElBLAorICAgIEFBVURJT19VU0FHRV9WT0lDRV9DT01NVU5JQ0FUSU9OLAorICAgIEFBVURJT19VU0FHRV9WT0lDRV9DT01NVU5JQ0FUSU9OX1NJR05BTExJTkcsCisgICAgQUFVRElPX1VTQUdFX0FMQVJNLAorICAgIEFBVURJT19VU0FHRV9OT1RJRklDQVRJT04sCisgICAgQUFVRElPX1VTQUdFX05PVElGSUNBVElPTl9SSU5HVE9ORSwKKyAgICBBQVVESU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AgICBmaW5hbFJlcG9ydCArPSAiY29tbWVudCwgY29tbWFuZCwgIiArIGZvcm1hdEVuZXJneUhlYWRlcigpICsgIlxuIgorICAgIGNvbW1lbnQgPSAiIgorICAgIHRyeToKKyAgICAgICAgZnAgPSBvcGVuKGZpbGVOYW1lKQorICAgICAgICBsaW5lID0gZnAucmVhZGxpbmUoKQorICAgICAgICB3aGlsZSBsaW5lOgorICAgICAgICAgICAgY29tbWFuZCA9IGxpbmUuc3RyaXAoKQorICAgICAgICAgICAgaWYgY29tbWFuZC5zdGFydHN3aXRoKCIjIik6CisgICAgICAgICAgICAgICAgIyBpZ25vcmUgY29tbWVudAorICAgICAgICAgICAgICAgIHByaW50KChjb21tYW5kICsgIlxuIikpCisgICAgICAgICAgICAgICAgY29tbWVudCA9IGNvbW1hbmRbMTpdLnN0cmlwKCkgIyByZW1vdmUgbGVhZGluZyAnIycKKyAgICAgICAgICAgIGVsaWYgY29tbWFuZC5lbmRzd2l0aCgnXFwnKToKKyAgICAgICAgICAgICAgICBjb21tYW5kID0gY29tbWFuZFs6LTFdLnN0cmlwKCkgIyByZW1vdmUgdHJhaWxpbmcgJ1wnCisgICAgICAgICAgICAgICAgcnVuQ29tbWFuZChjb21tYW5kKQorICAgICAgICAgICAgZWxpZiBjb21tYW5kOgorICAgICAgICAgICAgICAgIHJlcG9ydCA9IGF2ZXJhZ2VFbmVyZ3lGb3JDb21tYW5kKGNvbW1hbmQsIERFRkFVTFRfTlVNX0lURVJBVElPTlMpCisgICAgICAgICAgICAgICAgZmluYWxSZXBvcnQgKz0gY29tbWVudCArICIsICIgKyBjb21tYW5kICsgIiwgIiArIGZvcm1hdEVuZXJneURhdGEocmVwb3J0KSArICJcbiIKKyAgICAgICAgICAgICAgICBwcmludChmaW5hbFJlcG9ydCkKKyAgICAgICAgICAgIGxpbmUgPSBmcC5yZWFkbGluZSgpCisgICAgZmluYWxseToKKyAgICAgICAgZnAuY2xvc2UoKQorICAgIHJldHVybiBmaW5hbFJlcG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libGUgc3ltYm9sLgpAQCAtNTIsNyArMTEwLDcgQEAKICAgICAgICAgImxpYmN1dGlscyIsCiAgICAgICAgICJsaWJ1dGlscyIsCiAgICAgICAgICJsaWJiaW5kZXIiLAotICAgICAgICAibGlicGVybWlzc2lvbiIsCisgICAgICAgICJmcmFtZXdvcmstcGVybWlzc2lvbi1haWRsLWNwcCIsCiAgICAgXSwKIAogICAgIHNhbml0aXplOiB7CkBAIC02NCw2ICsxMjIsMTMgQEAKICAgICAgICAgc3ltYm9sX2ZpbGU6ICJsaWJhYXVkaW8ubWFwLnR4dCIsCiAgICAgICAgIHZlcnNpb25zOiBbIjI4Il0sCiAgICAgfSwKKworICAgIHRpZHk6IHRydWUsCisgICAgdGlkeV9jaGVja3M6IHRpZHlfZXJyb3JzLAorICAgIHRpZHlfY2hlY2tzX2FzX2Vycm9yczogdGlkeV9lcnJvcnMsCisgICAgdGlkeV9mbGFnczogWworICAgICAgICAiLWZvcm1hdC1zdHlsZT1maWxlIiwKKyAgICBdCiB9CiAKIGNjX2xpYnJhcnkgewpAQCAtMTAyLDYgKzE2Nyw4IEBACiAgICAgICAgICJsaWJiaW5kZXIiLAogICAgICAgICAiZnJhbWV3b3JrLXBlcm1pc3Npb24tYWlkbC1jcHAiLAogICAgICAgICAiYWF1ZGlvLWFpZGwtY3BwIiwKKyAgICAgICAgImFuZHJvaWQubWVkaWEuYXVkaW8uY29tbW9uLnR5cGVzLVYxLWNwcCIsCisgICAgICAgICJhdWRpb2NsaWVudC10eXBlcy1haWRsLWNwcCIsCiAgICAgICAgICJsaWJhdWRpb2NsaWVudF9haWRsX2NvbnZlcnNpb24iLAogICAgIF0sCiAKQEAgLTEzOSwxMCArMjA2LDE2IEBACiAgICAgICAgICJiaW5kaW5nL1JpbmdCdWZmZXJQYXJjZWxhYmxlLmNwcCIsCiAgICAgICAgICJiaW5kaW5nL1NoYXJlZE1lbW9yeVBhcmNlbGFibGUuY3BwIiwKICAgICAgICAgImJpbmRpbmcvU2hhc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2dyYXBoL0NsaXBUb1JhbmdlLmg+CisjaW5jbHVkZSA8Zmxvd2dyYXBoL01hbnlUb011bHRpQ29udmVydGVyLmg+CisjaW5jbHVkZSA8Zmxvd2dyYXBoL01vbm9CbGVuZC5oPgogI2luY2x1ZGUgPGZsb3dncmFwaC9Nb25vVG9NdWx0aUNvbnZlcnRlci5oPgorI2luY2x1ZGUgPGZsb3dncmFwaC9NdWx0aVRvTWFueUNvbnZlcnRlci5oPgogI2luY2x1ZGUgPGZsb3dncmFwaC9SYW1wTGluZWFyLmg+CiAKIGNsYXNzIEFBdWRpb0Zsb3dHcmFwaCB7CkBAIC0zNiwxMiArNDAsMTkgQEAKICAgICAgKiBAcGFyYW0gc291cmNlQ2hhbm5lbENvdW50CiAgICAgICogQHBhcmFtIHNpbmtGb3JtYXQKICAgICAgKiBAcGFyYW0gc2lua0NoYW5uZWxDb3VudAorICAgICAqIEBwYXJhbSB1c2VNb25vQmxlbmQKKyAgICAgKiBAcGFyYW0gYXVkaW9CYWxhbmNlCisgICAgICogQHBhcmFtIGNoYW5uZWxNYXNrCisgICAgICogQHBhcmFtIGlzRXhjbHVzaXZlCiAgICAgICogQHJldHVybgogICAgICAqLwogICAgIGFhdWRpb19yZXN1bHRfdCBjb25maWd1cmUoYXVkaW9fZm9ybWF0X3Qgc291cmNlRm9ybWF0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBzb3VyY2VDaGFubmVsQ291bnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19mb3JtYXRfdCBzaW5rRm9ybWF0LAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBzaW5rQ2hhbm5lbENvdW50KTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3Qgc2lua0NoYW5uZWxDb3VudCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgdXNlTW9ub0JsZW5kLAorICAgICAgICAgICAgICAgIC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XNjcmlwdG9yLT5yZWFkQ291bnRlckFkZHJlc3MgPT0gbnVsbHB0cikKKyAgICBpbnQ2NF90ICpyZWFkQ291bnRlckFkZHJlc3MgPSAoZGVzY3JpcHRvci5yZWFkQ291bnRlckFkZHJlc3MgPT0gbnVsbHB0cikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA/ICZtRGF0YVJlYWRDb3VudGVyCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiBkZXNjcmlwdG9yLT5yZWFkQ291bnRlckFkZHJlc3M7Ci0gICAgaW50NjRfdCAqd3JpdGVDb3VudGVyQWRkcmVzcyA9IChkZXNjcmlwdG9yLT53cml0ZUNvdW50ZXJBZGRyZXNzID09IG51bGxwdHIpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiBkZXNjcmlwdG9yLnJlYWRDb3VudGVyQWRkcmVzczsKKyAgICBpbnQ2NF90ICp3cml0ZUNvdW50ZXJBZGRyZXNzID0gKGRlc2NyaXB0b3Iud3JpdGVDb3VudGVyQWRkcmVzcyA9PSBudWxscHRyKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID8gJm1EYXRhV3JpdGVDb3VudGVyCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiBkZXNjcmlwdG9yLT53cml0ZUNvdW50ZXJBZGRyZXNzOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDogZGVzY3JpcHRvci53cml0ZUNvdW50ZXJBZGRyZXNzOwogCiAgICAgLy8gQ2xlYXIgYnVmZmVyIHRvIGF2b2lkIGFuIGluaXRpYWwgZ2xpdGNoIG9uIHNvbWUgZGV2aWNlcy4KLSAgICBzaXplX3QgYnVmZmVyU2l6ZUJ5dGVzID0gZGVzY3JpcHRvci0+Y2FwYWNpdHlJbkZyYW1lcyAqIGRlc2NyaXB0b3ItPmJ5dGVzUGVyRnJhbWU7Ci0gICAgbWVtc2V0KGRlc2NyaXB0b3ItPm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JjL2NsaWVudC9BdWRpb1N0cmVhbUludGVybmFsUGxheS5jcHAKaW5kZXggNzFiZGU5MC4uN2M3YTk2OSAxMDA2NDQKLS0tIGEvbWVkaWEvbGliYWF1ZGlvL3NyYy9jbGllbnQvQXVkaW9TdHJlYW1JbnRlcm5hbFBsYXkuY3BwCisrKyBiL21lZGlhL2xpYmFhdWRpby9zcmMvY2xpZW50L0F1ZGlvU3RyZWFtSW50ZXJuYWxQbGF5LmNwcApAQCAtNDQsOCArNDQsNiBAQAogCiB9CiAKLUF1ZGlvU3RyZWFtSW50ZXJuYWxQbGF5Ojp+QXVkaW9TdHJlYW1JbnRlcm5hbFBsYXkoKSB7fQotCiBjb25zdGV4cHIgaW50IGtSYW1wTVNlYyA9IDEwOyAvLyB0aW1lIHRvIGFwcGx5IGEgY2hhbmdlIGluIHZvbHVtZQogCiBhYXVkaW9fcmVzdWx0X3QgQXVkaW9TdHJlYW1JbnRlcm5hbFBsYXk6Om9wZW4oY29uc3QgQXVkaW9TdHJlYW1CdWlsZGVyICZidWlsZGVyKSB7CkBAIC01NCw3ICs1MiwxMCBAQAogICAgICAgICByZXN1bHQgPSBtRmxvd0dyYXBoLmNvbmZpZ3VyZShnZXRGb3JtYXQoKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2V0U2FtcGxlc1BlckZyYW1lKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldERldmljZUZvcm1hdCgpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXREZXZpY2VDaGFubmVsQ291bnQoKSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldERldmljZUNoYW5uZWxDb3VudCgpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXRSZXF1aXJlTW9ub0JsZW5kKCksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldEF1ZGlvQmFsYW5jZSgpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoZ2V0U2hhcmluZ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6Om1lZGlhOjphdWRpbzo6Y29tbW9uOjpBdWRpb01NYXBQb2xpY3lJbmZvOwordXNpbmcgYW5kcm9pZDo6bWVkaWE6OmF1ZGlvOjpjb21tb246OkF1ZGlvTU1hcFBvbGljeVR5cGU7CisKICNkZWZpbmUgQUFVRElPX01NQVBfUE9MSUNZX0RFRkFVTFQgICAgICAgICAgICAgQUFVRElPX1BPTElDWV9ORVZFUgogI2RlZmluZSBBQVVESU9fTU1BUF9FWENMVVNJVkVfUE9MSUNZX0RFRkFVTFQgICBBQVVESU9fUE9MSUNZX05FVkVSCiAKQEAgLTUzLDE2ICs2MiwxMCBAQAogLyoKICAqIEF1ZGlvU3RyZWFtQnVpbGRlcgogICovCi1BdWRpb1N0cmVhbUJ1aWxkZXI6OkF1ZGlvU3RyZWFtQnVpbGRlcigpIHsKLX0KLQotQXVkaW9TdHJlYW1CdWlsZGVyOjp+QXVkaW9TdHJlYW1CdWlsZGVyKCkgewotfQotCiBzdGF0aWMgYWF1ZGlvX3Jlc3VsdF90IGJ1aWxkZXJfY3JlYXRlU3RyZWFtKGFhdWRpb19kaXJlY3Rpb25fdCBkaXJlY3Rpb24sCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFhdWRpb19zaGFyaW5nX21vZGVfdCBzaGFyaW5nTW9kZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCB0cnlNTWFwLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbmRyb2lkOjpzcDxBdWRpb1N0cmVhbT4gJnN0cmVhbSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhYXVkaW9fc2hhcmluZ19tb2RlX3QgLypzaGFyaW5nTW9kZSovLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIHRyeU1NYXAsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC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KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi1BdWRpb0Zsb2F0QmxvY2tQb3J0OjpBdWRpb0Zsb2F0QmxvY2tQb3J0KEF1ZGlvUHJvY2Vzc29yQmFzZSAmcGFyZW50LAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3Qgc2FtcGxlc1BlckZyYW1lLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3QgZnJhbWVzUGVyQmxvY2spCi0gICAgICAgIDogQXVkaW9Qb3J0KHBhcmVudCwgc2FtcGxlc1BlckZyYW1lKQotICAgICAgICAsIG1GcmFtZXNQZXJCbG9jayhmcmFtZXNQZXJCbG9jaykKLSAgICAgICAgLCBtU2FtcGxlQmxvY2soTlVMTCkgewotICAgIGludDMyX3QgbnVtRmxvYXRzID0gZnJhbWVzUGVyQmxvY2sgKiBnZXRTYW1wbGVzUGVyRnJhbWUoKTsKLSAgICBtU2FtcGxlQmxvY2sgPSBuZXcgZmxvYXRbbnVtRmxvYXRzXXswLjBmfTsKLX0KLQotQXVkaW9GbG9hdEJsb2NrUG9ydDo6fkF1ZGlvRmxvYXRCbG9ja1BvcnQoKSB7Ci0gICAgZGVsZXRlW10gbVNhbXBsZUJsb2NrOwotfQotCi0vKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwotaW50MzJfdCBBdWRpb0Zsb2F0T3V0cHV0UG9ydDo6cHVsbERhdGEoaW50NjRfdCBmcmFtZVBvc2l0aW9uLCBpbnQzMl90IG51bUZyYW1lcykgewotICAgIG51bUZyYW1lcyA9IHN0ZDo6bWluKGdldEZyYW1lc1BlckJsb2NrKCksIG51bUZyYW1lcyk7Ci0gICAgcmV0dXJuIG1QYXJlbnQucHVsbERhdGEoZnJhbWVQb3NpdGlvbiwgbnVtRnJhbWVzKTsKLX0KLQotLy8gVGhlc2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gZ292ZXJuaW5nIHBlcm1pc3Npb25zIGFuZAorICogbGltaXRhdGlvbnMgdW5kZXIgdGhlIExpY2Vuc2UuCisgKi8KKworI2lmbmRlZiBGTE9XR1JBUEhfQ0hBTk5FTF9DT1VOVF9DT05WRVJURVJfSAorI2RlZmluZSBGTE9XR1JBUEhfQ0hBTk5FTF9DT1VOVF9DT05WRVJURVJfSAorCisjaW5jbHVkZSA8dW5pc3RkLmg+CisjaW5jbHVkZSA8c3lzL3R5cGVzLmg+CisKKyNpbmNsdWRlICJGbG93R3JhcGhOb2RlLmgiCisKK25hbWVzcGFjZSBGTE9XR1JBUEhfT1VURVJfTkFNRVNQQUNFOjpmbG93Z3JhcGggeworCisvKioKKyAqIENoYW5nZSB0aGUgbnVtYmVyIG9mIG51bWJlciBvZiBjaGFubmVscyB3aXRob3V0IG1peGluZy4KKyAqIFdoZW4gaW5jcmVhc2luZyB0aGUgY2hhbm5lbCBjb3VudCwgZHVwbGljYXRlIGlucHV0IGNoYW5uZWxzLgorICogV2hlbiBkZWNyZWFzaW5nIHRoZSBjaGFubmVsIGNvdW50LCBkcm9wIGlucHV0IGNoYW5uZWxzLgorICovCisgICAgY2xhc3MgQ2hhbm5lbENvdW50Q29udmVydGVyIDogcHVibGljIEZsb3dHcmFwaE5vZGUgeworICAgIHB1YmxpYzoKKyAgICAgICAgZXhwbGljaXQgQ2hhbm5lbENvdW50Q29udmVydGVyKAorICAgICAgICAgICAgICAgIGludDMyX3QgaW5wdXRDaGFubmVsQ291bnQsCisgICAgICAgICAgICAgICAgaW50MzJfdCBvdXRwdXRDaGFubmVsQ291bnQpOworCisgICAgICAgIHZpcnR1YWwgfkNoYW5uZWxDb3VudENvbnZlcnRlcigpOworCisgICAgICAgIGludDMyX3Qgb25Qcm9jZXNzKGludDMyX3QgbnVtRnJhbWVzKSBvdmVycmlkZTsKKworICAgICAgICBjb25zdCBjaGFyICpnZXROYW1lKCkgb3ZlcnJpZGUgeworICAgICAgICAgICAgcmV0dXJu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x1ZGUgPGFsZ29yaXRobT4KKyNpbmNsdWRlIDxzeXMvdHlwZXMuaD4KKyNpbmNsdWRlICJGbG93R3JhcGhOb2RlLmgiCisKK3VzaW5nIG5hbWVzcGFjZSBGTE9XR1JBUEhfT1VURVJfTkFNRVNQQUNFOjpmbG93Z3JhcGg7CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCitpbnQzMl90IEZsb3dHcmFwaE5vZGU6OnB1bGxEYXRhKGludDMyX3QgbnVtRnJhbWVzLCBpbnQ2NF90IGNhbGxDb3VudCkgeworICAgIGludDMyX3QgZnJhbWVDb3VudCA9IG51bUZyYW1lczsKKyAgICAvLyBQcmV2ZW50IHJlY3Vyc2lvbiBhbmQgbXVsdGlwbGUgZXhlY3V0aW9uIG9mIG5vZGVzLgorICAgIGlmIChjYWxsQ291bnQgPiBtTGFzdENhbGxDb3VudCkgeworICAgICAgICBtTGFzdENhbGxDb3VudCA9IGNhbGxDb3VudDsKKyAgICAgICAgaWYgKG1EYXRhUHVsbGVkQXV0b21hdGljYWxseSkgeworICAgICAgICAgICAgLy8gUHVsbCBmcm9tIGFsbCB0aGUgdXBzdHJlYW0gbm9kZXMuCisgICAgICAgICAgICBmb3IgKGF1dG8gJnBvcnQgOiBtSW5wdXRQb3J0cykgeworICAgICAgICAgICAgICAgIC8vIFRPRE8gZml4IGJ1ZyBvZiBsZWF2aW5nIHVudXNlZCBkYXRhIGluIHNvbWUgcG9ydHMgaWYgdXNpbmcgbXVsdGlwbGUgQXVkaW9Tb3VyY2UKKyAgICAgICAgICAgICAgICBmcmFtZUNvdW50ID0gcG9ydC5nZXQoKS5wdWxsRGF0YShjYWxsQ291bnQsIGZyYW1lQ291bnQpOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgICAgIGlmIChmcmFtZUNvdW50ID4gMCkgeworICAgICAgICAgICAgZnJhbWVDb3VudCA9IG9uUHJvY2VzcyhmcmFtZUNvdW50KTsKKyAgICAgICAgfQorICAgICAgICBtTGFzdEZyYW1lQ291bnQgPSBmcmFtZUNvdW50OworICAgIH0gZWxzZSB7CisgICAgICAgIGZyYW1lQ291bnQgPSBtTGFzdEZyYW1lQ291bnQ7CisgICAgfQorICAgIHJldHVybiBmcmFtZUNvdW50OworfQorCit2b2lkIEZsb3dHcmFwaE5vZGU6OnB1bGxSZXNldCgpIHsKKyAgICBpZiAoIW1CbG9ja1JlY3Vyc2lvbikgeworICAgICAgICBtQmxvY2tSZWN1cnNpb24gPSB0cnVlOyAvLyBmb3IgY3ljbGljIGdyYXBocworICAgICAgICAvLyBQdWxsIHJlc2V0IGZyb20gYWxsIHRoZSB1cHN0cmVhbSBub2Rlcy4KKyAgICAgICAgZm9yIChhdXRvICZwb3J0IDogbUlucHV0UG9ydHMpIHsKKyAgICAgICAgICAgIHBvcnQuZ2V0KCkucHVsbFJlc2V0KCk7CisgICAgICAgIH0KKyAgICAgICAgbUJsb2NrUmVjdXJzaW9uID0gZmFsc2U7CisgICAgICAgIHJlc2V0KCk7CisgICAgfQorfQorCit2b2lkIEZsb3dHcmFwaE5vZGU6OnJlc2V0KCkgeworICAgIG1MYXN0RnJhbWVDb3VudCA9IDA7CisgICAgbUxhc3RDYWxsQ291bnQgPSBrSW5pdGlhbENhbGxDb3VudDsKK30KKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KK0Zsb3dHcmFwaFBvcnRGbG9hdDo6Rmxvd0dyYXBoUG9ydEZsb2F0KEZsb3dHcmFwaE5vZGUgJnBhcmVudCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQzMl90IHNhbXBsZXNQZXJGcmFtZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQzMl90IGZyYW1lc1BlckJ1ZmZlcikKKyAgICAgICAgOiBGbG93R3JhcGhQb3J0KHBhcmVudCwgc2FtcGxlc1BlckZyYW1lKQorICAgICAgICAsIG1GcmFtZXNQZXJCdWZmZXIoZnJhbWVzUGVyQnVmZmVyKQorICAgICAgICAsIG1CdWZmZXIobnVsbHB0cikgeworICAgIHNpemVfdCBudW1GbG9hdHMgPSBzdGF0aWNfY2FzdDxzaXplX3Q+KGZyYW1lc1BlckJ1ZmZlcikgKiBnZXRTYW1wbGVzUGVyRnJhbWUoKTsKKyAgICBtQnVmZmVyID0gc3RkOjptYWtlX3VuaXF1ZTxmbG9hdFtdPihudW1GbG9hdHMpOworfQorCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworaW50MzJfdCBGbG93R3JhcGhQb3J0RmxvYXRPdXRwdXQ6OnB1bGxEYXRhKGludDY0X3QgY2FsbENvdW50LCBpbnQzMl90IG51bUZyYW1lcykgeworICAgIG51bUZyYW1lcyA9IHN0ZDo6bWluKGdldEZyYW1lc1BlckJ1ZmZlcigpLCBudW1GcmFtZXMpOworICAgIHJldHVybiBtQ29udGFpbmluZ05vZGUucHVsbERhdGEobnVtRnJhbWVzLCBjYWxsQ291bnQpOworfQorCit2b2lkIEZsb3dHcmFwaFBvcnRGbG9hdE91dHB1dDo6cHVsbFJlc2V0KCkgeworICAgIG1Db250YWluaW5nTm9kZS5wdWxsUmVzZXQoKTsKK30KKworLy8gVGhlc2UgbmVlZCB0byBiZSBpbiB0aGUgLmNwcCBmaWxlIGJlY2F1c2Ugb2YgZm9yd2FyZCBjcm9zcyByZWZlcmVuY2VzLgordm9pZCBGbG93R3JhcGhQb3J0RmxvYXRPdXRwdXQ6OmNvbm5lY3QoRmxvd0dyYXBoUG9ydEZsb2F0SW5wdXQgKnBvcnQpIHsKKyAgICBwb3J0LT5jb25uZWN0KHRoaXMpOworfQorCit2b2lkIEZsb3dHcmFwaFBvcnRGbG9hdE91dHB1dDo6ZGlzY29ubmVjdChGbG93R3J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IGlzIHRoZSBkZWZhdWx0LgorICAgICAqCisgICAgICogU2V0IGZhbHNlIGlmIHlvdSB3YW50IHRvIHB1bGwgdGhlIGRhdGEgZnJvbSB0aGUgaW5wdXQgcG9ydHMgaW4gdGhlIG9uUHJvY2VzcygpIG1ldGhvZC4KKyAgICAgKiBZb3UgbWlnaHQgZG8gdGhpcywgZm9yIGV4YW1wbGUsIGluIGEgc2FtcGxlIHJhdGUgY29udmVydGluZyBub2RlLgorICAgICAqCisgICAgICogQHBhcmFtIGF1dG9tYXRpYworICAgICAqLworICAgIHZvaWQgc2V0RGF0YVB1bGxlZEF1dG9tYXRpY2FsbHkoYm9vbCBhdXRvbWF0aWMpIHsKKyAgICAgICAgbURhdGFQdWxsZWRBdXRvbWF0aWNhbGx5ID0gYXV0b21hdGljOworICAgIH0KKworICAgIHZpcnR1YWwgY29uc3QgY2hhciAqZ2V0TmFtZSgpIHsKKyAgICAgICAgcmV0dXJuICJGbG93R3JhcGgiOworICAgIH0KKworICAgIGludDY0X3QgZ2V0TGFzdENhbGxDb3VudCgpIHsKKyAgICAgICAgcmV0dXJuIG1MYXN0Q2FsbENvdW50OworICAgIH0KKworcHJvdGVjdGVkOgorCisgICAgc3RhdGljIGNvbnN0ZXhwciBpbnQ2NF90ICBrSW5pdGlhbENhbGxDb3VudCA9IC0xOworICAgIGludDY0X3QgIG1MYXN0Q2FsbENvdW50ID0ga0luaXRpYWxDYWxsQ291bnQ7CisKKyAgICBzdGQ6OnZlY3RvcjxzdGQ6OnJlZmVyZW5jZV93cmFwcGVyPEZsb3dHcmFwaFBvcnQ+PiBtSW5wdXRQb3J0czsKKworcHJpdmF0ZToKKyAgICBib29sICAgICBtRGF0YVB1bGxlZEF1dG9tYXRpY2FsbHkgPSB0cnVlOworICAgIGJvb2wgICAgIG1CbG9ja1JlY3Vyc2lvbiA9IGZhbHNlOworICAgIGludDMyX3QgIG1MYXN0RnJhbWVDb3VudCA9IDA7CisKK307CisKKy8qKioqKioqKioqKioqKio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CBudW1GcmFtZXMpID0gMDsKKworICAgIHZpcnR1YWwgdm9pZCBwdWxsUmVzZXQoKSB7fQorCitwcm90ZWN0ZWQ6CisgICAgRmxvd0dyYXBoTm9kZSAmbUNvbnRhaW5pbmdOb2RlOworCitwcml2YXRlOgorICAgIGNvbnN0IGludDMyX3QgICAgbVNhbXBsZXNQZXJGcmFtZSA9IDE7Cit9OworCisvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLworLyoqCisgKiBUaGlzIHBvcnQgY29udGFpbnMgYSAzMi1iaXQgZmxvYXQgYnVmZmVyIHRoYXQgY2FuIGNvbnRhaW4gc2V2ZXJhbCBmcmFtZXMgb2YgZGF0YS4KKyAqIFByb2Nlc3NpbmcgdGhlIGRhdGEgaW4gYSBibG9jayBpbXByb3ZlcyBwZXJmb3JtYW5jZS4KKyAqCisgKiBUaGUgc2l6ZSBpcyBmcmFtZXNQZXJCdWZmZXIgKiBzYW1wbGVzUGVyRnJhbWUpLgorICovCitjbGFzcyBGbG93R3JhcGhQb3J0RmxvYXQgIDogcHVibGljIEZsb3dHcmFwaFBvcnQgeworcHVibGljOgorICAgIEZsb3dHcmFwaFBvcnRGbG9hdChGbG93R3JhcGhOb2RlICZwYXJlbnQsCisgICAgICAgICAgICAgICAgICAgaW50MzJfdCBzYW1wbGVzUGVyRnJhbWUsCisgICAgICAgICAgICAgICAgICAgaW50MzJfdCBmcmFtZXNQZXJCdWZmZXIgPSBrRGVmYXVsdEJ1ZmZlclNpemUKKyAgICAgICAgICAgICAgICApOworCisgICAgdmlydHVhbCB+Rmxvd0dyYXBoUG9ydEZsb2F0KCkgPSBkZWZhdWx0OworCisgICAgaW50MzJfdCBnZXRGcmFtZXNQZXJCdWZmZXIoKSBjb25zdCB7CisgICAgICAgIHJldHVybiBtRnJhbWVzUGVyQnVmZmVyOworICAgIH0KKworcHJvdGVjdGVkOgorCisgICAgLyoqCisgICA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F0T3V0cHV0ICpwb3J0KSB7CisgICAgICAgIGFzc2VydChnZXRTYW1wbGVzUGVyRnJhbWUoKSA9PSBwb3J0LT5nZXRTYW1wbGVzUGVyRnJhbWUoKSk7CisgICAgICAgIG1Db25uZWN0ZWQgPSBwb3J0OworICAgIH0KKworICAgIHZvaWQgZGlzY29ubmVjdChGbG93R3JhcGhQb3J0RmxvYXRPdXRwdXQgKnBvcnQpIHsKKyAgICAgICAgYXNzZXJ0KG1Db25uZWN0ZWQgPT0gcG9ydCk7CisgICAgICAgICh2b2lkKSBwb3J0OworICAgICAgICBtQ29ubmVjdGVkID0gbnVsbHB0cjsKKyAgICB9CisKKyAgICB2b2lkIGRpc2Nvbm5lY3QoKSB7CisgICAgICAgIG1Db25uZWN0ZWQgPSBudWxscHRyOworICAgIH0KKworICAgIC8qKgorICAgICAqIFB1bGwgZGF0YSBmcm9tIGFueSBvdXRwdXQgcG9ydCB0aGF0IGlzIGNvbm5lY3RlZC4KKyAgICAgKi8KKyAgICBpbnQzMl90IHB1bGxEYXRhKGludDY0X3QgZnJhbWVQb3NpdGlvbiwgaW50MzJfdCBudW1GcmFtZXMpIG92ZXJyaWRlOworCisgICAgdm9pZCBwdWxsUmVzZXQoKSBvdmVycmlkZTsKKworcHJpdmF0ZToKKyAgICBGbG93R3JhcGhQb3J0RmxvYXRPdXRwdXQgKm1Db25uZWN0ZWQgPSBudWxscHRyOworfTsKKworLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KKworLyoqCisgKiBCYXNlIGNsYXNzIGZvciBhbiBlZGdlIG5vZGUgaW4gYSBncmFwaCB0aGF0IGhhcyBubyB1cHN0cmVhbSBub2Rlcy4KKyAqIEl0IG91dHB1dHMgZGF0YSBidXQgZG9lcyBub3QgY29uc3VtZSBkYXRhLgorICogQnkgZGVmYXVsdCwgaXQgd2lsbCByZWFkIGl0cyBkYXRhIGZyb20gYW4g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W5rKGludDMyX3QgY2hhbm5lbENvdW50KQorICAgICAgICAgICAgOiBpbnB1dCgqdGhpcywgY2hhbm5lbENvdW50KSB7CisgICAgfQorCisgICAgdmlydHVhbCB+Rmxvd0dyYXBoU2luaygpID0gZGVmYXVsdDsKKworICAgIEZsb3dHcmFwaFBvcnRGbG9hdElucHV0IGlucHV0OworCisgICAgLyoqCisgICAgICogRG8gbm90aGluZy4gVGhlIHdvcmsgaGFwcGVucyBpbiB0aGUgcmVhZCgpIG1ldGhvZC4KKyAgICAgKgorICAgICAqIEBwYXJhbSBudW1GcmFtZXMKKyAgICAgKiBAcmV0dXJuIG51bWJlciBvZiBmcmFtZXMgYWN0dWFsbHkgcHJvY2Vzc2VkCisgICAgICovCisgICAgaW50MzJfdCBvblByb2Nlc3MoaW50MzJfdCBudW1GcmFtZXMpIG92ZXJyaWRlIHsKKyAgICAgICAgcmV0dXJuIG51bUZyYW1lczsKKyAgICB9CisKKyAgICB2aXJ0dWFsIGludDMyX3QgcmVhZCh2b2lkICpkYXRhLCBpbnQzMl90IG51bUZyYW1lcykgPSAwOworCitwcm90ZWN0ZWQ6CisgICAgLyoqCisgICAgICogUHVsbCBkYXRhIHRocm91Z2ggdGhlIGdyYXBoIHVzaW5nIHRoaXMgbm9kZXMgbGFzdCBjYWxsQ291bnQuCisgICAgICogQHBhcmFtIG51bUZyYW1lcworICAgICAqIEByZXR1cm4KKyAgICAgKi8KKyAgICBpbnQzMl90IHB1bGxEYXRhKGludDMyX3QgbnVtRnJhbWVzKTsKK307CisKKy8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCisvKioKKyAqIEJhc2UgY2xhc3MgZm9yIGEgbm9kZSB0aGF0IGhhcyBhbiBpbnB1dCBhbmQgYW4gb3V0cHV0IHdpdGggdGhlIHNhbWUgbnVtYmVyIG9mIGNoYW5uZWxzLgorICogVGhpcyBtYXkgaW5jbHVkZSB0c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AgLyoqCisgICAgICogQHBhcmFtIGF0dGVudWF0aW9uIHR5cGljYWwgdmFsdWVzIHJhbmdlIGZyb20gMzAgdG8gOTAgZEIKKyAgICAgKiBAcmV0dXJuIGJldGEKKyAgICAgKi8KKyAgICBkb3VibGUgc2V0U3RvcEJhbmRBdHRlbnVhdGlvbihkb3VibGUgYXR0ZW51YXRpb24pIHsKKyAgICAgICAgZG91YmxlIGFscGhhID0gKCgtMzI1LjFlLTYgKiBhdHRlbnVhdGlvbiArIDAuMTY3NykgKiBhdHRlbnVhdGlvbikgLSAzLjE0OTsKKyAgICAgICAgc2V0QWxwaGEoYWxwaGEpOworICAgICAgICByZXR1cm4gYWxwaGE7CisgICAgfQorCisgICAgdm9pZCBzZXRBbHBoYShkb3VibGUgYWxwaGEpIHsKKyAgICAgICAgbUFscGhhID0gYWxwaGE7CisgICAgICAgIG1JbnZlcnNlQ29zaEFscGhhID0gMS4wIC8gY29zaChhbHBoYSk7CisgICAgfQorCisgICAgLyoqCisgICAgICogQHBhcmFtIHggcmFuZ2VzIGZyb20gLTEuMCB0byArMS4wCisgICAgICovCisgICAgZG91YmxlIG9wZXJhdG9yKCkoZG91YmxlIHgpIHsKKyAgICAgICAgZG91YmxlIHgyID0geCAqIHg7CisgICAgICAgIGlmICh4MiA+PSAxLjApIHJldHVybiAwLjA7CisgICAgICAgIGRvdWJsZSB3ID0gbUFscGhhICogc3FydCgxLjAgLSB4Mik7CisgICAgICAgIHJldHVybiBjb3NoKHcpICogbUludmVyc2VDb3NoQWxwaGE7CisgICAgfQorCitwcml2YXRlOgorICAgIGRvdWJsZSBtQWxwaGEgPSAwLjA7CisgICAgZG91YmxlIG1JbnZlcnNlQ29zaEFscGhhID0gMS4wOworfTsKKworfSAvKiBuYW1lc3BhY2UgUkVTQU1QTEVSX09VVEVSX05BTUVTUEFDRTo6cmVzYW1wbGVyICovCisKKyNlbmRpZiAvL1JFU0FNUExFUl9IWVBFUkJPTElDX0NPU0lORV9XSU5ET1dfSApk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IGZvciB0aGUgc3BlY2lmaWMgbGFuZ3VhZ2UgZ292ZXJuaW5nIHBlcm1pc3Npb25zIGFuZAorICogbGltaXRhdGlvbnMgdW5kZXIgdGhlIExpY2Vuc2UuCisgKi8KKworI2luY2x1ZGUgIkludGVnZXJSYXRpby5oIgorCit1c2luZyBuYW1lc3BhY2UgUkVTQU1QTEVSX09VVEVSX05BTUVTUEFDRTo6cmVzYW1wbGVyOworCisvLyBFbm91Z2ggcHJpbWVzIHRvIGNvdmVyIHRoZSBjb21tb24gc2FtcGxlIHJhdGVzLgorc3RhdGljIGNvbnN0IGludCBrUHJpbWVzW10gPSB7CisgICAgICAgIDIsIDMsIDUsIDcsIDExLCAxMywgMTcsIDE5LCAyMywgMjksIDMxLCAzNywgNDEsCisgICAgICAgIDQzLCA0NywgNTMsIDU5LCA2MSwgNjcsIDcxLCA3MywgNzksIDgzLCA4OSwgOTcsCisgICAgICAgIDEwMSwgMTAzLCAxMDcsIDEwOSwgMTEzLCAxMjcsIDEzMSwgMTM3LCAxMzksIDE0OSwKKyAgICAgICAgMTUxLCAxNTcsIDE2MywgMTY3LCAxNzMsIDE3OSwgMTgxLCAxOTEsIDE5MywgMTk3LCAxOTl9OworCit2b2lkIEludGVnZXJSYXRpbzo6cmVkdWNlKCkgeworICAgIGZvciAoaW50IHByaW1lIDoga1ByaW1lcykgeworICAgICAgICBpZiAobU51bWVyYXRvciA8IHByaW1lIHx8IG1EZW5vbWluYXRvciA8IHByaW1lKSB7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorCisgICAgICAgIC8vIEZpbmQgYmlnZ2VzdCBwcmltZSBmYWN0b3IgZm9yIG51bWVyYXRvci4KKyAgICAgICAgd2hpbGUgKHRydWUpIHsKKyAgICAgICAgICAgIGludCB0b3AgPSBtTnVtZXJhdG9yIC8gcHJpbWU7CisgICAgICAgICAgICBpbnQgYm90dG9tID0gbURlbm9taW5hdG9yIC8gcHJpbWU7CisgICAgICAgICAgICBpZiAoKHRvc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gICAgICogQHJldHVybiBiZXRhCisgICAgICovCisgICAgZG91YmxlIHNldFN0b3BCYW5kQXR0ZW51YXRpb24oZG91YmxlIGF0dGVudWF0aW9uKSB7CisgICAgICAgIGRvdWJsZSBiZXRhID0gMC4wOworICAgICAgICBpZiAoYXR0ZW51YXRpb24gPiA1MCkgeworICAgICAgICAgICAgYmV0YSA9IDAuMTEwMiAqIChhdHRlbnVhdGlvbiAtIDguNyk7CisgICAgICAgIH0gZWxzZSBpZiAoYXR0ZW51YXRpb24gPj0gMjEpIHsKKyAgICAgICAgICAgIGRvdWJsZSBhMjEgPSBhdHRlbnVhdGlvbiAtIDIxOworICAgICAgICAgICAgYmV0YSA9IDAuNTg0MiAqIHBvdyhhMjEsIDAuNCkgKyAoMC4wNzg4NiAqIGEyMSk7CisgICAgICAgIH0KKyAgICAgICAgc2V0QmV0YShiZXRhKTsKKyAgICAgICAgcmV0dXJuIGJldGE7CisgICAgfQorCisgICAgdm9pZCBzZXRCZXRhKGRvdWJsZSBiZXRhKSB7CisgICAgICAgIG1CZXRhID0gYmV0YTsKKyAgICAgICAgbUludmVyc2VCZXNzZWxCZXRhID0gMS4wIC8gYmVzc2VsKGJldGEpOworICAgIH0KKworICAgIC8qKgorICAgICAqIEBwYXJhbSB4IHJhbmdlcyBmcm9tIC0xLjAgdG8gKzEuMAorICAgICAqLworICAgIGRvdWJsZSBvcGVyYXRvcigpKGRvdWJsZSB4KSB7CisgICAgICAgIGRvdWJsZSB4MiA9IHggKiB4OworICAgICAgICBpZiAoeDIgPj0gMS4wKSByZXR1cm4gMC4wOworICAgICAgICBkb3VibGUgdyA9IG1CZXRhICogc3FydCgxLjAgLSB4Mik7CisgICAgICAgIHJldHVybiBiZXNzZWwodykgKiBtSW52ZXJzZUJlc3NlbEJldGE7CisgICAgfQorCisgICAgLy8gQXBwcm94aW1hdGlvbiBvZiBhCisgICAgLy8gbW9kaWZpZWQgemVybyBvcmRlciBCZXNzZWwgZnVuY3Rpb24gb2YgdGhl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goc3RhdGljX2Nhc3Q8c2l6ZV90PihidWlsZGVyLmdldENoYW5uZWxDb3VudCgpKQorICAgICAgICAgICAgICAgICogc3RhdGljX2Nhc3Q8c2l6ZV90PihidWlsZGVyLmdldE51bVRhcHMoKSkgKiAyKQorICAgICAgICAsIG1TaW5nbGVGcmFtZShidWlsZGVyLmdldENoYW5uZWxDb3VudCgpKQorICAgICAgICAsIG1DaGFubmVsQ291bnQoYnVpbGRlci5nZXRDaGFubmVsQ291bnQoKSkKKyAgICAgICAgeworICAgIC8vIFJlZHVjZSBzYW1wbGUgcmF0ZXMgdG8gdGhlIHNtYWxsZXN0IHJhdGlvLgorICAgIC8vIEZvciBleGFtcGxlIDQ0MTAwLzQ4MDAwIHdvdWxkIGJlY29tZSAxNDcvMTYwLgorICAgIEludGVnZXJSYXRpbyByYXRpbyhidWlsZGVyLmdldElucHV0UmF0ZSgpLCBidWlsZGVyLmdldE91dHB1dFJhdGUoKSk7CisgICAgcmF0aW8ucmVkdWNlKCk7CisgICAgbU51bWVyYXRvciA9IHJhdGlvLmdldE51bWVyYXRvcigpOworICAgIG1EZW5vbWluYXRvciA9IHJhdGlvLmdldERlbm9taW5hdG9yKCk7CisgICAgbUludGVnZXJQaGFzZSA9IG1EZW5vbWluYXRvcjsKK30KKworLy8gc3RhdGljIGZhY3RvcnkgbWV0aG9kCitNdWx0aUNoYW5uZWxSZXNhbXBsZXIgKk11bHRpQ2hhbm5lbFJlc2FtcGxlcjo6bWFrZShpbnQzMl90IGNoYW5uZWxDb3VudCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3QgaW5wdXRSYXRlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBvdXRwdXRSYXRlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUXVhbGl0eSBxdWFsaXR5KSB7CisgICAgQnVpbGRlciBidWlsZGVyOworICAgIGJ1aWxkZXIuc2V0SW5wdXRSYXRlKGlucHV0UmF0ZSk7CisgICAgYnVpbGRlci5zZXRPdXRwdXRSYXRlKG91dHB1dFJhdGUpOworICAgIGJ1aWxkZXIuc2V0Q2hhbm5lbENvdW50KGNoYW5uZWxDb3VudCk7CisKKyAgICBzd2l0Y2ggKHF1YWxpdHkpIHsKKyAgICAgICAgY2FzZSBRdWFsaXR5OjpGYXN0ZXN0OgorICAgICAgICAgICAgYnVpbGRlci5zZXROdW1UYXBzKDIpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgUXVhbGl0eTo6TG93OgorICAgICAgICAgICAgYnVpbGRlci5zZXROdW1UYXBzKDQpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgUXVhbGl0eTo6TWVkaXVtOgorICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgYnVpbGRlci5zZXROdW1UYXBzKDgpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgUXVhbGl0eTo6SGlnaDoKKyAgICAgICAgICAgIGJ1aWxkZXIuc2V0TnVtVGFwcygxNik7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBRdWFsaXR5OjpCZXN0OgorICAgICAgICAgICAgYnVpbGRlci5zZXROdW1UYXBzKDMyKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgIH0KKworICAgIC8vIFNldCB0aGUgY3V0b2ZmIGZyZXF1ZW5jeSBzbyB0aGF0IHdlIGRvIG5vdCBnZXQgYWxpYXNpbmcgd2hlbiBkb3duLXNhbXBsaW5nLgorICAgIGlmIChpbnB1dFJhdGUgPiBvdXRwdXRSYXRlKSB7CisgICAgICAgIGJ1aWxkZXIuc2V0Tm9ybWFsaXplZEN1dG9mZihrRGVmYXVsdE5vcm1hbGl6ZWRDdXRvZmYpOworICAgIH0KKyAgICByZXR1cm4gYnVpbGRlci5idWlsZCgpOworfQorCitNdWx0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ICAgICAgICogTW9yZSB0YXBzIGdpdmVzIGJldHRlciBxdWFsaXR5IGJ1dCB1c2VzIG1vcmUgQ1BVIHRpbWUuCisgICAgICAgICAqIFRoaXMgdHlwaWNhbGx5IHJhbmdlcyBmcm9tIDQgdG8gNjQuIERlZmF1bHQgaXMgMTYuCisgICAgICAgICAqCisgICAgICAgICAqIEZvciBwb2x5cGhhc2UgZmlsdGVycywgbnVtVGFwcyBtdXN0IGJlIGEgbXVsdGlwbGUgb2YgZm91ciBmb3IgbG9vcCB1bnJvbGxpbmcuCisgICAgICAgICAqIEBwYXJhbSBudW1UYXBzIG51bWJlciBvZiB0YXBzIGZvciB0aGUgZmlsdGVyCisgICAgICAgICAqIEByZXR1cm4gYWRkcmVzcyBvZiB0aGlzIGJ1aWxkZXIgZm9yIGNoYWluaW5nIGNhbGxzCisgICAgICAgICAqLworICAgICAgICBCdWlsZGVyICpzZXROdW1UYXBzKGludDMyX3QgbnVtVGFwcykgeworICAgICAgICAgICAgbU51bVRhcHMgPSBudW1UYXBzOworICAgICAgICAgICAgcmV0dXJuIHRoaXM7CisgICAgICAgIH0KKworICAgICAgICAvKioKKyAgICAgICAgICogVXNlIDEgZm9yIG1vbm8sIDIgZm9yIHN0ZXJlbywgZXRjLiBEZWZhdWx0IGlzIDEuCisgICAgICAgICAqCisgICAgICAgICAqIEBwYXJhbSBjaGFubmVsQ291bnQgbnVtYmVyIG9mIGNoYW5uZWxzCisgICAgICAgICAqIEByZXR1cm4gYWRkcmVzcyBvZiB0aGlzIGJ1aWxkZXIgZm9yIGNoYWluaW5nIGNhbGxzCisgICAgICAgICAqLworICAgICAgICBCdWlsZGVyICpzZXRDaGFubmVsQ291bnQoaW50MzJfdCBjaGFubmVsQ291bnQpIHsKKyAgICAgICAgICAgIG1DaGFubmVsQ291bnQgPSBjaGFubmVsQ291bnQ7CisgICAgICAgICAgICByZXR1cm4gdGhpczsKKyAgICAgICAgfQorCisgICAgICAgIC8qKgorICAgICAgICAgKiBEZWZhdWx0IGlzIDQ4MDAwLgorICAgICAgICAgKgorICAgICAgICAgKiBAcGFyYW0gaW5wdXRSYXRlIHNhbXBsZSByYXRlIG9mIHRoZSBpbnB1dCBzdHJlYW0KKyAgICAgICAgICogQHJldHVybiBhZGRyZXNzIG9mIHRoaXMgYnVpbGRlciBmb3IgY2hhaW5pbmcgY2FsbHMKKyAgICAgICAgICovCisgICAgICAgIEJ1aWxkZXIgKnNldElucHV0UmF0ZShpbnQzMl90IGlucHV0UmF0ZSkgeworICAgICAgICAgICAgbUlucHV0UmF0ZSA9IGlucHV0UmF0ZTsKKyAgICAgICAgICAgIHJldHVybiB0aGlzOworICAgICAgICB9CisKKyAgICAgICAgLyoqCisgICAgICAgICAqIERlZmF1bHQgaXMgNDgwMDAuCisgICAgICAgICAqCisgICAgICAgICAqIEBwYXJhbSBvdXRwdXRSYXRlIHNhbXBsZSByYXRlIG9mIHRoZSBvdXRwdXQgc3RyZWFtCisgICAgICAgICAqIEByZXR1cm4gYWRkcmVzcyBvZiB0aGlzIGJ1aWxkZXIgZm9yIGNoYWluaW5nIGNhbGxzCisgICAgICAgICAqLworICAgICAgICBCdWlsZGVyICpzZXRPdXRwdXRSYXRlKGludDMyX3Qgb3V0cHV0UmF0ZSkgeworICAgICAgICAgICAgbU91dHB1dFJhdGUgPSBvdXRwdXRSYXRlOworICAgICAgICAgICAgcmV0dXJuIHRoaXM7CisgICAgICAgIH0KKworICAgICAgICAvKioKKyAgICAgICAgICogU2V0IGN1dG9mZiBmcmVxdWVuY3kgcmVsYXRpdmUgdG8gdGhlIE55cXVpc3QgcmF0ZSBvZiB0aGUgb3V0cHV0IHNhbXBsZSByYXRlLgorICAgICAgICAgKiBTZXQgdG8gMS4wIHRvIG1hdGNoIHRoZSBOeXF1aXN0IGZyZXF1ZW5jeS4KKyAgICAgICAgICogU2V0IGxvd2VyIHRvIHJlZHVjZSBhbGlhc2luZy4KKyAgICAgICAgICogRGVmYXVsdCBpcyAwLjcwLgorICAgICAgICAgKgorICAgICAgICAgKiBAcGFyYW0gbm9ybWFsaXplZEN1dG9mZiBhbnRpLWFsaWFzaW5nIGZpbHRlciBjdXRvZmYKKyAgICAgICAgICogQHJldHVybiBhZGRyZXNzIG9mIHRoaXMgYnVpbGRlciBmb3IgY2hhaW5pbmcgY2FsbHMKKyAgICAgICAgICovCisgICAgICAgIEJ1aWxkZXIgKnNldE5vcm1hbGl6ZWRDdXRvZmYoZmxvYXQgbm9ybWFsaXplZEN1dG9mZikgeworICAgICAgICAgICAgbU5vcm1hbGl6ZWRDdXRvZmYgPSBub3JtYWxpemVkQ3V0b2ZmOworICAgICAgICAgICAgcmV0dXJuIHRoaXM7CisgICAgICAgIH0KKworICAgICAgICBpbnQzMl90IGdldE51bVRhcHMoKSBjb25zdCB7CisgICAgICAgICAgICByZXR1cm4gbU51bVRhcHM7CisgICAgICAgIH0KKworICAgICAgICBpbnQzMl90IGdldENoYW5uZWxDb3VudCgpIGNvbnN0IHsKKyAgICAgICAgICAgIHJldHVybiBtQ2hhbm5lbENvdW50OworICAgICAgICB9CisKKyAgICAgICAgaW50MzJfdCBnZXRJbnB1dFJhdGUoKSBjb25zdCB7CisgICAgICAgICAgICByZXR1cm4gbUlucHV0UmF0ZTsKKyAgICAgICAgfQorCisgICAgICAgIGludDMyX3QgZ2V0T3V0cHV0UmF0ZSgpIGNvbnN0IHsKKyAgICAgICAgICAgIHJldHVybiBtT3V0cHV0UmF0ZTsKKyAgICAgICAgfQorCisgICAgICAgIGZsb2F0IGdldE5vcm1hbGl6ZWRDdXRvZmYoKSBjb25zdCB7CisgICAgICAgICAgICByZXR1cm4gbU5vcm1hbGl6ZWRDdXRvZmY7CisgICAgICAgIH0KKworICAgIHByb3RlY3RlZDoKKyAgICAgICAgaW50MzJfdCBtQ2hhbm5lbENvdW50ID0gMTsKKyAgICAgICAgaW50MzJfdCBtTnVtVGFwcyA9IDE2OworICAgICAgICBpbnQzMl90IG1JbnB1dFJhdGUgPSA0ODAwMDsKKyAgICAg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ICAgIHJldHVybiBtSW50ZWdlclBoYXNlID49IG1EZW5vbWluYXRvcjsKKyAgICB9CisKKyAgICAvKioKKyAgICAgKiBXcml0ZSBhIGZyYW1lIGNvbnRhaW5pbmcgTiBzYW1wbGVzLgorICAgICAqCisgICAgICogQHBhcmFtIGZyYW1lIHBvaW50ZXIgdG8gdGhlIGZpcnN0IHNhbXBsZSBpbiBhIGZyYW1lCisgICAgICovCisgICAgdm9pZCB3cml0ZU5leHRGcmFtZShjb25zdCBmbG9hdCAqZnJhbWUpIHsKKyAgICAgICAgd3JpdGVGcmFtZShmcmFtZSk7CisgICAgICAgIGFkdmFuY2VXcml0ZSgpOworICAgIH0KKworICAgIC8qKgorICAgICAqIFJlYWQgYSBmcmFtZSBjb250YWluaW5nIE4gc2FtcGxlcy4KKyAgICAgKgorICAgICAqIEBwYXJhbSBmcmFtZSBwb2ludGVyIHRvIHRoZSBmaXJzdCBzYW1wbGUgaW4gYSBmcmFtZQorICAgICAqLworICAgIHZvaWQgcmVhZE5leHRGcmFtZShmbG9hdCAqZnJhbWUpIHsKKyAgICAgICAgcmVhZEZyYW1lKGZyYW1lKTsKKyAgICAgICAgYWR2YW5jZVJlYWQoKTsKKyAgICB9CisKKyAgICBpbnQgZ2V0TnVtVGFwcygpIGNvbnN0IHsKKyAgICAgICAgcmV0dXJuIG1OdW1UYXBzOworICAgIH0KKworICAgIGludCBnZXRDaGFubmVsQ291bnQoKSBjb25zdCB7CisgICAgICAgIHJldHVybiBtQ2hhbm5lbENvdW50OworICAgIH0KKworICAgIHN0YXRpYyBmbG9hdCBoYW1taW5nV2luZG93KGZsb2F0IHJhZGlhbnMsIGZsb2F0IHNwcmVhZCk7CisKKyAgICBzdGF0aWMgZmxvYXQgc2luYyhmbG9hdCByYWRpYW5zKTsKKworcHJvdGVjdGVkOgorCisgICAgZXhwbGljaXQgTXVsdGlDaGFubmVsUmVzYW1wbGVyKGNvbnN0IE11bHRpQ2hhbm5lbFJlc2FtcGxlcjo6QnVpb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Jvd3MgbnVtYmVyIG9mIHJvd3MgaW4gdGhlIGFycmF5IHRoYXQgY29udGFpbiBhIHNldCBvZiB0YXAgY29lZmZpY2llbnRzCisgICAgICogQHBhcmFtIHBoYXNlSW5jcmVtZW50IGhvdyBtdWNoIHRvIGluY3JlbWVudCB0aGUgcGhhc2UgYmV0d2VlbiByb3dzCisgICAgICogQHBhcmFtIG5vcm1hbGl6ZWRDdXRvZmYgZmlsdGVyIGN1dG9mZiBmcmVxdWVuY3kgbm9ybWFsaXplZCB0byBOeXF1aXN0IHJhdGUgb2Ygb3V0cHV0CisgICAgICovCisgICAgdm9pZCBnZW5lcmF0ZUNvZWZmaWNpZW50cyhpbnQzMl90IGlucHV0UmF0ZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3Qgb3V0cHV0UmF0ZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3QgbnVtUm93cywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvdWJsZSBwaGFzZUluY3JlbWVudCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZsb2F0IG5vcm1hbGl6ZWRDdXRvZmYpOworCisKKyAgICBpbnQzMl90IGdldEludGVnZXJQaGFzZSgpIHsKKyAgICAgICAgcmV0dXJuIG1JbnRlZ2VyUGhhc2U7CisgICAgfQorCisgICAgc3RhdGljIGNvbnN0ZXhwciBpbnQga01heENvZWZmaWNpZW50cyA9IDggKiAxMDI0OworICAgIHN0ZDo6dmVjdG9yPGZsb2F0PiAgIG1Db2VmZmljaWVudHM7CisKKyAgICBjb25zdCBpbnQgICAgICAgICAgICBtTnVtVGFwczsKKyAgICBpbnQgICAgICAgICAgICAgICAgICBtQ3Vyc29yID0gMDsKKyAgICBzdGQ6OnZlY3RvcjxmbG9hdD4gICBtWDsgICAgICAgICAgIC8vIGRlbGF5ZWQgaW5wdXQgdmFsdWVzIGZvciB0aGUgRklSCisgICAgc3RkOjp2ZWN0b3I8Z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ZmaWNpZW50czEgPSAmbUNvZWZmaWNpZW50c1tzdGF0aWNfY2FzdDxzaXplX3Q+KGluZGV4MSkKKyAgICAgICAgICAgICogc3RhdGljX2Nhc3Q8c2l6ZV90PihnZXROdW1UYXBzKCkpXTsKKyAgICBmbG9hdCAqY29lZmZpY2llbnRzMiA9ICZtQ29lZmZpY2llbnRzW3N0YXRpY19jYXN0PHNpemVfdD4oaW5kZXgyKQorICAgICAgICAgICAgKiBzdGF0aWNfY2FzdDxzaXplX3Q+KGdldE51bVRhcHMoKSldOworCisgICAgZmxvYXQgKnhGcmFtZSA9ICZtWFtzdGF0aWNfY2FzdDxzaXplX3Q+KG1DdXJzb3IpICogc3RhdGljX2Nhc3Q8c2l6ZV90PihnZXRDaGFubmVsQ291bnQoKSldOworICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbU51bVRhcHM7IGkrKykgeworICAgICAgICBmbG9hdCBjb2VmZmljaWVudDEgPSAqY29lZmZpY2llbnRzMSsrOworICAgICAgICBmbG9hdCBjb2VmZmljaWVudDIgPSAqY29lZmZpY2llbnRzMisrOworICAgICAgICBmb3IgKGludCBjaGFubmVsID0gMDsgY2hhbm5lbCA8IGdldENoYW5uZWxDb3VudCgpOyBjaGFubmVsKyspIHsKKyAgICAgICAgICAgIGZsb2F0IHNhbXBsZSA9ICp4RnJhbWUrKzsKKyAgICAgICAgICAgIG1TaW5nbGVGcmFtZVtjaGFubmVsXSArPSAgc2FtcGxlICogY29lZmZpY2llbnQxOworICAgICAgICAgICAgbVNpbmdsZUZyYW1lMltjaGFubmVsXSArPSBzYW1wbGUgKiBjb2VmZmljaWVudDI7CisgICAgICAgIH0KKyAgICB9CisKKyAgICAvLyBJbnRlcnBvbGF0ZSBhbmQgY29weSB0byBvdXRwdXQuCisgICAgZmxvYXQgZnJhY3Rpb24gPSB0YWJsZVBoYXNlIC0gaW5kZXgxOworICAgIGZvciAoaW50IGNoYW5uZWwgPSAwOyBjaGFubmVsIDwgZ2V0Q2hhbm5l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iLgotICAgICAgICAgICAgICAgIGF1ZGlvQnVmZmVyLT5zaXplID0gMDsKLSAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgaWYgKGF1ZGlvQnVmZmVyLT5mcmFtZUNvdW50ID09IDApIHsKLSAgICAgICAgICAgICAgICAgICAgQUxPR1coInByb2Nlc3NDYWxsYmFja0NvbW1vbigpIGRhdGEsIGZyYW1lQ291bnQgaXMgemVybyIpOwotICAgICAgICAgICAgICAgICAgICByZXR1cm47Ci0gICAgICAgICAgICAgICAgfQotCi0gICAgICAgICAgICAgICAgLy8gSWYgdGhlIGNhbGxlciBzcGVjaWZpZWQgYW4gZXhhY3Qgc2l6ZSB0aGVuIHVzZSBhIGJsb2NrIHNpemUgYWRhcHRlci4KLSAgICAgICAgICAgICAgICBpZiAobUJsb2NrQWRhcHRlciAhPSBudWxscHRyKSB7Ci0gICAgICAgICAgICAgICAgICAgIGludDMyX3QgYnl0ZUNvdW50ID0gYXVkaW9CdWZmZXItPmZyYW1lQ291bnQgKiBnZXRCeXRlc1BlckRldmljZUZyYW1lKCk7Ci0gICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrUmVzdWx0ID0gbUJsb2NrQWRhcHRlci0+cHJvY2Vzc1ZhcmlhYmxlQmxvY2soCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgKHVpbnQ4X3QgKikgYXVkaW9CdWZmZXItPnJhdywgYnl0ZUNvdW50KTsKLSAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICAvLyBDYWxsIHVzaW5nIHRoZSBBQXVkaW8gY2FsbGJhY2sgaW50ZXJmYWNlLgotICAgICAgICAgICAgICAgICAgICBjYWxsYmFja1Jlc3VsdCA9IGNhbGxEYXRhQ2FsbGJhY2tGcmFtZXMoKHVpbnQ4X3QgKilhdWRpb0J1ZmZlci0+cmF3LAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9CdWZmZXItPmZyYW1lQ291bnQpOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBpZiAoY2FsbGJhY2tSZXN1bHQgPT0gQUFVRElPX0NBTExCQUNLX1JFU1VMVF9DT05USU5VRSkgewotICAgICAgICAgICAgICAgICAgICBhdWRpb0J1ZmZlci0+c2l6ZSA9IGF1ZGlvQnVmZmVyLT5mcmFtZUNvdW50ICogZ2V0Qnl0ZXNQZXJEZXZpY2VGcmFtZSgpOwotICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChjYWxsYmFja1Jlc3VsdCA9PSBBQVVESU9fQ0FMTEJBQ0tfUkVTVUxUX1NUT1ApIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIEFMT0dEKCIlcygpIGNhbGxiYWNrIHJldHVybmVkIEFBVURJT19DQUxMQkFDS19SRVNVTFRfU1RPUCIsIF9fZnVuY19fKTsKLSAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIEFMT0dXKCIlcygpIGNhbGxiYWNrIHJldHVybmVkIGludmFsaWQgcmVzdWx0ID0gJWQiLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX19mdW5jX18sIGNhbGxiYWNrUmVzdWx0KTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBhdWRpb0J1ZmZlci0+c2l6ZSA9IDA7Ci0gICAgICAgICAgICAgICAgICAgIHN5c3RlbVN0b3BJbnRlcm5hbCgpOwotICAgICAgICAgICAgICAgICAgICAvLyBEaXNhYmxlIHRoZSBjYWxsYmFjayBqdXN0IGluIGNhc2UgdGhlIHN5c3RlbSBrZWVwcyB0cnlpbmcgdG8gY2FsbCB1cy4KLSAgICAgICAgICAgICAgICAgICAgbUNhbGxiYWNrRW5hYmxlZC5zdG9yZShmYWxzZSk7Ci0gICAgICAgICAgICAgICAgfQotCi0gICAg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N1bHQgPSBtQmxvY2tBZGFwdGVyLT5wcm9jZXNzVmFyaWFibGVCbG9jaygKKyAgICAgICAgICAgICAgICAgICAgYnVmZmVyLmRhdGEoKSwgYnl0ZUNvdW50KTsKKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIC8vIENhbGwgdXNpbmcgdGhlIEFBdWRpbyBjYWxsYmFjayBpbnRlcmZhY2UuCisgICAgICAgICAgICBjYWxsYmFja1Jlc3VsdCA9IGNhbGxEYXRhQ2FsbGJhY2tGcmFtZXMoYnVmZmVyLmRhdGEoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBidWZmZXIuZ2V0RnJhbWVDb3VudCgpKTsKKyAgICAgICAgfQorICAgICAgICBpZiAoY2FsbGJhY2tSZXN1bHQgPT0gQUFVRElPX0NBTExCQUNLX1JFU1VMVF9DT05USU5VRSkgeworICAgICAgICAgICAgd3JpdHRlbiA9IGJ1ZmZlci5nZXRGcmFtZUNvdW50KCkgKiBnZXRCeXRlc1BlckRldmljZUZyYW1lKCk7CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICBpZiAoY2FsbGJhY2tSZXN1bHQgPT0gQUFVRElPX0NBTExCQUNLX1JFU1VMVF9TVE9QKSB7CisgICAgICAgICAgICAgICAgQUxPR0QoIiVzKCkgY2FsbGJhY2sgcmV0dXJuZWQgQUFVRElPX0NBTExCQUNLX1JFU1VMVF9TVE9QIiwgX19mdW5jX18pOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICBBTE9HVygiJXMoKSBjYWxsYmFjayByZXR1cm5lZCBpbnZhbGlkIHJlc3VsdCA9ICVkIiwKKyAgICAgICAgICAgICAgICAgICAgICBfX2Z1bmNfXywgY2FsbGJhY2tSZXN1bHQpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgd3JpdHRlbiA9IDA7CisgICAgICAgICAgICBzeXN0ZW1TdG9wSW50ZXJuYWwoKT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cy5jcHAKQEAgLTU0NCw0NSArNTQ0LDYgQEAKICAgICByZXR1cm4gQUFVRElPX09LOwogfQogCi1zdGF0aWMgaW50MzJfdCBBQXVkaW9Qcm9wZXJ0eV9nZXRNTWFwUHJvcGVydHkoY29uc3QgY2hhciAqcHJvcE5hbWUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBkZWZhdWx0VmFsdWUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hhciAqIGNhbGxlcikgewotICAgIGludDMyX3QgcHJvcCA9IHByb3BlcnR5X2dldF9pbnQzMihwcm9wTmFtZSwgZGVmYXVsdFZhbHVlKTsKLSAgICBzd2l0Y2ggKHByb3ApIHsKLSAgICAgICAgY2FzZSBBQVVESU9fVU5TUEVDSUZJRUQ6Ci0gICAgICAgIGNhc2UgQUFVRElPX1BPTElDWV9ORVZFUjoKLSAgICAgICAgY2FzZSBBQVVESU9fUE9MSUNZX0FMV0FZUzoKLSAgICAgICAgY2FzZSBBQVVESU9fUE9MSUNZX0FVVE86Ci0gICAgICAgICAgICBicmVhazsKLSAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgIEFMT0dFKCIlczogaW52YWxpZCA9ICVkIiwgY2FsbGVyLCBwcm9wKTsKLSAgICAgICAgICAgIHByb3AgPSBkZWZhdWx0VmFsdWU7Ci0gICAgICAgICAgICBicmVhazsKLSAgICB9Ci0gICAgcmV0dXJuIHByb3A7Ci19Ci0KLWludDMyX3QgQUF1ZGlvUHJvcGVydHlfZ2V0TU1hcFBvbGljeSgpIHsKLSAgICByZXR1cm4gQUF1ZGlvUHJvcGVydHlfZ2V0TU1hcFByb3BlcnR5KEFBVURJT19QUk9QX01NQVBfUE9MSUNZLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQUFVRElPX1VOU1BFQ0lGSUVELCBfX2Z1bmNfXyk7Ci19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XSwKICAgICBzcmNzOiBbInRlc3Rfb3Blbl9wYXJhbXMuY3BwIl0sCi0gICAgc2hhcmVkX2xpYnM6IFsKLSAgICAgICAgImxpYmFhdWRpbyIsCi0gICAgICAgICJsaWJiaW5kZXIiLAotICAgICAgICAibGliY3V0aWxzIiwKLSAgICAgICAgImxpYnV0aWxzIiwKLSAgICBdLAorICAgIHNoYXJlZF9saWJzOiBbImxpYmFhdWRpbyJdLAogfQogCi1jY190ZXN0IHsKK2NjX2JpbmFyeSB7CiAgICAgbmFtZTogInRlc3Rfbm9fY2xvc2UiLAogICAgIGRlZmF1bHRzOiBbImxpYmFhdWRpb190ZXN0c19kZWZhdWx0cyJdLAogICAgIHNyY3M6IFsidGVzdF9ub19jbG9zZS5jcHAiXSwKLSAgICBzaGFyZWRfbGliczogWwotICAgICAgICAibGliYWF1ZGlvIiwKLSAgICAgICAgImxpYmJpbmRlciIsCi0gICAgICAgICJsaWJjdXRpbHMiLAotICAgICAgICAibGlidXRpbHMiLAotICAgIF0sCisgICAgc2hhcmVkX2xpYnM6IFsibGliYWF1ZGlvIl0sCiB9CiAKLWNjX3Rlc3QgeworY2NfYmluYXJ5IHsKICAgICBuYW1lOiAidGVzdF9hYXVkaW9fcmVjb3ZlcnkiLAogICAgIGRlZmF1bHRzOiBbImxpYmFhdWRpb190ZXN0c19kZWZhdWx0cyJdLAogICAgIHNyY3M6IFsidGVzdF9yZWNvdmVyeS5jcHAiXSwKLSAgICBzaGFyZWRfbGliczogWwotICAgICAgICAibGliYWF1ZGlvIiwKLSAgICAgICAgImxpYmJpbmRlciIsCi0gICAgICAgICJsaWJjdXRpbHMiLAotICAgICAgICAibGlidXRpbHMiLAotICAgIF0sCisgICAgc2hhcmVkX2xpYnM6IFsibGliYWF1ZGlvIl0sCiB9CiAKLWNjX3Rlc3QgeworY2NfYmluYXJ5IHsKICAgICBuYW1lOiAidGVzdF9uX3N0cmVhbXMiLAogICAgIGRlZmF1bHRzOiBbImxpYmFhdWRpb190ZX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NIHZhbHVlcyAgYXMgaW50ZWdlcnMuCitjb25zdGV4cHIgc3RkOjphcnJheTxpbnQxNl90LCBrTnVtU2FtcGxlcz4gIGtFeHBlY3RlZEkxNiA9IHsKKyAgICBJTlQxNl9NQVgsIDEgPDwgMTQsIElOVDE2X01JTiAvIDQsIElOVDE2X01JTiwKKyAgICAwLCBJTlQxNl9NQVgsIElOVDE2X01JTiwgSU5UMTZfTUlOfTsKKworY29uc3RleHByIHN0ZDo6YXJyYXk8aW50MzJfdCwga051bVNhbXBsZXM+ICBrRXhwZWN0ZWRJMzIgPSB7CisgICAgSU5UMzJfTUFYLCAxIDw8IDMwLCBJTlQzMl9NSU4gLyA0LCBJTlQzMl9NSU4sCisgICAgMCwgSU5UMzJfTUFYLCBJTlQzMl9NSU4sIElOVDMyX01JTn07CisKKy8vID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09IEZMT0FUIHRvIEkxNiA9PT09PT09PT09PT09PQorCisvLyBTaW1wbGUgdGVzdCB0aGF0IHRyaWVzIHRvIHJlcHJvZHVjZSBhIENsYW5nIGNvbXBpbGVyIGJ1Zy4KK19fYXR0cmlidXRlX18oKG5vaW5saW5lKSkKK3ZvaWQgbG9jYWxfY29udmVydF9mbG9hdF90b19pbnQxNihjb25zdCBmbG9hdCAqaW5wdXQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MTZfdCAqb3V0cHV0LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCBjb3VudCkgeworICAgIGZvciAoaW50IGkgPSAwOyBpIDwgY291bnQ7IGkrKykgeworICAgICAgICBpbnQzMl90IG4gPSAoaW50MzJfdCkgKCppbnB1dCsrICogMzI3NjguMGYpOworICAgICAgICAqb3V0cHV0KysgPSBzdGQ6Om1pbihJTlQxNl9NQVgsIHN0ZDo6bWF4KElOVDE2X01JTiwgbikpOyAvLyBjbGlwCisgICAgfQorfQorCitURVNUKHRlc3RfZmxvd2dyYXBoLCBsb2N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bnVtUmVhZCk7CisgICAgb3V0cHV0LmZpbGwoNzc3KTsKKyAgICBpbnQzMl90IG51bVJlYWQgPSBzaW5rSTE2LnJlYWQob3V0cHV0LmRhdGEoKSwgb3V0cHV0LnNpemUoKSk7CisgICAgQVNTRVJUX0VRKGtOdW1TYW1wbGVzLCBudW1SZWFkKTsKICAgICBmb3IgKGludCBpID0gMDsgaSA8IG51bVJlYWQ7IGkrKykgewotICAgICAgICBFWFBFQ1RfRVEoZXhwZWN0ZWRbaV0sIG91dHB1dFtpXSk7CisgICAgICAgIEVYUEVDVF9FUShrRXhwZWN0ZWRJMTYuYXQoaSksIG91dHB1dC5hdChpKSkgPDwgIiwgaSA9ICIgPDwgaTsKKyAgICB9Cit9CisKKy8vID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09IEZMT0FUIHRvIEkzMiA9PT09PT09PT09PT09PQorLy8gU2ltcGxlIHRlc3QgdGhhdCB0cmllcyB0byByZXByb2R1Y2UgYSBDbGFuZyBjb21waWxlciBidWcuCitfX2F0dHJpYnV0ZV9fKChub2lubGluZSkpCitzdGF0aWMgaW50MzJfdCBjbGFtcDMyRnJvbUZsb2F0KGZsb2F0IGYpCit7CisgICAgc3RhdGljIGNvbnN0IGZsb2F0IHNjYWxlID0gKGZsb2F0KSgxVUwgPDwgMzEpOworICAgIHN0YXRpYyBjb25zdCBmbG9hdCBsaW1wb3MgPSAxLjsKKyAgICBzdGF0aWMgY29uc3QgZmxvYXQgbGltbmVnID0gLTEuOworCisgICAgaWYgKGYgPD0gbGltbmVnKSB7CisgICAgICAgIHJldHVybiBJTlQzMl9NSU47CisgICAgfSBlbHNlIGlmIChmID49IGxpbXBvcykgeworICAgICAgICByZXR1cm4gSU5UMzJfTUFYOworICAgIH0KKyAgICBmICo9IHNjYWxlOworICAgIC8qIGludGVnZXIgY29udmVyc2lvbiBpcyB0aHJvdWdoIHRydW5jYXRpb24gKHRob3VnaCBpbnQgdG8gZmxvYXQgaXMgbm90KS4KKyAgICAgKiBlbnN1cmUgdGhhdCB3ZSByb3VuZCB0byBuZWFyZXN0LCB0aWVzIGF3YXkgZnJvbSAwLgorICAgICAqLworICAgIHJldHVybiBmID4gMCA/IGYgKyAwLjUgOiBmIC0gMC41OworfQorCit2b2lkIGxvY2FsX2NvbnZlcnRfZmxvYXRfdG9faW50MzIoY29uc3QgZmxvYXQgKmlucHV0LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3QgKm91dHB1dCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgY291bnQpIHsKKyAgICBmb3IgKGludCBpID0gMDsgaSA8IGNvdW50OyBpKyspIHsKKyAgICAgICAgKm91dHB1dCsrID0gY2xhbXAzMkZyb21GbG9hdCgqaW5wdXQrKyk7CisgICAgfQorfQorCitURVNUKHRlc3RfZmxvd2dyYXBoLCBzaW1wbGVfY29udmVydF9mbG9hdF9pbnQzMikgeworICAgIHN0ZDo6YXJyYXk8aW50MzJfdCwga051bVNhbXBsZXM+IG91dHB1dDsKKworICAgIC8vIERvIGl0IGlubGluZSwgd2hpY2ggd2lsbCBwcm9iYWJseSB3b3JrIGV2ZW4gd2l0aCBhIGJ1Z2d5IGNvbXBpbGVyLgorICAgIC8vIFRoaXMgdmFsaWRhdGVzIHRoZSBleHBlY3RlZCBkYXRhLgorICAgIGNvbnN0IGZsb2F0ICppbiA9IGtJbnB1dEZsb2F0LmRhdGEoKTsKKyAgICBvdXRwdXQuZmlsbCg3NzcpOworICAgIGludDMyX3QgKm91dCA9IG91dHB1dC5kYXRhKCk7CisgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBrTnVtU2FtcGxlczsgaSsrKSB7CisgICAgICAgIGludDY0X3QgbiA9IChpbnQ2NF90KSAoKmluKysgKiAyMTQ3NDgzNjQ4LjBmKTsKKyAgICAgICAgKm91dCsrID0gKGludDMyX3Qpc3RkOjptaW4oKGludDY0X3QpSU5UMzJfTUFYLAorICAgICAgICAgICAgICAgIC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yAgICAgICAgICAgICAgICAgICAgICAgIEFBdWRpb19jb252ZXJ0UmVzdWx0VG9UZXh0KHJlc3VsdCkpOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICBwcmludGYoIkFBdWRpb1N0cmVhbV9jbG9zZSgpIERJU0FCTEVEIVxuIik7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBtU3RyZWFtID0gbnVsbHB0cjsKICAgICAgICAgfQpAQCAtMjMyLDYgKzIzOSwxMiBAQAogICAgICAgICByZXR1cm4gQUF1ZGlvU3RyZWFtX3JlcXVlc3RTdGFydChtU3RyZWFtKTsKICAgICB9CiAKKyAgICBhYXVkaW9fcmVzdWx0X3QgcGF1c2UoKSB7CisgICAgICAgIHN0ZDo6bG9ja19ndWFyZDxzdGQ6Om11dGV4PiBsb2NrKG1Mb2NrKTsKKyAgICAgICAgaWYgKG1TdHJlYW0gPT0gbnVsbHB0cikgcmV0dXJuIDA7CisgICAgICAgIHJldHVybiBBQXVkaW9TdHJlYW1fcmVxdWVzdFBhdXNlKG1TdHJlYW0pOworICAgIH0KKwogICAgIGFhdWRpb19yZXN1bHRfdCBzdG9wKCkgewogICAgICAgICBzdGQ6OmxvY2tfZ3VhcmQ8c3RkOjptdXRleD4gbG9jayhtTG9jayk7CiAgICAgICAgIGlmIChtU3RyZWFtID09IG51bGxwdHIpIHJldHVybiAwOwpAQCAtMjg3LDYgKzMwMCw3IEBACiAgICAgc3RkOjpzdHJpbmcgICAgICAgICBtTmFtZTsKICAgICBpbnQgICAgICAgICAgICAgICAgIG1NYXhSZXRyaWVzID0gMTsKICAgICBpbnQgICAgICAgICAgICAgICAgIG1PcGVuRGVsYXlNaWxsaXMgPSAwOworICAgIGJvb2wgICAgICAgICAgICAgICAgbUNsb3NlRW5hYmxlZCA9IHRydWU7CiB9OwogCiAvLyBDYWxsYmFjayBmdW5jdGlvbiB0aGF0IGZpbGxzIHRoZSBhdWRpbyBvdXRwdXQgYnVmZmVyLgpAQC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iAKIGludCBtYWluKGludCBhcmdjLCBjaGFyICoqIGFyZ3YpIHsKQEAgLTMzNCw3ICszNTAsOSBAQAogICAgIGludCBlcnJvckNvdW50ID0gMDsKICAgICBpbnQgbWF4UmV0cmllcyA9IDE7CiAgICAgaW50IG9wZW5EZWxheU1pbGxpcyA9IDA7CisgICAgYm9vbCBjbG9zZUVuYWJsZWQgPSB0cnVlOwogICAgIGFhdWRpb19zaGFyaW5nX21vZGVfdCByZXF1ZXN0ZWRTaGFyaW5nTW9kZSA9IEFBVURJT19TSEFSSU5HX01PREVfRVhDTFVTSVZFOworICAgIGludCBwYXVzZWRNaWxsaXMgPSAwOwogCiAgICAgLy8gTWFrZSBwcmludGYgcHJpbnQgaW1tZWRpYXRlbHkgc28gdGhhdCBkZWJ1ZyBpbmZvIGlzIG5vdCBzdHVjawogICAgIC8vIGluIGEgYnVmZmVyIGlmIHdlIGhhbmcgb3IgY3Jhc2guCkBAIC0zNDgsMTIgKzM2NiwxOCBAQAogICAgICAgICBpZiAoYXJnWzBdID09ICctJykgewogICAgICAgICAgICAgY2hhciBvcHRpb24gPSBhcmdbMV07CiAgICAgICAgICAgICBzd2l0Y2ggKG9wdGlvbikgeworICAgICAgICAgICAgICAgIGNhc2UgJ2MnOgorICAgICAgICAgICAgICAgICAgICBjbG9zZUVuYWJsZWQgPSBhdG9pKCZhcmdbMl0pICE9IDA7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgIGNhc2UgJ2QnOgogICAgICAgICAgICAgICAgICAgICBvcGVuRGVsYXlNaWxsaXMgPSBhdG9pKCZhcmdbMl0pOwogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICBjYXNlICdpJzoKICAgICAgICAgICAgICAgICAgICAgZGlyZWN0aW9uID0gQUFVRElPX0RJUkVDVElPTl9JTlBVVDsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSAncCc6CisgICA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RU5URVIgfSwKKyAgICAgICAgeyBBVURJT19DSEFOTkVMX0lOX0xPV19GUkVRVUVOQ1ksIEF1ZGlvQ2hhbm5lbExheW91dDo6Q0hBTk5FTF9MT1dfRlJFUVVFTkNZIH0sCisgICAgICAgIHsgQVVESU9fQ0hBTk5FTF9JTl9UT1BfTEVGVCwgQXVkaW9DaGFubmVsTGF5b3V0OjpDSEFOTkVMX1RPUF9TSURFX0xFRlQgfSwKKyAgICAgICAgeyBBVURJT19DSEFOTkVMX0lOX1RPUF9SSUdIVCwgQXVkaW9DaGFubmVsTGF5b3V0OjpDSEFOTkVMX1RPUF9TSURFX1JJR0hUIH0sCisgICAgICAgIC8vIFdoZW4gZ29pbmcgZnJvbSBhaWRsIHRvIGxlZ2FjeSwgSU5fQ0VOVEVSIGlzIHVzZWQKKyAgICAgICAgeyBBVURJT19DSEFOTkVMX0lOX0ZST05ULCBBdWRpb0NoYW5uZWxMYXlvdXQ6OkNIQU5ORUxfRlJPTlRfQ0VOVEVSIH0KKyAgICB9OworICAgIHJldHVybiBwYWlyczsKK30KKworY29uc3QgZGV0YWlsOjpBdWRpb0NoYW5uZWxQYWlycyYgZ2V0SW5BdWRpb0NoYW5uZWxQYWlycygpIHsKKyAgICBzdGF0aWMgY29uc3QgZGV0YWlsOjpBdWRpb0NoYW5uZWxQYWlycyBwYWlycyA9IHsKKyNkZWZpbmUgREVGSU5FX0lOUFVUX0xBWU9VVChuKSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgICAgICB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgICAgICAgICAgICAgIEFVRElPX0NIQU5ORUxfSU5fIyNuLCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgICAgICAgICBBdWRpb0NoYW5uZWxMYXlvdXQ6Om1ha2U8QXVkaW9DaGFubmVsTGF5b3V0OjpUYWc6OmxheW91dE1hc2s+KCBcCisgICAgICAgICAgICAgICAgICAgICAgICBBdWRpb0NoYW5uZWxMYXlvdXQ6OkxBWU9VVF8jI24pICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgICAgICAgICAgfQorCisgICAgICAgIERFRklORV9JTlBVVF9MQVlPVVQoTU9OTyksCisgICAgICAgIERFRklORV9JTlBVVF9MQVlPVVQoU1RFUkVPKSwKKyAgICAgICAgREVGSU5FX0lOUFVUX0xBWU9VVChGUk9OVF9CQUNLKSwKKyAgICAgICAgLy8gQVVESU9fQ0hBTk5FTF9JTl82IG5vdCBzdXBwb3J0ZWQKKyAgICAgICAgREVGSU5FX0lOUFVUX0xBWU9VVCgyUE9JTlQwUE9JTlQyKSwKKyAgICAgICAgREVGSU5FX0lOUFVUX0xBWU9VVCgyUE9JTlQxUE9JTlQyKSwKKyAgICAgICAgREVGSU5FX0lOUFVUX0xBWU9VVCgzUE9JTlQwUE9JTlQyKSwKKyAgICAgICAgREVGSU5FX0lOUFVUX0xBWU9VVCgzUE9JTlQxUE9JTlQyKSwKKyAgICAgICAgREVGSU5FX0lOUFVUX0xBWU9VVCg1UE9JTlQxKQorI3VuZGVmIERFRklORV9JTlBVVF9MQVlPVVQKKyAgICB9OworICAgIHJldHVybiBwYWlyczsKK30KKworY29uc3QgZGV0YWlsOjpBdWRpb0NoYW5uZWxCaXRQYWlycyYgZ2V0T3V0QXVkaW9DaGFubmVsQml0cygpIHsKKyAgICBzdGF0aWMgY29uc3QgZGV0YWlsOjpBdWRpb0NoYW5uZWxCaXRQYWlycyBwYWlycyA9IHsKKyNkZWZpbmUgREVGSU5FX09VVFBVVF9CSVRTKG4pICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgICAgICB7IEFVRElPX0NIQU5ORUxfT1VUXyMjbiwgQXVkaW9DaGFubmVsTGF5b3V0OjpDSEFOTkVMXyMjbiB9CisKKyAgICAgICAgREVGSU5FX09VVFBVVF9CSVRTKEZST05UX0xFRlQpLAorICAgICAgICBERUZJTkVfT1VUUFVUX0JJVFMoRlJPTlRfUklHSFQpLAorICAgICAgICBERUZJTkVfT1VUUFVUX0JJVFMoRlJPTlRfQ0VOVEVSKSwKKyAgICAgICAgREVGSU5FX09VVFBVVF9CSVRTKExPV19GUkVRVUVOQ1kpLAorICAgICAgICBERUZJTkVfT1VUUFVUX0JJVFMoQkFDS19MRUZUKSwKKyAgICAgICAgREVGSU5FX09VVFBVVF9CSVRTKEJBQ0tfUklHSFQpLAorICAgICAgICBERUZJTkVfT1VUUFVUX0JJVFMoRlJPTlRfTEVGVF9PRl9DRU5URVIpLAorICAgICAgICBERUZJTkVfT1VUUFVUX0JJVFMoRlJPTlRfUklHSFRfT0ZfQ0VOVEVSKSwKKyAgICAgICAgREVGSU5FX09VVFBVVF9CSVRTKEJBQ0tfQ0VOVEVSKSwKKyAgICAgICAgREVGSU5FX09VVFBVVF9CSVRTKFNJREVfTEVGVCksCisgICAgICAgIERFRklORV9PVVRQVVRfQklUUyhTSURFX1JJR0hUKSwKKyAgICAgICAgREVGSU5FX09VVFBVVF9CSVRTKFRPUF9DRU5URVIpLAorICAgICAgICBERUZJTkVfT1VUUFVUX0JJVFMoVE9QX0ZST05UX0xFRlQpLAorICAgICAgICBERUZJTkVfT1VUUFVUX0JJVFMoVE9QX0ZST05UX0NFTlRFUiksCisgICAgICAgIERFRklORV9PVVRQVVRfQklUUyhUT1BfRlJPTlRfUklHSFQpLAorICAgICAgICBERUZJTkVfT1VUUFVUX0JJVFMoVE9QX0JBQ0tfTEVGVCksCisgICAgICAgIERFRklORV9PVVRQVVRfQklUUyhUT1BfQkFDS19DRU5URVIpLAorICAgICAgICBERUZJTkVfT1VUUFVUX0JJVFMoVE9QX0JBQ0tfUklHSFQpLAorICAgICAgICBERUZJTkVfT1VUUFVUX0JJVFMoVE9QX1NJREVfTEVGVCksCisgICAgICAgIERFRklORV9PVVRQVVRfQklUUyhUT1BfU0lERV9SSUdIVCksCisgICAgICAgIERFRklORV9PVVRQVVRfQklUUyhCT1RUT01fRlJPTlRfTEVGVCksCisgICAgICAgIERFRklORV9PVVRQVVRfQklUUyhCT1RUT01fRlJPTlRfQ0VOVEVSKSwKKyAgICAgICAgREVGSU5FX09VVFBVVF9CSVRTKEJPVFRPTV9GUk9OVF9SSUdIVCksCisgICAgICAgIERFRklORV9PVVRQVVRfQklUUyhMT1dfRlJFUVVFTkNZXzIpLAorICAgICAgICBERUZJTkVfT1VUUFVUX0JJVFMoRlJPTlRfV0lERV9MRUZUKSwKKyAgICAgICAgREVGSU5FX09VVFBVVF9CSVRTKEZST05UX1dJREVfUklHSFQpLAorI3VuZGVmIERFRklORV9PVVRQVVRfQklUUworICAgICAgICB7IEFVRElPX0NIQU5ORUxfT1VUX0hBUFRJQ19BLCBBdWRpb0NoYW5uZWxMYXlvdXQ6OkNIQU5ORUxfSEFQVElDX0EgfSwKKyAgICAgICAgeyBBVURJT19DSEFOTkVMX09VVF9IQVBUSUNfQiwgQXVkaW9DaGFubmVsTGF5b3V0OjpDSEFOTkVMX0hBUFRJQ19CIH0KKyAgICB9OworICAgIHJldHVybiBwYWlyczsKK30KKworY29uc3QgZGV0YWlsOjpBdWRpb0NoYW5uZWxQYWlycyYgZ2V0T3V0QXVkaW9DaGFubmVsUGFpcnMoKSB7CisgICAgc3RhdGljIGNvbnN0IGRldGFpbDo6QXVkaW9DaGFubmVsUGFpcnMgcGFpcnMgPSB7CisjZGVmaW5lIERFRklORV9PVVRQVVRfTEFZT1VUKG4pICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgICAgICAgICAgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgICAgICAgICBBVURJT19DSEFOTkVMX09VVF8jI24sICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgICAgICAgICAgQXVkaW9DaGFubmVsTGF5b3V0OjptYWtlPEF1ZGlvQ2hhbm5lbExheW91dDo6VGFnOjpsYXlvdXRNYXNrPiggXAorICAgICAgICAgICAgICAgICAgICAgICAgQXVkaW9DaGFubmVsTGF5b3V0OjpMQVlPVVRfIyNuKSAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgICAgIH0KKworICAgICAgICBERUZJTkVfT1VUUFVUX0xBWU9VVChNT05PKSwKKyAgICAgICAgREVGSU5FX09VVFBVVF9MQVlPVVQoU1RFUkVPKSwKKyAgICAgICAgREVGSU5FX09VVFBVVF9MQVlPVVQoMlBPSU5UMSksCisgICAgICAgIERFRklORV9PVVRQVVRfTEFZT1VUKFRSSSksCisgICAgICAgIERFRklORV9PVVRQVVRfTEFZT1VUKFRSSV9CQUNLKSwKKyAgICAgICAgREVGSU5FX09VVFBVVF9MQVlPVVQoM1BPSU5UMSksCisgICAgICAgIERFRklORV9PVVRQVVRfTEFZT1VUKDJQT0lOVDBQT0lOVDIpLAorICAgICAgICBERUZJTkVfT1VUUFVUX0xBWU9VVCgyUE9JTlQxUE9JTlQyKSwKKyAgICAgICAgREVGSU5FX09VVFBVVF9MQVlPVVQoM1BPSU5UMFBPSU5UMiksCisgICAgICAgIERFRklORV9PVVRQVVRfTEFZT1VUKDNQT0lOVDFQT0lOVDIpLAorICAgICAgICBERUZJTkVfT1VUUFVUX0xBWU9VVChRVUFEKSwKKyAgICAgICAgREVGSU5FX09VVFBVVF9MQVlPVVQoUVVBRF9TSURFKSwKKyAgICAgICAgREVGSU5FX09VVFBVVF9MQVlPVVQoU1VSUk9VTkQpLAorICAgICAgICBERUZJTkVfT1VUUFVUX0xBWU9VVChQRU5UQSksCisgICAgICAgIERFRklORV9PVVRQVVRfTEFZT1VUKDVQT0lOVDEpLAorICAgICAgICBERUZJTkVfT1VUUFVUX0xBWU9VVCg1UE9JTlQxX1NJREUpLAorICAgICAgICBERUZJTkVfT1VUUFVUX0xBWU9VVCg1UE9JTlQxUE9JTlQyKSwKKyAgICAgICAgREVGSU5FX09VVFBVVF9MQVlPVVQoNVBPSU5UMVBPSU5UNCksCisgICAgICAgIERFRklORV9PVVRQVVRfTEFZT1VUKDZQT0lOVDEpLAorICAgICAgICBERUZJTkVfT1VUUFVUX0xBWU9VVCg3UE9JTlQxKSwKKyAgICAgICAgREVGSU5FX09VVFBVVF9MQVlPVVQoN1BPSU5UMVBPSU5UMiksCisgICAgICAgIERFRklORV9PVVRQVVRfTEFZT1VUKDdQT0lOVDFQT0lOVDQpLAorICAgICAgICBERUZJTkVfT1VUUFVUX0xBWU9VVCgxM1BPSU5UXzM2MFJBKSwKKyAgICAgICAgREVGSU5FX09VVFBVVF9MQVlPVVQoMjJQT0lOVDIpLAorICAgICAgICBERUZJTkVfT1VUUFVUX0xBWU9VVChNT05PX0hBUFRJQ19BKSwKKyAgICAgICAgREVGSU5FX09VVFBVVF9MQVlPVVQoU1RFUkVPX0hBUFRJQ19BKSwKKyAgICAgICAgREVGSU5FX09VVFBVVF9MQVlPVVQoSEFQVElDX0FCKSwKKyAgICAgICAgREVGSU5FX09VVFBVVF9MQVlPVVQoTU9OT19IQVBUSUNfQUIpLAorICAgICAgICBERUZJTkVfT1VUUFVUX0xBWU9VVChTVEVSRU9fSEFQVElDX0FCKQorI3VuZGVmIERFRklORV9PVVRQVVRfTEFZT1VUCisgICAgfTsKKyAgICByZXR1cm4gcGFpcnM7Cit9CisKK2NvbnN0IGRldGFpbDo6QXVkaW9DaGFubmVsUGFpcnMmIGdldFZvaWNlQXVkaW9DaGFubmVsUGFpcnMoKSB7CisgICAgc3RhdGljIGNvbnN0IGRldGFpbDo6QXVkaW9DaGFubmVsUGFpcnMgcGFpcnMgPSB7CisjZGVmaW5lIERFRklORV9WT0lDRV9MQVlPVVQobikgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgICAgICAgICAgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgICAgICAgICBBVURJT19DSEFOTkVMX0lOX1ZPSUNFXyMjbiwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgICAgICAgICAgQXVkaW9DaGFubmVsTGF5b3V0OjptYWtlPEF1ZGlvQ2hhbm5lbExheW91dDo6VGFnOjp2b2ljZU1hc2s+KCAgXAorICAgICAgICAgICAgICAgICAgICAgICAgQXVkaW9DaGFubmVsTGF5b3V0OjpWT0lDRV8jI24pICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgICAgIH0KKyAgICAgICAgREVGSU5FX1ZPSUNFX0xBWU9VVChVUExJTktfTU9OTyksCisgICAgICAgIERFRklORV9WT0lDRV9MQVlPVVQoRE5MSU5LX01PTk8pLAorICAgICAgICBERUZJTkVfVk9JQ0VfTEFZT1VUKENBTExfTU9OTykKKyN1bmRlZiBERUZJTkVfVk9JQ0VfTEFZT1VUCisgICAgfTsKKyAgICByZXR1cm4gcGFpcnM7Cit9CisKK0F1ZGlvRGV2aWNlRGVzY3JpcHRpb24gbWFrZV9BdWRpb0RldmljZURlc2NyaXB0aW9uKEF1ZGlvRGV2aWNlVHlwZSB0eXBlLAorICAgICAgICBjb25zdCBzdGQ6OnN0cmluZyYgY29ubmVjdGlvbiA9ICIiKSB7CisgICAgQXVkaW9EZXZpY2VEZXNjcmlwdGlvbiByZXN1bHQ7CisgICAgcmVzdWx0LnR5cGUgPSB0eXBlOworICAgIHJlc3VsdC5jb25uZWN0aW9uID0gY29ubmVjdGlvbjsKKyAgICByZXR1cm4gcmVzdWx0OworfQorCit2b2lkIGFwcGVuZF9BdWRpb0RldmljZURlc2NyaXB0aW9uKGRldGFpbDo6QXVkaW9EZXZpY2VQYWlycyYgcGFpcnMsCisgICAgICAgIGF1ZGlvX2RldmljZXNfdCBpbnB1dFR5cGUsIGF1ZGlvX2RldmljZXNfdCBvdXRwdXRUeXBlLAorICAgICAgICBBdWRpb0RldmljZVR5cGUgaW5UeXBlLCBBdWRpb0RldmljZVR5cGUgb3V0VHlwZSwKKyAgICAgICAgY29uc3Qgc3RkOjpzdHJpbmcmIGNvbm5lY3Rpb24gPSAiIikgeworICAgIHBhaXJzLnB1c2hfYmFjayhzdGQ6Om1ha2VfcGFpcihpbnB1dFR5cGUsIG1ha2VfQXVkaW9EZXZpY2VEZXNjcmlwdGlvbihpblR5cGUsIGNvbm5lY3Rpb24pKSk7CisgICAgcGFpcnMucHVzaF9iYWNrKHN0ZDo6bWFrZV9wYWlyKG91dHB1dFR5cGUsIG1ha2VfQXVkaW9EZXZpY2VEZXNjcmlwdGlvbihvdXRUeXBlLCBjb25uZWN0aW9uKSkpOworfQorCitjb25zdCBkZXRhaWw6OkF1ZGlvRGV2aWNlUGFpcnMmIGdldEF1ZGlvRGV2aWNlUGFpcnMoKSB7CisgICAgc3RhdGljIGNvbnN0IGRldGFpbDo6QXVkaW9EZXZpY2VQYWlycyBwYWlycyA9IFtdKCkgeworICAgICAgICBkZXRhaWw6OkF1ZGlvRGV2aWNlUGFpcnMgcGFpcnMgPSB7eworICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIEFVRElPX0RFVklDRV9OT05FLCBBdWRpb0RldmljZURlc2NyaXB0aW9ue30KKyAgICAgICAgICAgIH0sCisgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgQVVESU9fREVWSUNFX09VVF9FQVJQSUVDRSwgbWFrZV9BdWRpb0RldmljZURlc2NyaXB0aW9uKAorICAgICAgICAgICAgICAgICAgICAgICAgQXVkaW9EZXZpY2VUeXBlOjpPVVRfU1BFQUtFUl9FQVJQSUVDRSkKKyAgICAgICAgICAgIH0sCisgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgQVVESU9fREVWSUNFX09VVF9TUEVBS0VSLCBtYWtlX0F1ZGlvRGV2aWNlRGVzY3JpcHRpb24oCisgICAgICAgICAgICAgICAgICAgICAgICBBdWRpb0RldmljZVR5cGU6Ok9VVF9TUEVBS0VSKQorICAgICAgICAgICAgfSwKKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICBBVURJT19ERVZJQ0VfT1VUX1dJUkVEX0hFQURQSE9ORSwgbWFrZV9BdWRpb0RldmljZURlc2NyaXB0aW9uKAorICAgICAgICAgICAgICAgICAgICAgICAgQXVkaW9EZXZpY2VUeXBlOjpPVVRfSEVBRFBIT05FLAorICAgICAgICAgICAgICAgICAgICAgICAgQXVkaW9EZXZpY2VEZXNjcmlwdGlvbjo6Q09OTkVDVElPTl9BTkFMT0coKSkKKyAgICAgICAgICAgIH0sCisgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgQVVESU9fREVWSUNFX09VVF9CTFVFVE9PVEhfU0NPLCBtYWtlX0F1ZGlvRGV2aWNlRGVzY3JpcHRpb24oCisgICAgICAgICAgICAgICAgICAgICAgICBBdWRpb0RldmljZVR5cGU6Ok9VVF9ERVZJQ0UsCisgICAgICAgICAgICAgICAgICAgICAgICBBdWRpb0RldmljZURlc2NyaXB0aW9uOjpDT05ORUNUSU9OX0JUX1NDTygpKQorICAgICAgICAgICAgfSwKKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICBBVURJT19ERVZJQ0VfT1VUX0JMVUVUT09USF9TQ09fQ0FSS0lULCBtYWtlX0F1ZGlvRGV2aWNlRGVzY3JpcHRpb24oCisgICAgICAgICAgICAgICAgICAgICAgICBBdWRpb0RldmljZVR5cGU6Ok9VVF9DQVJLSVQsCisgICAgICAgICAgICAgICAgICAgICAgICBBdWRpb0RldmljZURlc2NyaXB0aW9uOjpDT05ORUNUSU9OX0JUX1NDTygpKQorICAgICAgICAgICAgfSwKKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICBBVURJT19ERVZJQ0VfT1VUX0JMVUVUT09USF9BMkRQX0hFQURQSE9ORVMsIG1ha2VfQXVkaW9EZXZpY2VEZXNjcmlwdGlvbigKKyAgICAgICAgICAgICAgICAgICAgICAgIEF1ZGlvRGV2aWNlVHlwZTo6T1VUX0hFQURQSE9ORSwKKyAgICAgICAgICAgICAgICAgICAgICAgIEF1ZGlvRGV2aWNlRGVzY3JpcHRpb246OkNPTk5FQ1RJT05fQlRfQTJEUCgpKQorICAgICAgICAgICAgfSwKKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICBBVURJT19ERVZJQ0VfT1VUX0JMVUVUT09USF9BMkRQX1NQRUFLRVIsIG1ha2VfQXVkaW9EZXZpY2VEZXNjcmlwdGlvbigKKyAgICAgICAgICAgICAgICAgICAgICAgIEF1ZGlvRGV2aWNlVHlwZTo6T1VUX1NQRUFLRVIsCisgICAgICAgICAgICAgICAgICAgICAgICBBdWRpb0RldmljZURlc2NyaXB0aW9uOjpDT05ORUNUSU9OX0JUX0EyRFAoKSkKKyAgICAgICAgICAgIH0sCisgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgQVVESU9fREVWSUNFX09VVF9URUxFUEhPTllfVFgsIG1ha2VfQXVkaW9EZXZpY2VEZXNjcmlwdGlvbigKKyAgICAgICAgICAgICAgICAgICAgICAgIEF1ZGlvRGV2aWNlVHlwZTo6T1VUX1RFTEVQSE9OWV9UWCkKKyAgICAgICAgICAgIH0sCisgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgQVVESU9fREVWSUNFX09VVF9BVVhfTElORSwgbWFrZV9BdWRpb0RldmljZURlc2NyaXB0aW9uKAorICAgICAgICAgICAgICAgICAgICAgICAgQXVkaW9EZXZpY2VUeXBlOjpPVVRfTElORV9BVVgpCisgICAgICAgICAgICB9LAorICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIEFVRElPX0RFVklDRV9PVVRfU1BFQUtFUl9TQUZFLCBtYWtlX0F1ZGlvRGV2aWNlRGVzY3JpcHRpb24oCisgICAgICAgICAgICAgICAgICAgICAgICBBdWRpb0RldmljZVR5cGU6Ok9VVF9TUEVBS0VSX1NBRkUpCisgICAgICAgICAgICB9LAorICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIEFVRElPX0RFVklDRV9PVVRfSEVBUklOR19BSUQsIG1ha2VfQXVkaW9EZXZpY2VEZXNjcmlwdGlvbigKKyAgICAgICAgICAgICAgICAgICAgICAgIEF1ZGlvRGV2aWNlVHlwZTo6T1VUX0hFQVJJTkdfQUlELAorICAgICAgICAgICAgICAgICAgICAgICAgQXVkaW9EZXZpY2VEZXNjcmlwdGlvbjo6Q09OTkVDVElPTl9XSVJFTEVTUygpKQorICAgICAgICAgICAgfSwKKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICBBVURJT19ERVZJQ0VfT1VUX0VDSE9fQ0FOQ0VMTEVSLCBtYWtlX0F1ZGlvRGV2aWNlRGVzY3JpcHRpb24oCisgICAgICAgICAgICAgICAgICAgICAgICBBdWRpb0RldmljZVR5cGU6Ok9VVF9FQ0hPX0NBTkNFTExFUikKKyAgICAgICAgICAgIH0sCisgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgQVVESU9fREVWSUNFX09VVF9CTEVfU1BFQUtFUiwgbWFrZV9BdWRpb0RldmljZURlc2NyaXB0aW9uKAorICAgICAgICAgICAgICAgICAgICAgICAgQXVkaW9EZXZpY2VUeXBlOjpPVVRfU1BFQUtFUiwKKyAgICAgICAgICAgICAgICAgICAgICAgIEF1ZGlvRGV2aWNlRGVzY3JpcHRpb246OkNPTk5FQ1RJT05fQlRfTEUoKSkKKyAgICAgICAgICAgIH0sCisgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgQVVESU9fREVWSUNFX09VVF9CTEVfQlJPQURDQVNULCBtYWtlX0F1ZGlvRGV2aWNlRGVzY3JpcHRpb24oCisgICAgICAgICAgICAgICAgICAgICAgICBBdWRpb0RldmljZVR5cGU6Ok9VVF9CUk9BRENBU1QsCisgICAgICAgICAgICAgICAgICAgICAgICBBdWRpb0RldmljZURlc2NyaXB0aW9uOjpDT05ORUNUSU9OX0JUX0xFKCkpCisgICAgICAgICAgICB9LAorICAgICAgICAgICAgLy8gQVVESU9fREVWSUNFX0lOX0FNQklFTlQgYW5kIElOX0NPTU1VTklDQVRJT04gYXJlIHJlbW92ZWQgc2luY2UgdGhleSB3ZXJlIGRlcHJlY2F0ZWQuCisgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgQVVESU9fREVWSUNFX0lOX0JVSUxUSU5fTUlDLCBtYWtlX0F1ZGlvRGV2aWNlRGVzY3JpcHRpb24oCisgICAgICAgICAgICAgICAgICAgICAgICBBdWRpb0RldmljZVR5cGU6OklOX01JQ1JPUEhPTkUpCisgICAgICAgICAgICB9LAorICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIEFVRElPX0RFVklDRV9JTl9CQUNLX01JQywgbWFrZV9BdWRpb0RldmljZURlc2NyaXB0aW9uKAorICAgICAgICAgICAgICAgICAgICAgICAgQXVkaW9EZXZpY2VUeXBlOjpJTl9NSUNST1BIT05FX0JBQ0spCisgICAgICAgICAgICB9LAorICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIEFVRElPX0RFVklDRV9JTl9URUxFUEhPTllfUlgsIG1ha2VfQXVkaW9EZXZpY2VEZXNjcmlwdGlvbigKKyAgICAgICAgICAgICAgICAgICAgICAgIEF1ZGlvRGV2aWNlVHlwZTo6SU5fVEVMRVBIT05ZX1JYKQorICAgICAgICAgICAgfSwKKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICBBVURJT19ERVZJQ0VfSU5fVFZfVFVORVIsIG1ha2VfQXVkaW9EZXZpY2VEZXNjcmlwdGlvbigKKyAgICAgICAgICAgICAgICAgICAgICAgIEF1ZGlvRGV2aWNlVHlwZTo6SU5fVFZfVFVORVIpCisgICAgICAgICAgICB9LAorICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIEFVRElPX0RFVklDRV9JTl9MT09QQkFDSywgbWFrZV9BdWRpb0RldmljZURlc2NyaXB0aW9uKAorICAgICAgICAgICAgICAgICAgICAgICAgQXVkaW9EZXZpY2VUeXBlOjpJTl9MT09QQkFDSykKKyAgICAgICAgICAgIH0sCisgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgQVVESU9fREVWSUNFX0lOX0JMVUVUT09USF9CTEUsIG1ha2VfQXVkaW9EZXZpY2VEZXNjcmlwdGlvbigKKyAgICAgICAgICAgICAgICAgICAgICAgIEF1ZGlvRGV2aWNlVHlwZTo6SU5fREVWSUNFLAorICAgICAgICAgICAgICAgICAgICAgICAgQXVkaW9EZXZpY2VEZXNjcmlwdGlvbjo6Q09OTkVDVElPTl9CVF9MRSgpKQorICAgICAgICAgICAgfSwKKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICBBVURJT19ERVZJQ0VfSU5fRUNIT19SRUZFUkVOQ0UsIG1ha2VfQXVkaW9EZXZpY2VEZXNjcmlwdGlvbigKKyAgICAgICAgICAgICAgICAgICAgICAgIEF1ZGlvRGV2aWNlVHlwZTo6SU5fRUNIT19SRUZFUkVOQ0UpCisgICAgICAgICAgICB9CisgICAgICAgIH19OworICAgICAgICBhcHBlbmRfQXVkaW9EZXZpY2VEZXNjcmlwdGlvbihwYWlycywKKyAgICAgICAgICAgICAgICBBVURJT19ERVZJQ0VfSU5fREVGQVVMVCwgQVVESU9fREVWSUNFX09VVF9ERUZBVUxULAorICAgICAgICAgICAgICAgIEF1ZGlvRGV2aWNlVHlwZTo6SU5fREVGQVVMVCwgQXVkaW9EZXZpY2VUeXBlOjpPVVRfREVGQVVMVCk7CisgICAgICAgIGFwcGVuZF9BdWRpb0RldmljZURlc2NyaXB0aW9uKHBhaXJzLAorICAgICAgICAgICAgICAgIEFVRElPX0RFVklDRV9JTl9XSVJFRF9IRUFEU0VULCBBVURJT19ERVZJQ0VfT1VUX1dJUkVEX0hFQURTRVQsCisgICAgICAgICAgICAgICAgQXVkaW9EZXZpY2VUeXBlOjpJTl9IRUFEU0VULCBBdWRpb0RldmljZVR5cGU6Ok9VVF9IRUFEU0VULAorICAgICAgICAgICAgICAgIEF1ZGlvRGV2aWNlRGVzY3JpcHRpb246OkNPTk5FQ1RJT05fQU5BTE9HKCkpOworICAgICAgICBhcHBlbmRfQXVkaW9EZXZpY2VEZXNjcmlwdGlvbihwYWlycywKKyAgICAgICAgICAgICAgICBBVURJT19ERVZJQ0VfSU5fQkxVRVRPT1RIX1NDT19IRUFEU0VULCBBVURJT19ERVZJQ0VfT1VUX0JMVUVUT09USF9TQ09fSEVBRFNFVCwKKyAgICAgICAgICAgICAgICBBdWRpb0RldmljZVR5cGU6OklOX0hFQURTRVQsIEF1ZGlvRGV2aWNlVHlwZTo6T1VUX0hFQURTRVQsCisgICAgICAgICAgICAgICAgQXVkaW9EZXZpY2VEZXNjcmlwdGlvbjo6Q09OTkVDVElPTl9CVF9TQ08oKSk7CisgICAgICAgIGFwcGVuZF9BdWRpb0RldmljZURlc2NyaXB0aW9uKHBhaXJzLAorICAgICAgICAgICAgICAgIEFVRElPX0RFVklDRV9JTl9IRE1JLCBBVURJT19ERVZJQ0VfT1VUX0hETUksCisgICAgICAgICAgICAgICAgQXVkaW9EZXZpY2VUeXBlOjpJTl9ERVZJQ0UsIEF1ZGlvRGV2aWNlVHlwZTo6T1VUX0RFVklDRSwKKyAgICAgICAgICAgICAgICBBdWRpb0RldmljZURlc2NyaXB0aW9uOjpDT05ORUNUSU9OX0hETUkoKSk7CisgICAgICAgIGFwcGVuZF9BdWRpb0RldmljZURlc2NyaXB0aW9uKHBhaXJzLAorICAgICAgICAgICAgICAgIEFVRElPX0RFVklDRV9JTl9SRU1PVEVfU1VCTUlYLCBBVURJT19ERVZJQ0VfT1VUX1JFTU9URV9TVUJNSVgsCisgICAgICAgICAgICAgICAgQXVkaW9EZXZpY2VUeXBlOjpJTl9TVUJNSVgsIEF1ZGlvRGV2aWNlVHlwZTo6T1VUX1NVQk1JWCk7CisgICAgICAgIGFwcGVuZF9BdWRpb0RldmljZURlc2NyaXB0aW9uKHBhaXJzLAorICAgICAgICAgICAgICAgIEFVRElPX0RFVklDRV9JT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CX0RFVklDRSwKKyAgICAgICAgICAgICAgICBBdWRpb0RldmljZVR5cGU6OklOX0RFVklDRSwgQXVkaW9EZXZpY2VUeXBlOjpPVVRfREVWSUNFLAorICAgICAgICAgICAgICAgIEF1ZGlvRGV2aWNlRGVzY3JpcHRpb246OkNPTk5FQ1RJT05fVVNCKCkpOworICAgICAgICBhcHBlbmRfQXVkaW9EZXZpY2VEZXNjcmlwdGlvbihwYWlycywKKyAgICAgICAgICAgICAgICBBVURJT19ERVZJQ0VfSU5fRk1fVFVORVIsIEFVRElPX0RFVklDRV9PVVRfRk0sCisgICAgICAgICAgICAgICAgQXVkaW9EZXZpY2VUeXBlOjpJTl9GTV9UVU5FUiwgQXVkaW9EZXZpY2VUeXBlOjpPVVRfRk0pOworICAgICAgICBhcHBlbmRfQXVkaW9EZXZpY2VEZXNjcmlwdGlvbihwYWlycywKKyAgICAgICAgICAgICAgICBBVURJT19ERVZJQ0VfSU5fTElORSwgQVVESU9fREVWSUNFX09VVF9MSU5FLAorICAgICAgICAgICAgICAgIEF1ZGlvRGV2aWNlVHlwZTo6SU5fREVWSUNFLCBBdWRpb0RldmljZVR5cGU6Ok9VVF9ERVZJQ0UsCisgICAgICAgICAgICAgICAgQXVkaW9EZXZpY2VEZXNjcmlwdGlvbjo6Q09OTkVDVElPTl9BTkFMT0coKSk7CisgICAgICAgIGFwcGVuZF9BdWRpb0RldmljZURlc2NyaXB0aW9uKHBhaXJzLAorICAgICAgICAgICAgICAgIEFVRElPX0RFVklDRV9JTl9TUERJRiwgQVVESU9fREVWSUNFX09VVF9TUERJRiwKKyAgICAgICAgICAgICAgICBBdWRpb0RldmljZVR5cGU6OklOX0RFVklDRSwgQXVkaW9EZXZpY2VUeXBlOjpPVVRfREVWSUNFLAorICAgICAgICAgICAgICAgIEF1ZGlvRGV2aWNlRGVzY3JpcHRpb246OkNPTk5FQ1RJT05fU1BESUYoKSk7CisgICAgICAgIGFwcGVuZF9BdWRpb0RldmljZURlc2NyaXB0aW9u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2aWNlVHlwZTo6SU5fQUZFX1BST1hZLCBBdWRpb0RldmljZVR5cGU6Ok9VVF9BRkVfUFJPWFkpOworICAgICAgICBhcHBlbmRfQXVkaW9EZXZpY2VEZXNjcmlwdGlvbihwYWlycywKKyAgICAgICAgICAgICAgICBBVURJT19ERVZJQ0VfSU5fVVNCX0hFQURTRVQsIEFVRElPX0RFVklDRV9PVVRfVVNCX0hFQURTRVQsCisgICAgICAgICAgICAgICAgQXVkaW9EZXZpY2VUeXBlOjpJTl9IRUFEU0VULCBBdWRpb0RldmljZVR5cGU6Ok9VVF9IRUFEU0VULAorICAgICAgICAgICAgICAgIEF1ZGlvRGV2aWNlRGVzY3JpcHRpb246OkNPTk5FQ1RJT05fVVNCKCkpOworICAgICAgICBhcHBlbmRfQXVkaW9EZXZpY2VEZXNjcmlwdGlvbihwYWlycywKKyAgICAgICAgICAgICAgICBBVURJT19ERVZJQ0VfSU5fSERNSV9BUkMsIEFVRElPX0RFVklDRV9PVVRfSERNSV9BUkMsCisgICAgICAgICAgICAgICAgQXVkaW9EZXZpY2VUeXBlOjpJTl9ERVZJQ0UsIEF1ZGlvRGV2aWNlVHlwZTo6T1VUX0RFVklDRSwKKyAgICAgICAgICAgICAgICBBdWRpb0RldmljZURlc2NyaXB0aW9uOjpDT05ORUNUSU9OX0hETUlfQVJDKCkpOworICAgICAgICBhcHBlbmRfQXVkaW9EZXZpY2VEZXNjcmlwdGlvbihwYWlycywKKyAgICAgICAgICAgICAgICBBVURJT19ERVZJQ0VfSU5fSERNSV9FQVJDLCBBVURJT19ERVZJQ0VfT1VUX0hETUlfRUFSQywKKyAgICAgICAgICAgICAgICBBdWRpb0RldmljZVR5cGU6OklOX0RFVklDRSwgQXVkaW9EZXZpY2VUeXBlOjpPVVRfREVWSUNFLAorICAgICAgICAgICAgICAgIEF1ZGlvRGV2aWNlRGVzY3JpcHRpb246OkNPTk5FQ1RJT05fSERNSV9FQVJDKCkpOworICAgICAgICBhcHBlbmRfQXVkaW9EZ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ihQY21UeXBlOjpJTlRfMzJfQklUKQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfUENNXzhfMjRfQklULCBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oUGNtVHlwZTo6RklYRURfUV84XzI0KQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfUENNX0ZMT0FULCBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oUGNtVHlwZTo6RkxPQVRfMzJfQklUKQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfUENNXzI0X0JJVF9QQUNLRUQsIG1ha2VfQXVkaW9Gb3JtYXREZXNjcmlwdGlvbihQY21UeXBlOjpJTlRfMjRfQklUKQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfTVAzLCBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oTUVESUFfTUlNRVRZUEVfQVVESU9fTVBFRykKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgQVVESU9fRk9STUFUX0FNUl9OQiwgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX0FNUl9OQikKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgQVVESU9fRk9STUFUX0FNUl9XQiwgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX0FNUl9XQikKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgQVVESU9fRk9STUFUX0FBQywgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX0FBQ19NUDQpCisgICAgICAgIH0sCisgICAgICAgIHsKKyAgICAgICAgICAgIEFVRElPX0ZPUk1BVF9BQUNfTUFJTiwgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX0FBQ19NQUlOKQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfQUFDX0xDLCBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oTUVESUFfTUlNRVRZUEVfQVVESU9fQUFDX0xDKQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfQUFDX1NTUiwgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX0FBQ19TU1IpCisgICAgICAgIH0sCisgICAgICAgIHsKKyAgICAgICAgICAgIEFVRElPX0ZPUk1BVF9BQUNfTFRQLCBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oTUVESUFfTUlNRVRZUEVfQVVESU9fQUFDX0xUUCkKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgQVVESU9fRk9STUFUX0FBQ19IRV9WMSwgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX0FBQ19IRV9WMSkKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgQVVESU9fRk9STUFUX0FBQ19TQ0FMQUJMRSwKKyAgICAgICAgICAgIG1ha2VfQXVkaW9Gb3JtYXREZXNjcmlwdGlvbihNRURJQV9NSU1FVFlQRV9BVURJT19BQUNfU0NBTEFCTEUpCisgICAgICAgIH0sCisgICAgICAgIHsKKyAgICAgICAgICAgIEFVRElPX0ZPUk1BVF9BQUNfRVJMQywgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX0FBQ19FUkxDKQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfQUFDX0xELCBtYWtlX0F1ZG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ICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfRE9MQllfVFJVRUhELAorICAgICAgICAgICAgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX0RPTEJZX1RSVUVIRCkKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgQVVESU9fRk9STUFUX0VWUkMsIG1ha2VfQXVkaW9Gb3JtYXREZXNjcmlwdGlvbihNRURJQV9NSU1FVFlQRV9BVURJT19FVlJDKQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfRVZSQ0IsIG1ha2VfQXVkaW9Gb3JtYXREZXNjcmlwdGlvbihNRURJQV9NSU1FVFlQRV9BVURJT19FVlJDQikKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgQVVESU9fRk9STUFUX0VWUkNXQiwgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX0VWUkNXQikKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgQVVESU9fRk9STUFUX0VWUkNOVywgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX0VWUkNOVykKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgQVVESU9fRk9STUFUX0FBQ19BRElGLCBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oTUVESUFfTUlNRVRZUEVfQVVESU9fQUFDX0FESUYpCisgICAgICAgIH0sCisgICAgICAgIHsKKyAgICAgICAgICAgIEFVRElPX0ZPUk1BVF9XTUEsIG1ha2VfQXVkaW9Gb3JtYXREZXNjcmlwdGlvbihNRURJQV9NSU1FVFlQRV9BVURJT19XTUEpCisgICAgICAgIH0sCisgICAgICAgIHsKKyAgICAgICAgICAgIC8vIE5vdGU6IG5vdCBpbiB0aGUgSUFOQSByZWdpc3RyeS4KKyAgICAgICAgICAgIEFVRElPX0ZPUk1BVF9XTUFfUFJPLCBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oImF1ZGlvL3gtbXMtd21hLnBybyIpCisgICAgICAgIH0sCisgICAgICAgIHsKKyAgICAgICAgICAgIEFVRElPX0ZPUk1BVF9BTVJfV0JfUExVUywgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX0FNUl9XQl9QTFVTKQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfTVAyLCBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oTUVESUFfTUlNRVRZUEVfQVVESU9fTVBFR19MQVlFUl9JSSkKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgQVVESU9fRk9STUFUX1FDRUxQLCBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oTUVESUFfTUlNRVRZUEVfQVVESU9fUUNFTFApCisgICAgICAgIH0sCisgICAgICAgIHsKKyAgICAgICAgICAgIC8vIE5vdGU6IG5vdCBpbiB0aGUgSUFOQSByZWdpc3RyeS4KKyAgICAgICAgICAgIEFVRElPX0ZPUk1BVF9EU0QsIG1ha2VfQXVkaW9Gb3JtYXREZXNjcmlwdGlvbigiYXVkaW8vdm5kLnNvbnkuZHNkIikKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgQVVESU9fRk9STUFUX0ZMQUMsIG1ha2VfQXVkaW9Gb3JtYXREZXNjcmlwdGlvbihNRURJQV9NSU1FVFlQRV9BVURJT19GTEFDKQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfQUxBQywgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX0FMQUMpCisgICAgICAgIH0sCisgICAgICAgIHsKKyAgICAgICAgICAgIC8vIE5vdGU6IG5vdCBpbiB0aGUgSUFOQSByZWdpc3RyeS4KKyAgICAgICAgICAgIEFVRElPX0ZPUk1BVF9BUEUsIG1ha2VfQXVkaW9Gb3JtYXREZXNjcmlwdGlvbigiYXVkaW8veC1hcGUiKQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfQUFDX0FEVFMsIG1ha2VfQXVkaW9Gb3JtYXREZXNjcmlwdGlvbihNRURJQV9NSU1FVFlQRV9BVURJT19BQUNfQURUUykKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgQVVESU9fRk9STUFUX0FBQ19BRFRTX01BSU4sCisgICAgICAgICAgICBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oTUVESUFfTUlNRVRZUEVfQVVESU9fQUFDX0FEVFNfTUFJTikKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgQVVESU9fRk9STUFUX0FBQ19BRFRTX0xDLCBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oTUVESUFfTUlNRVRZUEVfQVVESU9fQUFDX0FEVFNfTEMpCisgICAgICAgIH0sCisgICAgICAgIHsKKyAgICAgICAgICAgIEFVRElPX0ZPUk1BVF9BQUNfQURUU19TU1IsCisgICAgICAgICAgICBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oTUVESUFfTUlNRVRZUEVfQVVESU9fQUFDX0FEVFNfU1NSKQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfQUFDX0FEVFNfTFRQLAorICAgICAgICAgICAgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX0FBQ19BRFRTX0xUUCkKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgQVVESU9fRk9STUFUX0FBQ19BRFRTX0hFX1YxLAorICAgICAgICAgICAgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX0FBQ19BRFRTX0hFX1YxKQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfQUFDX0FEVFNfU0NBTEFCTEUsCisgICAgICAgICAgICBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oTUVESUFfTUlNRVRZUEVfQVVESU9fQUFDX0FEVFNfU0NBTEFCTEUpCisgICAgICAgIH0sCisgICAgICAgIHsKKyAgICAgICAgICAgIEFVRElPX0ZPUk1BVF9BQUNfQURUU19FUkxDLAorICAgICAgICAgICAgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX0FBQ19BRFRTX0VSTEMpCisgICAgICAgIH0sCisgICAgICAgIHsKKyAgICAgICAgICAgIEFVRElPX0ZPUk1BVF9BQUNfQURUU19MRCwgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX0FBQ19BRFRTX0xEKQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfQUFDX0FEVFNfSEVfVjIsCisgICAgICAgICAgICBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oTUVESUFfTUlNRVRZUEVfQVVESU9fQUFDX0FEVFNfSEVfVjIpCisgICAgICAgIH0sCisgICAgICAgIHsKKyAgICAgICAgICAgIEFVRElPX0ZPUk1BVF9BQUNfQURUU19FTEQsCisgICAgICAgICAgICBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oTUVESUFfTUlNRVRZUEVfQVVESU9fQUFDX0FEVFNfRUxEKQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfQUFDX0FEVFNfWEhFLAorICAgICAgICAgICAgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX0FBQ19BRFRTX1hIRSkKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgLy8gTm90ZTogbm90IGluIHRoZSBJQU5BIHJlZ2lzdHJ5LiAidm5kLm9jdGVsLnNiYyIgaXMgbm90IEJUIFNCQy4KKyAgICAgICAgICAgIEFVRElPX0ZPUk1BVF9TQkMsIG1ha2VfQXVkaW9Gb3JtYXREZXNjcmlwdGlvbigiYXVkaW8veC1zYmMiKQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfQVBUWCwgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX0FQVFgpCisgICAgICAgIH0sCisgICAgICAgIHsKKyAgICAgICAgICAgIC8vIE5vdGU6IG5vdCBpbiB0aGUgSUFOQSByZWdpc3RyeS4KKyAgICAgICAgICAgIEFVRElPX0ZPUk1BVF9BUFRYX0hELCBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oImF1ZGlvL3ZuZC5xY29tLmFwdHguaGQiKQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfQUM0LCBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oTUVESUFfTUlNRVRZUEVfQVVESU9fQUM0KQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICAvLyBOb3RlOiBub3QgaW4gdGhlIElBTkEgcmVnaXN0cnkuCisgICAgICAgICAgICBBVURJT19GT1JNQVRfTERBQywgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKCJhdWRpby92bmQuc29ueS5sZGFjIikKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgQVVESU9fRk9STUFUX01BVCwgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX0RPTEJZX01BVCkKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgLy8gTm90ZTogbm90IGluIHRoZSBJQU5BIHJlZ2lzdHJ5LgorICAgICAgICAgICAgQVVESU9fRk9STUFUX01BVF8xXzAsCisgICAgICAgICAgICBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oTUVESUFfTUlNRVRZUEVfQVVESU9fRE9MQllfTUFUICsgc3RkOjpzdHJpbmcoIi4xLjAiKSkKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgLy8gTm90ZTogbm90IGluIHRoZSBJQU5BIHJlZ2lzdHJ5LgorICAgICAgICAgICAgQVVESU9fRk9STUFUX01BVF8yXzAsCisgICAgICAgICAgICBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oTUVESUFfTUlNRVRZUEVfQVVESU9fRE9MQllfTUFUICsgc3RkOjpzdHJpbmcoIi4yLjAiKSkKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgLy8gTm90ZTogbm90IGluIHRoZSBJQU5BIHJlZ2lzdHJ5LgorICAgICAgICAgICAgQVVESU9fRk9STUFUX01BVF8yXzEsCisgICAgICAgICAgICBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oTUVESUFfTUlNRVRZUEVfQVVESU9fRE9MQllfTUFUICsgc3RkOjpzdHJpbmcoIi4yLjEiKSkKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgQVVESU9fRk9STUFUX0FBQ19MQVRNLCBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oTUVESUFfTUlNRVRZUEVfQVVESU9fQUFDKQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfQUFDX0xBVE1fTEMsIG1ha2VfQXVkaW9Gb3JtYXREZXNjcmlwdGlvbihNRURJQV9NSU1FVFlQRV9BVURJT19BQUNfTEFUTV9MQykKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgQVVESU9fRk9STUFUX0FBQ19MQVRNX0hFX1YxLAorICAgICAgICAgICAgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX0FBQ19MQVRNX0hFX1YxKQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfQUFDX0xBVE1fSEVfVjIsCisgICAgICAgICAgICBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oTUVESUFfTUlNRVRZUEVfQVVESU9fQUFDX0xBVE1fSEVfVjIpCisgICAgICAgIH0sCisgICAgICAgIHsKKyAgICAgICAgICAgIC8vIE5vdGU6IG5vdCBpbiB0aGUgSUFOQSByZWdpc3RyeS4KKyAgICAgICAgICAgIEFVRElPX0ZPUk1BVF9DRUxULCBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oImF1ZGlvL3gtY2VsdCIpCisgICAgICAgIH0sCisgICAgICAgIHsKKyAgICAgICAgICAgIC8vIE5vdGU6IG5vdCBpbiB0aGUgSUFOQSByZWdpc3RyeS4KKyAgICAgICAgICAgIEFVRElPX0ZPUk1BVF9BUFRYX0FEQVBUSVZFLCBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oImF1ZGlvL3ZuZC5xY29tLmFwdHguYWRhcHRpdmUiKQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICAvLyBOb3RlOiBub3QgaW4gdGhlIElBTkEgcmVnaXN0cnkuCisgICAgICAgICAgICBBVURJT19GT1JNQVRfTEhEQywgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKCJhdWRpby92bmQuc2F2aXRlY2gubGhkYyIpCisgICAgICAgIH0sCisgICAgICAgIHsKKyAgICAgICAgICAgIC8vIE5vdGU6IG5vdCBpbiB0aGUgSUFOQSByZWdpc3RyeS4KKyAgICAgICAgICAgIEFVRElPX0ZPUk1BVF9MSERDX0xMLCBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oImF1ZGlvL3ZuZC5zYXZpdGVjaC5saGRjLmxsIikKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgLy8gTm90ZTogbm90IGluIHRoZSBJQU5BIHJlZ2lzdHJ5LgorICAgICAgICAgICAgQVVESU9fRk9STUFUX0FQVFhfVFdTUCwgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKCJhdWRpby92bmQucWNvbS5hcHR4LnR3c3AiKQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICAvLyBOb3RlOiBub3QgaW4gdGhlIElBTkEgcmVnaXN0cnkuCisgICAgICAgICAgICBBVURJT19GT1JNQVRfTEMzLCBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oImF1ZGlvL3gtbGMzIikKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgQVVESU9fRk9STUFUX01QRUdILCBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oTUVESUFfTUlNRVRZUEVfQVVESU9fTVBFR0hfTUhNMSkKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICAgQVVESU9fRk9STUFUX01QRUdIX0JMX0wzLCBtYWtlX0F1ZGlvRm9ybWF0RGVzY3JpcHRpb24oTUVESUFfTUlNRVRZUEVfQVVESU9fTVBFR0hfQkxfTDMpCisgICAgICAgIH0sCisgICAgICAgIHsKKyAgICAgICAgICAgIEFVRElPX0ZPUk1BVF9NUEVHSF9CTF9MNCwgbWFrZV9BdWRpb0Zvcm1hdERlc2NyaXB0aW9uKE1FRElBX01JTUVUWVBFX0FVRElPX01QRUdIX0JMX0w0KQorICAgICAgICB9LAorICAgICAgICB7CisgICAgICAgICAgICBBVURJT19GT1JNQVRfTVBFR0hfTENfTDMsIG1ha2VfQXVkaW9Gb3JtYXREZXNjcmlwdGlvbihNRURJQV9NSU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XVkaW9DaGFubmVsTGF5b3V0JiBhaWRsLCBjb25zdCBSZXZlcnNlTWFwJiBtLAorICAgICAgICAgICAgY29uc3QgY2hhciogZnVuYywgY29uc3QgY2hhciogdHlwZSkgLT4gQ29udmVyc2lvblJlc3VsdDxhdWRpb19jaGFubmVsX21hc2tfdD4geworICAgICAgICBpZiAoYXV0byBpdCA9IG0uZmluZChhaWRsKTsgaXQgIT0gbS5lbmQoKSkgeworICAgICAgICAgICAgcmV0dXJuIGl0LT5zZWNvbmQ7CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICBBTE9HVygiJXM6IG5vIGxlZ2FjeSAlcyBhdWRpb19jaGFubmVsX21hc2tfdCBmb3VuZCBmb3IgJXMiLCBmdW5jLCB0eXBlLAorICAgICAgICAgICAgICAgICAgICBhaWRsLnRvU3RyaW5nKCkuY19zdHIoKSk7CisgICAgICAgICAgICByZXR1cm4gdW5leHBlY3RlZChCQURfVkFMVUUpOworICAgICAgICB9CisgICAgfTsKKworICAgIHN3aXRjaCAoYWlkbC5nZXRUYWcoKSkgeworICAgICAgICBjYXNlIFRhZzo6bm9uZToKKyAgICAgICAgICAgIHJldHVybiBBVURJT19DSEFOTkVMX05PTkU7CisgICAgICAgIGNhc2UgVGFnOjppbnZhbGlkOgorICAgICAgICAgICAgcmV0dXJuIEFVRElPX0NIQU5ORUxfSU5WQUxJRDsKKyAgICAgICAgY2FzZSBUYWc6OmluZGV4TWFzazoKKyAgICAgICAgICAgIC8vIEluZGV4IG1hc2tzIGRvIG5vdCBoYXZlIHByZS1kZWZpbmVkIHZhbHVlcy4KKyAgICAgICAgICAgIGlmIChjb25zdCBpbnQgYml0cyA9IGFpZGwuZ2V0PFRhZzo6aW5kZXhNYXNrPigpOworICAgICAgICAgICAgICAgICAgICBfX2J1aWx0aW5fcG9wY291bnQoYml0cykgIT0gMCAmJgorICAgICAgICAgICAgICAgICAgICBfX2J1aWx0aW5fcG9wY291bnQoYml0cykgPD0gQVVESU9fQ0hBTk5FTF9DT1VOVF9NQVgpIHsKKyAgICAgICAgICAgICAgICByZXR1cm4gYXVkaW9fY2hhbm5lbF9tYXNrX2Zyb21fcmVwcmVzZW50YXRpb25fYW5kX2JpdHMoCisgICAgICAgICAgICAgICAgICAgICAgICBBVURJT19DSEFOTkVMX1JFUFJFU0VOVEFUSU9OX0lOREVYLCBiaXRzKTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgQUxPR0UoIiVzOiBpbnZhbGlkIGluZGV4TWFzayB2YWx1ZSAweCV4IGluICVzIiwKKyAgICAgICAgICAgICAgICAgICAgICAgIF9fZnVuY19fLCBiaXRzLCBhaWRsLnRvU3RyaW5nKCkuY19zdHIoKSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIHVuZXhwZWN0ZWQoQkFEX1ZBTFVFKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgY2FzZSBUYWc6OmxheW91dE1hc2s6CisgICAgICAgICAgICAvLyBUaGUgZmFzdCBwYXRoIGlzIHRvIGZpbmQgYSBkaXJlY3QgbWF0Y2ggZm9yIHNvbWUga25vd24gbGF5b3V0IG1hc2suCisgICAgICAgICAgICBpZiAoY29uc3QgYXV0byBsYXlvdXRNYXRjaCA9IGNvbnZlcnQoYWlkbCwgaXNJbnB1dCA/IG1JbiA6IG1PdXQsIF9fZnVuY19fLAorICAgICAgICAgICAgICAgICAgICBpc0lucHV0ID8gImlucHV0IiA6ICJvdXRwdXQiKTsKKyAgICAgICAgICAgICAgICAgICAgbGF5b3V0TWF0Y2gub2soKSkgeworICAgICAgICAgICAgICAgIHJldHVybiBsYXlvdXRNYXRjaDsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIC8vIElmIGEgbWF0Y2ggZm9yIGEgcHJlZGVmaW5lZCBsYXlvdXQgd2Fzbid0IGZvdW5kLCBtYWtlIGEgY3VzdG9tIG9uZSBmcm9tIGJpdHMuCisgICAgICAgICAgICBpZiAoYXVkaW9fY2hhbm5lbF9t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IpOworICAgICAgICAgICAgICAgIGxheW91dE1hdGNoLm9rKCkpIHsKKyAgICAgICAgICAgIHJldHVybiBsYXlvdXRNYXRjaDsKKyAgICAgICAgfQorICAgICAgICAvLyBJZiBhIG1hdGNoIGZvciBhIHByZWRlZmluZWQgbGF5b3V0IHdhc24ndCBmb3VuZCwgbWFrZSBhIGN1c3RvbSBvbmUgZnJvbSBiaXRzLAorICAgICAgICAvLyByZWplY3RpbmcgdGhvc2Ugd2l0aCB2b2ljZSBjaGFubmVsIGJpdHMuCisgICAgICAgIGlmICghaXNJbnB1dCB8fAorICAgICAgICAgICAgICAgIChsZWdhY3kgJiAoQVVESU9fQ0hBTk5FTF9JTl9WT0lDRV9VUExJTksgfCBBVURJT19DSEFOTkVMX0lOX1ZPSUNFX0ROTElOSykpID09IDApIHsKKyAgICAgICAgICAgIGlmIChpbnQgYml0TWFza0xheW91dCA9CisgICAgICAgICAgICAgICAgICAgIGxlZ2FjeTJhaWRsX2F1ZGlvX2NoYW5uZWxfbWFza190X2JpdHNfQXVkaW9DaGFubmVsTGF5b3V0X2xheW91dCgKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZWdhY3ksIGlzSW5wdXQpOworICAgICAgICAgICAgICAgICAgICBiaXRNYXNrTGF5b3V0ICE9IDApIHsKKyAgICAgICAgICAgICAgICByZXR1cm4gQXVkaW9DaGFubmVsTGF5b3V0OjptYWtlPFRhZzo6bGF5b3V0TWFzaz4oYml0TWFza0xheW91dCk7CisgICAgICAgICAgICB9CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICBBTE9HRSgiJXM6IGxlZ2FjeSBhdWRpb19jaGFubmVsX21hc2tfdCB2YWx1ZSAweCV4IGNvbnRhaW5zIHZvaWNlIGJpdHMiLAorICAgICAgICAgICAgICAgICAgICBfX2Z1bmNfXywgbGVnYWN5KTsKKyAgICAgICAgfQorICAgICAgICByZXR1cm4gdW5leHBlY3RlZChCQURfVkFMVUUpOworICAgIH0KKworICAgIEFMT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3M6OlJBVzsKICAgICAgICAgY2FzZSBBVURJT19PVVRQVVRfRkxBR19TWU5DOgotICAgICAgICAgICAgcmV0dXJuIG1lZGlhOjpBdWRpb091dHB1dEZsYWdzOjpTWU5DOworICAgICAgICAgICAgcmV0dXJuIEF1ZGlvT3V0cHV0RmxhZ3M6OlNZTkM7CiAgICAgICAgIGNhc2UgQVVESU9fT1VUUFVUX0ZMQUdfSUVDOTU4X05PTkFVRElPOgotICAgICAgICAgICAgcmV0dXJuIG1lZGlhOjpBdWRpb091dHB1dEZsYWdzOjpJRUM5NThfTk9OQVVESU87CisgICAgICAgICAgICByZXR1cm4gQXVkaW9PdXRwdXRGbGFnczo6SUVDOTU4X05PTkFVRElPOwogICAgICAgICBjYXNlIEFVRElPX09VVFBVVF9GTEFHX0RJUkVDVF9QQ006Ci0gICAgICAgICAgICByZXR1cm4gbWVkaWE6OkF1ZGlvT3V0cHV0RmxhZ3M6OkRJUkVDVF9QQ007CisgICAgICAgICAgICByZXR1cm4gQXVkaW9PdXRwdXRGbGFnczo6RElSRUNUX1BDTTsKICAgICAgICAgY2FzZSBBVURJT19PVVRQVVRfRkxBR19NTUFQX05PSVJROgotICAgICAgICAgICAgcmV0dXJuIG1lZGlhOjpBdWRpb091dHB1dEZsYWdzOjpNTUFQX05PSVJROworICAgICAgICAgICAgcmV0dXJuIEF1ZGlvT3V0cHV0RmxhZ3M6Ok1NQVBfTk9JUlE7CiAgICAgICAgIGNhc2UgQVVESU9fT1VUUFVUX0ZMQUdfVk9JUF9SWDoKLSAgICAgICAgICAgIHJldHVybiBtZWRpYTo6QXVkaW9PdXRwdXRGbGFnczo6Vk9JUF9SWDsKKyAgICAgICAgICAgIHJldHVybiBBdWRpb091dHB1dEZsYWdzOjpWT0lQX1JYOwogICAgICAgICBjYXNlIEFVRElPX09VVFBVVF9GTEFHX0lOQ0FMTF9NVVNJQzoKLSAgICAgICAgICAgIHJldHVybiBtZWRpYTo6QXVkaW9PdXRwdXRGbGFnczo6SU5D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GwybGVnYWN5X2ludDMyX3RfYXVkaW9faW5wdXRfZmxhZ3NfdF9tYXNrKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZBTFVFX09SX1JFVFVSTihVTklPTl9HRVQoYWlkbCwgaW5wdXQpKSkpOwotICAgICAgICB9Ci0gICAgICAgICAgICBicmVhazsKLQotICAgICAgICBjYXNlIERpcmVjdGlvbjo6T1VUUFVUOiB7Ci0gICAgICAgICAgICBsZWdhY3kub3V0cHV0ID0gVkFMVUVfT1JfUkVUVVJOKAotICAgICAgICAgICAgICAgICAgICBhaWRsMmxlZ2FjeV9pbnQzMl90X2F1ZGlvX291dHB1dF9mbGFnc190X21hc2soCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgVkFMVUVfT1JfUkVUVVJOKFVOSU9OX0dFVChhaWRsLCBvdXRwdXQpKSkpOwotICAgICAgICB9Ci0gICAgICAgICAgICBicmVhazsKKyAgICBpZiAoaXNJbnB1dCkgeworICAgICAgICBsZWdhY3kuaW5wdXQgPSBWQUxVRV9PUl9SRVRVUk4oCisgICAgICAgICAgICAgICAgYWlkbDJsZWdhY3lfaW50MzJfdF9hdWRpb19pbnB1dF9mbGFnc190X21hc2soCisgICAgICAgICAgICAgICAgICAgICAgICBWQUxVRV9PUl9SRVRVUk4oVU5JT05fR0VUKGFpZGwsIGlucHV0KSkpKTsKKyAgICB9IGVsc2UgeworICAgICAgICBsZWdhY3kub3V0cHV0ID0gVkFMVUVfT1JfUkVUVVJOKAorICAgICAgICAgICAgICAgIGFpZGwybGVnYWN5X2ludDMyX3RfYXVkaW9fb3V0cHV0X2ZsYWdzX3RfbWFzaygKKyAgICAgICAgICAgICAgICAgICAgICAgIFZBTFVFX09SX1JFVFVSTihVTklPTl9HRVQoYWlkbCwgb3V0cHV0KSkpKTsKICAgICB9Ci0KICAgICByZXR1cm4gbGVnYWN5OwogfQogCi1Db252ZXJzaW9uUmVzdWx0PG1lZGlhOjpBdWRpb0lvRmxhZ3M+IGxlZ2Fje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ybiBsZWdhY3k7CiAgICAgICAgIGNhc2UgbWVkaWE6OkF1ZGlvUG9ydFR5cGU6OkRFVklDRToKICAgICAgICAgICAgIGxlZ2FjeS5kZXZpY2UgPSBWQUxVRV9PUl9SRVRVUk4oCi0gICAgICAgICAgICAgICAgICAgIGFpZGwybGVnYWN5X0F1ZGlvUG9ydENvbmZpZ0RldmljZUV4dF9hdWRpb19wb3J0X2NvbmZpZ19kZXZpY2VfZXh0KAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZBTFVFX09SX1JFVFVSTihVTklPTl9HRVQoYWlkbCwgZGV2aWNlKSkpKTsKKyAgICAgICAgICAgICAgICAgICAgYWlkbDJsZWdhY3lfQXVkaW9Qb3J0RGV2aWNlRXh0X2F1ZGlvX3BvcnRfY29uZmlnX2RldmljZV9leHQoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgVkFMVUVfT1JfUkVUVVJOKFVOSU9OX0dFVChhaWRsLCBkZXZpY2UpKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBWQUxVRV9PUl9SRVRVUk4oVU5JT05fR0VUKGFpZGxTeXMsIGRldmljZSkpKSk7CiAgICAgICAgICAgICByZXR1cm4gbGVnYWN5OwogICAgICAgICBjYXNlIG1lZGlhOjpBdWRpb1BvcnRUeXBlOjpNSVg6CiAgICAgICAgICAgICBsZWdhY3kubWl4ID0gVkFMVUVfT1JfUkVUVVJOKAotICAgICAgICAgICAgICAgICAgICBhaWRsMmxlZ2FjeV9BdWRpb1BvcnRDb25maWdNaXhFeHQoVkFMVUVfT1JfUkVUVVJOKFVOSU9OX0dFVChhaWRsLCBtaXgpKSwgcm9sZSkpOworICAgICAgICAgICAgICAgICAgICBhaWRsMmxlZ2FjeV9BdWRpb1BvcnRNaXhFeHQoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgVkFMVUVfT1JfUkVUVVJOKFVOSU9OX0dFVChhaWRsLCBtaXgpKSwgcm9sZSwKKyAgICAgICAgICAgICAgICAgICAg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hbHNlKTsKKyAgICAgICAgICAgIHJldHVybiBPSzsKKyAgICAgICAgY2FzZSBBVURJT19QT1JUX1RZUEVfREVWSUNFOiB7CisgICAgICAgICAgICBBdWRpb1BvcnREZXZpY2VFeHQgZGV2aWNlOworICAgICAgICAgICAgbWVkaWE6OkF1ZGlvUG9ydERldmljZUV4dFN5cyBkZXZpY2VTeXM7CisgICAgICAgICAgICBSRVRVUk5fU1RBVFVTX0lGX0VSUk9SKAorICAgICAgICAgICAgICAgICAgICBsZWdhY3kyYWlkbF9hdWRpb19wb3J0X2NvbmZpZ19kZXZpY2VfZXh0X0F1ZGlvUG9ydERldmljZUV4dCgKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZWdhY3kuZGV2aWNlLCAmZGV2aWNlLCAmZGV2aWNlU3lzKSk7CisgICAgICAgICAgICBVTklPTl9TRVQoKmFpZGwsIGRldmljZSwgZGV2aWNlKTsKKyAgICAgICAgICAgIFVOSU9OX1NFVCgqYWlkbFN5cywgZGV2aWNlLCBkZXZpY2VTeXMpOworICAgICAgICAgICAgcmV0dXJuIE9LOworICAgICAgICB9CisgICAgICAgIGNhc2UgQVVESU9fUE9SVF9UWVBFX01JWDogeworICAgICAgICAgICAgQXVkaW9Qb3J0TWl4RXh0IG1peDsKKyAgICAgICAgICAgIG1lZGlhOjpBdWRpb1BvcnRNaXhFeHRTeXMgbWl4U3lzOworICAgICAgICAgICAgUkVUVVJOX1NUQVRVU19JRl9FUlJPUihsZWdhY3kyYWlkbF9BdWRpb1BvcnRNaXhFeHQobGVnYWN5Lm1peCwgcm9sZSwgJm1peCwgJm1peFN5cykpOworICAgICAgICAgICAgVU5JT05fU0VUKCphaWRsLCBtaXgsIG1peCk7CisgICAgICAgICAgICBVTklPTl9TRVQoKmFpZGxTeXMsIG1peCwgbWl4U3lzKTsKKyAgICAgICAgICAgIHJldHVybiBPSzsKKyAgICAgICAgfQogICAgICAgICBjYXNlIEFVRElPX1BPUlRfVFlQRV9TRVNTSU9OOg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ZGlhOjpBdWRpb0NvbnRlbnRUeXBlIGFpZGwpIHsKK2FpZGwybGVnYWN5X0F1ZGlvQ29udGVudFR5cGVfYXVkaW9fY29udGVudF90eXBlX3QoQXVkaW9Db250ZW50VHlwZSBhaWRsKSB7CiAgICAgc3dpdGNoIChhaWRsKSB7Ci0gICAgICAgIGNhc2UgbWVkaWE6OkF1ZGlvQ29udGVudFR5cGU6OlVOS05PV046CisgICAgICAgIGNhc2UgQXVkaW9Db250ZW50VHlwZTo6VU5LTk9XTjoKICAgICAgICAgICAgIHJldHVybiBBVURJT19DT05URU5UX1RZUEVfVU5LTk9XTjsKLSAgICAgICAgY2FzZSBtZWRpYTo6QXVkaW9Db250ZW50VHlwZTo6U1BFRUNIOgorICAgICAgICBjYXNlIEF1ZGlvQ29udGVudFR5cGU6OlNQRUVDSDoKICAgICAgICAgICAgIHJldHVybiBBVURJT19DT05URU5UX1RZUEVfU1BFRUNIOwotICAgICAgICBjYXNlIG1lZGlhOjpBdWRpb0NvbnRlbnRUeXBlOjpNVVNJQzoKKyAgICAgICAgY2FzZSBBdWRpb0NvbnRlbnRUeXBlOjpNVVNJQzoKICAgICAgICAgICAgIHJldHVybiBBVURJT19DT05URU5UX1RZUEVfTVVTSUM7Ci0gICAgICAgIGNhc2UgbWVkaWE6OkF1ZGlvQ29udGVudFR5cGU6Ok1PVklFOgorICAgICAgICBjYXNlIEF1ZGlvQ29udGVudFR5cGU6Ok1PVklFOgogICAgICAgICAgICAgcmV0dXJuIEFVRElPX0NPTlRFTlRfVFlQRV9NT1ZJRTsKLSAgICAgICAgY2FzZSBtZWRpYTo6QXVkaW9Db250ZW50VHlwZTo6U09OSUZJQ0FUSU9OOgorICAgICAgICBjYXNlIEF1ZGlvQ29udGVudFR5cGU6OlNPTklGSUNBVElPTjoKICAgICAgICAgICAgIHJldHVybiBBVURJT19DT05URU5UX1RZUEVfU09OSUZJQ0FUSU9OOworICAgICAgICBjYXNlIEF1ZGlvQ29udGVudFR5cGU6OlVM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TFVFX09SX1JFVFVSTihsZWdhY3kyYWlkbF9hdWRpb19wb3J0X21peF9leHRfQXVkaW9Qb3J0TWl4RXh0KGxlZ2FjeS5taXgpKSk7Ci0gICAgICAgICAgICByZXR1cm4gYWlkbDsKKyAgICAgICAgICAgIFVOSU9OX1NFVCgqYWlkbCwgdW5zcGVjaWZpZWQsIGZhbHNlKTsKKyAgICAgICAgICAgIFVOSU9OX1NFVCgqYWlkbFN5cywgdW5zcGVjaWZpZWQsIGZhbHNlKTsKKyAgICAgICAgICAgIHJldHVybiBPSzsKKyAgICAgICAgY2FzZSBBVURJT19QT1JUX1RZUEVfREVWSUNFOiB7CisgICAgICAgICAgICBBdWRpb1BvcnREZXZpY2VFeHQgZGV2aWNlOworICAgICAgICAgICAgbWVkaWE6OkF1ZGlvUG9ydERldmljZUV4dFN5cyBkZXZpY2VTeXM7CisgICAgICAgICAgICBSRVRVUk5fU1RBVFVTX0lGX0VSUk9SKAorICAgICAgICAgICAgICAgICAgICBsZWdhY3kyYWlkbF9hdWRpb19wb3J0X2RldmljZV9leHRfQXVkaW9Qb3J0RGV2aWNlRXh0KAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlZ2FjeS5kZXZpY2UsICZkZXZpY2UsICZkZXZpY2VTeXMpKTsKKyAgICAgICAgICAgIFVOSU9OX1NFVCgqYWlkbCwgZGV2aWNlLCBkZXZpY2UpOworICAgICAgICAgICAgVU5JT05fU0VUKCphaWRsU3lzLCBkZXZpY2UsIGRldmljZVN5cyk7CisgICAgICAgICAgICByZXR1cm4gT0s7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBBVURJT19QT1JUX1RZUEVfTUlYOiB7CisgICAgICAgICAgICBBdWRpb1BvcnRNaXhFeHQgbWl4OworICAgICAgICAgICAgbWVkaWE6OkF1ZGlvUG9ydE1peEV4dFN5cyBtaXhTeXM7CisgICAgICAgICAgICBSRVRVUk5fU1RBVFVTX0lGX0VSUk9SKAorICAgICAgICAgICAgICAgICAgICBsZWdhY3kyYWlkbF9hdWRpb19wb3J0X21peF9leHRfQXVkaW9Qb3J0TWl4RXh0KAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlZ2FjeS5taXgsICZtaXgsICZtaXhTeXMpKTsKKyAgICAgICAgICAgIFVOSU9OX1NFVCgqYWlkbCwgbWl4LCBtaXgpOworICAgICAgICAgICAgVU5JT05fU0VUKCphaWRsU3lzLCBtaXgsIG1peFN5cyk7CisgICAgICAgICAgICByZXR1cm4gT0s7CisgICAgICAgIH0KICAgICAgICAgY2FzZSBBVURJT19QT1JUX1RZUEVfU0VTU0lPTjoKLSAgICAgICAgICAgIFVOSU9OX1NFVChhaWRsLCBzZXNzaW9uLAotICAgICAgICAgICAgICAgICAgICAgIFZBTFVFX09SX1JFVFVSTihsZWdhY3kyYWlkbF9hdWRpb19wb3J0X3Nlc3Npb25fZXh0X0F1ZGlvUG9ydFNlc3Npb25FeHQoCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZWdhY3kuc2Vzc2lvbikpKTsKLSAgICAgICAgICAgIHJldHVybiBhaWRsOworICAgICAgICAgICAgVU5JT05fU0VUKCphaWRsLCBzZXNzaW9uLCBWQUxVRV9PUl9SRVRVUk5fU1RBVFVTKAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlZ2FjeTJhaWRsX2F1ZGlvX3BvcnRfc2Vzc2lvbl9leHRfaW50MzJfdChsZWdhY3kuc2Vzc2lvbikpKTsKKyAgICAgICAgICAgIFVOSU9OX1NFVCgqYWlkbFN5cywgdW5zcGVjaWZpZWQsIGZhbHNlKTsKKyAgICAgICAgICAgIHJldHVybiBPSzsKICAgICB9CiAgICAgTE9HX0FMV0FZU19GQVRBTCgiU2hvdWxkbid0IGdldCBoZXJlIik7IC8vIHdpdGggLVdlcnJvciwtV3N3aXRjaCBtYXkgY29tcGlsZS10aW1lIGZhaWwKIH0KIAogQ29udmVyc2lvblJlc3VsdDxhdWRpb19wcm9maWxlPgotYWlkbDJsZWdh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9pZC5tZWRpYS5hdWRpby5jb21tb24udHlwZXMtVjEtY3BwIiwKICAgICAgICAgImF1ZGlvY2xpZW50LXR5cGVzLWFpZGwtY3BwIiwKICAgICAgICAgImF1ZGlvZmxpbmdlci1haWRsLWNwcCIsCiAgICAgICAgICJhdWRpb3BvbGljeS1haWRsLWNwcCIsCkBAIC0xMzQsOCArMTQxLDggQEAKICAgICAgICAgImxpYnByb2Nlc3Nncm91cCIsCiAgICAgICAgICJsaWJzaG1lbWNvbXBhdCIsCiAgICAgICAgICJsaWJ1dGlscyIsCi0gICAgICAgICJsaWJ2aWJyYXRvciIsCiAgICAgICAgICJmcmFtZXdvcmstcGVybWlzc2lvbi1haWRsLWNwcCIsCisgICAgICAgICJwYWNrYWdlbWFuYWdlcl9haWRsLWNwcCIsCiAgICAgXSwKICAgICBleHBvcnRfc2hhcmVkX2xpYl9oZWFkZXJzOiBbCiAgICAgICAgICJhdWRpb2ZsaW5nZXItYWlkbC1jcHAiLApAQCAtMTQzLDYgKzE1MCw3IEBACiAgICAgICAgICJzcGF0aWFsaXplci1haWRsLWNwcCIsCiAgICAgICAgICJmcmFtZXdvcmstcGVybWlzc2lvbi1haWRsLWNwcCIsCiAgICAgICAgICJsaWJiaW5kZXIiLAorICAgICAgICAibGlibWVkaWFtZXRyaWNzIiwKICAgICBdLAogCiAgICAgaW5jbHVkZV9kaXJzOiBbCkBAIC0xOTUsMTMgKzIwMywxNSBAQAogICAgIF0sCiAgICAgaGVhZGVyX2xpYnM6IFsKICAgICAgICAgImxpYmJhc2VfaGVhZGVycyIsCisgICAgICAgICJsaWJlcnJvcl9oZWFkZXJzIiwKICAgICBdLAogICAgIGV4cG9ydF9oZWFkZXJfbGliX2hlYWRlcnM6IFsKICAgICAgICAgImxpYmJhc2VfaGVhZGVycyIsCisgICAgICAgICJsaWJlcnJvcl9oZWFkZXJzIiwKICAgICBdLAogICAgIGFwZXhfYXZhaWxhYmxlOiBbCiAgICAgICAgICIvL2FwZXhfYXZhaWxhYmxlOnBsYXRmb3JtIiwKLSAgICAgICAgImNvbS5hbmRyb2lkLmJsdWV0b290aC51cGRhdGFibGUiLAorICAgICAgICAiY29tLmFuZHJvaWQuYmx1ZXRvb3RoIiwKICAgICAgICAgImNvbS5hbmRyb2lkLm1lZGlhIiwKICAgICAgICAgImNvbS5hbmRyb2lkLm1lZGlhLnN3Y29kZWMiLAogICAgIF0sCkBAIC0yMjgsMTYgKzIzOCwxOSBAQAogICAgICAgICAibGliYXVkaW9jbGllbnRfYWlkbF9jb252ZXJzaW9uX3V0aWwiLAogICAgIF0sCiAgICAgc2hhcmVkX2xpYnM6IFsKKyAgICAgICAgImFuZHJvaWQubWVkaWEuYXVkaW8uY29tbW9uLnR5cGVzLVYxLWNwcCIsCiAgICAgICAgICJhdWRpb2NsaWVudC10eXBlcy1haWRsLWNwcCIsCiAgICAgICAgICJsaWJiYXNlIiwKICAgICAgICAgImxpYmJpbmRlciIsCiAgICAgICAgICJsaWJsb2ciLAogICAgICAgICAibGlic2htZW1jb21wYXQiLAorICAgICAgICAibGlic3RhZ2VmcmlnaHRfZm91bmRhdGlvbiIsCiAgICAgICAgICJsaWJ1dGlscyIsCiAgICAgICAgICJzaGFyZWQtZmlsZS1yZWdpb24tYWlkbC1jcHAiLAogICAgICAgICAiZnJhbWV3b3JrLXBlcm1pc3Npb24tYWlkbC1jcHAiLAogICAgIF0sCiAgICAgZXhwb3J0X3NoYXJlZF9saWJfaGVhZGVyczogWworICAgICAgICAiYW5kcm9pZC5tZWRpYS5hdWRpby5jb21tb24udHlwZXMtVjEtY3BwIiwKICAgICAgICAgImF1ZGlvY2xpZW50LXR5cGVzLWFpZGwtY3BwIiwKICAgICAgICAgImxpYmJhc2UiLAogICAgICAgICAic2hhcmVkLWZpbGUtcmVnaW9uLWFpZGwtY3BwIiwKQEAgLTMwNyw1NyArMzIwLDMyIEBACiAgICAgc3JjczogWwogICAgICAgICAiYWlkbC9hbmRyb2lkL21lZGlhL0F1ZGlvQXR0cmlid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AgICAgICAgICAgXSwKICAgICAgICAgfSwKKyAgICAgICAgamF2YTogeworICAgICAgICAgICAgc2RrX3ZlcnNpb246ICJtb2R1bGVfY3VycmVudCIsCisgICAgICAgIH0sCiAgICAgfSwKIH0KIGFpZGxfaW50ZXJmYWNlIHsKQEAgLTM5OCw3ICszODksNyBAQAogICAgICAgICAiYWlkbC9hbmRyb2lkL21lZGlhL1NwYXRpYWxpemVySGVhZFRyYWNraW5nTW9kZS5haWRsIiwKICAgICBdLAogICAgIGltcG9ydHM6IFsKLSAgICAgICAgImF1ZGlvX2NvbW1vbi1haWRsIiwKKyAgICAgICAgImFuZHJvaWQubWVkaWEuYXVkaW8uY29tbW9uLnR5cGVzLVYxIiwKICAgICAgICAgImF1ZGlvY2xpZW50LXR5cGVzLWFpZGwiLAogICAgIF0sCiAgICAgYmFja2VuZDogewpAQCAtNDA5LDYgKzQwMCw5IEBACiAgICAgICAgICAgICAgICAgImNvbS5hbmRyb2lkLm1lZGlhIiwKICAgICAgICAgICAgIF0sCiAgICAgICAgIH0sCisgICAgICAgIGphdmE6IHsKKyAgICAgICAgICAgIHNka192ZXJzaW9uOiAibW9kdWxlX2N1cnJlbnQiLAorICAgICAgICB9LAogICAgIH0sCiB9CiAKQEAgLTQzOCw3ICs0MzIsNyBAQAogICAgICAgICAiYWlkbC9hbmRyb2lkL21lZGlhL0lBdWRpb1RyYWNrQ2FsbGJhY2suYWlkbCIsCiAgICAgXSwKICAgICBpbXBvcnRzOiBbCi0gICAgICAgICJhdWRpb19jb21tb24tYWlkbCIsCisgICAgICAgICJhbmRyb2lkLm1lZGlhLmF1ZGlvLmNvbW1vbi50eXBlcy1WMSIsCiAgICAgICAgICJhdWRpb2NsaWVudC10eXBlcy1haWRsIiwKICAgICAgICAgImF2LXR5cGVzLWFpZGwiLAogICAgICAgICAiZWZmZWN0LWFpZGwiLApAQCAtNDU0LDYgKzQ0OCw5IEBACiAgICAgICAgICAgICAgICAgImNvbS5hbmRyb2lkLm1lZGlhIiwKICAgICAgICAgICAgIF0sCiAgICAgICAgIH0sCisgICAgICAgIGphdmE6IHsKKyAgICAgICAgICAgIHNka192ZXJzaW9uOiAibW9kdWxlX2N1cnJlbnQiLAorICAgICAgICB9LAogICAgIH0sCiB9CiAKQEAgLTQ2NywxMyArNDY0LDEyIEBACiAgICAgICAgICJhaWRsL2FuZHJvaWQvbWVkaWEvR2V0SW5wdXRGb3JBdHRyUmVzcG9uc2UuYWlkbCIsCiAgICAgICAgICJhaWRsL2FuZHJvaWQvbWVkaWEvR2V0T3V0cHV0Rm9yQXR0clJlc3BvbnNlLmFpZGwiLAogICAgICAgICAiYWlkbC9hbmRyb2lkL21lZGlhL0dldFNwYXRpYWxpemVyUmVzcG9uc2UuYWlkbCIsCi0gICAgICAgICJhaWRsL2FuZHJvaWQvbWVkaWEvSW50LmFpZGwiLAogICAgICAgICAiYWlkbC9hbmRyb2lkL21lZGlhL1JlY29yZENsaWVudEluZm8uYWlkbCIsCiAgICAgICAgICJhaWRsL2FuZHJvaWQvbWVkaWEvSUF1ZGlvUG9saWN5U2VydmljZS5haWRsIiwKICAgICAgICAgImFpZGwvYW5kcm9pZC9tZWRpYS9JQXVkaW9Qb2xpY3lTZXJ2aWNlQ2xpZW50LmFpZGwiLAogICAgIF0sCiAgICAgaW1wb3J0czogWwotICAgICAgICAiYXVkaW9fY29tbW9uLWFpZGwiLAorICAgICAgICAiYW5kcm9pZC5tZWRpYS5hdWRpby5jb21tb24udHlwZXMtVjEiLAogICAgICAgICAiYXVkaW9jbGllbnQtdHlwZXMtYWlkbCIsCiAgICAgICAgICJhdWRpb3BvbGljeS10eXBlcy1haWRsIiwKICAgICAgICAgImNhcHR1cmVfc3RhdGVfbGlzdGVuZXItYWlkbCIsCkBAIC00OTAsNiArNDg2LDkgQEAKICAgICAgICAgICAgICAgICAiY29tLmFuZHJvaWQubWVkaWEiLAogICAgICAgICAgICAgXSwKICAgICAgICAgfSwKKyAgICAgICAgamF2YTogeworICAgICAgICAgICAg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b19oYW5kbGVfdCBpbywKKyAgICAgICAgICAgICAgICBjb25zdCBBdWRpb0RldmljZVR5cGVBZGRyJiBkZXZpY2UsCisgICAgICAgICAgICAgICAgYm9vbCBwcm9iZSwKKyAgICAgICAgICAgICAgICBib29sIG5vdGlmeUZyYW1lc1Byb2Nlc3NlZCkKK3sKKyAgICBpZiAoY2JmICE9IG51bGxwdHIpIHsKKyAgICAgICAgbUxlZ2FjeVdyYXBwZXIgPSBzcDxMZWdhY3lDYWxsYmFja1dyYXBwZXI+OjptYWtlKGNiZiwgdXNlcik7CisgICAgfSBlbHNlIGlmICh1c2VyICE9IG51bGxwdHIpIHsKKyAgICAgICAgTE9HX0FMV0FZU19GQVRBTCgiJXM6IFVzZXIgcHJvdmlkZWQgd2l0aG91dCBjYWxsYmFjayIsIF9fZnVuY19fKTsKKyAgICB9CisgICAgcmV0dXJuIHNldCh0eXBlLCB1dWlkLCBwcmlvcml0eSwgbUxlZ2FjeVdyYXBwZXIsIHNlc3Npb25JZCwgaW8sIGRldmljZSwgcHJvYmUsCisgICAgICAgICAgICAgICBub3RpZnlGcmFtZXNQcm9jZXNzZWQpOworfQogc3RhdHVzX3QgQXVkaW9FZmZlY3Q6OnNldChjb25zdCBjaGFyICp0eXBlU3RyLAogICAgICAgICAgICAgICAgIGNvbnN0IGNoYXIgKnV1aWRTdHIsCiAgICAgICAgICAgICAgICAgaW50MzJfdCBwcmlvcml0eSwKLSAgICAgICAgICAgICAgICBlZmZlY3RfY2FsbGJhY2tfdCBjYmYsCi0gICAgICAgICAgICAgICAgdm9pZCogdXNlciwKKyAgICAgICAgICAgICAgICBjb25zdCB3cDxJQXVkaW9FZmZlY3RDYWxsYmFjaz4mIGNhbGxiYWNrLAogICAgICAgICAgICAgICAgIGF1ZGlvX3Nlc3Npb25fdCBzZXNzaW9uSWQsCiAgICAgICAgICAgICAgICAgYXVkaW9faW9faGFuZGxlX3QgaW8sCiAgICAgICAgICAgICAgICAgY29uc3QgQXVkaW9EZXZpY2VUeXBlQWRkciYgZGV2aWNlLApAQCAtMjE0LDExICsyNjAsMjkgQEAKICAgICAgICAgcFV1aWQgPSAmdXVpZDsKICAgICB9CiAKLSAgICByZXR1cm4gc2V0KHBUeXBlLCBwVXVpZCwgcHJpb3JpdHksIGNiZiwgdXNlciwgc2Vzc2lvbklkLCBpbywKKyAgICByZXR1cm4gc2V0KHBUeXBlLCBwVXVpZCwgcHJpb3JpdHksIGNhbGxiYWNrLCBzZXNzaW9uSWQsIGlvLAogICAgICAgICAgICAgICAgZGV2aWNlLCBwcm9iZSwgbm90aWZ5RnJhbWVzUHJvY2Vzc2VkKTsKIH0KIAotCitzdGF0dXNfdCBBdWRpb0VmZmVjdDo6c2V0KGNvbnN0IGNoYXIgKnR5cGVTdHIsCisgICAgICAgICAgICAgICAgY29uc3QgY2hhciAqdXVpZFN0ciwKKyAgICAgICAgICAgICAgICBpbnQzMl90IHByaW9yaXR5LAorICAgICAgICAgICAgICAgIGxlZ2FjeV9jYWxsYmFja190IGNiZiwKKyAgICAgICAgICAgICAgICB2b2lkKiB1c2VyLAorICAgICAgICAgICAgICAgIGF1ZGlvX3Nlc3Npb25fdCBzZXNzaW9uSWQsCisgICAgICAgICAgICAgICAgYXVkaW9faW9faGFuZGxlX3QgaW8sCisgICAgICAgICAgICAgICAgY29uc3QgQXVkaW9EZXZpY2VUeXBlQWRkciYgZGV2aWNlLAorICAgICAgICAgICAgICAgIGJvb2wgcHJvYmUsCisgICAgICAgICAgICAgICAgYm9vbCBub3RpZnlGcmFtZXNQcm9jZXNzZWQpCit7CisgICAgaWYgKGNiZiAhPSBudWxscHRyKSB7CisgICAgICAgIG1MZWdhY3lXcmFwcGVyID0gc3A8TGVnYWN5Q2FsbGJhY2tXcmFwcGVyPjo6bWFrZShjYmYsIHVzZXIpOworICAgIH0gZWxzZSBpZiAodXNlciAhPSBudWxscHRyKSB7CisgICAgICAgIExPR19BTFdBWVNfRkFUQUwoIiVzOiBVc2VyIHByb3ZpZGVkIHdp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dFNvdXJjZSwKKyAgICAgICAgdWludDMyX3Qgc2FtcGxlUmF0ZSwKKyAgICAgICAgYXVkaW9fZm9ybWF0X3QgZm9ybWF0LAorICAgICAgICBhdWRpb19jaGFubmVsX21hc2tfdCBjaGFubmVsTWFzaywKKyAgICAgICAgc2l6ZV90IGZyYW1lQ291bnQsCisgICAgICAgIGxlZ2FjeV9jYWxsYmFja190IGNhbGxiYWNrLAorICAgICAgICB2b2lkKiB1c2VyLAorICAgICAgICB1aW50MzJfdCBub3RpZmljYXRpb25GcmFtZXMsCisgICAgICAgIGJvb2wgdGhyZWFkQ2FuQ2FsbEphdmEsCisgICAgICAgIGF1ZGlvX3Nlc3Npb25fdCBzZXNzaW9uSWQsCisgICAgICAgIHRyYW5zZmVyX3R5cGUgdHJhbnNmZXJUeXBlLAorICAgICAgICBhdWRpb19pbnB1dF9mbGFnc190IGZsYWdzLAorICAgICAgICB1aWRfdCB1aWQsCisgICAgICAgIHBpZF90IHBpZCwKKyAgICAgICAgY29uc3QgYXVkaW9fYXR0cmlidXRlc190KiBwQXR0cmlidXRlcywKKyAgICAgICAgYXVkaW9fcG9ydF9oYW5kbGVfdCBzZWxlY3RlZERldmljZUlkLAorICAgICAgICBhdWRpb19taWNyb3Bob25lX2RpcmVjdGlvbl90IHNlbGVjdGVkTWljRGlyZWN0aW9uLAorICAgICAgICBmbG9hdCBtaWNyb3Bob25lRmllbGREaW1lbnNpb24sCisgICAgICAgIGludDMyX3QgbWF4U2hhcmVkQXVkaW9IaXN0b3J5TXMpCit7CisgICAgaWYgKGNhbGxiYWNrICE9IG51bGxwdHIpIHsKKyAgICAgICAgbUxlZ2FjeUNhbGxiYWNrV3JhcHBlciA9IHNwPExlZ2FjeUNhbGxiYWNrV3JhcHBlcj46Om1ha2UoY2FsbGJhY2ssIHVzZXIpOworICAgIH0gZWxzZSBpZiAodXNlcikgeworICAgICAgICBMT0dfQUxXQVlTX0ZBVEFMKCJDYWxsYmFjayBkYXRhIHByb3ZpZGVk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lcyglZCk6IENvdWxkIG5vdCBnZXQgY29udHJvbCBibG9jayIsIF9fZnVuY19fLCBtUG9ydElkKTsKKyAgICAgICAgZXJyb3JNZXNzYWdlID0gU3RyaW5nUHJpbnRmKCIlcyglZCk6IENvdWxkIG5vdCBnZXQgY29udHJvbCBibG9jayIsIF9fZnVuY19fLCBtUG9ydElkKTsKICAgICAgICAgc3RhdHVzID0gTk9fSU5JVDsKICAgICAgICAgZ290byBleGl0OwogICAgIH0KQEAgLTg2OCw3ICs5ODUsOCBAQAogICAgIC8vICAgICAgIGlzc3VlIChlLmcuIGJ5IGNvcHlpbmcpLgogICAgIGlNZW1Qb2ludGVyID0gb3V0cHV0LmNibGsgLT51bnNlY3VyZVBvaW50ZXIoKTsKICAgICBpZiAoaU1lbVBvaW50ZXIgPT0gTlVMTCkgewotICAgICAgICBBTE9HRSgiJXMoJWQpOiBDb3VsZCBub3QgZ2V0IGNvbnRyb2wgYmxvY2sgcG9pbnRlciIsIF9fZnVuY19fLCBtUG9ydElkKTsKKyAgICAgICAgZXJyb3JNZXNzYWdlID0gU3RyaW5nUHJpbnRmKAorICAgICAgICAgICAgICAgICIlcyglZCk6IENvdWxkIG5vdCBnZXQgY29udHJvbCBibG9jayBwb2ludGVyIiwgX19mdW5jX18sIG1Qb3J0SWQpOwogICAgICAgICBzdGF0dXMgPSBOT19JTklUOwogICAgICAgICBnb3RvIGV4aXQ7CiAgICAgfQpAQCAtODg3LDcgKzEwMDUsOCBAQAogICAgICAgICAvLyAgICAgICBpc3N1ZSAoZS5nLiBieSBjb3B5aW5nKS4KICAgICAgICAgYnVmZmVycyA9IG91dHB1dC5idWZmZXJzLT51bnNlY3VyZVBvaW50ZXIoKTsKICAgICAgICAgaWYgKGJ1ZmZlcnMgPT0gTlVMTCkgewotICAgICAgICAgICAgQUxPR0UoIiVzKCVkKTogQ291bGQgbm90IGdldCBidWZmZXIgcG9pbnRlciIsIF9fZnVuY19fLCBtUG9ydElkKTsKKyAgICAgICAgICAgI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SSUNTX1BST1BfRlJBTUVDT1VOVCwgKGludDMyX3QpbUZyYW1lQ291bnQpCisgICAgICAgIC5zZXQoQU1FRElBTUVUUklDU19QUk9QX1NBTVBMRVJBVEUsIChpbnQzMl90KW1TYW1wbGVSYXRlKQorICAgICAgICAucmVjb3JkKCk7Cit9CisKIHN0YXR1c190IEF1ZGlvUmVjb3JkOjpvYnRhaW5CdWZmZXIoQnVmZmVyKiBhdWRpb0J1ZmZlciwgaW50MzJfdCB3YWl0Q291bnQsIHNpemVfdCAqbm9uQ29udGlnKQogewogICAgIGlmIChhdWRpb0J1ZmZlciA9PSBOVUxMKSB7CkBAIC05OTMsNyArMTE0Myw3IEBACiAgICAgfQogICAgIGlmIChtVHJhbnNmZXIgIT0gVFJBTlNGRVJfT0JUQUlOKSB7CiAgICAgICAgIGF1ZGlvQnVmZmVyLT5mcmFtZUNvdW50ID0gMDsKLSAgICAgICAgYXVkaW9CdWZmZXItPnNpemUgPSAwOworICAgICAgICBhdWRpb0J1ZmZlci0+bVNpemUgPSAwOwogICAgICAgICBhdWRpb0J1ZmZlci0+cmF3ID0gTlVMTDsKICAgICAgICAgaWYgKG5vbkNvbnRpZyAhPSBOVUxMKSB7CiAgICAgICAgICAgICAqbm9uQ29udGlnID0gMDsKQEAgLTEwNDYsNyArMTE5NiwxMyBAQAogICAgICAgICAgICAgaWYgKHN0YXR1cyA9PSBERUFEX09CSkVDVCkgewogICAgICAgICAgICAgICAgIC8vIHJlLWNyZWF0ZSB0cmFjaywgdW5sZXNzIHNvbWVvbmUgZWxzZSBoYXMgYWxyZWFkeSBkb25lIHNvCiAgICAgICAgICAgICAgICAgaWYgKG5ld1NlcXVlbmNlID09IG9sZFNlcXVlbmNlKSB7Ci0gICAgICAgICAgICAgICAgICAgIHN0YXR1cyA9IHJlc3RvcmVSZWNvcmRfbCgib2J0YWluQnVmZmVyIik7CisgICAgICAgICAgICAgICAgICAgIGlmICghYXVkaW9faXNfbGluZWFyX3BjbShtRm9ybWF0KSkgeworICAgICAgICAgICAgICAgICAgICAgICAgLy8gSWYgY29tcHJlc3NlZCBjYXB0dXJlLCBkb24ndCBhdHRlbXB0IHRvIHJlc3RvcmUgdGhlIHRyYWNrLgorICAgICAgICAgICAgICAgICAgICAgICAgLy8gUmV0dXJuIGEgREVBRF9PQkpFQ1QgZXJyb3IgYW5kIGxldCB0aGUgY2FsbGVyIHJlY3JlYXRlLgorICAgICAgICAgICAgICAgICAgICAgICAgdHJ5Q291bnRlciA9IDA7CisgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXMgPSByZXN0b3JlUmVjb3JkX2woIm9idGFpbkJ1ZmZlciIpOworICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0dXMgIT0gTk9fRVJST1IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIGJ1ZmZlci5tRnJhbWVDb3VudCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICBidWZmZXIubVJhdyA9IE5VTEw7CkBAIC0xMDc2LDcgKzEyMzIsNyBAQAogICAgIH0gd2hpbGUgKChzdGF0dXMgPT0gREVBRF9PQkpFQ1QpICYmICh0cnlDb3VudGVyLS0gPiAwKSk7CiAKICAgICBhdWRpb0J1ZmZlci0+ZnJhbWVDb3VudCA9IGJ1ZmZlci5tRnJhbWVDb3VudDsKLSAgICBhdWRpb0J1ZmZlci0+c2l6ZSA9IGJ1ZmZlci5tRnJhbWVDb3VudCAqIG1GcmFtZVNpemU7CisgICAgYXVkaW9CdWZmZXItPm1TaXplID0gYnVmZmVyLm1GcmFtZUNvdW50ICogbVNlcnZlckZyYW1lU2l6ZTsKICAgICBhdWRpb0J1ZmZlci0+cmF3ID0gYnVmZmVyLm1SYXc7CiAgICAgYXVkaW9CdWZmZXItPnNlcXVlbmNlID0gb2xkU2VxdWVuY2U7CiAgICAgaWYgKG5vbkNvbnRpZyAhPSBOVUxMKSB7CkBAI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T5tSW9IYW5kbGUpOworICAgICAgICAgICAgICAgICAgICAgICAgYXV0byBpdCA9IG1BdWRpb0RldmljZUNhbGxiYWNrcy5maW5kKGlvRGVzYy0+Z2V0SW9IYW5kbGUoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXQgIT0gbUF1ZGlvRGV2aWNlQ2FsbGJhY2tzLmVuZCgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2tzID0gaXQtPnNlY29uZDsKICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBBTE9HVigiaW9Db25maWdDaGFuZ2VkKCkgbmV3ICVzICVzICVkIHNhbXBsaW5nUmF0ZSAldSwgZm9ybWF0ICUjeCBjaGFubmVsIG1hc2sgJSN4ICIKLSAgICAgICAgICAgICAgICAgICAgICAiZnJhbWVDb3VudCAlenUgZGV2aWNlSWQgJWQiLAorICAgICAgICAgICAgICAgIEFMT0dWKCJpb0NvbmZpZ0NoYW5nZWQoKSBuZXcgJXMgJXMgJXMiLAogICAgICAgICAgICAgICAgICAgICAgIGV2ZW50ID09IEFVRElPX09VVFBVVF9PUEVORUQgfHwgZXZlbnQgPT0gQVVESU9fT1VUUFVUX1JFR0lTVEVSRUQgPwogICAgICAgICAgICAgICAgICAgICAgICJvdXRwdXQiIDogImlucHV0IiwKICAgICAgICAgICAgICAgICAgICAgICBldmVudCA9PSBBVURJT19PVVRQVVRfT1BFTkVEIHx8IGV2ZW50ID09IEFVRElPX0lOUFVUX09QRU5FRCA/CiAgICAgICAgICAgICAgICAgICAgICAgIm9wZW5lZCIgOiAicmVnaXN0ZXJlZCIsCi0gICAgICAgICAgICAgICAgICAgICAgaW9EZXNjLT5tSW9IYW5kbGUsIGlvRGVzYy0+bVNhbXBsaW5nUmF0ZSwgaW9EZXNjLT5tRm9ybWF0LAotICAgICAgICAgICAgICAgICAgICAgIGlvRGVzYy0+bUNoYW5uZWxNYXNrLAotICAgICAgICAgICAgICAgICAgICAgIGlvRGVzYy0+bUZyYW1lQ291bnQsIGlvRGVzYy0+Z2V0RGV2aWNlSWQoKSk7CisgICAgICAgICAgICAgICAgICAgICAgaW9EZXNjLT50b0RlYnVnU3RyaW5nKCkuY19zdHIoKSk7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICBjYXNlIEFVRElPX09VVFBVVF9DTE9TRUQ6CiAgICAgICAgICAgICBjYXNlIEFVRElPX0lOUFVUX0NMT1NFRDogewotICAgICAgICAgICAgICAgIGlmIChnZXRJb0Rlc2NyaXB0b3JfbChpb0Rlc2MtPm1Jb0hhbmRsZSkgPT0gMCkgeworICAgICAgICAgICAgICAgIGlmIChnZXRJb0Rlc2NyaXB0b3JfbChpb0Rlc2MtPmdldElvSGFuZGxlKCkpID09IDApIHsKICAgICAgICAgICAgICAgICAgICAgQUxPR1coImlvQ29uZmlnQ2hhbmdlZCgpIGNsb3NpbmcgdW5rbm93biAlcyAlZCIsCi0gICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50ID09IEFVRElPX09VVFBVVF9DTE9TRUQgPyAib3V0cHV0IiA6ICJpbnB1dCIsIGlvRGVzYy0+bUlvSGFuZGxlKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQgPT0gQVVESU9fT1VUUFVUX0NMT1NFRCA/ICJvdXRwdXQiIDogImlucHV0IiwgaW9EZXNjLT5nZXRJb0hhbmRsZSgpKTsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIEFMT0dWKCJpb0NvbmZpZ0NoYW5nZWQoKSAlcyAlZCBjbG9zZWQiLAotICAgICAgICAgICAgICAgICAgICAgIGV2ZW50ID09IEFVRElPX09VVFBVVF9DTE9TRUQgPyAib3V0cHV0IiA6ICJpbnB1dCIsIGlvRGVzYy0+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VURJT19PVVRQVVRfQ09ORklHX0NIQU5HRUQgPyAib3V0cHV0IiA6ICJpbnB1dCIsCi0gICAgICAgICAgICAgICAgICAgICAgICAgIGlvRGVzYy0+bUlvSGFuZGxlKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgaW9EZXNjLT5nZXRJb0hhbmRsZSgpKTsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgZGV2aWNlSWQgPSBvbGREZXNjLT5nZXREZXZpY2VJZCgpOwotICAgICAgICAgICAgICAgIG1Jb0Rlc2NyaXB0b3JzLnJlcGxhY2VWYWx1ZUZvcihpb0Rlc2MtPm1Jb0hhbmRsZSwgaW9EZXNjKTsKKyAgICAgICAgICAgICAgICBtSW9EZXNjcmlwdG9ycy5yZXBsYWNlVmFsdWVGb3IoaW9EZXNjLT5nZXRJb0hhbmRsZSgpLCBpb0Rlc2MpOwogCiAgICAgICAgICAgICAgICAgaWYgKGRldmljZUlkICE9IGlvRGVzYy0+Z2V0RGV2aWNlSWQoKSkgewogICAgICAgICAgICAgICAgICAgICBkZXZpY2VJZCA9IGlvRGVzYy0+Z2V0RGV2aWNlSWQoKTsKLSAgICAgICAgICAgICAgICAgICAgYXV0byBpdCA9IG1BdWRpb0RldmljZUNhbGxiYWNrcy5maW5kKGlvRGVzYy0+bUlvSGFuZGxlKTsKKyAgICAgICAgICAgICAgICAgICAgYXV0byBpdCA9IG1BdWRpb0RldmljZUNhbGxiYWNrcy5maW5kKGlvRGVzYy0+Z2V0SW9IYW5kbGUoKSk7CiAgICAgICAgICAgICAgICAgICAgIGlmIChpdCAhPSBtQXVkaW9EZXZpY2VDYWxsYmFja3MuZW5kKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrcyA9IGl0LT5zZWNvbmQ7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgQUxP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GxlKCkpOwogICAgICAgICAgICAgICAgIGlmIChvbGREZXNjID09IDApIHsKLSAgICAgICAgICAgICAgICAgICAgQUxPR1coImlvQ29uZmlnQ2hhbmdlZCgpIHN0YXJ0IGNsaWVudCBvbiB1bmtub3duIGlvISAlZCIsIGlvRGVzYy0+bUlvSGFuZGxlKTsKKyAgICAgICAgICAgICAgICAgICAgQUxPR1coImlvQ29uZmlnQ2hhbmdlZCgpIHN0YXJ0IGNsaWVudCBvbiB1bmtub3duIGlvISAlZCIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW9EZXNjLT5nZXRJb0hhbmRsZSgpKTsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIEFMT0dWKCJpb0NvbmZpZ0NoYW5nZWQoKSBBVURJT19DTElFTlRfU1RBUlRFRCAgaW8gJWQgcG9ydCAlZCBudW0gY2FsbGJhY2tzICV6dSIsCi0gICAgICAgICAgICAgICAgICAgICAgaW9EZXNjLT5tSW9IYW5kbGUsIGlvRGVzYy0+bVBvcnRJZCwgbUF1ZGlvRGV2aWNlQ2FsbGJhY2tzLnNpemUoKSk7Ci0gICAgICAgICAgICAgICAgb2xkRGVzYy0+bVBhdGNoID0gaW9EZXNjLT5tUGF0Y2g7Ci0gICAgICAgICAgICAgICAgYXV0byBpdCA9IG1BdWRpb0RldmljZUNhbGxiYWNrcy5maW5kKGlvRGVzYy0+bUlvSGFuZGxlKTsKKyAgICAgICAgICAgICAgICAgICAgICBpb0Rlc2MtPmdldElvSGFuZGxlKCksIGlvRGVzYy0+Z2V0UG9ydElkKCksIG1BdWRpb0RldmljZUNhbGxiYWNrcy5zaXplKCkpOworICAgICAgICAgICAgICAgIG9sZERlc2MtPnNldFBhdGNoKGlvRGVzYy0+Z2V0UGF0Y2goKSk7CisgICAgICAgICAgICAgICAgYXV0byBpdCA9IG1BdWRpb0RldmljZUNhbGxiYWNrcy5maW5kKGlvRGVzYy0+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0ZW06OmdldF9hdWRpb19wb2xpY3lfc2VydmljZSgpOwotICAgIGNvbnN0IGNoYXIqIGFkZHJlc3MgPSAiIjsKLSAgICBjb25zdCBjaGFyKiBuYW1lID0gIiI7CiAKICAgICBpZiAoYXBzID09IDApIHJldHVybiBQRVJNSVNTSU9OX0RFTklFRDsKIAotICAgIGlmIChkZXZpY2VfYWRkcmVzcyAhPSBOVUxMKSB7Ci0gICAgICAgIGFkZHJlc3MgPSBkZXZpY2VfYWRkcmVzczsKLSAgICB9Ci0gICAgaWYgKGRldmljZV9uYW1lICE9IE5VTEwpIHsKLSAgICAgICAgbmFtZSA9IGRldmljZV9uYW1lOwotICAgIH0KLQotICAgIG1lZGlhOjpBdWRpb0RldmljZSBkZXZpY2VBaWRsOwotICAgIGRldmljZUFpZGwudHlwZSA9IFZBTFVFX09SX1JFVFVSTl9TVEFUVVMobGVnYWN5MmFpZGxfYXVkaW9fZGV2aWNlc190X2ludDMyX3QoZGV2aWNlKSk7Ci0gICAgZGV2aWNlQWlkbC5hZGRyZXNzID0gYWRkcmVzczsKLQogICAgIHJldHVybiBzdGF0dXNURnJvbUJpbmRlclN0YXR1cygKICAgICAgICAgICAgIGFwcy0+c2V0RGV2aWNlQ29ubmVjdGlvblN0YXRlKAotICAgICAgICAgICAgICAgICAgICBkZXZpY2VBaWRsLAogICAgICAgICAgICAgICAgICAgICBWQUxVRV9PUl9SRVRVUk5fU1RBVFVTKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlZ2FjeTJhaWRsX2F1ZGlvX3BvbGljeV9kZXZfc3RhdGVfdF9BdWRpb1BvbGljeURldmljZVN0YXRlKHN0YXRlKSksCi0gICAgICAgICAgICAgICAgICAgIG5hbWUsCi0gICAgICAgICAgICAgICAgICAgIFZBTFVFX09SX1JFVFVSTl9TVEFUVVMobGVnYWN5MmFpZGxfYXVkaW9fZm9ybWF0X3RfQXVkaW9Gb3JtYXQoZW5jb2RlZEZvcm1hdCkpKSk7CisgICAgICAgIC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VsdDxhdWRpb19pb19oYW5kbGVfdD4gewotICAgICAgICBtZWRpYTo6QXVkaW9TdHJlYW1UeXBlIHN0cmVhbUFpZGwgPSBWQUxVRV9PUl9SRVRVUk4oCisgICAgICAgIEF1ZGlvU3RyZWFtVHlwZSBzdHJlYW1BaWRsID0gVkFMVUVfT1JfUkVUVVJOKAogICAgICAgICAgICAgICAgIGxlZ2FjeTJhaWRsX2F1ZGlvX3N0cmVhbV90eXBlX3RfQXVkaW9TdHJlYW1UeXBlKHN0cmVhbSkpOwogICAgICAgICBpbnQzMl90IG91dHB1dEFpZGw7CiAgICAgICAgIFJFVFVSTl9JRl9FUlJPUigKQEAgLTk3NSw3ICs5NzAsOCBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fb3V0cHV0X2ZsYWdzX3QgZmxhZ3MsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19wb3J0X2hhbmRsZV90KiBzZWxlY3RlZERldmljZUlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fcG9ydF9oYW5kbGVfdCogcG9ydElkLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RkOjp2ZWN0b3I8YXVkaW9faW9faGFuZGxlX3Q+KiBzZWNvbmRhcnlPdXRwdXRzKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGQ6OnZlY3RvcjxhdWRpb19pb19oYW5kbGVfdD4qIHNlY29uZGFyeU91dHB1dHMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sICppc1NwYXRpYWxpemVkKSB7CiAgICAgaWYgKGF0dHIgPT0gbnVsbHB0cikgewogICAgICAgICBBTE9HRSgiJXMgTlVMTCBhdWRpbyBhdHRyaWJ1dGVzIiwgX19mdW5jX18pOwogICAgICAgICByZXR1cm4gQkFEX1ZBTFVFOwpAQCAtMT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X1JFVFVSTigKLSAgICAgICAgICAgICAgICBsZWdhY3kyYWlkbF9hdWRpb19zdHJlYW1fdHlwZV90X0F1ZGlvU3RyZWFtVHlwZShzdHJlYW0pKTsKLSAgICAgICAgaW50MzJfdCByZXN1bHRBaWRsOwotICAgICAgICBSRVRVUk5fSUZfRVJST1Ioc3RhdHVzVEZyb21CaW5kZXJTdGF0dXMoCi0gICAgICAgICAgICAgICAgYXBzLT5nZXREZXZpY2VzRm9yU3RyZWFtKHN0cmVhbUFpZGwsICZyZXN1bHRBaWRsKSkpOwotICAgICAgICByZXR1cm4gYWlkbDJsZWdhY3lfaW50MzJfdF9hdWRpb19kZXZpY2VzX3QocmVzdWx0QWlkbCk7Ci0gICAgfSgpOwotICAgIHJldHVybiByZXN1bHQudmFsdWVfb3IoQVVESU9fREVWSUNFX05PTkUpOwotfQotCiBzdGF0dXNfdCBBdWRpb1N5c3RlbTo6Z2V0RGV2aWNlc0ZvckF0dHJpYnV0ZXMoY29uc3QgQXVkaW9BdHRyaWJ1dGVzJiBhYSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBdWRpb0RldmljZVR5cGVBZGRyVmVjdG9yKiBkZXZpY2VzKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQXVkaW9EZXZpY2VUeXBlQWRkclZlY3RvciogZGV2aWNlcywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIGZvclZvbHVtZSkgewogICAgIGlmIChkZXZpY2VzID09IG51bGxwdHIpIHsKICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKICAgICB9CkBAIC0xMjkwLDkgKzEyODQsOSBAQAogCiAgICAgbWVkaWE6OkF1ZGlvQXR0cmlidXRlc0V4IGFhQWlkbCA9IFZBTFVFX09SX1JFVFVSTl9TVEFUVVMoCiAgICAgICAgICAgICBsZWdhY3kyYWlkbF9BdWRpb0F0dHJp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U1RBVFVTKAotICAgICAgICAgICAgY29udmVydENvbnRhaW5lcjxzdGQ6OnZlY3RvcjxtZWRpYTo6QXVkaW9EZXZpY2U+PihkZXZpY2VzLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZWdhY3kyYWlkbF9BdWRpb0RldmljZVR5cGVBZGRyZXNzKSk7CisgICAgc3RkOjp2ZWN0b3I8QXVkaW9EZXZpY2U+IGRldmljZXNBaWRsID0gVkFMVUVfT1JfUkVUVVJOX1NUQVRVUygKKyAgICAgICAgICAgIGNvbnZlcnRDb250YWluZXI8c3RkOjp2ZWN0b3I8QXVkaW9EZXZpY2U+PihkZXZpY2VzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlZ2FjeTJhaWRsX0F1ZGlvRGV2aWNlVHlwZUFkZHJlc3MpKTsKICAgICByZXR1cm4gc3RhdHVzVEZyb21CaW5kZXJTdGF0dXMoCiAgICAgICAgICAgICBhcHMtPnNldERldmljZXNSb2xlRm9yQ2FwdHVyZVByZXNldChhdWRpb1NvdXJjZUFpZGwsIHJvbGVBaWRsLCBkZXZpY2VzQWlkbCkpOwogfQpAQCAtMjE4MiwxMiArMjE5MiwxMiBAQAogICAgIGlmIChhcHMgPT0gMCkgewogICAgICAgICByZXR1cm4gUEVSTUlTU0lPTl9ERU5JRUQ7CiAgICAgfQotICAgIG1lZGlhOjpBdWRpb1NvdXJjZVR5cGUgYXVkaW9Tb3VyY2VBaWRsID0gVkFMVUVfT1JfUkVUVVJOX1NUQVRVUygKLSAgICAgICAgICAgIGxlZ2FjeTJhaWRsX2F1ZGlvX3NvdXJjZV90X0F1ZGlvU291cmNlVHlwZShhdWRpb1NvdXJjZSkpOworICAgIEF1ZGlvU291cmNlIGF1ZGlvU291cmNlQWlkbCA9IFZBTFVFX09SX1JFVFVSTl9TVEFUVVMoCisgICAgICAgICAgICBsZWdhY3ky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ZXNwYWNlIHsKKyAgICBjbGFzcyBMZWdhY3lDYWxsYmFja1dyYXBwZXIgOiBwdWJsaWMgQXVkaW9UcmFjazo6SUF1ZGlvVHJhY2tDYWxsYmFjayB7CisgICAgICBjb25zdCBBdWRpb1RyYWNrOjpsZWdhY3lfY2FsbGJhY2tfdCBtQ2FsbGJhY2s7CisgICAgICB2b2lkICogY29uc3QgbURhdGE7CisgICAgICBwdWJsaWM6CisgICAgICAgIExlZ2FjeUNhbGxiYWNrV3JhcHBlcihBdWRpb1RyYWNrOjpsZWdhY3lfY2FsbGJhY2tfdCBjYWxsYmFjaywgdm9pZCogdXNlcikKKyAgICAgICAgICAgIDogbUNhbGxiYWNrKGNhbGxiYWNrKSwgbURhdGEodXNlcikge30KKyAgICAgICAgc2l6ZV90IG9uTW9yZURhdGEoY29uc3QgQXVkaW9UcmFjazo6QnVmZmVyICYgYnVmZmVyKSBvdmVycmlkZSB7CisgICAgICAgICAgQXVkaW9UcmFjazo6QnVmZmVyIGNvcHkgPSBidWZmZXI7CisgICAgICAgICAgbUNhbGxiYWNrKEF1ZGlvVHJhY2s6OkVWRU5UX01PUkVfREFUQSwgbURhdGEsIHN0YXRpY19jYXN0PHZvaWQqPigmY29weSkpOworICAgICAgICAgIHJldHVybiBjb3B5LnNpemUoKTsKKyAgICAgICAgfQorICAgICAgICB2b2lkIG9uVW5kZXJydW4oKSBvdmVycmlkZSB7CisgICAgICAgICAgICBtQ2FsbGJhY2soQXVkaW9UcmFjazo6RVZFTlRfVU5ERVJSVU4sIG1EYXRhLCBudWxscHRyKTsKKyAgICAgICAgfQorICAgICAgICB2b2lkIG9uTG9vcEVuZChpbnQzMl90IGxvb3BzUmVtYWluaW5nKSBvdmVycmlkZSB7CisgICAgICAgICAgICBtQ2FsbGJhY2soQXVkaW9UcmFjazo6RVZFTlRfTE9PUF9FTkQsIG1EYXRhLCAmbG9vcHNSZW1haW5pbmcpOworICAgICAgICB9CisgICAgICAgIHZvaWQgb25NYXJrZXIodW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ZXgsICZjYmxrLT5tRnV0ZXgsCiAgICAgICAgICAgICAgICAgICAgIG1DbGllbnRJblNlcnZlciA/IEZVVEVYX1dBSVRfUFJJVkFURSA6IEZVVEVYX1dBSVQsIG9sZCAmIH5DQkxLX0ZVVEVYX1dBS0UsIHRzKTsKLSAgICAgICAgICAgIHN3aXRjaCAoZXJybm8pIHsKKyAgICAgICAgICAgIHN0YXR1c190IGVycm9yID0gZXJybm87IC8vIGNsb2NrX2dldHRpbWUgY2FuIGFmZmVjdCBlcnJubworICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIHN0cnVjdCB0aW1lc3BlYyBhZnRlcjsKKyAgICAgICAgICAgICAgICBjbG9ja19nZXR0aW1lKENMT0NLX01PTk9UT05JQywgJmFmdGVyKTsKKyAgICAgICAgICAgICAgICB0b3RhbC50dl9zZWMgKz0gYWZ0ZXIudHZfc2VjIC0gYmVmb3JlLnR2X3NlYzsKKyAgICAgICAgICAgICAgICAvLyBVc2UgYXV0byBpbnN0ZWFkIG9mIGxvbmcgdG8gYXZvaWQgdGhlIGdvb2dsZS1ydW50aW1lLWludCB3YXJuaW5nLgorICAgICAgICAgICAgICAgIGF1dG8gZGVsdGFOcyA9IGFmdGVyLnR2X25zZWMgLSBiZWZvcmUudHZfbnNlYzsKKyAgICAgICAgICAgICAgICBpZiAoZGVsdGFOcyA8IDApIHsKKyAgICAgICAgICAgICAgICAgICAgZGVsdGFOcyArPSAxMDAwMDAwMDAwOworICAgICAgICAgICAgICAgICAgICB0b3RhbC50dl9zZWMtLTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgaWYgKCh0b3RhbC50dl9uc2VjICs9IGRlbHRhTnMpID49IDEwMDAwMDAwMDApIHsKKyAgICAgICAgICAgICAgICAgICAgdG90YWwudHZfbnNlYyAtPSAxMDAwMDAwMDAwOworICAgICAgICAgICAgICAgICAgICB0b3RhbC50dl9zZWMrKzsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgYmVmb3JlID0gYWZ0ZXI7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBzd2l0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICBjYXNlIDA6ICAgICAgICAgICAgLy8gbm9ybWFsIHdha2V1cCBieSBzZXJ2ZXIsIG9yIGJ5IGJpbmRlckRpZWQoKQogICAgICAgICAgICAgY2FzZSBFV09VTERCTE9DSzogIC8vIGJlbmlnbiByYWNlIGNvbmRpdGlvbiB3aXRoIHNlcnZlcgogICAgICAgICAgICAgY2FzZSBFSU5UUjogICAgICAgIC8vIHdhaXQgd2FzIGludGVycnVwdGVkIGJ5IHNpZ25hbCBvciBvdGhlciBzcHVyaW91cyB3YWtldXAKICAgICAgICAgICAgIGNhc2UgRVRJTUVET1VUOiAgICAvLyB0aW1lLW91dCBleHBpcmVkCiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAgICAgIHN0YXR1cyA9IGVycm5vOworICAgICAgICAgICAgICAgIHN0YXR1cyA9IGVycm9yOwogICAgICAgICAgICAgICAgIEFMT0dFKCIlcyB1bmV4cGVjdGVkIGVycm9yICVzIiwgX19mdW5jX18sIHN0cmVycm9yKHN0YXR1cykpOwogICAgICAgICAgICAgICAgIGdvdG8gZW5kOwogICAgICAgICAgICAgfQpAQCAtNzQ3LDcgKzc3MCw3IEBACiAgICAgICAgICAgICBpbnQzMl90IG9sZCA9IGFuZHJvaWRfYXRvbWljX29yKENCTEtfRlVURVhfV0FLRSwgJmNibGstPm1GdXRleCk7CiAgICAgICAgICAgICBpZiAoIShvbGQgJiBDQkxLX0ZVVEVYX1dBS0UpKSB7CiAgICAgICAgICAgICAgICAgKHZvaWQpIHN5c2NhbGwoX19OUl9mdXRleCwgJmNibGstPm1GdXRleCwKLSAgICAgICAgICAgICAgICAgICAgICAgIG1DbGllbnRJblNlcnZlciA/IEZVVEVYX1dBS0VfUFJJVkFURSA6IEZVVEVYX1dBS0UsIDEpOworIC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gICAgICAgICAgICAgbWVkaWE6OmF1ZGlvOjpjb21tb246OkF1ZGlvRm9ybWF0IGZvcm1hdCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBjaGFubmVsTWFzaywgaW50NjRfdCogX2FpZGxfcmV0dXJuKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IEF1ZGlvRm9ybWF0RGVzY3JpcHRpb24mIGZvcm1hdCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQXVkaW9DaGFubmVsTGF5b3V0JiBjaGFubmVsTWFzaywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50NjRfdCogX2FpZGxfcmV0dXJuKSB7CiAgICAgdWludDMyX3Qgc2FtcGxlUmF0ZUxlZ2FjeSA9IFZBTFVFX09SX1JFVFVSTl9CSU5ERVIoY29udmVydEludGVncmFsPHVpbnQzMl90PihzYW1wbGVSYXRlKSk7CiAgICAgYXVkaW9fZm9ybWF0X3QgZm9ybWF0TGVnYWN5ID0gVkFMVUVfT1JfUkVUVVJOX0JJTkRFUigKLSAgICAgICAgICAgIGFpZGwybGVnYWN5X0F1ZGlvRm9ybWF0X2F1ZGlvX2Zvcm1hdF90KGZvcm1hdCkpOworICAgICAgICAgICAgYWlkbDJsZWdhY3lfQXVkaW9Gb3JtYXREZXNjcmlwdGlvbl9hdWRpb19mb3JtYXRfdChmb3JtYXQpKTsKICAgICBhdWRpb19jaGFubmVsX21hc2tfdCBjaGFubmVsTWFza0xlZ2FjeSA9IFZBTFVFX09SX1JFVFVSTl9CSU5ERVIoCi0gICAgICAgICAgICBhaWRsMmxlZ2FjeV9pbnQzMl90X2F1ZGlvX2NoYW5uZWxfbWFza190KGNoYW5uZWxNYXNrKSk7CisgICAgICAgICAgICB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jb252ZXJ0IHVzZXIgc3BlY2lmaWVkIHN1cGVydmlzb3J5IHRvbmUgdHlwZQpAQCAtOTYwLDYgKzk2NiwxNiBAQAogICAgICAgICAgICAgVE9ORV9TVVBfRVJST1IsICAgICAgICAgICAgICAvLyBUT05FX1NVUF9FUlJPUgogICAgICAgICAgICAgVE9ORV9TVVBfQ0FMTF9XQUlUSU5HLCAgICAgICAvLyBUT05FX1NVUF9DQUxMX1dBSVRJTkcKICAgICAgICAgICAgIFRPTkVfVFdfUklOR1RPTkUgICAgICAgICAgICAgLy8gVE9ORV9TVVBfUklOR1RPTkUKKyAgICAgICAgfSwKKyAgICAgICAgeyAgIC8vIE5FVyBaRUFMQU5ECisgICAgICAgICAgICBUT05FX0pBUEFOX0RJQUwsICAgICAgICAgICAgICAvLyBUT05FX1NVUF9ESUFMCisgICAgICAgICAgICBUT05FX0pBUEFOX0JVU1ksICAgICAgICAgICAgICAvLyBUT05FX1NVUF9CVVNZCisgICAgICAgICAgICBUT05FX1NVUF9DT05HRVNUSU9OLCAgICAgICAgICAvLyBUT05FX1NVUF9DT05HRVNUSU9OCisgICAgICAgICAgICBUT05FX1NVUF9SQURJT19BQ0ssICAgICAgICAgICAvLyBUT05FX1NVUF9SQURJT19BQ0sKKyAgICAgICAgICAgIFRPTkVfU1VQX1JBRElPX05PVEFWQUlMLCAgICAgIC8vIFRPTkVfU1VQX1JBRElPX05PVEFWQUlMCisgICAgICAgICAgICBUT05FX1NVUF9FUlJPUiwgICAgICAgICAgICAgICAvLyBUT05FX1NVUF9FUlJPUgorICAgICAgICAgICAgVE9ORV9OWl9DQUxMX1dBSVRJTkcsICAgICAgICAgLy8gVE9ORV9TVVBfQ0FMTF9XQUlUSU5HCisgICAgICAgICAgICBUT05FX0dCX1JJTkdUT05FICAgICAgICAgICAgICAvLyBUT05FX1NVUF9SSU5HVE9ORQogICAgICAgICB9CiB9OwogCkBAIC05NzcsNyArOTkzLDcgQEAKIC8vICAgIE1ldGhvZDogICAgICAgI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AgICAgICAgICAgaWYgKG1TdGF0ZSA9PSBUT05FX1BMQVlJTkcpIHsKKyAgICAgICAgICAgICAgICBtU3RhdGUgPSBUT05FX1NUT1BQSU5HOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgaWYgKGxwVG9uZURlc2MtPnNlZ21lbnRzW2xwVG9uZUdlbi0+bUN1clNlZ21lbnRdLmR1cmF0aW9uID09IDApIHsKKyAgICAgICAgICAgIGlmIChtcFRvbmVEZXNjLT5zZWdtZW50c1ttQ3VyU2VnbWVudF0uZHVyYXRpb24gPT0gMCkgewogICAgICAgICAgICAgICAgIGdvdG8gYXVkaW9DYWxsYmFja19FbmRMb29wOwogICAgICAgICAgICAgfQogICAgICAgICAgICAgLy8gZmFkZSBvdXQgYmVmb3JlIHN0b3BwaW5nIGlmIG1heGltdW0gZHVyYXRpb24gcmVhY2hlZAogICAgICAgICAgICAgbFdhdmVDbWQgPSBXYXZlR2VuZXJhdG9yOjpXQVZFR0VOX1NUT1A7Ci0gICAgICAgICAgICBscFRvbmVHZW4tPm1OZXh0U2VnU21wID0gVE9ORUdFTl9JTkY7IC8vIGZvcmNlZCB0byBza2lwIHN0YXRlIG1hY2hpbmUgbWFuYWdlbWVudCBiZWxvdworICAgICAgICAgICAgbU5leHRTZWdTbXAgPSBUT05FR0VOX0lORjsgLy8gZm9yY2VkIHRvIHNraXAgc3RhdGUgbWFjaGluZSBtYW5hZ2VtZW50IGJlbG93CiAgICAgICAgIH0KIAotICAgICAgICBpZiAobHBUb25lR2VuLT5tVG90YWxTbXAgPiBscFRvbmVHZW4tPm1OZXh0U2VnU21wKSB7CisgICAgICAgIGlmIChtVG90YWxTbXAgPiBtTmV4dFNlZ1NtcCAmJiBtTmV4dFNlZ1NtcCAhPSBUT05FR0VOX0lORikgewogICAgICAgICAgICAgLy8gVGltZSB0byBnbyB0byBuZXh0IHNlcXVlbmNlIHNlZ21lbnQKIAogICAgICAgICAgICAgQUxPR1YoIkVuZCBTZWdtZW50LCB0aW1lO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bmN5KTsKICAgICAgICAgICAgICAgICAgICAgbHBXYXZlR2VuLT5nZXRTYW1wbGVzKGxwT3V0LCBsR2VuU21wLCBsV2F2ZUNtZCk7Ci0gICAgICAgICAgICAgICAgICAgIGxGcmVxdWVuY3kgPSBscFRvbmVEZXNjLT5zZWdtZW50c1tscFRvbmVHZW4tPm1DdXJTZWdtZW50XS53YXZlRnJlcVsrK2xGcmVxSWR4XTsKKyAgICAgICAgICAgICAgICAgICAgbEZyZXF1ZW5jeSA9IG1wVG9uZURlc2MtPnNlZ21lbnRzW21DdXJTZWdtZW50XS53YXZlRnJlcVsrK2xGcmVxSWR4XTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgQUxPR1YoIk9OLT5PRkYsIGxHZW5TbXA6ICVkLCBsUmVxU21wOiAlZCIsIGxHZW5TbXAsIGxSZXFTbXApOwogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAvLyBjaGVjayBpZiB3ZSBuZWVkIHRvIGxvb3AgYW5kIGxvb3AgZm9yIHRoZSByZXFkIHRpbWVzCi0gICAgICAgICAgICBpZiAobHBUb25lRGVzYy0+c2VnbWVudHNbbHBUb25lR2VuLT5tQ3VyU2VnbWVudF0ubG9vcENudCkgewotICAgICAgICAgICAgICAgIGlmIChscFRvbmVHZW4tPm1Mb29wQ291bnRlciA8IGxwVG9uZURlc2MtPnNlZ21lbnRzW2xwVG9uZUdlbi0+bUN1clNlZ21lbnRdLmxvb3BDbnQpIHsKKyAgICAgICAgICAgIGlmIChtcFRvbmVEZXNjLT5zZWdtZW50c1ttQ3VyU2VnbWVudF0ubG9vcENudCkgeworICAgICAgICAgICAgICAgIGlmIChtTG9vcENvdW50ZXIgPCBtcFRvbmVEZXNjLT5zZWdtZW50c1ttQ3VyU2VnbWVudF0ubG9vcENudCkgewogICAgICAgICAgICAgICAgICAgICBBTE9HViAoImluIGlmIGxvb3AgbG9vcENudCglZCkgbG9vcGN0ciglZCksIEN1clNlZyglZCkiLAotICAgICAgICAgICAgICAgICAgICAgICAgICBscFRvbmVEZXNjLT5zZWdtZW50c1tscFRvbmVHZW4tPm1DdXJTZWdtZW50XS5sb29wQ250LAotICAgICAgICAgICAgICAgICAgICAgICAgICBscFRvbmVHZW4tPm1Mb29wQ291bnRlciwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgbHBUb25lR2VuLT5tQ3VyU2VnbWVudCk7Ci0gICAgICAgICAgICAgICAgICAgIGxwVG9uZUdlbi0+bUN1clNlZ21lbnQgPSBscFRvbmVEZXNjLT5zZWdtZW50c1tscFRvbmVHZW4tPm1DdXJTZWdtZW50XS5sb29wSW5keDsKLSAgICAgICAgICAgICAgICAgICAgKytscFRvbmVHZW4tPm1Mb29wQ291bnRlcjsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgbXBUb25lRGVzYy0+c2VnbWVudHNbbUN1clNlZ21lbnRdLmxvb3BDbnQsCisgICAgICAgICAgICAgICAgICAgICAgICAgIG1Mb29wQ291bnRlciwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgbUN1clNlZ21lbnQpOworICAgICAgICAgICAgICAgICAgICBtQ3VyU2VnbWVudCA9IG1wVG9uZURlc2MtPnNlZ21lbnRzW21DdXJTZWdtZW50XS5sb29wSW5keDsKKyAgICAgICAgICAgICAgICAgICAgKyttTG9vcENvdW50ZXI7CiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgLy8gY29tcGxldGVkIGxvb3AuIGdvIHRvIG5leHQgc2VnbWVudAotICAgICAgICAgICAgICAgICAgICBscFRvbmVHZW4tPm1Mb29wQ291bnRlciA9IDA7Ci0gICAgICAgICAgICAgICAgICAgIGxwVG9uZUdlbi0+bUN1clNlZ21lbnQrKzsKKyAgICAgICAgICAgICAgICAgICAgbUxvb3BDb3VudGVyID0gMDsKKyAgICAgICAgICAgICAgICAgICAgbUN1clNlZ21lbnQrKzsKICAgICAgICAgICAgICAgICAgICAgQUxPR1YgKCJpbiBlbHNlIGxvb3AgbG9vcENudCglZCkgbG9vcGN0ciglZCksIEN1clNlZyglZCkiLAotICAgICAgICAgICAgICAgICAgICAgICAgICBscFRvbmVEZXNjLT5zZWdtZW50c1tscFRvbmVHZW4tPm1DdXJTZWdtZW50XS5sb29wQ250LAotICAgICAgICAgICAgICAgICAgICAgICAgICBscFRvbmVHZW4tPm1Mb29wQ291bnRlciwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgbHBUb25lR2VuLT5tQ3VyU2VnbWVudCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgIG1wVG9uZURlc2MtPnNlZ21lbnRzW21DdXJTZWdtZW50XS5sb29wQ250LAorICAgICAgICAgICAgICAgICAgICAgICAgICBtTG9vcENvdW50ZXIsCisgICAgICAgICAgICAgICAgICAgICAgICAgIG1DdXJTZWdtZW50KTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIGxwVG9uZUdlbi0+bUN1clNlZ21lbnQrKzsKKyAgICAgICAgICAgICAgICBtQ3VyU2VnbWVudCsrOwogICAgICAgICAgICAgICAgIEFMT0dWICgiR290byBuZXh0IHNlZyBsb29wQ250KCVkKSBsb29wY3RyKCVkKSwgQ3VyU2VnKCVkKSIsCi0gICAgICAgICAgICAgICAgICAgICAgbHBUb25lRGVzYy0+c2VnbWVudHNbbHBUb25lR2VuLT5tQ3VyU2VnbWVudF0ubG9vcENudCwKLSAgICAgICAgICAgICAgICAgICAgICBscFRvbmVHZW4tPm1Mb29wQ291bnRlciwKLSAgICAgICAgICAgICAgICAgICAgICBscFRvbmVHZW4tPm1DdXJTZWdtZW50KTsKKyAgICAgICAgICAgICAgICAgICAgICBtcFRvbmVEZXNjLT5zZWdtZW50c1ttQ3VyU2VnbWVudF0ubG9vcENudCwKKyAgICAgICAgICAgICAgICAgICAgICBtTG9vcENvdW50ZXIsCisgICAgICAgICAgICAgICAgICAgICAgbUN1clNlZ21lbnQpOwogCiAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgIC8vIEhhbmRsZSBsb29wIGlmIGxhc3Qgc2VnbWVudCByZWFjaGVkCi0gICAgICAgICAgICBpZiAobHBUb25lRGVzYy0+c2VnbWVudHNbbHBUb25lR2VuLT5tQ3VyU2VnbWVudF0uZHVyYXRpb24gPT0gMCkgewotICAgICAgICAgICAgICAgIEFMT0dWKCJMYXN0IFNlZzogJWQiLCBscFRvbmVHZW4tPm1DdXJTZWdtZW50KTsKKyAgICAgICAgICAgIGlmIChtcFRvbmVEZXNjLT5zZWdtZW50c1ttQ3VyU2VnbWVudF0uZHVyYXRpb24gPT0gMCkgeworICAgICAgICAgICAgICAgIEFMT0dWKCJMYXN0IFNlZzogJWQiLCBtQ3VyU2VnbWVudCk7CiAKICAgICAgICAgICAgICAgICAvLyBQcmUgaW5jcmVtZW50IGxvb3AgY291bnQgYW5kIHJlc3RhcnQgaWYgdG90YWwgY291bnQgbm90IHJlYWNoZWQuIFN0b3Agc2VxdWVuY2Ugb3RoZXJ3aXNlCi0gICAgICAgICAgICAgICAgaWYgKCsrbHBUb25lR2VuLT5tQ3VyQ291bnQgPD0gbHBUb25lRGVzYy0+cmVwZWF0Q250KSB7Ci0gICAgICAgICAgICAgICAgICAgIEFMT0dWKCJSZXBlYXRpbmcgQ291bnQ6ICVkIiwgbHBUb25lR2VuLT5tQ3VyQ291bnQpOworICAgICAgICAgICAgICAgIGlmICgrK21DdXJDb3VudCA8PSBtcFRvbmVEZXNjLT5yZXBlYXRDbnQpIHsKKyAgICAgICAgICAgICAgICAgICAgQUxPR1YoIlJlcGVhdGluZyBDb3VudDogJWQiLCBtQ3VyQ291bnQpOwogCi0gICAgICAgICAgICAgICAgICAgIGxwVG9uZUdlbi0+bUN1clNlZ21lbnQgPSBscFRvbmVEZXNjLT5yZXBlYXRTZWdtZW50OwotICAgICAgICAgICAgICAgICAgICBpZiAobHBUb25lRGVzYy0+c2VnbWVudHNbbHBUb25lRGVzYy0+cmVwZWF0U2VnbWVudF0ud2F2ZUZyZXFbMF0gIT0gMCkgeworICAgICAgICAgICAgICAgICAgICBtQ3VyU2VnbWVudCA9IG1wVG9uZURlc2MtPnJlcGVhdFNlZ21lbnQ7CisgICAgICAgICAgICAgICAgICAgIGlmIChtcFRvbmVEZXNjLT5zZWdtZW50c1ttcFRvbmVEZXNjLT5yZXBlYXRTZWdtZW50XS53YXZlRnJlcVswXSAhPSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBsV2F2ZUNtZCA9IFdhdmVHZW5lcmF0b3I6OldBVkVHRU5fU1RBUlQ7CiAgICAgICAgICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgICAgICAgICBBTE9HVigiTmV3IHNlZ21lbnQgJWQsIE5leHQgVGltZTogJWxsZCIsIGxwVG9uZUdlbi0+bUN1clNlZ21lbnQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgKChsb25nIGxvbmcpKGxwVG9uZUdlbi0+bU5leHRTZWdTbXApKjEwMDApL2xwVG9uZUdlbi0+bVNhbXBsaW5nUmF0ZSk7CisgICAgICAgICAgICAgICAgICAgIEFMT0dWKCJOZXcgc2VnbWVudCAlZCwgTmV4dCBUaW1lOiAlbGxkIiwgbUN1clNlZ21lbnQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgKChsb25nIGxvbmcpKG1OZXh0U2VnU21wKSoxMDAwKS9tU2FtcGxpbmdSYXRlKTsKIAogCiAgICAgICAgICAgICAgICAgfSBlbHNlIHsKQEAgLTE0NTksMTAgKzE0ODgsMTAgQEAKICAgICAgICAgICAgICAgICAgICAgQUxPR1YoIkVuZCByZXBlYXQsIHRpbWU6ICVkIiwgKHVuc2lnbmVkIGludCkoc3lzdGVtVGltZSgpLzEwMDAwMDApKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIEFMT0dWKCJOZXcgc2VnbWVudCAlZCwgTmV4dCBUaW1lOiAlbGxkIiwgbHBUb25lR2VuLT5tQ3VyU2VnbWVudCwKLSAgICAgICAgICAgICAgICAgICAgICAgICgobG9uZyBsb25nKShscFRvbmVHZW4tPm1OZXh0U2VnU21wKSoxMDAwKS9scFRvbmVHZW4tPm1TYW1wbGluZ1JhdGUpOworICAgICAgICAgICAgICAgIEFMT0dWKCJOZXcgc2VnbWVudCAlZCwgTmV4dCBUaW1lOiAlbGxkIiwgbUN1clNlZ21lbnQsCisgICAgICAgICAgICAgICAgICAgICAgICAoKGxvbmcgbG9uZykobU5leHRTZWdTbXApKjEwMDApL21TYW1wbGluZ1JhdGUpOwogCi0gICAgICAgICAgICAgICAgaWYgKGxwVG9uZURlc2MtPnNlZ21lbnRzW2xwVG9uZUdlbi0+bUN1clNlZ21lbnRdLndhdmVGcmVxWzBdICE9IDApIHsKKyAgICAgICAgICAgICAgICBpZiAobXBUb25lRGVzYy0+c2VnbWVudHNbbUN1clNlZ21lbnRdLndhdmVGcmVxWzBdICE9IDApIHsKICAgICAgICAgICAgICAgICAgICAgLy8gSWYgbmV4dCBzZWdtZW50IGlzIG5vdCBzaWxlbnQsICBPRkYgLT4gT04gdHJhbnNpdGlvbiA6IHJlc2V0IHdhdmUgZ2VuZXJhdG9yCiAgICAgICAgICAgICAgICAgICAgIGxXYXZlQ21kID0gV2F2ZUdlbmVyYXRvcjo6V0FWRUdFTl9TVEFSVDsKIApAQCAtMTQ3MiwxMyArMTUwMSwxNiBAQAogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KIAotICAgICAgICAgICAgLy8gVXBkYXRlIG5leHQgc2VnbWVudCB0cmFuc2l0aW9uIHBvc2l0aW9uLiBObyBoYXJtIHRvIGRvIGl0IGFsc28gZm9yIGxhc3Qgc2VnbWVudCBhcyBscFRvbmVHZW4tPm1OZXh0U2VnU21wIHdvbid0IGJlIHVzZWQgYW55IG1vcmUKLSAgICAgICAgICAgIGxwVG9uZUdlbi0+bU5leHRTZWdTbXAKLSAgICAgICAgICAgICAgICAgICAgKz0gKGxwVG9uZURl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LndhdmVGcmVxWysrbEZyZXFJZHhdOworICAgICAgICAgICAgICAgIGxGcmVxdWVuY3kgPSBtcFRvbmVEZXNjLT5zZWdtZW50c1ttQ3VyU2VnbWVudF0ud2F2ZUZyZXFbKytsRnJlcUlkeF07CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIApAQCAtMTUwMSwyMSArMTUzMywxOSBAQAogICAgICAgICBscE91dCArPSBsUmVxU21wOwogCiBhdWRpb0NhbGxiYWNrX0VuZExvb3A6Ci0KLSAgICAgICAgc3dpdGNoIChscFRvbmVHZW4tPm1TdGF0ZSkgeworICAgICAgICBzd2l0Y2ggKG1TdGF0ZSkgewogICAgICAgICBjYXNlIFRPTkVfUkVTVEFSVElORzoKICAgICAgICAgICAgIEFMT0dWKCJDYmsgcmVzdGFydGluZyB0cmFjayIpOwotICAgICAgICAgICAgaWYgKGxwVG9uZUdlbi0+cHJlcGFyZVdhdmUoKSkgewotICAgICAgICAgICAgICAgIGxwVG9uZUdlbi0+bVN0YXRlID0gVE9ORV9TVEFSVElORzsKLSAgICAgICAgICAgICAgICBpZiAoY2xvY2tfZ2V0dGltZShDTE9DS19NT05PVE9OSUMsICZscFRvbmVHZW4tPm1TdGFydFRpbWUpICE9IDApIHsKLSAgICAgICAgICAgICAgICAgICAgbHBUb25lR2VuLT5tU3RhcnRUaW1lLnR2X3NlYyA9IDA7CisgICAgICAgICAgICBpZiAocHJlcGFyZVdhdmUoKSkgeworICAgICAgICAgICAgICAgIG1TdGF0ZSA9IFRPTkVfU1RBUlRJTkc7CisgICAgICAgICAgICAgICAgaWYgKGNsb2NrX2dldHRpbWUoQ0xPQ0tfTU9OT1RPTklDLCAmbVN0YXJ0VGltZSkgIT0gMCkgeworICAgICAgICAgICAgICAgICAgICBtU3RhcnRUaW1lLnR2X3NlYyA9IDA7CiAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIC8vIG11c3QgcmVsb2FkIGxwVG9uZURlc2MgYXMgcHJlcGFyZVdhdmUoKSBtYXkgY2hhbmdlIG1wVG9uZURlc2MKLSAgICAgICAgICAgICAgICBscFRvbmVEZXNjID0gbHBUb25lR2VuLT5tcFRvbmVEZXNjOworICAgICAgICAgICAgICAgIC8vIG11c3QgcmVsb2FkIG1wVG9uZURlc2MgYXMgcHJlcGFyZVdhdmUoKSBtYXkgY2hhbmdlIG1wVG9uZURlc2MKICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgQUxPR1coIkNiayByZXN0YXJ0aW5nIHByZXBhcmVXYXZlKCkgZmFpbGVkIik7Ci0gICAgICAgICAgICAgICAgbHBUb25lR2VuLT5tU3RhdGUgPSBUT05FX0lETEU7Ci0gICAgICAgICAgICAgICAgbHBUb25lR2VuLT5tcEF1ZGlvVHJhY2stPnN0b3AoKTsKKyAgICAgICAgICAgICAgICBtU3RhdGUgPSBUT05FX0lETEU7CisgICAgICAgICAgICAgICAgbXBBdWRpb1RyYWNrLT5zdG9wKCk7CiAgICAgICAgICAgICAgICAgLy8gRm9yY2UgbG9vcCBleGl0CiAgICAgICAgICAgICAgICAgbE51bVNtcCA9IDA7CiAgICAgICAgICAgICB9CkBAIC0xNTIzLDIyICsxNTUzLDIyIEBACiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgY2FzZSBUT05FX1NUT1BQSU5HOgogICAgICAgICAgICAgQUxPR1YoIkNiayBTdG9wcGluZyIpOwotICAgICAgICAgICAgbHBUb25lR2VuLT5tU3RhdGUgPSBUT05FX1NUT1BQRUQ7CisgICAgICAgICAgICBtU3RhdGUgPSBUT05FX1NUT1BQRUQ7CiAgICAgICAgICAgICAvLyBGb3JjZSBsb29wIGV4aXQKICAgICAgICAgICAgIGxOdW1TbXAgPSAwOwogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIGNhc2UgVE9ORV9TVE9QUEVEOgotICAgICAgICAgICAgbHBUb25lR2VuLT5tU3RhdGUgPSBUT05FX0lOSVQ7CisgICAgICAgICAgICBtU3RhdGUgPSBUT05FX0lOSVQ7CiAgICAgICAgICAgICBBTE9HVigiQ2JrIFN0b3BwZWQgdHJhY2siKTsKLSAgICAgICAgICAgIGxwVG9uZUdlbi0+bXBBdWRpb1RyYWNrLT5zdG9wKCk7CisgICAgICAgICAgICBtcEF1ZGlvVHJhY2stPnN0b3AoKTsKICAgICAgICAgICAgIC8vIEZvcmNlIGxvb3AgZXhpdAogICAgICAgICAgICAgbE51bVNtcCA9IDA7Ci0gICAgICAgICAgICBidWZmZXItPnNpemUgPSAwOworICAgICAgICAgICAgYnl0ZXNXcml0dGVuID0gMDsKICAgICAgICAgICAgIGxTaWduYWwgPSB0cnVlOwogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIGNhc2UgVE9ORV9TVEFSVElORzoKICAgICAgICAgICAgIEFMT0dWKCJDYmsgc3RhcnRpbmcgdHJhY2siKTsKLSAgICAgICAgICAgIGxwVG9uZUdlbi0+bVN0YXRlID0gVE9ORV9QTEFZSU5HOworICAgICAgICAgICAgbVN0YXRlID0gVE9ORV9QTEFZSU5HOwogICAgICAgICAgICAgbFNpZ25hbCA9IHRydWU7CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgY2FzZSBUT05FX1BMQVlJTkc6CkBAIC0xNTQ2LDE0ICsxNTc2LDE1IEBACiAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAvLyBGb3JjZSBsb29wIGV4aXQKICAgICAgICAgICAgIGxOdW1TbXAgPSAwOwotICAgICAgICAgICAgYnVmZmVyLT5zaXplID0gMDsKKyAgICAgICAgICAgIGJ5dGVzV3JpdHRlbiA9IDA7CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogCiAgICAgICAgIGlmIChsU2lnbmFsKQotICAgICAgICAgICAgbHBUb25lR2VuLT5tV2FpdENia0NvbmQuYnJvYWRjYXN0KCk7Ci0gICAgICAgIGxwVG9uZUdlbi0+bUxvY2sudW5sb2NrKCk7CisgICAgICAgICAgICBtV2FpdENia0NvbmQuYnJvYWRjY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m1lZGlhLmF1ZGlvLmNvbW1vbi5BdWRpb1BvcnQgcG9ydCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbiBBdWRpb0Zvcm1hdERlc2NyaXB0aW9uIGVuY29kZWRGb3JtYXQpOwogCiAgICAgQXVkaW9Qb2xpY3lEZXZpY2VTdGF0ZSBnZXREZXZpY2VDb25uZWN0aW9uU3RhdGUoaW4gQXVkaW9EZXZpY2UgZGV2aWNlKTsKIAogICAgIHZvaWQgaGFuZGxlRGV2aWNlQ29uZmlnQ2hhbmdlKGluIEF1ZGlvRGV2aWNlIGRldmljZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBAdXRmOEluQ3BwIFN0cmluZyBkZXZpY2VOYW1lLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluIEF1ZGlvRm9ybWF0IGVuY29kZWRGb3JtYXQpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluIEF1ZGlvRm9ybWF0RGVzY3JpcHRpb24gZW5jb2RlZEZvcm1hdCk7CiAKICAgICB2b2lkIHNldFBob25lU3RhdGUoQXVkaW9Nb2RlIHN0YXRlLCBpbnQgLyogdWlkX3QgKi8gdWlkKTsKIApAQCAtMTE2LDE4ICsxMTgsMTggQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IGluZGV4TWF4KTsKIAogICAgIHZvaWQgc2V0U3RyZWFtVm9sdW1lSW5kZXgoQXVkaW9TdHJlYW1UeXBlIHN0cmVhbSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCAvKiBhdWRpb19kZXZpY2VzX3QgKi8gZGV2aWNlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW4gQXVkaW9EZXZpY2VEZXNjcmlwdGlvbiBkZXZpY2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgaW5kZXgpOwogCiAgICAgaW50IGdldFN0cmVhbVZvbHVtZUluZGV4KEF1ZGlvU3RyZWFtVHlwZSBzdHJlYW0sCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCAvKiBhdWRpb19kZXZpY2VzX3QgKi8gZGV2aWNlKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW4gQXVkaW9EZXZpY2VEZXNjcmlwdGlvbiBkZXZpY2UpOwogCiAgICAgdm9pZCBzZXRWb2x1bWVJbmRleEZvckF0dHJpYnV0ZXMoaW4gQXVkaW9BdHRyaWJ1dGVzSW50ZXJuYWwgYXR0ciwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgLyogYXVkaW9fZGV2aWNlc190ICovIGRldmljZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbiBBdWRpb0RldmljZURlc2NyaXB0aW9uIGRldmljZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgaW5kZXgpOwogCiAgICAgaW50IGdldFZvbHVtZUluZGV4Rm9yQXR0cmlidXRlcyhpbiBBdWRpb0F0dHJpYnV0ZXNJbnRlcm5hbCBhdHRyLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IC8qIGF1ZGlvX2RldmljZXNfdCAqLyBkZXZpY2UpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW4gQXVkaW9EZXZpY2VEZXNjcmlwdGlvbiBkZXZpY2UpOwogCiAgICAgaW50IGdldE1heFZvbHVtZUluZGV4Rm9yQXR0cmlidXRlcyhpbiBBdWRpb0F0dHJpYnV0ZXNJbnRlcm5hbCBhdHRyKTsKIApAQCAtMTM1LDkgKzEzNyw3IEBACiAKICAgICBpbnQgLyogcHJvZHVjdF9zdHJhdGVneV90ICovIGdldFN0cmF0ZWd5Rm9yU3RyZWFtKEF1ZGlvU3RyZWFtVHlwZSBzdHJlYW0pOwogCi0gICAgaW50IC8qIGJpdG1hc2sgb2YgYXVkaW9fZGV2aWNlc190ICovIGdldERldmljZXNGb3JTdHJlYW0oQXVkaW9TdHJlYW1UeXBlIHN0cmVhbSk7Ci0KLSAgICBBdWRpb0RldmljZVtdIGdldERldmljZXNGb3JBdHRyaWJ1dGVzKGluIEF1ZGlvQXR0cmlidXRlc0V4IGF0dHIpOworICAgIEF1ZGlvRGV2aWNlW10gZ2V0RGV2aWNlc0ZvckF0dHJpYnV0ZXMoaW4gQXVkaW9BdHRyaWJ1dGVzRXggYXR0ciwgYm9vbGVhbiBmb3JWb2x1bWUpOwogCiAgICAgaW50IC8qIGF1ZGlvX2lvX2hhbmRsZV90ICovIGdldE91dHB1dEZvckVmZmVjdChpbiBFZmZlY3REZXNjcmlwdG9yIGRlc2MpOwogCkBAIC0xNTcsNyArMTU3LDcgQEAKIAogICAgIGJvb2xlYW4gaXNTdHJlYW1BY3RpdmVSZW1vdGVseShBdWRpb1N0cmVhbVR5cGUgc3RyZWFtLCBpbnQgaW5QYXN0TXMpOwogCi0gICAgYm9vbGVhbiBpc1NvdXJjZUFjdGl2ZShBdWRpb1NvdXJjZVR5cGUgc291cmNlKTsKKyAgICBib29sZWFuIGlzU291cmNlQWN0aXZlKEF1ZGlvU291cmNlIHNvdXJjZSk7CiAKICAgICAvKioKICAgICAgKiBPbiBpbnB1dCwgY291bnQgcmVwcmVzZW50cyB0aGUgbWF4aW11bSBsZW5ndGggb2YgdGhlIHJldHVybmVkIGFycmF5LgpAQCAtMTcyLDcgKzE3Miw3IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQHV0ZjhJbkNwcCBTdHJpbmcgb3BQYWNrYWdlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbiBBdWRpb1V1aWQgdXVpZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgcHJpb3JpdHksCi0gICAgICAgICAgICAgIC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aW9TdHJlYW1UeXBlIHN0cmVhbSwgaW50IGluZGV4LCBpbnQgLyogYXVkaW9fZGV2aWNlc190ICovIGRldmljZSk7CisgICAgZmxvYXQgZ2V0U3RyZWFtVm9sdW1lREIoQXVkaW9TdHJlYW1UeXBlIHN0cmVhbSwgaW50IGluZGV4LCBpbiBBdWRpb0RldmljZURlc2NyaXB0aW9uIGRldmljZSk7CiAKICAgICAvKioKICAgICAgKiBQb3B1bGF0ZXMgc3VwcG9ydGVkIHN1cnJvdW5kIGZvcm1hdHMgYW5kIHRoZWlyIGVuYWJsZWQgc3RhdGUgaW4gZm9ybWF0cyBhbmQgZm9ybWF0c0VuYWJsZWQuCkBAIC0yODEsNyArMjgxLDcgQEAKICAgICAgKiBudW1iZXIgb2YgZWxlbWVudHMgd2l0aG91dCBhY3R1YWxseSByZXRyaWV2aW5nIHRoZW0uCiAgICAgICovCiAgICAgdm9pZCBnZXRTdXJyb3VuZEZvcm1hdHMoaW5vdXQgSW50IGNvdW50LAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dCBBdWRpb0Zvcm1hdFtdIGZvcm1hdHMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0IEF1ZGlvRm9ybWF0RGVzY3JpcHRpb25bXSBmb3JtYXRzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dCBib29sZWFuW10gZm9ybWF0c0VuYWJsZWQpOwogCiAgICAgLyoqCkBAIC0yOTMsMTUgKzI5MywxNiBAQAogICAgICAqIG51bWJlciBvZiBlbGVtZW50cyB3aXRob3V0IGFjdHVhbGx5IHJldHJpZXZpbmcgdGhlbS4KICAgICAgKi8KICAgICB2b2lkIGdldFJlcG9ydGVkU3Vycm91bmRGb3JtYXRzKGlub3V0IEludCBjb3VudCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dCBBdWRpb0Zvcm1hdFtdIGZvcm1hdHMpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg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gYm9vbGVhbiBpc1VsdHJhc291bmRTdXBwb3J0ZWQoKTsKKwogICAgIEF1ZGlvUHJvZHVjdFN0cmF0ZWd5W10gbGlzdEF1ZGlvUHJvZHVjdFN0cmF0ZWdpZXMoKTsKICAgICBpbnQgLyogcHJvZHVjdF9zdHJhdGVneV90ICovIGdldFByb2R1Y3RTdHJhdGVneUZyb21BdWRpb0F0dHJpYnV0ZXMoaW4gQXVkaW9BdHRyaWJ1dGVzRXggYWEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2xlYW4gZmFsbGJhY2tPbkRlZmF1bHQpOwpAQCAtMzMxLDIyICszMzQsMjIgQEAKICAgICBBdWRpb0RldmljZVtdIGdldERldmljZXNGb3JSb2xlQW5kU3RyYXRlZ3koaW50IC8qIHByb2R1Y3Rfc3RyYXRlZ3lfdCAqLyBzdHJhdGVneSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRGV2aWNlUm9sZSByb2xlKTsKIAotICAgIHZvaWQgc2V0RGV2aWNlc1JvbGVGb3JDYXB0dXJlUHJlc2V0KEF1ZGlvU291cmNlVHlwZSBhdWRpb1NvdXJjZSwKKyAgICB2b2lkIHNldERldmljZXNSb2xlRm9yQ2FwdHVyZVByZXNldChBdWRpb1NvdXJjZSBhdWRpb1NvdXJjZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBEZXZpY2VSb2xlIHJvbGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW4gQXVkaW9EZXZpY2VbXSBkZXZpY2VzKTsKIAotICAgIHZvaWQgYWRkRGV2aWNlc1JvbGVGb3JDYXB0dXJlUHJlc2V0KEF1ZGlvU291cmNlVHlwZSBhdWRpb1NvdXJjZSwKKyAgICB2b2lkIGFkZERldmljZXNSb2xlRm9yQ2FwdHVyZVByZXNldChBdWRpb1NvdXJjZSBhdWRpb1NvdXJjZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBEZXZpY2VSb2xlIHJvbGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW4gQXVkaW9EZXZpY2VbXSBkZXZpY2VzKTsKIAotICAgIHZvaWQgcmVtb3ZlRGV2aWNlc1JvbGVGb3JDYXB0dXJlUHJlc2V0KEF1ZGlvU291cmNlVHlwZSBhdWRpb1NvdXJjZSwKKyAgICB2b2lkIHJlbW92ZURldmljZXNSb2xlRm9yQ2FwdHVyZVByZXNldChBdWRpb1NvdXJjZSBhdWRpb1NvdXJjZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBEZXZpY2VSb2xlIHJvbGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW4gQXVkaW9EZXZpY2VbXSBkZXZpY2VzKTsKIAotICAgIHZvaWQgY2xlYXJEZXZpY2VzUm9sZUZvckNhcHR1cmVQcmVzZXQoQXVkaW9Tb3VyY2VUeXBlIGF1ZGlvU291cmNlLAorICAgIHZvaWQgY2xlYXJEZXZpY2VzUm9sZUZvckNhcHR1cmVQcmVzZXQoQXVkaW9Tb3VyY2UgYXVkaW9Tb3VyY2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBEZXZpY2VSb2xlIHJvbGUpOwogCi0gICAgQXVkaW9EZXZpY2VbXSBnZXREZXZpY2VzRm9yUm9sZUFuZENhcHR1cmVQcmVzZXQoQXVkaW9Tb3VyY2VUeXBlIGF1ZGlvU291cmNlLAorICAgIEF1ZGlvRGV2aWNlW10gZ2V0RGV2aWNlc0ZvclJvbGVBbmRDYXB0dXJlUHJlc2V0KEF1ZGlvU291cmNlIGF1ZGlvU291cmNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIERldmljZVJvb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1vbi5BdWRpb1NvdXJjZTsKIAogLyoqCiAgKiB7QGhpZGV9CkBAIC00Myw3ICs0MywxMCBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluIEF1ZGlvQ29uZmlnQmFzZSBkZXZpY2VDb25maWcsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW4gRWZmZWN0RGVzY3JpcHRvcltdIGVmZmVjdHMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IC8qIGF1ZGlvX3BhdGNoX2hhbmRsZV90ICovIHBhdGNoSGFuZGxlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEF1ZGlvU291cmNlVHlwZSBzb3VyY2UpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEF1ZGlvU291cmNlIHNvdXJjZSk7CiAgICAgIC8qKiBOb3RpZmllcyBhIGNoYW5nZSBvZiBhdWRpbyByb3V0aW5nICovCiAgICAgIHZvaWQgb25Sb3V0aW5nVXBkYXRlZCgpOworICAgICAvKiogTm90aWZpZXMgYSByZXF1ZXN0IGZvciB2b2x1bWUgaW5kZXggcmFuZ2VzIHRvIGJlIHJlc2V0IGFmdGVyIHRoZXkgd2VyZSBvYnNlcnZlZCBhcyBpbnZhbGlkCisgICAgICAqLworICAgICB2b2lkIG9uVm9sdW1lUmFuZ2VJbml0UmVxdWVzdCgpOwogfQpkaWZmIC0tZ2l0IGEvbWVkaWEvbGliYXVkaW9jbGllbnQvYWlkbC9hbmRyb2lkL21lZGlhL0lFZmZlY3QuYWlkbCBiL21lZGlhL2xpYmF1ZGlvY2xpZW50L2FpZGwvYW5kcm9pZC9tZWRpYS9JRWZmZWN0LmFpZGwKaW5kZXggODEzY2Q1Yy4uNmVjMDQwNSAxMDA2NDQKLS0tIGEvbWVkaWEvbGliYXVkaW9jbGllbnQvYWlkbC9hbmRyb2lkL21lZGlhL0lFZmZl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gICAgICAgICAgICAgICAgICAgICAgIFwKLSAgICAgICBhdXRvIF90bXAgPSAoeCk7ICAgICAgICAgICAgICAgICAgICAgXAotICAgICAgIGlmICghX3RtcC5vaygpKSByZXR1cm4gX3RtcC5lcnJvcigpOyBcCi0gICAgICAgc3RkOjptb3ZlKF90bXAudmFsdWUoKSk7ICAgICAgICAgICAgIFwKLSAgICAgfSkKLQotI2RlZmluZSBWQUxVRV9PUl9GQVRBTChyZXN1bHQpICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKLSAgICAoeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCi0gICAgICAgYXV0byBfdG1wID0gKHJlc3VsdCk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAotICAgICAgIExPR19BTFdBWVNfRkFUQUxfSUYoIV90bXAub2soKSwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICJGdW5jdGlvbjogJXMgTGluZTogJWQgRmFpbGVkIHJlc3VsdCAoJWQpIixcCi0gICAgICAgICAgICAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIF9fTElORV9fLCBfdG1wLmVycm9yKCkpOyAgICAgXAotICAgICAgIHN0ZDo6bW92ZShfdG1wLnZhbHVlKCkpOyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKLSAgICAgfSkKK3VzaW5nIENvbnZlcnNpb25SZXN1bHQgPSBlcnJvcjo6UmVzdWx0PFQ+OwogCiAvKioKICAqIEEgZ2VuZXJpYyB0ZW1wbGF0ZSB0byBzYWZlbHkgY2FzdCBiZXR3ZWVuIGludGVncmFsIHR5cGVzLCByZXNwZWN0aW5nIGxpbWl0cyBvZiB0aGUgZGVzdGluYXRpb24KQEAgLTEwNiw2ICs3OCwyNiBAQAogfQogCiAvKioKKyAqIEEgZ2V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IHRvCkBAIC0zODMsMTAgKzQyNCwyMCBAQAogICAgICAqICAtIE5PX0lOSVQ6IGF1ZGlvIGZsaW5nZXIgb3IgYXVkaW8gaGFyZHdhcmUgbm90IGluaXRpYWxpemVkCiAgICAgICovCiAgICAgICAgICAgICBzdGF0dXNfdCAgICBzZXQoY29uc3QgZWZmZWN0X3V1aWRfdCAqdHlwZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlZmZlY3RfdXVpZF90ICp1dWlkID0gTlVMTCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlZmZlY3RfdXVpZF90ICp1dWlkID0gbnVsbHB0ciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQzMl90IHByaW9yaXR5ID0gMCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZmZlY3RfY2FsbGJhY2tfdCBjYmYgPSBOVUxMLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZvaWQqIHVzZXIgPSBOVUxMLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdwPElBdWRpb0VmZmVjdENhbGxiYWNrPiYgY2FsbGJhY2sgPSBudWxscHRyLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX3Nlc3Npb25fdCBzZXNzaW9uSWQgPSBBVURJT19TRVNTSU9OX09VVFBVVF9NSVgsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9faW9faGFuZGxlX3QgaW8gPSBBVURJT19JT19IQU5ETEVfTk9ORSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBBdWRpb0RldmljZVR5cGVBZGRyJiBkZXZpY2UgPSB7fSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIHByb2JlID0gZmFsc2UsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBub3RpZnlGcmFtZXNQcm9jZXNzZWQgPSBmYWxzZSk7CisKKyAgICAgICAgICAgIHN0YXR1c190ICAgIHNldChjb25zdCBlZmZlY3RfdXVpZF90ICp0eXBlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVmZmVjdF91dWlkX3QgKnV1aWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBwcmlvcml0eSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZWdhY3lfY2FsbGJhY2tfdCBjYmYsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgdm9pZCogdXNlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19zZXNzaW9uX3Qgc2Vzc2lvbklkID0gQVVESU9fU0VTU0lPTl9PVVRQVVRfTUlYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX2lvX2hhbmRsZV90IGlvID0gQVVESU9fSU9fSEFORExFX05PTkUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQXVkaW9EZXZpY2VUeXBlQWRkciYgZGV2aWNlID0ge30sCkBAIC0zOTYsMTAgKzQ0NywyMSBAQAogICAgICAqIFNhbWUgYXMgYWJvdmUgYnV0IHdpdGggdHlwZSBhbmQgdXVpZCBzcGVjaWZpZWQgYnkgY2hhcmFjdGVyIHN0cmluZ3MuCiAgICAgICovCiAgICAgICAgICAgICBzdGF0dXNfdCAgICBzZXQoY29uc3QgY2hhciAqdHlwZVN0ciwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyICp1dWlkU3RyID0gTlVMTCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyICp1dWlkU3RyID0gbnVsbHB0ciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQzMl90IHByaW9yaXR5ID0gMCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZmZlY3RfY2FsbGJhY2tfdCBjYmYgPSBOVUxMLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZvaWQqIHVzZXIgPSBOVUxMLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdwPElBdWRpb0VmZmVjdENhbGxiYWNrPiYgY2FsbGJhY2sgPSBudWxscHRyLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX3Nlc3Npb25fdCBzZXNzaW9uSWQgPSBBVURJT19TRVNTSU9OX09VVFBVVF9NSVgsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9faW9faGFuZGxlX3QgaW8gPSBBVURJT19JT19IQU5ETEVfTk9ORSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBBdWRpb0RldmljZVR5cGVBZGRyJiBkZXZpY2UgPSB7fSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIHByb2JlID0gZmFsc2UsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBub3RpZnlGcmFtZXNQcm9jZXNzZWQgPSBmYWxzZSk7CisKKworICAgICAgICAgICAgc3RhdHVzX3QgICAgc2V0KGNvbnN0IGNoYXIgKnR5cGVTdHIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hhciAqdXVpZFN0ciwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQzMl90IHByaW9yaXR5LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlZ2FjeV9jYWxsYmFja190IGNiZiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB2b2lkKiB1c2VyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX3Nlc3Npb25fdCBzZXNzaW9uSWQgPSBBVURJT19TRVNTSU9OX09VVFBVVF9NSVgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9faW9faGFuZGxlX3QgaW8gPSBBVURJT19JT19IQU5ETEVfTk9ORSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBBdWRpb0RldmljZVR5cGVBZGRyJiBkZXZpY2UgPSB7fSwKQEAgLTUzNSwxOCArNTk3LDE5IEBACiAKIHByb3RlY3RlZDoKICAgICAgYW5kcm9pZDo6Y29udGVudDo6QXR0cmlidXRpb25Tb3VyY2VTdGF0ZSBtQ2xpZW50QXR0cmlidXRpb25Tb3VyY2U7IC8vIHNvdXJjZSBmb3IgYXBwIG9wIGNoZWNrcy4KLSAgICAgYm9vbCAgICAgICAgICAgICAgICAgICAgbUVuYWJsZWQgPSBmYWxzZTsgICAvLyBlbmFibGUgc3RhdGUKLSAgICAgYXVkaW9fc2Vzc2lvbl90ICAgICAgICAgbVNlc3Npb25JZCA9IEFVRElPX1NFU1NJT05fT1VUUFVUX01JWDsgLy8gYXVkaW8gc2Vzc2lvbiBJRAotICAgICBpbnQzMl90ICAgICAgICAgICAgICAgICBtUHJpb3JpdHkgPSAwOyAgICAgIC8vIHByaW9yaXR5IGZvciBlZmZlY3QgY29udHJvbAotICAgICBzdGF0dXNfdCAgICAgICAgICAgICAgICBtU3RhdHVzID0gTk9fSU5JVDsgIC8vIGVmZmVjdCBzdGF0dXMKLSAgICAgYm9vbCAgICAgICAgICAgICAgICAgICAgbVByb2JlID0gZmFsc2U7ICAgICAvLyBlZmZlY3QgY3JlYXRlZCBpbiBwcm9iZSBtb2RlOiBhbGwgY29tbWFuZHMKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBhcmUgbm8gb3BzIGJlY2F1c2UgbUlFZmZlY3QgaXMgTlVMTAotICAgICBlZmZlY3RfY2FsbGJhY2tfdCAgICAgICBtQ2JmID0gbnVsbHB0cjsgICAgIC8vIGNhbGxiYWNrIGZ1bmN0aW9uIGZvciBzdGF0dXMsIGNvbnRyb2wgYW5kCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gcGFyYW1ldGVyIGNoYW5nZXMgbm90aWZpY2F0aW9ucwotICAgICB2b2lkKiAgICAgICAgICAgICAgICAgICBtVXNlckRhdGEgPSBudWxscHRyOy8vIGNsaWVudCBjb250ZXh0IGZvciBjYWxsYmFjayBmdW5jdGlvbgotICAgICBlZmZlY3RfZGVzY3JpcHRvcl90ICAgICBtRGVzY3JpcHRvciA9IHt9OyAgIC8vIGVmZmVjdCBkZXNjcmlwdG9yCi0gICAgIGludDMyX3QgICAgICAgICAgICAgICAgIG1JZCA9IC0xOyAgICAgICAgICAgLy8gc3lzdGVtIHdpZGUgdW5pcXVlIGVmZmVjdCBlbmdpbmUgaW5zdGFuY2UgSUQKLSAgICAgTXV0ZXggICAgICAgICAgICAgICAgICAgbUxvY2s7ICAgICAgICAgICAgICAvLyBNdXRleCBmb3IgbUVuYWJsZWQgYWNjZXNzCisgICAgIGJvb2wgICAgICAgICAgICAgICAgICAgICBtRW5hYmxlZCA9IGZhbHNlOyAgIC8vIGVuYWJsZSBzdGF0ZQorICAgICBhdWRpb19zZXNzaW9uX3QgICAgICAgICAgbVNlc3Npb25JZCA9IEFVRElPX1NFU1NJT05fT1VUUFVUX01JWDsgLy8gYXVkaW8gc2Vzc2lvbiBJRAorICAgICBpbnQzMl90ICAgICAgICAgICAgICAgICAgbVByaW9yaXR5ID0gMDsgICAgICAvLyBwcmlvcml0eSBmb3IgZWZmZWN0IGNvbnRyb2wKKyAgICAgc3RhdHVzX3QgICAgICAgICAgICAgICAgIG1TdGF0dXMgPSBOT19JTklUOyAgLy8gZWZmZWN0IHN0YXR1cworICAgICBib29sICAgICAgICAgICAgICAgICAgICAgbVByb2JlID0gZmFsc2U7ICAgICAvLyBlZmZlY3QgY3JlYXRlZCBpbiBwcm9iZSBtb2RlOiBhbGwgY29tbWFuZHMKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBhcmUgbm8gb3BzIGJlY2F1c2UgbUlFZmZlY3QgaXMgbnVsbHB0cgorCisgICAgIHdwPElBdWRpb0VmZmVjdENhbGxiYWNrPiBtQ2FsbGJhY2sgPSBudWxsc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AgICAgICAgICAgICAgICBBVURJT19DSEFOTkVMX1JFUFJFU0VOVEFUSU9OX0lOREVYID8KKyAgICAgICAgICAgICAgICAgICBhdWRpb19jaGFubmVsX2luZGV4X21hc2tfdG9fc3RyaW5nKG1DaGFubmVsTWFzaykgOgorICAgICAgICAgICAgICAgICAgIChtSXNJbnB1dCA/IGF1ZGlvX2NoYW5uZWxfaW5fbWFza190b19zdHJpbmcobUNoYW5uZWxNYXNrKSA6CisgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19jaGFubmVsX291dF9tYXNrX3RvX3N0cmluZyhtQ2hhbm5lbE1hc2spKSkKKyAgICAgICAgICAgPDwgIiwgZnJhbWVDb3VudCAiIDw8IG1GcmFtZUNvdW50IDw8ICIsIGZyYW1lQ291bnRIQUwgIiA8PCBtRnJhbWVDb3VudEhBTAorICAgICAgICAgICA8PCAiLCBkZXZpY2VJZCAiIDw8IGdldERldmljZUlkKCk7CisgICAgICAgIHJldHVybiBzcy5zdHIoKTsKKyAgICB9CisKKyAgcHJpdmF0ZToKKyAgICBjb25zdCBhdWRpb19pb19oYW5kbGVfdCAgICBtSW9IYW5kbGUgPSBBVURJT19JT19IQU5ETEVfTk9ORTsKKyAgICAgICAgICBzdHJ1Y3QgYXVkaW9fcGF0Y2ggICBtUGF0Y2ggPSB7fTsKKyAgICBjb25zdCBib29sICAgICAgICAgICAgICAgICBtSXNJbnB1dCA9IGZhbHNlOworICAgIGNvbnN0IHVpbnQzMl90ICAgICAgICAgICAgIG1TYW1wbGluZ1JhdGUgPSAwOworICAgIGNvbnN0IGF1ZGlvX2Zvcm1hdF90ICAgICAgIG1Gb3JtYXQgPSBBVURJT19GT1JNQVRfREVGQVVMVDsKKyAgICBjb25zdCBhdWRpb19jaGFubmVsX21hc2tfdCBtQ2hhbm5lbE1hc2sgPSBBVURJT19DSEFOTkVMX05PTkU7CisgICAgY29uc3Qgc2l6ZV90ICAgICAgICAgICAgICAgbUZyYW1lQ291bnQgPSAwOworICAg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wb25kaW5nIHRvIHNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBvbiBpbnB1dCB0byBvYnRhaW5CdWZmZXIoKSBpdCBpcyB0aGUgbnVtYmVyIG9mIGZyYW1lcyBkZXNpcmVkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBvbiBvdXRwdXQgZnJvbSBvYnRhaW5CdWZmZXIoKSBpdCBpcyB0aGUgbnVtYmVyIG9mIGF2YWlsYWJsZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gICAgZnJhbWVzIHRvIGJlIHJlYWQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIG9uIGlucHV0IHRvIHJlbGVhc2VCdWZmZXIoKSBpdCBpcyBjdXJyZW50bHkgaWdub3JlZAogCi0gICAgICAgIHNpemVfdCAgICAgIHNpemU7ICAgICAgICAgICAvLyBpbnB1dC9vdXRwdXQgaW4gYnl0ZXMgPT0gZnJhbWVDb3VudCAqIGZyYW1lU2l6ZQorICAgIHByaXZhdGU6CisgICAgICAgIHNpemVfdCAgICAgIG1TaXplOyAgICAgICAgICAvLyBpbnB1dC9vdXRwdXQgaW4gYnl0ZXMgPT0gZnJhbWVDb3VudCAqIGZyYW1lU2l6ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gb24gaW5wdXQgdG8gb2J0YWluQnVmZmVyKCkgaXQgaXMgaWdub3JlZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gb24gb3V0cHV0IGZyb20gb2J0YWluQnVmZmVyKCkgaXQgaXMgdGhlIG51bWJlciBvZiBhdmFpbGFibGUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vICAgIGJ5dGVzIHRvIGJlIHJlYWQsIHdoaWNoIGlzIGZyYW1lQ291bnQgKiBmcmFtZVNpemUKQEAgLTkwLDcgKzk1LDcgQEAKICAgICAgICAgdW5pb24gewogICAgICAgICAgICAgdm9pZCogICAgICAgcmF3OwogICAgICAgICAgICAgaW50MTZfdCogICAgaTE2OyAgICAgICAgLy8gc2lnbmVkIDE2LWJpdAotICAgICAgICAgICAgaW50OF90KiAgICAgaTg7ICAgICAgICAgLy8gdW5zaWduZWQgOC1iaXQsIG9mZnNldCBieSAweDgwCisgICAgICAgICAgICB1aW50OF90KiAgICB1aTg7ICAgICAgICAvLyB1bnNpZ25lZCA4LWJpdCwgb2Zmc2V0IGJ5IDB4ODAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGlucHV0IHRvIG9idGFpbkJ1ZmZlcigpOiB1bnVzZWQsIG91dHB1dDogcG9pbnRlciB0byBidWZmZXIKICAgICAgICAgfTsKIApAQCAtMTE3LDcgKzEyMiwyOCBAQAogICAgICAqICAgICAgICAgIC0gRVZFTlRfTkVXX0lBVURJT1JFQ09SRDogdW51c2VkLgogICAgICAqLwogCi0gICAgdHlwZWRlZiB2b2lkICgqY2FsbGJhY2tfdCkoaW50IGV2ZW50LCB2b2lkKiB1c2VyLCB2b2lkICppbmZvKTsKKyAgICB0eXBlZGVmIHZvaWQgKCpsZWdhY3lfY2FsbGJhY2tfdCkoaW50IGV2ZW50LCB2b2lkKiB1c2VyLCB2b2lkICppbmZvKTsKKworICAgIGNsYXNzIElBdWRpb1JlY29yZENhbGxiYWNrIDogcHVibGljIHZpcnR1YWwgUmVmQmFzZSB7CisgICAgICAgIGZyaWVuZCBBdWRpb1JlY29yZDsKKyAgICAgcHJvdGVjdGVkOgorICAgICAgICAvLyBSZXF1ZXN0IGZvciBjbGllbnQgdG8gcmVhZCBuZXdseSBhdmFpbGFibGUgZGF0YS4KKyAgICAgICAgLy8gVXNlZCBmb3IgVFJBTlNGRVJfQ0FMTEJBQ0sgbW9kZS4KKyAgICAgICAgLy8gUGFyYW1ldGVyczoKKyAgICAgICAgLy8gIC0gYnVmZmVyIDogQnVmZmVyIHRvIHJlYWQgZnJ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BAIC0xODIsMjAgKzIwOCwzNyBAQAogICAgICAqIHBBdHRyaWJ1dGVzOiAgICAgICAgSWYgbm90IE5VTEwsIHN1cGVyc2VkZXMgaW5wdXRTb3VyY2UgZm9yIHVzZSBjYXNlIHNlbGVjdGlvbi4KICAgICAgKiB0aHJlYWRDYW5DYWxsSmF2YTogIE5vdCBwcmVzZW50IGluIHBhcmFtZXRlciBsaXN0LCBhbmQgc28gaXMgZml4ZWQgYXQgZmFsc2UuCiAgICAgICovCi0KICAgICAgICAgICAgICAgICAgICAgICAgIEF1ZGlvUmVjb3JkKGF1ZGlvX3NvdXJjZV90IGlucHV0U291cmNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdWludDMyX3Qgc2FtcGxlUmF0ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX2Zvcm1hdF90IGZvcm1hdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX2NoYW5uZWxfbWFza190IGNoYW5uZWxNYXNrLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYW5kcm9pZDo6Y29udGVudDo6QXR0cmlidXRpb25Tb3VyY2VTdGF0ZSYgY2xpZW50LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90IGZyYW1lQ291bnQgPSAwLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2tfdCBjYmYgPSBOVUxMLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdm9pZCogdXNlciA9IE5VTEwsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3cDxJQXVkaW9SZWNvcmRDYWxsYmFjaz4gJmNhbGxiYWNrID0gbnVsbHB0ciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVpbnQzMl90IG5vdGlmaWNhdGlvbkZyYW1lcyA9IDAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19zZXNzaW9uX3Qgc2Vzc2lvbklkID0gQVVESU9fU0VTU0lPTl9BTExPQ0FURSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zZmVyX3R5cGUgdHJhbnNmZXJUeXBlID0gVFJBTlNGRVJfREVGQVVMVCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX2lucHV0X2ZsYWdzX3QgZmxhZ3MgPSBBVURJT19JTlBVVF9GTEFHX05PTkUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhdWRpb19hdHRyaWJ1dGVzX3QqIHBBdHRyaWJ1dGVzID0gTlVMTCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGF1ZGlvX2F0dHJpYnV0ZXNfdCogcEF0dHJpYnV0ZXMgPSBudWxscHRyLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fcG9ydF9oYW5kbGVfdCBzZWxlY3RlZERldmljZUlkID0gQVVESU9fUE9SVF9IQU5ETEVfTk9ORSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX21pY3JvcGhvbmVfZGlyZWN0aW9uX3QKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RlZE1pY0RpcmVjdGlvbiA9IE1JQ19ESVJFQ1RJT05fVU5TUEVDSUZJRUQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbG9hdCBzZWxlY3RlZE1pY0ZpZWxkRGltZW5zaW9uID0gTUlDX0ZJRUxEX0RJTUVOU0lPTl9ERUZBVUxUKTsKKworCisgICAgICAgICAgICAgICAgICAgICAgICBBdWRpb1JlY29yZChhdWRpb19zb3VyY2VfdCBpbnB1dFNvdXJjZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVpbnQzMl90IHNhbXBsZVJhdGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19mb3JtYXRfdCBmb3JtYXQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19jaGFubmVsX21hc2tfdCBjaGFubmVsTWFzaywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFuZHJvaWQ6OmNvbnRlbnQ6OkF0dHJpYnV0aW9uU291cmNlU3RhdGUmIGNsaWVudCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemVfdCBmcmFtZUNvdW50LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVnYWN5X2NhbGxiYWNrX3QgY2FsbGJhY2ssCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2b2lkKiB1c2VyLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdWludDMyX3Qgbm90aWZpY2F0aW9uRnJhbWVzID0gMCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX3Nlc3Npb25fdCBzZXNzaW9uSWQgPSBBVURJT19TRVNTSU9OX0FMTE9DQVRFLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmZXJfdHlwZSB0cmFuc2ZlclR5cGUgPSBUUkFOU0ZFUl9ERUZBVUxULAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9faW5wdXRfZmxhZ3NfdCBmbGFncyA9IEFVRElPX0lOUFVUX0ZMQUdfTk9ORSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGF1ZGlvX2F0dHJpYnV0ZXNfdCogcEF0dHJpYnV0ZXMgPSBudWxscHRyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fcG9ydF9oYW5kbGVfdCBzZWxlY3RlZERldmljZUlkID0gQVVESU9fUE9SVF9IQU5ETEVfTk9ORSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX21pY3JvcGhvbmVfZGlyZWN0aW9uX3QKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RlZE1pY0RpcmVjdGlvbiA9IE1JQ19ESVJFQ1RJT05fVU5TUEVDSUZJRUQsCkBAIC0yMjMsMTMgKzI2NiwxMiBAQAogICAgICAqCiAgICAgICogdGhyZWFkQ2FuQ2FsbEphdmE6ICBXaGV0aGVyIGNhbGxiYWNrcyBhcmUgbWFkZSBmcm9tIGFuIGF0dGFjaGVkIHRocmVhZCBhbmQgdGh1cyBjYW4gY2FsbCBKTkkuCiAgICAgICovCi0gICAgICAgICAgICBzdGF0dXNfdCAgICBzZXQoYXVkaW9fc291cmNlX3QgaW5wdXRTb3VyY2UsCisgICAgICAgICAgIHN0YXR1c190ICAgIHNldChhdWRpb19zb3VyY2VfdCBpbnB1dFNvdXJjZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aW50MzJfdCBzYW1wbGVSYXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX2Zvcm1hdF90IGZvcm1hdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19jaGFubmVsX21hc2tfdCBjaGFubmVsTWFzaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplX3QgZnJhbWVDb3VudCA9IDAsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2tfdCBjYmYgPSBOVUxMLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZvaWQqIHVzZXIgPSBOVUxMLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdwPElBdWRpb1JlY29yZENhbGxiYWNrPiAmY2FsbGJhY2sgPSBudWxscHRyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVpbnQzMl90IG5vdGlmaWNhdGlvbkZyYW1lcyA9IDAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCB0aHJlYWRDYW5DYWxsSmF2YSA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX3Nlc3Npb25fdCBzZXNzaW9uSWQgPSBBVURJT19TRVNTSU9OX0FMTE9DQVRFLApAQCAtMjM3LDcgKzI3OSwyOCBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX2lucHV0X2ZsYWdzX3QgZmxhZ3MgPSBBVURJT19JTlBVVF9GTEFHX05PTkUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdWlkX3QgdWlkID0gQVVESU9fVUlEX0lOVkFMSUQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGlkX3QgcGlkID0gLTEsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYXVkaW9fYXR0cmlidXRlc190KiBwQXR0cmlidXRlcyA9IE5VTEwsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYXVkaW9fYXR0cmlidXRlc190KiBwQXR0cmlidXRlcyA9IG51bGxwdHIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fcG9ydF9oYW5kbGVfdCBzZWxlY3RlZERldmljZUlkID0gQVVESU9fUE9SVF9IQU5ETEVfTk9ORSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19taWNyb3Bob25lX2RpcmVjdGlvbl90CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkTWljRGlyZWN0aW9uID0gTUlDX0RJUkVDVElPTl9VTlNQRUNJRklFRCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbG9hdCBzZWxlY3RlZE1pY0ZpZWxkRGltZW5zaW9uID0gTUlDX0ZJRUxEX0RJTUVOU0lPTl9ERUZBVUxULAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3QgbWF4U2hhcmVkQXVkaW9IaXN0b3J5TXMgPSAwKTsKKworICAgICAgICAgICBzdGF0dXNfdCAgICBzZXQoYXVkaW9fc291cmNlX3QgaW5wdXRTb3VyY2UsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgdWludDMyX3Qgc2FtcGxlUmF0ZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19mb3JtYXRfdCBmb3JtYXQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fY2hhbm5lbF9tYXNrX3QgY2hhbm5lbE1hc2ssCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90IGZyYW1lQ291bnQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVnYWN5X2NhbGxiYWNrX3QgY2FsbGJhY2ssCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgdm9pZCogdXNlciwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aW50MzJfdCBub3RpZmljYXRpb25GcmFtZXMgPSAwLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgdGhyZWFkQ2FuQ2FsbEphdmEgPSBmYWxzZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19zZXNzaW9uX3Qgc2Vzc2lvbklkID0gQVVESU9fU0VTU0lPTl9BTExPQ0FURSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zlcl90eXBlIHRyYW5zZmVyVHlwZSA9IFRSQU5TRkVSX0RFRkFVTFQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9faW5wdXRfZmxhZ3NfdCBmbGFncyA9IEFVRElPX0lOUFVUX0ZMQUdfTk9ORSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aWRfdCB1aWQgPSBBVURJT19VSURfSU5WQUxJRCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBwaWRfdCBwaWQgPSAtMSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhdWRpb19hdHRyaWJ1dGVzX3QqIHBBdHRyaWJ1dGVzID0gbnVsbHB0ciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19wb3J0X2hhbmRsZV90IHNlbGVjdGVkRGV2aWNlSWQgPSBBVURJT19QT1JUX0hBTkRMRV9OT05FLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX21pY3JvcGhvbmVfZGlyZWN0aW9uX3QKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0ZWRNaWNEaXJlY3Rpb24gPSBNSUNfRElSRUNUSU9OX1VOU1BFQ0lGSUVELApAQCAtNjczLDkgKzczNiwxMSBAQAogICAgIGJvb2wgICAgICAgICAgICAgICAgICAgIG1BY3RpdmU7CiAKICAgICAvLyBmb3IgY2xpZW50IGNhbGxiYWNrIGhhbmRsZXIKLSAgICBjYWxsYmFja190ICAgICAgICAgICAgICBtQ2JmOyAgICAgICAgICAgICAgICAgICAvLyBjYWxsYmFjayBoYW5kbGVyIGZvciBldmVudHMsIG9yIE5VTEwKLSAgICB2b2lkKiAgICAgICAgICAgICAgICAgICBtVXNlckRhdGE7CiAKKyAgICB3cDxJQXVkaW9SZWNvcmRDYWxsYmFjaz4gbUNhbGxiYWNrOworICAgIHNwPElBdWRpb1JlY29yZENhbGxiYWNrPiBtTGVnYWN5Q2FsbGJhY2tXcmFwcGVyOworCisgICAgYm9vbCAgICAgICAgICAgICAgICAgICAgbUluaXRpYWxpemVkID0gZmFsc2U7ICAgLy8gUHJvdGVjdCBhZ2FpbnN0IGRvdWJsZSBzZXQKICAgICAvLyBmb3Igbm90aWZpY2F0aW9uIEFQSXMKICAgICB1aW50MzJfdCAgICAgICAgICAgICAgICBtTm90aWZpY2F0aW9uRnJhbWVzUmVxOyAvLyByZXF1ZXN0ZWQgbnVtYmVyIG9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ICsyNjYsOCBAQAogICAgIC8vIElBdWRpb1BvbGljeVNlcnZpY2UgaW50ZXJmYWNlIChzZWUgQXVkaW9Qb2xpY3lJbnRlcmZhY2UgZm9yIG1ldGhvZCBkZXNjcmlwdGlvbnMpCiAgICAgLy8KICAgICBzdGF0aWMgdm9pZCBvbk5ld0F1ZGlvTW9kdWxlc0F2YWlsYWJsZSgpOwotICAgIHN0YXRpYyBzdGF0dXNfdCBzZXREZXZpY2VDb25uZWN0aW9uU3RhdGUoYXVkaW9fZGV2aWNlc190IGRldmljZSwgYXVkaW9fcG9saWN5X2Rldl9zdGF0ZV90IHN0YXRlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hhciAqZGV2aWNlX2FkZHJlc3MsIGNvbnN0IGNoYXIgKmRldmljZV9uYW1lLAorICAgIHN0YXRpYyBzdGF0dXNfdCBzZXREZXZpY2VDb25uZWN0aW9uU3RhdGUoYXVkaW9fcG9saWN5X2Rldl9zdGF0ZV90IHN0YXRlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYW5kcm9pZDo6bWVkaWE6OmF1ZGlvOjpjb21tb246OkF1ZGlvUG9ydCYgcG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX2Zvcm1hdF90IGVuY29kZWRGb3JtYXQpOwogICAgIHN0YXRpYyBhdWRpb19wb2xpY3lfZGV2X3N0YXRlX3QgZ2V0RGV2aWNlQ29ubmVjdGlvblN0YXRlKGF1ZGlvX2RldmljZXNfdCBkZXZpY2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hhciAqZGV2aWNlX2FkZHJlc3MpOwpAQCAtMjgxLDcgKzI4OCw4IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVka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Y2suaAorKysgYi9tZWRpYS9saWJhdWRpb2NsaWVudC9pbmNsdWRlL21lZGlhL0F1ZGlvVHJhY2suaApAQCAtOTUsMzQgKzk1LDM2IEBACiAKICAgICBjbGFzcyBCdWZmZXIKICAgICB7CisgICAgZnJpZW5kIEF1ZGlvVHJhY2s7CiAgICAgcHVibGljOgotICAgICAgICAvLyBGSVhNRSB1c2UgbSBwcmVmaXgKKyAgICAgICBzaXplX3Qgc2l6ZSgpIGNvbnN0IHsgcmV0dXJuIG1TaXplOyB9CisgICAgICAgc2l6ZV90IGdldEZyYW1lQ291bnQoKSBjb25zdCB7IHJldHVybiBmcmFtZUNvdW50OyB9CisgICAgICAgdWludDhfdCAqIGRhdGEoKSBjb25zdCB7IHJldHVybiB1aTg7IH0KKyAgICAgICAvLyBMZWF2aW5nIHB1YmxpYyBmb3Igbm93IHRvIGVhc2UgcmVmYWN0b3JpbmcuIFRoaXMgY2xhc3Mgd2lsbCBiZQorICAgICAgIC8vIHJlcGxhY2VkCiAgICAgICAgIHNpemVfdCAgICAgIGZyYW1lQ291bnQ7ICAgLy8gbnVtYmVyIG9mIHNhbXBsZSBmcmFtZXMgY29ycmVzcG9uZGluZyB0byBzaXplOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIG9uIGlucHV0IHRvIG9idGFpbkJ1ZmZlcigpIGl0IGlzIHRoZSBudW1iZXIgb2YgZnJhbWVzIGRlc2lyZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gb24gb3V0cHV0IGZyb20gb2J0YWluQnVmZmVyKCkgaXQgaXMgdGhlIG51bWJlciBvZiBhdmFpbGFibGUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyAgICBbZW1wdHkgc2xvdHMgZm9yXSBmcmFtZXMgdG8gYmUgZmlsbGVkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gb24gaW5wdXQgdG8gcmVsZWFzZUJ1ZmZlcigpIGl0IGlzIGN1cnJlbnRseSBpZ25vcmVkCi0KLSAgICAgICAgc2l6ZV90ICAgICAgc2l6ZTsgICAgICAgICAvLyBpbnB1dC9vdXRwdXQgaW4gYnl0ZXMgPT0gZnJhbWVDb3VudCAqIGZyYW1lU2l6ZQorICAgIHByaXZhdGU6CisgICAgICAgIHNpemVfdCAgICAgIG1TaXplOyAgICAgICAgLy8gaW5wdXQvb3V0cHV0IGluIGJ5dGVzID09IGZyYW1lQ291bnQgKiBmcmFtZVNpemUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBvbiBpbnB1dCB0byBvYnRhaW5CdWZmZXIoKSBpdCBpcyBpZ25vcmVkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gb24gb3V0cHV0IGZyb20gb2J0YWluQnVmZmVyKCkgaXQgaXMgdGhlIG51bWJlciBvZiBhdmFpbGFibGUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyAgICBbZW1wdHkgc2xvdHMgZm9yXSBieXRlcyB0byBiZSBmaWxsZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gICAgd2hpY2ggaXMgZnJhbWVDb3VudCAqIGZyYW1lU2l6ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIG9uIGlucHV0IHRvIHJlbGVhc2VCdWZmZXIoKSBpdCBpcyB0aGUgbnVtYmVyIG9mIGJ5dGVzIHRvCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gICAgcmVsZWFzZQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIEZJWE1FIFRoaXMgaXMgcmVkdW5kYW50IHdpdGggcmVzcGVjdCB0byBmcmFtZUNvdW50LiAgQ29uc2lkZXIKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyAgICByZW1vdmluZyBzaXplIGFuZCBtYWtpbmcgZnJhbWVDb3VudCB0aGUgcHJpbWFyeSBmaWVsZC4KIAogICAgICAgICB1bmlvbiB7CiAgICAgICAgICAgICB2b2lkKiAgICAgICByYXc7CiAgICAgICAgICAgICBpbnQxNl90KiAgICBpMTY7ICAgICAgLy8gc2lnbmVkIDE2LWJpdAotICAgICAgICAgICAgaW50OF90KiAgICAgaTg7ICAgICAgIC8vIHVuc2lnbmVkIDgtYml0LCBvZmZzZXQgYnkgMHg4MAorICAgICAgICAgICAgdWludDhfdCogICAgdWk4OyAgICAgIC8vIHVuc2lnbmVkIDgtYml0LCBvZmZzZXQgYnkgMHg4MAogICAgICAgICB9OyAgICAgICAgICAgICAgICAgICAgICAgIC8vIGlucHV0IHRvIG9idGFpbkJ1ZmZlcigpOiB1bnVzZWQsIG91dHB1dDogcG9pbnRlciB0byBidWZmZXIKIAogICAgICAgICB1aW50MzJfdCAgICBzZXF1ZW5jZTsgICAgICAgLy8gSUF1ZGlvVHJhY2sgaW5zdGFuY2Ugc2VxdWVuY2UgbnVtYmVyLCBhcyBvZiBvYnRhaW5CdWZmZXIoKS4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIEl0IGlzIHNldCBieSBvYnRhaW5CdWZmZXIoKSBhbmQgY29uZmlybWVkIGJ5IHJlbGVhc2VCdWZmZXIoKS4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIE5vdCAidXNlci1zZXJ2aWNlYWJsZSIuCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBUT0RPIENvbnNpZGVyIHNwPElNZW1vcnk+IGluc3RlYWQsIG9yIGluIGFkZGl0aW9uIHRvIHRoaXMuCiAgICAgfTsKIAogICAgIC8qIEFzIGEgY29udmVuaWVuY2UsIGlmIGEgY2FsbGJhY2sgaXMgc3VwcGxpZWQsIGEgaGFuZGxlciB0aHJlYWQKQEAgLTE0Niw3ICsxNDgsNzkgQEAKICAgICAgKiAgICAgICAgICAtIEVWRU5UX05FV19USU1FU1RBTVA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3JlRGF0YShbW21heWJlX3VudXNlZF1dIGNvbnN0IEF1ZGlvVHJhY2s6OkJ1ZmZlciYgYnVmZmVyKSB7CisgICAgICAgICAgICByZXR1cm4gMDsKKyAgICAgICAgfQorICAgIH07CiAKICAgICAvKiBSZXR1cm5zIHRoZSBtaW5pbXVtIGZyYW1lIGNvdW50IHJlcXVpcmVkIGZvciB0aGUgc3VjY2Vzc2Z1bCBjcmVhdGlvbiBvZgogICAgICAqIGFuIEF1ZGlvVHJhY2sgb2JqZWN0LgpAQCAtMjU3LDE1ICszMzEsMzQgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX2NoYW5uZWxfbWFza190IGNoYW5uZWxNYXNrLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90IGZyYW1lQ291bnQgICAgPSAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fb3V0cHV0X2ZsYWdzX3QgZmxhZ3MgPSBBVURJT19PVVRQVVRfRkxBR19OT05FLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2tfdCBjYmYgICAgICAgPSBOVUxMLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdm9pZCogdXNlciAgICAgICAgICAgPSBOVUxMLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd3A8SUF1ZGlvVHJhY2tDYWxsYmFjaz4mIGNhbGxiYWNrID0gbnVsbHB0ciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3Qgbm90aWZpY2F0aW9uRnJhbWVzID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX3Nlc3Npb25fdCBzZXNzaW9uSWQgID0gQVVESU9fU0VTU0lPTl9BTExPQ0FURSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zZmVyX3R5cGUgdHJhbnNmZXJUeXBlID0gVFJBTlNGRVJfREVGQVVMVCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGF1ZGlvX29mZmxvYWRfaW5mb190ICpvZmZsb2FkSW5mbyA9IE5VTEwsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhdWRpb19vZmZsb2FkX2luZm9fdCAqb2ZmbG9hZEluZm8gPSBudWxscHRyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQXR0cmlidXRpb25Tb3VyY2VTdGF0ZSYgYXR0cmlidXRpb25Tb3VyY2UgPQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEF0dHJpYnV0aW9uU291cmNlU3RhdGUoKSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGF1ZGlvX2F0dHJpYnV0ZXNfdCogcEF0dHJpYnV0ZXMgPSBOVUxMLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYXVkaW9fYXR0cmlidXRlc190KiBwQXR0cmlidXRlcyA9IG51bGxwdHIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIGRvTm90UmVjb25uZWN0ID0gZmFsc2UsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbG9hdCBtYXhSZXF1aXJlZFNwZWVkID0gMS4wZiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX3BvcnRfaGFuZGxlX3Qgc2VsZWN0ZWREZXZpY2VJZCA9IEFVRElPX1BPUlRfSEFORExFX05PTkUpOworCisKKyAgICAgICAgICAgICAgICAgICAgICAgIEF1ZGlvVHJhY2soIGF1ZGlvX3N0cmVhbV90eXBlX3Qgc3RyZWFtVHlwZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVpbnQzMl90IHNhbXBsZVJhdGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19mb3JtYXRfdCBmb3JtYXQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19jaGFubmVsX21hc2tfdCBjaGFubmVsTWFzaywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemVfdCBmcmFtZUNvdW50LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fb3V0cHV0X2ZsYWdzX3QgZmxhZ3MsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZWdhY3lfY2FsbGJhY2tfdCBjYmYsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2b2lkKiB1c2VyID0gbnVsbHB0ciwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3Qgbm90aWZpY2F0aW9uRnJhbWVzID0gMCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX3Nlc3Npb25fdCBzZXNzaW9uSWQgID0gQVVESU9fU0VTU0lPTl9BTExPQ0FURSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zZmVyX3R5cGUgdHJhbnNmZXJUeXBlID0gVFJBTlNGRVJfREVGQVVMVCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGF1ZGlvX29mZmxvYWRfaW5mb190ICpvZmZsb2FkSW5mbyA9IG51bGxwdHIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBBdHRyaWJ1dGlvblNvdXJjZVN0YXRlJiBhdHRyaWJ1dGlvblNvdXJjZSA9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQXR0cmlidXRpb25Tb3VyY2VTdGF0ZSgpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYXVkaW9fYXR0cmlidXRlc190KiBwQXR0cmlidXRlcyA9IG51bGxwdHIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIGRvTm90UmVjb25uZWN0ID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbG9hdCBtYXhSZXF1aXJlZFNwZWVkID0gMS4wZiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX3BvcnRfaGFuZGxlX3Qgc2VsZWN0ZWREZXZpY2VJZCA9IEFVRElPX1BPUlRfSEFORExFX05PTkUpOwpAQCAtMjgxLDIyICszNzQsMzkgQEAKICAgICAgKiBJdCBpcyByZWNvbW1lbmRlZCB0byBwYXNzIGEgY2FsbGJhY2sgZnVuY3Rpb24gdG8gYmUgbm90aWZpZWQgb2YgcGxheWJhY2sgZW5kIGJ5IGFuCiAgICAgICogRVZFTlRfVU5ERVJSVU4gZXZlbnQuCiAgICAgICovCi0KICAgICAgICAgICAgICAgICAgICAgICAgIEF1ZGlvVHJhY2soIGF1ZGlvX3N0cmVhbV90eXBlX3Qgc3RyZWFtVHlwZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVpbnQzMl90IHNhbXBsZVJhdGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19mb3JtYXRfdCBmb3JtYXQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19jaGFubmVsX21hc2tfdCBjaGFubmVsTWFzaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNwPElNZW1vcnk+JiBzaGFyZWRCdWZmZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19vdXRwdXRfZmxhZ3NfdCBmbGFncyA9IEFVRElPX09VVFBVVF9GTEFHX05PTkUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFja190IGNiZiAgICAgID0gTlVMTCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZvaWQqIHVzZXIgICAgICAgICAgPSBOVUxMLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd3A8SUF1ZGlvVHJhY2tDYWxsYmFjaz4mIGNhbGxiYWNrID0gbnVsbHB0ciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3Qgbm90aWZpY2F0aW9uRnJhbWVzID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX3Nlc3Npb25fdCBzZXNzaW9uSWQgICA9IEFVRElPX1NFU1NJT05fQUxMT0NBVEUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zlcl90eXBlIHRyYW5zZmVyVHlwZSA9IFRSQU5TRkVSX0RFRkFVTFQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhdWRpb19vZmZsb2FkX2luZm9fdCAqb2ZmbG9hZEluZm8gPSBOVUxMLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYXVkaW9fb2ZmbG9hZF9pbmZvX3QgKm9mZmxvYWRJbmZvID0gbnVsbHB0ciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IEF0dHJpYnV0aW9uU291cmNlU3RhdGUmIGF0dHJpYnV0aW9uU291cmNlID0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBdHRyaWJ1dGlvblNvdXJjZVN0YXRlKCksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhdWRpb19hdHRyaWJ1dGVzX3QqIHBBdHRyaWJ1dGVzID0gTlVMTCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGF1ZGlvX2F0dHJpYnV0ZXNfdCogcEF0dHJpYnV0ZXMgPSBudWxscHRyLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBkb05vdFJlY29ubmVjdCA9IGZhbHNlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmxvYXQgbWF4UmVxdWlyZWRTcGVlZCA9IDEuMGYpOworCisKKyAgICAgICAgICAgICAgICAgICAgICAgIEF1ZGlvVHJhY2soIGF1ZGlvX3N0cmVhbV90eXBlX3Qgc3RyZWFtVHlwZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVpbnQzMl90IHNhbXBsZVJhdGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19mb3JtYXRfdCBmb3JtYXQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19jaGFubmVsX21hc2tfdCBjaGFubmVsTWFzaywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNwPElNZW1vcnk+JiBzaGFyZWRCdWZmZXIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19vdXRwdXRfZmxhZ3NfdCBmbGFncywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlZ2FjeV9jYWxsYmFja190IGNiZiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZvaWQqIHVzZXIgICAgICAgICAgPSBudWxscHRyLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBub3RpZmljYXRpb25GcmFtZXMgPSAwLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fc2Vzc2lvbl90IHNlc3Npb25JZCAgID0gQVVESU9fU0VTU0lPTl9BTExPQ0FURSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zZmVyX3R5cGUgdHJhbnNmZXJUeXBlID0gVFJBTlNGRVJfREVGQVVMVCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGF1ZGlvX29mZmxvYWRfaW5mb190ICpvZmZsb2FkSW5mbyA9IG51bGxwdHIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBBdHRyaWJ1dGlvblNvdXJjZVN0YXRlJiBhdHRyaWJ1dGlvblNvdXJjZSA9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQXR0cmlidXRpb25Tb3VyY2VTdGF0ZSgpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYXVkaW9fYXR0cmlidXRlc190KiBwQXR0cmlidXRlcyA9IG51bGxwdHIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIGRvTm90UmVjb25uZWN0ID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbG9hdCBtYXhSZXF1aXJlZFNwZWVkID0gMS4wZik7CiAKQEAgLTMzNCwyMCArNDQ0LDczIEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fY2hhbm5lbF9tYXNrX3QgY2hhbm5lbE1hc2ssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90IGZyYW1lQ291bnQgICA9IDAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fb3V0cHV0X2ZsYWdzX3QgZmxhZ3MgPSBBVURJT19PVVRQVVRfRkxBR19OT05FLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrX3QgY2JmICAgICAgPSBOVUxMLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZvaWQqIHVzZXIgICAgICAgICAgPSBOVUxMLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdwPElBdWRpb1RyYWNrQ2FsbGJhY2s+JiBjYWxsYmFjayA9IG51bGxwdHIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBub3RpZmljYXRpb25GcmFtZXMgPSAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNwPElNZW1vcnk+JiBzaGFyZWRCdWZmZXIgPSAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgdGhyZWFkQ2FuQ2FsbEphdmEgPSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19zZXNzaW9uX3Qgc2Vzc2lvbklkICA9IEFVRElPX1NFU1NJT05fQUxMT0NBVEUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmZXJfdHlwZSB0cmFuc2ZlclR5cGUgPSBUUkFOU0ZFUl9ERUZBVUxULAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGF1ZGlvX29mZmxvYWRfaW5mb190ICpvZmZsb2FkSW5mbyA9IE5VTEwsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYXVkaW9fb2ZmbG9hZF9pbmZvX3QgKm9mZmxvYWRJbmZvID0gbnVsbHB0ciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBBdHRyaWJ1dGlvblNvdXJjZVN0YXRlJiBhdHRyaWJ1dGlvblNvdXJjZSA9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEF0dHJpYnV0aW9uU291cmNlU3RhdGUoKSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhdWRpb19hdHRyaWJ1dGVzX3QqIHBBdHRyaWJ1dGVzID0gTlVMTCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhdWRpb19hdHRyaWJ1dGVzX3QqIHBBdHRyaWJ1dGVzID0gbnVsbHB0ciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIGRvTm90UmVjb25uZWN0ID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmxvYXQgbWF4UmVxdWlyZWRTcGVlZCA9IDEuMGYsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fcG9ydF9oYW5kbGVfdCBzZWxlY3RlZERldmljZUlkID0gQVVESU9fUE9SVF9IQU5ETEVfTk9ORSk7CisKKyAgICAgICAgICAgIHN0cnVjdCBTZXRQYXJhbXMgeworICAgICAgICAgICAgICAgIGF1ZGlvX3N0cmVhbV90eXBlX3Qgc3RyZWFtVHlwZTsKKyAgICAgICAgICAgICAgICB1aW50MzJfdCBzYW1wbGVSYXRlOworICAgICAgICAgICAgICAgIGF1ZGlvX2Zvcm1hdF90IGZvcm1hdDsKKyAgICAgICAgICAgICAgICBhdWRpb19jaGFubmVsX21hc2tfdCBjaGFubmVsTWFzazsKKyAgICAgICAgICAgICAgICBzaXplX3QgZnJhbWVDb3VudDsKKyAgICAgICAgICAgICAgICBhdWRpb19vdXRwdXRfZmxhZ3NfdCBmbGFnczsKKyAgICAgICAgICAgICAgICB3cDxJQXVkaW9UcmFja0NhbGxiYWNrPiBjYWxsYmFjazsKKyAgICAgICAgICAgICAgICBpbnQzMl90IG5vdGlmaWNhdGlvbkZyYW1lczsKKyAgICAgICAgICAgICAgICBzcDxJTWVtb3J5PiBzaGFyZWRCdWZmZXI7CisgICAgICAgICAgICAgICAgYm9vbCB0aHJlYWRDYW5DYWxsSmF2YTsKKyAgICAgICAgICAgICAgICBhdWRpb19zZXNzaW9uX3Qgc2Vzc2lvbklkOworICAgICAgICAgICAgICAgIHRyYW5zZmVyX3R5cGUgdHJhbnNmZXJUeXBlOworICAgICAgICAgICAgICAgIC8vIFRPRE8gZG9uJ3QgdGFrZSBwb2ludGVycyBoZXJlCisgICAgICAgICAgICAgICAgY29uc3QgYXVkaW9fb2ZmbG9hZF9pbmZvX3QgKm9mZmxvYWRJbmZvOworICAgICAgICAgICAgICAgIEF0dHJpYnV0aW9uU291cmNlU3RhdGUgYXR0cmlidXRpb25Tb3VyY2U7CisgICAgICAgICAgICAgICAgY29uc3QgYXVkaW9fYXR0cmlidXRlc190KiBwQXR0cmlidXRlczsKKyAgICAgICAgICAgICAgICBib29sIGRvTm90UmVjb25uZWN0OworICAgICAgICAgICAgICAgIGZsb2F0IG1heFJlcXVpcmVkU3BlZWQ7CisgICAgICAgICAgICAgICAgYXVkaW9fcG9ydF9oYW5kbGVfdCBzZWxlY3RlZERldmljZUlkOworICAgICAgICAgICAgfTsKKyAgICAgICAgcHJpdmF0ZToKKyAgICAgICAgICAgIC8vIE5vdGU6IENvbnN1bWVzIHBhcmFtZXRlcnMKKyAgICAgICAgICAgIHZvaWQgICAgICAgIHNldChTZXRQYXJhbXMmIHMpIHsKKyAgICAgICAgICAgICAgICAodm9pZClzZXQocy5zdHJlYW1UeXBlLCBzLnNhbXBsZVJhdGUsIHMuZm9ybWF0LCBzLmNoYW5uZWxNYXNrLCBzLmZyYW1lQ291bnQsCisgICAgICAgICAgICAgICAgICAgICAgICAgIHMuZmxhZ3MsIHN0ZDo6bW92ZShzLmNhbGxiYWNrKSwgcy5ub3RpZmljYXRpb25GcmFtZXMsCisgICAgICAgICAgICAgICAgICAgICAgICAgIHN0ZDo6bW92ZShzLnNoYXJlZEJ1ZmZlciksIHMudGhyZWFkQ2FuQ2FsbEphdmEsIHMuc2Vzc2lvbklkLAorICAgICAgICAgICAgICAgICAgICAgICAgICBzLnRyYW5zZmVyVHlwZSwgcy5vZmZsb2FkSW5mbywgc3RkOjptb3ZlKHMuYXR0cmlidXRpb25Tb3VyY2UpLAorICAgICAgICAgICAgICAgICAgICAgICAgICBzLnBBdHRyaWJ1dGVzLCBzLmRvTm90UmVjb25uZWN0LCBzLm1heFJlcXVpcmVkU3BlZWQsIHMuc2VsZWN0ZWREZXZpY2VJZCk7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB2b2lkICAgICAgIG9uRmlyc3RSZWYoKSBvdmVycmlkZTsKKyAgICAgICAgcHVibGljOgorICAgICAgICAgICAgc3RhdHVzX3QgICAgc2V0KGF1ZGlvX3N0cmVhbV90eXBlX3Qgc3RyZWFtVHlwZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aW50MzJfdCBzYW1wbGVSYXRlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX2Zvcm1hdF90IGZvcm1hdCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19jaGFubmVsX21hc2tfdCBjaGFubmVsTWFzaywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplX3QgZnJhbWVDb3VudCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19vdXRwdXRfZmxhZ3NfdCBmbGFncywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZWdhY3lfY2FsbGJhY2tfdCBjYWxsYmFjaywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB2b2lkICogdXNlciA9IG51bGxwdHIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBub3RpZmljYXRpb25GcmFtZXMgPSAwLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNwPElNZW1vcnk+JiBzaGFyZWRCdWZmZXIgPSAwLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgdGhyZWFkQ2FuQ2FsbEphdmEgPSBmYWxzZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19zZXNzaW9uX3Qgc2Vzc2lvbklkICA9IEFVRElPX1NFU1NJT05fQUxMT0NBVEUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmZXJfdHlwZSB0cmFuc2ZlclR5cGUgPSBUUkFOU0ZFUl9ERUZBVUxULAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGF1ZGlvX29mZmxvYWRfaW5mb190ICpvZmZsb2FkSW5mbyA9IG51bGxwdHIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQXR0cmlidXRpb25Tb3VyY2VTdGF0ZSYgYXR0cmlidXRpb25Tb3VyY2UgPQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBdHRyaWJ1dGlvblNvdXJjZVN0YXRlKCksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYXVkaW9fYXR0cmlidXRlc190KiBwQXR0cmlidXRlcyA9IG51bGxwdHIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBkb05vdFJlY29ubmVjdCA9IGZhbHNlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZsb2F0IG1heFJlcXVpcmVkU3BlZWQgPSAxLjBmLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX3BvcnRfaGFuZGxlX3Qgc2VsZWN0ZWREZXZpY2VJZCA9IEFVRElPX1BPUlRfSEFORExFX05PTkUpOworCiAgICAgLy8gRklYTUUoYi8xNjk4ODk3MTQpOiBWZW5kb3IgY29kZSBkZXBlbmRzIG9uIHRoZSBvbGQgbWV0aG9kIHNpZ25hdHVyZSBhdCBsaW5rIHRpbWUKICAgICAgICAgICAgIHN0YXR1c190ICAgIHNldChhdWRpb19zdHJlYW1fdHlwZV90IHN0cmVhbVR5cGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdWludDMyX3Qgc2FtcGxlUmF0ZSwKQEAgLTM1NSwxNyArNTE4LDE3IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdWludDMyX3QgY2hhbm5lbE1hc2ssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90IGZyYW1lQ291bnQgICA9IDAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fb3V0cHV0X2ZsYWdzX3QgZmxhZ3MgPSBBVURJT19PVVRQVVRfRkxBR19OT05FLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrX3QgY2JmICAgICAgPSBOVUxMLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZvaWQqIHVzZXIgICAgICAgICAgPSBOVUxMLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlZ2FjeV9jYWxsYmFja190IGNiZiA9IG51bGxwdHIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgdm9pZCogdXNlciAgICAgICAgICA9IG51bGxwdHIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBub3RpZmljYXRpb25GcmFtZXMgPSAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNwPElNZW1vcnk+JiBzaGFyZWRCdWZmZXIgPSAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgdGhyZWFkQ2FuQ2FsbEphdmEgPSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19zZXNzaW9uX3Qgc2Vzc2lvbklkICA9IEFVRElPX1NFU1NJT05fQUxMT0NBVEUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmZXJfdHlwZSB0cmFuc2ZlclR5cGUgPSBUUkFOU0ZFUl9ERUZBVUxULAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGF1ZGlvX29mZmxvYWRfaW5mb190ICpvZmZsb2FkSW5mbyA9IE5VTEwsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYXVkaW9fb2ZmbG9hZF9pbmZvX3QgKm9mZmxvYWRJbmZvID0gbnVsbHB0ciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aWRfdCB1aWQgPSBBVURJT19VSURfSU5WQUxJRCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwaWRfdCBwaWQgPSAtMSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhdWRpb19hdHRyaWJ1dGVzX3QqIHBBdH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XVkaW9jbGllbnQvdGVzdHMvQW5kcm9pZC5icCBiL21lZGlhL2xpYmF1ZGlvY2xpZW50L3Rlc3RzL0FuZHJvaWQuYnAKaW5kZXggZGVmN2NhNi4uODkxMjkzZSAxMDA2NDQKLS0tIGEvbWVkaWEvbGliYXVkaW9jbGllbnQvdGVzdHMvQW5kcm9pZC5icAorKysgYi9tZWRpYS9saWJhdWRpb2NsaWVudC90ZXN0cy9BbmRyb2lkLmJwCkBAIC05LDEwICs5LDM1IEBACiAKIGNjX2RlZmF1bHRzIHsKICAgICBuYW1lOiAibGliYXVkaW9jbGllbnRfdGVzdHNfZGVmYXVsdHMiLAorICAgIHRlc3Rfc3VpdGVzOiBbImRldmljZS10ZXN0cyJdLAogICAgIGNmbGFnczogWwogICAgICAgICAiLVdhbGwiLAogICAgICAgICAiLVdlcnJvciIsCiAgICAgXSwKKyAgICBzYW5pdGl6ZTogeworICAgICAgICBtaXNjX3VuZGVmaW5lZDogWworICAgICAgICAgICAgInVuc2lnbmVkLWludGVnZXItb3ZlcmZsb3ciLAorICAgICAgICAgICAgInNpZ25lZC1pbnRlZ2VyLW92ZXJmbG93IiwKKyAgICAgICAgXSwKKyAgICB9LAorfQorCitjY190ZXN0IHsKKyAgICBuYW1lOiAiYXVkaW9fYWlkbF9jb252ZXJzaW9uX3Rlc3RzIiwKKyAgICBkZWZhdWx0czogWyJsaWJhdWRpb2NsaWVudF90ZXN0c19kZWZhdWx0cyJdLAorICAgIHNyY3M6IFsiYXVkaW9fYWlkbF9sZWdhY3lfY29udmVyc2lvbl90ZXN0cy5jcHAiXSwKKyAgICBzaGFyZWRfbGliczogWworICAgICAgICAibGliYmluZGVyIiwKKyAgICAgICAgImxpYmN1dGlscyIsCisgICAgICAgICJsaWJsb2ciLAorICAgICAgICAibGlidXRpbHMiLAorICAgIF0sCisgICAgc3RhdGljX2xpYnM6IFsKKyAgICAgICAgImFuZHJvaWQubWVkaWEuYXVkaW8uY29tbW9uLnR5cGVzLVYxLWNwc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SBudW1lcmljYWwgcmVwcmVzZW50YXRpb24gYXMgTWFzayAnQicgYmVsb3cKKyAgICAgICAgICAgICAgICAgICAgICAgIEFVRElPX0NIQU5ORUxfT1VUX0ZST05UX0NFTlRFUiB8IEFVRElPX0NIQU5ORUxfT1VUX0xPV19GUkVRVUVOQ1kgfAorICAgICAgICAgICAgICAgICAgICAgICAgQVVESU9fQ0hBTk5FTF9PVVRfVE9QX0JBQ0tfTEVGVCwgZmFsc2UsIHRydWUpLAorICAgICAgICAgICAgICAgIC8vIEludmFsaWQgbGVnYWN5IGlucHV0IG1hc2tzLgorICAgICAgICAgICAgICAgIHN0ZDo6bWFrZV90dXBsZShBVURJT19DSEFOTkVMX0lOXzYsIHRydWUsIGZhbHNlKSwKKyAgICAgICAgICAgICAgICBzdGQ6Om1ha2VfdHVwbGUoCisgICAgICAgICAgICAgICAgICAgICAgICBBVURJT19DSEFOTkVMX0lOXzYgfCBBVURJT19DSEFOTkVMX0lOX0ZST05UX1BST0NFU1NFRCwgdHJ1ZSwgZmFsc2UpLAorICAgICAgICAgICAgICAgIHN0ZDo6bWFrZV90dXBsZSgKKyAgICAgICAgICAgICAgICAgICAgICAgIEFVRElPX0NIQU5ORUxfSU5fUFJFU1NVUkUgfCBBVURJT19DSEFOTkVMX0lOX1hfQVhJUyB8CisgICAgICAgICAgICAgICAgICAgICAgICBBVURJT19DSEFOTkVMX0lOX1lfQVhJUyB8IEFVRElPX0NIQU5ORUxfSU5fWl9BWElTLCB0cnVlLCBmYWxzZSksCisgICAgICAgICAgICAgICAgc3RkOjptYWtlX3R1cGxlKCAgLy8gTWFzayAnQScKKyAgICAgICAgICAgICAgICAgICAgICAgIEFVRElPX0NIQU5ORUxfSU5fU1RFUkVPIHwgQVVESU9fQ0hBTk5FTF9JTl9WT0lDRV9VUExJTkssIHRydWUsIGZhbHNlKSwKKyAgICAgICAgICAgICAgICBzdGQ6Om1ha2VfdHVwbGUoICAvLyBNYXNrICdCJworICAgICAgICAgICAgICAgIC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AgICAgICAgICAgc2FtcGxlUmF0ZSwKICAgICAgICAgICAgICAgICAgICBmb3JtYXQsCiAgICAgICAgICAgICAgICAgICAgY2hhbm5lbE1hc2ssCiAgICAgICAgICAgICAgICAgICAgZnJhbWVDb3VudCwKICAgICAgICAgICAgICAgICAgICBmbGFncywKLSAgICAgICAgICAgICAgICAgICAoZmFzdCB8fCBvZmZsb2FkKSA/IGNhbGxiYWNrIDogbnVsbHB0ciwKLSAgICAgICAgICAgICAgICAgICBudWxscHRyLAorICAgICAgICAgICAgICAgICAgIChmYXN0IHx8IG9mZmxvYWQpID8gZW1wdHlDYWxsYmFjayA6IG51bGxwdHIsCiAgICAgICAgICAgICAgICAgICAgbm90aWZpY2F0aW9uRnJhbWVzLAogICAgICAgICAgICAgICAgICAgIHNoYXJlZEJ1ZmZlciwKICAgICAgICAgICAgICAgICAgICBmYWxzZSwKQEAgLTEyNiw4ICsxMjUsNyBAQAogICAgICAgICAgICAgICAgICAgICgoZmFzdCAmJiBzaGFyZWRCdWZmZXIgPT0gMCkgfHwgb2ZmbG9hZCkgPwogICAgICAgICAgICAgICAgICAgICAgICAgICAgQXVkaW9UcmFjazo6VFJBTlNGRVJfQ0FMTEJBQ0sgOiBBdWRpb1RyYWNrOjpUUkFOU0ZFUl9ERUZBVUxULAogICAgICAgICAgICAgICAgICAgIG9mZmxvYWQgPyAmb2ZmbG9hZEluZm8gOiBudWxscHRyLAotICAgICAgICAgICAgICAgICAgIGdldHVpZCgpLAotICAgICAgICAgICAgICAgICAgIGdldHBpZCgpLAorICAgICAgICAgICAgICAgICAgIEF0dHJpYnV0aW9uU291cmNlU3RhdGUoKSwKICAgICAgICAgICAgICAgICAgICAmYXR0cmlidXRlcywKICAgICAgICAgICAgICAgICAgICBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAxLjBmLApkaWZmIC0tZ2l0IGEvbWVkaWEvbGliYXVkaW9jbGllbnQvdGVzdHMvdGVzdF9jcmVhdGVfdXRpbHMuY3BwIGIvbW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pdCA9IGRldmljZVR5cGVzLmJlZ2luKCk7IGl0ICE9IGRldmljZVR5cGVzLmVuZCgpOykgewotICAgICAgICBzdGQ6OnN0cmluZyBkZXZpY2VUeXBlU3RyOwotICAgICAgICByZXQgPSBhdWRpb19pc19vdXRwdXRfZGV2aWNlKCppdCkgPwotICAgICAgICAgICAgICBPdXRwdXREZXZpY2VDb252ZXJ0ZXI6OnRvU3RyaW5nKCppdCwgZGV2aWNlVHlwZVN0cikgOgotICAgICAgICAgICAgICBJbnB1dERldmljZUNvbnZlcnRlcjo6dG9TdHJpbmcoKml0LCBkZXZpY2VUeXBlU3RyKTsKLSAgICAgICAgaWYgKCFyZXQpIHsKLSAgICAgICAgICAgIGJyZWFrOworICAgIHN0ZDo6c3RyaW5nc3RyZWFtIHNzOworICAgIGZvciAoYXV0byBpdCA9IGRldmljZVR5cGVzLmJlZ2luKCk7IGl0ICE9IGRldmljZVR5cGVzLmVuZCgpOyArK2l0KSB7CisgICAgICAgIGlmIChpdCAhPSBkZXZpY2VUeXBlcy5iZWdpbigpKSB7CisgICAgICAgICAgICBzcyA8PCAiLCAiOwogICAgICAgICB9Ci0gICAgICAgIHN0ci5hcHBlbmQoZGV2aWNlVHlwZVN0cik7Ci0gICAgICAgIGlmICgrK2l0ICE9IGRldmljZVR5cGVzLmVuZCgpKSB7Ci0gICAgICAgICAgICBzdHIuYXBwZW5kKCIgLCAiKTsKKyAgICAgICAgY29uc3QgY2hhciogc3RyVHlwZSA9IGF1ZGlvX2RldmljZV90b19zdHJpbmcoKml0KTsKKyAgICAgICAgaWYgKHN0cmxlbihzdHJUeXBlKSAhPSAwKSB7CisgICAgICAgICAgICBzcyA8PCBzdHJUeXBlOworICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgc3MgPDwgInVua25vd24gdHlwZToweCIgPDwgc3RkOjpoZXggPDwgKml0OwogICAgICAgICB9CiAgICAgfQotICAgIGlmICghcmV0KSB7Ci0gICAgICAgIHN0ciA9ICJVbmtub3duIHZ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OmF1ZGlvOjpjb21tb246OkF1ZGlvUG9ydEV4dDo6bWl4PigpOworICAgICAgICBtYXhPcGVuQ291bnQgPSBtaXhFeHQubWF4T3BlblN0cmVhbUNvdW50OworICAgICAgICBtYXhBY3RpdmVDb3VudCA9IG1peEV4dC5tYXhBY3RpdmVTdHJlYW1Db3VudDsKKyAgICAgICAgcmVjb21tZW5kZWRNdXRlRHVyYXRpb25NcyA9IG1peEV4dC5yZWNvbW1lbmRlZE11dGVEdXJhdGlvbk1zOworICAgIH0KICAgICByZXR1cm4gT0s7CiB9CiAKQEAgLTI1MCw2ICsyOTIsOSBAQAogICAgIGlmIChjb25maWctPmNvbmZpZ19tYXNrICYgQVVESU9fUE9SVF9DT05GSUdfR0FJTikgewogICAgICAgICBtR2FpbiA9IGNvbmZpZy0+Z2FpbjsKICAgICB9CisgICAgaWYgKGNvbmZpZy0+Y29uZmlnX21hc2sgJiBBVURJT19QT1JUX0NPTkZJR19GTEFHUykgeworICAgICAgICBtRmxhZ3MgPSBjb25maWctPmZsYWdzOworICAgIH0KIAogICAgIHJldHVybiBOT19FUlJPUjsKIH0KQEAgLTMwMyw2ICszNDgsOSBAQAogICAgIH0gZWxzZSB7CiAgICAgICAgIGRzdENvbmZpZy0+Y29uZmlnX21hc2sgJj0gfkFVRElPX1BPUlRfQ09ORklHX0dBSU47CiAgICAgfQorCisgICAgdXBkYXRlRmllbGQobUZsYWdzLCAmYXVkaW9fcG9ydF9jb25maWc6OmZsYWdzLAorICAgICAgICAgICAgZHN0Q29uZmlnLCBzcmNDb25maWcsIEFVRElPX1BPUlRfQ09ORklHX0ZMQUdTLCB7IEFVRElPX0lOUFVUX0ZMQUdfTk9ORSB9KTsKIH0KIAogYm9vbCBBdWRpb1BvcnRDb25maWc6Omhhc0dhaW5Db250cm9sbGVyKGJvb2wgY2FuVXNlRm9yVm9sdW1lKSBjb25zdApAQCAtMzE1LDEyICszNjMsMTQgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgIDogYX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zY3JpcHRvcnMoKSB7CiAgICAgICAgIHJldHVybiBtRXh0cmFBdWRpb0Rlc2NyaXB0b3JzOwogICAgIH0KIApAQCAtOTMsMTkgKzk2LDQ3IEBACiAgICAgICAgICAgICAgICAgKChtVHlwZSA9PSBBVURJT19QT1JUX1RZUEVfTUlYKSAmJiAobVJvbGUgPT0gQVVESU9fUE9SVF9ST0xFX1NJTkspKTsKICAgICB9CiAKLSAgICB2b2lkIGR1bXAoc3RkOjpzdHJpbmcgKmRzdCwgaW50IHNwYWNlcywgYm9vbCB2ZXJib3NlID0gdHJ1ZSkgY29uc3Q7CisgICAgYm9vbCBpc0RpcmVjdE91dHB1dCgpIGNvbnN0CisgICAgeworICAgICAgICByZXR1cm4gKG1UeXBlID09IEFVRElPX1BPUlRfVFlQRV9NSVgpICYmIChtUm9sZSA9PSBBVURJT19QT1JUX1JPTEVfU09VUkNFKSAmJgorICAgICAgICAgICAgICAgICgobUZsYWdzLm91dHB1dCAmIEFVRElPX09VVFBVVF9GTEFHX0RJUkVDVCkgIT0gMCk7CisgICAgfQorCisgICAgYm9vbCBpc01tYXAoKSBjb25zdAorICAgIHsKKyAgICAgICAgcmV0dXJuIChtVHlwZSA9PSBBVURJT19QT1JUX1RZUEVfTUlYKQorICAgICAgICAgICAgICAgICYmICgoKG1Sb2xlID09IEFVRElPX1BPUlRfUk9MRV9TT1VSQ0UpICYmCisgICAgICAgICAgICAgICAgICAgICAgICAoKG1GbGFncy5vdXRwdXQgJiBBVURJT19PVVRQVVRfRkxBR19NTUFQX05PSVJRKSAhPSAwKSkKKyAgICAgICAgICAgICAgICAgICAgfHwgKChtUm9sZSA9PSBBVURJT19QT1JUX1JPTEVfU0lOSykgJiYKKyAgICAgICAgICAgICAgICAgICAgICAgICgobUZsYWdzLmlucHV0ICYgQVVESU9fSU5QVVRfRkxBR19NTUFQX05PSVJRKSAhPSAwKSkpOworICAgIH0KKworICAgIHZvaWQgZHVtcChzdGQ6OnN0cmluZyAqZHN0LCBpbn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IaWRsLmNwcCIsCi0gICAgICAgICJFZmZlY3RCdWZmZXJIYWxIaWRsLmNwcCIsCi0gICAgICAgICJFZmZlY3RIYWxIaWRsLmNwcCIsCi0gICAgICAgICJFZmZlY3RzRmFjdG9yeUhhbEhpZGwuY3BwIiwKICAgICAgICAgIlN0cmVhbUhhbEhpZGwuY3BwIiwKICAgICBdLAorfQorCitmaWxlZ3JvdXAgeworICAgIG5hbWU6ICJhdWRpb19lZmZlY3RfaGFsX2NsaWVudF9zb3VyY2VzIiwKKyAgICBzcmNzOiBbCisgICAgICAgICJFZmZlY3RCdWZmZXJIYWxIaWRsLmNwcCIsCisgICAgICAgICJFZmZlY3RDb252ZXJzaW9uSGVscGVySGlkbC5jcHAiLAorICAgICAgICAiRWZmZWN0SGFsSGlkbC5jcHAiLAorICAgICAgICAiRWZmZWN0c0ZhY3RvcnlIYWxIaWRsLmNwcCIsCisgICAgXSwKK30KKworY2NfZGVmYXVsdHMgeworICAgIG5hbWU6ICJsaWJhdWRpb2hhbF9kZWZhdWx0IiwKIAogICAgIGNmbGFnczogWwogICAgICAgICAiLVdhbGwiLApAQCAtNTAsNiArNTUsNyBAQAogICAgICAgICAibGlibWVkaWFfaGVscGVyIiwKICAgICAgICAgImxpYm1lZGlhdXRpbHMiLAogICAgICAgICAibGlidXRpbHMiLAorICAgICAgICAiYXVkaW9jbGllbnQtdHlwZXMtYWlkbC1jcHAiLAogICAgIF0sCiAgICAgaGVhZGVyX2xpYnM6IFsKICAgICAgICAgImFuZHJvaWQuaGFyZHdhcmUuYXVkaW8uY29tbW9uLnV0aWxAYWxsLXZlcnNpb25zIiwKQEAgLTY1LDYgKzcxLDExIEBACiBjY19saWJyYXJ5X3NoYXJlZCB7CiAgICAgbmFtZTogImxpYmF1ZGlvaGFsQDQuMCIsCiAgICAgZGVmYXVsdHM6IFsibGliYXVkaW9oYWxfZGVmYXVsdCJdLAorICAgIHNyY3M6IFsKKyAgICAgICAgIjphdWRpb19jb3JlX2hhbF9jbG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dWRpbzo6Q1BQX1ZFUlNJT046OklQcmltYXJ5RGV2aWNlPiYgZGV2aWNlKQorICAgICAgICA6IENvcmVDb252ZXJzaW9uSGVscGVySGlkbCgiRGV2aWNlSGFsSGlkbCIpLAorI2lmIE1BSk9SX1ZFUlNJT04gPD0gNiB8fCAoTUFKT1JfVkVSU0lPTiA9PSA3ICYmIE1JTk9SX1ZFUlNJT04gPT0gMCkKKyAgICAgICAgICBtRGV2aWNlKGRldmljZSksCisjZW5kaWYKKyAgICAgICAgICBtUHJpbWFyeURldmljZShkZXZpY2UpIHsKKyNpZiBNQUpPUl9WRVJTSU9OID09IDcgJiYgTUlOT1JfVkVSU0lPTiA9PSAxCisgICAgYXV0byBnZXREZXZpY2VSZXQgPSBtUHJpbWFyeURldmljZS0+Z2V0RGV2aWNlKCk7CisgICAgaWYgKGdldERldmljZVJldC5pc09rKCkpIHsKKyAgICAgICAgbURldmljZSA9IGdldERldmljZVJldDsKKyAgICB9IGVsc2UgeworICAgICAgICBBTE9HRSgiQ2FsbCB0byBJUHJpbWFyeURldmljZS5nZXREZXZpY2UgaGFzIGZhaWxlZDogJXMiLAorICAgICAgICAgICAgICAgIGdldERldmljZVJldC5kZXNjcmlwdGlvbigpLmNfc3RyKCkpOworICAgIH0KKyNlbmRpZgogfQogCiBEZXZpY2VIYWxIaWRsOjp+RGV2aWNlSGFsSGlkbCgpIHsKQEAgLTcwLDIyICs4OCwyNiBAQAogfQogCiBzdGF0dXNfdCBEZXZpY2VIYWxIaWRsOjppbml0Q2hlY2soKSB7CisgICAgVElNRV9DSEVDSygpOwogICAgIGlmIChtRGV2aWNlID09IDApIHJldHVybiBOT19JTklUOwogICAgIHJldHVybiBwcm9jZXNzUmV0dXJuKCJpbml0Q2hlY2siLCBtRGV2aWNlLT5pbml0Q2hlY2soKSk7CiB9CiAKIHN0YXR1c190IERldmljZUhhbEhpZGw6OnNldFZvaWNlVm9sdW1lKGZsb2F0IHZvbHVtZSkgeworICAgIFRJTUVfQ0h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gICAgICAgICAgcmV0dXJuIHByb2Nlc3NSZXR1cm4oInNldENvbm5lY3RlZFN0YXRlXzdfMSIsIHJldCk7CisgICAgICAgIH0gZWxzZSBpZiAocmV0ID09IFJlc3VsdDo6T0spIHsKKyAgICAgICAgICAgIHJldHVybiBOT19FUlJPUjsKKyAgICAgICAgfQorICAgICAgICBzdXBwb3J0c1NldENvbm5lY3RlZFN0YXRlN18xID0gZmFsc2U7CisgICAgfQorI2VuZGlmCisgICAgRGV2aWNlQWRkcmVzcyBoaWRsQWRkcmVzczsKKyAgICBpZiAoc3RhdHVzX3QgcmVzdWx0ID0gQ29yZVV0aWxzOjpkZXZpY2VBZGRyZXNzRnJvbUhhbCgKKyAgICAgICAgICAgICAgICAgICAgcG9ydC0+ZXh0LmRldmljZS50eXBlLCBwb3J0LT5leHQuZGV2aWNlLmFkZHJlc3MsICZoaWRsQWRkcmVzcyk7CisgICAgICAgICAgICByZXN1bHQgIT0gTk9fRVJST1IpIHsKKyAgICAgICAgcmV0dXJuIHJlc3VsdDsKKyAgICB9CisgICAgcmV0dXJuIHByb2Nlc3NSZXR1cm4oInNldENvbm5lY3RlZFN0YXRlIiwgbURldmljZS0+c2V0Q29ubmVjdGVkU3RhdGUoaGlkbEFkZHJlc3MsIGNvbm5lY3RlZCkpOworfQorCitlcnJvcjo6UmVzdWx0PGF1ZGlvX2h3X3N5bmNfdD4gRGV2aWNlSGFsSGlkbDo6Z2V0SHdBdlN5bmMoKSB7CisgICAgVElNRV9DSEVDSygpOworICAgIGlmIChtRGV2aWNlID09IDApIHJldHVybiBOT19JTklUOworICAgIGF1ZGlvX2h3X3N5bmNfdCB2YWx1ZTsKKyAgICBSZXN1bHQgcmVzdWx0OworICAgIFJldHVybjx2b2lkPiByZXQgPSBtRGV2aWNlLT5nZXRId0F2U3luYyhbJnZhbHVlLCAmcmVzdWx0XShSZXN1bHQgciwgYXVkaW9faHdfc3luY190IHYpIHsKKyAgICAgICAgdmFsdWUgPSB2OworICAgICAgICBy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mV0dmFsID0gUmVzdWx0OjpOT1RfSU5JVElBTElaRUQ7CiAgICAgZm9yIChjb25zdCBhdXRvJiBmYWN0b3J5IDogZmFjdG9yaWVzKSB7Ci0gICAgICAgIFJldHVybjx2b2lkPiByZXQgPSBmYWN0b3J5LT5vcGVuRGV2aWNlKAotICAgICAgICAgICAgICAgIGhpZGxJZCwKLSAgICAgICAgICAgICAgICBbJl0oUmVzdWx0IHIsIGNvbnN0IHNwPElEZXZpY2U+JiByZXN1bHQpIHsKLSAgICAgICAgICAgICAgICAgICAgcmV0dmFsID0gcjsKLSAgICAgICAgICAgICAgICAgICAgaWYgKHJldHZhbCA9PSBSZXN1bHQ6Ok9LKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAqZGV2aWNlID0gbmV3IERldmljZUhhbEhpZGwocmVzdWx0KTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIH0pOworICAgICAgICBSZXR1cm48dm9pZD4gcmV0OworICAgICAgICBpZiAoc3RyY21wKG5hbWUsIEFVRElPX0hBUkRXQVJFX01PRFVMRV9JRF9QUklNQVJZKSA9PSAwKSB7CisgICAgICAgICAgICAvLyBJbiBWNy4xIGl0J3Mgbm90IHBvc3NpYmxlIHRvIGNhc3QgSURldmljZSBiYWNrIHRvIElQcmltYXJ5RGV2aWNlLAorICAgICAgICAgICAgLy8gdGh1cyBvcGVuUHJpbWFyeURldmljZSBtdXN0IGJlIHVzZWQuCisjaWYgTUFKT1JfVkVSU0lPTiA9PSA3ICYmIE1JTk9SX1ZFUlNJT04gPT0gMQorICAgICAgICAgICAgcmV0ID0gZmFjdG9yeS0+b3BlblByaW1hcnlEZXZpY2VfN18xKAorI2Vsc2UKKyAgICAgICAgICAgIHJldCA9IGZhY3RvcnktPm9wZW5QcmltYXJ5RGV2aWNlKAorI2VuZGlmCisgICAgICAgICAgICAgICAgICAgIFsmXShSZXN1bHQgciwKKyAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNwPDo6YW5kcm9pZDo6aGFyZHdhcmU6OmF1ZGlvOjpDUFBfVkVSU0lPTjo6SVByaW1hcnlEZXZpY2U+JiByZXN1bHQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHZhbCA9IHI7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmV0dmFsID09IFJlc3VsdDo6T0spIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAqZGV2aWNlID0gbmV3IERldmljZUhhbEhpZGwocmVzdWx0KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgfSk7CisgICAgICAgIH0gZWxzZSB7CisjaWYgTUFKT1JfVkVSU0lPTiA9PSA3ICYmIE1JTk9SX1ZFUlNJT04gPT0gMQorICAgICAgICAgICAgcmV0ID0gZmFjdG9yeS0+b3BlbkRldmljZV83XzEoCisjZWxzZQorICAgICAgICAgICAgcmV0ID0gZmFjdG9yeS0+b3BlbkRldmljZSgKKyNlbmRpZgorICAgICAgICAgICAgICAgICAgICBoaWRsSWQsCisgICAgICAgICAgICAgICAgICAgIFsmXShSZXN1bHQgciwKKyAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNwPDo6YW5kcm9pZDo6aGFyZHdhcmU6OmF1ZGlvOjpDUFBfVkVSU0lPTjo6SURldmljZT4mIHJlc3VsdCkgeworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dmFsID0gcjsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXR2YWwgPT0gUmVzdWx0OjpPSykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICpkZXZpY2UgPSBuZXcgRGV2aWNlSGFsSGlkbChyZXN1bHQpOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICB9KTsKKyAgICAgICAgfQogICAgICAgICBpZiAoIXJldC5pc09rKCkpIHJldHVybiBGQUlMRURfVFJBTlNBQ1RJT047CiAgICAgICAgIHN3aXRjaCAocmV0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NwcAppbmRleCBlYjU2ZmMzLi4wODUzNjczIDEwMDY0NAotLS0gYS9tZWRpYS9saWJlZmZlY3RzL3ByZXByb2Nlc3NpbmcvdGVzdHMvY29ycmVsYXRpb24uY3BwCisrKyBiL21lZGlhL2xpYmVmZmVjdHMvcHJlcHJvY2Vzc2luZy90ZXN0cy9jb3JyZWxhdGlvbi5jcHAKQEAgLTM2LDcgKzM2LDcgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnQxNl90KiBzaWdZLCBpbnQgbGVuLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDE2X3QgZW5hYmxlQ3Jvc3NDb3JyKSB7CiAgICAgZmxvYXQgbWF4Q29yclZhbCA9IDAuZiwgcHJldkNvcnJWYWwgPSAwLmY7Ci0gICAgaW50IGRlbGF5ID0gMCwgcGVha0luZGV4ID0gMCwgZmxhZyA9IDA7CisgICAgaW50IHBlYWtJbmRleCA9IDAsIGZsYWcgPSAwOwogICAgIGludCBsb29wTGltID0gKDEgPT0gZW5hYmxlQ3Jvc3NDb3JyKSA/IGxlbiA6IGtNaW5Mb29wTGltaXRWYWx1ZTsKICAgICBzdGQ6OnZlY3RvcjxpbnQ+IHBlYWtJbmRleFZlY3Qoa051bVBlYWtzLCAwKTsKICAgICBzdGQ6OnZlY3RvcjxmbG9hdD4gcGVha1ZhbHVlVmVjdChrTnVtUGVha3MsIDAuZik7CkBAIC00Nyw3ICs0Nyw2IEBACiAgICAgICAgIH0KICAgICAgICAgY29yclZhbCAvPSBsZW4gLSBpOwogICAgICAgICBpZiAoY29yclZhbCA+IG1heENvcnJWYWwpIHsKLSAgICAgICAgICAgIGRlbGF5ID0gaTsKICAgICAgICAgICAgIG1heENvcnJWYWwgPSBjb3JyVmFsOwogICAgICAgICB9CiAgICAgICAgIC8vIENvcnJlbGF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KyAgICBdLAorCisgICAgc2hhcmVkX2xpYnM6IFsKKyAgICAgICAgImxpYmN1dGlscyIsCisgICAgICAgICJsaWJsb2ciLAorICAgIF0sCisKKyAgICByZWxhdGl2ZV9pbnN0YWxsX3BhdGg6ICJzb3VuZGZ4IiwKKworICAgIGNmbGFnczogWworICAgICAgICAiLWZ2aXNpYmlsaXR5PWhpZGRlbiIsCisgICAgICAgICItV2FsbCIsCisgICAgICAgICItV2Vycm9yIiwKKyAgICAgICAgIi1Xbm8tYWRkcmVzcy1vZi1wYWNrZWQtbWVtYmVyIiwKKyAgICBdLAorCisgICAgaGVhZGVyX2xpYnM6IFsKKyAgICAgICAgImxpYmF1ZGlvZWZmZWN0cyIsCisgICAgXSwKK30KKworY2NfbGlicmFyeSB7CisgICAgbmFtZTogImxpYmVxdWFsaXplcnRlc3QiLAorICAgIGhvc3Rfc3VwcG9ydGVkOiB0cnVlLAorICAgIHZlbmRvcjogdHJ1ZSwKKyAgICBzcmNzOiBbCisgICAgICAgICJBdWRpb0JpcXVhZEZpbHRlci5jcHAiLAorICAgICAgICAiQXVkaW9Db2VmSW50ZXJwb2xhdG9yLmNwcCIsCisgICAgICAgICJBdWRpb0VxdWFsaXplci5jcHAiLAorICAgICAgICAiQXVkaW9QZWFraW5nRmlsdGVyLmNwcCIsCisgICAgICAgICJBdWRpb1NoZWx2aW5nRmlsdGVyLmNwcCIsCisgICAgICAgICJFZmZlY3RFcXVhbGl6ZXIuY3BwIiwKKyAgICAgICAgIkVmZmVjdHNNYXRoLmMiLAorICAgIF0sCisKKyAgICBzaGFyZWRfbGliczogWworICAgICAgICAibGliY3V0aWxzIiwKKyAgICAgICAgImxpYmxvZyIsCisgICAgXSwKKworICAgIHJlbGF0aXZlX2luc3RhbGxfcGF0aDogInNvdW5kZngiLAorCisgICAgY2ZsYWdzOiBbCisgICAgICAgICItZnZpc2liaWxpdHk9aGlkZGVuIiwKKyAgICAgICAgIi1XYWxsIiwKKyAgICAgICAgIi1XZXJyb3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29kZWMiLAorICAgIF0sCit9CisKK2NjX3Rlc3RfaG9zdCB7CisgICAgbmFtZTogImxpYmV4cGVjdGVkdXRpbHNfdGVzdCIsCisgICAgc3JjczogWworICAgICAgICAiZXhwZWN0ZWRfdXRpbHNfdGVzdC5jcHAiLAorICAgIF0sCisgICAgc2hhcmVkX2xpYnM6IFsKKyAgICAgICAgImxpYmxvZyIsCisgICAgXSwKKyAgICBoZWFkZXJfbGliczogWworICAgICAgICAibGliZXhwZWN0ZWR1dGlsc19oZWFkZXJzIiwKKyAgICBdLAorfQorCitjY19saWJyYXJ5X2hlYWRlcnMgeworICAgIG5hbWU6ICJsaWJlcnJvcl9oZWFkZXJzIiwKKyAgICBob3N0X3N1cHBvcnRlZDogdHJ1ZSwKKyAgICB2ZW5kb3JfYXZhaWxhYmxlOiB0cnVlLAorICAgIG1pbl9zZGtfdmVyc2lvbjogIjI5IiwKKyAgICBhcGV4X2F2YWlsYWJsZTogWworICAgICAgICAiLy9hcGV4X2F2YWlsYWJsZTpwbGF0Zm9ybSIsCisgICAgICAgICJjb20uYW5kcm9pZC5ibHVldG9vdGgiLAorICAgICAgICAiY29tLmFuZHJvaWQubWVkaWEiLAorICAgICAgICAiY29tLmFuZHJvaWQubWVkaWEuc3djb2RlYyIsCisgICAgXSwKKyAgICBleHBvcnRfaW5jbHVkZV9kaXJzOiBbCisgICAgICAgICJpbmNsdWRlIiwKKyAgICBdLAorICAgIGhlYWRlcl9saWJzOiBbCisgICAgICAgICJsaWJleHBlY3RlZHV0aWxzX2hlYWRlcnMiLAorICAgIF0sCisgICAgZXhwb3J0X2hlYWRlcl9saWJfaGVhZGVyczogWworICAgICAgICAibGliZXhwZWN0ZWR1dGlsc19oZWFkZXJzIiwKKyAgICBdLAorfQpkaWZmIC0tZ2l0IGEvbWVkaWEvbGliZXJyb3IvZXhwZWN0ZWRfdXRpbHNfdGVzdC5jcHAgYi9tZWRpYS9saWJlcnJvci9leHBlY3RlZF91dGlsc190ZXN0LmNwcApu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VzdC5oPgorCisjZGVmaW5lIExPR19UQUcgIlJlc3VsdC10ZXN0IgorCituYW1lc3BhY2UgYW5kcm9pZCB7CituYW1lc3BhY2UgZm9vIHsKKworY2xhc3MgVmFsdWUgeworICBwdWJsaWM6CisgICAgZXhwbGljaXQgVmFsdWUoaW50IGkpIDogbUludChpKSB7fQorICAgIFZhbHVlKGNvbnN0IFZhbHVlJikgPSBkZWxldGU7CisgICAgVmFsdWUoVmFsdWUmJikgPSBkZWZhdWx0OworCisgICAgb3BlcmF0b3IgaW50KCkgY29uc3QgeyByZXR1cm4gbUludDsgfQorCisgIHByaXZhdGU6CisgICAgY29uc3QgaW50IG1JbnQ7Cit9OworCitjbGFzcyBTdGF0dXMgeworICBwdWJsaWM6CisgICAgZXhwbGljaXQgU3RhdHVzKGludCBpKSA6IG1JbnQoaSkge30KKyAgICBTdGF0dXMoY29uc3QgU3RhdHVzJikgPSBkZWxldGU7CisgICAgU3RhdHVzKFN0YXR1cyYmKSA9IGRlZmF1bHQ7CisKKyAgICBvcGVyYXRvciBpbnQoKSBjb25zdCB7IHJldHVybiBtSW50OyB9CisKKyAgcHJpdmF0ZToKKyAgICBjb25zdCBpbnQgbUludDsKK307CisKK2Jvb2wgZXJyb3JJc09rKGNvbnN0IFN0YXR1cyYgZSkgeworICAgIHJldHVybiBlID09IDA7Cit9CisKK3N0ZDo6c3RyaW5nIGVycm9yVG9TdHJpbmcoY29uc3QgU3RhdHVzJiBlKSB7CisgICAgc3RkOjpvc3RyaW5nc3RyZWFtIHN0cjsKKyAgICBzdHIgPDwgZTsKKyAgICByZXR1cm4gc3RyLnN0cigpOworfQorCit1c2luZyBSZXN1bHQgPSBiYXNlOjpleHBlY3RlZDxWYWx1ZSwgU3RhdHVzPjsKKworfSAgLy8gbmFtZXNwYWNlIGZvbworCituYW1lc3BhY2UgeworCit1c2luZyBmb286OlJlc3VsdDsKK3VzaW5nIGZvbzo6U3RhdHVzOwordXNpbmcgZm9vOjpWYWx1ZTsKKworVE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VVMoKSB8CisgKiArLS0tLS0tLS0tLS0tLS0tLS0tLS0rLS0tLS0tLS0tLS0tLS0tLS0tKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSsKKyAqCisgKiBBbGwgbWFjcm9zIGV4cGVjdCB0aGF0OgorICogLSBUaGUgZXJyb3IgdHlwZSBhbmQgdmFsdWUgdmFsdWUgdHlwZSBhcmUgbW92YWJsZS4KKyAqIC0gVGhlIG1hY3JvIGFyZ3VtZW50IGNhbiBiZSBhc3NpZ25lZCB0byBhIHZhcmlhYmxlIHVzaW5nIGBhdXRvIHggPSAoZXhwKWAuCisgKiAtIFRoZSBleHByZXNzaW9uIGVycm9ySXNPayhlKSBmb3IgdGhlIGVycm9yIHR5cGUgZXZhbHVhdGVhIHRvIGEgYm9vbCB3aGljaCBpcyB0cnVlIGlmZiB0aGUKKyAqICAgc3RhdHVzIGlzIGNvbnNpZGVyZWQgc3VjY2Vzcy4KKyAqIC0gVGhlIGV4cHJlc3Npb24gZXJyb3JUb1N0cmluZyhlKSBmb3IgYSBnaXZlbiBlcnJvciB0eXBlIGV2YWx1YXRlZCB0byBhIHN0ZDo6c3RyaW5nIGNvbnRhaW5pbmcgYQorICogICBodW1hbi1yZWFkYWJsZSB2ZXJzaW9uIG9mIHRoZSBzdGF0dXMuCisgKi8KKworI2RlZmluZSBWQUxVRV9PUl9SRVRVUk4oZXhwKSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAoeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgIGF1dG8gX3RtcCA9IChleHApOyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgICAgICBpZiAoIV90bXAub2soKSkgcmV0dXJuIDo6YW5kcm9pZDo6YmFzZTo6dW5leHBlY3RlZChzdGQ6Om1vdmUoX3RtcC5lcnJvcigpKSk7IFwKKyAgICAgICAgc3RkOjptb3ZlKF90bXAudmFsdWUoKSk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgfSkKKworI2RlZmluZSBWQUxVRV9PUl9SRVRVUk5fU1RBVFVTKGV4cCkgICAgICAgICAgICAgICAgICAgICBcCisgICAgKHsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgYXV0byBfdG1wID0gKGV4cCk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgICAgICBpZiAoIV90bXAub2soKSkgcmV0dXJuIHN0ZDo6bW92ZShfdG1wLmVycm9yKCkpOyBcCisgICAgICAgIHN0ZDo6bW92ZShfdG1wLnZhbHVlKCkpOyAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICB9KQorCisjZGVmaW5lIFZBTFVFX09SX0ZBVEFMKGV4cCkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAoeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgICAgICBhdXRvIF90bXAgPSAoZXhwKTsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgIExPR19BTFdBWVNfRkFUQUxfSUYoIV90bXAub2soKSwgIkZ1bmN0aW9uOiAlcyBMaW5lOiAlZCBGYWlsZWQgcmVzdWx0ICglcykiLCBfX0ZVTkNUSU9OX18sIFwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBfX0xJTkVfXywgZXJyb3JUb1N0cmluZyhfdG1wLmVycm9yKCkpLmNfc3RyKCkpOyAgICAgICAgICAgICAgICAgICAgICAgXAorICAgICAgICBzdGQ6Om1vdmUoX3RtcC52YWx1ZSgpKTsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgfSkKKworI2RlZmluZSBSRVRVUk5fSUZfRVJST1IoZXhwKSBcCisgICAgaWYgKGF1dG8gX3RtcCA9IChleHApOyAhZXJyb3JJc09rKF90bXApKSByZXR1cm4gOjphbmRyb2lkOjpiYXNlOjp1bmV4cGVjdGVkKHN0ZDo6bW92ZShfdG1wKSk7CisKKyNkZWZpbmUgUkVUVVJOX1NUQVRVU19JRl9FUlJPUihleHApIFwKKyAgICBpZiAoYXV0byBfdG1wID0gKGV4cCk7ICFlcnJvcklzT2soX3RtcCkpIHJldHVybiBfdG1wOworCisjZGVmaW5lIEZBVEFMX0lGX0VSUk9SKGV4cCkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgIHsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAgYXV0byBfdG1wID0gKGV4cCk7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgIExPR19BTFdBWVNfRkFUQUxfSUYoIWVycm9ySXNPayhfdG1wKSwgIkZ1bmN0aW9uOiAlcyBMaW5lOiAlZCBGYWlsZWQgcmVzdWx0OiAoJXMpIiwgXAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgX19MSU5FX18sIGVycm9yVG9TdHJpbmcoX3RtcCkuY19zdHIoKSk7ICAgICAgICAgXAorICAgIH0KZGlmZiAtLWdpdCBh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FsdWUoKSwgc2NyZWVuU3RhYmxlKTsKKyAgICAgICAgICAgIC8vIFdoZW5ldmVyIHRoZSBzY3JlZW4gaXMgdW5zdGFibGUsIHJlY2VudGVyIHRoZSBoZWFkIHBvc2UuCisgICAgICAgICAgICBpZiAoIXNjcmVlblN0YWJsZSkgeworICAgICAgICAgICAgICAgIHJlY2VudGVyKHRydWUsIGZhbHNlKTsKKyAgICAgICAgICAgIH0KICAgICAgICAgICAgIG1TY3JlZW5IZWFkRnVzaW9uLnNldFdvcmxkVG9TY3JlZW5Qb3NlKG1Xb3JsZFRvU2NyZWVuVGltZXN0YW1wLnZhbHVlKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JsZFRvTG9naWNhbFNjcmVlbik7CiAgICAgICAgIH0KIAorICAgICAgICAvLyBIYW5kbGUgaGVhZC4KKyAgICAgICAgaWYgKG1Xb3JsZFRvSGVhZFRpbWVzdGFtcC5oYXNfdmFsdWUoKSkgeworICAgICAgICAgICAgUG9zZTNmIHdvcmxkVG9IZWFkID0gbUhlYWRQb3NlQmlhcy5nZXRPdXRwdXQoKTsKKyAgICAgICAgICAgIC8vIEF1dG8tcmVjZW50ZXIuCisgICAgICAgICAgICBpZiAobUhlYWRTdGlsbG5lc3NEZXRlY3Rvci5jYWxjdWxhdGUodGltZXN0YW1wKSkgeworICAgICAgICAgICAgICAgIHJlY2VudGVyKHRydWUsIGZhbHNlKTsKKyAgICAgICAgICAgICAgICB3b3JsZFRvSGVhZCA9IG1IZWFkUG9zZUJpYXMuZ2V0T3V0cHV0KCk7CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIG1TY3JlZW5IZWFkRnVzaW9uLnNldFdvcmxkVG9IZWFkUG9zZShtV29ybGRUb0hlYWRUaW1lc3RhbXAudmFsdWUoKSwgd29ybGRUb0hlYWQpOworICAgICAgICAgICAgbU1vZGVTZWxlY3Rvci5zZXRXb3JsZFRvSGVhZFBvc2UobVdv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lIHRoZSBBUEkgcmVsaWVzCkBAIC0yNDgsMTcgKzI1MiwxNiBAQAogICAgIH0KIAogICAgIHZvaWQgaGFuZGxlRXZlbnQoY29uc3QgQVNlbnNvckV2ZW50JiBldmVudCkgewotICAgICAgICBEYXRhRm9ybWF0IGZvcm1hdDsKKyAgICAgICAgUG9zZUV2ZW50IHZhbHVlOwogICAgICAgICB7CiAgICAgICAgICAgICBzdGQ6OmxvY2tfZ3VhcmQgbG9jayhtTXV0ZXgpOwotICAgICAgICAgICAgYXV0byBpdGVyID0gbUVuYWJsZWRTZW5zb3JGb3JtYXRzLmZpbmQoZXZlbnQuc2Vuc29yKTsKLSAgICAgICAgICAgIGlmIChpdGVyID09IG1FbmFibGVkU2Vuc29yRm9ybWF0cy5lbmQoKSkgeworICAgICAgICAgICAgYXV0byBpdGVyID0gbUVuYWJsZWRTZW5zb3JzRXh0cmEuZmluZChldmVudC5zZW5zb3IpOworICAgICAgICAgICAgaWYgKGl0ZXIgPT0gbUVuYWJsZWRTZW5zb3JzRXh0cmEuZW5kKCkpIHsKICAgICAgICAgICAgICAgICAvLyBUaGlzIGNhbiBoYXBwZW4gaWYgd2UgaGF2ZSBhbnkgcGVuZGluZyBldmVudHMgc2hvcnRseSBhZnRlciBzdG9wcGluZy4KICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICB9Ci0gICAgICAgICAgICBmb3JtYXQgPSBpdGVyLT5zZWNvbmQ7CisgICAgICAgICAgICB2YWx1ZSA9IHBhcnNlRXZlbnQoZXZlbnQsIGl0ZXItPnNlY29uZC5mb3JtYXQsICZpdGVyLT5zZWNvbmQuZGlzY29udGludWl0eUNvdW50KTsKICAgICAgICAgfQotICAgICAgICBhdXRvIHZhbHVlID0gcGFyc2VFdmVudChldmVudCwgZm9ybWF0KTsKICAgICAgICAgbUxpc3RlbmVyLT5vblBvc2UoZXZlbnQudGltZXN0YW1wLCBldmVudC5zZW5zb3IsIHZhbHVlLnBvc2UsIHZhbHVlLnR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Ci0gICAgICAgIC8vIFRPRE8oeXRhaSk6IEFkZCBtb3JlIHR5cGVzLgorICAgIHN0YXRpYyBQb3NlRXZlbnQgcGFyc2VFdmVudChjb25zdCBBU2Vuc29yRXZlbnQmIGV2ZW50LCBEYXRhRm9ybWF0IGZvcm1hdCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RkOjpvcHRpb25hbDxpbnQzMl90PiogZGlzY29udGludXR5Q291bnQpIHsKICAgICAgICAgc3dpdGNoIChmb3JtYXQpIHsKICAgICAgICAgICAgIGNhc2UgRGF0YUZvcm1hdDo6a1F1YXRlcm5pb246IHsKICAgICAgICAgICAgICAgICBFaWdlbjo6UXVhdGVybmlvbmYgcXVhdChldmVudC5kYXRhWzNdLCBldmVudC5kYXRhWzBdLCBldmVudC5kYXRhWzFdLCBldmVudC5kYXRhWzJdKTsKQEAgLTMyMywxOSArMzI2LDE5IEBACiAgICAgICAgICAgICAgICAgcmV0dXJuIFBvc2VFdmVudHtQb3NlM2YocXVhdCksIHN0ZDo6b3B0aW9uYWw8VHdpc3QzZj4oKSwgZmFsc2V9OwogICAgICAgICAgICAgfQogCi0gICAgICAgICAgICBjYXNlIERhdGFGb3JtYXQ6OmtSb3RhdGlvblZlY3RvcnNBbmRGbGFnczogewotICAgICAgICAgICAgICAgIC8vIEN1c3RvbSBzZW5zb3IsIGFzc3VtZWQgdG8gY29udGFpbjoKLSAgICAgICAgICAgICAgICAvLyAzIGZsb2F0cyByZXByZXNlbnRpbmcgb3JpZW50YXRpb24gYXMgYSByb3RhdGlvbiB2ZWN0b3IgKGluIHJhZCkuCi0gICAgICAgICAgICAgICAgLy8gMyBmbG9hdHMgcmVwcmVzZW50aW5nIGFuZ3VsYXIgdmVsb2NpdHkgYXMgYSByb3RhdGlvbiB2ZWN0b3IgKGluIHJhZC9zKS4KLSAgICAgICAgICAgICAgICAvLyAxIHVpbnQzMl90IG9mIGZsYWdzLCB3aGVyZToKLSAgICAgICAgICAgICAgICAvLyAtIExTYiBpcyAnMScgaWZmIHRoZSBnaXZlbiBzYW1wbGUgaXMgdGhlIGZpcnN0IG9uZSBpbiBhIG5ldyBmcmFtZSBvZiByZWZlcmVuY2UuCi0gICAgICAgICAgICAgICAgLy8gLSBUaGUgcmVzdCBvZiB0aGUgYml0cyBhcmUgcmVzZXJ2ZWQgZm9yIGZ1dHVyZSB1c2UuCi0gICAgICAgICAgICAgICAgRWlnZW46OlZlY3RvcjNmIHJvdGF0aW9uID0ge2V2ZW50LmRhdGFbMF0sIGV2ZW50LmRhdGFbMV0sIGV2ZW50LmRhdGFbMl19OwotICAgICAgICAgICAgICAgIEVpZ2VuOjpWZWN0b3IzZiB0d2lzdCA9IHtldmVudC5kYXRhWzNdLCBldmVudC5kYXRhWzRdLCBldmVudC5kYXRhWzVdfTsKKyAgICAgICAgICAgIGNhc2UgRGF0YUZvcm1hdDo6a1JvdGF0aW9uVmVjdG9yc0FuZERpc2NvbnRpbnVpdHlDb3VudDogeworICAgICAgICAgICAgICAgIEVpZ2VuOjpWZWN0b3IzZiByb3RhdGlvbiA9IHtldmVudC5oZWFkX3RyYWNrZXIucngsIGV2ZW50LmhlYWRfdHJhY2tlci5yeSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuaGVhZF90cmFja2VyLnJ6fTsKKyAgICAgICAgICAgICAgICBFaWdlbjo6VmVjdG9yM2YgdHdpc3QgPSB7ZXZlbnQuaGVhZF90cmFja2VyLnZ4LCBldmVudC5oZWFkX3RyYWNrZXIudnksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LmhlYWRfdHJhY2tlci52en07CiAgICAgICAgICAgICAgICAgRWlnZW46OlF1YXRlcm5pb25mIHF1YXQgPSByb3RhdGlvblZlY3RvclRvUXVhdGVybmlvbihyb3RhdGlvbik7Ci0gICAgICAgICAgICAgICAgdWludDMyX3QgZmxhZ3MgPSAqcmVpbnRlcnByZXRfY2FzdDxjb25zdCB1aW50MzJfdCo+KCZldmVudC5kYXRhWzZdKTsKKyAgICAgICAgICAgICAgICBib29sIGlzTmV3UmVmZXJlbmNlID0KKyAgICAgICAgICAgICAgICAgICAgICAgICFkaXNjb250aW51dHlDb3VudC0+aGFzX3ZhbHVlKCkgfHwKKyAgICAgICAgICAgICAgICAgICAgICAgIGRpc2NvbnRpbnV0eUNvdW50LT52YWx1ZSgpICE9IGV2ZW50LmhlYWRfdHJhY2tlci5kaXNjb250aW51aXR5X2NvdW50OworICAgICAgICAgICAgICAgICpkaXNjb250aW51dHlDb3VudCA9IGV2ZW50LmhlYWRfdHJhY2tlci5kaXNjb250aW51aXR5X2NvdW50OworCiAgICAgICAgICAgICAgICAgcmV0dXJuIFBvc2VFdmVudHtQb3NlM2YocXVhdCksIFR3aXN0M2YoRWlnZW46OlZlY3RvcjNmOjpaZXJvKCksIHR3aXN0KSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChmbGFncyAmICgxIDw8IDApKSAhPSAwfTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzTmV3UmVmZXJlbmNlfTsKICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgZGVmYXVsdDoKZGlmZiAtLWdpdCBhL21lZGlhL2xpYmhlYWR0cmFja2luZy9TdGlsbG5lc3NEZXRlY3Rvci10ZXN0LmNwcCBiL21lZGlhL2xpYmhlYWR0cmFja2luZy9TdGlsbG5lc3NEZXRlY3Rvci10ZXN0LmNwcApuZXcgZmlsZSBtb2RlIDEwMDY0NAppbmRleCAwMDAwMDAwLi5iNmNkNDc5Ci0tLSAvZGV2L251bGwKKysrIGIvbWVkaWEvbGliaGVhZHRyYWNraW5nL1N0aWxsbmVzc0RldGVjdG9yLXRlc3QuY3BwCkBAIC0wLDAgKzEsMTY3IEBACisvKgorICogQ29weXJpZ2h0IChDKSAyMDIxIFRoZSBBbmRyb2lkIE9wZW4gU291cmNlIFByb2plY3QKKyAqCisgKi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ci5zZXRJbnB1dCgxMjk5LCB3aXRoaW5UaHJlc2hvbGQpOworICAgIEVYUEVDVF9GQUxTRShkZXRlY3Rvci5jYWxjdWxhdGUoMTI5OSkpOworICAgIGRldGVjdG9yLnNldElucHV0KDEzMDAsIGJhc2VsaW5lKTsKKyAgICBFWFBFQ1RfVFJVRShkZXRlY3Rvci5jYWxjdWxhdGUoMTMwMCkpOworfQorCitURVNUX1AoU3RpbGxuZXNzRGV0ZWN0b3JUZXN0LCBOb3RTdGlsbFJvdGF0aW9uKSB7CisgICAgU3RpbGxuZXNzRGV0ZWN0b3IgZGV0ZWN0b3IoT3B0aW9uc3suZGVmYXVsdFZhbHVlID0gbURlZmF1bHRWYWx1ZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC53aW5kb3dEdXJhdGlvbiA9IDEwMDAsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAudHJhbnNsYXRpb25hbFRocmVzaG9sZCA9IDEsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAucm90YXRpb25hbFRocmVzaG9sZCA9IDAuMDV9KTsKKworICAgIGNvbnN0IFBvc2UzZiBiYXNlbGluZShWZWN0b3IzZnsxLCAyLCAzfSwgUXVhdGVybmlvbmY6OlVuaXRSYW5kb20oKSk7CisgICAgY29uc3QgUG9zZTNmIHdpdGhpblRocmVzaG9sZCA9CisgICAgICAgICAgICBiYXNlbGluZSAqIFBvc2UzZihWZWN0b3IzZigwLjMsIC0wLjMsIDApLCByb3RhdGVYKDAuMDMpICogcm90YXRlWSgtMC4wMykpOworICAgIGNvbnN0IFBvc2UzZiBvdXRzaWRlVGhyZXNob2xkID0gYmFzZWxpbmUgKiBQb3NlM2Yocm90YXRlWigwLjA2KSk7CisKKyAgICBFWFBFQ1RfRVEobURlZmF1bHRWYWx1ZSwgZGV0ZWN0b3IuY2FsY3VsYXRlKDApKTsKKyAgICBkZXRlY3Rvci5zZXRJbnB1dCg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SkpIHsKKyAgICAgICAgICAgICAgICAvLyBFbmFibGUgc3VwcHJlc3Npb24gZm9yIHRoZSBkdXJhdGlvbiBvZiB0aGUgd2luZG93LgorICAgICAgICAgICAgICAgIGludDY0X3QgZGVhZGxpbmUgPSBldmVudC50aW1lc3RhbXAgKyBtT3B0aW9ucy53aW5kb3dEdXJhdGlvbjsKKyAgICAgICAgICAgICAgICBpZiAoIW1TdXBwcmVzc2lvbkRlYWRsaW5lLmhhc192YWx1ZSgpIHx8IG1TdXBwcmVzc2lvbkRlYWRsaW5lLnZhbHVlKCkgPCBkZWFkbGluZSkgeworICAgICAgICAgICAgICAgICAgICBtU3VwcHJlc3Npb25EZWFkbGluZSA9IGRlYWRsaW5lOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBtb3ZlZCA9IHRydWU7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICB9CisKKyAgICAvLyBJZiB0aGUgd2luZG93IGhhcyBub3QgYmVlbiBmdWxsLCByZXR1cm4gdGhlIGRlZmF1bHQgdmFsdWUuCisgICAgaWYgKCFtV2luZG93RnVsbCkgeworICAgICAgICByZXR1cm4gbU9wdGlvbnMuZGVmYXVsdFZhbHVlOworICAgIH0KKworICAgIC8vIEZvcmNlICJpbiBtb3Rpb24iIHdoaWxlIHRoZSBzdXBwcmVzc2lvbiBkZWFkbGluZSBpcyBhY3RpdmUuCisgICAgaWYgKG1TdXBwcmVzc2lvbkRlYWRsaW5lLmhhc192YWx1ZSgpKSB7CisgICAgICAgIHJldHVybiBmYWxzZTsKKyAgICB9CisKKyAgICByZXR1cm4gIW1vdmVkOworfQorCit2b2lkIFN0aWxsbmVzc0RldGVjdG9yOjpkaXNjYXJkT2xkKGludDY0X3QgdGltZXN0YW1wKSB7CisgICAgLy8gSGFuZGxlIHRoZSBzcGVjaWFsIGNhc2Ugb2YgdGhlIHdpbmRvdyBkdXJhdGlvbiBiZWluZyB6ZXJv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jpmaW5kTmFtZUZvclRhZygKKyAgICAgICAgY29uc3QgTWVkaWFQcm9maWxlczo6TmFtZVRvVGFnTWFwICptYXAsIHNpemVfdCBuTWFwcGluZ3MsIGludCB0YWcsIGNvbnN0IGNoYXIgKmRlZl8pCit7CisgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCBuTWFwcGluZ3M7ICsraSkgeworICAgICAgICBpZiAobWFwW2ldLnRhZyA9PSB0YWcpIHsKKyAgICAgICAgICAgIHJldHVybiBtYXBbaV0ubmFtZTsKKyAgICAgICAgfQorICAgIH0KKyAgICByZXR1cm4gZGVmXzsKK30KKworLypzdGF0aWMqLyBib29sCitNZWRpYVByb2ZpbGVzOjpkZXRlY3RBZHZhbmNlZFZpZGVvUHJvZmlsZSgKKyAgICAgICAgdmlkZW9fZW5jb2RlciBjb2RlYywgaW50IHByb2ZpbGUsCisgICAgICAgIGNocm9tYV9zdWJzYW1wbGluZyAqY2hyb21hLCBpbnQgKmJpdERlcHRoLCBoZHJfZm9ybWF0ICpoZHIpCit7CisgICAgLy8gZGVmYXVsdCB2YWx1ZXMKKyAgICAqY2hyb21hID0gQ0hST01BX1NVQlNBTVBMSU5HX1lVVl80MjA7CisgICAgKmJpdERlcHRoID0gODsKKyAgICAqaGRyID0gSERSX0ZPUk1BVF9OT05FOworCisgICAgc3dpdGNoIChjb2RlYykgeworICAgIGNhc2UgVklERU9fRU5DT0RFUl9IMjYzOgorICAgIGNhc2UgVklERU9fRU5DT0RFUl9NUEVHXzRfU1A6CisgICAgY2FzZSBWSURFT19FTkNPREVSX1ZQODoKKyAgICAgICAgLy8gdGhlc2UgYXJlIGFsd2F5cyA0OjI6MCBTRFIgOC1iaXQKKyAgICAgICAgcmV0dXJuIHRydWU7CisKKyAgICBjYXNlIFZJREVPX0VOQ09ERVJfSDI2NDoKKyAgICAgICAgc3dpdGNoIChwcm9maWxlKSB7CisgICAgICAgIGNhc2UgQVZDUHJvZmlsZUJhc2VsaW5lOgorICAgICAgICBjYXNlIEFWQ1Byb2ZpbGVDb25zdHJhaW5lZEJhc2VsaW5lOgorICAgICAgICBjYXNlIEFWQ1Byb2ZpbGVNYWluOgorICAgICAgICBjYXNlIEFWQ1Byb2ZpbGVFeHRlbmRlZDoKKyAgICAgICAgY2FzZSBBVkNQcm9maWxlSGlnaDoKKyAgICAgICAgY2FzZSBBVkNQcm9maWxlQ29uc3RyYWluZWRIaWdoOgorICAgICAgICAgICAgcmV0dXJuIHRydWU7CisgICAgICAgIGNhc2UgQVZDUHJvZmlsZUhpZ2gxMDoKKyAgICAgICAgICAgIC8vIHJldHVybmluZyBmYWxzZSBoZXJlIGFzIHRoaXMgY291bGQgYmUgYW4gSExHIHN0cmVhbQorICAgICAgICAgICAgKmJpdERlcHRoID0gMTA7CisgICAgICAgICAgICByZXR1cm4gZmFsc2U7CisgICAgICAgIGNhc2UgQVZDUHJvZmlsZUhpZ2g0MjI6CisgICAgICAgICAgICAqY2hyb21hID0gQ0hST01BX1NVQlNBTVBMSU5HX1lVVl80MjI7CisgICAgICAgICAgICAvLyByZXR1cm5pbmcgZmFsc2UgaGVyZSBhcyBiaXQtZGVwdGggY291bGQgYmUgOCBvciAxMAorICAgICAgICAgICAgcmV0dXJuIGZhbHNlOworICAgICAgICBjYXNlIEFWQ1Byb2ZpbGVIaWdoNDQ0OgorICAgICAgICAgICAgKmNocm9tYSA9IENIUk9NQV9TVUJTQU1QTElOR19ZVVZfNDQ0OworICAgICAgICAgICAgLy8gcmV0dXJuaW5nIGZhbHNlIGhlcmUgYXMgYml0LWRlcHRoIGNvdWxkIGJlIDggb3IgMTAKKyAgICAgICAgICAgIHJldHVybiBmYWxzZTsKKyAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgIHJldHVybiBmYWxzZTsKKyAgICAgICAgfQorICAgICAgICAvLyBmbG93IGRvZXMgbm90IGdldCBoZXJlCisKKyAgICBjYXNlIFZJREVPX0VOQ09ERVJfSEVWQzoKKyAgICAgICAgc3dpdGNoIChwcm9maWxlKSB7CisgICAgICAgIGNhc2UgSEVWQ1Byb2ZpbGVNYWluOgorICAgICAgICAgICAgcmV0dXJuIHRydWU7CisgICAgICAgIGNhc2UgSEVWQ1Byb2ZpbGVNYWluMTA6CisgICAgICAgICAgICAqYml0RGVwdGggPSAxMDsKKyAgICAgICAgICAgIC8vIHJldHVybmluZyBmYWxzZSBoZXJlIGFzIHRoaXMgY291bGQgYmUgYW4gSExHIHN0cmVhbQorICAgICAgICAgICAgcmV0dXJuIGZhbHNlOworICAgICAgICBjYXNlIEhFVkNQcm9maWxlTWFpbjEwSERSMTA6CisgICAgICAgICAgICAqYml0RGVwdGggPSAxMDsKKyAgICAgICAgICAgICpoZHIgPSBIRFJfRk9STUFUX0hEUjEwOworICAgICAgICAgICAgcmV0dXJuIHRydWU7CisgICAgICAgIGNhc2UgSEVWQ1Byb2ZpbGVNYWluMTBIRFIxMFBsdXM6CisgICAgICAgICAgICAqYml0RGVwdGggPSAxMDsKKyAgICAgICAgICAgICpoZHIgPSBIRFJfRk9STUFUX0hEUjEwUExVUzsKKyAgICAgICAgICAgIHJldHVybiB0cnVlOworICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgcmV0dXJuIGZhbHNlOworICAgICAgICB9CisgICAgICAgIC8vIGZsb3cgZG9lcyBub3QgZ2V0IGhlcmUKKworICAgIGNhc2UgVklERU9fRU5DT0RFUl9WUDk6CisgICAgICAgIHN3aXRjaCAocHJvZmlsZSkgeworICAgICAgICBjYXNlIFZQOVByb2ZpbGUwOgorICAgICAgICAgICAgcmV0dXJuIHRydWU7CisgICAgICAgIGNhc2UgVlA5UHJvZmlsZTI6CisgICAgICAgICAgICAvLyB0aGlzIGlzIGFsd2F5cyAxMC1iaXQgb24gQW5kcm9pZCAqLworICAgICAgICAgICAgKmJpdERlcHRoID0gMTA7CisgICAgICAgICAgICAvLyByZXR1cm5pbmcgZmFsc2UgaGVyZSBhcyB0aGlzIGNvdWxkIGJlIGFuIEhMRyBzdHJlYW0KKyAgICAgICAgICAgIHJldHVybiBmYWxzZTsKKyAgICAgICAgY2FzZSBWUDlQcm9maWxlMkhEUjoKKyAgICAgICAgICAgIC8vIHRoaXMgaXMgYWx3YXlzIDEwLWJpdCBvbiBBbmRyb2lkICovCisgICAgICAgICAgICAqYml0RGVwdGggPSAxMDsKKyAgICAgICAgICAgICpoZHIgPSBIRFJfRk9STUFUX0hEUjEwOworICAgICAgICAgICAgcmV0dXJuIHRydWU7CisgICAgICAgIGNhc2UgVlA5UHJvZmlsZTJIRFIxMFBsdXM6CisgICAgICAgICAgICAqYml0RGVwdGggPSAxMDsKKyAgICAgICAgICAgICpoZHIgPSBIRFJfRk9STUFUX0hEUjEwUExVUzsKKyAgICAgICAgICAgIHJldHVybiB0cnVlOworICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgcmV0dXJuIGZhbHNlOworICAgICAgICB9CisgICAgICAgIC8vIGZsb3cgZG9lcyBub3QgZ2V0IGhlcmUKKworICAgIGNhc2UgVklERU9fRU5DT0RFUl9ET0xCWV9WSVNJT046CisgICAgeworICAgICAgICAvLyBmb3IgRG9sYnkgVmlzaW9uIGNvZGVjIHdlIGFsd2F5cyBhc3N1bWUgMTAtYml0IERWCisgICAgICAgICpiaXREZXB0aCA9IDEwOworICAgICAgICAqaGRyID0gSERSX0ZPUk1BVF9ET0xCWV9WSVNJT047CisKKyAgICAgICAgc3dpdGNoIChwcm9maWxlKSB7CisgICAgICAgIGNhc2UgRG9sYnlWaXNpb25Qcm9maWxlRHZoZURlciAvKiBwcm9maWxlIDIgZGVwcmVjYXRlZCAqLzoKKyAgICAgICAgY2FzZSBEb2xieVZpc2lvblByb2ZpbGVEdmhlRGVuIC8qIHByb2ZpbGUgMyBkZXByZWNhdGVkICovOgorICAgICAgICBjYXNlIERvbGJ5VmlzaW9uUHJvZmlsZUR2YXZQZXIgLyogcHJvZmlsZSAwIGRlcHJlY2F0ZWQgKi86CisgICAgICAgIGNhc2UgRG9sYnlWaXNpb25Qcm9maWx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gICAgICAgICAgICpoZHIgPSBIRFJfRk9STUFUX0hEUjEwOworICAgICAgICAgICAgcmV0dXJuIHRydWU7CisgICAgICAgIGNhc2UgQVYxUHJvZmlsZU1haW4xMEhEUjEwUGx1czoKKyAgICAgICAgICAgICpiaXREZXB0aCA9IDEwOworICAgICAgICAgICAgKmhkciA9IEhEUl9GT1JNQVRfSERSMTBQTFVTOworICAgICAgICAgICAgcmV0dXJuIHRydWU7CisgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICByZXR1cm4gZmFsc2U7CisgICAgICAgIH0KKyAgICAgICAgLy8gZmxvdyBkb2VzIG5vdCBnZXQgaGVyZQorCisgICAgZGVmYXVsdDoKKyAgICAgICAgcmV0dXJuIGZhbHNlOworICAgIH0KKyAgICAvLyBmbG93IGRvZXMgbm90IGdldCBoZXJlCit9CisKIC8qc3RhdGljKi8gdm9pZAogTWVkaWFQcm9maWxlczo6Y3JlYXRlVmlkZW9Db2RlYyhjb25zdCBjaGFyICoqYXR0cywgc2l6ZV90IG5hdHRzLCBNZWRpYVByb2ZpbGVzICpwcm9maWxlcykKIHsKQEAgLTI1MCwxMyArNDI0LDU2IEBACiAgICAgfQogCiAgICAgaW50IHByb2ZpbGUgPSAtMTsKLSAgICBpZiAobmF0dHMgPj0gMTIgJiYgIXN0cmNtcCgicHJvZmlsZSIsIGF0dHNbMTBdKSkgewotICAgICAgICBwcm9maWxlID0gYXRvaShhdHRzWzExXSk7CisgICAgY2hyb21hX3N1YnNhbXBsaW5nIGNocm9tYSA9IENIUk9NQV9TVUJTQU1QTElOR19ZVVZfNDIwOworICAgIGludCBiaXREZXB0aCA9IDg7CisgICAgaGRyX2Zvcm1hdCBoZHIgPSBIRFJfRk9STUFUX05PTkU7CisgICAgaWYgKGNvZGVjID09IFZJREVPX0VOQ09ERVJfRE9MQllfVklTSU9OKSB7CisgICAgICAgIGJpdERlcHRoID0gMTA7CisgICAgICAgIGhkciA9IEhEUl9GT1JNQVRfRE9MQllfVklTSU9OOwogICAgIH0KIAotICAgIFZpZGVvQ29kZWMgdmlkZW9Db2RlYyB7CisgICAgaWYgKG5hdHRzID49IDEyICYmICFzdHJjbXAoInByb2ZpbGUiLCBhdHRzWzEwXSkpIHsKKyAgICAgICAgcHJvZmlsZSA9IGF0b2koYXR0c1sxMV0pOworICAgICAgICBpZiAoIWRldGVjdEFkdmFuY2VkVmlkZW9Qcm9maWxlKAorICAgICAgICAgICAgICAgICh2aWRlb19lbmNvZGVyKWNvZGVjLCBwcm9maWxlLCAmY2hyb21hLCAmYml0RGVwdGgsICZoZHIpKSB7CisgICAgICAgICAgICAvLyBpZiBub3QgZGV0ZWN0ZWQgcmVhZCB2YWx1ZXMgZnJvbSB0aGUgYXR0cmlidXRlcworICAgICAgICAgICAgZm9yIChzaXplX3QgaXggPSAxMjsgbmF0dHMgPj0gaXggKyAyOyBpeCArPSAyKSB7CisgICAgICAgICAgICAgICAgaWYgKCFzdHJjbXAoImNocm9tYSIsIGF0dHNbaXhdKSkgeworICAgICAgICAgICAgICAgICAgICBpbnQgY2hyb21hVGFnID0gZmluZFRhZ0Zvck5hbWUoc0Nocm9tYVN1YnNhbXBsaW5nTmFtZU1hcCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTkVMRU0oc0Nocm9tYVN1YnNhbXBsaW5nTmFtZU1hcCksIGF0dHNbaXggKyAxXSk7CisgICAgICAgICAgICAgICAgICAgIGlmIChjaHJvbWFUYWcgPT0gLTEpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIEFMT0dFKCJNZWRpYVByb2ZpbGVzOjpjcmVhdGVWaWRlb0NvZGVjIGludmFsaWQgY2hyb21hICVzIiwgYXR0c1tpeCArIDFdKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGNocm9tYSA9IChjaHJvbWFfc3Vic2FtcGxpbmcpY2hyb21hVGFnOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfSBlbHNlIGlmICghc3RyY21wKCJiaXREZXB0aCIsIGF0dHNbaXhdKSkgeworICAgICAgICAgICAgICAgICAgICBiaXREZXB0aCA9IGF0b2koYXR0c1tpeCArIDFdKTsKKyAgICAgICAgICAgICAgICAgICAgaWYgKGJpdERlcHRoIDwgOCB8fCBiaXREZXB0aCA+IDE2KSB7CisgICAgICAgICAgICAgICAgICAgICAgICBBTE9HRSgiTWVkaWFQcm9maWxlczo6Y3JlYXRlVmlkZW9Db2RlYyBpbnZhbGlkIGJpZERlcHRoICVzIiwgYXR0c1tpeCArIDFdKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIXN0cmNtcCgiaGRyIiwgYXR0c1tpeF0pKSB7CisgICAgICAgICAgICAgICAgICAgIGludCBoZHJUYWcgPSBmaW5kVGFnRm9yTmFtZShzSGRyRm9ybWF0TmFtZU1hcCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE5FTEVNKHNIZHJGb3JtYXROYW1lTWFwKSwgYXR0c1tpeCArIDFdKTsKKyAgICAgICAgICAgICAgICAgICAgaWYgKGhkclRhZyA9PSAtMSkgeworICAgICAgICAgICAgICAgICAgICAgICAgQUxPR0UoIk1lZGlhUHJvZmlsZXM6OmNyZWF0ZVZpZGVvQ29kZWMgaW52YWxpZCBoZHIgJXMiLCBhdHRzW2l4ICsgMV0pOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOworICAgICAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgaGRyID0gKGhkcl9mb3JtYXQpaGRyVGFnOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgL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01BX1NVQlNBTVBMSU5HX1lVVl80NDQsCit9OworCitlbnVtIGhkcl9mb3JtYXQgeworICAgIEhEUl9GT1JNQVRfTk9ORSwKKyAgICBIRFJfRk9STUFUX0hMRywKKyAgICBIRFJfRk9STUFUX0hEUjEwLAorICAgIEhEUl9GT1JNQVRfSERSMTBQTFVTLAorICAgIEhEUl9GT1JNQVRfRE9MQllfVklTSU9OLAorfTsKIAogY2xhc3MgTWVkaWFQcm9maWxlcwogewpAQCAtMTE3LDEzICsxMzAsMTkgQEAKICAgICAgICAgICogQHBhcmFtIHByb2ZpbGUgY29kZWMgcHJvZmlsZSAoZm9yIE1lZGlhQ29kZWMpIG9yIC0xIGZvciBub25lCiAgICAgICAgICAqLwogICAgICAgICBWaWRlb0NvZGVjKHZpZGVvX2VuY29kZXIgY29kZWMsIGludCBiaXRyYXRlLCBpbnQgZnJhbWVXaWR0aCwgaW50IGZyYW1lSGVpZ2h0LCBpbnQgZnJhbWVSYXRlLAotICAgICAgICAgICAgICAgICAgIGludCBwcm9maWxlID0gLTEpCisgICAgICAgICAgICAgICAgICAgaW50IHByb2ZpbGUgPSAtMSwKKyAgICAgICAgICAgICAgICAgICBjaHJvbWFfc3Vic2FtcGxpbmcgY2hyb21hID0gQ0hST01BX1NVQlNBTVBMSU5HX1lVVl80MjAsCisgICAgICAgICAgICAgICAgICAgaW50IGJpdERlcHRoID0gOCwKKyAgICAgICAgICAgICAgICAgICBoZHJfZm9ybWF0IGhkciA9IEhEUl9GT1JNQVRfTk9ORSkKICAgICAgICAgICAgIDogbUNvZGVjKGNvZGVjKSwKICAgICAgICAgICAgICAgbUJpdFJhdGUoYml0cmF0ZSksCiAgICAgICAgICAgICAgIG1GcmFtZVdpZHRoKGZyYW1lV2lkdGgpLAogICAgICAgICAgICAgICBtRnJhbWVIZWlnaHQoZnJhbWVIZWlnaHQpLAogICAgICAgICAgICAgICBtRnJhbWVSYXRlKGZyYW1lUmF0ZSksCi0gICAgICAgICAgICAgIG1Qcm9maWxlKHByb2ZpbGUpIHsKKyAgICAgICAgICAgICAgbVByb2ZpbGUocHJvZmlsZSksCisgICAgICAgICAgICAgIG1DaHJvbWFTdWJzYW1wbGluZyhjaHJvbWEpLAorICAgICAgICAgICAgICBtQml0RGVwdGgoYml0RGVwdGgpLAorICAgICAgICAgICAgICBtSGRyRm9ybWF0KGhkcikgewogICAgICAgICB9CiAKICAgICAgICAgVmlkZW9Db2RlYyhjb25zdCBWaWRlb0NvZGVjJikgPSBkZWZhdWx0OwpAQCAtMTYwLDYgKzE3OSwyMSBAQAogICAgICAgICAgICAgcmV0dXJuIG1Qcm9maWxlOwogICAgICAgICB9CiAKKyAgICAgICAgLyoqIFJldHVybnMgdGhlIGNocm9tYSBzdWJzYW1wbGluZy4gKi8KKyAgICAgICAgY2hyb21hX3N1YnNhbXBsaW5nIGdldENocm9tYVN1YnNhbXBsaW5nKCkgY29uc3QgeworICAgICAgICAgICAgcmV0dXJuIG1DaHJvbWFTdWJzYW1wbGluZzsKKyAgICAgICAgfQorCisgICAgICAgIC8qKiBSZXR1cm5zIHRoZSBiaXQgZGVwdGguICovCisgICAgICAgIGludCBnZXRCaXREZXB0aCgpIGNvbnN0IHsKKyAgICAgICAgICAgIHJldHVybiBtQml0RGVwdGg7CisgICAgICAgIH0KKworICAgICAgICAvKiogUmV0dXJucyB0aGUgY2hyb21hIHN1YnNhbXBsaW5nLiAqLworICAgICAgICBoZHJfZm9ybWF0IGdldEhkckZvcm1hdCgpIGNvbnN0IHsKKyAgICAgICAgICAgIHJldHVybiBtSGRyRm9ybWF0OworICAgICAgICB9CisKICAgICBwcml2YXRlOgogICAgICAgICB2aWRlb19lbmNvZGVyIG1Db2RlYzsKICAgICAgICAgaW50IG1CaXRSYXRlOwpAQCAtMTY3LDYgKzIwMSw5IEBACiAgICAgICAgIGludCBtRnJhbWVIZWlnaHQ7CiAgICAgICAgIGludCBtRnJhbWVSYXRlOwogICAgICAgICBpbnQgbVByb2ZpbGU7CisgICAgICAgIGNoc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CBhcnRpZmFjdHMgaW50byBhIHNpbmdsZSBgdGVzdGNhc2VzYCBkaXJlY3RvcnkuCisgICAgY29tcGlsZV9tdWx0aWxpYjogImJvdGgiLAorICAgIG11bHRpbGliOiB7CisgICAgICAgIGxpYjMyOiB7CisgICAgICAgICAgICBzdWZmaXg6ICIzMiIsCisgICAgICAgIH0sCisgICAgICAgIGxpYjY0OiB7CisgICAgICAgICAgICBzdWZmaXg6ICI2NCIsCisgICAgICAgIH0sCisgICAgfSwKKworICAgIC8vIHVzZWQgd2l0aGluIG1haW5saW5lIE1UUywgYnV0IG9ubHkgdG8gUiwgbm90IHRvIFEuCisgICAgbWluX3Nka192ZXJzaW9uOiAiMzAiLAorCiAgICAgc3JjczogWwogICAgICAgICAiQ29kZWNMaXN0VGVzdC5jcHAiLAogICAgIF0sCkBAIC0zNSw3ICs1MSw3IEBACiAgICAgc2hhcmVkX2xpYnM6IFsKICAgICAgICAgImxpYmJpbmRlciIsCiAgICAgICAgICJsaWJsb2ciLAotICAgICAgICAibGlibWVkaWFfY29kZWNsaXN0IiwKKyAgICAgICAgImxpYm1lZGlhX2NvZGVjbGlzdCIsIC8vIGF2YWlsYWJsZSA+PSBSCiAgICAgICAgICJsaWJzdGFnZWZyaWdodCIsCiAgICAgICAgICJsaWJzdGFnZWZyaWdodF9mb3VuZGF0aW9uIiwKICAgICAgICAgImxpYnN0YWdlZnJpZ2h0X3htbHBhcnNlciIsCmRpZmYgLS1naXQgYS9tZWRpYS9saWJtZWRpYS90ZXN0cy9jb2RlY2xpc3QvQW5kcm9pZFRlc3QueG1sIGIvbWVkaWEvbGlibWVkaWEvdGVzdHMvY29kZWNsaXN0L0FuZHJvaWRUZXN0LnhtbApuZXcgZmlsZSBtb2RlIDEwMDY0NAppbmRleCAwMDAwMDAwLi5lZWFhYjhlCi0tLSAvZGV2L251bGwKKysrIGIvbWVkaWEvbGlibWVkaWEvdGVzdHMvY29kZWNsaXN0L0FuZHJvaWRUZXN0LnhtbApAQCAtM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gICAgICBTVUJNSVRfSVRFTSwgZGF0YSwgbnVsbHB0ciAvKiByZXBseSAqLywgSUJpbmRlcjo6RkxBR19PTkVXQVkpOwotICAgICAgICBBTE9HV19JRihzdGF0dXMgIT0gTk9fRVJST1IsICIlczogYmFkIHJlc3BvbnNlIGZyb20gc2VydmljZSBmb3Igc3VibWl0LCBzdGF0dXM9JWQiLAotICAgICAgICAgICAgICAgIF9fZnVuY19fLCBzdGF0dXMpOwotICAgICAgICByZXR1cm4gc3RhdHVzOwotICAgIH0KLQotICAgIHN0YXR1c190IHN1Ym1pdEJ1ZmZlcihjb25zdCBjaGFyICpidWZmZXIsIHNpemVfdCBsZW5ndGgpIG92ZXJyaWRlCi0gICAgewotICAgICAgICBpZiAoYnVmZmVyID09IG51bGxwdHIgfHwgbGVuZ3RoID4gSU5UMzJfTUFYKSB7Ci0gICAgICAgICAgICByZXR1cm4gQkFEX1ZBTFVFOwotICAgICAgICB9Ci0gICAgICAgIEFMT0dWKCIlczogKE9ORVdBWSkgbGVuZ3RoOiV6dSIsIF9fZnVuY19fLCBsZW5ndGgpOwotCi0gICAgICAgIFBhcmNlbCBkYXRhOwotICAgICAgICBkYXRhLndyaXRlSW50ZXJmYWNlVG9rZW4oSU1lZGlhTWV0cmljc1NlcnZpY2U6OmdldEludGVyZmFjZURlc2NyaXB0b3IoKSk7Ci0KLSAgICAgICAgc3RhdHVzX3Qgc3RhdHVzID0gZGF0YS53cml0ZUludDMyKGxlbmd0aCkKLSAgICAgICAgICAgICAgICA/OiBkYXRhLndyaXRlKCh1aW50OF90KilidWZmZXIsIGxlbmd0aCk7Ci0gICAgICAgIGlmIChzdGF0dXMgIT0gTk9fRVJST1IpIHsKLSAgICAgICAgICAgIHJldHVybiBzdGF0dXM7Ci0gICAgICAgIH0KLQotICAgICAgICBzdGF0dXMgPSByZW1vdGUoKS0+dHJhbnNhY3QoCi0gICAgICAgICAgICAgICAgU1VCTUlUX0JVRkZFUiwgZGF0YSwgbnVsbHB0ciAv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ZS9BbmRyb2lkLmJwCmluZGV4IGY1NTY3OGQuLjI2NmNiMTcgMTAwNjQ0Ci0tLSBhL21lZGlhL2xpYm1lZGlhcGxheWVyc2VydmljZS9BbmRyb2lkLmJwCisrKyBiL21lZGlhL2xpYm1lZGlhcGxheWVyc2VydmljZS9BbmRyb2lkLmJwCkBAIC02NSwxMCArNjUsMTQgQEAKICAgICAgICAgImxpYnN0YWdlZnJpZ2h0X2ZvdW5kYXRpb24iLAogICAgICAgICAibGlic3RhZ2VmcmlnaHRfaHR0cGxpdmUiLAogICAgICAgICAibGlidXRpbHMiLAorICAgICAgICAicGFja2FnZW1hbmFnZXJfYWlkbC1jcHAiLAogICAgIF0sCiAKICAgICBoZWFkZXJfbGliczogWwogICAgICAgICAibWVkaWFfcGx1Z2luX2hlYWRlcnMiLAorICAgICAgICAibGlibWVkaWF1dGlsc19oZWFkZXJzIiwKKyAgICAgICAgImxpYnN0YWdlZnJpZ2h0X3J0c3BfaGVhZGVycyIsCisgICAgICAgICJsaWJzdGFnZWZyaWdodF93ZWJtX2hlYWRlcnMiLAogICAgIF0sCiAKICAgICBzdGF0aWNfbGliczogWwpAQCAtODQsMTMgKzg4LDE2IEBACiAgICAgICAgICJmcmFtZXdvcmstcGVybWlzc2lvbi1haWRsLWNwcCIsCiAgICAgXSwKIAotICAgIGluY2x1ZGVfZGlyczogWwotICAgICAgICAiZnJhbWV3b3Jrcy9hdi9tZWRpYS9saWJzdGFnZWZyaWdodC9ydHNwIiwKLSAgICAgICAgImZyYW1ld29ya3MvYXYvbWVkaWEvbGlic3RhZ2VmcmlnaHQvd2VibSIsCisgICAgZXhwb3J0X2hlYWRlcl9saWJfaGVhZGVyczogWworICAgICAgICAibGlibWVkaWF1dGlsc19oZWFkZXJzIiwKICAgICBdLAogCiAgICAgbG9jYWxfaW5jbHVkZV9kaXJzOiBbImluY2x1ZGUiXSwKIAorICAgIGV4cG9ydF9pbmNsdWRlX2RpcnM6IFsKKyAgICAgICAgIi4iLAorICA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AgICAgIHNwPENsaWVudD4gYyA9IG1DbGllbnRzW2ldLnByb21vdGUoKTsKKyAgICAgICAgICAgICAgICBpZiAoYyAhPSBudWxscHRyKSB7CisgICAgICAgICAgICAgICAgICAgIGNsaWVudHMuYWRkKGMpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKwogICAgICAgICAgICAgZm9yIChpbnQgaSA9IDAsIG4gPSBtTWVkaWFSZWNvcmRlckNsaWVudHMuc2l6ZSgpOyBpIDwgbjsgKytpKSB7CiAgICAgICAgICAgICAgICAgc3A8TWVkaWFSZWNvcmRlckNsaWVudD4gYyA9IG1NZWRpYVJlY29yZGVyQ2xpZW50c1tpXS5wcm9tb3RlKCk7Ci0gICAgICAgICAgICAgICAgaWYgKGMgIT0gMCkgewotICAgICAgICAgICAgICAgICAgICBzbnByaW50ZihidWZmZXIsIDI1NSwgIiBNZWRpYVJlY29yZGVyQ2xpZW50IHBpZCglZClcbiIsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgYy0+bUF0dHJpYnV0aW9uU291cmNlLnBpZCk7Ci0gICAgICAgICAgICAgICAgICAgIHJlc3VsdC5hcHBlbmQoYnVmZmVyKTsKLSAgICAgICAgICAgICAgICAgICAgd3JpdGUoZmQsIHJlc3VsdC5zdHJpbmcoKSwgcmVzdWx0LnNpemUoKSk7Ci0gICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9ICJcbiI7Ci0gICAgICAgICAgICAgICAgICAgIGMtPmR1bXAoZmQsIGFyZ3MpOworICAgICAgICAgICAgICAgIGlmIChjICE9IG51bGxwdHIpIHsKICAgICAgICAgICAgICAgICAgICAgbWVkaWFSZWNvcmRlckNsaWVudHMuYWRkKGMpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KICAgICAgICAgfQogCisgICAgICAgIC8vIGR1bXAgY2xpZW50cyBvdXRzaWRlIG9mIGxvY2sKKyAgICAgICAgZm9yIChjb25zdCBzcDxDbGllbnQ+ICZjIDogY2xpZW50cykgeworICAgICAgICAgICAgYy0+ZHVtcChmZCwgYXJncyk7CisgICAgICAgIH0KKyAgICAgICAgaWYgKG1lZGlhUmVjb3JkZXJDbGllbnRzLnNpemUoKSA9PSAwKSB7CisgICAgICAgICAgICByZXN1bHQuYXBwZW5kKCIgTm8gbWVkaWEgcmVjb3JkZXIgY2xpZW50XG5cbiIpOworICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgZm9yIChjb25zdCBzcDxNZWRpYVJlY29yZGVyQ2xpZW50PiAmYyA6IG1lZGlhUmVjb3JkZXJDbGllbnRzKSB7CisgICAgICAgICAgICAgICAgc25wcmludGYoYnVmZmVyLCAyNTUsICIgTWVkaWFSZWNvcmRlckNsaWVudCBwaWQoJWQpXG4iLAorICAgICAgICAgICAgICAgICAgICAgICAgYy0+bUF0dHJpYnV0aW9uU291cmNlLnBpZCk7CisgICAgICAgICAgICAgICAgcmVzdWx0LmFwcGVuZChidWZmZXIpOworICAgICAgICAgICAgICAgIHdyaXRlKGZkLCByZXN1bHQuc3RyaW5nKCksIHJlc3VsdC5zaXplKCkpOworICAgICAgICAgICAgICAgIHJlc3VsdCA9ICJcbiI7CisgICAgICAgICAgICAgICAgYy0+ZHVtcChmZCwgYXJncyk7CisKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorCiAgICAgICAgIHJlc3VsdC5hcHBlbmQoIiBGaWxlcyBvcGVuZWQgYW5kL29yIG1hcHBlZDpcbiIpOwogICAgICAgICBzbnByaW50ZihidWZmZXIsIFNJWkUgLSAxLCAiL3Byb2MvJWQvbWFwcyIsIGdldHBpZCgpKTsKICAgICAgICAgRklMRSAqZiA9IGZvcGVuKGJ1ZmZlciwgInIiKTsKQEAgLTE4MzEsNyArMTg0NCw2IEBACiB7CiAgICAgY2xvc2UoKTsKICAgICBmcmVlKG1BdHRyaWJ1dGVzKTsKLSAgICBkZWxldGUgbUNhbGxiYWNrRGF0YTsKIH0KIAogLy9zdGF0aWMKQEAgLTIwNTIsOCArM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bXBsZVJhdGUsCkBAIC0yMTkzLDcgKzIyMDQsNiBAQAogICAgICAgICAgICAgICAgICAgICBjaGFubmVsTWFzaywKICAgICAgICAgICAgICAgICAgICAgZnJhbWVDb3VudCwKICAgICAgICAgICAgICAgICAgICAgZmxhZ3MsCi0gICAgICAgICAgICAgICAgICAgIENhbGxiYWNrV3JhcHBlciwKICAgICAgICAgICAgICAgICAgICAgbmV3Y2JkLAogICAgICAgICAgICAgICAgICAgICAwLCAgLy8gbm90aWZpY2F0aW9uIGZyYW1lcwogICAgICAgICAgICAgICAgICAgICBtU2Vzc2lvbklkLApAQCAtMjIyMCw4ICsyMjMwLDcgQEAKICAgICAgICAgICAgICAgICAgICAgY2hhbm5lbE1hc2ssCiAgICAgICAgICAgICAgICAgICAgIGZyYW1lQ291bnQsCiAgICAgICAgICAgICAgICAgICAgIGZsYWdzLAotICAgICAgICAgICAgICAgICAgICBOVUxMLCAvLyBjYWxsYmFjawotICAgICAgICAgICAgICAgICAgICBOVUxMLCAvLyB1c2VyIGRhdGEKKyAgICAgICAgICAgICAgICAgICAgbnVsbHB0ciwgLy8gY2FsbGJhY2sKICAgICAgICAgICAgICAgICAgICAgMCwgLy8gbm90aWZpY2F0aW9uIGZyYW1lcwogICAgICAgICAgICAgICAgICAgICBtU2Vzc2lvbklkLAogICAgICAgICAgICAgICAgICAgICBBdWRpb1RyYWNrOjpUUkFOU0ZFUl9ERUZBVUxULApAQCAtMjIzNyw4ICsyMjQ2LDcgQEAKICAgICAgICAgdC0+c2V0Q2FsbGVyTmFtZSgibWVkaWEiKTsKICAgICAgICAgaWYgKCh0ID09IDApIHx8ICh0LT5pbml0Q2hlY2soKSAhPSBOT19FUlJPUikpIHsKICAgICAgICAgICAgIEFMT0dFKCJVbmFibGUgdG8gY3JlYXRlIGF1ZGlvIHRyYWNrIik7Ci0gICAgICAgICAgICBkZWxldGUgbmV3Y2JkOwotICAgICAgICAgICAgLy8gdCBnb2VzIG91dCBvZiBzY29wZSwgc28gcmVmZXJlbmNlIGNvdW50IGRyb3BzIHRvIHplcm8KKyAgICAgICAgICAgIC8vIHQsIG5ld2NiZCBnb2VzIG91dCBvZiBzY29wZSwgc28gcmVmZXJlbmNlIGNvdW50IGRyb3BzIHRvIHplcm8KICAgICAgICAgICAgIHJldHVybiBOT19JTklUOwogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgLy8gc3VjY2Vzc2Z1bCBBdWRpb1RyYWNrIGluaXRpYWxpemF0aW9uIGltcGxpZXMgYSBsZWdhY3kgc3RyZWFtIHR5cGUgd2FzIGdlbmVyYXRlZApAQCAtMjI3Miw3ICsyMjgwLDYgQEAKICAgICAgICAgICAgIGlmIChtQ2FsbGJhY2tEYXRhICE9IE5VTEwpIHsKICAgICAgICAgICAgICAgICBtQ2FsbGJhY2tEYXRhLT5zZXRPdXRwdXQodGhpcyk7CiAgICAgICAgICAgICB9Ci0gICAgICAgICAgICBkZWxldGUgbmV3Y2JkOwogICAgICAgICAgICAgcmV0dXJuIHVwZGF0ZVRyYWNrKCk7CiAgICAgICAgIH0KICAgICB9CkBAIC0yMzc4LDcgKzIzODUsNyBAQAogICAgICAgICAgICAgaWYgKG1DYWxsYmFja0RhdGEgIT0gTlVMTCkgewogICAgICAgICAgICAgICAgIC8vIHR3byBhbHRlcm5hdGl2ZSBhcHByb2FjaGVzCiAjaWYgMQotICAgICAgICAgICAgICAgIENhbGxiYWNrRGF0YSAqY2FsbGJhY2tEYXRhID0gbUNhbGxiYWNrRGF0YTsKKyAgICAgICAgICAgICAgICBzcDxDYWxsYmFja0RhdGE+IGNhbGxiYWNrRGF0YSA9IG1DYWxsYmFja0RhdGE7CiAgICAgICAgICAgICAgICAgbUxvY2sudW5sb2NrKCk7CiAgICAgICAgICAgICAgICAgLy8gcHJvcGVyIGFjcXVpc2l0aW9uIHNlcXVlbmNlCiAgICAgICAgICAgICAgICAgY2FsbGJhY2tEYXRhLT5sb2NrKCk7CkBAIC0yNDE1LDkgKzI0MjIsOCBAQAogIC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VzZWQgYnkgdGhlIGNhbGxiYWNrIGJlZm9yZSBhY2Nlc3NpbmcgdGhlIHBheWxvYWQgb2YgdGhpcyBvYmplY3QKICAgICAgICAgICAgIHZvaWQgICAgICAgICAgICBsb2NrKCkgY29uc3QgeyBtTG9jay5sb2NrKCk7IH0KICAgICAgICAgICAgIHZvaWQgICAgICAgICAgICB1bmxvY2soKSBjb25zdCB7IG1Mb2NrLnVubG9jaygpOyB9CkBAIC0yMjAsOCArMjIxLDEzIEBACiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIG1Td2l0Y2hpbmcgPSBmYWxzZTsKICAgICAgICAgICAgIH0KKyAgICAgICAgcHJvdGVjdGVkOgorICAgICAgICAgICAgc2l6ZV90IG9uTW9yZURhdGEoY29uc3QgQXVkaW9UcmFjazo6QnVmZmVyJiBidWZmZXIpIG92ZXJyaWRlOworICAgICAgICAgICAgdm9pZCBvblVuZGVycnVuKCkgb3ZlcnJpZGU7CisgICAgICAgICAgICB2b2lkIG9uU3RyZWFtRW5kKCkgb3ZlcnJpZGU7CisgICAgICAgICAgICB2b2lkIG9uTmV3SUF1ZGlvVHJhY2soKSBvdmVycmlkZTsKICAgICAgICAgcHJpdmF0ZToKLSAgICAgICAgICAgIEF1ZGlvT3V0cHV0ICogICBtRGF0YTsKKyAgICAgICAgICAgIG1lZGlhdXRpbHM6OmF0b21pY193cDxBdWRpb091dHB1dD4gbURhdGE7CiAgICAgICAgICAgICBtdXRhYmxlIE11dGV4ICAgbUxvY2s7IC8vIGEgcmVjdXJzaXZlIG11dGV4IG1pZ2h0IG1ha2UgdGhpcyB1bm5lY2Vzc2FyeS4KICAgICAgICAgICAgIGJvb2wgICAgICAgICAgICBtU3dpdGNoaW5nOwogICAgICAgICAgICAgRElTQUxMT1dfRVZJTF9DT05TVFJVQ1RPUlMoQ2FsbGJhY2tEYXRhKTsKZGlmZiAtLWdpdCBhL21lZGlhL2xpYm1lZGlhcGxheWVyc2VydmljZS9NZWRpYVJlY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gICAgaWYgKG1ldGFPbmx5KSB7Ci0gICAgICAgIHJldHVybiBGcmFtZURlY29kZXI6OmdldE1ldGFkYXRhT25seSh0cmFja01ldGEsIGNvbG9yRm9ybWF0LCB0aHVtYm5haWwpOwotICAgIH0KLQotICAgIHNwPElNZWRpYVNvdXJjZT4gc291cmNlID0gbUV4dHJhY3Rvci0+Z2V0VHJhY2soaSk7Ci0KLSAgICBpZiAoc291cmNlLmdldCgpID09IE5VTEwpIHsKLSAgICAgICAgQUxPR0UoInVuYWJsZSB0byBpbnN0YW50aWF0ZSBpbWFnZSB0cmFjay4iKTsKLSAgICAgICAgcmV0dXJuIE5VTEw7Ci0gICAgfQotCiAgICAgY29uc3QgY2hhciAqbWltZTsKKyAgICBib29sIGlzSGVpZiA9IGZhbHNlOwogICAgIGlmICghdHJhY2tNZXRhLT5maW5kQ1N0cmluZyhrS2V5TUlNRVR5cGUsICZtaW1lKSkgewogICAgICAgICBBTE9HRSgiaW1hZ2UgdHJhY2sgaGFzIG5vIG1pbWUgdHlwZSIpOwogICAgICAgICByZXR1cm4gTlVMTDsKQEAgLTIxNSwyMCArMjA2LDc5IEBACiAgICAgICAgIG1pbWUgPSBNRURJQV9NSU1FVFlQRV9WSURFT19IRVZDOwogICAgICAgICB0cmFja01ldGEgPSBuZXcgTWV0YURhdGEoKnRyYWNrTWV0YSk7CiAgICAgICAgIHRyYWNrTWV0YS0+c2V0Q1N0cmluZyhrS2V5TUlNRVR5cGUsIG1pbWUpOworICAgICAgICBpc0hlaWYgPSB0cnVlOwogICAgIH0gZWxzZSBpZiAoIXN0cmNhc2VjbXAobWltZSwgTUVESUFfTUlNRVRZUEVfSU1BR0VfQVZJRikpIHsKICAgICAgICAgbWltZSA9IE1FRElBX01JTUVUWVBFX1ZJREVPX0FWMTsKICAgICAgICAgdHJhY2tNZXRhID0gbmV3IE1ldGFEYXRhKCp0cmFja01ldGEpOwogICAgICAgICB0cmFja01ldGEtPnNldENTdHJpbmcoa0tleU1JTUVUeXBlLCBtaW1lKTsKICAgICB9CiAKKyAgICBzcDxBTWVzc2FnZT4gZm9ybWF0ID0gbmV3IEFNZXNzYWdlOworICAgIHN0YXR1c190IGVyciA9IGNvbnZlcnRNZXRhRGF0YVRvTWVzc2FnZSh0cmFja01ldGEsICZmb3JtYXQpOworICAgIGlmIChlcnIgIT0gT0spIHsKKyAgICAgICAgQUxPR0UoImdldEltYWdlSW50ZXJuYWw6IGNvbnZlcnRNZXRhRGF0YVRvTWVzc2FnZSgpIGZhaWxlZCwgdW5hYmxlIHRvIGV4dHJhY3QgaW1hZ2UiKTsKKyAgICAgICAgcmV0dXJuIE5VTEw7CisgICAgfQorCisgICAgdWludDMyX3QgYml0RGVwdGggPSA4OworICAgIGlmICghc3RyY2FzZWNtcChtaW1lLCBNRURJQV9NSU1FVFlQRV9WSURFT19IRVZDKSkgeworICAgICAgICBpbnQzMl90IHByb2ZpbGU7CisgICAgICAgIGlmIChmb3JtYXQtPmZpbmRJbnQzMigicHJvZmlsZSIsICZwcm9maWxlKSkgeworICAgICAgICAgICAgaWYgKEhFVkNQcm9maWxlTWFpbjEwID09IHByb2ZpbGUgfHwgSEVWQ1Byb2ZpbGVNYWluMTBIRFIxMCA9PSBwcm9maWxlIHx8CisgICAgICAgICAgICAgICAgICAgIEhFVkNQcm9maWxlTWFpbjEwSERSMTBQbHVzID09IHByb2ZpbGUpIHsKKyAgICAgICAgICAgICAgICAgIGJpdERlcHRoID0gMTA7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICB9IGVsc2UgaWYgKCFzdHJjYXNlY21wKG1pbWUsIE1FRElBX01JTUVUWVBFX1ZJREVPX0FWMSkpIHsKKyAgICAgICAgaW50MzJfdCBwcm9maWxlOworICAgICAgICBpZiAoZm9ybWF0LT5maW5kSW50MzIoInByb2ZpbGUiLCAmcHJvZmlsZSkpIHsKKyAgICAgICAgICAgIGlmIChBVjFQcm9maWxlTWFpbjEwID09IHByb2ZpbGUgfHwgQVYxUHJvZmlsZU1haW4xMEhEUjEwID09IHByb2ZpbGUgfHwKKyAgICAgICAgICAgICAgICAgICAgQVYxUHJvZmlsZU1haW4xMEhEUjEwUGx1cyA9PSBwcm9maWxlKSB7CisgICAgICAgICAgICAgICAgICBiaXREZXB0aCA9IDEwOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgfQorCisgICAgaWYgKG1ldGFPbmx5KSB7CisgICAgICAgIHJldHVybiBGcmFtZURlY29kZXI6OmdldE1ldGFkYXRhT25seSh0cmFja01ldGEsIGNvbG9yRm9ybWF0LCB0aHVtYm5haWwsIGJpdERlcHRoKTsKKyAgICB9CisKKyAgICBzcDxJTWVkaWFTb3VyY2U+IHNvdXJjZSA9IG1FeHRyYWN0b3ItPmdldFRyYWNrKGkpOworCisgICAgaWYgKHNvdXJjZS5nZXQoKSA9PSBOVUxMKSB7CisgICAgICAgIEFMT0dFKCJ1bmFibGUgdG8gaW5zdGFudGlhdGUgaW1hZ2UgdHJhY2suIik7CisgICAgICAgIHJldHVybiBOVUxMOworICAgIH0KKwogICAgIGJvb2wgcHJlZmVyaHcgPSBwcm9wZXJ0eV9nZXRfYm9vbCgKICAgICAgICAgICAgICJtZWRpYS5zdGFnZWZyaWdodC50aHVtYm5haWwucHJlZmVyX2h3X2NvZGVjcyIsIGZhbHNlKTsKICAgICB1aW50MzJfdCBmbGFncyA9IHByZWZlcmh3ID8gMCA6IE1lZGlhQ29kZWNMaXN0OjprUHJlZmVyU29mdHdhcmVDb2RlY3M7CiAgICAgVmVjdG9yPEFTdHJpbmc+IG1hdGNoaW5nQ29kZWNzOworCisgICAgLy8gSWYgZGVjb2RpbmcgdGh1bWJuYWlsIGNoZWNrIGRlY29kZXIgc3VwcG9ydHMgdGh1bWJuYWlsIGRpbWVuc2lvbnMgaW5zdGVhZAorICAgIGludDMyX3QgdGh1bWJIZWlnaHQsIHRodW1iV2lkdGg7CisgICAgaWYgKHRodW1ibmFpbCAmJiBmb3JtYXQgIT0gTlVMTAorICAgICAgICAgICAg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zaW9uLWFpZGwtY3BwIiwKKyAgICAgICAgImxpYmJpbmRlciIsCisgICAgICAgICJsaWJjdXRpbHMiLAorICAgICAgICAibGlibWVkaWEiLAorICAgICAgICAibGlic3RhZ2VmcmlnaHQiLAorICAgICAgICAibGlidXRpbHMiLAorICAgICAgICAibGlic3RhZ2VmcmlnaHRfZm91bmRhdGlvbiIsCisgICAgXSwKKyAgICBmdXp6X2NvbmZpZzogeworICAgICAgICBjYzogWworICAgICAgICAgICAgImFuZHJvaWQtbWVkaWEtZnV6emluZy1yZXBvcnRzQGdvb2dsZS5jb20iLAorICAgICAgICBdLAorICAgICAgICBjb21wb25lbnRpZDogMTU1Mjc2LAorICAgIH0sCit9CisKK2NjX2Z1enogeworICAgIG5hbWU6ICJtZWRpYXJlY29yZGVyX2Z1enplciIsCisgICAgc3JjczogWworICAgICAgICAibWVkaWFyZWNvcmRlcl9mdXp6ZXIuY3BwIiwKKyAgICBdLAorICAgIGRlZmF1bHRzOiBbCisgICAgICAgICJsaWJtZWRpYXBsYXllcnNlcnZpY2VGdXp6ZXJfZGVmYXVsdHMiLAorICAgIF0sCisgICAgc3RhdGljX2xpYnM6IFsKKyAgICAgICAgImxpYnN0YWdlZnJpZ2h0X3J0c3AiLAorICAgICAgICAibGliYmFzZSIsCisgICAgXSwKKyAgICBzaGFyZWRfbGliczogWworICAgICAgICAiYXYtdHlwZXMtYWlkbC1jcHAiLAorICAgICAgICAibWVkaWFfcGVybWlzc2lvbi1haWRsLWNwcCIsCisgICAgICAgICJsaWJhdWRpb2NsaWVudF9haWRsX2NvbnZlcnNpb24iLAorICAgICAgICAibGliYW5kcm9pZF9uZXQiLAorICAgICAgICAibGliY2FtZXJhX2NsaWVudCIsCisgICAgICAgICJsaWJndWkiLAorICAgICAgICAibGlibWVkaWFtZXRyaWNzIiwKKyAgICBdLAorfQorCitjY19mdXp6IHsKKyAgICBuYW1lOiAibWV0YWRhdGFyZXRyaWV2ZXJfZnV6emVyIiwKKyAgICBzcmNzOiBbCisgICAgICAgICJtZXRhZGF0YXJldHJpZXZlcl9mdXp6ZXIuY3BwIiwKKyAgICBdLAorICAgIGRlZmF1bHRzOiBbCisgICAgICAgICJsaWJtZWRpYXBsYXllcnNlcnZpY2VGdXp6ZXJfZGVmYXVsdHMiLAorICAgIF0sCisgICAgc3RhdGljX2xpYnM6IFsKKyAgICAgICAgImxpYnBsYXllcnNlcnZpY2VfZGF0YXNvdXJjZSIsCisgICAgXSwKKyAgICBzaGFyZWRfbGliczogWworICAgICAgICAibGliZGF0YXNvdXJjZSIsCisgICAgICAgICJsaWJkcm1mcmFtZXdvcmsiLAorICAgIF0sCit9CisKK2NjX2Z1enogeworICAgIG5hbWU6ICJtZWRpYXBsYXllcl9mdXp6ZXIiLAorICAgIHNyY3M6IFsKKyAgICAgICAgIm1lZGlhcGxheWVyX2Z1enplci5jcHAiLAorICAgIF0sCisgICAgZGVmYXVsdHM6IFsKKyAgICAgICAgImxpYm1lZGlhcGxheWVyc2VydmljZUZ1enplcl9kZWZhdWx0cyIsCisgICAgXSwKKyAgICBzdGF0aWNfbGliczogWworICAgICAgICAibGlicGxheWVyc2VydmljZV9kYXRhc291cmNlIiwKKyAgICAgICAgImxpYnN0YWdlZnJpZ2h0X251cGxheWVyIiwKKyAgICAgICAgImxpYnN0YWdlZnJpZ2h0X3J0c3AiLAorICAgICAgICAibGlic3RhZ2VmcmlnaHRfdGltZWR0ZXh0IiwKKyAgICBdLAorICAgIHNoYXJlZF9saWJzOiBbCisgICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLm1lZGlhLmMyQDEuMCIsCisgICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLm1lZGlhLm9teEAxLjAiLAorICAgICAgICAiYXYtdHlwZXMtYWlkbC1jcHAiLAorICAgICAgICAibGliYXVkaW9jbGllbnRfYWlkbF9jb252ZXJzaW9uIiwKKyAgICAgICAgImxpYmJhc2UiLAorICAgICAgICAibGliYWN0aXZpdHltYW5hZ2VyX2FpZGwiLAorICAgICAgICAibGliYW5kcm9pZF9uZXQiLAorICAgICAgICAibGliYXVkaW9jbGllbnQiLAorICAgICAgICAibGliY2FtZXJhX2NsaWVudCIsCisgICAgICAgICJsaWJjb2RlYzJfY2xpZW50IiwKKyAgICAgICAgImxpYmNyeXB0byIsCisgICAgICAgICJsaWJkYXRhc291cmNlIiwKKyAgICAgICAgImxpYmRybWZyYW1ld29yayIsCisgICAgICAgICJsaWJndWkiLAorICAgICAgICAibGliaGlkbGJhc2UiLAorICAgICAgICAibGlibG9nIiwKKyAgICAgICAgImxpYm1lZGlhX2NvZGVjbGlzdCIsCisgICAgICAgICJsaWJtZWRpYV9vbXgiLAorICAgICAgICAibGlibWVkaWFkcm0iLAorICAgICAgICAibGlibWVkaWFtZXRyaWNzIiwKKyAgICAgICAgImxpYm1lZGlhdXRpbHMiLAorICAgICAgICAibGlibWVtdW5yZWFjaGFibGUiLAorICAgICAgICAibGlibmV0ZF9jbGllbnQiLAorICAgICAgICAibGlicG93ZXJtYW5hZ2VyIiwKKyAgICAgICAgImxpYnN0YWdlZnJpZ2h0X2h0dHBsaXZlIiwKKyAgICBdLAorfQpkaWZmIC0tZ2l0IGEvbWVkaWEvbGlibWVkaWFwbGF5ZXJzZXJ2aWNlL2Z1enplci9SRUFETUUubWQgYi9tZWRpYS9saWJtZWRpYXBsYXllcnNlcnZpY2UvZnV6emVyL1JFQURNRS5tZApuZXcgZmlsZSBtb2RlIDEwMDY0NAppbmRleCAwMDAwMDAwLi5hOTNjODA5Ci0tLSAvZGV2L251bGwKKysrIGIvbWVkaWEvbGlibWVkaWFwbGF5ZXJzZXJ2aWNlL2Z1enplci9SRUFETUUubWQKQEAgLTAsMCArMSw4MyBAQAorIyBGdXp6ZXIgZm9yIGxpYm1lZGlhcGxheWVyc2VydmljZQorIyMgVGFibGUgb2YgY29udGVudHMKKysgW1N0YWdlZnJpZ2h0TWVkaWFSZWNvcmRlcl0oI1N0YWdlZnJpZ2h0TWVkaWFSZWNvcmRlcikKKys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tdID0ge01FRElBX05PUCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNRURJQV9QUkVQQVJFRCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNRURJQV9QTEFZQkFDS19DT01QTEVURSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNRURJQV9CVUZGRVJJTkdfVVBEQVRFLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1FRElBX1NFRUtfQ09NUExFVEUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTUVESUFfU0VUX1ZJREVPX1NJWkUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTUVESUFfU1RBUlRFRCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNRURJQV9QQVVTRUQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTUVESUFfU1RPUFBFRCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNRURJQV9TS0lQUEVELAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1FRElBX05PVElGWV9USU1FLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1FRElBX1RJTUVEX1RFWFQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTUVESUFfRVJST1IsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTUVESUFfSU5GTywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNRURJQV9TVUJUSVRMRV9EQVRBLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1FRElBX01FVEFfREFUQSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNRURJQV9EUk1fSU5GTywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNRURJQV9USU1FX0RJU0NPTlRJTlVJVFksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTUVESUFfSU1TX1JYX05PVElDRSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNRURJQV9BVURJT19ST1VUSU5HX0NIQU5HRUR9OworCitjb25zdGV4cHIgbWVkaWFfaW5mb190eXBlIGtNZWRpYUluZm9UeXBlc1tdID0geworICAgIE1FRElBX0lORk9fVU5LTk9XTiwgICAgICAgICAgIE1FRElBX0lORk9fU1RBUlRFRF9BU19ORVhULAorICAgIE1FRElBX0lORk9fUkVOREVSSU5HX1NUQVJULCAgIE1FRElBX0lORk9fVklERU9fVFJBQ0tfTEFHR0lORywKKyAgICBNRURJQV9JTkZPX0JVRkZFUklOR19TVEFSVCwgICBNRURJQV9JTkZPX0JVRkZFUklOR19FTkQsCisgICAgTUVESUFfSU5GT19ORVRXT1JLX0JBTkRXSURUSCwgTUVESUFfSU5GT19CQURfSU5URVJMRUFWSU5HLAorICAgIE1FRElBX0lORk9fTk9UX1NFRUtBQkxFLCAgICAgIE1FRElBX0lORk9fTUVUQURBVEFfVVBEQVRFLAorICAgIE1FRElBX0lORk9fUExBWV9BVURJT19FUlJPUiwgIE1FRElBX0lORk9fUExBWV9WSURFT19FUlJPUiwKKyAgICBNRURJQV9JTkZPX1RJTUVEX1RFWFRfRVJST1J9OworCitjb25zdCBjaGFyICprVXJsUHJlZml4W10gPSB7ImRhdGE6IiwgImh0dHA6Ly8iLCAiaHR0cHM6Ly8iLCAicnRzcD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wLkNvbnN1bWVCeXRlczx1aW50OF90PihkYXRhQmxvYlNpemUpOworCisgICAgICAgICAgICBzdHJpbmcgdXJpKG1GZHAuUGlja1ZhbHVlSW5BcnJheShrVXJsUHJlZml4KSk7CisgICAgICAgICAgICB1cmkgKz0gIjtiYXNlNjQsIjsKKyAgICAgICAgICAgIEFTdHJpbmcgb3V0OworICAgICAgICAgICAgZW5jb2RlQmFzZTY0KHVyaVN1ZmZpeC5kYXRhKCksIHVyaVN1ZmZpeC5zaXplKCksICZvdXQpOworICAgICAgICAgICAgdXJpICs9IG91dC5jX3N0cigpOworICAgICAgICAgICAgc3RhdHVzID0gbU1lZGlhUGxheWVyLT5zZXREYXRhU291cmNlKG51bGxwdHIgLypodHRwU2VydmljZSovLCB1cmkuY19zdHIoKSwgJmhlYWRlcnMpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBmZDogeworICAgICAgICAgICAgd3JpdGUobURhdGFTb3VyY2VGZCwgZGF0YSwgc2l6ZSk7CisKKyAgICAgICAgICAgIHN0YXR1cyA9IG1NZWRpYVBsYXllci0+c2V0RGF0YVNvdXJjZShtRGF0YVNvdXJjZUZkLCAwLCBzaXplKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CisgICAgICAgIGNhc2Ugc3RyZWFtOiB7CisgICAgICAgICAgICBzcDxJU3RyZWFtU291cmNlPiBzdHJlYW1Tb3VyY2UgPSBzcDxUZXN0U3RyZWFtU291cmNlPjo6bWFrZSgpOworICAgICAgICAgICAgc3RhdHVzID0gbU1lZGlhUGxheWVyLT5zZXREYXRhU291cmNlKHN0cmVhbVNvdXJjZSk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICBjYXNlIGZpbGU6IHsKKyAgICAgICAgICAgIHdyaXRlKG1EYXRhU291cmNlRmQsIGRhdGEsIHNpemUpOworCisgICAgICAgICAgICBzcDxEYXRhU291cmNlPiBkYXRhU291cmNlID0gbmV3IEZpbGVTb3VyY2UoZHVwKG1EYXRhU291cmNlRmQpLCAwLCBzaXplKTsKKyAgICAgICAgICAgIHNwPElEYXRhU291cmNlPiBpRGF0YVNvdXJjZSA9IFJlbW90ZURhdGFTb3VyY2U6OndyYXAoZGF0YVNvdXJjZSk7CisgICAgICAgICAgICBpZiAoIWlEYXRhU291cmNlKSB7CisgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOworICAgICAgICAgICAgfQorICAgICAgICAgICAgc3RhdHVzID0gbU1lZGlhUGxheWVyLT5zZXREYXRhU291cmNlKGlEYXRhU291cmNlKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CisgICAgICAgIGNhc2Ugc29ja2V0OiB7CisgICAgICAgICAgICBTdHJpbmc4IHJ0cFBhcmFtcyA9IFN0cmluZzgobUZkcC5Db25zdW1lUmFuZG9tTGVuZ3RoU3RyaW5nKCkuY19zdHIoKSk7CisgICAgICAgICAgICBzdHJ1Y3Qgc29ja2FkZHJfaW4gZW5kcG9pbnQ7CisgICAgICAgICAgICBlbmRwb2ludC5zaW5fZmFtaWx5ID0gbUZkcC5Db25zdW1lSW50ZWdyYWw8dW5zaWduZWQgc2hvcnQ+KCk7CisgICAgICAgICAgICBlbmRwb2ludC5zaW5fcG9ydCA9IG1GZHAuQ29uc3VtZUludGVncmFsPHVpbnQxNl90PigpOworICAgICAgICAgICAgbU1lZGlhUGxheWVyLT5zZXRSZXRyYW5zbWl0RW5kcG9pbnQoJmVuZHBvaW50KTsKKyAgICAgICAgICAgIHN0YXR1cyA9IG1NZWRpYVBsYXllci0+c2V0RGF0YVNvdXJjZShydHBQYXJhbXMpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICB9CisKKyAgICBpZiAoc3RhdHVzICE9IDApIHsKKyAgICAgICAgcmV0dXJuIGZhbHNlOworICAgIH0KKyAgICByZXR1cm4gdHJ1ZTsKK30KKwordm9pZCBNZWRpYVBsYXllclNlcnZpY2VGdXp6ZX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9uSWQucHVzaF9iYWNrKG1GZHAuQ29uc3VtZUludGVncmFsPHVpbnQ4X3Q+KCkpOworICAgIG1NZWRpYVBsYXllci0+cHJlcGFyZURybSh1dWlkLCBkcm1TZXNzaW9uSWQpOworICAgIG1NZWRpYVBsYXllci0+cmVsZWFzZURybSgpOworCisgICAgYXVkaW9fcG9ydF9oYW5kbGVfdCBkZXZpY2VJZCA9IG1GZHAuQ29uc3VtZUludGVncmFsPGludDMyX3Q+KCk7CisgICAgbU1lZGlhUGxheWVyLT5zZXRPdXRwdXREZXZpY2UoZGV2aWNlSWQpOworICAgIG1NZWRpYVBsYXllci0+Z2V0Um91dGVkRGV2aWNlSWQoJmRldmljZUlkKTsKKworICAgIG1NZWRpYVBsYXllci0+ZW5hYmxlQXVkaW9EZXZpY2VDYWxsYmFjayhtRmRwLkNvbnN1bWVCb29sKCkpOworCisgICAgc3A8TWVkaWFQbGF5ZXI+IG1lZGlhUGxheWVyID0gKE1lZGlhUGxheWVyICopbU1lZGlhUGxheWVyLmdldCgpOworCisgICAgaW50MzJfdCBtc2cgPSBtRmRwLlBpY2tWYWx1ZUluQXJyYXkoa01lZGlhRXZlbnRUeXBlcyk7CisgICAgaW50MzJfdCBleHQxID0gbUZkcC5QaWNrVmFsdWVJbkFycmF5KGtNZWRpYUluZm9UeXBlcyk7CisgICAgaW50MzJfdCBleHQyID0gbUZkcC5Db25zdW1lSW50ZWdyYWw8aW50MzJfdD4oKTsKKyAgICBQYXJjZWwgb2JqOworICAgIG9iai53cml0ZUludDMyKG1GZHAuQ29uc3VtZUludGVncmFsPGludDMyX3Q+KCkpOworICAgIG9iai5zZXREYXRhUG9zaXRpb24oMCk7CisgICAgbWVkaWFQbGF5ZXItPm5vdGlmeShtc2csIGV4dDEsIGV4dDIsICZvYmopOworCisgICAgaW50MzJfdCBtZWRpYVBsYXllckR1bXBGZCA9IG1lbWZkX2NyZWF0ZSgiT3V0cHV0RHVtcEZpbGUiLCBNRkRfQUxMT1dfU0VBTElOR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X0FWUCwgQVVESU9fRU5DT0RFUl9ERUZBVUxULCBWSURFT19FTkNPREVSX0RFRkFVTFR9LAorICAgIHtPVVRQVVRfRk9STUFUX01QRUcyVFMsIEFVRElPX0VOQ09ERVJfQUFDLCBWSURFT19FTkNPREVSX0gyNjR9LAorICAgIHtPVVRQVVRfRk9STUFUX1dFQk0sIEFVRElPX0VOQ09ERVJfVk9SQklTLCBWSURFT19FTkNPREVSX1ZQOH0sCisgICAge09VVFBVVF9GT1JNQVRfVEhSRUVfR1BQLCBBVURJT19FTkNPREVSX0RFRkFVTFQsIFZJREVPX0VOQ09ERVJfTVBFR180X1NQfSwKKyAgICB7T1VUUFVUX0ZPUk1BVF9NUEVHXzQsIEFVRElPX0VOQ09ERVJfQUFDLCBWSURFT19FTkNPREVSX0gyNjR9LAorICAgIHtPVVRQVVRfRk9STUFUX01QRUdfNCwgQVVESU9fRU5DT0RFUl9ERUZBVUxULCBWSURFT19FTkNPREVSX01QRUdfNF9TUH0sCisgICAge09VVFBVVF9GT1JNQVRfTVBFR180LCBBVURJT19FTkNPREVSX0RFRkFVTFQsIFZJREVPX0VOQ09ERVJfSEVWQ319OworCitjb25zdCBzdHJpbmcga1BhcmFtZXRlcnNMaXN0W10gPSB7Im1heC1kdXJhdGlvbiIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIm1heC1maWxlc2l6ZSIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgImludGVybGVhdmUtZHVyYXRpb24tdXMiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJwYXJhbS1tb3ZpZS10aW1lLXNjYWxlIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAicGFyYW0tZ2VvdGFnLWxvbmdpdHVkZSIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgInBhcmFtLWdlb3RhZy1sYXRpdHVkZSIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgInBhcmFtLXRyYWNrLXRpbWUtc3RhdHVzIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiYXVkaW8tcGFyYW0tc2FtcGxpbmctcmF0ZSIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgImF1ZGlvLXBhcmFtLWVuY29kaW5nLWJpdHJhdGUiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJhdWRpby1wYXJhbS1udW1iZXItb2YtY2hhbm5lbHMiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJhdWRpby1wYXJhbS10aW1lLXNjYWxlIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAidmlkZW8tcGFyYW0tcm90YXRpb24tYW5nbGUtZGVncmVlcyIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgInZpZGVvLXBhcmFtLWVuY29kaW5nLWJpdHJhdGUiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJ2aWRlby1wYXJhbS1iaXRyYXRlLW1vZGUiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJ2aWRlby1wYXJhbS1pLWZyYW1lcy1pbnRlcnZhbCIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgInZpZGVvLXBhcmFtLWVuY29kZXItcHJvZmlsZSIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgInZpZGVvLXBhcmFtLWVuY29kZXItbGV2ZWwiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJ2aWRlby1wYXJhbS1jYW1lcmEtaWQiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJ2aWRlby1wYXJhbS10aW1lLXNjYWxlIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAicGFyYW0tdXNlLTY0Yml0LW9mZnNldCIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgInRpbWUtbGFwc2UtZW5hYmxlIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAidGltZS1sYXBzZS1mcHMiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJydHAtcGFyYW0tbG9jYWwtaXAiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJydHAtcGFyYW0tbG9jYWwtcG9ydCIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgInJ0cC1wYXJhbS1yZW1vdGUtcG9ydCIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgInJ0cC1wYXJhbS1zZWxmLWlkIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAicnRwLXBhcmFtLW9wcG9uZW50LWlkIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAicnRwLXBhcmFtLXBheWxvYWQtdHlwZSIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgInJ0cC1wYXJhbS1leHQtY3ZvLWV4dG1hcCIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgInJ0cC1wYXJhbS1leHQtY3ZvLWRlZ3JlZXMiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJ2aWRlby1wYXJhbS1yZXF1ZXN0LWktZnJhbWUiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJydHAtcGFyYW0tc2V0LXNvY2tldC1kc2NwIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAicnRwLXBhcmFtLXNldC1zb2NrZXQtbmV0d29yayJ9OworCitjb25zdGV4cHIgaW50MzJfdCBrTWF4U2xlZXBUaW1lSW5NcyA9IDEwMDsKK2NvbnN0ZXhwciBpbnQzMl90IGtNaW5TbGVlcFRpbWVJbk1zID0gMDsKK2NvbnN0ZXhwciBpbnQzMl90IGtNaW5WaWRlb1NpemUgPSAyOworY29uc3RleHByIGludDMyX3Qga01heFZpZGVvU2l6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YXRhUHJvdmlkZXIuaD4KKwordXNpbmcgbmFtZXNwYWNlIHN0ZDsKK3VzaW5nIG5hbWVzcGFjZSBhbmRyb2lkOworCitjb25zdCBjaGFyICprTWltZVR5cGVzW10gPSB7TUVESUFfTUlNRVRZUEVfSU1BR0VfSlBFRywgICAgICAgICBNRURJQV9NSU1FVFlQRV9JTUFHRV9BTkRST0lEX0hFSUMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgTUVESUFfTUlNRVRZUEVfVklERU9fVlA4LCAgICAgICAgICBNRURJQV9NSU1FVFlQRV9WSURFT19WUDksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgTUVESUFfTUlNRVRZUEVfVklERU9fQVYxLCAgICAgICAgICBNRURJQV9NSU1FVFlQRV9WSURFT19BVkMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgTUVESUFfTUlNRVRZUEVfVklERU9fSEVWQywgICAgICAgICBNRURJQV9NSU1FVFlQRV9WSURFT19NUEVHNCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBNRURJQV9NSU1FVFlQRV9WSURFT19IMjYzLCAgICAgICAgIE1FRElBX01JTUVUWVBFX1ZJREVPX01QRUcyLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1FRElBX01JTUVUWVBFX1ZJREVPX1JBVywgICAgICAgICAgTUVESUFfTUlNRVRZUEVfVklERU9fRE9MQllfVklTSU9OLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1FRElBX01JTUVUWVBFX1ZJREVPX1NDUkFNQkxFRCwgICAgTUVESUFfTUlNRVRZUEVfVklERU9fRElWWCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBNRURJQV9NSU1FVFlQRV9WSURFT19ESVZYMywgICAgICAgIE1FRElBX01JTUVUWVBFX1ZJREVPX1hWSUQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgTUVESUFfTUlNRVRZUEVfVklERU9fTUpQRUcsICAgICAgICBNRURJQV9NSU1FVFlQRV9BVURJT19BTVJfTkIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgTUVESUFfTUlNRVRZUEVfQVVESU9fQU1SX1dCLCAgICAgICBNRURJQV9NSU1FVFlQRV9BVURJT19NUEVHLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1FRElBX01JTUVUWVBFX0FVRElPX01QRUdfTEFZRVJfSSwgTUVESUFfTUlNRVRZUEVfQVVESU9fTVBFR19MQVlFUl9JSSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBNRURJQV9NSU1FVFlQRV9BVURJT19NSURJLCAgICAgICAgIE1FRElBX01JTUVUWVBFX0FVRElPX0FBQywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBNRURJQV9NSU1FVFlQRV9BVURJT19RQ0VMUCwgICAgICAgIE1FRElBX01JTUVUWVBFX0FVRElPX1ZPUkJJUywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBNRURJQV9NSU1FVFlQRV9BVURJT19PUFVTLCAgICAgICAgIE1FRElBX01JTUVUWVBFX0FVRElPX0c3MTFfQUxBVywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBNRURJQV9NSU1FVFlQRV9BVURJT19HNzExX01MQVcsICAgIE1FRElBX01JTUVUWVBFX0FVRElPX1JBVywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBNRURJQV9NSU1FVFlQRV9BVURJT19GTEFDLCAgICAgICAgIE1FRElBX01JTUVUWVBFX0FVRElPX0FBQ19BRFRTLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1FRElBX01JTUVUWVBFX0FVRElPX01TR1NNLCAgICAgICAgTUVESUFfTUlNRVRZUEVfQVVESU9fQUMzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1FRElBX01JTUVUWVBFX0FVRElPX0VBQzMsICAgICAgICAgTUVESUFfTUlNRVRZUEVfQVVESU9fRUFDM19KT0MsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgTUVESUFfTUlNRVRZUEVfQVVESU9fQUM0LCAgICAgICAgICBNRURJQV9NSU1FVFlQRV9BVURJT19TQ1JBTUJMRUQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgTUVESUFfTUlNRVRZUEVfQVVESU9fQUxBQywgICAgICAgICBNRURJQV9NSU1FVFlQRV9BVURJT19XTUEsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgTUVESUFfTUlNRVRZUEVfQVVESU9fTVNfQURQQ00sICAgICBNRURJQV9NSU1FVFlQRV9BVURJT19EVklfSU1BX0FEUENNLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1FRElBX01JTUVUWVBFX0NPTlRBSU5FUl9NUEVHNCwgICAgTUVESUFfTUlNRVRZUEVfQ09OVEFJTkVSX1dBViwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBNRURJQV9NSU1FVFlQRV9DT05UQUlORVJfT0dHLCAgICAgIE1FRElBX01JTUVUWVBFX0NPTlRBSU5FUl9NQVRST1NLQSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBNRURJQV9NSU1FVFlQRV9DT05UQUlORVJfTVBFRzJUUywgIE1FRElBX01JTUVUWVBFX0NPTlRBSU5FUl9BVkksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgTUVESUFfTUlNRVRZUEVfQ09OVEFJTkVSX01QRUcyUFMsICBNRURJQV9NSU1FVFlQRV9DT05UQUlORVJfSEVJRiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBNRURJQV9NSU1FVFlQRV9URVhUXzNHUFAsICAgICAgICAgIE1FRElBX01JTUVUWVBFX1RFWFRfU1VCUklQLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1FRElBX01JTUVUWVBFX1RFWFRfVlRULCAgICAgICAgICAgTUVESUFfTUlNRVRZUEVfVEVYVF9DRUFfNjA4LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1FRElBX01JTUVUWVBFX1RFWFRfQ0VBXzcwOCwgICAgICAgTUVESUFfTUlNRVRZU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gICAgICAgICAgdmVjdG9yPHVpbnQ4X3Q+IHVyaVN1ZmZpeCA9IG1GZHAuQ29uc3VtZUJ5dGVzPHVpbnQ4X3Q+KGRhdGFCbG9iU2l6ZSk7CisKKyAgICAgICAgICAgIHN0cmluZyB1cmkoImRhdGE6Iik7CisgICAgICAgICAgICB1cmkgKz0gIjtiYXNlNjQsIjsKKyAgICAgICAgICAgIEFTdHJpbmcgb3V0OworICAgICAgICAgICAgZW5jb2RlQmFzZTY0KHVyaVN1ZmZpeC5kYXRhKCksIHVyaVN1ZmZpeC5zaXplKCksICZvdXQpOworICAgICAgICAgICAgdXJpICs9IG91dC5jX3N0cigpOworICAgICAgICAgICAgc3RhdHVzID0gbU1kUmV0cmlldmVyLT5zZXREYXRhU291cmNlKG51bGxwdHIgLypodHRwU2VydmljZSovLCB1cmkuY19zdHIoKSwgJm1IZWFkZXJzKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CisgICAgICAgIGNhc2UgRnJvbUZkOiB7CisgICAgICAgICAgICB3cml0ZShtRGF0YVNvdXJjZUZkLCBkYXRhLCBzaXplKTsKKworICAgICAgICAgICAgc3RhdHVzID0gbU1kUmV0cmlldmVyLT5zZXREYXRhU291cmNlKG1EYXRhU291cmNlRmQsIDAsIHNpemUpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBGcm9tRmlsZVNvdXJjZTogeworICAgICAgICAgICAgd3JpdGUobURhdGFTb3VyY2VGZCwgZGF0YSwgc2l6ZSk7CisKKyAgICAgICAgICAgIHNwPERhdGFTb3VyY2U+IGRhdGFTb3VyY2UgPSBuZXcgRmlsZVNvdXJjZShkdXAobURhdGFTb3VyY2VGZCksIDAsIHNpemUpOworICAgICAgICAgICAgc3RhdHVzID0gbU1kUmV0cmlldmVyLT5zZXREYXRhU291cmNlKGRhdGFTb3VyY2UsIG1GZHAuUGlja1ZhbHVlSW5BcnJheShrTWltZVR5cGVzKSk7CisgICAgICAgICA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CJtZWRpYSIpLAotICAgICAgICAgICAgICAgICAgICB7fSAvKiB3b3JrU291cmNlICovLCB7fSAvKiBoaXN0b3J5VGFnICovLCAtMSAvKiBkaXNwbGF5SWQgKi8pOworICAgICAgICAgICAgICAgICAgICB7fSAvKiB3b3JrU291cmNlICovLCB7fSAvKiBoaXN0b3J5VGFnICovLCAtMSAvKiBkaXNwbGF5SWQgKi8sCisgICAgICAgICAgICAgICAgICAgIG51bGxwdHIgLyogY2FsbGJhY2sgKi8pOwogICAgICAgICAgICAgSVBDVGhyZWFkU3RhdGU6OnNlbGYoKS0+cmVzdG9yZUNhbGxpbmdJZGVudGl0eSh0b2tlbik7CiAgICAgICAgICAgICBpZiAoc3RhdHVzLmlzT2soKSkgewogICAgICAgICAgICAgICAgIG1XYWtlTG9ja1Rva2VuID0gYmluZGVyOwpkaWZmIC0tZ2l0IGEvbWVkaWEvbGlibWVkaWFwbGF5ZXJzZXJ2aWNlL251cGxheWVyL0FuZHJvaWQuYnAgYi9tZWRpYS9saWJtZWRpYXBsYXllcnNlcnZpY2UvbnVwbGF5ZXIvQW5kcm9pZC5icAppbmRleCA2ZDMzOGRiLi43MWEzMTY4IDEwMDY0NAotLS0gYS9tZWRpYS9saWJtZWRpYXBsYXllcnNlcnZpY2UvbnVwbGF5ZXIvQW5kcm9pZC5icAorKysgYi9tZWRpYS9saWJtZWRpYXBsYXllcnNlcnZpY2UvbnVwbGF5ZXIvQW5kcm9pZC5icApAQCAtMzcsMjAgKzM3LDIyIEBACiAgICAgICAgICJTdHJlYW1pbmdTb3VyY2UuY3BwIiwKICAgICBdLAogCisgICAgbG9jYWxfaW5jbHVkZV9kaXJzOiBbCisgICAgICAgICJpbmNsdWRlL251cGxheWVyIiwKKyAgICBdLAorCisgICAgZXhwb3J0X2luY2x1ZGVfZGlyczogWworICAgICAgICAiaW5jbHVkZSIsCisgICAgXSwKKwogICAgIGhlYWRlcl9saWJzOiBbCiAgICAgICAgICJsaWJtZWRpYWRybV9oZWFkZ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QX1JSOgorICAgICAgICB7CisgICAgICAgICAgICBpbnQ2NF90IHJlY3ZUaW1lVXM7CisgICAgICAgICAgICBpbnQzMl90IHNlbmRlcklkOworICAgICAgICAgICAgaW50MzJfdCBzc3JjOworICAgICAgICAgICAgaW50MzJfdCBmcmFjdGlvbjsKKyAgICAgICAgICAgIGludDMyX3QgbG9zdDsKKyAgICAgICAgICAgIGludDMyX3QgbGFzdFNlcTsKKyAgICAgICAgICAgIGludDMyX3Qgaml0dGVyOworICAgICAgICAgICAgaW50MzJfdCBsc3I7CisgICAgICAgICAgICBpbnQzMl90IGRsc3I7CisgICAgICAgICAgICBDSEVDSyhtc2ctPmZpbmRJbnQ2NCgicmVjdi10aW1lLXVzIiwgJnJlY3ZUaW1lVXMpKTsKKyAgICAgICAgICAgIENIRUNLKG1zZy0+ZmluZEludDMyKCJydGNwLXJyLXNzcmMiLCAmc2VuZGVySWQpKTsKKyAgICAgICAgICAgIENIRUNLKG1zZy0+ZmluZEludDMyKCJydGNwLXJyYi1zc3JjIiwgJnNzcmMpKTsKKyAgICAgICAgICAgIENIRUNLKG1zZy0+ZmluZEludDMyKCJydGNwLXJyYi1mcmFjdGlvbiIsICZmcmFjdGlvbikpOworICAgICAgICAgICAgQ0hFQ0sobXNnLT5maW5kSW50MzIoInJ0Y3AtcnJiLWxvc3QiLCAmbG9zdCkpOworICAgICAgICAgICAgQ0hFQ0sobXNnLT5maW5kSW50MzIoInJ0Y3AtcnJiLWxhc3RTZXEiLCAmbGFzdFNlcSkpOworICAgICAgICAgICAgQ0hFQ0sobXNnLT5maW5kSW50MzIoInJ0Y3AtcnJiLWppdHRlciIsICZqaXR0ZXIpKTsKKyAgICAgICAgICAgIENIRUNLKG1zZy0+ZmluZEludDMyKCJydGNwLXJyYi1sc3IiLCAmbHNyKSk7CisgICAgICAgICAgICBDSEVDSyhtc2ctPmZpbmRJbnQzMigicnRjcC1ycmItZGxzciIsICZkbHNyKSk7CisgICAgICAgICAgICBpbi53cml0ZUludDMyKHJlY3ZUaW1lVXMgPj4gMzIpOworICAgICAgICAgICAgaW4ud3JpdGVJbnQzMihyZWN2VGltZVVzICYgMHhGRkZGRkZGRik7CisgICAgICAgICAgICBpbi53cml0ZUludDMyKHNlbmRlcklkKTsKKyAgICAgICAgICAgIGluLndyaXRlSW50MzIoc3NyYyk7CisgICAgICAgICAgICBpbi53cml0ZUludDMyKGZyYWN0aW9uKTsKKyAgICAgICAgICAgIGluLndyaXRlSW50MzIobG9zdCk7CisgICAgICAgICAgICBpbi53cml0ZUludDMyKGxhc3RTZXEpOworICAgICAgICAgICAgaW4ud3JpdGVJbnQzMihqaXR0ZXIpOworICAgICAgICAgICAgaW4ud3JpdGVJbnQzMihsc3IpOworICAgICAgICAgICAgaW4ud3JpdGVJbnQzMihkbHNyKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CiAgICAgICAgIGNhc2UgQVJUUFNvdXJjZTo6UlRDUF9UU0ZCOiAgIC8vIFJUQ1AgVFNGQgogICAgICAgICBjYXNlIEFSVFBTb3VyY2U6OlJUQ1BfUFNGQjogICAvLyBSVENQIFBTRkIKICAgICAgICAgY2FzZSBBUlRQU291cmNlOjpSVFBfQVVUT0RPV046CmRpZmYgLS1naXQgYS9tZWRpYS9saWJtZWRpYXBsYXllcnNlcnZpY2UvbnVwbGF5ZXIvTnVQbGF5ZXJEZWNvZGVyLmNwcCBiL21lZGlhL2xpYm1lZGlhcGxheWVyc2VydmljZS9udXBsYXllci9OdVBsYXllckRlY29kZXIuY3BwCmluZGV4IDJjMWYxNTguLjUyYjIwNDEgMTAwNjQ0Ci0tLSBhL21lZGlhL2xpYm1lZGlhcGxheWVyc2VydmljZS9udXBsYXllci9OdVBsYXllckRlY29kZXIuY3BwCisrKyBiL21lZGlhL2xpYm1lZGlhcGxheWVyc2VydmljZS9udXBsYXllci9OdVBsYXllckRlY29kZXIuY3BwCkBAIC00MCwxMCArNDAsOSBAQAogI2luY2x1ZGUgPG1lZGlhL3N0YWdlZ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KQEAgLTc5Myw2ICs3OTcsMjAgQEAKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIEFMT0dWKCJBdWRpbyBPZmZsb2FkIHRlYXIgZG93biBkdWUgdG8gcGF1c2UgdGltZW91dC4iKTsKICAgICAgICAgICAgIG9uQXVkaW9UZWFyRG93bihrRHVlVG9UaW1lb3V0KTsKKyAgICAgICAgICAgIHNwPEFNZXNzYWdlPiBuZXdNc2cgPSBuZXcgQU1lc3NhZ2Uoa1doYXRSZWxlYXNlV2FrZUxvY2ssIHRoaXMpOworICAgICAgICAgICAgbmV3TXNnLT5zZXRJbnQzMigiZHJhaW5HZW5lcmF0aW9uIiwgZ2VuZXJhdGlvbik7CisgICAgICAgICAgICBuZXdNc2ctPnBvc3Qoa1dha2Vsb2NrUmVsZWFzZURlbGF5VXMpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKworICAgICAgICBjYXNlIGtXaGF0UmVsZWFzZVdha2VMb2NrOgorICAgICAgICB7CisgICAgICAgICAgICBpbnQzMl90IGdlbmVyYXRpb247CisgICAgICAgICAgICBDSEVDSyhtc2ctPmZpbmRJbnQzMigiZHJhaW5HZW5lcmF0aW9uIiwgJmdlbmVyYXRpb24pKTsKKyAgICAgICAgICAgIGlmIChnZW5lcmF0aW9uICE9IG1BdWRpb09mZmxvYWRQYXVzZVRpbWVvdXRHZW5lcmF0aW9uKSB7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBBTE9HVigicmVsZWFzaW5nIGF1ZGlvIG9mZmxvYWQgcGF1c2Ugd2FrZWxvY2suIik7CiAgICAgICAgICAgICBtV2FrZUxvY2stPnJlbGVhc2UoKTsKICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICB9CkBAIC0xNjczLDI0ICsxNjkxLDE4IEBACiAKICAgICAgICAgbURyYWluQXVkaW9RdWV1ZVBlbmRpbmcgPSBmYWxzZTsKIAotICAgICAgICBpZiAob2ZmbG9hZGluZ0F1ZGlvKCkpIHsKLSAgICAgICAgICAgIG1BdWRpb1NpbmstPnBhdXNlKCk7Ci0gICAgICAgICAgICBtQXVkaW9TaW5rLT5mbHVzaCgpOwotICAgICAgICAgICAgaWYgKCFtUGF1c2VkKSB7Ci0gICAgICAgICAgICAgICAgbUF1ZGlvU2luay0+c3RhcnQoKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIG1BdWRpb1NpbmstPnBhdXNlKCk7Ci0gICAgICAgICAgICBtQXVkaW9TaW5rLT5mbHVzaCgpOworICAgICAgICBtQXVkaW9TaW5rLT5wYXVzZSgpOworICAgICAgICBtQXVkaW9TaW5rLT5mbHVzaCgpOworICAgICAgICBpZiAoIW9mZmxvYWRpbmdBdWRpbygpKSB7CiAgICAgICAgICAgICAvLyBDYWxsIHN0b3AoKSB0byBzaWduYWwgdG8gdGhlIEF1ZGlvU2luayB0byBjb21wbGV0ZWx5IGZpbGwgdGhlCiAgICAgICAgICAgICAvLyBpbnRlcm5hbCBidWZmZXIgYmVmb3JlIHJlc3VtaW5nIHBsYXliYWNrLgogICAgICAgICAgICAgLy8gRklYTUU6IHRoaXMgaXMgaWdub3JlZCBhZnRlciBmbHVzaCgpLgogICAgICAgICAgICAgbUF1ZGlvU2luay0+c3RvcCgpOwotICAgICAgICAgICAgaWYgKCFtUGF1c2VkKSB7Ci0gICAgICAgICAgICAgICAgbUF1ZGlvU2luay0+c3RhcnQoKTsKLSAgICAgICAgICAgIH0KICAgICAgICAgICAgIG1OdW1GcmFtZXNXcml0dGVuID0gMDsKICAgICAgICAgfQorICAgICAgICBpZiAoIW1QYXVzZWQpIHsKKyAgICAgICAgICAgIG1BdWRpb1NpbmstPnN0YXJ0KCk7CisgICAgICAgIH0KICAgICAgICAgbU5leHRBdWRpb0Nsb2NrVXBkYXRlVGltZVVzID0gLTE7CiAgICAgfSBlbHNlIHsKICAgICAgICAgZmx1c2hRdWV1ZSgmbVZpZGVvUXVld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b2YodHVubmVsUGVla0xlZ2FjeU1vZGVDb25maWcpKTsKKyAgICBpZiAoZXJyICE9IE9LKSB7CisgICAgICAgIEFMT0dFKCJkZWNvZGVyIGNhbm5vdCBzZXQgdmlkZW8gcGVlayBsZWdhY3kgbW9kZSB0byAlZCAoZXJyICVkKSIsCisgICAgICAgICAgICAgICAgaXNMZWdhY3ksICBlcnIpOworICAgIH0KICAgICByZXR1cm4gZXJyOwogfQogCkBAIC0zMzA3LDEwICszMzMwLDEyIEBACiAgICAgaWYgKGVyciAhPSBPSykgewogICAgICAgICBBTE9HRSgibmF0aXZlX3dpbmRvd19zZXRfc2lkZWJhbmRfc3RyZWFtKCVwKSBmYWlsZWQhIChlcnIgJWQpLiIsCiAgICAgICAgICAgICAgICAgc2lkZWJhbmRIYW5kbGUsIGVycik7Ci0gICAgICAgIHJldHVybiBlcnI7CiAgICAgfQogCi0gICAgcmV0dXJuIE9LOworICAgIG5hdGl2ZV9oYW5kbGVfY2xvc2Uoc2lkZWJhbmRIYW5kbGUpOworICAgIG5hdGl2ZV9oYW5kbGVfZGVsZXRlKHNpZGViYW5kSGFuZGxlKTsKKworICAgIHJldHVybiBlcnI7CiB9CiAKIHN0YXR1c190IEFDb2RlYzo6c2V0VmlkZW9Qb3J0Rm9ybWF0VHlwZSgKQEAgLTU0MzQsNiArNTQ1OSw3IEBACiAgICAgICAgICAgICAgICAgICAgIG5vdGlmeS0+c2V0SW50MzIoImNoYW5uZWwtY291bnQiLCBwYXJhbXMubkNoYW5uZWxzKTsKICAgICAgICAgICAgICAgICAgICAgbm90aWZ5LT5zZXRJbnQzMigic2FtcGxlLXJhdGUiLCBwYXJhbXMublNhbXBsZVJhdGUpOwogICAgICAgICAgICAgICAgICAgICBub3RpZnktPnNldEludDMyKCJiaXRyYXRlIiwgcGFyYW1zLm5CaXRSYXRlKTsKKyAgICAgICAgICAgICAgICAgICAgbm90aWZ5LT5zZXRJbnQzMigiYWFjLXByb2ZpbGUiLCBwYXJhbXMuZUFBQ1Byb2ZpbGUpOwogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICB9CiAKQEAgLTc5MzEsMTEgKzc5NTcsMjIgQEAKICAgICAgICAgfQogICAgIH0KIAotICAgIGludDMyX3QgdHVubmVsUGVlayA9IDA7Ci0gICAgaWYgKHBhcmFtcy0+ZmluZEludDMyKFRVTk5FTF9QRUVLX0tFWSwgJnR1bm5lbFBlZWspKSB7Ci0gICAgICAgIHN0YXR1c190IGVyciA9IHNldFR1bm5lbFBlZWsodHVubmVsUGVlayk7Ci0gICAgICAgIGlmIChlcnIgIT0gT0spIHsKLSAgICAgICAgICAgIHJldHVybiBlcnI7CisgICAgeworICAgICAgICBpbnQzMl90IHR1bm5lbFBlZWsgPSAwOworICAgICAgICBpZiAocGFyYW1zLT5maW5kSW50MzIoVFVOTkVMX1BFRUtfS0VZLCAmdHVubmVsUGVlaykpIHsKKyAgICAgICAgICAgIHN0YXR1c190IGVyciA9IHNldFR1bm5lbFBlZWsodHVubmVsUGVlayk7CisgICAgICAgICAgICBpZiAoZXJyICE9IE9LKSB7CisgICAgICAgICAgICAgICAgcmV0dXJuIGVycjsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KKyAgICB7CisgICAgICAgIGludDMyX3QgdHVubmVsUGVla1NldExlZ2FjeSA9IDA7CisgICAgICAgIGlmIChwYXJhbXMtPmZpbmRJbnQzMihUVU5ORUxfUEVFS19TRVRfTEVHQUNZX0tFWSwgJnR1bm5lbFBlZWtTZXRMZWdhY3kpKSB7CisgICAgICAgICAgICBzdGF0dXNfdCBlcnIgPSBzZXRUdW5uZWxQZWVrTGVnYWN5KHR1bm5lbFBlZWtTZXRMZWdhY3kpOworICAgICAgICAgICAgaWYgKGVyciAhPSBPSykgeworICAgICAgICAgICAgICAgIHJldHVybiBlcnI7CisgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICB9CiAKQEAgLTkyMDgsNCArOTI0NSwxOSBAQAogICAgIHJ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xMjUsNiArMTI2LDcgQEAKICAgICBdLAogCiAgICAgc2hhcmVkX2xpYnM6IFsKKyAgICAgICAgImxpYmF1ZGlvdXRpbHMiLAogICAgICAgICAibGliZ3VpIiwKICAgICAgICAgImxpYmhpZGxhbGxvY2F0b3J1dGlscyIsCiAgICAgICAgICJsaWJsb2ciLApAQCAtMjUxLDYgKzI1Myw0MCBAQAogICAgICAgICBdLAogICAgIH0sCiB9CisKK2NjX2xpYnJhcnlfc2hhcmVkIHsKKyAgICBuYW1lOiAibGlic3RhZ2VmcmlnaHRfc3VyZmFjZV91dGlscyIsCisKKyAgICBzcmNzOiBbCisgICAgICAgICJTdXJmYWNlVXRpbHMuY3BwIiwKKyAgICBdLAorCisgICAgc2hhcmVkX2xpYnM6IFsKKyAgICAgICAgImxpYmd1aSIsCisgICAgICAgICJsaWJsb2ciLAorICAgICAgICAibGlidWkiLAorICAgICAgICAibGlidXRpbHMiLAorICAgIF0sCisKKyAgICBleHBvcnRfaW5jbHVkZV9kaXJzOiBbCisgICAgICAgICJpbmNsdWRlIiwKKyAgICBdLAorCisgICAgY2ZsYWdzOiBbCisgICAgICAgICItV25vLW11bHRpY2hhciIsCisgICAgICAgICItV2Vycm9yIiwKKyAgICAgICAgIi1XYWxsIiwKKyAgICBdLAorCisgICAgc2FuaXRpemU6IHsKKyAgICAgICAgY2ZpOiB0cnVlLAorICAgICAgICBtaXNjX3VuZGVmaW5lZDogWworICAgICAgICAgICAgInVuc2lnbmVkLWludGVnZXItb3ZlcmZsb3ciLAorICAgICAgICAgICAgInNpZ25lZC1pbnRlZ2VyLW92ZXJmbG93IiwKKyAgICAgICAgXSwKKyAgICB9LAorfQorCiBjY19saWJyYXJ5IHsKICAgICBuYW1lOiAibGlic3RhZ2VmcmlnaHQiLAogCkBAIC0yNjYsNyArMzAyLDYgQEAKICAgICAgICAgIkNhbGxiYWNrTWVkaWFTb3VyY2UuY3BwIiwKICAgICAgICAgIkNhbWVyYVNvdXJjZS5jcHAiLAogICAg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gICAgaW50MzJfdCBzbGljZV9oZWlnaHQ7CisgICAgaWYgKG91dHB1dEZvcm1hdC0+ZmluZEludDMyKCJzbGljZS1oZWlnaHQiLCAmc2xpY2VfaGVpZ2h0KSAmJiBzbGljZV9oZWlnaHQgPiAwKSB7CisgICAgICAgIGhlaWdodCA9IHNsaWNlX2hlaWdodDsKKyAgICB9CisKKyAgICB1aW50MzJfdCBiaXREZXB0aCA9IDg7CisgICAgaWYgKENPTE9SX0Zvcm1hdFlVVlAwMTAgPT0gc3JjRm9ybWF0KSB7CisgICAgICAgIGJpdERlcHRoID0gMTA7CisgICAgfQorCiAgICAgaWYgKG1GcmFtZSA9PSBOVUxMKSB7CiAgICAgICAgIHNwPElNZW1vcnk+IGZyYW1lTWVtID0gYWxsb2NWaWRlb0ZyYW1lKAogICAgICAgICAgICAgICAgIHRyYWNrTWV0YSgpLApAQCAtNjQzLDYgKzY2Miw3IEBACiAgICAgICAgICAgICAgICAgMCwKICAgICAgICAgICAgICAgICAwLAogICAgICAgICAgICAgICAgIGRzdEJwcCgpLAorICAgICAgICAgICAgICAgIGJpdERlcHRoLAogICAgICAgICAgICAgICAgIG1DYXB0dXJlTGF5ZXIgIT0gbnVsbHB0ciAvKmFsbG9jUm90YXRlZCovKTsKICAgICAgICAgaWYgKGZyYW1lTWVtID09IG51bGxwdHIpIHsKICAgICAgICAgICAgIHJldHVybiBOT19NRU1PUlk7CkBAIC04MzQsOCArODU0LDExIEBACiAgICAgICAgIHJldHVybiBOVUxMOwogICAgIH0KIAotICAgIC8vIFRPRE86IFVzZSBGbGV4aWJsZSBjb2xvciBpbnN0ZWFkCi0gICAgdmlkZW9Gb3JtYXQtPnNldEludDMyKCJjb2xvci1mb3JtYXQiLCBPTVhfQ09MT1JfRm9ybWF0WVVWNDIwUGxhbmFyKTsKKyAgICBpZiAoZHN0Rm9ybWF0KCkgPT0gQ09MT1JfRm9ybWF0MzJiaXRBQkdSMjEwMTAxMCkgeworICAgICAgICB2aWRlb0Zvc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W4gZ2V0IHRoZSB1cGRhdGVkIGRyaWZ0IHRpbWUgaW5mb3JtYXRpb24KQEAgLTM0NzQsOCArMzU0NCwyNyBAQAogICAgICAgICAgICAgICAgICAgICBlcnIgPSBjb3B5Q29kZWNTcGVjaWZpY0RhdGEoKGNvbnN0IHVpbnQ4X3QgKilidWZmZXItPmRhdGEoKSArIGJ1ZmZlci0+cmFuZ2Vfb2Zmc2V0KCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyLT5yYW5nZV9sZW5ndGgoKSk7CiAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGlmIChtSXNEb3ZpKSB7CisgICAgICAgICAgICAgICAgICAgIGVyciA9IGdldERvbGJ5VmlzaW9uUHJvZmlsZSgpOworICAgICAgICAgICAgICAgICAgICBpZihlcnIgPT0gT0spIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZvaWQgKmRhdGEgPSBOVUxMOworICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90IHNpemUgPSAwOworICAgICAgICAgICAgICAgICAgICAgICAgdWludDMyX3QgdHlwZSA9IDA7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAobURvdmlQcm9maWxlID09IERvbGJ5VmlzaW9uUHJvZmlsZUR2YXZTZSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1NZXRhLT5maW5kRGF0YShrS2V5QVZDQywgJnR5cGUsICZkYXRhLCAmc2l6ZSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG1Eb3ZpUHJvZmlsZSA8IERvbGJ5VmlzaW9uUHJvZmlsZUR2YXZTZSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1NZXRhLT5maW5kRGF0YShrS2V5SFZDQywgJnR5cGUsICZkYXRhLCAmc2l6ZSk7CisgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFMT0dXKCJEViBQcm9maWxlcyA+IERvbGJ5VmlzaW9uUHJvZmlsZUR2YXZTZSBhcmUgbm90IHN1cHBvcnRlZCIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVyciA9IEVSUk9SX01BTEZPUk1FRDsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnIgPT0gT0sgJiYgZGF0YSAhPSBOVUxMICYmCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29weUNvZGVjU3BlY2lmaWNEYXRhKCh1aW50OF90ICopZGF0YSwgc2l6ZSkgPT0gT0spIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUdvdEFsbENvZGVjU3BlY2lmaWNEYXRhID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KLQogICAgICAgICAgICAgYnVmZmVyLT5yZWxlYXNlKCk7CiAgICAgICAgICAgICBidWZmZXIgPSBOVUxMOwogICAgICAgICAgICAgaWYgKE9LICE9IGVycikgewpAQCAtNDE3Myw2ICs0MjYyLDcgQEAKICAgICAgICAgIXN0cmNhc2VjbXAoTUVESUFfTUlNRVRZUEVfVklERU9fTVBFRzQsIG1pbWUpIHx8CiAgICAgICAgICFzdHJjYXNlY21wKE1FRElBX01JTUVUWVBFX1ZJREVPX0FWQywgbWltZSkgfHwKICAgICAgICAgIXN0cmNhc2VjbXAoTUVESUFfTUlNRVRZUEVfVklERU9fSEVWQywgbWltZSkgfHwKKyAgICAgICAgIXN0cmNhc2VjbXAoTUVESUFfTUlNRVRZUEVfVklERU9fRE9MQllfVklTSU9OLCBtaW1lKSB8fAogICAgICAgICAhc3RyY2FzZWNtcChNRURJQV9NSU1FVFlQRV9JTUFHRV9BTkRST0lEX0hFSUMsIG1pbWUpKSB7CiAgICAgICAgIGlmICghbUNvZGVjU3BlY2lmaWN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gKGludDMyX3QqKSZhc3BlY3RzLm1SYW5nZSkpIHsKLSAgICAgICAgaW50MzJfdCBwcmltYXJpZXMsIHRyYW5zZmVyLCBjb2VmZnM7Ci0gICAgICAgIGJvb2wgZnVsbFJhbmdlOwotICAgICAgICBBTE9HVigicHJpbWFyaWVzPSVzIHRyYW5zZmVyPSVzIG1hdHJpeD0lcyByYW5nZT0lcyIsCi0gICAgICAgICAgICAgICAgYXNTdHJpbmcoYXNwZWN0cy5tUHJpbWFyaWVzKSwKLSAgICAgICAgICAgICAgICBhc1N0cmluZyhhc3BlY3RzLm1UcmFuc2ZlciksCi0gICAgICAgICAgICAgICAgYXNTdHJpbmcoYXNwZWN0cy5tTWF0cml4Q29lZmZzKSwKLSAgICAgICAgICAgICAgICBhc1N0cmluZyhhc3BlY3RzLm1SYW5nZSkpOwotICAgICAgICBDb2xvclV0aWxzOjpjb252ZXJ0Q29kZWNDb2xvckFzcGVjdHNUb0lzb0FzcGVjdHMoCi0gICAgICAgICAgICAgICAgYXNwZWN0cywgJnByaW1hcmllcywgJnRyYW5zZmVyLCAmY29lZmZzLCAmZnVsbFJhbmdlKTsKLSAgICAgICAgbU93bmVyLT5iZWdpbkJveCgiY29sciIpOwotICAgICAgICBtT3duZXItPndyaXRlRm91cmNjKCJuY2x4Iik7Ci0gICAgICAgIG1Pd25lci0+d3JpdGVJbnQxNihwcmltYXJpZXMpOwotICAgICAgICBtT3duZXItPndyaXRlSW50MTYodHJhbnNmZXIpOwotICAgICAgICBtT3duZXItPndyaXRlSW50MTYoY29lZmZzKTsKLSAgICAgICAgbU93bmVyLT53cml0ZUludDgoaW50OF90KGZ1bGxSYW5nZSA/IDB4ODAgOiAweDApKTsKLSAgICAgICAgbU93bmVyLT5lbmRCb3goKTsgLy8gY29scgotICAgIH0gZWxzZSB7CisgICAgYm9vbCBmaW5kUHJpbWFyaWVzID0gbWV0YS0+ZmluZEludDMyKGtLZXlDb2xvclByaW1hcmllcywgKGludDMyX3QqKSZhc3BlY3RzLm1QcmltYXJpZXMpOworICAgIGJvb2wgZmluZFRyYW5zZmVyID0gbWV0YS0+ZmluZEludDMyKGtLZXlUcmFuc2ZlckZ1bmN0aW9uLCAoaW50MzJfdCopJmFzcGVjdHMubVRyYW5zZmVyKTsKKyAgICBib29sIGZpbmRNYXRyaXggPSBtZXRhLT5maW5kSW50MzIoa0tleUNvbG9yTWF0cml4LCAoaW50MzJfdCopJmFzcGVjdHMubU1hdHJpeENvZWZmcyk7CisgICAgYm9vbCBmaW5kUmFuZ2UgPSBtZXRhLT5maW5kSW50MzIoa0tleUNvbG9yUmFuZ2UsIChpbnQzMl90KikmYXNwZWN0cy5tUmFuZ2UpOworICAgIGlmICghZmluZFByaW1hcmllcyAmJiAhZmluZFRyYW5zZmVyICYmICFmaW5kTWF0cml4ICYmICFmaW5kUmFuZ2UpIHsKICAgICAgICAgQUxPR1YoIm5vIGNvbG9yIGluZm9ybWF0aW9uIik7CisgICAgICAgIHJldHVybjsKICAgICB9CisKKyAgICBpbnQzMl90IHByaW1hcmllcywgdHJhbnNmZXIsIGNvZWZmczsKKyAgICBib29sIGZ1bGxSYW5nZTsKKyAgICBBTE9HVigicHJpbWFyaWVzPSVzIHRyYW5zZmVyPSVzIG1hdHJpeD0lcyByYW5nZT0lcyIsCisgICAgICAgICAgICBhc1N0cmluZyhhc3BlY3RzLm1QcmltYXJpZXMpLAorICAgICAgICAgICAgYXNTdHJpbmcoYXNwZWN0cy5tVHJhbnNmZXIpLAorICAgICAgICAgICAgYXNTdHJpbmcoYXNwZWN0cy5tTWF0cml4Q29lZmZzKSwKKyAgICAgICAgICAgIGFzU3RyaW5nKGFzcGVjdHMubVJhbmdlKSk7CisgICAgQ29sb3JVdGlsczo6Y29udmVydENvZGVjQ29sb3JBc3BlY3RzVG9Jc29Bc3BlY3RzKAorICAgICAgICAgICAgYXNwZWN0cywgJnByaW1hcmllcywgJnRyYW5zZmVyLCAmY29lZmZzLCAmZnVsbFJhbmdlKTsKKyAgICBtT3duZXItPmJlZ2luQm94KCJjb2xyIik7CisgICAgbU93bmVyLT53cml0ZUZvdXJjYygibmNseCIpOworICAgIG1Pd25lci0+d3JpdGVJbnQxNihwcmltYXJpZXMpOworICAgIG1Pd25lci0+d3JpdGVJbnQxNih0cmFuc2Zlcik7CisgICAgbU93bmVyLT53cml0ZUludDE2KGNvZWZmcyk7CisgICAgbU93bmVyLT53cml0ZUludDgoaW50OF90KGZ1bGxSYW5nZSA/IDB4ODAgOiAweDApKTsKKyAgICBtT3duZXItPmVuZEJveCgpOyAvLyBjb2xyCit9CisKK3ZvaWQgTVBFRzRXcml0ZXI6OlRyYWNrOjp3cml0ZU1kY3ZBbmRDbGxpQm94ZXMoKSB7CisgICAgc3A8TWV0YURhdGE+IG1ldGEgPSBtU291cmNlLT5nZXRGb3JtYXQoKTsKKyAgICB1aW50MzJfdCB0eXBlOworICAgIGNvbnN0IHVpbnQ4X3QqIGRhdGE7CisgICAgc2l6ZV90IHNpemU7CisgICAgYm9vbCBmb3VuZCA9CisgICAgICAgICAgICBtZXRhLT5maW5kRGF0YShrS2V5SGRyU3RhdGljSW5mbywgJnR5cGUsIHJlaW50ZXJwcmV0X2Nhc3Q8Y29uc3Qgdm9pZCoqPigmZGF0YSksICZzaXplKTsKKyAgICBpZiAoIWZvdW5kKSB7CisgICAgICAgIHJldHVybjsgLy8gTm90aGluZyB0byBlbmNvZGUuCisgICAgfQorICAgIGlmIChzaXplICE9IDI1KSB7CisgICAgICAgIEFMT0dXKCJJZ25vcmluZyBIRFIgc3RhdGljIGluZm8gd2l0aCB1bmV4cGVjdGVkIHNpemUgJWQiLCAoaW50KXNpemUpOworICAgICAgICByZXR1cm47CisgICAgfQorICAgIHVpbnQxNl90IGRpc3BsYXlQcmltYXJpZXNSWCA9IFUxNkxFX0FUKCZkYXRhWzFdKTsKKyAgICB1aW50MTZfdCBkaXNwbGF5UHJpbWFyaWVzUlkgPSBVMTZMRV9BVCgmZGF0YVszXSk7CisKKyAgICB1aW50MTZf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Db2RlYy5wcm9tb3RlKCk7CiAgICAgICAgIGlmIChjb2RlYyA9PSBOVUxMKSB7Ci0gICAgICAgICAgICAvLyBjb2RlYyBpcyBhbHJlYWR5IGdvbmUuCisgICAgICAgICAgICAvLyBDb2RlYyBpcyBhbHJlYWR5IGdvbmUsIHNvIHJlbW92ZSB0aGUgcmVzb3VyY2VzIGFzIHdlbGwKKyAgICAgICAgICAgIDo6bmRrOjpTcEFJQmluZGVyIGJpbmRlcihBU2VydmljZU1hbmFnZXJfZ2V0U2VydmljZSgibWVkaWEucmVzb3VyY2VfbWFuYWdlciIpKTsKKyAgICAgICAgICAgIHN0ZDo6c2hhcmVkX3B0cjxJUmVzb3VyY2VNYW5hZ2VyU2VydmljZT4gc2VydmljZSA9CisgICAgICAgICAgICAgICAgICAgIElSZXNvdXJjZU1hbmFnZXJTZXJ2aWNlOjpmcm9tQmluZGVyKGJpbmRlcik7CisgICAgICAgICAgICBpZiAoc2VydmljZSA9PSBudWxscHRyKSB7CisgICAgICAgICAgICAgICAgQUxPR1coIk1lZGlhQ29kZWM6OlJlc291cmNlTWFuYWdlckNsaWVudCB1bmFibGUgdG8gZmluZCBSZXNvdXJjZU1hbmFnZXJTZXJ2aWNlIik7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBzZXJ2aWNlLT5yZW1vdmVDbGllbnQobVBpZCwgZ2V0SWQodGhpcykpOwogICAgICAgICAgICAgKl9haWRsX3JldHVybiA9IHRydWU7CiAgICAgICAgICAgICByZXR1cm4gU3RhdHVzOjpvaygpOwogICAgICAgICB9CkBAIC0yMzgsNiArMjYwLDcgQEAKIAogcHJpdmF0ZToKICAgICB3cDxNZWRpYUNvZGVjPiBtTWVkaWFDb2RlYzsKKyAgICBpbnQzMl90IG1QaWQ7CiAKICAgICBESVNBTExPV19FVklMX0NPTlNUUlVDVE9SUyhSZXNvdXJjZU1hbmFnZXJDbGllbnQpOwogfTsKQEAgLTI0Nyw3ICsyNzAsNyBAQAogICAgICAgICAgICAgY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kYXRlSERSRm9ybWF0TWV0cmljKCkgeworICAgIGludDMyX3QgcHJvZmlsZSA9IC0xOworICAgIEFTdHJpbmcgbWVkaWFUeXBlOworICAgIGlmIChtT3V0cHV0Rm9ybWF0LT5maW5kSW50MzIoS0VZX1BST0ZJTEUsICZwcm9maWxlKQorICAgICAgICAgICAgJiYgbU91dHB1dEZvcm1hdC0+ZmluZFN0cmluZygibWltZSIsICZtZWRpYVR5cGUpKSB7CisgICAgICAgIGhkcl9mb3JtYXQgaGRyRm9ybWF0ID0gZ2V0SERSRm9ybWF0KHByb2ZpbGUsIG1Db25maWdDb2xvclRyYW5zZmVyLCBtZWRpYVR5cGUpOworICAgICAgICBtZWRpYW1ldHJpY3Nfc2V0SW50MzIobU1ldHJpY3NIYW5kbGUsIGtDb2RlY0hEUkZvcm1hdCwgc3RhdGljX2Nhc3Q8aW50PihoZHJGb3JtYXQpKTsKKyAgICB9Cit9CisKK2hkcl9mb3JtYXQgTWVkaWFDb2RlYzo6Z2V0SERSRm9ybWF0KGNvbnN0IGludDMyX3QgcHJvZmlsZSwgY29uc3QgaW50MzJfdCB0cmFuc2ZlciwKKyAgICAgICAgY29uc3QgQVN0cmluZyAmbWVkaWFUeXBlKSB7CisgICAgc3dpdGNoICh0cmFuc2ZlcikgeworICAgICAgICBjYXNlIENPTE9SX1RSQU5TRkVSX1NUMjA4NDoKKyAgICAgICAgICAgIGlmIChtZWRpYVR5cGUuZXF1YWxzSWdub3JlQ2FzZShNRURJQV9NSU1FVFlQRV9WSURFT19WUDkpKSB7CisgICAgICAgICAgICAgICAgc3dpdGNoIChwcm9maWxlKSB7CisgICAgICAgICAgICAgICAgICAgIGNhc2UgVlA5UHJvZmlsZTJIRFI6CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gSERSX0ZPUk1BVF9IRFIxMDsKKyAgICAgICAgICAgICAgICAgICAgY2FzZSBWUDlQcm9maWxlMkhEUjEwUGx1czoKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBIRFJfRk9STUFUX0hEUjEwUExVUzsKKyAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBIRFJfRk9STUFUX05PTkU7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfSBlbHNlIGlmIChtZWRpYVR5cGUuZXF1YWxzSWdub3JlQ2FzZShNRURJQV9NSU1FVFlQRV9WSURFT19BVjEpKSB7CisgICAgICAgICAgICAgICAgc3dpdGNoIChwcm9maWxlKSB7CisgICAgICAgICAgICAgICAgICAgIGNhc2UgQVYxUHJvZmlsZU1haW4xMEhEUjEwOgorICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEhEUl9GT1JNQVRfSERSMTA7CisgICAgICAgICAgICAgICAgICAgIGNhc2UgQVYxUHJvZmlsZU1haW4xMEhEUjEwUGx1czoKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBIRFJfRk9STUFUX0hEUjEwUExVUzsKKyAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBIRFJfRk9STUFUX05PTkU7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfSBlbHNlIGlmIChtZWRpYVR5cGUuZXF1YWxzSWdub3JlQ2FzZShNRURJQV9NSU1FVFlQRV9WSURFT19IRVZDKSkgeworICAgICAgICAgICAgICAgIHN3aXRjaCAocHJvZmlsZSkgeworICAgICAgICAgICAgICAgICAgICBjYXNlIEhFVkNQcm9maWxlTWFpbjEwSERSMTA6CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gSERSX0ZPUk1BVF9IRFIxMDsKKyAgICAgICAgICAgICAgICAgICAgY2FzZSBIRVZDUHJvZmlsZU1haW4xMEhEUjEwUGx1czoKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBIRFJfRk9STUFUX0hEUjEwUExVUzsKKyAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBIRFJfRk9STUFUX05PTkU7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICByZXR1cm4gSERSX0ZPUk1BVF9OT05FOworICAgICAgICAgICAgfQorICAgICAgICBjYXNlIENPTE9SX1RSQU5TRkVSX0hMRzoKKyAgICAgICAgICAgIGlmICghbWVkaWFUeXBlLmVxdWFsc0lnbm9yZUNhc2UoTUVESUFfTUlNRVRZUEVfVklERU9fRE9MQllfVklTSU9OKSkgeworICAgICAgICAgICAgICAgIHJldHVybiBIRFJfRk9STUFUX0hMRzsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgLy8gVE9ETzogRE9MQlkgZm9ybWF0CisgICAgICAgICAgICAgICAgcmV0dXJuIEhEUl9GT1JNQVRfTk9ORTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgIHJldHVybiBIRFJfRk9STUFUX05PTkU7CisgICAgfQorfQorCisKIHZvaWQgTWVkaWFDb2RlYzo6dXBkYXRlRXBoZW1lcmFsTWVkaWFtZXRyaWNzKG1lZGlhbWV0cmljc19oYW5kbGVfdCBpdGVtKSB7CiAgICAgQUxPR0QoIk1lZGlhQ29kZWM6OnVwZGF0ZUVwaGVtZXJhbE1lZGlhbWV0cmljcygpIik7CiAKQEAgLTk3MSw2ICsxMDg3LDggQEAKIAogY29uc3RleHByIGNvbnN0IGNoYXIgKk1lZGlhQ29kZWM6OmFzU3RyaW5nKFR1bm5lbFBlZWtTdGF0ZSBzdGF0ZSwgY29uc3QgY2hhciAqZGVmYXVsdF9zdHJpbmcpewogICAgIHN3aXRjaChzdGF0ZSkgeworICAgICAgICBjYXNlIFR1bm5lbFBlZWtTdGF0ZTo6a0xlZ2FjeU1vZGU6CisgICAgICAgICAgICByZXR1cm4gIkxlZ2FjeU1vZGUiOwogICAgICAgICB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jCisgICAgICAgIHJldHVybiBlcnI7CisgICAgfQogCiAgICAgLy8gc2F2ZSBpbml0IHBhcmFtZXRlcnMgZm9yIHJlc2V0CiAgICAgbUluaXROYW1lID0gbmFtZTsKQEAgLTEzNzgsNyArMTUwNiw3IEBACiAgICAgYm9vbCBzZWN1cmVDb2RlYyA9IGZhbHNlOwogICAgIGNvbnN0IGNoYXIgKm93bmVyID0gIiI7CiAgICAgaWYgKCFuYW1lLnN0YXJ0c1dpdGgoImFuZHJvaWQuZmlsdGVyLiIpKSB7Ci0gICAgICAgIHN0YXR1c190IGVyciA9IG1HZXRDb2RlY0luZm8obmFtZSwgJm1Db2RlY0luZm8pOworICAgICAgICBlcnIgPSBtR2V0Q29kZWNJbmZvKG5hbWUsICZtQ29kZWNJbmZvKTsKICAgICAgICAgaWYgKGVyciAhPSBPSykgewogICAgICAgICAgICAgbUNvZGVjID0gTlVMTDsgIC8vIHJlbW92ZSB0aGUgY29kZWMuCiAgICAgICAgICAgICByZXR1cm4gZXJyOwpAQCAtMTM5Miw3ICsxNTIwLDEzIEBACiAgICAgICAgIG1Db2RlY0luZm8tPmdldFN1cHBvcnRlZE1lZGlhVHlwZXMoJm1lZGlhVHlwZXMpOwogICAgICAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IG1lZGlhVHlwZXMuc2l6ZSgpOyArK2kpIHsKICAgICAgICAgICAgIGlmIChtZWRpYVR5cGVzW2ldLnN0YXJ0c1dpdGgoInZpZGVvLyIpKSB7Ci0gICAgICAgICAgICAgICAgbUlzVmlkZW8gPSB0cnVlOworICAgICAgICAgICAgICAgIG1Eb21haW4gPSBET01BSU5fVklERU87CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICB9IGVsc2UgaWYgKG1lZGlhVHlwZXNbaV0uc3RhcnRzV2l0aCgiYXVkaW8vIikpIHsKKyAgICAgICAgICAgICAgICBtRG9tYWluID0gRE9NQUlOX0FVRElPOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgfSBlbHNlIGlmIChtZWRpYVR5cGVzW2ldLnN0YXJ0c1dpdGgoImltYWdlLyIpKSB7CisgICAgICAgICAgICAgICAgbURvbWFpbiA9IERPTUFJTl9JTUFHRTsKICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIH0KICAgICAgICAgfQpAQCAtMTQwNSwxMiArMTUzOSwxNyBAQAogICAgICAgICByZXR1cm4gTkFNRV9OT1RfRk9VTkQ7CiAgICAgfQogCi0gICAgaWYgKG1Jc1ZpZGVvKSB7CisgICAgaWYgKG1Eb21haW4gPT0gRE9NQUlOX1ZJREVPKSB7CiAgICAgICAgIC8vIHZpZGVvIGNvZGVjIG5lZWRzIGRlZGljYXRlZCBsb29wZXIKICAgICAgICAgaWYgKG1Db2RlY0xvb3BlciA9PSBOVUxMKSB7CisgICAgICAgICAgICBzdGF0dXNfdCBlcnIgPSBPSzsKICAgICAgICAgICAgIG1Db2RlY0xvb3BlciA9IG5ldyBBTG9vcGVyOwogICAgICAgICAgICAgbUNvZGVjTG9vcGVyLT5zZXROYW1lKCJDb2RlY0xvb3BlciIpOwotICAgICAgICAgICAgbUNvZGVjTG9vcGVyLT5zdGFydChmYWxzZSwgZmFsc2UsIEFORFJPSURfUFJJT1JJVFlfQVVESU8pOworICAgICAgICAgICAgZXJyID0gbUNvZGVjTG9vcGVyLT5zdGFydChmYWxzZSwgZmFsc2UsIEFORFJPSURfUFJJT1JJVFlfQVVESU8pOworICAgICAgICAgICAgaWYgKE9LICE9IGVycikgeworICAgICAgICAgICAgICAgIEFMT0dFKCJDb2RlYyBMb29wZXIgZmFpbGVkIHRvIHN0YXJ0Iik7CisgICAgICAgICAgICAgICAgcmV0dXJuIGVycjsKKyAgICAgICAgICAgIH0KICAgICAgICAgfQogCiAgICAgICAgIG1Db2RlY0xvb3Blci0+cmVnaXN0ZXJIYW5kbGVyKG1Db2RlYyk7CkBAIC0xNDM4LDE3ICsxNTc3LDE1IEBACiAKICAgICBpZiAobU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hbWV0cmljc19zZXREb3VibGUobU1ldHJpY3NIYW5kbGUsIGtDb2RlY0ZyYW1lUmF0ZSwgZnJhbWVSYXRlKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgZmxvYXQgY2FwdHVyZVJhdGUgPSAtMS4wOworICAgICAgICAgICAgICAgIGlmIChmb3JtYXQtPmZpbmRGbG9hdCgiY2FwdHVyZS1yYXRlIiwgJmNhcHR1cmVSYXRlKSkgeworICAgICAgICAgICAgICAgICAgICBtZWRpYW1ldHJpY3Nfc2V0RG91YmxlKG1NZXRyaWNzSGFuZGxlLCBrQ29kZWNDYXB0dXJlUmF0ZSwgY2FwdHVyZVJhdGUpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBmbG9hdCBvcGVyYXRpbmdSYXRlID0gLTEuMDsKKyAgICAgICAgICAgICAgICBpZiAoZm9ybWF0LT5maW5kRmxvYXQoIm9wZXJhdGluZy1yYXRlIiwgJm9wZXJhdGluZ1JhdGUpKSB7CisgICAgICAgICAgICAgICAgICAgIG1lZGlhbWV0cmljc19zZXREb3VibGUobU1ldHJpY3NIYW5kbGUsIGtDb2RlY09wZXJhdGluZ1JhdGUsIG9wZXJhdGluZ1JhdGUpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBpbnQzMl90IHByaW9yaXR5ID0gLTE7CisgICAgICAgICAgICAgICAgaWYgKGZvcm1hdC0+ZmluZEludDMyKCJwcmlvcml0eSIsICZwcmlvcml0eSkpIHsKKyAgICAgICAgICAgICAgICAgICAgbWVkaWFtZXRyaWNzX3NldEludDMyKG1NZXRyaWNzSGFuZGxlLCBrQ29kZWNQcmlvcml0eSwgcHJpb3JpdHkpOworICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGZsb2F0IGNhcHR1cmVSYXRlID0gLTEuMDsKLSAgICAgICAgICAgIGlmIChmb3JtYXQtPmZpbmRGbG9hdCgiY2FwdHVyZS1y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iLCAmcHJpb3JpdHkpKSB7Ci0gICAgICAgICAgICAgICAgbWVkaWFtZXRyaWNzX3NldEludDMyKG1NZXRyaWNzSGFuZGxlLCBrQ29kZWNQcmlvcml0eSwgcHJpb3JpdHkpOworICAgICAgICAgICAgaW50MzJfdCBjb2xvclRyYW5zZmVyID0gLTE7CisgICAgICAgICAgICBpZiAoZm9ybWF0LT5maW5kSW50MzIoS0VZX0NPTE9SX1RSQU5TRkVSLCAmY29sb3JUcmFuc2ZlcikpIHsKKyAgICAgICAgICAgICAgICBtQ29uZmlnQ29sb3JUcmFuc2ZlciA9IGNvbG9yVHJhbnNmZXI7CisgICAgICAgICAgICAgICAgbWVkaWFtZXRyaWNzX3NldEludDMyKG1NZXRyaWNzSGFuZGxlLCBrQ29kZWNDb25maWdDb2xvclRyYW5zZmVyLCBjb2xvclRyYW5zZmVyKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIEhEUlN0YXRpY0luZm8gaW5mbzsKKyAgICAgICAgICAgIGlmIChDb2xvclV0aWxzOjpnZXRIRFJTdGF0aWNJbmZvRnJvbUZvcm1hdChmb3JtYXQsICZpbmZvKQorICAgICAgICAgICAgICAgICAgICAmJiBDb2xvclV0aWxzOjppc0hEUlN0YXRpY0luZm9WYWxpZCgmaW5mbykpIHsKKyAgICAgICAgICAgICAgICBtSERSU3RhdGljSW5mbyA9IHRydWU7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIAogICAgICAgICAvLyBQcmV2ZW50IHBvc3NpYmxlIGludGVnZXIgb3ZlcmZsb3cgaW4gZG93bnN0cmVhbSBjb2RlLgotICAgICAgICBpZiAobVZpZGVvV2lkdGggPCAwIHx8IG1WaWRlb0hlaWdodCA8IDAgfHwKLSAgICAgICAgICAgICAgICh1aW50NjRfdCltVmlkZW9XaWR0aCAqIG1WaWRlb0hlaWdodCA+ICh1aW50NjRfdClJTlQzMl9NQVggLyA0KSB7Ci0gICAgICAgICAgICBBTE9HRSgiSW52YWxpZCBzaX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0dW5pbmdzLT5jb3VudEVudHJpZXMoKSA+IDApIHsKKyAgICAgICAgbXNnLT5zZXRNZXNzYWdlKCJ0dW5pbmdzIiwgdHVuaW5ncyk7CisgICAgfQogICAgIG1zZy0+c2V0UG9pbnRlcigiZXJyb3JEZXRhaWxNc2ciLCBlcnJvckRldGFpbE1zZyk7CiAKICAgICBzcDxBTWVzc2FnZT4gcmVzcG9uc2U7CkBAIC0yOTc3LDggKzMxNDAsOSBAQAogICAgICAgICAgICAgICAgICAgICBDSEVDSyhtc2ctPmZpbmRJbnQzMigiZXJyIiwgJmVycikpOwogICAgICAgICAgICAgICAgICAgICBDSEVDSyhtc2ctPmZpbmRJbnQzMigiYWN0aW9uQ29kZSIsICZhY3Rpb25Db2RlKSk7CiAKLSAgICAgICAgICAgICAgICAgICAgQUxPR0UoIkNvZGVjIHJlcG9ydGVkIGVyciAlI3gsIGFjdGlvbkNvZGUgJWQsIHdoaWxlIGluIHN0YXRlICVkLyVzIiwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnIsIGFjdGlvbkNvZGUsIG1TdGF0ZSwgc3RhdGVTdHJpbmcobVN0YXRlKS5jX3N0cigpKTsKKyAgICAgICAgICAgICAgICAgICAgQUxPR0UoIkNvZGVjIHJlcG9ydGVkIGVyciAlI3gvJXMsIGFjdGlvbkNvZGUgJWQsIHdoaWxlIGluIHN0YXRlICVkLyVzIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnIsIFN0ck1lZGlhRXJyb3IoZXJyKS5jX3N0cigpLCBhY3Rpb25Db2RlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1TdGF0ZSwgc3RhdGVTdHJpbmcobVN0YXRlKS5jX3N0cigpKTsKICAgICAgICAgICAgICAgICAgICAgaWYgKGVyciA9PSBERUFEX09CSkVDVCkgewogICAgICAgICAgICAgICAgICAgICAgICAgbUZsYWdzIHw9IGtGbGFnU2F3TWVkaWFTZXJ2ZXJEaWU7CiAgICAgICAgICAgICAgICAgICAgICAgICBtRmxhZ3MgJj0gfmtGbGFnSXNDb21wb25lbnRBbGxvY2F0ZWQ7CkBAIC0zMDM0LDEwICszMTk4LDggQEAKICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgU1RPUFBJTkc6CiAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1GbGFncyAmIGtGbGFnU2F3TWVkaWFTZXJ2ZXJEaWUpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBwb3N0UGVuZGluZ1JlcGxpZXMgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobVN0YXRlID09IFJFTEVBU0lORyAmJiAhbVJlcGx5SUQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFMT0dEKCJSZWxlYXNpbmcgYXN5bmNocm9ub3VzbHksIHNvIG5vdGhpbmcgdG8gcmVwbHkgaGVyZS4iKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvc3RQZW5kaW5nUmVwbGllcyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIE1lZGlhU2VydmVyIGRpZWQsIHRoZXJlIGRlZmluaXRlbHkgd29uJ3QKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gYmUgYSBzaHV0ZG93biBjb21wbGV0ZSBub3RpZmljYXRpb24gYWZ0ZXIKQEAgLTMwNTAsOCArMzIxMiwxMSBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobVN0YXRlID09IFJFTEVBU0lORykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNvbXBvbmVudE5hbWUuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocG9zdFBlbmRpbmdSZXBsaWVzKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtUmVwbHlJRCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9zdFBlbmRpbmdSZXBsaWVzQW5kRGVmZXJyZWRNZXNzYWdlcyhvcmlnaW4gKyAiOmRlYWQiKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFMT0dEKCJubyBwZW5kaW5nIHJlcGxpZXM6ICVzOmRlYWQgZm9sbG93aW5nICVzIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9yaWdpbi5jX3N0cigpLCBtTGFzdFJlcGx5T3JpZ2luLmNfc3RyKCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbmRFcnJvclJlc3BvbnNlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICghbVJlcGx5SUQpIHsKQEAgLTMxODcsMTAgKzMzNTIsMTMgQEAKICAgICAgICAgICAgICAgICAgICAgICAgIG1lZGlhbWV0cmljc19zZXRJbnQzMihtTWV0cmljc0hhbmRsZSwga0NvZGVjU2VjdXJlLCAwKTsKICAgICAgICAgICAgICAgICAgICAgfQogCi0gICAgICAgICAgICAgICAgICAgIGlmIChtSXNWaWRlbykgewotICAgICAgICAgICAgICAgICAgICAgICAgLy8gYXVkaW8gY29kZWMgaXMgY3VycmVudGx5IGlnbm9yZWQuCi0gICAgICAgICAgICAgICAgICAgICAgICBtUmVzb3VyY2VNYW5hZ2VyUHJveHktPmFkZFJlc291cmNlKAotICAgICAgICAgICAgICAgICAgICAgICAgICAg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IiwgJm1PdXRwdXRGb3JtYXQpKTsKIAorICAgICAgICAgICAgICAgICAgICB1cGRhdGVIRFJGb3JtYXRNZXRyaWMoKTsKKwogICAgICAgICAgICAgICAgICAgICAvLyBsaW1pdCB0byBjb25maXJtaW5nIHRoZSBvcHQtaW4gYmVoYXZpb3IgdG8gbWluaW1pemUgYW55IGJlaGF2aW9yYWwgY2hhbmdlCiAgICAgICAgICAgICAgICAgICAgIGlmIChtU3VyZmFjZSAhPSBudWxscHRyICYmICFtQWxsb3dGcmFtZURyb3BwaW5nQnlTdXJmYWNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBzaWduYWwgZnJhbWUgZHJvcHBpbmcgbW9kZSBpbiB0aGUgaW5wdXQgZm9ybWF0IGFzIHRoaXMgbWF5IGFsc28gYmUKQEAgLTMyOTUsNiArMzQ2NSw3IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1Db21wb25lbnROYW1lLmNfc3RyKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1JbnB1dEZvcm1hdC0+ZGVidWdTdHJpbmcoNCkuY19zdHIoKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbU91dHB1dEZvcm1hdC0+ZGVidWdTdHJpbmcoNCkuY19zdHIoKSk7CisgICAgICAgICAgICAgICAgICAgICAgICB1cGRhdGVIRFJGb3JtYXRNZXRyaWMoKTsKICAgICAgICAgICAgICAgICAgICAgICAgIENIRUNLKG9iaiAhPSBOVUxMKTsKICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlLT5zZXRPYmplY3QoImlucHV0LXN1cmZhY2UiLCBvYmopOwogICAgICAgICAgICAgICAgICAgICAgICAgbUhhdmVJbnB1dFN1cmZhY2UgPSB0cnVlOwpAQCAtMzMxOSw2ICszNDkwLDcgQEAKICAgICAgICAgICAgICAgICAgICAgaWYgKCFtc2ctPmZpbmRJbnQzMigiZXJyIiwgJmVycikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIENIRUNLKG1zZy0+ZmluZE1lc3NhZ2UoImlucHV0LWZvcm1hdCIsICZtSW5wdXRGb3JtYXQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgIENIRUNLKG1zZy0+ZmluZE1lc3NhZ2UoIm91dHB1dC1mb3JtYXQiLCAmbU91dHB1dEZvcm1hdCkpOworICAgICAgICAgICAgICAgICAgICAgICAgdXBkYXRlSERSRm9ybWF0TWV0cmljKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICBtSGF2ZUlucHV0U3VyZmFjZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICByZXNwb25zZS0+c2V0SW50MzIoImVyciIsIGVycik7CkBAIC0zMzU2LDcgKzM1MjgsNyBAQAogICAgICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICAgICAgQ0hFQ0tfRVEobVN0YXRlLCBTVEFSVElORyk7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChtSXNWaWRlbykgeworICAgICAgICAgICAgICAgICAgICBpZiAobURvbWFpbiA9PSBET01BSU5fVklERU8gfHwgbURvbWFpbiA9PSBET01BSU5fSU1BR0UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIG1SZXNvdXJjZU1hbmFnZXJQcm94eS0+YWRkUmVzb3VyY2UoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1lZGlhUmVzb3VyY2U6OkdyYXBoaWNNZW1vcnlSZXNvdXJjZShnZXRHcmFwaGljQnVmZmVyU2l6ZSgpKSk7CiAgICAgICAgICAgICAgICAgICAgIH0KQEAgLTMzNzksMTAgKzM1NTEsMTIgQEAKICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIFR1bm5lbFBlZWtTdGF0ZSBwcmV2aW91c1N0YXRlID0gbVR1bm5lbFBlZWtTdGF0ZTsKLSAgICAgICAgICAgICAgICAgICAgbVR1bm5lbFBlZWtTdGF0ZSA9IFR1bm5lbFBlZWtTdGF0ZTo6a0J1ZmZlclJlbmRlcmVkOwotICAgICAgICAgICAgICAgICAgICBBTE9HVigiVHVubmVsUGVla1N0YXRlOiAlcyAtPiAlcyIsCi0gICAgICAgICAgICAgICAgICAgICAgICAgIGFzU3RyaW5nKHByZXZpb3VzU3RhdGUpLAotICAgICAgICAgICAgICAgICAgICAgICAgICBhc1N0cmluZyhUdW5uZWxQZWVrU3RhdGU6OmtCdWZmZXJSZW5kZXJlZCkpOworICAgICAgICAgICAgICAgICAgICBpZiAobVR1bm5lbFBlZWtTdGF0ZSAhPSBUdW5uZWxQZWVrU3RhdGU6OmtMZWdhY3lNb2RlKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBtVHVubmVsUGVla1N0YXRlID0gVHVubmVsUGVla1N0YXRlOjprQnVmZmVyUmVuZGVyZWQ7CisgICAgICAgICAgICAgICAgICAgICAgICBBTE9HVigiVHVubmVsUGVla1N0YXRlOiAlcyAtPiAlcyIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFzU3RyaW5nKHByZXZpb3VzU3RhdGUpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhc1N0cmluZyhUdW5uZWxQZWVrU3RhdGU6OmtCdWZmZXJSZW5kZXJlZCkpOworICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIHVwZGF0ZVBsYXliYWNrRHVyYXRpb24obXNnKTsKICAgICAgICAgICAgICAgICAgICAgLy8gY2hlY2sgdGhhdCB3ZSBoYXZlIGEgbm90aWZpY2F0aW9uIHNldAogICAgICAgICAgICAgICAgICAgICBpZiAobU9uRnJhbWVSZW5kZXJlZE5vdGlmaWNhdGlvbiAhPSBOVUxMKSB7CkBAIC0zNTA0LDYgKzM2NzgsMjAgQEAKIAogICAgICAgICAgICAgICAgIGNhc2Uga1doYXREcmFpblRoaXNCdWZmZXI6CiAgICAgICAgICAgICAgICAgeworICAgICAgICAgICAgICAgICAgICBpZiAoKG1GbGFncyAmIGtGbGFnVXNlQmxvY2tNb2RlbCkgPT0gMCAmJiBtVHVubmVsZWQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHNwPFJlZkJhc2U+IG9iajsKKyAgICAgICAgICAgICAgICAgICAgICAgIENIRUNLKG1zZy0+ZmluZE9iamVjdCgiYnVmZmVyIiwgJm9iaikpOworICAgICAgICAgICAgICAgICAgICAgICAgc3A8TWVkaWFDb2RlY0J1ZmZlcj4gYnVmZmVyID0gc3RhdGljX2Nhc3Q8TWVkaWFDb2RlY0J1ZmZlciAqPihvYmouZ2V0KCkpOworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1GbGFncyAmIGtGbGFnSXNBc3luYykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIEluIGFzeW5jaHJvbm91cyBtb2RlLCBvdXRwdXQgZm9ybWF0IGNoYW5nZSBpcyBwcm9jZXNzZWQgaW1tZWRpYXRlbHkuCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFuZGxlT3V0cHV0Rm9ybWF0Q2hhbmdlSWZOZWVkZWQoYnVmZmVyKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9zdEFjdGl2aXR5Tm90aWZpY2F0aW9uSWZQb3NzaWJsZSgpOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgbUJ1ZmZlckNoYW5uZWwtPmRpc2NhcmRCdWZmZXIoYnVmZmVyKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICB9CisKICAgICAgICAgICAgICAgICAgICAgLyogc2l6ZV90IGluZGV4ID0gKi91cGRhdGVCdWZmZXJzKGtQb3J0SW5kZXhPdXRwdXQsIG1zZyk7CiAKICAgICAgICAgICAg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AgIFR1bm5lbFBlZWtTdGF0ZSBwcmV2aW91c1N0YXRlID0gbVR1bm5lbFBlZWtTdGF0ZTsKLSAgICAgICAgICAgIG1UdW5uZWxQZWVrU3RhdGUgPSBUdW5uZWxQZWVrU3RhdGU6OmtFbmFibGVkTm9CdWZmZXI7Ci0gICAgICAgICAgICBBTE9HVigiVHVubmVsUGVla1N0YXRlOiAlcyAtPiAlcyIsCi0gICAgICAgICAgICAgICAgICBhc1N0cmluZyhwcmV2aW91c1N0YXRlKSwKLSAgICAgICAgICAgICAgICAgIGFzU3RyaW5nKFR1bm5lbFBlZWtTdGF0ZTo6a0VuYWJsZWROb0J1ZmZlcikpOworICAgICAgICAgICAgaWYgKHByZXZpb3VzU3RhdGUgIT0gVHVubmVsUGVla1N0YXRlOjprTGVnYWN5TW9kZSkgeworICAgICAgICAgICAgICAgIG1UdW5uZWxQZWVrU3RhdGUgPSBUdW5uZWxQZWVrU3RhdGU6OmtFbmFibGVkTm9CdWZmZXI7CisgICAgICAgICAgICAgICAgQUxPR1YoIlR1bm5lbFBlZWtTdGF0ZTogJXMgLT4gJXMiLAorICAgICAgICAgICAgICAgICAgICAgICAgYXNTdHJpbmcocHJldmlvdXNTdGF0ZSksCisgICAgICAgICAgICAgICAgICAgICAgICBhc1N0cmluZyhUdW5uZWxQZWVrU3RhdGU6OmtFbmFibGVkTm9CdWZmZXIpKTsKKyAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgbVJlcGx5SUQgPSByZXBseUlEOwogICAgICAgICAgICAgc2V0U3RhdGUoU1RBUlRJTkcpOwpAQCAtNDA0OCwyNiArNDI0NiwyOSBAQAogICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgfQogCi0gICAgICAgICAgICBpZiAoYXN5bmNOb3RpZnkgIT0gbnVsbHB0cikgewotICAgICAgICAgICAgICAgIGlmIChtU3VyZmFjZSAhPSBOVUxMKSB7Ci0gICAgICAgICAgICAgICAgICAgIGlmICghbVJlbGVhc2VTdXJmYWNlKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICB1aW50NjRfdCB1c2FnZSA9IDA7Ci0gICAgICAgICAgICAgICAgICAgICAgICBpZiAobVN1cmZhY2UtPmdldENvbnN1bWVyVXNhZ2UoJnVzYWdlKSAhPSBPSykgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVzYWdlID0gMDsKLSAgICAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgICAgIG1SZWxlYXNlU3VyZmFjZS5yZXNldChuZXcgUmVsZWFzZVN1cmZhY2UodXNhZ2UpKTsKKyAgICAgICAgICAgIGJvb2wgZm9yY2VTeW5jID0gZmFsc2U7CisgICAgICAgICAgICBpZiAoYXN5bmNOb3RpZnkgIT0gbnVsbHB0ciAmJiBtU3VyZmFjZSAhPSBOVUxMKSB7CisgICAgICAgICAgICAgICAgaWYgKCFtUmVsZWFzZVN1cmZhY2UpIHsKKyAgICAgICAgICAgICAgICAgICAgdWludDY0X3QgdXNhZ2UgPSAwOworICAgICAgICAgICAgICAgICAgICBpZiAobVN1cmZhY2UtPmdldENvbnN1bWVyVXNhZ2UoJnVzYWdlKSAhPSBPSykgeworICAgICAgICAgICAgICAgICAgICAgICAgdXNhZ2UgPSAwOwogICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIGlmIChtU3VyZmFjZSAhPSBtUmVsZWFzZVN1cmZhY2UtPmdldFN1cmZhY2UoKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzX3QgZXJyID0gY29ubmVjdFRvU3VyZmFjZShtUmVsZWFzZVN1cmZhY2UtPmdldFN1cmZhY2UoKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBBTE9HV19JRihlcnIgIT0gT0ssICJlcnJvciBjb25uZWN0aW5nIHRvIHJlbGVhc2Ugc3VyZmFjZTogZXJyID0gJWQiLCBlcnIpOwotICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVyciA9PSBPSyAmJiAhKG1GbGFncyAmIGtGbGFnVXNlc1NvZnR3YXJlUmVuZGVyZXIpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgZXJyID0gbUNvZGVjLT5zZXRTdXJmYWNlKG1SZWxlYXNlU3VyZmFjZS0+Z2V0U3VyZmFjZSgpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBBTE9HV19JRihlcnIgIT0gT0ssICJlcnJvciBzZXR0aW5nIHJlbGVhc2Ugc3VyZmFjZTogZXJyID0gJWQiLCBlcnIpOwotICAgICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVyciA9PSBPSykgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgICh2b2lkKWRpc2Nvbm5lY3RGcm9tU3VyZmFjZSgpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1TdXJmYWNlID0gbVJlbGVhc2VTdXJmYWNlLT5nZXRTdXJmYWNlKCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIG1SZWxlYXNlU3VyZmFjZS5yZXNldChuZXcgUmVsZWFzZVN1cmZhY2UodXNhZ2UpKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgaWYgKG1TdXJmYWNlICE9IG1SZWxlYXNlU3VyZmFjZS0+Z2V0U3VyZmFjZSgpKSB7CisgICAgICAgICAgICAgICAgICAgIHN0YXR1c190IGVyciA9IGNvbm5lY3RUb1N1cmZhY2UobVJlbGVhc2VTdXJmYWNlLT5nZXRTdXJmYWNlKCkpOworICAgICAgICAgICAgICAgICAgICBBTE9HV19JRihlcnIgIT0gT0ssICJlcnJvciBjb25uZWN0aW5nIHRvIHJlbGVhc2Ugc3VyZmFjZTogZXJyID0gJWQiLCBlcnIpOworICAgICAgICAgICAgICAgICAgICBpZiAoZXJyID09IE9LICYmICEobUZsYWdzICYga0ZsYWdVc2VzU29mdHdhcmVSZW5kZXJlcikpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGVyciA9IG1Db2RlYy0+c2V0U3VyZmFjZShtUmVsZWFzZVN1cmZhY2UtPmdldFN1cmZhY2UoKSk7CisgICAgICAgICAgICAgICAgICAgICAgICBBTE9HV19JRihlcnIgIT0gT0ssICJlcnJvciBzZXR0aW5nIHJlbGVhc2Ugc3VyZmFjZTogZXJyID0gJWQiLCBlcnIpOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIGlmIChlcnIgPT0gT0spIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICh2b2lkKWRpc2Nvbm5lY3RGcm9tU3VyZmFjZSgpOworICAgICAgICAgICAgICAgICAgICAgICAgbVN1cmZhY2UgPSBtUmVsZWFzZVN1cmZhY2UtPmdldFN1cmZhY2UoKTsKKyAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIC8vIFdlIHdlcmUgbm90IGFibGUgdG8gc3dpdGNoIHRoZSBzdXJmYWNlLCBzbyBmb3JjZQorICAgICAgICAgICAgICAgICAgICAgICAgLy8gc3luY2hyb25vdXMgcmVsZWFzZS4KKyAgICAgICAgICAgICAgICAgICAgICAgIGZvcmNlU3luYyA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CkBAIC00MDkxLDggKzQyOTIsMTAgQEAKICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgaWYgKGFzeW5jTm90aWZ5ICE9IG51bGxwdHIpIHsKLSAgICAgICAgICAgICAgICBtUmVzb3VyY2VNYW5hZ2VyUHJveHktPm1hcmtDbGllbnRGb3JQZW5kaW5nUmVtb3ZhbCgpOwotICAgICAgICAgICAgICAgIHBvc3RQZW5kaW5nUmVwbGllc0FuZERlZmVycmVkTWVzc2FnZXMoImtXaGF0UmVsZWFzZTphc3luYyIpOworICAgICAgICAgICAgICAgIGlmICghZm9yY2VTeW5jKSB7CisgICAgICAgICAgICAgICAgICAgIG1SZXNvdXJjZU1hbmFnZXJQcm94eS0+bWFya0NsaWVudEZvclBlbmRpbmdSZW1vdmFsKCk7CisgICAgICAgICAgICAgICAgICAgIHBvc3RQZW5kaW5nUmVwbGllc0FuZERlZmVycmVkTWVzc2FnZXMoImtXaGF0UmVsZWFzZTphc3luYyIpOworICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBhc3luY05vdGlmeVBvc3QuY2xlYXIoKTsKICAgICAgICAgICAgICAgICBtQXN5bmNSZWxlYXNlQ29tcGxldGVOb3RpZmljYXRpb24gPSBhc3luY05vdGlmeTsKICAgICAgICAgICAgIH0KQEAgLTQzNDIsMTAgKzQ1NDUsMTIgQEAKICAgICAgICAgICAgIG1Db2RlYy0+c2lnbmFsRmx1c2goKTsKICAgICAgICAgICAgIHJldHVybkJ1ZmZlcnNUb0NvZGVjKCk7CiAgICAgICAgICAgICBUdW5uZWxQZWVrU3RhdGUgcHJldmlvdXNTdGF0ZSA9IG1UdW5uZWxQZWVrU3RhdGU7Ci0gICAgICAgICAgICBtVHVubmVsUGVla1N0YXRlID0gVHVubmVsUGVla1N0YXRlOjprRW5hYmxlZE5vQnVmZmVyOwotICAgICAgICAgICAgQUxPR1YoIlR1bm5lbFBlZWtTdGF0ZTogJXMgLT4gJXMiLAotICAgICAgICAgICAgICAgICAgYXNTdHJpbmcocHJldmlvdXNTdGF0ZSksCi0gICAgICAgICAgICAgICAgICBhc1N0cmluZyhUdW5uZWxQZWVrU3RhdGU6OmtFbmFibGVkTm9CdWZmZXIpKTsKKyAgICAgICAgICAgIGlmIChwcmV2aW91c1N0YXRlICE9IFR1bm5lbFBlZWtTdGF0ZTo6a0xlZ2FjeU1vZGUpIHsKKyAgICAgICAgICAgICAgICBtVHVubmVsUGVla1N0YXRlID0gVHVubmVsUGVla1N0YXRlOjprRW5hYmxlZE5vQnVmZmVyOworICAgICAgICAgICAgICAgIEFMT0dWKCJUdW5uZWxQ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gICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIApAQCAtNDUwOSw2ICs0NzE4LDcgQEAKICAgICAgICAgICAgICAgICAmJiBoZHIxMFBsdXNJbmZvICE9IG51bGxwdHIgJiYgaGRyMTBQbHVzSW5mby0+c2l6ZSgpID4gMCkgewogICAgICAgICAgICAgbmF0aXZlX3dpbmRvd19zZXRfYnVmZmVyc19oZHIxMF9wbHVzX21ldGFkYXRhKG1TdXJmYWNlLmdldCgpLAogICAgICAgICAgICAgICAgICAgICBoZHIxMFBsdXNJbmZvLT5zaXplKCksIGhkcjEwUGx1c0luZm8tPmRhdGEoKSk7CisgICAgICAgICAgICBtSERSMTBQbHVzSW5mbyA9IHRydWU7CiAgICAgICAgIH0KIAogICAgICAgICBpZiAobWltZS5zdGFydHNXaXRoSWdub3JlQ2FzZSgidmlkZW8vIikpIHsKQEAgLTQ1NTMsNiArNDc2MywyMSBAQAogICAgICAgICAgICAgbUNyeXB0by0+bm90aWZ5UmVzb2x1dGlvbih3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgfQogICAgIH0KKworICAgIGlmIChtTWV0cmljc0hhbmRsZSAhPSAwKSB7CisgICAgICAgIGludDMyX3QgY29sb3JTdGFuZGFyZCA9IC0xOworICAgICAgICBpZiAoZm9ybWF0LT5maW5kSW50MzIoS0VZX0NPTE9SX1NUQU5EQVJELCAmY29sb3JTdGFuZGFyZCkpIHsKKyAgICAgICAgICAgIG1lZGlhbWV0cmljc19zZXRJbnQzMihtTWV0cmljc0hhbmRsZSwga0NvZGVjUGFyc2VkQ29sb3JTdGFuZGFyZCwgY29sb3JTdGFuZGFyZCk7CisgICAgICAgIH0KKyAgICAgICAgaW50MzJfdCBjb2xvclJhbmdlID0gLTE7CisgICAgICAgIGlmIChmb3JtYXQtPmZpbmRJbnQzMiggS0VZX0NPTE9SX1JBTkdFLCAmY29sb3JSYW5nZSkpIHsKKyAgICAgICAgICAgIG1lZGlhbWV0cmljc19zZXR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gIGlmIChlcnIgIT0gT0sgfHwgb3V0YnVmID09IE5VTEwgfHwgb3V0YnVmLT5kYXRhKCkgPT0gTlVMTCkgewogICAgICAgICAgICAgICAgIHNpZ25hbEVPUygpOwogICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgfSBlbHNlIGlmIChvdXRidWYtPnNpemUoKSA9PSAwKSB7CisgICAgICAgICAgICAgICAgLy8gWmVybyBsZW5ndGggQ1NEIGJ1ZmZlcnMgYXJlIG5vdCB0cmVhdGVkIGFzIGFuIGVycm9yCisgICAgICAgICAgICAgICAgaWYgKGZsYWdzICYgTWVkaWFDb2RlYzo6QlVGRkVSX0ZMQUdfQ09ERUNDT05GSUcpIHsKKyAgICAgICAgICAgICAgICAgICAgbUVuY29kZXItPnJlbGVhc2VPdXRwdXRCdWZmZXIoaW5kZXgpOworICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgIHNpZ25hbEVPUygpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgTWVkaWFCdWZmZXJCYXNlICptYnVmID0gbmV3IE1lZGlhQnVmZmVyKG91dGJ1Zi0+c2l6ZSgpKTsKZGlmZiAtLWdpdCBhL21lZGlhL2xpYnN0YWdlZnJpZ2h0L09nZ1dyaXRlci5jcHAgYi9tZWRpYS9saWJzdGFnZWZyaWdodC9PZ2dXcml0ZXIuY3BwCmluZGV4IDBiYzU5NzYuLjBmNWU5NWUgMTAwNjQ0Ci0tLSBhL21lZGlhL2xpYnN0YWdlZnJpZ2h0L09nZ1dyaXRlci5jcHAKKysrIGIvbWVkaWEvbGlic3RhZ2VmcmlnaHQvT2dnV3JpdGVyLmNwcApAQCAtNjcsNyArNjcsMTEgQEAKICAgICAgICAgbUZkID0gLTE7CiAgICAgfQogCi0gICAgZnJlZShtT3MpOworICAgIGlmIChtT3MgIT0gbnVsbHB0cikgeworICAgICAgICBv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25zLlByZXN1Ym1pdCIKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICJleGNsdWRlLWFubm90YXRpb24iOiAiYW5kcm9pZC5wbGF0Zm9ybS50ZXN0LmFubm90YXRpb25zLlJlcXVpcmVzRGV2aWNlIgorICAgICAgICB9CisgICAgICBdCisgICAgfSwKKyAgICB7CisgICAgICAibmFtZSI6ICJDdHNNZWRpYUVuY29kZXJUZXN0Q2FzZXMiLAorICAgICAgIm9wdGlvbnMiOiBbCisgICAgICAgIHsKKyAgICAgICAgICAiaW5jbHVkZS1hbm5vdGF0aW9uIjogImFuZHJvaWQucGxhdGZvcm0udGVzdC5hbm5vdGF0aW9ucy5QcmVzdWJtaXQiCisgICAgICAgIH0sCisgICAgICAgIHsKKyAgICAgICAgICAiZXhjbHVkZS1hbm5vdGF0aW9uIjogImFuZHJvaWQucGxhdGZvcm0udGVzdC5hbm5vdGF0aW9ucy5SZXF1aXJlc0RldmljZSIKKyAgICAgICAgfQorICAgICAgXQorICAgIH0sCisgICAgeworICAgICAgIm5hbWUiOiAiQ3RzTWVkaWFDb2RlY1Rlc3RDYXNlcyIsCisgICAgICAib3B0aW9ucyI6IFsKKyAgICAgICAgeworICAgICAgICAgICJpbmNsdWRlLWFubm90YXRpb24iOiAiYW5kcm9pZC5wbGF0Zm9ybS50ZXN0LmFubm90YXRpb25zLlByZXN1Ym1pdCIKKyAgICAgICAgfSwKKyAgICAgICAgeworICAgICAgICAgICJleGNsdWRlLWFubm90YXRpb24iOiAiYW5kcm9pZC5wbGF0Zm9ybS50ZXN0LmFubm90YXRpb25zLlJlcXVpcmVzRGV2aWNlIgorICAgICAgICB9CisgICAgICBdCisgICAgfSwKKyAgICB7CisgICAgICAibmFtZSI6ICJDdHNNZWRpYVBsYXllclRlc3RDYXNlcyIsCisgICAgICAib3B0aW9ucyI6IFsKKyAgICAgICAgeworICAgICAgICAgICJpbmNsdWRlLWFubm90YXRpb24iOiAiYW5kcm9pZC5wbGF0Zm9ybS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gIH0sCi0gICAgICAgIHsgMiwgIE9NWF9BVURJT19BQUNPYmplY3RMQyAgICAgICB9LAotICAgICAgICB7IDMsICBPTVhfQVVESU9fQUFDT2JqZWN0U1NSICAgICAgfSwKLSAgICAgICAgeyA0LCAgT01YX0FVRElPX0FBQ09iamVjdExUUCAgICAgIH0sCi0gICAgICAgIHsgNSwgIE9NWF9BVURJT19BQUNPYmplY3RIRSAgICAgICB9LAotICAgICAgICB7IDYsICBPTVhfQVVESU9fQUFDT2JqZWN0U2NhbGFibGUgfSwKLSAgICAgICAgeyAxNywgT01YX0FVRElPX0FBQ09iamVjdEVSTEMgICAgIH0sCi0gICAgICAgIHsgMjMsIE9NWF9BVURJT19BQUNPYmplY3RMRCAgICAgICB9LAotICAgICAgICB7IDI5LCBPTVhfQVVESU9fQUFDT2JqZWN0SEVfUFMgICAgfSwKLSAgICAgICAgeyAzOSwgT01YX0FVRElPX0FBQ09iamVjdEVMRCAgICAgIH0sCi0gICAgICAgIHsgNDIsIE9NWF9BVURJT19BQUNPYmplY3RYSEUgICAgICB9LAorCisgICAgY29uc3Qgc3RhdGljIEFMb29rdXA8dWludDE2X3QsIGludDMyX3Q+IHByb2ZpbGVzIHsKKyAgICAgICAgeyAxLCAgQUFDT2JqZWN0TWFpbiAgICAgfSwKKyAgICAgICAgeyAyLCAgQUFDT2JqZWN0TEMgICAgICAgfSwKKyAgICAgICAgeyAzLCAgQUFDT2JqZWN0U1NSICAgICAgfSwKKyAgICAgICAgeyA0LCAgQUFDT2JqZWN0TFRQICAgICAgfSwKKyAgICAgICAgeyA1LCAgQUFDT2JqZWN0SEUgICAgICAgfSwKKyAgICAgICAgeyA2LCAgQUFDT2JqZWN0U2NhbGFibGUgfSwKKyAgICAgICAgeyAxNywgQUFDT2JqZWN0RVJMQyAgICAgfSwKKyAgICAgICAgeyAyMywgQUFDT2JqZWN0TEQgICAgICAgfSwKKyAgICAgICAgeyAyOSwgQUFDT2JqZWN0SEVfUFMgICAgfSwKKyAgICA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AgICAgICAgICBjb2RlY1Byb2ZpbGUgPSAoT01YX1ZJREVPX0FWQ1BST0ZJTEVUWVBFKU9NWF9WSURFT19BVkNQcm9maWxlQ29uc3RyYWluZWRIaWdoOworICAgICAgICAgICAgY29kZWNQcm9maWxlID0gQVZDUHJvZmlsZUNvbnN0cmFpbmVkSGlnaDsKICAgICAgICAgfQogICAgICAgICBmb3JtYXQtPnNldEludDMyKCJwcm9maWxlIiwgY29kZWNQcm9maWxlKTsKICAgICAgICAgaWYgKGxldmVscy5tYXAobGV2ZWwsICZjb2RlY0xldmVsKSkgewogICAgICAgICAgICAgLy8gZm9yIDkgJiYgMTEgZGVjaWRlIGxldmVsIGJhc2VkIG9uIHByb2ZpbGUgYW5kIGNvbnN0cmFpbnRfc2V0MyBmbGFnCiAgICAgICAgICAgICBpZiAobGV2ZWwgPT0gMTEgJiYgKHByb2ZpbGUgPT0gNjYgfHwgcHJvZmlsZSA9PSA3NyB8fCBwcm9maWxlID09IDg4KSkgewotICAgICAgICAgICAgICAgIGNvZGVjTGV2ZWwgPSAoY29uc3RyYWludHMgJiAweDEwKSA/IE9NWF9WSURFT19BVkNMZXZlbDFiIDogT01YX1ZJREVPX0FWQ0xldmVsMTE7CisgICAgICAgICAgICAgICAgY29kZWNMZXZlbCA9IChjb25zdHJhaW50cyAmIDB4MTApID8gQVZDTGV2ZWwxYiA6IEFWQ0xldmVsMTE7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBmb3JtYXQtPnNldEludDMyKCJsZXZlbCIsIGNvZGVjTGV2ZWwpOwogICAgICAgICB9CiAgICAgfQogfQogCitzdGF0aWMgY29uc3QgQUxvb2t1cDx1aW50OF90LCBpbnQzMl90PiYgIGdldERvbGJ5VmlzaW9uUHJvZmlsZVRhYmxlKCkgeworICAgIHN0YXRpYyBjb25zdCBBTG9va3VwPHVpbnQ4X3QsIGludDMyX3Q+IHByb2ZpbGVUYWJsZSA9IHsKKyAgICAgICAgezEsIERvbGJ5VmlzaW9uUHJvZmlsZUR2YXZQZW59LAorICAgICAgICB7MywgRG9sYnlWaXNpb25Qcm9maWxlRHZoZURlbn0sCisgICAgICAgIHs0LCBEb2xieVZpc2lvblByb2ZpbGVEdmhlRHRyfSwKKyAgICAgICAgezUsIERvbGJ5VmlzaW9uUHJvZmlsZUR2aGVTdG59LAorICAgICAgICB7NiwgRG9sYnlWaXNpb25Qcm9maWxlRHZoZUR0aH0sCisgICAgICAgIHs3LCBEb2xieVZpc2lvblByb2ZpbGVEdmhlRHRifSwKKyAgICAgICAgezgsIERvbGJ5VmlzaW9uUHJvZmlsZUR2aGVTdH0sCisgICAgICAgIHs5LCBEb2xieVZpc2lvblByb2ZpbGVEdmF2U2V9LAorICAgICAgICB7MTAsIERvbGJ5VmlzaW9uUHJvZmlsZUR2YXYxMTB9LAorICAgIH07CisgICAgcmV0dXJuIHByb2ZpbGVUYWJsZTsKK30KKworc3RhdGljIGNvbnN0IEFMb29rdXA8dWludDhfdCwgaW50MzJfdD4mICBnZXREb2xieVZpc2lvbkxldmVsc1RhYmxlKCkgeworICAgIHN0YXRpYyBjb25zdCBBTG9va3VwPHVpbnQ4X3QsIGludDMyX3Q+IGxldmVsc1RhYmxlID0geworICAgICAgICB7MCwgRG9sYnlWaXNpb25MZXZlbFVua25vd259LAorICAgICAgICB7MSwgRG9sYnlWaXNpb25MZXZlbEhkMjR9LAorICAgICAgICB7MiwgRG9sYnlWaXNpb25MZXZlbEhkMzB9LAorICAgICAgICB7MywgRG9sYnlWaXNpb25MZXZlbEZoZDI0fSwKKyAgICAgICAgezQsIERvbGJ5VmlzaW9uTGV2ZWxGaGQzMH0sCisgICAgICAgIHs1LCBEb2xieVZpc2lvbkxldmVsRmhkNjB9LAorICAgICAgICB7NiwgRG9sYnlWaXNpb25MZXZlbFVoZDI0fSwKKyAgICAgICAgezcsIERvbGJ5VmlzaW9uTGV2ZWxVaGQzMH0sCisgICAgICAgIHs4LCBEb2xieVZpc2lvbkxldmVsVWhkNDh9LAorICAgICAg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NQcm9maWxlKSkgewogICAgICAgICBpZiAocHRyWzJdICYgMHg0MCAvKiBnZW5lcmFsIGNvbXBhdGliaWxpdHkgZmxhZyAxICovKSB7CiAgICAgICAgICAgICAvLyBOb3RlIHRoYXQgdGhpcyBjYXNlIGNvdmVycyBNYWluIFN0aWxsIFBpY3R1cmUgdG9vCi0gICAgICAgICAgICBjb2RlY1Byb2ZpbGUgPSBPTVhfVklERU9fSEVWQ1Byb2ZpbGVNYWluOworICAgICAgICAgICAgY29kZWNQcm9maWxlID0gSEVWQ1Byb2ZpbGVNYWluOwogICAgICAgICB9IGVsc2UgaWYgKHB0clsyXSAmIDB4MjAgLyogZ2VuZXJhbCBjb21wYXRpYmlsaXR5IGZsYWcgMiAqLykgewotICAgICAgICAgICAgY29kZWNQcm9maWxlID0gT01YX1ZJREVPX0hFVkNQcm9maWxlTWFpbjEwOworICAgICAgICAgICAgY29kZWNQcm9maWxlID0gSEVWQ1Byb2ZpbGVNYWluMTA7CiAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgIH0KICAgICB9CiAKICAgICAvLyBidW1wIHRvIEhEUiBwcm9maWxlCi0gICAgaWYgKGlzSGRyKGZvcm1hdCkgJiYgY29kZWNQcm9maWxlID09IE9NWF9WSURFT19IRVZDUHJvZmlsZU1haW4xMCkgewotICAgICAgICBjb2RlY1Byb2ZpbGUgPSBPTVhfVklERU9fSEVWQ1Byb2ZpbGVNYWluMTBIRFIxMDsKKyAgICBpZiAoaXNIZHIxMG9yMTBQbHVzKGZvcm1hdCkgJiYgY29kZWNQcm9maWxlID09IEhFVkNQcm9maWxlTWFpbjEwKSB7CisgICAgICAgIGlmIChmb3JtYXQtPmNvbnRhaW5zKCJoZHIxMC1wbHVzLWluZm8iKSkgeworICAgICAgICAgICAgY29kZWNQcm9maWxlID0gSEVWQ1Byb2ZpbGVNYWluMTBIRFIxMFBsdXM7CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICBjb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sZUhpZ2ggICAgfSwKICAgICAgICAgfTsKIAotICAgICAgICBjb25zdCBzdGF0aWMgQUxvb2t1cDx1aW50OF90LCBPTVhfVklERU9fTVBFRzJMRVZFTFRZUEU+IGxldmVscyB7Ci0gICAgICAgICAgICB7IDB4MEEsIE9NWF9WSURFT19NUEVHMkxldmVsTEwgIH0sCi0gICAgICAgICAgICB7IDB4MDgsIE9NWF9WSURFT19NUEVHMkxldmVsTUwgIH0sCi0gICAgICAgICAgICB7IDB4MDYsIE9NWF9WSURFT19NUEVHMkxldmVsSDE0IH0sCi0gICAgICAgICAgICB7IDB4MDQsIE9NWF9WSURFT19NUEVHMkxldmVsSEwgIH0sCi0gICAgICAgICAgICB7IDB4MDIsIE9NWF9WSURFT19NUEVHMkxldmVsSFAgIH0sCisgICAgICAgIGNvbnN0IHN0YXRpYyBBTG9va3VwPHVpbnQ4X3QsIGludDMyX3Q+IGxldmVscyB7CisgICAgICAgICAgICB7IDB4MEEsIE1QRUcyTGV2ZWxMTCAgfSwKKyAgICAgICAgICAgIHsgMHgwOCwgTVBFRzJMZXZlbE1MICB9LAorICAgICAgICAgICAgeyAweDA2LCBNUEVHMkxldmVsSDE0IH0sCisgICAgICAgICAgICB7IDB4MDQsIE1QRUcyTGV2ZWxITCAgfSwKKyAgICAgICAgICAgIHsgMHgwMiwgTVBFRzJMZXZlbEhQICB9LAogICAgICAgICB9OwogCiAgICAgICAgIGNvbnN0IHN0YXRpYyBBTG9va3VwPHVpbnQ4X3QsCi0gICAgICAgICAgICAgICAgc3RkOjpwYWlyPE9NWF9WSURFT19NUEVHMlBST0ZJTEVUWVBFLCBPTVhfVklERU9fTVBFRzJMRVZFTFRZUEU+PiBlc2NhcGVzIHsKKyAgICAgICAgICAgICAgICBzdGQ6OnBhaXI8aW50MzJfdCwgaW50MzJfdD4+IGVzY2FwZXMgewogICAgICAgICAgICAgLyogdW5zdXBwb3J0ZWQKLSAgICAgICAgICAgIHsgMHg4RSwgeyBYWFhfTVBFRzJQ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NjIsIE9NWF9WSURFT19NUEVHMlByb2ZpbGVTTlIgICAgIH0sCi0gICAgICAgICAgICB7IDB4NjMsIE9NWF9WSURFT19NUEVHMlByb2ZpbGVTcGF0aWFsIH0sCi0gICAgICAgICAgICB7IDB4NjQsIE9NWF9WSURFT19NUEVHMlByb2ZpbGVIaWdoICAgIH0sCi0gICAgICAgICAgICB7IDB4NjUsIE9NWF9WSURFT19NUEVHMlByb2ZpbGU0MjIgICAgIH0sCisgICAgICAgIGNvbnN0IHN0YXRpYyBBTG9va3VwPHVpbnQ4X3QsIGludDMyX3Q+IHByb2ZpbGVzeworICAgICAgICAgICAgeyAweDYwLCBNUEVHMlByb2ZpbGVTaW1wbGUgIH0sCisgICAgICAgICAgICB7IDB4NjEsIE1QRUcyUHJvZmlsZU1haW4gICAgfSwKKyAgICAgICAgICAgIHsgMHg2MiwgTVBFRzJQcm9maWxlU05SICAgICB9LAorICAgICAgICAgICAgeyAweDYzLCBNUEVHMlByb2ZpbGVTcGF0aWFsIH0sCisgICAgICAgICAgICB7IDB4NjQsIE1QRUcyUHJvZmlsZUhpZ2ggICAgfSwKKyAgICAgICAgICAgIHsgMHg2NSwgTVBFRzJQcm9maWxlNDIyICAgICB9LAogICAgICAgICB9OwogCi0gICAgICAgIE9NWF9WSURFT19NUEVHMlBST0ZJTEVUWVBFIHByb2ZpbGU7CisgICAgICAgIGludDMyX3QgcHJvZmlsZTsKICAgICAgICAgaWYgKHByb2ZpbGVzLm1hcChvYmpUeXBlLCAmcHJvZmlsZSkpIHsKICAgICAgICAgICAgIGZvcm1hdC0+c2V0SW50MzIoInByb2ZpbGUiLCBwcm9maWxlKTsKICAgICAgICAgfQpAQCAtNDkyLDgyICs1MDksODIgQEAKICAgICAgICAgY29uc3QgdWludDhfdCBpbmRpY2F0aW9uID0gc2VxWzRdOwogCiAgICAgICAgIGNvbnN0IHN0YXRpYyBBTG9va3VwPHVpbnQ4X3QsCi0gICAgICAgICAgICAgICAgc3RkOjpwYWlyPE9NWF9WSURFT19NUEVHNFBST0ZJTEVUWVBFLCBPTVhfVklERU9fTVBFRzRMRVZFTFRZUEU+PiB0YWJsZSB7Ci0gICAgICAgICAgICB7IDBiMDAwMDAwMDEsIHsgT01YX1ZJREVPX01QRUc0UHJvZmlsZVNpbXBsZSwgICAgICAgICAgICBPTVhfVklERU9fTVBFRzRMZXZlbDEgIH0gfSwKLSAgICAgICAgICAgIHsgMGIwMDAwMDAxMCwgeyBPTVhfVklERU9fTVBFRzRQcm9maWxlU2ltcGxlLCAgICAgICAgICAgIE9NWF9WSURFT19NUEVHNExldmVsMiAgfSB9LAotICAgICAgICAgICAgeyAwYjAwMDAwMDExLCB7IE9NWF9WSURFT19NUEVHNFByb2ZpbGVTaW1wbGUsICAgICAgICAgICAgT01YX1ZJREVPX01QRUc0TGV2ZWwzICB9IH0sCi0gICAgICAgICAgICB7IDBiMDAwMDAxMDAsIHsgT01YX1ZJREVPX01QRUc0UHJvZmlsZVNpbXBsZSwgICAgICAgICAgICBPTVhfVklERU9fTVBFRzRMZXZlbDRhIH0gfSwKLSAgICAgICAgICAgIHsgMGIwMDAwMDEwMSwgeyBPTVhfVklERU9fTVBFRzRQcm9maWxlU2ltcGxlLCAgICAgICAgICAgIE9NWF9WSURFT19NUEVHNExldmVsNSAgfSB9LAotICAgICAgICAgICAgeyAwYjAwMDAwMTEwLCB7IE9NWF9WSURFT19NUEVHNFByb2ZpbGVTaW1wbGUsICAgICAgICAgICAgT01YX1ZJREVPX01QRUc0TGV2ZWw2ICB9IH0sCi0gICAgICAgICAgICB7IDBiMDAwMDEwMDAsIHsgT01YX1ZJREVPX01QRUc0UHJvZmlsZVNpbXBsZSwgICAgICAgICAgICBPTVhfVklERU9fTVBFRzRMZXZlbDAgIH0gfSwKLSAgICAgICAgICAgIHsgMGIwMDAwMTAwMSwgeyBPTVhfVklERU9fTVBFRzRQcm9maWxlU2ltcGxlLCAgICAgICAgICAgIE9NWF9WSURFT19NUEVHNExldmVsMGIgfSB9LAotICAgICAgICAgICAgeyAwYjAwMDEwMDAwLCB7IE9NWF9WSURFT19NUEVHNFByb2ZpbGVTaW1wbGVTY2FsYWJsZSwgICAgT01YX1ZJREVPX01QRUc0TGV2ZWwwICB9IH0sCi0gICAgICAgICAgICB7IDBiMDAwMTAwMDEsIHsgT01YX1ZJREVPX01QRUc0UHJvZmlsZVNpbXBsZVNjYWxhYmxlLCAgICBPTVhfVklERU9fTVBFRzRMZXZlbDEgIH0gfSwKLSAgICAgICAgICAgIHsgMGIwMDAxMDAxMCwgeyBPTVhfVklERU9fTVBFRzRQcm9maWxlU2ltcGxlU2NhbGFibGUsICAgIE9NWF9WSURFT19NUEVHNExldmVsMiAgfSB9LAorICAgICAgICAgICAgICAgIHN0ZDo6cGFpcjxpbnQzMl90LCBpbnQzMl90Pj4gdGFibGUgeworICAgICAgICAgICAgeyAwYjAwMDAwMDAxLCB7IE1QRUc0UHJvZmlsZVNpbXBsZSwgICAgICAgICAgICBNUEVHNExldmVsMSAgfSB9LAorICAgICAgICAgICAgeyAwYjAwMDAwMDEwLCB7IE1QRUc0UHJvZmlsZVNpbXBsZSwgICAgICAgICAgICBNUEVHNExldmVsMiAgfSB9LAorICAgICAgICAgICAgeyAwYjAwMDAwMDExLCB7IE1QRUc0UHJvZmlsZVNpbXBsZSwgICAgICAgICAgICBNUEVHNExldmVsMyAgfSB9LAorICAgICAgICAgICAgeyAwYjAwMDAwMTAwLCB7IE1QRUc0UHJvZmlsZVNpbXBsZSwgICAgICAgICAgICBNUEVHNExldmVsNGEgfSB9LAorICAgICAgICAgICAgeyAwYjAwMDAwMTAxLCB7IE1QRUc0UHJvZmlsZVNpbXBsZSwgICAgICAgICAgICBNUEVHNExldmVsNSAgfSB9LAorICAgICAgICAgICAgeyAwYjAwMDAwMTEwLCB7IE1QRUc0UHJvZmlsZVNpbXBsZSwgICAgICAgICAgICBNUEVHNExldmVsNiAgfSB9LAorICAgICAgICAgICAgeyAwYjAwMDAxMDAwLCB7IE1QRUc0UH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ICAgT01YX1ZJREVPX01QRUc0TGV2ZWwyICB9IH0sCi0gICAgICAgICAgICB7IDBiMDAxMTAwMTAsIHsgT01YX1ZJREVPX01QRUc0UHJvZmlsZU1haW4sICAgICAgICAgICAgICBPTVhfVklERU9fTVBFRzRMZXZlbDIgIH0gfSwKLSAgICAgICAgICAgIHsgMGIwMDExMDAxMSwgeyBPTVhfVklERU9fTVBFRzRQcm9maWxlTWFpbiwgICAgICAgICAgICAgIE9NWF9WSURFT19NUEVHNExldmVsMyAgfSB9LAotICAgICAgICAgICAgeyAwYjAwMTEwMTAwLCB7IE9NWF9WSURFT19NUEVHNFByb2ZpbGVNYWluLCAgICAgICAgICAgICAgT01YX1ZJREVPX01QRUc0TGV2ZWw0ICB9IH0sCisgICAgICAgICAgICB7IDBiMDAwMTExMDEsIHsgWFhYX01QRUc0UHJvZmlsZVNpbXBsZVNjYWxhYmxlRVIsICAgICAgICBNUEVHNExldmVsMCAgfSB9LAorICAgICAgICAgICAgeyAwYjAwMDExMTEwLCB7IFhYWF9NUEVHNFByb2ZpbGVTaW1wbGVTY2FsYWJsZUVSLCAgICAgICAgTVBFRzRMZXZlbDEgIH0gfSwKKyAgICAgICAgICAgIHsgMGIwMDAxMTExMSwgeyBYWFhfTVBFRzRQcm9maWxlU2ltcGxlU2NhbGFibGVFUiwgICAgICAgIE1QRUc0TGV2ZWwyICB9IH0sICovCisgICAgICAgICAgICB7IDBiMDAxMDAwMDEsIHsgTVBFRzRQcm9maWxlQ29yZSwgICAgICAgICAgICAgIE1QRUc0TGV2ZWwxICB9IH0sCisgICAgICAgICAgICB7IDBiMDAxMDAwMTAsIHsgTVBFRzRQcm9maWxlQ29yZSwgICAgICAgICAgICAgIE1QRUc0TGV2ZWwyICB9IH0sCisgICAgICAgICAgICB7IDBiMDAxMTAwMTAsIHsgTVBFRzRQcm9maWxlTWFpbiwgICAgICAgICAgICAgIE1QRUc0TGV2ZWwyICB9IH0sCisgICAgICAgICAgICB7IDBiMDAxMTAwMT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eyAwYjEwMTEwMDExLCB7IE1QRUc0UHJvZmlsZUFkdmFuY2VkQ29kaW5nLCAgICBNUEVHNExldmVsMyAgfSB9LAorICAgICAgICAgICAgeyAwYjEwMTEwMTAwLCB7IE1QRUc0UHJvZmlsZUFkdmFuY2VkQ29kaW5nLCAgICBNUEVHNExldmVsNCAgfSB9LAorICAgICAgICAgICAgeyAwYjExMDAwMDAxLCB7IE1QRUc0UHJvZmlsZUFkdmFuY2VkQ29yZSwgICAgICBNUEVHNExldmVsMSAgfSB9LAorICAgICAgICAgICAgeyAwYjExMDAwMDEwLCB7IE1QRUc0UHJvZmlsZUFkdmFuY2VkQ29yZSwgICAgICBNUEVHNExldmVsMiAgfSB9LAorICAgICAgICAgICAgeyAwYjExMDEwMDAxLCB7IE1QRUc0UHJvZmlsZUFkdmFuY2VkU2NhbGFibGUsICBNUEVHNExldmVsMSAgfSB9LAorICAgICAgICAgICAgeyAwYjExMDEwMDEwLCB7IE1QRUc0UHJvZmlsZUFkdmFuY2VkU2NhbGFibGUsICBNUEVHNExldmVsMiAgfSB9LAorICAgICAgICAgICAgeyAwYjExMDEwMDExLCB7IE1QRUc0UHJvZmlsZUFkdmFuY2VkU2NhbGFibGUsICBNUEVHNExldmVsMyAgfSB9LAogICAgICAgICAgICAgLyogdW5zdXBwb3J0ZWQKLSAgICAgICAgICAgIHsgMGIxMTEwMDAwMSwgeyBYWFhfTVBFRzRQcm9maWxlU2ltcGxlU3R1ZGlvLCAgICAgICAgICAgIE9NWF9WSURFT19NUEVHNExldmVsMSAgfSB9LAotICAgICAgICAgICAgeyAwYjExMTAwMDEwLCB7IFhYWF9NUEVHNFByb2ZpbGVTaW1wbGVTdHVkaW8sICAgICAgICAgICAgT01YX1ZJREVPX01QRUc0TGV2ZWwyICB9IH0sCi0gICAgICAgICAgICB7IDBiMTExMDAwMTEsIHsgWFhYX01QRUc0UHJvZmlsZVNpbXBsZVN0dWRpbywgICAgICAgICAgICBPTVhfVklERU9fTVBFRzRMZXZ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QRUc0UHJvZmlsZVNpbXBsZVN0dWRpbywgICAgICAgICAgICBNUEVHNExldmVsNCAgfSB9LAorICAgICAgICAgICAgeyAwYjExMTAwMTAxLCB7IFhYWF9NUEVHNFByb2ZpbGVDb3JlU3R1ZGlvLCAgICAgICAgICAgICAgTVBFRzRMZXZlbDEgIH0gfSwKKyAgICAgICAgICAgIHsgMGIxMTEwMDExMCwgeyBYWFhfTVBFRzRQcm9maWxlQ29yZVN0dWRpbywgICAgICAgICAgICAgIE1QRUc0TGV2ZWwyICB9IH0sCisgICAgICAgICAgICB7IDBiMTExMDAxMTEsIHsgWFhYX01QRUc0UHJvZmlsZUNvcmVTdHVkaW8sICAgICAgICAgICAgICBNUEVHNExldmVsMyAgfSB9LAorICAgICAgICAgICAgeyAwYjExMTAxMDAwLCB7IFhYWF9NUEVHNFByb2ZpbGVDb3JlU3R1ZGlvLCAgICAgICAgICAgICAgTVBFRzRMZXZlbDQgIH0gfSwKKyAgICAgICAgICAgIHsgMGIxMTEwMTAxMSwgeyBYWFhfTVBFRzRQcm9maWxlU2ltcGxlU3R1ZGlvLCAgICAgICAgICAgIE1QRUc0TGV2ZWw1ICB9IH0sCisgICAgICAgICAgICB7IDBiMTExMDExMDAsIHsgWFhYX01QRUc0UHJvZmlsZVNpbXBsZVN0dWRpbywgICAgICAgICAgICBNUEVHNExldmVsNiAgfSB9LCAqLworICAgICAgICAgICAgeyAwYjExMTEwMDAwLCB7IE1QRUc0UHJvZmlsZUFkdmFuY2VkU2ltcGxlLCAgICBNUEVHNExldmVsMCAgfSB9LAorICAgICAgICAgICAgeyAwYjExMTEwMDAxLCB7IE1QRUc0UHJvZmlsZUFkdmFuY2VkU2ltcGxlLCAgICBNUEVHNExldmVsMSAgfSB9LAorICAgICAgICAgICAgeyAwYjExMTEwMDEwLCB7IE1QRUc0UHJvZmlsZUFkdmFuY2VkU2ltcGxlLCAgICBNUEVHNExldmVsMiAgfSB9LAorICAgICAgICAgICAgeyAwYjExMTEwMDExLCB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InByb2ZpbGUiLCBwcm9maWxlTGV2ZWwuZmlyc3QpOwogICAgICAgICAgICAgZm9ybWF0LT5zZXRJbnQzMigibGV2ZWwiLCBwcm9maWxlTGV2ZWwuc2Vjb25kKTsKQEAgLTU5MCwyMyArNjA3LDMyIEBACiAgICAgICAgIHN3aXRjaCAoaWQpIHsKICAgICAgICAgICAgIGNhc2UgMSAvKiBwcm9maWxlSWQgKi86CiAgICAgICAgICAgICAgICAgaWYgKGxlbmd0aCA+PSAxKSB7Ci0gICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0YXRpYyBBTG9va3VwPHVpbnQ4X3QsIE9NWF9WSURFT19WUDlQUk9GSUxFVFlQRT4gcHJvZmlsZXMgewotICAgICAgICAgICAgICAgICAgICAgICAgeyAwLCBPTVhfVklERU9fVlA5UHJvZmlsZTAgfSwKLSAgICAgICAgICAgICAgICAgICAgICAgIHsgMSwgT01YX1ZJREVPX1ZQOVByb2ZpbGUxIH0sCi0gICAgICAgICAgICAgICAgICAgICAgICB7IDIsIE9NWF9WSURFT19WUDlQcm9maWxlMiB9LAotICAgICAgICAgICAgICAgICAgICAgICAgeyAzLCBPTVhfVklERU9fVlA5UHJvZmlsZTMgfSwKKyAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RhdGljIEFMb29rdXA8dWludDhfdCwgaW50MzJfdD4gcHJvZmlsZXMgeworICAgICAgICAgICAgICAgICAgICAgICAgeyAwLCBWUDlQcm9maWxlMCB9LAorICAgICAgICAgICAgICAgICAgICAgICAgeyAxLCBWUDlQcm9maWxlMSB9LAorICAgICAgICAgICAgICAgICAgICAgICAgeyAyLCBWUDlQcm9maWxlMiB9LAorICAgICAgICAgICAgICAgICAgICAgICAgeyAzLCBWUDlQcm9maWxlMyB9LAogICAgICAgICAgICAgICAgICAgICB9OwogCi0gICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0YXRpYyBBTG9va3VwPE9NWF9WSURFT19WUDlQUk9GSUxFVFlQRSwgT01YX1ZJREVPX1ZQOVBST0ZJTEVUWVBFPiB0b0hkciB7Ci0gICAgICAgICAgICAgICAgICAgICAgICB7IE9NWF9WSURFT19WUDlQcm9maWxlMiwgT01YX1ZJREVPX1ZQOVByb2ZpbGUySERSIH0sCi0gICAgICAgICAgICAgICAgICAgICAgICB7IE9NWF9WSURFT19WUDlQcm9maWxlMywgT01YX1ZJREVPX1ZQOVByb2ZpbGUzSERSIH0sCisgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0YXRpYyBBTG9va3VwPGludDMyX3QsIGludDMyX3Q+IHRvSGRyMTAgeworICAgICAgICAgICAgICAgICAgICAgICAgeyBWUDlQcm9maWxlMiwgVlA5UHJvZmlsZTJIRFIgfSwKKyAgICAgICAgICAgICAgICAgICAgICAgIHsgVlA5UHJvZmlsZTMsIFZQOVByb2ZpbGUzSERSIH0sCiAgICAgICAgICAgICAgICAgICAgIH07CiAKLSAgICAgICAgICAgICAgICAgICAgT01YX1ZJREVPX1ZQOVBST0ZJTEVUWVBFIHByb2ZpbGU7CisgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0YXRpYyBBTG9va3VwPGludDMyX3QsIGludDMyX3Q+IHRvSGRyMTBQbHVzIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHsgVlA5UHJvZmlsZTIsIFZQOVByb2ZpbGUySERSMTBQbHVzIH0sCisgICAgICAgICAgICAgICAgICAgICAgICB7IFZQOVByb2ZpbGUzLCBWUDlQcm9maWxlM0hEUjEwUGx1cyB9LAorICAgICAgICAgICAgICAgICAgICB9OworCisgICAgICAgICAgICAgICAgICAgIGludDMyX3QgcHJvZmlsZTsKICAgICAgICAgICAgICAgICAgICAgaWYgKHByb2ZpbGVzLm1hcChkYXRhWzBdLCAmcHJvZmlsZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGNvbnZlcnQgdG8gSERSIHByb2ZpbGUKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc0hkcihmb3JtYXQpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgdG9IZHIubG9va3VwKHByb2ZpbGUsICZwcm9maWxlKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc0hkcjEwb3IxMFBsdXMoZm9ybWF0KSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb3JtYXQtPmNvbnRhaW5zKCJoZHIxMC1wbHVzLWluZm8iKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b0hkcjEwUGx1cy5sb29rdXAocHJvZmlsZSwgJnByb2ZpbGUpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvSGRyMTAubG9va3VwKHByb2ZpbGUsICZwcm9maWxlKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgICAgICAgICAgIGZvcm1hdC0+c2V0SW50MzIoInByb2ZpbGUiLCBwcm9maWxlKTsKQEAgLTYxNSwyNCArNjQxLDI0IEBACiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICBjYXNlIDIgLyogbGV2ZWxJZCAqLzoKICAgICAgICAgICAgICAgICBpZiAobGVuZ3RoID49IDEpIHsKLSAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RhdGljIEFMb29rdXA8dWludDhfdCwgT01YX1ZJREVPX1ZQOUxFVkVMVFlQRT4gbGV2ZWxzIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIHsgMTAsIE9NWF9WSURFT19WUDlMZXZlbDEgIH0sCi0gICAgICAgICAgICAgICAgICAgICAgICB7IDExLCBPTVhfVklERU9fVlA5TGV2ZWwxMSB9LAotICAgICAgICAgICAgICAgICAgICAgICAgeyAyMCwgT01YX1ZJREVPX1ZQOUxldmVsMiAgfSwKLSAgICAgICAgICAgICAgICAgICAgICAgIHsgMjEsIE9NWF9WSURFT19WUDlMZXZlbDIxIH0sCi0gICAgICAgICAgICAgICAgICAgICAgICB7IDMwLCBPTVhfVklERU9fVlA5TGV2ZWwzICB9LAotICAgICAgICAgICAgICAgICAgICAgICAgeyAzMSwgT01YX1ZJREVPX1ZQOUxldmVsMzEgfSwKLSAgICAgICAgICAgICAgICAgICAgICAgIHsgNDAsIE9NWF9WSURFT19WUDlMZXZlbDQgIH0sCi0gICAgICAgICAgICAgICAgICAgICAgICB7IDQxLCBPTVhfVklERU9fVlA5TGV2ZWw0MSB9LAotICAgICAgICAgICAgICAgICAgICAgICAgeyA1MCwgT01YX1ZJREVPX1ZQOUxldmVsNSAgfSwKLSAgICAgICAgICAgICAgICAgICAgICAgIHsgNTEsIE9NWF9WSURFT19WUDlMZXZlbDUxIH0sCi0gICAgICAgICAgICAgICAgICAgICAgICB7IDUyLCBPTVhfVklERU9fVlA5TGV2ZWw1MiB9LAotICAgICAgICAgICAgICAgICAgICAgICAgeyA2MCwgT01YX1ZJREVPX1ZQOUxldmVsNiAgfSwKLSAgICAgICAgICAgICAgICAgICAgICAgIHsgNjEsIE9NWF9WSURFT19WUDlMZXZlbDYxIH0sCi0gICAgICAgICAgICAgICAgICAgICAgICB7IDYyLCBPTVhfVklERU9fVlA5TGV2ZWw2MiB9LAorICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGF0aWMgQUxvb2t1cDx1aW50OF90LCBpbnQzMl90PiBsZXZlbHMgeworICAgICAgICAgICAgICAgICAgICAgICAgeyAxMCwgVlA5TGV2ZWwxICB9LAorICAgICAgICAgICAgICAgICAgICAgICAgeyAxMSwgVlA5TGV2ZWwxMSB9LAorICAgICAgICAgICAgICAgICAgICAgICAgeyAyMCwgVlA5TGV2ZWwyICB9LAorICAgICAgICAgICAgICAgICAgICAgICAgeyAyMSwgVlA5TGV2ZWwyMSB9LAorICAgICAgICAgICAgICAgICAgICAgICAgeyAzMCwgVlA5TGV2ZWwzICB9LAorICAgICAgICAgICAgICAgICAgICAgICAgeyAzMSwgVlA5TGV2ZWwzMSB9LAorICAgICAgICAgICAgICAgICAgICAgICAgeyA0MCwgVlA5TGV2ZWw0ICB9LAorICAgICAgICAgICAgICAgICAgICAgICAgeyA0MSwgVlA5TGV2ZWw0MSB9LAorICAgICAgICAgICAgICAgICAgICAgICAgeyA1MCwgVlA5TGV2ZWw1ICB9LAorICAgICAgICAgICAgICAgICAgICAgICAgeyA1MSwgVlA5TGV2ZWw1MSB9LAorICAgICAgICAgICAgICAgICAgICAgICAgeyA1MiwgVlA5TGV2ZWw1MiB9LAorICAgICAgICAgICAgICAgICAgICAgICAgeyA2MCwgVlA5TGV2ZWw2ICB9LAorICAgICAgICAgICAgICAgICAgICAgICAgeyA2MSwgVlA5TGV2ZWw2MSB9LAorICAgICAgICAgICAgICAgICAgICAgICAgeyA2MiwgVlA5TGV2ZWw2MiB9LAogICAgICAgICAgICAgICAgICAgICB9OwogCi0gICAgICAgICAgICAgICAgICAgIE9NWF9WSURFT19WUDlMRVZFTFRZUEUgbGV2ZWw7CisgICAgICAgICAgICAgICAgICAgIGludDMyX3QgbGV2ZWw7CiAgICAgICAgICAgICAgICAgICAgIGlmIChsZXZlbHMubWFwKGRhdGFbMF0sICZsZXZlbCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIGZvcm1hdC0+c2V0SW50MzIoImxldmVsIiwgbGV2ZWwpOwogICAgICAgICAgICAgICAgICAgICB9CkBAIC02NjYsNyArNjkyLDcgQEAKICAgICBpbnQzMl90IHByb2ZpbGU7CiAgICAgaWYgKHByb2ZpbGVzLm1hcChzdGQ6Om1ha2VfcGFpcihoaWdoQml0RGVwdGgsIHByb2ZpbGVEYXRhKSwgJnByb2ZpbGUpKSB7CiAgICAgICAgIC8vIGJ1bXAgdG8gSERSIHByb2ZpbGUKLSAgICAgICAgaWYgKGlzSGRyKGZvcm1hdCkgJiYgcHJvZmlsZSA9PSBBVjFQcm9maWxlTWFpbjEwKSB7CisgICAgICAgIGlmIChpc0hkcjEwb3IxMFBsdX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gICAgIHJldHVybiBOT19NRU1PUlk7CisgICAgICAgIH0KKyAgICAgICAgbWVtY3B5KGJ1ZmZlci0+ZGF0YSgpLCBkYXRhLCBzaXplKTsKKworICAgICAgICBidWZmZXItPm1ldGEoKS0+c2V0SW50MzIoImNzZCIsIHRydWUpOworICAgICAgICBidWZmZXItPm1ldGEoKS0+c2V0SW50NjQoInRpbWVVcyIsIDApOworICAgICAgICBtc2ctPnNldEJ1ZmZlcigiY3NkLTIiLCBidWZmZXIpOwogICAgIH0KIAogICAgICpmb3JtYXQgPSBtc2c7CkBAIC0xNzU5LDI0ICsxNzk2LDM5IEBACiAgICAgaWYgKG1pbWUuc3RhcnRzV2l0aCgidmlkZW8vIikgfHwgbWltZS5zdGFydHNXaXRoKCJpbWFnZS8iKSkgewogICAgICAgICBpbnQzMl90IHdpZHRoOwogICAgICAgICBpbnQzMl90IGhlaWdodDsKLSAgICAgICAgaWYgKG1zZy0+ZmluZEludDMyKCJ3aWR0aCIsICZ3aWR0aCkgJiYgbXNnLT5maW5kSW50MzIoImhlaWdodCIsICZoZWlnaHQpKSB7Ci0gICAgICAgICAgICBtZXRhLT5zZXRJbnQzMihrS2V5V2lkdGgsIHdpZHRoKTsKLSAgICAgICAgICAgIG1ldGEtPnNldEludDMyKGtLZXlIZWlnaHQsIGhlaWdodCk7Ci0gICAgICAgIH0gZWxzZSB7CisgICAgICAgIGlmICghbXNnLT5maW5kSW50MzIoIndpZHRoIiwgJndpZHRoKSB8fCAhbXNnLT5maW5kSW50MzIoImhlaWdodCIsICZoZWlnaHQpKSB7CiAgICAgICAgICAgICBBTE9HVigiZGlkIG5vdCBmaW5kIHdpZHRoIGFuZC9vciBoZWlnaHQiKTsKICAgICAgICAgICAgIHJldHVybiBCQURfVkFMVUU7CiAgICAgICAgIH0KKyAgICAgICAgaWYgKHdpZHRoIDw9IDAgfHwgaGVpZ2h0IDw9IDApIHsKKyAgICAgICAgICAgIEFMT0dFKCJJbnZhbGlkIHZhbHVlIG9mIH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ICAgICAgICAgICAgIG1ldGEtPnNldEludDMyKGtLZXlTQVJIZWlnaHQsIHNhckhlaWdodCk7CiAgICAgICAgIH0KIAotICAgICAgICBpbnQzMl90IGRpc3BsYXlXaWR0aCwgZGlzcGxheUhlaWdodDsKLSAgICAgICAgaWYgKG1zZy0+ZmluZEludDMyKCJkaXNwbGF5LXdpZHRoIiwgJmRpc3BsYXlXaWR0aCkKLSAgICAgICAgICAgICAgICAmJiBtc2ctPmZpbmRJbnQzMigiZGlzcGxheS1oZWlnaHQiLCAmZGlzcGxheUhlaWdodCkpIHsKKyAgICAgICAgaW50MzJfdCBkaXNwbGF5V2lkdGggPSAtMSwgZGlzcGxheUhlaWdodCA9IC0xOworICAgICAgICBmb3VuZFdpZHRoID0gbXNnLT5maW5kSW50MzIoImRpc3BsYXktd2lkdGgiLCAmZGlzcGxheVdpZHRoKTsKKyAgICAgICAgZm91bmRIZWlnaHQgPSBtc2ctPmZpbmRJbnQzMigiZGlzcGxheS1oZWlnaHQiLCAmZGlzcGxheUhlaWdodCk7CisgICAgICAgIGlmIChmb3VuZFdpZHRoIHx8IGZvdW5kSGVpZ2h0KSB7CisgICAgICAgICAgICBpZiAoZGlzcGxheVdpZHRoIDw9IDAgfHwgZGlzcGxheUhlaWdodCA8PSAwKSB7CisgICAgICAgICAgICAgICAgQUxPR0UoIkludmFsaWQgdmFsdWUgb2YgZGlzcGxheVdpZHRoOiAlZCBhbmQvb3IgZGlzcGxheUhlaWdodDogJWQiLAorICAgICAgICAgICAgICAgICAgICAgICAgZGlzcGxheVdpZHRoLCBkaXNwbGF5SGVpZ2h0KTsKKyAgICAgICAgICAgICAgICByZXR1cm4gQkFEX1ZBTFVFOworICAgICAgICAgICAgfQogICAgICAgICAgICAgbWV0YS0+c2V0SW50MzIoa0tleURpc3BsYXlXaWR0aCwgZGlzcGxheVdpZHRoKTsKICAgICAgICAgICAgIG1ldGEtPnNldEludDMyKGtLZXlEaXNwbGF5SGVpZ2h0LCBkaXNwbGF5SGVpZ2h0KTsKICAgICAgICAgfQpAQCAtMTc4NiwxNyArMTgzOCwyOSBAQAogICAgICAgICAgICAgaWYgKG1zZy0+ZmluZEludDMyKCJpcy1kZWZhdWx0IiwgJmlzUHJpbWFyeSkgJiYgaXNQcmltYXJ5KSB7CiAgICAgICAgICAgICAgICAgbWV0YS0+c2V0SW50MzIoa0tleVRyYWNrSXNEZWZhdWx0LCAxKTsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGludDMyX3QgdGlsZVdpZHRoLCB0aWxlSGVpZ2h0LCBncmlkUm93cywgZ3JpZENvbHM7Ci0gICAgICAgICAgICBpZiAobXNnLT5maW5kSW50MzIoInRpbGUtd2lkdGgiLCAmdGlsZVdpZHRoKSkgeworICAgICAgICAgICAgaW50MzJfdCB0aWxlV2lkdGggPSAtMSwgdGlsZUhlaWdodCA9IC0xOworICAgICAgICAgICAgZm91bmRXaWR0aCA9IG1zZy0+ZmluZEludDMyKCJ0aWxlLXdpZHRoIiwgJnRpbGVXaWR0aCk7CisgICAgICAgICAgICBmb3VuZEhlaWdodCA9IG1zZy0+ZmluZEludDMyKCJ0aWxlLWhlaWdodCIsICZ0aWxlSGVpZ2h0KTsKKyAgICAgICAgICAgIGlmIChmb3VuZFdpZHRoIHx8IGZvdW5kSGVpZ2h0KSB7CisgICAgICAgICAgICAgICAgaWYgKHRpbGVXaWR0aCA8PSAwIHx8IHRpbGVIZWlnaHQgPD0gMCkgeworICAgICAgICAgICAgICAgICAgICBBTE9HRSgiSW52YWxpZCB2YWx1ZSBvZiB0aWxlV2lkdGg6ICVkIGFuZC9vciB0aWxlSGVpZ2h0OiAlZCIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGlsZVdpZHRoLCB0aWxlSGVpZ2h0KTsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgbWV0YS0+c2V0SW50MzIoa0tleVRpbGVXaWR0aCwgdGlsZVdpZHRoKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGlmIChtc2ctPmZpbmRJbnQzMigidGlsZS1oZWlnaHQiLCAmdGlsZUhlaWdodCkpIHsKICAgICAgICAgICAgICAgICBtZXRhLT5zZXRJbnQzMihrS2V5VGlsZUhlaWdodCwgdGlsZUhlaWdodCk7CiAgICAgICAgICAgICB9Ci0gICAgICAgICAgICBpZiAobXNnLT5maW5kSW50MzIoImdyaWQtcm93cyIsICZncmlkUm93cykpIHsKKyAgICAgICAgICAgIGludDMyX3QgZ3JpZFJvd3MgPSAtMSwgZ3JpZENvbHMgPSAtMTsKKyAgICAgICAgICAgIGJvb2wgZm91bmRSb3dzLCBmb3VuZENvbHM7CisgICAgICAgICAgICBmb3VuZFJvd3MgPSBtc2ctPmZpbmRJbnQzMigiZ3JpZC1yb3dzIiwgJmdyaWRSb3dzKTsKKyAgICAgICAgICAgIGZvdW5kQ29scyA9IG1zZy0+ZmluZEludDMyKCJncmlkLWNvbHMiLCAmZ3JpZENvbHMpOworICAgICAgICAgICAgaWYgKGZvdW5kUm93cyB8fCBmb3VuZENvbHMpIHsKKyAgICAgICAgICAgICAgICBpZiAoZ3JpZFJvd3MgPD0gMCB8fCBncmlkQ29scyA8PSAwKSB7CisgICAgICAgICAgICAgICAgICAgIEFMT0dFKCJJbnZhbGlkIHZhbHVlIG9mIGdyaWRSb3dzOiAlZCBhbmQvb3IgZ3JpZENvbHM6ICVkIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmlkUm93cywgZ3JpZENvbHMpOworICAgICAgICAgICAgICAgICAgICByZXR1cm4gQkFEX1ZBTFVFOworICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBtZXRhLT5zZXRJbnQzMihrS2V5R3JpZFJvd3MsIGdyaWRSb3dzKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGlmIChtc2ctPmZpbmRJbnQzMigiZ3JpZC1jb2xzIiwgJmdyaWRDb2xzKSkgewogICAgICAgICAgICAgICAgIG1ldGEtPnNldEludDMyKGtLZXlHcmlkQ29scywgZ3JpZENvbHMpOwogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC0xODEyLDYgKzE4NzYsMTQgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgJmNyb3BUb3AsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICZjcm9wUmlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICZjcm9wQm90dG9tKSkgeworICAgICAgICAgICAgaWYgKGNyb3BMZWZ0IDwgMCB8fCBjcm9wTGVmdCA+IGNyb3BSaWdodCB8fCBjcm9wUmlnaHQgPj0gd2lkdGgpIHsKKyAgICAgICAgICAgICAgICBBTE9HRSgiSW52YWxpZCB2YWx1ZSBvZiBjcm9wTGVmdDogJWQgYW5kL29yIGNyb3BSaWdodDogJWQiLCBjcm9wTGVmdCwgY3JvcFJpZ2h0KTsKKyAgICAgICAgICAgICAgICByZXR1cm4gQkFEX1ZBTFVFOworICAgICAgICAgICAgfQorICAgICAgICAgICAgaWYgKGNyb3BUb3AgPCAwIHx8IGNyb3BUb3AgPiBjcm9wQm90dG9tIHx8IGNyb3BCb3R0b20gPj0gaGVpZ2h0KSB7CisgICAgICAgICAgICAgICAgQUxPR0UoIkludmFsaWQgdmFsdWUgb2YgY3JvcFRvcDogJWQgYW5kL29yIGNyb3BCb3R0b206ICVkIiwgY3JvcFRvcCwgY3JvcEJvdHRvbSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKKyAgICAgICAgICAgIH0KICAgICAgICAgICAgIG1ldGEtPnNldFJlY3Qoa0tleUNyb3BSZWN0LCBjcm9wTGVmdCwgY3JvcFRvcCwgY3JvcFJpZ2h0LCBjcm9wQm90dG9tKTsKICAgICAgICAgfQogCkBAIC0xODU1LDkgKzE5MjcsMTYgQEAKICAgICAgICAgICAgIEFMT0dWKCJkaWQgbm90IGZpbmQgY2hhbm5lbC1jb3VudCBhbmQvb3Igc2FtcGxlLXJhdGUiKTsKICAgICAgICAgICAgIHJldHVybiBCQURfVkFMVUU7CiAgICAgICAgIH0KKyAgICAgICAgLy8gY2hhbm5lbCBjb3VudCBjYW4gYmUgemVybyBpbiBzb21lIGNhc2VzIGxpa2UgbXBlZyBoCisgICAgICAgIGlmIChzYW1wbGVSYXRlIDw9IDAgfHwgbnVtQ2hhbm5lbHMgPCAwKSB7CisgICAgICAgICAgICBBTE9HRSgiSW52YWxpZCB2YWx1ZSBvZiBjaGFubmVsLWNvdW50OiAlZCBhbmQvb3Igc2FtcGxlLXJhdGU6ICVkIiwKKyAgICAgICAgICAgICAgICAgICBudW1DaGFubmVscywgc2FtcGxlUmF0ZSk7CisgICAgICAgICAgICByZXR1cm4gQkFEX1ZBTFVFOworICAgICAgICB9CiAgICAgICAgIG1ldGEtPnNldEludDMyKGtLZXlDaGFubmVsQ291bnQsIG51bUNoYW5uZWxzKTsKICAgICAgICAgbWV0YS0+c2V0SW50MzIoa0tleVNhbXBsZVJhdGUsIHNhbXBsZVJhdGUpOwogICAgICAgICBpbnQzMl90IGJpdHNQZXJTYW1wbGU7CisgICAgICAgIC8vIFRPRE86KGIvMjA0NDMwOTUyKSBhZGQgYXBwcm9wcmlhdGUgYm91bmQgY2hlY2sgZm9yIGJpdHNQZXJTYW1wbGUKICAgICAgICAgaWYgKG1zZy0+ZmluZEludDMyKCJiaXRzLXBlci1zYW1wbGUiLCAmYml0c1BlclNhbXBsZSkpIHsKICAgICAgICAgICAgIG1ldGEtPnNldEludDMyKGtLZXlCaXRzUGVyU2FtcGxlLCBiaXRzUGVyU2FtcGxlKTsKICAgICAgICAgfQpAQCAtMTk2NywzMCArMjA0NiwxNDcgQEAKICAgICAgICAgICAgICAgICAgICBtaW1lID09IE1FRElBX01JTUVUWVBFX0lNQUdFX0FWSUYpIHsKICAgICAgICAgICAgIG1ldGEtPnNldERhdGEoa0tleUFWMUMsIDAsIGNzZDAtPmRhdGEoKSwgY3NkMC0+c2l6ZSgpKTsKICAgICAgICAgfSBlbHNlIGlmIChtaW1lID09IE1FRElBX01JTUVUWVBFX1ZJREVPX0RPTEJZX1ZJU0lPTikgewotICAgICAgICAgICAgaWYgKG1zZy0+ZmluZEJ1ZmZlcigiY3NkLTIiLCAmY3NkMikpIHsKLSAgICAgICAgICAgICAgICAvL2R2Y2Mgc2hvdWxkIGJlIDI0Ci0gICAgICAgICAgICAgICAgaWYgKGNzZDItPnNpemUoKSA9PSAyNCkgewotICAgICAgICAgICAgICAgICAgICBtZXRhLT5zZXREYXRhKGtLZXlEVkNDLCBrVHlwZURWQ0MsIGNzZDItPmRhdGEoKSwgY3NkMi0+c2l6ZSgpKTsKLSAgICAgICAgICAgICAgICAgICAgdWludDhfdCAqZHZjYyA9IGNzZDItPmRhdGEoKTsKLSAgICAgICAgICAgICAgICAgICAgY29uc3QgdWludDhfdCBwcm9maWxlID0gZHZjY1syXSA+PiAxOwotICAgICAgICAgICAgICAgICAgICBpZiAocHJvZmlsZSA+IDEgJiYgcHJvZmlsZSA8IDkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIHN0ZDo6dmVjdG9yPHVpbnQ4X3Q+IGh2Y2MoY3NkMHNpemUgKyAxMDI0KTsKLSAgICAgICAgICAgICAgICAgICAgICAgIHNpemVfdCBvdXRzaXplID0gcmVhc3NlbWJsZUhWQ0MoY3NkMCwgaHZjYy5kYXRhKCksIGh2Y2Muc2l6ZSgpLCA0KTsKLSAgICAgICAgICAgICAgICAgICAgICAgIG1ldGEtPnNldERhdGEoa0tleUhWQ0MsIGtUeXBlSFZDQywgaHZjYy5kYXRhKCksIG91dHNpemUpOwotICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKERvbGJ5VmlzaW9uUHJvZmlsZUR2YXYxMTAgPT0gcHJvZmlsZSkgewotICAgICAgICAgICAgICAgICAgICAgICAgbWV0YS0+c2V0RGF0YShrS2V5QVYxQywgMCwgY3NkMC0+ZGF0YSgpLCBjc2QwLT5zaXplKCkpOwotICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICAgICAgc3A8QUJ1ZmZlcj4gY3NkMTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtc2ctPmZpbmRCdWZmZXIoImNzZC0xIiwgJmNzZDEpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RkOjp2ZWN0b3I8Y2hhcj4gYXZjYyhjc2Qwc2l6ZSArIGNzZDEtPnNpemUoKSArIDEwMjQpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemVfdCBvdXRzaXplID0gcmVhc3NlbWJsZUFWQ0MoY3NkMCwgY3NkMSwgYXZjYy5kYXRhKCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1ldGEtPnNldERhdGEoa0tleUFWQ0MsIGtUeXBlQVZDQywgYXZjYy5kYXRhKCksIG91dHNpemUpOwotICAgICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICBpbnQzMl90IHByb2ZpbGUgPSAtMTsKKyAgICAgICAgICAgIHVpbnQ4X3QgYmxDb21wYXRpYmlsaXR5SWQgPSAtMTsKKyAgICAgICAgICAgIGludDMyX3QgbGV2ZWwgPSAwOworICAgICAgICAgICAgdWludDhfdCBwcm9maWxlVmFsID0gLTE7CisgICAgICAgICAgICB1aW50OF90IHByb2ZpbGVWYWwxID0gLTE7CisgICAgICAgICAgICB1aW50OF90IHByb2ZpbGVWYWwyID0gLTE7CisgICAgICAgICAgICBjb25zdGV4cHIgc2l6ZV90IGR2Y2NTaXplID0gMjQ7CisKKyAgICAgICAgICAgIGNvbnN0IEFMb29rdXA8dWludDhfdCwgaW50MzJfdD4gJnByb2ZpbGVzID0KKyAgICAgICAgICAgICAgICBnZXREb2xieVZpc2lvblByb2ZpbGVUYWJsZSgpOworICAgICAgICAgICAgY29uc3QgQUxvb2t1cDx1aW50OF90LCBpbnQzMl90PiAmbGV2ZWxzID0KKyAgICAgICAgICAgICAgICBnZXREb2xieVZpc2lvbkxldmVsc1RhYmxlKCk7CisKKyAgICAgICAgICAgIGlmICghbXNnLT5maW5kQnVmZmVyKCJjc2QtMiIsICZjc2QyKSkgeworICAgICAgICAgICAgICAgIC8vIE1QNCBleHRyYWN0b3JzIGFyZSBleHBlY3RlZCB0byBnZW5lcmF0ZSBjc2QgYnVmZmVyCisgICAgICAgICAgICAgICAgLy8gc29tZSBlbmNvZGVycyBtaWdodCBub3QgYmUgZ2VuZXJhdGluZyBpdCwgaW4gd2hpY2gKKyAgICAgICAgICAgICAgICAvLyBjYXNlIHdlIHBvcHVsYXRlIHRoZSB0cmFjayBtZXRhZGF0YSBkdiAoY2N8dmN8d2MpCisgICAgICAgICAgICAgICAgLy8gZnJvbSB0aGUgJ3Byb2ZpbGUnIGFuZCAnbGV2ZWwnIGluZm8uCisgICAgICAgICAgICAgICAgLy8gVGhpcyBpcyBkb25lIGFjY29yZGluZyB0byBEb2xieSBWaXNpb24gSVNPQk1GRiBzcGVjCisKKyAgICAgICAgICAgICAgICBpZiAoIW1zZy0+ZmluZEludDMyKCJwcm9maWxlIiwgJnByb2ZpbGUpKSB7CisgICAgICAgICAgICAgICAgICAgIEFMT0dFKCJEb2xieSBWaXNpb24gcHJvZmlsZSBub3QgZm91bmQiKTsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgbXNnLT5maW5kSW50MzIoImxldmVsIiwgJmxldmVsKTsKKworICAgICAgICAgICAgICAgIGlmIChwcm9maWxlID09IERvbGJ5VmlzaW9uUHJvZmlsZUR2aGVTdCkgeworICAgICAgICAgICAgICAgICAgICBpZiAoIXByb2ZpbGVzLnJsb29rdXAoRG9sYnlWaXNpb25Qcm9maWxlRHZoZVN0LCAmcHJvZmlsZVZhbCkpIHsgLy8gZHZoZS4wOAorICAgICAgICAgICAgICAgICAgICAgICAgQUxPR0UoIkRvbGJ5IFZpc2lvbiBwcm9maWxlIGxvb2t1cCBlcnJvciIpOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICBibENvbXBhdGliaWxpdHlJZCA9IDQ7CisgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChwcm9maWxlID09IERvbGJ5VmlzaW9uUHJvZmlsZUR2YXZTZSkgeworICAgICAgICAgICAgICAgICAgICBpZiAoIXByb2ZpbGVzLnJsb29rdXAoRG9sYnlWaXNpb25Qcm9maWxlRHZhdlNlLCAmcHJvZmlsZVZhbCkpIHsgLy8gZHZhdi4wOQorICAgICAgICAgICAgICAgICAgICAgICAgQUxPR0UoIkRvbGJ5IFZpc2lvbiBwcm9maWxlIGxvb2t1cCBlcnJvciIpOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICBibENvbXBhdGliaWxpdHlJZCA9IDI7CisgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgQUxPR0UoIkRvbGJ5IFZpc2lvbiBwcm9maWxlIGxvb2sgdXAgZXJyb3IiKTsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKKyAgICAgICAgICAgICAgICB9CisKKyAgICAgICAgICAgICAgICBwcm9maWxlID0gKGludDMyX3QpIHByb2ZpbGVWYWw7CisKKyAgICAgICAgICAgICAgICB1aW50OF90IGxldmVsX3ZhbCA9IDA7CisgICAgICAgICAgICAgICAgaWYgKCFsZXZlbHMubWFwKGxldmVsLCAmbGV2ZWxfdmFsKSkgeworICAgICAgICAgICAgICAgICAgICBBTE9HRSgiRG9sYnkgVmlzaW9uIGxldmVsIGxvb2t1cCBlcnJvciIpOworICAgICAgICAgICAgICAgICAgICByZXR1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AgICAgICAgICAgICAgaWYgKHByb2ZpbGUgPiAoaW50MzJfdCkgcHJvZmlsZVZhbCkgeworICAgICAgICAgICAgICAgICAgICBtZXRhLT5zZXREYXRhKGtLZXlEVldDLCBrVHlwZURWV0MsIGR2Y2MuZGF0YSgpLCBkdmNjU2l6ZSk7CisgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChwcm9maWxlID4gKGludDMyX3QpIHByb2ZpbGVWYWwxKSB7CisgICAgICAgICAgICAgICAgICAgIG1ldGEtPnNldERhdGEoa0tleURWVkMsIGtUeXBlRFZWQywgZHZjYy5kYXRhKCksIGR2Y2NTaXplKTsKKyAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICBtZXRhLT5zZXREYXRhKGtLZXlEVkNDLCBrVHlwZURWQ0MsIGR2Y2MuZGF0YSgpLCBkdmNjU2l6ZSk7CisgICAgICAgICAgICAgICAgfQorCiAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIEFMT0dFKCJXZSBuZWVkIGNzZC0yISEuICVzIiwgbXNnLT5kZWJ1Z1N0cmluZygpLmNfc3RyKCkpOwotICAgICAgICAgICAgICAgIHJldHVybiBCQURfVkFMVUU7CisgICAgICAgICAgICAgICAgLy8gd2UgaGF2ZSBjc2QtMiwganVzdCB1c2UgdGhhdCB0byBwb3B1bGF0ZSBkdmNjCisgICAgICAgICAgICAgICAgaWYgKGNzZDItPnNpemUoKSA9PSBkdmNjU2l6ZSkgeworICAgICAgICAgICAgICAgICAgICB1aW50OF90ICpkdmNjID0gY3NkMi0+ZGF0YSgpOworICAgICAgICAgICAgICAgICAgICBwcm9maWxlID0gZHZjY1syXSA+PiAxOworCisgICAgICAgICAgICAgICAgICAgIHByb2ZpbGVzLnJsb29rdXAoRG9sYnlWaXNpb25Qcm9maWxlRHZhdjExMCwgJnByb2ZpbGVWYWwpOworICAgICAgICAgICAgICAgICAgICBwcm9maWxlcy5ybG9va3VwKERvbGJ5VmlzaW9uUHJvZmlsZUR2aGVEdGIsICZwcm9maWxlVmFsMSk7CisgICAgICAgICAgICAgICAgICAgIGlmIChwcm9maWxlID4gKGludDMyX3QpIHByb2ZpbGVWYWwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1ldGEtPnNldERhdGEoa0tleURWV0MsIGtUeXBlRFZXQywgY3NkMi0+ZGF0YSgpLCBjc2QyLT5zaXplKCkpOworICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHByb2ZpbGUgPiAoaW50MzJfdCkgcHJvZmlsZVZhbDEpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1ldGEtPnNldERhdGEoa0tleURWVkMsIGtUeXBlRFZWQywgY3NkMi0+ZGF0YSgpLCBjc2QyLT5zaXplKCkpOworICAgICAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgIG1ldGEtPnNldERhdGEoa0tleURWQ0MsIGtUeXBlRFZDQywgY3NkMi0+ZGF0YSgpLCBjc2QyLT5zaXplKCkpOworICAgICAgICAgICAgICAgICAgICB9CisKKyAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICBBTE9HRSgiQ29udmVydCBNZXNzYWdlVG9NZXRhZGF0YSBjc2QtMiBpcyBwcmVzZW50IGJ1dCBub3QgdmFsaWQiKTsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CisgICAgICAgICAgICBwcm9maWxlcy5ybG9va3VwKERvbGJ5VmlzaW9uUHJvZmlsZUR2YXZQZW4sICZwcm9maWxlVmFsKTsKKyAgICAgICAgICAgIHByb2ZpbGVzLnJsb29rdXAoRG9sYnlWaXNpb25Qcm9maWxlRHZhdlNlLCAmcHJvZmlsZVZhbDEpOworICAgICAgICAgICAgcHJvZmlsZXMucmxvb2t1cChEb2xieVZpc2lvblByb2ZpbGVEdmF2MTEwLCAmcHJvZmlsZVZhbDIpOworICAgICAgICAgICAgaWYgKChwcm9maWxlID4gKGludDMyX3QpIHByb2ZpbGVWYWwpICYmIChwcm9maWxlIDwgKGludDMyX3QpIHByb2ZpbGVWYWwxKSkgeworICAgICAgICAgICAgICAgIHN0ZDo6dmVjdG9yPHVpbnQ4X3Q+IGh2Y2MoY3NkMHNpemUgKyAxMDI0KTsKKyAgICAgICAgICAgICAgICBzaXplX3Qgb3V0c2l6ZSA9IHJlYXNzZW1ibGVIVkNDKGNzZDAsIGh2Y2MuZGF0YSgpLCBodmNjLnNpemUoKSwgNCk7CisgICAgICAgICAgICAgICAgbWV0YS0+c2V0RGF0YShrS2V5SFZDQywga1R5cGVIVkNDLCBodmNjLmRhdGEoKSwgb3V0c2l6ZSk7CisgICAgICAgICAgICB9IGVsc2UgaWYgKHByb2ZpbGUgPT0gKGludDMyX3QpIHByb2ZpbGVWYWwyKSB7CisgICAgICAgICAgICAgICAgbWV0YS0+c2V0RGF0YShrS2V5QVYxQywgMCwgY3NkMC0+ZGF0YSgpLCBjc2QwLT5zaXplKCkpOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICBzcDxBQnVmZmVyPiBjc2QxOworICAgICAgICAgICAgICAgIGlmIChtc2ctPmZpbmRCdWZmZXIoImNzZC0xIiwgJmNzZDEpKSB7CisgICAgICAgICAgICAgICAgICAgIHN0ZDo6dmVjdG9yPGNoYXI+IGF2Y2MoY3NkMHNpemUgKyBjc2QxLT5zaXplKCkgKyAxMDI0KTsKKyAgICAgICAgICAgICAgICAgICAgc2l6ZV90IG91dHNpemUgPSByZWFzc2VtYmxlQVZDQyhjc2QwLCBjc2QxLCBhdmNjLmRhdGEoKSk7CisgICAgICAgICAgICAgICAgICAgIG1ldGEtPnNldERhdGEoa0tleUFWQ0MsIGtUeXBlQVZDQywgYXZjYy5kYXRhKCksIG91dHNpemUpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgLy8gZm9yIGRvbGJ5IHZpc2lvbiBhdmMsIGNzZDAgYWxzbyBob2xkcyBjc2QxCisgICAgICAgICAgICAgICAgICAgIHNpemVfdCBpID0gMDsKKyAgICAgICAgICAgICAgICAgICAgaW50IGNzZDByZWFsc2l6ZSA9IDA7CisgICAgICAgICAgICAgICAgICAgIGRvIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGkgPSBmaW5kTmV4dE5hbFN0YXJ0Q29kZShjc2QwLT5kYXRhKCkgKyBpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNzZDAtPnNpemUoKSAtIGkpIC0gY3NkMC0+ZGF0YSgpOworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPiAwKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3NkMHJlYWxzaXplID0gaTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIGkgKz0gNDsKKyAgICAgICAgICAgICAgICAgICAgfSB3aGlsZShpIDwgY3NkMC0+c2l6ZSgpKTsKKyAgICAgICAgICAgICAgICAgICAgLy8gYnVmZmVyMCAtPiBjc2QwCisgICAgICAgICAgICAgICAgICAgIHNwPEFCdWZmZXI+IGJ1ZmZlcjAgPSBuZXcgKHN0ZDo6bm90aHJvdykgQUJ1ZmZlcihjc2QwcmVhbHNpemUpOworICAgICAgICAgICAgICAgICAgICBpZiAoYnVmZmVyMC5nZXQoKSA9PSBOVUxMIHx8IGJ1ZmZlcjAtPmJhc2UoKSA9PSBOVUxMKSB7CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gTk9fTUVNT1JZOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIG1lbWNweShidWZmZXIwLT5kYXRhKCksIGNzZDAtPmRhdGEoKSwgY3NkMHJlYWxzaXplKTsKKyAgICAgICAgICAgICAgICAgICAgLy8gYnVmZmVyMSAtPiBjc2QxCisgICAgICAgICAgICAgICAgICAgIHNwPEFCdWZmZXI+IGJ1ZmZlcjEgPSBuZXcgKHN0ZDo6bm90aHJvdykKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBBQnVmZmVyKGNzZDAtPnNpemUoKSAtIGNzZDByZWFsc2l6ZSk7CisgICAgICAgICAgICAgICAgICAgIGlmIChidWZmZXIxLmdldCgpID09IE5VTEwgfHwgYnVmZmVyMS0+YmFzZSgpID09IE5VTEwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBOT19NRU1PUlk7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgbWVtY3B5KGJ1ZmZlcjEtPmRhdGEoKSwgY3NkMC0+ZGF0YSgpK2NzZDByZWFsc2l6ZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3NkMC0+c2l6ZSgpIC0gY3NkMHJlYWxzaXplKTsKKworICAgICAgICAgICAgICAgICAgICBzdGQ6OnZlY3RvcjxjaGFyPiBhdmNjKGNzZDAtPnNpemUoKSArIDEwMjQpOworICAgICAgICAgICAgICAgICAgICBzaXplX3Qgb3V0c2l6ZSA9IHJlYXNzZW1ibGVBVkNDKGJ1ZmZlcjAsIGJ1ZmZlcjEsIGF2Y2MuZGF0YSgpKTsKKyAgICAgICAgICAgICAgICAgICAgbWV0YS0+c2V0RGF0YShrS2V5QVZDQywga1R5cGVBVkNDLCBhdmNjLmRhdGEoKSwgb3V0c2l6ZSk7CisgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogICAgICAgICB9IGVsc2UgaWYgKG1pbWUgPT0gTUVESUFfTUlNRVRZUEVfVklERU9fVlA5KSB7CiAgICAgICAgICAgICBtZXRhLT5zZXREYXRhKGtLZXlWcDlDb2RlY1ByaXZhdGUsIDAsIGNzZDAtPmRhdGEoKSwgY3NkMC0+c2l6ZSgpKTsKQEAgLTIxMzEsMjkgKzIzMjcsMjkgQEAKIH0KIAogc3RydWN0IGFhY19mb3JtYXRfY29udl90IHsKLSAgICBPTVhfQVVESU9fQUFDUFJPRklMRVRZUEUgZUFhY1Byb2ZpbGVUeXBlOworICAgIGludDMyX3QgZUFhY1Byb2ZpbGVUeXBlOwogICAgIGF1ZGlvX2Zvcm1hdF90IGZvcm1hdDsKIH07CiAKIHN0YXRpYyBjb25zdCBzdHJ1Y3QgYWFjX2Zvcm1hdF9jb252X3QgcHJvZmlsZUxvb2t1cFtdID0gewotICAgIHsgT01YX0FVRElPX0FBQ09iamVjdE1haW4sICAgICAgICBBVURJT19GT1JNQVRfQUFDX01BSU59LAotICAgIHsgT01YX0FVRElPX0FBQ09iamVjdExDLCAgICAgICAgICBBVURJT19GT1JNQVRfQUFDX0xDfSwKLSAgICB7IE9NWF9BVURJT19BQUNPYmplY3RTU1IsICAgICAgICAgQVVESU9fRk9STUFUX0FBQ19TU1J9LAotICAgIHsgT01YX0FVRElPX0FBQ09iamVjdExUUCwgICAgICAgICBBVURJT19GT1JNQVRfQUFDX0xUUH0sCi0gICAgeyBPTVhfQVVESU9fQUFDT2JqZWN0SEUsICAgICAgICAgIEFVRElPX0ZPUk1BVF9BQUNfSEVfVjF9LAotICAgIHsgT01YX0FVRElPX0FBQ09iamVjdFNjYWxhYmxlLCAgICBBVURJT19GT1JNQVRfQUFDX1NDQUxBQkxFfSwKLSAgICB7IE9NWF9BVURJT19BQUNPYmplY3RFUkxDLCAgICAgICAgQVVESU9fRk9STUFUX0FBQ19FUkxDfSwKLSAgICB7IE9NWF9BVURJT19BQUNPYmplY3RMRCwgICAgICAgICAgQVVESU9fRk9STUFUX0FBQ19MRH0sCi0gICAgeyBPTVhfQVVESU9fQUFDT2JqZWN0SEVfUFMsICAgICAgIEFVRElPX0ZPUk1BVF9BQUNfSEVfVjJ9LAotICAgIHsgT01YX0FVRElPX0FBQ09iamVjdEVMRCwgICAgICAgICBBVURJT19GT1JNQVRfQUFD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2VydmljZShuYW1lKSk7CisgICAgICAgIG1Db21wb3NlciA9IGludGVyZmFjZV9jYXN0PGd1aTo6SVN1cmZhY2VDb21wb3Nlcj4oc20tPmNoZWNrU2VydmljZShuYW1lKSk7CiAgICAgfQogICAgIGlmIChtQ29tcG9zZXIgIT0gTlVMTCkgewotICAgICAgICBEaXNwbGF5U3RhdEluZm8gc3RhdHM7Ci0gICAgICAgIHN0YXR1c190IHJlcyA9IG1Db21wb3Nlci0+Z2V0RGlzcGxheVN0YXRzKE5VTEwgLyogZGlzcGxheSAqLywgJnN0YXRzKTsKLSAgICAgICAgaWYgKHJlcyA9PSBPSykgeworICAgICAgICBndWk6OkRpc3BsYXlTdGF0SW5mbyBzdGF0czsKKyAgICAgICAgYmluZGVyOjpTdGF0dXMgc3RhdHVzID0gbUNvbXBvc2VyLT5nZXREaXNwbGF5U3RhdHMobnVsbHB0ci8qIGRpc3BsYXkgKi8sICZzdGF0cyk7CisgICAgICAgIGlmIChzdGF0dXMuaXNPaygpKSB7CiAgICAgICAgICAgICBBTE9HVigidnN5bmMgdGltZTolbGxkIHBlcmlvZDolbGxkIiwKICAgICAgICAgICAgICAgICAgICAgKGxvbmcgbG9uZylzdGF0cy52c3luY1RpbWUsIChsb25nIGxvbmcpc3RhdHMudnN5bmNQZXJpb2QpOwogICAgICAgICAgICAgbVZzeW5jVGltZSA9IHN0YXRzLnZzeW5jVGltZTsKICAgICAgICAgICAgIG1Wc3luY1BlcmlvZCA9IHN0YXRzLnZzeW5jUGVyaW9kOwogICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgQUxPR1coImdldERpc3BsYXlTdGF0cyByZXR1cm5lZCAlZCIsIHJlcyk7CisgICAgICAgICAgICBBTE9HVygiZ2V0RGlzcGxheVN0YXRzIHJldHVybmVkICVkIiwgc3RhdHVzLnRyYW5zYWN0aW9uRXJyb3IoKSk7CiAgICAgICAgIH0KICAgICB9IGVsc2UgewogICAgICAgICBBTE9HVygiY291bGQgbm90IGdldCBzd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WQgcmFuZ2UgbWVhbnMgWSBpcyBpbiBbMTYsIDIzNV0sIFUgYW5kIFYgYXJlIGluIFsxNiwgMjI0XSBjb3JyZXNwb25kaW5nIHRvIFstMC41IHRvIDAuNV0uCisKK0Z1bGwgcmFuZ2UgbWVhbnMgWSBpcyBpbiBbMCwgMjU1XSwgVSBhbmQgViBhcmUgaW4gWzAuNSwgMjU1LjVdIGNvcnJlc3BvbmRpbmcgdG8gWy0wLjUgdG8gLjVdLgorCitSR0IgaXMgYWx3YXlzIGluIGZ1bGwgcmFuZ2UgKFswLCAyNTVdKQorCitUaGUgY29sb3IgcHJpbWFyaWVzIGRldGVybWluZSB0aGUgS1IgYW5kIEtCIHZhbHVlczoKKworCitGb3IgZnVsbCByYW5nZSAoYXNzdW1pbmcgOC1iaXRzKSBJU08gZGVmaW5lczoKKworKCAgIFkgICApICAgKCAgS1IgICAgICAxLUtSLUtCICAgICAgIEtCICApCisoICAgICAgICkgICAoICAgICAgICAgICAgICAgICAgICAgICAgICAgICkgICAoUikKKyggICAgICAgKSAgICgtS1IvMiAgIC0oMS1LUi1LQikvMiAgICAgICAgKSAgICggKQorKFUgLSAxMjgpID0gKC0tLS0tICAgLS0tLS0tLS0tLS0tICAgIDAuNSApICogKEcpCisoICAgICAgICkgICAoKDEtS0IpICAgICAoMS1LQikgICAgICAgICAgICkgICAoICkKKyggICAgICAgKSAgICggICAgICAgICAgICAgICAgICAgICAgICAgICAgKSAgIChCKQorKCAgICAgICApICAgKCAgICAgICAgLSgxLUtSLUtCKS8yICAtS0IvMiApCisoViAtIDEyOCkgICAoIDAuNSAgICAtLS0tLS0tLS0tLS0gIC0tLS0tICkKKyAgICAgICAgICAgICggICAgICAgICAgICgxLUtSKSAgICAgKDEtS1IpKQorCisodGhlIG1hdGggaXMgcm91bmRlZCwgMTI4IGlzICgxIDw8IChiaXRkZXB0aCAtIDEpKSApCisKK0Zyb20gdGhpcworCisoUikgICAgICAoIDEgICAgICAgMCAgICAgICAgMiooMS1LUikgICApICAgKCAgIFkgICApCisoICkgICAgICAoICAgICAgICAgICAgICAgICAgICAgICAgICAgICApICAgKCAgICAgICApCisoICkgICAgICAoICAgIDIqS0IqKEtCLTEpICAyKktSKihLUi0xKSApICAgKCAgICAgICApCisoRykgID0gICAoIDEgIC0tLS0tLS0tLS0tICAtLS0tLS0tLS0tLSApICogKFUgLSAxMjgpCisoICkgICAgICAoICAgICAgMS1LUi1LQiAgICAgIDEtS1ItS0IgICApICAgKCAgICAgICApCisoICkgICAgICAoICAgICAgICAgICAgICAgICAgICAgICAgICAgICApICAgKCAgICAgICApCisoQikgICAgICAoIDEgICAyKigxLUtCKSAgICAgICAgIDAgICAgICApICAgKFYgLSAxMjgpCisKK0ZvciBsaW1pdGVkIHJhbmdlLCB0aGlzIGJlY29tZXMKKworKFIpICAgICAgKCAxICAgICAgIDAgICAgICAgIDIqKDEtS1IpICAgKSAgICgyNTUvMjE5ICAwICAwKSAgIChZIC0gIDE2KQorKCApICAgICAgKCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKSAgICggICAgICAgICAgICAgKSAgICggICAgICAgKQorKCApICAgICAgKCAgICAyKktCKihLQi0xKSAgMipLUiooS1ItMSkgKSAgICggICAgICAgICAgICAgKSAgICggICAgICAgKQorKEcpICA9ICAgKCAxICAtLS0tLS0tLS0tLSAgLS0tLS0tLS0tLS0gKSAqICgwICAyNTUvMjI0ICAwKSAqIChVIC0gMTI4KQorKCApICAgICAgKCAgICAgIDEtS1ItS0IgICAgICAxLUtSLUtCICAgKSAgICggICAgICAgICAgICAgKSAgICggICAgICAgKQorKCApICAgICAgKCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKSAgICggICAgICAgICAgICAgKSAgICggICAgICAgKQorKEIpICAgICAgKCAxICAgMiooMS1LQikgICAgICAgICAwICAgICAgKSAgICgwICAwICAyNTUvMjI0KSAgIChWIC0gMTI4KQorCisoIEZvciBub24tOC1iaXQsIDE2IGlzICgxIDw8IChiaXRkZXB0aCAtIDQ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oKICAgICAgICAgbUJwcCA9IDQ7CiAgICAgICAgIG1TdHJpZGUgPSA0ICogbVdpZHRoOwpAQCAtMjEzLDcgKzM2Nyw3IEBACiAKICAgICBzdGF0dXNfdCBlcnI7CiAKLSAgICBzd2l0Y2ggKG1TcmNGb3JtYXQpIHsKKyAgICBzd2l0Y2ggKChpbnQzMl90KW1TcmNGb3JtYXQpIHsKICAgICAgICAgY2FzZSBPTVhfQ09MT1JfRm9ybWF0WVVWNDIwUGxhbmFyOgogI2lmZGVmIFVTRV9MSUJZVVYKICAgICAgICAgICAgIGVyciA9IGNvbnZlcnRZVVY0MjBQbGFuYXJVc2VMaWJZVVYoc3JjLCBkc3QpOwpAQCAtMjM1LDYgKzM4OSwxOSBAQAogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIH0KIAorICAgICAgICBjYXNlIENPTE9SX0Zvcm1hdFlVVlAwMTA6CisgICAgICAgIHsKKyNpZiBQRVJGX1BST0ZJTElORworICAgICAgICAgICAgaW50NjRfdCBzdGFydFRpbWVVcyA9IEFMb29wZXI6OkdldE5vd1VzKCk7CisjZW5kaWYKKyAgICAgICAgICAgIGVyciA9IGNvbnZlcnRZVVZQMDEwKHNyYywgZHN0KTsKKyNpZiBQRVJGX1BST0ZJTElORworICAgICAgICAgICAgaW50NjRfdCBlbmRUaW1lVXMgPSBBTG9vcGVyOjpHZXROb3dVcygpOworICAgICAgICAgICAgQUxPR0QoImNvbnZlcnRZVVZQMDEwIHRvb2sgJWxsZCB1cyIsIChsb25nIGxvbmcpIChlbmRUaW1lVXMgLSBzdGFydFRpbWVVcykpOworI2VuZGlmCisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorCiAgICAgICAgIGNhc2UgT01YX0NPTE9SX0Zvcm1hdENiWUNyWToKICAgICAgICAgICAgIGVyciA9IGNvbnZlcnRDYllDclkoc3JjLCBkc3QpOwogICAgICAgICAgICAgYnJlYWs7CkBAIC0yNjUsMTAgKzQzMiw1MyBAQAogICAgIHJldH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ZENsaXAgPSBpbml0Q2xpcCgpOwogCiAgICAgdWludDE2X3QgKmRzdF9wdHIgPSAodWludDE2X3QgKilkc3QubUJpdHMKQEAgLTI3OSwyMiArNDg5LDIyIEBACiAKICAgICBmb3IgKHNpemVfdCB5ID0gMDsgeSA8IHNyYy5jcm9wSGVpZ2h0KCk7ICsreSkgewogICAgICAgICBmb3IgKHNpemVfdCB4ID0gMDsgeCA8IHNyYy5jcm9wV2lkdGgoKTsgeCArPSAyKSB7Ci0gICAgICAgICAgICBzaWduZWQgeTEgPSAoc2lnbmVkKXNyY19wdHJbMiAqIHggKyAxXSAtIDE2OwotICAgICAgICAgICAgc2lnbmVkIHkyID0gKHNpZ25lZClzcmNfcHRyWzIgKiB4ICsgM10gLSAxNjsKKyAgICAgICAgICAgIHNpZ25lZCB5MSA9IChzaWduZWQpc3JjX3B0clsyICogeCArIDFdIC0gX2MxNjsKKyAgICAgICAgICAgIHNpZ25lZCB5MiA9IChzaWduZWQpc3JjX3B0clsyICogeCArIDNdIC0gX2MxNjsKICAgICAgICAgICAgIHNpZ25lZCB1ID0gKHNpZ25lZClzcmNfcHRyWzIgKiB4XSAtIDEyODsKICAgICAgICAgICAgIHNpZ25lZCB2ID0gKHNpZ25lZClzcmNfcHRyWzIgKiB4ICsgMl0gLSAxMjg7CiAKLSAgICAgICAgICAgIHNpZ25lZCB1X2IgPSB1ICogNTE3OwotICAgICAgICAgICAgc2lnbmVkIHVfZyA9IC11ICogMTAwOwotICAgICAgICAgICAgc2lnbmVkIHZfZyA9IC12ICogMjA4OwotICAgICAgICAgICAgc2lnbmVkIHZfciA9IHYgKiA0MDk7CisgICAgICAgICAgICBzaWduZWQgdV9iID0gdSAqIF9iX3U7CisgICAgICAgICAgICBzaWduZWQgdV9nID0gdSAqIF9uZWdfZ191OworICAgICAgICAgICAgc2lnbmVkIHZfZyA9IHYgKiBfbmVnX2dfdjsKKyAgICAgICAgICAgIHNpZ25lZCB2X3IgPSB2ICogX3JfdjsKIAotICAg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NWF9DT0xPUl9Gb3JtYXRZVVY0MjBQbGFuYXI6CiAgICAgICAgIHJldHVybiBbXSh2b2lkICpzcmNfeSwgdm9pZCAqc3JjX3UsIHZvaWQgKnNyY192LCBzaXplX3QgeCwKICAgICAgICAgICAgICAgICAgIHNpZ25lZCAqeTEsIHNpZ25lZCAqeTIsIHNpZ25lZCAqdSwgc2lnbmVkICp2KSB7Ci0gICAgICAgICAgICAqeTEgPSAoKHVpbnQ4X3QqKXNyY195KVt4XSAtIDE2OwotICAgICAgICAgICAgKnkyID0gKCh1aW50OF90KilzcmNfeSlbeCArIDFdIC0gMTY7CisgICAgICAgICAgICAqeTEgPSAoKHVpbnQ4X3QqKXNyY195KVt4XTsKKyAgICAgICAgICAgICp5MiA9ICgodWludDhfdCopc3JjX3kpW3ggKyAxXTsKICAgICAgICAgICAgICp1ID0gKCh1aW50OF90KilzcmNfdSlbeCAvIDJdIC0gMTI4OwogICAgICAgICAgICAgKnYgPSAoKHVpbnQ4X3QqKXNyY192KVt4IC8gMl0gLSAxMjg7CiAgICAgICAgIH07CiAgICAgY2FzZSBPTVhfQ09MT1JfRm9ybWF0WVVWNDIwUGxhbmFyMTY6CiAgICAgICAgIHJldHVybiBbXSh2b2lkICpzcmNfeSwgdm9pZCAqc3JjX3UsIHZvaWQgKnNyY192LCBzaXplX3QgeCwKICAgICAgICAgICAgICAgICBzaWduZWQgKnkxLCBzaWduZWQgKnkyLCBzaWduZWQgKnUsIHNpZ25lZCAqdikgewotICAgICAgICAgICAgKnkxID0gKHNpZ25lZCkoKCh1aW50MTZfdCopc3JjX3kpW3hdID4+IDIpIC0gMTY7Ci0gICAgICAgICAgICAqeTIgPSAoc2lnbmVkKSgoKHVpbnQxNl90KilzcmNfeSlbeCArIDFdID4+IDIpIC0gMTY7CisgICAgICAgICAgICAqeTEgPSAoc2lnbmVkKSgoKHVpbnQxNl90KilzcmNfeSlbeF0gPj4gMik7CisgICAgICAgICAgICAqeTIgPSAoc2lnbmVkKSgoKHV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gICAgICAgICAgICAgICAgICAgICAgICAgIHNpZ25lZCByMSwgc2lnbmVkIGcxLCBzaWduZWQgYjEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2lnbmVkIHIyLCBzaWduZWQgZzIsIHNpZ25lZCBiMikgewogICAgICAgICAgICAgdWludDMyX3QgcmdiMSA9Ci0gICAgICAgICAgICAgICAgKChrQWRqdXN0ZWRDbGlwW3IxXSA+PiAzKSA8PCAxMSkKLSAgICAgICAgICAgICAgICB8ICgoa0FkanVzdGVkQ2xpcFtnMV0gPj4gMikgPDwgNSkKLSAgICAgICAgICAgICAgICB8IChrQWRqdXN0ZWRDbGlwW2IxXSA+PiAzKTsKKyAgICAgICAgICAgICAgICAoKCgodWludDhfdCAqKWtBZGp1c3RlZENsaXApW3IxXSA+PiAzKSA8PCAxMSkKKyAgICAgICAgICAgICAgICB8ICgoKCh1aW50OF90ICopa0FkanVzdGVkQ2xpcClbZzFdID4+IDIpIDw8IDUpCisgICAgICAgICAgICAgICAgfCAoKCh1aW50OF90ICopa0FkanVzdGVkQ2xpcClbYjFdID4+IDMpOwogCiAgICAgICAgICAgICBpZiAodW5jcm9wcGVkKSB7CiAgICAgICAgICAgICAgICAgdWludDMyX3QgcmdiMiA9Ci0gICAgICAgICAgICAgICAgICAgICgoa0FkanVzdGVkQ2xpcFtyMl0gPj4gMykgPDwgMTEpCi0gICAgICAgICAgICAgICAgICAgIHwgKChrQWRqdXN0ZWRDbGlwW2cyXSA+PiAyKSA8PCA1KQotICAgICAgICAgICAgICAgICAgICB8IChrQWRqdXN0ZWRDbGlwW2IyXSA+PiAzKTsKKyAgICAgICAgICAgICAgICAgICAgKCgoKHVpbnQ4X3QgKilrQWRqdXN0ZWRDbGlwKVtyMl0gPj4gMykgPDwgMTEpCisgICAgICAgICAgICAgICAgICAgIHwgKCgoKHVpbnQ4X3QgKilrQWRqdXN0ZWRDbGlwKVtnMl0gPj4gMikgPDwgNSkKKyAgICAgICAgICAgICAgICAgICAgfCAoKCh1aW50OF90ICopa0FkanVzdGVkQ2xpcClbYjJdID4+IDMpOwogCiAgICAgICAgICAgICAgICAgKih1aW50MzJfdCAqKWRzdF9wdHIgPSAocmdiMiA8PCAxNikgfCByZ2IxOwogICAgICAgICAgICAgfSBlbHNlIHsKQEAgLTQ2OSwxNiArNzA1LDE2IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2lnbmVkIHIxLCBzaWduZWQgZzEsIHNpZ25lZCBiMSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaWduZWQgcjIsIHNpZ25lZCBnMiwgc2lnbmVkIGIyKSB7CiAgICAgICAgICAgICAoKHVpbnQzMl90ICopZHN0X3B0cilbMF0gPQotICAgICAgICAgICAgICAgICAgICAoa0FkanVzdGVkQ2xpcFtyMV0pCi0gICAgICAgICAgICAgICAgICAgIHwgKGtBZGp1c3RlZENsaXBbZzFdIDw8IDgpCi0gICAgICAgICAgICAgICAgICAgIHwgKGtBZGp1c3RlZENsaXBbYjFdIDw8IDE2KQorICAgICAgICAgICAgICAgICAgICAoKCh1aW50OF90ICopa0FkanVzdGVkQ2xpcClbcjFdKQorICAgICAgICAgICAgICAgICAgICB8ICgoKHVpbnQ4X3QgKilrQWRqdXN0ZWRDbGlwKVtnMV0gPDwgOCkKKyAgICAgICAgICAgICAgICAgICAgfCAoKCh1aW50OF90ICopa0FkanVzdGVkQ2xpcClbYjFdIDw8IDE2KQogICAgICAgICAgICAgICAgICAgICB8ICgweEZGIDw8IDI0KTsKIAogICAgICAgICAgICAgaWYgKHVuY3JvcHBlZCkgewogICAgICAgICAgICAgICAgICgodWludDMyX3QgKilkc3RfcHRyKVsxXSA9Ci0gICAgICAgICAgICAgICAgICAgICAgICAoa0FkanVzdGVkQ2xpcFtyMl0pCi0gICAgICAgICAgICAgICAgICAgICAgICB8IChrQWRqdXN0ZWRDbGlwW2cyXSA8PCA4KQotICAgICAgICAgICAgICAgICAgICAgICAgfCAoa0FkanVzdGVkQ2xpcFtiMl0gPDwgMTYpCisgICAgICAgICAgICAgICAgICAgICAgICAoKCh1aW50OF90ICopa0FkanVzdGVkQ2xpcClbcjJdKQorICAgICAgICAgICAgICAgICAgICAgICAgfCAoKCh1aW50OF90ICopa0FkanVzdGVkQ2xpcClbZzJdIDw8IDgpCisgICAgICAgICAgICAgICAgICAgICAgICB8ICgoKHVpbnQ4X3QgKilrQWRqdXN0ZWRDbGlwKVtiMl0gPDwgMTYpCiAgICAgICAgICAgICAgICAgICAgICAgICB8ICgweEZGIDw8IDI0KTsKICAgICAgICAgICAgIH0KICAgICAgICAgfTsKQEAgLTQ4OSwyMCArNzI1LDQxIEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2lnbmVkIHIxLCBzaWduZWQgZzEsIHNpZ25lZCBiMSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaWduZWQgcjIsIHNpZ25lZCBnMiwgc2lnbmVkIGIyKSB7CiAgICAgICAgICAgICAoKHVpbnQzMl90ICopZHN0X3B0cilbMF0gPQotICAgICAgICAgICAgICAgICAgICAoa0FkanVzdGVkQ2xpcFtiMV0pCi0gICAgICAgICAgICAgICAgICAgIHwgKGtBZGp1c3RlZENsaXBbZzFdIDw8IDgpCi0gICAgICAgICAgICAgICAgICAgIHwgKGtBZGp1c3RlZENsaXBbcjFdIDw8IDE2KQorICAgICAgICAgICAgICAgICAgICAoKCh1aW50OF90ICopa0FkanVzdGVkQ2xpcClbYjFdKQorICAgICAgICAgICAgICAgICAgICB8ICgoKHVpbnQ4X3QgKilrQWRqdXN0ZWRDbGlwKVtnMV0gPDwgOCkKKyAgICAgICAgICAgICAgICAgICAgfCAoKCh1aW50OF90ICopa0FkanVzdGVkQ2xpcClbcjFdIDw8IDE2KQogICAgICAgICAgICAgICAgICAgICB8ICgweEZGIDw8IDI0KTsKIAogICAgICAgICAgICAgaWYgKHVuY3JvcHBlZCkgewogICAgICAgICAgICAgICAgICgodWludDMyX3QgKilkc3RfcHRyKVsxXSA9Ci0gICAgICAgICAgICAgICAgICAgICAgICAoa0FkanVzdGVkQ2xpcFtiMl0pCi0gICAgICAgICAgICAgICAgICAgICAgICB8IChrQWRqdXN0ZWRDbGlwW2cyXSA8PCA4KQotICAgICAgICAgICAgICAgICAgICAgICAgfCAoa0FkanVzdGVkQ2xpcFtyMl0gPDwgMTYpCisgICAgICAgICAgICAgICAgICAgICAgICAoKCh1aW50OF90ICopa0FkanVzdGVkQ2xpcClbYjJdKQorICAgICAgICAgICAgICAgICAgICAgICAgfCAoKCh1aW50OF90ICopa0FkanVzdGVkQ2xpcClbZzJdIDw8IDgpCisgICAgICAgICAgICAgICAgICAgICAgICB8ICgoKHVpbnQ4X3QgKilrQWRqdXN0ZWRDbGlwKVtyMl0gPDwgMTYpCiAgICAgICAgICAgICAgICAgICAgICAgICB8ICgweEZGIDw8IDI0KTsKICAgICAgICAgICAgIH0KICAgICAgICAgfTsKICAgICB9CisgICAgY2FzZSBDT0xPUl9Gb3JtYXQzMmJpdEFCR1IyMTAxMDEwOgorICAgIHsKKyAgICAgICAgcmV0dXJuIFtrQWRqdXN0ZWRDbGlwXSh2b2lkICpkc3RfcHRyLCBib29sIHVuY3JvcHBlZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaWduZWQgcjEsIHNpZ25lZCBnMSwgc2lnbmVkIGIxLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpZ25lZCByMiwgc2lnbmVkIGcyLCBzaWduZWQgYjIpIHsKKyAgICAgICAgICAgICgodWludDMyX3QgKilkc3RfcHRyKVswXSA9CisgICAgICAgICAgICAgICAgICAgICgoKHVpbnQxNl90ICopa0FkanVzdGVkQ2xpcClbcjFdKQorICAgICAgICAgICAgICAgICAgICB8ICgoKHVpbnQxNl90ICopa0FkanVzdGVkQ2xpcClbZzFdIDw8IDEwKQorICAgICAgICAgICAgICAgICAgICB8ICgoKHVpbnQxNl90ICopa0FkanVzdGVkQ2xpcClbYjFdIDw8IDIwKQorICAgICAgICAgICAgICAgICAgICB8ICgzIDw8IDMwKTsKKworICAgICAgICAgICAgaWYgKHVuY3JvcHBlZCkgeworICAgICAgICAgICAgICAgICgodWludDMyX3QgKilkc3RfcHRyKVsxXSA9CisgICAgICAgICAgICAgICAgICAgICAgICAoKCh1aW50MTZfdCAqKWtBZGp1c3RlZENsaXApW3IyXSkKKyAgICAgICAgICAgICAgICAgICAgICAgIHwgKCgodWludDE2X3QgKilrQWRqdXN0ZWRDbGlwKVtnMl0gPDwgMTApCisgICAgICAgICAgICAgICAgICAgICAgICB8ICgoKHVpbnQxNl90ICopa0FkanVzdGVkQ2xpcClbYjJdIDw8IDIwKQorICAgICAgICAgICAgICAgICAgICAgICAgfCAoMyA8PCAzMCk7CisgICAgICAgICAgICB9CisgICAgICAgIH07CisgICAgfQorCiAgICAgZGVmYXVsdDoKICAgICAgICAgVFJFU1BBU1MoKTsKICAgICB9CkBAIC01MTEsMTAgKzc2OCwyMiBAQAogCiBzdGF0dXNfdCBDb2xvckNvbnZlcnRlcjo6Y29udmVydFlVVjQyMFBsYW5hcigKICAgICAgICAgY29uc3QgQml0bWFwUGFyYW1zICZzcmMsIGNvbnN0IEJpdG1hcFBhcmFtcyAmZHN0KSB7CisgICAgY29uc3Qgc3RydWN0IENvZWZmcyAqbWF0cml4ID0gZ2V0TWF0cml4KCk7CisgICAgaWYgKCFtYXRyaXgpIHsKKyAgICAgICAgcmV0dXJuIEVSUk9SX1VOU1VQUE9SVEVEOworICAgIH0KKworICAgIHNpZ25lZCBfYl91ID0gbWF0cml4LT5fYl91OworICAgIHNpZ25lZCBfbmVnX2dfdSA9IC1tYXRyaXgtPl9nX3U7CisgICAgc2lnbmVkIF9uZWdfZ192ID0gLW1hdHJpeC0+X2dfdjsKKyAgICBzaWduZWQgX3JfdiA9IG1hdHJpeC0+X3JfdjsKKyAgICBzaWduZWQgX3kgPSBtYXRyaXgtPl95OworICAgIHNpZ25lZCBfYzE2ID0gbVNyY0NvbG9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eCArPSAyKSB7CisgICAgICAgICAgICBzaWduZWQgeTEsIHkyLCB1LCB2OworICAgICAgICAgICAgeTEgPSAoc3JjX3lbeF0gPj4gNikgLSBfYzE2OworICAgICAgICAgICAgeTIgPSAoc3JjX3lbeCArIDFdID4+IDYpIC0gX2MxNjsKKyAgICAgICAgICAgIHUgPSBpbnQoc3JjX3V2W3hdID4+IDYpIC0gNTEyOworICAgICAgICAgICAgdiA9IGludChzcmNfdXZbeCArIDFdID4+IDYpIC0gNTEyOworCisgICAgICAgICAgICBzaWduZWQgdV9iID0gdSAqIF9iX3U7CisgICAgICAgICAgICBzaWduZWQgdV9nID0gdSAqIF9uZWdfZ191OworICAgICAgICAgICAgc2lnbmVkIHZfZyA9IHYgKiBfbmVnX2dfdjsKKyAgICAgICAgICAgIHNpZ25lZCB2X3IgPSB2ICogX3JfdjsKKworICAgICAgICAgICAgc2lnbmVkIHRtcDEgPSB5MSAqIF95ICsgMTI4OworICAgICAgICAgICAgc2lnbmVkIGIxID0gKHRtcDEgKyB1X2IpIC8gMjU2OworICAgICAgICAgICAgc2lnbmVkIGcxID0gKHRtcDEgKyB2X2cgKyB1X2cpIC8gMjU2OworICAgICAgICAgICAgc2lnbmVkIHIxID0gKHRtcDEgKyB2X3IpIC8gMjU2OworCisgICAgICAgICAgICBzaWduZWQgdG1wMiA9IHkyICogX3kgKyAxMjg7CisgICAgICAgICAgICBzaWduZWQgYjIgPSAodG1wMiArIHVfYikgLyAyNTY7CisgICAgICAgICAgICBzaWduZWQgZzIgPSAodG1wMiArIHZfZyArIHVfZykgLyAyNTY7CisgICAgICAgICAgICBzaWduZWQgcjIgPSAodG1wMiArIHZfcikgLyAyNTY7CisKKyAgICAgICAgICAgIGJvb2wgdW5jcm9wcGVkID0geCArIDEgPCBzcmMuY3JvcFdpZHRoKCk7CisKKyAgICAgICAgICAgIHdyaXRlVG9Ec3QoZHN0X3B0ciArIHggKiBkc3QubUJwcCwgdW5jcm9wcGVkLCByMSwgZzEsIGIxLCByMiwgZzIsIGIyKTsKKyAgICAgICAgfQorCisgICAgICAgIHNyY195ICs9IHNyYy5tU3RyaWRlIC8gMjsKKworICAgICAgICBpZiAoeSAmIDEpIHsKKyAgICAgICAgICAgIHNyY191diArPSBzcmMubVN0cmlkZSAvIDI7CisgICAgICAgIH0KKworICAgICAgICBkc3RfcHRyICs9IGRzdC5tU3RyaWRlOworICAgIH0KKworICAgIHJldHVybiBPSzsKK30KKwogCiAjaWYgIVVTRV9ORU9OX1k0MTAKIApAQCAtODIxLDExICsxMTIyLDYgQEAKIAogc3RhdHVzX3QgQ29sb3JDb252ZXJ0ZXI6OmNvbnZlcnRRQ09NWVVWNDIwU2VtaVBsYW5hcigKICAgICAgICAgY29uc3QgQml0bWFwUGFyYW1zICZzcmMsIGNvbnN0IEJpdG1hcFBhcmFtcyAmZHN0KSB7Ci0gICAgdWludDhfdCAqa0FkanVzdGVkQ2xpcCA9IGluaXRDbGlwKCk7Ci0KLSAgICB1aW50MTZfdCAqZHN0X3B0ciA9ICh1aW50MTZfdCAqKWRzdC5tQml0cwotICAgICAgICArIGRzdC5tQ3JvcFRvcCAqIGRzdC5tV2lkdGggKyBkc3QubUNyb3BMZWZ0OwotCiAgICAgY29uc3QgdWludDhfdCAqc3JjX3kgPQogICAgICAgICAoY29uc3QgdWludDhfdCAqKXNyYy5tQml0cyArIHNyYy5tQ3JvcFRvcCAqIHNyYy5tV2lkdGggKyBzcmMubUNyb3BMZWZ0OwogCkBAIC04MzMsNjcgKzExMjksMjUgQEAKICAgICAgICAgKGNvbnN0IHVpbnQ4X3QgKilzcmNfeSArIHNyYy5tV2lkdGggKiBzcmMubUhlaWdodAogICAgICAgICArIHNyYy5tQ3JvcFRvcCAqIHNyYy5tV2lkdGggKyBzcmMubUNyb3BMZWZ0OwogCi0gICAgZm9yIChzaXplX3QgeSA9IDA7IHkgPCBzcmMuY3JvcEhlaWdodCgpOyArK3kpIHsKLSAgICAgICAgZm9yIChzaXplX3QgeCA9IDA7IHggPCBzcmMuY3JvcFdpZHRoKCk7IHggKz0gMikgewotICAgICAgICAgICAgc2lnbmVkIHkxID0gKHNpZ25lZClzcmNfeVt4XSAtIDE2OwotICAgICAgICAgICAgc2lnbmVkIHkyID0gKHNpZ25lZClzcmNfeVt4ICsgMV0gLSAxNjsKKyAgICAvKiBRQ09NWVVWNDIwU2VtaVBsYW5hciBpcyBOVjIxLCB3aGlsZSBNZWRpYUNvZGVjIHVzZXMgTlYxMiAqLworICAgIHJldHVybiBjb252ZXJ0WVVWNDIwU2VtaVBsYW5hckJhc2UoCisgICAgICAgICAgICBzcmMsIGRzdCwgc3JjX3ksIHNyY191LCBzcmMubVdpZHRoIC8qIHJvd19pbmMgKi8sIHRydWUgLyogaXNOVjIxICovKTsKK30KIAotICAgICAgICAgICAgc2lnbmVkIHUgPSAoc2lnbmVkKXNyY191W3ggJiB+MV0gLSAxMjg7Ci0gICAgICAgICAgICBzaWduZWQgdiA9IChzaWduZWQpc3JjX3VbKHggJiB+MSkgKyAxXSAtIDEyODsKK3N0YXR1c190IENvbG9yQ29udmVydGVyOjpjb252ZXJ0VElZVVY0MjBQYWNrZWRTZW1pUGxhbmFyKAorICAgICAgICBjb25zdCBCaXRtYXBQYXJhbXMgJnNyYywgY29uc3QgQml0bWFwUGFyYW1zICZkc3QpIHsKKyAgICBjb25zdCB1aW50OF90ICpzcmNfeSA9CisgICAgICAgIChjb25zdCB1aW50OF90ICopc3JjLm1CaXRzICsgc3JjLm1Dcm9wVG9wICogc3JjLm1XaWR0aCArIHNyYy5tQ3JvcExlZnQ7CiAKLSAgICAgICAgICAgIHNpZ25lZCB1X2IgPSB1ICogNTE3OwotICAgICAgICAgICAgc2lnbmVkIHVfZyA9IC11ICogMTAwOwotICAgICAgICAgICAgc2lnbmVkIHZfZyA9IC12ICogMjA4OwotICAgICAgICAgICAgc2lnbmVkIHZfciA9IHYgKiA0MDk7CisgICAgY29uc3QgdWludDhfdCAqc3JjX3UgPQorICAgICAgICAoY29uc3QgdWludDhfdCAqKXNyY195ICsgc3JjLm1XaWR0aCAqIChzcmMubUhlaWdodCAtIHNyYy5tQ3JvcFRvcCAvIDIpOwogCi0gICAgICAgICAgICBzaWduZWQgdG1wMSA9IHkxICogMjk4OwotICAgICAgICAgICAgc2lnbmVkIGIxID0gKHRtcDEgKyB1X2IpIC8gMjU2OwotICAgICAgICAgICAgc2lnbmVkIGcxID0gKHRtcDEgKyB2X2cgKyB1X2cpIC8gMjU2OwotICAgICAgICAgICAgc2lnbmVkIHIxID0gKHRtcDEgKyB2X3IpIC8gMjU2OwotCi0gICAgICAgICAgICBzaWduZWQgdG1wMiA9IHkyICogMjk4OwotICAgICAgICAgICAgc2lnbmVkIGIyID0gKHRtcDIgKyB1X2IpIC8gMjU2OwotICAgICAgICAgICAgc2lnbmVkIGcyID0gKHRtcDIgKyB2X2cgKyB1X2cpIC8gMjU2OwotICAgICAgICAgICAgc2lnbmVkIHIyID0gKHRtcDIgKyB2X3IpIC8gMjU2OwotCi0gICAgICAgICAgICB1aW50MzJfdCByZ2IxID0KLSAgICAgICAgICAgICAgICAoKGtBZGp1c3RlZENsaXBbYjFdID4+IDMpIDw8IDExKQotICAgICAgICAgICAgICAgIHwgKChrQWRqdXN0ZWRDbGlwW2cxXSA+PiAyKSA8PCA1KQotICAgICAgICAgICAgICAgIHwgKGtBZGp1c3RlZENsaXBbcjFdID4+IDMpOwotCi0gICAgICAgICAgICB1aW50MzJfdCByZ2IyID0KLSAgICAgICAgICAgICAgICAoKGtBZGp1c3RlZENsaXBbYjJdID4+IDMpIDw8IDExKQotICAgICAgICAgICAgICAgIHwgKChrQWRqdXN0ZWRDbGlwW2cyXSA+PiAyKSA8PCA1KQotICAgICAgICAgICAgICAgIHwgKGtBZGp1c3RlZENsaXBbcjJdID4+IDMpOwotCi0gICAgICAgICAgICBpZiAoeCArIDEgPCBzcmMuY3JvcFdpZHRoKCkpIHsKLSAgICAgICAgICAgICAgICAqKHVpbnQzMl90ICopKCZkc3RfcHRyW3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LyAyNTY7Ci0gICAgICAgICAgICBzaWduZWQgZzIgPSAodG1wMiArIHZfZyArIHVfZykgLyAyNTY7Ci0gICAgICAgICAgICBzaWduZWQgcjIgPSAodG1wMiArIHZfcikgLyAyNTY7Ci0KLSAgICAgICAgICAgIHVpbnQzMl90IHJnYjEgPQotICAgICAgICAgICAgICAgICgoa0FkanVzdGVkQ2xpcFtiMV0gPj4gMykgPDwgMTEpCi0gICAgICAgICAgICAgICAgfCAoKGtBZGp1c3RlZENsaXBbZzFdID4+IDIpIDw8IDUpCi0gICAgICAgICAgICAgICAgfCAoa0FkanVzdGVkQ2xpcFtyMV0gPj4gMyk7Ci0KLSAgICAgICAgICAgIHVpbnQzMl90IHJnYjIgPQotICAgICAgICAgICAgICAgICgoa0FkanVzdGVkQ2xpcFtiMl0gPj4gMykgPDwgMTEpCi0gICAgICAgICAgICAgICAgfCAoKGtBZGp1c3RlZENsaXBbZzJdID4+IDIpIDw8IDUpCi0gICAgICAgICAgICAgICAgfCAoa0FkanVzdGVkQ2xpcFtyMl0gPj4gMyk7Ci0KLSAgICAgICAgICAgIGlmICh4ICsgMSA8IHNyYy5jcm9wV2lkdGgoKSkgewotICAgICAgICAgICAgICAgICoodWludDMyX3QgKikoJmRzdF9wdHJbeF0pID0gKHJnYjIgPDwgMTYpIHwgcmdiMTsKLSAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgZHN0X3B0clt4XSA9IHJnYjE7Ci0gICAgICAgICAgICB9Ci0gICAgICAgIH0KLQotICAgICAgICBzcmNfeSArPSBzcmMubVN0cmlkZTsKLQotICAgICAgICBpZiAoeSAmIDEpIHsKLSAgICAgICAgICAgIHNyY191ICs9IHNyYy5tU3RyaWRlOwotICAgICAgICB9Ci0KLSAgICAgICAgZHN0X3B0ciA9ICh1aW50MTZfdCopKCh1aW50OF90Kilkc3RfcHRyICsgZHN0Lm1TdHJpZGUpOwotICAgIH0KLQotICAgIHJldHVybiBPSzsKKyAgICByZXR1c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AgICB1aW50MTZfdCAqZHN0X3B0ciA9ICh1aW50MTZfdCAqKWRzdC5tQml0cwotICAgICAgICArIGRzdC5tQ3JvcFRvcCAqIGRzdC5tV2lkdGggKyBkc3QubUNyb3BMZWZ0OwotCi0gICAgY29uc3QgdWludDhfdCAqc3JjX3kgPQotICAgICAgICAoY29uc3QgdWludDhfdCAqKXNyYy5tQml0cyArIHNyYy5tQ3JvcFRvcCAqIHNyYy5tV2lkdGggKyBzcmMubUNyb3BMZWZ0OwotCi0gICAgY29uc3QgdWludDhfdCAqc3JjX3UgPQotICAgICAgICAoY29uc3QgdWludDhfdCAqKXNyY195ICsgc3JjLm1XaWR0aCAqIChzcmMubUhlaWdodCAtIHNyYy5tQ3JvcFRvcCAvIDIpOworICAgIHVpbnQxNl90ICpkc3RfcHRyID0gKHVpbnQxNl90ICopKCh1aW50OF90ICopCisgICAgICAgICAgICBkc3QubUJpdHMgKyBkc3QubUNyb3BUb3AgKiBkc3QubVN0cmlkZSArIGRzdC5tQ3JvcExlZnQgKiBkc3QubUJwcCk7CiAKICAgICBmb3IgKHNpemVfdCB5ID0gMDsgeSA8IHNyYy5jcm9wSGVpZ2h0KCk7ICsreSkgewogICAgICAgICBmb3IgKHNpemVfdCB4ID0gMDsgeCA8IHNyYy5jcm9wV2lkdGgoKTsgeCArPSAyKSB7Ci0gICAgICAgICAgICBzaWduZWQgeTEgPSAoc2lnbmVkKXNyY195W3hdIC0gMTY7Ci0gICAgICAgICAgICBzaWduZWQgeTIgPSAoc2lnbmVkKXNyY195W3ggKyAxXSAtIDE2OworICAgICAgICAgICAgc2lnbmVkIHkxID0gKHNpZ25lZClzcmNfeVt4XSAtIF9jMTY7CisgICAgICAgICAgICBzaWduZWQgeTIgPSAoc2lnbmVkKXNyY195W3ggKyAxXSAtIF9jMTY7CiAKLSAgICAgICAgICAgIHNpZ25lZCB1ID0gKHNpZ25lZClzcmNfdVt4ICYgfjFdIC0gMTI4OwotICAgICAgICAgICAgc2lnbmVkIHYgPSAoc2lnbmVkKXNyY191Wyh4ICYgfjEpICsgMV0gLSAxMjg7CisgICAgICAgICAgICBzaWduZWQgdSA9IChzaWduZWQpc3JjX3VbKHggJiB+MSkgKyBpc05WMjFdIC0gMTI4OworICAgICAgICAgICAgc2lnbmVkIHYgPSAoc2lnbmVkKXNyY191Wyh4ICYgfjEpICsgIWlzTlYyMV0gLSAxMjg7CiAKLSAgICAgICAgICAgIHNpZ25lZCB1X2IgPSB1ICogNTE3OwotICAgICAgICAgICAgc2lnbmVkIHVfZyA9IC11ICogMTAwOwotICAgICAgICAgICAgc2lnbmVkIHZfZyA9IC12ICogMjA4OwotICAgICAgICAgICAgc2lnbmVkIHZfciA9IHYgKiA0MDk7CisgICAgICAgICAgICBzaWduZWQgdV9iID0gdSAqIF9iX3U7CisgICAgICAgICAgICBzaWduZWQgdV9nID0gdSAqIF9uZWdfZ191OworICAgICAgICAgICAgc2lnbmVkIHZfZyA9IHYgKiBfbmVnX2dfdjsKKyAgICAgICAgICAgIHNpZ25lZCB2X3IgPSB2ICogX3JfdjsKIAotICAgICAgICAgICAgc2lnbmVkIHRtcDEgPSB5MSAqIDI5ODsKKyAgICAgICAgICAgIHNpZ25lZCB0bXAxID0geTEgKiBfeSArIDEyODsKICAgICAgICAgICAgIHNpZ25lZCBiMSA9ICh0bXAxICsgdV9iKSAvIDI1NjsKICAgICAgICAgICAgIHNpZ25lZCBnMSA9ICh0bXAxICsgdl9nICsgdV9nKSAvIDI1NjsKICAgICAgICAgICAgIHNpZ25lZCByMSA9ICh0bXAxICsgdl9yKSAvIDI1NjsKIAotICAgICAgICAgICAgc2lnbmVkIHRtcDIgPSB5MiAqIDI5ODsKKyAgICAgICAgICAgIHNpZ25lZCB0bXAyID0geTIgKiBfeSArIDEyODsKICAgICAgICAgICAgIHNpZ25lZCBiMiA9ICh0bXAyICsgdV9iKSAvIDI1NjsKICAgICAgICAgICAgIHNpZ25lZCBnMiA9ICh0bXAyICsgdl9nICsgdV9nKSAvIDI1NjsKICAgICAgICAgICAgIHNpZ25lZCByMiA9ICh0bXAyICsgdl9yKSAvIDI1NjsKQEAgLTEwMDYsMzEgKzEyMTksNDAgQEAKICAgICAgICAgICAgIH0KICAgICAgICAgfQogCi0gICAgICAgIHNyY195ICs9IHNyYy5tV2lkdGg7CisgICAgICAgIHNyY195ICs9IHJvd19pbmM7CiAKICAgICAgICAgaWYgKHkgJiAxKSB7Ci0gICAgICAgICAgICBzcmNfdSArPSBzcmMubVdpZHRoOworICAgICAgICAgICAgc3JjX3UgKz0gcm93X2luYzsKICAgICAgICAgfQogCi0gICAgICAgIGRzdF9wdHIgKz0gZHN0Lm1XaWR0aDsKKyAgICAgICAgZHN0X3B0ciA9ICh1aW50MTZfdCopKCh1aW50OF90Kilkc3RfcHRyICsgZHN0Lm1TdHJpZGUpOwogICAgIH0KIAogICAgIHJldHVybiBPSzsKIH0KIAogdWludDhfdCAqQ29sb3JDb252ZXJ0ZXI6OmluaXRDbGlwKCkgewotICAgIHN0YXRpYyBjb25zdCBzaWduZWQga0NsaXBNaW4gPSAtMjc4OwotICAgIHN0YXRpYyBjb25zdCBzaWduZWQga0NsaXBNYXggPSA1MzU7Ci0KICAgICBpZiAobUNsaXAgPT0gTlVMTCkgewotICAgICAgICBtQ2xpcCA9IG5ldyB1aW50OF90W2tDbGlwTWF4IC0ga0NsaXBNaW4gKyAxXTsKKyAgICAgICAgbUNsaXAgPSBuZXcgdWludDhfdFtDTElQX1JBTkdFX01BWF84QklUIC0gQ0xJUF9SQU5HRV9NSU5fOEJJVCArIDFdOwogCi0gICAgICAgIGZvciAoc2lnbmVkIGkgPSBrQ2xpcE1pbjsgaSA8PSBrQ2xpcE1heDsgKytpKSB7Ci0gICAgICAgICAgICBtQ2xpcFtpIC0ga0NsaXBNaW5dID0gKGkgPCAwKSA/IDAgOiAoaSA+IDI1NSkgPyAyNTUgOiAodWludDhfdClpOworICAgICAgICBmb3IgKHNpZ25lZCBpID0gQ0xJUF9SQU5HRV9NSU5fOE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KIHN0YXR1c190IE1ldGFEYXRhQmFzZTo6d3JpdGVUb1BhcmNlbChQYXJjZWwgJnBhcmNlbCkgewogICAgIHN0YXR1c190IHJldDsKICAgICBzaXplX3QgbnVtSXRlbXMgPSBtSW50ZXJuYWxEYXRhLT5tSXRlbXMuc2l6ZSgpOwpAQCAtNTIxLDkgKzUyMSw2NCBAQAogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBzZXREYXRhKGtleSwgdHlwZSwgYmxvYi5kYXRhKCksIHNpemUpOwogICAgICAgICAgICAgICAgIGJsb2IucmVsZWFzZSgpOworICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlID09IFRZUEVfQ19TVFJJTkcpIHsKKyAgICAgICAgICAgICAgICAvLyBjb3B5IGRhdGEgZGlyZWN0bHkgZnJvbSBQYXJjZWwgc3RvcmFnZSwgdGhlbiBhZHZhbmNlIHBvc2l0aW9uCisgICAgICAgICAgICAgICAgLy8gTkI6IHJlYWRJbnBsYWNlKCkgYnVtcHMgcG9zaXRpb24sIGl0IGlzIE5PVCBpZGVtcG90ZW50LgorICAgICAgICAgICAgICAgIGNvbnN0IHZvaWQgKnNyYyA9IHBhcmNlbC5yZWFkSW5wbGFjZShzaXplKTsKKyAgICAgICAgICAgICAgICBjaGFyICpzdHIgPSAoY2hhciAqKSBzcmM7CisgICAgICAgICAgICAgICAgaWYgKHNyYyA9PSBudWxscHRyIHx8IHNpemUgPT0gMCB8fCBzdHJbc2l6ZS0xXSAhPSAnXDAnKSB7CisgICAgICAgICAgICAgICAgICAgIGNoYXIgY2NLZXlbNV07CisgICAgICAgICAgICAgICAgICAgIE1ha2VGb3VyQ0NTdHJpbmcoa2V5LCBjY0tleSk7CisgICAgICAgICAgICAgICAgICAgIGlmIChzcmMgPT0gbnVsbHB0cikgeworICAgICAgICAgICAgICAgICAgICAgICAgQUxPR1coImlnbm9yaW5nIGtleSAnJXMnIHN0cmluZyB3aXRoIG5vIGRhdGEgKGV4cGVjdGVkICVkKSIsIGNjS2V5LCBzaXplKTsKKyAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIEFMT0dXKCJpZ25vcmluZyBrZXkgJyVzJzogdW50ZXJtaW5hdGVkIHN0cmluZyBvZiAlZCBieXRlcyIsIGNjS2V5LCBzaXplKTsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgIHNldERhdGEoa2V5LCB0eXBlLCBzcmMsIHNpemUpOworICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgLy8gY29weSBkYXRhIGRpcmVjdGx5IGZyb20gUGFyY2VsIHN0b3JhZ2UsIHRoZW4gYWR2YW5jZSBwb3NpdGlvbgotICAgICAgICAgICAgICAgIHNldERhdGEoa2V5LCB0eXBlLCBwYXJjZWwucmVhZElucGxhY2Uoc2l6ZSksIHNpemUpOworICAgICAgICAgICAgICAgIC8vIHZlcmlmeSB0aGF0IHRoZSByZWNlaXZlZCBzaXplIGlzIGVub3VnaAorICAgICAgICAgICAgICAgIHVpbnQzMl90IG5lZWRlZCA9IDA7CisgICAgICAgICAgICAgICAgc3dpdGNoICh0eXBlKSB7CisgICAgICAgICAgICAgICAgICAgIGNhc2UgVFlQRV9JTlQzMjoKKyAgICAgICAgICAgICAgICAgICAgICAgIG5lZWRlZCA9IHNpemVvZihpbnQzMl90KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICBjYXNlIFRZUEVfSU5UNjQ6CisgICAgICAgICAgICAgICAgICAgICAgICBuZWVkZWQgPSBzaXplb2YoaW50NjRfdCk7CisgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgY2FzZSBUWVBFX0ZMT0FUOgorICAgICAgICAgICAgICAgICAgICAgICAgbmVlZGVkID0gc2l6ZW9mKGZsb2F0KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICBjYXNlIFRZUEVfUE9JTlRFUjoKKyAgICAgICAgICAgICAgICAgICAgICAgIC8vIE5COiB0aGlzIHJlamVjdHMgcGFzc2luZyBiZXR3ZWVuIDMyLWJpdCBhbmQgNjQtYml0IHNwYWNlLgorICAgICAgICAgICAgICAgICAgICAgICAgbmVlZGVkID0gc2l6ZW9mKHZvaWQqKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICBjYXNlIFRZUEVfUkVDVDoKKyAgICAgICAgICAgICAgICAgICAgICAgIG5lZWRlZCA9IHNpemVvZihSZWN0KTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgICAgICAgICAgLy8gbm9uLXN0YW5kYXJkIGVudGl0aWVzIGNhbiBiZSBhbnkgc2l6ZSA+PSAwCisgICAgICAgICAgICAgICAgICAgICAgICBuZWVkZWQgPSAwOworICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGNvbnN0IHZvaWQgKnNyYyA9IHBhcmNlbC5yZWFkSW5wbGFjZShzaXplKTsKKyAgICAgICAgICAgICAgICBpZiAoc3JjID09IG51bGxwdHIgfHwgKG5lZWRlZCAhPSAwICYmIHNpemUgIT0gbmVlZGVkKSkgeworICAgICAgICAgICAgICAgICAgICBjaGFyIGNjS2V5WzVdOworICAgICAgICAgICAgICAgICAgICBNYWtlRm91ckNDU3RyaW5nKGtleSwgY2NLZXkpOworICAgICAgICAgICAgICAgICAgICBjaGFyIGNjVHlwZVs1XTsKKyAgICAgICAgICAgICAgICAgICAgTWFrZUZvdXJDQ1N0cmluZyh0eXBlLCBjY1R5cGUpOworICAgICAgICAgICAgICAgICAgICBpZiAoc3JjID09IG51bGxwdHIpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIEFMT0dXKCJpZ25vcmluZyBrZXkgJyVzJyB0eXBlICclcycgbWlzc2luZyBkYXRhIChleHBlY3RlZCAlZCkiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2NLZXksIGNjVHlwZSwgc2l6ZSk7CisgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgICAgICBBTE9HVygiaWdub3Jpbmcga2V5ICclcyc6IHR5cGUgJyVzJyBieXRlczogZXhwZWN0ZWQgJWQgIT0gJWQgcmVjZWl2ZWQiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNjS2V5LCBjY1R5cGUsIG5lZWRlZCwgc2l6ZSk7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICBzZXREYXRhKGtleSwgdHlwZSwgc3JjLCBzaXplKTsKKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAgICAgICAgICB9CiAKQEAgLTUzMiw3ICs1ODcsNyBAQAogICAgIEFMT0dXKCJubyBtZXRhZGF0YSBpbiBwYXJjZWwiKTsKICAgICByZXR1cm4gVU5LTk9XTl9FUlJPUjsKIH0KLSNlbmRpZiAvLyAhZGVmaW5lZChfX0FORFJPSURfVk5ES19fKSAmJiAhZGVmaW5lZChfX0FORFJPSURfQVBFWF9fKQorI2VuZGlmIC8vIGRlZmluZWQoX19BTkRST0lEX18pICYmICFkZWZpbmVkKF9fQU5EUk9JRF9WTkRLX18pICYmICFkZWZpbmVkKF9fQU5EUk9JRF9BUEVYX18pCiAKIH0gIC8vIG5hbWVzcGFjZSBhbmRyb2lkCiAKZGlmZiAtLWdpdCBhL21lZGlhL2xpYnN0YWdlZnJpZ2h0L2ZvdW5kYXRpb24vaW5jbHVkZS9tZWRpYS9zdGFnZWZyaWdodC9mb3VuZGF0aW9uL0FIYW5kbG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U1haW4xMDogICAgICAgICAgcmV0dXJuICJNYWluMTAiOwogICAgICAgICBjYXNlIEFWMVByb2ZpbGVNYWluMTBIRFIxMDogICAgIHJldHVybiAiTWFpbjEwSERSMTAiOwogICAgICAgICBjYXNlIEFWMVByb2ZpbGVNYWluMTBIRFIxMFBsdXM6IHJldHVybiAiTWFpbjEwSERSUGx1cyI7CiAgICAgICAgIGRlZmF1bHQ6ICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZjsKQEAgLTU0MCw2ICs1NDAsOSBAQAogY29uc3RleHByIGludDMyX3QgRG9sYnlWaXNpb25MZXZlbFVoZDMwICAgPSAweDQwOwogY29uc3RleHByIGludDMyX3QgRG9sYnlWaXNpb25MZXZlbFVoZDQ4ICAgPSAweDgwOwogY29uc3RleHByIGludDMyX3QgRG9sYnlWaXNpb25MZXZlbFVoZDYwICAgPSAweDEwMDsKK2NvbnN0ZXhwciBpbnQzMl90IERvbGJ5VmlzaW9uTGV2ZWxVaGQxMjAgID0gMHgyMDA7Citjb25zdGV4cHIgaW50MzJfdCBEb2xieVZpc2lvbkxldmVsOGszMCAgICA9IDB4NDAwOworY29uc3RleHByIGludDMyX3QgRG9sYnlWaXNpb25MZXZlbDhrNjAgICAgPSAweDgwMDsKIAogaW5saW5lIHN0YXRpYyBjb25zdCBjaGFyICphc1N0cmluZ19Eb2xieVZpc2lvbkxldmVsKGludDMyX3QgaSwgY29uc3QgY2hhciAqZGVmID0gIj8/IikgewogICAgIHN3aXRjaCAoaSkgewpAQCAtNTUyLDYgKzU1NSw5IEBACiAgICAgICAgIGNhc2UgRG9sYnlWaXNpb25MZXZlbFVoZDMwOiByZXR1cm4gIlVoZDMwIjsKICAgICAgICAgY2FzZSBEb2xieVZpc2lvbkxldmVsVWhkNDg6IHJldHVybiAiVWhkNDgiOwogICAgICAgICBjYXNlIERvbGJ5VmlzaW9uTGV2ZWxVaGQ2MDogcmV0dXJuICJVaGQ2MCI7CisgICAgICAgIGNhc2UgRG9s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IHZvaWQgT01YU3RvcmU6OmFkZFBsdWdpbihPTVhQbHVnaW5CYXNlICpwbHVnaW4pIHsKICAgICBNdXRleDo6QXV0b2xvY2sgYXV0b0xvY2sobUxvY2spOwogCisgICAgYm9vbCB0eXBlVFYgPSBpc1RWKCk7CisgICAgaW50IGZpcnN0QXBpTGV2ZWwgPSBnZXRGaXJzdEFwaUxldmVsKCk7CisKICAgICBPTVhfVTMyIGluZGV4ID0gMDsKIAogICAgIGNoYXIgbmFtZVsxMjhdOwpAQCAtMTEwLDYgKzEzOCwzMiBAQAogICAgICAgICAgICAgICAgICAgICBuYW1lLCBzaXplb2YobmFtZSksIGluZGV4KyspKSA9PSBPTVhfRXJyb3JOb25lKSB7CiAgICAgICAgIFN0cmluZzggbmFtZTgobmFtZSk7CiAKKyAgICAgICAgVmVjdG9yPFN0cmluZzg+IHJvbGVzOworICAgICAgICBPTVhfRVJST1JUWVBFIGVyciA9IHBsdWdpbi0+Z2V0Um9sZXNPZkNvbXBvbmVudChuYW1lLCAmcm9sZXMpOworICAgICAgICBpZiAoZXJyID09IE9NWF9FcnJvck5vbmUpIHsKKyAgICAgICAgICAgIGJvb2wgc2tpcCA9IGZhbHNlOworICAgICAgICAgICAgZm9yIChTdHJpbmc4IHJvbGUgOiByb2xlcykgeworICAgICAgICAgICAgICAgIGlmIChyb2xlLmZpbmQoInZpZGVvX2RlY29kZXIiKSAhPSAtMSB8fCByb2xlLmZpbmQoInZpZGVvX2VuY29kZXIiKSAhPSAtMSkgeworICAgICAgICAgICAgICAgICAgICBpZiAoZmlyc3RBcGlMZXZlbCA+PSBfX0FORFJPSURfQVBJX1RfXykgeworICAgICAgICAgICAgICAgICAgICAgICAgc2tpcCA9IHRydWU7CisgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICghdHlwZVRWICYmIGZpcnN0QXBpTGV2ZWwgPj0gX19BTkRST0lEX0FQSV9TX18pIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHNraXAgPSB0cnVlOworICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgaWYgKHJvbGUuZmluZCgiYXVkaW9fZGVjb2RlciIpICE9IC0xIHx8IHJvbGUuZmluZCgiYXVkaW9fZW5jb2RlciIpICE9IC0xKSB7CisgICAgICAgICAgICAgICAgICAgIGlmIChmaXJzdEFwaUxldmVsID49IF9fQU5EUk9JRF9BUElfVF9fKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBza2lwID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorICAgICAgICAgICAgaWYgKHNraXApIHsKKyAgICAgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorCiAgICAgICAgIGlmIChtUGx1Z2luQnlDb21wb25lbnROYW1lLmluZGV4T2ZLZXkobmFtZTgpID49IDApIHsKICAgICAgICAgICAgIEFMT0dFKCJBIGNvbXBvbmVudCBvZiBuYW1lICclcycgYWxyZWFkeSBleGlzdHMsIGlnbm9yaW5nIHRoaXMgb25lLiIsCiAgICAgICAgICAgICAgICAgIG5hbWU4LnN0cmluZygpKTsKZGlmZiAtLWdpdCBhL21lZGlhL2xpYnN0YWdlZnJpZ2h0L29teC90ZXN0cy9BbmRyb2lkLmJwIGIvbWVkaWEvbGlic3RhZ2VmcmlnaHQvb214L3Rlc3RzL0FuZHJvaWQuYnAKaW5kZXggODNjYzgwZS4uMTU5ZmQxOSAxMDA2NDQKLS0tIGEvbWVkaWEvbGlic3RhZ2VmcmlnaHQvb214L3Rlc3RzL0FuZHJvaWQuYnAKKysrIGIvbWVkaWEvbGlic3RhZ2VmcmlnaHQvb214L3Rlc3RzL0FuZHJvaWQuYnAKQEAg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AogI2luY2x1ZGUgPG1lZGlhL3N0YWdlZnJpZ2h0L2ZvdW5kYXRpb24vQUJ1ZmZlci5oPgogI2luY2x1ZGUgPG1lZGlhL3N0YWdlZnJpZ2h0L2ZvdW5kYXRpb24vQURlYnVnLmg+CkBAIC00MSw2ICs0MiwxMCBAQAogICAgIHJldHVybiBkYXRhWzBdIDw8IDggfCBkYXRhWzFdOwogfQogCitzdGF0aWMgdWludDMyX3QgdTI0YXQoY29uc3QgdWludDhfdCAqZGF0YSkgeworICAgIHJldHVybiB1MTZhdChkYXRhKSA8PCAxNiB8IGRhdGFbMl07Cit9CisKIHN0YXRpYyB1aW50MzJfdCB1MzJhdChjb25zdCB1aW50OF90ICpkYXRhKSB7CiAgICAgcmV0dXJuIHUxNmF0KGRhdGEpIDw8IDE2IHwgdTE2YXQoJmRhdGFbMl0pOwogfQpAQCAtODc3LDExICs4ODIsMTUgQEAKICAgICAgICAgc3dpdGNoIChkYXRhWzFdKSB7CiAgICAgICAgICAgICBjYXNlIDIwMDoKICAgICAgICAgICAgIHsKLSAgICAgICAgICAgICAgICBwYXJzZVNSKHMsIGRhdGEsIGhlYWRlckxlbmd0aCk7CisgICAgICAgICAgICAgICAgcGFyc2VTZW5kZXJSZXBvcnQocywgZGF0YSwgaGVhZGVyTGVuZ3RoKTsKICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgY2FzZSAyMDE6ICAvLyBSUgorICAgICAgICAgICAgeworICAgICAgICAgICAgICAgIHBhcnNlUmVjZWl2ZXJSZXBvcnQocywgZGF0YSwgaGVhZGVyTGVuZ3RoKTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIH0KICAgICAgICAgICAgIGNhc2UgMjAyOiAgLy8gU0RFUwogICAgICAgICAgICAgY2FzZSAyMDQ6ICAvLyBBUFAKICAgICAgICAgICAgICAgICBicmVhazsKQEAgLTk0MCwxOCArOTQ5LDQ0IEBACiAgICAgcmV0dX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BHZXRBdHRyaWJ1dGUoY29uc3QgY2hhciAqcywgY29uc3QgY2hhciAqa2V5LCBBU3RyaW5nICp2YWx1ZSkgewotICAgIHZhbHVlLT5jbGVhcigpOwotCi0gICAgc2l6ZV90IGtleUxlbiA9IHN0cmxlbihrZXkpOwotCi0gICAgZm9yICg7OykgewotICAgICAgICBjb25zdCBjaGFyICpjb2xvblBvcyA9IHN0cmNocihzLCAnOycpOwotCi0gICAgICAgIHNpemVfdCBsZW4gPQotICAgICAgICAgICAgKGNvbG9uUG9zID09IE5VTEwpID8gc3RybGVuKHMpIDogY29sb25Qb3MgLSBzOwotCi0gICAgICAgIGlmIChsZW4gPj0ga2V5TGVuICsgMSAmJiBzW2tleUxlbl0gPT0gJz0nICYmICFzdHJuY21wKHMsIGtleSwga2V5TGVuKSkgewotICAgICAgICAgICAgdmFsdWUtPnNldFRvKCZzW2tleUxlbiArIDFdLCBsZW4gLSBrZXlMZW4gLSAxKTsKLSAgICAgICAgICAgIHJldHVybiB0cnVlOwotICAgICAgICB9Ci0KLSAgICAgICAgaWYgKGNvbG9uUG9zID09IE5VTEwpIHsKLSAgICAgICAgICAgIHJldHVybiBmYWxzZTsKLSAgICAgICAgfQotCi0gICAgICAgIHMgPSBjb2xvblBvcyArIDE7Ci0gICAgfQotfQotCi1zdHJ1Y3QgTXlUcmFuc21pdHRlciA6IHB1YmxpYyBBSGFuZGxlciB7Ci0gICAgTXlUcmFuc21pdHRlcihjb25zdCBjaGFyICp1cmwsIGNvbnN0IHNwPEFMb29wZXI+ICZsb29wZXIpCi0gICAgICAgIDogbVNlcnZlclVSTCh1cmwpLAotICAgICAgICAgIG1Mb29wZXIobG9vcGVyKSwKLSAgICAgICAgICBtQ29ubihuZXcgQVJUU1BDb25uZWN0aW9uKSwKLSAgICAgICAgICBtQ29ubmVjdGVkKGZhbHNlKSwKLSAgICAgICAgICBtQXV0aFR5cGUoTk9ORSksCi0gICAgICAgICAgbVJUUFNvY2tldCgtMSksCi0gICAgICAgIC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XZhbCB0djsKLSAgICAgICAgZ2V0dGltZW9mZGF5KCZ0diwgTlVMTCk7Ci0KLSAgICAgICAgdWludDY0X3Qgbm93VXMgPSB0di50dl9zZWMgKiAxMDAwMDAwbGwgKyB0di50dl91c2VjOwotCi0gICAgICAgIG5vd1VzICs9ICgoNzBsbCAqIDM2NSArIDE3KSAqIDI0KSAqIDYwICogNjAgKiAxMDAwMDAwbGw7Ci0KLSAgICAgICAgdWludDY0X3QgaGkgPSBub3dVcyAvIDEwMDAwMDBsbDsKLSAgICAgICAgdWludDY0X3QgbG8gPSAoKDFsbCA8PCAzMikgKiAobm93VXMgJSAxMDAwMDAwbGwpKSAvIDEwMDAwMDBsbDsKLQotICAgICAgICByZXR1cm4gKGhpIDw8IDMyKSB8IGxvOwotICAgIH0KLQotICAgIHZvaWQgaXNzdWVBbm5vdW5jZSgpIHsKLSAgICAgICAgQVN0cmluZyBzZHA7Ci0gICAgICAgIHNkcCA9ICJ2PTBcclxuIjsKLQotICAgICAgICBzZHAuYXBwZW5kKCJvPS0gIik7Ci0KLSAgICAgICAgdWludDY0X3QgbnRwID0gbnRwVGltZSgpOwotICAgICAgICBzZHAuYXBwZW5kKG50cCk7Ci0gICAgICAgIHNkcC5hcHBlbmQoIiAiKTsKLSAgICAgICAgc2RwLmFwcGVuZChudHApOwotICAgICAgICBzZHAuYXBwZW5kKCIgSU4gSVA0IDEyNy4wLjAuMFxyXG4iKTsKLQotICAgICAgICBzZHAuYXBwZW5kKAotICAgICAgICAgICAgICAicz1TYW1wbGVcclxuIgotICAgICAgICAgICAgICAiaT1QbGF5aW5nIGFyb3VuZCB3aXRoIEFOTk9VTkNFXHJcbiIKLSAgICAgICAgICAgICAgImM9SU4gSVA0ICIpOwotCi0gICAgICAgIHN0cnVjdCBpbl9hZGRyIGFkZHI7Ci0gICAgICAgIGFkZHIuc19hZGRyID0gaHRvbmwobVNlcnZlcklQKTsKLQotICAgICAgICBzZHAuYXBwZW5kKGluZXRfbnRvYShhZGRyK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kKCJcclxuIik7Ci0KLSAgICAgICAgcmVxdWVzdC5hcHBlbmQoIlxyXG4iKTsKLSAgICAgICAgcmVxdWVzdC5hcHBlbmQoc2RwKTsKLQotICAgICAgICBzcDxBTWVzc2FnZT4gcmVwbHkgPSBuZXcgQU1lc3NhZ2UoJ2Fubm8nLCB0aGlzKTsKLSAgICAgICAgbUNvbm4tPnNlbmRSZXF1ZXN0KHJlcXVlc3QuY19zdHIoKSwgcmVwbHkpOwotICAgIH0KLQotICAgIHZvaWQgSChjb25zdCBBU3RyaW5nICZzLCBBU3RyaW5nICpvdXQpIHsKLSAgICAgICAgb3V0LT5jbGVhcigpOwotCi0gICAgICAgIE1ENV9DVFggbTsKLSAgICAgICAgTUQ1X0luaXQoJm0pOwotICAgICAgICBNRDVfVXBkYXRlKCZtLCBzLmNfc3RyKCksIHMuc2l6ZSgpKTsKLQotICAgICAgICB1aW50OF90IGtleVsxNl07Ci0gICAgICAgIE1ENV9GaW5hbChrZXksICZtKTsKLQotICAgICAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IDE2OyArK2kpIHsKLSAgICAgICAgICAgIGNoYXIgbmliYmxlID0ga2V5W2ldID4+IDQ7Ci0gICAgICAgICAgICBpZiAobmliYmxlIDw9IDkpIHsKLSAgICAgICAgICAgICAgICBuaWJibGUgKz0gJzAnOwotICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICBuaWJibGUgKz0gJ2EnIC0gMTA7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBvdXQtPmFwcGVuZCgmbmliYmxlLCAxKTsKLQotICAgICAgICAgICAgbmliYmxlID0ga2V5W2ldICYgMHgwZjsKLSAgICAgICAgICAgIGlmIChuaWJibGUgPD0gOSkgewotICAgICAgICAgICAgICAgIG5pYmJsZSArPSAnMCc7Ci0gICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIG5pYmJsZSArPSAnYScgLSAxMDsKLSAgICAgICAgICAgIH0KLSAgIC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PCAiKSI7Ci0KLSAgICAgICAgICAgICAgICBpZiAocmVzdWx0ICE9IE9LKSB7Ci0gICAgICAgICAgICAgICAgICAgIChuZXcgQU1lc3NhZ2UoJ3F1aXQnLCB0aGlzKSktPnBvc3QoKTsKLSAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgfQotCi0gICAgICAgICAgICAgICAgbUNvbm5lY3RlZCA9IHRydWU7Ci0KLSAgICAgICAgICAgICAgICBDSEVDSyhtc2ctPmZpbmRJbnQzMigic2VydmVyLWlwIiwgKGludDMyX3QgKikmbVNlcnZlcklQKSk7Ci0KLSAgICAgICAgICAgICAgICBpc3N1ZUFubm91bmNlKCk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgIGNhc2UgJ2Fubm8nOgotICAgICAgICAgICAgewotICAgICAgICAgICAgICAgIGludDMyX3QgcmVzdWx0OwotICAgICAgICAgICAgICAgIENIRUNLKG1zZy0+ZmluZEludDMyKCJyZXN1bHQiLCAmcmVzdWx0KSk7Ci0KLSAgICAgICAgICAgICAgICBMT0coSU5GTykgPDwgIkFOTk9VTkNFIGNvbXBsZXRlZCB3aXRoIHJlc3VsdCAiCi0gICAgICAgICAgICAgICAgICAgICA8PCByZXN1bHQgPDwgIiAoIiA8PCBzdHJlcnJvcigtcmVzdWx0KSA8PCAiKSI7Ci0KLSAgICAgICAgICAgICAgICBzcDxSZWZCYXNlPiBvYmo7Ci0gICAgICAgICAgICAgICAgQ0hFQ0sobXNnLT5maW5kT2JqZWN0KCJyZXNwb25zZSIsICZvYmopKTsKLSAgICAgICAgICAgICAgICBzcDxBUlRTUFJlc3BvbnNlPiByZXNwb25zZTsKLQotICAgICAgICAgICAgICAgIGlmIChyZXN1bHQgPT0gT0spIHsKLSAgICAgICAgICAgICAgICAgICAgcmVzcG9uc2UgPSBzdGF0aWNfY2FzdDxBUlRTUFJlc3BvbnNlICo+KG9iai5nZXQoKSk7Ci0gICAgICAgICAgICAgICAgICAgIENIRUNLKHJlc3BvbnNlICE9IE5VTEwpOwotCi0gICAgICAgICAgICAgICAgICAgIGlmIChyZXNwb25zZS0+bVN0YXR1c0NvZGUgPT0gNDAxKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBpZiAobUF1dGhUeXBlICE9IE5PTkUpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBMT0coSU5GTykgPDwgIkZBSUxFRCB0byBhdXRoZW50aWNhdGUiOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIChuZXcgQU1lc3NhZ2UoJ3F1aXQnLCB0aGlzKSktPnBvc3QoKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgICAgICAgICAgICAgYXV0aGVudGljYXRlKHJlc3BvbnNlKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgfQotCi0gICAgICAgICAgICAgICAgaWYgKHJlc3VsdCAhPSBPSyB8fCByZXNwb25zZS0+bVN0YXR1c0NvZGUgIT0gMjAwKSB7Ci0gICAgICAgICAgICAgICAgICAgIChuZXcgQU1lc3NhZ2UoJ3F1aXQnLCB0aGlzKSktPnBvc3QoKTsKLSAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgfQotCi0gICAgICAgICAgICAgICAgdW5zaWduZWQgcnRwUG9ydDsKLSAgICAgICAgICAgICAgICBBUlRQQ29ubmVjdGlvbjo6TWFrZVBvcnRQYWlyKCZtUlRQU29ja2V0LCAmbVJUQ1BTb2NrZXQsICZydHBQb3J0KTsKLQotICAgICAgICAgICAgICAgIC8vIChuZXcgQU1lc3NhZ2UoJ3BvbGwnLCB0aGlzKSktPnBvc3QoKTsKLQotICAgICAgICAgICAgICAgIEFTdHJpbmcgcmVxdWVzdDsKLSAgICAgICAgICAgICAgICByZXF1ZXN0LmFwcGVuZCgiU0VUVVAgIik7Ci0gICAgICAgICAgICAgICAgcmVxdWVzdC5hcHBlbmQobVRyYWNrVVJMKTsKLSAgICAgICAgICAgICAgICByZXF1ZXN0LmFwcGVuZCgiIFJUU1AvMS4wXHJcbiIpOwotCi0gICAgICAgICAgICAgICAgYWRkQXV0aGVudGljYXRpb24oJnJlcXVlc3QsICJTRVRVUCIsIG1UcmFja1VSTC5jX3N0cigpKTsKLQotICAgICAgICAgICAgICAgIHJlcXVlc3QuYXBwZW5kKCJUcmFuc3BvcnQ6IFJUUC9BVlA7dW5pY2FzdDtjbGllbnRfcG9ydD0iKTsKLSAgICAgICAgICAgICAgICByZXF1ZXN0LmFwcGVuZChydHBQb3J0KTsKLSAgICAgICAgICAgICAgICByZXF1ZXN0LmFwcGVuZCgiLSIpOwotICAgICAgICAgICAgICAgIHJlcXVlc3QuYXBwZW5kKHJ0cFBvcnQgKyAxKTsKLSAgICAgICAgICAgICAgICByZXF1ZXN0LmFwcGVuZCgiO21vZGU9cmVjb3JkXHJcbiIpOwotICAgICAgICAgICAgICAgIHJlcXVlc3QuYXBwZW5kKCJcclxuIik7Ci0KLSAgICAgICAgICAgICAgICBzcDxBTWVzc2FnZT4gcmVwbHkgPSBuZXcgQU1lc3NhZ2UoJ3NldHUnLCB0aGlzKTsKLSAgICAgICAgICAgICAgICBtQ29ubi0+c2VuZFJlcXVlc3QocmVxdWVzdC5jX3N0cigpLCByZXBseSk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICB9Ci0KLSNpZiAwCi0gICAgICAgICAgICBjYXNlICdwb2xsJzoKLSAgICAgICAgICAgIHsKLSAgICAgICAgICAgICAgICBmZF9zZXQgcnM7Ci0gICAgICAgICAgICAgICAgRkRfWkVSTygmcnMpOwotICAgICAgICAgICAgICAgIEZEX1NFVChtUlRDUFNvY2tldCwgJnJzKTsKLQotICAgICAgICAgICAgICAgIHN0cnVjdCB0aW1ldmFsIHR2OwotICAgICAgICAgICAgICAgIHR2LnR2X3NlYyA9IDA7Ci0gICAgICAgICAgICAgICAgdHYudHZfdXNlYyA9IDA7Ci0KLSAgICAgICAgICAgICAgICBpbnQgcmVzID0gc2VsZWN0KG1SVENQU29ja2V0ICsgMSwgJnJzLCBOVUxMLCBOVUxMLCAmdHYpOwotCi0gICAgICAgICAgICAgICAgaWYgKHJlcyA9PSAxKSB7Ci0gICAgICAgICAgICAgICAgICAgIHNwPEFCdWZmZXI+IGJ1ZmZlciA9IG5ldyBBQnVmZmVyKDY1NTM2KTsKLSAgICAgICAgICAgICAgICAgICAgc3NpemVfdCBuID0gcmVjdihtUlRDUFNvY2tldCwgYnVmZmVyLT5kYXRhKCksIGJ1ZmZlci0+c2l6ZSgpLCAwKTsKLQotICAgICAgICAgICAgICAgICAgICBpZiAobiA8PSAwKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBMT0coRVJST1IpIDw8ICJyZWN2IHJldHVybmVkICIgPDwgbjsKLSAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIExPRyhJTkZPKSA8PCAicmVjdiByZXR1cm5lZCAiIDw8IG4gPDwgIiBieXRlcyBvZiBkYXRhLiI7Ci0KLSAgICAgICAgICAgICAgICAgICAgICAgIGhleGR1bXAoYnVmZmVyLT5kYXRhKCksIG4pOwotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgfQotCi0gICAgICAgICAgICAgICAgbXNnLT5wb3N0KDUwMDAwKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLSNlbmRpZgotCi0gICAgICAgICAgICBjYXNlICdzZXR1JzoKLSAgICAgICAgICAgIHsKLSAgICAgICAgICAgICAgICBpbnQzMl90IHJlc3VsdDsKLSAgICAgICAgICAgICAgICBDSEVDSyhtc2ctPmZpbmRJbnQzMigicmVzdWx0IiwgJnJlc3VsdCkpOwotCi0gICAgICAgICAgICAgICAgTE9HKElORk8pIDw8ICJTRVRVUCBjb21wbGV0ZWQgd2l0aCByZXN1bHQgIgotICAgICAgICAgICAgICAgICAgICAgPDwgcmVzdWx0IDw8ICIgKCIgPDwgc3RyZXJyb3IoLXJlc3VsdCkgPDwgIikiOwotCi0gICAgICAgICAgICAgICAgc3A8UmVmQmFzZT4gb2JqOwotICAgICAgICAgICAgICAgIENIRUNLKG1zZy0+ZmluZE9iamVjdCgicmVzcG9uc2UiLCAmb2JqKSk7Ci0gICAgICAgICAgICAgICAgc3A8QVJUU1BSZXNwb25zZT4gcmVzcG9uc2U7Ci0KLSAgICAgICAgICAgICAgICBpZiAocmVzdWx0ID09IE9LKSB7Ci0gICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gc3RhdGljX2Nhc3Q8QVJUU1BSZXNwb25zZSAqPihvYmouZ2V0KCkpOwotICAgICAgICAgICAgICAgICAgICBDSEVDSyhyZXNwb25zZSAhPSBOVUxMKTsKLSAgICAgICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgICAgICBpZiAocmVzdWx0ICE9IE9LIHx8IHJlc3BvbnNlLT5tU3RhdHVzQ29kZSAhPSAyMDApIHsKLSAgICAgICAgICAgICAgICAgICAgKG5ldyBBTWVzc2FnZSgncXVpdCcsIHRoaXMpKS0+cG9zdCgpOwotICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgICAgICBzc2l6ZV90IGkgPSByZXNwb25zZS0+bUhlYWRlcnMuaW5kZXhPZktleSgic2Vzc2lvbiIpOwotICAgICAgICAgICAgICAgIENIRUNLX0dFKGksIDApOwotICAgICAgICAgICAgICAgIG1TZXNzaW9uSUQgPSByZXNwb25zZS0+bUhlYWRlcnMudmFsdWVBdChpKTsKLSAgICAgICAgICAgICAgICBpID0gbVNlc3Npb25JRC5maW5kKCI7Iik7Ci0gICAgICAgICAgICAgICAgaWYgKGkgPj0gMCkgewotICAgICAgICAgICAgICAgICAgICAvLyBSZW1vdmUgb3B0aW9ucywgaS5lLiAiO3RpbWVvdXQ9OTAiCi0gICAgICAgICAgICAgICAgICAgIG1TZXNzaW9uSUQuZXJhc2UoaSwgbVNlc3Npb25JRC5zaXplKCkgLSBpKTsKLSAgICAgICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgICAgICBpID0gcmVzcG9uc2UtPm1IZWFkZXJzLmluZGV4T2ZLZXkoInRyYW5zcG9ydCIpOwotICAgICAgICAgICAgICAgIENIRUNLX0dFKGksIDApOwotICAgICAgICAgICAgICAgIEFTdHJpbmcgdHJhbnNwb3J0ID0gcmVzcG9uc2UtPm1IZWFkZXJzLnZhbHVlQXQoaSk7Ci0KLSAgICAgICAgICAgICAgICBMT0coSU5GTykgPDwgInRyYW5zcG9ydCA9ICciIDw8IHRyYW5zcG9ydCA8PCAiJyI7Ci0KLSAgICAgICAgICAgICAgICBBU3RyaW5nIHZhbHVlOwotICAgICAgICAgICAgICAgIENIRUNLKEdldEF0dHJpYnV0ZSh0cmFuc3BvcnQuY19zdHIoKSwgInNlcnZlcl9wb3J0IiwgJnZhbHVlKSk7Ci0KLSAgICAgICAgICAgICAgICB1bnNpZ25lZCBydHBQb3J0LCBydGNwUG9ydDsKLSAgICAgICAgICAgICAgICBDSEVDS19FUShzc2NhbmYodmFsdWUuY19zdHIoKSwgIiV1LSV1IiwgJnJ0cFBvcnQsICZydGNwUG9ydCksIDIpOwotCi0gICAgICAgICAgICAgICAgQ0hFQ0soR2V0QXR0cmlidXRlKHRyYW5zcG9ydC5jX3N0cigpLCAic291cmNlIiwgJnZhbHVlKSk7Ci0KLSAgICAgICAgICAgICAgICBtZW1zZXQobVJlbW90ZUFkZHIuc2luX3plcm8sIDAsIHNpemVvZihtUmVtb3RlQWRkci5zaW5femVybykpOwotICAgICAgICAgICAgICAgIG1SZW1vdGVBZGRyLnNpbl9mYW1pbHkgPSBBRl9JTkVUOwotICAgICAgICAgICAgICAgIG1SZW1vdGVBZGRyLnNpbl9hZGRyLnNfYWRkciA9IGluZXRfYWRkcih2YWx1ZS5jX3N0cigpKTsKLSAgICAgICAgICAgICAgICBtUmVtb3RlQWRkci5zaW5fcG9ydCA9IGh0b25zKHJ0cFBvcnQpOwotCi0gICAgICAgICAgICAgICAgbVJlbW90ZVJUQ1BBZGRyID0gbVJlbW90ZUFkZHI7Ci0gICAgICAgICAgICAgICAgbVJlbW90ZVJUQ1BBZGRyLnNpbl9wb3J0ID0gaHRvbnMocnRwUG9ydCArIDEpOwotCi0gICAgICAgICAgICAgICAgQ0hFQ0tfRVEoMCwgY29ubmVjdChtUlRQU29ja2V0LAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGNvbnN0IHN0cnVjdCBzb2NrYWRkciAqKSZtUmVtb3RlQWRkciwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemVvZihtUmVtb3RlQWRkcikpKTsKLQotICAgICAgICAgICAgICAgIENIRUNLX0VRKDAsIGNvbm5lY3QobVJUQ1BTb2NrZXQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoY29uc3Qgc3RydWN0IHNvY2thZGRyICopJm1SZW1vdGVSVENQQWRkciwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemVvZihtUmVtb3RlUlRDUEFkZHIpKSk7Ci0KLSAgICAgICAgICAgICAgICB1aW50MzJfdCB4ID0gbnRvaGwobVJlbW90ZUFkZHIuc2luX2FkZHIuc19hZGRyKTsKLSAgICAgICAgICAgICAgICBMT0coSU5GTykgPDwgInNlbmRpbmcgZGF0YSB0byAiCi0gICAgICAgICAgICAgICAgICAgICA8PCAoeCA+PiAyNCkKLSAgICAgICAgICAgICAgICAgICAgIDw8ICIuIgotICAgICAgICAgICAgICAgICAgICAgPDwgKCh4ID4+IDE2KSAmIDB4ZmYpCi0gICAgICAgICAgICAgICAgICAgICA8PCAiLiIKLSAgICAgICAgICAgICAgICAgICAgIDw8ICgoeCA+PiA4KSAmIDB4ZmYpCi0gICAgICAgICAgICAgICAgICAgICA8PCAiLiIKLSAgICAgICAgICAgICAgICAgICAgIDw8ICh4ICYgMHhmZikKLSAgICAgICAgICAgICAgICAgICAgIDw8ICI6IgotICAgICAgICAgICAgICAgICAgICAgPDwgcnRwUG9ydDsKLQotICAgICAgICAgICAgICAgIEFTdHJpbmcgcmVxdWVzdDsKLSAgICAgICAgICAgICAgICByZXF1ZXN0LmFwcGVuZCgiUkVDT1JEICIpOwotICAgICAgICAgICAgICAgIHJlcXVlc3QuYXBwZW5kKG1TdHJlYW1VUkwpOwotICAgICAgICAgICAgICAgIHJlcXVlc3QuYXBwZW5kKCIgUlRTUC8xLjBcclxuIik7Ci0KLSAgICAgICAgICAgICAgICBhZGRBdXRoZW50aWNhdGlvbigmcmVxdWVzdCwgIlJFQ09SRCIsIG1TdHJlYW1VUkwuY19zdHIoKSk7Ci0KLSAgICAgICAgICAgICAgICByZXF1ZXN0LmFwcGVuZCgiU2Vzc2lvbjogIik7Ci0gICAgICAgICAgICAgICAgcmVxdWVzdC5hcHBlbmQobVNlc3Npb25JRCk7Ci0gICAgICAgICAgICAgICAgcmVxdWVzdC5hcHBlbmQoIlxyXG4iKTsKLSAgICAgICAgICAgICAgICByZXF1ZXN0LmFwcGVuZCgiXHJcbiIpOwotCi0gICAgICAgICAgICAgICAgc3A8QU1lc3NhZ2U+IHJlcGx5ID0gbmV3IEFNZXNzYWdlKCdyZWNvJywgdGhpcyk7Ci0gICAgICAgICAgICAgICAgbUNvbm4tPnNlbmRSZXF1ZXN0KHJlcXVlc3QuY19zdHIoKSwgcmVwbHkpOwotICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgfQotCi0gICAgICAgICAgICBjYXNlICdyZWNvJzoKLSAgICAgICAgICAgIHsKLSAgICAgICAgICAgICAgICBpbnQzMl90IHJlc3VsdDsKLSAgICAgICAgICAgICAgICBDSEVDSyhtc2ctPmZpbmRJbnQzMigicmVzdWx0IiwgJnJlc3VsdCkpOwotCi0gICAgICAgICAgICAgICAgTE9HKElORk8pIDw8ICJSRUNPUkQgY29tcGxldGVkIHdpdGggcmVzdWx0ICIKLSAgICAgICAgICAgICAgICAgICAgIDw8IHJlc3VsdCA8PCAiICgiIDw8IHN0cmVycm9yKC1yZXN1bHQpIDw8ICIpIjsKLQotICAgICAgICAgICAgICAgIHNwPFJlZkJhc2U+IG9iajsKLSAgICAgICAgICAgICAgICBDSEVDSyhtc2ctPmZpbmRPYmplY3QoInJlc3BvbnNlIiwgJm9iaikpOwotICAgICAgICAgICAgICAgIHNwPEFSVFNQUmVzcG9uc2U+IHJlc3BvbnNlOwotCi0gICAgICAgICAgICAgICAgaWYgKHJlc3VsdCA9PSBPSykgewotICAgICAgICAgICAgICAgICAgICByZXNwb25zZSA9IHN0YXRpY19jYXN0PEFSVFNQUmVzcG9uc2UgKj4ob2JqLmdldCgpKTsKLSAgICAgICAgICAgICAgICAgICAgQ0hFQ0socmVzcG9uc2UgIT0gTlVMTCk7Ci0gICAgICAgICAgICAgICAgfQotCi0gICAgICAgICAgICAgICAgaWYgKHJlc3VsdCAhPSBPSykgewotICAgICAgICAgICAgICAgICAgICAobmV3IEFNZXNzYWdlKCdxdWl0JywgdGhpcykpLT5wb3N0KCk7Ci0gICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgICAgIChuZXcgQU1lc3NhZ2UoJ21vcmUnLCB0aGlzKSktPnBvc3QoKTsKLSAgICAgICAgICAgICAgICAobmV3IEFNZXNzYWdlKCdzciAgJywgdGhpcykpLT5wb3N0KCk7Ci0gICAgICAgICAgICAgICAgKG5ldyBBTWVzc2FnZSgnYWxpdicsIHRoaXMpKS0+cG9zdCgzMDAwMDAwMGxsKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgY2FzZSAnYWxpdic6Ci0gICAgICAgICAgICB7Ci0gICAgICAgICAgICAgICAgaWYgKCFtQ29ubmVjdGVkKSB7Ci0gICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgICAgIEFTdHJpbmcgcmVxdWVzdDsKLSAgICAgICAgICAgICAgICByZXF1ZXN0LmFwcGVuZCgiT1BUSU9OUyAiKTsKLSAgICAgICAgICAgICAgICByZXF1ZXN0LmFwcGVuZChtU3RyZWFtVVJMKTsKLSAgICAgICAgICAgICAgICByZXF1ZXN0LmFwcGVuZCgiIFJUU1AvMS4wXHJcbiIpOwotCi0gICAgICAgICAgICAgICAgYWRkQXV0aGVudGljYXRpb24oJnJlcXVlc3QsICJSRUNPUkQiLCBtU3RyZWFtVVJMLmNfc3RyKCkpOwotCi0gICAgICAgICAgICAgICAgcmVxdWVzdC5hcHBlbmQoIlNlc3Npb246ICIpOwotICAgICAgICAgICAgICAgIHJlcXVlc3QuYXBwZW5kKG1TZXNzaW9uSUQpOwotICAgICAgICAgICAgICAgIHJlcXVlc3QuYXBwZW5kKCJcclxuIik7Ci0gICAgICAgICAgICAgICAgcmVxdWVzdC5hcHBlbmQoIlxyXG4iKTsKLQotICAgICAgICAgICAgICAgIHNwPEFNZXNzYWdlPiByZXBseSA9IG5ldyBBTWVzc2FnZSgnb3B0cycsIHRoaXMpOwotICAgICAgICAgICAgICAgIG1Db25uLT5zZW5kUmVxdWVzdChyZXF1ZXN0LmNfc3RyKCksIHJlcGx5KTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgY2FzZSAnb3B0cyc6Ci0gICAgICAgICAgICB7Ci0gICAgICAgICAgICAgICAgaW50MzJfdCByZXN1bHQ7Ci0gICAgICAgICAgICAgICAgQ0hFQ0sobXNnLT5maW5kSW50MzIoInJlc3VsdCIsICZyZXN1bHQpKTsKLQotICAgICAgICAgICAgICAgIExPRyhJTkZPKSA8PCAiT1BUSU9OUyBjb21wbGV0ZWQgd2l0aCByZXN1bHQgIgotICAgICAgICAgICAgICAgICAgICAgPDwgcmVzdWx0IDw8ICIgKCIgPDwgc3RyZXJyb3IoLXJlc3VsdCkgPDwgIikiOwotCi0gICAgICAgICAgICAgICAgaWYgKCFtQ29ubmVjdGVkKSB7Ci0gICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgICAgIChuZXcgQU1lc3NhZ2UoJ2FsaXYnLCB0aGlzKSktPnBvc3QoMzAwMDAwMDBsbCk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgIGNhc2UgJ21vcmUnOgotICAgICAgICAgICAgewotICAgICAgICAgICAgICAgIGlmICghbUNvbm5lY3RlZCkgewotICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgICAgICBzcDxBQnVmZmVyPiBidWZmZXIgPSBuZXcgQUJ1ZmZlcig2NTUzNik7Ci0gICAgICAgICAgICAgICAgdWludDhfdCAqZGF0YSA9IGJ1ZmZlci0+ZGF0YSgpOwotICAgICAgICAgICAgICAgIGRhdGFbMF0gPSAweDgwOwotICAgICAgICAgICAgICAgIGRhdGFbMV0gPSAoMSA8PCA3KSB8IFBUOyAgLy8gTS1iaXQKLSAgICAgICAgICAgICAgICBkYXRhWzJdID0gKG1TZXFObyA+PiA4KSAmIDB4ZmY7Ci0gICAgICAgICAgICAgICAgZGF0YVszXSA9IG1TZXFObyAmIDB4ZmY7Ci0gICAgICAgICAgICAgICAgZGF0YVs4XSA9IG1Tb3VyY2VJRCA+PiAyNDsKLSAgICAgICAgICAgICAgICBkYXRhWzldID0gKG1Tb3VyY2VJRCA+PiAxNikgJiAweGZmOwotICAgICAgICAgICAgICAgIGRhdGFbMTBdID0gKG1Tb3VyY2VJRCA+PiA4KSAmIDB4ZmY7Ci0gICAgICAgICAgICAgICAgZGF0YVsxMV0gPSBtU291cmNlSUQgJiAweGZmOwotCi0jaWZkZWYgQU5EUk9JRAotICAgICAgICAgICAgICAgIE1lZGlhQnVmZmVyICptZWRpYUJ1ZiA9IE5VTEw7Ci0gICAgICAgICAgICAgICAgZm9yICg7OykgewotICAgICAgICAgICAgICAgICAgICBDSEVDS19FUShtRW5jb2Rlci0+cmVhZCgmbWVkaWFCdWYpLCAoc3RhdHVzX3QpT0spOwotICAgICAgICAgICAgICAgICAgICBpZiAobWVkaWFCdWYtPnJhbmdlX2xlbmd0aCgpID4gMCkgewotICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgbWVkaWFCdWYtPnJlbGVhc2UoKTsKLSAgICAgICAgICAgICAgICAgICAgbWVkaWFCdWYgPSBOVUxMOwotICAgICAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgICAgIGludDY0X3QgdGltZVVzOwotICAgICAgICAgICAgICAgIENIRUNLKG1lZGlhQnVmLT5tZXRhX2RhdGEoKS0+ZmluZEludDY0KGtLZXlUaW1lLCAmdGltZVVzKSk7Ci0KLSAgICAgICAgICAgICAgICB1aW50MzJfdCBydHBUaW1lID0gbVJUUFRpbWVCYXNlICsgKHRpbWVVcyAqIDkgLyAxMDBsbCk7Ci0KLSAgICAgICAgICAgICAgICBjb25zdCB1aW50OF90ICptZWRpYURhdGEgPQotICAgICAgICAgICAgICAgICAgICAoY29uc3QgdWludDhfdCAqKW1lZGlhQnVmLT5kYXRhKCkgKyBtZWRpYUJ1Zi0+cmFuZ2Vfb2Zmc2V0KCk7Ci0KLSAgICAgICAgICAgICAgICBDSEVDSyghbWVtY21wKCJceDAwXHgwMFx4MDBceDAxIiwgbWVkaWFEYXRhLCA0KSk7Ci0KLSAgICAgICAgICAgICAgICBDSEVDS19MRShtZWRpYUJ1Zi0+cmFuZ2VfbGVuZ3RoKCkgLSA0ICsgMTIsIGJ1ZmZlci0+c2l6ZSgpKTsKLQotICAgICAgICAgICAgICAgIG1lbWNweSgmZGF0YVsxMl0sCi0gICAgICAgICAgICAgICAgICAgICAgIG1lZGlhRGF0YSArIDQsIG1lZGlhQnVmLT5yYW5nZV9sZW5ndGgoKSAtIDQpOwotCi0gICAgICAgICAgICAgICAgYnVmZmVyLT5zZXRSYW5nZSgwLCBtZWRpYUJ1Zi0+cmFuZ2VfbGVuZ3RoKCkgLSA0ICsgMTIpOwotCi0gICAgICAgICAgICAgICAgbWVkaWFCdWYtPnJlbGVhc2UoKTsKLSAgICAgICAgICAgICAgICBtZWRpYUJ1ZiA9IE5VTEw7Ci0jZWxzZQotICAgICAgICAgICAgICAgIHVpbnQzMl90IHJ0cFRpbWUgPSBtUlRQVGltZUJhc2UgKyBtTnVtUlRQU2VudCAqIDEyODsKLSAgICAgICAgICAgICAgICBtZW1zZXQoJmRhdGFbMTJdLCAwLCAxMjgpOwotICAgICAgICAgICAgICAgIGJ1ZmZlci0+c2V0UmFuZ2UoMCwgMTIgKyAxMjgpOwotI2VuZGlmCi0KLSAgICAgICAgICAgICAgICBkYXRhWzRdID0gcnRwVGltZSA+PiAyNDsKLSAgICAgICAgICAgICAgICBkYXRhWzVdID0gKHJ0cFRpbWUgPj4gMTYpICYgMHhmZjsKLSAgICAgICAgICAgICAgICBkYXRhWzZdID0gKHJ0cFRpbWUgPj4gOCkgJiAweGZmOwotICAgICAgICAgICAgICAgIGRhdGFbN10gPSBydHBUaW1lICYgMHhmZjsKLQotICAgICAgICAgICAgICAgIHNzaXplX3QgbiA9IHNlbmQoCi0gICAgICAgICAgICAgICAgICAgICAgICBtUlRQU29ja2V0LCBkYXRhLCBidWZmZXItPnNpemUoKSwgMCk7Ci0gICAgICAgICAgICAgICAgaWYgKG4gPCAwKSB7Ci0gICAgICAgICAgICAgICAgICAgIExPRyhFUlJPUikgPDwgInNlbmQgZmFpbGVkICgiIDw8IHN0cmVycm9yKGVycm5vKSA8PCAiKSI7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIENIRUNLX0VRKG4sIChzc2l6ZV90KWJ1ZmZlci0+c2l6ZSgpKTsKLQotICAgICAgICAgICAgICAgICsrbVNlcU5vOwotCi0gICAgICAgICAgICAgICAgKyttTnVtUlRQU2VudDsKLSAgICAgICAgICAgICAgICBtTnVtUlRQT2N0ZXRzU2VudCArPSBidWZmZXItPnNpemUoKSAtIDEyOwotCi0gICAgICAgICAgICAgICAgbUxhc3RSVFBUaW1lID0gcnRwVGltZTsKLSAgICAgICAgICAgICAgICBtTGFzdE5UUFRpbWUgPSBudHBUaW1lKCk7Ci0KLSNpZmRlZiBBTkRST0lECi0gICAgICAgICAgICAgICAgaWYgKG1OdW1SVFBTZW50IDwgNjAgKiAyNSkgeyAgLy8gNjAgc2VjcyB3b3J0aAotICAgICAgICAgICAgICAgICAgICBtc2ctPnBvc3QoNDAwMDApOwotI2Vsc2UKLSAgICAgICAgICAgICAgICBpZiAobU51bVJUUE9jdGV0c1NlbnQgPCA4MDAwICogNjApIHsKLSAgICAgICAgICAgICAgICAgICAgbXNnLT5wb3N0KDEwMDAwMDBsbCAqIDEyOCAvIDgwMDApOwotI2VuZGlmCi0gICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgTE9HKElORk8pIDw8ICJUaGF0J3MgZW5vdWdoLCBwYXVzaW5nLiI7Ci0KLSAgICAgICAgICAgICAgICAgICAgQVN0cmluZyByZXF1ZXN0OwotICAgICAgICAgICAgICAgICAgICByZXF1ZXN0LmFwcGVuZCgiUEFVU0UgIik7Ci0gICAgICAgICAgICAgICAgICAgIHJlcXVlc3QuYXBwZW5kKG1TdHJlYW1VUkwpOwotICAgICAgICAgICAgICAgICAgICByZXF1ZXN0LmFwcGVuZCgiIFJUU1AvMS4wXHJcbiIpOwotCi0gICAgICAgICAgICAgICAgICAgIGFkZEF1dGhlbnRpY2F0aW9uKCZyZXF1ZXN0LCAiUEFVU0UiLCBtU3RyZWFtVVJMLmNfc3RyKCkpOwotCi0gICAgICAgICAgICAgICAgICAgIHJlcXVlc3QuYXBwZW5kKCJTZXNzaW9uOiAiKTsKLSAgICAgICAgICAgICAgICAgICAgcmVxdWVzdC5hcHBlbmQobVNlc3Npb25JRCk7Ci0gICAgICAgICAgICAgICAgICAgIHJlcXVlc3QuYXBwZW5kKCJcclxuIik7Ci0gICAgICAgICAgICAgICAgICAgIHJlcXVlc3QuYXBwZW5kKCJcclxuIik7Ci0KLSAgICAgICAgICAgICAgICAgICAgc3A8QU1lc3NhZ2U+IHJlcGx5ID0gbmV3IEFNZXNzYWdlKCdwYXVzJywgdGhpcyk7Ci0gICAgICAgICAgICAgICAgICAgIG1Db25uLT5zZW5kUmVxdWVzdChyZXF1ZXN0LmNfc3RyKCksIHJlcGx5KTsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgIGNhc2UgJ3NyICAnOgotICAgICAgICAgICAgewotICAgICAgICAgICAgICAgIGlmICghbUNvbm5lY3RlZCkgewotICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgICAgICBzcDxBQnVmZmVyPiBidWZmZXIgPSBuZXcgQUJ1ZmZlcig2NTUzNik7Ci0gICAgICAgICAgICAgICAgYnVmZmVyLT5zZXRSYW5nZSgwLCAwKTsKLQotICAgICAgICAgICAgICAgIGFkZFNSKGJ1ZmZlcik7Ci0gICAgICAgICAgICAgICAgYWRkU0RFUyhidWZmZXIpOwotCi0gICAgICAgICAgICAgICAgdWludDhfdCAqZGF0YSA9IGJ1ZmZlci0+ZGF0YSgpOwotICAgICAgICAgICAgICAgIHNzaXplX3QgbiA9IHNlbmQoCi0gICAgICAgICAgICAgICAgICAgICAgICBtUlRDUFNvY2tldCwgZGF0YSwgYnVmZmVyLT5zaXplKCksIDApOwotICAgICAgICAgICAgICAgIENIRUNLX0VRKG4sIChzc2l6ZV90KWJ1ZmZlci0+c2l6ZSgpKTsKLQotICAgICAgICAgICAgICAgIG1zZy0+cG9zdCgzMDAwMDAwKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgY2FzZSAncGF1cyc6Ci0gICAgICAgICAgICB7Ci0gICAgICAgICAgICAgICAgaW50MzJfdCByZXN1bHQ7Ci0gICAgICAgICAgICAgICAgQ0hFQ0sobXNnLT5maW5kSW50MzIoInJlc3VsdCIsICZyZXN1bHQpKTsKLQotICAgICAgICAgICAgICAgIExPRyhJTkZPKSA8PCAiUEFVU0UgY29tcGxldGVkIHdpdGggcmVzdWx0ICIKLSAgICAgICAgICAgICAgICAgICAgIDw8IHJlc3VsdCA8PCAiICgiIDw8IHN0cmVycm9yKC1yZXN1bHQpIDw8ICIpIjsKLQotICAgICAgICAgICAgICAgIHNwPFJlZkJhc2U+IG9iajsKLSAgICAgICAgICAgICAgICBDSEVDSyhtc2ctPmZpbmRPYmplY3QoInJlc3BvbnNlIiwgJm9iaikpOwotICAgICAgICAgICAgICAgIHNwPEFSVFNQUmVzcG9uc2U+IHJlc3BvbnNlOwotCi0gICAgICAgICAgICAgICAgQVN0cmluZyByZXF1ZXN0OwotICAgICAgICAgICAgICAgIHJlcXVlc3QuYXBwZW5kKCJURUFSRE9XTiAiKTsKLSAgICAgICAgICAgICAgICByZXF1ZXN0LmFwcGVuZChtU3RyZWFtVVJMKTsKLSAgICAgICAgICAgICAgICByZXF1ZXN0LmFwcGVuZCgiIFJUU1AvMS4wXHJcbiIpOwotCi0gICAgICAgICAgICAgICAgYWRkQXV0aGVudGljYXRpb24oJnJlcXVlc3QsICJURUFSRE9XTiIsIG1TdHJlYW1VUkwuY19zdHIoKSk7Ci0KLSAgICAgICAgICAgICAgICByZXF1ZXN0LmFwcGVuZCgiU2Vzc2lvbjogIik7Ci0gICAgICAgICAgICAgICAgcmVxdWVzdC5hcHBlbmQobVNlc3Npb25JRCk7Ci0gICAgICAgICAgICAgICAgcmVxdWVzdC5hcHBlbmQoIlxyXG4iKTsKLSAgICAgICAgICAgICAgICByZXF1ZXN0LmFwcGVuZCgiXHJcbiIpOwotCi0gICAgICAgICAgICAgICAgc3A8QU1lc3NhZ2U+IHJlcGx5ID0gbmV3IEFNZXNzYWdlKCd0ZWFyJywgdGhpcyk7Ci0gICAgICAgICAgICAgICAgbUNvbm4tPnNlbmRSZXF1ZXN0KHJlcXVlc3QuY19zdHIoKSwgcmVwbHkpOwotICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgfQotCi0gICAgICAgICAgICBjYXNlICd0ZWFyJzoKLSAgICAgICAgICAgIHsKLSAgICAgICAgICAgICAgICBpbnQzMl90IHJlc3VsdDsKLSAgICAgICAgICAgICAgICBDSEVDSyhtc2ctPmZpbmRJbnQzMigicmVzdWx0IiwgJnJlc3VsdCkpOwotCi0gICAgICAgICAgICAgICAgTE9HKElORk8pIDw8ICJURUFSRE9XTiBjb21wbGV0ZWQgd2l0aCByZXN1bHQgIgotICAgICAgICAgICAgICAgICAgICAgPDwgcmVzdWx0IDw8ICIgKCIgPDwgc3RyZXJyb3IoLXJlc3VsdCkgPDwgIikiOwotCi0gICAgICAgICAgICAgICAgc3A8UmVmQmFzZT4gb2JqOwotICAgICAgICAgICAgICAgIENIRUNLKG1zZy0+ZmluZE9iamVjdCgicmVzcG9uc2UiLCAmb2JqKSk7Ci0gICAgICAgICAgICAgICAgc3A8QVJUU1BSZXNwb25zZT4gcmVzcG9uc2U7Ci0KLSAgICAgICAgICAgICAgICBpZiAocmVzdWx0ID09IE9LKSB7Ci0gICAgICAgICAgICAgICAgICAgIHJlc3BvbnNlID0gc3RhdGljX2Nhc3Q8QVJUU1BSZXNwb25zZSAqPihvYmouZ2V0KCkpOwotICAgICAgICAgICAgICAgICAgICBDSEVDSyhyZXNwb25zZSAhPSBOVUxMKTsKLSAgICAgICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgICAgICAobmV3IEFNZXNzYWdlKCdxdWl0JywgdGhpcykpLT5wb3N0KCk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgIGNhc2UgJ2Rpc2MnOgotICAgICAgICAgICAgewotICAgICAgICAgICAgICAgIExPRyhJTkZPKSA8PCAiZGlzY29ubmVjdCBjb21wbGV0ZWQiOwotCi0gICAgICAgICAgICAgICAgbUNvbm5lY3RlZCA9IGZhbHNlOwotICAgICAgICAgICAgICAgIChuZXcgQU1lc3NhZ2UoJ3F1aXQnLCB0aGlzKSktPnBvc3QoKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgY2FzZSAncXVpdCc6Ci0gICAgICAgICAgICB7Ci0gICAgICAgICAgICAgICAgaWYgKG1Db25uZWN0ZWQpIHsKLSAgICAgICAgICAgICAgICAgICAgbUNvbm4tPmRpc2Nvbm5lY3QobmV3IEFNZXNzYWdlKCdkaXNjJywgdGhpcykpOwotICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICB9Ci0KLSAgICAgICAgICAgICAgICBpZiAobVJUUFNvY2tldCA+PSAwKSB7Ci0gICAgICAgICAgICAgICAgICAgIGNsb3NlKG1SVFBTb2NrZXQpOwotICAgICAgICAgICAgICAgICAgICBtUlRQU29ja2V0ID0gLTE7Ci0gICAgICAgICAgICAgICAgfQotCi0gICAgICAgICAgICAgICAgaWYgKG1SVENQU29ja2V0ID49IDApIHsKLSAgICAgICAgICAgICAgICAgICAgY2xvc2UobVJUQ1BTb2NrZXQpOwotICAgICAgICAgICAgICAgICAgICBtUlRDUFNvY2tldCA9IC0xOwotICAgICAgICAgICAgICAgIH0KLQotI2lmZGVmIEFORFJPSUQKLSAgICAgICAgICAgICAgICBtRW5jb2Rlci0+c3RvcCgpOwotICAgICAgICAgICAgICAgIG1FbmNvZGVyLmNsZWFyKCk7Ci0jZW5kaWYKLQotIC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gICAgICAgICBjYXNlIDA6Ci0gICAgICAgICAgICAgICAgZGVjb2Rlci0+aW5pdCgvKmZyYW1lVGltZVVzKi8gZmRwLkNvbnN1bWVJbnRlZ3JhbDxpbnQ2NF90PigpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLypvcHRpb24qLyBmZHAuQ29uc3VtZUludGVncmFsPGludD4oKSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qY29sb3JGb3JtYXQqLyBmZHAuQ29uc3VtZUludGVncmFsPGludD4oKSk7CisgICAgICAgIHVpbnQ4X3Qgc3dpdGNoQ2FzZSA9IGZkcC5Db25zdW1lSW50ZWdyYWxJblJhbmdlPHVpbnQ4X3Q+KDAsIDMpOworICAgICAgICBzd2l0Y2ggKHN3aXRjaENhc2UpIHsKKyAgICAgICAgICAgIGNhc2UgMDogeworICAgICAgICAgICAgICAgIGludDY0X3QgZnJhbWVUaW1lVXMgPSBmZHAuQ29uc3VtZUludGVncmFsPGludDY0X3Q+KCk7CisgICAgICAgICAgICAgICAgaW50IG9wdGlvbiA9IGZkcC5Db25zdW1lSW50ZWdyYWw8aW50PigpOworICAgICAgICAgICAgICAgIGludCBjb2xvckZvcm1hdCA9IGZkcC5Db25zdW1lSW50ZWdyYWw8aW50PigpOworICAgICAgICAgICAgICAgIGRlY29kZXItPmluaXQoZnJhbWVUaW1lVXMsIG9wdGlvbiwgY29sb3JGb3JtYXQpOwogICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgfQogICAgICAgICAgICAgY2FzZSAxOgogICAgICAgICAgICAgICAgIGRlY29kZXItPmV4dHJhY3RGcmFtZSgpOwogICAgICAgICAgICAgICAgIGJyZWFrOwpkaWZmIC0tZ2l0IGEvbWVkaWEvbGlic3RhZ2VmcmlnaHQvdGVzdHMvZnV6emVycy9GdXp6ZXJNZWRpYVV0aWxpdHkuY3BwIGIvbWVkaWEvbGlic3RhZ2VmcmlnaHQvdGVzdHMvZnV6emVycy9GdXp6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nRBbGxvY2F0ZWQoa0NvZGVjTmFtZS5jX3N0cigpKTsKKyAgICAgICAgICAgICAgICB9KTsKKyAgICAgICAgICAgIE9OX0NBTEwoKm1vY2tDb2RlYywgaW5pdGlhdGVTaHV0ZG93bihfKSkKKyAgICAgICAgICAgICAgICAuV2lsbEJ5RGVmYXVsdChbbW9ja0NvZGVjXShib29sKSB7CisgICAgICAgICAgICAgICAgICAgIC8vIDIpCisgICAgICAgICAgICAgICAgICAgIG1vY2tDb2RlYy0+Y2FsbGJhY2soKS0+b25FcnJvcihVTktOT1dOX0VSUk9SLCBBQ1RJT05fQ09ERV9GQVRBTCk7CisgICAgICAgICAgICAgICAgICAgIC8vIDQpCisgICAgICAgICAgICAgICAgICAgIG1vY2tDb2RlYy0+Y2FsbGJhY2soKS0+b25FcnJvcihERUFEX09CSkVDVCwgQUNUSU9OX0NPREVfRkFUQUwpOworICAgICAgICAgICAgICAgICAgICAvLyBDb2RlYyBzZXJ2aWNlIGhhcyBkaWVkLCBubyBjYWxsYmFjay4KKyAgICAgICAgICAgICAgICB9KTsKKyAgICAgICAgICAgIHJldHVybiBtb2NrQ29kZWM7CisgICAgICAgIH07CisKKyAgICBzcDxBTG9vcGVyPiBsb29wZXJ7bmV3IEFMb29wZXJ9OworICAgIHNwPE1lZGlhQ29kZWM+IGNvZGVjID0gU2V0dXBNZWRpYUNvZGVjKAorICAgICAgICAgICAga0NvZGVjT3duZXIsIGtDb2RlY05hbWUsIGtNZWRpYVR5cGUsIGxvb3BlciwgZ2V0Q29kZWNCYXNlKTsKKyAgICBBU1NFUlRfTkUobnVsbHB0ciwgY29kZWMpIDw8ICJDb2RlYyBtdXN0IG5vdCBiZSBudWxsIjsKKyAgICBBU1NFUlRfTkUobnVsbHB0ciwgbW9ja0NvZGVjKSA8PCAiTW9ja0NvZGVjIG11c3Qgbm90IGJlIG51bGwiOworCisgICAgY29kZWMtPnN0b3AoKTsKKyAgICAvLyBzbGVlcCBoZXJlIHNvIHRoYXQgdGh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WwogICAgICAgICAgICAgInVuc2lnbmVkLWludGVnZXItb3ZlcmZsb3ciLApkaWZmIC0tZ2l0IGEvbWVkaWEvbGlid2F0Y2hkb2cvQW5kcm9pZC5icCBiL21lZGlhL2xpYndhdGNoZG9nL0FuZHJvaWQuYnAKaW5kZXggNDExYzIwNi4uNTUwNmE3MyAxMDA2NDQKLS0tIGEvbWVkaWEvbGlid2F0Y2hkb2cvQW5kcm9pZC5icAorKysgYi9tZWRpYS9saWJ3YXRjaGRvZy9BbmRyb2lkLmJwCkBAIC0zOSw3ICszOSw3IEBACiAgICAgICAgIGRhcndpbjogewogICAgICAgICAgICAgZW5hYmxlZDogZmFsc2UsCiAgICAgICAgIH0sCi0gICAgICAgIGxpbnV4X2dsaWJjOiB7CisgICAgICAgIGdsaWJjOiB7CiAgICAgICAgICAgICBjZmxhZ3M6IFsKICAgICAgICAgICAgICAgICAiLURzaWdldl9ub3RpZnlfdGhyZWFkX2lkPV9zaWdldl91bi5fdGlkIiwKICAgICAgICAgICAgIF0sCmRpZmYgLS1naXQgYS9tZWRpYS9tZWRpYXNlcnZlci9BbmRyb2lkLmJwIGIvbWVkaWEvbWVkaWFzZXJ2ZXIvQW5kcm9pZC5icAppbmRleCBlMjU2NThmLi5lZGRkYWE0IDEwMDY0NAotLS0gYS9tZWRpYS9tZWRpYXNlcnZlci9BbmRyb2lkLmJwCisrKyBiL21lZGlhL21lZGlhc2VydmVyL0FuZHJvaWQuYnAKQEAgLTMzLDcgKzMzLDcgQEAKIAogICAgIHNoYXJlZF9saWJzOiBbCiAgICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLm1lZGlhLm9teEAxLjAiLAotICAgICAgICAibGliYW5kcm9pZGljdSIsCisgICAgICAgICJsaWJpY3UiLAogICAgICAgICAibGliZm1xIiwKICAgICAgICAgImxpYmJpbmRlciIsCiAgICAgICAgICJsaWJoaWRsYmFzZSIsCkBAIC00NywxMSArNDcsNiBAQAogICAgICAgICAibGlicmVnaXN0ZXJtc2V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Ymd1aSIsCiAgICAgICAgICJsaWJ1aSIsCiAgICAgICAgICJsaWJtZWRpYW5ka191dGlscyIsCisgICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLmRybS1WMS1uZGsiLAogICAgIF0sCiAKICAgICBleHBvcnRfaGVhZGVyX2xpYl9oZWFkZXJzOiBbImpuaV9oZWFkZXJzIl0sCkBAIC0xNjcsNyArMTY3LDcgQEAKICAgICBzdHViczogewogICAgICAgICBzeW1ib2xfZmlsZTogImxpYm1lZGlhbmRrLm1hcC50eHQiLAogICAgICAgICB2ZXJzaW9uczogWyIyOSJdLAotICAgIH0sCisgICAgfQogfQogCiBjY19saWJyYXJ5IHsKQEAgLTE3Nyw5ICsxNzcsOCBAQAogICAgICAgICAiTmRrTWVkaWFEYXRhU291cmNlQ2FsbGJhY2tzLmNwcCIsCiAgICAgXSwKIAotICAgIGluY2x1ZGVfZGlyczogWwotICAgICAgICAiZnJhbWV3b3Jrcy9hdi9tZWRpYS9saWJzdGFnZWZyaWdodC9pbmNsdWRlIiwKLSAgICAgICAgImZyYW1ld29ya3MvYXYvbWVkaWEvbmRrL2luY2x1ZGUiLAorICAgIGxvY2FsX2luY2x1ZGVfZGlyczogWworICAgICAgICAiaW5jbHVkZSIsCiAgICAgXSwKIAogICAgIGV4cG9ydF9pbmNsdWRlX2RpcnM6IFsKQEAgLTE5Myw3ICsxOTIsOSBAQAogICAgIF0sCiAKICAgICBoZWFkZXJfbGliczogWworICAgICAgICAibGlic3RhZ2VmcmlnaHRfaGVhZGVycyIsCiAgICAgICAgICJsaWJtZWRpYV9oZWFkZXJzIiwKKyAgICAgICAgImxpYnN0YWdlZnJpZ2h0X2hlYWRlcnMiLAogICAgIF0sCiAKICAgICBzaGFyZWRfbGliczogWwpAQCAtMjIzLDYgKzIyNCw3IEBACiAgICAgICAgICJsaWJjdXRpbHMiLAogICAgICAgICAiYW5kcm9pZC5oYXJkd2FyZS5ncmFwaGljcy5idWZmZXJxdWV1ZUAxLjAiLAogICAg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YSAhPSBOVUxMCi0gICAgICAgICAgICAgICAgICAgICAgICAgfHwgbUNvZGVjLT5tQXN5bmNDYWxsYmFjay5vbkFzeW5jSW5wdXRBdmFpbGFibGUgIT0gTlVMTCkgeworICAgICAgICAgICAgICAgICAgICAgaWYgKG1Db2RlYy0+bUFzeW5jQ2FsbGJhY2sub25Bc3luY0lucHV0QXZhaWxhYmxlICE9IE5VTEwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICBtQ29kZWMtPm1Bc3luY0NhbGxiYWNrLm9uQXN5bmNJbnB1dEF2YWlsYWJsZSgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1Db2RlYywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1Db2RlYy0+bUFzeW5jQ2FsbGJhY2tVc2VyRGF0YSwKQEAgLTIwNSw4ICsyMjUsNyBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICh1aW50MzJfdClmbGFnc307CiAKICAgICAgICAgICAgICAgICAgICAgIE11dGV4OjpBdXRvbG9jayBfbChtQ29kZWMtPm1Bc3luY0NhbGxiYWNrTG9jayk7Ci0gICAgICAgICAgICAgICAgICAgICBpZiAobUNvZGVjLT5tQXN5bmNDYWxsYmFja1VzZXJEYXRhICE9IE5VTEwKLSAgICAgICAgICAgICAgICAgICAgICAgICB8fCBtQ29kZWMtPm1Bc3luY0NhbGxiYWNrLm9uQXN5bmNPdXRwdXRBdmFpbGFibGUgIT0gTlVMTCkgeworICAgICAgICAgICAgICAgICAgICAgaWYgKG1Db2RlYy0+bUFzeW5jQ2FsbGJhY2sub25Bc3luY091dHB1dEF2YWlsYWJsZSAhPSBOVUxMKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5tQXN5bmNDYWxsYmFjay5vbkFzeW5jT3V0cHV0QXZhaWxhYmxlKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNvZGVjLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5tQXN5bmNDYWxsYmFja1VzZXJEYXRhLApAQCAtMjM0LDggKzI1Myw3IEBACiAgICAgICAgICAgICAgICAgICAgICBBTWVkaWFGb3JtYXQgKmFNZWRpYUZvcm1hdCA9IEFNZWRpYUZvcm1hdF9mcm9tTXNnKCZjb3B5KTsKIAogICAgICAgICAgICAgICAgICAgICAgTXV0ZXg6OkF1dG9sb2NrIF9sKG1Db2RlYy0+bUFzeW5jQ2FsbGJhY2tMb2NrKTsKLSAgICAgICAgICAgICAgICAgICAgIGlmIChtQ29kZWMtPm1Bc3luY0NhbGxiYWNrVXNlckRhdGEgIT0gTlVMTAotICAgICAgICAgICAgICAgICAgICAgICAgIHx8IG1Db2RlYy0+bUFzeW5jQ2FsbGJhY2sub25Bc3luY0Zvcm1hdENoYW5nZWQgIT0gTlVMTCkgeworICAgICAgICAgICAgICAgICAgICAgaWYgKG1Db2RlYy0+bUFzeW5jQ2FsbGJhY2sub25Bc3luY0Zvcm1hdENoYW5nZWQgIT0gTlVMTCkgewogICAgICAgICAgICAgICAgICAgICAgICAgIG1Db2RlYy0+bUFzeW5jQ2FsbGJhY2sub25Bc3luY0Zvcm1hdENoYW5nZWQoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtQ29kZWMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtQ29kZWMtPm1Bc3luY0NhbGxiYWNrVXNlckRhdGEsCkBAIC0yNTksMTIgKzI3NywxMSBAQAogICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgbXNnLT5maW5kU3RyaW5nKCJkZXRhaWwiLCAmZGV0YWlsKTsKLSAgICAgICAgICAgICAgICAgICAgIEFMT0dFKCJDb2RlYyByZXBvcnRlZCBlcnJvcigweCV4KSwgYWN0aW9uQ29kZSglZCksIGRldGFpbCglcykiLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgZXJyLCBhY3Rpb25Db2RlLCBkZXRhaWwuY19zdHIoKSk7CisgICAgICAgICAgICAgICAgICAgICBBTE9HRSgiQ29kZWMgcmVwb3J0ZWQgZXJyb3IoMHgleC8lcyksIGFjdGlvbkNvZGUoJWQpLCBkZXRhaWwoJXMpIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgIGVyciwgU3RyTWVkaWFFcnJvcihlcnIpLmNfc3RyKCksIGFjdGlvbkNvZGUsIGRldGFpbC5jX3N0cigpKTsKIAogICAgICAgICAgICAgICAgICAgICAgTXV0ZXg6OkF1dG9sb2NrIF9sKG1Db2RlYy0+bUFzeW5jQ2FsbGJhY2tMb2NrKTsKLSAgICAgICAgICAgICAgICAgICAgIGlmIChtQ29kZWMtPm1Bc3luY0NhbGxiYWNrVXNlckRhdGEgIT0gTlVMTAotICAgICAgICAgICAgICAgICAgICAgICAgIHx8IG1Db2RlYy0+bUFzeW5jQ2FsbGJhY2sub25Bc3luY0Vycm9yICE9IE5VTEwpIHsKKyAgICAgICAgICAgICAgICAgICAgIGlmIChtQ29kZWMtPm1Bc3luY0NhbGxiYWNrLm9uQXN5bmNFcnJvciAhPSBOVUxMKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5tQXN5bmNDYWxsYmFjay5vbkFzeW5jRXJyb3IoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtQ29kZWMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtQ29kZWMtPm1Bc3luY0NhbGxiYWNrVXNlckRhdGEsCkBAIC0yOTgsNiArMzE1LDQzIEBACiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogCisgICAgICAgIGNhc2Uga1doYXRGcmFtZVJlbmRlcmVkTm90aWZ5OgorICAgICAgICB7CisgICAgICAgICAgICBzcDxBTWVzc2FnZT4gZGF0YTsKKyAgICAgICAgICAgIGlmICghbXNnLT5maW5kTWVzc2FnZSgiZGF0YSIsICZkYXRhKSkgeworICAgICAgICAgICAgICAgIEFMT0dFKCJrV2hhdEZyYW1lUmVuZGVyZWROb3RpZnk6IGRhdGEgaXMgZXhwZWN0ZWQuIik7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIEFNZXNzYWdlOjpUeXBlIHR5cGU7CisgICAgICAgICAgICBpbnQ2NF90IG1lZGlhVGltZVVzLCBzeXN0ZW1OYW5vOworICAgICAgICAgICAgc2l6ZV90IGluZGV4ID0gMDsKKworICAgICAgICAgICAgLy8gVE9ETy4gVGhpcyBjb2RlIGhhcyBkZXBlbmRlbmN5IHdpdGggTWVkaWFDb2RlYzo6Q3JlYXRlRnJhbWVzUmVuZGVyZWRNZXNzYWdlLgorICAgICAgICAgICAgZm9yIChzaXplX3QgaXggPSAwOyBpeCA8IGRhdGEtPmNvdW50RW50cmllcygpOyBpeCsrKSB7CisgICAgICAgICAgICAgICAgQVN0cmluZyBuYW1lID0gZGF0YS0+Z2V0RW50cnlOYW1lQXQoaXgsICZ0eXBlKTsKKyAgICAgICAgICAgICAgICBpZiAobmFtZS5zdGFydHNXaXRoKEFTdHJpbmdQcmludGYoIiV6dS1tZWRpYS10aW1lLXVzIiwgaW5kZXgpLmNfc3RyKCkpKSB7CisgICAgICAgICAgICAgICAgICAgIEFNZXNzYWdlOjpJdGVtRGF0YSBkYXRhID0gbXNnLT5nZXRFbnRyeUF0KGluZGV4KTsKKyAgICAgICAgICAgICAgICAgICAgZGF0YS5maW5kKCZtZWRpYVRpbWVVcyk7CisgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChuYW1lLnN0YXJ0c1dpdGgoQVN0cmluZ1ByaW50ZigiJXp1LXN5c3RlbS1uYW5vIiwgaW5kZXgpLmNfc3RyKCkpKSB7CisgICAgICAgICAgICAgICAgICAgIEFNZXNzYWdlOjpJdGVtRGF0YSBkYXRhID0gbXNnLT5nZXRFbnRyeUF0KGluZGV4KTsKKyAgICAgICAgICAgICAgICAgICAgZGF0YS5maW5kKCZzeXN0ZW1OYW5vKTsKKworICAgICAgICAgICAgICAgICAgICBNdXRleDo6QXV0b2xvY2sgX2wobUNvZGVjLT5tRnJhbWVSZW5kZXJlZENhbGxiYWNrTG9jayk7CisgICAgICAgICAgICAgICAgICAgIGlmIChtQ29kZWMtPm1GcmFtZVJlbmRlcmVkQ2FsbGJhY2sgIT0gTlVMTCkgeworICAgICAgICAgICAgICAgICAgICAgICAgbUNvZGVjLT5tRnJhbWVSZW5kZXJlZENhbGxiYWNrKAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtQ29kZWMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1Db2RlYy0+bUZyYW1lUmVuZGVyZWRDYWxsYmFja1VzZXJEYXRhLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZWRpYVRpbWVVcywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3lzdGVtTmFubyk7CisgICAgICAgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgICAgICBpbmRleCsrOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CisKICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgIEFMT0dFKCJzaG91bGRuJ3QgYmUgaGVyZSIpOwogICAgICAgICAgICAgYnJlYWs7CkBAIC00NTIsMTcgKzUwNiwxOSBAQAogICAgICAgICB1aW50MzJfdCBmbGFncykgewogICAgIHNwPEFNZXNzYWdlPiBuYXRpdmVGb3JtYXQ7CiAgICAgQU1lZGlhRm9ybWF0X2dldEZvcm1hdChmb3JtYXQsICZuYXRpdmVGb3JtYXQpOwotICAgIEFMT0dWKCJjb25maWd1cmUgd2l0aCBmb3JtYXQ6ICVzIiwgbmF0aXZlRm9ybWF0LT5kZWJ1Z1N0cmluZygwKS5jX3N0cigpKTsKKyAgICAvLyBjcmVhdGUgb3VyIHNoYWxsb3cgY29weSwgc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VsdFVybCA9IG1PYmotPm1EZWZhdWx0VXJsLnN0cmluZygpOworICAgICAgICBzd2l0Y2gocmVxdWVzdFR5cGUpIHsKKyAgICAgICAgICAgIGNhc2UgRHJtUGx1Z2luOjprS2V5UmVxdWVzdFR5cGVfSW5pdGlhbDoKKyAgICAgICAgICAgICAgICBtT2JqLT5ta2V5UmVxdWVzdFR5cGUgPSBLRVlfUkVRVUVTVF9UWVBFX0lOSVRJQUw7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIERybVBsdWdpbjo6a0tleVJlcXVlc3RUeXBlX1JlbmV3YWw6CisgICAgICAgICAgICAgICAgbU9iai0+bWtleVJlcXVlc3RUeXBlID0gS0VZX1JFUVVFU1RfVFlQRV9SRU5FV0FMOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBEcm1QbHVnaW46OmtLZXlSZXF1ZXN0VHlwZV9SZWxlYXNlOgorICAgICAgICAgICAgICAgIG1PYmotPm1rZXlSZXF1ZXN0VHlwZSA9IEtFWV9SRVFVRVNUX1RZUEVfUkVMRUFTRTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgRHJtUGx1Z2luOjprS2V5UmVxdWVzdFR5cGVfTm9uZToKKyAgICAgICAgICAgICAgICBtT2JqLT5ta2V5UmVxdWVzdFR5cGUgPSBLRVlfUkVRVUVTVF9UWVBFX05PTkU7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIERybVBsdWdpbjo6a0tleVJlcXVlc3RUeXBlX1VwZGF0ZToKKyAgICAgICAgICAgICAgICBtT2JqLT5ta2V5UmVxdWVzdFR5cGUgPSBLRVlfUkVRVUVTVF9UWVBFX1VQREFURTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgcmV0dXJuIEFNRURJQV9FUlJPUl9VTktOT1dOOworICAgIC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zTWVtb3J5LmNwcCIsCisgICAgICAgICJNZWRpYVV0aWxzRGVsYXllZC5jcHAiLAogICAgICAgICAiTWVtb3J5TGVha1RyYWNrVXRpbC5jcHAiLAorICAgICAgICAiTWV0aG9kU3RhdGlzdGljcy5jcHAiLAorICAgICAgICAiUHJvY2Vzcy5jcHAiLAogICAgICAgICAiUHJvY2Vzc0luZm8uY3BwIiwKICAgICAgICAgIlNjaGVkdWxpbmdQb2xpY3lTZXJ2aWNlLmNwcCIsCiAgICAgICAgICJTZXJ2aWNlVXRpbGl0aWVzLmNwcCIsCisgICAgICAgICJUaHJlYWRTbmFwc2hvdC5jcHAiLAogICAgICAgICAiVGltZUNoZWNrLmNwcCIsCisgICAgICAgICJUaW1lclRocmVhZC5jcHAiLAogICAgIF0sCiAgICAgc3RhdGljX2xpYnM6IFsKICAgICAgICAgImxpYmNfbWFsbG9jX2RlYnVnX2JhY2t0cmFjZSIsCkBAIC00Miw3ICs0OCw3IEBACiAgICAgXSwKICAgICBzaGFyZWRfbGliczogWwogICAgICAgICAibGliYXVkaW9jbGllbnRfYWlkbF9jb252ZXJzaW9uIiwKLSAgICAgICAgImxpYmF1ZGlvdXRpbHMiLCAvLyBmb3IgY2xvY2suaAorICAgICAgICAibGliYXVkaW91dGlscyIsIC8vIGZvciBjbG9jay5oLCBTdGF0aXN0aWNzLmgKICAgICAgICAgImxpYmJpbmRlciIsCiAgICAgICAgICJsaWJjdXRpbHMiLAogICAgICAgICAibGlibG9nIiwKQEAgLTUxLDYgKzU3LDcgQEAKICAgICAgICAgImxpYnBlcm1pc3Npb24iLAogICAgICAgICAiYW5kcm9pZC5oYXJkd2FyZS5ncmFwaGljcy5idWZmZXJxdWV1ZUAxLjAiLAogICAgICAgICAiYW5kcm9pZC5oaWRsLnRva2VuQDEuMC11dGlscyIsCisgICAgICAgICJwYWNrYWdlbWFuYWdlcl9haWRsLWNwcCIsCiAgICAgXSwKICAgICBleHBvcnRfc3RhdGljX2xpYl9oZWFkZXJzOi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gICAgICAgICAgICAgICBhdXRvIGRpZmYgPSBpdE5vdy0+c2Vjb25kIC0gaXRUaGVuLT5zZWNvbmQ7CisgICAgICAgICAgICAgICAgZGlmZiAqPSBsYXN0UnVuUGVyU2VjOworICAgICAgICAgICAgICAgIGF1dG8gdG90YWwgPSBpdE5vdy0+c2Vjb25kICogdG90YWxQZXJTZWM7CisgICAgICAgICAgICAgICAgZGlmZlN0cmluZy5hcHBlbmQoZGlmZktleSkuYXBwZW5kKCIgIGxhc3QtcnVuOiIpCisgICAgICAgICAgICAgICAgICAgICAgICAuYXBwZW5kKHN0ZDo6dG9fc3RyaW5nKGRpZmYpKQorICAgICAgICAgICAgICAgICAgICAgICAgLmFwcGVuZCgiICBjdW11bGF0aXZlOiIpCisgICAgICAgICAgICAgICAgICAgICAgICAuYXBwZW5kKHN0ZDo6dG9fc3RyaW5nKHRvdGFsKSkKKyAgICAgICAgICAgICAgICAgICAgICAgIC5hcHBlbmQoIlxuIik7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICB9CisKKyAgICBpZiAoIWRpZmZTdHJpbmcuZW1wdHkoKSkgeworICAgICAgICBzY2hlZE5vdy5hcHBlbmQoIioqKiBwZXIgc2Vjb25kIHN0YXRzICoqKlxuIikuYXBwZW5kKGRpZmZTdHJpbmcpOworICAgIH0KKworICAgIC8vIFJldHVybiBzbmFwc2hvdCBzdHJpbmcuCisgICAgcmV0dXJuIHNjaGVkTm93OworfQorCit9IC8vIGFuZHJvaWQ6Om1lZGlhdXRpbHMKZGlmZiAtLWdpdCBhL21lZGlhL3V0aWxzL1RpbWVDaGVjay5jcHAgYi9tZWRpYS91dGlscy9UaW1lQ2hlY2suY3BwCmluZGV4IDgxOWUxNDYuLjA4NDhlYjMgMTAwNjQ0Ci0tLSBhL21lZGlhL3V0aWxzL1RpbWVDaGVjay5jcHAKKysrIGIvbWVkaWEvdXRpbHMvVGltZUNoZWNrLmNwcApAQCAtMTYsMTIgKzE2LDgwIEBACiAKICNkZWZ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zID09IDAKKyAgICAgICAgICAgICAgPyBnZXRUaW1lQ2hlY2tUaHJlYWQoKS50cmFja1Rhc2sobVRpbWVDaGVja0hhbmRsZXItPnRhZykKKyAgICAgICAgICAgICAgOiBnZXRUaW1lQ2hlY2tUaHJlYWQoKS5zY2hlZHVsZVRhc2soCisgICAgICAgICAgICAgICAgICAgICAgbVRpbWVDaGVja0hhbmRsZXItPnRhZywKKyAgICAgICAgICAgICAgICAgICAgICAvLyBQYXNzIGluIGFsbCB0aGUgYXJndW1lbnRzIGJ5IHZhbHVlIHRvIHRoaXMgdGFzayBmb3Igc2FmZXR5LgorICAgICAgICAgICAgICAgICAgICAgIC8vIFRoZSB0aHJlYWQgY291bGQgY2FsbCB0aGUgY2FsbGJhY2sgYmVmb3JlIHRoZSBjb25zdHJ1Y3RvciBpcyBmaW5pc2hlZC4KKyAgICAgICAgICAgICAgICAgICAgICAvLyBUaGUgZGVzdHJ1Y3RvciBpcyBub3QgYmxvY2tlZCBvbiBjYWxsYmFjay4KKyAgICAgICAgICAgICAgICAgICAgICBbIHRpbWVDaGVja0hhbmRsZXIgPSBtVGltZUNoZWNrSGFuZGxlciBdIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgdGltZUNoZWNrSGFuZGxlci0+b25UaW1lb3V0KCk7CisgICAgICAgICAgICAgICAgICAgICAgfSwKKyAgICAgICAgICAgICAgICAgICAgICBzdGQ6OmNocm9ubzo6bWlsbGlzZWNvbmRzKHRpbWVvdXRNcykpKSB7fQorCiBUaW1lQ2hlY2s6On5UaW1lQ2hlY2soKSB7Ci0gICAgZ2V0VGltZUNoZWNrVGhyZWFkKCktPnN0b3BNb25pdG9yaW5nKG1FbmRUaW1lTnMpOwotfQotCi1UaW1lQ2hlY2s6OlRpbWVDaGVja1RocmVhZDo6flRpbWVDaGVja1RocmVhZCgpCi17Ci0gICAgQXV0b011dGV4IF9sKG1NdXRleCk7Ci0gICAgcmVxdWVzdEV4aXQoKTsKLSAgICBtTW9uaXRvclJ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AgIHN0ZDo6c2hhcmVkX3B0cjxNZXRob2RTdGF0aXN0aWNzPHN0ZDo6c3RyaW5nPj4gc3RhdGlzdGljcyA9CisgICAgICAgICAgICBtZWRpYXV0aWxzOjpnZXRTdGF0aXN0aWNzRm9yQ2xhc3MoY2xhc3NOYW1lKTsKKyAgICBpZiAoIXN0YXRpc3RpY3MpIHJldHVybiB7fTsgLy8gZW1wdHkgVGltZUNoZWNrLgorICAgIHJldHVybiBtZWRpYXV0aWxzOjpUaW1lQ2hlY2soCisgICAgICAgICAgICBzdGQ6OnN0cmluZyhjbGFzc05hbWUpLmFwcGVuZCgiOjoiKS5hcHBlbmQobWV0aG9kTmFtZSksCisgICAgICAgICAgICBbIGNsYXp6ID0gc3RkOjpzdHJpbmcoY2xhc3NOYW1lKSwgbWV0aG9kID0gc3RkOjpzdHJpbmcobWV0aG9kTmFtZSksCisgICAgICAgICAgICAgIHN0YXRzID0gc3RkOjptb3ZlKHN0YXRpc3RpY3MpIF0KKyAgICAgICAgICAgIChib29sIHRpbWVvdXQsIGZsb2F0IGVsYXBzZWRNcykgeworICAgICAgICAgICAgICAgICAgICBpZiAodGltZW91dCkgeworICAgICAgICAgICAgICAgICAgICAgICAgOyAvLyBpZ25vcmVkLCB0aGVyZSBpcyBubyB0aW1lb3V0IHZhbHVlLgorICAgICAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHMtPmV2ZW50KG1ldGhvZCwgZWxhcHNlZE1zKTsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfSwgMCAvKiB0aW1lb3V0TXMgKi8pOworfQorCit9ICAvLyBuYW1lc3BhY2UgYW5kcm9pZDo6bWVkaWF1dGlscwpkaWZmIC0tZ2l0IGEvbWVkaWEvdXRpbHMvVGltZXJUaHJlYWQtdGVzdC5jcHAgYi9tZWRpYS91dGlscy9UaW1lclRocmVhZC10ZXN0LmNwcApuZXcgZmlsZSBtb2RlIDEwMDY0N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RfQVVESU8pOworfQorCitUaW1lclRocmVhZDo6TW9uaXRvclRocmVhZDo6fk1vbml0b3JUaHJlYWQoKSB7CisgICAgeworICAgICAgICBzdGQ6OmxvY2tfZ3VhcmQgX2wobU11dGV4KTsKKyAgICAgICAgbVNob3VsZEV4aXQgPSB0cnVlOworICAgICAgICBtQ29uZC5ub3RpZnlfYWxsKCk7CisgICAgfQorICAgIG1UaHJlYWQuam9pbigpOworfQorCit2b2lkIFRpbWVyVGhyZWFkOjpNb25pdG9yVGhyZWFkOjp0aHJlYWRGdW5jKCkgeworICAgIHN0ZDo6dW5pcXVlX2xvY2sgX2wobU11dGV4KTsKKyAgICB3aGlsZSAoIW1TaG91bGRFeGl0KSB7CisgICAgICAgIGlmICghbU1vbml0b3JSZXF1ZXN0cy5lbXB0eSgpKSB7CisgICAgICAgICAgICBIYW5kbGUgbmV4dERlYWRsaW5lID0gbU1vbml0b3JSZXF1ZXN0cy5iZWdpbigpLT5maXJzdDsKKyAgICAgICAgICAgIGlmIChuZXh0RGVhZGxpbmUgPCBzdGQ6OmNocm9ubzo6c3RlYWR5X2Nsb2NrOjpub3coKSkgeworICAgICAgICAgICAgICAgIC8vIERlYWRsaW5lIGhhcyBleHBpcmVkLCBoYW5kbGUgdGhlIHJlcXVlc3QuCisgICAgICAgICAgICAgICAgeworICAgICAgICAgICAgICAgICAgICBhdXRvIG5vZGUgPSBtTW9uaXRvclJlcXVlc3RzLmV4dHJhY3QobU1vbml0b3JSZXF1ZXN0cy5iZWdpbigpKTsKKyAgICAgICAgICAgICAgICAgICAgX2wudW5sb2NrKCk7CisgICAgICAgICAgICAgICAgICAgIC8vIFdlIGFkZCBSZXF1ZXN0IHRvIHJldGlyZWQgcXVldWUgZWFybHkgc28gdGhhdCBpdCBjYW4gYmUgZHVtcGVkIG91dC4KKyAgICAgICAgICAgICAgICAgICAgbVRpbWVvdXRRdWV1ZS5hZGQoc3RkOjptb3ZlKG5vZGUubWFwcGVkKCkuZmlyc3QpKTsKKyAgICAgICAgICAgICAgICAgICAgbm9kZS5tYXBwZWQoKS5zZWNvbmQoKTsgLy8gQ2F1dGlvbjogd2UgZG9uJ3QgaG9sZCBsb2NrIGhlcmUgLSBidXQgZG8gd2UgY2FyZT8KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gdGhpcyBpcyB0aGUgdGltZW91dCBjYXNlISAgV2Ugd2lsbCBjcmFzaCBzb29uLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBtYXliZSBiZWZvcmUgcmV0dXJuaW5nLgorICAgICAgICAgICAgICAgICAgICAvLyBhbnl0aGluZyBsZWZ0IG92ZXIgaXMgcmVsZWFzZWQgaGVyZSBvdXRzaWRlIGxvY2suCisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIC8vIHJlYWNxdWlyZSB0aGUgbG9jayAtIGlmIHNvbWV0aGluZyB3YXMgYWRkZWQsIHdlIGxvb3AgaW1tZWRpYXRlbHkgdG8gY2hlY2suCisgICAgICAgICAgICAgICAgX2wubG9jaygpOworICAgICAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICAgICAgfQorICAgICAgICAgICAgbUNvbmQud2FpdF91bnRpbChfbCwgbmV4dERlYWRsaW5lKTsKKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIG1Db25kLndhaXQoX2wpOworICAgICAgICB9CisgICAgfQorfQorCitUaW1lclRocmVhZDo6SGFuZGxlIFRpbWVyVGhyZWFkOjpNb25pdG9yVGhyZWFkOjphZGQoCisgICAgICAgIHN0ZDo6c2hhcmVkX3B0cjxjb25zdCBSZXF1ZXN0PiByZXF1ZXN0LCBzdGQ6OmZ1bmN0aW9uPHZvaWQoKT4mJiBmdW5jLAorICAgICAgICBzdGQ6OmNocm9ubzo6bWlsbGlzZWNvbmRzIHRpbWVvdXQpIHsKKyAgICBzdGQ6OmxvY2tfZ3VhcmQgX2wobU11dGV4KTsKKyAgICB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Do6bG9ja19ndWFyZCBsZyhtTG9jayk7CisgICAgICAgIGF1dG8gaXQgPSBtU3RhdGlzdGljc01hcC5maW5kKGNvZGUpOworICAgICAgICByZXR1cm4gaXQgPT0gbVN0YXRpc3RpY3NNYXAuZW5kKCkgPyAwIDogaXQtPnNlY29uZC5nZXROKCk7CisgICAgfQorCisgICAgLyoqCisgICAgICogUmV0dXJucyB0aGUgc3RhdGlzdGljcyBvYmplY3QgZm9yIHRoZSBtZXRob2QuCisgICAgICovCisgICAgU3RhdHNUeXBlIGdldFN0YXRpc3RpY3MoQ29kZSBjb2RlKSBjb25zdCB7CisgICAgICAgIHN0ZDo6bG9ja19ndWFyZCBsZyhtTG9jayk7CisgICAgICAgIGF1dG8gaXQgPSBtU3RhdGlzdGljc01hcC5maW5kKGNvZGUpOworICAgICAgICByZXR1cm4gaXQgPT0gbVN0YXRpc3RpY3NNYXAuZW5kKCkgPyBTdGF0c1R5cGV7fSA6IGl0LT5zZWNvbmQ7CisgICAgfQorCisgICAgLyoqCisgICAgICogRHVtcHMgdGhlIGN1cnJlbnQgbWV0aG9kIHN0YXRpc3RpY3MuCisgICAgICovCisgICAgc3RkOjpzdHJpbmcgZHVtcCgpIGNvbnN0IHsKKyAgICAgICAgc3RkOjpzdHJpbmdzdHJlYW0gc3M7CisgICAgICAgIHN0ZDo6bG9ja19ndWFyZCBsZyhtTG9jayk7CisgICAgICAgIGlmIGNvbnN0ZXhwciAoc3RkOjppc19zYW1lX3Y8Q29kZSwgc3RkOjpzdHJpbmc+KSB7CisgICAgICAgICAgICBmb3IgKGNvbnN0IGF1dG8gJltjb2RlLCBzdGF0c10gOiBtU3RhdGlzdGljc01hcCkgeworICAgICAgICAgICAgICAgIHNzIDw8IGNvZGUgPDwKKyAgICAgICAgICAgICAgICAgICAgICAgICIgbj0iIDw8IHN0YXRzLmdldE4oKSA8PCAiICIgPDwgc3RhdHMudG9TdHJpbmcoKSA8PCAiXG4iOworICAgICAgICAgICAgfQorICAgICAgICB9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1sL2xhdGVzdC9zY2hlZHVsZXIvaW5kZXguaHRtbAorICogaHR0cHM6Ly9tYW43Lm9yZy9saW51eC9tYW4tcGFnZXMvbWFuNy9zY2hlZC43Lmh0bWwKKyAqCisgKiBTYW1wbGUgYXMgZm9sbG93czoKKworQXVkaW9PdXRfOEQgKDEwODAwLCAjdGhyZWFkczogMzYpCistLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCitzZS5leGVjX3N0YXJ0ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgIDgxMzIwNzcuNTk4MDI2CitzZS52cnVudGltZSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICA3OTg2ODkuODcyMDg3CitzZS5zdW1fZXhlY19ydW50aW1lICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAxMzY0NjYuOTU3ODM4CitzZS5ucl9taWdyYXRpb25zICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgMTMyNDg3CitzZS5zdGF0aXN0aWNzLnN1bV9zbGVlcF9ydW50aW1lICAgICAgICAgICAgICA6ICAgICAgIDU2Mjk3OTQuNTY1OTQ1CitzZS5zdGF0aXN0aWNzLndhaXRfc3RhcnQgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgIDAuMDAwMDAwCitzZS5zdGF0aXN0aWNzLnNsZWVwX3N0YXJ0ICAgICAgICAgICAgICAgICAgICA6ICAgICAgIDgxOTU3MjcuNTg2MzkyCitzZS5zdGF0aXN0aWNzLmJsb2NrX3N0YXJ0ICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgIDAuMDAwMDAwCitzZS5zdGF0aXN0aWNzLnNsZWVwX21heCAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgIDE5OTU2NjUuODY5ODA4CitzZS5zdGF0aXN0aWNzLmJsb2NrX21heCAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgIDAuNTkxNjc1CitzZS5zdGF0aXN0aWNzLmV4ZWNfbWF4ICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgIDIuNDc3NTgwCitzZS5zdGF0aXN0aWNzLnNsaWNlX21heCAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgIDAuMDAwMDAwCitzZS5zdGF0aXN0aWNzLndhaXRfbWF4ICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgIDguNjA4NjQyCitzZS5zdGF0aXN0aWNzLndhaXRfc3VtICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgIDQ2ODMuMjY2ODM1CitzZS5zdGF0aXN0aWNzLndhaXRfY291bnQgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgMzAwOTY0CitzZS5zdGF0aXN0aWNzLmlvd2FpdF9zdW0gICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgIDAuMDAwMDAwCitzZS5zdGF0aXN0aWNzLmlvd2FpdF9jb3VudCAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAwCitzZS5zdGF0aXN0aWNzLm5yX21pZ3JhdGlvbnNfY29sZCAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAwCitzZS5zdGF0aXN0aWNzLm5yX2ZhaWxlZF9taWdyYXRpb25zX2FmZmluZSAgICA6ICAgICAgICAgICAgICAgICAgMjk3CitzZS5zdGF0aXN0aWNzLm5yX2ZhaWxlZF9taWdyYXRpb25zX3J1bm5pbmcgICA6ICAgICAgICAgICAgICAgICAxNDEyCitzZS5zdGF0aXN0aWNzLm5yX2ZhaWxlZF9taWdyYXRpb25zX2hvdCAgICAgICA6ICAgICAgICAgICAgICAgICAgIDk2CitzZS5zdGF0aXN0aWNzLm5yX2ZvcmNlZF9taWdyYXRpb25zICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgIDI2CitzZS5zdGF0aXN0aWNzLm5yX3dha2V1cHMgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgMjgxMjYzCitzZS5zdGF0aXN0aWNzLm5yX3dha2V1cHNfc3luYyAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgIDg0CitzZS5zdGF0aXN0aWNzLm5yX3dha2V1cHNfbWlncmF0ZSAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgMTMyMzIyCitzZS5zdGF0aXN0aWNzLm5yX3dha2V1cHNfbG9jYWwgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAyMTY1CitzZS5zdGF0aXN0aWNzLm5yX3dha2V1cHNfcmVtb3RlICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgMjc5MDk4CitzZS5zdGF0aXN0aWNzLm5yX3dha2V1cHNfYWZmaW5lICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAwCitzZS5zdGF0aXN0aWNzLm5yX3dha2V1cHNfYWZmaW5lX2F0dGVtcHRzICAgICA6ICAgICAgICAgICAgICAgICAgICAwCitzZS5zdGF0aXN0aWNzLm5yX3dha2V1cHNfcGFzc2l2ZSAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAwCitzZS5zdGF0aXN0aWNzLm5yX3dha2V1cHNfaWRsZSAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAwCithdmdfYXRvbSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgIDAuNDUzNDM0CithdmdfcGVyX2NwdSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgIDEuMDMwMDQwCitucl9zd2l0Y2hlcyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgMzAwOTYzCitucl92b2x1bnRhcnlfc3dpdGNoZXMgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgMjgxMjUyCitucl9pbnZvbHVudGFyeV9zd2l0Y2hlcyAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgIDE5NzExCitzZS5sb2FkLndlaWdodCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgIDczNDc3MTIwCitzZS5hdmcubG9hZF9zdW0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgIDU4CitzZS5hdmcucnVubmFibGVfc3VtICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgIDI3NjQ4CitzZS5hdmcudXRpbF9zdW0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgIDIxNTA0CitzZS5hdmcubG9hZF9hdmcgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgIDQ4CitzZS5hdmcucnVubmFibGVfYXZnICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAwCitzZS5hdmcudXRpbF9hdmcgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAwCitzZS5hdmcubGFzdF91cGRhdGVfdGltZSAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICA4MTMyMDc1ODI0MTI4CitzZS5hdmcudXRpbF9lc3QuZXdtYSAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICA4CitzZS5hdmcudXRpbF9lc3QuZW5xdWV1ZWQgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAxCit1Y2xhbXAubWluICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAwCit1Y2xhbXAubWF4ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAxMDI0CitlZmZlY3RpdmUgdWNsYW1wLm1pbiAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAwCitlZmZlY3RpdmUgdWNsYW1wLm1heCAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAxMDI0Citwb2xpY3kgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAwCitwcmlvICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgMTAxCitjbG9jay1kZWx0YSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgMTYzCisqLworc3RkOjpzdHJpbmcgZ2V0VGhyZWFkU2NoZWRBc1N0cmluZyhwaWRfdCB0aWQpOworCisvKioKKyAqIFJldHVybnMgbWFwIGZvciB0aGUgcmF3IHRocmVhZCBzY2hlZHVsZSBzdHJpbmcuCisgKi8KK3N0ZDo6bWFwPHN0ZDo6c3RyaW5nLCBkb3VibGU+IHBhcnNlVGhyZWFkU2NoZWRTdHJpbmcoY29uc3Qgc3RkOjpzdHJpbmcmIHNjaGVkU3RyaW5nKTsKKworLyoqCisgKiBSZXR1cm5zIG1hcCBmb3IgL3Byb2MvcGlkL3Rhc2svdGlkL3NjaGVkCisgKi8KK2lubGluZSBzdGQ6Om1hcDxzdGQ6OnN0cmluZywgZG91YmxlPiBnZXRUaHJlYWRTY2hlZEFzTWFwKHBpZF90IHRpZCkgeworICAgIHJldHVybiBwYXJzZVRocmVhZFNjaGVkU3RyaW5nKGdldFRocmVhZFNjaGVkQXNTdHJpbmcodGlkKSk7Cit9CisKKy8vIFRPRE86IEV4dGVuZCB0byBvdGhlciAvcHJvYy9waWQgZmlsZSBpbmZvcm1hdGlvbi4KKy8vCisvLyBTZWUgInBzIiBjb21tYW5kIGdldF9wcygpLgorLy8gaHR0cHM6Ly9jcy5hbmRyb2lkLmNvbS9hbmRyb2lkL3BsYXRmb3JtL3N1cGVycHJvamVjdC8rL21hc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YWxsYmFjayBmdW5jdGlvbiByZXR1cm5zIGZvciB0aW1lb3V0IGl0IHdpbGwgbm90IGJlIGNhbGxlZCBhZ2FpbiBmb3IKKyAgICAgKiB0aGUgZGVhbGxvY2F0aW9uLgorICAgICAqCisgICAgICogXHBhcmFtIHRhZyAgICAgICBzdHJpbmcgYXNzb2NpYXRlZCB3aXRoIHRoZSBUaW1lQ2hlY2sgb2JqZWN0LgorICAgICAqIFxwYXJhbSBvblRpbWVyICAgY2FsbGJhY2sgZnVuY3Rpb24gd2l0aCAyIHBhcmFtZXRlcnMKKyAgICAgKiAgICAgICAgICAgICAgICAgICAgICBib29sIHRpbWVvdXQgICh3aGljaCBpcyB0cnVlIHdoZW4gdGhlIFRpbWVDaGVjayBvYmplY3QKKyAgICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpbWVzIG91dCwgZmFsc2Ugd2hlbiB0aGUgVGltZUNoZWNrIG9iamVjdCBpcworICAgICAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdHJveWVkIG9yIGxlYXZlcyBzY29wZSBiZWZvcmUgdGhlIHRpbWVyIGV4cGlyZXMuKQorICAgICAqICAgICAgICAgICAgICAgICAgICAgIGZsb2F0IGVsYXBzZWRNcyAodGhlIGVsYXBzZWQgdGltZSB0byB0aGlzIGV2ZW50KS4KKyAgICAgKiAgICAgICAgICAgICAgICAgIFRoZSBjYWxsYmFjayB3aGVuIHRpbWVvdXQgaXMgdHJ1ZSB3aWxsIGJlIGNhbGxlZCBvbiBhIGRpZmZlcmVudCB0aHJlYWQuCisgICAgICogICAgICAgICAgICAgICAgICBUaGlzIHdpbGwgY2FuY2VsIHRoZSBjYWxsYmFjayBvbiB0aGUgZGVzdHJ1Y3RvciBidXQgaXMgbm90IGd1YXJhbnRlZWQKKyAgICAgKiAgICAgICAgICAgICAgICAgIHRvIGJsb2NrIGZvciBjYWxsYmFjayBjb21wbGV0aW9uIGlmIGl0IGlzIGFscmVh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6Om1pbigpOworCisgICAgLyoqCisgICAgICogU2NoZWR1bGVzIGEgdGFzayB0byBiZSBleGVjdXRlZCBpbiB0aGUgZnV0dXJlIChgdGltZW91dGAgZHVyYXRpb24gZnJvbSBub3cpLgorICAgICAqCisgICAgICogXHBhcmFtIHRhZyAgICAgc3RyaW5nIGFzc29jaWF0ZWQgd2l0aCB0aGUgdGFzay4gIFRoaXMgbmVlZCBub3QgYmUgdW5pcXVlLAorICAgICAqICAgICAgICAgICAgICAgIGFzIHRoZSBIYW5kbGUgcmV0dXJuZWQgaXMgdXNlZCBmb3IgY2FuY2VsbGluZy4KKyAgICAgKiBccGFyYW0gZnVuYyAgICBjYWxsYmFjayBmdW5jdGlvbiB0aGF0IGlzIGludm9rZWQgYXQgdGhlIHRpbWVvdXQuCisgICAgICogXHBhcmFtIHRpbWVvdXQgdGltZW91dCBkdXJhdGlvbiB3aGljaCBpcyBjb252ZXJ0ZWQgdG8gbWlsbGlzZWNvbmRzIHdpdGggYXQKKyAgICAgKiAgICAgICAgICAgICAgICBsZWFzdCA0NSBpbnRlZ2VyIGJpdHMuCisgICAgICogICAgICAgICAgICAgICAgQSB0aW1lb3V0IG9mIDAgKG9yIG5lZ2F0aXZlKSBtZWFucyB0aGUgdGltZXIgbmV2ZXIgZXhwaXJlcworICAgICAqICAgICAgICAgICAgICAgIHNvIGZ1bmMoKSBpcyBuZXZlciBjYWxsZWQuIFRoZXNlIHRhc2tzIGFyZSBzdG9yZWQgaW50ZXJuYWxseQorICAgICAqICAgICAgICAgICAgICAgIGFuZCByZXBvcnRlZCBpbiB0aGUgdG9TdHJpbmcoKSB1bnRpbCBtYW51YWxseSBjYW5jZWxsZWQuCisgICAgICogXHJldHVybnMgICAgICAgYSBoYW5kbGUgdGhhdCBjYW4gYmUgdXNlZCBmb3IgY2FuY2VsbGF0aW9uLgorICAgICAqLworICAgIEhhbmRsZSBzY2hlZHVsZVRhc2soCisgICAgICAgICAgICBzdGQ6OnN0cmluZyB0YWcsIH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isgICAgc3RydWN0IFJlcXVlc3QgeworICAgICAgICBjb25zdCBzdGQ6OmNocm9ubzo6c3lzdGVtX2Nsb2NrOjp0aW1lX3BvaW50IHNjaGVkdWxlZDsKKyAgICAgICAgY29uc3Qgc3RkOjpjaHJvbm86OnN5c3RlbV9jbG9jazo6dGltZV9wb2ludCBkZWFkbGluZTsgLy8gZGVhZGxpbmUgOj0gc2NoZWR1bGVkICsgdGltZW91dAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBpZiBkZWFkbGluZSA9PSBzY2hlZHVsZWQsIG5vCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHRpbWVvdXQsIHRhc2sgbm90IGV4ZWN1dGVkLgorICAgICAgICBjb25zdCBwaWRfdCB0aWQ7CisgICAgICAgIGNvbnN0IHN0ZDo6c3RyaW5nIHRhZzsKKworICAgICAgICBzdGQ6OnN0cmluZyB0b1N0cmluZygpIGNvbnN0OworICAgIH07CisKKyAgICAvLyBEZXF1ZSBvZiByZXF1ZXN0cywgaW4gb3JkZXIgb2YgYWRkKCkuCisgICAgLy8gVGhpcyBjbGFzcyBpcyB0aHJlYWQtc2FmZS4KKyAgICBjbGFzcyBSZXF1ZXN0UXVldWUgeworICAgICAgcHVibGljOgorICAgICAgICBleHBsaWNpdCBSZXF1ZXN0UXVldWUoc2l6ZV90IG1heFNpemUpCisgICAgICAgICAgICA6IG1SZXF1ZXN0UXVldWVNYXgobWF4U2l6ZSkge30KKworICAgICAgICB2b2lkIGFkZChzdGQ6OnNoYXJlZF9wdHI8Y29uc3QgUmVxdWVzdD4pOworCisgICAgICAgIC8vIHJldHVybiB1cCB0byB0aGUgbGFzdCAibiIgcmVxdWVzdHMgcmV0aXJlZC4KKyAgICAgICAgdm9pZCBjb3B5UmVxdWVzdHMoc3RkOjp2ZWN0b3I8c3RkOjpzaGFyZWRfc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RyYSIsCisgICAgXSwKKworICAgIHNhbml0aXplOnsKKyAgICAgICBhZGRyZXNzOiB0cnVlLAorICAgICAgIGNmaTogdHJ1ZSwKKyAgICAgICBpbnRlZ2VyX292ZXJmbG93OiB0cnVlLAorICAgICAgIG1lbXRhZ19oZWFwOiB0cnVlLAorICAgIH0sCisKKyAgICBzaGFyZWRfbGliczogWworICAgICAgICAibGlibG9nIiwKKyAgICBdLAorCisgICAgc3JjczogWworICAgICAgICAic2hhcmVkdGVzdC5jcHAiLAorICAgIF0KK30KKworY2NfdGVzdCB7CisgICAgbmFtZTogImxpYnJhcnlfdGVzdHMiLAorCisgICAgY2ZsYWdzOiBbCisgICAgICAgICItV2FsbCIsCisgICAgICAgICItV2Vycm9yIiwKKyAgICAgICAgIi1XZXh0cmEiLAorICAgIF0sCisKKyAgICBzYW5pdGl6ZTp7CisgICAgICAgYWRkcmVzczogdHJ1ZSwKKyAgICAgICBjZmk6IHRydWUsCisgICAgICAgaW50ZWdlcl9vdmVyZmxvdzogdHJ1ZSwKKyAgICAgICBtZW10YWdfaGVhcDogdHJ1ZSwKKyAgICB9LAorCisgICAgc2hhcmVkX2xpYnM6IFsKKyAgICAgICAgImxpYmJhc2UiLAorICAgICAgICAibGlibG9nIiwKKyAgICAgICAgImxpYm1lZGlhdXRpbHMiLAorICAgICAgICAibGlidXRpbHMiLAorICAgIF0sCisKKyAgICBkYXRhX2xpYnM6IFsKKyAgICAgICAgImxpYnNoYXJlZHRlc3QiLAorICAgIF0sCisKKyAgICBzcmNzOiBbCisgICAgICAgICJsaWJyYXJ5X3Rlc3RzLmNwcCIsCisgICAgXSwKK30KKworY2NfdGVzdCB7CisgICAgbmFtZTogIm1lZGlhX3Byb2Nlc3NfdGVzdHMiLAorCisgICAgY2ZsYWdzOiBbCisgICAgICAgICItV2FsbCIsCisgICAgICAgICItV2Vycm9yIiwKKyAgICAgICAgIi1XZXh0cmEiLAorICAgIF0sCisKKyAgICBzaGFyZWRfbGliczogWworICAgICAgICAibGlibG9nIiwKKyAgICAgICAgImxpYm1lZGlhdXRpbHMiLAorICAgICAgICAibGlidXRpbHMiLAorICAgIF0sCisKKyAgICBzcmNzOiBbCisgICAgICAgICJtZWRpYV9wcm9jZXNzX3Rlc3RzLmNwcCIsCisgICAgXSwKK30KKwogY2NfdGVzdCB7CiAgICAgbmFtZTogIm1lZGlhX3N5bmNocm9uaXphdGlvbl90ZXN0cyIsCiAKQEAgLTI2LDMgKzEwMiw5MiBAQAogICAgICAgICAibWVkaWFfc3luY2hyb25pemF0aW9uX3Rlc3RzLmNwcCIsCiAgICAgXSwKIH0KKworY2NfdGVzdCB7CisgICAgbmFtZTogIm1lZGlhX3RocmVhZHNuYXBzaG90X3Rlc3RzIiwKKworICAgIGNmbGFnczogWworICAgICAgICAiLVdhbGwiLAorICAgICAgICAiLVdlcnJvciIsCisgICAgICAgICItV2V4dHJhIiwKKyAgICBdLAorCisgICAgc2hhcmVkX2xpYnM6IFsKKyAgICAgICAgImxpYmxvZyIsCisgICAgICAgICJsaWJtZWRpYXV0aWxzIiwKKyAgICAgICAgImxpYnV0aWxzIiwKKyAgICBdLAorCisgICAgc3JjczogWworICAgICAgICAibWVkaWFfdGhyZWFkc25hcHNob3RfdGVzdHMuY3BwIiwKKyAgICBdLAorfQorCitjY190ZXN0IHsKKyAgICBuYW1lOiAibWVkaWF1dGlsc19zY29wZWRzdGF0aXN0aWNzX3Rlc3RzIiwKKworICAgIGNmbGFnczogWworICAgICAgICAiLVdhbGwiLAorICAgICAgICAiLVdlcnJvciIsCisgICAgICAgICItV2V4dHJhIiwKKyAgICBdLAorCisgICAgc2hhcmVkX2xpYnM6IFsKKyAgICAgICAgImxpYmF1ZGlvdXRpbHMiLAorICAgICAgICAibGlibG9nIiwKKyAgICAgICAgImxpYm1lZGlhdXRpbHMiLAorICAgICAgICAibGlidXRpbHMiLAorICAgIF0sCisKKyAgICBzcmNzOiBbCisgICAgICAgICJtZWRpYXV0aWxzX3Njb3BlZHN0YXRpc3RpY3NfdGVzdHMuY3BwIiwKKyAgICBdLAorfQorCitjY190ZXN0IHsKKyAgICBuYW1lOiAibWV0aG9kc3RhdGlzdGljc190ZXN0cyIsCisKKyAgICBjZmxhZ3M6IFsKKyAgICAgICAgIi1XYWxsIiwKKyAgICAgICAgIi1XZXJyb3IiLAorICAgICAgICAiLVdleHRyYSIsCisgICAgXSwKKworICAgIHNoYXJlZF9saWJzOiBbCisgICAgICAgICJsaWJhdWRpb3V0aWxzIiwKKyAgICAgICAgImxpYmxvZyIsCisgICAgICAgICJsaWJtZWRpYXV0aWxzIiwKKyAgICAgICAgImxpYnV0aWxzIiwKKyAgICBdLAorCisgICAgc3JjczogWworICAgICAgICAibWV0aG9kc3RhdGlzdGljc190ZXN0cy5jcHAiLAorICAgIF0sCit9CisKK2NjX3Rlc3QgeworICAgIG5hbWU6ICJ0aW1lY2hlY2tfdGVzdHMiLAorCisgICAgY2ZsYWdzOiBbCisgICAgICAgICItV2FsbCIsCisgICAgICAgICItV2Vycm9yIiwKKyAgICAgICAgIi1XZXh0cmEiLAorICAgIF0sCisKKyAgICBzYW5pdGl6ZTp7CisgICAgICAgYWRkcmVzczogdHJ1ZSwKKyAgICAgICBjZmk6IHRydWUsCisgICAgICAgaW50ZWdlcl9vdmVyZmxvdzogdHJ1ZSwKKyAgICAgICBtZW10YWdfaGVhcDogdHJ1ZSwKKyAgICB9LAorCisgICAgc2hhcmVkX2xpYnM6IFsKKyAgICAgICAgImxpYmxvZyIsCisgICAgICAgICJsaWJtZWRpYXV0aWxzIiwKKyAgICAgICAgImxpYnV0aWxzIiwKKyAgICBdLAorCisgICAgc3JjczogWworICAgICAgICAidGltZWNoZWNrX3Rlc3RzLmNwcCIsCisgICAgXSwKK30KZGlmZiAtLWdpdCBhL21lZGlhL3V0aWxzL3Rlc3RzL2xpYnJhcnlfdGVzdHMuY3BwIGIvbWVkaWEvdXRpbHMvdGVzdHMvbGlicmFyeV90ZXN0cy5jcHAKbmV3IGZpbGUgbW9kZ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c3RhcnQgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgIDAuMDAwMDAwXG5cCitzZS5zdGF0aXN0aWNzLnNsZWVwX3N0YXJ0ICAgICAgICAgICAgICAgICAgICA6ICAgICAgIDgxOTU3MjcuNTg2MzkyXG5cCitzZS5zdGF0aXN0aWNzLmJsb2NrX3N0YXJ0ICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgIDAuMDAwMDAwXG5cCitzZS5zdGF0aXN0aWNzLnNsZWVwX21heCAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgIDE5OTU2NjUuODY5ODA4XG5cCitzZS5zdGF0aXN0aWNzLmJsb2NrX21heCAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgIDAuNTkxNjc1XG5cCitzZS5zdGF0aXN0aWNzLmV4ZWNfbWF4ICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgIDIuNDc3NTgwXG5cCitzZS5zdGF0aXN0aWNzLnNsaWNlX21heCAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgIDAuMDAwMDAwXG5cCitzZS5zdGF0aXN0aWNzLndhaXRfbWF4ICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgIDguNjA4NjQyXG5cCitzZS5zdGF0aXN0aWNzLndhaXRfc3VtICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgIDQ2ODMuMjY2ODM1XG5cCitzZS5zdGF0aXN0aWNzLndhaXRfY291bnQgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgMzAwOTY0XG5cCitzZS5zdGF0aXN0aWNzLmlvd2FpdF9zdW0gICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgIDAuMDAwMDAwXG5cCitzZS5zdGF0aXN0aWNzLmlvd2FpdF9jb3VudCAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAwXG5cCitzZS5zdGF0aXN0aWNzLm5yX21pZ3JhdGlvbnNfY29sZCAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAwXG5cCitzZS5zdGF0aXN0aWNzLm5yX2ZhaWxlZF9taWdyYXRpb25zX2FmZmluZSAgICA6ICAgICAgICAgICAgICAgICAgMjk3XG5cCitzZS5zdGF0aXN0aWNzLm5yX2ZhaWxlZF9taWdyYXRpb25zX3J1bm5pbmcgICA6ICAgICAgICAgICAgICAgICAxNDEyXG5cCitzZS5zdGF0aXN0aWNzLm5yX2ZhaWxlZF9taWdyYXRpb25zX2hvdCAgICAgICA6ICAgICAgICAgICAgICAgICAgIDk2XG5cCitzZS5zdGF0aXN0aWNzLm5yX2ZvcmNlZF9taWdyYXRpb25zICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgIDI2XG5cCitzZS5zdGF0aXN0aWNzLm5yX3dha2V1cHMgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgMjgxMjYzXG5cCitzZS5zdGF0aXN0aWNzLm5yX3dha2V1cHNfc3luYyAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgIDg0XG5cCitzZS5zdGF0aXN0aWNzLm5yX3dha2V1cHNfbWlncmF0ZSAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgMTMyMzIyXG5cCitzZS5zdGF0aXN0aWNzLm5yX3dha2V1cHNfbG9jYWwgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAyMTY1XG5cCitzZS5zdGF0aXN0aWNzLm5yX3dha2V1cHNfcmVtb3RlICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgMjc5MDk4XG5cCitzZS5zdGF0aXN0aWNzLm5yX3dha2V1cHNfYWZmaW5lICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAwXG5cCitzZS5zdGF0aXN0aWNzLm5yX3dha2V1cHNfYWZmaW5lX2F0dGVtcHRzICAgICA6ICAgICAgICAgICAgICAgICAgICAwXG5cCitzZS5zdGF0aXN0aWNzLm5yX3dha2V1cHNfcGFzc2l2ZSAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAwXG5cCitzZS5zdGF0aXN0aWNzLm5yX3dha2V1cHNfaWRsZSAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAwXG5cCithdmdfYXRvbSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgIDAuNDUzNDM0XG5cCithdmdfcGVyX2NwdSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgIDEuMDMwMDQwXG5cCitucl9zd2l0Y2hlcyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgMzAwOTYzXG5cCitucl92b2x1bnRhcnlfc3dpdGNoZXMgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgMjgxMjUyXG5cCitucl9pbnZvbHVudGFyeV9zd2l0Y2hlcyAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgIDE5NzExXG5cCitzZS5sb2FkLndlaWdodCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgIDczNDc3MTIwXG5cCitzZS5hdmcubG9hZF9zdW0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgIDU4XG5cCitzZS5hdmcucnVubmFibGVfc3VtICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgIDI3NjQ4XG5cCitzZS5hdmcudXRpbF9zdW0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgIDIxNTA0XG5cCitzZS5hdmcubG9hZF9hdmcgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgIDQ4XG5cCitzZS5hdmcucnVubmFibGVfYXZnICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAwXG5cCitzZS5hdmcudXRpbF9hdmcgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAwXG5cCitzZS5hdmcubGFzdF91cGRhdGVfdGltZSAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICA4MTMyMDc1ODI0MTI4XG5cCitzZS5hdmcudXRpbF9lc3QuZXdtYSAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICA4XG5cCitzZS5hdmcudXRpbF9lc3QuZW5xdWV1ZWQgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAxXG5cCit1Y2xhbXAubWluICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAwXG5cCit1Y2xhbXAubWF4ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAxMDI0XG5cCitlZmZlY3RpdmUgdWNsYW1wLm1pbiAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAwXG5cCitlZmZlY3RpdmUgdWNsYW1wLm1heCAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAxMDI0XG5cCitwb2xpY3kgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgICAwXG5cCitwcmlvICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgMTAxXG5cCitjbG9jay1kZWx0YSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgICAgMTYzIjsKKworICBzdGQ6Om1hcDxzdGQ6OnN0cmluZywgZG91YmxlPiBtID0gcGFyc2VUaHJlYWRTY2hlZFN0cmluZyhmYWtlU3RyaW5nKTsKKworICBhdXRvIGl0ID0gbS5maW5kKCJjbG9jay1kZWx0YSIpOworICBBU1NFUlRfTkUoaXQsIG0uZW5kKCkpOworICB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ggYjkxZjMwMi4uNzYzYzA3MCAxMDA2NDQKLS0tIGEvc2VydmljZXMvYXVkaW9mbGluZ2VyL0FuZHJvaWQuYnAKKysrIGIvc2VydmljZXMvYXVkaW9mbGluZ2VyL0FuZHJvaWQuYnAKQEAgLTQxLDYgKzQxLDcgQEAKICAgICAgICAgIkZhc3RUaHJlYWRTdGF0ZS5jcHAiLAogICAgICAgICAiTkJBSU9fVGVlLmNwcCIsCiAgICAgICAgICJQYXRjaFBhbmVsLmNwcCIsCisgICAgICAgICJQcm9wZXJ0eVV0aWxzLmNwcCIsCiAgICAgICAgICJTcGRpZlN0cmVhbU91dC5jcHAiLAogICAgICAgICAiU3RhdGVRdWV1ZS5jcHAiLAogICAgICAgICAiVGhyZWFkcy5jcHAiLApAQCAtNTQsNiArNTUsNyBAQAogICAgIF0sCiAKICAgICBzaGFyZWRfbGliczogWworICAgICAgICAiYW5kcm9pZC5tZWRpYS5hdWRpby5jb21tb24udHlwZXMtVjEtY3BwIiwKICAgICAgICAgImF1ZGlvZmxpbmdlci1haWRsLWNwcCIsCiAgICAgICAgICJhdWRpb2NsaWVudC10eXBlcy1haWRsLWNwcCIsCiAgICAgICAgICJhdi10eXBlcy1haWRsLWNwcCIsCkBAIC04MSw2ICs4Myw3IEBACiAgICAgICAgICJsaWJtZWRpYV9oZWxwZXIiLAogICAgICAgICAibGlic2htZW1jb21wYXQiLAogICAgICAgICAibGlidmlicmF0b3IiLAorICAgICAgICAicGFja2FnZW1hbmFnZXJfYWlkbC1jcHAiLAogICAgIF0sCiAKICAgICBzdGF0aWNfbGliczogWwpAQCAtOTAsNiArOTMsNyBAQAogICAgIF0sCiAKICAgICBoZWFkZXJfbGliczogWworICAgICAgICAibGliYWF1ZGlvX2hlYWRlcnMiLAogICAgICAgICAibGliYXVkaW9jbGllbnRfaGVhZGVycyIsCiAgICAgICAgICJsaWJhdWRpb2hhbF9oZWFkZXJzIiwKICAgICAgICAgImxpYm1lZGlhX2hlYWRlcnMiLApkaWZm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dGggQXVkaW9GbGluZ2VyIGxvY2sgaGVsZC4KIHN0ZDo6b3B0aW9uYWw8bWVkaWE6OkF1ZGlvVmlicmF0b3JJbmZvPiBBdWRpb0ZsaW5nZXI6OmdldERlZmF1bHRWaWJyYXRvckluZm9fbCgpIHsKICAgICBpZiAobUF1ZGlvVmlicmF0b3JJbmZvcy5lbXB0eSgpKSB7CkBAIC00MzAsMTQgKzU4NSwxNCBAQAogICAgICAgICBmdWxsQ29uZmlnLmNoYW5uZWxfbWFzayA9IGNvbmZpZy0+Y2hhbm5lbF9tYXNrOwogICAgICAgICBmdWxsQ29uZmlnLmZvcm1hdCA9IGNvbmZpZy0+Zm9ybWF0OwogICAgICAgICBzdGQ6OnZlY3RvcjxhdWRpb19pb19oYW5kbGVfdD4gc2Vjb25kYXJ5T3V0cHV0czsKLQorICAgICAgICBib29sIGlzU3BhdGlhbGl6ZWQ7CiAgICAgICAgIHJldCA9IEF1ZGlvU3lzdGVtOjpnZXRPdXRwdXRGb3JBdHRyKCZsb2NhbEF0dHIsICZpbywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWN0dWFsU2Vzc2lvbklkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmc3RyZWFtVHlwZSwgY2xpZW50LmF0dHJpYnV0aW9uU291cmNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmZnVsbENvbmZpZywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGF1ZGlvX291dHB1dF9mbGFnc190KShBVURJT19PVVRQVVRfRkxBR19NTUFQX05PSVJRIHwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBVURJT19PVVRQVVRfRkxBR19ESVJFQ1QpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXZpY2VJZCwgJnBvcnRJZC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AgICAgICAgIGlmIChoaWRsQ2xhc3NOYW1lcykgeworICAgICAgICAgICAgICAgIGZvciAoY29uc3QgYXV0byYgY2xhc3NOYW1lIDogKmhpZGxDbGFzc05hbWVzKSB7CisgICAgICAgICAgICAgICAgICAgIGF1dG8gc3RhdHMgPSBtZWRpYXV0aWxzOjpnZXRTdGF0aXN0aWNzRm9yQ2xhc3MoY2xhc3NOYW1lKTsKKyAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRzKSB7CisgICAgICAgICAgICAgICAgICAgICAgICB0aW1lQ2hlY2tTdGF0cyA9IHN0YXRzLT5kdW1wKCk7CisgICAgICAgICAgICAgICAgICAgICAgICBkcHJpbnRmKGZkLCAiXG4lcyBiaW5kZXIgY2FsbCBwcm9maWxlOlxuIiwgY2xhc3NOYW1lLmNfc3RyKCkpOworICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGUoZmQsIHRpbWVDaGVja1N0YXRzLmNfc3RyKCksIHRpbWVDaGVja1N0YXRzLnNpemUoKSk7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIHRpbWVDaGVja1N0YXRzID0gbWVkaWF1dGlsczo6VGltZUNoZWNrOjp0b1N0cmluZygpOworICAgICAgICAgICAgZHByaW50ZihmZCwgIlxuVGltZUNoZWNrOlxuIik7CisgICAgICAgICAgICB3cml0ZShmZCwgdGltZUNoZWNrU3RhdHMuY19zdHIoKSwgdGltZUNoZWNrU3RhdHMuc2l6ZSgpKTsKKyAgICAgICAgICAgIGRwcmludGYoZmQsICJcbiIpOworICAgICAgICB9CiAgICAgfQogICAgIHJldHVybiBOT19FUlJPUjsKIH0KQEAgLTg0Nyw2ICsxMDM0LDcgQEAKICAgICBhdWRpb19zdHJlYW1fdHlwZV90IHN0cmVhbVR5cGU7CiAgICAgYXVkaW9fcG9ydF9oYW5kbGVfdCBwb3J0SWQgPSBBVURJT19QT1JUX0hBTkRMRV9OT05FOwogICAgIHN0ZDo6dmVjdG9yPGF1ZGlvX2lvX2hhbmRsZV90PiBzZWNvbmRhcnlPdXRwdXRzOworICAgIGJvb2wgaXNTcGF0aWFsaXplZCA9IGZhbHNlOzsKIAogICAgIC8vIFRPRE8gYi8xODIzOTI1NTM6IHJlZmFjdG9yIG9yIG1ha2UgY2xlYXJlcgogICAgIHBpZF90IGNsaWVudFBpZCA9CkBAIC04OTAsNyArMTA3OCw4IEBACiAgICAgb3V0cHV0LnNlbGVjdGVkRGV2aWNlSWQgPSBpbnB1dC5zZWxlY3RlZERldmljZUlkOwogICAgIGxTdGF0dXMgPSBBdWRpb1N5c3RlbTo6Z2V0T3V0cHV0Rm9yQXR0cigmbG9jYWxBdHRyLCAmb3V0cHV0Lm91dHB1dElkLCBzZXNzaW9uSWQsICZzdHJlYW1UeXBlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGpBdHRyaWJ1dGlvblNvdXJjZSwgJmlucHV0LmNvbmZpZywgaW5wdXQuZmxhZ3MsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZvdXRwdXQuc2VsZWN0ZWREZXZpY2VJZCwgJnBvcnRJZCwgJnNlY29uZGFyeU91dHB1dHMpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmb3V0cHV0LnNlbGVjdGVkRGV2aWNlSWQsICZwb3J0SWQsICZzZWNvbmRhcnlPdXRwdXRzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmaXNTcGF0aWFsaXplZCk7CiAKICAgICBpZiAobFN0YXR1cyAhPSBOT19FUlJPUiB8fCBvdXRwdXQub3V0cHV0SWQgPT0gQVVESU9fSU9fSEFORExFX05PTkUpIHsKICAgICAgICAgQUxPR0UoImNyZWF0ZVRyYWNrKCkgZ2V0T3V0cHV0Rm9yQXR0cigpIHJldHVybiBlcnJvciAlZCBvciBpbnZhbGlkIG91dHB1dCBoYW5kbGUiLCBsU3RhdHVzKTsKQEAgLTk1Niw3ICsxMTQ1LDcgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5wdXQubm90aWZpY2F0aW9uc1BlckJ1ZmZlciwgaW5wdXQuc3BlZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlucHV0LnNoYXJlZEJ1ZmZlciwgc2Vzc2lvbklkLCAmb3V0cHV0LmZsYWdzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsaW5nUGlkLCBhZGpBdHRyaWJ1dGlvblNvdXJjZSwgaW5wdXQuY2xpZW50SW5mby5jbGllbnRUaWQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZsU3RhdHVzLCBwb3J0SWQsIGlucHV0LmF1ZGlvVHJhY2tDYWxsYmFjayk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZsU3RhdHVzLCBwb3J0SWQsIGlucHV0LmF1ZGlvVHJhY2tDYWxsYmFjaywgaXNTcGF0aWFsaXplZCk7CiAgICAgICAgIExPR19BTFdBWVNfRkFUQUxfSUYoKGxTdGF0dXMgPT0gTk9fRVJST1IpICYmICh0cmFjayA9PSAwKSk7CiAgICAgICAgIC8vIHdlIGRvbid0IGFib3J0IHlldCBpZiBsU3RhdHVzICE9IE5PX0VSUk9SOyB0aGVyZSBpcyBzdGlsbCB3b3JrIHRvIGJlIGRvbmUgcmVnYXJkbGVzcwogCkBAIC05OTgsOCArMTE4Nyw5IEBACiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogICAgICAgICB9Ci0KLSAgICAgICAgc2V0QXVkaW9Id1N5bmNGb3JTZXNzaW9uX2wodGhyZWFkLCBzZXNzaW9uSWQpOworICAgICAgICBpZiAoKG91dHB1dC5mbGFncyAmIEFVRElPX09VVFBVVF9GTEFHX0hXX0FWX1NZTkMpID09IEF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WdFdmVudChldmVudCkpOwogCiAgICAgTXV0ZXg6OkF1dG9sb2NrIF9sKG1DbGllbnRMb2NrKTsKICAgICBzaXplX3Qgc2l6ZSA9IG1Ob3RpZmljYXRpb25DbGllbnRzLnNpemUoKTsKQEAgLTIxNDMsNiArMjMzMywyMCBAQAogICAgICAgICAgICAgZ290byBFeGl0OwogICAgICAgICB9CiAKKyAgICAgICAgaWYgKHJlY29yZFRyYWNrLT5pc0Zhc3RUcmFjaygpKSB7CisgICAgICAgICAgICBvdXRwdXQuc2VydmVyQ29uZmlnID0geworICAgICAgICAgICAgICAgICAgICB0aHJlYWQtPnNhbXBsZVJhdGUoKSwKKyAgICAgICAgICAgICAgICAgICAgdGhyZWFkLT5jaGFubmVsTWFzaygpLAorICAgICAgICAgICAgICAgICAgICB0aHJlYWQtPmZvcm1hdCgpCisgICAgICAgICAgICB9OworICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgb3V0cHV0LnNlcnZlckNvbmZpZyA9IHsKKyAgICAgICAgICAgICAgICAgICAgcmVjb3JkVHJhY2stPnNhbXBsZVJhdGUoKSwKKyAgICAgICAgICAgICAgICAgICAgcmVjb3JkVHJhY2stPmNoYW5uZWxNYXNrKCksCisgICAgICAgICAgICAgICAgICAgIHJlY29yZFRyYWNrLT5mb3JtYXQoKQorICAgICAgICAgICAgfTsKKyAgICAgICAgfQorCiAgICAgICAgIC8vIENoZWNrIGlmIG9uZSBlZmZlY3QgY2hhaW4gd2FzIGF3YWl0aW5nIGZvciBhbiBBdWRpb1JlY29yZCB0byBiZSBjcmVhdGVkIG9uIHRoaXMKICAgICAgICAgLy8gc2Vzc2lvbiBhbmQgbW92ZSBpdCB0byB0aGlzIHRocmVhZC4KICAgICAgICAgc3A8RWZmZWN0Q2hhaW4+IGNoYWluID0gZ2V0T3JwaGFuRWZmZWN0Q2hhaW5fbChzZXNzaW9uSWQpOwpAQCAtMjI3Myw2ICsyNDc3LDE4IEBACiAgICAgICAgIG1IYXJkd2FyZVN0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gICAgICAgICAgIndpdGhvdXQgI2RlZmluZSBNVUxUSUNIQU5ORUxfRUZGRUNUX0NIQUlOIik7CisgICAgICAgIHJldHVybiBudWxscHRyOworICAgIH0KKyNlbmRpZgorCiAgICAgbUhhcmR3YXJlU3RhdHVzID0gQVVESU9fSFdfT1VUUFVUX09QRU47CiAKICAgICAvLyBGT1IgVEVTVElORyBPTkxZOgpAQCAtMjU3MCwxOCArMjc5MCwxMSBAQAogICAgICAgICAgICAgcmV0dXJuIHRocmVhZDsKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIHNwPFBsYXliYWNrVGhyZWFkPiB0aHJlYWQ7Ci0gICAgICAgICAgICAvL1RPRE86IGIvMTkzNDk2MTgwIHVzZSBzcGF0aWFsaXplciBmbGFnIGF0IGF1ZGlvIEhBTCB3aGVuIGF2YWlsYWJsZQotICAgICAgICAgICAgaWYgKGZsYWdzID09IChhdWRpb19vdXRwdXRfZmxhZ3NfdCkoQVVESU9fT1VUUFVUX0ZMQUdfRkFTVAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgQVVESU9fT1VUUFVUX0ZMQUdfREVFUF9CVUZGRVIpKSB7Ci0jaWZkZWYgTVVMVElDSEFOTkVMX0VGRkVDVF9DSEFJTgorICAgICAgICAgICAgaWYgKGZsYWdzICYgQVVESU9fT1VUUFVUX0ZMQUdfU1BBVElBTElaRVIpIHsKICAgICAgICAgICAgICAgICB0aHJlYWQgPSBuZXcgU3BhdGlhbGl6ZXJUaHJlYWQodGhpcywgb3V0cHV0U3RyZWFtLCAqb3V0cHV0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1TeXN0ZW1SZWFkeSwgbWl4ZXJDb25maWcpOwotICAgICAgICAgICAgICAgIEFMT0dEKCJvcGVuT3V0cHV0X2woKSBjcmVhdGVkIHNwYXRpYWxpemVyIG91dHB1dDogSUQgJWQgdGhyZWFkICV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NT1JZOwpAQCAtMzI2MCw2ICszMzAzLDggQEAKICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIG1IYWxFZmZlY3QtPnNldERldmljZXMoe21EZXZpY2V9KTsKICAgICAgICAgfQorICAgICAgICBtSGFsRWZmZWN0LT5jb25maWd1cmUoKTsKKwogICAgICAgICAqaGFuZGxlID0gbmV3IEVmZmVjdEhhbmRsZShtSGFsRWZmZWN0LCBudWxscHRyLCBudWxscHRyLCAwIC8qcHJpb3JpdHkqLywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbU5vdGlmeUZyYW1lc1Byb2Nlc3NlZCk7CiAgICAgICAgIHN0YXR1cyA9ICgqaGFuZGxlKS0+aW5pdENoZWNrKCk7CkBAIC0zMzA4LDggKzMzNTMsMTQgQEAKIH0KIAogdm9pZCBBdWRpb0ZsaW5nZXI6OkRldmljZUVmZmVjdFByb3h5OjpvblJlbGVhc2VQYXRjaChhdWRpb19wYXRjaF9oYW5kbGVfdCBwYXRjaEhhbmRsZSkgewotICAgIE11dGV4OjpBdXRvbG9jayBfbChtUHJveHlMb2NrKTsKLSAgICBtRWZmZWN0SGFuZGxlcy5lcmFzZShwYXRjaEhhbmRsZSk7CisgICAgc3A8RWZmZWN0SGFuZGxlPiBlZmZlY3Q7CisgICAgeworICAgICAgICBNdXRleDo6QXV0b2xvY2sgX2wobVByb3h5TG9jayk7CisgICAgICAgIGlmIChtRWZmZWN0SGFuZGxlcy5maW5kKHBhdGNoSGFuZGxlKSAhPSBtRWZmZWN0SGFuZGxlcy5lbmQoKSkgeworICAgICAgICAgICAgZWZmZWN0ID0gbUVmZmVjdEhhbmRsZXMuYXQocGF0Y2hIYW5kbGUpOworICAgICAgICAgICAgbUVmZmVjdEhhbmRsZXMuZXJhc2UocGF0Y2hIYW5kbGUpOworICAgICAgICB9CisgICAgfQogfQogCiAKQEAgLTMzMTcsNiArMzM2OCw3IEBACiB7CiAgICAgTXV0ZXg6OkF1dG9sb2NrIF9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2tUaHJlYWQ6OlBhdGNoVHJhY2s+IHRlbXBQYXRjaFRyYWNrID0gbmV3IFBsYXliYWNrVGhyZWFkOjpQYXRjaFRyYWNrKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1QbGF5YmFjay50aHJlYWQoKS5nZXQoKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1UeXBlLApAQCAtNTg0LDcgKzU5MCw5IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJhbWVDb3VudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZW1wUmVjb3JkVHJhY2stPmJ1ZmZlcigpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXBSZWNvcmRUcmFjay0+YnVmZmVyU2l6ZSgpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dEZsYWdzKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRGbGFncywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7fSAvKnRpbWVvdXQqLywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcmFtZUNvdW50VG9CZVJlYWR5KTsKICAgICBzdGF0dXMgPSBtUGxheWJhY2suY2hlY2tUcmFjayh0ZW1wUGF0Y2hUcmFjay5nZXQoKSk7CiAgICAgaWYgKHN0YXR1cyAhPSBOT19FUlJPUikgewogICAgICAgICByZXR1cm4gc3RhdHVzOwpkaWZmIC0tZ2l0IGEvc2VydmljZXMvYXVkaW9mbGluZ2VyL1BsYXliYWNrVHJhY2tzLmggYi9zZXJ2aWNlcy9hdWRpb2ZsaW5nZXIvUGxheWJhY2tUcmFja3MuaAppbmRleCAzY2NlOTk4Li42YTEzOGJiIDEwMDY0NAotLS0gYS9zZXJ2aWNlcy9hdWRpb2ZsaW5nZXIvUGxheWJhY2tUcmFja3MuaAorKysgYi9zZXJ2aWNlcy9hdWRpb2ZsaW5nZXIvUGxheWJhY2tUcmFja3MuaApAQCAtODIsNyArODIsOCBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiogZGVmYXVsdCBiZWhhdmlvdXIgaXMgdG8gc3RhcnQgd2hlbiB0aGVyZSBhcmUgYXMgbWFueSBmcmFtZXMKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqIHJlYWR5IGFzIHBvc3NpYmxlIChha2EuIEJ1ZmZlciBpcyBmdWxsKS4gKi8KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZV90IGZyYW1lQ291bnRUb0JlUmVhZHkgPSBTSVpFX01BWCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmxvYXQgc3BlZWQgPSAxLjBmKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmxvYXQgc3BlZWQgPSAxLjBmLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIGlzU3BhdGlhbGl6ZWQgPSBmYWxzZSk7CiAgICAgdmlydHVhbCAgICAgICAgICAgICB+VHJhY2soKTsKICAgICB2aXJ0dWFsIHN0YXR1c190ICAgIGluaXRDaGVjaygpIGNvbnN0OwogCkBAIC0xOTMsOCArMTk0LDE1IEBACiAgICAgICAgfQogICAgIH0KIAorICAgIHN0YXRpYyBib29sIGNoZWNrU2VydmVyTGF0ZW5jeVN1cHBvcnRlZCgKKyAgICAgICAgICAgIGF1ZGlvX2Zvcm1hdF90IGZvcm1hdCwgYXVkaW9fb3V0cHV0X2ZsYWdzX3QgZmxhZ3MpIHsKKyAgICAgICAgcmV0dXJuIGF1ZGlvX2lzX2xpbmVhcl9wY20oZm9ybWF0KQorICAgICAgICAgICAgICAgICYmIChmbGFncyAmIEFVRElPX09VVFBVVF9GT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iAgICAgZHByaW50ZihmZCwgIiAgTG9jYWwgbG9nOlxuIik7CiAgICAgbUxvY2FsTG9nLmR1bXAoZmQsICIgICAiIC8qIHByZWZpeCAqLywgNDAgLyogbGluZXMgKi8pOworCisgICAgLy8gLS1hbGwgZG9lcyB0aGUgc3RhdGlzdGljcworICAgIGJvb2wgZHVtcEFsbCA9IGZhbHNlOworICAgIGZvciAoY29uc3QgYXV0byAmYXJnIDogYXJncykgeworICAgICAgICBpZiAoYXJnID09IFN0cmluZzE2KCItLWFsbCIpKSB7CisgICAgICAgICAgICBkdW1wQWxsID0gdHJ1ZTsKKyAgICAgICAgfQorICAgIH0KKyAgICBpZiAoZHVtcEFsbCB8fCB0eXBlKCkgPT0gU1BBVElBTElaRVIpIHsKKyAgICAgICAgY29uc3Qgc3RkOjpzdHJpbmcgc2NoZWQgPSBtVGhyZWFkU25hcHNob3QudG9TdHJpbmcoKTsKKyAgICAgICAgaWYgKCFzY2hlZC5lbXB0eSgpKSB7CisgICAgICAgICAgICAodm9pZCl3cml0ZShmZCwgc2NoZWQuY19zdHIoKSwgc2NoZWQuc2l6ZSgpKTsKKyAgICAgICAgfQorICAgIH0KIH0KIAogdm9pZCBBdWRpb0ZsaW5nZXI6OlRocmVhZEJhc2U6OmR1bXBCYXNlX2woaW50IGZkLCBjb25zdCBWZWN0b3I8U3RyaW5nMTY+JiBhcmdzIF9fdW51c2VkKQpAQCAtOTYyLDcgKzk3OCw4IEBACiAgICAgICAgICAgICB8fCBtVHlwZSA9PSBNSVhFUgogICAgICAgICAgICAgfHwgbVR5cGUgPT0gRFVQTElDQVRJTkcKICAgICAgICAgICAgIHx8IG1UeXBlID09IERJUkVDVAotICAgICAgICAgICAgfHwgbVR5cGUgPT0gT0ZGTE9BRCkgeworICAgICAgICAgICAgfHwgbVR5cGUgPT0gT0ZGTE9BRAorICAgICAgICAgICAgfHwgbVR5cGUgPT0gU1BBVElBTElaRVIpIHsKICAgICAgICAgZHByaW50ZihmZCwgIiAgVGlt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fRkxBR19GQVNUIGRlbmllZDogc2hhcmVkQnVmZmVyPSVwIGZyYW1lQ291bnQ9JXp1ICIKKyAgICAgICAgQUxPR0QoIkFVRElPX09VVFBVVF9GTEFHX0ZBU1QgZGVuaWVkOiBzaGFyZWRCdWZmZXI9JXAgZnJhbWVDb3VudD0lenUgIgogICAgICAgICAgICAgICAgICJtRnJhbWVDb3VudD0lenUgZm9ybWF0PSUjeCBtRm9ybWF0PSUjeCBpc0xpbmVhcj0lZCBjaGFubmVsTWFzaz0lI3ggIgogICAgICAgICAgICAgICAgICJzYW1wbGVSYXRlPSV1IG1TYW1wbGVSYXRlPSV1ICIKICAgICAgICAgICAgICAgICAiaGFzRmFzdE1peGVyPSVkIHRpZD0lZCBmYXN0VHJhY2tBdmFpbE1hc2s9JSN4IiwKQEAgLTI1MDksNyArMjUzOCw4IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYW5uZWxNYXNrLCBmcmFtZUNvdW50LAogICAgICAgICAgICAgICAgICAgICAgICAgICBudWxscHRyIC8qIGJ1ZmZlciAqLywgKHNpemVfdCkwIC8qIGJ1ZmZlclNpemUgKi8sIHNoYXJlZEJ1ZmZlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgc2Vzc2lvbklkLCBjcmVhdG9yUGlkLCBhdHRyaWJ1dGlvblNvdXJjZSwgdHJhY2tGbGFncywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgVHJhY2tCYXNlOjpUWVBFX0RFRkFVTFQsIHBvcnRJZCwgU0laRV9NQVggLypmcmFtZUNvdW50VG9CZVJlYWR5Ki8sIHNwZWVkKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgVHJhY2tCYXNlOjpUWVBFX0RFRkFVTFQsIHBvcnRJZCwgU0laRV9NQVggLypmcmFtZUNvdW50VG9CZVJlYWR5Ki8sCisgICAgICAgICAgICAgICAgICAgICAgICAgIHNwZWVkLCBpc1NwYXRpYWxpemVkKTsKIAogICAgICAgICBsU3RhdHVzID0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AgICAgICAgIHNsZWVwVGltZVNoaWZ0ID0gMDsKICAgICB9CiAKQEAgLTM4MjEsNiArMzg0Myw3IEBACiAgICAgICAgICAgICAgICAgICAgIGlmICghbVN0YW5kYnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIExPR19BVURJT19TVEFURSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgbVRocmVhZE1ldHJpY3MubG9nRW5kSW50ZXJ2YWwoKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1UaHJlYWRTbmFwc2hvdC5vbkVuZCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgbVN0YW5kYnkgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIHNlbmRTdGF0aXN0aWNzKGZhbHNlIC8qIGZvcmNlICovKTsKQEAgLTM4NTEsNyArMzg3NCw3IEBACiAKICAgICAgICAgICAgICAgICAgICAgbVN0YW5kYnlUaW1lTnMgPSBzeXN0ZW1UaW1lKCkgKyBtU3RhbmRieURlbGF5TnM7CiAgICAgICAgICAgICAgICAgICAgIG1TbGVlcFRpbWVVcyA9IG1JZGxlU2xlZXBUaW1lVXM7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChtVHlwZSA9PSBNSVhFUikgeworICAgICAgICAgICAgICAgICAgICBpZiAobVR5cGUgPT0gTUlYRVIgfHwgbVR5cGUgPT0gU1BBVElBTElaRVIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIHNsZWVwVGltZVNoaWZ0ID0gMDsKICAgICAgICAgICAgICAgICAgICAgfQogCkBAIC0zODgxLDE0ICszOTA0LDE0IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJiYgZWZmZWN0Q2hhaW4tPmNvbnRhaW5zSGFwdGljR2VuZXJhdGluZ0VmZmVjdF9sKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIGFjdGl2ZUhhcHRpY1Nlc3Npb25JZCA9IHRyYWNrLT5zZXNzaW9uSWQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgIGlzSGFwdGljU2Vzc2lvblNwYXRpYWxpemVkID0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbVR5cGUgPT0gU1BBVElBTElaRVIgJiYgdHJhY2stPmNhbkJlU3BhdGlhbGl6ZWQoKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbVR5cGUgPT0gU1BBVElBTElaRVIgJiYgdHJhY2stPmlzU3BhdGlhbGl6ZWQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIGlmIChhY3RpdmVIYXB0aWNTZXNzaW9uSWQgPT0gQVVESU9fU0VTU0lPTl9OT05FCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJiYgdHJhY2stPmdldEhhcHRpY1BsYXliYWNrRW5hYmxlZCgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBhY3RpdmVIYXB0aWNTZXNzaW9uSWQgPSB0cmFjay0+c2Vzc2lvbklkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICBpc0hhcHRpY1Nlc3Npb25TcGF0aWFsaXplZCA9Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1UeXBlID09IFNQQVRJQUxJWkVSICYmIHRyYWNrLT5jYW5CZVNwYXRpYWxpemVkKCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1UeXBlID09IFNQQVRJQUxJWkVSICYmIHRyYWNrLT5pc1NwYXRpYWxpemVkKCk7CiAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CkBAIC00MTEyLDExICs0MTM1LDI0IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE11dGV4OjpBdXRvbG9jayBfbChtTG9jayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1Jb0ppdHRlck1zLmFkZChqaXR0ZXJNcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1Qcm9jZXNzVGltZU1zLmFkZChwcm9jZXNzTXMpOworCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtUGlwZVNpbmsuZ2V0KCkgIT0gbnVsbHB0cikgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gVXNpbmcgdGhlIE1vbm9waXBlIGF2YWlsYWJsZVRvV3JpdGUsIHdlIGVzdGltYXRlIHRoZSBjdXJyZW50CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBidWZmZXIgc2l6ZS4KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE1vbm9QaXBlKiBtb25vUGlwZSA9IHN0YXRpY19jYXN0PE1vbm9QaXBlKj4obVBpcGVTaW5rLmdldCgpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNzaXplX3QKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXZhaWxhYmxlVG9Xcml0ZSA9IG1QaXBlU2luay0+YXZhaWxhYmxlVG9Xcml0ZSgpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2l6ZV90IHBpcGVGcmFtZXMgPSBtb25vUGlwZS0+bWF4RnJhbWVzKCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzaXplX3QKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVtYWluaW5nRnJhbWVzID0gcGlwZUZyYW1lcyAtIG1heChhdmFpbGFibGVUb1dyaXRlLCAwKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1Nb25vcGlwZVBpcGVEZXB0aFN0YXRzLmFkZChyZW1haW5pbmdGcmFtZXMpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gd3JpdGUgYmxvY2tlZCBkZXRlY3Rpb24KICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnQ2NF90IGRlbHRhV3JpdGVOcyA9IGxhc3RJb0VuZE5zIC0gbGFzdElvQmVnaW5OczsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobVR5cGUgPT0gTUlYRVIgJiYgZGVsdGFXcml0ZU5zID4gbWF4UGVyaW9kKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKChtVHlwZSA9PSBNSVhFUiB8fCBtVHlwZSA9PSBTUEFUSUFMSVpFUikKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICYmIGRlbHRhV3JpdGVOcyA+IG1heFBlcmlvZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtTnVtRGVsYXllZFdyaXRlcysrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoKGxhc3RJb0VuZE5zIC0gbGFzdFdhcm5pbmcpID4ga1dhcm5pbmdUaHJvdHRsZU5zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBVFJBQ0VfTkFNRSgidW5kZXJydW4iKTsKQEAgLTQxMzcsNyArNDE3Myw3IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAobU1peGVyU3RhdHVzID09IE1JWEVSX0RSQUlOX0FMTCkpIHsKICAgICAgICAgICAgICAgICAgICAgdGhyZWFkTG9vcF9kcmFpbigpOwogICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBpZiAobVR5cGUgPT0gTUlYRVIgJiYgIW1TdGFuZGJ5KSB7CisgICAgICAgICAgICAgICAgaWYgKChtVHlwZSA9PSBNSVhFUiB8fCBtVHlwZSA9PSBTUEFUSUFMSVpFUikgJiYgIW1TdGFuZGJ5KSB7CiAKICAgICAgICAgICAgICAgICAgICAgaWYgKG1UaHJlYWRUaHJvdHRsZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICYmIG1NaXhlclN0YXR1cyA9PSBNSVhFUl9UUkFDS1NfUkVBRFkgLy8gd2UgYXJlIG1peGluZyAoYWN0aXZlIHRyYWNrcykKQEAgLTQyNjIsMTMgKzQyOTgsNiBAQAogCiB2b2lkIEF1ZGlvRmxpbmdlcjo6UGxheWJhY2tUaHJlYWQ6OmNvbGxlY3RUaW1lc3RhbXBzX2woKQogewotICAgIC8vIENvbGxlY3QgdGltZXN0YW1wIHN0YXRpc3RpY3MgZm9yIHRoZSBQbGF5YmFjayBUaHJlYWQgdHlwZXMgdGhhdCBzdXBwb3J0IGl0LgotICAgIGlmIChtVHlwZSAhPSBNSVhFUgotICAgICAgICAgICAgJiYgbVR5cGUgIT0gRFVQTElDQVRJTkcKLSAgICAgICAgICAgICYmIG1UeXBlICE9IERJUkVDVAotICAgICAgICAgICAgJiYgbVR5cGUgIT0gT0ZGTE9BRCkgewotICAgICAgICByZXR1cm47Ci0gICAgfQogICAgIGlmIChtU3RhbmRieSkgewogICAgICAgICBtVGltZXN0YW1wVmVyaWZpZXIuZGlzY29udGludWl0eShkaXNjb250aW51aXR5Rm9yU3RhbmRieU9yRmx1c2goKSk7CiAgICAgICAgIHJldHVybjsKQEAgLTQ1NzAsMTkgKzQ1OTksNyBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRjaC0+c2lua3MsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhbmRsZSk7CiAgICAgfSBlbHNlIHsKLSAgICAgICAgY2hhciAqYWRkcmVzczsKLSAgICAgICAgaWYgKHN0cmNtcChwYXRjaC0+c2lua3NbMF0uZXh0LmRldmljZS5hZGRyZXNzLCAiIikgIT0gMCkgewotICAgICAgICAgICAgLy9GSVhNRTogd2Ugb25seSBzdXBwb3J0IGFkZHJlc3Mgb24gZmlyc3Qgc2luayB3aXRoIEhBTCB2ZXJzaW9uIDwgMy4wCi0gICAgICAgICAgICBhZGRyZXNzID0gYXVkaW9fZGV2aWNlX2FkZHJlc3NfdG9fcGFyYW1ldGVyKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRjaC0+c2lua3NbMF0uZXh0LmRldmljZS50eXBlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRjaC0+c2lua3NbMF0uZXh0LmRldmljZS5hZGRyZXNzKTsKLSAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIGFkZHJlc3MgPSAoY2hhciAqKWNhbGxvYygxLCAxKTsKLSAgICAgICAgfQotICAgICAgICBBdWRpb1BhcmFtZXRlciBwYXJhbSA9IEF1ZGlvUGFyYW1ldGVyKFN0cmluZzgoYWRkcmVzcykpOwotICAgICAgICBmcmVlKGFkZHJlc3MpOwotICAgICAgICBwYXJhbS5hZGRJbnQoU3RyaW5nOChBdWRpb1BhcmFtZXRlcjo6a2V5Um91dGluZyksIChpbnQpdHlwZSk7Ci0gICAgICAgIHN0YXR1cyA9IG1PdXRwdXQtPnN0cmVhbS0+c2V0UGFyYW1ldGVycyhwYXJhbS50b1N0cmluZygpKTsKKyAgICAgICAgc3RhdHVzID0gbU91dHB1dC0+c3RyZWFtLT5sZWdhY3lDcmVhdGVBdWRpb1BhdGNoKHBhdGNoLT5zaW5rc1swXSwgc3RkOjpudWxsb3B0LCB0eXBlKTsKICAgICAgICAgKmhhbmRsZSA9IEFVRElPX1BBVENIX0hBTkRMRV9OT05FOwogICAgIH0KICAgICBjb25zdCBzdGQ6OnN0cmluZyBwYXRjaFNpbmtzQXNTdHJpbmcgPSBwYXRjaFNpbmtzVG9TdHJpbmcocGF0Y2gpOwpAQCAtNDYyNyw5ICs0NjQ0LDcgQEAKICAgICAgICAgc3A8RGV2aWNl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NvIGNhbm5vdCBvcGVyYXRlIHdpdGggRmFzdE1peGVyLgotICAgICAgICAgICAgaW5pdEZhc3RNaXhlciA9IG1GcmFtZUNvdW50IDwgbU5vcm1hbEZyYW1lQ291bnQKLSAgICAgICAgICAgICAgICAgICAgJiYgSW50ZXJzZWN0aW9uKG91dERldmljZVR5cGVzKCksIGdldEF1ZGlvRGV2aWNlT3V0QWxsQTJkcFNldCgpKS5lbXB0eSgpOworICAgICAgICAgICAgaW5pdEZhc3RNaXhlciA9IG1GcmFtZUNvdW50IDwgbU5vcm1hbEZyYW1lQ291bnQ7CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogICAgICAgICBBTE9HV19JRihpbml0RmFzdE1peGVyID09IGZhbHNlICYmIG1GcmFtZUNvdW50IDwgbU5vcm1hbEZyYW1lQ291bnQsCkBAIC01NTc1LDcgKzU1ODUsNyBAQAogICAgICAgICAgICAgICAgIEF1ZGlvTWl4ZXI6OlRSQUNLLAogICAgICAgICAgICAgICAgIEF1ZGlvTWl4ZXI6OkNIQU5ORUxfTUFTSywgKHZvaWQgKikodWludHB0cl90KXRyYWNrLT5jaGFubmVsTWFzaygpKTsKIAotICAgICAgICAgICAgaWYgKG1UeXBlID09IFNQQVRJQUxJWkVSICYmICF0cmFjay0+Y2FuQmVTcGF0aWFsaXplZCgpKSB7CisgICAgICAgICAgICBpZiAobVR5cGUgPT0gU1BBVElBTElaRVIgJiYgIXRyYWNrLT5pc1NwYXRpYWxpemVkKCkpIHsKICAgICAgICAgICAgICAgICBtQXVkaW9NaXhlci0+c2V0UGFyYW1ldGVyKAogICAgICAgICAgICAgICAgICAgICB0cmFja0lkLAogICAgICAgICAgICAgICAgICAgICBBdWRpb01peGVyOjpUUkFDSywKQEAgLTU2MjUsNyArNTYzNSw3IEBACiAgICAgICAgICAgICBpZiAobU1peGVyQnVmZmVyRW5hYmxlZAogICAgICAgICAgICAgICAgICAgICAmJiAodHJhY2stPm1haW5CdWZmZXIoKSA9PSBtU2lua0J1ZmZlcgogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHx8IHRyYWNrLT5tYWluQnVmZmVyKCkgPT0gbU1peGVyQnVmZmVyKSkgewotICAgICAgICAgICAgICAgIGlmIChtVHlwZSA9PSBTUEFUSUFMSVpFUiAmJiAhdHJhY2stPmNhbkJlU3BhdGlhbGl6ZWQoKSkgeworICAgICAgICAgICAgICAgIGlmIChtVHlwZSA9PSBTUEFUSUFMSVpFUiAmJiAhdHJhY2stPmlzU3BhdGlhbGl6ZWQoKSkgewogICAgICAgICAgICAgICAgICAgICBtQXVkaW9NaXhlci0+c2V0UGFyYW1ldGVyKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYWNrSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQXVkaW9NaXhlcjo6VFJBQ0ssCkBAIC01ODc5LDYgKzU4ODksMjAgQEAKICAgICByZXR1cm4gdHJhY2tDb3VudDsKIH0KIAorYm9vbCBBdWRpb0ZsaW5nZXI6OlBsYXliYWNrVGhyZWFkOjpjaGVja1J1bm5pbmdUaW1lc3RhbXAoKQoreworICAgIHVpbnQ2NF90IHBvc2l0aW9uID0gMDsKKyAgICBzdHJ1Y3QgdGltZXNwZWMgdW51c2VkOworICAgIGNvbnN0IHN0YXR1c190IHJldCA9IG1PdXRwdXQtPmdldFByZXNlbnRhdGlvblBvc2l0aW9uKCZwb3NpdGlvbiwgJnVudXNlZCk7CisgICAgaWYgKHJldCA9PSBOT19FUlJPUikgeworICAgICAgICBpZiAocG9zaXRpb24gIT0gbUxhc3RDaGVja2VkVGltZXN0YW1wUG9zaXRpb24pIHsKKyAgICAgICAgICAgIG1MYXN0Q2hlY2tlZFRpbWVzdGFtcFBvc2l0aW9uID0gcG9zaXRpb247CisgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKKyAgICAgICAgfQorICAgIH0KKyAgICByZXR1cm4gZmFsc2U7Cit9CisKIC8vIGlzVHJhY2tBbGxvd2VkX2woKSBtdXN0IGJlIGNhbGxlZCB3aXRoIFRocmVhZEJhc2U6Om1Mb2NrIGhlbGQKIGJvb2wgQXVkaW9GbGluZ2VyOjpNaXhlclRocmVhZDo6aXNUcmFja0FsbG93ZWRfbCgKICAgICAgICAgYXVkaW9fY2hhbm5lbF9tYXNrX3QgY2hhbm5lbE1hc2ssIGF1ZGlvX2Zvcm1hdF90IGZvcm1hdCwKQEAgLTU5NDksNiArNTk3Myw3IEBACiAgICAgICAgICAgICBtT3V0cHV0LT5zdGFuZGJ5KCk7CiAgICAgICAgICAgICBpZiAoIW1TdGFuZGJ5KSB7CiAgICAgICAgICAgICAgICAgbVRocmVhZE1ldHJpY3MubG9nRW5kSW50ZXJ2YWwoKTsKKyAgICAgICAgICAgICAgICBtVGhyZWFkU25hcHNob3Qub25FbmQoKTsKICAgICAgICAgICAgICAgICBtU3RhbmRieSA9IHRydWU7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBtQnl0ZXNXcml0dGVuID0gMDsKQEAgLTYyOTEsOSArNjMxNiwxMyBAQAogICAgICAgICAgICAgICAgICAgICB0cmFjay0+aXNTdG9wcGluZ18yKCkgfHwgdHJhY2stPmlzUGF1c2VkKCkpIHsKICAgICAgICAgICAgICAgICAvLyBXZSBoYXZlIGNvbnN1bWVkIGFsbCB0aGUgYnVmZmVycyBvZiB0aGlzIHRyYWNrLgogICAgICAgICAgICAgICAgIC8vIFJlbW92ZSBpdCBmcm9tIHRoZSBsaXN0IG9mIGFjdGl2ZSB0cmFja3MuCisgICAgICAgICAgICAgICAgYm9vbCBwcmVzQ29tcGxldGUgPSBmYWxzZTsKICAgICAgICAgICAgICAgICBpZiAobVN0YW5kYnkgfHwgIWxhc3QgfHwKLSAgICAgICAgICAgICAgICAgICAgICAgIHRyYWNrLT5wcmVzZW50YXRpb25Db21wbGV0ZShsYXRlbmN5X2woKSkgfHwKKyAgICAgICAgICAgICAgICAgICAgICAgIChwcmVzQ29tcGxldGUgPSB0cmFjay0+cHJlc2VudGF0aW9uQ29tcGxldGUobGF0ZW5jeV9sKCkpKSB8fAogICAgICAgICAgICAgICAgICAgICAgICAgdHJhY2stPmlzUGF1c2VkKCkgfHwgbUh3UGF1c2VkKSB7CisgICAgICAgICAgICAgICAgICAgIGlmIChwcmVzQ29tcGxldGUpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIG1PdXRwdXQtPnByZXNlbnRhdGlvbkNvbXBsZXRlKCk7CisgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgaWYgKHRyYWNrLT5pc1N0b3BwaW5nXzIoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgdHJhY2stPm1TdGF0ZSA9IFRyYWNrQmFzZTo6U1RPUFBFRDsKICAgICAgICAgICAgICAgICAgICAgfQpAQCAtNjMwNywxOSArNjMzNiwyNCBAQAogICAgICAgICAgICAgICAgIC8vIGZpbGwgYSBidWZmZXIsIHRoZW4gcmVtb3ZlIGl0IGZyb20gYWN0aXZlIGxpc3QuCiAgICAgICAgICAgICAgICAgLy8gT25seSBjb25zaWRlciBsYXN0IHRyYWNrIHN0YXJ0ZWQgZm9yIG1peGVyIHN0YXRlIGNvbnRyb2wKICAgICAgICAgICAgICAgICBpZiAoLS0odHJhY2stPm1SZXRyeUNvdW50KSA8PSAwKSB7Ci0gICAgICAgICAgICAgICAgICAgIEFMT0dWKCJCVUZGRVIgVElNRU9VVDogcmVtb3ZlIHRyYWNrKCVkKSBmcm9tIGFjdGl2ZSBsaXN0IiwgdHJhY2tJZCk7Ci0gICAgICAgICAgICAgICAgICAgIHRyYWNrc1RvUmVtb3ZlLT5hZGQodHJhY2spOwotICAgICAgICAgICAgICAgICAgICAvLyBpbmRpY2F0ZSB0byBjbGllbnQgcHJvY2VzcyB0aGF0IHRoZSB0cmFjayB3YXMgZGlzYWJsZWQgYmVjYXVzZSBvZiB1bmRlcnJ1bjsKLSAgICAgICAgICAgICAgICAgICAgLy8gaXQgd2lsbCB0aGVuIGF1dG9tYXRpY2FsbHkgY2FsbCBzdGFydCgpIHdoZW4gZGF0YSBpcyBhdmFpbGFibGUKLSAgICAgICAgICAgICAgICAgICAgdHJhY2stPmRpc2FibGUoKTsKLSAgICAgICAgICAgICAgICAgICAgLy8gb25seSBkbyBodyBwYXVzZSB3aGVuIHRyYWNrIGlzIGdvaW5nIHRvIGJlIHJlbW92ZWQgZHVlIHRvIEJVRkZFUiBUSU1FT1VULgotICAgICAgICAgICAgICAgICAgICAvLyB1bmxpa2UgbWl4ZXJ0aHJlYWQsIEhBTCBjYW4gYmUgcGF1c2VkIGZvciBkaXJlY3Qgb3V0cHV0Ci0gICAgICAgICAgICAgICAgICAgIEFMT0dXKCJwYXVzZSBiZWNhdXNlIG9mIFVOREVSUlVOLCBmcmFtZXNSZWFkeSA9ICV6dSwiCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgIm1pbkZyYW1lcyA9ICV1LCBtRm9ybWF0ID0gJSN4IiwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcmFtZXNSZWFkeSwgbWluRnJhbWVzLCBtRm9ybWF0KTsKLSAgICAgICAgICAgICAgICAgICAgaWYgKGxhc3QgJiYgbUh3U3VwcG9ydHNQYXVzZSAmJiAhbUh3UGF1c2VkICYmICFtU3RhbmRieSkgewotICAgICAgICAgICAgICAgICAgICAgICAgZG9Id1BhdXNlID0gdHJ1ZTsKLSAgICAgICAgICAgICAgICAgICAgICAgIG1Id1BhdXNlZCA9IHRydWU7CisgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJvb2wgcnVubmluZyA9IGNoZWNrUnVubmluZ1RpbWVzdGFtcCgpOworICAgICAgICAgICAgICAgICAgICBpZiAocnVubmluZykgeyAvLyBzdGlsbCBydW5uaW5nLCBnaXZlIHVzIG1vcmUgdGltZS4KKyAgICAgICAgICAgICAgICAgICAgICAgIHRyYWNrLT5tUmV0cnlDb3VudCA9IGtNYXhUcmFja1JldHJpZXNPZmZsb2FkOworICAgICAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgQUxPR1YoIkJVRkZFUiBUSU1FT1VUOiByZW1vdmUgdHJhY2soJWQpIGZyb20gYWN0aXZlIGxpc3QiLCB0cmFja0lkKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHRyYWNrc1RvUmVtb3ZlLT5hZGQodHJhY2spOworICAgICAgICAgICAgICAgICAgICAgICAgLy8gaW5kaWNhdGUgdG8gY2xpZW50IHByb2Nlc3MgdGhhdCB0aGUgdHJhY2sgd2FzIGRpc2FibGVkIGJlY2F1c2Ugb2YKKyAgICAgICAgICAgICAgICAgICAgICAgIC8vIHVuZGVycnVuOyBpdCB3aWxsIHRoZW4gYXV0b21hdGljYWxseSBjYWxsIHN0YXJ0KCkgd2hlbiBkYXRhIGlzIGF2YWlsYWJsZQorICAgICAgICAgICAgICAgICAgICAgICAgdHJhY2stPmRpc2FibGUoKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIC8vIG9ubHkgZG8gaHcgcGF1c2Ugd2hlbiB0cmFjayBpcyBnb2luZyB0byBiZSByZW1vdmVkIGR1ZSB0byBCVUZGRVIgVElNRU9VVC4KKyAgICAgICAgICAgICAgICAgICAgICAgIC8vIHVubGlrZSBtaXhlcnRocmVhZCwgSEFMIGNhbiBiZSBwYXVzZWQgZm9yIGRpcmVjdCBvdXRwdXQKKyAgICAgICAgICAgICAgICAgICAgICAgIEFMT0dXKCJwYXVzZSBiZWNhdXNlIG9mIFVOREVSUlVOLCBmcmFtZXNSZWFkeSA9ICV6dSwiCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICJtaW5GcmFtZXMgPSAldSwgbUZvcm1hdCA9ICUjeCIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZyYW1lc1JlYWR5LCBtaW5GcmFtZXMsIG1Gb3JtYXQpOworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxhc3QgJiYgbUh3U3VwcG9ydHNQYXVzZSAmJiAhbUh3UGF1c2VkICYmICFtU3RhbmRieSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvSHdQYXVzZSA9IHRydWU7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUh3UGF1c2VkID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobGFzdCkgewogICAgICAgICAgICAgICAgICAgICBtaXhlclN0YXR1cyA9IE1JWEVSX1RSQUNLU19FTkFCTEVEOwpAQCAtNjQ2NSw2ICs2NDk5LDcgQEAKICAgICAgICAgICAgIG1PdXRwdXQtPnN0YW5kYnkoKTsKICAgICAgICAgICAgIGlmICghbVN0YW5kYnkpIHsKICAgICAgICAgICAgICAgICBtVGhyZWFkTWV0cmljcy5sb2dFbmRJbnRlcnZhbCgpOworICAgICAgICAgICAgICAgIG1UaHJlYWRTbmFwc2hvdC5vbkVuZCgpOwogICAgICAgICAgICAgICAgIG1TdGFuZGJ5ID0gdHJ1ZTsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIG1CeXRlc1dyaXR0ZW4gPSAwOwpAQCAtNjUzMCw2ICs2NTY1LDcgQEAKIAogdm9pZCBBdWRpb0ZsaW5nZXI6OkRpcmVjdE91dHB1dFRocmVhZDo6Zmx1c2hId19sKCkKIHsKKyAgICBQbGF5YmFja1RocmVhZDo6Zmx1c2hId19sKCk7CiAgICAgbU91dHB1dC0+Zmx1c2goKTsKICAgICBtSHdQYXVzZWQgPSBmYWxzZTsKICAgICBtRmx1c2hQZW5kaW5nID0gZmFsc2U7CkBAIC02NjY1LDggKzY3MDEsNyBAQAogQXVkaW9GbGluZ2VyOjpPZmZsb2FkVGhyZWFkOjpPZmZsb2FkVGhyZWFkKGNvbnN0IHNwPEF1ZGlvRmxpbmdlcj4mIGF1ZGlvRmxpbmdlciwKICAgICAgICAgQXVkaW9TdHJlYW1PdXQqIG91dHB1dCwgYXVkaW9faW9faGFuZGxlX3Qg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KICAgICAgICAgICAgICAgICAgICAgdHJhY2stPnJlc2V0KCk7CiAgICAgICAgICAgICAgICAgICAgIHRyYWNrc1RvUmVtb3ZlLT5hZGQodHJhY2spOwogICAgICAgICAgICAgICAgICAgICAvLyBPRkZMT0FERUQgc3RvcCByZXNldHMgZnJhbWUgY291bnRzLgpAQCAtNjg4MywxOSArNjkxOSw3IEBACiAgICAgICAgICAgICAgICAgLy8gTm8gYnVmZmVycyBmb3IgdGhpcyB0cmFjay4gR2l2ZSBpdCBhIGZldyBjaGFuY2VzIHRvCiAgICAgICAgICAgICAgICAgLy8gZmlsbCBhIGJ1ZmZlciwgdGhlbiByZW1vdmUgaXQgZnJvbSBhY3RpdmUgbGlzdC4KICAgICAgICAgICAgICAgICBpZiAoLS0odHJhY2stPm1SZXRyeUNvdW50KSA8PSAwKSB7Ci0gICAgICAgICAgICAgICAgICAgIGJvb2wgcnVubmluZyA9IGZhbHNlOwotICAgICAgICAgICAgICAgICAgICB1aW50NjRfdCBwb3NpdGlvbiA9IDA7Ci0gICAgICAgICAgICAgICAgICAgIHN0cnVjdCB0aW1lc3BlYyB1bnVzZWQ7Ci0gICAgICAgICAgICAgICAgICAgIC8vIFRoZSBydW5uaW5nIGNoZWNrIHJlc3RhcnRzIHRoZSByZXRyeSBjb3VudGVyIGF0IGxlYXN0IG9uY2UuCi0gICAgICAgICAgICAgICAgICAgIHN0YXR1c190IHJldCA9IG1PdXRwdXQtPnN0cmVhbS0+Z2V0UHJlc2VudGF0aW9uUG9zaXRpb24oJnBvc2l0aW9uLCAmdW51c2VkKTsKLSAgICAgICAgICAgICAgICAgICAgaWYgKHJldCA9PSBOT19FUlJPUiAmJiBwb3NpdGlvbiAhPSBtT2ZmbG9hZFVuZGVycnVuUG9zaXRpb24pIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIHJ1bm5pbmcgPSB0cnVlOwotICAgICAgICAgICAgICAgICAgICAgICAgbU9mZmxvYWRVbmRlcnJ1blBvc2l0aW9uID0gcG9zaXRpb247Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgaWYgKHJldCA9PSBOT19FUlJPUikgewotICAgICAgICAgICAgICAgICAgICAgICAgQUxPR1ZWKCJ1bmRlcnJ1biBjb3VudGVyLCBydW5uaW5nKCVkKTogJWxsZCB2cyAlbGxkIiwgcnVubmluZywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGxvbmcgbG9uZylwb3NpdGlvbiwgKGxvbmcgbG9uZyltT2ZmbG9hZFVuZGVycnVuUG9zaXRpb24pOwotICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJvb2wgcnVubmluZyA9IGNoZWNrUnVubmluZ1RpbWVzdGFtcCgpOwogICAgICAgICAgICAgICAgICAgICBpZiAocnVubmluZykgeyAvLyBzdGlsbCBydW5uaW5nLCBnaXZlIHVzIG1vcmUgdGltZS4KICAgICAgICAgICAgICAgICAgICAgICAgIHRyYWNrLT5tUmV0cnlDb3VudCA9IGtNYXhUcmFja1JldHJpZXNPZmZsb2FkOwogICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewpAQCAtNjk2Niw3ICs2OTkwLDYgQEAKICAgICBtUGF1c2VkQnl0ZXNSZW1haW5pbmcgPSAwOwogICAgIC8vIHJlc2V0IGJ5dGVzIHdyaXR0ZW4gY291bnQgdG8gcmVmbGVjdCB0aGF0IERTUCBidWZmZXJzIGFyZSBlbXB0eSBhZnRlciBmbHVzaC4KICAgICBtQnl0ZXNXcml0dGVuID0gMDsKLSAgICBtT2ZmbG9hZFVuZGVycnVuUG9zaXRpb24gPSB+MExMOwogCiAgICAgaWYgKG1Vc2VBc3luY1dyaXRlKSB7CiAgICAgICAgIC8vIGRpc2NhcmQgYW55IHBlbmRpbmcgZHJhaW4gb3Igd3JpdGUgYWNrIGJ5IGluY3JlbWVudGluZyBzZXF1ZW5jZQpAQCAtNzA2NCw2ICs3MDg3LDcgQEAKICAgICB9CiAgICAgaWYgKG1TdGFuZGJ5KSB7CiAgICAgICAgIG1UaHJlYWRNZXRyaWNzLmxvZ0JlZ2luSW50ZXJ2YWwoKTsKKyAgICAgICAgbVRocmVhZFNuYXBzaG90Lm9uQmVnaW4oKTsKICAgICAgICAgbVN0YW5kYnkgPSBmYWxzZTsKICAgICB9CiAgICAgcmV0dXJuIChzc2l6ZV90KW1TaW5rQnVmZmVyU2l6ZTsKQEAgLTc1ODksNiArNzYxMyw3IEBACiAgICAgICAgICAgICAgICAgICAgIGRvQnJvYWRjYXN0ID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgaWYgKG1TdGFuZGJ5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBtVGhyZWFkTWV0cmljcy5sb2dCZWdpbkludGVydmFsKCk7CisgICAgICAgICAgICAgICAgICAgICAgICBtVGhyZWFkU25hcHNob3Qub25CZWdpbigpOwogICAgICAgICAgICAgICAgICAgICAgICAgbVN0YW5kYnkgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICBhY3RpdmVUcmFjay0+bVN0YXRlID0gVHJhY2tCYXNlOjpBQ1RJVkU7CkBAIC03NzYxLDYgKzc3ODYsNyBAQAogCiAgICAgICAgICAgICBjb25zdCBzc2l6ZV90IGF2YWlsYWJsZVRvUmVhZCA9IG1QaXBlU291cmNlLT5hdmFpbGFibGVUb1JlYWQoKTsKICAgICAgICAgICAgIGlmIChhdmFpbGFibGVUb1JlYWQgPj0gMCkgeworICAgICAgICAgICAgICAgIG1Nb25vcGlwZVBpcGVEZXB0aFN0YXRzLmFkZChhdmFpbGFibGVUb1JlYWQpOwogICAgICAgICAgICAgICAgIC8vIFBpcGVTb3VyY2UgaXMgdGhlIHByaW1hcnkgY2xvY2suICBJdCBpcyB1cCB0byB0aGUgQXVkaW9SZWNvcmQgY2xpZW50IHRvIGtlZXAgdXAuCiAgICAgICAgICAgICAgICAgTE9HX0FMV0FZU19GQVRBTF9JR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ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRjaC0+c2lua3MsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhbmRsZSk7CiAgICAgfSBlbHNlIHsKLSAgICAgICAgY2hhciAqYWRkcmVzczsKLSAgICAgICAgaWYgKHN0cmNtcChwYXRjaC0+c291cmNlc1swXS5leHQuZGV2aWNlLmFkZHJlc3MsICIiKSAhPSAwKSB7Ci0gICAgICAgICAgICBhZGRyZXNzID0gYXVkaW9fZGV2aWNlX2FkZHJlc3NfdG9fcGFyYW1ldGVyKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0Y2gtPnNvdXJjZXNbMF0uZXh0LmRldmljZS50eXBlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0Y2gtPnNvdXJjZXNbMF0uZXh0LmRldmljZS5hZGRyZXNzKTsKLSAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIGFkZHJlc3MgPSAoY2hhciAqKWNhbGxvYygxLCAxKTsKLSAgICAgICAgfQotICAgICAgICBBdWRpb1BhcmFtZXRlciBwYXJhbSA9IEF1ZGlvUGFyYW1ldGVyKFN0cmluZzgoYWRkcmVzcykpOwotICAgICAgICBmcmVlKGFkZHJlc3MpOwotICAgICAgICBwYXJhbS5hZGRJbnQoU3RyaW5nOChBdWRpb1BhcmFtZXRlcjo6a2V5Um91dGluZyksCi0gICAgICAgICAgICAgICAgICAgICAoaW50KXBhdGNoLT5zb3VyY2VzWzBdLmV4dC5kZXZpY2UudHlwZSk7Ci0gICAgICAgIHBhcmFtLmFkZEludChTdHJpbmc4KEF1ZGlvUGFyYW1ldGVyOjprZXlJbnB1dFNvdXJjZSksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChpbnQpcGF0Y2gtPnNpbmtzWzBdLmV4dC5taXgudXNlY2FzZS5zb3VyY2UpOwotICAgICAgICBzdGF0dXMgPSBtSW5wdXQtPnN0cmVhbS0+c2V0UGFyYW1ldGVycyhwYXJhbS50b1N0cmluZygpKTsKKyAgICAgICAgc3RhdHVzID0gbUlucHV0LT5zdHJlYW0tPmxlZ2FjeUNyZWF0ZUF1ZGlvUGF0Y2gocGF0Y2gtPnNvdXJjZXNbMF0sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGNoLT5zaW5rc1swXS5leHQubWl4LnVzZWNhc2Uuc291cmNlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRjaC0+c291cmNlc1swXS5leHQuZGV2aWNlLnR5cGUpOwogICAgICAgICAqaGFuZGxlID0gQVVESU9fUEFUQ0hfSEFORExFX05PTkU7CiAgICAgfQogCkBAIC05MTY4LDkgKzkxNzQsNyBAQAogICAgICAgICBzcDxEZXZpY2VIYWxJbnRlcmZhY2U+IGh3RGV2aWNlID0gbUlucHV0LT5hdWRpb0h3RGV2LT5od0RldmljZSgpOwogICAgICAgICBzdGF0dXMgPSBod0RldmljZS0+cmVsZWFzZUF1ZGlvUGF0Y2goaGFuZGxlKTsKICAgICB9IGVsc2UgewotICAgICAgICBBdWRpb1BhcmFtZXRlciBwYXJhbTsKLSAgICAgICAgcGFyYW0uYWRkSW50KFN0cmluZzgoQXVkaW9QYXJhbWV0ZXI6OmtleVJvdXRpbmcpLCAwKTsKLSAgICAgICAgc3RhdHVzID0gbUlucHV0LT5zdHJlYW0tPnNldFBhcmFtZXRlcnMocGFyYW0udG9TdHJpbmcoKSk7CisgICAgICAgIHN0YXR1cyA9IG1JbnB1dC0+c3RyZWFtLT5sZWdhY3lSZWxlYXNlQXVkaW9QYXRjaCgpOwogICAgIH0KICAgICByZXR1cm4gc3RhdHVzOwogfQpAQCAtOTQ3Nyw2ICs5NDgxLDcgQEAKICAgICB9CiAgICAgaWYgKG1TdGFuZGJ5KSB7CiAgICAgICAgIG1UaHJlYWRNZXRyaWNzLmxvZ0JlZ2luSW50ZXJ2YWwoKTsKKyAgICAgICAgbVRocmVhZFNuYXBzaG90Lm9uQmVnaW4oKTsKICAgICAgICAgbVN0YW5kYnkgPSBmYWxzZTsKICAgICB9CiAgICAgcmV0dXJuIE5PX0VSUk9SOwpAQCAtOTUxNiw2ICs5NTIxLDcgQEAKICAgICAgICAgICAgICAgICAoYXVkaW9fb3V0cHV0X2ZsYWdzX3QpKEFVRElPX09VVFBVVF9GTEFHX01NQVBfTk9JUlEgfCBBVURJT19PVVRQVVRfRkxBR19ESVJFQ1QpOwogICAgICAgICBhdWRpb19wb3J0X2hhbmRsZV90IGRldmljZUlkID0gbURldmljZUlkOwogICAgICAgICBzdGQ6OnZlY3RvcjxhdWRpb19pb19oYW5kbGVfdD4gc2Vjb25kYXJ5T3V0cHV0czsKKyAgICAgICAgYm9vbCBpc1NwYXRpYWxpemVkOwogICAgICAgICByZXQgPSBBdWRpb1N5c3RlbTo6Z2V0T3V0cHV0Rm9yQXR0cigmbUF0dHIsICZpbywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbVNlc3Npb25JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJnN0cmVhbSwKQEAgLTk1MjQsNyArOTUzMCw4IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZsYWdzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmZGV2aWNlSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZwb3J0SWQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZzZWNvbmRhcnlPdXRwdXRzKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJnNlY29uZGFyeU91dHB1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fT1VUUFVUX0NMT1NFRDoKICAgICBkZWZhdWx0OgorICAgICAgICBkZXNjID0gc3A8QXVkaW9Jb0Rlc2NyaXB0b3I+OjptYWtlKG1JZCk7CiAgICAgICAgIGJyZWFrOwogICAgIH0KICAgICBtQXVkaW9GbGluZ2VyLT5pb0NvbmZpZ0NoYW5nZWQoZXZlbnQsIGRlc2MsIHBpZCk7CkBAIC05OTA1LDI5ICs5OTA4LDE4IEBACiAgICAgfQogCiAgICAgaWYgKG1BdWRpb0h3RGV2LT5zdXBwb3J0c0F1ZGlvUGF0Y2hlcygpKSB7Ci0gICAgICAgIHN0YXR1cyA9IG1IYWxEZXZpY2UtPmNyZWF0ZUF1ZGlvUGF0Y2gocGF0Y2gtPm51bV9zb3VyY2VzLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRjaC0+c291cmNlcywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0Y2gtPm51bV9zaW5rcywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0Y2gtPnNpbmtzLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYW5kbGUpOworICAgICAgICBzdGF0dXMgPSBtSGFsRGV2aWNlLT5jcmVhdGVBdWRpb1BhdGNoKHBhdGNoLT5udW1fc291cmNlcywgcGF0Y2gtPnNvdXJjZXMsIHBhdGNoLT5udW1fc2lua3MsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0Y2gtPnNpbmtzLCBoYW5kbGUpOwogICAgIH0gZWxzZSB7Ci0gICAgICAgIGNoYXIgKmFkZHJlc3M7Ci0gICAgICAgIGlmIChzdHJjbXAocGF0Y2gtPnNpbmtzWzBdLmV4dC5kZXZpY2UuYWRkcmVzcywgIiIpICE9IDApIHsKLSAgICAgICAgICAgIC8vRklYTUU6IHdlIG9ubHkgc3VwcG9ydCBhZGRyZXNzIG9uIGZpcnN0IHNpbmsgd2l0aCBIQUwgdmVyc2lvbiA8IDMuMAotICAgICAgICAgICAgYWRkcmVzcyA9IGF1ZGlvX2RldmljZV9hZGRyZXNzX3RvX3BhcmFtZXRlcigKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0Y2gtPnNpbmtzWzBdLmV4dC5kZXZpY2UudHlwZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0Y2gtPnNpbmtzWzBdLmV4dC5kZXZpY2UuYWRkcmVzcyk7CisgICAgICAgIGF1ZGlvX3BvcnRfY29uZmlnIHBvcnQ7CisgICAgICAgIHN0ZDo6b3B0aW9uYWw8YXVkaW9fc291cmNlX3Q+IHNvdXJjZTsKKyAgICAgICAgaWYgKGlzT3V0cHV0KCkpIHsKKyAgICAgICAgICAgIHBvcnQgPSBwYXRjaC0+c2lua3NbMF07CiAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICBhZGRyZXNzID0gKGNoYXIgKiljYWxsb2MoMSwgMSk7CisgICAgICAgICAgICBwb3J0ID0gcGF0Y2gtPnNvdXJjZXNbMF07CisgICAgICAgICAgICBzb3VyY2UgPSBwYXRjaC0+c2lua3NbMF0uZXh0Lm1peC51c2VjYXNlLnNvdXJjZTsKICAgICAgICAgfQotICAgICAgICBBdWRpb1BhcmFtZXRlciBwYXJhbSA9IEF1ZGlvUGFyYW1ldGVyKFN0cmluZzgoYWRkcmVzcykpOwotICAgICAgICBmcmVlKGFkZHJlc3MpOwotICAgICAgICBwYXJhbS5hZGRJbnQoU3RyaW5nOChBdWRpb1BhcmFtZXRlcjo6a2V5Um91dGluZyksIChpbnQpdHlwZSk7Ci0gICAgICAgIGlmICghaXNPdXRwdXQoKSkgewotICAgICAgICAgICAgcGFyYW0uYWRkSW50KFN0cmluZzgoQXVkaW9QYXJhbWV0ZX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ZmlnRXZlbnQoYXVkaW9faW9fY29uZmlnX2V2ZW50X3QgZXZlbnQsIHBpZF90IHBpZCwgYXVkaW9fcG9ydF9oYW5kbGVfdCBwb3J0SWQpIDoKICAgICAgICAgICAgIENvbmZpZ0V2ZW50KENGR19FVkVOVF9JTykgewogICAgICAgICAgICAgbURhdGEgPSBuZXcgSW9Db25maWdFdmVudERhdGEoZXZlbnQsIHBpZCwgcG9ydElkKTsKICAgICAgICAgfQpAQCAtMzMyLDE1ICszMzIsMTUgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXNfdCYgc3RhdHVzKSA9IDA7CiAgICAgdmlydHVhbCAgICAgc3RhdHVzX3QgICAgc2V0UGFyYW1ldGVycyhjb25zdCBTdHJpbmc4JiBrZXlWYWx1ZVBhaXJzKTsKICAgICB2aXJ0dWFsICAgICBTdHJpbmc4ICAgICBnZXRQYXJhbWV0ZXJzKGNvbnN0IFN0cmluZzgmIGtleXMpID0gMDsKLSAgICB2aXJ0dWFsICAgICB2b2lkICAgICAgICBpb0NvbmZpZ0NoYW5nZWQoYXVkaW9faW9fY29uZmlnX2V2ZW50IGV2ZW50LCBwaWRfdCBwaWQgPSAwLAorICAgIHZpcnR1YWwgICAgIHZvaWQgICAgICAgIGlvQ29uZmlnQ2hhbmdlZChhdWRpb19pb19jb25maWdfZXZlbnRfdCBldmVudCwgcGlkX3QgcGlkID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19wb3J0X2hhbmRsZV90IHBvcnRJZCA9IEFVRElPX1BPUlRfSEFORExFX05PTkUpID0gMDsKICAgICAgICAgICAgICAgICAvLyBzZW5kQ29uZmlnRXZlbnRfbCgpIG11c3QgYmUgY2FsbGVkIHdpdGggVGhyZWFkQmFzZTo6bUxvY2sgaGVsZAogICAgICAgICAgICAgICAgIC8vIENhbiB0ZW1wb3JhcmlseSByZWxlYXNlIHRoZSBsb2NrIGlmIHdhaXRpbmcgZm9yIGEgcmVwbHkgZnJvbQogICAgICAgICAgICAgICAgIC8vIHByb2Nlc3NDb25maWdFdmVudHNfbCgpLgogICAgICAgICAgICAgICAgIHN0YXR1c190ICAgIHNlbmRDb25maWdFdmVudF9sKHNwPENvbmZpZ0V2ZW50PiYgZXZlbnQpOwotICAgICAgICAgICAgICAgIHZvaWQgICAgICAgIHNlbmRJb0NvbmZpZ0V2ZW50KGF1ZGlvX2lvX2NvbmZpZ19ldmVudCBldmVudCwgcGlkX3QgcGlkID0gMCwKKyAgICAgICAgICAgICAgICB2b2lkICAgICAgICBzZW5kSW9Db25maWdFdmVudChhdWRpb19pb19jb25maWdfZXZlbnRfdCBldmVudCwgcGlkX3QgcGlkID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19wb3J0X2hhbmRsZV90IHBvcnRJZCA9IEFVRElPX1BPUlRfSEFORExFX05PTkUpOwotICAgICAgICAgICAgICAgIHZvaWQgICAgICAgIHNlbmRJb0NvbmZpZ0V2ZW50X2woYXVkaW9faW9fY29uZmlnX2V2ZW50IGV2ZW50LCBwaWRfdCBwaWQgPSAwLAorICAgICAgICAgICAgICAgIHZvaWQgICAgICAgIHNlbmRJb0NvbmZpZ0V2ZW50X2woYXVkaW9faW9fY29uZmlnX2V2ZW50X3QgZXZlbnQsIHBpZF90IHBpZCA9IDAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX3BvcnRfaGFuZGxlX3QgcG9ydElkID0gQVVESU9fUE9SVF9IQU5ETEVfTk9ORSk7CiAgICAgICAgICAgICAgICAgdm9pZCAgICAgICAgc2VuZFByaW9Db25maWdFdmVudChwaWRfdCBwaWQsIHBpZF90IHRpZCwgaW50MzJfdCBwcmlvLCBib29sIGZvckFwcCk7CiAgICAgICAgICAgICAgICAgdm9pZCAgICAgICAgc2VuZFByaW9Db25maWdFdmVudF9sKHBpZF90IHBpZCwgcGlkX3QgdGlkLCBpbnQzMl90IHByaW8sIGJvb2wgZm9yQXBwKTsKQEAgLTQ4Myw3ICs0ODMsNyBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cmFjay0+aXNGYXN0VHJhY2soKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgfD0gRkFTVF9TRVNTSU9OOyAgLy8gY2F1dGlvbiwgb25seSByZXByZXNlbnRzIGZpcnN0IHRyYWNrLgogICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJhY2stPmNhbkJlU3BhdGlhbGl6ZWQoKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cmFjay0+aXNTcGF0aWFsaXplZCgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCB8PSBTUEFUSUFMSVpFRF9TRVNTSU9OOyAgLy8gY2F1dGlvbiwgb25seSBmaXJzdCB0cmFjay4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CkBAIC02ODcsMTAgKzY4NywxNCBAQAogICAgICAgICAgICAgICAgIGludDY0X3QgICAgICAgICAgICAgICAgIG1MYXN0SW9CZWdpbk5zID0gLTE7CiAgICAgICAgICAgICAgICAgaW50NjRfdCAgICAgICAgICAgICAgICAgbUxhc3RJb0VuZE5zID0gLTE7CiAKKyAgICAgICAgICAgICAgICAvLyBUaHJlYWRTbmFwc2hvdCBpcyB0aHJlYWQtc2FmZSAoaW50ZXJuYWxseSBsb2NrZWQpCisgICAgICAgICAgICAgICAgbWVkaWF1dGlsczo6VGhyZWFkU25hcHNob3QgbVRocmVhZFNuYXBzaG90OworCiAgICAgICAgICAgICAgICAgLy8gVGhpcyBzaG91bGQgYmUgcmVhZCB1bmRlciBUaHJlYWRCYXNlIGxvY2sgKGlmIG5vdCBvbiB0aGUgdGhyZWFkTG9vcCB0aHJlYWQpLgogICAgICAgICAgICAgICAgIGF1ZGlvX3V0aWxzOjpTdGF0aXN0aWNzPGRvdWJsZT4gbUlvSml0dGVyTXN7MC45OTUgLyogYWxwaGEgKi99OwogICAgICAgICAgICAgICAgIGF1ZGlvX3V0aWxzOjpTdGF0aXN0aWNzPGRvdWJsZT4gbVByb2Nlc3NUaW1lTXN7MC45OTUgLyogYWxwaGEgKi99OwogICAgICAgICAgICAgICAgIGF1ZGlvX3V0aWxzOjpTdGF0aXN0aWNzPGRvdWJsZT4gbUxhdGVuY3lNc3swLjk5NSAvKiBhbHBoYSAqL307CisgICAgICAgICAgICAgICAgYXVkaW9fdXRpbHM6OlN0YXRpc3RpY3M8ZG91YmxlPiBtTW9ub3BpcGVQaXBlRGVwdGhTdGF0c3swLjk5OSAvKiBhbHBoYSAqL307CiAKICAgICAgICAgICAgICAgICAvLyBTYXZlIHRoZSBsYXN0IGNvdW50IHdoZW4gd2UgZGVsaXZlcmVkIHN0YXRpc3RpY3MgdG8gbWVkaWFtZXRyaWNzLgogICAgICAgICAgICAgICAgIGludDY0X3QgICAgICAgICAgICAgICAgIG1MYXN0UmVjb3JkZWRUaW1lc3RhbXBWZXJpZmllck4gPSAwOwpAQCAtOTU5LDcgKzk2Myw4IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBpZF90IHRpZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzX3QgKnN0YXR1cyAvKm5vbi1OVUxMKi8sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX3BvcnRfaGFuZGxlX3QgcG9ydElkLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcDxtZWRpYTo6SUF1ZGlvVHJhY2tDYWxsYmFjaz4mIGNhbGxiYWNrKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3A8bWVkaWE6OklBdWRpb1RyYWNrQ2FsbGJhY2s+JiBjYWxsYmFjaywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBpc1NwYXRpYWxpemVkKTsKIAogICAgICAgICAgICAgICAgIEF1ZGlvU3RyZWFtT3V0KiBnZXRPdXRwdXQoKSBjb25zdDsKICAgICAgICAgICAgICAgICBBdWRpb1N0cmVhbU91dCogY2xlYXJPdXRwdXQoKTsKQEAgLTk3OSw3ICs5ODQsNyBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7IHJldHVybiBhbmRyb2lkX2F0b21pY19hY3F1aXJlX2xvYWQoJm1TdXNwZW5kZWQpID4gMDsgfQogCiAgICAgdmlydHVhbCAgICAgU3RyaW5nOCAgICAgZ2V0UGFyYW1ldGVycyhjb25zdCBTdHJpbmc4JiBrZXlzKTsKLSAgICB2aXJ0dWFsICAgICB2b2lkICAgICAgICBpb0NvbmZpZ0NoYW5nZWQoYXVkaW9faW9fY29uZmlnX2V2ZW50IGV2ZW50LCBwaWRfdCBwaWQgPSAwLAorICAgIHZpcnR1YWwgICAgIHZvaWQgICAgICAgIGlvQ29uZmlnQ2hhbmdlZChhdWRpb19pb19jb25maWdfZXZlbnRfdCBldmVudCwgcGlkX3QgcGlkID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fcG9ydF9oYW5kbGVfdCBwb3J0SWQgPSBBVURJT19QT1JUX0hBTkRMRV9OT05FKTsKICAgICAgICAgICAgICAgICBzdGF0dXNfdCAgICBnZXRSZW5kZXJQb3NpdGlvbih1aW50MzJfdCAqaGFsRnJhbWVzLCB1aW50MzJfdCAqZHNwRnJhbWVzKTsKICAgICAgICAgICAgICAgICAvLyBDb25zaWRlciBhbHNvIHJlbW92aW5nIGFuZCBwYXNzaW5nIGFuIGV4cGxpY2l0IG1NYWluQnVmZmVyIGluaXRpYWxpemF0aW9uCkBAIC0xMzc1LDYgKzEzODAsMTQgQEAKICAgICAgICAgICAgICAgICBzdHJ1Y3QgYXVkaW9fcGF0Y2ggbURvd25TdHJlYW1QYXRjaDsKIAogICAgICAgICAgICAgICAgIHN0ZDo6YXRvbWljX2Jvb2wgbUNoZWNrT3V0cHV0U3RhZ2VFZmZlY3Rze307CisKKyAgICAgICAgICAgICAgICAvLyBBIGRpZmZlcmVudGlhbCBjaGVjayBvbiB0aGUgdGltZXN0YW1wcyB0byBzZWUgaWYgdGhlcmUgaXMgYSBjaGFuZ2UgaW4gdGhlCisgICAgICAgICAgICAgICAgLy8gdGltZXN0YW1wIGZyYW1lIHBvc2l0aW9uIGJldHdlZW4gdGhlIGxhc3QgY2FsbCB0byBjaGVja1J1bm5pbmdUaW1lc3RhbXAuCisgICAgICAgICAgICAgICAgdWludDY0X3QgbUxhc3RDaGVja2VkVGltZXN0YW1wUG9zaXRpb24gPSB+MExMOworCisgICAgICAgICAgICAgICAgYm9vbCBjaGVja1J1bm5pbmdUaW1lc3RhbXAoKTsKKworICAgIHZpcnR1YWwgICAgIHZvaWQgZmx1c2hId19sKCkgeyBtTGFzdENoZWNrZWRUaW1lc3RhbXBQb3NpdGlvbiA9IH4wTEw7IH0KIH07CiAKIGNsYXNzIE1peGVyVGhyZWFkIDogcHVibGljIFBsYXliYWNrVGhyZWFkIHsKQEAgLTE0OTIsNyArMTUwNSw3IEBACiAgICAgdmlydHVhbCAgICAgYm9vbCAgICAgICAgY2hlY2tGb3JOZXdQYXJhbWV0ZXJfbChjb25zdCBTdHJpbmc4JiBrZXlWYWx1ZVBhaXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXNfdCYgc3RhdHVzKTsKIAotICAgIHZpcnR1YWwgICAgIHZvaWQgICAgICAgIGZsdXNoSHdfbCgpOworICAgICAgICAgICAgICAgIHZvaWQgICAgICAgIGZsdXNoSHdfbCgpIG92ZXJyaWRlOwogCiAgICAgICAgICAgICAgICAgdm9pZC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ICAgICAgICAgICAgLy8gdXNlZCBhbmQgdmFsaWQgb25seSBkdXJpbmcgdW5kZXJydW4uICB+MCBpZgotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gbm8gdW5kZXJydW4gaGFzIG9jY3VycmVkIGR1cmluZyBwbGF5YmFjayBhbmQKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGlzIG5vdCByZXNldCBvbiBzdGFuZGJ5LgogfTsKIAogY2xhc3MgQXN5bmNDYWxsYmFja1RocmVhZCA6IHB1YmxpYyBUaHJlYWQgewpAQCAtMTgwMSw3ICsxODEwLDcgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzX3QmIHN0YXR1cyk7CiAgICAgdmlydHVhbCB2b2lkICAgICAgICBjYWNoZVBhcmFtZXRlcnNfbCgpIHt9CiAgICAgdmlydHVhbCBTdHJpbmc4ICAgICBnZXRQYXJhbWV0ZXJzKGNvbnN0IFN0cmluZzgmIGtleXMpOwotICAgIHZpcnR1YWwgdm9pZCAgICAgICAgaW9Db25maWdDaGFuZ2VkKGF1ZGlvX2lvX2NvbmZpZ19ldmVudCBldmVudCwgcGlkX3QgcGlkID0gMCwKKyAgICB2aXJ0dWFsIHZvaWQgICAgICAgIGlvQ29uZmlnQ2hhbmdlZChhdWRpb19pb19jb25maWdfZXZlbnRfdCBldmVudCwgcGlkX3QgcGlkID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19wb3J0X2hhbmRsZV90IHBvcnRJZCA9IEFVRElPX1BPUlRfSEFORExFX05PTkUpOwogICAgIHZpcnR1YWwgc3RhdHVzX3QgICAgY3JlYXRlQXVkaW9QYXRjaF9sKGNvbnN0IHN0cnVjdCBhdWRpb19wYXRjaCAqcGF0Y2gsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fcGF0Y2hfaGFuZGxlX3QgKmhhbmRsZSk7CkBAIC0xODU5LDYgKzE4NjgsOCBAQAogCiAgICAgICAgICAgICBib29sICAgICAgICBpc1RpbWVzdGFtcENvcnJlY3Rpb25FbmFibGVkKCkgY29uc3Qgb3ZlcnJpZGUgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGNoZWNrcyBwb3Bjb3VudCBmb3IgZXhhY3RseSBvbmUgZGV2aWNlLgorICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIElzIGN1cnJlbnRseSBkaXNhYmxlZC4gQmVmb3JlIGVuYWJsaW5nLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHZlcmlmeSBjb21wcmVzc2VkIHJlY29yZCB0aW1lc3RhbXBzLgogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhdWRpb19pc19pbnB1dF9kZXZpY2UobVRpbWVzdGFtcENvcnJlY3RlZERldmljZSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICYmIGluRGV2aWNlVHlwZSgpID09IG1UaW1lc3RhbXBDb3JyZWN0ZWREZXZpY2U7CiAgICAgICAgICAgICAgICAgICAgICAgICB9CkBAIC0yMDEwLDcgKzIwMjEsNyBAQAogICAgIHZpcnR1YWwgICAgIGJvb2wgICAgICAgIGNoZWNrRm9yTmV3UGFyYW1ldGVyX2woY29uc3QgU3RyaW5nOCYga2V5VmFsdWVQYWlyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXR1c190JiBzdGF0dXMpOwogICAgIHZpcnR1YWwgICAgIFN0cmluZzggICAgIGdldFBhcmFtZXRlcnMoY29uc3QgU3RyaW5nOCYga2V5cyk7Ci0gICAgdmlydHVhbCAgICAgdm9pZCAgICAgICAgaW9Db25maWdDaGFuZ2VkKGF1ZGlvX2lvX2NvbmZpZ19ldmVudCBldmVudCwgcGlkX3QgcGlkID0gMCwKKyAgICB2aX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U3RhcnRWb2x1bWVUaW1lTnMpOwogICAgICAgICBtVm9sdW1lID0gdm9sdW1lOwogICAgICAgICBtTGFzdFZvbHVtZUNoYW5nZVRpbWVOcyA9IHRpbWVOczsKICAgICB9CkBAIC0xNTcsNyArMTc1LDExIEBACiAgICAgICAgICAgICAgICAgLnNldChBTUVESUFNRVRSSUNTX1BST1BfRVZFTlQsIGV2ZW50TmFtZSkKICAgICAgICAgICAgICAgICAuc2V0KEFNRURJQU1FVFJJQ1NfUFJPUF9JTlRFUlZBTENPVU5ULCAoaW50MzJfdCltSW50ZXJ2YWxDb3VudCk7CiAgICAgICAgICAgICBpZiAobUlzT3V0KSB7Ci0gICAgICAgICAgICAgICAgaXRlbS5zZXQoQU1FRElBTUVUUklDU19QUk9QX0RFVklDRVZPTFVNRSwgbURldmljZVZvbHVtZSk7CisgICAgICAgICAgICAgICAgaXRlbS5zZXQoQU1FRElBTUVUUklDU19QUk9QX0RFVklDRVZPTFVNRSwgbURldmljZVZvbHVtZSkKKyAgICAgICAgICAgICAgICAgICAgLnNldChBTUVESUFNRVRSSUNTX1BST1BfREVWSUNFTUFYVk9MVU1FRFVSQVRJT05OUywgbU1heFZvbHVtZUR1cmF0aW9uTnMpCisgICAgICAgICAgICAgICAgICAgIC5zZXQoQU1FRElBTUVUUklDU19QUk9QX0RFVklDRU1BWFZPTFVNRSwgbU1heFZvbHVtZSkKKyAgICAgICAgICAgICAgICAgICAgLnNldChBTUVESUFNRVRSSUNTX1BST1BfREVWSUNFTUlOVk9MVU1FRFVSQVRJT05OUywgbU1pblZvbHVtZUR1cmF0aW9uTnMpCisgICAgICAgICAgICAgICAgICAgIC5zZXQoQU1FRElBTUVUUklDU19QUk9QX0RFVklDRU1JTlZPTFVNRSwgbU1pblZvbHVtZSk7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBpZiAobURldmljZUxhdGVuY3lNcy5nZXROKCkgPiAwKSB7CiAgICAgICAgICAgICAgICAgaXRlbS5zZXQoQU1FRElBT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1RPTkU7CisgICAgICAgICAgICBtZXRhZGF0YS5iYXNlLmNvbnRlbnRfdHlwZSA9IEFVRElPX0NPTlRFTlRfVFlQRV9TT05JRklDQVRJT047CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBBVURJT19TVFJFQU1fTVVTSUM6CisgICAgICAgICAgICBtZXRhZGF0YS5iYXNlLnVzYWdlID0gQVVESU9fVVNBR0VfTUVESUE7CisgICAgICAgICAgICBtZXRhZGF0YS5iYXNlLmNvbnRlbnRfdHlwZSA9IEFVRElPX0NPTlRFTlRfVFlQRV9NVVNJQzsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIEFVRElPX1NUUkVBTV9BTEFSTToKKyAgICAgICAgICAgIG1ldGFkYXRhLmJhc2UudXNhZ2UgPSBBVURJT19VU0FHRV9BTEFSTTsKKyAgICAgICAgICAgIG1ldGFkYXRhLmJhc2UuY29udGVudF90eXBlID0gQVVESU9fQ09OVEVOVF9UWVBFX1NPTklGSUNBVElPTjsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIEFVRElPX1NUUkVBTV9OT1RJRklDQVRJT046CisgICAgICAgICAgICBtZXRhZGF0YS5iYXNlLnVzYWdlID0gQVVESU9fVVNBR0VfTk9USUZJQ0FUSU9OOworICAgICAgICAgICAgbWV0YWRhdGEuYmFzZS5jb250ZW50X3R5cGUgPSBBVURJT19DT05URU5UX1RZUEVfU09OSUZJQ0FUSU9OOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgQVVESU9fU1RSRUFNX0RUTUY6CisgICAgICAgICAgICBtZXRhZGF0YS5iYXNlLnVzYWdlID0gQVVESU9fVVNBR0VfVk9JQ0VfQ09NTVVOSUNBVElPTl9TSUdOQUxMSU5HOworICAgICAgICAgICAgbWV0YWRhdGEuYmFzZS5jb250ZW50X3R5cGUgPSBBVURJT19DT05URU5UX1RZUEVfU09OSUZJQ0FUSU9OOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgQVVESU9fU1RSRUFNX0FDQ0VTU0lCSUxJVFk6CisgICAgICAgICAgICBtZXRhZGF0YS5iYXNlLnVzYWdlID0gQVVESU9fVVNBR0VfQVNTSVNUQU5DRV9BQ0NFU1NJQklMSVRZOworICAgICAgICAgICAgbWV0YWRhdGEuYmFzZS5jb250ZW50X3R5cGUgPSBBVURJT19DT05URU5UX1RZUEVfU1BFRUNIOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgQVVESU9fU1RSRUFNX0FTU0lTVEFOVDoKKyAgICAgICAgICAgIG1ldGFkYXRhLmJhc2UudXNhZ2UgPSBBVURJT19VU0FHRV9BU1NJU1RBTlQ7CisgICAgICAgICAgICBtZXRhZGF0YS5iYXNlLmNvbnRlbnRfdHlwZSA9IEFVRElPX0NPTlRFTlRfVFlQRV9TUEVFQ0g7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBBVURJT19TVFJFQU1fUkVST1VUSU5HOgorICAgICAgICAgICAgbWV0YWRhdGEuYmFzZS51c2FnZSA9IEFVRElPX1VTQUdFX1ZJUlRVQUxfU09VUkNFOworICAgICAgICAgICAgLy8gdW5rbm93biBjb250ZW50IHR5cGUKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIEFVRElPX1NUUkVBTV9DQUxMX0FTU0lTVEFOVDoKKyAgICAgICAgICAgIG1ldGFkYXRhLmJhc2UudXNhZ2UgPSBBVURJT19VU0FHRV9DQUxMX0FTU0lTVEFOVDsKKyAgICAgICAgICAgIG1ldGFkYXRhLmJhc2UuY29udGVudF90eXBlID0gQVVESU9fQ09OVEVOVF9UWVBFX1NQRUVDSDsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICB9CisKICAgICBtZXRhZGF0YS5jaGFubmVsX21hc2sgPSBtQ2hhbm5lbE1hc2ssCiAgICAgc3RybmNwe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yAgICB2aXJ0dWFsIHN0YXR1c190IHNldERldmljZUNvbm5lY3Rpb25TdGF0ZShhdWRpb19wb2xpY3lfZGV2X3N0YXRlX3Qgc3RhdGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYW5kcm9pZDo6bWVkaWE6OmF1ZGlvOjpjb21tb246OkF1ZGlvUG9ydCYgcG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19mb3JtYXRfdCBlbmNvZGVkRm9ybWF0KSA9IDA7CiAgICAgLy8gcmV0cmlldmUgYSBkZXZpY2UgY29ubmVjdGlvbiBzdGF0dXMKICAgICB2aXJ0dWFsIGF1ZGlvX3BvbGljeV9kZXZfc3RhdGVfdCBnZXREZXZpY2VDb25uZWN0aW9uU3RhdGUoYXVkaW9fZGV2aWNlc190IGRldmljZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hhciAqZGV2aWNlX2FkZHJlc3MpID0gMDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hhciAqZGV2aWNlX2FkZHJlc3MpID0gMDsKICAgICAvLyBpbmRpY2F0ZSBhIGNoYW5nZSBpbiBkZXZpY2UgY29uZmlndXJhdGlvbgogICAgIHZpcnR1YWwgc3RhdHVzX3QgaGFuZGxlRGV2aWNlQ29uZmlnQ2hhbmdlKGF1ZGlvX2RldmljZXNfdCBkZXZpY2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hhciAqZGV2aWNlX2FkZHJlc3MsCkBAIC0xMzIsMTAgKzE0MywxMyBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX3BvcnRfaGFuZG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VSQ0VfVk9JQ0VfQ09NTVVOSUNBVElPTjoKLSAgICAgICAgcmV0dXJuIDk7CisgICAgICAgIHJldHVybiAxMDsKICAgICBjYXNlIEFVRElPX1NPVVJDRV9DQU1DT1JERVI6Ci0gICAgICAgIHJldHVybiA4OworICAgICAgICByZXR1cm4gOTsKICAgICBjYXNlIEFVRElPX1NPVVJDRV9WT0lDRV9QRVJGT1JNQU5DRToKLSAgICAgICAgcmV0dXJuIDc7CisgICAgICAgIHJldHVybiA4OwogICAgIGNhc2UgQVVESU9fU09VUkNFX1VOUFJPQ0VTU0VEOgotICAgICAgICByZXR1cm4gNjsKKyAgICAgICAgcmV0dXJuIDc7CiAgICAgY2FzZSBBVURJT19TT1VSQ0VfTUlDOgotICAgICAgICByZXR1cm4gNTsKKyAgICAgICAgcmV0dXJuIDY7CiAgICAgY2FzZSBBVURJT19TT1VSQ0VfRUNIT19SRUZFUkVOQ0U6Ci0gICAgICAgIHJldHVybiA0OworICAgICAgICByZXR1cm4gNTsKICAgICBjYXNlIEFVRElPX1NPVVJDRV9GTV9UVU5FUjoKLSAgICAgICAgcmV0dXJuIDM7CisgICAgICAgIHJldHVybiA0OwogICAgIGNhc2UgQVVESU9fU09VUkNFX1ZPSUNFX1JFQ09HTklUSU9OOgotICAgICAgICByZXR1cm4gMjsKKyAgICAgICAgcmV0dXJuIDM7CiAgICAgY2FzZSBBVURJT19TT1VSQ0VfSE9UV09SRDoKKyAgICAgICAgcmV0dXJuIDI7CisgICAgY2FzZSBBVURJT19TT1VSQ0VfVUxUUkFTT1VORDoKICAgICAgICAgcmV0dXJuIDE7CiAgICAgZGVmYXVsdDoKICAgICAgICAgYnJlYWs7CmRpZmYgLS1naXQgYS9zZXJ2aWNlcy9hdWRpb3BvbGljeS9jb21tb24vbWFuYWdlcmRlZmluaXRpb25zL0FuZHJvaWQuYnAgYi9zZXJ2aWNlcy9hdWRpb3BvbGljeS9jb21tb24vbWFuYWdlcmRlZmluaXRpb25zL0FuZHJvaWQu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U3RyZWFtVHlwZVZlY3RvciAmLypzdHJlYW1zKi8sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IERldmljZVR5cGVTZXQmIGRldmljZVR5cGVzLApAQCAtMTg4LDcgKzE5MCw2IEBACiAgICAgdG9BdWRpb1BvcnRDb25maWcoJmxvY2FsQmFja3VwQ29uZmlnKTsKICAgICBpZiAoKHN0YXR1cyA9IHZhbGlkYXRpb25CZWZvcmVBcHBseUNvbmZpZyhjb25maWcpKSA9PSBOT19FUlJPUikgewogICAgICAgICBBdWRpb1BvcnRDb25maWc6OmFwcGx5QXVkaW9Qb3J0Q29uZmlnKGNvbmZpZywgYmFja3VwQ29uZmlnKTsKLSAgICAgICAgYXBwbHlQb2xpY3lBdWRpb1BvcnRDb25maWcoY29uZmlnKTsKICAgICB9CiAKICAgICBpZiAoYmFja3VwQ29uZmlnICE9IE5VTEwpIHsKQEAgLTIwMSwxMyArMjAyLDExIEBACiB2b2lkIEF1ZGlvT3V0cHV0RGVzY3JpcHRvcjo6dG9BdWRpb1BvcnRDb25maWcoc3RydWN0IGF1ZGlvX3BvcnRfY29uZmlnICpkc3RDb25maWcsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RydWN0IGF1ZGlvX3BvcnRfY29uZmlnICpzcmNDb25maWcpIGNvbnN0CiB7Ci0gICAgZHN0Q29uZmlnLT5jb25maWdfbWFzayA9IEFVRElPX1BPUlRfQ09ORklHX1NBTVBMRV9SQVRFfEFVRElPX1BPUlRfQ09ORklHX0NIQU5ORUxfTUFTS3wKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBBVURJT19QT1JUX0NPTkZJR19GT1JNQVR8QVVESU9fUE9SVF9DT05GSUdfR0FJTjsKKyAgICBkc3RDb25maWctPmNvbmZpZ19tYXNrID0gQVVESU9fUE9SVF9DT05GSUdfQUxMOwogICAgIGlmIChzcmNDb25maWcgIT0gTlVMTCkg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KyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgcmV0dXJuOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgfQorfQorCitib29sIFN3QXVkaW9PdXRwdXREZXNjcmlwdG9yOjpzZXRWb2x1bWUoZmxvYXQgdm9sdW1lRGIsIGJvb2wgbXV0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVm9sdW1lU291cmNlIHZzLCBjb25zdCBTdHJlYW1UeXBlVmVjdG9yICZzdHJlYW1UeXBlcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBEZXZpY2VUeXBlU2V0JiBkZXZpY2VUeXBlcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aW50MzJfdCBkZWxheU1zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgZm9yY2UpCiB7CiAgICAgU3RyZWFtVHlwZVZlY3RvciBzdHJlYW1zID0gc3RyZWFtVHlwZXM7Ci0gICAgaWYgKCFBdWRpb091dHB1dERlc2NyaXB0b3I6OnNldFZvbHVtZSh2b2x1bWVEYiwgdnMsIHN0cmVhbVR5cGVzLCBkZXZpY2VUeXBlcywgZGVsYXlNcywgZm9yY2UpKSB7CisgICAgaWYgKCFBdWRpb091dHB1dERlc2NyaXB0b3I6OnNldFZvbHVtZSgKKyAgICAgICAgICAgIHZvbHVtZURiLCBtdXRlZCwgdnMsIHN0cmVhbVR5cGVzLCBkZXZpY2VUeXBlcywgZGVsYXlNcywgZm9yY2UpKSB7CiAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICB9CiAgICAgaWYgKHN0cmVhbXMuZW1wdHkoKSkgewpAQCAtNDU5LDExICs0OTksMTcgQEAKICAgICAgICAgICAgIC8vIGRpZmZlcmVudCBWb2x1bWUgU291cmNlIChvciBpZiB3ZSBhbGxvdyBzZXZlcmFsIGN1cnZlcyB3aXRoaW4gc2Ft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Db25maWcgPT0gbnVsbHB0cikgewotICAgICAgICAgICAgbE1peGVyQ29uZmlnLmNoYW5uZWxfbWFzayA9IEFVRElPX0NIQU5ORUxfT1VUXzVQT0lOVDE7Ci0gICAgICAgIH0KKyAgICAvLyBJZiBubyBtaXhlciBjb25maWcgaXMgc3BlY2lmaWVkIGZvciBhIHNwYXRpYWxpemVyIG91dHB1dCwgZGVmYXVsdCB0byA1LjEgZm9yIHByb3BlcgorICAgIC8vIGNvbmZpZ3VyYXRpb24gb2YgdGhlIGZpbmFsIGRvd25taXhlciBvciBzcGF0aWFsaXplcgorICAgIGlmICgobUZsYWdzICYgQVVESU9fT1VUUFVUX0ZMQUdfU1BBVElBTElaRVIpICE9IDAKKyAgICAgICAgICAgICYmIG1peGVyQ29uZmlnID09IG51bGxwdHIpIHsKKyAgICAgICAgbE1peGVyQ29uZmlnLmNoYW5uZWxfbWFzayA9IEFVRElPX0NIQU5ORUxfT1VUXzVQT0lOVDE7CiAgICAgfQogCiAgICAgQUxPR1YoIm9wZW5pbmcgb3V0cHV0IGZvciBkZXZpY2UgJXMgcHJvZmlsZSAlcCBuYW1lICVzIiwKQEAgLTU2NSw3ICs2MDEsNyBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJmxNaXhlckNvbmZpZywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldmljZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZtTGF0ZW5jeSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhbEZsYWdzKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1GbGFncyk7CiAKICAgICBpZiAoc3RhdHVzID09IE5PX0VSUk9SKSB7CiAgICAgICAgIExPR19BTFdBWVNfRkFUQUxfSUYoKm91d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UeXBlcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aW50MzJfdCBkZWxheU1zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgZm9yY2UpCiB7CiAgICAgYm9vbCBjaGFuZ2VkID0gQXVkaW9PdXRwdXREZXNjcmlwdG9yOjpzZXRWb2x1bWUoCi0gICAgICAgICAgICB2b2x1bWVEYiwgdm9sdW1lU291cmNlLCBzdHJlYW1zLCBkZXZpY2VUeXBlcywgZGVsYXlNcywgZm9yY2UpOworICAgICAgICAgICAgdm9sdW1lRGIsIG11dGVkLCB2b2x1bWVTb3VyY2UsIHN0cmVhbXMsIGRldmljZVR5cGVzLCBkZWxheU1zLCBmb3JjZSk7CiAKICAgICBpZiAoY2hhbmdlZCkgewogICAgICAgLy8gVE9ETzogdXNlIGdhaW4gY29udHJvbGxlciBvbiBzb3VyY2UgZGV2aWNlIGlmIGFueSB0byBhZGp1c3Qgdm9sdW1lCkBAIC03ODIsNiArODM1LDE2IEBACiAgICAgcmV0dXJuIGZhbHNlOwogfQogCitib29sIFN3QXVkaW9PdXRwdXRDb2xsZWN0aW9uOjppc1N0cmF0ZWd5QWN0aXZlKHByb2R1Y3Rfc3RyYXRlZ3lfdCBwcykgY29uc3QKK3sKKyAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IHNpemUoKTsgaSsrKSB7CisgICAgICAgIGlmICh2YWx1ZUF0KGkpLT5pc1N0cmF0ZWd5QWN0aXZlKHBzKSkgeworICAgICAgICAgICAgcmV0dXJuIHRydWU7CisgICAgICAgIH0KKyAgICB9CisgICAgcmV0dXJuIGZhbHNlOworfQorCiBhdWRpb19pb19oYW5kbGVfdCBTd0F1ZGlvT3V0cHV0Q29sbGVjdGlvbjo6Z2V0QTJkcE91dHB1dCgpIGNvbnN0CiB7CiAgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCBzaXplKCk7IGkrKykgewpAQCAtODU3LDEzICs5Mj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OT1dOLCBBVURJT19VU0FHRV9OT1RJRklDQVRJT04sIEFVRElPX1NPVVJDRV9ERUZBVUxULAogICAgICAgICAgICAgICAgQVVESU9fRkxBR19OT05FLCAiIn0sCi0gICAgICAgICAgICAgIHtBVURJT19DT05URU5UX1RZUEVfVU5LTk9XTiwgQVVESU9fVVNBR0VfTk9USUZJQ0FUSU9OX0NPTU1VTklDQVRJT05fUkVRVUVTVCwKLSAgICAgICAgICAgICAgIEFVRElPX1NPVVJDRV9ERUZBVUxULCBBVURJT19GTEFHX05PTkUsICIifSwKLSAgICAgICAgICAgICAge0FVRElPX0NPTlRFTlRfVFlQRV9VTktOT1dOLCBBVURJT19VU0FHRV9OT1RJRklDQVRJT05fQ09NTVVOSUNBVElPTl9JTlNUQU5ULAotICAgICAgICAgICAgICAgQVVESU9fU09VUkNFX0RFRkFVTFQsIEFVRElPX0ZMQUdfTk9ORSwgIiJ9LAotICAgICAgICAgICAgICB7QVVESU9fQ09OVEVOVF9UWVBFX1VOS05PV04sIEFVRElPX1VTQUdFX05PVElGSUNBVElPTl9DT01NVU5JQ0FUSU9OX0RFTEFZRUQsCi0gICAgICAgICAgICAgICBBVURJT19TT1VSQ0VfREVGQVVMVCwgQVVESU9fRkxBR19OT05FLCAiIn0sCiAgICAgICAgICAgICAgIHtBVURJT19DT05URU5UX1RZUEVfVU5LTk9XTiwgQVVESU9fVVNBR0VfTk9USUZJQ0FUSU9OX0VWRU5ULAogICAgICAgICAgICAgICAgQVVESU9fU09VUkNFX0RFRkFVTFQsIEFVRElPX0ZMQUdfTk9ORSwgIiJ9CiAgICAgICAgICAgfQpAQCAtMTI4LDggKzEyMiwxMiBAQAogICAgIHsiU1RSQVRFR1lfVFJBTlNNSVRURURfVEhST1VHSF9TUEVBS0VSIiwKICAgICAgewogICAgICAgICAgeyIiLCBBVURJT19TVFJFQU1fVFRTLCAiQVVESU9fU1RSRUFNX1RUUyIsCi0gICAgICAgICAge3tBVURJT19DT05URU5UX1RZUEVfVU5LT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YWx1ZSA9IHN0cihpbnQoY29tcG9uZW50X3R5cGVfbnVtZXJpY2FsX3ZhbHVlLCAwKSAmIH4yMTQ3NDgzNjQ4KQorICAgICAgICAgICAgICAgIGNvbXBvbmVudF90eXBlX251bWVyaWNhbF92YWx1ZSA9IHN0cihpbnQoY29tcG9uZW50X3R5cGVfbnVtZXJpY2FsX3ZhbHVlLCAwKSkKICAgICAgICAgICAgICAgICBpZiBjb21wb25lbnRfdHlwZV9saXRlcmFsID09ICJkZWZhdWx0IjoKICAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50X3R5cGVfbGl0ZXJhbCA9ICJzdHViIgogCisgICAgICAgICAgICAgICAgc3RyaW5nX2ludCA9IGludChjb21wb25lbnRfdHlwZV9udW1lcmljYWxfdmFsdWUsIDApCisgICAgICAgICAgICAgICAgbnVtX2JpdHMgPSBiaW4oc3RyaW5nX2ludCkuY291bnQoIjEiKQorICAgICAgICAgICAgICAgIGlmIG51bV9iaXRzID4gMToKKyAgICAgICAgICAgICAgICAgICAgbG9nZ2luZy5pbmZvKCJUaGUgdmFsdWUge30gaXMgZm9yIGNyaXRlcmlvbiB7fSBiaW5hcnkgcmVwIHt9IGhhcyB7fSBiaXRzIHNldHMiCisgICAgICAgICAgICAgICAgICAgICAgICAuZm9ybWF0KGNvbXBvbmVudF90eXBlX251bWVyaWNhbF92YWx1ZSwgY29tcG9uZW50X3R5cGVfbmFtZSwgYmluKHN0cmluZ19pbnQpLCBudW1fYml0cykpCisgICAgICAgICAgICAgICAgICAgIHN0cmluZ19pbnQgPSAyKiptdWx0aV9iaXRfaW5wdXRfZGV2aWNlX3NoaWZ0CisgICAgICAgICAgICAgICAgICAgIGxvZ2dpbmcuaW5mbygibmV3IHZhbCBhc3NpZ25lZCBpcyB7fSB7fSIgLmZvcm1hdChzdHJpbmdfaW50LCBiaW4oc3RyaW5nX2ludCkpKQorICAgICAgICAgICAgICAgICAgICBtdWx0aV9iaXRfaW5wdXRfZGV2aWNlX3NoaWZ0ICs9IDEKKyAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50X3R5cGVfbnVtZXJpY2FsX3ZhbHVlID0gc3RyKHN0cmluZ19pbnQpCisKICAgICAgICAgICAgIGlmIGNvbXBvbmVudF90eXBlX25hbWUgPT0gIk91dHB1dERldmljZXNNYXNrIjoKICAgICAgICAgICAgICAgICBpZiBjb21wb25lbnRfdHlwZV9saXRlcmFsID09ICJkZWZhdWx0IjoKICAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50X3R5cGVfbGl0ZXJhbCA9ICJzdHViIgogCisgICAgICAgICAgICAgICAgc3RyaW5nX2ludCA9IGludChjb21wb25lbnRfdHlwZV9udW1lcmljYWxfdmFsdWUsIDApCisgICAgICAgICAgICAgICAgbnVtX2JpdHMgPSBiaW4oc3RyaW5nX2ludCkuY291bnQoIjEiKQorICAgICAgICAgICAgICAgIGlmIG51bV9iaXRzID4gMToKKyAgICAgICAgICAgICAgICAgICAgbG9nZ2luZy5pbmZvKCJUaGUgdmFsdWUge30gaXMgZm9yIGNyaXRlcmlvbiB7fSBiaW5hcnkgcmVwIHt9IGhhcyB7fSBiaXRzIHNldHMiCisgICAgICAgICAgICAgICAgICAgICAgICAuZm9ybWF0KGNvbXBvbmVudF90eXBlX251bWVyaWNhbF92YWx1ZSwgY29tcG9uZW50X3R5cGVfbmFtZSwgYmluKHN0cmluZ19pbnQpLCBudW1fYml0cykpCisgICAgICAgICAgICAgICAgICAgIHN0cmluZ19pbnQgPSAyKiptdWx0aV9iaXRfb3V0cHV0X2RldmljZV9zaGlmdAorICAgICAgICAgICAgICAgICAgICBsb2dnaW5nLmluZm8oIm5ldyB2YWwgYXNzaWduZWQgaXMge30ge30iIC5mb3JtYXQoc3RyaW5nX2ludCwgYmluKHN0cmluZ19pbnQpKSkKKyAgICAgICAgICAgICAgICAgICAgbXVsdGlfYml0X291dHB1dF9kZXZpY2Vfc2hpZnQgKz0gMQorICAgICAgICAgICAgICAgICAgICBjb21wb25lbnRfdHlwZ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mljZXNNYXNrVHlwZSI6CiAgICAgICAgICAgICAgICAgaWYgY3JpdGVyaW9uX2xpdGVyYWwgPT0gIkRlZmF1bHQiOgogICAgICAgICAgICAgICAgICAgICBjcml0ZXJpb25fbnVtZXJpY2FsX3ZhbHVlID0gc3RyKGludCgiMHg0MDAwMDAwMCIsIDApKQorICAgICAgICAgICAgICAgICAgICBpbnB1dF9kZXZpY2VzX3R5cGVfdmFsdWVbY3JpdGVyaW9uX2xpdGVyYWxdID0gIjB4QzAwMDAwMDAiCiAgICAgICAgICAgICAgICAgZWxzZToKICAgICAgICAgICAgICAgICAgICAgdHJ5OgogICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nX2ludCA9IGludChjcml0ZXJpb25fbnVtZXJpY2FsX3ZhbHVlLCAwKQorICAgICAgICAgICAgICAgICAgICAgICAgIyBBcHBlbmQgQVVESU9fREVWSUNFX0lOIGZvciBhbmRyb2lkIHR5cGUgdGFnCisgICAgICAgICAgICAgICAgICAgICAgICBpbnB1dF9kZXZpY2VzX3R5cGVfdmFsdWVbY3JpdGVyaW9uX2xpdGVyYWxdID0gaGV4KHN0cmluZ19pbnQgfCAyMTQ3NDgzNjQ4KQorCisgICAgICAgICAgICAgICAgICAgICAgICBudW1fYml0cyA9IGJpbihzdHJpbmdfaW50KS5jb3VudCgiMSIpCisgICAgICAgICAgICAgICAgICAgICAgICBpZiBudW1fYml0cyA+IDE6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nZ2luZy5pbmZvKCJUaGUgdmFsdWUge306e30gaXMgZm9yIGNyaXRlcmlvbiB7fSBiaW5hcnkgcmVwIHt9IGhhcyB7fSBiaXRzIHNldHMiCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5mb3JtYXQoY3JpdGVyaW9uX251bWVyaWNhbF92YWx1ZSwgY3JpdGVyaW9uX2xpdGVyYWwsIGNyaXRlcmlvbl9uYW1lLCBiaW4oc3RyaW5nX2ludCksIG51bV9iaXRzKSkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJpbmdfaW50ID0gMioqbXVsdGlfYml0X2lucHV0ZGV2aWNlX3NoaWZ0CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nZ2luZy5pbmZvKCJuZXcgdmFsIGFzc2lnbmVkIGlzIHt9IHt9IiAuZm9ybWF0KHN0cmluZ19pbnQsIGJpbihzdHJpbmdfaW50KSkpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbXVsdGlfYml0X2lucHV0ZGV2aWNlX3NoaWZ0ICs9IDEKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBjcml0ZXJpb25fbnVtZXJpY2FsX3ZhbHVlID0gc3RyKHN0cmluZ19pbnQpCisKICAgICAgICAgICAgICAgICAgICAgZXhjZXB0IFZhbHVlRXJyb3I6CiAgICAgICAgICAgICAgICAgICAgICAgICAjIEhhbmRsZSB0aGUgZXhjZXB0aW9uCiAgICAgICAgICAgICAgICAgICAgICAgICBsb2dnaW5nLmluZm8oInZhbHVlIHt9Ont9IGZvciBjcml0ZXJpb24ge30gaXMgbm90IGEgbnVtYmVyLCBpZ25vcmluZyIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuZm9ybWF0KGNyaXRlcmlvbl9udW1lcmljYWxfdmFsdWUsIGNyaXRlcmlvbl9saXRlcmFsLCBjcml0ZXJpb25fbmFtZSkpCiAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZQotICAgICAgICAgICAgICAgICAgICBjcml0ZXJpb25fbnVtZXJpY2FsX3ZhbHVlID0gc3RyKGludChjcml0ZXJpb25fbnVtZXJpY2FsX3ZhbHVlLCAwKSAmIH4yMTQ3NDgzNjQ4KQogCiAgICAgICAgICAgICBpZiBjcml0ZXJpb25fbmFtZSA9PSAiT3V0cHV0RGV2aWNlc01hc2tUeXBlIjoKICAgICAgICAgICAgICAgICBpZiBjcml0ZXJpb25fbGl0ZXJhbCA9PSAiRGVmYXVsdCI6CiAgICAgICAgICAgICAgICAgICAgIGNyaXRlcmlvbl9udW1lcmljYWxfdmFsdWUgPSBzdHIoaW50KCIweDQwMDAwMDAwIiwgMCkpCi0gICAgICAgICAgICAgICAgaWYgY3JpdGVyaW9uX2xpdGVyYWwgaW4gaWdub3JlZF9vdXRwdXRfZGV2aWNlX3ZhbHVlczoKLSAgICAgICAgICAgICAgICAgICAgbG9nZ2luZy5pbmZvKCJPdXRwdXREZXZpY2VzTWFza1R5cGUgc2tpcHBpbmcge30iLmZvcm1hdChjcml0ZXJpb25fbGl0ZXJhbCkpCi0gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlCisgICAgICAgICAgICAgICAgICAgIG91dHB1dF9kZXZpY2VzX3R5cGVfdmFsdWVbY3JpdGVyaW9uX2xpdGVyYWxdID0gIjB4NDAwMDAwMDAiCisgICAgICAgICAgICAgICAgZWxzZToKKyAgICAgICAgICAgICAgICAgICAgdHJ5OgorICAgICAgICAgICAgICAgICAgICAgICAgc3RyaW5nX2ludCA9IGludChjcml0ZXJpb25fbnVtZXJpY2FsX3ZhbHVlLCAwKQorICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0X2RldmljZXNfdHlwZV92YWx1ZVtjcml0ZXJpb25fbGl0ZXJhbF0gPSBjcml0ZXJpb25fbnVtZXJpY2FsX3ZhbHVlCisKKyAgICAgICAgICAgICAgICAgICAgICAgIG51bV9iaXRzID0gYmluKHN0cmluZ19pbnQpLmNvdW50KCIxIikKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIG51bV9iaXRzID4gMToKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2dnaW5nLmluZm8oIlRoZSB2YWx1ZSB7fTp7fSBpcyBmb3IgY3JpdGVyaW9uIHt9IGJpbmFyeSByZXAge30gaGFzIHt9IGJpdHMgc2V0cyIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZvcm1hdChjcml0ZXJpb25fbnVtZXJpY2FsX3ZhbHVlLCBjcml0ZXJpb25fbGl0ZXJhbCwgY3JpdGVyaW9uX25hbWUsIGJpbihzdHJpbmdfaW50KSwgbnVtX2JpdHMpKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmluZ19pbnQgPSAyKiptdWx0aV9iaXRfb3V0cHV0ZGV2aWNlX3NoaWZ0CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9nZ2luZy5pbmZvKCJuZXcgdmFsIGFzc2lnbmVkIGlzIHt9IHt9IiAuZm9ybWF0KHN0cmluZ19pbnQsIGJpbihzdHJpbmdfaW50KSkpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbXVsdGlfYml0X291dHB1dGRldmljZV9zaGlmdCArPSAxCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JpdGVyaW9uX251bWVyaWNhbF92YWx1ZSA9IHN0cihzdHJpbmdfaW50KQorCisgICAgICAgICAgICAgICAgICAgIGV4Y2VwdCBWYWx1ZUVycm9yOgorICAgICAgICAgICAgICAgICAgICAgICAgIyBIYW5kbGUgdGhlIGV4Y2VwdGlvbgorICAgICAgICAgICAgICAgICAgICAgICAgbG9nZ2luZy5pbmZvKCJUaGUgdmFsdWUge306e30gaXMgZm9yIGNyaXRlcmlvbiB7fSBpcyBub3QgYSBudW1iZXIsIGlnbm9yaW5nIgorICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5mb3JtYXQoY3JpdGVyaW9uX251bWVyaWNhbF92YWx1ZSwgY3JpdGVyaW9uX2xpdGVyYWwsIGNyaXRlcmlvbl9uYW1lKSkKKyAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlCisKICAgICAgICAgICAgIHRyeToKICAgICAgICAgICAgICAgICBzdHJpbmdfaW50ID0gaW50KGNyaXRlcmlvbl9udW1lcmljYWxfdmFsdWUsIDApCisKICAgICAgICAgICAgIGV4Y2VwdCBWYWx1ZUVycm9yOgogICAgICAgICAgICAgICAgICMgSGFuZGxlIHRoZSBleGNlcHRpb24KICAgICAgICAgICAgICAgICBsb2dnaW5n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NFbXB0eSgpKSBicmVhazsKICAgICAgICAgZGV2aWNlcyA9IGF2YWlsYWJsZU91dHB1dERldmljZXMuZ2V0Rmlyc3REZXZpY2VzRnJvbVR5cGVzKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2V0TGFzdFJlbW92YWJsZU1lZGlhRGV2aWNlcygpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIGdldExhc3RSZW1vdmFibGVNZWRpYURldmljZXMoR1JPVVBfTk9ORSwge0FVRElPX0RFVklDRV9PVVRfQkxFX0hFQURTRVR9KSk7CiAgICAgICAgIGlmICghZGV2aWNlcy5pc0VtcHR5KCkpIGJyZWFrOwotICAgICAgICBkZXZpY2VzID0gYXZhaWxhYmxlT3V0cHV0RGV2aWNlcy5nZXREZXZpY2VzRnJvbVR5cGUoQVVESU9fREVWSUNFX09VVF9FQVJQSUVDRSk7CisgICAgICAgIGRldmljZXMgPSBhdmFpbGFibGVPdXRwdXREZXZpY2VzLmdldEZpcnN0RGV2aWNlc0Zyb21UeXBlcyh7CisgICAgICAgICAgICAgICAgQVVESU9fREVWSUNFX09VVF9ER1RMX0RPQ0tfSEVBRFNFVCwgQVVESU9fREVWSUNFX09VVF9FQVJQSUVDRX0pOwogICAgIH0gYnJlYWs7CiAKICAgICBjYXNlIFNUUkFURUdZX1NPTklGSUNBVElPTjoKQEAgLTM0Myw2ICszNDQsMzAgQEAKICAgICAgICAgICAgIChnZXRGb3JjZVVzZShBVURJT19QT0xJQ1lfRk9SQ0VfRk9SX01FRElBKSA9PSBBVURJT19QT0xJQ1lfRk9SQ0VfU1BFQUtFUikpIHsKICAgICAgICAgICAgIGRldmljZXMyID0gYXZhaWxhYmxlT3V0cHV0RGV2aWNlcy5nZXREZXZpY2VzRnJvbVR5cGUoQVVESU9fREVWSUNFX09VVF9TUEVBS0VSKTsKICAgICAgICAgfQorCisgICAgICAgIC8vIExFIGF1ZGlvIGJyb2FkY2FzdCBkZXZpY2UgaXMgb25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PSBTVFJBVEVHWV9NRURJQQorICAgICAgICAgICAgICAgICAgICB8fCB0b3BBY3RpdmVTdHJhdGVneSA9PSBTVFJBVEVHWV9TT05JRklDQVRJT05fUkVTUEVDVEZVTAorICAgICAgICAgICAgICAgICAgICB8fCAhb3V0cHV0cy5pc0FueURldmljZVR5cGVBY3RpdmUoZ2V0QXVkaW9EZXZpY2VPdXRMZUF1ZGlvVW5pY2FzdFNldCgpKSkgeworICAgICAgICAgICAgICAgIGRldmljZXMyID0KKyAgICAgICAgICAgICAgICAgICAgICAgIGF2YWlsYWJsZU91dHB1dERldmljZXMuZ2V0RGV2aWNlc0Zyb21UeXBlKEFVRElPX0RFVklDRV9PVVRfQkxFX0JST0FEQ0FTVCk7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKwogICAgICAgICBpZiAoZGV2aWNlczIuaXNFbXB0eSgpICYmIChnZXRMYXN0UmVtb3ZhYmxlTWVkaWFEZXZpY2VzKCkuc2l6ZSgpID4gMCkpIHsKICAgICAgICAgICAgIGlmICgoZ2V0Rm9yY2VVc2UoQVVESU9fUE9MSUNZX0ZPUkNFX0ZPUl9NRURJQSkgIT0gQVVESU9fUE9MSUNZX0ZPUkNFX05PX0JUX0EyRFApKSB7CiAgICAgICAgICAgICAgICAgLy8gR2V0IHRoZSBsYXN0IGNvbm5lY3RlZCBkZXZpY2Ugb2Ygd2lyZWQgYW5kIGJsdWV0b290aCBhMmRwCkBAIC0zNjQsNyArMzg5LDggQEAKICAgICAgICAgICAgICAgICAgICAgQVVESU9fREVWSUNFX09VVF9BTkxHX0RPQ0tfSEVBRFNFVCk7CiAgICAgICAgIH0KICAgICAgICAgaWYgKGRldmljZXMyLmlzRW1wdHkoKSkgewotICAgICAgICAgICAgZGV2aWNlczIgPSBhdmFpbGFibGVPdXRwdXREZXZpY2VzLmdldERldmljZXNGcm9tVHlwZShBVURJT19ERVZJQ0VfT1VUX1NQRUFLRVIpOworICAgICAgICAgICAgZGV2aWNlczIgPSBhdmFpbG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ICAgQVVESU9fREVWSUNFX0lOX0JMVUVUT09USF9CTEUsIEFVRElPX0RFVklDRV9JTl9CVUlMVElOX01JQ30pOwogICAgICAgICBicmVhazsKQEAgLTUzNiw3ICs1NjMsNyBAQAogICAgICAgICAvLyBiZWNhdXNlIHNvbWV0aW1lcyB1c2VyIHdhbnQgdG8gZG8gdm9pY2Ugc2VhcmNoIGJ5IGJ0IHJlbW90ZQogICAgICAgICAvLyBldmVuIGlmIEJVSUxESU5fTUlDIGlzIGF2YWlsYWJsZS4KICAgICAgICAgZGV2aWNlID0gYXZhaWxhYmxlRGV2aWNlcy5nZXRGaXJzdEV4aXN0aW5nRGV2aWNlKHsKLSAgICAgICAgICAgICAgICBBVURJT19ERVZJQ0VfSU5fQkxFX0hFQURTRVQsIEFVRElPX0RFVklDRV9JTl9XSVJFRF9IRUFEU0VULAorICAgICAgICAgICAgICAgIEFVRElPX0RFVklDRV9JTl9XSVJFRF9IRUFEU0VULAogICAgICAgICAgICAgICAgIEFVRElPX0RFVklDRV9JTl9VU0JfSEVBRFNFVCwgQVVESU9fREVWSUNFX0lOX1VTQl9ERVZJQ0UsCiAgICAgICAgICAgICAgICAgQVVESU9fREVWSUNFX0lOX0JMVUVUT09USF9CTEUsIEFVRElPX0RFVklDRV9JTl9CVUlMVElOX01JQ30pOwogCkBAIC01NTIsNyArNTc5LDcgQEAKICAgICAgICAgICAgIGlmIChkZXZpY2UgIT0gbnVsbHB0cikgYnJlYWs7CiAgICAgICAgIH0KICAgICAgICAgZGV2aWNlID0gYXZhaWxhYmxlRGV2aWNlcy5nZXRGaXJzdEV4aXN0aW5nRGV2aWNlKHsKLSAgICAgICAgICAgICAgICBBVURJT19ERVZJQ0VfSU5fQkxFX0hFQURTRVQsIEFVRElPX0RFVklDRV9JTl9XSVJFRF9IRUFEU0VULAorICAgICAgICAgICAgICAgIEFVRElPX0RFVklDRV9JTl9XSVJFRF9IRUFEU0VULAogICAgICAgICAgICAgICAgIEFVRElPX0RFVklDRV9JTl9VU0JfSEVBRFNFVCwgQVVESU9fREVWSUNFX0lOX1VTQl9ERVZJQ0UsCiAgICAgICAgICAgICAgICAgQVVESU9fREVWSUNFX0lOX0JVSUxUSU5fTUlDfSk7CiAgICAgICAgIGJyZWFrOwpAQCAtNTg2LDYgKzYxMywxMCBAQAogICAgICAgICBkZXZpY2UgPSBhdmFpbGFibGVEZXZpY2VzLmdldERldmljZSgKICAgICAgICAgICAgICAgICBBVURJT19ERVZJQ0VfSU5fRUNIT19SRUZFUkVOQ0UsIFN0cmluZzgoIiIpLCBBVURJT19GT1JNQVRfREVGQVVMVCk7CiAgICAgICAgIGJyZWFrOworICAgIGNhc2UgQVVESU9fU09VUkNFX1VMVFJBU09VTkQ6CisgICAgICAgIGRldmljZSA9IGF2YWlsYWJsZURldmljZXMuZ2V0Rmlyc3RFeGlzdGluZ0RldmljZSh7CisgICAgICAgICAgICAgICAgQVVESU9fREVWSUNFX0lOX0JVSUxUSU5fTUlDLCBBVURJT19ERVZJQ0VfSU5fQkFDS19NSUN9KTsKKyAgICAgICAgYnJlYWs7CiAgICAgZGVmYXVsdDoKICAgICAgICAgQUxPR1coImdldERldmljZUZvcklucHV0U291cmNlKCkgaW52YWxpZCBpbnB1dCBzb3VyY2UgJWQiLCBpbnB1dFNvdXJjZSk7CiAgICAgICAgIGJyZWFrOwpAQCAtNjQ1LDcgKzY3Niw3IEBACiAgICAgICAgIC8vIHRoZXJlIGlzIGEgcHJlZmVycmVkIGRldmljZSwgaXMgaXQgYXZhaWxhYmxlPwogICAgICAgICBwcmVmZXJyZWRBdmFpbGFibGVEZXZWZWMgPQogICAgICAgICAgICAgICAgIGF2YWlsYWJsZU91dHB1dERldmljZXMuZ2V0RGV2aWNlc0Zyb21EZXZpY2VUeXBlQWRkclZlYyhwcmVmZXJyZWRTdHJhdGVneURldmljZXMpOwotICAgICAgICBpZiAocHJlZmVycmVkQXZhaWxhYmxlRGV2VmVjLnNpemUoKSA9PSBwcmVmZXJyZWRBdmFpbGF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vcnREZXZpY2VFeHQ7Cit1c2luZyBhbmRyb2lkOjptZWRpYTo6YXVkaW86OmNvbW1vbjo6QXVkaW9Qb3J0RXh0OwogdXNpbmcgY29udGVudDo6QXR0cmlidXRpb25Tb3VyY2VTdGF0ZTsKIAogLy9GSVhNRTogd29ya2Fyb3VuZCBmb3IgdHJ1bmNhdGVkIHRvdWNoIHNvdW5kcwpAQCAtOTcsNDQgKzEwMiw4MCBAQAogLy8gQXVkaW9Qb2xpY3lJbnRlcmZhY2UgaW1wbGVtZW50YXRpb24KIC8vIC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KIAotc3RhdHVzX3QgQXVkaW9Qb2xpY3lNYW5hZ2VyOjpzZXREZXZpY2VDb25uZWN0aW9uU3RhdGUoYXVkaW9fZGV2aWNlc190IGRldmljZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX3BvbGljeV9kZXZfc3RhdGVfdCBzdGF0ZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoYXIgKmRldmljZV9hZGRyZXNzLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hhciAqZGV2aWNlX25hbWUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19mb3JtYXRfdCBlbmNvZGVkRm9ybWF0KQotewotICAgIHN0YXR1c190IHN0YXR1cyA9IHNldERldmljZUNvbm5lY3Rpb25TdGF0ZUludChkZXZpY2UsIHN0YXRlLCBkZXZpY2VfYWRkcmVzcywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGV2aWNlX25hbWUsIGVuY29kZWRGb3JtYXQpOworc3RhdHVzX3QgQXVkaW9Qb2xpY3lNYW5hZ2VyOjpzZXREZXZpY2VDb25uZWN0aW9uU3RhdGUoYXVkaW9fcG9saWN5X2Rldl9zdGF0ZV90IHN0YXRlLAorICAgICAgICBjb25zdCBhbmRyb2lkOjptZWRpYTo6YXVkaW86OmNvbW1vbjo6QXVkaW9Qb3J0JiBwb3J0LCBhdWRpb19mb3JtYXRfdCBlbmNvZGVkRm9ybWF0KSB7CisgICAgc3RhdHVzX3Qgc3RhdHVzID0gc2V0RGV2aWNlQ29ubmVjdGlvblN0YXRlSW50KHN0YXRlLCBwb3J0LCBlbmNvZGVkRm9ybWF0KTsKICAgICBuZXh0QXVkaW9Qb3J0R2VuZXJhdGlvbigpOwogICAgIHJldHVybiBzdGF0dXM7CiB9CiAKK3N0YXR1c190IEF1ZGlvUG9saWN5TWFuYWdlcjo6c2V0RGV2aWNlQ29ubmVjdGlvblN0YXRlKGF1ZGlvX2RldmljZXNfdCBkZXZpY2UsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19wb2xpY3lfZGV2X3N0YXRlX3Qgc3RhdGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyKiBkZXZpY2VfYWRkcmVzcywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoYXIqIGRldmljZV9uYW1lLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fZm9ybWF0X3QgZW5jb2RlZEZvcm1hdCkgeworICAgIG1lZGlhOjpBdWRpb1BvcnQgYWlkbFBvcnQ7CisgICAgaWYgKHN0YXR1c190IHN0YXR1cyA9IGRldmljZVRvQXVkaW9Qb3J0KGRldmljZSwgZGV2aWNlX2FkZHJ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pY2VDb25uZWN0aW9uU3RhdGVJbnQoYXVkaW9fZGV2aWNlc190IGRldmljZVR5cGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19wb2xpY3lfZGV2X3N0YXRlX3Qgc3RhdGUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyICpkZXZpY2VfYWRkcmVzcywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoYXIgKmRldmljZV9uYW1lLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fZm9ybWF0X3QgZW5jb2RlZEZvcm1hdCkKLXsKLSAgICBBTE9HVigic2V0RGV2aWNlQ29ubmVjdGlvblN0YXRlSW50KCkgZGV2aWNlOiAweCVYLCBzdGF0ZSAlZCwgYWRkcmVzcyAlcyBuYW1lICVzIGZvcm1hdCAweCVYIiwKLSAgICAgICAgICAgIGRldmljZVR5cGUsIHN0YXRlLCBkZXZpY2VfYWRkcmVzcywgZGV2aWNlX25hbWUsIGVuY29kZWRGb3JtYXQpOwotCi0gICAgLy8gY29ubmVjdC9kaXNjb25uZWN0IG9ubHkgMSBkZXZpY2UgYXQgYSB0aW1lCi0gICAgaWYgKCFhdWRpb19pc19vdXRwdXRfZGV2aWNlKGRldmljZVR5cGUpICYmICFhdWRpb19pc19pbnB1dF9kZXZpY2UoZGV2aWNlVHlwZSkpIHJldHVybiBCQURfVkFMVUU7Ci0KLSAgICBzcDxEZXZpY2VEZXNjcmlwdG9yPiBkZXZpY2UgPQotICAgICAgICAgICAgbUh3TW9kdWxlcy5nZXREZXZpY2VEZXNjcmlwdG9yKGRldmljZVR5cGUsIGRldmljZV9hZGRyZXNzLCBkZXZpY2VfbmFtZSwgZW5jb2RlZEZvcm1hdCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZSA9PSBBVURJT19QT0xJQ1lfREVWSUNFX1NUQVRFX0FWQUlMQUJMRSk7Ci0gICAgcmV0dXJuIGRldmljZSA/IHNldERldmljZUNvbm5lY3Rpb25TdGF0ZUludChkZXZpY2UsIHN0YXRlKSA6IElOVkFMSURfT1BFUkFUSU9OOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hhciogZGV2aWNlX2FkZHJlc3MsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyKiBkZXZpY2VfbmFtZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX2Zvcm1hdF90IGVuY29kZWRGb3JtYXQpIHsKKyAgICBtZWRpYTo6QXVkaW9Qb3J0IGFpZGxQb3J0OworICAgIGlmIChzdGF0dXNfdCBzdGF0dXMgPSBkZXZpY2VUb0F1ZGlvUG9ydChkZXZpY2VUeXBlLCBkZXZpY2VfYWRkcmVzcywgZGV2aWNlX25hbWUsICZhaWRsUG9ydCk7CisgICAgICAgIHN0YXR1cyA9PSBPSykgeworICAgICAgICByZXR1cm4gc2V0RGV2aWNlQ29ubmVjdGlvblN0YXRlSW50KHN0YXRlLCBhaWRsUG9ydC5oYWwsIGVuY29kZWRGb3JtYXQpOworICAgIH0gZWxzZSB7CisgICAgICAgIEFMT0dFKCJGYWlsZWQgdG8gY29udmVydCB0byBBdWRpb1BvcnQgUGFyY2VsYWJsZTogJXMiLCBzdGF0dXNUb1N0cmluZyhzdGF0dXMpLmNfc3RyKCkpOworICAgICAgICByZXR1cm4gc3RhdHVzOworICAgIH0KIH0KIAogc3RhdHVzX3QgQXVkaW9Qb2xpY3lNYW5hZ2VyOjpzZXREZXZpY2VDb25u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oKHN0YXRlID09IEFVRElPX1BPTElDWV9ERVZJQ0VfU1RBVEVfVU5BVkFJTEFCTEUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfHwgKCgoZGVzYy0+bUZsYWdzICYgQVVESU9fT1VUUFVUX0ZMQUdfRElSRUNUKSAhPSAwKSAmJgotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoZGVzYy0+bURpcmVjdE9wZW5Db3VudCA9PSAwKSkpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGRlc2MtPm1EaXJlY3RPcGVuQ291bnQgPT0gMCkpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgfHwgKCgoZGVzYy0+bUZsYWdzICYgQVVESU9fT1VUUFVUX0ZMQUdfU1BBVElBTElaRVIpICE9IDApICYmCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICFpc091dHB1dE9ubHlBdmFpbGFibGVSb3V0ZVRvU29tZURldmljZShkZXNjKSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFyQXVkaW9Tb3VyY2VzRm9yT3V0cHV0KG91dHB1dCk7CiAgICAgICAgICAgICAgICAgICAgICAgICBjbG9zZU91dHB1dChvdXRwdXQpOwogICAgICAgICAgICAgICAgICAgICB9CkBAIC0zMTIsNiArMzU5LDggQEAKICAgICAgICAgICAgIGNsZWFuVXBGb3JEZXZpY2UoZGV2aWNlKTsKICAgICAgICAgfQogCisgICAgICAgIGNoZWNrTGVCcm9hZGNhc3RSb3V0ZXMod2FzTGVVbmljYXN0QWN0aXZlLCBudWxscHRyLCAwKTsKKwogICAgICAgICBtcENsaWVudEludGVyZmFjZS0+b25BdWRpb1BvcnRMaXN0VXBkYXRlKCk7CiAgICAgICAgIHJldHVybiBOT19FUlJPUjsKICAgICB9ICAvLyBlbmQgaWYgaXMgb3V0cHV0IGRldmljZQpAQCAtMzk5LDYgKzQ0OCwxNCBAQAogICAgIHJldHVybiBCQURfVkFMVUU7CiB9CiAKK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0ZXMod2FzTGVVbmljYXN0QWN0aXZlLCBudWxscHRyLCBkZWxheU1zKTsKKwogICAgIGlmIChpc1N0YXRlSW5DYWxsKHN0YXRlKSkgewogICAgICAgICBBTE9HVigic2V0UGhvbmVTdGF0ZSgpIGluIGNhbGwgc3RhdGUgbWFuYWdlbWVudDogbmV3IHN0YXRlIGlzICVkIiwgc3RhdGUpOwogICAgICAgICAvLyBmb3JjZSByZWV2YWx1YXRpbmcgYWNjZXNzaWJpbGl0eSByb3V0aW5nIHdoZW4gY2FsbCBzdGFydHMKQEAgLTg3MSw2ICs5NDYsMzIgQEAKICAgICBBTE9HVigic2V0U3lzdGVtUHJvcGVydHkoKSBwcm9wZXJ0eSAlcywgdmFsdWUgJXMiLCBwcm9wZXJ0eSwgdmFsdWUpOwogfQogCisvLyBGaW5kIGFuIE1TRCBvdXRwdXQgcHJvZmlsZSBjb21wYXRpYmxlIHdpdGggdGhlIHBhcmFtZXRlcnMgcGFzc2VkLgorLy8gV2hlbiAiZGlyZWN0T25seSIgaXMgc2V0LCByZXN0cmljdCBzZWFyY2ggdG8gcHJvZmlsZXMgZm9yIGRpcmVjdCBvdXRwdXRzLgorc3A8SU9Qcm9maWxlPiBBdWRpb1BvbGljeU1hbmFnZXI6OmdldE1zZFByb2ZpbGVGb3JPdXRwdXQoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBEZXZpY2VWZWN0b3ImIGRldmljZXMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aW50MzJfdCBzYW1wbGluZ1JhdGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19mb3JtYXRfdCBmb3JtYXQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19jaGFubmVsX21hc2tfdCBjaGFubmVsTWFzaywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX291dHB1dF9mbGFnc190IGZsYWdzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBkaXJlY3RPbmx5KQoreworICAgIGZsYWdzID0gZ2V0UmVsZXZhbnRGbGFncyhmbGFncywgZGlyZWN0T25seSk7CisKKyAgICBzcDxId01vZHVsZT4gbXNkTW9kdWxlID0gbUh3TW9kdWxlcy5nZXRNb2R1bGVGcm9tTmFtZShBVURJT19IQVJEV0FSRV9NT0RVTEVfSURfTVNEKTsKKyAgICBpZiAobXNkTW9kdWxlICE9IG51bGxwdHIpIHsKKyAgICAgICAgLy8gZm9yIHRoZSBtc2QgbW9kdWxlIGNoZWNrIGlmIHRoZXJlIGFyZSBwYXRjaGVzIHRvIHRoZSBvdXRwdXQgZGV2aWNlcworICAgICAgICBpZiAobXNkSGFzUGF0Y2hlc1RvQWxsRGV2aWNlcyhkZXZpY2VzLnRvVHlwZUFkZHJWZWN0b3IoKSkpIHsKKyAgICAgICAgICAgIEh3TW9kdWxlQ29sbGVjdGlvbiBtb2R1bGVzOworICAgICAgICAgICAgbW9kdWxlcy5hZGQobXNkTW9kdWxlKTsKKyAgICAgICAgICAgIHJldHVybiBzZWFyY2hDb21wYXRpYmxlUHJvZmlsZUh3TW9kdWxlcygKKyAgICAgICAgICAgICAgICAgICAgbW9kdWxlcywgZ2V0TXNkQXVkaW9PdXREZXZpY2VzKCksIHNhbXBsaW5nUmF0ZSwgZm9ybWF0LCBjaGFubmVsTWFzaywKKyAgICAgICAgICAgICAgICAgICAgZmxhZ3MsIGRpcmVjdE9ubHkpOworICAgICAgICB9CisgICAgfQorICAgIHJldHVybiBudWxscHRyOworfQorCiAvLyBGaW5kIGFuIG91dHB1dCBwcm9maWxlIGNvbXBhdGlibGUgd2l0aCB0aGUgcGFyYW1ldGVycyBwYXNzZWQuIFdoZW4gImRpcmVjdE9ubHkiIGlzIHNldCwgcmVzdHJpY3QKIC8vIHNlYXJjaCB0byBwcm9maWxlcyBmb3IgZGlyZWN0IG91dHB1dHMuCiBzcDxJT1Byb2ZpbGU+IEF1ZGlvUG9saWN5TWFuYWdlcjo6Z2V0UHJvZmlsZUZvck91dHB1dCgKQEAgLTg4MSw0NSArOTgyLDY1IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19vdXRwdXRfZmxhZ3NfdCBmbGFncywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgZGlyZWN0T25seSkKIHsKKyAgICBmbGFncyA9IGdldFJlbGV2YW50RmxhZ3MoZmxhZ3MsIGRpcmVjdE9ubHkpOworCisgICAgcmV0dXJuIHNlYXJjaENvbXBhdGlibGVQcm9maWxlSHdNb2R1bGVzKAorICAgICAgICAgICAgbUh3TW9kdWxlcywgZGV2aWNlcywgc2FtcGxpbmdSYXRlLCBmb3JtYXQsIGNoYW5uZWxNYXNrLCBmbGFncywgZGlyZWN0T25seSk7Cit9CisKK2F1ZGlvX291dHB1dF9mbGFnc190IEF1ZGlvUG9saWN5TWFuYWdlcjo6Z2V0UmVsZXZhbnRGbGFncyAoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX291dHB1dF9mbGFnc190IGZsYWdzLCBib29sIGRpcmVjdE9ubHkpIHsKICAgICBpZiAoZGlyZWN0T25seSkgewotICAgICAgICAvLyBvbmx5IHJldGFpbiBmbGFncyB0aGF0IHdpbGwgZHJpdmUgdGhlIGRpcmVjdCBvdXRwdXQgcHJvZmlsZSBzZWxlY3Rpb24KLSAgICAgICAgLy8gaWYgZXhwbGljaXRseSByZXF1ZXN0ZWQKLSAgICAgICAgc3RhdGljIGNvbnN0IHVpbnQzMl90IGtSZWxldmFudEZsYWdzID0KKyAgICAgICAgIC8vIG9ubHkgcmV0YWluIGZsYWdzIHRoYXQgd2lsbCBkcml2ZSB0aGUgZGlyZWN0IG91dHB1dCBwcm9maWxlIHNlbGVjdGlvbgorICAgICAgICAgLy8gaWYgZXhwbGljaXRseSByZXF1ZXN0ZWQKKyAgICAgICAgIHN0YXRpYyBjb25zdCB1aW50MzJfdCBrUmVsZXZhbnRGbGFncyA9CiAgICAgICAgICAgICAgICAgKEFVRElPX09VVFBVVF9GTEFHX0hXX0FWX1NZTkMgfCBBVURJT19PVVRQVVRfRkxBR19DT01QUkVTU19PRkZMT0FEIHwKLSAgICAgICAgICAgICAgICAgQVVESU9fT1VUUFVUX0ZMQUdfVk9JUF9SWCB8IEFVRElPX09VVFBVVF9GTEFHX01NQVBfTk9JUlEpOwotICAgICAgICBmbGFncyA9Ci0gICAgICAgICAgICAoYXVkaW9fb3V0cHV0X2ZsYWdzX3QpKChmbGFncyAmIGtSZWxldmFudEZsYWdzKSB8IEFVRElPX09VVFBVVF9GTEFHX0RJUkVDVCk7CisgICAgICAgICAgICAgICAgQVVESU9fT1VUUFVUX0ZMQUdfVk9JUF9SWCB8IEFVRElPX09VVFBVVF9GTEFHX01NQVBfTk9JUlEpOworICAgICAgICAgZmxhZ3MgPSAoYXVkaW9fb3V0cHV0X2ZsYWdzX3QpKChmbGFncyAmIGtSZWxldmFudEZsYWdzKSB8IEFVRElPX09VVFBVVF9GTEFHX0RJUkVDVCk7CiAgICAgfQorICAgIHJldHVybiBmbGFnczsKK30KIAorc3A8SU9Qcm9maWxlPiBBdWRpb1BvbGljeU1hbmFnZXI6OnNlYXJjaENvbXBhdGlibGVQcm9maWxlSHdNb2R1bGVzICgKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBId01vZHVsZUNvbGxlY3Rpb24mIGh3TW9kdWxlcywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBEZXZpY2VWZWN0b3ImIGRldmljZXMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdWludDMyX3Qgc2FtcGxpbmdSYXRlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX2Zvcm1hdF90IGZvcm1hdCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19jaGFubmVsX21hc2tfdCBjaGFubmVsTWFzaywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19vdXRwdXRfZmxhZ3NfdCBmbGFncywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIGRpcmVjdE9ubHkpIHsKICAgICBzcDxJT1Byb2ZpbGU+IHByb2ZpbGU7Ci0KLSAgICBmb3IgKGNvbnN0IGF1dG8mIGh3TW9kdWxlIDogbUh3TW9kdWxlcykgeworICAgIGZvciAoY29uc3QgYXV0byYgaHdNb2R1bGUgOiBod01vZHVsZXMpIHsKICAgICAgICAgZm9yIChjb25zdCBhdXRvJiBjdXJQcm9maWxlIDogaHdNb2R1bGUtPmdldE91dHB1dFByb2ZpbGVzKCkpIHsKLSAgICAgICAgICAgIGlmICghY3VyUHJvZmlsZS0+aXNDb21wYXRpYmxlUHJvZmlsZShkZXZpY2VzLAotICAgICAgICAgICAgICAgICAgICBzYW1wbGluZ1JhdGUsIE5VTEwgLyp1cGRhdGVkU2FtcGxpbmdSYXRlKi8sCi0gICAgICAgICAgICAgICAgICAgIGZvcm1hdCwgTlVMTCAvKnVwZGF0ZWRGb3JtYXQqLywKLSAgICAgICAgICAgICAgICAgICAgY2hhbm5lbE1hc2ssIE5VTEwgLyp1cGRhdGVkQ2hhbm5lbE1hc2sqLywKLSAgICAgICAgICAgICAgICAgICAgZmxhZ3MpKSB7CisgICAgICAgICAgICAgaWYgKCFjdXJQcm9maWxlLT5pc0NvbXBhdGlibGVQcm9maWxlKGRldmljZXMsCisgICAgICAgICAgICAgICAgICAgICBzYW1wbGluZ1JhdGUsIE5VTEwgLyp1cGRhdGVkU2FtcGxpbmdSYXRlKi8sCisgICAgICAgICAgICAgICAgICAgICBmb3JtYXQsIE5VTEwgLyp1cGRhdGVkRm9ybWF0Ki8sCisgICAgICAgICAgICAgICAgICAgICBjaGFubmVsTWFzaywgTlVMTCAvKnVwZGF0ZWRDaGFubmVsTWFzayovLAorICAgICAgICAgICAgICAgICAgICAgZmxhZ3MpKSB7CisgICAgICAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAvLyByZWplY3QgcHJvZmlsZXMgbm90IGNvcnJlc3BvbmRpbmcgdG8gYSBkZXZpY2UgY3VycmVudGx5IGF2YWlsYWJsZQorICAgICAgICAgICAgIGlmICghbUF2YWlsYWJsZU91dHB1dERldmljZXMuY29udGFpbnNBdExlYXN0T25lKGN1clByb2ZpbGUtPmdldFN1cHBvcnRlZERldmljZXMoKSkpIHsKKyAgICAgICAgICAgICAgICAgY29udGludWU7CisgICAgICAgICAgICAgfQorICAgICAgICAgICAgIC8vIHJlamVjdCBwcm9maWxlcyBpZiBjb25uZWN0ZWQgZGV2aWNlIGRvZXMgbm90IHN1cHBvcnQgY29kZWMKKyAgICAgICAgICAgICBpZiAoIWN1clByb2ZpbGUtPmRldmljZXNTdXBwb3J0RW5jb2RlZEZvcm1hdHMoZGV2aWNlcy50eXBlcygpKSkgeworICAgICAgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgICAgICB9CisgICAgICAgICAgICAgaWYgKCFkaXJlY3RPbmx5KSB7CisgICAgICAgICAgICAgICAgcmV0dXJuIGN1clByb2ZpbGU7CisgICAgICAgICAgICAgfQorCisgICAgICAgICAgICAgLy8gd2hlbiBzZWFyY2hpbmcgZm9yIGRpcmVjdCBvdXRwdXRzLCBpZiBzZXZlcmFsIHByb2ZpbGVzIGFyZSBjb21wYXRpYmxlLCBnaXZlIHByaW9yaXR5CisgICAgICAgICAgICAgLy8gdG8gb25lIHdpdGggb2ZmbG9hZCBjYXBhYmlsaXR5CisgICAgICAgICAgICAgaWYgKHByb2ZpbGUgIT0gMCAmJiAKKyAgICAgICAgICAgICAgICAgKChjdXJQcm9maWxlLT5nZXRGbGFncygpICYgQVVESU9fT1VUUFVUX0ZMQUdfQ09NUFJFU1NfT0ZGTE9BRCkgPT0gMCkpIHsKICAgICAgICAgICAgICAgICBjb250aW51ZTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIC8vIHJlamVjdCBwcm9maWxlcyBub3QgY29ycmVzcG9uZGluZyB0byBhIGRldmljZSBjdXJyZW50bHkgYXZhaWxhYmxlCi0gICAgICAgICAgICBpZiAoIW1BdmFpbGFibGVPdXRwdXREZXZpY2VzLmNvbnRhaW5zQXRMZWFzdE9uZShjdXJQcm9maWxlLT5nZXRTdXBwb3J0ZWREZXZpY2VzKCkpKSB7Ci0gICAgICAgICAgICAgICAgY29udGludWU7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICAvLyByZWplY3QgcHJvZmlsZXMgaWYgY29ubmVjdGVkIGRldmljZSBkb2VzIG5vdCBzdXBwb3J0IGNvZGVjCi0gICAgICAgICAgICBpZiAoIWN1clByb2ZpbGUtPmRldmljZXNTdXBwb3J0RW5jb2RlZEZvcm1hdHMoZGV2aWNlcy50eXBlcygpKSkgewotICAgICAgICAgICAgICAgIGNvbnRpbnVlOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgaWYgKCFkaXJlY3RPbmx5KSByZXR1cm4gY3VyUHJvZmlsZTsKLSAgICAgICAgICAgIC8vIHdoZW4gc2VhcmNoaW5nIGZvciBkaXJlY3Qgb3V0cHV0cywgaWYgc2V2ZXJhbCBwcm9maWxlcyBhcmUgY29tcGF0aWJsZSwgZ2l2ZSBwcmlvcml0eQotICAgICAgICAgICAgLy8gdG8gb25lIHdpdGggb2ZmbG9hZCBjYXBhYmlsaXR5Ci0gICAgICAgICAgICBpZiAocHJvZmlsZSAhPSAwICYmICgoY3VyUHJvZmlsZS0+Z2V0RmxhZ3MoKSAmIEFVRElPX09VVFBVVF9GTEFHX0NPTVBSRVNTX09GRkxPQUQpID09IDApKSB7Ci0gICAgICAgICAgICAgICAgY29udGludWU7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBwcm9maWxlID0gY3VyUHJvZmlsZTsKLSAgICAgICAgICAgIGlmICgocHJvZmlsZS0+Z2V0RmxhZ3MoKSAmIEFVRElPX09VVFBVVF9GTEFHX0NPTVBSRVNTX09GRkxPQUQpICE9IDApIHsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KKyAgICAgICAgICAgICB9CisgICAgICAgICAgICAgcHJvZmlsZSA9IGN1clByb2ZpbGU7CisgICAgICAgICAgICAgaWYgKChwcm9maWxlLT5nZXRGbGFncygpICYgQVVESU9fT1VUUFVUX0ZMQUdfQ09NUFJFU1NfT0ZGTE9BRCkgIT0gMCkgeworICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICB9CiAgICAgcmV0dXJuIHByb2ZpbGU7CkBAIC0xMDEyLDcgKzExMzMsOCBAQAogICAgICAgICBhdWRpb19wb3J0X2hhbmRsZV90ICpzZWxlY3RlZERldmljZUlkLAogICAgICAgICBib29sICppc1JlcXVlc3RlZERldmljZUZvckV4Y2x1c2l2ZVVzZSwKICAgICAgICAgc3RkOjp2ZWN0b3I8c3A8QXVkaW9Qb2xpY3lNaXg+PiAqc2Vjb25kYXJ5TWl4ZXMsCi0gICAgICAgIG91dHB1dF90eXBlX3QgKm91dHB1dFR5cGUpCisgICAgICAgIG91dHB1dF90eXBlX3QgKm91dHB1dFR5cGUsCisgICAgICAgIGJvb2wgKmlzU3BhdGlhbGl6ZWQpCiB7CiAgICAgRGV2aWNlVmVjdG9yIG91dHB1dERldmljZXM7CiAgICAgY29uc3QgYXVkaW9fcG9ydF9oYW5kbGVfdCByZXF1ZXN0ZWRQb3J0SWQgPSAqc2VsZWN0ZWREZXZpY2VJ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3RyKCkpOwpAQCAtMTEzMCw3ICsxMjU0LDcgQEAKICAgICB9CiAgICAgaWYgKCpvdXRwdXQgPT0gQVVESU9fSU9fSEFORExFX05PTkUpIHsKICAgICAgICAgKm91dHB1dCA9IGdldE91dHB1dEZvckRldmljZXMob3V0cHV0RGV2aWNlcywgc2Vzc2lvbiwgcmVzdWx0QXR0ciwgY29uZmlnLAotICAgICAgICAgICAgICAgIGZsYWdzLCByZXN1bHRBdHRyLT5mbGFncyAmIEFVRElPX0ZMQUdfTVVURV9IQVBUSUMpOworICAgICAgICAgICAgICAgIGZsYWdzLCBpc1NwYXRpYWxpemVkLCByZXN1bHRBdHRyLT5mbGFncyAmIEFVRElPX0ZMQUdfTVVURV9IQVBUSUMpOwogICAgIH0KICAgICBpZiAoKm91dHB1dCA9PSBBVURJT19JT19IQU5ETEVfTk9ORSkgewogICAgICAgICByZXR1cm4gSU5WQUxJRF9PUEVSQVRJT047CkBAIC0xMTY1LDcgKzEyODksOCBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX3BvcnRfaGFuZGxlX3QgKnNlbGVjdGVkRGV2aWNlSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fcG9ydF9oYW5kbGVfdCAqcG9ydElkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0ZDo6dmVjdG9yPGF1ZGlvX2lvX2hhbmRsZV90PiAqc2Vjb25kYXJ5T3V0cHV0cywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXRfdHlwZV90ICpvdXRwdXRUeXBlKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dF90eXBlX3QgKm91dHB1dFR5cGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbC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QgeworICAgIHNzaXplX3QgaW5kZXggPSBtQXVkaW9QYXRjaGVzLmluZGV4T2ZLZXkoaGFuZGxlKTsKKyAgICBpZiAoaW5kZXggPCAwKSB7CisgICAgICAgIHJldHVybiBmYWxzZTsKKyAgICB9CisgICAgY29uc3Qgc3A8QXVkaW9QYXRjaD4gcGF0Y2ggPSBtQXVkaW9QYXRjaGVzLnZhbHVlQXQoaW5kZXgpOworICAgIHNwPEh3TW9kdWxlPiBtc2RNb2R1bGUgPSBtSHdNb2R1bGVzLmdldE1vZHVsZUZyb21OYW1lKEFVRElPX0hBUkRXQVJFX01PRFVMRV9JRF9NU0QpOworICAgIGlmIChtc2RNb2R1bGUgPT0gbnVsbHB0cikgeworICAgICAgICByZXR1cm4gZmFsc2U7CisgICAgfQorICAgIGNvbnN0IHN0cnVjdCBhdWRpb19wb3J0X2NvbmZpZyAqc2luayA9ICZwYXRjaC0+bVBhdGNoLnNpbmtzWzBdOworICAgIGlmIChnZXRNc2RBdWRpb091dERldmljZXMoKS5jb250YWlucyhtQXZhaWxhYmxlT3V0cHV0RGV2aWNlcy5nZXREZXZpY2VGcm9tSWQoc2luay0+aWQpKSkgeworICAgICAgICByZXR1cm4gdHJ1ZTsKKyAgICB9CisgICAgaW5kZXggPSBnZXRNc2RPdXRwdXRQYXRjaGVzKCkuaW5kZXhPZktleShoYW5kbGUpOworICAgIGlmIChpbmRleCA8IDApIHsKKyAgICAgICAgcmV0dXJuIGZhbHNlOworICAgIH0KKyAgICByZXR1cm4gdHJ1ZTsKK30KKwogc3RhdHVzX3QgQXVkaW9Qb2xpY3lNYW5hZ2VyOjpnZXRNc2RQcm9maWxlcyhib29sIGh3QXZTeW5jLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBJbnB1dFByb2ZpbGVDb2xsZWN0aW9uICZpbnB1dFByb2ZpbGVzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBP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ZXZpY2UgIT0gbnVsbHB0cikgeworICAgICAgICAgICAgICAgICAgICBkZXZpY2VzVG9DaGVjay5yZW1vdmUoZm91bmREZXZpY2UpOworICAgICAgICAgICAgICAgICAgICBpZiAoZGV2aWNlc1RvQ2hlY2suaXNFbXB0eSgpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KKyAgICByZXR1cm4gZmFsc2U7Cit9CisKIGF1ZGlvX2lvX2hhbmRsZV90IEF1ZGlvUG9saWN5TWFuYWdlcjo6c2VsZWN0T3V0cHV0KGNvbnN0IFNvcnRlZFZlY3RvcjxhdWRpb19pb19oYW5kbGVfdD4mIG91dHB1dHMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19vdXRwdXRfZmxhZ3NfdCBmbGFncywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX2Zvcm1hdF90IGZvcm1hdCwKQEAgLTE2NjksNyArMTg0NCw4IEBACiAgICAgLy8gb3RoZXIgY3JpdGVyaWEKICAgICBzdGF0aWMgY29uc3QgYXVkaW9fb3V0cHV0X2ZsYWdzX3Qga0Z1bmN0aW9uYWxGbGFncyA9IChhdWRpb19vdXRwdXRfZmxhZ3NfdCkKICAgICAgICAgKEFVRElPX09VVFBVVF9GTEFHX1ZPSVBfUlggfCBBVURJT19PVVRQVVRfRkxBR19JTkNBTExfTVVTSUMgfAotICAgICAgICAgICAgQVVESU9fT1VUUFVUX0ZMQUdfVFRTIHwgQVVESU9fT1VUUFVUX0ZMQUdfRElSRUNUX1BDTSk7CisgICAgICAgICAgICBBVURJT19PVVRQVVRfRkxBR19UVFMgfCBBVURJT19PVVRQVVRfRkxBR19ESVJFQ1RfUENNIHwgQVVESU9f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5hZ2VyOjppc0xlVW5pY2FzdEFjdGl2ZSgpIGNvbnN0IHsKKyAgICBpZiAoaXNJbkNhbGwoKSkgeworICAgICAgICByZXR1cm4gdHJ1ZTsKKyAgICB9CisgICAgcmV0dXJuIGlzQW55RGV2aWNlVHlwZUFjdGl2ZShnZXRBdWRpb0RldmljZU91dExlQXVkaW9VbmljYXN0U2V0KCkpOworfQorCitib29sIEF1ZGlvUG9saWN5TWFuYWdlcjo6aXNBbnlEZXZpY2VUeXBlQWN0aXZlKGNvbnN0IERldmljZVR5cGVTZXQmIGRldmljZVR5cGVzKSBjb25zdCB7CisgICAgaWYgKG1BdmFpbGFibGVPdXRwdXREZXZpY2VzLmdldERldmljZXNGcm9tVHlwZXMoZGV2aWNlVHlwZXMpLmlzRW1wdHkoKSkgeworICAgICAgICByZXR1cm4gZmFsc2U7CisgICAgfQorICAgIGJvb2wgYWN0aXZlID0gbU91dHB1dHMuaXNBbnlEZXZpY2VUeXBlQWN0aXZlKGRldmljZVR5cGVzKTsKKyAgICBBTE9HVigiJXMgYWN0aXZlICVkIiwgX19mdW5jX18sIGFjdGl2ZSk7CisgICAgcmV0dXJuIGFjdGl2ZTsKK30KKwogc3RhdHVzX3QgQXVkaW9Qb2xpY3lNYW5hZ2VyOjpzdGFydFNvdXJjZShjb25zdCBzcDxTd0F1ZGlvT3V0cHV0RGVzY3JpcHRvcj4mIG91dHB1dERlc2MsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNwPFRyYWNrQ2xpZW50RGVzY3JpcHRvcj4mIGNsaWVudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdWludDMyX3QgKmRlbGF5TXMpCkBAIC0xODI4LDcgKzIwMjcsNyBAQAogICAgIGlmIChzdHJlYW0gPT0gQVVESU9fU1RSRUFNX1RUUykgewogICAgICAgICBBTE9HVigiXHQgZm91bmQgQkVBQ09OIHN0cmVhbSIpOwogICAgICAgICBpZ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dldFZvbHVtZUluZGV4KG91dHB1dERlc2MtPmRldmljZXMoKS50eXBlcygpKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0RGVzYywKICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0RGVzYy0+ZGV2aWNlcygpLnR5cGVzKCksIDAgLypkZWxheSovLAotICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXREZXNjLT51c2VId0dhaW4oKSAvKmZvcmNlKi8pOworICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXREZXNjLT51c2VId0dhaW4oKSAvKmZvcmNlKi8pKSB7CisgICAgICAgICAgICAvLyByZXF1ZXN0IEF1ZGlvU2VydmljZSB0byByZWluaXRpYWxpemUgdGhlIHZvbHVtZSBjdXJ2ZXMgYXN5bmNocm9ub3VzbHkKKyAgICAgICAgICAgIEFMT0dFKCJjaGVja0FuZFNldFZvbHVtZSBmYWlsZWQsIHJlcXVlc3Rpbmcgdm9sdW1lIHJhbmdlIGluaXQiKTsKKyAgICAgICAgICAgIG1wQ2xpZW50SW50ZXJmYWNlLT5vblZvbHVtZVJhbmdlSW5pdFJlcXVlc3QoKTsKKyAgICAgICAgfTsKIAogICAgICAgICAvLyB1cGRhdGUgdGhlIG91dHB1dHMgaWYgc3RhcnRpbmcgYW4gb3V0cHV0IHdpdGggYSBzdHJlYW0gdGhhdCBjYW4gYWZmZWN0IG5vdGlmaWNhdGlvbgogICAgICAgICAvLyByb3V0aW5nCkBAIC0xOTg4LDkgKzIxOTEsMzggQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFVRElPX0ZPUk1BVF9ERUZBVUxUKTsKICAgICB9CiAKKyAgICBjaGVja0xlQnJvYWRjYXN0Um91dGVzKHdhc0xlVW5pY2FzdEFjdGl2ZSwgb3V0cHV0RGVzYywgKmRlbGF5TXMpOworCiAgICAgcmV0dXJuIE5PX0VSUk9SOwogfQogCit2b2lkIEF1ZGlvUG9saWN5TWFuYWd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ICAgICBnZXRBdWRpb0RldmljZU91dExlQXVkaW9VbmljYXN0U2V0KCkpLmlzRW1wdHkoKSkpKSB7CisgICAgICAgICAgICAgICAgRGV2aWNlVmVjdG9yIG5ld0RldmljZXMgPSBnZXROZXdPdXRwdXREZXZpY2VzKGRlc2MsIGZhbHNlIC8qZnJvbUNhY2hlKi8pOworICAgICAgICAgICAgICAgIGJvb2wgZm9yY2UgPSBkZXNjLT5kZXZpY2VzKCkgIT0gbmV3RGV2aWNlczsKKyAgICAgICAgICAgICAgICBzZXRPdXRwdXREZXZpY2VzKGRlc2MsIG5ld0RldmljZXMsIGZvcmNlLCBkZWxheU1zKTsKKyAgICAgICAgICAgICAgICAvLyByZS1hcHBseSBkZXZpY2Ugc3BlY2lmaWMgdm9sdW1lIGlmIG5vdCBkb25lIGJ5IHNldE91dHB1dERldmljZSgpCisgICAgICAgICAgICAgICAgaWYgKCFmb3JjZSkgeworICAgICAgICAgICAgICAgICAgICBhcHBseVN0cmVhbVZvbHVtZXMoZGVzYywgbmV3RGV2aWNlcy50eXBlcygpLCBkZWxheU1zKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICB9Cit9CisKIHN0YXR1c190IEF1ZGlvUG9saWN5TWFuYWdlcjo6c3RvcE91dHB1dChhdWRpb19wb3J0X2hhbmRsZV90IHBvcnRJZCkKIHsKICAgICBBTE9HVigiJXMgcG9ydElkICVkIiwgX19GVU5DVElPTl9fLCBwb3J0SWQpOwpAQCAtMjAxOSw2ICsyMjUxLDcgQEAKICAgICAvLyBhbHdheXMgaGFuZGxlIHN0cmVhbSBzdG9wLCBjaGVjayB3aGljaCBzdHJlYW0gdHlwZSBpcyBzdG9wcGluZwogICAgIGF1ZGlvX3N0cmVhbV90eXBlX3Qgc3RyZWFtID0gY2xpZW50LT5zdHJlYW0oKTsKICAgICBhdXRvIGNsaWVudFZvbFNyYyA9IGNsaWVudC0+dm9sdW1lU291cmNlKCk7CisgICAgYm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HX1JBVyk7IC8vIHJldHJ5Ci0gICAgICAgIH0gZWxzZSBpZiAocHJvZmlsZUZsYWdzICE9IEFVRElPX0lOUFVUX0ZMQUdfTk9ORSkgeworICAgICAgICB9IGVsc2UgaWYgKHByb2ZpbGVGbGFncyAhPSBBVURJT19JTlBVVF9GTEFHX05PTkUgJiYgYXVkaW9faXNfbGluZWFyX3BjbShjb25maWctPmZvcm1hdCkpIHsKICAgICAgICAgICAgIHByb2ZpbGVGbGFncyA9IEFVRElPX0lOUFVUX0ZMQUdfTk9ORTsgLy8gcmV0cnkKICAgICAgICAgfSBlbHNlIHsgLy8gZmFpbAogICAgICAgICAgICAgQUxPR1coIiVzIGNvdWxkIG5vdCBmaW5kIHByb2ZpbGUgZm9yIGRldmljZSAlcywgc2FtcGxpbmcgcmF0ZSAldSwgZm9ybWF0ICUjeCwgIgotICAgICAgICAgICAgICAgICAgImNoYW5uZWwgbWFzayAweCVYLCBmbGFncyAlI3giLCBfX2Z1bmNfXywgZGV2aWNlLT50b1N0cmluZygpLmNfc3RyKCksIAorICAgICAgICAgICAgICAgICAgImNoYW5uZWwgbWFzayAweCVYLCBmbGFncyAlI3giLCBfX2Z1bmNfXywgZGV2aWNlLT50b1N0cmluZygpLmNfc3RyKCksCiAgICAgICAgICAgICAgICAgICBjb25maWctPnNhbXBsZV9yYXRlLCBjb25maWctPmZvcm1hdCwgY29uZmlnLT5jaGFubmVsX21hc2ssIGZsYWdzKTsKICAgICAgICAgICAgIHJldHVybiBpbnB1dDsKICAgICAgICAgfQpAQCAtMjgxMSw2ICszMDU3LDggQEAKICAgICAgICAgLy8gSFcgR2FpbiBtYW5hZ2VtZW50LCBkbyBub3QgY2hhbmdlIHRoZSB2b2x1bWUKICAgICAgICAgaWYgKGRlc2MtPnVzZUh3R2FpbigpKSB7CiAgICAgICAgICAgICBhcHBseVZvbHVtZSA9IGZhbHNlOworICAgICAgICAgICAgLy8gSWYgdGhlIHZvbHVtZSBzb3VyY2UgaXMgYWN0aXZlIHdpdGggaGlnaGVyIHByaW9yaXR5IHNvdXJjZSwgZW5zdXJlIGF0IGxlYXN0IFN3IE11dGVkCisgICAgICAgICAgICBkZXNjLT5zZXRTd011dGUoKGluZGV4ID09IDApLCB2cywgY3VydmVzLmdldFN0cmVhbVR5cGVzKCksIGN1ckRldmljZXMsIDAgLypkZWxheU1zKi8pOwogICAgICAgICAgICAgZm9yIChjb25zdCBhdXRvICZwcm9kdWN0U3RyYXRlZ3kgOiBtRW5naW5lLT5nZXRPcmRlcmVkUHJvZHVjdFN0cmF0ZWdpZXMoKSkgewogICAgICAgICAgICAgICAgIGF1dG8gYWN0aXZlQ2xpZW50cyA9IGRlc2MtPmNsaWVudHNMaXN0KHRydWUgLyphY3RpdmVPbmx5Ki8sIHByb2R1Y3RTdHJhdGVneSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmYWxzZSAvKnByZWZlcnJlZERldmljZSovKTsKQEAgLTI4NTAsNyArMzA5OCw3IEBACiAgICAgICAgIC8vIGhhbmRsZWQgYnkgc3lzdGVtIFVJCiAgICAgICAgIHN0YXR1c190IHZvbFN0YXR1cyA9IGNoZWNrQW5kU2V0Vm9sdW1lKAogICAgICAgICAgICAgICAgICAgICBjdXJ2ZXMsIHZzLCBpbmRleCwgZGVzYywgY3VyRGV2aWNlcywKLSAgICAgICAgICAgICAgICAgICAgKCh2cyA9PSB0b1ZvbHVtZVNvdXJjZShBVURJT19TVFJFQU1fU1lTVEVNKSk/CisgICAgICAgICAgICAgICAgICAgICgodnMgPT0gdG9Wb2x1bWVTb3VyY2UoQVVESU9fU1RSRUFNX1NZU1RFTSwgZmFsc2UpKT8KICAgICAgICAgICAgICAgICAgICAgICAgICBUT1VDSF9TT1VORF9GSVhFRF9ERUxBWV9NUyA6IDApKTsKICAgICAgICAgaWYgKHZvbFN0YXR1cyAhPSBOT19FUlJPUikgewogICAgICAgICAgICAgc3RhdHVzID0gdm9sU3RhdHVzO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AgICAgICAgIC8vIHByZXZlbnRpbmcgdGhlIGZvcmNlIHJlLXJvdXRpbmcgaW4gY2FzZSBvZiBkZWZhdWx0IGRldiB0aGF0IGRpc3Rpbmd1aXNoZXMgb24gYWRkcmVzcy4KICAgICAgICAgICAgIC8vIExldCdzIGdpdmUgYmFjayB0byBlbmdpbmUgZnVsbCBkZXZpY2UgY2hvaWNlIGRlY2lzaW9uIGhvd2V2ZXIuCi0gICAgICAgICAgICB3YWl0TXMgPSBzZXRPdXRwdXREZXZpY2VzKG91dHB1dERlc2MsIG5ld0RldmljZXMsICFuZXdEZXZpY2VzLmlzRW1wdHkoKSwgZGVsYXlNcyk7CisgICAgICAgICAgICBib29sIGZvcmNlUm91dGluZyA9ICFuZXdEZXZpY2VzLmlzRW1wdHkoKTsKKyAgICAgICAgICAgIHdhaXRNcyA9IHNldE91dHB1dERldmljZXMob3V0cHV0RGVzYywgbmV3RGV2aWNlcywgZm9yY2VSb3V0aW5nLCBkZWxheU1zLCBudWxscHRyLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnVlIC8qcmVxdWlyZXNNdXRlQ2hlY2sqLywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIWZvcmNlUm91dGluZyAvKnJlcXVpcmVzVm9sdW1lQ2hlY2sqLyk7CiAgICAgICAgICAgICAvLyBPbmx5IGFwcGx5IHNwZWNpYWwgdG91Y2ggc291bmQgZGVsYXkgb25jZQogICAgICAgICAgICAgZGVsYXlNcyA9IDA7CiAgICAgICAgIH0KQEAgLTM0MDgsNiArMzY2Myw3IEBACiAgICAgICAgICAgICBhcHBseVN0cmVhbVZvbHVtZXMob3V0cHV0RGVzYywgbmV3RGV2aWNlcy50eXBlcygpLCB3YWl0TXMsIHRydWUpOwogICAgICAgICB9CiAgICAgfQorICAgIGNoZWNrTGVCcm9hZGNhc3RSb3V0ZXMod2FzTGVVbmljYXN0QWN0aXZlLCBudWxscHRyLCBkZWxheU1zKT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QAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGF1ZGlvX2F0dHJpYnV0ZXNfdCYgYXR0cmlidXRlcykgewogICAgIGF1ZGlvX291dHB1dF9mbGFnc190IG91dHB1dF9mbGFncyA9IEFVRElPX09VVFBVVF9GTEFHX05PTkU7CiAgICAgYXVkaW9fZmxhZ3NfdG9fYXVkaW9fb3V0cHV0X2ZsYWdzKGF0dHJpYnV0ZXMuZmxhZ3MsICZvdXRwdXRfZmxhZ3MpOwotICAgIHNwPElPUHJvZmlsZT4gcHJvZmlsZSA9IGdldFByb2ZpbGVGb3JPdXRwdXQoRGV2aWNlVmVjdG9yKCkgLyppZ25vcmUgZGV2aWNlICovLAorICAgIERldmljZVZlY3RvciBvdXRwdXREZXZpY2VzID0gbUVuZ2luZS0+Z2V0T3V0cHV0RGV2aWNlc0ZvckF0dHJpYnV0ZXMoYXR0cmlidXRlcyk7CisgICAgc3A8SU9Qcm9maWxlPiBwcm9maWxlID0gZ2V0UHJvZmlsZUZvck91dHB1dChvdXRwdXREZXZpY2VzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWcuc2FtcGxlX3JhdGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpZy5mb3JtYXQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpZy5jaGFubmVsX21hc2ssCkBAIC0zNzI0LDcgKzM5MzcsMTk3IEBACiAgICAgICAgIF9fRlVOQ1RJT05fXywgcHJvZmlsZSAhPSAwID8gIiIgOiAiTk9UICIsCiAgICAgICAgIChwcm9maWxlICE9IDAgPyBwcm9maWxlLT5nZXRUYWdOYW1lKCkuY19zdHIoKSA6ICJudWxsIiksCiAgICAgICAgIGNvbmZpZy5zYW1wbGVfcmF0ZSwgY29uZmlnLmZvcm1hdCwgY29uZmlnLmNoYW5uZWxfbWFzaywgb3V0cHV0X2ZsYWdzKTsKLSAgICByZXR1cm4gKHByb2ZpbGUgIT0gMCk7CisKKyAgICAvLyBhbHNvIHRyeSB0aGUgTVNEIG1vZHVsZSBpZiBjb21wYXRpYmxlIHByb2ZpbGUgbm90IGZvdW5kCisgICAgaWYgKHByb2ZpbGUgPT0gbnVsbHB0cikgeworICAgICAgICBwcm9maWxlID0gZ2V0TXNkUHJvZmlsZUZvck91dHB1dChvdXRwdXREZXZpY2VzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpZy5zYW1wbGVfcmF0ZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWcuZm9ybWF0LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpZy5jaGFubmVsX21hc2ssCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0X2ZsYWdzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRydWUgLyogZGlyZWN0T25seSAqLyk7CisgICAgICAgIEFMT0dWKCIlcygpIE1TRCBwcm9maWxlICVzZm91bmQgd2l0aCBuYW1lOiAlcywgIgorICAgICAgICAgICAgInNhbXBsZSByYXRlOiAldSwgZm9ybWF0OiAweCV4LCBjaGFubmVsX21hc2s6IDB4JXgsIG91dHB1dCBmbGFnczogMHgleCIsCisgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIHByb2ZpbGUgIT0gMCA/ICIiIDogIk5PVCAiLAorICAgICAgICAgICAgKHByb2ZpbGUgIT0gMCA/IHByb2ZpbGUtPmdldFRhZ05hbWUoKS5jX3N0cigpIDogIm51bGwiKSwKKyAgICAgICAgICAgIGNvbmZpZy5zYW1wbGVfcmF0ZSwgY29uZmlnLmZvcm1hdCwgY29uZmlnLmNoYW5uZWxfbWFzaywgb3V0cHV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cHV0RGV2aWNlcyA9IGdldE1zZEF1ZGlvT3V0RGV2aWNlcygpOworICAgICAgICB9CisgICAgICAgIGZvciAoY29uc3QgYXV0byYgY3VyUHJvZmlsZSA6IGh3TW9kdWxlLT5nZXRPdXRwdXRQcm9maWxlcygpKSB7CisgICAgICAgICAgICBpZiAoIWN1clByb2ZpbGUtPmlzQ29tcGF0aWJsZVByb2ZpbGUob3V0cHV0RGV2aWNlcywKKyAgICAgICAgICAgICAgICAgICAgY29uZmlnLT5zYW1wbGVfcmF0ZSwgbnVsbHB0ciAvKnVwZGF0ZWRTYW1wbGluZ1JhdGUqLywKKyAgICAgICAgICAgICAgICAgICAgY29uZmlnLT5mb3JtYXQsIG51bGxwdHIgLyp1cGRhdGVkRm9ybWF0Ki8sCisgICAgICAgICAgICAgICAgICAgIGNvbmZpZy0+Y2hhbm5lbF9tYXNrLCBudWxscHRyIC8qdXBkYXRlZENoYW5uZWxNYXNrKi8sCisgICAgICAgICAgICAgICAgICAgIGZsYWdzKSkgeworICAgICAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICAgICAgfQorICAgICAgICAgICAgLy8gcmVqZWN0IHByb2ZpbGVzIG5vdCBjb3JyZXNwb25kaW5nIHRvIGEgZGV2aWNlIGN1cnJlbnRseSBhdmFpbGFibGUKKyAgICAgICAgICAgIGlmICghbUF2YWlsYWJsZU91dHB1dERldmljZXMuY29udGFpbnNBdExlYXN0T25lKGN1clByb2ZpbGUtPmdldFN1cHBvcnRlZERldmljZXMoKSkpIHsKKyAgICAgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGlmICgoY3VyUHJvZmlsZS0+Z2V0RmxhZ3MoKSAmIEFVRElPX09VVFBVVF9GTEFHX0NPTVBSRVNTX09GRkxPQUQpCisgICAgICAgICAgICAgICAgICAgICAgICAhPSBBVURJT19PVVRQVVRfRkxBR19OT05FKSB7CisgICAgICAgICAgICAgICAgaWYgKChkaXJlY3RNb2RlICYgQVVESU9fRElSRUNUX09GRkxPQURfR0FQTEVTU19TVVBQT1JURUQpCisgICAgICAgICAgICAgICAgICAgICAgICAhPSBBVURJT19ESVJFQ1RfTk9UX1NVUFBPUlRFRCkgeworICAgICAgICAgICAgICAgICAgICAvLyBBbHJlYWR5IHJlcG9ydHMgb2ZmbG9hZCBnYXBsZXNzIHN1cHBvcnRlZC4gTm8gbmVlZCB0byByZXBvcnQgb2ZmbG9hZCBzdXBwb3J0LgorICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgaWYgKChjdXJQcm9maWxlLT5nZXRGbGFncygpICYgQVVESU9fT1VUUFVUX0ZMQUdfR0FQTEVTU19PRkZMT0FEKQorICAgICAgICAgICAgICAgICAgICAgICAgIT0gQVVESU9fT1VUUFVUX0ZMQUdfTk9ORSkgeworICAgICAgICAgICAgICAgICAgICAvLyBJZiBvZmZsb2FkIGdhcGxlc3MgaXMgcmVwb3J0ZWQsIG5vIG5lZWQgdG8gcmVwb3J0IG9mZmxvYWQgc3VwcG9ydC4KKyAgICAgICAgICAgICAgICAgICAgZGlyZWN0TW9kZSA9IChhdWRpb19kaXJlY3RfbW9kZV90KSAoKGRpcmVjdE1vZGUgJgorICAgICAgICAgICAgICAgICAgICAgICAgICAgIH5BVURJT19ESVJFQ1RfT0ZGTE9BRF9TVVBQT1JURUQpIHwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBBVURJT19ESVJFQ1RfT0ZGTE9BRF9HQVBMRVNTX1NVUFBPUlRFRCk7CisgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgZGlyZWN0TW9kZSA9IChhdWRpb19kaXJlY3RfbW9kZV90KShkaXJlY3RNb2RlIHwgQVVESU9fRElSRUNUX09GRkxPQURfU1VQUE9SVEVEKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgI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2R1bGUtPmdldE5hbWUoKSwgQVVESU9fSEFSRFdBUkVfTU9EVUxFX0lEX01TRCkgPT0gMCkgeworICAgICAgICAgICAgY29udGludWU7CisgICAgICAgIH0KKyAgICAgICAgZm9yIChjb25zdCBhdXRvJiBvdXRwdXRQcm9maWxlIDogaHdNb2R1bGUtPmdldE91dHB1dFByb2ZpbGVzKCkpIHsKKyAgICAgICAgICAgIGlmICghb3V0cHV0UHJvZmlsZS0+YXNBdWRpb1BvcnQoKS0+aXNEaXJlY3RPdXRwdXQoKSkgeworICAgICAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICAgICAgfQorICAgICAgICAgICAgLy8gYWxsb3cgb25seSBwcm9maWxlcyB0aGF0IHN1cHBvcnQgYWxsIHRoZSBhdmFpbGFibGUgYW5kIHJvdXRlZCBkZXZpY2VzCisgICAgICAgICAgICBpZiAob3V0cHV0UHJvZmlsZS0+Z2V0U3VwcG9ydGVkRGV2aWNlcygpLmdldERldmljZXNGcm9tRGV2aWNlVHlwZUFkZHJWZWMoZGV2aWNlcykuc2l6ZSgpCisgICAgICAgICAgICAgICAgICAgICE9IGRldmljZXMuc2l6ZSgpKSB7CisgICAgICAgICAgICAgICAgY29udGludWU7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBhdWRpb1Byb2ZpbGVzVmVjdG9yLmFkZEFsbFZhbGlkUHJvZmlsZXMoCisgICAgICAgICAgICAgICAgICAgIG91dHB1dFByb2ZpbGUtPmFzQXVkaW9Qb3J0KCktPmdldEF1ZGlvUHJvZmlsZXMoKSk7CisgICAgICAgIH0KKyAgICB9CisKKyAgICAvLyBhZGQgdGhlIGRpcmVjdCBwcm9maWxlcyBmcm9tIE1TRCBpZiBwcmVzZW50IGFuZCBoYXMgYXVkaW8gcGF0Y2hlcyB0byBhbGwgdGhlIG91dHB1dChzKQorICAgIGNvbnN0IGF1dG8mIG1zZE1vZHVsZSA9IG1Id01vZHVsZXMuZ2V0TW9kdWxlRnJvbU5hbWUoQVVESU9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mFnZXI6OmNyZWF0ZUF1ZGlvUGF0Y2hJbnRlcm5hbChjb25zdCBzdHJ1Y3QgYXVkaW9fcGF0Y2ggKnBhdGNoLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fcGF0Y2hfaGFuZGxlX3QgKmhhbmRsZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVpZF90IHVpZCwgdWludDMyX3QgZGVsYXlNcywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNwPFNvdXJjZUNsaWVudERlc2NyaXB0b3I+JiBzb3VyY2VEZXNjKQorc3RhdHVzX3QgQXVkaW9Qb2xpY3lNYW5hZ2VyOjpjcmVhdGVBdWRpb1BhdGNoKGNvbnN0IHN0cnVjdCBhdWRpb19wYXRjaCAqcGF0Y2gsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fcGF0Y2hfaGFuZGxlX3QgKmhhbmRsZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aWRfdCB1aWQpCiB7CiAgICAgQUxPR1YoIiVzIiwgX19mdW5jX18pOwogICAgIGlmIChoYW5kbGUgPT0gTlVMTCB8fCBwYXRjaCA9PSBOVUxMKSB7CiAgICAgICAgIHJldHVybiBCQURfVkFMVUU7CiAgICAgfQogICAgIEFMT0dWKCIlcyBudW0gc291cmNlcyAlZCBudW0gc2lua3MgJWQiLCBfX2Z1bmNfXywgcGF0Y2gtPm51bV9zb3VyY2VzLCBwYXRjaC0+bnVtX3NpbmtzKTsKLQogICAgIGlmICghYXVkaW9fcGF0Y2hfaXNfdmFsaWQocGF0Y2gpKSB7CiAgICAgICAgIHJldHVybiBCQURfVkFMVUU7CiAgICAgfQpAQCAtMzg0Miw3ICs0MjQzLDYgQEAK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kZWQ6CisgICAgcmVsZWFzZUF1ZGlvUGF0Y2hJbnRlcm5hbChoYW5kbGUpOworICAgIHJldHVybiBJTlZBTElEX09QRVJBVElPTjsKK30KKworc3RhdHVzX3QgQXVkaW9Qb2xpY3lNYW5hZ2VyOjpjcmVhdGVBdWRpb1BhdGNoSW50ZXJuYWwoY29uc3Qgc3RydWN0IGF1ZGlvX3BhdGNoICpwYXRjaCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX3BhdGNoX2hhbmRsZV90ICpoYW5kbGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aWRfdCB1aWQsIHVpbnQzMl90IGRlbGF5TXMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcDxTb3VyY2VDbGllbnREZXNjcmlwdG9yPiYgc291cmNlRGVzYykKK3sKKyAgICBBTE9HVigiJXMgbnVtIHNvdXJjZXMgJWQgbnVtIHNpbmtzICVkIiwgX19mdW5jX18sIHBhdGNoLT5udW1fc291cmNlcywgcGF0Y2gtPm51bV9zaW5rcyk7CiAgICAgc3A8QXVkaW9QYXRjaD4gcGF0Y2hEZXNjOwogICAgIHNzaXplX3QgaW5kZXggPSBtQXVkaW9QYXRjaGVzLmluZGV4T2ZLZXkoKmhhbmRsZSk7CiAKQEAgLTQwNDAsNyArNDUyMCw3IEBACiAgICAgICAgICAgICAgICAgLy8gaW4gY29uZmlnIFhNTCB0byByZWFjaCB0aGUgc2luayBzbyB0aGF0IGlzIGNhbiBiZSBkZWNsYXJlZCBhcyBhdmFpbGFibGUuCiAgICAgICAgICAgICAgICAgYXVkaW9faW9faGFuZGxlX3Qgb3V0cHV0ID0gQVVESU9fSU9fSEFORExFX05PTkU7CiAgICAgICAgICAgICAgICAgc3A8U3dBdWRpb091dHB1dERlc2NyaXB0b3I+IG91dHB1dERlc2MgPSBudWxscHRyOwotICAgICAgICAgICAgICAgIGlmIChzb3VyY2VEZXNjICE9IG51bGxwdHIpIHsKKyAgICAgICAgICAgICAgICBpZiAoIXNvdXJjZURlc2MtPmlzSW50ZXJuYWwoKSkgewogICAgICAgICAgICAgICAgICAgICAvLyB0YWtlIGNhcmUgb2YgZHluYW1pYyByb3V0aW5nIGZvciBTd091dHB1dCBzZWxlY3Rpb24sCiAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX2F0dHJpYnV0ZXNfdCBhdHRyaWJ1dGVzID0gc291cmNlRGVzYy0+YXR0cmlidXRlcygpOwogICAgICAgICAgICAgICAgICAgICBhdWRpb19zdHJlYW1fdHlwZV90IHN0cmVhbSA9IHNvdXJjZURlc2MtPnN0cmVhbSgpOwpAQCAtNDA1MywxMCArNDUzMywxMSBAQAogICAgICAgICAgICAgICAgICAgICBhdWRpb19wb3J0X2hhbmRsZV90IHNlbGVjdGVkRGV2aWNlSWQgPSBBVURJT19QT1JUX0hBTkRMRV9OT05FOwogICAgICAgICAgICAgICAgICAgICBib29sIGlzUmVxdWVzdGVkRGV2aWNlRm9yRXhjbHVzaXZlVXNlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgIG91dHB1dF90eXBlX3Qgb3V0cHV0VHlwZTsKKyAgICAgICAgICAgICAgICAgICAgYm9vbCBpc1NwYXRpYWxpemVkOwogICAgICAgICAgICAgICAgICAgICBnZXRPdXRwdXRGb3JBdHRySW50KCZyZXN1bHRBdHRyLCAmb3V0cHV0LCBBVURJT19TRVNTSU9OX05PTkUsICZhdHRyaWJ1dGVzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZzdHJlYW0sIHNvdXJjZURlc2MtPnVpZCgpLCAmY29uZmlnLCAmZmxhZ3MsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJnNlbGVjdGVkRGV2aWNlSWQsICZpc1JlcXVlc3RlZERldmljZUZvckV4Y2x1c2l2ZVVzZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBudWxscHRyLCAmb3V0cHV0VHlwZSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbnVsbHB0ciwgJm91dHB1dFR5cGUsICZpc1NwYXRpYWxpemVkKTsKICAgICAgICAgICAgICAgICAgICAgaWYgKG91dHB1dCA9PSBBVURJT19JT19IQU5ETEVfTk9ORSkgewogICAgICAgICAgICAgICAgICAgICAgICAgQUxPR1YoIiVzIG5vIG91dHB1dCBmb3IgZGV2aWNlICVzIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgc2lua0RldmljZS0+dG9TdHJpbmcoKS5jX3N0cigpKTsKQEAgLTQwNjgsNDQgKzQ1NDksNDkgQEAKICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBJTlZBTElEX09QRVJBVElPTjsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICBzb3VyY2VEZXNjLT5zZXRTd091dHB1dChvdXRwdXREZXNjKTsKKyAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICAvLyBTYW1lIGZvciAicmF3IHBhdGNoZXMiIGFrYSBjcmVhdGVkIGZyb20gY3JlYXRlQXVkaW9QYXRjaCBBUEkKKyAgICAgICAgICAgICAgICAgICAgU29ydGVkVmVjdG9yPGF1ZGlvX2lvX2hhbmRsZV90PiBvdXRwdXRzID0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXRPdXRwdXRzRm9yRGV2aWNlcyhEZXZpY2VWZWN0b3Ioc2lua0RldmljZSksIG1PdXRwdXRzKTsKKyAgICAgICAgICAgICAgICAgICAgLy8gaWYgdGhlIHNpbmsgZGV2aWNlIGlzIHJlYWNoYWJsZSB2aWEgYW4gb3BlbmVkIG91dHB1dCBzdHJlYW0sIHJlcXVlc3QgdG8KKyAgICAgICAgICAgICAgICAgICAgLy8gZ28gdmlhIHRoaXMgb3V0cHV0IHN0cmVhbSBieSBhZGRpbmcgYSBzZWNvbmQgc291cmNlIHRvIHRoZSBwYXRjaAorICAgICAgICAgICAgICAgICAgICAvLyBkZXNjcmlwdGlvbgorICAgICAgICAgICAgICAgICAgICBvdXRwdXQgPSBzZWxlY3RPdXRwdXQob3V0cHV0cyk7CisgICAgICAgICAgICAgICAgICAgIGlmIChvdXRwdXQgPT0gQVVESU9fSU9fSEFORExFX05PTkUpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIEFMT0dFKCIlcyBubyBvdXRwdXQgYXZhaWxhYmxlIGZvciBpbnRlcm5hbCBwYXRjaCBzaW5rIiwgX19mdW5jX18pOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOVkFMSURfT1BFUkFUSU9OOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIG91dHB1dERlc2MgPSBtT3V0cHV0cy52YWx1ZUZvcihvdXRwdXQpOworICAgICAgICAgICAgICAgICAgICBpZiAob3V0cHV0RGVzYy0+aXNEdXBsaWNhdGVkKCkpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIEFMT0dWKCIlcyBvdXRwdXQgZm9yIGRldmljZSAlcyBpcyBkdXBsaWNhdGVkIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9fZnVuY19fLCBzaW5rRGV2aWNlLT50b1N0cmluZygpLmNfc3RyKCkpOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOVkFMSURfT1BFUkFUSU9OOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIHNvdXJjZURlc2MtPnNldFN3T3V0cHV0KG91dHB1dERlc2MpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAvLyBjcmVhdGUgYSBzb2Z0d2FyZSBicmlkZ2UgaW4gUGF0Y2hQYW5lbCBpZjoKICAgICAgICAgICAgICAgICAvLyAtIHNvdXJjZSBhbmQgc2luayBkZXZpY2VzIGFyZSBvbiBkaWZmZXJlbnQgSFcgbW9kdWxlcyBPUgogICAgICAgICAgICAgICAgIC8vIC0gYXVkaW8gSEFMIHZlcnNpb24gaXMgPCAzLjAKICAgICAgICAgICAgICAgICAvLyAtIGF1ZGlvIEhBTCB2ZXJzaW9uIGlzID49IDMuMCBidXQgbm8gcm91dGUgaGFzIGJlZW4gZGVjbGFyZWQgYmV0d2VlbiBkZXZpY2VzCi0gICAgICAgICAgICAgICAgLy8gLSBjYWxsZWQgZnJvbSBzdGFydEF1ZGlvU291cmNlIChha2Egc291cmNlRGVzYyAhPSBudWxscHRyKSBhbmQgc291cmNlIGRldmljZSBkb2VzCi0gICAgICAgICAgICAgICAgLy8gICBub3QgaGF2ZSBhIGdhaW4gY29udHJvbGxlcgorICAgICAgICAgICAgICAgIC8vIC0gY2FsbGVkIGZyb20gc3RhcnRBdWRpb1NvdXJjZSAoYWthIHNvdXJjZURlc2MgaXMgbm90IGludGVybmFsKSBhbmQgc291cmNlIGRldmljZQorICAgICAgICAgICAgICAgIC8vICAgZG9lcyBub3QgaGF2ZSBhIGdhaW4gY29udHJvbGxlcgogICAgICAgICAgICAgICAgIGlmICghc3JjRGV2aWNlLT5oYXNTYW1lSHdNb2R1bGVBcyhzaW5rRGV2aWNlKSB8fAogICAgICAgICAgICAgICAgICAgICAgICAgKHNyY0RldmljZS0+Z2V0TW9kdWxlVmVyc2lvbk1ham9yKCkgPCAzKSB8fAogICAgICAgICAgICAgICAgICAgICAgICAgIXNyY0RldmljZS0+Z2V0TW9kdWxlKCktPnN1cHBvcnRzUGF0Y2goc3JjRGV2aWNlLCBzaW5rRGV2aWNlKSB8fAotICAgICAgICAgICAgICAgICAgICAgICAgKHNvdXJjZURlc2MgIT0gbnVsbHB0ciAmJgorICAgICAgICAgICAgICAgICAgICAgICAgKCFzb3VyY2VEZXNjLT5pc0ludGVybmFsKCkgJiYKICAgICAgICAgICAgICAgICAgICAgICAgICBzcmNEZXZpY2UtPmdldEF1ZGlvUG9ydCgpLT5nZXRHYWlucygpLnNpemUoKSA9PSAwKSkgewogICAgICAgICAgICAgICAgICAgICAvLyBzdXBwb3J0IG9ubHkgb25lIHNpbmsgZGV2aWNlIGZvciBub3cgdG8gc2ltcGxpZnkgb3V0cHV0IHNlbGVjdGlvbiBsb2dpYwogICAgICAgICAgICAgICAgICAgICBpZiAocGF0Y2gtPm51bV9zaW5rcyA+IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBJTlZBTElEX09QRVJBVElPTjsKICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICBpZiAoc291cmNlRGVzYyA9PSBudWxscHRyKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBTb3J0ZWRWZWN0b3I8YXVkaW9faW9faGFuZGxlX3Q+IG91dHB1dHMgPQotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXRPdXRwdXRzRm9yRGV2aWNlcyhEZXZpY2VWZWN0b3Ioc2lua0RldmljZSksIG1PdXRwdXRzKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIC8vIGlmIHRoZSBzaW5rIGRldmljZSBpcyByZWFjaGFibGUgdmlhIGFuIG9wZW5lZCBvdXRwdXQgc3RyZWFtLCByZXF1ZXN0IHRvCi0gICAgICAgICAgICAgICAgICAgICAgICAvLyBnbyB2aWEgdGhpcyBvdXRwdXQgc3RyZWFtIGJ5IGFkZGluZyBhIHNlY29uZCBzb3VyY2UgdG8gdGhlIHBhdGNoCi0gICAgICAgICAgICAgICAgICAgICAgICAvLyBkZXNjcmlwdGlvbgotICAgICAgICAgICAgICAgICAgICAgICAgb3V0cHV0ID0gc2VsZWN0T3V0cHV0KG91dHB1dHMpOwotICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG91dHB1dCAhPSBBVURJT19JT19IQU5ETEVfTk9ORSkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dERlc2MgPSBtT3V0cHV0cy52YWx1ZUZvcihvdXRwdXQpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvdXRwdXREZXNjLT5pc0R1cGxpY2F0ZWQoKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBTE9HVigiJXMgb3V0cHV0IGZvciBkZXZpY2UgJXMgaXMgZHVwbGljYXRlZCIsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgc2lua0RldmljZS0+dG9TdHJpbmcoKS5jX3N0cigpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOVkFMSURfT1BFUkFUSU9OOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICBzb3VyY2VEZXNjLT5zZXRVc2VTd0JyaWRnZSgpOwogICAgICAgICAgICAgICAgICAgICBpZiAob3V0cHV0RGVzYyAhPSBudWxscHRyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19wb3J0X2NvbmZpZyBzcmNNaXhQb3J0Q29uZmlnID0ge307Ci0gICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXREZXNjLT50b0F1ZGlvUG9ydENvbmZpZygmc3JjTWl4UG9ydENvbmZpZywgJnBhdGNoLT5zb3VyY2VzWzBdKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dERlc2MtPnRvQXVkaW9Qb3J0Q29uZmlnKCZzcmNNaXhQb3J0Q29uZmlnLCBudWxscHRyKTsKICAgICAgICAgICAgICAgICAgICAgICAgIC8vIGZvciB2b2x1bWUgY29udHJvbCwgd2UgbWF5IG5lZWQgYSB2YWxpZCBzdHJlYW0KLSAgICAgICAgICAgICAgICAgICAgICAgIHNyY01peFBvcnRDb25maWcuZXh0Lm1peC51c2VjYXNlLnN0cmVhbSA9IHNvdXJjZURlc2MgIT0gbnVsbHB0ciA/Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VEZXNjLT5zdHJlYW0oKSA6IEFVRElPX1NUUkVBTV9QQVRDSDsKKyAgICAgICAgICAgICAgICAgICAgICAgIHNyY01peFBvcnRDb25maWcuZXh0Lm1peC51c2VjYXNlLnN0cmVhbSA9ICFzb3VyY2VEZXNjLT5pc0ludGVybmFsKCkgPworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUVuZ2luZS0+Z2V0U3RyZWFtVHlwZUZvckF0dHJpYnV0ZXMoc291cmNlRGVzYy0+YXR0cmlidXRlcygpKSA6CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBVURJT19TVFJFQU1fUEFUQ0g7CiAgICAgICAgICAgICAgICAgICAgICAgICBwYXRjaEJ1aWxkZXIuYWRkU291cmNlKHNyY01peFBvcnRDb25maWcpOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgfQpAQCAtNDEyOCwxMSArNDYxNCw5IEBACiAgICAgcmV0dXJuIE5PX0VSUk9SOwogfQogCi1zdGF0dXNfdCBBdWRpb1BvbGljeU1hbmFnZXI6OnJlbGVhc2VBdWRpb1BhdGNoKGF1ZGlvX3BhdGNoX2hhbmRsZV90IGhhbmRsZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdWlkX3QgdWlkKQorc3RhdHVzX3QgQXVkaW9Qb2xpY3lNYW5hZ2VyOjpyZWxlYXNlQXVkaW9QYXRjaChhdWRpb19wYXRjaF9oYW5kbGVfdCBoYW5kbGUsIHVpZF90IHVpZCkKIHsKLSAgICBBTE9HVigicmVsZWFzZUF1ZGlvUGF0Y2goKSBwYXRjaCAlZCIsIGhhbmRsZSk7Ci0KKyAgICBBTE9HVigiJXMgcGF0Y2ggJWQiLCBfX2Z1bmNfXywgaGFuZGxlKTsKICAgIC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ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVpbnQzMl90IGRlbGF5TXMpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdWludDMyX3QgZGVsYXlNcywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcDxTb3VyY2VDbGllbnREZXNjcmlwdG9yPiYgc291cmNlRGVzYykKIHsKICAgICBBTE9HVigiJXMgcGF0Y2ggJWQiLCBfX2Z1bmNfXywgaGFuZGxlKTsKICAgICBpZiAobUF1ZGlvUGF0Y2hlcy5pbmRleE9mS2V5KGhhbmRsZSkgPCAwKSB7CkBAIC00MTg5LDI2ICs0NjgzLDI5IEBACiAgICAgICAgICAgICByZW1vdmVBdWRpb1BhdGNoKHBhdGNoRGVzYy0+Z2V0SGFuZGxlKCkpOwogICAgICAgICAgICAgbmV4dEF1ZGlvUG9ydEdlbmVyYXRpb24oKTsKICAgICAgICAgICAgIG1wQ2xpZW50SW50ZXJmYWNlLT5vbkF1ZGlvUGF0Y2hMaXN0VXBkYXRlKCk7Ci0gICAgICAgICAgICAvLyBTVyBCcmlkZ2UKKyAgICAgICAgICAgIC8vIFNXIG9yIEhXIEJyaWRnZQorICAgICAgICAgICAgc3A8U3dBdWRpb091dHB1dERlc2NyaXB0b3I+IG91dHB1dERlc2MgPSBudWxscHRyOworICAgICAgICAgICAgYXVkaW9fcGF0Y2hfaGFuZGxlX3QgcGF0Y2hIYW5kbGUgPSBBVURJT19QQVRDSF9IQU5ETEVfTk9ORTsKICAgICAgICAgICAgIGlmIChwYXRjaC0+bnVtX3NvdXJjZXMgPiAxICYmIHBhdGNoLT5zb3VyY2VzWzFdLnR5cGUgPT0gQVVESU9fUE9SVF9UWVBFX01JWCkgewotICAgICAgICAgICAgICAgIHNwPFN3QXVkaW9PdXRwdXREZXNjcmlwdG9yPiBvdXRwdXREZXNjID0KLSAgICAgICAgICAgICAgICAgICAgICAgIG1PdXRwdXRzLmdldE91dHB1dEZyb21JZChwYXRjaC0+c291cmNlc1sxXS5pZCk7Ci0gICAgICAgICAgICAgICAgaWYgKG91dHB1dERlc2MgPT0gTlVMTCkgewotICAgICAgICAgICAgICAgICAgICBBTE9HVygiJXMgb3V0cHV0IG5vdCBmb3VuZCBmb3IgaWQgJWQiLCBfX2Z1bmNfXywgcGF0Y2gtPnNvdXJjZXNbMF0uaWQpOwotICAgICAgICAgICAgICAgICAgICAvLyByZWxlYXNlT3V0cHV0IGhhcyBhbHJlYWR5IGNhbGxlZCBjbG9zZU91cHV0IGluIGNhc2Ugb2YgZGlyZWN0IG91dHB1dAotICAgICAgICAgICAgICAgICAgICByZXR1cm4gTk9fRVJST1I7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIGlmIChwYXRjaERlc2MtPmdldEhhbmRsZSgpICE9IG91dHB1dERlc2MtPmdldFBhdGNoSGFuZGxlKCkpIHsKLSAgICAgICAgICAgICAgICAgICAgLy8gZm9yY2UgU3dPdXRwdXQgcGF0Y2ggcmVtb3ZhbCBhcyBBRiBjb3VudGVyIHBhcnQgcGF0Y2ggaGFzIGFscmVhZHkgZ29uZS4KLSAgICAgICAgICAgICAgICAgICAgQUxPR1YoIiVzIHJlc2V0IHBhdGNoIGhhbmRsZSBvbiBPdXRwdXQgYXMgZGlmZmVyZW50IGZyb20gU1dCcmlkZ2UiLCBfX2Z1bmNfXyk7Ci0gICAgICAgICAgICAgICAgICAgIHJlbW92ZUF1ZGlvUGF0Y2gob3V0cHV0RGVzYy0+Z2V0UGF0Y2hIYW5kbGUoKSk7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIG91dHB1dERlc2MtPnNldFBhdGNoSGFuZGxlKEFVRElPX1BBVENIX0hBTkRMRV9OT05FKTsKKyAgICAgICAgICAgICAgICBvdXRwdXREZXNjID0gbU91dHB1dHMuZ2V0T3V0cHV0RnJvbUlkKHBhdGNoLT5zb3VyY2VzWzFdLmlkKTsKKyAgICAgICAgICAgIH0gZWxzZSBpZiAocGF0Y2gtPm51bV9zb3VyY2VzID09IDEgJiYgc291cmNlRGVzYyAhPSBudWxscHRyKSB7CisgICAgICAgICAgICAgICAgb3V0cHV0RGVzYyA9IHNvdXJjZURlc2MtPnN3T3V0cHV0KCkucHJvbW90ZSgpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgaWYgKG91dHB1dERlc2MgPT0gbnVsbHB0cikgeworICAgICAgICAgICAgICAgIEFMT0dXKCIlcyBubyBvdXRwdXQgZm9yIGlkICVkIiwgX19mdW5jX18sIHBhdGNoLT5zb3VyY2VzWzBdLmlkKTsKKyAgICAgICAgICAgICAgICAvLyByZWxlYXNlT3V0cHV0IGhhcyBhbHJlYWR5IGNhbGxlZCBjbG9zZU91dHB1dCBpbiBjYXNlIG9mIGRpcmVjdCBvdXRwdXQKKyAgICAgICAgICAgICAgICByZXR1cm4gTk9fRVJST1I7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBpZiAoIW91dHB1dERlc2MtPmlzQWN0aXZlKCkgJiYgIXNvdXJjZURlc2MtPnVzZVN3QnJpZGdlKCkpIHsKKyAgICAgICAgICAgICAgICByZXNldE91dHB1dERldmljZShvdXRwdXREZXNjKTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgLy8gUmV1c2UgcGF0Y2ggaGFuZGxlIGlmIHN0aWxsIHZhbGlkIC8gZG8gbm90IGZvcmNlIHJlcm91dGluZyBpZiBzdGlsbCByb3V0ZWQKKyAgICAgICAgICAgICAgICBwYXRjaEhhbmRsZSA9IG91dHB1dERlc2MtPmdldFBhdGNoSGFuZGxlKCk7CiAgICAgICAgICAgICAgICAgc2V0T3V0cHV0RGV2aWNlcyhvdXRwdXREZXNjLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2V0TmV3T3V0cHV0RGV2aWNlcyhvdXRwdXREZXNjLCB0cnVlIC8qZnJvbUNhY2hlKi8pLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ1ZSwgLypmb3JjZSovCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRjaEhhbmRsZSA9PSBBVURJT19QQVRDSF9IQU5ETEVfTk9ORSwgLypmb3JjZSovCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAwLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTlVMTCk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRjaEhhbmRsZSA9PSBBVURJT19QQVRDSF9IQU5ETEVfTk9ORSA/IG51bGxwdHIgOiAmcGF0Y2hIYW5kbGUpOwogICAgICAgICAgICAgfQogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKQEAgLTQ0NTQsNiArNDk1MSwxOCBAQAogICAgIHJldHVybiBzdGF0dXM7CiB9CiAKK3NwPFNvdXJjZUNsaWVudERlc2NyaXB0b3I+IEF1ZGlvUG9saWN5TWFuYWdlcjo6c3RhcnRBdWRpb1NvdXJjZUludGVybmFsKAorICAgICAgICBjb25zdCBzdHJ1Y3QgYXVkaW9fcG9ydF9jb25maWcgKnNvdXJjZSwgY29uc3QgYXVkaW9fYXR0cmlidXRlc190ICphdHRyaWJ1dGVzLCB1aWRfdCB1aWQpCit7CisgICAgQUxPR1YoIiVzIiwgX19GVU5DVElPTl9fKTsKKyAgICBhdWRpb19wb3J0X2hhbmRsZV90IHBvcnRJZCA9IEFVRElPX1BPUlRfSEFORExFX05PTkU7CisKKyAgICBzdGF0dXNfdCBzdGF0dXMgPSBzdGFydEF1ZGlvU291cmNlKHNvdXJjZSwgYXR0cmlidXRlcywgJnBvcnRJZCwgdWlkKTsKKyAgICBBTE9HRV9JRihzdGF0dXMgIT0gT0ssICIlczogZmFpbGVkIHRvIHN0YXJ0IGF1ZGlvIHNvdXJjZSAoJWQpIiw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9fcG9ydF9oYW5kbGVfdCBwb3J0SWQpCkBAIC00Nzg2LDYgKzUyNTIsMzcgQEAKICAgICByZXR1cm4gZmFsc2U7CiB9CiAKK2Jvb2wgQXVkaW9Qb2xpY3lNYW5hZ2VyOjppc1VsdHJhc291bmRTdXBwb3J0ZWQoKQoreworICAgIGJvb2wgaGFzVWx0cmFzb3VuZE91dHB1dCA9IGZhbHNlOworICAgIGJvb2wgaGFzVWx0cmFzb3VuZElucHV0ID0gZmFsc2U7CisgICAgZm9yIChjb25zdCBhdXRvJiBod01vZHVsZSA6IG1Id01vZHVsZXMpIHsKKyAgICAgICAgY29uc3QgT3V0cHV0UHJvZmlsZUNvbGxlY3Rpb24gJm91dHB1dFByb2ZpbGVzID0gaHdNb2R1bGUtPmdldE91dHB1dFByb2ZpbGVzKCk7CisgICAgICAgIGlmICghaGFzVWx0cmFzb3VuZE91dHB1dCkgeworICAgICAgICAgICAgZm9yIChjb25zdCBhdXRvICZvdXRQcm9maWxlIDogb3V0cHV0UHJvZmlsZXMpIHsKKyAgICAgICAgICAgICAgICBpZiAob3V0UHJvZmlsZS0+Z2V0RmxhZ3MoKSAmIEFVRElPX09VVFBVVF9GTEFHX1VMVFJBU09VTkQpIHsKKyAgICAgICAgICAgICAgICAgICAgaGFzVWx0cmFzb3VuZE91dHB1dCA9IHRydWU7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorCisgICAgICAgIGNvbnN0IElucHV0UHJvZmlsZUNvbGxlY3Rpb24gJmlucHV0UHJvZmlsZXMgPSBod01vZHVsZS0+Z2V0SW5wdXRQcm9maWxlcygpOworICAgICAgICBpZiAoIWhhc1VsdHJhc291bmRJbnB1dCkgeworICAgICAgICAgICAgZm9yIChjb25zdCBhdXRvICZpbnB1dFByb2ZpbGUgOiBpbnB1dFByb2ZpbGVzKSB7CisgICAgICAgICAgICAgICAgaWYgKGlucHV0UHJvZmls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2hhbm5lbE1hc2tTcGF0aWFsaXplZChhdWRpb19jaGFubmVsX21hc2tfdCBjaGFubmVscykgewotICAgIHN3aXRjaCAoY2hhbm5lbHMpIHsKLSAgICAgICAgY2FzZSBBVURJT19DSEFOTkVMX09VVF81UE9JTlQxOgotICAgICAgICBjYXNlIEFVRElPX0NIQU5ORUxfT1VUXzVQT0lOVDFQT0lOVDI6Ci0gICAgICAgIGNhc2UgQVVESU9fQ0hBTk5FTF9PVVRfNVBPSU5UMVBPSU5UNDoKLSAgICAgICAgY2FzZSBBVURJT19DSEFOTkVMX09VVF83UE9JTlQxOgotICAgICAgICBjYXNlIEFVRElPX0NIQU5ORUxfT1VUXzdQT0lOVDFQT0lOVDI6Ci0gICAgICAgIGNhc2UgQVVESU9fQ0hBTk5FTF9PVVRfN1BPSU5UMVBPSU5UNDoKLSAgICAgICAgICAgIHJldHVybiB0cnVlOwotICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwotICAgIH0KLX0KLQogYm9vbCBBdWRpb1BvbGljeU1hbmFnZXI6OmNhbkJlU3BhdGlhbGl6ZWRJbnQoY29uc3QgYXVkaW9fYXR0cmlidXRlc190ICphdHRyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhdWRpb19jb25maWdfdCAqY29uZmlnLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBBdWRpb0RldmljZVR5cGVBZGRyVmVjdG9yICZkZXZpY2VzLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIGFsbG93Q3VycmVudE91dHB1dFJlY29uZmlnKSAgY29uc3QKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQXVkaW9EZXZpY2VUeXBlQWRkclZlY3RvciAmZGV2aWNlcykgIGNvbnN0CiB7CiAgICAgLy8gVGhlIGNhbGxlciBjYW4gaGF2ZSB0aGUgYXVka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WxlID09IHByb2ZpbGUpIHsKLSAgICAgICAgICAgIGlmICgoY29uZmlnLT5jaGFubmVsX21hc2sgJiBtU3BhdGlhbGl6ZXJPdXRwdXQtPm1NaXhlckNoYW5uZWxNYXNrKQotICAgICAgICAgICAgICAgICAgICAhPSBjb25maWctPmNoYW5uZWxfbWFzaykgewotICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgfQogICAgIH0KICAgICByZXR1cm4gdHJ1ZTsKIH0KQEAgLTQ5MTUsOCArNTM4Nyw3IEBACiAgICAgICAgICAgICBhdWRpb19jb25maWdfYmFzZV90IGNsaWVudENvbmZpZyA9IGNsaWVudC0+Y29uZmlnKCk7CiAgICAgICAgICAgICBhdWRpb19jb25maWdfdCBjb25maWcgPSBhdWRpb19jb25maWdfaW5pdGlhbGl6ZXIoJmNsaWVudENvbmZpZyk7CiAgICAgICAgICAgICBpZiAoZGVzYyAhPSBtU3BhdGlhbGl6ZXJPdXRwdXQKLSAgICAgICAgICAgICAgICAgICAgJiYgY2FuQmVTcGF0aWFsaXplZEludCgmYXR0ciwgJmNvbmZpZywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXZpY2VzVHlwZUFkZHJlc3MsIGZhbHNlIC8qIGFsbG93Q3VycmVudE91dHB1dFJlY29uZmlnICovKSkgeworICAgICAgICAgICAgICAgICAgICAmJiBjYW5CZVNwYXRpYWxpemVkSW50KCZhdHRyLCAmY29uZmlnLCBkZXZpY2VzVHlwZUFkZHJlc3MpKSB7CiAgICAgICAgICAgICAgICAgc3RyZWFtc1RvSW52YWxpZGF0ZS5pbnNlcnQoY2xpZW50LT5zdHJlYW0oKSk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KQEAgLTQ5MjcsNiArNTM5OCwyOSBAQAogICAgIH0KIH0KIAorCitib29sIEF1ZGlvUG9saWN5TWFuYWdlcjo6aXNPdXRwdXRPbmx5QXZhaWxhYmxlUm91dGVUb1NvbW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GVyQ29uZmlnLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhdWRpb19hdHRyaWJ1dGVzX3QgKmF0dHIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX2lvX2hhbmRsZV90ICpvdXRwdXQpIHsKQEAgLTQ5NDAsODIgKzU0MzQsNjggQEAKICAgICAgICAgY29uZmlnID0gYXVkaW9fY29uZmlnX2luaXRpYWxpemVyKG1peGVyQ29uZmlnKTsKICAgICAgICAgY29uZmlnUHRyID0gJmNvbmZpZzsKICAgICB9Ci0gICAgaWYgKCFjYW5CZVNwYXRpYWxpemVkSW50KAotICAgICAgICAgICAgYXR0ciwgY29uZmlnUHRyLCBkZXZpY2VzVHlwZUFkZHJlc3MpKSB7Ci0gICAgICAgIEFMT0dXKCIlcyBwcm92aWRlZCBhdHRyaWJ1dGVzIG9yIG1peGVyIGNvbmZpZyBjYW5ub3QgYmUgc3BhdGlhbGl6ZWQiLCBfX2Z1bmNfXyk7CisgICAgaWYgKCFjYW5CZVNwYXRpYWxpemVkSW50KGF0dHIsIGNvbmZpZ1B0ciwgZGV2aWNlc1R5cGVBZGRyZXNzKSkgeworICAgICAgICBBTE9HVigiJXMgcHJvdmlkZWQgYXR0cmlidXRlcyBvciBtaXhlciBjb25maWcgY2Fubm90IGJlIHNwYXRpYWxpemVkIiwgX19mdW5jX18pOwogICAgICAgICByZXR1cm4gQkFEX1ZBTFVFOwogICAgIH0KIAogICAgIHNwPElPUHJvZmlsZT4gcHJvZmlsZSA9CiAgICAgICAgICAgICBnZXRTcGF0aWFsaXplck91dHB1dFByb2ZpbGUoY29uZmlnUHRyLCBkZXZpY2VzVHlwZUFkZHJlc3MpOwogICAgIGlmIChwcm9maWxlID09IG51bGxwdHIpIHsKLSAgICAgICAgQUxPR1coIiVzIG5vIHN1aXRhYmxlIG91dHB1dCBwcm9maWxl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IEFVRElPX09VVFBVVF9GTEFHX1RUUykgIT0gMCB8fAorICAgICAgICAgICAgICAgIChvdXRQcm9maWxlLT5nZXRGbGFncygpICYgQVVESU9fT1VUUFVUX0ZMQUdfVUxUUkFTT1VORCkgIT0gMCkgewogICAgICAgICAgICAgICAgIG1UdHNPdXRwdXRBdmFpbGFibGUgPSB0cnVlOwogICAgICAgICAgICAgfQogCkBAIC01MzA2LDYgKzU3ODgsMjEgQEAKICAgICAgICAgICAgIGlucHV0RGVzYy0+Y2xvc2UoKTsKICAgICAgICAgfQogICAgIH0KKworICAgIC8vIENoZWNrIGlmIHNwYXRpYWxpemVyIG91dHB1dHMgY2FuIGJlIGNsb3NlZCB1bnRpbCB1c2VkLgorICAgIC8vIG1PdXRwdXRzIHZlY3RvciBuZXZlciBjb250YWlucyBkdXBsaWNhdGVkIG91dHB1dHMgYXQgdGhpcyBwb2ludC4KKyAgICBzdGQ6OnZlY3RvcjxhdWRpb19pb19oYW5kbGVfdD4gb3V0cHV0c0Nsb3NlZDsKKyAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IG1PdXRwdXRzLnNpemUoKTsgaSsrKSB7CisgICAgICAgIHNwPFN3QXVkaW9PdXRwdXREZXNjcmlwdG9yPiBkZXNjID0gbU91dHB1dHMudmFsdWVBdChpKTsKKyAgICAgICAgaWYgKChkZXNjLT5tRmxhZ3MgJiBBVURJT19PVVRQVVRfRkxBR19TUEFUSUFMSVpFUikgIT0gMAorICAgICAgICAgICAgICAgICYmICFpc091dHB1dE9ubHlBdmFpbGFibGVSb3V0ZVRvU29tZURldmljZShkZXNjKSkgeworICAgICAgICAgICAgb3V0cHV0c0Nsb3NlZC5wdXNoX2JhY2soZGVzYy0+bUlvSGFuZGxlKTsKKyAgICAgICAgICAgIGRlc2MtPmNsb3NlKCk7CisgICAgICAgIH0KKyAgICB9CisgICAgZm9yIChhdXRvIG91dHB1dCA6IG91dHB1dHNDbG9zZWQpIHsKKyAgICAgICAgcmVtb3ZlT3V0cHV0KG91dHB1dCk7CisgICAgfQogfQogCiB2b2lkIEF1ZGlvUG9saWN5TWFuYWdlcjo6YWRkT3V0cHV0KGF1ZGlvX2lvX2hhbmRsZV90IG91dHB1dCwKQEAgLTU1ODUsNyArNjA4Miw3IEBACiAgICAgICAgICAgICB9IC8vIGVuZGlmIGlucHV0ICE9IDAKIAogICAgICAgICAgICAgaWYgKGlucHV0ID09IEFVRElPX0lPX0hBTkRMRV9OT05FKSB7Ci0gICAgICAgICAgICAgICAgQUxPR1coIiVzIGNvdWxkIG5vdCBvcGVuIGlucHV0IGZvciBkZXZpY2UgJXMiLCBfX2Z1bmNfXywgIAorICAgICAgICAgICAgICAgIEFMT0dXKCIlcyBjb3VsZCBub3Qgb3BlbiBpbnB1dCBmb3IgZGV2aWNlICVzIiwgX19mdW5jX18sCiAgICAgICAgICAgICAgICAgICAgICAgIGRldmljZS0+dG9TdHJpbmcoKS5jX3N0cigpKTsKICAgICAgICAgICAgICAgICBwcm9maWxlcy5yZW1vdmVBdChwcm9maWxlX2luZGV4KTsKICAgICAgICAgICAgICAgICBwcm9maWxlX2luZGV4LS07CkBAIC01NzkyLDcgKzYyODksNyBAQAogICAgICAgICBzcDxTb3VyY2VDbGllbnREZXNjcmlwdG9yPiBzb3VyY2VEZXNjID0gbUF1ZGlvU291cmNlcy52YWx1ZUF0KGkpOwogICAgICAgICBpZiAoc291cmNlRGVzYyAhPSBudWxscHRyICYmIGZvbGxvd3NTYW1lUm91dGluZyhhdHRyLCBzb3VyY2VEZXNjLT5hdHRyaWJ1dGVzKCkpCiAgICAgICAgICAgICAgICAgJiYgc291cmNlRGVzYy0+Z2V0UGF0Y2hIYW5kbGUoKSA9PSBBVURJT19QQVRDSF9IQU5ETEVfTk9ORQotICAgICAgICAgICAgICAgICYmICFpc0NhbGxSeEF1ZGlvU291cmNlKHNvdXJjZURlc2MpKSB7CisgICAgICAgICAgICAgICAgJiYgIWlzQ2FsbFJ4QXVkaW9Tb3VyY2Uoc291cmNlRGVzYykgJiYgIXNvdXJjZURlc2MtPmlzSW50ZXJuYWwoKSkgewogICAgICAgICAgICAgY29ubmVjdEF1ZGlvU291cmNlKHNvdXJjZURlc2MpOwogICAgICAgICB9CiAgICAgfQpAQCAtNTkwNSw3ICs2NDAyLDcgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3RGV2aWNlcy50eXBlcygpKTsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIHNwPFNvdXJjZUNsaWVudERlc2NyaXB0b3I+IHNvdXJjZSA9IGdldFNvdXJjZUZvckF0dHJpYnV0ZXNPbk91dHB1dChzcmNPdXQsIGF0dHIpOwotICAgICAgICAgICAgaWYgKHNvdXJjZSAhPSBudWxscHRyICYmICFpc0NhbGxSeEF1ZGlvU291cmNlKHNvdXJjZSkpIHsKKyAgICAgICAgICAgIGlmIChzb3VyY2UgIT0gbnVsbHB0ciAmJiAhaXNDYWxsUnhBdWRpb1NvdXJjZShzb3VyY2UpICYmICFzb3VyY2UtPmlzSW50ZXJuYWwoKSkgewogICAgICAgICAgICAgICAgIGNvbm5lY3RBdWRpb1NvdXJjZShzb3VyY2UpOwogICAgICAgICAgICAgfQogICAgICAgICB9CkBAIC01OTE5LDYgKzY0MTYsMTIgQEAKICAgICAgICAgICAgIGZvciAoYXV0byBzdHJlYW0gOiAgbUVuZ2luZS0+Z2V0U3RyZWFtVHlwZXNGb3JQcm9kdWN0U3RyYXRlZ3kocHNJZCkpIHsKICAgICAgICAgICAgICAgICBtcENsaWVudEludGVyZmFjZS0+aW52YWxpZGF0ZVN0cmVhbShzdHJlYW0pOwogICAgICAgICAgICAgfQorICAgICAgICAgICAgZm9yIChhdWRpb19pb19oYW5kbGVfdCBzcmNPdXQgOiBzcmNPdXRwdXRzKSB7CisgICAgICAgICAgICAgICAgc3A8U3dBdWRpb091dHB1dERlc2NyaXB0b3I+IGRlc2MgPSBtUHJldmlvdXNPdXRwdXRzLnZhbHVlRm9yKHNyY091dCk7CisgICAg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WNrcyBzaG91bGQgYmUgaW52YWxpZGF0ZWQgdG8gZ2V0IGNvcnJlY3QKKyAgICAgICAgICAgICAgICAgICAgLy8gYmVoYXZpb3Igd2hlbiB0aGUgc2Vjb25kYXJ5IG91dHB1dCBpcyBjaGFuZ2VkLgorICAgICAgICAgICAgICAgICAgICBzdHJlYW1zVG9JbnZhbGlkYXRlLmluc2VydChjbGllbnQtPnN0cmVhbSgpKTsKKyAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICBzdGQ6OnZlY3Rvcjx3cDxTd0F1ZGlvT3V0cHV0RGVzY3JpcHRvcj4+IHdlYWtTZWNvbmRhcnlEZXNjczsKKyAgICAgICAgICAgICAgICAgICAgc3RkOjp2ZWN0b3I8YXVkaW9faW9faGFuZGxlX3Q+IHNlY29uZGFyeU91dHB1dElkczsKKyAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBhdXRvICZzZWNvbmRhcnlEZXNjOiBzZWNvbmRhcnlEZXNjcykgeworICAgICAgICAgICAgICAgICAgICAgICAgc2Vjb25kYXJ5T3V0cHV0SWRzLnB1c2hfYmFjayhzZWNvbmRhcnlEZXNjLT5tSW9IYW5kbGUpOworICAgICAgICAgICAgICAgICAgICAgICAgd2Vha1NlY29uZGFyeURlc2NzLnB1c2hfYmFjayhzZWNvbmRhcnlEZXNjKTsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICB0cmFja1NlY29uZGFyeU91dHB1dHMuZW1wbGFjZShjbGllbnQtPnBvcnRJZCgpLCBzZWNvbmRhcnlPdXRwdXRJZHMpOworICAgICAgICAgICAgICAgICAgICBjbGllbnQtPnNldFNlY29uZGFyeU91dHB1dHMoc3RkOjptb3ZlKHdlYWtTZWNvbmRhcnlEZXNjcykpOwogICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICB0cmFja1NlY29uZGFyeU91dHB1dHMuZW1wbGFjZShjbGllbnQtPnBvcnRJZCgpLC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FzcGVha2VyU2FmZURldmljZXMuaXNFbXB0eSgpKSB7CisgICAgICAgICAgICBjdXJEZXZpY2VzLm1lcmdlKAorICAgICAgICAgICAgICAgICAgICBtQXZhaWxhYmxlT3V0cHV0RGV2aWNlcy5nZXREZXZpY2VzRnJvbVR5cGUoQVVESU9fREVWSUNFX09VVF9TUEVBS0VSKSk7CisgICAgICAgICAgICBjdXJEZXZpY2VzLnJlbW92ZShzcGVha2VyU2FmZURldmljZXMpOworICAgICAgICB9CisgICAgfQogICAgIGZvciAoY29uc3QgYXV0byYgZGV2aWNlIDogY3VyRGV2aWNlcykgewogICAgICAgICBkZXZpY2VzLT5wdXNoX2JhY2soZGV2aWNlLT5nZXREZXZpY2VUeXBlQWRkcigpKTsKICAgICB9CkBAIC02Mjc0LDcgKzY4MDEsMTEgQEAKICAgICAgICAgLy8gbXV0ZS91bm11dGUgQVVESU9fU1RSRUFNX1RUUyBvbiBhbGwgb3V0cHV0cwogICAgICAgICBBTE9HVigiXHQgbXV0aW5nICVkIiwgbXV0ZSk7CiAgICAgICAgIHVpbnQzMl90IG1heExhdGVuY3kgPSAwOwotICAgICAgICBhdXRvIHR0c1ZvbHVtZVNvdXJjZSA9IHRvVm9sdW1lU291cmNlKEFVRElPX1NUUkVBTV9UVFMpOworICAgICAgICBhdXRvIHR0c1ZvbHVtZVNvdXJjZSA9IHRvVm9sdW1lU291cmNlKEFVRElPX1NUUkVBTV9UVFMsIGZhbHNlKTsKKyAgICAgICAgaWYgKHR0c1ZvbHVtZVNvdXJjZSA9PSBWT0xVTUVfU09VUkNFX05PTkUpIHsKKyAgICAgICAgICAgIEFMT0dWKCJcdCBubyB0dHMgdm9sdW1lIHNvdXJjZSBhdmFpbGFibGUiKTsKKyAgICAgICAgICAgIHJldHVybiAwOworICAgICAgICB9CiAgICAgICAgIGZvciAoc2l6ZV90IGkgPSAwOyBpIDwgbU91dHB1dHMuc2l6ZSgpOyBpKyspIHsKICAgICAgICAgICAgIHNwPFN3QXVkaW9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cyBjb25zZXJ2YXRpdmVseSBzZXQgdG8gNCB0aW1lcyB0aGUgcmVwb3J0ZWQgbGF0ZW5jeS4KKyAgICAgICAgdWludDMyX3QgdGVtcFJlY29tbWVuZGVkTXV0ZUR1cmF0aW9uID0gb3V0cHV0RGVzYy0+Z2V0UmVjb21tZW5kZWRNdXRlRHVyYXRpb25NcygpOworICAgICAgICB1aW50MzJfdCB0ZW1wTXV0ZUR1cmF0aW9uTXMgPSB0ZW1wUmVjb21tZW5kZWRNdXRlRHVyYXRpb24gPiAwID8KKyAgICAgICAgICAgICAgICB0ZW1wUmVjb21tZW5kZWRNdXRlRHVyYXRpb24gOiBvdXRwdXREZXNjLT5sYXRlbmN5KCkgKiA0OworCiAgICAgICAgIGZvciAoY29uc3QgYXV0byAmYWN0aXZlVnMgOiBvdXRwdXREZXNjLT5nZXRBY3RpdmVWb2x1bWVTb3VyY2VzKCkpIHsKICAgICAgICAgICAgIC8vIG1ha2Ugc3VyZSB0aGF0IHdlIGRvIG5vdCBzdGFydCB0aGUgdGVtcG9yYXJ5IG11dGUgcGVyaW9kIHRvbyBlYXJseSBpbiBjYXNlIG9mCiAgICAgICAgICAgICAvLyBkZWxheWVkIGRldmljZSBjaGFuZ2UKQEAgLTYzODQsNyArNjkyMiw3IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBmb3JjZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgZGVsYXlNcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19wYXRjaF9oYW5kbGVfdCAqcGF0Y2hIYW5kbGUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCByZXF1aXJlc011dGVDaGVjaykKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIHJlcXVpcmVzTXV0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sdW1lICsgc29tZSBsb3cgaGVhZHJvb20KICAgICBpZiAoKHZvbHVtZVNvdXJjZSAhPSBjYWxsVm9sdW1lU3JjICYmIChpc0luQ2FsbCgpIHx8CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbU91dHB1dHMuaXNBY3RpdmVMb2NhbGx5KGNhbGxWb2x1bWVTcmMpKSkgJiYKLSAgICAgICAgICAgICh2b2x1bWVTb3VyY2UgPT0gdG9Wb2x1bWVTb3VyY2UoQVVESU9fU1RSRUFNX1NZU1RFTSkgfHwKKyAgICAgICAgICAgICh2b2x1bWVTb3VyY2UgPT0gdG9Wb2x1bWVTb3VyY2UoQVVESU9fU1RSRUFNX1NZU1RFTSwgZmFsc2UpIHx8CiAgICAgICAgICAgICAgdm9sdW1lU291cmNlID09IHJpbmdWb2x1bWVTcmMgfHwgdm9sdW1lU291cmNlID09IG11c2ljVm9sdW1lU3JjIHx8CiAgICAgICAgICAgICAgdm9sdW1lU291cmNlID09IGFsYXJtVm9sdW1lU3JjIHx8Ci0gICAgICAgICAgICAgdm9sdW1lU291cmNlID09IHRvVm9sdW1lU291cmNlKEFVRElPX1NUUkVBTV9OT1RJRklDQVRJT04pIHx8Ci0gICAgICAgICAgICAgdm9sdW1lU291cmNlID09IHRvVm9sdW1lU291cmNlKEFVRElPX1NUUkVBTV9FTkZPUkNFRF9BVURJQkxFKSB8fAotICAgICAgICAgICAgIHZvbHVtZVNvdXJjZSA9PSB0b1ZvbHVtZVNvdXJjZShBVURJT19TVFJFQU1fRFRNRikgfHwKKyAgICAgICAgICAgICB2b2x1bWVTb3VyY2UgPT0gdG9Wb2x1bWVTb3VyY2UoQVVESU9fU1RSRUFNX05PVElGSUNBVElPTiwgZmFsc2UpIHx8CisgICAgICAgICAgICAgdm9sdW1lU291cmNlID09IHRvVm9sdW1lU291cmNlKEFVRElPX1NUUkVBTV9FTkZPUkNFRF9BVURJQkxFLCBmYWxzZSkgfHwKKyAgICAgICAgICAg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ICAgaWYgKChzb3VyY2UgIT0gVk9MVU1FX1NPVVJDRV9OT05FKSAmJgorICAgICAgICAgICAgICAgIChzdGQ6OmZpbmQoYmVnaW4oc291cmNlc1RvTXV0ZSksIGVuZChzb3VyY2VzVG9NdXRlKSwgc291cmNlKQorICAgICAgICAgICAgICAgICAgICAgICAgPT0gZW5kKHNvdXJjZXNUb011dGUpKSkgewogICAgICAgICAgICAgc291cmNlc1RvTXV0ZS5wdXNoX2JhY2soc291cmNlKTsKICAgICAgICAgfQogICAgIH0KQEAgLTY4NDksNyArNzQwNSw3IEBACiAgICAgaWYgKG9uKSB7CiAgICAgICAgIGlmICghb3V0cHV0RGVzYy0+aXNNdXRlZCh2b2x1bWVTb3VyY2UpKSB7CiAgICAgICAgICAgICBpZiAoY3VydmVzLmNhbkJlTXV0ZWQoKSAmJgotICAgICAgICAgICAgICAgICAgICAodm9sdW1lU291cmNlICE9IHRvVm9sdW1lU291cmNlKEFVRElPX1NUUkVBTV9FTkZPUkNFRF9BVURJQkxFKSB8fAorICAgICAgICAgICAgICAgICAgICAodm9sdW1lU291cmNlICE9IHRvVm9sdW1lU291cmNlKEFVRElPX1NUUkVBTV9FTkZPUkNFRF9BVURJQkxFLCBmYWxzZSkgfHwKICAgICAgICAgICAgICAgICAgICAgIChtRW5naW5lLT5nZXRGb3JjZVVzZShBVURJT19QT0xJQ1lfRk9SQ0VfRk9SX1NZU1RFTSkgPT0KICAgICAgICAgICAgICAgICAgICAgICBBVURJT19QT0xJQ1lfRk9SQ0VfTk9ORSkpKSB7CiAgICAgICAgICAgICAgICAgY2hlY2tBbmRTZXRWb2x1bWUoY3VydmVzLCB2b2x1bWVTb3VyY2UsIDAsIG91dHB1dERlc2MsIGRldmljZVR5cGVzLCBkZWxheU1zKTsKQEAgLTY5MTYsMTMgKzc0NzIsMTEgQEAKICAgICByZXR1cm4gbUVuZ2luZS0+Z2V0Rm9yY2VVc2UodXNhZ2UpOwogfQogCi1ib29sIEF1ZGlvUG9saWN5T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dlck9ic2VydmVyLmg+CiAjaW5jbHVkZSA8QXVkaW9Qb2xpY3lDb25maWcuaD4KICNpbmNsdWRlIDxQb2xpY3lBdWRpb1BvcnQuaD4KQEAgLTk1LDExICs5Niw4IEBACiAgICAgICAgIHZpcnR1YWwgfkF1ZGlvUG9saWN5TWFuYWdlcigpOwogCiAgICAgICAgIC8vIEF1ZGlvUG9saWN5SW50ZXJmYWNlCi0gICAgICAgIHZpcnR1YWwgc3RhdHVzX3Qgc2V0RGV2aWNlQ29ubmVjdGlvblN0YXRlKGF1ZGlvX2RldmljZXNfdCBkZXZpY2UsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fcG9saWN5X2Rldl9zdGF0ZV90IHN0YXRlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoYXIgKmRldmljZV9hZGRyZXNzLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoYXIgKmRldmljZV9uYW1lLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX2Zvcm1hdF90IGVuY29kZWRGb3JtYXQpOworICAgICAgICB2aXJ0dWFsIHN0YXR1c190IHNldERldmljZUNvbm5lY3Rpb25TdGF0ZShhdWRpb19wb2xpY3lfZGV2X3N0YXRlX3Qgc3RhdGUsCisgICAgICAgICAgICAgICAgY29uc3QgYW5kcm9pZDo6bWVkaWE6OmF1ZGlvOjpjb21tb246OkF1ZGlvUG9ydCYgcG9ydCwgYXVkaW9fZm9ybWF0X3QgZW5jb2RlZEZvcm1hdCk7CiAgICAgICAgIHZpcnR1YWwgYXVkaW9fcG9saWN5X2Rldl9zdGF0ZV90IGdldERldmljZUNvbm5lY3Rpb25TdGF0ZShhdWRpb19kZXZpY2VzX3QgZGV2aWNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hhciAqZGV2aWNlX2FkZHJlc3MpOwogICAgICAgICB2aXJ0dWFsIHN0YXR1c190IGhhbmRsZURldmljZUNvbmZpZ0NoYW5nZShhdWRpb19kZXZpY2VzX3QgZGV2aWNlLApAQCAtMTI0LDcgKzEyMiw4IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fcG9ydF9oYW5kbGVfdCAqc2VsZWN0ZWREZXZpY2VJZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19wb3J0X2hhbmRsZV90ICpwb3J0SWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RkOjp2ZWN0b3I8YXVkaW9faW9faGFuZGxlX3Q+ICpzZWNvbmRhcnlPdXRwdXRzLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dF90eXBlX3QgKm91dHB1dFR5cGUpIG92ZXJyaWRlOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG91dHB1dF90eXBlX3QgKm91dHB1dFR5cGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCAqaXNTcGF0aWFsaXplZCkgb3ZlcnJpZGU7CiAgICAgICAgIHZpcnR1YWwgc3RhdHVzX3Qgc3RhcnRPdXRwdXQoYXVkaW9fcG9ydF9oYW5kbGVfdCBwb3J0SWQpOwogICAgICAgICB2aXJ0dWFsIHN0YXR1c190IHN0b3BPdXRwdXQoYXVkaW9fcG9ydF9oYW5kbGVfdCBwb3J0SWQpOwogICAgICAgICB2aXJ0dWFsIGJvb2wgcmVsZWFzZU91dHB1dChhdWRpb19wb3J0X2hhbmRsZV90IHBvcnRJZCk7CkBAIC0xOTIsMTIgKzE5MSwzNyBAQAogICAgICAgICAgICAgc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ljIHBvbGljeSBhcmUgbm90IGluY2x1ZGVkLgorICAgICAgICAgKgorICAgICAgICAgKiBJZiBubyBzdWNoIGR5bmFtaWMgcG9saWN5IHRoZW4KKyAgICAgICAgICogMikgRGV2aWNlcyBjb250YWluaW5nIGFuIGFjdGl2ZSBjbGllbnQgdXNpbmcgc2V0UHJlZmVycmVkRGV2aWNlCisgICAgICAgICAqICAgIHdpdGggc2FtZSBzdHJhdGVneSBhcyB0aGUgYXR0cmlidXRlcy4KKyAgICAgICAgICogICAgKGZyb20gdGhlIGRlZmF1bHQgRW5naW5lOjpnZXRPdXRwdXREZXZpY2VzRm9yQXR0cmlidXRlcygpIGltcGxlbWVudGF0aW9uKS4KKyAgICAgICAgICoKKyAgICAgICAgICogSWYgbm8gY29ycmVzcG9uZGluZyBhY3RpdmUgY2xpZW50IHdpdGggc2V0UHJlZmVycmVkRGV2aWNlIHRoZW4KKyAgICAgICAgICogMykgRGV2aWNlcyBhc3NvY2lhdGVkIHdpdGggdGhlIHN0cmF0ZWd5IGRldGVybWluZWQgYnkgdGhlIGF0dHJpYnV0ZXMKKyAgICAgICAgICogICAgKGZyb20gdGhlIGRlZmF1bHQgRW5naW5lOjpnZXRPdXRwdXREZXZpY2VzRm9yQXR0cmlidXRlcygpIGltcGxlbWVudGF0aW9uKS4KKyAgICAgICAgICoKKyAgICAgICAgICogQHBhcmFtIGF0dHJpYnV0ZXMgdG8gYmUgY29uc2lkZXJlZAorICAgICAgICAgKiBAcGFyYW0gZGV2aWNlcyAgICBhbiBBdWRpb0RldmljZVR5cGVBZGRyVmVjdG9yIGNvbnRhaW5lciBwYXNzZWQgaW4gdGhhdAorICAgICAgICAgKiAgICAgICAgICAgICAgICAgICB3aWxsIGJlIGZpbGxlZCBvbiBzdWNjZXNzLgorICAgICAgICAgKiBAcGFyYW0gZm9yVm9sdW1lICB0cnVlIGlmIHRoZSBkZXZpY2VzIGFyZSB0byBiZSBhc3NvY2lhdGVkIHdpdGggY3VycmVudCBkZXZpY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kaW9PdXRwdXREZXNjcmlwdG9yPiYgb3V0cHV0RGVzYywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBEZXZpY2VWZWN0b3IgJmRldmljZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIGZvcmNlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IGRlbGF5TXMgPSAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX3BhdGNoX2hhbmRsZV90ICpwYXRjaEhhbmRsZSA9IE5VTEwsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCByZXF1aXJlc011dGVDaGVjayA9IHRydWUpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgcmVxdWlyZXNNdXRlQ2hlY2sgPSB0cnVlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgcmVxdWlyZXNWb2x1bWVDaGVjayA9IGZhbHNlKTsKICAgICAgICAgc3RhdHVzX3QgcmVzZXRPdXRwdXREZXZpY2UoY29uc3Qgc3A8QXVkaW9PdXRwdXREZXNjcmlwdG9yPiYgb3V0cHV0RGVzYywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IGRlbGF5TXMgPSAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19wYXRjaF9oYW5kbGVfdCAqcGF0Y2hIYW5kbGUgPSBOVUxMKTsKQEAgLTUzOSw5ICs1OTgsOSBAQAogICAgICAgICBhdWRpb19tb2RlX3QgZ2V0UGhvbmVTdGF0ZSgpOwogCiAgICAgICAgIC8vIHRydWUgaWYgZGV2aWNlIGlzIGluIGEgdGVsZXBob255IG9yIFZvSVAgY2FsbAotICAgICAgICB2aXJ0dWFsIGJvb2wgaXNJbkNhbGwoKTsKKyAgICAgICAgdmlydHVhbCBib29sIGlzSW5DYWx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dFRlbGVwaG9ueVJ4QXVkaW9Tb3VyY2UoKTsKKyAgICAgICAgdm9pZCBkaXNjb25uZWN0VGVsZXBob255QXVkaW9Tb3VyY2Uoc3A8U291cmNlQ2xpZW50RGVzY3JpcHRvcj4gJmNsaWVudERlc2MpOworCisgICAgICAgIHZvaWQgY29ubmVjdFRlbGVwaG9ueVR4QXVkaW9Tb3VyY2UoY29uc3Qgc3A8RGV2aWNlRGVzY3JpcHRvcj4gJnNyY2RldmljZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcDxEZXZpY2VEZXNjcmlwdG9yPiAmc2lua0RldmljZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aW50MzJfdCBkZWxheU1zKTsKKworICAgICAgICBib29sIGlzVGVsZXBob255UnhPclR4KGNvbnN0IHNwPFN3QXVkaW9PdXRwdXREZXNjcmlwdG9yPiYgZGVzYykgY29uc3QgeworICAgICAgICAgICAgcmV0dXJuIChtQ2FsbFJ4U291cmNlQ2xpZW50ICE9IG51bGxwdHIgJiYgbUNhbGxSeFNvdXJjZUNsaWVudC0+YmVsb25nc1RvT3V0cHV0KGRlc2MpKQorICAgICAgICAgICAgICAgICAgICB8fCAobUNhbGxUeFNvdXJjZUNsaWVudCAhPSBudWxscHRyCisgICAgICAgICAgICAgICAgICAgICYmICBtQ2FsbFR4U291cmNlQ2xpZW50LT5iZWxvbmdzVG9PdXRwdXQoZGVzYykpOworICAgICAgICB9CiAKICAgICAgICAgLyoqCiAgICAgICAgICAqIEBicmllZiB1cGRhdGVzIHJvdXRpbmcgZm9yIGFsbCBpbnB1dHMuCkBAIC03MDEsNiArNzY5LDE1IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19jaGFubmVsX21hc2tfdCBjaGFubmVsTWFzaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX291dHB1dF9mbGFnc190IGZsYWdzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBkaXJlY3RPbmx5KTsKKyAgICAgICAgLyoqCisgICAgICAgICogU2FtZSBhcyBnZXRQcm9maWxlRm9yT3V0cHV0LCBidXQgaXQgbG9va3MgZm9yIGFuIE1TRCBwcm9maWxlCisgICAgICAgICovCisgICAgICAgIHNwPElPUHJvZmlsZT4gZ2V0TXNkUHJvZmlsZUZvck91dHB1dChjb25zdCBEZXZpY2VWZWN0b3IgJmRldmljZXMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdWludDMyX3Qgc2FtcGxpbmdSYXRlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX2Zvcm1hdF90IGZvcm1hdCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19jaGFubmVsX21hc2tfdCBjaGFubmVsTWFzaywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19vdXRwdXRfZmxhZ3NfdCBmbGFncywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIGRpcmVjdE9ubHkpOwogCiAgICAgICAgIGF1ZGlvX2lvX2hhbmRsZV90IHNlbGVjdE91dHB1dEZvck11c2ljRWZmZWN0cygpOwogCkBAIC03OTAsNiArODY3LDEyIEBACiAgICAgICAgIHN0YXR1c190IGNvbm5lY3RBdWRpb1NvdXJjZShjb25zdCBzcDxTb3VyY2VDbGllbnREZXNjcmlwdG9yPiYgc291cmNlRGVzYyk7CiAgICAgICAgIHN0YXR1c190IGRpc2Nvbm5lY3RBdWRpb1NvdXJjZShjb25zdCBzcDxTb3VyY2VDbGllbnREZXNjcmlwdG9yPiYgc291cmNlRGVzYyk7CiAKKyAgICAgICAgc3RhdHVzX3QgY29ubmVjdEF1ZGlvU291cmNlVG9TaW5rKGNvbnN0IHNwPFNvdXJjZUNsaWVudERlc2NyaXB0b3I+JiBzb3VyY2VEZXNjLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3A8RGV2aWNlRGVzY3JpcHRvcj4gJnNpbmtEZXZpY2UsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdHJ1Y3QgYXVkaW9fcGF0Y2ggKnBhdGNoLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fcGF0Y2hfaGFuZGxlX3QgJmhhbmRsZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVpZF90IHVpZCwgdWludDMyX3QgZGVsYXlNcyk7CisKICAgICAgICAgc3A8U291cmNlQ2xpZW50RGVzY3JpcHRvcj4gZ2V0U291cmNlRm9yQXR0cmlidXRlc09uT3V0cHV0KGF1ZGlvX2lvX2hhbmRsZV90IG91dHB1dCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGF1ZGlvX2F0dHJpYnV0ZXNfdCAmYXR0cik7CiAgICAgICAgIHZvaWQgY2xlYXJBdWRpb1NvdXJjZXNGb3JPdXRwdXQoYXVkaW9faW9faGFuZGxlX3Qgb3V0cHV0KTsKQEAgLTgwNCw2ICs4ODcsMjEgQEAKICAgICAgICAgdm9pZCBjbG9zZUFjdGl2ZUNsaWVudHMoY29uc3Qgc3A8QXVkaW9JbnB1dERlc2NyaXB0b3I+JiBpbnB1dCk7CiAgICAgICAgIHZvaWQgY2xvc2VDbGllbnQoYXVkaW9fcG9ydF9oYW5kbGVfdCBwb3J0SWQpOwogCisgICAgICAgIC8qKgorICAgICAgICAgKiBAYnJpZWYgaXNBbnlEZXZpY2VUeXBlQWN0aXZlOiByZXR1cm5zIHRydWUgaWYgY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WRkclZlY3RvciYgZGV2aWNlcyk7CisKKyAgICAgICAgLy8gT3ZlcmxvYWQgb2Ygc2V0RGV2aWNlQ29ubmVjdGlvblN0YXRlKCkKKyAgICAgICAgc3RhdHVzX3Qgc2V0RGV2aWNlQ29ubmVjdGlvblN0YXRlKGF1ZGlvX2RldmljZXNfdCBkZXZpY2VUeXBlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fcG9saWN5X2Rldl9zdGF0ZV90IHN0YXRlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hhciogZGV2aWNlX2FkZHJlc3MsIGNvbnN0IGNoYXIqIGRldmljZV9uYW1lLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fZm9ybWF0X3QgZW5jb2RlZEZvcm1hdCk7CisKKyAgICAgICAgLy8gQ2FsbGVkIGJ5IHNldERldmljZUNvbm5lY3Rpb25TdGF0ZSgpCisgICAgICAgIHN0YXR1c190IGRldmljZVRvQXVkaW9Qb3J0KGF1ZGlvX2RldmljZXNfdCBkZXZpY2VUeXBlLCBjb25zdCBjaGFyKiBkZXZpY2VfYWRkcmVzcywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hhciogZGV2aWNlX25hbWUsIG1lZGlhOjpBdWRpb1BvcnQqIGFpZFBvcnQpOworICAgICAgICBib29sIGlzTXNkUGF0Y2goY29uc3QgYXVkaW9fcGF0Y2hfaGFuZGxlX3QgJmhhbmRsZSkgY29uc3Q7CisKIHByaXZhdGU6CisgICAgICAgIHNwPFNvdXJjZUNsaWVudERlc2NyaXB0b3I+IHN0YXJ0QXVkaW9Tb3VyY2VJbnRlcm5hbCgKKyAgICAgICAgICAgICAgICBjb25zdCBzdHJ1Y3QgYXVkaW9fcG9ydF9jb25maWcgKnNvdXJjZSwgY29uc3QgYXVkaW9fYXR0cmlidXRlc190ICphdHRyaWJ1dGVzLAorICAgICAgICAgICAgICAgIHVpZF90IHVpZCk7CisKICAgICAgICAgdm9pZCBvbk5ld0F1ZGlvTW9kdWxlc0F2YWlsYWJsZUludChEZXZpY2VWZWN0b3IgKm5ld0RldmljZXMpOwogCiAgICAgICAgIC8vIEFkZCBvciByZW1vdmUgQUMzIERUUyBlbmNvZGluZ3MgYmFzZWQgb24gdXNlciBwcmVmZXJlbmNlcy4KQEAgLTk0Miw3ICsxMDU3LDggQEAKICAgICAgICAgICAgICAgICBhdWRpb19wb3J0X2hhbmRsZV90ICpzZWxlY3RlZERldmljZUlkLAogICAgICAgICAgICAgICAgIGJvb2wgKmlzUmVxdWVzdGVkRGV2aWNlRm9yRXhjbHVzaXZlVXNlLAogICAgICAgICAgICAgICAgIHN0ZDo6dmVjdG9yPHNwPEF1ZGlvUG9saWN5TWl4Pj4gKnNlY29uZGFyeU1peGVzLAotICAgICAgICAgICAgICAgIG91dHB1dF90eXBlX3QgKm91dHB1dFR5cGUpOworICAgICAgICAgICAgICAgIG91dHB1dF90eXBlX3QgKm91dHB1dFR5cGUsCisgICAgICAgICAgICAgICAgYm9vbCAqaXNTcGF0aWFsaXplZCk7CiAgICAgICAgIC8vIGludGVybmFsIG1ldGhvZCB0byByZXR1cm4gdGhlIG91dHB1dCBoYW5kbGUgZm9yIHRoZSBnaXZlbiBkZXZpY2UgYW5kIGZvcm1hdAogICAgICAgICBhdWRpb19pb19oYW5kbGVfdCBnZXRPdXRwdXRGb3JEZXZpY2VzKAogICAgICAgICAgICAgICAgIGNvbnN0IERldmljZVZlY3RvciAmZGV2aWNlcywKQEAgLTk1MCw2ICsxMDY2LDcgQEAKICAgICAgICAgICAgICAgICBjb25zdCBhdWRpb19hdHRyaWJ1dGVzX3QgKmF0dHIsCiAgICAgICAgICAgICAgICAgY29uc3QgYXVkaW9fY29uZmlnX3QgKmNvbmZpZywKICAgICAgICAgICAgICAgICBhdWRpb19vdXRwdXRfZmxhZ3NfdCAqZmxhZ3M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b3IgdGhpcyBjb250ZXh0LCBmYWxzZSBvdGhlcndpc2UuCiAgICAgICAgICAqLwogICAgICAgICB2aXJ0dWFsIGJvb2wgY2FuQmVTcGF0aWFsaXplZEludChjb25zdCBhdWRpb19hdHRyaWJ1dGVzX3QgKmF0dHIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGF1ZGlvX2NvbmZpZ190ICpjb25maWcsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IEF1ZGlvRGV2aWNlVHlwZUFkZHJWZWN0b3IgJmRldmljZXMsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgYWxsb3dDdXJyZW50T3V0cHV0UmVjb25maWcgPSB0cnVlKSBjb25zdDsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQXVkaW9EZXZpY2VUeXBlQWRkclZlY3RvciAmZGV2aWNlcykgY29uc3Q7CiAKICAgICAgICAgc3A8SU9Qcm9maWxlPiBnZXRTcGF0aWFsaXplck91dHB1dFByb2ZpbGUoY29uc3QgYXVkaW9fY29uZmlnX3QgKmNvbmZpZywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQXVkaW9EZXZpY2VUeXBlQWRkclZlY3RvciAmZGV2aWNlcykgY29uc3Q7CiAKLSAgICAgICAgc3RhdGljIGJvb2wgaXNDaGFubmVsTWFza1NwYXRpYWxpemVkKGF1ZGlvX2NoYW5uZWxfbWFza190IGNoYW5uZWxzKTsKLQogICAgICAgICB2b2lkIGNoZWNrVmlydHVhbGl6ZXJDbGllbnRSb3V0ZXMoKTsKIAogICAgICAgICAvKioKKyAgICAgICAgICogQGJyaWVmIFJldHVybnMgdHJ1ZSBpZiBhdCBsZWFzdCBvbmUgZGV2aWNlIGNhbiBvbmx5IGJlIHJlYWNoZWQgdmlhIHRoZSBvdXRwdXQ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gc3RhdHVzX3Qgc2V0RGV2aWNlQ29ubmVjdGlvblN0YXRlSW50KGF1ZGlvX3BvbGljeV9kZXZfc3RhdGVfdCBzdGF0ZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFuZHJvaWQ6Om1lZGlhOjphdWRpbzo6Y29tbW9uOjpBdWRpb1BvcnQmIHBvcnQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19mb3JtYXRfdCBlbmNvZGVkRm9ybWF0KTsKICAgICAgICAgc3RhdHVzX3Qgc2V0RGV2aWNlQ29ubmVjdGlvblN0YXRlSW50KGF1ZGlvX2RldmljZXNfdCBkZXZpY2VUeXBlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fcG9saWN5X2Rldl9zdGF0ZV90IHN0YXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hhciAqZGV2aWNlX2FkZHJlc3MsCkBAIC0xMDQ0LDIxICsxMTY3LDI1IEBACiAgICAgICAgICAqIEBwYXJhbVtvdXRdIGhhbmRsZSBwYXRjaCBoYW5kbGUgdG8gYmUgcHJvdmlkZWQgaWYgcGF0Y2ggaW5zdGFsbGVkIGNvcnJlY3RseQogICAgICAgICAgKiBAcGFyYW1baW5dIHVpZCBvZiB0aGUgY2xpZW50CiAgICAgICAgICAqIEBwYXJhbVtpbl0gZGVsYXlNcyBpZiByZXF1aXJlZAotICAgICAgICAgKiBAcGFyYW1baW5dIHNvdXJjZURlc2MgW29wdGlvbmFsXSBpbiBjYXNlIG9mIGV4dGVybmFsIHNvdXJjZSwgc291cmNlIGNsaWVudCB0byBiZQotICAgICAgICAgKiBjb25maWd1cmVkIGJ5IHRoZSBwYXRjaCwgaS5lLiBhc3NpZ25pbmcgYW4gT3V0cHV0IChIVyBvciBTVykKKyAgICAgICAgICogQHBhcmFtW2luXSBzb3VyY2VEZXNjIHNvdXJjZSBjbGllbnQgdG8gYmUgY29uZmlndXJlZCB3aGVuIGNyZWF0aW5nIHRoZSBwYXRjaCwgaS5lLgorICAgICAgICAgKiAgICAgICAgICAgIGFzc2lnbmluZyBhbiBPdXRwdXQgKEhXIG9yIFNXKSB1c2VkIGZvciB2b2x1bWUgY29udHJvbC4KICAgICAgICAgICogQHJldHVybiBOT19FUlJPUiBpZiBwYXRjaCBpbnN0YWxsZWQgY29ycmVjdGx5LCBlcnJvciBjb2RlIG90aGVyd2lzZS4KICAgICAgICAgICovCiAgICAgICAgIHN0YXR1c190IGNyZWF0ZUF1ZGlvUGF0Y2hJbnRlcm5hbChjb25zdCBzdHJ1Y3QgYXVkaW9fcGF0Y2ggKnBhdGNoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fcGF0Y2hfaGFuZGxlX3QgKmhhbmRsZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVpZF90IHVpZCwgdWludDMyX3QgZGVsYXlNcyA9IDAsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcDxTb3VyY2VDbGllbnREZXNjcmlwdG9yPiYgc291cmNlRGVzYyA9IG51bGxwdHIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdWlkX3QgdWlkLCB1aW50MzJfdCBkZWxheU1zLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3A8U291cmNlQ2xpZW50RGVzY3JpcHRvcj4mIHNvdXJjZURlc2MpOwogICAgICAgICAvKioKICAgICAgICAgICogQGJyaWVmIHJlbGVhc2VBdWRpb1BhdGNoSW50ZXJuYWwgaW50ZXJuYWwgZnVuY3Rpb24gdG8gcmVtb3ZlIGFuIGF1ZGlvIHBhdGNoCiAgICAgICAgICAqIEBwYXJhbVtpbl0gaGFuZGxlIG9mIHRoZSBwYXRjaCB0byBiZSByZW1vdmVkCiAgICAgICAgICAqIEBwYXJhbVtpbl0gZGVsYXlNcyBpZiByZXF1aXJlZAorICAgICAgICAgKiBAcGFyYW1baW5dIHNvdXJjZURlc2MgW29wdGlvbmFsXSBpbiBjYXNlIG9mIGV4dGVybmFsIHNvdXJjZSwgc291cmNlIGNsaWVudCB0byBiZQorICAgICAgICAgKiB1bnJvdXRlZCBmcm9tIHRoZSBwYXRjaCwgaS5lLiBhc3NpZ25pbmcgYW4gT3V0cHV0IChIVyBvciBTVykKICAgICAgICAgICogQHJldHVybiBOT19FUlJPUiBpZiBwYXRjaCByZW1vdmVkIGNvcnJlY3RseSwgZXJyb3IgY29kZSBvdGhlcndpc2UuCiAgICAgICAgICAqLwotICAgICAgICBzdGF0dXNfdCByZWxlYXNlQXVkaW9QYXRjaEludGVybmFsKGF1ZGlvX3BhdGNoX2hhbmRsZV90IGhhbmRsZSwgdWludDMyX3QgZGVsYXlNcyA9IDApOworICAgICAgICBzdGF0dXNfdCByZWxlYXNlQXVkaW9QYXRjaEludGVybmFsKGF1ZGlvX3BhdGNoX2hhbmRsZV90IGhhbmRsZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1aW50MzJfdCBkZWxheU1zID0gMCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcDxTb3VyY2VDbGllbnREZXNjcmlwdG9yPiYgc291cmNlRGVzYyA9IG51bGxwdHIpOwogCiAgICAgICAgIHN0YXR1c190IGluc3RhbGxQYXRjaChjb25zdCBjaGFyICpjYWxsZXIsCiAgICAgICAgICAgICAgICAgYXVkaW9fcGF0Y2hfaGFuZGxlX3QgKnBhdGNoSGFuZGxlLApAQCAtMTA4MCw2ICsxMjA3LDggQEAKIAogICAgICAgICBib29sIGlzU2NvUmVxdWVzdGVkRm9yQ29tbSgpIGNvbnN0OwogCisgICAgICAgIGJvb2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ICAgICAgLy8gaW4gdGhlIGxpc3Qgb2YgcGFzc2VkIEh3TW9kdWxlKHMpLgorICAgICAgICAvLyByZXR1cm5zIGEgY29tcGF0aWJsZSBwcm9maWxlIGlmIGZvdW5kLCBudWxscHRyIG90aGVyd2lzZQorICAgICAgICBzcDxJT1Byb2ZpbGU+IHNlYXJjaENvbXBhdGlibGVQcm9maWxlSHdNb2R1bGVzICgKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgSHdNb2R1bGVDb2xsZWN0aW9uJiBod01vZHVsZXMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IERldmljZVZlY3RvciYgZGV2aWNlcywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdWludDMyX3Qgc2FtcGxpbmdSYXRlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19mb3JtYXRfdCBmb3JtYXQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX2NoYW5uZWxfbWFza190IGNoYW5uZWxNYXNrLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19vdXRwdXRfZmxhZ3NfdCBmbGFncywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBkaXJlY3RPbmx5KTsKKworICAgICAgICAvLyBGaWx0ZXJzIG9ubHkgdGhlIHJlbGV2YW50IGZsYWdzIGZvciBnZXRQcm9maWxlRm9yT3V0cHV0CisgICAgICAgIGF1ZGlvX291dHB1dF9mbGFnc190IGdldFJlbGV2YW50RmxhZ3MgKGF1ZGlvX291dHB1dF9mbGFnc190IGZsYWdzLCBib29sIGRpcmVjdE9ubHkpOwogfTsKIAogfTsKZGlmZiAtLWdpdCBhL3NlcnZpY2VzL2F1ZGlvcG9saWN5L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ICAgICAgICAgIGlmIChhdHRyLnVzYWdlID09IEFVRElPX1VTQUdFX0NBTExfQVNTSVNUQU5UCisgICAgICAgICAgICAgICAgICAgICYmICgoYXR0ci5mbGFncyAmIEFVRElPX0ZMQUdfQ0FMTF9SRURJUkVDVElPTikgIT0gMCkpIHsKKyAgICAgICAgICAgICAgICBpZiAoIWNhbGxBdWRpb0ludGVyY2VwdGlvbkFsbG93ZWQoYXR0cmlidXRpb25Tb3VyY2UpKSB7CisgICAgICAgICAgICAgICAgICAgIEFMT0dFKCIlczogY2FsbCBhdWRpbyBpbnRlcmNlcHRpb24gbm90IGFsbG93ZWQgZm9yIGF0dHJpYnV0aW9uIHNvdXJjZTogJXMiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgX19mdW5jX18sIGF0dHJpYnV0aW9uU291cmNlLnRvU3RyaW5nKCkuY19zdHIoKSk7CisgICAgICAgICAgICAgICAgICAgIHJldHVybiBQRVJNSVNTSU9OX0RFTklFRDsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9IGVsc2UgaWYgKCFtb2RpZnlBdWRpb1JvdXRpbmdBbGxvd2VkKGF0dHJpYnV0aW9uU291cmNlKSkgeworICAgICAgICAgICAgICAgIEFMT0dFKCIlczogbW9kaWZ5IGF1ZGlvIHJvdXRpbmcgbm90IGFsbG93ZWQgZm9yIGF0dHJpYnV0aW9uIHNvdXJjZTogJXMiLAorICAgICAgICAgICAgICAgICAgICAgICAgX19mdW5jX18sIGF0dHJpYnV0aW9uU291cmNlLnRvU3RyaW5nKCkuY19zdHIoKSk7CiAgICAgICAgICAgICAgICAgcmV0dXJuIFBFUk1JU1NJT05fREVOSUVEOwogICAgICAgICAgICAgfQogICAgICAgICB9IGVsc2UgewpAQCAtOTYsMTYgKzExOSwxMyBAQAogfQogCiBTdGF0dXMgQXVkaW9Qb2xpY3lTZXJ2aWNlOjpzZXREZXZpY2VDb25uZWN0aW9uU3RhdGUoCi0gICAgICAgIGNvbnN0IG1lZGlhO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wpKTsKIAogICAgIGlmIChtQXVkaW9Qb2xpY3lNYW5hZ2VyID09IE5VTEwpIHsKICAgICAgICAgcmV0dXJuIGJpbmRlclN0YXR1c0Zyb21TdGF0dXNUKE5PX0lOSVQpOwpAQCAtMTIxLDQyICsxNDEsNDUgQEAKICAgICBBTE9HVigic2V0RGV2aWNlQ29ubmVjdGlvblN0YXRlKCkiKTsKICAgICBNdXRleDo6QXV0b2xvY2sgX2wobUxvY2spOwogICAgIEF1dG9DYWxsZXJDbGVhciBhY2M7Ci0gICAgc3RhdHVzX3Qgc3RhdHVzID0gbUF1ZGlvUG9saWN5TWFuYWdlci0+c2V0RGV2aWNlQ29ubmVjdGlvblN0YXRlKGRldmljZSwgc3RhdGUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGV2aWNlQWlkbC5hZGRyZXNzLmNfc3RyKCksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGV2aWNlTmFtZUFpZGwuY19zdHIoKSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmNvZGVkRm9ybWF0KTsKKyAgICBzdGF0dXNfdCBzdGF0dXMgPSBtQXVkaW9Qb2xpY3lNYW5hZ2VyLT5zZXREZXZpY2VDb25uZWN0aW9uU3RhdGUoCisgICAgICAgICAgICBzdGF0ZSwgcG9ydCwgZW5jb2RlZEZvcm1hdCk7CiAgICAgaWYgKHN0YXR1cyA9PSBOT19FUlJPUikgewogICAgICAgICBvbkNoZWNrU3BhdGlhbGl6ZXJfbCgpOwogICAgIH0KICAgICByZXR1cm4gYmluZGVyU3RhdHVzRnJvbVN0YXR1c1Qoc3RhdHVzKTsKIH0KIAotU3RhdHVzIEF1ZGlvUG9saWN5U2VydmljZTo6Z2V0RGV2aWNlQ29ubmVjdGlvblN0YXRlKGNvbnN0IG1lZGlhOj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N0cmVhbVR5cGUgc3RyZWFtQWlkbCwgaW50MzJfdCogX2FpZGxfcmV0dXJuKQogewogICAgIGF1ZGlvX3N0cmVhbV90eXBlX3Qgc3RyZWFtID0gVkFMVUVfT1JfUkVUVVJOX0JJTkRFUl9TVEFUVVMoCiAgICAgICAgICAgICBhaWRsMmxlZ2FjeV9BdWRpb1N0cmVhbVR5cGVfYXVkaW9fc3RyZWFtX3R5cGVfdChzdHJlYW1BaWRsKSk7CkBAIC0yODksNyArMzIwLDcgQEAKIFN0YXR1cyBBdWRpb1BvbGljeVNlcnZpY2U6OmdldE91dHB1dEZvckF0dHIoY29uc3QgbWVkaWE6OkF1ZGlvQXR0cmlidXRlc0ludGVybmFsJiBhdHRyQWlkbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBzZXNzaW9uQWlkbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQXR0cmlidXRpb25Tb3VyY2VTdGF0ZSYgYXR0cmlidXRpb25Tb3VyY2UsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1lZGlhOjpBdWRpb0NvbmZpZyYgY29uZmlnQWlkbCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQXVkaW9Db25maWcmIGNvbmZpZ0FpZGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3QgZmxhZ3NBaWRsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQzMl90IHNlbGVjdGVkRGV2aWNlSWRBaWRsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZWRpYTo6R2V0T3V0cHV0Rm9yQXR0clJlc3BvbnNlKiBfYWlkbF9yZXR1cm4pCkBAIC0zMDAsNyArMzMxLDc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zdWx0ID0gbUF1ZGlvUG9saWN5TWFuYWdlci0+Z2V0T3V0cHV0Rm9yQXR0cigmYXR0ciwgJm91dHB1dCwgc2Vzc2lvbiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZzdHJlYW0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGpBdHRyaWJ1dGlvblNvdXJjZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZjb25maWcsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmZmxhZ3MsICZzZWxlY3RlZERldmljZUlkLCAmcG9ydElkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJnNlY29uZGFyeU91dHB1dHMsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmb3V0cHV0VHlwZSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmb3V0cHV0VHlwZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZpc1NwYXRpYWxpemVkKTsKIAogICAgIC8vIEZJWE1FOiBJbnRyb2R1Y2UgYSB3YXkgdG8gY2hlY2sgZm9yIHRoZSB0aGUgdGVsZXBob255IGRldmljZSBiZWZvcmUgb3BlbmluZyB0aGUgb3V0cHV0CiAgICAgaWYgKHJlc3VsdCA9PSBOT19FUlJPUikgewpAQCAtMzU4LDcgKzQwMCwxMiBAQAogICAgICAgICBjYXNlIEF1ZGlvUG9saWN5SW50ZXJmYWNlOjpBUElfT1VUUFVUX0xFR0FDWToKICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICBjYXNlIEF1ZGlvUG9saWN5SW50ZXJmYWNlOjpBUElfT1VUUFVUX1RFTEVQSE9OWV9UWDoKLSAgICAgICAgICAgIGlmICghbW9kaWZ5UGhvbmVTdGF0ZUFsbG93ZWQoYWRqQXR0cmlidXRpb25Tb3VyY2UpKSB7CisgICAgICAgICAgICBpZiAoKChhdHRyLmZsYWdzICYgQVVESU9fRkxBR19DQUxMX1JFRElSRUNUSU9OKSAhPSAwKQorICAgICAgICAgICAgICAgICYmICFjYWxsQXVkaW9JbnRlcmNlcHRpb25BbGxvd2VkKGFkakF0dHJpYnV0aW9uU291cmNlKSkgeworICAgICAgICAgICAgICAgIEFMT0dFKCIlcygpIHBlcm1pc3Npb24gZGVuaWVkOiBjYWxsIHJlZGlyZWN0aW9uIG5vdCBhbGxvd2VkIGZvciB1aWQgJWQiLAorICAgICAgICAgICAgICAgICAgICBfX2Z1bmNfXywgYWRqQXR0cmlidXRpb25Tb3VyY2UudWlkKTsKKyAgICAgICAgICAgICAgICByZXN1bHQgPSBQRVJNSVNTSU9OX0RFTklFRDsKKyAgICAgICAgICAgIH0gZWxzZSBpZiAoIW1vZGlmeVBob25lU3RhdGVBbGxvd2VkKGFkakF0dHJpYnV0aW9uU291cmNlKSkgewogICAgICAgICAgICAgICAgIEFMT0dFKCIlcygpIHBlcm1pc3Npb24gZGVuaWVkOiBtb2RpZnkgcGhvbmUgc3RhdGUgbm90IGFsbG93ZWQgZm9yIHVpZCAlZCIsCiAgICAgICAgICAgICAgICAgICAgIF9fZnVuY19fLCBhZGpBdHRyaWJ1dGlvblNvdXJjZS51aWQpOwogICAgICAgICAgICAgICAgIHJlc3VsdCA9IFBFUk1JU1NJT05fREVOSUVEOwpAQCAtMzgxLDcgKzQyOCw3IEBACiAgICAgaWYgKHJlc3VsdCA9PSBOT19FUlJPUikgewogICAgICAgICBzcDxBdWRpb1BsYXliYWNrQ2xpZW50PiBjbGllbnQgPQogICAgICAgICAgICAgICAgIG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IG9uVXBkYXRlQWN0aXZlU3BhdGlhbGl6ZXJUcmFja3NfbCgpOwogICAgIH0KICAgICByZXR1cm4gYmluZGVyU3RhdHVzRnJvbVN0YXR1c1Qoc3RhdHVzKTsKIH0KQEAgLTQ3Nyw2ICs1MjYsNyBAQAogICAgIHN0YXR1c190IHN0YXR1cyA9IG1BdWRpb1BvbGljeU1hbmFnZXItPnN0b3BPdXRwdXQocG9ydElkKTsKICAgICBpZiAoc3RhdHVzID09IE5PX0VSUk9SKSB7CiAgICAgICAgIGNsaWVudC0+YWN0aXZlID0gZmFsc2U7CisgICAgICAgIG9uVXBkYXRlQWN0aXZlU3BhdGlhbGl6ZXJUcmFja3NfbCgpOwogICAgIH0KICAgICByZXR1cm4gc3RhdHVzOwogfQpAQCAtNTA3LDggKzU1NywxMCBAQAogICAgICAgICAgICAgY2xpZW50LT5pbywgY2xpZW50LT5zdHJlYW0sIGNsaWVudC0+c2Vzc2lvbik7CiAgICAgfQogICAgIE11dGV4OjpBdXRvbG9jayBfbChtTG9jayk7CisgICAgaWYgKGNsaWVudCAhPSBudWxscHRyICYmIGNsaWVudC0+YWN0aXZlKSB7CisgICAgICAgIG9uVXBkYXRlQWN0aXZlU3BhdGlhbGl6ZXJUcmFja3NfbCgpOworICAgIH0KICAgICBtQXVkaW9QbGF5YmFja0NsaWVudHMucmVtb3ZlSXRlbShwb3J0SWQpOwotCiAgICAgLy8gY2FsbGVkIGZyb20gaW50ZXJuYWwgdGhyZWFkOiBubyBuZWVkIHRvIGNsZWFyIGNhbGxlciBpZGVudGl0eQogICAgIG1BdWRpb1BvbGljeU1hbmFnZXItPnJlbGVhc2VPdXRwdXQocG9ydElkKTsKIH0KQEAgLTUxOCw3ICs1NzAsNyBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3QgcmlpZEFpZGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBzZXNzaW9uQWlkbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBBdHRyaWJ1dGlvblNvdXJjZVN0YXRlJiBhdHRyaWJ1dGlvblNvdXJjZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtZWRpYTo6QXVkaW9Db25maWdCYXNlJiBjb25maWdBaWRsLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IEF1ZGlvQ29uZmlnQmFzZSYgY29uZmlnQWlkbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQzMl90IGZsYWdzQWlkbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQzMl90IHNlbGVjdGVkRGV2aWNlSWRBaWRsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1lZGlhOjpHZXRJbnB1dEZvckF0dHJSZXNwb25zZSogX2FpZGxfcmV0dXJuKSB7CkBAIC01MzEsNyArNTgzLDcgQEAKICAgICBhdWRpb19zZXNzaW9uX3Qgc2Vzc2lvbiA9IFZBTFVFX09SX1JFVFVSTl9CSU5ERVJfU1RBVFVTKAogICAgICAgICAgICAgYWlkbDJsZWdhY3lfaW50MzJfdF9hdWRpb19zZXNzaW9uX3Qoc2Vzc2lvbkFpZGwpKTsKICAgICBhdWRpb19jb25maWdfYmFzZV90IGNvbmZpZyA9IFZBTFVFX09SX1JFVFVSTl9CSU5ERVJfU1RBVFVTKAotICAgICAgICAgICAgYWlkbDJsZWdhY3lfQXVkaW9Db25maWdCYXNlX2F1ZGlvX2NvbmZpZ19iYXNlX3QoY29uZmlnQWlkbCkpOworICAgICAgICAgICAgYWlkbDJsZWdhY3lfQXVkaW9Db25maWdCYXNlX2F1ZGlvX2NvbmZpZ19iYXNlX3QoY29uZmlnQWlkbCwgdHJ1ZSAvKmlzSW5wd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zcyNCwzMCBAQAogICAgICAgICAgICAgY2FzZSBBdWRpb1BvbGljeUludGVyZmFjZTo6QVBJX0lOUFVUX0xFR0FDWToKICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgQXVkaW9Qb2xpY3lJbnRlcmZhY2U6OkFQSV9JTlBVVF9URUxFUEhPTllfUlg6CisgICAgICAgICAgICAgICAgaWYgKChhdHRyLmZsYWdzICYgQVVESU9fRkxBR19DQUxMX1JFRElSRUNUSU9OKSAhPSAwCisgICAgICAgICAgICAgICAgICAgICAgICAmJiBjYW5JbnRlcmNlcHRDYWxsQXVkaW8pIHsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIC8vIEZJWE1FOiB1c2UgdGhlIHNhbWUgcGVybWlzc2lvbiBhcyBmb3IgcmVtb3RlIHN1Ym1peCBmb3Igbm93LgorICAgICAgICAgICAgICAgIEZBTExUSFJPVUdIX0lOVEVOREVEOwogICAgICAgICAgICAgY2FzZSBBdWRpb1BvbGljeUludGVyZmFjZTo6QVBJX0lOUFVUX01JWF9DQVBUVVJFOgogICAgICAgICAgICAgICAgIGlmICghY2FuQ2FwdHVyZU91dHB1dCkgewotICAgICAgICAgICAgICAgICAgICBBTE9HRSgiZ2V0SW5wdXRGb3JBdHRyKCkgcGVybWlzc2lvbiBkZW5pZWQ6IGNhcHR1cmUgbm90IGFsbG93ZWQiKTsKKyAgICAgICAgICAgICAgICAgICAgQUxPR0UoIiVzIHBlcm1pc3Npb24gZGVuaWVkOiBjYXB0dXJlIG5vdCBhbGxvd2VkIiwgX19mdW5jX18pOwogICAgICAgICAgICAgICAgICAgICBzdGF0dXMgPSBQRVJNSVNTSU9OX0RFTklFRDsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICBjYXNlIEF1ZGlvUG9saWN5SW50ZXJmYWNlOjpBUElfSU5QVVRfTUlYX0VYVF9QT0xJQ1lfUkVST1VURToKLSAgICAgICAgICAgICAgICBpZiAoIW1vZGlmeUF1ZGlvUm91dGluZ0FsbG93ZWQoYWRqQXR0cmlidXRpb25Tb3VyY2UpKSB7Ci0gICAgICAgICAgICAgICAgICAgIEFMT0dFKCJnZXRJbnB1dEZvckF0dHIoKSBwZXJtaXNzaW9uIGRlbmllZDogbW9kaWZ5IGF1ZGlvIHJvdXRpbmcgbm90IGFsbG93ZWQiKTsKKyAgICAgICAgICAgICAgICBpZiAoIShtb2RpZnlBdWRpb1JvdXRpbmdBbGxvd2VkKGFkakF0dHJpYnV0aW9uU291cmNlKQorICAgICAgICAgICAgICAgICAgICAgICAgfHwgKChhdHRyLmZsYWdzICYgQVVESU9fRkxBR19DQUxMX1JFRElSRUNUSU9OKSAhPSAwCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgJiYgY2FuSW50ZXJjZXB0Q2FsbEF1ZGlvKSkpIHsKKyAgICAgICAgICAgICAgICAgICAgQUxPR0UoIiVzIHBlcm1pc3Npb24gZGVuaWVkIGZvciByZW1vdGUgc3VibWl4IGNhcHR1cmUiLCBfX2Z1bmNfXyk7CiAgICAgICAgICAgICAgICAgICAgIHN0YXR1cyA9IFBFUk1JU1NJT05fREVOSUVEOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIGNhc2UgQXVkaW9Qb2xpY3lJbnRlcmZhY2U6OkFQSV9JTlBVVF9JTlZBTElEOgogICAgICAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgICAgICBMT0dfQUxXQVlTX0ZBVEFMKCJnZXRJbnB1dEZvckF0dHIoKSBlbmNvdW50ZXJlZCBhbiBpbnZhbGlkIGlucHV0IHR5cGUgJWQiLAotICAgICAgICAgICAgICAgICAgICAgICAgKGludClpbnB1dFR5cGUpOworICAgICAgICAgICAgICAgIExPR19BTFdBWVNfRkFUQUwoIiVzIGVuY291bnRlcmVkIGFuIGludmFsaWQgaW5wdXQgdHlwZSAlZCIsCisgICAgICAgICAgICAgICAgICAgICAgICBfX2Z1bmNfXywgKGludClpbnB1dFR5cGUpOwogICAgICAgICAgICAgfQogICAgICAgICB9CiAKQEAgLTczOCw4ICs4MTcsMTAgQEAKIAogICAgIC8vIGNoZWNrIGNhbGxpbmcgcGVybWlzc2lvbnMKICAgICBpZiAoIShzdGFydFJlY29yZGluZyhjbGllbnQtPmF0dHJpYnV0aW9uU291cmNlLCBTdHJpbmcxNihtc2cuc3RyKCkuY19zdHIoKSksCi0gICAgICAgIGNsaWVudC0+YXR0cmlidXRlcy5zb3VyY2UpCi0gICAgICAgICAgICB8fCBjbGllbnQtPmF0dHJpYnV0ZXMuc291cmNlID09IEFVRElPX1NPVVJDRV9GTV9UVU5FUikpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICBjbGllbnQtPmF0dHJpYnV0ZXMuc291cmNlKQorICAgICAgICAgICAgfHwgY2xpZW50LT5hdHRyaWJ1dGVzLnNvdXJjZSA9PSBBVURJT19TT1VSQ0VfRk1fVFVORVIKKyAgICAgICAgICAgIHx8IGNsaWVudC0+YXR0cmlidXRlcy5zb3VyY2UgPT0gQVVESU9fU09VUkNFX1JFTU9URV9TVUJNSVgKKyAgICAgICAgICAgIHx8IGNsaWVudC0+YXR0cmlidXRlcy5zb3VyY2UgPT0gQVVESU9fU09VUkNFX0VDSE9fUkVGRVJFTkNFKSkgewogICAgICAgICBBTE9HRSgiJXMgcGVybWlzc2lvbiBkZW5pZWQ6IHJlY29yZGluZyBub3QgYWxsb3dlZCBmb3IgYXR0cmlidXRpb24gc291cmNlICVzIiwKICAgICAgICAgICAgICAgICBfX2Z1bmNfXywgY2xpZW50LT5hdHRyaWJ1dGlvblNvdXJjZS50b1N0cmluZygpLmNfc3RyKCkpOwogICAgICAgICByZXR1cm4gYmluZGVyU3RhdHVzRnJvbVN0YXR1c1QoUEVSTUlTU0lPTl9ERU5JRUQpOwpAQCAtOTA5LDcgKzk5MCw3IEBACiAgICAgcmV0dXJuIFN0YXR1czo6b2soKTsKIH0KIAotU3RhdHVzIEF1ZGlvUG9saWN5U2VydmljZTo6aW5pdFN0cmVhbVZvbHVtZShtZWRpYTo6QXVkaW9TdHJlYW1UeXBlIHN0cmVhbUFpZGwsCitTdGF0dXMgQXVkaW9Qb2xpY3lTZXJ2aWNlOjppbml0U3RyZWFtVm9sdW1lKEF1ZGlvU3RyZWFtVHlwZSBzdHJlYW1BaWRsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQzMl90IGluZGV4TWluQWlkbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBpbmRleE1heEFpZGwpIHsKICAgICBhdWRpb19zdHJlYW1fdHlwZV90IHN0cmVhbSA9IFZBTFVFX09SX1JFVFVSTl9CSU5ERVJfU1RBVFVTKApAQCAtOTMyLDEzICsxMDEzLDE0IEBACiAgICAgcmV0dXJuIGJpbmRlclN0YXR1c0Zyb21TdGF0dXNUKE5PX0VSUk9SKTsKIH0KIAotU3RhdHVzIEF1ZGlvUG9saWN5U2VydmljZTo6c2V0U3RyZWFtVm9sdW1lSW5kZXgobWVkaWE6OkF1ZGlvU3RyZWFtVHlwZSBzdHJlYW1BaWRsLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBkZXZpY2VBaWRsLCBpbnQzMl90IGluZGV4QWlkbCkgeworU3RhdHVzIEF1ZGlvUG9saWN5U2VydmljZTo6c2V0U3RyZWFtVm9sdW1lSW5kZXgoQXVkaW9TdHJlYW1UeXBlIHN0cmVhbUFpZGwsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBBdWRpb0RldmljZURlc2NyaXB0aW9uJiBkZXZpY2VBaWRsLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50M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iBjb3VudEFpZGwsCiAgICAgICAgIHN0ZDo6dmVjdG9yPG1lZGlhOjpFZmZlY3REZXNjcmlwdG9yPiogX2FpZGxfcmV0dXJuKSB7CiAgICAgYXVkaW9fc2Vzc2lvbl90IGF1ZGlvU2Vzc2lvbiA9IFZBTFVFX09SX1JFVFVSTl9CSU5ERVJfU1RBVFVTKAogICAgICAgICAgICAgYWlkbDJsZWdhY3lfaW50MzJfdF9hdWRpb19zZXNzaW9uX3QoYXVkaW9TZXNzaW9uQWlkbCkpOwpAQCAtMTI5OCwxMSArMTM2MywxMSBAQAogICAgIHJldHVybiBTdGF0dXM6Om9rKCk7CiB9CiAKLVN0YXR1cyBBdWRpb1BvbGljeVNlcnZpY2U6OmFkZFNvdXJjZURlZmF1bHRFZmZlY3QoY29uc3QgbWVkaWE6OkF1ZGlvVXVpZCYgdHlwZUFpZGwsCitTdGF0dXMgQXVkaW9Qb2xpY3lTZXJ2aWNlOjphZGRTb3VyY2VEZWZhdWx0RWZmZWN0KGNvbnN0IEF1ZGlvVXVpZCYgdHlwZUFpZGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ZDo6c3RyaW5nJiBvcFBhY2thZ2VOYW1lQWlkbCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWVkaWE6OkF1ZGlvVXVpZCYgdXVpZEFpZGwsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IEF1ZGlvVXVpZCYgdXVpZEFpZGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3QgcHJpb3JpdHksCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1lZGlhOjpBdWRpb1NvdXJjZVR5cGUgc291cmNlQWlkbCwKKyAgICAgICAgIC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ljeVNlcnZpY2U6OmFkZFN0cmVhbURlZmF1bHRFZmZlY3QoY29uc3QgQXVkaW9VdWlkJiB0eXBlQWlkbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjpzdHJpbmcmIG9wUGFja2FnZU5hbWVBaWRsLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtZWRpYTo6QXVkaW9VdWlkJiB1dWlkQWlkbCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBwcmlvcml0eSwgbWVkaWE6OkF1ZGlvVXNhZ2UgdXNhZ2VBaWRsLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBBdWRpb1V1aWQmIHV1aWRBaWRsLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQzMl90IHByaW9yaXR5LCBBdWRpb1VzYWdlIHVzYWdlQWlkbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCogX2FpZGxfcmV0dXJuKSB7CiAgICAgZWZmZWN0X3V1aWRfdCB0eXBlID0gVkFMVUVfT1JfUkVUVVJOX0JJTkRFUl9TVEFUVVMoCiAgICAgICAgICAgICBhaWRsMmxlZ2FjeV9BdWRpb1V1aWRfYXVkaW9fdXVpZF90KHR5cGVBaWRsKSk7CkBAIC0xMzc2LDcgKzE0NDEsNyBAQAogfQogCiBTdGF0dXMgQXVkaW9Qb2xpY3lTZXJ2aWNlOjpzZXRTdXBwb3J0ZWRTeXN0ZW1Vc2FnZXMoCi0gICAgICAgIGNvbnN0IHN0ZDo6dmVjdG9yPG1lZGlhOjpBdWRpb1VzYWdlPiYgc3lzdGVtVXNhZ2VzQWlkbCkgeworICAgICAgICBjb25zdCBz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ICAgYXVkaW9fY29uZmlnX3QgY29uZmlnID0gQVVESU9fQ09ORklHX0lOSVRJQUxJWkVSOwogICAgIGlmIChjb25maWdBaWRsLmhhc192YWx1ZSgpKSB7CiAgICAgICAgIGNvbmZpZyA9IFZBTFVFX09SX1JFVFVSTl9CSU5ERVJfU1RBVFVTKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWlkbDJsZWdhY3lfQXVkaW9Db25maWdfYXVkaW9fY29uZmlnX3QoY29uZmlnQWlkbC52YWx1ZSgpKSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhaWRsMmxlZ2FjeV9BdWRpb0NvbmZpZ19hdWRpb19jb25maWdfdChjb25maWdBaWRsLnZhbHVlKCksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmYWxzZSAvKmlzSW5wdXQqLykpOwogICAgIH0KICAgICBBdWRpb0RldmljZVR5cGVBZGRyVmVjdG9yIGRldmljZXMgPSBWQUxVRV9PUl9SRVRVUk5fQklOREVSX1NUQVRVUygKICAgICAgICAgICAgIGNvbnZlcnRDb250YWluZXI8QXVkaW9EZXZpY2VUeXBlQWRkclZlY3Rvcj4oZGV2aWNlc0FpZGwsCkBAIC0yMjYxLDQgKzIzNTAsNDQgQEAKICAgICByZXR1cm4gU3RhdHVzOjpvaygpOwogfQogCitTdGF0dXMgQXVkaW9Qb2xpY3lTZXJ2aWNlOjpnZXREaXJlY3RQbGF5YmFja1N1cHBvcnQoY29uc3QgbWVkaWE6OkF1ZGlvQXR0cmlidXRlc0ludGVybmFsICZhdHRyQWlkbCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBBdWRpb0NvbmZpZyAmY29uZmlnQWlkbCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZWRpYTo6QXVkaW9EaXJlY3RNb2RlICpfYWlkbF9yZXR1cm4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IgIT0gbnVsbHB0cgogICAgICAgICBpZiAobVNwYXRpYWxpemVyLT5nZXRMZXZlbCgpICE9IG1lZGlhOjpTcGF0aWFsaXphdGlvbkxldmVsOjpOT05FKSB7CkBAIC0zOTcsNiArNTM0LDcgQEAKICAgICAgICAgICAgIGlmIChzdGF0dXMgPT0gTk9fRVJST1IgJiYgY3VycmVudE91dHB1dCA9PSBuZXdPdXRwdXQpIHsKICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICB9CisgICAgICAgICAgICBzaXplX3QgbnVtQWN0aXZlVHJhY2tzID0gY291bnRBY3RpdmVDbGllbnRzT25PdXRwdXRfbChuZXdPdXRwdXQpOwogICAgICAgICAgICAgbUxvY2sudW5sb2NrKCk7CiAgICAgICAgICAgICAvLyBJdCBpcyBPSyB0byBjYWxsIGRldGFjaE91dHB1dCgpIGlzIG5vbmUgaXMgYWxyZWFkeSBhdHRhY2hlZC4KICAgICAgICAgICAgIG1TcGF0aWFsaXplci0+ZGV0YWNoT3V0cHV0KCk7CkBAIC00MDQsNyArNTQyLDcgQEAKICAgICAgICAgICAgICAgICBtTG9jay5sb2NrKCk7CiAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgc3RhdHVzID0gbVNwYXRpYWxpemVyLT5hdHRhY2hPdXRwdXQobmV3T3V0cHV0KTsKKyAgICAgICAgICAgIHN0YXR1cyA9IG1TcGF0aWFsaXplci0+YXR0YWNoT3V0cHV0KG5ld091dHB1dCwgbnVtQWN0aXZlVHJhY2tzKTsKICAgICAgICAgICAgIG1Mb2NrLmxvY2soKTsKICAgICAgICAgICAgIGlmIChzdGF0dXMgIT0gTk9fRVJST1IpIHsKICAgICAgICAgICAgICAgICBtQXVkaW9Qb2xpY3lNYW5hZ2VyLT5yZWxlYXNlU3BhdGlhbGl6ZXJPdXRwdXQobmV3T3V0cHV0KTsKQEAgLTQyMSw2ICs1NTksNDMgQEAKICAgICB9CiB9CiAKK3NpemVfdCBBdWRpb1BvbGljeVNlcnZpY2U6OmNvdW50QWN0aXZlQ2xpZW50c09uT3V0cHV0X2woCisgICAgICAgIGF1ZGlvX2lvX2hhbmRsZV90IG91dHB1dCwgYm9vbCBzcGF0aWFsaXplZE9ubHkpIHsKKyAgICBzaXplX3QgY291bnQgPSAwOworICAgIGZvciAoc2l6ZV90IGkgPSAwOyBpIDwgbUF1ZGlvUGxheWJhY2tDbGllbnRzLnNpemUoKTsgaSsrKSB7CisgICAgICAgIGF1dG8gY2xpZW50ID0gbUF1ZGlvUGxheWJhY2tDbGllbnRzLnZhbHVlQXQoaSk7CisgICAgICAgIGlmIChjbGllbnQtPmlvID09IG91dHB1dCAmJiBjbGllbnQtPmFjdGl2ZQorICAgICAgICAgICAgICAgICYmICghc3BhdGlhbGl6ZWRPbmx5IHx8IGNsaWVudC0+aXNTcGF0aWFsaXplZCkpIHsKKyAgICAgICAgICAgIGNvdW50Kys7CisgICAgICAgIH0KKyAgICB9CisgICAgcmV0dXJuIGNvdW50OworfQorCit2b2lkIEF1ZGlvUG9saWN5U2VydmljZTo6b25VcGRhdGVBY3RpdmVTcGF0aWFsaXplclRyYWNrc19sKCkgeworICAgIGlmIChtU3BhdGlhbGl6ZXIgPT0gbnVsbHB0cikgeworICAgICAgICByZXR1cm47CisgICAgfQorICAgIG1PdXRwdXRDb21tYW5kVGhyZWFkLT51cGRhdGVBY3RpdmVTcGF0aWFsaXplclRyYWNrc0NvbW1hbmQoKTsKK30KKwordm9pZCBBdWRpb1BvbGljeVNlcnZpY2U6OmRvT25VcGRhdGVBY3RpdmVTcGF0aWFsaXplclRyYWNrcygpCit7CisgICAgc3A8U3BhdGlhbGl6ZXI+IHNwYXRpYWxpemVyOworICAgIHNpemVfdCBhY3RpdmVDbGllbnRzOworICAgIHsKKyAgICAgICAgTXV0ZXg6OkF1dG9sb2NrIF9sKG1Mb2NrKTsKKyAgICAgICAgaWYgKG1TcGF0aWFsaXplciA9PSBudWxscHRyKSB7Cisg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GVzY3JpcHRvcj4+KAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsaWVudEVmZmVjdHMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVnYWN5MmFpZGxfZWZmZWN0X2Rlc2NyaXB0b3JfdF9FZmZlY3REZXNjcmlwdG9yKSk7Ci0gICAgICAgICAgICBtZWRpYTo6QXVkaW9Db25maWdCYXNlIGRldmljZUNvbmZpZ0FpZGwgPSBWQUxVRV9PUl9SRVRVUk5fU1RBVFVTKAotICAgICAgICAgICAgICAgICAgICBsZWdhY3kyYWlkbF9hdWRpb19jb25maWdfYmFzZV90X0F1ZGlvQ29uZmlnQmFzZSgqZGV2aWNlQ29uZmlnKSk7CisgICAgICAgICAgICBBdWRpb0NvbmZpZ0Jhc2UgZGV2aWNlQ29uZmlnQWlkbCA9IFZBTFVFX09SX1JFVFVSTl9TVEFUVVMoCisgICAgICAgICAgICAgICAgICAgIGxlZ2FjeTJhaWRsX2F1ZGlvX2NvbmZpZ19iYXNlX3RfQXVkaW9Db25maWdCYXNlKAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICpkZXZpY2VDb25maWcsIHRydWUgLyppc0lucHV0Ki8pKTsKICAgICAgICAgICAgIHN0ZDo6dmVjdG9yPG1lZGlhOjpFZmZlY3REZXNjcmlwdG9yPiBlZmZlY3RzQWlkbCA9IFZBTFVFX09SX1JFVFVSTl9TVEFUVVMoCiAgICAgICAgICAgICAgICAgICAgIGNvbnZlcnRDb250YWluZXI8c3RkOjp2ZWN0b3I8bWVkaWE6OkVmZmVjdERlc2NyaXB0b3I+PigKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZmZlY3RzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlZ2FjeTJhaWRsX2VmZmVjdF9kZXNjcmlwdG9yX3RfRWZmZWN0RGVzY3JpcHRvcikpOwogICAgICAgICAgICAgaW50MzJfdCBwYXRjaEhhbmRsZUFpZGwgPSBWQUxVRV9PUl9SRVRVU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AgaXNBc3Npc3RhbnRPblRvcCA9IHRydWU7CisgICAgICAgICAgICAgICAgICAgIGlmIChpc0FjdGl2ZUFzc2lzdGFudCkgeworICAgICAgICAgICAgICAgICAgICAgICAgdXNlQWN0aXZlQXNzaXN0YW50TGlzdCA9IHRydWU7CisgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIXVzZUFjdGl2ZUFzc2lzdGFudExpc3QpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LT5zdGFydFRpbWVOcyA+IGxhdGVzdEFzc2lzdGFudFN0YXJ0TnMpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXRlc3RBY3RpdmVBc3Npc3RhbnQgPSBjdXJyZW50OworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxhdGVzdEFzc2lzdGFudFN0YXJ0TnMgPSBjdXJyZW50LT5zdGFydFRpbWVOczsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KICAgICAgICAgICAgIC8vIENsaWVudHMgY2FwdHVyaW5nIGZvciBIT1RXT1JEIGFyZSBub3QgY29uc2lkZXJlZApAQCAtNzI4LDcgKzkzOCw4IEBACiAgICAgICAgIGlmIChjdXJyZW50LT5hdHRyaWJ1dGVzLnNvdXJjZSAhPSBBVURJT19TT1VSQ0VfSE9UV09SRCkgewogICAgICAgICAgICAgb25seUhvdHdvcmRBY3RpdmUgPSBmYWxzZTsKICAgICAgICAgfQotICAgICAgICBpZiAoY3VycmVudFVpZCA9PSBtUGhvbmVTdGF0ZU93bmVyVWlkKSB7CisgICAgICAgIGlmIChjdXJyZW50VWlkID09IG1QaG9uZVN0YXRlT3duZXJVaWQgJiYKKyAgICAgICAgICAgICAgICAhaXNWaXJ0dWFsU291cmNlKGN1cnJlbnQtPmF0dHJpYnV0ZXMuc291cmNlKSkgewogICAgICAgICAgICAgaXNQaG9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pdmFjeSBzZW5zaXRpdmUgY2FwdHVyZSBvciBjYWxsCisgICAgICAgICAgICAvLyAgICAgICAgICBPUiBjbGllbnQgaGFzIENBUFRVUkVfQVVESU9fT1VUUFVUIHByaXZpbGVnZWQgcGVybWlzc2lvbgorICAgICAgICAgICAgLy8gICAgICAgICAgICBBTkQgaXMgbGF0ZXN0IFRPUCBhc3Npc3RhbnQgQU5ECisgICAgICAgICAgICAvLyAgICAgICAgICAgICAgIHVzZXMgVk9JQ0VfUkVDT0dOSVRJT04gT1IgdXNlcyBIT1RXT1JECisgICAgICAgICAgICAvLyAgICAgICAgICAgIE9SIHRoZXJlIGlzIG5vIFRPUCBhc3Npc3RhbnQgYW5kIHVzZXMgSE9UV09SRAogICAgICAgICAgICAgaWYgKGlzQTExeU9uVG9wIHx8IHJ0dENhbGxBY3RpdmUpIHsKICAgICAgICAgICAgICAgICBpZiAoc291cmNlID09IEFVRElPX1NPVVJDRV9IT1RXT1JEIHx8IHNvdXJjZSA9PSBBVURJT19TT1VSQ0VfVk9JQ0VfUkVDT0dOSVRJT04pIHsKICAgICAgICAgICAgICAgICAgICAgYWxsb3dDYXB0dXJlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIGlmICgoKGlzQXNzaXN0YW50T25Ub3AgJiYgc291cmNlID09IEFVRElPX1NPVVJDRV9WT0lDRV9SRUNPR05JVElPTikgfHwKLSAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZSA9PSBBVURJT19TT1VSQ0VfSE9UV09SRCkKLSAgICAgICAgICAgICAgICAgICAgICAgICYmICEoaXNTZW5zaXRpdmVBY3RpdmUgJiYgIWN1cnJlbnQtPmNhbkNhcHR1cmVPdXRwdXQpCisgICAgICAgICAgICB9IGVsc2UgaWYgKCEoaXNTZW5zaXRpdmVBY3RpdmUgJiYgIWN1cnJlbnQtPmNhbkNhcHR1cmVPdXRwdXQpCisgICAgICAgICAgICAgICAgICAgICYmIGNhbkNhcHR1cmVJZkluQ2FsbE9yQ29tbXVuaWNhdGlvbihjdXJyZW50KSkgeworICAgICAgICAgICAgICAgIGlmIChpc1RvcE9yTGF0ZXN0QXNzaXN0YW50CisgICAgICAgICAgICAgICAgICAgICYmIChzb3VyY2UgPT0gQVVESU9fU09VUkNFX1ZPSUNFX1JFQ09HTklUSU9OCisgICAgICAgICAgICAgICAgICAgICAgICB8fCBzb3VyY2UgPT0gQVVESU9fU09VUkNFX0hPVFdPUkQpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBhbGxvd0NhcHR1cmUgPSB0cnVlOworICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIWlzQXNzaXN0YW50T25Ub3AgJiYgKHNvdXJjZSA9PSBBVURJT19TT1VSQ0VfSE9UV09SRCkpIHsKKyAgICAgICAgICAgICAgICAgICAgYWxsb3dDYXB0dXJlID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CisgICAgICAgIH0gZWxzZSBpZiAodXNlQWN0aXZlQXNzaXN0YW50TGlzdCAmJiBtVWlkUG9saWN5LT5pc0FjdGl2ZUFzc2lzdGFudFVpZChjdXJyZW50VWlkKSkgeworICAgICAgICAgICAgLy8gRm9yIGFzc2lzdGFudCBvbiBhY3RpdmUgbGlzdCBhbmQgb24gdG9wIGFsbG93IGNhcHR1cmUgaWY6CisgICAgICAgICAgICAvLyAgICAgQW4gYWNjZXNzaWJpbGl0eSBzZXJ2aWNlIGlzIG9uIFRPUAorICAgICAgICAgICAgLy8gICAgICAgICBBTkQgdGhlIHNvdXJjZSBpcyBWT0lDRV9SRUNPR05JVElPTiBvciBIT1RXT1JECisgICAgICAgICAgICAvLyAgICAgT1IgdGhlcmUgaXMgbm8gYWN0aXZlIHByaXZhY3kgc2Vuc2l0aXZlIGNhcHR1cmUgb3IgY2FsbAorICAgICAgICAgICAgLy8gICAgICAgICAgICAgT1IgY2xpZW50IGhhcyBDQVBUVVJFX0FVRElPX09VVFBVVCBwcml2aWxlZ2VkIHBlcm1pc3Npb24KKyAgICAgICAgICAgIC8vICAgICAgICAgQU5EIHVzZXMgVk9JQ0VfUkVDT0dOSVRJT04gT1IgdXNlcyBIT1RXT1JECisgICAgICAgICAgICBpZiAoaXNBMTF5T25Ub3ApIHsKKyAgICAgICAgICAgICAgICBpZiAoc291cmNlID09IEFVRElPX1NPVVJDRV9IT1RXT1JEIHx8IHNvdXJjZSA9PSBBVURJT19TT1VSQ0VfVk9JQ0VfUkVDT0dOSVRJT04pIHsKKyAgICAgICAgICAgICAgICAgICAgYWxsb3dDYXB0dXJlID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9IGVsc2UgaWYgKCEoaXNTZW5zaXRpdmVBY3RpdmUgJiYgIWN1cnJlbnQtPmNhbkNhcHR1cmVPdXRwdXQpCiAgICAgICAgICAgICAgICAgICAgICAgICAmJiBjYW5DYXB0dXJlSWZJbkNhbGxPckNvbW11bmljYXRpb24oY3VycmVudCkpIHsKKyAgICAgICAgICAgICAgICBpZiAoKHNvdXJjZSA9PSBBVURJT19TT1VSQ0VfVk9JQ0VfUkVDT0dOSVRJT04pIHx8IChzb3VyY2UgPT0gQVVESU9fU09VUkNFX0hPVFdPUkQpKQorICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgYWxsb3dDYXB0dXJlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CkBAIC05MDcsNiArMTE0Miw3IEBACiAgICAgc3dpdGNoIChzb3VyY2UpIHsKICAgICAgICAgY2FzZSBBVURJT19TT1VSQ0VfRk1fVFVORVI6CiAgICAgICAgIGNhc2UgQVVESU9fU09VUkNFX0VDSE9fUkVGRVJFTkNFOgorICAgICAgICBjYXNlIEFVRElPX1NPVVJDRV9SRU1PVEVfU1VCTUlYOgogICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICBkZWZhdWx0OgogICAgIC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gICAgICAgIHNwPEF1ZGlvQ29tbWFuZD4gY29tbWFuZCA9IG1BdWRpb0NvbW1hbmRzWzBdOwogICAgICAgICAgICAgICAgIG1BdWRpb0NvbW1hbmRzLnJlbW92ZUF0KDApOworICAgICAgICAgICAgICAgIGlmIChtQXVkaW9Db21tYW5kcy5pc0VtcHR5KCkpIHsKKyAgICAgICAgICAgICAgICAgICsrbnVtVGltZXNCZWNhbWVFbXB0eTsKKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgbUxhc3RDb21tYW5kID0gY29tbWFuZDsKIAogICAgICAgICAgICAgICAgIHN3aXRjaCAoY29tbWFuZC0+bUNvbW1hbmQpIHsKQEAgLTE4MzMsOCArMjE1OSw4IEBACiAgICAgICAgICAgICAgICAgICAgIG1Mb2NrLmxvY2soKTsKICAgICAgICAgICAgICAgICAgICAgfSBicmVhazsKIAotICAgICAgICAgICAgICAgIGNhc2UgQ0hFQ0tfU1BBVElBTElaRVI6IHsKLSAgICAgICAgICAgICAgICAgICAgQUxPR1YoIkF1ZGlvQ29tbWFuZFRocmVhZCgpIHByb2Nlc3NpbmcgdXBkYXRlVUlEIHN0YXRlcyIpOworICAgICAgICAgICAgICAgIGNhc2UgQ0hFQ0tfU1BBVElBTElaRVJfT1VUUFVUOiB7CisgICAgICAgICAgICAgICAgICAgIEFMT0dWKCJBdWRpb0NvbW1hbmRUaHJlYWQoKSBwcm9jZXNzaW5nIGNoZWNrIHNwYXRpYWxpemVyIik7CiAgICAgICAgICAgICAgICAgICAgIHN2YyA9IG1TZXJ2aWNlLnByb21vdGUoKTsKICAgICAgICAgICAgICAgICAgICAgaWYgKHN2YyA9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKQEAgLTE4NDQsNiArMjE3MCwyOCBAQAogICAgICAgICAgICAgICAgICAgICBtTG9jay5sb2NrKCk7CiAgICAgICAgICAgICAgICAgICAgIH0gYnJlYWs7CiAKKyAgICAgICAgICAgICAgICBjYXNlIFVQREFURV9BQ1RJVkVfU1BBVElBTElaRVJfVFJBQ0tTOiB7CisgICAgICAgICAgICAgICAgICAgIEFMT0dWKCJBdWRpb0NvbW1hbmRUaHJlYWQoKSBwcm9jZXNzaW5nIHVwZGF0ZSBzcGF0aWFsaXplciB0cmFja3MiKTsKKyAgICAgICAgICAgICAgICAgICAgc3ZjID0gbVNlcnZpY2UucHJvbW90ZSgpOworICAgICAgICAgICAgICAgICAgICBpZiAoc3ZjID09IDApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIG1Mb2NrLnVubG9jaygpOworICAgICAgICAgICAgICAgICAgICBzdmMtPmRvT25VcGRhdGVBY3RpdmVTcGF0aWFsaXplclRyYWNrcygpOworICAgICAgICAgICAgICAgICAgICBtTG9jay5sb2NrKCk7CisgICAgICAgICAgICAgICAgICAgIH0gYnJlYWs7CisKKyAgICAgICAgICAgICAgICBjYXNlIFZPTF9SQU5HRV9JTklUX1JFUVVFU1Q6IHsKKyAgICAgICAgICAgICAgICAgICAgQUxPR1YoIkF1ZGlvQ29tbWFuZFRocmVhZCgpIHByb2Nlc3Npbmcgdm9sdW1lIHJhbmdlIGluaXQgcmVxdWVzdCIpOworICAgICAgICAgICAgICAgICAgICBzdmMgPSBtU2VydmljZS5wcm9tb3RlKCk7CisgICAgICAgICAgICAgICAgICAgIGlmIChzdmMgPT0gMCkgeworICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgbUxvY2sudW5sb2NrKCk7CisgICAgICAgICAgICAgICAgICAgIHN2Yy0+ZG9PblZvbHVtZVJhbmdlSW5pdFJlcXVlc3QoKTsKKyAgICAgICAgICAgICAgICAgICAgbUxvY2subG9jaygpOworICAgICAgICAgICAgICAgICAgICB9IGJyZWFrOworCiAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgIC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WRpYTo6QXVkaW9Db25maWcmIGNvbmZpZywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IEF1ZGlvQ29uZmlnJiBjb25maWcsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQzMl90IGZsYWdzLCBpbnQzMl90IHNlbGVjdGVkRGV2aWNlSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZWRpYTo6R2V0T3V0cHV0Rm9yQXR0clJlc3BvbnNlKiBfYWlkbF9yZXR1cm4pIG92ZXJyaWRlOwogICAgIGJpbmRlcjo6U3RhdHVzIHN0YXJ0T3V0cHV0KGludDMyX3QgcG9ydElkKSBvdmVycmlkZTsKQEAgLTk4LDMyICsxMDgsMzUgQEAKICAgICBiaW5kZXI6OlN0YXR1cyBnZXRJbnB1dEZvckF0dHIoY29uc3QgbWVkaWE6OkF1ZGlvQXR0cmlidXRlc0ludGVybmFsJiBhdHRyLCBpbnQzMl90IGlucHV0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQzMl90IHJpaWQsIGludDMyX3Qgc2Vzc2lvbiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQXR0cmlidXRpb25Tb3VyY2VTdGF0ZSAmYXR0cmlidXRpb25Tb3VyY2UsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1lZGlhOjpBdWRpb0NvbmZpZ0Jhc2UmIGNvbmZpZywgaW50MzJfdCBmbGFncywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQXVkaW9Db25maWdCYXNlJiBjb25maWcsIGludDMyX3QgZmxhZ3MsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3Qgc2VsZWN0ZWREZXZpY2VJZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVkaWE6OkdldElucHV0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isgICAgYmluZGVyOjpTdGF0dXMgZ2V0U3RyZWFtVm9sdW1lSW5kZXgoQXVkaW9TdHJlYW1UeXBlIHN0cmVhbSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBBdWRpb0RldmljZURlc2NyaXB0aW9uJiBkZXZpY2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCogX2FpZGxfcmV0dXJuKSBvdmVycmlkZTsKICAgICBiaW5kZXI6OlN0YXR1cyBzZXRWb2x1bWVJbmRleEZvckF0dHJpYnV0ZXMoY29uc3QgbWVkaWE6OkF1ZGlvQXR0cmlidXRlc0ludGVybmFsJiBhdHRyLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQzMl90IGRldmljZSwgaW50MzJfdCBpbmRleCkgb3ZlcnJpZGU7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IEF1ZGlvRGV2aWNlRGVzY3JpcHRpb24mIGRldmljZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBpbmRleCkgb3ZlcnJpZGU7CiAgICAgYmluZGVyOjpTdGF0dXMgZ2V0Vm9sdW1lSW5kZXhGb3JBdHRyaWJ1dGVzKGNvbnN0IG1lZGlhOjpBdWRpb0F0dHJpYnV0ZXNJbnRlcm5hbCYgYXR0ciwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBkZXZpY2UsIGludDMyX3QqIF9haWRsX3JldHVybikgb3ZlcnJpZGU7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IEF1ZGlvRGV2aWNlRGVzY3JpcHRpb24mIGRldmljZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg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b25zdCBtZWRpYTo6QXVkaW9VdWlkJiB0eXBlLAorICAgIGJpbmRlcjo6U3RhdHVzIGFkZFNvdXJjZURlZmF1bHRFZmZlY3QoY29uc3QgQXVkaW9VdWlkJiB0eXBlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjpzdHJpbmcmIG9wUGFja2FnZU5hbWUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtZWRpYTo6QXVkaW9VdWlkJiB1dWlkLCBpbnQzMl90IHByaW9yaXR5LAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVkaWE6OkF1ZGlvU291cmNlVHlwZSBzb3VyY2UsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBBdWRpb1V1aWQmIHV1aWQsIGludDMyX3QgcHJpb3JpdHksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBdWRpb1NvdXJjZSBzb3VyY2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQzMl90KiBfYWlkbF9yZXR1cm4pIG92ZXJyaWRlOwotICAgIGJpbmRlcjo6U3RhdHVzIGFkZFN0cmVhbURlZmF1bHRFZmZlY3QoY29uc3QgbWVkaWE6OkF1ZGlvVXVpZCYgdHlwZSwKKyAgICBiaW5kZXI6OlN0YXR1cyBhZGRTdHJlYW1EZWZhdWx0RWZmZWN0KGNvbnN0IEF1ZGlvVXVpZCYgdHlwZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ZDo6c3RyaW5nJiBvcFBhY2thZ2VOYW1lLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWVkaWE6OkF1ZGlvVXVpZCYgdXVpZCwgaW50MzJfdCBwcmlvcml0eSwKLSAg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QpOwogICAgICAgICAgICAgdm9pZCB1bnJlZ2lzdGVyU2VsZigpOwogCiAgICAgICAgICAgICBib29sIGlzU2Vuc29yUHJpdmFjeUVuYWJsZWQoKTsKIAotICAgICAgICAgICAgYmluZGVyOjpTdGF0dXMgb25TZW5zb3JQcml2YWN5Q2hhbmdlZChib29sIGVuYWJsZWQpOworICAgICAgICAgICAgYmluZGVyOjpTdGF0dXMgb25TZW5zb3JQcml2YWN5Q2hhbmdlZChpbnQgdG9nZ2xlVHlwZSwgaW50IHNlbnNvciwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBlbmFibGVkKTsKIAogICAgICAgICBwcml2YXRlOgogICAgICAgICAgICAgd3A8QXVkaW9Qb2xpY3lTZXJ2aWNlPiBtU2VydmljZTsKQEAgLTUwMSw3ICs1MzIsOSBAQAogICAgICAgICAgICAgQVVESU9fTU9EVUxFU19VUERBVEUsCiAgICAgICAgICAgICBST1VUSU5HX1VQREFURUQsCiAgICAgICAgICAgICBVUERBVEVfVUlEX1NUQVRFUywKLSAgICAgICAgICAgIENIRUNLX1NQQVRJQUxJWkVSCisgICAgICAgICAgICBDSEVDS19TUEFUSUFMSVpFUl9PVVRQVVQsIC8vIHZlcmlmeSBpZiBzcGF0aWFsaXplciBlZmZlY3Qgc2hvdWxkIGJlIGNyZWF0ZWQgb3IgbW92ZWQKKyAgICAgICAgICAgIFVQREFURV9BQ1RJVkVfU1BBVElBTElaRVJfVFJBQ0tTLCAvLyBVcGRhdGUgYWN0aXZlIHRyYWNrIGNvdW50cyBvbiBzcGFsaWFsaXplciBvdXRwdXQKKyAgICAgICAgICAgIFZPTF9SQU5HRV9JTklUX1JFUVVFU1QsIC8vIHJlcXVlc3QgdG8gcmVzZXQgdGhlIHZvbHVtZSByYW5nZSBpbmRpY2VzCiAgICAgICAgIH07CiAKICAgICAgICAgQXVkaW9Db21tYW5kVGhyZWFkIChTdHJpbmc4IG5hbWUsIGNvb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gICAgICAgICAgIGNvbnN0IFRyYWNrU2Vjb25kYXJ5T3V0cHV0c01hcCYgdHJhY2tTZWNvbmRhcnlPdXRwdXRzKSBvdmVycmlkZTsKIAorICAgICAgICBzdGF0dXNfdCBzZXREZXZpY2VDb25uZWN0ZWRTdGF0ZSgKKyAgICAgICAgICAgICAgICBjb25zdCBzdHJ1Y3QgYXVkaW9fcG9ydF92NyAqcG9ydCwgYm9vbCBjb25uZWN0ZWQpIG92ZXJyaWRlOworCiAgICAgIHByaXZhdGU6CiAgICAgICAgIEF1ZGlvUG9saWN5U2VydmljZSAqbUF1ZGlvUG9saWN5U2VydmljZTsKICAgICB9OwpAQCAtODA4LDYgKzg0OSw3IEBACiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fcGF0Y2hfaGFuZGxlX3QgcGF0Y2hIYW5kbGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXVkaW9fc291cmNlX3Qgc291cmNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2b2lkICAgICAgb25Sb3V0aW5nVXBkYXRlZCgpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZvaWQgICAgICBvblZvbHVtZVJhbmdlSW5pdFJlcXVlc3QoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2b2lkICAgICAgc2V0QXVkaW9Qb3J0Q2FsbGJhY2tzRW5hYmxlZChib29sIGVuYWJsZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZvaWQgc2V0QXVkaW9Wb2x1bWVHcm91cENhbGxiYWNrc0VuYWJsZWQoYm9vbCBlbmFibGVkKTsKIApAQCAtOTM3LDEyICs5NzksMTQgQEAKICAgICAgICAgICAgICAgICBBdWRpb1BsYXliYWNrQ2xpZW50KGNvbnN0IGF1ZGlvX2F0dHJpYnV0ZXNfdCBhdHRyaWJ1dGVzLAogICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGF1ZGlvX2lvX2hhbmRsZV90IGlvLCBBdHRyaWJ1dGlvblNvdXJjZVN0YXRlIGF0dHJpYnV0aW9uU291cmNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGF1ZGlvX3Nlc3Npb25fdCBzZXNzaW9uLCBhdWRpb19wb3J0X2hhbmRsZV90IHBvcnRJZCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdWRpb19wb3J0X2hhbmRsZV90IGRldmljZUlkLCBhdWRpb19zdHJlYW1fdHlwZV90IHN0cmVhbSkgOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF1ZGlvX3BvcnRfaGFuZGxlX3QgZGV2aWNlSWQsIGF1ZGlvX3N0cmVhbV90eXBlX3Qgc3RyZWFtLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvb2wgaXNTcGF0aWFsaXplZCkgOgogICAgICAgICAgICAgICAgICAgICBBdWRpb0NsaWVudChhdHRyaWJ1dGVzLCBpbywgYXR0cmlidXRpb25Tb3VyY2UsIHNlc3Npb24sIHBvcnRJZCwKLSAgICAgICAgICAgICAgICAgICAgICAgIGRldmljZUlkKSwgc3RyZWFtKHN0cmVhbSkge30KKyAgICAgICAgICAgICAgICAgICAgICAgIGRldmljZUlkKSwgc3RyZWFtKHN0cmVhbSksIGlzU3BhdGlhbGl6ZWQoaXNTcGF0aWFsaXplZCkgIHt9CiAgICAgICAgICAgICAgICAgfkF1ZGlvUGxheWJhY2tDbGllbnQoKSBvdmVycmlkZSA9IGRlZmF1bHQ7CiAKICAgICAgICAgY29uc3QgYXVkaW9fc3RyZWFtX3R5cGVfdCBzdHJlYW07CisgICAgICAgIGNvbnN0IGJvb2wgaXNTcGF0aWFsaXplZDsKICAgICB9OwogCiAgICAgdm9pZCBnZXRQbGF5YmFja0NsaWVudEFuZEVmZmVjdHMoYXVkaW9fcG9ydF9oYW5kbGVfdCBwb3J0SWQsCkBAIC05NzIsNiArMT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bUVuZ2luZS0+c2V0RW5hYmxlZCh0cnVlKTsKICAgICAgICAgb3V0cHV0Q2hhbmdlZCA9IG1PdXRwdXQgIT0gb3V0cHV0OwogICAgICAgICBtT3V0cHV0ID0gb3V0cHV0OworICAgICAgICBtTnVtQWN0aXZlVHJhY2tzID0gbnVtQWN0aXZlVHJhY2tzOwogCisgICAgICAgIGNoZWNrRW5naW5lU3RhdGVfbCgpOwogICAgICAgICBpZiAobVN1cHBvcnRzSGVhZFRyYWNraW5nKSB7Ci0gICAgICAgICAgICBtUG9zZUNvbnRyb2xsZXIgPSBzdGQ6Om1ha2Vfc2hhcmVkPFNwYXRpYWxpemVyUG9zZUNvbnRyb2xsZXI+KAotICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxTcGF0aWFsaXplclBvc2VDb250cm9sbGVyOjpMaXN0ZW5lcio+KHRoaXMpLCAxMG1zLCA1MG1zKTsKLSAgICAgICAgICAgIExPR19BTFdBWVNfRkFUQUxfSUYobVBvc2VDb250cm9sbGVyID09IG51bGxwdHIsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIlcyBjb3VsZCBub3QgYWxsb2NhdGUgcG9zZSBjb250cm9sbGVyIiwgX19mdW5jX18pOwotCi0gICAgICAgICAgICBtUG9zZUNvbnRyb2xsZXItPnNldERlc2lyZWRNb2RlKG1EZXNpcmVkSGVhZFRyYWNraW5nTW9kZSk7Ci0gICAgICAgICAgICBtUG9zZUNvbnRyb2xsZXItPnNldEhlYWRTZW5zb3IobUhlYWRTZW5zb3IpOwotICAgICAgICAgICAgbVBvc2VDb250cm9sbGVyLT5zZXRTY3JlZW5TZW5zb3IobVNjcmVlblNlbnNvcik7Ci0gICAgICAgICAgICBtUG9zZUNvbnRyb2xsZXItPnNldERpc3BsYXlPcmllbnRhdGlvbihtRGlzcGxheU9yaWVudGF0aW9uKTsKLSAgICAgICAgICAgIHBvc2VDb250cm9sbGVyID0gbVBvc2VDb250cm9sbGVyOworICAgICAgICAg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KCkgeworICAgIGlmIChtU3VwcG9ydHNIZWFkVHJhY2tpbmcgJiYgbVBvc2VDb250cm9sbGVyICE9IG51bGxwdHIpIHsKKyAgICAgICAgaWYgKG1OdW1BY3RpdmVUcmFja3MgPiAwICYmIG1MZXZlbCAhPSBTcGF0aWFsaXphdGlvbkxldmVsOjpOT05FCisgICAgICAgICAgICAmJiBtRGVzaXJlZEhlYWRUcmFja2luZ01vZGUgIT0gSGVhZFRyYWNraW5nTW9kZTo6U1RBVElDCisgICAgICAgICAgICAmJiBtSGVhZFNlbnNvciAhPSBTcGF0aWFsaXplclBvc2VDb250cm9sbGVyOjpJTlZBTElEX1NFTlNPUikgeworICAgICAgICAgICAgbVBvc2VDb250cm9sbGVyLT5zZXRIZWFkU2Vuc29yKG1IZWFkU2Vuc29yKTsKKyAgICAgICAgICAgIG1Qb3NlQ29udHJvbGxlci0+c2V0U2NyZWVuU2Vuc29yKG1TY3JlZW5TZW5zb3IpOworICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgbVBvc2VDb250cm9sbGVyLT5zZXRIZWFkU2Vuc29yKFNwYXRpYWxpemVyUG9zZUNvbnRyb2xsZXI6OklOVkFMSURfU0VOU09SKTsKKyAgICAgICAgICAgIG1Qb3NlQ29udHJvbGxlci0+c2V0U2NyZWVuU2Vuc29yKFNwYXRpYWxpemVyUG9zZUNvbnRyb2xsZXI6OklOVkFMSURfU0VOU09SKTsKKyAgICAgICAgfQorICAgIH0KK30KKwordm9pZCBTcGF0aWFsaXplcjo6Y2hlY2tFbmdpbmVTdGF0ZV9sKCkgeworICAgIGlmIChtRW5naW5lICE9IG51bGxwdHIpIHsKKyAgICAgICAgaWYgKG1MZXZlbCAhPSBTcGF0aWFsaXphdGlvbkxldmVsOjpOT05FICYmIG1OdW1BY3RpdmVUcmFja3MgPiAwKSB7CisgICAgICAgICAgICBtRW5naW5lLT5zZXRFbmFibGVkKHRydWUpOworICAgICAgICAgICAgc2V0RWZmZWN0UGFyYW1ldGVyX2wo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AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGQ6OmNocm9ubzo6bWljcm9zZWNvbmRzIHNlbnNvclBlcmlvZCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RkOjpjaHJvbm86Om1pY3Jvc2Vjb25kcyBtYXhVcGRhdGVQZXJpb2QpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RkOjpjaHJvbm86Om1pY3Jvc2Vjb25kcyBzZW5zb3JQZXJpb2QsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RkOjpvcHRpb25hbDxzdGQ6OmNocm9ubzo6bWljcm9zZWNvbmRzPiBtYXhVcGRhdGVQZXJpb2QpCiAgICAgOiBtTGlzdGVuZXIobGlzdGVuZXIpLAogICAgICAgbVNlbnNvclBlcmlvZChzZW5zb3JQZXJpb2QpLAogICAgICAgbVByb2Nlc3NvcihjcmVhdGVIZWFkVHJhY2tpbmdQcm9jZXNzb3IoSGVhZFRyYWNraW5nUHJvY2Vzc29yOjpPcHRpb25zewogICAgICAgICAgICAgICAubWF4VHJhbnNsYXRpb25hbFZlbG9jaXR5ID0ga01heFRyYW5zbGF0aW9uYWxWZWxvY2l0eSAvIGtUaWNrc1BlclNlY29uZCwKICAgICAgICAgICAgICAgLm1heFJvdGF0aW9uYWxWZWxvY2l0eSA9IGtNYXhSb3RhdGlvbmFsVmVsb2NpdHkgLyBrVGlja3NQZXJTZWNvbmQsCi0gICAgICAgICAgICAgIC50cmFuc2xhdGlvbmFsRHJpZnRUaW1lQ29uc3RhbnQgPSBUaWNrcyhrVHJhbnNsYXRpb25hbERyaWZ0VGltZUNvbnN0YW50KS5jb3VudCgpLAotICAgICAgICAgICAgICAucm90YXRpb25hbERyaWZ0VGltZUNvbnN0YW50ID0gVGlja3Moa1JvdGF0aW9uYWxEcmlmdFRpbWVDb25zdGFudCku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2tlciIsIHRoaXMpKSwKICAgICAgIG1UaHJlYWQoW3RoaXMsIG1heFVwZGF0ZVBlcmlvZF0gewpAQCAtOTMsOCArMTA2LDEyIEBACiAgICAgICAgICAgICAgIHN0ZDo6b3B0aW9uYWw8SGVhZFRyYWNraW5nTW9kZT4gbW9kZUlmQ2hhbmdlZDsKICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgc3RkOjp1bmlxdWVfbG9jayBsb2NrKG1NdXRleCk7Ci0gICAgICAgICAgICAgICAgICBtQ29uZFZhci53YWl0X2Zvcihsb2NrLCBtYXhVcGRhdGVQZXJpb2QsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBbdGhpc10geyByZXR1cm4gbVNob3VsZEV4aXQgfHwgbVNob3VsZENhbGN1bGF0ZTsgfSk7CisgICAgICAgICAgICAgICAgICBpZiAobWF4VXBkYXRlUGVyaW9kLmhhc192YWx1ZSgpKSB7CisgICAgICAgICAgICAgICAgICAgICAgbUNvbmRWYXIud2FpdF9mb3IobG9jaywgbWF4VXBkYXRlUGVyaW9kLnZhbHVlKCksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgW3RoaXNdIHsgcmV0dXJuIG1TaG91bGRFeGl0IHx8IG1TaG91bGRDYWxjdWxhdGU7IH0pOworICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICBtQ29uZFZhci53YWl0KGxvY2ssIFt0aGlzXSB7IHJldHVybiBtU2hvdWxkRXhpdCB8fCBtU2hvdWxkQ2FsY3VsYXRlOyB9KTsKKyAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgIGlmIChtU2hvdWxkRXhpdCkgewogICAgICAgICAgICAgICAgICAgICAgIEFMT0dWKCJFeGl0aW5nIHRocmVhZCIpOwogICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKQEAgLTEzMiw5ICsxNDksMTYgQEAKIAogdm9pZCBTcGF0aW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kFMSURfU0VOU09SOworICAgICAgICAgICAgaWYgKG1IZWFkU2Vuc29yICE9IElOVkFMSURfU0VOU09SKSB7CisgICAgICAgICAgICAgICAgYXV0byBzZW5zb3IgPSBtUG9zZVByb3ZpZGVyLT5nZXRTZW5zb3JCeUhhbmRsZShtSGVhZFNlbnNvcik7CisgICAgICAgICAgICAgICAgc3RkOjpzdHJpbmcgc3RyaW5nVHlwZSA9IHNlbnNvciA/IHNlbnNvci0+Z2V0U3RyaW5nVHlwZSgpLmNfc3RyKCkgOiAiIjsKKyAgICAgICAgICAgICAgICBtZWRpYW1ldHJpY3M6OkxvZ0l0ZW0oZ2V0U2Vuc29yTWV0cmljc0lkKG1IZWFkU2Vuc29yKSkKKyAgICAgICAgICAgICAgICAgICAgLnNldChBTUVESUFNRVRSSUNTX1BST1BfRVZFTlQsIEFNRURJQU1FVFJJQ1NfUFJPUF9FVkVOVF9WQUxVRV9TVEFSVCkKKyAgICAgICAgICAgICAgICAgICAgLnNldChBTUVESUFNRVRSSUNTX1BST1BfTU9ERSwgQU1FRElBTUVUUklDU19QUk9QX01PREVfVkFMVUVfSEVBRCkKKyAgICAgICAgICAgICAgICAgICAgLnNldChBTUVESUFNRVRSSUNTX1BST1BfVFlQRSwgc3RyaW5nVHlwZSkKKyAgICAgICAgICAgICAgICAgICAgLnJlY29yZCgpOworICAgICAgICAgICAgfQogICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgLy8gU2Vuc29yIGlzIGFscmVhZHkgZW5hYmxlZC4KICAgICAgICAgICAgIG1IZWFkU2Vuc29yID0gbVNjcmVlblNlbnNvcjsKQEAgLTE1MCwxNCArMTgzLDIxIEBACiAgICAgICAgIG1IZWFkU2Vuc29yID0gSU5WQUxJRF9TRU5TT1I7CiAgICAgfQogCi0gICAgbVByb2Nlc3Nvci0+cmVjZW50ZXIodHJ1ZSwgZmFsc2UpOworICAgIG1Qcm9jZXNzb3ItPnJlY2VudGVyKHRydWUgLyogcmVjZW50ZXJIZWFkIC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UyMjBiYyAxMDA2NDQKLS0tIGEvc2VydmljZXMvYXVkaW9wb2xpY3kvdGVzdHMvQW5kcm9pZC5icAorKysgYi9zZXJ2aWNlcy9hdWRpb3BvbGljeS90ZXN0cy9BbmRyb2lkLmJwCkBAIC0yNSwxMyArMjUsMTMgQEAKICAgICAgICAgImxpYm1lZGlhX2hlbHBlciIsCiAgICAgICAgICJsaWJ1dGlscyIsCiAgICAgICAgICJsaWJ4bWwyIiwKLSAgICAgICAgImxpYnBlcm1pc3Npb24iLAorICAgICAgICAiZnJhbWV3b3JrLXBlcm1pc3Npb24tYWlkbC1jcHAiLAogICAgICAgICAibGliYmluZGVyIiwKICAgICBdLAogCiAgICAgc3RhdGljX2xpYnM6IFsKICAgICAgICAgImxpYmF1ZGlvcG9saWN5Y29tcG9uZW50cyIsCi0gICAgICAgICJsaWJnbW9jayIKKyAgICAgICAgImxpYmdtb2NrIiwKICAgICBdLAogCiAgICAgaGVhZGVyX2xpYnM6IFsKQEAgLTY1LDYgKzY1LDEyIEBACiAgICAgICAgICJsaWJsb2ciLAogICAgICAgICAibGlibWVkaWFfaGVscGVyIiwKICAgICAgICAgImxpYnV0aWxzIiwKKyAgICAgICAgImFuZHJvaWQubWVkaWEuYXVkaW8uY29tbW9uLnR5cGVzLVYxLWNwcCIsCisgICAgICAgICJsaWJhdWRpb2NsaWVudF9haWRsX2NvbnZlcnNpb24iLAorICAgICAgICAibGlic3RhZ2VmcmlnaHRfZm91bmRhdGlvbiIsCisgICAgICAgICJsaWJzaG1lbWNvbXBhdCIsCisgICAgICAgICJsaWJzaG1lbXV0aWwiLAorICAgICAgICAiYXVkaW9jbGllbnQtdHlwZXMtYWlkbC1jcHAiLAogICAgIF0sCiAKICAgICBzdGF0aWNfbGliczogWyJsaWJhdWRpb3BvbGljeWNvbXBvbmVudHMiXSwKZGlmZiAtLWdpdCBhL3NlcnZpY2VzL2F1ZGlvcG9saWN5L3Rlc3RzL0F1ZGlvUG9saWN5TWFuYWdlclRlc3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A9PSBBVURJT19QT1JUX1JPTEVfU09VUkNFKSB7CisgICAgICAgICAgICAgICAgaWYgKChwb3J0LmFjdGl2ZV9jb25maWcuZmxhZ3Mub3V0cHV0ICYgQVVESU9fT1VUUFVUX0ZMQUdfUFJJTUFSWSkgIT0gMCkgeworICAgICAgICAgICAgICAgICAgICBmb3VuZFByaW1hcnkgPSB0cnVlOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBpZiAoKHBvcnQuYWN0aXZlX2NvbmZpZy5mbGFncy5vdXRwdXQgJiBBVURJT19PVVRQVVRfRkxBR19WT0lQX1JYKSAhPSAwKSB7CisgICAgICAgICAgICAgICAgICAgIGZvdW5kVm9pcFJ4ID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9IGVsc2UgaWYgKHBvcnQucm9sZSA9PSBBVURJT19QT1JUX1JPTEVfU0lOSykgeworICAgICAgICAgICAgICAgIGlmICgocG9ydC5hY3RpdmVfY29uZmlnLmZsYWdzLmlucHV0ICYgQVVESU9fSU5QVVRfRkxBR19WT0lQX1RYKSAhPSAwKSB7CisgICAgICAgICAgICAgICAgICAgIGZvdW5kVm9pcFR4ID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICB9CisgICAgRVhQRUNUX1RSVUUoaGFzRmxhZ3MpOworICAgIEVYUEVDVF9UUlVFKGZvdW5kUHJpbWFyeSk7CisgICAgRVhQRUNUX1RSVUUoZm91bmRWb2lwUngpOworICAgIEVYUEVDVF9UUlVFKGZvdW5kVm9pcFR4KTsKK30KKwogdXNpbmcgUG9saWN5TWl4VHVwbGUgPSBzdGQ6OnR1cGxlPGF1ZGlvX3VzYWdlX3QsIGF1ZGlvX3NvdXJjZV90LCB1aW50MzJfdD47CiAKIGNsYXNzIEF1ZGlvUG9saWN5TWFuYWdlclRlc3REeW5hbWljUG9saWN5IDogcHVibGljIEF1ZGlvUG9saWN5TWFuY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gICA8cHJvZmlsZSBuYW1lPSIiIGZvcm1hdD0iQVVESU9fRk9STUFUX1BDTV8xNl9CSVQiCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNhbXBsaW5nUmF0ZXM9IjgwMDAsMTEwMjUsMTYwMDAsNDQxMDAsNDgwMDAiCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYW5uZWxNYXNrcz0iQVVESU9fQ0hBTk5FTF9JTl9TVEVSRU8sQVVESU9fQ0hBTk5FTF9JTl9NT05PIi8+CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNhbXBsaW5nUmF0ZXM9IjgwMDAgMTEwMjUgMTYwMDAgNDQxMDAgNDgwMDAiCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYW5uZWxNYXNrcz0iQVVESU9fQ0hBTk5FTF9JTl9TVEVSRU8gQVVESU9fQ0hBTk5FTF9JTl9NT05PIi8+CisgICAgICAgICAgICAgICAgPC9taXhQb3J0PgorICAgICAgICAgICAgICAgIDxtaXhQb3J0IG5hbWU9InZvaXBfdHgiIHJvbGU9InNpbmsiCisgICAgICAgICAgICAgICAgICAgICAgICAgZmxhZ3M9IkFVRElPX0lOUFVUX0ZMQUdfVk9JUF9UWCI+CisgICAgICAgICAgICAgICAgICAgIDxwcm9maWxlIG5hbWU9IiIgZm9ybWF0PSJBVURJT19GT1JNQVRfUENNXzE2X0JJVCIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2FtcGxpbmdSYXRlcz0iODAwMCAxNjAwMCAzMjAwMCA0ODAwMCIgY2hhbm5lbE1hc2tzPSJBVURJT19DSEFOTkVMX0lOX01PTk8iLz4KKyAgICAgICAgICAgICAgICA8L21peFBvcnQ+CisgICAgICAgICAgICAgICAgPG1peFBvcnQgbmFtZT0idm9pcF9yeCIgcm9sZT0ic291cmNlIgorICAgICAgICAgICAgICAgICAgICAgICAgIGZsYWdzPSJBVURJT19PVVRQVVRfRkxBR19WT0lQX1JYIj4KKyAgICAgICAgICAgICAgICAgICAgPHByb2ZpbGUgbmFtZT0iIiBmb3JtYXQ9IkFVRElPX0ZPUk1BVF9QQ01fMTZfQklUIgorICAgICAgICAgICAgICAgICAgICAgICAgICAgc2FtcGxpbmdSYXRlcz0iODAwMCAxNjAwMCAzMjAwMCA0ODAwMCIgY2hhbm5lbE1hc2tzPSJBVURJT19DSEFOTkVMX09VVF9TVEVSRU8iLz4KICAgICAgICAgICAgICAgICA8L21peFBvcnQ+CiAgICAgICAgICAgICA8L21peFBvcnRzPgogICAgICAgICAgICAgPGRldmljZVBvcnRzPgpAQCAtNTAsNyArNjAsOCBAQAogICAgICAgICAgICAgICAgIDwvZGV2aWNlUG9ydD4KICAgICAgICAgICAgICAgICA8ZGV2aWNlUG9ydCB0YWdOYW1lPSJCdWlsdC1JbiBNaWMiIHR5cGU9IkFVRElPX0RFVklDRV9JTl9CVUlMVElOX01JQyIgcm9sZT0ic291cmNlIj4KICAgICAgICAgICAgICAgICA8L2RldmljZVBvcnQ+Ci0gICAgICAgICAgICAgICAgPGRldmljZVBvcnQgdGFnTmFtZT0iSGRtaSIgdHlwZT0iQVVESU9fREVWSUNFX09VVF9IRE1JIiByb2xlPSJzaW5rIj4KKyAgICAgICAgICAgICAgICA8ZGV2aWNlUG9ydCB0YWdOYW1lPSJIZG1pIiB0eXBlPSJBVURJT19ERVZJQ0VfT1VUX0hETUkiIHJvbGU9InNpbmsiCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5jb2RlZEZvcm1hdHM9IkFVRElPX0ZPUk1BVF9BQzMiPgogICAgICAgICAgICAgICAgIDwvZGV2aWNlUG9ydD4KICAgICAgICAgICAgICAgICA8ZGV2aWNlUG9ydCB0YWdOYW1lPSJIZG1pLUluIE1pYyIgdHlwZT0iQVVESU9fREVWSUNFX0lOX0hETUkiIHJvbGU9InNvdXJjZSI+CiAgICAgICAgICAgICAgICAgPC9kZXZpY2VQb3J0PgpAQCAtNjMsMTMgKzc0LDE1IEBACiAgICAgICAgICAgICA8L2RldmljZVBvcnRzPgogICAgICAgICAgICAgPHJvdXRlcz4KICAgICAgICAgICAgICAgICA8cm91dGUgdHlwZT0ibWl4IiBzaW5rPSJTcGVha2VyIgotICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VzPSJwcmltYXJ5IG91dHB1dCIvPgorICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VzPSJwcmltYXJ5IG91dHB1dCx2b2lwX3J4Ii8+CiAgICAgICAgICAgICAgICAgPHJvdXRlIHR5cGU9Im1peCIgc2luaz0icHJpbWFyeSBpbnB1dCIKICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlcz0iQnVpbHQtSW4gTWljLEhkbWktSW4gTWljIi8+CisgICAgICAgICAgICAgICAgPHJvdXRlIHR5cGU9Im1peCIgc2luaz0idm9pcF90eCIKKyAgICAgICAgICAgICAgICAgICAgICAgc291cmNlcz0iQnVpbHQtSW4gTWljIi8+CiAgICAgICAgICAgICAgICAgPHJvdXRlIHR5cGU9Im1peCIgc2luaz0iSGRtaSIKICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlcz0icHJpbWFyeSBvdXRwdXQiLz4KICAgICAgICAgICAgICAgICA8cm91dGUgdHlwZT0ibWl4IiBzaW5rPSJCVCBTQ08iCi0gICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZXM9Im1peHBvcnRfYnRfaGZwX291dHB1dCIvPgorICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VzPSJtaXhwb3J0X2J0X2hmcF9vdXRwdXQsdm9pcF9yeCIvPgogICAgICAgICAgICAgICAgIDxyb3V0ZSB0eXBlPSJtaXgiIHNpbms9Im1peHBvcnRfYnRfaGZwX2lucHV0IgogICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VzPSJCVCBTQ08gSGVhZHNldCBNaWMiLz4KICAgICAgICAgICAgIDwvcm91dGVzPgpkaWZmIC0tZ2l0IGEvc2VydmljZXMvY2FtZXJhL2xpYmNhbWVyYXNlcnZp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wIiwKICAgICAgICAgImd1aS9SaW5nQnVmZmVyQ29uc3VtZXIuY3BwIiwKICAgICAgICAgImhpZGwvQWlkbENhbWVyYURldmljZUNhbGxiYWNrcy5jcHAiLAogICAgICAgICAiaGlkbC9BaWRsQ2FtZXJhU2VydmljZUxpc3RlbmVyLmNwcCIsCi0gICAgICAgICJoaWRsL0NvbnZlcnQuY3BwIiwKICAgICAgICAgImhpZGwvSGlkbENhbWVyYURldmljZVVzZXIuY3BwIiwKICAgICAgICAgImhpZGwvSGlkbENhbWVyYVNlcnZpY2UuY3BwIiwKKyAgICAgICAgImhpZGwvVXRpbHMuY3BwIiwKICAgICAgICAgInV0aWxzL0NhbWVyYVNlcnZpY2VQcm94eVdyYXBwZXIuY3BwIiwKICAgICAgICAgInV0aWxzL0NhbWVyYVRocmVhZFN0YXRlLmNwcCIsCiAgICAgICAgICJ1dGlscy9DYW1lcmFUcmFjZXMuY3BwIiwKICAgICAgICAgInV0aWxzL0F1dG9Db25kaXRpb25Mb2NrLmNwcCIsCi0gICAgICAgICJ1dGlscy9FeGlmVXRpbHMuY3BwIiwKICAgICAgICAgInV0aWxzL1Nlc3Npb25Db25maWd1cmF0aW9uVXRpbHMuY3BwIiwKKyAgICAgICAgInV0aWxzL1Nlc3Npb25Db25maWd1cmF0aW9uVXRpbHNIaWRsLmNwcCIsCiAgICAgICAgICJ1dGlscy9TZXNzaW9uU3RhdHNCdWlsZGVyLmNwcCIsCiAgICAgICAgICJ1dGlscy9UYWdNb25pdG9yLmNwcCIsCiAgICAgICAgICJ1dGlscy9MYXRlbmN5SGlzdG9ncmFtLmNwcCIsCiAgICAgXSwKIAogICAgIGhlYWRlcl9saWJzOiBbCisgICAgICAgICJsaWJkeW5hbWljX2RlcHRoLWludGVybmFsX2hlYWRlcnMiLAorICAgICAgICAibGliZHluYW1pY19kZXB0aC1wdWJsaWNfaGVhZGVycyIsCiAgICAgICAgICJsaWJtZWRpYWRybV9oZWFkZXJzIiwKICAgICAgICAgImxpYm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RpY19saWJzOiBbCisgICAgICAgICJsaWJhaWRsY29tbW9uc3VwcG9ydCIsCiAgICAgICAgICJsaWJwcm9jZXNzaW5mb3NlcnZpY2VfYWlkbCIsCiAgICAgICAgICJsaWJiaW5kZXJ0aHJlYWRzdGF0ZXV0aWxzIiwKICAgICAgICAgIm1lZGlhX3Blcm1pc3Npb24tYWlkbC1jcHAiLAorICAgICAgICAibGliY2FtZXJhc2VydmljZV9kZXZpY2VfaW5kZXBlbmRlbnQiLAogICAgIF0sCiAKICAgICBleHBvcnRfc2hhcmVkX2xpYl9oZWFkZXJzOiBbCkBAIC0xNzUsOSArMTg3LDU1IEBACiAgICAgaW5jbHVkZV9kaXJzOiBbCiAgICAgICAgICJzeXN0ZW0vbWVkaWEvcHJpdmF0ZS9jYW1lcmEvaW5jbHVkZSIsCiAgICAgICAgICJmcmFtZXdvcmtzL25hdGl2ZS9pbmNsdWRlL21lZGlhL29wZW5tYXgiLAotICAgICAgICAiZnJhbWV3b3Jrcy9hdi9tZWRpYS9uZGsiLAotICAgICAgICAiZXh0ZXJuYWwvZHluYW1pY19kZXB0aC9pbmNsdWRlcyIsCi0gICAgICAgICJleHRlcm5hbC9keW5hbWljX2RlcHRoL2ludGVybmFsIiwKKyAgICBdLAorCisgICAgZXhwb3J0X2luY2x1ZGVfZGlyczogWyIuIl0sCisKKyAgICBjZmxhZ3M6IFsKKyAgICAgICAgIi1XYWxsIiwKKyAgICAgICAgIi1XZXh0cmEiLAorICAgICAgICAiLVdlcnJvciIsCisgICAgICAgICItV25vLWlnbm9yZWQtcXVhbGlmaWVycyIsCisgICAgXSwKKworfQorCitjY19saWJyYXJ5X3N0YXRpYyB7CisgICAgbmFtZTogImxpYmNhbWVyYXNlcnZpY2VfZGV2aWNlX2luZGVwZW5kZW50IiwKKyAgICBob3N0X3N1cHBvcnRlZDogdHJ1ZSwKKworICAgIC8vIENhbWVyYSBzZXJ2aWNlIHNvdXJjZQorCisgICAgc3JjczogWworICAgICAgICAiY29tbW9uL0RlcHRoUGhvdG9Qcm9jZXNzb3IuY3BwIiwKKyAgICAgICAgImRldmljZTMvQ29vcmRpbmF0ZU1hcHBlci5jcHAiLAorICAgICAgICAiZGV2aWNlMy9EaXN0b3J0aW9uTWFwcGVyLmNwcCIsCisgICAgICAgICJkZXZpY2UzL1JvdGF0ZUFuZENyb3BNYXBwZXIuY3BwIiwKKyAgICAgICAgImRldmljZTMvWm9vbVJhdGlvTWFwcGVyLmNwcCIsCisgICAgICAgICJ1dGlscy9FeGlmVXRpbHMuY3BwIiwKKyAgICAgICAgInV0aWxzL1Nlc3Npb25Db25maWd1cmF0aW9uVXRpbHNIb3N0LmNwcCIsCisgICAgXSwKKworICAgIGhlYWRlcl9saWJzOiBbCisgICAgICAgICJsaWJkeW5hbWljX2RlcHRoLWludGVybmFsX2hlYWRlcnMiLAorICAgICAgICAibGliZHluYW1pY19kZXB0aC1wdWJsaWNfaGVhZGVycyIsCisgICAgXSwKKworICAgIHNoYXJlZF9saWJzOiBbCisgICAgICAgICJsaWJiYXNlIiwKKyAgICAgICAgImxpYmJpbmRlciIsCisgICAgICAgICJsaWJjYW1lcmFfbWV0YWRhdGEiLAorICAgICAgICAibGliZHluYW1pY19kZXB0aCIsCisgICAgICAgICJsaWJleGlmIiwKKyAgICAgICAgImxpYmpwZWciLAorICAgICAgICAibGlibG9nIiwKKyAgICAgICAgImxpYnV0aWxzIiwKKyAgICAgICAgImxpYnhtbDIiLAorICAgIF0sCisKKyAgICBpbmNsdWRlX2RpcnM6IFsKKyAgICAgICAgImZyYW1ld29ya3MvYXYvY2FtZXJhL2luY2x1ZGUiLAorICAgICAgICAiZnJhbWV3b3Jrcy9hdi9jYW1lcmEvaW5jbHVkZS9jYW1lcmEiLAogICAgIF0sCiAKICAgICBleHBvcnRfaW5jbHVkZV9kaXJzOiBbIi4iXSwKZGlmZiAtLWdpdCBhL3NlcnZpY2VzL2NhbWVyYS9saWJjYW1lcmFzZXJ2aWNlL0NhbWVyYUZsYXNobGl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Q7CisgICAgfQorCisgICAgQUxPR1YoIiVzOiBzZXQgdG9yY2ggc3RyZW5ndGggb2YgY2FtZXJhICVzIHRvICVkIiwgX19GVU5DVElPTl9fLAorICAgICAgICAgICAgY2FtZXJhSWQuc3RyaW5nKCksIHRvcmNoU3RyZW5ndGgpOworICAgIHN0YXR1c190IHJlcyA9IE9LOworICAgIE11dGV4OjpBdXRvbG9jayBsKG1Mb2NrKTsKKworICAgIGlmIChtT3BlbmVkQ2FtZXJhSWRzLmluZGV4T2YoY2FtZXJhSWQpICE9IE5BTUVfTk9UX0ZPVU5EKSB7CisgICAgICAgIEFMT0dFKCIlczogQ2FtZXJhIGRldmljZSAlcyBpcyBpbiB1c2UsIGNhbm5vdCBiZSB0dXJuZWQgT04uIiwKKyAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIGNhbWVyYUlkLnN0cmluZygpKTsKKyAgICAgICAgcmV0dXJuIC1FQlVTWTsKKyAgICB9CisKKyAgICBpZiAobUZsYXNoQ29udHJvbCA9PSBOVUxMKSB7CisgICAgICAgIHJlcyA9IGNyZWF0ZUZsYXNobGlnaHRDb250cm9sKGNhbWVyYUlkKTsKKyAgICAgICAgaWYgKHJlcykgeworICAgICAgICAgICAgcmV0dXJuIHJlczsKKyAgICAgICAgfQorICAgIH0KKworICAgIHJlcyA9IG1GbGFzaENvbnRyb2wtPnR1cm5PblRvcmNoV2l0aFN0cmVuZ3RoTGV2ZWwoY2FtZXJhSWQsIHRvcmNoU3RyZW5ndGgpOworICAgIHJldHVybiByZXM7Cit9CisKKworc3RhdHVzX3QgQ2FtZXJhRmxhc2hsaWdodDo6Z2V0VG9yY2hTdHJlbmd0aExldmVsKGNvbnN0IFN0cmluZzgmIGNhbWVyYUlkLAorICAgICAgICAgICAgaW50MzJfdCogdG9yY2hTdHJlbmd0aCkgeworICAgIHN0YXR1c190IHJlcyA9IE9LOworICAgIGlmICghbUZsYXNobGlnaHRNYXBJbml0aWFsaXplZCkgeworICAgICAgICBBT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cnN0OworICAgICAgICBzd2l0Y2goZGV2aWNlVmVyc2lvbikgeworICAgICAgICAgICAgY2FzZSBDQU1FUkFfREVWSUNFX0FQSV9WRVJTSU9OXzFfMDoKKyAgICAgICAgICAgICAgICBBTE9HRSgiQ2FtZXJhIHVzaW5nIG9sZCBIQUwgdmVyc2lvbjogJWQiLCBkZXZpY2VWZXJzaW9uKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gU1RBVFVTX0VSUk9SX0ZNVChFUlJPUl9ERVBSRUNBVEVEX0hBTCwKKyAgICAgICAgICAgICAgICAgICAgICAgICJDYW1lcmEgZGV2aWNlIFwiJXNcIiBIQUwgdmVyc2lvbiAlZCBubyBsb25nZXIgc3VwcG9ydGVkIiwKKyAgICAgICAgICAgICAgICAgICAgICAgIGNhbWVyYUlkLnN0cmluZygpLCBkZXZpY2VWZXJzaW9uKTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgQ0FNRVJBX0RFVklDRV9BUElfVkVSU0lPTl8zXzA6CisgICAgICAgICAgICBjYXNlIENBTUVSQV9ERVZJQ0VfQVBJX1ZFUlNJT05fM18xOgorICAgICAgICAgICAgY2FzZSBDQU1FUkFfREVWSUNFX0FQSV9WRVJTSU9OXzNfMjoKKyAgICAgICAgICAgIGNhc2UgQ0FNRVJBX0RFVklDRV9BUElfVkVSU0lPTl8zXzM6CisgICAgICAgICAgICBjYXNlIENBTUVSQV9ERVZJQ0VfQVBJX1ZFUlNJT05fM180OgorICAgICAgICAgICAgY2FzZSBDQU1FUkFfREVWSUNFX0FQSV9WRVJTSU9OXzNfNToKKyAgICAgICAgICAgIGNhc2UgQ0FNRVJBX0RFVklDRV9BUElfVkVSU0lPTl8zXzY6CisgICAgICAgICAgICBjYXNlIENBTUVSQV9ERVZJQ0VfQVBJX1ZFUlNJT05fM183OgorICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICAvLyBT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zdCBTdHJpbmc4JiBwYWNrYWdlTmFtZSwKLSAgICAgICAgaW50IG9vbVNjb3JlT2Zmc2V0LAorICAgICAgICBpbnQgb29tU2NvcmVPZmZzZXQsIGJvb2wgc3lzdGVtTmF0aXZlQ2xpZW50LAogICAgICAgICAvKm91dCovCiAgICAgICAgIHNwPEJhc2ljQ2xpZW50PiogY2xpZW50LAogICAgICAgICBzdGQ6OnNoYXJlZF9wdHI8cmVzb3VyY2VfcG9saWN5OjpDbGllbnREZXNjcmlwdG9yPFN0cmluZzgsIHNwPEJhc2ljQ2xpZW50Pj4+KiBwYXJ0aWFsKSB7CkBAIC0xMzM0LDcgKzEzOTYsNyBAQAogICAgICAgICAgICAgICAgIGF1dG8gY2xpZW50U3AgPSBjdXJyZW50LT5nZXRWYWx1ZSgpOwogICAgICAgICAgICAgICAgIGlmIChjbGllbnRTcC5nZXQoKSAhPSBudWxscHRyKSB7IC8vIHNob3VsZCBuZXZlciBiZSBuZWVkZWQKICAgICAgICAgICAgICAgICAgICAgaWYgKCFjbGllbnRTcC0+Y2FuQ2FzdFRvQXBpQ2xpZW50KGVmZmVjdGl2ZUFwaUxldmVsKSkgewotICAgICAgICAgICAgICAgICAgICAgICAgQUxPR1coIkNhbWVyYVNlcnZpY2UgY29ubmVjdCBjYWxsZWQgZnJvbSBzYW1lIGNsaWVudCwgYnV0IHdpdGggYSBkaWZmZXJlbnQiCisgICAgICAgICAgICAgICAgICAgICAgICBBTE9HVygiQ2FtZXJhU2VydmljZSBjb25uZWN0IGNhbGxlZCB3aXRoIGEgZGlmZmVyZW50IgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiIEFQSSBsZXZlbCwgZXZpY3RpbmcgcHJpb3IgY2xpZW50Li4uIik7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoY2xpZW50U3AtPmdldFJlbW90ZSgpID09IHJlbW90ZUNhbGxiYWNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICBBTE9HSSgiQ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SwKLSAgICAgICAgICAgIGVmZmVjdGl2ZUFwaUxldmVsLCBpc05kaywgb3BlbkxhdGVuY3lNcyk7CisgICAgICAgICAgICBlZmZlY3RpdmVBcGlMZXZlbCwgaXNOb25TeXN0ZW1OZGssIG9wZW5MYXRlbmN5TXMpOworCisgICAgeworICAgICAgICBNdXRleDo6QXV0b2xvY2sgbG9jayhtSW5qZWN0aW9uUGFyYW1ldGVyc0xvY2spOworICAgICAgICBpZiAoY2FtZXJhSWQgPT0gbUluamVjdGlvbkludGVybmFsQ2FtSWQgJiYgbUluamVjdGlvbkluaXRQZW5kaW5nKSB7CisgICAgICAgICAgICBtSW5qZWN0aW9uSW5pdFBlbmRpbmcgPSBmYWxzZTsKKyAgICAgICAgICAgIHN0YXR1c190IHJlcyA9IE5PX0VSUk9SOworICAgICAgICAgICAgYXV0byBjbGllbnREZXNjcmlwdG9yID0gbUFjdGl2ZUNsaWVudE1hbmFnZXIuZ2V0KG1JbmplY3Rpb25JbnRlcm5hbENhbUlkKTsKKyAgICAgICAgICAgIGlmIChjbGllbnREZXNjcmlwdG9yICE9IG51bGxwdHIpIHsKKyAgICAgICAgICAgICAgICBzcDxCYXNpY0NsaWVudD4gY2xpZW50U3AgPSBjbGllbnREZXNjcmlwdG9yLT5nZXRWYWx1ZSgpOworICAgICAgICAgICAgICAgIHJlcyA9IGNoZWNrSWZJbmplY3Rpb25DYW1lcmFJc1ByZXNlbnQobUluamVjdGlvbkV4dGVybmFsQ2FtSWQsIGNsaWVudFNwKTsKKyAgICAgICAgICAgICAgICBpZihyZXMgIT0gT0spIHsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFNUQVRVU19FUlJPUl9GTVQoRVJST1JfRElTQ09OTkVDVEVELAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICJObyBjYW1lcmEgZGV2aWNlIHdpdGggSUQgXCIlc1wiIGN1cnJlbnRseSBhdmFpbGFibGUiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1JbmplY3Rpb25FeHRlcm5hbENhbUlkLnN0cmluZygpKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgcmVzID0gY2xpZW50U3AtPmluamVjdENhbWVyYShtSW5qZWN0aW9uRXh0ZXJuYWxDYW1JZCwgbUNhbWVyYVByb3ZpZGVyTWFuYWdlcik7CisgICAgICAgICAgICAgICAgaWYgKHJlcyAhPSBPSykgeworICAgICAgICAgICAgICAgICAgICBtSW5qZWN0aW9uU3RhdHVzTGlzdGVuZXItPm5vdGlmeUluamVjdGlvbkVycm9yKG1JbmplY3Rpb25FeHRlcm5hbENhbUlkLCByZXMpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgQUxPR0UoIiVzOiBJbnRlcm5hbCBjYW1lcmEgSUQgPSAlcyAncyBjbGllbnQgZG9lcyBub3QgZXhpc3QhIiwKKyAgICAgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgbUluamVjdGlvbkludGVybmFsQ2FtSWQuc3RyaW5nKCkpOworICAgICAgICAgICAgICAgIHJlcyA9IE5PX0lOSVQ7CisgICAgICAgICAgICAgICAgbUluamVjdGlvblN0YXR1c0xpc3RlbmVyLT5ub3RpZnlJbmplY3Rpb25FcnJvcihtSW5qZWN0aW9uRXh0ZXJuYWxDYW1JZCwgcmVzKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KIAogICAgIHJldHVybiByZXQ7CiB9CkBAIC0xOTI0LDcgKzIwMjAsOCBAQAogICAgICAgICAgICAgICAgIGtPZmZsaW5lRGV2aWNlICsgb25saW5lQ2xpZW50RGVzYy0+Z2V0S2V5KCksIG9mZmxpbmVDbGllbnQsIC8qY29zdCovIDAsCiAgICAgICAgICAgICAgICAgLypjb25mbGljdGluZ0tleXMqLyBzdGQ6OnNldDxTdHJpbmc4PigpLCBvbmxpbmVQcmlvcml0eS5nZXRTY29yZSgpLAogICAgICAgICAgICAgICA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oU3RhdHVzTG9ja2VkKGlkLCAmc3RhdHVzKTsKKyAgICAgICAgaWYgKGVyciAhPSBPSykgeworICAgICAgICAgICAgaWYgKGVyciA9PSBOQU1FX05PVF9GT1VORCkgeworICAgICAgICAgICAgIHJldHVybiBTVEFUVVNfRVJST1JfRk1UKEVSUk9SX0lMTEVHQUxfQVJHVU1FTlQsCisgICAgICAgICAgICAgICAgICAgICJDYW1lcmEgXCIlc1wiIGRvZXMgbm90IGhhdmUgYSBmbGFzaCB1bml0IiwgaWQuc3RyaW5nKCkpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgQUxPR0UoIiVzOiBnZXR0aW5nIGN1cnJlbnQgdG9yY2ggc3RhdHVzIGZhaWxlZCBmb3IgY2FtZXJhICVzIiwKKyAgICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fLCBpZC5zdHJpbmcoKSk7CisgICAgICAgICAgICByZXR1cm4gU1RBVFVTX0VSUk9SX0ZNVChFUlJPUl9JTlZBTElEX09QRVJBVElPTiwKKyAgICAgICAgICAgICAgICAgICAgIkVycm9yIGNoYW5naW5nIHRvcmNoIHN0cmVuZ3RoIGxldmVsIGZvciBjYW1lcmEgXCIlc1wiOiAlcyAoJWQpIiwKKyAgICAgICAgICAgICAgICAgICAgaWQuc3RyaW5nKCksIHN0cmVycm9yKC1lcnIpLCBlcnIpOworICAgICAgICB9CisKKyAgICAgICAgaWYgKHN0YXR1cyA9PSBUb3JjaE1vZGVTdGF0dXM6Ok5PVF9BVkFJTEFCTEUpIHsKKyAgICAgICAgICAgIGlmIChjYW1lcmFTdGF0dXMgPT0gU3RhdHVzSW50ZXJuYWw6Ok5PVF9BVkFJTEFCTEUpIHsKKyAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IHRvcmNoIG1vZGUgb2YgY2FtZXJhICVzIGlzIG5vdCBhdmFpbGFibGUgYmVjYXVzZSAiCisgICAgICAgICAgICAgICAgICAgICAgICAiY2FtZXJhIGlzIGluIHVzZS4iLCBfX0ZVTkNUSU9OX18sIGlkLnN0cmluZygpKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gU1RBVFVTX0VSUk9SX0ZNVChFUlJPUl9DQU1FUkFfSU5fVVNFLAorICAgICAgICAgICAgICAgICAgICAgICAgIlRvcmNoIGZvciBjYW1lcmEgXCIlc1wiIGlzIG5vdCBhdmFpbGFibGUgZHVlIHRvIGFuIGV4aXN0aW5nIGNhbWVyYSB1c2VyIiwKKyAgICAgICAgICAgICAgICAgICAgICAgIGlkLnN0cmluZygpKTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgQUxPR0UoIiVzOiB0b3JjaCBtb2RlIG9mIGNhbWVyYSAlcyBpcyBub3QgYXZhaWxhYmxlIGR1ZSB0byAiCisgICAgICAgICAgICAgICAgICAgICAgICJpbnN1ZmZpY2llbnQgcmVzb3VyY2VzIiwgX19GVU5DVElPTl9fLCBpZC5zdHJpbmcoKSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIFNUQVRVU19FUlJPUl9GTVQoRVJST1JfTUFYX0NBTUVSQVNfSU5fVVNFLAorICAgICAgICAgICAgICAgICAgICAgICAgIlRvcmNoIGZvciBjYW1lcmEgXCIlc1wiIGlzIG5vdCBhdmFpbGFibGUgZHVlIHRvIGluc3VmZmljaWVudCByZXNvdXJjZXMiLAorICAgICAgICAgICAgICAgICAgICAgICAgaWQuc3RyaW5nKCkpOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgfQorCisgICAgeworICAgICAgICBNdXRleDo6QXV0b2xvY2sgYWwobVRvcmNoVWlkTWFwTXV0ZXgpOworICAgICAgICB1cGRhdGVUb3JjaFVpZE1hcExvY2tlZChjYW1lcmFJZCwgdWlkKTsKKyAgICB9CisgICAgLy8gQ2hlY2sgaWYgdGhlIGN1cnJlbnQgdG9yY2ggc3RyZW5ndGggbGV2ZWwgaXMgc2FtZSBhcyB0aGUgbmV3IG9uZS4KKyAgICBib29sIHNob3VsZFNraXBUb3JjaFN0cmVuZ3RoVXBkYXRlcyA9IG1DYW1lcmFQcm92aWRlck1hbmFnZXItPnNob3VsZFNraXBUb3JjaFN0cmVuZ3RoVXBkYXRlKAorICAgICAgICAgICAgaWQuc3RyaW5nKCksIHRvcmNoU3RyZW5ndGgpOworCisgICAgc3RhdHVzX3QgZXJyID0gbUZsYXNobGlnaHQtPnR1cm5PblRvcmNoV2l0aFN0cmVuZ3RoTGV2ZWwoaWQsIHRvcmNoU3RyZW5ndGgpOworCisgICAgaWYgKGVyciAhPSBPSykgeworICAgICAgICBpbnQzMl90IGVycm9yQ29kZTsKKyAgICAgICAgU3RyaW5nOCBtc2c7CisgICAgICAgIHN3aXRjaCAoZXJyKSB7CisgICAgICAgICAgICBjYXNlIC1FTk9TWVM6CisgICAgICAgICAgICAgICAgbXNnID0gU3RyaW5nODo6Zm9ybWF0KCJDYW1lcmEgXCIlc1wiIGhhcyBubyBmbGFzaGxpZ2h0LiIsCisgICAgICAgICAgICAgICAgICAgIGlkLnN0cmluZygpKTsKKyAgICAgICAgICAgICAgICBlcnJvckNvZGUgPSBFUlJPUl9JTExFR0FMX0FSR1VNRU5UOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSAtRUJVU1k6CisgICAgICAgICAgICAgICAgbXNnID0gU3RyaW5nODo6Zm9ybWF0KCJDYW1lcmEgXCIlc1wiIGlzIGluIHVzZSIsCisgICAgICAgICAgICAgICAgICAgIGlkLnN0cmluZygpKTsKKyAgICAgICAgICAgICAgICBlcnJvckNvZGUgPSBFUlJPUl9DQU1FUkFfSU5fVVNFOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSAtRUlOVkFMOgorICAgICAgICAgICAgICAgIG1zZyA9IFN0cmluZzg6OmZvcm1hdCgiVG9yY2ggc3RyZW5ndGggbGV2ZWwgJWQgaXMgbm90IHdpdGhpbiB0aGUgIgorICAgICAgICAgICAgICAgICAgICAgICAgInZhbGlkIHJhbmdlLiIsIHR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uZFRyYW5zcG9ydC5zZWNvbmQgPT0gSVBDVHJhbnNwb3J0OjpISURMKSB7CisgICAgICAgIGludCBkZXZpY2VWZXJzaW9uID0gZGV2aWNlVmVyc2lvbkFuZFRyYW5zcG9ydC5maXJzdDsKKyAgICAgICAgc3dpdGNoIChkZXZpY2VWZXJzaW9uKSB7CisgICAgICAgICAgICBjYXNlIENBTUVSQV9ERVZJQ0VfQVBJX1ZFUlNJT05fMV8wOgorICAgICAgICAgICAgY2FzZSBDQU1FUkFfREVWSUNFX0FQSV9WRVJTSU9OXzNfMDoKKyAgICAgICAgICAgIGNhc2UgQ0FNRVJBX0RFVklDRV9BUElfVkVSU0lPTl8zXzE6CisgICAgICAgICAgICAgICAgaWYgKGFwaVZlcnNpb24gPT0gQVBJX1ZFUlNJT05fMikgeworICAgICAgICAgICAgICAgICAgICBBTE9HVigiJXM6IENhbWVyYSBpZCAlcyB1c2VzIEhBTCB2ZXJzaW9uICVkIDwzLjIsIGRvZXNuJ3Qgc3VwcG9ydCBhcGkyIHdpdGhvdXQgIgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICJzaGltIiwgX19GVU5DVElPTl9fLCBpZC5zdHJpbmcoKSwgZGV2aWNlVmVyc2lvbik7CisgICAgICAgICAgICAgICAgICAgICppc1N1cHBvcnRlZCA9IGZhbHNlOworICAgICAgICAgICAgICAgIH0gZWxzZSB7IC8vIGlmIChhcGlWZXJzaW9uID09IEFQSV9WRVJTSU9OXzEpIHsKKyAgICAgICAgICAgICAgICAgICAgQUxPR1YoIiVzOiBDYW1lcmEgaWQgJXMgdXNlcyBvbGRlciBIQUwgYmVmb3JlIDMuMiwgYnV0IGFwaTEgaXMgYWx3YXlzICIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAic3VwcG9ydGVkIiwgX19GVU5DVElPTl9fLCBpZC5zdHJpbmcoKSk7CisgICAgICAgICAgICAgICAgICAgICppc1N1cHBvcnRlZCA9IHRydWU7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBDQU1FUkFfREVWSUNFX0FQSV9WRVJTSU9OXzNfMjoKKyAgICAgICAgICAgIGNhc2UgQ0FNRVJBX0RFVklDRV9BUElfVkVSU0lPTl8zXzM6CisgICAgICAgICAgICBjYXNlIENBTUVSQV9ERVZJQ0VfQVBJX1ZFUlNJT05fM180OgorICAgICAgICAgICAgY2FzZSBDQU1FUkFfREVWSUNFX0FQSV9WRVJTSU9OXzNfNToKKyAgICAgICAgICAgIGNhc2UgQ0FNRVJBX0RFVklDRV9BUElfVkVSU0lPTl8zXzY6CisgICAgICAgICAgICBjYXNlIENBTUVSQV9ERVZJQ0VfQVBJX1ZFUlNJT05fM183OgorICAgICAgICAgICAgICAgIEFMT0dWKCIlczogQ2FtZXJhIGlkICVzIHVzZXMgSEFMMy4yIG9yIG5ld2VyLCBzdXBwb3J0cyBhcGkxL2FwaTIgZGlyZWN0bHkiLAogICAgICAgICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fLCBpZC5zdHJpbmcoKSk7CiAgICAgICAgICAgICAgICAgKmlzU3VwcG9ydGVkID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGRlZmF1bHQ6IHsKKyAgICAgICAgICAgICAgICBTdHJpbmc4IG1zZyA9IFN0cmluZzg6OmZvcm1hdCgiVW5rbm93biBkZXZpY2UgdmVyc2lvbiAleCBmb3IgZGV2aWNlICVzIiwKKyAgICAgICAgICAgICAgICAgICAgICAgIGRldmljZVZlcnNpb24sIGlkLnN0cmluZygpKTsKKyAgICAgICAgICAgICAgICBBTE9HRSgiJXM6ICVzIiwgX19GVU5DVElPTl9fLCBtc2cuc3RyaW5nKCkpOworICAgICAgICAgICAgICAgIHJldHVybiBTVEFUVVNfRVJST1IoRVJST1JfSU5WQUxJRF9PUEVSQVRJT04sIG1zZy5zdHJpbmcoKSk7CiAgICAgICAgICAgICB9Ci0gICAgICAgICAgICB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saWVudCBpcyBlc3RhYmxpc2hlZAorICAgICAgICAvLyAoZXhlY3V0ZSBjb25uZWN0SGVscGVyKCkpIGJlZm9yZSBpbmplY3RpbmcgdGhlIGNhbWVyYSB0byB0aGUgY2FtZXJhIGRldmljZS4KKyAgICAgICAgaWYgKGNsaWVudERlc2NyaXB0b3IgIT0gbnVsbHB0cikgeworICAgICAgICAgICAgbUluamVjdGlvbkluaXRQZW5kaW5nID0gZmFsc2U7CisgICAgICAgICAgICBzcDxCYXNpY0NsaWVudD4gY2xpZW50U3AgPSBjbGllbnREZXNjcmlwdG9yLT5nZXRWYWx1ZSgpOworICAgICAgICAgICAgcmVzID0gY2hlY2tJZkluamVjdGlvbkNhbWVyYUlzUHJlc2VudChtSW5qZWN0aW9uRXh0ZXJuYWxDYW1JZCwgY2xpZW50U3ApOworICAgICAgICAgICAgaWYocmVzICE9IE9LKSB7CisgICAgICAgICAgICAgICAgcmV0dXJuIFNUQVRVU19FUlJPUl9GTVQoRVJST1JfRElTQ09OTkVDVEVELAorICAgICAgICAgICAgICAgICAgICAgICAgIk5vIGNhbWVyYSBkZXZpY2Ugd2l0aCBJRCBcIiVzXCIgY3VycmVudGx5IGF2YWlsYWJsZSIsCisgICAgICAgICAgICAgICAgICAgICAgICBtSW5qZWN0aW9uRXh0ZXJuYWxDYW1JZC5zdHJpbmcoKSk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICByZXMgPSBjbGllbnRTcC0+aW5qZWN0Q2FtZXJhKG1JbmplY3Rpb25FeHRlcm5hbENhbUlkLCBtQ2FtZXJhUHJvdmlkZXJNYW5hZ2VyKTsKKyAgICAgICAgICAgIGlmKHJlcyAhPSBPSykgeworICAgICAgICAgICAgICAgIG1JbmplY3Rpb25TdGF0dXNMaXN0ZW5lci0+bm90aWZ5SW5qZWN0aW9uRXJyb3IobUluamVjdGlvbkV4dGVybmFsQ2FtSWQsIHJlcyk7CisgICAgICAgICAgICB9CisgICAgICAgIH0gZWxzZSB7CisgICAgICAg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gICAgICAgICAgICAgICAgICAgaW5qZWN0ZWRDYW1JZC5zdHJpbmcoKSk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSAtRUJVU1k6CisgICAgICAgICAgICBtQ2FtZXJhSW5qZWN0aW9uQ2FsbGJhY2stPm9uSW5qZWN0aW9uRXJyb3IoCisgICAgICAgICAgICAgICAgICAgIElDYW1lcmFJbmplY3Rpb25DYWxsYmFjazo6RVJST1JfSU5KRUNUSU9OX1NFU1NJT04pOworICAgICAgICAgICAgQUxPR0UoIkhpZ2hlci1wcmlvcml0eSBjbGllbnQgdXNpbmcgY2FtZXJhLCBJRCBcIiVzXCIgY3VycmVudGx5IHVuYXZhaWxhYmxlISIsCisgICAgICAgICAgICAgICAgICAgIGluamVjdGVkQ2FtSWQuc3RyaW5nKCkpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgREVBRF9PQkpFQ1Q6CisgICAgICAgICAgICBtQ2FtZXJhSW5qZWN0aW9uQ2FsbGJhY2stPm9uSW5qZWN0aW9uRXJyb3IoCisgICAgICAgICAgICAgICAgICAgIElDYW1lcmFJbmplY3Rpb25DYWxsYmFjazo6RVJST1JfSU5KRUNUSU9OX1NFU1NJT04pOworICAgICAgICAgICAgQUxPR0UoIkNhbWVyYSBJRCBcIiVzXCIgb2JqZWN0IGlzIGRlYWQhIiwKKyAgICAgICAgICAgICAgICAgICAgaW5qZWN0ZWRDYW1JZC5zdHJpbmcoKSk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBJTlZBTElEX09QRVJBVElPTjoKKyAgICAgICAgICAgIG1DYW1lcmFJbmplY3Rpb25DYWxsYmFjay0+b25JbmplY3Rpb25FcnJvcigKKyAgICAgICAgICAgICAgICAgICAgSUNhbWVyYUluamVjdGlvbkNhbGxiYWNrOjpFUlJPUl9JTkpFQ1RJT05fU0VTU0lPTik7CisgICAgICAgICAgICBBTE9HRSgiQ2FtZXJhIElEIFwiJXNcIiBlbmNvdW50ZXJlZCBhbiBvcGVyYXRpbmcgb3IgaW50ZXJuYWwgZXJyb3IhIiwKKyAgICAgICAgICAgICAgICAgICAgaW5qZWN0ZWRDYW1JZC5zdHJpbmcoKSk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBVTktOT1dOX1RSQU5TQUNUSU9OOgorICAgICAgICAgICAgbUNhbWVyYUluamVjdGlvbkNhbGxiYWNrLT5vbkluamVjdGlvbkVycm9yKAorICAgICAgICAgICAgICAgICAgICBJQ2FtZXJhSW5qZWN0aW9uQ2FsbGJhY2s6OkVSUk9SX0lOSkVDVElPTl9VTlNVUFBPUlRFRCk7CisgICAgICAgICAgICBBTE9HRSgiQ2FtZXJhIElEIFwiJXNcIiBtZXRob2QgZG9lc24ndCBzdXBwb3J0ISIsCisgICAgICAgICAgICAgICAgICAgIGluamVjdGVkQ2FtSWQuc3RyaW5nKCkpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICBtQ2FtZXJhSW5qZWN0aW9uQ2FsbGJhY2stPm9uSW5qZWN0aW9uRXJyb3IoCisgICAgICAgICAgICAgICAgICAgIElDYW1lcmFJbmplY3Rpb25DYWxsYmFjazo6RVJST1JfSU5KRUNUSU9OX0lOVkFMSURfRVJST1IpOworICAgICAgICAgICAgQUxPR0UoIlVuZXhwZWN0ZWQgZXJyb3IgJXMgKCVkKSBvcGVuaW5nIGNhbWVyYSBcIiVzXCIhIiwKKyAgICAgICAgICAgICAgICAgICAgc3RyZXJyb3IoLWVyciksIGVyciwgaW5qZWN0ZWRDYW1JZC5zdHJpbmcoKSk7CisgICAgfQogfQogCiB2b2lkIENhbWVyYVNlcnZpY2U6OkluamVjdGlvblN0YXR1c0xpc3RlbmVyOjpiaW5kZXJEaWVkKAogICAgICAgICBjb25zdCB3cDxJQmluZGVyPiYgLyp3aG8qLykgewotICAgIE11dGV4OjpBdXRvbG9jayBsb2NrKG1MaXN0ZW5lckxvY2spOwog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aWRlZCB0YWdzIGZvciBjbGllbnRzIHdpdGggcHJvdmlkZWQgcGFja2FnZVxuIgorICAgICAgICAgICAgICAgICAiICAgICAgICByZWNvZ25pemVzIHRhZyBzaG9ydGhhbmRzIGxpa2UgJzNhJ1xuIgorICAgICAgICAgICAgICAgICAiICAgICAgICB3YXRjaGVzIGFsbCBjbGllbnRzIGlmIG5vIGNsaWVudCBpcyBwYXNzZWQsIG9yIGlmICdhbGwnIGlzIGxpc3RlZFxuIgorICAgICAgICAgICAgICAgICAiICBkdW1wIGR1bXBzIHRoZSBtb25pdG9yaW5nIGluZm9ybWF0aW9uIGFuZCBleGl0c1xuIgorICAgICAgICAgICAgICAgICAiICBzdG9wIHN0b3BzIHdhdGNoaW5nIGFsbCB0YWdzXG4iCisgICAgICAgICAgICAgICAgICIgIGxpdmUgWy1uIDxyZWZyZXNoX2ludGVydmFsX21zPl1cbiIKKyAgICAgICAgICAgICAgICAgIiAgICAgICAgcHJpbnRzIHRoZSBtb25pdG9yZWQgaW5mb3JtYXRpb24gaW4gcmVhbCB0aW1lXG4iCisgICAgICAgICAgICAgICAgICIgICAgICAgIEhpdCByZXR1cm4gdG8gZXhpdFxuIgorICAgICAgICAgICAgICAgICAiICBjbGVhciBjbGVhcnMgYWxsIGJ1ZmZlcnMgc3RvcmluZyBpbmZvcm1hdGlvbiBmb3Igd2F0Y2ggY29tbWFuZCIpOworICByZXR1cm4gQkFEX1ZBTFVFOworfQorCitzdGF0dXNfdCBDYW1lcmFTZXJ2aWNlOjpzdGFydFdhdGNoaW5nVGFncyhjb25zdCBWZWN0b3I8U3RyaW5nMTY+ICZhcmdzLCBpbnQgb3V0RmQpIHsKKyAgICBNdXRleDo6QXV0b2xvY2sgbG9jayhtTG9nTG9jayk7CisgICAgc2l6ZV90IHRhZ3NJZHg7IC8vIGluZGV4IG9mICctbScKKyAgICBTdHJpbmcxNiB0YWdzKCIiKTsKKyAgICBmb3IgKHRhZ3NJZHggPSAyOyB0YWdzSWR4IDwg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8gY2FtZXJhQ2xpZW50cyA9IG1BY3RpdmVDbGllbnRNYW5hZ2VyLmdldEFsbCgpOworICAgIGZvciAoY29uc3QgYXV0byAmY2xpZW50RGVzY3JpcHRvcjogY2FtZXJhQ2xpZW50cykgeworICAgICAgICBpZiAoY2xpZW50RGVzY3JpcHRvciA9PSBudWxscHRyKSB7IGNvbnRpbnVlOyB9CisgICAgICAgIHNwPEJhc2ljQ2xpZW50PiBjbGllbnQgPSBjbGllbnREZXNjcmlwdG9yLT5nZXRWYWx1ZSgpOworICAgICAgICBpZiAoY2xpZW50LmdldCgpID09IG51bGxwdHIpIHsgY29udGludWU7IH0KKworICAgICAgICBpZiAoaXNDbGllbnRXYXRjaGVkTG9ja2VkKGNsaWVudC5nZXQoKSkpIHsKKyAgICAgICAgICAgIGNsaWVudC0+c3RhcnRXYXRjaGluZ1RhZ3MobU1vbml0b3JUYWdzLCBvdXRGZCk7CisgICAgICAgICAgICBudW1XYXRjaGVkQ2xpZW50cysrOworICAgICAgICB9CisgICAgfQorICAgIGRwcmludGYob3V0RmQsICJTdGFydGVkIHdhdGNoaW5nICVkIGFjdGl2ZSBjbGllbnRzXG4iLCBudW1XYXRjaGVkQ2xpZW50cyk7CisKKyAgICBpZiAoc2VydmljZUxvY2spIHsgbVNlcnZpY2VMb2NrLnVubG9jaygpOyB9CisgICAgcmV0dXJuIE9LOworfQorCitzdGF0dXNfdCBDYW1lcmFTZXJ2aWNlOjpzdG9wV2F0Y2hpbmdUYWdzKGludCBvdXRGZCkgeworICAgIC8vIGNsZWFyIG1Nb25pdG9yVGFncyB0byBwcmV2ZW50IG5ldyBjbGllbnRzIGZyb20gbW9uaXRvcmluZyB0YWdzIGF0IGluaXRpYWxpemF0aW9uCisgICAgTXV0ZXg6OkF1dG9sb2NrIGxvY2sobUxvZ0xvY2spOworICAgIG1Nb25pdG9yVGFncyA9IFN0cmluZzg6OmVtcHR5KCk7CisKKyAgICBtV2F0Y2hlZENsaWVudFBhY2thZ2VzLmNs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xlYXJlZFNpemUpOworICAgIHJldHVybiBPSzsKK30KKworc3RhdHVzX3QgQ2FtZXJhU2VydmljZTo6cHJpbnRXYXRjaGVkVGFncyhpbnQgb3V0RmQpIHsKKyAgICBNdXRleDo6QXV0b2xvY2sgbG9nTG9jayhtTG9nTG9jayk7CisgICAgc3RkOjpzZXQ8U3RyaW5nMTY+IGNvbm5lY3RlZE1vbml0b3JlZENsaWVudHM7CisKKyAgICBib29sIHByaW50ZWRTb21ldGhpbmcgPSBmYWxzZTsgLy8gdHJhY2tzIGlmIGFueSBtb25pdG9yaW5nIGluZm9ybWF0aW9uIHdhcyBwcmludGVkCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIChmcm9tIGVpdGhlciBjYWNoZWQgb3IgYWN0aXZlIGNsaWVudHMpCisKKyAgICBib29sIHNlcnZpY2VMb2NrID0gdHJ5TG9jayhtU2VydmljZUxvY2spOworICAgIC8vIGdldCBhbGwgd2F0Y2hlZCBjbGllbnRzIHRoYXQgYXJlIGN1cnJlbnRseSBjb25uZWN0ZWQKKyAgICBmb3IgKGNvbnN0IGF1dG8gJmNsaWVudERlc2NyaXB0b3I6IG1BY3RpdmVDbGllbnRNYW5hZ2VyLmdldEFsbCgpKSB7CisgICAgICAgIGlmIChjbGllbnREZXNjcmlwdG9yID09IG51bGxwdHIpIHsgY29udGludWU7IH0KKworICAgICAgICBzcDxCYXNpY0NsaWVudD4gY2xpZW50ID0gY2xpZW50RGVzY3JpcHRvci0+Z2V0VmFsdWUoKTsKKyAgICAgICAgaWYgKGNsaWVudC5nZXQoKSA9PSBudWxscHRyKSB7IGNvbnRpbnVlOyB9CisgICAgICAgIGlmICghaXNDbGllbnRXYXRjaGVkTG9ja2VkKGNsaWVudC5nZXQoKSkpIHsgY29udGludWU7IH0KKworICAgICAgICBzdGQ6OnZlY3RvcjxzdGQ6OnN0cmluZz4gZHVtcFZlY3RvcjsKKyAgICAgICAgY2xpZW50LT5kdW1wV2F0Y2hlZEV2ZW50c1RvVmVjdG9yKGR1bXBWZWN0b3IpOworCisgICAgICAgIHNpemVfdCBwcmludElkeCA9IGR1bXBWZWN0b3Iuc2l6ZSgpOworICAgICAgICBpZiAocHJpbnRJZHggPT0gMCkgeworICAgICAgICAgICAgY29udGludWU7CisgICAgICAgIH0KKworICAgICAgICAvLyBQcmludCB0YWcgZHVtcHMgZm9yIGFjdGl2ZSBjbGllbnQKKyAgICAgICAgY29uc3QgU3RyaW5nOCAmY2FtZXJhSWQgPSBjbGllbnREZXNjcmlwdG9yLT5nZXRLZXkoKTsKKyAgICAgICAgU3RyaW5nOCBwYWNrYWdlTmFtZTggPSBTdHJpbmc4KGNsaWVudC0+Z2V0UGFja2FnZU5hbWUoKSk7CisgICAgICAgIGNvbnN0IGNoYXIgKnByaW50YWJsZVBhY2thZ2VOYW1lID0gcGFja2FnZU5hbWU4LmxvY2tCdWZmZXIocGFja2FnZU5hbWU4LnNpemUoKSk7CisgICAgICAgIGRwcmludGYob3V0RmQsICJDbGllbnQ6ICVzIChhY3RpdmUpXG4iLCBwcmludGFibGVQYWNrYWdlTmFtZSk7CisgICAgICAgIHdoaWxlKHByaW50SWR4ID4gMCkgeworICAgICAgICAgICAgcHJpbnRJZHgtLTsKKyAgICAgICAgICAgIGRwcmludGYob3V0RmQsICIlczolcyAgJXMiLCBjYW1lcmFJZC5zdHJpbmcoKSwgcHJpbnRhYmxlUGFja2FnZU5hbWUsCisgICAgICAgICAgICAgICAgICAgIGR1bXBWZWN0b3JbcHJpbnRJZHhdLmNfc3RyKCkpOworICAgICAgICB9CisgICAgICAgIGRwcmludGYob3V0RmQsICJcbiIpOworICAgICAgICBwYWNrYWdlTmFtZTgudW5sb2NrQnVmZmVyKCk7CisgICAgICAgIHByaW50ZWRTb21ldGhpbmcgPSB0cnVlOworCisgICAgICAgIGNvbm5lY3RlZE1vbml0b3JlZENsaWVudHMuZW1wbGFjZShjbGllbnQtPmdldFBhY2thZ2VOYW1lKCkpOworICAgIH0KKyAgICBpZiAoc2VydmljZUxvY2spIHsgbVNlcnZpY2VMb2NrLnVubG9jaygpOyB9CisKKyAgICAvLyBQcmludCBlbnRyaWVzIGluIG1XYXRjaGVkQ2xpZW50c0R1bXBDYWNoZSBmb3IgY2xpZW50cyB0aGF0IGFyZSBub3QgY29ubmVjdGVkCisgICAgZm9yIChjb25zdCBhdXRvICZrdjogbVdhdGNoZWRDbGllbnRzRHVtcENhY2hlKSB7CisgICAgICAgIGNvbnN0IFN0cmluZzE2ICZwYWNrYWdlID0ga3YuZmlyc3Q7CisgICAgICAgIGlmIChjb25uZWN0ZWRNb25pdG9yZWRDbGllbnRzLmZpbmQocGFja2FnZSkgIT0gY29ubmVjdGVkTW9uaXRvcmVkQ2xpZW50cy5lbmQoKSkgeworICAgICAgICAgICAgY29udGludWU7CisgICAgICAgIH0KKworICAgICAgICBkcHJpbnRmKG91dEZkLCAiQ2xpZW50OiAlcyAoY2FjaGVkKVxuIiwgU3RyaW5nOChwYWNrYWdlKS5zdHJpbmcoKSk7CisgICAgICAgIGRwcmludGYob3V0RmQsICIlc1xuIiwga3Yuc2Vjb25kLmNfc3RyKCkpOworICAgICAgICBwcmludGVkU29tZXRoaW5nID0gdHJ1ZTsKKyAgICB9CisKKyAgICBpZiAoIXByaW50ZWRTb21ldGhpbmcpIHsKKyAgICAgICAgZHByaW50ZihvdXRGZCwgIk5vIG1vbml0b3JpbmcgaW5mb3JtYXRpb24gdG8gcHJpbnQuXG4iKTsKKyAgICB9CisKKyAgICByZXR1cm4gT0s7Cit9CisKKy8vIFByaW50IGFsbCBldmVudHMgaW4gdmVjdG9yIGBldmVudHMnIHRoYXQgY2FtZSBhZnRlciBsYXN0UHJpbnRlZEV2ZW50Cit2b2lkIHByaW50TmV3V2F0Y2hlZEV2ZW50cyhpbnQgb3V0RmQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyICpjYW1lcmFJZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0I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ID0gUE9MTElOLCAucmV2ZW50cyA9IDAgfTsKKworICAgIHN0cnVjdCB0aW1ldmFsIGN1cnJUaW1lOworICAgIGNoYXIgYnVmZmVyWzJdOworICAgIHdoaWxlKHRydWUpIHsKKyAgICAgICAgaW50IGN1cnJUaW1lRXJyb3IgPSBnZXR0aW1lb2ZkYXkoJmN1cnJUaW1lLCBudWxscHRyKTsKKyAgICAgICAgaWYgKGN1cnJUaW1lRXJyb3IpIHsKKyAgICAgICAgICAgIGRwcmludGYob3V0RmQsICJGYWlsZWQgd2FpdGluZyBmb3IgaW50ZXJydXB0LCBhYm9ydGluZy5cbiIpOworICAgICAgICAgICAgcmV0dXJuIHRydWU7CisgICAgICAgIH0KKworICAgICAgICBsb25nIGVsYXBzZWRUaW1lTXMgPSAoKGN1cnJUaW1lLnR2X3NlYyAtIHN0YXJ0VGltZS50dl9zZWMpICogMTAwMEwpCisgICAgICAgICAgICAgICAgKyAoKGN1cnJUaW1lLnR2X3VzZWMgLSBzdGFydFRpbWUudHZfdXNlYykgLyAxMDAwTCk7CisgICAgICAgIGludCByZW1haW5pbmdUaW1lTXMgPSAoaW50KSAodGltZW91dE1zIC0gZWxhcHNlZFRpbWVNcyk7CisKKyAgICAgICAgaWYgKHJlbWFpbmluZ1RpbWVNcyA8PSAwKSB7CisgICAgICAgICAgICAvLyBObyB1c2VyIGludGVycnVwdCB3aXRoaW4gdGltZW91dE1zLCBkb24ndCBpbnRlcnJ1cHQgd2F0Y2ggY29tbWFuZAorICAgICAgICAgICAgcmV0dXJuIGZhbHNlOworICAgICAgICB9CisKKyAgICAgICAgaW50IG51bUZkc1VwZGF0ZWQgPSBwb2xsKCZwb2xsRmQsIG51bUZkcywgcmVtYWluaW5nVGltZU1zKTsKKyAgICAgICAgaWYgKG51bUZkc1VwZGF0ZWQgPCAwKSB7CisgICAgICAgICAgICBkcHJpbnRmKG91dEZkLCAiRmFpbGVkIHdoaWxlIHdhaXRpbmcgZm9yIHVzZXIgaW5wdXQuIEV4aXRpbmcuXG4iKTsKKyAgICAgICAgICAgIHJldHVybiB0cnVlOworICAgICAgICB9CisKKyAgICAgICAgaWYgKG51bUZkc1VwZGF0ZWQgPT0gMCkgeworICAgICAgICAgICAgLy8gTm8gdXNlciBpbnB1dCB3aXRoaW4gdGltZW91dE1zLCBkb24ndCBpbnRlcnJ1cHQgd2F0Y2ggY29tbWFuZAorICAgICAgICAgICAgcmV0dXJuIGZhbHNlOworICAgICAgICB9CisKKyAgICAgICAgaWYgKCEocG9sbEZkLnJldmVudHMgJiBQT0xMSU4pKSB7CisgICAgICAgICAgICBkcHJpbnRmKG91dEZkLCAiRmFpbGVkIHdoaWxlIHdhaXRpbmcgZm9yIHVzZXIgaW5wdXQuIEV4aXRpbmcuXG4iKTsKKyAgICAgICAgICAgIHJldHVybiB0cnVlOworICAgICAgICB9CisKKyAgICAgICAgc3NpemVfdCBzaXplUmVhZCA9IHJlYWQoaW5GZCwgYnVmZmVyLCBzaXplb2YoYnVmZmVyKSAtIDEpOworICAgICAgICBpZiAoc2l6ZVJlYWQgPCAwKSB7CisgICAgICAgICAgICBkcHJpbnRmKG91dEZkLCAiRXJyb3IgcmVhZGluZyB1c2VyIGlucHV0LiBFeGl0aW5nLlxuIik7CisgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKKyAgICAgICAgfQorCisgICAgICAgIGlmIChzaXplUmVhZCA9PSAwKSB7CisgICAgICAgICAgICAvLyBSZWFjaGVkIGVuZCBvZiBpbnB1dCBmZCAoY2FuIGhhcHBlbiBpZiBpbnB1dCBpcyBwaXBlZCkKKyAgICAgICAgICAgIC8vIFVzZXIgaGFzIG5vIHdheSB0byBzaWduYWwgYW4gaW50ZXJydXB0LCBzbyBpbnRlcnJ1cHQgaGVyZQorICAgICAgICAgICAgcmV0dXJuIHRydWU7CisgICAgICAgIH0KKworICAgICAgICBpZiAoYnVmZmVyWzBdID09ICdcbicpIHsKKyAgICAgICAgICAgIC8vIFVzZXIgcHJlc3NlZCByZXR1cm4sIGludGVycnVwdCB3YXRjaCBjb21tYW5kLgorICAgICAgICAgICAgcmV0dXJuIHRydWU7CisgICAgICAgIH0KKyAgICB9Cit9CisKK3N0YXR1c190IENhbWVyYVNlcnZpY2U6OnByaW50V2F0Y2hlZFRhZ3NVbnRpbEludGVycnVwdChjb25zdCBWZWN0b3I8U3RyaW5nMTY+ICZhcmdzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCBpbkZkLCBpbnQgb3V0RmQpIHsKKyAgICAvLyBGaWd1cmUgb3V0IHJlZnJlc2ggaW50ZXJ2YWwsIGlmIHByZXNlbnQgaW4gYXJncworICAgIGxvbmcgcmVmcmVzaFRpbWVvdXRNcyA9IDEwMDBMOyAvLyByZWZyZXNoIGV2ZXJ5IDFzIGJ5IGRlZmF1bHQKKyAgICBpZiAoYXJncy5zaXplKCkgPiAyKSB7CisgICAgICAgIHNpemVfdCBpbnRlcnZhbElkeDsgLy8gaW5kZXggb2YgJy1uJworICAgICAgICBmb3IgKGludGVydmFsSWR4ID0gMjsgaW50ZXJ2YWxJZHggPCBhcmdzLnNpemUoKSAmJiBTdHJpbmcxNigiLW4iKSAhPSBhcmdzW2ludGVydmFsSWR4XTsKKyAgICAgICAgICAgICBpbnRlcnZhbElkeCsrKTsKKworICAgICAgICBzaXplX3QgaW50ZXJ2YWxWYWxJZHggPSBpbnRlcnZhbElkeCArIDE7CisgICAgICAgIGlmIChpbnRlcnZhbFZhbElkeCA8IGFyZ3Muc2l6ZSgpKSB7CisgICAgICAgICAgICByZWZyZXNoVGltZW91dE1zID0gc3RydG9sKFN0cmluZzgoYXJnc1tpbnRlcnZhbFZhbElkeF0uc3RyaW5nKCkpLCBudWxscHRyLCAxMCk7CisgICAgICAgICAgICBpZiAoZXJybm8pIHsgcmV0dXJuIEJBRF9WQUxVRTsgfQorICAgICAgICB9CisgICAgfQorCisgICAgLy8gU2V0IG1pbiB0aW1lb3V0IG9mIDEwbXMuIFRoaXMgcHJldmVudHMgZWRnZSBjYXNlcyBpbiBwb2xsaW5nIHdoZW4gdGltZW91dCBvZiAwIGlzIHBhc3NlZC4KKyAgICByZWZyZXNoVGltZW91dE1zID0gcmVmcmVzaFRpbWVvdXRNcyA8IDEwID8gMTAgOiByZWZyZXNoVGltZW91dE1zOworCisgICAgZHByaW50ZihvdXRGZCwgIlByZXNzIHJldHVybiB0byBleGl0Li4uXG5cbiIpOworICAgIHN0ZDo6bWFwPFN0cmluZzE2LCBzdGQ6OnN0cmluZz4gcGFja2FnZU5hbWVUb0xhc3RFdmVudDsKKworICAgIHdoaWxlICh0cnVlKSB7CisgICAgICAgIGJvb2wgc2VydmljZUxvY2sgPSB0cnlMb2NrKG1TZXJ2aWNlTG9jayk7CisgICAgICAgIGF1dG8gY2FtZXJhQ2xpZW50cyA9IG1BY3RpdmVDbGllbnRNYW5hZ2VyLmdldEFsbCgpOworICAgICAgICBpZiAoc2VydmljZUxvY2spIHsgbVNlcnZpY2VMb2NrLnVubG9jaygpOyB9CisKKyAgICAgICAgZm9yIChjb25zdCBhdXRvJiBjbGllbnREZXNjcmlwdG9yIDogY2FtZXJhQ2xpZW50cykgeworICAgICAgICAgICAgTXV0ZXg6OkF1dG9sb2NrIGxvY2sobUxvZ0xvY2spOworICAgICAgICAgICAgaWYgKGNsaWVudERlc2NyaXB0b3IgPT0gbnVsbHB0cikgeyBjb250aW51ZTsgfQorCisgICAgICAgICAgICBzcDxCYXNpY0NsaWVudD4gY2xpZW50ID0gY2xpZW50RGVzY3JpcHRvci0+Z2V0VmFsdWUoKTsKKyAgICAgICAgICAgIGlmIChjbGllbnQuZ2V0KCkgPT0gbnVsbHB0cikgeyBjb250aW51ZTsgfQorICAgICAgICAgICAgaWYgKCFpc0NsaWVudFdhdGNoZWRMb2NrZWQoY2xpZW50LmdldCgpKSkgeyBjb250aW51ZTsgfQorCisgICAgICAgICAgICBjb25zdCBTdHJpbmcxNiAmcGFja2FnZU5hbWUgPSBjbGllbnQtPmdldFBhY2thZ2VOYW1lKCk7CisgICAgICAgICAgICAvLyBUaGlzIGFsc28gaW5pdGlhbGl6ZXMgdGhlIG1hcCBlbnRyaWVzIHdpdGggYW4gZW1wdHkgc3RyaW5nCisgICAgICAgICAgICBjb25zdCBzdGQ6OnN0cmluZyYgbGFzdFByaW50ZWRFdmVudCA9IHBhY2thZ2VOYW1lVG9MYXN0RXZlbnRbcGFja2FnZU5hbWVdOworCisgICAgICAgICAgICBzdGQ6OnZlY3RvcjxzdGQ6OnN0cmluZz4gbGF0ZXN0RXZlbnRzOworICAgICAgICAgICAgY2xpZW50LT5kdW1wV2F0Y2hlZEV2ZW50c1RvVmVjdG9yKGxhdGVzdEV2ZW50cyk7CisKKyAgICAgICAgICAgIGlmICghbGF0ZXN0RXZlbnRzLmVtcHR5KCkpIHsKKyAgICAgICAgICAgICAgICBTdHJpbmc4IGNhbWVyYUlkID0gY2xpZW50RGVzY3JpcHRvci0+Z2V0S2V5KCk7CisgICAgICAgICAgICAgICAgY29uc3QgY2hhciAqcHJpbnRhYmxlQ2FtZXJhSWQgPSBjYW1lcmFJZC5sb2NrQnVmZmVyKGNhbWVyYUlkLnNpemUoKSk7CisgICAgICAgICAgICAgICAgcHJpbnROZXdXYXRjaGVkRXZlbnRzKG91dEZkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmludGFibGVDYW1lcmFJZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFja2FnZU5hbWUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxhdGVzdEV2ZW50cywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGFzdFByaW50ZWRFdmVudCk7CisgICAgICAgICAgICAgICAgcGFja2FnZU5hbWVUb0xhc3RFdmVudFtwYWNrYWdlTmFtZV0gPSBsYXRlc3RFdmVudHNbMF07CisgICAgICAgICAgICAgICAgY2FtZXJhSWQudW5sb2NrQnVmZmVyKCk7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICAgICAgaWYgKHNob3VsZEludGVycnVwdFdhdGNoQ29tbWFuZChpbkZkLCBvdXRGZCwgcmVmcmVzaFRpbWVvdXRNcykpIHsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CisgICAgfQorICAgIHJldHVybiBPSzsKK30KKwordm9pZCBDYW1lcmFTZXJ2aWNlOjpwYXJzZUNsaWVudHNUb1dhdGNoTG9ja2VkKFN0cmluZzggY2xpZW50cykgeworICAgIG1XYXRjaGVkQ2xpZW50UGFja2FnZXMuY2xlYXIoKTsKKworICAgIGNvbnN0IGNoYXIgKmFsbFNlbnRpbmVsID0gU3RyaW5nOChrV2F0Y2hBbGxDbGllbnRzRmxhZykuc3RyaW5nKCk7CisKKyAgICBjaGFyICp0b2tlbml6ZWQgPSBjbGllbnRzLmxvY2tCdWZmZXIoY2xpZW50cy5zaXplKCkpOworICAgIGNoYXIgKnNhdmVQdHI7CisgICAgY2hhciAqbmV4dENsaWVudCA9IHN0cnRva19yKHRva2VuaXplZCwgIiwiLCAmc2F2ZVB0cik7CisKKyAgICB3aGlsZSAobmV4dENsaWVudCAhPSBudWxscHRyKSB7CisgICAgICAgIGlmIChzdHJjbXAobmV4dENsaWVudCwgYWxsU2VudGluZWwpID09IDApIHsKKyAgICAgICAgICAgIC8vIERvbid0IG5lZWQgdG8gdHJhY2sgYW55IG90aGVyIHBhY2thZ2UgaWYgJ2FsbCcgaXMgcHJlc2VudAorICAgICAgICAgICAgbVdhdGNoZWRDbGllbnRQYWNrYWdlcy5jbGVhcigpOworICAgICAgICAgICAgbVdhdGNoZWRDbGllbnRQYWNrYWdlcy5lbXBsYWNlKGtXYXRjaEFsbENsaWVudHNGbGFnKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CisKKyAgICAgICAgLy8gdHJhY2sgcGFja2FnZSBuYW1lcworICAgICAgICBtV2F0Y2hlZENsaWVudFBhY2thZ2VzLm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YW1lcmFQcm92aWRlck1hbmFnZXI+IG1hbmFnZXIpID0gMDsKKworICAgICAgICAvLyBTdG9wIHRoZSBpbmplY3Rpb24gY2FtZXJhIGFuZCByZXN0b3JlIHRvIGludGVybmFsIGNhbWVyYSBzZXNzaW9uLgorICAgICAgICB2aXJ0dWFsIHN0YXR1c190IHN0b3BJbmplY3Rpb24oKSA9IDA7CisKICAgICBwcm90ZWN0ZWQ6CiAgICAgICAgIEJhc2ljQ2xpZW50KGNvbnN0IHNwPENhbWVyYVNlcnZpY2U+JiBjYW1lcmFTZXJ2aWNlLAogICAgICAgICAgICAgICAgIGNvbnN0IHNwPElCaW5kZXI+JiByZW1vdGVDYWxsYmFjaywKICAgICAgICAgICAgICAgICBjb25zdCBTdHJpbmcxNiYgY2xpZW50UGFja2FnZU5hbWUsCisgICAgICAgICAgICAgICAgYm9vbCBuYXRpdmVDbGllbnQsCiAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjpvcHRpb25hbDxTdHJpbmcxNj4mIGNsaWVudEZlYXR1cmVJZCwKICAgICAgICAgICAgICAgICBjb25zdCBTdHJpbmc4JiBjYW1lcmFJZFN0ciwKICAgICAgICAgICAgICAgICBpbnQgY2FtZXJhRmFjaW5nLApAQCAtMzQ2LDYgKzM3NCw3IEBACiAgICAgICAgIGNvbnN0IGludCAgICAgICAgICAgICAgICAgICAgICAgbUNhbWVyYUZhY2luZzsKICAgICAgICAgY29uc3QgaW50ICAgICAgICAgICAgICAgICAgICAgICBtT3JpZW50YXRpb247CiAgICAgICAgIFN0cmluZzE2ICAgICAgICAgICAgICAgICAgICAgICAgbUNsaWVudFBhY2thZ2VOYW1lOworICAgICAgICBib29sICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1TeXN0ZW1OYXRpdmVDbGllbnQ7CiAgICAgICAgIHN0ZDo6b3B0aW9uYWw8U3RyaW5nMTY+ICAgICAgICAgbUNsaWVudEZlYXR1cmVJZDsKICAgICAgICAgcGlkX3QgICAgICAgICAgICAgICAgICAgICAgICAgICBtQ2xpZW50UGlkOwogICAgICAgICBjb25zdCB1aWRfdCAgICAgICAgICAgICAgICAgICAgIG1DbGllbnRVaWQ7CkBAIC00MzMsNiArNDYyLDcgQEAKICAgICAgICAgQ2xpZW50KGNvbnN0IHNwPENhbWVyYVNlcnZpY2U+JiBjYW1lcmFTZXJ2aWNlLAogICAgICAgICAgICAgICAgIGNvbnN0IHNwPGhhcmR3YXJlOjpJQ2FtZXJhQ2xpZW50PiYgY2FtZXJhQ2xpZW50LAogICAgICAgICAgICAgICAgIGNvbnN0IFN0cmluZzE2JiBjbGllbnRQYWNrYWdlTmFtZSwKKyAgICAgICAgICAgICAgICBib29sIHN5c3RlbU5hdGl2ZUNsaWVudCwKICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6Om9wdGlvbmFsPFN0cmluZzE2PiYgY2xpZW50RmVhdHVyZUlkLAogICAgICAgICAgICAgICAgIGNvbnN0IFN0cmluZzgmIGNhbWVyYUlkU3RyLAogICAgICAgICAgICAgICAgIGludCBhcGkxQ2FtZXJhSWQsCkBAIC01MTYsMTQgKzU0NiwxNSBAQAogICAgICAgICAgKi8KICAgICAgICAgc3RhdGljIERlc2NyaXB0b3JQdHIgbWFrZUNsaWVudERlc2NyaXB0b3IoY29uc3QgU3RyaW5nOCYga2V5LCBjb25zdCBzcDxCYXNpY0NsaWVudD4mIHZhbHVlLAogICAgICAgICAgICAgICAgIGludDMyX3QgY29zdCwgY29uc3Qgc3RkOjpzZXQ8U3RyaW5nOD4mIGNvbmZsaWN0aW5nS2V5cywgaW50MzJfdCBzY29yZSwKLSAgICAgICAgICAgICAgICBpbnQzMl90IG93bmVySWQsIGludDMyX3Qgc3RhdGUsIGludCBvb21TY29yZU9mZnNldCk7CisgICAgICAgICAgICAgICAgaW50MzJfdCBvd25lcklkLCBpbnQzMl90IHN0YXRlLCBpbnQgb29tU2NvcmVPZmZzZXQsIGJvb2wgc3lzdGVtTmF0aXZlQ2xpZW50KTsKIAogICAgIC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VQUyAtIDEpOwogCiAgICAgICAgIHsKICAgICAgICAgICAgIFN0cmluZzggem9vbVJhdGlvczsKQEAgLTg3MiwxOCArODkxLDM0IEBACiAgICAgICAgICAgICBmbG9hdCB6b29tSW5jcmVtZW50ID0gKG1heERpZ2l0YWxab29tLmRhdGEuZlswXSAtIHpvb20pIC8KICAgICAgICAgICAgICAgICAgICAgKE5VTV9aT09NX1NURVBTLTEpOwogICAgICAgICAgICAgYm9vbCBhZGRDb21tYSA9IGZhbHNlOwotICAgICAgICAgICAgZm9yIChzaXplX3QgaT0wOyBpIDwgTlVNX1pPT01fU1RFUFM7IGkrKykgeworICAgICAgICAgICAgaW50IHByZXZpb3VzWm9vbSA9IC0xOworICAgICAgICAgICAgc2l6ZV90IHpvb21TdGVwcyA9IDA7CisgICAgICAgICAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IE5VTV9aT09NX1NURVBTOyBpKyspIHsKKyAgICAgICAgICAgICAgICBpbnQgY3VycmVudFpvb20gPSBzdGF0aWNfY2FzdDxpbnQ+KHpvb20gKiAxMDApOworICAgICAgICAgICAgICAgIGlmIChwcmV2aW91c1pvb20gPT0gY3VycmVudFpvb20pIHsKKyAgICAgICAgICAgICAgICAgICAgem9vbSArPSB6b29tSW5jcmVtZW50OworICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgaWYgKGFkZENvbW1hKSB6b29tUmF0aW9zICs9ICIsIjsKICAgICAgICAgICAgICAgICBhZGRDb21tYSA9IHRydWU7Ci0gICAgICAgICAgICAgICAgem9vbVJhdGlvcyArPSBTdHJpbmc4Ojpmb3JtYXQoIiVkIiwgc3RhdGljX2Nhc3Q8aW50Pih6b29tICogMTAwKSk7CisgICAgICAgICAgICAgICAgem9vbVJhdGlvcyArPSBTdHJpbmc4Ojpmb3JtYXQoIiVkIiwgY3VycmVudFpvb20pOwogICAgICAgICAgICAgICAgIHpvb20gKz0gem9vbUluY3JlbWVudDsKKyAgICAgICAgICAgICAgICBwcmV2aW91c1pvb20gPSBjdXJyZW50Wm9vbTsKKyAgICAgICAgICAgICAgICB6b29tU3RlcHMrKzsKICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIHBhcmFtcy5zZXQoQ2FtZXJhUGFyYW1ldGVyczo6S0VZX1pPT01fUkFUSU9TLCB6b29tUmF0aW9zKTsKKworICAgICAgICAgICAgaWYgKHpvb21TdGVwcyA+IDApIHsKKyAgICAgICAgICAgICAgICBwYXJhbXMuc2V0KENhbWVyYVBhcmFtZXRlcnM6OktFWV9aT09NX1JBVElPUywgem9vbVJhdGlvcyk7CisgICAgICAgICAgICAgICAgcGFyYW1zLnNldChDYW1lcmFQYXJhbWV0ZXJzOjpLRVlfWk9PTV9TVVBQT1JURUQsCisgICAgICAgICAgICAgICAgICAgICAgICBDYW1lcmFQYXJhbWV0ZXJzOjpUUlVFKTsKKyAgICAgICAgICAgICAgICBwYXJhbXMuc2V0KENhbWVyYVBhcmFtZXRlcnM6OktFWV9NQVhfWk9PTSwgem9vbVN0ZXBzIC0gMSk7CisgICAgICAgICAgICAgICAgem9vbUF2YWlsYWJsZSA9IHRydWU7CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIHBhcmFtcy5zZXQoQ2FtZXJhUGFyYW1ldGVyczo6S0VZX1pPT01fU1VQUE9SVEVELAorICAgICAgICAgICAgICAgICAgICAgICAgQ2FtZXJhUGFyYW1ldGVyczo6RkFMU0UpOworICAgICAgICAgICAgfQogICAgICAgICB9CiAKLSAgICAgICAgcGFyYW1zLnNldChDYW1lcmFQYXJhbWV0ZXJzOjpLRVlfWk9PTV9TVVBQT1JURUQsCi0gICAgICAgICAgICAgICAgQ2FtZXJhUGFyYW1ldGVyczo6VFJVRSk7Ci0gICAgICAgIHpvb21BdmFpbGFibGUgPSB0cnVlOwogICAgIH0gZWxzZSB7CiAgICAgICAgIHBhcmFtcy5zZXQoQ2FtZXJhUGFyYW1ldGVy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5LmNvdW50KSB7CisgICAgICAgICAgICBlbnRyeSA9IGRldmljZUluZm8uZmluZChBTkRST0lEX1JFUVVFU1RfQVZBSUxBQkxFX0RZTkFNSUNfUkFOR0VfUFJPRklMRVNfTUFQKTsKKyAgICAgICAgICAgIGlmIChlbnRyeS5jb3VudCA+IDAgfHwgKChlbnRyeS5jb3VudCAlIDMpICE9IDApKSB7CisgICAgICAgICAgICAgICAgaW50NjRfdCBzdGFuZGFyZEJpdG1hcCA9CisgICAgICAgICAgICAgICAgICAgICAgICBBTkRST0lEX1JFUVVFU1RfQVZBSUxBQkxFX0RZTkFNSUNfUkFOR0VfUFJPRklMRVNfTUFQX1NUQU5EQVJEOworICAgICAgICAgICAgICAgIGZvciAoc2l6ZV90IGkgPSAwOyBpIDwgZW50cnkuY291bnQ7IGkgKz0gMykgeworICAgICAgICAgICAgICAgICAgICBpZiAoZW50cnkuZGF0YS5pNjRbaV0gIT0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBBTkRST0lEX1JFUVVFU1RfQVZBSUxBQkxFX0RZTkFNSUNfUkFOR0VfUFJPRklMRVNfTUFQX1NUQU5EQVJEKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBtRHluYW1pY1Byb2ZpbGVNYXAuZW1wbGFjZShlbnRyeS5kYXRhLmk2NFtpXSwgZW50cnkuZGF0YS5pNjRbaSsxXSk7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoKGVudHJ5LmRhdGEuaTY0W2krMV0gPT0gMCkgfHwgKGVudHJ5LmRhdGEuaTY0W2krMV0gJgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBTkRST0lEX1JFUVVFU1RfQVZBSUxBQkxFX0RZTkFNSUNfUkFOR0VfUFJPRklMRVNfTUFQX1NUQU5EQVJEKSkgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YW5kYXJkQml0bWFwIHw9IGVudHJ5LmRhdGEuaTY0W2ldOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgQUxPR0UoIiVzOiBEZXZpY2UgJXMgaW5jbHVkZXMgdW5leHBlY3RlZCBwcm9maWxlIGVudHJ5OiAweCUiIFBSSXg2NCAiISIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgbUNhbWVyYUlkU3RyLmNfc3RyKCksIGVudHJ5LmRhdGEuaTY0W2ldKTsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBtRHluYW1pY1Byb2ZpbGVNYXBbQU5EUk9JRF9SRVFVRVNUX0FWQUlMQUJMRV9EWU5BTUlDX1JBTkdFX1BST0ZJTEVTX01BUF9TVEFOREFSRF0gPQorICAgICAgICAgICAgICAgICAgICAgICAgc3RhbmRhcmRCaXRtYXA7CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIEFMT0dFKCIlczogRGV2aWNlICVzIHN1cHBvcnRzIDEwLWJpdCBvdXRwdXQgYnV0IGRvZXNuJ3QgaW5jbHVkZSBhIGR5bmFtaWMgcmFuZ2UiCisgICAgICAgICAgICAgICAgICAgICAgICAiIHByb2ZpbGUgbWFwISIsIF9fRlVOQ1RJT05fXywgbUNhbWVyYUlkU3RyLmNfc3RyKCkpOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgfQorCiAgICAgbVByb3ZpZGVyTWFuYWdlciA9IHByb3ZpZGVyUHRyOwogICAgIC8vIENhY2hlIHBoeXNpY2FsIGNhbWVyYSBpZHMgY29ycmVzcG9uZGluZyB0byB0aGlzIGRldmljZSBhbmQgYWxzbyB0aGUgaGlnaAogICAgIC8vIHJlc29sdXRpb24gc2Vuc29ycyBpbiB0aGlzIGRldmljZSArIHBoeXNpY2FsIGNhbWVyYSBpZHMKQEAgLTE3Miw2ICsyMDksNyBAQAogICAgIGludCBjb21wb3NpdGVJZHg7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Elkcy5wdXNoX2JhY2socmVxdWVzdGVkUGh5c2ljYWxJZC5zdHJpbmcoKSk7CisgICAgICAgICAgICAgICAgICAgIGR5bmFtaWNQcm9maWxlQml0bWFwIHw9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUNvbmZpZ3VyZWRPdXRwdXRzLnZhbHVlQXQoaW5kZXgpLmdldER5bmFtaWNSYW5nZVByb2ZpbGUoKTsKICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICBBTE9HVygiJXM6IE91dHB1dCBzdHJlYW0gSWQgbm90IGZvdW5kIGFtb25nIGNvbmZpZ3VyZWQgb3V0cHV0cyEiLCBfX0ZVTkNUSU9OX18pOwogICAgICAgICAgICAgICAgIH0KQEAgLTM0OCw2ICszODksNDEgQEAKICAgICAgICAgICAgICAgICBTdHJpbmc4IHJlcXVlc3RlZFBoeXNpY2FsSWQoCiAgICAgICAgICAgICAgICAgICAgICAgICBtQ29uZmlndXJlZE91dHB1dHMudmFsdWVBdChpbmRleCkuZ2V0UGh5c2ljYWxDYW1lcmFJZCgpKTsKICAgICAgICAgICAgICAgICByZXF1ZXN0ZWRQaHlzaWNhbElkcy5wdXNoX2JhY2socmVxdWVzdGVkUGh5c2ljYWxJZC5zdHJpbmcoKSk7CisgICAgICAgICAgICAgICAgZHluYW1pY1Byb2ZpbGVCaXRtYXAgfD0KKyAgICAgICAgICAgICAgICAgICAgICAgIG1Db25maWd1cmVkT3V0cHV0cy52YWx1ZUF0KGluZGV4KS5nZXREeW5hbWljUmFuZ2VQcm9maWxlKCk7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKworICAgICAgICBpZiAoZHluYW1pY1Byb2ZpbGVCaXRtYXAgIT0KKyAgICAgICAgICAgICAgICAgICAgQU5EUk9JRF9SRVFVRVNUX0FWQUlMQUJMRV9EWU5BTUlDX1JBTkdFX1BST0ZJTEVTX01BUF9TVEFOREFSRCkgeworICAgICAgICAgICAgZm9yIChpbnQgaSA9IEFORFJPSURfUkVRVUVTVF9BVkFJTEFCTEVfRFlOQU1JQ19SQU5HRV9QUk9GSUxFU19NQVBfU1RBTkRBUkQ7CisgICAgICAgICAgICAgICAgICAgIGkgPCBBTkRST0lEX1JFUVVFU1RfQVZBSUxBQkxFX0RZTkFNSUNfUkFOR0VfUFJPRklMRVNfTUFQX01BWDsgaSA8PD0gMSkgeworICAgICAgICAgICAgICAgIGlmICgoZHluYW1pY1Byb2ZpbGVCaXRtYXAgJiBpKSA9PSAwKSB7CisgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgIGNvbnN0IGF1dG8mIGl0ID0gbUR5bmFtaWNQcm9maWxlTWFwLmZpbmQoaSk7CisgICAgICAgICAgICAgICAgaWYgKGl0ICE9IG1EeW5hbWljUHJvZmlsZU1hcC5lbmQoKSkgeworICAgICAgICAgICAgICAgICAgICBpZiAoKGl0LT5zZWNvbmQgPT0gMCkgfHwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAoKGl0LT5zZWNvbmQgJiBkeW5hbWljUHJvZmlsZUJpdG1hcCkgPT0gZHluYW1pY1Byb2ZpbGVCaXRtYXApKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIEFMT0dFKCIlczogQ2FtZXJhICVzOiBUcmllZCB0byBzdWJtaXQgYSByZXF1ZXN0IHdpdGggYSBzdXJmYWNlcyB0aGF0IgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiIHJlZmVyZW5jZSBhbiB1bnN1cHBvcnRlZCBkeW5hbWljIHJhbmdlIHByb2ZpbGUgY29tYmluYXRpb24iCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIgMHglIiBQUkl4NjQgIiEiLCBfX0ZVTkNUSU9OX18sIG1DYW1lcmFJZFN0ci5zdHJpbmcoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZHluYW1pY1Byb2ZpbGVCaXRtYXApOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFNUQVRVU19FUlJPUihDYW1lcmFTZXJ2aWNlOjpFUlJPUl9JTExFR0FMX0FSR1VNRU5ULAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiUmVxdWVzdCB0YXJnZXRzIGFuIHVuc3VwcG9ydGVkIGR5bmFtaWMgcmFuZ2UgcHJvZmlsZSIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIiBjb21iaW5hdGlvbiIpOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgQUxPR0UoIiVzOiBDYW1lcmEgJXM6IFRyaWVkIHRvIHN1Ym1pdCBhIHJlcXVlc3Qgd2l0aCBhIHN1cmZhY2UgdGhhdCIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAiIHJlZmVyZW5jZXMgdW5zdXBwb3J0ZWQgZHluYW1pYyByYW5nZSBwcm9maWxlIDB4JXghIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIG1DYW1lcmFJZFN0ci5zdHJpbmcoKSwgaSk7CisgICAgICAgICAgICAgICAgICAgIHJldHVybiBTVEFUVVNfRVJST1IoQ2FtZXJhU2VydmljZTo6RVJST1JfSUxMRUdBTF9BUkdVTUVOVCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAiUmVxdWVzdCB0YXJnZXRzIDEwLWJpdCBTdXJmYWNlIHdpdGggdW5zdXBwb3J0ZWQgZHluYW1pYyByYW5nZSIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAiIHByb2ZpbGUiKTsKKyAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KIApAQCAtNDQxLDYgKzUxNywxNyBAQAogCiAgICAgICAgIG1ldGFkYXRhUmVxdWVzdExpc3QucHVzaF9iYWNrKHBoeXNpY2FsU2V0dGluZ3NMaXN0KTsKICAgICAgICAgc3VyZmFjZU1hcExpc3QucHVzaF9iYWNrKHN1cmZhY2VNYXApOworCisgICAgICAgIC8vIFNhdmUgY2VydGFpbiBDYXB0dXJlUmVxdWVzdCBzZXR0aW5ncworICAgICAgICBpZiAoIXJlcXVlc3QubVVzZXJUYWcuZW1wdHkoKSkgeworICAgICAgICAgICAgbVVzZXJUYWcgPSByZXF1ZXN0Lm1Vc2VyVGFnOworICAgICAgICB9CisgICAgICAgIGNhbWVyYV9tZXRhZGF0YV9lbnRyeSBlbnRyeSA9CisgICAgICAgICAgICAgICAgcGh5c2ljYWxTZXR0aW5nc0xpc3QuYmVnaW4oKS0+bWV0YWRhdGEuZmluZCgKKyAgICAgICAgICAgICAgICAgICAgICAgIEFORFJPSURfQ09OVFJPTF9WSURFT19TVEFCSUxJWkFUSU9OX01PREUpOworICAgICAgICBpZiAoZW50cnkuY291bnQgPT0gMSkgeworICAgICAgICAgICAgbVZpZGVvU3RhYmlsaXphdGlvbk1vZGUgPSBlbnRyeS5kYXRhLnU4WzBdOworICAgICAgICB9CiAgICAgfQogICAgIG1SZXF1ZXN0SWRDb3VudGVyKys7CiAKQEAgLTU2OCw2ICs2NTUsNyBAQAogICAgICAgICBvZmZsaW5lU3RyZWFtSWRzLT5jbGVhcigpOwogICAgICAgICBtRGV2aWNlLT5nZXRPZmZsaW5lU3RyZWFtSWRzKG9mZmxpbmVTdHJlYW1JZHMpOwogCisgICAgICAgIE11dGV4OjpBdXRvbG9jayBsKG1Db21wb3NpdGVMb2NrKTsKICAgICAgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCBtQ29tcG9zaXRlU3RyZWFtTWFwLnNpemUoKTsgKytpKSB7CiAgICAgICAgICAgICBlcnIgPSBtQ29tcG9zaXRlU3RyZWFtTWFwLnZhbHVlQXQoaSktPmNvbmZpZ3VyZVN0cmVhbSgpOw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AgICAgbURlZmVycmVkU3RyZWFtcy5jbGVhcigpOwogICAgICAgICBtU3RyZWFtSW5mb01hcC5jbGVhcigpOworICAgICAgICBNdXRleDo6QXV0b2xvY2sgbChtQ29tcG9zaXRlTG9jayk7CiAgICAgICAgIG1Db21wb3NpdGVTdHJlYW1NYXAuY2xlYXIoKTsKICAgICAgICAgbUlucHV0U3RyZWFtID0ge2ZhbHNlLCAwLCAwLCAwLCAwfTsKICAgICB9IGVsc2UgewpAQCAtMTgwNCwxNiArMTkwNSw1MCBAQAogICAgIHJldHVybiBkdW1wRGV2aWNlKGZkLCBhcmdzKTsKIH0KIAorc3RhdHVzX3QgQ2FtZXJhRGV2aWNlQ2xpZW50OjpzdGFydFdhdGNoaW5nVGFncyhjb25zdCBTdHJpbmc4ICZ0YWdzLCBpbnQgb3V0KSB7CisgICAgc3A8Q2FtZXJhRGV2aWNlQmFzZT4gZGV2aWNlID0gbURldmljZTsKKyAgICBpZiAoIWRldmljZSkgeworICAgICAgICBkcHJpbnRmKG91dCwgIiAgRGV2aWNlIGlzIGRldGFjaGVkLiIpOworICAgICAgICByZXR1cm4gT0s7CisgICAgfQorICAgIGRldmljZS0+c3RhcnRXYXRjaGluZ1RhZ3ModGFncyk7CisgICAgcmV0dXJuIE9LOworfQorCitzdGF0dXNfdCBDYW1lcmFEZXZpY2VDbGllbnQ6OnN0b3BXYXRjaGluZ1RhZ3MoaW50IG91dCkgeworICAgIHNwPENhbWVyYURldmljZUJhc2U+IGRldmljZSA9IG1EZXZpY2U7CisgICAgaWYgKCFkZXZpY2UpIHsKKyAgICAgICAgZHByaW50ZihvdXQsICIgIERldmljZSBpcyBkZXRhY2hlZC4iKTsKKyAgICAgICAgcmV0dXJuIE9LOworICAgIH0KKyAgICBkZXZpY2UtPnN0b3BXYXRjaGluZ1RhZ3MoKTsKKyAgICByZXR1cm4gT0s7Cit9CisKK3N0YXR1c190IENhbWVyYURldmljZUNsaWVudDo6ZHVtcFdhdGNoZWRFdmVudHNUb1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gICAgICBuZXcgQWlkbENhbWVyYTNEZXZpY2UoVENsaWVudEJhc2U6Om1DYW1lcmFJZFN0ciwgbU92ZXJyaWRlRm9yUGVyZkNsYXNzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1MZWdhY3lDbGllbnQpOworICAgICAgICAgICAgIGJyZWFrOworICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgQUxPR0UoIiVzIEludmFsaWQgdHJhbnNwb3J0IGZvciBjYW1lcmEgaWQgJXMiLCBfX0ZVTkNUSU9OX18sCisgICAgICAgICAgICAgICAgICAgIFRDbGllbnRCYXNlOjptQ2FtZXJhSWRTdHIuc3RyaW5nKCkpOworICAgICAgICAgICAgcmV0dXJuIE5PX0lOSVQ7CisgICAgfQogICAgIGlmIChtRGV2aWNlID09IE5VTEwpIHsKICAgICAgICAgQUxPR0UoIiVzOiBDYW1lcmEgJXM6IE5vIGRldmljZSBjb25uZWN0ZWQiLAogICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgVENsaWVudEJhc2U6Om1DYW1lcmFJZFN0ci5zdHJpbmcoKSk7CkBAIC0xNTYsNiArMTc5LDM4IEBACiB9CiAKIHRlbXBsYXRlIDx0eXBlbmFtZSBUQ2xpZW50QmFzZT4KK3N0YXR1c190IENhbWVyYTJDbGllbnRCYXNlPFRDbGllbnRCYXNlPjo6c3RhcnRXYXRjaGluZ1RhZ3MoY29uc3QgU3RyaW5nOCAmdGFncywgaW50IG91dCkgeworICBzcDxDYW1lcmFEZXZpY2VCYXNlPiBkZXZpY2UgPSBtRGV2aWNlOworICBpZiAoIWRldmljZSkgeworICAgIGRwcmludGYob3V0LCAiICBEZXZpY2UgaXMgZGV0YWNoZWQiKTsKKyAgICByZXR1cm4gT0s7CisgIH0KKworICByZXR1cm4gZGV2aWNlLT5zdGFydFdhdGNoaW5nVGFncyh0YWdzKTsKK30KKwordGVtcGxhdGUgPHR5cGVuYW1lIFRDbGllbnRCYXNlPgorc3RhdHVzX3QgQ2F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yYXMpOwotICAgIHZpcnR1YWwgc3RhdHVzX3QgICAgICBub3RpZnlBY3RpdmUoKTsgIC8vIFJldHVybnMgZXJyb3JzIG9uIGFwcCBvcHMgcGVybWlzc2lvbiBmYWlsdXJlcwotICAgIHZpcnR1YWwgdm9pZCAgICAgICAgICBub3RpZnlJZGxlKGludDY0X3QgcmVxdWVzdENvdW50LCBpbnQ2NF90IHJlc3VsdEVycm9yQ291bnQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCBkZXZpY2VFcnJvciwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnZlY3RvcjxoYXJkd2FyZTo6Q2FtZXJhU3RyZWFtU3RhdHM+JiBzdHJlYW1TdGF0cyk7CisgICAgLy8gUmV0dXJucyBlcnJvcnMgb24gYXBwIG9wcyBwZXJtaXNzaW9uIGZhaWx1cmVzCisgICAgdmlydHVhbCBzdGF0dXNfdCAgICAgIG5vdGlmeUFjdGl2ZShmbG9hdCBtYXhQcmV2aWV3RnBzKTsKKyAgICB2aXJ0dWFsIHZvaWQgICAgICAgICAgbm90aWZ5SWRsZShpbnQ2NF90IC8qcmVxdWVzdENvdW50Ki8sIGludDY0X3QgLypyZXN1bHRFcnJvckNvdW50Ki8sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9vbCAvKmRldmljZUVycm9yKi8sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjp2ZWN0b3I8aGFyZHdhcmU6OkNhbWVyYVN0cmVhbVN0YXRzPiYpIHt9CiAgICAgdmlydHVhbCB2b2lkICAgICAgICAgIG5vdGlmeVNodXR0ZXIoY29uc3QgQ2FwdHVyZVJlc3VsdEV4dHJhcyYgcmVzdWx0RXh0cmFzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5zZWNzX3QgdGltZXN0YW1wKTsKICAgICB2aX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CBTdHJpbmc4PiB0YWdUb1NlY3Rpb25NYXA7CisKKyAgICBpbnQgaWR4ID0gMDsKKyAgICBmb3IgKHNpemVfdCBzID0gMDsgcyA8IHZ0cy5zaXplKCk7IHMrKykgeworICAgICAgICBjb25zdCBWZW5kb3JUYWdTZWN0aW9uVHlwZSYgc2VjdGlvbiA9IHZ0c1tzXTsKKyAgICAgICAgY29uc3QgY2hhciAqc2VjdGlvbk5hbWUgPSBzZWN0aW9uLnNlY3Rpb25OYW1lLmNfc3RyKCk7CisgICAgICAgIGlmIChzZWN0aW9uTmFtZSA9PSBOVUxMKSB7CisgICAgICAgICAgICBBTE9HRSgiJXM6IG5vIHNlY3Rpb24gbmFtZSBkZWZpbmVkIGZvciB2ZW5kb3IgdGFnIHNlY3Rpb24gJXp1LiIsIF9fRlVOQ1RJT05fXywgcyk7CisgICAgICAgICAgICByZXR1cm4gQkFEX1ZBTFVFOworICAgICAgICB9CisgICAgICAgIFN0cmluZzggc2VjdGlvblN0cmluZyhzZWN0aW9uTmFtZSk7CisgICAgICAgIHNlY3Rpb25zLmFkZChzZWN0aW9uU3RyaW5nKTsKKworICAgICAgICBmb3IgKHNpemVfdCBqID0gMDsgaiA8IHNlY3Rpb24udGFncy5zaXplKCk7IGorKykgeworICAgICAgICAgICAgdWludDMyX3QgdGFnID0gc2VjdGlvbi50YWdzW2pdLnRhZ0lkOworICAgICAgICAgICAgaWYgKHRhZyA8IENBTUVSQV9NRVRBREFUQV9WRU5ET1JfVEFHX0JPVU5EQVJZKSB7CisgICAgICAgICAgICAgICAgQUxPR0UoIiVzOiB2ZW5kb3IgdGFnICVkIG5vdCBpbiB2ZW5kb3IgdGFnIHNlY3Rpb24uIiwgX19GVU5DVElPTl9fLCB0YWcpOworICAgICAgICAgICAgICAgIHJldHVybiBCQURfVkFMVUU7CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIHRhZ0FycmF5LmVkaXRJdGVtQXQoaWR4KyspID0gc2VjdGlvbi50YWdzW2pdLnRhZ0lkOworCisgICAgICAgICAgICBjb25zdCBjaGFyICp0YWdOYW1lID0gc2VjdGlvbi50YWdzW2pdLnRhZ05hbWUuY19zdHIoKTsKKyAgICAgICAgICAgIGlmICh0YWdOYW1lID09IE5VTEwpIHsKKyAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IG5vIHRhZyBuYW1lIGRlZmluZWQgZm9yIHZlbmRvciB0YWcgJWQuIiwgX19GVU5DVElPTl9fLCB0YWcpOworICAgICAgICAgICAgICAgIHJldHVybiBCQURfVkFMVUU7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBkZXNjLT5tVGFnVG9OYW1lTWFwLmFkZCh0YWcsIFN0cmluZzgodGFnTmFtZSkpOworICAgICAgICAgICAgdGFnVG9TZWN0aW9uTWFwLmFkZCh0YWcsIHNlY3Rpb25TdHJpbmcpOworCisgICAgICAgICAgICBpbnQgdGFnVHlwZSA9IChpbnQpIHNlY3Rpb24udGFnc1tqXS50YWdUeXBlOworICAgICAgICAgICAgaWYgKHRhZ1R5cGUgPCAwIHx8IHRhZ1R5cGUgPj0gTlVNX1RZUEVTKSB7CisgICAgICAgICAgICAgICAgQUxPR0UoIiVzOiB0YWcgdHlwZSAlZCBmcm9tIHZlbmRvciBvcHMgZG9lcyBub3QgZXhpc3QuIiwgX19GVU5DVElPTl9fLCB0YWdUeXBlKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gQkFEX1ZBTFVFOworICAgICAgICAgICAgfQorICAgICAgICAgICAgZGVzYy0+bVRhZ1RvVHlwZU1hcC5hZGQodGFnLCB0YWdUeXBlKTsKKyAgICAgICAgfQorICAgIH0KKworICAgIGRlc2MtPm1TZWN0aW9ucyA9IHNlY3Rpb25zOworCisgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCB0YWdBcnJheS5zaXplKCk7ICsraSkgeworICAgICAgICB1aW50MzJfdCB0YWcgPSB0YWdBcnJheVtpXTsKKyAgICAgICAgU3RyaW5nOCBzZWN0aW9uU3RyaW5n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c2VydmljZSBtYW5hZ2VyIiwKKyAgICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fKTsKKyAgICAgICAgICAgIHJldHVybiByZXM7CisgICAgICAgIH0KKyAgICAgICAgYWRkQWlkbFByb3ZpZGVyTG9ja2VkKGFpZGxTZXJ2aWNlTmFtZSk7CisgICAgfQorICAgIHJldHVybiBPSzsKK30KKworc3RhdHVzX3QgQ2FtZXJhUHJvdmlkZXJNYW5hZ2VyOjppbml0aWFsaXplKHdwPENhbWVyYVByb3ZpZGVyTWFuYWdlcjo6U3RhdHVzTGlzdGVuZXI+IGxpc3RlbmVyLAorICAgICAgICBIaWRsU2VydmljZUludGVyYWN0aW9uUHJveHkqIGhpZGxQcm94eSkgeworICAgIHN0ZDo6bG9ja19ndWFyZDxzdGQ6Om11dGV4PiBsb2NrKG1JbnRlcmZhY2VNdXRleCk7CisgICAgaWYgKGhpZGxQcm94eSA9PSBudWxscHRyKSB7CisgICAgICAgIEFMT0dFKCIlczogTm8gdmFsaWQgc2VydmljZSBpbnRlcmFjdGlvbiBwcm94eSBwcm92aWRlZCIsIF9fRlVOQ1RJT05fXyk7CisgICAgICAgIHJldHVybiBCQURfVkFMVUU7CisgICAgfQorICAgIG1MaXN0ZW5lciA9IGxpc3RlbmVyOworICAgIG1EZXZpY2VTdGF0ZSA9IDA7CisgICAgYXV0byByZXMgPSB0cnlUb0luaXRBbmRBZGRIaWRsUHJvdmlkZXJzTG9ja2VkKGhpZGxQcm94eSk7CisgICAgaWYgKHJlcyAhPSBPSykgeworICAgICAgICAvLyBMb2dnaW5nIGRvbmUgaW4gY2FsbGVkIGZ1bmN0aW9uOworICAgICAgICByZXR1cm4gcmVzOworICAgIH0KKyAgICByZXMgPSB0cnlUb0FkZEFpZGxQcm92aWRlcnNMb2NrZWQoKTsKIAogICAgIElQQ1RocmVhZFN0YXRlOjpzZWxmKCktPmZsdXNoQ29tbWFuZHMoKTsKIAotICAgIHJldHVybiBPSzsKKyAgICByZXR1cm4gc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BDYW1lcmFQcm92aWRlck1hbmFnZXI6OmdldEhpZ2hlc3RTdXBwb3J0ZWRWZXJzaW9uKGNvbnN0IHN0ZDo6c3RyaW5nICZpZCwKLSAgICAgICAgaGFyZHdhcmU6OmhpZGxfdmVyc2lvbiAqdikgeworICAgICAgICBoYXJkd2FyZTo6aGlkbF92ZXJzaW9uICp2LCBJUENUcmFuc3BvcnQgKnRyYW5zcG9ydCkgeworICAgIGlmICh2ID09IG51bGxwdHIgfHwgdHJhbnNwb3J0ID09IG51bGxwdHIpIHsKKyAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKKyAgICB9CiAgICAgc3RkOjpsb2NrX2d1YXJkPHN0ZDo6bXV0ZXg+IGxvY2sobUludGVyZmFjZU11dGV4KTsKIAogICAgIGhhcmR3YXJlOjpoaWRsX3ZlcnNpb24gbWF4VmVyc2lvbnswLDB9OwogICAgIGJvb2wgZm91bmQgPSBmYWxzZTsKKyAgICBJUENUcmFuc3BvcnQgcHJvdmlkZXJUcmFuc3BvcnQgPSBJUENUcmFuc3BvcnQ6OklOVkFMSUQ7CiAgICAgZm9yIChhdXRvJiBwcm92aWRlciA6IG1Qcm92aWRlcnMpIHsKICAgICAgICAgZm9yIChhdXRvJiBkZXZpY2VJbmZvIDogcHJvdmlkZXItPm1EZXZpY2VzKSB7CiAgICAgICAgICAgICBpZiAoZGV2aWNlSW5mby0+bUlkID09IGlkKSB7CiAgICAgICAgICAgICAgICAgaWYgKGRldmljZUluZm8tPm1WZXJzaW9uID4gbWF4VmVyc2lvbikgewogICAgICAgICAgICAgICAgICAgICBtYXhWZXJzaW9uID0gZGV2aWNlSW5mby0+bVZlcnNpb247CisgICAgICAgICAgICAgICAgICAgIHByb3ZpZGVyVHJhbnNwb3J0ID0gcHJvdmlkZXItPmdldElQQ1RyYW5zcG9ydCgpOwogICAgICAgICAgICAgICAgICAgICBmb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgfQogICAgICAgICB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cmV0dXJuIG51bGxwdHI7CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIHJldHVybiBwcm92aWRlckluZm87CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICB9CisgICAgcmV0dXJuIG51bGxwdHI7Cit9CisKK3N0YXR1c190IENhbWVyYVByb3ZpZGVyTWFuYWdlcjo6bm90aWZ5VXNiRGV2aWNlRXZlbnQoaW50MzJfdCBldmVudElkLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnN0cmluZyYgdXNiRGV2aWNlSWQpIHsKKyAgICBpZiAoIWtFbmFibGVMYXp5SGFsKSB7CisgICAgICAgIHJldHVybiBPSzsKKyAgICB9CisKKyAgICBBTE9HVigibm90aWZ5U3lzdGVtRXZlbnQ6ICVkIHVzYkRldmljZUlkIDogJXMiLCBldmVudElkLCB1c2JEZXZpY2VJZC5jX3N0cigpKTsKKworICAgIGlmIChldmVudElkID09IGFuZHJvaWQ6OmhhcmR3YXJlOjpJQ2FtZXJhU2VydmljZTo6RVZFTlRfVVNCX0RFVklDRV9BVFRBQ0hFRCkgeworICAgICAgICBzcDxQcm92aWRlckluZm8+IGV4dGVybmFsUHJvdmlkZXIgPSBzdGFydEV4dGVybmFsTGF6eVByb3ZpZGVyKCk7CisgICAgICAgIGlmIChleHRlcm5hbFByb3ZpZGVyICE9IG51bGxwdHIpIHsKKyAgICAgICAgICAgIGF1dG8gdXNiRGV2aWNlcyA9IG1FeHRlcm5hbFVzYkRldmljZXNGb3JQcm92aWRlci5maXJzdDsKKyAgICAgICAgICAgIHVzYkRldmljZXMucHVzaF9iYWNrKHVzYkRldmljZUlkKTsKKyAgICAgICAgICAgIG1FeHRlcm5hbFVzYkRldmljZXNGb3JQcm92aWRlciA9IHt1c2JEZXZpY2VzLCBleHRlcm5hbFByb3ZpZGVyfTsKKyAgICAgICAgfQorICAgIH0gZWxzZSBpZiAoZXZlbnRJ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GVyLnN1YnN0cihzdGQ6OnN0cmluZyhJQ2FtZXJhUHJvdmlkZXI6OmRlc2NyaXB0b3IpLnNpemUoKSArIDEpOworICAgIGZvciAoY29uc3QgYXV0byYgcHJvdmlkZXJJbmZvIDogbVByb3ZpZGVycykgeworICAgICAgICBpZiAocHJvdmlkZXJJbmZvLT5tUHJvdmlkZXJOYW1lID09IGV4dHJhY3RlZFByb3ZpZGVyTmFtZSkgeworICAgICAgICAgICAgQUxPR1coIiVzOiBDYW1lcmEgcHJvdmlkZXIgSEFMIHdpdGggbmFtZSAnJXMnIGFscmVhZHkgcmVnaXN0ZXJlZCIsCisgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgbmV3UHJvdmlkZXIuY19zdHIoKSk7CisgICAgICAgICAgICAvLyBEbyBub3QgYWRkIG5ldyBpbnN0YW5jZXMgZm9yIGxhenkgSEFMIGV4dGVybmFsIHByb3ZpZGVyIG9yIGFpZGwKKyAgICAgICAgICAgIC8vIGJpbmRlcnMgcHJldmlvdXNseSBzZWVuLgorICAgICAgICAgICAgaWYgKHByZWV4aXN0aW5nIHx8IHByb3ZpZGVySW5mby0+aXNFeHRlcm5hbExhenlIQUwoKSkgeworICAgICAgICAgICAgICAgIHJldHVybiBBTFJFQURZX0VYSVNUUzsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgQUxPR1coIiVzOiBUaGUgbmV3IHByb3ZpZGVyIGluc3RhbmNlIHdpbGwgZ2V0IGluaXRpYWxpemVkIGltbWVkaWF0ZWx5IGFmdGVyIHRoZSIKKyAgICAgICAgICAgICAgICAgICAgICAgICIgY3VycmVudGx5IHByZXNlbnQgaW5zdGFuY2UgaXMgcmVtb3ZlZCEiLCBfX0ZVTkNUSU9OX18pOworICAgICAgICAgICAgICAgIHByb3ZpZGVyUHJlc2VudCA9IHRydWU7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICB9CisKK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XM6IENhbWVyYSBwcm92aWRlciBIQUwgd2l0aCBuYW1lICclcycgYWxyZWFkeSByZWdpc3RlcmVkIiwKICAgICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fLCBuZXdQcm92aWRlci5jX3N0cigpKTsKLSAgICAgICAgICAgIGlmIChwcmVleGlzdGluZykgeworICAgICAgICAgICAgLy8gRG8gbm90IGFkZCBuZXcgaW5zdGFuY2VzIGZvciBsYXp5IEhBTCBleHRlcm5hbCBwcm92aWRlcgorICAgICAgICAgICAgaWYgKHByZWV4aXN0aW5nIHx8IHByb3ZpZGVySW5mby0+aXNFeHRlcm5hbExhenlIQUwoKSkgewogICAgICAgICAgICAgICAgIHJldHVybiBBTFJFQURZX0VYSVNUUzsKLSAgICAgICAgICAgIH0gZWxzZXsKKyAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgQUxPR1coIiVzOiBUaGUgbmV3IHByb3ZpZGVyIGluc3RhbmNlIHdpbGwgZ2V0IGluaXRpYWxpemVkIGltbWVkaWF0ZWx5IGFmdGVyIHRoZSIKICAgICAgICAgICAgICAgICAgICAgICAgICIgY3VycmVudGx5IHByZXNlbnQgaW5zdGFuY2UgaXMgcmVtb3ZlZCEiLCBfX0ZVTkNUSU9OX18pOwogICAgICAgICAgICAgICAgIHByb3ZpZGVyUHJlc2VudCA9IHRydWU7CkBAIC0xMjgxLDkgKzE3NjcsOSBAQAogICAgICAgICB9CiAgICAgfQogCi0gICAgc3A8UHJvdmlkZXJJbmZvPiBwcm92aWRlckluZm8gPSBuZXcgUHJvdmlkZXJJbmZvKG5ld1Byb3ZpZGVyLCBwcm92aWRlckluc3RhbmNlLCB0aGlzKTsKKyAgICBzcDxIaWRsUHJvdmlkZXJJbmZvPiBwcm92aWRlckluZm8gPSBuZXcgSGlkbFByb3ZpZGVySW5mbyhuZXdQcm92aWRlciwgcHJvdmlkZXJJbnN0YW5jZSwgdGhpcyk7CiAgICAgaWYgKCFwcm92aWRlclByZXNlbnQpIHsKLSAgICAgICAgc3RhdHVzX3QgcmVzID0gdHJ5VG9Jbml0aWFsaXplUHJvdmlkZXJMb2NrZWQobmV3UHJvdmlkZXIsIHByb3ZpZGVySW5mbyk7CisgICAgICAgIHN0YXR1c190IHJlcyA9IHRyeVRvSW5pdGlhbGl6ZUhpZGxQcm92aWRlckxvY2tlZChuZXdQcm92aWRlciwgcHJvdmlkZXJJbmZvKTsKICAgICAgICAgaWYgKHJlcyAhPSBPSykgewogICAgICAgICAgICAgcmV0dXJuIHJlczsKICAgICAgICAgfQpAQCAtMTMyMSw3ICsxODA3LDE3IEBACiAgICAgICAgIC8vIGluaXRpYWxpemUuCiAgICAgICAgIGZvciAoY29uc3QgYXV0byYgcHJvdmlkZXJJbmZvIDogbVByb3ZpZGVycykgewogICAgICAgICAgICAgaWYgKHByb3ZpZGVySW5mby0+bVByb3ZpZGVyTmFtZSA9PSByZW1vdmVkUHJvdmlkZXJOYW1lKSB7Ci0gICAgICAgICAgICAgICAgcmV0dXJuIHRyeVRvSW5pdGlhbGl6ZVByb3ZpZGVyTG9ja2VkKHJlbW92ZWRQcm92aWRlck5hbWUsIHByb3ZpZGVySW5mbyk7CisgICAgICAgICAgICAgICAgSVBDVHJhbnNwb3J0IHByb3ZpZGVyVHJhbnNwb3J0ID0gcHJvdmlkZXJJbmZvLT5nZXRJUENUcmFuc3BvcnQoKTsKKyAgICAgICAgICAgICAgICBzdGQ6OnN0cmluZyByZW1vdmVkQWlkbFByb3ZpZGVyTmFtZSA9IGdldEZ1bGxBaWRsUHJvdmlkZXJOYW1lKHJlbW92ZWRQcm92aWRlck5hbWUpOworICAgICAgICAgICAgICAgIHN3aXRjaChwcm92aWRlclRyYW5zcG9ydCkgeworICAgICAgICAgICAgICAgICAgICBjYXNlIElQQ1RyYW5zcG9ydDo6SElETDoKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnlUb0luaXRpYWxpemVIaWRsUHJvdmlkZXJMb2NrZWQocmVtb3ZlZ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hdHVzIGlkU3RhdHVzLAotICAgICAgICAgICAgY29uc3QgaGFyZHdhcmU6OmhpZGxfdmVjPGhhcmR3YXJlOjpoaWRsX3N0cmluZz4mIGNhbWVyYURldmljZU5hbWVzKSB7Ci0gICAgICAgIHN0YXR1cyA9IGlkU3RhdHVzOwotICAgICAgICBpZiAoc3RhdHVzID09IFN0YXR1czo6T0spIHsKLSAgICAgICAgICAgIGZvciAoYXV0byYgbmFtZSA6IGNhbWVyYURldmljZU5hbWVzKSB7Ci0gICAgICAgICAgICAgICAgdWludDE2X3QgbWFqb3IsIG1pbm9yOwotICAgICAgICAgICAgICAgIHN0ZDo6c3RyaW5nIHR5cGUsIGlkOwotICAgICAgICAgICAgICAgIHN0YXR1c190IHJlcyA9IHBhcnNlRGV2aWNlTmFtZShuYW1lLCAmbWFqb3IsICZtaW5vciwgJnR5cGUsICZpZCk7Ci0gICAgICAgICAgICAgICAgaWYgKHJlcyAhPSBPSykgewotICAgICAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IEVycm9yIHBhcnNpbmcgZGV2aWNlTmFtZTogJXM6ICVkIiwgX19GVU5DVElPTl9fLCBuYW1lLmNfc3RyKCksIHJlcyk7Ci0gICAgICAgICAgICAgICAgICAgIHN0YXR1cyA9IFN0YXR1czo6SU5URVJOQUxfRVJST1I7Ci0gICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgZGV2aWNlcy5wdXNoX2JhY2sobmFtZSk7Ci0gICAgICAgICAgICAgICAgICAgIG1Qcm92aWRlclB1YmxpY0NhbWVyYUlkcy5wdXNoX2JhY2soaWQpOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KLSAgICAgICAgfSB9KTsKLSAgICBpZiAoIXJldC5pc09rKCkpIHsKLSAgICAgICAgQUxPR0UoIiVzOiBUcmFuc2FjdGlvbiBlcnJvciBpbiBnZXR0aW5nIGNhbWVyYSBJRCBsaXN0IGZyb20gcHJvdmlkZXIgJyVz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AgICAgICAgICAgIHJldHVybiBudWxscHRyOwotICAgICAgICB9IGVsc2UgaWYgKCFsaW5rZWQpIHsKLSAgICAgICAgICAgIEFMT0dXKCIlczogVW5hYmxlIHRvIGxpbmsgdG8gcHJvdmlkZXIgJyVzJyBkZWF0aCBub3RpZmljYXRpb25zIiwKLSAgICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fLCBtUHJvdmlkZXJOYW1lLmNfc3RyKCkpOwotICAgICAgICB9Ci0gICAgICAgIC8vIFNlbmQgY3VycmVudCBkZXZpY2Ugc3RhdGUKLSAgICAgICAgaWYgKG1NaW5vclZlcnNpb24gPj0gNSkgewotICAgICAgICAgICAgYXV0byBjYXN0UmVzdWx0ID0gcHJvdmlkZXI6OlYyXzU6OklDYW1lcmFQcm92aWRlcjo6Y2FzdEZyb20oaW50ZXJmYWNlKTsKLSAgICAgICAgICAgIGlmIChjYXN0UmVzdWx0LmlzT2soKSkgewotICAgICAgICAgICAgICAgIHNwPHByb3ZpZGVyOjpWMl81OjpJQ2FtZXJhUHJvdmlkZXI+IGludGVyZmFjZV8yXzUgPSBjYXN0UmVzdWx0OwotICAgICAgICAgICAgICAgIGlmIChpbnRlcmZhY2VfMl81ICE9IG51bGxwdHIpIHsKLSAgICAgICAgICAgICAgICAgICAgQUxPR1YoIiVzOiBJbml0aWFsIGRldmljZSBzdGF0ZSBmb3IgJXM6IDB4ICUiIFBSSXg2NCwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIG1Qcm92aWRlck5hbWUuY19zdHIoKSwgbURldmljZVN0YXRlKTsKLSAgICAgICAgICAgICAgICAgICAgaW50ZXJmYWNlXzJfNS0+bm90aWZ5RGV2aWNlU3RhdGVDaGFuZ2UobURldmljZVN0YXRlKTsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICB9Ci0gICAgICAgIH0KLQotICAgICAgICBtQWN0aXZlSW50ZXJmYWNlID0gaW50ZXJmYWNlOwotICAgIH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ogICAgIGlmIChyZXMgIT0gT0spIHsKICAgICAgICAgcmV0dXJuIHJlczsKICAgICB9CisKICAgICBpZiAodHlwZSAhPSBtVHlwZSkgewogICAgICAgICBBTE9HRSgiJXM6IERldmljZSB0eXBlICVzIGRvZXMgbm90IG1hdGNoIHByb3ZpZGVyIHR5cGUgJXMiLCBfX0ZVTkNUSU9OX18sCiAgICAgICAgICAgICAgICAgdHlwZS5jX3N0cigpLCBtVHlwZS5jX3N0cigpKTsKICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKICAgICB9Ci0gICAgaWYgKG1NYW5hZ2VyLT5pc1ZhbGlkRGV2aWNlTG9ja2VkKGlkLCBtYWpvcikpIHsKKyAgICBpZiAobU1hbmFnZXItPmlzVmFsaWREZXZpY2VMb2NrZWQoaWQsIG1ham9yLCB0cmFuc3BvcnQpKSB7CiAgICAgICAgIEFMT0dFKCIlczogRGV2aWNlICVzOiBJRCAlcyBpcyBhbHJlYWR5IGluIHVzZSBmb3IgZGV2aWNlIG1ham9yIHZlcnNpb24gJWQiLCBfX0ZVTkNUSU9OX18sCiAgICAgICAgICAgICAgICAgbmFtZS5jX3N0cigpLCBpZC5jX3N0cigpLCBtYWpvcik7CiAgICAgICAgIHJldHVybiBCQURfVkFMVUU7CiAgICAgfQogCiAgICAgc3RkOjp1bmlxdWVfcHRyPERldmljZUluZm8+IGRldmljZUluZm87Ci0gICAgc3dpdGNoIChtYWpvcikgewotICAgICAgICBjYXNlIDE6Ci0gICAgICAgICAgICBBTE9HRSgiJXM6IERldmljZSAlczogVW5zdXBwb3J0ZWQgSElETCBkZXZpY2UgSEFMIG1ham9yIHZlcnNpb24gJWQ6IiwgX19GVU5DVElPTl9fLAotICAgICAgICAgICAgICAgICAgICBuYW1lLmNfc3RyKCksIG1ham9yKTsKLSAgICAgICAgICAgIHJldHVybiBCQURfVkFMVUU7Ci0gICAgICAgIGNhc2UgMzoKLSAgICAgICAgICAgIGRldmljZUluZm8gPSBpbml0aWFsaXplRGV2aWNlSW5mbzxEZXZpY2VJbmZvMz4obmFtZSwgbVByb3ZpZGVyVGFnaWQsCi0gICAgICAgICAgICAgICAgICAgIGlkLCBtaW5vcik7CisgICAgc3dpdGNoICh0cmFuc3BvcnQpIHsKKyAgICAgICAgY2FzZSBJUENUcmFuc3BvcnQ6OkhJREw6CisgICAgICAgICAgICBzd2l0Y2ggKG1ham9yKSB7CisgICAgICAgICAgICAgICAgY2FzZSAzOgorICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IERldmljZSAlczogVW5zdXBwb3J0ZWQgSElETCBkZXZpY2UgSEFMIG1ham9yIHZlcnNpb24gJWQ6IiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fLCAgbmFtZS5jX3N0cigpLCBtYWpvcik7CisgICAgICAgICAgICAgICAgICAgIHJldHVybiBCQURfVkFMVUU7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBJUENUcmFuc3BvcnQ6OkFJREw6CisgICAgICAgICAgICBpZiAobWFqb3IgIT0gMSkgeworICAgICAgICAgICAgICAgIEFMT0dFKCIlczogRGV2aWNlICVzOiBVbnN1cHBvcnRlZCBBSURMIGRldmljZSBIQUwgbWFqb3IgdmVyc2lvbiAlZDoiLCBfX0ZVTkNUSU9OX18sCisgICAgICAgICAgICAgICAgICAgICAgICBuYW1lLmNfc3RyKCksIG1ham9yKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gQkFEX1ZBTFVFOworICAgICAgICAgICAgfQogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIGRlZmF1bHQ6Ci0gICAgICAgICAgICBBTE9HRSgiJXM6IERldmljZSAlczogVW5rbm93biBISURMIGRldmljZSBIQUwgbWFqb3IgdmVyc2lvbiAlZDoiLCBfX0ZVTkNUSU9OX18sCi0gICAgICAgICAgICAgICAgICAgIG5hbWUuY19zdHIoKSwgbWFqb3IpOworICAgICAgICAgICAgQUxPR0UoIiVzIEludmFsaWQgdHJhbnNwb3J0ICVkIiwgX19GVU5DVElPTl9fLCB0cmFuc3BvcnQpOwogICAgICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKICAgICB9CisKKyAgICBkZXZpY2VJbmZvID0gaW5pdGlhbGl6ZURldmljZUluZm8obmFtZSwgbVByb3ZpZGVyVGFnaWQsIGlkLCBtaW5vcik7CiAgICAgaWYgKGRldmljZUluZm8gPT0gbnVsbHB0cikgcmV0dXJuIEJBRF9WQUxVRTsKLSAgICBkZXZpY2VJbmZvLT5ub3RpZnlEZXZpY2VTdGF0ZUNoYW5nZShtRGV2aWNlU3RhdGUpOworICAgIGRldmljZUluZm8tPm5vdGlmeURldmljZVN0YXRlQ2hhbmdlKGdldERldmljZVN0YXRlKCkpOwogICAgIGRldmljZUluZm8tPm1TdGF0dXMgPSBpbml0aWFsU3RhdHVzOwogICAgIGJvb2wgaXNBUEkxQ29tcGF0aWJsZSA9IGRldmljZUluZm8tPmlzQVBJMUNvbXBhdGlibGUoKTsKIApAQCAtMTY2NiwxNSArMTkzOCw1MCBAQAogICAgICAgICAgICAgbVVuaXF1ZUNhbWVyYUlkcy5lcmFzZShpZCk7CiAgICAgICAgICAgICBpZiAoKCppdCktPmlzQVBJMUNvbXBhdGlibGUoKSkgewogICAgICAgICAgICAgICAgIG1VbmlxdWVBUEkxQ29tcGF0aWJsZUNhbWVyYUlkcy5lcmFzZShzdGQ6OnJlbW92ZSgKLSAgICAgICAgICAgICAgICAgICAgICAgIG1VbmlxdWVBUEkxQ29tcGF0aWJsZUNhbWVyYUlkcy5iZWdpbigpLAotICAgICAgICAgICAgICAgICAgICAgICAgbVVuaXF1ZUFQSTFDb21wYXRpYmxlQ2FtZXJhSWRzLmVuZCgpLCBpZCkpOworICAgICAgICAgICAgICAgICAgICBtVW5pcXVlQVBJMUNvbXBhdGlibGVDYW1lcmFJZHMuYmVnaW4oKSwKKyAgICAgICAgICAgICAgICAgICAgbVVuaXF1ZUFQSTFDb21wYXRpYmxlQ2FtZXJhSWRzLmVuZCgpLCBpZCkpOwogICAgICAgICAgICAgfQorCisgICAgICAgICAgICAvLyBSZW1vdmUgcmVmZXJlbmNlIHRvIGNhbWVyYSBwcm92aWRlciB0byBhdm9pZCBwb2ludGVyIGxlYWsgd2hlbgorICAgICAgICAgICAgLy8gdW5wbHVnZ2luZyBleHRlcm5hbCBjYW1lcmEgd2hpbGUgaW4gdXNlIHdpdGggbGF6eSBIQUxzCisgICAgICAgICAgICBtTWFuYWdlci0+cmVtb3ZlUmVmKERldmljZU1vZGU6OkNBTUVSQSwgaWQpOworICAgICAgICAgICAgbU1hbmFnZXItPnJlbW92ZVJlZihEZXZpY2VNb2RlOjpUT1JDSCwgaWQpOworCiAgICAgICAgICAgICBtRGV2aWNlcy5lcmFzZShpdCk7CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogICAgIH0KIH0KIAordm9pZCBDYW1lcmFQcm92aWRlck1hbmFnZXI6OlByb3ZpZGVySW5mbzo6cmVtb3ZlQWxsRGV2aWNlcygpIHsKKyAgICBzdGQ6OmxvY2tfZ3VhcmQ8c3RkOjptdXRleD4gbG9jayhtTG9jayk7CisKKyAgICBhdXRvIGl0RGV2aWNlcyA9IG1EZXZpY2VzLmJlZ2luKCk7CisgICAgd2hpbGUgKGl0RGV2aWNlcyAhPSBtRGV2aWNlcy5lbmQoKSkgeworICAgICAgICBzdGQ6OnN0cmluZyBpZCA9ICgqaXREZXZpY2VzKS0+bUlkOworICAgICAgICBzdGQ6OnN0cmluZyBkZXZpY2VOYW1lID0gKCppdERldmljZXMpLT5tTmFtZTsKKyAgICAgICAgcmVtb3ZlRGV2aWNlKGlkKTsKKyAgICAgICAgLy8gZGV2aWNlIHdhcyByZW1vdmVkLCByZXNldCBpdGVyYXRvcgorICAgICAgICBpdERldmljZXMgPSBtRGV2aWNlcy5iZWdpbigpOworCisgIC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AgbUNvbmN1cnJlbnRDYW1lcmFJZENvbWJpbmF0aW9ucy5jbGVhcigpOwotICAgICAgICAgICAgICAgIGZvciAoYXV0byYgY29tYmluYXRpb24gOiBjYW1lcmFEZXZpY2VJZENvbWJpbmF0aW9ucykgewotICAgICAgICAgICAgICAgICAgICBzdGQ6OnVub3JkZXJlZF9zZXQ8c3RkOjpzdHJpbmc+IGRldmljZUlkczsKLSAgICAgICAgICAgICAgICAgICAgZm9yIChhdXRvICZjYW1lcmFEZXZpY2VJZCA6IGNvbWJpbmF0aW9uKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBkZXZpY2VJZHMuaW5zZXJ0KGNhbWVyYURldmljZUlkLmNfc3RyKCkpOwotICAgICAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgICAgIG1Db25jdXJyZW50Q2FtZXJhSWRDb21iaW5hdGlvbnMucHVzaF9iYWNrKHN0ZDo6bW92ZShkZXZpY2VJZHMpKTsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICB9IH0pOwotICAgIGlmICghcmV0LmlzT2soKSkgewotICAgICAgICBBTE9HRSgiJXM6IFRyYW5zYWN0aW9uIGVycm9yIGluIGdldHRpbmcgY29uY3VycmVudCBjYW1lcmEgSUQgbGlzdCBmcm9tIHByb3ZpZGVyICclcyciLAotICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgbVByb3ZpZGVyTmFtZS5jX3N0cigpKTsKLSAgICAgICAgICAgIHJldHVybiBERUFEX09CSkVDVDsKLSAgICB9Ci0gICAgaWYgKHN0YXR1cyAhPSBTdGF0dXM6Ok9LKSB7Ci0gICAgICAgIEFMT0dFKCIlczogVW5hYmxlIHRvIHF1ZXJ5IGZvciBjYW1lcmEgZGV2aWNlcyBmcm9tIHByb3ZpZGVyICclcyciLAotICAgICAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIG1Qcm92aWRlck5hbWUuY19zdHIoKSk7Ci0gICAgICAgIHJldHVybiBtY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ICAgICAgICAgQUxPR0koIkNhbWVyYSBkZXZpY2UgJXMgc3RhdHVzIGlzIG5vdyAlcywgd2FzICVzIiwgY2FtZXJhRGV2aWNlTmFtZS5jX3N0cigpLAotICAgICAgICAgICAgICAgICAgICBkZXZpY2VTdGF0dXNUb1N0cmluZyhuZXdTdGF0dXMpLCBkZXZpY2VTdGF0dXNUb1N0cmluZyhkZXZpY2VJbmZvLT5tU3RhdHVzKSk7CisgICAgICAgICAgICAgICAgICAgIEZyYW1ld29ya0RldmljZVN0YXR1c1RvU3RyaW5nKG5ld1N0YXR1cyksCisgICAgICAgICAgICAgICAgICAgIEZyYW1ld29ya0RldmljZVN0YXR1c1RvU3RyaW5nKGRldmljZUluZm8tPm1TdGF0dXMpKTsKICAgICAgICAgICAgIGRldmljZUluZm8tPm1TdGF0dXMgPSBuZXdTdGF0dXM7CiAgICAgICAgICAgICAvLyBUT0RPOiBIYW5kbGUgZGV2aWNlIHJlbW92YWwgKE5PVF9QUkVTRU5UKQogICAgICAgICAgICAgY2FtZXJhSWQgPSBkZXZpY2VJbmZvLT5tSWQ7CiAgICAgICAgICAgICBrbm93biA9IHRydWU7CisgICAgICAgICAgICBkZXZpY2VJbmZvLT5tSXNEZXZpY2VBdmFpbGFibGUgPQorICAgICAgICAgICAgICAgIChuZXdTdGF0dXMgPT0gQ2FtZXJhRGV2aWNlU3RhdHVzOjpQUkVTRU5UKTsKKyAgICAgICAgICAgIGRldmljZUluZm8tPm1EZXZpY2VBdmFpbGFibGVTaWduYWwuc2lnbmFsKCk7CiAgICAgICAgICAgICBicmVhazsKICAgICAgICAgfQogICAgIH0KQEAgLTE4NzMsNyArMjEyMCwxMyBAQAogICAgICAgICBhZGREZXZpY2UoY2FtZXJhRGV2aWNlTmFtZSwgbmV3U3RhdHVzLCAmY2FtZXJhSWQpOwogICAgIH0gZWxzZSBpZiAobmV3U3RhdHVzID09IENhbWVyYURldmljZVN0YXR1czo6Tk9UX1BSRVNFTlQpIHsKICAgICAgICAgc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ID0gZmFsc2U7CisgICAgICAgIC8vIEhvbGQgbUxvY2sgZm9yIGFjY2Vzc2luZyBtRGV2aWNlcworICAgICAgICBzdGQ6OmxvY2tfZ3VhcmQ8c3RkOjptdXRleD4gbG9jayhtTG9jayk7CiAgICAgICAgIGZvciAoYXV0byYgZGV2aWNlSW5mbyA6IG1EZXZpY2VzKSB7CiAgICAgICAgICAgICBpZiAoZGV2aWNlSW5mby0+bU5hbWUgPT0gY2FtZXJhRGV2aWNlTmFtZSkgewogICAgICAgICAgICAgICAgIEFMT0dJKCJDYW1lcmEgZGV2aWNlICVzIHRvcmNoIHN0YXR1cyBpcyBub3cgJXMiLCBjYW1lcmFEZXZpY2VOYW1lLmNfc3RyKCksCi0gICAgICAgICAgICAgICAgICAgICAgICB0b3JjaFN0YXR1c1RvU3RyaW5nKG5ld1N0YXR1cykpOworICAgICAgICAgICAgICAgICAgICAgICAgRnJhbWV3b3JrVG9yY2hTdGF0dXNUb1N0cmluZyhuZXdTdGF0dXMpKTsKICAgICAgICAgICAgICAgICBpZCA9IGRldmljZUluZm8tPm1JZDsKICAgICAgICAgICAgICAgICBrbm93biA9IHRydWU7CisgICAgICAgICAgICAgICAgc3lzdGVtQ2FtZXJhS2luZCA9IGRldmljZUluZm8tPm1TeXN0ZW1DYW1lcmFLaW5kOwogICAgICAgICAgICAgICAgIGlmIChUb3JjaE1vZGVTdGF0dXM6OkFWQUlMQUJMRV9PTiAhPSBuZXdTdGF0dXMpIHsKLSAgICAgICAgICAgICAgICAgICAgbU1hbmFnZXItPnJlbW92ZVJlZihEZXZpY2VNb2RlOjpUT1JDSCwgaWQpOworICAgICAgICAgICAgICAgICAgICBtTWFuYWdlci0+cmVtb3ZlUmVmKENhbWVyYVByb3ZpZGVyTWFuYWdlcjo6RGV2aWNlTW9kZTo6VE9SQ0gsIGlkKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICB9CkBAIC0xOTc5LDE3NS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JpbmF0aW9uRnJvbVYzN1RvVjM0KAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFsQ2FtZXJhSWRzQW5kU3RyZWFtQ29tYmluYXRpb25zXzJfNltpXS5zdHJlYW1Db25maWd1cmF0aW9uLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tYmluYXRpb24uc3RyZWFtQ29uZmlndXJhdGlvbik7Ci0gICAgICAgICAgICAgICAgICAgIGlmICghc3VjY2VzcykgewotICAgICAgICAgICAgICAgICAgICAgICAgKmlzU3VwcG9ydGVkID0gZmFsc2U7Ci0gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gT0s7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgcmV0ID0gaW50ZXJmYWNlXzJfNi0+aXNDb25jdXJyZW50U3RyZWFtQ29tYmluYXRpb25TdXBwb3J0ZWQoCi0gICAgICAgICAgICAgICAgICAgICAgICBoYWxDYW1lcmFJZHNBbmRTdHJlYW1Db21iaW5hdGlvbnNfMl82LCBjYik7Ci0gICAgICAgICAgICB9Ci0gICAgICAgIH0KLQotICAgICAgICBpZiAoaW50ZXJmYWNlXzJfNyAhPSBudWxscHRyIHx8IGludGVyZmFjZV8yXzYgIT0gbnVsbHB0cikgewotICAgICAgICAgICAgaWYgKHJldC5pc09rKCkpIHsKLSAgICAgICAgICAgICAgICBzd2l0Y2ggKGNhbGxTdGF0dXMpIHsKLSAgICAgICAgICAgICAgICAgICAgY2FzZSBTdGF0dXM6Ok9LOgotICAgICAgICAgICAgICAgICAgICAgICAgLy8gRXhwZWN0ZWQgY2FzZSwgZG8gbm90aGluZy4KLSAgICAgICAgICAgICAgICAgICAgICAgIHJlcyA9IE9LOwotICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgICAgIGNhc2UgU3RhdHVzOjpNRVRIT0RfTk9UX1NVUFBPUlRFRDoKLSAgICAgICAgICAgICAgICAgICAgICAgIHJlcyA9IElOVkFMSURfT1BFUkFUSU9OOwotICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6Ci0gICAgICAgICAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IFNlc3Npb24gY29uZmlndXJhdGlvbiBxdWVyeSBmYWlsZWQ6ICVkIiwgX19GVU5DVElPTl9fLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxTdGF0dXMpOwotICAgICAgICAgICAgICAgICAgICAgICAgcmVzID0gVU5LTk9XTl9FUlJPUjsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIEFMT0dFKCIlczogVW5leHBlY3RlZCBiaW5kZXIgZXJyb3I6ICVzIiwgX19GVU5DVElPTl9fLCByZXQuZGVzY3JpcHRpb24oKS5jX3N0cigpKTsKLSAgICAgICAgICAgICAgICByZXMgPSBVTktOT1dOX0VSUk9SOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgcmV0dXJuIHJlczsKLSAgICAgICAgfQotICAgIH0KLSAgICAvLyB1bnN1cHBvcnRlZCBvcGVyYXRpb24KLSAgICByZXR1cm4gSU5WQUxJRF9PUEVSQVRJT047Ci19Ci0KIHZvaWQgQ2FtZXJhUHJvdmlkZXJNYW5hZ2VyOjpQcm92aWRlckluZm86Om5vdGlmeUluaXRpYWxTdGF0dXNDaGFuZ2UoCiAgICAgICAgIHNwPFN0YXR1c0xpc3RlbmVyPiBsaXN0ZW5lciwKICAgICAgICAgc3RkOjp1bmlxdWVfcHRyPHN0ZDo6dmVjdG9yPENhbWVyYVN0YXR1c0luZm9UPj4gY2FjaGVkU3RhdHVzKSB7CkBAIC0yMTYyLDI5MCArMjI3NSwxNiBAQAogICAgIH0KIH0KIAotdGVtcGxhdGU8Y2xhc3MgRGV2aWNlSW5mb1Q+Ci1zdGQ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yB8fCByZXMgPT0gQ0FNRVJBX01FVEFEQVRBX1ZBTElEQVRJT05fU0hJRlRFRCkgewotICAgICAgICAgICAgICAgICAgICAgICAgc2V0X2NhbWVyYV9tZXRhZGF0YV92ZW5kb3JfaWQoYnVmZmVyLCBtUHJvdmlkZXJUYWdpZCk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBtQ2FtZXJhQ2hhcmFjdGVyaXN0aWNzID0gYnVmZmVyOwotICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICAgICAgQUxPR0UoIiVzOiBNYWxmb3JtZWQgY2FtZXJhIG1ldGFkYXRhIHJlY2VpdmVkIGZyb20gSEFMIiwgX19GVU5DVElPTl9fKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIHN0YXR1cyA9IFN0YXR1czo6SU5URVJOQUxfRVJST1I7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICB9KTsKLSAgICBpZiAoIXJldC5pc09rKCkpIHsKLSAgICAgICAgQUxPR0UoIiVzOiBUcmFuc2FjdGlvbiBlcnJvciBnZXR0aW5nIGNhbWVyYSBjaGFyYWN0ZXJpc3RpY3MgZm9yIGRldmljZSAlcyIKLSAgICAgICAgICAgICAgICAiIHRvIGNoZWNrIGZvciBhIGZsYXNoIHVuaXQ6ICVzIiwgX19GVU5DVElPTl9fLCBpZC5jX3N0cigpLAotICAgICAgICAgICAgICAgIHJldC5kZXNjcmlwdGlvbigpLmNfc3RyKCkpOwotICAgICAgICByZXR1cm47Ci0gICAgfQotICAgIGlmIChzdGF0dXMgIT0gU3RhdHVzOjpPSykgewotICAgICAgICBBTE9HRSgiJXM6IFVuYWJsZSB0byBnZXQgY2FtZXJhIGNoYXJhY3RlcmlzdGljcyBmb3IgZGV2aWNlICVzOiAlcyAoJWQpIiwKLSAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIGlkLmNfc3RyKCksIENhbWVyYVBy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6Ok9LKSB7Ci0gICAgICAgICAgICAgICAgICAgIGNhbWVyYV9tZXRhZGF0YV90ICpidWZmZXIgPQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlaW50ZXJwcmV0X2Nhc3Q8Y2FtZXJhX21ldGFkYXRhX3QqPihtZXRhZGF0YS5kYXRhKCkpOwotICAgICAgICAgICAgICAgICAgICBzaXplX3QgZXhwZWN0ZWRTaXplID0gbWV0YWRhdGEuc2l6ZSgpOwotICAgICAgICAgICAgICAgICAgICBpbnQgcmVzID0gdmFsaWRhdGVfY2FtZXJhX21ldGFkYXRhX3N0cnVjdHVyZShidWZmZXIsICZleHBlY3RlZFNpemUpOwotICAgICAgICAgICAgICAgICAgICBpZiAocmVzID09IE9LIHx8IHJlcyA9PSBDQU1FUkFfTUVUQURBVEFfVkFMSURBVElPTl9TSElGVEVEKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBzZXRfY2FtZXJhX21ldGFkYXRhX3ZlbmRvcl9pZChidWZmZXIsIG1Qcm92aWRlclRhZ2lkKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIG1QaHlzaWNhbENhbWVyYUNoYXJhY3RlcmlzdGljc1tpZF0gPSBidWZmZXI7Ci0gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IE1hbGZvcm1lZCBjYW1lcmEgbWV0YWRhdGEgcmVjZWl2ZWQgZnJvbSBIQUwiLCBfX0ZVTkNUSU9OX18pOwotICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzID0gU3RhdHVzOjpJTlRFUk5BTF9FUlJPUjsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0pOwotCi0gICAgICAgICAgICBpZiAoIXJldC5pc09rKCkpIHsKLSAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IFRyYW5zYWN0aW9uIGVycm9yIGdldHRpbmcgcGh5c2ljYWwgY2FtZXJhICVzIGNoYXJhY3RlcmlzdGljcyBmb3IgJXM6ICVzIiwKLSAgICAgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgaWQuY19zdHIoKSwgaWQuY19zdHIoKSwgcmV0LmRlc2NyaXB0aW9uKCkuY19zdHIoKSk7Ci0gICAgICAgICAgICAgICAgcmV0dXJuOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgaWYgKHN0YXR1cyAhPSBTdGF0dXM6Ok9LKSB7Ci0gICAgICAgICAgICAgICAgQUxPR0UoIiVzOiBVbmFibGUgdG8gZ2V0IHBoeXNpY2FsIGNhbWVyYSAlcyBjaGFyYWN0ZXJpc3RpY3MgZm9yIGRldmljZSAlczogJXMgKCVkKSIsCi0gICAgICAgICAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIGlkLmNfc3RyKCksIG1JZC5jX3N0cigpLAotICAgICAgICAgICAgICAgICAgICAgICAgQ2FtZXJhUHJvdmlkZXJNYW5hZ2VyOjpzdGF0dXNUb1N0cmluZyhzdGF0dXMpLCBzdGF0dXMpOwotICAgICAgICAgICAgICAgIHJldHVybjsKLSAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgcmVzID0gY2FtZXJhMzo6Wm9vbVJhdGlvTWFwcGVyOjpvdmVycmlkZVpvb21SYXRpb1RhZ3MoCi0gICAgICAgICAgICAgICAgICAgICZtUGh5c2ljYWxDYW1lcmFDaGFyYWN0ZXJpc3RpY3NbaWRdLCAmbVN1cHBvcnROYXRpdmVab29tUmF0aW8pOwotICAgICAgICAgICAgaWYgKE9LICE9IHJlcykgewotICAgICAgICAgICAgICAgIEFMT0dFKCIlczogVW5hYmxlIHRvIG92ZXJyaWRlIHpvb21SYXRpbyByZWxhdGVkIHRhZ3M6ICVzICglZCkiLAotICAgICAgICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fLCBzdHJlcnJvcigtcmVzKSwgcmVzKTsKLSAgICAgICAgICAgIH0KLSAgICAgICA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AgICAgIGlmICghc3VjY2VzcykgewotICAgICAgICAgICAgKnN0YXR1cyA9IGZhbHNlOwotICAgICAgICAgICAgcmV0dXJuIE9LOwotICAgICAgICB9Ci0gICAgICAgIHJldCA9IGludGVyZmFjZV8zXzUtPmlzU3RyZWFtQ29tYmluYXRpb25TdXBwb3J0ZWQoY29uZmlndXJhdGlvbl8zXzQsIGhhbENiKTsKLSAgICB9IGVsc2UgewotICAgICAgICByZXR1cm4gSU5WQUxJRF9PUEVSQVRJT047Ci0gICAgfQotICAgIGlmIChyZXQuaXNPaygpKSB7Ci0gICAgICAgIHN3aXRjaCAoY2FsbFN0YXR1cykgewotICAgICAgICAgICAgY2FzZSBTdGF0dXM6Ok9LOgotICAgICAgICAgICAgICAgIC8vIEV4cGVjdGVkIGNhc2UsIGRvIG5vdGhpbmcuCi0gICAgICAgICAgICAgICAgcmVzID0gT0s7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICBjYXNlIFN0YXR1czo6TUVUSE9EX05PVF9TVVBQT1JURUQ6Ci0gICAgICAgICAgICAgICAgcmVzID0gSU5WQUxJRF9PUEVSQVRJT047Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAgICAgIEFMT0dFKCIlczogU2Vzc2lvbiBjb25maWd1cmF0aW9uIHF1ZXJ5IGZhaWxlZDogJWQiLCBfX0ZVTkNUSU9OX18sIGNhbGxTdGF0dXMpOwotICAgICAgICAgICAgICAgIHJlcyA9IFVOS05PV05fRVJST1I7Ci0gICAgICAgIH0KLSAgICB9IGVsc2UgewotICAgICAgICBBTE9HRSgiJXM6IFVuZXhwZWN0ZWQgYmluZGVyIGVycm9yOiAlcyIsIF9fRlVOQ1RJT05fXywgcmV0LmRlc2NyaXB0aW9uKCkuY19zdHIoKSk7Ci0gICAgICAgIHJlcyA9IFVOS05PV05fRVJST1I7Ci0gICAgfQotCi0gICAgcmV0dXJuIHJlczsKLX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sKLSAgICAgICAgICAgIHN0YXR1c190IHJlcyA9IGNvbnZlcnRUb0hBTFN0cmVhbUNvbWJpbmF0aW9uQW5kQ2FtZXJhSWRzTG9ja2VkKAotICAgICAgICAgICAgICAgICAgICBjYW1lcmFJZHNBbmRTZXNzaW9uQ29uZmlncywgcGVyZkNsYXNzUHJpbWFyeUNhbWVyYUlkcywKLSAgICAgICAgICAgICAgICAgICAgdGFyZ2V0U2RrVmVyc2lvbiwgJmhhbENhbWVyYUlkc0FuZFN0cmVhbUNvbWJpbmF0aW9ucywgJmtub3dVbnN1cHBvcnRlZCk7Ci0gICAgICAgICAgICBpZiAocmVzICE9IE9LKSB7Ci0gICAgICAgICAgICAgICAgQUxPR0UoIiVzIHVuYWJsZSB0byBjb252ZXJ0IHNlc3Npb24gY29uZmlndXJhdGlvbnMgcHJvdmlkZWQgdG8gSEFMIHN0cmVhbSIKLSAgICAgICAgICAgICAgICAgICAgICAiY29tYmluYXRpb25zIiwgX19GVU5DVElPTl9fKTsKLSAgICAgICAgICAgICAgICByZXR1cm4gcmVzOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgaWYgKGtub3dVbnN1cHBvcnRlZCkgewotICAgICAgICAgICAgICAgIC8vIFdlIGdvdCB0byBrbm93IHRoZSBzdHJlYW1zIGFyZW4ndCB2YWxpZCBiZWZvcmUgZG9pbmcgdGhlIEhBTAotICAgICAgICAgICAgICAgIC8vIGNhbGwgaXRzZWxmLgotICAgICAgICAgICAgICAgICppc1N1cHBvcnRlZCA9IGZhbHNlOwotICAgICAgICAgICAgICAgIHJldHVybiBPSzsKLSAgICAgICAgICAgIH0KICAgICAgICAgICAgIHJldHVybiBwcm92aWRlci0+aXNDb25jdXJyZW50U2Vzc2lvbkNvbmZpZ3VyYXRpb25TdXBwb3J0ZWQoCi0gICAgICAgICAgICAgICAgICAgIGhhbENhbWVyYUlkc0FuZFN0cmVhbUNvbWJpbmF0aW9ucywgaXNTdXBwb3J0ZWQpOworICAgICAgICAgICAgICA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CBzdGF0dXNfdCBkdW1wU3RhdGUoaW50IGZkKSA9IDA7CkBAIC00OTQsNDQgKzU3NywzMyBAQAogICAgICAgICAgICAgfQogCiAgICAgICAgICAgICB2aXJ0dWFsIHN0YXR1c190IGlzU2Vzc2lvbkNvbmZpZ3VyYXRpb25TdXBwb3J0ZWQoCi0gICAgICAgICAgICAgICAgICAgIGNvbnN0IGhhcmR3YXJlOjpjYW1lcmE6OmRldmljZTo6VjNfNzo6U3RyZWFtQ29uZmlndXJhdGlvbiAmLypjb25maWd1cmF0aW9uKi8sCisgICAgICAgICAgICAgICAgICAgIGNvbnN0IFNlc3Npb25Db25maWd1cmF0aW9uICYvKmNvbmZpZ3VyYXRpb24qLywKKyAgICAgICAgICAgICAgICAgICAgYm9vbCAvKm92ZXJyaWRlRm9yUGVyZkNsYXNzKi8sCisgICAgICAgICAgICAgICAgICAgIGNhbWVyYTM6Om1ldGFkYXRhR2V0dGVyIC8qZ2V0TWV0YWRhdGEqLywKICAgICAgICAgICAgICAgICAgICAgYm9vbCAqIC8qc3RhdHVzKi8pIHsKICAgICAgICAgICAgICAgICByZXR1cm4gSU5WQUxJRF9PUEVSQVRJT047CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICB2aXJ0dWFsIHN0YXR1c190IGZpbHRlclNtYWxsSnBlZ1NpemVzKCkgPSAwOwotICAgICAgICAgICAgdmlydHVhbCB2b2lkIG5vdGlmeURldmljZVN0YXRlQ2hhbmdlKAotICAgICAgICAgICAgICAgICAgICBoYXJkd2FyZTo6aGlkbF9iaXRmaWVsZDxoYXJkd2FyZTo6Y2FtZXJhOjpwcm92aWRlcjo6VjJfNTo6RGV2aWNlU3RhdGU+Ci0gICAgICAgICAgICAgICAgICAgICAgICAvKm5ld1N0YXRlKi8pIHt9Ci0KLSAgICAgICAgICAgIHRlbXBsYXRlPGNsYXNzIEludGVyZmFjZVQ+Ci0gICAgICAgICAgICBzcDxJbnRlcmZhY2VUPiBzdGFydERldmljZUludGVyZmFjZSg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yaW5nJiBwaHlzaWNhbENhbWVyYUlkLAogICAgICAgICAgICAgICAgICAgICBDYW1lcmFNZXRhZGF0YSAqY2hhcmFjdGVyaXN0aWNzKSBjb25zdCBvdmVycmlkZTsKICAgICAgICAgICAgIHZpcnR1YWwgc3RhdHVzX3QgaXNTZXNzaW9uQ29uZmlndXJhdGlvblN1cHBvcnRlZCgKLSAgICAgICAgICAgICAgICAgICAgY29uc3QgaGFyZHdhcmU6OmNhbWVyYTo6ZGV2aWNlOjpWM183OjpTdHJlYW1Db25maWd1cmF0aW9uICZjb25maWd1cmF0aW9uLAotICAgICAgICAgICAgICAgICAgICBib29sICpzdGF0dXMgLypvdXQqLykKLSAgICAgICAgICAgICAgICAgICAgb3ZlcnJpZGU7CisgICAgICAgICAgICAgICAgICAgIGNvbnN0IFNlc3Npb25Db25maWd1cmF0aW9uICZjb25maWd1cmF0aW9uLCBib29sIC8qb3ZlcnJpZGVGb3JQZXJmQ2xhc3MqLywKKyAgICAgICAgICAgICAgICAgICAgY2FtZXJhMzo6bWV0YWRhdGFHZXR0ZXIgLypnZXRNZXRhZGF0YSovLAorICAgICAgICAgICAgICAgICAgICBib29sICpzdGF0dXMgLypvdXQqLykgPSAwOwogICAgICAgICAgICAgdmlydHVhbCBzdGF0dXNfdCBmaWx0ZXJTbWFsbEpwZWdTaXplcygpIG92ZXJyaWRlOwogICAgICAgICAgICAgdmlydHVhbCB2b2lkIG5vdGlmeURldmljZVN0YXRlQ2hhbmdlKAotICAgICAgICAgICAgICAgICAgICBoYXJkd2FyZTo6aGlkbF9iaXRmaWVsZDxoYXJkd2FyZTo6Y2FtZXJhOjpwcm92aWRlcjo6VjJfNTo6RGV2aWNlU3RhdGU+Ci0gICAgICAgICAgICAgICAgICAgICAgICBuZXdTdGF0ZSkgb3ZlcnJpZGU7CisgICAgICAgICAgICAgICAgICAgICAgICBpbnQ2NF90IG5ld1N0YXRlKSBvdmVycmlkZTsKIAogICAgICAgICAgICAgRGV2aWNlSW5mbzMo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sKKyAgICAgICAgcmV0dXJuIG1TYXZlZEludGVyZmFjZTsKKyAgICB9CisgICAgaWYgKCFrRW5hYmxlTGF6eUhhbCkgeworICAgICAgICBBTE9HRSgiQmFkIHByb3ZpZGVyIHN0YXRlISBTaG91bGQgbm90IGJlIGhlcmUgb24gYSBub24tbGF6eSBIQUwhIik7CisgICAgICAgIHJldHVybiBudWxscHRyOworICAgIH0KKworICAgIGF1dG8gaW50ZXJmYWNlID0gbUFjdGl2ZUludGVyZmFjZS5sb2NrKCk7CisgICAgaWYgKGludGVyZmFjZSA9PSBudWxscHRyKSB7CisgICAgICAgIC8vIFRyeSB0byBnZXQgc2VydmljZSB3aXRob3V0IHN0YXJ0aW5nCisgICAgICAgIGludGVyZmFjZSA9CisgICAgICAgICAgICAgICAgICAgIElDYW1lcmFQcm92aWRlcjo6ZnJvbUJpbmRlcigKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZGs6OlNwQUlCaW5kZXIoQVNlcnZpY2VNYW5hZ2VyX2NoZWNrU2VydmljZShtUHJvdmlkZXJOYW1lLmNfc3RyKCkpKSk7CisgICAgICAgIGlmIChpbnRlcmZhY2UgPT0gbnVsbHB0cikgeworICAgICAgICAgICAgQUxPR1YoIkNhbWVyYSBwcm92aWRlciBhY3R1YWxseSBuZWVkcyByZXN0YXJ0LCBjYWxsaW5nIGdldFNlcnZpY2UoJXMpIiwKKyAgICAgICAgICAgICAgICAgIG1Qcm92aWRlck5hbWUuY19zdHIoKSk7CisgICAgICAgICAgICBpbnRlcmZhY2UgPQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIElDYW1lcmFQcm92aWRlcjo6ZnJvbUJpbmRlcigKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5kazo6U3BBSUJpbmRlcigKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEFTZXJ2aWNlTWFuYWdlcl9nZXRTZXJ2aWNlKG1Qcm92aWRlck5hbWUuY19zdHIoKSkpKTsKKworICAgICAgICAgICAgLy8gU2V0IGFsbCBkZXZpY2VzIGFzIEVOVU1FUkFUSU5HLCBwcm92aWRlciBzaG91bGQgdXBkYXRlIHN0YXR1cworICAgICAgICAgICAgLy8gdG8gUFJFU0VOVCBhZnRlciBpbml0aWFsaXppbmcuCisgICAgICAgICAgICAvLyBUaGlzIGF2b2lkcyBmYWlsaW5nIGdldENhbWVyYURldmljZUludGVyZmFjZV9WM194IGJlZm9yZSBkZXZpY2VzCisgICAgICAgICAgICAvLyBhcmUgcmVhZHkuCisgICAgICAgICAgICBmb3IgKGF1dG8mIGRldmljZSA6IG1EZXZpY2VzKSB7CisgICAgICAgICAgICAgIGRldmljZS0+bUlzRGV2aWNlQXZhaWxhYmxlID0gZmFsc2U7CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIGludGVyZmFjZS0+c2V0Q2FsbGJhY2sobUNhbGxiYWNrcyk7CisgICAgICAgICAgICBhdXRvIGxpbmsgPSBBSUJpbmRlcl9saW5rVG9EZWF0aChpbnRlcmZhY2UtPmFzQmluZGVyKCkuZ2V0KCksIG1EZWF0aFJlY2lwaWVudC5nZXQoKSwKKyAgICAgICAgICAgICAgICAgICAgdGhpcyk7CisgICAgICAgICAgICBpZiAobGluayAhPSBTVEFUVVNfT0spIHsKKyAgICAgICAgICAgICAgICBBTE9HVygiJXM6IFVuYWJsZSB0byBsaW5rIHRvIHByb3ZpZGVyICclcycgZGVhdGggbm90aWZpY2F0aW9ucyIsCisgICAgICAgICAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIG1Qcm92aWRlck5hbWUuY19zdHIoKSk7CisgICAgICAgICAgICAgICAgbU1hbmFnZXItPnJlbW92ZVByb3ZpZGVyKG1Qcm92aWRlck5hbWUpOworICAgICAgICAgICAgICAgIHJldHVybiBudWxscHRyOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICAvLyBTZW5kIGN1cnJlbnQgZGV2aWNlIHN0YXRlCisgICAgICAg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UmVzb3VyY2VDb3N0KCZyZXNvdXJjZUNvc3QpOworICAgIGlmICghc3RhdHVzLmlzT2soKSkgeworICAgICAgICBBTE9HRSgiJXM6IFVuYWJsZSB0byBvYnRhaW4gcmVzb3VyY2UgY29zdHMgZm9yIGNhbWVyYSBkZXZpY2UgJXM6ICVzIiwgX19GVU5DVElPTl9fLAorICAgICAgICAgICAgICAgIG5hbWUuY19zdHIoKSwgc3RhdHVzLmdldE1lc3NhZ2UoKSk7CisgICAgICAgIHJldHVybiBudWxscHRyOworICAgIH0KKworICAgIGZvciAoYXV0byYgY29uZmxpY3ROYW1lIDogcmVzb3VyY2VDb3N0LmNvbmZsaWN0aW5nRGV2aWNlcykgeworICAgICAgICB1aW50MTZfdCBtYWpvciwgbWlub3I7CisgICAgICAgIHN0ZDo6c3RyaW5nIHR5cGUsIGlkOworICAgICAgICBzdGF0dXNfdCByZXMgPSBwYXJzZURldmljZU5hbWUoY29uZmxpY3ROYW1lLCAmbWFqb3IsICZtaW5vciwgJnR5cGUsICZpZCk7CisgICAgICAgIGlmIChyZXMgIT0gT0spIHsKKyAgICAgICAgICAgIEFMT0dFKCIlczogRmFpbGVkIHRvIHBhcnNlIGNvbmZsaWN0aW5nIGRldmljZSAlcyIsIF9fRlVOQ1RJT05fXywgY29uZmxpY3ROYW1lLmNfc3RyKCkpOworICAgICAgICAgICAgcmV0dXJuIG51bGxwdHI7CisgICAgICAgIH0KKyAgICAgICAgY29uZmxpY3ROYW1lID0gaWQ7CisgICAgfQorCisgICAgcmV0dXJuIHN0ZDo6dW5pcXVlX3B0cjxEZXZpY2VJbmZvMz4oCisgICAgICAgIG5ldyBBaWRsRGV2aWNlSW5mbzMobmFtZSwgdGFnSWQsIGlkLCBtaW5vclZlcnNpb24sIEhhbFRvRnJhbWV3b3JrUmVzb3VyY2VDb3N0KHJlc291cmNlQ29zdCksCisgICAgICAgICAgICAgICAgdGhpcywgbVByb3ZpZGVyUHVibGljQ2FtZXJhSWRzLCBjYW1lcmF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ljcy5maW5kKEFORFJPSURfSU5GT19ERVZJQ0VfU1RBVEVfT1JJRU5UQVRJT05TKTsKKyAgICAgICAgaWYgKChzdGF0ZU1hcC5jb3VudCA+IDApICYmICgoc3RhdGVNYXAuY291bnQgJSAyKSA9PSAwKSkgeworICAgICAgICAgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCBzdGF0ZU1hcC5jb3VudDsgaSArPSAyKSB7CisgICAgICAgICAgICAgICAgbURldmljZVN0YXRlT3JpZW50YXRpb25NYXAuZW1wbGFjZShzdGF0ZU1hcC5kYXRhLmk2NFtpXSwgc3RhdGVNYXAuZGF0YS5pNjRbaSsxXSk7CisgICAgICAgICAgICB9CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICBBTE9HVygiJXM6IEludmFsaWQgQU5EUk9JRF9JTkZPX0RFVklDRV9TVEFURV9PUklFTlRBVElPTlMgbWFwIHNpemU6ICV6dSIsIF9fRlVOQ1RJT05fXywKKyAgICAgICAgICAgICAgICAgICAgc3RhdGVNYXAuY291bnQpOworICAgICAgICB9CisgICAgfQorCisgICAgbVN5c3RlbUNhbWVyYUtpbmQgPSBnZXRTeXN0ZW1DYW1lcmFLaW5kKCk7CisKKyAgICBzdGF0dXNfdCByZXMgPSBmaXh1cE1vbm9jaHJvbWVUYWdzKCk7CisgICAgaWYgKE9LICE9IHJlcykgeworICAgICAgICBBTE9HRSgiJXM6IFVuYWJsZSB0byBmaXggdXAgbW9ub2Nocm9tZSB0YWdzIGJhc2VkIGZvciBvbGRlciBIQUwgdmVyc2lvbjogJXMgKCVkKSIsCisgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fLCBzdHJlcnJvcigtcmVzKSwgcmVzKTsKKyAgICAgICAgcmV0dXJuOworICAgIH0KKyAgICBhdXRvIHN0YXQgPSBhZGREeW5hbWljRGVwdGhUYWdzKCk7CisgICAgaWYgKE9LICE9IHN0YXQpIHsKKyAgICAgICAgQUxPR0UoIiVzOiBGYWlsZWQgYXBwZW5ka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lZGlhIGNhcGFiaWxpdGllcyBmb3IiCisgICAgICAgICAgICAgICAgICAgICJtYXhpbXVtIHJlc29sdXRpb24gbW9kZTogJXMgKCVkKSIsIF9fRlVOQ1RJT05fXywgc3RyZXJyb3IoLXN0YXR1cyksIHN0YXR1cyk7CisgICAgICAgIH0KKyAgICB9CisKKyAgICByZXMgPSBhZGRSb3RhdGVDcm9wVGFncygpOworICAgIGlmIChPSyAhPSByZXMpIHsKKyAgICAgICAgQUxPR0UoIiVzOiBVbmFibGUgdG8gYWRkIGRlZmF1bHQgU0NBTEVSX1JPVEFURV9BTkRfQ1JPUCB0YWdzOiAlcyAoJWQpIiwgX19GVU5DVElPTl9fLAorICAgICAgICAgICAgICAgIHN0cmVycm9yKC1yZXMpLCByZXMpOworICAgIH0KKyAgICByZXMgPSBhZGRQcmVDb3JyZWN0aW9uQWN0aXZlQXJyYXlTaXplKCk7CisgICAgaWYgKE9LICE9IHJlcykgeworICAgICAgICBBTE9HRSgiJXM6IFVuYWJsZSB0byBhZGQgUFJFX0NPUlJFQ1RJT05fQUNUSVZFX0FSUkFZX1NJWkU6ICVzICglZCkiLCBfX0ZVTkNUSU9OX18sCisgICAgICAgICAgICAgICAgc3RyZXJyb3IoLXJlcyksIHJlcyk7CisgICAgfQorICAgIHJlcyA9IGNhbWVyYTM6Olpvb21SYXRpb01hcHBlcjo6b3ZlcnJpZGVab29tUmF0aW9UYWdzKAorICAgICAgICAgICAgJm1DYW1lcmFDaGFyYWN0ZXJpc3RpY3MsICZtU3VwcG9ydE5hdGl2ZVpvb21SYXRpbyk7CisgICAgaWYgKE9LICE9IHJlcykgeworICAgICAgICBBTE9HRSgiJXM6IFVuYWJsZSB0byBvdmVycmlkZSB6b29tUmF0aW8gcmVsYXRlZCB0YWdzOiAlcyAoJWQpIiwKKyAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIHN0cmVycm9yKC1yZXMpLCByZXMpOworICAgIH0KKworICAgIGNhbWVyYV9tZXRhZGF0YV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Y2FsQ2FtZXJhQ2hhcmFjdGVyaXN0aWNzKGlkLCAmcENoYXJzKTsKKyAgICAgICAgICAgIGlmICghc3RhdHVzLmlzT2soKSkgeworICAgICAgICAgICAgICAgIEFMT0dFKCIlczogVHJhbnNhY3Rpb24gZXJyb3IgZ2V0dGluZyBwaHlzaWNhbCBjYW1lcmEgJXMgY2hhcmFjdGVyaXN0aWNzIGZvciAlczogJXMiLAorICAgICAgICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fLCBpZC5jX3N0cigpLCBpZC5jX3N0cigpLCBzdGF0dXMuZ2V0TWVzc2FnZSgpKTsKKyAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICB9CisgICAgICAgICAgICBzdGQ6OnZlY3Rvcjx1aW50OF90PiAmcE1ldGFkYXRhID0gcENoYXJzLm1ldGFkYXRhOworICAgICAgICAgICAgY2FtZXJhX21ldGFkYXRhX3QgKnBCdWZmZXIgPQorICAgICAgICAgICAgICAgICAgICByZWludGVycHJldF9jYXN0PGNhbWVyYV9tZXRhZGF0YV90Kj4ocE1ldGFkYXRhLmRhdGEoKSk7CisgICAgICAgICAgICBzaXplX3QgZXhwZWN0ZWRTaXplID0gcE1ldGFkYXRhLnNpemUoKTsKKyAgICAgICAgICAgIGludCByZXMgPSB2YWxpZGF0ZV9jYW1lcmFfbWV0YWRhdGFfc3RydWN0dXJlKHBCdWZmZXIsICZleHBlY3RlZFNpemUpOworICAgICAgICAgICAgaWYgKHJlcyA9PSBPSyB8fCByZXMgPT0gQ0FNRVJBX01FVEFEQVRBX1ZBTElEQVRJT05fU0hJRlRFRCkgeworICAgICAgICAgICAgICAgIHNldF9jYW1lcmFfbWV0YWRhdGFfdmVuZG9yX2lkKHBCdWZmZXIsIG1Qcm92aWRlclRhZ2lkKTsKKyAgICAgICAgICAgICAgICBtUGh5c2ljYWxDYW1lcmFDaGFyYWN0ZXJpc3RpY3NbaWRdID0gcEJ1ZmZlcjsKKyAgICAgICAgICAgIH0gZWx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CgpOworICAgIGlmIChtU2F2ZWRJbnRlcmZhY2UgPT0gbnVsbHB0cikgeworICAgICAgICBzcDxBaWRsUHJvdmlkZXJJbmZvPiBwYXJlbnRQcm92aWRlciA9CisgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8QWlkbFByb3ZpZGVySW5mbyAqPihtUGFyZW50UHJvdmlkZXIucHJvbW90ZSgpLmdldCgpKTsKKyAgICAgICAgaWYgKHBhcmVudFByb3ZpZGVyICE9IG51bGxwdHIpIHsKKyAgICAgICAgICAgIC8vIFdhaXQgZm9yIGxhenkgSEFMcyB0byBjb25maXJtIGRldmljZSBhdmFpbGFiaWxpdHkKKyAgICAgICAgICAgIGlmIChwYXJlbnRQcm92aWRlci0+aXNFeHRlcm5hbExhenlIQUwoKSAmJiAhbUlzRGV2aWNlQXZhaWxhYmxlKSB7CisgICAgICAgICAgICAgICAgQUxPR1YoIiVzOiBXYWl0IGZvciBleHRlcm5hbCBkZXZpY2UgdG8gYmVjb21lIGF2YWlsYWJsZSAlcyIsCisgICAgICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fLAorICAgICAgICAgICAgICAgICAgICAgIG1JZC5jX3N0cigpKTsKKworICAgICAgICAgICAgICAgIGF1dG8gcmVzID0gbURldmljZUF2YWlsYWJsZVNpZ25hbC53YWl0UmVsYXRpdmUobURldmljZUF2YWlsYWJsZUxvY2ssCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrRGV2aWNlQXZhaWxhYmxlVGltZW91dCk7CisgICAgICAgICAgICAgICAgaWYgKHJlcyAhPSBPSykgeworICAgICAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IEZhaWxlZCB3YWl0aW5nIGZvciBkZXZpY2UgdG8gYmVjb21lIGF2YWlsYWJsZSIsCisgICAgICAgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXyk7CisgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxscHRyOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgZGV2aWNlID0gcGFyZW50UHJvdmlkZXItPnN0YXJ0RGV2aWNlSW50ZXJmYWNlKG1OYW1lKTsKKyAgICAgICAgfQorICAgIH0gZWxzZSB7CisgICAgICAgIGRldmljZSA9IG1TYXZlZEludGVyZmFjZTsKKyAgICB9CisgICAgcmV0dXJuIGRldmljZTsKK30KKworc3RhdHVzX3QgQWlkbFByb3ZpZGVySW5mbzo6QWlkbERldmljZUluZm8zOjpkdW1wU3RhdGUoaW50IGZkKSB7CisgICAgY29uc3Qgc3RkOjpzaGFyZWRfcHRyPGNhbWVyYTo6ZGV2aWNlOjpJQ2FtZXJhRGV2aWNlPiBpbnRlcmZhY2UgPSBzdGFydERldmljZUludGVyZmFjZSgpOworICAgIGlmIChpbnRlcmZhY2UgPT0gbnVsbHB0cikgeworICAgICAgICByZXR1cm4gREVBRF9PQkpFQ1Q7CisgICAgfQorICAgIGNvbnN0IGNoYXIgKmFyZ3MgPSBudWxscHRyOworICAgIGF1dG8gcmV0ID0gaW50ZXJmYWNlLT5kdW1wKGZkLCAmYXJncywgLypudW1BcmdzKi8wKTsKKyAgICBpZiAocmV0ICE9IE9LKSB7CisgICAgICAgIHJldHVybiByZXQ7CisgICAgfQorICAgIHJldHVybiBPSzsKK30KKworc3RhdHVzX3QgQWlkbFByb3ZpZGVySW5mbzo6QWlkbERldmljZUluZm8zOjppc1Nlc3Npb25Db25maWd1cmF0aW9uU3VwcG9ydGVkKAorICAgICAgICBjb25zdCBTZXNzaW9uQ29uZmlndXJhdGlvbiAmY29uZmlndXJhdGlvbiwgYm9vbCBvdmVycmlkZUZvclBlcmZDbGFzcywKKyAgICAgICAgY2FtZXJhMzo6bWV0YWRhdGFHZXR0ZXIgZ2V0TWV0YWRhdGEsIGJvb2wgKnN0YXR1cykgeworCisgICAgY2FtZXJhOjpkZXZpY2U6OlN0cmVhbUNvbmZpZ3VyYXRpb24gc3RyZWFtQ29uZmlndXJhdGlvbjsKKyAgICBib29sIGVhcmx5RXhpdCA9IGZhbHNlOworICAgIGF1dG8gYlJlcyA9IFNlc3Npb25Db25maWd1cmF0aW9uVXRpbHM6OmNvbnZlcnRUb0hBTFN0cmVhbUNvbWJpbmF0aW9uKGNvbmZpZ3VyYXRpb24sCisgICAgICAgICAgICBTdHJpbmc4KG1JZC5jX3N0cigpKSwgbUNhbWVyYUNoYXJhY3RlcmlzdGljcywgZ2V0TWV0YWRhdGEsIG1QaHlzaWNhbElkcywKKyAgICAgICAgICAgIHN0cmVhbUNvbmZpZ3VyYXRpb24sIG92ZXJyaWRlRm9yUGVyZkNsYXNzLCAmZWFybHlFeGl0KTsKKworICAgIGlmICghYlJlcy5pc09rKCkpIHsKKyAgICAgICAgcmV0dXJuIFVOS05PV05fRVJST1I7CisgICAgfQorCisgICAgaWYgKGVhcmx5RXhpdCkgeworICAgICAgICAqc3RhdHVzID0gZmFsc2U7CisgICAgICAgIHJldHVybiBPSzsKKyAgICB9CisKKyAgICBjb25zdCBzdGQ6OnNoYXJlZF9wdHI8Y2FtZXJhOjpkZXZpY2U6OklDYW1lcmFEZXZpY2U+IGludGVyZmFjZSA9CisgICAgICAgICAgICBzdGFydERldmljZUludGVyZmFjZSgpOworCisgICAgaWYgKGludGVyZmFjZSA9PSBudWxscHRyKSB7CisgICAgICAgIHJldHVybiBERUFEX09CSkVDVDsKKyAgICB9CisKKyAgICA6Om5kazo6U2NvcGVkQVN0YXR1cyByZXQgPQorICAgICAgICBpbnRlcmZhY2UtPmlzU3RyZWFtQ29tYmluYXRpb25TdXBwb3J0ZWQoc3RyZWFtQ29uZmlndXJhdGlvbiwgc3RhdHVzKTsKKyAgICBpZiAoIXJldC5pc09rKCkpIHsKKyAgICAgICAgKnN0YXR1cyA9IGZhbHNlOworICAgICAgICBBTE9HRSgiJXM6IFVuZXhwZWN0ZWQgYmluZGVyIGVycm9yOiAlcyIsIF9fRlVOQ1RJT05fXywgcmV0LmdldE1l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gIHJldHVybiBwaHlzaWNhbERldmljZUluZm87CisgICAgICAgICAgICAgICAgfTsKKyAgICAgICAgc3RkOjp2ZWN0b3I8c3RkOjpzdHJpbmc+IHBoeXNpY2FsQ2FtZXJhSWRzOworICAgICAgICBtTWFuYWdlci0+aXNMb2dpY2FsQ2FtZXJhTG9ja2VkKGNhbWVyYUlkLCAmcGh5c2ljYWxDYW1lcmFJZHMpOworICAgICAgICBiU3RhdHVzID0KKyAgICAgICAgICAgIFNlc3Npb25Db25maWd1cmF0aW9uVXRpbHM6OmNvbnZlcnRUb0hBTFN0cmVhbUNvbWJpbmF0aW9uKAorICAgICAgICAgICAgICAgICAgICBjYW1lcmFJZEFuZFNlc3Npb25Db25maWcubVNlc3Npb25Db25maWd1cmF0aW9uLAorICAgICAgICAgICAgICAgICAgICBTdHJpbmc4KGNhbWVyYUlkLmNfc3RyKCkpLCBkZXZpY2VJbmZvLCBnZXRNZXRhZGF0YSwKKyAgICAgICAgICAgICAgICAgICAgcGh5c2ljYWxDYW1lcmFJZHMsIHN0cmVhbUNvbmZpZ3VyYXRpb24sCisgICAgICAgICAgICAgICAgICAgIG92ZXJyaWRlRm9yUGVyZkNsYXNzLCAmc2hvdWxkRXhpdCk7CisgICAgICAgIGlmICghYlN0YXR1cy5pc09rKCkpIHsKKyAgICAgICAgICAgIEFMT0dFKCIlczogY29udmVydFRvSEFMU3RyZWFtQ29tYmluYXRpb24gZmFpbGVkIiwgX19GVU5DVElPTl9fKTsKKyAgICAgICAgICAgIHJldHVybiBJTlZBTElEX09QRVJBVElPTjsKKyAgICAgICAgfQorICAgICAgICBpZiAoc2hvdWxkRXhpdCkgeworICAgICAgICAgICAgKmVhcmx5RXhpdCA9IHRydWU7CisgICAgICAgICAgICByZXR1cm4gT0s7CisgICAgICAgIH0KKyAgICAgICAgY2FtZXJhOjpwcm92aWRlcjo6Q2FtZXJhSWRBbmRTdHJlYW1Db21iaW5hdGlvbiBoYWxDYW1lcmFJZEFuZFN0cmVhbTsK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25maWdzLCBwZXJmQ2xhc3NQcmltYXJ5Q2FtZXJhSWRzLAorICAgICAgICAgICAgICB0YXJnZXRTZGtWZXJzaW9uLCAmaGFsQ2FtZXJhSWRzQW5kU3RyZWFtQ29tYmluYXRpb25zLCAma25vd1Vuc3VwcG9ydGVkKTsKKyAgICAgIGlmIChyZXMgIT0gT0spIHsKKyAgICAgICAgICBBTE9HRSgiJXMgdW5hYmxlIHRvIGNvbnZlcnQgc2Vzc2lvbiBjb25maWd1cmF0aW9ucyBwcm92aWRlZCB0byBIQUwgc3RyZWFtIgorICAgICAgICAgICAgICAgICJjb21iaW5hdGlvbnMiLCBfX0ZVTkNUSU9OX18pOworICAgICAgICAgIHJldHVybiByZXM7CisgICAgICB9CisgICAgICBpZiAoa25vd1Vuc3VwcG9ydGVkKSB7CisgICAgICAgICAgLy8gV2UgZ290IHRvIGtub3cgdGhlIHN0cmVhbXMgYXJlbid0IHZhbGlkIGJlZm9yZSBkb2luZyB0aGUgSEFMCisgICAgICAgICAgLy8gY2FsbCBpdHNlbGYuCisgICAgICAgICAgKmlzU3VwcG9ydGVkID0gZmFsc2U7CisgICAgICAgICAgcmV0dXJuIE9LOworICAgICAgfQorCisgICAgICAvLyBDaGVjayBpZiB0aGUgcHJvdmlkZXIgaXMgY3VycmVudGx5IGFjdGl2ZSAtIG5vdCBnb2luZyB0byBzdGFydCBpdCB1cCBmb3IgdGhpcyBub3RpZmljYXRpb24KKyAgICAgIGF1dG8gaW50ZXJmYWNlID0gbVNhdmVkSW50ZXJmYWNlICE9IG51bGxwdHIgPyBtU2F2ZWRJbnRlcmZhY2UgOiBtQWN0aXZlSW50ZXJmYWNlLmxvY2soKTsKKyAgICAgIGlmIChpbnRlcmZhY2UgPT0gbnVsbHB0cikgeworICAgICAgICAgIC8vIFRPRE86IFRoaXMgbWlnaHQgYmUgc29tZSBvdGhlciBwcm9ibGVtCisgICAgICAgICAgcmV0dXJuIElOVkFMSURfT1BFUkFUSU9OOworICAgICAgfQorICAg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bnVsbHB0cikgeworICAgICAgICAgICAgbU1pbm9yVmVyc2lvbiA9IDY7CisgICAgICAgIH0KKyAgICB9CisgICAgLy8gV2UgbmVlZCB0byBjaGVjayBhZ2FpbiBzaW5jZSBjYXN0Ml82LmlzT2soKSBzdWNjZWVkcyBldmVuIGlmIHRoZSBwcm92aWRlcgorICAgIC8vIHZlcnNpb24gaXNuJ3QgYWN0dWFsbHkgMi42LgorICAgIGlmIChpbnRlcmZhY2UyXzYgPT0gbnVsbHB0cil7CisgICAgICAgIGF1dG8gY2FzdDJfNSA9CisgICAgICAgICAgICAgICAgcHJvdmlkZXI6OlYyXzU6OklDYW1lcmFQcm92aWRlcjo6Y2FzdEZyb20oaW50ZXJmYWNlKTsKKyAgICAgICAgc3A8cHJvdmlkZXI6OlYyXzU6OklDYW1lcmFQcm92aWRlcj4gaW50ZXJmYWNlMl81ID0gbnVsbHB0cjsKKyAgICAgICAgaWYgKGNhc3QyXzUuaXNPaygpKSB7CisgICAgICAgICAgICBpbnRlcmZhY2UyXzUgPSBjYXN0Ml81OworICAgICAgICAgICAgaWYgKGludGVyZmFjZSAhPSBudWxscHRyKSB7CisgICAgICAgICAgICAgICAgbU1pbm9yVmVyc2lvbiA9IDU7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKyAgICB9IGVsc2UgeworICAgICAgICBhdXRvIGNhc3QyXzcgPSBwcm92aWRlcjo6VjJfNzo6SUNhbWVyYVByb3ZpZGVyOjpjYXN0RnJvbShpbnRlcmZhY2UpOworICAgICAgICBpZiAoY2FzdDJfNy5pc09rKCkpIHsKKyAgICAgICAgICAgIHNwPHByb3ZpZGVyOjpWMl83OjpJQ2FtZXJhUHJvdmlkZXI+IGludGVyZmFjZTJfNyA9IGNhc3QyXzc7CisgICAgICAgICAgICBpZiAoaW50ZXJmYWNlMl83ICE9IG51bGxwdHIpIHsKKyAgICAgICAgICAgICAgICBtTWlub3JWZXJzaW9uID0gNzsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQ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IGRlYXRoOiAlcyIsCisgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fLCBtUHJvdmlkZXJOYW1lLmNfc3RyKCksIGxpbmtlZC5kZXNjcmlwdGlvbigpLmNfc3RyKCkpOworICAgICAgICByZXR1cm4gREVBRF9PQkpFQ1Q7CisgICAgfSBlbHNlIGlmICghbGlua2VkKSB7CisgICAgICAgIEFMT0dXKCIlczogVW5hYmxlIHRvIGxpbmsgdG8gcHJvdmlkZXIgJyVzJyBkZWF0aCBub3RpZmljYXRpb25zIiwKKyAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIG1Qcm92aWRlck5hbWUuY19zdHIoKSk7CisgICAgfQorCisgICAgaWYgKCFrRW5hYmxlTGF6eUhhbCkgeworICAgICAgICAvLyBTYXZlIEhBTCByZWZlcmVuY2UgaW5kZWZpbml0ZWx5CisgICAgICAgIG1TYXZlZEludGVyZmFjZSA9IGludGVyZmFjZTsKKyAgICB9IGVsc2UgeworICAgICAgICBtQWN0aXZlSW50ZXJmYWNlID0gaW50ZXJmYWNlOworICAgIH0KKworICAgIEFMT0dWKCIlczogU2V0dGluZyBkZXZpY2Ugc3RhdGUgZm9yICVzOiAweCUiIFBSSXg2NCwKKyAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgbVByb3ZpZGVyTmFtZS5jX3N0cigpLCBtRGV2aWNlU3RhdGUpOworICAgIG5vdGlmeURldmljZVN0YXRlQ2hhbmdlKGN1cnJlbnREZXZpY2VTdGF0ZSk7CisKKyAgICByZXMgPSBzZXRVcFZlbmRvclRhZ3MoKTsKKyAgICBpZiAocmVzICE9IE9LKSB7CisgICAgICAgIEFMT0dFKCIlczogVW5hYmxlIHRvIHNldCB1cCB2ZW5kb3IgdGFncyBmcm9tIHByb3ZpZGVyICclcyciLAorICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgbVByb3ZpZGVyTmFtZS5jX3N0cigpKTsKKyAgICAgICAgcmV0dXJuIHJlczsKKyAgICB9CisKKyAg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gICAgICAgbVByb3ZpZGVyUHVibGljQ2FtZXJhSWRzLnB1c2hfYmFjayhpZCk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorICAgICAgICB9IH0pOworICAgIGlmICghcmV0LmlzT2soKSkgeworICAgICAgICBBTE9HRSgiJXM6IFRyYW5zYWN0aW9uIGVycm9yIGluIGdldHRpbmcgY2FtZXJhIElEIGxpc3QgZnJvbSBwcm92aWRlciAnJXMnOiAlcyIsCisgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fLCBtUHJvdmlkZXJOYW1lLmNfc3RyKCksIGxpbmtlZC5kZXNjcmlwdGlvbigpLmNfc3RyKCkpOworICAgICAgICByZXR1cm4gREVBRF9PQkpFQ1Q7CisgICAgfQorICAgIGlmIChzdGF0dXMgIT0gU3RhdHVzOjpPSykgeworICAgICAgICBBTE9HRSgiJXM6IFVuYWJsZSB0byBxdWVyeSBmb3IgY2FtZXJhIGRldmljZXMgZnJvbSBwcm92aWRlciAnJXMnIiwKKyAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIG1Qcm92aWRlck5hbWUuY19zdHIoKSk7CisgICAgICAgIHJldHVybiBtYXBUb1N0YXR1c1Qoc3RhdHVzKTsKKyAgICB9CisKKyAgICAvLyBHZXQgbGlzdCBvZiBjb25jdXJyZW50IHN0cmVhbWluZyBjYW1lcmEgZGV2aWNlIGNvbWJpbmF0aW9ucworICAgIGlmIChtTWlub3JWZXJzaW9uID49IDYpIHsKKyAgICAgICAgcmVzID0gZ2V0Q29uY3VycmVudENhbWVyYUlkc0ludGVybmFsTG9ja2VkKGludGVyZmFjZTJfNik7CisgICAgICAgIGlmIChyZXMgIT0gT0spIHsKKyAgICAgICAgICAgIHJldHVybiByZXM7CisgICAgICAgIH0KKyAgICB9CisKKyAgICByZXQgPSBpbnRlcmZhY2UtPmlzU2V0VG9yY2hNb2RlU3VwcG9ydGVkKAorICAgICAgICBbdGhpc10oYXV0byBzdGF0dXMsIGJvb2wgc3VwcG9ydGVkKSB7CisgICAgICAgICAgICBpZiAoc3RhdHVzID09IFN0YXR1czo6T0spIHsKKyAgICAgICAgICAgICAgICBtU2V0VG9yY2hNb2RlU3VwcG9ydGVkID0gc3VwcG9ydGVkOworICAgICAgICAgICAgfQorICAgICAgICB9KTsKKyAgICBpZiAoIXJldC5pc09rKCkpIHsKKyAgICAgICAgQUxPR0UoIiVzOiBUcmFuc2FjdGlvbiBlcnJvciBjaGVja2luZyB0b3JjaCBtb2RlIHN1cHBvcnQgJyVzJzogJXMiLAorICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgbVByb3ZpZGVyTmFtZS5jX3N0cigpLCByZXQuZGVzY3JpcHRpb24oKS5jX3N0cigpKTsKKyAgICAgICAgcmV0dXJuIERFQURfT0JKRUNUOworICAgIH0KKworICAgIG1Jc1JlbW90ZSA9IGludGVyZmFjZS0+aXNSZW1vdGUoKTsKKworICAgIGluaXRpYWxpemVQcm92aWRlckluZm9Db21tb24oZGV2aWNlcyk7CisKKyAgICByZXR1cm4gT0s7Cit9CisKK3N0YXR1c190IEhpZGxQcm92aWRlckluZm86OnNldFVwVmVuZG9yVGFncygpIHsKKyAgICBpZiAobVZlbmRvclRhZ0Rlc2NyaXB0b3IgIT0gbnVsbHB0cikKKyAgICAgICAgcmV0dXJuIE9LOworCisgICAgaGFyZHdhcmU6OmhpZGxfdmVjPFZlbmRvclRhZ1NlY3Rpb24+IHZ0czsKKyAgICBTdGF0dXMgc3RhdHVzOworICAgIGhhcmR3YXJlOjpSZXR1cm48dm9pZD4gcmV0OworICAgIGNvbnN0IHNwPGhhcmR3YXJlOjpjYW1lcmE6OnByb3ZpZGVyOjpWMl80OjpJQ2FtZXJhUHJvdmlkZXI+IGludGVyZmFjZSA9CisgICAgICAgICAgICBzdGFydFByb3ZpZGVySW50ZXJmYWNlKCk7CisgICAgaWYgKGludGVyZmFjZSA9PSBudWxscHRyKSB7CisgICAgICAgIHJldHVybiBERUFEX09CSkVDVDsKKyAgIC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fNTo6SUNhbWVyYVByb3ZpZGVyOjpjYXN0RnJvbShpbnRlcmZhY2UpOworICAgICAgICAgICAgaWYgKGNhc3RSZXN1bHQuaXNPaygpKSB7CisgICAgICAgICAgICAgICAgc3A8cHJvdmlkZXI6OlYyXzU6OklDYW1lcmFQcm92aWRlcj4gaW50ZXJmYWNlXzJfNSA9IGNhc3RSZXN1bHQ7CisgICAgICAgICAgICAgICAgaWYgKGludGVyZmFjZV8yXzUgIT0gbnVsbHB0cikgeworICAgICAgICAgICAgICAgICAgICBpbnRlcmZhY2VfMl81LT5ub3RpZnlEZXZpY2VTdGF0ZUNoYW5nZShtRGV2aWNlU3RhdGUpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KKyAgICByZXR1cm4gT0s7Cit9CisKK3NwPGRldmljZTo6VjNfMjo6SUNhbWVyYURldmljZT4KK0hpZGxQcm92aWRlckluZm86OnN0YXJ0RGV2aWNlSW50ZXJmYWNlKGNvbnN0IHN0ZDo6c3RyaW5nICZuYW1lKSB7CisgICAgU3RhdHVzIHN0YXR1czsKKyAgICBzcDxkZXZpY2U6OlYzXzI6OklDYW1lcmFEZXZpY2U+IGNhbWVyYUludGVyZmFjZTsKKyAgICBoYXJkd2FyZTo6UmV0dXJuPHZvaWQ+IHJldDsKKyAgICBjb25zdCBzcDxwcm92aWRlcjo6VjJfNDo6SUNhbWVyYVByb3ZpZGVyPiBpbnRlcmZhY2UgPSBzdGFydFByb3ZpZGVySW50ZXJmYWNlKCk7CisgICAgaWYgKGludGVyZmFjZSA9PSBudWxscHRyKSB7CisgICAgICAgIHJldHVybiBudWxscHRyOworICAgIH0KKyAgICByZXQgPSBpbnRlcmZhY2UtPmdldENhbWVyYURldmljZUludGVyZmFjZV9WM194KG5hbWUsIFsmc3RhdHVzLCAmY2FtZXJhSW50ZXJmYWNlXSgKKyAgICAgICAgU3RhdHVzIHMsIHNwPGRldmljZTo6VjNfMjo6SUNhbWVyYUR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yAgICAgICAgICAgIC8vIFRoaXMgYXZvaWRzIGZhaWxpbmcgZ2V0Q2FtZXJhRGV2aWNlSW50ZXJmYWNlX1YzX3ggYmVmb3JlIGRldmljZXMKKyAgICAgICAgICAgIC8vIGFyZSByZWFkeS4KKyAgICAgICAgICAgIGZvciAoYXV0byYgZGV2aWNlIDogbURldmljZXMpIHsKKyAgICAgICAgICAgICAgZGV2aWNlLT5tSXNEZXZpY2VBdmFpbGFibGUgPSBmYWxzZTsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgaW50ZXJmYWNlLT5zZXRDYWxsYmFjayh0aGlzKTsKKyAgICAgICAgICAgIGhhcmR3YXJlOjpSZXR1cm48Ym9vbD4KKyAgICAgICAgICAgICAgICBsaW5rZWQgPSBpbnRlcmZhY2UtPmxpbmtUb0RlYXRoKHRoaXMsIC8qY29va2llKi8gbUlkKTsKKyAgICAgICAgICAgIGlmICghbGlua2VkLmlzT2soKSkgeworICAgICAgICAgICAgICBBTE9HRSgKKyAgICAgICAgICAgICAgICAgICIlczogVHJhbnNhY3Rpb24gZXJyb3IgaW4gbGlua2luZyB0byBjYW1lcmEgcHJvdmlkZXIgJyVzJyBkZWF0aDogJXMiLAorICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fLAorICAgICAgICAgICAgICAgICAgbVByb3ZpZGVyTmFtZS5jX3N0cigpLAorICAgICAgICAgICAgICAgICAgbGlua2VkLmRlc2NyaXB0aW9uKCkuY19zdHIoKSk7CisgICAgICAgICAgICAgIG1NYW5hZ2VyLT5yZW1vdmVQcm92aWRlcihtUHJvdmlkZXJOYW1lKTsKKyAgICAgICAgICAgICAgcmV0dXJuIG51bGxwdHI7CisgICAgICAgICAgICB9IGVsc2UgaWYgKCFsaW5rZWQpIHsKKyAgICAgICAgICAgICAgQUxPR1coIiVzOiBVbmFibGUgdG8gbGluayB0byBwcm92aWRlciAnJXMnIGRlYXRoIG5vdGlmaWNhdGlvbnMiLAorICAgICAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIG1Qcm92aWRlck5hbWUuY19zdHIoKSk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICAvLyBTZW5kIGN1cnJlbnQgZGV2aWNlIHN0YXRlCisgICAgICAgICAgICBpZiAobU1pbm9yVmVyc2lvbiA+PSA1KSB7CisgICAgICAgICAgICAgIGF1dG8gY2FzdFJlc3VsdCA9CisgICAgICAgICAgICAgICAgICBwcm92aWRlcjo6VjJfNTo6SUNhbWVyYVByb3ZpZGVyOjpjYXN0RnJvbShpbnRlcmZhY2UpOworICAgICAgICAgICAgICBpZiAoY2FzdFJlc3VsdC5pc09rKCkpIHsKKyAgICAgICAgICAgICAgICBzcDxwcm92aWRlcjo6VjJfNTo6SUNhbWVyYVByb3ZpZGVyPiBpbnRlcmZhY2VfMl81ID0gY2FzdFJlc3VsdDsKKyAgICAgICAgICAgICAgICBpZiAoaW50ZXJmYWNlXzJfNSAhPSBudWxscHRyKSB7CisgICAgICAgICAgICAgICAgICBBTE9HVigiJXM6IEluaXRpYWwgZGV2aWNlIHN0YXRlIGZvciAlczogMHggJSIgUFJJeDY0LAorICAgICAgICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fLCBtUHJvdmlkZXJOYW1lLmNfc3RyKCksIG1EZXZpY2VTdGF0ZSk7CisgICAgICAgICAgICAgICAgICBpbnRlcmZhY2VfMl81LT5ub3RpZnlEZXZpY2VTdGF0ZUNoYW5nZShtRGV2aWNlU3RhdGUpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgICAgIG1BY3RpdmVJbnRlcmZhY2UgPSBpbnRlcmZhY2U7CisgICAgfSBlbHNlIHsKKyAgICAgICAgQUxPR1YoIkNhbWVyYSBwcm92aWRlciAoJXMpIGFscmVhZHkgaW4gdXNlLiBSZS11c2luZyBpbnN0YW5jZS4iLAorICAgICAgICAgICAgICBtUHJvdmlkZXJOYW1lLmNfc3RyKCkpOwor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sbHB0ciA/IG1TYXZlZEludGVyZmFjZSA6IG1BY3RpdmVJbnRlcmZhY2UucHJvbW90ZSgpOworICAgIGlmIChpbnRlcmZhY2UgPT0gbnVsbHB0cikgeworICAgICAgICBBTE9HRSgiJXM6IGNhbWVyYSBwcm92aWRlciBpbnRlcmZhY2UgZm9yICVzIGlzIG5vdCB2YWxpZCIsIF9fRlVOQ1RJT05fXywKKyAgICAgICAgICAgICAgICBtUHJvdmlkZXJOYW1lLmNfc3RyKCkpOworICAgICAgICByZXR1cm4gSU5WQUxJRF9PUEVSQVRJT047CisgICAgfQorICAgIGF1dG8gY2FzdFJlc3VsdCA9IHByb3ZpZGVyOjpWMl82OjpJQ2FtZXJhUHJvdmlkZXI6OmNhc3RGcm9tKGludGVyZmFjZSk7CisKKyAgICBpZiAoY2FzdFJlc3VsdC5pc09rKCkpIHsKKyAgICAgICAgc3A8cHJvdmlkZXI6OlYyXzY6OklDYW1lcmFQcm92aWRlcj4gaW50ZXJmYWNlMl82ID0gY2FzdFJlc3VsdDsKKyAgICAgICAgaWYgKGludGVyZmFjZTJfNiAhPSBudWxscHRyKSB7CisgICAgICAgICAgICByZXR1cm4gZ2V0Q29uY3VycmVudENhbWVyYUlkc0ludGVybmFsTG9ja2VkKGludGVyZmFjZTJfNik7CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAvLyBUaGlzIHNob3VsZCBub3QgaGFwcGVuIHNpbmNlIG1NaW5vclZlcnNpb24gPj0gNgorICAgICAgICAgICAgQUxPR0UoIiVzOiBtTWlub3JWZXJzaW9uIHdhcyA+PSA2LCBidXQgaW50ZXJmYWNlMl82IHdhcyBudWxscHRyIiwgX19GVU5DVElPTl9fKTsKKyAgICAgICAgICAgIHJldHVybiBVTktOT1dOX0VSUk9SOworICAgICAgICB9CisgICAgfQorICAgIHJldHVybiBPSzsKK30KKworc3RhdHVzX3QgSGlkbFByb3ZpZGVySW5mbzo6Z2V0Q29uY3VycmVudENhbWVyYUlkc0ludGVybmFsTG9ja2VkKAorICAgICAgICBzcDxwcm92aWRlcjo6VjJfNjo6SUNhbWVyYVByb3ZpZGVyPiAmaW50ZXJmYWNlMl82KSB7CisgICAgaWYgKGludGVyZmFjZTJfNiA9PSBudWxscHRyKSB7CisgICAgICAgIEFMT0dFKCIlczogbnVsbCBpbnRlcmZhY2UgcHJvdmlkZWQiLCBfX0ZVTkNUSU9OX18pOworICAgICAgICByZXR1cm4gQkFEX1ZBTFVFOworICAgIH0KKyAgICBTdGF0dXMgc3RhdHVzID0gU3RhdHVzOjpPSzsKKyAgICBoYXJkd2FyZTo6UmV0dXJuPHZvaWQ+IHJldCA9CisgICAgICAgICAgICBpbnRlcmZhY2UyXzYtPmdldENvbmN1cnJlbnRTdHJlYW1pbmdDYW1lcmFJZHMoWyZzdGF0dXMsIHRoaXNdKAorICAgICAgICAgICAgU3RhdHVzIGNvbmN1cnJlbnRJZFN0YXR1cywgLy8gVE9ETzogTW92ZSBhbGwgaW5zdGFuY2VzIG9mIGhpZGxfc3RyaW5nIHRvICd1c2luZycKKyAgICAgICAgICAgIGNvbnN0IGhhcmR3YXJlOjpoaWRsX3ZlYzxoYXJkd2FyZTo6aGlkbF92ZWM8aGFyZHdhcmU6OmhpZGxfc3RyaW5nPj4mCisgICAgICAgICAgICAgICAgICAgICAgICBjYW1lcmFEZXZpY2VJZENvbWJpbmF0aW9ucykgeworICAgICAgICAgICAgc3RhdHVzID0gY29uY3VycmVudElkU3RhdHVzOworICAgICAgICAgICAgaWYgKHN0YXR1cyA9PSBTdGF0dXM6Ok9LKSB7CisgICAgICAgICAgICAgICAgbUNvbmN1cnJlbnRDYW1lcmFJZENvbWJpbmF0aW9ucy5jbGVhcigpOworICAgICAgICAgICAgICAgIGZvciAoYXV0byYgY29tYmluYXRpb24gOiBjYW1lcmFEZXZpY2VJZENvbWJpbmF0aW9ucykgeworICAgICAgICAgICAgICAgICAgICBzdGQ6OnVub3JkZXJlZF9zZXQ8c3RkOjpzdHJpbmc+IGRldmljZUlkczsKKyAgICAgICAgICAgICAgICAgICAgZm9yIChhdXRvICZjYW1lcmFEZXZpY2VJZCA6IGNvbWJpbmF0aW9uKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBkZXZpY2VJZHMuaW5zZXJ0KGNhbWVyYURldmljZUlkLmNfc3RyKCkpOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIG1Db25jdXJyZW50Q2FtZXJhSWRDb21iaW5hdGlvbnMucHVzaF9iYWNrKHN0ZDo6bW92ZShkZXZpY2VJZHMpKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9IH0pOworICAgIGlmICghcmV0LmlzT2soKSkgeworICAgICAgICBBTE9HRSgiJXM6IFRyYW5zYWN0aW9uIGVycm9yIGluIGdldHRpbmcgY29uY3VycmVudCBjYW1lcmEgSUQgbGlzdCBmcm9tIHByb3ZpZGVyICclcyciLAorICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgbVByb3ZpZGVyTmFtZS5jX3N0cigpKTsKKyAgICAgICAgICAgIHJldHVybiBERUFEX09CSkVDVDsKKyAgICB9CisgICAgaWYgKHN0YXR1cyAhPSBTdGF0dXM6Ok9LKSB7CisgICAgICAgIEFMT0dFKCIlczogVW5hYmxlIHRvIHF1ZXJ5IGZvciBjYW1lcmEgZGV2aWNlcyBmcm9tIHByb3ZpZGVyICclcyciLAorICAgICAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIG1Qcm92aWRlck5hbWUuY19zdHIoKSk7CisgICAgICAgIHJldHVybiBtYXBUb1N0YXR1c1Qoc3RhdHVzKTsKKyAgICB9CisgICAgcmV0dXJuIE9LOworfQorCitIaWRsUHJvdmlkZXJJbmZvOjpIaWRsRGV2aWNlSW5mbzM6OkhpZGxEZXZpY2VJbmZvMygKKyAgICAgICAgY29uc3Qgc3RkOjpzdHJpbmcmIG5hbWUsCisgICAgICAgIGNvbnN0IG1ldGFkYXRhX3ZlbmRvcl9pZF90IHRhZ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cmFfbWV0YWRhdGFfdCo+KG1ldGFkYXRhLmRhdGEoKSk7CisgICAgICAgICAgICAgICAgICAgIHNpemVfdCBleHBlY3RlZFNpemUgPSBtZXRhZGF0YS5zaXplKCk7CisgICAgICAgICAgICAgICAgICAgIGludCByZXMgPSB2YWxpZGF0ZV9jYW1lcmFfbWV0YWRhdGFfc3RydWN0dXJlKGJ1ZmZlciwgJmV4cGVjdGVkU2l6ZSk7CisgICAgICAgICAgICAgICAgICAgIGlmIChyZXMgPT0gT0sgfHwgcmVzID09IENBTUVSQV9NRVRBREFUQV9WQUxJREFUSU9OX1NISUZURUQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHNldF9jYW1lcmFfbWV0YWRhdGFfdmVuZG9yX2lkKGJ1ZmZlciwgbVByb3ZpZGVyVGFnaWQpOworICAgICAgICAgICAgICAgICAgICAgICAgbUNhbWVyYUNoYXJhY3RlcmlzdGljcyA9IGJ1ZmZlcjsKKyAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIEFMT0dFKCIlczogTWFsZm9ybWVkIGNhbWVyYSBtZXRhZGF0YSByZWNlaXZlZCBmcm9tIEhBTCIsIF9fRlVOQ1RJT05fXyk7CisgICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXMgPSBTdGF0dXM6OklOVEVSTkFMX0VSUk9SOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfSk7CisgICAgaWYgKCFyZXQuaXNPaygpKSB7CisgICAgICAgIEFMT0dFKCIlczogVHJhbnNhY3Rpb24gZXJyb3IgZ2V0dGluZyBjYW1lcmEgY2hhcmFjdGVyaXN0aWNzIGZvciBkZXZpY2UgJXMiCisgICAgICAgICAgICAgICAgIiB0byBjaGVjayBmb3IgYSBmbGFzaCB1bml0OiAlcyIsIF9fRlVOQ1RJT05fXywgaWQuY19zdHIoKSwKKyAgICAgICAgICAgICAgICByZXQuZGVzY3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AgICAgICAgWyZzdGF0dXMsICZpZCwgdGhpc10oU3RhdHVzIHMsIGRldmljZTo6VjNfMjo6Q2FtZXJhTWV0YWRhdGEgbWV0YWRhdGEpIHsKKyAgICAgICAgICAgICAgICBzdGF0dXMgPSBzOworICAgICAgICAgICAgICAgIGlmIChzID09IFN0YXR1czo6T0spIHsKKyAgICAgICAgICAgICAgICAgICAgY2FtZXJhX21ldGFkYXRhX3QgKmJ1ZmZlciA9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVpbnRlcnByZXRfY2FzdDxjYW1lcmFfbWV0YWRhdGFfdCo+KG1ldGFkYXRhLmRhdGEoKSk7CisgICAgICAgICAgICAgICAgICAgIHNpemVfdCBleHBlY3RlZFNpemUgPSBtZXRhZGF0YS5zaXplKCk7CisgICAgICAgICAgICAgICAgICAgIGludCByZXMgPSB2YWxpZGF0ZV9jYW1lcmFfbWV0YWRhdGFfc3RydWN0dXJlKGJ1ZmZlciwgJmV4cGVjdGVkU2l6ZSk7CisgICAgICAgICAgICAgICAgICAgIGlmIChyZXMgPT0gT0sgfHwgcmVzID09IENBTUVSQV9NRVRBREFUQV9WQUxJREFUSU9OX1NISUZURUQpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHNldF9jYW1lcmFfbWV0YWRhdGFfdmVuZG9yX2lkKGJ1ZmZlciwgbVByb3ZpZGVyVGFnaWQpOworICAgICAgICAgICAgICAgICAgICAgICAgbVBoeXNpY2FsQ2FtZXJhQ2hhcmFjdGVyaXN0aWNzW2lkXSA9IGJ1ZmZlcjsKKyAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIEFMT0dFKCIlczogTWFsZm9ybWVkIGNhbWVyYSBtZXRhZGF0YSByZWNlaXZlZCBmcm9tIEhBTCIsIF9fRlVOQ1RJT05fXyk7CisgICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXMgPSBTdGF0dXM6OklOVEVSTkFMX0VSUk9SOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfSk7CisKKyAgICAgICAgICAgIGlmICghcmV0LmlzT2soKSkgeworICAgICAgICAgICAgICAgIEFMT0dFKCIlczogVHJhbnNhY3Rpb24gZXJyb3IgZ2V0dGluZyBwaHlzaWNhbCBjYW1lcmEgJXMgY2hhcmFjdGVyaXN0aWNzIGZvciAlczogJXMiLAorICAgICAgICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fLCBpZC5jX3N0cigpLCBpZC5jX3N0cigpLCByZXQuZGVzY3JpcHRpb24oKS5jX3N0cigpKTsKKyAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICB9CisgICAgICAgICAgICBpZiAoc3RhdHVzICE9IFN0YXR1czo6T0spIHsKKyAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IFVuYWJsZSB0byBnZXQgcGh5c2ljYWwgY2FtZXJhICVzIGNoYXJhY3RlcmlzdGljcyBmb3IgZGV2aWNlICVzOiAlcyAoJWQpIiwKKyAgICAgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgaWQuY19zdHIoKSwgbUlkLmNfc3RyKCksCisgICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXNUb1N0cmluZyhzdGF0dXMpLCBzdGF0dXMpOworICAgICAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgcmVzID0gY2FtZXJhMzo6Wm9vbVJhdGlvTWFwcGVyOjpvdmVycmlkZVpvb21SYXRpb1RhZ3MoCisgICAgICAgICAgICAgICAgICAgICZtUGh5c2ljYWxDYW1lcmFDaGFyYWN0ZXJpc3RpY3NbaWRdLCAmbVN1cHBvcnROYXRpdmVab29tUmF0aW8pOworICAgICAgICAgICAgaWYgKE9LICE9IHJlcykgeworICAgICAgICAgICAgICAgIEFMT0dFKCIlczogVW5hYmxlIHRvIG92ZXJyaWRlIHpvb21SYXRpbyByZWxhdGVkIHRhZ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Zm9yIGV4dGVybmFsIGRldmljZSB0byBiZWNvbWUgYXZhaWxhYmxlICVzIiwKKyAgICAgICAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sCisgICAgICAgICAgICAgICAgICAgICAgbUlkLmNfc3RyKCkpOworCisgICAgICAgICAgICAgICAgYXV0byByZXMgPSBtRGV2aWNlQXZhaWxhYmxlU2lnbmFsLndhaXRSZWxhdGl2ZShtRGV2aWNlQXZhaWxhYmxlTG9jaywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtEZXZpY2VBdmFpbGFibGVUaW1lb3V0KTsKKyAgICAgICAgICAgICAgICBpZiAocmVzICE9IE9LKSB7CisgICAgICAgICAgICAgICAgICAgIEFMT0dFKCIlczogRmFpbGVkIHdhaXRpbmcgZm9yIGRldmljZSB0byBiZWNvbWUgYXZhaWxhYmxlIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fKTsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGxwdHI7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorCisgICAgICAgICAgICBkZXZpY2UgPSBwYXJlbnRQcm92aWRlci0+c3RhcnREZXZpY2VJbnRlcmZhY2UobU5hbWUpOworICAgICAgICB9CisgICAgfSBlbHNlIHsKKyAgICAgICAgZGV2aWNlID0gKGhhcmR3YXJlOjpjYW1lcmE6OmRldmljZTo6VjNfMjo6SUNhbWVyYURldmljZSAqKSBtU2F2ZWRJbnRlcmZhY2UuZ2V0KCk7CisgICAgfQorICAgIHJldHVybiBkZXZpY2U7Cit9CisKK3N0YXR1c190IEhpZGxQcm92aWRlckluZm86OkhpZGxEZXZpY2VJbmZvMzo6ZHVtcFN0YXRlKGludCBmZCkgeworICAgIG5hdGl2ZV9oYW5kbGVfdCogaGFuZGxlID0gbmF0aXZlX2hhbmRsZV9jcmVhdGUoMSwwKTsKKyAgICBoYW5kbGUtPmRh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pY2FsSWRzLAorICAgICAgICAgICAgY29uZmlndXJhdGlvbl8zXzcsIG92ZXJyaWRlRm9yUGVyZkNsYXNzLCAmZWFybHlFeGl0KTsKKworICAgIGlmICghYlJlcy5pc09rKCkpIHsKKyAgICAgICAgcmV0dXJuIFVOS05PV05fRVJST1I7CisgICAgfQorCisgICAgaWYgKGVhcmx5RXhpdCkgeworICAgICAgICAqc3RhdHVzID0gZmFsc2U7CisgICAgICAgIHJldHVybiBPSzsKKyAgICB9CisKKyAgICBjb25zdCBzcDxoYXJkd2FyZTo6Y2FtZXJhOjpkZXZpY2U6OlYzXzI6OklDYW1lcmFEZXZpY2U+IGludGVyZmFjZSA9CisgICAgICAgICAgICBzdGFydERldmljZUludGVyZmFjZSgpOworCisgICAgaWYgKGludGVyZmFjZSA9PSBudWxscHRyKSB7CisgICAgICAgIHJldHVybiBERUFEX09CSkVDVDsKKyAgICB9CisKKyAgICBhdXRvIGNhc3RSZXN1bHRfM181ID0gZGV2aWNlOjpWM181OjpJQ2FtZXJhRGV2aWNlOjpjYXN0RnJvbShpbnRlcmZhY2UpOworICAgIHNwPGhhcmR3YXJlOjpjYW1lcmE6OmRldmljZTo6VjNfNTo6SUNhbWVyYURldmljZT4gaW50ZXJmYWNlXzNfNSA9IGNhc3RSZXN1bHRfM181OworICAgIGF1dG8gY2FzdFJlc3VsdF8zXzcgPSBkZXZpY2U6OlYzXzc6OklDYW1lcmFEZXZpY2U6OmNhc3RGcm9tKGludGVyZmFjZSk7CisgICAgc3A8aGFyZHdhcmU6OmNhbWVyYTo6ZGV2aWNlOjpWM183OjpJQ2FtZXJhRGV2aWNlPiBpbnRlcmZhY2VfM183ID0gY2FzdFJlc3VsdF8zXzc7CisKKyAgICBzdGF0dXNfdCByZXM7CisgICAgU3RhdHVzIGNhbGxTdGF0dXM7CisgICAgOjphbmRyb2lkOjpoYXJkd2FyZTo6UmV0dXJuPHZvaWQ+IHJldDsKKyAgICBhdXRvIGhhbENiID0KKyAgICAgICAgICAgIFsmY2FsbFN0YXR1cywgJnN0YXR1c10gKFN0YXR1cyBzLCBib29sIGNvbWJTdGF0dXMpIHsKKyAgICAgICAgICAgICAgICBjYWxsU3RhdHVzID0gczsKKyAgICAgICAgICAgICAgICAqc3RhdHVzID0gY29tYlN0YXR1czsKKyAgICAgICAgICAgIH07CisgICAgaWYgKGludGVyZmFjZV8zXzcgIT0gbnVsbHB0cikgeworICAgICAgICByZXQgPSBpbnRlcmZhY2VfM183LT5pc1N0cmVhbUNvbWJpbmF0aW9uU3VwcG9ydGVkXzNfNyhjb25maWd1cmF0aW9uXzNfNywgaGFsQ2IpOworICAgIH0gZWxzZSBpZiAoaW50ZXJmYWNlXzNfNSAhPSBudWxscHRyKSB7CisgICAgICAgIGhhcmR3YXJlOjpjYW1lcmE6OmRldmljZTo6VjNfNDo6U3RyZWFtQ29uZmlndXJhdGlvbiBjb25maWd1cmF0aW9uXzNfNDsKKyAgICAgICAgYm9vbCBzdWNjZXNzID0gU2Vzc2lvbkNvbmZpZ3VyYXRpb25VdGlsczo6Y29udmVydEhBTFN0cmVhbUNvbWJpbmF0aW9uRnJvbVYzN1RvVjM0KAorICAgICAgICAgICAgICAgIGNvbmZpZ3VyYXRpb25fM180LCBjb25maWd1cmF0aW9uXzNfNyk7CisgICAgICAgIGlmICghc3VjY2VzcykgeworICAgICAgICAgICAgKnN0YXR1cyA9IGZhbHNlOworICAgICAgICAgICAgcmV0dXJuIE9LOworICAgICAgICB9CisgICAgICAgIHJldCA9IGludGVyZmFjZV8zXzUtPmlzU3RyZWFtQ29tYmluYXRpb25TdXBwb3J0ZWQoY29uZmlndXJhdGlvbl8zXzQsIGhhbENiKTsKKyAgICB9IGVsc2UgeworICAgICAgICByZXR1cm4gSU5WQUxJRF9PUEVSQVRJT047CisgICAgfQorICAgIGlmIChyZXQuaXNPaygpKSB7CisgICAgICAgIHN3aXRjaCAoY2FsbFN0YXR1cykgeworICAgICAgICAgICAgY2FzZSBTdGF0dXM6Ok9LOgorICAgICAgICAgICAgICAgIC8vIEV4cGVjdGVkIGNhc2UsIGRvIG5vdGhpbmcuCisgICAgICAgICAgICAgICAgcmVzID0gT0s7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIFN0YXR1czo6TUVUSE9EX05PVF9TVVBQT1JURUQ6CisgICAgICAgICAgICAgICAgcmVzID0gSU5WQUxJRF9PUEVSQVRJT047CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgIEFMT0dFKCIlczogU2Vzc2lvbiBjb25maWd1cmF0aW9uIHF1ZXJ5IGZhaWxlZDogJWQiLCBfX0ZVTkNUSU9OX18sIGNhbGxTdGF0dXMpOworICAgICAgICAgICAgICAgIHJlcyA9IFVOS05PV05fRVJST1I7CisgICAgICAgIH0KKyAgICB9IGVsc2UgeworICAgICAgICBBTE9HRSgiJXM6IFVuZXhwZWN0ZWQgYmluZGVyIGVycm9yOiAlcyIsIF9fRlVOQ1RJT05fXywgcmV0LmRlc2NyaXB0aW9uKCkuY19zdHIoKSk7CisgICAgICAgIHJlcyA9IFVOS05PV05fRVJST1I7CisgICAgfQorCisgICAgcmV0dXJuIHJlczsKK30KKworc3RhdHVzX3QgSGlkbFByb3ZpZGVySW5mbzo6Y29udmVydFRvSEFMU3RyZWFtQ29tYmluYXRpb25BbmRDYW1lcmFJZHNMb2NrZWQoCisgICAgICAgIGNvbnN0IHN0ZDo6dmVjdG9yPENhbWVyYUlkQW5kU2Vzc2lvbkNvbmZpZ3VyYXRpb24+ICZjYW1lcmFJZHNBbmRTZXNzaW9uQ29uZmlncywKKyAgICAgICAgY29uc3Qgc3RkOjpzZXQ8c3RkOjpzdHJpbmc+JiBwZXJmQ2xhc3NQcmltYXJ5Q2FtZXJhSWRzLAorICAgICAgICBpbnQgdGFyZ2V0U2RrVmVyc2lvbiwKKyAgICAgICAgaGFyZHdhcmU6OmhpZGxfdmVjPENhbWVyYUlkQW5kU3R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ICAgICAgICBpZiAocmVzICE9IE9LKSB7CisgICAgICAgICAgICByZXR1cm4gcmVzOworICAgICAgICB9CisgICAgICAgIGNhbWVyYTM6Om1ldGFkYXRhR2V0dGVyIGdldE1ldGFkYXRhID0KKyAgICAgICAgICAgICAgICBbdGhpc10oY29uc3QgU3RyaW5nOCAmaWQsIGJvb2wgb3ZlcnJpZGVGb3JQZXJmQ2xhc3MpIHsKKyAgICAgICAgICAgICAgICAgICAgQ2FtZXJhTWV0YWRhdGEgcGh5c2ljYWxEZXZpY2VJbmZvOworICAgICAgICAgICAgICAgICAgICBtTWFuYWdlci0+Z2V0Q2FtZXJhQ2hhcmFjdGVyaXN0aWNzTG9ja2VkKGlkLnN0cmluZygpLCBvdmVycmlkZUZvclBlcmZDbGFzcywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZwaHlzaWNhbERldmljZUluZm8pOworICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGh5c2ljYWxEZXZpY2VJbmZvOworICAgICAgICAgICAgICAgIH07CisgICAgICAgIHN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPiBwaHlzaWNhbENhbWVyYUlkczsKKyAgICAgICAgbU1hbmFnZXItPmlzTG9naWNhbENhbWVyYUxvY2tlZChjYW1lcmFJZCwgJnBoeXNpY2FsQ2FtZXJhSWRzKTsKKyAgICAgICAgYlN0YXR1cyA9CisgICAgICAgICAgICBTZXNzaW9uQ29uZmlndXJhdGlvblV0aWxzOjpjb252ZXJ0VG9IQUxTdHJlYW1Db21iaW5hdGlvbigKKyAgICAgICAgICAgICAgICAgICAgY2FtZXJhSWRBbmRTZXNzaW9uQ29uZmlnLm1TZXNzaW9uQ29uZmlndXJhdGlvbiwKKyAgICAgICAgICAgICAgICAgICAgU3RyaW5nOChjYW1lcmFJZC5jX3N0cigpKSwgZGV2aWNlSW5mbywgZ2V0TWV0YWRhdGEsCisgICAgICAgICAgICAgICAgICAgIHBoeXNpY2F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gICAgICAgIHNwPHByb3ZpZGVyOjpWMl83OjpJQ2FtZXJhUHJvdmlkZXI+IGludGVyZmFjZV8yXzc7CisgICAgICAgIHNwPHByb3ZpZGVyOjpWMl82OjpJQ2FtZXJhUHJvdmlkZXI+IGludGVyZmFjZV8yXzY7CisgICAgICAgIGlmIChtTWlub3JWZXJzaW9uID49IDcgJiYgY2FzdFJlc3VsdDJfNy5pc09rKCkpIHsKKyAgICAgICAgICAgIGludGVyZmFjZV8yXzcgPSBjYXN0UmVzdWx0Ml83OworICAgICAgICAgICAgaWYgKGludGVyZmFjZV8yXzcgIT0gbnVsbHB0cikgeworICAgICAgICAgICAgICAgIHJldCA9IGludGVyZmFjZV8yXzctPmlzQ29uY3VycmVudFN0cmVhbUNvbWJpbmF0aW9uU3VwcG9ydGVkXzJfNygKKyAgICAgICAgICAgICAgICAgICAgICAgIGhhbENhbWVyYUlkc0FuZFN0cmVhbUNvbWJpbmF0aW9ucywgY2IpOworICAgICAgICAgICAgfQorICAgICAgICB9IGVsc2UgaWYgKG1NaW5vclZlcnNpb24gPT0gNiAmJiBjYXN0UmVzdWx0Ml82LmlzT2soKSkgeworICAgICAgICAgICAgaW50ZXJmYWNlXzJfNiA9IGNhc3RSZXN1bHQyXzY7CisgICAgICAgICAgICBpZiAoaW50ZXJmYWNlXzJfNiAhPSBudWxscHRyKSB7CisgICAgICAgICAgICAgICAgaGFyZHdhcmU6OmhpZGxfdmVjPHByb3ZpZGVyOjpWMl82OjpDYW1lcmFJZEFuZFN0cmVhbUNvbWJpbmF0aW9uPgorICAgICAgICAgICAgICAgICAgICAgICAgaGFsQ2FtZXJhSWRzQW5kU3RyZWFtQ29tYmluYXRpb25zXzJfNjsKKyAgICAgICAgICAgICAgICBzaXplX3QgbnVtU3RyZWFtcyA9IGhhbENhbWVyYUlkc0FuZFN0cmVhbUNvbWJpbmF0aW9ucy5zaXplKCk7CisgICAgICAgICAgICAgICAgaGFsQ2FtZXJhSWRzQW5kU3RyZWFtQ29tYmluYXRpb25zXzJfNi5yZXNpemUobnVtU3RyZWFtcyk7CisgICAgICAgICAgICAgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCBudW1TdHJlYW1zOyBpKyspIHsKKyAgICAgICAgICAgICAgICAgICAgdXNpbmcgbmFtZXNwYWNlIGNhbWVyYTM7CisgICAgICAgICAgICAgICAgICAgIGF1dG8gY29uc3QmIGNvbWJpbmF0aW9uID0gaGFsQ2FtZXJhSWRzQW5kU3RyZWFtQ29tYmluYXRpb25zW2ldOworICAgICAgICAgICAgICAgICAgICBoYWxDYW1lcmFJZHNBbmRTdHJlYW1Db21iaW5hdGlvbnNfMl82W2ldLmNhbWVyYUlkID0gY29tYmluYXRpb24uY2FtZXJhSWQ7CisgICAgICAgICAgICAgICAgICAgIGJvb2wgc3VjY2VzcyA9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgU2Vzc2lvbkNvbmZpZ3VyYXRpb25VdGlsczo6Y29udmVydEhBTFN0cmVhbUNvbWJpbmF0aW9uRnJvbVYzN1RvVjM0KAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFsQ2FtZXJhSWRzQW5kU3RyZWFtQ29tYmluYXRpb25zXzJfNltpXS5zdHJlYW1Db25maWd1cmF0aW9uLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tYmluYXRpb24uc3RyZWFtQ29uZmlndXJhdGlvbik7CisgICAgICAgICAgICAgICAgICAgIGlmICghc3VjY2VzcykgeworICAgICAgICAgICAgICAgICAgICAgICAgKmlzU3VwcG9ydGVkID0gZmFsc2U7CisgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gT0s7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgcmV0ID0gaW50ZXJmYWNlXzJfNi0+aXNDb25jdXJyZW50U3RyZWFtQ29tYmluYXRpb25TdXBwb3J0ZWQoCisgICAgICAgICAgICAgICAgICAgICAgICBoYWxDYW1lcmFJZHNBbmRTdHJlYW1Db21iaW5hdGlvbnNfMl82LCBjYik7CisgICAgICAgICAgICB9CisgICAgICAgIH0KKworICAgICAgICBpZiAoaW50ZXJmYWNlXzJfNyAhPSBudWxscHRyIHx8IGludGVyZmFjZV8yXzYgIT0gbnVsbHB0cikgeworICAgICAgICAgICAgaWYgKHJldC5pc09rKCkpIHsKKyAgICAgICAgICAgICAgICBzd2l0Y2ggKGNhbGxTdGF0dXMpIHsKKyAgICAgICAgICAgICAgICAgICAgY2FzZSBTdGF0dXM6Ok9LOgorICAgICAgICAgICAgICAgICAgICAgICAgLy8gRXhwZWN0ZWQgY2FzZSwgZG8gbm90aGluZy4KKyAgICAgICAgICAgICAgICAgICAgICAgIHJlcyA9IE9LOworICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgICAgIGNhc2UgU3RhdHVzOjpNRVRIT0RfTk9UX1NVUFBPUlRFRDoKKyAgICAgICAgICAgICAgICAgICAgICAgIHJlcyA9IElOVkFMSURfT1BFUkFUSU9OOworICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IFNlc3Npb24gY29uZmlndXJhdGlvbiBxdWVyeSBmYWlsZWQ6ICVkIiwgX19GVU5DVElPTl9fLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxTdGF0dXMpOworICAgICAgICAgICAgICAgICAgICAgICAgcmVzID0gVU5LTk9XTl9FUlJPUjsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIEFMT0dFKCIlczogVW5leHBlY3RlZCBiaW5kZXIgZXJyb3I6ICVzIiwgX19GVU5DVElPTl9fLCByZXQuZGVzY3JpcHRpb24oKS5jX3N0cigpKTsKKyAgICAgICAgICAgICAgICByZXMgPSBVTktOT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ICByZXR1cm4gcmVzOwotICAgICAgICAgICAgfQotCi0gICAgICAgICAgICBib29sIHVzZVByZWNvcnJlY3RBcnJheSA9Ci0gICAgICAgICAgICAgICAgICAgIERpc3RvcnRpb25NYXBwZXI6OmlzRGlzdG9ydGlvblN1cHBvcnRlZChtUGh5c2ljYWxEZXZpY2VJbmZvTWFwW3BoeXNpY2FsSWRdKTsKLSAgICAgICAgICAgIGlmICh1c2VQcmVjb3JyZWN0QXJyYXkpIHsKLSAgICAgICAgICAgICAgICByZXMgPSBtRGlzdG9ydGlvbk1hcHBlcnNbcGh5c2ljYWxJZF0uc2V0dXBTdGF0aWNJbmZvKAotICAgICAgICAgICAgICAgICAgICAgICAgbVBoeXNpY2FsRGV2aWNlSW5mb01hcFtwaHlzaWNhbElkXSk7Ci0gICAgICAgICAgICAgICAgaWYgKHJlcyAhPSBPSykgewotICAgICAgICAgICAgICAgICAgICBTRVRfRVJSX0woIlVuYWJsZSB0byByZWFkIGNhbWVyYSAlcydzIGNhbGlicmF0aW9uIGZpZWxkcyBmb3IgZGlzdG9ydGlvbiAiCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgImNvcnJlY3Rpb24iLCBwaHlzaWNhbElkLmNfc3RyKCkpOwotICAgICAgICAgICAgICAgICAgICBzZXNzaW9uLT5jbG9zZSgpOwotICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgIH0KLQotICAgICAgICAgICAgbVpvb21SYXRpb01hcHBlcnNbcGh5c2ljYWxJZF0gPSBab29tUmF0aW9NYXBwZXIoCi0gICAgICAgICAgICAgICAgICAgICZtUGh5c2ljYWxEZXZpY2VJbmZvTWFwW3BoeXNpY2FsSWRdLAotICAgICAgICAgICAgICAgICAgICBtU3VwcG9ydE5hdGl2ZVpvb21SYXRpbywgdXNlUHJlY29ycmVjdEFycmF5KTsKLQotICAgICAgICAgICAgaWYgKFNlc3Npb25Db25maWd1cmF0aW9uVXRpb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KCkpOwogICAgICAgICAgICAgICAgIENhbWVyYTNTdHJlYW0qIGNhbWVyYTNTdHJlYW0gPSBDYW1lcmEzU3RyZWFtOjpjYXN0KHN0cmVhbS0+YXNIYWxTdHJlYW0oKSk7CiAgICAgICAgICAgICAgICAgaW50NjRfdCB1c2FnZSA9IDBMTDsKKyAgICAgICAgICAgICAgICBpbnQ2NF90IHN0cmVhbVVzZUNhc2UgPSBBTkRST0lEX1NDQUxFUl9BVkFJTEFCTEVfU1RSRUFNX1VTRV9DQVNFU19ERUZBVUxUOwogICAgICAgICAgICAgICAgIGlmIChjYW1lcmEzU3RyZWFtICE9IG51bGxwdHIpIHsKICAgICAgICAgICAgICAgICAgICAgdXNhZ2UgPSBjYW1lcmEzU3RyZWFtLT5nZXRVc2FnZSgpOworICAgICAgICAgICAgICAgICAgICBzdHJlYW1Vc2VDYXNlID0gY2FtZXJhM1N0cmVhbS0+Z2V0U3RyZWFtVXNlQ2FzZSgpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICBzdHJlYW1TdGF0cy5lbXBsYWNlX2JhY2soc3RyZWFtLT5nZXRXaWR0aCgpLCBzdHJlYW0tPmdldEhlaWdodCgpLAotICAgICAgICAgICAgICAgICAgICBzdHJlYW0tPmdldEZvcm1hdCgpLCBzdHJlYW0tPmdldERhdGFTcGFjZSgpLCB1c2FnZSwKKyAgICAgICAgICAgICAgICAgICAgc3RyZWFtLT5nZXRGb3JtYXQoKSwgc3RyZWFtTWF4UHJldmlld0Zwcywgc3RyZWFtLT5nZXREYXRhU3BhY2UoKSwgdXNhZ2UsCiAgICAgICAgICAgICAgICAgICAgIHN0cmVhbS0+Z2V0TWF4SGFsQnVmZmVycygpLAotICAgICAgICAgICAgICAgICAgICBzdHJlYW0tPmdldE1heFRvdGFsQnVmZmVycygpIC0gc3RyZWFtLT5nZXRNYXhIYWxCdWZmZXJzKCkpOworICAgICAgICAgICAgICAgICAgICBzdHJlYW0tPmdldE1heFRvdGFsQnVmZm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YSYgcmVxdWVzdCkgewotICAgICAgICAgICAgc3RhdHVzID0gczsKLSAgICAgICAgICAgIGlmIChzdGF0dXMgPT0gY29tbW9uOjpWMV8wOjpTdGF0dXM6Ok9LKSB7Ci0gICAgICAgICAgICAgICAgY29uc3QgY2FtZXJhX21ldGFkYXRhICpyID0KLSAgICAgICAgICAgICAgICAgICAgICAgIHJlaW50ZXJwcmV0X2Nhc3Q8Y29uc3QgY2FtZXJhX21ldGFkYXRhX3QqPihyZXF1ZXN0LmRhdGEoKSk7Ci0gICAgICAgICAgICAgICAgc2l6ZV90IGV4cGVjdGVkU2l6ZSA9IHJlcXVlc3Quc2l6ZSgpOwotICAgICAgICAgICAgICAgIGludCByZXQgPSB2YWxpZGF0ZV9jYW1lcmFfbWV0YWRhdGFfc3RydWN0dXJlKHIsICZleHBlY3RlZFNpemUpOwotICAgICAgICAgICAgICAgIGlmIChyZXQgPT0gT0sgfHwgcmV0ID09IENBTUVSQV9NRVRBREFUQV9WQUxJREFUSU9OX1NISUZURUQpIHsKLSAgICAgICAgICAgICAgICAgICAgKnJlcXVlc3RUZW1wbGF0ZSA9IGNsb25lX2NhbWVyYV9tZXRhZGF0YShyKTsKLSAgICAgICAgICAgICAgICAgICAgaWYgKCpyZXF1ZXN0VGVtcGxhdGUgPT0gbnVsbHB0cikgewotICAgICAgICAgICAgICAgICAgICAgICAgQUxPR0UoIiVzOiBVbmFibGUgdG8gY2xvbmUgY2FtZXJhIG1ldGFkYXRhIHJlY2VpdmVkIGZyb20gSEFMIiwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIHN0YXR1cyA9IGNvbW1vbjo6VjFfMDo6U3RhdHVzOjpJTlRFUk5BTF9FUlJPUjsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIEFMT0dFKCIlczogTWFsZm9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ci0gICAgICAgICAgICBjYWxsU3RhdHVzID0gczsKLSAgICAgICAgICAgIHJlcXVpcmVkID0gcmVxdWlyZWRGbGFnOwotICAgICAgICB9OwotICAgICAgICBhdXRvIGVyciA9IG1IaWRsU2Vzc2lvbl8zXzUtPmlzUmVjb25maWd1cmF0aW9uUmVxdWlyZWQob2xkUGFyYW1zLCBuZXdQYXJhbXMsIGhpZGxDYik7Ci0gICAgICAgIG9sZFNlc3Npb25QYXJhbXMudW5sb2NrKG9sZFNlc3Npb01ldGEpOwotICAgICAgICBuZXdTZXNzaW9uUGFyYW1zLnVubG9jayhuZXdTZXNzaW9NZXRhKTsKLSAgICAgICAgaWYgKGVyci5pc09rKCkpIHsKLSAgICAgICAgICAgIHN3aXRjaCAoY2FsbFN0YXR1cykgewotICAgICAgICAgICAgICAgIGNhc2UgaGFyZHdhcmU6OmNhbWVyYTo6Y29tbW9uOjpWMV8wOjpTdGF0dXM6Ok9LOgotICAgICAgICAgICAgICAgICAgICByZXQgPSByZXF1aXJlZDsKLSAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgY2FzZSBoYXJkd2FyZTo6Y2FtZXJhOjpjb21tb246OlYxXzA6OlN0YXR1czo6TUVUSE9EX05PVF9TVVBQT1JURUQ6Ci0gICAgICAgICAgICAgICAgICAgIG1Jc1JlY29uZmlndXJhdGlvblF1ZXJ5U3VwcG9ydGVkID0gZmFsc2U7Ci0gICAgICAgICAgICAgICAgICAgIHJldCA9IHRydWU7Ci0gICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgIGRlZmF1bHQ6Ci0gICAgICAgICAgICAgICAgICAgIEFMT0dWKCIlczogUmVjb25maWd1cmF0aW9uIHF1ZXJ5IGZhaWxlZDogJWQiLCBfX0ZVTkNUSU9OX18sIGNhbGxTdGF0dXMpOwotICAgICAgICAgICAgICAgICAgICByZXQgPSB0cnVlOwotICAgICAgICAgICAgfQotICAgICAgICB9IGVsc2U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zaW9uUGFyYW1TaXplKTsKLQotICAgIC8vIEludm9rZSBjb25maWd1cmVTdHJlYW1zCi0gICAgZGV2aWNlOjpWM18zOjpIYWxTdHJlYW1Db25maWd1cmF0aW9uIGZpbmFsQ29uZmlndXJhdGlvbjsKLSAgICBkZXZpY2U6OlYzXzQ6OkhhbFN0cmVhbUNvbmZpZ3VyYXRpb24gZmluYWxDb25maWd1cmF0aW9uM180OwotICAgIGRldmljZTo6VjNfNjo6SGFsU3RyZWFtQ29uZmlndXJhdGlvbiBmaW5hbENvbmZpZ3VyYXRpb24zXzY7Ci0gICAgY29tbW9uOjpWMV8wOjpTdGF0dXMgc3RhdHVzOwotCi0gICAgYXV0byBjb25maWdTdHJlYW0zNENiID0gWyZzdGF0dXMsICZmaW5hbENvbmZpZ3VyYXRpb24zXzRdCi0gICAgICAgICAgICAoY29tbW9uOjpWMV8wOjpTdGF0dXMgcywgY29uc3QgZGV2aWNlOjpWM180OjpIYWxTdHJlYW1Db25maWd1cmF0aW9uJiBoYWxDb25maWd1cmF0aW9uKSB7Ci0gICAgICAgICAgICAgICAgZmluYWxDb25maWd1cmF0aW9uM180ID0gaGFsQ29uZmlndXJhdGlvbjsKLSAgICAgICAgICAgICAgICBzdGF0dXMgPSBzOwotICAgICAgICAgICAgfTsKLQotICAgIGF1dG8gY29uZmlnU3RyZWFtMzZDYiA9IFsmc3RhdHVzLCAmZmluYWxDb25maWd1cmF0aW9uM182XQotICAgICAgICAgICAgKGNvbW1vbjo6VjFfMDo6U3RhdHVzIHMsIGNvbnN0IGRldmljZTo6VjNfNjo6SGFsU3RyZWFtQ29uZmlndXJhdGlvbiYgaGFsQ29uZmlndXJhdGlvbikgewotICAgICAgICAgICAgICAgIGZpbmFsQ29uZmlndXJhdGlvbjNfNiA9IGhhbENvbmZpZ3VyYXRpb247Ci0gICAgICAgICAgICAgICAgc3RhdHVzID0gczsKLSAgICAgICAgICAgIH07Ci0KLSAgICBhdXRvIHBvc3Rwcm9jQ29uZmlnU3RyZWFtMzQgPSBbJmZpbmFsQ29uZmlndXJhdGlvbiwgJmZpbmFsQ29uZmlndXJhdGlvbjNfNF0KLSAgICAgICAgICAgIChoYXJkd2FyZTo6UmV0dXJuPHZvaWQ+JiBlcnIpIC0+IHN0YXR1c190IHsKLSAgICAgICAgICAgICAgICBpZiAoIWVyci5pc09rKCkpIHsKLSAgICAgICAgICAgICAgICAgICAgQUxPR0UoIiVzOiBUcmFuc2FjdGlvbiBlcnJvcjogJXMiLCBfX0ZVTkNUSU9OX18sIGVyci5kZXNjcmlwdGlvbigpLmNfc3RyKCkpOwotICAgICAgICAgICAgICAgICAgICByZXR1cm4gREVBRF9PQkpFQ1Q7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIGZpbmFsQ29uZmlndXJhdGlvbi5zdHJlYW1zLnJlc2l6ZShmaW5hbENvbmZpZ3VyYXRpb24zXzQuc3RyZWFtcy5zaXplKCkpOwotICAgICAgICAgICAgICAgIGZvciAoc2l6ZV90IGkgPSAwOyBpIDwgZmluYWxDb25maWd1cmF0aW9uM180LnN0cmVhbXMuc2l6ZSgpOyBpKyspIHsKLSAgICAgICAgICAgICAgICAgICAgZmluYWxDb25maWd1cmF0aW9uLnN0cmVhbXNbaV0gPSBmaW5hbENvbmZpZ3VyYXRpb24zXzQuc3RyZWFtc1tpXS52M18zOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICByZXR1cm4gT0s7Ci0gICAgICAgICAgICB9OwotCi0gICAgYXV0byBwb3N0cHJvY0NvbmZpZ1N0cmVhbTM2ID0gWyZmaW5hbENvbmZpZ3VyYXRpb24sICZmaW5hbENvbmZpZ3VyYXRpb24zXzZdCi0gICAgICAgICAgICAoaGFyZHdhcmU6OlJldHVybjx2b2lkPiYgZXJyKSAtPiBzdGF0dXNfdCB7Ci0gICAgICAgICAgICAgICAgaWYgKCFlcnIuaXNPaygpKSB7Ci0gICAgICAgICAgICAgICAgICAgIEFMT0dFKCIlczogVHJh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zXzI7Ci0gICAgICAgIGF1dG8gZXJyID0gbUhpZGxTZXNzaW9uLT5jb25maWd1cmVTdHJlYW1zKHJlcXVlc3RlZENvbmZpZ3VyYXRpb24zXzIsCi0gICAgICAgICAgICAgICAgWyZzdGF0dXMsICZmaW5hbENvbmZpZ3VyYXRpb25fM18yXQotICAgICAgICAgICAgICAgIChjb21tb246OlYxXzA6OlN0YXR1cyBzLCBjb25zdCBIYWxTdHJlYW1Db25maWd1cmF0aW9uJiBoYWxDb25maWd1cmF0aW9uKSB7Ci0gICAgICAgICAgICAgICAgICAgIGZpbmFsQ29uZmlndXJhdGlvbl8zXzIgPSBoYWxDb25maWd1cmF0aW9uOwotICAgICAgICAgICAgICAgICAgICBzdGF0dXMgPSBzOwotICAgICAgICAgICAgICAgIH0pOwotICAgICAgICBpZiAoIWVyci5pc09rKCkpIHsKLSAgICAgICAgICAgIEFMT0dFKCIlczogVHJhbnNhY3Rpb24gZXJyb3I6ICVzIiwgX19GVU5DVElPTl9fLCBlcnIuZGVzY3JpcHRpb24oKS5jX3N0cigpKTsKLSAgICAgICAgICAgIHJldHVybiBERUFEX09CSkVDVDsKLSAgICAgICAgfQotICAgICAgICBmaW5hbENvbmZpZ3VyYXRpb24uc3RyZWFtcy5yZXNpemUoZmluYWxDb25maWd1cmF0aW9uXzNfMi5zdHJlYW1zLnNpemUoKSk7Ci0gICAgICAgIGZvciAoc2l6ZV90IGkgPSAwOyBpIDwgZmluYWxDb25maWd1cmF0aW9uXzNfMi5zdHJlYW1zLnNpemUoKTsgaSsrKSB7Ci0gICAgICAgICAgICBmaW5hbENvbmZpZ3VyYXRpb24uc3RyZWFtc1tpXS52M18yID0gZmluYWxDb25maWd1cmF0aW9uXzNfMi5zdHJlYW1zW2ldOwotICAgICAgICAgICAgZmluYWxDb25maWd1cmF0aW9uLnN0cmVhbXNbaV0ub3ZlcnJpZGVEYXRhU3BhY2UgPQotICAgICAgICAgICAgICAgICAgICByZXF1ZXN0ZWRDb25maWd1cmF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3QqPihyZXF1ZXN0LT5zZXR0aW5ncyksIHNldHRpbmdzU2l6ZSkpIHsKLSAgICAgICAgICAgICAgICBjYXB0dXJlUmVxdWVzdC0+c2V0dGluZ3MucmVzaXplKDApOwotICAgICAgICAgICAgICAgIGNhcHR1cmVSZXF1ZXN0LT5mbXFTZXR0aW5nc1NpemUgPSBzZXR0aW5nc1NpemU7Ci0gICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIGlmIChtUmVxdWVzdE1ldGFkYXRhUXVldWUgIT0gbnVsbHB0cikgewotICAgICAgICAgICAgICAgICAgICBBTE9HVygiJXM6IGNvdWxkbid0IHV0aWxpemUgZm1xLCBmYWxsYmFjayB0byBod2JpbmRlciIsIF9fRlVOQ1RJT05fXyk7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIGNhcHR1cmVSZXF1ZXN0LT5zZXR0aW5ncy5zZXRUb0V4dGVybmFsKAotICAgICAgICAgICAgICAgICAgICAgICAgcmVpbnRlcnByZXRfY2FzdDx1aW50OF90Kj4oY29uc3RfY2FzdDxjYW1lcmFfbWV0YWRhdGFfdCo+KHJlcXVlc3QtPnNldHRpbmdzKSksCi0gICAgICAgICAgICAgICAgICAgICAgICBnZXRfY2FtZXJhX21ldGFkYXRhX3NpemUocmVxdWVzdC0+c2V0dGluZ3MpKTsKLSAgICAgICAgICAgICAgICBjYXB0dXJlUmVxdWVzdC0+Zm1xU2V0dGluZ3NTaXplID0gMHU7Ci0gICAgICAgICAgICB9Ci0gICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAvLyBBIG51bGwgcmVxdWVzdCBzZXR0aW5ncyBtYXBzIHRvIGEgc2l6ZS0wIENhbWVyYU1ldGFkYXRhCi0gICAgICAgICAgICBjYXB0dXJlUmVxdWVzdC0+c2V0dGluZ3MucmVzaXplKDApOwotICAgICAgICAgICAgY2FwdHVyZVJlcXVlc3QtPmZtcVNldHRpbmdzU2l6ZSA9IDB1OwotICAgICAgICB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ICAgICAgICAgICAgIGlmIChyZXF1ZXN0LT5waHlzY2FtX3NldHRpbmdzICE9IG51bGxwdHIpIHsKLSAgICAgICAgICAgICAgICAgICAgc2l6ZV90IHNldHRpbmdzU2l6ZSA9IGdldF9jYW1lcmFfbWV0YWRhdGFfc2l6ZShyZXF1ZXN0LT5waHlzY2FtX3NldHRpbmdzW2pdKTsKLSAgICAgICAgICAgICAgICAgICAgaWYgKG1SZXF1ZXN0TWV0YWRhdGFRdWV1ZSAhPSBudWxscHRyICYmIG1SZXF1ZXN0TWV0YWRhdGFRdWV1ZS0+d3JpdGUoCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlaW50ZXJwcmV0X2Nhc3Q8Y29uc3QgdWludDhfdCo+KHJlcXVlc3QtPnBoeXNjYW1fc2V0dGluZ3Nbal0pLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXR0aW5nc1NpemUpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBwaHlzaWNhbENhbWVyYVNldHRpbmdzW2pdLnNldHRpbmdzLnJlc2l6ZSgwKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIHBoeXNpY2FsQ2FtZXJhU2V0dGluZ3Nbal0uZm1xU2V0dGluZ3NTaXplID0gc2V0dGluZ3NTaXplOwotICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1SZXF1ZXN0TWV0YWRhdGFRdWV1ZSAhPSBudWxscHRyKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgQUxPR1coIiVzOiBjb3VsZG4ndCB1dGlsaXplIGZtcSwgZmFsbGJhY2sgdG8gaHdiaW5kZXIiLCBfX0ZVTkNUSU9OX18pOwotICAgICAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgICAgICAgICAgcGh5c2ljYWxDYW1lcmFTZXR0aW5nc1tqXS5zZXR0aW5ncy5zZXRUb0V4dGVybmFsKAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWludGVycHJldF9jYXN0PHVpbnQ4X3QqPihjb25zdF9jYXN0PGNhbWVyYV9tZXRhZGF0YV90Kj4oCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdC0+cGh5c2NhbV9zZXR0aW5nc1tqXSkpLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXRfY2FtZXJhX21ldGFkYXRhX3NpemUocmVxdWVzdC0+cGh5c2NhbV9zZXR0aW5nc1tqXSkpOwotICAgICAgICAgICAgICAgICAgICAgICAgcGh5c2ljYWxDYW1lcmFTZXR0aW5nc1tqXS5mbXFTZXR0aW5nc1NpemUgPSAwdTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIHBoeXNpY2FsQ2FtZXJhU2V0dGluZ3Nbal0uZm1xU2V0dGluZ3NTaXplID0gMHU7Ci0gICAgICAgICAgICAgICAgICAgIHBoeXNpY2FsQ2FtZXJhU2V0dGluZ3Nbal0uc2V0dGluZ3MucmVzaXplKDApOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBwaHlzaWNhbENhbWVyYVNldHRpbmdzW2pdLnBoeXNpY2FsQ2FtZXJhSWQgPSByZXF1ZXN0LT5waHlzY2FtX2lkW2pdOwotICAgICAgICAgICAgfQotICAgICAgICB9Ci0gICAgfQotCi0gICAgaGFyZHdhcmU6OmRldGFpbHM6OnJldHVybl9zdGF0dXMgZXJyOwotICAgIGF1dG8gcmVzdWx0Q2FsbGJhY2sgPQotICAgICAgICBbJnN0YXR1cywgJm51bVJlcXVlc3RQcm9jZXNzZWRdIChhdXRvIHMsIHVpbnQzMl90IG4pIHsKLSAgICAgICAgICAgICAgICBzdGF0dXMgPSBzOwotICAgICAgICAgICAgICAgICpudW1SZXF1ZXN0UHJvY2Vzc2VkID0gbjsKLSAgICAgICAgfTsK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CisgICAgICAgICAgICAgICAgZXhwZWN0ZWRSYW5nZS5zZWNvbmQgPSBleHBlY3RlZFJhbmdlLmZpcnN0OwogICAgICAgICAgICAgfQogICAgICAgICAgICAgZmluZF9jYW1lcmFfbWV0YWRhdGFfcm9fZW50cnkocmVxdWVzdCwKICAgICAgICAgICAgICAgICAgICAgQU5EUk9JRF9TRU5TT1JfRlJBTUVfRFVSQVRJT04sCiAgICAgICAgICAgICAgICAgICAgICZlKTsKICAgICAgICAgICAgIGlmIChlLmNvdW50ID4gMCkgewotICAgICAgICAgICAgICAgIG1heEV4cGVjdGVkRHVyYXRpb24gPSBzdGQ6Om1heChlLmRhdGEuaTY0WzBdLCBtYXhFeHBlY3RlZER1cmF0aW9uKTsKKyAgICAgICAgICAgICAgICBleHBlY3RlZFJhbmdlLmZpcnN0ID0gc3RkOjptYXgoZS5kYXRhLmk2NFswXSwgZXhwZWN0ZWRSYW5nZS5maXJzdCk7CisgICAgICAgICAgICAgICAgZXhwZWN0ZWRSYW5nZS5zZWNvbmQgPSBleHBlY3RlZFJhbmdlLmZpcnN0OwogICAgICAgICAgICAgfQogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIGRlZmF1bHQ6CkBAIC00NTYwLDEyICszMjc2LDEzIEBACiAgICAgICAgICAgICAgICAgICAgIEFORFJPSURfQ09OVFJPTF9BRV9UQVJHRVRfRlBTX1JBTkdFLAogICAgICAgICAgICAgICAgICAgICAmZSk7CiAgICAgICAgICAgICBpZiAoZS5jb3VudCA+IDEpIHsKLSAgICAgICAgICAgICAgICBtYXhFeHBlY3RlZER1cmF0aW9uID0gMWU5IC8gZS5kYXRhLnU4WzBdOworICAgICAgICAgICAgICAgIGV4cGVjdGVkUmFuZ2UuZmlyc3QgPSAxZTkgLyBlLmRhdGEuaTMyWzFdOworICAgICAgICAgICAgICAgIGV4cGVjdGVkUmFuZ2Uuc2Vjb25kID0gMWU5IC8gZS5kYXRhLmkzMlswXTsKICAgICAgICAgICAgIH0KICAgICAgICAgICAgIGJyZWFrOwogICAgIH0KIAotICAgIHJldHVybiBtYXhFeHBlY3RlZER1cmF0aW9uOworICAgIHJldHVybiBleHBlY3RlZFJhbmdlOwogfQogCiBib29sIENhbWVyYTNEZXZpY2U6OlJlcXVlc3RUaHJlYWQ6OnNraXBIRlJUYXJnZXRGUFNVcGRhdGUoaW50MzJfdCB0YWcsCkBAIC00NTk3LDkgKzMzMTQsMTUgQEAKIAogICAgICAgICBzcDxDYW1lcmEzRGV2aWNlPiBwYXJlbnQgPSBtUGFyZW50LnByb21vdGUoKTsKICAgICAgICAgaWYgKHBhcmVudCAhPSBOVUxMKSB7CisgICAgICAgICAgICBpbnQzMl90IGlucHV0U3RyZWFtSWQgPSAtMTsKKyAgICAgICAgICAgIGlmIChoYWxSZXF1ZXN0LmlucHV0X2J1ZmZlciAhPSBudWxscHRyKSB7CisgICAgICAgICAgICAgIGlucHV0U3RyZWFtSWQgPSBDYW1lcmEzU3RyZWFtOjpjYXN0KGhhbFJlcXVlc3QuaW5wdXRfYnVmZmVyLT5zdHJlYW0pLT5nZXRJZCgpOworICAgICAgICAgICAgfQorCiAgICAgICAgICAgICBwYXJlbnQtPm1vbml0b3JNZXRhZGF0YShUYWdNb25pdG9yOjpSRVFVRVNULAogICAgICAgICAgICAgICAgICAgICBoYWxSZXF1ZXN0LmZyYW1lX251bWJlciwKLSAgICAgICAgICAgICAgICAgICAgMCwgbUxhdGVzdFJlcXVlc3QsIG1MYXRlc3RQaHlzaWNhbFJlcXVlc3QpOworICAgICAgICAgICAgICAgICAgICAwLCBtTGF0ZXN0UmVxdWVzdCwgbUxhdGVzdFBoeXNpY2FsUmVxdWVzdCwgaGFsUmVxdWVzdC5vdXRwdXRfYnVmZmVycywKKyAgICAgICAgICAgICAgICAgICAgaGFsUmVxdWVzdC5udW1fb3V0cHV0X2J1ZmZlcnMsIGlucHV0U3RyZWFtSWQpOwogICAgICAgICB9CiAgICAgfQogCkBAIC01MTc0LDExICszODk3LDEzIEBACiA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hvZHMtPmdldEluamVjdGlvbkNvbmZpZygmaW5qZWN0aW9uQ29uZmlnLCAmaW5qZWN0aW9uQnVmZmVyU2l6ZXMpOworICAgICAgICBpZiAobU9wZXJhdGluZ01vZGUgPCAwIHx8IGluamVjdGlvbkNvbmZpZy5udW1fc3RyZWFtcyA8PSAwCisgICAgICAgICAgICAgICAgICAgIHx8IGluamVjdGlvbkJ1ZmZlclNpemVzLnNpemUoKSA8PSAwKSB7CisgICAgICAgICAgICBBTE9HRSgiRmFpbGVkIHRvIGluamVjdCBjYW1lcmEgZHVlIHRvIGFiYW5kb25lZCBjb25maWd1cmF0aW9uISAiCisgICAgICAgICAgICAgICAgICAgICJtT3BlcmF0aW5nTW9kZTogJWQgaW5qZWN0aW9uQ29uZmlnLm51bV9zdHJlYW1zOiAlZCAiCisgICAgICAgICAgICAgICAgICAgICJpbmplY3Rpb25CdWZmZXJTaXplcy5zaXplKCk6ICV6dSIsIG1PcGVyYXRpbmdNb2RlLAorICAgICAgICAgICAgICAgICAgICBpbmplY3Rpb25Db25maWcubnVtX3N0cmVhbXMsIGluamVjdGlvbkJ1ZmZlclNpemVzLnNpemUoKSk7CisgICAgICAgICAgICByZXR1cm4gREVBRF9PQkpFQ1Q7CisgICAgICAgIH0KKwogICAgICAgICByZXMgPSBtSW5qZWN0aW9uTWV0aG9kcy0+aW5qZWN0Q2FtZXJhKAogICAgICAgICAgICAgICAgIGluamVjdGlvbkNvbmZpZywgaW5qZWN0aW9uQnVmZmVyU2l6ZXMpOwogICAgICAgICBpZiAocmVzICE9IE9LKSB7CkBAIC02Njk1LDYgKzUxOTQsNyBAQAogc3RhdHVzX3QgQ2FtZXJhM0RldmljZTo6c3RvcEluamVjdGlvbigpIHsKICAgICBBTE9HSSgiJXM6IEluamVjdGlvbiBjYW1lcmE6IHN0b3BJbmplY3Rpb24iLCBfX0ZVTkNUSU9OX18pOwogICAgIE11dGV4OjpBdXRvbG9jayBpbChtSW50ZXJmYWNlTG9jayk7CisgICAgT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LCBib29sIGlzTXVsdGlSZXNvbHV0aW9uLCBpbnQ2NF90IGR5bmFtaWNSYW5nZVByb2ZpbGUsCisgICAgICAgIGludDY0X3Qgc3RyZWFtVXNlQ2FzZSwgYm9vbCBkZXZpY2VUaW1lQmFzZUlzUmVhbHRpbWUsIGludCB0aW1lc3RhbXBCYXNlLAorICAgICAgICBpbnQgbWlycm9yTW9kZSkgOgogICAgICAgICBDYW1lcmEzSU9TdHJlYW1CYXNlKGlkLCBDQU1FUkFfU1RSRUFNX09VVFBVVCwgd2lkdGgsIGhlaWdodCwgbWF4U2l6ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JtYXQsIGRhdGFTcGFjZSwgcm90YXRpb24sIHBoeXNpY2FsQ2FtZXJhSWQsIHNlbnNvclBpeGVsTW9kZXNVc2VkLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldElkLCBpc011bHRpUmVzb2x1dGlvbiksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0SWQsIGlzTXVsdGlSZXNvbHV0aW9uLCBkeW5hbWljUmFuZ2VQcm9maWxlLCBzdHJlYW1Vc2VDYXNlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldmljZVRpbWVCYXNlSXNSZWFsdGltZSwgdGltZXN0YW1wQmFzZSksCiAgICAgICAgIG1Db25zdW1lcihjb25zdW1lciksCiAgICAgICAgIG1UcmFuc2Zvcm0oMCksCiAgICAgICAgIG1UcmFjZUZpcnN0QnVmZmVyKHRydWUpLAotICAgICAgICBtVXNlTW9ub1RpbWVzdGFtcChmYWxzZSksCiAgICAgICAgIG1Vc2VCdWZmZXJNYW5hZ2VyKGZhbHNlKSwKICAgICAgICAgbVRpbWVzdGFtcE9mZnNldCh0aW1lc3RhbXBPZmZzZXQpLAogICAgICAgICBtQ29uc3VtZXJVc2FnZSgwKSwKICAgICAgICAgbURyb3BCdWZmZXJzKGZhbHNlKSwKLSAgICAgICAgbURlcXVldWVCdWZmZXJMYXR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ck1vZGUobWlycm9yTW9kZSksCisgICAgICAgIG1EZXF1ZXVlQnVmZmVyTGF0ZW5jeShrRGVxdWV1ZUxhdGVuY3lCaW5TaXplKSwKKyAgICAgICAgbUlQQ1RyYW5zcG9ydCh0cmFuc3BvcnQpIHsKICAgICAvLyBEZWZlcnJlZCBjb25zdW1lciBvbmx5IHN1cHBvcnQgcHJldmlldyBzdXJmYWNlIGZvcm1hdCBub3cuCiAgICAgaWYgKGZvcm1hdCAhPSBIQUxfUElYRUxfRk9STUFUX0lNUExFTUVOVEFUSU9OX0RFRklORUQpIHsKICAgICAgICAgQUxPR0UoIiVzOiBEZWZlcnJlZCBjb25zdW1lciBvbmx5IHN1cHBvcnRzIElNUExFTUVOVEFUSU9OX0RFRklORUQgZm9ybWF0IG5vdyEiLApAQCAtMTQ2LDIxICsxNzEsMjggQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5kcm9pZF9kYXRhc3BhY2UgZGF0YVNwYWNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW1lcmFfc3RyZWFtX3JvdGF0aW9uX3Qgcm90YXRpb24sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFN0cmluZzgmIHBoeXNpY2FsQ2FtZXJhSWQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjp1bm9yZGVyZWRfc2V0PGludDMyX3Q+ICZzZW5zb3JQaXhlbE1vZGVzVXNlZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjp1bm9yZGVyZWRfc2V0PGludDMyX3Q+ICZzZW5zb3JQaXhlbE1vZGVzVXNlZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSVBDVHJhbnNwb3J0IHRyYW5zcG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdWludDY0X3QgY29uc3VtZXJVc2FnZSwgbnNlY3NfdCB0aW1lc3RhbXBPZmZzZXQsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCBzZXRJZCwgYm9vbCBpc011bHRpUmVzb2x1dGlvbikgOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgc2V0SWQsIGJvb2wgaXNNdWx0aVJlc29sdXRpb24sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDY0X3QgZHluYW1pY1JhbmdlUHJvZmlsZSwgaW50NjRfdCBzdHJlYW1Vc2VDYXNlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib29sIGRldmljZVRpbWVCYXNlSXNSZWFsdGltZSwgaW50IHRpbWVzdGFtcEJhc2UsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCBtaXJyb3JNb2RlKSA6CiAgICAgICAgIENhbWVyYTNJT1N0cmVhbUJhc2UoaWQsIHR5cGUsIHdpZHRoLCBoZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLyptYXhTaXplKi8wLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcm1hdCwgZGF0YVNwYWNlLCByb3RhdGlvbiwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBwaHlzaWNhbENhbWVyYUlkLCBzZW5zb3JQaXhlbE1vZGVzVXNlZCwgc2V0SWQsIGlzTXVsdGlSZXNvbHV0aW9uKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBwaHlzaWNhbENhbWVyYUlkLCBzZW5zb3JQaXhlbE1vZGVzVXNlZCwgc2V0SWQsIGlzTXVsdGlSZXNvbHV0aW9uLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIGR5bmFtaWNSYW5nZVByb2ZpbGUsIHN0cmVhbVVzZUNhc2UsIGRld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gICAgICAgaWYgKHJlcyAhPSBPSykgeworICAgICAgICAgICAgICAgIEFMT0dFKCIlczogU3RyZWFtICVkOiBFcnJvciBxdWV1aW5nIGJ1ZmZlciB0byBwcmV2aWV3IGJ1ZmZlciBzcGFjZXI6ICVzICglZCkiLAorICAgICAgICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fLCBtSWQsIHN0cmVycm9yKC1yZXMpLCByZXMpOworICAgICAgICAgICAgICAgIHJldHVybiByZXM7CisgICAgICAgICAgICB9CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICBuc2Vjc190IGNhcHR1cmVUaW1lID0gKG1TeW5jVG9EaXNwbGF5ID8gcmVhZG91dFRpbWVzdGFtcCA6IHRpbWVzdGFtcCkKKyAgICAgICAgICAgICAgICAgICAgLSBtVGltZXN0YW1wT2Zmc2V0OworICAgICAgICAgICAgbnNlY3NfdCBwcmVzZW50VGltZSA9IG1TeW5jVG9EaXNwbGF5ID8KKyAgICAgICAgICAgICAgICAgICAgc3luY1RpbWVzdGFtcFRvRGlzcGxheUxvY2tlZChjYXB0dXJlVGltZSkgOiBjYXB0dXJlVGltZTsKIAotICAgICAgICByZXMgPSBxdWV1ZUJ1ZmZlclRvQ29uc3VtZXIoY3VycmVudENvbnN1bWVyLCBhbndCdWZmZXIsIGFud1JlbGVhc2VGZW5jZSwgc3VyZmFjZV9pZHMpOwotICAgICAgICBpZiAoc2hvdWxkTG9nRXJyb3IocmVzLCBzdGF0ZSkpIHsKLSAgICAgICAgICAgIEFMT0dFKCIlczogU3RyZWFtICVkOiBFcnJvciBxdWV1ZWluZyBidWZmZXIgdG8gbmF0aXZlIHdpbmRvdzoiCi0gICAgICAgICAgICAgICAgICAiICVzICglZCkiLCBfX0ZVTkNUSU9OX18sIG1JZCwgc3RyZXJyb3IoLXJlcyksIHJlcyk7CisgICAgICAgICAgICBzZXRUcmFuc2Zvcm0odHJhbnNmb3JtLCB0cnVlLyptYXlDaGFuZ2VNaXJyb3IqLyk7CisgICAgICAgICAgICByZXMgPSBuYXRpdmVfd2luZG93X3NldF9idWZmZXJzX3RpbWVzdGFtcChtQ29uc3VtZXIuZ2V0KCksIHByZXNlbnRUaW1lKTsKKyAgICAgICAgICAgIGlmIChyZXMgIT0gT0spIHsKKyAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IFN0cmVhbSAlZDogRXJyb3Igc2V0dGluZyB0aW1lc3RhbXA6ICVzICglZCkiLAorICAgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgbUlkLCBzdHJlcnJvcigtcmVzKSwgcmVzKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gcmVzOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBxdWV1ZUhEUk1ldGFkYXRhKGFud0J1ZmZlci0+aGFuZGxlLCBjdXJyZW50Q29uc3VtZXIsIGR5bmFtaWNfcmFuZ2VfcHJvZmlsZSk7CisKKyAgICAgICAgICAgIHJlcyA9IHF1ZXVlQnVmZmVyVG9Db25zdW1lcihjdXJyZW50Q29uc3VtZXIsIGFud0J1ZmZlciwgYW53UmVsZWFzZUZlbmNlLCBzdXJmYWNlX2lkcyk7CisgICAgICAgICAgICBpZiAoc2hvdWxkTG9nRXJyb3IocmVzLCBzdGF0ZSkpIHsKKyAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IFN0cmVhbSAlZDogRXJyb3IgcXVldWVpbmcgYnVmZmVyIHRvIG5hdGl2ZSB3aW5kb3c6IgorICAgICAgICAgICAgICAgICAgICAgICIgJXMgKCVkKSIsIF9fRlVOQ1RJT05fXywgbUlkLCBzdHJlcnJvcigtcmVzKSwgcmVzKTsKKyAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgIH0KICAgICBtTG9jay5sb2NrKCk7CkBAIC00MDQsMTQgKzUyMywyMyBAQAogICAgICAgICAiICAgICAgRGVxdWV1ZUJ1ZmZlciBsYXRlbmN5IGhpc3RvZ3JhbToiKTsKIH0KIAotc3RhdHVzX3QgQ2FtZXJhM091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UaW1lbGluZXNbaV07CisgICAgICAgIGlmIChtaW5Wc3luY3MgPiAwKSB7CisgICAgICAgICAgICAvLyBCaWFzIHRvd2FyZHMgdXNpbmcgc21hbGxlciB0aW1lbGluZSBpbmRleDoKKyAgICAgICAgICAgIC8vICAgaSA9IDA6ICAgICAgICAgICAgICAgIGJpYXMgPSAxCisgICAgICAgICAgICAvLyAgIGkgPSBtYXhUaW1lbGluZXMtMTogICBiaWFzID0gLTEKKyAgICAgICAgICAgIGJpYXNGb3JTaG9ydERlbGF5ID0gMS4wIC0gMi4wICogaSAvIChtYXhUaW1lbGluZXMgLSAxKTsKKyAgICAgICAgfQorICAgICAgICBpZiAoc3RkOjphYnModnN5bmNUaW1lLmV4cGVjdGVkUHJlc2VudGF0aW9uVGltZSAtIGlkZWFsUHJlc2VudFQpIDwgbWluRGlmZiAmJgorICAgICAgICAgICAgICAgIHZzeW5jVGltZS5kZWFkbGluZVRpbWVzdGFtcCA+PSBjdXJyZW50VGltZSAmJgorICAgICAgICAgICAgICAgIHZzeW5jVGltZS5leHBlY3RlZFByZXNlbnRhdGlvblRpbWUgPgorICAgICAgICAgICAgICAgIG1MYXN0UHJlc2VudFRpbWUgKyBtaW5JbnRlcnZhbCArIGJpYXNGb3JTaG9ydERlbGF5ICoga1RpbWVsaW5lVGhyZXNob2xkTnMpIHsKKyAgICAgICAgICAgIGV4cGVjdGVkUHJlc2VudFQgPSB2c3luY1RpbWUuZXhwZWN0ZWRQcmVzZW50YXRpb25UaW1lOworICAgICAgICAgICAgbWluRGlmZiA9IHN0ZDo6YWJzKHZzeW5jVGltZS5leHBlY3RlZFByZXNlbnRhdGlvblRpbWUgLSBpZGVhbFByZXNlbnRUKTsKKyAgICAgICAgfQorICAgIH0KKyAgICBtTGFzdENhcHR1cmVUaW1lID0gdDsKKyAgICBtTGFzdFByZXNlbnRUaW1lID0gZXhwZWN0ZWRQcmVzZW50VDsKKworICAgIC8vIE1vdmUgdGhlIGV4cGVjdGVkIHByZXNlbn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WVzdC5yZXF1ZXN0VGltZU5zLCBzZXNzaW9uU3RhdHNCdWlsZGVyLCB0aW1lc3RhbXBJbmNyZWFzaW5nLAogICAgICAgICAgICAgcmVxdWVzdC5vdXRwdXRTdXJmYWNlcywgcmVxdWVzdC5yZXN1bHRFeHRyYXMsCiAgICAgICAgICAgICByZXF1ZXN0LmVycm9yQnVmU3RyYXRlZ3ksIHJlcXVlc3QudHJhbnNmb3JtKTsKIApAQCAtMTAzNSw2ICs4NTIsMTQgQEAKICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgci5zaHV0dGVyVGltZXN0YW1wID0gbXNnLnRpbWVzdGFtcDsKKyAgICAgICAgICAgIHIuc2h1dHRlclJlYWRvdXRUaW1lc3RhbXAgPSBtc2cucmVhZG91dF90aW1lc3RhbXA7CisgICAgICAgICAgICBpZiAoci5taW5FeHBlY3RlZER1cmF0aW9uICE9IHN0YXRlcy5taW5GcmFtZUR1cmF0aW9uKSB7CisgICAgICAgICAgICAgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCBzdGF0ZXMub3V0cHV0U3RyZWFtcy5zaXplKCk7IGkrKykgeworICAgICAgICAgICAgICAgICAgICBhdXRvIG91dHB1dFN0cmVhbSA9IHN0YXRlcy5vdXRwdXRTdHJlYW1zW2ldOworICAgICAgICAgICAgICAgICAgICBvdXRwdXRTdHJlYW0tPm9uTWluRHVyYXRpb25DaGFuZ2VkKHIubWluRXhwZWN0ZWREdXJhdGlvbik7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIHN0YXRlcy5taW5GcmFtZUR1cmF0aW9uID0gci5taW5FeHBlY3RlZER1cmF0aW9uOworICAgICAgICAgICAgfQogICAgICAgICAgICAgaWYgKHIuaGFzQ2FsbGJhY2spIHsKICAgICAgICAgICAgICAgICBBTE9HVlYoIkNhbWVyYSAlczogJXM6IFNodXR0ZXIgZmlyZWQgZm9yIGZyYW1lICVkIChpZCAlZCkgYXQgJSIgUFJJZDY0LAogICAgICAg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tIGlkICVkIiwgX19GVU5DVElPTl9fLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIG0ubWVzc2FnZS5lcnJvci5mcmFtZV9udW1iZXIsIG1zZy5tc2cuZXJyb3IuZXJyb3JTdHJlYW1JZCk7Ci0gICAgICAgICAgICAgICAgICAgIHJldHVybjsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgbS5tZXNzYWdlLmVycm9yLmVycm9yX3N0cmVhbSA9IHN0cmVhbS0+YXNIYWxTdHJlYW0oKTsKLSAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgbS5tZXNzYWdlLmVycm9yLmVycm9yX3N0cmVhbSA9IG51bGxwdHI7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBzd2l0Y2ggKG1zZy5tc2cuZXJyb3IuZXJyb3JDb2RlKSB7Ci0gICAgICAgICAgICAgICAgY2FzZSBFcnJvckNvZGU6OkVSUk9SX0RFVklDRToKLSAgICAgICAgICAgICAgICAgICAgbS5tZXNzYWdlLmVycm9yLmVycm9yX2NvZGUgPSBDQU1FUkFfTVNHX0VSUk9SX0RFVklDRTsKLSAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgY2FzZSBFcnJvckNvZGU6OkVSUk9SX1JFUVVFU1Q6Ci0gICAgICAgICAgICAgICAgICAgIG0ubWVzc2FnZS5lcnJvci5lcnJvcl9jb2RlID0gQ0FNRVJBX01TR19FUlJPUl9SRVFVRVNUOwotICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICBjYXNlIEVycm9yQ29kZTo6RVJST1JfUkVTVUxUOgotICAgICAgICAgICAgICAgICAgICBtLm1lc3NhZ2UuZXJyb3IuZXJyb3JfY29kZSA9IENBTUVSQV9NU0dfRVJST1JfUkVTVUxUOwotICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICBjYXNlIEVycm9yQ29kZTo6RVJST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RhdGVzLnNlc3Npb25TdGF0c0J1aWxkZXIuc3RvcENvdW50ZXIoc3RyZWFtSWQpOwotICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgIEFMT0dFKCIlczogQ2FuJ3QgZ2V0IG91dHB1dCBidWZmZXIgZm9yIHN0cmVhbSAlZDogJXMgKCVkKSIsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fLCBzdHJlYW1JZCwgc3RyZXJyb3IoLXJlcyksIHJlcyk7Ci0gICAgICAgICAgICAgICAgICAgIGlmIChyZXMgPT0gVElNRURfT1VUIHx8IHJlcyA9PSBOT19NRU1PUlkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJ1ZlJldC52YWwuZXJyb3IoU3RyZWFtQnVmZmVyUmVxdWVzdEVycm9yOjpOT19CVUZGRVJfQVZBSUxBQkxFKTsKLSAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJ1ZlJldC52YWwuZXJyb3IoU3RyZWFtQnVmZmVyUmVxdWVzdEVycm9yOjpVTktOT1dOX0VSUk9SKTsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBjdXJyZW50UmVxU3VjY2VlZHMgPSBmYWxzZTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIG51bUFsbG9jYXRlZEJ1ZmZlcnMrKzsKLQotICAgICAgICAgICAgYnVmZmVyX2hhbmRsZV90ICpidWZmZXIgPSBzYi5idWZmZXI7Ci0gICAgICAgICAgICBhdXRvIHBhaXIgPSBzdGF0ZXMuYnVmZmVyUmVjb3Jkc0ludGYuZ2V0QnVmZmVySWQoKmJ1ZmZlciwgc3RyZWFtSWQpOwotICAgICAgICAgICAgYm9vbCBpc05ld0J1ZmZlciA9IHBhaXIuZmlyc3Q7Ci0gICAgICA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YnVmZmVySWQsIGJ1ZmZlciwgc3RyZWFtSWQpOwotICAgICAgICAgICAgaWYgKHJlcyAhPSBPSykgewotICAgICAgICAgICAgICAgIEFMT0dFKCIlczogQ2FuJ3QgZ2V0IHJlZ2lzdGVyIHJlcXVlc3QgYnVmZmVycyBmb3Igc3RyZWFtICVkOiAlcyAoJWQpIiwKLSAgICAgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgc3RyZWFtSWQsIHN0cmVycm9yKC1yZXMpLCByZXMpOwotICAgICAgICAgICAgICAgIGJ1ZlJldC52YWwuZXJyb3IoU3RyZWFtQnVmZmVyUmVxdWVzdEVycm9yOjpVTktOT1dOX0VSUk9SKTsKLSAgICAgICAgICAgICAgICBjdXJyZW50UmVxU3VjY2VlZHMgPSBmYWxzZTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIG51bVB1c2hlZEluZmxpZ2h0QnVmZmVycysrOwotICAgICAgICB9Ci0gICAgICAgIGlmIChjdXJyZW50UmVxU3VjY2VlZHMpIHsKLSAgICAgICAgICAgIGJ1ZlJldC52YWwuYnVmZmVycyhzdGQ6Om1vdmUodG1wUmV0QnVmZmVycykpOwotICAgICAgICAgICAgb25lUmVxU3VjY2VlZHMgPSB0cnVlOwotICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgYWxsUmVxc1N1Y2NlZWRzID0gZmFsc2U7Ci0gICAgICAgICAgICBmb3IgKHNpemVfdCBiID0gMDsgYiA8IG51bVB1c2hlZEluZmxpZ2h0QnVmZmVyczsgYisrKSB7Ci0gICAgICAgICAgICAgICAgU3RyZWFtQnVmZmVyJiBoQnVmID0gdG1wUmV0QnVmZmVyc1tiXTsKLSAgICAgICAgICAgICAgICBidWZmZXJfaGFuZGxlX3QqIGJ1ZmZlcjsKLSAgICAgICAgICAgICAgICBzdGF0dXNfdCByZXMgPSBzdGF0ZXMuYnVmZmVyUmVjb3Jkc0ludGYucG9wSW5mb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lN0cmF0ZWd5KTsKICAgICAgICAgICAgIEFMT0dXKCIlczogRnJhbWUgJWQgfCAgVGltZXN0YW1wOiAlIiBQUklkNjQgIiwgbWV0YWRhdGEiCiAgICAgICAgICAgICAgICAgICAgICIgYXJyaXZlZDogJXMsIGJ1ZmZlcnMgbGVmdDogJWQuXG4iLCBfX0ZVTkNUSU9OX18sCiAgICAgICAgICAgICAgICAgICAgIHN0YXRlcy5pbmZsaWdodE1hcC5rZXlBdChpZHgpLCByZXF1ZXN0LnNodXR0ZXJUaW1lc3RhbXAsCkBAIC0xNTY1LDcgKzExMDEsNyBAQAogICAgICAgICAgICAgICAgIHN3aXRjaCAoaGFsU3RyZWFtLT5zdHJlYW1fdHlwZSkgewogICAgICAgICAgICAgICAgICAgICBjYXNlIENBTUVSQV9TVFJFQU1fT1VUUFVUOgogICAgICAgICAgICAgICAgICAgICAgICAgcmVzID0gc3RyZWFtLT5yZXR1cm5CdWZmZXIoc3RyZWFtQnVmZmVyLCAvKnRpbWVzdGFtcCovIDAsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qdGltZXN0YW1wSW5jcmVhc2luZyovdHJ1ZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLypyZWFkb3V0VGltZXN0YW1wKi8wLCAvKnRpbWVzdGFtcEluY3JlYXNpbmcqL3RydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0ZDo6dmVjdG9yPHNpemVfdD4gKCksIGZyYW1lTnVtYmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXMgIT0gT0spIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IENhbid0IHJldHVybiBvdXRwdXQgYnVmZmVyIGZvciBmcmFtZSAlZCB0byIKZGlmZiAtLWdpdCBhL3NlcnZpY2VzL2NhbWVyYS9saWJjYW1lcmFzZXJ2aWNlL2RldmljZTMvQ2FtZXJhM091dHB1dFV0aWxzLmggY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m9vbCBub0J1ZmZlclJldHVybmVkID0gZmFsc2U7CisgICAgICAgIGJ1ZmZlcl9oYW5kbGVfdCAqYnVmZmVyID0gbnVsbHB0cjsKKyAgICAgICAgaWYgKHN0YXRlcy51c2VIYWxCdWZNYW5hZ2VyKSB7CisgICAgICAgICAgICAvLyBUaGlzIGlzIHN1c3BpY2lvdXMgbW9zdCBvZiB0aGUgdGltZSBidXQgY2FuIGJlIGNvcnJlY3QgZHVyaW5nIGZsdXNoIHdoZXJlIEhBTAorICAgICAgICAgICAgLy8gaGFzIHRvIHJldHVybiBjYXB0dXJlIHJlc3VsdCBiZWZvcmUgYSBidWZmZXIgaXMgcmVxdWVzdGVkCisgICAgICAgICAgICBpZiAoYlNyYy5idWZmZXJJZCA9PSBCVUZGRVJfSURfTk9fQlVGRkVSKSB7CisgICAgICAgICAgICAgICAgaWYgKGJTcmMuc3RhdHVzID09IEJ1ZmZlclN0YXR1c1R5cGU6Ok9LKSB7CisgICAgICAgICAgICAgICAgICAgIEFMT0dFKCIlczogRnJhbWUgJWQ6IEJ1ZmZlciAlenU6IE5vIGJ1ZmZlcklkIGZvciBzdHJlYW0gJWQiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgcmVzdWx0LmZyYW1lTnVtYmVyLCBpLCBiU3JjLnN0cmVhbUlkKTsKKyAgICAgICAgICAgICAgICAgICAgLy8gU3RpbGwgcHJvY2VlZHMgc28gb3RoZXIgYnVmZmVycyBjYW4gYmUgcmV0dXJuZWQKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgbm9CdWZmZXJSZXR1cm5lZCA9IHRydWU7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBpZiAobm9CdWZmZXJSZXR1cm5lZCkgeworICAgICAgICAgICAgICAgIHJlcyA9IE9LOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICByZXMgPSBidWZmZXJSZWNvcmRzLnBvcEluZmxpZ2h0UmV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V9mZW5jZSA9IC0xOworICAgICAgICB9IGVsc2UgaWYgKG51bUZkc0luSGFuZGxlKGJ1Zi5yZWxlYXNlRmVuY2UpID09IDEpIHsKKyAgICAgICAgICAgIHN0cmVhbUJ1ZmZlci5yZWxlYXNlX2ZlbmNlID0gZHVwKGdldEhhbmRsZUZpcnN0RmQoYnVmLnJlbGVhc2VGZW5jZSkpOworICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgQUxPR0UoIiVzOiBJbnZhbGlkIHJlbGVhc2UgZmVuY2UsIGZkIGNvdW50IGlzICVkLCBub3QgMSIsCisgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgKGludCludW1GZHNJbkhhbmRsZShidWYucmVsZWFzZUZlbmNlKSk7CisgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgfQorCisgICAgICAgIHNwPENhbWVyYTNTdHJlYW1JbnRlcmZhY2U+IHN0cmVhbSA9IHN0YXRlcy5vdXRwdXRTdHJlYW1zLmdldChidWYuc3RyZWFtSWQpOworICAgICAgICBpZiAoc3RyZWFtID09IG51bGxwdHIpIHsKKyAgICAgICAgICAgIEFMT0dFKCIlczogT3V0cHV0IHN0cmVhbSBpZCAlZCBub3QgZm91bmQhIiwgX19GVU5DVElPTl9fLCBidWYuc3RyZWFtSWQpOworICAgICAgICAgICAgY29udGludWU7CisgICAgICAgIH0KKyAgICAgICAgc3RyZWFtQnVmZmVyLnN0cmVhbSA9IHN0cmVhbS0+YXNIYWxTdHJlYW0oKTsKKyAgICAgICAgcmV0dXJuT3V0cHV0QnVmZmVycyhzdGF0ZXMudXNlSGFsQnVmTWFuYWdlciwgLypsaXN0ZW5lciovbnVsbHB0ciwKKyAgICAgICAgICAgICAgICAmc3RyZWFtQnVmZmVyLCAvKnNpemUqLzEsIC8qdGltZXN0YW1wKi8gMCwgLypyZWFkb3V0VGltZXN0YW1wKi8wLAorICAgICAgICAgICAgICAgIC8qcmVxdWVzdGVkKi9mYWxzZSwgLypyZXF1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jA4Ni5oYXNfdmFsdWUoKSkgeworICAgICAgICAgICAgICAgIGNvbnN0IGF1dG8mIG1ldGFWYWx1ZSA9IHNtcHRlMjA4Ni52YWx1ZSgpOworICAgICAgICAgICAgICAgIGFuZHJvaWRfc21wdGUyMDg2X21ldGFkYXRhIG1ldGEgPSB7CisgICAgICAgICAgICAgICAgICAgIC5kaXNwbGF5UHJpbWFyeVJlZC54ID0gbWV0YVZhbHVlLnByaW1hcnlSZWQueCwKKyAgICAgICAgICAgICAgICAgICAgLmRpc3BsYXlQcmltYXJ5UmVkLnkgPSBtZXRhVmFsdWUucHJpbWFyeVJlZC55LAorICAgICAgICAgICAgICAgICAgICAuZGlzcGxheVByaW1hcnlHcmVlbi54ID0gbWV0YVZhbHVlLnByaW1hcnlHcmVlbi54LAorICAgICAgICAgICAgICAgICAgICAuZGlzcGxheVByaW1hcnlHcmVlbi55ID0gbWV0YVZhbHVlLnByaW1hcnlHcmVlbi55LAorICAgICAgICAgICAgICAgICAgICAuZGlzcGxheVByaW1hcnlCbHVlLnggPSBtZXRhVmFsdWUucHJpbWFyeUJsdWUueCwKKyAgICAgICAgICAgICAgICAgICAgLmRpc3BsYXlQcmltYXJ5Qmx1ZS55ID0gbWV0YVZhbHVlLnByaW1hcnlCbHVlLnksCisgICAgICAgICAgICAgICAgICAgIC53aGl0ZVBvaW50LnggPSBtZXRhVmFsdWUud2hpdGVQb2ludC54LAorICAgICAgICAgICAgICAgICAgICAud2hpdGVQb2ludC55ID0gbWV0YVZhbHVlLndoaXRlUG9pbnQueSwKKyAgICAgICAgICAgICAgICAgICAgLm1heEx1bWluYW5jZSA9IG1ldGFWYWx1ZS5tYXhMdW1pbmFuY2UsCisgICAgICAgICAgICAgICAgICAgIC5taW5MdW1pbmFuY2UgPSBtZXRhVmFsdWUubWluTHVtaW5hbmNlfTsKKyAgICAgICAgICAgICAgICBuYXRpdmVfd2luZG93X3NldF9idWZmZXJzX3NtcHRlMjA4Nl9tZXRhZGF0YShhbncuZ2V0KCksICZtZXRhKTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgQUxPR0UoIiVzIENvdWxkbid0IHJldHJpZXZlIFNtcHRlMjA4NiBtZXRhZGF0YSAlcyAoJWQpIiwKKyAgICAgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgc3RyZXJyb3IoLXJlcyksIHJlcyk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICBjYXNlIEFORFJPSURfUkVRVUVTVF9BVkFJTEFCTEVfRFlOQU1JQ19SQU5HRV9QUk9GSUxFU19NQVBfSERSMTBfUExVUzogeworICAgICAgICAgICAgc3RkOjpvcHRpb25hbDxzdGQ6OnZlY3Rvcjx1aW50OF90Pj4gc21wdGUyMDk0XzQwOworICAgICAgICAgICAgYXV0byByZXMgPSBtYXBwZXIuZ2V0U21wdGUyMDk0XzQwKGJ1ZmZlciwgJnNtcHRlMjA5NF80MCk7CisgICAgICAgICAgICBpZiAoKHJlcyA9PSBPSykgJiYgc21wdGUyMDk0XzQwLmhhc192YWx1ZSgpKSB7CisgICAgICAgICAgICAgICAgbmF0aXZlX3dpbmRvd19zZXRfYnVmZmVyc19oZHIxMF9wbHVzX21ldGFkYXRhKGFudy5nZXQoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgIHNtcHRlMjA5NF80MC52YWx1ZSgpLnNpemUoKSwgc21wdGUyMDk0XzQwLnZhbHVlKCkuZGF0YSgpKTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgQUxPR0UoIiVzIENvdWxkbid0IHJldHJpZXZlIFNtcHRlMjA5NF80MCBtZXRhZGF0YSAlcyAoJWQpIiwKKyAgICAgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgc3RyZXJyb3IoLXJlcyksIHJlcyk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICB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iAgICAgdm9pZCAgICAgICAgICAgICAgc2V0Rm9ybWF0T3ZlcnJpZGUoYm9vbCBmb3JtYXRPdmVycmlkZW4pOwogICAgIGJvb2wgICAgICAgICAgICAgIGlzRm9ybWF0T3ZlcnJpZGRlbigpIGNvbnN0OwogICAgIGludCAgICAgICAgICAgICAgIGdldE9yaWdpbmFsRm9ybWF0KCkgY29uc3Q7CisgICAgaW50NjRfdCAgICAgICAgICAgZ2V0RHluYW1pY1JhbmdlUHJvZmlsZSgpIGNvbnN0OwogICAgIHZvaWQgICAgICAgICAgICAgIHNldERhdGFTcGFjZU92ZXJyaWRlKGJvb2wgZGF0YVNwYWNlT3ZlcnJpZGVuKTsKICAgICBib29sICAgICAgICAgICAgICBpc0RhdGFTcGFjZU92ZXJyaWRkZW4oKSBjb25zdDsKICAgICBhbmRyb2lkX2RhdGFzcGFjZSBnZXRPcmlnaW5hbERhdGFTcGFjZSgpIGNvbnN0OwogICAgIGludCAgICAgICAgICAgICAgIGdldE1heEhhbEJ1ZmZlcnMoKSBjb25zdDsKICAgICBjb25zdCBTdHJpbmc4JiAgICBwaHlzaWNhbENhbWVyYUlkKCkgY29uc3Q7CisgICAgaW50NjRfdCAgICAgICAgICAgZ2V0U3RyZWFtVXNlQ2FzZSgpIGNvbnN0OworICAgIGludCAgICAgICAgICAgICAgIGdldFRpbWVzdGFtcEJhc2UoKSBjb25zdDsKKyAgICBib29sICAgICAgICAgICAgICBpc0RldmljZVRpbWVCYXNlUmVhbHRpbWUoKSBjb25zdDsKIAogICAgIHZvaWQgICAgICAgICAgICAgIHNldE9mZmxpbmVQcm9jZXNzaW5nU3VwcG9ydChib29sKSBvdmVycmlkZTsKICAgICBib29sICAgICAgICAgICAgICBnZXRPZmZsaW5lUHJvY2Vzc2luZ1N1cHBvcnQoKSBjb25zdCBvdmVycmlkZTsKQEAgLTM1Miw3ICszNjAsNyBAQAogICAgICAqIEZvciBiaWRpcmVjdGlvbmFsIHN0cmVhbXMsIHRoaXMgbWV0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BHcmFwaGljQnVmZmVyTG9ja2VyKHNwPEdyYXBoaWNCdWZmZXI+IGJ1ZmZlcikgOiBfYnVmZmVyKGJ1ZmZlcikge30KKworICAgIHN0YXR1c190IGxvY2tBc3luYyh1aW50MzJfdCB1c2FnZSwgdm9pZCoqIGRzdEJ1ZmZlciwgaW50IGZlbmNlRmQpIHsKKyAgICAgICAgaWYgKF9idWZmZXIgPT0gbnVsbHB0cikgcmV0dXJuIEJBRF9WQUxVRTsKKworICAgICAgICBzdGF0dXNfdCByZXMgPSBPSzsKKyAgICAgICAgaWYgKCFfbG9ja2VkKSB7CisgICAgICAgICAgICBzdGF0dXNfdCByZXMgPSAgX2J1ZmZlci0+bG9ja0FzeW5jKHVzYWdlLCBkc3RCdWZmZXIsIGZlbmNlRmQpOworICAgICAgICAgICAgaWYgKHJlcyA9PSBPSykgeworICAgICAgICAgICAgICAgIF9sb2NrZWQgPSB0cnVlOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgICAgIHJldHVybiByZXM7CisgICAgfQorCisgICAgc3RhdHVzX3QgbG9ja0FzeW5jKHZvaWQqKiBkc3RCdWZmZXIsIGludCBmZW5jZUZkKSB7CisgICAgICAgIHJldHVybiBsb2NrQXN5bmMoR1JBTExPQ19VU0FHRV9TV19XUklURV9PRlRFTiwgZHN0QnVmZmVyLCBmZW5jZUZkKTsKKyAgICB9CisKKyAgICB+R3JhcGhpY0J1ZmZlckxvY2tlcigpIHsKKyAgICAgICAgaWYgKF9sb2NrZWQgJiYgX2J1ZmZlciAhPSBudWxscHRyKSB7CisgICAgICAgICAgICBhdXRvIHJlcyA9IF9idWZmZXItPnVubG9jaygpOworICAgICAgICAgICAgaWYgKHJlcyAhPSBPSykgeworICAgICAgICAgICAgICAgIEFMT0dFKCIlczogRXJyb3IgdHJ5aW5nIHRvIHVubG9jayBidWZmZXI6ICVzICglZCkiLCBfX0ZVTkNUSU9OX18sCisgICAgICAgICAgICAgICAgICAgICAgICBzdHJlcnJvcigtcmVzK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IEJBRF9WQUxVRTsKKyAgICBpZiAob3BlcmF0aW9uTW9kZSA8IENBTUVSQV9WRU5ET1JfU1RSRUFNX0NPTkZJR1VSQVRJT05fTU9ERV9TVEFSVCkgeworICAgICAgICBzd2l0Y2gob3BlcmF0aW9uTW9kZSkgeworICAgICAgICAgICAgY2FzZSBDQU1FUkFfU1RSRUFNX0NPTkZJR1VSQVRJT05fTk9STUFMX01PREU6CisgICAgICAgICAgICAgICAgKm1vZGUgPSBTdHJlYW1Db25maWd1cmF0aW9uTW9kZTo6Tk9STUFMX01PREU7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIENBTUVSQV9TVFJFQU1fQ09ORklHVVJBVElPTl9DT05TVFJBSU5FRF9ISUdIX1NQRUVEX01PREU6CisgICAgICAgICAgICAgICAgKm1vZGUgPSBTdHJlYW1Db25maWd1cmF0aW9uTW9kZTo6Q09OU1RSQUlORURfSElHSF9TUEVFRF9NT0RFOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IFVua25vd24gc3RyZWFtIGNvbmZpZ3VyYXRpb24gbW9kZSAlZCIsIF9fRlVOQ1RJT05fXywgb3BlcmF0aW9uTW9kZSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKKyAgICAgICAgfQorICAgIH0gZWxzZSB7CisgICAgICAgICptb2RlID0gc3RhdGljX2Nhc3Q8U3RyZWFtQ29uZmlndXJhdGlvbk1vZGU+KG9wZXJhdGlvbk1vZGUpOworICAgIH0KKyAgICByZXR1cm4gT0s7Cit9CisKK2ludCBBaWRsQ2FtZXJhM0RldmljZTo6bWFwVG9GcmFtZXdvcmtGb3JtYXQoCisgICAgICAgIGFpZGw6OmFuZHJvaWQ6OmhhcmR3YXJlOjpncmFwaGljczo6Y29tbW9uOjpQaXhlbEZvcm1hdCBwaXhlbEZvcm1hdCkgeworICAgIHJ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2FsbGJhY2tzPih0aGlzKTsKK30KKworc3RhdHVzX3QgQWlkbENhbWVyYTNEZXZpY2U6OmluaXRpYWxpemUoc3A8Q2FtZXJhUHJvdmlkZXJNYW5hZ2VyPiBtYW5hZ2VyLAorICAgICAgICBjb25zdCBTdHJpbmc4JiBtb25pdG9yVGFncykgeworICAgIEFUUkFDRV9DQUxMKCk7CisgICAgTXV0ZXg6OkF1dG9sb2NrIGlsKG1JbnRlcmZhY2VMb2NrKTsKKyAgICBNdXRleDo6QXV0b2xvY2sgbChtTG9jayk7CisKKyAgICBBTE9HVigiJXM6IEluaXRpYWxpemluZyBBSURMIGRldmljZSBmb3IgY2FtZXJhICVzIiwgX19GVU5DVElPTl9fLCBtSWQuc3RyaW5nKCkpOworICAgIGlmIChtU3RhdHVzICE9IFNUQVRVU19VTklOSVRJQUxJWkVEKSB7CisgICAgICAgIENMT0dFKCJBbHJlYWR5IGluaXRpYWxpemVkISIpOworICAgICAgICByZXR1cm4gSU5WQUxJRF9PUEVSQVRJT047CisgICAgfQorICAgIGlmIChtYW5hZ2VyID09IG51bGxwdHIpIHJldHVybiBJTlZBTElEX09QRVJBVElPTjsKKworICAgIHN0ZDo6c2hhcmVkX3B0cjxjYW1lcmE6OmRldmljZTo6SUNhbWVyYURldmljZVNlc3Npb24+IHNlc3Npb247CisgICAgQVRSQUNFX0JFR0lOKCJDYW1lcmFIYWw6Om9wZW5TZXNzaW9uIik7CisgICAgc3RhdHVzX3QgcmVzID0gbWFuYWdlci0+b3BlbkFpZGxTZXNzaW9uKG1JZC5zdHJpbmcoKSwgbUNhbGxiYWNrcywKKyAgICAgICAgICAgIC8qb3V0Ki8gJnNlc3Npb24pOworICAgIEFUUkFDRV9FTkQoKTsKKyAgICBpZiAocmVzICE9IE9LKSB7CisgICAgICAgIFNFVF9FUlJfTCgiQ291bGQgbm90IG9wZW4gY2FtZXJhIHNlc3Npb246ICVzICglZCkiLCBzdHJlcnJvcigtcmVzKSwgcmVzKTsKKyAgICAgIC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gICAgICAgICAgICAgICAgICAgcGh5c2ljYWxJZCwgLypvdmVycmlkZUZvclBlcmZDbGFzcyovZmFsc2UsICZtUGh5c2ljYWxEZXZpY2VJbmZvTWFwW3BoeXNpY2FsSWRdKTsKKyAgICAgICAgICAgIGlmIChyZXMgIT0gT0spIHsKKyAgICAgICAgICAgICAgICBTRVRfRVJSX0woIkNvdWxkIG5vdCByZXRyaWV2ZSBjYW1lcmEgJXMgY2hhcmFjdGVyaXN0aWNzOiAlcyAoJWQpIiwKKyAgICAgICAgICAgICAgICAgICAgICAgIHBoeXNpY2FsSWQuY19zdHIoKSwgc3RyZXJyb3IoLXJlcyksIHJlcyk7CisgICAgICAgICAgICAgICAgc2Vzc2lvbi0+Y2xvc2UoKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gcmVzOworICAgICAgICAgICAgfQorCisgICAgICAgICAgICBib29sIHVzZVByZWNvcnJlY3RBcnJheSA9CisgICAgICAgICAgICAgICAgICAgIERpc3RvcnRpb25NYXBwZXI6OmlzRGlzdG9ydGlvblN1cHBvcnRlZChtUGh5c2ljYWxEZXZpY2VJbmZvTWFwW3BoeXNpY2FsSWRdKTsKKyAgICAgICAgICAgIGlmICh1c2VQcmVjb3JyZWN0QXJyYXkpIHsKKyAgICAgICAgICAgICAgICByZXMgPSBtRGlzdG9ydGlvbk1hcHBlcnNbcGh5c2ljYWxJZF0uc2V0dXBTdGF0aWNJbmZvKAorICAgICAgICAgICAgICAgICAgICAgICAgbVBoeXNpY2FsRGV2aWNlSW5mb01hcFtwaHlzaWNhbElkXSk7CisgICAgICAgICAgICAgICAgaWYgKHJlcyAhPSBPSykgeworICAgICAgICAgICAgICAgICAgICBTRVRfRVJSX0woIlVuYWJsZSB0byByZWFkIGNhbWVyYSAlcydzIGNhbGlicmF0aW9uIGZpZWxkcyBmb3IgZGlzdG9ydGlvbiAiCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgImNvcnJlY3Rpb24iLCBwaHlzaWNhbElkLmNfc3RyKCkpOworICAgICAgICAgICAgICAgICAgICBzZXNzaW9uLT5jbG9zZSgpOworICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKworICAgICAgICAgICAgbVpvb21SYXRpb01hcHBlcnNbcGh5c2ljYWxJZF0gPSBab29tUmF0aW9NYXBwZXIoCisgICAgICAgICAgICAgICAgICAgICZtUGh5c2ljYWxEZXZpY2VJbmZvTWFwW3BoeXNpY2FsSWRdLAorICAgICAgICAgICAgICAgICAgICBtU3VwcG9ydE5hdGl2ZVpvb21SYXRpbywgdXNlUHJlY29ycmVjdEFycmF5KTsKKworICAgICAgICAgICAgaWYgKFNlc3Npb25Db25maWd1cmF0aW9uVXRpbHM6OmlzVWx0cmFIaWdoUmVzb2x1dGlvblNlbnNvcigKKyAgICAgICAgICAgICAgICAgICAgbVBoeXNpY2FsRGV2aWNlSW5mb01hcFtwaHlzaWNhbElkXSkpIHsKKyAgICAgICAgICAgICAgICBtVUhSQ3JvcEFuZE1ldGVyaW5nUmVnaW9uTWFwcGVyc1twaHlzaWNhbElkXSA9CisgICAgICAgICAgICAgICAgICAgICAgICBVSFJDcm9wQW5kTWV0ZXJpbmdSZWdpb25NYXBwZXIobVBoeXNpY2FsRGV2aWNlSW5mb01hcFtwaHlzaWNhbElkXSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXNlUHJlY29ycmVjdEFycmF5KTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KKworICAgIHN0ZDo6c2hhcmVkX3B0cjxBaWRsUmVxdWVzdE1ldGFkYXRhUXVldWU+IHF1ZXVlOworICAgIDo6YWlkbDo6YW5kcm9pZDo6aGFyZHdhcmU6OmNvbW1vbjo6Zm1xOjpNUURlc2NyaXB0b3I8CisgICAgICAgICAgICBpbnQ4X3QsIDo6YWlkbDo6YW5kcm9pZDo6aGFyZHdhcmU6OmNvbW1vbjo6Zm1xOjpTeW5jaHJ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WQpIHsKKyAgICAgICAgICAgIGlmICghaW5wdXRTdHJlYW1TdXBwb3J0c09mZmxpbmUpIHsKKyAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IGlucHV0IHN0cmVhbSAlZCBjYW5ub3QgYmUgc3dpdGNoZWQgdG8gb2ZmbGluZSIsCisgICAgICAgICAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIGlkKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gQkFEX1ZBTFVFOworICAgICAgICAgICAgfQorICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgc3A8Y2FtZXJhMzo6Q2FtZXJhM091dHB1dFN0cmVhbUludGVyZmFjZT4gc3RyZWFtID0gbU91dHB1dFN0cmVhbXMuZ2V0KGlkKTsKKyAgICAgICAgICAgIGlmICghc3RyZWFtLT5nZXRPZmZsaW5lUHJvY2Vzc2luZ1N1cHBvcnQoKSkgeworICAgICAgICAgICAgICAgIEFMT0dFKCIlczogb3V0cHV0IHN0cmVhbSAlZCBjYW5ub3QgYmUgc3dpdGNoZWQgdG8gb2ZmbGluZSIsCisgICAgICAgICAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIGlkKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gQkFEX1ZBTFVFOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgfQorICAgIC8vIFRPRE86IGJsb2NrIHN1cmZhY2Ugc2hhcmluZyBhbmQgc3VyZmFjZSBncm91cCBzdHJlYW1zIHVudGlsIHdlIGNhbiBzdXBwb3J0IHRoZW0KKworICAgIC8vIFN0b3AgcmVwZWF0aW5nIHJlcXVlc3QsIHdhaXQgdW50aWwgYWxsIHJlbWFpbmluZyByZXF1ZXN0cyBhcmUgc3VibWl0dGVkLCB0aGVuIGNhbGwgaW50bworICAgIC8vIEhBTCBzd2l0Y2hUb09mZmxpbmUKKyAgICBjYW1lcmE6OmRldmljZTo6Q2FtZXJhT2ZmbGluZVNlc3Npb25JbmZvIG9mZmxpbmVT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G1JbnB1dFN0cmVhbS0+aGFzT3V0c3RhbmRpbmdCdWZmZXJzKCkpIHsKKyAgICAgICAgICAgIFNFVF9FUlIoIklucHV0IHN0cmVhbSAlZCBzdGlsbCBoYXMgJXp1IG91dHN0YW5kaW5nIGJ1ZmZlciEiLAorICAgICAgICAgICAgICAgICAgICBpbnB1dFN0cmVhbUlkLCBtSW5wdXRTdHJlYW0tPmdldE91dHN0YW5kaW5nQnVmZmVyc0NvdW50KCkpOworICAgICAgICAgICAgcmV0dXJuIFVOS05PV05fRVJST1I7CisgICAgICAgIH0KKyAgICB9CisKKyAgICBmb3IgKGNvbnN0IGF1dG8mIG91dFN0cmVhbUlkIDogb3V0cHV0U3RyZWFtSWRzKSB7CisgICAgICAgIGlmIChzdGQ6OmZpbmQob2ZmbGluZVN0cmVhbUlkcy5iZWdpbigpLCBvZmZsaW5lU3RyZWFtSWRzLmVuZCgpLAorICAgICAgICAgICAgICAgIG91dFN0cmVhbUlkKSA9PSBvZmZsaW5lU3RyZWFtSWRzLmVuZCgpKSB7CisgICAgICAgICAgICBhdXRvIG91dFN0cmVhbSA9IG1PdXRwdXRTdHJlYW1zLmdldChvdXRTdHJlYW1JZCk7CisgICAgICAgICAgICBpZiAob3V0U3RyZWFtLT5oYXNPdXRzdGFuZGluZ0J1ZmZlcnMoKSkgeworICAgICAgICAgICAgICAgIFNFVF9FUlIoIk91dHB1dCBzdHJlYW0gJWQgc3RpbGwgaGFzICV6dSBvdXRzdGFuZGluZyBidWZmZXIhIiwKKyAgICAgICAgICAgICAgICAgICAgICAgIG91dFN0cmVhbUlkLCBvdXRTdHJlYW0tPmdldE91dHN0YW5kaW5nQnVmZmVyc0NvdW50KCkpOworICAgICAgICAgICAgICAgIHJldHVybiBVTktOT1dOX0VSUk9SOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgfQorCisgICAgSW5GbGlnaHRSZXF1ZXN0TWFwIG9mZmxpbmVSZXFzOworICAgIC8vIFZlcmlmeSBpbmZsaWdod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yAgICAgICAgY2FzZSBDQU1FUkFfVEVNUExBVEVfU1RJTExfQ0FQVFVSRToKKyAgICAgICAgICAgIGlkID0gUmVxdWVzdFRlbXBsYXRlOjpTVElMTF9DQVBUVVJFOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgQ0FNRVJBX1RFTVBMQVRFX1ZJREVPX1JFQ09SRDoKKyAgICAgICAgICAgIGlkID0gUmVxdWVzdFRlbXBsYXRlOjpWSURFT19SRUNPUkQ7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBDQU1FUkFfVEVNUExBVEVfVklERU9fU05BUFNIT1Q6CisgICAgICAgICAgICBpZCA9IFJlcXVlc3RUZW1wbGF0ZTo6VklERU9fU05BUFNIT1Q7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBDQU1FUkFfVEVNUExBVEVfWkVST19TSFVUVEVSX0xBRzoKKyAgICAgICAgICAgIGlkID0gUmVxdWVzdFRlbXBsYXRlOjpaRVJPX1NIVVRURVJfTEFHOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgQ0FNRVJBX1RFTVBMQVRFX01BTlVBTDoKKyAgICAgICAgICAgIGlkID0gUmVxdWVzdFRlbXBsYXRlOjpNQU5VQUw7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgIC8vIFVua25vd24gdGVtcGxhdGUgSUQsIG9yIHRoaXMgSEFMIGlzIHRvbyBvbGQgdG8gc3VwcG9ydCBpdAorICAgICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKKyAgICB9CisgICAgYXV0byBlcnIgPSBtQWlkbFNlc3Npb24tPmNvbnN0cnVjdERlZmF1bHRSZXF1ZXN0U2V0dGluZ3MoaWQsICZyZXF1ZXN0KTsKKworICAgIGlmICghZXJyLmlzT2soKSkgeworICAgICAgICBBTE9HRSgiJXM6IFRyYW5zYWN0aW9uIGVycm9yOiAlcyIsIF9fRlVO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OjpjYXN0KHNyYyk7CisgICAgICAgIGNhbTNzdHJlYW0tPnNldEJ1ZmZlckZyZWVkTGlzdGVuZXIodGhpcyk7CisgICAgICAgIGludCBzdHJlYW1JZCA9IGNhbTNzdHJlYW0tPmdldElkKCk7CisgICAgICAgIFN0cmVhbVR5cGUgc3RyZWFtVHlwZTsKKyAgICAgICAgc3dpdGNoIChzcmMtPnN0cmVhbV90eXBlKSB7CisgICAgICAgICAgICBjYXNlIENBTUVSQV9TVFJFQU1fT1VUUFVUOgorICAgICAgICAgICAgICAgIHN0cmVhbVR5cGUgPSBTdHJlYW1UeXBlOjpPVVRQVVQ7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIENBTUVSQV9TVFJFQU1fSU5QVVQ6CisgICAgICAgICAgICAgICAgc3RyZWFtVHlwZSA9IFN0cmVhbVR5cGU6OklOUFVUOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IFN0cmVhbSAlZDogVW5zdXBwb3J0ZWQgc3RyZWFtIHR5cGUgJWQiLAorICAgICAgICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fLCBzdHJlYW1JZCwgY29uZmlnLT5zdHJlYW1zW2ldLT5zdHJlYW1fdHlwZSk7CisgICAgICAgICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKKyAgICAgICAgfQorICAgICAgICBkc3QuaWQgPSBzdHJlYW1JZDsKKyAgICAgICAgZHN0LnN0cmVhbVR5cGUgPSBzdHJlYW1UeXBlOworICAgICAgICBkc3Qud2lkdGggPSBzcmMtPndpZHRoOworICAgICAgICBkc3QuaGVpZ2h0ID0gc3JjLT5oZWlnaHQ7CisgICAgICAgIGRzdC51c2FnZSA9IG1hcFRvQWlkbENvbnN1bWVyVXNhZ2UoY2FtM3N0cmVhbS0+Z2V0VXNhZ2UoKSk7CisgICAgICAgIGRzdC5yb3RhdGlvbi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0ZVTkNUSU9OX18sIGVyci5nZXRNZXNzYWdlKCkpOworICAgICAgICByZXR1cm4gQWlkbFByb3ZpZGVySW5mbzo6bWFwVG9TdGF0dXNUKGVycik7CisgICAgfQorCisgICAgLy8gQW5kIGNvbnZlcnQgb3V0cHV0IHN0cmVhbSBjb25maWd1cmF0aW9uIGZyb20gQUlETAorCisgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCBjb25maWctPm51bV9zdHJlYW1zOyBpKyspIHsKKyAgICAgICAgY2FtZXJhMzo6Y2FtZXJhX3N0cmVhbV90ICpkc3QgPSBjb25maWctPnN0cmVhbXNbaV07CisgICAgICAgIGludCBzdHJlYW1JZCA9IENhbWVyYTNTdHJlYW06OmNhc3QoZHN0KS0+Z2V0SWQoKTsKKworICAgICAgICAvLyBTdGFydCBzY2FuIGF0IGksIHdpdGggdGhlIGFzc3VtcHRpb24gdGhhdCB0aGUgc3RyZWFtIG9yZGVyIG1hdGNoZXMKKyAgICAgICAgc2l6ZV90IHJlYWxJZHggPSBpOworICAgICAgICBib29sIGZvdW5kID0gZmFsc2U7CisgICAgICAgIHNpemVfdCBoYWxTdHJlYW1Db3VudCA9IGZpbmFsQ29uZmlndXJhdGlvbi5zaXplKCk7CisgICAgICAgIGZvciAoc2l6ZV90IGlkeCA9IDA7IGlkeCA8IGhhbFN0cmVhbUNvdW50OyBpZHgrKykgeworICAgICAgICAgICAgaWYgKGZpbmFsQ29uZmlndXJhdGlvbltyZWFsSWR4XS5pZCA9PSBzdHJlYW1JZCkgeworICAgICAgICAgICAgICAgIGZvdW5kID0gdHJ1ZTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIHJlYWxJZHggPSAocmVhbElkeCA+PSBoYWxTdHJlYW1Db3VudCAtIDEpID8gMCA6IHJlYWxJZHggKyAxOworICAgICAgICB9CisgICAgICAgIGlmICghZm91bmQpIHsKKyAgICAgICAgICAgIEFMT0dFKCIlczogU3RyZWFt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b3JtYXQ7CisgICAgICAgICAgICBkc3QtPmRhdGFfc3BhY2UgPSBvdmVycmlkZURhdGFTcGFjZTsKKyAgICAgICAgfQorCisgICAgICAgIGlmIChkc3QtPnN0cmVhbV90eXBlID09IENBTUVSQV9TVFJFQU1fSU5QVVQpIHsKKyAgICAgICAgICAgIGlmIChzdGF0aWNfY2FzdDxpbnQ2NF90PihzcmMucHJvZHVjZXJVc2FnZSkgIT0gMCkgeworICAgICAgICAgICAgICAgIEFMT0dFKCIlczogU3RyZWFtICVkOiBJTlBVVCBzdHJlYW1zIG11c3QgaGF2ZSAwIGZvciBwcm9kdWNlciB1c2FnZSIsCisgICAgICAgICAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIHN0cmVhbUlkKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gSU5WQUxJRF9PUEVSQVRJT047CisgICAgICAgICAgICB9CisgICAgICAgICAgICBkc3RTdHJlYW0tPnNldFVzYWdlKAorICAgICAgICAgICAgICAgICAgICBtYXBDb25zdW1lclRvRnJhbWV3b3JrVXNhZ2Uoc3JjLmNvbnN1bWVyVXNhZ2UpKTsKKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIC8vIE9VVFBVVAorICAgICAgICAgICAgaWYgKHN0YXRpY19jYXN0PGludDY0X3Q+KHNyYy5jb25zdW1lclVzYWdlKSAhPSAwKSB7CisgICAgICAgICAgICAgICAgQUxPR0UoIiVzOiBTdHJlYW0gJWQ6IE9VVFBVVCBzdHJlYW1zIG11c3QgaGF2ZSAwIGZvciBjb25zdW1lciB1c2FnZSIsCisgICAgICAgICAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIHN0cmVhbUlkKTsKKyAgICAgICAgICAgICAgICByZXR1cm4gSU5WQUxJRF9PUEVSQVRJT047CisgICAgICAgICAgICB9CisgICAgICAgICAgICBkc3RTdHJlYW0tPnNldFVzYWdlKAorICAgICAgICAgICAgICAgICAgICBtYXBQcm9kdWNlclRvRnJhbWV3b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1ldGFkYXRhUXVldWUgIT0gbnVsbHB0cikgeworICAgICAgICAgICAgICAgICAgICBBTE9HVygiJXM6IGNvdWxkbid0IHV0aWxpemUgZm1xLCBmYWxsYmFjayB0byBod2JpbmRlciIsIF9fRlVOQ1RJT05fXyk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIHVpbnQ4X3QgKnNldHRpbmdzUCA9CisgICAgICAgICAgICAgICAgICAgICAgICByZWludGVycHJldF9jYXN0PHVpbnQ4X3QqPigKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3RfY2FzdDxjYW1lcmFfbWV0YWRhdGFfdCo+KHJlcXVlc3QtPnNldHRpbmdzKSk7CisgICAgICAgICAgICAgICAgc2l6ZV90IHNldHRpbmdzU2l6ZSA9ICBnZXRfY2FtZXJhX21ldGFkYXRhX3NpemUocmVxdWVzdC0+c2V0dGluZ3MpOworICAgICAgICAgICAgICAgIGNhcHR1cmVSZXF1ZXN0LT5zZXR0aW5ncy5tZXRhZGF0YS5hc3NpZ24oc2V0dGluZ3NQLCBzZXR0aW5nc1AgKyBzZXR0aW5nc1NpemUpOworICAgICAgICAgICAgICAgIGNhcHR1cmVSZXF1ZXN0LT5mbXFTZXR0aW5nc1NpemUgPSAwdTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIC8vIEEgbnVsbCByZXF1ZXN0IHNldHRpbmdzIG1hcHMgdG8gYSBzaXplLTAgQ2FtZXJhTWV0YWRhdGEKKyAgICAgICAgICAgIGNhcHR1cmVSZXF1ZXN0LT5zZXR0aW5ncy5tZXRhZGF0YS5yZXNpemUoMCk7CisgICAgICAgICAgICBjYXB0dXJlUmVxdWVzdC0+Zm1xU2V0dGluZ3NTaXplID0gMHU7CisgICAgICAgIH0KKworICAgICAgICBjYXB0dXJlUmVxdWVzdCAtPmlucHV0V2lkdGggPSByZXF1ZXN0LT5pbnB1dF93aWR0aDsKKyAgICAgICAgY2Fw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mbXFTZXR0aW5nc1NpemUgPSBzZXR0aW5nc1NpemU7CisgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKG1SZXF1ZXN0TWV0YWRhdGFRdWV1ZSAhPSBudWxscHRyKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBBTE9HVygiJXM6IGNvdWxkbid0IHV0aWxpemUgZm1xLCBmYWxsYmFjayB0byBod2JpbmRlciIsIF9fRlVOQ1RJT05fXyk7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgdWludDhfdCAqcGh5c2ljYWxTZXR0aW5nc1AgPQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlaW50ZXJwcmV0X2Nhc3Q8dWludDhfdCo+KGNvbnN0X2Nhc3Q8Y2FtZXJhX21ldGFkYXRhX3QqPigKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3QtPnBoeXNjYW1fc2V0dGluZ3Nbal0pKTsKKyAgICAgICAgICAgICAgICAgICAgcGh5c2ljYWxDYW1lcmFTZXR0aW5nc1tqXS5zZXR0aW5ncy5tZXRhZGF0YS5hc3NpZ24ocGh5c2ljYWxTZXR0aW5nc1AsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGh5c2ljYWxTZXR0aW5nc1AgKyBzZXR0aW5nc1NpemUpOworICAgICAgICAgICAgICAgICAgICBwaHlzaWNhbENhbWVyYVNldHRpbmdzW2pdLmZtcVNldHRpbmdzU2l6ZSA9IDB1OworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgcGh5c2ljYWxDYW1lcmFTZXR0aW5nc1tqXS5mbXFTZXR0aW5nc1NpemUgPSAwdTsKKyAgICAgICAgICAgICAgICBwaHlzaWNhbENhbWVyYVNldHRpbmdzW2pdLnNldHRpbmdzLm1ldGFkYXRhLnJlc2l6ZSgwKTsKKyAgICAgICAgICA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Pm91dHB1dEJ1ZmZlcnNbaV07CisgICAgICAgICAgICBpbnQzMl90IHN0cmVhbUlkID0gQ2FtZXJhM1N0cmVhbTo6Y2FzdChzcmMtPnN0cmVhbSktPmdldElkKCk7CisgICAgICAgICAgICBpZiAoc3JjLT5idWZmZXIgIT0gbnVsbHB0cikgeworICAgICAgICAgICAgICAgIGJ1ZmZlcl9oYW5kbGVfdCBidWYgPSAqKHNyYy0+YnVmZmVyKTsKKyAgICAgICAgICAgICAgICBhdXRvIHBhaXIgPSBnZXRCdWZmZXJJZChidWYsIHN0cmVhbUlkKTsKKyAgICAgICAgICAgICAgICBib29sIGlzTmV3QnVmZmVyID0gcGFpci5maXJzdDsKKyAgICAgICAgICAgICAgICBkc3QuYnVmZmVySWQgPSBwYWlyLnNlY29uZDsKKyAgICAgICAgICAgICAgICBkc3QuYnVmZmVyID0gaXNOZXdCdWZmZXIgPworICAgICAgICAgICAgICAgICAgICAgICAgY2FtZXJhMzo6ZHVwVG9BaWRsSWZOb3ROdWxsKGJ1ZikgOgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhaWRsOjphbmRyb2lkOjpoYXJkd2FyZTo6Y29tbW9uOjpOYXRpdmVIYW5kbGUoKTsKKyAgICAgICAgICAgICAgICBuYXRpdmVfaGFuZGxlX3QgKmFjcXVpcmVGZW5jZSA9IG51bGxwdHI7CisgICAgICAgICAgICAgICAgaWYgKHNyYy0+YWNxdWlyZV9mZW5jZSAhPSAtMSkgeworICAgICAgICAgICAgICAgICAgICBhY3F1aXJlRmVuY2UgPSBuYXRpdmVfaGFuZGxlX2NyZWF0ZSgxLDApOworICAgICAgICAgICAgICAgICAgICBhY3F1aXJlRmVuY2UtPmRhdGFbMF0gPSBzcmMtPmFjcXVpcmVfZmVuY2U7CisgICAgICAgICAgICAgICAgICAgIGhhbmRsZXNDcmVhdGVkLT5wdXNoX2JhY2soYWNxdWlyZUZlbmNlKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgIC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RyZWFtcy5nZXQobXNnLmdldDxUYWc6OmVycm9yPigpLmVycm9yU3RyZWFtSWQpOworICAgICAgICAgICAgICAgIGlmIChzdHJlYW0gPT0gbnVsbHB0cikgeworICAgICAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IEZyYW1lICVkOiBJbnZhbGlkIGVycm9yIHN0cmVhbSBpZCAlZCIsIF9fRlVOQ1RJT05fXywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtLm1lc3NhZ2UuZXJyb3IuZnJhbWVfbnVtYmVyLCBtc2cuZ2V0PFRhZzo6ZXJyb3I+KCkuZXJyb3JTdHJlYW1JZCk7CisgICAgICAgICAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgbS5tZXNzYWdlLmVycm9yLmVycm9yX3N0cmVhbSA9IHN0cmVhbS0+YXNIYWxTdHJlYW0oKTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgbS5tZXNzYWdlLmVycm9yLmVycm9yX3N0cmVhbSA9IG51bGxwdHI7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBzd2l0Y2ggKG1zZy5nZXQ8VGFnOjplcnJvcj4oKS5lcnJvckNvZGUpIHsKKyAgICAgICAgICAgICAgICBjYXNlIEVycm9yQ29kZTo6RVJST1JfREVWSUNFOgorICAgICAgICAgICAgICAgICAgICBtLm1lc3NhZ2UuZXJyb3IuZXJyb3JfY29kZSA9IENBTUVSQV9NU0dfRVJST1JfREVWSUNFOworICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICBjYXNlIEVycm9yQ29kZTo6RVJST1JfUkVRVUVTVDoKKyAgICAgICAgICAgICAgICAgICAgbS5tZXNzYWdlLmVycm9yLmVycm9yX2NvZGUgPSBDQU1FUkFfTVNHX0VSUk9SX1JFUVVFU1Q7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgRXJy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ICAgICAgcmV0dXJuOworICAgIH0KKworICAgIC8vIENoZWNrIGZvciByZXBlYXRlZCBzdHJlYW1JZAorICAgIGZvciAoY29uc3QgYXV0byYgYnVmUmVxIDogYnVmUmVxcykgeworICAgICAgICBpZiAoc3RyZWFtSWRzLmluZGV4T2YoYnVmUmVxLnN0cmVhbUlkKSAhPSBOQU1FX05PVF9GT1VORCkgeworICAgICAgICAgICAgQUxPR0UoIiVzOiBTdHJlYW0gJWQgYXBwZWFyIG11bHRpcGxlIHRpbWVzIGluIGJ1ZmZlciByZXF1ZXN0cyIsCisgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgYnVmUmVxLnN0cmVhbUlkKTsKKyAgICAgICAgICAgICpzdGF0dXMgPSBCdWZmZXJSZXF1ZXN0U3RhdHVzOjpGQUlMRURfSUxMRUdBTF9BUkdVTUVOVFM7CisgICAgICAgICAgICByZXR1cm47CisgICAgICAgIH0KKyAgICAgICAgc3RyZWFtSWRzLmFkZChidWZSZXEuc3RyZWFtSWQpOworICAgIH0KKworICAgIGlmICghc3RhdGVzLnJlcUJ1ZmZlckludGYuc3RhcnRSZXF1ZXN0QnVmZmVyKCkpIHsKKyAgICAgICAgQUxPR0UoIiVzOiByZXF1ZXN0IGJ1ZmZlciBkaXNhbGxvd2VkIHdoaWxlIGNhbWVyYSBzZXJ2aWNlIGlzIGNvbmZpZ3VyaW5nIiwKKyAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18pOworICAgICAgICAqc3RhdHVzID0gQnVmZmVyUmVxdWVzdFN0YXR1czo6RkFJTEVEX0NPTkZJR1VSSU5HOworICAgICAgICByZXR1cm47CisgICAgfQorCisgICAgYnVmUmV0cy5yZXNpemUoYnVmUmVxcy5zaXplKCkpOworCisgICAgYm9vbCBhbGxSZXFzU3VjY2VlZHMgPSB0cnVlOworICAgIGJvb2wgb25lUmVxU3VjY2VlZHMgPSBmYWxzZTsKKyAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IGJ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gIEFMT0dWKCIlczogQ2FuJ3QgZ2V0IG91dHB1dCBidWZmZXIgZm9yIHN0cmVhbSAlZDogJXMgKCVkKSIsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fLCBzdHJlYW1JZCwgc3RyZXJyb3IoLXJlcyksIHJlcyk7CisgICAgICAgICAgICAgICAgICAgIGJ1ZlJldC52YWwuc2V0PFRhZzo6ZXJyb3I+KFN0cmVhbUJ1ZmZlclJlcXVlc3RFcnJvcjo6U1RSRUFNX0RJU0NPTk5FQ1RFRCk7CisgICAgICAgICAgICAgICAgICAgIHN0YXRlcy5zZXNzaW9uU3RhdHNCdWlsZGVyLnN0b3BDb3VudGVyKHN0cmVhbUlkKTsKKyAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IENhbid0IGdldCBvdXRwdXQgYnVmZmVyIGZvciBzdHJlYW0gJWQ6ICVzICglZCkiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgc3RyZWFtSWQsIHN0cmVycm9yKC1yZXMpLCByZXMpOworICAgICAgICAgICAgICAgICAgICBpZiAocmVzID09IFRJTUVEX09VVCB8fCByZXMgPT0gTk9fTUVNT1JZKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBidWZSZXQudmFsLnNldDxUYWc6OmVycm9yPihTdHJlYW1CdWZmZXJSZXF1ZXN0RXJyb3I6Ok5PX0JVRkZFUl9BVkFJTEFCTEUpOworICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHJlcyA9PSBJTlZBTElEX09QRVJBVElPTikgeworICAgICAgICAgICAgICAgICAgICAgICAgYnVmUmV0LnZhbC5zZXQ8VGFnOjplcnJvcj4oU3RyZWFtQnVmZmVyUmVxdWVzdEVycm9yOjpNQVhfQlVGRkVSX0VYQ0VFREVEKTsKKyAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICA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F1ZXN0QnVmZmVyKGJ1ZmZlcklkLCBidWZmZXIsIHN0cmVhbUlkKTsKKyAgICAgICAgICAgIGlmIChyZXMgIT0gT0spIHsKKyAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IENhbid0IGdldCByZWdpc3RlciByZXF1ZXN0IGJ1ZmZlcnMgZm9yIHN0cmVhbSAlZDogJXMgKCVkKSIsCisgICAgICAgICAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIHN0cmVhbUlkLCBzdHJlcnJvcigtcmVzKSwgcmVzKTsKKyAgICAgICAgICAgICAgICBidWZSZXQudmFsLnNldDxUYWc6OmVycm9yPihTdHJlYW1CdWZmZXJSZXF1ZXN0RXJyb3I6OlVOS05PV05fRVJST1IpOworICAgICAgICAgICAgICAgIGN1cnJlbnRSZXFTdWNjZWVkcyA9IGZhbHNlOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgfQorICAgICAgICAgICAgbnVtUHVzaGVkSW5mbGlnaHRCdWZmZXJzKys7CisgICAgICAgIH0KKyAgICAgICAgaWYgKGN1cnJlbnRSZXFTdWNjZWVkcykgeworICAgICAgICAgICAgYnVmUmV0LnZhbC5zZXQ8VGFnOjpidWZmZXJzPihzdGQ6Om1vdmUodG1wUmV0QnVmZmVycykpOworICAgICAgICAgICAgb25lUmVxU3VjY2VlZHMgPSB0cnVlOworICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgYWxsUmVxc1N1Y2NlZWRzID0gZmFsc2U7CisgICAgICAgICAgICBmb3IgKHNpemVfdCBiID0gMDsgYiA8IG51bVB1c2hlZEluZmxpZ2h0QnVmZmVyczsgYisrKSB7CisgICAgICAgICAgICAgICAgU3RyZWFtQnVmZmVyJiBoQnVmID0gdG1wUmV0QnVmZmVyc1tiXTsKKyAgICAgICAgICAgICAgICBidWZmZXJfaGFuZGxlX3QqIGJ1ZmZlcjsKKyAgICAgICAgICAgICAgICBzdGF0dXNfdCByZXMgPSBzdGF0ZXMuYnVmZmVyUmVjb3Jkc0ludGYucG9wSW5mbGlnaHRSZXF1ZXN0QnVmZmVyKAorICAgICAgICAgICAgICAgICAgICAgICAgaEJ1Zi5idWZmZXJJZCwgJmJ1ZmZlcik7CisgICAgICAgICAgICAgICAgaWYgKHJlcyAhPSBPSykgeworICAgICAgICAgICAgICAgICAgICBTRVRfRVJSKCIlczogcG9wSW5mbGlnaHRSZXF1ZXN0QnVmZmVyIGZhaWxlZCBmb3Igc3RyZWFtICVkOiAlcyAoJWQpIiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18sIHN0cmVhbUlkLCBzdHJlcnJvcigtcmVzKSwgcmVzKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICB9CisgICAgICAgICAgICBmb3IgKHNpemVfdCBiID0gMDsgYiA8IG51bUFsbG9jYXRlZEJ1ZmZlcnM7IGIrKykgeworICAgICAgICAgICAgICAgIGNhbWVyYV9zdHJlYW1fYnVmZmVyX3QmIHNiID0gc3RyZWFtQnVmZmVyc1tiXTsKKyAgICAgICAgICAgICAgICBzYi5hY3F1aXJlX2ZlbmNlID0gLTE7CisgICAgICAgICAgICAgICAgc2Iuc3RhdHVzID0gQ0FNRVJBX0JVRkZFUl9TVEFUVVNfRVJST1I7CisgICAgICAgICAgICB9CisgICAgICAgICAgICByZXR1cm5PdXRwdXRCdWZmZXJzKHN0YXRlcy51c2VIYWxCdWZNYW5hZ2VyLCBudWxscHRyLAorICAgICAgICAgICAgICAgICAgICBzdHJlYW1CdWZmZXJzLmRhdGEoKSwgbnVtQWxsb2NhdGVkQnVmZmVycywgMCwKKyAgICAgICAgICAgICAgICAgICAgMCwgZmFsc2UsCisgICAgICAgICAgICAgICAgICAgIDAsIHN0YXRlcy5zZXNzaW9uU3RhdHNCdWlsZGVyKTsKKyAgICAgICAgICAgIGZvciAoYXV0byBidWYgOiBuZXdCdWZmZXJzKSB7CisgICAgICAgICAgICAgICAgc3RhdGVzLmJ1ZmZlclJl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V9TVFJFQU1fUk9UQVRJT05fMjcwOgorICAgICAgICAgICAgcmV0dXJuIFN0cmVhbVJvdGF0aW9uOjpST1RBVElPTl8yNzA7CisgICAgfQorICAgIEFMT0dFKCIlczogVW5rbm93biBzdHJlYW0gcm90YXRpb24gJWQiLCBfX0ZVTkNUSU9OX18sIHJvdGF0aW9uKTsKKyAgICByZXR1cm4gU3RyZWFtUm90YXRpb246OlJPVEFUSU9OXzA7Cit9CisKK3N0YXR1c190IEhpZGxDYW1lcmEzRGV2aWNlOjptYXBUb1N0cmVhbUNvbmZpZ3VyYXRpb25Nb2RlKAorICAgICAgICBjYW1lcmFfc3RyZWFtX2NvbmZpZ3VyYXRpb25fbW9kZV90IG9wZXJhdGlvbk1vZGUsIFN0cmVhbUNvbmZpZ3VyYXRpb25Nb2RlICptb2RlKSB7CisgICAgaWYgKG1vZGUgPT0gbnVsbHB0cikgcmV0dXJuIEJBRF9WQUxVRTsKKyAgICBpZiAob3BlcmF0aW9uTW9kZSA8IENBTUVSQV9WRU5ET1JfU1RSRUFNX0NPTkZJR1VSQVRJT05fTU9ERV9TVEFSVCkgeworICAgICAgICBzd2l0Y2gob3BlcmF0aW9uTW9kZSkgeworICAgICAgICAgICAgY2FzZSBDQU1FUkFfU1RSRUFNX0NPTkZJR1VSQVRJT05fTk9STUFMX01PREU6CisgICAgICAgICAgICAgICAgKm1vZGUgPSBTdHJlYW1Db25maWd1cmF0aW9uTW9kZTo6Tk9STUFMX01PREU7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIENBTUVSQV9TVFJFQU1fQ09ORklHVVJBVElPTl9DT05TVFJBSU5FRF9ISUdIX1NQRUVEX01PREU6CisgICAgICAgICAgICAgICAgKm1vZGUgPSBTdHJlYW1Db25maWd1cmF0aW9uTW9kZTo6Q09OU1RSQUlORURfSElHSF9TUEVFRF9NT0RFOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgZGVmYXVsdDoKKyAgICA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ZXZpY2U6OmluaXRpYWxpemUoc3A8Q2FtZXJhUHJvdmlkZXJNYW5hZ2VyPiBtYW5hZ2VyLAorICAgICAgICBjb25zdCBTdHJpbmc4JiBtb25pdG9yVGFncykgeworICAgIEFUUkFDRV9DQUxMKCk7CisgICAgTXV0ZXg6OkF1dG9sb2NrIGlsKG1JbnRlcmZhY2VMb2NrKTsKKyAgICBNdXRleDo6QXV0b2xvY2sgbChtTG9jayk7CisKKyAgICBBTE9HVigiJXM6IEluaXRpYWxpemluZyBISURMIGRldmljZSBmb3IgY2FtZXJhICVzIiwgX19GVU5DVElPTl9fLCBtSWQuc3RyaW5nKCkpOworICAgIGlmIChtU3RhdHVzICE9IFNUQVRVU19VTklOSVRJQUxJWkVEKSB7CisgICAgICAgIENMT0dFKCJBbHJlYWR5IGluaXRpYWxpemVkISIpOworICAgICAgICByZXR1cm4gSU5WQUxJRF9PUEVSQVRJT047CisgICAgfQorICAgIGlmIChtYW5hZ2VyID09IG51bGxwdHIpIHJldHVybiBJTlZBTElEX09QRVJBVElPTjsKKworICAgIHNwPElDYW1lcmFEZXZpY2VTZXNzaW9uPiBzZXNzaW9uOworICAgIEFUUkFDRV9CRUdJTigiQ2FtZXJhSGFsOjpvcGVuU2Vzc2lvbiIpOworICAgIHN0YXR1c190IHJlcyA9IG1hbmFnZXItPm9wZW5IaWRsU2Vzc2lvbihtSWQuc3RyaW5nKCksIHRoaXMsCisgICAgICAgICAgICAvKm91dCovICZzZXNzaW9uKTsKKyAgICBBVFJBQ0VfRU5EKCk7CisgICAgaWYgKHJlcyAhPSBPSykgeworICAgICAgICBTRVRfRVJSX0woIkNvdWxkIG5vdCBvcGVuIGNhbWVyYSBzZXNzaW9uOiAlcyAoJWQpIiwgc3RyZXJyb3IoLXJlcyksIHJlcyk7CisgICAgICAgIHJldHVybiByZXM7CisgICAgfQorCisgICAgcmVzID0gbWFuYWdlci0+Z2V0Q2FtZXJhQ2hhcmFjdGVyaXN0aWNzKG1JZC5zdHJpbmcoKSwgbU92ZXJyaWRlRm9yUGVyZkNsYXNzLCAmbURldmljZUluZm8pOworICAgIGlmIChyZXMgIT0gT0spIHsKKyAgICAgICAgU0VUX0VSUl9MKCJDb3VsZCBub3QgcmV0cmlldmUgY2FtZXJhIGNoYXJhY3RlcmlzdGljczogJXMgKCVkKSIsIHN0cmVycm9yKC1yZXMpLCByZXMpOworICAgICAgICBzZXNzaW9uLT5jbG9zZSgpOworICAgICAgICByZXR1cm4gcmVzOworICAgIH0KKyAgICBtU3VwcG9ydE5hdGl2ZVpvb21SYXRpbyA9IG1hbmFnZXItPnN1cHBvcnROYXRpdmVab29tUmF0aW8obUlkLnN0cmluZygpKTsKKworICAgIHN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPiBwaHlzaWNhbENhbWVyYUlkczsKKyAgICBib29sIGlzTG9naWNhbCA9IG1hbmFnZXItPmlzTG9naWNhbENhbWVyYShtSWQuc3RyaW5nKCksICZwaHlzaWNhbENhbWVyYUlkcyk7CisgICAgaWYgKGlzTG9naWNhbCkgeworICAgICAgICBmb3IgKGF1dG8mIHBoeXNpY2FsSWQgOiBwaHlzaWNhbENhbWVyYUlkcykgeworICAgICAgICAgICAgLy8gRG8gbm90IG92ZXJyaWRlIGNoYXJhY3RlcmlzdGljcyBmb3IgcGh5c2ljYWwgY2FtZXJhcworICAgICAgICAgICAgcmVzID0gbWFuYWdlci0+Z2V0Q2FtZXJhQ2hhcmFjdGVyaXN0aWNzKAorICAgICAgICAgICAgICAgICAgICBwaHlzaWNhbElkLCAvKm92ZXJyaWRlRm9yUGVyZkNsYXNzKi9mYWxzZSwgJm1QaHlzaWNhbERldmljZUluZm9NYXBbcGh5c2ljYWxJZF0pOworICAgICAgICAgICAgaWYgKHJlcyAhPSBPSykgeworICAgICAgICAgICAgICAgIFNFVF9FUlJfTCgiQ291bGQgbm90IHJldHJpZXZlIGNhbWVyYSAlcyBjaGFyYWN0ZXJpc3RpY3M6ICVzICglZCkiLAorICAgICAgICAgICAgICAgICAgICAgICAgcGh5c2ljYWxJZC5jX3N0cigpLCBzdHJlcnJvcigtcmVzKSwgcmVzKTsKKyAgICAgICAgICAgICAgICBzZXNzaW9uLT5jbG9zZSgpOworICAgICAgICAgICAgICAgIHJldHVybiByZXM7CisgICAgICAgICAgICB9CisKKyAgICAgICAgICAgIGJvb2wgdXNlUHJlY29ycmVjdEFycmF5ID0KKyAgICAgICAgICAgICAgICAgICAgRGlzdG9ydGlvbk1hcHBlcjo6aXNEaXN0b3J0aW9uU3VwcG9ydGVkKG1QaHlzaWNhbERldmljZUluZm9NYXBbcGh5c2ljYWxJZF0pOworICAgICAgICAgICAgaWYgKHVzZVByZWNvcnJlY3RBcnJheSkgeworICAgICAgICAgICAgICAgIHJlcyA9IG1EaXN0b3J0aW9uTWFwcGVyc1twaHlzaWNhbElkXS5zZXR1cFN0YXRpY0luZm8oCisgICAgICAgICAgICAgICAgICAgICAgICBtUGh5c2ljYWxEZXZpY2VJbmZvTWFwW3BoeXNpY2FsSWRdKTsKKyAgICAgICAgICAgICAgICBpZiAocmVzICE9IE9LKSB7CisgICAgICAgICAgICAgICAgICAgIFNFVF9FUlJfTCgiVW5hYmxlIHRvIHJlYWQgY2FtZXJhICVzJ3MgY2FsaWJyYXRpb24gZmllbGRzIGZvciBkaXN0b3J0aW9uICIKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAiY29ycmVjdGlvbiIsIHBoeXNpY2FsSWQuY19zdHIoKSk7CisgICAgICAgICAgICAgICAgICAgIHNlc3Npb24tPmNsb3NlKCk7CisgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXM7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorCisgICAgICAgICAgICBtWm9vbVJhdGlvTWFwcGVyc1twaHlzaWNhbElkXSA9IFpvb21SYXRpb01hcHBlcigKKyAgICAgICAgICAgICAgICAgICAgJm1QaHlzaWNhbERldmljZUluZm9NYXBbcGh5c2ljYWxJZF0sCisgICAgICAgICAgICAgICAgICA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KKyAgICAgICAgfSk7CisgICAgaWYgKCFyZXN1bHRRdWV1ZVJldC5pc09rKCkpIHsKKyAgICAgICAgQUxPR0UoIlRyYW5zYWN0aW9uIGVycm9yIHdoZW4gZ2V0dGluZyByZXN1bHQgbWV0YWRhdGEgcXVldWUgZnJvbSBjYW1lcmEgc2Vzc2lvbjogJXMiLAorICAgICAgICAgICAgICAgIHJlc3VsdFF1ZXVlUmV0LmRlc2NyaXB0aW9uKCkuY19zdHIoKSk7CisgICAgICAgIHJldHVybiBERUFEX09CSkVDVDsKKyAgICB9CisgICAgSUZfQUxPR1YoKSB7CisgICAgICAgIHNlc3Npb24tPmludGVyZmFjZUNoYWluKFtdKAorICAgICAgICAgICAgOjphbmRyb2lkOjpoYXJkd2FyZTo6aGlkbF92ZWM8OjphbmRyb2lkOjpoYXJkd2FyZTo6aGlkbF9zdHJpbmc+IGludGVyZmFjZUNoYWluKSB7CisgICAgICAgICAgICAgICAgQUxPR1YoIlNlc3Npb24gaW50ZXJmYWNlIGNoYWluOiIpOworICAgICAgICAgICAgICAgIGZvciAoY29uc3QgYXV0byYgaWZhY2UgOiBpbnRlcmZhY2VDaGFpbikgeworICAgICAgICAgICAgICAgICAgICBBTE9HVigiICAlcyIsIGlmYWNlLmNfc3RyKCkpOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0pOworICAgIH0KKworICAgIGNhbWVyYV9tZXRhZGF0YV9lbnRyeSBidWZNZ3JNb2RlID0KKyAgICAgICAgICAgIG1EZXZpY2VJbmZvLmZpbmQoQU5EUk9JRF9JTkZPX1NVUFBPUlRFRF9CVUZGRVJfTUFOQUdFTUVOVF9WRVJTSU9OKTsKKyAgICBpZiAoYnVmTWdyTW9kZS5jb3VudCA+IDApIHsKKyAgICAgICAgIG1Vc2VIYWxCdWZNYW5hZ2VyID0gKGJ1Zk1nck1vZGUuZGF0YS51OFswXSA9PQorICAgICAgICAgICAgQU5EUk9JRF9JTkZPX1NVUFBPUlRFRF9CVUZGRV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NhdGlvbkxpc3RlbmVyPiBsaXN0ZW5lcjsKKyAgICB7CisgICAgICAgIHN0ZDo6bG9ja19ndWFyZDxzdGQ6Om11dGV4PiBsKG1PdXRwdXRMb2NrKTsKKyAgICAgICAgbGlzdGVuZXIgPSBtTGlzdGVuZXIucHJvbW90ZSgpOworICAgIH0KKworICAgIGlmIChtUHJvY2Vzc0NhcHR1cmVSZXN1bHRMb2NrLnRyeUxvY2soKSAhPSBPSykgeworICAgICAgICAvLyBUaGlzIHNob3VsZCBuZXZlciBoYXBwZW47IGl0IGluZGljYXRlcyBhIHdyb25nIGNsaWVudCBpbXBsZW1lbnRhdGlvbgorICAgICAgICAvLyB0aGF0IGRvZXNuJ3QgZm9sbG93IHRoZSBjb250cmFjdC4gQnV0LCB3ZSBjYW4gYmUgdG9sZXJhbnQgaGVyZS4KKyAgICAgICAgQUxPR0UoIiVzOiBjYWxsYmFjayBvdmVybGFwcGVkISB3YWl0aW5nIDFzLi4uIiwKKyAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18pOworICAgICAgICBpZiAobVByb2Nlc3NDYXB0dXJlUmVzdWx0TG9jay50aW1lZExvY2soMTAwMDAwMDAwMCAvKiAxcyAqLykgIT0gT0spIHsKKyAgICAgICAgICAgIEFMT0dFKCIlczogY2Fubm90IGFjcXVpcmUgbG9jayBpbiAxcywgZHJvcHBpbmcgcmVzdWx0cyIsCisgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXyk7CisgICAgICAgICAgICAvLyByZWFsbHkgZG9uJ3Qga25vdyB3aGF0IHRvIGRvLCBzbyBiYWlsIG91dC4KKyAgICAgICAgICAgIHJldHVybiBoYXJkd2FyZTo6Vm9pZCgpOworICAgICAgICB9CisgICAgfQorICAgIEhpZGxDYXB0dXJlT3V0cHV0U3RhdGVzIHN0YXRlcyB7CisgICAgICAgeworICAgICAgICBtSWQsCisgICAgICAgIG1JbkZsaWdodExvY2ssIG1MYXN0Q29tcGxldGVkUmVndWxhckZyYW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hfYmFjayhtSW5wdXRTdHJlYW0tPmdldElkKCkpOworICAgIH0KKworICAgIC8vIENoZWNrIGFsbCBzdHJlYW1zIGluIHN0cmVhbXNUb0tlZXAgc3VwcG9ydHMgb2ZmbGluZSBtb2RlCisgICAgZm9yIChhdXRvIGlkIDogc3RyZWFtc1RvS2VlcCkgeworICAgICAgICBpZiAoc3RkOjpmaW5kKHN0cmVhbUlkcy5iZWdpbigpLCBzdHJlYW1JZHMuZW5kKCksIGlkKSA9PSBzdHJlYW1JZHMuZW5kKCkpIHsKKyAgICAgICAgICAgIEFMT0dFKCIlczogVW5rbm93biBzdHJlYW0gSUQgJWQiLCBfX0ZVTkNUSU9OX18sIGlkKTsKKyAgICAgICAgICAgIHJldHVybiBCQURfVkFMVUU7CisgICAgICAgIH0gZWxzZSBpZiAoaWQgPT0gaW5wdXRTdHJlYW1JZCkgeworICAgICAgICAgICAgaWYgKCFpbnB1dFN0cmVhbVN1cHBvcnRzT2ZmbGluZSkgeworICAgICAgICAgICAgICAgIEFMT0dFKCIlczogaW5wdXQgc3RyZWFtICVkIGNhbm5vdCBiZSBzd2l0Y2hlZCB0byBvZmZsaW5lIiwKKyAgICAgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgaWQpOworICAgICAgICAgICAgICAgIHJldHVybiBCQURfVkFMVUU7CisgICAgICAgICAgICB9CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICBzcDxjYW1lcmEzOjpDYW1lcmEzT3V0cHV0U3RyZWFtSW50ZXJmYWNlPiBzdHJlYW0gPSBtT3V0cHV0U3RyZWFtcy5nZXQoaWQpOworICAgICAgICAgICAgaWYgKCFzdHJlYW0tPmdldE9mZmxpbmVQcm9jZXNzaW5nU3VwcG9ydCgpKSB7CisgICAgICAgICAgICAgICAgQUxPR0UoIiVzOiBvdXRwdXQgc3RyZWFtICVkIGNhbm5vdCBiZSBzd2l0Y2hlZCB0byBvZmZsaW5lIiwKKyAgICAgICAgICAgICAgICAgICA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X21ldGFkYXRhKHIpOworICAgICAgICAgICAgICAgICAgICBpZiAoKnJlcXVlc3RUZW1wbGF0ZSA9PSBudWxscHRyKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IFVuYWJsZSB0byBjbG9uZSBjYW1lcmEgbWV0YWRhdGEgcmVjZWl2ZWQgZnJvbSBIQUwiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfX0ZVTkNUSU9OX18pOworICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzID0gY29tbW9uOjpWMV8wOjpTdGF0dXM6OklOVEVSTkFMX0VSUk9SOworICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgQUxPR0UoIiVzOiBNYWxmb3JtZWQgY2FtZXJhIG1ldGFkYXRhIHJlY2VpdmVkIGZyb20gSEFMIiwgX19GVU5DVElPTl9fKTsKKyAgICAgICAgICAgICAgICAgICAgc3RhdHVzID0gY29tbW9uOjpWMV8wOjpTdGF0dXM6OklOVEVSTkFMX0VSUk9SOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0KKyAgICAgICAgfTsKKyAgICBoYXJkd2FyZTo6UmV0dXJuPHZvaWQ+IGVycjsKKyAgICBSZXF1ZXN0VGVtcGxhdGUgaWQ7CisgICAgc3dpdGNoICh0ZW1wbGF0ZUlkKSB7CisgICAgICAgIGNhc2UgQ0FNRVJBX1RFTVBMQVRFX1BSRVZJRVc6CisgICAgICAgICAgICBpZCA9IFJlcXVlc3RUZW1wbGF0ZTo6UFJFVklFVzsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIENBTUVSQV9URU1QTEFURV9TVElMTF9DQVBUVVJFOgorICAgICAgICAgICAgaWQgPSBSZXF1ZXN0VGVtcGxhdGU6OlNUSUxMX0NBUFRVUkU7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBDQU1FUkFfVEVNUExBVEVfVklERU9fUkVDT1JEOgorICAgICAgICAgICAgaWQgPSBSZXF1ZXN0VGVtcGxhdGU6OlZJREVPX1JFQ09SRDsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIENBTUVSQV9URU1QTEFURV9WSURFT19TTkFQU0hPVDoKKyAgICAgICAgICAgIGlkID0gUmVxdWVzdFRlbXBsYXRlOjpWSURFT19TTkFQU0hPVDsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIENBTUVSQV9URU1QTEFURV9aRVJPX1NIVVRURVJfTEFHOgorICAgICAgICAgICAgaWQgPSBSZXF1ZXN0VGVtcGxhdGU6OlpFUk9fU0hVVFRFUl9MQUc7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBDQU1FUkFfVEVNUExBVEVfTUFOVUFMOgorICAgICAgICAgICAgaWQgPSBSZXF1ZXN0VGVtcGxhdGU6Ok1BTlVBTDsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgLy8gVW5rbm93biB0ZW1wbGF0ZSBJRCwgb3IgdGhpcyBIQUwgaXMgdG9vIG9sZCB0byBzdXBwb3J0IGl0CisgICAgICAgICAgICByZXR1cm4gQkFEX1ZBTFVFOworICAgIH0KKyAgICBlcnIgPSBtSGlkbFNlc3Npb24tPmNvbnN0cnVjdERlZmF1bHRSZXF1ZXN0U2V0dGluZ3MoaWQsIHJlcXVlc3RDYWxsYmFjayk7CisKKyAgICBpZiAoIWVyci5pc09rKCkpIHsKKyAgICAgICAgQUxPR0UoIiVzOiBUcmFuc2FjdGlvbiBlcnJvcjogJXMiLCBfX0ZVTkNUSU9OX18sIGVyci5kZXNjcmlwdGlvbigpLmNfc3RyKCkpOworICAgICAgICByZXMgPSBERUFEX09CSkVDVDsKKyAgICB9IGVsc2UgeworICAgICAgICByZXMgPSBIaWRsUHJvdmlkZXJJbmZvOjptYXBUb1N0YXR1c1Qoc3RhdHVzKTsK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q8dWludDhfdCo+KG5ld1Nlc3Npb01ldGEpLAorICAgICAgICAgICAgICAgIGdldF9jYW1lcmFfbWV0YWRhdGFfc2l6ZShuZXdTZXNzaW9NZXRhKSk7CisgICAgICAgIGhhcmR3YXJlOjpjYW1lcmE6OmNvbW1vbjo6VjFfMDo6U3RhdHVzIGNhbGxTdGF0dXM7CisgICAgICAgIGJvb2wgcmVxdWlyZWQ7CisgICAgICAgIGF1dG8gaGlkbENiID0gWyZjYWxsU3RhdHVzLCAmcmVxdWlyZWRdIChoYXJkd2FyZTo6Y2FtZXJhOjpjb21tb246OlYxXzA6OlN0YXR1cyBzLAorICAgICAgICAgICAgICAgIGJvb2wgcmVxdWlyZWRGbGFnKSB7CisgICAgICAgICAgICBjYWxsU3RhdHVzID0gczsKKyAgICAgICAgICAgIHJlcXVpcmVkID0gcmVxdWlyZWRGbGFnOworICAgICAgICB9OworICAgICAgICBhdXRvIGVyciA9IG1IaWRsU2Vzc2lvbl8zXzUtPmlzUmVjb25maWd1cmF0aW9uUmVxdWlyZWQob2xkUGFyYW1zLCBuZXdQYXJhbXMsIGhpZGxDYik7CisgICAgICAgIG9sZFNlc3Npb25QYXJhbXMudW5sb2NrKG9sZFNlc3Npb01ldGEpOworICAgICAgICBuZXdTZXNzaW9uUGFyYW1zLnVubG9jayhuZXdTZXNzaW9NZXRhKTsKKyAgICAgICAgaWYgKGVyci5pc09rKCkpIHsKKyAgICAgICAgICAgIHN3aXRjaCAoY2FsbFN0YXR1cykgeworICAgICAgICAgICAgICAgIGNhc2UgaGFyZHdhcmU6OmNhbWVyYTo6Y29tbW9uOjpWMV8wOjpTdGF0dXM6Ok9LOgorICAgICAgICAgICAgICAgICAgICByZXQgPSByZXF1aXJlZDsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSBoYXJkd2FyZTo6Y2FtZXJhOjpjb21tb246OlYxXzA6OlN0YXR1czo6TUVUSE9EX05PVF9TVVBQT1JURUQ6CisgICAgICAgICAgICAgICAgICAgIG1Jc1JlY29uZmlndXJhdGlvblF1ZXJ5U3VwcG9ydGVkID0gZmFsc2U7CisgICAgICAgICAgICAgICAgICAgIHJldCA9IHRydWU7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgICAgIEFMT0dWKCIlczogUmVjb25maWd1cmF0aW9uIHF1ZXJ5IGZhaWxlZDogJWQiLCBfX0ZVTkNUSU9OX18sIGNhbGxTdGF0dXMpOworICAgICAgICAgICAgICAgICAgICByZXQgPSB0cnVlOworICAgICAgICAgICAgfQorICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgQUxPR0UoIiVzOiBVbmV4cGVjdGVkIGJpbmRlciBlcnJvcjogJXMiLCBfX0ZVTkNUSU9OX18sIGVyci5kZXNjcmlwdGlvbigpLmNfc3RyKCkpOworICAgICAgICAgICAgcmV0ID0gdHJ1ZTsKKyAgICAgICAgfQorICAgIH0KKworICAgIHJldHVybiByZXQ7Cit9CisKK3N0YXR1c190IEhpZGxDYW1lcmEzRGV2aWNlOjpIaWRsSGFsSW50ZXJmYWNlOjpjb25maWd1cmVTdHJlYW1zKAorICAgICAgICBjb25zdCBjYW1lcmFfbWV0YWRhdGFfdCAqc2Vzc2lvblBhcmFtcywKKyAgICAgICAgY2FtZXJhX3N0cmVhbV9jb25maWd1cmF0aW9uICpjb25maWcsIGNvbnN0IHN0ZDo6dmVjdG9yPHVpbnQzMl90PiYgYnVmZmVyU2l6ZXMpIHsKKyAgICBBVFJBQ0VfTkFNRSgiQ2FtZXJhSGFsOjpjb25maWd1cmVTdHJlYW1zIik7CisgICAgaWYgKCF2YWxpZCgpKSByZXR1cm4gSU5WQUxJRF9PUEVSQVRJT047CisgICAgc3RhdHVzX3QgcmVzID0gT0s7CisKKyAgICBpZiAoY29uZmlnLT5pbnB1dF9pc19tdWx0aV9yZXNvbHV0aW9uICYmIG1IaWRsU2Vzc2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hdGlvbjNfNC5zdHJlYW1zW2ldOworICAgICAgICBkZXZpY2U6OlYzXzc6OlN0cmVhbSAmZHN0M183ID0gcmVxdWVzdGVkQ29uZmlndXJhdGlvbjNfNy5zdHJlYW1zW2ldOworICAgICAgICBjYW1lcmEzOjpjYW1lcmFfc3RyZWFtX3QgKnNyYyA9IGNvbmZpZy0+c3RyZWFtc1tpXTsKKworICAgICAgICBDYW1lcmEzU3RyZWFtKiBjYW0zc3RyZWFtID0gQ2FtZXJhM1N0cmVhbTo6Y2FzdChzcmMpOworICAgICAgICBjYW0zc3RyZWFtLT5zZXRCdWZmZXJGcmVlZExpc3RlbmVyKHRoaXMpOworICAgICAgICBpbnQgc3RyZWFtSWQgPSBjYW0zc3RyZWFtLT5nZXRJZCgpOworICAgICAgICBTdHJlYW1UeXBlIHN0cmVhbVR5cGU7CisgICAgICAgIHN3aXRjaCAoc3JjLT5zdHJlYW1fdHlwZSkgeworICAgICAgICAgICAgY2FzZSBDQU1FUkFfU1RSRUFNX09VVFBVVDoKKyAgICAgICAgICAgICAgICBzdHJlYW1UeXBlID0gU3RyZWFtVHlwZTo6T1VUUFVUOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBDQU1FUkFfU1RSRUFNX0lOUFVUOgorICAgICAgICAgICAgICAgIHN0cmVhbVR5cGUgPSBTdHJlYW1UeXBlOjpJTlBVVDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgQUxPR0UoIiVzOiBTdHJlYW0gJWQ6IFVuc3VwcG9ydGVkIHN0cmVhbSB0eXBlICVkIiwKKyAgICAgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgc3RyZWFtSWQsIGNvbmZpZy0+c3RyZWFtc1tpXS0+c3RyZWFtX3R5cGUpOworICAgICAgICAgICAgICAgIHJldHVybiBCQURfVkFMVUU7CisgICAgICAgIH0KKyAgICAgICAgZHN0M18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cmVhbXMKKyAgICBkZXZpY2U6OlYzXzM6OkhhbFN0cmVhbUNvbmZpZ3VyYXRpb24gZmluYWxDb25maWd1cmF0aW9uOworICAgIGRldmljZTo6VjNfNDo6SGFsU3RyZWFtQ29uZmlndXJhdGlvbiBmaW5hbENvbmZpZ3VyYXRpb24zXzQ7CisgICAgZGV2aWNlOjpWM182OjpIYWxTdHJlYW1Db25maWd1cmF0aW9uIGZpbmFsQ29uZmlndXJhdGlvbjNfNjsKKyAgICBjb21tb246OlYxXzA6OlN0YXR1cyBzdGF0dXM7CisKKyAgICBhdXRvIGNvbmZpZ1N0cmVhbTM0Q2IgPSBbJnN0YXR1cywgJmZpbmFsQ29uZmlndXJhdGlvbjNfNF0KKyAgICAgICAgICAgIChjb21tb246OlYxXzA6OlN0YXR1cyBzLCBjb25zdCBkZXZpY2U6OlYzXzQ6OkhhbFN0cmVhbUNvbmZpZ3VyYXRpb24mIGhhbENvbmZpZ3VyYXRpb24pIHsKKyAgICAgICAgICAgICAgICBmaW5hbENvbmZpZ3VyYXRpb24zXzQgPSBoYWxDb25maWd1cmF0aW9uOworICAgICAgICAgICAgICAgIHN0YXR1cyA9IHM7CisgICAgICAgICAgICB9OworCisgICAgYXV0byBjb25maWdTdHJlYW0zNkNiID0gWyZzdGF0dXMsICZmaW5hbENvbmZpZ3VyYXRpb24zXzZdCisgICAgICAgICAgICAoY29tbW9uOjpWMV8wOjpTdGF0dXMgcywgY29uc3QgZGV2aWNlOjpWM182OjpIYWxTdHJlYW1Db25maWd1cmF0aW9uJiBoYWxDb25maWd1cmF0aW9uKSB7CisgICAgICAgICAgICAgICAgZmluYWxDb25maWd1cmF0aW9uM182ID0gaGFsQ29uZmlndXJhdGlvbjsKKyAgICAgICAgICAgICAgICBzdGF0dXMgPSBzOworICAgICAgICAgICAgfTsKKworICAgIGF1dG8gcG9zdHByb2NDb25maWdTdHJlYW0zNCA9IFsmZmluYWxDb25maWd1cmF0aW9uLCAmZmluYWxDb25maWd1cmF0aW9uM180XQorICAgICAgICAgICAgKGhhcmR3YXJlOjpSZXR1cm48dm9pZD4mIGVycikgLT4gc3RhdHVzX3QgeworICAgICAgICAgICAgICAgIGlmICghZXJyLmlzT2soKSkgeworICAgICAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IFRyYW5zYWN0aW9uIGVycm9yOiAlcyIsIF9fRlVOQ1RJT05fXywgZXJyLmRlc2NyaXB0aW9uKCkuY19zdHIoKSk7CisgICAgICAgICAgICAgICAgICAgIHJldHVybiBERUFEX09CSkVDVDsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgZmluYWxDb25maWd1cmF0aW9uLnN0cmVhbXMucmVzaXplKGZpbmFsQ29uZmlndXJhdGlvbjNfNC5zdHJlYW1zLnNpemUoKSk7CisgICAgICAgICAgICAgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCBmaW5hbENvbmZpZ3VyYXRpb24zXzQuc3RyZWFtcy5zaXplKCk7IGkrKykgeworICAgICAgICAgICAgICAgICAgICBmaW5hbENvbmZpZ3VyYXRpb24uc3RyZWFtc1tpXSA9IGZpbmFsQ29uZmlndXJhdGlvbjNfNC5zdHJlYW1zW2ldLnYzXzM7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIHJldHVybiBPSzsKKyAgICAgICAgICAgIH07CisKKyAgICBhdXRvIHBvc3Rwcm9jQ29uZmlnU3RyZWFtMzYgPSBbJmZpbmFsQ29uZmlndXJhdGlvbiwgJmZpbmFsQ29uZmlndXJhdGlvbjNfNl0KKyAgICAgICAgICAgIChoYXJkd2FyZTo6UmV0dXJuPHZvaWQ+JiBlcnIpIC0+IHN0YXR1c190IHsKKyAgICAgICAgICAgICAgICBpZiAoIWVyci5pc09rKCkpIHsKKyAgICAgICAgICAgICAgICAgICAgQUxPR0UoIiVzOiBUcmFuc2FjdGlvbiBlcnJvcjogJXMiLCBfX0ZVTkNUSU9OX18sIGVyci5kZXNjcmlwdGlvbigpLmNfc3RyKCkpOworICAgICAgICAgICAgICAgICAgICByZXR1cm4gREVBRF9PQkpFQ1Q7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGZpbmFsQ29uZmlndXJhdGlvbi5zdHJlYW1zLnJlc2l6ZShmaW5hbENvbmZpZ3VyYXRpb24zXzYuc3RyZWFtcy5zaXplKCkpOworICAgICAgICAgICAgICAgIGZvciAoc2l6ZV90IGkgPSAwOyBpIDwgZmluYWxDb25maWd1cmF0aW9uM182LnN0cmVhbXMuc2l6ZSgpOyBpKyspIHsKKyAgICAgICAgICAgICAgICAgICAgZmluYWxDb25maWd1cmF0aW9uLnN0cmVhbXNbaV0gPSBmaW5hbENvbmZpZ3VyYXRpb24zXzYuc3RyZWFtc1tpXS52M180LnYzXzM7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIHJldHVybiBPSzsKKyAgICAgICAgICAgIH07CisKKyAgICBpZiAobUhpZGxTZXNzaW9uXzNfNyAhPSBudWxscHRyKSB7CisgICAgICAgIEFMT0dWKCIlczogdjMuNyBkZXZpY2UgZm91bmQiLCBfX0ZVTkNUSU9OX18pOworICAgICAgICByZXF1ZXN0ZWRDb25maWd1cmF0aW9uM183LnN0cmVhbUNvbmZpZ0NvdW50ZXIgPSBtTmV4dFN0cmVhbUNvbmZpZ0NvdW50ZXIrKzsKKyAgICAgICAgcmVxdWVzdGVkQ29uZmlndXJhdGlvbjNfNy5tdWx0aVJlc29sdXRpb25JbnB1dEltYWdlID0gY29uZmlnLT5pbnB1dF9pc19tdWx0aV9yZXNvbHV0aW9uOworICAgICAgICBhdXRvIGVyciA9IG1IaWRsU2Vzc2lvbl8zXzctPmNvbmZpZ3VyZVN0cmVhbXNfM183KAorICAgICAgICAgICAgICAgIHJlcXVlc3RlZENvbmZpZ3VyYXRpb24zXzcsIGNvbmZpZ1N0cmVhbTM2Q2IpOworICAgICAgICByZXMgPSBwb3N0cHJvY0NvbmZpZ1N0cmVhbTM2KGVycik7CisgICAgICAgIGlmIChy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ICBhdXRvIGVyciA9IG1IaWRsU2Vzc2lvbl8zXzMtPmNvbmZpZ3VyZVN0cmVhbXNfM18zKHJlcXVlc3RlZENvbmZpZ3VyYXRpb24zXzIsCisgICAgICAgICAgICBbJnN0YXR1cywgJmZpbmFsQ29uZmlndXJhdGlvbl0KKyAgICAgICAgICAgIChjb21tb246OlYxXzA6OlN0YXR1cyBzLCBjb25zdCBkZXZpY2U6OlYzXzM6OkhhbFN0cmVhbUNvbmZpZ3VyYXRpb24mIGhhbENvbmZpZ3VyYXRpb24pIHsKKyAgICAgICAgICAgICAgICBmaW5hbENvbmZpZ3VyYXRpb24gPSBoYWxDb25maWd1cmF0aW9uOworICAgICAgICAgICAgICAgIHN0YXR1cyA9IHM7CisgICAgICAgICAgICB9KTsKKyAgICAgICAgaWYgKCFlcnIuaXNPaygpKSB7CisgICAgICAgICAgICBBTE9HRSgiJXM6IFRyYW5zYWN0aW9uIGVycm9yOiAlcyIsIF9fRlVOQ1RJT05fXywgZXJyLmRlc2NyaXB0aW9uKCkuY19zdHIoKSk7CisgICAgICAgICAgICByZXR1cm4gREVBRF9PQkpFQ1Q7CisgICAgICAgIH0KKyAgICB9IGVsc2UgeworICAgICAgICAvLyBXZSBkb24ndDsgdXNlIHYzLjIgY2FsbCBhbmQgY29uc3RydWN0IGEgdjMuMyBIYWxTdHJlYW1Db25maWd1cmF0aW9uCisgICAgICAgIEFMT0dWKCIlczogdjMuMiBkZXZpY2UgZm91bmQiLCBfX0ZVTkNUSU9OX18pOworICAgICAgICBIYWxTdHJlYW1Db25maWd1cmF0aW9uIGZpbmFsQ29uZmlndXJhdGlvbl8zXzI7CisgICAgICAgIGF1dG8gZXJyID0gbUhpZGxTZXNzaW9uLT5jb25maWd1cmVTdHJlYW1zKHJlcXVlc3RlZENvbmZpZ3VyYXRpb24zXzIsCisgICAgICAgICAgICAgICAgWyZzdGF0dXMsICZmaW5hbENvbmZpZ3VyYXRpb25fM18yXQorICAgICAgICAgICAgICAgIChjb21tb246OlYxXzA6OlN0YXR1cyBzLCBjb25zdCBIYWxTdHJlYW1Db25maWd1cmF0aW9uJiBoYWxDb25maWd1cmF0aW9uKSB7CisgICAgICAgICAgICAgICAgICAgIGZpbmFsQ29uZmlndXJhdGlvbl8zXzIgPSBoYWxDb25maWd1cmF0aW9uOworICAgICAgICAgICAgICAgICAgICBzdGF0dXMgPSBzOworICAgICAgICAgICAgICAgIH0pOworICAgICAgICBpZiAoIWVyci5pc09rKCkpIHsKKyAgICAgICAgICAgIEFMT0dFKCIlczogVHJhbnNhY3Rpb24gZXJyb3I6ICVzIiwgX19GVU5DVElPTl9fLCBlcnIuZGVzY3JpcHRpb24oKS5jX3N0cigpKTsKKyAgICAgICAgICAgIHJldHVybiBERUFEX09CSkVDVDsKKyAgICAgICAgfQorICAgICAgICBmaW5hbENvbmZpZ3VyYXRpb24uc3RyZWFtcy5yZXNpemUoZmluYWxDb25maWd1cmF0aW9uXzNfMi5zdHJlYW1zLnNpemUoKSk7CisgICAgICAgIGZvciAoc2l6ZV90IGkgPSAwOyBpIDwgZmluYWxDb25maWd1cmF0aW9uXzNfMi5zdHJlYW1zLnNpemUoKTsgaSsrKSB7CisgICAgICAgICAgICBmaW5hbENvbmZpZ3VyYXRpb24uc3RyZWFtc1tpXS52M18yID0gZmluYWxDb25maWd1cmF0aW9uXzNfMi5zdHJlYW1zW2ldOworICAgICAgICAgICAgZmluYWxDb25maWd1cmF0aW9uLnN0cmVhbXNbaV0ub3ZlcnJpZGVEYXRhU3BhY2UgPQorICAgICAgICAgICAgICAgICAgICByZXF1ZXN0ZWRDb25maWd1cmF0aW9uM18yLnN0cmVhbXNbaV0uZGF0YVNwYWNlOworICAgICAgICB9CisgICAgfQorCisgICAgaWYgKHN0YXR1cyAhPSBjb21tb246OlYxXzA6OlN0YXR1czo6T0sgKSB7CisgICAgICAgIHJldHVybiBIaWRsUHJvdmlkZXJJbmZvOjptYXBUb1N0YXR1c1Qoc3RhdHVzKTsKKyAgICB9CisKKyAgICAvLyBBbmQgY29udmVydCBvdXRwdXQgc3RyZWFtIGNvbmZpZ3VyYXRpb24gZnJvbSBISURMCisKKyAgICBmb3IgKHNpemVfdCBpID0gMDsgaSA8IGNvbmZpZy0+bnVtX3N0cmVhbXM7IGkrKykgeworICAgICAgICBjYW1lcmEzOjpjYW1lcmFfc3RyZWFtX3QgKmRzdCA9IGNvbmZpZy0+c3RyZWFtc1tpXTsKKyAgICAgICAgaW50IHN0cmVhbUlkID0gQ2FtZXJhM1N0cmVhbTo6Y2FzdChkc3QpLT5nZXRJZCgpOworCisgICAgICAgIC8vIFN0YXJ0IHNjYW4gYXQgaSwgd2l0aCB0aGUgYXNzdW1wdGlvbiB0aGF0IHRoZSBzdHJlYW0gb3JkZXIgbWF0Y2hlcworICAgICAgICBzaXplX3QgcmVhbElkeCA9IGk7CisgICAgICAgIGJvb2wgZm91bmQgPSBmYWxzZTsKKyAgICAgICAgc2l6ZV90IGhhbFN0cmVhbUNvdW50ID0gZmluYWxDb25maWd1cmF0aW9uLnN0cmVhbXMuc2l6ZSgpOworICAgICAgICBmb3IgKHNpemVfdCBpZHggPSAwOyBpZHggPCBoYWxTdHJlYW1Db3VudDsgaWR4KyspIHsKKyAgICAgICAgICAgIGlmIChmaW5hbENvbmZpZ3VyYXRpb24uc3RyZWFtc1tyZWFsSWR4XS52M18yLmlkID09IHN0cmVhbUlkKSB7CisgICAgICAgICAgICAgICAgZm91bmQgPSB0cnVlOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgfQorICAgICAgICAgICAgcmVhbElkeCA9IChyZWFsSWR4ID49IGhhbFN0cmVhbUNvdW50IC0gMSkgPyAwIDogcmVhbElkeCArIDE7CisgICAgICAgIH0KKyAgICAgICAgaWYgKCFmb3VuZCkgeworICAgICAgICAgICAgQUxPR0UoIiVzOiBTdHJlYW0gJWQgbm90IGZvdW5kIGluIHN0cmVhbSBjb25maWd1cmF0aW9uIHJlc3BvbnNlIGZyb20gSEFMIiwKKyAgICA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0LT5mb3JtYXQgIT0gb3ZlcnJpZGVGb3JtYXQpIHsKKyAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IFN0cmVhbSAlZDogRm9ybWF0IG92ZXJyaWRlIG5vdCBhbGxvd2VkIGZvciBmb3JtYXQgMHgleCIsIF9fRlVOQ1RJT05fXywKKyAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUlkLCBkc3QtPmZvcm1hdCk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBpZiAoZHN0LT5kYXRhX3NwYWNlICE9IG92ZXJyaWRlRGF0YVNwYWNlKSB7CisgICAgICAgICAgICAgICAgQUxPR0UoIiVzOiBTdHJlYW0gJWQ6IERhdGFTcGFjZSBvdmVycmlkZSBub3QgYWxsb3dlZCBmb3IgZm9ybWF0IDB4JXgiLCBfX0ZVTkNUSU9OX18sCisgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwgZHN0LT5mb3JtYXQpOworICAgICAgICAgICAgfQorICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgYm9vbCBuZWVkRm9ybWF0T3ZlcnJpZGUgPQorICAgICAgICAgICAgICAgICAgICByZXF1ZXN0ZWRDb25maWd1cmF0aW9uM18yLnN0cmVhbXNbaV0uZm9ybWF0ICE9IHNyYy52M18yLm92ZXJyaWRlRm9ybWF0OworICAgICAgICAgICAgYm9vbCBuZWVkRGF0YXNwYWNlT3ZlcnJpZGUgPQorICAgICAgICAgICAgICAgICAgICByZXF1ZXN0ZWRDb25maWd1cmF0aW9uM18yLnN0cmVhbXNbaV0uZGF0YVNwYWNlICE9IHNyYy5vdmVycmlkZURhdGFTcGFjZTsKKyAgICAgICAgICAgIC8vIE92ZXJyaWRlIGFsbG93ZWQgd2l0aCBJTVBMRU1FTlRBVElPTl9ERUZJTkVECisgICAgICAgICAgICBkc3RTdHJlYW0tPnNldEZvcm1hdE92ZXJyaWRlKG5lZWRGb3JtYXRPdmVycmlkZSk7CisgICAgICAgICAgICBkc3RTdHJlYW0tPnNldERhdGFTcGFjZU92ZXJyaWRlKG5lZWREYXRhc3BhY2VPdmVycmlkZSk7CisgICAgICAgICAgICBkc3QtPmZvcm1hdCA9IG92ZXJyaWRlRm9ybWF0OworICAgICAgICAgICAgZHN0LT5kYXRhX3NwYWNlID0gb3ZlcnJpZGVEYXRhU3BhY2U7CisgICAgICAgIH0KKworICAgICAgICBpZiAoZHN0LT5zdHJlYW1fdHlwZSA9PSBDQU1FUkFfU1RSRUFNX0lOUFVUKSB7CisgICAgICAgICAgICBpZiAoc3JjLnYzXzIucHJvZHVjZXJVc2FnZSAhPSAwKSB7CisgICAgICAgICAgICAgICAgQUxPR0UoIiVzOiBTdHJlYW0gJWQ6IElOUFVUIHN0cmVhbXMgbXVzdCBoYXZlIDAgZm9yIHByb2R1Y2VyIHVzYWdlIiwKKyAgICAgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgc3RyZWFtSWQpOworICAgICAgICAgICAgICAgIHJldHVybiBJTlZBTElEX09QRVJBVElPTjsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGRzdFN0cmVhbS0+c2V0VXNhZ2UoCisgICAgICAgICAgICAgICAgICAgIG1hcENvbnN1bWVyVG9GcmFtZXdvcmtVc2FnZShzcmMudjNfMi5jb25zdW1lclVzYWdlKSk7CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAvLyBPVVRQVVQKKyAgICAgICAgICAgIGlmIChzcmMudjNfMi5jb25zdW1lclVzYWdlICE9IDApIHsKKyAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IFN0cmVhbSAlZDogT1VUUFVUIHN0cmVhbXMgbXVzdCBoYXZlIDAgZm9yIGNvbnN1bWVyIHVzYWdlIiwKKyAgICAgICAgICAgICAgICAgICAgICAgIF9fRlVOQ1RJT05fXywgc3RyZWFtSWQpOworICAgICAgICAgICAgICAgIHJldHVybiBJTlZBTElEX09QRVJBVElPTjsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgI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0gQ2FtZXJhM1N0cmVhbTo6Y2FzdChzcmMpOworICAgICAgICBjYW0zc3RyZWFtLT5zZXRCdWZmZXJGcmVlZExpc3RlbmVyKHRoaXMpOworICAgICAgICBpbnQgc3RyZWFtSWQgPSBjYW0zc3RyZWFtLT5nZXRJZCgpOworICAgICAgICBTdHJlYW1UeXBlIHN0cmVhbVR5cGU7CisgICAgICAgIHN3aXRjaCAoc3JjLT5zdHJlYW1fdHlwZSkgeworICAgICAgICAgICAgY2FzZSBDQU1FUkFfU1RSRUFNX09VVFBVVDoKKyAgICAgICAgICAgICAgICBzdHJlYW1UeXBlID0gU3RyZWFtVHlwZTo6T1VUUFVUOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBDQU1FUkFfU1RSRUFNX0lOUFVUOgorICAgICAgICAgICAgICAgIHN0cmVhbVR5cGUgPSBTdHJlYW1UeXBlOjpJTlBVVDsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgQUxPR0UoIiVzOiBTdHJlYW0gJWQ6IFVuc3VwcG9ydGVkIHN0cmVhbSB0eXBlICVkIiwgX19GVU5DVElPTl9fLAorICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtSWQsIGNvbmZpZy0+c3RyZWFtc1tpXS0+c3RyZWFtX3R5cGUpOworICAgICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKKyAgICAgICAgfQorICAgICAgICBkc3QzXzIuaWQgPSBzdHJlYW1JZDsKKyAgICAgICAgZHN0M18yLnN0cmVhbVR5cGUgPSBzdHJlYW1UeXBlOworICAgICAgICBkc3QzXzIud2lkdGggPSBzcmMtPndpZHRoOworICAgICAgICBkc3QzXzIuaGVpZ2h0ID0gc3JjLT5oZWlnaHQ7CisgICAgICAgIGRzdDNfMi51c2FnZSA9IG1hcFRvQ29uc3VtZXJVc2FnZShjYW0zc3RyZWFtLT5nZXRVc2FnZSgpKTsKKyAgICAgICAgZHN0M18yLnJvdGF0aW9uID0KKyAgICAgICAgICAgICAgICBtYXBUb1N0cmVhbVJvdGF0aW9uKChjYW1lcmFfc3RyZWFtX3JvdGF0aW9uX3Qpc3JjLT5yb3RhdGlvbik7CisgICAgICAgIC8vIEZvciBIaWRsU2Vzc2lvbiB2ZXJzaW9uIDMuNSBvciBuZXdlciwgdGhlIGZvcm1hdCBhbmQgZGF0YVNwYWNlIHNlbnQKKyAgICAgICAgLy8gdG8gSEFMIGFyZSBvcmlnaW5hbCwgbm90IHRoZSBvdmVycmlkZGVuIG9uZXMuCisgICAgICAgIGlmIChtSGlkbFNlc3Npb25fM181ICE9IG51bGxwdHIpIHsKKyAgICAgICAgICAgIGRzdDNfMi5mb3JtYXQgPSBtYXBUb1BpeGVsRm9ybWF0KGNhbTNzdHJlYW0tPmlzRm9ybWF0T3ZlcnJpZGRlbigpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID8gY2FtM3N0cmVhbS0+Z2V0T3JpZ2luYWxGb3JtYXQoKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6IHNyYy0+Zm9ybWF0KTsKKyAgICAgICAgICAgIGRzdDNfMi5kYXRhU3BhY2UgPQorICAgICAgICAgICAgICAgICAgICBtYXBUb0hpZGxEYXRhc3BhY2UoY2FtM3N0cmVhbS0+aXNEYXRhU3BhY2VPdmVycmlkZGVuKCkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID8gY2FtM3N0cmVhbS0+Z2V0T3JpZ2luYWxEYXRhU3BhY2UoKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiBzcmMtPmRhdGFfc3BhY2UpOworICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgZHN0M18yLmZvcm1hdCA9IG1hcFRvUGl4ZWxGb3JtYXQoc3JjLT5mb3JtYXQpOworICAgICAgICAgICAgZHN0M18yLmRhdGFTcGFjZS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sdF8zXzcuaXNPaygpKSB7CisgICAgICAgICAgICBoaWRsSW5qZWN0aW9uU2Vzc2lvbl8zXzcgPSBjYXN0SW5qZWN0aW9uUmVzdWx0XzNfNzsKKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIEFMT0dFKCIlczogVHJhbnNhY3Rpb24gZXJyb3I6ICVzIiwgX19GVU5DVElPTl9fLAorICAgICAgICAgICAgICAgICAgICBjYXN0SW5qZWN0aW9uUmVzdWx0XzNfNy5kZXNjcmlwdGlvbigpLmNfc3RyKCkpOworICAgICAgICAgICAgcmV0dXJuIERFQURfT0JKRUNUOworICAgICAgICB9CisKKyAgICAgICAgYXV0byBlcnIgPSBoaWRsSW5qZWN0aW9uU2Vzc2lvbl8zXzctPmNvbmZpZ3VyZUluamVjdGlvblN0cmVhbXMoCisgICAgICAgICAgICAgICAgcmVxdWVzdGVkQ29uZmlndXJhdGlvbjNfNywgaGlkbENoYXJzKTsKKyAgICAgICAgaWYgKCFlcnIuaXNPaygpKSB7CisgICAgICAgICAgICBBTE9HRSgiJXM6IFRyYW5zYWN0aW9uIGVycm9yOiAlcyIsIF9fRlVOQ1RJT05fXywKKyAgICAgICAgICAgICAgICAgICAgZXJyLmRlc2NyaXB0aW9uKCkuY19zdHIoKSk7CisgICAgICAgICAgICByZXR1cm4gREVBRF9PQkpFQ1Q7CisgICAgICAgIH0KKyAgICB9IGVsc2UgeworICAgICAgICBBTE9HRSgiJXM6IG1IaWRsU2Vzc2lvbl8zXzcgZG9lcyBub3QgZXhpc3QsIHRoZSBsb3dlc3QgdmVyc2lvbiBvZiBpbmplY3Rpb24gIgorICAgICAgICAgICAgICAgICJzZXNzaW9uIGlzIDMuNyIsIF9fRlVOQ1RJT05fXyk7CisgICAgICAgIHJldHVybiBERUFEX09CSkVDVDsKKyAgICB9CisKKyAgICByZXR1cm4gcmVzOworfQorCitzdGF0dXNfdCBIaWRsQ2FtZXJhM0RldmljZTo6SGlkbEhhbEludGVyZmFjZTo6d3J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dC0+b3V0cHV0QnVmZmVyc1tpXTsKKyAgICAgICAgICAgIGludDMyX3Qgc3RyZWFtSWQgPSBDYW1lcmEzU3RyZWFtOjpjYXN0KHNyYy0+c3RyZWFtKS0+Z2V0SWQoKTsKKyAgICAgICAgICAgIGlmIChzcmMtPmJ1ZmZlciAhPSBudWxscHRyKSB7CisgICAgICAgICAgICAgICAgYnVmZmVyX2hhbmRsZV90IGJ1ZiA9ICooc3JjLT5idWZmZXIpOworICAgICAgICAgICAgICAgIGF1dG8gcGFpciA9IGdldEJ1ZmZlcklkKGJ1Ziwgc3RyZWFtSWQpOworICAgICAgICAgICAgICAgIGJvb2wgaXNOZXdCdWZmZXIgPSBwYWlyLmZpcnN0OworICAgICAgICAgICAgICAgIGRzdC5idWZmZXJJZCA9IHBhaXIuc2Vjb25kOworICAgICAgICAgICAgICAgIGRzdC5idWZmZXIgPSBpc05ld0J1ZmZlciA/IGJ1ZiA6IG51bGxwdHI7CisgICAgICAgICAgICAgICAgbmF0aXZlX2hhbmRsZV90ICphY3F1aXJlRmVuY2UgPSBudWxscHRyOworICAgICAgICAgICAgICAgIGlmIChzcmMtPmFjcXVpcmVfZmVuY2UgIT0gLTEpIHsKKyAgICAgICAgICAgICAgICAgICAgYWNxdWlyZUZlbmNlID0gbmF0aXZlX2hhbmRsZV9jcmVhdGUoMSwwKTsKKyAgICAgICAgICAgICAgICAgICAgYWNxdWlyZUZlbmNlLT5kYXRhWzBdID0gc3JjLT5hY3F1aXJlX2ZlbmNlOworICAgICAgICAgICAgICAgICAgICBoYW5kbGVzQ3JlYXRlZC0+cHVzaF9iYWNrKGFjcXVpcmVGZW5jZSk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGRzdC5hY3F1aXJlRmVuY2UgPSBhY3F1aXJlRmVuY2U7CisgICAgICAgICAgICB9IGVsc2UgaWYgKG1Vc2VIYWxCdWZNYW5hZ2VyKSB7CisgICAgICAgICAgICAgICAgLy8gSEFMIGJ1ZmZlciBtYW5hZ2VtZW50IHBhdGgKKyAgICAgICAgICAgICAgICBkc3QuYnVmZmVySWQgPSBCVUZGRVJfSURfTk9fQlVGRkVSOworICAgICAgICAgICAgICAgIGRzdC5idWZmZXIgPSBudWxscHRyOworICAgICAgICAgICAgICAgIGRzdC5hY3F1aXJlRmVuY2UgPSBudWxscHRyOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IGNhbm5vdCBzZW5kIGEgbnVsbCBidWZmZXIgaW4gY2FwdHVyZSByZXF1ZXN0ISIsIF9fRlVOQ1RJT05fXyk7CisgICAgICAgICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIGRzdC5zdHJlYW1JZCA9IHN0cmVhbUlkOworICAgICAgICAgICAgZHN0LnN0YXR1cyA9IEJ1ZmZlclN0YXR1czo6T0s7CisgICAgICAgICAgICBkc3QucmVsZWFzZUZlbmNlID0gbnVsbHB0cjsKKworICAgICAgICAgICAgLy8gT3V0cHV0IGJ1ZmZlcnMgYXJlIGVtcHR5IHdoZW4gdXNpbmcgSEFMIGJ1ZmZlciBtYW5hZ2VyCisgICAgICAgICAgICBpZiAoIW1Vc2VIYWxCdWZNYW5hZ2VyKSB7CisgICAgICAgICAgICAgICAgbUJ1ZmZlclJlY29yZHMucHVzaEluZmxpZ2h0QnVmZmVyKAorICAgICAgICAgICAgICAgICAgICAgICAgY2FwdHVyZVJlcXVlc3QtPmZyYW1lTnVtYmVyLCBzdHJlYW1JZCwgc3JjLT5idWZmZXIpOworICAgICAgICAgICAgICAgIGluZmxpZ2h0QnVmZmVycy0+cHVzaF9iYWNrKHN0ZDo6bWFrZV9wYWlyKGNhcHR1cmVSZXF1ZXN0LT5mcmFtZU51bWJlciwgc3RyZWFtSWQpKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KKyAgICByZXR1cm4gT0s7Cit9CisKK3N0YXR1c190IEhp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JlcXVlc3RzW2ldLCAvKm91dCovJmNhcHR1cmVSZXF1ZXN0c18zXzdbaV0udjNfNC52M18yLAorICAgICAgICAgICAgICAgICAgICAvKm91dCovJmhhbmRsZXNDcmVhdGVkLCAvKm91dCovJmluZmxpZ2h0QnVmZmVycyk7CisgICAgICAgIH0gZWxzZSBpZiAoaGlkbFNlc3Npb25fM180ICE9IG51bGxwdHIpIHsKKyAgICAgICAgICAgIHJlcyA9IHdyYXBBc0hpZGxSZXF1ZXN0KHJlcXVlc3RzW2ldLCAvKm91dCovJmNhcHR1cmVSZXF1ZXN0c18zXzRbaV0udjNfMiwKKyAgICAgICAgICAgICAgICAgICAgLypvdXQqLyZoYW5kbGVzQ3JlYXRlZCwgLypvdXQqLyZpbmZsaWdodEJ1ZmZlcnMpOworICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgcmVzID0gd3JhcEFzSGlkbFJlcXVlc3QocmVxdWVzdHNbaV0sIC8qb3V0Ki8mY2FwdHVyZVJlcXVlc3RzW2ldLAorICAgICAgICAgICAgICAgICAgICAvKm91dCovJmhhbmRsZXNDcmVhdGVkLCAvKm91dCovJmluZmxpZ2h0QnVmZmVycyk7CisgICAgICAgIH0KKyAgICAgICAgaWYgKHJlcyAhPSBPSykgeworICAgICAgICAgICAgbUJ1ZmZlclJlY29yZHMucG9wSW5mbGlnaHRCdWZmZXJzKGluZmxpZ2h0QnVmZmVycyk7CisgICAgICAgICAgICBjbGVhbnVwTmF0aXZlSGFuZGxlcygmaGFuZGxlc0NyZWF0ZWQpOworICAgICAgICAgICAgcmV0dXJuIHJlczsKKyAgICAgICAgfQorICAgIH0KKworICAgIHN0ZDo6dmVjdG9yPGRldmljZTo6VjNfMjo6QnVmZmVyQ2FjaGU+IGNhY2hlc1RvUmVtb3ZlOworICAgIHsKKyAgICAgICAgc3RkOjpsb2NrX2d1YXJkPHN0ZDo6bXV0ZXg+IGxvY2sobUZyZWVkQnVmZmVyc0xvY2spOworICAgICAgICBmb3IgKGF1d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AgICAgICAgICAgY2FwdHVyZVJlcXVlc3QgPSAmY2FwdHVyZVJlcXVlc3RzW2ldOworICAgICAgICB9CisKKyAgICAgICAgaWYgKHJlcXVlc3QtPnNldHRpbmdzICE9IG51bGxwdHIpIHsKKyAgICAgICAgICAgIHNpemVfdCBzZXR0aW5nc1NpemUgPSBnZXRfY2FtZXJhX21ldGFkYXRhX3NpemUocmVxdWVzdC0+c2V0dGluZ3MpOworICAgICAgICAgICAgaWYgKG1SZXF1ZXN0TWV0YWRhdGFRdWV1ZSAhPSBudWxscHRyICYmIG1SZXF1ZXN0TWV0YWRhdGFRdWV1ZS0+d3JpdGUoCisgICAgICAgICAgICAgICAgICAgIHJlaW50ZXJwcmV0X2Nhc3Q8Y29uc3QgdWludDhfdCo+KHJlcXVlc3QtPnNldHRpbmdzKSwgc2V0dGluZ3NTaXplKSkgeworICAgICAgICAgICAgICAgIGNhcHR1cmVSZXF1ZXN0LT5zZXR0aW5ncy5yZXNpemUoMCk7CisgICAgICAgICAgICAgICAgY2FwdHVyZVJlcXVlc3QtPmZtcVNldHRpbmdzU2l6ZSA9IHNldHRpbmdzU2l6ZTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgaWYgKG1SZXF1ZXN0TWV0YWRhdGFRdWV1ZSAhPSBudWxscHRyKSB7CisgICAgICAgICAgICAgICAgICAgIEFMT0dXKCIlczogY291bGRuJ3QgdXRpbGl6ZSBmbXEsIGZhbGxiYWNrIHRvIGh3YmluZGVyIiwgX19GVU5DVElPTl9fKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgY2FwdHVyZVJlcXVlc3QtPnNldHRpbmdzLnNldFRvRXh0ZXJuYWwoCisgICAgICAgICAgICAgICAgICAgICAgICByZWludGVycHJldF9jYXN0PHVpbnQ4X3QqPihjb25zdF9jYXN0PGNhbWVyYV9tZXRhZGF0YV90Kj4oCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3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ICAgICAgICAgIChoaWRsU2Vzc2lvbl8zXzcgIT0gbnVsbHB0cikgPworICAgICAgICAgICAgICAgICAgICBjYXB0dXJlUmVxdWVzdHNfM183W2ldLnYzXzQucGh5c2ljYWxDYW1lcmFTZXR0aW5ncyA6CisgICAgICAgICAgICAgICAgICAgIGNhcHR1cmVSZXF1ZXN0c18zXzRbaV0ucGh5c2ljYWxDYW1lcmFTZXR0aW5nczsKKyAgICAgICAgICAgIHBoeXNpY2FsQ2FtZXJhU2V0dGluZ3MucmVzaXplKHJlcXVlc3QtPm51bV9waHlzY2FtX3NldHRpbmdzKTsKKyAgICAgICAgICAgIGZvciAoc2l6ZV90IGogPSAwOyBqIDwgcmVxdWVzdC0+bnVtX3BoeXNjYW1fc2V0dGluZ3M7IGorKykgeworICAgICAgICAgICAgICAgIGlmIChyZXF1ZXN0LT5waHlzY2FtX3NldHRpbmdzICE9IG51bGxwdHIpIHsKKyAgICAgICAgICAgICAgICAgICAgc2l6ZV90IHNldHRpbmdzU2l6ZSA9IGdldF9jYW1lcmFfbWV0YWRhdGFfc2l6ZShyZXF1ZXN0LT5waHlzY2FtX3NldHRpbmdzW2pdKTsKKyAgICAgICAgICAgICAgICAgICAgaWYgKG1SZXF1ZXN0TWV0YWRhdGFRdWV1ZSAhPSBudWxscHRyICYmIG1SZXF1ZXN0TWV0YWRhdGFRdWV1ZS0+d3JpdGUoCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlaW50ZXJwcmV0X2Nhc3Q8Y29uc3QgdWludDhfdCo+KHJlcXVlc3QtPnBoeXNjYW1fc2V0dGluZ3Nbal0pLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXR0aW5nc1NpemUpKSB7CisgICAgICAgICAgICAgICAgICAgICAgICBwaHlzaWNhbENhbWVyYVNldHRpbmdzW2pdLnNldHRpbmdzLnJlc2l6ZSgwKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHBoeXNpY2FsQ2FtZXJhU2V0dGluZ3Nbal0uZm1xU2V0dGluZ3NTaXplID0gc2V0dGluZ3NTaXplOworICAgICAgICAgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1SZXF1ZXN0TWV0YWRhdGFRdWV1ZSAhPSBudWxscHRyKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgQUxPR1coIiVzOiBjb3VsZG4ndCB1dGlsaXplIGZtcSwgZmFsbGJhY2sgdG8gaHdiaW5kZXIiLCBfX0ZVTkNUSU9OX18pOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgcGh5c2ljYWxDYW1lcmFTZXR0aW5nc1tqXS5zZXR0aW5ncy5zZXRUb0V4dGVybmFsKAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWludGVycHJldF9jYXN0PHVpbnQ4X3QqPihjb25zdF9jYXN0PGNhbWVyYV9tZXRhZGF0YV90Kj4oCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdC0+cGh5c2NhbV9zZXR0aW5nc1tqXSkpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXRfY2FtZXJhX21ldGFkYXRhX3NpemUocmVxdWVzdC0+cGh5c2NhbV9zZXR0aW5nc1tqXSkpOworICAgICAgICAgICAgICAgICAgICAgICAgcGh5c2ljYWxDYW1lcmFTZXR0aW5nc1tqXS5mbXFTZXR0aW5nc1NpemUgPSAwdTsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgICAgIHBoeXNpY2FsQ2FtZXJhU2V0dGluZ3Nbal0uZm1xU2V0dGluZ3NTaXplID0gMHU7CisgICAgICAgICAgICAgICAgICAgIHBoeXNpY2FsQ2FtZXJhU2V0dGluZ3Nbal0uc2V0dGluZ3MucmVzaXplKDApOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBwaHlzaWNhbENhbWVyYVNldHRpbmdzW2pdLnBoeXNpY2FsQ2FtZXJhSWQgPSByZXF1ZXN0LT5waHlzY2FtX2lkW2pdOworICAgICAgICAgICAgfQorICAgICAgICB9CisgICAgfQorCisgICAgaGFyZHdhcmU6OmRldGFpbHM6OnJldHVybl9zdGF0dXMgZXJyOworICAgIGF1dG8gcmVzdWx0Q2FsbGJhY2sgPQorICAgICAgICBbJnN0YXR1cywgJm51bVJlcXVlc3RQcm9jZXNzZWRdIChhdXRvIHMsIHVpbnQzMl90IG4pIHsKKyAgICAgICAgICAgICAgICBzdGF0dXMgPSBzOworICAgICAgICAgICAgICAgICpudW1SZXF1ZXN0UHJvY2Vzc2VkID0gbjsKKyAgICAgICAgfTsKKyAgICBpZiAoaGlkbFNlc3Npb25fM183ICE9IG51bGxwdHIpIHsKKyAgICAgICAgZXJyID0gaGlkbFNlc3Npb25fM183LT5wcm9jZXNzQ2FwdHVyZVJlcXVlc3RfM183KGNhcHR1cmVSZXF1ZXN0c18zXzcsIGNhY2hlc1RvUmVtb3ZlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0Q2FsbGJhY2spOworICAgIH0gZWxzZSBpZiAoaGlkbFNlc3Npb25fM180ICE9IG51bGxwdHIpIHsKKyAgICAgICAgZXJyID0gaGlkbFNlc3Npb25fM180LT5wcm9jZXNzQ2FwdHVyZVJlcXVlc3RfM180KGNhcHR1cmVSZXF1ZXN0c18zXzQsIGNhY2hlc1RvUmVtb3ZlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0Q2FsbGJhY2spOworICAgIH0gZWxzZSB7CisgICAgICAgIGVyciA9IG1IaWRsU2Vzc2lvbi0+cHJvY2Vzc0NhcHR1cmVSZXF1ZXN0KGNhcHR1cmVSZXF1ZXN0cywgY2FjaGVzVG9SZW1vdmUsCisgICAgICAg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dlciwKKyAgICAgICAgY29uc3Qgc3A8YW5kcm9pZDo6aGFyZHdhcmU6OmNhbWVyYTo6ZGV2aWNlOjpWM18yOjpJQ2FtZXJhRGV2aWNlQ2FsbGJhY2s+JgorICAgICAgICAgICAgICAgIGNhbGxiYWNrKSB7CisgICAgQVRSQUNFX0NBTEwoKTsKKyAgICBNdXRleDo6QXV0b2xvY2sgbG9jayhtSW5qZWN0aW9uTG9jayk7CisKKyAgICBpZiAobWFuYWdlciA9PSBudWxscHRyKSB7CisgICAgICAgIEFMT0dFKCIlczogbWFuYWdlciBkb2VzIG5vdCBleGlzdCEiLCBfX0ZVTkNUSU9OX18pOworICAgICAgICByZXR1cm4gSU5WQUxJRF9PUEVSQVRJT047CisgICAgfQorCisgICAgc3A8Q2FtZXJhM0RldmljZT4gcGFyZW50ID0gbVBhcmVudC5wcm9tb3RlKCk7CisgICAgaWYgKHBhcmVudCA9PSBudWxscHRyKSB7CisgICAgICAgIEFMT0dFKCIlczogcGFyZW50IGRvZXMgbm90IGV4aXN0ISIsIF9fRlVOQ1RJT05fXyk7CisgICAgICAgIHJldHVybiBJTlZBTElEX09QRVJBVElPTjsKKyAgICB9CisKKyAgICBtSW5qZWN0ZWRDYW1JZCA9IGluamVjdGVkQ2FtSWQ7CisgICAgc3A8SUNhbWVyYURldmljZVNlc3Npb24+IHNlc3Npb247CisgICAgQVRSQUNFX0JFR0lOKCJJbmplY3Rpb24gQ2FtZXJhSGFsOjpvcGVuU2Vzc2lvbiIpOworICAgIHN0YXR1c190IHJlcyA9IG1hbmFnZXItPm9wZW5IaWRsU2Vzc2lvbihpbmplY3RlZENhbUlkLnN0cmluZygpLCBjYWxsYmFjaywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8qb3V0Ki8gJnNlc3Npb24pOworICAgIEFUUkFDRV9FTkQoKTsKKyAgICBpZiAocmVzICE9IE9LKSB7CisgICAgICAgIEFMT0dFKCJJbmplY3Rpb24gY2FtZXJhI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cHRpb24oKS5jX3N0cigpKTsKKyAgICAgICAgcmV0dXJuIERFQURfT0JKRUNUOworICAgIH0KKyAgICBJRl9BTE9HVigpIHsKKyAgICAgICAgc2Vzc2lvbi0+aW50ZXJmYWNlQ2hhaW4oCisgICAgICAgICAgICAgICAgW10oOjphbmRyb2lkOjpoYXJkd2FyZTo6aGlkbF92ZWM8OjphbmRyb2lkOjpoYXJkd2FyZTo6aGlkbF9zdHJpbmc+CisgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcmZhY2VDaGFpbikgeworICAgICAgICAgICAgICAgICAgICAgICAgQUxPR1YoIkluamVjdGlvbiBjYW1lcmEgc2Vzc2lvbiBpbnRlcmZhY2UgY2hhaW46Iik7CisgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGF1dG8mIGlmYWNlIDogaW50ZXJmYWNlQ2hhaW4pIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBBTE9HVigiICAlcyIsIGlmYWNlLmNfc3RyKCkpOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIH0pOworICAgIH0KKworICAgIEFMT0dWKCIlczogSW5qZWN0aW9uIGNhbWVyYSBpbnRlcmZhY2UgPSBuZXcgSGFsSW50ZXJmYWNlKCkiLCBfX0ZVTkNUSU9OX18pOworCisgICAgbUluamVjdGVkQ2FtSGFsSW50ZXJmYWNlID0KKyAgICAgICAgICAgIG5ldyBIaWRsSGFsSW50ZXJmYWNlKHNlc3Npb24sIHF1ZXVlLCBwYXJlbnQtPm1Vc2VIYWxCdWZNYW5hZ2VyLAorICAgICAgICAgICAgICAgICAgICAgICBwYXJlbnQtPm1TdXBwb3J0T2ZmbGluZVByb2Nlc3NpbmcpOworICAgIGlmIChtSW5qZWN0ZWRDYW1IYWxJbnRlcmZhY2UgPT0gbnVsbHB0cikgeworICAgICAgICBBTE9HRSgiJXM6IG1JbmplY3RlZENhbUhhbEludGVyZmFjZSBkb2VzIG5vdCBleGlzdCEiLCBfX0ZVTkNUSU9OX18pOworICAgICAgICByZXR1cm4gREVBRF9PQkpFQ1Q7CisgICAgfQorCisgICAgcmV0dXJuIE9LOworfQorCitzdGF0dXNfdCBIaWRsQ2FtZXJhM0RldmljZTo6SGlkbENhbWVyYTNEZXZpY2VJbmplY3Rpb25NZXRob2RzOjpyZXBsYWNlSGFsSW50ZXJmYWNlKAorICAgICAgICBzcDxIYWxJbnRlcmZhY2U+IG5ld0hhbEludGVyZmFjZSwgYm9vbCBrZWVwQmFja3VwKSB7CisgICAgTXV0ZXg6OkF1dG9sb2NrIGxvY2sobUluamVjdGlvbkxvY2spOworICAgIGlmIChuZXdIYWxJbnRlcmZhY2UuZ2V0KCkgPT0gbnVsbHB0cikgeworICAgICAgICBBTE9HRSgiJXM6IFRoZSBuZXdIYWxJbnRlcmZhY2UgZG9lcyBub3QgZXhpc3QsIHRvIHN0b3AgcmVwbGFjaW5nLiIsCisgICAgICAgICAgICAgICAgX19GVU5DVElPTl9fKTsKKyAgICAgICAgcmV0dXJuIERFQURfT0JKRUNUOworICAgIH0KKworICAgIHNwPENhbWVyYTNEZXZpY2U+IHBhcmVudCA9IG1QYXJlbnQucHJvbW90ZSgpOworICAgIGlmIChwYXJlbnQgPT0gbnVsbHB0cikgeworICAgICAgICBBTE9HRSgiJXM6IHBhcmVudCBkb2VzIG5vdCBleGlzdCEiLCBfX0ZVTkNUSU9OX18pOworICAgICAgICByZXR1cm4gSU5WQUxJRF9PUEVSQVRJT047CisgICAgfQorICAgIGlmIChuZXdIYWxJbnRlcmZhY2UtPmdldFRyYW5zcG9ydFR5cGUoKSAhPSBJUENUcmFuc3BvcnQ6OkhJREwpIHsKKyAgICAgICAgQUxPR0UoIiVzIFJlcGxhY2luZyBISURMIEhhbEludGVyZmFjZSB3aXRoIGFub3RoZXIgdHJhbnNwb3J0IHVuc3VwcG9ydGVkIiwgX19GVU5DVElPTl9fKTsKKyAgICAgICAgcmV0dXJuIElOVkFMSURfT1BFUkFUSU9OOwor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gICAgICByZXNRdWV1ZSA9IHN0ZDo6bWFrZV91bmlxdWU8UmVzdWx0TWV0YWRhdGFRdWV1ZT4oZGVzY3JpcHRvcik7CisgICAgICAgICAgICAgICAgaWYgKCFyZXNRdWV1ZS0+aXNWYWxpZCgpIHx8IHJlc1F1ZXVlLT5hdmFpbGFibGVUb1dyaXRlKCkgPD0gMCkgeworICAgICAgICAgICAgICAgICAgICBBTE9HRSgiSEFMIHJldHVybnMgZW1wdHkgcmVzdWx0IG1ldGFkYXRhIGZtcSwgbm90IHVzZSBpdCIpOworICAgICAgICAgICAgICAgICAgICByZXNRdWV1ZSA9IG51bGxwdHI7CisgICAgICAgICAgICAgICAgICAgIC8vIERvbid0IHVzZSByZXNRdWV1ZSBvbndhcmRzLgorICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgIH0pOworICAgICAgICBpZiAoIXJlc3VsdFF1ZXVlUmV0LmlzT2soKSkgeworICAgICAgICAgICAgQUxPR0UoIlRyYW5zYWN0aW9uIGVycm9yIHdoZW4gZ2V0dGluZyByZXN1bHQgbWV0YWRhdGEgcXVldWUgZnJvbSBjYW1lcmEgc2Vzc2lvbjogJXMiLAorICAgICAgICAgICAgICAgICAgICByZXN1bHRRdWV1ZVJldC5kZXNjcmlwdGlvbigpLmNfc3RyKCkpOworICAgICAgICAgICAgcmV0dXJuIERFQURfT0JKRUNUOworICAgICAgICB9CisgICAgICAgIG1TdGF0dXMgPSBTVEFUVVNfQUNUSVZFOworICAgIH0KKworICAgIG1TZXNzaW9uLT5zZXRDYWxsYmFjayh0aGlzKTsKKworICAgIHJldHVybiBPSzsKK30KKworaGFyZHdhcmU6OlJldHVybjx2b2lkPiBIaWRsQ2FtZXJhM09mZmxpbmVTZXNzaW9uOjpwcm9jZXNzQ2FwdHVyZVJlc3VsdF8zXzQoCisgICAgICAgIGNvbnN0IGhhcmR3YXJlOjpoaWRsX3ZlYzwKKyAgICAgICAgICAgICAgICBoYXJkd2FyZTo6Y2FtZXJhOjpkZ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1N0cmVhbUludGVyZmFjZT4gc3RyZWFtID0KKyAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRlcy5vdXRwdXRTdHJlYW1zLmdldChtc2cubXNnLmVycm9yLmVycm9yU3RyZWFtSWQpOworICAgICAgICAgICAgICAgIGlmIChzdHJlYW0gPT0gbnVsbHB0cikgeworICAgICAgICAgICAgICAgICAgICBBTE9HRSgiJXM6IEZyYW1lICVkOiBJbnZhbGlkIGVycm9yIHN0cmVhbSBpZCAlZCIsIF9fRlVOQ1RJT05fXywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBtLm1lc3NhZ2UuZXJyb3IuZnJhbWVfbnVtYmVyLCBtc2cubXNnLmVycm9yLmVycm9yU3RyZWFtSWQpOworICAgICAgICAgICAgICAgICAgICByZXR1cm47CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIG0ubWVzc2FnZS5lcnJvci5lcnJvcl9zdHJlYW0gPSBzdHJlYW0tPmFzSGFsU3RyZWFtKCk7CisgICAgICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgICAgIG0ubWVzc2FnZS5lcnJvci5lcnJvcl9zdHJlYW0gPSBudWxscHRyOworICAgICAgICAgICAgfQorICAgICAgICAgICAgc3dpdGNoIChtc2cubXNnLmVycm9yLmVycm9yQ29kZSkgeworICAgICAgICAgICAgICAgIGNhc2UgRXJyb3JDb2RlOjpFUlJPUl9ERVZJQ0U6CisgICAgICAgICAgICAgICAgICAgIG0ubWVzc2FnZS5lcnJvci5lcnJvcl9jb2RlID0gQ0FNRVJBX01TR19FUlJPUl9ERVZJQ0U7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgRXJyb3JDb2RlOjpFUlJPUl9SRVFVRVNUOgorICAgICAgICAgICAgICAgICAgICBtLm1lc3NhZ2UuZXJyb3IuZXJyb3JfY29kZSA9IENBTUVSQV9NU0dfRVJST1JfUkVRVUVTVDsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSBFcnJvckNvZGU6OkVSUk9SX1JFU1VMVDoKKyAgICAgICAgICAgICAgICAgICAgbS5tZXNzYWdlLmVycm9yLmVycm9yX2NvZGUgPSBDQU1FUkFfTVNHX0VSUk9SX1JFU1VMVDsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSBFcnJvckNvZGU6OkVSUk9SX0JVRkZFUjoKKyAgICAgICAgICAgICAgICAgICAgbS5tZXNzYWdlLmVycm9yLmVycm9yX2NvZGUgPSBDQU1FUkFfTVNHX0VSUk9SX0JVRkZFUjsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBNc2dUeXBlOjpTSFVUVEVSOgorICAgICAgICAgICAgbS50eXBlID0gQ0FNRVJBX01TR19TSFVUVEVSOworICAgICAgICAgICAgbS5tZXNzYWdlLnNodXR0ZXIuZnJhbWVfbnVtYmVyID0gbXNnLm1zZy5zaHV0dGVyLmZyYW1lTnVtYmVyOworICAgICAgICAgICAgbS5tZXNzYWdlLnNodXR0ZXIudGltZXN0YW1wID0gbXNnLm1zZy5zaHV0dGVyLnRpbWVzdGFtcDsKKyAgICAgICAgICAgIG0ubWVzc2FnZS5zaHV0dGVyLnJlYWRvdXRfdGltZXN0YW1wID0gMExMOworICAgICAgICAgICAgYnJlYWs7CisgICAgfQorICAgIG5vdGlmeShzdGF0ZXMsICZtKTsKK30KKworc3RhdGljIHZvaWQgY29udmVydFRvQWlkbCgKKyAgICAgICAgY29uc3QgaGFyZHdhcmU6OmhpZGxfdmVjPGhhcmR3YXJlOjpjYW1lcmE6OmRldmljZTo6VjNfNTo6QnVmZmVyUmVxdWVzdD4mIGhpZGxCdWZSZXFzLAorICAgICAgICBzdGQ6OnZlY3RvcjxhaWRsOjphbmRyb2lkOjpoYXJkd2FyZTo6Y2FtZXJhOjp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zc2lvbnMgYW5kCisvLyBsaW1pdGF0aW9ucyB1bmRlciB0aGUgTGljZW5zZS4KKworcGFja2FnZSB7CisgICAgZGVmYXVsdF9hcHBsaWNhYmxlX2xpY2Vuc2VzOiBbCisgICAgICAgICJmcmFtZXdvcmtzX2F2X3NlcnZpY2VzX2NhbWVyYV9saWJjYW1lcmFzZXJ2aWNlX2xpY2Vuc2UiLAorICAgIF0sCit9CisKK2NjX3Rlc3QgeworICAgIG5hbWU6ICJjYW1lcmFzZXJ2aWNlX3Rlc3QiLAorCisgICAgaW5jbHVkZV9kaXJzOiBbCisgICAgICAgICJzeXN0ZW0vbWVkaWEvcHJpdmF0ZS9jYW1lcmEvaW5jbHVkZSIsCisgICAgICAgICJleHRlcm5hbC9keW5hbWljX2RlcHRoL2luY2x1ZGVzIiwKKyAgICAgICAgImV4dGVybmFsL2R5bmFtaWNfZGVwdGgvaW50ZXJuYWwiLAorICAgIF0sCisKKyAgICBzaGFyZWRfbGliczogWworICAgICAgICAibGliYmFzZSIsCisgICAgICAgICJsaWJjdXRpbHMiLAorICAgICAgICAibGliY2FtZXJhc2VydmljZSIsCisgICAgICAgICJsaWJoaWRsYmFzZSIsCisgICAgICAgICJsaWJsb2ciLAorICAgICAgICAibGliY2FtZXJhX2NsaWVudCIsCisgICAgICAgICJsaWJjYW1lcmFfbWV0YWRhdGEiLAorICAgICAgICAibGlidWkiLAorICAgICAgICAibGlidXRpbHMiLAorICAgICAgICAibGlianBlZyIsCisgICAgICAgICJsaWJleGlmIiwKKyAgICAgICAgImFuZHJvaWQuaGFyZHdhcmUuY2FtZXJhLmNvbW1vbkAxLjAiLAorICAgICAgICAiYW5kcm9pZC5oYXJkd2FyZS5jYW1lcmEucHJvdmlkZXJAMi40IiwKKyAgICAgICAgImFuZHJvaWQuaGFyZHdhcmUuY2FtZXJhLnByb3ZpZGVyQDIuNSIsCisgICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLmNhbWVyYS5wcm92aWRlckAyLjYiLAorICAgICAgICAiYW5kcm9pZC5oYXJkd2FyZS5jYW1lcmEucHJvdmlkZXJAMi43IiwKKyAgICAgICAgImFuZHJvaWQuaGFyZHdhcmUuY2FtZXJhLnByb3ZpZGVyLVYxLW5kayIsCisgICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLmNhbWVyYS5kZXZpY2VAMS4wIiwKKyAgICAgICAgImFuZHJvaWQuaGFyZHdhcmUuY2FtZXJhLmRldmljZUAzLjIiLAorICAgICAgICAiYW5kcm9pZC5oYXJkd2FyZS5jYW1lcmEuZGV2aWNlQDMuNCIsCisgICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLmNhbWVyYS5kZXZpY2VAMy43IiwKKyAgICAgICAgImFuZHJvaWQuaGlkbC50b2tlbkAxLjAtdXRpbHMiLAorICAgIF0sCisKKyAgICBzdGF0aWNfbGliczogWworICAgICAgICAibGliZ21vY2siLAorICAgIF0sCisKKyAgICBzcmNzOiBbCisgICAgICAgICJDYW1lcmFQcm92aWRlck1hbmFnZXJUZXN0LmNwcCIsCisgICAgICAgICJDbGllbnRNYW5hZ2VyVGVzdC5jcHAiLAorICAgICAgICAiRGVwdGhQcm9jZXNzb3JUZXN0LmNwcCIsCisgICAgICAgICJEaXN0b3J0aW9uTWFwcGVyVGVzdC5jcHAiLAorICAgICAgICAiRXhpZlV0aWxzVGVzdC5jcHAiLAorICAgICAgICAiTlYxMkNvbXByZXNzb3IuY3BwIiwKKyAgICAgICAgIlJvdGF0ZUFuZENyb3BNYXBwZXJUZXN0LmNwcCIsCisgICAgICAgICJab29tUmF0aW9UZXN0LmNwcCIsCisgICAgXSwKKworICAgIGNmbGFnczogWworICAgICAgICAiLVdhbGwiLAorICAgICAgICAiLVdleHRyYSIsCisgICAgICAgICItV2Vycm9yIiwKKyAgICBdLAorCisgICAgdGVzdF9zdWl0ZXM6IFsiZGV2aWNlLXRlc3RzIl0sCisKK30KKworY2NfdGVzdF9ob3N0IHsKKyAgICBuYW1lOiAiY2FtZXJhc2VydmljZV90ZXN0X2hvc3QiLAorCisgICAgaW5jbHVkZV9kaXJzOiBbCisgICAgICAgICJmcmFtZXdvcmtzL2F2L2NhbWVyYS9pbmNsdWRlIiwKKyAgICAgICAgImZyYW1ld29ya3MvYXYvY2FtZXJhL2luY2x1ZGUvY2FtZXJhIiwKKyAgICAgICAgImZyYW1ld29ya3MvbmF0aXZlL2xpYnMvYmluZGVyL2luY2x1ZGVfYWN0aXZpdHltYW5hZ2VyIgorICAgIF0sCisKKyAgICBzaGFyZWRfbGliczogWworICAgICAgICAibGliYWN0aXZpdHlfbWFuYWdlcl9wcm9jc3RhdGVfYWlkbC1jcHAiLAorICAgICAgICAibGliYmFzZSIsCisgICAgICAgICJsaWJiaW5kZXIiLAorICAgICAgICAibGliY2FtZXJhX21ldGFkYXRhIiwKKyAgICAgICAgImxpYmR5bmFtaWNfZGVwdGgiLAorICAgICAgICAibGliZXhpZiIsCisgICAgICAgICJsaWJqcGVnIiwKKyAgICAgICAgImxpYmxvZyIsCisgICAgICAgICJsaWJ1dGlscyIsCisgICAgXSwKKworICAgIHN0YXRpY19saWJzOiBbCisgICAgICAgICJsaWJjYW1lcmFfY2xpZW50X2hvc3QiLAorICAgICAgICAibGliY2FtZXJhc2VydmljZV9kZXZpY2VfaW5kZXBlbmRlbnQiLAorICAgICAgICAibGliZ21vY2siLAorICAgIF0sCisKKyAgICBzcmNzOiBbCisgICAgICAgICJDbGllbnRNYW5hZ2VyVGVzdC5jcHAiLAorICAgICAgICAiRGVwdGhQcm9jZXNzb3JUZXN0LmNwcCIsCisgICAgICAgICJEaXN0b3J0aW9uTWFwcGVyVGVzdC5jcHAiLAorICAgICAgICAiRXhpZlV0aWxzVGVzdC5jcHAiLAorICAgICAgICAiTlYxMkNvbXByZXNzb3IuY3BwIiwKKyAgICAgICAgIlJvdGF0ZUFuZENyb3BNYXBwZXJUZXN0LmNwcCIsCisgICAgICAgICJab29tUmF0aW9UZXN0LmNwcCIsCisgICAgXSwKKworICAgIGNmbG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cikgeworICAgICAgICAgICAgaWYgKGNvbmZsaWN0aW5nICYmIG93bmVyID09IGN1ck93bmVyKSB7CiAgICAgICAgICAgICAgICAgLy8gUHJlLWV4aXN0aW5nIGNvbmZsaWN0aW5nIGNsaWVudCB3aXRoIHRoZSBzYW1lIGNsaWVudCBvd25lciBleGlzdHMKICAgICAgICAgICAgICAgICAvLyBPcGVuIHRoZSBzYW1lIGRldmljZSB0d2ljZSAtPiBtb3N0IHJlY2VudCBvcGVuIHdpbnMKICAgICAgICAgICAgICAgICAvLyBPdGhlcndpc2UgbGV0IHRoZSBleGlzdGluZyBjbGllbnQgd2lucyB0byBhdm9pZCBiZWhhdmlvcnMgZGlmZmVyZW5jZQpAQCAtNTQ2LDYgKzU0MSwxMSBAQAogICAgICAgICAgICAgICAgICAgICBldmljdExpc3QucHVzaF9iYWNrKGNsaWVudCk7CiAgICAgICAgICAgICAgICAgICAgIHJldHVybiBldmljdExpc3Q7CiAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfSBlbHNlIGlmIChjb25mbGljdGluZyAmJiBjdXJQcmlvcml0eSA8IHByaW9yaXR5KSB7CisgICAgICAgICAgICAgICAgLy8gUHJlLWV4aXN0aW5nIGNvbmZsaWN0aW5nIGNsaWVudCB3aXRoIGhpZ2hlciBwcmlvcml0eSBleGlzdHMKKyAgICAgICAgICAgICAgICBldmljdExpc3QuY2xlYXIoKTsKKyAgICAgICAgICAgICAgICBldmljdExpc3QucHVzaF9iYWNrKGNsaWVudCk7CisgICAgICAgICAgICAgICAgcmV0dXJuIGV2aWN0TGlzdDsKICAgICAgICAgICAgIH0gZWxzZSBpZiAoY29uZmxpY3RpbmcgfHwgKCh0b3RhbENvc3QgPiBtTWF4Q29zdCAmJiBjdXJDb3N0ID4gMCkgJiYKICAgICAgICAgICAgICAgICAgICAgKGN1clByaW9yaXR5ID49IHByaW9yaXR5KSAmJgogICAgICAgICAgICAgICAgICAgICAhKGhpZ2hlc3RQcmlvcml0eU93bmVyID09IG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FtaWNSYW5nZVByb2ZpbGUpOworICAgICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKKyAgICAgICAgfQorCisgICAgICAgIGlmIChzdGF0aWNfY2FzdDxpbnQ+KHN0cmVhbS51c2VDYXNlKSAhPSBBTkRST0lEX1NDQUxFUl9BVkFJTEFCTEVfU1RSRUFNX1VTRV9DQVNFU19ERUZBVUxUKSB7CisgICAgICAgICAgICBBTE9HRSgiJXMgU3RyZWFtIHVzZSBjYXNlICUiIFBSSWQ2NCAibm90IHN1cHBvcnRlZCBieSBISURMIiwgX19GVU5DVElPTl9fLAorICAgICAgICAgICAgICAgICAgICBzdHJlYW0udXNlQ2FzZSk7CisgICAgICAgICAgICByZXR1cm4gQkFEX1ZBTFVFOworICAgICAgICB9CisKKyAgICAgICAgLy8gaGlkbCB2M183CisgICAgICAgIGhpZGwuc3RyZWFtc1tpXS5ncm91cElkID0gc3RyZWFtLmdyb3VwSWQ7CisgICAgICAgIGhpZGwuc3RyZWFtc1tpXS5zZW5zb3JQaXhlbE1vZGVzVXNlZC5yZXNpemUoc3RyZWFtLnNlbnNvclBpeGVsTW9kZXNVc2VkLnNpemUoKSk7CisgICAgICAgIHNpemVfdCBqID0gMDsKKyAgICAgICAgZm9yIChjb25zdCBhdXRvICZtb2RlIDogc3RyZWFtLnNlbnNvclBpeGVsTW9kZXNVc2VkKSB7CisgICAgICAgICAgICBoaWRsLnN0cmVhbXNbaV0uc2Vuc29yUGl4ZWxNb2Rlc1VzZWRbal0gPQorICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxDYW1lcmFNZXRhZGF0YUVudW1BbmRyb2lkU2Vuc29yUGl4ZWxNb2RlPihtb2RlKTsKKyAgICAgICAgICAgIGorKzsKKyAgICAgICAgfQorCisgICAgICAgIC8vaGlkbCB2M180CisgICAgICAgIGhpZGwuc3RyZWFtc1tpXS52M180LnBoeXNpY2FsQ2FtZXJhSWQgPSBzdHJlYW0ucGh5c2ljYWxDYW1lcmFJZDsKKworICAgICAgICBpZiAoc3RyZWFtLmJ1ZmZlclNpemUgPCAwKSB7CisgICAgICAgICAgICByZXR1cm4gQkFEX1ZBTFVFOworICAgICAgICB9CisgICAgICAgIGhpZGwuc3RyZWFtc1tpXS52M180LmJ1ZmZlclNpemUgPSBzdGF0aWNfY2FzdDx1aW50MzJfdD4oc3RyZWFtLmJ1ZmZlclNpemUpOworCisgICAgICAgIC8vIGhpbGQgdjNfMgorICAgICAgICBoaWRsLnN0cmVhbXNbaV0udjNfNC52M18yLmlkID0gc3RyZWFtLmlkOworICAgICAgICBoaWRsLnN0cmVhbXNbaV0udjNfNC52M18yLmZvcm1hdCA9CisgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8aGFyZHdhcmU6OmdyYXBoaWNzOjpjb21tb246OlYxXzA6OlBpeGVsRm9ybWF0PihzdHJlYW0uZm9ybWF0KTsKKworICAgICAgICBpZiAoc3RyZWFtLndpZHRoIDwgMCB8fCBzdHJlYW0uaGVpZ2h0IDwgMCkgeworICAgICAgICAgICAgcmV0dXJuIEJBRF9WQUxVRTsKKyAgICAgICAgfQorICAgICAgICBoaWRsLnN0cmVhbXNbaV0udjNfNC52M18yLndpZHRoID0gc3RhdGljX2Nhc3Q8dWludDMyX3Q+KHN0cmVhbS53aWR0aCk7CisgICAgICAgIGhpZGwuc3RyZWFtc1tpXS52M180LnYzXzIuaGVpZ2h0ID0gc3RhdGljX2Nhc3Q8dWludDMyX3Q+KHN0cmVhbS5oZWlnaHQpOworICAgICAgICBoaWRsLnN0cmVhbXNbaV0udjNfNC52M18yLnVzYWdlID0KKyAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxoYXJkd2FyZTo6Y2FtZXJhOjpkZXZpY2U6OlYzXzI6OkJ1ZmZlclVzYWdlRmxhZ3M+KHN0cmVhbS51c2FnZSk7CisgICAgICAgIGhpZGwuc3RyZWFtc1tpXS52M180LnYzXzIuc3RyZWFtVHlwZSA9CisgICAgICAgICAgICAgICAgc3Rhd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TlNfTUFYSU1VTV9SRVNPTFVUSU9OOworICAgICAgICBjYXNlIEFORFJPSURfU0VOU09SX09QQVFVRV9SQVdfU0laRToKKyAgICAgICAgICAgIHJldHVybiBBTkRST0lEX1NFTlNPUl9PUEFRVUVfUkFXX1NJWkVfTUFYSU1VTV9SRVNPTFVUSU9OOworICAgICAgICBjYXNlIEFORFJPSURfTEVOU19JTlRSSU5TSUNfQ0FMSUJSQVRJT046CisgICAgICAgICAgICByZXR1cm4gQU5EUk9JRF9MRU5TX0lOVFJJTlNJQ19DQUxJQlJBVElPTl9NQVhJTVVNX1JFU09MVVRJT047CisgICAgICAgIGNhc2UgQU5EUk9JRF9MRU5TX0RJU1RPUlRJT046CisgICAgICAgICAgICByZXR1cm4gQU5EUk9JRF9MRU5TX0RJU1RPUlRJT05fTUFYSU1VTV9SRVNPTFVUSU9OOworICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgQUxPR0UoIiVzOiBUYWcgJWQgZG9lc24ndCBoYXZlIGEgbWF4aW11bSByZXNvbHV0aW9uIGNvdW50ZXJwYXJ0IiwgX19GVU5DVElPTl9fLAorICAgICAgICAgICAgICAgICAgICBkZWZhdWx0VGFnKTsKKyAgICAgICAgICAgIHJldHVybiAtMTsKKyAgICB9CisgICAgcmV0dXJuIC0xOworfQorCitib29sIGlzVWx0cmFIaWdoUmVzb2x1dGlvblNlbnNvcihjb25zdCBDYW1lcmFNZXRhZGF0YSAmZGV2aWNlSW5mbykgeworICAgIGNhbWVyYV9tZXRhZGF0YV9yb19lbnRyeV90IGVudHJ5Q2FwOworICAgIGVudHJ5Q2FwID0gZGV2aWNlSW5mby5maW5kKEFORFJPSURfUkVRVUVTVF9BVkFJTEFCTEVfQ0FQQUJJTElUSUVTKTsKKyAgICAvLyBHbyB0aHJvdWdoIHRoZSBjYXBhYmlsaXRpZXMgYW5kIGNoZWNrIGlmIGl0IGhhcworICAgIC8vIEFORFJPSURfUkVRVUVTVF9BVkFJTEFCTEVfQ0FQQUJJ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ci0gICAgICAgICAgICBpbnQgaW5kZW50YXRpb24gPSAoZXZlbnQuc291cmNlID09IFJFUVVFU1QpID8gMTUgOiAzMDsKLSAgICAgICAgICAgIGRwcmludGYoZmQsICIgICAgICAgIGYlZDolIiBQUklkNjQgIm5zOiUqcyUqcyVzLiVzOiAiLAotICAgICAgICAgICAgICAgICAgICBldmVudC5mcmFtZU51bWJlciwgZXZlbnQudGltZXN0YW1wLAotICAgICAgICAgICAgICAgICAgICAyLCBldmVudC5jYW1lcmFJZC5jX3N0cigpLAotICAgICAgICAgICAgICAgICAgICBpbmRlbnRhdGlvbiwKLSAgICAgICAgICAgICAgICAgICAgZXZlbnQuc291cmNlID09IFJFUVVFU1QgPyAiUkVROiIgOiAiUkVTOiIsCi0gICAgICAgICAgICAgICAgICAgIGdldF9sb2NhbF9jYW1lcmFfbWV0YWRhdGFfc2VjdGlvbl9uYW1lX3ZlbmRvcl9pZChldmVudC50YWcsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgbVZlbmRvclRhZ0lkKSwKLSAgICAgICAgICAgICAgICAgICAgZ2V0X2xvY2FsX2NhbWVyYV9tZXRhZGF0YV90YWdfbmFtZV92ZW5kb3JfaWQoZXZlbnQudGFnLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1WZW5kb3JUYWdJZCkpOwotICAgICAgICAgICAgaWYgKGV2ZW50Lm5ld0RhdGEuc2l6ZSgpID09IDApIHsKLSAgICAgICAgICAgICAgICBkcHJpbnRmKGZkLCAiIChSZW1vdmVkKVxuIik7Ci0gICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIHByaW50RGF0YShmZCwgZXZlbnQubmV3RGF0YS5kYXRhKCksIGV2ZW50LnRhZywKLSAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnR5cGUsIGV2ZW50Lm5ld0RhdGEuc2l6ZSgpIC8gY2FtZXJhX21ldGFkYXRhX3R5cGVfc2l6ZVtldmVudC50eXBlXSwKLSAgICAgICAgIC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W5nRXZlbnRzKSB7CisgICAgICAgIGludCBpbmRlbnRhdGlvbiA9IChldmVudC5zb3VyY2UgPT0gUkVRVUVTVCkgPyAxNSA6IDMwOworICAgICAgICBTdHJpbmc4IGV2ZW50U3RyaW5nID0gU3RyaW5nODo6Zm9ybWF0KCJmJWQ6JSIgUFJJZDY0ICJuczolKnMlKnMlcy4lczogIiwKKyAgICAgICAgICAgICAgICBldmVudC5mcmFtZU51bWJlciwgZXZlbnQudGltZXN0YW1wLAorICAgICAgICAgICAgICAgIDIsIGV2ZW50LmNhbWVyYUlkLmNfc3RyKCksCisgICAgICAgICAgICAgICAgaW5kZW50YXRpb24sCisgICAgICAgICAgICAgICAgZXZlbnQuc291cmNlID09IFJFUVVFU1QgPyAiUkVROiIgOiAiUkVTOiIsCisgICAgICAgICAgICAgICAgZ2V0X2xvY2FsX2NhbWVyYV9tZXRhZGF0YV9zZWN0aW9uX25hbWVfdmVuZG9yX2lkKGV2ZW50LnRhZywgbVZlbmRvclRhZ0lkKSwKKyAgICAgICAgICAgICAgICBnZXRfbG9jYWxfY2FtZXJhX21ldGFkYXRhX3RhZ19uYW1lX3ZlbmRvcl9pZChldmVudC50YWcsIG1WZW5kb3JUYWdJZCkpOworICAgICAgICBpZiAoZXZlbnQubmV3RGF0YS5zaXplKCkgPT0gMCkgeworICAgICAgICAgICAgZXZlbnRTdHJpbmcgKz0gIiAoUmVtb3ZlZCkiOworICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgZXZlbnRTdHJpbmcgKz0gZ2V0RXZlbnREYXRhU3RyaW5nKGV2ZW50Lm5ld0RhdGEuZGF0YSgpLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFnLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudHlwZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50Lm5ld0RhdGEuc2l6ZSgpIC8gY2FtZXJhX21ldGFkYXRhX3R5cGVfc2l6ZVtldmVudC50eXBlXSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluZGVudGF0aW9uICsgMTgsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC5vdXRwdXRTdHJlYW1JZHMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC5pbnB1dFN0cmVhbUlkKTsKKyAgICAgICAgfQorICAgICAgICB2ZWMuZW1wbGFjZV9iYWNrKGV2ZW50U3RyaW5nLnN0cmluZygpKTsKKyAgICB9Cit9CiAKICNkZWZpbmUgQ0FNRVJBX01FVEFEQVRBX0VOVU1fU1RSSU5HX01BWF9TSVpFIDI5CiAKLXZvaWQgVGFnTW9uaXRvcjo6cHJpbnREYXRhKGludCBmZCwgY29uc3QgdWludDhfdCAqZGF0YV9wdHIsIHVpbnQzMl90IHRhZywKLSAgICAgICAgaW50IHR5cGUsIGludCBjb3VudCwgaW50IGluZGVudGF0aW9uKSB7CitTdHJpbmc4IFRhZ01vbml0b3I6OmdldEV2ZW50RGF0YVN0cmluZyhjb25zdCB1aW50OF90KiBkYXRhX3B0ciwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVpbnQzMl90IHRhZywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCB0eXBlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IGNvdW50LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IGluZGVudGF0aW9uLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RkOjp1bm9yZGVyZWRfc2V0PGludDMyX3Q+JiBvdXRwdXRTdHJlYW1JZHMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQzMl90IGlucHV0U3RyZWFtSWQpIHsKICAgICBzdGF0aWMgaW50IHZhbHVlc19wZXJfbGluZVtOVU1fVFlQRVNdID0gewogICAgICAgICBbVFlQRV9CWVRFXSAgICAgPSAxNiwKICAgICAgICAgW1RZUEVfSU5UMzJdICAgID0gOCwKQEAgLTI1Myw2ICszMDAsNyBAQAogICAgICAgICBbVFlQRV9ET1VCTEVdICAgPSA0LAogICAgICAgICBbVFlQRV9SQVRJT05BTF0gPSA0LAogICAgIH07CisKICAgICBzaXplX3QgdHlwZV9zaXplID0gY2FtZXJhX21ldGFkYXRhX3R5cGVfc2l6ZVt0eXBlXTsKICAgICBjaGFyIHZhbHVlX3N0cmluZ190bXBbQ0FNRVJBX01FVEFEQVRBX0VOVU1fU1RSSU5HX01BWF9TSVpFXTsKICAgICB1aW50MzJfdCB2YWx1ZTsKQEAgLTI2MCwxMCArMzA4LDExIEBACiAgICAgaW50IGxpbmVzID0gY291bnQgLyB2YWx1ZXNfcGVyX2xpbmVbdHlwZV07CiAgICAgaWYgKGNvdW50ICUgdmFsdWVzX3Blcl9saW5lW3R5cGVdICE9IDApIGxpbmVzKys7CiAKKyAgICBTdHJpbmc4IHJldHVyblN0ciA9IFN0cmluZzgoKTsKICAgICBpbnQgaW5kZXggPSAwOwogICAgIGludCBqLCBrOwogICAgIGZvciAoaiA9IDA7IGogPCBsaW5lczsgaisrKSB7Ci0gICAgICAgIGRwcmludGYoZmQsICIlKnNbIiwgKGogIT0gMCkgPyBpbmRlbnRhdGlvbiArIDQgOiAwLCAiIik7CisgICAgICAgIHJldHVyblN0ci5hcHBlbmRGb3JtYXQoIiUqc1siLCAoaiAhPSAwKSA/IGluZGVudGF0aW9uICsgNCA6IDAsICIiKTsKICAgICAgICAgZm9yIChrID0gMDsKICAgICAgICAgICAgICBrIDwgdmFsdWVzX3Blcl9saW5lW3R5cGVdICYmIGNvdW50ID4gMDsKICAgICAgICAgICAgICBrKyssIGNvdW50LS0sIGluZGV4ICs9IHR5cGVfc2l6ZSkgewpAQCAtMjc2LDEwICszMjUsOSBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZV9zdHJpbmdfdG1wLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplb2YodmFsdWVfc3RyaW5nX3RtcCkpCiAgICAgICAgICAgICAgICAgICAgICAgICA9PSBPSykgewotICAgICAgICAgICAgICAgICAgICAgICAgZHByaW50ZihmZCwgIiVzICIsIHZhbHVlX3N0cmluZ190bXApOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuU3RyICs9IHZhbHVlX3N0cmluZ190bXA7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBkcHJpbnRmKGZkLCAiJWhodSAiLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqKGRhdGFfcHRyICsgaW5kZXgpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIHJldHVyblN0ci5hcHBlbmRGb3JtYXQoIiVoaHUiLCAqKGRhdGFfcHRyICsgaW5kZXgpKTsKICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICBjYXNlIFRZUEVfSU5UMzI6CkBAIC0yOTAsNDkgKzMzOCw1NyBAQAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZV9zdHJpbmdfdG1wLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplb2YodmFsdWVfc3RyaW5nX3RtcCkpCiAgICAgICAgICAgICAgICAgICAgICAgICA9PSBPSykgewotICAgICAgICAgICAgICAgICAgICAgICAgZHByaW50ZihmZCwgIiVzICIsIHZhbHVlX3N0cmluZ190bXApOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuU3RyICs9IHZhbHVlX3N0cmluZ190bXA7CiAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBkcHJpbnRmKGZkLCAiJSIgUFJJZDMyICIgIiwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKihpbnQzMl90KikoZGF0YV9wdHIgKyBpbmRleCkpOworICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuU3RyLmFwcGVuZEZvcm1hdCgiJSIgUFJJZDMyICIgIiwgKihpbnQzMl90KikoZGF0YV9wdHIgKyBpbmRleCkpOwogICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgIGNhc2UgVFlQRV9GTE9BVDoKLSAgICAgICAgICAgICAgICAgICAgZHByaW50ZihmZCwgIiUwLjhmICIsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgKihmbG9hdCopKGRhdGFfcHRyICsgaW5kZXgpKTsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuU3RyLmFwcGVuZEZvcm1hdCgiJTAuOGYiLCAqKGZsb2F0KikoZGF0YV9wdHIgKyBpbmRleCkpOwogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICBjYXNlIFRZUEVfSU5UNjQ6Ci0gICAgICAgICAgICAgICAgICAgIGRwcmludGYoZmQsICIlIiBQUklkNjQgIiAiLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICooaW50NjRfdCopKGRhdGFfcHRyICsgaW5kZXgpKTsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuU3RyLmFwcGVuZEZvcm1hdCgiJSIgUFJJZDY0ICIgIiwgKihpbnQ2NF90KikoZGF0YV9wdHIgKyBpbmRleCkpOwogICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICBjYXNlIFRZUEVfRE9VQkxFOgotICAgICAgICAgICAgICAgICAgICBkcHJpbnRmKGZkLCAiJTAuOGYgIiwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAqKGRvdWJsZSopKGRhdGFfcHRyICsgaW5kZXgpKTsKKyAgICAgICAgICAgICAgICAgICAgcmV0dXJuU3RyLmFwcGVuZEZvcm1hdCgiJTAuOGYgIiwgKihkb3VibGUqKShkYXRhX3B0ciArIGluZGV4KSk7CiAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgIGNhc2UgVFlQRV9SQVRJT05BTDogewogICAgICAgICAgICAgICAgICAgICBpbnQzMl90IG51bWVyYXRvciA9ICooaW50MzJfdCopKGRhdGFfcHRyICsgaW5kZXgpOwogICAgICAgICAgICAgICAgICAgICBpbnQzMl90IGRlbm9taW5hdG9yID0gKihpbnQzMl90KikoZGF0YV9wdHIgKyBpbmRleCArIDQpOwotICAgICAgICAgICAgICAgICAgICBkcHJpbnRmKGZkLCAiKCVkIC8gJWQpICIsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgbnVtZXJhdG9yLCBkZW5vbWluYXRvcik7CisgICAgICAgICAgICAgICAgICAgIHJldHVyblN0ci5hcHBlbmRGb3JtYXQoIiglZCAvICVkKSAiLCBudW1lcmF0b3IsIGRlbm9taW5hdG9yKTsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgIGRlZmF1bHQ6Ci0gICAgICAgICAgICAgICAgICAgIGRwcmludGYoZmQsICI/Pz8gIik7CisgICAgICAgICAgICAgICAgICAgIHJldHVyblN0ciArPSAiPz8/ICI7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KLSAgICAgICAgZHByaW50ZihmZCwgIl1cbiIpOworICAgICAgICByZXR1cm5TdHIgKz0gIl0gIjsKKyAgICAgICAgaWYgKCFvdXRwdXRTdHJlYW1JZHMuZW1wdHkoKSkgeworICAgICAgICAgICAgcmV0dXJuU3RyICs9ICJvdXRwdXQgc3RyZWFtIGlkczogIjsKKyAgICAgICAgICAgIGZvciAoY29uc3QgYXV0byAmaWQgOiBvdXRwdXRTdHJlYW1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ZywKLSAgICAgICAgICAgIGludCB0eXBlLCBpbnQgY291bnQsIGludCBpbmRlbnRhdGlvbik7CisgIHByaXZhdGU6CisgICAgLy8gRHVtcHMgbW9uaXRvcmVkIHRhZyBldmVudHMgdG8gdGhlIHBhc3NlZCB2ZWN0b3Igd2l0aG91dCBhY3F1aXJpbmcKKyAgICAvLyBtTW9uaXRvck11dGV4LiBtTW9uaXRvck11dGV4IG11c3QgYmUgYWNxdWlyZWQgYmVmb3JlIGNhbGxpbmcgdGhpcworICAgIC8vIGZ1bmN0aW9uLgorICAgIHZvaWQgZHVtcE1vbml0b3JlZFRhZ0V2ZW50c1RvVmVjdG9yTG9ja2VkKHN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPiAmb3V0KTsKKworICAgIHN0YXRpYyBTdHJpbmc4IGdldEV2ZW50RGF0YVN0cmluZyhjb25zdCB1aW50OF90ICpkYXRhX3B0ciwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVpbnQzMl90IHRhZywgaW50IHR5cGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgY291bnQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgaW5kZW50YXRpb24sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGQ6OnVub3JkZXJlZF9zZXQ8aW50MzJfdD4gJm91dHB1dFN0cmVhbUlkcywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3QgaW5wdXRTdHJlYW1JZCk7CiAKICAgICB2b2lkIG1vbml0b3JTaW5nbGVNZXRhZGF0YShUYWdNb25pdG9yOjpldmVudFNvdXJjZSBzb3VyY2UsIGludDY0X3QgZnJhbWVOdW1iZXIsCiAgICAgICAgICAgICBuc2Vjc190IHRpbWVzdGFtcCwgY29uc3Qgc3RkOjpzdHJpbmcmIGNhbWVyYUlkLCB1aW50MzJfdC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WFtZXRyaWNzc2VydmljZS1haWRsLWNwcCIsCisgICAgICAgICJwYWNrYWdlbWFuYWdlcl9haWRsLWNwcCIsCiAgICAgXSwKICAgICBoZWFkZXJfbGliczogWwogICAgICAgICAibGliYXVkaW91dGlsc19oZWFkZXJzIiwKQEAgLTE3Miw2ICsxNzMsNyBAQAogICAgICAgICAibGlic3RhdHNwdWxsIiwKICAgICAgICAgImxpYnN0YXRzc29ja2V0IiwKICAgICAgICAgImxpYnV0aWxzIiwKKyAgICAgICAgInBhY2thZ2VtYW5hZ2VyX2FpZGwtY3BwIiwKICAgICBdLAogCiAgICAgZXhwb3J0X3NoYXJlZF9saWJfaGVhZGVyczogWwpAQCAtMTc5LDE1ICsxODEsMjIgQEAKICAgICAgICAgImxpYnN0YXRzc29ja2V0IiwKICAgICBdLAogCisgICAgLy8gd2l0aGluIHRoZSBsaWJyYXJ5LCB3ZSB1c2UgInh4eC5oIgorICAgIGxvY2FsX2luY2x1ZGVfZGlyczogWworICAgICAgICAiaW5jbHVkZS9tZWRpYW1ldHJpY3NzZXJ2aWNlIiwKKyAgICBdLAorCisgICAgLy8gZXh0ZXJuYWwgcGFydGllcyB1c2UgPG1lZGlhbWV0cmljc3NlcnZpY2UveHh4Lmg+CisgICAgZXhwb3J0X2luY2x1ZGVfZGlyczogWworICAgICAgICAiaW5jbHVkZSIsCisgICAgXSwKKwogICAgIHN0YXRpY19saWJzOiBbCiAgICAgICAgICJsaWJwbGF0Zm9ybXByb3RvcyIsCiAgICAgXSwKIAogICAgIGhlYWRlcl9saWJzOiBbCiAgICAgICAgICJsaWJhYXVkaW9faGVhZGVycyIsCi0gICAgXSwKLQotICAgIGluY2x1ZGVfZGlyczogWwotICAgICAgICAic3lzdGVtL21lZGlhL2F1ZGlvX3V0aWxzL2luY2x1ZGUiLAorICAgICAgICAibGliYXVkaW91dGlsc19oZWFkZXJzIiwKICAgICBdLAogfQpkaWZmIC0tZ2l0IGEvc2VydmljZXMvbWVkaWFtZXRyaWNzL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gICAgICAgICAgICAiJXM6ICVzIG1pc3NpbmcgJXMgZmllbGQiLCBfX2Z1bmNfXywKKyAgICAgICAgICAgICAgICBBTUVESUFNRVRSSUNTX0tFWV9QUkVGSVhfQVVESU9fUkVDT1JELCBBTUVESUFNRVRSSUNTX1BST1BfT1JJR0lOQUxGTEFHUyk7CisgICAgICAgIGNvbnN0IGF1dG8gZmxhZ3MgPSB0eXBlczo6bG9va3VwPHR5cGVzOjpJTlBVVF9GTEFHLCBpbnQzMl90PihmbGFnc1N0cik7CisKKyAgICAgICAgLy8gQU1FRElBTUVUUklDU19QUk9QX1NFU1NJT05JRCBvbWl0dGVkIGZyb20gYXRvbQorCisgICAgICAgIHN0ZDo6c3RyaW5nIHNvdXJjZVN0cjsKKyAgICAgICAgQUxPR0RfSUYoIWl0ZW0tPmdldChBTUVESUFNRVRSSUNTX1BST1BfU09VUkNFLCAmc291cmNlU3RyKSwKKyAgICAgICAgICAgICAgICAiJXM6ICVzIG1pc3NpbmcgJXMgZmllbGQiLAorICAgICAgICAgICAgICAgIF9fZnVuY19fLCBBTUVESUFNRVRSSUNTX0tFWV9QUkVGSVhfQVVESU9fUkVDT1JELCBBTUVESUFNRVRSSUNTX1BST1BfU09VUkNFKTsKKyAgICAgICAgY29uc3QgaW50MzJfdCBzb3VyY2UgPSB0eXBlczo6bG9va3VwPHR5cGVzOjpTT1VSQ0VfVFlQRSwgaW50MzJfdD4oc291cmNlU3RyKTsKKworICAgICAgICAvLyBBTUVESUFNRVRSSUNTX1BST1BfU0VMRUNURURERVZJQ0VJRCBvbWl0dGVkIGZyb20gYXRvbQorCisgICAgICAgIHN0ZDo6c3RyaW5nIGVuY29kaW5nU3RyOworICAgICAgICBBTE9HRF9JRighaXRlbS0+Z2V0KEFNRURJQU1FVFJJQ1NfUFJPUF9FTkNPRElORywgJmVuY29kaW5nU3RyKSwKKyAgICAgICAgICAgICAgICAiJXM6ICVzIG1pc3NpbmcgJXMgZmllbGQiLAorICAgICAgICAgICAgICAgIF9fZnVuY19fLCBBTUVESUFNRVRSSUNTX0tFWV9QUkVGSVhfQVVESU9fUkVDT1JELCBBTUVESUFNRVRSSUNTX1BST1BfRU5DT0RJTkcpOworICAgICAgICBjb25zdCBhdXRvIGVuY29kaW5nID0gdHlwZXM6Omxvb2t1cDx0eXBlczo6RU5DT0RJTkcsIGludDMyX3Q+KGVuY29kaW5nU3RyKTsKKworICAgICAgICBpbnQzMl90IGNoYW5uZWxNYXNrID0gMDsKKyAgICAgICAgQUxPR0RfSUYoIWl0ZW0tPmdldChBTUVESUFNRVRSSUNTX1BST1BfQ0hBTk5FTE1BU0ssICZjaGFubmVsTWFzayksCisgICAgICAgICAgICAgICAgIiVzOiAlcyBtaXNzaW5nICVzIGZpZWxkIiwKKyAgICAgICAgICAgICAgICBfX2Z1bmNfXywgQU1FRElBTUVUUklDU19LRVlfUFJFRklYX0FVRElPX1JFQ09SRCwgQU1FRElBTUVUUklDU19QUk9QX0NIQU5ORUxNQVNLKTsKKyAgICAgICAgaW50MzJfdCBmcmFtZUNvdW50ID0gMDsKKyAgICAgICAgQUxPR0RfSUYoIWl0ZW0tPmdldChBTUVESUFNRVRSSUNTX1BST1BfRlJBTUVDT1VOVCwgJmZyYW1lQ291bnQpLAorICAgICAgICAgICAgICAgICIlczogJXMgbWlzc2luZyAlcyBmaWVsZCIsCisgICAgICAgICAgICAgICAgX19mdW5jX18sIEFNRURJQU1FVFJJQ1NfS0VZX1BSRUZJWF9BVURJT19SRUNPUkQsIEFNRURJQU1FVFJJQ1NfUFJPUF9GUkFNRUNPVU5UKTsKKyAgICAgICAgaW50MzJfdCBzYW1wbGVSYXRlID0gMDsKKyAgICAgICAgQUxPR0RfSUYoIWl0ZW0tPmdldChBTUVESUFNRVRSSUNTX1BST1BfU0FNUExFUkFURSwgJnNhbXBsZVJhdGUpLAorICAgICAgICAgICAgICAgICIlczogJXMgbWlzc2luZyAlcyBmaWVsZCIsCisgICAgICAgICAgICAgICAgX19mdW5jX18sIEFNRURJQU1FVFJJQ1NfS0VZX1BSRUZJWF9BVURJT19SRUNPUkQsIEFNRURJQU1FVFJJQ1NfUFJPUF9TQU1QTEVSQVRFKTsKKworICAgICAgICBjb25zdCBhdXRvIFsgcmVzdWx0LCBzdHIgXSA9IHNlbmRUb1N0YXRzZChBdWRpb1JlY29yZFN0YXR1c0ZpZWxkcywKKyAgICAgICAgICAgICAgICBDT05ESVRJT04oYW5kcm9pZDo6dXRpbDo6TUVESUFNRVRSSUNTX0FVRElPUkVDT1JEU1RBVFVTX1JFUE9SVEVEKQorICAgICAgICAgICAgICAgICwgYXRvbV9zdGF0dXMKKyAgICAgICAgICAgICAgICAsIG1lc3NhZ2UuY19zdHIoKQorICAgICAgICAgICAgICAgICwgc3ViQ29kZQorICAgICAgICAgICAgICAgICwgdWlkCisgICAgICAgICAgICAgICAgLCBldmVudAorICAgICAgICAgICAgICAgICwgZmxhZ3MKKyAgICAgICAgICAgICAgICAsIHNvdXJjZQorICAgICAgICAgICAgICAgICwgZW5jb2RpbmcKKyAgICAgICAgICAgICAgICAsIChpbnQ2NF90KWNoYW5uZWxNYXNrCisgICAgICAgICAgICAgICAgLCBmcmFtZUNvdW50CisgICAgICAgICAgICAgICAgLCBzYW1wbGVSYXRlCisgICAgICAgICAgICAgICAgKTsKKyAgICAgICAgQUxPR1YoIiVzOiBzdGF0c2QgJXMiLCBfX2Z1bmNfXywgc3RyLmNfc3RyKCkpOworICAgICAgICBtU3RhdHNkTG9nLT5sb2coYW5kcm9pZDo6dXRpbDo6TUVESUFNRVRSSUNTX0FVRElPUkVDT1JEU1RBVFVTX1JFUE9SVEVELCBzdHIpOworICAgICAgICByZXR1cm4gdHJ1ZTsKKyAgICB9CisgICAgcmV0dXJuIGZhbHNlOworfQorCitib29sIEF1ZGlvQW5hbHl0aWNzOjpyZXBvcnRBdWRpb1RyYWNrU3RhdHVzKAorICAgICAgICBjb25zdCBzdGQ6OnNoYXJlZF9wdHI8Y29uc3QgbWVkaWFtZXRyaWNzO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CIsCisgICAgICAgICAgICAgICAgX19mdW5jX18sIEFNRURJQU1FVFJJQ1NfS0VZX1BSRUZJWF9BVURJT19UUkFDSywgQU1FRElBTUVUUklDU19QUk9QX1VTQUdFKTsKKyAgICAgICAgY29uc3QgYXV0byB1c2FnZSA9IHR5cGVzOjpsb29rdXA8dHlwZXM6OlVTQUdFLCBpbnQzMl90Pih1c2FnZVN0cik7CisKKyAgICAgICAgLy8gQU1FRElBTUVUUklDU19QUk9QX1NFTEVDVEVEREVWSUNFSUQgb21pdHRlZCBmcm9tIGF0b20KKworICAgICAgICBzdGQ6OnN0cmluZyBlbmNvZGluZ1N0cjsKKyAgICAgICAgQUxPR0RfSUYoIWl0ZW0tPmdldChBTUVESUFNRVRSSUNTX1BST1BfRU5DT0RJTkcsICZlbmNvZGluZ1N0ciksCisgICAgICAgICAgICAgICAgIiVzOiAlcyBtaXNzaW5nICVzIGZpZWxkIiwKKyAgICAgICAgICAgICAgICBfX2Z1bmNfXywgQU1FRElBTUVUUklDU19LRVlfUFJFRklYX0FVRElPX1RSQUNLLCBBTUVESUFNRVRSSUNTX1BST1BfRU5DT0RJTkcpOworICAgICAgICBjb25zdCBhdXRvIGVuY29kaW5nID0gdHlwZXM6Omxvb2t1cDx0eXBlczo6RU5DT0RJTkcsIGludDMyX3Q+KGVuY29kaW5nU3RyKTsKKworICAgICAgICBpbnQzMl90IGNoYW5uZWxNYXNrID0gMDsKKyAgICAgICAgQUxPR0RfSUYoIWl0ZW0tPmdldChBTUVESUFNRVRSSUNTX1BST1BfQ0hBTk5FTE1BU0ssICZjaGFubmVsTWFzayksCisgICAgICAgICAgICAgICAgIiVzOiAlcyBtaXNzaW5nICVzIGZpZWxkIiwKKyAgICAgICAgICAgICAgICBfX2Z1bmNfXywgQU1FRElBTUVUUklDU19LRVlfUFJFRklYX0FVRElPX1RSQUNLLCBBTUVESUFNRVRSSUNTX1BST1BfQ0hBTk5FTE1BU0spOworICAgICAgICBpbnQzMl90IGZyYW1lQ291bn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ElBTUVUUklDU19QUk9QX1BMQVlCQUNLX1BJVENILCAmcGl0Y2gpLAorICAgICAgICAgICAgICAgICIlczogJXMgbWlzc2luZyAlcyBmaWVsZCIsCisgICAgICAgICAgICAgICAgX19mdW5jX18sCisgICAgICAgICAgICAgICAgQU1FRElBTUVUUklDU19LRVlfUFJFRklYX0FVRElPX1RSQUNLLCBBTUVESUFNRVRSSUNTX1BST1BfUExBWUJBQ0tfUElUQ0gpOworICAgICAgICBjb25zdCBhdXRvIFsgcmVzdWx0LCBzdHIgXSA9IHNlbmRUb1N0YXRzZChBdWRpb1RyYWNrU3RhdHVzRmllbGRzLAorICAgICAgICAgICAgICAgIENPTkRJVElPTihhbmRyb2lkOjp1dGlsOjpNRURJQU1FVFJJQ1NfQVVESU9UUkFDS1NUQVRVU19SRVBPUlRFRCkKKyAgICAgICAgICAgICAgICAsIGF0b21fc3RhdHVzCisgICAgICAgICAgICAgICAgLCBtZXNzYWdlLmNfc3RyKCkKKyAgICAgICAgICAgICAgICAsIHN1YkNvZGUKKyAgICAgICAgICAgICAgICAsIHVpZAorICAgICAgICAgICAgICAgICwgZXZlbnQKKyAgICAgICAgICAgICAgICAsIGZsYWdzCisgICAgICAgICAgICAgICAgLCBjb250ZW50VHlwZQorICAgICAgICAgICAgICAgICwgdXNhZ2UKKyAgICAgICAgICAgICAgICAsIGVuY29kaW5nCisgICAgICAgICAgICAgICAgLCAoaW50NjRfdCljaGFubmVsTWFzaworICAgICAgICAgICAgICAgICwgZnJhbWVDb3VudAorICAgICAgICAgICAgICAgICwgc2FtcGxlUmF0ZQorICAgICAgICAgICAgICAgICwgKGZsb2F0KXNwZWVkCisgICAgICAgICAgICAgICAgLCAoZmxvYXQpcGl0Y2gKKyAgICAgICAgICAgICAgICApOworICAgICAgICBBTE9HVigiJXM6IHN0YXRzZCAlcyIsIF9fZnVuY19fLCBzdHIuY19zdHIoKSk7CisgICAgICAgIG1TdGF0c2RMb2ctPmxvZyhhbmRyb2lkOjp1dGlsOjpNRURJQU1FVFJJQ1NfQVVESU9UUkFDS1NUQVRVU19SRVBPUlRFRCwgc3RyKTsKKyAgICAgICAgcmV0dXJuIHRydWU7CisgICAgfQorICAgIHJldHVybiBmYWxzZTsKIH0KIAogLy8gSEVMUEVSIE1FVEhPRFMKQEAgLTEwNTYsMTAgKzEyNDgsMTAgQEAKICAgICAgICAgaWYgKGNoYW5uZWxNYXNrICE9IDApIHsKICAgICAgICAgICAgIHN3aXRjaCAoZGlyZWN0aW9uKSB7CiAgICAgICAgICAgICAgICAgY2FzZSAxOiAvLyBPdXRwdXQsIGtlZXAgc3luYyB3aXRoIEF1ZGlvVHlwZXMjZ2V0QUF1ZGlvRGlyZWN0aW9uKCkKLSAgICAgICAgICAgICAgICAgICAgY2hhbm5lbENvdW50ID0gYXVkaW9fY2hhbm5lbF9jb3VudF9mcm9tX291dF9tYXNrKGNoYW5uZWxNYXNrKTsKKyAgICAgICAgICAgICAgICAgICAgY2hhbm5lbENvdW50ID0gKGludDMyX3QpYXVkaW9fY2hhbm5lbF9jb3VudF9mcm9tX291dF9tYXNrKGNoYW5uZWxNYXNrKTsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgY2FzZSAyOiAvLyBJbnB1dCwga2VlcCBzeW5jIHdpdGggQXVkaW9UeXBlcyNnZXRBQXVkaW9EaXJlY3Rpb24oKQotICAgICAgICAgICAgICAgICAgICBjaGFubmVsQ291bnQgPSBhdWRpb19jaGFubmVsX2NvdW50X2Zyb21faW5fbWFzayhjaGFubmVsTWFzayk7CisgICAgICAgICAgICAgICAgICAgIGNoYW5uZWxDb3VudCA9IChpbnQzMl90KWF1ZGlvX2NoYW5uZWxfY291bnRfZnJvbV9pbl9tYXNrKGNoYW5uZWxNYXNrKTsKICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgQUxPR1coIkludmFsaWQgZGlyZWN0aW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ICAgbVNpbXBsZUxvZy5sb2coIkF1ZGlvRmxpbmdlciBjdG9yIik7CisgICAgICAgIH0KKyAgICAgICAgbUF1ZGlvQW5hbHl0aWNzLm5ld1N0YXRlKCk7CisgICAgICAgIHJldHVybjsKKyAgICB9CisgICAgaWYgKG1vZHVsZSA9PSBNb2R1bGU6OkFVRElPUE9MSUNZKSB7CisgICAgICAgIC8vIEEgc3RhcnQgZXZlbnQgb2NjdXJzIHdoZW4gYXVkaW9zZXJ2ZXIKKyAgICAgICAgLy8KKyAgICAgICAgLy8gKDEpIFN0YXJ0cyB0aGUgZmlyc3QgdGltZQorICAgICAgICAvLyAoMikgUmVzdGFydHMgYmVjYXVzZSBvZiB0aGUgVGltZUNoZWNrIHdhdGNoZG9nCisgICAgICAgIC8vICgzKSBSZXN0YXJ0cyBub3QgYmVjYXVzZSBvZiB0aGUgVGltZUNoZWNrIHdhdGNoZG9nLgorICAgICAgICBpbnQ2NF90IGV4ZWN1dGlvblRpbWVOcyA9IDA7CisgICAgICAgICh2b2lkKWl0ZW0tPmdldChBTUVESUFNRVRSSUNTX1BST1BfRVhFQ1VUSU9OVElNRU5TLCAmZXhlY3V0aW9uVGltZU5zKTsKKyAgICAgICAgY29uc3QgZmxvYXQgbG9hZFRpbWVNcyA9IGV4ZWN1dGlvblRpbWVOcyAqIDFlLTZmOworICAgICAgICBzdGQ6OmxvY2tfZ3VhcmQgbGcobUxvY2spOworICAgICAgICBjb25zdCBpbnQ2NF90IHJlc3RhcnRzID0gbVN0YXJ0Q291bnQ7CisgICAgICAgIGlmIChtU3RvcENvdW50ID09IG1TdGFydENvdW50KSB7CisgICAgICAgICAgICBtQXVkaW9Qb2xpY3lDdG9yVGltZSA9IG5vd1RpbWU7CisgICAgICAgICAgICArK21TdGFydENvdW50OworICAgICAgICAgICAgaWYgKG1TdG9wQ291bnQgPT0gMCkgeworICAgICAgICAgICAgICAgIC8vICgxKSBGaXJzdCB0aW1lIGluaXRpYWxpemF0aW9uLgorICAgICAgICAgICAgICAgIEFMT0dXKCIlczogKGtleT0lcykgQXVkaW9Qb2xpY3kgY3RvciwgbG9hZFRpbWVNczolZiIsCisgICAgICAgICAgICAgICAgICAgICAgICBfX2Z1bmNfXywgaXRlbS0+Z2V0S2V5KCkuY19zdHIoKSwgbG9hZFRpbWVNcyk7CisgICAgICAgICAgICAgICAgbVNpbXBsZUxvZy5sb2coIkF1ZGlvUG9saWN5IGN0b3IsIGxvYWRUaW1lTXM6JWYiLCBsb2FkVGltZU1zKTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgLy8gKDIpIFByZXZpb3VzIGZhaWx1cmUgY2F1Z2h0IGR1ZSB0byBUaW1lQ2hlY2suICBXZSBrbm93IGhvdyBsb25nIHJlc3RhcnQgdGFrZXMuCisgICAgICAgICAgICAgICAgY29uc3QgZmxvYXQgcmVzdGFydE1zID0KKyAgICAgICAgICAgICAgICAgICAgICAgIHN0ZDo6Y2hyb25vOjpkdXJhdGlvbl9jYXN0PHN0ZDo6Y2hyb25vOjpkdXJhdGlvbjxmbG9hdCwgc3RkOjptaWxsaT4+KAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtQXVkaW9GbGluZ2VyQ3RvclRpbWUgLSBtU3RvcFRpbWUpLmNvdW50KCk7CisgICAgICAgICAgICAgICAgQUxPR1coIiVzOiAoa2V5PSVzKSBBdWRpb1BvbGljeSBjdG9yLCAiCisgICAgICAgICAgICAgICAgICAgICAgICAicmVzdGFydHM6JWxsZCByZXN0YXJ0TXM6JWYgbG9hZFRpbWVNczolZiIsCisgICAgICAgICAgICAgICAgICAgICAgICBfX2Z1bmNfXywgaXRlbS0+Z2V0S2V5KCkuY19zdHIoKSwKKyAgICAgICAgICAgICAgICAgICAgICAgIChsb25nIGxvbmcpcmVzdGFydHMsIHJlc3RhcnRNcywgbG9hZFRpbWVNcyk7CisgICAgICAgICAgICAgICAgbVNpbXBsZUxvZy5sb2coIkF1ZGlvUG9saWN5IGN0b3IgcmVzdGFydHM6JWxsZCByZXN0YXJ0TXM6JWYgbG9hZFRpbWVNczolZiIsCisgICAgICAgICAgICAgICAgICAgICAgICAobG9uZyBsb25nKXJlc3RhcnRzLCByZXN0YXJ0TXMsIGxvYWRUaW1lTXMpOworICAgICAgICAgICAgfQorICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgLy8gKDMpIFByZXZpb3VzIGZhaWx1cmUgaXMgTk9UIGR1ZSB0byBUaW1lQ2hlY2ssIHNvIHdlIGRvbid0IGtub3cgdGhlIHJlc3RhcnQgdGltZS4KKyAgICAgICAgICAgIC8vIEhvd2V2ZXIgd2UgY2FuIGVzdGltYXRlIHRoZSB1cHRpbWUgZnJvbSB0aGUgZGVsdGEgdGltZSBmcm9tIHByZXZpb3VzIGN0b3IuCisgICAgICAgICAgICBjb25zdCBmbG9hdCB1cHRpbWVNcyA9CisgICAgICAgICAgICAgICAgICAgIHN0ZDo6Y2hyb25vOjpkdXJhdGlvbl9jYXN0PHN0ZDo6Y2hyb25vOjpkdXJhdGlvbjxmbG9hdCwgc3RkOjptaWxsaT4+KAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vd1RpbWUgLSBtQXVkaW9GbGluZ2VyQ3RvclRpbWUpLmNvdW50KCk7CisgICAgICAgICAgICBtU3RvcENvdW50ID0gbVN0YXJ0Q291bnQ7CisgICAgICAgICAgICBtQXVkaW9Qb2xpY3lDdG9yVGltZSA9IG5vd1RpbWU7CisgICAgICAgICAgICArK21TdGFydENvdW50OworCisgICAgICAgICAgICBBTE9HVygiJXM6IChrZXk9JXMpIEF1ZGlvUG9saWN5IGN0b3IgYWZ0ZXIgdW5jYXVnaHQgZmFpbHVyZSwgIgorICAgICAgICAgICAgICAgICAgICAibVN0YXJ0Q291bnQ6JWxsZCBtU3RvcENvdW50OiVsbGQgdXB0aW1lTXM6JWYgbG9hZFRpbWVNczolZiIsCisgICAgICAgICAgICAgICAgICAgIF9fZnVuY19fLCBpdGVtLT5nZXRLZXk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SwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZHVyYXRpb25fc2VjcywKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXZlcmFnZV92b2x1bWUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoZmxvYXQpdm9sdW1lLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5fdm9sdW1lX2R1cmF0aW9uX3NlY3MsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChmbG9hdCltaW5fdm9sdW1lLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXhfdm9sdW1lX2R1cmF0aW9uX3NlY3MsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChmbG9hdCltYXhfdm9sdW1lKTsKIAogICAgIHN0ZDo6c3RyaW5nc3RyZWFtIGxvZzsKICAgICBsb2cgPDwgInJlc3VsdDoiIDw8IHJlc3VsdCA8PCAiIHsiCkBAIC0xNTUsMTcgKzE4MCw0MyBAQAogICAgICAgICAgICAgPDwgYW5kcm9pZDo6dXRpbDo6QVVESU9fUE9XRVJfVVNBR0VfREFUQV9SRVBPUlRFRAogICAgICAgICAgICAgPDwgIiBhdWRpb19kZXZpY2U6IiA8PCBhdWRpb19kZXZpY2UKICAgICAgICAgICAgIDw8ICIgZHVyYXRpb25fc2VjczoiIDw8IGR1cmF0aW9uX3NlY3MKLSAgICAgICAgICAgIDw8ICIgYXZlcmFnZV92b2x1bWU6IiA8PCBhdmVyYWdlX3ZvbHVtZQorICAgICAgICAgICAgPDwgIiBhdmVyYWdlX3ZvbHVtZToiIDw8IChmbG9hdCl2b2x1bWUKICAgICAg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V2aWNlLCB0eXBlLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAobG9uZyBsb25nKWR1cmF0aW9uX25zLCBhdmVyYWdlX3ZvbCApOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAobG9uZyBsb25nKWR1cmF0aW9uX25zLCBhdmVyYWdlX3ZvbCk7CiAgICAgaWYgKGR1cmF0aW9uX25zID09IDApIHsKICAgICAgICAgcmV0dXJuIHRydWU7IC8vIHNraXAgZHVyYXRpb24gMCB1c2FnZQogICAgIH0KQEAgLTE5MywxMCArMjQ0LDM2IEBACiAgICAgICAgICAgICBpdGVtLT5zZXREb3VibGUoQVVESU9fUE9XRVJfVVNBR0VfUFJPUF9WT0xVTUUsIGZpbmFsX3ZvbHVtZSk7CiAgICAgICAgICAgICBpdGVtLT5zZXRUaW1lc3RhbXAoc3lzdGVtVGltZShTWVNURU1fVElNRV9SRUFMVElNRSkpOwogCi0gICAgICAgICAgICBBTE9HVigiJXM6IHVwZGF0ZSAoJSN4LCAlZCwgJWxsZCwgJWYpIC0tPiAoJWxsZCwgJWYpIiwgX19mdW5jX18sCisgICAgICAgICAgICAvLyBVcGRhdGUgdGhlIG1heC9taW4gdm9sdW1lIGFuZCBkdXJhdGlvbgorICAgICAgICAgICAgaW50NjRfdCBmaW5hbF9taW5fdm9sdW1lX2R1cmF0aW9uX25zOworICAgICAgICAgICAgaW50NjRfdCBmaW5hbF9tYXhfdm9sdW1lX2R1cmF0aW9uX25zOworICAgICAgICAgICAgZG91YmxlIGZpbmFsX21pbl92b2x1bWU7CisgICAgICAgICAgICBkb3VibGUgZmluYWxfbWF4X3ZvbHVtZTsKKworICAgICAgICAgICAgaXRlbS0+Z2V0SW50NjQoQVVESU9fUE9XRVJfVVNBR0VfUFJPUF9NSU5fVk9MVU1FX0RVUkFUSU9OX05TLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgJmZpbmFsX21pbl92b2x1bWVfZHVyYXRpb25fbnMpOworICAgICAgICAgICAgaXRlbS0+Z2V0RG91YmxlKEFVRElPX1BPV0VSX1VTQUdFX1BST1BfTUlOX1ZPTFVNRSwgJmZpbmFsX21pbl92b2x1bWUpOworICAgICAgICAgICAgaXRlbS0+Z2V0SW50NjQoQVVESU9fUE9XRVJfVVNBR0VfUFJPUF9NQVhfVk9MVU1FX0RVUkFUSU9OX05TLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgJmZpbmFsX21heF92b2x1bWVfZHVyYXRpb25fbnMpOworICAgICAgICAgICAgaXRlbS0+Z2V0RG91YmxlKEFVRElPX1BPV0VSX1VTQUdFX1BST1BfTUFYX1ZPTFVNRSwgJmZpbmFsX21heF92b2x1bWUpOworICAgICAgICAgICAgdXBkYXRlTWluTWF4Vm9sdW1lQW5kRHVyYXRpb24obWF4X3ZvbHVtZV9kdXJhdGlvbl9ucywgbWF4X3ZvbHVtZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbl92b2x1bWVfZHVyYXRpb25fbnMsIG1pbl92b2x1bWUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaW5hbF9tYXhfdm9sdW1lX2R1cmF0aW9uX25zLCBmaW5hbF9tYXhfdm9sdW1lLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmluYWxfbWluX3ZvbHVtZV9kdXJhdGlvbl9ucywgZmluYWxfbWluX3ZvbHVtZSk7CisgICAgICAgICAgICBpdGVtLT5zZXRJbnQ2NChBVURJT19QT1dFUl9VU0FHRV9QUk9QX01JTl9WT0xVTUVfRFVSQVRJT05fTlMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICBmaW5hbF9taW5fdm9sdW1lX2R1cmF0aW9uX25zKTsKKyAgICAgICAgICAgIGl0ZW0tPnNldERvdWJsZShBVURJT19QT1dFUl9VU0FHRV9QUk9QX01JTl9WT0xVTUUsIGZpbmFsX21pbl92b2x1bWUpOworICAgICAgICAgICAgaXRlbS0+c2V0SW50NjQoQVVESU9fUE9XRVJfVVNBR0VfUFJPUF9NQVhfVk9MVU1FX0RVUkFUSU9OX05TLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgZmluYWxfbWF4X3ZvbHVtZV9kdXJhdGlvbl9ucyk7CisgICAgICAgICAgICBpdGVtLT5zZXREb3VibGUoQVVESU9fUE9XRVJfVVNBR0VfUFJPUF9NQVhfVk9MVU1FLCBmaW5hbF9tYXhfdm9sdW1lKTsKKworICAgICAgICAgICAgQUxPR1YoIiVzOiB1cGRhdGUgKCUjeCwgJWQsICVsbGQsICVmKSAtLT4gKCVsbGQsICVmKSBtaW4oJWxsZCwgJWYpIG1heCglbGxkLCAlZikiLAorICAgICAgICAgICAgICAgICAgX19mdW5jX18sCiAgICAgICAgICAgICAgICAgICBkZXZpY2UsIHR5cGUsCiAgICAgICAgICAgICAgICAgICAobG9uZyBsb25nKWl0ZW1fZHVyYXRpb25fbnMsIGl0ZW1fdm9sdW1lLAotICAgICAgICAgICAgICAgICAgKGxvbmcgbG9uZylmaW5hbF9kdXJhdGlvbl9ucywgZmluYWxfdm9sdW1lKTsKKyAgICAgICAgICAgICAgICAgIChsb25nIGxvbmcpZmluYWxfZHVyYXRpb25fbnMsIGZpbmFsX3ZvbHVtZSwKKyAgICAgICAgICAgICAgICAgIChsb25nIGxvbmcpZmluYWxfbWluX3ZvbHVtZV9kdXJhdGlvbl9ucywgZmluYWxfbWluX3ZvbHVtZSwKKyAgICAgICAgICAgICAgICAgIChsb25nIGxvbmcpZmluYWxfbWF4X3ZvbHVtZV9kdXJhdGlvbl9ucywgZmluYWxfbWF4X3ZvbHVtZSk7CiAKICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICB9CkBAIC0yMDgsMTIgKzI4NSwxOCBAQAogICAgIHNpdGVtLT5zZXRJbnQ2NChBVURJT19QT1dFUl9VU0FHRV9QUk9QX0RVUkFUSU9OX05TLCBkdXJhdGlvbl9ucyk7CiAgICAgc2l0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PmdldERvdWJsZShBTUVESUFNRVRSSUNTX1BST1BfREVWSUNFVk9MVU1FLCAmZGV2aWNlVm9sdW1lKSkgewotICAgICAgICByZXR1cm47CisgICAgaW50NjRfdCBtYXhWb2x1bWVEdXJhdGlvbk5zID0gMDsKKyAgICBkb3VibGUgbWF4Vm9sdW1lID0gQU1FRElBTUVUUklDU19JTklUSUFMX01BWF9WT0xVTUU7CisgICAgaW50NjRfdCBtaW5Wb2x1bWVEdXJhdGlvbk5zID0gMDsKKyAgICBkb3VibGUgbWluVm9sdW1lID0gQU1FRElBTUVUUklDU19JTklUSUFMX01JTl9WT0xVTUU7CisgICAgaWYgKGlzVHJhY2spIHsKKyAgICAgICAgaWYgKCFpdGVtLT5nZXREb3VibGUoQU1FRElBTUVUUklDU19QUk9QX0RFVklDRVZPTFVNRSwgJmRldmljZVZvbHVtZSkpIHsKKyAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgfQorICAgICAgICBpZiAoIWl0ZW0tPmdldEludDY0KEFNRURJQU1FVFJJQ1NfUFJPUF9ERVZJQ0VNQVhWT0xVTUVEVVJBVElPTk5TLCAmbWF4Vm9sdW1lRHVyYXRpb25OcykpIHsKKyAgICAgICAgICAgIHJldHVybjsKKyAgICAgICAgfQorICAgICAgICBpZiAoIWl0ZW0tPmdldERvdWJsZShBTUVESUFNRVRSSUNTX1BST1BfREVWSUNFTUFYVk9MVU1FLCAmbWF4Vm9sdW1lKSkgeworICAgICAgICAgICAgcmV0dXJuOworICAgICAgICB9CisgICAgICAgIGlmICghaXRlbS0+Z2V0SW50NjQoQU1FRElBTUVUUklDU19QUk9QX0RFVklDRU1JTlZPTFVNRURVUkFUSU9OTlMsICZtaW5Wb2x1bWVEdXJhdGlvbk5zKSkgeworICAgICAgICAgICAgcmV0dXJuOworICAgICAgICB9CisgICAgICAgIGlmICghaXRlbS0+Z2V0RG91YmxlKEFNRURJQU1FVFJJQ1NfUFJPUF9ERVZJQ0VNSU5WT0xVTUUsICZtaW5Wb2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ICAgICAgc2VydmljZS0+bm90aWZ5UmVzb3VyY2VHcmFudGVkKHBpZCwgSU1lZGlhUmVzb3VyY2VNb25pdG9yOjpUWVBFX0FVRElPX0NPREVDKTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSBNZWRpYVJlc291cmNlOjpTdWJUeXBlOjprVmlkZW9Db2RlYzoKKyAgICAgICAgICAgICAgICAgICAgc2VydmljZS0+bm90aWZ5UmVzb3VyY2VHcmFudGVkKHBpZCwgSU1lZGlhUmVzb3VyY2VNb25pdG9yOjpUWVBFX1ZJREVPX0NPREVDKTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSBNZWRpYVJlc291cmNlOjpTdWJUeXBlOjprSW1hZ2VDb2RlYzoKKyAgICAgICAgICAgICAgICAgICAgc2VydmljZS0+bm90aWZ5UmVzb3VyY2VHcmFudGVkKHBpZCwgSU1lZGlhUmVzb3VyY2VNb25pdG9yOjpUWVBFX0lNQUdFX0NPREVDKTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSBNZWRpYVJlc291cmNlOjpTdWJUeXBlOjprVW5zcGVjaWZpZWRTdWJUeXBlOgorICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgIH0KIH0KIAotYmluZGVyX3N0YXR1c190IFJlc291cmNlTWFuYWdlclNlcnZpY2U6OmR1bXAoCi0gICAgICAgIGludCBmZCwgY29uc3QgY2hhcioqIC8qYXJncyovLCB1aW50MzJfdCAvKm51bUFyZ3MqLykgeworYmluZGVyX3N0YXR1c190IFJlc291cmNlTWFuYWdlclNlcnZpY2U6OmR1bXAoaW50IGZkLCBjb25zdCBjaGFyKiogLyphcmdzKi8sIHVpbnQzMl90IC8qbnVtQXJncyovKSB7CiAgICAgU3RyaW5nOCByZXN1bHQ7CiAKICAgICBpZiAoY2hl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SBpZiAodHlwZSA9PSBNZWRpYVJlc291cmNlOjpUeXBlOjprR3JhcGhpY01lbW9yeSkgewotICAgICAgICAgICAgICAgIGdyYXBoaWNNZW1vcnkgPSAmcmVzb3VyY2VzW2ldOwotICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlID09IE1lZGlhUmVzb3VyY2U6OlR5cGU6OmtEcm1TZXNzaW9uKSB7Ci0gICAgICAgICAgICAgICAgZHJtU2Vzc2lvbiA9ICZyZXNvdXJjZXNbaV07CisgICAgICAgICAgICBzd2l0Y2ggKHJlc291cmNlc1tpXS50eXBlKSB7CisgICAgICAgICAgICAgICAgY2FzZSBNZWRpYVJlc291cmNlOjpUeXBlOjprU2VjdXJlQ29kZWM6CisgICAgICAgICAgICAgICAgICAgIHNlY3VyZUNvZGVjID0gJnJlc291cmNlc1tpXTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSBNZWRpYVJlc291cmNlOjpUeXBlOjprTm9uU2VjdXJlQ29kZWM6CisgICAgICAgICAgICAgICAgICAgIG5vblNlY3VyZUNvZGVjID0gJnJlc291cmNlc1tpXTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSBNZWRpYVJlc291cmNlOjpUeXBlOjprR3JhcGhpY01lbW9yeToKKyAgICAgICAgICAgICAgICAgICAgZ3JhcGhpY01lbW9yeSA9ICZyZXNvdXJjZXNbaV07CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgTWVkaWFSZXNvdXJjZTo6VHlwZTo6a0RybVNlc3Npb246CisgICAgICAgICAgICAgICAgICAgIGRybVNlc3Npb24gPSAmcmVzb3VyY2VzW2ldOworICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogCiAgICAgICAgIC8vIGZpcnN0IHBhc3MgdG8gaGFuZGxlIHNlY3VyZS9ub24tc2VjdXJlIGNvZGVjIGNvbmZsaWN0CiAgICAgICAgIGlmIChzZWN1cmVDb2RlYyAhPSBOVUxMKSB7CiAgICAgICAgICAgICBpZiAoIW1TdXBwb3J0c011bHRpcGxlU2VjdXJlQ29kZWNzKSB7Ci0gICAgICAgICAgICAgICAgaWYgKCFnZXRBbGxDbGllbnRzX2woY2FsbGluZ1BpZCwgTWVkaWFSZXNvdXJjZTo6VHlwZTo6a1NlY3VyZUNvZGVjLCAmY2xpZW50cykpIHsKKyAgICAgICAgICAgICAgICBpZiAoIWdldEFsbENsaWVudHNfbChjYWxsaW5nUGlkLCBNZWRpYVJlc291cmNlOjpUeXBlOjprU2VjdXJlQ29kZWMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VjdXJlQ29kZWMtPnN1YlR5cGUsICZjbGllbnRzKSkgewogICAgICAgICAgICAgICAgICAgICByZXR1cm4gU3RhdHVzOjpvaygpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KICAgICAgICAgICAgIGlmICghbVN1cHBvcnRzU2VjdXJlV2l0aE5vblNlY3VyZUNvZGVjKSB7Ci0gICAgICAgICAgICAgICAgaWYgKCFnZXRBbGxDbGllbnRzX2woY2FsbGluZ1BpZCwgTWVkaWFSZXNvdXJjZTo6VHlwZTo6a05vblNlY3VyZUNvZGVjLCAmY2xpZW50cykpIHsKKyAgICAgICAgICAgICAgICBpZiAoIWdldEFsbENsaWVudHNfbChjYWxsaW5nUGlkLCBNZWRpYVJlc291cmNlOjpUeXBlOjprTm9uU2VjdXJlQ29kZWMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VjdXJlQ29kZWMtPnN1YlR5cGUsICZjbGllbnRzKSkgewogICAgICAgICAgICAgICAgICAgICByZXR1cm4gU3RhdHVzOjpvaygpOwogICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgICAgICBpZiAobm9uU2VjdXJlQ29kZWMgIT0gTlVMTCkgewogICAgICAgICAgICAgaWYgKCFtU3VwcG9ydHNTZWN1cmVXaXRoTm9uU2VjdXJlQ29kZWMpIHsKLSAgICAgICAgICAgICAgICBpZiAoIWdldEFsbENsaWVudHNfbChjYWxsaW5nUGlkLCBNZWRpYVJlc291cmNlOjpUeXBlOjprU2VjdXJlQ29kZWMsICZjbGllbnRzKSkgeworICAgICAgICAgICAgICAgIGlmICghZ2V0QWxsQ2xpZW50c19sKGNhbGxpbmdQaWQsIE1lZGlhUmVzb3VyY2U6OlR5cGU6OmtTZWN1cmVDb2RlYywKKyAgICAgICAgICAgICAgICAgICAgICAgIG5vblNlY3VyZUNvZGVjLT5zdWJUeXBlLCAmY2xpZW50cykpIHsKICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFN0YXR1czo6b2soKTsKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CkBAIC02NzEsMjEgKzY5NiwyMSBAQAogICAgICAgICBpZiAoY2xpZW50cy5zaXplKCkgPT0gMCkgewogICAgICAgICAgICAgLy8gaWYgd2UgYXJlIGhlcmUsIHJ1biB0aGUgZm91cnRoIHBhc3MgdG8gZnJlZSBvbmUgY29kZWMgd2l0aCB0aGUgZGlmZmVyZW50IHR5cGUuCiAgICAgICAgICAgICBpZiAoc2VjdXJlQ29kZWMgIT0gTlVMTCkgewotICAgICAgICAgICAgICAgIE1lZGlhUmVzb3VyY2UgdGVtcChNZWRpYVJlc291cmNlOjpUeXBlOjprTm9uU2VjdXJlQ29kZWMsIDEpOworICAgICAgICAgICAgICAgIE1lZGlhUmVzb3VyY2UgdGVtcChNZWRpYVJlc291cmNlOjpUeXBlOjprTm9uU2VjdXJlQ29kZWMsIHNlY3VyZUNvZGVjLT5zdWJUeXBlLCAxKTsKICAgICAgICAgICAgICAgICBnZXRDbGllbnRGb3JSZXNvdXJjZV9sKGNhbGxpbmdQaWQsICZ0ZW1wLCAmY2xpZW50cyk7CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBpZiAobm9uU2VjdXJlQ29kZWMgIT0gTlVMTCkgewotICAgICAgICAgICAgICAgIE1lZGlhUmVzb3VyY2UgdGVtcChNZWRpYVJlc291cmNlOjpUeXBlOjprU2VjdXJlQ29kZWMsIDEpOworICAgICAgICAgICAgICAgIE1lZGlhUmVzb3VyY2UgdGVtcChNZWRpYVJlc291cmNlOjpUeXBlOjprU2VjdXJlQ29kZWMsIG5vblNlY3VyZUNvZGVjLT5zdWJUeXBlLCAxKTsKICAgICAgICAgICAgICAgICBnZXRDbGllbnRGb3JSZXNvdXJjZV9sKGNhbGxpbmdQaWQsICZ0ZW1wLCAmY2xpZW50cyk7CiAgICAgICAgICAgICB9CiAgICAgICAgIH0KICAgICB9CiAKLSAgICAqX2FpZGxfcmV0dXJuID0gcmVjbGFpbUludGVybmFsKGNsaWVudHMpOworICAgICpfYWlkbF9yZXR1cm4gPSByZWNsYWltVW5jb25kaXRpb25hbGx5RnJvbShjbGllbnRzKTsKICAgICByZXR1cm4gU3RhdHVzOjpvaygpOwogfQogCi1ib29sIFJlc291cmNlTWFuYWdlclNlcnZpY2U6OnJlY2xhaW1JbnRlcm5hbCgKK2Jvb2wgUmVzb3VyY2VNYW5hZ2VyU2VydmljZTo6cmVjbGFpbVVuY29uZGl0aW9uYWxseUZyb20oCiAgICAgICAgIGNvbnN0IFZlY3RvcjxzdGQ6OnNoYXJlZF9wdHI8SVJlc291cmNlTWFuYWdlckNsaWVudD4+ICZjbGllbnRzKSB7CiAgICAgaWYgKGNsaWVudHMuc2l6ZSgpID09IDApIHsKICAgICAgICAgcmV0dXJuIGZhbHNlOwpAQCAtNzA3LDYgKzczMiw3IEBACiAgICAgICAgIHJldHVybiB0cnVlOwogICAgIH0KIAorICAgIGludCBmYWlsZWRDbGllbnRQaWQgPSAtMTsKICAgICB7CiAgICAgICAgIE11dGV4OjpBdXRvbG9jayBsb2NrKG1Mb2NrKTsKICAgICAgICAgYm9vbCBmb3VuZCA9IGZhbHNlOwpAQCAtNzIxLDIwICs3NDcsMjEgQEAKICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBpZiAoZm91bmQpIHsKKyAgICAgICAgICAgICAgICBmYWlsZWRDbGllbnRQaWQgPSBtTWFwLmtleUF0KGkpOwogICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgfQogICAgICAgICB9Ci0gICAgICAgIGlmICghZm91bmQpIHsKLSAgICAgICAgICAgIEFMT0dWKCJkaWRuJ3QgZmluZCBmYWlsZWQgY2xpZW50Iik7CisgICAgICAgIGlmIChmb3VuZCkgeworICAgICAgICAgICAgQUxPR1coIkZhaWxlZCB0byByZWNsYWltIHJlc291cmNlcyBmcm9tIGNsaWVudCB3aXRoIHBpZCAlZCIsIGZhaWxlZENsaWVudFBpZCk7CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICBBTE9HVygiRmFpbGVkIHRvIHJlY2xhaW0gcmVzb3VyY2VzIGZyb20gdW5sb2NhdGVhYmxlIGNsaWVudCIpOwogICAgICAgICB9CiAgICAgfQogCiAgICAgcmV0dXJuIGZhbHNlOwogfQogCi1TdGF0dXMgUmVzb3VyY2VNYW5hZ2VyU2VydmljZTo6b3ZlcnJpZGVQaWQoCi0gICAgICAgIGludCBvcmlnaW5hbFBpZCwKLSAgICAgICAgaW50IG5ld1BpZCkgeworU3RhdHVzIFJlc291cmNlTWFuYWdlclNlcnZpY2U6Om92ZXJyaWRlUGlkKGludCBvcmlnaW5hbFBpZCwgaW50IG5ld1BpZCkgewogICAgIFN0cmluZzggbG9nID0gU3RyaW5nODo6Zm9ybWF0KCJvdmVycmlkZVBpZChvcmlnaW5hbFBpZCAlZCwgbmV3UGlkICVkKSIsCiAgICAgICAgICAgICBvcmlnaW5hbFBpZCwgbmV3UGlkKTsKICAgICBtU2VydmljZUxvZy0+YWRkKGxvZyk7CkBAIC03NjMsOSArNzkwLDcgQEAKI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b3VyY2VNYW5hZ2VyU2VydmljZTo6YWRkQ29va2llQW5kTGlua19sKAotICAgICAgICA6Om5kazo6U3BBSUJpbmRlciBiaW5kZXIsIGNvbnN0IHNwPERlYXRoTm90aWZpZXI+JiBub3RpZmllcikgeworICAgICAgICBjb25zdCBzdGQ6OnNoYXJlZF9wdHI8SVJlc291cmNlTWFuYWdlckNsaWVudD4mIGNsaWVudCwgY29uc3Qgc3A8RGVhdGhOb3RpZmllcj4mIG5vdGlmaWVyKSB7CisgICAgaWYgKGNsaWVudCA9PSBudWxscHRyKSB7CisgICAgICAgIHJldHVybiAwOworICAgIH0KICAgICBzdGQ6OnNjb3BlZF9sb2NrIGxvY2t7c0Nvb2tpZUxvY2t9OwogCiAgICAgdWludHB0cl90IGNvb2tpZTsKICAgICAvLyBOZWVkIHRvIHNraXAgY29va2llIDAgKGlmIGl0IHdyYXBzIGFyb3VuZCkuIFJlc291cmNlSW5mbyBoYXMgY29va2llIGluaXRpYWxpemVkIHRvIDAKICAgICAvLyBpbmRpY2F0aW5nIHRoZSBkZWF0aCBub3RpZmllciBpcyBub3QgY3JlYXRlZCB5ZXQuCiAgICAgd2hpbGUgKChjb29raWUgPSArK3NDb29raWVDb3VudGVyKSA9PSAwKTsKLSAgICBBSUJpbmRlcl9saW5rVG9EZWF0aChiaW5kZXIuZ2V0KCksIG1EZWF0aFJlY2lwaWVudC5nZXQoKSwgKHZvaWQqKWNvb2tpZSk7CisgICAgQUlCaW5kZXJfbGlua1RvRGVhdGgoY2xpZW50LT5hc0JpbmRlcigpLmdldCgpLCBtRGVhdGhSZWNpcGllbnQuZ2V0KCksICh2b2lkKiljb29raWUpOwogICAgIHNDb29raWVUb0RlYXRoTm90aWZpZXJNYXAuZW1wbGFjZShjb29raWUsIG5vdGlmaWVyKTsKIAogICAgIHJldHVybiBjb29raWU7CiB9CiAKIHZvaWQgUmVzb3VyY2VNYW5hZ2VyU2VydmljZTo6cmVtb3ZlQ29va2llQW5kVW5saW5rX2woCi0g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FwaGljTWVtb3J5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNZWRpYVJlc291cmNlOjpUeXBlOjprRHJtU2Vzc2lvbn0pIHsKLSAgICAgICAgICAgIHN0ZDo6c2hhcmVkX3B0cjxJUmVzb3VyY2VNYW5hZ2VyQ2xpZW50PiBjbGllbnQ7Ci0gICAgICAgICAgICBpZiAoZ2V0QmlnZ2VzdENsaWVudF9sKHBpZCwgdHlwZSwgJmNsaWVudCwgdHJ1ZSAvKiBwZW5kaW5nUmVtb3ZhbE9ubHkgKi8pKSB7Ci0gICAgICAgICAgICAgICAgY2xpZW50cy5hZGQoY2xpZW50KTsKLSAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgeworICAgICAgICAgICAgICAgIC8vIENvZGVjIHJlc291cmNlcyBhcmUgc2VncmVnYXRlZCBieSBhdWRpbywgdmlkZW8gYW5kIGltYWdlIGRvbWFpbnMuCisgICAgICAgICAgICAgICAgY2FzZSBNZWRpYVJlc291cmNlOjpUeXBlOjprU2VjdXJlQ29kZWM6CisgICAgICAgICAgICAgICAgY2FzZSBNZWRpYVJlc291cmNlOjpUeXBlOjprTm9uU2VjdXJlQ29kZWM6CisgICAgICAgICAgICAgICAgICAgIGZvciAoTWVkaWFSZXNvdXJjZTo6U3ViVHlwZSBzdWJUeXBlIDoge01lZGlhUmVzb3VyY2U6OlN1YlR5cGU6OmtBdWRpb0NvZGVjLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNZWRpYVJlc291cmNlOjpTdWJUeXBlOjprVmlkZW9Db2RlYywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTWVkaWFSZXNvdXJjZTo6U3ViVHlwZTo6a0ltYWdlQ29kZWN9KSB7CisgICAgICAgICAgICAgICAgICAgICAgICBzdGQ6OnNoYXJlZF9wdHI8SVJlc291cmNlTWFuYWdlckNsaWVudD4gY2xpZW50OworICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdldEJpZ2dlc3RDbGllbnRQZW5kaW5nUmVtb3ZhbF9sKHBpZCwgdHlwZSwgc3ViVHlwZSwgJmNsaWVudCkpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGllbnRzLmFkZChjbGllbnQpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIC8vIE5vbi1jb2RlYyByZXNvdXJjZXMgYXJlIHNoYXJlZCBieSBhdWRpbywgdmlkZW8gYW5kIGltYWdlIGNvZGVjcyAobm8gc3VidHlwZSkuCisgICAgICAgICAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgICAgICAgICAgc3RkOjpzaGFyZWRfcHRyPElSZXNvdXJjZU1hbmFnZXJDbGllbnQ+IGNsaWVudDsKKyAgICAgICAgICAgICAgICAgICAgaWYgKGdldEJpZ2dlc3RDbGllbnRQZW5kaW5nUmVtb3ZhbF9sKHBpZCwgdHlwZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBNZWRpYVJlc291cmNlOjpTdWJUeXBlOjprVW5zcGVjaWZpZWRTdWJUeXBlLCAmY2xpZW50KSkgeworICAgICAgICAgICAgICAgICAgICAgICAgY2xpZW50cy5hZGQoY2xpZW50KTsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgIH0KIAogICAgIGlmICghY2xpZW50cy5lbXB0eSgpKSB7Ci0gICAgICAgIHJlY2xhaW1JbnRlcm5hbChjbGllbnRzKTsKKyAgICAgICAgcmVjbGFpbVVuY29uZGl0aW9uYWxseUZyb20oY2xpZW50cyk7Ci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JlYWRzIC0gMTsgaSArPSAyKSB7Ci0gICAgICAgIHRocmVhZEFyZ3MucGlkID0gbUZ1enplZERhdGFQcm92aWRlci0+Q29uc3VtZUludGVncmFsPGludDMyX3Q+KCk7Ci0gICAgICAgIHRocmVhZEFyZ3MudWlkID0gbUZ1enplZERhdGFQcm92aWRlci0+Q29uc3VtZUludGVncmFsPGludDMyX3Q+KCk7CisgICAgZm9yIChpbnQgayA9IDA7IGsgPCBudW1UaHJlYWRQYWlyczsgKytrKSB7CisgICAgICAgIHRocmVhZEFyZ3Nba10ucGlkID0gbUZ1enplZERhdGFQcm92aWRlci0+Q29uc3VtZUludGVncmFsPGludDMyX3Q+KCk7CisgICAgICAgIHRocmVhZEFyZ3Nba10udWlkID0gbUZ1enplZERhdGFQcm92aWRlci0+Q29uc3VtZUludGVncmFsPGludDMyX3Q+KCk7CiAgICAgICAgIGludDMyX3QgbWVkaWFSZXNvdXJjZVR5cGUgPSBtRnV6emVkRGF0YVByb3ZpZGVyLT5Db25zdW1lSW50ZWdyYWxJblJhbmdlPGludDMyX3Q+KAogICAgICAgICAgICAga01pblJlc291cmNlVHlwZSwga01heFJlc291cmNlVHlwZSk7CiAgICAgICAgIGludDMyX3QgbWVkaWFSZXNvdXJjZVN1YlR5cGUgPSBtRnV6emVkRGF0YVByb3ZpZGVyLT5Db25zdW1lSW50ZWdyYWxJblJhbmdlPGludDMyX3Q+KAogICAgICAgICAgICAga01pblJlc291cmNlVHlwZSwga01heFJlc291cmNlVHlwZSk7CiAgICAgICAgIHVpbnQ2NF90IG1lZGlhUmVzb3VyY2VWYWx1ZSA9IG1GdXp6ZWREYXRhUHJvdmlkZXItPkNvbnN1bWVJbnRlZ3JhbDx1aW50NjRfdD4oKTsKLSAgICAgICAgdGhyZWFkQXJncy5zZXJ2aWNlID0gbVNlcnZpY2U7CisgICAgICAgIHRocmVhZEFyZ3Nba10uc2VydmljZSA9IG1TZXJ2aWNlOwogICAgICAgICBzaGFyZWRfcHRyPElSZXNv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0aHJlYWRBcmdzW2tdLnRlc3RDbGllbnRJZCA9IGdldElkKHRlc3RDbGllbnQpOworICAgICAgICBtZWRpYVJlc291cmNlW2tdLnB1c2hfYmFjayhNZWRpYVJlc291cmNlKHN0YXRpY19jYXN0PE1lZFJlc1R5cGU+KG1lZGlhUmVzb3VyY2VUeXBlKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxNZWRSZXNTdWJUeXBlPihtZWRpYVJlc291cmNlU3ViVHlwZSksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVkaWFSZXNvdXJjZVZhbHVlKSk7CisgICAgICAgIHRocmVhZEFyZ3Nba10ubWVkaWFSZXNvdXJjZSA9IG1lZGlhUmVzb3VyY2Vba107CisgICAgICAgIHB0aHJlYWRfY3JlYXRlKCZwdFsyICoga10sIG51bGxwdHIsIGFkZFJlc291cmNlLCAmdGhyZWFkQXJnc1trXSk7CisgICAgICAgIHB0aHJlYWRfY3JlYXRlKCZwdFsyICogayArIDFdLCBudWxscHRyLCByZW1vdmVSZXNvdXJjZSwgJnRocmVhZEFyZ3Nba10pOwogICAgIH0KIAotICAgIGZvciAoaSA9IDA7IGkgPCBudW1UaHJlYWRzOyArK2kpIHsKKyAgICBmb3IgKGludCBpID0gMDsgaSA8IG51bVRocmVhZHM7ICsraSkgewogICAgICAgICBwdGhyZWFkX2pvaW4ocHRbaV0sIG51bGxwdHIpOwogICAgIH0KIApAQCAtMjY1LDE0ICsyNjQsMTQgQEAKICAgICBpbnQzMl90IG1lZGlhUmVzb3VyY2VTdWJUeXBlID0KICAgICAgICAgbUZ1enplZERhdGFQcm92aWRlci0+Q29uc3VtZUludGVncmFsSW5SYW5nZTxpbnQzMl90PihrTWluUmVzb3VyY2VUeXBlLCBrTWF4UmVzb3VyY2VUeXBlKTsKICAgICB1aW50NjRfdCBtZWRpYVJlc291cmNlVmFsdWUgPSB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Jlc291cmNlKDEpKTsKKyAgICAgICAgICAgIG1TZXJ2aWNlLT5hZGRSZXNvdXJjZShvbmx5UGlkLCBvbmx5VWlkLCBnZXRJZChzbWFsbE5vblNlY3VyZVZpZGVvTWFya2VkQ2xpZW50KSwKKyAgICAgICAgICAgICAgICAgICAgc21hbGxOb25TZWN1cmVWaWRlb01hcmtlZENsaWVudCwgcmVzb3VyY2VzKTsKKyAgICAgICAgICAgIHJlc291cmNlcy5jbGVhcigpOworICAgICAgICAgICAgcmVzb3VyY2VzLnB1c2hfYmFjayhjcmVhdGVOb25TZWN1cmVWaWRlb0NvZGVjUmVzb3VyY2UoMikpOworICAgICAgICAgICAgbVNlcnZpY2UtPmFkZFJlc291cmNlKG9ubHlQaWQsIG9ubHlVaWQsIGdldElkKGxhcmdlTm9uU2VjdXJlVmlkZW9NYXJrZWRDbGllbnQpLAorICAgICAgICAgICAgICAgICAgICBsYXJnZU5vblNlY3VyZVZpZGVvTWFya2VkQ2xpZW50LCByZXNvdXJjZXMpOworICAgICAgICAgICAgcmVzb3VyY2VzLmNsZWFyKCk7CisgICAgICAgICAgICByZXNvdXJjZXMucHVzaF9iYWNrKGNyZWF0ZU5vblNlY3VyZVZpZGVvQ29kZWNSZXNvdXJjZSgzKSk7CisgICAgICAgICAgICBtU2VydmljZS0+YWRkUmVzb3VyY2Uob25seVBpZCwgb25seVVpZCwgZ2V0SWQobGFyZ2VzdE5vblNlY3VyZVZpZGVvQWN0aXZlQ2xpZW50KSwKKyAgICAgICAgICAgICAgICAgICAgbGFyZ2VzdE5vblNlY3VyZVZpZGVvQWN0aXZlQ2xpZW50LCByZXNvdXJjZXMpOworICAgICAgICB9CisgICAgICAgIG1TZXJ2aWNlLT5tYXJrQ2xpZW50Rm9yUGVuZGluZ1JlbW92YWwob25seVBpZCwgZ2V0SWQoc21hbGxOb25TZWN1cmVWaWRlb01hcmtlZENsaWVudCkpOworICAgICAgICBtU2VydmljZS0+bWFya0NsaWVudEZvclBlbmRpbmdS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CByZXNvdXJjZXMpOworICAgICAgICB9CisgICAgICAgIG1TZXJ2aWNlLT5tYXJrQ2xpZW50Rm9yUGVuZGluZ1JlbW92YWwob25seVBpZCwgZ2V0SWQoc21hbGxOb25TZWN1cmVBdWRpb01hcmtlZENsaWVudCkpOworICAgICAgICBtU2VydmljZS0+bWFya0NsaWVudEZvclBlbmRpbmdSZW1vdmFsKG9ubHlQaWQsIGdldElkKGxhcmdlTm9uU2VjdXJlQXVkaW9NYXJrZWRDbGllbnQpKTsKKyAgICAgICAgLy8gZG9uJ3QgbWFyayB0aGUgbGFyZ2VzdCBjbGllbnQKKworICAgICAgICAvLyBzZWN1cmUgaW1hZ2UgY29kZWMKKyAgICAgICAgY29uc3QgYXV0byBzbWFsbFNlY3VyZUltYWdlTWFya2VkQ2xpZW50ID0gY3JlYXRlVGVzdENsaWVudChvbmx5UGlkKTsKKyAgICAgICAgY29uc3QgYXV0byBsYXJnZVNlY3VyZUltYWdlTWFya2VkQ2xpZW50ID0gY3JlYXRlVGVzdENsaWVudChvbmx5UGlkKTsKKyAgICAgICAgY29uc3QgYXV0byBsYXJnZXN0U2VjdXJlSW1hZ2VBY3RpdmVDbGllbnQgPSBjcmVhdGVUZXN0Q2xpZW50KG9ubHlQaWQpOworICAgICAgICB7CisgICAgICAgICAgICBzdGQ6OnZlY3RvcjxNZWRpYVJlc291cmNlUGFyY2VsPiByZXNvdXJjZXM7CisgICAgICAgICAgICByZXNvdXJjZXMucHVzaF9iYWNrKGNyZWF0ZVNlY3VyZUltYWdlQ29kZWNSZXNvdXJjZSgxKSk7CisgICAgICAgICAgICBtU2VydmljZS0+YWRkUmVzb3VyY2Uob25seVBpZCwgb25seVVpZCwgZ2V0SWQoc21hbGxTZWN1cmVJbWFnZU1hcmtlZENsaWVudCksCisgICAgICAgICAgICAgICAgICAgIHNtYWxsU2VjdXJlSW1hZ2VNYXJrZWRDbGllbnQsIHJlc291cmNlcyk7CisgICAgICAgICAgICByZXNvdXJjZXMuY2xlYX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CisgICAgICAgICAgICBtU2VydmljZS0+YWRkUmVzb3VyY2Uob25seVBpZCwgb25seVVpZCwgZ2V0SWQobGFyZ2VzdE5vblNlY3VyZUltYWdlQWN0aXZlQ2xpZW50KSwKKyAgICAgICAgICAgICAgICAgICAgbGFyZ2VzdE5vblNlY3VyZUltYWdlQWN0aXZlQ2xpZW50LCByZXNvdXJjZXMpOworICAgICAgICB9CisgICAgICAgIG1TZXJ2aWNlLT5tYXJrQ2xpZW50Rm9yUGVuZGluZ1JlbW92YWwob25seVBpZCwgZ2V0SWQoc21hbGxOb25TZWN1cmVJbWFnZU1hcmtlZENsaWVudCkpOworICAgICAgICBtU2VydmljZS0+bWFya0NsaWVudEZvclBlbmRpbmdSZW1vdmFsKG9ubHlQaWQsIGdldElkKGxhcmdlTm9uU2VjdXJlSW1hZ2VNYXJrZWRDbGllbnQpKTsKKyAgICAgICAgLy8gZG9uJ3QgbWFyayB0aGUgbGFyZ2VzdCBjbGllbnQKKworICAgICAgICAvLyBncmFwaGljIG1lbW9yeQorICAgICAgICBjb25zdCBhdXRvIHNtYWxsR3JhcGhpY01lbW9yeU1hcmtlZENsaWVudCA9IGNyZWF0ZVRlc3RDbGllbnQob25seVBpZCk7CisgICAgICAgIGNvbnN0IGF1dG8gbGFyZ2VHcmFwaGljTWVtb3J5TWFya2VkQ2xpZW50ID0gY3JlYXRlVGVzdENsaWVudChvbmx5UGlkKTsKKyAgICAgICAgY29uc3QgYXV0byBsYXJnZXN0R3JhcGhpY01lbW9yeUFjdGl2ZUNsaWVudCA9IGNyZWF0ZVRlc3RDbGllbnQob25seVBpZCk7CisgICAgICAgIHsKKyAgICAgICAgICAgIHN0ZDo6dmVjdG9yPE1lZGlhUmVzb3VyY2VQYXJjZWw+IHJlc291cmNlczsKKyAgICAgICAgICAgIHJlc291cmNlcy5wdXNoX2JhY2soY3JlYXRlR3JhcGhpY01lbW9yeVJlc291cmNlKDEwMCkpOworICAgICAgICAgICAgbVNlcnZpY2UtPmFkZFJ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2xpZW50KSk7CisgICAgICAgIC8vIGRvbid0IG1hcmsgdGhlIGxhcmdlc3QgY2xpZW50CisKKyAgICAgICAgLy8gRFJNIHNlc3Npb24KKyAgICAgICAgY29uc3QgYXV0byBzbWFsbERybVNlc3Npb25NYXJrZWRDbGllbnQgPSBjcmVhdGVUZXN0Q2xpZW50KG9ubHlQaWQpOworICAgICAgICBjb25zdCBhdXRvIGxhcmdlRHJtU2Vzc2lvbk1hcmtlZENsaWVudCA9IGNyZWF0ZVRlc3RDbGllbnQob25seVBpZCk7CisgICAgICAgIGNvbnN0IGF1dG8gbGFyZ2VzdERybVNlc3Npb25BY3RpdmVDbGllbnQgPSBjcmVhdGVUZXN0Q2xpZW50KG9ubHlQaWQpOworICAgICAgICB7CisgICAgICAgICAgICBzdGQ6OnZlY3RvcjxNZWRpYVJlc291cmNlUGFyY2VsPiByZXNvdXJjZXM7CisgICAgICAgICAgICByZXNvdXJjZXMucHVzaF9iYWNrKGNyZWF0ZURybVNlc3Npb25SZXNvdXJjZSgxKSk7CisgICAgICAgICAgICBtU2VydmljZS0+YWRkUmVzb3VyY2Uob25seVBpZCwgb25seVVpZCwgZ2V0SWQoc21hbGxEcm1TZXNzaW9uTWFya2VkQ2xpZW50KSwKKyAgICAgICAgICAgICAgICAgICAgc21hbGxEcm1TZXNzaW9uTWFya2VkQ2xpZW50LCByZXNvdXJjZXMpOworICAgICAgICAgICAgcmVzb3VyY2VzLmNsZWFyKCk7CisgICAgICAgICAgICByZXNvdXJjZXMucHVzaF9iYWNrKGNyZWF0ZURybVNlc3Npb25SZXNvdXJjZSgyKSk7CisgICAgICAgICAgICBtU2VydmljZS0+YWRkUmVzb3VyY2Uob25seVBpZCwgb25seVVpZCwgZ2V0SWQobGFyZ2VEcm1TZXNzaW9uTWFya2VkQ2xpZW50KSwKKyAgICAgICAgICAgICAgICAgICAgbGFyZ2VEcm1TZXNzaW9uTWFya2VkQ2xpZW50LCByZXNvdXJjZXMpOworICAgICAgICAgICAgcmVzb3VyY2VzLmNsZWFyKCk7CisgICAgICAgICAgICByZXNvdXJjZXMucHVzaF9iYWNrKGNyZWF0ZURybVNlc3Npb25SZXNvdXJjZSgzKSk7CisgICAgICAgICAgICBtU2VydmljZS0+YWRkUmVzb3VyY2Uob25seVBpZCwgb25seVVpZCwgZ2V0SWQobGFyZ2VzdERybVNlc3Npb25BY3RpdmVDbGllbnQpLAorICAgICAgICAgICAgICAgICAgICBsYXJnZXN0RHJtU2Vzc2lvbkFjdGl2ZUNsaWVudCwgcmVzb3VyY2VzKTsKKyAgICAgICAgfQorICAgICAgICBtU2VydmljZS0+bWFya0NsaWVudEZvclBlbmRpbmdSZW1vdmFsKG9ubHlQaWQsIGdldElkKHNtYWxsRHJtU2Vzc2lvbk1hcmtlZENsaWVudCkpOworICAgICAgICBtU2VydmljZS0+bWFya0NsaWVudEZvclBlbmRpbmdSZW1vdmFsKG9ubHlQaWQsIGdldElkKGxhcmdlRHJtU2Vzc2lvbk1hcmtlZENsaWVudCkpOworICAgICAgICAvLyBkb24ndCBtYXJrIHRoZSBsYXJnZXN0IGNsaWVudAorCisgICAgICAgIC8vIGJhdHRlcnkKKyAgICAgICAgY29uc3QgYXV0byBiYXR0ZXJ5TWFya2VkQ2xpZW50ID0gY3JlYXRlVGVzdENsaWVudChvbmx5UGlkKTsKKyAgICAgICAgeworICAgICAgICAgICAgc3RkOjp2ZWN0b3I8TWVkaWFSZXNvdXJjZVBhcmNlbD4gcmVzb3VyY2VzOworICAgICAgICAgICAgcmVzb3VyY2VzLnB1c2hfYmFjayhjcmVhdGVCYXR0ZXJ5UmVzb3VyY2UoKSk7CisgICAgICAgICAgICBtU2VydmljZS0+YWRkUmVzb3VyY2Uob25seVBpZCwgb25seVVpZCwgZ2V0SWQoYmF0dGVyeU1hcmtlZENsaWVudCksCisgICAgICAgICAgICAgICAgICAgIGJhdHRlcnlNYXJrZWRDbGllbnQsIHJlc291cmNlcyk7CisgICAgICAgIH0KKyAgICAgICAgbVNlcnZpY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0VuZHBvaW50UGFyY2VsYWJsZSogcGFyY2VsYWJsZSk7CiAKICAgICBpbnQ2NF90IGdldEhhcmR3YXJlVGltZU9mZnNldE5hbm9zKCkgY29uc3QgewogICAgICAgICByZXR1cm4gbUhhcmR3YXJlVGltZU9mZnNldE5hbm9zOwpAQCAtOTEsNiArOTUsOCBAQAogCiAgICAgYWF1ZGlvX3Jlc3VsdF90IG9wZW5XaXRoRm9ybWF0KGF1ZGlvX2Zvcm1hdF90IGF1ZGlvRm9ybWF0KTsKIAorICAgIGFhdWRpb19yZXN1bHRfdCBjcmVhdGVNbWFwQnVmZmVyKGFuZHJvaWQ6OmJhc2U6OnVuaXF1ZV9mZCogZmlsZURlc2NyaXB0b3IpOworCiAgICAgTW9ub3RvbmljQ291bnRlciAgICAgICAgICAgICAgICAgICAgICAgICAgbUZyYW1lc1RyYW5zZmVycmVkOwogCiAgICAgLy8gSW50ZXJmYWNlIHRvIHRoZSBBdWRpb0ZsaW5nZXIgTU1BUCBzdXBwb3J0LgpAQCAtMTA2LDcgKzExMiwxMiBAQAogCiAgICAgaW50NjRfdCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbUhhcmR3YXJlVGltZU9mZnNldE5hbm9zID0gMDsgLy8gVE9ETyBnZXQgZnJvbSBIQUwKIAotICAgIGJvb2wgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1FeHRlcm5hbFBvc2l0aW9uU3VwcG9ydGVkID0gdHJ1ZTsKKyAgICBhYXVkaW9fcmVzdWx0X3QgICAgICAgICAgICAgICAgICAgICAgICAgICBtSGFsRXh0ZXJuYWxQb3NpdGlvblN0YXR1cyA9IEFBVURJT19PSzsKKyAgICB1aW50NjRfdCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtTGFzdFBvc2l0aW9uRnJhbWVzID0gMDsKKyAgICBpbnQ2NF90ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtVGltZXN0YW1wTmFub3NGb3J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gICAgIGlmICghbVRocmVhZEVuYWJsZWQpIHsKKyAgICAgICAgICAgIC8vIEJyZWFrIHRoZSBsb29wIGlmIHRoZSB0aHJlYWQgaXMgZGlzYWJsZWQuCisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorCisgICAgICAgIGlmIChpc1J1bm5pbmcoKSAmJiBBdWRpb0Nsb2NrOjpnZXROYW5vc2Vjb25kcygpID49IG5leHRUaW1lKSB7CisgICAgICAgICAgICAvLyBJdCBpcyB0aW1lIHRvIHVwZGF0ZSB0aW1lc3RhbXAuCisgICAgICAgICAgICBpZiAoc2VuZEN1cnJlbnRUaW1lc3RhbXBfbCgpICE9IEFBVURJT19PSykgeworICAgICAgICAgICAgICAgIEFMT0dFKCJGYWlsZWQgdG8gc2VuZCBjdXJyZW50IHRpbWVzdGFtcCwgc3RvcCB1cGRhdGluZyB0aW1lc3RhbXAiKTsKKyAgICAgICAgICAgICAgICBkaXNjb25uZWN0X2woKTsKKyAgICAgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAgICAgbmV4dFRpbWUgPSB0aW1lc3RhbXBTY2hlZHVsZXIubmV4dEFic29sdXRlVGltZSgpOwogICAgICAgICAgICAgfQotICAgICAgICAgICAgbmV4dFRpbWUgPSB0aW1lc3RhbXBTY2hlZHVsZXIubmV4dEFic29sdXRlVGltZSgpOwotICAgICAgICB9IGVsc2UgIHsKLSAgICAgICAgICAgIC8vIFNsZWVwIHVudGlsIGl0IGlzIHRpbWUgdG8gc2VuZCB0aGUgbmV4dCB0aW1lc3RhbXAuCi0gICAgICAgICAgICAvLyBUT0RPIFdhaXQgZm9yIGEgc2lnbmFsIHdpdGggYSB0aW1lb3V0IHNvIHRoYXQgd2UgY2FuIHN0b3AgbW9yZSBxdWlja2x5LgotICAgICAgICAgICAgQXVkaW9DbG9jazo6c2xlZXBVbnRpbE5hbm9UaW1lKG5leHRUaW1lKTsKKyAgICAgICAgfQorICAgICAgICBpZiAoaXNJZGxlX2woKSAmJiBBdWRpb0Nsb2NrOjpnZXROYW5vc2Vjb25kcygpID49IHN0YW5kYnlUaW1lKSB7CisgICAgICAgICAgICBzdGFuZGJ5X2woKTsKKyAgICAgICAgfQorCisgICAgICAgIGlmIChjb21tYW5kICE9IG51bGxwdHIpIHsKKyAgICAgICAgICAgIHN0ZDo6c2NvcGVkX2xvY2s8c3RkOjptdXRleD4gX2NvbW1hbmRMb2NrKGNvbW1hbmQtPmxvY2spOworICAgICAgICAgICAgc3dpdGNoIChjb21tYW5kLT5vcGVyYXRpb25Db2RlKSB7CisgICAgICAgICAgICAgICAgY2FzZSBTVEFSVDoKKyAgICAgICAgICAgICAgICAgICAgY29tbWFuZC0+cmVzdWx0ID0gc3RhcnRfbCgpOworICAgICAgICAgICAgICAgICAgICB0aW1lc3RhbXBTY2hlZHVsZXIuc2V0QnVyc3RQZXJpb2QobUZyYW1lc1BlckJ1cnN0LCBnZXRTYW1wbGVSYXRlKCkpOworICAgICAgICAgICAgICAgICAgICB0aW1lc3RhbXBTY2hlZHVsZXIuc3RhcnQoQXVkaW9DbG9jazo6Z2V0TmFub3NlY29uZHMoKSk7CisgICAgICAgICAgICAgICAgICAgIG5leHRUaW1lID0gdGltZXN0YW1wU2NoZWR1bGVyLm5leHRBYnNvbHV0ZVRpbWUoKTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSBQQVVTRToKKyAgICAgICAgICAgICAgICAgICAgY29tbWFuZC0+cmVzdWx0ID0gcGF1c2VfbCgpOworICAgICAgICAgICAgICAgICAgICBzdGFuZGJ5VGltZSA9IEF1ZGlvQ2xvY2s6OmdldE5hbm9zZWNvbmRzKCkgKyBJRExFX1RJTUVPVVRfTkFOT1M7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgU1RPUDoKKyAgICAgICAgICAgICAgICAgICAgY29tbWFuZC0+cmVzdWx0ID0gc3RvcF9sKCk7CisgICAgICAgICAgICAgICAgICAgIHN0YW5kYnlUaW1lID0gQXVkaW9DbG9jazo6Z2V0TmFub3NlY29uZHMoKSArIElETEVfVElNRU9VVF9OQU5PUzsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSBGTFVTSDoKKyAgICAgICAgICAgICAgICAgICAgY29tbWFuZC0+cmVzdWx0ID0gZmx1c2hfbCgpOworICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICBjYXNlIENMT1NFOgorICAgICAgICAgICAgICAgICAgICBjb21tYW5kLT5yZXN1bHQgPSBjbG9zZV9sKCk7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgRElTQ09OTkVDVDoKKyAgICAgICAgICAgICAgICAgICAgZGlzY29ubmVjdF9sKCk7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgUkVHSVNURVJfQVVESU9fVEhSRUFEOiB7CisgICAgICAgICAgICAgICAgICAgIFJlZ2lzdGVyQXVkaW9UaHJlYWRQYXJhbSAqcGFyYW0gPQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIChSZWdpc3RlckF1ZGlvVGhyZWFkUGFyYW0gKikgY29tbWFuZC0+cGFyYW1ldGVyLmdldCgpOworICAgICAgICAgICAgICAgICAgICBjb21tYW5kLT5yZXN1bHQgPQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtID09IG51bGxwdHIgPyBBQVVESU9fRVJST1JfSUxMRUdBTF9BUkdVTUVOVAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiByZWdpc3RlckF1ZGlvVGhyZWFkX2wocGFyYW0tPm1Pd25lclBpZCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtLT5tQ2xpZW50VGhyZWFkSWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbS0+bVByaW9yaXR5KTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgVU5SRUdJU1RFUl9BVURJT19USFJFQUQ6IHsKKyAgICAgICAgICAgICAgICAgICAgVW5yZWdpc3RlckF1ZGlvVGhyZWFkUGFyYW0gKnBhcmFtID0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAoVW5yZWdpc3RlckF1ZGlvVGhyZWFkUGFyYW0gKikgY29tbWFuZC0+cGFyYW1ldGVyLmdldCgpOworICAgICAgICAgICAgICAgICAgICBjb21tYW5kLT5yZXN1bHQgPQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtID09IG51bGxwdHIgPyBBQVVESU9fRVJST1JfSUxMRUdBTF9BUkdVTUVOVAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiB1bnJlZ2lzdGVyQXVkaW9UaHJlYWRfbChwYXJhbS0+bUNsaWVudFRocmVhZElkKTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgR0VUX0RFU0NSSVBUSU9OOiB7CisgICAgICAgICAgICAgICAgICAgIEdldERlc2NyaXB0aW9uUGFyYW0gKnBhcmFtID0gKEdldERlc2NyaXB0aW9uUGFyYW0gKikgY29tbWFuZC0+cGFyYW1ldGVyLmdldCgpOworICAgICAgICAgICAgICAgICAgICBjb21tYW5kLT5yZXN1bHQgPSBwYXJhbSA9PSBudWxscHRyID8gQUFVRElPX0VSUk9SX0lMTEVHQUxfQVJHVU1FTlQKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiBnZXREZXNjcmlwdGlvbl9sKHBhcmFtLT5tUGFyY2VsYWJsZSk7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICBjYXNlIEVYSVRfU1RBTkRCWTogeworICAgICAgICAgICAgICAgICAgICBFeGl0U3RhbmRieVBhcmFtICpwYXJhbSA9IChFeGl0U3RhbmRieVBhcmFtICopIGNvbW1hbmQtPnBhcmFtZXRlci5nZXQoKTsKKyAgICAgICAgICAgICAgICAgICAgY29tbWFuZC0+cmVzdWx0ID0gcGFyYW0gPT0gbnVsbHB0ciA/IEFBVURJT19FUlJPUl9JTExFR0FMX0FSR1VNRU5UCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOiBleGl0U3RhbmRieV9sKHBhcmFtLT5tUGFyY2VsYWJsZSk7CisgICAgICAgICAgICAgICAgICAgIHN0YW5kYnlUaW1lID0gQXVkaW9DbG9jazo6Z2V0TmFub3NlY29uZHMoKSArIElETEVfVElNRU9VVF9OQU5PUzsKKyAgICAgICAgICAgICAgICB9IGJyZWFrOworICAgICAgICAgICAgICAgIGRlZmF1bHQ6CisgICAgICAgICAgICAgICAgICAgIEFMT0dFKCJJbnZhbGlkIGNvbW1hbmQgb3AgY29kZTogJWQiLCBjb21tYW5kLT5vcGVyYXRpb25Db2RlKTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBpZiAoY29tbWFuZC0+aXNXYWl0aW5nRm9yUmVwbHkpIHsKKyAgICAgICAgICAgICAgICBjb21tYW5kLT5pc1dhaXRpbmdGb3JSZXBseSA9IGZhbHNlOworICAgICAgICAgICAgICAgIGNvbW1hbmQtPmNvbmRpdGlvblZhcmlhYmxlLm5vdGlmeV9vbmUoKTsKKyAgICAgICAgICAgIH0KICAgICAgICAgfQogICAgIH0KLSAgICAvLyBUaGlzIHdhcyBtb3ZlZCBmcm9tIHRoZSBjYWxscyBpbiBzdG9wX2woKSBhb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IChsb25nIGxvbmcpIGNvbW1hbmQudGltZXN0YW1wLnBvc2l0aW9uLApAQCAtNTczLDggKzY0OSw4IEBACiAKICAgICAgICAgaWYgKHJlc3VsdCA9PSBBQVVESU9fT0spIHsKICAgICAgICAgICAgIC8vIFNlbmQgYSBoYXJkd2FyZSB0aW1lc3RhbXAgZm9yIHByZXNlbnRhdGlvbiB0aW1lLgotICAgICAgICAgICAgcmVzdWx0ID0gZ2V0SGFyZHdhcmVUaW1lc3RhbXAoJmNvbW1hbmQudGltZXN0YW1wLnBvc2l0aW9uLAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJmNvbW1hbmQudGltZXN0YW1wLnRpbWVzdGFtcCk7CisgICAgICAgICAgICByZXN1bHQgPSBnZXRIYXJkd2FyZVRpbWVzdGFtcF9sKCZjb21tYW5kLnRpbWVzdGFtcC5wb3NpdGlvbiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJmNvbW1hbmQudGltZXN0YW1wLnRpbWVzdGFtcCk7CiAgICAgICAgICAgICBpZiAocmVzdWx0ID09IEFBVURJT19PSykgewogICAgICAgICAgICAgICAgIEFMT0dWKCIlcygpIEhBUkRXQVJFICU4bGxkIGF0ICVsbGQiLCBfX2Z1bmNfXywKICAgICAgICAgICAgICAgICAgICAgICAobG9uZyBsb25nKSBjb21tYW5kLnRpbWVzdGFtcC5wb3NpdGlvbiwKQEAgLTU5Niw3ICs2NzIsMTQgQEAKICAqIHVzZWQgdG8gY29tbXVuaWNhdGUgd2l0aCB0aGUgdW5kZXJseWluZyBIQUwgb3IgU2VydmljZS4KICAqLwogYWF1ZGlvX3Jlc3VsdF90IEFBdWRpb1NlcnZpY2VTdHJlYW1CYXNlOjpnZXREZXNjcmlwdGlvbihBdWRpb0VuZHBvaW50UGFyY2VsYWJsZSAmcGFyY2VsYWJsZSkgewotICAgIHN0ZDo6bG9ja19ndWFyZDxzdGQ6Om11dGV4PiBsb2NrKG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gICAgICAgICAgaW50NjRfdCAqdGltZU5hbm9zKSB7CithYXVkaW9fcmVzdWx0X3QgQUF1ZGlvU2VydmljZVN0cmVhbVNoYXJlZDo6Z2V0RnJlZVJ1bm5pbmdQb3NpdGlvbl9sKGludDY0X3QgKnBvc2l0aW9uRnJhbWVzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQ2NF90ICp0aW1lTmFub3MpIHsKICAgICAvLyBUT0RPIEdldCBwcmVzZW50YXRpb24gdGltZXN0YW1wIGZyb20gdGhlIEhBTAogICAgIGlmIChtQXRvbWljU3RyZWFtVGltZXN0YW1wLmlzVmFsaWQoKSkgewogICAgICAgICBUaW1lc3RhbXAgdGltZXN0YW1wID0gbUF0b21pY1N0cmVhbVRpbWVzdGFtcC5yZWFkKCk7CkBAIC0yNDUsOCArMjQ1LDggQEAKIH0KIAogLy8gR2V0IHRpbWVzdGFtcCBmcm9tIGxvd2VyIGxldmVsIHNlcnZpY2UuCi1hYXVkaW9fcmVzdWx0X3QgQUF1ZGlvU2VydmljZVN0cmVhbVNoYXJlZDo6Z2V0SGFyZHdhcmVUaW1lc3RhbXAoaW50NjRfdCAqcG9zaXRpb25GcmFtZXMsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50NjRfdCAqdGltZU5hbm9zKSB7CithYXVkaW9fcmVzdWx0X3QgQUF1ZGlvU2VydmljZVN0cmVhbVNoYXJlZDo6Z2V0SGFyZHdhcmVUaW1lc3RhbXBfbChpbnQ2NF90ICpwb3NpdGlvbkZyYW1lcywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDY0X3QgKnRpbWVOYW5vcykgewogCiAgICAgaW50NjRfdCBwb3NpdGlvbiA9IDA7CiAgICAgc3A8QUF1ZGlvU2VydmljZU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Wdlcl9haWRsLWNwcCIsCisgICAgICAgICJ0dl90dW5lcl9haWRsX2ludGVyZmFjZS1uZGsiLAorICAgICAgICAidHZfdHVuZXJfcmVzb3VyY2VfbWFuYWdlcl9haWRsX2ludGVyZmFjZS1uZGsiLAogICAgIF0sCiAKICAgICBzdGF0aWNfbGliczogWwotICAgICAgICAiYW5kcm9pZC5oYXJkd2FyZS5jb21tb24uZm1xLVYxLW5ka19wbGF0Zm9ybSIsCisgICAgICAgICJhbmRyb2lkLmhhcmR3YXJlLmNvbW1vbi5mbXEtVjEtbmRrIiwKICAgICAgICAgImxpYmFpZGxjb21tb25zdXBwb3J0IiwKICAgICBdLAogCkBAIC0xMjIsMTggKzg1LDE1IEBACiAgICAgc2hhcmVkX2xpYnM6IFsKICAgICAgICAgImFuZHJvaWQuaGFyZHdhcmUudHYudHVuZXJAMS4wIiwKICAgICAgICAgImFuZHJvaWQuaGFyZHdhcmUudHYudHVuZXJAMS4xIiwKKyAgICAgICAgImFuZHJvaWQuaGFyZHdhcmUudHYudHVuZXItVjEtbmRrIiwKICAgICAgICAgImxpYmJhc2UiLAogICAgICAgICAibGliYmluZGVyIiwKICAgICAgICAgImxpYmZtcSIsCiAgICAgICAgICJsaWJsb2ciLAogICAgICAgICAibGlidHVuZXJzZXJ2aWNlIiwKICAgICAgICAgImxpYnV0aWxzIiwKLSAgICAgICAgInR2X3R1bmVyX3Jlc291cmNlX21hbmFnZXJfYWlkbF9pbnRlcmZhY2UtbmRrX3BsYXRmb3JtIiwKLSAgICAgICAgInR2X3R1bmVyX3Jlc291cmNlX21hbmFnZXJfYWlkbF9pbnRlcmZhY2UtY3BwIiwKLSAgICBdLAotCi0gICAgc3RhdGljX2xpYnM6IFsKLSAgICAgICAgInR2X3R1bmVyX2FpZGxfaW50ZXJmYWNlLW5ka19wbGF0Zm9ybSIsCisgICAgICAgICJ0dl90dW5lcl9haWRsX2ludGVyZmFjZS1uZGsiLAorICAgICAgICAidHZfdHVuZXJfcmVzb3VyY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GFyZWRfcHRyPElUdW5lckZpbHRlcj4qIF9haWRsX3JldHVybikgeworOjpuZGs6OlNjb3BlZEFTdGF0dXMgVHVuZXJEZW11eDo6c2V0RnJvbnRlbmREYXRhU291cmNlQnlJZChpbnQgZnJvbnRlbmRJZCkgeworICAgIGlmIChtRGVtdXggPT0gbnVsbHB0cikgeworICAgICAgICBBTE9HRSgiSURlbXV4IGlzIG5vdCBpbml0aWFsaXplZCIpOworICAgICAgICByZXR1cm4gOjpuZGs6OlNjb3BlZEFTdGF0dXM6OmZyb21TZXJ2aWNlU3BlY2lmaWNFcnJvcigKKyAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxpbnQzMl90PihSZXN1bHQ6OlVOQVZBSUxBQkxFKSk7CisgICAgfQorCisgICAgcmV0dXJuIG1EZW11eC0+c2V0RnJvbnRlbmREYXRhU291cmNlKGZyb250ZW5kSWQpOworfQorCis6Om5kazo6U2NvcGVkQVN0YXR1cyBUdW5lckRlbXV4OjpvcGVuRmlsdGVyKGNvbnN0IERlbXV4RmlsdGVyVHlwZSYgaW5fdHlwZSwgaW50MzJfdCBpbl9idWZmZXJTaXplLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzaGFyZWRfcHRyPElUdW5lckZpbHRlckNhbGxiYWNrPiYgaW5fY2IsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNoYXJlZF9wdHI8SVR1bmVyRmlsdGVyPiogX2FpZGxfcmV0dXJuKSB7CisgICAgaWYgKG1EZW11eCA9PSBudWxscHRyKSB7CisgICAgICAgIEFMT0dFKCJJRGVtdXggaXMgbm90IGluaXRpYWxpemVkIik7CisgICAgICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6ZnJvbVNlcnZpY2VTcGVjaWZpY0Vycm9yKAorICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PGludDMyX3Q+KFJlc3VsdDo6VU5BVkFJTEFC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VGhyZXNob2xkID0gc3RhdGljX2Nhc3Q8dWludDMyX3Q+KHNldHRpbmdzLmxvd1RocmVzaG9sZCksCi0gICAgICAgICAgICAgICAgLmhpZ2hUaHJlc2hvbGQgPSBzdGF0aWNfY2FzdDx1aW50MzJfdD4oc2V0dGluZ3MuaGlnaFRocmVzaG9sZCksCi0gICAgICAgICAgICAgICAgLmRhdGFGb3JtYXQgPSBzdGF0aWNfY2FzdDxEYXRhRm9ybWF0PihzZXR0aW5ncy5kYXRhRm9ybWF0KSwKLSAgICAgICAgICAgICAgICAucGFja2V0U2l6ZSA9IHN0YXRpY19jYXN0PHVpbnQ4X3Q+KHNldHRpbmdzLnBhY2tldFNpemUpLAotICAgICAgICAgICAgfSk7Ci0gICAgICAgICAgICByZXR1cm4gczsKLSAgICAgICAgfQotICAgICAgICBjYXNlIER2clR5cGU6OlJFQ09SRDogewotICAgICAgICAgICAgcy5yZWNvcmQoewotICAgICAgICAgICAgICAgIC5zdGF0dXNNYXNrID0gc3RhdGljX2Nhc3Q8dWludDhfdD4oc2V0dGluZ3Muc3RhdHVzTWFzayksCi0gICAgICAgICAgICAgICAgLmxvd1RocmVzaG9sZCA9IHN0YXRpY19jYXN0PHVpbnQzMl90PihzZXR0aW5ncy5sb3dUaHJlc2hvbGQpLAotICAgICAgICAgICAgICAgIC5oaWdoVGhyZXNob2xkID0gc3RhdGljX2Nhc3Q8dWludDMyX3Q+KHNldHRpbmdzLmhpZ2hUaHJlc2hvbGQpLAotICAgICAgICAgICAgICAgIC5kYXRhRm9ybWF0ID0gc3RhdGljX2Nhc3Q8RGF0YUZvcm1hdD4oc2V0dGluZ3MuZGF0YUZvcm1hdCksCi0gICAgICAgICAgICAgICAgLnBhY2tldFNpemUgPSBzdGF0aWNfY2FzdDx1aW50OF90PihzZXR0aW5ncy5wYWNrZXRTaXplKSwKLSAgICAgICAgICAgIH0pOwotICAgICAgICAgICAgcmV0dXJuIHM7Ci0gICAgICAgIH0KLSAgICAgICAgZGVmYXV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OF90PiBtYXNrKHNlY3Rpb25CaXRzLm1hc2suYmVnaW4oKSwgc2VjdGlvbkJpdHMubWFzay5lbmQoKSk7Ci0gICAgICAgICAgICB2ZWN0b3I8dWludDhfdD4gbW9kZShzZWN0aW9uQml0cy5tb2RlLmJlZ2luKCksIHNlY3Rpb25CaXRzLm1vZGUuZW5kKCkpOwotICAgICAgICAgICAgc2VjdGlvbi5jb25kaXRpb24uc2VjdGlvbkJpdHMoewotICAgICAgICAgICAgICAgIC5maWx0ZXIgPSBmaWx0ZXIsCi0gICAgICAgICAgICAgICAgLm1hc2sgPSBtYXNrLAotICAgICAgICAgICAgICAgIC5tb2RlID0gbW9kZSwKLSAgICAgICAgICAgIH0pOwotICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgIH0KLSAgICAgICAgY2FzZSBUdW5lckZpbHRlclNlY3Rpb25Db25kaXRpb246OnRhYmxlSW5mbzogewotICAgICAgICAgICAgYXV0byB0YWJsZUluZm8gPSBzLmNvbmRpdGlvbi5nZXQ8VHVuZXJGaWx0ZXJTZWN0aW9uQ29uZGl0aW9uOjp0YWJsZUluZm8+KCk7Ci0gICAgICAgICAgICBzZWN0aW9uLmNvbmRpdGlvbi50YWJsZUluZm8oewotICAgICAgICAgICAgICAgIC50YWJsZUlkID0gc3RhdGljX2Nhc3Q8dWludDE2X3Q+KHRhYmxlSW5mby50YWJsZUlkKSwKLSAgICAgICAgICAgICAgICAudmVyc2lvbiA9IHN0YXRpY19jYXN0PHVpbnQxNl90Pih0YWJsZUluZm8udmVyc2lvbiksCi0gICAgICAgICAgICB9KTsKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICB9Ci0gICAgICAgIGRlZmF1bHQ6IHsKLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICB9Ci0gICAgfQotICAgIHJldHVybiBzZWN0aW9uOwotfQotCi1EZW11eEZpbHRlclBlc0RhdGFTZXR0aW5ncyBUdW5lckZpbHRlcjo6Z2V0UGVzRGF0YVNldHRpbm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F2TWVtb3J5LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDY0X3QqIF9haWRsX3JldHVybikgeworICAgIE11dGV4OjpBdXRvbG9jayBfbChtTG9jayk7CisgICAgaWYgKG1GaWx0ZXIgPT0gbnVsbHB0cikgeworICAgICAgICBBTE9HRSgiSUZpbHRlciBpcyBub3QgaW5pdGlhbGl6ZWQiKTsKKyAgICAgICAgcmV0dXJuIDo6bmRrOjpTY29wZWRBU3RhdHVzOjpmcm9tU2VydmljZVNwZWNpZmljRXJyb3IoCisgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8aW50MzJfdD4oUmVzdWx0OjpVTkFWQUlMQUJMRSkpOworICAgIH0KKworICAgIGlmIChtU2hhcmVkKSB7CisgICAgICAgIEFMT0dEKCIlcyBpcyBjYWxsZWQgb24gYSBzaGFyZWQgZmlsdGVyIiwgX19GVU5DVElPTl9fKTsKKyAgICAgICAgcmV0dXJuIDo6bmRrOjpTY29wZWRBU3RhdHVzOjpmcm9tU2VydmljZVNwZWNpZmljRXJyb3IoCisgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8aW50MzJfdD4oUmVzdWx0OjpJTlZBTElEX1NUQVRFKSk7CisgICAgfQorCisgICAgcmV0dXJuIG1GaWx0ZXItPmdldEF2U2hhcmVkSGFuZGxlKG91dF9hdk1lbW9yeSwgX2FpZGxfcmV0dXJuKTsKK30KKworOjpuZGs6OlNjb3BlZEFTdGF0dXMgVHVuZXJGaWx0ZXI6OnJlbGVhc2VBdkhhbmRsZShjb25zdCBOYXRpdmVIYW5kbGUmIGluX2hhbmRsZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50NjRfdCBpbl9hdkRhdGFJZCkgeworICAgIE11dGV4OjpBdXRvbG9jayBfbChtTG9jayk7CisgICAgaWYgKG1GaWx0ZXIgPT0gbnVsbHB0cikgeworICAgICAgICBBTE9HRS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xpbmdQaWQgPSBpcGMtPmdldENhbGxpbmdQaWQoKTsKKyAgICAgICAgaWYgKGNhbGxpbmdQaWQgPT0gbUNsaWVudFBpZCkgeworICAgICAgICAgICAgQUxPR0QoIiVzIGlzIGNhbGxlZCBpbiB3cm9uZyBwcm9jZXNzIiwgX19GVU5DVElPTl9fKTsKKyAgICAgICAgICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6ZnJvbVNlcnZpY2VTcGVjaWZpY0Vycm9yKAorICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxpbnQzMl90PihSZXN1bHQ6OklOVkFMSURfU1RBVEUpKTsKKyAgICAgICAgfQorICAgIH0KKworICAgIGF1dG8gcmVzID0gbUZpbHRlci0+c3RhcnQoKTsKKyAgICBpZiAocmVzLmlzT2soKSkgeworICAgICAgICBtU3RhcnRlZCA9IHRydWU7CisgICAgfQorICAgIHJldHVybiByZXM7Cit9CisKKzo6bmRrOjpTY29wZWRBU3RhdHVzIFR1bmVyRmlsdGVyOjpzdG9wKCkgeworICAgIE11dGV4OjpBdXRvbG9jayBfbChtTG9jayk7CisgICAgaWYgKG1GaWx0ZXIgPT0gbnVsbHB0cikgeworICAgICAgICBBTE9HRSgiSUZpbHRlciBpcyBub3QgaW5pdGlhbGl6ZWQiKTsKKyAgICAgICAgcmV0dXJuIDo6bmRrOjpTY29wZWRBU3RhdHVzOjpmcm9tU2VydmljZVNwZWNpZmljRXJyb3IoCisgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8aW50MzJfdD4oUmVzdWx0OjpVTkFWQUlMQUJMRSkpOworICAgIH0KKworICAgIGlmIChtU2hhcmVkKSB7CisgICAgICAgIElQQ1RocmVhZFN0YXRlKiBpcGMgPSBJUENUaHJlYWRTdGF0ZTo6c2VsZigpOworICAgICAgICBpbnQzMl90IGNhbGxpbmdQaWQgPSBpcGMtPmdldENhbGxpbmdQaWQoKTsKKyAgICAgICAgaWYgKGNhbGxpbmdQaWQgPT0g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AgICAgICAgICAgcmV0dXJuIDo6bmRrOjpTY29wZWRBU3RhdHVzOjpmcm9tU2VydmljZVNwZWNpZmljRXJyb3IoCisgICAgICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PGludDMyX3Q+KFJlc3VsdDo6SU5WQUxJRF9TVEFURSkpOworICAgICAgICB9CisgICAgfQorCisgICAgcmV0dXJuIG1GaWx0ZXItPmZsdXNoKCk7Cit9CisKKzo6bmRrOjpTY29wZWRBU3RhdHVzIFR1bmVyRmlsdGVyOjpjbG9zZSgpIHsKKyAgICBNdXRleDo6QXV0b2xvY2sgX2wobUxvY2spOworICAgIGlmIChtRmlsdGVyID09IG51bGxwdHIpIHsKKyAgICAgICAgQUxPR0UoIklGaWx0ZXIgaXMgbm90IGluaXRpYWxpemVkIik7CisgICAgICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6ZnJvbVNlcnZpY2VTcGVjaWZpY0Vycm9yKAorICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PGludDMyX3Q+KFJlc3VsdDo6VU5BVkFJTEFCTEUpKTsKKyAgICB9CisKKyAgICBpZiAobVNoYXJlZCkgeworICAgICAgICBJUENUaHJlYWRTdGF0ZSogaXBjID0gSVBDVGhyZWFkU3RhdGU6OnNlbGYoKTsKKyAgICAgICAgaW50MzJfdCBjYWxsaW5nUGlkID0gaXBjLT5nZXRDYWxsaW5nUGlkKCk7CisgICAgICAgIGlmIChjYWxsaW5nUGlkID09IG1DbGllbnRQaWQpIHsKKyAgICAgICAgICAgIGlmIChtRmlsdGVyQ2FsbGJhY2sgIT0gbnVsbHB0cikgeworICAgICAgICAgICAgICAgIG1GaWx0ZXJDYWxsYmFjay0+c2VuZFNoYXJlZEZpbHRlclN0YXR1cyhTVEFUVVNfSU5BQ0NFU1NJQkxFKTsKKyAgICAgICAgICAgICAgICBtRmlsdGVyQ2FsbGJhY2stPmRldGFjaFNoYXJlZEZpbHRlckNhbGxiYWNrKCk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBUdW5lclNlcnZpY2U6OmdldFR1bmVyU2VydmljZSgpLT5yZW1vdmVTaGFyZWRGaWx0ZXIodGhpcy0+cmVmPFR1bmVyRmlsdGVyPigpKTsKICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgIF9haWRsX3JldHVybiA9IE5VTEw7CisgICAgICAgICAgICAvLyBDYWxsaW5nIGZyb20gc2hhcmVkIHByb2Nlc3MsIGRvIG5vdCByZWFsbHkgY2xvc2UgdGhpcyBmaWx0ZXIuCisgICAgICAgICAgICBpZiAobUZpbHRlckNhbGxiYWNrICE9IG51bGxwdHIpIHsKKyAgICAgICAgICAgICAgICBtRmlsdGVyQ2FsbGJhY2stPmRldGFjaFNoYXJlZEZpbHRlckNhbGxiYWNrKCk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBtU3RhcnRlZCA9IGZhbHNlOworICAgICAgICAgICAgcmV0dXJuIDo6bmRrOjpTY29wZWRBU3RhdHVzOjpvaygpOwogICAgICAgICB9Ci0gICAgfSk7Ci0KLSAgICBpZiAocmVzICE9IFJlc3VsdDo6U1VDQ0VTUykgewotICAgICAgICByZXR1cm4gU3RhdHVzOjpmcm9tU2VydmljZVNwZWNpZmljRXJyb3Ioc3RhdGljX2Nhc3Q8aW50MzJfdD4ocmVzKSk7CiAgICAgfQotICAgIHJldHVybiBTdGF0dXM6Om9rKCk7CisKKyAgICBpZiAobUZpbHRlckNhbGxiYWNrICE9IG51bGxwdHIpIHsKKyAgICAgICAgbUZpbHRlckNhbGxiYWNrLT5kZXRhY2hDYWxsYmFja3MoKTsKKyAgICB9CisgICAgYXV0byByZXMgPSBtRmlsdGVyLT5jbG9zZSgpOworICAgIG1GaWx0ZXIgPSBudWxscHRyOworICAgIG1TdGFydGVkID0gZmFsc2U7CisgICAgbVNoYXJlZCA9IGZhbHNlOworICAgIG1DbGllbnRQaWQgPSAtMTsKKworICAgIHJldHVybiByZXM7CiB9CiAKLVN0YXR1cyBUdW5lckZpbH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BnZXRNbXRwUmVjb3JkRXZlbnQoZXZlbnRzLCBldmVudHNFeHQsIHR1bmVyRXZlbnQpOwotICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgY2FzZSBEZW11eEZpbHRlckV2ZW50OjpFdmVudDo6aGlkbF9kaXNjcmltaW5hdG9yOjpkb3dubG9hZDogewotICAgICAgICAgICAgICAgIGdldERvd25sb2FkRXZlbnQoZXZlbnRzLCB0dW5lckV2ZW50KTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGNhc2UgRGVtdXhGaWx0ZXJFdmVudDo6RXZlbnQ6OmhpZGxfZGlzY3JpbWluYXRvcjo6aXBQYXlsb2FkOiB7Ci0gICAgICAgICAgICAgICAgZ2V0SXBQYXlsb2FkRXZlbnQoZXZlbnRzLCB0dW5lckV2ZW50KTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGNhc2UgRGVtdXhGaWx0ZXJFdmVudDo6RXZlbnQ6OmhpZGxfZGlzY3JpbWluYXRvcjo6dGVtaTogewotICAgICAgICAgICAgICAgIGdldFRlbWlFdmVudChldmVudHMsIHR1bmVyRXZlbnQpOwotICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgZGVmYXVsdDogewotICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgfQotICAgICAgICB9Cit2b2lkIFR1bmVyRmlsdGVyOjpGaWx0ZXJDYWxsYmFjazo6c2VuZFNoYXJlZEZpbHRlclN0YXR1cyhpbnQzMl90IHN0YXR1cykgeworICAgIE11dGV4OjpBdXRvbG9jayBfbChtQ2FsbGJhY2tMb2NrKTsKKyAgICBpZiAobVR1bmVyRmlsdGVyQ2FsbGJhY2sgIT0gbnVsbHB0ciAmJiBtT3JpZ2luYWxDYWxsYmFjayAhPSBudWxscHRyKSB7CisgICA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DxpbnQ4X3Q+KAotICAgICAgICAgICAgICAgICAgICAgICAgbWVkaWFFdmVudC5leHRyYU1ldGFEYXRhLmF1ZGlvKCkuYWRQYW4pLAotICAgICAgICAgICAgICAgIC52ZXJzaW9uVGV4dFRhZyA9IHN0YXRpY19jYXN0PGludDhfdD4oCi0gICAgICAgICAgICAgICAgICAgICAgICBtZWRpYUV2ZW50LmV4dHJhTWV0YURhdGEuYXVkaW8oKS52ZXJzaW9uVGV4dFRhZyksCi0gICAgICAgICAgICAgICAgLmFkR2FpbkNlbnRlciA9IHN0YXRpY19jYXN0PGludDhfdD4oCi0gICAgICAgICAgICAgICAgICAgICAgICBtZWRpYUV2ZW50LmV4dHJhTWV0YURhdGEuYXVkaW8oKS5hZEdhaW5DZW50ZXIpLAotICAgICAgICAgICAgICAgIC5hZEdhaW5Gcm9udCA9IHN0YXRpY19jYXN0PGludDhfdD4oCi0gICAgICAgICAgICAgICAgICAgICAgICBtZWRpYUV2ZW50LmV4dHJhTWV0YURhdGEuYXVkaW8oKS5hZEdhaW5Gcm9udCksCi0gICAgICAgICAgICAgICAgLmFkR2FpblN1cnJvdW5kID0gc3RhdGljX2Nhc3Q8aW50OF90PigKLSAgICAgICAgICAgICAgICAgICAgICAgIG1lZGlhRXZlbnQuZXh0cmFNZXRhRGF0YS5hdWRpbygpLmFkR2FpblN1cnJvdW5kKSwKLSAgICAgICAgICAgIH07Ci0gICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICB0dW5lck1lZGlhLmlzQXVkaW9FeHRyYU1ldGFEYXRhID0gZmFsc2U7Ci0gICAgICAgIH0KLQotICAgICAgICBpZiAobWVkaWFFdmVudC5hdk1lbW9yeS5nZXROYXRpdmVIYW5kbGUoKSAhPSBudWxscHRyKSB7Ci0gICAgICAgICAgICB0dW5lck1lZGlhLmF2TWVtb3J5ID0gZHVwVG9BaWRsKG1lZGlhRXZlbnQuYXZNZW1vcnkuZ2V0TmF0aXZlSGFuZGxlKCkpOwotICAgICAgIC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bnRlbmRTY2FuQXRzYzNQbHBJbmZvPiBwbHBJbmZvcyA9IG1lc3NhZ2UuYXRzYzNQbHBJbmZvcygpOwotICAgICAgICAgICAgdmVjdG9yPFR1bmVyRnJvbnRlbmRTY2FuQXRzYzNQbHBJbmZvPiB0dW5lclBscEluZm9zOwotICAgICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBwbHBJbmZvcy5zaXplKCk7IGkrKykgewotICAgICAgICAgICAgICAgIGF1dG8gaW5mbyA9IHBscEluZm9zW2ldOwotICAgICAgICAgICAgICAgIGludDhfdCBwbHBJZCA9IChpbnQ4X3QpIGluZm8ucGxwSWQ7Ci0gICAgICAgICAgICAgICAgYm9vbCBsbHMgPSAoYm9vbCkgaW5mby5iTGxzRmxhZzsKLSAgICAgICAgICAgICAgICBUdW5lckZyb250ZW5kU2NhbkF0c2MzUGxwSW5mbyBwbHBJbmZvewotICAgICAgICAgICAgICAgICAgICAucGxwSWQgPSBwbHBJZCwKLSAgICAgICAgICAgICAgICAgICAgLmxsc0ZsYWcgPSBsbHMsCi0gICAgICAgICAgICAgICAgfTsKLSAgICAgICAgICAgICAgICB0dW5lclBscEluZm9zLnB1c2hfYmFjayhwbHBJbmZvKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIHNjYW5NZXNzYWdlLnNldDxUdW5lckZyb250ZW5kU2Nhbk1lc3NhZ2U6OmF0c2MzUGxwSW5mb3M+KHR1bmVyUGxwSW5mb3MpOwotICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgIH0KLSAgICAgICAgZGVmYXVsdDoKLSAgICAgICAgICAgIGJyZWFrOworICAgIEFMT0dWKCJGcm9udGVuZENhbGxiYWNrOjpvblNjYW5NZXNzYWdlLCB0eXBlPSVkIiwgdHlwZSk7CisgICAgaWYgKG1UdW5lckZyb250ZW5kQ2FsbGJhY2sgIT0gbnVsbHB0cikgeworICAgICAgICBtVHVuZXJGcm9udGVuZENhbGxiYWNrLT5vblNjYW5NZXNzYW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6aGlkbF9kaXNjcmltaW5hdG9yOjpkdmJ0OgotICAgICAgICAgICAgICAgICAgICBtb2R1bGF0aW9uID0gKGludCkgbS5kdmJ0KCk7Ci0gICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRNb2R1bGF0aW9uOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmR2YnM6Ci0gICAgICAgICAgICAgICAgICAgIG1vZHVsYXRpb24gPSAoaW50KSBtLmR2YnMoKTsKLSAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgY2FzZSBGcm9udGVuZE1vZHVsYXRpb246OmhpZGxfZGlzY3JpbWluYXRvcjo6aXNkYnM6Ci0gICAgICAgICAgICAgICAgICAgIG1vZHVsYXRpb24gPSAoaW50KSBtLmlzZGJzKCk7Ci0gICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRNb2R1bGF0aW9uOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmlzZGJzMzoKLSAgICAgICAgICAgICAgICAgICAgbW9kdWxhdGlvbiA9IChpbnQpIG0uaXNkYnMzKCk7Ci0gICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRNb2R1bGF0aW9uOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmlzZGJ0OgotICAgICAgICAgICAgICAgICAgICBtb2R1bGF0aW9uID0gKGludCkgbS5pc2RidCgpOwotICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICBjYXNlIEZyb250ZW5kTW9kdWxhdGlvbjo6aGlkbF9kaXNjcmltaW5hdG9yOjphdHNjOgotICAgICAgICAgICAgICAgICAgICBtb2R1bGF0aW9uID0gKGludCkgbS5hdHNjKCk7Ci0gICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRNb2R1bGF0aW9uOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmF0c2MzOgotICAgICAgICAgICAgICAgICAgICBtb2R1bGF0aW9uID0gKGludCkgbS5hdHNjMygpOwotICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICBjYXNlIEZyb250ZW5kTW9kdWxhdGlvbjo6aGlkbF9kaXNjcmltaW5hdG9yOjpkdG1iOgotICAgICAgICAgICAgICAgICAgICBtb2R1bGF0aW9uID0gKGludCkgbS5kdG1iKCk7Ci0gICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgc2Nhbk1lc3NhZ2Uuc2V0PFR1bmVyRnJvbnRlbmRTY2FuTWVzc2FnZTo6bW9kdWxhdGlvbj4obW9kdWxhdGlvbik7Ci0gICAgICAgICAgICBicmVhazsKLSAgICAgICAgfQotICAgICAgICBjYXNlIEZyb250ZW5kU2Nhbk1lc3NhZ2VUeXBlRXh0MV8xOjpEVkJDX0FOTkVYOiB7Ci0gICAgICAgICAgICBzY2FuTWVzc2FnZS5zZXQ8VHVuZXJGcm9udGVuZFNjYW5NZXNzYWdlOjphbm5leD4oKGludCltZXNzYWdlLmFubmV4KCkpOwotICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgIH0KLSAgICAgICAgY2FzZSBGcm9udGVuZFNjYW5NZXNzYWdlVHlwZUV4dDFfMTo6SElHSF9QUklPUklUWTogewotICAgICAgICAgICAgc2Nhbk1lc3NhZ2Uuc2V0PFR1bmVyRnJvbnRlbmRTY2FuTWVzc2FnZTo6aXNIaWdoUHJpb3JpdHk+KG1lc3NhZ2UuaXNIaWdoUHJpb3JpdHkoKSk7Ci0gICAgICAgICAgICBicmVhazsKLSAgICAgICAgfQotICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAgYnJlYWs7Ci0gICAgfQotICAgIG1UdW5lckZyb250ZW5kQ2FsbGJhY2stPm9uU2Nhbk1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gICAgICAgICB9Ci0gICAgICAgICAgICBjYXNlIEZyb250ZW5kU3RhdHVzOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmJlcjogewotICAgICAgICAgICAgICAgIHN0YXR1cy5zZXQ8VHVuZXJGcm9udGVuZFN0YXR1czo6YmVyPigoaW50KXMuYmVyKCkpOwotICAgICAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBjYXNlIEZyb250ZW5kU3RhdHVzOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OnBlcjogewotICAgICAgICAgICAgICAgIHN0YXR1cy5zZXQ8VHVuZXJGcm9udGVuZFN0YXR1czo6cGVyPigoaW50KXMucGVyKCkpOwotICAgICAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBjYXNlIEZyb250ZW5kU3RhdHVzOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OnByZUJlcjogewotICAgICAgICAgICAgICAgIHN0YXR1cy5zZXQ8VHVuZXJGcm9udGVuZFN0YXR1czo6cHJlQmVyPigoaW50KXMucHJlQmVyKCkpOwotICAgICAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBjYXNlIEZyb250ZW5kU3RhdHVzOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OnNpZ25hbFF1YWxpdHk6IHsKLSAgICAgICAgICAgICAgICBzdGF0dXMuc2V0PFR1bmVyRnJvbnRlbmRTdGF0dXM6OnNpZ25hbFF1YWxpdHk+KChpbnQpcy5zaWduYWxRdWFsaXR5KCkpOwotICAgICAgICAgICAgICAgIGFpZ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1bGF0aW9uOiB7Ci0gICAgICAgICAgICAgICAgc3dpdGNoIChzLm1vZHVsYXRpb24oKS5nZXREaXNjcmltaW5hdG9yKCkpIHsKLSAgICAgICAgICAgICAgICAgICAgY2FzZSBGcm9udGVuZE1vZHVsYXRpb25TdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6ZHZiYzoKLSAgICAgICAgICAgICAgICAgICAgICAgIHN0YXR1cy5zZXQ8VHVuZXJGcm9udGVuZFN0YXR1czo6bW9kdWxhdGlvbj4oKGludClzLm1vZHVsYXRpb24oKS5kdmJjKCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgICAgICBjYXNlIEZyb250ZW5kTW9kdWxhdGlvblN0YXR1czo6aGlkbF9kaXNjcmltaW5hdG9yOjpkdmJzOgotICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzLnNldDxUdW5lckZyb250ZW5kU3RhdHVzOjptb2R1bGF0aW9uPigoaW50KXMubW9kdWxhdGlvbigpLmR2YnMoKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOwotICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRNb2R1bGF0aW9uU3RhdHVzOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmlzZGJzOgotICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzLnNldDxUdW5lckZyb250ZW5kU3RhdHVzOjptb2R1bGF0aW9uPigoaW50KXMubW9kdWxhdGlvbigpLmlzZGJzKCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgICAgICBjYXNlIEZyb250ZW5kTW9kdWxhdGlvblN0YXR1czo6aGlkbF9kaXNjcmltaW5hdG9yOjppc2RiczM6Ci0gICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXMuc2V0PFR1bmVyRnJvbnRlbmRTdGF0dXM6Om1vZHVsYXRpb24+KChpbnQpcy5tb2R1bGF0aW9uKCkuaXNkYnMzKCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgICAgICBjYXNlIEZyb250ZW5kTW9kdWxhdGlvblN0YXR1czo6aGlkbF9kaXNjcmltaW5hdG9yOjppc2RidDoKLSAgICAgICAgICAgICAgICAgICAgICAgIHN0YXR1cy5zZXQ8VHVuZXJGcm9udGVuZFN0YXR1czo6bW9kdWxhdGlvbj4oKGludClzLm1vZHVsYXRpb24oKS5pc2RidCgpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBjYXNlIEZyb250ZW5kU3RhdHVzOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmludmVyc2lvbjogewotICAgICAgICAgICAgICAgIHN0YXR1cy5zZXQ8VHVuZXJGcm9udGVuZFN0YXR1czo6aW52ZXJzaW9uPigoaW50KXMuaW52ZXJzaW9uKCkpOwotICAgICAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBjYXNlIEZyb250ZW5kU3RhdHVzOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmxuYlZvbHRhZ2U6IHsKLSAgICAgICAgICAgICAgICBzdGF0dXMuc2V0PFR1bmVyRnJvbnRlbmRTdGF0dXM6OmxuYlZvbHRhZ2U+KChpbnQpcy5sbmJWb2x0YWdlKCkpOwotICAgICAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBjYXNlIEZyb250ZW5kU3RhdHVzOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OnBscElkOiB7Ci0gICAgICAgICAgICAgICAgc3RhdHVzLnNldDxUdW5lckZyb250ZW5kU3RhdHVzOjpwbHBJZD4oKGludDhfdClzLnBscElkKCkpOwotICAgICAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBjYXNlIEZyb250ZW5kU3RhdHVzOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmlzRVdCUzogewotICAgICAgICAgICAgICAgIHN0YXR1cy5zZXQ8VHVuZXJGcm9udGVuZFN0YXR1czo6aXNFV0JTPihzLmlzRVdCUygpKTsKLSAgICAgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOwotICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgY2FzZSBGcm9udGVuZFN0YXR1czo6aGlkbF9kaXNjcmltaW5hdG9yOjphZ2M6IHsKLSAgICAgICAgICAgICAgICBzdGF0dXMuc2V0PFR1bmVyRnJvbnRlbmRTdGF0dXM6OmFnYz4oKGludDhfdClzLmFnYygpKTsKLSAgICAgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOwotICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgY2FzZSBGcm9udGVuZFN0YXR1czo6aGlkbF9kaXNjcmltaW5hdG9yOjppc0xuYU9uOiB7Ci0gICAgICAgICAgICAgICAgc3RhdHVzLnNldDxUdW5lckZyb250ZW5kU3RhdHVzOjppc0xuYU9uPihzLmlzTG5hT24oKSk7Ci0gICAgICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRTdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6aXNMYXllckVycm9yOiB7Ci0gICAgICAgICAgICAgICAgdmVjdG9yPGJvb2w+IGUocy5pc0xheWVyRXJyb3IoKS5iZWdpbigpLCBzLmlzTGF5ZXJFcnJvcigpLmVuZCgpKTsKLSAgICAgICAgICAgICAgICBzdGF0dXMuc2V0PFR1bmVyRnJvbnRlbmRTdGF0dXM6OmlzTGF5ZXJFcnJvcj4oZSk7Ci0gICAgICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRTdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6bWVyOiB7Ci0gICAgICAgICAgICAgICAgc3RhdHVzLnNldDxUdW5lckZyb250ZW5kU3RhdHVzOjptZXI+KChpbnQpcy5tZXIoKSk7Ci0gICAgICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRTdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6ZnJlcU9mZnNldDogewotICAgICAgICAgICAgICAgIHN0YXR1cy5zZXQ8VHVuZXJGcm9udGVuZFN0YXR1czo6ZnJlcU9mZnNldD4oKGludClzLmZyZXFPZmZzZXQoKSk7Ci0gICAgICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRTdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6aGllcmFyY2h5OiB7Ci0gICAgICAgICAgICAgICAgc3RhdHVzLnNldDxUdW5lckZyb250ZW5kU3RhdHVzOjpoaWVyYXJjaHk+KChpbnQpcy5oaWVyYXJjaHkoKSk7Ci0gICAgICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRTdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6aXNSZkxvY2tlZDogewotICAgICAgICAgICAgICAgIHN0YXR1cy5zZXQ8VHVuZXJGcm9udGVuZFN0YXR1czo6aXNSZkxvY2tlZD4ocy5pc1JmTG9ja2VkKCkpOwotICAgICAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBjYXNlIEZyb250ZW5kU3RhdHVzOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OnBscEluZm86IHsKLSAgICAgICAgICAgICAgICB2ZWN0b3I8VHVuZXJGcm9udGVuZFN0YXR1c0F0c2MzUGxwSW5mbz4gaW5mbzsKLSAgICAgICAgICAgICAgICBmb3IgKGF1dG8gaSA6IHMucGxwSW5mbygpKSB7Ci0gICAgICAgICAgICAgICAgICAgIGluZm8ucHVzaF9iYWNrKHsKLSAgICAgICAgICAgICAgICAgICAgICAgIC5wbHBJZCA9IChpbnQ4X3QpaS5wbHBJZCwKLSAgICAgICAgICAgICAgICAgICAgICAgIC5pc0xvY2tlZCA9IGkuaXNMb2NrZWQsCi0gICAgICAgICAgICAgICAgICAgICAgICAudWVjID0gKGludClpLnVlYywKLSAgICAgICAgICAgICAgICAgICAgfSk7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIHN0YXR1cy5zZXQ8VHVuZXJGcm9udGVuZFN0YXR1czo6cGxwSW5mbz4oaW5mbyk7Ci0gICAgICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLSAgICAgICAgfQotICAgIH0KLX0KLQotdm9pZCBUdW5lckZyb250ZW5kOjpnZXRBaWRsRnJvbnRlbmRTdGF0dXNFeHQoCi0gICAgICAgIHZlY3RvcjxGcm9udGVuZFN0YXR1c0V4dDFfMT4mIGhpZGxTdGF0dXMsIHZlY3RvcjxUdW5lckZyb250ZW5kU3RhdHVzPiYgYWlkbFN0YXR1cykgewotICAgIGZvciAoRnJvbnRlbmRTdGF0dXNFeHQxXzEgcyA6IGhpZGxTdGF0dXMpIHsKLSAgICAgICAgVHVuZXJGcm9udGVuZFN0YXR1cyBzdGF0dXM7Ci0gICAgICAgIHN3aXRjaCAocy5nZXREaXNjcmltaW5hdG9yKCkpIHsKLSAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRTdGF0dXNFeHQxXzE6OmhpZGxfZGlzY3JpbWluYXRvcjo6bW9kdWxhdGlvbnM6IHsKLSAgICAgICAgICAgICAgICB2ZWN0b3I8aW50PiBhaWRsTW9kOwotICAgICAgICAgICAgICAgIGZvciAoYXV0byBtIDogcy5tb2R1bGF0aW9ucygpKSB7Ci0gICAgICAgICAgICAgICAgICAgIHN3aXRjaCAobS5nZXREaXNjcmltaW5hdG9yKCkpIHsKLSAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRNb2R1bGF0aW9uOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmR2YmM6Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgYWlkbE1vZC5wdXNoX2JhY2soKGludCltLmR2YmMoKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIEZyb250ZW5kTW9kdWxhdGlvbjo6aGlkbF9kaXNjcmltaW5hdG9yOjpkdmJzOgotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFpZGxNb2QucHVzaF9iYWNrKChpbnQpbS5kdmJzKCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBGcm9udGVuZE1vZHVsYXRpb246OmhpZGxfZGlzY3JpbWluYXRvcjo6ZHZidDoKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBhaWRsTW9kLnB1c2hfYmFjaygoaW50KW0uZHZidCgpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRNb2R1bGF0aW9uOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmlzZGJzOgotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFpZGxNb2QucHVzaF9iYWNrKChpbnQpbS5pc2RicygpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRNb2R1bGF0aW9uOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmlzZGJzMzoKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBhaWRsTW9kLnB1c2hfYmFjaygoaW50KW0uaXNkYnMzKCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBGcm9udGVuZE1vZHVsYXRpb246OmhpZGxfZGlzY3JpbWluYXRvcjo6aXNkYnQ6Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgYWlkbE1vZC5wdXNoX2JhY2soKGludCltLmlzZGJ0KCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBGcm9udGVuZE1vZHVsYXRpb246OmhpZGxfZGlzY3JpbWluYXRvcjo6YXRzYzoKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBhaWRsTW9kLnB1c2hfYmFjaygoaW50KW0uYXRzYygpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRNb2R1bGF0aW9uOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmF0c2MzOgotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFpZGxNb2QucHVzaF9iYWNrKChpbnQpbS5hdHNjMygpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRNb2R1bGF0aW9uOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmR0bWI6Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgYWlkbE1vZC5wdXNoX2JhY2soKGludCltLmR0bWIoKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgc3RhdHVzLnNldDxUdW5lckZyb250ZW5kU3RhdHVzOjptb2R1bGF0aW9ucz4oYWlkbE1vZCk7Ci0gICAgICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRTdGF0dXNFeHQxXzE6OmhpZGxfZGlzY3JpbWluYXRvcjo6YmVyczogewotICAgICAgICAgICAgICAgIHZlY3RvcjxpbnQ+IGIocy5iZXJzKCkuYmVnaW4oKSwgcy5iZXJzKCkuZW5kKCkpOwotICAgICAgICAgICAgICAgIHN0YXR1cy5zZXQ8VHVuZXJGcm9udGVuZFN0YXR1czo6YmVycz4oYik7Ci0gICAgICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRTdGF0dXNFeHQxXzE6OmhpZGxfZGlzY3JpbWluYXRvcjo6Y29kZVJhdGVzOiB7Ci0gICAgICAgICAgICAgICAgdmVjdG9yPGludDY0X3Q+IGNvZGVSYXRlczsKLSAgICAgICAgICAgICAgICBmb3IgKGF1dG8gYyA6IHMuY29kZVJhdGVzKCkpIHsKLSAgICAgICAgICAgICAgICAgICAgY29kZVJhdGVzLnB1c2hfYmFjaygobG9uZyljKTsKLSAgICAgICAgICAgICAgICB9Ci0gICAgICAgICAgICAgICAgc3RhdHVzLnNldDxUdW5lckZyb250ZW5kU3RhdHVzOjpjb2RlUmF0ZXM+KGNvZGVSYXRlcyk7Ci0gICAgICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRTdGF0dXNFeHQxXzE6OmhpZGxfZGlzY3JpbWluYXRvcjo6YmFuZHdpZHRoOiB7Ci0gICAgICAgICAgICAgICAgc3dpdGNoIChzLmJhbmR3aWR0aCgpLmdldERpc2NyaW1pbmF0b3IoKSkgewotICAgICAgICAgICAgICAgICAgICBjYXNlIEZyb250ZW5kQmFuZHdpZHRoOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmF0c2MzOgotICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzLnNldDxUdW5lckZyb250ZW5kU3RhdHVzOjpiYW5kd2lkdGg+KChpbnQpcy5iYW5kd2lkdGgoKS5hdHNjMygpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgICAgICBjYXNlIEZyb250ZW5kQmFuZHdpZHRoOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmR2YmM6Ci0gICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXMuc2V0PFR1bmVyRnJvbnRlbmRTdGF0dXM6OmJhbmR3aWR0aD4oKGludClzLmJhbmR3aWR0aCgpLmR2YmMoKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICAgICAgY2FzZSBGcm9udGVuZEJhbmR3aWR0aDo6aGlkbF9kaXNjcmltaW5hdG9yOjpkdmJ0OgotICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzLnNldDxUdW5lckZyb250ZW5kU3RhdHVzOjpiYW5kd2lkdGg+KChpbnQpcy5iYW5kd2lkdGgoKS5kdmJ0KCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRCYW5kd2lkdGg6OmhpZGxfZGlzY3JpbWluYXRvcjo6aXNkYnQ6Ci0gICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXMuc2V0PFR1bmVyRnJvbnRlbmRTdGF0dXM6OmJhbmR3aWR0aD4oKGludClzLmJhbmR3aWR0aCgpLmlzZGJ0KCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRCYW5kd2lkdGg6OmhpZGxfZGlzY3JpbWluYXRvcjo6ZHRtYjoKLSAgICAgICAgICAgICAgICAgICAgICAgIHN0YXR1cy5zZXQ8VHVuZXJGcm9udGVuZFN0YXR1czo6YmFuZHdpZHRoPigoaW50KXMuYmFuZHdpZHRoKCkuZHRtYigpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOwotICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgY2FzZSBGcm9udGVuZFN0YXR1c0V4dDFfMTo6aGlkbF9kaXNjcmltaW5hdG9yOjppbnRlcnZhbDogewotICAgICAgICAgICAgICAgIHN3aXRjaCAocy5pbnRlcnZhbCgpLmdldERpc2NyaW1pbmF0b3IoKSkgewotICAgICAgICAgICAgICAgICAgICBjYXNlIEZyb250ZW5kR3VhcmRJbnRlcnZhbDo6aGlkbF9kaXNjcmltaW5hdG9yOjpkdmJ0OgotICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzLnNldDxUdW5lckZyb250ZW5kU3RhdHVzOjppbnRlcnZhbD4oKGludClzLmludGVydmFsKCkuZHZidCgpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgICAgICBjYXNlIEZyb250ZW5kR3VhcmRJbnRlcnZhbDo6aGlkbF9kaXNjcmltaW5hdG9yOjppc2RidDoKLSAgICAgICAgICAgICAgICAgICAgICAgIHN0YXR1cy5zZXQ8VHVuZXJGcm9udGVuZFN0YXR1czo6aW50ZXJ2YWw+KChpbnQpcy5pbnRlcnZhbCgpLmlzZGJ0KCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRHdWFyZEludGVydmFsOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmR0bWI6Ci0gICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXMuc2V0PFR1bmVyRnJvbnRlbmRTdGF0dXM6OmludGVydmFsPigoaW50KXMuaW50ZXJ2YWwoKS5kdG1iKCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBjYXNlIEZyb250ZW5kU3RhdHVzRXh0MV8xOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OnRyYW5zbWlzc2lvbk1vZGU6IHsKLSAgICAgICAgICAgICAgICBzd2l0Y2ggKHMudHJhbnNtaXNzaW9uTW9kZSgpLmdldERpc2NyaW1pbmF0b3IoKSkgewotICAgICAgICAgICAgICAgICAgICBjYXNlIEZyb250ZW5kVHJhbnNtaXNzaW9uTW9kZTo6aGlkbF9kaXNjcmltaW5hdG9yOjpkdmJ0OgotICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzLnNldDxUdW5lckZyb250ZW5kU3RhdHVzOjp0cmFuc21pc3Npb25Nb2RlPigKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGludClzLnRyYW5zbWlzc2lvbk1vZGUoKS5kdmJ0KCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRUcmFuc21pc3Npb25Nb2RlOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmlzZGJ0OgotICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzLnNldDxUdW5lckZyb250ZW5kU3RhdHVzOjp0cmFuc21pc3Npb25Nb2RlPigKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGludClzLnRyYW5zbWlzc2lvbk1vZGUoKS5pc2RidCgpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgICAgICBjYXNlIEZyb250ZW5kVHJhbnNtaXNzaW9uTW9kZTo6aGlkbF9kaXNjcmltaW5hdG9yOjpkdG1iOgotICAgICAgICAgICAgICAgICAgICAgICAgc3RhdHVzLnNldDxUdW5lckZyb250ZW5kU3RhdHVzOjp0cmFuc21pc3Npb25Nb2RlPigKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGludClzLnRyYW5zbWlzc2lvbk1vZGUoKS5kdG1iKCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBjYXNlIEZyb250ZW5kU3RhdHVzRXh0MV8xOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OnVlYzogewotICAgICAgICAgICAgICAgIHN0YXR1cy5zZXQ8VHVuZXJGcm9udGVuZFN0YXR1czo6dWVjPigoaW50KXMudWVjKCkpOwotICAgICAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBjYXNlIEZyb250ZW5kU3RhdHVzRXh0MV8xOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OnN5c3RlbUlkOiB7Ci0gICAgICAgICAgICAgICAgc3RhdHVzLnNldDxUdW5lckZyb250ZW5kU3RhdHVzOjpzeXN0ZW1JZD4oKGNoYXIxNl90KXMuc3lzdGVtSWQoKSk7Ci0gICAgICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKLSAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGNhc2UgRnJvbnRlbmRTdGF0dXNFeHQxXzE6OmhpZGxfZGlzY3JpbWluYXRvcjo6aW50ZXJsZWF2aW5nOiB7Ci0gICAgICAgICAgICAgICAgdmVjdG9yPGludD4gYWlkbEludGVyOwotICAgICAgICAgICAgICAgIGZvciAoYXV0byBpIDogcy5pbnRlcmxlYXZpbmcoKSkgewotICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGkuZ2V0RGlzY3JpbWluYXRvcigpKSB7Ci0gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIEZyb250ZW5kSW50ZXJsZWF2ZU1vZGU6OmhpZGxfZGlzY3JpbWluYXRvcjo6YXRzYzM6Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgYWlkbEludGVyLnB1c2hfYmFjaygoaW50KWkuYXRzYzMoKSk7Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgICAgICAgICBjYXNlIEZyb250ZW5kSW50ZXJsZWF2ZU1vZGU6OmhpZGxfZGlzY3JpbWluYXRvcjo6ZHZiYzoKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBhaWRsSW50ZXIucHVzaF9iYWNrKChpbnQpaS5kdmJjKCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBGcm9udGVuZEludGVybGVhdmVNb2RlOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmR0bWI6Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgYWlkbEludGVyLnB1c2hfYmFjaygoaW50KWkuZHRtYigpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKLSAgICAgICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBzdGF0dXMuc2V0PFR1bmVyRnJvbnRlbmRTdGF0dXM6OmludGVybGVhdmluZz4oYWlkbEludGVyKTsKLSAgICAgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOwotICAgICAgICAgICAgICAgIGJyZWFr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c2NyaW1pbmF0b3I6OmR2YnM6Ci0gICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXMuc2V0PFR1bmVyRnJvbnRlbmRTdGF0dXM6OnJvbGxPZmY+KChpbnQpcy5yb2xsT2ZmKCkuZHZicygpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgICAgICBjYXNlIEZyb250ZW5kUm9sbE9mZjo6aGlkbF9kaXNjcmltaW5hdG9yOjppc2RiczoKLSAgICAgICAgICAgICAgICAgICAgICAgIHN0YXR1cy5zZXQ8VHVuZXJGcm9udGVuZFN0YXR1czo6cm9sbE9mZj4oKGludClzLnJvbGxPZmYoKS5pc2RicygpKTsKLSAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAgICAgICAgICAgICBjYXNlIEZyb250ZW5kUm9sbE9mZjo6aGlkbF9kaXNjcmltaW5hdG9yOjppc2RiczM6Ci0gICAgICAgICAgICAgICAgICAgICAgICBzdGF0dXMuc2V0PFR1bmVyRnJvbnRlbmRTdGF0dXM6OnJvbGxPZmY+KChpbnQpcy5yb2xsT2ZmKCkuaXNkYnMzKCkpOwotICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICAgICAgfQotICAgICAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7Ci0gICAgICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBjYXNlIEZyb250ZW5kU3RhdHVzRXh0MV8xOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmlzTWlzbzogewotICAgICAgICAgICAgICAgIHN0YXR1cy5zZXQ8VHVuZXJGcm9udGVuZFN0YXR1czo6aXNNaXNvPihzLmlzTWlzbygpKTsKLSAgICAgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOwotICAgICAgICAgICAgICAgIGJyZWFrOwotICAgICAgICAg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HVsYXRpb24gPSBzdGF0aWNfY2FzdDxGcm9udGVuZEF0c2NNb2R1bGF0aW9uPihhdHNjLm1vZHVsYXRpb24pLAotICAgICAgICAgICAgfSk7Ci0gICAgICAgICAgICBicmVhazsKLSAgICAgICAgfQotICAgICAgICBjYXNlIFR1bmVyRnJvbnRlbmRVbmlvblNldHRpbmdzOjphdHNjMzogewotICAgICAgICAgICAgYXV0byBhdHNjMyA9IHNldHRpbmdzLmdldDxUdW5lckZyb250ZW5kVW5pb25TZXR0aW5nczo6YXRzYzM+KCk7Ci0gICAgICAgICAgICBmcm9udGVuZFNldHRpbmdzLmF0c2MzKHsKLSAgICAgICAgICAgICAgICAuZnJlcXVlbmN5ID0gc3RhdGljX2Nhc3Q8dWludDMyX3Q+KGF0c2MzLmZyZXF1ZW5jeSksCi0gICAgICAgICAgICAgICAgLmJhbmR3aWR0aCA9IHN0YXRpY19jYXN0PEZyb250ZW5kQXRzYzNCYW5kd2lkdGg+KGF0c2MzLmJhbmR3aWR0aCksCi0gICAgICAgICAgICAgICAgLmRlbW9kT3V0cHV0Rm9ybWF0ID0gc3RhdGljX2Nhc3Q8RnJvbnRlbmRBdHNjM0RlbW9kT3V0cHV0Rm9ybWF0PigKLSAgICAgICAgICAgICAgICAgICAgICAgIGF0c2MzLmRlbW9kT3V0cHV0Rm9ybWF0KSwKLSAgICAgICAgICAgICAgICAucGxwU2V0dGluZ3MgPSBnZXRBdHNjM1BscFNldHRpbmdzKGF0c2MzKSwKLSAgICAgICAgICAgIH0pOwotICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgIH0KLSAgICAgICAgY2FzZSBUdW5lckZyb250ZW5kVW5pb25TZXR0aW5nczo6Y2FibGU6IHsKLSAgICAgICAgICAgIGF1dG8gZHZiYyA9IHNldHRpbmdzLmdldDxUdW5lckZyb250ZW5kVW5pb25TZXR0aW5nczo6Y2FibGU+KCk7Ci0gICAgICAgICAgICBmcm9udGVuZFNldHRpbmdzLmR2YmMoewotICAgICAgICA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gICAgICAgICAgICAgICAuYWZ0RmxhZyA9IHN0YXRpY19jYXN0PEZyb250ZW5kQW5hbG9nQWZ0RmxhZz4oYW5hbG9nLmFmdEZsYWcpLAotICAgICAgICAgICAgICAgIH0pOwotICAgICAgICAgICAgfSBlbHNlIHsKLSAgICAgICAgICAgICAgICBmcm9udGVuZFNldHRpbmdzRXh0LnNldHRpbmdFeHQubm9pbml0KCk7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBicmVhazsKLSAgICAgICAgfQotICAgICAgICBjYXNlIFR1bmVyRnJvbnRlbmRVbmlvblNldHRpbmdzOjpjYWJsZTogewotICAgICAgICAgICAgYXV0byBkdmJjID0gc2V0dGluZ3MuZ2V0PFR1bmVyRnJvbnRlbmRVbmlvblNldHRpbmdzOjpjYWJsZT4oKTsKLSAgICAgICAgICAgIGlmIChkdmJjLmlzRXh0ZW5kZWQpIHsKLSAgICAgICAgICAgICAgICBmcm9udGVuZFNldHRpbmdzRXh0LnNldHRpbmdFeHQuZHZiYyh7Ci0gICAgICAgICAgICAgICAgICAgIC5pbnRlcmxlYXZlTW9kZSA9IHN0YXRpY19jYXN0PEZyb250ZW5kQ2FibGVUaW1lSW50ZXJsZWF2ZU1vZGU+KAotICAgICAgICAgICAgICAgICAgICAgICAgICAgIGR2YmMuaW50ZXJsZWF2ZU1vZGUpLAotICAgICAgICAgICAgICAgICAgICAuYmFuZHdpZHRoID0gc3RhdGljX2Nhc3Q8RnJvbnRlbmREdmJjQmFuZHdpZHRoPigKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICBkdmJjLmJhbmR3aWR0aCksCi0gICAgICAgICAgICAgICAgfSk7Ci0gICAgICAgICAgICB9IGVsc2UgewotICAgICAgICAgICAgICAgIGZyb250ZW5kU2V0dGluZ3NFeHQuc2V0dGluZ0V4dC5ub2luaXQoKTsKLSAgICAgICAgICAgIH0KLSAgICAgICAgICAgIGJyZWFrOwotICAgICAgICB9Ci0gICAgICAgIGNhc2UgVHVuZXJGcm9udGVuZFVuaW9uU2V0dGluZ3M6OmR2YnM6IHsKLSAgICAgICAgICAgIGF1dG8gZHZicyA9IHNldHRpbmdzLmdldDxUdW5lckZyb250ZW5kVW5pb25TZXR0aW5nczo6ZHZicz4oKTsKLSAgICAgICAgICAgIGlmIChkdmJzLmlzRXh0ZW5kZWQpIHsKLSAgICAgICAgICAgICAgICBmcm9udGVuZFNldHRpbmdzRXh0LnNldHRpbmdFeHQuZHZicyh7Ci0gICAgICAgICAgICAgICAgICAgIC5zY2FuVHlwZSA9IHN0YXRpY19jYXN0PEZyb250ZW5kRHZic1NjYW5UeXBlPihkdmJzLnNjYW5UeXBlKSwKLSAgICAgICAgICAgICAgICAgICAgLmlzRGlzZXFjUnhNZXNzYWdlID0gZHZicy5pc0Rpc2VxY1J4TWVzc2FnZSwKLSAgICAgICAgICAgICAgICB9KTsKLSAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgZnJvbnRlbmRTZXR0aW5nc0V4dC5zZXR0aW5nRXh0Lm5vaW5pdCgpOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgIH0KLSAgICAgICAgY2FzZSBUdW5lckZyb250ZW5kVW5pb25TZXR0aW5nczo6ZHZidDogewotICAgICAgICAgICAgYXV0byBkdmJ0ID0gc2V0dGluZ3MuZ2V0PFR1bmVyRnJvbnRlbmRVbmlvblNldHRpbmdzOjpkdmJ0PigpOwotICAgICAgICAgICAgaWYgKGR2YnQuaXNFeHRlbmRlZCkgewotICAgICAgICAgICAgICAgIGZyb250ZW5kU2V0dGluZ3NFeHQuc2V0dGluZ0V4dC5kdmJ0KHsKLSAgICAgICAgICAgICAgICAgICAgLmNvbnN0ZWxsYXRpb24gPQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PGhhcmR3YXJlOjp0djo6dHVuZXI6OlYxXzE6OkZyb250ZW5kRHZidENvbnN0ZWxsYXRpb24+KAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZHZidC5jb25zdGVsbGF0aW9uKSwKLSAgICAgICAgICAgICAgICAgICAgLnRyYW5zbWlzc2lvbk1vZGUgPQotICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PGhhcmR3YXJlOjp0djo6dHVuZXI6OlYxXzE6OkZyb250ZW5kRHZidFRyYW5zbWlzc2lvbk1vZGU+KAotICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZHZidC50cmFuc21pc3Npb25Nb2RlKSwKLSAgICAgICAgICAgICAgICB9KTsKLSAgICAgICAgICAgIH0gZWxzZSB7Ci0gICAgICAgICAgICAgICAgZnJvbnRlbmRTZXR0aW5nc0V4dC5zZXR0aW5nRXh0Lm5vaW5pdCgpOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgIH0KLSAgICAgICAgY2FzZSBUdW5lckZyb250ZW5kVW5pb25TZXR0aW5nczo6ZHRtYjogewotICAgICAgICAgICAgYXV0byBkdG1iID0gc2V0dGluZ3MuZ2V0PFR1bmVyRnJvbnRlbmRVbmlvblNldHRpbmdzOjpkdG1iPigpOwotICAgICAgICAgICAgZnJvbnRlbmRTZXR0aW5nc0V4dC5zZXR0aW5nRXh0LmR0bWIoewotICAgICAgICAgICAgICAgIC5mcmVxdWVuY3kgPSBzdGF0aWNfY2FzdDx1aW50MzJfdD4oZHRtYi5mcmVxdWVuY3kpLAotICAgICAgICAgICAgICAgIC50cmFuc21pc3Npb25Nb2RlID0gc3RhdGljX2Nhc3Q8RnJvbnRlbmREdG1iVHJhbnNtaXNzaW9uTW9kZT4oCi0gICAgICAgICAgICAgICAgICAgICAgICBkdG1iLnRyYW5zbWlzc2lvbk1vZGUpLAotICAgICAgICAgICAgICAgIC5iYW5kd2lkdGggPSBzdGF0aWNfY2FzdDxGcm9udGVuZER0bWJCYW5kd2lkdGg+KGR0bWIuYmFuZHdpZHRoKSwKLSAgICAgICAgICAg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AgICAgQUxPR0QoImdldCBJVHVuZXIgZmFpbGVkIik7CisgICAgICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6ZnJvbVNlcnZpY2VTcGVjaWZpY0Vycm9yKAorICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PGludDMyX3Q+KFJlc3VsdDo6VU5BVkFJTEFCTEUpKTsKKyAgICB9CisKKyAgICByZXR1cm4gbVR1bmVyLT5zZXRMbmEoYkVuYWJsZSk7Cit9CisKKzo6bmRrOjpTY29wZWRBU3RhdHVzIFR1bmVyU2VydmljZTo6c2V0TWF4TnVtYmVyT2ZGcm9udGVuZHMoRnJvbnRlbmRUeXBlIGluX2Zyb250ZW5kVHlwZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCBpbl9tYXhOdW1iZXIpIHsKKyAgICBpZiAoIWhhc0lUdW5lcigpKSB7CisgICAgICAgIEFMT0dEKCJnZXQgSVR1bmVyIGZhaWxlZCIpOworICAgICAgICByZXR1cm4gOjpuZGs6OlNjb3BlZEFTdGF0dXM6OmZyb21TZXJ2aWNlU3BlY2lmaWNFcnJvcigKKyAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxpbnQzMl90PihSZXN1bHQ6OlVOQVZBSUxBQkxFKSk7CisgICAgfQorCisgICAgcmV0dXJuIG1UdW5lci0+c2V0TWF4TnVtYmVyT2ZGcm9udGVuZHMoaW5fZnJvbnRlbmRUeXBlLCBpbl9tYXhOdW1iZXIpOworfQorCis6Om5kazo6U2NvcGVkQVN0YXR1cyBUdW5lclNlcnZpY2U6OmdldE1heE51bWJlck9mRnJvbnRlbmRzKEZyb250ZW5kVHlwZSBpbl9mcm9udGVuZFR5cGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3QqIF9haWRsX3JldHVybikgeworICAgIGlmICghaGFzSVR1bmVy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OmdldFRSTUZyb250ZW5kSW5mb3MoKSB7CiAgICAgdmVjdG9yPFR1bmVyRnJvbnRlbmRJbmZvPiBpbmZvczsKKyAgICB2ZWN0b3I8aW50MzJfdD4gaWRzOworICAgIGF1dG8gc3RhdHVzID0gbVR1bmVyLT5nZXRGcm9udGVuZElkcygmaWRzKTsKKyAgICBpZiAoIXN0YXR1cy5pc09rKCkpIHsKKyAgICAgICAgcmV0dXJuIGluZm9zOworICAgIH0KKwogICAgIGZvciAoaW50IGkgPSAwOyBpIDwgaWRzLnNpemUoKTsgaSsrKSB7CiAgICAgICAgIEZyb250ZW5kSW5mbyBmcm9udGVuZEluZm87Ci0gICAgICAgIFJlc3VsdCByZXMgPSBnZXRIaWRsRnJvbnRlbmRJbmZvKChpbnQpaWRzW2ldLCBmcm9udGVuZEluZm8pOwotICAgICAgICBpZiAocmVzICE9IFJlc3VsdDo6U1VDQ0VTUykgeworICAgICAgICBhdXRvIHJlcyA9IG1UdW5lci0+Z2V0RnJvbnRlbmRJbmZvKGlkc1tpXSwgJmZyb250ZW5kSW5mbyk7CisgICAgICAgIGlmICghcmVzLmlzT2soKSkgewogICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgIH0KICAgICAgICAgVHVuZXJGcm9udGVuZEluZm8gdHVuZXJGcm9udGVuZEluZm97Ci0gICAgICAgICAgICAuaGFuZGxlID0gZ2V0UmVzb3VyY2VIYW5kbGVGcm9tSWQoKGludClpZHNbaV0sIEZST05URU5EKSwKLSAgICAgICAgICAgIC50eXBlID0gc3RhdGljX2Nhc3Q8aW50Pihmcm9udGVuZEluZm8udHlwZSksCi0gICAgICAgICAgICAuZXhjbHVzaXZlR3JvdXBJZCA9IHN0YXRpY19jYXN0PGludD4oZnJvbnRlbmRJbmZvLmV4Y2x1c2l2ZUdyb3VwSWQpLAorICAgICAgICAgICAgICAgIC5oYW5kbGUgPSBUdW5lckhlbHBlcjo6Z2V0UmVzb3VyY2VIYW5kbGVGcm9tSWQoKGludClpZHNbaV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gICAgICAgICAgICBUdW5lckZyb250ZW5kQ2FibGVDYXBhYmlsaXRpZXMgY2FibGVDYXBzewotICAgICAgICAgICAgICAgICAgICAubW9kdWxhdGlvbkNhcCA9IChpbnQpaGFsSW5mby5mcm9udGVuZENhcHMuZHZiY0NhcHMoKS5tb2R1bGF0aW9uQ2FwLAotICAgICAgICAgICAgICAgICAgICAuY29kZVJhdGVDYXAgPSAoaW50NjRfdCloYWxJbmZvLmZyb250ZW5kQ2Fwcy5kdmJjQ2FwcygpLmZlY0NhcCwKLSAgICAgICAgICAgICAgICAgICAgLmFubmV4Q2FwID0gKGludCloYWxJbmZvLmZyb250ZW5kQ2Fwcy5kdmJjQ2FwcygpLmFubmV4Q2FwLAotICAgICAgICAgICAgICAgIH07Ci0gICAgICAgICAgICAgICAgY2Fwcy5zZXQ8VHVuZXJGcm9udGVuZENhcGFiaWxpdGllczo6Y2FibGVDYXBzPihjYWJsZUNhcHMpOwotICAgICAgICAgICAgfQotICAgICAgICAgICAgYnJlYWs7Ci0gICAgICAgIH0KLSAgICAgICAgY2FzZSBGcm9udGVuZFR5cGU6OkRWQlM6IHsKLSAgICAgICAgICAgIGlmIChGcm9udGVuZEluZm86OkZyb250ZW5kQ2FwYWJpbGl0aWVzOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmR2YnNDYXBzCi0gICAgICAgICAgICAgICAgICAgID09IGhhbEluZm8uZnJvbnRlbmRDYXBzLmdldERpc2NyaW1pbmF0b3IoKSkgewotICAgICAgICAgICAgICAgIFR1bmVyRnJvbnRlbmREdmJzQ2FwYWJpbGl0aWVzIGR2YnNDYXBzewotICAgICAgICAgICAgICAgICAgICAubW9kdWxhdGlvbkNhcCA9IChpbnQpaGFsSW5mby5mcm9udGVuZENhcHMuZHZic0NhcHMoKS5tb2R1bGF0aW9uQ2FwLAotICAgICAgICAgICAgICAgICAgICAuY29kZVJhdGVDYXAgPSAobG9uZyloYWxJbmZvLmZyb250ZW5kQ2Fwcy5kdmJzQ2Fwc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b250ZW5kVHlwZTo6SVNEQlQ6IHsKLSAgICAgICAgICAgIGlmIChGcm9udGVuZEluZm86OkZyb250ZW5kQ2FwYWJpbGl0aWVzOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmlzZGJ0Q2FwcwotICAgICAgICAgICAgICAgICAgICA9PSBoYWxJbmZvLmZyb250ZW5kQ2Fwcy5nZXREaXNjcmltaW5hdG9yKCkpIHsKLSAgICAgICAgICAgICAgICBUdW5lckZyb250ZW5kSXNkYnRDYXBhYmlsaXRpZXMgaXNkYnRDYXBzewotICAgICAgICAgICAgICAgICAgICAubW9kZUNhcCA9IChpbnQpaGFsSW5mby5mcm9udGVuZENhcHMuaXNkYnRDYXBzKCkubW9kZUNhcCwKLSAgICAgICAgICAgICAgICAgICAgLmJhbmR3aWR0aENhcCA9IChpbnQpaGFsSW5mby5mcm9udGVuZENhcHMuaXNkYnRDYXBzKCkuYmFuZHdpZHRoQ2FwLAotICAgICAgICAgICAgICAgICAgICAubW9kdWxhdGlvbkNhcCA9IChpbnQpaGFsSW5mby5mcm9udGVuZENhcHMuaXNkYnRDYXBzKCkubW9kdWxhdGlvbkNhcCwKLSAgICAgICAgICAgICAgICAgICAgLmNvZGVSYXRlQ2FwID0gKGludCloYWxJbmZvLmZyb250ZW5kQ2Fwcy5pc2RidENhcHMoKS5jb2RlcmF0ZUNhcCwKLSAgICAgICAgICAgICAgICAgICAgLmd1YXJkSW50ZXJ2YWxDYXAgPSAoaW50KWhhbEluZm8uZnJvbnRlbmRDYXBzLmlzZGJ0Q2FwcygpLmd1YXJkSW50ZXJ2YWxDYXAsCi0gICAgICAgICAgICAgICAgfTsKLSAgICAgICAgICAgICAgICBjYXBzLnNldDxUdW5lckZyb250ZW5kQ2FwYWJpbGl0aWVzOjppc2RidENhcHM+KGlzZGJ0Q2Fwcyk7Ci0gICAgICAgICAgICB9Ci0gICAgICAgICAgICBicmVhazsKLSAgICAgICAgfQotICAgICAgICBkZWZhdWx0OgotICAgICAgICAgICAg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QVN0YXR1cyBnZXRGcm9udGVuZEluZm8oaW50MzJfdCBpbl9mcm9udGVuZEhhbmRsZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRnJvbnRlbmRJbmZvKiBfYWlkbF9yZXR1cm4pIG92ZXJyaWRlOworICAgIDo6bmRrOjpTY29wZWRBU3RhdHVzIG9wZW5Gcm9udGVuZChpbnQzMl90IGluX2Zyb250ZW5kSGFuZGxlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaGFyZWRfcHRyPElUdW5lckZyb250ZW5kPiogX2FpZGxfcmV0dXJuKSBvdmVycmlkZTsKKyAgICA6Om5kazo6U2NvcGVkQVN0YXR1cyBvcGVuTG5iKGludDMyX3QgaW5fbG5iSGFuZGxlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2hhcmVkX3B0cjxJVHVuZXJMbmI+KiBfYWlkbF9yZXR1cm4pIG92ZXJyaWRlOworICAgIDo6bmRrOjpTY29wZWRBU3RhdHVzIG9wZW5MbmJCeU5hbWUoY29uc3Qgc3RyaW5nJiBpbl9sbmJOYW1lLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2hhcmVkX3B0cjxJVHVuZXJMbmI+KiBfYWlkbF9yZXR1cm4pIG92ZXJyaWRlOworICAgIDo6bmRrOjpTY29wZWRBU3RhdHVzIG9wZW5EZW11eChpbnQzMl90IGluX2RlbXV4SGFuZGxlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaGFyZWRfcHRyPElUdW5lckRlbXV4PiogX2FpZGxfcmV0dXJuKSBvdmVycmlkZTsKKyAgICA6Om5kazo6U2NvcGVkQVN0YXR1cyBnZXREZW11eENhcHMoRGVtdXhDYXBhYmlsaXRpZXMqIF9haWRsX3JldHVybikgb3ZlcnJpZGU7CisgICAgOjpuZGs6OlNjb3BlZEFTdGF0dXMgb3BlbkRlc2NyYW1ibGVyKGludDMyX3QgaW5fZGVzY3JhbWJsZXJIYW5kbGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNoYXJlZF9wdHI8SVR1bmVyRGVzY3JhbWJsZXI+KiBfYWlkbF9yZXR1cm4pIG92ZXJyaWRlOworICAgIDo6bmRrOjpTY29wZWRBU3RhdHVzIGdldFR1bmVySGFsVmVyc2lvbihpbnQzMl90KiBfYWlkbF9yZXR1cm4pIG92ZXJyaWRlOworICAgIDo6bmRrOjpTY29wZWRBU3RhdHVzIG9wZW5TaGFyZWRGaWx0ZXIoY29uc3Qgc3RyaW5nJiBpbl9maWx0ZXJUb2tlbiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNoYXJlZF9wdHI8SVR1bmVyRmlsdGVyQ2FsbGJhY2s+JiBpbl9jYiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNoYXJlZF9wdHI8SVR1bmVyRmlsdGVyPiogX2FpZGxfcmV0dXJuKSBvdmVycmlkZTsKKyAgICA6Om5kazo6U2NvcGVkQVN0YXR1cyBzZXRMbmEoYm9vbCBpbl9iRW5hYmxlKSBvdmVycmlkZTsKKyAgICA6Om5kazo6U2NvcGVkQVN0YXR1cyBzZXRNYXhOdW1iZXJPZkZyb250ZW5kcyhGcm9udGVuZFR5cGUgaW5fZnJvbnRlbmRUeXBlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3QgaW5fbWF4TnVtYmVyKSBvdmVycmlkZTsKKyAgICA6Om5kazo6U2NvcGVkQVN0YXR1cyBnZXRNYXhOdW1iZXJPZkZyb250ZW5kcyhGcm9udGVuZFR5cGUgaW5fZnJvbnRlbmRUeXBlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3QqIF9haWRsX3JldHVybikgb3ZlcnJpZGU7CiAKLSAgICAv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VyY2UoCisgICAgICAgIGNvbnN0IHNoYXJlZF9wdHI8SVR1bmVyRnJvbnRlbmQ+JiBpbl9mcm9udGVuZCkgeworICAgIGlmIChtRGVtdXggPT0gbnVsbHB0cikgeworICAgICAgICBBTE9HRSgiSURlbXV4IGlzIG5vdCBpbml0aWFsaXplZCIpOworICAgICAgICByZXR1cm4gOjpuZGs6OlNjb3BlZEFTdGF0dXM6OmZyb21TZXJ2aWNlU3BlY2lmaWNFcnJvcigKKyAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxpbnQzMl90PihIaWRsUmVzdWx0OjpVTkFWQUlMQUJMRSkpOworICAgIH0KKworICAgIGludCBmcm9udGVuZElkOworICAgIGluX2Zyb250ZW5kLT5nZXRGcm9udGVuZElkKCZmcm9udGVuZElkKTsKKyAgICBIaWRsUmVzdWx0IHJlcyA9IG1EZW11eC0+c2V0RnJvbnRlbmREYXRhU291cmNlKGZyb250ZW5kSWQpOworICAgIGlmIChyZXMgIT0gSGlkbFJlc3VsdDo6U1VDQ0VTUykgeworICAgICAgICByZXR1cm4gOjpuZGs6OlNjb3BlZEFTdGF0dXM6OmZyb21TZXJ2aWNlU3BlY2lmaWNFcnJvcihzdGF0aWNfY2FzdDxpbnQzMl90PihyZXMpKTsKKyAgICB9CisgICAgcmV0dXJuIDo6bmRrOjpTY29wZWRBU3RhdHVzOjpvaygpOworfQorCis6Om5kazo6U2NvcGVkQVN0YXR1cyBUdW5lckhpZGxEZW11eDo6c2V0RnJvbnRlbmREYXRhU291cmNlQnlJZChpbnQgZnJvbnRlbmRJZCkgeworICAgIGlmIChtRGVtdXggPT0gbnVsbHB0cikgeworICAgICAgICBBTE9HRSgiSURlbXV4IGlzIG5vdCBpbml0aWFsaXplZCIpOworICAgICAgICByZXR1cm4gOjpuZGs6OlNjb3BlZEFTdGF0dXM6OmZyb21TZXJ2aWNlU3BlY2lmaWNFcnJvcigKKyAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxpbnQzMl90PihIaWRsUmVzdWx0OjpVTkFWQUlMQUJMRSkpOworICAgIH0KKworICAgIEhpZGxSZXN1bHQgcmVzID0gbURlbXV4LT5zZXRGcm9udGVuZERhdGFTb3VyY2UoZnJvbnRlbmRJZCk7CisgICAgaWYgKHJlcyAhPSBIaWRsUmVzdWx0OjpTVUNDRVNTKSB7CisgICAgICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6ZnJvbVNlcnZpY2VTcGVjaWZpY0Vycm9yKHN0YXRpY19jYXN0PGludDMyX3Q+KHJlcykpOworICAgIH0KKyAgICByZXR1cm4gOjpuZGs6OlNjb3BlZEFTdGF0dXM6Om9rKCk7Cit9CisKKzo6bmRrOjpTY29wZWRBU3RhdHVzIFR1bmVySGlkbERlbXV4OjpvcGVuRmlsdGVyKGNvbnN0IERlbXV4RmlsdGVyVHlwZSYgaW5fdHlwZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3QgaW5fYnVmZmVyU2l6ZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNoYXJlZF9wdHI8SVR1bmVyRmlsdGVyQ2FsbGJhY2s+JiBpbl9jYiwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNoYXJlZF9wdHI8SVR1bmVyRmlsdGVyPiogX2FpZGxfcmV0dXJuKSB7CisgICAgaWYgKG1EZW11eCA9PSBudWxscHRyKSB7CisgICAgICAgIEFMT0dFKCJJRGVtdXggaXMgbm90IGluaXRpYWxpemVkIik7CisgICAgICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6ZnJvbVNlcnZpY2VTcGVjaWZpY0Vycm9yKAorICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PGludDMyX3Q+KEhpZGxSZXN1bHQ6OlVOQVZBSUxBQkxFKSk7CisgICAgfQorCisgICAgSGlkbERlbXV4Rml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lkbElUaW1lRmlsdGVyPiYgZmlsdGVyKSB7CisgICAgICAgIGZpbHRlclNwID0gZmlsdGVyOworICAgICAgICBzdGF0dXMgPSByOworICAgIH0pOworICAgIGlmIChzdGF0dXMgIT0gSGlkbFJlc3VsdDo6U1VDQ0VTUykgeworICAgICAgICByZXR1cm4gOjpuZGs6OlNjb3BlZEFTdGF0dXM6OmZyb21TZXJ2aWNlU3BlY2lmaWNFcnJvcihzdGF0aWNfY2FzdDxpbnQzMl90PihzdGF0dXMpKTsKKyAgICB9CisKKyAgICAqX2FpZGxfcmV0dXJuID0gOjpuZGs6OlNoYXJlZFJlZkJhc2U6Om1ha2U8VHVuZXJIaWRsVGltZUZpbHRlcj4oZmlsdGVyU3ApOworICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6b2soKTsKK30KKworOjpuZGs6OlNjb3BlZEFTdGF0dXMgVHVuZXJIaWRsRGVtdXg6OmdldEF2U3luY0h3SWQoY29uc3Qgc2hhcmVkX3B0cjxJVHVuZXJGaWx0ZXI+JiB0dW5lckZpbHRlciwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludDMyX3QqIF9haWRsX3JldHVybikgeworICAgIGlmIChtRGVtdXggPT0gbnVsbHB0cikgeworICAgICAgICBBTE9HRSgiSURlbXV4IGlzIG5vdCBpbml0aWFsaXplZC4iKTsKKyAgICAgICAgcmV0dXJuIDo6bmRrOjpTY29wZWRBU3RhdHVzOjpmcm9tU2VydmljZVNwZWNpZmljRXJyb3IoCisgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8aW50MzJfdD4oSGlkbFJlc3VsdDo6VU5BVkFJTEFCTEUpKTsKKyAgICB9CisKKyAgICB1aW50MzJfdCBhdlN5bmNId0lkOworICAgIEhpZGxSZXN1bHQgcmVzOworICAgIHNwPEhpZGxJRmlsdGVyPiBoYWxGaWx0ZXIgPSBzdGF0aWNfY2FzdDxUdW5lckhpZGxGaWx0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KyAgICAgICAgcmVzID0gcjsKKyAgICAgICAgdGltZSA9IHRzOworICAgIH0pOworICAgIGlmIChyZXMgIT0gSGlkbFJlc3VsdDo6U1VDQ0VTUykgeworICAgICAgICByZXR1cm4gOjpuZGs6OlNjb3BlZEFTdGF0dXM6OmZyb21TZXJ2aWNlU3BlY2lmaWNFcnJvcihzdGF0aWNfY2FzdDxpbnQzMl90PihyZXMpKTsKKyAgICB9CisKKyAgICAqX2FpZGxfcmV0dXJuID0gKGludDY0X3QpdGltZTsKKyAgICByZXR1cm4gOjpuZGs6OlNjb3BlZEFTdGF0dXM6Om9rKCk7Cit9CisKKzo6bmRrOjpTY29wZWRBU3RhdHVzIFR1bmVySGlkbERlbXV4OjpvcGVuRHZyKER2clR5cGUgaW5fZHZiVHlwZSwgaW50MzJfdCBpbl9idWZmZXJTaXplLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2hhcmVkX3B0cjxJVHVuZXJEdnJDYWxsYmFjaz4mIGluX2NiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2hhcmVkX3B0cjxJVHVuZXJEdnI+KiBfYWlkbF9yZXR1cm4pIHsKKyAgICBpZiAobURlbXV4ID09IG51bGxwdHIpIHsKKyAgICAgICAgQUxPR0UoIklEZW11eCBpcyBub3QgaW5pdGlhbGl6ZWQuIik7CisgICAgICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6ZnJvbVNlcnZpY2VTcGVjaWZpY0Vycm9yKAorICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PGludDMyX3Q+KEhpZGxSZXN1bHQ6OlVOQVZBSUxBQkxFKSk7CisgICAgfQorCisgICAgSGlkbFJlc3VsdCByZXM7CisgICAgc3A8SGlkbElEdnJDYWxsYmFjaz4gY2FsbGJhY2sgPSBuZXcgVHVuZXJIaWRsRHZyOjpEdnJDYWxsYmFjayhpbl9jYik7CisgICAgc3A8S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nN0IERlbXV4RmlsdGVyVHlwZSYgaW5fdHlwZSwgaW50MzJfdCBpbl9idWZmZXJTaXplLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2hhcmVkX3B0cjxJVHVuZXJGaWx0ZXJDYWxsYmFjaz4mIGluX2NiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2hhcmVkX3B0cjxJVHVuZXJGaWx0ZXI+KiBfYWlkbF9yZXR1cm4pIG92ZXJyaWRlOworICAgIDo6bmRrOjpTY29wZWRBU3RhdHVzIG9wZW5UaW1lRmlsdGVyKHNoYXJlZF9wdHI8SVR1bmVyVGltZUZpbHRlcj4qIF9haWRsX3JldHVybikgb3ZlcnJpZGU7CisgICAgOjpuZGs6OlNjb3BlZEFTdGF0dXMgZ2V0QXZTeW5jSHdJZChjb25zdCBzaGFyZWRfcHRyPElUdW5lckZpbHRlcj4mIGluX3R1bmVyRmlsdGVyLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCogX2FpZGxfcmV0dXJuKSBvdmVycmlkZTsKKyAgICA6Om5kazo6U2NvcGVkQVN0YXR1cyBnZXRBdlN5bmNUaW1lKGludDMyX3QgaW5fYXZTeW5jSHdJZCwgaW50NjRfdCogX2FpZGxfcmV0dXJuKSBvdmVycmlkZTsKKyAgICA6Om5kazo6U2NvcGVkQVN0YXR1cyBvcGVuRHZyKER2clR5cGUgaW5fZHZiVHlwZSwgaW50MzJfdCBpbl9idWZmZXJTaXplLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2hhcmVkX3B0cjxJVHVuZXJEdnJDYWxsYmFjaz4mIGluX2NiLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2hhcmVkX3B0cjxJVHVuZXJEdnI+KiBfYWlkbF9yZXR1cm4pIG92ZXJyaWRlOworICAgIDo6bmRrOjpTY29wZWRBU3RhdHVzIGNvbm5lY3RD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ZGxEdnJTZXR0aW5ncyBUdW5lckhpZGxEdnI6OmdldEhpZGxEdnJTZXR0aW5ncyhjb25zdCBEdnJTZXR0aW5ncyYgc2V0dGluZ3MpIHsKKyAgICBIaWRsRHZyU2V0dGluZ3MgczsKKyAgICBzd2l0Y2ggKG1UeXBlKSB7CisgICAgY2FzZSBEdnJUeXBlOjpQTEFZQkFDSzogeworICAgICAgICBzLnBsYXliYWNrKHsKKyAgICAgICAgICAgICAgICAuc3RhdHVzTWFzayA9CisgICAgICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDx1aW50OF90PihzZXR0aW5ncy5nZXQ8RHZyU2V0dGluZ3M6OnBsYXliYWNrPigpLnN0YXR1c01hc2spLAorICAgICAgICAgICAgICAgIC5sb3dUaHJlc2hvbGQgPQorICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8dWludDMyX3Q+KHNldHRpbmdzLmdldDxEdnJTZXR0aW5nczo6cGxheWJhY2s+KCkubG93VGhyZXNob2xkKSwKKyAgICAgICAgICAgICAgICAuaGlnaFRocmVzaG9sZCA9CisgICAgICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDx1aW50MzJfdD4oc2V0dGluZ3MuZ2V0PER2clNldHRpbmdzOjpwbGF5YmFjaz4oKS5oaWdoVGhyZXNob2xkKSwKKyAgICAgICAgICAgICAgICAuZGF0YUZvcm1hdCA9IHN0YXRpY19jYXN0PEhpZGxEYXRhRm9ybWF0PigKKyAgICAgICAgICAgICAgICAgICAgICAgIHNldHRpbmdzLmdldDxEdnJTZXR0aW5nczo6cGxheWJhY2s+KCkuZGF0YUZvcm1hdCksCisgICAgICAgICAgICAgICAgLnBhY2tldFNpemUgPQorICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8dWludDhfdD4oc2V0dGluZ3MuZ2V0PER2clNldHRpbmdzOjpwbGF5YmFjaz4oKS5wYWNrZXRTaXplKSwKKyAgICAgICAgfSk7CisgICAgICAgIHJldHVybiBzOworICAgIH0KKyAgICBjYXNlIER2clR5cGU6OlJFQ09SRDogeworICAgICAgICBzLnJlY29yZCh7CisgICAgICAgICAgICAgICAgLnN0YXR1c01hc2sgPSBzdGF0aWNfY2FzdDx1aW50OF90PihzZXR0aW5ncy5nZXQ8RHZyU2V0dGluZ3M6OnJlY29yZD4oKS5zdGF0dXNNYXNrKSwKKyAgICAgICAgICAgICAgICAubG93VGhyZXNob2xkID0KKyAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PHVpbnQzMl90PihzZXR0aW5ncy5nZXQ8RHZyU2V0dGluZ3M6OnJlY29yZD4oKS5sb3dUaHJlc2hvbGQpLAorICAgICAgICAgICAgICAgIC5oaWdoVGhyZXNob2xkID0KKyAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PHVpbnQzMl90PihzZXR0aW5ncy5nZXQ8RHZyU2V0dGluZ3M6OnJlY29yZD4oKS5oaWdoVGhyZXNob2xkKSwKKyAgICAgICAgICAgICAgICAuZGF0YUZvcm1hdCA9CisgICAgICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxIaWRsRGF0YUZvcm1hdD4oc2V0dGluZ3MuZ2V0PER2clNldHRpbmdzOjpyZWNvcmQ+KCkuZGF0YUZvcm1hdCksCisgICAgICAgICAgICAgICAgLnBhY2tldFNpemUgPSBzdGF0aWNfY2FzdDx1aW50OF90PihzZXR0aW5ncy5nZXQ8RHZyU2V0dGluZ3M6OnJlY29yZD4oKS5wYWNrZXRTaXplKSwKKyAgICAgICAgfSk7CisgICAgICAgIHJldHVybiBzOworICAgIH0KKyAgICBkZWZhdWx0OgorICAgICAgICBicmVhazsKKyAgICB9CisgICAgcmV0dXJuIHM7Cit9CisKKy8vLy8vLy8vLy8vLy8vLyBJRHZyQ2FsbGJhY2sgLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8KK1JldHVybjx2b2lkPiBUdW5lckhpZGxEdnI6OkR2ckNhbGxiYWN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ICB9CisKKyAgICBpZiAobVNoYXJlZCkgeworICAgICAgICBBTE9HRCgiJXMgaXMgY2FsbGVkIG9uIGEgc2hhcmVkIGZpbHRlciIsIF9fRlVOQ1RJT05fXyk7CisgICAgICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6ZnJvbVNlcnZpY2VTcGVjaWZpY0Vycm9yKAorICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PGludDMyX3Q+KFJlc3VsdDo6SU5WQUxJRF9TVEFURSkpOworICAgIH0KKworICAgIEhpZGxSZXN1bHQgcmVzOworICAgIG1GaWx0ZXItPmdldElkKFsmXShIaWRsUmVzdWx0IHIsIHVpbnQzMl90IGZpbHRlcklkKSB7CisgICAgICAgIHJlcyA9IHI7CisgICAgICAgIG1JZCA9IGZpbHRlcklkOworICAgIH0pOworICAgIGlmIChyZXMgIT0gSGlkbFJlc3VsdDo6U1VDQ0VTUykgeworICAgICAgICByZXR1cm4gOjpuZGs6OlNjb3BlZEFTdGF0dXM6OmZyb21TZXJ2aWNlU3BlY2lmaWNFcnJvcihzdGF0aWNfY2FzdDxpbnQzMl90PihyZXMpKTsKKyAgICB9CisgICAgKl9haWRsX3JldHVybiA9IG1JZDsKKworICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6b2soKTsKK30KKworOjpuZGs6OlNjb3BlZEFTdGF0dXMgVHVuZXJIaWRsRmlsdGVyOjpnZXRJZDY0Qml0KGludDY0X3QqIF9haWRsX3JldHVybikgeworICAgIE11dGV4OjpBdXRvbG9jayBfbChtTG9jayk7CisgICAgaWYgKG1GaWx0ZXJfMV8xID09IG51bGxwdHIpIHsKKyAgICAgICAgQUxPR0UoIklGaWx0ZXJfMV8xIGlzIG5vdCBpbml0aWFsaXplZCIpOworICAgICAgICByZXR1cm4gOjpuZGs6OlNjb3BlZEFTdGF0dXM6OmZyb21TZXJ2aWNlU3BlY2lmaWNFcnJvcigKKyAgICAgICAgICAgICAgICBzdGF0aWNfY2Fz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RsZShOYXRpdmVIYW5kbGUqIG91dF9hdk1lbW9yeSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50NjRfdCogX2FpZGxfcmV0dXJuKSB7CisgICAgTXV0ZXg6OkF1dG9sb2NrIF9sKG1Mb2NrKTsKKyAgICBpZiAobUZpbHRlcl8xXzEgPT0gbnVsbHB0cikgeworICAgICAgICBBTE9HRSgiSUZpbHRlcl8xXzEgaXMgbm90IGluaXRpYWxpemVkIik7CisgICAgICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6ZnJvbVNlcnZpY2VTcGVjaWZpY0Vycm9yKAorICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PGludDMyX3Q+KFJlc3VsdDo6VU5BVkFJTEFCTEUpKTsKKyAgICB9CisKKyAgICBpZiAobVNoYXJlZCkgeworICAgICAgICBBTE9HRCgiJXMgaXMgY2FsbGVkIG9uIGEgc2hhcmVkIGZpbHRlciIsIF9fRlVOQ1RJT05fXyk7CisgICAgICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6ZnJvbVNlcnZpY2VTcGVjaWZpY0Vycm9yKAorICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PGludDMyX3Q+KFJlc3VsdDo6SU5WQUxJRF9TVEFURSkpOworICAgIH0KKworICAgIEhpZGxSZXN1bHQgcmVzOworICAgIG1GaWx0ZXJfMV8xLT5nZXRBdlNoYXJlZEhhbmRsZShbJl0oSGlkbFJlc3VsdCByLCBoaWRsX2hhbmRsZSBhdk1lbW9yeSwgdWludDY0X3QgYXZNZW1TaXplKSB7CisgICAgICAgIHJlcyA9IHI7CisgICAgICAgIGlmIChyZXMgPT0gSGlkbFJlc3VsdDo6U1VDQ0VTUykgeworICAgICAgICAgICAgKm91dF9hdk1lbW9yeSA9IGR1cFRvQWlkbChhdk1lbW9yeSk7CisgICAgICAgICAgICAqX2FpZGxfcmV0dXJuID0gc3Rhd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GV4OjpBdXRvbG9jayBfbChtTG9jayk7CisgICAgaWYgKG1GaWx0ZXIgPT0gbnVsbHB0cikgeworICAgICAgICBBTE9HRSgiSUZpbHRlciBpcyBub3QgaW5pdGlhbGl6ZWQiKTsKKyAgICAgICAgcmV0dXJuIDo6bmRrOjpTY29wZWRBU3RhdHVzOjpmcm9tU2VydmljZVNwZWNpZmljRXJyb3IoCisgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8aW50MzJfdD4oUmVzdWx0OjpVTkFWQUlMQUJMRSkpOworICAgIH0KKworICAgIGlmIChtU2hhcmVkKSB7CisgICAgICAgIElQQ1RocmVhZFN0YXRlKiBpcGMgPSBJUENUaHJlYWRTdGF0ZTo6c2VsZigpOworICAgICAgICBpbnQzMl90IGNhbGxpbmdQaWQgPSBpcGMtPmdldENhbGxpbmdQaWQoKTsKKyAgICAgICAgaWYgKGNhbGxpbmdQaWQgPT0gbUNsaWVudFBpZCkgeworICAgICAgICAgICAgQUxPR0QoIiVzIGlzIGNhbGxlZCBpbiB3cm9uZyBwcm9jZXNzIiwgX19GVU5DVElPTl9fKTsKKyAgICAgICAgICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6ZnJvbVNlcnZpY2VTcGVjaWZpY0Vycm9yKAorICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxpbnQzMl90PihSZXN1bHQ6OklOVkFMSURfU1RBVEUpKTsKKyAgICAgICAgfQorICAgIH0KKworICAgIEhpZGxSZXN1bHQgcmVzID0gbUZpbHRlci0+c3RvcCgpOworICAgIG1TdGFydGVkID0gZmFsc2U7CisgICAgaWYgKHJlcyAhPSBIaWRsUmVzdWx0OjpTVUNDRVNTKSB7CisgICAgICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6ZnJvbVNlcnZpY2VTcGVjaWZpY0Vycm9yKHN0YXRpY19jYXN0PGludDMyX3Q+KHJlcykpOworICAgIH0KKworICAgIHJldHVybiA6Om5kazo6U2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W5lckhpZGxGaWx0ZXI+KCkpOworICAgICAgICB9IGVsc2UgeworICAgICAgICAgICAgLy8gQ2FsbGluZyBmcm9tIHNoYXJlZCBwcm9jZXNzLCBkbyBub3QgcmVhbGx5IGNsb3NlIHRoaXMgZmlsdGVyLgorICAgICAgICAgICAgaWYgKG1GaWx0ZXJDYWxsYmFjayAhPSBudWxscHRyKSB7CisgICAgICAgICAgICAgICAgbUZpbHRlckNhbGxiYWNrLT5kZXRhY2hTaGFyZWRGaWx0ZXJDYWxsYmFjaygpOworICAgICAgICAgICAgfQorICAgICAgICAgICAgbVN0YXJ0ZWQgPSBmYWxzZTsKKyAgICAgICAgICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6b2soKTsKKyAgICAgICAgfQorICAgIH0KKworICAgIGlmIChtRmlsdGVyQ2FsbGJhY2sgIT0gbnVsbHB0cikgeworICAgICAgICBtRmlsdGVyQ2FsbGJhY2stPmRldGFjaENhbGxiYWNrcygpOworICAgIH0KKyAgICBIaWRsUmVzdWx0IHJlcyA9IG1GaWx0ZXItPmNsb3NlKCk7CisgICAgbUZpbHRlciA9IG51bGxwdHI7CisgICAgbUZpbHRlcl8xXzEgPSBudWxscHRyOworICAgIG1TdGFydGVkID0gZmFsc2U7CisgICAgbVNoYXJlZCA9IGZhbHNlOworICAgIG1DbGllbnRQaWQgPSAtMTsKKworICAgIGlmIChyZXMgIT0gSGlkbFJlc3VsdDo6U1VDQ0VTUykgeworICAgICAgICByZXR1cm4gOjpuZGs6OlNjb3BlZEFTdGF0dXM6OmZyb21TZXJ2aWNlU3BlY2lmaWNFcnJvcihzdGF0aWNfY2FzdDxpbnQzMl90PihyZXMpKTsKKyAgICB9CisKKyAgICByZXR1cm4gOjpuZGs6OlNjb3BlZEFTdGF0dXM6Om9rKCk7Cit9CisKKzo6bmRrOjpTY29wZWRBU3RhdHVzIFR1bmVySGlkbEZpbHRlcjo6YWNxdWlyZVNoYXJlZEZpbHRlclRva2VuKHN0cmluZy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gICAgICAgdHNDb25mLmZpbHRlclNldHRpbmdzLmdldDxEZW11eFRzRmlsdGVyU2V0dGluZ3NGaWx0ZXJTZXR0aW5nczo6cGVzRGF0YT4oKSkpOworICAgICAgICBicmVhazsKKyAgICB9CisgICAgY2FzZSBEZW11eFRzRmlsdGVyU2V0dGluZ3NGaWx0ZXJTZXR0aW5nczo6cmVjb3JkOiB7CisgICAgICAgIHRzLmZpbHRlclNldHRpbmdzLnJlY29yZChnZXRIaWRsUmVjb3JkU2V0dGluZ3MoCisgICAgICAgICAgICAgICAgdHNDb25mLmZpbHRlclNldHRpbmdzLmdldDxEZW11eFRzRmlsdGVyU2V0dGluZ3NGaWx0ZXJTZXR0aW5nczo6cmVjb3JkPigpKSk7CisgICAgICAgIGJyZWFrOworICAgIH0KKyAgICBkZWZhdWx0OiB7CisgICAgICAgIHRzLmZpbHRlclNldHRpbmdzLm5vaW5pdCgpOworICAgICAgICBicmVhazsKKyAgICB9CisgICAgfQorICAgIGhpZGxTZXR0aW5ncy50cyh0cyk7Cit9CisKK3ZvaWQgVHVuZXJIaWRsRmlsdGVyOjpnZXRIaWRsTW10cFNldHRpbmdzKGNvbnN0IERlbXV4RmlsdGVyU2V0dGluZ3MmIHNldHRpbmdzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSGlkbERlbXV4RmlsdGVyU2V0dGluZ3MmIGhpZGxTZXR0aW5ncykgeworICAgIGNvbnN0IERlbXV4TW10cEZpbHRlclNldHRpbmdzJiBtbXRwQ29uZiA9IHNldHRpbmdzLmdldDxEZW11eEZpbHRlclNldHRpbmdzOjptbXRwPigpOworICAgIEhpZGxEZW11eE1tdHBGaWx0ZXJTZXR0aW5ncyBtbXRweworICAgICAgICAgICAgLm1tdHBQaWQgPSBzdGF0aWNfY2FzdDxIaWRsRGVtdXhNbXRwUGlkPihtbXRwQ29uZi5tbXRwUGlkKSwKKyAgICB9OworCisgICAgc3dpdGNoIChtbXRwQ29uZi5maWx0Z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RsUmVjb3JkU2V0dGluZ3MoCisgICAgICAgICAgICAgICAgbW10cENvbmYuZmlsdGVyU2V0dGluZ3MuZ2V0PERlbXV4TW10cEZpbHRlclNldHRpbmdzRmlsdGVyU2V0dGluZ3M6OnJlY29yZD4oKSkpOworICAgICAgICBicmVhazsKKyAgICB9CisgICAgY2FzZSBEZW11eE1tdHBGaWx0ZXJTZXR0aW5nc0ZpbHRlclNldHRpbmdzOjpkb3dubG9hZDogeworICAgICAgICBtbXRwLmZpbHRlclNldHRpbmdzLmRvd25sb2FkKGdldEhpZGxEb3dubG9hZFNldHRpbmdzKAorICAgICAgICAgICAgICAgIG1tdHBDb25mLmZpbHRlclNldHRpbmdzLmdldDxEZW11eE1tdHBGaWx0ZXJTZXR0aW5nc0ZpbHRlclNldHRpbmdzOjpkb3dubG9hZD4oKSkpOworICAgICAgICBicmVhazsKKyAgICB9CisgICAgZGVmYXVsdDogeworICAgICAgICBtbXRwLmZpbHRlclNldHRpbmdzLm5vaW5pdCgpOworICAgICAgICBicmVhazsKKyAgICB9CisgICAgfQorICAgIGhpZGxTZXR0aW5ncy5tbXRwKG1tdHApOworfQorCit2b2lkIFR1bmVySGlkbEZpbHRlcjo6Z2V0SGlkbElwU2V0dGluZ3MoY29uc3QgRGVtdXhGaWx0ZXJTZXR0aW5ncyYgc2V0dGluZ3MsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSGlkbERlbXV4RmlsdGVyU2V0dGluZ3MmIGhpZGxTZXR0aW5ncykgeworICAgIGNvbnN0IERlbXV4SXBGaWx0ZXJTZXR0aW5ncyYgaXBDb25mID0gc2V0dGluZ3MuZ2V0PERlbXV4RmlsdGVyU2V0dGluZ3M6OmlwPigpOworICAgIEhpZGxEZW11eElwQWRkcmVzcyBpcEFkZHJ7CisgICAgICAgICAgICAuc3JjUG9ydCA9IHN0YXRpY19jYXN0PHVpbnQxNl90PihpcENvbmYuaXBBZGRyLnNyY1BvcnQpLAorICAgICAgICAgIC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XRzLm1vZGUuZW5kKCkpOworICAgICAgICBzZWN0aW9uLmNvbmRpdGlvbi5zZWN0aW9uQml0cyh7CisgICAgICAgICAgICAgICAgLmZpbHRlciA9IGZpbHRlciwKKyAgICAgICAgICAgICAgICAubWFzayA9IG1hc2ssCisgICAgICAgICAgICAgICAgLm1vZGUgPSBtb2RlLAorICAgICAgICB9KTsKKyAgICAgICAgYnJlYWs7CisgICAgfQorICAgIGNhc2UgRGVtdXhGaWx0ZXJTZWN0aW9uU2V0dGluZ3NDb25kaXRpb246OnRhYmxlSW5mbzogeworICAgICAgICBjb25zdCBEZW11eEZpbHRlclNlY3Rpb25TZXR0aW5nc0NvbmRpdGlvblRhYmxlSW5mbyYgdGFibGVJbmZvID0KKyAgICAgICAgICAgICAgICBzZXR0aW5ncy5jb25kaXRpb24uZ2V0PERlbXV4RmlsdGVyU2VjdGlvblNldHRpbmdzQ29uZGl0aW9uOjp0YWJsZUluZm8+KCk7CisgICAgICAgIHNlY3Rpb24uY29uZGl0aW9uLnRhYmxlSW5mbyh7CisgICAgICAgICAgICAgICAgLnRhYmxlSWQgPSBzdGF0aWNfY2FzdDx1aW50MTZfdD4odGFibGVJbmZvLnRhYmxlSWQpLAorICAgICAgICAgICAgICAgIC52ZXJzaW9uID0gc3RhdGljX2Nhc3Q8dWludDE2X3Q+KHRhYmxlSW5mby52ZXJzaW9uKSwKKyAgICAgICAgfSk7CisgICAgICAgIGJyZWFrOworICAgIH0KKyAgICBkZWZhdWx0OiB7CisgICAgICAgIGJyZWFrOworICAgIH0KKyAgICB9CisgICAgcmV0dXJuIHNlY3Rpb247Cit9CisKK0hpZGxEZW11eEZpbHRlclBlc0RhdGFTZXR0aW5ncyBUdW5lckhpZGxGaWx0ZXI6OmdldEhpZGxQZXNEYXRhU2V0dGluZ3MoCisgICAgICAgIGNvbnN0IERlbXV4RmlsdGVyUGVzRGF0YVNldHRpbmdzJiBzZXR0aW5ncykgeworICAgIEhpZGxEZW11eEZpbHRlclBlc0Rhd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lbXV4UmVjb3JkU2NJbmRleFR5cGU6OlNDOworICAgICAgICB1aW50MzJfdCBpbmRleCA9CisgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8dWludDMyX3Q+KHNldHRpbmdzLnNjSW5kZXhNYXNrLmdldDxEZW11eEZpbHRlclNjSW5kZXhNYXNrOjpzY0F2Yz4oKSk7CisgICAgICAgIC8vIEhJREwgSEFMIHN0YXJ0aW5nIGZyb20gMSA8PCA0OyBBSURMIHN0YXJ0aW5nIGZyb20gMSA8PCAwLgorICAgICAgICBpbmRleCA9IGluZGV4IDw8IDQ7CisgICAgICAgIHJlY29yZC5zY0luZGV4TWFzay5zYyhpbmRleCk7CisgICAgICAgIGJyZWFrOworICAgIH0KKyAgICBjYXNlIERlbXV4RmlsdGVyU2NJbmRleE1hc2s6OnNjSGV2YzogeworICAgICAgICByZWNvcmQuc2NJbmRleFR5cGUgPSBzdGF0aWNfY2FzdDxIaWRsRGVtdXhSZWNvcmRTY0luZGV4VHlwZT4oc2V0dGluZ3Muc2NJbmRleFR5cGUpOworICAgICAgICByZWNvcmQuc2NJbmRleE1hc2suc2NIZXZjKAorICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PHVpbnQzMl90PihzZXR0aW5ncy5zY0luZGV4TWFzay5nZXQ8RGVtdXhGaWx0ZXJTY0luZGV4TWFzazo6c2NIZXZjPigpKSk7CisgICAgICAgIGJyZWFrOworICAgIH0KKyAgICB9CisgICAgcmV0dXJuIHJlY29yZDsKK30KKworSGlkbERlbXV4RmlsdGVyRG93bmxvYWRTZXR0aW5ncyBUdW5lckhpZGxGaWx0ZXI6OmdldEhpZGxEb3dubG9hZFNldHRpbmdzKAorICAgICAgICBjb25zdCBEZW11eEZpbHRlckRvd25sb2FkU2V0dGluZ3MmIHNldHRpbmdzKSB7CisgICAgSGlkbERlbXV4RmlsdGVyRG93bmxvYWRTZXR0aW5ncyBkb3dubG9hZHsKKyAgICAgICAgICAgIC5kb3dubG9hZElkID0gc3RhdG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ogeworICAgICAgICAgICAgZ2V0RG93bmxvYWRFdmVudChldmVudHMsIGFpZGxFdmVudHMpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBIaWRsRGVtdXhGaWx0ZXJFdmVudDo6RXZlbnQ6OmhpZGxfZGlzY3JpbWluYXRvcjo6aXBQYXlsb2FkOiB7CisgICAgICAgICAgICBnZXRJcFBheWxvYWRFdmVudChldmVudHMsIGFpZGxFdmVudHMpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBIaWRsRGVtdXhGaWx0ZXJFdmVudDo6RXZlbnQ6OmhpZGxfZGlzY3JpbWluYXRvcjo6dGVtaTogeworICAgICAgICAgICAgZ2V0VGVtaUV2ZW50KGV2ZW50cywgYWlkbEV2ZW50cyk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICBkZWZhdWx0OiB7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICB9CisgICAgfQorfQorCit2b2lkIFR1bmVySGlkbEZpbHRlcjo6RmlsdGVyQ2FsbGJhY2s6OmdldE1lZGlhRXZlbnQoCisgICAgICAgIGNvbnN0IHZlY3RvcjxIaWRsRGVtdXhGaWx0ZXJFdmVudDo6RXZlbnQ+JiBldmVudHMsIHZlY3RvcjxEZW11eEZpbHRlckV2ZW50PiYgcmVzKSB7CisgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBldmVudHMuc2l6ZSgpOyBpKyspIHsKKyAgICAgICAgY29uc3QgSGlkbERlbXV4RmlsdGVyTWVkaWFFdmVudCYgbWVkaWFFdmVudCA9IGV2ZW50c1tpXS5tZWRpYSgpOworICAgICAgICBEZW11eEZpbHRlck1lZGlhRXZlbnQgbWVkaWE7CisKKyAgICAgICAgbWVkaWEuc3RyZWFtSWQgPSBzdGF0aWNfY2FzdDxpbnQzMl90PihtZWRpYUV2ZW50LnN0cmVhbUlkKTsKKyAgICAgICAgb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YykgeworICAgICAgICAgICAgaW50MzJfdCBoaWRsU2NJbmRleCA9IHN0YXRpY19jYXN0PGludDMyX3Q+KHRzUmVjb3JkRXZlbnQuc2NJbmRleE1hc2suc2MoKSk7CisgICAgICAgICAgICBpZiAoaGlkbFNjSW5kZXggPD0gc3RhdGljX2Nhc3Q8aW50MzJfdD4oRGVtdXhTY0luZGV4OjpTRVFVRU5DRSkpIHsKKyAgICAgICAgICAgICAgICBzY0luZGV4TWFzay5zZXQ8RGVtdXhGaWx0ZXJTY0luZGV4TWFzazo6c2NJbmRleD4oaGlkbFNjSW5kZXgpOworICAgICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAvLyBISURMIEhBTCBzdGFydGluZyBmcm9tIDEgPDwgNDsgQUlETCBzdGFydGluZyBmcm9tIDEgPDwgMC4KKyAgICAgICAgICAgICAgICBzY0luZGV4TWFzay5zZXQ8RGVtdXhGaWx0ZXJTY0luZGV4TWFzazo6c2NBdmM+KGhpZGxTY0luZGV4ID4+IDQpOworICAgICAgICAgICAgfQorICAgICAgICB9IGVsc2UgaWYgKHRzUmVjb3JkRXZlbnQuc2NJbmRleE1hc2suZ2V0RGlzY3JpbWluYXRvcigpID09CisgICAgICAgICAgICAgICAgICAgSGlkbERlbXV4RmlsdGVyVHNSZWNvcmRFdmVudDo6U2NJbmRleE1hc2s6OmhpZGxfZGlzY3JpbWluYXRvcjo6c2NIZXZjKSB7CisgICAgICAgICAgICBzY0luZGV4TWFzay5zZXQ8RGVtdXhGaWx0ZXJTY0luZGV4TWFzazo6c2NIZXZjPigKKyAgICAgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8aW50MzJfdD4odHNSZWNvcmRFdmVudC5zY0luZGV4TWFzay5zY0hldmMoKSkpOworICAgICAgICB9CisKKyAgICAgICAgaWYgKHRzUmVjb3JkRXZlbnQucGlkLmdldERpc2NyaW1pbmF0b3IoKSA9PSBIaWRsRGVtdXhQaWQ6OmhpZGxfZGlzY3JpbWluYXRvcjo6dFBpZCkgeworICAgICAgICAgICAgRGVtdXhQaWQgcGlkOworICAgICAgICAgICAgcGlkLnNldDxEZW11eFBpZDo6dFBpZD4oc3RhdGljX2Nhc3Q8aW50MzJfdD4odHNSZWNvcmRFdmVudC5waWQudFBpZCgpKSk7CisgICAgICAgICAgICB0c1JlY29yZC5waWQgPSBwaWQ7CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICBEZW11eFBpZCBwaWQ7CisgICAgICAgICAgICBwaWQuc2V0PERlbXV4UGlkOjp0UGlkPihzdGF0aWNfY2FzdDxpbnQzMl90PihDb25zdGFudDo6SU5WQUxJRF9UU19QSUQpKTsKKyAgICAgICAgICAgIHRzUmVjb3JkLnBpZCA9IHBpZDsKKyAgICAgICAgfQorCisgICAgICAgIHRzUmVjb3JkLnNjSW5kZXhNYXNrID0gc2NJbmRleE1hc2s7CisgICAgICAgIHRzUmVjb3JkLnRzSW5kZXhNYXNrID0gc3RhdGljX2Nhc3Q8aW50MzJfdD4odHNSZWNvcmRFdmVudC50c0luZGV4TWFzayk7CisgICAgICAgIHRzUmVjb3JkLmJ5dGVOdW1iZXIgPSBzdGF0aWNfY2FzdDxpbnQ2NF90Pih0c1JlY29yZEV2ZW50LmJ5dGVOdW1iZXIpOworCisgICAgICAgIGlmIChldmVudHNFeHQuc2l6ZSgpID4gaSAmJgorICAgICAgICAgICAgZXZlbnRzRXh0W2ldLmdldERpc2NyaW1pbmF0b3IoKSA9PQorICAgICAgICAgICAgICAgICAgICBIaWRsRGVtdXhGaWx0ZXJFdmVudEV4dDo6RXZlbnQ6OmhpZGxfZGlzY3JpbWluYXRvcjo6dHNSZWNvcmQpIHsKKyAgICAgICAgICAgIHRzUmVjb3JkLnB0cyA9IHN0YXRpY19jYXN0PGludDY0X3Q+KGV2ZW50c0V4dFtpXS50c1JlY29yZCgpLnB0cyk7CisgICAgICAgICAgICB0c1JlY29yZC5maXJzdE1iSW5TbGljZSA9IHN0YXRpY19jYXN0PGludDMyX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4dC5zaXplKCkgPiBpICYmCisgICAgICAgICAgICBldmVudHNFeHRbaV0uZ2V0RGlzY3JpbWluYXRvcigpID09CisgICAgICAgICAgICAgICAgICAgIEhpZGxEZW11eEZpbHRlckV2ZW50RXh0OjpFdmVudDo6aGlkbF9kaXNjcmltaW5hdG9yOjptbXRwUmVjb3JkKSB7CisgICAgICAgICAgICBtbXRwUmVjb3JkLnB0cyA9IHN0YXRpY19jYXN0PGludDY0X3Q+KGV2ZW50c0V4dFtpXS5tbXRwUmVjb3JkKCkucHRzKTsKKyAgICAgICAgICAgIG1tdHBSZWNvcmQubXB1U2VxdWVuY2VOdW1iZXIgPQorICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxpbnQzMl90PihldmVudHNFeHRbaV0ubW10cFJlY29yZCgpLm1wdVNlcXVlbmNlTnVtYmVyKTsKKyAgICAgICAgICAgIG1tdHBSZWNvcmQuZmlyc3RNYkluU2xpY2UgPQorICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxpbnQzMl90PihldmVudHNFeHRbaV0ubW10cFJlY29yZCgpLmZpcnN0TWJJblNsaWNlKTsKKyAgICAgICAgICAgIG1tdHBSZWNvcmQudHNJbmRleE1hc2sgPSBzdGF0aWNfY2FzdDxpbnQzMl90PihldmVudHNFeHRbaV0ubW10cFJlY29yZCgpLnRzSW5kZXhNYXNrKTsKKyAgICAgICAgfQorCisgICAgICAgIERlbXV4RmlsdGVyRXZlbnQgZmlsdGVyRXZlbnQ7CisgICAgICAgIGZpbHRlckV2ZW50LnNldDxEZW11eEZpbHRlckV2ZW50OjptbXRwUmVjb3JkPihtb3ZlKG1tdHBSZWNvcmQpKTsKKyAgICAgICAgcmVzLnB1c2hfYmFjayhtb3ZlKGZpbHRlckV2ZW50KSk7CisgICAgfQorfQorCit2b2lkIFR1bmVySGlkbEZpbHRlcjo6RmlsdGVyQ2FsbGJhY2s6OmdldERvd25sb2FkRXZlbnQoCisgICAgICAgIGNvbnN0IHZlY3R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RXZlbnQoY29uc3QgdmVjdG9yPEhpZGxEZW11eEZpbHRlckV2ZW50OjpFdmVudD4mIGV2ZW50cywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmVjdG9yPERlbXV4RmlsdGVyRXZlbnQ+JiByZXMpOworICAgICAgICB2b2lkIGdldFBlc0V2ZW50KGNvbnN0IHZlY3RvcjxIaWRsRGVtdXhGaWx0ZXJFdmVudDo6RXZlbnQ+JiBldmVudHMsCisgICAgICAgICAgICAgICAgICAgICAgICAgdmVjdG9yPERlbXV4RmlsdGVyRXZlbnQ+JiByZXMpOworICAgICAgICB2b2lkIGdldFRzUmVjb3JkRXZlbnQoY29uc3QgdmVjdG9yPEhpZGxEZW11eEZpbHRlckV2ZW50OjpFdmVudD4mIGV2ZW50cywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZlY3RvcjxIaWRsRGVtdXhGaWx0ZXJFdmVudEV4dDo6RXZlbnQ+JiBldmVudHNFeHQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2ZWN0b3I8RGVtdXhGaWx0ZXJFdmVudD4mIHJlcyk7CisgICAgICAgIHZvaWQgZ2V0TW10cFJlY29yZEV2ZW50KGNvbnN0IHZlY3RvcjxIaWRsRGVtdXhGaWx0ZXJFdmVudDo6RXZlbnQ+JiBldmVudHMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZlY3RvcjxIaWRsRGVtdXhGaWx0ZXJFdmVudEV4dDo6RXZlbnQ+JiBldmVudHNFeHQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZlY3RvcjxEZW11eEZpbHRlckV2ZW50PiYgcmVzKTsKKyAgICAgICAgdm9pZCBnZXREb3dubG9hZEV2ZW50KGNvbnN0IHZlY3RvcjxIaWRsRGVtdXhGaWx0ZXJFdmVudDo6RXZlbnQ+JiBldmVudHMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2ZWN0b3I8RGVt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worICAgIH0KKworICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6ZnJvbVNlcnZpY2VTcGVjaWZpY0Vycm9yKHN0YXRpY19jYXN0PGludDMyX3Q+KHN0YXR1cykpOworfQorCis6Om5kazo6U2NvcGVkQVN0YXR1cyBUdW5lckhpZGxGcm9udGVuZDo6c3RvcFR1bmUoKSB7CisgICAgaWYgKG1Gcm9udGVuZCA9PSBudWxscHRyKSB7CisgICAgICAgIEFMT0dEKCJJRnJvbnRlbmQgaXMgbm90IGluaXRpYWxpemVkIik7CisgICAgICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6ZnJvbVNlcnZpY2VTcGVjaWZpY0Vycm9yKAorICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PGludDMyX3Q+KFJlc3VsdDo6VU5BVkFJTEFCTEUpKTsKKyAgICB9CisKKyAgICBIaWRsUmVzdWx0IHN0YXR1cyA9IG1Gcm9udGVuZC0+c3RvcFR1bmUoKTsKKyAgICBpZiAoc3RhdHVzID09IEhpZGxSZXN1bHQ6OlNVQ0NFU1MpIHsKKyAgICAgICAgcmV0dXJuIDo6bmRrOjpTY29wZWRBU3RhdHVzOjpvaygpOworICAgIH0KKworICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6ZnJvbVNlcnZpY2VTcGVjaWZpY0Vycm9yKHN0YXRpY19jYXN0PGludDMyX3Q+KHN0YXR1cykpOworfQorCis6Om5kazo6U2NvcGVkQVN0YXR1cyBUdW5lckhpZGxGcm9udGVuZDo6c2Nhbihjb25zdCBGcm9udGVuZFNldHRpbmdzJiBzZXR0aW5ncywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZyb250ZW5kU2NhblR5cGUgZnJvbnRlbmRTY2FuVHlwZSkgeworICAgIGlmIChtRnJvbnRlbmQgPT0gbnVsbHB0cikgeworICAgICAgICBBTE9HRCgiSUZyb250ZW5kIGlzIG5vdCBpbml0aWFsaXplZCIpOworICAgICAgICByZXR1cm4gOjpuZGs6OlNjb3BlZEFTdGF0dXM6OmZyb21TZXJ2aWNlU3BlY2lmaWNFcnJvcigKKyAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxpbnQzMl90PihSZXN1bHQ6OlVOQVZBSUxBQkxFKSk7CisgICAgfQorCisgICAgSGlkbFJlc3VsdCBzdGF0dXM7CisgICAgSGlkbEZyb250ZW5kU2V0dGluZ3MgZnJvbnRlbmRTZXR0aW5nczsKKyAgICBIaWRsRnJvbnRlbmRTZXR0aW5nc0V4dDFfMSBmcm9udGVuZFNldHRpbmdzRXh0OworICAgIGdldEhpZGxGcm9udGVuZFNldHRpbmdzKHNldHRpbmdzLCBmcm9udGVuZFNldHRpbmdzLCBmcm9udGVuZFNldHRpbmdzRXh0KTsKKyAgICBpZiAobUZyb250ZW5kXzFfMSAhPSBudWxscHRyKSB7CisgICAgICAgIHN0YXR1cyA9IG1Gcm9udGVuZF8xXzEtPnNjYW5fMV8xKGZyb250ZW5kU2V0dGluZ3MsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PEhpZGxGcm9udGVuZFNjYW5UeXBlPihmcm9udGVuZFNjYW5UeXBlKSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnJvbnRlbmRTZXR0aW5nc0V4dCk7CisgICAgfSBlbHNlIHsKKyAgICAgICAgc3RhdHVzID0gbUZyb250ZW5kLT5zY2FuKGZyb250ZW5kU2V0dGluZ3MsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxIaWRsRnJvbnRlbmRTY2FuVHlwZT4oZnJvbnRlbmRTY2FuVHlwZSkpOworICAgIH0KKyAgICBpZiAoc3RhdHVzID09IEhpZGxSZXN1bHQ6OlNVQ0NFU1MpIHsKKyAgICAgICAgcmV0dXJuIDo6bmRrOjpTY29wZWRBU3RhdHVzOjpvaygp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bnRlbmRTdGF0dXNUeXBlPihzKSk7CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICB0eXBlc0V4dC5wdXNoX2JhY2soc3RhdGljX2Nhc3Q8SGlkbEZyb250ZW5kU3RhdHVzVHlwZUV4dDFfMT4ocykpOworICAgICAgICB9CisgICAgfQorCisgICAgbUZyb250ZW5kLT5nZXRTdGF0dXModHlwZXMsIFsmXShIaWRsUmVzdWx0IHIsIGNvbnN0IGhpZGxfdmVjPEhpZGxGcm9udGVuZFN0YXR1cz4mIHNzKSB7CisgICAgICAgIHJlcyA9IHI7CisgICAgICAgIGZvciAoYXV0byBzIDogc3MpIHsKKyAgICAgICAgICAgIHN0YXR1cy5wdXNoX2JhY2socyk7CisgICAgICAgIH0KKyAgICB9KTsKKyAgICBpZiAocmVzICE9IEhpZGxSZXN1bHQ6OlNVQ0NFU1MpIHsKKyAgICAgICAgcmV0dXJuIDo6bmRrOjpTY29wZWRBU3RhdHVzOjpmcm9tU2VydmljZVNwZWNpZmljRXJyb3Ioc3RhdGljX2Nhc3Q8aW50MzJfdD4ocmVzKSk7CisgICAgfQorCisgICAgaWYgKG1Gcm9udGVuZF8xXzEgIT0gbnVsbHB0cikgeworICAgICAgICBtRnJvbnRlbmRfMV8xLT5nZXRTdGF0dXNFeHQxXzEoCisgICAgICAgICAgICAgICAgdHlwZXNFeHQsIFsmXShIaWRsUmVzdWx0IHIsIGNvbnN0IGhpZGxfdmVjPEhpZGxGcm9udGVuZFN0YXR1c0V4dDFfMT4mIHNzKSB7CisgICAgICAgICAgICAgICAgICAgIHJlcyA9IHI7CisgICAgICAgICAgICAgICAgICAgIGZvciAoYXV0byBzIDogc3MpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIHN0YXR1c0V4dC5wdXNoX2JhY2socyk7CisgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB9KTsKKyAgICAgICAgaWYgKHJlcyAhPSBIaWRsUmVzdWx0OjpTVUNDRVNTKSB7C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pb24+KG0uZHZiYygpKSk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICBjYXNlIEhpZGxGcm9udGVuZE1vZHVsYXRpb246OmhpZGxfZGlzY3JpbWluYXRvcjo6ZHZidDogeworICAgICAgICAgICAgbW9kdWxhdGlvbi5zZXQ8RnJvbnRlbmRNb2R1bGF0aW9uOjpkdmJ0PigKKyAgICAgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8RnJvbnRlbmREdmJ0Q29uc3RlbGxhdGlvbj4obS5kdmJ0KCkpKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CisgICAgICAgIGNhc2UgSGlkbEZyb250ZW5kTW9kdWxhdGlvbjo6aGlkbF9kaXNjcmltaW5hdG9yOjpkdmJzOiB7CisgICAgICAgICAgICBtb2R1bGF0aW9uLnNldDxGcm9udGVuZE1vZHVsYXRpb246OmR2YnM+KHN0YXRpY19jYXN0PEZyb250ZW5kRHZic01vZHVsYXRpb24+KG0uZHZicygpKSk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICBjYXNlIEhpZGxGcm9udGVuZE1vZHVsYXRpb246OmhpZGxfZGlzY3JpbWluYXRvcjo6aXNkYnM6IHsKKyAgICAgICAgICAgIG1vZHVsYXRpb24uc2V0PEZyb250ZW5kTW9kdWxhdGlvbjo6aXNkYnM+KAorICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxGcm9udGVuZElzZGJzTW9kdWxhdGlvbj4obS5pc2RicygpKSk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICBjYXNlIEhpZGxGcm9udGVuZE1vZHVsYXRpb246OmhpZGxfZGlzY3JpbWluYXRvcjo6aXNkYnMzOiB7CisgICAgICAgICAgICBtb2R1bGF0aW9uLnNldDxGcm9udGVuZE1vZHVsYXRpb246OmlzZGJzMz4oCisgICAgICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PEZyb250ZW5kSXNk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bnRlbmRTdGF0dXMoY29uc3QgdmVjdG9yPEhpZGxGcm9udGVuZFN0YXR1cz4mIGhpZGxTdGF0dXMsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmVjdG9yPEhpZGxGcm9udGVuZFN0YXR1c0V4dDFfMT4mIGhpZGxTdGF0dXNFeHQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmVjdG9yPEZyb250ZW5kU3RhdHVzPiYgYWlkbFN0YXR1cykgeworICAgIGZvciAoSGlkbEZyb250ZW5kU3RhdHVzIHMgOiBoaWRsU3RhdHVzKSB7CisgICAgICAgIEZyb250ZW5kU3RhdHVzIHN0YXR1czsKKyAgICAgICAgc3dpdGNoIChzLmdldERpc2NyaW1pbmF0b3IoKSkgeworICAgICAgICBjYXNlIEhpZGxGcm9udGVuZFN0YXR1czo6aGlkbF9kaXNjcmltaW5hdG9yOjppc0RlbW9kTG9ja2VkOiB7CisgICAgICAgICAgICBzdGF0dXMuc2V0PEZyb250ZW5kU3RhdHVzOjppc0RlbW9kTG9ja2VkPihzLmlzRGVtb2RMb2NrZWQoKSk7CisgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRTdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6c25yOiB7CisgICAgICAgICAgICBzdGF0dXMuc2V0PEZyb250ZW5kU3RhdHVzOjpzbnI+KChpbnQpcy5zbnIoKSk7CisgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRTdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6YmVyOiB7CisgICAgICAgICAgICBzdGF0dXMuc2V0PEZyb250ZW5kU3RhdHVzOjpiZXI+KChpbnQpcy5iZXIoKSk7CisgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRTdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6cGVyOiB7CisgICAgICAgICAgICBzdGF0dXMuc2V0PEZyb250ZW5kU3RhdHVzOjpwZXI+KChpbnQpcy5wZXIoKSk7CisgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRTdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6cHJlQmVyOiB7CisgICAgICAgICAgICBzdGF0dXMuc2V0PEZyb250ZW5kU3RhdHVzOjpwcmVCZXI+KChpbnQpcy5wcmVCZXIoKSk7CisgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRTdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6c2lnbmFsUXVhbGl0eTogeworICAgICAgICAgICAgc3RhdHVzLnNldDxGcm9udGVuZFN0YXR1czo6c2lnbmFsUXVhbGl0eT4oKGludClzLnNpZ25hbFF1YWxpdHkoKSk7CisgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRTdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6c2lnbmFsU3RyZW5ndGg6IHsKKyAgICAgICAgICAgIHN0YXR1cy5zZXQ8RnJvbnRlbm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ICAgICBtb2R1bGF0aW9uU3RhdHVzLnNldDxGcm9udGVuZE1vZHVsYXRpb25TdGF0dXM6OmR2YmM+KAorICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8RnJvbnRlbmREdmJjTW9kdWxhdGlvbj4ocy5tb2R1bGF0aW9uKCkuZHZiYygpKSk7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIEhpZGxGcm9udGVuZE1vZHVsYXRpb25TdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6ZHZiczoKKyAgICAgICAgICAgICAgICBtb2R1bGF0aW9uU3RhdHVzLnNldDxGcm9udGVuZE1vZHVsYXRpb25TdGF0dXM6OmR2YnM+KAorICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8RnJvbnRlbmREdmJzTW9kdWxhdGlvbj4ocy5tb2R1bGF0aW9uKCkuZHZicygpKSk7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIEhpZGxGcm9udGVuZE1vZHVsYXRpb25TdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6aXNkYnM6CisgICAgICAgICAgICAgICAgbW9kdWxhdGlvblN0YXR1cy5zZXQ8RnJvbnRlbmRNb2R1bGF0aW9uU3RhdHVzOjppc2Ricz4oCisgICAgICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxGcm9udGVuZElzZGJzTW9kdWxhdGlvbj4ocy5tb2R1bGF0aW9uKCkuaXNkYnMoKSkpOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRNb2R1bGF0aW9uU3RhdHVzOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmlzZGJzMzoKKyAgICAgICAgICAgICAgICBtb2R1bGF0aW9uU3RhdHVzLnNldDxGcm9udGVuZE1vZHVsYXRpb25TdGF0dXM6OmlzZGJzMz4oCisgICAgICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxGcm9udGVuZElzZGJzM01vZHVsYXRpb24+KHMubW9kdWxhdGlvbigpLmlzZGJzMygpKSk7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIEhpZGxGcm9udGVuZE1vZHVsYXRpb25TdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6aXNkYnQ6CisgICAgICAgICAgICAgICAgbW9kdWxhdGlvblN0YXR1cy5zZXQ8RnJvbnRlbmRNb2R1bGF0aW9uU3RhdHVzOjppc2RidD4oCisgICAgICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxGcm9udGVuZElzZGJ0TW9kdWxhdGlvbj4ocy5tb2R1bGF0aW9uKCkuaXNkYnQoKSkpOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgfQorICAgICAgICAgICAgc3RhdHVzLnNldDxGcm9udGVuZFN0YXR1czo6bW9kdWxhdGlvblN0YXR1cz4obW9kdWxhdGlvblN0YXR1cyk7CisgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRTdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6aW52ZXJzaW9uOiB7CisgICAgICAgICAgICBzdGF0dXMuc2V0PEZyb250ZW5kU3RhdHVzOjppbnZlcnNpb24+KAorICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxGcm9udGVuZFNwZWN0cmFsSW52ZXJzaW9uPihzLmludmVyc2lvbigpKSk7CisgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRTdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6bG5iVm9sdGFnZTogeworICAgICAgICAgICAgc3RhdHVzLnNldDxGcm9udGVuZFN0YXR1czo6bG5iVm9sdGFnZT4oc3RhdGljX2Nhc3Q8TG5iVm9sdGFnZT4ocy5sbmJWb2x0YWdlKCkpKTsKKyAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICBjYXNlIEhpZGxGcm9udGVuZFN0YXR1czo6aGlkbF9kaXNjcmltaW5hdG9yOjpwbHBJZDogeworICAgICAgICAgICAgc3RhdHVzLnNldDxGcm9udGVuZFN0YXR1czo6cGxwSWQ+KChpbnQzMl90KXMucGxwSWQoKSk7CisgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRTdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6aXNFV0JTOiB7CisgICAgICAgICAgICBzdGF0dXMuc2V0PEZyb250ZW5kU3RhdHVzOjppc0VXQlM+KHMuaXNFV0JTKCkpOworICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CisgICAgICAgIGNhc2UgSGlkbEZyb250ZW5kU3RhdHVzOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmFnYzogeworICAgICAgICAgICAgc3RhdHVzLnNldDxGcm9udGVuZFN0YXR1czo6YWdjPigoaW50MzJfdClzLmFnYygpKTsKKyAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICBjYXNlIEhpZGxGcm9udGVuZFN0YXR1czo6aGlkbF9kaXNjcmltaW5hdG9yOjppc0xuYU9uOiB7CisgICAgICAgICAgICBzdGF0dXMuc2V0PEZyb250ZW5kU3RhdHVzOjppc0xuYU9uPihzLmlzTG5hT24oKSk7CisgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRTdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6aXNMYXllckVycm9yOiB7CisgICAgICAgICAgICB2ZWN0b3I8Ym9vbD4gZShzLmlzTGF5ZXJFcnJvcigpLmJlZ2luKCksIHMuaXNMYXllckVycm9yKCkuZW5kKCkpOworICAgICAgICAgICAgc3RhdHVzLnNldDxGcm9udGVuZFN0YXR1czo6aXNMYXllckVycm9yPihlKTsKKyAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICBjYXNlIEhpZGxGcm9udGVuZFN0YXR1czo6aGlkbF9kaXNjcmltaW5hdG9yOjptZXI6IHsKKyAgICAgICAgICAgIHN0YXR1cy5zZXQ8RnJvbnRlbmRTdGF0dXM6Om1lcj4oc3RhdGljX2Nhc3Q8aW50MzJfdD4ocy5tZXIoKSkpOworICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CisgICAgICAgIGNhc2UgSGlkbEZyb250ZW5kU3RhdHVzOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmZyZXFPZmZzZXQ6IHsKKyAgICAgICAgICAgIHN0YXR1cy5zZXQ8RnJvbnRlbmRTdGF0dXM6OmZyZXFPZmZzZXQ+KHN0YXRpY19jYXN0PGludDY0X3Q+KHMuZnJlcU9mZnNldCgpKSk7CisgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRTdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6aGllcmFyY2h5OiB7CisgICAgICAgICAgICBzdGF0dXMuc2V0PEZyb250ZW5kU3RhdHVzOjpoaWVyYXJjaHk+KAorICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxGcm9udGVuZER2YnRIaWVyYXJjaHk+KHMuaGllcmFyY2h5KCkpKTsKKyAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICBjYXNlIEhpZGxGcm9udGVuZFN0YXR1czo6aGlkbF9kaXNjcmltaW5hdG9yOjppc1JmTG9ja2VkOiB7CisgICAgICAgICAgICBzdGF0dXMuc2V0PEZyb250ZW5kU3RhdHVzOjppc1JmTG9ja2VkPihzLmlzUmZMb2NrZWQoKSk7CisgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRTdGF0dXM6OmhpZGxfZGlzY3JpbWluYXRvcjo6cGxwSW5mbzogeworICAgICAgICAgICAgdmVjdG9yPEZyb250ZW5kU3RhdHVzQXRzYzNQbHBJbmZvPiBpbmZvOworICAgICAgICAgICAgZm9yIChhdXRvIGkgOiBzLnBscEluZm8oKSkgeworICAgICAgICAgICAgICAgIGluZm8ucHVzaF9iYWNrKHsKKyAgICAgICAgICAgICAgICAgICAgICAgIC5wbHBJZCA9IHN0YXRpY19jYXN0PGludDMyX3Q+KGkucGxwSWQpLAorICAgICAgICAgICAgICAgICAgICAgICAgLmlzTG9ja2VkID0gaS5pc0xvY2tlZCwKKyAgICAgICAgICAgICAgICAgICAgICAgIC51ZWMgPSBzdGF0aWNfY2FzdDxpbnQzMl90PihpLnVlYyksCisgICAgICAgICAgICAgICAgfSk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBzdGF0dXMuc2V0PEZyb250ZW5kU3RhdHVzOjpwbHBJbmZvPihpbmZvKTsKKyAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICB9CisgICAgfQorCisgICAgZm9yIChIaWRsRnJvbnRlbmRTdGF0dXNFeHQxXzEgcyA6IGhpZGxTdGF0dXNFeHQpIHsKKyAgICAgICAgRnJvbnRlbmRTdGF0dXMgc3RhdHVzOworICAgICAgICBzd2l0Y2ggKHMuZ2V0RGlzY3JpbWluYXRvcigpKSB7CisgICAgICAgIGNhc2UgSGlkbEZyb250ZW5kU3RhdHVzRXh0MV8xOjpoaWRsX2Rpc2NyaW1pbmF0b3I6Om1vZHVsYXRpb25zOiB7CisgICAgICAgICAgICB2ZWN0b3I8RnJvbnRlbmRNb2R1bGF0aW9uPiBhaWRsTW9kOworICAgICAgICAgICAgZm9yIChhdXRvIG0gOiBzLm1vZHVsYXRpb25zKCkpIHsKKyAgICAgICAgICAgICAgICBzd2l0Y2ggKG0uZ2V0RGlzY3JpbWluYXRvcigpKSB7CisgICAgICAgICAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRNb2R1bGF0aW9uOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmR2YmM6CisgICAgICAgICAgICAgICAgICAgIGFpZGxNb2QucHVzaF9iYWNrKHN0YXRpY19jYXN0PEZyb250ZW5kRHZiY01vZHVsYXRpb24+KG0uZHZiYygpKSk7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgSGlkbEZyb250ZW5kTW9kdWxhdGlvbjo6aGlkbF9kaXNjcmltaW5hdG9yOjpkdmJzOgorICAgICAgICAgICAgICAgICAgICBhaWRsTW9kLnB1c2hfYmFjayhzdGF0aWNfY2FzdDxGcm9udGVuZER2YnNNb2R1bGF0aW9uPihtLmR2YnMoKSkpOworICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICBjYXNlIEhpZGxGcm9udGVuZE1vZHVsYXRpb246OmhpZGxfZGlzY3JpbWluYXRvcjo6ZHZidDoKKyAgICAgICAgICAgICAgICAgICAgYWlkbE1vZC5wdXNoX2JhY2soc3RhdGljX2Nhc3Q8RnJvbnRlbmREdmJ0Q29uc3RlbGxhdGlvbj4obS5kdmJ0KCkpKTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRNb2R1bGF0aW9uOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmlzZGJzOgorICAgICAgICAgICAgICAgICAgICBhaWRsTW9kLnB1c2hfYmFjayhzdGF0aWNfY2FzdDxGcm9udGVuZElzZGJzTW9kdWxhdGlvbj4obS5pc2RicygpKSk7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgSGlkbEZyb250ZW5kTW9kdWxhdGlvbjo6aGlkbF9kaXNjcmltaW5hdG9yOjppc2RiczM6CisgICAgICAgICAgICAgICAgICAgIGFpZGxNb2QucHVzaF9iYWNrKHN0YXRpY19jYXN0PEZyb250ZW5kSXNkYnMzTW9kdWxhdGlvbj4obS5pc2RiczMoKSkpOworICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICBjYXNlIEhpZGxGcm9udGVuZE1vZHVsYXRpb246OmhpZGxfZGlzY3JpbWluYXRvcjo6aXNkYnQ6CisgICAgICAgICAgICAgICAgICAgIGFpZGxNb2QucHVzaF9iYWNrKHN0YXRpY19jYXN0PEZyb250ZW5kSXNkYnRNb2R1bGF0aW9uPihtLmlzZGJ0KCkpKTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRNb2R1bGF0aW9uOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmF0c2M6CisgICAgICAgICAgICAgICAgICAgIGFpZGxNb2QucHVzaF9iYWNrKHN0YXRpY19jYXN0PEZyb250ZW5kQXRzY01vZHVsYXRpb24+KG0uYXRzYygpKSk7CisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgIGNhc2UgSGlkbEZyb250ZW5kTW9kdWxhdGlvbjo6aGlkbF9kaXNjcmltaW5hdG9yOjphdHNjMzoKKyAgICAgICAgICAgICAgICAgICAgYWlkbE1vZC5wdXNoX2JhY2soc3RhdGljX2Nhc3Q8RnJvbnRlbmRBdHNjM01vZHVsYXRpb24+KG0uYXRzYzMoKSkpOworICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICBjYXNlIEhpZGxGcm9udGVuZE1vZHVsYXRpb246OmhpZGxfZGlzY3JpbWluYXRvcjo6ZHRtYjoKKyAgICAgICAgICAgICAgICAgICAgYWlkbE1vZC5wdXNoX2JhY2soc3RhdGljX2Nhc3Q8RnJvbnRlbmREdG1iTW9kdWxhdGlvbj4obS5kdG1iKCkpKTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorICAgICAgICAgICAgc3RhdHVzLnNldDxGcm9udGVuZFN0YXR1czo6bW9kdWxhdGlvbnM+KGFpZGxNb2QpOworICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CisgICAgICAgIGNhc2UgSGlkbEZyb250ZW5kU3RhdHVzRXh0MV8xOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmJlcnM6IHsKKyAgICAgICAgICAgIHZlY3RvcjxpbnQ+IGIocy5iZXJzKCkuYmVnaW4oKSwgcy5iZXJzKCkuZW5kKCkpOworICAgICAgICAgICAgc3RhdHVzLnNldDxGcm9udGVuZFN0YXR1czo6YmVycz4oYik7CisgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRTdGF0dXNFeHQxXzE6OmhpZGxfZGlzY3JpbWluYXRvcjo6Y29kZVJhdGVzOiB7CisgICAgICAgICAgICB2ZWN0b3I8RnJvbnRlbmRJbm5lckZlYz4gY29kZVJhdGVzOworICAgICAgICAgICAgZm9yIChhdXRvIGMgOiBzLmNvZGVSYXRlcygpKSB7CisgICAgICAgICAgICAgICAgY29kZVJhdGVzLnB1c2hfYmFjayhzdGF0aWNfY2FzdDxGcm9udGVuZElubmVyRmVjPihjKSk7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBzdGF0dXMuc2V0PEZyb250ZW5kU3RhdHVzOjpjb2RlUmF0ZXM+KGNvZGVSYXRlcyk7CisgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRTdGF0dXNFeHQxXzE6OmhpZGxfZGlzY3JpbWluYXRvcjo6YmFuZHdpZHRoOiB7CisgICAgICAgICAgICBGcm9udGVuZEJhbmR3aWR0aCBiYW5kd2lkdGg7CisgICAgICAgICAgICBzd2l0Y2ggKHMuYmFuZHdpZHRoKCkuZ2V0RGlzY3JpbWluYXRvcigpKSB7CisgICAgICAgICAgICBjYXNlIEhpZGxGcm9udGVuZEJhbmR3aWR0aDo6aGlkbF9kaXNjcmltaW5hdG9yOjphdHNjMzoKKyAgICAgICAgICAgICAgICBiYW5kd2lkdGguc2V0PEZyb250ZW5kQmFuZHdpZHRoOjphdHNjMz4oCisgICAgICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxGcm9udGVuZEF0c2MzQmFuZHdpZHRoPihzLmJhbmR3aWR0aCgpLmF0c2MzKCkpKTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgSGlkbEZyb250ZW5kQmFuZHdpZHRoOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmR2YmM6CisgICAgICAgICAgICAgICAgYmFuZHdpZHRoLnNldDxGcm9udGVuZEJhbmR3aWR0aDo6ZHZiYz4oCisgICAgICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxGcm9udGVuZER2YmNCYW5kd2lkdGg+KHMuYmFuZHdpZHRoKCkuZHZiYygpKSk7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIEhpZGxGcm9udGVuZEJhbmR3aWR0aDo6aGlkbF9kaXNjcmltaW5hdG9yOjpkdmJ0OgorICAgICAgICAgICAgICAgIGJhbmR3aWR0aC5zZXQ8RnJvbnRlbmRCYW5kd2lkdGg6OmR2YnQ+KAorICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8RnJvbnRlbmREdmJ0QmFuZHdpZHRoPihzLmJhbmR3aWR0aCgpLmR2YnQoKSkpOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRCYW5kd2lkdGg6OmhpZGxfZGlzY3JpbWluYXRvcjo6aXNkYnQ6CisgICAgICAgICAgICAgICAgYmFuZHdpZHRoLnNldDxGcm9udGVuZEJhbmR3aWR0aDo6aXNkYnQ+KAorICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8RnJvbnRlbmRJc2RidEJhbmR3aWR0aD4ocy5iYW5kd2lkdGgoKS5pc2RidCgpKSk7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIEhpZGxGcm9udGVuZEJhbmR3aWR0aDo6aGlkbF9kaXNjcmltaW5hdG9yOjpkdG1iOgorICAgICAgICAgICAgICAgIGJhbmR3aWR0aC5zZXQ8RnJvbnRlbmRCYW5kd2lkdGg6OmR0bWI+KAorICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8RnJvbnRlbmREdG1iQmFuZHdpZHRoPihzLmJhbmR3aWR0aCgpLmR0bWIoKSkpOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgfQorICAgICAgICAgICAgc3RhdHVzLnNldDxGcm9udGVuZFN0YXR1czo6YmFuZHdpZHRoPihiYW5kd2lkdGgpOworICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CisgICAgICAgIGNhc2UgSGlkbEZyb250ZW5kU3RhdHVzRXh0MV8xOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmludGVydmFsOiB7CisgICAgICAgICAgICBGcm9udGVuZEd1YXJkSW50ZXJ2YWwgaW50ZXJ2YWw7CisgICAgICAgICAgICBzd2l0Y2ggKHMuaW50ZXJ2YWwoKS5nZXREaXNjcmltaW5hdG9yKCkpIHsKKyAgICAgICAgICAgIGNhc2UgSGlkbEZyb250ZW5kR3VhcmRJbnRlcnZhbDo6aGlkbF9kaXNjcmltaW5hdG9yOjpkdmJ0OgorICAgICAgICAgICAgICAgIGludGVydmFsLnNldDxGcm9udGVuZEd1YXJkSW50ZXJ2YWw6OmR2YnQ+KAorICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8RnJvbnRlbmREdmJ0R3VhcmRJbnRlcnZhbD4ocy5pbnRlcnZhbCgpLmR2YnQoKSkpOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRHdWFyZEludGVydmFsOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmlzZGJ0OgorICAgICAgICAgICAgICAgIGludGVydmFsLnNldDxGcm9udGVuZEd1YXJkSW50ZXJ2YWw6OmlzZGJ0PigKKyAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PEZyb250ZW5kSXNkYnRHdWFyZEludGVydmFsPihzLmludGVydmFsKCkuaXNkYnQoKSkpOworICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRHdWFyZEludGVydmFsOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmR0bWI6CisgICAgICAgICAgICAgICAgaW50ZXJ2YWwuc2V0PEZyb250ZW5kR3VhcmRJbnRlcnZhbDo6ZHRtYj4oCisgICAgICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxGcm9udGVuZER0bWJHdWFyZEludGVydmFsPihzLmludGVydmFsKCkuZHRtYigpKSk7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBzdGF0dXMuc2V0PEZyb250ZW5kU3RhdHVzOjppbnRlcnZhbD4oaW50ZXJ2YWwpOworICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CisgICAgICAgIGNhc2UgSGlkbEZyb250ZW5kU3RhdHVzRXh0MV8xOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OnRyYW5zbWlzc2lvbk1vZGU6IHsKKyAgICAgICAgICAgIEZyb250ZW5kVHJhbnNtaXNzaW9uTW9kZSB0cmFuc21pc3Npb25Nb2RlOworICAgICAgICAgICAgc3dpdGNoIChzLnRyYW5zbWlzc2lvbk1vZGUoKS5nZXREaXNjcmltaW5hdG9yKCkpIHsKKyAgICAgICAgICAgIGNhc2UgSGlkbEZyb250ZW5kVHJhbnNtaXNzaW9uTW9kZTo6aGlkbF9kaXNjcmltaW5hdG9yOjpkdmJ0OgorICAgICAgICAgICAgICAgIHRyYW5zbWlzc2lvbk1vZGUuc2V0PEZyb250ZW5kVHJhbnNtaXNzaW9uTW9kZTo6ZHZidD4oCisgICAgICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxGcm9udGVuZER2YnRUcmFuc21pc3Npb25Nb2RlPihzLnRyYW5zbWlzc2lvbk1vZGUoKS5kdmJ0KCkpKTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgSGlkbEZyb250ZW5kVHJhbnNtaXNzaW9uTW9kZTo6aGlkbF9kaXNjcmltaW5hdG9yOjppc2RidDoKKyAgICAgICAgICAgICAgICB0cmFuc21pc3Npb25Nb2RlLnNldDxGcm9udGVuZFRyYW5zbWlzc2lvbk1vZGU6OmlzZGJ0PigKKyAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PEZyb250ZW5kSXNkYnRNb2RlPihzLnRyYW5zbWlzc2lvbk1vZGUoKS5pc2RidCgpKSk7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIEhpZGxGcm9udGVuZFRyYW5zbWlzc2lvbk1vZGU6OmhpZGxfZGlzY3JpbWluYXRvcjo6ZHRtYjoKKyAgICAgICAgICAgICAgICB0cmFuc21pc3Npb25Nb2RlLnNldDxGcm9udGVuZFRyYW5zbWlzc2lvbk1vZGU6OmR0bWI+KAorICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8RnJvbnRlbmREdG1iVHJhbnNtaXNzaW9uTW9kZT4ocy50cmFuc21pc3Npb25Nb2RlKCkuZHRtYigpKSk7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICB9CisgICAgICAgICAgICBzdGF0dXMuc2V0PEZyb250ZW5kU3RhdHVzOjp0cmFuc21pc3Npb25Nb2RlPih0cmFuc21pc3Npb25Nb2RlKTsKKyAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICBjYXNlIEhpZGxGcm9udGVuZFN0YXR1c0V4dDFfMTo6aGlkbF9kaXNjcmltaW5hdG9yOjp1ZWM6IHsKKyAgICAgICAgICAgIHN0YXR1cy5zZXQ8R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ZXJsZWF2ZU1vZGU+KGkuYXRzYzMoKSkpOworICAgICAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICBjYXNlIEhpZGxGcm9udGVuZEludGVybGVhdmVNb2RlOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmR2YmM6CisgICAgICAgICAgICAgICAgICAgIGxlYXZlTW9kZS5zZXQ8RnJvbnRlbmRJbnRlcmxlYXZlTW9kZTo6ZHZiYz4oCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8RnJvbnRlbmRDYWJsZVRpbWVJbnRlcmxlYXZlTW9kZT4oaS5kdmJjKCkpKTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRJbnRlcmxlYXZlTW9kZTo6aGlkbF9kaXNjcmltaW5hdG9yOjpkdG1iOgorICAgICAgICAgICAgICAgICAgICBsZWF2ZU1vZGUuc2V0PEZyb250ZW5kSW50ZXJsZWF2ZU1vZGU6OmR0bWI+KAorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PEZyb250ZW5kRHRtYlRpbWVJbnRlcmxlYXZlTW9kZT4oaS5kdG1iKCkpKTsKKyAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgIGFpZGxJbnRlci5wdXNoX2JhY2sobGVhdmVNb2RlKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIHN0YXR1cy5zZXQ8RnJvbnRlbmRTdGF0dXM6OmludGVybGVhdmluZz4oYWlkbEludGVyKTsKKyAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICBjYXNlIEhpZGxGcm9udGVuZFN0YXR1c0V4dDFfMTo6aGlkbF9kaXNjcmltaW5hdG9yOjppc2RidFNlZ21lbnQ6IHsKKyAgICAgICAgICAgIGNvbnN0IHZlY3Rvcjx1aW50OF90PiYgc2VnID0gcy5pc2RidFNlZ21lbnQoKTsKKyAgICAgICAgICAgIHZlY3RvcjxpbnQzMl90PiBpKHNlZy5iZWdpbigpLCBzZWcuZW5kKCkpOworICAgICAgICAgICAgc3RhdHVzLnNldDxGcm9udGVuZFN0YXR1czo6aXNkYnRTZWdtZW50PihpKTsKKyAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICBjYXNlIEhpZGxGcm9udGVuZFN0YXR1c0V4dDFfMTo6aGlkbF9kaXNjcmltaW5hdG9yOjp0c0RhdGFSYXRlOiB7CisgICAgICAgICAgICB2ZWN0b3I8aW50MzJfdD4gdHMocy50c0RhdGFSYXRlKCkuYmVnaW4oKSwgcy50c0RhdGFSYXRlKCkuZW5kKCkpOworICAgICAgICAgICAgc3RhdHVzLnNldDxGcm9udGVuZFN0YXR1czo6dHNEYXRhUmF0ZT4odHMpOworICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CisgICAgICAgIGNhc2UgSGlkbEZyb250ZW5kU3RhdHVzRXh0MV8xOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OnJvbGxPZmY6IHsKKyAgICAgICAgICAgIEZyb250ZW5kUm9sbE9mZiByb2xsT2ZmOworICAgICAgICAgICAgc3dpdGNoIChzLnJvbGxPZmYoKS5nZXREaXNjcmltaW5hdG9yKCkpIHsKKyAgICAgICAgICAgIGNhc2UgSGlkbEZyb250ZW5kUm9sbE9mZjo6aGlkbF9kaXNjcmltaW5hdG9yOjpkdmJzOgorICAgICAgICAgICAgICAgIHJvbGxPZmYuc2V0PEZyb250ZW5kUm9sbE9mZjo6ZHZicz4oCisgICAgICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxGcm9udGVuZER2YnNSb2xsb2ZmPihzLnJvbGxPZmYoKS5kdmJzKCkpKTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIGNhc2UgSGlkbEZyb250ZW5kUm9sbE9mZjo6aGlkbF9kaXNjcmltaW5hdG9yOjppc2RiczoKKyAgICAgICAgICAgICAgICByb2xsT2ZmLnNldDxGcm9udGVuZFJvbGxPZmY6OmlzZGJzPigKKyAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PEZyb250ZW5kSXNkYnNSb2xsb2ZmPihzLnJvbGxPZmYoKS5pc2RicygpKSk7CisgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAgICBjYXNlIEhpZGxGcm9udGVuZFJvbGxPZmY6OmhpZGxfZGlzY3JpbWluYXRvcjo6aXNkYnMzOgorICAgICAgICAgICAgICAgIHJvbGxPZmYuc2V0PEZyb250ZW5kUm9sbE9mZjo6aXNkYnMzPigKKyAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PEZyb250ZW5kSXNkYnMzUm9sbG9mZj4ocy5yb2xsT2ZmKCkuaXNkYnMzKCkpKTsKKyAgICAgICAgICAgICAgICBicmVhazsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIHN0YXR1cy5zZXQ8RnJvbnRlbmRTdGF0dXM6OnJvbGxPZmY+KHJvbGxPZmYpOworICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CisgICAgICAgIGNhc2UgSGlkbEZyb250ZW5kU3RhdHVzRXh0MV8xOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmlzTWlzbzogeworICAgICAgICAgICAgc3RhdHVzLnNldDxGcm9udGVuZFN0YXR1czo6aXNNaXNvPihzLmlzTWlzbygpKTsKKyAgICAgICAgICAgIGFpZGxTdGF0dXMucHVzaF9iYWNrKHN0YXR1cyk7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICBjYXNlIEhpZGxGcm9udGVuZFN0YXR1c0V4dDFfMTo6aGlkbF9kaXNjcmltaW5hdG9yOjppc0xpbmVhcjogeworICAgICAgICAgICAgc3RhdHVzLnNldDxGcm9udGVuZFN0YXR1czo6aXNMaW5lYXI+KHMuaXNMaW5lYXIoKSk7CisgICAgICAgICAgICBhaWRsU3RhdHVzLnB1c2hfYmFjayhzdGF0dXMpOworICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgY2FzZSBIaWRsRnJvbnRlbmRTdGF0dXNFeHQxXzE6OmhpZGxfZGlzY3JpbWluYXRvcjo6aXNTaG9ydEZyYW1lczogeworICAgICAgICAgICAgc3RhdHVzLnNldDxGcm9udGVuZFN0YXR1czo6aXNTaG9ydEZyYW1lcz4ocy5pc1Nob3J0RnJhbWVzKCkpOworICAgICAgICAgICAgYWlkbFN0YXR1cy5wdXNoX2JhY2soc3RhdHVzKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICB9CisgICAgICAgIH0KKyAgICB9Cit9CisKK2hpZGxfdmVjPEhpZGxGcm9udGVuZEF0c2MzUGxwU2V0dGluZ3M+IFR1bmVySGlkbEZyb250ZW5kOjpnZXRBdHNjM1BscFNldHRpbmdzKAorICAgICAgICBjb25zdCBGcm9udGVuZEF0c2MzU2V0dGluZ3MmIHNldHRpbmdzKSB7CisgICAgaW50IGxlbiA9IHNldHRpbmdzLnBscFNldHRpbmdzLnNpemUoKTsKKyAgICBoaWRsX3ZlYzxIaWRsRnJvbnRlbmRBdHNjM1BscFNldHRpbmdzPiBwbHBzID0gaGlkbF92ZWM8SGlkbEZyb250ZW5kQXRzYzNQbHBTZXR0aW5ncz4obGVuKTsKKyAgICAvLyBwYXJzZSBQTFAgc2V0dGluZ3MKKyAgICBmb3IgKGludCBpID0gMDsgaSA8IGxlbjsgaSsrKSB7CisgICAgICAgIHVpbnQ4X3Qg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ICAgICAgICAucGxwSWQgPSBzdGF0aWNfY2FzdDx1aW50OF90PihkdmJ0LnBscElkKSwKKyAgICAgICAgICAgICAgICAucGxwR3JvdXBJZCA9IHN0YXRpY19jYXN0PHVpbnQ4X3Q+KGR2YnQucGxwR3JvdXBJZCksCisgICAgICAgIH0pOworICAgICAgICBzZXR0aW5nc0V4dC5zZXR0aW5nRXh0LmR2YnQoeworICAgICAgICAgICAgICAgIC5jb25zdGVsbGF0aW9uID0gc3RhdGljX2Nhc3Q8CisgICAgICAgICAgICAgICAgICAgICAgICA6OmFuZHJvaWQ6OmhhcmR3YXJlOjp0djo6dHVuZXI6OlYxXzE6OkZyb250ZW5kRHZidENvbnN0ZWxsYXRpb24+KAorICAgICAgICAgICAgICAgICAgICAgICAgZHZidC5jb25zdGVsbGF0aW9uKSwKKyAgICAgICAgICAgICAgICAudHJhbnNtaXNzaW9uTW9kZSA9IHN0YXRpY19jYXN0PAorICAgICAgICAgICAgICAgICAgICAgICAgOjphbmRyb2lkOjpoYXJkd2FyZTo6dHY6OnR1bmVyOjpWMV8xOjpGcm9udGVuZER2YnRUcmFuc21pc3Npb25Nb2RlPigKKyAgICAgICAgICAgICAgICAgICAgICAgIGR2YnQudHJhbnNtaXNzaW9uTW9kZSksCisgICAgICAgIH0pOworICAgICAgICBzZXR0aW5nc0V4dC5lbmRGcmVxdWVuY3kgPSBzdGF0aWNfY2FzdDx1aW50MzJfdD4oZHZidC5lbmRGcmVxdWVuY3kpOworICAgICAgICBzZXR0aW5nc0V4dC5pbnZlcnNpb24gPSBzdGF0aWNfY2FzdDxIaWRsRnJvbnRlbmRTcGVjdHJhbEludmVyc2lvbj4oZHZidC5pbnZlcnNpb24pOworICAgICAgICBicmVhazsKKyAgICB9CisgICAgY2FzZSBGcm9udGVuZFNldHRpbmdzOjppc2RiczogeworICAgICAgICBjb25zdCBGcm9udGVuZElzZGJzU2V0dGluZ3MmIGlzZGJzID0gYWlkbFNldHRpbmdzLmdldDxGcm9udGVuZFN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BlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IEhpZGxGcm9udGVuZFNjYW5NZXNzYWdlRXh0MV8xJiBtZXNzYWdlKTsKKworICAgICAgICBzaGFyZWRfcHRyPElUdW5lckZyb250ZW5kQ2FsbGJhY2s+IG1UdW5lckZyb250ZW5kQ2FsbGJhY2s7CisgICAgfTsKKworcHJpdmF0ZToKKyAgICBoaWRsX3ZlYzxIaWRsRnJvbnRlbmRBdHNjM1BscFNldHRpbmdzPiBnZXRBdHNjM1BscFNldHRpbmdzKAorICAgICAgICAgICAgY29uc3QgRnJvbnRlbmRBdHNjM1NldHRpbmdzJiBzZXR0aW5ncyk7CisgICAgSGlkbEZyb250ZW5kRHZic0NvZGVSYXRlIGdldER2YnNDb2RlUmF0ZShjb25zdCBGcm9udGVuZER2YnNDb2RlUmF0ZSYgY29kZVJhdGUpOworICAgIHZvaWQgZ2V0SGlkbEZyb250ZW5kU2V0dGluZ3MoY29uc3QgRnJvbnRlbmRTZXR0aW5ncyYgYWlkbFNldHRpbmdzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSGlkbEZyb250ZW5kU2V0dGluZ3MmIHNldHRpbmdzLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSGlkbEZyb250ZW5kU2V0dGluZ3NFeHQxXzEmIHNldHRpbmdzRXh0KTsKKyAgICB2b2lkIGdldEFpZGxGcm9udGVuZFN0YXR1cyhjb25zdCB2ZWN0b3I8SGlkbEZyb250ZW5kU3RhdHVzPiYgaGlkbFN0YXR1cywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2ZWN0b3I8SGlkbEZyb250ZW5kU3RhdHVzRXh0MV8xPiYgaGlkbFN0YXR1c0V4dCwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2ZWN0b3I8RnJvbnRlbmRTdGF0dXM+JiBhaWRsU3RhdHVzKTsKKworICAgIGludCB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VyID0gSGlkbElUdW5lcjo6Z2V0U2VydmljZSgpOworICAgIGlmIChtVHVuZXIgPT0gbnVsbHB0cikgeworICAgICAgICBBTE9HRSgiRmFpbGVkIHRvIGdldCBJVHVuZXIgc2VydmljZSIpOworICAgICAgICByZXR1cm4gZmFsc2U7CisgICAgfQorICAgIG1UdW5lclZlcnNpb24gPSBUVU5FUl9IQUxfVkVSU0lPTl8xXzA7CisKKyAgICBtVHVuZXJfMV8xID0gOjphbmRyb2lkOjpoYXJkd2FyZTo6dHY6OnR1bmVyOjpWMV8xOjpJVHVuZXI6OmNhc3RGcm9tKG1UdW5lcik7CisgICAgaWYgKG1UdW5lcl8xXzEgIT0gbnVsbHB0cikgeworICAgICAgICBtVHVuZXJWZXJzaW9uID0gVFVORVJfSEFMX1ZFUlNJT05fMV8xOworICAgIH0gZWxzZSB7CisgICAgICAgIEFMT0dEKCJGYWlsZWQgdG8gZ2V0IElUdW5lcl8xXzEgc2VydmljZSIpOworICAgIH0KKworICAgIHJldHVybiB0cnVlOworfQorCitib29sIFR1bmVySGlkbFNlcnZpY2U6Omhhc0lUdW5lcl8xXzEoKSB7CisgICAgQUxPR1YoImhhc0lUdW5lcl8xXzEiKTsKKyAgICBoYXNJVHVuZXIoKTsKKyAgICByZXR1cm4gKG1UdW5lclZlcnNpb24gPT0gVFVORVJfSEFMX1ZFUlNJT05fMV8xKTsKK30KKworOjpuZGs6OlNjb3BlZEFTdGF0dXMgVHVuZXJIaWRsU2VydmljZTo6b3BlbkRlbXV4KGludDMyX3QgLyogaW5fZGVtdXhIYW5kbGUgKi8sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2hhcmVkX3B0cjxJVHVuZXJEZW11eD4qIF9haWRsX3JldHVybikgeworICAgIEFMT0dWKCJvcGVuRGVtdXgiKTsKKyAgICBpZiAoIWhhc0lUdW5lcigpKSB7CisgICAgICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6ZnJvbVNlcnZpY2VTcGVjaWZpY0Vycm9yKAorICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PGludDMyX3Q+KFJlc3VsdDo6VU5BVkFJTEFCTEUpKTsKKyAgICB9CisKKyAgICBIaWRsUmVzdWx0IHJlczsKKyAgICB1aW50MzJfdCBpZDsKKyAgICBzcDxJRGVtdXg+IGRlbXV4U3AgPSBudWxscHRyOworICAgIG1UdW5lci0+b3BlbkRlbXV4KFsmXShIaWRsUmVzdWx0IHIsIHVpbnQzMl90IGRlbXV4SWQsIGNvbnN0IHNwPElEZW11eD4mIGRlbXV4KSB7CisgICAgICAgIGRlbXV4U3AgPSBkZW11eDsKKyAgICAgICAgaWQgPSBkZW11eElkOworICAgICAgICByZXMgPSByOworICAgICAgICBBTE9HRCgib3BlbiBkZW11eCwgaWQgPSAlZCIsIGRlbXV4SWQpOworICAgIH0pOworICAgIGlmIChyZXMgPT0gSGlkbFJlc3VsdDo6U1VDQ0VTUykgeworICAgICAgICAqX2FpZGxfcmV0dXJuID0gOjpuZGs6OlNoYXJlZFJlZkJhc2U6Om1ha2U8VHVuZXJIaWRsRGVtdXg+KGRlbXV4U3AsIGlkKTsKKyAgICAgICAgcmV0dXJuIDo6bmRrOjpTY29wZWRBU3RhdHVzOjpvaygpOworICAgIH0KKworICAgIEFMT0dXKCJvcGVuIGRlbXV4IGZhaWxlZCwgcmVzID0gJWQiLCByZXMpOworICAgIHJldHVybiA6Om5kazo6U2NvcGVkQVN0YXR1czo6ZnJvbVNlcnZpY2VTcGVjaWZpY0Vycm9yKHN0YXRpY19jYXN0PGludDMyX3Q+KHJlcykpOworfQorCis6Om5kazo6U2NvcGVkQVN0YXR1cyBUdW5lckhpZGxTZXJ2aWNlOjpnZXREZW11eENhcHMoRGVtdXhDYXBhYmlsaXRpZXMqIF9haWRsX3JldHVybikgeworICAgIEFMT0dWKCJnZXREZW11eENhcHMiKTsKKyAgICBpZiAoIWhhc0lUdW5lcigpKSB7CisgICAgICAgIHJldHV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iKTsKKyAgICAgICAgcmV0dXJuIDo6bmRrOjpTY29wZWRBU3RhdHVzOjpmcm9tU2VydmljZVNwZWNpZmljRXJyb3IoCisgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8aW50MzJfdD4oUmVzdWx0OjpVTkFWQUlMQUJMRSkpOworICAgIH0KKworICAgIG1MbmFTdGF0dXMgPSBiRW5hYmxlID8gMSA6IDA7CisKKyAgICB7CisgICAgICAgIE11dGV4OjpBdXRvbG9jayBfbChtT3BlbmVkRnJvbnRlbmRzTG9jayk7CisgICAgICAgIGZvciAoYXV0byBpdCA9IG1PcGVuZWRGcm9udGVuZHMuYmVnaW4oKTsgaXQgIT0gbU9wZW5lZEZyb250ZW5kcy5lbmQoKTsgKytpdCkgeworICAgICAgICAgICAgKCppdCktPnNldExuYShtTG5hU3RhdHVzID09IDEpOworICAgICAgICB9CisgICAgfQorCisgICAgcmV0dXJuIDo6bmRrOjpTY29wZWRBU3RhdHVzOjpvaygpOworfQorCis6Om5kazo6U2NvcGVkQVN0YXR1cyBUdW5lckhpZGxTZXJ2aWNlOjpzZXRNYXhOdW1iZXJPZkZyb250ZW5kcyhGcm9udGVuZFR5cGUgLyogaW5fZnJvbnRlbmRUeXBlICovLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50MzJfdCAvKiBpbl9tYXhOdW1iZXIgKi8pIHsKKyAgICByZXR1cm4gOjpuZGs6OlNjb3BlZEFTdGF0dXM6OmZyb21TZXJ2aWNlU3BlY2lmaWNFcnJvcigKKyAgICAgICAgICAgIHN0YXRpY19jYXN0PGludDMyX3Q+KFJlc3VsdDo6VU5BVkFJTEFCTEUpKTsKK30KKworOjpuZGs6OlNjb3BlZEFTdGF0dXMgVHVuZXJIaWRsU2VydmljZTo6Z2V0TWF4TnVtYmVyT2ZGcm9udGVuZHMoRnJvbnRlbmRUeXBlIC8qIGluX2Zyb250ZW5kVHlwZSAqLywKKyA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lcyAhPSBIaWRsUmVzdWx0OjpTVUNDRVNTKSB7CisgICAgICAgIHJldHVybiBpbmZvczsKKyAgICB9CisKKyAgICBmb3IgKGludCBpID0gMDsgaSA8IGlkcy5zaXplKCk7IGkrKykgeworICAgICAgICBIaWRsRnJvbnRlbmRJbmZvIGZyb250ZW5kSW5mbzsKKyAgICAgICAgSGlkbFJlc3VsdCByZXMgPSBnZXRIaWRsRnJvbnRlbmRJbmZvKHN0YXRpY19jYXN0PGludDMyX3Q+KGlkc1tpXSksIGZyb250ZW5kSW5mbyk7CisgICAgICAgIGlmIChyZXMgIT0gSGlkbFJlc3VsdDo6U1VDQ0VTUykgeworICAgICAgICAgICAgY29udGludWU7CisgICAgICAgIH0KKyAgICAgICAgVHVuZXJGcm9udGVuZEluZm8gdHVuZXJGcm9udGVuZEluZm97CisgICAgICAgICAgICAgICAgLmhhbmRsZSA9IFR1bmVySGVscGVyOjpnZXRSZXNvdXJjZUhhbmRsZUZyb21JZChzdGF0aWNfY2FzdDxpbnQzMl90PihpZHNbaV0pLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRlJPTlRFTkQpLAorICAgICAgICAgICAgICAgIC50eXBlID0gc3RhdGljX2Nhc3Q8aW50MzJfdD4oZnJvbnRlbmRJbmZvLnR5cGUpLAorICAgICAgICAgICAgICAgIC5leGNsdXNpdmVHcm91cElkID0gc3RhdGljX2Nhc3Q8aW50MzJfdD4oZnJvbnRlbmRJbmZvLmV4Y2x1c2l2ZUdyb3VwSWQpLAorICAgICAgICB9OworICAgICAgICBpbmZvcy5wdXNoX2JhY2sodHVuZXJGcm9udGVuZEluZm8pOworICAgIH0KKworICAgIHJldHVybiBpbmZvczsKK30KKwordmVjdG9yPGludDMyX3Q+IFR1bmVySGlkbFNlcnZpY2U6OmdldFRSTUxuYkhhbmRsZXMoKSB7CisgICAgdmVjdG9yPGludDMyX3Q+IGxuYkhhbmRsZXM7CisgICAgaWYgKG1UdW5lciAhPSBudWxscHRyKSB7CisgICAgICAgIEhpZGxSZXN1bHQgcmVzOworICAgICAgICB2ZWN0b3I8SGlkbExuYklkPiBsbmJJZHM7CisgICAgICAgIG1UdW5lci0+Z2V0TG5iSWRzKFsmXShIaWRsUmVzdWx0IHIsIGNvbnN0IGhpZGxfdmVjPEhpZGxMbmJJZD4mIGlkcykgeworICAgICAgICAgICAgbG5iSWRzID0gaWRzOworICAgICAgICAgICAgcmVzID0gcjsKKyAgICAgICAgfSk7CisgICAgICAgIGlmIChyZXMgPT0gSGlkbFJlc3VsdDo6U1VDQ0VTUyAmJiBsbmJJZHMuc2l6ZSgpID4gMCkgeworICAgICAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBsbmJJZHMuc2l6ZSgpOyBpKyspIHsKKyAgICAgICAgICAgICAgICBsbmJIYW5kbGVzLnB1c2hfYmFjaygKKyAgICAgICAgICAgICAgICAgICAgICAgIFR1bmVySGVscGVyOjpnZXRSZXNvdXJjZUhhbmRsZUZyb21JZChzdGF0aWNfY2FzdDxpbnQzMl90PihsbmJJZHNbaV0pLCBMTkIpKTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgfQorICAgIH0KKworICAgIHJldHVybiBsbmJIYW5kbGVzOworfQorCitIaWRsUmVzdWx0IFR1bmVySGlkbFNlcnZpY2U6OmdldEhpZGxGcm9udGVuZElkcyhoaWRsX3ZlYzxIaWRsRnJvbnRlbmRJZD4mIGlkcykgeworICAgIGlmIChtVHVuZXIgPT0gbnVsbHB0cikgeworICAgICAgICByZXR1cm4gSGlkbFJlc3VsdDo6Tk9UX0lOSVRJQUxJWkVEOworICAgIH0KKyAgICBIaWRsUmVzdWx0IHJlczsKKyAgICBtVHVuZXItPmdldEZyb250ZW5kSWRzKFsmXShIaWRsUmVzdWx0IHIsIGNvbnN0IGhpZGxfdmVjPEhpZGxGcm9udGVuZElkPiYgZnJvbnRlbmRJZHMpIHsKKyAgICAgICAgaWRzID0gZnJvbnR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zeworICAgICAgICAgICAgICAgICAgICAubW9kdWxhdGlvbkNhcCA9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8aW50MzJfdD4oaGFsSW5mby5mcm9udGVuZENhcHMuYXRzY0NhcHMoKS5tb2R1bGF0aW9uQ2FwKSwKKyAgICAgICAgICAgIH07CisgICAgICAgICAgICBjYXBzLnNldDxGcm9udGVuZENhcGFiaWxpdGllczo6YXRzY0NhcHM+KGF0c2NDYXBzKTsKKyAgICAgICAgfQorICAgICAgICBicmVhazsKKyAgICB9CisgICAgY2FzZSA6OmFuZHJvaWQ6OmhhcmR3YXJlOjp0djo6dHVuZXI6OlYxXzA6OkZyb250ZW5kVHlwZTo6QVRTQzM6IHsKKyAgICAgICAgaWYgKEhpZGxGcm9udGVuZEluZm86OkZyb250ZW5kQ2FwYWJpbGl0aWVzOjpoaWRsX2Rpc2NyaW1pbmF0b3I6OmF0c2MzQ2FwcyA9PQorICAgICAgICAgICAgaGFsSW5mby5mcm9udGVuZENhcHMuZ2V0RGlzY3JpbWluYXRvcigpKSB7CisgICAgICAgICAgICBGcm9udGVuZEF0c2MzQ2FwYWJpbGl0aWVzIGF0c2MzQ2Fwc3sKKyAgICAgICAgICAgICAgICAgICAgLmJhbmR3aWR0aENhcCA9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8aW50MzJfdD4oaGFsSW5mby5mcm9udGVuZENhcHMuYXRzYzNDYXBzKCkuYmFuZHdpZHRoQ2FwKSwKKyAgICAgICAgICAgICAgICAgICAgLm1vZHVsYXRpb25DYXAgPQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PGludDMyX3Q+KGhhbEluZm8uZnJvbnRlbmRDYXBzLmF0c2MzQ2FwcygpLm1vZHVsYXRpb25DYXApLAorICAgICAgICAgICAgICAgICAgICAudGltZUludGVybGVhdmVNb2RlQ2FwID0gc3RhdGljX2Nhc3Q8aW50MzJfdD4oCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFsSW5mby5mcm9udGVuZENhcHMuYXRzYzNDYXBzKCkudGltZUludGVybGVhdmVNb2RlQ2FwKSwKKyAgICAgICAgICAgICAgICAgICAgLmNvZGVSYXRlQ2FwID0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxpbnQzMl90PihoYWxJbmZvLmZyb250ZW5kQ2Fwcy5hdHNjM0NhcHMoKS5jb2RlUmF0ZUNhcCksCisgICAgICAgICAgICAgICAgICAgIC5kZW1vZE91dHB1dEZvcm1hdENhcCA9IHN0YXRpY19jYXN0PGludDhfdD4oCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFsSW5mby5mcm9udGVuZENhcHMuYXRzYzNDYXBzKCkuZGVtb2RPdXRwdXRGb3JtYXRDYXApLAorICAgICAgICAgICAgICAgICAgICAuZmVjQ2FwID0gc3RhdGljX2Nhc3Q8aW50MzJfdD4oaGFsSW5mby5mcm9udGVuZENhcHMuYXRzYzNDYXBzKCkuZmVjQ2FwKSwKKyAgICAgICAgICAgIH07CisgICAgICAgICAgICBjYXBzLnNldDxGcm9udGVuZENhcGFiaWxpdGllczo6YXRzYzNDYXBzPihhdHNjM0NhcHMpOworICAgICAgICB9CisgICAgICAgIGJyZWFrOworICAgIH0KKyAgICBjYXNlIDo6YW5kcm9pZDo6aGFyZHdhcmU6OnR2Ojp0dW5lcjo6VjFfMDo6RnJvbnRlbmRUeXBlOjpEVkJDOiB7CisgICAgICAgIGlmIChIaWRsRnJvbnRlbmRJbmZvOjpGcm9udGVuZENhcGFiaWxpdGllczo6aGlkbF9kaXNjcmltaW5hdG9yOjpkdmJjQ2FwcyA9PQorICAgICAgICAgICAgaGFsSW5mby5mcm9udGVuZENhcHMuZ2V0RGlzY3JpbWluYXRvcigpKSB7CisgICAgICAgICAgICBGcm9udGVuZER2YmNDYXBhYmlsaXRpZXMgZHZiY0NhcHN7CisgICAgICAgICAgICAgICAgICAgIC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DYXAgPQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PGludDY0X3Q+KGhhbEluZm8uZnJvbnRlbmRDYXBzLmR2YnNDYXBzKCkuaW5uZXJmZWNDYXApLAorICAgICAgICAgICAgICAgICAgICAuc3RhbmRhcmQgPSBzdGF0aWNfY2FzdDxpbnQ4X3Q+KGhhbEluZm8uZnJvbnRlbmRDYXBzLmR2YnNDYXBzKCkuc3RhbmRhcmQpLAorICAgICAgICAgICAgfTsKKyAgICAgICAgICAgIGNhcHMuc2V0PEZyb250ZW5kQ2FwYWJpbGl0aWVzOjpkdmJzQ2Fwcz4oZHZic0NhcHMpOworICAgICAgICB9CisgICAgICAgIGJyZWFrOworICAgIH0KKyAgICBjYXNlIDo6YW5kcm9pZDo6aGFyZHdhcmU6OnR2Ojp0dW5lcjo6VjFfMDo6RnJvbnRlbmRUeXBlOjpEVkJUOiB7CisgICAgICAgIGlmIChIaWRsRnJvbnRlbmRJbmZvOjpGcm9udGVuZENhcGFiaWxpdGllczo6aGlkbF9kaXNjcmltaW5hdG9yOjpkdmJ0Q2FwcyA9PQorICAgICAgICAgICAgaGFsSW5mby5mcm9udGVuZENhcHMuZ2V0RGlzY3JpbWluYXRvcigpKSB7CisgICAgICAgICAgICBGcm9udGVuZER2YnRDYXBhYmlsaXRpZXMgZHZidENhcHN7CisgICAgICAgICAgICAgICAgICAgIC50cmFuc21pc3Npb25Nb2RlQ2FwID0gc3RhdGljX2Nhc3Q8aW50MzJfdD4oCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFsSW5mby5mcm9udGVuZENhcHMuZHZidENhcHMoKS50cmFuc21pc3Npb25Nb2RlQ2FwKSwKKyAgICAgICAgICAgICAgICAgICAgLmJhbmR3aWR0aENhcCA9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8aW50MzJfdD4oaGFsSW5mby5mcm9udGVuZENhcHMuZHZidENhcHMoKS5iYW5kd2lkdGhDYXApLAorICAgICAgICAgICAgICAgICAgICAuY29uc3RlbGxhdGlvbkNhcCA9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8aW50MzJfdD4oaGFsSW5mby5mcm9udGVuZENhcHMuZHZidENhcHMoKS5jb25zdGVsbGF0aW9uQ2FwKSwKKyAgICAgICAgICAgICAgICAgICAgLmNvZGVyYXRlQ2FwID0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0aWNfY2FzdDxpbnQzMl90PihoYWxJbmZvLmZyb250ZW5kQ2Fwcy5kdmJ0Q2FwcygpLmNvZGVyYXRlQ2FwKSwKKyAgICAgICAgICAgICAgICAgICAgLmhpZXJhcmNoeUNhcCA9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8aW50MzJfdD4oaGFsSW5mby5mcm9udGVuZENhcHMuZHZidENhcHMoKS5oaWVyYXJjaHlDYXApLAorICAgICAgICAgICAgICAgICAgICAuZ3VhcmRJbnRlcnZhbENhcCA9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8aW50MzJfdD4oaGFsSW5mby5mcm9udGVuZENhcHMuZHZidENhcHMoKS5ndWFyZEludGVydmFsQ2FwKSwKKyAgICAgICAgICAgICAgICAgICAgLmlzVDJTdXBwb3J0ZWQgPSBoYWxJbmZvLmZyb250ZW5kQ2Fwcy5kdmJ0Q2FwcygpLmlzVDJTdXBwb3J0ZWQsCisgICAgICAgICAgICAgICAgICAgIC5pc01pc29TdXBwb3J0ZWQgPSBoYWxJbmZvLmZyb250ZW5kQ2Fwcy5kdmJ0Q2FwcygpLmlzTWlzb1N1cHBvcnRlZCwKKyAgICAgICAgICAgIH07CisgICAgICAgICAgICBjYXBzLnNldDxGcm9udGVuZENhcGFiaWxpdGllczo6ZHZidENhcHM+KGR2YnRDYXBzKTsKKyAgICAgICAgfQorICAgICAgICBicmVhazsKKyAgICB9CisgICAgY2FzZSA6OmFuZH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3aWR0aENhcCA9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGljX2Nhc3Q8aW50MzJfdD4oaGFsSW5mby5mcm9udGVuZENhcHMuaXNkYnRDYXBzKCkuYmFuZHdpZHRoQ2FwKSwKKyAgICAgICAgICAgICAgICAgICAgLm1vZHVsYXRpb25DYXAgPQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PGludDMyX3Q+KGhhbEluZm8uZnJvbnRlbmRDYXBzLmlzZGJ0Q2FwcygpLm1vZHVsYXRpb25DYXApLAorICAgICAgICAgICAgICAgICAgICAuY29kZXJhdGVDYXAgPQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PGludDMyX3Q+KGhhbEluZm8uZnJvbnRlbmRDYXBzLmlzZGJ0Q2FwcygpLmNvZGVyYXRlQ2FwKSwKKyAgICAgICAgICAgICAgICAgICAgLmd1YXJkSW50ZXJ2YWxDYXAgPQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PGludDMyX3Q+KGhhbEluZm8uZnJvbnRlbmRDYXBzLmlzZGJ0Q2FwcygpLmd1YXJkSW50ZXJ2YWxDYXApLAorICAgICAgICAgICAgICAgICAgICAudGltZUludGVybGVhdmVDYXAgPQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRpY19jYXN0PGludDMyX3Q+KEZyb250ZW5kSXNkYnRUaW1lSW50ZXJsZWF2ZU1vZGU6OlVOREVGSU5FRCksCisgICAgICAgICAgICAgICAgICAgIC5pc1NlZ21lbnRBdXRvID0gZmFsc2UsCisgICAgICAgICAgICAgICAgICAgIC5pc0Z1bGxTZWdtZW50ID0gZmFsc2UsCisgICAgICAgICAgICB9OworICAgICAgICAgICAgY2Fwcy5zZXQ8RnJvbnRlbmRDYXBhYmlsaXRpZXM6OmlzZGJ0Q2Fwcz4oaXNkYnRDYXBzKTsKKyAgICAgICAgfQorICAgICAgICBicmVhazsKKyAgICB9CisgICAgZGVmYXVsdDogeworICAgICAgICBpZiAoc3RhdGljX2Nhc3Q8SGlkbEZyb250ZW5kVHlwZT4oaW5mby50eXBlKSA9PSBIaWRsRnJvbnRlbmRUeXBlOjpEVE1CKSB7CisgICAgICAgICAgICBGcm9udGVuZER0bWJDYXBhYmlsaXRpZXMgZHRtYkNhcHN7CisgICAgICAgICAgICAgICAgICAgIC50cmFuc21pc3Npb25Nb2RlQ2FwID0gc3RhdGljX2Nhc3Q8aW50MzJfdD4oaGFsRHRtYkNhcHMudHJhbnNtaXNzaW9uTW9kZUNhcCksCisgICAgICAgICAgICAgICAgICAgIC5iYW5kd2lkdGhDYXAgPSBzdGF0aWNfY2FzdDxpbnQzMl90PihoYWxEdG1iQ2Fwcy5iYW5kd2lkdGhDYXApLAorICAgICAgICAgICAgICAgICAgICAubW9kdWxhdGlvbkNhcCA9IHN0YXRpY19jYXN0PGludDMyX3Q+KGhhbER0bWJDYXBzLm1vZHVsYXRpb25DYXApLAorICAgICAgICAgICAgICAgICAgICAuY29kZVJhdGVDYXAgPSBzdGF0aWNfY2FzdDxpbnQzMl90PihoYWxEdG1iQ2Fwcy5jb2RlUmF0ZUNhcCksCisgICAgICAgICAgICAgICAgICAgIC5ndWFyZEludGVydmFsQ2FwID0gc3RhdGljX2Nhc3Q8aW50MzJfdD4oaGFsRHRtYkNhcHMuZ3VhcmRJbnRlcnZhbENhcCksCisgICAgICAgICAgICAgICAgICAgIC5pbnRlcmxlYXZlTW9kZUNhcCA9IHN0YXRpY19jYXN0PGludDMyX3Q+KGhhbER0bWJDYXBzLmludGVybGVhdmVNb2RlQ2FwKSwKKyAgICAgICAgICAgIH07CisgICAgICAgICAgICBjYXBzLnNldDxGcm9udGVuZENhcGFiaWxpdGllczo6ZHRtYkNhcHM+KGR0bWJDYXBzKTsKKyAgICAgICAgfQorICAgICAgICBicmVhazsKKyAgICB9CisgICAgfQorCisgICAgaW5mby5mcm9udGVuZENhcHMgPSBjYXBzOworICAgIHJldHV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HsgcmV0dXJuICJtZWRpYS50dW5lciI7IH0KKyAgICBzdGF0aWMgYmluZGVyX3N0YXR1c190IGluc3RhbnRpYXRlKCk7CisgICAgVHVuZXJIaWRsU2VydmljZSgpOworICAgIHZpcnR1YWwgflR1bmVySGlkbFNlcnZpY2UoKTsKKworICAgIDo6bmRrOjpTY29wZWRBU3RhdHVzIGdldEZyb250ZW5kSWRzKHZlY3RvcjxpbnQzMl90Piogb3V0X2lkcykgb3ZlcnJpZGU7CisgICAgOjpuZGs6OlNjb3BlZEFTdGF0dXMgZ2V0RnJvbnRlbmRJbmZvKGludDMyX3QgaW5fZnJvbnRlbmRIYW5kbGUsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZyb250ZW5kSW5mbyogX2FpZGxfcmV0dXJuKSBvdmVycmlkZTsKKyAgICA6Om5kazo6U2NvcGVkQVN0YXR1cyBvcGVuRnJvbnRlbmQoaW50MzJfdCBpbl9mcm9udGVuZEhhbmRsZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2hhcmVkX3B0cjxJVHVuZXJGcm9udGVuZD4qIF9haWRsX3JldHVybikgb3ZlcnJpZGU7CisgICAgOjpuZGs6OlNjb3BlZEFTdGF0dXMgb3BlbkxuYihpbnQzMl90IGluX2xuYkhhbmRsZSwKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNoYXJlZF9wdHI8SVR1bmVyTG5iPiogX2FpZGxfcmV0dXJuKSBvdmVycmlkZTsKKyAgICA6Om5kazo6U2NvcGVkQVN0YXR1cyBvcGVuTG5iQnlOYW1lKGNvbnN0IHN0ZDo6c3RyaW5nJiBpbl9sbmJOYW1lLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2hhcmVkX3B0cjxJVHVuZXJMbmI+KiBfYWlkbF9yZXR1cm4pIG92ZXJyaWRlOworICAgIDo6bmRrOjpTY29wZWRBU3RhdHVzIG9wZW5EZW11eChp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