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B8IFNNUF9WQUxfRkVfUkVRX0NOVCB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9GRV9IUlFfSERSIHwgU01QX1ZBTF9GRV9IUlFfQkRZIHwgU01QX1ZBTF9GRV9TRVRfQkNLIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX0JFX1JFUV9DTlQgfCBTTVBfVkFMX0JFX0hSUV9IRFIgfCBTTVBfVkFMX0JFX0hSUV9CRFkgfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfQkVfU0VUX1NSViB8IFNNUF9WQUxfQkVfU1JWX0NPTiB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfX19fX19fX19fXyksCgoJW1NNUF9TUkNfSFJRSFZdID0gKFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfRkVfUkVRX0NOVCB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9GRV9IUlFfSERSIHwgU01QX1ZBTF9GRV9IUlFfQkRZIHwgU01QX1ZBTF9GRV9TRVRfQkNLIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX0JFX1JFUV9DTlQgfCBTTVBfVkFMX0JFX0hSUV9IRFIgfCBTTVBfVkFMX0JFX0hSUV9CRFkgfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfQkVfU0VUX1NSViB8IFNNUF9WQUxfQkVfU1JWX0NPTiB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfX19fX19fX19fXyksCgoJW1NNUF9TUkNfSFJRSFBdID0gKFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfRkVfUkVRX0NOVCB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9GRV9IUlFfSERSIHwgU01QX1ZBTF9GRV9IUlFfQkRZIHwgU01QX1ZBTF9GRV9TRVRfQkNLIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX0JFX1JFUV9DTlQgfCBTTVBfVkFMX0JFX0hSUV9IRFIgfCBTTVBfVkFMX0JFX0hSUV9CRFkgfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfQkVfU0VUX1NSViB8IFNNUF9WQUxfQkVfU1JWX0NPTiB8IFNNUF9WQUxfQkVfUkVTX0NOVCB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9CRV9IUlNfSERSIHwgU01QX1ZBTF9CRV9IUlNfQkRZIHwgU01QX1ZBTF9CRV9TVE9fUlVMIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX0ZFX1JFU19DTlQgfCBTTVBfVkFMX0ZFX0hSU19IRFIgfCBTTVBfVkFMX0ZFX0hSU19CRFkgfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfRkVfTE9HX0VORCksCgoJW1NNUF9TUkNfSFJRQk9dID0gKFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9GRV9IUlFfQkRZIHwgU01QX1ZBTF9GRV9TRVRfQkNLIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX0JFX1JFUV9DTlQgfCBTTVBfVkFMX0JFX0hSUV9IRFIgfCBTTVBfVkFMX0JFX0hSUV9CRFkgfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfQkVfU0VUX1NSViB8IFNNUF9WQUxfQkVfU1JWX0NPTiB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfX19fX19fX19fXyksCgoJW1NNUF9TUkNfQktFTkRdID0gKFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX0JFX1JFUV9DTlQgfCBTTVBfVkFMX0JFX0hSUV9IRFIgfCBTTVBfVkFMX0JFX0hSUV9CRFkgfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfQkVfU0VUX1NSViB8IFNNUF9WQUxfQkVfU1JWX0NPTiB8IFNNUF9WQUxfQkVfUkVTX0NOVCB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9CRV9IUlNfSERSIHwgU01QX1ZBTF9CRV9IUlNfQkRZIHwgU01QX1ZBTF9CRV9TVE9fUlVMIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX0ZFX1JFU19DTlQgfCBTTVBfVkFMX0ZFX0hSU19IRFIgfCBTTVBfVkFMX0ZFX0hSU19CRFkgfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfRkVfTE9HX0VORCksCgoJW1NNUF9TUkNfU0VSVlJdID0gKFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfQkVfU1JWX0NPTiB8IFNNUF9WQUxfQkVfUkVTX0NOVCB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9CRV9IUlNfSERSIHwgU01QX1ZBTF9CRV9IUlNfQkRZIHwgU01QX1ZBTF9CRV9TVE9fUlVMIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX0ZFX1JFU19DTlQgfCBTTVBfVkFMX0ZFX0hSU19IRFIgfCBTTVBfVkFMX0ZFX0hSU19CRFkgfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfRkVfTE9HX0VORCksCgoJW1NNUF9TUkNfTDRTUlZdID0gKFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfQkVfUkVTX0NOVCB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9CRV9IUlNfSERSIHwgU01QX1ZBTF9CRV9IUlNfQkRZIHwgU01QX1ZBTF9CRV9TVE9fUlVMIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX0ZFX1JFU19DTlQgfCBTTVBfVkFMX0ZFX0hSU19IRFIgfCBTTVBfVkFMX0ZFX0hSU19CRFkgfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfRkVfTE9HX0VORCksCgoJW1NNUF9TUkNfTDVTUlZdID0gKFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfQkVfUkVTX0NOVCB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9CRV9IUlNfSERSIHwgU01QX1ZBTF9CRV9IUlNfQkRZIHwgU01QX1ZBTF9CRV9TVE9fUlVMIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX0ZFX1JFU19DTlQgfCBTTVBfVkFMX0ZFX0hSU19IRFIgfCBTTVBfVkFMX0ZFX0hSU19CRFkgfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfRkVfTE9HX0VORCksCgoJW1NNUF9TUkNfTDZSRVNdID0gKFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfQkVfUkVTX0NOVCB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9CRV9IUlNfSERSIHwgU01QX1ZBTF9CRV9IUlNfQkRZIHwgU01QX1ZBTF9CRV9TVE9fUlVMIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX0ZFX1JFU19DTlQgfCBTTVBfVkFMX0ZFX0hSU19IRFIgfCBTTVBfVkFMX0ZFX0hSU19CRFkgfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfX19fX19fX19fXyksCgoJW1NNUF9TUkNfSFJTSFZdID0gKFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfQkVfUkVTX0NOVCB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9CRV9IUlNfSERSIHwgU01QX1ZBTF9CRV9IUlNfQkRZIHwgU01QX1ZBTF9CRV9TVE9fUlVMIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX0ZFX1JFU19DTlQgfCBTTVBfVkFMX0ZFX0hSU19IRFIgfCBTTVBfVkFMX0ZFX0hSU19CRFkgfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfX19fX19fX19fXyksCgoJW1NNUF9TUkNfSFJTSFBdID0gKFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfQkVfUkVTX0NOVCB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9CRV9IUlNfSERSIHwgU01QX1ZBTF9CRV9IUlNfQkRZIHwgU01QX1ZBTF9CRV9TVE9fUlVMIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX0ZFX1JFU19DTlQgfCBTTVBfVkFMX0ZFX0hSU19IRFIgfCBTTVBfVkFMX0ZFX0hSU19CRFkgfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfRkVfTE9HX0VORCksCgoJW1NNUF9TUkNfSFJTQk9dID0gKFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9CRV9IUlNfQkRZIHwgU01QX1ZBTF9CRV9TVE9fUlVMIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX0ZFX1JFU19DTlQgfCBTTVBfVkFMX0ZFX0hSU19IRFIgfCBTTVBfVkFMX0ZFX0hSU19CRFkgfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfX19fX19fX19fXyksCgoJW1NNUF9TUkNfUlFGSU5dID0gKFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfRkVfTE9HX0VORCksCgoJW1NNUF9TUkNfUlNGSU5dID0gKFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfRkVfTE9HX0VORCksCgoJW1NNUF9TUkNfVFhGSU5dID0gKFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfRkVfTE9HX0VORCksCgoJW1NNUF9TUkNfU1NGSU5dID0gKFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8IFNNUF9WQUxfX19fX19fX19fXyB8CgkgICAgICAgICAgICAgICAgICAgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwgU01QX1ZBTF9fX19fX19fX19fIHwKCSAgICAgICAgICAgICAgICAgICBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfCBTTVBfVkFMX19fX19fX19fX18gfAoJICAgICAgICAgICAgICAgICAgIFNNUF9WQUxfRkVfTE9HX0VORCksCn07CgpzdGF0aWMgY29uc3QgY2hhciAqZmV0Y2hfc3JjX25hbWVzW1NNUF9TUkNfRU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CAmc21wLT5kYXRhLmlwdjYsIGNoay0+bGVuKTsKCX0KCWVsc2UKCQlyZXR1cm4gMDsKCglzbXAtPmRhdGEuc3RyID0gKmNoazsKCXNtcC0+dHlwZSA9IFNNUF9UX0JJTjsKCXJldHVybiAxOwp9CgpzdGF0aWMgaW50IGNfaW50MmJpbihzdHJ1Y3Qgc2FtcGxlICpzbXApCnsKCXN0cnVjdCBjaHVuayAqY2hrID0gZ2V0X3RyYXNoX2NodW5rKCk7CgoJKih1bnNpZ25lZCBpbnQgKiljaGstPnN0ciA9IGh0b25sKHNtcC0+ZGF0YS51aW50KTsKCWNoay0+bGVuID0gNDsKCglzbXAtPmRhdGEuc3RyID0gKmNoazsKCXNtcC0+dHlwZSA9IFNNUF9UX0JJTjsKCXJldHVybiAxOwp9CgoKLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwovKiAgICAgIFNhbXBsZSBjYXN0cyBtYXRyaXg6ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICovCi8qICAgICAgICAgICBzYW1wbGVfY2FzdHNbZnJvbSB0eXBlXVt0byB0eXBlXSAgICAgICAgICAgICAgICAgICAgKi8KLyogICAgICAgICAgIE5VTEwgcG9pbnRlciB1c2VkIGZvciBpbXBvc3NpYmxlIHNhbXBsZSBjYXN0cyAgICAgICAqLwovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCgpzYW1wbGVfY2FzdF9mY3Qgc2FtcGxlX2Nhc3RzW1NNUF9UWVBFU11bU01QX1RZUEVTXSA9IHsKLyogICAgICAgICAgICB0bzogIEJPT0wgICAgICAgVUlOVCAgICAgICBTSU5UICAgICAgIEFERFIgICAgICAgIElQVjQgICAgICBJUFY2ICAgICAgICBTVFIgICAgICAgICBCSU4gICAgICAgICBNRVRIICovCi8qIGZyb206IEJPT0wgKi8geyBjX25vbmUsICAgIGNfbm9uZSwgICAgY19ub25lLCAgICBOVUxMLCAgICAgICBOVUxMLCAgICAgTlVMTCwgICAgICAgY19pbnQyc3RyLCAgTlVMTCwgICAgICAgTlVMTCwgICAgICAgfSwKLyogICAgICAgVUlOVCAqLyB7IGNfbm9uZSwgICAgY19ub25lLCAgICBjX25vbmUsICAgIGNfaW50MmlwLCAgIGNfaW50MmlwLCBOVUxMLCAgICAgICBjX2ludDJzdHIsICBjX2ludDJiaW4sICBOVUxMLCAgICAgICB9LAovKiAgICAgICBTSU5UICovIHsgY19ub25lLCAgICBjX25vbmUsICAgIGNfbm9uZSwgICAgY19pbnQyaXAsICAgY19pbnQyaXAsIE5VTEwsICAgICAgIGNfaW50MnN0ciwgIGNfaW50MmJpbiwgIE5VTEwsICAgICAgIH0sCi8qICAgICAgIEFERFIgKi8geyBOVUxMLCAgICAgIE5VTEwsICAgICAgTlVMTCwgICAgICBOVUxMLCAgICAgICBOVUxMLCAgICAgTlVMTCwgICAgICAgTlVMTCwgICAgICAgTlVMTCwgICAgICAgTlVMTCwgICAgICAgfSwKLyogICAgICAgSVBWNCAqLyB7IE5VTEwsICAgICAgY19pcDJpbnQsICBjX2lwMmludCwgIGNfbm9uZSwgICAgIGNfbm9uZSwgICBjX2lwMmlwdjYsICBjX2lwMnN0ciwgICBjX2FkZHIyYmluLCBOVUxMLCAgICAgICB9LAovKiAgICAgICBJUFY2ICovIHsgTlVMTCwgICAgICBOVUxMLCAgICAgIE5VTEwsICAgICAgY19ub25lLCAgICAgTlVMTCwgICAgIGNfbm9uZSwgICAgIGNfaXB2NjJzdHIsIGNfYWRkcjJiaW4sIE5VTEwsICAgICAgIH0sCi8qICAgICAgICBTVFIgKi8geyBjX3N0cjJpbnQsIGNfc3RyMmludCwgY19zdHIyaW50LCBjX3N0cjJhZGRyLCBjX3N0cjJpcCwgY19zdHIyaXB2NiwgY19ub25lLCAgICAgY19ub25lLCAgICAgY19zdHIybWV0aCwgfSwKLyogICAgICAgIEJJTiAq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EgQk9PTC4KICovCnN0YXRpYyBpbnQgc2FtcGxlX2NvbnZfYXJpdGhfb2RkKHN0cnVjdCBzZXNzaW9uICpzZXNzaW9uLCBjb25zdCBzdHJ1Y3QgYXJnICphcmdfcCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RydWN0IHNhbXBsZSAqc21wLCB2b2lkICpwcml2YXRlKQp7CglzbXAtPmRhdGEudWludCA9IHNtcC0+ZGF0YS51aW50ICYgMTsKCXNtcC0+dHlwZSA9IFNNUF9UX0JPT0w7CglyZXR1cm4gMTsKfQoKLyogVGFrZXMgYSBVSU5UIG9uIGlucHV0LCByZXR1cm5zIHRydWUgaXMgdGhlIHZhbHVlIGlzIGV2ZW4sIG90aGVyd2lzZSBmYWxzZS4KICogVGhlIG91dHB1dCBpcyBhIEJPT0wuCiAqLwpzdGF0aWMgaW50IHNhbXBsZV9jb252X2FyaXRoX2V2ZW4oc3RydWN0IHNlc3Npb24gKnNlc3Npb24sIGNvbnN0IHN0cnVjdCBhcmcgKmFyZ19wLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RydWN0IHNhbXBsZSAqc21wLCB2b2lkICpwcml2YXRlKQp7CglzbXAtPmRhdGEudWludCA9ICEoc21wLT5kYXRhLnVpbnQgJiAxKTsKCXNtcC0+dHlwZSA9IFNNUF9UX0JPT0w7CglyZXR1cm4gMTsKfQoKLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KLyogICAgICAgQWxsIHN1cHBvcnRlZCBzYW1wbGUgZmV0Y2ggZnVuY3Rpb25zIG11c3QgYmUgZGVjbGFyZWQgaGVyZSAgICAgKi8KLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KCi8qIGZvcmNlIFRSVUUgdG8gYmUgcmV0dXJuZWQgYXQgdGhlIGZldGNo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