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7CisgICAgICAgICAgICBiYWRBdHRyaWJWZWMucHVzaF9iYWNrKCJFR0xfVFJBTlNQQVJFTlRfR1JFRU5fVkFMVUUiKTsKKyAgICAgICAgfQorICAgICAgICBpZiAoIWVnbEdldENvbmZpZ0F0dHJpYihkcHksIGhhbmRsZV8sIEVHTF9UUkFOU1BBUkVOVF9CTFVFX1ZBTFVFLCAmeHBhcmVudEJsdWVWYWx1ZV8pKQorICAgICAgICB7CisgICAgICAgICAgICBiYWRBdHRyaWJWZWMucHVzaF9iYWNrKCJFR0xfVFJBTlNQQVJFTlRfQkxVRV9WQUxVRSIpOworICAgICAgICB9CisgICAgfQorCisgICAgaWYgKCFiYWRBdHRyaWJWZWMuZW1wdHkoKSkKKyAgICB7CisgICAgICAgIExvZzo6ZXJyb3IoIkZhaWxlZCB0byBnZXQgdGhlIGZvbGxvd2luZyBjb25maWcgYXR0cmlidXRlcyBmb3IgY29uZmlnIDB4JXg6XG4iLAorICAgICAgICAgICAgICAgICAgICBjb25maWcpOworICAgICAgICBmb3IgKHZlY3RvcjxzdHJpbmc+Ojpjb25zdF9pdGVyYXRvciBhdHRyaWJJdCA9IGJhZEF0dHJpYlZlYy5iZWdpbigpOworICAgICAgICAgICAgIGF0dHJpYkl0ICE9IGJhZEF0dHJpYlZlYy5lbmQoKTsKKyAgICAgICAgICAgICBhdHRyaWJJdCsrKQorICAgICAgICB7CisgICAgICAgICAgICBMb2c6OmVycm9yKCIlc1xuIiwgYXR0cmliSXQtPmNfc3RyKCkpOworICAgICAgICB9CisgICAgfQorfQorCit2b2lkCitFZ2xDb25maWc6OnByaW50X2hlYWRlcigpCit7CisgICAgTG9nOjpkZWJ1ZygiXG4iKTsKKyAgICBMb2c6OmRlYnVnKCIgICAgY2ZnIGJ1ZiAgcmdiICBjb2xvcmJ1ZmZlciBkcCBzdCBjb25maWcgbmF0aXZlIHN1cHBvcnQgc3VyZmFjZSBzYW1wbGVcbiIpOworICAgIExvZzo6ZGVidWcoIiAgICAgaWQg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Q09ORklHOgorICAgICAgICAgICAgY2F2ZWF0ID0gc3RyaW5nKCJTbG93Iik7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBFR0xfTk9OX0NPTkZPUk1BTlRfQ09ORklHOgorICAgICAgICAgICAgY2F2ZWF0ID0gc3RyaW5nKCJOY29uIik7CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgY2FzZSBFR0xfTk9ORToKKyAgICAgICAgICAgIC8vIEluaXRpYWxpemVkIHRvIG5vbmUuCisgICAgICAgICAgICBicmVhazsKKyAgICB9CisgICAgcyA8PCAiICAgIiA8PCBjYXZlYXQ7CisgICAgc3RyaW5nIGRvTmF0aXZlKG5hdGl2ZVJlbmRlcmFibGVfID8gInRydWUiIDogImZhbHNlIik7CisgICAgcyA8PCBzdGQ6OnNldHcoNykgPDwgZG9OYXRpdmU7CisgICAgc3RyaW5nIHZpc1R5cGUoInRjIik7CisgICAgc3dpdGNoIChuYXRpdmVUeXBlXykKKyAgICB7CisgICAgICAgIGNhc2UgU3RhdGljR3JheToKKyAgICAgICAgY2FzZSBHcmF5U2NhbGU6CisgICAgICAgIGNhc2UgU3RhdGljQ29sb3I6CisgICAgICAgIGNhc2UgUHNldWRvQ29sb3I6CisgICAgICAgICAgICAvLyBPcGVuR0wgRVMgZG9lc24ndCBzdXBwb3J0IHRoZXNlLCBhbmQgd2UgZG8gbm90IGV4cGVjdCB0byBzZWUKKyAgICAgICAgICAgIC8vIHRoZW0gaW4gdGhlIG1vZGVybiBlcmEsIGJ1dC4uLgorICAgICAgICAgICAgdmlzVHlwZSA9IHN0cmluZygiY2kiKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICBjYXNlIFRydWVDb2xvcjoKKyAgICAgICAgICAgIC8vIEluaXRpYWxpemVkIHRvIFRydWVDb2xvcgorICAgICAgICAgICAgYnJlYWs7CisgICAgICAgIGNhc2UgRGlyZWN0Q29sb3I6CisgICAgICAgICAgICB2aXNUeXBlID0gc3RyaW5nKC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sX2NvbmZpZy5hbHBoYSk7CisgICAgZWdsR2V0Q29uZmlnQXR0cmliKGVnbF9kaXNwbGF5XywgY29uZmlnLCBFR0xfREVQVEhfU0laRSwgJnZpc3VhbF9jb25maWcuZGVwdGgpOworfQorCitFR0xDb25maWcKK0VHTFN0YXRlOjpzZWxlY3RfYmVzdF9jb25maWcoc3RkOjp2ZWN0b3I8RUdMQ29uZmlnPiYgY29uZmlncykKK3sKKyAgICBpbnQgYmVzdF9zY29yZShJTlRfTUlOKTsKKyAgICBFR0xDb25maWcgYmVzdF9jb25maWcoMCk7CisKKyAgICAvKgorICAgICAqIEdvIHRocm91Z2ggYWxsIHRoZSBjb25maWdzIGFuZCBjaG9vc2UgdGhlIG9uZSB3aXRoIHRoZSBiZXN0IHNjb3JlLAorICAgICAqIGkuZS4sIHRoZSBvbmUgYmV0dGVyIG1hdGNoaW5nIHRoZSByZXF1ZXN0ZWQgY29uZmlnLgorICAgICAqLworICAgIGZvciAoc3RkOjp2ZWN0b3I8RUdMQ29uZmlnPjo6Y29uc3RfaXRlcmF0b3IgaXRlciA9IGNvbmZpZ3MuYmVnaW4oKTsKKyAgICAgICAgIGl0ZXIgIT0gY29uZmlncy5lbmQoKTsKKyAgICAgICAgIGl0ZXIrKykKKyAgICB7CisgICAgICAgIGNvbnN0IEVHTENvbmZpZyBjb25maWcoKml0ZXIpOworICAgICAgICBHTFZpc3VhbENvbmZpZyB2YzsKKyAgICAgICAgaW50IHNjb3JlOworCisgICAgICAgIGdldF9nbHZpc3VhbGNvbmZpZyhjb25maWcsIHZjKTsKKworICAgICAgICBzY29yZSA9IHZjLm1hdGNoX3Njb3JlKHZpc3VhbF9jb25maWdfKTsKKworICAgICAgICBpZiAoc2NvcmUgPiBiZXN0X3Njb3JlKSB7CisgICAgICAgICAgICBiZXN0X3Njb3JlID0gc2NvcmU7CisgICAgICAgICAgICBiZXN0X2NvbmZpZyA9IGNvbmZpZzsKKyAgICAgICAgfQorICAgIH0KKworICAgIHJldHVyb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0KKworICAgIGlmIChudW1fY29uZmlncyA9PSAwKSB7CisgICAgICAgIExvZzo6ZXJyb3IoImVnbENob29zZUNvbmZpZygpIGRpZG4ndCByZXR1cm4gYW55IGNvbmZpZ3NcbiIpOworICAgICAgICByZXR1cm4gZmFsc2U7CisgICAgfQorCisgICAgLy8gR2V0IGFsbCB0aGUgbWF0Y2hpbmcgY29uZmlncworICAgIHZlY3RvcjxFR0xDb25maWc+IGNvbmZpZ3MobnVtX2NvbmZpZ3MpOworICAgIGlmICghZWdsQ2hvb3NlQ29uZmlnKGVnbF9kaXNwbGF5XywgY29uZmlnX2F0dHJpYnMsICZjb25maWdzLmZyb250KCksCisgICAgICAgICAgICAgICAgICAgICAgICAgbnVtX2NvbmZpZ3MsICZudW1fY29uZmlncykpCisgICAgeworICAgICAgICBMb2c6OmVycm9yKCJlZ2xDaG9vc2VDb25maWcoKSBmYWlsZWQgd2l0aCBlcnJvcjogJWRcbiIsCisgICAgICAgICAgICAgICAgICAgICBlZ2xHZXRFcnJvcigpKTsKKyAgICAgICAgcmV0dXJuIGZhbHNlOworICAgIH0KKworICAgIC8vIFNlbGVjdCB0aGUgYmVzdCBtYXRjaGluZyBjb25maWcKKyAgICBlZ2xfY29uZmlnXyA9IHNlbGVjdF9iZXN0X2NvbmZpZyhjb25maWdzKTsKKyAgICBnZXRfZ2x2aXN1YWxjb25maWcoZWdsX2NvbmZpZ18sIHZpc3VhbF9jb25maWdfKTsKKworICAgIHZlY3RvcjxFZ2xDb25maWc+IGNvbmZpZ1ZlYzsKKyAgICBmb3IgKHZlY3RvcjxFR0xDb25maWc+Ojpjb25zdF9pdGVyYXRvciBjb25maWdJdCA9IGNvbmZpZ3MuYmVnaW4oKTsKKyAgICAgICAgIGNvbmZpZ0l0ICE9IGNvbmZpZ3MuZW5kKCk7CisgICAgICAgICBjb25maWdJdCsrKQorICAgIHsKKyAgICAgICAgRWdsQ29uZmlnIGNmZyhlZ2xfZGlzcGxheV8sICpjb25maWdJdCk7CisgICAgICAgIGNvbmZpZ1ZlYy5wdXNoX2JhY2soY2ZnKTsKKyAgICAgICAgaWYgKCpjb25maWdJdCA9PSBlZ2xfY29uZmlnXykgeworICAgICAgICAgICAgYmVzdF9jb25maWdfID0gY2ZnOworICAgICAgICB9CisgICAgfSAKKworICAgIC8vIFByaW50IG91dCB0aGUgY29uZmlnIGluZm9ybWF0aW9uLCBhbmQgbGV0IHRoZSB1c2VyIGtub3cgdGhlIGRlY2lzaW9uCisgICAgLy8gYWJvdXQgdGhlICJiZXN0IiBvbmUgd2l0aCByZXNwZWN0IHRvIHRoZSBvcHRpb25zLgorICAgIHVuc2lnbmVkIGludCBsaW5lTnVtYmVyKDApOworICAgIExvZzo6ZGVidWcoIkdvdCAldSBzdWl0YWJsZSBFR0xDb25maWdzOlxuIiwgbnVtX2NvbmZpZ3MpOworICAgIGZvciAodmVjdG9yPEVnbENvbmZpZz46OmNvbnN0X2l0ZXJhdG9yIGNvbmZpZ0l0ID0gY29uZmlnVmVjLmJlZ2luKCk7CisgICAgICAgICBjb25maWdJdCAhPSBjb25maWdWZWMuZW5kKCk7CisgICAgICAgICBjb25maWdJdCsrLCBsaW5lTnVtYmVyKyspCisgICAgeworICAgICAgICBpZiAoIShsaW5lTnVtYmVyICUgMzIpKQorICAgICAgICB7CisgICAgICAgICAgICBjb25maWdJdC0+cHJpbnRfaGVhZGVyKCk7CisgICAgICAgIH0KKyAgICAgICAgY29uZmlnSXQtPnByaW50KCk7CisgICAgfQorICAgIExvZzo6ZGVidWcoIlxuIik7CisgICAgTG9nOjpkZWJ1ZygiQmVzdCBFR0xDb25maWcgSUQ6IDB4JXhcbiIsIGJlc3RfY29uZmlnXy5jb25maWdJRCgpKTsKKworICAgIHJldHVybiB0cnVlOworfQorCitib29sCitFR0xTdGF0ZTo6Z290VmFsaWRTdXJmYWNlKCkKK3sKKyAgICBpZiAoZWdsX3N1cmZhY2VfKQorICAgICAgICByZXR1cm4gdHJ1ZTsKKworICAgIGlmICghZ290VmFsaWREaXNwbGF5KCkpCisgICAgICAgIHJldHVybiBmYWxzZTsKKworICAgIGlmICghZ290VmFsaWRDb25maWcoKSkKKyAgICAgICAgcmV0dXJuIGZhbHNlOworCisgICAgZWdsX3N1cmZhY2VfID0gZWdsQ3JlYXRlV2luZG93U3VyZmFjZShlZ2xfZGlzcGxheV8sIGVnbF9jb25maWdfLCBuYXRpdmVfd2luZG93XywgMCk7CisgICAgaWYgKCFlZ2xfc3VyZmFjZV8pIHsKKyAgICAgICAgTG9nOjplcnJvcigiZWdsQ3JlYXRlV2luZG93U3VyZmFjZSBmYWlsZWQgd2l0aCBlcnJvcjogMHgleFxuIiwgZWdsR2V0RXJyb3IoKSk7CisgICAgICAgIHJldHVybiBmYWxzZTsKKyAgICB9CisKKyAgICByZXR1cm4gdHJ1ZTsKK30KKworYm9vbAorRUdMU3RhdGU6OmdvdFZhbGlkQ29udGV4dCgpCit7CisgICAgaWYgKGVnbF9jb250ZXh0XykKKyAgICAgICAgcmV0dXJuIHRydWU7CisKKyAgICBpZiAoIWdvdFZhbGlkRGlzcGxheSgpKQorICAgICAgICByZXR1cm4gZmFsc2U7CisKKyAgICBpZiAoIWdvdFZhbGlkQ29uZmlnKCkpCisgICAgICAgIHJldHVybiBmYWxzZTsKKworICAgIHN0YXRpYyBjb25zdCBFR0xpbnQgY29udGV4dF9hdHRyaWJzW10gPSB7CisjaWZkZWYgVVNFX0dMRVN2MgorICAgICAgICBFR0xfQ09OVEVYVF9DTElFTlRfVkVSU0lPTiwgMiwKKyNlbmRpZgorICAgICAgICBFR0xfTk9ORQorICAgIH07CisKKyAgICBlZ2xfY29udGV4dF8gPSBlZ2xDcmVhdGVDb250ZXh0KGVnbF9kaXNwbGF5XywgZWdsX2NvbmZpZ18sCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBFR0xfTk9fQ09OVEVYVCwgY29udGV4dF9hdHRyaWJzKTsKKyAgICBpZiAoIWVnbF9jb250ZXh0XykgeworICAgICAgICBMb2c6OmVycm9yKCJlZ2xDcmVhdGVDb250ZXh0KCkgZmFpbGVkIHdpdGggZXJyb3I6IDB4JXhcbiIsCisgICAgICAgICAgICAgICAgICAgZWdsR2V0RXJyb3IoKSk7CisgICAgICAgIHJldHVybiBmYWxzZTsKKyAgICB9CisKKyAgICByZXR1cm4gdHJ1ZTsKK30KKworYm9vbAorRUdMU3RhdGU6OnZhbGlkKCkKK3sKKyAgICBpZiAoIWdvdFZhbGlkRGlzcGxheSgpKQorICAgICAgICByZXR1cm4gZmFsc2U7CisKKyAgICBpZiAoIWdvdFZhbGlkQ29uZmlnKCkpCisgICAgICAgIHJldHVybiBmYWxzZTsKKworICAgIGlmICghZ290VmFsaWRTdXJmYWNlKCkpCisgICAgICAgIHJldHVybiBmYWxzZTsKKworICAgIGlmICghZ290VmFsaWRDb250ZXh0KCkpCisgICAgICAgIHJldHVybiBmYWxzZTsKKworICAgIGlmIChlZ2xfY29udGV4dF8gPT0gZWdsR2V0Q3VycmVudENvbnRleHQoKSkKKyAgICAgICAgcmV0dXJuIHRydWU7CisKKyAgICBpZiAoIWVnbE1ha2VDdXJyZW50KGVnbF9kaXNwbGF5XywgZWdsX3N1cmZhY2VfLCBlZ2xfc3VyZmFjZV8sIGVnbF9jb250ZXh0XykpIHsKKyAgICAgICAgTG9nOjplcnJvcigiZWdsTWFrZUN1cnJlbnQgZmFpbGVkIHdpdGggZXJyb3I6IDB4JXhcbiIsIGVnbEdldEVycm9yKCkpOworICAgICAgICByZXR1cm4gZmFsc2U7CisgICAgfQorCisgICAgaWYgKCFlZ2xTd2FwSW50ZXJ2YWwoZWdsX2Rpc3BsYXlfLCAwKSkgeworICAgICAgICBMb2c6OmluZm8oIioqIEZhaWxlZCB0byBzZXQgc3dhcCBpbnRlcnZhbC4gUmVzdWx0cyBtYXkgYmUgYm91bmRlZCBhYm92ZSBieSByZWZyZXNoIHJhdGUuXG4iKTsKKyAgICB9CisKKyAgICByZXR1cm4gdHJ1ZTsKK30KKworYm9vb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c2VzLz4uCisvLworLy8gQXV0aG9yczoKKy8vICBKZXNzZSBCYXJrZXIKKy8vCisjaWZuZGVmIEVHTF9TVEFURV9IXworI2RlZmluZSBFR0xfU1RBVEVfSF8KKworI2luY2x1ZGUgPHZlY3Rvcj4KKyNpbmNsdWRlIDxFR0wvZWdsLmg+CisjaW5jbHVkZSAiZ2wtdmlzdWFsLWNvbmZpZy5oIgorCitjbGFzcyBFZ2xDb25maWcKK3sKKyAgICBFR0xDb25maWcgaGFuZGxlXzsKKyAgICAvLyBDb2xvciBidWZmZXIgYXR0cmlidXRlcy4KKyAgICBFR0xpbnQgYnVmZmVyU2l6ZV87CisgICAgRUdMaW50IHJlZFNpemVfOworICAgIEVHTGludCBncmVlblNpemVfOworICAgIEVHTGludCBibHVlU2l6ZV87CisgICAgRUdMaW50IGx1bWluYW5jZVNpemVfOworICAgIEVHTGludCBhbHBoYVNpemVfOworICAgIEVHTGludCBhbHBoYU1hc2tTaXplXzsKKyAgICBFR0xpbnQgYnVmZmVyVHlwZV87CisgICAgLy8gQmFzZSBjb25maWcgYXR0cmlidXRlcworICAgIEVHTGludCBjYXZlYXRfOworICAgIEVHTGludCBjb25maWdJRF87CisgICAgLy8gRGVwdGggYnVmZmVyCisgICAgRUdMaW50IGRlcHRoU2l6ZV87CisgICAgLy8gTmF0aXZlIHdpbmRvdyBzeXN0ZW0gYXR0cmlidXRlcy4KKyAgICBFR0xpbnQgbmF0aXZlSURfOworICAgIEVHTGludCBuYXRpdmVUeXBlXzsKKyAgICBib29sIG5hdGl2ZVJlbmRlcmFibGVfOworICAgIC8vIE11bHRpc2FtcGxlIHN1cHBvcnQKKyAgICBFR0xpbnQgc2FtcGxlQnVmZmVyc187CisgICAgRUdMaW50IHNhbXBsZXNfOworICAgIC8vIFN0ZW5jaWwgYnVmZmVyCisgICAgRUdMaW50IHN0ZW5jaWxTaXplXzsKKyAgICBFR0xpbnQgc3VyZmFjZVR5cGVfOworICAgIC8vIFRyYW5zcGFyZW5jeQorICAgIEVHTGludCB4cGFyZW50VHlwZV87IC8vIFNob3VsZCBiZSBSR0Igb3IgTk9ORQorICAgIEVHTGludCB4cGFyZW50UmVkVmFsdWVfOworICAgIEVHTGludCB4cGFyZW50R3JlZW5WYWx1ZV87CisgICAgRUdMaW50IHhwYXJlbnRCbHVlVmFsdWVfOworCitwdWJsaWM6CisgICAgRWdsQ29uZmlnKCkgOgorICAgICAgICBoYW5kbGVfKDApLAorICAgICAgICBidWZmZXJTaXplXygwKSwKKyAgICAgICAgcmVkU2l6ZV8oMCksCisgICAgICAgIGdyZWVuU2l6ZV8oMCksCisgICAgICAgIGJsdWVTaXplXygwKSwKKyAgICAgICAgbHVtaW5hbmNlU2l6ZV8oMCksCisgICAgICAgIGFscGhhU2l6ZV8oMCksCisgICAgICAgIGFscGhhTWFza1NpemVfKDApLAorICAgICAgICBidWZmZXJUeXBlXyhFR0xfUkdCX0JVRkZFUiksCisgICAgICAgIGNhdmVhdF8oMCksCisgICAgICAgIGNvbmZpZ0lEXygwKSwKKyAgICAgICAgZGVwdGhTaXplXygwKSwKKyAgICAgICAgbmF0aXZlSURfKDApLAorICAgICAgICBuYXRpdmVUeXBlXygwKSwKKyAgICAgICAgbmF0aXZlUmVuZGVyYWJsZV8oZmFsc2UpLAorICAgICAgICBzYW1wbGVCdWZmZXJzXygwKSwKKyAgICAgICAgc2FtcGxlc18oMCksCisgICAgICAgIHN0ZW5jaWxTaXplXygwKSwKKyAgICAgICAgc3VyZmFjZVR5cGVfKDApLAorICAgICAgICB4cGFyZW50VHlwZV8oMCksCisgICAgICAgIHhwYXJlbnRSZWRWYWx1ZV8oMCksCisgICAgICAgIHhwYXJlbnRHcmVlblZhbHVlXygwKSwKKyAgICAgICAgeHBhcmVudEJsdWVWYWx1ZV8oMCkge30KKyAgICBFZ2xDb25maWcoRUdMRGlzcGxheSBkcHksIEVHTENvbmZpZyBjb25maWcpOworICAgIH5FZ2xDb25maWcoKSB7fQorICAgIHZvaWQgcHJpbnQoKS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