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sYWNlLCBTdWl0ZSAzMzAsIEJvc3RvbiwKICogTUEgMDIxMTEtMTMwNyBVU0EKICovCgovKgogKiBwb3J0ZWQgZnJvbSBjdGZiLmMgKGxpbnV4IGtlcm5lbCkgZm9yIHRoZSBVLUJvb3QKICoKICovCgovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCiAgR2V0IFBhcmFtZXRlcnMgZm9yIHRoZSB2aWRlbyBtb2RlOgogIFBhcmFtZXRlcnMgY2FuIGJlIHNldCB2aWEgdGhlIHZhcmlhYmxlICJ2aWRlb21vZGUiIGluIHRoZSBlbnZpcm9ubWVudC4KICAyIGRpZmVyZW50IHdheXMgYXJlIHBvc3NpYmxlOgogICJ2aWRlb21vZGU9MzAxIiAgIC0gMzAxIGlzIGEgaGV4YWRlY2ltYWwgbnVtYmVyIGRlc2NyaWJpbmcgdGhlIFZFU0EKICAgICAgICAgICAgICAgICAgICAgIG1vZGUuIEZvbGxvd2luZyBtb2RlcyBhcmUgaW1wbGVtZW50ZWQ6CgogICAgICAgICAgICAgICAgICAgICAgQ29sb3JzICAgIDY0MHg0ODAgODAweDYwMCAxMDI0eDc2OCAxMTUyeDg2NAogICAgICAgICAgICAgICAgICAgICAtLS0tLS0tLSstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQogICAgICAgICAgICAgICAgICAgICAgOCBiaXRzIHwgIDB4MzAxICAgMHgzMDMgICAgMHgzMDUgICAgMHgxNjEKICAgICAgICAgICAgICAgICAgICAgMTUgYml0cyB8ICAweDMxMCAgIDB4MzEzICAgIDB4MzE2ICAgIDB4MTYyCiAgICAgICAgICAgICAgICAgICAgIDE2IGJpdHMgfCAgMHgzMTEgICAweDMxNCAgICAweDMxNyAgICAweDE2MwogICAgICAgICAgICAgICAgICAgICAyNCBiaXRzIHwgIDB4MzEyICAgMHgzMTUgICAgMHgzMTggICAgICA/CiAgICAgICAgICAgICAgICAgICAgIC0tLS0tLS0tKy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCiAgInZpZGVvbW9kZT1ib290YXJncyIKICAgICAgICAgICAgICAgICAgIC0gdGhlIHBhcmFtZXRlcnMgYXJlIHBhcnNlZCBmcm9tIHRoZSBib290YXJncy4KICAgICAgICAgICAgICAgICAgICAgIFRoZSBmb3JtYXQgaXMgIk5BTUU6VkFMVUUsTkFNRTpWQUxVRSIgZXRjLgogICAgICAgICAgICAgICAgICAgICAgRXguOgogICAgICAgICAgICAgICAgICAgICAgImJvb3RhcmdzPXZpZGVvPWN0ZmI6eDo4MDAseTo2MDAsZGVwdGg6MTYscGNsazoyNTAwMCIKICAgICAgICAgICAgICAgICAgICAgIFBhcmFtZXRlcnMgbm90IGluY2x1ZGVkIGluIHRoZSBsaXN0IHdpbGwgYmUgdGFrZW4gZnJvbQogICAgICAgICAgICAgICAgICAgICAgdGhlIGRlZmF1bHQgbW9kZSwgd2hpY2ggaXMgb25lIG9mIHRoZSBmb2xsb3dpbmc6CiAgICAgICAgICAgICAgICAgICAgICBtb2RlOjAgIDY0MHg0ODB4MjQKICAgICAgICAgICAgICAgICAgICAgIG1vZGU6MSAgODAweDYwMHgxNgogICAgICAgICAgICAgICAgICAgICAgbW9kZToyICAxMDI0eDc2OHg4CiAgICAgICAgICAgICAgICAgICAgICBtb2RlOjMgIDk2MHg3MjB4MjQKICAgICAgICAgICAgICAgICAgICAgIG1vZGU6NCAgMTE1Mng4NjR4MTYKICAgICAgICAgICAgICAgICAgICAgIGlmICJtb2RlIiBpcyBub3QgcHJvdmlkZWQgd2l0aGluIHRoZSBwYXJhbWV0ZXIgbGlzdCwKICAgICAgICAgICAgICAgICAgICAgIG1vZGU6MCBpcyBhc3N1bWVkLgogICAgICAgICAgICAgICAgICAgICAgRm9sbG93aW5nIHBhcmFtZXRlcnMgYXJlIHN1cHBvcnRlZDoKICAgICAgICAgICAgICAgICAgICAgIHggICAgICAgeHJlcyA9IHZpc2libGUgcmVzb2x1dGlvbiBob3Jpem9udGFsCiAgICAgICAgICAgICAgICAgICAgICB5ICAgICAgIHlyZXMgPSB2aXNpYmxlIHJlc29sdXRpb24gdmVydGljYWwKICAgICAgICAgICAgICAgICAgICAgIHBjbGsgICAgcGl4ZWxjbG9ja3MgaW4gcGljbyBzZWMKICAgICAgICAgICAgICAgICAgICAgIGxlICAgICAgbGVmdF9tYXJnaW5nIHRpbWUgZnJvbSBzeW5jIHRvIHBpY3R1cmUgaW4gcGl4ZWxjbG9ja3MKICAgICAgICAgICAgICAgICAgICAgIHJpICAgICAgcmlnaHRfbWFyZ2luZyB0aW1lIGZyb20gcGljdHVyZSB0byBzeW5jIGluIHBpeGVsY2xvY2tzCiAgICAgICAgICAgICAgICAgICAgICB1cCAgICAgIHVwcGVyX21hcmdpbiB0aW1lIGZyb20gc3luYyB0byBwaWN0dXJlCiAgICAgICAgICAgICAgICAgICAgICBsbyAgICAgIGxvd2VyX21hcmdpbgogICAgICAgICAgICAgICAgICAgICAgaHMgICAgICBoc3luY19sZW4gbGVuZ3RoIG9mIGhvcml6b250YWwgc3luYwogICAgICAgICAgICAgICAgICAgICAgdnMgICAgICB2c3luY19sZW4gbGVuZ3RoIG9mIHZlcnRpY2FsIHN5bmMKICAgICAgICAgICAgICAgICAgICAgIHN5bmMgICAgc2VlIEZCX1NZTkNfKgogICAgICAgICAgICAgICAgICAgICAgdm1vZGUgICBzZWUgRkJfVk1PREVfKgogICAgICAgICAgICAgICAgICAgICAgZGVwdGggICBDb2xvciBkZXB0aCBpbiBiaXRzIHBlciBwaXhlbAogICAgICAgICAgICAgICAgICAgICAgQWxsIG90aGVyIHBhcmFtZXRlcnMgaW4gdGhlIHZhcmlhYmxlIGJvb3RhcmdzIGFyZSBpZ25vcmVkLgogICAgICAgICAgICAgICAgICAgICAgSXQgaXMgYWxzbyBwb3NzaWJsZSB0byBzZXQgdGhlIHBhcmFtZXRlcnMgZGlyZWN0IGluIHR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gICAgICAgICAgICAweDM0CiAqCiAqIE1lbW9yeSBDbGsgZm9yIG1vc3QgbW9kZXMgPjUwTUh6OgogKiAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCiAqIEZ2Y28gPSAxNC4zMTggKiA1OCAvIDUgPSAxNjZNSHoKICogRm91dCA9IDE2Nk1IeiAvIDIgICAgICA9IDgzTUh6CiAqIFBvc3QgRGl2aXNvciA9IDIKICogWFJDQyA9IChNIC0gMikgPSA1NyAgPSAweDM4CiAqIFhSQ0QgPSAoTiAtIDIpID0gMyAgID0gMHgwMwogKiBYUkNFID0gICAgICAgICAgICAgICAgIDB4OTAKICoKICogTm90ZSBCaXQ3IGVuYWJsZXMgdGhlIGNsb2NrIHNvdXJjZSBmcm9tIHRoZSBWQ08KICoKICovCgovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCiAqIFJlc29sdXRpb24gU3RydWN0CiAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCnN0cnVjdCBjdGZiX3Jlc19tb2RlcyB7CglpbnQgeHJlczsJCS8qIHZpc2libGUgcmVzb2x1dGlvbiAgICAgICAgICAgKi8KCWludCB5cmVzOwoJLyogVGltaW5nOiBBbGwgdmFsdWVzIGluIHBpeGNsb2NrcywgZXhjZXB0IHBpeGNsb2NrIChvZiBjb3Vyc2UpICovCglpbnQgcGl4Y2xvY2s7CQkvKiBwaXhlbCBjbG9jayBpbiBwcyAocGljbyBzZWNvbmRzKSAqLwoJaW50IGxlZnRfbWFyZ2luOwkvKiB0aW1lIGZyb20gc3luYyB0byBwaWN0dXJlICAgICovCglpbnQgcmlnaHRfbWFyZ2luOwkvKiB0aW1lIGZyb20gcGljdHVyZSB0byBzeW5jICAgICovCglpbnQgdXBwZXJfbWFyZ2luOwkvKiB0aW1lIGZyb20gc3luYyB0byBwaWN0dXJlICAgICovCglpbnQgbG93ZXJfbWFyZ2luOwoJaW50IGhzeW5jX2xlbjsJCS8qIGxlbmd0aCBvZiBob3Jpem9udGFsIHN5bmMgICAgKi8KCWludCB2c3luY19sZW47CQkvKiBsZW5ndGggb2YgdmVydGljYWwgc3luYyAgICAgICovCglpbnQgc3luYzsJCS8qIHNlZSBGQl9TWU5DXyogICAgICAgICAgICAgICAgKi8KCWludCB2bW9kZTsJCS8qIHNlZSBGQl9WTU9ERV8qICAgICAgICAgICAgICAgKi8KfTsKCi8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKICogVmVzYSBNb2RlIFN0cnVjdAogKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwpzdHJ1Y3QgY3RmYl92ZXNhX21vZGVzIHsKCWludCB2ZXNhbnI7CQkvKiBWZXNhIG51bWJlciBhcyBpbiBMSUxPIChWRVNBIE5yICsgMHgyMDB9ICovCglpbnQgcmVzaW5kZXg7CQkvKiBpbmRleCB0byByZXNvbHV0aW9uIHN0cnVjdCAqLwoJaW50IGJpdHNfcGVyX3BpeGVsOwkvKiBicHAgKi8KfTsKLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKICogQ2hpcHMgc3RydWN0CiAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwpzdHJ1Y3QgY3RmYl9jaGlwc19wcm9wZXJ0aWVzIHsKCWludCBkZXZpY2VfaWQ7CQkvKiBQQ0kgRGV2aWNlIElEICovCgl1bnNpZ25lZCBsb25nIG1heF9tZW07CS8qIG1lbW9yeSBmb3IgZnJhbWUgYnVmZmVyICovCglpbnQgdmxkX3NldDsJCS8qIHZhbHVlIG9mIFZMRCBpZiBiaXQyIGluIGNs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8qCiAqIFRoZSBHcmFwaGljIERldmljZQogKi8KR3JhcGhpY0RldmljZSBjdGZiOwoKLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKgoqIExvdyBMZXZlbCBSb3V0aW5lcwoqLwoKLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKgoqIFJlYWQgQ1QgSVNBIHJlZ2lzdGVyCiovCiNpZmRlZiBWR0FfREVCVUcKc3RhdGljIHVuc2lnbmVkIGNoYXIKY3RSZWFkICh1bnNpZ25lZCBzaG9ydCBpbmRleCkKewoJR3JhcGhpY0RldmljZSAqcEdEID0gKEdyYXBoaWNEZXZpY2UgKikgJiBjdGZiOwoJaWYgKGluZGV4ID09IENUX0FSX08pCgkJLyogc3luY2ggdGhlIEZsaXAgRmxvcCAqLwoJCWluOCAocEdELT5pc2FCYXNlICsgQ1RfU1RBVFVTX1JFRzFfTyk7CgoJcmV0dXJuIChpbjggKHBHRC0+aXNhQmFzZSArIGluZGV4KSk7Cn0KI2VuZGlmCi8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCioKKiBXcml0ZSBDVCBJU0EgcmVnaXN0ZXIKKi8Kc3RhdGljIHZvaWQKY3RXcml0ZSAodW5zaWduZWQgc2hvcnQgaW5kZXgsIHVuc2lnbmVkIGNoYXIgdmFsKQp7CglHcmFwaGljRGV2aWNlICpwR0QgPSAoR3JhcGhpY0RldmljZSAqKSAmIGN0ZmI7CgoJb3V0OCAoKHBHRC0+aXNhQmFzZSArIGluZGV4KSwgdmFsKTsKfQoKLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKKgoqIF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ywgMHgxNCwgMHgwMCk7CS8qIENvbG9yIFNlbGVjdCBSZWdpc3RlciAgICAqLwoJY3RXcml0ZSAoQ1RfQVJfTywgMHgyMCk7CS8qIGVuYWJsZSB2aWRlbyAgICAgICAgICAgICAqLwp9CgovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCnN0YXRpYyB2b2lkClNldEdyUmVncyAodm9pZCkKewkJCQkvKiBTZXQgR3JhcGhpY3MgTW9kZSAqLwoJaW50IGk7CgoJZm9yIChpID0gMDsgaSA8IDB4MDU7IGkrKykKCQljdFdyaXRlX2kgKENUX0dSX08sIGksIDApOwoJaWYgKHRleHQpIHsKCQljdFdyaXRlX2kgKENUX0dSX08sIDB4MDUsIDB4MTApOwoJCWN0V3JpdGVfaSAoQ1RfR1JfTywgMHgwNiwgMHgwMik7Cgl9IGVsc2UgewoJCWN0V3JpdGVfaSAoQ1RfR1JfTywgMHgwNSwgMHg0MCk7CgkJY3RXcml0ZV9pIChDVF9HUl9PLCAweDA2LCAweDA1KTsKCX0KCWN0V3JpdGVfaSAoQ1RfR1JfTywgMHgwNywgMHgwZik7CgljdFdyaXRlX2kgKENUX0dSX08sIDB4MDgsIDB4ZmYpOwp9CgovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCnN0YXRpYyB2b2lkClNldFNyUmVncyAodm9pZCkKewoJaW50IHRtcCA9IDA7CgoJY3RXcml0ZV9pIChDVF9TUl9PLCAweDAwLCAweDAwKTsJLyogcmVzZXQgKi8KCS8qcnIoIHNyLCAweDAxLCB0bXAgKTsKCSAgIGlmKCBmbnR3aWR0aCA9PSA4ICkgdG1wIHw9IDB4MDE7IGVsc2UgdG1wICY9IH4weDAxOwoJICAgd3IoIHNyLCAweDAxLCB0bXAgKTsgICovCglpZiAoZm50d2lkdGggPT0gOCkKCQ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AgICAgICAgICAgIGZvdXQKIHwgKy0tLS0tLS0tKyAgKy0tLS0tLS0tLS0tLSsgICstLS0tLSsgICAgICstLS0tLS0tLS0tLS0tLS0tLS0tKyAgICstLS0tKwogKy18IFBoYXNlICB8X198Q2hhcmdlIFB1bXAgfF9ffCBWQ08gfF9fX19ffFBvc3QgRGl2aXNvciAoUEQpICB8X19ffENMSyB8LS0tPgogKy18IERldGVjdCB8ICB8JiBGaWx0ZXIgVkNPfCAgfCAgICAgfCAgfCAgfPcxLCAyLCA0LCA4LCAxNiwgMzJ8ICAgfCAgICB8CiB8ICstLS0tLS0tLSsgICstLS0tLS0tLS0tLS0rICArLS0tLS0rICB8ICArLS0tLS0tLS0tLS0tLS0tLS0tLSsgICArLS0tLSsKIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwKIHwgICAgKy0tKyAgICstLS0tLS0tLS0tLS0tLS0rICAgICAgICAgIHwKIHxfX19ffPdNfF9fX3xWQ08gTG9vcCBEaXZpZGV8X19fX19fX19fX3wKICAgICAgfCAgfCAgIHwoVkxEKSj3NCwg9zE2KSB8CiAgICAgICstLSsgICArLS0tLS0tLS0tLS0tLS0tKwoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCiAgdGhhdCBpcyB0aGUgaGFyZHdhcmUgPj0gNjkwMDAgd2UgaGF2ZSB0byBtYW5hZ2UKICstLS0tLS0tLS0rICArLS0rCiB8IFJFRkNMSyAgfF9ffPdOfF9fCiB8IDE0LjNNSHogfCAgfCAgfCAgfAogKy0tLS0tLS0tLSsgICstLSsgIHwKICBfX19fX19fX19fX19fX19fX198CiB8CiB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnZjbyAgICAgICAgICAgICAgICAgICAgICBmb3V0CiB8ICstLS0tLS0tLSsgICstLS0tLS0tLS0tLS0rICArLS0tLS0rICAgICArLS0tLS0tLS0tL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sKfQojZW5kaWYJCQkJLyogQ09ORklHX1ZJREVPX0hXX0NVUlNPUiAqLwoKLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgogKiBXYWl0IGZvciBCaXRCbHQgcmVhZHkKICovCnN0YXRpYyBpbnQKdmlkZW9fd2FpdF9iaXRibHQgKHVuc2lnbmVkIGxvbmcgYWRkcikKewoJdW5zaWduZWQgbG9uZyBicjA0OwoJaW50IGkgPSAwOwoJYnIwNCA9IGluMzJyIChhZGRyKTsKCXdoaWxlIChicjA0ICYgMHg4MDAwMDAwMCkgewoJCXVkZWxheSAoMSk7CgkJYnIwNCA9IGluMzJyIChhZGRyKTsKCQlpZiAoaSsrID4gMTAwMDAwMCkgewoJCQlwcmludGYgKCJFUlJPUiBUaW1lb3V0ICVseFxuIiwgYnIwNCk7CgkJCXJldHVybiAxOwoJCX0KCX0KCXJldHVybiAwOwp9CgovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCiAqIFNldCB1cCBCaXRCbHQgUmVnaXN0cnMKICovCnN0YXRpYyB2b2lkClNldERyYXdpbmdFbmdpbmUgKGludCBiaXRzX3Blcl9waXhlbCkKewoJdW5zaWduZWQgbG9uZyBicjA0LCBicjAwOwoJdW5zaWduZWQgY2hhciB0bXA7CgoJR3JhcGhpY0RldmljZSAqcEdEID0gKEdyYXBoaWNEZXZpY2UgKikgJiBjdGZiOwoKCXRtcCA9IGN0UmVhZF9pIChDVF9YUl9PLCAweDIwKTsJLyogQml0QkxUIENvbmZpZ3VyYXRpb24gKi8KCXRtcCB8PSAweDAyOwkJLyogcmVzZXQgQml0QkxUICovCgljdFdyaXRlX2kgKENUX1hSX08sIDB4MjAsIHRtcCk7CS8qIEJpdEJMVCBDb25maWd1cmF0aW9uICovCgl1ZGVsYXkgKDEwKTsKCXRtcCAmPSAweGZkOwkJLyogcmVsZWFzZSByZXNld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