I2RlZmluZSBfR05VX1NPVVJDRQ0KI2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3RkbGliLmg+DQojaW5jbHVkZSA8dW5pc3RkLmg+DQojaW5jbHVkZSA8c3RyaW5nLmg+DQojaW5jbHVkZSA8c3lzL3R5cGVzLmg+DQojaW5jbHVkZSA8c3lzL3N0YXQuaD4NCiNpbmNsdWRlIDxmY250bC5oPg0KI2luY2x1ZGUgPHN5cy92ZnMuaD4NCiNpbmNsdWRlIDxhc3NlcnQuaD4NCg0KDQojaW5jbHVkZSA8bXRkL210ZC1hYmkuaD4NCiNpbmNsdWRlIDxlcnJuby5oPg0KDQojaW5jbHVkZSA8c3lzL2lvY3RsLmg+DQojaW5jbHVkZSAiZnNfY2hlY2suaCINCiNpbmNsdWRlICJjZmdfYXBpLmgiDQojaW5jbHVkZSAicHViX2RlYnVnX2luZm8uaCINCg0KLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioNCiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICBNYWNybyBkZWZpbml0aW9ucyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqDQogKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLw0KI2RlZmluZSBNT1VOVFNfSU5GT19GSUxFCQkJCSIvcHJvYy9tb3VudHMiDQoNCiNkZWZpbmUgTlZfRlNfRkFDX01BSU5fUEFUSCAgICAgICAgIAkiL21udC9pbWFnZWZzL252cndhbGwuYmluIg0KI2RlZmluZSBOVl9GU19SV19IQVNIX0ZBQ19QQVRIICAgICAJCSIvbW50L2ltYWdlZnMvbnZyd2FsbC5oYXNoIg0KI2RlZmluZSBOVl9GU19SV19UT1BfUEFUSCAgICAgICAJCSIvZXRjX3J3L3BzbnYiDQojZGVmaW5lIE5WX0ZTX1JXX0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ywgIndyaXRlICVzIGZhaWxlZCBlcnJubyAlZFxuIiwgZnNja25hbWUsIGVycm5vKTsNCiAgICAgICAgICAgICAgICByZXQgPSAtMTsNCiAgICAgICAgICAgICAgICBicmVhazsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfQ0KICAgICAgICBwdHIgKz0gcmVzOw0KICAgICAgICBsZW4gLT0gcmVzOw0KICAgIH0NCg0KICAgIA0KICAgIGlmIChjbG9zZShmZCkgPCAwKQ0KICAgIHsNCiAgICAgICAgcHJpbnRmKCJjbG9zZSAlcyBmYWlsZWQgZXJybm8gJWRcbiIsIGZzY2tuYW1lLCBlcnJubyk7DQoJCXNjX2RlYnVnX2luZm9fcmVjb3JkKE1PRFVMRV9JRF9BUF9GU19DSEVDSywgImNsb3NlICVzIGZhaWxlZCBlcnJubyAlZFxuIiwgZnNja25hbWUsIGVycm5vKTsNCiAgICAgICAgcmV0dXJuIC0xOw0KICAgIH0NCiAgICByZXR1cm4gcmV0Ow0KfQ0KDQovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioNCioguq/K/cP7s8ajuiBjaGVja191c2VyZGF0YV9pc19ub3JtYWwNCioguabE3MPoyvajuiC87LLpdXNlcmRhdGG31sf4z8LD5rXEzsS8/srHt/HV/bOjo6zI57n7tObU2tLss6OjrNTy0OjSqtbY0MK71ri0dXNlcmRhdGG31sf4DQoqILLOyv3LtcP3o7ogKElOKQ0KKiAgICAgICAgICAgIGRzdF9maWxlOiAgxL+x6s7EvP4NCiogICAgICAgICAgICBzcmNfZmlsZTogINS0zsS8/g0KKiAgICAgICAgICAgIChPVVQpDQoqILe1ILvYINa1o7q87LLp1f2zo7e1u9gwLCDQ6NKq1tjQwrvWuLS31sf4t7W72C0xDQoqIMbky/zLtcP3o7oNCioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqK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