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XRidWZmZXIuaCIKI2luY2x1ZGUgInBzZGVjX2h5YnJpZC5oIgoKI2luY2x1ZGUgInNicl9yb20uaCIKI2luY2x1ZGUgInNicl9yYW0uaCIKCiNpbmNsdWRlICJGREtfdG9vbHNfcm9tLmgiCgojaW5jbHVkZSAiZ2VuZXJpY1N0ZHMuaCIKCiNpbmNsdWRlICJGREtfdHJpZ0ZjdHMuaCIKCgovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qICAgICAgICAgICAgICAgICAgICAgICBNTFFVQUwgREVGSU5FUyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKi8KLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwoKICAjZGVmaW5lIEZSQUNUX1pFUk8gRlJBQ1RfQklUUy0xCi8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KClNCUl9FUlJPUiBSZXNldFBzRGVjKCBIQU5ETEVfUFNfREVDIGhfcHNfZCApOwoKdm9pZCBSZXNldFBzRGVDb3IoIEhBTkRMRV9QU19ERUMgaF9wc19kICk7CgoKLyoqKioqIEhFTFBFUlMgKioqKiovCgpzdGF0aWMgdm9pZCBhc3NpZ25UaW1lU2xvdHNQUyAoRklYUF9EQkwgKmJ1ZkFkciwgRklYUF9EQkwgKipidWZQdHIsIGNvbnN0IGludCBudW1TbG90cywgY29uc3QgaW50IG51bUNoYW4pOwoKCgovKioqKioqKioqKioqKioqKioqKi8KCiNkZWZpbmUgRElWMyBGTDJGWENPTlNUX0RCTCgxLmYvMy5mKSAgICAgLyogZGl2aXNpb24gMy4wICovCiNkZWZpbmUgRElWMV81IEZMMkZYQ09OU1RfREJMKDIuZi8zLmYpICAgLyogZGl2aXNpb24gMS41ICovCgovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEKICBcYnJpZWYgIENyZWF0ZXMgb25lIGluc3RhbmNlIG9mIHRoZSBQU19ERUMgc3RydWN0CgogIFxyZXR1cm4gRXJyb3IgaW5mbwoKKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KaW50CkNyZWF0ZVBzRGVjKCBIQU5ETEVfUFNfREVDICpoX1BTX0RFQywgICAvKiE8IHBvaW50ZXIgdG8gdGhlIG1vZHVsZSBzdGF0ZSAqLwogICAgICAgICAgICAgaW50IGFhY1NhbXBsZXNQZXJGcmFtZQogICAgICAgICAgICkKewogIFNCUl9FUlJPUiBlcnJvckluZm8gPSBTQlJERUNfT0s7CiAgSEFORExFX1BTX0RFQyAgaF9wc19kOwogIGludCBpOwoKICBpZiAoKmhfUFNfREVDID09IE5VTEwpIHsKICAgIC8qIEdldCBwcyBkZWMgcmFtICovCiAgICBoX3BzX2QgPSBHZXRSYW1fcHNfZGVjKCk7CiAgICBpZiAoaF9wc19kID09IE5VTEwpIHsKICAgICAgZXJyb3JJbmZvID0gU0JSREVDX01FTV9BTExPQ19GQUlMRUQ7CiAgICAgIGdvdG8gYmFpbDsKICAgIH0KICB9IGVsc2UgewogICAgLyogUmVzZXQgYW4gb3BlbiBpbnN0YW5jZSAqLwogICAgaF9wc19kID0gKmhfUFNfREVDOwogIH0KCiAgIC8qIGluaXRpYWxpc2F0aW9uICovCiAgc3dpdGNoIChhYWNTYW1wbGVzUGVyRnJhbWUpIHsKICBjYXNlIDk2MDoKICAgIGhfcHNfZC0+bm9TdWJTYW1wbGVzID0gMzA7ICAgICAgICAgICAgICAvKiBjb2wgKi8KICAgIGJyZWFrOwogIGNhc2UgMTAyNDoKICAgIGhfcHNfZC0+bm9TdWJTYW1wbGVzID0gMzI7ICAgICAgICAgICAgICAvKiBjb2wgKi8KICAgIG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vciBpbmZvCgoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwppbnQKRGVsZXRlUHNEZWMoIEhBTkRMRV9QU19ERUMgKmhfUFNfREVDKSAgLyohPCBwb2ludGVyIHRvIHRoZSBtb2R1bGUgc3RhdGUgKi8KewogIGlmICgqaF9QU19ERUMgPT0gTlVMTCkgewogICAgcmV0dXJuIC0xOwogIH0KCgogIEZyZWVSYW1fcHNfZGVjKGhfUFNfREVDKTsKCgogIHJldHVybiAwOwp9IC8qRU5EIERlbGV0ZVBzRGVjICovCgovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEKICBcYnJpZWYgcmVzZXRzIHNvbWUgdmFsdWVzIG9mIHRoZSBQUyBoYW5kbGUgdG8gZGVmYXVsdCBzdGF0ZXMKCiAgXHJldHVybgoKKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KU0JSX0VSUk9SIFJlc2V0UHNEZWMoIEhBTkRMRV9QU19ERUMgaF9wc19kICkgIC8qITwgcG9pbnRlciB0byB0aGUgbW9kdWxlIHN0YXRlICovCnsKICBTQlJfRVJST1IgZXJyb3JJbmZvID0gU0JSREVDX09LOwogIElOVCBpOwoKICBjb25zdCBVQ0hBUiBub1FtZkJhbmRzSW5IeWJyaWQyMCA9IDM7CiAgLyogY29uc3QgVUNIQVIgbm9RbWZCYW5kc0luSHlicmlkMzQgPSA1OyAqLwoKICBjb25zdCBVQ0hBUiBhSHlicmlkUmVzb2x1dGlvbjIwW10gPSB7IEhZQlJJRF84X0NQTFgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBIWUJSSURfMl9SRUFMLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg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nBBYVJlYWxEZWxheUJ1ZmZlclFtZlsxXSwKICAgICAgICAgICAgICAgICAgICAgIGhfcHNfZC0+c3BlY2lmaWNUby5tcGVnLm5vU2FtcGxlRGVsYXktMSwKICAgICAgICAgICAgICAgICAgICAgIChOT19ERUxBWV9CVUZGRVJfQkFORFMtRklSU1RfREVMQVlfU0IpKTsKCiAgaF9wc19kLT5zcGVjaWZpY1RvLm1wZWcucEFhSW1hZ0RlbGF5QnVmZmVyUW1mWzBdID0gaF9wc19kLT5zcGVjaWZpY1RvLm1wZWcuYWFRbWZEZWxheUJ1ZkltYWc7CgogIGFzc2lnblRpbWVTbG90c1BTICggaF9wc19kLT5zcGVjaWZpY1RvLm1wZWcucEFhSW1hZ0RlbGF5QnVmZmVyUW1mWzBdICsgKE5PX1FNRl9DSEFOTkVMUy1GSVJTVF9ERUxBWV9TQiksCiAgICAgICAgICAgICAgICAgICAgICZoX3BzX2QtPnNwZWNpZmljVG8ubXBlZy5wQWFJbWFnRGVsYXlCdWZmZXJRbWZbMV0sCiAgICAgICAgICAgICAgICAgICAgICBoX3BzX2QtPnNwZWNpZmljVG8ubXBlZy5ub1NhbXBsZURlbGF5LTEsCiAgICAgICAgICAgICAgICAgICAgICAoTk9fREVMQVlfQlVGRkVSX0JBTkRTLUZJUlNUX0RFTEFZX1NCKSk7CgogIC8qIEh5YnJpZCBGaWx0ZXIgQmFuayAxIGNyZWF0aW9uLiAqLwogIGVycm9ySW5mbyA9IEluaXRIeWJyaWRGaWx0ZXJCYW5rICggJmhfcHNfZC0+c3BlY2lmaWNUby5tcGVnLmh5YnJpZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoX3BzX2QtPm5vU3ViU2FtcGxlcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBub1FtZkJhbmRzSW5IeWJyaWQyMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhSHlicmlkUmVzb2x1dGlvbjIwICk7Cgog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ioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KCi8qIHNsb3QgYmFzZWQgZnVuY2lvbiBwcm90b3R5cGVzICovCgpzdGF0aWMgdm9pZCBkZUNvcnJlbGF0ZVNsb3RCYXNlZCggSEFORExFX1BTX0RFQyBoX3BzX2QsCgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRklYUF9EQkwgICAgKm1IeWJyaWRSZWFsTGVmdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZJWFBfREJMICAgICptSHlicmlkSW1hZ0xlZnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTQ0hBUiAgICAgICAgc2ZfbUh5YnJpZExlZnQsCgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRklYUF9EQkwgICAgKnJJbnRCdWZmZXJMZWZ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRklYUF9EQkwgICAgKmlJbnRCdWZmZXJMZWZ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU0NIQVIgICAgICAgIHNmX0ludEJ1ZmZlciwKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBGSVhQX0RCTCAgICAqbUh5YnJpZFJlYWxSaWdodCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZJWFBfREJMICAgICptSHlicmlkSW1hZ1JpZ2h0LAoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZJWFBfREJMICAgICpySW50QnVmZmVyUmlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBGSVhQX0RCTCAgICAqaUludEJ1ZmZlclJpZ2h0ICk7CgpzdGF0aWMgdm9pZCBhcHBseVNsb3RCYXNlZFJvdGF0aW9uKCBIQU5ETEVfUFNfREVDIGhfcHNfZCwKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZJWFBfREJMICAqbUh5YnJpZFJlYWxMZWZ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBGSVhQX0RCTCAgKm1IeWJyaWRJbWFnTGVmdCwKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZJWFBfREJMICAqUW1mTGVmdFJlYWwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZJWFBfREJMICAqUW1mTGVmdEltYWcsCgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBGSVhQX0RCTCAgKm1IeWJyaWRSZWFsUmlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZJWFBfREJMICAqbUh5YnJpZEltYWdSaWdodCwKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZJWFBfREJMICAqUW1mUmlnaHRSZWFsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBGSVhQX0RCTCAgKlFtZlJpZ2h0SW1hZwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKTsKCgovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiEKICBcYnJpZWYgIEdldCBzY2FsZSBmYWN0b3IgZm9yIGFsbCBwcyBkZWxheSBidWZmZXIuCgogIFxyZXR1cm4KCioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCnN0YXRpYwppbnQgZ2V0U2NhbGVGYWN0b3JQc1N0YXRlc0J1ZmZlcihIQU5ETEVfUFNfREVDICAgaF9wc19kKQp7CiAgSU5UIGk7CiAgaW50IHNjYWxlID0gREZSQUNUX0JJVFMtMTsKCiAgZm9yIChpPTA7IGk8Tk9fUU1GX0JBTkRTX0hZQlJJRDIwOyBpKyspIHsKICAgIHNjYWxlID0gZk1pbihzY2FsZSwgZ2V0U2NhbGVmYWN0b3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ioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyohCiAgXGJyaWVmICBTY2FsZSBpbnB1dCBjaGFubmVsIHRvIHRoZSBzYW1lIHNjYWxlZmFjdG9yIGFuZCByZXNjYWxlIGh5YnJpZAogICAgICAgICAgZmlsdGVyYmFuayB2YWx1ZXMKCiAgXHJldHVybgoKKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KCnZvaWQgc2NhbEZpbHRlckJhbmtWYWx1ZXMoIEhBTkRMRV9QU19ERUMgICBoX3BzX2QsCiAgICAgICAgICAgICAgICAgICAgICAgICAgIEZJWFBfREJMICAgICAgKipmaXhwUW1mUmVhbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgRklYUF9EQkwgICAgICAqKmZpeHBRbWZJbWFnLAogICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgICAgICAgICAgICAgbHNiLAogICAgICAgICAgICAgICAgICAgICAgICAgICBpbnQgICAgICAgICAgICAgc2NhbGVGYWN0b3JMb3dCYW5kU3BsaXRMb3csCiAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCAgICAgICAgICAgICBzY2FsZUZhY3Rvckxvd0JhbmRTcGxpdEhpZ2gsCiAgICAgICAgICAgICAgICAgICAgICAgICAgIFNDSEFSICAgICAgICAgICpzY2FsZUZhY3Rvckxvd0JhbmRfbGIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgIFNDSEFSICAgICAgICAgICpzY2FsZUZhY3Rvckxvd0JhbmRfaGIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCAgICAgICAgICAgICBzY2FsZUZhY3RvckhpZ2hCYW5kcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgSU5UICAgICAgICAgICAgKnNjYWxlRmFjdG9ySGlnaEJhbmQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgIElOVCAgICAgICAgICAgICBub0NvbHMKICAg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ICAgICAgICAgICAgICovCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ICAgICAgICAgICAgIGxzYiwgICAgICAgICAgICAgICAgICAgICAgICAgLyogc2JyIHN0YXJ0IHN1YmJhbmQgICAgICAgICAgICAgICAgICAgICovCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSU5UICAgICAgICAgICAgIG5vQ29scykKewogIGludCBpOwogIC8qIHNjYWxlIGJhY2sgNiB0aW1lc2xvdHMgbG9vayBhaGVhZCBmb3IgaHlicmlkIGZpbHRlcmJhbmsgdG8gb3JpZ2luYWwgdmFsdWUgKi8KICBmb3IgKCBpPW5vQ29sczsgaTxub0NvbHMgKyAoNik7IGkrKyApIHsKICAgIHNjYWxlVmFsdWVzKCBRbWZCdWZmZXJSZWFsW2ldLCBsc2IsIGhfcHNfZC0+cmVzY2FsICk7CiAgICBzY2FsZVZhbHVlcyggUW1mQnVmZmVySW1hZ1tpXSwgbHNiLCBoX3BzX2QtPnJlc2NhbCApOwogIH0KfQoKLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyohCiAgXGJyaWVmICBHZW5lcmF0ZSBkZWNvcnJlbGF0ZWQgc2lkZSBjaGFubmVsIHVzaW5nIGFsbHBhc3MvZGVsYXkKCiAgXHJldHVybgoKKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8Kc3RhdGljIHZvaWQKZGVDb3JyZWxhdGVTbG90QmFzZWQoIEhBTkRMRV9QU19ERUMgaF9wc19kLCAgICAgICAgICAgIC8qITwgcG9pbnRlciB0byB0aGUgbW9kdWxlIHN0YXRlICovCgogICAgICAgICAgICAgICAgICAgICAgRklYUF9EQkwgICAgKm1IeWJyaWRSZWFsTGVmdCwgICAgLyohPCBsZWZ0IChtb25vKSBoeWJyaWQgdmFsdWVzIHJlYWwgKi8KICAgICAgICAgICAgICAgICAgICAgIEZJWFBfREJMICAgICptSHlicmlkSW1hZ0xlZnQsICAgIC8qITwgbGVmdCAobW9ubykgaHlicmlkIHZhbHVlcyBpbWFnICovCiAgICAgICAgICAgICAgICAgICAgICBTQ0hBUiAgICAgICAgc2ZfbUh5YnJpZExlZnQsICAgICAvKiE8IHNjYWxlZmFjdG9yIGZvciBsZWZ0IChtb25vKSBoeWJyaWQgYmFuZHMgKi8KCiAgICAgICAgICAgICAgICAgICAgICBGSVhQX0RCTCAgICAqckludEJ1ZmZlckxlZnQsICAgICAvKiE8IHJlYWwgcW1mIGJhbmRzIGxlZnQgKG1vbm8pICgzOHg2NCkgKi8KICAgICAgICAgICAgICAgICAgICAgIEZJWFBfREJMICAgICppSW50QnVmZmVyTGVmdCwgICAgIC8qITwgcmVhbCBxbWYgYmFuZHMgbGVmdCAobW9ubykgKDM4eDY0KSAqLwogICAgICAgICAgICAgICAgICAgICAgU0NIQVIgICAgICAgIHNmX0ludEJ1ZmZlciwgICAgICAgLyohPCBzY2FsZWZhY3RvciBmb3IgYWxsIGxlZnQgYW5kIHJpZ2h0IHFtZiBiYW5kcyAgICovCgogICAgICAgICAgICAgICAgICAgICAgRklYUF9EQkwgICAgKm1IeWJyaWRSZWFsUmlnaHQsICAgLyohPCByaWdodCAoZGVjb3JyZWxhdGVkKSBoeWJyaWQgdmFsdWVzIHJlYWwgKi8KICAgICAgICAgICAgICAgICAgICAgIEZJWFBfREJMICAgICptSHlicmlkSW1hZ1JpZ2h0LCAgIC8qITwgcmlnaHQgKGRlY29ycmVsYXRlZCkgaHlicmlkIHZhbHVlcyBpbWFnICovCgogICAgICAgICAgICAgICAgICAgICAgRklYUF9EQkwgICAgKnJJbnRCdWZmZXJSaWdodCwgICAgLyohPCByZWFsIHFtZiBiYW5kcyByaWdodCAoZGVjb3JyZWxhdGVkKSAoMzh4NjQpICovCiAgICAgICAgICAgICAgICAgICAgICBGSVhQX0RCTCAgICAqaUludEJ1Z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AgICAgICAgICAgICAgICAgIDMgICAgICAgICAgIEhZQlJJRCBCQU5EUwogICAgICAgICA0ICAgICAgICAgICAgICAgICAgIDEgICAgICAgICAgICAgICAgICAgICAgOQogICAgICAgICA1ICAgICAgICAgICAgICAgICAgIDEgICAgICAgICAgICAgICAgICAgICAgOAogICAgICAgICA2ICAgICAgICAgICAgICAgICAgIDIgICAgICAgICAgICAgICAgICAgICAxMAogICAgICAgICA3ICAgICAgICAgICAgICAgICAgIDIgICAgICAgICAgICAgICAgICAgICAxMQogIC0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KICAgICAgICAgOCAgICAgICAgICAgICAgICAgICAzCiAgICAgICAgIDkgICAgICAgICAgICAgICAgICAgNAogICAgICAgIDEwICAgICAgICAgICAgICAgICAgIDUKICAgICAgICAxMSAgICAgICAgICAgICAgICAgICA2CiAgICAgICAgMTIgICAgICAgICAgICAgICAgICAgNwogICAgICAgIDEzICAgICAgICAgICAgICAgICAgIDgKICAgICAgICAxNCAgICAgICAgICAgICAgICAgICA5LDEwICAgICAgKDIgKSAgICAgICAgICAgICAgICAgICAgICBRTUYgQkFORFMKICAgICAgICAxNSAgICAgICAgICAgICAgICAgICAxMSAtIDEzICAgKDMgKQogICAgICAgIDE2ICAgICAgICAgICAgICAgICAgIDE0IC0gMTcgICAoNCApCiAgICAgICAgMTcgICAgICAgICAgICAgICAgICAgMTggLSAyMiAgICg1ICkKICAgICAgICAxOCAgICAgICAgICAgICAgICAgICAyMyAtIDM0ICAgKDEyKQogICAgICAgIDE5ICAgICAgICAgICAgICAgICAgIDM1IC0gNjMgICAoMjkpCiAgLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQo8L3ByZT4KKi8KCiAgI2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RklYUF9EQkwgdHJpZ0RhdGFbNF07CgogICAgICBpbmxpbmVfZml4cF9jb3Nfc2luKEJldGEgKyBBbHBoYSwgQmV0YSAtIEFscGhhLCAyLCB0cmlnRGF0YSk7CiAgICAgIGgxMXIgPSBmTXVsdCggU2NhbGVMLCB0cmlnRGF0YVswXSk7CiAgICAgIGgxMnIgPSBmTXVsdCggU2NhbGVSLCB0cmlnRGF0YVsyXSk7CiAgICAgIGgyMXIgPSBmTXVsdCggU2NhbGVMLCB0cmlnRGF0YVsxXSk7CiAgICAgIGgyMnIgPSBmTXVsdCggU2NhbGVSLCB0cmlnRGF0YVszXSk7CiAgICB9CiAgICAvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCiAgICAvKiBJbnRlcnBvbGF0aW9uIG9mIHRoZSBtYXRyaWNlcyBIMTEuLi4gSDIyOiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICovCiAgICAvKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICovCiAgICAvKiBIMTEoayxuKSA9IEgxMShrLG5bZV0pICsgKG4tbltlXSkgKiAoSDExKGssbltlKzFdIC0gSDExKGssbltlXSkpIC8gKG5bZSsxXSAtIG5bZV0pICAgICovCiAgICAvKiAuLi4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICovCiAgICAvKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCgogICAgLyogaW52TCA9IDEvKGxlbmd0aCBvZiBlbnZlbG9wZSkgKi8KICAgIGludkwgPSBGWF9EQkwyRlh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WwgYmFuZHMgbGVmdCBxbWYgY2hhbm5lbCAqLwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBGSVhQX0RCTCAgKlFtZkxlZnRJbWFnLCAgICAgIC8qITwgaW1hZyBiYW5kcyBsZWZ0IHFtZiBjaGFubmVsICovCgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBGSVhQX0RCTCAgKm1IeWJyaWRSZWFsUmlnaHQsIC8qITwgaHlicmlkIHZhbHVlcyByZWFsIHJpZ2h0ICAqLwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBGSVhQX0RCTCAgKm1IeWJyaWRJbWFnUmlnaHQsIC8qITwgaHlicmlkIHZhbHVlcyBpbWFnIHJpZ2h0ICAqLwoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRklYUF9EQkwgICpRbWZSaWdodFJlYWwsICAgICAvKiE8IHJlYWwgYmFuZHMgcmlnaHQgcW1mIGNoYW5uZWwgKi8KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRklYUF9EQkwgICpRbWZSaWdodEltYWcgICAgICAvKiE8IGltYWcgYmFuZHMgcmlnaHQgcW1mIGNoYW5uZWwgKi8KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICApCnsKICBJTlQgICAgIGdyb3VwOwogIElOVCAgICAgc3ViYmFuZDsKCiAgRklYUF9EQkwgKlJFU1RSSUNUIEh5YnJMZWZ0UmVhbDsKICBGSVhQX0RCTCAqUkVTVFJJQ1QgSHlickxlZnRJbWFnOwogIEZJWFBfREJMICpSRVNUUklDVCBIeWJyUmlnaHRSZWFsOwogIEZJWFBfREJMICpSRVNUUklDVCBIeWJyUmlnaHRJbWFnOwoKICBGSVhQX0RCTCB0bXBMZWZ0LCB0bXBSaWdodDsKCgogIC8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqK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yBvbiBJQ0MgbW9kZSBlaXRoZXIgbWl4aW5nIHByb2NlZHVyZSBSX2EKICBvciBSX2IgaXMgdXNlZCBmb3IgdGhhdC4gRm9yIGJvdGggcHJvY2VkdXJlcywgdGhlIHBhcmFtZXRlcnMgZm9yIHBhcmFtZXRlciBwb3NpdGlvbiBuW2UrMV0KICBpcyB1c2VkLgogICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KCgogIC8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCiAgLyohCiAgPGgyPlBoYXNlIHBhcmFtZXRlcnMgPC9oMj4KICBXaXRoIGRpc2FibGVkIHBoYXNlIHBhcmFtZXRlcnMgKHdoaWNoIGlzIHRoZSBjYXNlIGluIGJhc2VsaW5lIHZlcnNpb24pLCB0aGUgSC1tYXRyaWNlcyBhcmUKICBqdXN0IGNhbGN1bGF0ZWQgYnk6CgogIDxwcmU+CiAgSDExKGssbltlKzFdID0gaDExKGIoaykpCiAgKC4uLikKICBiKGspOiBwYXJhbWV0ZXIgaW5kZXggYWNjb3JkaW5nIHRvIG1hcHBpbmcgdGFibGUKICA8L3ByZT4KCiAgPGgyPlByb2Nlc3Npbmcgb2YgdGhlIHNhbXBsZXMgaW4gdGhlIHN1YiBzdWJiYW5kcyA8L2gyPgogIHRoaXMgbG9vcCBpbmNsdWRlcyB0aGUgaW50ZXJwb2xhdGlvbiBvZiB0aGUgY29lZmZpY2llbnRzIEh4eAogICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KCgogIC8qIGxvb3AgdGhydSBhbGwgZ3JvdXBzIC4uLiAqLwogIEh5YnJMZWZ0UmVhbCAgPSBtSHlicmlkUmVhbExlZnQ7CiAgSHlickxlZnRJbWFnICA9IG1IeWJyaWRJbWFnTGVmdDsKICBIeWJyUmlnaHRSZWFsID0gbUh5YnJpZFJlYWxSaWdodDsKICBIeWJyUmlnaHRJbWFnID0gbUh5YnJpZEltYWdSaWdodDsKCiAgLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KICAvKiBjb25zdHJ1Y3Qgc3RlcmVvIHN1YiBzdWJiYW5kIHNpZ25hbHMgYWNjb3JkaW5nIHRvOiAqLwogIC8qICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICovCiAgLyogbF9rKG4pID0gSDExKGssbikgc19rKG4pICsgSDIxKGssbikgZF9rKG4pICAgICAgICAgKi8KICAvKiByX2sobikgPSBIMTIoayxuKSBzX2sobikgKyBIMjIoayxuKSBkX2sobikgICAgICAgICAqLwogIC8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCiAgZm9yICggZ3JvdXAgPSAwOyBncm91cCA8IFNVQlFNRl9HUk9VUFM7IGdyb3VwKysgKSB7CgogICAgaF9wc19kLT5zcGVjaWZpY1RvLm1wZWcuY29lZi5IMTFyW2dyb3VwXSArPSBoX3BzX2QtPnNwZWNpZmljVG8ubXBlZy5jb2VmLkRlbHRhSDExcltncm91cF07CiAgICBoX3BzX2QtPnNwZWNpZmljVG8ubXBlZy5jb2VmLkgxMnJbZ3JvdXBdICs9IGhfcHNfZC0+c3BlY2lmaWNUby5tcGVnLmNvZWYuRGVsdGFIMTJyW2dyb3VwXTsKICAgIGhfcHNfZC0+c3BlY2lmaWNUby5tcGVnLmNvZWYuSDIxcltncm91cF0gKz0gaF9wc19kLT5zcGVjaWZpY1RvLm1wZWcuY29lZi5EZWx0YUgyMXJbZ3JvdXBdOwogICAgaF9wc19kLT5zcGVjaWZpY1RvL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SW1hZyBbc3ViYmFuZF0gPSB0bXBMZWZ0OwogICAgICBIeWJyUmlnaHRJbWFnW3N1YmJhbmRdID0gdG1wUmlnaHQ7CgogICAgfSAvKiBzdWJiYW5kICovCiAgfQp9CgoKLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyohCiAgXGJyaWVmICBBcHBsaWVzIElJRCwgSUNDLCBJUEQgYW5kIE9QRCBwYXJhbWV0ZXJzIHRvIHRoZSBjdXJyZW50IGZyYW1lLgoKICBccmV0dXJuIG5vbmUKCioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCnZvaWQKQXBwbHlQc1Nsb3QoIEhBTkRMRV9QU19ERUMgaF9wc19kLCAgICAgICAgIC8qITwgaGFuZGxlIFBTX0RFQyovCiAgICAgICAgICAgICBGSVhQX0RCTCAgKipySW50QnVmZmVyTGVmdCwgICAvKiE8IHJlYWwgYmFuZHMgbGVmdCBxbWYgY2hhbm5lbCAoMzh4NjQpICAqLwogICAgICAgICAgICAgRklYUF9EQkwgICoqaUludEJ1ZmZlckxlZnQsICAgLyohPCBpbWFnIGJhbmRzIGxlZnQgcW1mIGNoYW5uZWwgKDM4eDY0KSAgKi8KICAgICAgICAgICAgIEZJWFBfREJMICAqckludEJ1ZmZlclJpZ2h0LCAgIC8qITwgcmVhbCBiYW5kcyByaWdodCBxbWYgY2hhbm5lbCAoMzh4NjQpICovCiAgICAgICAgICAgICBGSVhQX0RCTCAgKmlJbnRCdWZmZXJSaWdodCAgICAvKiE8IGltYWcgYmFuZHMgcmlnaHQgcW1mIGNoYW5uZWwgKDM4eDY0KSAqLwogICAgICAgICAgICkKewoKICAvKiEKICBUaGUgNjQtYmFuZCBRTUYgcmVwcmVzZW50YXRpb24gb2YgdGhlIG1vbmF1cmFsIHNpZ25hbCBnZW5lcmF0ZWQgYnkgdGhlIFNCUiB0b29sCiAgaXMgdXNlZCBhcyBpbnB1dCBvZiB0aGUgUFMgdG9vbC4gQWZ0ZXIgdGhlIFBTIHByb2Nlc3NpbmcsIHRoZSBvdXRwdXRzIG9mIHRoZSBsZWZ0CiAgYW5kIHJpZ2h0IGh5YnJpZCBzeW50aGVzaXMgZmlsdGVyYmFua3MgYXJlIHVzZWQgdG8gZ2VuZXJhdGUgdGhlIHN0ZXJlbyBvdXRwdXQKICBzaWduYWwuCgogIDxwcmU+CgogICAgICAgICAgICAgLS0tLS0tLS0tLS0tLSAgICAgICAgICAgIC0tLS0tLS0tLS0gICAgICAgICAgICAtLS0tLS0tLS0tLS0tCiAgICAgICAgICAgIHwgSHlicmlkICAgICAgfCBNX25bayxtXSB8ICAgICAgICAgIHwgTF9uW2ssbV0gfCBIeWJyaWQgICAgICB8IGxbbl0KICAgbVtuXSAtLS0+fCBhbmFseXNpcyAgICB8LS0tLS0tLS0tPnwgICAgICAgICAgfC0tLS0tLS0tLT58IHN5bnRoZXNpcyAgIHwtLS0tLT4KICAgICAgICAgICAgfCBmaWx0ZXIgYmFuayB8ICAgICAgICAgIHwgICAgICAgICAgfCAgICAgICAgICB8IGZpbHRlciBiYW5rIHwKICAgICAgICAgICAgIC0tLS0tLS0tLS0tLS0gICAgICAgICAgIHwgU3RlcmVvICAgfCAgICAgICAgICAgLS0tLS0tLS0tLS0tLQogICAgICAgICAgICAgICAgICAgfCAgICAgICAgICAgICAgICAgfCByZWNvbi0gICB8CiAgICAgICAgICAgICAgICAgICB8ICAgICAgICAgICAgICAgICB8IHN0dWN0aW9uIHwKICAgICAgICAgICAgICAgICAgXHwvICAgICAgICAgICAgICAgIHwgICAgICAgICAgfAogICAgICAgICAgICAgLS0tLS0tLS0tLS0tLSAgICAgICAgICAgfCAgICAgICAgICB8CiAgICAgICAgICAgIHwgRGUtICAgICAgICAgfCBEX25bayxtXSB8ICAgICAgICAgIHwKICAgICAgICAgICAgfCBjb3JyZWxhdGlvbiB8LS0tLS0tLS0tPnwgICAgICAgICAgfAogICAgICAgICAgICAgLS0tLS0tLS0tLS0tLSAgICAgICAgICAgfCAgICAgICAgICB8ICAgICAgICAgICAtLS0tLS0tLS0tLS0tCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8ICAgICAgICAgIHwgUl9uW2ssbV0gfCBIeWJyaWQgICAgICB8IHJbbl0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHwgICAgICAgICAgfC0tLS0tLS0tLT58IHN5bnRoZXNpcyAgIHwtLS0tLT4KICAgSUlELCBJQ0MgLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tPnwgICAgICAgICAgfCAgICAgICAgICB8IGZpbHRlciBiYW5rIHwKICAoSVBELCBPUEQpICAgICAgICAgICAgICAgICAgICAgICAgICAtLS0tLS0tLS0tICAgICAgICAgICAgLS0tLS0tLS0tLS0tLQoKICBtW25dOiAgICAgIFFNRiByZXByZXNhbnRhdGlvbiBvZiB0aGUgbW9ubyBpbnB1dAogIE1fbltrLG1dOiAgKHN1Yi0pc3ViLWJhbmQgZG9tYWluIHNpZ25hbHMgb2YgdGhlIG1vbm8gaW5wdXQKICBEX25bayxtXTogIGRlY29ycmVsYXRlZCAoc3ViLSlzdWItYmFuZCBkb21haW4gc2lnbmFscwogIExfbltrLG1dOiAgKHN1Yi0pc3ViLWJhbmQgZG9tYWluIHNpZ25hbHMgb2YgdGhlIGxlZnQgb3V0cHV0CiAgUl9uW2ssbV06ICAoc3ViLSlzdWItYmFuZCBkb21haW4gc2lnbmFscyBvZiB0aGUgcmlnaHQgb3V0cHV0CiAgbFtuXSxyW25dOiBsZWZ0L3JpZ2h0IG91dHB1dCBzaWduYWxzCgogIDwvcHJlPgogICovCgogIC8qIGdldCB0ZW1wb3JhcnkgaHlicmlkIHFtZiB2YWx1ZXMgb2Ygb25lIHRpbWVzbG90ICovCiAgQ19BTExPQ19TQ1JBVENIX1NUQVJUKGh5YnJpZ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bWYgZmlsdGVyYmFuayB2YWx1ZXMgICAgICAgICAgICAgICAgICAgICAgICAgKi8KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlJbnRCdWZmZXJMZWZ0W0hZQlJJRF9GSUxURVJfREVMQVldLCAvKiBxbWYgZmlsdGVyYmFuayB2YWx1ZXMgICAgICAgICAgICAgICAgICAgICAgICAgKi8KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGh5YnJpZFJlYWxMZWZ0LCAgICAgICAgICAgICAgICAgICAgICAvKiBoeWJyaWQgZmlsdGVyYmFuayB2YWx1ZXMgICAgICAgICAgICAgICAgICAgICAgKi8KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGh5YnJpZEltYWdMZWZ0LCAgICAgICAgICAgICAgICAgICAgICAvKiBoeWJyaWQgZmlsdGVyYmFuayB2YWx1ZXMgICAgICAgICAgICAgICAgICAgICAgKi8KICAgICAgICAgICAgICAgICAgICAgICAgICAgJmhfcHNfZC0+c3BlY2lmaWNUby5tcGVnLmh5YnJpZCk7ICAgICAgICAgIC8qIGh5YnJpZCBmaWx0ZXJiYW5rIGhhbmRsZSAgICAgICAgICAgICAgICAgICAgICAqLwoKCiAgU0NIQVIgaHlicmlkU2NhbCA9IGhfcHNfZC0+c3BlY2lmaWNUby5tcGVnLmh5YnJpZC5zZl9tUW1mQnVmZmVyOwoKCiAgLyohCiAgRGVjb3JyZWxhdGlvbjoKICBCeSBtZWFucyBvZiBhbGwtcGFzcyBmaWx0ZXJpbmcgYW5kIGRlbGF5aW5nLCB0aGUgKHN1Yi0pc3ViLWJhbmQgc2FtcGxlcyBzX2sobikgYXJlCiAgY29udmVydGVkIGludG8gZGUtY29ycmVsYXRlZCAoc3ViLSlzdWItYmFuZCBzYW1wbGVzIGRfayhuKS4KICAtIGs6IGZyZXF1ZW5jeSBpbiBoeWJyaWQgc3BlY3RydW0KICAtIG46IHRpbWUgaW5kZXgKICAqLwoKICBkZUNvcnJlbGF0ZVNsb3RCYXNlZCggaF9wc19kLCAgICAgICAgICAgICAgLyogcGFyYW1ldHJpYyBzdGVyZW8gZGVjb2RlciBoYW5kbGUgICAgICAgKi8KICAgICAgICAgICAgICAgICAgICAgICAgaHlicmlkUmVhbExlZnQsICAgICAgLyogbGVmdCBoeWJyaWQgdGltZSBzbG90ICAgICAgICAgICAgICAgICAgKi8KICAgICAgICAgICAgICAgICAgICAgICAgaHlicmlkSW1hZ0xlZnQsCiAgICAgICAgICAgICAgICAgICAgICAgIGh5YnJpZFNjYWwsICAgICAgLyogc2NhbGUgZmFjdG9yIG9mIGxlZnQgaHlicmlkIHRpbWUgc2xvdCAgKi8KICAgICAgICAgICAgICAgICAgICAgICAgckludEJ1ZmZlckxlZnRbMF0sICAgLyogbGVmdCBxbWYgdGltZSBzbG90ICAgICAgICAgICAgICAgICAgICAgKi8KICAgICAgICAgICAgICAgICAgICAgICAgaUludEJ1ZmZlckxlZnRbMF0sCiAgICAgICAgICAgICAgICAgICAgICAgIHNmX0ludEJ1ZmZlciwgICAgICAgIC8qIHNjYWxlIGZhY3RvciBvZiBsZWZ0IGFuZCByaWdodCBxbWYgdGltZSBzbG90ICovCiAgICAgICAgICAgICAgICAgICAgICAgIGh5YnJpZFJlYWxSaWdodCwgICAgIC8qIHJpZ2h0IGh5YnJpZCB0aW1lIHNsb3QgICAgICAgICAgICAgICAgICovCiAgICAgICAgICAgICAgICAgICAgICAgIGh5YnJpZEltYWdSaWdodCwKICAgICAgICAgICAgICAgICAgICAgICAgckludEJ1ZmZlclJpZ2h0LCAgICAgLyogcmlnaHQgcW1mIHRpbWUgc2xvdCAgICAgICAgICAgICAgICAgICAgKi8KICAgICAgICAgICAgICAgICAgICAgICAgaUludEJ1ZmZlclJpZ2h0ICk7CgoKCiAgLyohCiAgU3RlcmVvIFByb2Nlc3Npbmc6CiAgVGhlIHNldHMgb2YgKHN1Yi0pc3ViLWJhbmQgc2FtcGxlcyBzX2sobikgYW5kIGRfayhuKSBhcmUgcHJvY2Vzc2VkIGFjY29yZGluZyB0bwogIHRoZSBzdGVyZW8gY3VlcyB3aGljaCBhcmUgZGVmaW5lZCBwZXIgc3RlcmVvIGJhbmQuCiAgKi8KCgogIGFwcGx5U2xvdEJhc2VkUm90YXRpb24oIGhfcHNfZCwgICAgICAgICAgICAvKiBwYXJhbWV0cmljIHN0ZXJlbyBkZWNvZGVyIGhhbmRsZSAgICAgICAqLwogICAgICAgICAgICAgICAgICAgICAgICAgIGh5YnJpZFJlYWxMZWZ0LCAgICAvKiBsZWZ0IGh5YnJpZCB0aW1lIHNsb3QgICAgICAgICAgICAgICAgICAqLwogICAgICAgICAgICAgICAgICAgICAgICAgIGh5YnJpZEltYWdMZWZ0LAogICAgICAgICAgICAgICAgICAgICAgICAgIHJJbnRCdWZmZXJMZWZ0WzBdLCAvKiBsZWZ0IHFtZiB0aW1lIHNsb3QgICAgICAgICAgICAgICAgICAgICAqLwogICAgICAgICAgICAgICAgICAgICAgICAgIGlJbnRCdWZmZXJMZWZ0WzBdLAogICAgICAgICAgICAgICAgICAgICAgICAgIGh5YnJpZFJlYWxSaWdodCwgICAvKiByaWdodCBoeWJyaWQgdGltZSBzbG90ICAgICAgICAgICAgICAgICAqLwogICAgICAgICAgICAgICAgICAgICAgICAgIGh5YnJpZEltYWdSaWdodCwKICAgICAgICAgICAgICAgICAgICAgICAgICBySW50QnVmZmVyUmlnaHQsICAgLyogcmlnaHQgcW1mIHRpbWUgc2xvdCAgICAgICAgICAgICAgICAgICAgKi8KICAgICAgICAgICAgICAgICAgICAgICAgICBpSW50QnVmZmVyUmlnaHQgKTsKCgoKCiAgLyohCiAgSHlicmlkIHN5bnRoZXNpcyBmaWx0ZXJiYW5rOgogIFRoZSBzdGVyZW8gcHJvY2Vzc2VkIGh5YnJpZCBzdWJiYW5kIHNpZ25hbHMgbF9rKG4pIGFuZCByX2sobikgYXJlIGZlZCBpbnRvIHRoZSBoeWJyaWQgc3ludGhlc2lzCiAgZmlsdGVyYmFua3Mgd2hpY2ggYXJlIGlkZW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ogIFxyZXR1cm4KCioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCgpzdGF0aWMgdm9pZCBhc3NpZ25UaW1lU2xvdHNQUyAoRklYUF9EQkwgKmJ1ZkFkciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZJWFBfREJMICoqYnVmUHRyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW50IG51bVNsb3RzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW50IG51bUNoYW4pCnsKICBGSVhQX0RCTCAgKnB0cjsKICBpbnQgc2xvdDsKICBwdHIgPSBidWZBZHI7CiAgZm9yKHNsb3Q9MDsgc2xvdCA8IG51bVNsb3RzOyBzbG90KyspIHsKICAgYnVmUHRyIFtzbG90XSA9IHB0cjsKICAgIHB0ciArPSBudW1DaGFuOwogIH0KfQoK