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0KKwlyZWxlYXNlX3NvY2soc2spOworCisJaWYgKHB1dF91c2VyKGxlbmd0aCwgb3B0bGVuKSkKKwkJcmV0dXJuIC1FRkFVTFQ7CisKKwlyZXR1cm4gY29weV90b191c2VyKG9wdHZhbCwgdmFscHRyLCBsZW5ndGgpID8gLUVGQVVMVCA6IDA7Cit9CisKK3N0YXRpYyBpbnQgYXgyNV9saXN0ZW4oc3RydWN0IHNvY2tldCAqc29jaywgaW50IGJhY2tsb2cpCit7CisJc3RydWN0IHNvY2sgKnNrID0gc29jay0+c2s7CisJaW50IHJlcyA9IDA7CisKKwlsb2NrX3NvY2soc2spOworCWlmIChzay0+c2tfdHlwZSA9PSBTT0NLX1NFUVBBQ0tFVCAmJiBzay0+c2tfc3RhdGUgIT0gVENQX0xJU1RFTikgeworCQlzay0+c2tfbWF4X2Fja19iYWNrbG9nID0gYmFja2xvZzsKKwkJc2stPnNrX3N0YXRlICAgICAgICAgICA9IFRDUF9MSVNURU47CisJCWdvdG8gb3V0OworCX0KKwlyZXMgPSAtRU9QTk9UU1VQUDsKKworb3V0OgorCXJlbGVhc2Vfc29jayhzayk7CisKKwlyZXR1cm4gcmVzOworfQorCisvKgorICogWFhYOiB3aGVuIGNyZWF0aW5nIGF4MjVfc29jayB3ZSBzaG91bGQgdXBkYXRlIHRoZSAub2JqX3NpemUgc2V0dGluZworICogYmVsb3cuCisgKi8KK3N0YXRpYyBzdHJ1Y3QgcHJvdG8gYXgyNV9wcm90byA9IHsKKwkubmFtZQkgID0gIkFYMjUiLAorCS5vd25lcgkgID0gVEhJU19NT0RVTEUsCisJLm9ial9zaXplID0gc2l6ZW9mKHN0cnVjdCBzb2NrKSwKK307CisKK3N0YXRpYyBpbnQgYXgyNV9jcmVhdGUoc3RydWN0IHNvY2tldCAqc29jaywgaW50IHByb3RvY29sKQoreworCXN0cnVjdCBzb2NrICpzazsKKwlheDI1X2NiICpheDI1OworCisJc3dpdGNoIChzb2NrLT50eXBlKSB7CisJY2FzZSBTT0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oKKwljYXNlIFNJT0NBWDI1R0VUSU5GT09MRDogeworCQlheDI1X2NiICpheDI1ID0gYXgyNV9zayhzayk7CisJCXN0cnVjdCBheDI1X2luZm9fc3RydWN0IGF4MjVfaW5mbzsKKworCQlheDI1X2luZm8udDEgICAgICAgID0gYXgyNS0+dDEgICAvIEhaOworCQlheDI1X2luZm8udDIgICAgICAgID0gYXgyNS0+dDIgICAvIEhaOworCQlheDI1X2luZm8udDMgICAgICAgID0gYXgyNS0+dDMgICAvIEhaOworCQlheDI1X2luZm8uaWRsZSAgICAgID0gYXgyNS0+aWRsZSAvICg2MCAqIEhaKTsKKwkJYXgyNV9pbmZvLm4yICAgICAgICA9IGF4MjUtPm4yOworCQlheDI1X2luZm8udDF0aW1lciAgID0gYXgyNV9kaXNwbGF5X3RpbWVyKCZheDI1LT50MXRpbWVyKSAgIC8gSFo7CisJCWF4MjVfaW5mby50MnRpbWVyICAgPSBheDI1X2Rpc3BsYXlfdGltZXIoJmF4MjUtPnQydGltZXIpICAgLyBIWjsKKwkJYXgyNV9pbmZvLnQzdGltZXIgICA9IGF4MjVfZGlzcGxheV90aW1lcigmYXgyNS0+dDN0aW1lcikgICAvIEhaOworCQlheDI1X2luZm8uaWRsZXRpbWVyID0gYXgyNV9kaXNwbGF5X3RpbWVyKCZheDI1LT5pZGxldGltZXIpIC8gKDYwICogSFopOworCQlheDI1X2luZm8ubjJjb3VudCAgID0gYXgyNS0+bjJjb3VudDsKKwkJYXgyNV9pbmZvLnN0YXRlICAgICA9IGF4MjUtPnN0YXRlOworCQlheDI1X2luZm8ucmN2X3EgICAgID0gYXRvbWljX3JlYWQoJnNrLT5za19ybWVtX2FsbG9jKTsKKwkJYXgyNV9pbmZvLnNuZF9xICAgICA9IGF0b21pY19yZWFkKCZzay0+c2tfd21lbV9hbGxvYyk7CisJCWF4MjVfaW5mby52cyAgICAgICAgPSBheDI1LT52czsKKwkJYXgyNV9pbmZvLnZyICAgICAgICA9IGF4MjUtPnZyOworCQlheD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V9TQUJNKSB7CisJCQlheDI1LT5tb2R1bHVzICAgPSBBWDI1X01PRFVMVVM7CisJCQlheDI1LT53aW5kb3cgICAgPSBheDI1LT5heDI1X2Rldi0+dmFsdWVzW0FYMjVfVkFMVUVTX1dJTkRPV107CisJCX0gZWxzZSB7CisJCQlheDI1LT5tb2R1bHVzICAgPSBBWDI1X0VNT0RVTFVTOworCQkJYXgyNS0+d2luZG93ICAgID0gYXgyNS0+YXgyNV9kZXYtPnZhbHVlc1tBWDI1X1ZBTFVFU19FV0lORE9XXTsKKwkJfQorCQlheDI1X3NlbmRfY29udHJvbChheDI1LCBBWDI1X1VBLCBwZiwgQVgyNV9SRVNQT05TRSk7CisJCWF4MjVfc3RvcF90MXRpbWVyKGF4MjUpOworCQlheDI1X3N0YXJ0X3QzdGltZXIoYXgyNSk7CisJCWF4MjVfc3RhcnRfaWRsZXRpbWVyKGF4MjUpOworCQlheDI1LT5jb25kaXRpb24gPSAweDAwOworCQlheDI1LT52cyAgICAgICAgPSAwOworCQlheDI1LT52YSAgICAgICAgPSAwOworCQlheDI1LT52ciAgICAgICAgPSAwOworCQlheDI1X3JlcXVldWVfZnJhbWVzKGF4MjUpOworCQlheDI1X2RhbWFfb24oYXgyNSk7CisJCWJyZWFrOworCisJY2FzZSBBWDI1X0RJU0M6CisJCWF4MjVfc2VuZF9jb250cm9sKGF4MjUsIEFYMjVfVUEsIHBmLCBBWDI1X1JFU1BPTlNFKTsKKwkJYXgyNV9kYW1hX29mZihheDI1KTsKKwkJYXgyNV9kaXNjb25uZWN0KGF4MjUsIDApOworCQlicmVhazsKKworCWNhc2UgQVgyNV9ETToKKwkJYXgyNV9kYW1hX29mZihheDI1KTsKKwkJYXgyNV9kaXNjb25uZWN0KGF4MjUsIEVDT05OUkVTRVQpOworCQlicmVhazsKKworCWNhc2UgQVgyNV9SUjoKKwljYXNlIEFYMjVfUk5SOgorCQlpZiAoZnJhbWV0eXBlID09IEFYMjVfUlIpCisJCQlheDI1LT5jb25ka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