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1bGVkOyBlc3BlY2lhbGx5IG9wdGlvbmFsIEFDOTcgbWl4ZXIgYml0cwogKiAgICAgICAgICAgICAgICAgICAgICAgc2hvdWxkIGJlIGRldGVjdGVkLiBUaGlzIHJlc3VsdHMgaW4gc3RyYW5nZSBiZWhhdmlvdXIgb2Ygc29tZSBtaXhlcgogKiAgICAgICAgICAgICAgICAgICAgICAgc2V0dGluZ3MsIGxpa2UgbWFzdGVyIHZvbHVtZSBhbmQgbWljLgogKiAgICAwOC4wNi4xOTk4ICAgMC4yICAgRmlyc3QgcmVsZWFzZSB1c2luZyBBbGFuIENveCcgc291bmRjb3JlIGluc3RlYWQgb2YgbWlzY2RldmljZQogKiAgICAwMy4wOC4xOTk4ICAgMC4zICAgRG8gbm90IGluY2x1ZGUgbW9kdmVyc2lvbnMuaAogKiAgICAgICAgICAgICAgICAgICAgICAgTm93IG1peGVyIGJlaGF2aW91ciBjYW4gYmFzaWNhbGx5IGJlIHNlbGVjdGVkIGJldHdlZW4KICogICAgICAgICAgICAgICAgICAgICAgICJPU1MgZG9jdW1lbnRlZCIgYW5kICJPU1MgYWN0dWFsIiBiZWhhdmlvdXIKICogICAgMzEuMDguMTk5OCAgIDAuNCAgIEZpeCByZWFscGxheWVyIHByb2JsZW1zIC0gZGFjLmNvdW50IGlzc3VlcwogKiAgICAyNy4xMC4xOTk4ICAgMC41ICAgRml4IGpveXN0aWNrIHN1cHBvcnQKICogICAgICAgICAgICAgICAgICAgICAgIC0tIE9saXZlciBOZXVrdW0gKGMxODhAb3JnLmNoZW1pZS51bmktbXVlbmNoZW4uZGUpCiAqICAgIDEwLjEyLjE5OTggICAwLjYgICBGaXggZHJhaW5fZGFjIHRyeWluZyB0byB3YWl0IG9uIG5vdCB5ZXQgaW5pdGlhbGl6ZWQgRE1BCiAqICAgIDIzLjEyLjE5OTggICAwLjcgICBGaXggYSBmZXcgZl9maWxlICYgRk1PREVfIGJ1Z3MKICogICAgICAgICAgICAgICAgICAgICAgIERvbid0IHdha2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c2ljLnBhcmsubXN1LnJ1PgogKiAgICAgICAgICAgICAgICAgICAgICAgTm90ZTogam95c3RpY2sgYWRkcmVzcyBoYW5kbGluZyBtaWdodCBzdGlsbCBiZSB3cm9uZyBvbiBhcmNocwogKiAgICAgICAgICAgICAgICAgICAgICAgb3RoZXIgdGhhbiBpMzg2CiAqICAgIDE1LjA2LjE5OTkgICAwLjEyICBGaXggYmFkIGFsbG9jYXRpb24gYnVnLgogKiAgICAgICAgICAgICAgICAgICAgICAgVGhhbmtzIHRvIERldGkgRmxpZWdsIDxmbGllZ2xAaW4udHVtLmRlPgogKiAgICAyOC4wNi4xOTk5ICAgMC4xMyAgQWRkIHBjaV9zZXRfbWFzdGVyCiAqICAgIDAzLjA4LjE5OTkgICAwLjE0ICBhZGFwdCB0byBMaW51cycgbmV3IF9fc2V0dXAvX19pbml0Y2FsbAogKiAgICAgICAgICAgICAgICAgICAgICAgYWRkZWQga2VybmVsIGNvbW1hbmQgbGluZSBvcHRpb24gImVzMTM3MT1qb3lzdGlja2FkZHIiCiAqICAgICAgICAgICAgICAgICAgICAgICByZW1vdmVkIENPTkZJR19TT1VORF9FUzEzNzFfSk9ZUE9SVF9CT09UIGtsdWRnZQogKiAgICAxMC4wOC4xOTk5ICAgMC4xNSAgKFJlKWFkZGVkIFMvUERJRiBtb2R1bGUgb3B0aW9uIGZvciBjYXJkcyByZXZpc2lvbiA+PSA0LgogKiAgICAgICAgICAgICAgICAgICAgICAgSW5pdGlhbCB2ZXJzaW9uIGJ5IERhdmUgUGxhdHQgPGRwbGF0dEBzbnVsYnVnLm10dmlldy5jYS51cz4uCiAqICAgICAgICAgICAgICAgICAgICAgICBtb2R1bGVfaW5pdC9fX3NldHVwIGZpeGVzCiAqICAgIDA4LjE2LjE5OTkgICAwLjE2ICBKb2UgQ290ZWxsZXNlIDxqb2VjQGVuc29uaXEuY29tPgogKiAgICAgICAgICAgICAgICAgICAgICAgQWRkZWQgZGV0ZWN0aW9uIGZvciBFUzEzNzEg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qLwogICAgICAgIG91dGwgKCAodGVtcCAmIFNSQ19DVExNQVNLKSB8IChyZWcgPDwgU1JDX1JBTUFERFJfU0hJRlQpIHwgMHgxMDAwMFVMLAogICAgICAgICAgICAgICBzLT5pbyArIEVTMTM3MV9SRUdfU1JDT05WKTsKCiAgICAgICAgLyogbm93LCB3YWl0IGZvciBidXN5IGFuZCB0aGUgY29ycmVjdCB0aW1lIHRvIHJlYWQgKi8KICAgICAgICB0ZW1wID0gd2FpdF9zcmNfcmVhZHkgKHMpOwoKICAgICAgICBpZiAoICh0ZW1wICYgMHgwMDg3MDAwMFVMICkgIT0gKCBTUkNfT0tTVEFURSA8PCAxNiApKXsKICAgICAgICAgICAgICAgIC8qIHdhaXQgZm9yIHRoZSByaWdodCBzdGF0ZSAqLwogICAgICAgICAgICAgICAgZm9yIChpPTA7IGk8UE9MTF9DT1VOVDsgaSsrKXsKICAgICAgICAgICAgICAgICAgICAgICAgdGVtcCA9IGlubCAocy0+aW8gKyBFUzEzNzFfUkVHX1NSQ09OVik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICggKHRlbXAgJiAweDAwODcwMDAwVUwgKSA9PSAoIFNSQ19PS1NUQVRFIDw8IDE2ICkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICAvKiBoaWRlIHRoZSBzdGF0ZSBiaXRzICovCiAgICAgICAgb3V0bCAoKG9yaWcgJiBTUkNfQ1RMTUFTSykgfCAocmVnIDw8IFNSQ19SQU1BRERSX1NISUZUKSwgcy0+aW8gKyBFUzEzNzFfUkVHX1NSQ09OVik7CiAgICAgICAgcmV0dXJuIHRlbXA7CiAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgCn0KCnN0YXRpYyB2b2lkIHNyY193cml0ZShzdHJ1Y3QgZXMxMzcxX3N0YXRlICpzLCB1bnNpZ25lZCByZWcsIHVuc2lnbmVkIGRh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9zcmNfcmVhZHkocyk7CgogICAgICAgIG91dGwoU1JDX0RJUywgcy0+aW8gKyBFUzEzNzFfUkVHX1NSQ09OVik7CgogICAgICAgIGZvciAoaSA9IDA7IGkgPCAweDgwOyBpKyspCiAgICAgICAgICAgICAgICBzcmNfd3JpdGUocywgaSwgMCk7CgogICAgICAgIHNyY193cml0ZShzLCBTUkNSRUdfREFDMStTUkNSRUdfVFJVTkNfTiwgMTYgPDwgNCk7CiAgICAgICAgc3JjX3dyaXRlKHMsIFNSQ1JFR19EQUMxK1NSQ1JFR19JTlRfUkVHUywgMTYgPDwgMTApOwogICAgICAgIHNyY193cml0ZShzLCBTUkNSRUdfREFDMitTUkNSRUdfVFJVTkNfTiwgMTYgPDwgNCk7CiAgICAgICAgc3JjX3dyaXRlKHMsIFNSQ1JFR19EQUMyK1NSQ1JFR19JTlRfUkVHUywgMTYgPDwgMTApOwogICAgICAgIHNyY193cml0ZShzLCBTUkNSRUdfVk9MX0FEQywgMSA8PCAxMik7CiAgICAgICAgc3JjX3dyaXRlKHMsIFNSQ1JFR19WT0xfQURDKzEsIDEgPDwgMTIpOwogICAgICAgIHNyY193cml0ZShzLCBTUkNSRUdfVk9MX0RBQzEsIDEgPDwgMTIpOwogICAgICAgIHNyY193cml0ZShzLCBTUkNSRUdfVk9MX0RBQzErMSwgMSA8PCAxMik7CiAgICAgICAgc3JjX3dyaXRlKHMsIFNSQ1JFR19WT0xfREFDMiwgMSA8PCAxMik7CiAgICAgICAgc3JjX3dyaXRlKHMsIFNSQ1JFR19WT0xfREFDMisxLCAxIDw8IDEyKTsKICAgICAgICBzZXRfYWRjX3JhdGUocywgMjIwNTApOwogICAgICAgIHNldF9kYWMxX3JhdGUocywgMjIwNTApOwogICAgICAgIHNldF9kYWMyX3JhdGUocywgMjIwNTApOwoKICAgICAgICAvKiBXQVJOSU5HOgogICAgICAgICAqIGVuYWJsaW5nIHRoZSBzYW1wbGUgcmF0ZSBjb252ZXJ0ZXIgd2l0aG91dCBwc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NSQ19EREFDMSB8IFNSQ19EREFDMiB8IFNSQ19EQURDKSkgfCAweDAwMDEwMDAwLAoJICAgICBzLT5pbytFUzEzNzFfUkVHX1NSQ09OVik7CgogICAgICAgIC8qIHdhaXQgZm9yIG5vdCBidXN5IChzdGF0ZSAwKSBmaXJzdCB0byBhdm9pZAogICAgICAgICAgIHRyYW5zaXRpb24gc3RhdGVzICovCiAgICAgICAgZm9yICh0PTA7IHQ8UE9MTF9DT1VOVDsgdCsrKXsKICAgICAgICAgICAgICAgIGlmKChpbmwocy0+aW8rRVMxMzcxX1JFR19TUkNPTlYpICYgMHgwMDg3MDAwMCkgPT0wICkKICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIHVkZWxheSgxKTsKICAgICAgICB9CiAgICAgICAgCiAgICAgICAgLyogd2FpdCBmb3IgYSBTQUZFIHRpbWUgdG8gd3JpdGUgYWRkci9kYXRhIGFuZCB0aGVuIGRvIGl0LCBkYW1taXQgKi8KICAgICAgICBmb3IgKHQ9MDsgdDxQT0xMX0NPVU5UOyB0KyspewogICAgICAgICAgICAgICAgaWYoKGlubChzLT5pbytFUzEzNzFfUkVHX1NSQ09OVikgJiAweDAwODcwMDAwKSA9PTB4MDAwMTAwMDApCiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB1ZGVsYXkoMSk7CiAgICAgICAgfQoKCW91dGwoKChhZGRyIDw8IENPREVDX1BPQUREX1NISUZUKSAmIENPREVDX1BPQUREX01BU0spIHwKCSAgICAgKChkYXRhIDw8IENPREVDX1BPREFUX1NISUZUKSAmIENPREVDX1BPREFUX01BU0spLCBzLT5pbytFUzEzNzFfUkVHX0NPREVDKTsKCgkvKiByZXN0b3JlIFNSQyByZWcgKi8KCXdhaXRfc3JjX3JlYWR5KHMpOwoJb3V0bCh4LCBzLT5pbytFUzEzNzFfUkVHX1NSQ09OVik7CglzcGluX3VubG9ja19pcnFyZXN0b3JlKCZzLT5sb2NrLCBm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